From 99e02edef8a5bdfb4227486ac4c49ebd60c859cf Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 10 Oct 2009 07:42:42 +0000 Subject: [PATCH] add a version of PHINode::getIncomingBlock that takes a raw Use, to complement the version that takes a use_iterator. llvm-svn: 83702 --- llvm/include/llvm/Instructions.h | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/llvm/include/llvm/Instructions.h b/llvm/include/llvm/Instructions.h index c71d64ab0720..4ba7c084f07d 100644 --- a/llvm/include/llvm/Instructions.h +++ b/llvm/include/llvm/Instructions.h @@ -1910,19 +1910,29 @@ public: return i/2; } - /// getIncomingBlock - Return incoming basic block corresponding - /// to value use iterator - /// - template - BasicBlock *getIncomingBlock(value_use_iterator I) const { - assert(this == *I && "Iterator doesn't point to PHI's Uses?"); - return static_cast((&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(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((&U + 1)->get()); + } + + /// getIncomingBlock - Return incoming basic block corresponding + /// to value use iterator. + /// + template + BasicBlock *getIncomingBlock(value_use_iterator I) const { + return getIncomingBlock(I.getUse()); + } + + void setIncomingBlock(unsigned i, BasicBlock *BB) { setOperand(i*2+1, BB); }