SelectionDAGNodes.h revision a844bdeab31ef04221e7ef59a8467893584cc14d
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"
26#include "llvm/ADT/APFloat.h"
27#include "llvm/CodeGen/ValueTypes.h"
28#include "llvm/Support/DataTypes.h"
29#include <cassert>
30
31namespace llvm {
32
33class SelectionDAG;
34class GlobalValue;
35class MachineBasicBlock;
36class MachineConstantPoolValue;
37class SDNode;
38template <typename T> struct DenseMapInfo;
39template <typename T> struct simplify_type;
40template <typename T> struct ilist_traits;
41template<typename NodeTy, typename Traits> class iplist;
42template<typename NodeTy> class ilist_iterator;
43
44/// SDVTList - This represents a list of ValueType's that has been intern'd by
45/// a SelectionDAG.  Instances of this simple value class are returned by
46/// SelectionDAG::getVTList(...).
47///
48struct SDVTList {
49  const MVT::ValueType *VTs;
50  unsigned short NumVTs;
51};
52
53/// ISD namespace - This namespace contains an enum which represents all of the
54/// SelectionDAG node types and value types.
55///
56namespace ISD {
57  namespace ParamFlags {
58  enum Flags {
59    NoFlagSet         = 0,
60    ZExt              = 1<<0,  ///< Parameter should be zero extended
61    ZExtOffs          = 0,
62    SExt              = 1<<1,  ///< Parameter should be sign extended
63    SExtOffs          = 1,
64    InReg             = 1<<2,  ///< Parameter should be passed in register
65    InRegOffs         = 2,
66    StructReturn      = 1<<3,  ///< Hidden struct-return pointer
67    StructReturnOffs  = 3,
68    ByVal             = 1<<4,  ///< Struct passed by value
69    ByValOffs         = 4,
70    Nest              = 1<<5,  ///< Parameter is nested function static chain
71    NestOffs          = 5,
72    ByValAlign        = 0xF << 6, //< The alignment of the struct
73    ByValAlignOffs    = 6,
74    ByValSize         = 0x1ffff << 10, //< The size of the struct
75    ByValSizeOffs     = 10,
76    OrigAlignment     = 0x1F<<27,
77    OrigAlignmentOffs = 27
78  };
79  }
80
81  //===--------------------------------------------------------------------===//
82  /// ISD::NodeType enum - This enum defines all of the operators valid in a
83  /// SelectionDAG.
84  ///
85  enum NodeType {
86    // DELETED_NODE - This is an illegal flag value that is used to catch
87    // errors.  This opcode is not a legal opcode for any node.
88    DELETED_NODE,
89
90    // EntryToken - This is the marker used to indicate the start of the region.
91    EntryToken,
92
93    // Token factor - This node takes multiple tokens as input and produces a
94    // single token result.  This is used to represent the fact that the operand
95    // operators are independent of each other.
96    TokenFactor,
97
98    // AssertSext, AssertZext - These nodes record if a register contains a
99    // value that has already been zero or sign extended from a narrower type.
100    // These nodes take two operands.  The first is the node that has already
101    // been extended, and the second is a value type node indicating the width
102    // of the extension
103    AssertSext, AssertZext,
104
105    // Various leaf nodes.
106    STRING, BasicBlock, VALUETYPE, CONDCODE, Register,
107    Constant, ConstantFP,
108    GlobalAddress, GlobalTLSAddress, FrameIndex,
109    JumpTable, ConstantPool, ExternalSymbol,
110
111    // The address of the GOT
112    GLOBAL_OFFSET_TABLE,
113
114    // FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and
115    // llvm.returnaddress on the DAG.  These nodes take one operand, the index
116    // of the frame or return address to return.  An index of zero corresponds
117    // to the current function's frame or return address, an index of one to the
118    // parent's frame or return address, and so on.
119    FRAMEADDR, RETURNADDR,
120
121    // FRAME_TO_ARGS_OFFSET - This node represents offset from frame pointer to
122    // first (possible) on-stack argument. This is needed for correct stack
123    // adjustment during unwind.
124    FRAME_TO_ARGS_OFFSET,
125
126    // RESULT, OUTCHAIN = EXCEPTIONADDR(INCHAIN) - This node represents the
127    // address of the exception block on entry to an landing pad block.
128    EXCEPTIONADDR,
129
130    // RESULT, OUTCHAIN = EHSELECTION(INCHAIN, EXCEPTION) - This node represents
131    // the selection index of the exception thrown.
132    EHSELECTION,
133
134    // OUTCHAIN = EH_RETURN(INCHAIN, OFFSET, HANDLER) - This node represents
135    // 'eh_return' gcc dwarf builtin, which is used to return from
136    // exception. The general meaning is: adjust stack by OFFSET and pass
137    // execution to HANDLER. Many platform-related details also :)
138    EH_RETURN,
139
140    // TargetConstant* - Like Constant*, but the DAG does not do any folding or
141    // simplification of the constant.
142    TargetConstant,
143    TargetConstantFP,
144
145    // TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or
146    // anything else with this node, and this is valid in the target-specific
147    // dag, turning into a GlobalAddress operand.
148    TargetGlobalAddress,
149    TargetGlobalTLSAddress,
150    TargetFrameIndex,
151    TargetJumpTable,
152    TargetConstantPool,
153    TargetExternalSymbol,
154
155    /// RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...)
156    /// This node represents a target intrinsic function with no side effects.
157    /// The first operand is the ID number of the intrinsic from the
158    /// llvm::Intrinsic namespace.  The operands to the intrinsic follow.  The
159    /// node has returns the result of the intrinsic.
160    INTRINSIC_WO_CHAIN,
161
162    /// RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...)
163    /// This node represents a target intrinsic function with side effects that
164    /// returns a result.  The first operand is a chain pointer.  The second is
165    /// the ID number of the intrinsic from the llvm::Intrinsic namespace.  The
166    /// operands to the intrinsic follow.  The node has two results, the result
167    /// of the intrinsic and an output chain.
168    INTRINSIC_W_CHAIN,
169
170    /// OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...)
171    /// This node represents a target intrinsic function with side effects that
172    /// does not return a result.  The first operand is a chain pointer.  The
173    /// second is the ID number of the intrinsic from the llvm::Intrinsic
174    /// namespace.  The operands to the intrinsic follow.
175    INTRINSIC_VOID,
176
177    // CopyToReg - This node has three operands: a chain, a register number to
178    // set to this value, and a value.
179    CopyToReg,
180
181    // CopyFromReg - This node indicates that the input value is a virtual or
182    // physical register that is defined outside of the scope of this
183    // SelectionDAG.  The register is available from the RegisterSDNode object.
184    CopyFromReg,
185
186    // UNDEF - An undefined node
187    UNDEF,
188
189    /// FORMAL_ARGUMENTS(CHAIN, CC#, ISVARARG, FLAG0, ..., FLAGn) - This node
190    /// represents the formal arguments for a function.  CC# is a Constant value
191    /// indicating the calling convention of the function, and ISVARARG is a
192    /// flag that indicates whether the function is varargs or not. This node
193    /// has one result value for each incoming argument, plus one for the output
194    /// chain. It must be custom legalized. See description of CALL node for
195    /// FLAG argument contents explanation.
196    ///
197    FORMAL_ARGUMENTS,
198
199    /// RV1, RV2...RVn, CHAIN = CALL(CHAIN, CC#, ISVARARG, ISTAILCALL, CALLEE,
200    ///                              ARG0, FLAG0, ARG1, FLAG1, ... ARGn, FLAGn)
201    /// This node represents a fully general function call, before the legalizer
202    /// runs.  This has one result value for each argument / flag pair, plus
203    /// a chain result. It must be custom legalized. Flag argument indicates
204    /// misc. argument attributes. Currently:
205    /// Bit 0 - signness
206    /// Bit 1 - 'inreg' attribute
207    /// Bit 2 - 'sret' attribute
208    /// Bit 4 - 'byval' attribute
209    /// Bit 5 - 'nest' attribute
210    /// Bit 6-9 - alignment of byval structures
211    /// Bit 10-26 - size of byval structures
212    /// Bits 31:27 - argument ABI alignment in the first argument piece and
213    /// alignment '1' in other argument pieces.
214    CALL,
215
216    // EXTRACT_ELEMENT - This is used to get the first or second (determined by
217    // a Constant, which is required to be operand #1), element of the aggregate
218    // value specified as operand #0.  This is only for use before legalization,
219    // for values that will be broken into multiple registers.
220    EXTRACT_ELEMENT,
221
222    // BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.  Given
223    // two values of the same integer value type, this produces a value twice as
224    // big.  Like EXTRACT_ELEMENT, this can only be used before legalization.
225    BUILD_PAIR,
226
227    // MERGE_VALUES - This node takes multiple discrete operands and returns
228    // them all as its individual results.  This nodes has exactly the same
229    // number of inputs and outputs, and is only valid before legalization.
230    // This node is useful for some pieces of the code generator that want to
231    // think about a single node with multiple results, not multiple nodes.
232    MERGE_VALUES,
233
234    // Simple integer binary arithmetic operators.
235    ADD, SUB, MUL, SDIV, UDIV, SREM, UREM,
236
237    // SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing
238    // a signed/unsigned value of type i[2*N], and return the full value as
239    // two results, each of type iN.
240    SMUL_LOHI, UMUL_LOHI,
241
242    // SDIVREM/UDIVREM - Divide two integers and produce both a quotient and
243    // remainder result.
244    SDIVREM, UDIVREM,
245
246    // CARRY_FALSE - This node is used when folding other nodes,
247    // like ADDC/SUBC, which indicate the carry result is always false.
248    CARRY_FALSE,
249
250    // Carry-setting nodes for multiple precision addition and subtraction.
251    // These nodes take two operands of the same value type, and produce two
252    // results.  The first result is the normal add or sub result, the second
253    // result is the carry flag result.
254    ADDC, SUBC,
255
256    // Carry-using nodes for multiple precision addition and subtraction.  These
257    // nodes take three operands: The first two are the normal lhs and rhs to
258    // the add or sub, and the third is the input carry flag.  These nodes
259    // produce two results; the normal result of the add or sub, and the output
260    // carry flag.  These nodes both read and write a carry flag to allow them
261    // to them to be chained together for add and sub of arbitrarily large
262    // values.
263    ADDE, SUBE,
264
265    // Simple binary floating point operators.
266    FADD, FSUB, FMUL, FDIV, FREM,
267
268    // FCOPYSIGN(X, Y) - Return the value of X with the sign of Y.  NOTE: This
269    // DAG node does not require that X and Y have the same type, just that they
270    // are both floating point.  X and the result must have the same type.
271    // FCOPYSIGN(f32, f64) is allowed.
272    FCOPYSIGN,
273
274    // INT = FGETSIGN(FP) - Return the sign bit of the specified floating point
275    // value as an integer 0/1 value.
276    FGETSIGN,
277
278    /// BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a vector
279    /// with the specified, possibly variable, elements.  The number of elements
280    /// is required to be a power of two.
281    BUILD_VECTOR,
282
283    /// INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element
284    /// at IDX replaced with VAL.
285    INSERT_VECTOR_ELT,
286
287    /// EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR
288    /// identified by the (potentially variable) element number IDX.
289    EXTRACT_VECTOR_ELT,
290
291    /// CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of
292    /// vector type with the same length and element type, this produces a
293    /// concatenated vector result value, with length equal to the sum of the
294    /// lengths of the input vectors.
295    CONCAT_VECTORS,
296
297    /// EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR (an
298    /// vector value) starting with the (potentially variable) element number
299    /// IDX, which must be a multiple of the result vector length.
300    EXTRACT_SUBVECTOR,
301
302    /// VECTOR_SHUFFLE(VEC1, VEC2, SHUFFLEVEC) - Returns a vector, of the same
303    /// type as VEC1/VEC2.  SHUFFLEVEC is a BUILD_VECTOR of constant int values
304    /// (regardless of whether its datatype is legal or not) that indicate
305    /// which value each result element will get.  The elements of VEC1/VEC2 are
306    /// enumerated in order.  This is quite similar to the Altivec 'vperm'
307    /// instruction, except that the indices must be constants and are in terms
308    /// of the element size of VEC1/VEC2, not in terms of bytes.
309    VECTOR_SHUFFLE,
310
311    /// SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a
312    /// scalar value into element 0 of the resultant vector type.  The top
313    /// elements 1 to N-1 of the N-element vector are undefined.
314    SCALAR_TO_VECTOR,
315
316    // EXTRACT_SUBREG - This node is used to extract a sub-register value.
317    // This node takes a superreg and a constant sub-register index as operands.
318    EXTRACT_SUBREG,
319
320    // INSERT_SUBREG - This node is used to insert a sub-register value.
321    // This node takes a superreg, a subreg value, and a constant sub-register
322    // index as operands.
323    INSERT_SUBREG,
324
325    // MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing
326    // an unsigned/signed value of type i[2*N], then return the top part.
327    MULHU, MULHS,
328
329    // Bitwise operators - logical and, logical or, logical xor, shift left,
330    // shift right algebraic (shift in sign bits), shift right logical (shift in
331    // zeroes), rotate left, rotate right, and byteswap.
332    AND, OR, XOR, SHL, SRA, SRL, ROTL, ROTR, BSWAP,
333
334    // Counting operators
335    CTTZ, CTLZ, CTPOP,
336
337    // Select(COND, TRUEVAL, FALSEVAL)
338    SELECT,
339
340    // Select with condition operator - This selects between a true value and
341    // a false value (ops #2 and #3) based on the boolean result of comparing
342    // the lhs and rhs (ops #0 and #1) of a conditional expression with the
343    // condition code in op #4, a CondCodeSDNode.
344    SELECT_CC,
345
346    // SetCC operator - This evaluates to a boolean (i1) true value if the
347    // condition is true.  The operands to this are the left and right operands
348    // to compare (ops #0, and #1) and the condition code to compare them with
349    // (op #2) as a CondCodeSDNode.
350    SETCC,
351
352    // SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded
353    // integer shift operations, just like ADD/SUB_PARTS.  The operation
354    // ordering is:
355    //       [Lo,Hi] = op [LoLHS,HiLHS], Amt
356    SHL_PARTS, SRA_PARTS, SRL_PARTS,
357
358    // Conversion operators.  These are all single input single output
359    // operations.  For all of these, the result type must be strictly
360    // wider or narrower (depending on the operation) than the source
361    // type.
362
363    // SIGN_EXTEND - Used for integer types, replicating the sign bit
364    // into new bits.
365    SIGN_EXTEND,
366
367    // ZERO_EXTEND - Used for integer types, zeroing the new bits.
368    ZERO_EXTEND,
369
370    // ANY_EXTEND - Used for integer types.  The high bits are undefined.
371    ANY_EXTEND,
372
373    // TRUNCATE - Completely drop the high bits.
374    TRUNCATE,
375
376    // [SU]INT_TO_FP - These operators convert integers (whose interpreted sign
377    // depends on the first letter) to floating point.
378    SINT_TO_FP,
379    UINT_TO_FP,
380
381    // SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to
382    // sign extend a small value in a large integer register (e.g. sign
383    // extending the low 8 bits of a 32-bit register to fill the top 24 bits
384    // with the 7th bit).  The size of the smaller type is indicated by the 1th
385    // operand, a ValueType node.
386    SIGN_EXTEND_INREG,
387
388    /// FP_TO_[US]INT - Convert a floating point value to a signed or unsigned
389    /// integer.
390    FP_TO_SINT,
391    FP_TO_UINT,
392
393    /// X = FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type
394    /// down to the precision of the destination VT.  TRUNC is a flag, which is
395    /// always an integer that is zero or one.  If TRUNC is 0, this is a
396    /// normal rounding, if it is 1, this FP_ROUND is known to not change the
397    /// value of Y.
398    ///
399    /// The TRUNC = 1 case is used in cases where we know that the value will
400    /// not be modified by the node, because Y is not using any of the extra
401    /// precision of source type.  This allows certain transformations like
402    /// FP_EXTEND(FP_ROUND(X,1)) -> X which are not safe for
403    /// FP_EXTEND(FP_ROUND(X,0)) because the extra bits aren't removed.
404    FP_ROUND,
405
406    // FLT_ROUNDS_ - Returns current rounding mode:
407    // -1 Undefined
408    //  0 Round to 0
409    //  1 Round to nearest
410    //  2 Round to +inf
411    //  3 Round to -inf
412    FLT_ROUNDS_,
413
414    /// X = FP_ROUND_INREG(Y, VT) - This operator takes an FP register, and
415    /// rounds it to a floating point value.  It then promotes it and returns it
416    /// in a register of the same size.  This operation effectively just
417    /// discards excess precision.  The type to round down to is specified by
418    /// the VT operand, a VTSDNode.
419    FP_ROUND_INREG,
420
421    /// X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
422    FP_EXTEND,
423
424    // BIT_CONVERT - Theis operator converts between integer and FP values, as
425    // if one was stored to memory as integer and the other was loaded from the
426    // same address (or equivalently for vector format conversions, etc).  The
427    // source and result are required to have the same bit size (e.g.
428    // f32 <-> i32).  This can also be used for int-to-int or fp-to-fp
429    // conversions, but that is a noop, deleted by getNode().
430    BIT_CONVERT,
431
432    // FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, FPOW - Perform unary floating point
433    // negation, absolute value, square root, sine and cosine, powi, and pow
434    // operations.
435    FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, FPOW,
436
437    // LOAD and STORE have token chains as their first operand, then the same
438    // operands as an LLVM load/store instruction, then an offset node that
439    // is added / subtracted from the base pointer to form the address (for
440    // indexed memory ops).
441    LOAD, STORE,
442
443    // DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned
444    // to a specified boundary.  This node always has two return values: a new
445    // stack pointer value and a chain. The first operand is the token chain,
446    // the second is the number of bytes to allocate, and the third is the
447    // alignment boundary.  The size is guaranteed to be a multiple of the stack
448    // alignment, and the alignment is guaranteed to be bigger than the stack
449    // alignment (if required) or 0 to get standard stack alignment.
450    DYNAMIC_STACKALLOC,
451
452    // Control flow instructions.  These all have token chains.
453
454    // BR - Unconditional branch.  The first operand is the chain
455    // operand, the second is the MBB to branch to.
456    BR,
457
458    // BRIND - Indirect branch.  The first operand is the chain, the second
459    // is the value to branch to, which must be of the same type as the target's
460    // pointer type.
461    BRIND,
462
463    // BR_JT - Jumptable branch. The first operand is the chain, the second
464    // is the jumptable index, the last one is the jumptable entry index.
465    BR_JT,
466
467    // BRCOND - Conditional branch.  The first operand is the chain,
468    // the second is the condition, the third is the block to branch
469    // to if the condition is true.
470    BRCOND,
471
472    // BR_CC - Conditional branch.  The behavior is like that of SELECT_CC, in
473    // that the condition is represented as condition code, and two nodes to
474    // compare, rather than as a combined SetCC node.  The operands in order are
475    // chain, cc, lhs, rhs, block to branch to if condition is true.
476    BR_CC,
477
478    // RET - Return from function.  The first operand is the chain,
479    // and any subsequent operands are pairs of return value and return value
480    // signness for the function.  This operation can have variable number of
481    // operands.
482    RET,
483
484    // INLINEASM - Represents an inline asm block.  This node always has two
485    // return values: a chain and a flag result.  The inputs are as follows:
486    //   Operand #0   : Input chain.
487    //   Operand #1   : a ExternalSymbolSDNode with a pointer to the asm string.
488    //   Operand #2n+2: A RegisterNode.
489    //   Operand #2n+3: A TargetConstant, indicating if the reg is a use/def
490    //   Operand #last: Optional, an incoming flag.
491    INLINEASM,
492
493    // LABEL - Represents a label in mid basic block used to track
494    // locations needed for debug and exception handling tables.  This node
495    // returns a chain.
496    //   Operand #0 : input chain.
497    //   Operand #1 : module unique number use to identify the label.
498    //   Operand #2 : 0 indicates a debug label (e.g. stoppoint), 1 indicates
499    //                a EH label, 2 indicates unknown label type.
500    LABEL,
501
502    // DECLARE - Represents a llvm.dbg.declare intrinsic. It's used to track
503    // local variable declarations for debugging information. First operand is
504    // a chain, while the next two operands are first two arguments (address
505    // and variable) of a llvm.dbg.declare instruction.
506    DECLARE,
507
508    // STACKSAVE - STACKSAVE has one operand, an input chain.  It produces a
509    // value, the same type as the pointer type for the system, and an output
510    // chain.
511    STACKSAVE,
512
513    // STACKRESTORE has two operands, an input chain and a pointer to restore to
514    // it returns an output chain.
515    STACKRESTORE,
516
517    // MEMSET/MEMCPY/MEMMOVE - The first operand is the chain. The following
518    // correspond to the operands of the LLVM intrinsic functions and the last
519    // one is AlwaysInline.  The only result is a token chain.  The alignment
520    // argument is guaranteed to be a Constant node.
521    MEMSET,
522    MEMMOVE,
523    MEMCPY,
524
525    // CALLSEQ_START/CALLSEQ_END - These operators mark the beginning and end of
526    // a call sequence, and carry arbitrary information that target might want
527    // to know.  The first operand is a chain, the rest are specified by the
528    // target and not touched by the DAG optimizers.
529    CALLSEQ_START,  // Beginning of a call sequence
530    CALLSEQ_END,    // End of a call sequence
531
532    // VAARG - VAARG has three operands: an input chain, a pointer, and a
533    // SRCVALUE.  It returns a pair of values: the vaarg value and a new chain.
534    VAARG,
535
536    // VACOPY - VACOPY has five operands: an input chain, a destination pointer,
537    // a source pointer, a SRCVALUE for the destination, and a SRCVALUE for the
538    // source.
539    VACOPY,
540
541    // VAEND, VASTART - VAEND and VASTART have three operands: an input chain, a
542    // pointer, and a SRCVALUE.
543    VAEND, VASTART,
544
545    // SRCVALUE - This corresponds to a Value*, and is used to associate memory
546    // locations with their value.  This allows one use alias analysis
547    // information in the backend.
548    SRCVALUE,
549
550    // PCMARKER - This corresponds to the pcmarker intrinsic.
551    PCMARKER,
552
553    // READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic.
554    // The only operand is a chain and a value and a chain are produced.  The
555    // value is the contents of the architecture specific cycle counter like
556    // register (or other high accuracy low latency clock source)
557    READCYCLECOUNTER,
558
559    // HANDLENODE node - Used as a handle for various purposes.
560    HANDLENODE,
561
562    // LOCATION - This node is used to represent a source location for debug
563    // info.  It takes token chain as input, then a line number, then a column
564    // number, then a filename, then a working dir.  It produces a token chain
565    // as output.
566    LOCATION,
567
568    // DEBUG_LOC - This node is used to represent source line information
569    // embedded in the code.  It takes a token chain as input, then a line
570    // number, then a column then a file id (provided by MachineModuleInfo.) It
571    // produces a token chain as output.
572    DEBUG_LOC,
573
574    // TRAMPOLINE - This corresponds to the init_trampoline intrinsic.
575    // It takes as input a token chain, the pointer to the trampoline,
576    // the pointer to the nested function, the pointer to pass for the
577    // 'nest' parameter, a SRCVALUE for the trampoline and another for
578    // the nested function (allowing targets to access the original
579    // Function*).  It produces the result of the intrinsic and a token
580    // chain as output.
581    TRAMPOLINE,
582
583    // TRAP - Trapping instruction
584    TRAP,
585
586    // BUILTIN_OP_END - This must be the last enum value in this list.
587    BUILTIN_OP_END
588  };
589
590  /// Node predicates
591
592  /// isBuildVectorAllOnes - Return true if the specified node is a
593  /// BUILD_VECTOR where all of the elements are ~0 or undef.
594  bool isBuildVectorAllOnes(const SDNode *N);
595
596  /// isBuildVectorAllZeros - Return true if the specified node is a
597  /// BUILD_VECTOR where all of the elements are 0 or undef.
598  bool isBuildVectorAllZeros(const SDNode *N);
599
600  /// isDebugLabel - Return true if the specified node represents a debug
601  /// label (i.e. ISD::LABEL or TargetInstrInfo::LANEL node and third operand
602  /// is 0).
603  bool isDebugLabel(const SDNode *N);
604
605  //===--------------------------------------------------------------------===//
606  /// MemIndexedMode enum - This enum defines the load / store indexed
607  /// addressing modes.
608  ///
609  /// UNINDEXED    "Normal" load / store. The effective address is already
610  ///              computed and is available in the base pointer. The offset
611  ///              operand is always undefined. In addition to producing a
612  ///              chain, an unindexed load produces one value (result of the
613  ///              load); an unindexed store does not produces a value.
614  ///
615  /// PRE_INC      Similar to the unindexed mode where the effective address is
616  /// PRE_DEC      the value of the base pointer add / subtract the offset.
617  ///              It considers the computation as being folded into the load /
618  ///              store operation (i.e. the load / store does the address
619  ///              computation as well as performing the memory transaction).
620  ///              The base operand is always undefined. In addition to
621  ///              producing a chain, pre-indexed load produces two values
622  ///              (result of the load and the result of the address
623  ///              computation); a pre-indexed store produces one value (result
624  ///              of the address computation).
625  ///
626  /// POST_INC     The effective address is the value of the base pointer. The
627  /// POST_DEC     value of the offset operand is then added to / subtracted
628  ///              from the base after memory transaction. In addition to
629  ///              producing a chain, post-indexed load produces two values
630  ///              (the result of the load and the result of the base +/- offset
631  ///              computation); a post-indexed store produces one value (the
632  ///              the result of the base +/- offset computation).
633  ///
634  enum MemIndexedMode {
635    UNINDEXED = 0,
636    PRE_INC,
637    PRE_DEC,
638    POST_INC,
639    POST_DEC,
640    LAST_INDEXED_MODE
641  };
642
643  //===--------------------------------------------------------------------===//
644  /// LoadExtType enum - This enum defines the three variants of LOADEXT
645  /// (load with extension).
646  ///
647  /// SEXTLOAD loads the integer operand and sign extends it to a larger
648  ///          integer result type.
649  /// ZEXTLOAD loads the integer operand and zero extends it to a larger
650  ///          integer result type.
651  /// EXTLOAD  is used for three things: floating point extending loads,
652  ///          integer extending loads [the top bits are undefined], and vector
653  ///          extending loads [load into low elt].
654  ///
655  enum LoadExtType {
656    NON_EXTLOAD = 0,
657    EXTLOAD,
658    SEXTLOAD,
659    ZEXTLOAD,
660    LAST_LOADX_TYPE
661  };
662
663  //===--------------------------------------------------------------------===//
664  /// ISD::CondCode enum - These are ordered carefully to make the bitfields
665  /// below work out, when considering SETFALSE (something that never exists
666  /// dynamically) as 0.  "U" -> Unsigned (for integer operands) or Unordered
667  /// (for floating point), "L" -> Less than, "G" -> Greater than, "E" -> Equal
668  /// to.  If the "N" column is 1, the result of the comparison is undefined if
669  /// the input is a NAN.
670  ///
671  /// All of these (except for the 'always folded ops') should be handled for
672  /// floating point.  For integer, only the SETEQ,SETNE,SETLT,SETLE,SETGT,
673  /// SETGE,SETULT,SETULE,SETUGT, and SETUGE opcodes are used.
674  ///
675  /// Note that these are laid out in a specific order to allow bit-twiddling
676  /// to transform conditions.
677  enum CondCode {
678    // Opcode          N U L G E       Intuitive operation
679    SETFALSE,      //    0 0 0 0       Always false (always folded)
680    SETOEQ,        //    0 0 0 1       True if ordered and equal
681    SETOGT,        //    0 0 1 0       True if ordered and greater than
682    SETOGE,        //    0 0 1 1       True if ordered and greater than or equal
683    SETOLT,        //    0 1 0 0       True if ordered and less than
684    SETOLE,        //    0 1 0 1       True if ordered and less than or equal
685    SETONE,        //    0 1 1 0       True if ordered and operands are unequal
686    SETO,          //    0 1 1 1       True if ordered (no nans)
687    SETUO,         //    1 0 0 0       True if unordered: isnan(X) | isnan(Y)
688    SETUEQ,        //    1 0 0 1       True if unordered or equal
689    SETUGT,        //    1 0 1 0       True if unordered or greater than
690    SETUGE,        //    1 0 1 1       True if unordered, greater than, or equal
691    SETULT,        //    1 1 0 0       True if unordered or less than
692    SETULE,        //    1 1 0 1       True if unordered, less than, or equal
693    SETUNE,        //    1 1 1 0       True if unordered or not equal
694    SETTRUE,       //    1 1 1 1       Always true (always folded)
695    // Don't care operations: undefined if the input is a nan.
696    SETFALSE2,     //  1 X 0 0 0       Always false (always folded)
697    SETEQ,         //  1 X 0 0 1       True if equal
698    SETGT,         //  1 X 0 1 0       True if greater than
699    SETGE,         //  1 X 0 1 1       True if greater than or equal
700    SETLT,         //  1 X 1 0 0       True if less than
701    SETLE,         //  1 X 1 0 1       True if less than or equal
702    SETNE,         //  1 X 1 1 0       True if not equal
703    SETTRUE2,      //  1 X 1 1 1       Always true (always folded)
704
705    SETCC_INVALID       // Marker value.
706  };
707
708  /// isSignedIntSetCC - Return true if this is a setcc instruction that
709  /// performs a signed comparison when used with integer operands.
710  inline bool isSignedIntSetCC(CondCode Code) {
711    return Code == SETGT || Code == SETGE || Code == SETLT || Code == SETLE;
712  }
713
714  /// isUnsignedIntSetCC - Return true if this is a setcc instruction that
715  /// performs an unsigned comparison when used with integer operands.
716  inline bool isUnsignedIntSetCC(CondCode Code) {
717    return Code == SETUGT || Code == SETUGE || Code == SETULT || Code == SETULE;
718  }
719
720  /// isTrueWhenEqual - Return true if the specified condition returns true if
721  /// the two operands to the condition are equal.  Note that if one of the two
722  /// operands is a NaN, this value is meaningless.
723  inline bool isTrueWhenEqual(CondCode Cond) {
724    return ((int)Cond & 1) != 0;
725  }
726
727  /// getUnorderedFlavor - This function returns 0 if the condition is always
728  /// false if an operand is a NaN, 1 if the condition is always true if the
729  /// operand is a NaN, and 2 if the condition is undefined if the operand is a
730  /// NaN.
731  inline unsigned getUnorderedFlavor(CondCode Cond) {
732    return ((int)Cond >> 3) & 3;
733  }
734
735  /// getSetCCInverse - Return the operation corresponding to !(X op Y), where
736  /// 'op' is a valid SetCC operation.
737  CondCode getSetCCInverse(CondCode Operation, bool isInteger);
738
739  /// getSetCCSwappedOperands - Return the operation corresponding to (Y op X)
740  /// when given the operation for (X op Y).
741  CondCode getSetCCSwappedOperands(CondCode Operation);
742
743  /// getSetCCOrOperation - Return the result of a logical OR between different
744  /// comparisons of identical values: ((X op1 Y) | (X op2 Y)).  This
745  /// function returns SETCC_INVALID if it is not possible to represent the
746  /// resultant comparison.
747  CondCode getSetCCOrOperation(CondCode Op1, CondCode Op2, bool isInteger);
748
749  /// getSetCCAndOperation - Return the result of a logical AND between
750  /// different comparisons of identical values: ((X op1 Y) & (X op2 Y)).  This
751  /// function returns SETCC_INVALID if it is not possible to represent the
752  /// resultant comparison.
753  CondCode getSetCCAndOperation(CondCode Op1, CondCode Op2, bool isInteger);
754}  // end llvm::ISD namespace
755
756
757//===----------------------------------------------------------------------===//
758/// SDOperand - Unlike LLVM values, Selection DAG nodes may return multiple
759/// values as the result of a computation.  Many nodes return multiple values,
760/// from loads (which define a token and a return value) to ADDC (which returns
761/// a result and a carry value), to calls (which may return an arbitrary number
762/// of values).
763///
764/// As such, each use of a SelectionDAG computation must indicate the node that
765/// computes it as well as which return value to use from that node.  This pair
766/// of information is represented with the SDOperand value type.
767///
768class SDOperand {
769public:
770  SDNode *Val;        // The node defining the value we are using.
771  unsigned ResNo;     // Which return value of the node we are using.
772
773  SDOperand() : Val(0), ResNo(0) {}
774  SDOperand(SDNode *val, unsigned resno) : Val(val), ResNo(resno) {}
775
776  bool operator==(const SDOperand &O) const {
777    return Val == O.Val && ResNo == O.ResNo;
778  }
779  bool operator!=(const SDOperand &O) const {
780    return !operator==(O);
781  }
782  bool operator<(const SDOperand &O) const {
783    return Val < O.Val || (Val == O.Val && ResNo < O.ResNo);
784  }
785
786  SDOperand getValue(unsigned R) const {
787    return SDOperand(Val, R);
788  }
789
790  // isOperand - Return true if this node is an operand of N.
791  bool isOperand(SDNode *N) const;
792
793  /// getValueType - Return the ValueType of the referenced return value.
794  ///
795  inline MVT::ValueType getValueType() const;
796
797  // Forwarding methods - These forward to the corresponding methods in SDNode.
798  inline unsigned getOpcode() const;
799  inline unsigned getNumOperands() const;
800  inline const SDOperand &getOperand(unsigned i) const;
801  inline uint64_t getConstantOperandVal(unsigned i) const;
802  inline bool isTargetOpcode() const;
803  inline unsigned getTargetOpcode() const;
804
805
806  /// reachesChainWithoutSideEffects - Return true if this operand (which must
807  /// be a chain) reaches the specified operand without crossing any
808  /// side-effecting instructions.  In practice, this looks through token
809  /// factors and non-volatile loads.  In order to remain efficient, this only
810  /// looks a couple of nodes in, it does not do an exhaustive search.
811  bool reachesChainWithoutSideEffects(SDOperand Dest, unsigned Depth = 2) const;
812
813  /// hasOneUse - Return true if there is exactly one operation using this
814  /// result value of the defining operator.
815  inline bool hasOneUse() const;
816
817  /// use_empty - Return true if there are no operations using this
818  /// result value of the defining operator.
819  inline bool use_empty() const;
820};
821
822
823template<> struct DenseMapInfo<SDOperand> {
824  static inline SDOperand getEmptyKey() { return SDOperand((SDNode*)-1, -1U); }
825  static inline SDOperand getTombstoneKey() { return SDOperand((SDNode*)-1, 0);}
826  static unsigned getHashValue(const SDOperand &Val) {
827    return (unsigned)((uintptr_t)Val.Val >> 4) ^
828           (unsigned)((uintptr_t)Val.Val >> 9) + Val.ResNo;
829  }
830  static bool isEqual(const SDOperand &LHS, const SDOperand &RHS) {
831    return LHS == RHS;
832  }
833  static bool isPod() { return true; }
834};
835
836/// simplify_type specializations - Allow casting operators to work directly on
837/// SDOperands as if they were SDNode*'s.
838template<> struct simplify_type<SDOperand> {
839  typedef SDNode* SimpleType;
840  static SimpleType getSimplifiedValue(const SDOperand &Val) {
841    return static_cast<SimpleType>(Val.Val);
842  }
843};
844template<> struct simplify_type<const SDOperand> {
845  typedef SDNode* SimpleType;
846  static SimpleType getSimplifiedValue(const SDOperand &Val) {
847    return static_cast<SimpleType>(Val.Val);
848  }
849};
850
851
852/// SDNode - Represents one node in the SelectionDAG.
853///
854class SDNode : public FoldingSetNode {
855  /// NodeType - The operation that this node performs.
856  ///
857  unsigned short NodeType;
858
859  /// OperandsNeedDelete - This is true if OperandList was new[]'d.  If true,
860  /// then they will be delete[]'d when the node is destroyed.
861  bool OperandsNeedDelete : 1;
862
863  /// NodeId - Unique id per SDNode in the DAG.
864  int NodeId;
865
866  /// OperandList - The values that are used by this operation.
867  ///
868  SDOperand *OperandList;
869
870  /// ValueList - The types of the values this node defines.  SDNode's may
871  /// define multiple values simultaneously.
872  const MVT::ValueType *ValueList;
873
874  /// NumOperands/NumValues - The number of entries in the Operand/Value list.
875  unsigned short NumOperands, NumValues;
876
877  /// Prev/Next pointers - These pointers form the linked list of of the
878  /// AllNodes list in the current DAG.
879  SDNode *Prev, *Next;
880  friend struct ilist_traits<SDNode>;
881
882  /// Uses - These are all of the SDNode's that use a value produced by this
883  /// node.
884  SmallVector<SDNode*,3> Uses;
885
886  // Out-of-line virtual method to give class a home.
887  virtual void ANCHOR();
888public:
889  virtual ~SDNode() {
890    assert(NumOperands == 0 && "Operand list not cleared before deletion");
891    NodeType = ISD::DELETED_NODE;
892  }
893
894  //===--------------------------------------------------------------------===//
895  //  Accessors
896  //
897  unsigned getOpcode()  const { return NodeType; }
898  bool isTargetOpcode() const { return NodeType >= ISD::BUILTIN_OP_END; }
899  unsigned getTargetOpcode() const {
900    assert(isTargetOpcode() && "Not a target opcode!");
901    return NodeType - ISD::BUILTIN_OP_END;
902  }
903
904  size_t use_size() const { return Uses.size(); }
905  bool use_empty() const { return Uses.empty(); }
906  bool hasOneUse() const { return Uses.size() == 1; }
907
908  /// getNodeId - Return the unique node id.
909  ///
910  int getNodeId() const { return NodeId; }
911
912  /// setNodeId - Set unique node id.
913  void setNodeId(int Id) { NodeId = Id; }
914
915  typedef SmallVector<SDNode*,3>::const_iterator use_iterator;
916  use_iterator use_begin() const { return Uses.begin(); }
917  use_iterator use_end() const { return Uses.end(); }
918
919  /// hasNUsesOfValue - Return true if there are exactly NUSES uses of the
920  /// indicated value.  This method ignores uses of other values defined by this
921  /// operation.
922  bool hasNUsesOfValue(unsigned NUses, unsigned Value) const;
923
924  /// hasAnyUseOfValue - Return true if there are any use of the indicated
925  /// value. This method ignores uses of other values defined by this operation.
926  bool hasAnyUseOfValue(unsigned Value) const;
927
928  /// isOnlyUse - Return true if this node is the only use of N.
929  ///
930  bool isOnlyUse(SDNode *N) const;
931
932  /// isOperand - Return true if this node is an operand of N.
933  ///
934  bool isOperand(SDNode *N) const;
935
936  /// isPredecessor - Return true if this node is a predecessor of N. This node
937  /// is either an operand of N or it can be reached by recursively traversing
938  /// up the operands.
939  /// NOTE: this is an expensive method. Use it carefully.
940  bool isPredecessor(SDNode *N) const;
941
942  /// getNumOperands - Return the number of values used by this operation.
943  ///
944  unsigned getNumOperands() const { return NumOperands; }
945
946  /// getConstantOperandVal - Helper method returns the integer value of a
947  /// ConstantSDNode operand.
948  uint64_t getConstantOperandVal(unsigned Num) const;
949
950  const SDOperand &getOperand(unsigned Num) const {
951    assert(Num < NumOperands && "Invalid child # of SDNode!");
952    return OperandList[Num];
953  }
954
955  typedef const SDOperand* op_iterator;
956  op_iterator op_begin() const { return OperandList; }
957  op_iterator op_end() const { return OperandList+NumOperands; }
958
959
960  SDVTList getVTList() const {
961    SDVTList X = { ValueList, NumValues };
962    return X;
963  };
964
965  /// getNumValues - Return the number of values defined/returned by this
966  /// operator.
967  ///
968  unsigned getNumValues() const { return NumValues; }
969
970  /// getValueType - Return the type of a specified result.
971  ///
972  MVT::ValueType getValueType(unsigned ResNo) const {
973    assert(ResNo < NumValues && "Illegal result number!");
974    return ValueList[ResNo];
975  }
976
977  typedef const MVT::ValueType* value_iterator;
978  value_iterator value_begin() const { return ValueList; }
979  value_iterator value_end() const { return ValueList+NumValues; }
980
981  /// getOperationName - Return the opcode of this operation for printing.
982  ///
983  std::string getOperationName(const SelectionDAG *G = 0) const;
984  static const char* getIndexedModeName(ISD::MemIndexedMode AM);
985  void dump() const;
986  void dump(const SelectionDAG *G) const;
987
988  static bool classof(const SDNode *) { return true; }
989
990  /// Profile - Gather unique data for the node.
991  ///
992  void Profile(FoldingSetNodeID &ID);
993
994protected:
995  friend class SelectionDAG;
996
997  /// getValueTypeList - Return a pointer to the specified value type.
998  ///
999  static MVT::ValueType *getValueTypeList(MVT::ValueType VT);
1000  static SDVTList getSDVTList(MVT::ValueType VT) {
1001    SDVTList Ret = { getValueTypeList(VT), 1 };
1002    return Ret;
1003  }
1004
1005  SDNode(unsigned Opc, SDVTList VTs, const SDOperand *Ops, unsigned NumOps)
1006    : NodeType(Opc), NodeId(-1) {
1007    OperandsNeedDelete = true;
1008    NumOperands = NumOps;
1009    OperandList = NumOps ? new SDOperand[NumOperands] : 0;
1010
1011    for (unsigned i = 0; i != NumOps; ++i) {
1012      OperandList[i] = Ops[i];
1013      Ops[i].Val->Uses.push_back(this);
1014    }
1015
1016    ValueList = VTs.VTs;
1017    NumValues = VTs.NumVTs;
1018    Prev = 0; Next = 0;
1019  }
1020  SDNode(unsigned Opc, SDVTList VTs) : NodeType(Opc), NodeId(-1) {
1021    OperandsNeedDelete = false;  // Operands set with InitOperands.
1022    NumOperands = 0;
1023    OperandList = 0;
1024
1025    ValueList = VTs.VTs;
1026    NumValues = VTs.NumVTs;
1027    Prev = 0; Next = 0;
1028  }
1029
1030  /// InitOperands - Initialize the operands list of this node with the
1031  /// specified values, which are part of the node (thus they don't need to be
1032  /// copied in or allocated).
1033  void InitOperands(SDOperand *Ops, unsigned NumOps) {
1034    assert(OperandList == 0 && "Operands already set!");
1035    NumOperands = NumOps;
1036    OperandList = Ops;
1037
1038    for (unsigned i = 0; i != NumOps; ++i)
1039      Ops[i].Val->Uses.push_back(this);
1040  }
1041
1042  /// MorphNodeTo - This frees the operands of the current node, resets the
1043  /// opcode, types, and operands to the specified value.  This should only be
1044  /// used by the SelectionDAG class.
1045  void MorphNodeTo(unsigned Opc, SDVTList L,
1046                   const SDOperand *Ops, unsigned NumOps);
1047
1048  void addUser(SDNode *User) {
1049    Uses.push_back(User);
1050  }
1051  void removeUser(SDNode *User) {
1052    // Remove this user from the operand's use list.
1053    for (unsigned i = Uses.size(); ; --i) {
1054      assert(i != 0 && "Didn't find user!");
1055      if (Uses[i-1] == User) {
1056        Uses[i-1] = Uses.back();
1057        Uses.pop_back();
1058        return;
1059      }
1060    }
1061  }
1062};
1063
1064
1065// Define inline functions from the SDOperand class.
1066
1067inline unsigned SDOperand::getOpcode() const {
1068  return Val->getOpcode();
1069}
1070inline MVT::ValueType SDOperand::getValueType() const {
1071  return Val->getValueType(ResNo);
1072}
1073inline unsigned SDOperand::getNumOperands() const {
1074  return Val->getNumOperands();
1075}
1076inline const SDOperand &SDOperand::getOperand(unsigned i) const {
1077  return Val->getOperand(i);
1078}
1079inline uint64_t SDOperand::getConstantOperandVal(unsigned i) const {
1080  return Val->getConstantOperandVal(i);
1081}
1082inline bool SDOperand::isTargetOpcode() const {
1083  return Val->isTargetOpcode();
1084}
1085inline unsigned SDOperand::getTargetOpcode() const {
1086  return Val->getTargetOpcode();
1087}
1088inline bool SDOperand::hasOneUse() const {
1089  return Val->hasNUsesOfValue(1, ResNo);
1090}
1091inline bool SDOperand::use_empty() const {
1092  return !Val->hasAnyUseOfValue(ResNo);
1093}
1094
1095/// UnarySDNode - This class is used for single-operand SDNodes.  This is solely
1096/// to allow co-allocation of node operands with the node itself.
1097class UnarySDNode : public SDNode {
1098  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1099  SDOperand Op;
1100public:
1101  UnarySDNode(unsigned Opc, SDVTList VTs, SDOperand X)
1102    : SDNode(Opc, VTs), Op(X) {
1103    InitOperands(&Op, 1);
1104  }
1105};
1106
1107/// BinarySDNode - This class is used for two-operand SDNodes.  This is solely
1108/// to allow co-allocation of node operands with the node itself.
1109class BinarySDNode : public SDNode {
1110  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1111  SDOperand Ops[2];
1112public:
1113  BinarySDNode(unsigned Opc, SDVTList VTs, SDOperand X, SDOperand Y)
1114    : SDNode(Opc, VTs) {
1115    Ops[0] = X;
1116    Ops[1] = Y;
1117    InitOperands(Ops, 2);
1118  }
1119};
1120
1121/// TernarySDNode - This class is used for three-operand SDNodes. This is solely
1122/// to allow co-allocation of node operands with the node itself.
1123class TernarySDNode : public SDNode {
1124  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1125  SDOperand Ops[3];
1126public:
1127  TernarySDNode(unsigned Opc, SDVTList VTs, SDOperand X, SDOperand Y,
1128                SDOperand Z)
1129    : SDNode(Opc, VTs) {
1130    Ops[0] = X;
1131    Ops[1] = Y;
1132    Ops[2] = Z;
1133    InitOperands(Ops, 3);
1134  }
1135};
1136
1137
1138/// HandleSDNode - This class is used to form a handle around another node that
1139/// is persistant and is updated across invocations of replaceAllUsesWith on its
1140/// operand.  This node should be directly created by end-users and not added to
1141/// the AllNodes list.
1142class HandleSDNode : public SDNode {
1143  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1144  SDOperand Op;
1145public:
1146  explicit HandleSDNode(SDOperand X)
1147    : SDNode(ISD::HANDLENODE, getSDVTList(MVT::Other)), Op(X) {
1148    InitOperands(&Op, 1);
1149  }
1150  ~HandleSDNode();
1151  SDOperand getValue() const { return Op; }
1152};
1153
1154class StringSDNode : public SDNode {
1155  std::string Value;
1156  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1157protected:
1158  friend class SelectionDAG;
1159  explicit StringSDNode(const std::string &val)
1160    : SDNode(ISD::STRING, getSDVTList(MVT::Other)), Value(val) {
1161  }
1162public:
1163  const std::string &getValue() const { return Value; }
1164  static bool classof(const StringSDNode *) { return true; }
1165  static bool classof(const SDNode *N) {
1166    return N->getOpcode() == ISD::STRING;
1167  }
1168};
1169
1170class ConstantSDNode : public SDNode {
1171  uint64_t Value;
1172  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1173protected:
1174  friend class SelectionDAG;
1175  ConstantSDNode(bool isTarget, uint64_t val, MVT::ValueType VT)
1176    : SDNode(isTarget ? ISD::TargetConstant : ISD::Constant, getSDVTList(VT)),
1177      Value(val) {
1178  }
1179public:
1180
1181  uint64_t getValue() const { return Value; }
1182
1183  int64_t getSignExtended() const {
1184    unsigned Bits = MVT::getSizeInBits(getValueType(0));
1185    return ((int64_t)Value << (64-Bits)) >> (64-Bits);
1186  }
1187
1188  bool isNullValue() const { return Value == 0; }
1189  bool isAllOnesValue() const {
1190    return Value == MVT::getIntVTBitMask(getValueType(0));
1191  }
1192
1193  static bool classof(const ConstantSDNode *) { return true; }
1194  static bool classof(const SDNode *N) {
1195    return N->getOpcode() == ISD::Constant ||
1196           N->getOpcode() == ISD::TargetConstant;
1197  }
1198};
1199
1200class ConstantFPSDNode : public SDNode {
1201  APFloat Value;
1202  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1203  // Longterm plan: replace all uses of getValue with getValueAPF, remove
1204  // getValue, rename getValueAPF to getValue.
1205protected:
1206  friend class SelectionDAG;
1207  ConstantFPSDNode(bool isTarget, const APFloat& val, MVT::ValueType VT)
1208    : SDNode(isTarget ? ISD::TargetConstantFP : ISD::ConstantFP,
1209             getSDVTList(VT)), Value(val) {
1210  }
1211public:
1212
1213  const APFloat& getValueAPF() const { return Value; }
1214
1215  /// isExactlyValue - We don't rely on operator== working on double values, as
1216  /// it returns true for things that are clearly not equal, like -0.0 and 0.0.
1217  /// As such, this method can be used to do an exact bit-for-bit comparison of
1218  /// two floating point values.
1219
1220  /// We leave the version with the double argument here because it's just so
1221  /// convenient to write "2.0" and the like.  Without this function we'd
1222  /// have to duplicate its logic everywhere it's called.
1223  bool isExactlyValue(double V) const {
1224    APFloat Tmp(V);
1225    Tmp.convert(Value.getSemantics(), APFloat::rmNearestTiesToEven);
1226    return isExactlyValue(Tmp);
1227  }
1228  bool isExactlyValue(const APFloat& V) const;
1229
1230  bool isValueValidForType(MVT::ValueType VT, const APFloat& Val);
1231
1232  static bool classof(const ConstantFPSDNode *) { return true; }
1233  static bool classof(const SDNode *N) {
1234    return N->getOpcode() == ISD::ConstantFP ||
1235           N->getOpcode() == ISD::TargetConstantFP;
1236  }
1237};
1238
1239class GlobalAddressSDNode : public SDNode {
1240  GlobalValue *TheGlobal;
1241  int Offset;
1242  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1243protected:
1244  friend class SelectionDAG;
1245  GlobalAddressSDNode(bool isTarget, const GlobalValue *GA, MVT::ValueType VT,
1246                      int o = 0);
1247public:
1248
1249  GlobalValue *getGlobal() const { return TheGlobal; }
1250  int getOffset() const { return Offset; }
1251
1252  static bool classof(const GlobalAddressSDNode *) { return true; }
1253  static bool classof(const SDNode *N) {
1254    return N->getOpcode() == ISD::GlobalAddress ||
1255           N->getOpcode() == ISD::TargetGlobalAddress ||
1256           N->getOpcode() == ISD::GlobalTLSAddress ||
1257           N->getOpcode() == ISD::TargetGlobalTLSAddress;
1258  }
1259};
1260
1261class FrameIndexSDNode : public SDNode {
1262  int FI;
1263  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1264protected:
1265  friend class SelectionDAG;
1266  FrameIndexSDNode(int fi, MVT::ValueType VT, bool isTarg)
1267    : SDNode(isTarg ? ISD::TargetFrameIndex : ISD::FrameIndex, getSDVTList(VT)),
1268      FI(fi) {
1269  }
1270public:
1271
1272  int getIndex() const { return FI; }
1273
1274  static bool classof(const FrameIndexSDNode *) { return true; }
1275  static bool classof(const SDNode *N) {
1276    return N->getOpcode() == ISD::FrameIndex ||
1277           N->getOpcode() == ISD::TargetFrameIndex;
1278  }
1279};
1280
1281class JumpTableSDNode : public SDNode {
1282  int JTI;
1283  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1284protected:
1285  friend class SelectionDAG;
1286  JumpTableSDNode(int jti, MVT::ValueType VT, bool isTarg)
1287    : SDNode(isTarg ? ISD::TargetJumpTable : ISD::JumpTable, getSDVTList(VT)),
1288      JTI(jti) {
1289  }
1290public:
1291
1292    int getIndex() const { return JTI; }
1293
1294  static bool classof(const JumpTableSDNode *) { return true; }
1295  static bool classof(const SDNode *N) {
1296    return N->getOpcode() == ISD::JumpTable ||
1297           N->getOpcode() == ISD::TargetJumpTable;
1298  }
1299};
1300
1301class ConstantPoolSDNode : public SDNode {
1302  union {
1303    Constant *ConstVal;
1304    MachineConstantPoolValue *MachineCPVal;
1305  } Val;
1306  int Offset;  // It's a MachineConstantPoolValue if top bit is set.
1307  unsigned Alignment;
1308  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1309protected:
1310  friend class SelectionDAG;
1311  ConstantPoolSDNode(bool isTarget, Constant *c, MVT::ValueType VT,
1312                     int o=0)
1313    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
1314             getSDVTList(VT)), Offset(o), Alignment(0) {
1315    assert((int)Offset >= 0 && "Offset is too large");
1316    Val.ConstVal = c;
1317  }
1318  ConstantPoolSDNode(bool isTarget, Constant *c, MVT::ValueType VT, int o,
1319                     unsigned Align)
1320    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
1321             getSDVTList(VT)), Offset(o), Alignment(Align) {
1322    assert((int)Offset >= 0 && "Offset is too large");
1323    Val.ConstVal = c;
1324  }
1325  ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v,
1326                     MVT::ValueType VT, int o=0)
1327    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
1328             getSDVTList(VT)), Offset(o), Alignment(0) {
1329    assert((int)Offset >= 0 && "Offset is too large");
1330    Val.MachineCPVal = v;
1331    Offset |= 1 << (sizeof(unsigned)*8-1);
1332  }
1333  ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v,
1334                     MVT::ValueType VT, int o, unsigned Align)
1335    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
1336             getSDVTList(VT)), Offset(o), Alignment(Align) {
1337    assert((int)Offset >= 0 && "Offset is too large");
1338    Val.MachineCPVal = v;
1339    Offset |= 1 << (sizeof(unsigned)*8-1);
1340  }
1341public:
1342
1343  bool isMachineConstantPoolEntry() const {
1344    return (int)Offset < 0;
1345  }
1346
1347  Constant *getConstVal() const {
1348    assert(!isMachineConstantPoolEntry() && "Wrong constantpool type");
1349    return Val.ConstVal;
1350  }
1351
1352  MachineConstantPoolValue *getMachineCPVal() const {
1353    assert(isMachineConstantPoolEntry() && "Wrong constantpool type");
1354    return Val.MachineCPVal;
1355  }
1356
1357  int getOffset() const {
1358    return Offset & ~(1 << (sizeof(unsigned)*8-1));
1359  }
1360
1361  // Return the alignment of this constant pool object, which is either 0 (for
1362  // default alignment) or log2 of the desired value.
1363  unsigned getAlignment() const { return Alignment; }
1364
1365  const Type *getType() const;
1366
1367  static bool classof(const ConstantPoolSDNode *) { return true; }
1368  static bool classof(const SDNode *N) {
1369    return N->getOpcode() == ISD::ConstantPool ||
1370           N->getOpcode() == ISD::TargetConstantPool;
1371  }
1372};
1373
1374class BasicBlockSDNode : public SDNode {
1375  MachineBasicBlock *MBB;
1376  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1377protected:
1378  friend class SelectionDAG;
1379  explicit BasicBlockSDNode(MachineBasicBlock *mbb)
1380    : SDNode(ISD::BasicBlock, getSDVTList(MVT::Other)), MBB(mbb) {
1381  }
1382public:
1383
1384  MachineBasicBlock *getBasicBlock() const { return MBB; }
1385
1386  static bool classof(const BasicBlockSDNode *) { return true; }
1387  static bool classof(const SDNode *N) {
1388    return N->getOpcode() == ISD::BasicBlock;
1389  }
1390};
1391
1392class SrcValueSDNode : public SDNode {
1393  const Value *V;
1394  int offset;
1395  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1396protected:
1397  friend class SelectionDAG;
1398  SrcValueSDNode(const Value* v, int o)
1399    : SDNode(ISD::SRCVALUE, getSDVTList(MVT::Other)), V(v), offset(o) {
1400  }
1401
1402public:
1403  const Value *getValue() const { return V; }
1404  int getOffset() const { return offset; }
1405
1406  static bool classof(const SrcValueSDNode *) { return true; }
1407  static bool classof(const SDNode *N) {
1408    return N->getOpcode() == ISD::SRCVALUE;
1409  }
1410};
1411
1412
1413class RegisterSDNode : public SDNode {
1414  unsigned Reg;
1415  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1416protected:
1417  friend class SelectionDAG;
1418  RegisterSDNode(unsigned reg, MVT::ValueType VT)
1419    : SDNode(ISD::Register, getSDVTList(VT)), Reg(reg) {
1420  }
1421public:
1422
1423  unsigned getReg() const { return Reg; }
1424
1425  static bool classof(const RegisterSDNode *) { return true; }
1426  static bool classof(const SDNode *N) {
1427    return N->getOpcode() == ISD::Register;
1428  }
1429};
1430
1431class ExternalSymbolSDNode : public SDNode {
1432  const char *Symbol;
1433  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1434protected:
1435  friend class SelectionDAG;
1436  ExternalSymbolSDNode(bool isTarget, const char *Sym, MVT::ValueType VT)
1437    : SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol,
1438             getSDVTList(VT)), Symbol(Sym) {
1439  }
1440public:
1441
1442  const char *getSymbol() const { return Symbol; }
1443
1444  static bool classof(const ExternalSymbolSDNode *) { return true; }
1445  static bool classof(const SDNode *N) {
1446    return N->getOpcode() == ISD::ExternalSymbol ||
1447           N->getOpcode() == ISD::TargetExternalSymbol;
1448  }
1449};
1450
1451class CondCodeSDNode : public SDNode {
1452  ISD::CondCode Condition;
1453  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1454protected:
1455  friend class SelectionDAG;
1456  explicit CondCodeSDNode(ISD::CondCode Cond)
1457    : SDNode(ISD::CONDCODE, getSDVTList(MVT::Other)), Condition(Cond) {
1458  }
1459public:
1460
1461  ISD::CondCode get() const { return Condition; }
1462
1463  static bool classof(const CondCodeSDNode *) { return true; }
1464  static bool classof(const SDNode *N) {
1465    return N->getOpcode() == ISD::CONDCODE;
1466  }
1467};
1468
1469/// VTSDNode - This class is used to represent MVT::ValueType's, which are used
1470/// to parameterize some operations.
1471class VTSDNode : public SDNode {
1472  MVT::ValueType ValueType;
1473  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1474protected:
1475  friend class SelectionDAG;
1476  explicit VTSDNode(MVT::ValueType VT)
1477    : SDNode(ISD::VALUETYPE, getSDVTList(MVT::Other)), ValueType(VT) {
1478  }
1479public:
1480
1481  MVT::ValueType getVT() const { return ValueType; }
1482
1483  static bool classof(const VTSDNode *) { return true; }
1484  static bool classof(const SDNode *N) {
1485    return N->getOpcode() == ISD::VALUETYPE;
1486  }
1487};
1488
1489/// LSBaseSDNode - Base class for LoadSDNode and StoreSDNode
1490///
1491class LSBaseSDNode : public SDNode {
1492private:
1493  // AddrMode - unindexed, pre-indexed, post-indexed.
1494  ISD::MemIndexedMode AddrMode;
1495
1496  // MemoryVT - VT of in-memory value.
1497  MVT::ValueType MemoryVT;
1498
1499  //! SrcValue - Memory location for alias analysis.
1500  const Value *SrcValue;
1501
1502  //! SVOffset - Memory location offset.
1503  int SVOffset;
1504
1505  //! Alignment - Alignment of memory location in bytes.
1506  unsigned Alignment;
1507
1508  //! IsVolatile - True if the store is volatile.
1509  bool IsVolatile;
1510protected:
1511  //! Operand array for load and store
1512  /*!
1513    \note Moving this array to the base class captures more
1514    common functionality shared between LoadSDNode and
1515    StoreSDNode
1516   */
1517  SDOperand Ops[4];
1518public:
1519  LSBaseSDNode(ISD::NodeType NodeTy, SDOperand *Operands, unsigned NumOperands,
1520               SDVTList VTs, ISD::MemIndexedMode AM, MVT::ValueType VT,
1521               const Value *SV, int SVO, unsigned Align, bool Vol)
1522    : SDNode(NodeTy, VTs),
1523      AddrMode(AM), MemoryVT(VT),
1524      SrcValue(SV), SVOffset(SVO), Alignment(Align), IsVolatile(Vol)
1525  {
1526    for (unsigned i = 0; i != NumOperands; ++i)
1527      Ops[i] = Operands[i];
1528    InitOperands(Ops, NumOperands);
1529    assert(Align != 0 && "Loads and stores should have non-zero aligment");
1530    assert((getOffset().getOpcode() == ISD::UNDEF || isIndexed()) &&
1531           "Only indexed loads and stores have a non-undef offset operand");
1532  }
1533
1534  const SDOperand getChain() const {
1535    return getOperand(0);
1536  }
1537  const SDOperand getBasePtr() const {
1538    return getOperand(getOpcode() == ISD::LOAD ? 1 : 2);
1539  }
1540  const SDOperand getOffset() const {
1541    return getOperand(getOpcode() == ISD::LOAD ? 2 : 3);
1542  }
1543  const SDOperand getValue() const {
1544    assert(getOpcode() == ISD::STORE);
1545    return getOperand(1);
1546  }
1547
1548  const Value *getSrcValue() const { return SrcValue; }
1549  int getSrcValueOffset() const { return SVOffset; }
1550  unsigned getAlignment() const { return Alignment; }
1551  MVT::ValueType getMemoryVT() const { return MemoryVT; }
1552  bool isVolatile() const { return IsVolatile; }
1553
1554  ISD::MemIndexedMode getAddressingMode() const { return AddrMode; }
1555
1556  /// isIndexed - Return true if this is a pre/post inc/dec load/store.
1557  bool isIndexed() const { return AddrMode != ISD::UNINDEXED; }
1558
1559  /// isUnindexed - Return true if this is NOT a pre/post inc/dec load/store.
1560  bool isUnindexed() const { return AddrMode == ISD::UNINDEXED; }
1561
1562  static bool classof(const LSBaseSDNode *N) { return true; }
1563  static bool classof(const SDNode *N) {
1564    return N->getOpcode() == ISD::LOAD ||
1565           N->getOpcode() == ISD::STORE;
1566  }
1567};
1568
1569/// LoadSDNode - This class is used to represent ISD::LOAD nodes.
1570///
1571class LoadSDNode : public LSBaseSDNode {
1572  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1573
1574  // ExtType - non-ext, anyext, sext, zext.
1575  ISD::LoadExtType ExtType;
1576
1577protected:
1578  friend class SelectionDAG;
1579  LoadSDNode(SDOperand *ChainPtrOff, SDVTList VTs,
1580             ISD::MemIndexedMode AM, ISD::LoadExtType ETy, MVT::ValueType LVT,
1581             const Value *SV, int O=0, unsigned Align=0, bool Vol=false)
1582    : LSBaseSDNode(ISD::LOAD, ChainPtrOff, 3,
1583                   VTs, AM, LVT, SV, O, Align, Vol),
1584      ExtType(ETy) { }
1585public:
1586
1587  ISD::LoadExtType getExtensionType() const { return ExtType; }
1588
1589  static bool classof(const LoadSDNode *) { return true; }
1590  static bool classof(const SDNode *N) {
1591    return N->getOpcode() == ISD::LOAD;
1592  }
1593};
1594
1595/// StoreSDNode - This class is used to represent ISD::STORE nodes.
1596///
1597class StoreSDNode : public LSBaseSDNode {
1598  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1599
1600  // IsTruncStore - True if the op does a truncation before store.
1601  bool IsTruncStore;
1602protected:
1603  friend class SelectionDAG;
1604  StoreSDNode(SDOperand *ChainValuePtrOff, SDVTList VTs,
1605              ISD::MemIndexedMode AM, bool isTrunc, MVT::ValueType SVT,
1606              const Value *SV, int O=0, unsigned Align=0, bool Vol=false)
1607    : LSBaseSDNode(ISD::STORE, ChainValuePtrOff, 4,
1608                   VTs, AM, SVT, SV, O, Align, Vol),
1609      IsTruncStore(isTrunc) { }
1610public:
1611
1612  bool isTruncatingStore() const { return IsTruncStore; }
1613
1614  static bool classof(const StoreSDNode *) { return true; }
1615  static bool classof(const SDNode *N) {
1616    return N->getOpcode() == ISD::STORE;
1617  }
1618};
1619
1620
1621class SDNodeIterator : public forward_iterator<SDNode, ptrdiff_t> {
1622  SDNode *Node;
1623  unsigned Operand;
1624
1625  SDNodeIterator(SDNode *N, unsigned Op) : Node(N), Operand(Op) {}
1626public:
1627  bool operator==(const SDNodeIterator& x) const {
1628    return Operand == x.Operand;
1629  }
1630  bool operator!=(const SDNodeIterator& x) const { return !operator==(x); }
1631
1632  const SDNodeIterator &operator=(const SDNodeIterator &I) {
1633    assert(I.Node == Node && "Cannot assign iterators to two different nodes!");
1634    Operand = I.Operand;
1635    return *this;
1636  }
1637
1638  pointer operator*() const {
1639    return Node->getOperand(Operand).Val;
1640  }
1641  pointer operator->() const { return operator*(); }
1642
1643  SDNodeIterator& operator++() {                // Preincrement
1644    ++Operand;
1645    return *this;
1646  }
1647  SDNodeIterator operator++(int) { // Postincrement
1648    SDNodeIterator tmp = *this; ++*this; return tmp;
1649  }
1650
1651  static SDNodeIterator begin(SDNode *N) { return SDNodeIterator(N, 0); }
1652  static SDNodeIterator end  (SDNode *N) {
1653    return SDNodeIterator(N, N->getNumOperands());
1654  }
1655
1656  unsigned getOperand() const { return Operand; }
1657  const SDNode *getNode() const { return Node; }
1658};
1659
1660template <> struct GraphTraits<SDNode*> {
1661  typedef SDNode NodeType;
1662  typedef SDNodeIterator ChildIteratorType;
1663  static inline NodeType *getEntryNode(SDNode *N) { return N; }
1664  static inline ChildIteratorType child_begin(NodeType *N) {
1665    return SDNodeIterator::begin(N);
1666  }
1667  static inline ChildIteratorType child_end(NodeType *N) {
1668    return SDNodeIterator::end(N);
1669  }
1670};
1671
1672template<>
1673struct ilist_traits<SDNode> {
1674  static SDNode *getPrev(const SDNode *N) { return N->Prev; }
1675  static SDNode *getNext(const SDNode *N) { return N->Next; }
1676
1677  static void setPrev(SDNode *N, SDNode *Prev) { N->Prev = Prev; }
1678  static void setNext(SDNode *N, SDNode *Next) { N->Next = Next; }
1679
1680  static SDNode *createSentinel() {
1681    return new SDNode(ISD::EntryToken, SDNode::getSDVTList(MVT::Other));
1682  }
1683  static void destroySentinel(SDNode *N) { delete N; }
1684  //static SDNode *createNode(const SDNode &V) { return new SDNode(V); }
1685
1686
1687  void addNodeToList(SDNode *NTy) {}
1688  void removeNodeFromList(SDNode *NTy) {}
1689  void transferNodesFromList(iplist<SDNode, ilist_traits> &L2,
1690                             const ilist_iterator<SDNode> &X,
1691                             const ilist_iterator<SDNode> &Y) {}
1692};
1693
1694namespace ISD {
1695  /// isNormalLoad - Returns true if the specified node is a non-extending
1696  /// and unindexed load.
1697  inline bool isNormalLoad(const SDNode *N) {
1698    if (N->getOpcode() != ISD::LOAD)
1699      return false;
1700    const LoadSDNode *Ld = cast<LoadSDNode>(N);
1701    return Ld->getExtensionType() == ISD::NON_EXTLOAD &&
1702      Ld->getAddressingMode() == ISD::UNINDEXED;
1703  }
1704
1705  /// isNON_EXTLoad - Returns true if the specified node is a non-extending
1706  /// load.
1707  inline bool isNON_EXTLoad(const SDNode *N) {
1708    return N->getOpcode() == ISD::LOAD &&
1709      cast<LoadSDNode>(N)->getExtensionType() == ISD::NON_EXTLOAD;
1710  }
1711
1712  /// isEXTLoad - Returns true if the specified node is a EXTLOAD.
1713  ///
1714  inline bool isEXTLoad(const SDNode *N) {
1715    return N->getOpcode() == ISD::LOAD &&
1716      cast<LoadSDNode>(N)->getExtensionType() == ISD::EXTLOAD;
1717  }
1718
1719  /// isSEXTLoad - Returns true if the specified node is a SEXTLOAD.
1720  ///
1721  inline bool isSEXTLoad(const SDNode *N) {
1722    return N->getOpcode() == ISD::LOAD &&
1723      cast<LoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD;
1724  }
1725
1726  /// isZEXTLoad - Returns true if the specified node is a ZEXTLOAD.
1727  ///
1728  inline bool isZEXTLoad(const SDNode *N) {
1729    return N->getOpcode() == ISD::LOAD &&
1730      cast<LoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD;
1731  }
1732
1733  /// isUNINDEXEDLoad - Returns true if the specified node is a unindexed load.
1734  ///
1735  inline bool isUNINDEXEDLoad(const SDNode *N) {
1736    return N->getOpcode() == ISD::LOAD &&
1737      cast<LoadSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
1738  }
1739
1740  /// isNON_TRUNCStore - Returns true if the specified node is a non-truncating
1741  /// store.
1742  inline bool isNON_TRUNCStore(const SDNode *N) {
1743    return N->getOpcode() == ISD::STORE &&
1744      !cast<StoreSDNode>(N)->isTruncatingStore();
1745  }
1746
1747  /// isTRUNCStore - Returns true if the specified node is a truncating
1748  /// store.
1749  inline bool isTRUNCStore(const SDNode *N) {
1750    return N->getOpcode() == ISD::STORE &&
1751      cast<StoreSDNode>(N)->isTruncatingStore();
1752  }
1753}
1754
1755
1756} // end llvm namespace
1757
1758#endif
1759