blob: a528c80ddaead264a8aefe615b074eebecf0948f [file] [log] [blame]
Chris Lattner7f650752005-01-10 23:08:40 +00001//===-- SelectionDAGPrinter.cpp - Implement SelectionDAG::viewGraph() -----===//
Misha Brukman835702a2005-04-21 22:36:52 +00002//
Chris Lattner7f650752005-01-10 23:08:40 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Misha Brukman835702a2005-04-21 22:36:52 +00007//
Chris Lattner7f650752005-01-10 23:08:40 +00008//===----------------------------------------------------------------------===//
9//
10// This implements the SelectionDAG::viewGraph method.
11//
12//===----------------------------------------------------------------------===//
13
Chris Lattnerc30405e2005-08-26 17:15:30 +000014#include "llvm/Constants.h"
15#include "llvm/Function.h"
Chris Lattnerc610e622006-03-05 09:38:03 +000016#include "llvm/Assembly/Writer.h"
Chris Lattner7f650752005-01-10 23:08:40 +000017#include "llvm/CodeGen/SelectionDAG.h"
Dan Gohman60cb69e2008-11-19 23:18:57 +000018#include "llvm/CodeGen/ScheduleDAGSDNodes.h"
Evan Cheng45fe3bc2006-09-12 21:00:35 +000019#include "llvm/CodeGen/MachineConstantPool.h"
Chris Lattner7f650752005-01-10 23:08:40 +000020#include "llvm/CodeGen/MachineFunction.h"
Bill Wendling2e5068942008-07-03 22:53:42 +000021#include "llvm/CodeGen/MachineModuleInfo.h"
Dan Gohman7168de72008-07-17 21:12:16 +000022#include "llvm/CodeGen/PseudoSourceValue.h"
Dan Gohman3a4be0f2008-02-10 18:45:23 +000023#include "llvm/Target/TargetRegisterInfo.h"
Chris Lattner49903352005-08-19 21:21:16 +000024#include "llvm/Target/TargetMachine.h"
David Greeneb04e7c32008-10-27 18:17:03 +000025#include "llvm/Support/Debug.h"
Chris Lattner7f650752005-01-10 23:08:40 +000026#include "llvm/Support/GraphWriter.h"
Chris Lattner838aff32008-08-23 22:53:13 +000027#include "llvm/Support/raw_ostream.h"
David Greeneb04e7c32008-10-27 18:17:03 +000028#include "llvm/ADT/DenseSet.h"
Chris Lattner1308b482005-01-11 00:34:33 +000029#include "llvm/ADT/StringExtras.h"
Chris Lattnerb47f5e62005-07-15 22:48:31 +000030#include "llvm/Config/config.h"
Chris Lattner7f650752005-01-10 23:08:40 +000031#include <fstream>
32using namespace llvm;
33
Chris Lattner12be0272005-01-10 23:26:00 +000034namespace llvm {
35 template<>
36 struct DOTGraphTraits<SelectionDAG*> : public DefaultDOTGraphTraits {
Dan Gohmanf1dc3622008-07-21 21:06:55 +000037 static bool hasEdgeDestLabels() {
38 return true;
39 }
40
41 static unsigned numEdgeDestLabels(const void *Node) {
42 return ((const SDNode *) Node)->getNumValues();
43 }
44
45 static std::string getEdgeDestLabel(const void *Node, unsigned i) {
46 return ((const SDNode *) Node)->getValueType(i).getMVTString();
47 }
48
49 /// edgeTargetsEdgeSource - This method returns true if this outgoing edge
50 /// should actually target another edge source, not a node. If this method is
51 /// implemented, getEdgeTarget should be implemented.
52 template<typename EdgeIter>
53 static bool edgeTargetsEdgeSource(const void *Node, EdgeIter I) {
54 return true;
55 }
56
57 /// getEdgeTarget - If edgeTargetsEdgeSource returns true, this method is
58 /// called to determine which outgoing edge of Node is the target of this
59 /// edge.
60 template<typename EdgeIter>
61 static EdgeIter getEdgeTarget(const void *Node, EdgeIter I) {
62 SDNode *TargetNode = *I;
63 SDNodeIterator NI = SDNodeIterator::begin(TargetNode);
Gabor Greifabfdf922008-08-26 22:36:50 +000064 std::advance(NI, I.getNode()->getOperand(I.getOperand()).getResNo());
Dan Gohmanf1dc3622008-07-21 21:06:55 +000065 return NI;
66 }
67
Chris Lattner12be0272005-01-10 23:26:00 +000068 static std::string getGraphName(const SelectionDAG *G) {
69 return G->getMachineFunction().getFunction()->getName();
70 }
Chris Lattner1308b482005-01-11 00:34:33 +000071
72 static bool renderGraphFromBottomUp() {
73 return true;
Chris Lattner12be0272005-01-10 23:26:00 +000074 }
Chris Lattnerfda69442005-10-01 00:17:07 +000075
76 static bool hasNodeAddressLabel(const SDNode *Node,
77 const SelectionDAG *Graph) {
78 return true;
79 }
Chris Lattnerc5ab6ce2006-10-20 18:06:09 +000080
81 /// If you want to override the dot attributes printed for a particular
82 /// edge, override this method.
83 template<typename EdgeIter>
84 static std::string getEdgeAttributes(const void *Node, EdgeIter EI) {
Dan Gohman2ce6f2a2008-07-27 21:46:04 +000085 SDValue Op = EI.getNode()->getOperand(EI.getOperand());
Duncan Sands13237ac2008-06-06 12:08:01 +000086 MVT VT = Op.getValueType();
Chris Lattnerc5ab6ce2006-10-20 18:06:09 +000087 if (VT == MVT::Flag)
88 return "color=red,style=bold";
89 else if (VT == MVT::Other)
Dan Gohman8c733322007-06-18 15:30:16 +000090 return "color=blue,style=dashed";
Chris Lattnerc5ab6ce2006-10-20 18:06:09 +000091 return "";
92 }
93
Chris Lattner12be0272005-01-10 23:26:00 +000094
Chris Lattner1308b482005-01-11 00:34:33 +000095 static std::string getNodeLabel(const SDNode *Node,
96 const SelectionDAG *Graph);
Jim Laskey1368c262006-10-02 12:26:53 +000097 static std::string getNodeAttributes(const SDNode *N,
98 const SelectionDAG *Graph) {
99#ifndef NDEBUG
100 const std::string &Attrs = Graph->getGraphAttrs(N);
101 if (!Attrs.empty()) {
102 if (Attrs.find("shape=") == std::string::npos)
103 return std::string("shape=Mrecord,") + Attrs;
104 else
105 return Attrs;
106 }
107#endif
Chris Lattner12be0272005-01-10 23:26:00 +0000108 return "shape=Mrecord";
109 }
Chris Lattnerb241b442005-01-10 23:52:04 +0000110
111 static void addCustomGraphFeatures(SelectionDAG *G,
112 GraphWriter<SelectionDAG*> &GW) {
113 GW.emitSimpleNode(0, "plaintext=circle", "GraphRoot");
Gabor Greiff304a7a2008-08-28 21:40:38 +0000114 if (G->getRoot().getNode())
115 GW.emitEdge(0, -1, G->getRoot().getNode(), G->getRoot().getResNo(),
Dan Gohman57c74922008-07-22 17:52:59 +0000116 "color=blue,style=dashed");
Chris Lattnerb241b442005-01-10 23:52:04 +0000117 }
Chris Lattner12be0272005-01-10 23:26:00 +0000118 };
119}
120
Chris Lattner1308b482005-01-11 00:34:33 +0000121std::string DOTGraphTraits<SelectionDAG*>::getNodeLabel(const SDNode *Node,
122 const SelectionDAG *G) {
Chris Lattner7e57d182005-08-16 18:31:23 +0000123 std::string Op = Node->getOperationName(G);
Chris Lattnerc2785562005-01-11 22:21:04 +0000124
Chris Lattner1308b482005-01-11 00:34:33 +0000125 if (const ConstantSDNode *CSDN = dyn_cast<ConstantSDNode>(Node)) {
Dan Gohmaneffb8942008-09-12 16:56:44 +0000126 Op += ": " + utostr(CSDN->getZExtValue());
Chris Lattner1308b482005-01-11 00:34:33 +0000127 } else if (const ConstantFPSDNode *CSDN = dyn_cast<ConstantFPSDNode>(Node)) {
Dale Johannesen3cf889f2007-08-31 04:03:46 +0000128 Op += ": " + ftostr(CSDN->getValueAPF());
Misha Brukman835702a2005-04-21 22:36:52 +0000129 } else if (const GlobalAddressSDNode *GADN =
Chris Lattner1308b482005-01-11 00:34:33 +0000130 dyn_cast<GlobalAddressSDNode>(Node)) {
131 Op += ": " + GADN->getGlobal()->getName();
Dan Gohman727a9402008-10-18 18:22:42 +0000132 if (int64_t Offset = GADN->getOffset()) {
Chris Lattner43f54492008-09-21 18:38:31 +0000133 if (Offset > 0)
134 Op += "+" + itostr(Offset);
135 else
136 Op += itostr(Offset);
137 }
Misha Brukman77451162005-04-22 04:01:18 +0000138 } else if (const FrameIndexSDNode *FIDN = dyn_cast<FrameIndexSDNode>(Node)) {
Chris Lattner1308b482005-01-11 00:34:33 +0000139 Op += " " + itostr(FIDN->getIndex());
Evan Cheng415f3652006-11-01 04:48:30 +0000140 } else if (const JumpTableSDNode *JTDN = dyn_cast<JumpTableSDNode>(Node)) {
141 Op += " " + itostr(JTDN->getIndex());
Chris Lattner1308b482005-01-11 00:34:33 +0000142 } else if (const ConstantPoolSDNode *CP = dyn_cast<ConstantPoolSDNode>(Node)){
Evan Cheng45fe3bc2006-09-12 21:00:35 +0000143 if (CP->isMachineConstantPoolEntry()) {
Chris Lattner838aff32008-08-23 22:53:13 +0000144 Op += '<';
145 {
146 raw_string_ostream OSS(Op);
147 OSS << *CP->getMachineCPVal();
148 }
149 Op += '>';
Evan Cheng45fe3bc2006-09-12 21:00:35 +0000150 } else {
151 if (ConstantFP *CFP = dyn_cast<ConstantFP>(CP->getConstVal()))
Dale Johannesen3cf889f2007-08-31 04:03:46 +0000152 Op += "<" + ftostr(CFP->getValueAPF()) + ">";
Evan Cheng45fe3bc2006-09-12 21:00:35 +0000153 else if (ConstantInt *CI = dyn_cast<ConstantInt>(CP->getConstVal()))
154 Op += "<" + utostr(CI->getZExtValue()) + ">";
155 else {
Chris Lattner838aff32008-08-23 22:53:13 +0000156 Op += '<';
157 {
158 raw_string_ostream OSS(Op);
159 WriteAsOperand(OSS, CP->getConstVal(), false);
160 }
161 Op += '>';
Evan Cheng45fe3bc2006-09-12 21:00:35 +0000162 }
Chris Lattnerc610e622006-03-05 09:38:03 +0000163 }
Dan Gohmanab26f202008-09-16 21:18:22 +0000164 Op += " A=" + itostr(1 << CP->getAlignment());
Misha Brukman77451162005-04-22 04:01:18 +0000165 } else if (const BasicBlockSDNode *BBDN = dyn_cast<BasicBlockSDNode>(Node)) {
Chris Lattner1308b482005-01-11 00:34:33 +0000166 Op = "BB: ";
167 const Value *LBB = (const Value*)BBDN->getBasicBlock()->getBasicBlock();
168 if (LBB)
169 Op += LBB->getName();
170 //Op += " " + (const void*)BBDN->getBasicBlock();
Chris Lattner33182322005-08-16 21:55:35 +0000171 } else if (const RegisterSDNode *R = dyn_cast<RegisterSDNode>(Node)) {
Chris Lattnerc5ab6ce2006-10-20 18:06:09 +0000172 if (G && R->getReg() != 0 &&
Dan Gohman3a4be0f2008-02-10 18:45:23 +0000173 TargetRegisterInfo::isPhysicalRegister(R->getReg())) {
Bill Wendlingc24ea4f2008-02-26 21:11:01 +0000174 Op = Op + " " +
Bill Wendling97925ec2008-02-27 06:33:05 +0000175 G->getTarget().getRegisterInfo()->getName(R->getReg());
Chris Lattner49903352005-08-19 21:21:16 +0000176 } else {
177 Op += " #" + utostr(R->getReg());
178 }
Dan Gohman5c73a882008-06-30 20:59:49 +0000179 } else if (const DbgStopPointSDNode *D = dyn_cast<DbgStopPointSDNode>(Node)) {
180 Op += ": " + D->getCompileUnit()->getFileName();
181 Op += ":" + utostr(D->getLine());
182 if (D->getColumn() != 0)
183 Op += ":" + utostr(D->getColumn());
Dan Gohmanfb19f942008-07-01 00:05:16 +0000184 } else if (const LabelSDNode *L = dyn_cast<LabelSDNode>(Node)) {
185 Op += ": LabelID=" + utostr(L->getLabelID());
Dan Gohmand3fe1742008-09-13 01:54:27 +0000186 } else if (const CallSDNode *C = dyn_cast<CallSDNode>(Node)) {
187 Op += ": CallingConv=" + utostr(C->getCallingConv());
188 if (C->isVarArg())
189 Op += ", isVarArg";
190 if (C->isTailCall())
191 Op += ", isTailCall";
Bill Wendling24c79f22008-09-16 21:48:12 +0000192 } else if (const ExternalSymbolSDNode *ES =
193 dyn_cast<ExternalSymbolSDNode>(Node)) {
194 Op += "'" + std::string(ES->getSymbol()) + "'";
Chris Lattner9440d6e2005-05-09 04:08:27 +0000195 } else if (const SrcValueSDNode *M = dyn_cast<SrcValueSDNode>(Node)) {
196 if (M->getValue())
Dan Gohman2d489b52008-02-06 22:27:42 +0000197 Op += "<" + M->getValue()->getName() + ">";
Chris Lattner9440d6e2005-05-09 04:08:27 +0000198 else
Dan Gohman2d489b52008-02-06 22:27:42 +0000199 Op += "<null>";
200 } else if (const MemOperandSDNode *M = dyn_cast<MemOperandSDNode>(Node)) {
Dan Gohman7168de72008-07-17 21:12:16 +0000201 const Value *V = M->MO.getValue();
202 Op += '<';
203 if (!V) {
204 Op += "(unknown)";
Dan Gohmana7e139a2008-12-15 17:28:10 +0000205 } else if (const PseudoSourceValue *PSV = dyn_cast<PseudoSourceValue>(V)) {
Dan Gohman7168de72008-07-17 21:12:16 +0000206 // PseudoSourceValues don't have names, so use their print method.
Dan Gohmana7e139a2008-12-15 17:28:10 +0000207 raw_string_ostream OSS(Op);
208 PSV->print(OSS);
Dan Gohmane7c83872008-07-14 17:51:24 +0000209 } else {
Dan Gohman7168de72008-07-17 21:12:16 +0000210 Op += V->getName();
Dan Gohmane7c83872008-07-14 17:51:24 +0000211 }
Dan Gohman7168de72008-07-17 21:12:16 +0000212 Op += '+' + itostr(M->MO.getOffset()) + '>';
Duncan Sandsd97eea32008-03-21 09:14:45 +0000213 } else if (const ARG_FLAGSSDNode *N = dyn_cast<ARG_FLAGSSDNode>(Node)) {
214 Op = Op + " AF=" + N->getArgFlags().getArgFlagsString();
Chris Lattner802080d2005-08-18 03:31:02 +0000215 } else if (const VTSDNode *N = dyn_cast<VTSDNode>(Node)) {
Duncan Sands13237ac2008-06-06 12:08:01 +0000216 Op = Op + " VT=" + N->getVT().getMVTString();
Evan Cheng7994aec2006-10-10 20:11:26 +0000217 } else if (const LoadSDNode *LD = dyn_cast<LoadSDNode>(Node)) {
218 bool doExt = true;
219 switch (LD->getExtensionType()) {
220 default: doExt = false; break;
221 case ISD::EXTLOAD:
222 Op = Op + "<anyext ";
223 break;
224 case ISD::SEXTLOAD:
225 Op = Op + " <sext ";
226 break;
227 case ISD::ZEXTLOAD:
228 Op = Op + " <zext ";
229 break;
230 }
231 if (doExt)
Duncan Sands13237ac2008-06-06 12:08:01 +0000232 Op += LD->getMemoryVT().getMVTString() + ">";
Chris Lattnerda52d9e2008-01-25 06:40:45 +0000233 if (LD->isVolatile())
234 Op += "<V>";
Evan Chengc034f142006-11-09 18:44:21 +0000235 Op += LD->getIndexedModeName(LD->getAddressingMode());
Chris Lattnerda52d9e2008-01-25 06:40:45 +0000236 if (LD->getAlignment() > 1)
237 Op += " A=" + utostr(LD->getAlignment());
Evan Cheng2f4ddce2006-10-17 21:18:26 +0000238 } else if (const StoreSDNode *ST = dyn_cast<StoreSDNode>(Node)) {
239 if (ST->isTruncatingStore())
Duncan Sands13237ac2008-06-06 12:08:01 +0000240 Op += "<trunc " + ST->getMemoryVT().getMVTString() + ">";
Chris Lattnerda52d9e2008-01-25 06:40:45 +0000241 if (ST->isVolatile())
242 Op += "<V>";
Evan Chengc034f142006-11-09 18:44:21 +0000243 Op += ST->getIndexedModeName(ST->getAddressingMode());
Chris Lattnerda52d9e2008-01-25 06:40:45 +0000244 if (ST->getAlignment() > 1)
245 Op += " A=" + utostr(ST->getAlignment());
Chris Lattner1308b482005-01-11 00:34:33 +0000246 }
Chris Lattner90e0b272007-10-15 05:32:43 +0000247
248#if 0
249 Op += " Id=" + itostr(Node->getNodeId());
250#endif
Chris Lattner435b4022005-11-29 06:21:05 +0000251
Chris Lattner1308b482005-01-11 00:34:33 +0000252 return Op;
253}
Misha Brukman835702a2005-04-21 22:36:52 +0000254
Chris Lattner1308b482005-01-11 00:34:33 +0000255
Chris Lattner7f650752005-01-10 23:08:40 +0000256/// viewGraph - Pop up a ghostview window with the reachable parts of the DAG
257/// rendered using 'dot'.
258///
Dan Gohman581cc872008-07-21 20:00:07 +0000259void SelectionDAG::viewGraph(const std::string &Title) {
Chris Lattnerfcc53ad2005-07-14 05:17:43 +0000260// This code is only for debugging!
Chris Lattner46524e22005-07-14 05:33:13 +0000261#ifndef NDEBUG
Dan Gohman581cc872008-07-21 20:00:07 +0000262 ViewGraph(this, "dag." + getMachineFunction().getFunction()->getName(),
263 Title);
Reid Spenceree7eaa22006-06-27 16:49:46 +0000264#else
Bill Wendling22e978a2006-12-07 20:04:42 +0000265 cerr << "SelectionDAG::viewGraph is only available in debug builds on "
266 << "systems with Graphviz or gv!\n";
Reid Spenceree7eaa22006-06-27 16:49:46 +0000267#endif // NDEBUG
Chris Lattner7f650752005-01-10 23:08:40 +0000268}
Jim Laskey1368c262006-10-02 12:26:53 +0000269
Dan Gohman88e0df02008-07-30 18:48:53 +0000270// This overload is defined out-of-line here instead of just using a
271// default parameter because this is easiest for gdb to call.
272void SelectionDAG::viewGraph() {
273 viewGraph("");
274}
Jim Laskey1368c262006-10-02 12:26:53 +0000275
276/// clearGraphAttrs - Clear all previously defined node graph attributes.
277/// Intended to be used from a debugging tool (eg. gdb).
278void SelectionDAG::clearGraphAttrs() {
279#ifndef NDEBUG
280 NodeGraphAttrs.clear();
281#else
Bill Wendling22e978a2006-12-07 20:04:42 +0000282 cerr << "SelectionDAG::clearGraphAttrs is only available in debug builds"
283 << " on systems with Graphviz or gv!\n";
Jim Laskey1368c262006-10-02 12:26:53 +0000284#endif
285}
286
287
288/// setGraphAttrs - Set graph attributes for a node. (eg. "color=red".)
289///
290void SelectionDAG::setGraphAttrs(const SDNode *N, const char *Attrs) {
291#ifndef NDEBUG
292 NodeGraphAttrs[N] = Attrs;
293#else
Bill Wendling22e978a2006-12-07 20:04:42 +0000294 cerr << "SelectionDAG::setGraphAttrs is only available in debug builds"
295 << " on systems with Graphviz or gv!\n";
Jim Laskey1368c262006-10-02 12:26:53 +0000296#endif
297}
298
299
300/// getGraphAttrs - Get graph attributes for a node. (eg. "color=red".)
301/// Used from getNodeAttributes.
302const std::string SelectionDAG::getGraphAttrs(const SDNode *N) const {
303#ifndef NDEBUG
304 std::map<const SDNode *, std::string>::const_iterator I =
305 NodeGraphAttrs.find(N);
306
307 if (I != NodeGraphAttrs.end())
308 return I->second;
309 else
310 return "";
311#else
Bill Wendling22e978a2006-12-07 20:04:42 +0000312 cerr << "SelectionDAG::getGraphAttrs is only available in debug builds"
313 << " on systems with Graphviz or gv!\n";
Jim Laskey1368c262006-10-02 12:26:53 +0000314 return std::string("");
315#endif
316}
317
318/// setGraphColor - Convenience for setting node color attribute.
319///
320void SelectionDAG::setGraphColor(const SDNode *N, const char *Color) {
321#ifndef NDEBUG
322 NodeGraphAttrs[N] = std::string("color=") + Color;
323#else
Bill Wendling22e978a2006-12-07 20:04:42 +0000324 cerr << "SelectionDAG::setGraphColor is only available in debug builds"
325 << " on systems with Graphviz or gv!\n";
Jim Laskey1368c262006-10-02 12:26:53 +0000326#endif
327}
328
David Greeneb04e7c32008-10-27 18:17:03 +0000329/// setSubgraphColorHelper - Implement setSubgraphColor. Return
330/// whether we truncated the search.
331///
332bool SelectionDAG::setSubgraphColorHelper(SDNode *N, const char *Color, DenseSet<SDNode *> &visited,
333 int level, bool &printed) {
334 bool hit_limit = false;
335
336#ifndef NDEBUG
337 if (level >= 20) {
338 if (!printed) {
339 printed = true;
340 DOUT << "setSubgraphColor hit max level\n";
341 }
342 return true;
343 }
344
345 unsigned oldSize = visited.size();
346 visited.insert(N);
347 if (visited.size() != oldSize) {
348 setGraphColor(N, Color);
349 for(SDNodeIterator i = SDNodeIterator::begin(N), iend = SDNodeIterator::end(N);
350 i != iend;
351 ++i) {
352 hit_limit = setSubgraphColorHelper(*i, Color, visited, level+1, printed) || hit_limit;
353 }
354 }
355#else
356 cerr << "SelectionDAG::setSubgraphColor is only available in debug builds"
357 << " on systems with Graphviz or gv!\n";
358#endif
359 return hit_limit;
360}
361
362/// setSubgraphColor - Convenience for setting subgraph color attribute.
363///
364void SelectionDAG::setSubgraphColor(SDNode *N, const char *Color) {
365#ifndef NDEBUG
366 DenseSet<SDNode *> visited;
367 bool printed = false;
368 if (setSubgraphColorHelper(N, Color, visited, 0, printed)) {
369 // Visually mark that we hit the limit
Ted Kremenek8fcff4d2008-10-27 22:43:07 +0000370 if (strcmp(Color, "red") == 0) {
David Greeneb04e7c32008-10-27 18:17:03 +0000371 setSubgraphColorHelper(N, "blue", visited, 0, printed);
372 }
Ted Kremenek8fcff4d2008-10-27 22:43:07 +0000373 else if (strcmp(Color, "yellow") == 0) {
David Greeneb04e7c32008-10-27 18:17:03 +0000374 setSubgraphColorHelper(N, "green", visited, 0, printed);
375 }
376 }
377
378#else
379 cerr << "SelectionDAG::setSubgraphColor is only available in debug builds"
380 << " on systems with Graphviz or gv!\n";
381#endif
382}
383
Dan Gohman60cb69e2008-11-19 23:18:57 +0000384std::string ScheduleDAGSDNodes::getGraphNodeLabel(const SUnit *SU) const {
Dan Gohmanf4d95fd2008-11-19 22:09:45 +0000385 std::string s;
386 raw_string_ostream O(s);
387 O << "SU(" << SU->NodeNum << "): ";
388 if (SU->getNode()) {
389 SmallVector<SDNode *, 4> FlaggedNodes;
390 for (SDNode *N = SU->getNode(); N; N = N->getFlaggedNode())
391 FlaggedNodes.push_back(N);
392 while (!FlaggedNodes.empty()) {
393 O << DOTGraphTraits<SelectionDAG*>::getNodeLabel(FlaggedNodes.back(), DAG);
394 FlaggedNodes.pop_back();
395 if (!FlaggedNodes.empty())
396 O << "\n ";
397 }
398 } else {
399 O << "CROSS RC COPY";
400 }
401 return O.str();
402}
Dan Gohman81b62e12007-08-28 20:32:58 +0000403
Dan Gohman60cb69e2008-11-19 23:18:57 +0000404void ScheduleDAGSDNodes::getCustomGraphFeatures(GraphWriter<ScheduleDAG*> &GW) const {
405 if (DAG) {
406 // Draw a special "GraphRoot" node to indicate the root of the graph.
407 GW.emitSimpleNode(0, "plaintext=circle", "GraphRoot");
408 const SDNode *N = DAG->getRoot().getNode();
409 if (N && N->getNodeId() != -1)
410 GW.emitEdge(0, -1, &SUnits[N->getNodeId()], -1,
411 "color=blue,style=dashed");
412 }
Dan Gohman81b62e12007-08-28 20:32:58 +0000413}