Add vreg-conflicts and vreg-conflict-lifetimes to drop-asm-stats
[ghc-hetmet.git] / compiler / nativeGen / AsmCodeGen.lhs
index 177ef0e..29ffb89 100644 (file)
@@ -23,7 +23,6 @@ import RegAllocLinear
 import RegAllocStats
 import RegLiveness
 import RegCoalesce
-import qualified RegSpill      as Spill
 import qualified RegAllocColor as Color
 import qualified GraphColor    as Color
 
@@ -404,6 +403,7 @@ cmmNativeGenDump dflags mod modLocation dump
                                (zip [0..] codeGraphs)))
         $ map ((\(Just c) -> c) . cdRegAllocStats) dump
 
+
        -- Build a global register conflict graph.
        --      If you want to see the graph for just one basic block then use asm-regalloc-stages instead.
        dumpIfSet_dyn dflags
@@ -416,33 +416,24 @@ cmmNativeGenDump dflags mod modLocation dump
        -- Drop native code gen statistics.
        --      This is potentially a large amount of information, so we make a new file instead
        --      of dumping it to stdout.
-       --
        when (dopt Opt_D_drop_asm_stats dflags)
         $ do   -- make the drop file name based on the object file name
                let dropFile    = (init $ ml_obj_file modLocation) ++ "drop-asm-stats"
 
-               -- slurp out the stats from all the spiller stages
-               let spillStats  = [ s   | s@RegAllocStatsSpill{}
-                                       <- concat [ c | Just c <- map cdRegAllocStats dump]]
-
-               -- build a map of how many spill load/stores were inserted for each vreg
-               let spillLS     = foldl' (plusUFM_C Spill.accSpillLS) emptyUFM
-                               $ map (Spill.spillLoadStore . raSpillStats) spillStats
+               -- slurp out all the regalloc stats
+               let stats       = concat $ catMaybes $ map cdRegAllocStats dump
 
-               -- print the count of load/spills as a tuple so we can read back from the file easilly
-               let pprSpillLS :: (Reg, Int, Int) -> SDoc
-                   pprSpillLS  (r, loads, stores) =
-                       (parens $ (hcat $ punctuate (text ", ") [doubleQuotes (ppr r), int loads, int stores]))
+               -- build a global conflict graph
+               let graph       = foldl Color.union Color.initGraph $ map raGraph stats
 
-               -- write out the file
-               let out         = showSDoc
-                               (  text "-- (spills-added)"
-                               $$ text "--    Spill instructions inserted for each virtual reg."
-                               $$ text "--    (reg name, spill loads added, spill stores added)."
-                               $$ (vcat $ map pprSpillLS $ eltsUFM spillLS)
-                               $$ text "\n")
+               -- pretty print the various sections and write out the file.
+               let outSpills   = pprStatsSpills    stats
+               let outLife     = pprStatsLifetimes stats
+               let outConflict = pprStatsConflict  stats
+               let outScatter  = pprStatsLifeConflict stats graph
 
-               writeFile dropFile out
+               writeFile dropFile
+                       (showSDoc $ vcat [outSpills, outLife, outConflict, outScatter])
 
                return ()