diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2020-09-02 19:42:01 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-09-17 20:04:08 -0400 |
commit | ca48076ae866665913b9c81cbc0c76f0afef7a00 (patch) | |
tree | 52ad46e313b99fc564bd77de2efeb0bfb8babb47 /compiler/GHC/CmmToAsm/SPARC/CodeGen/Sanity.hs | |
parent | 9dec8600ad4734607bea2b4dc3b40a5af788996b (diff) | |
download | haskell-ca48076ae866665913b9c81cbc0c76f0afef7a00.tar.gz |
Introduce OutputableP
Some types need a Platform value to be pretty-printed: CLabel, Cmm
types, instructions, etc.
Before this patch they had an Outputable instance and the Platform value
was obtained via sdocWithDynFlags. It meant that the *renderer* of the
SDoc was responsible of passing the appropriate Platform value (e.g. via
the DynFlags given to showSDoc). It put the burden of passing the
Platform value on the renderer while the generator of the SDoc knows the
Platform it is generating the SDoc for and there is no point passing a
different Platform at rendering time.
With this patch, we introduce a new OutputableP class:
class OutputableP a where
pdoc :: Platform -> a -> SDoc
With this class we still have some polymorphism as we have with `ppr`
(i.e. we can use `pdoc` on a variety of types instead of having a
dedicated `pprXXX` function for each XXX type).
One step closer removing `sdocWithDynFlags` (#10143) and supporting
several platforms (#14335).
Diffstat (limited to 'compiler/GHC/CmmToAsm/SPARC/CodeGen/Sanity.hs')
-rw-r--r-- | compiler/GHC/CmmToAsm/SPARC/CodeGen/Sanity.hs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/compiler/GHC/CmmToAsm/SPARC/CodeGen/Sanity.hs b/compiler/GHC/CmmToAsm/SPARC/CodeGen/Sanity.hs index 4bbb3e3823..2284c4cb81 100644 --- a/compiler/GHC/CmmToAsm/SPARC/CodeGen/Sanity.hs +++ b/compiler/GHC/CmmToAsm/SPARC/CodeGen/Sanity.hs @@ -7,6 +7,7 @@ module GHC.CmmToAsm.SPARC.CodeGen.Sanity ( where import GHC.Prelude +import GHC.Platform import GHC.CmmToAsm.SPARC.Instr import GHC.CmmToAsm.SPARC.Ppr () -- For Outputable instances @@ -20,11 +21,12 @@ import GHC.Utils.Panic -- | Enforce intra-block invariants. -- -checkBlock :: CmmBlock +checkBlock :: Platform + -> CmmBlock -> NatBasicBlock Instr -> NatBasicBlock Instr -checkBlock cmm block@(BasicBlock _ instrs) +checkBlock platform cmm block@(BasicBlock _ instrs) | checkBlockInstrs instrs = block @@ -32,9 +34,9 @@ checkBlock cmm block@(BasicBlock _ instrs) = pprPanic ("SPARC.CodeGen: bad block\n") ( vcat [ text " -- cmm -----------------\n" - , ppr cmm + , pdoc platform cmm , text " -- native code ---------\n" - , ppr block ]) + , pdoc platform block ]) checkBlockInstrs :: [Instr] -> Bool |