1 //===-- SelectionDAGDumper.cpp - Implement SelectionDAG::dump() -----------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This implements the SelectionDAG::dump method and friends.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/CodeGen/SelectionDAG.h"
15 #include "ScheduleDAGSDNodes.h"
16 #include "llvm/ADT/StringExtras.h"
17 #include "llvm/CodeGen/MachineConstantPool.h"
18 #include "llvm/CodeGen/MachineFunction.h"
19 #include "llvm/CodeGen/MachineModuleInfo.h"
20 #include "llvm/IR/DebugInfo.h"
21 #include "llvm/IR/Function.h"
22 #include "llvm/IR/Intrinsics.h"
23 #include "llvm/Support/Debug.h"
24 #include "llvm/Support/GraphWriter.h"
25 #include "llvm/Support/raw_ostream.h"
26 #include "llvm/Target/TargetInstrInfo.h"
27 #include "llvm/Target/TargetIntrinsicInfo.h"
28 #include "llvm/Target/TargetMachine.h"
29 #include "llvm/Target/TargetRegisterInfo.h"
30 #include "llvm/Target/TargetSubtargetInfo.h"
33 std::string SDNode::getOperationName(const SelectionDAG *G) const {
34 switch (getOpcode()) {
36 if (getOpcode() < ISD::BUILTIN_OP_END)
37 return "<<Unknown DAG Node>>";
38 if (isMachineOpcode()) {
40 if (const TargetInstrInfo *TII = G->getSubtarget().getInstrInfo())
41 if (getMachineOpcode() < TII->getNumOpcodes())
42 return TII->getName(getMachineOpcode());
43 return "<<Unknown Machine Node #" + utostr(getOpcode()) + ">>";
46 const TargetLowering &TLI = G->getTargetLoweringInfo();
47 const char *Name = TLI.getTargetNodeName(getOpcode());
48 if (Name) return Name;
49 return "<<Unknown Target Node #" + utostr(getOpcode()) + ">>";
51 return "<<Unknown Node #" + utostr(getOpcode()) + ">>";
54 case ISD::DELETED_NODE: return "<<Deleted Node!>>";
56 case ISD::PREFETCH: return "Prefetch";
57 case ISD::ATOMIC_FENCE: return "AtomicFence";
58 case ISD::ATOMIC_CMP_SWAP: return "AtomicCmpSwap";
59 case ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS: return "AtomicCmpSwapWithSuccess";
60 case ISD::ATOMIC_SWAP: return "AtomicSwap";
61 case ISD::ATOMIC_LOAD_ADD: return "AtomicLoadAdd";
62 case ISD::ATOMIC_LOAD_SUB: return "AtomicLoadSub";
63 case ISD::ATOMIC_LOAD_AND: return "AtomicLoadAnd";
64 case ISD::ATOMIC_LOAD_OR: return "AtomicLoadOr";
65 case ISD::ATOMIC_LOAD_XOR: return "AtomicLoadXor";
66 case ISD::ATOMIC_LOAD_NAND: return "AtomicLoadNand";
67 case ISD::ATOMIC_LOAD_MIN: return "AtomicLoadMin";
68 case ISD::ATOMIC_LOAD_MAX: return "AtomicLoadMax";
69 case ISD::ATOMIC_LOAD_UMIN: return "AtomicLoadUMin";
70 case ISD::ATOMIC_LOAD_UMAX: return "AtomicLoadUMax";
71 case ISD::ATOMIC_LOAD: return "AtomicLoad";
72 case ISD::ATOMIC_STORE: return "AtomicStore";
73 case ISD::PCMARKER: return "PCMarker";
74 case ISD::READCYCLECOUNTER: return "ReadCycleCounter";
75 case ISD::SRCVALUE: return "SrcValue";
76 case ISD::MDNODE_SDNODE: return "MDNode";
77 case ISD::EntryToken: return "EntryToken";
78 case ISD::TokenFactor: return "TokenFactor";
79 case ISD::AssertSext: return "AssertSext";
80 case ISD::AssertZext: return "AssertZext";
82 case ISD::BasicBlock: return "BasicBlock";
83 case ISD::VALUETYPE: return "ValueType";
84 case ISD::Register: return "Register";
85 case ISD::RegisterMask: return "RegisterMask";
87 if (cast<ConstantSDNode>(this)->isOpaque())
88 return "OpaqueConstant";
90 case ISD::ConstantFP: return "ConstantFP";
91 case ISD::GlobalAddress: return "GlobalAddress";
92 case ISD::GlobalTLSAddress: return "GlobalTLSAddress";
93 case ISD::FrameIndex: return "FrameIndex";
94 case ISD::JumpTable: return "JumpTable";
95 case ISD::GLOBAL_OFFSET_TABLE: return "GLOBAL_OFFSET_TABLE";
96 case ISD::RETURNADDR: return "RETURNADDR";
97 case ISD::FRAMEADDR: return "FRAMEADDR";
98 case ISD::READ_REGISTER: return "READ_REGISTER";
99 case ISD::WRITE_REGISTER: return "WRITE_REGISTER";
100 case ISD::FRAME_TO_ARGS_OFFSET: return "FRAME_TO_ARGS_OFFSET";
101 case ISD::EH_RETURN: return "EH_RETURN";
102 case ISD::EH_SJLJ_SETJMP: return "EH_SJLJ_SETJMP";
103 case ISD::EH_SJLJ_LONGJMP: return "EH_SJLJ_LONGJMP";
104 case ISD::ConstantPool: return "ConstantPool";
105 case ISD::TargetIndex: return "TargetIndex";
106 case ISD::ExternalSymbol: return "ExternalSymbol";
107 case ISD::BlockAddress: return "BlockAddress";
108 case ISD::INTRINSIC_WO_CHAIN:
109 case ISD::INTRINSIC_VOID:
110 case ISD::INTRINSIC_W_CHAIN: {
111 unsigned OpNo = getOpcode() == ISD::INTRINSIC_WO_CHAIN ? 0 : 1;
112 unsigned IID = cast<ConstantSDNode>(getOperand(OpNo))->getZExtValue();
113 if (IID < Intrinsic::num_intrinsics)
114 return Intrinsic::getName((Intrinsic::ID)IID);
115 else if (const TargetIntrinsicInfo *TII = G->getTarget().getIntrinsicInfo())
116 return TII->getName(IID);
117 llvm_unreachable("Invalid intrinsic ID");
120 case ISD::BUILD_VECTOR: return "BUILD_VECTOR";
121 case ISD::TargetConstant:
122 if (cast<ConstantSDNode>(this)->isOpaque())
123 return "OpaqueTargetConstant";
124 return "TargetConstant";
125 case ISD::TargetConstantFP: return "TargetConstantFP";
126 case ISD::TargetGlobalAddress: return "TargetGlobalAddress";
127 case ISD::TargetGlobalTLSAddress: return "TargetGlobalTLSAddress";
128 case ISD::TargetFrameIndex: return "TargetFrameIndex";
129 case ISD::TargetJumpTable: return "TargetJumpTable";
130 case ISD::TargetConstantPool: return "TargetConstantPool";
131 case ISD::TargetExternalSymbol: return "TargetExternalSymbol";
132 case ISD::TargetBlockAddress: return "TargetBlockAddress";
134 case ISD::CopyToReg: return "CopyToReg";
135 case ISD::CopyFromReg: return "CopyFromReg";
136 case ISD::UNDEF: return "undef";
137 case ISD::MERGE_VALUES: return "merge_values";
138 case ISD::INLINEASM: return "inlineasm";
139 case ISD::EH_LABEL: return "eh_label";
140 case ISD::HANDLENODE: return "handlenode";
143 case ISD::FABS: return "fabs";
144 case ISD::FMINNUM: return "fminnum";
145 case ISD::FMAXNUM: return "fmaxnum";
146 case ISD::FNEG: return "fneg";
147 case ISD::FSQRT: return "fsqrt";
148 case ISD::FSIN: return "fsin";
149 case ISD::FCOS: return "fcos";
150 case ISD::FSINCOS: return "fsincos";
151 case ISD::FTRUNC: return "ftrunc";
152 case ISD::FFLOOR: return "ffloor";
153 case ISD::FCEIL: return "fceil";
154 case ISD::FRINT: return "frint";
155 case ISD::FNEARBYINT: return "fnearbyint";
156 case ISD::FROUND: return "fround";
157 case ISD::FEXP: return "fexp";
158 case ISD::FEXP2: return "fexp2";
159 case ISD::FLOG: return "flog";
160 case ISD::FLOG2: return "flog2";
161 case ISD::FLOG10: return "flog10";
164 case ISD::ADD: return "add";
165 case ISD::SUB: return "sub";
166 case ISD::MUL: return "mul";
167 case ISD::MULHU: return "mulhu";
168 case ISD::MULHS: return "mulhs";
169 case ISD::SDIV: return "sdiv";
170 case ISD::UDIV: return "udiv";
171 case ISD::SREM: return "srem";
172 case ISD::UREM: return "urem";
173 case ISD::SMUL_LOHI: return "smul_lohi";
174 case ISD::UMUL_LOHI: return "umul_lohi";
175 case ISD::SDIVREM: return "sdivrem";
176 case ISD::UDIVREM: return "udivrem";
177 case ISD::AND: return "and";
178 case ISD::OR: return "or";
179 case ISD::XOR: return "xor";
180 case ISD::SHL: return "shl";
181 case ISD::SRA: return "sra";
182 case ISD::SRL: return "srl";
183 case ISD::ROTL: return "rotl";
184 case ISD::ROTR: return "rotr";
185 case ISD::FADD: return "fadd";
186 case ISD::FSUB: return "fsub";
187 case ISD::FMUL: return "fmul";
188 case ISD::FDIV: return "fdiv";
189 case ISD::FMA: return "fma";
190 case ISD::FMAD: return "fmad";
191 case ISD::FREM: return "frem";
192 case ISD::FCOPYSIGN: return "fcopysign";
193 case ISD::FGETSIGN: return "fgetsign";
194 case ISD::FPOW: return "fpow";
196 case ISD::FPOWI: return "fpowi";
197 case ISD::SETCC: return "setcc";
198 case ISD::SELECT: return "select";
199 case ISD::VSELECT: return "vselect";
200 case ISD::SELECT_CC: return "select_cc";
201 case ISD::INSERT_VECTOR_ELT: return "insert_vector_elt";
202 case ISD::EXTRACT_VECTOR_ELT: return "extract_vector_elt";
203 case ISD::CONCAT_VECTORS: return "concat_vectors";
204 case ISD::INSERT_SUBVECTOR: return "insert_subvector";
205 case ISD::EXTRACT_SUBVECTOR: return "extract_subvector";
206 case ISD::SCALAR_TO_VECTOR: return "scalar_to_vector";
207 case ISD::VECTOR_SHUFFLE: return "vector_shuffle";
208 case ISD::CARRY_FALSE: return "carry_false";
209 case ISD::ADDC: return "addc";
210 case ISD::ADDE: return "adde";
211 case ISD::SADDO: return "saddo";
212 case ISD::UADDO: return "uaddo";
213 case ISD::SSUBO: return "ssubo";
214 case ISD::USUBO: return "usubo";
215 case ISD::SMULO: return "smulo";
216 case ISD::UMULO: return "umulo";
217 case ISD::SUBC: return "subc";
218 case ISD::SUBE: return "sube";
219 case ISD::SHL_PARTS: return "shl_parts";
220 case ISD::SRA_PARTS: return "sra_parts";
221 case ISD::SRL_PARTS: return "srl_parts";
223 // Conversion operators.
224 case ISD::SIGN_EXTEND: return "sign_extend";
225 case ISD::ZERO_EXTEND: return "zero_extend";
226 case ISD::ANY_EXTEND: return "any_extend";
227 case ISD::SIGN_EXTEND_INREG: return "sign_extend_inreg";
228 case ISD::ANY_EXTEND_VECTOR_INREG: return "any_extend_vector_inreg";
229 case ISD::SIGN_EXTEND_VECTOR_INREG: return "sign_extend_vector_inreg";
230 case ISD::ZERO_EXTEND_VECTOR_INREG: return "zero_extend_vector_inreg";
231 case ISD::TRUNCATE: return "truncate";
232 case ISD::FP_ROUND: return "fp_round";
233 case ISD::FLT_ROUNDS_: return "flt_rounds";
234 case ISD::FP_ROUND_INREG: return "fp_round_inreg";
235 case ISD::FP_EXTEND: return "fp_extend";
237 case ISD::SINT_TO_FP: return "sint_to_fp";
238 case ISD::UINT_TO_FP: return "uint_to_fp";
239 case ISD::FP_TO_SINT: return "fp_to_sint";
240 case ISD::FP_TO_UINT: return "fp_to_uint";
241 case ISD::BITCAST: return "bitcast";
242 case ISD::ADDRSPACECAST: return "addrspacecast";
243 case ISD::FP16_TO_FP: return "fp16_to_fp";
244 case ISD::FP_TO_FP16: return "fp_to_fp16";
246 case ISD::CONVERT_RNDSAT: {
247 switch (cast<CvtRndSatSDNode>(this)->getCvtCode()) {
248 default: llvm_unreachable("Unknown cvt code!");
249 case ISD::CVT_FF: return "cvt_ff";
250 case ISD::CVT_FS: return "cvt_fs";
251 case ISD::CVT_FU: return "cvt_fu";
252 case ISD::CVT_SF: return "cvt_sf";
253 case ISD::CVT_UF: return "cvt_uf";
254 case ISD::CVT_SS: return "cvt_ss";
255 case ISD::CVT_SU: return "cvt_su";
256 case ISD::CVT_US: return "cvt_us";
257 case ISD::CVT_UU: return "cvt_uu";
261 // Control flow instructions
262 case ISD::BR: return "br";
263 case ISD::BRIND: return "brind";
264 case ISD::BR_JT: return "br_jt";
265 case ISD::BRCOND: return "brcond";
266 case ISD::BR_CC: return "br_cc";
267 case ISD::CALLSEQ_START: return "callseq_start";
268 case ISD::CALLSEQ_END: return "callseq_end";
271 case ISD::LOAD: return "load";
272 case ISD::STORE: return "store";
273 case ISD::MLOAD: return "masked_load";
274 case ISD::MSTORE: return "masked_store";
275 case ISD::VAARG: return "vaarg";
276 case ISD::VACOPY: return "vacopy";
277 case ISD::VAEND: return "vaend";
278 case ISD::VASTART: return "vastart";
279 case ISD::DYNAMIC_STACKALLOC: return "dynamic_stackalloc";
280 case ISD::EXTRACT_ELEMENT: return "extract_element";
281 case ISD::BUILD_PAIR: return "build_pair";
282 case ISD::STACKSAVE: return "stacksave";
283 case ISD::STACKRESTORE: return "stackrestore";
284 case ISD::TRAP: return "trap";
285 case ISD::DEBUGTRAP: return "debugtrap";
286 case ISD::LIFETIME_START: return "lifetime.start";
287 case ISD::LIFETIME_END: return "lifetime.end";
290 case ISD::BSWAP: return "bswap";
291 case ISD::CTPOP: return "ctpop";
292 case ISD::CTTZ: return "cttz";
293 case ISD::CTTZ_ZERO_UNDEF: return "cttz_zero_undef";
294 case ISD::CTLZ: return "ctlz";
295 case ISD::CTLZ_ZERO_UNDEF: return "ctlz_zero_undef";
298 case ISD::INIT_TRAMPOLINE: return "init_trampoline";
299 case ISD::ADJUST_TRAMPOLINE: return "adjust_trampoline";
302 switch (cast<CondCodeSDNode>(this)->get()) {
303 default: llvm_unreachable("Unknown setcc condition!");
304 case ISD::SETOEQ: return "setoeq";
305 case ISD::SETOGT: return "setogt";
306 case ISD::SETOGE: return "setoge";
307 case ISD::SETOLT: return "setolt";
308 case ISD::SETOLE: return "setole";
309 case ISD::SETONE: return "setone";
311 case ISD::SETO: return "seto";
312 case ISD::SETUO: return "setuo";
313 case ISD::SETUEQ: return "setue";
314 case ISD::SETUGT: return "setugt";
315 case ISD::SETUGE: return "setuge";
316 case ISD::SETULT: return "setult";
317 case ISD::SETULE: return "setule";
318 case ISD::SETUNE: return "setune";
320 case ISD::SETEQ: return "seteq";
321 case ISD::SETGT: return "setgt";
322 case ISD::SETGE: return "setge";
323 case ISD::SETLT: return "setlt";
324 case ISD::SETLE: return "setle";
325 case ISD::SETNE: return "setne";
327 case ISD::SETTRUE: return "settrue";
328 case ISD::SETTRUE2: return "settrue2";
329 case ISD::SETFALSE: return "setfalse";
330 case ISD::SETFALSE2: return "setfalse2";
335 const char *SDNode::getIndexedModeName(ISD::MemIndexedMode AM) {
338 case ISD::PRE_INC: return "<pre-inc>";
339 case ISD::PRE_DEC: return "<pre-dec>";
340 case ISD::POST_INC: return "<post-inc>";
341 case ISD::POST_DEC: return "<post-dec>";
345 void SDNode::dump() const { dump(nullptr); }
346 void SDNode::dump(const SelectionDAG *G) const {
351 void SDNode::print_types(raw_ostream &OS, const SelectionDAG *G) const {
352 OS << (const void*)this << ": ";
354 for (unsigned i = 0, e = getNumValues(); i != e; ++i) {
356 if (getValueType(i) == MVT::Other)
359 OS << getValueType(i).getEVTString();
361 OS << " = " << getOperationName(G);
364 void SDNode::print_details(raw_ostream &OS, const SelectionDAG *G) const {
365 if (const MachineSDNode *MN = dyn_cast<MachineSDNode>(this)) {
366 if (!MN->memoperands_empty()) {
369 for (MachineSDNode::mmo_iterator i = MN->memoperands_begin(),
370 e = MN->memoperands_end(); i != e; ++i) {
372 if (std::next(i) != e)
377 } else if (const ShuffleVectorSDNode *SVN =
378 dyn_cast<ShuffleVectorSDNode>(this)) {
380 for (unsigned i = 0, e = ValueList[0].getVectorNumElements(); i != e; ++i) {
381 int Idx = SVN->getMaskElt(i);
389 } else if (const ConstantSDNode *CSDN = dyn_cast<ConstantSDNode>(this)) {
390 OS << '<' << CSDN->getAPIntValue() << '>';
391 } else if (const ConstantFPSDNode *CSDN = dyn_cast<ConstantFPSDNode>(this)) {
392 if (&CSDN->getValueAPF().getSemantics()==&APFloat::IEEEsingle)
393 OS << '<' << CSDN->getValueAPF().convertToFloat() << '>';
394 else if (&CSDN->getValueAPF().getSemantics()==&APFloat::IEEEdouble)
395 OS << '<' << CSDN->getValueAPF().convertToDouble() << '>';
398 CSDN->getValueAPF().bitcastToAPInt().dump();
401 } else if (const GlobalAddressSDNode *GADN =
402 dyn_cast<GlobalAddressSDNode>(this)) {
403 int64_t offset = GADN->getOffset();
405 GADN->getGlobal()->printAsOperand(OS);
408 OS << " + " << offset;
411 if (unsigned int TF = GADN->getTargetFlags())
412 OS << " [TF=" << TF << ']';
413 } else if (const FrameIndexSDNode *FIDN = dyn_cast<FrameIndexSDNode>(this)) {
414 OS << "<" << FIDN->getIndex() << ">";
415 } else if (const JumpTableSDNode *JTDN = dyn_cast<JumpTableSDNode>(this)) {
416 OS << "<" << JTDN->getIndex() << ">";
417 if (unsigned int TF = JTDN->getTargetFlags())
418 OS << " [TF=" << TF << ']';
419 } else if (const ConstantPoolSDNode *CP = dyn_cast<ConstantPoolSDNode>(this)){
420 int offset = CP->getOffset();
421 if (CP->isMachineConstantPoolEntry())
422 OS << "<" << *CP->getMachineCPVal() << ">";
424 OS << "<" << *CP->getConstVal() << ">";
426 OS << " + " << offset;
429 if (unsigned int TF = CP->getTargetFlags())
430 OS << " [TF=" << TF << ']';
431 } else if (const TargetIndexSDNode *TI = dyn_cast<TargetIndexSDNode>(this)) {
432 OS << "<" << TI->getIndex() << '+' << TI->getOffset() << ">";
433 if (unsigned TF = TI->getTargetFlags())
434 OS << " [TF=" << TF << ']';
435 } else if (const BasicBlockSDNode *BBDN = dyn_cast<BasicBlockSDNode>(this)) {
437 const Value *LBB = (const Value*)BBDN->getBasicBlock()->getBasicBlock();
439 OS << LBB->getName() << " ";
440 OS << (const void*)BBDN->getBasicBlock() << ">";
441 } else if (const RegisterSDNode *R = dyn_cast<RegisterSDNode>(this)) {
442 OS << ' ' << PrintReg(R->getReg(),
443 G ? G->getSubtarget().getRegisterInfo() : nullptr);
444 } else if (const ExternalSymbolSDNode *ES =
445 dyn_cast<ExternalSymbolSDNode>(this)) {
446 OS << "'" << ES->getSymbol() << "'";
447 if (unsigned int TF = ES->getTargetFlags())
448 OS << " [TF=" << TF << ']';
449 } else if (const SrcValueSDNode *M = dyn_cast<SrcValueSDNode>(this)) {
451 OS << "<" << M->getValue() << ">";
454 } else if (const MDNodeSDNode *MD = dyn_cast<MDNodeSDNode>(this)) {
456 OS << "<" << MD->getMD() << ">";
459 } else if (const VTSDNode *N = dyn_cast<VTSDNode>(this)) {
460 OS << ":" << N->getVT().getEVTString();
462 else if (const LoadSDNode *LD = dyn_cast<LoadSDNode>(this)) {
463 OS << "<" << *LD->getMemOperand();
466 switch (LD->getExtensionType()) {
467 default: doExt = false; break;
468 case ISD::EXTLOAD: OS << ", anyext"; break;
469 case ISD::SEXTLOAD: OS << ", sext"; break;
470 case ISD::ZEXTLOAD: OS << ", zext"; break;
473 OS << " from " << LD->getMemoryVT().getEVTString();
475 const char *AM = getIndexedModeName(LD->getAddressingMode());
480 } else if (const StoreSDNode *ST = dyn_cast<StoreSDNode>(this)) {
481 OS << "<" << *ST->getMemOperand();
483 if (ST->isTruncatingStore())
484 OS << ", trunc to " << ST->getMemoryVT().getEVTString();
486 const char *AM = getIndexedModeName(ST->getAddressingMode());
491 } else if (const MemSDNode* M = dyn_cast<MemSDNode>(this)) {
492 OS << "<" << *M->getMemOperand() << ">";
493 } else if (const BlockAddressSDNode *BA =
494 dyn_cast<BlockAddressSDNode>(this)) {
495 int64_t offset = BA->getOffset();
497 BA->getBlockAddress()->getFunction()->printAsOperand(OS, false);
499 BA->getBlockAddress()->getBasicBlock()->printAsOperand(OS, false);
502 OS << " + " << offset;
505 if (unsigned int TF = BA->getTargetFlags())
506 OS << " [TF=" << TF << ']';
507 } else if (const AddrSpaceCastSDNode *ASC =
508 dyn_cast<AddrSpaceCastSDNode>(this)) {
510 << ASC->getSrcAddressSpace()
512 << ASC->getDestAddressSpace()
516 if (unsigned Order = getIROrder())
517 OS << " [ORD=" << Order << ']';
519 if (getNodeId() != -1)
520 OS << " [ID=" << getNodeId() << ']';
522 DebugLoc dl = getDebugLoc();
523 if (G && !dl.isUnknown()) {
525 Scope(dl.getScope(G->getMachineFunction().getFunction()->getContext()));
527 assert((!Scope || Scope.isScope()) &&
528 "Scope of a DebugLoc should be null or a DIScope.");
529 // Omit the directory, since it's usually long and uninteresting.
531 OS << Scope.getFilename();
534 OS << ':' << dl.getLine();
535 if (dl.getCol() != 0)
536 OS << ':' << dl.getCol();
540 static void DumpNodes(const SDNode *N, unsigned indent, const SelectionDAG *G) {
541 for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i)
542 if (N->getOperand(i).getNode()->hasOneUse())
543 DumpNodes(N->getOperand(i).getNode(), indent+2, G);
545 dbgs() << "\n" << std::string(indent+2, ' ')
546 << (void*)N->getOperand(i).getNode() << ": <multiple use>";
549 dbgs().indent(indent);
553 void SelectionDAG::dump() const {
554 dbgs() << "SelectionDAG has " << AllNodes.size() << " nodes:";
556 for (allnodes_const_iterator I = allnodes_begin(), E = allnodes_end();
559 if (!N->hasOneUse() && N != getRoot().getNode())
560 DumpNodes(N, 2, this);
563 if (getRoot().getNode()) DumpNodes(getRoot().getNode(), 2, this);
567 void SDNode::printr(raw_ostream &OS, const SelectionDAG *G) const {
569 print_details(OS, G);
572 typedef SmallPtrSet<const SDNode *, 128> VisitedSDNodeSet;
573 static void DumpNodesr(raw_ostream &OS, const SDNode *N, unsigned indent,
574 const SelectionDAG *G, VisitedSDNodeSet &once) {
575 if (!once.insert(N).second) // If we've been here before, return now.
578 // Dump the current SDNode, but don't end the line yet.
582 // Having printed this SDNode, walk the children:
583 for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) {
584 const SDNode *child = N->getOperand(i).getNode();
589 if (child->getNumOperands() == 0) {
590 // This child has no grandchildren; print it inline right here.
591 child->printr(OS, G);
593 } else { // Just the address. FIXME: also print the child's opcode.
594 OS << (const void*)child;
595 if (unsigned RN = N->getOperand(i).getResNo())
602 // Dump children that have grandchildren on their own line(s).
603 for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) {
604 const SDNode *child = N->getOperand(i).getNode();
605 DumpNodesr(OS, child, indent+2, G, once);
609 void SDNode::dumpr() const {
610 VisitedSDNodeSet once;
611 DumpNodesr(dbgs(), this, 0, nullptr, once);
614 void SDNode::dumpr(const SelectionDAG *G) const {
615 VisitedSDNodeSet once;
616 DumpNodesr(dbgs(), this, 0, G, once);
619 static void printrWithDepthHelper(raw_ostream &OS, const SDNode *N,
620 const SelectionDAG *G, unsigned depth,
632 for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) {
633 // Don't follow chain operands.
634 if (N->getOperand(i).getValueType() == MVT::Other)
637 printrWithDepthHelper(OS, N->getOperand(i).getNode(), G, depth-1, indent+2);
641 void SDNode::printrWithDepth(raw_ostream &OS, const SelectionDAG *G,
642 unsigned depth) const {
643 printrWithDepthHelper(OS, this, G, depth, 0);
646 void SDNode::printrFull(raw_ostream &OS, const SelectionDAG *G) const {
647 // Don't print impossibly deep things.
648 printrWithDepth(OS, G, 10);
651 void SDNode::dumprWithDepth(const SelectionDAG *G, unsigned depth) const {
652 printrWithDepth(dbgs(), G, depth);
655 void SDNode::dumprFull(const SelectionDAG *G) const {
656 // Don't print impossibly deep things.
657 dumprWithDepth(G, 10);
660 void SDNode::print(raw_ostream &OS, const SelectionDAG *G) const {
662 for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
663 if (i) OS << ", "; else OS << " ";
664 OS << (void*)getOperand(i).getNode();
665 if (unsigned RN = getOperand(i).getResNo())
668 print_details(OS, G);