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