add a version of PHINode::getIncomingBlock that takes a raw

Use, to complement the version that takes a use_iterator.

llvm-svn: 83702
This commit is contained in:
Chris Lattner 2009-10-10 07:42:42 +00:00
parent f30a2b0c86
commit 99e02edef8
1 changed files with 19 additions and 9 deletions

View File

@ -1910,19 +1910,29 @@ public:
return i/2;
}
/// getIncomingBlock - Return incoming basic block corresponding
/// to value use iterator
///
template <typename U>
BasicBlock *getIncomingBlock(value_use_iterator<U> I) const {
assert(this == *I && "Iterator doesn't point to PHI's Uses?");
return static_cast<BasicBlock*>((&I.getUse() + 1)->get());
}
/// getIncomingBlock - Return incoming basic block number x
/// getIncomingBlock - Return incoming basic block #i.
///
BasicBlock *getIncomingBlock(unsigned i) const {
return static_cast<BasicBlock*>(getOperand(i*2+1));
}
/// getIncomingBlock - Return incoming basic block corresponding
/// to an operand of the PHI.
///
BasicBlock *getIncomingBlock(const Use &U) const {
assert(this == U.getUser() && "Iterator doesn't point to PHI's Uses?");
return static_cast<BasicBlock*>((&U + 1)->get());
}
/// getIncomingBlock - Return incoming basic block corresponding
/// to value use iterator.
///
template <typename U>
BasicBlock *getIncomingBlock(value_use_iterator<U> I) const {
return getIncomingBlock(I.getUse());
}
void setIncomingBlock(unsigned i, BasicBlock *BB) {
setOperand(i*2+1, BB);
}