2 -- Carries interesting info for debugging / profiling of the
3 -- graph coloring register allocator.
12 #include "nativeGen/NCG.h"
14 import qualified GraphColor as Color
27 { raLiveCmm :: [LiveCmmTop] -- ^ code we tried to allocate regs for
28 , raGraph :: Color.Graph Reg RegClass Reg -- ^ the partially colored graph
29 , raSpillStats :: SpillStats } -- ^ spiller stats
31 -- a successful coloring
32 | RegAllocStatsColored
33 { raLiveCmm :: [LiveCmmTop] -- ^ the code we allocated regs for
34 , raGraph :: Color.Graph Reg RegClass Reg -- ^ the colored graph
35 , raPatchedCmm :: [LiveCmmTop] } -- ^ code with register allocation
38 instance Outputable RegAllocStats where
40 ppr (s@RegAllocStatsSpill{})
43 $$ text "-- Native code with liveness information."
47 $$ text "-- Register conflict graph."
48 $$ Color.dotGraph regDotColor trivColorable (raGraph s)
50 $$ text "-- Spill statistics."
51 $$ ppr (raSpillStats s)
54 ppr (s@RegAllocStatsColored{})
57 $$ text "-- Native code with liveness information."
61 $$ text "-- Register conflict graph."
62 $$ Color.dotGraph regDotColor trivColorable (raGraph s)
64 $$ text "-- Native code after register allocation."
65 $$ ppr (raPatchedCmm s)
69 -- Register colors for drawing conflict graphs
70 -- Keep this out of MachRegs.hs because it's specific to the graph coloring allocator.
75 regDotColor :: Reg -> SDoc
77 = let Just str = lookupUFM regColors reg
92 , (fake5, "#5500ff") ]
96 -- reg colors for x86_64
97 #if x86_64_TARGET_ARCH
98 regDotColor :: Reg -> SDoc
100 = let Just str = lookupUFM regColors reg
105 $ [ (rax, "#00ff00"), (eax, "#00ff00")
106 , (rbx, "#0000ff"), (ebx, "#0000ff")
107 , (rcx, "#00ffff"), (ecx, "#00ffff")
108 , (rdx, "#0080ff"), (edx, "#00ffff")
118 ++ zip (map RealReg [16..31]) (repeat "red")
122 -- reg colors for ppc
123 #if powerpc_TARGET_ARCH
124 regDotColor :: Reg -> SDoc
126 = case regClass reg of
127 RcInteger -> text "blue"
128 RcFloat -> text "red"
134 = let rs = padL 2 '0' (showHex r "")
135 gs = padL 2 '0' (showHex r "")
136 bs = padL 2 '0' (showHex r "")
139 = replicate (n - length s) c ++ s
140 in "#" ++ rs ++ gs ++ bs