[llvm-commits] [llvm] r93901 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAGNodes.h lib/CodeGen/SelectionDAG/SelectionDAG.cpp lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
David Greene
greened at obbligato.org
Tue Jan 19 12:37:34 PST 2010
Author: greened
Date: Tue Jan 19 14:37:34 2010
New Revision: 93901
URL: http://llvm.org/viewvc/llvm-project?rev=93901&view=rev
Log:
Add some new debugging APIs to print out "raw" SelectionDAGs to make
understanding CannotYTetSelect and other errors easier.
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=93901&r1=93900&r2=93901&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Tue Jan 19 14:37:34 2010
@@ -1285,37 +1285,55 @@
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."
+
+ /// printrFull - Print a SelectionDAG node and all children down to
+ /// the leaves. The given SelectionDAG allows target-specific nodes
+ /// to be printed in human-readable form. Unlike printr, this will
+ /// print the whole DAG, including children that appear multiple
+ /// times.
///
- 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 printrFull(raw_ostream &O, const SelectionDAG *G = 0) const;
+
+ /// printrWithDepth - Print a SelectionDAG node and children up to
+ /// depth "depth." The given SelectionDAG allows target-specific
+ /// nodes to be printed in human-readable form. Unlike printr, this
+ /// will print children that appear multiple times wherever they are
+ /// used.
///
- void printWithFullDepth(raw_ostream &O, const SelectionDAG *G = 0,
- unsigned indent = 0) const;
+ void printrWithDepth(raw_ostream &O, const SelectionDAG *G = 0,
+ unsigned depth = 100) const;
+
+
/// dump - Dump this node, for debugging.
void dump() const;
+
/// dumpr - Dump (recursively) this node and its use-def subgraph.
void dumpr() const;
+
/// dump - Dump this node, for debugging.
/// The given SelectionDAG allows target-specific nodes to be printed
/// in human-readable form.
void dump(const SelectionDAG *G) const;
+
/// dumpr - Dump (recursively) this node and its use-def subgraph.
/// The given SelectionDAG allows target-specific nodes to be printed
/// in human-readable form.
void dumpr(const SelectionDAG *G) const;
- /// dumpWithDepth - printWithDepth to dbgs().
+
+ /// dumprFull - printrFull to dbgs(). The given SelectionDAG allows
+ /// target-specific nodes to be printed in human-readable form.
+ /// Unlike dumpr, this will print the whole DAG, including children
+ /// that appear multiple times.
///
- void dumpWithDepth(const SelectionDAG *G = 0, unsigned depth = 1,
- unsigned indent = 0, bool limit = false) const;
- /// dumpWithFullDepth - printWithFullDepth to dbgs().
+ void dumprFull(const SelectionDAG *G = 0) const;
+
+ /// dumprWithDepth - printrWithDepth to dbgs(). The given
+ /// SelectionDAG allows target-specific nodes to be printed in
+ /// human-readable form. Unlike dumpr, this will print children
+ /// that appear multiple times wherever they are used.
///
- void dumpWithFullDepth(const SelectionDAG *G = 0, unsigned indent = 0) const;
+ void dumprWithDepth(const SelectionDAG *G = 0, unsigned depth = 100) 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=93901&r1=93900&r2=93901&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Tue Jan 19 14:37:34 2010
@@ -5893,47 +5893,43 @@
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";
+static void printrWithDepthHelper(raw_ostream &OS, const SDNode *N,
+ const SelectionDAG *G, unsigned depth,
+ unsigned indent)
+{
+ if (depth == 0)
return;
- }
- int myindent = indent;
+ OS.indent(indent);
- while (myindent--) {
- OS << ' ';
- }
+ N->print(OS, G);
- print(OS, G);
+ if (depth < 1)
+ return;
- 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);
- }
+ for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) {
+ OS << '\n';
+ printrWithDepthHelper(OS, N->getOperand(i).getNode(), G, depth-1, indent+2);
}
+}
+
+void SDNode::printrWithDepth(raw_ostream &OS, const SelectionDAG *G,
+ unsigned depth) const {
+ printrWithDepthHelper(OS, this, G, depth, 0);
}
-void SDNode::printWithFullDepth(raw_ostream &OS, const SelectionDAG *G,
- unsigned indent) const {
+void SDNode::printrFull(raw_ostream &OS, const SelectionDAG *G) const {
// Don't print impossibly deep things.
- printWithDepth(OS, G, 100, indent, true);
-}
+ printrWithDepth(OS, G, 100);
+}
-void SDNode::dumpWithDepth(const SelectionDAG *G, unsigned depth,
- unsigned indent, bool limit) const {
- printWithDepth(dbgs(), G, depth, indent, limit);
+void SDNode::dumprWithDepth(const SelectionDAG *G, unsigned depth) const {
+ printrWithDepth(dbgs(), G, depth);
}
-void SDNode::dumpWithFullDepth(const SelectionDAG *G, unsigned indent) const {
+void SDNode::dumprFull(const SelectionDAG *G) const {
// Don't print impossibly deep things.
- dumpWithDepth(G, 100, indent, true);
+ dumprWithDepth(G, 100);
}
static void DumpNodes(const SDNode *N, unsigned indent, const SelectionDAG *G) {
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=93901&r1=93900&r2=93901&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Tue Jan 19 14:37:34 2010
@@ -1426,7 +1426,7 @@
std::string msg;
raw_string_ostream Msg(msg);
Msg << "Cannot yet select: ";
- N->printWithFullDepth(Msg, CurDAG);
+ N->printrFull(Msg, CurDAG);
llvm_report_error(Msg.str());
}
More information about the llvm-commits
mailing list