SelectionDAGNodes.h revision 944fac71e082cc2664cc71b4d3f6c72bab7143fb
1//===-- llvm/CodeGen/SelectionDAGNodes.h - SelectionDAG Nodes ---*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This 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.
14//
15// Clients should include the SelectionDAG.h file instead of this file directly.
16//
17//===----------------------------------------------------------------------===//
18
19#ifndef LLVM_CODEGEN_SELECTIONDAGNODES_H
20#define LLVM_CODEGEN_SELECTIONDAGNODES_H
21
22#include "llvm/Value.h"
23#include "llvm/ADT/FoldingSet.h"
24#include "llvm/ADT/GraphTraits.h"
25#include "llvm/ADT/iterator.h"
26#include "llvm/ADT/APFloat.h"
27#include "llvm/ADT/APInt.h"
28#include "llvm/ADT/ilist_node.h"
29#include "llvm/ADT/STLExtras.h"
30#include "llvm/CodeGen/ValueTypes.h"
31#include "llvm/CodeGen/MachineMemOperand.h"
32#include "llvm/Support/Allocator.h"
33#include "llvm/Support/RecyclingAllocator.h"
34#include "llvm/Support/DataTypes.h"
35#include <cassert>
36
37namespace llvm {
38
39class SelectionDAG;
40class GlobalValue;
41class MachineBasicBlock;
42class MachineConstantPoolValue;
43class SDNode;
44class CompileUnitDesc;
45template <typename T> struct DenseMapInfo;
46template <typename T> struct simplify_type;
47template <typename T> class ilist_traits;
48
49/// SDVTList - This represents a list of ValueType's that has been intern'd by
50/// a SelectionDAG.  Instances of this simple value class are returned by
51/// SelectionDAG::getVTList(...).
52///
53struct SDVTList {
54  const MVT *VTs;
55  unsigned short NumVTs;
56};
57
58/// ISD namespace - This namespace contains an enum which represents all of the
59/// SelectionDAG node types and value types.
60///
61namespace ISD {
62
63  //===--------------------------------------------------------------------===//
64  /// ISD::NodeType enum - This enum defines all of the operators valid in a
65  /// SelectionDAG.
66  ///
67  enum NodeType {
68    // DELETED_NODE - This is an illegal flag value that is used to catch
69    // errors.  This opcode is not a legal opcode for any node.
70    DELETED_NODE,
71
72    // EntryToken - This is the marker used to indicate the start of the region.
73    EntryToken,
74
75    // Token factor - This node takes multiple tokens as input and produces a
76    // single token result.  This is used to represent the fact that the operand
77    // operators are independent of each other.
78    TokenFactor,
79
80    // AssertSext, AssertZext - These nodes record if a register contains a
81    // value that has already been zero or sign extended from a narrower type.
82    // These nodes take two operands.  The first is the node that has already
83    // been extended, and the second is a value type node indicating the width
84    // of the extension
85    AssertSext, AssertZext,
86
87    // Various leaf nodes.
88    BasicBlock, VALUETYPE, ARG_FLAGS, CONDCODE, Register,
89    Constant, ConstantFP,
90    GlobalAddress, GlobalTLSAddress, FrameIndex,
91    JumpTable, ConstantPool, ExternalSymbol,
92
93    // The address of the GOT
94    GLOBAL_OFFSET_TABLE,
95
96    // FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and
97    // llvm.returnaddress on the DAG.  These nodes take one operand, the index
98    // of the frame or return address to return.  An index of zero corresponds
99    // to the current function's frame or return address, an index of one to the
100    // parent's frame or return address, and so on.
101    FRAMEADDR, RETURNADDR,
102
103    // FRAME_TO_ARGS_OFFSET - This node represents offset from frame pointer to
104    // first (possible) on-stack argument. This is needed for correct stack
105    // adjustment during unwind.
106    FRAME_TO_ARGS_OFFSET,
107
108    // RESULT, OUTCHAIN = EXCEPTIONADDR(INCHAIN) - This node represents the
109    // address of the exception block on entry to an landing pad block.
110    EXCEPTIONADDR,
111
112    // RESULT, OUTCHAIN = EHSELECTION(INCHAIN, EXCEPTION) - This node represents
113    // the selection index of the exception thrown.
114    EHSELECTION,
115
116    // OUTCHAIN = EH_RETURN(INCHAIN, OFFSET, HANDLER) - This node represents
117    // 'eh_return' gcc dwarf builtin, which is used to return from
118    // exception. The general meaning is: adjust stack by OFFSET and pass
119    // execution to HANDLER. Many platform-related details also :)
120    EH_RETURN,
121
122    // TargetConstant* - Like Constant*, but the DAG does not do any folding or
123    // simplification of the constant.
124    TargetConstant,
125    TargetConstantFP,
126
127    // TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or
128    // anything else with this node, and this is valid in the target-specific
129    // dag, turning into a GlobalAddress operand.
130    TargetGlobalAddress,
131    TargetGlobalTLSAddress,
132    TargetFrameIndex,
133    TargetJumpTable,
134    TargetConstantPool,
135    TargetExternalSymbol,
136
137    /// RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...)
138    /// This node represents a target intrinsic function with no side effects.
139    /// The first operand is the ID number of the intrinsic from the
140    /// llvm::Intrinsic namespace.  The operands to the intrinsic follow.  The
141    /// node has returns the result of the intrinsic.
142    INTRINSIC_WO_CHAIN,
143
144    /// RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...)
145    /// This node represents a target intrinsic function with side effects that
146    /// returns a result.  The first operand is a chain pointer.  The second is
147    /// the ID number of the intrinsic from the llvm::Intrinsic namespace.  The
148    /// operands to the intrinsic follow.  The node has two results, the result
149    /// of the intrinsic and an output chain.
150    INTRINSIC_W_CHAIN,
151
152    /// OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...)
153    /// This node represents a target intrinsic function with side effects that
154    /// does not return a result.  The first operand is a chain pointer.  The
155    /// second is the ID number of the intrinsic from the llvm::Intrinsic
156    /// namespace.  The operands to the intrinsic follow.
157    INTRINSIC_VOID,
158
159    // CopyToReg - This node has three operands: a chain, a register number to
160    // set to this value, and a value.
161    CopyToReg,
162
163    // CopyFromReg - This node indicates that the input value is a virtual or
164    // physical register that is defined outside of the scope of this
165    // SelectionDAG.  The register is available from the RegisterSDNode object.
166    CopyFromReg,
167
168    // UNDEF - An undefined node
169    UNDEF,
170
171    /// FORMAL_ARGUMENTS(CHAIN, CC#, ISVARARG, FLAG0, ..., FLAGn) - This node
172    /// represents the formal arguments for a function.  CC# is a Constant value
173    /// indicating the calling convention of the function, and ISVARARG is a
174    /// flag that indicates whether the function is varargs or not. This node
175    /// has one result value for each incoming argument, plus one for the output
176    /// chain. It must be custom legalized. See description of CALL node for
177    /// FLAG argument contents explanation.
178    ///
179    FORMAL_ARGUMENTS,
180
181    /// RV1, RV2...RVn, CHAIN = CALL(CHAIN, CC#, ISVARARG, ISTAILCALL, CALLEE,
182    ///                              ARG0, FLAG0, ARG1, FLAG1, ... ARGn, FLAGn)
183    /// This node represents a fully general function call, before the legalizer
184    /// runs.  This has one result value for each argument / flag pair, plus
185    /// a chain result. It must be custom legalized. Flag argument indicates
186    /// misc. argument attributes. Currently:
187    /// Bit 0 - signness
188    /// Bit 1 - 'inreg' attribute
189    /// Bit 2 - 'sret' attribute
190    /// Bit 4 - 'byval' attribute
191    /// Bit 5 - 'nest' attribute
192    /// Bit 6-9 - alignment of byval structures
193    /// Bit 10-26 - size of byval structures
194    /// Bits 31:27 - argument ABI alignment in the first argument piece and
195    /// alignment '1' in other argument pieces.
196    CALL,
197
198    // EXTRACT_ELEMENT - This is used to get the lower or upper (determined by
199    // a Constant, which is required to be operand #1) half of the integer or
200    // float value specified as operand #0.  This is only for use before
201    // legalization, for values that will be broken into multiple registers.
202    EXTRACT_ELEMENT,
203
204    // BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.  Given
205    // two values of the same integer value type, this produces a value twice as
206    // big.  Like EXTRACT_ELEMENT, this can only be used before legalization.
207    BUILD_PAIR,
208
209    // MERGE_VALUES - This node takes multiple discrete operands and returns
210    // them all as its individual results.  This nodes has exactly the same
211    // number of inputs and outputs, and is only valid before legalization.
212    // This node is useful for some pieces of the code generator that want to
213    // think about a single node with multiple results, not multiple nodes.
214    MERGE_VALUES,
215
216    // Simple integer binary arithmetic operators.
217    ADD, SUB, MUL, SDIV, UDIV, SREM, UREM,
218
219    // SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing
220    // a signed/unsigned value of type i[2*N], and return the full value as
221    // two results, each of type iN.
222    SMUL_LOHI, UMUL_LOHI,
223
224    // SDIVREM/UDIVREM - Divide two integers and produce both a quotient and
225    // remainder result.
226    SDIVREM, UDIVREM,
227
228    // CARRY_FALSE - This node is used when folding other nodes,
229    // like ADDC/SUBC, which indicate the carry result is always false.
230    CARRY_FALSE,
231
232    // Carry-setting nodes for multiple precision addition and subtraction.
233    // These nodes take two operands of the same value type, and produce two
234    // results.  The first result is the normal add or sub result, the second
235    // result is the carry flag result.
236    ADDC, SUBC,
237
238    // Carry-using nodes for multiple precision addition and subtraction.  These
239    // nodes take three operands: The first two are the normal lhs and rhs to
240    // the add or sub, and the third is the input carry flag.  These nodes
241    // produce two results; the normal result of the add or sub, and the output
242    // carry flag.  These nodes both read and write a carry flag to allow them
243    // to them to be chained together for add and sub of arbitrarily large
244    // values.
245    ADDE, SUBE,
246
247    // Simple binary floating point operators.
248    FADD, FSUB, FMUL, FDIV, FREM,
249
250    // FCOPYSIGN(X, Y) - Return the value of X with the sign of Y.  NOTE: This
251    // DAG node does not require that X and Y have the same type, just that they
252    // are both floating point.  X and the result must have the same type.
253    // FCOPYSIGN(f32, f64) is allowed.
254    FCOPYSIGN,
255
256    // INT = FGETSIGN(FP) - Return the sign bit of the specified floating point
257    // value as an integer 0/1 value.
258    FGETSIGN,
259
260    /// BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a vector
261    /// with the specified, possibly variable, elements.  The number of elements
262    /// is required to be a power of two.
263    BUILD_VECTOR,
264
265    /// INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element
266    /// at IDX replaced with VAL.  If the type of VAL is larger than the vector
267    /// element type then VAL is truncated before replacement.
268    INSERT_VECTOR_ELT,
269
270    /// EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR
271    /// identified by the (potentially variable) element number IDX.
272    EXTRACT_VECTOR_ELT,
273
274    /// CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of
275    /// vector type with the same length and element type, this produces a
276    /// concatenated vector result value, with length equal to the sum of the
277    /// lengths of the input vectors.
278    CONCAT_VECTORS,
279
280    /// EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR (an
281    /// vector value) starting with the (potentially variable) element number
282    /// IDX, which must be a multiple of the result vector length.
283    EXTRACT_SUBVECTOR,
284
285    /// VECTOR_SHUFFLE(VEC1, VEC2, SHUFFLEVEC) - Returns a vector, of the same
286    /// type as VEC1/VEC2.  SHUFFLEVEC is a BUILD_VECTOR of constant int values
287    /// (maybe of an illegal datatype) or undef that indicate which value each
288    /// result element will get.  The elements of VEC1/VEC2 are enumerated in
289    /// order.  This is quite similar to the Altivec 'vperm' instruction, except
290    /// that the indices must be constants and are in terms of the element size
291    /// of VEC1/VEC2, not in terms of bytes.
292    VECTOR_SHUFFLE,
293
294    /// SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a
295    /// scalar value into element 0 of the resultant vector type.  The top
296    /// elements 1 to N-1 of the N-element vector are undefined.
297    SCALAR_TO_VECTOR,
298
299    // EXTRACT_SUBREG - This node is used to extract a sub-register value.
300    // This node takes a superreg and a constant sub-register index as operands.
301    // Note sub-register indices must be increasing. That is, if the
302    // sub-register index of a 8-bit sub-register is N, then the index for a
303    // 16-bit sub-register must be at least N+1.
304    EXTRACT_SUBREG,
305
306    // INSERT_SUBREG - This node is used to insert a sub-register value.
307    // This node takes a superreg, a subreg value, and a constant sub-register
308    // index as operands.
309    INSERT_SUBREG,
310
311    // MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing
312    // an unsigned/signed value of type i[2*N], then return the top part.
313    MULHU, MULHS,
314
315    // Bitwise operators - logical and, logical or, logical xor, shift left,
316    // shift right algebraic (shift in sign bits), shift right logical (shift in
317    // zeroes), rotate left, rotate right, and byteswap.
318    AND, OR, XOR, SHL, SRA, SRL, ROTL, ROTR, BSWAP,
319
320    // Counting operators
321    CTTZ, CTLZ, CTPOP,
322
323    // Select(COND, TRUEVAL, FALSEVAL)
324    SELECT,
325
326    // Select with condition operator - This selects between a true value and
327    // a false value (ops #2 and #3) based on the boolean result of comparing
328    // the lhs and rhs (ops #0 and #1) of a conditional expression with the
329    // condition code in op #4, a CondCodeSDNode.
330    SELECT_CC,
331
332    // SetCC operator - This evaluates to a boolean (i1) true value if the
333    // condition is true.  The operands to this are the left and right operands
334    // to compare (ops #0, and #1) and the condition code to compare them with
335    // (op #2) as a CondCodeSDNode.
336    SETCC,
337
338    // Vector SetCC operator - This evaluates to a vector of integer elements
339    // with the high bit in each element set to true if the comparison is true
340    // and false if the comparison is false.  All other bits in each element
341    // are undefined.  The operands to this are the left and right operands
342    // to compare (ops #0, and #1) and the condition code to compare them with
343    // (op #2) as a CondCodeSDNode.
344    VSETCC,
345
346    // SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded
347    // integer shift operations, just like ADD/SUB_PARTS.  The operation
348    // ordering is:
349    //       [Lo,Hi] = op [LoLHS,HiLHS], Amt
350    SHL_PARTS, SRA_PARTS, SRL_PARTS,
351
352    // Conversion operators.  These are all single input single output
353    // operations.  For all of these, the result type must be strictly
354    // wider or narrower (depending on the operation) than the source
355    // type.
356
357    // SIGN_EXTEND - Used for integer types, replicating the sign bit
358    // into new bits.
359    SIGN_EXTEND,
360
361    // ZERO_EXTEND - Used for integer types, zeroing the new bits.
362    ZERO_EXTEND,
363
364    // ANY_EXTEND - Used for integer types.  The high bits are undefined.
365    ANY_EXTEND,
366
367    // TRUNCATE - Completely drop the high bits.
368    TRUNCATE,
369
370    // [SU]INT_TO_FP - These operators convert integers (whose interpreted sign
371    // depends on the first letter) to floating point.
372    SINT_TO_FP,
373    UINT_TO_FP,
374
375    // SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to
376    // sign extend a small value in a large integer register (e.g. sign
377    // extending the low 8 bits of a 32-bit register to fill the top 24 bits
378    // with the 7th bit).  The size of the smaller type is indicated by the 1th
379    // operand, a ValueType node.
380    SIGN_EXTEND_INREG,
381
382    /// FP_TO_[US]INT - Convert a floating point value to a signed or unsigned
383    /// integer.
384    FP_TO_SINT,
385    FP_TO_UINT,
386
387    /// X = FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type
388    /// down to the precision of the destination VT.  TRUNC is a flag, which is
389    /// always an integer that is zero or one.  If TRUNC is 0, this is a
390    /// normal rounding, if it is 1, this FP_ROUND is known to not change the
391    /// value of Y.
392    ///
393    /// The TRUNC = 1 case is used in cases where we know that the value will
394    /// not be modified by the node, because Y is not using any of the extra
395    /// precision of source type.  This allows certain transformations like
396    /// FP_EXTEND(FP_ROUND(X,1)) -> X which are not safe for
397    /// FP_EXTEND(FP_ROUND(X,0)) because the extra bits aren't removed.
398    FP_ROUND,
399
400    // FLT_ROUNDS_ - Returns current rounding mode:
401    // -1 Undefined
402    //  0 Round to 0
403    //  1 Round to nearest
404    //  2 Round to +inf
405    //  3 Round to -inf
406    FLT_ROUNDS_,
407
408    /// X = FP_ROUND_INREG(Y, VT) - This operator takes an FP register, and
409    /// rounds it to a floating point value.  It then promotes it and returns it
410    /// in a register of the same size.  This operation effectively just
411    /// discards excess precision.  The type to round down to is specified by
412    /// the VT operand, a VTSDNode.
413    FP_ROUND_INREG,
414
415    /// X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
416    FP_EXTEND,
417
418    // BIT_CONVERT - Theis operator converts between integer and FP values, as
419    // if one was stored to memory as integer and the other was loaded from the
420    // same address (or equivalently for vector format conversions, etc).  The
421    // source and result are required to have the same bit size (e.g.
422    // f32 <-> i32).  This can also be used for int-to-int or fp-to-fp
423    // conversions, but that is a noop, deleted by getNode().
424    BIT_CONVERT,
425
426    // FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, FPOW,
427    // FCEIL, FTRUNC, FRINT, FNEARBYINT, FFLOOR - Perform various unary floating
428    // point operations. These are inspired by libm.
429    FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, FPOW,
430    FCEIL, FTRUNC, FRINT, FNEARBYINT, FFLOOR,
431
432    // LOAD and STORE have token chains as their first operand, then the same
433    // operands as an LLVM load/store instruction, then an offset node that
434    // is added / subtracted from the base pointer to form the address (for
435    // indexed memory ops).
436    LOAD, STORE,
437
438    // DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned
439    // to a specified boundary.  This node always has two return values: a new
440    // stack pointer value and a chain. The first operand is the token chain,
441    // the second is the number of bytes to allocate, and the third is the
442    // alignment boundary.  The size is guaranteed to be a multiple of the stack
443    // alignment, and the alignment is guaranteed to be bigger than the stack
444    // alignment (if required) or 0 to get standard stack alignment.
445    DYNAMIC_STACKALLOC,
446
447    // Control flow instructions.  These all have token chains.
448
449    // BR - Unconditional branch.  The first operand is the chain
450    // operand, the second is the MBB to branch to.
451    BR,
452
453    // BRIND - Indirect branch.  The first operand is the chain, the second
454    // is the value to branch to, which must be of the same type as the target's
455    // pointer type.
456    BRIND,
457
458    // BR_JT - Jumptable branch. The first operand is the chain, the second
459    // is the jumptable index, the last one is the jumptable entry index.
460    BR_JT,
461
462    // BRCOND - Conditional branch.  The first operand is the chain,
463    // the second is the condition, the third is the block to branch
464    // to if the condition is true.
465    BRCOND,
466
467    // BR_CC - Conditional branch.  The behavior is like that of SELECT_CC, in
468    // that the condition is represented as condition code, and two nodes to
469    // compare, rather than as a combined SetCC node.  The operands in order are
470    // chain, cc, lhs, rhs, block to branch to if condition is true.
471    BR_CC,
472
473    // RET - Return from function.  The first operand is the chain,
474    // and any subsequent operands are pairs of return value and return value
475    // signness for the function.  This operation can have variable number of
476    // operands.
477    RET,
478
479    // INLINEASM - Represents an inline asm block.  This node always has two
480    // return values: a chain and a flag result.  The inputs are as follows:
481    //   Operand #0   : Input chain.
482    //   Operand #1   : a ExternalSymbolSDNode with a pointer to the asm string.
483    //   Operand #2n+2: A RegisterNode.
484    //   Operand #2n+3: A TargetConstant, indicating if the reg is a use/def
485    //   Operand #last: Optional, an incoming flag.
486    INLINEASM,
487
488    // DBG_LABEL, EH_LABEL - Represents a label in mid basic block used to track
489    // locations needed for debug and exception handling tables.  These nodes
490    // take a chain as input and return a chain.
491    DBG_LABEL,
492    EH_LABEL,
493
494    // DECLARE - Represents a llvm.dbg.declare intrinsic. It's used to track
495    // local variable declarations for debugging information. First operand is
496    // a chain, while the next two operands are first two arguments (address
497    // and variable) of a llvm.dbg.declare instruction.
498    DECLARE,
499
500    // STACKSAVE - STACKSAVE has one operand, an input chain.  It produces a
501    // value, the same type as the pointer type for the system, and an output
502    // chain.
503    STACKSAVE,
504
505    // STACKRESTORE has two operands, an input chain and a pointer to restore to
506    // it returns an output chain.
507    STACKRESTORE,
508
509    // CALLSEQ_START/CALLSEQ_END - These operators mark the beginning and end of
510    // a call sequence, and carry arbitrary information that target might want
511    // to know.  The first operand is a chain, the rest are specified by the
512    // target and not touched by the DAG optimizers.
513    // CALLSEQ_START..CALLSEQ_END pairs may not be nested.
514    CALLSEQ_START,  // Beginning of a call sequence
515    CALLSEQ_END,    // End of a call sequence
516
517    // VAARG - VAARG has three operands: an input chain, a pointer, and a
518    // SRCVALUE.  It returns a pair of values: the vaarg value and a new chain.
519    VAARG,
520
521    // VACOPY - VACOPY has five operands: an input chain, a destination pointer,
522    // a source pointer, a SRCVALUE for the destination, and a SRCVALUE for the
523    // source.
524    VACOPY,
525
526    // VAEND, VASTART - VAEND and VASTART have three operands: an input chain, a
527    // pointer, and a SRCVALUE.
528    VAEND, VASTART,
529
530    // SRCVALUE - This is a node type that holds a Value* that is used to
531    // make reference to a value in the LLVM IR.
532    SRCVALUE,
533
534    // MEMOPERAND - This is a node that contains a MachineMemOperand which
535    // records information about a memory reference. This is used to make
536    // AliasAnalysis queries from the backend.
537    MEMOPERAND,
538
539    // PCMARKER - This corresponds to the pcmarker intrinsic.
540    PCMARKER,
541
542    // READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic.
543    // The only operand is a chain and a value and a chain are produced.  The
544    // value is the contents of the architecture specific cycle counter like
545    // register (or other high accuracy low latency clock source)
546    READCYCLECOUNTER,
547
548    // HANDLENODE node - Used as a handle for various purposes.
549    HANDLENODE,
550
551    // DBG_STOPPOINT - This node is used to represent a source location for
552    // debug info.  It takes token chain as input, and carries a line number,
553    // column number, and a pointer to a CompileUnitDesc object identifying
554    // the containing compilation unit.  It produces a token chain as output.
555    DBG_STOPPOINT,
556
557    // DEBUG_LOC - This node is used to represent source line information
558    // embedded in the code.  It takes a token chain as input, then a line
559    // number, then a column then a file id (provided by MachineModuleInfo.) It
560    // produces a token chain as output.
561    DEBUG_LOC,
562
563    // TRAMPOLINE - This corresponds to the init_trampoline intrinsic.
564    // It takes as input a token chain, the pointer to the trampoline,
565    // the pointer to the nested function, the pointer to pass for the
566    // 'nest' parameter, a SRCVALUE for the trampoline and another for
567    // the nested function (allowing targets to access the original
568    // Function*).  It produces the result of the intrinsic and a token
569    // chain as output.
570    TRAMPOLINE,
571
572    // TRAP - Trapping instruction
573    TRAP,
574
575    // PREFETCH - This corresponds to a prefetch intrinsic. It takes chains are
576    // their first operand. The other operands are the address to prefetch,
577    // read / write specifier, and locality specifier.
578    PREFETCH,
579
580    // OUTCHAIN = MEMBARRIER(INCHAIN, load-load, load-store, store-load,
581    //                       store-store, device)
582    // This corresponds to the memory.barrier intrinsic.
583    // it takes an input chain, 4 operands to specify the type of barrier, an
584    // operand specifying if the barrier applies to device and uncached memory
585    // and produces an output chain.
586    MEMBARRIER,
587
588    // Val, OUTCHAIN = ATOMIC_CMP_SWAP(INCHAIN, ptr, cmp, swap)
589    // this corresponds to the atomic.lcs intrinsic.
590    // cmp is compared to *ptr, and if equal, swap is stored in *ptr.
591    // the return is always the original value in *ptr
592    ATOMIC_CMP_SWAP,
593
594    // Val, OUTCHAIN = ATOMIC_LOAD_ADD(INCHAIN, ptr, amt)
595    // this corresponds to the atomic.las intrinsic.
596    // *ptr + amt is stored to *ptr atomically.
597    // the return is always the original value in *ptr
598    ATOMIC_LOAD_ADD,
599
600    // Val, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amt)
601    // this corresponds to the atomic.swap intrinsic.
602    // amt is stored to *ptr atomically.
603    // the return is always the original value in *ptr
604    ATOMIC_SWAP,
605
606    // Val, OUTCHAIN = ATOMIC_LOAD_SUB(INCHAIN, ptr, amt)
607    // this corresponds to the atomic.lss intrinsic.
608    // *ptr - amt is stored to *ptr atomically.
609    // the return is always the original value in *ptr
610    ATOMIC_LOAD_SUB,
611
612    // Val, OUTCHAIN = ATOMIC_L[OpName]S(INCHAIN, ptr, amt)
613    // this corresponds to the atomic.[OpName] intrinsic.
614    // op(*ptr, amt) is stored to *ptr atomically.
615    // the return is always the original value in *ptr
616    ATOMIC_LOAD_AND,
617    ATOMIC_LOAD_OR,
618    ATOMIC_LOAD_XOR,
619    ATOMIC_LOAD_NAND,
620    ATOMIC_LOAD_MIN,
621    ATOMIC_LOAD_MAX,
622    ATOMIC_LOAD_UMIN,
623    ATOMIC_LOAD_UMAX,
624
625    // BUILTIN_OP_END - This must be the last enum value in this list.
626    BUILTIN_OP_END
627  };
628
629  /// Node predicates
630
631  /// isBuildVectorAllOnes - Return true if the specified node is a
632  /// BUILD_VECTOR where all of the elements are ~0 or undef.
633  bool isBuildVectorAllOnes(const SDNode *N);
634
635  /// isBuildVectorAllZeros - Return true if the specified node is a
636  /// BUILD_VECTOR where all of the elements are 0 or undef.
637  bool isBuildVectorAllZeros(const SDNode *N);
638
639  /// isScalarToVector - Return true if the specified node is a
640  /// ISD::SCALAR_TO_VECTOR node or a BUILD_VECTOR node where only the low
641  /// element is not an undef.
642  bool isScalarToVector(const SDNode *N);
643
644  /// isDebugLabel - Return true if the specified node represents a debug
645  /// label (i.e. ISD::DBG_LABEL or TargetInstrInfo::DBG_LABEL node).
646  bool isDebugLabel(const SDNode *N);
647
648  //===--------------------------------------------------------------------===//
649  /// MemIndexedMode enum - This enum defines the load / store indexed
650  /// addressing modes.
651  ///
652  /// UNINDEXED    "Normal" load / store. The effective address is already
653  ///              computed and is available in the base pointer. The offset
654  ///              operand is always undefined. In addition to producing a
655  ///              chain, an unindexed load produces one value (result of the
656  ///              load); an unindexed store does not produce a value.
657  ///
658  /// PRE_INC      Similar to the unindexed mode where the effective address is
659  /// PRE_DEC      the value of the base pointer add / subtract the offset.
660  ///              It considers the computation as being folded into the load /
661  ///              store operation (i.e. the load / store does the address
662  ///              computation as well as performing the memory transaction).
663  ///              The base operand is always undefined. In addition to
664  ///              producing a chain, pre-indexed load produces two values
665  ///              (result of the load and the result of the address
666  ///              computation); a pre-indexed store produces one value (result
667  ///              of the address computation).
668  ///
669  /// POST_INC     The effective address is the value of the base pointer. The
670  /// POST_DEC     value of the offset operand is then added to / subtracted
671  ///              from the base after memory transaction. In addition to
672  ///              producing a chain, post-indexed load produces two values
673  ///              (the result of the load and the result of the base +/- offset
674  ///              computation); a post-indexed store produces one value (the
675  ///              the result of the base +/- offset computation).
676  ///
677  enum MemIndexedMode {
678    UNINDEXED = 0,
679    PRE_INC,
680    PRE_DEC,
681    POST_INC,
682    POST_DEC,
683    LAST_INDEXED_MODE
684  };
685
686  //===--------------------------------------------------------------------===//
687  /// LoadExtType enum - This enum defines the three variants of LOADEXT
688  /// (load with extension).
689  ///
690  /// SEXTLOAD loads the integer operand and sign extends it to a larger
691  ///          integer result type.
692  /// ZEXTLOAD loads the integer operand and zero extends it to a larger
693  ///          integer result type.
694  /// EXTLOAD  is used for three things: floating point extending loads,
695  ///          integer extending loads [the top bits are undefined], and vector
696  ///          extending loads [load into low elt].
697  ///
698  enum LoadExtType {
699    NON_EXTLOAD = 0,
700    EXTLOAD,
701    SEXTLOAD,
702    ZEXTLOAD,
703    LAST_LOADX_TYPE
704  };
705
706  //===--------------------------------------------------------------------===//
707  /// ISD::CondCode enum - These are ordered carefully to make the bitfields
708  /// below work out, when considering SETFALSE (something that never exists
709  /// dynamically) as 0.  "U" -> Unsigned (for integer operands) or Unordered
710  /// (for floating point), "L" -> Less than, "G" -> Greater than, "E" -> Equal
711  /// to.  If the "N" column is 1, the result of the comparison is undefined if
712  /// the input is a NAN.
713  ///
714  /// All of these (except for the 'always folded ops') should be handled for
715  /// floating point.  For integer, only the SETEQ,SETNE,SETLT,SETLE,SETGT,
716  /// SETGE,SETULT,SETULE,SETUGT, and SETUGE opcodes are used.
717  ///
718  /// Note that these are laid out in a specific order to allow bit-twiddling
719  /// to transform conditions.
720  enum CondCode {
721    // Opcode          N U L G E       Intuitive operation
722    SETFALSE,      //    0 0 0 0       Always false (always folded)
723    SETOEQ,        //    0 0 0 1       True if ordered and equal
724    SETOGT,        //    0 0 1 0       True if ordered and greater than
725    SETOGE,        //    0 0 1 1       True if ordered and greater than or equal
726    SETOLT,        //    0 1 0 0       True if ordered and less than
727    SETOLE,        //    0 1 0 1       True if ordered and less than or equal
728    SETONE,        //    0 1 1 0       True if ordered and operands are unequal
729    SETO,          //    0 1 1 1       True if ordered (no nans)
730    SETUO,         //    1 0 0 0       True if unordered: isnan(X) | isnan(Y)
731    SETUEQ,        //    1 0 0 1       True if unordered or equal
732    SETUGT,        //    1 0 1 0       True if unordered or greater than
733    SETUGE,        //    1 0 1 1       True if unordered, greater than, or equal
734    SETULT,        //    1 1 0 0       True if unordered or less than
735    SETULE,        //    1 1 0 1       True if unordered, less than, or equal
736    SETUNE,        //    1 1 1 0       True if unordered or not equal
737    SETTRUE,       //    1 1 1 1       Always true (always folded)
738    // Don't care operations: undefined if the input is a nan.
739    SETFALSE2,     //  1 X 0 0 0       Always false (always folded)
740    SETEQ,         //  1 X 0 0 1       True if equal
741    SETGT,         //  1 X 0 1 0       True if greater than
742    SETGE,         //  1 X 0 1 1       True if greater than or equal
743    SETLT,         //  1 X 1 0 0       True if less than
744    SETLE,         //  1 X 1 0 1       True if less than or equal
745    SETNE,         //  1 X 1 1 0       True if not equal
746    SETTRUE2,      //  1 X 1 1 1       Always true (always folded)
747
748    SETCC_INVALID       // Marker value.
749  };
750
751  /// isSignedIntSetCC - Return true if this is a setcc instruction that
752  /// performs a signed comparison when used with integer operands.
753  inline bool isSignedIntSetCC(CondCode Code) {
754    return Code == SETGT || Code == SETGE || Code == SETLT || Code == SETLE;
755  }
756
757  /// isUnsignedIntSetCC - Return true if this is a setcc instruction that
758  /// performs an unsigned comparison when used with integer operands.
759  inline bool isUnsignedIntSetCC(CondCode Code) {
760    return Code == SETUGT || Code == SETUGE || Code == SETULT || Code == SETULE;
761  }
762
763  /// isTrueWhenEqual - Return true if the specified condition returns true if
764  /// the two operands to the condition are equal.  Note that if one of the two
765  /// operands is a NaN, this value is meaningless.
766  inline bool isTrueWhenEqual(CondCode Cond) {
767    return ((int)Cond & 1) != 0;
768  }
769
770  /// getUnorderedFlavor - This function returns 0 if the condition is always
771  /// false if an operand is a NaN, 1 if the condition is always true if the
772  /// operand is a NaN, and 2 if the condition is undefined if the operand is a
773  /// NaN.
774  inline unsigned getUnorderedFlavor(CondCode Cond) {
775    return ((int)Cond >> 3) & 3;
776  }
777
778  /// getSetCCInverse - Return the operation corresponding to !(X op Y), where
779  /// 'op' is a valid SetCC operation.
780  CondCode getSetCCInverse(CondCode Operation, bool isInteger);
781
782  /// getSetCCSwappedOperands - Return the operation corresponding to (Y op X)
783  /// when given the operation for (X op Y).
784  CondCode getSetCCSwappedOperands(CondCode Operation);
785
786  /// getSetCCOrOperation - Return the result of a logical OR between different
787  /// comparisons of identical values: ((X op1 Y) | (X op2 Y)).  This
788  /// function returns SETCC_INVALID if it is not possible to represent the
789  /// resultant comparison.
790  CondCode getSetCCOrOperation(CondCode Op1, CondCode Op2, bool isInteger);
791
792  /// getSetCCAndOperation - Return the result of a logical AND between
793  /// different comparisons of identical values: ((X op1 Y) & (X op2 Y)).  This
794  /// function returns SETCC_INVALID if it is not possible to represent the
795  /// resultant comparison.
796  CondCode getSetCCAndOperation(CondCode Op1, CondCode Op2, bool isInteger);
797}  // end llvm::ISD namespace
798
799
800//===----------------------------------------------------------------------===//
801/// SDValue - Unlike LLVM values, Selection DAG nodes may return multiple
802/// values as the result of a computation.  Many nodes return multiple values,
803/// from loads (which define a token and a return value) to ADDC (which returns
804/// a result and a carry value), to calls (which may return an arbitrary number
805/// of values).
806///
807/// As such, each use of a SelectionDAG computation must indicate the node that
808/// computes it as well as which return value to use from that node.  This pair
809/// of information is represented with the SDValue value type.
810///
811class SDValue {
812public:
813  SDNode *Val;        // The node defining the value we are using.
814  unsigned ResNo;     // Which return value of the node we are using.
815
816  SDValue() : Val(0), ResNo(0) {}
817  SDValue(SDNode *val, unsigned resno) : Val(val), ResNo(resno) {}
818
819  bool operator==(const SDValue &O) const {
820    return Val == O.Val && ResNo == O.ResNo;
821  }
822  bool operator!=(const SDValue &O) const {
823    return !operator==(O);
824  }
825  bool operator<(const SDValue &O) const {
826    return Val < O.Val || (Val == O.Val && ResNo < O.ResNo);
827  }
828
829  SDValue getValue(unsigned R) const {
830    return SDValue(Val, R);
831  }
832
833  // isOperandOf - Return true if this node is an operand of N.
834  bool isOperandOf(SDNode *N) const;
835
836  /// getValueType - Return the ValueType of the referenced return value.
837  ///
838  inline MVT getValueType() const;
839
840  /// getValueSizeInBits - Returns the size of the value in bits.
841  ///
842  unsigned getValueSizeInBits() const {
843    return getValueType().getSizeInBits();
844  }
845
846  // Forwarding methods - These forward to the corresponding methods in SDNode.
847  inline unsigned getOpcode() const;
848  inline unsigned getNumOperands() const;
849  inline const SDValue &getOperand(unsigned i) const;
850  inline uint64_t getConstantOperandVal(unsigned i) const;
851  inline bool isTargetOpcode() const;
852  inline bool isMachineOpcode() const;
853  inline unsigned getMachineOpcode() const;
854
855
856  /// reachesChainWithoutSideEffects - Return true if this operand (which must
857  /// be a chain) reaches the specified operand without crossing any
858  /// side-effecting instructions.  In practice, this looks through token
859  /// factors and non-volatile loads.  In order to remain efficient, this only
860  /// looks a couple of nodes in, it does not do an exhaustive search.
861  bool reachesChainWithoutSideEffects(SDValue Dest,
862                                      unsigned Depth = 2) const;
863
864  /// use_empty - Return true if there are no nodes using value ResNo
865  /// of node Val.
866  ///
867  inline bool use_empty() const;
868
869  /// use_empty - Return true if there is exactly one node using value
870  /// ResNo of node Val.
871  ///
872  inline bool hasOneUse() const;
873};
874
875
876template<> struct DenseMapInfo<SDValue> {
877  static inline SDValue getEmptyKey() {
878    return SDValue((SDNode*)-1, -1U);
879  }
880  static inline SDValue getTombstoneKey() {
881    return SDValue((SDNode*)-1, 0);
882  }
883  static unsigned getHashValue(const SDValue &Val) {
884    return ((unsigned)((uintptr_t)Val.Val >> 4) ^
885            (unsigned)((uintptr_t)Val.Val >> 9)) + Val.ResNo;
886  }
887  static bool isEqual(const SDValue &LHS, const SDValue &RHS) {
888    return LHS == RHS;
889  }
890  static bool isPod() { return true; }
891};
892
893/// simplify_type specializations - Allow casting operators to work directly on
894/// SDValues as if they were SDNode*'s.
895template<> struct simplify_type<SDValue> {
896  typedef SDNode* SimpleType;
897  static SimpleType getSimplifiedValue(const SDValue &Val) {
898    return static_cast<SimpleType>(Val.Val);
899  }
900};
901template<> struct simplify_type<const SDValue> {
902  typedef SDNode* SimpleType;
903  static SimpleType getSimplifiedValue(const SDValue &Val) {
904    return static_cast<SimpleType>(Val.Val);
905  }
906};
907
908/// SDUse - Represents a use of the SDNode referred by
909/// the SDValue.
910class SDUse {
911  SDValue Operand;
912  /// User - Parent node of this operand.
913  SDNode    *User;
914  /// Prev, next - Pointers to the uses list of the SDNode referred by
915  /// this operand.
916  SDUse **Prev, *Next;
917public:
918  friend class SDNode;
919  SDUse(): Operand(), User(NULL), Prev(NULL), Next(NULL) {}
920
921  SDUse(SDNode *val, unsigned resno) :
922    Operand(val,resno), User(NULL), Prev(NULL), Next(NULL) {}
923
924  SDUse& operator= (const SDValue& Op) {
925      Operand = Op;
926      Next = NULL;
927      Prev = NULL;
928      return *this;
929  }
930
931  SDUse& operator= (const SDUse& Op) {
932      Operand = Op;
933      Next = NULL;
934      Prev = NULL;
935      return *this;
936  }
937
938  SDUse *getNext() { return Next; }
939
940  SDNode *getUser() { return User; }
941
942  void setUser(SDNode *p) { User = p; }
943
944  operator SDValue() const { return Operand; }
945
946  const SDValue& getSDValue() const { return Operand; }
947
948  SDNode *&getVal() { return Operand.Val; }
949  SDNode *const &getVal() const { return Operand.Val; }
950
951  bool operator==(const SDValue &O) const {
952    return Operand == O;
953  }
954
955  bool operator!=(const SDValue &O) const {
956    return !(Operand == O);
957  }
958
959  bool operator<(const SDValue &O) const {
960    return Operand < O;
961  }
962
963protected:
964  void addToList(SDUse **List) {
965    Next = *List;
966    if (Next) Next->Prev = &Next;
967    Prev = List;
968    *List = this;
969  }
970
971  void removeFromList() {
972    *Prev = Next;
973    if (Next) Next->Prev = Prev;
974  }
975};
976
977
978/// simplify_type specializations - Allow casting operators to work directly on
979/// SDValues as if they were SDNode*'s.
980template<> struct simplify_type<SDUse> {
981  typedef SDNode* SimpleType;
982  static SimpleType getSimplifiedValue(const SDUse &Val) {
983    return static_cast<SimpleType>(Val.getVal());
984  }
985};
986template<> struct simplify_type<const SDUse> {
987  typedef SDNode* SimpleType;
988  static SimpleType getSimplifiedValue(const SDUse &Val) {
989    return static_cast<SimpleType>(Val.getVal());
990  }
991};
992
993
994/// SDOperandPtr - A helper SDValue pointer class, that can handle
995/// arrays of SDUse and arrays of SDValue objects. This is required
996/// in many places inside the SelectionDAG.
997///
998class SDOperandPtr {
999  const SDValue *ptr; // The pointer to the SDValue object
1000  int object_size;      // The size of the object containg the SDValue
1001public:
1002  SDOperandPtr() : ptr(0), object_size(0) {}
1003
1004  SDOperandPtr(SDUse * use_ptr) {
1005    ptr = &use_ptr->getSDValue();
1006    object_size = (int)sizeof(SDUse);
1007  }
1008
1009  SDOperandPtr(const SDValue * op_ptr) {
1010    ptr = op_ptr;
1011    object_size = (int)sizeof(SDValue);
1012  }
1013
1014  const SDValue operator *() { return *ptr; }
1015  const SDValue *operator ->() { return ptr; }
1016  SDOperandPtr operator ++ () {
1017    ptr = (SDValue*)((char *)ptr + object_size);
1018    return *this;
1019  }
1020
1021  SDOperandPtr operator ++ (int) {
1022    SDOperandPtr tmp = *this;
1023    ptr = (SDValue*)((char *)ptr + object_size);
1024    return tmp;
1025  }
1026
1027  SDValue operator[] (int idx) const {
1028    return *(SDValue*)((char*) ptr + object_size * idx);
1029  }
1030};
1031
1032/// SDNode - Represents one node in the SelectionDAG.
1033///
1034class SDNode : public FoldingSetNode, public ilist_node<SDNode> {
1035private:
1036  /// NodeType - The operation that this node performs.
1037  ///
1038  short NodeType;
1039
1040  /// OperandsNeedDelete - This is true if OperandList was new[]'d.  If true,
1041  /// then they will be delete[]'d when the node is destroyed.
1042  unsigned short OperandsNeedDelete : 1;
1043
1044protected:
1045  /// SubclassData - This member is defined by this class, but is not used for
1046  /// anything.  Subclasses can use it to hold whatever state they find useful.
1047  /// This field is initialized to zero by the ctor.
1048  unsigned short SubclassData : 15;
1049
1050private:
1051  /// NodeId - Unique id per SDNode in the DAG.
1052  int NodeId;
1053
1054  /// OperandList - The values that are used by this operation.
1055  ///
1056  SDUse *OperandList;
1057
1058  /// ValueList - The types of the values this node defines.  SDNode's may
1059  /// define multiple values simultaneously.
1060  const MVT *ValueList;
1061
1062  /// NumOperands/NumValues - The number of entries in the Operand/Value list.
1063  unsigned short NumOperands, NumValues;
1064
1065  /// Uses - List of uses for this SDNode.
1066  SDUse *Uses;
1067
1068  /// addUse - add SDUse to the list of uses.
1069  void addUse(SDUse &U) { U.addToList(&Uses); }
1070
1071  // Out-of-line virtual method to give class a home.
1072  virtual void ANCHOR();
1073public:
1074  virtual ~SDNode() {
1075    assert(NumOperands == 0 && "Operand list not cleared before deletion");
1076    NodeType = ISD::DELETED_NODE;
1077  }
1078
1079  //===--------------------------------------------------------------------===//
1080  //  Accessors
1081  //
1082
1083  /// getOpcode - Return the SelectionDAG opcode value for this node. For
1084  /// pre-isel nodes (those for which isMachineOpcode returns false), these
1085  /// are the opcode values in the ISD and <target>ISD namespaces. For
1086  /// post-isel opcodes, see getMachineOpcode.
1087  unsigned getOpcode()  const { return (unsigned short)NodeType; }
1088
1089  /// isTargetOpcode - Test if this node has a target-specific opcode (in the
1090  /// <target>ISD namespace).
1091  bool isTargetOpcode() const { return NodeType >= ISD::BUILTIN_OP_END; }
1092
1093  /// isMachineOpcode - Test if this node has a post-isel opcode, directly
1094  /// corresponding to a MachineInstr opcode.
1095  bool isMachineOpcode() const { return NodeType < 0; }
1096
1097  /// getMachineOpcode - This may only be called if isMachineOpcode returns
1098  /// true. It returns the MachineInstr opcode value that the node's opcode
1099  /// corresponds to.
1100  unsigned getMachineOpcode() const {
1101    assert(isMachineOpcode() && "Not a MachineInstr opcode!");
1102    return ~NodeType;
1103  }
1104
1105  /// use_empty - Return true if there are no uses of this node.
1106  ///
1107  bool use_empty() const { return Uses == NULL; }
1108
1109  /// hasOneUse - Return true if there is exactly one use of this node.
1110  ///
1111  bool hasOneUse() const {
1112    return !use_empty() && next(use_begin()) == use_end();
1113  }
1114
1115  /// use_size - Return the number of uses of this node. This method takes
1116  /// time proportional to the number of uses.
1117  ///
1118  size_t use_size() const { return std::distance(use_begin(), use_end()); }
1119
1120  /// getNodeId - Return the unique node id.
1121  ///
1122  int getNodeId() const { return NodeId; }
1123
1124  /// setNodeId - Set unique node id.
1125  void setNodeId(int Id) { NodeId = Id; }
1126
1127  /// use_iterator - This class provides iterator support for SDUse
1128  /// operands that use a specific SDNode.
1129  class use_iterator
1130    : public forward_iterator<SDUse, ptrdiff_t> {
1131    SDUse *Op;
1132    explicit use_iterator(SDUse *op) : Op(op) {
1133    }
1134    friend class SDNode;
1135  public:
1136    typedef forward_iterator<SDUse, ptrdiff_t>::reference reference;
1137    typedef forward_iterator<SDUse, ptrdiff_t>::pointer pointer;
1138
1139    use_iterator(const use_iterator &I) : Op(I.Op) {}
1140    use_iterator() : Op(0) {}
1141
1142    bool operator==(const use_iterator &x) const {
1143      return Op == x.Op;
1144    }
1145    bool operator!=(const use_iterator &x) const {
1146      return !operator==(x);
1147    }
1148
1149    /// atEnd - return true if this iterator is at the end of uses list.
1150    bool atEnd() const { return Op == 0; }
1151
1152    // Iterator traversal: forward iteration only.
1153    use_iterator &operator++() {          // Preincrement
1154      assert(Op && "Cannot increment end iterator!");
1155      Op = Op->getNext();
1156      return *this;
1157    }
1158
1159    use_iterator operator++(int) {        // Postincrement
1160      use_iterator tmp = *this; ++*this; return tmp;
1161    }
1162
1163    /// Retrieve a pointer to the current user node.
1164    SDNode *operator*() const {
1165      assert(Op && "Cannot dereference end iterator!");
1166      return Op->getUser();
1167    }
1168
1169    SDNode *operator->() const { return operator*(); }
1170
1171    SDUse &getUse() const { return *Op; }
1172
1173    /// getOperandNo - Retrive the operand # of this use in its user.
1174    ///
1175    unsigned getOperandNo() const {
1176      assert(Op && "Cannot dereference end iterator!");
1177      return (unsigned)(Op - Op->getUser()->OperandList);
1178    }
1179  };
1180
1181  /// use_begin/use_end - Provide iteration support to walk over all uses
1182  /// of an SDNode.
1183
1184  use_iterator use_begin() const {
1185    return use_iterator(Uses);
1186  }
1187
1188  static use_iterator use_end() { return use_iterator(0); }
1189
1190
1191  /// hasNUsesOfValue - Return true if there are exactly NUSES uses of the
1192  /// indicated value.  This method ignores uses of other values defined by this
1193  /// operation.
1194  bool hasNUsesOfValue(unsigned NUses, unsigned Value) const;
1195
1196  /// hasAnyUseOfValue - Return true if there are any use of the indicated
1197  /// value. This method ignores uses of other values defined by this operation.
1198  bool hasAnyUseOfValue(unsigned Value) const;
1199
1200  /// isOnlyUserOf - Return true if this node is the only use of N.
1201  ///
1202  bool isOnlyUserOf(SDNode *N) const;
1203
1204  /// isOperandOf - Return true if this node is an operand of N.
1205  ///
1206  bool isOperandOf(SDNode *N) const;
1207
1208  /// isPredecessorOf - Return true if this node is a predecessor of N. This
1209  /// node is either an operand of N or it can be reached by recursively
1210  /// traversing up the operands.
1211  /// NOTE: this is an expensive method. Use it carefully.
1212  bool isPredecessorOf(SDNode *N) const;
1213
1214  /// getNumOperands - Return the number of values used by this operation.
1215  ///
1216  unsigned getNumOperands() const { return NumOperands; }
1217
1218  /// getConstantOperandVal - Helper method returns the integer value of a
1219  /// ConstantSDNode operand.
1220  uint64_t getConstantOperandVal(unsigned Num) const;
1221
1222  const SDValue &getOperand(unsigned Num) const {
1223    assert(Num < NumOperands && "Invalid child # of SDNode!");
1224    return OperandList[Num].getSDValue();
1225  }
1226
1227  typedef SDUse* op_iterator;
1228  op_iterator op_begin() const { return OperandList; }
1229  op_iterator op_end() const { return OperandList+NumOperands; }
1230
1231
1232  SDVTList getVTList() const {
1233    SDVTList X = { ValueList, NumValues };
1234    return X;
1235  };
1236
1237  /// getNumValues - Return the number of values defined/returned by this
1238  /// operator.
1239  ///
1240  unsigned getNumValues() const { return NumValues; }
1241
1242  /// getValueType - Return the type of a specified result.
1243  ///
1244  MVT getValueType(unsigned ResNo) const {
1245    assert(ResNo < NumValues && "Illegal result number!");
1246    return ValueList[ResNo];
1247  }
1248
1249  /// getValueSizeInBits - Returns MVT::getSizeInBits(getValueType(ResNo)).
1250  ///
1251  unsigned getValueSizeInBits(unsigned ResNo) const {
1252    return getValueType(ResNo).getSizeInBits();
1253  }
1254
1255  typedef const MVT* value_iterator;
1256  value_iterator value_begin() const { return ValueList; }
1257  value_iterator value_end() const { return ValueList+NumValues; }
1258
1259  /// getOperationName - Return the opcode of this operation for printing.
1260  ///
1261  std::string getOperationName(const SelectionDAG *G = 0) const;
1262  static const char* getIndexedModeName(ISD::MemIndexedMode AM);
1263  void print(raw_ostream &OS, const SelectionDAG *G = 0) const;
1264  void dump() const;
1265  void dump(const SelectionDAG *G) const;
1266
1267  static bool classof(const SDNode *) { return true; }
1268
1269  /// Profile - Gather unique data for the node.
1270  ///
1271  void Profile(FoldingSetNodeID &ID) const;
1272
1273protected:
1274  friend class SelectionDAG;
1275  friend class ilist_traits<SDNode>;
1276
1277  /// getValueTypeList - Return a pointer to the specified value type.
1278  ///
1279  static const MVT *getValueTypeList(MVT VT);
1280  static SDVTList getSDVTList(MVT VT) {
1281    SDVTList Ret = { getValueTypeList(VT), 1 };
1282    return Ret;
1283  }
1284
1285  SDNode(unsigned Opc, SDVTList VTs, const SDValue *Ops, unsigned NumOps)
1286    : NodeType(Opc), OperandsNeedDelete(true), SubclassData(0),
1287      NodeId(-1), Uses(NULL) {
1288    NumOperands = NumOps;
1289    OperandList = NumOps ? new SDUse[NumOperands] : 0;
1290
1291    for (unsigned i = 0; i != NumOps; ++i) {
1292      OperandList[i] = Ops[i];
1293      OperandList[i].setUser(this);
1294      Ops[i].Val->addUse(OperandList[i]);
1295    }
1296
1297    ValueList = VTs.VTs;
1298    NumValues = VTs.NumVTs;
1299  }
1300
1301  SDNode(unsigned Opc, SDVTList VTs, const SDUse *Ops, unsigned NumOps)
1302    : NodeType(Opc), OperandsNeedDelete(true), SubclassData(0),
1303      NodeId(-1), Uses(NULL) {
1304    OperandsNeedDelete = true;
1305    NumOperands = NumOps;
1306    OperandList = NumOps ? new SDUse[NumOperands] : 0;
1307
1308    for (unsigned i = 0; i != NumOps; ++i) {
1309      OperandList[i] = Ops[i];
1310      OperandList[i].setUser(this);
1311      Ops[i].getVal()->addUse(OperandList[i]);
1312    }
1313
1314    ValueList = VTs.VTs;
1315    NumValues = VTs.NumVTs;
1316  }
1317
1318  /// This constructor adds no operands itself; operands can be
1319  /// set later with InitOperands.
1320  SDNode(unsigned Opc, SDVTList VTs)
1321    : NodeType(Opc), OperandsNeedDelete(false), SubclassData(0),
1322      NodeId(-1), Uses(NULL) {
1323    NumOperands = 0;
1324    OperandList = 0;
1325    ValueList = VTs.VTs;
1326    NumValues = VTs.NumVTs;
1327  }
1328
1329  /// InitOperands - Initialize the operands list of this node with the
1330  /// specified values, which are part of the node (thus they don't need to be
1331  /// copied in or allocated).
1332  void InitOperands(SDUse *Ops, unsigned NumOps) {
1333    assert(OperandList == 0 && "Operands already set!");
1334    NumOperands = NumOps;
1335    OperandList = Ops;
1336    Uses = NULL;
1337
1338    for (unsigned i = 0; i != NumOps; ++i) {
1339      OperandList[i].setUser(this);
1340      Ops[i].getVal()->addUse(OperandList[i]);
1341    }
1342  }
1343
1344  /// DropOperands - Release the operands and set this node to have
1345  /// zero operands.
1346  void DropOperands();
1347
1348  void addUser(unsigned i, SDNode *User) {
1349    assert(User->OperandList[i].getUser() && "Node without parent");
1350    addUse(User->OperandList[i]);
1351  }
1352
1353  void removeUser(unsigned i, SDNode *User) {
1354    assert(User->OperandList[i].getUser() && "Node without parent");
1355    SDUse &Op = User->OperandList[i];
1356    Op.removeFromList();
1357  }
1358};
1359
1360
1361// Define inline functions from the SDValue class.
1362
1363inline unsigned SDValue::getOpcode() const {
1364  return Val->getOpcode();
1365}
1366inline MVT SDValue::getValueType() const {
1367  return Val->getValueType(ResNo);
1368}
1369inline unsigned SDValue::getNumOperands() const {
1370  return Val->getNumOperands();
1371}
1372inline const SDValue &SDValue::getOperand(unsigned i) const {
1373  return Val->getOperand(i);
1374}
1375inline uint64_t SDValue::getConstantOperandVal(unsigned i) const {
1376  return Val->getConstantOperandVal(i);
1377}
1378inline bool SDValue::isTargetOpcode() const {
1379  return Val->isTargetOpcode();
1380}
1381inline bool SDValue::isMachineOpcode() const {
1382  return Val->isMachineOpcode();
1383}
1384inline unsigned SDValue::getMachineOpcode() const {
1385  return Val->getMachineOpcode();
1386}
1387inline bool SDValue::use_empty() const {
1388  return !Val->hasAnyUseOfValue(ResNo);
1389}
1390inline bool SDValue::hasOneUse() const {
1391  return Val->hasNUsesOfValue(1, ResNo);
1392}
1393
1394/// UnarySDNode - This class is used for single-operand SDNodes.  This is solely
1395/// to allow co-allocation of node operands with the node itself.
1396class UnarySDNode : public SDNode {
1397  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1398  SDUse Op;
1399public:
1400  UnarySDNode(unsigned Opc, SDVTList VTs, SDValue X)
1401    : SDNode(Opc, VTs) {
1402    Op = X;
1403    InitOperands(&Op, 1);
1404  }
1405};
1406
1407/// BinarySDNode - This class is used for two-operand SDNodes.  This is solely
1408/// to allow co-allocation of node operands with the node itself.
1409class BinarySDNode : public SDNode {
1410  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1411  SDUse Ops[2];
1412public:
1413  BinarySDNode(unsigned Opc, SDVTList VTs, SDValue X, SDValue Y)
1414    : SDNode(Opc, VTs) {
1415    Ops[0] = X;
1416    Ops[1] = Y;
1417    InitOperands(Ops, 2);
1418  }
1419};
1420
1421/// TernarySDNode - This class is used for three-operand SDNodes. This is solely
1422/// to allow co-allocation of node operands with the node itself.
1423class TernarySDNode : public SDNode {
1424  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1425  SDUse Ops[3];
1426public:
1427  TernarySDNode(unsigned Opc, SDVTList VTs, SDValue X, SDValue Y,
1428                SDValue Z)
1429    : SDNode(Opc, VTs) {
1430    Ops[0] = X;
1431    Ops[1] = Y;
1432    Ops[2] = Z;
1433    InitOperands(Ops, 3);
1434  }
1435};
1436
1437
1438/// HandleSDNode - This class is used to form a handle around another node that
1439/// is persistant and is updated across invocations of replaceAllUsesWith on its
1440/// operand.  This node should be directly created by end-users and not added to
1441/// the AllNodes list.
1442class HandleSDNode : public SDNode {
1443  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1444  SDUse Op;
1445public:
1446  // FIXME: Remove the "noinline" attribute once <rdar://problem/5852746> is
1447  // fixed.
1448#ifdef __GNUC__
1449  explicit __attribute__((__noinline__)) HandleSDNode(SDValue X)
1450#else
1451  explicit HandleSDNode(SDValue X)
1452#endif
1453    : SDNode(ISD::HANDLENODE, getSDVTList(MVT::Other)) {
1454    Op = X;
1455    InitOperands(&Op, 1);
1456  }
1457  ~HandleSDNode();
1458  const SDValue &getValue() const { return Op.getSDValue(); }
1459};
1460
1461/// Abstact virtual class for operations for memory operations
1462class MemSDNode : public SDNode {
1463  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1464
1465private:
1466  // MemoryVT - VT of in-memory value.
1467  MVT MemoryVT;
1468
1469  //! SrcValue - Memory location for alias analysis.
1470  const Value *SrcValue;
1471
1472  //! SVOffset - Memory location offset. Note that base is defined in MemSDNode
1473  int SVOffset;
1474
1475  /// Flags - the low bit indicates whether this is a volatile reference;
1476  /// the remainder is a log2 encoding of the alignment in bytes.
1477  unsigned Flags;
1478
1479public:
1480  MemSDNode(unsigned Opc, SDVTList VTs, MVT MemoryVT,
1481            const Value *srcValue, int SVOff,
1482            unsigned alignment, bool isvolatile);
1483
1484  /// Returns alignment and volatility of the memory access
1485  unsigned getAlignment() const { return (1u << (Flags >> 1)) >> 1; }
1486  bool isVolatile() const { return Flags & 1; }
1487
1488  /// Returns the SrcValue and offset that describes the location of the access
1489  const Value *getSrcValue() const { return SrcValue; }
1490  int getSrcValueOffset() const { return SVOffset; }
1491
1492  /// getMemoryVT - Return the type of the in-memory value.
1493  MVT getMemoryVT() const { return MemoryVT; }
1494
1495  /// getMemOperand - Return a MachineMemOperand object describing the memory
1496  /// reference performed by operation.
1497  MachineMemOperand getMemOperand() const;
1498
1499  const SDValue &getChain() const { return getOperand(0); }
1500  const SDValue &getBasePtr() const {
1501    return getOperand(getOpcode() == ISD::STORE ? 2 : 1);
1502  }
1503
1504  /// getRawFlags - Represent the flags as a bunch of bits.
1505  ///
1506  unsigned getRawFlags() const { return Flags; }
1507
1508  // Methods to support isa and dyn_cast
1509  static bool classof(const MemSDNode *) { return true; }
1510  static bool classof(const SDNode *N) {
1511    return N->getOpcode() == ISD::LOAD  ||
1512           N->getOpcode() == ISD::STORE ||
1513           N->getOpcode() == ISD::ATOMIC_CMP_SWAP  ||
1514           N->getOpcode() == ISD::ATOMIC_LOAD_ADD  ||
1515           N->getOpcode() == ISD::ATOMIC_SWAP      ||
1516           N->getOpcode() == ISD::ATOMIC_LOAD_SUB  ||
1517           N->getOpcode() == ISD::ATOMIC_LOAD_AND  ||
1518           N->getOpcode() == ISD::ATOMIC_LOAD_OR   ||
1519           N->getOpcode() == ISD::ATOMIC_LOAD_XOR  ||
1520           N->getOpcode() == ISD::ATOMIC_LOAD_NAND ||
1521           N->getOpcode() == ISD::ATOMIC_LOAD_MIN  ||
1522           N->getOpcode() == ISD::ATOMIC_LOAD_MAX  ||
1523           N->getOpcode() == ISD::ATOMIC_LOAD_UMIN ||
1524           N->getOpcode() == ISD::ATOMIC_LOAD_UMAX;
1525  }
1526};
1527
1528/// Atomic operations node
1529class AtomicSDNode : public MemSDNode {
1530  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1531  SDUse Ops[4];
1532
1533 public:
1534  // Opc:   opcode for atomic
1535  // VTL:    value type list
1536  // Chain:  memory chain for operaand
1537  // Ptr:    address to update as a SDValue
1538  // Cmp:    compare value
1539  // Swp:    swap value
1540  // SrcVal: address to update as a Value (used for MemOperand)
1541  // Align:  alignment of memory
1542  AtomicSDNode(unsigned Opc, SDVTList VTL, SDValue Chain, SDValue Ptr,
1543               SDValue Cmp, SDValue Swp, const Value* SrcVal,
1544               unsigned Align=0)
1545    : MemSDNode(Opc, VTL, Cmp.getValueType(), SrcVal, /*SVOffset=*/0,
1546                Align, /*isVolatile=*/true) {
1547    Ops[0] = Chain;
1548    Ops[1] = Ptr;
1549    Ops[2] = Swp;
1550    Ops[3] = Cmp;
1551    InitOperands(Ops, 4);
1552  }
1553  AtomicSDNode(unsigned Opc, SDVTList VTL, SDValue Chain, SDValue Ptr,
1554               SDValue Val, const Value* SrcVal, unsigned Align=0)
1555    : MemSDNode(Opc, VTL, Val.getValueType(), SrcVal, /*SVOffset=*/0,
1556                Align, /*isVolatile=*/true) {
1557    Ops[0] = Chain;
1558    Ops[1] = Ptr;
1559    Ops[2] = Val;
1560    InitOperands(Ops, 3);
1561  }
1562
1563  const SDValue &getBasePtr() const { return getOperand(1); }
1564  const SDValue &getVal() const { return getOperand(2); }
1565
1566  bool isCompareAndSwap() const { return getOpcode() == ISD::ATOMIC_CMP_SWAP; }
1567
1568  // Methods to support isa and dyn_cast
1569  static bool classof(const AtomicSDNode *) { return true; }
1570  static bool classof(const SDNode *N) {
1571    return N->getOpcode() == ISD::ATOMIC_CMP_SWAP  ||
1572           N->getOpcode() == ISD::ATOMIC_LOAD_ADD  ||
1573           N->getOpcode() == ISD::ATOMIC_SWAP      ||
1574           N->getOpcode() == ISD::ATOMIC_LOAD_SUB  ||
1575           N->getOpcode() == ISD::ATOMIC_LOAD_AND  ||
1576           N->getOpcode() == ISD::ATOMIC_LOAD_OR   ||
1577           N->getOpcode() == ISD::ATOMIC_LOAD_XOR  ||
1578           N->getOpcode() == ISD::ATOMIC_LOAD_NAND ||
1579           N->getOpcode() == ISD::ATOMIC_LOAD_MIN  ||
1580           N->getOpcode() == ISD::ATOMIC_LOAD_MAX  ||
1581           N->getOpcode() == ISD::ATOMIC_LOAD_UMIN ||
1582           N->getOpcode() == ISD::ATOMIC_LOAD_UMAX;
1583  }
1584};
1585
1586class ConstantSDNode : public SDNode {
1587  APInt Value;
1588  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1589protected:
1590  friend class SelectionDAG;
1591  ConstantSDNode(bool isTarget, const APInt &val, MVT VT)
1592    : SDNode(isTarget ? ISD::TargetConstant : ISD::Constant, getSDVTList(VT)),
1593      Value(val) {
1594  }
1595public:
1596
1597  const APInt &getAPIntValue() const { return Value; }
1598  uint64_t getValue() const { return Value.getZExtValue(); }
1599
1600  int64_t getSignExtended() const {
1601    unsigned Bits = getValueType(0).getSizeInBits();
1602    return ((int64_t)Value.getZExtValue() << (64-Bits)) >> (64-Bits);
1603  }
1604
1605  bool isNullValue() const { return Value == 0; }
1606  bool isAllOnesValue() const {
1607    return Value == getValueType(0).getIntegerVTBitMask();
1608  }
1609
1610  static bool classof(const ConstantSDNode *) { return true; }
1611  static bool classof(const SDNode *N) {
1612    return N->getOpcode() == ISD::Constant ||
1613           N->getOpcode() == ISD::TargetConstant;
1614  }
1615};
1616
1617class ConstantFPSDNode : public SDNode {
1618  APFloat Value;
1619  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1620protected:
1621  friend class SelectionDAG;
1622  ConstantFPSDNode(bool isTarget, const APFloat& val, MVT VT)
1623    : SDNode(isTarget ? ISD::TargetConstantFP : ISD::ConstantFP,
1624             getSDVTList(VT)), Value(val) {
1625  }
1626public:
1627
1628  const APFloat& getValueAPF() const { return Value; }
1629
1630  /// isExactlyValue - We don't rely on operator== working on double values, as
1631  /// it returns true for things that are clearly not equal, like -0.0 and 0.0.
1632  /// As such, this method can be used to do an exact bit-for-bit comparison of
1633  /// two floating point values.
1634
1635  /// We leave the version with the double argument here because it's just so
1636  /// convenient to write "2.0" and the like.  Without this function we'd
1637  /// have to duplicate its logic everywhere it's called.
1638  bool isExactlyValue(double V) const {
1639    // convert is not supported on this type
1640    if (&Value.getSemantics() == &APFloat::PPCDoubleDouble)
1641      return false;
1642    APFloat Tmp(V);
1643    Tmp.convert(Value.getSemantics(), APFloat::rmNearestTiesToEven);
1644    return isExactlyValue(Tmp);
1645  }
1646  bool isExactlyValue(const APFloat& V) const;
1647
1648  bool isValueValidForType(MVT VT, const APFloat& Val);
1649
1650  static bool classof(const ConstantFPSDNode *) { return true; }
1651  static bool classof(const SDNode *N) {
1652    return N->getOpcode() == ISD::ConstantFP ||
1653           N->getOpcode() == ISD::TargetConstantFP;
1654  }
1655};
1656
1657class GlobalAddressSDNode : public SDNode {
1658  GlobalValue *TheGlobal;
1659  int Offset;
1660  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1661protected:
1662  friend class SelectionDAG;
1663  GlobalAddressSDNode(bool isTarget, const GlobalValue *GA, MVT VT, int o = 0);
1664public:
1665
1666  GlobalValue *getGlobal() const { return TheGlobal; }
1667  int getOffset() const { return Offset; }
1668
1669  static bool classof(const GlobalAddressSDNode *) { return true; }
1670  static bool classof(const SDNode *N) {
1671    return N->getOpcode() == ISD::GlobalAddress ||
1672           N->getOpcode() == ISD::TargetGlobalAddress ||
1673           N->getOpcode() == ISD::GlobalTLSAddress ||
1674           N->getOpcode() == ISD::TargetGlobalTLSAddress;
1675  }
1676};
1677
1678class FrameIndexSDNode : public SDNode {
1679  int FI;
1680  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1681protected:
1682  friend class SelectionDAG;
1683  FrameIndexSDNode(int fi, MVT VT, bool isTarg)
1684    : SDNode(isTarg ? ISD::TargetFrameIndex : ISD::FrameIndex, getSDVTList(VT)),
1685      FI(fi) {
1686  }
1687public:
1688
1689  int getIndex() const { return FI; }
1690
1691  static bool classof(const FrameIndexSDNode *) { return true; }
1692  static bool classof(const SDNode *N) {
1693    return N->getOpcode() == ISD::FrameIndex ||
1694           N->getOpcode() == ISD::TargetFrameIndex;
1695  }
1696};
1697
1698class JumpTableSDNode : public SDNode {
1699  int JTI;
1700  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1701protected:
1702  friend class SelectionDAG;
1703  JumpTableSDNode(int jti, MVT VT, bool isTarg)
1704    : SDNode(isTarg ? ISD::TargetJumpTable : ISD::JumpTable, getSDVTList(VT)),
1705      JTI(jti) {
1706  }
1707public:
1708
1709  int getIndex() const { return JTI; }
1710
1711  static bool classof(const JumpTableSDNode *) { return true; }
1712  static bool classof(const SDNode *N) {
1713    return N->getOpcode() == ISD::JumpTable ||
1714           N->getOpcode() == ISD::TargetJumpTable;
1715  }
1716};
1717
1718class ConstantPoolSDNode : public SDNode {
1719  union {
1720    Constant *ConstVal;
1721    MachineConstantPoolValue *MachineCPVal;
1722  } Val;
1723  int Offset;  // It's a MachineConstantPoolValue if top bit is set.
1724  unsigned Alignment;
1725  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1726protected:
1727  friend class SelectionDAG;
1728  ConstantPoolSDNode(bool isTarget, Constant *c, MVT VT, int o=0)
1729    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
1730             getSDVTList(VT)), Offset(o), Alignment(0) {
1731    assert((int)Offset >= 0 && "Offset is too large");
1732    Val.ConstVal = c;
1733  }
1734  ConstantPoolSDNode(bool isTarget, Constant *c, MVT VT, int o, unsigned Align)
1735    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
1736             getSDVTList(VT)), Offset(o), Alignment(Align) {
1737    assert((int)Offset >= 0 && "Offset is too large");
1738    Val.ConstVal = c;
1739  }
1740  ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v,
1741                     MVT VT, int o=0)
1742    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
1743             getSDVTList(VT)), Offset(o), Alignment(0) {
1744    assert((int)Offset >= 0 && "Offset is too large");
1745    Val.MachineCPVal = v;
1746    Offset |= 1 << (sizeof(unsigned)*8-1);
1747  }
1748  ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v,
1749                     MVT VT, int o, unsigned Align)
1750    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
1751             getSDVTList(VT)), Offset(o), Alignment(Align) {
1752    assert((int)Offset >= 0 && "Offset is too large");
1753    Val.MachineCPVal = v;
1754    Offset |= 1 << (sizeof(unsigned)*8-1);
1755  }
1756public:
1757
1758  bool isMachineConstantPoolEntry() const {
1759    return (int)Offset < 0;
1760  }
1761
1762  Constant *getConstVal() const {
1763    assert(!isMachineConstantPoolEntry() && "Wrong constantpool type");
1764    return Val.ConstVal;
1765  }
1766
1767  MachineConstantPoolValue *getMachineCPVal() const {
1768    assert(isMachineConstantPoolEntry() && "Wrong constantpool type");
1769    return Val.MachineCPVal;
1770  }
1771
1772  int getOffset() const {
1773    return Offset & ~(1 << (sizeof(unsigned)*8-1));
1774  }
1775
1776  // Return the alignment of this constant pool object, which is either 0 (for
1777  // default alignment) or log2 of the desired value.
1778  unsigned getAlignment() const { return Alignment; }
1779
1780  const Type *getType() const;
1781
1782  static bool classof(const ConstantPoolSDNode *) { return true; }
1783  static bool classof(const SDNode *N) {
1784    return N->getOpcode() == ISD::ConstantPool ||
1785           N->getOpcode() == ISD::TargetConstantPool;
1786  }
1787};
1788
1789class BasicBlockSDNode : public SDNode {
1790  MachineBasicBlock *MBB;
1791  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1792protected:
1793  friend class SelectionDAG;
1794  explicit BasicBlockSDNode(MachineBasicBlock *mbb)
1795    : SDNode(ISD::BasicBlock, getSDVTList(MVT::Other)), MBB(mbb) {
1796  }
1797public:
1798
1799  MachineBasicBlock *getBasicBlock() const { return MBB; }
1800
1801  static bool classof(const BasicBlockSDNode *) { return true; }
1802  static bool classof(const SDNode *N) {
1803    return N->getOpcode() == ISD::BasicBlock;
1804  }
1805};
1806
1807/// SrcValueSDNode - An SDNode that holds an arbitrary LLVM IR Value. This is
1808/// used when the SelectionDAG needs to make a simple reference to something
1809/// in the LLVM IR representation.
1810///
1811/// Note that this is not used for carrying alias information; that is done
1812/// with MemOperandSDNode, which includes a Value which is required to be a
1813/// pointer, and several other fields specific to memory references.
1814///
1815class SrcValueSDNode : public SDNode {
1816  const Value *V;
1817  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1818protected:
1819  friend class SelectionDAG;
1820  /// Create a SrcValue for a general value.
1821  explicit SrcValueSDNode(const Value *v)
1822    : SDNode(ISD::SRCVALUE, getSDVTList(MVT::Other)), V(v) {}
1823
1824public:
1825  /// getValue - return the contained Value.
1826  const Value *getValue() const { return V; }
1827
1828  static bool classof(const SrcValueSDNode *) { return true; }
1829  static bool classof(const SDNode *N) {
1830    return N->getOpcode() == ISD::SRCVALUE;
1831  }
1832};
1833
1834
1835/// MemOperandSDNode - An SDNode that holds a MachineMemOperand. This is
1836/// used to represent a reference to memory after ISD::LOAD
1837/// and ISD::STORE have been lowered.
1838///
1839class MemOperandSDNode : public SDNode {
1840  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1841protected:
1842  friend class SelectionDAG;
1843  /// Create a MachineMemOperand node
1844  explicit MemOperandSDNode(const MachineMemOperand &mo)
1845    : SDNode(ISD::MEMOPERAND, getSDVTList(MVT::Other)), MO(mo) {}
1846
1847public:
1848  /// MO - The contained MachineMemOperand.
1849  const MachineMemOperand MO;
1850
1851  static bool classof(const MemOperandSDNode *) { return true; }
1852  static bool classof(const SDNode *N) {
1853    return N->getOpcode() == ISD::MEMOPERAND;
1854  }
1855};
1856
1857
1858class RegisterSDNode : public SDNode {
1859  unsigned Reg;
1860  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1861protected:
1862  friend class SelectionDAG;
1863  RegisterSDNode(unsigned reg, MVT VT)
1864    : SDNode(ISD::Register, getSDVTList(VT)), Reg(reg) {
1865  }
1866public:
1867
1868  unsigned getReg() const { return Reg; }
1869
1870  static bool classof(const RegisterSDNode *) { return true; }
1871  static bool classof(const SDNode *N) {
1872    return N->getOpcode() == ISD::Register;
1873  }
1874};
1875
1876class DbgStopPointSDNode : public SDNode {
1877  SDUse Chain;
1878  unsigned Line;
1879  unsigned Column;
1880  const CompileUnitDesc *CU;
1881  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1882protected:
1883  friend class SelectionDAG;
1884  DbgStopPointSDNode(SDValue ch, unsigned l, unsigned c,
1885                     const CompileUnitDesc *cu)
1886    : SDNode(ISD::DBG_STOPPOINT, getSDVTList(MVT::Other)),
1887      Line(l), Column(c), CU(cu) {
1888    Chain = ch;
1889    InitOperands(&Chain, 1);
1890  }
1891public:
1892  unsigned getLine() const { return Line; }
1893  unsigned getColumn() const { return Column; }
1894  const CompileUnitDesc *getCompileUnit() const { return CU; }
1895
1896  static bool classof(const DbgStopPointSDNode *) { return true; }
1897  static bool classof(const SDNode *N) {
1898    return N->getOpcode() == ISD::DBG_STOPPOINT;
1899  }
1900};
1901
1902class LabelSDNode : public SDNode {
1903  SDUse Chain;
1904  unsigned LabelID;
1905  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1906protected:
1907  friend class SelectionDAG;
1908  LabelSDNode(unsigned NodeTy, SDValue ch, unsigned id)
1909    : SDNode(NodeTy, getSDVTList(MVT::Other)), LabelID(id) {
1910    Chain = ch;
1911    InitOperands(&Chain, 1);
1912  }
1913public:
1914  unsigned getLabelID() const { return LabelID; }
1915
1916  static bool classof(const LabelSDNode *) { return true; }
1917  static bool classof(const SDNode *N) {
1918    return N->getOpcode() == ISD::DBG_LABEL ||
1919           N->getOpcode() == ISD::EH_LABEL;
1920  }
1921};
1922
1923class ExternalSymbolSDNode : public SDNode {
1924  const char *Symbol;
1925  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1926protected:
1927  friend class SelectionDAG;
1928  ExternalSymbolSDNode(bool isTarget, const char *Sym, MVT VT)
1929    : SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol,
1930             getSDVTList(VT)), Symbol(Sym) {
1931  }
1932public:
1933
1934  const char *getSymbol() const { return Symbol; }
1935
1936  static bool classof(const ExternalSymbolSDNode *) { return true; }
1937  static bool classof(const SDNode *N) {
1938    return N->getOpcode() == ISD::ExternalSymbol ||
1939           N->getOpcode() == ISD::TargetExternalSymbol;
1940  }
1941};
1942
1943class CondCodeSDNode : public SDNode {
1944  ISD::CondCode Condition;
1945  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1946protected:
1947  friend class SelectionDAG;
1948  explicit CondCodeSDNode(ISD::CondCode Cond)
1949    : SDNode(ISD::CONDCODE, getSDVTList(MVT::Other)), Condition(Cond) {
1950  }
1951public:
1952
1953  ISD::CondCode get() const { return Condition; }
1954
1955  static bool classof(const CondCodeSDNode *) { return true; }
1956  static bool classof(const SDNode *N) {
1957    return N->getOpcode() == ISD::CONDCODE;
1958  }
1959};
1960
1961namespace ISD {
1962  struct ArgFlagsTy {
1963  private:
1964    static const uint64_t NoFlagSet      = 0ULL;
1965    static const uint64_t ZExt           = 1ULL<<0;  ///< Zero extended
1966    static const uint64_t ZExtOffs       = 0;
1967    static const uint64_t SExt           = 1ULL<<1;  ///< Sign extended
1968    static const uint64_t SExtOffs       = 1;
1969    static const uint64_t InReg          = 1ULL<<2;  ///< Passed in register
1970    static const uint64_t InRegOffs      = 2;
1971    static const uint64_t SRet           = 1ULL<<3;  ///< Hidden struct-ret ptr
1972    static const uint64_t SRetOffs       = 3;
1973    static const uint64_t ByVal          = 1ULL<<4;  ///< Struct passed by value
1974    static const uint64_t ByValOffs      = 4;
1975    static const uint64_t Nest           = 1ULL<<5;  ///< Nested fn static chain
1976    static const uint64_t NestOffs       = 5;
1977    static const uint64_t ByValAlign     = 0xFULL << 6; //< Struct alignment
1978    static const uint64_t ByValAlignOffs = 6;
1979    static const uint64_t Split          = 1ULL << 10;
1980    static const uint64_t SplitOffs      = 10;
1981    static const uint64_t OrigAlign      = 0x1FULL<<27;
1982    static const uint64_t OrigAlignOffs  = 27;
1983    static const uint64_t ByValSize      = 0xffffffffULL << 32; //< Struct size
1984    static const uint64_t ByValSizeOffs  = 32;
1985
1986    static const uint64_t One            = 1ULL; //< 1 of this type, for shifts
1987
1988    uint64_t Flags;
1989  public:
1990    ArgFlagsTy() : Flags(0) { }
1991
1992    bool isZExt()   const { return Flags & ZExt; }
1993    void setZExt()  { Flags |= One << ZExtOffs; }
1994
1995    bool isSExt()   const { return Flags & SExt; }
1996    void setSExt()  { Flags |= One << SExtOffs; }
1997
1998    bool isInReg()  const { return Flags & InReg; }
1999    void setInReg() { Flags |= One << InRegOffs; }
2000
2001    bool isSRet()   const { return Flags & SRet; }
2002    void setSRet()  { Flags |= One << SRetOffs; }
2003
2004    bool isByVal()  const { return Flags & ByVal; }
2005    void setByVal() { Flags |= One << ByValOffs; }
2006
2007    bool isNest()   const { return Flags & Nest; }
2008    void setNest()  { Flags |= One << NestOffs; }
2009
2010    unsigned getByValAlign() const {
2011      return (unsigned)
2012        ((One << ((Flags & ByValAlign) >> ByValAlignOffs)) / 2);
2013    }
2014    void setByValAlign(unsigned A) {
2015      Flags = (Flags & ~ByValAlign) |
2016        (uint64_t(Log2_32(A) + 1) << ByValAlignOffs);
2017    }
2018
2019    bool isSplit()   const { return Flags & Split; }
2020    void setSplit()  { Flags |= One << SplitOffs; }
2021
2022    unsigned getOrigAlign() const {
2023      return (unsigned)
2024        ((One << ((Flags & OrigAlign) >> OrigAlignOffs)) / 2);
2025    }
2026    void setOrigAlign(unsigned A) {
2027      Flags = (Flags & ~OrigAlign) |
2028        (uint64_t(Log2_32(A) + 1) << OrigAlignOffs);
2029    }
2030
2031    unsigned getByValSize() const {
2032      return (unsigned)((Flags & ByValSize) >> ByValSizeOffs);
2033    }
2034    void setByValSize(unsigned S) {
2035      Flags = (Flags & ~ByValSize) | (uint64_t(S) << ByValSizeOffs);
2036    }
2037
2038    /// getArgFlagsString - Returns the flags as a string, eg: "zext align:4".
2039    std::string getArgFlagsString();
2040
2041    /// getRawBits - Represent the flags as a bunch of bits.
2042    uint64_t getRawBits() const { return Flags; }
2043  };
2044}
2045
2046/// ARG_FLAGSSDNode - Leaf node holding parameter flags.
2047class ARG_FLAGSSDNode : public SDNode {
2048  ISD::ArgFlagsTy TheFlags;
2049  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
2050protected:
2051  friend class SelectionDAG;
2052  explicit ARG_FLAGSSDNode(ISD::ArgFlagsTy Flags)
2053    : SDNode(ISD::ARG_FLAGS, getSDVTList(MVT::Other)), TheFlags(Flags) {
2054  }
2055public:
2056  ISD::ArgFlagsTy getArgFlags() const { return TheFlags; }
2057
2058  static bool classof(const ARG_FLAGSSDNode *) { return true; }
2059  static bool classof(const SDNode *N) {
2060    return N->getOpcode() == ISD::ARG_FLAGS;
2061  }
2062};
2063
2064/// VTSDNode - This class is used to represent MVT's, which are used
2065/// to parameterize some operations.
2066class VTSDNode : public SDNode {
2067  MVT ValueType;
2068  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
2069protected:
2070  friend class SelectionDAG;
2071  explicit VTSDNode(MVT VT)
2072    : SDNode(ISD::VALUETYPE, getSDVTList(MVT::Other)), ValueType(VT) {
2073  }
2074public:
2075
2076  MVT getVT() const { return ValueType; }
2077
2078  static bool classof(const VTSDNode *) { return true; }
2079  static bool classof(const SDNode *N) {
2080    return N->getOpcode() == ISD::VALUETYPE;
2081  }
2082};
2083
2084/// LSBaseSDNode - Base class for LoadSDNode and StoreSDNode
2085///
2086class LSBaseSDNode : public MemSDNode {
2087protected:
2088  //! Operand array for load and store
2089  /*!
2090    \note Moving this array to the base class captures more
2091    common functionality shared between LoadSDNode and
2092    StoreSDNode
2093   */
2094  SDUse Ops[4];
2095public:
2096  LSBaseSDNode(ISD::NodeType NodeTy, SDValue *Operands, unsigned numOperands,
2097               SDVTList VTs, ISD::MemIndexedMode AM, MVT VT,
2098               const Value *SV, int SVO, unsigned Align, bool Vol)
2099    : MemSDNode(NodeTy, VTs, VT, SV, SVO, Align, Vol) {
2100    SubclassData = AM;
2101    for (unsigned i = 0; i != numOperands; ++i)
2102      Ops[i] = Operands[i];
2103    InitOperands(Ops, numOperands);
2104    assert(Align != 0 && "Loads and stores should have non-zero aligment");
2105    assert((getOffset().getOpcode() == ISD::UNDEF || isIndexed()) &&
2106           "Only indexed loads and stores have a non-undef offset operand");
2107  }
2108
2109  const SDValue &getOffset() const {
2110    return getOperand(getOpcode() == ISD::LOAD ? 2 : 3);
2111  }
2112
2113  /// getAddressingMode - Return the addressing mode for this load or store:
2114  /// unindexed, pre-inc, pre-dec, post-inc, or post-dec.
2115  ISD::MemIndexedMode getAddressingMode() const {
2116    return ISD::MemIndexedMode(SubclassData & 7);
2117  }
2118
2119  /// isIndexed - Return true if this is a pre/post inc/dec load/store.
2120  bool isIndexed() const { return getAddressingMode() != ISD::UNINDEXED; }
2121
2122  /// isUnindexed - Return true if this is NOT a pre/post inc/dec load/store.
2123  bool isUnindexed() const { return getAddressingMode() == ISD::UNINDEXED; }
2124
2125  static bool classof(const LSBaseSDNode *) { return true; }
2126  static bool classof(const SDNode *N) {
2127    return N->getOpcode() == ISD::LOAD ||
2128           N->getOpcode() == ISD::STORE;
2129  }
2130};
2131
2132/// LoadSDNode - This class is used to represent ISD::LOAD nodes.
2133///
2134class LoadSDNode : public LSBaseSDNode {
2135  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
2136protected:
2137  friend class SelectionDAG;
2138  LoadSDNode(SDValue *ChainPtrOff, SDVTList VTs,
2139             ISD::MemIndexedMode AM, ISD::LoadExtType ETy, MVT LVT,
2140             const Value *SV, int O=0, unsigned Align=0, bool Vol=false)
2141    : LSBaseSDNode(ISD::LOAD, ChainPtrOff, 3,
2142                   VTs, AM, LVT, SV, O, Align, Vol) {
2143    SubclassData |= (unsigned short)ETy << 3;
2144  }
2145public:
2146
2147  /// getExtensionType - Return whether this is a plain node,
2148  /// or one of the varieties of value-extending loads.
2149  ISD::LoadExtType getExtensionType() const {
2150    return ISD::LoadExtType((SubclassData >> 3) & 3);
2151  }
2152
2153  const SDValue &getBasePtr() const { return getOperand(1); }
2154  const SDValue &getOffset() const { return getOperand(2); }
2155
2156  static bool classof(const LoadSDNode *) { return true; }
2157  static bool classof(const SDNode *N) {
2158    return N->getOpcode() == ISD::LOAD;
2159  }
2160};
2161
2162/// StoreSDNode - This class is used to represent ISD::STORE nodes.
2163///
2164class StoreSDNode : public LSBaseSDNode {
2165  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
2166protected:
2167  friend class SelectionDAG;
2168  StoreSDNode(SDValue *ChainValuePtrOff, SDVTList VTs,
2169              ISD::MemIndexedMode AM, bool isTrunc, MVT SVT,
2170              const Value *SV, int O=0, unsigned Align=0, bool Vol=false)
2171    : LSBaseSDNode(ISD::STORE, ChainValuePtrOff, 4,
2172                   VTs, AM, SVT, SV, O, Align, Vol) {
2173    SubclassData |= (unsigned short)isTrunc << 3;
2174  }
2175public:
2176
2177  /// isTruncatingStore - Return true if the op does a truncation before store.
2178  /// For integers this is the same as doing a TRUNCATE and storing the result.
2179  /// For floats, it is the same as doing an FP_ROUND and storing the result.
2180  bool isTruncatingStore() const { return (SubclassData >> 3) & 1; }
2181
2182  const SDValue &getValue() const { return getOperand(1); }
2183  const SDValue &getBasePtr() const { return getOperand(2); }
2184  const SDValue &getOffset() const { return getOperand(3); }
2185
2186  static bool classof(const StoreSDNode *) { return true; }
2187  static bool classof(const SDNode *N) {
2188    return N->getOpcode() == ISD::STORE;
2189  }
2190};
2191
2192
2193class SDNodeIterator : public forward_iterator<SDNode, ptrdiff_t> {
2194  SDNode *Node;
2195  unsigned Operand;
2196
2197  SDNodeIterator(SDNode *N, unsigned Op) : Node(N), Operand(Op) {}
2198public:
2199  bool operator==(const SDNodeIterator& x) const {
2200    return Operand == x.Operand;
2201  }
2202  bool operator!=(const SDNodeIterator& x) const { return !operator==(x); }
2203
2204  const SDNodeIterator &operator=(const SDNodeIterator &I) {
2205    assert(I.Node == Node && "Cannot assign iterators to two different nodes!");
2206    Operand = I.Operand;
2207    return *this;
2208  }
2209
2210  pointer operator*() const {
2211    return Node->getOperand(Operand).Val;
2212  }
2213  pointer operator->() const { return operator*(); }
2214
2215  SDNodeIterator& operator++() {                // Preincrement
2216    ++Operand;
2217    return *this;
2218  }
2219  SDNodeIterator operator++(int) { // Postincrement
2220    SDNodeIterator tmp = *this; ++*this; return tmp;
2221  }
2222
2223  static SDNodeIterator begin(SDNode *N) { return SDNodeIterator(N, 0); }
2224  static SDNodeIterator end  (SDNode *N) {
2225    return SDNodeIterator(N, N->getNumOperands());
2226  }
2227
2228  unsigned getOperand() const { return Operand; }
2229  const SDNode *getNode() const { return Node; }
2230};
2231
2232template <> struct GraphTraits<SDNode*> {
2233  typedef SDNode NodeType;
2234  typedef SDNodeIterator ChildIteratorType;
2235  static inline NodeType *getEntryNode(SDNode *N) { return N; }
2236  static inline ChildIteratorType child_begin(NodeType *N) {
2237    return SDNodeIterator::begin(N);
2238  }
2239  static inline ChildIteratorType child_end(NodeType *N) {
2240    return SDNodeIterator::end(N);
2241  }
2242};
2243
2244/// LargestSDNode - The largest SDNode class.
2245///
2246typedef LoadSDNode LargestSDNode;
2247
2248/// MostAlignedSDNode - The SDNode class with the greatest alignment
2249/// requirement.
2250///
2251typedef ConstantSDNode MostAlignedSDNode;
2252
2253namespace ISD {
2254  /// isNormalLoad - Returns true if the specified node is a non-extending
2255  /// and unindexed load.
2256  inline bool isNormalLoad(const SDNode *N) {
2257    const LoadSDNode *Ld = dyn_cast<LoadSDNode>(N);
2258    return Ld && Ld->getExtensionType() == ISD::NON_EXTLOAD &&
2259      Ld->getAddressingMode() == ISD::UNINDEXED;
2260  }
2261
2262  /// isNON_EXTLoad - Returns true if the specified node is a non-extending
2263  /// load.
2264  inline bool isNON_EXTLoad(const SDNode *N) {
2265    return isa<LoadSDNode>(N) &&
2266      cast<LoadSDNode>(N)->getExtensionType() == ISD::NON_EXTLOAD;
2267  }
2268
2269  /// isEXTLoad - Returns true if the specified node is a EXTLOAD.
2270  ///
2271  inline bool isEXTLoad(const SDNode *N) {
2272    return isa<LoadSDNode>(N) &&
2273      cast<LoadSDNode>(N)->getExtensionType() == ISD::EXTLOAD;
2274  }
2275
2276  /// isSEXTLoad - Returns true if the specified node is a SEXTLOAD.
2277  ///
2278  inline bool isSEXTLoad(const SDNode *N) {
2279    return isa<LoadSDNode>(N) &&
2280      cast<LoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD;
2281  }
2282
2283  /// isZEXTLoad - Returns true if the specified node is a ZEXTLOAD.
2284  ///
2285  inline bool isZEXTLoad(const SDNode *N) {
2286    return isa<LoadSDNode>(N) &&
2287      cast<LoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD;
2288  }
2289
2290  /// isUNINDEXEDLoad - Returns true if the specified node is an unindexed load.
2291  ///
2292  inline bool isUNINDEXEDLoad(const SDNode *N) {
2293    return isa<LoadSDNode>(N) &&
2294      cast<LoadSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
2295  }
2296
2297  /// isNormalStore - Returns true if the specified node is a non-truncating
2298  /// and unindexed store.
2299  inline bool isNormalStore(const SDNode *N) {
2300    const StoreSDNode *St = dyn_cast<StoreSDNode>(N);
2301    return St && !St->isTruncatingStore() &&
2302      St->getAddressingMode() == ISD::UNINDEXED;
2303  }
2304
2305  /// isNON_TRUNCStore - Returns true if the specified node is a non-truncating
2306  /// store.
2307  inline bool isNON_TRUNCStore(const SDNode *N) {
2308    return isa<StoreSDNode>(N) && !cast<StoreSDNode>(N)->isTruncatingStore();
2309  }
2310
2311  /// isTRUNCStore - Returns true if the specified node is a truncating
2312  /// store.
2313  inline bool isTRUNCStore(const SDNode *N) {
2314    return isa<StoreSDNode>(N) && cast<StoreSDNode>(N)->isTruncatingStore();
2315  }
2316
2317  /// isUNINDEXEDStore - Returns true if the specified node is an
2318  /// unindexed store.
2319  inline bool isUNINDEXEDStore(const SDNode *N) {
2320    return isa<StoreSDNode>(N) &&
2321      cast<StoreSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
2322  }
2323}
2324
2325
2326} // end llvm namespace
2327
2328#endif
2329