Remove unneccesary method
[oota-llvm.git] / include / llvm / iPHINode.h
1 //===-- llvm/iPHINode.h - PHI instruction definition -------------*- C++ -*--=//
2 //
3 // This file defines the PHINode class.
4 //
5 //===----------------------------------------------------------------------===//
6
7 #ifndef LLVM_IPHINODE_H
8 #define LLVM_IPHINODE_H
9
10 #include "llvm/Instruction.h"
11 class BasicBlock;
12
13 //===----------------------------------------------------------------------===//
14 //                               PHINode Class
15 //===----------------------------------------------------------------------===//
16
17 // PHINode - The PHINode class is used to represent the magical mystical PHI
18 // node, that can not exist in nature, but can be synthesized in a computer
19 // scientist's overactive imagination.
20 //
21 class PHINode : public Instruction {
22   PHINode(const PHINode &PN);
23 public:
24   PHINode(const Type *Ty, const std::string &Name = "");
25
26   virtual Instruction *clone() const { return new PHINode(*this); }
27
28   // getNumIncomingValues - Return the number of incoming edges the PHI node has
29   inline unsigned getNumIncomingValues() const { return Operands.size()/2; }
30
31   // getIncomingValue - Return incoming value #x
32   inline const Value *getIncomingValue(unsigned i) const {
33     return Operands[i*2];
34   }
35   inline Value *getIncomingValue(unsigned i) {
36     return Operands[i*2];
37   }
38   inline void setIncomingValue(unsigned i, Value *V) {
39     Operands[i*2] = V;
40   }
41
42   // getIncomingBlock - Return incoming basic block #x
43   inline const BasicBlock *getIncomingBlock(unsigned i) const { 
44     return (const BasicBlock*)Operands[i*2+1].get();
45   }
46   inline BasicBlock *getIncomingBlock(unsigned i) { 
47     return (BasicBlock*)Operands[i*2+1].get();
48   }
49   inline void setIncomingBlock(unsigned i, BasicBlock *BB) {
50     Operands[i*2+1] = (Value*)BB;
51   }
52
53   // addIncoming - Add an incoming value to the end of the PHI list
54   void addIncoming(Value *D, BasicBlock *BB);
55
56   // removeIncomingValue - Remove an incoming value.  This is useful if a
57   // predecessor basic block is deleted.  The value removed is returned.
58   Value *removeIncomingValue(const BasicBlock *BB);
59
60   // getBasicBlockIndex - Return the first index of the specified basic 
61   // block in the value list for this PHI.  Returns -1 if no instance.
62   //
63   int getBasicBlockIndex(const BasicBlock *BB) const {
64     for (unsigned i = 0; i < Operands.size()/2; ++i) 
65       if (getIncomingBlock(i) == BB) return i;
66     return -1;
67   }
68
69   // Methods for support type inquiry through isa, cast, and dyn_cast:
70   static inline bool classof(const PHINode *) { return true; }
71   static inline bool classof(const Instruction *I) {
72     return I->getOpcode() == Instruction::PHINode; 
73   }
74   static inline bool classof(const Value *V) {
75     return isa<Instruction>(V) && classof(cast<Instruction>(V));
76   }
77 };
78
79 #endif