summaryrefslogtreecommitdiff
path: root/compiler/GHC/StgToCmm
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2021-05-27 12:02:45 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-06-05 19:23:46 -0400
commit52a524f7c8c5701708a007a5946c27914703d045 (patch)
tree63e5417205788aa800e06ef679f96ca29a3586aa /compiler/GHC/StgToCmm
parentea9a4ef69a382cf3cee28b78eca390a6a06c6965 (diff)
downloadhaskell-52a524f7c8c5701708a007a5946c27914703d045.tar.gz
Re-do rubbish literals
As #19882 pointed out, we were simply doing rubbish literals wrong. (I'll refrain from explaining the wrong-ness here -- see the ticket.) This patch fixes it by adding a Type (of kind RuntimeRep) as field of LitRubbish, rather than [PrimRep]. The Note [Rubbish literals] in GHC.Types.Literal explains the details.
Diffstat (limited to 'compiler/GHC/StgToCmm')
-rw-r--r--compiler/GHC/StgToCmm/Lit.hs10
1 files changed, 7 insertions, 3 deletions
diff --git a/compiler/GHC/StgToCmm/Lit.hs b/compiler/GHC/StgToCmm/Lit.hs
index 8e2e000753..11de674618 100644
--- a/compiler/GHC/StgToCmm/Lit.hs
+++ b/compiler/GHC/StgToCmm/Lit.hs
@@ -23,6 +23,7 @@ import GHC.Cmm.CLabel
import GHC.Cmm.Utils
import GHC.Types.Literal
+import GHC.Types.RepType( runtimeRepPrimRep )
import GHC.Builtin.Types ( unitDataConId )
import GHC.Core.TyCon
import GHC.Utils.Misc
@@ -49,8 +50,8 @@ cgLit :: Literal -> FCode CmmExpr
cgLit (LitString s) =
CmmLit <$> newByteStringCLit s
-- not unpackFS; we want the UTF-8 byte stream.
-cgLit (LitRubbish preps) =
- case expectOnly "cgLit:Rubbish" preps of -- Note [Post-unarisation invariants]
+cgLit (LitRubbish rep) =
+ case expectOnly "cgLit" prim_reps of -- Note [Post-unarisation invariants]
VoidRep -> panic "cgLit:VoidRep" -- dito
LiftedRep -> idInfoToAmode <$> getCgIdInfo unitDataConId
UnliftedRep -> idInfoToAmode <$> getCgIdInfo unitDataConId
@@ -60,7 +61,9 @@ cgLit (LitRubbish preps) =
let elem_lit = mkSimpleLit platform (num_rep_lit (primElemRepToPrimRep elem))
pure (CmmLit (CmmVec (replicate n elem_lit)))
prep -> cgLit (num_rep_lit prep)
- where
+ where
+ prim_reps = runtimeRepPrimRep (text "cgLit") rep
+
num_rep_lit IntRep = mkLitIntUnchecked 0
num_rep_lit Int8Rep = mkLitInt8Unchecked 0
num_rep_lit Int16Rep = mkLitInt16Unchecked 0
@@ -74,6 +77,7 @@ cgLit (LitRubbish preps) =
num_rep_lit FloatRep = LitFloat 0
num_rep_lit DoubleRep = LitDouble 0
num_rep_lit other = pprPanic "num_rep_lit: Not a num lit" (ppr other)
+
cgLit other_lit = do
platform <- getPlatform
pure (CmmLit (mkSimpleLit platform other_lit))