1 //===-- llvm/CodeGen/SelectionDAGNodes.h - SelectionDAG Nodes ---*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares the SDNode class and derived classes, which are used to
11 // represent the nodes and operations present in a SelectionDAG. These nodes
12 // and operations are machine code level operations, with some similarities to
13 // the GCC RTL representation.
15 // Clients should include the SelectionDAG.h file instead of this file directly.
17 //===----------------------------------------------------------------------===//
19 #ifndef LLVM_CODEGEN_SELECTIONDAGNODES_H
20 #define LLVM_CODEGEN_SELECTIONDAGNODES_H
22 #include "llvm/Value.h"
23 #include "llvm/Constants.h"
24 #include "llvm/ADT/FoldingSet.h"
25 #include "llvm/ADT/GraphTraits.h"
26 #include "llvm/ADT/iterator.h"
27 #include "llvm/ADT/ilist_node.h"
28 #include "llvm/ADT/STLExtras.h"
29 #include "llvm/CodeGen/ValueTypes.h"
30 #include "llvm/CodeGen/MachineMemOperand.h"
31 #include "llvm/Support/Allocator.h"
32 #include "llvm/Support/RecyclingAllocator.h"
33 #include "llvm/Support/DataTypes.h"
40 class MachineBasicBlock;
41 class MachineConstantPoolValue;
43 class CompileUnitDesc;
44 template <typename T> struct DenseMapInfo;
45 template <typename T> struct simplify_type;
46 template <typename T> struct ilist_traits;
48 /// SDVTList - This represents a list of ValueType's that has been intern'd by
49 /// a SelectionDAG. Instances of this simple value class are returned by
50 /// SelectionDAG::getVTList(...).
54 unsigned short NumVTs;
57 /// ISD namespace - This namespace contains an enum which represents all of the
58 /// SelectionDAG node types and value types.
60 /// If you add new elements here you should increase OpActionsCapacity in
61 /// TargetLowering.h by the number of new elements.
64 //===--------------------------------------------------------------------===//
65 /// ISD::NodeType enum - This enum defines all of the operators valid in a
69 // DELETED_NODE - This is an illegal flag value that is used to catch
70 // errors. This opcode is not a legal opcode for any node.
73 // EntryToken - This is the marker used to indicate the start of the region.
76 // TokenFactor - This node takes multiple tokens as input and produces a
77 // single token result. This is used to represent the fact that the operand
78 // operators are independent of each other.
81 // AssertSext, AssertZext - These nodes record if a register contains a
82 // value that has already been zero or sign extended from a narrower type.
83 // These nodes take two operands. The first is the node that has already
84 // been extended, and the second is a value type node indicating the width
86 AssertSext, AssertZext,
88 // Various leaf nodes.
89 BasicBlock, VALUETYPE, ARG_FLAGS, CONDCODE, Register,
91 GlobalAddress, GlobalTLSAddress, FrameIndex,
92 JumpTable, ConstantPool, ExternalSymbol,
94 // The address of the GOT
97 // FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and
98 // llvm.returnaddress on the DAG. These nodes take one operand, the index
99 // of the frame or return address to return. An index of zero corresponds
100 // to the current function's frame or return address, an index of one to the
101 // parent's frame or return address, and so on.
102 FRAMEADDR, RETURNADDR,
104 // FRAME_TO_ARGS_OFFSET - This node represents offset from frame pointer to
105 // first (possible) on-stack argument. This is needed for correct stack
106 // adjustment during unwind.
107 FRAME_TO_ARGS_OFFSET,
109 // RESULT, OUTCHAIN = EXCEPTIONADDR(INCHAIN) - This node represents the
110 // address of the exception block on entry to an landing pad block.
113 // RESULT, OUTCHAIN = EHSELECTION(INCHAIN, EXCEPTION) - This node represents
114 // the selection index of the exception thrown.
117 // OUTCHAIN = EH_RETURN(INCHAIN, OFFSET, HANDLER) - This node represents
118 // 'eh_return' gcc dwarf builtin, which is used to return from
119 // exception. The general meaning is: adjust stack by OFFSET and pass
120 // execution to HANDLER. Many platform-related details also :)
123 // TargetConstant* - Like Constant*, but the DAG does not do any folding or
124 // simplification of the constant.
128 // TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or
129 // anything else with this node, and this is valid in the target-specific
130 // dag, turning into a GlobalAddress operand.
132 TargetGlobalTLSAddress,
136 TargetExternalSymbol,
138 /// RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...)
139 /// This node represents a target intrinsic function with no side effects.
140 /// The first operand is the ID number of the intrinsic from the
141 /// llvm::Intrinsic namespace. The operands to the intrinsic follow. The
142 /// node has returns the result of the intrinsic.
145 /// RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...)
146 /// This node represents a target intrinsic function with side effects that
147 /// returns a result. The first operand is a chain pointer. The second is
148 /// the ID number of the intrinsic from the llvm::Intrinsic namespace. The
149 /// operands to the intrinsic follow. The node has two results, the result
150 /// of the intrinsic and an output chain.
153 /// OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...)
154 /// This node represents a target intrinsic function with side effects that
155 /// does not return a result. The first operand is a chain pointer. The
156 /// second is the ID number of the intrinsic from the llvm::Intrinsic
157 /// namespace. The operands to the intrinsic follow.
160 // CopyToReg - This node has three operands: a chain, a register number to
161 // set to this value, and a value.
164 // CopyFromReg - This node indicates that the input value is a virtual or
165 // physical register that is defined outside of the scope of this
166 // SelectionDAG. The register is available from the RegisterSDNode object.
169 // UNDEF - An undefined node
172 /// FORMAL_ARGUMENTS(CHAIN, CC#, ISVARARG, FLAG0, ..., FLAGn) - This node
173 /// represents the formal arguments for a function. CC# is a Constant value
174 /// indicating the calling convention of the function, and ISVARARG is a
175 /// flag that indicates whether the function is varargs or not. This node
176 /// has one result value for each incoming argument, plus one for the output
177 /// chain. It must be custom legalized. See description of CALL node for
178 /// FLAG argument contents explanation.
182 /// RV1, RV2...RVn, CHAIN = CALL(CHAIN, CALLEE,
183 /// ARG0, FLAG0, ARG1, FLAG1, ... ARGn, FLAGn)
184 /// This node represents a fully general function call, before the legalizer
185 /// runs. This has one result value for each argument / flag pair, plus
186 /// a chain result. It must be custom legalized. Flag argument indicates
187 /// misc. argument attributes. Currently:
189 /// Bit 1 - 'inreg' attribute
190 /// Bit 2 - 'sret' attribute
191 /// Bit 4 - 'byval' attribute
192 /// Bit 5 - 'nest' attribute
193 /// Bit 6-9 - alignment of byval structures
194 /// Bit 10-26 - size of byval structures
195 /// Bits 31:27 - argument ABI alignment in the first argument piece and
196 /// alignment '1' in other argument pieces.
198 /// CALL nodes use the CallSDNode subclass of SDNode, which
199 /// additionally carries information about the calling convention,
200 /// whether the call is varargs, and if it's marked as a tail call.
204 // EXTRACT_ELEMENT - This is used to get the lower or upper (determined by
205 // a Constant, which is required to be operand #1) half of the integer or
206 // float value specified as operand #0. This is only for use before
207 // legalization, for values that will be broken into multiple registers.
210 // BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways. Given
211 // two values of the same integer value type, this produces a value twice as
212 // big. Like EXTRACT_ELEMENT, this can only be used before legalization.
215 // MERGE_VALUES - This node takes multiple discrete operands and returns
216 // them all as its individual results. This nodes has exactly the same
217 // number of inputs and outputs, and is only valid before legalization.
218 // This node is useful for some pieces of the code generator that want to
219 // think about a single node with multiple results, not multiple nodes.
222 // Simple integer binary arithmetic operators.
223 ADD, SUB, MUL, SDIV, UDIV, SREM, UREM,
225 // SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing
226 // a signed/unsigned value of type i[2*N], and return the full value as
227 // two results, each of type iN.
228 SMUL_LOHI, UMUL_LOHI,
230 // SDIVREM/UDIVREM - Divide two integers and produce both a quotient and
234 // CARRY_FALSE - This node is used when folding other nodes,
235 // like ADDC/SUBC, which indicate the carry result is always false.
238 // Carry-setting nodes for multiple precision addition and subtraction.
239 // These nodes take two operands of the same value type, and produce two
240 // results. The first result is the normal add or sub result, the second
241 // result is the carry flag result.
244 // Carry-using nodes for multiple precision addition and subtraction. These
245 // nodes take three operands: The first two are the normal lhs and rhs to
246 // the add or sub, and the third is the input carry flag. These nodes
247 // produce two results; the normal result of the add or sub, and the output
248 // carry flag. These nodes both read and write a carry flag to allow them
249 // to them to be chained together for add and sub of arbitrarily large
253 // RESULT, BOOL = [SU]ADDO(LHS, RHS) - Overflow-aware nodes for addition.
254 // These nodes take two operands: the normal LHS and RHS to the add. They
255 // produce two results: the normal result of the add, and a boolean that
256 // indicates if an overflow occured (*not* a flag, because it may be stored
257 // to memory, etc.). If the type of the boolean is not i1 then the high
258 // bits conform to getBooleanContents.
259 // These nodes are generated from the llvm.[su]add.with.overflow intrinsics.
262 // Same for subtraction
265 // Same for multiplication
268 // Simple binary floating point operators.
269 FADD, FSUB, FMUL, FDIV, FREM,
271 // FCOPYSIGN(X, Y) - Return the value of X with the sign of Y. NOTE: This
272 // DAG node does not require that X and Y have the same type, just that they
273 // are both floating point. X and the result must have the same type.
274 // FCOPYSIGN(f32, f64) is allowed.
277 // INT = FGETSIGN(FP) - Return the sign bit of the specified floating point
278 // value as an integer 0/1 value.
281 /// BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a vector
282 /// with the specified, possibly variable, elements. The number of elements
283 /// is required to be a power of two.
286 /// INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element
287 /// at IDX replaced with VAL. If the type of VAL is larger than the vector
288 /// element type then VAL is truncated before replacement.
291 /// EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR
292 /// identified by the (potentially variable) element number IDX.
295 /// CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of
296 /// vector type with the same length and element type, this produces a
297 /// concatenated vector result value, with length equal to the sum of the
298 /// lengths of the input vectors.
301 /// EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR (an
302 /// vector value) starting with the (potentially variable) element number
303 /// IDX, which must be a multiple of the result vector length.
306 /// VECTOR_SHUFFLE(VEC1, VEC2, SHUFFLEVEC) - Returns a vector, of the same
307 /// type as VEC1/VEC2. SHUFFLEVEC is a BUILD_VECTOR of constant int values
308 /// (maybe of an illegal datatype) or undef that indicate which value each
309 /// result element will get. The elements of VEC1/VEC2 are enumerated in
310 /// order. This is quite similar to the Altivec 'vperm' instruction, except
311 /// that the indices must be constants and are in terms of the element size
312 /// of VEC1/VEC2, not in terms of bytes.
315 /// SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a
316 /// scalar value into element 0 of the resultant vector type. The top
317 /// elements 1 to N-1 of the N-element vector are undefined.
320 // EXTRACT_SUBREG - This node is used to extract a sub-register value.
321 // This node takes a superreg and a constant sub-register index as operands.
322 // Note sub-register indices must be increasing. That is, if the
323 // sub-register index of a 8-bit sub-register is N, then the index for a
324 // 16-bit sub-register must be at least N+1.
327 // INSERT_SUBREG - This node is used to insert a sub-register value.
328 // This node takes a superreg, a subreg value, and a constant sub-register
329 // index as operands.
332 // MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing
333 // an unsigned/signed value of type i[2*N], then return the top part.
336 // Bitwise operators - logical and, logical or, logical xor, shift left,
337 // shift right algebraic (shift in sign bits), shift right logical (shift in
338 // zeroes), rotate left, rotate right, and byteswap.
339 AND, OR, XOR, SHL, SRA, SRL, ROTL, ROTR, BSWAP,
341 // Counting operators
344 // Select(COND, TRUEVAL, FALSEVAL). If the type of the boolean COND is not
345 // i1 then the high bits must conform to getBooleanContents.
348 // Select with condition operator - This selects between a true value and
349 // a false value (ops #2 and #3) based on the boolean result of comparing
350 // the lhs and rhs (ops #0 and #1) of a conditional expression with the
351 // condition code in op #4, a CondCodeSDNode.
354 // SetCC operator - This evaluates to a true value iff the condition is
355 // true. If the result value type is not i1 then the high bits conform
356 // to getBooleanContents. The operands to this are the left and right
357 // operands to compare (ops #0, and #1) and the condition code to compare
358 // them with (op #2) as a CondCodeSDNode.
361 // Vector SetCC operator - This evaluates to a vector of integer elements
362 // with the high bit in each element set to true if the comparison is true
363 // and false if the comparison is false. All other bits in each element
364 // are undefined. The operands to this are the left and right operands
365 // to compare (ops #0, and #1) and the condition code to compare them with
366 // (op #2) as a CondCodeSDNode.
369 // SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded
370 // integer shift operations, just like ADD/SUB_PARTS. The operation
372 // [Lo,Hi] = op [LoLHS,HiLHS], Amt
373 SHL_PARTS, SRA_PARTS, SRL_PARTS,
375 // Conversion operators. These are all single input single output
376 // operations. For all of these, the result type must be strictly
377 // wider or narrower (depending on the operation) than the source
380 // SIGN_EXTEND - Used for integer types, replicating the sign bit
384 // ZERO_EXTEND - Used for integer types, zeroing the new bits.
387 // ANY_EXTEND - Used for integer types. The high bits are undefined.
390 // TRUNCATE - Completely drop the high bits.
393 // [SU]INT_TO_FP - These operators convert integers (whose interpreted sign
394 // depends on the first letter) to floating point.
398 // SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to
399 // sign extend a small value in a large integer register (e.g. sign
400 // extending the low 8 bits of a 32-bit register to fill the top 24 bits
401 // with the 7th bit). The size of the smaller type is indicated by the 1th
402 // operand, a ValueType node.
405 /// FP_TO_[US]INT - Convert a floating point value to a signed or unsigned
410 /// X = FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type
411 /// down to the precision of the destination VT. TRUNC is a flag, which is
412 /// always an integer that is zero or one. If TRUNC is 0, this is a
413 /// normal rounding, if it is 1, this FP_ROUND is known to not change the
416 /// The TRUNC = 1 case is used in cases where we know that the value will
417 /// not be modified by the node, because Y is not using any of the extra
418 /// precision of source type. This allows certain transformations like
419 /// FP_EXTEND(FP_ROUND(X,1)) -> X which are not safe for
420 /// FP_EXTEND(FP_ROUND(X,0)) because the extra bits aren't removed.
423 // FLT_ROUNDS_ - Returns current rounding mode:
426 // 1 Round to nearest
431 /// X = FP_ROUND_INREG(Y, VT) - This operator takes an FP register, and
432 /// rounds it to a floating point value. It then promotes it and returns it
433 /// in a register of the same size. This operation effectively just
434 /// discards excess precision. The type to round down to is specified by
435 /// the VT operand, a VTSDNode.
438 /// X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
441 // BIT_CONVERT - Theis operator converts between integer and FP values, as
442 // if one was stored to memory as integer and the other was loaded from the
443 // same address (or equivalently for vector format conversions, etc). The
444 // source and result are required to have the same bit size (e.g.
445 // f32 <-> i32). This can also be used for int-to-int or fp-to-fp
446 // conversions, but that is a noop, deleted by getNode().
449 // CONVERT_RNDSAT - This operator is used to support various conversions
450 // between various types (float, signed, unsigned and vectors of those
451 // types) with rounding and saturation. NOTE: Avoid using this operator as
452 // most target don't support it and the operator might be removed in the
453 // future. It takes the following arguments:
455 // 1) dest type (type to convert to)
456 // 2) src type (type to convert from)
459 // 5) ISD::CvtCode indicating the type of conversion to do
462 // FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, FPOW,
463 // FLOG, FLOG2, FLOG10, FEXP, FEXP2,
464 // FCEIL, FTRUNC, FRINT, FNEARBYINT, FFLOOR - Perform various unary floating
465 // point operations. These are inspired by libm.
466 FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, FPOW,
467 FLOG, FLOG2, FLOG10, FEXP, FEXP2,
468 FCEIL, FTRUNC, FRINT, FNEARBYINT, FFLOOR,
470 // LOAD and STORE have token chains as their first operand, then the same
471 // operands as an LLVM load/store instruction, then an offset node that
472 // is added / subtracted from the base pointer to form the address (for
473 // indexed memory ops).
476 // DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned
477 // to a specified boundary. This node always has two return values: a new
478 // stack pointer value and a chain. The first operand is the token chain,
479 // the second is the number of bytes to allocate, and the third is the
480 // alignment boundary. The size is guaranteed to be a multiple of the stack
481 // alignment, and the alignment is guaranteed to be bigger than the stack
482 // alignment (if required) or 0 to get standard stack alignment.
485 // Control flow instructions. These all have token chains.
487 // BR - Unconditional branch. The first operand is the chain
488 // operand, the second is the MBB to branch to.
491 // BRIND - Indirect branch. The first operand is the chain, the second
492 // is the value to branch to, which must be of the same type as the target's
496 // BR_JT - Jumptable branch. The first operand is the chain, the second
497 // is the jumptable index, the last one is the jumptable entry index.
500 // BRCOND - Conditional branch. The first operand is the chain, the
501 // second is the condition, the third is the block to branch to if the
502 // condition is true. If the type of the condition is not i1, then the
503 // high bits must conform to getBooleanContents.
506 // BR_CC - Conditional branch. The behavior is like that of SELECT_CC, in
507 // that the condition is represented as condition code, and two nodes to
508 // compare, rather than as a combined SetCC node. The operands in order are
509 // chain, cc, lhs, rhs, block to branch to if condition is true.
512 // RET - Return from function. The first operand is the chain,
513 // and any subsequent operands are pairs of return value and return value
514 // attributes (see CALL for description of attributes) for the function.
515 // This operation can have variable number of operands.
518 // INLINEASM - Represents an inline asm block. This node always has two
519 // return values: a chain and a flag result. The inputs are as follows:
520 // Operand #0 : Input chain.
521 // Operand #1 : a ExternalSymbolSDNode with a pointer to the asm string.
522 // Operand #2n+2: A RegisterNode.
523 // Operand #2n+3: A TargetConstant, indicating if the reg is a use/def
524 // Operand #last: Optional, an incoming flag.
527 // DBG_LABEL, EH_LABEL - Represents a label in mid basic block used to track
528 // locations needed for debug and exception handling tables. These nodes
529 // take a chain as input and return a chain.
533 // DECLARE - Represents a llvm.dbg.declare intrinsic. It's used to track
534 // local variable declarations for debugging information. First operand is
535 // a chain, while the next two operands are first two arguments (address
536 // and variable) of a llvm.dbg.declare instruction.
539 // STACKSAVE - STACKSAVE has one operand, an input chain. It produces a
540 // value, the same type as the pointer type for the system, and an output
544 // STACKRESTORE has two operands, an input chain and a pointer to restore to
545 // it returns an output chain.
548 // CALLSEQ_START/CALLSEQ_END - These operators mark the beginning and end of
549 // a call sequence, and carry arbitrary information that target might want
550 // to know. The first operand is a chain, the rest are specified by the
551 // target and not touched by the DAG optimizers.
552 // CALLSEQ_START..CALLSEQ_END pairs may not be nested.
553 CALLSEQ_START, // Beginning of a call sequence
554 CALLSEQ_END, // End of a call sequence
556 // VAARG - VAARG has three operands: an input chain, a pointer, and a
557 // SRCVALUE. It returns a pair of values: the vaarg value and a new chain.
560 // VACOPY - VACOPY has five operands: an input chain, a destination pointer,
561 // a source pointer, a SRCVALUE for the destination, and a SRCVALUE for the
565 // VAEND, VASTART - VAEND and VASTART have three operands: an input chain, a
566 // pointer, and a SRCVALUE.
569 // SRCVALUE - This is a node type that holds a Value* that is used to
570 // make reference to a value in the LLVM IR.
573 // MEMOPERAND - This is a node that contains a MachineMemOperand which
574 // records information about a memory reference. This is used to make
575 // AliasAnalysis queries from the backend.
578 // PCMARKER - This corresponds to the pcmarker intrinsic.
581 // READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic.
582 // The only operand is a chain and a value and a chain are produced. The
583 // value is the contents of the architecture specific cycle counter like
584 // register (or other high accuracy low latency clock source)
587 // HANDLENODE node - Used as a handle for various purposes.
590 // DBG_STOPPOINT - This node is used to represent a source location for
591 // debug info. It takes token chain as input, and carries a line number,
592 // column number, and a pointer to a CompileUnitDesc object identifying
593 // the containing compilation unit. It produces a token chain as output.
596 // DEBUG_LOC - This node is used to represent source line information
597 // embedded in the code. It takes a token chain as input, then a line
598 // number, then a column then a file id (provided by MachineModuleInfo.) It
599 // produces a token chain as output.
602 // TRAMPOLINE - This corresponds to the init_trampoline intrinsic.
603 // It takes as input a token chain, the pointer to the trampoline,
604 // the pointer to the nested function, the pointer to pass for the
605 // 'nest' parameter, a SRCVALUE for the trampoline and another for
606 // the nested function (allowing targets to access the original
607 // Function*). It produces the result of the intrinsic and a token
611 // TRAP - Trapping instruction
614 // PREFETCH - This corresponds to a prefetch intrinsic. It takes chains are
615 // their first operand. The other operands are the address to prefetch,
616 // read / write specifier, and locality specifier.
619 // OUTCHAIN = MEMBARRIER(INCHAIN, load-load, load-store, store-load,
620 // store-store, device)
621 // This corresponds to the memory.barrier intrinsic.
622 // it takes an input chain, 4 operands to specify the type of barrier, an
623 // operand specifying if the barrier applies to device and uncached memory
624 // and produces an output chain.
627 // Val, OUTCHAIN = ATOMIC_CMP_SWAP(INCHAIN, ptr, cmp, swap)
628 // this corresponds to the atomic.lcs intrinsic.
629 // cmp is compared to *ptr, and if equal, swap is stored in *ptr.
630 // the return is always the original value in *ptr
636 // Val, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amt)
637 // this corresponds to the atomic.swap intrinsic.
638 // amt is stored to *ptr atomically.
639 // the return is always the original value in *ptr
645 // Val, OUTCHAIN = ATOMIC_L[OpName]S(INCHAIN, ptr, amt)
646 // this corresponds to the atomic.[OpName] intrinsic.
647 // op(*ptr, amt) is stored to *ptr atomically.
648 // the return is always the original value in *ptr
690 // BUILTIN_OP_END - This must be the last enum value in this list.
696 /// isBuildVectorAllOnes - Return true if the specified node is a
697 /// BUILD_VECTOR where all of the elements are ~0 or undef.
698 bool isBuildVectorAllOnes(const SDNode *N);
700 /// isBuildVectorAllZeros - Return true if the specified node is a
701 /// BUILD_VECTOR where all of the elements are 0 or undef.
702 bool isBuildVectorAllZeros(const SDNode *N);
704 /// isScalarToVector - Return true if the specified node is a
705 /// ISD::SCALAR_TO_VECTOR node or a BUILD_VECTOR node where only the low
706 /// element is not an undef.
707 bool isScalarToVector(const SDNode *N);
709 /// isDebugLabel - Return true if the specified node represents a debug
710 /// label (i.e. ISD::DBG_LABEL or TargetInstrInfo::DBG_LABEL node).
711 bool isDebugLabel(const SDNode *N);
713 //===--------------------------------------------------------------------===//
714 /// MemIndexedMode enum - This enum defines the load / store indexed
715 /// addressing modes.
717 /// UNINDEXED "Normal" load / store. The effective address is already
718 /// computed and is available in the base pointer. The offset
719 /// operand is always undefined. In addition to producing a
720 /// chain, an unindexed load produces one value (result of the
721 /// load); an unindexed store does not produce a value.
723 /// PRE_INC Similar to the unindexed mode where the effective address is
724 /// PRE_DEC the value of the base pointer add / subtract the offset.
725 /// It considers the computation as being folded into the load /
726 /// store operation (i.e. the load / store does the address
727 /// computation as well as performing the memory transaction).
728 /// The base operand is always undefined. In addition to
729 /// producing a chain, pre-indexed load produces two values
730 /// (result of the load and the result of the address
731 /// computation); a pre-indexed store produces one value (result
732 /// of the address computation).
734 /// POST_INC The effective address is the value of the base pointer. The
735 /// POST_DEC value of the offset operand is then added to / subtracted
736 /// from the base after memory transaction. In addition to
737 /// producing a chain, post-indexed load produces two values
738 /// (the result of the load and the result of the base +/- offset
739 /// computation); a post-indexed store produces one value (the
740 /// the result of the base +/- offset computation).
742 enum MemIndexedMode {
751 //===--------------------------------------------------------------------===//
752 /// LoadExtType enum - This enum defines the three variants of LOADEXT
753 /// (load with extension).
755 /// SEXTLOAD loads the integer operand and sign extends it to a larger
756 /// integer result type.
757 /// ZEXTLOAD loads the integer operand and zero extends it to a larger
758 /// integer result type.
759 /// EXTLOAD is used for three things: floating point extending loads,
760 /// integer extending loads [the top bits are undefined], and vector
761 /// extending loads [load into low elt].
771 //===--------------------------------------------------------------------===//
772 /// ISD::CondCode enum - These are ordered carefully to make the bitfields
773 /// below work out, when considering SETFALSE (something that never exists
774 /// dynamically) as 0. "U" -> Unsigned (for integer operands) or Unordered
775 /// (for floating point), "L" -> Less than, "G" -> Greater than, "E" -> Equal
776 /// to. If the "N" column is 1, the result of the comparison is undefined if
777 /// the input is a NAN.
779 /// All of these (except for the 'always folded ops') should be handled for
780 /// floating point. For integer, only the SETEQ,SETNE,SETLT,SETLE,SETGT,
781 /// SETGE,SETULT,SETULE,SETUGT, and SETUGE opcodes are used.
783 /// Note that these are laid out in a specific order to allow bit-twiddling
784 /// to transform conditions.
786 // Opcode N U L G E Intuitive operation
787 SETFALSE, // 0 0 0 0 Always false (always folded)
788 SETOEQ, // 0 0 0 1 True if ordered and equal
789 SETOGT, // 0 0 1 0 True if ordered and greater than
790 SETOGE, // 0 0 1 1 True if ordered and greater than or equal
791 SETOLT, // 0 1 0 0 True if ordered and less than
792 SETOLE, // 0 1 0 1 True if ordered and less than or equal
793 SETONE, // 0 1 1 0 True if ordered and operands are unequal
794 SETO, // 0 1 1 1 True if ordered (no nans)
795 SETUO, // 1 0 0 0 True if unordered: isnan(X) | isnan(Y)
796 SETUEQ, // 1 0 0 1 True if unordered or equal
797 SETUGT, // 1 0 1 0 True if unordered or greater than
798 SETUGE, // 1 0 1 1 True if unordered, greater than, or equal
799 SETULT, // 1 1 0 0 True if unordered or less than
800 SETULE, // 1 1 0 1 True if unordered, less than, or equal
801 SETUNE, // 1 1 1 0 True if unordered or not equal
802 SETTRUE, // 1 1 1 1 Always true (always folded)
803 // Don't care operations: undefined if the input is a nan.
804 SETFALSE2, // 1 X 0 0 0 Always false (always folded)
805 SETEQ, // 1 X 0 0 1 True if equal
806 SETGT, // 1 X 0 1 0 True if greater than
807 SETGE, // 1 X 0 1 1 True if greater than or equal
808 SETLT, // 1 X 1 0 0 True if less than
809 SETLE, // 1 X 1 0 1 True if less than or equal
810 SETNE, // 1 X 1 1 0 True if not equal
811 SETTRUE2, // 1 X 1 1 1 Always true (always folded)
813 SETCC_INVALID // Marker value.
816 /// isSignedIntSetCC - Return true if this is a setcc instruction that
817 /// performs a signed comparison when used with integer operands.
818 inline bool isSignedIntSetCC(CondCode Code) {
819 return Code == SETGT || Code == SETGE || Code == SETLT || Code == SETLE;
822 /// isUnsignedIntSetCC - Return true if this is a setcc instruction that
823 /// performs an unsigned comparison when used with integer operands.
824 inline bool isUnsignedIntSetCC(CondCode Code) {
825 return Code == SETUGT || Code == SETUGE || Code == SETULT || Code == SETULE;
828 /// isTrueWhenEqual - Return true if the specified condition returns true if
829 /// the two operands to the condition are equal. Note that if one of the two
830 /// operands is a NaN, this value is meaningless.
831 inline bool isTrueWhenEqual(CondCode Cond) {
832 return ((int)Cond & 1) != 0;
835 /// getUnorderedFlavor - This function returns 0 if the condition is always
836 /// false if an operand is a NaN, 1 if the condition is always true if the
837 /// operand is a NaN, and 2 if the condition is undefined if the operand is a
839 inline unsigned getUnorderedFlavor(CondCode Cond) {
840 return ((int)Cond >> 3) & 3;
843 /// getSetCCInverse - Return the operation corresponding to !(X op Y), where
844 /// 'op' is a valid SetCC operation.
845 CondCode getSetCCInverse(CondCode Operation, bool isInteger);
847 /// getSetCCSwappedOperands - Return the operation corresponding to (Y op X)
848 /// when given the operation for (X op Y).
849 CondCode getSetCCSwappedOperands(CondCode Operation);
851 /// getSetCCOrOperation - Return the result of a logical OR between different
852 /// comparisons of identical values: ((X op1 Y) | (X op2 Y)). This
853 /// function returns SETCC_INVALID if it is not possible to represent the
854 /// resultant comparison.
855 CondCode getSetCCOrOperation(CondCode Op1, CondCode Op2, bool isInteger);
857 /// getSetCCAndOperation - Return the result of a logical AND between
858 /// different comparisons of identical values: ((X op1 Y) & (X op2 Y)). This
859 /// function returns SETCC_INVALID if it is not possible to represent the
860 /// resultant comparison.
861 CondCode getSetCCAndOperation(CondCode Op1, CondCode Op2, bool isInteger);
863 //===--------------------------------------------------------------------===//
864 /// CvtCode enum - This enum defines the various converts CONVERT_RNDSAT
867 CVT_FF, // Float from Float
868 CVT_FS, // Float from Signed
869 CVT_FU, // Float from Unsigned
870 CVT_SF, // Signed from Float
871 CVT_UF, // Unsigned from Float
872 CVT_SS, // Signed from Signed
873 CVT_SU, // Signed from Unsigned
874 CVT_US, // Unsigned from Signed
875 CVT_UU, // Unsigned from Unsigned
876 CVT_INVALID // Marker - Invalid opcode
878 } // end llvm::ISD namespace
881 //===----------------------------------------------------------------------===//
882 /// SDValue - Unlike LLVM values, Selection DAG nodes may return multiple
883 /// values as the result of a computation. Many nodes return multiple values,
884 /// from loads (which define a token and a return value) to ADDC (which returns
885 /// a result and a carry value), to calls (which may return an arbitrary number
888 /// As such, each use of a SelectionDAG computation must indicate the node that
889 /// computes it as well as which return value to use from that node. This pair
890 /// of information is represented with the SDValue value type.
893 SDNode *Node; // The node defining the value we are using.
894 unsigned ResNo; // Which return value of the node we are using.
896 SDValue() : Node(0), ResNo(0) {}
897 SDValue(SDNode *node, unsigned resno) : Node(node), ResNo(resno) {}
899 /// get the index which selects a specific result in the SDNode
900 unsigned getResNo() const { return ResNo; }
902 /// get the SDNode which holds the desired result
903 SDNode *getNode() const { return Node; }
906 void setNode(SDNode *N) { Node = N; }
908 bool operator==(const SDValue &O) const {
909 return Node == O.Node && ResNo == O.ResNo;
911 bool operator!=(const SDValue &O) const {
912 return !operator==(O);
914 bool operator<(const SDValue &O) const {
915 return Node < O.Node || (Node == O.Node && ResNo < O.ResNo);
918 SDValue getValue(unsigned R) const {
919 return SDValue(Node, R);
922 // isOperandOf - Return true if this node is an operand of N.
923 bool isOperandOf(SDNode *N) const;
925 /// getValueType - Return the ValueType of the referenced return value.
927 inline MVT getValueType() const;
929 /// getValueSizeInBits - Returns the size of the value in bits.
931 unsigned getValueSizeInBits() const {
932 return getValueType().getSizeInBits();
935 // Forwarding methods - These forward to the corresponding methods in SDNode.
936 inline unsigned getOpcode() const;
937 inline unsigned getNumOperands() const;
938 inline const SDValue &getOperand(unsigned i) const;
939 inline uint64_t getConstantOperandVal(unsigned i) const;
940 inline bool isTargetOpcode() const;
941 inline bool isMachineOpcode() const;
942 inline unsigned getMachineOpcode() const;
945 /// reachesChainWithoutSideEffects - Return true if this operand (which must
946 /// be a chain) reaches the specified operand without crossing any
947 /// side-effecting instructions. In practice, this looks through token
948 /// factors and non-volatile loads. In order to remain efficient, this only
949 /// looks a couple of nodes in, it does not do an exhaustive search.
950 bool reachesChainWithoutSideEffects(SDValue Dest,
951 unsigned Depth = 2) const;
953 /// use_empty - Return true if there are no nodes using value ResNo
956 inline bool use_empty() const;
958 /// hasOneUse - Return true if there is exactly one node using value
961 inline bool hasOneUse() const;
965 template<> struct DenseMapInfo<SDValue> {
966 static inline SDValue getEmptyKey() {
967 return SDValue((SDNode*)-1, -1U);
969 static inline SDValue getTombstoneKey() {
970 return SDValue((SDNode*)-1, 0);
972 static unsigned getHashValue(const SDValue &Val) {
973 return ((unsigned)((uintptr_t)Val.getNode() >> 4) ^
974 (unsigned)((uintptr_t)Val.getNode() >> 9)) + Val.getResNo();
976 static bool isEqual(const SDValue &LHS, const SDValue &RHS) {
979 static bool isPod() { return true; }
982 /// simplify_type specializations - Allow casting operators to work directly on
983 /// SDValues as if they were SDNode*'s.
984 template<> struct simplify_type<SDValue> {
985 typedef SDNode* SimpleType;
986 static SimpleType getSimplifiedValue(const SDValue &Val) {
987 return static_cast<SimpleType>(Val.getNode());
990 template<> struct simplify_type<const SDValue> {
991 typedef SDNode* SimpleType;
992 static SimpleType getSimplifiedValue(const SDValue &Val) {
993 return static_cast<SimpleType>(Val.getNode());
997 /// SDUse - Represents a use of the SDNode referred by
1001 /// User - Parent node of this operand.
1003 /// Prev, next - Pointers to the uses list of the SDNode referred by
1005 SDUse **Prev, *Next;
1007 friend class SDNode;
1008 SDUse(): Operand(), User(NULL), Prev(NULL), Next(NULL) {}
1010 SDUse(SDNode *val, unsigned resno) :
1011 Operand(val,resno), User(NULL), Prev(NULL), Next(NULL) {}
1013 SDUse& operator= (const SDValue& Op) {
1020 SDUse& operator= (const SDUse& Op) {
1027 SDUse *getNext() { return Next; }
1029 SDNode *getUser() { return User; }
1031 void setUser(SDNode *p) { User = p; }
1033 operator SDValue() const { return Operand; }
1035 const SDValue& getSDValue() const { return Operand; }
1037 SDValue &getSDValue() { return Operand; }
1038 SDNode *getVal() { return Operand.getNode(); }
1039 SDNode *getVal() const { return Operand.getNode(); } // FIXME: const correct?
1041 bool operator==(const SDValue &O) const {
1042 return Operand == O;
1045 bool operator!=(const SDValue &O) const {
1046 return !(Operand == O);
1049 bool operator<(const SDValue &O) const {
1054 void addToList(SDUse **List) {
1056 if (Next) Next->Prev = &Next;
1061 void removeFromList() {
1063 if (Next) Next->Prev = Prev;
1068 /// simplify_type specializations - Allow casting operators to work directly on
1069 /// SDValues as if they were SDNode*'s.
1070 template<> struct simplify_type<SDUse> {
1071 typedef SDNode* SimpleType;
1072 static SimpleType getSimplifiedValue(const SDUse &Val) {
1073 return static_cast<SimpleType>(Val.getVal());
1076 template<> struct simplify_type<const SDUse> {
1077 typedef SDNode* SimpleType;
1078 static SimpleType getSimplifiedValue(const SDUse &Val) {
1079 return static_cast<SimpleType>(Val.getVal());
1084 /// SDOperandPtr - A helper SDValue pointer class, that can handle
1085 /// arrays of SDUse and arrays of SDValue objects. This is required
1086 /// in many places inside the SelectionDAG.
1088 class SDOperandPtr {
1089 const SDValue *ptr; // The pointer to the SDValue object
1090 int object_size; // The size of the object containg the SDValue
1092 SDOperandPtr() : ptr(0), object_size(0) {}
1094 SDOperandPtr(SDUse * use_ptr) {
1095 ptr = &use_ptr->getSDValue();
1096 object_size = (int)sizeof(SDUse);
1099 SDOperandPtr(const SDValue * op_ptr) {
1101 object_size = (int)sizeof(SDValue);
1104 const SDValue operator *() { return *ptr; }
1105 const SDValue *operator ->() { return ptr; }
1106 SDOperandPtr operator ++ () {
1107 ptr = (SDValue*)((char *)ptr + object_size);
1111 SDOperandPtr operator ++ (int) {
1112 SDOperandPtr tmp = *this;
1113 ptr = (SDValue*)((char *)ptr + object_size);
1117 SDValue operator[] (int idx) const {
1118 return *(SDValue*)((char*) ptr + object_size * idx);
1122 /// SDNode - Represents one node in the SelectionDAG.
1124 class SDNode : public FoldingSetNode, public ilist_node<SDNode> {
1126 /// NodeType - The operation that this node performs.
1130 /// OperandsNeedDelete - This is true if OperandList was new[]'d. If true,
1131 /// then they will be delete[]'d when the node is destroyed.
1132 unsigned short OperandsNeedDelete : 1;
1135 /// SubclassData - This member is defined by this class, but is not used for
1136 /// anything. Subclasses can use it to hold whatever state they find useful.
1137 /// This field is initialized to zero by the ctor.
1138 unsigned short SubclassData : 15;
1141 /// NodeId - Unique id per SDNode in the DAG.
1144 /// OperandList - The values that are used by this operation.
1148 /// ValueList - The types of the values this node defines. SDNode's may
1149 /// define multiple values simultaneously.
1150 const MVT *ValueList;
1152 /// NumOperands/NumValues - The number of entries in the Operand/Value list.
1153 unsigned short NumOperands, NumValues;
1155 /// Uses - List of uses for this SDNode.
1158 /// addUse - add SDUse to the list of uses.
1159 void addUse(SDUse &U) { U.addToList(&Uses); }
1161 // Out-of-line virtual method to give class a home.
1162 virtual void ANCHOR();
1165 assert(NumOperands == 0 && "Operand list not cleared before deletion");
1166 NodeType = ISD::DELETED_NODE;
1169 //===--------------------------------------------------------------------===//
1173 /// getOpcode - Return the SelectionDAG opcode value for this node. For
1174 /// pre-isel nodes (those for which isMachineOpcode returns false), these
1175 /// are the opcode values in the ISD and <target>ISD namespaces. For
1176 /// post-isel opcodes, see getMachineOpcode.
1177 unsigned getOpcode() const { return (unsigned short)NodeType; }
1179 /// isTargetOpcode - Test if this node has a target-specific opcode (in the
1180 /// <target>ISD namespace).
1181 bool isTargetOpcode() const { return NodeType >= ISD::BUILTIN_OP_END; }
1183 /// isMachineOpcode - Test if this node has a post-isel opcode, directly
1184 /// corresponding to a MachineInstr opcode.
1185 bool isMachineOpcode() const { return NodeType < 0; }
1187 /// getMachineOpcode - This may only be called if isMachineOpcode returns
1188 /// true. It returns the MachineInstr opcode value that the node's opcode
1190 unsigned getMachineOpcode() const {
1191 assert(isMachineOpcode() && "Not a MachineInstr opcode!");
1195 /// use_empty - Return true if there are no uses of this node.
1197 bool use_empty() const { return Uses == NULL; }
1199 /// hasOneUse - Return true if there is exactly one use of this node.
1201 bool hasOneUse() const {
1202 return !use_empty() && next(use_begin()) == use_end();
1205 /// use_size - Return the number of uses of this node. This method takes
1206 /// time proportional to the number of uses.
1208 size_t use_size() const { return std::distance(use_begin(), use_end()); }
1210 /// getNodeId - Return the unique node id.
1212 int getNodeId() const { return NodeId; }
1214 /// setNodeId - Set unique node id.
1215 void setNodeId(int Id) { NodeId = Id; }
1217 /// use_iterator - This class provides iterator support for SDUse
1218 /// operands that use a specific SDNode.
1220 : public forward_iterator<SDUse, ptrdiff_t> {
1222 explicit use_iterator(SDUse *op) : Op(op) {
1224 friend class SDNode;
1226 typedef forward_iterator<SDUse, ptrdiff_t>::reference reference;
1227 typedef forward_iterator<SDUse, ptrdiff_t>::pointer pointer;
1229 use_iterator(const use_iterator &I) : Op(I.Op) {}
1230 use_iterator() : Op(0) {}
1232 bool operator==(const use_iterator &x) const {
1235 bool operator!=(const use_iterator &x) const {
1236 return !operator==(x);
1239 /// atEnd - return true if this iterator is at the end of uses list.
1240 bool atEnd() const { return Op == 0; }
1242 // Iterator traversal: forward iteration only.
1243 use_iterator &operator++() { // Preincrement
1244 assert(Op && "Cannot increment end iterator!");
1249 use_iterator operator++(int) { // Postincrement
1250 use_iterator tmp = *this; ++*this; return tmp;
1253 /// Retrieve a pointer to the current user node.
1254 SDNode *operator*() const {
1255 assert(Op && "Cannot dereference end iterator!");
1256 return Op->getUser();
1259 SDNode *operator->() const { return operator*(); }
1261 SDUse &getUse() const { return *Op; }
1263 /// getOperandNo - Retrieve the operand # of this use in its user.
1265 unsigned getOperandNo() const {
1266 assert(Op && "Cannot dereference end iterator!");
1267 return (unsigned)(Op - Op->getUser()->OperandList);
1271 /// use_begin/use_end - Provide iteration support to walk over all uses
1274 use_iterator use_begin() const {
1275 return use_iterator(Uses);
1278 static use_iterator use_end() { return use_iterator(0); }
1281 /// hasNUsesOfValue - Return true if there are exactly NUSES uses of the
1282 /// indicated value. This method ignores uses of other values defined by this
1284 bool hasNUsesOfValue(unsigned NUses, unsigned Value) const;
1286 /// hasAnyUseOfValue - Return true if there are any use of the indicated
1287 /// value. This method ignores uses of other values defined by this operation.
1288 bool hasAnyUseOfValue(unsigned Value) const;
1290 /// isOnlyUserOf - Return true if this node is the only use of N.
1292 bool isOnlyUserOf(SDNode *N) const;
1294 /// isOperandOf - Return true if this node is an operand of N.
1296 bool isOperandOf(SDNode *N) const;
1298 /// isPredecessorOf - Return true if this node is a predecessor of N. This
1299 /// node is either an operand of N or it can be reached by recursively
1300 /// traversing up the operands.
1301 /// NOTE: this is an expensive method. Use it carefully.
1302 bool isPredecessorOf(SDNode *N) const;
1304 /// getNumOperands - Return the number of values used by this operation.
1306 unsigned getNumOperands() const { return NumOperands; }
1308 /// getConstantOperandVal - Helper method returns the integer value of a
1309 /// ConstantSDNode operand.
1310 uint64_t getConstantOperandVal(unsigned Num) const;
1312 const SDValue &getOperand(unsigned Num) const {
1313 assert(Num < NumOperands && "Invalid child # of SDNode!");
1314 return OperandList[Num].getSDValue();
1317 typedef SDUse* op_iterator;
1318 op_iterator op_begin() const { return OperandList; }
1319 op_iterator op_end() const { return OperandList+NumOperands; }
1322 SDVTList getVTList() const {
1323 SDVTList X = { ValueList, NumValues };
1327 /// getFlaggedNode - If this node has a flag operand, return the node
1328 /// to which the flag operand points. Otherwise return NULL.
1329 SDNode *getFlaggedNode() const {
1330 if (getNumOperands() != 0 &&
1331 getOperand(getNumOperands()-1).getValueType() == MVT::Flag)
1332 return getOperand(getNumOperands()-1).getNode();
1336 /// getNumValues - Return the number of values defined/returned by this
1339 unsigned getNumValues() const { return NumValues; }
1341 /// getValueType - Return the type of a specified result.
1343 MVT getValueType(unsigned ResNo) const {
1344 assert(ResNo < NumValues && "Illegal result number!");
1345 return ValueList[ResNo];
1348 /// getValueSizeInBits - Returns MVT::getSizeInBits(getValueType(ResNo)).
1350 unsigned getValueSizeInBits(unsigned ResNo) const {
1351 return getValueType(ResNo).getSizeInBits();
1354 typedef const MVT* value_iterator;
1355 value_iterator value_begin() const { return ValueList; }
1356 value_iterator value_end() const { return ValueList+NumValues; }
1358 /// getOperationName - Return the opcode of this operation for printing.
1360 std::string getOperationName(const SelectionDAG *G = 0) const;
1361 static const char* getIndexedModeName(ISD::MemIndexedMode AM);
1362 void print(raw_ostream &OS, const SelectionDAG *G = 0) const;
1364 void dump(const SelectionDAG *G) const;
1366 static bool classof(const SDNode *) { return true; }
1368 /// Profile - Gather unique data for the node.
1370 void Profile(FoldingSetNodeID &ID) const;
1373 friend class SelectionDAG;
1374 friend struct ilist_traits<SDNode>;
1376 /// getValueTypeList - Return a pointer to the specified value type.
1378 static const MVT *getValueTypeList(MVT VT);
1379 static SDVTList getSDVTList(MVT VT) {
1380 SDVTList Ret = { getValueTypeList(VT), 1 };
1384 SDNode(unsigned Opc, SDVTList VTs, const SDValue *Ops, unsigned NumOps)
1385 : NodeType(Opc), OperandsNeedDelete(true), SubclassData(0),
1386 NodeId(-1), Uses(NULL) {
1387 NumOperands = NumOps;
1388 OperandList = NumOps ? new SDUse[NumOperands] : 0;
1390 for (unsigned i = 0; i != NumOps; ++i) {
1391 OperandList[i] = Ops[i];
1392 OperandList[i].setUser(this);
1393 Ops[i].getNode()->addUse(OperandList[i]);
1396 ValueList = VTs.VTs;
1397 NumValues = VTs.NumVTs;
1400 SDNode(unsigned Opc, SDVTList VTs, const SDUse *Ops, unsigned NumOps)
1401 : NodeType(Opc), OperandsNeedDelete(true), SubclassData(0),
1402 NodeId(-1), Uses(NULL) {
1403 OperandsNeedDelete = true;
1404 NumOperands = NumOps;
1405 OperandList = NumOps ? new SDUse[NumOperands] : 0;
1407 for (unsigned i = 0; i != NumOps; ++i) {
1408 OperandList[i] = Ops[i];
1409 OperandList[i].setUser(this);
1410 Ops[i].getVal()->addUse(OperandList[i]);
1413 ValueList = VTs.VTs;
1414 NumValues = VTs.NumVTs;
1417 /// This constructor adds no operands itself; operands can be
1418 /// set later with InitOperands.
1419 SDNode(unsigned Opc, SDVTList VTs)
1420 : NodeType(Opc), OperandsNeedDelete(false), SubclassData(0),
1421 NodeId(-1), Uses(NULL) {
1424 ValueList = VTs.VTs;
1425 NumValues = VTs.NumVTs;
1428 /// InitOperands - Initialize the operands list of this node with the
1429 /// specified values, which are part of the node (thus they don't need to be
1430 /// copied in or allocated).
1431 void InitOperands(SDUse *Ops, unsigned NumOps) {
1432 assert(OperandList == 0 && "Operands already set!");
1433 NumOperands = NumOps;
1437 for (unsigned i = 0; i != NumOps; ++i) {
1438 OperandList[i].setUser(this);
1439 Ops[i].getVal()->addUse(OperandList[i]);
1443 /// DropOperands - Release the operands and set this node to have
1445 void DropOperands();
1447 void addUser(unsigned i, SDNode *User) {
1448 assert(User->OperandList[i].getUser() && "Node without parent");
1449 addUse(User->OperandList[i]);
1452 void removeUser(unsigned i, SDNode *User) {
1453 assert(User->OperandList[i].getUser() && "Node without parent");
1454 SDUse &Op = User->OperandList[i];
1455 Op.removeFromList();
1460 // Define inline functions from the SDValue class.
1462 inline unsigned SDValue::getOpcode() const {
1463 return Node->getOpcode();
1465 inline MVT SDValue::getValueType() const {
1466 return Node->getValueType(ResNo);
1468 inline unsigned SDValue::getNumOperands() const {
1469 return Node->getNumOperands();
1471 inline const SDValue &SDValue::getOperand(unsigned i) const {
1472 return Node->getOperand(i);
1474 inline uint64_t SDValue::getConstantOperandVal(unsigned i) const {
1475 return Node->getConstantOperandVal(i);
1477 inline bool SDValue::isTargetOpcode() const {
1478 return Node->isTargetOpcode();
1480 inline bool SDValue::isMachineOpcode() const {
1481 return Node->isMachineOpcode();
1483 inline unsigned SDValue::getMachineOpcode() const {
1484 return Node->getMachineOpcode();
1486 inline bool SDValue::use_empty() const {
1487 return !Node->hasAnyUseOfValue(ResNo);
1489 inline bool SDValue::hasOneUse() const {
1490 return Node->hasNUsesOfValue(1, ResNo);
1493 /// UnarySDNode - This class is used for single-operand SDNodes. This is solely
1494 /// to allow co-allocation of node operands with the node itself.
1495 class UnarySDNode : public SDNode {
1496 virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
1499 UnarySDNode(unsigned Opc, SDVTList VTs, SDValue X)
1500 : SDNode(Opc, VTs) {
1502 InitOperands(&Op, 1);
1506 /// BinarySDNode - This class is used for two-operand SDNodes. This is solely
1507 /// to allow co-allocation of node operands with the node itself.
1508 class BinarySDNode : public SDNode {
1509 virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
1512 BinarySDNode(unsigned Opc, SDVTList VTs, SDValue X, SDValue Y)
1513 : SDNode(Opc, VTs) {
1516 InitOperands(Ops, 2);
1520 /// TernarySDNode - This class is used for three-operand SDNodes. This is solely
1521 /// to allow co-allocation of node operands with the node itself.
1522 class TernarySDNode : public SDNode {
1523 virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
1526 TernarySDNode(unsigned Opc, SDVTList VTs, SDValue X, SDValue Y,
1528 : SDNode(Opc, VTs) {
1532 InitOperands(Ops, 3);
1537 /// HandleSDNode - This class is used to form a handle around another node that
1538 /// is persistant and is updated across invocations of replaceAllUsesWith on its
1539 /// operand. This node should be directly created by end-users and not added to
1540 /// the AllNodes list.
1541 class HandleSDNode : public SDNode {
1542 virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
1545 // FIXME: Remove the "noinline" attribute once <rdar://problem/5852746> is
1548 explicit __attribute__((__noinline__)) HandleSDNode(SDValue X)
1550 explicit HandleSDNode(SDValue X)
1552 : SDNode(ISD::HANDLENODE, getSDVTList(MVT::Other)) {
1554 InitOperands(&Op, 1);
1557 const SDValue &getValue() const { return Op.getSDValue(); }
1560 /// Abstact virtual class for operations for memory operations
1561 class MemSDNode : public SDNode {
1562 virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
1565 // MemoryVT - VT of in-memory value.
1568 //! SrcValue - Memory location for alias analysis.
1569 const Value *SrcValue;
1571 //! SVOffset - Memory location offset. Note that base is defined in MemSDNode
1574 /// Flags - the low bit indicates whether this is a volatile reference;
1575 /// the remainder is a log2 encoding of the alignment in bytes.
1579 MemSDNode(unsigned Opc, SDVTList VTs, MVT MemoryVT,
1580 const Value *srcValue, int SVOff,
1581 unsigned alignment, bool isvolatile);
1583 MemSDNode(unsigned Opc, SDVTList VTs, const SDValue *Ops, unsigned NumOps,
1584 MVT MemoryVT, const Value *srcValue, int SVOff,
1585 unsigned alignment, bool isvolatile);
1587 /// Returns alignment and volatility of the memory access
1588 unsigned getAlignment() const { return (1u << (Flags >> 1)) >> 1; }
1589 bool isVolatile() const { return Flags & 1; }
1591 /// Returns the SrcValue and offset that describes the location of the access
1592 const Value *getSrcValue() const { return SrcValue; }
1593 int getSrcValueOffset() const { return SVOffset; }
1595 /// getMemoryVT - Return the type of the in-memory value.
1596 MVT getMemoryVT() const { return MemoryVT; }
1598 /// getMemOperand - Return a MachineMemOperand object describing the memory
1599 /// reference performed by operation.
1600 MachineMemOperand getMemOperand() const;
1602 const SDValue &getChain() const { return getOperand(0); }
1603 const SDValue &getBasePtr() const {
1604 return getOperand(getOpcode() == ISD::STORE ? 2 : 1);
1607 /// getRawFlags - Represent the flags as a bunch of bits.
1609 unsigned getRawFlags() const { return Flags; }
1611 // Methods to support isa and dyn_cast
1612 static bool classof(const MemSDNode *) { return true; }
1613 static bool classof(const SDNode *N) {
1614 // For some targets, we lower some target intrinsics to a MemIntrinsicNode
1615 // with either an intrinsic or a target opcode.
1616 return N->getOpcode() == ISD::LOAD ||
1617 N->getOpcode() == ISD::STORE ||
1618 N->getOpcode() == ISD::ATOMIC_CMP_SWAP_8 ||
1619 N->getOpcode() == ISD::ATOMIC_SWAP_8 ||
1620 N->getOpcode() == ISD::ATOMIC_LOAD_ADD_8 ||
1621 N->getOpcode() == ISD::ATOMIC_LOAD_SUB_8 ||
1622 N->getOpcode() == ISD::ATOMIC_LOAD_AND_8 ||
1623 N->getOpcode() == ISD::ATOMIC_LOAD_OR_8 ||
1624 N->getOpcode() == ISD::ATOMIC_LOAD_XOR_8 ||
1625 N->getOpcode() == ISD::ATOMIC_LOAD_NAND_8 ||
1626 N->getOpcode() == ISD::ATOMIC_LOAD_MIN_8 ||
1627 N->getOpcode() == ISD::ATOMIC_LOAD_MAX_8 ||
1628 N->getOpcode() == ISD::ATOMIC_LOAD_UMIN_8 ||
1629 N->getOpcode() == ISD::ATOMIC_LOAD_UMAX_8 ||
1631 N->getOpcode() == ISD::ATOMIC_CMP_SWAP_16 ||
1632 N->getOpcode() == ISD::ATOMIC_SWAP_16 ||
1633 N->getOpcode() == ISD::ATOMIC_LOAD_ADD_16 ||
1634 N->getOpcode() == ISD::ATOMIC_LOAD_SUB_16 ||
1635 N->getOpcode() == ISD::ATOMIC_LOAD_AND_16 ||
1636 N->getOpcode() == ISD::ATOMIC_LOAD_OR_16 ||
1637 N->getOpcode() == ISD::ATOMIC_LOAD_XOR_16 ||
1638 N->getOpcode() == ISD::ATOMIC_LOAD_NAND_16 ||
1639 N->getOpcode() == ISD::ATOMIC_LOAD_MIN_16 ||
1640 N->getOpcode() == ISD::ATOMIC_LOAD_MAX_16 ||
1641 N->getOpcode() == ISD::ATOMIC_LOAD_UMIN_16 ||
1642 N->getOpcode() == ISD::ATOMIC_LOAD_UMAX_16 ||
1644 N->getOpcode() == ISD::ATOMIC_CMP_SWAP_32 ||
1645 N->getOpcode() == ISD::ATOMIC_SWAP_32 ||
1646 N->getOpcode() == ISD::ATOMIC_LOAD_ADD_32 ||
1647 N->getOpcode() == ISD::ATOMIC_LOAD_SUB_32 ||
1648 N->getOpcode() == ISD::ATOMIC_LOAD_AND_32 ||
1649 N->getOpcode() == ISD::ATOMIC_LOAD_OR_32 ||
1650 N->getOpcode() == ISD::ATOMIC_LOAD_XOR_32 ||
1651 N->getOpcode() == ISD::ATOMIC_LOAD_NAND_32 ||
1652 N->getOpcode() == ISD::ATOMIC_LOAD_MIN_32 ||
1653 N->getOpcode() == ISD::ATOMIC_LOAD_MAX_32 ||
1654 N->getOpcode() == ISD::ATOMIC_LOAD_UMIN_32 ||
1655 N->getOpcode() == ISD::ATOMIC_LOAD_UMAX_32 ||
1657 N->getOpcode() == ISD::ATOMIC_CMP_SWAP_64 ||
1658 N->getOpcode() == ISD::ATOMIC_SWAP_64 ||
1659 N->getOpcode() == ISD::ATOMIC_LOAD_ADD_64 ||
1660 N->getOpcode() == ISD::ATOMIC_LOAD_SUB_64 ||
1661 N->getOpcode() == ISD::ATOMIC_LOAD_AND_64 ||
1662 N->getOpcode() == ISD::ATOMIC_LOAD_OR_64 ||
1663 N->getOpcode() == ISD::ATOMIC_LOAD_XOR_64 ||
1664 N->getOpcode() == ISD::ATOMIC_LOAD_NAND_64 ||
1665 N->getOpcode() == ISD::ATOMIC_LOAD_MIN_64 ||
1666 N->getOpcode() == ISD::ATOMIC_LOAD_MAX_64 ||
1667 N->getOpcode() == ISD::ATOMIC_LOAD_UMIN_64 ||
1668 N->getOpcode() == ISD::ATOMIC_LOAD_UMAX_64 ||
1670 N->getOpcode() == ISD::INTRINSIC_W_CHAIN ||
1671 N->getOpcode() == ISD::INTRINSIC_VOID ||
1672 N->isTargetOpcode();
1676 /// AtomicSDNode - A SDNode reprenting atomic operations.
1678 class AtomicSDNode : public MemSDNode {
1679 virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
1683 // Opc: opcode for atomic
1684 // VTL: value type list
1685 // Chain: memory chain for operaand
1686 // Ptr: address to update as a SDValue
1687 // Cmp: compare value
1689 // SrcVal: address to update as a Value (used for MemOperand)
1690 // Align: alignment of memory
1691 AtomicSDNode(unsigned Opc, SDVTList VTL, SDValue Chain, SDValue Ptr,
1692 SDValue Cmp, SDValue Swp, const Value* SrcVal,
1694 : MemSDNode(Opc, VTL, Cmp.getValueType(), SrcVal, /*SVOffset=*/0,
1695 Align, /*isVolatile=*/true) {
1700 InitOperands(Ops, 4);
1702 AtomicSDNode(unsigned Opc, SDVTList VTL, SDValue Chain, SDValue Ptr,
1703 SDValue Val, const Value* SrcVal, unsigned Align=0)
1704 : MemSDNode(Opc, VTL, Val.getValueType(), SrcVal, /*SVOffset=*/0,
1705 Align, /*isVolatile=*/true) {
1709 InitOperands(Ops, 3);
1712 const SDValue &getBasePtr() const { return getOperand(1); }
1713 const SDValue &getVal() const { return getOperand(2); }
1715 bool isCompareAndSwap() const {
1716 unsigned Op = getOpcode();
1717 return Op == ISD::ATOMIC_CMP_SWAP_8 ||
1718 Op == ISD::ATOMIC_CMP_SWAP_16 ||
1719 Op == ISD::ATOMIC_CMP_SWAP_32 ||
1720 Op == ISD::ATOMIC_CMP_SWAP_64;
1723 // Methods to support isa and dyn_cast
1724 static bool classof(const AtomicSDNode *) { return true; }
1725 static bool classof(const SDNode *N) {
1726 return N->getOpcode() == ISD::ATOMIC_CMP_SWAP_8 ||
1727 N->getOpcode() == ISD::ATOMIC_SWAP_8 ||
1728 N->getOpcode() == ISD::ATOMIC_LOAD_ADD_8 ||
1729 N->getOpcode() == ISD::ATOMIC_LOAD_SUB_8 ||
1730 N->getOpcode() == ISD::ATOMIC_LOAD_AND_8 ||
1731 N->getOpcode() == ISD::ATOMIC_LOAD_OR_8 ||
1732 N->getOpcode() == ISD::ATOMIC_LOAD_XOR_8 ||
1733 N->getOpcode() == ISD::ATOMIC_LOAD_NAND_8 ||
1734 N->getOpcode() == ISD::ATOMIC_LOAD_MIN_8 ||
1735 N->getOpcode() == ISD::ATOMIC_LOAD_MAX_8 ||
1736 N->getOpcode() == ISD::ATOMIC_LOAD_UMIN_8 ||
1737 N->getOpcode() == ISD::ATOMIC_LOAD_UMAX_8 ||
1738 N->getOpcode() == ISD::ATOMIC_CMP_SWAP_16 ||
1739 N->getOpcode() == ISD::ATOMIC_SWAP_16 ||
1740 N->getOpcode() == ISD::ATOMIC_LOAD_ADD_16 ||
1741 N->getOpcode() == ISD::ATOMIC_LOAD_SUB_16 ||
1742 N->getOpcode() == ISD::ATOMIC_LOAD_AND_16 ||
1743 N->getOpcode() == ISD::ATOMIC_LOAD_OR_16 ||
1744 N->getOpcode() == ISD::ATOMIC_LOAD_XOR_16 ||
1745 N->getOpcode() == ISD::ATOMIC_LOAD_NAND_16 ||
1746 N->getOpcode() == ISD::ATOMIC_LOAD_MIN_16 ||
1747 N->getOpcode() == ISD::ATOMIC_LOAD_MAX_16 ||
1748 N->getOpcode() == ISD::ATOMIC_LOAD_UMIN_16 ||
1749 N->getOpcode() == ISD::ATOMIC_LOAD_UMAX_16 ||
1750 N->getOpcode() == ISD::ATOMIC_CMP_SWAP_32 ||
1751 N->getOpcode() == ISD::ATOMIC_SWAP_32 ||
1752 N->getOpcode() == ISD::ATOMIC_LOAD_ADD_32 ||
1753 N->getOpcode() == ISD::ATOMIC_LOAD_SUB_32 ||
1754 N->getOpcode() == ISD::ATOMIC_LOAD_AND_32 ||
1755 N->getOpcode() == ISD::ATOMIC_LOAD_OR_32 ||
1756 N->getOpcode() == ISD::ATOMIC_LOAD_XOR_32 ||
1757 N->getOpcode() == ISD::ATOMIC_LOAD_NAND_32 ||
1758 N->getOpcode() == ISD::ATOMIC_LOAD_MIN_32 ||
1759 N->getOpcode() == ISD::ATOMIC_LOAD_MAX_32 ||
1760 N->getOpcode() == ISD::ATOMIC_LOAD_UMIN_32 ||
1761 N->getOpcode() == ISD::ATOMIC_LOAD_UMAX_32 ||
1762 N->getOpcode() == ISD::ATOMIC_CMP_SWAP_64 ||
1763 N->getOpcode() == ISD::ATOMIC_SWAP_64 ||
1764 N->getOpcode() == ISD::ATOMIC_LOAD_ADD_64 ||
1765 N->getOpcode() == ISD::ATOMIC_LOAD_SUB_64 ||
1766 N->getOpcode() == ISD::ATOMIC_LOAD_AND_64 ||
1767 N->getOpcode() == ISD::ATOMIC_LOAD_OR_64 ||
1768 N->getOpcode() == ISD::ATOMIC_LOAD_XOR_64 ||
1769 N->getOpcode() == ISD::ATOMIC_LOAD_NAND_64 ||
1770 N->getOpcode() == ISD::ATOMIC_LOAD_MIN_64 ||
1771 N->getOpcode() == ISD::ATOMIC_LOAD_MAX_64 ||
1772 N->getOpcode() == ISD::ATOMIC_LOAD_UMIN_64 ||
1773 N->getOpcode() == ISD::ATOMIC_LOAD_UMAX_64;
1777 /// MemIntrinsicSDNode - This SDNode is used for target intrinsic that touches
1778 /// memory and need an associated memory operand.
1780 class MemIntrinsicSDNode : public MemSDNode {
1781 virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
1782 bool ReadMem; // Intrinsic reads memory
1783 bool WriteMem; // Intrinsic writes memory
1785 MemIntrinsicSDNode(unsigned Opc, SDVTList VTs,
1786 const SDValue *Ops, unsigned NumOps,
1787 MVT MemoryVT, const Value *srcValue, int SVO,
1788 unsigned Align, bool Vol, bool ReadMem, bool WriteMem)
1789 : MemSDNode(Opc, VTs, Ops, NumOps, MemoryVT, srcValue, SVO, Align, Vol),
1790 ReadMem(ReadMem), WriteMem(WriteMem) {
1793 bool readMem() const { return ReadMem; }
1794 bool writeMem() const { return WriteMem; }
1796 // Methods to support isa and dyn_cast
1797 static bool classof(const MemIntrinsicSDNode *) { return true; }
1798 static bool classof(const SDNode *N) {
1799 // We lower some target intrinsics to their target opcode
1800 // early a node with a target opcode can be of this class
1801 return N->getOpcode() == ISD::INTRINSIC_W_CHAIN ||
1802 N->getOpcode() == ISD::INTRINSIC_VOID ||
1803 N->isTargetOpcode();
1807 class ConstantSDNode : public SDNode {
1808 const ConstantInt *Value;
1809 virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
1811 friend class SelectionDAG;
1812 ConstantSDNode(bool isTarget, const ConstantInt *val, MVT VT)
1813 : SDNode(isTarget ? ISD::TargetConstant : ISD::Constant, getSDVTList(VT)),
1818 const ConstantInt *getConstantIntValue() const { return Value; }
1819 const APInt &getAPIntValue() const { return Value->getValue(); }
1820 uint64_t getZExtValue() const { return Value->getZExtValue(); }
1821 int64_t getSExtValue() const { return Value->getSExtValue(); }
1823 bool isNullValue() const { return Value->isNullValue(); }
1824 bool isAllOnesValue() const { return Value->isAllOnesValue(); }
1826 static bool classof(const ConstantSDNode *) { return true; }
1827 static bool classof(const SDNode *N) {
1828 return N->getOpcode() == ISD::Constant ||
1829 N->getOpcode() == ISD::TargetConstant;
1833 class ConstantFPSDNode : public SDNode {
1834 const ConstantFP *Value;
1835 virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
1837 friend class SelectionDAG;
1838 ConstantFPSDNode(bool isTarget, const ConstantFP *val, MVT VT)
1839 : SDNode(isTarget ? ISD::TargetConstantFP : ISD::ConstantFP,
1840 getSDVTList(VT)), Value(val) {
1844 const APFloat& getValueAPF() const { return Value->getValueAPF(); }
1845 const ConstantFP *getConstantFPValue() const { return Value; }
1847 /// isExactlyValue - We don't rely on operator== working on double values, as
1848 /// it returns true for things that are clearly not equal, like -0.0 and 0.0.
1849 /// As such, this method can be used to do an exact bit-for-bit comparison of
1850 /// two floating point values.
1852 /// We leave the version with the double argument here because it's just so
1853 /// convenient to write "2.0" and the like. Without this function we'd
1854 /// have to duplicate its logic everywhere it's called.
1855 bool isExactlyValue(double V) const {
1857 // convert is not supported on this type
1858 if (&Value->getValueAPF().getSemantics() == &APFloat::PPCDoubleDouble)
1861 Tmp.convert(Value->getValueAPF().getSemantics(),
1862 APFloat::rmNearestTiesToEven, &ignored);
1863 return isExactlyValue(Tmp);
1865 bool isExactlyValue(const APFloat& V) const;
1867 bool isValueValidForType(MVT VT, const APFloat& Val);
1869 static bool classof(const ConstantFPSDNode *) { return true; }
1870 static bool classof(const SDNode *N) {
1871 return N->getOpcode() == ISD::ConstantFP ||
1872 N->getOpcode() == ISD::TargetConstantFP;
1876 class GlobalAddressSDNode : public SDNode {
1877 GlobalValue *TheGlobal;
1879 virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
1881 friend class SelectionDAG;
1882 GlobalAddressSDNode(bool isTarget, const GlobalValue *GA, MVT VT,
1886 GlobalValue *getGlobal() const { return TheGlobal; }
1887 int64_t getOffset() const { return Offset; }
1889 static bool classof(const GlobalAddressSDNode *) { return true; }
1890 static bool classof(const SDNode *N) {
1891 return N->getOpcode() == ISD::GlobalAddress ||
1892 N->getOpcode() == ISD::TargetGlobalAddress ||
1893 N->getOpcode() == ISD::GlobalTLSAddress ||
1894 N->getOpcode() == ISD::TargetGlobalTLSAddress;
1898 class FrameIndexSDNode : public SDNode {
1900 virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
1902 friend class SelectionDAG;
1903 FrameIndexSDNode(int fi, MVT VT, bool isTarg)
1904 : SDNode(isTarg ? ISD::TargetFrameIndex : ISD::FrameIndex, getSDVTList(VT)),
1909 int getIndex() const { return FI; }
1911 static bool classof(const FrameIndexSDNode *) { return true; }
1912 static bool classof(const SDNode *N) {
1913 return N->getOpcode() == ISD::FrameIndex ||
1914 N->getOpcode() == ISD::TargetFrameIndex;
1918 class JumpTableSDNode : public SDNode {
1920 virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
1922 friend class SelectionDAG;
1923 JumpTableSDNode(int jti, MVT VT, bool isTarg)
1924 : SDNode(isTarg ? ISD::TargetJumpTable : ISD::JumpTable, getSDVTList(VT)),
1929 int getIndex() const { return JTI; }
1931 static bool classof(const JumpTableSDNode *) { return true; }
1932 static bool classof(const SDNode *N) {
1933 return N->getOpcode() == ISD::JumpTable ||
1934 N->getOpcode() == ISD::TargetJumpTable;
1938 class ConstantPoolSDNode : public SDNode {
1941 MachineConstantPoolValue *MachineCPVal;
1943 int Offset; // It's a MachineConstantPoolValue if top bit is set.
1945 virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
1947 friend class SelectionDAG;
1948 ConstantPoolSDNode(bool isTarget, Constant *c, MVT VT, int o=0)
1949 : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
1950 getSDVTList(VT)), Offset(o), Alignment(0) {
1951 assert((int)Offset >= 0 && "Offset is too large");
1954 ConstantPoolSDNode(bool isTarget, Constant *c, MVT VT, int o, unsigned Align)
1955 : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
1956 getSDVTList(VT)), Offset(o), Alignment(Align) {
1957 assert((int)Offset >= 0 && "Offset is too large");
1960 ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v,
1962 : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
1963 getSDVTList(VT)), Offset(o), Alignment(0) {
1964 assert((int)Offset >= 0 && "Offset is too large");
1965 Val.MachineCPVal = v;
1966 Offset |= 1 << (sizeof(unsigned)*8-1);
1968 ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v,
1969 MVT VT, int o, unsigned Align)
1970 : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
1971 getSDVTList(VT)), Offset(o), Alignment(Align) {
1972 assert((int)Offset >= 0 && "Offset is too large");
1973 Val.MachineCPVal = v;
1974 Offset |= 1 << (sizeof(unsigned)*8-1);
1978 bool isMachineConstantPoolEntry() const {
1979 return (int)Offset < 0;
1982 Constant *getConstVal() const {
1983 assert(!isMachineConstantPoolEntry() && "Wrong constantpool type");
1984 return Val.ConstVal;
1987 MachineConstantPoolValue *getMachineCPVal() const {
1988 assert(isMachineConstantPoolEntry() && "Wrong constantpool type");
1989 return Val.MachineCPVal;
1992 int getOffset() const {
1993 return Offset & ~(1 << (sizeof(unsigned)*8-1));
1996 // Return the alignment of this constant pool object, which is either 0 (for
1997 // default alignment) or log2 of the desired value.
1998 unsigned getAlignment() const { return Alignment; }
2000 const Type *getType() const;
2002 static bool classof(const ConstantPoolSDNode *) { return true; }
2003 static bool classof(const SDNode *N) {
2004 return N->getOpcode() == ISD::ConstantPool ||
2005 N->getOpcode() == ISD::TargetConstantPool;
2009 class BasicBlockSDNode : public SDNode {
2010 MachineBasicBlock *MBB;
2011 virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
2013 friend class SelectionDAG;
2014 explicit BasicBlockSDNode(MachineBasicBlock *mbb)
2015 : SDNode(ISD::BasicBlock, getSDVTList(MVT::Other)), MBB(mbb) {
2019 MachineBasicBlock *getBasicBlock() const { return MBB; }
2021 static bool classof(const BasicBlockSDNode *) { return true; }
2022 static bool classof(const SDNode *N) {
2023 return N->getOpcode() == ISD::BasicBlock;
2027 /// SrcValueSDNode - An SDNode that holds an arbitrary LLVM IR Value. This is
2028 /// used when the SelectionDAG needs to make a simple reference to something
2029 /// in the LLVM IR representation.
2031 /// Note that this is not used for carrying alias information; that is done
2032 /// with MemOperandSDNode, which includes a Value which is required to be a
2033 /// pointer, and several other fields specific to memory references.
2035 class SrcValueSDNode : public SDNode {
2037 virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
2039 friend class SelectionDAG;
2040 /// Create a SrcValue for a general value.
2041 explicit SrcValueSDNode(const Value *v)
2042 : SDNode(ISD::SRCVALUE, getSDVTList(MVT::Other)), V(v) {}
2045 /// getValue - return the contained Value.
2046 const Value *getValue() const { return V; }
2048 static bool classof(const SrcValueSDNode *) { return true; }
2049 static bool classof(const SDNode *N) {
2050 return N->getOpcode() == ISD::SRCVALUE;
2055 /// MemOperandSDNode - An SDNode that holds a MachineMemOperand. This is
2056 /// used to represent a reference to memory after ISD::LOAD
2057 /// and ISD::STORE have been lowered.
2059 class MemOperandSDNode : public SDNode {
2060 virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
2062 friend class SelectionDAG;
2063 /// Create a MachineMemOperand node
2064 explicit MemOperandSDNode(const MachineMemOperand &mo)
2065 : SDNode(ISD::MEMOPERAND, getSDVTList(MVT::Other)), MO(mo) {}
2068 /// MO - The contained MachineMemOperand.
2069 const MachineMemOperand MO;
2071 static bool classof(const MemOperandSDNode *) { return true; }
2072 static bool classof(const SDNode *N) {
2073 return N->getOpcode() == ISD::MEMOPERAND;
2078 class RegisterSDNode : public SDNode {
2080 virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
2082 friend class SelectionDAG;
2083 RegisterSDNode(unsigned reg, MVT VT)
2084 : SDNode(ISD::Register, getSDVTList(VT)), Reg(reg) {
2088 unsigned getReg() const { return Reg; }
2090 static bool classof(const RegisterSDNode *) { return true; }
2091 static bool classof(const SDNode *N) {
2092 return N->getOpcode() == ISD::Register;
2096 class DbgStopPointSDNode : public SDNode {
2100 const CompileUnitDesc *CU;
2101 virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
2103 friend class SelectionDAG;
2104 DbgStopPointSDNode(SDValue ch, unsigned l, unsigned c,
2105 const CompileUnitDesc *cu)
2106 : SDNode(ISD::DBG_STOPPOINT, getSDVTList(MVT::Other)),
2107 Line(l), Column(c), CU(cu) {
2109 InitOperands(&Chain, 1);
2112 unsigned getLine() const { return Line; }
2113 unsigned getColumn() const { return Column; }
2114 const CompileUnitDesc *getCompileUnit() const { return CU; }
2116 static bool classof(const DbgStopPointSDNode *) { return true; }
2117 static bool classof(const SDNode *N) {
2118 return N->getOpcode() == ISD::DBG_STOPPOINT;
2122 class LabelSDNode : public SDNode {
2125 virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
2127 friend class SelectionDAG;
2128 LabelSDNode(unsigned NodeTy, SDValue ch, unsigned id)
2129 : SDNode(NodeTy, getSDVTList(MVT::Other)), LabelID(id) {
2131 InitOperands(&Chain, 1);
2134 unsigned getLabelID() const { return LabelID; }
2136 static bool classof(const LabelSDNode *) { return true; }
2137 static bool classof(const SDNode *N) {
2138 return N->getOpcode() == ISD::DBG_LABEL ||
2139 N->getOpcode() == ISD::EH_LABEL;
2143 class ExternalSymbolSDNode : public SDNode {
2145 virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
2147 friend class SelectionDAG;
2148 ExternalSymbolSDNode(bool isTarget, const char *Sym, MVT VT)
2149 : SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol,
2150 getSDVTList(VT)), Symbol(Sym) {
2154 const char *getSymbol() const { return Symbol; }
2156 static bool classof(const ExternalSymbolSDNode *) { return true; }
2157 static bool classof(const SDNode *N) {
2158 return N->getOpcode() == ISD::ExternalSymbol ||
2159 N->getOpcode() == ISD::TargetExternalSymbol;
2163 class CondCodeSDNode : public SDNode {
2164 ISD::CondCode Condition;
2165 virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
2167 friend class SelectionDAG;
2168 explicit CondCodeSDNode(ISD::CondCode Cond)
2169 : SDNode(ISD::CONDCODE, getSDVTList(MVT::Other)), Condition(Cond) {
2173 ISD::CondCode get() const { return Condition; }
2175 static bool classof(const CondCodeSDNode *) { return true; }
2176 static bool classof(const SDNode *N) {
2177 return N->getOpcode() == ISD::CONDCODE;
2181 /// CvtRndSatSDNode - NOTE: avoid using this node as this may disappear in the
2182 /// future and most targets don't support it.
2183 class CvtRndSatSDNode : public SDNode {
2184 ISD::CvtCode CvtCode;
2185 virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
2187 friend class SelectionDAG;
2188 explicit CvtRndSatSDNode(MVT VT, const SDValue *Ops, unsigned NumOps,
2190 : SDNode(ISD::CONVERT_RNDSAT, getSDVTList(VT), Ops, NumOps), CvtCode(Code) {
2191 assert(NumOps == 5 && "wrong number of operations");
2194 ISD::CvtCode getCvtCode() const { return CvtCode; }
2196 static bool classof(const CvtRndSatSDNode *) { return true; }
2197 static bool classof(const SDNode *N) {
2198 return N->getOpcode() == ISD::CONVERT_RNDSAT;
2205 static const uint64_t NoFlagSet = 0ULL;
2206 static const uint64_t ZExt = 1ULL<<0; ///< Zero extended
2207 static const uint64_t ZExtOffs = 0;
2208 static const uint64_t SExt = 1ULL<<1; ///< Sign extended
2209 static const uint64_t SExtOffs = 1;
2210 static const uint64_t InReg = 1ULL<<2; ///< Passed in register
2211 static const uint64_t InRegOffs = 2;
2212 static const uint64_t SRet = 1ULL<<3; ///< Hidden struct-ret ptr
2213 static const uint64_t SRetOffs = 3;
2214 static const uint64_t ByVal = 1ULL<<4; ///< Struct passed by value
2215 static const uint64_t ByValOffs = 4;
2216 static const uint64_t Nest = 1ULL<<5; ///< Nested fn static chain
2217 static const uint64_t NestOffs = 5;
2218 static const uint64_t ByValAlign = 0xFULL << 6; //< Struct alignment
2219 static const uint64_t ByValAlignOffs = 6;
2220 static const uint64_t Split = 1ULL << 10;
2221 static const uint64_t SplitOffs = 10;
2222 static const uint64_t OrigAlign = 0x1FULL<<27;
2223 static const uint64_t OrigAlignOffs = 27;
2224 static const uint64_t ByValSize = 0xffffffffULL << 32; //< Struct size
2225 static const uint64_t ByValSizeOffs = 32;
2227 static const uint64_t One = 1ULL; //< 1 of this type, for shifts
2231 ArgFlagsTy() : Flags(0) { }
2233 bool isZExt() const { return Flags & ZExt; }
2234 void setZExt() { Flags |= One << ZExtOffs; }
2236 bool isSExt() const { return Flags & SExt; }
2237 void setSExt() { Flags |= One << SExtOffs; }
2239 bool isInReg() const { return Flags & InReg; }
2240 void setInReg() { Flags |= One << InRegOffs; }
2242 bool isSRet() const { return Flags & SRet; }
2243 void setSRet() { Flags |= One << SRetOffs; }
2245 bool isByVal() const { return Flags & ByVal; }
2246 void setByVal() { Flags |= One << ByValOffs; }
2248 bool isNest() const { return Flags & Nest; }
2249 void setNest() { Flags |= One << NestOffs; }
2251 unsigned getByValAlign() const {
2253 ((One << ((Flags & ByValAlign) >> ByValAlignOffs)) / 2);
2255 void setByValAlign(unsigned A) {
2256 Flags = (Flags & ~ByValAlign) |
2257 (uint64_t(Log2_32(A) + 1) << ByValAlignOffs);
2260 bool isSplit() const { return Flags & Split; }
2261 void setSplit() { Flags |= One << SplitOffs; }
2263 unsigned getOrigAlign() const {
2265 ((One << ((Flags & OrigAlign) >> OrigAlignOffs)) / 2);
2267 void setOrigAlign(unsigned A) {
2268 Flags = (Flags & ~OrigAlign) |
2269 (uint64_t(Log2_32(A) + 1) << OrigAlignOffs);
2272 unsigned getByValSize() const {
2273 return (unsigned)((Flags & ByValSize) >> ByValSizeOffs);
2275 void setByValSize(unsigned S) {
2276 Flags = (Flags & ~ByValSize) | (uint64_t(S) << ByValSizeOffs);
2279 /// getArgFlagsString - Returns the flags as a string, eg: "zext align:4".
2280 std::string getArgFlagsString();
2282 /// getRawBits - Represent the flags as a bunch of bits.
2283 uint64_t getRawBits() const { return Flags; }
2287 /// ARG_FLAGSSDNode - Leaf node holding parameter flags.
2288 class ARG_FLAGSSDNode : public SDNode {
2289 ISD::ArgFlagsTy TheFlags;
2290 virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
2292 friend class SelectionDAG;
2293 explicit ARG_FLAGSSDNode(ISD::ArgFlagsTy Flags)
2294 : SDNode(ISD::ARG_FLAGS, getSDVTList(MVT::Other)), TheFlags(Flags) {
2297 ISD::ArgFlagsTy getArgFlags() const { return TheFlags; }
2299 static bool classof(const ARG_FLAGSSDNode *) { return true; }
2300 static bool classof(const SDNode *N) {
2301 return N->getOpcode() == ISD::ARG_FLAGS;
2305 /// CallSDNode - Node for calls -- ISD::CALL.
2306 class CallSDNode : public SDNode {
2307 unsigned CallingConv;
2310 // We might eventually want a full-blown Attributes for the result; that
2311 // will expand the size of the representation. At the moment we only
2314 virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
2316 friend class SelectionDAG;
2317 CallSDNode(unsigned cc, bool isvararg, bool istailcall, bool isinreg,
2318 SDVTList VTs, const SDValue *Operands, unsigned numOperands)
2319 : SDNode(ISD::CALL, VTs, Operands, numOperands),
2320 CallingConv(cc), IsVarArg(isvararg), IsTailCall(istailcall),
2323 unsigned getCallingConv() const { return CallingConv; }
2324 unsigned isVarArg() const { return IsVarArg; }
2325 unsigned isTailCall() const { return IsTailCall; }
2326 unsigned isInreg() const { return Inreg; }
2328 /// Set this call to not be marked as a tail call. Normally setter
2329 /// methods in SDNodes are unsafe because it breaks the CSE map,
2330 /// but we don't include the tail call flag for calls so it's ok
2332 void setNotTailCall() { IsTailCall = false; }
2334 SDValue getChain() const { return getOperand(0); }
2335 SDValue getCallee() const { return getOperand(1); }
2337 unsigned getNumArgs() const { return (getNumOperands() - 2) / 2; }
2338 SDValue getArg(unsigned i) const { return getOperand(2+2*i); }
2339 SDValue getArgFlagsVal(unsigned i) const {
2340 return getOperand(3+2*i);
2342 ISD::ArgFlagsTy getArgFlags(unsigned i) const {
2343 return cast<ARG_FLAGSSDNode>(getArgFlagsVal(i).getNode())->getArgFlags();
2346 unsigned getNumRetVals() const { return getNumValues() - 1; }
2347 MVT getRetValType(unsigned i) const { return getValueType(i); }
2349 static bool classof(const CallSDNode *) { return true; }
2350 static bool classof(const SDNode *N) {
2351 return N->getOpcode() == ISD::CALL;
2355 /// VTSDNode - This class is used to represent MVT's, which are used
2356 /// to parameterize some operations.
2357 class VTSDNode : public SDNode {
2359 virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
2361 friend class SelectionDAG;
2362 explicit VTSDNode(MVT VT)
2363 : SDNode(ISD::VALUETYPE, getSDVTList(MVT::Other)), ValueType(VT) {
2367 MVT getVT() const { return ValueType; }
2369 static bool classof(const VTSDNode *) { return true; }
2370 static bool classof(const SDNode *N) {
2371 return N->getOpcode() == ISD::VALUETYPE;
2375 /// LSBaseSDNode - Base class for LoadSDNode and StoreSDNode
2377 class LSBaseSDNode : public MemSDNode {
2379 //! Operand array for load and store
2381 \note Moving this array to the base class captures more
2382 common functionality shared between LoadSDNode and
2387 LSBaseSDNode(ISD::NodeType NodeTy, SDValue *Operands, unsigned numOperands,
2388 SDVTList VTs, ISD::MemIndexedMode AM, MVT VT,
2389 const Value *SV, int SVO, unsigned Align, bool Vol)
2390 : MemSDNode(NodeTy, VTs, VT, SV, SVO, Align, Vol) {
2392 for (unsigned i = 0; i != numOperands; ++i)
2393 Ops[i] = Operands[i];
2394 InitOperands(Ops, numOperands);
2395 assert(Align != 0 && "Loads and stores should have non-zero aligment");
2396 assert((getOffset().getOpcode() == ISD::UNDEF || isIndexed()) &&
2397 "Only indexed loads and stores have a non-undef offset operand");
2400 const SDValue &getOffset() const {
2401 return getOperand(getOpcode() == ISD::LOAD ? 2 : 3);
2404 /// getAddressingMode - Return the addressing mode for this load or store:
2405 /// unindexed, pre-inc, pre-dec, post-inc, or post-dec.
2406 ISD::MemIndexedMode getAddressingMode() const {
2407 return ISD::MemIndexedMode(SubclassData & 7);
2410 /// isIndexed - Return true if this is a pre/post inc/dec load/store.
2411 bool isIndexed() const { return getAddressingMode() != ISD::UNINDEXED; }
2413 /// isUnindexed - Return true if this is NOT a pre/post inc/dec load/store.
2414 bool isUnindexed() const { return getAddressingMode() == ISD::UNINDEXED; }
2416 static bool classof(const LSBaseSDNode *) { return true; }
2417 static bool classof(const SDNode *N) {
2418 return N->getOpcode() == ISD::LOAD ||
2419 N->getOpcode() == ISD::STORE;
2423 /// LoadSDNode - This class is used to represent ISD::LOAD nodes.
2425 class LoadSDNode : public LSBaseSDNode {
2426 virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
2428 friend class SelectionDAG;
2429 LoadSDNode(SDValue *ChainPtrOff, SDVTList VTs,
2430 ISD::MemIndexedMode AM, ISD::LoadExtType ETy, MVT LVT,
2431 const Value *SV, int O=0, unsigned Align=0, bool Vol=false)
2432 : LSBaseSDNode(ISD::LOAD, ChainPtrOff, 3,
2433 VTs, AM, LVT, SV, O, Align, Vol) {
2434 SubclassData |= (unsigned short)ETy << 3;
2438 /// getExtensionType - Return whether this is a plain node,
2439 /// or one of the varieties of value-extending loads.
2440 ISD::LoadExtType getExtensionType() const {
2441 return ISD::LoadExtType((SubclassData >> 3) & 3);
2444 const SDValue &getBasePtr() const { return getOperand(1); }
2445 const SDValue &getOffset() const { return getOperand(2); }
2447 static bool classof(const LoadSDNode *) { return true; }
2448 static bool classof(const SDNode *N) {
2449 return N->getOpcode() == ISD::LOAD;
2453 /// StoreSDNode - This class is used to represent ISD::STORE nodes.
2455 class StoreSDNode : public LSBaseSDNode {
2456 virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
2458 friend class SelectionDAG;
2459 StoreSDNode(SDValue *ChainValuePtrOff, SDVTList VTs,
2460 ISD::MemIndexedMode AM, bool isTrunc, MVT SVT,
2461 const Value *SV, int O=0, unsigned Align=0, bool Vol=false)
2462 : LSBaseSDNode(ISD::STORE, ChainValuePtrOff, 4,
2463 VTs, AM, SVT, SV, O, Align, Vol) {
2464 SubclassData |= (unsigned short)isTrunc << 3;
2468 /// isTruncatingStore - Return true if the op does a truncation before store.
2469 /// For integers this is the same as doing a TRUNCATE and storing the result.
2470 /// For floats, it is the same as doing an FP_ROUND and storing the result.
2471 bool isTruncatingStore() const { return (SubclassData >> 3) & 1; }
2473 const SDValue &getValue() const { return getOperand(1); }
2474 const SDValue &getBasePtr() const { return getOperand(2); }
2475 const SDValue &getOffset() const { return getOperand(3); }
2477 static bool classof(const StoreSDNode *) { return true; }
2478 static bool classof(const SDNode *N) {
2479 return N->getOpcode() == ISD::STORE;
2484 class SDNodeIterator : public forward_iterator<SDNode, ptrdiff_t> {
2488 SDNodeIterator(SDNode *N, unsigned Op) : Node(N), Operand(Op) {}
2490 bool operator==(const SDNodeIterator& x) const {
2491 return Operand == x.Operand;
2493 bool operator!=(const SDNodeIterator& x) const { return !operator==(x); }
2495 const SDNodeIterator &operator=(const SDNodeIterator &I) {
2496 assert(I.Node == Node && "Cannot assign iterators to two different nodes!");
2497 Operand = I.Operand;
2501 pointer operator*() const {
2502 return Node->getOperand(Operand).getNode();
2504 pointer operator->() const { return operator*(); }
2506 SDNodeIterator& operator++() { // Preincrement
2510 SDNodeIterator operator++(int) { // Postincrement
2511 SDNodeIterator tmp = *this; ++*this; return tmp;
2514 static SDNodeIterator begin(SDNode *N) { return SDNodeIterator(N, 0); }
2515 static SDNodeIterator end (SDNode *N) {
2516 return SDNodeIterator(N, N->getNumOperands());
2519 unsigned getOperand() const { return Operand; }
2520 const SDNode *getNode() const { return Node; }
2523 template <> struct GraphTraits<SDNode*> {
2524 typedef SDNode NodeType;
2525 typedef SDNodeIterator ChildIteratorType;
2526 static inline NodeType *getEntryNode(SDNode *N) { return N; }
2527 static inline ChildIteratorType child_begin(NodeType *N) {
2528 return SDNodeIterator::begin(N);
2530 static inline ChildIteratorType child_end(NodeType *N) {
2531 return SDNodeIterator::end(N);
2535 /// LargestSDNode - The largest SDNode class.
2537 typedef LoadSDNode LargestSDNode;
2539 /// MostAlignedSDNode - The SDNode class with the greatest alignment
2542 typedef ARG_FLAGSSDNode MostAlignedSDNode;
2545 /// isNormalLoad - Returns true if the specified node is a non-extending
2546 /// and unindexed load.
2547 inline bool isNormalLoad(const SDNode *N) {
2548 const LoadSDNode *Ld = dyn_cast<LoadSDNode>(N);
2549 return Ld && Ld->getExtensionType() == ISD::NON_EXTLOAD &&
2550 Ld->getAddressingMode() == ISD::UNINDEXED;
2553 /// isNON_EXTLoad - Returns true if the specified node is a non-extending
2555 inline bool isNON_EXTLoad(const SDNode *N) {
2556 return isa<LoadSDNode>(N) &&
2557 cast<LoadSDNode>(N)->getExtensionType() == ISD::NON_EXTLOAD;
2560 /// isEXTLoad - Returns true if the specified node is a EXTLOAD.
2562 inline bool isEXTLoad(const SDNode *N) {
2563 return isa<LoadSDNode>(N) &&
2564 cast<LoadSDNode>(N)->getExtensionType() == ISD::EXTLOAD;
2567 /// isSEXTLoad - Returns true if the specified node is a SEXTLOAD.
2569 inline bool isSEXTLoad(const SDNode *N) {
2570 return isa<LoadSDNode>(N) &&
2571 cast<LoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD;
2574 /// isZEXTLoad - Returns true if the specified node is a ZEXTLOAD.
2576 inline bool isZEXTLoad(const SDNode *N) {
2577 return isa<LoadSDNode>(N) &&
2578 cast<LoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD;
2581 /// isUNINDEXEDLoad - Returns true if the specified node is an unindexed load.
2583 inline bool isUNINDEXEDLoad(const SDNode *N) {
2584 return isa<LoadSDNode>(N) &&
2585 cast<LoadSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
2588 /// isNormalStore - Returns true if the specified node is a non-truncating
2589 /// and unindexed store.
2590 inline bool isNormalStore(const SDNode *N) {
2591 const StoreSDNode *St = dyn_cast<StoreSDNode>(N);
2592 return St && !St->isTruncatingStore() &&
2593 St->getAddressingMode() == ISD::UNINDEXED;
2596 /// isNON_TRUNCStore - Returns true if the specified node is a non-truncating
2598 inline bool isNON_TRUNCStore(const SDNode *N) {
2599 return isa<StoreSDNode>(N) && !cast<StoreSDNode>(N)->isTruncatingStore();
2602 /// isTRUNCStore - Returns true if the specified node is a truncating
2604 inline bool isTRUNCStore(const SDNode *N) {
2605 return isa<StoreSDNode>(N) && cast<StoreSDNode>(N)->isTruncatingStore();
2608 /// isUNINDEXEDStore - Returns true if the specified node is an
2609 /// unindexed store.
2610 inline bool isUNINDEXEDStore(const SDNode *N) {
2611 return isa<StoreSDNode>(N) &&
2612 cast<StoreSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
2617 } // end llvm namespace