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