[llvm-commits] [llvm] r93538 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAGNodes.h lib/CodeGen/SelectionDAG/SelectionDAG.cpp lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
David Greene
greened at obbligato.org
Fri Jan 15 11:43:24 PST 2010
Author: greened
Date: Fri Jan 15 13:43:23 2010
New Revision: 93538
URL: http://llvm.org/viewvc/llvm-project?rev=93538&view=rev
Log:
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.
Modified:
llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h?rev=93538&r1=93537&r2=93538&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Fri Jan 15 13:43:23 2010
@@ -1285,10 +1285,29 @@
void print_details(raw_ostream &OS, const SelectionDAG *G) const;
void print(raw_ostream &OS, const SelectionDAG *G = 0) const;
void printr(raw_ostream &OS, const SelectionDAG *G = 0) const;
+ /// printWithDepth - Print a SelectionDAG node and children up to
+ /// depth "depth." "limit" controls whether a message should be
+ /// printed if we hit depth "depth."
+ ///
+ void printWithDepth(raw_ostream &O, const SelectionDAG *G = 0,
+ unsigned depth = -1, unsigned indent = 0,
+ bool limit = false) const;
+ /// printWithFullDepth - Print a SelectionDAG node and all children
+ /// down to the leaves.
+ ///
+ void printWithFullDepth(raw_ostream &O, const SelectionDAG *G = 0,
+ unsigned indent = 0) const;
void dump() const;
void dumpr() const;
void dump(const SelectionDAG *G) const;
void dumpr(const SelectionDAG *G) const;
+ /// dumpWithDepth - printWithDepth to dbgs().
+ ///
+ void dumpWithDepth(const SelectionDAG *G = 0, unsigned depth = 1,
+ unsigned indent = 0, bool limit = false) const;
+ /// dumpWithFullDepth - printWithFullDepth to dbgs().
+ ///
+ void dumpWithFullDepth(const SelectionDAG *G = 0, unsigned indent = 0) const;
static bool classof(const SDNode *) { return true; }
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=93538&r1=93537&r2=93538&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Fri Jan 15 13:43:23 2010
@@ -5893,6 +5893,49 @@
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())
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=93538&r1=93537&r2=93538&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Fri Jan 15 13:43:23 2010
@@ -1426,7 +1426,7 @@
std::string msg;
raw_string_ostream Msg(msg);
Msg << "Cannot yet select: ";
- N->print(Msg, CurDAG);
+ N->printWithFullDepth(Msg, CurDAG);
llvm_report_error(Msg.str());
}
More information about the llvm-commits
mailing list