[Git][ghc/ghc][wip/T14586] Add Meta instructions.

dmjio gitlab at gitlab.haskell.org
Thu Jun 25 14:59:52 UTC 2020



dmjio pushed to branch wip/T14586 at Glasgow Haskell Compiler / GHC


Commits:
9737b347 by David Johnson at 2020-06-25T10:59:33-04:00
Add Meta instructions.

- - - - -


2 changed files:

- compiler/GHC/CmmToAsm/ARM/Instr.hs
- compiler/GHC/CmmToAsm/ARM/Ppr.hs


Changes:

=====================================
compiler/GHC/CmmToAsm/ARM/Instr.hs
=====================================
@@ -2,10 +2,11 @@ module GHC.CmmToAsm.ARM.Instr where
 
 import GHC.Cmm
 import GHC.Cmm.BlockId
+import GHC.Cmm.CLabel
 import GHC.Cmm.Dataflow.Label
 import GHC.CmmToAsm.Config
 import GHC.CmmToAsm.Instr
-import GHC.Cmm.CLabel
+import GHC.Data.FastString
 import GHC.Platform
 import GHC.Platform.Reg
 import GHC.Prelude
@@ -36,7 +37,27 @@ data RI
     | RIImm Imm
 
 data Instr
-  = Add Reg Reg RI
+  -- comment pseudo-op
+  = COMMENT FastString
+
+  -- location pseudo-op (file, line, col, name)
+  | LOCATION Int Int Int String
+
+  -- some static data spat out during code
+  -- generation.  Will be extracted before
+  -- pretty-printing.
+  | LDATA   Section RawCmmStatics
+
+  -- start a new basic block.  Useful during
+  -- codegen, removed later.  Preceding
+  -- instruction should be a jump, as per the
+  -- invariants for a BasicBlock (see Cmm).
+  | NEWBLOCK BlockId
+
+  -- specify current stack offset for
+  -- benefit of subsequent passes
+  | DELTA   Int
+
 
 instance Instruction Instr where
   regUsageOfInstr         = arm_regUsageOfInstr
@@ -79,7 +100,14 @@ arm_takeDeltaInstr :: Instr -> Maybe Int
 arm_takeDeltaInstr = undefined
 
 arm_isMetaInstr :: Instr -> Bool
-arm_isMetaInstr = undefined
+arm_isMetaInstr instr =
+ case instr of
+   COMMENT{}   -> True
+   LOCATION{}  -> True
+   LDATA{}     -> True
+   NEWBLOCK{}  -> True
+   DELTA{}     -> True
+   _           -> False
 
 arm_mkRegRegMoveInstr :: Reg -> Reg -> Instr
 arm_mkRegRegMoveInstr = undefined


=====================================
compiler/GHC/CmmToAsm/ARM/Ppr.hs
=====================================
@@ -1,6 +1,7 @@
 module GHC.CmmToAsm.ARM.Ppr (pprNatCmmDecl) where
 
 import GHC.Prelude
+import GHC.Platform
 import GHC.CmmToAsm.Config
 import GHC.CmmToAsm.Instr
 import GHC.CmmToAsm.ARM.Instr
@@ -13,3 +14,23 @@ pprNatCmmDecl
   -> SDoc
 pprNatCmmDecl = undefined
 
+pprInstr :: Platform -> Instr -> SDoc
+pprInstr _ instr = case instr of
+   COMMENT s
+      -> asmComment (ftext s)
+
+   LOCATION file line col _name
+      -> text "\t.loc " <> ppr file <+> ppr line <+> ppr col
+
+   DELTA d
+      -> asmComment $ text ("\tdelta = " ++ show d)
+
+   NEWBLOCK _
+      -> panic "pprInstr: NEWBLOCK"
+
+   LDATA _ _
+      -> panic "pprInstr: LDATA"
+
+asmComment :: SDoc -> SDoc
+asmComment c = whenPprDebug $ text "# " <> c
+



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9737b347ecbf59adb82401659da8587f3e2a5a1a

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9737b347ecbf59adb82401659da8587f3e2a5a1a
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/20200625/01e74a35/attachment-0001.html>


More information about the ghc-commits mailing list