+{-# OPTIONS -fno-warn-missing-signatures #-}
-- | Basic operations on graphs.
--
--- TODO: refine coalescing crieteria
-
-{-# OPTIONS -fno-warn-missing-signatures #-}
module GraphOps (
addNode, delNode, getNode, lookupNode, modNode,
-- less colorable (aggressive coalescing)
-> Triv k cls color
-> Graph k cls color
- -> (Graph k cls color, [(k, k)])
+ -> ( Graph k cls color
+ , [(k, k)]) -- pairs of nodes that were coalesced, in the order that the
+ -- coalescing was applied.
coalesceGraph aggressive triv graph
= coalesceGraph' aggressive triv graph []
-- keep running until there are no more coalesces can be found
in case catMaybes mPairs of
- [] -> (graph', kkPairsAcc)
- pairs -> coalesceGraph' aggressive triv graph' (pairs ++ kkPairsAcc)
+ [] -> (graph', reverse 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
-- 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)