Add some convenience methods for querying attributes, and
[oota-llvm.git] / include / llvm / Instructions.h
1 //===-- llvm/Instructions.h - Instruction subclass definitions --*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file exposes the class definitions of all of the subclasses of the
11 // Instruction class.  This is meant to be an easy way to get access to all
12 // instruction subclasses.
13 //
14 //===----------------------------------------------------------------------===//
15
16 #ifndef LLVM_INSTRUCTIONS_H
17 #define LLVM_INSTRUCTIONS_H
18
19 #include <iterator>
20
21 #include "llvm/InstrTypes.h"
22 #include "llvm/DerivedTypes.h"
23 #include "llvm/ParameterAttributes.h"
24
25 namespace llvm {
26
27 class BasicBlock;
28 class ConstantInt;
29 class PointerType;
30 class VectorType;
31 class ConstantRange;
32 class APInt;
33 class ParamAttrsList;
34
35 //===----------------------------------------------------------------------===//
36 //                             AllocationInst Class
37 //===----------------------------------------------------------------------===//
38
39 /// AllocationInst - This class is the common base class of MallocInst and
40 /// AllocaInst.
41 ///
42 class AllocationInst : public UnaryInstruction {
43   unsigned Alignment;
44 protected:
45   AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, unsigned Align,
46                  const std::string &Name = "", Instruction *InsertBefore = 0);
47   AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, unsigned Align,
48                  const std::string &Name, BasicBlock *InsertAtEnd);
49 public:
50   // Out of line virtual method, so the vtable, etc has a home.
51   virtual ~AllocationInst();
52
53   /// isArrayAllocation - Return true if there is an allocation size parameter
54   /// to the allocation instruction that is not 1.
55   ///
56   bool isArrayAllocation() const;
57
58   /// getArraySize - Get the number of element allocated, for a simple
59   /// allocation of a single element, this will return a constant 1 value.
60   ///
61   inline const Value *getArraySize() const { return getOperand(0); }
62   inline Value *getArraySize() { return getOperand(0); }
63
64   /// getType - Overload to return most specific pointer type
65   ///
66   inline const PointerType *getType() const {
67     return reinterpret_cast<const PointerType*>(Instruction::getType());
68   }
69
70   /// getAllocatedType - Return the type that is being allocated by the
71   /// instruction.
72   ///
73   const Type *getAllocatedType() const;
74
75   /// getAlignment - Return the alignment of the memory that is being allocated
76   /// by the instruction.
77   ///
78   unsigned getAlignment() const { return Alignment; }
79   void setAlignment(unsigned Align) {
80     assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!");
81     Alignment = Align;
82   }
83
84   virtual Instruction *clone() const = 0;
85
86   // Methods for support type inquiry through isa, cast, and dyn_cast:
87   static inline bool classof(const AllocationInst *) { return true; }
88   static inline bool classof(const Instruction *I) {
89     return I->getOpcode() == Instruction::Alloca ||
90            I->getOpcode() == Instruction::Malloc;
91   }
92   static inline bool classof(const Value *V) {
93     return isa<Instruction>(V) && classof(cast<Instruction>(V));
94   }
95 };
96
97
98 //===----------------------------------------------------------------------===//
99 //                                MallocInst Class
100 //===----------------------------------------------------------------------===//
101
102 /// MallocInst - an instruction to allocated memory on the heap
103 ///
104 class MallocInst : public AllocationInst {
105   MallocInst(const MallocInst &MI);
106 public:
107   explicit MallocInst(const Type *Ty, Value *ArraySize = 0,
108                       const std::string &Name = "",
109                       Instruction *InsertBefore = 0)
110     : AllocationInst(Ty, ArraySize, Malloc, 0, Name, InsertBefore) {}
111   MallocInst(const Type *Ty, Value *ArraySize, const std::string &Name,
112              BasicBlock *InsertAtEnd)
113     : AllocationInst(Ty, ArraySize, Malloc, 0, Name, InsertAtEnd) {}
114
115   MallocInst(const Type *Ty, const std::string &Name,
116              Instruction *InsertBefore = 0)
117     : AllocationInst(Ty, 0, Malloc, 0, Name, InsertBefore) {}
118   MallocInst(const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd)
119     : AllocationInst(Ty, 0, Malloc, 0, Name, InsertAtEnd) {}
120
121   MallocInst(const Type *Ty, Value *ArraySize, unsigned Align,
122              const std::string &Name, BasicBlock *InsertAtEnd)
123     : AllocationInst(Ty, ArraySize, Malloc, Align, Name, InsertAtEnd) {}
124   MallocInst(const Type *Ty, Value *ArraySize, unsigned Align,
125                       const std::string &Name = "",
126                       Instruction *InsertBefore = 0)
127     : AllocationInst(Ty, ArraySize, Malloc, Align, Name, InsertBefore) {}
128
129   virtual MallocInst *clone() const;
130
131   // Methods for support type inquiry through isa, cast, and dyn_cast:
132   static inline bool classof(const MallocInst *) { return true; }
133   static inline bool classof(const Instruction *I) {
134     return (I->getOpcode() == Instruction::Malloc);
135   }
136   static inline bool classof(const Value *V) {
137     return isa<Instruction>(V) && classof(cast<Instruction>(V));
138   }
139 };
140
141
142 //===----------------------------------------------------------------------===//
143 //                                AllocaInst Class
144 //===----------------------------------------------------------------------===//
145
146 /// AllocaInst - an instruction to allocate memory on the stack
147 ///
148 class AllocaInst : public AllocationInst {
149   AllocaInst(const AllocaInst &);
150 public:
151   explicit AllocaInst(const Type *Ty, Value *ArraySize = 0,
152                       const std::string &Name = "",
153                       Instruction *InsertBefore = 0)
154     : AllocationInst(Ty, ArraySize, Alloca, 0, Name, InsertBefore) {}
155   AllocaInst(const Type *Ty, Value *ArraySize, const std::string &Name,
156              BasicBlock *InsertAtEnd)
157     : AllocationInst(Ty, ArraySize, Alloca, 0, Name, InsertAtEnd) {}
158
159   AllocaInst(const Type *Ty, const std::string &Name,
160              Instruction *InsertBefore = 0)
161     : AllocationInst(Ty, 0, Alloca, 0, Name, InsertBefore) {}
162   AllocaInst(const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd)
163     : AllocationInst(Ty, 0, Alloca, 0, Name, InsertAtEnd) {}
164
165   AllocaInst(const Type *Ty, Value *ArraySize, unsigned Align,
166              const std::string &Name = "", Instruction *InsertBefore = 0)
167     : AllocationInst(Ty, ArraySize, Alloca, Align, Name, InsertBefore) {}
168   AllocaInst(const Type *Ty, Value *ArraySize, unsigned Align,
169              const std::string &Name, BasicBlock *InsertAtEnd)
170     : AllocationInst(Ty, ArraySize, Alloca, Align, Name, InsertAtEnd) {}
171
172   virtual AllocaInst *clone() const;
173
174   // Methods for support type inquiry through isa, cast, and dyn_cast:
175   static inline bool classof(const AllocaInst *) { return true; }
176   static inline bool classof(const Instruction *I) {
177     return (I->getOpcode() == Instruction::Alloca);
178   }
179   static inline bool classof(const Value *V) {
180     return isa<Instruction>(V) && classof(cast<Instruction>(V));
181   }
182 };
183
184
185 //===----------------------------------------------------------------------===//
186 //                                 FreeInst Class
187 //===----------------------------------------------------------------------===//
188
189 /// FreeInst - an instruction to deallocate memory
190 ///
191 class FreeInst : public UnaryInstruction {
192   void AssertOK();
193 public:
194   explicit FreeInst(Value *Ptr, Instruction *InsertBefore = 0);
195   FreeInst(Value *Ptr, BasicBlock *InsertAfter);
196
197   virtual FreeInst *clone() const;
198   
199   // Accessor methods for consistency with other memory operations
200   Value *getPointerOperand() { return getOperand(0); }
201   const Value *getPointerOperand() const { return getOperand(0); }
202
203   // Methods for support type inquiry through isa, cast, and dyn_cast:
204   static inline bool classof(const FreeInst *) { return true; }
205   static inline bool classof(const Instruction *I) {
206     return (I->getOpcode() == Instruction::Free);
207   }
208   static inline bool classof(const Value *V) {
209     return isa<Instruction>(V) && classof(cast<Instruction>(V));
210   }
211 };
212
213
214 //===----------------------------------------------------------------------===//
215 //                                LoadInst Class
216 //===----------------------------------------------------------------------===//
217
218 /// LoadInst - an instruction for reading from memory.  This uses the
219 /// SubclassData field in Value to store whether or not the load is volatile.
220 ///
221 class LoadInst : public UnaryInstruction {
222
223   LoadInst(const LoadInst &LI)
224     : UnaryInstruction(LI.getType(), Load, LI.getOperand(0)) {
225     setVolatile(LI.isVolatile());
226     setAlignment(LI.getAlignment());
227
228 #ifndef NDEBUG
229     AssertOK();
230 #endif
231   }
232   void AssertOK();
233 public:
234   LoadInst(Value *Ptr, const std::string &Name, Instruction *InsertBefore);
235   LoadInst(Value *Ptr, const std::string &Name, BasicBlock *InsertAtEnd);
236   LoadInst(Value *Ptr, const std::string &Name, bool isVolatile = false, 
237            Instruction *InsertBefore = 0);
238   LoadInst(Value *Ptr, const std::string &Name, bool isVolatile, unsigned Align,
239            Instruction *InsertBefore = 0);
240   LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,
241            BasicBlock *InsertAtEnd);
242   LoadInst(Value *Ptr, const std::string &Name, bool isVolatile, unsigned Align,
243            BasicBlock *InsertAtEnd);
244
245   LoadInst(Value *Ptr, const char *Name, Instruction *InsertBefore);
246   LoadInst(Value *Ptr, const char *Name, BasicBlock *InsertAtEnd);
247   explicit LoadInst(Value *Ptr, const char *Name = 0, bool isVolatile = false, 
248                     Instruction *InsertBefore = 0);
249   LoadInst(Value *Ptr, const char *Name, bool isVolatile,
250            BasicBlock *InsertAtEnd);
251   
252   /// isVolatile - Return true if this is a load from a volatile memory
253   /// location.
254   ///
255   bool isVolatile() const { return SubclassData & 1; }
256
257   /// setVolatile - Specify whether this is a volatile load or not.
258   ///
259   void setVolatile(bool V) { 
260     SubclassData = (SubclassData & ~1) | (V ? 1 : 0); 
261   }
262
263   virtual LoadInst *clone() const;
264
265   /// getAlignment - Return the alignment of the access that is being performed
266   ///
267   unsigned getAlignment() const {
268     return (1 << (SubclassData>>1)) >> 1;
269   }
270   
271   void setAlignment(unsigned Align);
272
273   Value *getPointerOperand() { return getOperand(0); }
274   const Value *getPointerOperand() const { return getOperand(0); }
275   static unsigned getPointerOperandIndex() { return 0U; }
276
277   // Methods for support type inquiry through isa, cast, and dyn_cast:
278   static inline bool classof(const LoadInst *) { return true; }
279   static inline bool classof(const Instruction *I) {
280     return I->getOpcode() == Instruction::Load;
281   }
282   static inline bool classof(const Value *V) {
283     return isa<Instruction>(V) && classof(cast<Instruction>(V));
284   }
285 };
286
287
288 //===----------------------------------------------------------------------===//
289 //                                StoreInst Class
290 //===----------------------------------------------------------------------===//
291
292 /// StoreInst - an instruction for storing to memory
293 ///
294 class StoreInst : public Instruction {
295   Use Ops[2];
296   
297   StoreInst(const StoreInst &SI) : Instruction(SI.getType(), Store, Ops, 2) {
298     Ops[0].init(SI.Ops[0], this);
299     Ops[1].init(SI.Ops[1], this);
300     setVolatile(SI.isVolatile());
301     setAlignment(SI.getAlignment());
302     
303 #ifndef NDEBUG
304     AssertOK();
305 #endif
306   }
307   void AssertOK();
308 public:
309   StoreInst(Value *Val, Value *Ptr, Instruction *InsertBefore);
310   StoreInst(Value *Val, Value *Ptr, BasicBlock *InsertAtEnd);
311   StoreInst(Value *Val, Value *Ptr, bool isVolatile = false,
312             Instruction *InsertBefore = 0);
313   StoreInst(Value *Val, Value *Ptr, bool isVolatile,
314             unsigned Align, Instruction *InsertBefore = 0);
315   StoreInst(Value *Val, Value *Ptr, bool isVolatile, BasicBlock *InsertAtEnd);
316   StoreInst(Value *Val, Value *Ptr, bool isVolatile,
317             unsigned Align, BasicBlock *InsertAtEnd);
318
319
320   /// isVolatile - Return true if this is a load from a volatile memory
321   /// location.
322   ///
323   bool isVolatile() const { return SubclassData & 1; }
324
325   /// setVolatile - Specify whether this is a volatile load or not.
326   ///
327   void setVolatile(bool V) { 
328     SubclassData = (SubclassData & ~1) | (V ? 1 : 0); 
329   }
330
331   /// Transparently provide more efficient getOperand methods.
332   Value *getOperand(unsigned i) const {
333     assert(i < 2 && "getOperand() out of range!");
334     return Ops[i];
335   }
336   void setOperand(unsigned i, Value *Val) {
337     assert(i < 2 && "setOperand() out of range!");
338     Ops[i] = Val;
339   }
340   unsigned getNumOperands() const { return 2; }
341
342   /// getAlignment - Return the alignment of the access that is being performed
343   ///
344   unsigned getAlignment() const {
345     return (1 << (SubclassData>>1)) >> 1;
346   }
347   
348   void setAlignment(unsigned Align);
349   
350   virtual StoreInst *clone() const;
351
352   Value *getPointerOperand() { return getOperand(1); }
353   const Value *getPointerOperand() const { return getOperand(1); }
354   static unsigned getPointerOperandIndex() { return 1U; }
355
356   // Methods for support type inquiry through isa, cast, and dyn_cast:
357   static inline bool classof(const StoreInst *) { return true; }
358   static inline bool classof(const Instruction *I) {
359     return I->getOpcode() == Instruction::Store;
360   }
361   static inline bool classof(const Value *V) {
362     return isa<Instruction>(V) && classof(cast<Instruction>(V));
363   }
364 };
365
366
367 //===----------------------------------------------------------------------===//
368 //                             GetElementPtrInst Class
369 //===----------------------------------------------------------------------===//
370
371 // checkType - Simple wrapper function to give a better assertion failure
372 // message on bad indexes for a gep instruction.
373 //
374 static inline const Type *checkType(const Type *Ty) {
375   assert(Ty && "Invalid GetElementPtrInst indices for type!");
376   return Ty;
377 }
378
379 /// GetElementPtrInst - an instruction for type-safe pointer arithmetic to
380 /// access elements of arrays and structs
381 ///
382 class GetElementPtrInst : public Instruction {
383   GetElementPtrInst(const GetElementPtrInst &GEPI)
384     : Instruction(reinterpret_cast<const Type*>(GEPI.getType()), GetElementPtr,
385                   0, GEPI.getNumOperands()) {
386     Use *OL = OperandList = new Use[NumOperands];
387     Use *GEPIOL = GEPI.OperandList;
388     for (unsigned i = 0, E = NumOperands; i != E; ++i)
389       OL[i].init(GEPIOL[i], this);
390   }
391   void init(Value *Ptr, Value* const *Idx, unsigned NumIdx);
392   void init(Value *Ptr, Value *Idx);
393
394   template<typename InputIterator>
395   void init(Value *Ptr, InputIterator IdxBegin, InputIterator IdxEnd,
396             const std::string &Name,
397             // This argument ensures that we have an iterator we can
398             // do arithmetic on in constant time
399             std::random_access_iterator_tag) {
400     typename std::iterator_traits<InputIterator>::difference_type NumIdx = 
401       std::distance(IdxBegin, IdxEnd);
402     
403     if (NumIdx > 0) {
404       // This requires that the itoerator points to contiguous memory.
405       init(Ptr, &*IdxBegin, NumIdx);
406     }
407     else {
408       init(Ptr, 0, NumIdx);
409     }
410
411     setName(Name);
412   }
413
414   /// getIndexedType - Returns the type of the element that would be loaded with
415   /// a load instruction with the specified parameters.
416   ///
417   /// A null type is returned if the indices are invalid for the specified
418   /// pointer type.
419   ///
420   static const Type *getIndexedType(const Type *Ptr,
421                                     Value* const *Idx, unsigned NumIdx,
422                                     bool AllowStructLeaf = false);
423
424   template<typename InputIterator>
425   static const Type *getIndexedType(const Type *Ptr,
426                                     InputIterator IdxBegin, 
427                                     InputIterator IdxEnd,
428                                     bool AllowStructLeaf,
429                                     // This argument ensures that we
430                                     // have an iterator we can do
431                                     // arithmetic on in constant time
432                                     std::random_access_iterator_tag) {
433     typename std::iterator_traits<InputIterator>::difference_type NumIdx = 
434       std::distance(IdxBegin, IdxEnd);
435
436     if (NumIdx > 0) {
437       // This requires that the iterator points to contiguous memory.
438       return(getIndexedType(Ptr, (Value *const *)&*IdxBegin, NumIdx,
439                             AllowStructLeaf));
440     }
441     else {
442       return(getIndexedType(Ptr, (Value *const*)0, NumIdx, AllowStructLeaf));
443     }
444   }
445
446 public:
447   /// Constructors - Create a getelementptr instruction with a base pointer an
448   /// list of indices.  The first ctor can optionally insert before an existing
449   /// instruction, the second appends the new instruction to the specified
450   /// BasicBlock.
451   template<typename InputIterator>
452   GetElementPtrInst(Value *Ptr, InputIterator IdxBegin, 
453                     InputIterator IdxEnd,
454                     const std::string &Name = "",
455                     Instruction *InsertBefore =0)
456       : Instruction(PointerType::get(
457                       checkType(getIndexedType(Ptr->getType(),
458                                                IdxBegin, IdxEnd, true))),
459                     GetElementPtr, 0, 0, InsertBefore) {
460     init(Ptr, IdxBegin, IdxEnd, Name,
461          typename std::iterator_traits<InputIterator>::iterator_category());
462   }
463   template<typename InputIterator>
464   GetElementPtrInst(Value *Ptr, InputIterator IdxBegin, InputIterator IdxEnd,
465                     const std::string &Name, BasicBlock *InsertAtEnd)
466       : Instruction(PointerType::get(
467                       checkType(getIndexedType(Ptr->getType(),
468                                                IdxBegin, IdxEnd, true))),
469                     GetElementPtr, 0, 0, InsertAtEnd) {
470     init(Ptr, IdxBegin, IdxEnd, Name,
471          typename std::iterator_traits<InputIterator>::iterator_category());
472   }
473
474   /// Constructors - These two constructors are convenience methods because one
475   /// and two index getelementptr instructions are so common.
476   GetElementPtrInst(Value *Ptr, Value *Idx,
477                     const std::string &Name = "", Instruction *InsertBefore =0);
478   GetElementPtrInst(Value *Ptr, Value *Idx,
479                     const std::string &Name, BasicBlock *InsertAtEnd);
480   ~GetElementPtrInst();
481
482   virtual GetElementPtrInst *clone() const;
483
484   // getType - Overload to return most specific pointer type...
485   inline const PointerType *getType() const {
486     return reinterpret_cast<const PointerType*>(Instruction::getType());
487   }
488
489   /// getIndexedType - Returns the type of the element that would be loaded with
490   /// a load instruction with the specified parameters.
491   ///
492   /// A null type is returned if the indices are invalid for the specified
493   /// pointer type.
494   ///
495   template<typename InputIterator>
496   static const Type *getIndexedType(const Type *Ptr,
497                                     InputIterator IdxBegin,
498                                     InputIterator IdxEnd,
499                                     bool AllowStructLeaf = false) {
500     return(getIndexedType(Ptr, IdxBegin, IdxEnd, AllowStructLeaf, 
501                           typename std::iterator_traits<InputIterator>::
502                           iterator_category()));
503   }  
504   static const Type *getIndexedType(const Type *Ptr, Value *Idx);
505
506   inline op_iterator       idx_begin()       { return op_begin()+1; }
507   inline const_op_iterator idx_begin() const { return op_begin()+1; }
508   inline op_iterator       idx_end()         { return op_end(); }
509   inline const_op_iterator idx_end()   const { return op_end(); }
510
511   Value *getPointerOperand() {
512     return getOperand(0);
513   }
514   const Value *getPointerOperand() const {
515     return getOperand(0);
516   }
517   static unsigned getPointerOperandIndex() {
518     return 0U;                      // get index for modifying correct operand
519   }
520
521   inline unsigned getNumIndices() const {  // Note: always non-negative
522     return getNumOperands() - 1;
523   }
524
525   inline bool hasIndices() const {
526     return getNumOperands() > 1;
527   }
528   
529   /// hasAllZeroIndices - Return true if all of the indices of this GEP are
530   /// zeros.  If so, the result pointer and the first operand have the same
531   /// value, just potentially different types.
532   bool hasAllZeroIndices() const;
533   
534   /// hasAllConstantIndices - Return true if all of the indices of this GEP are
535   /// constant integers.  If so, the result pointer and the first operand have
536   /// a constant offset between them.
537   bool hasAllConstantIndices() const;
538   
539
540   // Methods for support type inquiry through isa, cast, and dyn_cast:
541   static inline bool classof(const GetElementPtrInst *) { return true; }
542   static inline bool classof(const Instruction *I) {
543     return (I->getOpcode() == Instruction::GetElementPtr);
544   }
545   static inline bool classof(const Value *V) {
546     return isa<Instruction>(V) && classof(cast<Instruction>(V));
547   }
548 };
549
550 //===----------------------------------------------------------------------===//
551 //                               ICmpInst Class
552 //===----------------------------------------------------------------------===//
553
554 /// This instruction compares its operands according to the predicate given
555 /// to the constructor. It only operates on integers, pointers, or packed 
556 /// vectors of integrals. The two operands must be the same type.
557 /// @brief Represent an integer comparison operator.
558 class ICmpInst: public CmpInst {
559 public:
560   /// This enumeration lists the possible predicates for the ICmpInst. The
561   /// values in the range 0-31 are reserved for FCmpInst while values in the
562   /// range 32-64 are reserved for ICmpInst. This is necessary to ensure the
563   /// predicate values are not overlapping between the classes.
564   enum Predicate {
565     ICMP_EQ  = 32,    ///< equal
566     ICMP_NE  = 33,    ///< not equal
567     ICMP_UGT = 34,    ///< unsigned greater than
568     ICMP_UGE = 35,    ///< unsigned greater or equal
569     ICMP_ULT = 36,    ///< unsigned less than
570     ICMP_ULE = 37,    ///< unsigned less or equal
571     ICMP_SGT = 38,    ///< signed greater than
572     ICMP_SGE = 39,    ///< signed greater or equal
573     ICMP_SLT = 40,    ///< signed less than
574     ICMP_SLE = 41,    ///< signed less or equal
575     FIRST_ICMP_PREDICATE = ICMP_EQ,
576     LAST_ICMP_PREDICATE = ICMP_SLE,
577     BAD_ICMP_PREDICATE = ICMP_SLE + 1
578   };
579
580   /// @brief Constructor with insert-before-instruction semantics.
581   ICmpInst(
582     Predicate pred,  ///< The predicate to use for the comparison
583     Value *LHS,      ///< The left-hand-side of the expression
584     Value *RHS,      ///< The right-hand-side of the expression
585     const std::string &Name = "",  ///< Name of the instruction
586     Instruction *InsertBefore = 0  ///< Where to insert
587   ) : CmpInst(Instruction::ICmp, pred, LHS, RHS, Name, InsertBefore) {
588   }
589
590   /// @brief Constructor with insert-at-block-end semantics.
591   ICmpInst(
592     Predicate pred, ///< The predicate to use for the comparison
593     Value *LHS,     ///< The left-hand-side of the expression
594     Value *RHS,     ///< The right-hand-side of the expression
595     const std::string &Name,  ///< Name of the instruction
596     BasicBlock *InsertAtEnd   ///< Block to insert into.
597   ) : CmpInst(Instruction::ICmp, pred, LHS, RHS, Name, InsertAtEnd) {
598   }
599
600   /// @brief Return the predicate for this instruction.
601   Predicate getPredicate() const { return Predicate(SubclassData); }
602
603   /// @brief Set the predicate for this instruction to the specified value.
604   void setPredicate(Predicate P) { SubclassData = P; }
605   
606   /// For example, EQ -> NE, UGT -> ULE, SLT -> SGE, etc.
607   /// @returns the inverse predicate for the instruction's current predicate. 
608   /// @brief Return the inverse of the instruction's predicate.
609   Predicate getInversePredicate() const {
610     return getInversePredicate(getPredicate());
611   }
612
613   /// For example, EQ -> NE, UGT -> ULE, SLT -> SGE, etc.
614   /// @returns the inverse predicate for predicate provided in \p pred. 
615   /// @brief Return the inverse of a given predicate
616   static Predicate getInversePredicate(Predicate pred);
617
618   /// For example, EQ->EQ, SLE->SGE, ULT->UGT, etc.
619   /// @returns the predicate that would be the result of exchanging the two 
620   /// operands of the ICmpInst instruction without changing the result 
621   /// produced.  
622   /// @brief Return the predicate as if the operands were swapped
623   Predicate getSwappedPredicate() const {
624     return getSwappedPredicate(getPredicate());
625   }
626
627   /// This is a static version that you can use without an instruction 
628   /// available.
629   /// @brief Return the predicate as if the operands were swapped.
630   static Predicate getSwappedPredicate(Predicate pred);
631
632   /// For example, EQ->EQ, SLE->SLE, UGT->SGT, etc.
633   /// @returns the predicate that would be the result if the operand were
634   /// regarded as signed.
635   /// @brief Return the signed version of the predicate
636   Predicate getSignedPredicate() const {
637     return getSignedPredicate(getPredicate());
638   }
639
640   /// This is a static version that you can use without an instruction.
641   /// @brief Return the signed version of the predicate.
642   static Predicate getSignedPredicate(Predicate pred);
643
644   /// isEquality - Return true if this predicate is either EQ or NE.  This also
645   /// tests for commutativity.
646   static bool isEquality(Predicate P) {
647     return P == ICMP_EQ || P == ICMP_NE;
648   }
649   
650   /// isEquality - Return true if this predicate is either EQ or NE.  This also
651   /// tests for commutativity.
652   bool isEquality() const {
653     return isEquality(getPredicate());
654   }
655
656   /// @returns true if the predicate of this ICmpInst is commutative
657   /// @brief Determine if this relation is commutative.
658   bool isCommutative() const { return isEquality(); }
659
660   /// isRelational - Return true if the predicate is relational (not EQ or NE). 
661   ///
662   bool isRelational() const {
663     return !isEquality();
664   }
665
666   /// isRelational - Return true if the predicate is relational (not EQ or NE). 
667   ///
668   static bool isRelational(Predicate P) {
669     return !isEquality(P);
670   }
671   
672   /// @returns true if the predicate of this ICmpInst is signed, false otherwise
673   /// @brief Determine if this instruction's predicate is signed.
674   bool isSignedPredicate() const { return isSignedPredicate(getPredicate()); }
675
676   /// @returns true if the predicate provided is signed, false otherwise
677   /// @brief Determine if the predicate is signed.
678   static bool isSignedPredicate(Predicate pred);
679
680   /// Initialize a set of values that all satisfy the predicate with C. 
681   /// @brief Make a ConstantRange for a relation with a constant value.
682   static ConstantRange makeConstantRange(Predicate pred, const APInt &C);
683
684   /// Exchange the two operands to this instruction in such a way that it does
685   /// not modify the semantics of the instruction. The predicate value may be
686   /// changed to retain the same result if the predicate is order dependent
687   /// (e.g. ult). 
688   /// @brief Swap operands and adjust predicate.
689   void swapOperands() {
690     SubclassData = getSwappedPredicate();
691     std::swap(Ops[0], Ops[1]);
692   }
693
694   virtual ICmpInst *clone() const;
695
696   // Methods for support type inquiry through isa, cast, and dyn_cast:
697   static inline bool classof(const ICmpInst *) { return true; }
698   static inline bool classof(const Instruction *I) {
699     return I->getOpcode() == Instruction::ICmp;
700   }
701   static inline bool classof(const Value *V) {
702     return isa<Instruction>(V) && classof(cast<Instruction>(V));
703   }
704 };
705
706 //===----------------------------------------------------------------------===//
707 //                               FCmpInst Class
708 //===----------------------------------------------------------------------===//
709
710 /// This instruction compares its operands according to the predicate given
711 /// to the constructor. It only operates on floating point values or packed     
712 /// vectors of floating point values. The operands must be identical types.
713 /// @brief Represents a floating point comparison operator.
714 class FCmpInst: public CmpInst {
715 public:
716   /// This enumeration lists the possible predicates for the FCmpInst. Values
717   /// in the range 0-31 are reserved for FCmpInst.
718   enum Predicate {
719     // Opcode        U L G E    Intuitive operation
720     FCMP_FALSE = 0, ///<  0 0 0 0    Always false (always folded)
721     FCMP_OEQ   = 1, ///<  0 0 0 1    True if ordered and equal
722     FCMP_OGT   = 2, ///<  0 0 1 0    True if ordered and greater than
723     FCMP_OGE   = 3, ///<  0 0 1 1    True if ordered and greater than or equal
724     FCMP_OLT   = 4, ///<  0 1 0 0    True if ordered and less than
725     FCMP_OLE   = 5, ///<  0 1 0 1    True if ordered and less than or equal
726     FCMP_ONE   = 6, ///<  0 1 1 0    True if ordered and operands are unequal
727     FCMP_ORD   = 7, ///<  0 1 1 1    True if ordered (no nans)
728     FCMP_UNO   = 8, ///<  1 0 0 0    True if unordered: isnan(X) | isnan(Y)
729     FCMP_UEQ   = 9, ///<  1 0 0 1    True if unordered or equal
730     FCMP_UGT   =10, ///<  1 0 1 0    True if unordered or greater than
731     FCMP_UGE   =11, ///<  1 0 1 1    True if unordered, greater than, or equal
732     FCMP_ULT   =12, ///<  1 1 0 0    True if unordered or less than
733     FCMP_ULE   =13, ///<  1 1 0 1    True if unordered, less than, or equal
734     FCMP_UNE   =14, ///<  1 1 1 0    True if unordered or not equal
735     FCMP_TRUE  =15, ///<  1 1 1 1    Always true (always folded)
736     FIRST_FCMP_PREDICATE = FCMP_FALSE,
737     LAST_FCMP_PREDICATE = FCMP_TRUE,
738     BAD_FCMP_PREDICATE = FCMP_TRUE + 1
739   };
740
741   /// @brief Constructor with insert-before-instruction semantics.
742   FCmpInst(
743     Predicate pred,  ///< The predicate to use for the comparison
744     Value *LHS,      ///< The left-hand-side of the expression
745     Value *RHS,      ///< The right-hand-side of the expression
746     const std::string &Name = "",  ///< Name of the instruction
747     Instruction *InsertBefore = 0  ///< Where to insert
748   ) : CmpInst(Instruction::FCmp, pred, LHS, RHS, Name, InsertBefore) {
749   }
750
751   /// @brief Constructor with insert-at-block-end semantics.
752   FCmpInst(
753     Predicate pred, ///< The predicate to use for the comparison
754     Value *LHS,     ///< The left-hand-side of the expression
755     Value *RHS,     ///< The right-hand-side of the expression
756     const std::string &Name,  ///< Name of the instruction
757     BasicBlock *InsertAtEnd   ///< Block to insert into.
758   ) : CmpInst(Instruction::FCmp, pred, LHS, RHS, Name, InsertAtEnd) {
759   }
760
761   /// @brief Return the predicate for this instruction.
762   Predicate getPredicate() const { return Predicate(SubclassData); }
763
764   /// @brief Set the predicate for this instruction to the specified value.
765   void setPredicate(Predicate P) { SubclassData = P; }
766
767   /// For example, OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc.
768   /// @returns the inverse predicate for the instructions current predicate. 
769   /// @brief Return the inverse of the predicate
770   Predicate getInversePredicate() const {
771     return getInversePredicate(getPredicate());
772   }
773
774   /// For example, OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc.
775   /// @returns the inverse predicate for \p pred.
776   /// @brief Return the inverse of a given predicate
777   static Predicate getInversePredicate(Predicate pred);
778
779   /// For example, OEQ->OEQ, ULE->UGE, OLT->OGT, etc.
780   /// @returns the predicate that would be the result of exchanging the two 
781   /// operands of the ICmpInst instruction without changing the result 
782   /// produced.  
783   /// @brief Return the predicate as if the operands were swapped
784   Predicate getSwappedPredicate() const {
785     return getSwappedPredicate(getPredicate());
786   }
787
788   /// This is a static version that you can use without an instruction 
789   /// available.
790   /// @brief Return the predicate as if the operands were swapped.
791   static Predicate getSwappedPredicate(Predicate Opcode);
792
793   /// This also tests for commutativity. If isEquality() returns true then
794   /// the predicate is also commutative. Only the equality predicates are
795   /// commutative.
796   /// @returns true if the predicate of this instruction is EQ or NE.
797   /// @brief Determine if this is an equality predicate.
798   bool isEquality() const {
799     return SubclassData == FCMP_OEQ || SubclassData == FCMP_ONE ||
800            SubclassData == FCMP_UEQ || SubclassData == FCMP_UNE;
801   }
802   bool isCommutative() const { return isEquality(); }
803
804   /// @returns true if the predicate is relational (not EQ or NE). 
805   /// @brief Determine if this a relational predicate.
806   bool isRelational() const { return !isEquality(); }
807
808   /// Exchange the two operands to this instruction in such a way that it does
809   /// not modify the semantics of the instruction. The predicate value may be
810   /// changed to retain the same result if the predicate is order dependent
811   /// (e.g. ult). 
812   /// @brief Swap operands and adjust predicate.
813   void swapOperands() {
814     SubclassData = getSwappedPredicate();
815     std::swap(Ops[0], Ops[1]);
816   }
817
818   virtual FCmpInst *clone() const;
819
820   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
821   static inline bool classof(const FCmpInst *) { return true; }
822   static inline bool classof(const Instruction *I) {
823     return I->getOpcode() == Instruction::FCmp;
824   }
825   static inline bool classof(const Value *V) {
826     return isa<Instruction>(V) && classof(cast<Instruction>(V));
827   }
828 };
829
830 //===----------------------------------------------------------------------===//
831 //                                 CallInst Class
832 //===----------------------------------------------------------------------===//
833 /// CallInst - This class represents a function call, abstracting a target
834 /// machine's calling convention.  This class uses low bit of the SubClassData
835 /// field to indicate whether or not this is a tail call.  The rest of the bits
836 /// hold the calling convention of the call.
837 ///
838
839 class CallInst : public Instruction {
840   const ParamAttrsList *ParamAttrs; ///< parameter attributes for call
841   CallInst(const CallInst &CI);
842   void init(Value *Func, Value* const *Params, unsigned NumParams);
843   void init(Value *Func, Value *Actual1, Value *Actual2);
844   void init(Value *Func, Value *Actual);
845   void init(Value *Func);
846
847   template<typename InputIterator>
848   void init(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd,
849             const std::string &Name,
850             // This argument ensures that we have an iterator we can
851             // do arithmetic on in constant time
852             std::random_access_iterator_tag) {
853     unsigned NumArgs = (unsigned)std::distance(ArgBegin, ArgEnd);
854     
855     // This requires that the iterator points to contiguous memory.
856     init(Func, NumArgs ? &*ArgBegin : 0, NumArgs);
857     setName(Name);
858   }
859
860 public:
861   /// Construct a CallInst given a range of arguments.  InputIterator
862   /// must be a random-access iterator pointing to contiguous storage
863   /// (e.g. a std::vector<>::iterator).  Checks are made for
864   /// random-accessness but not for contiguous storage as that would
865   /// incur runtime overhead.
866   /// @brief Construct a CallInst from a range of arguments
867   template<typename InputIterator>
868   CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd,
869            const std::string &Name = "", Instruction *InsertBefore = 0)
870       : Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
871                                        ->getElementType())->getReturnType(),
872                     Instruction::Call, 0, 0, InsertBefore) {
873     init(Func, ArgBegin, ArgEnd, Name, 
874          typename std::iterator_traits<InputIterator>::iterator_category());
875   }
876
877   /// Construct a CallInst given a range of arguments.  InputIterator
878   /// must be a random-access iterator pointing to contiguous storage
879   /// (e.g. a std::vector<>::iterator).  Checks are made for
880   /// random-accessness but not for contiguous storage as that would
881   /// incur runtime overhead.
882   /// @brief Construct a CallInst from a range of arguments
883   template<typename InputIterator>
884   CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd,
885            const std::string &Name, BasicBlock *InsertAtEnd)
886       : Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
887                                        ->getElementType())->getReturnType(),
888                     Instruction::Call, 0, 0, InsertAtEnd) {
889     init(Func, ArgBegin, ArgEnd, Name,
890          typename std::iterator_traits<InputIterator>::iterator_category());
891   }
892
893   CallInst(Value *F, Value *Actual, const std::string& Name = "",
894            Instruction *InsertBefore = 0);
895   CallInst(Value *F, Value *Actual, const std::string& Name,
896            BasicBlock *InsertAtEnd);
897   explicit CallInst(Value *F, const std::string &Name = "",
898                     Instruction *InsertBefore = 0);
899   CallInst(Value *F, const std::string &Name, BasicBlock *InsertAtEnd);
900   ~CallInst();
901
902   virtual CallInst *clone() const;
903   
904   bool isTailCall() const           { return SubclassData & 1; }
905   void setTailCall(bool isTailCall = true) {
906     SubclassData = (SubclassData & ~1) | unsigned(isTailCall);
907   }
908
909   /// getCallingConv/setCallingConv - Get or set the calling convention of this
910   /// function call.
911   unsigned getCallingConv() const { return SubclassData >> 1; }
912   void setCallingConv(unsigned CC) {
913     SubclassData = (SubclassData & 1) | (CC << 1);
914   }
915
916   /// Obtains a pointer to the ParamAttrsList object which holds the
917   /// parameter attributes information, if any.
918   /// @returns 0 if no attributes have been set.
919   /// @brief Get the parameter attributes.
920   const ParamAttrsList *getParamAttrs() const { return ParamAttrs; }
921
922   /// Sets the parameter attributes for this CallInst. To construct a 
923   /// ParamAttrsList, see ParameterAttributes.h
924   /// @brief Set the parameter attributes.
925   void setParamAttrs(const ParamAttrsList *attrs);
926
927   /// @brief Determine whether the call or the callee has the given attribute.
928   bool paramHasAttr(uint16_t i, ParameterAttributes attr) const;
929
930   /// @brief Determine if the call returns a structure.
931   bool isStructReturn() const {
932     // Be friendly and also check the callee.
933     return paramHasAttr(1, ParamAttr::StructRet);
934   }
935
936   /// getCalledFunction - Return the function being called by this instruction
937   /// if it is a direct call.  If it is a call through a function pointer,
938   /// return null.
939   Function *getCalledFunction() const {
940     return dyn_cast<Function>(getOperand(0));
941   }
942
943   /// getCalledValue - Get a pointer to the function that is invoked by this 
944   /// instruction
945   inline const Value *getCalledValue() const { return getOperand(0); }
946   inline       Value *getCalledValue()       { return getOperand(0); }
947
948   // Methods for support type inquiry through isa, cast, and dyn_cast:
949   static inline bool classof(const CallInst *) { return true; }
950   static inline bool classof(const Instruction *I) {
951     return I->getOpcode() == Instruction::Call;
952   }
953   static inline bool classof(const Value *V) {
954     return isa<Instruction>(V) && classof(cast<Instruction>(V));
955   }
956 };
957
958 //===----------------------------------------------------------------------===//
959 //                               SelectInst Class
960 //===----------------------------------------------------------------------===//
961
962 /// SelectInst - This class represents the LLVM 'select' instruction.
963 ///
964 class SelectInst : public Instruction {
965   Use Ops[3];
966
967   void init(Value *C, Value *S1, Value *S2) {
968     Ops[0].init(C, this);
969     Ops[1].init(S1, this);
970     Ops[2].init(S2, this);
971   }
972
973   SelectInst(const SelectInst &SI)
974     : Instruction(SI.getType(), SI.getOpcode(), Ops, 3) {
975     init(SI.Ops[0], SI.Ops[1], SI.Ops[2]);
976   }
977 public:
978   SelectInst(Value *C, Value *S1, Value *S2, const std::string &Name = "",
979              Instruction *InsertBefore = 0)
980     : Instruction(S1->getType(), Instruction::Select, Ops, 3, InsertBefore) {
981     init(C, S1, S2);
982     setName(Name);
983   }
984   SelectInst(Value *C, Value *S1, Value *S2, const std::string &Name,
985              BasicBlock *InsertAtEnd)
986     : Instruction(S1->getType(), Instruction::Select, Ops, 3, InsertAtEnd) {
987     init(C, S1, S2);
988     setName(Name);
989   }
990
991   Value *getCondition() const { return Ops[0]; }
992   Value *getTrueValue() const { return Ops[1]; }
993   Value *getFalseValue() const { return Ops[2]; }
994
995   /// Transparently provide more efficient getOperand methods.
996   Value *getOperand(unsigned i) const {
997     assert(i < 3 && "getOperand() out of range!");
998     return Ops[i];
999   }
1000   void setOperand(unsigned i, Value *Val) {
1001     assert(i < 3 && "setOperand() out of range!");
1002     Ops[i] = Val;
1003   }
1004   unsigned getNumOperands() const { return 3; }
1005
1006   OtherOps getOpcode() const {
1007     return static_cast<OtherOps>(Instruction::getOpcode());
1008   }
1009
1010   virtual SelectInst *clone() const;
1011
1012   // Methods for support type inquiry through isa, cast, and dyn_cast:
1013   static inline bool classof(const SelectInst *) { return true; }
1014   static inline bool classof(const Instruction *I) {
1015     return I->getOpcode() == Instruction::Select;
1016   }
1017   static inline bool classof(const Value *V) {
1018     return isa<Instruction>(V) && classof(cast<Instruction>(V));
1019   }
1020 };
1021
1022 //===----------------------------------------------------------------------===//
1023 //                                VAArgInst Class
1024 //===----------------------------------------------------------------------===//
1025
1026 /// VAArgInst - This class represents the va_arg llvm instruction, which returns
1027 /// an argument of the specified type given a va_list and increments that list
1028 ///
1029 class VAArgInst : public UnaryInstruction {
1030   VAArgInst(const VAArgInst &VAA)
1031     : UnaryInstruction(VAA.getType(), VAArg, VAA.getOperand(0)) {}
1032 public:
1033   VAArgInst(Value *List, const Type *Ty, const std::string &Name = "",
1034              Instruction *InsertBefore = 0)
1035     : UnaryInstruction(Ty, VAArg, List, InsertBefore) {
1036     setName(Name);
1037   }
1038   VAArgInst(Value *List, const Type *Ty, const std::string &Name,
1039             BasicBlock *InsertAtEnd)
1040     : UnaryInstruction(Ty, VAArg, List, InsertAtEnd) {
1041     setName(Name);
1042   }
1043
1044   virtual VAArgInst *clone() const;
1045
1046   // Methods for support type inquiry through isa, cast, and dyn_cast:
1047   static inline bool classof(const VAArgInst *) { return true; }
1048   static inline bool classof(const Instruction *I) {
1049     return I->getOpcode() == VAArg;
1050   }
1051   static inline bool classof(const Value *V) {
1052     return isa<Instruction>(V) && classof(cast<Instruction>(V));
1053   }
1054 };
1055
1056 //===----------------------------------------------------------------------===//
1057 //                                ExtractElementInst Class
1058 //===----------------------------------------------------------------------===//
1059
1060 /// ExtractElementInst - This instruction extracts a single (scalar)
1061 /// element from a VectorType value
1062 ///
1063 class ExtractElementInst : public Instruction {
1064   Use Ops[2];
1065   ExtractElementInst(const ExtractElementInst &EE) :
1066     Instruction(EE.getType(), ExtractElement, Ops, 2) {
1067     Ops[0].init(EE.Ops[0], this);
1068     Ops[1].init(EE.Ops[1], this);
1069   }
1070
1071 public:
1072   ExtractElementInst(Value *Vec, Value *Idx, const std::string &Name = "",
1073                      Instruction *InsertBefore = 0);
1074   ExtractElementInst(Value *Vec, unsigned Idx, const std::string &Name = "",
1075                      Instruction *InsertBefore = 0);
1076   ExtractElementInst(Value *Vec, Value *Idx, const std::string &Name,
1077                      BasicBlock *InsertAtEnd);
1078   ExtractElementInst(Value *Vec, unsigned Idx, const std::string &Name,
1079                      BasicBlock *InsertAtEnd);
1080
1081   /// isValidOperands - Return true if an extractelement instruction can be
1082   /// formed with the specified operands.
1083   static bool isValidOperands(const Value *Vec, const Value *Idx);
1084
1085   virtual ExtractElementInst *clone() const;
1086
1087   /// Transparently provide more efficient getOperand methods.
1088   Value *getOperand(unsigned i) const {
1089     assert(i < 2 && "getOperand() out of range!");
1090     return Ops[i];
1091   }
1092   void setOperand(unsigned i, Value *Val) {
1093     assert(i < 2 && "setOperand() out of range!");
1094     Ops[i] = Val;
1095   }
1096   unsigned getNumOperands() const { return 2; }
1097
1098   // Methods for support type inquiry through isa, cast, and dyn_cast:
1099   static inline bool classof(const ExtractElementInst *) { return true; }
1100   static inline bool classof(const Instruction *I) {
1101     return I->getOpcode() == Instruction::ExtractElement;
1102   }
1103   static inline bool classof(const Value *V) {
1104     return isa<Instruction>(V) && classof(cast<Instruction>(V));
1105   }
1106 };
1107
1108 //===----------------------------------------------------------------------===//
1109 //                                InsertElementInst Class
1110 //===----------------------------------------------------------------------===//
1111
1112 /// InsertElementInst - This instruction inserts a single (scalar)
1113 /// element into a VectorType value
1114 ///
1115 class InsertElementInst : public Instruction {
1116   Use Ops[3];
1117   InsertElementInst(const InsertElementInst &IE);
1118 public:
1119   InsertElementInst(Value *Vec, Value *NewElt, Value *Idx,
1120                     const std::string &Name = "",Instruction *InsertBefore = 0);
1121   InsertElementInst(Value *Vec, Value *NewElt, unsigned Idx,
1122                     const std::string &Name = "",Instruction *InsertBefore = 0);
1123   InsertElementInst(Value *Vec, Value *NewElt, Value *Idx,
1124                     const std::string &Name, BasicBlock *InsertAtEnd);
1125   InsertElementInst(Value *Vec, Value *NewElt, unsigned Idx,
1126                     const std::string &Name, BasicBlock *InsertAtEnd);
1127
1128   /// isValidOperands - Return true if an insertelement instruction can be
1129   /// formed with the specified operands.
1130   static bool isValidOperands(const Value *Vec, const Value *NewElt,
1131                               const Value *Idx);
1132
1133   virtual InsertElementInst *clone() const;
1134
1135   /// getType - Overload to return most specific vector type.
1136   ///
1137   inline const VectorType *getType() const {
1138     return reinterpret_cast<const VectorType*>(Instruction::getType());
1139   }
1140
1141   /// Transparently provide more efficient getOperand methods.
1142   Value *getOperand(unsigned i) const {
1143     assert(i < 3 && "getOperand() out of range!");
1144     return Ops[i];
1145   }
1146   void setOperand(unsigned i, Value *Val) {
1147     assert(i < 3 && "setOperand() out of range!");
1148     Ops[i] = Val;
1149   }
1150   unsigned getNumOperands() const { return 3; }
1151
1152   // Methods for support type inquiry through isa, cast, and dyn_cast:
1153   static inline bool classof(const InsertElementInst *) { return true; }
1154   static inline bool classof(const Instruction *I) {
1155     return I->getOpcode() == Instruction::InsertElement;
1156   }
1157   static inline bool classof(const Value *V) {
1158     return isa<Instruction>(V) && classof(cast<Instruction>(V));
1159   }
1160 };
1161
1162 //===----------------------------------------------------------------------===//
1163 //                           ShuffleVectorInst Class
1164 //===----------------------------------------------------------------------===//
1165
1166 /// ShuffleVectorInst - This instruction constructs a fixed permutation of two
1167 /// input vectors.
1168 ///
1169 class ShuffleVectorInst : public Instruction {
1170   Use Ops[3];
1171   ShuffleVectorInst(const ShuffleVectorInst &IE);
1172 public:
1173   ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
1174                     const std::string &Name = "", Instruction *InsertBefor = 0);
1175   ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
1176                     const std::string &Name, BasicBlock *InsertAtEnd);
1177
1178   /// isValidOperands - Return true if a shufflevector instruction can be
1179   /// formed with the specified operands.
1180   static bool isValidOperands(const Value *V1, const Value *V2,
1181                               const Value *Mask);
1182
1183   virtual ShuffleVectorInst *clone() const;
1184
1185   /// getType - Overload to return most specific vector type.
1186   ///
1187   inline const VectorType *getType() const {
1188     return reinterpret_cast<const VectorType*>(Instruction::getType());
1189   }
1190
1191   /// Transparently provide more efficient getOperand methods.
1192   Value *getOperand(unsigned i) const {
1193     assert(i < 3 && "getOperand() out of range!");
1194     return Ops[i];
1195   }
1196   void setOperand(unsigned i, Value *Val) {
1197     assert(i < 3 && "setOperand() out of range!");
1198     Ops[i] = Val;
1199   }
1200   unsigned getNumOperands() const { return 3; }
1201
1202   // Methods for support type inquiry through isa, cast, and dyn_cast:
1203   static inline bool classof(const ShuffleVectorInst *) { return true; }
1204   static inline bool classof(const Instruction *I) {
1205     return I->getOpcode() == Instruction::ShuffleVector;
1206   }
1207   static inline bool classof(const Value *V) {
1208     return isa<Instruction>(V) && classof(cast<Instruction>(V));
1209   }
1210 };
1211
1212
1213 //===----------------------------------------------------------------------===//
1214 //                               PHINode Class
1215 //===----------------------------------------------------------------------===//
1216
1217 // PHINode - The PHINode class is used to represent the magical mystical PHI
1218 // node, that can not exist in nature, but can be synthesized in a computer
1219 // scientist's overactive imagination.
1220 //
1221 class PHINode : public Instruction {
1222   /// ReservedSpace - The number of operands actually allocated.  NumOperands is
1223   /// the number actually in use.
1224   unsigned ReservedSpace;
1225   PHINode(const PHINode &PN);
1226 public:
1227   explicit PHINode(const Type *Ty, const std::string &Name = "",
1228                    Instruction *InsertBefore = 0)
1229     : Instruction(Ty, Instruction::PHI, 0, 0, InsertBefore),
1230       ReservedSpace(0) {
1231     setName(Name);
1232   }
1233
1234   PHINode(const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd)
1235     : Instruction(Ty, Instruction::PHI, 0, 0, InsertAtEnd),
1236       ReservedSpace(0) {
1237     setName(Name);
1238   }
1239
1240   ~PHINode();
1241
1242   /// reserveOperandSpace - This method can be used to avoid repeated
1243   /// reallocation of PHI operand lists by reserving space for the correct
1244   /// number of operands before adding them.  Unlike normal vector reserves,
1245   /// this method can also be used to trim the operand space.
1246   void reserveOperandSpace(unsigned NumValues) {
1247     resizeOperands(NumValues*2);
1248   }
1249
1250   virtual PHINode *clone() const;
1251
1252   /// getNumIncomingValues - Return the number of incoming edges
1253   ///
1254   unsigned getNumIncomingValues() const { return getNumOperands()/2; }
1255
1256   /// getIncomingValue - Return incoming value number x
1257   ///
1258   Value *getIncomingValue(unsigned i) const {
1259     assert(i*2 < getNumOperands() && "Invalid value number!");
1260     return getOperand(i*2);
1261   }
1262   void setIncomingValue(unsigned i, Value *V) {
1263     assert(i*2 < getNumOperands() && "Invalid value number!");
1264     setOperand(i*2, V);
1265   }
1266   unsigned getOperandNumForIncomingValue(unsigned i) {
1267     return i*2;
1268   }
1269
1270   /// getIncomingBlock - Return incoming basic block number x
1271   ///
1272   BasicBlock *getIncomingBlock(unsigned i) const {
1273     return reinterpret_cast<BasicBlock*>(getOperand(i*2+1));
1274   }
1275   void setIncomingBlock(unsigned i, BasicBlock *BB) {
1276     setOperand(i*2+1, reinterpret_cast<Value*>(BB));
1277   }
1278   unsigned getOperandNumForIncomingBlock(unsigned i) {
1279     return i*2+1;
1280   }
1281
1282   /// addIncoming - Add an incoming value to the end of the PHI list
1283   ///
1284   void addIncoming(Value *V, BasicBlock *BB) {
1285     assert(getType() == V->getType() &&
1286            "All operands to PHI node must be the same type as the PHI node!");
1287     unsigned OpNo = NumOperands;
1288     if (OpNo+2 > ReservedSpace)
1289       resizeOperands(0);  // Get more space!
1290     // Initialize some new operands.
1291     NumOperands = OpNo+2;
1292     OperandList[OpNo].init(V, this);
1293     OperandList[OpNo+1].init(reinterpret_cast<Value*>(BB), this);
1294   }
1295
1296   /// removeIncomingValue - Remove an incoming value.  This is useful if a
1297   /// predecessor basic block is deleted.  The value removed is returned.
1298   ///
1299   /// If the last incoming value for a PHI node is removed (and DeletePHIIfEmpty
1300   /// is true), the PHI node is destroyed and any uses of it are replaced with
1301   /// dummy values.  The only time there should be zero incoming values to a PHI
1302   /// node is when the block is dead, so this strategy is sound.
1303   ///
1304   Value *removeIncomingValue(unsigned Idx, bool DeletePHIIfEmpty = true);
1305
1306   Value *removeIncomingValue(const BasicBlock *BB, bool DeletePHIIfEmpty =true){
1307     int Idx = getBasicBlockIndex(BB);
1308     assert(Idx >= 0 && "Invalid basic block argument to remove!");
1309     return removeIncomingValue(Idx, DeletePHIIfEmpty);
1310   }
1311
1312   /// getBasicBlockIndex - Return the first index of the specified basic
1313   /// block in the value list for this PHI.  Returns -1 if no instance.
1314   ///
1315   int getBasicBlockIndex(const BasicBlock *BB) const {
1316     Use *OL = OperandList;
1317     for (unsigned i = 0, e = getNumOperands(); i != e; i += 2)
1318       if (OL[i+1] == reinterpret_cast<const Value*>(BB)) return i/2;
1319     return -1;
1320   }
1321
1322   Value *getIncomingValueForBlock(const BasicBlock *BB) const {
1323     return getIncomingValue(getBasicBlockIndex(BB));
1324   }
1325
1326   /// hasConstantValue - If the specified PHI node always merges together the
1327   /// same value, return the value, otherwise return null.
1328   ///
1329   Value *hasConstantValue(bool AllowNonDominatingInstruction = false) const;
1330
1331   /// Methods for support type inquiry through isa, cast, and dyn_cast:
1332   static inline bool classof(const PHINode *) { return true; }
1333   static inline bool classof(const Instruction *I) {
1334     return I->getOpcode() == Instruction::PHI;
1335   }
1336   static inline bool classof(const Value *V) {
1337     return isa<Instruction>(V) && classof(cast<Instruction>(V));
1338   }
1339  private:
1340   void resizeOperands(unsigned NumOperands);
1341 };
1342
1343 //===----------------------------------------------------------------------===//
1344 //                               ReturnInst Class
1345 //===----------------------------------------------------------------------===//
1346
1347 //===---------------------------------------------------------------------------
1348 /// ReturnInst - Return a value (possibly void), from a function.  Execution
1349 /// does not continue in this function any longer.
1350 ///
1351 class ReturnInst : public TerminatorInst {
1352   Use RetVal;  // Return Value: null if 'void'.
1353   ReturnInst(const ReturnInst &RI);
1354   void init(Value *RetVal);
1355
1356 public:
1357   // ReturnInst constructors:
1358   // ReturnInst()                  - 'ret void' instruction
1359   // ReturnInst(    null)          - 'ret void' instruction
1360   // ReturnInst(Value* X)          - 'ret X'    instruction
1361   // ReturnInst(    null, Inst *)  - 'ret void' instruction, insert before I
1362   // ReturnInst(Value* X, Inst *I) - 'ret X'    instruction, insert before I
1363   // ReturnInst(    null, BB *B)   - 'ret void' instruction, insert @ end of BB
1364   // ReturnInst(Value* X, BB *B)   - 'ret X'    instruction, insert @ end of BB
1365   //
1366   // NOTE: If the Value* passed is of type void then the constructor behaves as
1367   // if it was passed NULL.
1368   explicit ReturnInst(Value *retVal = 0, Instruction *InsertBefore = 0);
1369   ReturnInst(Value *retVal, BasicBlock *InsertAtEnd);
1370   explicit ReturnInst(BasicBlock *InsertAtEnd);
1371
1372   virtual ReturnInst *clone() const;
1373
1374   // Transparently provide more efficient getOperand methods.
1375   Value *getOperand(unsigned i) const {
1376     assert(i < getNumOperands() && "getOperand() out of range!");
1377     return RetVal;
1378   }
1379   void setOperand(unsigned i, Value *Val) {
1380     assert(i < getNumOperands() && "setOperand() out of range!");
1381     RetVal = Val;
1382   }
1383
1384   Value *getReturnValue() const { return RetVal; }
1385
1386   unsigned getNumSuccessors() const { return 0; }
1387
1388   // Methods for support type inquiry through isa, cast, and dyn_cast:
1389   static inline bool classof(const ReturnInst *) { return true; }
1390   static inline bool classof(const Instruction *I) {
1391     return (I->getOpcode() == Instruction::Ret);
1392   }
1393   static inline bool classof(const Value *V) {
1394     return isa<Instruction>(V) && classof(cast<Instruction>(V));
1395   }
1396  private:
1397   virtual BasicBlock *getSuccessorV(unsigned idx) const;
1398   virtual unsigned getNumSuccessorsV() const;
1399   virtual void setSuccessorV(unsigned idx, BasicBlock *B);
1400 };
1401
1402 //===----------------------------------------------------------------------===//
1403 //                               BranchInst Class
1404 //===----------------------------------------------------------------------===//
1405
1406 //===---------------------------------------------------------------------------
1407 /// BranchInst - Conditional or Unconditional Branch instruction.
1408 ///
1409 class BranchInst : public TerminatorInst {
1410   /// Ops list - Branches are strange.  The operands are ordered:
1411   ///  TrueDest, FalseDest, Cond.  This makes some accessors faster because
1412   /// they don't have to check for cond/uncond branchness.
1413   Use Ops[3];
1414   BranchInst(const BranchInst &BI);
1415   void AssertOK();
1416 public:
1417   // BranchInst constructors (where {B, T, F} are blocks, and C is a condition):
1418   // BranchInst(BB *B)                           - 'br B'
1419   // BranchInst(BB* T, BB *F, Value *C)          - 'br C, T, F'
1420   // BranchInst(BB* B, Inst *I)                  - 'br B'        insert before I
1421   // BranchInst(BB* T, BB *F, Value *C, Inst *I) - 'br C, T, F', insert before I
1422   // BranchInst(BB* B, BB *I)                    - 'br B'        insert at end
1423   // BranchInst(BB* T, BB *F, Value *C, BB *I)   - 'br C, T, F', insert at end
1424   explicit BranchInst(BasicBlock *IfTrue, Instruction *InsertBefore = 0);
1425   BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond,
1426              Instruction *InsertBefore = 0);
1427   BranchInst(BasicBlock *IfTrue, BasicBlock *InsertAtEnd);
1428   BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond,
1429              BasicBlock *InsertAtEnd);
1430
1431   /// Transparently provide more efficient getOperand methods.
1432   Value *getOperand(unsigned i) const {
1433     assert(i < getNumOperands() && "getOperand() out of range!");
1434     return Ops[i];
1435   }
1436   void setOperand(unsigned i, Value *Val) {
1437     assert(i < getNumOperands() && "setOperand() out of range!");
1438     Ops[i] = Val;
1439   }
1440
1441   virtual BranchInst *clone() const;
1442
1443   inline bool isUnconditional() const { return getNumOperands() == 1; }
1444   inline bool isConditional()   const { return getNumOperands() == 3; }
1445
1446   inline Value *getCondition() const {
1447     assert(isConditional() && "Cannot get condition of an uncond branch!");
1448     return getOperand(2);
1449   }
1450
1451   void setCondition(Value *V) {
1452     assert(isConditional() && "Cannot set condition of unconditional branch!");
1453     setOperand(2, V);
1454   }
1455
1456   // setUnconditionalDest - Change the current branch to an unconditional branch
1457   // targeting the specified block.
1458   // FIXME: Eliminate this ugly method.
1459   void setUnconditionalDest(BasicBlock *Dest) {
1460     if (isConditional()) {  // Convert this to an uncond branch.
1461       NumOperands = 1;
1462       Ops[1].set(0);
1463       Ops[2].set(0);
1464     }
1465     setOperand(0, reinterpret_cast<Value*>(Dest));
1466   }
1467
1468   unsigned getNumSuccessors() const { return 1+isConditional(); }
1469
1470   BasicBlock *getSuccessor(unsigned i) const {
1471     assert(i < getNumSuccessors() && "Successor # out of range for Branch!");
1472     return cast<BasicBlock>(getOperand(i));
1473   }
1474
1475   void setSuccessor(unsigned idx, BasicBlock *NewSucc) {
1476     assert(idx < getNumSuccessors() && "Successor # out of range for Branch!");
1477     setOperand(idx, reinterpret_cast<Value*>(NewSucc));
1478   }
1479
1480   // Methods for support type inquiry through isa, cast, and dyn_cast:
1481   static inline bool classof(const BranchInst *) { return true; }
1482   static inline bool classof(const Instruction *I) {
1483     return (I->getOpcode() == Instruction::Br);
1484   }
1485   static inline bool classof(const Value *V) {
1486     return isa<Instruction>(V) && classof(cast<Instruction>(V));
1487   }
1488 private:
1489   virtual BasicBlock *getSuccessorV(unsigned idx) const;
1490   virtual unsigned getNumSuccessorsV() const;
1491   virtual void setSuccessorV(unsigned idx, BasicBlock *B);
1492 };
1493
1494 //===----------------------------------------------------------------------===//
1495 //                               SwitchInst Class
1496 //===----------------------------------------------------------------------===//
1497
1498 //===---------------------------------------------------------------------------
1499 /// SwitchInst - Multiway switch
1500 ///
1501 class SwitchInst : public TerminatorInst {
1502   unsigned ReservedSpace;
1503   // Operand[0]    = Value to switch on
1504   // Operand[1]    = Default basic block destination
1505   // Operand[2n  ] = Value to match
1506   // Operand[2n+1] = BasicBlock to go to on match
1507   SwitchInst(const SwitchInst &RI);
1508   void init(Value *Value, BasicBlock *Default, unsigned NumCases);
1509   void resizeOperands(unsigned No);
1510 public:
1511   /// SwitchInst ctor - Create a new switch instruction, specifying a value to
1512   /// switch on and a default destination.  The number of additional cases can
1513   /// be specified here to make memory allocation more efficient.  This
1514   /// constructor can also autoinsert before another instruction.
1515   SwitchInst(Value *Value, BasicBlock *Default, unsigned NumCases,
1516              Instruction *InsertBefore = 0);
1517   
1518   /// SwitchInst ctor - Create a new switch instruction, specifying a value to
1519   /// switch on and a default destination.  The number of additional cases can
1520   /// be specified here to make memory allocation more efficient.  This
1521   /// constructor also autoinserts at the end of the specified BasicBlock.
1522   SwitchInst(Value *Value, BasicBlock *Default, unsigned NumCases,
1523              BasicBlock *InsertAtEnd);
1524   ~SwitchInst();
1525
1526
1527   // Accessor Methods for Switch stmt
1528   inline Value *getCondition() const { return getOperand(0); }
1529   void setCondition(Value *V) { setOperand(0, V); }
1530
1531   inline BasicBlock *getDefaultDest() const {
1532     return cast<BasicBlock>(getOperand(1));
1533   }
1534
1535   /// getNumCases - return the number of 'cases' in this switch instruction.
1536   /// Note that case #0 is always the default case.
1537   unsigned getNumCases() const {
1538     return getNumOperands()/2;
1539   }
1540
1541   /// getCaseValue - Return the specified case value.  Note that case #0, the
1542   /// default destination, does not have a case value.
1543   ConstantInt *getCaseValue(unsigned i) {
1544     assert(i && i < getNumCases() && "Illegal case value to get!");
1545     return getSuccessorValue(i);
1546   }
1547
1548   /// getCaseValue - Return the specified case value.  Note that case #0, the
1549   /// default destination, does not have a case value.
1550   const ConstantInt *getCaseValue(unsigned i) const {
1551     assert(i && i < getNumCases() && "Illegal case value to get!");
1552     return getSuccessorValue(i);
1553   }
1554
1555   /// findCaseValue - Search all of the case values for the specified constant.
1556   /// If it is explicitly handled, return the case number of it, otherwise
1557   /// return 0 to indicate that it is handled by the default handler.
1558   unsigned findCaseValue(const ConstantInt *C) const {
1559     for (unsigned i = 1, e = getNumCases(); i != e; ++i)
1560       if (getCaseValue(i) == C)
1561         return i;
1562     return 0;
1563   }
1564
1565   /// findCaseDest - Finds the unique case value for a given successor. Returns
1566   /// null if the successor is not found, not unique, or is the default case.
1567   ConstantInt *findCaseDest(BasicBlock *BB) {
1568     if (BB == getDefaultDest()) return NULL;
1569
1570     ConstantInt *CI = NULL;
1571     for (unsigned i = 1, e = getNumCases(); i != e; ++i) {
1572       if (getSuccessor(i) == BB) {
1573         if (CI) return NULL;   // Multiple cases lead to BB.
1574         else CI = getCaseValue(i);
1575       }
1576     }
1577     return CI;
1578   }
1579
1580   /// addCase - Add an entry to the switch instruction...
1581   ///
1582   void addCase(ConstantInt *OnVal, BasicBlock *Dest);
1583
1584   /// removeCase - This method removes the specified successor from the switch
1585   /// instruction.  Note that this cannot be used to remove the default
1586   /// destination (successor #0).
1587   ///
1588   void removeCase(unsigned idx);
1589
1590   virtual SwitchInst *clone() const;
1591
1592   unsigned getNumSuccessors() const { return getNumOperands()/2; }
1593   BasicBlock *getSuccessor(unsigned idx) const {
1594     assert(idx < getNumSuccessors() &&"Successor idx out of range for switch!");
1595     return cast<BasicBlock>(getOperand(idx*2+1));
1596   }
1597   void setSuccessor(unsigned idx, BasicBlock *NewSucc) {
1598     assert(idx < getNumSuccessors() && "Successor # out of range for switch!");
1599     setOperand(idx*2+1, reinterpret_cast<Value*>(NewSucc));
1600   }
1601
1602   // getSuccessorValue - Return the value associated with the specified
1603   // successor.
1604   inline ConstantInt *getSuccessorValue(unsigned idx) const {
1605     assert(idx < getNumSuccessors() && "Successor # out of range!");
1606     return reinterpret_cast<ConstantInt*>(getOperand(idx*2));
1607   }
1608
1609   // Methods for support type inquiry through isa, cast, and dyn_cast:
1610   static inline bool classof(const SwitchInst *) { return true; }
1611   static inline bool classof(const Instruction *I) {
1612     return I->getOpcode() == Instruction::Switch;
1613   }
1614   static inline bool classof(const Value *V) {
1615     return isa<Instruction>(V) && classof(cast<Instruction>(V));
1616   }
1617 private:
1618   virtual BasicBlock *getSuccessorV(unsigned idx) const;
1619   virtual unsigned getNumSuccessorsV() const;
1620   virtual void setSuccessorV(unsigned idx, BasicBlock *B);
1621 };
1622
1623 //===----------------------------------------------------------------------===//
1624 //                               InvokeInst Class
1625 //===----------------------------------------------------------------------===//
1626
1627 //===---------------------------------------------------------------------------
1628
1629 /// InvokeInst - Invoke instruction.  The SubclassData field is used to hold the
1630 /// calling convention of the call.
1631 ///
1632 class InvokeInst : public TerminatorInst {
1633   const ParamAttrsList *ParamAttrs;
1634   InvokeInst(const InvokeInst &BI);
1635   void init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
1636             Value* const *Args, unsigned NumArgs);
1637
1638   template<typename InputIterator>
1639   void init(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException,
1640             InputIterator ArgBegin, InputIterator ArgEnd,
1641             const std::string &Name,
1642             // This argument ensures that we have an iterator we can
1643             // do arithmetic on in constant time
1644             std::random_access_iterator_tag) {
1645     unsigned NumArgs = (unsigned)std::distance(ArgBegin, ArgEnd);
1646     
1647     // This requires that the iterator points to contiguous memory.
1648     init(Func, IfNormal, IfException, NumArgs ? &*ArgBegin : 0, NumArgs);
1649     setName(Name);
1650   }
1651
1652 public:
1653   /// Construct an InvokeInst given a range of arguments.
1654   /// InputIterator must be a random-access iterator pointing to
1655   /// contiguous storage (e.g. a std::vector<>::iterator).  Checks are
1656   /// made for random-accessness but not for contiguous storage as
1657   /// that would incur runtime overhead.
1658   ///
1659   /// @brief Construct an InvokeInst from a range of arguments
1660   template<typename InputIterator>
1661   InvokeInst(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException,
1662              InputIterator ArgBegin, InputIterator ArgEnd,
1663              const std::string &Name = "", Instruction *InsertBefore = 0)
1664       : TerminatorInst(cast<FunctionType>(cast<PointerType>(Func->getType())
1665                                           ->getElementType())->getReturnType(),
1666                        Instruction::Invoke, 0, 0, InsertBefore) {
1667     init(Func, IfNormal, IfException, ArgBegin, ArgEnd, Name,
1668          typename std::iterator_traits<InputIterator>::iterator_category());
1669   }
1670
1671   /// Construct an InvokeInst given a range of arguments.
1672   /// InputIterator must be a random-access iterator pointing to
1673   /// contiguous storage (e.g. a std::vector<>::iterator).  Checks are
1674   /// made for random-accessness but not for contiguous storage as
1675   /// that would incur runtime overhead.
1676   ///
1677   /// @brief Construct an InvokeInst from a range of arguments
1678   template<typename InputIterator>
1679   InvokeInst(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException,
1680              InputIterator ArgBegin, InputIterator ArgEnd,
1681              const std::string &Name, BasicBlock *InsertAtEnd)
1682       : TerminatorInst(cast<FunctionType>(cast<PointerType>(Func->getType())
1683                                           ->getElementType())->getReturnType(),
1684                        Instruction::Invoke, 0, 0, InsertAtEnd) {
1685     init(Func, IfNormal, IfException, ArgBegin, ArgEnd, Name,
1686          typename std::iterator_traits<InputIterator>::iterator_category());
1687   }
1688
1689   ~InvokeInst();
1690
1691   virtual InvokeInst *clone() const;
1692
1693   /// getCallingConv/setCallingConv - Get or set the calling convention of this
1694   /// function call.
1695   unsigned getCallingConv() const { return SubclassData; }
1696   void setCallingConv(unsigned CC) {
1697     SubclassData = CC;
1698   }
1699
1700   /// Obtains a pointer to the ParamAttrsList object which holds the
1701   /// parameter attributes information, if any.
1702   /// @returns 0 if no attributes have been set.
1703   /// @brief Get the parameter attributes.
1704   const ParamAttrsList *getParamAttrs() const { return ParamAttrs; }
1705
1706   /// Sets the parameter attributes for this InvokeInst. To construct a 
1707   /// ParamAttrsList, see ParameterAttributes.h
1708   /// @brief Set the parameter attributes.
1709   void setParamAttrs(const ParamAttrsList *attrs);
1710
1711   /// @brief Determine whether the call or the callee has the given attribute.
1712   bool paramHasAttr(uint16_t i, ParameterAttributes attr) const;
1713
1714   /// @brief Determine if the call returns a structure.
1715   bool isStructReturn() const {
1716     // Be friendly and also check the callee.
1717     return paramHasAttr(1, ParamAttr::StructRet);
1718   }
1719
1720   /// getCalledFunction - Return the function called, or null if this is an
1721   /// indirect function invocation.
1722   ///
1723   Function *getCalledFunction() const {
1724     return dyn_cast<Function>(getOperand(0));
1725   }
1726
1727   // getCalledValue - Get a pointer to a function that is invoked by this inst.
1728   inline Value *getCalledValue() const { return getOperand(0); }
1729
1730   // get*Dest - Return the destination basic blocks...
1731   BasicBlock *getNormalDest() const {
1732     return cast<BasicBlock>(getOperand(1));
1733   }
1734   BasicBlock *getUnwindDest() const {
1735     return cast<BasicBlock>(getOperand(2));
1736   }
1737   void setNormalDest(BasicBlock *B) {
1738     setOperand(1, reinterpret_cast<Value*>(B));
1739   }
1740
1741   void setUnwindDest(BasicBlock *B) {
1742     setOperand(2, reinterpret_cast<Value*>(B));
1743   }
1744
1745   inline BasicBlock *getSuccessor(unsigned i) const {
1746     assert(i < 2 && "Successor # out of range for invoke!");
1747     return i == 0 ? getNormalDest() : getUnwindDest();
1748   }
1749
1750   void setSuccessor(unsigned idx, BasicBlock *NewSucc) {
1751     assert(idx < 2 && "Successor # out of range for invoke!");
1752     setOperand(idx+1, reinterpret_cast<Value*>(NewSucc));
1753   }
1754
1755   unsigned getNumSuccessors() const { return 2; }
1756
1757   // Methods for support type inquiry through isa, cast, and dyn_cast:
1758   static inline bool classof(const InvokeInst *) { return true; }
1759   static inline bool classof(const Instruction *I) {
1760     return (I->getOpcode() == Instruction::Invoke);
1761   }
1762   static inline bool classof(const Value *V) {
1763     return isa<Instruction>(V) && classof(cast<Instruction>(V));
1764   }
1765 private:
1766   virtual BasicBlock *getSuccessorV(unsigned idx) const;
1767   virtual unsigned getNumSuccessorsV() const;
1768   virtual void setSuccessorV(unsigned idx, BasicBlock *B);
1769 };
1770
1771
1772 //===----------------------------------------------------------------------===//
1773 //                              UnwindInst Class
1774 //===----------------------------------------------------------------------===//
1775
1776 //===---------------------------------------------------------------------------
1777 /// UnwindInst - Immediately exit the current function, unwinding the stack
1778 /// until an invoke instruction is found.
1779 ///
1780 class UnwindInst : public TerminatorInst {
1781 public:
1782   explicit UnwindInst(Instruction *InsertBefore = 0);
1783   explicit UnwindInst(BasicBlock *InsertAtEnd);
1784
1785   virtual UnwindInst *clone() const;
1786
1787   unsigned getNumSuccessors() const { return 0; }
1788
1789   // Methods for support type inquiry through isa, cast, and dyn_cast:
1790   static inline bool classof(const UnwindInst *) { return true; }
1791   static inline bool classof(const Instruction *I) {
1792     return I->getOpcode() == Instruction::Unwind;
1793   }
1794   static inline bool classof(const Value *V) {
1795     return isa<Instruction>(V) && classof(cast<Instruction>(V));
1796   }
1797 private:
1798   virtual BasicBlock *getSuccessorV(unsigned idx) const;
1799   virtual unsigned getNumSuccessorsV() const;
1800   virtual void setSuccessorV(unsigned idx, BasicBlock *B);
1801 };
1802
1803 //===----------------------------------------------------------------------===//
1804 //                           UnreachableInst Class
1805 //===----------------------------------------------------------------------===//
1806
1807 //===---------------------------------------------------------------------------
1808 /// UnreachableInst - This function has undefined behavior.  In particular, the
1809 /// presence of this instruction indicates some higher level knowledge that the
1810 /// end of the block cannot be reached.
1811 ///
1812 class UnreachableInst : public TerminatorInst {
1813 public:
1814   explicit UnreachableInst(Instruction *InsertBefore = 0);
1815   explicit UnreachableInst(BasicBlock *InsertAtEnd);
1816
1817   virtual UnreachableInst *clone() const;
1818
1819   unsigned getNumSuccessors() const { return 0; }
1820
1821   // Methods for support type inquiry through isa, cast, and dyn_cast:
1822   static inline bool classof(const UnreachableInst *) { return true; }
1823   static inline bool classof(const Instruction *I) {
1824     return I->getOpcode() == Instruction::Unreachable;
1825   }
1826   static inline bool classof(const Value *V) {
1827     return isa<Instruction>(V) && classof(cast<Instruction>(V));
1828   }
1829 private:
1830   virtual BasicBlock *getSuccessorV(unsigned idx) const;
1831   virtual unsigned getNumSuccessorsV() const;
1832   virtual void setSuccessorV(unsigned idx, BasicBlock *B);
1833 };
1834
1835 //===----------------------------------------------------------------------===//
1836 //                                 TruncInst Class
1837 //===----------------------------------------------------------------------===//
1838
1839 /// @brief This class represents a truncation of integer types.
1840 class TruncInst : public CastInst {
1841   /// Private copy constructor
1842   TruncInst(const TruncInst &CI)
1843     : CastInst(CI.getType(), Trunc, CI.getOperand(0)) {
1844   }
1845 public:
1846   /// @brief Constructor with insert-before-instruction semantics
1847   TruncInst(
1848     Value *S,                     ///< The value to be truncated
1849     const Type *Ty,               ///< The (smaller) type to truncate to
1850     const std::string &Name = "", ///< A name for the new instruction
1851     Instruction *InsertBefore = 0 ///< Where to insert the new instruction
1852   );
1853
1854   /// @brief Constructor with insert-at-end-of-block semantics
1855   TruncInst(
1856     Value *S,                     ///< The value to be truncated
1857     const Type *Ty,               ///< The (smaller) type to truncate to
1858     const std::string &Name,      ///< A name for the new instruction
1859     BasicBlock *InsertAtEnd       ///< The block to insert the instruction into
1860   );
1861
1862   /// @brief Clone an identical TruncInst
1863   virtual CastInst *clone() const;
1864
1865   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
1866   static inline bool classof(const TruncInst *) { return true; }
1867   static inline bool classof(const Instruction *I) {
1868     return I->getOpcode() == Trunc;
1869   }
1870   static inline bool classof(const Value *V) {
1871     return isa<Instruction>(V) && classof(cast<Instruction>(V));
1872   }
1873 };
1874
1875 //===----------------------------------------------------------------------===//
1876 //                                 ZExtInst Class
1877 //===----------------------------------------------------------------------===//
1878
1879 /// @brief This class represents zero extension of integer types.
1880 class ZExtInst : public CastInst {
1881   /// @brief Private copy constructor
1882   ZExtInst(const ZExtInst &CI)
1883     : CastInst(CI.getType(), ZExt, CI.getOperand(0)) {
1884   }
1885 public:
1886   /// @brief Constructor with insert-before-instruction semantics
1887   ZExtInst(
1888     Value *S,                     ///< The value to be zero extended
1889     const Type *Ty,               ///< The type to zero extend to
1890     const std::string &Name = "", ///< A name for the new instruction
1891     Instruction *InsertBefore = 0 ///< Where to insert the new instruction
1892   );
1893
1894   /// @brief Constructor with insert-at-end semantics.
1895   ZExtInst(
1896     Value *S,                     ///< The value to be zero extended
1897     const Type *Ty,               ///< The type to zero extend to
1898     const std::string &Name,      ///< A name for the new instruction
1899     BasicBlock *InsertAtEnd       ///< The block to insert the instruction into
1900   );
1901
1902   /// @brief Clone an identical ZExtInst
1903   virtual CastInst *clone() const;
1904
1905   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
1906   static inline bool classof(const ZExtInst *) { return true; }
1907   static inline bool classof(const Instruction *I) {
1908     return I->getOpcode() == ZExt;
1909   }
1910   static inline bool classof(const Value *V) {
1911     return isa<Instruction>(V) && classof(cast<Instruction>(V));
1912   }
1913 };
1914
1915 //===----------------------------------------------------------------------===//
1916 //                                 SExtInst Class
1917 //===----------------------------------------------------------------------===//
1918
1919 /// @brief This class represents a sign extension of integer types.
1920 class SExtInst : public CastInst {
1921   /// @brief Private copy constructor
1922   SExtInst(const SExtInst &CI)
1923     : CastInst(CI.getType(), SExt, CI.getOperand(0)) {
1924   }
1925 public:
1926   /// @brief Constructor with insert-before-instruction semantics
1927   SExtInst(
1928     Value *S,                     ///< The value to be sign extended
1929     const Type *Ty,               ///< The type to sign extend to
1930     const std::string &Name = "", ///< A name for the new instruction
1931     Instruction *InsertBefore = 0 ///< Where to insert the new instruction
1932   );
1933
1934   /// @brief Constructor with insert-at-end-of-block semantics
1935   SExtInst(
1936     Value *S,                     ///< The value to be sign extended
1937     const Type *Ty,               ///< The type to sign extend to
1938     const std::string &Name,      ///< A name for the new instruction
1939     BasicBlock *InsertAtEnd       ///< The block to insert the instruction into
1940   );
1941
1942   /// @brief Clone an identical SExtInst
1943   virtual CastInst *clone() const;
1944
1945   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
1946   static inline bool classof(const SExtInst *) { return true; }
1947   static inline bool classof(const Instruction *I) {
1948     return I->getOpcode() == SExt;
1949   }
1950   static inline bool classof(const Value *V) {
1951     return isa<Instruction>(V) && classof(cast<Instruction>(V));
1952   }
1953 };
1954
1955 //===----------------------------------------------------------------------===//
1956 //                                 FPTruncInst Class
1957 //===----------------------------------------------------------------------===//
1958
1959 /// @brief This class represents a truncation of floating point types.
1960 class FPTruncInst : public CastInst {
1961   FPTruncInst(const FPTruncInst &CI)
1962     : CastInst(CI.getType(), FPTrunc, CI.getOperand(0)) {
1963   }
1964 public:
1965   /// @brief Constructor with insert-before-instruction semantics
1966   FPTruncInst(
1967     Value *S,                     ///< The value to be truncated
1968     const Type *Ty,               ///< The type to truncate to
1969     const std::string &Name = "", ///< A name for the new instruction
1970     Instruction *InsertBefore = 0 ///< Where to insert the new instruction
1971   );
1972
1973   /// @brief Constructor with insert-before-instruction semantics
1974   FPTruncInst(
1975     Value *S,                     ///< The value to be truncated
1976     const Type *Ty,               ///< The type to truncate to
1977     const std::string &Name,      ///< A name for the new instruction
1978     BasicBlock *InsertAtEnd       ///< The block to insert the instruction into
1979   );
1980
1981   /// @brief Clone an identical FPTruncInst
1982   virtual CastInst *clone() const;
1983
1984   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
1985   static inline bool classof(const FPTruncInst *) { return true; }
1986   static inline bool classof(const Instruction *I) {
1987     return I->getOpcode() == FPTrunc;
1988   }
1989   static inline bool classof(const Value *V) {
1990     return isa<Instruction>(V) && classof(cast<Instruction>(V));
1991   }
1992 };
1993
1994 //===----------------------------------------------------------------------===//
1995 //                                 FPExtInst Class
1996 //===----------------------------------------------------------------------===//
1997
1998 /// @brief This class represents an extension of floating point types.
1999 class FPExtInst : public CastInst {
2000   FPExtInst(const FPExtInst &CI)
2001     : CastInst(CI.getType(), FPExt, CI.getOperand(0)) {
2002   }
2003 public:
2004   /// @brief Constructor with insert-before-instruction semantics
2005   FPExtInst(
2006     Value *S,                     ///< The value to be extended
2007     const Type *Ty,               ///< The type to extend to
2008     const std::string &Name = "", ///< A name for the new instruction
2009     Instruction *InsertBefore = 0 ///< Where to insert the new instruction
2010   );
2011
2012   /// @brief Constructor with insert-at-end-of-block semantics
2013   FPExtInst(
2014     Value *S,                     ///< The value to be extended
2015     const Type *Ty,               ///< The type to extend to
2016     const std::string &Name,      ///< A name for the new instruction
2017     BasicBlock *InsertAtEnd       ///< The block to insert the instruction into
2018   );
2019
2020   /// @brief Clone an identical FPExtInst
2021   virtual CastInst *clone() const;
2022
2023   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
2024   static inline bool classof(const FPExtInst *) { return true; }
2025   static inline bool classof(const Instruction *I) {
2026     return I->getOpcode() == FPExt;
2027   }
2028   static inline bool classof(const Value *V) {
2029     return isa<Instruction>(V) && classof(cast<Instruction>(V));
2030   }
2031 };
2032
2033 //===----------------------------------------------------------------------===//
2034 //                                 UIToFPInst Class
2035 //===----------------------------------------------------------------------===//
2036
2037 /// @brief This class represents a cast unsigned integer to floating point.
2038 class UIToFPInst : public CastInst {
2039   UIToFPInst(const UIToFPInst &CI)
2040     : CastInst(CI.getType(), UIToFP, CI.getOperand(0)) {
2041   }
2042 public:
2043   /// @brief Constructor with insert-before-instruction semantics
2044   UIToFPInst(
2045     Value *S,                     ///< The value to be converted
2046     const Type *Ty,               ///< The type to convert to
2047     const std::string &Name = "", ///< A name for the new instruction
2048     Instruction *InsertBefore = 0 ///< Where to insert the new instruction
2049   );
2050
2051   /// @brief Constructor with insert-at-end-of-block semantics
2052   UIToFPInst(
2053     Value *S,                     ///< The value to be converted
2054     const Type *Ty,               ///< The type to convert to
2055     const std::string &Name,      ///< A name for the new instruction
2056     BasicBlock *InsertAtEnd       ///< The block to insert the instruction into
2057   );
2058
2059   /// @brief Clone an identical UIToFPInst
2060   virtual CastInst *clone() const;
2061
2062   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
2063   static inline bool classof(const UIToFPInst *) { return true; }
2064   static inline bool classof(const Instruction *I) {
2065     return I->getOpcode() == UIToFP;
2066   }
2067   static inline bool classof(const Value *V) {
2068     return isa<Instruction>(V) && classof(cast<Instruction>(V));
2069   }
2070 };
2071
2072 //===----------------------------------------------------------------------===//
2073 //                                 SIToFPInst Class
2074 //===----------------------------------------------------------------------===//
2075
2076 /// @brief This class represents a cast from signed integer to floating point.
2077 class SIToFPInst : public CastInst {
2078   SIToFPInst(const SIToFPInst &CI)
2079     : CastInst(CI.getType(), SIToFP, CI.getOperand(0)) {
2080   }
2081 public:
2082   /// @brief Constructor with insert-before-instruction semantics
2083   SIToFPInst(
2084     Value *S,                     ///< The value to be converted
2085     const Type *Ty,               ///< The type to convert to
2086     const std::string &Name = "", ///< A name for the new instruction
2087     Instruction *InsertBefore = 0 ///< Where to insert the new instruction
2088   );
2089
2090   /// @brief Constructor with insert-at-end-of-block semantics
2091   SIToFPInst(
2092     Value *S,                     ///< The value to be converted
2093     const Type *Ty,               ///< The type to convert to
2094     const std::string &Name,      ///< A name for the new instruction
2095     BasicBlock *InsertAtEnd       ///< The block to insert the instruction into
2096   );
2097
2098   /// @brief Clone an identical SIToFPInst
2099   virtual CastInst *clone() const;
2100
2101   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
2102   static inline bool classof(const SIToFPInst *) { return true; }
2103   static inline bool classof(const Instruction *I) {
2104     return I->getOpcode() == SIToFP;
2105   }
2106   static inline bool classof(const Value *V) {
2107     return isa<Instruction>(V) && classof(cast<Instruction>(V));
2108   }
2109 };
2110
2111 //===----------------------------------------------------------------------===//
2112 //                                 FPToUIInst Class
2113 //===----------------------------------------------------------------------===//
2114
2115 /// @brief This class represents a cast from floating point to unsigned integer
2116 class FPToUIInst  : public CastInst {
2117   FPToUIInst(const FPToUIInst &CI)
2118     : CastInst(CI.getType(), FPToUI, CI.getOperand(0)) {
2119   }
2120 public:
2121   /// @brief Constructor with insert-before-instruction semantics
2122   FPToUIInst(
2123     Value *S,                     ///< The value to be converted
2124     const Type *Ty,               ///< The type to convert to
2125     const std::string &Name = "", ///< A name for the new instruction
2126     Instruction *InsertBefore = 0 ///< Where to insert the new instruction
2127   );
2128
2129   /// @brief Constructor with insert-at-end-of-block semantics
2130   FPToUIInst(
2131     Value *S,                     ///< The value to be converted
2132     const Type *Ty,               ///< The type to convert to
2133     const std::string &Name,      ///< A name for the new instruction
2134     BasicBlock *InsertAtEnd       ///< Where to insert the new instruction
2135   );
2136
2137   /// @brief Clone an identical FPToUIInst
2138   virtual CastInst *clone() const;
2139
2140   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
2141   static inline bool classof(const FPToUIInst *) { return true; }
2142   static inline bool classof(const Instruction *I) {
2143     return I->getOpcode() == FPToUI;
2144   }
2145   static inline bool classof(const Value *V) {
2146     return isa<Instruction>(V) && classof(cast<Instruction>(V));
2147   }
2148 };
2149
2150 //===----------------------------------------------------------------------===//
2151 //                                 FPToSIInst Class
2152 //===----------------------------------------------------------------------===//
2153
2154 /// @brief This class represents a cast from floating point to signed integer.
2155 class FPToSIInst  : public CastInst {
2156   FPToSIInst(const FPToSIInst &CI)
2157     : CastInst(CI.getType(), FPToSI, CI.getOperand(0)) {
2158   }
2159 public:
2160   /// @brief Constructor with insert-before-instruction semantics
2161   FPToSIInst(
2162     Value *S,                     ///< The value to be converted
2163     const Type *Ty,               ///< The type to convert to
2164     const std::string &Name = "", ///< A name for the new instruction
2165     Instruction *InsertBefore = 0 ///< Where to insert the new instruction
2166   );
2167
2168   /// @brief Constructor with insert-at-end-of-block semantics
2169   FPToSIInst(
2170     Value *S,                     ///< The value to be converted
2171     const Type *Ty,               ///< The type to convert to
2172     const std::string &Name,      ///< A name for the new instruction
2173     BasicBlock *InsertAtEnd       ///< The block to insert the instruction into
2174   );
2175
2176   /// @brief Clone an identical FPToSIInst
2177   virtual CastInst *clone() const;
2178
2179   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
2180   static inline bool classof(const FPToSIInst *) { return true; }
2181   static inline bool classof(const Instruction *I) {
2182     return I->getOpcode() == FPToSI;
2183   }
2184   static inline bool classof(const Value *V) {
2185     return isa<Instruction>(V) && classof(cast<Instruction>(V));
2186   }
2187 };
2188
2189 //===----------------------------------------------------------------------===//
2190 //                                 IntToPtrInst Class
2191 //===----------------------------------------------------------------------===//
2192
2193 /// @brief This class represents a cast from an integer to a pointer.
2194 class IntToPtrInst : public CastInst {
2195   IntToPtrInst(const IntToPtrInst &CI)
2196     : CastInst(CI.getType(), IntToPtr, CI.getOperand(0)) {
2197   }
2198 public:
2199   /// @brief Constructor with insert-before-instruction semantics
2200   IntToPtrInst(
2201     Value *S,                     ///< The value to be converted
2202     const Type *Ty,               ///< The type to convert to
2203     const std::string &Name = "", ///< A name for the new instruction
2204     Instruction *InsertBefore = 0 ///< Where to insert the new instruction
2205   );
2206
2207   /// @brief Constructor with insert-at-end-of-block semantics
2208   IntToPtrInst(
2209     Value *S,                     ///< The value to be converted
2210     const Type *Ty,               ///< The type to convert to
2211     const std::string &Name,      ///< A name for the new instruction
2212     BasicBlock *InsertAtEnd       ///< The block to insert the instruction into
2213   );
2214
2215   /// @brief Clone an identical IntToPtrInst
2216   virtual CastInst *clone() const;
2217
2218   // Methods for support type inquiry through isa, cast, and dyn_cast:
2219   static inline bool classof(const IntToPtrInst *) { return true; }
2220   static inline bool classof(const Instruction *I) {
2221     return I->getOpcode() == IntToPtr;
2222   }
2223   static inline bool classof(const Value *V) {
2224     return isa<Instruction>(V) && classof(cast<Instruction>(V));
2225   }
2226 };
2227
2228 //===----------------------------------------------------------------------===//
2229 //                                 PtrToIntInst Class
2230 //===----------------------------------------------------------------------===//
2231
2232 /// @brief This class represents a cast from a pointer to an integer
2233 class PtrToIntInst : public CastInst {
2234   PtrToIntInst(const PtrToIntInst &CI)
2235     : CastInst(CI.getType(), PtrToInt, CI.getOperand(0)) {
2236   }
2237 public:
2238   /// @brief Constructor with insert-before-instruction semantics
2239   PtrToIntInst(
2240     Value *S,                     ///< The value to be converted
2241     const Type *Ty,               ///< The type to convert to
2242     const std::string &Name = "", ///< A name for the new instruction
2243     Instruction *InsertBefore = 0 ///< Where to insert the new instruction
2244   );
2245
2246   /// @brief Constructor with insert-at-end-of-block semantics
2247   PtrToIntInst(
2248     Value *S,                     ///< The value to be converted
2249     const Type *Ty,               ///< The type to convert to
2250     const std::string &Name,      ///< A name for the new instruction
2251     BasicBlock *InsertAtEnd       ///< The block to insert the instruction into
2252   );
2253
2254   /// @brief Clone an identical PtrToIntInst
2255   virtual CastInst *clone() const;
2256
2257   // Methods for support type inquiry through isa, cast, and dyn_cast:
2258   static inline bool classof(const PtrToIntInst *) { return true; }
2259   static inline bool classof(const Instruction *I) {
2260     return I->getOpcode() == PtrToInt;
2261   }
2262   static inline bool classof(const Value *V) {
2263     return isa<Instruction>(V) && classof(cast<Instruction>(V));
2264   }
2265 };
2266
2267 //===----------------------------------------------------------------------===//
2268 //                             BitCastInst Class
2269 //===----------------------------------------------------------------------===//
2270
2271 /// @brief This class represents a no-op cast from one type to another.
2272 class BitCastInst : public CastInst {
2273   BitCastInst(const BitCastInst &CI)
2274     : CastInst(CI.getType(), BitCast, CI.getOperand(0)) {
2275   }
2276 public:
2277   /// @brief Constructor with insert-before-instruction semantics
2278   BitCastInst(
2279     Value *S,                     ///< The value to be casted
2280     const Type *Ty,               ///< The type to casted to
2281     const std::string &Name = "", ///< A name for the new instruction
2282     Instruction *InsertBefore = 0 ///< Where to insert the new instruction
2283   );
2284
2285   /// @brief Constructor with insert-at-end-of-block semantics
2286   BitCastInst(
2287     Value *S,                     ///< The value to be casted
2288     const Type *Ty,               ///< The type to casted to
2289     const std::string &Name,      ///< A name for the new instruction
2290     BasicBlock *InsertAtEnd       ///< The block to insert the instruction into
2291   );
2292
2293   /// @brief Clone an identical BitCastInst
2294   virtual CastInst *clone() const;
2295
2296   // Methods for support type inquiry through isa, cast, and dyn_cast:
2297   static inline bool classof(const BitCastInst *) { return true; }
2298   static inline bool classof(const Instruction *I) {
2299     return I->getOpcode() == BitCast;
2300   }
2301   static inline bool classof(const Value *V) {
2302     return isa<Instruction>(V) && classof(cast<Instruction>(V));
2303   }
2304 };
2305
2306 } // End llvm namespace
2307
2308 #endif