diff options
author | Chad Rosier <mcrosier@apple.com> | 2011-06-21 02:09:03 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@apple.com> | 2011-06-21 02:09:03 +0000 |
commit | a88a0ca8082006b37d14d8aee4a644b20bae8bc9 (patch) | |
tree | 50672ebd357c0af7075c51ab546813243c10b978 /include/llvm/Instructions.h | |
parent | 805569f54aa5ac3ac4c59a008ba68913177b3ce8 (diff) | |
download | llvm-a88a0ca8082006b37d14d8aee4a644b20bae8bc9.tar.gz llvm-a88a0ca8082006b37d14d8aee4a644b20bae8bc9.tar.bz2 llvm-a88a0ca8082006b37d14d8aee4a644b20bae8bc9.tar.xz |
Revert r133435 and r133449 to appease buildbots.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133499 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Instructions.h')
-rw-r--r-- | include/llvm/Instructions.h | 81 |
1 files changed, 30 insertions, 51 deletions
diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h index cc3801043e..54dfe3957f 100644 --- a/include/llvm/Instructions.h +++ b/include/llvm/Instructions.h @@ -1814,7 +1814,7 @@ class PHINode : public Instruction { explicit PHINode(const Type *Ty, unsigned NumReservedValues, const Twine &NameStr = "", Instruction *InsertBefore = 0) : Instruction(Ty, Instruction::PHI, 0, 0, InsertBefore), - ReservedSpace(NumReservedValues) { + ReservedSpace(NumReservedValues * 2) { setName(NameStr); OperandList = allocHungoffUses(ReservedSpace); } @@ -1822,16 +1822,11 @@ class PHINode : public Instruction { PHINode(const Type *Ty, unsigned NumReservedValues, const Twine &NameStr, BasicBlock *InsertAtEnd) : Instruction(Ty, Instruction::PHI, 0, 0, InsertAtEnd), - ReservedSpace(NumReservedValues) { + ReservedSpace(NumReservedValues * 2) { setName(NameStr); OperandList = allocHungoffUses(ReservedSpace); } protected: - // allocHungoffUses - this is more complicated than the generic - // User::allocHungoffUses, because we have to allocate Uses for the incoming - // values and pointers to the incoming blocks, all in one allocation. - Use *allocHungoffUses(unsigned) const; - virtual PHINode *clone_impl() const; public: /// Constructors - NumReservedValues is a hint for the number of incoming @@ -1850,55 +1845,32 @@ public: /// Provide fast operand accessors DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); - // Block iterator interface. This provides access to the list of incoming - // basic blocks, which parallels the list of incoming values. - - typedef BasicBlock **block_iterator; - typedef BasicBlock * const *const_block_iterator; - - block_iterator block_begin() { - Use::UserRef *ref = - reinterpret_cast<Use::UserRef*>(op_begin() + ReservedSpace); - return reinterpret_cast<block_iterator>(ref + 1); - } - - const_block_iterator block_begin() const { - const Use::UserRef *ref = - reinterpret_cast<const Use::UserRef*>(op_begin() + ReservedSpace); - return reinterpret_cast<const_block_iterator>(ref + 1); - } - - block_iterator block_end() { - return block_begin() + getNumOperands(); - } - - const_block_iterator block_end() const { - return block_begin() + getNumOperands(); - } - /// getNumIncomingValues - Return the number of incoming edges /// - unsigned getNumIncomingValues() const { return getNumOperands(); } + unsigned getNumIncomingValues() const { return getNumOperands()/2; } /// getIncomingValue - Return incoming value number x /// Value *getIncomingValue(unsigned i) const { - return getOperand(i); + assert(i*2 < getNumOperands() && "Invalid value number!"); + return getOperand(i*2); } void setIncomingValue(unsigned i, Value *V) { - setOperand(i, V); + assert(i*2 < getNumOperands() && "Invalid value number!"); + setOperand(i*2, V); } static unsigned getOperandNumForIncomingValue(unsigned i) { - return i; + return i*2; } static unsigned getIncomingValueNumForOperand(unsigned i) { - return i; + assert(i % 2 == 0 && "Invalid incoming-value operand index!"); + return i/2; } /// getIncomingBlock - Return incoming basic block number @p i. /// BasicBlock *getIncomingBlock(unsigned i) const { - return block_begin()[i]; + return cast<BasicBlock>(getOperand(i*2+1)); } /// getIncomingBlock - Return incoming basic block corresponding @@ -1906,7 +1878,7 @@ public: /// BasicBlock *getIncomingBlock(const Use &U) const { assert(this == U.getUser() && "Iterator doesn't point to PHI's Uses?"); - return getIncomingBlock(&U - op_begin()); + return cast<BasicBlock>((&U + 1)->get()); } /// getIncomingBlock - Return incoming basic block corresponding @@ -1917,8 +1889,16 @@ public: return getIncomingBlock(I.getUse()); } + void setIncomingBlock(unsigned i, BasicBlock *BB) { - block_begin()[i] = BB; + setOperand(i*2+1, (Value*)BB); + } + static unsigned getOperandNumForIncomingBlock(unsigned i) { + return i*2+1; + } + static unsigned getIncomingBlockNumForOperand(unsigned i) { + assert(i % 2 == 1 && "Invalid incoming-block operand index!"); + return i/2; } /// addIncoming - Add an incoming value to the end of the PHI list @@ -1928,12 +1908,13 @@ public: assert(BB && "PHI node got a null basic block!"); assert(getType() == V->getType() && "All operands to PHI node must be the same type as the PHI node!"); - if (NumOperands == ReservedSpace) + unsigned OpNo = NumOperands; + if (OpNo+2 > ReservedSpace) growOperands(); // Get more space! // Initialize some new operands. - ++NumOperands; - setIncomingValue(NumOperands - 1, V); - setIncomingBlock(NumOperands - 1, BB); + NumOperands = OpNo+2; + OperandList[OpNo] = V; + OperandList[OpNo+1] = (Value*)BB; } /// removeIncomingValue - Remove an incoming value. This is useful if a @@ -1956,16 +1937,14 @@ public: /// block in the value list for this PHI. Returns -1 if no instance. /// int getBasicBlockIndex(const BasicBlock *BB) const { - for (unsigned i = 0, e = getNumOperands(); i != e; ++i) - if (block_begin()[i] == BB) - return i; + Use *OL = OperandList; + for (unsigned i = 0, e = getNumOperands(); i != e; i += 2) + if (OL[i+1].get() == (const Value*)BB) return i/2; return -1; } Value *getIncomingValueForBlock(const BasicBlock *BB) const { - int Idx = getBasicBlockIndex(BB); - assert(Idx >= 0 && "Invalid basic block argument!"); - return getIncomingValue(Idx); + return getIncomingValue(getBasicBlockIndex(BB)); } /// hasConstantValue - If the specified PHI node always merges together the |