summaryrefslogtreecommitdiff
path: root/compiler/cmm/MkGraph.hs
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2012-07-09 16:08:21 +0100
committerSimon Marlow <marlowsd@gmail.com>2012-07-09 16:23:45 +0100
commitc6a61235aa0baf6f9e8a41c5a771ccc7e32c23a5 (patch)
treea288174c5f6ab513319bd4d1dae6ef79044f5ae9 /compiler/cmm/MkGraph.hs
parentc9cb46bec47ada686d18437578fbc95281c9c6d4 (diff)
downloadhaskell-c6a61235aa0baf6f9e8a41c5a771ccc7e32c23a5.tar.gz
Track liveness of GlobalRegs in the new code generator
This gives the register allocator access to R1.., F1.., D1.. etc. for the new code generator, and is a cheap way to eliminate all the extra "x = R1" assignments that we get from copyIn.
Diffstat (limited to 'compiler/cmm/MkGraph.hs')
-rw-r--r--compiler/cmm/MkGraph.hs29
1 files changed, 17 insertions, 12 deletions
diff --git a/compiler/cmm/MkGraph.hs b/compiler/cmm/MkGraph.hs
index ecd4d4f985..443fa3a441 100644
--- a/compiler/cmm/MkGraph.hs
+++ b/compiler/cmm/MkGraph.hs
@@ -294,7 +294,7 @@ data Transfer = Call | Jump | Ret deriving Eq
copyOutOflow :: Convention -> Transfer -> Area -> [CmmActual]
-> UpdFrameOffset
-> (ByteOff, [(CmmExpr,ByteOff)]) -- extra stack stuff
- -> (Int, CmmAGraph)
+ -> (Int, [GlobalReg], CmmAGraph)
-- Generate code to move the actual parameters into the locations
-- required by the calling convention. This includes a store for the
@@ -307,10 +307,12 @@ copyOutOflow :: Convention -> Transfer -> Area -> [CmmActual]
-- of the other parameters.
copyOutOflow conv transfer area actuals updfr_off
(extra_stack_off, extra_stack_stuff)
- = foldr co (init_offset, mkNop) (args' ++ stack_params)
+ = foldr co (init_offset, [], mkNop) (args' ++ stack_params)
where
- co (v, RegisterParam r) (n, ms) = (n, mkAssign (CmmGlobal r) v <*> ms)
- co (v, StackParam off) (n, ms) = (max n off, mkStore (CmmStackSlot area off) v <*> ms)
+ co (v, RegisterParam r) (n, rs, ms)
+ = (n, r:rs, mkAssign (CmmGlobal r) v <*> ms)
+ co (v, StackParam off) (n, rs, ms)
+ = (max n off, rs, mkStore (CmmStackSlot area off) v <*> ms)
stack_params = [ (e, StackParam (off + init_offset))
| (e,off) <- extra_stack_stuff ]
@@ -341,7 +343,7 @@ mkCallEntry conv formals = copyInOflow conv Old formals
lastWithArgs :: Transfer -> Area -> Convention -> [CmmActual]
-> UpdFrameOffset
- -> (ByteOff -> CmmAGraph)
+ -> (ByteOff -> [GlobalReg] -> CmmAGraph)
-> CmmAGraph
lastWithArgs transfer area conv actuals updfr_off last =
lastWithArgsAndExtraStack transfer area conv actuals
@@ -349,18 +351,21 @@ lastWithArgs transfer area conv actuals updfr_off last =
lastWithArgsAndExtraStack :: Transfer -> Area -> Convention -> [CmmActual]
-> UpdFrameOffset -> (ByteOff, [(CmmExpr,ByteOff)])
- -> (ByteOff -> CmmAGraph)
+ -> (ByteOff -> [GlobalReg] -> CmmAGraph)
-> CmmAGraph
lastWithArgsAndExtraStack transfer area conv actuals updfr_off
extra_stack last =
- let (outArgs, copies) = copyOutOflow conv transfer area actuals
- updfr_off extra_stack in
- copies <*> last outArgs
+ copies <*> last outArgs regs
+ where
+ (outArgs, regs, copies) = copyOutOflow conv transfer area actuals
+ updfr_off extra_stack
+
noExtraStack :: (ByteOff, [(CmmExpr,ByteOff)])
noExtraStack = (0,[])
-toCall :: CmmExpr -> Maybe BlockId -> UpdFrameOffset -> ByteOff -> ByteOff
+toCall :: CmmExpr -> Maybe BlockId -> UpdFrameOffset -> ByteOff
+ -> ByteOff -> [GlobalReg]
-> CmmAGraph
-toCall e cont updfr_off res_space arg_space =
- mkLast $ CmmCall e cont arg_space res_space updfr_off
+toCall e cont updfr_off res_space arg_space regs =
+ mkLast $ CmmCall e cont regs arg_space res_space updfr_off