summaryrefslogtreecommitdiff
path: root/compiler/GHC/Cmm
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2020-02-03 17:57:29 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-02-20 21:18:48 -0500
commit6880d6aa1e6e96579bbff89712efd813489cc828 (patch)
treef2156d5a5c168bf28ee569a62a74b51adf74dac9 /compiler/GHC/Cmm
parent74ad75e87317196c600dfabc61aee1b87d95c214 (diff)
downloadhaskell-6880d6aa1e6e96579bbff89712efd813489cc828.tar.gz
Disentangle DynFlags and SDoc
Remove several uses of `sdocWithDynFlags`. The remaining ones are mostly CodeGen related (e.g. depend on target platform constants) and will be fixed separately. Metric Decrease: T12425 T9961 WWRec T1969 T14683
Diffstat (limited to 'compiler/GHC/Cmm')
-rw-r--r--compiler/GHC/Cmm/Ppr.hs22
-rw-r--r--compiler/GHC/Cmm/Ppr/Expr.hs15
2 files changed, 18 insertions, 19 deletions
diff --git a/compiler/GHC/Cmm/Ppr.hs b/compiler/GHC/Cmm/Ppr.hs
index 891cbd9c6d..9f02cdcace 100644
--- a/compiler/GHC/Cmm/Ppr.hs
+++ b/compiler/GHC/Cmm/Ppr.hs
@@ -1,4 +1,5 @@
{-# LANGUAGE GADTs, TypeFamilies, FlexibleContexts, FlexibleInstances #-}
+{-# LANGUAGE LambdaCase #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
----------------------------------------------------------------------------
@@ -45,7 +46,6 @@ import GHC.Cmm.CLabel
import GHC.Cmm
import GHC.Cmm.Utils
import GHC.Cmm.Switch
-import DynFlags
import FastString
import Outputable
import GHC.Cmm.Ppr.Decl
@@ -181,22 +181,22 @@ pprNode :: CmmNode e x -> SDoc
pprNode node = pp_node <+> pp_debug
where
pp_node :: SDoc
- pp_node = sdocWithDynFlags $ \dflags -> case node of
+ pp_node = case node of
-- label:
- CmmEntry id tscope -> lbl <> colon <+>
- (sdocWithDynFlags $ \dflags ->
- ppUnless (gopt Opt_SuppressTicks dflags) (text "//" <+> ppr tscope))
- where
- lbl = if gopt Opt_SuppressUniques dflags
- then text "_lbl_"
- else ppr id
+ CmmEntry id tscope ->
+ (sdocOption sdocSuppressUniques $ \case
+ True -> text "_lbl_"
+ False -> ppr id
+ )
+ <> colon
+ <+> ppUnlessOption sdocSuppressTicks (text "//" <+> ppr tscope)
-- // text
CmmComment s -> text "//" <+> ftext s
-- //tick bla<...>
- CmmTick t -> ppUnless (gopt Opt_SuppressTicks dflags) $
- text "//tick" <+> ppr t
+ CmmTick t -> ppUnlessOption sdocSuppressTicks
+ (text "//tick" <+> ppr t)
-- unwind reg = expr;
CmmUnwind regs ->
diff --git a/compiler/GHC/Cmm/Ppr/Expr.hs b/compiler/GHC/Cmm/Ppr/Expr.hs
index 53a335e561..fbd4cdb7f1 100644
--- a/compiler/GHC/Cmm/Ppr/Expr.hs
+++ b/compiler/GHC/Cmm/Ppr/Expr.hs
@@ -31,8 +31,9 @@
--
-- A useful example pass over Cmm is in nativeGen/MachCodeGen.hs
--
-
+{-# LANGUAGE LambdaCase #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
+
module GHC.Cmm.Ppr.Expr
( pprExpr, pprLit
)
@@ -43,7 +44,6 @@ import GhcPrelude
import GHC.Cmm.Expr
import Outputable
-import DynFlags
import Data.Maybe
import Numeric ( fromRat )
@@ -227,18 +227,17 @@ pprReg r
-- We only print the type of the local reg if it isn't wordRep
--
pprLocalReg :: LocalReg -> SDoc
-pprLocalReg (LocalReg uniq rep) = sdocWithDynFlags $ \dflags ->
+pprLocalReg (LocalReg uniq rep) =
-- = ppr rep <> char '_' <> ppr uniq
-- Temp Jan08
- char '_' <> pprUnique dflags uniq <>
+ char '_' <> pprUnique uniq <>
(if isWord32 rep -- && not (isGcPtrType rep) -- Temp Jan08 -- sigh
then dcolon <> ptr <> ppr rep
else dcolon <> ptr <> ppr rep)
where
- pprUnique dflags unique =
- if gopt Opt_SuppressUniques dflags
- then text "_locVar_"
- else ppr unique
+ pprUnique unique = sdocOption sdocSuppressUniques $ \case
+ True -> text "_locVar_"
+ False -> ppr unique
ptr = empty
--if isGcPtrType rep
-- then doubleQuotes (text "ptr")