Print the DAG out more like a DAG in nested format.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19422 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2005-01-09 20:38:33 +00:00
parent 49d24716a4
commit ea946cdb1b

View File

@ -920,15 +920,31 @@ void SDNode::dump() const {
}
static void DumpNodes(SDNode *N, unsigned indent) {
for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i)
if (N->getOperand(i).Val->hasOneUse())
DumpNodes(N->getOperand(i).Val, indent+2);
else
std::cerr << "\n" << std::string(indent+2, ' ')
<< (void*)N->getOperand(i).Val << ": <multiple use>";
std::cerr << "\n" << std::string(indent, ' ');
N->dump();
}
void SelectionDAG::dump() const {
std::cerr << "SelectionDAG has " << AllNodes.size() << " nodes:";
std::vector<SDNode*> Nodes(AllNodes);
std::sort(Nodes.begin(), Nodes.end());
for (unsigned i = 0, e = Nodes.size(); i != e; ++i) {
std::cerr << "\n ";
Nodes[i]->dump();
if (!Nodes[i]->hasOneUse() && Nodes[i] != getRoot().Val)
DumpNodes(Nodes[i], 2);
}
DumpNodes(getRoot().Val, 2);
std::cerr << "\n\n";
}