diff options
author | Lang Hames <lhames@gmail.com> | 2012-03-26 23:07:23 +0000 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2012-03-26 23:07:23 +0000 |
commit | 20df03ccd572aefadc3d68e4abc2e58c0bef9ff7 (patch) | |
tree | a345dedbf2a51d81dced2ca9add284fa4c0accd4 /include | |
parent | eb6dd23c95c1df08a4a924e2125158c5203b0991 (diff) | |
download | llvm-20df03ccd572aefadc3d68e4abc2e58c0bef9ff7.tar.gz llvm-20df03ccd572aefadc3d68e4abc2e58c0bef9ff7.tar.bz2 llvm-20df03ccd572aefadc3d68e4abc2e58c0bef9ff7.tar.xz |
Add a debug option to dump PBQP graphs during register allocation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153483 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/CodeGen/PBQP/Graph.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/include/llvm/CodeGen/PBQP/Graph.h b/include/llvm/CodeGen/PBQP/Graph.h index 5240729f52..a5d8b0dbd6 100644 --- a/include/llvm/CodeGen/PBQP/Graph.h +++ b/include/llvm/CodeGen/PBQP/Graph.h @@ -350,6 +350,43 @@ namespace PBQP { numNodes = numEdges = 0; } + /// \brief Dump a graph to an output stream. + template <typename OStream> + void dump(OStream &os) { + os << getNumNodes() << " " << getNumEdges() << "\n"; + + for (NodeItr nodeItr = nodesBegin(), nodeEnd = nodesEnd(); + nodeItr != nodeEnd; ++nodeItr) { + const Vector& v = getNodeCosts(nodeItr); + os << "\n" << v.getLength() << "\n"; + assert(v.getLength() != 0 && "Empty vector in graph."); + os << v[0]; + for (unsigned i = 1; i < v.getLength(); ++i) { + os << " " << v[i]; + } + os << "\n"; + } + + for (EdgeItr edgeItr = edgesBegin(), edgeEnd = edgesEnd(); + edgeItr != edgeEnd; ++edgeItr) { + unsigned n1 = std::distance(nodesBegin(), getEdgeNode1(edgeItr)); + unsigned n2 = std::distance(nodesBegin(), getEdgeNode2(edgeItr)); + assert(n1 != n2 && "PBQP graphs shound not have self-edges."); + const Matrix& m = getEdgeCosts(edgeItr); + os << "\n" << n1 << " " << n2 << "\n" + << m.getRows() << " " << m.getCols() << "\n"; + assert(m.getRows() != 0 && "No rows in matrix."); + assert(m.getCols() != 0 && "No cols in matrix."); + for (unsigned i = 0; i < m.getRows(); ++i) { + os << m[i][0]; + for (unsigned j = 1; j < m.getCols(); ++j) { + os << " " << m[i][j]; + } + os << "\n"; + } + } + } + /// \brief Print a representation of this graph in DOT format. /// @param os Output stream to print on. template <typename OStream> |