X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FnativeGen%2FRegAllocLinear.hs;h=4a706b070acb017ec7d918c0cd974b9daeb37111;hb=589238c4c2712d29092086926cc48eeb5e9b8fa7;hp=d761bae3c0ae88fd889780683339f9856033c9b1;hpb=9e5cd691a00f5e53bdd735df4d5a33b72eeafedf;p=ghc-hetmet.git diff --git a/compiler/nativeGen/RegAllocLinear.hs b/compiler/nativeGen/RegAllocLinear.hs index d761bae..4a706b0 100644 --- a/compiler/nativeGen/RegAllocLinear.hs +++ b/compiler/nativeGen/RegAllocLinear.hs @@ -1,3 +1,10 @@ +{-# OPTIONS_GHC -w #-} +-- The above warning supression flag is a temporary kludge. +-- While working on this module you are encouraged to remove it and fix +-- any warnings in the module. See +-- http://hackage.haskell.org/trac/ghc/wiki/WorkingConventions#Warnings +-- for details + ----------------------------------------------------------------------------- -- -- The register allocator @@ -99,6 +106,7 @@ import UniqSet import UniqFM import UniqSupply import Outputable +import State #ifndef DEBUG import Data.Maybe ( fromJust ) @@ -1054,10 +1062,29 @@ binSpillReasons reasons SpillJoinRM r -> (r, [0, 0, 0, 0, 1])) reasons) +-- | Count reg-reg moves remaining in this code. +countRegRegMovesNat :: NatCmmTop -> Int +countRegRegMovesNat cmm + = execState (mapGenBlockTopM countBlock cmm) 0 + where + countBlock b@(BasicBlock i instrs) + = do instrs' <- mapM countInstr instrs + return b + + countInstr instr + | Just _ <- isRegRegMove instr + = do modify (+ 1) + return instr + + | otherwise + = return instr + + -- | Pretty print some RegAllocStats -pprStats :: [RegAllocStats] -> SDoc -pprStats statss - = let spills = foldl' (plusUFM_C (zipWith (+))) +pprStats :: [NatCmmTop] -> [RegAllocStats] -> SDoc +pprStats code statss + = let -- sum up all the instrs inserted by the spiller + spills = foldl' (plusUFM_C (zipWith (+))) emptyUFM $ map ra_spillInstrs statss @@ -1065,12 +1092,15 @@ pprStats statss [0, 0, 0, 0, 0] $ eltsUFM spills + -- count how many reg-reg-moves remain in the code + moves = sum $ map countRegRegMovesNat code + pprSpill (reg, spills) = parens $ (hcat $ punctuate (text ", ") (doubleQuotes (ppr reg) : map ppr spills)) in ( text "-- spills-added-total" - $$ text "-- (allocs, clobbers, loads, joinRR, joinRM)" - $$ (parens $ (hcat $ punctuate (text ", ") (map ppr spillTotals))) + $$ text "-- (allocs, clobbers, loads, joinRR, joinRM, reg_reg_moves_remaining)" + $$ (parens $ (hcat $ punctuate (text ", ") (map ppr spillTotals ++ [ppr moves]))) $$ text "" $$ text "-- spills-added" $$ text "-- (reg_name, allocs, clobbers, loads, joinRR, joinRM)"