LLVM 20.0.0git
|
#include "llvm/CodeGen/PBQP/Graph.h"
Classes | |
class | AdjEdgeIdSet |
class | EdgeIdSet |
class | EdgeItr |
class | NodeIdSet |
class | NodeItr |
Public Types | |
using | RawVector = typename SolverT::RawVector |
using | RawMatrix = typename SolverT::RawMatrix |
using | Vector = typename SolverT::Vector |
using | Matrix = typename SolverT::Matrix |
using | VectorPtr = typename CostAllocator::VectorPtr |
using | MatrixPtr = typename CostAllocator::MatrixPtr |
using | NodeMetadata = typename SolverT::NodeMetadata |
using | EdgeMetadata = typename SolverT::EdgeMetadata |
using | GraphMetadata = typename SolverT::GraphMetadata |
using | AdjEdgeItr = typename NodeEntry::AdjEdgeItr |
Public Types inherited from llvm::PBQP::GraphBase | |
using | NodeId = unsigned |
using | EdgeId = unsigned |
Public Member Functions | |
Graph ()=default | |
Construct an empty PBQP graph. | |
Graph (GraphMetadata Metadata) | |
Construct an empty PBQP graph with the given graph metadata. | |
GraphMetadata & | getMetadata () |
Get a reference to the graph metadata. | |
const GraphMetadata & | getMetadata () const |
Get a const-reference to the graph metadata. | |
void | setSolver (SolverT &S) |
Lock this graph to the given solver instance in preparation for running the solver. | |
void | unsetSolver () |
Release from solver instance. | |
template<typename OtherVectorT > | |
NodeId | addNode (OtherVectorT Costs) |
Add a node with the given costs. | |
template<typename OtherVectorPtrT > | |
NodeId | addNodeBypassingCostAllocator (OtherVectorPtrT Costs) |
Add a node bypassing the cost allocator. | |
template<typename OtherVectorT > | |
EdgeId | addEdge (NodeId N1Id, NodeId N2Id, OtherVectorT Costs) |
Add an edge between the given nodes with the given costs. | |
template<typename OtherMatrixPtrT > | |
NodeId | addEdgeBypassingCostAllocator (NodeId N1Id, NodeId N2Id, OtherMatrixPtrT Costs) |
Add an edge bypassing the cost allocator. | |
bool | empty () const |
Returns true if the graph is empty. | |
NodeIdSet | nodeIds () const |
EdgeIdSet | edgeIds () const |
AdjEdgeIdSet | adjEdgeIds (NodeId NId) |
unsigned | getNumNodes () const |
Get the number of nodes in the graph. | |
unsigned | getNumEdges () const |
Get the number of edges in the graph. | |
template<typename OtherVectorT > | |
void | setNodeCosts (NodeId NId, OtherVectorT Costs) |
Set a node's cost vector. | |
const VectorPtr & | getNodeCostsPtr (NodeId NId) const |
Get a VectorPtr to a node's cost vector. | |
const Vector & | getNodeCosts (NodeId NId) const |
Get a node's cost vector. | |
NodeMetadata & | getNodeMetadata (NodeId NId) |
const NodeMetadata & | getNodeMetadata (NodeId NId) const |
NodeEntry::AdjEdgeList::size_type | getNodeDegree (NodeId NId) const |
template<typename OtherMatrixT > | |
void | updateEdgeCosts (EdgeId EId, OtherMatrixT Costs) |
Update an edge's cost matrix. | |
const MatrixPtr & | getEdgeCostsPtr (EdgeId EId) const |
Get a MatrixPtr to a node's cost matrix. | |
const Matrix & | getEdgeCosts (EdgeId EId) const |
Get an edge's cost matrix. | |
EdgeMetadata & | getEdgeMetadata (EdgeId EId) |
const EdgeMetadata & | getEdgeMetadata (EdgeId EId) const |
NodeId | getEdgeNode1Id (EdgeId EId) const |
Get the first node connected to this edge. | |
NodeId | getEdgeNode2Id (EdgeId EId) const |
Get the second node connected to this edge. | |
NodeId | getEdgeOtherNodeId (EdgeId EId, NodeId NId) |
Get the "other" node connected to this edge. | |
EdgeId | findEdge (NodeId N1Id, NodeId N2Id) |
Get the edge connecting two nodes. | |
void | removeNode (NodeId NId) |
Remove a node from the graph. | |
void | disconnectEdge (EdgeId EId, NodeId NId) |
Disconnect an edge from the given node. | |
void | disconnectAllNeighborsFromNode (NodeId NId) |
Convenience method to disconnect all neighbours from the given node. | |
void | reconnectEdge (EdgeId EId, NodeId NId) |
Re-attach an edge to its nodes. | |
void | removeEdge (EdgeId EId) |
Remove an edge from the graph. | |
void | clear () |
Remove all nodes and edges from the graph. | |
Additional Inherited Members | |
Static Public Member Functions inherited from llvm::PBQP::GraphBase | |
static NodeId | invalidNodeId () |
Returns a value representing an invalid (non-existent) node. | |
static EdgeId | invalidEdgeId () |
Returns a value representing an invalid (non-existent) edge. | |
Instances of this class describe PBQP problems.
using llvm::PBQP::Graph< SolverT >::AdjEdgeItr = typename NodeEntry::AdjEdgeItr |
using llvm::PBQP::Graph< SolverT >::EdgeMetadata = typename SolverT::EdgeMetadata |
using llvm::PBQP::Graph< SolverT >::GraphMetadata = typename SolverT::GraphMetadata |
using llvm::PBQP::Graph< SolverT >::Matrix = typename SolverT::Matrix |
using llvm::PBQP::Graph< SolverT >::MatrixPtr = typename CostAllocator::MatrixPtr |
using llvm::PBQP::Graph< SolverT >::NodeMetadata = typename SolverT::NodeMetadata |
using llvm::PBQP::Graph< SolverT >::RawMatrix = typename SolverT::RawMatrix |
using llvm::PBQP::Graph< SolverT >::RawVector = typename SolverT::RawVector |
using llvm::PBQP::Graph< SolverT >::Vector = typename SolverT::Vector |
using llvm::PBQP::Graph< SolverT >::VectorPtr = typename CostAllocator::VectorPtr |
|
default |
Construct an empty PBQP graph.
|
inline |
|
inline |
Add an edge between the given nodes with the given costs.
N1Id | First node. |
N2Id | Second node. |
Costs | Cost matrix for new edge. |
Definition at line 409 of file Graph.h.
References assert(), and llvm::PBQP::Graph< SolverT >::getNodeCosts().
|
inline |
Add an edge bypassing the cost allocator.
N1Id | First node. |
N2Id | Second node. |
Costs | Cost matrix for new edge. |
This method allows for fast addition of an edge whose costs don't need to be passed through the cost allocator. The most common use case for this is when duplicating costs from an existing edge (when using a pooling allocator). These have already been uniqued, so we can avoid re-constructing and re-uniquing them by attaching them directly to the new edge.
Definition at line 434 of file Graph.h.
References assert(), and llvm::PBQP::Graph< SolverT >::getNodeCosts().
|
inline |
|
inline |
Add a node bypassing the cost allocator.
Costs | Cost vector ptr for the new node (must be convertible to VectorPtr). |
This method allows for fast addition of a node whose costs don't need to be passed through the cost allocator. The most common use case for this is when duplicating costs from an existing node (when using a pooling allocator). These have already been uniqued, so we can avoid re-constructing and re-uniquing them by attaching them directly to the new node.
|
inline |
Definition at line 452 of file Graph.h.
Referenced by llvm::PBQP::Graph< SolverT >::disconnectAllNeighborsFromNode(), and llvm::PBQP::Graph< SolverT >::findEdge().
|
inline |
|
inline |
Convenience method to disconnect all neighbours from the given node.
Definition at line 635 of file Graph.h.
References llvm::PBQP::Graph< SolverT >::adjEdgeIds(), llvm::PBQP::Graph< SolverT >::disconnectEdge(), and llvm::PBQP::Graph< SolverT >::getEdgeOtherNodeId().
|
inline |
Disconnect an edge from the given node.
Removes the given edge from the adjacency list of the given node. This operation leaves the edge in an 'asymmetric' state: It will no longer appear in an iteration over the given node's (NId's) edges, but will appear in an iteration over the 'other', unnamed node's edges.
This does not correspond to any normal graph operation, but exists to support efficient PBQP graph-reduction based solvers. It is used to 'effectively' remove the unnamed node from the graph while the solver is performing the reduction. The solver will later call reconnectNode to restore the edge in the named node's adjacency list.
Since the degree of a node is the number of connected edges, disconnecting an edge from a node 'u' will cause the degree of 'u' to drop by 1.
A disconnected edge WILL still appear in an iteration over the graph edges.
A disconnected edge should not be removed from the graph, it should be reconnected first.
A disconnected edge can be reconnected by calling the reconnectEdge method.
Definition at line 625 of file Graph.h.
References E.
Referenced by llvm::PBQP::Graph< SolverT >::disconnectAllNeighborsFromNode().
|
inline |
Definition at line 450 of file Graph.h.
Referenced by llvm::PBQP::Graph< SolverT >::setSolver().
|
inline |
Returns true if the graph is empty.
Definition at line 447 of file Graph.h.
References llvm::PBQP::Graph< SolverT >::NodeIdSet::empty().
|
inline |
Get the edge connecting two nodes.
N1Id | First node id. |
N2Id | Second node id. |
Definition at line 573 of file Graph.h.
References llvm::PBQP::Graph< SolverT >::adjEdgeIds(), llvm::PBQP::Graph< SolverT >::getEdgeNode1Id(), llvm::PBQP::Graph< SolverT >::getEdgeNode2Id(), and llvm::PBQP::GraphBase::invalidEdgeId().
|
inline |
Get an edge's cost matrix.
EId | Edge id. |
Definition at line 530 of file Graph.h.
Referenced by llvm::PBQP::RegAlloc::RegAllocSolverImpl::handleDisconnectEdge(), llvm::PBQP::RegAlloc::RegAllocSolverImpl::handleReconnectEdge(), and llvm::PBQP::RegAlloc::RegAllocSolverImpl::handleUpdateCosts().
|
inline |
Get a MatrixPtr to a node's cost matrix.
Rarely useful - use getEdgeCosts where possible.
EId | Edge id. |
This method is primarily useful for duplicating costs quickly by bypassing the cost allocator. See addNodeBypassingCostAllocator. Prefer getEdgeCosts when dealing with edge cost values.
|
inline |
|
inline |
|
inline |
Get the first node connected to this edge.
EId | Edge id. |
Definition at line 545 of file Graph.h.
Referenced by llvm::PBQP::Graph< SolverT >::findEdge(), llvm::PBQP::RegAlloc::RegAllocSolverImpl::handleAddEdge(), and llvm::PBQP::RegAlloc::RegAllocSolverImpl::handleUpdateCosts().
|
inline |
Get the second node connected to this edge.
EId | Edge id. |
Definition at line 552 of file Graph.h.
Referenced by llvm::PBQP::Graph< SolverT >::findEdge(), llvm::PBQP::RegAlloc::RegAllocSolverImpl::handleAddEdge(), llvm::PBQP::RegAlloc::RegAllocSolverImpl::handleDisconnectEdge(), llvm::PBQP::RegAlloc::RegAllocSolverImpl::handleReconnectEdge(), and llvm::PBQP::RegAlloc::RegAllocSolverImpl::handleUpdateCosts().
|
inline |
Get the "other" node connected to this edge.
EId | Edge id. |
NId | Node id for the "given" node. |
Definition at line 560 of file Graph.h.
References E.
Referenced by llvm::PBQP::Graph< SolverT >::disconnectAllNeighborsFromNode().
|
inline |
|
inline |
|
inline |
Get a node's cost vector.
NId | Node id. |
Definition at line 488 of file Graph.h.
References llvm::PBQP::Graph< SolverT >::getNodeCostsPtr().
Referenced by llvm::PBQP::Graph< SolverT >::addEdge(), llvm::PBQP::Graph< SolverT >::addEdgeBypassingCostAllocator(), and llvm::PBQP::RegAlloc::RegAllocSolverImpl::handleAddNode().
|
inline |
Get a VectorPtr to a node's cost vector.
Rarely useful - use getNodeCosts where possible.
NId | Node id. |
This method is primarily useful for duplicating costs quickly by bypassing the cost allocator. See addNodeBypassingCostAllocator. Prefer getNodeCosts when dealing with node cost values.
Definition at line 481 of file Graph.h.
Referenced by llvm::PBQP::Graph< SolverT >::getNodeCosts().
|
inline |
|
inline |
Definition at line 492 of file Graph.h.
Referenced by llvm::PBQP::RegAlloc::RegAllocSolverImpl::handleAddNode(), llvm::PBQP::RegAlloc::RegAllocSolverImpl::handleDisconnectEdge(), llvm::PBQP::RegAlloc::RegAllocSolverImpl::handleReconnectEdge(), and llvm::PBQP::RegAlloc::RegAllocSolverImpl::handleUpdateCosts().
|
inline |
|
inline |
Get the number of edges in the graph.
Definition at line 460 of file Graph.h.
References llvm::PBQP::Graph< SolverT >::EdgeIdSet::size().
|
inline |
Get the number of nodes in the graph.
Definition at line 456 of file Graph.h.
References llvm::PBQP::Graph< SolverT >::NodeIdSet::size().
|
inline |
Definition at line 449 of file Graph.h.
Referenced by llvm::PBQP::Graph< SolverT >::setSolver().
|
inline |
|
inline |
Remove an edge from the graph.
EId | Edge id. |
Definition at line 653 of file Graph.h.
References E.
Referenced by llvm::PBQP::Graph< SolverT >::removeNode().
|
inline |
Remove a node from the graph.
NId | Node id. |
Definition at line 585 of file Graph.h.
References N, and llvm::PBQP::Graph< SolverT >::removeEdge().
|
inline |
|
inline |
Lock this graph to the given solver instance in preparation for running the solver.
This method will call solver.handleAddNode for each node in the graph, and handleAddEdge for each edge, to give the solver an opportunity to set up any requried metadata.
Definition at line 356 of file Graph.h.
References assert(), llvm::PBQP::Graph< SolverT >::edgeIds(), and llvm::PBQP::Graph< SolverT >::nodeIds().
Referenced by llvm::PBQP::RegAlloc::RegAllocSolverImpl::solve().
|
inline |
Release from solver instance.
Definition at line 366 of file Graph.h.
References assert().
Referenced by llvm::PBQP::RegAlloc::RegAllocSolverImpl::solve().
|
inline |