Eugene Zelenko | 149178d | 2017-10-10 22:33:29 +0000 | [diff] [blame] | 1 | //===- SelectionDAGDumper.cpp - Implement SelectionDAG::dump() ------------===// |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This implements the SelectionDAG::dump method and friends. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Eugene Zelenko | 149178d | 2017-10-10 22:33:29 +0000 | [diff] [blame] | 14 | #include "llvm/ADT/APFloat.h" |
| 15 | #include "llvm/ADT/APInt.h" |
| 16 | #include "llvm/ADT/None.h" |
| 17 | #include "llvm/ADT/SmallPtrSet.h" |
Chandler Carruth | ed0881b | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 18 | #include "llvm/ADT/StringExtras.h" |
Eugene Zelenko | 149178d | 2017-10-10 22:33:29 +0000 | [diff] [blame] | 19 | #include "llvm/CodeGen/ISDOpcodes.h" |
| 20 | #include "llvm/CodeGen/MachineBasicBlock.h" |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 21 | #include "llvm/CodeGen/MachineConstantPool.h" |
Eugene Zelenko | 149178d | 2017-10-10 22:33:29 +0000 | [diff] [blame] | 22 | #include "llvm/CodeGen/MachineMemOperand.h" |
Chandler Carruth | 6bda14b | 2017-06-06 11:49:48 +0000 | [diff] [blame] | 23 | #include "llvm/CodeGen/SelectionDAG.h" |
Eugene Zelenko | 149178d | 2017-10-10 22:33:29 +0000 | [diff] [blame] | 24 | #include "llvm/CodeGen/SelectionDAGNodes.h" |
David Blaikie | 3f833ed | 2017-11-08 01:01:31 +0000 | [diff] [blame] | 25 | #include "llvm/CodeGen/TargetInstrInfo.h" |
David Blaikie | b3bde2e | 2017-11-17 01:07:10 +0000 | [diff] [blame] | 26 | #include "llvm/CodeGen/TargetLowering.h" |
| 27 | #include "llvm/CodeGen/TargetRegisterInfo.h" |
| 28 | #include "llvm/CodeGen/TargetSubtargetInfo.h" |
Craig Topper | 2fa1436 | 2018-03-29 17:21:10 +0000 | [diff] [blame] | 29 | #include "llvm/CodeGen/ValueTypes.h" |
Nico Weber | 432a388 | 2018-04-30 14:59:11 +0000 | [diff] [blame] | 30 | #include "llvm/Config/llvm-config.h" |
Eugene Zelenko | 149178d | 2017-10-10 22:33:29 +0000 | [diff] [blame] | 31 | #include "llvm/IR/BasicBlock.h" |
| 32 | #include "llvm/IR/Constants.h" |
| 33 | #include "llvm/IR/DebugInfoMetadata.h" |
| 34 | #include "llvm/IR/DebugLoc.h" |
Chandler Carruth | 9fb823b | 2013-01-02 11:36:10 +0000 | [diff] [blame] | 35 | #include "llvm/IR/Function.h" |
| 36 | #include "llvm/IR/Intrinsics.h" |
Francis Visoiu Mistrih | e85b06d | 2018-03-14 21:52:13 +0000 | [diff] [blame] | 37 | #include "llvm/IR/ModuleSlotTracker.h" |
Eugene Zelenko | 149178d | 2017-10-10 22:33:29 +0000 | [diff] [blame] | 38 | #include "llvm/IR/Value.h" |
| 39 | #include "llvm/Support/Casting.h" |
| 40 | #include "llvm/Support/CommandLine.h" |
| 41 | #include "llvm/Support/Compiler.h" |
Chandler Carruth | ed0881b | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 42 | #include "llvm/Support/Debug.h" |
Eugene Zelenko | 149178d | 2017-10-10 22:33:29 +0000 | [diff] [blame] | 43 | #include "llvm/Support/ErrorHandling.h" |
David Blaikie | 13e77db | 2018-03-23 23:58:25 +0000 | [diff] [blame] | 44 | #include "llvm/Support/MachineValueType.h" |
Matthias Braun | c07cbc8 | 2015-12-04 01:31:59 +0000 | [diff] [blame] | 45 | #include "llvm/Support/Printable.h" |
Chandler Carruth | ed0881b | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 46 | #include "llvm/Support/raw_ostream.h" |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 47 | #include "llvm/Target/TargetIntrinsicInfo.h" |
| 48 | #include "llvm/Target/TargetMachine.h" |
Adrian Prantl | 55b8756b | 2018-09-14 17:08:02 +0000 | [diff] [blame] | 49 | #include "SDNodeDbgValue.h" |
Eugene Zelenko | 149178d | 2017-10-10 22:33:29 +0000 | [diff] [blame] | 50 | #include <cstdint> |
| 51 | #include <iterator> |
| 52 | |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 53 | using namespace llvm; |
| 54 | |
Matthias Braun | f89b7c7 | 2015-09-18 17:57:28 +0000 | [diff] [blame] | 55 | static cl::opt<bool> |
| 56 | VerboseDAGDumping("dag-dump-verbose", cl::Hidden, |
| 57 | cl::desc("Display more information when dumping selection " |
| 58 | "DAG nodes.")); |
| 59 | |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 60 | std::string SDNode::getOperationName(const SelectionDAG *G) const { |
| 61 | switch (getOpcode()) { |
| 62 | default: |
| 63 | if (getOpcode() < ISD::BUILTIN_OP_END) |
| 64 | return "<<Unknown DAG Node>>"; |
| 65 | if (isMachineOpcode()) { |
| 66 | if (G) |
Eric Christopher | fc6de42 | 2014-08-05 02:39:49 +0000 | [diff] [blame] | 67 | if (const TargetInstrInfo *TII = G->getSubtarget().getInstrInfo()) |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 68 | if (getMachineOpcode() < TII->getNumOpcodes()) |
| 69 | return TII->getName(getMachineOpcode()); |
| 70 | return "<<Unknown Machine Node #" + utostr(getOpcode()) + ">>"; |
| 71 | } |
| 72 | if (G) { |
| 73 | const TargetLowering &TLI = G->getTargetLoweringInfo(); |
| 74 | const char *Name = TLI.getTargetNodeName(getOpcode()); |
| 75 | if (Name) return Name; |
| 76 | return "<<Unknown Target Node #" + utostr(getOpcode()) + ">>"; |
| 77 | } |
| 78 | return "<<Unknown Node #" + utostr(getOpcode()) + ">>"; |
| 79 | |
| 80 | #ifndef NDEBUG |
| 81 | case ISD::DELETED_NODE: return "<<Deleted Node!>>"; |
| 82 | #endif |
| 83 | case ISD::PREFETCH: return "Prefetch"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 84 | case ISD::ATOMIC_FENCE: return "AtomicFence"; |
| 85 | case ISD::ATOMIC_CMP_SWAP: return "AtomicCmpSwap"; |
Tim Northover | 420a216 | 2014-06-13 14:24:07 +0000 | [diff] [blame] | 86 | case ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS: return "AtomicCmpSwapWithSuccess"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 87 | case ISD::ATOMIC_SWAP: return "AtomicSwap"; |
| 88 | case ISD::ATOMIC_LOAD_ADD: return "AtomicLoadAdd"; |
| 89 | case ISD::ATOMIC_LOAD_SUB: return "AtomicLoadSub"; |
| 90 | case ISD::ATOMIC_LOAD_AND: return "AtomicLoadAnd"; |
Oliver Stannard | 02f08c9 | 2018-02-12 17:03:11 +0000 | [diff] [blame] | 91 | case ISD::ATOMIC_LOAD_CLR: return "AtomicLoadClr"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 92 | case ISD::ATOMIC_LOAD_OR: return "AtomicLoadOr"; |
| 93 | case ISD::ATOMIC_LOAD_XOR: return "AtomicLoadXor"; |
| 94 | case ISD::ATOMIC_LOAD_NAND: return "AtomicLoadNand"; |
| 95 | case ISD::ATOMIC_LOAD_MIN: return "AtomicLoadMin"; |
| 96 | case ISD::ATOMIC_LOAD_MAX: return "AtomicLoadMax"; |
| 97 | case ISD::ATOMIC_LOAD_UMIN: return "AtomicLoadUMin"; |
| 98 | case ISD::ATOMIC_LOAD_UMAX: return "AtomicLoadUMax"; |
| 99 | case ISD::ATOMIC_LOAD: return "AtomicLoad"; |
| 100 | case ISD::ATOMIC_STORE: return "AtomicStore"; |
| 101 | case ISD::PCMARKER: return "PCMarker"; |
| 102 | case ISD::READCYCLECOUNTER: return "ReadCycleCounter"; |
| 103 | case ISD::SRCVALUE: return "SrcValue"; |
| 104 | case ISD::MDNODE_SDNODE: return "MDNode"; |
| 105 | case ISD::EntryToken: return "EntryToken"; |
| 106 | case ISD::TokenFactor: return "TokenFactor"; |
| 107 | case ISD::AssertSext: return "AssertSext"; |
| 108 | case ISD::AssertZext: return "AssertZext"; |
| 109 | |
| 110 | case ISD::BasicBlock: return "BasicBlock"; |
| 111 | case ISD::VALUETYPE: return "ValueType"; |
| 112 | case ISD::Register: return "Register"; |
| 113 | case ISD::RegisterMask: return "RegisterMask"; |
Juergen Ributzka | f26beda | 2014-01-25 02:02:55 +0000 | [diff] [blame] | 114 | case ISD::Constant: |
| 115 | if (cast<ConstantSDNode>(this)->isOpaque()) |
| 116 | return "OpaqueConstant"; |
| 117 | return "Constant"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 118 | case ISD::ConstantFP: return "ConstantFP"; |
| 119 | case ISD::GlobalAddress: return "GlobalAddress"; |
| 120 | case ISD::GlobalTLSAddress: return "GlobalTLSAddress"; |
| 121 | case ISD::FrameIndex: return "FrameIndex"; |
| 122 | case ISD::JumpTable: return "JumpTable"; |
| 123 | case ISD::GLOBAL_OFFSET_TABLE: return "GLOBAL_OFFSET_TABLE"; |
| 124 | case ISD::RETURNADDR: return "RETURNADDR"; |
Albert Gutowski | 795d7d6 | 2016-10-12 22:13:19 +0000 | [diff] [blame] | 125 | case ISD::ADDROFRETURNADDR: return "ADDROFRETURNADDR"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 126 | case ISD::FRAMEADDR: return "FRAMEADDR"; |
Mandeep Singh Grang | 547a0d7 | 2018-11-01 23:22:25 +0000 | [diff] [blame] | 127 | case ISD::SPONENTRY: return "SPONENTRY"; |
Joerg Sonnenberger | fe68b04 | 2016-06-19 12:37:52 +0000 | [diff] [blame] | 128 | case ISD::LOCAL_RECOVER: return "LOCAL_RECOVER"; |
Renato Golin | c7aea40 | 2014-05-06 16:51:25 +0000 | [diff] [blame] | 129 | case ISD::READ_REGISTER: return "READ_REGISTER"; |
| 130 | case ISD::WRITE_REGISTER: return "WRITE_REGISTER"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 131 | case ISD::FRAME_TO_ARGS_OFFSET: return "FRAME_TO_ARGS_OFFSET"; |
Hal Finkel | 5081ac2 | 2016-09-01 10:28:47 +0000 | [diff] [blame] | 132 | case ISD::EH_DWARF_CFA: return "EH_DWARF_CFA"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 133 | case ISD::EH_RETURN: return "EH_RETURN"; |
| 134 | case ISD::EH_SJLJ_SETJMP: return "EH_SJLJ_SETJMP"; |
| 135 | case ISD::EH_SJLJ_LONGJMP: return "EH_SJLJ_LONGJMP"; |
Matthias Braun | 3cd00c1 | 2015-07-16 22:34:16 +0000 | [diff] [blame] | 136 | case ISD::EH_SJLJ_SETUP_DISPATCH: return "EH_SJLJ_SETUP_DISPATCH"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 137 | case ISD::ConstantPool: return "ConstantPool"; |
Jakob Stoklund Olesen | 505715d | 2012-08-07 22:37:05 +0000 | [diff] [blame] | 138 | case ISD::TargetIndex: return "TargetIndex"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 139 | case ISD::ExternalSymbol: return "ExternalSymbol"; |
| 140 | case ISD::BlockAddress: return "BlockAddress"; |
| 141 | case ISD::INTRINSIC_WO_CHAIN: |
| 142 | case ISD::INTRINSIC_VOID: |
| 143 | case ISD::INTRINSIC_W_CHAIN: { |
| 144 | unsigned OpNo = getOpcode() == ISD::INTRINSIC_WO_CHAIN ? 0 : 1; |
| 145 | unsigned IID = cast<ConstantSDNode>(getOperand(OpNo))->getZExtValue(); |
| 146 | if (IID < Intrinsic::num_intrinsics) |
Pete Cooper | 036b94d | 2016-08-23 16:23:45 +0000 | [diff] [blame] | 147 | return Intrinsic::getName((Intrinsic::ID)IID, None); |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 148 | else if (const TargetIntrinsicInfo *TII = G->getTarget().getIntrinsicInfo()) |
| 149 | return TII->getName(IID); |
| 150 | llvm_unreachable("Invalid intrinsic ID"); |
| 151 | } |
| 152 | |
| 153 | case ISD::BUILD_VECTOR: return "BUILD_VECTOR"; |
Juergen Ributzka | f26beda | 2014-01-25 02:02:55 +0000 | [diff] [blame] | 154 | case ISD::TargetConstant: |
| 155 | if (cast<ConstantSDNode>(this)->isOpaque()) |
| 156 | return "OpaqueTargetConstant"; |
| 157 | return "TargetConstant"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 158 | case ISD::TargetConstantFP: return "TargetConstantFP"; |
| 159 | case ISD::TargetGlobalAddress: return "TargetGlobalAddress"; |
| 160 | case ISD::TargetGlobalTLSAddress: return "TargetGlobalTLSAddress"; |
| 161 | case ISD::TargetFrameIndex: return "TargetFrameIndex"; |
| 162 | case ISD::TargetJumpTable: return "TargetJumpTable"; |
| 163 | case ISD::TargetConstantPool: return "TargetConstantPool"; |
| 164 | case ISD::TargetExternalSymbol: return "TargetExternalSymbol"; |
Rafael Espindola | 36b718f | 2015-06-22 17:46:53 +0000 | [diff] [blame] | 165 | case ISD::MCSymbol: return "MCSymbol"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 166 | case ISD::TargetBlockAddress: return "TargetBlockAddress"; |
| 167 | |
| 168 | case ISD::CopyToReg: return "CopyToReg"; |
| 169 | case ISD::CopyFromReg: return "CopyFromReg"; |
| 170 | case ISD::UNDEF: return "undef"; |
| 171 | case ISD::MERGE_VALUES: return "merge_values"; |
| 172 | case ISD::INLINEASM: return "inlineasm"; |
| 173 | case ISD::EH_LABEL: return "eh_label"; |
| 174 | case ISD::HANDLENODE: return "handlenode"; |
| 175 | |
| 176 | // Unary operators |
| 177 | case ISD::FABS: return "fabs"; |
Matt Arsenault | 7c93690 | 2014-10-21 23:01:01 +0000 | [diff] [blame] | 178 | case ISD::FMINNUM: return "fminnum"; |
Cameron McInally | 2ad870e | 2018-10-30 21:01:29 +0000 | [diff] [blame] | 179 | case ISD::STRICT_FMINNUM: return "strict_fminnum"; |
Matt Arsenault | 7c93690 | 2014-10-21 23:01:01 +0000 | [diff] [blame] | 180 | case ISD::FMAXNUM: return "fmaxnum"; |
Cameron McInally | 2ad870e | 2018-10-30 21:01:29 +0000 | [diff] [blame] | 181 | case ISD::STRICT_FMAXNUM: return "strict_fmaxnum"; |
Matt Arsenault | 687ec75 | 2018-10-22 16:27:27 +0000 | [diff] [blame] | 182 | case ISD::FMINNUM_IEEE: return "fminnum_ieee"; |
| 183 | case ISD::FMAXNUM_IEEE: return "fmaxnum_ieee"; |
Thomas Lively | 30f1d69 | 2018-10-24 22:49:55 +0000 | [diff] [blame] | 184 | case ISD::FMINIMUM: return "fminimum"; |
| 185 | case ISD::FMAXIMUM: return "fmaximum"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 186 | case ISD::FNEG: return "fneg"; |
| 187 | case ISD::FSQRT: return "fsqrt"; |
Andrew Kaylor | c414998 | 2018-02-06 22:28:15 +0000 | [diff] [blame] | 188 | case ISD::STRICT_FSQRT: return "strict_fsqrt"; |
Sanjay Patel | 3eaf500 | 2018-09-16 16:50:26 +0000 | [diff] [blame] | 189 | case ISD::FCBRT: return "fcbrt"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 190 | case ISD::FSIN: return "fsin"; |
Andrew Kaylor | c414998 | 2018-02-06 22:28:15 +0000 | [diff] [blame] | 191 | case ISD::STRICT_FSIN: return "strict_fsin"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 192 | case ISD::FCOS: return "fcos"; |
Andrew Kaylor | c414998 | 2018-02-06 22:28:15 +0000 | [diff] [blame] | 193 | case ISD::STRICT_FCOS: return "strict_fcos"; |
Evan Cheng | 0e88c7d | 2013-01-29 02:32:37 +0000 | [diff] [blame] | 194 | case ISD::FSINCOS: return "fsincos"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 195 | case ISD::FTRUNC: return "ftrunc"; |
Cameron McInally | 9757d5d | 2018-11-05 15:59:49 +0000 | [diff] [blame] | 196 | case ISD::STRICT_FTRUNC: return "strict_ftrunc"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 197 | case ISD::FFLOOR: return "ffloor"; |
Cameron McInally | 9757d5d | 2018-11-05 15:59:49 +0000 | [diff] [blame] | 198 | case ISD::STRICT_FFLOOR: return "strict_ffloor"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 199 | case ISD::FCEIL: return "fceil"; |
Cameron McInally | 9757d5d | 2018-11-05 15:59:49 +0000 | [diff] [blame] | 200 | case ISD::STRICT_FCEIL: return "strict_fceil"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 201 | case ISD::FRINT: return "frint"; |
Andrew Kaylor | c414998 | 2018-02-06 22:28:15 +0000 | [diff] [blame] | 202 | case ISD::STRICT_FRINT: return "strict_frint"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 203 | case ISD::FNEARBYINT: return "fnearbyint"; |
Andrew Kaylor | c414998 | 2018-02-06 22:28:15 +0000 | [diff] [blame] | 204 | case ISD::STRICT_FNEARBYINT: return "strict_fnearbyint"; |
Hal Finkel | 171817e | 2013-08-07 22:49:12 +0000 | [diff] [blame] | 205 | case ISD::FROUND: return "fround"; |
Cameron McInally | 9757d5d | 2018-11-05 15:59:49 +0000 | [diff] [blame] | 206 | case ISD::STRICT_FROUND: return "strict_fround"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 207 | case ISD::FEXP: return "fexp"; |
Andrew Kaylor | c414998 | 2018-02-06 22:28:15 +0000 | [diff] [blame] | 208 | case ISD::STRICT_FEXP: return "strict_fexp"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 209 | case ISD::FEXP2: return "fexp2"; |
Andrew Kaylor | c414998 | 2018-02-06 22:28:15 +0000 | [diff] [blame] | 210 | case ISD::STRICT_FEXP2: return "strict_fexp2"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 211 | case ISD::FLOG: return "flog"; |
Andrew Kaylor | c414998 | 2018-02-06 22:28:15 +0000 | [diff] [blame] | 212 | case ISD::STRICT_FLOG: return "strict_flog"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 213 | case ISD::FLOG2: return "flog2"; |
Andrew Kaylor | c414998 | 2018-02-06 22:28:15 +0000 | [diff] [blame] | 214 | case ISD::STRICT_FLOG2: return "strict_flog2"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 215 | case ISD::FLOG10: return "flog10"; |
Andrew Kaylor | c414998 | 2018-02-06 22:28:15 +0000 | [diff] [blame] | 216 | case ISD::STRICT_FLOG10: return "strict_flog10"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 217 | |
| 218 | // Binary operators |
| 219 | case ISD::ADD: return "add"; |
| 220 | case ISD::SUB: return "sub"; |
| 221 | case ISD::MUL: return "mul"; |
| 222 | case ISD::MULHU: return "mulhu"; |
| 223 | case ISD::MULHS: return "mulhs"; |
| 224 | case ISD::SDIV: return "sdiv"; |
| 225 | case ISD::UDIV: return "udiv"; |
| 226 | case ISD::SREM: return "srem"; |
| 227 | case ISD::UREM: return "urem"; |
| 228 | case ISD::SMUL_LOHI: return "smul_lohi"; |
| 229 | case ISD::UMUL_LOHI: return "umul_lohi"; |
| 230 | case ISD::SDIVREM: return "sdivrem"; |
| 231 | case ISD::UDIVREM: return "udivrem"; |
| 232 | case ISD::AND: return "and"; |
| 233 | case ISD::OR: return "or"; |
| 234 | case ISD::XOR: return "xor"; |
| 235 | case ISD::SHL: return "shl"; |
| 236 | case ISD::SRA: return "sra"; |
| 237 | case ISD::SRL: return "srl"; |
| 238 | case ISD::ROTL: return "rotl"; |
| 239 | case ISD::ROTR: return "rotr"; |
Simon Pilgrim | 180639a | 2018-12-05 11:12:12 +0000 | [diff] [blame] | 240 | case ISD::FSHL: return "fshl"; |
| 241 | case ISD::FSHR: return "fshr"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 242 | case ISD::FADD: return "fadd"; |
Andrew Kaylor | c414998 | 2018-02-06 22:28:15 +0000 | [diff] [blame] | 243 | case ISD::STRICT_FADD: return "strict_fadd"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 244 | case ISD::FSUB: return "fsub"; |
Andrew Kaylor | c414998 | 2018-02-06 22:28:15 +0000 | [diff] [blame] | 245 | case ISD::STRICT_FSUB: return "strict_fsub"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 246 | case ISD::FMUL: return "fmul"; |
Andrew Kaylor | c414998 | 2018-02-06 22:28:15 +0000 | [diff] [blame] | 247 | case ISD::STRICT_FMUL: return "strict_fmul"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 248 | case ISD::FDIV: return "fdiv"; |
Andrew Kaylor | c414998 | 2018-02-06 22:28:15 +0000 | [diff] [blame] | 249 | case ISD::STRICT_FDIV: return "strict_fdiv"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 250 | case ISD::FMA: return "fma"; |
Andrew Kaylor | c414998 | 2018-02-06 22:28:15 +0000 | [diff] [blame] | 251 | case ISD::STRICT_FMA: return "strict_fma"; |
Matt Arsenault | 0dc54c4 | 2015-02-20 22:10:33 +0000 | [diff] [blame] | 252 | case ISD::FMAD: return "fmad"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 253 | case ISD::FREM: return "frem"; |
Andrew Kaylor | c414998 | 2018-02-06 22:28:15 +0000 | [diff] [blame] | 254 | case ISD::STRICT_FREM: return "strict_frem"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 255 | case ISD::FCOPYSIGN: return "fcopysign"; |
| 256 | case ISD::FGETSIGN: return "fgetsign"; |
Matt Arsenault | 9cd9071 | 2016-04-14 01:42:16 +0000 | [diff] [blame] | 257 | case ISD::FCANONICALIZE: return "fcanonicalize"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 258 | case ISD::FPOW: return "fpow"; |
Andrew Kaylor | c414998 | 2018-02-06 22:28:15 +0000 | [diff] [blame] | 259 | case ISD::STRICT_FPOW: return "strict_fpow"; |
James Molloy | 7e9776b | 2015-05-15 09:03:15 +0000 | [diff] [blame] | 260 | case ISD::SMIN: return "smin"; |
| 261 | case ISD::SMAX: return "smax"; |
| 262 | case ISD::UMIN: return "umin"; |
| 263 | case ISD::UMAX: return "umax"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 264 | |
| 265 | case ISD::FPOWI: return "fpowi"; |
Andrew Kaylor | c414998 | 2018-02-06 22:28:15 +0000 | [diff] [blame] | 266 | case ISD::STRICT_FPOWI: return "strict_fpowi"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 267 | case ISD::SETCC: return "setcc"; |
Amaury Sechet | 251ea8a | 2017-06-01 11:14:17 +0000 | [diff] [blame] | 268 | case ISD::SETCCCARRY: return "setcccarry"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 269 | case ISD::SELECT: return "select"; |
| 270 | case ISD::VSELECT: return "vselect"; |
| 271 | case ISD::SELECT_CC: return "select_cc"; |
| 272 | case ISD::INSERT_VECTOR_ELT: return "insert_vector_elt"; |
| 273 | case ISD::EXTRACT_VECTOR_ELT: return "extract_vector_elt"; |
| 274 | case ISD::CONCAT_VECTORS: return "concat_vectors"; |
| 275 | case ISD::INSERT_SUBVECTOR: return "insert_subvector"; |
| 276 | case ISD::EXTRACT_SUBVECTOR: return "extract_subvector"; |
| 277 | case ISD::SCALAR_TO_VECTOR: return "scalar_to_vector"; |
| 278 | case ISD::VECTOR_SHUFFLE: return "vector_shuffle"; |
| 279 | case ISD::CARRY_FALSE: return "carry_false"; |
| 280 | case ISD::ADDC: return "addc"; |
| 281 | case ISD::ADDE: return "adde"; |
Amaury Sechet | 8ac81f3 | 2017-04-30 19:24:09 +0000 | [diff] [blame] | 282 | case ISD::ADDCARRY: return "addcarry"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 283 | case ISD::SADDO: return "saddo"; |
| 284 | case ISD::UADDO: return "uaddo"; |
| 285 | case ISD::SSUBO: return "ssubo"; |
| 286 | case ISD::USUBO: return "usubo"; |
| 287 | case ISD::SMULO: return "smulo"; |
| 288 | case ISD::UMULO: return "umulo"; |
| 289 | case ISD::SUBC: return "subc"; |
| 290 | case ISD::SUBE: return "sube"; |
Amaury Sechet | 8ac81f3 | 2017-04-30 19:24:09 +0000 | [diff] [blame] | 291 | case ISD::SUBCARRY: return "subcarry"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 292 | case ISD::SHL_PARTS: return "shl_parts"; |
| 293 | case ISD::SRA_PARTS: return "sra_parts"; |
| 294 | case ISD::SRL_PARTS: return "srl_parts"; |
| 295 | |
Leonard Chan | 699b3b5 | 2018-10-16 17:35:41 +0000 | [diff] [blame] | 296 | case ISD::SADDSAT: return "saddsat"; |
Leonard Chan | 0acfc6b | 2018-10-22 23:08:40 +0000 | [diff] [blame] | 297 | case ISD::UADDSAT: return "uaddsat"; |
Leonard Chan | 905abe5 | 2018-10-29 16:54:37 +0000 | [diff] [blame] | 298 | case ISD::SSUBSAT: return "ssubsat"; |
| 299 | case ISD::USUBSAT: return "usubsat"; |
Leonard Chan | 118e53f | 2018-12-12 06:29:14 +0000 | [diff] [blame] | 300 | case ISD::SMULFIX: return "smulfix"; |
Leonard Chan | 699b3b5 | 2018-10-16 17:35:41 +0000 | [diff] [blame] | 301 | |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 302 | // Conversion operators. |
| 303 | case ISD::SIGN_EXTEND: return "sign_extend"; |
| 304 | case ISD::ZERO_EXTEND: return "zero_extend"; |
| 305 | case ISD::ANY_EXTEND: return "any_extend"; |
| 306 | case ISD::SIGN_EXTEND_INREG: return "sign_extend_inreg"; |
Chandler Carruth | 0b666e0 | 2014-07-10 12:32:32 +0000 | [diff] [blame] | 307 | case ISD::ANY_EXTEND_VECTOR_INREG: return "any_extend_vector_inreg"; |
| 308 | case ISD::SIGN_EXTEND_VECTOR_INREG: return "sign_extend_vector_inreg"; |
Chandler Carruth | afe4b25 | 2014-07-09 10:58:18 +0000 | [diff] [blame] | 309 | case ISD::ZERO_EXTEND_VECTOR_INREG: return "zero_extend_vector_inreg"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 310 | case ISD::TRUNCATE: return "truncate"; |
| 311 | case ISD::FP_ROUND: return "fp_round"; |
| 312 | case ISD::FLT_ROUNDS_: return "flt_rounds"; |
| 313 | case ISD::FP_ROUND_INREG: return "fp_round_inreg"; |
| 314 | case ISD::FP_EXTEND: return "fp_extend"; |
| 315 | |
| 316 | case ISD::SINT_TO_FP: return "sint_to_fp"; |
| 317 | case ISD::UINT_TO_FP: return "uint_to_fp"; |
| 318 | case ISD::FP_TO_SINT: return "fp_to_sint"; |
| 319 | case ISD::FP_TO_UINT: return "fp_to_uint"; |
| 320 | case ISD::BITCAST: return "bitcast"; |
Matt Arsenault | b03bd4d | 2013-11-15 01:34:59 +0000 | [diff] [blame] | 321 | case ISD::ADDRSPACECAST: return "addrspacecast"; |
Tim Northover | fd7e424 | 2014-07-17 10:51:23 +0000 | [diff] [blame] | 322 | case ISD::FP16_TO_FP: return "fp16_to_fp"; |
| 323 | case ISD::FP_TO_FP16: return "fp_to_fp16"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 324 | |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 325 | // Control flow instructions |
| 326 | case ISD::BR: return "br"; |
| 327 | case ISD::BRIND: return "brind"; |
| 328 | case ISD::BR_JT: return "br_jt"; |
| 329 | case ISD::BRCOND: return "brcond"; |
| 330 | case ISD::BR_CC: return "br_cc"; |
| 331 | case ISD::CALLSEQ_START: return "callseq_start"; |
| 332 | case ISD::CALLSEQ_END: return "callseq_end"; |
| 333 | |
Reid Kleckner | 0e28823 | 2015-08-27 23:27:47 +0000 | [diff] [blame] | 334 | // EH instructions |
| 335 | case ISD::CATCHRET: return "catchret"; |
| 336 | case ISD::CLEANUPRET: return "cleanupret"; |
| 337 | |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 338 | // Other operators |
| 339 | case ISD::LOAD: return "load"; |
| 340 | case ISD::STORE: return "store"; |
Elena Demikhovsky | f1de34b | 2014-12-04 09:40:44 +0000 | [diff] [blame] | 341 | case ISD::MLOAD: return "masked_load"; |
| 342 | case ISD::MSTORE: return "masked_store"; |
Elena Demikhovsky | e1eda8a | 2015-04-30 08:38:48 +0000 | [diff] [blame] | 343 | case ISD::MGATHER: return "masked_gather"; |
| 344 | case ISD::MSCATTER: return "masked_scatter"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 345 | case ISD::VAARG: return "vaarg"; |
| 346 | case ISD::VACOPY: return "vacopy"; |
| 347 | case ISD::VAEND: return "vaend"; |
| 348 | case ISD::VASTART: return "vastart"; |
| 349 | case ISD::DYNAMIC_STACKALLOC: return "dynamic_stackalloc"; |
| 350 | case ISD::EXTRACT_ELEMENT: return "extract_element"; |
| 351 | case ISD::BUILD_PAIR: return "build_pair"; |
| 352 | case ISD::STACKSAVE: return "stacksave"; |
| 353 | case ISD::STACKRESTORE: return "stackrestore"; |
| 354 | case ISD::TRAP: return "trap"; |
Dan Gohman | 164fe18 | 2012-05-14 18:58:10 +0000 | [diff] [blame] | 355 | case ISD::DEBUGTRAP: return "debugtrap"; |
Nadav Rotem | 7c277da | 2012-09-06 09:17:37 +0000 | [diff] [blame] | 356 | case ISD::LIFETIME_START: return "lifetime.start"; |
| 357 | case ISD::LIFETIME_END: return "lifetime.end"; |
Pat Gavlin | cc0431d | 2015-05-08 18:07:42 +0000 | [diff] [blame] | 358 | case ISD::GC_TRANSITION_START: return "gc_transition.start"; |
| 359 | case ISD::GC_TRANSITION_END: return "gc_transition.end"; |
Yury Gribov | d7dbb66 | 2015-12-01 11:40:55 +0000 | [diff] [blame] | 360 | case ISD::GET_DYNAMIC_AREA_OFFSET: return "get.dynamic.area.offset"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 361 | |
| 362 | // Bit manipulation |
Simon Pilgrim | cf2da96 | 2017-03-14 21:26:58 +0000 | [diff] [blame] | 363 | case ISD::ABS: return "abs"; |
James Molloy | 90111f7 | 2015-11-12 12:29:09 +0000 | [diff] [blame] | 364 | case ISD::BITREVERSE: return "bitreverse"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 365 | case ISD::BSWAP: return "bswap"; |
| 366 | case ISD::CTPOP: return "ctpop"; |
| 367 | case ISD::CTTZ: return "cttz"; |
| 368 | case ISD::CTTZ_ZERO_UNDEF: return "cttz_zero_undef"; |
| 369 | case ISD::CTLZ: return "ctlz"; |
| 370 | case ISD::CTLZ_ZERO_UNDEF: return "ctlz_zero_undef"; |
Matt Arsenault | def496c | 2017-01-10 22:38:02 +0000 | [diff] [blame] | 371 | |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 372 | // Trampolines |
| 373 | case ISD::INIT_TRAMPOLINE: return "init_trampoline"; |
| 374 | case ISD::ADJUST_TRAMPOLINE: return "adjust_trampoline"; |
| 375 | |
| 376 | case ISD::CONDCODE: |
| 377 | switch (cast<CondCodeSDNode>(this)->get()) { |
| 378 | default: llvm_unreachable("Unknown setcc condition!"); |
| 379 | case ISD::SETOEQ: return "setoeq"; |
| 380 | case ISD::SETOGT: return "setogt"; |
| 381 | case ISD::SETOGE: return "setoge"; |
| 382 | case ISD::SETOLT: return "setolt"; |
| 383 | case ISD::SETOLE: return "setole"; |
| 384 | case ISD::SETONE: return "setone"; |
| 385 | |
| 386 | case ISD::SETO: return "seto"; |
| 387 | case ISD::SETUO: return "setuo"; |
JF Bastien | 0cf7452 | 2015-08-11 21:10:07 +0000 | [diff] [blame] | 388 | case ISD::SETUEQ: return "setueq"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 389 | case ISD::SETUGT: return "setugt"; |
| 390 | case ISD::SETUGE: return "setuge"; |
| 391 | case ISD::SETULT: return "setult"; |
| 392 | case ISD::SETULE: return "setule"; |
| 393 | case ISD::SETUNE: return "setune"; |
| 394 | |
| 395 | case ISD::SETEQ: return "seteq"; |
| 396 | case ISD::SETGT: return "setgt"; |
| 397 | case ISD::SETGE: return "setge"; |
| 398 | case ISD::SETLT: return "setlt"; |
| 399 | case ISD::SETLE: return "setle"; |
| 400 | case ISD::SETNE: return "setne"; |
| 401 | |
| 402 | case ISD::SETTRUE: return "settrue"; |
| 403 | case ISD::SETTRUE2: return "settrue2"; |
| 404 | case ISD::SETFALSE: return "setfalse"; |
| 405 | case ISD::SETFALSE2: return "setfalse2"; |
| 406 | } |
Amara Emerson | cf9daa3 | 2017-05-09 10:43:25 +0000 | [diff] [blame] | 407 | case ISD::VECREDUCE_FADD: return "vecreduce_fadd"; |
Andrew Kaylor | c414998 | 2018-02-06 22:28:15 +0000 | [diff] [blame] | 408 | case ISD::VECREDUCE_STRICT_FADD: return "vecreduce_strict_fadd"; |
Amara Emerson | cf9daa3 | 2017-05-09 10:43:25 +0000 | [diff] [blame] | 409 | case ISD::VECREDUCE_FMUL: return "vecreduce_fmul"; |
Andrew Kaylor | c414998 | 2018-02-06 22:28:15 +0000 | [diff] [blame] | 410 | case ISD::VECREDUCE_STRICT_FMUL: return "vecreduce_strict_fmul"; |
Amara Emerson | cf9daa3 | 2017-05-09 10:43:25 +0000 | [diff] [blame] | 411 | case ISD::VECREDUCE_ADD: return "vecreduce_add"; |
| 412 | case ISD::VECREDUCE_MUL: return "vecreduce_mul"; |
| 413 | case ISD::VECREDUCE_AND: return "vecreduce_and"; |
| 414 | case ISD::VECREDUCE_OR: return "vecreduce_or"; |
| 415 | case ISD::VECREDUCE_XOR: return "vecreduce_xor"; |
| 416 | case ISD::VECREDUCE_SMAX: return "vecreduce_smax"; |
| 417 | case ISD::VECREDUCE_SMIN: return "vecreduce_smin"; |
| 418 | case ISD::VECREDUCE_UMAX: return "vecreduce_umax"; |
| 419 | case ISD::VECREDUCE_UMIN: return "vecreduce_umin"; |
| 420 | case ISD::VECREDUCE_FMAX: return "vecreduce_fmax"; |
| 421 | case ISD::VECREDUCE_FMIN: return "vecreduce_fmin"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 422 | } |
| 423 | } |
| 424 | |
| 425 | const char *SDNode::getIndexedModeName(ISD::MemIndexedMode AM) { |
| 426 | switch (AM) { |
| 427 | default: return ""; |
| 428 | case ISD::PRE_INC: return "<pre-inc>"; |
| 429 | case ISD::PRE_DEC: return "<pre-dec>"; |
| 430 | case ISD::POST_INC: return "<post-inc>"; |
| 431 | case ISD::POST_DEC: return "<post-dec>"; |
| 432 | } |
| 433 | } |
| 434 | |
Matthias Braun | c07cbc8 | 2015-12-04 01:31:59 +0000 | [diff] [blame] | 435 | static Printable PrintNodeId(const SDNode &Node) { |
| 436 | return Printable([&Node](raw_ostream &OS) { |
Matthias Braun | 0b7d6c1 | 2015-09-18 17:41:00 +0000 | [diff] [blame] | 437 | #ifndef NDEBUG |
| 438 | OS << 't' << Node.PersistentId; |
| 439 | #else |
| 440 | OS << (const void*)&Node; |
| 441 | #endif |
Matthias Braun | c07cbc8 | 2015-12-04 01:31:59 +0000 | [diff] [blame] | 442 | }); |
Matthias Braun | 0b7d6c1 | 2015-09-18 17:41:00 +0000 | [diff] [blame] | 443 | } |
| 444 | |
Francis Visoiu Mistrih | e85b06d | 2018-03-14 21:52:13 +0000 | [diff] [blame] | 445 | // Print the MMO with more information from the SelectionDAG. |
| 446 | static void printMemOperand(raw_ostream &OS, const MachineMemOperand &MMO, |
Francis Visoiu Mistrih | 3c0d61b | 2018-04-12 12:59:50 +0000 | [diff] [blame] | 447 | const MachineFunction *MF, const Module *M, |
| 448 | const MachineFrameInfo *MFI, |
| 449 | const TargetInstrInfo *TII, LLVMContext &Ctx) { |
| 450 | ModuleSlotTracker MST(M); |
| 451 | if (MF) |
| 452 | MST.incorporateFunction(MF->getFunction()); |
Francis Visoiu Mistrih | e85b06d | 2018-03-14 21:52:13 +0000 | [diff] [blame] | 453 | SmallVector<StringRef, 0> SSNs; |
Francis Visoiu Mistrih | 3c0d61b | 2018-04-12 12:59:50 +0000 | [diff] [blame] | 454 | MMO.print(OS, MST, SSNs, Ctx, MFI, TII); |
| 455 | } |
| 456 | |
| 457 | static void printMemOperand(raw_ostream &OS, const MachineMemOperand &MMO, |
| 458 | const SelectionDAG *G) { |
| 459 | if (G) { |
| 460 | const MachineFunction *MF = &G->getMachineFunction(); |
| 461 | return printMemOperand(OS, MMO, MF, MF->getFunction().getParent(), |
| 462 | &MF->getFrameInfo(), G->getSubtarget().getInstrInfo(), |
| 463 | *G->getContext()); |
| 464 | } else { |
| 465 | LLVMContext Ctx; |
| 466 | return printMemOperand(OS, MMO, /*MF=*/nullptr, /*M=*/nullptr, |
| 467 | /*MFI=*/nullptr, /*TII=*/nullptr, Ctx); |
| 468 | } |
Francis Visoiu Mistrih | e85b06d | 2018-03-14 21:52:13 +0000 | [diff] [blame] | 469 | } |
| 470 | |
Aaron Ballman | 615eb47 | 2017-10-15 14:32:27 +0000 | [diff] [blame] | 471 | #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) |
Yaron Keren | eb2a254 | 2016-01-29 20:50:44 +0000 | [diff] [blame] | 472 | LLVM_DUMP_METHOD void SDNode::dump() const { dump(nullptr); } |
Eugene Zelenko | 149178d | 2017-10-10 22:33:29 +0000 | [diff] [blame] | 473 | |
Matthias Braun | 8c209aa | 2017-01-28 02:02:38 +0000 | [diff] [blame] | 474 | LLVM_DUMP_METHOD void SDNode::dump(const SelectionDAG *G) const { |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 475 | print(dbgs(), G); |
Quentin Colombet | 35a4701 | 2017-04-01 01:26:17 +0000 | [diff] [blame] | 476 | dbgs() << '\n'; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 477 | } |
Matthias Braun | 8c209aa | 2017-01-28 02:02:38 +0000 | [diff] [blame] | 478 | #endif |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 479 | |
| 480 | void SDNode::print_types(raw_ostream &OS, const SelectionDAG *G) const { |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 481 | for (unsigned i = 0, e = getNumValues(); i != e; ++i) { |
| 482 | if (i) OS << ","; |
| 483 | if (getValueType(i) == MVT::Other) |
| 484 | OS << "ch"; |
| 485 | else |
| 486 | OS << getValueType(i).getEVTString(); |
| 487 | } |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 488 | } |
| 489 | |
| 490 | void SDNode::print_details(raw_ostream &OS, const SelectionDAG *G) const { |
Matt Arsenault | 846dd6b | 2017-10-13 15:41:40 +0000 | [diff] [blame] | 491 | if (getFlags().hasNoUnsignedWrap()) |
| 492 | OS << " nuw"; |
| 493 | |
| 494 | if (getFlags().hasNoSignedWrap()) |
| 495 | OS << " nsw"; |
| 496 | |
| 497 | if (getFlags().hasExact()) |
| 498 | OS << " exact"; |
| 499 | |
Matt Arsenault | 846dd6b | 2017-10-13 15:41:40 +0000 | [diff] [blame] | 500 | if (getFlags().hasNoNaNs()) |
| 501 | OS << " nnan"; |
| 502 | |
| 503 | if (getFlags().hasNoInfs()) |
| 504 | OS << " ninf"; |
| 505 | |
| 506 | if (getFlags().hasNoSignedZeros()) |
| 507 | OS << " nsz"; |
| 508 | |
| 509 | if (getFlags().hasAllowReciprocal()) |
| 510 | OS << " arcp"; |
| 511 | |
| 512 | if (getFlags().hasAllowContract()) |
| 513 | OS << " contract"; |
| 514 | |
Michael Berg | 7acc81b | 2018-05-04 18:48:20 +0000 | [diff] [blame] | 515 | if (getFlags().hasApproximateFuncs()) |
| 516 | OS << " afn"; |
| 517 | |
| 518 | if (getFlags().hasAllowReassociation()) |
| 519 | OS << " reassoc"; |
| 520 | |
Matt Arsenault | 846dd6b | 2017-10-13 15:41:40 +0000 | [diff] [blame] | 521 | if (getFlags().hasVectorReduction()) |
| 522 | OS << " vector-reduction"; |
| 523 | |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 524 | if (const MachineSDNode *MN = dyn_cast<MachineSDNode>(this)) { |
| 525 | if (!MN->memoperands_empty()) { |
| 526 | OS << "<"; |
| 527 | OS << "Mem:"; |
| 528 | for (MachineSDNode::mmo_iterator i = MN->memoperands_begin(), |
| 529 | e = MN->memoperands_end(); i != e; ++i) { |
Francis Visoiu Mistrih | e85b06d | 2018-03-14 21:52:13 +0000 | [diff] [blame] | 530 | printMemOperand(OS, **i, G); |
Benjamin Kramer | b6d0bd4 | 2014-03-02 12:27:27 +0000 | [diff] [blame] | 531 | if (std::next(i) != e) |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 532 | OS << " "; |
| 533 | } |
| 534 | OS << ">"; |
| 535 | } |
| 536 | } else if (const ShuffleVectorSDNode *SVN = |
| 537 | dyn_cast<ShuffleVectorSDNode>(this)) { |
| 538 | OS << "<"; |
| 539 | for (unsigned i = 0, e = ValueList[0].getVectorNumElements(); i != e; ++i) { |
| 540 | int Idx = SVN->getMaskElt(i); |
| 541 | if (i) OS << ","; |
| 542 | if (Idx < 0) |
| 543 | OS << "u"; |
| 544 | else |
| 545 | OS << Idx; |
| 546 | } |
| 547 | OS << ">"; |
| 548 | } else if (const ConstantSDNode *CSDN = dyn_cast<ConstantSDNode>(this)) { |
| 549 | OS << '<' << CSDN->getAPIntValue() << '>'; |
| 550 | } else if (const ConstantFPSDNode *CSDN = dyn_cast<ConstantFPSDNode>(this)) { |
Eugene Zelenko | 149178d | 2017-10-10 22:33:29 +0000 | [diff] [blame] | 551 | if (&CSDN->getValueAPF().getSemantics() == &APFloat::IEEEsingle()) |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 552 | OS << '<' << CSDN->getValueAPF().convertToFloat() << '>'; |
Eugene Zelenko | 149178d | 2017-10-10 22:33:29 +0000 | [diff] [blame] | 553 | else if (&CSDN->getValueAPF().getSemantics() == &APFloat::IEEEdouble()) |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 554 | OS << '<' << CSDN->getValueAPF().convertToDouble() << '>'; |
| 555 | else { |
| 556 | OS << "<APFloat("; |
Matthias Braun | 8c209aa | 2017-01-28 02:02:38 +0000 | [diff] [blame] | 557 | CSDN->getValueAPF().bitcastToAPInt().print(OS, false); |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 558 | OS << ")>"; |
| 559 | } |
| 560 | } else if (const GlobalAddressSDNode *GADN = |
| 561 | dyn_cast<GlobalAddressSDNode>(this)) { |
| 562 | int64_t offset = GADN->getOffset(); |
| 563 | OS << '<'; |
Chandler Carruth | d48cdbf | 2014-01-09 02:29:41 +0000 | [diff] [blame] | 564 | GADN->getGlobal()->printAsOperand(OS); |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 565 | OS << '>'; |
| 566 | if (offset > 0) |
| 567 | OS << " + " << offset; |
| 568 | else |
| 569 | OS << " " << offset; |
| 570 | if (unsigned int TF = GADN->getTargetFlags()) |
| 571 | OS << " [TF=" << TF << ']'; |
| 572 | } else if (const FrameIndexSDNode *FIDN = dyn_cast<FrameIndexSDNode>(this)) { |
| 573 | OS << "<" << FIDN->getIndex() << ">"; |
| 574 | } else if (const JumpTableSDNode *JTDN = dyn_cast<JumpTableSDNode>(this)) { |
| 575 | OS << "<" << JTDN->getIndex() << ">"; |
| 576 | if (unsigned int TF = JTDN->getTargetFlags()) |
| 577 | OS << " [TF=" << TF << ']'; |
| 578 | } else if (const ConstantPoolSDNode *CP = dyn_cast<ConstantPoolSDNode>(this)){ |
| 579 | int offset = CP->getOffset(); |
| 580 | if (CP->isMachineConstantPoolEntry()) |
| 581 | OS << "<" << *CP->getMachineCPVal() << ">"; |
| 582 | else |
| 583 | OS << "<" << *CP->getConstVal() << ">"; |
| 584 | if (offset > 0) |
| 585 | OS << " + " << offset; |
| 586 | else |
| 587 | OS << " " << offset; |
| 588 | if (unsigned int TF = CP->getTargetFlags()) |
| 589 | OS << " [TF=" << TF << ']'; |
Jakob Stoklund Olesen | 505715d | 2012-08-07 22:37:05 +0000 | [diff] [blame] | 590 | } else if (const TargetIndexSDNode *TI = dyn_cast<TargetIndexSDNode>(this)) { |
| 591 | OS << "<" << TI->getIndex() << '+' << TI->getOffset() << ">"; |
| 592 | if (unsigned TF = TI->getTargetFlags()) |
| 593 | OS << " [TF=" << TF << ']'; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 594 | } else if (const BasicBlockSDNode *BBDN = dyn_cast<BasicBlockSDNode>(this)) { |
| 595 | OS << "<"; |
| 596 | const Value *LBB = (const Value*)BBDN->getBasicBlock()->getBasicBlock(); |
| 597 | if (LBB) |
| 598 | OS << LBB->getName() << " "; |
| 599 | OS << (const void*)BBDN->getBasicBlock() << ">"; |
| 600 | } else if (const RegisterSDNode *R = dyn_cast<RegisterSDNode>(this)) { |
Francis Visoiu Mistrih | 9d419d3 | 2017-11-28 12:42:37 +0000 | [diff] [blame] | 601 | OS << ' ' << printReg(R->getReg(), |
Eric Christopher | fc6de42 | 2014-08-05 02:39:49 +0000 | [diff] [blame] | 602 | G ? G->getSubtarget().getRegisterInfo() : nullptr); |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 603 | } else if (const ExternalSymbolSDNode *ES = |
| 604 | dyn_cast<ExternalSymbolSDNode>(this)) { |
| 605 | OS << "'" << ES->getSymbol() << "'"; |
| 606 | if (unsigned int TF = ES->getTargetFlags()) |
| 607 | OS << " [TF=" << TF << ']'; |
| 608 | } else if (const SrcValueSDNode *M = dyn_cast<SrcValueSDNode>(this)) { |
| 609 | if (M->getValue()) |
| 610 | OS << "<" << M->getValue() << ">"; |
| 611 | else |
| 612 | OS << "<null>"; |
| 613 | } else if (const MDNodeSDNode *MD = dyn_cast<MDNodeSDNode>(this)) { |
| 614 | if (MD->getMD()) |
| 615 | OS << "<" << MD->getMD() << ">"; |
| 616 | else |
| 617 | OS << "<null>"; |
| 618 | } else if (const VTSDNode *N = dyn_cast<VTSDNode>(this)) { |
| 619 | OS << ":" << N->getVT().getEVTString(); |
| 620 | } |
| 621 | else if (const LoadSDNode *LD = dyn_cast<LoadSDNode>(this)) { |
Francis Visoiu Mistrih | e85b06d | 2018-03-14 21:52:13 +0000 | [diff] [blame] | 622 | OS << "<"; |
| 623 | |
| 624 | printMemOperand(OS, *LD->getMemOperand(), G); |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 625 | |
| 626 | bool doExt = true; |
| 627 | switch (LD->getExtensionType()) { |
| 628 | default: doExt = false; break; |
| 629 | case ISD::EXTLOAD: OS << ", anyext"; break; |
| 630 | case ISD::SEXTLOAD: OS << ", sext"; break; |
| 631 | case ISD::ZEXTLOAD: OS << ", zext"; break; |
| 632 | } |
| 633 | if (doExt) |
| 634 | OS << " from " << LD->getMemoryVT().getEVTString(); |
| 635 | |
| 636 | const char *AM = getIndexedModeName(LD->getAddressingMode()); |
| 637 | if (*AM) |
| 638 | OS << ", " << AM; |
| 639 | |
| 640 | OS << ">"; |
| 641 | } else if (const StoreSDNode *ST = dyn_cast<StoreSDNode>(this)) { |
Francis Visoiu Mistrih | e85b06d | 2018-03-14 21:52:13 +0000 | [diff] [blame] | 642 | OS << "<"; |
| 643 | printMemOperand(OS, *ST->getMemOperand(), G); |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 644 | |
| 645 | if (ST->isTruncatingStore()) |
| 646 | OS << ", trunc to " << ST->getMemoryVT().getEVTString(); |
| 647 | |
| 648 | const char *AM = getIndexedModeName(ST->getAddressingMode()); |
| 649 | if (*AM) |
| 650 | OS << ", " << AM; |
| 651 | |
| 652 | OS << ">"; |
| 653 | } else if (const MemSDNode* M = dyn_cast<MemSDNode>(this)) { |
Francis Visoiu Mistrih | e85b06d | 2018-03-14 21:52:13 +0000 | [diff] [blame] | 654 | OS << "<"; |
| 655 | printMemOperand(OS, *M->getMemOperand(), G); |
| 656 | OS << ">"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 657 | } else if (const BlockAddressSDNode *BA = |
| 658 | dyn_cast<BlockAddressSDNode>(this)) { |
Michael Liao | abb87d4 | 2012-09-12 21:43:09 +0000 | [diff] [blame] | 659 | int64_t offset = BA->getOffset(); |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 660 | OS << "<"; |
Chandler Carruth | d48cdbf | 2014-01-09 02:29:41 +0000 | [diff] [blame] | 661 | BA->getBlockAddress()->getFunction()->printAsOperand(OS, false); |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 662 | OS << ", "; |
Chandler Carruth | d48cdbf | 2014-01-09 02:29:41 +0000 | [diff] [blame] | 663 | BA->getBlockAddress()->getBasicBlock()->printAsOperand(OS, false); |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 664 | OS << ">"; |
Michael Liao | abb87d4 | 2012-09-12 21:43:09 +0000 | [diff] [blame] | 665 | if (offset > 0) |
| 666 | OS << " + " << offset; |
| 667 | else |
| 668 | OS << " " << offset; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 669 | if (unsigned int TF = BA->getTargetFlags()) |
| 670 | OS << " [TF=" << TF << ']'; |
Matt Arsenault | b03bd4d | 2013-11-15 01:34:59 +0000 | [diff] [blame] | 671 | } else if (const AddrSpaceCastSDNode *ASC = |
| 672 | dyn_cast<AddrSpaceCastSDNode>(this)) { |
| 673 | OS << '[' |
| 674 | << ASC->getSrcAddressSpace() |
| 675 | << " -> " |
| 676 | << ASC->getDestAddressSpace() |
| 677 | << ']'; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 678 | } |
| 679 | |
Matthias Braun | f89b7c7 | 2015-09-18 17:57:28 +0000 | [diff] [blame] | 680 | if (VerboseDAGDumping) { |
| 681 | if (unsigned Order = getIROrder()) |
| 682 | OS << " [ORD=" << Order << ']'; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 683 | |
Matthias Braun | f89b7c7 | 2015-09-18 17:57:28 +0000 | [diff] [blame] | 684 | if (getNodeId() != -1) |
| 685 | OS << " [ID=" << getNodeId() << ']'; |
Alexander Timofeev | 2e5eece | 2018-03-05 15:12:21 +0000 | [diff] [blame] | 686 | if (!(isa<ConstantSDNode>(this) || (isa<ConstantFPSDNode>(this)))) |
| 687 | OS << "# D:" << isDivergent(); |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 688 | |
Matthias Braun | f89b7c7 | 2015-09-18 17:57:28 +0000 | [diff] [blame] | 689 | if (!G) |
| 690 | return; |
Duncan P. N. Exon Smith | b525e1c | 2015-03-30 18:23:28 +0000 | [diff] [blame] | 691 | |
Matthias Braun | f89b7c7 | 2015-09-18 17:57:28 +0000 | [diff] [blame] | 692 | DILocation *L = getDebugLoc(); |
| 693 | if (!L) |
| 694 | return; |
Duncan P. N. Exon Smith | b525e1c | 2015-03-30 18:23:28 +0000 | [diff] [blame] | 695 | |
Matthias Braun | f89b7c7 | 2015-09-18 17:57:28 +0000 | [diff] [blame] | 696 | if (auto *Scope = L->getScope()) |
| 697 | OS << Scope->getFilename(); |
| 698 | else |
| 699 | OS << "<unknown>"; |
| 700 | OS << ':' << L->getLine(); |
| 701 | if (unsigned C = L->getColumn()) |
| 702 | OS << ':' << C; |
Adrian Prantl | 55b8756b | 2018-09-14 17:08:02 +0000 | [diff] [blame] | 703 | |
| 704 | for (SDDbgValue *Dbg : G->GetDbgValues(this)) { |
| 705 | if (Dbg->getKind() != SDDbgValue::SDNODE || Dbg->isInvalidated()) |
| 706 | continue; |
| 707 | Dbg->dump(OS); |
| 708 | } |
Matthias Braun | f89b7c7 | 2015-09-18 17:57:28 +0000 | [diff] [blame] | 709 | } |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 710 | } |
| 711 | |
Adrian Prantl | 55b8756b | 2018-09-14 17:08:02 +0000 | [diff] [blame] | 712 | LLVM_DUMP_METHOD void SDDbgValue::dump(raw_ostream &OS) const { |
| 713 | OS << " DbgVal"; |
| 714 | if (kind==SDNODE) |
| 715 | OS << '(' << u.s.ResNo << ')'; |
| 716 | OS << ":\"" << Var->getName() << '"'; |
Adrian Prantl | 66945cf | 2018-09-14 17:32:52 +0000 | [diff] [blame] | 717 | #ifndef NDEBUG |
Adrian Prantl | 55b8756b | 2018-09-14 17:08:02 +0000 | [diff] [blame] | 718 | if (Expr->getNumElements()) |
| 719 | Expr->dump(); |
Adrian Prantl | 66945cf | 2018-09-14 17:32:52 +0000 | [diff] [blame] | 720 | #endif |
Adrian Prantl | 55b8756b | 2018-09-14 17:08:02 +0000 | [diff] [blame] | 721 | } |
| 722 | |
Matthias Braun | a3b701f | 2015-09-25 22:27:02 +0000 | [diff] [blame] | 723 | /// Return true if this node is so simple that we should just print it inline |
| 724 | /// if it appears as an operand. |
| 725 | static bool shouldPrintInline(const SDNode &Node) { |
| 726 | if (Node.getOpcode() == ISD::EntryToken) |
| 727 | return false; |
| 728 | return Node.getNumOperands() == 0; |
| 729 | } |
| 730 | |
Aaron Ballman | 615eb47 | 2017-10-15 14:32:27 +0000 | [diff] [blame] | 731 | #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 732 | static void DumpNodes(const SDNode *N, unsigned indent, const SelectionDAG *G) { |
Matthias Braun | a3b701f | 2015-09-25 22:27:02 +0000 | [diff] [blame] | 733 | for (const SDValue &Op : N->op_values()) { |
| 734 | if (shouldPrintInline(*Op.getNode())) |
| 735 | continue; |
Pete Cooper | 485d114 | 2015-06-26 19:37:02 +0000 | [diff] [blame] | 736 | if (Op.getNode()->hasOneUse()) |
| 737 | DumpNodes(Op.getNode(), indent+2, G); |
Matthias Braun | a3b701f | 2015-09-25 22:27:02 +0000 | [diff] [blame] | 738 | } |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 739 | |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 740 | dbgs().indent(indent); |
| 741 | N->dump(G); |
| 742 | } |
| 743 | |
Yaron Keren | eb2a254 | 2016-01-29 20:50:44 +0000 | [diff] [blame] | 744 | LLVM_DUMP_METHOD void SelectionDAG::dump() const { |
Matthias Braun | bab3fb4 | 2015-09-18 17:57:31 +0000 | [diff] [blame] | 745 | dbgs() << "SelectionDAG has " << AllNodes.size() << " nodes:\n"; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 746 | |
| 747 | for (allnodes_const_iterator I = allnodes_begin(), E = allnodes_end(); |
| 748 | I != E; ++I) { |
Duncan P. N. Exon Smith | e400a7d | 2015-10-13 19:47:46 +0000 | [diff] [blame] | 749 | const SDNode *N = &*I; |
Matthias Braun | a3b701f | 2015-09-25 22:27:02 +0000 | [diff] [blame] | 750 | if (!N->hasOneUse() && N != getRoot().getNode() && |
| 751 | (!shouldPrintInline(*N) || N->use_empty())) |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 752 | DumpNodes(N, 2, this); |
| 753 | } |
| 754 | |
| 755 | if (getRoot().getNode()) DumpNodes(getRoot().getNode(), 2, this); |
| 756 | dbgs() << "\n\n"; |
| 757 | } |
Matthias Braun | 8c209aa | 2017-01-28 02:02:38 +0000 | [diff] [blame] | 758 | #endif |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 759 | |
| 760 | void SDNode::printr(raw_ostream &OS, const SelectionDAG *G) const { |
Matthias Braun | a3b701f | 2015-09-25 22:27:02 +0000 | [diff] [blame] | 761 | OS << PrintNodeId(*this) << ": "; |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 762 | print_types(OS, G); |
Matthias Braun | a3b701f | 2015-09-25 22:27:02 +0000 | [diff] [blame] | 763 | OS << " = " << getOperationName(G); |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 764 | print_details(OS, G); |
| 765 | } |
| 766 | |
Matthias Braun | a3b701f | 2015-09-25 22:27:02 +0000 | [diff] [blame] | 767 | static bool printOperand(raw_ostream &OS, const SelectionDAG *G, |
| 768 | const SDValue Value) { |
Chih-Hung Hsieh | ed7d81e | 2015-12-03 22:02:40 +0000 | [diff] [blame] | 769 | if (!Value.getNode()) { |
| 770 | OS << "<null>"; |
| 771 | return false; |
| 772 | } else if (shouldPrintInline(*Value.getNode())) { |
Matthias Braun | a3b701f | 2015-09-25 22:27:02 +0000 | [diff] [blame] | 773 | OS << Value->getOperationName(G) << ':'; |
| 774 | Value->print_types(OS, G); |
| 775 | Value->print_details(OS, G); |
| 776 | return true; |
| 777 | } else { |
| 778 | OS << PrintNodeId(*Value.getNode()); |
| 779 | if (unsigned RN = Value.getResNo()) |
| 780 | OS << ':' << RN; |
| 781 | return false; |
| 782 | } |
| 783 | } |
| 784 | |
Aaron Ballman | 615eb47 | 2017-10-15 14:32:27 +0000 | [diff] [blame] | 785 | #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) |
Eugene Zelenko | 149178d | 2017-10-10 22:33:29 +0000 | [diff] [blame] | 786 | using VisitedSDNodeSet = SmallPtrSet<const SDNode *, 32>; |
| 787 | |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 788 | static void DumpNodesr(raw_ostream &OS, const SDNode *N, unsigned indent, |
| 789 | const SelectionDAG *G, VisitedSDNodeSet &once) { |
David Blaikie | 70573dc | 2014-11-19 07:49:26 +0000 | [diff] [blame] | 790 | if (!once.insert(N).second) // If we've been here before, return now. |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 791 | return; |
| 792 | |
| 793 | // Dump the current SDNode, but don't end the line yet. |
| 794 | OS.indent(indent); |
| 795 | N->printr(OS, G); |
| 796 | |
| 797 | // Having printed this SDNode, walk the children: |
| 798 | for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) { |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 799 | if (i) OS << ","; |
| 800 | OS << " "; |
| 801 | |
Matthias Braun | a3b701f | 2015-09-25 22:27:02 +0000 | [diff] [blame] | 802 | const SDValue Op = N->getOperand(i); |
| 803 | bool printedInline = printOperand(OS, G, Op); |
| 804 | if (printedInline) |
| 805 | once.insert(Op.getNode()); |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 806 | } |
| 807 | |
| 808 | OS << "\n"; |
| 809 | |
| 810 | // Dump children that have grandchildren on their own line(s). |
Pete Cooper | 485d114 | 2015-06-26 19:37:02 +0000 | [diff] [blame] | 811 | for (const SDValue &Op : N->op_values()) |
| 812 | DumpNodesr(OS, Op.getNode(), indent+2, G, once); |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 813 | } |
| 814 | |
Matthias Braun | 8c209aa | 2017-01-28 02:02:38 +0000 | [diff] [blame] | 815 | LLVM_DUMP_METHOD void SDNode::dumpr() const { |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 816 | VisitedSDNodeSet once; |
Craig Topper | c0196b1 | 2014-04-14 00:51:57 +0000 | [diff] [blame] | 817 | DumpNodesr(dbgs(), this, 0, nullptr, once); |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 818 | } |
| 819 | |
Matthias Braun | 8c209aa | 2017-01-28 02:02:38 +0000 | [diff] [blame] | 820 | LLVM_DUMP_METHOD void SDNode::dumpr(const SelectionDAG *G) const { |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 821 | VisitedSDNodeSet once; |
| 822 | DumpNodesr(dbgs(), this, 0, G, once); |
| 823 | } |
Matthias Braun | 8c209aa | 2017-01-28 02:02:38 +0000 | [diff] [blame] | 824 | #endif |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 825 | |
| 826 | static void printrWithDepthHelper(raw_ostream &OS, const SDNode *N, |
| 827 | const SelectionDAG *G, unsigned depth, |
| 828 | unsigned indent) { |
| 829 | if (depth == 0) |
| 830 | return; |
| 831 | |
| 832 | OS.indent(indent); |
| 833 | |
| 834 | N->print(OS, G); |
| 835 | |
| 836 | if (depth < 1) |
| 837 | return; |
| 838 | |
Pete Cooper | 485d114 | 2015-06-26 19:37:02 +0000 | [diff] [blame] | 839 | for (const SDValue &Op : N->op_values()) { |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 840 | // Don't follow chain operands. |
Pete Cooper | 485d114 | 2015-06-26 19:37:02 +0000 | [diff] [blame] | 841 | if (Op.getValueType() == MVT::Other) |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 842 | continue; |
| 843 | OS << '\n'; |
Pete Cooper | 485d114 | 2015-06-26 19:37:02 +0000 | [diff] [blame] | 844 | printrWithDepthHelper(OS, Op.getNode(), G, depth-1, indent+2); |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 845 | } |
| 846 | } |
| 847 | |
| 848 | void SDNode::printrWithDepth(raw_ostream &OS, const SelectionDAG *G, |
| 849 | unsigned depth) const { |
| 850 | printrWithDepthHelper(OS, this, G, depth, 0); |
| 851 | } |
| 852 | |
| 853 | void SDNode::printrFull(raw_ostream &OS, const SelectionDAG *G) const { |
| 854 | // Don't print impossibly deep things. |
| 855 | printrWithDepth(OS, G, 10); |
| 856 | } |
| 857 | |
Aaron Ballman | 615eb47 | 2017-10-15 14:32:27 +0000 | [diff] [blame] | 858 | #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) |
Matthias Braun | 8c209aa | 2017-01-28 02:02:38 +0000 | [diff] [blame] | 859 | LLVM_DUMP_METHOD |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 860 | void SDNode::dumprWithDepth(const SelectionDAG *G, unsigned depth) const { |
| 861 | printrWithDepth(dbgs(), G, depth); |
| 862 | } |
| 863 | |
Matthias Braun | 8c209aa | 2017-01-28 02:02:38 +0000 | [diff] [blame] | 864 | LLVM_DUMP_METHOD void SDNode::dumprFull(const SelectionDAG *G) const { |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 865 | // Don't print impossibly deep things. |
| 866 | dumprWithDepth(G, 10); |
| 867 | } |
Matthias Braun | 8c209aa | 2017-01-28 02:02:38 +0000 | [diff] [blame] | 868 | #endif |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 869 | |
| 870 | void SDNode::print(raw_ostream &OS, const SelectionDAG *G) const { |
Matthias Braun | a3b701f | 2015-09-25 22:27:02 +0000 | [diff] [blame] | 871 | printr(OS, G); |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 872 | for (unsigned i = 0, e = getNumOperands(); i != e; ++i) { |
| 873 | if (i) OS << ", "; else OS << " "; |
Matthias Braun | a3b701f | 2015-09-25 22:27:02 +0000 | [diff] [blame] | 874 | printOperand(OS, G, getOperand(i)); |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 875 | } |
Vedant Kumar | f177206 | 2018-04-23 17:18:24 +0000 | [diff] [blame] | 876 | if (DebugLoc DL = getDebugLoc()) { |
| 877 | OS << ", "; |
| 878 | DL.print(OS); |
| 879 | } |
Bill Wendling | 508a3e5 | 2012-03-13 05:47:27 +0000 | [diff] [blame] | 880 | } |