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