-
------
--- Simple maxconflicts isn't always good, because we
--- can naievely end up spilling vregs that only live for one or two instrs.
---
-{-
-chooseSpill_maxConflicts
- :: Color.Graph Reg RegClass Reg
- -> Reg
-
-chooseSpill_maxConflicts graph
- = let node = maximumBy
- (\n1 n2 -> compare
- (sizeUniqSet $ Color.nodeConflicts n1)
- (sizeUniqSet $ Color.nodeConflicts n2))
- $ eltsUFM $ Color.graphMap graph
-
- in Color.nodeId node
--}
-
------
-chooseSpill_maxLife
- :: UniqFM (Reg, Int)
- -> Color.Graph Reg RegClass Reg
- -> Reg
-
-chooseSpill_maxLife life graph
- = let node = maximumBy (\n1 n2 -> compare (getLife n1) (getLife n2))
- $ eltsUFM $ Color.graphMap graph
-
- -- Orphan vregs die in the same instruction they are born in.
- -- They will be in the graph, but not in the liveness map.
- -- Their liveness is 0.
- getLife n
- = case lookupUFM life (Color.nodeId n) of
- Just (_, l) -> l
- Nothing -> 0