SelectionDAGNodes.h revision 8471ef5f4e79fbe4d7021e91d45e39fdbf8783fc
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 dump() const;
1264  void dump(const SelectionDAG *G) const;
1265
1266  static bool classof(const SDNode *) { return true; }
1267
1268  /// Profile - Gather unique data for the node.
1269  ///
1270  void Profile(FoldingSetNodeID &ID) const;
1271
1272protected:
1273  friend class SelectionDAG;
1274  friend class ilist_traits<SDNode>;
1275
1276  /// getValueTypeList - Return a pointer to the specified value type.
1277  ///
1278  static const MVT *getValueTypeList(MVT VT);
1279  static SDVTList getSDVTList(MVT VT) {
1280    SDVTList Ret = { getValueTypeList(VT), 1 };
1281    return Ret;
1282  }
1283
1284  SDNode(unsigned Opc, SDVTList VTs, const SDValue *Ops, unsigned NumOps)
1285    : NodeType(Opc), OperandsNeedDelete(true), SubclassData(0),
1286      NodeId(-1), Uses(NULL) {
1287    NumOperands = NumOps;
1288    OperandList = NumOps ? new SDUse[NumOperands] : 0;
1289
1290    for (unsigned i = 0; i != NumOps; ++i) {
1291      OperandList[i] = Ops[i];
1292      OperandList[i].setUser(this);
1293      Ops[i].Val->addUse(OperandList[i]);
1294    }
1295
1296    ValueList = VTs.VTs;
1297    NumValues = VTs.NumVTs;
1298  }
1299
1300  SDNode(unsigned Opc, SDVTList VTs, const SDUse *Ops, unsigned NumOps)
1301    : NodeType(Opc), OperandsNeedDelete(true), SubclassData(0),
1302      NodeId(-1), Uses(NULL) {
1303    OperandsNeedDelete = true;
1304    NumOperands = NumOps;
1305    OperandList = NumOps ? new SDUse[NumOperands] : 0;
1306
1307    for (unsigned i = 0; i != NumOps; ++i) {
1308      OperandList[i] = Ops[i];
1309      OperandList[i].setUser(this);
1310      Ops[i].getVal()->addUse(OperandList[i]);
1311    }
1312
1313    ValueList = VTs.VTs;
1314    NumValues = VTs.NumVTs;
1315  }
1316
1317  /// This constructor adds no operands itself; operands can be
1318  /// set later with InitOperands.
1319  SDNode(unsigned Opc, SDVTList VTs)
1320    : NodeType(Opc), OperandsNeedDelete(false), SubclassData(0),
1321      NodeId(-1), Uses(NULL) {
1322    NumOperands = 0;
1323    OperandList = 0;
1324    ValueList = VTs.VTs;
1325    NumValues = VTs.NumVTs;
1326  }
1327
1328  /// InitOperands - Initialize the operands list of this node with the
1329  /// specified values, which are part of the node (thus they don't need to be
1330  /// copied in or allocated).
1331  void InitOperands(SDUse *Ops, unsigned NumOps) {
1332    assert(OperandList == 0 && "Operands already set!");
1333    NumOperands = NumOps;
1334    OperandList = Ops;
1335    Uses = NULL;
1336
1337    for (unsigned i = 0; i != NumOps; ++i) {
1338      OperandList[i].setUser(this);
1339      Ops[i].getVal()->addUse(OperandList[i]);
1340    }
1341  }
1342
1343  /// DropOperands - Release the operands and set this node to have
1344  /// zero operands.
1345  void DropOperands();
1346
1347  void addUser(unsigned i, SDNode *User) {
1348    assert(User->OperandList[i].getUser() && "Node without parent");
1349    addUse(User->OperandList[i]);
1350  }
1351
1352  void removeUser(unsigned i, SDNode *User) {
1353    assert(User->OperandList[i].getUser() && "Node without parent");
1354    SDUse &Op = User->OperandList[i];
1355    Op.removeFromList();
1356  }
1357};
1358
1359
1360// Define inline functions from the SDValue class.
1361
1362inline unsigned SDValue::getOpcode() const {
1363  return Val->getOpcode();
1364}
1365inline MVT SDValue::getValueType() const {
1366  return Val->getValueType(ResNo);
1367}
1368inline unsigned SDValue::getNumOperands() const {
1369  return Val->getNumOperands();
1370}
1371inline const SDValue &SDValue::getOperand(unsigned i) const {
1372  return Val->getOperand(i);
1373}
1374inline uint64_t SDValue::getConstantOperandVal(unsigned i) const {
1375  return Val->getConstantOperandVal(i);
1376}
1377inline bool SDValue::isTargetOpcode() const {
1378  return Val->isTargetOpcode();
1379}
1380inline bool SDValue::isMachineOpcode() const {
1381  return Val->isMachineOpcode();
1382}
1383inline unsigned SDValue::getMachineOpcode() const {
1384  return Val->getMachineOpcode();
1385}
1386inline bool SDValue::use_empty() const {
1387  return !Val->hasAnyUseOfValue(ResNo);
1388}
1389inline bool SDValue::hasOneUse() const {
1390  return Val->hasNUsesOfValue(1, ResNo);
1391}
1392
1393/// UnarySDNode - This class is used for single-operand SDNodes.  This is solely
1394/// to allow co-allocation of node operands with the node itself.
1395class UnarySDNode : public SDNode {
1396  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1397  SDUse Op;
1398public:
1399  UnarySDNode(unsigned Opc, SDVTList VTs, SDValue X)
1400    : SDNode(Opc, VTs) {
1401    Op = X;
1402    InitOperands(&Op, 1);
1403  }
1404};
1405
1406/// BinarySDNode - This class is used for two-operand SDNodes.  This is solely
1407/// to allow co-allocation of node operands with the node itself.
1408class BinarySDNode : public SDNode {
1409  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1410  SDUse Ops[2];
1411public:
1412  BinarySDNode(unsigned Opc, SDVTList VTs, SDValue X, SDValue Y)
1413    : SDNode(Opc, VTs) {
1414    Ops[0] = X;
1415    Ops[1] = Y;
1416    InitOperands(Ops, 2);
1417  }
1418};
1419
1420/// TernarySDNode - This class is used for three-operand SDNodes. This is solely
1421/// to allow co-allocation of node operands with the node itself.
1422class TernarySDNode : public SDNode {
1423  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1424  SDUse Ops[3];
1425public:
1426  TernarySDNode(unsigned Opc, SDVTList VTs, SDValue X, SDValue Y,
1427                SDValue Z)
1428    : SDNode(Opc, VTs) {
1429    Ops[0] = X;
1430    Ops[1] = Y;
1431    Ops[2] = Z;
1432    InitOperands(Ops, 3);
1433  }
1434};
1435
1436
1437/// HandleSDNode - This class is used to form a handle around another node that
1438/// is persistant and is updated across invocations of replaceAllUsesWith on its
1439/// operand.  This node should be directly created by end-users and not added to
1440/// the AllNodes list.
1441class HandleSDNode : public SDNode {
1442  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1443  SDUse Op;
1444public:
1445  // FIXME: Remove the "noinline" attribute once <rdar://problem/5852746> is
1446  // fixed.
1447#ifdef __GNUC__
1448  explicit __attribute__((__noinline__)) HandleSDNode(SDValue X)
1449#else
1450  explicit HandleSDNode(SDValue X)
1451#endif
1452    : SDNode(ISD::HANDLENODE, getSDVTList(MVT::Other)) {
1453    Op = X;
1454    InitOperands(&Op, 1);
1455  }
1456  ~HandleSDNode();
1457  const SDValue &getValue() const { return Op.getSDValue(); }
1458};
1459
1460/// Abstact virtual class for operations for memory operations
1461class MemSDNode : public SDNode {
1462  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1463
1464private:
1465  // MemoryVT - VT of in-memory value.
1466  MVT MemoryVT;
1467
1468  //! SrcValue - Memory location for alias analysis.
1469  const Value *SrcValue;
1470
1471  //! SVOffset - Memory location offset. Note that base is defined in MemSDNode
1472  int SVOffset;
1473
1474  /// Flags - the low bit indicates whether this is a volatile reference;
1475  /// the remainder is a log2 encoding of the alignment in bytes.
1476  unsigned Flags;
1477
1478public:
1479  MemSDNode(unsigned Opc, SDVTList VTs, MVT MemoryVT,
1480            const Value *srcValue, int SVOff,
1481            unsigned alignment, bool isvolatile);
1482
1483  /// Returns alignment and volatility of the memory access
1484  unsigned getAlignment() const { return (1u << (Flags >> 1)) >> 1; }
1485  bool isVolatile() const { return Flags & 1; }
1486
1487  /// Returns the SrcValue and offset that describes the location of the access
1488  const Value *getSrcValue() const { return SrcValue; }
1489  int getSrcValueOffset() const { return SVOffset; }
1490
1491  /// getMemoryVT - Return the type of the in-memory value.
1492  MVT getMemoryVT() const { return MemoryVT; }
1493
1494  /// getMemOperand - Return a MachineMemOperand object describing the memory
1495  /// reference performed by operation.
1496  MachineMemOperand getMemOperand() const;
1497
1498  const SDValue &getChain() const { return getOperand(0); }
1499  const SDValue &getBasePtr() const {
1500    return getOperand(getOpcode() == ISD::STORE ? 2 : 1);
1501  }
1502
1503  /// getRawFlags - Represent the flags as a bunch of bits.
1504  ///
1505  unsigned getRawFlags() const { return Flags; }
1506
1507  // Methods to support isa and dyn_cast
1508  static bool classof(const MemSDNode *) { return true; }
1509  static bool classof(const SDNode *N) {
1510    return N->getOpcode() == ISD::LOAD  ||
1511           N->getOpcode() == ISD::STORE ||
1512           N->getOpcode() == ISD::ATOMIC_CMP_SWAP  ||
1513           N->getOpcode() == ISD::ATOMIC_LOAD_ADD  ||
1514           N->getOpcode() == ISD::ATOMIC_SWAP      ||
1515           N->getOpcode() == ISD::ATOMIC_LOAD_SUB  ||
1516           N->getOpcode() == ISD::ATOMIC_LOAD_AND  ||
1517           N->getOpcode() == ISD::ATOMIC_LOAD_OR   ||
1518           N->getOpcode() == ISD::ATOMIC_LOAD_XOR  ||
1519           N->getOpcode() == ISD::ATOMIC_LOAD_NAND ||
1520           N->getOpcode() == ISD::ATOMIC_LOAD_MIN  ||
1521           N->getOpcode() == ISD::ATOMIC_LOAD_MAX  ||
1522           N->getOpcode() == ISD::ATOMIC_LOAD_UMIN ||
1523           N->getOpcode() == ISD::ATOMIC_LOAD_UMAX;
1524  }
1525};
1526
1527/// Atomic operations node
1528class AtomicSDNode : public MemSDNode {
1529  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1530  SDUse Ops[4];
1531
1532 public:
1533  // Opc:   opcode for atomic
1534  // VTL:    value type list
1535  // Chain:  memory chain for operaand
1536  // Ptr:    address to update as a SDValue
1537  // Cmp:    compare value
1538  // Swp:    swap value
1539  // SrcVal: address to update as a Value (used for MemOperand)
1540  // Align:  alignment of memory
1541  AtomicSDNode(unsigned Opc, SDVTList VTL, SDValue Chain, SDValue Ptr,
1542               SDValue Cmp, SDValue Swp, const Value* SrcVal,
1543               unsigned Align=0)
1544    : MemSDNode(Opc, VTL, Cmp.getValueType(), SrcVal, /*SVOffset=*/0,
1545                Align, /*isVolatile=*/true) {
1546    Ops[0] = Chain;
1547    Ops[1] = Ptr;
1548    Ops[2] = Swp;
1549    Ops[3] = Cmp;
1550    InitOperands(Ops, 4);
1551  }
1552  AtomicSDNode(unsigned Opc, SDVTList VTL, SDValue Chain, SDValue Ptr,
1553               SDValue Val, const Value* SrcVal, unsigned Align=0)
1554    : MemSDNode(Opc, VTL, Val.getValueType(), SrcVal, /*SVOffset=*/0,
1555                Align, /*isVolatile=*/true) {
1556    Ops[0] = Chain;
1557    Ops[1] = Ptr;
1558    Ops[2] = Val;
1559    InitOperands(Ops, 3);
1560  }
1561
1562  const SDValue &getBasePtr() const { return getOperand(1); }
1563  const SDValue &getVal() const { return getOperand(2); }
1564
1565  bool isCompareAndSwap() const { return getOpcode() == ISD::ATOMIC_CMP_SWAP; }
1566
1567  // Methods to support isa and dyn_cast
1568  static bool classof(const AtomicSDNode *) { return true; }
1569  static bool classof(const SDNode *N) {
1570    return N->getOpcode() == ISD::ATOMIC_CMP_SWAP  ||
1571           N->getOpcode() == ISD::ATOMIC_LOAD_ADD  ||
1572           N->getOpcode() == ISD::ATOMIC_SWAP      ||
1573           N->getOpcode() == ISD::ATOMIC_LOAD_SUB  ||
1574           N->getOpcode() == ISD::ATOMIC_LOAD_AND  ||
1575           N->getOpcode() == ISD::ATOMIC_LOAD_OR   ||
1576           N->getOpcode() == ISD::ATOMIC_LOAD_XOR  ||
1577           N->getOpcode() == ISD::ATOMIC_LOAD_NAND ||
1578           N->getOpcode() == ISD::ATOMIC_LOAD_MIN  ||
1579           N->getOpcode() == ISD::ATOMIC_LOAD_MAX  ||
1580           N->getOpcode() == ISD::ATOMIC_LOAD_UMIN ||
1581           N->getOpcode() == ISD::ATOMIC_LOAD_UMAX;
1582  }
1583};
1584
1585class ConstantSDNode : public SDNode {
1586  APInt Value;
1587  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1588protected:
1589  friend class SelectionDAG;
1590  ConstantSDNode(bool isTarget, const APInt &val, MVT VT)
1591    : SDNode(isTarget ? ISD::TargetConstant : ISD::Constant, getSDVTList(VT)),
1592      Value(val) {
1593  }
1594public:
1595
1596  const APInt &getAPIntValue() const { return Value; }
1597  uint64_t getValue() const { return Value.getZExtValue(); }
1598
1599  int64_t getSignExtended() const {
1600    unsigned Bits = getValueType(0).getSizeInBits();
1601    return ((int64_t)Value.getZExtValue() << (64-Bits)) >> (64-Bits);
1602  }
1603
1604  bool isNullValue() const { return Value == 0; }
1605  bool isAllOnesValue() const {
1606    return Value == getValueType(0).getIntegerVTBitMask();
1607  }
1608
1609  static bool classof(const ConstantSDNode *) { return true; }
1610  static bool classof(const SDNode *N) {
1611    return N->getOpcode() == ISD::Constant ||
1612           N->getOpcode() == ISD::TargetConstant;
1613  }
1614};
1615
1616class ConstantFPSDNode : public SDNode {
1617  APFloat Value;
1618  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1619protected:
1620  friend class SelectionDAG;
1621  ConstantFPSDNode(bool isTarget, const APFloat& val, MVT VT)
1622    : SDNode(isTarget ? ISD::TargetConstantFP : ISD::ConstantFP,
1623             getSDVTList(VT)), Value(val) {
1624  }
1625public:
1626
1627  const APFloat& getValueAPF() const { return Value; }
1628
1629  /// isExactlyValue - We don't rely on operator== working on double values, as
1630  /// it returns true for things that are clearly not equal, like -0.0 and 0.0.
1631  /// As such, this method can be used to do an exact bit-for-bit comparison of
1632  /// two floating point values.
1633
1634  /// We leave the version with the double argument here because it's just so
1635  /// convenient to write "2.0" and the like.  Without this function we'd
1636  /// have to duplicate its logic everywhere it's called.
1637  bool isExactlyValue(double V) const {
1638    // convert is not supported on this type
1639    if (&Value.getSemantics() == &APFloat::PPCDoubleDouble)
1640      return false;
1641    APFloat Tmp(V);
1642    Tmp.convert(Value.getSemantics(), APFloat::rmNearestTiesToEven);
1643    return isExactlyValue(Tmp);
1644  }
1645  bool isExactlyValue(const APFloat& V) const;
1646
1647  bool isValueValidForType(MVT VT, const APFloat& Val);
1648
1649  static bool classof(const ConstantFPSDNode *) { return true; }
1650  static bool classof(const SDNode *N) {
1651    return N->getOpcode() == ISD::ConstantFP ||
1652           N->getOpcode() == ISD::TargetConstantFP;
1653  }
1654};
1655
1656class GlobalAddressSDNode : public SDNode {
1657  GlobalValue *TheGlobal;
1658  int Offset;
1659  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1660protected:
1661  friend class SelectionDAG;
1662  GlobalAddressSDNode(bool isTarget, const GlobalValue *GA, MVT VT, int o = 0);
1663public:
1664
1665  GlobalValue *getGlobal() const { return TheGlobal; }
1666  int getOffset() const { return Offset; }
1667
1668  static bool classof(const GlobalAddressSDNode *) { return true; }
1669  static bool classof(const SDNode *N) {
1670    return N->getOpcode() == ISD::GlobalAddress ||
1671           N->getOpcode() == ISD::TargetGlobalAddress ||
1672           N->getOpcode() == ISD::GlobalTLSAddress ||
1673           N->getOpcode() == ISD::TargetGlobalTLSAddress;
1674  }
1675};
1676
1677class FrameIndexSDNode : public SDNode {
1678  int FI;
1679  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1680protected:
1681  friend class SelectionDAG;
1682  FrameIndexSDNode(int fi, MVT VT, bool isTarg)
1683    : SDNode(isTarg ? ISD::TargetFrameIndex : ISD::FrameIndex, getSDVTList(VT)),
1684      FI(fi) {
1685  }
1686public:
1687
1688  int getIndex() const { return FI; }
1689
1690  static bool classof(const FrameIndexSDNode *) { return true; }
1691  static bool classof(const SDNode *N) {
1692    return N->getOpcode() == ISD::FrameIndex ||
1693           N->getOpcode() == ISD::TargetFrameIndex;
1694  }
1695};
1696
1697class JumpTableSDNode : public SDNode {
1698  int JTI;
1699  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1700protected:
1701  friend class SelectionDAG;
1702  JumpTableSDNode(int jti, MVT VT, bool isTarg)
1703    : SDNode(isTarg ? ISD::TargetJumpTable : ISD::JumpTable, getSDVTList(VT)),
1704      JTI(jti) {
1705  }
1706public:
1707
1708  int getIndex() const { return JTI; }
1709
1710  static bool classof(const JumpTableSDNode *) { return true; }
1711  static bool classof(const SDNode *N) {
1712    return N->getOpcode() == ISD::JumpTable ||
1713           N->getOpcode() == ISD::TargetJumpTable;
1714  }
1715};
1716
1717class ConstantPoolSDNode : public SDNode {
1718  union {
1719    Constant *ConstVal;
1720    MachineConstantPoolValue *MachineCPVal;
1721  } Val;
1722  int Offset;  // It's a MachineConstantPoolValue if top bit is set.
1723  unsigned Alignment;
1724  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1725protected:
1726  friend class SelectionDAG;
1727  ConstantPoolSDNode(bool isTarget, Constant *c, MVT VT, int o=0)
1728    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
1729             getSDVTList(VT)), Offset(o), Alignment(0) {
1730    assert((int)Offset >= 0 && "Offset is too large");
1731    Val.ConstVal = c;
1732  }
1733  ConstantPoolSDNode(bool isTarget, Constant *c, MVT VT, int o, unsigned Align)
1734    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
1735             getSDVTList(VT)), Offset(o), Alignment(Align) {
1736    assert((int)Offset >= 0 && "Offset is too large");
1737    Val.ConstVal = c;
1738  }
1739  ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v,
1740                     MVT VT, int o=0)
1741    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
1742             getSDVTList(VT)), Offset(o), Alignment(0) {
1743    assert((int)Offset >= 0 && "Offset is too large");
1744    Val.MachineCPVal = v;
1745    Offset |= 1 << (sizeof(unsigned)*8-1);
1746  }
1747  ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v,
1748                     MVT VT, int o, unsigned Align)
1749    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
1750             getSDVTList(VT)), Offset(o), Alignment(Align) {
1751    assert((int)Offset >= 0 && "Offset is too large");
1752    Val.MachineCPVal = v;
1753    Offset |= 1 << (sizeof(unsigned)*8-1);
1754  }
1755public:
1756
1757  bool isMachineConstantPoolEntry() const {
1758    return (int)Offset < 0;
1759  }
1760
1761  Constant *getConstVal() const {
1762    assert(!isMachineConstantPoolEntry() && "Wrong constantpool type");
1763    return Val.ConstVal;
1764  }
1765
1766  MachineConstantPoolValue *getMachineCPVal() const {
1767    assert(isMachineConstantPoolEntry() && "Wrong constantpool type");
1768    return Val.MachineCPVal;
1769  }
1770
1771  int getOffset() const {
1772    return Offset & ~(1 << (sizeof(unsigned)*8-1));
1773  }
1774
1775  // Return the alignment of this constant pool object, which is either 0 (for
1776  // default alignment) or log2 of the desired value.
1777  unsigned getAlignment() const { return Alignment; }
1778
1779  const Type *getType() const;
1780
1781  static bool classof(const ConstantPoolSDNode *) { return true; }
1782  static bool classof(const SDNode *N) {
1783    return N->getOpcode() == ISD::ConstantPool ||
1784           N->getOpcode() == ISD::TargetConstantPool;
1785  }
1786};
1787
1788class BasicBlockSDNode : public SDNode {
1789  MachineBasicBlock *MBB;
1790  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1791protected:
1792  friend class SelectionDAG;
1793  explicit BasicBlockSDNode(MachineBasicBlock *mbb)
1794    : SDNode(ISD::BasicBlock, getSDVTList(MVT::Other)), MBB(mbb) {
1795  }
1796public:
1797
1798  MachineBasicBlock *getBasicBlock() const { return MBB; }
1799
1800  static bool classof(const BasicBlockSDNode *) { return true; }
1801  static bool classof(const SDNode *N) {
1802    return N->getOpcode() == ISD::BasicBlock;
1803  }
1804};
1805
1806/// SrcValueSDNode - An SDNode that holds an arbitrary LLVM IR Value. This is
1807/// used when the SelectionDAG needs to make a simple reference to something
1808/// in the LLVM IR representation.
1809///
1810/// Note that this is not used for carrying alias information; that is done
1811/// with MemOperandSDNode, which includes a Value which is required to be a
1812/// pointer, and several other fields specific to memory references.
1813///
1814class SrcValueSDNode : public SDNode {
1815  const Value *V;
1816  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1817protected:
1818  friend class SelectionDAG;
1819  /// Create a SrcValue for a general value.
1820  explicit SrcValueSDNode(const Value *v)
1821    : SDNode(ISD::SRCVALUE, getSDVTList(MVT::Other)), V(v) {}
1822
1823public:
1824  /// getValue - return the contained Value.
1825  const Value *getValue() const { return V; }
1826
1827  static bool classof(const SrcValueSDNode *) { return true; }
1828  static bool classof(const SDNode *N) {
1829    return N->getOpcode() == ISD::SRCVALUE;
1830  }
1831};
1832
1833
1834/// MemOperandSDNode - An SDNode that holds a MachineMemOperand. This is
1835/// used to represent a reference to memory after ISD::LOAD
1836/// and ISD::STORE have been lowered.
1837///
1838class MemOperandSDNode : public SDNode {
1839  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1840protected:
1841  friend class SelectionDAG;
1842  /// Create a MachineMemOperand node
1843  explicit MemOperandSDNode(const MachineMemOperand &mo)
1844    : SDNode(ISD::MEMOPERAND, getSDVTList(MVT::Other)), MO(mo) {}
1845
1846public:
1847  /// MO - The contained MachineMemOperand.
1848  const MachineMemOperand MO;
1849
1850  static bool classof(const MemOperandSDNode *) { return true; }
1851  static bool classof(const SDNode *N) {
1852    return N->getOpcode() == ISD::MEMOPERAND;
1853  }
1854};
1855
1856
1857class RegisterSDNode : public SDNode {
1858  unsigned Reg;
1859  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1860protected:
1861  friend class SelectionDAG;
1862  RegisterSDNode(unsigned reg, MVT VT)
1863    : SDNode(ISD::Register, getSDVTList(VT)), Reg(reg) {
1864  }
1865public:
1866
1867  unsigned getReg() const { return Reg; }
1868
1869  static bool classof(const RegisterSDNode *) { return true; }
1870  static bool classof(const SDNode *N) {
1871    return N->getOpcode() == ISD::Register;
1872  }
1873};
1874
1875class DbgStopPointSDNode : public SDNode {
1876  SDUse Chain;
1877  unsigned Line;
1878  unsigned Column;
1879  const CompileUnitDesc *CU;
1880  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1881protected:
1882  friend class SelectionDAG;
1883  DbgStopPointSDNode(SDValue ch, unsigned l, unsigned c,
1884                     const CompileUnitDesc *cu)
1885    : SDNode(ISD::DBG_STOPPOINT, getSDVTList(MVT::Other)),
1886      Line(l), Column(c), CU(cu) {
1887    Chain = ch;
1888    InitOperands(&Chain, 1);
1889  }
1890public:
1891  unsigned getLine() const { return Line; }
1892  unsigned getColumn() const { return Column; }
1893  const CompileUnitDesc *getCompileUnit() const { return CU; }
1894
1895  static bool classof(const DbgStopPointSDNode *) { return true; }
1896  static bool classof(const SDNode *N) {
1897    return N->getOpcode() == ISD::DBG_STOPPOINT;
1898  }
1899};
1900
1901class LabelSDNode : public SDNode {
1902  SDUse Chain;
1903  unsigned LabelID;
1904  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1905protected:
1906  friend class SelectionDAG;
1907  LabelSDNode(unsigned NodeTy, SDValue ch, unsigned id)
1908    : SDNode(NodeTy, getSDVTList(MVT::Other)), LabelID(id) {
1909    Chain = ch;
1910    InitOperands(&Chain, 1);
1911  }
1912public:
1913  unsigned getLabelID() const { return LabelID; }
1914
1915  static bool classof(const LabelSDNode *) { return true; }
1916  static bool classof(const SDNode *N) {
1917    return N->getOpcode() == ISD::DBG_LABEL ||
1918           N->getOpcode() == ISD::EH_LABEL;
1919  }
1920};
1921
1922class ExternalSymbolSDNode : public SDNode {
1923  const char *Symbol;
1924  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1925protected:
1926  friend class SelectionDAG;
1927  ExternalSymbolSDNode(bool isTarget, const char *Sym, MVT VT)
1928    : SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol,
1929             getSDVTList(VT)), Symbol(Sym) {
1930  }
1931public:
1932
1933  const char *getSymbol() const { return Symbol; }
1934
1935  static bool classof(const ExternalSymbolSDNode *) { return true; }
1936  static bool classof(const SDNode *N) {
1937    return N->getOpcode() == ISD::ExternalSymbol ||
1938           N->getOpcode() == ISD::TargetExternalSymbol;
1939  }
1940};
1941
1942class CondCodeSDNode : public SDNode {
1943  ISD::CondCode Condition;
1944  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1945protected:
1946  friend class SelectionDAG;
1947  explicit CondCodeSDNode(ISD::CondCode Cond)
1948    : SDNode(ISD::CONDCODE, getSDVTList(MVT::Other)), Condition(Cond) {
1949  }
1950public:
1951
1952  ISD::CondCode get() const { return Condition; }
1953
1954  static bool classof(const CondCodeSDNode *) { return true; }
1955  static bool classof(const SDNode *N) {
1956    return N->getOpcode() == ISD::CONDCODE;
1957  }
1958};
1959
1960namespace ISD {
1961  struct ArgFlagsTy {
1962  private:
1963    static const uint64_t NoFlagSet      = 0ULL;
1964    static const uint64_t ZExt           = 1ULL<<0;  ///< Zero extended
1965    static const uint64_t ZExtOffs       = 0;
1966    static const uint64_t SExt           = 1ULL<<1;  ///< Sign extended
1967    static const uint64_t SExtOffs       = 1;
1968    static const uint64_t InReg          = 1ULL<<2;  ///< Passed in register
1969    static const uint64_t InRegOffs      = 2;
1970    static const uint64_t SRet           = 1ULL<<3;  ///< Hidden struct-ret ptr
1971    static const uint64_t SRetOffs       = 3;
1972    static const uint64_t ByVal          = 1ULL<<4;  ///< Struct passed by value
1973    static const uint64_t ByValOffs      = 4;
1974    static const uint64_t Nest           = 1ULL<<5;  ///< Nested fn static chain
1975    static const uint64_t NestOffs       = 5;
1976    static const uint64_t ByValAlign     = 0xFULL << 6; //< Struct alignment
1977    static const uint64_t ByValAlignOffs = 6;
1978    static const uint64_t Split          = 1ULL << 10;
1979    static const uint64_t SplitOffs      = 10;
1980    static const uint64_t OrigAlign      = 0x1FULL<<27;
1981    static const uint64_t OrigAlignOffs  = 27;
1982    static const uint64_t ByValSize      = 0xffffffffULL << 32; //< Struct size
1983    static const uint64_t ByValSizeOffs  = 32;
1984
1985    static const uint64_t One            = 1ULL; //< 1 of this type, for shifts
1986
1987    uint64_t Flags;
1988  public:
1989    ArgFlagsTy() : Flags(0) { }
1990
1991    bool isZExt()   const { return Flags & ZExt; }
1992    void setZExt()  { Flags |= One << ZExtOffs; }
1993
1994    bool isSExt()   const { return Flags & SExt; }
1995    void setSExt()  { Flags |= One << SExtOffs; }
1996
1997    bool isInReg()  const { return Flags & InReg; }
1998    void setInReg() { Flags |= One << InRegOffs; }
1999
2000    bool isSRet()   const { return Flags & SRet; }
2001    void setSRet()  { Flags |= One << SRetOffs; }
2002
2003    bool isByVal()  const { return Flags & ByVal; }
2004    void setByVal() { Flags |= One << ByValOffs; }
2005
2006    bool isNest()   const { return Flags & Nest; }
2007    void setNest()  { Flags |= One << NestOffs; }
2008
2009    unsigned getByValAlign() const {
2010      return (unsigned)
2011        ((One << ((Flags & ByValAlign) >> ByValAlignOffs)) / 2);
2012    }
2013    void setByValAlign(unsigned A) {
2014      Flags = (Flags & ~ByValAlign) |
2015        (uint64_t(Log2_32(A) + 1) << ByValAlignOffs);
2016    }
2017
2018    bool isSplit()   const { return Flags & Split; }
2019    void setSplit()  { Flags |= One << SplitOffs; }
2020
2021    unsigned getOrigAlign() const {
2022      return (unsigned)
2023        ((One << ((Flags & OrigAlign) >> OrigAlignOffs)) / 2);
2024    }
2025    void setOrigAlign(unsigned A) {
2026      Flags = (Flags & ~OrigAlign) |
2027        (uint64_t(Log2_32(A) + 1) << OrigAlignOffs);
2028    }
2029
2030    unsigned getByValSize() const {
2031      return (unsigned)((Flags & ByValSize) >> ByValSizeOffs);
2032    }
2033    void setByValSize(unsigned S) {
2034      Flags = (Flags & ~ByValSize) | (uint64_t(S) << ByValSizeOffs);
2035    }
2036
2037    /// getArgFlagsString - Returns the flags as a string, eg: "zext align:4".
2038    std::string getArgFlagsString();
2039
2040    /// getRawBits - Represent the flags as a bunch of bits.
2041    uint64_t getRawBits() const { return Flags; }
2042  };
2043}
2044
2045/// ARG_FLAGSSDNode - Leaf node holding parameter flags.
2046class ARG_FLAGSSDNode : public SDNode {
2047  ISD::ArgFlagsTy TheFlags;
2048  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
2049protected:
2050  friend class SelectionDAG;
2051  explicit ARG_FLAGSSDNode(ISD::ArgFlagsTy Flags)
2052    : SDNode(ISD::ARG_FLAGS, getSDVTList(MVT::Other)), TheFlags(Flags) {
2053  }
2054public:
2055  ISD::ArgFlagsTy getArgFlags() const { return TheFlags; }
2056
2057  static bool classof(const ARG_FLAGSSDNode *) { return true; }
2058  static bool classof(const SDNode *N) {
2059    return N->getOpcode() == ISD::ARG_FLAGS;
2060  }
2061};
2062
2063/// VTSDNode - This class is used to represent MVT's, which are used
2064/// to parameterize some operations.
2065class VTSDNode : public SDNode {
2066  MVT ValueType;
2067  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
2068protected:
2069  friend class SelectionDAG;
2070  explicit VTSDNode(MVT VT)
2071    : SDNode(ISD::VALUETYPE, getSDVTList(MVT::Other)), ValueType(VT) {
2072  }
2073public:
2074
2075  MVT getVT() const { return ValueType; }
2076
2077  static bool classof(const VTSDNode *) { return true; }
2078  static bool classof(const SDNode *N) {
2079    return N->getOpcode() == ISD::VALUETYPE;
2080  }
2081};
2082
2083/// LSBaseSDNode - Base class for LoadSDNode and StoreSDNode
2084///
2085class LSBaseSDNode : public MemSDNode {
2086protected:
2087  //! Operand array for load and store
2088  /*!
2089    \note Moving this array to the base class captures more
2090    common functionality shared between LoadSDNode and
2091    StoreSDNode
2092   */
2093  SDUse Ops[4];
2094public:
2095  LSBaseSDNode(ISD::NodeType NodeTy, SDValue *Operands, unsigned numOperands,
2096               SDVTList VTs, ISD::MemIndexedMode AM, MVT VT,
2097               const Value *SV, int SVO, unsigned Align, bool Vol)
2098    : MemSDNode(NodeTy, VTs, VT, SV, SVO, Align, Vol) {
2099    SubclassData = AM;
2100    for (unsigned i = 0; i != numOperands; ++i)
2101      Ops[i] = Operands[i];
2102    InitOperands(Ops, numOperands);
2103    assert(Align != 0 && "Loads and stores should have non-zero aligment");
2104    assert((getOffset().getOpcode() == ISD::UNDEF || isIndexed()) &&
2105           "Only indexed loads and stores have a non-undef offset operand");
2106  }
2107
2108  const SDValue &getOffset() const {
2109    return getOperand(getOpcode() == ISD::LOAD ? 2 : 3);
2110  }
2111
2112  /// getAddressingMode - Return the addressing mode for this load or store:
2113  /// unindexed, pre-inc, pre-dec, post-inc, or post-dec.
2114  ISD::MemIndexedMode getAddressingMode() const {
2115    return ISD::MemIndexedMode(SubclassData & 7);
2116  }
2117
2118  /// isIndexed - Return true if this is a pre/post inc/dec load/store.
2119  bool isIndexed() const { return getAddressingMode() != ISD::UNINDEXED; }
2120
2121  /// isUnindexed - Return true if this is NOT a pre/post inc/dec load/store.
2122  bool isUnindexed() const { return getAddressingMode() == ISD::UNINDEXED; }
2123
2124  static bool classof(const LSBaseSDNode *) { return true; }
2125  static bool classof(const SDNode *N) {
2126    return N->getOpcode() == ISD::LOAD ||
2127           N->getOpcode() == ISD::STORE;
2128  }
2129};
2130
2131/// LoadSDNode - This class is used to represent ISD::LOAD nodes.
2132///
2133class LoadSDNode : public LSBaseSDNode {
2134  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
2135protected:
2136  friend class SelectionDAG;
2137  LoadSDNode(SDValue *ChainPtrOff, SDVTList VTs,
2138             ISD::MemIndexedMode AM, ISD::LoadExtType ETy, MVT LVT,
2139             const Value *SV, int O=0, unsigned Align=0, bool Vol=false)
2140    : LSBaseSDNode(ISD::LOAD, ChainPtrOff, 3,
2141                   VTs, AM, LVT, SV, O, Align, Vol) {
2142    SubclassData |= (unsigned short)ETy << 3;
2143  }
2144public:
2145
2146  /// getExtensionType - Return whether this is a plain node,
2147  /// or one of the varieties of value-extending loads.
2148  ISD::LoadExtType getExtensionType() const {
2149    return ISD::LoadExtType((SubclassData >> 3) & 3);
2150  }
2151
2152  const SDValue &getBasePtr() const { return getOperand(1); }
2153  const SDValue &getOffset() const { return getOperand(2); }
2154
2155  static bool classof(const LoadSDNode *) { return true; }
2156  static bool classof(const SDNode *N) {
2157    return N->getOpcode() == ISD::LOAD;
2158  }
2159};
2160
2161/// StoreSDNode - This class is used to represent ISD::STORE nodes.
2162///
2163class StoreSDNode : public LSBaseSDNode {
2164  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
2165protected:
2166  friend class SelectionDAG;
2167  StoreSDNode(SDValue *ChainValuePtrOff, SDVTList VTs,
2168              ISD::MemIndexedMode AM, bool isTrunc, MVT SVT,
2169              const Value *SV, int O=0, unsigned Align=0, bool Vol=false)
2170    : LSBaseSDNode(ISD::STORE, ChainValuePtrOff, 4,
2171                   VTs, AM, SVT, SV, O, Align, Vol) {
2172    SubclassData |= (unsigned short)isTrunc << 3;
2173  }
2174public:
2175
2176  /// isTruncatingStore - Return true if the op does a truncation before store.
2177  /// For integers this is the same as doing a TRUNCATE and storing the result.
2178  /// For floats, it is the same as doing an FP_ROUND and storing the result.
2179  bool isTruncatingStore() const { return (SubclassData >> 3) & 1; }
2180
2181  const SDValue &getValue() const { return getOperand(1); }
2182  const SDValue &getBasePtr() const { return getOperand(2); }
2183  const SDValue &getOffset() const { return getOperand(3); }
2184
2185  static bool classof(const StoreSDNode *) { return true; }
2186  static bool classof(const SDNode *N) {
2187    return N->getOpcode() == ISD::STORE;
2188  }
2189};
2190
2191
2192class SDNodeIterator : public forward_iterator<SDNode, ptrdiff_t> {
2193  SDNode *Node;
2194  unsigned Operand;
2195
2196  SDNodeIterator(SDNode *N, unsigned Op) : Node(N), Operand(Op) {}
2197public:
2198  bool operator==(const SDNodeIterator& x) const {
2199    return Operand == x.Operand;
2200  }
2201  bool operator!=(const SDNodeIterator& x) const { return !operator==(x); }
2202
2203  const SDNodeIterator &operator=(const SDNodeIterator &I) {
2204    assert(I.Node == Node && "Cannot assign iterators to two different nodes!");
2205    Operand = I.Operand;
2206    return *this;
2207  }
2208
2209  pointer operator*() const {
2210    return Node->getOperand(Operand).Val;
2211  }
2212  pointer operator->() const { return operator*(); }
2213
2214  SDNodeIterator& operator++() {                // Preincrement
2215    ++Operand;
2216    return *this;
2217  }
2218  SDNodeIterator operator++(int) { // Postincrement
2219    SDNodeIterator tmp = *this; ++*this; return tmp;
2220  }
2221
2222  static SDNodeIterator begin(SDNode *N) { return SDNodeIterator(N, 0); }
2223  static SDNodeIterator end  (SDNode *N) {
2224    return SDNodeIterator(N, N->getNumOperands());
2225  }
2226
2227  unsigned getOperand() const { return Operand; }
2228  const SDNode *getNode() const { return Node; }
2229};
2230
2231template <> struct GraphTraits<SDNode*> {
2232  typedef SDNode NodeType;
2233  typedef SDNodeIterator ChildIteratorType;
2234  static inline NodeType *getEntryNode(SDNode *N) { return N; }
2235  static inline ChildIteratorType child_begin(NodeType *N) {
2236    return SDNodeIterator::begin(N);
2237  }
2238  static inline ChildIteratorType child_end(NodeType *N) {
2239    return SDNodeIterator::end(N);
2240  }
2241};
2242
2243/// LargestSDNode - The largest SDNode class.
2244///
2245typedef LoadSDNode LargestSDNode;
2246
2247/// MostAlignedSDNode - The SDNode class with the greatest alignment
2248/// requirement.
2249///
2250typedef ConstantSDNode MostAlignedSDNode;
2251
2252namespace ISD {
2253  /// isNormalLoad - Returns true if the specified node is a non-extending
2254  /// and unindexed load.
2255  inline bool isNormalLoad(const SDNode *N) {
2256    const LoadSDNode *Ld = dyn_cast<LoadSDNode>(N);
2257    return Ld && Ld->getExtensionType() == ISD::NON_EXTLOAD &&
2258      Ld->getAddressingMode() == ISD::UNINDEXED;
2259  }
2260
2261  /// isNON_EXTLoad - Returns true if the specified node is a non-extending
2262  /// load.
2263  inline bool isNON_EXTLoad(const SDNode *N) {
2264    return isa<LoadSDNode>(N) &&
2265      cast<LoadSDNode>(N)->getExtensionType() == ISD::NON_EXTLOAD;
2266  }
2267
2268  /// isEXTLoad - Returns true if the specified node is a EXTLOAD.
2269  ///
2270  inline bool isEXTLoad(const SDNode *N) {
2271    return isa<LoadSDNode>(N) &&
2272      cast<LoadSDNode>(N)->getExtensionType() == ISD::EXTLOAD;
2273  }
2274
2275  /// isSEXTLoad - Returns true if the specified node is a SEXTLOAD.
2276  ///
2277  inline bool isSEXTLoad(const SDNode *N) {
2278    return isa<LoadSDNode>(N) &&
2279      cast<LoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD;
2280  }
2281
2282  /// isZEXTLoad - Returns true if the specified node is a ZEXTLOAD.
2283  ///
2284  inline bool isZEXTLoad(const SDNode *N) {
2285    return isa<LoadSDNode>(N) &&
2286      cast<LoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD;
2287  }
2288
2289  /// isUNINDEXEDLoad - Returns true if the specified node is an unindexed load.
2290  ///
2291  inline bool isUNINDEXEDLoad(const SDNode *N) {
2292    return isa<LoadSDNode>(N) &&
2293      cast<LoadSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
2294  }
2295
2296  /// isNormalStore - Returns true if the specified node is a non-truncating
2297  /// and unindexed store.
2298  inline bool isNormalStore(const SDNode *N) {
2299    const StoreSDNode *St = dyn_cast<StoreSDNode>(N);
2300    return St && !St->isTruncatingStore() &&
2301      St->getAddressingMode() == ISD::UNINDEXED;
2302  }
2303
2304  /// isNON_TRUNCStore - Returns true if the specified node is a non-truncating
2305  /// store.
2306  inline bool isNON_TRUNCStore(const SDNode *N) {
2307    return isa<StoreSDNode>(N) && !cast<StoreSDNode>(N)->isTruncatingStore();
2308  }
2309
2310  /// isTRUNCStore - Returns true if the specified node is a truncating
2311  /// store.
2312  inline bool isTRUNCStore(const SDNode *N) {
2313    return isa<StoreSDNode>(N) && cast<StoreSDNode>(N)->isTruncatingStore();
2314  }
2315
2316  /// isUNINDEXEDStore - Returns true if the specified node is an
2317  /// unindexed store.
2318  inline bool isUNINDEXEDStore(const SDNode *N) {
2319    return isa<StoreSDNode>(N) &&
2320      cast<StoreSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
2321  }
2322}
2323
2324
2325} // end llvm namespace
2326
2327#endif
2328