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