[Git][ghc/ghc][master] AArch64: Implement takeRegRegMoveInstr
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Sun Sep 8 18:19:12 UTC 2024
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
573f9833 by Sven Tennie at 2024-09-08T09:58:21+00:00
AArch64: Implement takeRegRegMoveInstr
This has likely been forgotten.
- - - - -
1 changed file:
- compiler/GHC/CmmToAsm/AArch64/Instr.hs
Changes:
=====================================
compiler/GHC/CmmToAsm/AArch64/Instr.hs
=====================================
@@ -30,6 +30,7 @@ import GHC.Utils.Panic
import Data.Maybe (fromMaybe)
import GHC.Stack
+import GHC.Platform.Reg.Class
-- | LR and FP (8 byte each) are the prologue of each stack frame
stackFrameHeaderSize :: Int
@@ -454,10 +455,22 @@ isMetaInstr instr
mkRegRegMoveInstr :: Reg -> Reg -> Instr
mkRegRegMoveInstr src dst = ANN (text "Reg->Reg Move: " <> ppr src <> text " -> " <> ppr dst) $ MOV (OpReg W64 dst) (OpReg W64 src)
--- | Take the source and destination from this reg -> reg move instruction
--- or Nothing if it's not one
+-- | Take the source and destination registers from a move instruction of same
+-- register class (`RegClass`).
+--
+-- The idea is to identify moves that can be eliminated by the register
+-- allocator: If the source register serves no special purpose, one could
+-- continue using it; saving one move instruction. For this, the register kinds
+-- (classes) must be the same (no conversion involved.)
takeRegRegMoveInstr :: Instr -> Maybe (Reg,Reg)
---takeRegRegMoveInstr (MOV (OpReg fmt dst) (OpReg fmt' src)) | fmt == fmt' = Just (src, dst)
+takeRegRegMoveInstr (MOV (OpReg _fmt dst) (OpReg _fmt' src))
+ | classOfReg dst == classOfReg src = pure (src, dst)
+ where
+ classOfReg ::Reg -> RegClass
+ classOfReg reg
+ = case reg of
+ RegVirtual vr -> classOfVirtualReg vr
+ RegReal rr -> classOfRealReg rr
takeRegRegMoveInstr _ = Nothing
-- | Make an unconditional jump instruction.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/573f9833a7c56bf8fd8c6731069a7160541e5287
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/573f9833a7c56bf8fd8c6731069a7160541e5287
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/20240908/1244845b/attachment-0001.html>
More information about the ghc-commits
mailing list