summaryrefslogtreecommitdiff
path: root/compiler/GHC/Cmm.hs
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2020-03-31 18:49:01 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-04-03 06:26:54 -0400
commitcc2918a0407e1581e824ebd90a1fcbb0637d5744 (patch)
tree42cdc286b9b2557252f59db47373305c1cfc9c36 /compiler/GHC/Cmm.hs
parenta485c3c4049fff09e989bfd7d2ba47035c92a69b (diff)
downloadhaskell-cc2918a0407e1581e824ebd90a1fcbb0637d5744.tar.gz
Refactor CmmStatics
In !2959 we noticed that there was some redundant code (in GHC.Cmm.Utils and GHC.Cmm.StgToCmm.Utils) used to deal with `CmmStatics` datatype (before SRT generation) and `RawCmmStatics` datatype (after SRT generation). This patch removes this redundant code by using a single GADT for (Raw)CmmStatics.
Diffstat (limited to 'compiler/GHC/Cmm.hs')
-rw-r--r--compiler/GHC/Cmm.hs37
1 files changed, 21 insertions, 16 deletions
diff --git a/compiler/GHC/Cmm.hs b/compiler/GHC/Cmm.hs
index 9973db8d0d..fe5109aa6f 100644
--- a/compiler/GHC/Cmm.hs
+++ b/compiler/GHC/Cmm.hs
@@ -1,5 +1,8 @@
-- Cmm representations using Hoopl's Graph CmmNode e x.
{-# LANGUAGE GADTs #-}
+{-# LANGUAGE KindSignatures #-}
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE ExplicitNamespaces #-}
module GHC.Cmm (
-- * Cmm top-level datatypes
@@ -7,7 +10,8 @@ module GHC.Cmm (
CmmDecl, CmmDeclSRTs, GenCmmDecl(..),
CmmGraph, GenCmmGraph(..),
CmmBlock, RawCmmDecl,
- Section(..), SectionType(..), CmmStatics(..), RawCmmStatics(..), CmmStatic(..),
+ Section(..), SectionType(..),
+ GenCmmStatics(..), type CmmStatics, type RawCmmStatics, CmmStatic(..),
isSecConstant,
-- ** Blocks containing lists
@@ -206,21 +210,22 @@ data CmmStatic
-- ^ an embedded binary file
-- Static data before SRT generation
-data CmmStatics
- = CmmStatics
- CLabel -- Label of statics
- CmmInfoTable
- CostCentreStack
- [CmmLit] -- Payload
- | CmmStaticsRaw
- CLabel -- Label of statics
- [CmmStatic] -- The static data itself
-
--- Static data, after SRTs are generated
-data RawCmmStatics
- = RawCmmStatics
- CLabel -- Label of statics
- [CmmStatic] -- The static data itself
+data GenCmmStatics (rawOnly :: Bool) where
+ CmmStatics
+ :: CLabel -- Label of statics
+ -> CmmInfoTable
+ -> CostCentreStack
+ -> [CmmLit] -- Payload
+ -> GenCmmStatics 'False
+
+ -- | Static data, after SRTs are generated
+ CmmStaticsRaw
+ :: CLabel -- Label of statics
+ -> [CmmStatic] -- The static data itself
+ -> GenCmmStatics a
+
+type CmmStatics = GenCmmStatics 'False
+type RawCmmStatics = GenCmmStatics 'True
-- -----------------------------------------------------------------------------
-- Basic blocks consisting of lists