36 cl::desc(
"Display more information when dumping selection "
43 return "<<Unknown DAG Node>>";
54 if (Name)
return Name;
93 if (cast<ConstantSDNode>(
this)->isOpaque())
94 return "OpaqueConstant";
122 unsigned IID = cast<ConstantSDNode>(
getOperand(OpNo))->getZExtValue();
126 return TII->getName(IID);
132 if (cast<ConstantSDNode>(
this)->isOpaque())
133 return "OpaqueTargetConstant";
134 return "TargetConstant";
316 switch (cast<CondCodeSDNode>(
this)->
get()) {
364 OS << (
const void*)&Node;
386 if (
const MachineSDNode *MN = dyn_cast<MachineSDNode>(
this)) {
387 if (!MN->memoperands_empty()) {
391 e = MN->memoperands_end();
i != e; ++
i) {
393 if (std::next(i) != e)
399 dyn_cast<ShuffleVectorSDNode>(
this)) {
401 for (
unsigned i = 0, e = ValueList[0].getVectorNumElements();
i != e; ++
i) {
402 int Idx = SVN->getMaskElt(
i);
410 }
else if (
const ConstantSDNode *CSDN = dyn_cast<ConstantSDNode>(
this)) {
411 OS <<
'<' << CSDN->getAPIntValue() <<
'>';
412 }
else if (
const ConstantFPSDNode *CSDN = dyn_cast<ConstantFPSDNode>(
this)) {
414 OS <<
'<' << CSDN->getValueAPF().convertToFloat() <<
'>';
416 OS <<
'<' << CSDN->getValueAPF().convertToDouble() <<
'>';
419 CSDN->getValueAPF().bitcastToAPInt().dump();
423 dyn_cast<GlobalAddressSDNode>(
this)) {
424 int64_t offset = GADN->getOffset();
426 GADN->getGlobal()->printAsOperand(OS);
429 OS << " + " << offset;
432 if (unsigned int TF = GADN->getTargetFlags())
433 OS << " [TF=" << TF << ']
';
434 } else if (const FrameIndexSDNode *FIDN = dyn_cast<FrameIndexSDNode>(this)) {
435 OS << "<" << FIDN->getIndex() << ">";
436 } else if (const JumpTableSDNode *JTDN = dyn_cast<JumpTableSDNode>(this)) {
437 OS << "<" << JTDN->getIndex() << ">";
438 if (unsigned int TF = JTDN->getTargetFlags())
439 OS << " [TF=" << TF << ']
';
440 } else if (const ConstantPoolSDNode *CP = dyn_cast<ConstantPoolSDNode>(this)){
441 int offset = CP->getOffset();
442 if (CP->isMachineConstantPoolEntry())
443 OS << "<" << *CP->getMachineCPVal() << ">";
445 OS << "<" << *CP->getConstVal() << ">";
447 OS << " + " << offset;
450 if (unsigned int TF = CP->getTargetFlags())
451 OS << " [TF=" << TF << ']
';
452 } else if (const TargetIndexSDNode *TI = dyn_cast<TargetIndexSDNode>(this)) {
453 OS << "<" << TI->getIndex() << '+
' << TI->getOffset() << ">";
454 if (unsigned TF = TI->getTargetFlags())
455 OS << " [TF=" << TF << ']
';
456 } else if (const BasicBlockSDNode *BBDN = dyn_cast<BasicBlockSDNode>(this)) {
458 const Value *LBB = (const Value*)BBDN->getBasicBlock()->getBasicBlock();
460 OS << LBB->getName() << " ";
461 OS << (const void*)BBDN->getBasicBlock() << ">";
462 } else if (const RegisterSDNode *R = dyn_cast<RegisterSDNode>(this)) {
463 OS << ' ' << PrintReg(R->getReg(),
464 G ? G->getSubtarget().getRegisterInfo() : nullptr);
465 } else if (const ExternalSymbolSDNode *ES =
466 dyn_cast<ExternalSymbolSDNode>(this)) {
467 OS << "'" << ES->getSymbol() << "'";
468 if (unsigned int TF = ES->getTargetFlags())
469 OS << " [TF=" << TF << ']
';
470 } else if (const SrcValueSDNode *M = dyn_cast<SrcValueSDNode>(this)) {
472 OS << "<" << M->getValue() << ">";
475 } else if (const MDNodeSDNode *MD = dyn_cast<MDNodeSDNode>(this)) {
477 OS << "<" << MD->getMD() << ">";
480 } else if (const VTSDNode *N = dyn_cast<VTSDNode>(this)) {
481 OS << ":" << N->getVT().getEVTString();
483 else if (const LoadSDNode *LD = dyn_cast<LoadSDNode>(this)) {
484 OS << "<" << *LD->getMemOperand();
487 switch (LD->getExtensionType()) {
488 default: doExt = false; break;
489 case ISD::EXTLOAD: OS << ", anyext"; break;
490 case ISD::SEXTLOAD: OS << ", sext"; break;
491 case ISD::ZEXTLOAD: OS << ", zext"; break;
494 OS << " from " << LD->getMemoryVT().getEVTString();
496 const char *AM = getIndexedModeName(LD->getAddressingMode());
501 } else if (const StoreSDNode *ST = dyn_cast<StoreSDNode>(this)) {
502 OS << "<" << *ST->getMemOperand();
504 if (ST->isTruncatingStore())
505 OS << ", trunc to " << ST->getMemoryVT().getEVTString();
507 const char *AM = getIndexedModeName(ST->getAddressingMode());
512 } else if (const MemSDNode* M = dyn_cast<MemSDNode>(this)) {
513 OS << "<" << *M->getMemOperand() << ">";
514 } else if (const BlockAddressSDNode *BA =
515 dyn_cast<BlockAddressSDNode>(this)) {
516 int64_t offset = BA->getOffset();
518 BA->getBlockAddress()->getFunction()->printAsOperand(OS, false);
520 BA->getBlockAddress()->getBasicBlock()->printAsOperand(OS, false);
523 OS << " + " << offset;
526 if (unsigned int TF = BA->getTargetFlags())
527 OS << " [TF=" << TF << ']
';
528 } else if (const AddrSpaceCastSDNode *ASC =
529 dyn_cast<AddrSpaceCastSDNode>(this)) {
531 << ASC->getSrcAddressSpace()
533 << ASC->getDestAddressSpace()
537 if (VerboseDAGDumping) {
538 if (unsigned Order = getIROrder())
539 OS << " [ORD=" << Order << ']
';
541 if (getNodeId() != -1)
542 OS << " [ID=" << getNodeId() << ']
';
547 DILocation *L = getDebugLoc();
551 if (auto *Scope = L->getScope())
552 OS << Scope->getFilename();
555 OS << ':
' << L->getLine();
556 if (unsigned C = L->getColumn())
563 static bool shouldPrintInline(const SDNode &Node) {
564 if (Node.getOpcode() == ISD::EntryToken)
566 return Node.getNumOperands() == 0;
569 static void DumpNodes(const SDNode *N, unsigned indent, const SelectionDAG *G) {
570 for (const SDValue &Op : N->op_values()) {
571 if (shouldPrintInline(*Op.getNode()))
573 if (Op.getNode()->hasOneUse())
574 DumpNodes(Op.getNode(), indent+2, G);
577 dbgs().indent(indent);
581 LLVM_DUMP_METHOD void SelectionDAG::dump() const {
582 dbgs() << "SelectionDAG has " << AllNodes.size() << " nodes:\n";
584 for (allnodes_const_iterator I = allnodes_begin(), E = allnodes_end();
586 const SDNode *N = &*I;
587 if (!N->hasOneUse() && N != getRoot().getNode() &&
588 (!shouldPrintInline(*N) || N->use_empty()))
589 DumpNodes(N, 2, this);
592 if (getRoot().getNode()) DumpNodes(getRoot().getNode(), 2, this);
596 void SDNode::printr(raw_ostream &OS, const SelectionDAG *G) const {
597 OS << PrintNodeId(*this) << ": ";
599 OS << " = " << getOperationName(G);
600 print_details(OS, G);
603 static bool printOperand(raw_ostream &OS, const SelectionDAG *G,
604 const SDValue Value) {
605 if (!Value.getNode()) {
608 } else if (shouldPrintInline(*Value.getNode())) {
609 OS << Value->getOperationName(G) << ':
';
610 Value->print_types(OS, G);
611 Value->print_details(OS, G);
614 OS << PrintNodeId(*Value.getNode());
615 if (unsigned RN = Value.getResNo())
621 typedef SmallPtrSet<const SDNode *, 32> VisitedSDNodeSet;
622 static void DumpNodesr(raw_ostream &OS, const SDNode *N, unsigned indent,
623 const SelectionDAG *G, VisitedSDNodeSet &once) {
624 if (!once.insert(N).second) // If we've been here before,
return now.
632 for (
unsigned i = 0, e =
N->getNumOperands();
i != e; ++
i) {
682 unsigned depth)
const {
703 if (
i) OS <<
", ";
else OS <<
" ";
ADJUST_TRAMPOLINE - This corresponds to the adjust_trampoline intrinsic.
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
X = FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type down to the precision of the ...
BUILTIN_OP_END - This must be the last enum value in this list.
FMINNUM/FMAXNUM - Perform floating-point minimum or maximum on two values.
EXTRACT_ELEMENT - This is used to get the lower or upper (determined by a Constant, which is required to be operand #1) half of the integer or float value specified as operand #0.
void dumprFull(const SelectionDAG *G=nullptr) const
printrFull to dbgs().
DELETED_NODE - This is an illegal value that is used to catch errors.
MDNODE_SDNODE - This is a node that holdes an MDNode*, which is used to reference metadata in the IR...
EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR (an vector value) starting with the ...
BR_CC - Conditional branch.
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds...
VECTOR_SHUFFLE(VEC1, VEC2) - Returns a vector, of the same type as VEC1/VEC2.
ZERO_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register zero-extension of the low ...
Carry-setting nodes for multiple precision addition and subtraction.
const TargetMachine & getTarget() const
const TargetSubtargetInfo & getSubtarget() const
STACKRESTORE has two operands, an input chain and a pointer to restore to it returns an output chain...
raw_ostream & indent(unsigned NumSpaces)
indent - Insert 'NumSpaces' spaces.
RESULT, BOOL = [SU]ADDO(LHS, RHS) - Overflow-aware nodes for addition.
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or anything else with this node...
Val, Success, OUTCHAIN = ATOMIC_CMP_SWAP_WITH_SUCCESS(INCHAIN, ptr, cmp, swap) N.b.
unsigned getNumOperands() const
Return the number of values used by this operation.
const SDValue & getOperand(unsigned Num) const
SIGN_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register sign-extension of the low ...
[US]{MIN/MAX} - Binary minimum or maximum or signed or unsigned integers.
INSERT_SUBVECTOR(VECTOR1, VECTOR2, IDX) - Returns a vector with VECTOR2 inserted into VECTOR1 at the ...
uint16_t PersistentId
Unique and persistent id per SDNode in the DAG.
EntryToken - This is the marker used to indicate the start of a region.
OUTCHAIN = ATOMIC_FENCE(INCHAIN, ordering, scope) This corresponds to the fence instruction.
Select with condition operator - This selects between a true value and a false value (ops #2 and #3) ...
INT = FGETSIGN(FP) - Return the sign bit of the specified floating point value as an integer 0/1 valu...
This SDNode is used to implement the code generator support for the llvm IR shufflevector instruction...
RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...) This node represents a target in...
void dumpr() const
Dump (recursively) this node and its use-def subgraph.
OUTCHAIN = EH_SJLJ_LONGJMP(INCHAIN, buffer) This corresponds to the eh.sjlj.longjmp intrinsic...
SDIVREM/UDIVREM - Divide two integers and produce both a quotient and remainder result.
SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded integer shift operations...
void print_types(raw_ostream &OS, const SelectionDAG *G) const
CLEANUPRET - Represents a return from a cleanup block funclet.
void dumprWithDepth(const SelectionDAG *G=nullptr, unsigned depth=100) const
printrWithDepth to dbgs().
static Printable PrintNodeId(const SDNode &Node)
A description of a memory reference used in the backend.
virtual const char * getTargetNodeName(unsigned Opcode) const
This method returns the name of a target specific DAG node.
std::string getEVTString() const
getEVTString - This function returns value type as a string, e.g.
PCMARKER - This corresponds to the pcmarker intrinsic.
StringRef getName(ID id)
Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
const HexagonInstrInfo * TII
Shift and rotation operations.
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.
CopyToReg - This node has three operands: a chain, a register number to set to this value...
FLT_ROUNDS_ - Returns current rounding mode: -1 Undefined 0 Round to 0 1 Round to nearest 2 Round to ...
CALLSEQ_START/CALLSEQ_END - These operators mark the beginning and end of a call sequence, and carry arbitrary information that target might want to know.
EH_DWARF_CFA - This node represents the pointer to the DWARF Canonical Frame Address (CFA)...
Val, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amt) Val, OUTCHAIN = ATOMIC_LOAD_[OpName](INCHAIN, ptr, amt) For double-word atomic operations: ValLo, ValHi, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amtLo, amtHi) ValLo, ValHi, OUTCHAIN = ATOMIC_LOAD_[OpName](INCHAIN, ptr, amtLo, amtHi) These correspond to the atomicrmw instruction.
FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and llvm.returnaddress on the DAG...
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
static void printrWithDepthHelper(raw_ostream &OS, const SDNode *N, const SelectionDAG *G, unsigned depth, unsigned indent)
INLINEASM - Represents an inline asm block.
STACKSAVE - STACKSAVE has one operand, an input chain.
FRAME_TO_ARGS_OFFSET - This node represents offset from frame pointer to first (possible) on-stack ar...
[SU]INT_TO_FP - These operators convert integers (whose interpreted sign depends on the first letter)...
OUTCHAIN = EH_SJLJ_SETUP_DISPATCH(INCHAIN) The target initializes the dispatch table here...
unsigned getNumValues() const
Return the number of values defined/returned by this operator.
Select with a vector condition (op #0) and two vector operands (ops #1 and #2), returning a vector re...
Simple integer binary arithmetic operators.
static std::string utostr(uint64_t X, bool isNeg=false)
static void DumpNodesr(raw_ostream &OS, const SDNode *N, unsigned indent, const SelectionDAG *G, VisitedSDNodeSet &once)
TargetConstant* - Like Constant*, but the DAG does not do any folding, simplification, or lowering of the constant.
static const char * getIndexedModeName(ISD::MemIndexedMode AM)
READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic.
ANY_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register any-extension of the low la...
RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...) This node represents a target intrinsic fun...
UNDEF - An undefined node.
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
std::string getOperationName(const SelectionDAG *G=nullptr) const
Return the opcode of this operation for printing.
static const fltSemantics & IEEEsingle()
BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a vector with the specified, possibly variable...
TargetInstrInfo - Interface to description of machine instruction set.
This corresponds to the llvm.lifetime.
SDNode * getNode() const
get the SDNode which holds the desired result
OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...) This node represents a target intrin...
Control flow instructions. These all have token chains.
READ_REGISTER, WRITE_REGISTER - This node represents llvm.register on the DAG, which implements the n...
GC_TRANSITION_START/GC_TRANSITION_END - These operators mark the beginning and end of GC transition s...
LOCAL_RECOVER - Represents the llvm.localrecover intrinsic.
Simple binary floating point operators.
VAEND, VASTART - VAEND and VASTART have three operands: an input chain, pointer, and a SRCVALUE...
INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element at IDX replaced with VAL...
Carry-using nodes for multiple precision addition and subtraction.
static sys::TimePoint< std::chrono::seconds > now(bool Deterministic)
INIT_TRAMPOLINE - This corresponds to the init_trampoline intrinsic.
void printrFull(raw_ostream &O, const SelectionDAG *G=nullptr) const
Print a SelectionDAG node and all children down to the leaves.
TRAP - Trapping instruction.
TargetIndex - Like a constant pool entry, but with completely target-dependent semantics.
AssertSext, AssertZext - These nodes record if a register contains a value that has already been zero...
DEBUGTRAP - Trap intended to get the attention of a debugger.
VAARG - VAARG has four operands: an input chain, a pointer, a SRCVALUE, and the alignment.
Bit counting operators with an undefined result for zero inputs.
Val, OUTCHAIN = ATOMIC_CMP_SWAP(INCHAIN, ptr, cmp, swap) For double-word atomic operations: ValLo...
X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
HANDLENODE node - Used as a handle for various purposes.
EH_LABEL - Represents a label in mid basic block used to track locations needed for debug and excepti...
void print(raw_ostream &OS, const SelectionDAG *G=nullptr) const
TargetIntrinsicInfo - Interface to description of machine instruction set.
TokenFactor - This node takes multiple tokens as input and produces a single token result...
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
void dump() const
Dump this node, for debugging.
Returns platform specific canonical encoding of a floating point number.
EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR identified by the (potentially...
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
X = FP_ROUND_INREG(Y, VT) - This operator takes an FP register, and rounds it to a floating point val...
ADDRSPACECAST - This operator converts between pointers of different address spaces.
BRCOND - Conditional branch.
An SDNode that represents everything that will be needed to construct a MachineInstr.
Byte Swap and Counting operators.
FP16_TO_FP, FP_TO_FP16 - These operators are used to perform promotions and truncation for half-preci...
Represents one node in the SelectionDAG.
void print_details(raw_ostream &OS, const SelectionDAG *G) const
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void printr(raw_ostream &OS, const SelectionDAG *G=nullptr) const
Select(COND, TRUEVAL, FALSEVAL).
ZERO_EXTEND - Used for integer types, zeroing the new bits.
ANY_EXTEND - Used for integer types. The high bits are undefined.
FCOPYSIGN(X, Y) - Return the value of X with the sign of Y.
FMINNAN/FMAXNAN - Behave identically to FMINNUM/FMAXNUM, except that when a single input is NaN...
iterator_range< value_op_iterator > op_values() const
static const fltSemantics & IEEEdouble()
CATCHRET - Represents a return from a catch block funclet.
GET_DYNAMIC_AREA_OFFSET - get offset from native SP to the address of the most recent dynamic alloca...
BR_JT - Jumptable branch.
VACOPY - VACOPY has 5 operands: an input chain, a destination pointer, a source pointer, a SRCVALUE for the destination, and a SRCVALUE for the source.
static bool printOperand(raw_ostream &OS, const SelectionDAG *G, const SDValue Value)
Bitwise operators - logical and, logical or, logical xor.
SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing a signed/unsigned value of type i[2...
virtual const TargetIntrinsicInfo * getIntrinsicInfo() const
If intrinsic information is available, return it. If not, return null.
SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to sign extend a small value in ...
LOAD and STORE have token chains as their first operand, then the same operands as an LLVM load/store...
FSINCOS - Compute both fsin and fcos as a single operation.
RESULT, OUTCHAIN = EH_SJLJ_SETJMP(INCHAIN, buffer) This corresponds to the eh.sjlj.setjmp intrinsic.
CopyFromReg - This node indicates that the input value is a virtual or physical register that is defi...
OUTCHAIN = EH_RETURN(INCHAIN, OFFSET, HANDLER) - This node represents 'eh_return' gcc dwarf builtin...
Like SetCC, ops #0 and #1 are the LHS and RHS operands to compare, but op #2 is a carry value...
CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of vector type with the same length ...
virtual const TargetInstrInfo * getInstrInfo() const
FMA - Perform a * b + c with no intermediate rounding step.
PREFETCH - This corresponds to a prefetch intrinsic.
void printrWithDepth(raw_ostream &O, const SelectionDAG *G=nullptr, unsigned depth=100) const
Print a SelectionDAG node and children up to depth "depth." The given SelectionDAG allows target-spec...
const TargetLowering & getTargetLoweringInfo() const
This class implements an extremely fast bulk output stream that can only output to a stream...
FMAD - Perform a * b + c, while getting the same result as the separately rounded operations...
SetCC operator - This evaluates to a true value iff the condition is true.
MERGE_VALUES - This node takes multiple discrete operands and returns them all as its individual resu...
Simple wrapper around std::function<void(raw_ostream&)>.
OUTCHAIN = ATOMIC_STORE(INCHAIN, ptr, val) This corresponds to "store atomic" instruction.
TRUNCATE - Completely drop the high bits.
static cl::opt< bool > VerboseDAGDumping("dag-dump-verbose", cl::Hidden, cl::desc("Display more information when dumping selection ""DAG nodes."))
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, FPOW, FLOG, FLOG2, FLOG10, FEXP, FEXP2, FCEIL, FTRUNC, FRINT, FNEARBYINT, FROUND, FFLOOR - Perform various unary floating point operations.
Val, OUTCHAIN = ATOMIC_LOAD(INCHAIN, ptr) This corresponds to "load atomic" instruction.
SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a scalar value into element 0 of the...
CARRY_FALSE - This node is used when folding other nodes, like ADDC/SUBC, which indicate the carry re...
bool isMachineOpcode() const
Test if this node has a post-isel opcode, directly corresponding to a MachineInstr opcode...
unsigned getMachineOpcode() const
This may only be called if isMachineOpcode returns true.
MemIndexedMode
MemIndexedMode enum - This enum defines the load / store indexed addressing modes.
MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing an unsigned/signed value of...
SRCVALUE - This is a node type that holds a Value* that is used to make reference to a value in the L...
DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned to a specified boundary...