+-- | Dump a table of how many spill loads / stores were inserted for each vreg.
+pprStatsSpills
+ :: [RegAllocStats] -> SDoc
+
+pprStatsSpills stats
+ = let -- slurp out the stats from all the spiller stages
+ spillStats = [ s | s@RegAllocStatsSpill{} <- stats]
+
+ -- build a map of how many spill load/stores were inserted for each vreg
+ spillLS = foldl' (plusUFM_C accSpillLS) emptyUFM
+ $ map (spillLoadStore . raSpillStats) spillStats
+
+ -- print the count of load/spills as a tuple so we can read back from the file easilly
+ pprSpillLS (r, loads, stores)
+ = (parens $ (hcat $ punctuate (text ", ") [doubleQuotes (ppr r), int loads, int stores]))
+
+
+ in ( text "-- spills-added"
+ $$ text "-- (reg_name, spill_loads_added, spill_stores_added)."
+ $$ (vcat $ map pprSpillLS $ eltsUFM spillLS)
+ $$ text "\n")
+
+
+
+-- | Dump a table of how long vregs tend to live for.
+pprStatsLifetimes
+ :: [RegAllocStats] -> SDoc
+
+pprStatsLifetimes stats
+ = let lifeMap = foldl' plusUFM emptyUFM $ map raLifetimes stats
+ lifeBins = binLifetimeCount lifeMap
+
+ in ( text "-- vreg-population-lifetimes"
+ $$ text "-- (instruction_count, number_of_vregs_that_lived_that_long)"
+ $$ (vcat $ map ppr $ eltsUFM lifeBins)
+ $$ text "\n")
+