import RegAlloc.Linear.StackMap
import RegAlloc.Linear.Base
import RegAlloc.Linear.FreeRegs
-
-
-import Instrs
-import Regs
-import RegAllocInfo
-import RegLiveness
+import RegAlloc.Liveness
+import Instruction
+import Reg
import Unique
import UniqSupply
{ ra_spillInstrs = binSpillReasons (ra_spills state) }
-spillR :: Reg -> Unique -> RegM (Instr, Int)
+spillR :: Instruction instr
+ => Reg -> Unique -> RegM (instr, Int)
+
spillR reg temp = RegM $ \ s@RA_State{ra_delta=delta, ra_stack=stack} ->
let (stack',slot) = getStackSlotFor stack temp
instr = mkSpillInstr reg delta slot
in
(# s{ra_stack=stack'}, (instr,slot) #)
-loadR :: Reg -> Int -> RegM Instr
+
+loadR :: Instruction instr
+ => Reg -> Int -> RegM instr
+
loadR reg slot = RegM $ \ s@RA_State{ra_delta=delta} ->
(# s, mkLoadInstr reg delta slot #)
getUniqueR :: RegM Unique
getUniqueR = RegM $ \s ->
- case splitUniqSupply (ra_us s) of
- (us1, us2) -> (# s{ra_us = us2}, uniqFromSupply us1 #)
+ case takeUniqFromSupply (ra_us s) of
+ (uniq, us) -> (# s{ra_us = us}, uniq #)
-- | Record that a spill instruction was inserted, for profiling.