module RegAllocStats (
RegAllocStats (..),
- regDotColor
+ regDotColor,
+ binLifetimeCount
)
where
= RegAllocStatsSpill
{ raLiveCmm :: [LiveCmmTop] -- ^ code we tried to allocate regs for
, raGraph :: Color.Graph Reg RegClass Reg -- ^ the partially colored graph
- , raSpillStats :: SpillStats } -- ^ spiller stats
+ , raSpillStats :: SpillStats -- ^ spiller stats
+ , raLifetimes :: UniqFM (Reg, Int) } -- ^ number of instrs each reg lives for
-- a successful coloring
| RegAllocStatsColored
{ raLiveCmm :: [LiveCmmTop] -- ^ the code we allocated regs for
, raGraph :: Color.Graph Reg RegClass Reg -- ^ the colored graph
- , raPatchedCmm :: [LiveCmmTop] } -- ^ code with register allocation
+ , raPatchedCmm :: [LiveCmmTop] -- ^ code with register allocation
+ , raLifetimes :: UniqFM (Reg, Int) } -- ^ number of instrs each reg lives for
instance Outputable RegAllocStats where
-----
+binLifetimeCount :: UniqFM (Reg, Int) -> UniqFM (Int, Int)
+binLifetimeCount fm
+ = let lifes = map (\l -> (l, (l, 1)))
+ $ map snd
+ $ eltsUFM fm
+
+ in addListToUFM_C
+ (\(l1, c1) (l2, c2) -> (l1, c1 + c2))
+ emptyUFM
+ lifes
+
+-----
-- Register colors for drawing conflict graphs
-- Keep this out of MachRegs.hs because it's specific to the graph coloring allocator.