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