<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">This looks like it's longer than 80 col. :-)<div><div><span class="Apple-style-span" style="font-family: -webkit-monospace; font-size: 11px; "><br>+static void DumpNodesr(raw_ostream &OS, const SDNode *N, unsigned indent, const SelectionDAG *G, VisitedSDNodeSet &once) {</span></div><div><font class="Apple-style-span" face="-webkit-monospace" size="3"><span class="Apple-style-span" style="font-size: 11px;"><br></span></font></div><div><font class="Apple-style-span" face="-webkit-monospace" size="3"><span class="Apple-style-span" style="font-size: 11px;">Evan</span></font></div><div><font class="Apple-style-span" face="-webkit-monospace" size="3"><span class="Apple-style-span" style="font-size: 11px;"><br></span></font><div><div>On Feb 4, 2009, at 8:46 AM, Stuart Hastings wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Author: stuart<br>Date: Wed Feb 4 10:46:19 2009<br>New Revision: 63736<br><br>URL: <a href="http://llvm.org/viewvc/llvm-project?rev=63736&view=rev">http://llvm.org/viewvc/llvm-project?rev=63736&view=rev</a><br>Log:<br>Since I'm obliged to work with a development OS that currently doesn't<br>support GraphViz, I've been using the foo->dump() facility. This<br>patch is a minor rewrite to the SelectionDAG dump() stuff to make it a<br>little more helpful. The existing foo->dump() functionality does not<br>change; this patch adds foo->dumpr(). All of this is only useful when<br>running LLVM under a debugger.<br><br>Modified:<br> llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h<br> llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp<br><br>Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h<br>URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h?rev=63736&r1=63735&r2=63736&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h?rev=63736&r1=63735&r2=63736&view=diff</a><br><br>==============================================================================<br>--- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h (original)<br>+++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Wed Feb 4 10:46:19 2009<br>@@ -1329,8 +1329,12 @@<br> ///<br> std::string getOperationName(const SelectionDAG *G = 0) const;<br> static const char* getIndexedModeName(ISD::MemIndexedMode AM);<br>+ void print_types(raw_ostream &OS, const SelectionDAG *G) const;<br>+ void print_details(raw_ostream &OS, const SelectionDAG *G) const;<br> void print(raw_ostream &OS, const SelectionDAG *G = 0) const;<br>+ void printr(raw_ostream &OS, const SelectionDAG *G = 0) const;<br> void dump() const;<br>+ void dumpr() const;<br> void dump(const SelectionDAG *G) const;<br><br> static bool classof(const SDNode *) { return true; }<br><br>Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp<br>URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=63736&r1=63735&r2=63736&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=63736&r1=63735&r2=63736&view=diff</a><br><br>==============================================================================<br>--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)<br>+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Wed Feb 4 10:46:19 2009<br>@@ -5638,7 +5638,7 @@<br> errs().flush();<br> }<br><br>-void SDNode::print(raw_ostream &OS, const SelectionDAG *G) const {<br>+void SDNode::print_types(raw_ostream &OS, const SelectionDAG *G) const {<br> OS << (void*)this << ": ";<br><br> for (unsigned i = 0, e = getNumValues(); i != e; ++i) {<br>@@ -5649,15 +5649,9 @@<br> OS << getValueType(i).getMVTString();<br> }<br> OS << " = " << getOperationName(G);<br>+}<br><br>- OS << " ";<br>- for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {<br>- if (i) OS << ", ";<br>- OS << (void*)getOperand(i).getNode();<br>- if (unsigned RN = getOperand(i).getResNo())<br>- OS << ":" << RN;<br>- }<br>-<br>+void SDNode::print_details(raw_ostream &OS, const SelectionDAG *G) const {<br> if (!isTargetOpcode() && getOpcode() == ISD::VECTOR_SHUFFLE) {<br> SDNode *Mask = getOperand(2).getNode();<br> OS << "<";<br>@@ -5798,6 +5792,18 @@<br> }<br> }<br><br>+void SDNode::print(raw_ostream &OS, const SelectionDAG *G) const {<br>+ print_types(OS, G);<br>+ OS << " ";<br>+ for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {<br>+ if (i) OS << ", ";<br>+ OS << (void*)getOperand(i).getNode();<br>+ if (unsigned RN = getOperand(i).getResNo())<br>+ OS << ":" << RN;<br>+ }<br>+ print_details(OS, G);<br>+}<br>+<br> static void DumpNodes(const SDNode *N, unsigned indent, const SelectionDAG *G) {<br> for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i)<br> if (N->getOperand(i).getNode()->hasOneUse())<br>@@ -5826,6 +5832,47 @@<br> cerr << "\n\n";<br> }<br><br>+void SDNode::printr(raw_ostream &OS, const SelectionDAG *G) const {<br>+ print_types(OS, G);<br>+ print_details(OS, G);<br>+}<br>+<br>+typedef SmallPtrSet<const SDNode *, 128> VisitedSDNodeSet;<br>+static void DumpNodesr(raw_ostream &OS, const SDNode *N, unsigned indent, const SelectionDAG *G, VisitedSDNodeSet &once) {<br>+ if (!once.insert(N))<span class="Apple-tab-span" style="white-space:pre"> </span>// If we've been here before, return now.<br>+ return;<br>+ // Dump the current SDNode, but don't end the line yet.<br>+ OS << std::string(indent, ' ');<br>+ N->printr(OS, G);<br>+ // Having printed this SDNode, walk the children:<br>+ for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) {<br>+ const SDNode *child = N->getOperand(i).getNode();<br>+ if (i) OS << ",";<br>+ OS << " ";<br>+ if (child->getNumOperands() == 0) {<br>+ // This child has no grandchildren; print it inline right here.<br>+ child->printr(OS, G);<br>+ once.insert(child);<br>+ } else {<span class="Apple-tab-span" style="white-space:pre"> </span>// Just the address. FIXME: also print the child's opcode<br>+ OS << (void*)child;<br>+ if (unsigned RN = N->getOperand(i).getResNo())<br>+<span class="Apple-tab-span" style="white-space:pre"> </span>OS << ":" << RN;<br>+ }<br>+ }<br>+ OS << "\n";<br>+ // Dump children that have grandchildren on their own line(s).<br>+ for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) {<br>+ const SDNode *child = N->getOperand(i).getNode();<br>+ DumpNodesr(OS, child, indent+2, G, once);<br>+ }<br>+}<br>+<br>+void SDNode::dumpr() const {<br>+ VisitedSDNodeSet once;<br>+ DumpNodesr(errs(), this, 0, 0, once);<br>+ errs().flush();<br>+}<br>+<br> const Type *ConstantPoolSDNode::getType() const {<br> if (isMachineConstantPoolEntry())<br> return Val.MachineCPVal->getType();<br><br><br>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br></div></blockquote></div><br></div></div></body></html>