Add spill/reload pseudo instrs to MachInstrs
[ghc-hetmet.git] / compiler / nativeGen / RegAllocColor.hs
index 9c21faa..92efc4a 100644 (file)
@@ -105,8 +105,12 @@ regAlloc_spin (spinCount :: Int) triv regsFree slotsFree debug_codeGraphs code
        if isEmptyUniqSet rsSpill
         then do
                -- patch the registers using the info in the graph
+               --      also rewrite SPILL/REALOAD pseudos into real instructions
                let code_patched        = map (patchRegsFromGraph graph_colored) code
-               let code_nat            = map stripLive code_patched
+
+               let spillNatTop         = mapGenBlockTop spillNatBlock
+               let code_nat            = map (spillNatTop . stripLive) code_patched
+
                
                -- record what happened in this stage for debugging
                let stat                =
@@ -115,7 +119,7 @@ regAlloc_spin (spinCount :: Int) triv regsFree slotsFree debug_codeGraphs code
                        , raPatchedCmm  = code_patched }
 
                return  ( code_nat
-                       , maybeToList stat1 ++ [stat] ++ debug_codeGraphs
+                       , [stat] ++ maybeToList stat1 ++ debug_codeGraphs
                        , graph_colored)
 
         else do
@@ -137,7 +141,7 @@ regAlloc_spin (spinCount :: Int) triv regsFree slotsFree debug_codeGraphs code
                                
                -- try again
                regAlloc_spin (spinCount + 1) triv regsFree slotsFree' 
-                       (maybeToList stat1 ++ [stat] ++ debug_codeGraphs)
+                       ([stat] ++ maybeToList stat1 ++ debug_codeGraphs)
                        code_relive