Add a node to the graph, linking up its edges
Moduleghc-9.10.3GHC2021
GHC.Data.Graph.Ops
Basic operations on graphs.
- 24 values
- Packageghc-9.10.3
- Exports24
- LanguageGHC2021
- LicenceBSD-3-Clause
- SourceOps.hs
Delete a node and all its edges from the graph.
Get a node from the graph, throwing an error if it's not there
Lookup a node from the graph.
Modify a node in the graph. returns Nothing if the node isn't present.
Get the size of the graph, O(n)
Union two graphs together.
Add a conflict between nodes to the graph, creating the nodes required. Conflicts are virtual regs which need to be colored differently.
Delete a conflict edge. k1 -> k2 returns Nothing if the node isn't in the graph
Add some conflicts to the graph, creating nodes if required. All the nodes in the set are taken to conflict with each other.
Add a coalescence edge to the graph, creating nodes if required. It is considered advantageous to assign the same color to nodes in a coalescence.
Delete a coalescence edge (k1 -> k2) from the graph.
Add an exclusion to the graph, creating nodes if required. These are extra colors that the node cannot use.
Add a color preference to the graph, creating nodes if required. The most recently added preference is the most preferred. The algorithm tries to assign a node it's preferred color if possible.
coalesceNodes Coalesce this pair of nodes unconditionally / aggressively. The resulting node is the one with the least key.
returns: Just the pair of keys if the nodes were coalesced the second element of the pair being the least one
Nothing if either of the nodes weren't in the graph
coalesceGraph Do aggressive coalescing on this graph. returns the new graph and the list of pairs of nodes that got coalesced together. for each pair, the resulting node will have the least key and be second in the pair.
freezeNode Freeze a node This is for the iterative coalescer. By freezing a node we give up on ever coalescing it. Move all its coalesce edges into the frozen set - and update back edges from other nodes.
Freeze one node in the graph This if for the iterative coalescer. Look for a move related node of low degree and freeze it.
We probably don't need to scan the whole graph looking for the node of absolute lowest degree. Just sample the first few and choose the one with the lowest degree out of those. Also, we don't make any distinction between conflicts of different 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.
Freeze all the nodes in the graph for debugging the iterative allocator.
Find all the nodes in the graph that meet some criteria
Set the color of a certain node
validateGraph validate the internal structure of a graph all its edges should point to valid nodes If they don't then throw an error
Slurp out a map of how many nodes had a certain number of conflict neighbours