X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Futils%2FGraphOps.hs;h=87e77bfc83b15297de0aaaa007f71194854af07d;hp=a82ff686290f4a84c9b37b02e96ede5ff7d10e36;hb=f9288086f935c97812b2d80defcff38baf7b6a6c;hpb=727fae32ea0b6ca6ebdf1b3137649813e4d7ac3d diff --git a/compiler/utils/GraphOps.hs b/compiler/utils/GraphOps.hs index a82ff68..87e77bf 100644 --- a/compiler/utils/GraphOps.hs +++ b/compiler/utils/GraphOps.hs @@ -8,7 +8,7 @@ module GraphOps ( union, addConflict, delConflict, addConflicts, addCoalesce, delCoalesce, - addExclusion, + addExclusion, addExclusions, addPreference, coalesceNodes, coalesceGraph, freezeNode, freezeOneInGraph, freezeAllInGraph, @@ -24,7 +24,7 @@ import GraphBase import Outputable import Unique import UniqSet -import LazyUniqFM +import UniqFM import Data.List hiding (union) import Data.Maybe @@ -213,6 +213,14 @@ addExclusion u getClass color (newNode u (getClass u)) { nodeExclusions = unitUniqSet color } u +addExclusions + :: (Uniquable k, Uniquable color) + => k -> (k -> cls) -> [color] + -> Graph k cls color -> Graph k cls color + +addExclusions u getClass colors graph + = foldr (addExclusion u getClass) graph colors + -- | Add a coalescence edge to the graph, creating nodes if requried. -- It is considered adventageous to assign the same color to nodes in a coalesence. @@ -305,7 +313,7 @@ coalesceGraph' aggressive triv graph kkPairsAcc pairs -> coalesceGraph' aggressive triv graph' (reverse pairs ++ kkPairsAcc) --- | Coalesce this pair of nodes unconditionally / agressively. +-- | Coalesce this pair of nodes unconditionally \/ agressively. -- The resulting node is the one with the least key. -- -- returns: Just the pair of keys if the nodes were coalesced @@ -335,6 +343,9 @@ coalesceNodes aggressive triv graph (k1, k2) , not $ elementOfUniqSet kMin (nodeConflicts nMax) , not $ elementOfUniqSet kMax (nodeConflicts nMin) + -- can't coalesce the same node + , nodeId nMin /= nodeId nMax + = coalesceNodes_merge aggressive triv graph kMin kMax nMin nMax -- don't do the coalescing after all @@ -350,9 +361,6 @@ coalesceNodes_merge aggressive triv graph kMin kMax nMin nMax | not (isNothing (nodeColor nMin) && isNothing (nodeColor nMax)) = error "GraphOps.coalesceNodes: can't coalesce colored nodes." - | nodeId nMin == nodeId nMax - = error "GraphOps.coalesceNodes: can't coalesce the same node." - --- | otherwise = let @@ -443,7 +451,7 @@ freezeNode k -- classes.. this is just a heuristic, after all. -- -- IDEA: freezing a node might free it up for Simplify.. would be good to check for triv --- right here, and add it to a worklist if known triv/non-move nodes. +-- right here, and add it to a worklist if known triv\/non-move nodes. -- freezeOneInGraph :: (Uniquable k, Outputable k)