From ceaa457a9d1ec567862e71125447479304942c12 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83702 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Instructions.h | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h index c71d64ab072..4ba7c084f07 100644 --- a/include/llvm/Instructions.h +++ b/include/llvm/Instructions.h @@ -1910,19 +1910,29 @@ public: return i/2; } + /// 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 value use iterator + /// to an operand of the PHI. /// - 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()); + 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 number x + + /// getIncomingBlock - Return incoming basic block corresponding + /// to value use iterator. /// - BasicBlock *getIncomingBlock(unsigned i) const { - return static_cast(getOperand(i*2+1)); + template + BasicBlock *getIncomingBlock(value_use_iterator I) const { + return getIncomingBlock(I.getUse()); } + + void setIncomingBlock(unsigned i, BasicBlock *BB) { setOperand(i*2+1, BB); } -- 2.34.1