Remove dead field
[oota-llvm.git] / include / llvm / Instructions.h
1 //===-- llvm/Instructions.h - Instruction subclass definitions --*- C++ -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 // This file exposes the class definitions of all of the subclasses of the
11 // Instruction class.  This is meant to be an easy way to get access to all
12 // instruction subclasses.
13 //
14 //===----------------------------------------------------------------------===//
15
16 #ifndef LLVM_INSTRUCTIONS_H
17 #define LLVM_INSTRUCTIONS_H
18
19 #include "llvm/Instruction.h"
20 #include "llvm/InstrTypes.h"
21
22 namespace llvm {
23
24 class BasicBlock;
25 class PointerType;
26
27 //===----------------------------------------------------------------------===//
28 //                             AllocationInst Class
29 //===----------------------------------------------------------------------===//
30
31 /// AllocationInst - This class is the common base class of MallocInst and
32 /// AllocaInst.
33 ///
34 class AllocationInst : public Instruction {
35 protected:
36   void init(const Type *Ty, Value *ArraySize, unsigned iTy);
37   AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, 
38                  const std::string &Name = "", Instruction *InsertBefore = 0);
39   AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, 
40                  const std::string &Name, BasicBlock *InsertAtEnd);
41
42 public:
43
44   /// isArrayAllocation - Return true if there is an allocation size parameter
45   /// to the allocation instruction that is not 1.
46   ///
47   bool isArrayAllocation() const;
48
49   /// getArraySize - Get the number of element allocated, for a simple
50   /// allocation of a single element, this will return a constant 1 value.
51   ///
52   inline const Value *getArraySize() const { return Operands[0]; }
53   inline Value *getArraySize() { return Operands[0]; }
54
55   /// getType - Overload to return most specific pointer type
56   ///
57   inline const PointerType *getType() const {
58     return reinterpret_cast<const PointerType*>(Instruction::getType()); 
59   }
60
61   /// getAllocatedType - Return the type that is being allocated by the
62   /// instruction.
63   ///
64   const Type *getAllocatedType() const;
65
66   virtual Instruction *clone() const = 0;
67
68   // Methods for support type inquiry through isa, cast, and dyn_cast:
69   static inline bool classof(const AllocationInst *) { return true; }
70   static inline bool classof(const Instruction *I) {
71     return I->getOpcode() == Instruction::Alloca ||
72            I->getOpcode() == Instruction::Malloc;
73   }
74   static inline bool classof(const Value *V) {
75     return isa<Instruction>(V) && classof(cast<Instruction>(V));
76   }
77 };
78
79
80 //===----------------------------------------------------------------------===//
81 //                                MallocInst Class
82 //===----------------------------------------------------------------------===//
83
84 /// MallocInst - an instruction to allocated memory on the heap
85 ///
86 class MallocInst : public AllocationInst {
87   MallocInst(const MallocInst &MI);
88 public:
89   explicit MallocInst(const Type *Ty, Value *ArraySize = 0,
90                       const std::string &Name = "",
91                       Instruction *InsertBefore = 0)
92     : AllocationInst(Ty, ArraySize, Malloc, Name, InsertBefore) {}
93   MallocInst(const Type *Ty, Value *ArraySize, const std::string &Name,
94              BasicBlock *InsertAtEnd)
95     : AllocationInst(Ty, ArraySize, Malloc, Name, InsertAtEnd) {}
96
97   virtual MallocInst *clone() const;
98
99   // Methods for support type inquiry through isa, cast, and dyn_cast:
100   static inline bool classof(const MallocInst *) { return true; }
101   static inline bool classof(const Instruction *I) {
102     return (I->getOpcode() == Instruction::Malloc);
103   }
104   static inline bool classof(const Value *V) {
105     return isa<Instruction>(V) && classof(cast<Instruction>(V));
106   }
107 };
108
109
110 //===----------------------------------------------------------------------===//
111 //                                AllocaInst Class
112 //===----------------------------------------------------------------------===//
113
114 /// AllocaInst - an instruction to allocate memory on the stack
115 ///
116 class AllocaInst : public AllocationInst {
117   AllocaInst(const AllocaInst &);
118 public:
119   explicit AllocaInst(const Type *Ty, Value *ArraySize = 0,
120                       const std::string &Name = "",
121                       Instruction *InsertBefore = 0)
122     : AllocationInst(Ty, ArraySize, Alloca, Name, InsertBefore) {}
123   AllocaInst(const Type *Ty, Value *ArraySize, const std::string &Name,
124              BasicBlock *InsertAtEnd)
125     : AllocationInst(Ty, ArraySize, Alloca, Name, InsertAtEnd) {}
126
127   virtual AllocaInst *clone() const;
128
129   // Methods for support type inquiry through isa, cast, and dyn_cast:
130   static inline bool classof(const AllocaInst *) { return true; }
131   static inline bool classof(const Instruction *I) {
132     return (I->getOpcode() == Instruction::Alloca);
133   }
134   static inline bool classof(const Value *V) {
135     return isa<Instruction>(V) && classof(cast<Instruction>(V));
136   }
137 };
138
139
140 //===----------------------------------------------------------------------===//
141 //                                 FreeInst Class
142 //===----------------------------------------------------------------------===//
143
144 /// FreeInst - an instruction to deallocate memory
145 ///
146 class FreeInst : public Instruction {
147   void init(Value *Ptr);
148
149 public:
150   explicit FreeInst(Value *Ptr, Instruction *InsertBefore = 0);
151   FreeInst(Value *Ptr, BasicBlock *InsertAfter);
152
153   virtual FreeInst *clone() const;
154
155   virtual bool mayWriteToMemory() const { return true; }
156
157   // Methods for support type inquiry through isa, cast, and dyn_cast:
158   static inline bool classof(const FreeInst *) { return true; }
159   static inline bool classof(const Instruction *I) {
160     return (I->getOpcode() == Instruction::Free);
161   }
162   static inline bool classof(const Value *V) {
163     return isa<Instruction>(V) && classof(cast<Instruction>(V));
164   }
165 };
166
167
168 //===----------------------------------------------------------------------===//
169 //                                LoadInst Class
170 //===----------------------------------------------------------------------===//
171
172 /// LoadInst - an instruction for reading from memory 
173 ///
174 class LoadInst : public Instruction {
175   LoadInst(const LoadInst &LI) : Instruction(LI.getType(), Load) {
176     Volatile = LI.isVolatile();
177     init(LI.Operands[0]);
178   }
179   bool Volatile;   // True if this is a volatile load
180   void init(Value *Ptr);
181 public:
182   LoadInst(Value *Ptr, const std::string &Name, Instruction *InsertBefore);
183   LoadInst(Value *Ptr, const std::string &Name, BasicBlock *InsertAtEnd);
184   LoadInst(Value *Ptr, const std::string &Name = "", bool isVolatile = false,
185            Instruction *InsertBefore = 0);
186   LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,
187            BasicBlock *InsertAtEnd);
188
189   /// isVolatile - Return true if this is a load from a volatile memory
190   /// location.
191   ///
192   bool isVolatile() const { return Volatile; }
193
194   /// setVolatile - Specify whether this is a volatile load or not.
195   ///
196   void setVolatile(bool V) { Volatile = V; }
197
198   virtual LoadInst *clone() const;
199
200   virtual bool mayWriteToMemory() const { return isVolatile(); }
201
202   Value *getPointerOperand() { return getOperand(0); }
203   const Value *getPointerOperand() const { return getOperand(0); }
204   static unsigned getPointerOperandIndex() { return 0U; }
205
206   // Methods for support type inquiry through isa, cast, and dyn_cast:
207   static inline bool classof(const LoadInst *) { return true; }
208   static inline bool classof(const Instruction *I) {
209     return I->getOpcode() == Instruction::Load;
210   }
211   static inline bool classof(const Value *V) {
212     return isa<Instruction>(V) && classof(cast<Instruction>(V));
213   }
214 };
215
216
217 //===----------------------------------------------------------------------===//
218 //                                StoreInst Class
219 //===----------------------------------------------------------------------===//
220
221 /// StoreInst - an instruction for storing to memory 
222 ///
223 class StoreInst : public Instruction {
224   StoreInst(const StoreInst &SI) : Instruction(SI.getType(), Store) {
225     Volatile = SI.isVolatile();
226     init(SI.Operands[0], SI.Operands[1]);
227   }
228   bool Volatile;   // True if this is a volatile store
229   void init(Value *Val, Value *Ptr);
230 public:
231   StoreInst(Value *Val, Value *Ptr, Instruction *InsertBefore);
232   StoreInst(Value *Val, Value *Ptr, BasicBlock *InsertAtEnd);
233   StoreInst(Value *Val, Value *Ptr, bool isVolatile = false,
234             Instruction *InsertBefore = 0);
235   StoreInst(Value *Val, Value *Ptr, bool isVolatile, BasicBlock *InsertAtEnd);
236
237
238   /// isVolatile - Return true if this is a load from a volatile memory
239   /// location.
240   ///
241   bool isVolatile() const { return Volatile; }
242
243   /// setVolatile - Specify whether this is a volatile load or not.
244   ///
245   void setVolatile(bool V) { Volatile = V; }
246
247   virtual StoreInst *clone() const;
248
249   virtual bool mayWriteToMemory() const { return true; }
250
251   Value *getPointerOperand() { return getOperand(1); }
252   const Value *getPointerOperand() const { return getOperand(1); }
253   static unsigned getPointerOperandIndex() { return 1U; }
254
255   // Methods for support type inquiry through isa, cast, and dyn_cast:
256   static inline bool classof(const StoreInst *) { return true; }
257   static inline bool classof(const Instruction *I) {
258     return I->getOpcode() == Instruction::Store;
259   }
260   static inline bool classof(const Value *V) {
261     return isa<Instruction>(V) && classof(cast<Instruction>(V));
262   }
263 };
264
265
266 //===----------------------------------------------------------------------===//
267 //                             GetElementPtrInst Class
268 //===----------------------------------------------------------------------===//
269
270 /// GetElementPtrInst - an instruction for type-safe pointer arithmetic to
271 /// access elements of arrays and structs
272 ///
273 class GetElementPtrInst : public Instruction {
274   GetElementPtrInst(const GetElementPtrInst &EPI)
275     : Instruction((static_cast<const Instruction*>(&EPI)->getType()),
276                   GetElementPtr) {
277     Operands.reserve(EPI.Operands.size());
278     for (unsigned i = 0, E = (unsigned)EPI.Operands.size(); i != E; ++i)
279       Operands.push_back(Use(EPI.Operands[i], this));
280   }
281   void init(Value *Ptr, const std::vector<Value*> &Idx);
282   void init(Value *Ptr, Value *Idx0, Value *Idx1);
283 public:
284   /// Constructors - Create a getelementptr instruction with a base pointer an
285   /// list of indices.  The first ctor can optionally insert before an existing
286   /// instruction, the second appends the new instruction to the specified
287   /// BasicBlock.
288   GetElementPtrInst(Value *Ptr, const std::vector<Value*> &Idx,
289                     const std::string &Name = "", Instruction *InsertBefore =0);
290   GetElementPtrInst(Value *Ptr, const std::vector<Value*> &Idx,
291                     const std::string &Name, BasicBlock *InsertAtEnd);
292
293   /// Constructors - These two constructors are convenience methods because two
294   /// index getelementptr instructions are so common.
295   GetElementPtrInst(Value *Ptr, Value *Idx0, Value *Idx1,
296                     const std::string &Name = "", Instruction *InsertBefore =0);
297   GetElementPtrInst(Value *Ptr, Value *Idx0, Value *Idx1,
298                     const std::string &Name, BasicBlock *InsertAtEnd);
299
300   virtual GetElementPtrInst *clone() const;
301   
302   // getType - Overload to return most specific pointer type...
303   inline const PointerType *getType() const {
304     return reinterpret_cast<const PointerType*>(Instruction::getType());
305   }
306
307   /// getIndexedType - Returns the type of the element that would be loaded with
308   /// a load instruction with the specified parameters.
309   ///
310   /// A null type is returned if the indices are invalid for the specified 
311   /// pointer type.
312   ///
313   static const Type *getIndexedType(const Type *Ptr, 
314                                     const std::vector<Value*> &Indices,
315                                     bool AllowStructLeaf = false);
316   static const Type *getIndexedType(const Type *Ptr, Value *Idx0, Value *Idx1,
317                                     bool AllowStructLeaf = false);
318   
319   inline op_iterator       idx_begin()       { return op_begin()+1; }
320   inline const_op_iterator idx_begin() const { return op_begin()+1; }
321   inline op_iterator       idx_end()         { return op_end(); }
322   inline const_op_iterator idx_end()   const { return op_end(); }
323
324   Value *getPointerOperand() {
325     return getOperand(0);
326   }
327   const Value *getPointerOperand() const {
328     return getOperand(0);
329   }
330   static unsigned getPointerOperandIndex() {
331     return 0U;                      // get index for modifying correct operand
332   }
333
334   inline unsigned getNumIndices() const {  // Note: always non-negative
335     return getNumOperands() - 1;
336   }
337   
338   inline bool hasIndices() const {
339     return getNumOperands() > 1;
340   }
341
342   // Methods for support type inquiry through isa, cast, and dyn_cast:
343   static inline bool classof(const GetElementPtrInst *) { return true; }
344   static inline bool classof(const Instruction *I) {
345     return (I->getOpcode() == Instruction::GetElementPtr);
346   }
347   static inline bool classof(const Value *V) {
348     return isa<Instruction>(V) && classof(cast<Instruction>(V));
349   }
350 };
351
352 //===----------------------------------------------------------------------===//
353 //                            SetCondInst Class
354 //===----------------------------------------------------------------------===//
355
356 /// SetCondInst class - Represent a setCC operator, where CC is eq, ne, lt, gt,
357 /// le, or ge.
358 ///
359 class SetCondInst : public BinaryOperator {
360 public:
361   SetCondInst(BinaryOps Opcode, Value *LHS, Value *RHS,
362               const std::string &Name = "", Instruction *InsertBefore = 0);
363   SetCondInst(BinaryOps Opcode, Value *LHS, Value *RHS,
364               const std::string &Name, BasicBlock *InsertAtEnd);
365
366   /// getInverseCondition - Return the inverse of the current condition opcode.
367   /// For example seteq -> setne, setgt -> setle, setlt -> setge, etc...
368   ///
369   BinaryOps getInverseCondition() const {
370     return getInverseCondition(getOpcode());
371   }
372
373   /// getInverseCondition - Static version that you can use without an
374   /// instruction available.
375   ///
376   static BinaryOps getInverseCondition(BinaryOps Opcode);
377
378   /// getSwappedCondition - Return the condition opcode that would be the result
379   /// of exchanging the two operands of the setcc instruction without changing
380   /// the result produced.  Thus, seteq->seteq, setle->setge, setlt->setgt, etc.
381   ///
382   BinaryOps getSwappedCondition() const {
383     return getSwappedCondition(getOpcode());
384   }
385
386   /// getSwappedCondition - Static version that you can use without an
387   /// instruction available.
388   ///
389   static BinaryOps getSwappedCondition(BinaryOps Opcode);
390
391
392   // Methods for support type inquiry through isa, cast, and dyn_cast:
393   static inline bool classof(const SetCondInst *) { return true; }
394   static inline bool classof(const Instruction *I) {
395     return I->getOpcode() == SetEQ || I->getOpcode() == SetNE ||
396            I->getOpcode() == SetLE || I->getOpcode() == SetGE ||
397            I->getOpcode() == SetLT || I->getOpcode() == SetGT;
398   }
399   static inline bool classof(const Value *V) {
400     return isa<Instruction>(V) && classof(cast<Instruction>(V));
401   }
402 };
403
404 //===----------------------------------------------------------------------===//
405 //                                 CastInst Class
406 //===----------------------------------------------------------------------===//
407
408 /// CastInst - This class represents a cast from Operand[0] to the type of
409 /// the instruction (i->getType()).
410 ///
411 class CastInst : public Instruction {
412   CastInst(const CastInst &CI) : Instruction(CI.getType(), Cast) {
413     Operands.reserve(1);
414     Operands.push_back(Use(CI.Operands[0], this));
415   }
416   void init(Value *S) {
417     Operands.reserve(1);
418     Operands.push_back(Use(S, this));
419   }
420 public:
421   CastInst(Value *S, const Type *Ty, const std::string &Name = "",
422            Instruction *InsertBefore = 0)
423     : Instruction(Ty, Cast, Name, InsertBefore) {
424     init(S);
425   }
426   CastInst(Value *S, const Type *Ty, const std::string &Name,
427            BasicBlock *InsertAtEnd)
428     : Instruction(Ty, Cast, Name, InsertAtEnd) {
429     init(S);
430   }
431
432   virtual CastInst *clone() const;
433
434   // Methods for support type inquiry through isa, cast, and dyn_cast:
435   static inline bool classof(const CastInst *) { return true; }
436   static inline bool classof(const Instruction *I) {
437     return I->getOpcode() == Cast;
438   }
439   static inline bool classof(const Value *V) {
440     return isa<Instruction>(V) && classof(cast<Instruction>(V));
441   }
442 };
443
444
445 //===----------------------------------------------------------------------===//
446 //                                 CallInst Class
447 //===----------------------------------------------------------------------===//
448
449 /// CallInst - This class represents a function call, abstracting a target
450 /// machine's calling convention.
451 ///
452 class CallInst : public Instruction {
453   CallInst(const CallInst &CI);
454   void init(Value *Func, const std::vector<Value*> &Params);
455   void init(Value *Func, Value *Actual1, Value *Actual2);
456   void init(Value *Func, Value *Actual);
457   void init(Value *Func);
458
459 public:
460   CallInst(Value *F, const std::vector<Value*> &Par,
461            const std::string &Name = "", Instruction *InsertBefore = 0);
462   CallInst(Value *F, const std::vector<Value*> &Par,
463            const std::string &Name, BasicBlock *InsertAtEnd);
464
465   // Alternate CallInst ctors w/ two actuals, w/ one actual and no
466   // actuals, respectively.
467   CallInst(Value *F, Value *Actual1, Value *Actual2,
468            const std::string& Name = "", Instruction *InsertBefore = 0);
469   CallInst(Value *F, Value *Actual1, Value *Actual2,
470            const std::string& Name, BasicBlock *InsertAtEnd);
471   CallInst(Value *F, Value *Actual, const std::string& Name = "",
472            Instruction *InsertBefore = 0);
473   CallInst(Value *F, Value *Actual, const std::string& Name,
474            BasicBlock *InsertAtEnd);
475   explicit CallInst(Value *F, const std::string &Name = "", 
476                     Instruction *InsertBefore = 0);
477   explicit CallInst(Value *F, const std::string &Name, 
478                     BasicBlock *InsertAtEnd);
479
480   virtual CallInst *clone() const;
481   bool mayWriteToMemory() const { return true; }
482
483   /// getCalledFunction - Return the function being called by this instruction
484   /// if it is a direct call.  If it is a call through a function pointer,
485   /// return null.
486   Function *getCalledFunction() const {
487     return dyn_cast<Function>(Operands[0]);
488   }
489
490   // getCalledValue - Get a pointer to a method that is invoked by this inst.
491   inline const Value *getCalledValue() const { return Operands[0]; }
492   inline       Value *getCalledValue()       { return Operands[0]; }
493
494   // Methods for support type inquiry through isa, cast, and dyn_cast:
495   static inline bool classof(const CallInst *) { return true; }
496   static inline bool classof(const Instruction *I) {
497     return I->getOpcode() == Instruction::Call; 
498   }
499   static inline bool classof(const Value *V) {
500     return isa<Instruction>(V) && classof(cast<Instruction>(V));
501   }
502 };
503
504
505 //===----------------------------------------------------------------------===//
506 //                                 ShiftInst Class
507 //===----------------------------------------------------------------------===//
508
509 /// ShiftInst - This class represents left and right shift instructions.
510 ///
511 class ShiftInst : public Instruction {
512   ShiftInst(const ShiftInst &SI) : Instruction(SI.getType(), SI.getOpcode()) {
513     Operands.reserve(2);
514     Operands.push_back(Use(SI.Operands[0], this));
515     Operands.push_back(Use(SI.Operands[1], this));
516   }
517   void init(OtherOps Opcode, Value *S, Value *SA) {
518     assert((Opcode == Shl || Opcode == Shr) && "ShiftInst Opcode invalid!");
519     Operands.reserve(2);
520     Operands.push_back(Use(S, this));
521     Operands.push_back(Use(SA, this));
522   }
523
524 public:
525   ShiftInst(OtherOps Opcode, Value *S, Value *SA, const std::string &Name = "",
526             Instruction *InsertBefore = 0)
527     : Instruction(S->getType(), Opcode, Name, InsertBefore) {
528     init(Opcode, S, SA);
529   }
530   ShiftInst(OtherOps Opcode, Value *S, Value *SA, const std::string &Name,
531             BasicBlock *InsertAtEnd)
532     : Instruction(S->getType(), Opcode, Name, InsertAtEnd) {
533     init(Opcode, S, SA);
534   }
535
536   OtherOps getOpcode() const {
537     return static_cast<OtherOps>(Instruction::getOpcode());
538   }
539
540   virtual ShiftInst *clone() const;
541
542   // Methods for support type inquiry through isa, cast, and dyn_cast:
543   static inline bool classof(const ShiftInst *) { return true; }
544   static inline bool classof(const Instruction *I) {
545     return (I->getOpcode() == Instruction::Shr) | 
546            (I->getOpcode() == Instruction::Shl);
547   }
548   static inline bool classof(const Value *V) {
549     return isa<Instruction>(V) && classof(cast<Instruction>(V));
550   }
551 };
552
553 //===----------------------------------------------------------------------===//
554 //                               SelectInst Class
555 //===----------------------------------------------------------------------===//
556
557 /// SelectInst - This class represents the LLVM 'select' instruction.
558 ///
559 class SelectInst : public Instruction {
560   SelectInst(const SelectInst &SI) : Instruction(SI.getType(), SI.getOpcode()) {
561     Operands.reserve(3);
562     Operands.push_back(Use(SI.Operands[0], this));
563     Operands.push_back(Use(SI.Operands[1], this));
564     Operands.push_back(Use(SI.Operands[2], this));
565   }
566   void init(Value *C, Value *S1, Value *S2) {
567     Operands.reserve(3);
568     Operands.push_back(Use(C, this));
569     Operands.push_back(Use(S1, this));
570     Operands.push_back(Use(S2, this));
571   }
572
573 public:
574   SelectInst(Value *C, Value *S1, Value *S2, const std::string &Name = "",
575              Instruction *InsertBefore = 0)
576     : Instruction(S1->getType(), Instruction::Select, Name, InsertBefore) {
577     init(C, S1, S2);
578   }
579   SelectInst(Value *C, Value *S1, Value *S2, const std::string &Name,
580              BasicBlock *InsertAtEnd)
581     : Instruction(S1->getType(), Instruction::Select, Name, InsertAtEnd) {
582     init(C, S1, S2);
583   }
584
585   Value *getCondition() const { return Operands[0]; }
586   Value *getTrueValue() const { return Operands[1]; }
587   Value *getFalseValue() const { return Operands[2]; }
588
589   OtherOps getOpcode() const {
590     return static_cast<OtherOps>(Instruction::getOpcode());
591   }
592
593   virtual SelectInst *clone() const;
594
595   // Methods for support type inquiry through isa, cast, and dyn_cast:
596   static inline bool classof(const SelectInst *) { return true; }
597   static inline bool classof(const Instruction *I) {
598     return I->getOpcode() == Instruction::Select;
599   }
600   static inline bool classof(const Value *V) {
601     return isa<Instruction>(V) && classof(cast<Instruction>(V));
602   }
603 };
604
605
606 //===----------------------------------------------------------------------===//
607 //                                VANextInst Class
608 //===----------------------------------------------------------------------===//
609
610 /// VANextInst - This class represents the va_next llvm instruction, which
611 /// advances a vararg list passed an argument of the specified type, returning
612 /// the resultant list.
613 ///
614 class VANextInst : public Instruction {
615   PATypeHolder ArgTy;
616   void init(Value *List) {
617     Operands.reserve(1);
618     Operands.push_back(Use(List, this));
619   }
620   VANextInst(const VANextInst &VAN)
621     : Instruction(VAN.getType(), VANext), ArgTy(VAN.getArgType()) {
622     init(VAN.Operands[0]);
623   }
624
625 public:
626   VANextInst(Value *List, const Type *Ty, const std::string &Name = "",
627              Instruction *InsertBefore = 0)
628     : Instruction(List->getType(), VANext, Name, InsertBefore), ArgTy(Ty) {
629     init(List);
630   }
631   VANextInst(Value *List, const Type *Ty, const std::string &Name,
632              BasicBlock *InsertAtEnd)
633     : Instruction(List->getType(), VANext, Name, InsertAtEnd), ArgTy(Ty) {
634     init(List);
635   }
636
637   const Type *getArgType() const { return ArgTy; }
638
639   virtual VANextInst *clone() const;
640
641   // Methods for support type inquiry through isa, cast, and dyn_cast:
642   static inline bool classof(const VANextInst *) { return true; }
643   static inline bool classof(const Instruction *I) {
644     return I->getOpcode() == VANext;
645   }
646   static inline bool classof(const Value *V) {
647     return isa<Instruction>(V) && classof(cast<Instruction>(V));
648   }
649 };
650
651
652 //===----------------------------------------------------------------------===//
653 //                                VAArgInst Class
654 //===----------------------------------------------------------------------===//
655
656 /// VAArgInst - This class represents the va_arg llvm instruction, which returns
657 /// an argument of the specified type given a va_list.
658 ///
659 class VAArgInst : public Instruction {
660   void init(Value* List) {
661     Operands.reserve(1);
662     Operands.push_back(Use(List, this));
663   }
664   VAArgInst(const VAArgInst &VAA)
665     : Instruction(VAA.getType(), VAArg) {
666     init(VAA.Operands[0]);
667   }
668 public:
669   VAArgInst(Value *List, const Type *Ty, const std::string &Name = "",
670              Instruction *InsertBefore = 0)
671     : Instruction(Ty, VAArg, Name, InsertBefore) {
672     init(List);
673   }
674   VAArgInst(Value *List, const Type *Ty, const std::string &Name,
675             BasicBlock *InsertAtEnd)
676     : Instruction(Ty, VAArg, Name, InsertAtEnd) {
677     init(List);
678   }
679
680   virtual VAArgInst *clone() const;
681
682   // Methods for support type inquiry through isa, cast, and dyn_cast:
683   static inline bool classof(const VAArgInst *) { return true; }
684   static inline bool classof(const Instruction *I) {
685     return I->getOpcode() == VAArg;
686   }
687   static inline bool classof(const Value *V) {
688     return isa<Instruction>(V) && classof(cast<Instruction>(V));
689   }
690 };
691
692 //===----------------------------------------------------------------------===//
693 //                               PHINode Class
694 //===----------------------------------------------------------------------===//
695
696 // PHINode - The PHINode class is used to represent the magical mystical PHI
697 // node, that can not exist in nature, but can be synthesized in a computer
698 // scientist's overactive imagination.
699 //
700 class PHINode : public Instruction {
701   PHINode(const PHINode &PN);
702 public:
703   PHINode(const Type *Ty, const std::string &Name = "",
704           Instruction *InsertBefore = 0)
705     : Instruction(Ty, Instruction::PHI, Name, InsertBefore) {
706   }
707
708   PHINode(const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd)
709     : Instruction(Ty, Instruction::PHI, Name, InsertAtEnd) {
710   }
711
712   virtual PHINode *clone() const;
713
714   /// getNumIncomingValues - Return the number of incoming edges
715   ///
716   unsigned getNumIncomingValues() const { return (unsigned)Operands.size()/2; }
717
718   /// getIncomingValue - Return incoming value #x
719   ///
720   Value *getIncomingValue(unsigned i) const {
721     assert(i*2 < Operands.size() && "Invalid value number!");
722     return Operands[i*2];
723   }
724   void setIncomingValue(unsigned i, Value *V) {
725     assert(i*2 < Operands.size() && "Invalid value number!");
726     Operands[i*2] = V;
727   }
728   inline unsigned getOperandNumForIncomingValue(unsigned i) {
729     return i*2;
730   }
731
732   /// getIncomingBlock - Return incoming basic block #x
733   ///
734   BasicBlock *getIncomingBlock(unsigned i) const { 
735     assert(i*2+1 < Operands.size() && "Invalid value number!");
736     return reinterpret_cast<BasicBlock*>(Operands[i*2+1].get());
737   }
738   void setIncomingBlock(unsigned i, BasicBlock *BB) {
739     assert(i*2+1 < Operands.size() && "Invalid value number!");
740     Operands[i*2+1] = reinterpret_cast<Value*>(BB);
741   }
742   unsigned getOperandNumForIncomingBlock(unsigned i) {
743     return i*2+1;
744   }
745
746   /// addIncoming - Add an incoming value to the end of the PHI list
747   ///
748   void addIncoming(Value *V, BasicBlock *BB) {
749     assert(getType() == V->getType() &&
750            "All operands to PHI node must be the same type as the PHI node!");
751     Operands.push_back(Use(V, this));
752     Operands.push_back(Use(reinterpret_cast<Value*>(BB), this));
753   }
754   
755   /// removeIncomingValue - Remove an incoming value.  This is useful if a
756   /// predecessor basic block is deleted.  The value removed is returned.
757   ///
758   /// If the last incoming value for a PHI node is removed (and DeletePHIIfEmpty
759   /// is true), the PHI node is destroyed and any uses of it are replaced with
760   /// dummy values.  The only time there should be zero incoming values to a PHI
761   /// node is when the block is dead, so this strategy is sound.
762   ///
763   Value *removeIncomingValue(unsigned Idx, bool DeletePHIIfEmpty = true);
764
765   Value *removeIncomingValue(const BasicBlock *BB, bool DeletePHIIfEmpty =true){
766     int Idx = getBasicBlockIndex(BB);
767     assert(Idx >= 0 && "Invalid basic block argument to remove!");
768     return removeIncomingValue(Idx, DeletePHIIfEmpty);
769   }
770
771   /// getBasicBlockIndex - Return the first index of the specified basic 
772   /// block in the value list for this PHI.  Returns -1 if no instance.
773   ///
774   int getBasicBlockIndex(const BasicBlock *BB) const {
775     for (unsigned i = 0; i < Operands.size()/2; ++i) 
776       if (getIncomingBlock(i) == BB) return i;
777     return -1;
778   }
779
780   Value *getIncomingValueForBlock(const BasicBlock *BB) const {
781     return getIncomingValue(getBasicBlockIndex(BB));
782   }
783
784   /// Methods for support type inquiry through isa, cast, and dyn_cast:
785   static inline bool classof(const PHINode *) { return true; }
786   static inline bool classof(const Instruction *I) {
787     return I->getOpcode() == Instruction::PHI; 
788   }
789   static inline bool classof(const Value *V) {
790     return isa<Instruction>(V) && classof(cast<Instruction>(V));
791   }
792 };
793
794 //===----------------------------------------------------------------------===//
795 //                               ReturnInst Class
796 //===----------------------------------------------------------------------===//
797
798 //===---------------------------------------------------------------------------
799 /// ReturnInst - Return a value (possibly void), from a function.  Execution
800 /// does not continue in this function any longer.
801 ///
802 class ReturnInst : public TerminatorInst {
803   ReturnInst(const ReturnInst &RI) : TerminatorInst(Instruction::Ret) {
804     if (RI.Operands.size()) {
805       assert(RI.Operands.size() == 1 && "Return insn can only have 1 operand!");
806       Operands.reserve(1);
807       Operands.push_back(Use(RI.Operands[0], this));
808     }
809   }
810
811   void init(Value *RetVal);
812
813 public:
814   // ReturnInst constructors:
815   // ReturnInst()                  - 'ret void' instruction
816   // ReturnInst(    null)          - 'ret void' instruction
817   // ReturnInst(Value* X)          - 'ret X'    instruction
818   // ReturnInst(    null, Inst *)  - 'ret void' instruction, insert before I
819   // ReturnInst(Value* X, Inst *I) - 'ret X'    instruction, insert before I
820   // ReturnInst(    null, BB *B)   - 'ret void' instruction, insert @ end of BB
821   // ReturnInst(Value* X, BB *B)   - 'ret X'    instruction, insert @ end of BB
822   //
823   // NOTE: If the Value* passed is of type void then the constructor behaves as
824   // if it was passed NULL.
825   ReturnInst(Value *RetVal = 0, Instruction *InsertBefore = 0)
826     : TerminatorInst(Instruction::Ret, InsertBefore) {
827     init(RetVal);
828   }
829   ReturnInst(Value *RetVal, BasicBlock *InsertAtEnd)
830     : TerminatorInst(Instruction::Ret, InsertAtEnd) {
831     init(RetVal);
832   }
833   ReturnInst(BasicBlock *InsertAtEnd)
834     : TerminatorInst(Instruction::Ret, InsertAtEnd) {
835   }
836
837   virtual ReturnInst *clone() const;
838
839   inline const Value *getReturnValue() const {
840     return Operands.size() ? Operands[0].get() : 0; 
841   }
842   inline       Value *getReturnValue()       {
843     return Operands.size() ? Operands[0].get() : 0;
844   }
845
846   virtual const BasicBlock *getSuccessor(unsigned idx) const {
847     assert(0 && "ReturnInst has no successors!");
848     abort();
849     return 0;
850   }
851   virtual void setSuccessor(unsigned idx, BasicBlock *NewSucc);
852   virtual unsigned getNumSuccessors() const { return 0; }
853
854   // Methods for support type inquiry through isa, cast, and dyn_cast:
855   static inline bool classof(const ReturnInst *) { return true; }
856   static inline bool classof(const Instruction *I) {
857     return (I->getOpcode() == Instruction::Ret);
858   }
859   static inline bool classof(const Value *V) {
860     return isa<Instruction>(V) && classof(cast<Instruction>(V));
861   }
862 };
863
864 //===----------------------------------------------------------------------===//
865 //                               BranchInst Class
866 //===----------------------------------------------------------------------===//
867
868 //===---------------------------------------------------------------------------
869 /// BranchInst - Conditional or Unconditional Branch instruction.
870 ///
871 class BranchInst : public TerminatorInst {
872   BranchInst(const BranchInst &BI);
873   void init(BasicBlock *IfTrue);
874   void init(BasicBlock *True, BasicBlock *False, Value *Cond);
875 public:
876   // BranchInst constructors (where {B, T, F} are blocks, and C is a condition):
877   // BranchInst(BB *B)                           - 'br B'
878   // BranchInst(BB* T, BB *F, Value *C)          - 'br C, T, F'
879   // BranchInst(BB* B, Inst *I)                  - 'br B'        insert before I
880   // BranchInst(BB* T, BB *F, Value *C, Inst *I) - 'br C, T, F', insert before I
881   // BranchInst(BB* B, BB *I)                    - 'br B'        insert at end
882   // BranchInst(BB* T, BB *F, Value *C, BB *I)   - 'br C, T, F', insert at end
883   BranchInst(BasicBlock *IfTrue, Instruction *InsertBefore = 0)
884     : TerminatorInst(Instruction::Br, InsertBefore) {
885     init(IfTrue);
886   }
887   BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond,
888              Instruction *InsertBefore = 0)
889     : TerminatorInst(Instruction::Br, InsertBefore) {
890     init(IfTrue, IfFalse, Cond);
891   }
892
893   BranchInst(BasicBlock *IfTrue, BasicBlock *InsertAtEnd)
894     : TerminatorInst(Instruction::Br, InsertAtEnd) {
895     init(IfTrue);
896   }
897
898   BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond,
899              BasicBlock *InsertAtEnd)
900     : TerminatorInst(Instruction::Br, InsertAtEnd) {
901     init(IfTrue, IfFalse, Cond);
902   }
903
904   virtual BranchInst *clone() const;
905
906   inline bool isUnconditional() const { return Operands.size() == 1; }
907   inline bool isConditional()   const { return Operands.size() == 3; }
908
909   inline Value *getCondition() const {
910     assert(isConditional() && "Cannot get condition of an uncond branch!");
911     return Operands[2].get();
912   }
913
914   void setCondition(Value *V) {
915     assert(isConditional() && "Cannot set condition of unconditional branch!");
916     setOperand(2, V);
917   }
918
919   // setUnconditionalDest - Change the current branch to an unconditional branch
920   // targeting the specified block.
921   //
922   void setUnconditionalDest(BasicBlock *Dest) {
923     if (isConditional()) Operands.erase(Operands.begin()+1, Operands.end());
924     Operands[0] = reinterpret_cast<Value*>(Dest);
925   }
926
927   virtual const BasicBlock *getSuccessor(unsigned i) const {
928     assert(i < getNumSuccessors() && "Successor # out of range for Branch!");
929     return (i == 0) ? cast<BasicBlock>(Operands[0].get()) : 
930                       cast<BasicBlock>(Operands[1].get());
931   }
932   inline BasicBlock *getSuccessor(unsigned idx) {
933     const BranchInst *BI = this;
934     return const_cast<BasicBlock*>(BI->getSuccessor(idx));
935   }
936
937   virtual void setSuccessor(unsigned idx, BasicBlock *NewSucc) {
938     assert(idx < getNumSuccessors() && "Successor # out of range for Branch!");
939     Operands[idx] = reinterpret_cast<Value*>(NewSucc);
940   }
941
942   virtual unsigned getNumSuccessors() const { return 1+isConditional(); }
943
944   // Methods for support type inquiry through isa, cast, and dyn_cast:
945   static inline bool classof(const BranchInst *) { return true; }
946   static inline bool classof(const Instruction *I) {
947     return (I->getOpcode() == Instruction::Br);
948   }
949   static inline bool classof(const Value *V) {
950     return isa<Instruction>(V) && classof(cast<Instruction>(V));
951   }
952 };
953
954 //===----------------------------------------------------------------------===//
955 //                               SwitchInst Class
956 //===----------------------------------------------------------------------===//
957
958 //===---------------------------------------------------------------------------
959 /// SwitchInst - Multiway switch
960 ///
961 class SwitchInst : public TerminatorInst {
962   // Operand[0]    = Value to switch on
963   // Operand[1]    = Default basic block destination
964   // Operand[2n  ] = Value to match
965   // Operand[2n+1] = BasicBlock to go to on match
966   SwitchInst(const SwitchInst &RI);
967   void init(Value *Value, BasicBlock *Default);
968
969 public:
970   SwitchInst(Value *Value, BasicBlock *Default, Instruction *InsertBefore = 0) 
971     : TerminatorInst(Instruction::Switch, InsertBefore) {
972     init(Value, Default);
973   }
974   SwitchInst(Value *Value, BasicBlock *Default, BasicBlock  *InsertAtEnd) 
975     : TerminatorInst(Instruction::Switch, InsertAtEnd) {
976     init(Value, Default);
977   }
978
979   virtual SwitchInst *clone() const;
980
981   // Accessor Methods for Switch stmt
982   //
983   inline const Value *getCondition() const { return Operands[0]; }
984   inline       Value *getCondition()       { return Operands[0]; }
985   inline const BasicBlock *getDefaultDest() const {
986     return cast<BasicBlock>(Operands[1].get());
987   }
988   inline       BasicBlock *getDefaultDest()       {
989     return cast<BasicBlock>(Operands[1].get());
990   }
991
992   /// getNumCases - return the number of 'cases' in this switch instruction.
993   /// Note that case #0 is always the default case.
994   unsigned getNumCases() const {
995     return (unsigned)Operands.size()/2;
996   }
997
998   /// getCaseValue - Return the specified case value.  Note that case #0, the
999   /// default destination, does not have a case value.
1000   Constant *getCaseValue(unsigned i) {
1001     assert(i && i < getNumCases() && "Illegal case value to get!");
1002     return getSuccessorValue(i);
1003   }
1004
1005   /// getCaseValue - Return the specified case value.  Note that case #0, the
1006   /// default destination, does not have a case value.
1007   const Constant *getCaseValue(unsigned i) const {
1008     assert(i && i < getNumCases() && "Illegal case value to get!");
1009     return getSuccessorValue(i);
1010   }
1011
1012   /// findCaseValue - Search all of the case values for the specified constant.
1013   /// If it is explicitly handled, return the case number of it, otherwise
1014   /// return 0 to indicate that it is handled by the default handler.
1015   unsigned findCaseValue(const Constant *C) const {
1016     for (unsigned i = 1, e = getNumCases(); i != e; ++i)
1017       if (getCaseValue(i) == C)
1018         return i;
1019     return 0;
1020   }
1021
1022   /// addCase - Add an entry to the switch instruction...
1023   ///
1024   void addCase(Constant *OnVal, BasicBlock *Dest);
1025
1026   /// removeCase - This method removes the specified successor from the switch
1027   /// instruction.  Note that this cannot be used to remove the default
1028   /// destination (successor #0).
1029   ///
1030   void removeCase(unsigned idx);
1031
1032   virtual const BasicBlock *getSuccessor(unsigned idx) const {
1033     assert(idx < getNumSuccessors() &&"Successor idx out of range for switch!");
1034     return cast<BasicBlock>(Operands[idx*2+1].get());
1035   }
1036   inline BasicBlock *getSuccessor(unsigned idx) {
1037     assert(idx < getNumSuccessors() &&"Successor idx out of range for switch!");
1038     return cast<BasicBlock>(Operands[idx*2+1].get());
1039   }
1040
1041   virtual void setSuccessor(unsigned idx, BasicBlock *NewSucc) {
1042     assert(idx < getNumSuccessors() && "Successor # out of range for switch!");
1043     Operands[idx*2+1] = reinterpret_cast<Value*>(NewSucc);
1044   }
1045
1046   // getSuccessorValue - Return the value associated with the specified
1047   // successor.
1048   inline const Constant *getSuccessorValue(unsigned idx) const {
1049     assert(idx < getNumSuccessors() && "Successor # out of range!");
1050     return cast<Constant>(Operands[idx*2].get());
1051   }
1052   inline Constant *getSuccessorValue(unsigned idx) {
1053     assert(idx < getNumSuccessors() && "Successor # out of range!");
1054     return cast<Constant>(Operands[idx*2].get());
1055   }
1056   virtual unsigned getNumSuccessors() const { return (unsigned)Operands.size()/2; }
1057
1058   // Methods for support type inquiry through isa, cast, and dyn_cast:
1059   static inline bool classof(const SwitchInst *) { return true; }
1060   static inline bool classof(const Instruction *I) {
1061     return (I->getOpcode() == Instruction::Switch);
1062   }
1063   static inline bool classof(const Value *V) {
1064     return isa<Instruction>(V) && classof(cast<Instruction>(V));
1065   }
1066 };
1067
1068 //===----------------------------------------------------------------------===//
1069 //                               InvokeInst Class
1070 //===----------------------------------------------------------------------===//
1071
1072 //===---------------------------------------------------------------------------
1073 /// InvokeInst - Invoke instruction
1074 ///
1075 class InvokeInst : public TerminatorInst {
1076   InvokeInst(const InvokeInst &BI);
1077   void init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
1078             const std::vector<Value*> &Params);
1079 public:
1080   InvokeInst(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
1081              const std::vector<Value*> &Params, const std::string &Name = "",
1082              Instruction *InsertBefore = 0);
1083   InvokeInst(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
1084              const std::vector<Value*> &Params, const std::string &Name,
1085              BasicBlock *InsertAtEnd);
1086
1087   virtual InvokeInst *clone() const;
1088
1089   bool mayWriteToMemory() const { return true; }
1090
1091   /// getCalledFunction - Return the function called, or null if this is an
1092   /// indirect function invocation.
1093   ///
1094   Function *getCalledFunction() const {
1095     return dyn_cast<Function>(Operands[0]);
1096   }
1097
1098   // getCalledValue - Get a pointer to a function that is invoked by this inst.
1099   inline const Value *getCalledValue() const { return Operands[0]; }
1100   inline       Value *getCalledValue()       { return Operands[0]; }
1101
1102   // get*Dest - Return the destination basic blocks...
1103   inline const BasicBlock *getNormalDest() const {
1104     return cast<BasicBlock>(Operands[1].get());
1105   }
1106   inline       BasicBlock *getNormalDest() {
1107     return cast<BasicBlock>(Operands[1].get());
1108   }
1109   inline const BasicBlock *getUnwindDest() const {
1110     return cast<BasicBlock>(Operands[2].get());
1111   }
1112   inline       BasicBlock *getUnwindDest() {
1113     return cast<BasicBlock>(Operands[2].get());
1114   }
1115
1116   inline void setNormalDest(BasicBlock *B){
1117     Operands[1] = reinterpret_cast<Value*>(B);
1118   }
1119
1120   inline void setUnwindDest(BasicBlock *B){
1121     Operands[2] = reinterpret_cast<Value*>(B);
1122   }
1123
1124   virtual const BasicBlock *getSuccessor(unsigned i) const {
1125     assert(i < 2 && "Successor # out of range for invoke!");
1126     return i == 0 ? getNormalDest() : getUnwindDest();
1127   }
1128   inline BasicBlock *getSuccessor(unsigned i) {
1129     assert(i < 2 && "Successor # out of range for invoke!");
1130     return i == 0 ? getNormalDest() : getUnwindDest();
1131   }
1132
1133   virtual void setSuccessor(unsigned idx, BasicBlock *NewSucc) {
1134     assert(idx < 2 && "Successor # out of range for invoke!");
1135     Operands[idx+1] = reinterpret_cast<Value*>(NewSucc);
1136   }
1137
1138   virtual unsigned getNumSuccessors() const { return 2; }
1139
1140   // Methods for support type inquiry through isa, cast, and dyn_cast:
1141   static inline bool classof(const InvokeInst *) { return true; }
1142   static inline bool classof(const Instruction *I) {
1143     return (I->getOpcode() == Instruction::Invoke);
1144   }
1145   static inline bool classof(const Value *V) {
1146     return isa<Instruction>(V) && classof(cast<Instruction>(V));
1147   }
1148 };
1149
1150
1151 //===----------------------------------------------------------------------===//
1152 //                              UnwindInst Class
1153 //===----------------------------------------------------------------------===//
1154
1155 //===---------------------------------------------------------------------------
1156 /// UnwindInst - Immediately exit the current function, unwinding the stack
1157 /// until an invoke instruction is found.
1158 ///
1159 class UnwindInst : public TerminatorInst {
1160 public:
1161   UnwindInst(Instruction *InsertBefore = 0)
1162     : TerminatorInst(Instruction::Unwind, InsertBefore) {
1163   }
1164   UnwindInst(BasicBlock *InsertAtEnd)
1165     : TerminatorInst(Instruction::Unwind, InsertAtEnd) {
1166   }
1167
1168   virtual UnwindInst *clone() const;
1169
1170   virtual const BasicBlock *getSuccessor(unsigned idx) const {
1171     assert(0 && "UnwindInst has no successors!");
1172     abort();
1173     return 0;
1174   }
1175   virtual void setSuccessor(unsigned idx, BasicBlock *NewSucc);
1176   virtual unsigned getNumSuccessors() const { return 0; }
1177
1178   // Methods for support type inquiry through isa, cast, and dyn_cast:
1179   static inline bool classof(const UnwindInst *) { return true; }
1180   static inline bool classof(const Instruction *I) {
1181     return I->getOpcode() == Instruction::Unwind;
1182   }
1183   static inline bool classof(const Value *V) {
1184     return isa<Instruction>(V) && classof(cast<Instruction>(V));
1185   }
1186 };
1187
1188 //===----------------------------------------------------------------------===//
1189 //                           UnreachableInst Class
1190 //===----------------------------------------------------------------------===//
1191
1192 //===---------------------------------------------------------------------------
1193 /// UnreachableInst - This function has undefined behavior.  In particular, the
1194 /// presence of this instruction indicates some higher level knowledge that the
1195 /// end of the block cannot be reached.
1196 ///
1197 class UnreachableInst : public TerminatorInst {
1198 public:
1199   UnreachableInst(Instruction *InsertBefore = 0)
1200     : TerminatorInst(Instruction::Unreachable, InsertBefore) {
1201   }
1202   UnreachableInst(BasicBlock *InsertAtEnd)
1203     : TerminatorInst(Instruction::Unreachable, InsertAtEnd) {
1204   }
1205
1206   virtual UnreachableInst *clone() const;
1207
1208   virtual const BasicBlock *getSuccessor(unsigned idx) const {
1209     assert(0 && "UnreachableInst has no successors!");
1210     abort();
1211     return 0;
1212   }
1213   virtual void setSuccessor(unsigned idx, BasicBlock *NewSucc);
1214   virtual unsigned getNumSuccessors() const { return 0; }
1215
1216   // Methods for support type inquiry through isa, cast, and dyn_cast:
1217   static inline bool classof(const UnreachableInst *) { return true; }
1218   static inline bool classof(const Instruction *I) {
1219     return I->getOpcode() == Instruction::Unreachable;
1220   }
1221   static inline bool classof(const Value *V) {
1222     return isa<Instruction>(V) && classof(cast<Instruction>(V));
1223   }
1224 };
1225
1226 } // End llvm namespace
1227
1228 #endif