[Git][ghc/ghc][wip/supersven/riscv64-ncg] Fix loading 12bit < imm <= 32bit immediates

Sven Tennie (@supersven) gitlab at gitlab.haskell.org
Wed Aug 2 16:29:49 UTC 2023



Sven Tennie pushed to branch wip/supersven/riscv64-ncg at Glasgow Haskell Compiler / GHC


Commits:
265bb433 by Sven Tennie at 2023-08-02T18:24:49+02:00
Fix loading 12bit < imm <= 32bit immediates

The prior version sign extended the immediate.

- - - - -


1 changed file:

- compiler/GHC/CmmToAsm/RV64/Ppr.hs


Changes:

=====================================
compiler/GHC/CmmToAsm/RV64/Ppr.hs
=====================================
@@ -532,11 +532,11 @@ pprInstr platform instr = case instr of
     | (OpImm (ImmInteger i)) <- o2
     , fitsIn32bits i
         -> lines_ [ text "\tlui" <+> pprOp platform o1 <> comma <+> text "%hi(" <> pprOp platform o2 <> text ")"
-                                             , text "\taddi" <+> pprOp platform o1 <> comma <+> pprOp platform o1 <> comma <+> text "%lo(" <> pprOp platform o2 <> text ")" ]
+                                             , text "\taddw" <+> pprOp platform o1 <> comma <+> pprOp platform o1 <> comma <+> text "%lo(" <> pprOp platform o2 <> text ")" ]
     | (OpImm (ImmInt i)) <- o2
     , fitsIn32bits i
         -> lines_ [ text "\tlui" <+> pprOp platform o1 <> comma <+> text "%hi(" <> pprOp platform o2 <> text ")"
-                                             , text "\taddi" <+> pprOp platform o1 <> comma <+> pprOp platform o1 <> comma <+> text "%lo(" <> pprOp platform o2 <> text ")" ]
+                                             , text "\taddw" <+> pprOp platform o1 <> comma <+> pprOp platform o1 <> comma <+> text "%lo(" <> pprOp platform o2 <> text ")" ]
     | isImmOp o2
         -- Surrender! Let the assembler figure out the right expressions with pseudo-op LI.
         -> lines_ [ text "\tli" <+> pprOp platform o1 <> comma <+>  pprOp platform o2 ]



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/265bb433fd78d8ff21026ee0894e1468a5974071

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/265bb433fd78d8ff21026ee0894e1468a5974071
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230802/9a2c97e1/attachment-0001.html>


More information about the ghc-commits mailing list