diff options
author | Chris Lattner <sabre@nondot.org> | 2001-11-03 21:08:00 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2001-11-03 21:08:00 +0000 |
commit | 3bf04d5b99db505b07d55b42a348c6c642546d8c (patch) | |
tree | 77b3d9a452284f9fd9124c23ed70cdf6ed59d123 | |
parent | 80b1a1a26aaebf13eda9ff6d9c9492b1a06a75de (diff) | |
download | external_llvm-3bf04d5b99db505b07d55b42a348c6c642546d8c.zip external_llvm-3bf04d5b99db505b07d55b42a348c6c642546d8c.tar.gz external_llvm-3bf04d5b99db505b07d55b42a348c6c642546d8c.tar.bz2 |
Add a helper function to PHI node
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1113 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/iOther.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/llvm/iOther.h b/include/llvm/iOther.h index a566566..cba4196 100644 --- a/include/llvm/iOther.h +++ b/include/llvm/iOther.h @@ -48,6 +48,9 @@ public: inline BasicBlock *getIncomingBlock(unsigned i) { return cast<BasicBlock>(Operands[i*2+1]); } + inline void setIncomingBlock(unsigned i, BasicBlock *BB) { + Operands[i*2+1] = BB; + } // addIncoming - Add an incoming value to the end of the PHI list void addIncoming(Value *D, BasicBlock *BB); @@ -56,6 +59,14 @@ public: // predecessor basic block is deleted. The value removed is returned. Value *removeIncomingValue(const BasicBlock *BB); + // getBasicBlockIndex - Return the first index of the specified basic + // block in the value list for this PHI. Returns -1 if no instance. + // + int getBasicBlockIndex(const BasicBlock *BB) const { + for (unsigned i = 0; i < Operands.size()/2; ++i) + if (getIncomingBlock(i) == BB) return i; + return -1; + } // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const PHINode *) { return true; } |