Create a new class, MemOperand, for describing memory references
[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     LABEL,
500     
501     // STACKSAVE - STACKSAVE has one operand, an input chain.  It produces a
502     // value, the same type as the pointer type for the system, and an output
503     // chain.
504     STACKSAVE,
505     
506     // STACKRESTORE has two operands, an input chain and a pointer to restore to
507     // it returns an output chain.
508     STACKRESTORE,
509     
510     // MEMSET/MEMCPY/MEMMOVE - The first operand is the chain. The following
511     // correspond to the operands of the LLVM intrinsic functions and the last
512     // one is AlwaysInline.  The only result is a token chain.  The alignment
513     // argument is guaranteed to be a Constant node.
514     MEMSET,
515     MEMMOVE,
516     MEMCPY,
517
518     // CALLSEQ_START/CALLSEQ_END - These operators mark the beginning and end of
519     // a call sequence, and carry arbitrary information that target might want
520     // to know.  The first operand is a chain, the rest are specified by the
521     // target and not touched by the DAG optimizers.
522     CALLSEQ_START,  // Beginning of a call sequence
523     CALLSEQ_END,    // End of a call sequence
524     
525     // VAARG - VAARG has three operands: an input chain, a pointer, and a 
526     // SRCVALUE.  It returns a pair of values: the vaarg value and a new chain.
527     VAARG,
528     
529     // VACOPY - VACOPY has five operands: an input chain, a destination pointer,
530     // a source pointer, a SRCVALUE for the destination, and a SRCVALUE for the
531     // source.
532     VACOPY,
533     
534     // VAEND, VASTART - VAEND and VASTART have three operands: an input chain, a
535     // pointer, and a SRCVALUE.
536     VAEND, VASTART,
537
538     // SRCVALUE - This is a node type that holds a Value* that is used to
539     // make reference to a value in the LLVM IR.
540     SRCVALUE,
541
542     // MEMOPERAND - This is a node that contains a MemOperand which records
543     // information about a memory reference. This is used to make AliasAnalysis
544     // queries from the backend.
545     MEMOPERAND,
546
547     // PCMARKER - This corresponds to the pcmarker intrinsic.
548     PCMARKER,
549
550     // READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic.
551     // The only operand is a chain and a value and a chain are produced.  The
552     // value is the contents of the architecture specific cycle counter like 
553     // register (or other high accuracy low latency clock source)
554     READCYCLECOUNTER,
555
556     // HANDLENODE node - Used as a handle for various purposes.
557     HANDLENODE,
558
559     // LOCATION - This node is used to represent a source location for debug
560     // info.  It takes token chain as input, then a line number, then a column
561     // number, then a filename, then a working dir.  It produces a token chain
562     // as output.
563     LOCATION,
564     
565     // DEBUG_LOC - This node is used to represent source line information
566     // embedded in the code.  It takes a token chain as input, then a line
567     // number, then a column then a file id (provided by MachineModuleInfo.) It
568     // produces a token chain as output.
569     DEBUG_LOC,
570
571     // TRAMPOLINE - This corresponds to the init_trampoline intrinsic.
572     // It takes as input a token chain, the pointer to the trampoline,
573     // the pointer to the nested function, the pointer to pass for the
574     // 'nest' parameter, a SRCVALUE for the trampoline and another for
575     // the nested function (allowing targets to access the original
576     // Function*).  It produces the result of the intrinsic and a token
577     // chain as output.
578     TRAMPOLINE,
579
580     // TRAP - Trapping instruction
581     TRAP,
582
583     // BUILTIN_OP_END - This must be the last enum value in this list.
584     BUILTIN_OP_END
585   };
586
587   /// Node predicates
588
589   /// isBuildVectorAllOnes - Return true if the specified node is a
590   /// BUILD_VECTOR where all of the elements are ~0 or undef.
591   bool isBuildVectorAllOnes(const SDNode *N);
592
593   /// isBuildVectorAllZeros - Return true if the specified node is a
594   /// BUILD_VECTOR where all of the elements are 0 or undef.
595   bool isBuildVectorAllZeros(const SDNode *N);
596   
597   //===--------------------------------------------------------------------===//
598   /// MemIndexedMode enum - This enum defines the load / store indexed 
599   /// addressing modes.
600   ///
601   /// UNINDEXED    "Normal" load / store. The effective address is already
602   ///              computed and is available in the base pointer. The offset
603   ///              operand is always undefined. In addition to producing a
604   ///              chain, an unindexed load produces one value (result of the
605   ///              load); an unindexed store does not produces a value.
606   ///
607   /// PRE_INC      Similar to the unindexed mode where the effective address is
608   /// PRE_DEC      the value of the base pointer add / subtract the offset.
609   ///              It considers the computation as being folded into the load /
610   ///              store operation (i.e. the load / store does the address
611   ///              computation as well as performing the memory transaction).
612   ///              The base operand is always undefined. In addition to
613   ///              producing a chain, pre-indexed load produces two values
614   ///              (result of the load and the result of the address
615   ///              computation); a pre-indexed store produces one value (result
616   ///              of the address computation).
617   ///
618   /// POST_INC     The effective address is the value of the base pointer. The
619   /// POST_DEC     value of the offset operand is then added to / subtracted
620   ///              from the base after memory transaction. In addition to
621   ///              producing a chain, post-indexed load produces two values
622   ///              (the result of the load and the result of the base +/- offset
623   ///              computation); a post-indexed store produces one value (the
624   ///              the result of the base +/- offset computation).
625   ///
626   enum MemIndexedMode {
627     UNINDEXED = 0,
628     PRE_INC,
629     PRE_DEC,
630     POST_INC,
631     POST_DEC,
632     LAST_INDEXED_MODE
633   };
634
635   //===--------------------------------------------------------------------===//
636   /// LoadExtType enum - This enum defines the three variants of LOADEXT
637   /// (load with extension).
638   ///
639   /// SEXTLOAD loads the integer operand and sign extends it to a larger
640   ///          integer result type.
641   /// ZEXTLOAD loads the integer operand and zero extends it to a larger
642   ///          integer result type.
643   /// EXTLOAD  is used for three things: floating point extending loads, 
644   ///          integer extending loads [the top bits are undefined], and vector
645   ///          extending loads [load into low elt].
646   ///
647   enum LoadExtType {
648     NON_EXTLOAD = 0,
649     EXTLOAD,
650     SEXTLOAD,
651     ZEXTLOAD,
652     LAST_LOADX_TYPE
653   };
654
655   //===--------------------------------------------------------------------===//
656   /// ISD::CondCode enum - These are ordered carefully to make the bitfields
657   /// below work out, when considering SETFALSE (something that never exists
658   /// dynamically) as 0.  "U" -> Unsigned (for integer operands) or Unordered
659   /// (for floating point), "L" -> Less than, "G" -> Greater than, "E" -> Equal
660   /// to.  If the "N" column is 1, the result of the comparison is undefined if
661   /// the input is a NAN.
662   ///
663   /// All of these (except for the 'always folded ops') should be handled for
664   /// floating point.  For integer, only the SETEQ,SETNE,SETLT,SETLE,SETGT,
665   /// SETGE,SETULT,SETULE,SETUGT, and SETUGE opcodes are used.
666   ///
667   /// Note that these are laid out in a specific order to allow bit-twiddling
668   /// to transform conditions.
669   enum CondCode {
670     // Opcode          N U L G E       Intuitive operation
671     SETFALSE,      //    0 0 0 0       Always false (always folded)
672     SETOEQ,        //    0 0 0 1       True if ordered and equal
673     SETOGT,        //    0 0 1 0       True if ordered and greater than
674     SETOGE,        //    0 0 1 1       True if ordered and greater than or equal
675     SETOLT,        //    0 1 0 0       True if ordered and less than
676     SETOLE,        //    0 1 0 1       True if ordered and less than or equal
677     SETONE,        //    0 1 1 0       True if ordered and operands are unequal
678     SETO,          //    0 1 1 1       True if ordered (no nans)
679     SETUO,         //    1 0 0 0       True if unordered: isnan(X) | isnan(Y)
680     SETUEQ,        //    1 0 0 1       True if unordered or equal
681     SETUGT,        //    1 0 1 0       True if unordered or greater than
682     SETUGE,        //    1 0 1 1       True if unordered, greater than, or equal
683     SETULT,        //    1 1 0 0       True if unordered or less than
684     SETULE,        //    1 1 0 1       True if unordered, less than, or equal
685     SETUNE,        //    1 1 1 0       True if unordered or not equal
686     SETTRUE,       //    1 1 1 1       Always true (always folded)
687     // Don't care operations: undefined if the input is a nan.
688     SETFALSE2,     //  1 X 0 0 0       Always false (always folded)
689     SETEQ,         //  1 X 0 0 1       True if equal
690     SETGT,         //  1 X 0 1 0       True if greater than
691     SETGE,         //  1 X 0 1 1       True if greater than or equal
692     SETLT,         //  1 X 1 0 0       True if less than
693     SETLE,         //  1 X 1 0 1       True if less than or equal
694     SETNE,         //  1 X 1 1 0       True if not equal
695     SETTRUE2,      //  1 X 1 1 1       Always true (always folded)
696
697     SETCC_INVALID       // Marker value.
698   };
699
700   /// isSignedIntSetCC - Return true if this is a setcc instruction that
701   /// performs a signed comparison when used with integer operands.
702   inline bool isSignedIntSetCC(CondCode Code) {
703     return Code == SETGT || Code == SETGE || Code == SETLT || Code == SETLE;
704   }
705
706   /// isUnsignedIntSetCC - Return true if this is a setcc instruction that
707   /// performs an unsigned comparison when used with integer operands.
708   inline bool isUnsignedIntSetCC(CondCode Code) {
709     return Code == SETUGT || Code == SETUGE || Code == SETULT || Code == SETULE;
710   }
711
712   /// isTrueWhenEqual - Return true if the specified condition returns true if
713   /// the two operands to the condition are equal.  Note that if one of the two
714   /// operands is a NaN, this value is meaningless.
715   inline bool isTrueWhenEqual(CondCode Cond) {
716     return ((int)Cond & 1) != 0;
717   }
718
719   /// getUnorderedFlavor - This function returns 0 if the condition is always
720   /// false if an operand is a NaN, 1 if the condition is always true if the
721   /// operand is a NaN, and 2 if the condition is undefined if the operand is a
722   /// NaN.
723   inline unsigned getUnorderedFlavor(CondCode Cond) {
724     return ((int)Cond >> 3) & 3;
725   }
726
727   /// getSetCCInverse - Return the operation corresponding to !(X op Y), where
728   /// 'op' is a valid SetCC operation.
729   CondCode getSetCCInverse(CondCode Operation, bool isInteger);
730
731   /// getSetCCSwappedOperands - Return the operation corresponding to (Y op X)
732   /// when given the operation for (X op Y).
733   CondCode getSetCCSwappedOperands(CondCode Operation);
734
735   /// getSetCCOrOperation - Return the result of a logical OR between different
736   /// comparisons of identical values: ((X op1 Y) | (X op2 Y)).  This
737   /// function returns SETCC_INVALID if it is not possible to represent the
738   /// resultant comparison.
739   CondCode getSetCCOrOperation(CondCode Op1, CondCode Op2, bool isInteger);
740
741   /// getSetCCAndOperation - Return the result of a logical AND between
742   /// different comparisons of identical values: ((X op1 Y) & (X op2 Y)).  This
743   /// function returns SETCC_INVALID if it is not possible to represent the
744   /// resultant comparison.
745   CondCode getSetCCAndOperation(CondCode Op1, CondCode Op2, bool isInteger);
746 }  // end llvm::ISD namespace
747
748
749 //===----------------------------------------------------------------------===//
750 /// SDOperand - Unlike LLVM values, Selection DAG nodes may return multiple
751 /// values as the result of a computation.  Many nodes return multiple values,
752 /// from loads (which define a token and a return value) to ADDC (which returns
753 /// a result and a carry value), to calls (which may return an arbitrary number
754 /// of values).
755 ///
756 /// As such, each use of a SelectionDAG computation must indicate the node that
757 /// computes it as well as which return value to use from that node.  This pair
758 /// of information is represented with the SDOperand value type.
759 ///
760 class SDOperand {
761 public:
762   SDNode *Val;        // The node defining the value we are using.
763   unsigned ResNo;     // Which return value of the node we are using.
764
765   SDOperand() : Val(0), ResNo(0) {}
766   SDOperand(SDNode *val, unsigned resno) : Val(val), ResNo(resno) {}
767
768   bool operator==(const SDOperand &O) const {
769     return Val == O.Val && ResNo == O.ResNo;
770   }
771   bool operator!=(const SDOperand &O) const {
772     return !operator==(O);
773   }
774   bool operator<(const SDOperand &O) const {
775     return Val < O.Val || (Val == O.Val && ResNo < O.ResNo);
776   }
777
778   SDOperand getValue(unsigned R) const {
779     return SDOperand(Val, R);
780   }
781
782   // isOperand - Return true if this node is an operand of N.
783   bool isOperand(SDNode *N) const;
784
785   /// getValueType - Return the ValueType of the referenced return value.
786   ///
787   inline MVT::ValueType getValueType() const;
788
789   // Forwarding methods - These forward to the corresponding methods in SDNode.
790   inline unsigned getOpcode() const;
791   inline unsigned getNumOperands() const;
792   inline const SDOperand &getOperand(unsigned i) const;
793   inline uint64_t getConstantOperandVal(unsigned i) const;
794   inline bool isTargetOpcode() const;
795   inline unsigned getTargetOpcode() const;
796
797   
798   /// reachesChainWithoutSideEffects - Return true if this operand (which must
799   /// be a chain) reaches the specified operand without crossing any 
800   /// side-effecting instructions.  In practice, this looks through token
801   /// factors and non-volatile loads.  In order to remain efficient, this only
802   /// looks a couple of nodes in, it does not do an exhaustive search.
803   bool reachesChainWithoutSideEffects(SDOperand Dest, unsigned Depth = 2) const;
804   
805   /// hasOneUse - Return true if there is exactly one operation using this
806   /// result value of the defining operator.
807   inline bool hasOneUse() const;
808
809   /// use_empty - Return true if there are no operations using this
810   /// result value of the defining operator.
811   inline bool use_empty() const;
812 };
813
814
815 template<> struct DenseMapInfo<SDOperand> {
816   static inline SDOperand getEmptyKey() { return SDOperand((SDNode*)-1, -1U); }
817   static inline SDOperand getTombstoneKey() { return SDOperand((SDNode*)-1, 0);}
818   static unsigned getHashValue(const SDOperand &Val) {
819     return (unsigned)((uintptr_t)Val.Val >> 4) ^
820            (unsigned)((uintptr_t)Val.Val >> 9) + Val.ResNo;
821   }
822   static bool isEqual(const SDOperand &LHS, const SDOperand &RHS) {
823     return LHS == RHS;
824   }
825   static bool isPod() { return true; }
826 };
827
828 /// simplify_type specializations - Allow casting operators to work directly on
829 /// SDOperands as if they were SDNode*'s.
830 template<> struct simplify_type<SDOperand> {
831   typedef SDNode* SimpleType;
832   static SimpleType getSimplifiedValue(const SDOperand &Val) {
833     return static_cast<SimpleType>(Val.Val);
834   }
835 };
836 template<> struct simplify_type<const SDOperand> {
837   typedef SDNode* SimpleType;
838   static SimpleType getSimplifiedValue(const SDOperand &Val) {
839     return static_cast<SimpleType>(Val.Val);
840   }
841 };
842
843
844 /// SDNode - Represents one node in the SelectionDAG.
845 ///
846 class SDNode : public FoldingSetNode {
847   /// NodeType - The operation that this node performs.
848   ///
849   unsigned short NodeType;
850   
851   /// OperandsNeedDelete - This is true if OperandList was new[]'d.  If true,
852   /// then they will be delete[]'d when the node is destroyed.
853   bool OperandsNeedDelete : 1;
854
855   /// NodeId - Unique id per SDNode in the DAG.
856   int NodeId;
857
858   /// OperandList - The values that are used by this operation.
859   ///
860   SDOperand *OperandList;
861   
862   /// ValueList - The types of the values this node defines.  SDNode's may
863   /// define multiple values simultaneously.
864   const MVT::ValueType *ValueList;
865
866   /// NumOperands/NumValues - The number of entries in the Operand/Value list.
867   unsigned short NumOperands, NumValues;
868   
869   /// Prev/Next pointers - These pointers form the linked list of of the
870   /// AllNodes list in the current DAG.
871   SDNode *Prev, *Next;
872   friend struct ilist_traits<SDNode>;
873
874   /// Uses - These are all of the SDNode's that use a value produced by this
875   /// node.
876   SmallVector<SDNode*,3> Uses;
877   
878   // Out-of-line virtual method to give class a home.
879   virtual void ANCHOR();
880 public:
881   virtual ~SDNode() {
882     assert(NumOperands == 0 && "Operand list not cleared before deletion");
883     NodeType = ISD::DELETED_NODE;
884   }
885   
886   //===--------------------------------------------------------------------===//
887   //  Accessors
888   //
889   unsigned getOpcode()  const { return NodeType; }
890   bool isTargetOpcode() const { return NodeType >= ISD::BUILTIN_OP_END; }
891   unsigned getTargetOpcode() const {
892     assert(isTargetOpcode() && "Not a target opcode!");
893     return NodeType - ISD::BUILTIN_OP_END;
894   }
895
896   size_t use_size() const { return Uses.size(); }
897   bool use_empty() const { return Uses.empty(); }
898   bool hasOneUse() const { return Uses.size() == 1; }
899
900   /// getNodeId - Return the unique node id.
901   ///
902   int getNodeId() const { return NodeId; }
903
904   /// setNodeId - Set unique node id.
905   void setNodeId(int Id) { NodeId = Id; }
906
907   typedef SmallVector<SDNode*,3>::const_iterator use_iterator;
908   use_iterator use_begin() const { return Uses.begin(); }
909   use_iterator use_end() const { return Uses.end(); }
910
911   /// hasNUsesOfValue - Return true if there are exactly NUSES uses of the
912   /// indicated value.  This method ignores uses of other values defined by this
913   /// operation.
914   bool hasNUsesOfValue(unsigned NUses, unsigned Value) const;
915
916   /// hasAnyUseOfValue - Return true if there are any use of the indicated
917   /// value. This method ignores uses of other values defined by this operation.
918   bool hasAnyUseOfValue(unsigned Value) const;
919
920   /// isOnlyUse - Return true if this node is the only use of N.
921   ///
922   bool isOnlyUse(SDNode *N) const;
923
924   /// isOperand - Return true if this node is an operand of N.
925   ///
926   bool isOperand(SDNode *N) const;
927
928   /// isPredecessor - Return true if this node is a predecessor of N. This node
929   /// is either an operand of N or it can be reached by recursively traversing
930   /// up the operands.
931   /// NOTE: this is an expensive method. Use it carefully.
932   bool isPredecessor(SDNode *N) const;
933
934   /// getNumOperands - Return the number of values used by this operation.
935   ///
936   unsigned getNumOperands() const { return NumOperands; }
937
938   /// getConstantOperandVal - Helper method returns the integer value of a 
939   /// ConstantSDNode operand.
940   uint64_t getConstantOperandVal(unsigned Num) const;
941
942   const SDOperand &getOperand(unsigned Num) const {
943     assert(Num < NumOperands && "Invalid child # of SDNode!");
944     return OperandList[Num];
945   }
946
947   typedef const SDOperand* op_iterator;
948   op_iterator op_begin() const { return OperandList; }
949   op_iterator op_end() const { return OperandList+NumOperands; }
950
951
952   SDVTList getVTList() const {
953     SDVTList X = { ValueList, NumValues };
954     return X;
955   };
956   
957   /// getNumValues - Return the number of values defined/returned by this
958   /// operator.
959   ///
960   unsigned getNumValues() const { return NumValues; }
961
962   /// getValueType - Return the type of a specified result.
963   ///
964   MVT::ValueType getValueType(unsigned ResNo) const {
965     assert(ResNo < NumValues && "Illegal result number!");
966     return ValueList[ResNo];
967   }
968
969   typedef const MVT::ValueType* value_iterator;
970   value_iterator value_begin() const { return ValueList; }
971   value_iterator value_end() const { return ValueList+NumValues; }
972
973   /// getOperationName - Return the opcode of this operation for printing.
974   ///
975   std::string getOperationName(const SelectionDAG *G = 0) const;
976   static const char* getIndexedModeName(ISD::MemIndexedMode AM);
977   void dump() const;
978   void dump(const SelectionDAG *G) const;
979
980   static bool classof(const SDNode *) { return true; }
981
982   /// Profile - Gather unique data for the node.
983   ///
984   void Profile(FoldingSetNodeID &ID);
985
986 protected:
987   friend class SelectionDAG;
988   
989   /// getValueTypeList - Return a pointer to the specified value type.
990   ///
991   static MVT::ValueType *getValueTypeList(MVT::ValueType VT);
992   static SDVTList getSDVTList(MVT::ValueType VT) {
993     SDVTList Ret = { getValueTypeList(VT), 1 };
994     return Ret;
995   }
996
997   SDNode(unsigned Opc, SDVTList VTs, const SDOperand *Ops, unsigned NumOps)
998     : NodeType(Opc), NodeId(-1) {
999     OperandsNeedDelete = true;
1000     NumOperands = NumOps;
1001     OperandList = NumOps ? new SDOperand[NumOperands] : 0;
1002     
1003     for (unsigned i = 0; i != NumOps; ++i) {
1004       OperandList[i] = Ops[i];
1005       Ops[i].Val->Uses.push_back(this);
1006     }
1007     
1008     ValueList = VTs.VTs;
1009     NumValues = VTs.NumVTs;
1010     Prev = 0; Next = 0;
1011   }
1012   SDNode(unsigned Opc, SDVTList VTs) : NodeType(Opc), NodeId(-1) {
1013     OperandsNeedDelete = false;  // Operands set with InitOperands.
1014     NumOperands = 0;
1015     OperandList = 0;
1016     
1017     ValueList = VTs.VTs;
1018     NumValues = VTs.NumVTs;
1019     Prev = 0; Next = 0;
1020   }
1021   
1022   /// InitOperands - Initialize the operands list of this node with the
1023   /// specified values, which are part of the node (thus they don't need to be
1024   /// copied in or allocated).
1025   void InitOperands(SDOperand *Ops, unsigned NumOps) {
1026     assert(OperandList == 0 && "Operands already set!");
1027     NumOperands = NumOps;
1028     OperandList = Ops;
1029     
1030     for (unsigned i = 0; i != NumOps; ++i)
1031       Ops[i].Val->Uses.push_back(this);
1032   }
1033   
1034   /// MorphNodeTo - This frees the operands of the current node, resets the
1035   /// opcode, types, and operands to the specified value.  This should only be
1036   /// used by the SelectionDAG class.
1037   void MorphNodeTo(unsigned Opc, SDVTList L,
1038                    const SDOperand *Ops, unsigned NumOps);
1039   
1040   void addUser(SDNode *User) {
1041     Uses.push_back(User);
1042   }
1043   void removeUser(SDNode *User) {
1044     // Remove this user from the operand's use list.
1045     for (unsigned i = Uses.size(); ; --i) {
1046       assert(i != 0 && "Didn't find user!");
1047       if (Uses[i-1] == User) {
1048         Uses[i-1] = Uses.back();
1049         Uses.pop_back();
1050         return;
1051       }
1052     }
1053   }
1054 };
1055
1056
1057 // Define inline functions from the SDOperand class.
1058
1059 inline unsigned SDOperand::getOpcode() const {
1060   return Val->getOpcode();
1061 }
1062 inline MVT::ValueType SDOperand::getValueType() const {
1063   return Val->getValueType(ResNo);
1064 }
1065 inline unsigned SDOperand::getNumOperands() const {
1066   return Val->getNumOperands();
1067 }
1068 inline const SDOperand &SDOperand::getOperand(unsigned i) const {
1069   return Val->getOperand(i);
1070 }
1071 inline uint64_t SDOperand::getConstantOperandVal(unsigned i) const {
1072   return Val->getConstantOperandVal(i);
1073 }
1074 inline bool SDOperand::isTargetOpcode() const {
1075   return Val->isTargetOpcode();
1076 }
1077 inline unsigned SDOperand::getTargetOpcode() const {
1078   return Val->getTargetOpcode();
1079 }
1080 inline bool SDOperand::hasOneUse() const {
1081   return Val->hasNUsesOfValue(1, ResNo);
1082 }
1083 inline bool SDOperand::use_empty() const {
1084   return !Val->hasAnyUseOfValue(ResNo);
1085 }
1086
1087 /// UnarySDNode - This class is used for single-operand SDNodes.  This is solely
1088 /// to allow co-allocation of node operands with the node itself.
1089 class UnarySDNode : public SDNode {
1090   virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1091   SDOperand Op;
1092 public:
1093   UnarySDNode(unsigned Opc, SDVTList VTs, SDOperand X)
1094     : SDNode(Opc, VTs), Op(X) {
1095     InitOperands(&Op, 1);
1096   }
1097 };
1098
1099 /// BinarySDNode - This class is used for two-operand SDNodes.  This is solely
1100 /// to allow co-allocation of node operands with the node itself.
1101 class BinarySDNode : public SDNode {
1102   virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1103   SDOperand Ops[2];
1104 public:
1105   BinarySDNode(unsigned Opc, SDVTList VTs, SDOperand X, SDOperand Y)
1106     : SDNode(Opc, VTs) {
1107     Ops[0] = X;
1108     Ops[1] = Y;
1109     InitOperands(Ops, 2);
1110   }
1111 };
1112
1113 /// TernarySDNode - This class is used for three-operand SDNodes. This is solely
1114 /// to allow co-allocation of node operands with the node itself.
1115 class TernarySDNode : public SDNode {
1116   virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1117   SDOperand Ops[3];
1118 public:
1119   TernarySDNode(unsigned Opc, SDVTList VTs, SDOperand X, SDOperand Y,
1120                 SDOperand Z)
1121     : SDNode(Opc, VTs) {
1122     Ops[0] = X;
1123     Ops[1] = Y;
1124     Ops[2] = Z;
1125     InitOperands(Ops, 3);
1126   }
1127 };
1128
1129
1130 /// HandleSDNode - This class is used to form a handle around another node that
1131 /// is persistant and is updated across invocations of replaceAllUsesWith on its
1132 /// operand.  This node should be directly created by end-users and not added to
1133 /// the AllNodes list.
1134 class HandleSDNode : public SDNode {
1135   virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1136   SDOperand Op;
1137 public:
1138   explicit HandleSDNode(SDOperand X)
1139     : SDNode(ISD::HANDLENODE, getSDVTList(MVT::Other)), Op(X) {
1140     InitOperands(&Op, 1);
1141   }
1142   ~HandleSDNode();  
1143   SDOperand getValue() const { return Op; }
1144 };
1145
1146 class StringSDNode : public SDNode {
1147   std::string Value;
1148   virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1149 protected:
1150   friend class SelectionDAG;
1151   explicit StringSDNode(const std::string &val)
1152     : SDNode(ISD::STRING, getSDVTList(MVT::Other)), Value(val) {
1153   }
1154 public:
1155   const std::string &getValue() const { return Value; }
1156   static bool classof(const StringSDNode *) { return true; }
1157   static bool classof(const SDNode *N) {
1158     return N->getOpcode() == ISD::STRING;
1159   }
1160 };  
1161
1162 class ConstantSDNode : public SDNode {
1163   uint64_t Value;
1164   virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1165 protected:
1166   friend class SelectionDAG;
1167   ConstantSDNode(bool isTarget, uint64_t val, MVT::ValueType VT)
1168     : SDNode(isTarget ? ISD::TargetConstant : ISD::Constant, getSDVTList(VT)),
1169       Value(val) {
1170   }
1171 public:
1172
1173   uint64_t getValue() const { return Value; }
1174
1175   int64_t getSignExtended() const {
1176     unsigned Bits = MVT::getSizeInBits(getValueType(0));
1177     return ((int64_t)Value << (64-Bits)) >> (64-Bits);
1178   }
1179
1180   bool isNullValue() const { return Value == 0; }
1181   bool isAllOnesValue() const {
1182     return Value == MVT::getIntVTBitMask(getValueType(0));
1183   }
1184
1185   static bool classof(const ConstantSDNode *) { return true; }
1186   static bool classof(const SDNode *N) {
1187     return N->getOpcode() == ISD::Constant ||
1188            N->getOpcode() == ISD::TargetConstant;
1189   }
1190 };
1191
1192 class ConstantFPSDNode : public SDNode {
1193   APFloat Value;
1194   virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1195   // Longterm plan: replace all uses of getValue with getValueAPF, remove
1196   // getValue, rename getValueAPF to getValue.
1197 protected:
1198   friend class SelectionDAG;
1199   ConstantFPSDNode(bool isTarget, const APFloat& val, MVT::ValueType VT)
1200     : SDNode(isTarget ? ISD::TargetConstantFP : ISD::ConstantFP,
1201              getSDVTList(VT)), Value(val) {
1202   }
1203 public:
1204
1205   const APFloat& getValueAPF() const { return Value; }
1206
1207   /// isExactlyValue - We don't rely on operator== working on double values, as
1208   /// it returns true for things that are clearly not equal, like -0.0 and 0.0.
1209   /// As such, this method can be used to do an exact bit-for-bit comparison of
1210   /// two floating point values.
1211
1212   /// We leave the version with the double argument here because it's just so
1213   /// convenient to write "2.0" and the like.  Without this function we'd 
1214   /// have to duplicate its logic everywhere it's called.
1215   bool isExactlyValue(double V) const { 
1216     APFloat Tmp(V);
1217     Tmp.convert(Value.getSemantics(), APFloat::rmNearestTiesToEven);
1218     return isExactlyValue(Tmp);
1219   }
1220   bool isExactlyValue(const APFloat& V) const;
1221
1222   bool isValueValidForType(MVT::ValueType VT, const APFloat& Val);
1223
1224   static bool classof(const ConstantFPSDNode *) { return true; }
1225   static bool classof(const SDNode *N) {
1226     return N->getOpcode() == ISD::ConstantFP || 
1227            N->getOpcode() == ISD::TargetConstantFP;
1228   }
1229 };
1230
1231 class GlobalAddressSDNode : public SDNode {
1232   GlobalValue *TheGlobal;
1233   int Offset;
1234   virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1235 protected:
1236   friend class SelectionDAG;
1237   GlobalAddressSDNode(bool isTarget, const GlobalValue *GA, MVT::ValueType VT,
1238                       int o = 0);
1239 public:
1240
1241   GlobalValue *getGlobal() const { return TheGlobal; }
1242   int getOffset() const { return Offset; }
1243
1244   static bool classof(const GlobalAddressSDNode *) { return true; }
1245   static bool classof(const SDNode *N) {
1246     return N->getOpcode() == ISD::GlobalAddress ||
1247            N->getOpcode() == ISD::TargetGlobalAddress ||
1248            N->getOpcode() == ISD::GlobalTLSAddress ||
1249            N->getOpcode() == ISD::TargetGlobalTLSAddress;
1250   }
1251 };
1252
1253 class FrameIndexSDNode : public SDNode {
1254   int FI;
1255   virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1256 protected:
1257   friend class SelectionDAG;
1258   FrameIndexSDNode(int fi, MVT::ValueType VT, bool isTarg)
1259     : SDNode(isTarg ? ISD::TargetFrameIndex : ISD::FrameIndex, getSDVTList(VT)),
1260       FI(fi) {
1261   }
1262 public:
1263
1264   int getIndex() const { return FI; }
1265
1266   static bool classof(const FrameIndexSDNode *) { return true; }
1267   static bool classof(const SDNode *N) {
1268     return N->getOpcode() == ISD::FrameIndex ||
1269            N->getOpcode() == ISD::TargetFrameIndex;
1270   }
1271 };
1272
1273 class JumpTableSDNode : public SDNode {
1274   int JTI;
1275   virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1276 protected:
1277   friend class SelectionDAG;
1278   JumpTableSDNode(int jti, MVT::ValueType VT, bool isTarg)
1279     : SDNode(isTarg ? ISD::TargetJumpTable : ISD::JumpTable, getSDVTList(VT)),
1280       JTI(jti) {
1281   }
1282 public:
1283     
1284     int getIndex() const { return JTI; }
1285   
1286   static bool classof(const JumpTableSDNode *) { return true; }
1287   static bool classof(const SDNode *N) {
1288     return N->getOpcode() == ISD::JumpTable ||
1289            N->getOpcode() == ISD::TargetJumpTable;
1290   }
1291 };
1292
1293 class ConstantPoolSDNode : public SDNode {
1294   union {
1295     Constant *ConstVal;
1296     MachineConstantPoolValue *MachineCPVal;
1297   } Val;
1298   int Offset;  // It's a MachineConstantPoolValue if top bit is set.
1299   unsigned Alignment;
1300   virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1301 protected:
1302   friend class SelectionDAG;
1303   ConstantPoolSDNode(bool isTarget, Constant *c, MVT::ValueType VT,
1304                      int o=0)
1305     : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
1306              getSDVTList(VT)), Offset(o), Alignment(0) {
1307     assert((int)Offset >= 0 && "Offset is too large");
1308     Val.ConstVal = c;
1309   }
1310   ConstantPoolSDNode(bool isTarget, Constant *c, MVT::ValueType VT, int o,
1311                      unsigned Align)
1312     : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 
1313              getSDVTList(VT)), Offset(o), Alignment(Align) {
1314     assert((int)Offset >= 0 && "Offset is too large");
1315     Val.ConstVal = c;
1316   }
1317   ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v,
1318                      MVT::ValueType VT, int o=0)
1319     : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 
1320              getSDVTList(VT)), Offset(o), Alignment(0) {
1321     assert((int)Offset >= 0 && "Offset is too large");
1322     Val.MachineCPVal = v;
1323     Offset |= 1 << (sizeof(unsigned)*8-1);
1324   }
1325   ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v,
1326                      MVT::ValueType VT, int o, unsigned Align)
1327     : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
1328              getSDVTList(VT)), Offset(o), Alignment(Align) {
1329     assert((int)Offset >= 0 && "Offset is too large");
1330     Val.MachineCPVal = v;
1331     Offset |= 1 << (sizeof(unsigned)*8-1);
1332   }
1333 public:
1334
1335   bool isMachineConstantPoolEntry() const {
1336     return (int)Offset < 0;
1337   }
1338
1339   Constant *getConstVal() const {
1340     assert(!isMachineConstantPoolEntry() && "Wrong constantpool type");
1341     return Val.ConstVal;
1342   }
1343
1344   MachineConstantPoolValue *getMachineCPVal() const {
1345     assert(isMachineConstantPoolEntry() && "Wrong constantpool type");
1346     return Val.MachineCPVal;
1347   }
1348
1349   int getOffset() const {
1350     return Offset & ~(1 << (sizeof(unsigned)*8-1));
1351   }
1352   
1353   // Return the alignment of this constant pool object, which is either 0 (for
1354   // default alignment) or log2 of the desired value.
1355   unsigned getAlignment() const { return Alignment; }
1356
1357   const Type *getType() const;
1358
1359   static bool classof(const ConstantPoolSDNode *) { return true; }
1360   static bool classof(const SDNode *N) {
1361     return N->getOpcode() == ISD::ConstantPool ||
1362            N->getOpcode() == ISD::TargetConstantPool;
1363   }
1364 };
1365
1366 class BasicBlockSDNode : public SDNode {
1367   MachineBasicBlock *MBB;
1368   virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1369 protected:
1370   friend class SelectionDAG;
1371   explicit BasicBlockSDNode(MachineBasicBlock *mbb)
1372     : SDNode(ISD::BasicBlock, getSDVTList(MVT::Other)), MBB(mbb) {
1373   }
1374 public:
1375
1376   MachineBasicBlock *getBasicBlock() const { return MBB; }
1377
1378   static bool classof(const BasicBlockSDNode *) { return true; }
1379   static bool classof(const SDNode *N) {
1380     return N->getOpcode() == ISD::BasicBlock;
1381   }
1382 };
1383
1384 class SrcValueSDNode : public SDNode {
1385   const Value *V;
1386   virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1387 protected:
1388   friend class SelectionDAG;
1389   /// Create a SrcValue for a general value.
1390   explicit SrcValueSDNode(const Value *v)
1391     : SDNode(ISD::SRCVALUE, getSDVTList(MVT::Other)), V(v) {}
1392
1393 public:
1394   /// getValue - return the contained Value.
1395   const Value *getValue() const { return V; }
1396
1397   static bool classof(const SrcValueSDNode *) { return true; }
1398   static bool classof(const SDNode *N) {
1399     return N->getOpcode() == ISD::SRCVALUE;
1400   }
1401 };
1402
1403
1404 /// MemOperandSDNode - An SDNode that holds a MemOperand. This is
1405 /// used to represent a reference to memory after ISD::LOAD
1406 /// and ISD::STORE have been lowered.
1407 ///
1408 class MemOperandSDNode : public SDNode {
1409   virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1410 protected:
1411   friend class SelectionDAG;
1412   /// Create a MemOperand node
1413   explicit MemOperandSDNode(MemOperand mo)
1414     : SDNode(ISD::MEMOPERAND, getSDVTList(MVT::Other)), MO(mo) {}
1415
1416 public:
1417   /// MO - The contained MemOperand.
1418   const MemOperand MO;
1419
1420   static bool classof(const MemOperandSDNode *) { return true; }
1421   static bool classof(const SDNode *N) {
1422     return N->getOpcode() == ISD::MEMOPERAND;
1423   }
1424 };
1425
1426
1427 class RegisterSDNode : public SDNode {
1428   unsigned Reg;
1429   virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1430 protected:
1431   friend class SelectionDAG;
1432   RegisterSDNode(unsigned reg, MVT::ValueType VT)
1433     : SDNode(ISD::Register, getSDVTList(VT)), Reg(reg) {
1434   }
1435 public:
1436
1437   unsigned getReg() const { return Reg; }
1438
1439   static bool classof(const RegisterSDNode *) { return true; }
1440   static bool classof(const SDNode *N) {
1441     return N->getOpcode() == ISD::Register;
1442   }
1443 };
1444
1445 class ExternalSymbolSDNode : public SDNode {
1446   const char *Symbol;
1447   virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1448 protected:
1449   friend class SelectionDAG;
1450   ExternalSymbolSDNode(bool isTarget, const char *Sym, MVT::ValueType VT)
1451     : SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol,
1452              getSDVTList(VT)), Symbol(Sym) {
1453   }
1454 public:
1455
1456   const char *getSymbol() const { return Symbol; }
1457
1458   static bool classof(const ExternalSymbolSDNode *) { return true; }
1459   static bool classof(const SDNode *N) {
1460     return N->getOpcode() == ISD::ExternalSymbol ||
1461            N->getOpcode() == ISD::TargetExternalSymbol;
1462   }
1463 };
1464
1465 class CondCodeSDNode : public SDNode {
1466   ISD::CondCode Condition;
1467   virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1468 protected:
1469   friend class SelectionDAG;
1470   explicit CondCodeSDNode(ISD::CondCode Cond)
1471     : SDNode(ISD::CONDCODE, getSDVTList(MVT::Other)), Condition(Cond) {
1472   }
1473 public:
1474
1475   ISD::CondCode get() const { return Condition; }
1476
1477   static bool classof(const CondCodeSDNode *) { return true; }
1478   static bool classof(const SDNode *N) {
1479     return N->getOpcode() == ISD::CONDCODE;
1480   }
1481 };
1482
1483 /// VTSDNode - This class is used to represent MVT::ValueType's, which are used
1484 /// to parameterize some operations.
1485 class VTSDNode : public SDNode {
1486   MVT::ValueType ValueType;
1487   virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1488 protected:
1489   friend class SelectionDAG;
1490   explicit VTSDNode(MVT::ValueType VT)
1491     : SDNode(ISD::VALUETYPE, getSDVTList(MVT::Other)), ValueType(VT) {
1492   }
1493 public:
1494
1495   MVT::ValueType getVT() const { return ValueType; }
1496
1497   static bool classof(const VTSDNode *) { return true; }
1498   static bool classof(const SDNode *N) {
1499     return N->getOpcode() == ISD::VALUETYPE;
1500   }
1501 };
1502
1503 /// LSBaseSDNode - Base class for LoadSDNode and StoreSDNode
1504 ///
1505 class LSBaseSDNode : public SDNode {
1506 private:
1507   // AddrMode - unindexed, pre-indexed, post-indexed.
1508   ISD::MemIndexedMode AddrMode;
1509
1510   // MemoryVT - VT of in-memory value.
1511   MVT::ValueType MemoryVT;
1512
1513   //! SrcValue - Memory location for alias analysis.
1514   const Value *SrcValue;
1515
1516   //! SVOffset - Memory location offset.
1517   int SVOffset;
1518
1519   //! Alignment - Alignment of memory location in bytes.
1520   unsigned Alignment;
1521
1522   //! IsVolatile - True if the store is volatile.
1523   bool IsVolatile;
1524 protected:
1525   //! Operand array for load and store
1526   /*!
1527     \note Moving this array to the base class captures more
1528     common functionality shared between LoadSDNode and
1529     StoreSDNode
1530    */
1531   SDOperand Ops[4];
1532 public:
1533   LSBaseSDNode(ISD::NodeType NodeTy, SDOperand *Operands, unsigned NumOperands,
1534                SDVTList VTs, ISD::MemIndexedMode AM, MVT::ValueType VT, 
1535                const Value *SV, int SVO, unsigned Align, bool Vol)
1536     : SDNode(NodeTy, VTs),
1537       AddrMode(AM), MemoryVT(VT),
1538       SrcValue(SV), SVOffset(SVO), Alignment(Align), IsVolatile(Vol)
1539   {
1540     for (unsigned i = 0; i != NumOperands; ++i)
1541       Ops[i] = Operands[i];
1542     InitOperands(Ops, NumOperands);
1543     assert(Align != 0 && "Loads and stores should have non-zero aligment");
1544     assert((getOffset().getOpcode() == ISD::UNDEF || isIndexed()) &&
1545            "Only indexed loads and stores have a non-undef offset operand");
1546   }
1547
1548   const SDOperand getChain() const {
1549     return getOperand(0);
1550   }
1551   const SDOperand getBasePtr() const {
1552     return getOperand(getOpcode() == ISD::LOAD ? 1 : 2);
1553   }
1554   const SDOperand getOffset() const {
1555     return getOperand(getOpcode() == ISD::LOAD ? 2 : 3);
1556   }
1557   const SDOperand getValue() const {
1558     assert(getOpcode() == ISD::STORE);
1559     return getOperand(1);
1560   }
1561
1562   const Value *getSrcValue() const { return SrcValue; }
1563   int getSrcValueOffset() const { return SVOffset; }
1564   unsigned getAlignment() const { return Alignment; }
1565   MVT::ValueType getMemoryVT() const { return MemoryVT; }
1566   bool isVolatile() const { return IsVolatile; }
1567
1568   ISD::MemIndexedMode getAddressingMode() const { return AddrMode; }
1569
1570   /// isIndexed - Return true if this is a pre/post inc/dec load/store.
1571   bool isIndexed() const { return AddrMode != ISD::UNINDEXED; }
1572
1573   /// isUnindexed - Return true if this is NOT a pre/post inc/dec load/store.
1574   bool isUnindexed() const { return AddrMode == ISD::UNINDEXED; }
1575
1576   /// getMemOperand - Return a MemOperand object describing the memory
1577   /// reference performed by this load or store.
1578   MemOperand getMemOperand() const;
1579
1580   static bool classof(const LSBaseSDNode *N) { return true; }
1581   static bool classof(const SDNode *N) {
1582     return N->getOpcode() == ISD::LOAD ||
1583            N->getOpcode() == ISD::STORE;
1584   }
1585 };
1586
1587 /// LoadSDNode - This class is used to represent ISD::LOAD nodes.
1588 ///
1589 class LoadSDNode : public LSBaseSDNode {
1590   virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1591   
1592   // ExtType - non-ext, anyext, sext, zext.
1593   ISD::LoadExtType ExtType;
1594
1595 protected:
1596   friend class SelectionDAG;
1597   LoadSDNode(SDOperand *ChainPtrOff, SDVTList VTs,
1598              ISD::MemIndexedMode AM, ISD::LoadExtType ETy, MVT::ValueType LVT,
1599              const Value *SV, int O=0, unsigned Align=0, bool Vol=false)
1600     : LSBaseSDNode(ISD::LOAD, ChainPtrOff, 3,
1601                    VTs, AM, LVT, SV, O, Align, Vol),
1602       ExtType(ETy) { }
1603 public:
1604
1605   ISD::LoadExtType getExtensionType() const { return ExtType; }
1606   
1607   static bool classof(const LoadSDNode *) { return true; }
1608   static bool classof(const SDNode *N) {
1609     return N->getOpcode() == ISD::LOAD;
1610   }
1611 };
1612
1613 /// StoreSDNode - This class is used to represent ISD::STORE nodes.
1614 ///
1615 class StoreSDNode : public LSBaseSDNode {
1616   virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1617     
1618   // IsTruncStore - True if the op does a truncation before store.
1619   bool IsTruncStore;
1620 protected:
1621   friend class SelectionDAG;
1622   StoreSDNode(SDOperand *ChainValuePtrOff, SDVTList VTs,
1623               ISD::MemIndexedMode AM, bool isTrunc, MVT::ValueType SVT,
1624               const Value *SV, int O=0, unsigned Align=0, bool Vol=false)
1625     : LSBaseSDNode(ISD::STORE, ChainValuePtrOff, 4,
1626                    VTs, AM, SVT, SV, O, Align, Vol),
1627       IsTruncStore(isTrunc) { }
1628 public:
1629
1630   bool isTruncatingStore() const { return IsTruncStore; }
1631   
1632   static bool classof(const StoreSDNode *) { return true; }
1633   static bool classof(const SDNode *N) {
1634     return N->getOpcode() == ISD::STORE;
1635   }
1636 };
1637
1638
1639 class SDNodeIterator : public forward_iterator<SDNode, ptrdiff_t> {
1640   SDNode *Node;
1641   unsigned Operand;
1642
1643   SDNodeIterator(SDNode *N, unsigned Op) : Node(N), Operand(Op) {}
1644 public:
1645   bool operator==(const SDNodeIterator& x) const {
1646     return Operand == x.Operand;
1647   }
1648   bool operator!=(const SDNodeIterator& x) const { return !operator==(x); }
1649
1650   const SDNodeIterator &operator=(const SDNodeIterator &I) {
1651     assert(I.Node == Node && "Cannot assign iterators to two different nodes!");
1652     Operand = I.Operand;
1653     return *this;
1654   }
1655
1656   pointer operator*() const {
1657     return Node->getOperand(Operand).Val;
1658   }
1659   pointer operator->() const { return operator*(); }
1660
1661   SDNodeIterator& operator++() {                // Preincrement
1662     ++Operand;
1663     return *this;
1664   }
1665   SDNodeIterator operator++(int) { // Postincrement
1666     SDNodeIterator tmp = *this; ++*this; return tmp;
1667   }
1668
1669   static SDNodeIterator begin(SDNode *N) { return SDNodeIterator(N, 0); }
1670   static SDNodeIterator end  (SDNode *N) {
1671     return SDNodeIterator(N, N->getNumOperands());
1672   }
1673
1674   unsigned getOperand() const { return Operand; }
1675   const SDNode *getNode() const { return Node; }
1676 };
1677
1678 template <> struct GraphTraits<SDNode*> {
1679   typedef SDNode NodeType;
1680   typedef SDNodeIterator ChildIteratorType;
1681   static inline NodeType *getEntryNode(SDNode *N) { return N; }
1682   static inline ChildIteratorType child_begin(NodeType *N) {
1683     return SDNodeIterator::begin(N);
1684   }
1685   static inline ChildIteratorType child_end(NodeType *N) {
1686     return SDNodeIterator::end(N);
1687   }
1688 };
1689
1690 template<>
1691 struct ilist_traits<SDNode> {
1692   static SDNode *getPrev(const SDNode *N) { return N->Prev; }
1693   static SDNode *getNext(const SDNode *N) { return N->Next; }
1694   
1695   static void setPrev(SDNode *N, SDNode *Prev) { N->Prev = Prev; }
1696   static void setNext(SDNode *N, SDNode *Next) { N->Next = Next; }
1697   
1698   static SDNode *createSentinel() {
1699     return new SDNode(ISD::EntryToken, SDNode::getSDVTList(MVT::Other));
1700   }
1701   static void destroySentinel(SDNode *N) { delete N; }
1702   //static SDNode *createNode(const SDNode &V) { return new SDNode(V); }
1703   
1704   
1705   void addNodeToList(SDNode *NTy) {}
1706   void removeNodeFromList(SDNode *NTy) {}
1707   void transferNodesFromList(iplist<SDNode, ilist_traits> &L2,
1708                              const ilist_iterator<SDNode> &X,
1709                              const ilist_iterator<SDNode> &Y) {}
1710 };
1711
1712 namespace ISD {
1713   /// isNormalLoad - Returns true if the specified node is a non-extending
1714   /// and unindexed load.
1715   inline bool isNormalLoad(const SDNode *N) {
1716     if (N->getOpcode() != ISD::LOAD)
1717       return false;
1718     const LoadSDNode *Ld = cast<LoadSDNode>(N);
1719     return Ld->getExtensionType() == ISD::NON_EXTLOAD &&
1720       Ld->getAddressingMode() == ISD::UNINDEXED;
1721   }
1722
1723   /// isNON_EXTLoad - Returns true if the specified node is a non-extending
1724   /// load.
1725   inline bool isNON_EXTLoad(const SDNode *N) {
1726     return N->getOpcode() == ISD::LOAD &&
1727       cast<LoadSDNode>(N)->getExtensionType() == ISD::NON_EXTLOAD;
1728   }
1729
1730   /// isEXTLoad - Returns true if the specified node is a EXTLOAD.
1731   ///
1732   inline bool isEXTLoad(const SDNode *N) {
1733     return N->getOpcode() == ISD::LOAD &&
1734       cast<LoadSDNode>(N)->getExtensionType() == ISD::EXTLOAD;
1735   }
1736
1737   /// isSEXTLoad - Returns true if the specified node is a SEXTLOAD.
1738   ///
1739   inline bool isSEXTLoad(const SDNode *N) {
1740     return N->getOpcode() == ISD::LOAD &&
1741       cast<LoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD;
1742   }
1743
1744   /// isZEXTLoad - Returns true if the specified node is a ZEXTLOAD.
1745   ///
1746   inline bool isZEXTLoad(const SDNode *N) {
1747     return N->getOpcode() == ISD::LOAD &&
1748       cast<LoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD;
1749   }
1750
1751   /// isUNINDEXEDLoad - Returns true if the specified node is a unindexed load.
1752   ///
1753   inline bool isUNINDEXEDLoad(const SDNode *N) {
1754     return N->getOpcode() == ISD::LOAD &&
1755       cast<LoadSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
1756   }
1757
1758   /// isNON_TRUNCStore - Returns true if the specified node is a non-truncating
1759   /// store.
1760   inline bool isNON_TRUNCStore(const SDNode *N) {
1761     return N->getOpcode() == ISD::STORE &&
1762       !cast<StoreSDNode>(N)->isTruncatingStore();
1763   }
1764
1765   /// isTRUNCStore - Returns true if the specified node is a truncating
1766   /// store.
1767   inline bool isTRUNCStore(const SDNode *N) {
1768     return N->getOpcode() == ISD::STORE &&
1769       cast<StoreSDNode>(N)->isTruncatingStore();
1770   }
1771 }
1772
1773
1774 } // end llvm namespace
1775
1776 #endif