aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff options
context:
space:
mode:
authorDavid Greene <greened@obbligato.org>2010-01-15 19:43:23 +0000
committerDavid Greene <greened@obbligato.org>2010-01-15 19:43:23 +0000
commitac931c011fae9392b5d68e763ec64ee25181c267 (patch)
treeecc7b06f8b53b117b137b982a3131ab64c2abc76 /lib/CodeGen/SelectionDAG/SelectionDAG.cpp
parent54482b472a888c9efe003ad694ecf47b21878f0e (diff)
Add some debug routines to SelectionDAG to dump full DAGs.
print/dumpWithDepth allows one to dump a DAG up to N levels deep. dump/printWithFullDepth prints the whole DAG, subject to a depth limit on 100 in the default case (to prevent infinite recursion). Have CannotYetSelect to a dumpWithFullDepth so it is clearer exactly what the non-matching DAG looks like. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93538 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAG.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index cb1a0d660b..b8ac005952 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -5893,6 +5893,49 @@ void SDNode::print(raw_ostream &OS, const SelectionDAG *G) const {
print_details(OS, G);
}
+void SDNode::printWithDepth(raw_ostream &OS, const SelectionDAG *G,
+ unsigned depth, unsigned indent,
+ bool limit) const {
+ if (depth == 0) {
+ if (limit)
+ OS << "*** <max depth> - Cycle? ***\n";
+ return;
+ }
+
+ int myindent = indent;
+
+ while (myindent--) {
+ OS << ' ';
+ }
+
+ print(OS, G);
+
+ if (depth > 1) {
+ for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
+ OS << '\n';
+ getOperand(i).getNode()->printWithDepth(OS, G,
+ depth > 0 ? depth-1 : depth,
+ indent+2);
+ }
+ }
+}
+
+void SDNode::printWithFullDepth(raw_ostream &OS, const SelectionDAG *G,
+ unsigned indent) const {
+ // Don't print impossibly deep things.
+ printWithDepth(OS, G, 100, indent, true);
+}
+
+void SDNode::dumpWithDepth(const SelectionDAG *G, unsigned depth,
+ unsigned indent, bool limit) const {
+ printWithDepth(dbgs(), G, depth, indent, limit);
+}
+
+void SDNode::dumpWithFullDepth(const SelectionDAG *G, unsigned indent) const {
+ // Don't print impossibly deep things.
+ dumpWithDepth(G, 100, indent, true);
+}
+
static void DumpNodes(const SDNode *N, unsigned indent, const SelectionDAG *G) {
for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i)
if (N->getOperand(i).getNode()->hasOneUse())