summaryrefslogtreecommitdiff
path: root/compiler/cmm/PprCmm.hs
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2012-06-13 12:13:00 +0100
committerIan Lynagh <igloo@earth.li>2012-06-13 12:13:00 +0100
commitd06edb8e93d6d19bbd898e2b2e26755598bb11f3 (patch)
tree88a6adbbd663f1a575c8b6a4d67f55ffd806ea2d /compiler/cmm/PprCmm.hs
parent2901e3ff1acaea9689d38e65b58080d515215414 (diff)
downloadhaskell-d06edb8e93d6d19bbd898e2b2e26755598bb11f3.tar.gz
Remove PlatformOutputable
We can now get the Platform from the DynFlags inside an SDoc, so we no longer need to pass the Platform in.
Diffstat (limited to 'compiler/cmm/PprCmm.hs')
-rw-r--r--compiler/cmm/PprCmm.hs94
1 files changed, 47 insertions, 47 deletions
diff --git a/compiler/cmm/PprCmm.hs b/compiler/cmm/PprCmm.hs
index d32f129247..fd2efdf011 100644
--- a/compiler/cmm/PprCmm.hs
+++ b/compiler/cmm/PprCmm.hs
@@ -59,12 +59,12 @@ import Prelude hiding (succ)
instance Outputable CmmStackInfo where
ppr = pprStackInfo
-instance PlatformOutputable CmmTopInfo where
- pprPlatform = pprTopInfo
+instance Outputable CmmTopInfo where
+ ppr x = sdocWithPlatform $ \platform -> pprTopInfo platform x
-instance PlatformOutputable (CmmNode e x) where
- pprPlatform = pprNode
+instance Outputable (CmmNode e x) where
+ ppr x = sdocWithPlatform $ \platform -> pprNode platform x
instance Outputable Convention where
ppr = pprConvention
@@ -72,24 +72,24 @@ instance Outputable Convention where
instance Outputable ForeignConvention where
ppr = pprForeignConvention
-instance PlatformOutputable ForeignTarget where
- pprPlatform = pprForeignTarget
+instance Outputable ForeignTarget where
+ ppr x = sdocWithPlatform $ \platform -> pprForeignTarget platform x
-instance PlatformOutputable (Block CmmNode C C) where
- pprPlatform = pprBlock
-instance PlatformOutputable (Block CmmNode C O) where
- pprPlatform = pprBlock
-instance PlatformOutputable (Block CmmNode O C) where
- pprPlatform = pprBlock
-instance PlatformOutputable (Block CmmNode O O) where
- pprPlatform = pprBlock
+instance Outputable (Block CmmNode C C) where
+ ppr x = sdocWithPlatform $ \platform -> pprBlock platform x
+instance Outputable (Block CmmNode C O) where
+ ppr x = sdocWithPlatform $ \platform -> pprBlock platform x
+instance Outputable (Block CmmNode O C) where
+ ppr x = sdocWithPlatform $ \platform -> pprBlock platform x
+instance Outputable (Block CmmNode O O) where
+ ppr x = sdocWithPlatform $ \platform -> pprBlock platform x
-instance PlatformOutputable (Graph CmmNode e x) where
- pprPlatform = pprGraph
+instance Outputable (Graph CmmNode e x) where
+ ppr x = sdocWithPlatform $ \platform -> pprGraph platform x
-instance PlatformOutputable CmmGraph where
- pprPlatform platform = pprCmmGraph platform
+instance Outputable CmmGraph where
+ ppr g = sdocWithPlatform $ \platform -> pprCmmGraph platform g
----------------------------------------------------------
-- Outputting types Cmm contains
@@ -100,8 +100,8 @@ pprStackInfo (StackInfo {arg_space=arg_space, updfr_space=updfr_space}) =
ptext (sLit "updfr_space: ") <> ppr updfr_space
pprTopInfo :: Platform -> CmmTopInfo -> SDoc
-pprTopInfo platform (TopInfo {info_tbl=info_tbl, stack_info=stack_info}) =
- vcat [ptext (sLit "info_tbl: ") <> pprPlatform platform info_tbl,
+pprTopInfo _ (TopInfo {info_tbl=info_tbl, stack_info=stack_info}) =
+ vcat [ptext (sLit "info_tbl: ") <> ppr info_tbl,
ptext (sLit "stack_info: ") <> ppr stack_info]
----------------------------------------------------------
@@ -109,30 +109,30 @@ pprTopInfo platform (TopInfo {info_tbl=info_tbl, stack_info=stack_info}) =
pprBlock :: IndexedCO x SDoc SDoc ~ SDoc
=> Platform -> Block CmmNode e x -> IndexedCO e SDoc SDoc
-pprBlock platform block
- = foldBlockNodesB3 ( ($$) . pprPlatform platform
- , ($$) . (nest 4) . pprPlatform platform
- , ($$) . (nest 4) . pprPlatform platform
+pprBlock _ block
+ = foldBlockNodesB3 ( ($$) . ppr
+ , ($$) . (nest 4) . ppr
+ , ($$) . (nest 4) . ppr
)
block
empty
pprGraph :: Platform -> Graph CmmNode e x -> SDoc
pprGraph _ GNil = empty
-pprGraph platform (GUnit block) = pprPlatform platform block
-pprGraph platform (GMany entry body exit)
+pprGraph _ (GUnit block) = ppr block
+pprGraph _ (GMany entry body exit)
= text "{"
- $$ nest 2 (pprMaybeO entry $$ (vcat $ map (pprPlatform platform) $ bodyToBlockList body) $$ pprMaybeO exit)
+ $$ nest 2 (pprMaybeO entry $$ (vcat $ map ppr $ bodyToBlockList body) $$ pprMaybeO exit)
$$ text "}"
- where pprMaybeO :: PlatformOutputable (Block CmmNode e x)
+ where pprMaybeO :: Outputable (Block CmmNode e x)
=> MaybeO ex (Block CmmNode e x) -> SDoc
pprMaybeO NothingO = empty
- pprMaybeO (JustO block) = pprPlatform platform block
+ pprMaybeO (JustO block) = ppr block
pprCmmGraph :: Platform -> CmmGraph -> SDoc
-pprCmmGraph platform g
+pprCmmGraph _ g
= text "{" <> text "offset"
- $$ nest 2 (vcat $ map (pprPlatform platform) blocks)
+ $$ nest 2 (vcat $ map ppr blocks)
$$ text "}"
where blocks = postorderDfs g
@@ -154,24 +154,24 @@ pprForeignConvention :: ForeignConvention -> SDoc
pprForeignConvention (ForeignConvention c as rs) = ppr c <> ppr as <> ppr rs
pprForeignTarget :: Platform -> ForeignTarget -> SDoc
-pprForeignTarget platform (ForeignTarget fn c) = ppr_fc c <+> ppr_target fn
+pprForeignTarget _ (ForeignTarget fn c) = ppr_fc c <+> ppr_target fn
where ppr_fc :: ForeignConvention -> SDoc
ppr_fc (ForeignConvention c args res) =
doubleQuotes (ppr c) <+> text "arg hints: " <+> ppr args <+> text " result hints: " <+> ppr res
ppr_target :: CmmExpr -> SDoc
- ppr_target t@(CmmLit _) = pprPlatform platform t
- ppr_target fn' = parens (pprPlatform platform fn')
+ ppr_target t@(CmmLit _) = ppr t
+ ppr_target fn' = parens (ppr fn')
-pprForeignTarget platform (PrimTarget op)
+pprForeignTarget _ (PrimTarget op)
-- HACK: We're just using a ForeignLabel to get this printed, the label
-- might not really be foreign.
- = pprPlatform platform
+ = ppr
(CmmLabel (mkForeignLabel
(mkFastString (show op))
Nothing ForeignLabelInThisPackage IsFunction))
pprNode :: Platform -> CmmNode e x -> SDoc
-pprNode platform node = pp_node <+> pp_debug
+pprNode _ node = pp_node <+> pp_debug
where
pp_node :: SDoc
pp_node = case node of
@@ -182,10 +182,10 @@ pprNode platform node = pp_node <+> pp_debug
CmmComment s -> text "//" <+> ftext s
-- reg = expr;
- CmmAssign reg expr -> ppr reg <+> equals <+> pprPlatform platform expr <> semi
+ CmmAssign reg expr -> ppr reg <+> equals <+> ppr expr <> semi
-- rep[lv] = expr;
- CmmStore lv expr -> rep <> brackets(pprPlatform platform lv) <+> equals <+> pprPlatform platform expr <> semi
+ CmmStore lv expr -> rep <> brackets(ppr lv) <+> equals <+> ppr expr <> semi
where
rep = ppr ( cmmExprType expr )
@@ -195,7 +195,7 @@ pprNode platform node = pp_node <+> pp_debug
hsep [ ppUnless (null results) $
parens (commafy $ map ppr results) <+> equals,
ptext $ sLit "call",
- pprPlatform platform target <> parens (commafy $ map (pprPlatform platform) args) <> semi]
+ ppr target <> parens (commafy $ map ppr args) <> semi]
-- goto label;
CmmBranch ident -> ptext (sLit "goto") <+> ppr ident <> semi
@@ -203,7 +203,7 @@ pprNode platform node = pp_node <+> pp_debug
-- if (expr) goto t; else goto f;
CmmCondBranch expr t f ->
hsep [ ptext (sLit "if")
- , parens(pprPlatform platform expr)
+ , parens(ppr expr)
, ptext (sLit "goto")
, ppr t <> semi
, ptext (sLit "else goto")
@@ -215,8 +215,8 @@ pprNode platform node = pp_node <+> pp_debug
, int (length maybe_ids - 1)
, ptext (sLit "] ")
, if isTrivialCmmExpr expr
- then pprPlatform platform expr
- else parens (pprPlatform platform expr)
+ then ppr expr
+ else parens (ppr expr)
, ptext (sLit " {")
])
4 (vcat ( map caseify pairs )) $$ rbrace
@@ -237,15 +237,15 @@ pprNode platform node = pp_node <+> pp_debug
<+> parens (ppr res)
, ptext (sLit " with update frame") <+> ppr updfr_off
, semi ]
- where pprFun f@(CmmLit _) = pprPlatform platform f
- pprFun f = parens (pprPlatform platform f)
+ where pprFun f@(CmmLit _) = ppr f
+ pprFun f = parens (ppr f)
CmmForeignCall {tgt=t, res=rs, args=as, succ=s, updfr=u, intrbl=i} ->
hcat $ if i then [ptext (sLit "interruptible"), space] else [] ++
[ ptext (sLit "foreign call"), space
- , pprPlatform platform t, ptext (sLit "(...)"), space
+ , ppr t, ptext (sLit "(...)"), space
, ptext (sLit "returns to") <+> ppr s
- <+> ptext (sLit "args:") <+> parens (pprPlatform platform as)
+ <+> ptext (sLit "args:") <+> parens (ppr as)
<+> ptext (sLit "ress:") <+> parens (ppr rs)
, ptext (sLit " with update frame") <+> ppr u
, semi ]