+-- | Make real spill instructions out of SPILL, RELOAD pseudos
+
+spillNatBlock :: NatBasicBlock -> NatBasicBlock
+spillNatBlock (BasicBlock i instrs)
+ = BasicBlock i instrs'
+ where (instrs', _)
+ = runState (spillNat [] instrs) 0
+
+ spillNat acc []
+ = return (reverse acc)
+
+ spillNat acc (instr@(DELTA i) : instrs)
+ = do put i
+ spillNat acc instrs
+
+ spillNat acc (SPILL reg slot : instrs)
+ = do delta <- get
+ spillNat (mkSpillInstr reg delta slot : acc) instrs
+
+ spillNat acc (RELOAD slot reg : instrs)
+ = do delta <- get
+ spillNat (mkLoadInstr reg delta slot : acc) instrs
+
+ spillNat acc (instr : instrs)
+ = spillNat (instr : acc) instrs
+
+