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