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