X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FnativeGen%2FRegLiveness.hs;h=1ba241f92ddbe9228f2eb06d3c19cd144b9919cf;hb=f2033eff4f1f49728f2180e902db32ae9da29b0e;hp=8f313aeb50678fb228e7b34631f390c38b811b82;hpb=0168c633a9d209e978528f059193d19cdb5e6740;p=ghc-hetmet.git diff --git a/compiler/nativeGen/RegLiveness.hs b/compiler/nativeGen/RegLiveness.hs index 8f313ae..1ba241f 100644 --- a/compiler/nativeGen/RegLiveness.hs +++ b/compiler/nativeGen/RegLiveness.hs @@ -178,9 +178,6 @@ mapGenBlockTopM f (CmmProc header label params blocks) return $ CmmProc header label params blocks' - - - -- | Slurp out the list of register conflicts from this top level thing. slurpConflicts :: LiveCmmTop -> Bag (UniqSet Reg) @@ -248,22 +245,25 @@ spillNatBlock :: NatBasicBlock -> NatBasicBlock spillNatBlock (BasicBlock i instrs) = BasicBlock i instrs' where (instrs', _) - = runState (mapM spillNat instrs) 0 + = runState (spillNat [] instrs) 0 + + spillNat acc [] + = return (reverse acc) - spillNat instr@(DELTA i) + spillNat acc (instr@(DELTA i) : instrs) = do put i - return instr + spillNat acc instrs - spillNat (SPILL reg slot) + spillNat acc (SPILL reg slot : instrs) = do delta <- get - return $ mkSpillInstr reg delta slot + spillNat (mkSpillInstr reg delta slot : acc) instrs - spillNat (RELOAD slot reg) + spillNat acc (RELOAD slot reg : instrs) = do delta <- get - return $ mkLoadInstr reg delta slot + spillNat (mkLoadInstr reg delta slot : acc) instrs - spillNat instr - = return instr + spillNat acc (instr : instrs) + = spillNat (instr : acc) instrs -- | Slurp out a map of how many times each register was live upon entry to an instruction.