summaryrefslogtreecommitdiff
path: root/compiler/GHC/Cmm/Ppr
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2020-09-14 19:46:45 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-09-17 20:04:08 -0400
commite45c85446de7589e17acf5654c2b33f766043eb1 (patch)
treedb36adba8d53eb3b9cc8e6cbfd37d43f7c8445b7 /compiler/GHC/Cmm/Ppr
parentca48076ae866665913b9c81cbc0c76f0afef7a00 (diff)
downloadhaskell-e45c85446de7589e17acf5654c2b33f766043eb1.tar.gz
Generalize OutputableP
Add a type parameter for the environment required by OutputableP. It avoids tying Platform with OutputableP.
Diffstat (limited to 'compiler/GHC/Cmm/Ppr')
-rw-r--r--compiler/GHC/Cmm/Ppr/Decl.hs20
-rw-r--r--compiler/GHC/Cmm/Ppr/Expr.hs9
2 files changed, 18 insertions, 11 deletions
diff --git a/compiler/GHC/Cmm/Ppr/Decl.hs b/compiler/GHC/Cmm/Ppr/Decl.hs
index b65cb9bd0b..c2e46c6e16 100644
--- a/compiler/GHC/Cmm/Ppr/Decl.hs
+++ b/compiler/GHC/Cmm/Ppr/Decl.hs
@@ -1,4 +1,8 @@
{-# LANGUAGE GADTs #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE FlexibleContexts #-}
+
----------------------------------------------------------------------------
--
@@ -54,7 +58,7 @@ import Data.List
import qualified Data.ByteString as BS
-pprCmms :: (OutputableP info, OutputableP g)
+pprCmms :: (OutputableP Platform info, OutputableP Platform g)
=> Platform -> [GenCmmGroup RawCmmStatics info g] -> SDoc
pprCmms platform cmms = pprCode CStyle (vcat (intersperse separator $ map (pdoc platform) cmms))
where
@@ -62,23 +66,23 @@ pprCmms platform cmms = pprCode CStyle (vcat (intersperse separator $ map (pdoc
-----------------------------------------------------------------------------
-instance (OutputableP d, OutputableP info, OutputableP i)
- => OutputableP (GenCmmDecl d info i) where
+instance (OutputableP Platform d, OutputableP Platform info, OutputableP Platform i)
+ => OutputableP Platform (GenCmmDecl d info i) where
pdoc = pprTop
-instance OutputableP (GenCmmStatics a) where
+instance OutputableP Platform (GenCmmStatics a) where
pdoc = pprStatics
-instance OutputableP CmmStatic where
+instance OutputableP Platform CmmStatic where
pdoc = pprStatic
-instance OutputableP CmmInfoTable where
+instance OutputableP Platform CmmInfoTable where
pdoc = pprInfoTable
-----------------------------------------------------------------------------
-pprCmmGroup :: (OutputableP d, OutputableP info, OutputableP g)
+pprCmmGroup :: (OutputableP Platform d, OutputableP Platform info, OutputableP Platform g)
=> Platform -> GenCmmGroup d info g -> SDoc
pprCmmGroup platform tops
= vcat $ intersperse blankLine $ map (pprTop platform) tops
@@ -86,7 +90,7 @@ pprCmmGroup platform tops
-- --------------------------------------------------------------------------
-- Top level `procedure' blocks.
--
-pprTop :: (OutputableP d, OutputableP info, OutputableP i)
+pprTop :: (OutputableP Platform d, OutputableP Platform info, OutputableP Platform i)
=> Platform -> GenCmmDecl d info i -> SDoc
pprTop platform (CmmProc info lbl live graph)
diff --git a/compiler/GHC/Cmm/Ppr/Expr.hs b/compiler/GHC/Cmm/Ppr/Expr.hs
index 5b1d01b00a..c656c98522 100644
--- a/compiler/GHC/Cmm/Ppr/Expr.hs
+++ b/compiler/GHC/Cmm/Ppr/Expr.hs
@@ -32,6 +32,9 @@
-- A useful example pass over Cmm is in nativeGen/MachCodeGen.hs
--
{-# LANGUAGE LambdaCase #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE FlexibleInstances #-}
+
{-# OPTIONS_GHC -fno-warn-orphans #-}
module GHC.Cmm.Ppr.Expr
@@ -53,13 +56,13 @@ import Numeric ( fromRat )
-----------------------------------------------------------------------------
-instance OutputableP CmmExpr where
+instance OutputableP Platform CmmExpr where
pdoc = pprExpr
instance Outputable CmmReg where
ppr e = pprReg e
-instance OutputableP CmmLit where
+instance OutputableP Platform CmmLit where
pdoc = pprLit
instance Outputable LocalReg where
@@ -71,7 +74,7 @@ instance Outputable Area where
instance Outputable GlobalReg where
ppr e = pprGlobalReg e
-instance OutputableP GlobalReg where
+instance OutputableP env GlobalReg where
pdoc _ = ppr
-- --------------------------------------------------------------------------