[Git][ghc/ghc][wip/supersven/riscv64-ncg] Implement MO_UU_Conv
Sven Tennie (@supersven)
gitlab at gitlab.haskell.org
Fri Jul 7 15:46:07 UTC 2023
Sven Tennie pushed to branch wip/supersven/riscv64-ncg at Glasgow Haskell Compiler / GHC
Commits:
d71ea641 by Sven Tennie at 2023-07-06T20:06:42+02:00
Implement MO_UU_Conv
Expect zero extended (!) register. If the source Width is smaller or
equal to the target Width just move (copy) the value. Otherwise (target
Width is smaller), truncate it.
We don't need to care about sign-extension, as this mach op is unsigned.
- - - - -
1 changed file:
- compiler/GHC/CmmToAsm/RV64/CodeGen.hs
Changes:
=====================================
compiler/GHC/CmmToAsm/RV64/CodeGen.hs
=====================================
@@ -611,15 +611,16 @@ getRegister' config plat expr =
signExtendAdjustPrecission W32 to dst dst) -- (float convert (-> zero) signed)
MO_FS_Conv from to -> pure $ Any (intFormat to) (\dst -> code `snocOL` annExpr expr (FCVTZS (OpReg to dst) (OpReg from reg))) -- (float convert (-> zero) signed)
- -- TODO this is very slow. We effectively use store + load (byte, half, word, double)
- -- for this in memory.
- MO_UU_Conv from to -> return $ Any (intFormat to) (\dst ->
- code `appOL` toOL [ SUB sp sp (OpImm (ImmInt 8))
- , STR (intFormat from) (OpReg from reg) (OpAddr (AddrRegImm sp_reg (ImmInt 0)))
- , LDR (intFormat to) (OpReg to dst) (OpAddr (AddrRegImm sp_reg (ImmInt 0)))
- , ADD sp sp (OpImm (ImmInt 8))
- ])
- -- MO_UU_Conv from to -> return $ Any (intFormat to) (\dst -> code `snocOL` UBFM (OpReg (max from to) dst) (OpReg (max from to) reg) (OpImm (ImmInt 0)) (toImm (min from to)))
+ MO_UU_Conv from to | from <= to -> pure $ Any (intFormat to) (\dst ->
+ code `snocOL`
+ annExpr e (MOV (OpReg to dst) (OpReg from reg))
+ )
+
+ MO_UU_Conv from to -> pure $ Any (intFormat to) (\dst ->
+ code `snocOL`
+ annExpr e (MOV (OpReg from dst) (OpReg from reg)) `appOL`
+ truncateReg from to dst
+ )
MO_SS_Conv from to -> ss_conv from to reg code
MO_FF_Conv from to -> return $ Any (floatFormat to) (\dst -> code `snocOL` FCVT (OpReg to dst) (OpReg from reg))
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d71ea641f81c980dc3be0e7a458bdbab5c7c4108
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d71ea641f81c980dc3be0e7a458bdbab5c7c4108
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/20230707/39e69f61/attachment-0001.html>
More information about the ghc-commits
mailing list