mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-23 01:24:30 +00:00
Rewrite the PBQP graph data structure.
The new graph structure replaces the node and edge linked lists with vectors. Free lists (well, free vectors) are used for fast insertion/deletion. The ultimate aim is to make PBQP graphs cheap to clone. The motivation is that the PBQP solver destructively consumes input graphs while computing a solution, forcing the graph to be fully reconstructed for each round of PBQP. This imposes a high cost on large functions, which often require several rounds of solving/spilling to find a final register allocation. If we can cheaply clone the PBQP graph and incrementally update it between rounds then hopefully we can reduce this cost. Further, once we begin pooling matrix/vector values (future work), we can cache some PBQP solver metadata and share it between cloned graphs, allowing the PBQP solver to re-use some of the computation done in earlier rounds. For now this is just a data structure update. The allocator and solver still use the graph the same way as before, fully reconstructing it between each round. I expect no material change from this update, although it may change the iteration order of the nodes, causing ties in the solver to break in different directions, and this could perturb the generated allocations (hopefully in a completely benign way). Thanks very much to Arnaud Allard de Grandmaison for encouraging me to get back to work on this, and for a lot of discussion and many useful PBQP test cases. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194300 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -26,8 +26,7 @@ namespace PBQP {
|
||||
class Solution {
|
||||
private:
|
||||
|
||||
typedef std::map<Graph::ConstNodeItr, unsigned,
|
||||
NodeItrComparator> SelectionsMap;
|
||||
typedef std::map<Graph::NodeId, unsigned> SelectionsMap;
|
||||
SelectionsMap selections;
|
||||
|
||||
unsigned r0Reductions, r1Reductions, r2Reductions, rNReductions;
|
||||
@ -73,15 +72,15 @@ namespace PBQP {
|
||||
/// \brief Set the selection for a given node.
|
||||
/// @param nItr Node iterator.
|
||||
/// @param selection Selection for nItr.
|
||||
void setSelection(Graph::NodeItr nItr, unsigned selection) {
|
||||
selections[nItr] = selection;
|
||||
void setSelection(Graph::NodeId nodeId, unsigned selection) {
|
||||
selections[nodeId] = selection;
|
||||
}
|
||||
|
||||
/// \brief Get a node's selection.
|
||||
/// @param nItr Node iterator.
|
||||
/// @return The selection for nItr;
|
||||
unsigned getSelection(Graph::ConstNodeItr nItr) const {
|
||||
SelectionsMap::const_iterator sItr = selections.find(nItr);
|
||||
unsigned getSelection(Graph::NodeId nodeId) const {
|
||||
SelectionsMap::const_iterator sItr = selections.find(nodeId);
|
||||
assert(sItr != selections.end() && "No selection for node.");
|
||||
return sItr->second;
|
||||
}
|
||||
|
Reference in New Issue
Block a user