summaryrefslogtreecommitdiff
path: root/compiler/codeGen/StgCmmEnv.hs
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2011-08-22 13:56:17 +0100
committerSimon Marlow <marlowsd@gmail.com>2011-08-25 11:12:30 +0100
commit5b167f5edad7d3268de20452da7af05c38972f7c (patch)
tree36a14e64b510ede91e4e334f3e44d865321adcde /compiler/codeGen/StgCmmEnv.hs
parent3108accd634a521b25471df19f063c2061d6d3ee (diff)
downloadhaskell-5b167f5edad7d3268de20452da7af05c38972f7c.tar.gz
Snapshot of codegen refactoring to share with simonpj
Diffstat (limited to 'compiler/codeGen/StgCmmEnv.hs')
-rw-r--r--compiler/codeGen/StgCmmEnv.hs32
1 files changed, 19 insertions, 13 deletions
diff --git a/compiler/codeGen/StgCmmEnv.hs b/compiler/codeGen/StgCmmEnv.hs
index 369e1993aa..25bbe8f63f 100644
--- a/compiler/codeGen/StgCmmEnv.hs
+++ b/compiler/codeGen/StgCmmEnv.hs
@@ -70,33 +70,39 @@ nonVoidIds ids = [NonVoid id | id <- ids, not (isVoidRep (idPrimRep id))]
mkCgIdInfo :: Id -> LambdaFormInfo -> CmmExpr -> CgIdInfo
mkCgIdInfo id lf expr
- = CgIdInfo { cg_id = id, cg_loc = CmmLoc expr,
- cg_lf = lf, cg_rep = idPrimRep id,
+ = CgIdInfo { cg_id = id, cg_rep = idPrimRep id, cg_lf = lf
+ , cg_loc = CmmLoc expr,
cg_tag = lfDynTag lf }
+litIdInfo :: Id -> LambdaFormInfo -> CmmLit -> CgIdInfo
+litIdInfo id lf lit
+ = CgIdInfo { cg_id = id, cg_rep = idPrimRep id, cg_lf = lf
+ , cg_loc = CmmLoc (addDynTag (CmmLit lit) tag)
+ , cg_tag = tag }
+ where
+ tag = lfDynTag lf
+
lneIdInfo :: Id -> [LocalReg] -> CgIdInfo
lneIdInfo id regs
- = CgIdInfo { cg_id = id, cg_loc = LneLoc blk_id regs,
- cg_lf = lf, cg_rep = idPrimRep id,
- cg_tag = lfDynTag lf }
+ = CgIdInfo { cg_id = id, cg_rep = idPrimRep id, cg_lf = lf
+ , cg_loc = LneLoc blk_id regs
+ , cg_tag = lfDynTag lf }
where
lf = mkLFLetNoEscape
blk_id = mkBlockId (idUnique id)
-litIdInfo :: Id -> LambdaFormInfo -> CmmLit -> CgIdInfo
-litIdInfo id lf_info lit = --mkCgIdInfo id lf_info (CmmLit lit)
- mkCgIdInfo id lf_info (addDynTag (CmmLit lit) (lfDynTag lf_info))
-
-- Because the register may be spilled to the stack in untagged form, we
-- modify the initialization code 'init' to immediately tag the
-- register, and store a plain register in the CgIdInfo. We allocate
-- a new register in order to keep single-assignment and help out the
-- inliner. -- EZY
regIdInfo :: Id -> LambdaFormInfo -> LocalReg -> CmmAGraph -> FCode (CgIdInfo, CmmAGraph)
-regIdInfo id lf_info reg init = do
- reg' <- newTemp (localRegType reg)
- let init' = init <*> mkAssign (CmmLocal reg') (addDynTag (CmmReg (CmmLocal reg)) (lfDynTag lf_info))
- return (mkCgIdInfo id lf_info (CmmReg (CmmLocal reg')), init')
+regIdInfo id lf_info reg init
+ = do { reg' <- newTemp (localRegType reg)
+ ; let init' = init <*> mkAssign (CmmLocal reg')
+ (addDynTag (CmmReg (CmmLocal reg))
+ (lfDynTag lf_info))
+ ; return (mkCgIdInfo id lf_info (CmmReg (CmmLocal reg')), init') }
idInfoToAmode :: CgIdInfo -> CmmExpr
-- Returns a CmmExpr for the *tagged* pointer