summaryrefslogtreecommitdiff
path: root/compiler/GHC/Cmm.hs
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2020-06-03 20:46:05 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-08-18 22:12:13 -0400
commit0c5ed5c7eb30bc5462b67ff097c3388597265a4b (patch)
treed55e420625a2118c7854d2b41bb4ee4ed5755b7f /compiler/GHC/Cmm.hs
parentaa4b744d51aa6bdb46064f981ea8e001627921d6 (diff)
downloadhaskell-0c5ed5c7eb30bc5462b67ff097c3388597265a4b.tar.gz
DynFlags: refactor GHC.CmmToAsm (#17957, #10143)
This patch removes the use of `sdocWithDynFlags` from GHC.CmmToAsm.*.Ppr To do that I've had to make some refactoring: * X86' and PPC's `Instr` are no longer `Outputable` as they require a `Platform` argument * `Instruction` class now exposes `pprInstr :: Platform -> instr -> SDoc` * as a consequence, I've refactored some modules to avoid .hs-boot files * added (derived) functor instances for some datatypes parametric in the instruction type. It's useful for pretty-printing as we just have to map `pprInstr` before pretty-printing the container datatype.
Diffstat (limited to 'compiler/GHC/Cmm.hs')
-rw-r--r--compiler/GHC/Cmm.hs12
1 files changed, 10 insertions, 2 deletions
diff --git a/compiler/GHC/Cmm.hs b/compiler/GHC/Cmm.hs
index 6f69525dc7..d93b885e9e 100644
--- a/compiler/GHC/Cmm.hs
+++ b/compiler/GHC/Cmm.hs
@@ -3,6 +3,7 @@
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE ExplicitNamespaces #-}
+{-# LANGUAGE DeriveFunctor #-}
module GHC.Cmm (
-- * Cmm top-level datatypes
@@ -96,6 +97,8 @@ data GenCmmDecl d h g
Section
d
+ deriving (Functor)
+
type CmmDecl = GenCmmDecl CmmStatics CmmTopInfo CmmGraph
type CmmDeclSRTs = GenCmmDecl RawCmmStatics CmmTopInfo CmmGraph
@@ -246,14 +249,19 @@ type RawCmmStatics = GenCmmStatics 'True
-- These are used by the LLVM and NCG backends, when populating Cmm
-- with lists of instructions.
-data GenBasicBlock i = BasicBlock BlockId [i]
+data GenBasicBlock i
+ = BasicBlock BlockId [i]
+ deriving (Functor)
+
-- | The branch block id is that of the first block in
-- the branch, which is that branch's entry point
blockId :: GenBasicBlock i -> BlockId
blockId (BasicBlock blk_id _ ) = blk_id
-newtype ListGraph i = ListGraph [GenBasicBlock i]
+newtype ListGraph i
+ = ListGraph [GenBasicBlock i]
+ deriving (Functor)
instance Outputable instr => Outputable (ListGraph instr) where
ppr (ListGraph blocks) = vcat (map ppr blocks)