summaryrefslogtreecommitdiff
path: root/compiler/GHC/CmmToAsm/SPARC
diff options
context:
space:
mode:
authorBenjamin Maurer <maurer.benjamin@gmail.com>2021-09-21 20:25:34 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-09-29 09:42:41 -0400
commit5cc4bd574720fd97d877d702cbafa453434f035e (patch)
tree737560ef4b45170a7e48ad03867f5588ad2b8525 /compiler/GHC/CmmToAsm/SPARC
parent361da88a29af9005135d33e00fc61ba92c592970 (diff)
downloadhaskell-5cc4bd574720fd97d877d702cbafa453434f035e.tar.gz
Rectifying COMMENT and `mkComment` across platforms to work with SDoc
and exhibit similar behaviors. Issue 20400
Diffstat (limited to 'compiler/GHC/CmmToAsm/SPARC')
-rw-r--r--compiler/GHC/CmmToAsm/SPARC/CodeGen.hs3
-rw-r--r--compiler/GHC/CmmToAsm/SPARC/Instr.hs4
-rw-r--r--compiler/GHC/CmmToAsm/SPARC/Ppr.hs9
3 files changed, 10 insertions, 6 deletions
diff --git a/compiler/GHC/CmmToAsm/SPARC/CodeGen.hs b/compiler/GHC/CmmToAsm/SPARC/CodeGen.hs
index aeaaf1c9d3..ae8ee37cf9 100644
--- a/compiler/GHC/CmmToAsm/SPARC/CodeGen.hs
+++ b/compiler/GHC/CmmToAsm/SPARC/CodeGen.hs
@@ -53,6 +53,7 @@ import GHC.CmmToAsm.CPrim
import GHC.Types.Basic
import GHC.Data.FastString
import GHC.Data.OrdList
+import GHC.Utils.Outputable
import GHC.Utils.Panic
import GHC.Platform
@@ -125,7 +126,7 @@ stmtToInstrs stmt = do
platform <- getPlatform
config <- getConfig
case stmt of
- CmmComment s -> return (unitOL (COMMENT s))
+ CmmComment s -> return (unitOL (COMMENT $ ftext s))
CmmTick {} -> return nilOL
CmmUnwind {} -> return nilOL
diff --git a/compiler/GHC/CmmToAsm/SPARC/Instr.hs b/compiler/GHC/CmmToAsm/SPARC/Instr.hs
index a5c9e46936..6881b06de0 100644
--- a/compiler/GHC/CmmToAsm/SPARC/Instr.hs
+++ b/compiler/GHC/CmmToAsm/SPARC/Instr.hs
@@ -51,7 +51,7 @@ import GHC.Platform.Regs
import GHC.Cmm.CLabel
import GHC.Cmm.BlockId
import GHC.Cmm
-import GHC.Data.FastString
+import GHC.Utils.Outputable
import GHC.Utils.Panic
@@ -102,7 +102,7 @@ data Instr
-- meta ops --------------------------------------------------
-- comment pseudo-op
- = COMMENT FastString
+ = COMMENT SDoc
-- some static data spat out during code generation.
-- Will be extracted before pretty-printing.
diff --git a/compiler/GHC/CmmToAsm/SPARC/Ppr.hs b/compiler/GHC/CmmToAsm/SPARC/Ppr.hs
index b4028fe3b4..2b0d9675fd 100644
--- a/compiler/GHC/CmmToAsm/SPARC/Ppr.hs
+++ b/compiler/GHC/CmmToAsm/SPARC/Ppr.hs
@@ -56,7 +56,6 @@ import GHC.Types.Unique ( pprUniqueAlways )
import GHC.Utils.Outputable
import GHC.Utils.Panic
import GHC.Platform
-import GHC.Data.FastString
-- -----------------------------------------------------------------------------
-- Printing this stuff out
@@ -388,11 +387,15 @@ castFloatToWord8Array :: STUArray s Int Float -> ST s (STUArray s Int Word8)
castFloatToWord8Array = U.castSTUArray
+asmComment :: SDoc -> SDoc
+asmComment c = whenPprDebug $ text "#" <+> c
+
+
-- | Pretty print an instruction.
pprInstr :: Platform -> Instr -> SDoc
pprInstr platform = \case
- COMMENT _ -> empty -- nuke comments.
- DELTA d -> pprInstr platform (COMMENT (mkFastString ("\tdelta = " ++ show d)))
+ COMMENT s -> asmComment s
+ DELTA d -> asmComment $ text ("\tdelta = " ++ show d)
-- Newblocks and LData should have been slurped out before producing the .s file.
NEWBLOCK _ -> panic "X86.Ppr.pprInstr: NEWBLOCK"