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