mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-09 11:25:55 +00:00
Simplify some of the PHI node interfaces
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5700 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -61,7 +61,12 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// addIncoming - Add an incoming value to the end of the PHI list
|
/// addIncoming - Add an incoming value to the end of the PHI list
|
||||||
void addIncoming(Value *D, BasicBlock *BB);
|
void addIncoming(Value *D, BasicBlock *BB) {
|
||||||
|
assert(getType() == D->getType() &&
|
||||||
|
"All operands to PHI node must be the same type as the PHI node!");
|
||||||
|
Operands.push_back(Use(D, this));
|
||||||
|
Operands.push_back(Use((Value*)BB, this));
|
||||||
|
}
|
||||||
|
|
||||||
/// removeIncomingValue - Remove an incoming value. This is useful if a
|
/// removeIncomingValue - Remove an incoming value. This is useful if a
|
||||||
/// predecessor basic block is deleted. The value removed is returned.
|
/// predecessor basic block is deleted. The value removed is returned.
|
||||||
@@ -71,8 +76,13 @@ public:
|
|||||||
/// dummy values. The only time there should be zero incoming values to a PHI
|
/// dummy values. The only time there should be zero incoming values to a PHI
|
||||||
/// node is when the block is dead, so this strategy is sound.
|
/// node is when the block is dead, so this strategy is sound.
|
||||||
///
|
///
|
||||||
Value *removeIncomingValue(const BasicBlock *BB,
|
Value *removeIncomingValue(unsigned Idx, bool DeletePHIIfEmpty = true);
|
||||||
bool DeletePHIIfEmpty = true);
|
|
||||||
|
Value *removeIncomingValue(const BasicBlock *BB, bool DeletePHIIfEmpty =true){
|
||||||
|
int Idx = getBasicBlockIndex(BB);
|
||||||
|
assert(Idx >= 0 && "Invalid basic block argument to remove!");
|
||||||
|
return removeIncomingValue(Idx, DeletePHIIfEmpty);
|
||||||
|
}
|
||||||
|
|
||||||
/// getBasicBlockIndex - Return the first index of the specified basic
|
/// getBasicBlockIndex - Return the first index of the specified basic
|
||||||
/// block in the value list for this PHI. Returns -1 if no instance.
|
/// block in the value list for this PHI. Returns -1 if no instance.
|
||||||
|
@@ -33,22 +33,13 @@ PHINode::PHINode(const PHINode &PN)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PHINode::addIncoming(Value *D, BasicBlock *BB) {
|
|
||||||
assert(getType() == D->getType() &&
|
|
||||||
"All operands to PHI node must be the same type as the PHI node!");
|
|
||||||
Operands.push_back(Use(D, this));
|
|
||||||
Operands.push_back(Use(BB, this));
|
|
||||||
}
|
|
||||||
|
|
||||||
// removeIncomingValue - Remove an incoming value. This is useful if a
|
// removeIncomingValue - Remove an incoming value. This is useful if a
|
||||||
// predecessor basic block is deleted.
|
// predecessor basic block is deleted.
|
||||||
Value *PHINode::removeIncomingValue(const BasicBlock *BB,
|
Value *PHINode::removeIncomingValue(unsigned Idx, bool DeletePHIIfEmpty) {
|
||||||
bool DeletePHIIfEmpty) {
|
assert(Idx*2 < Operands.size() && "BB not in PHI node!");
|
||||||
op_iterator Idx = find(Operands.begin(), Operands.end(), (const Value*)BB);
|
Value *Removed = Operands[Idx*2];
|
||||||
assert(Idx != Operands.end() && "BB not in PHI node!");
|
Operands.erase(Operands.begin()+Idx*2, // Erase Value and BasicBlock
|
||||||
--Idx; // Back up to value prior to Basic block
|
Operands.begin()+Idx*2+2);
|
||||||
Value *Removed = *Idx;
|
|
||||||
Operands.erase(Idx, Idx+2); // Erase Value and BasicBlock
|
|
||||||
|
|
||||||
// If the PHI node is dead, because it has zero entries, nuke it now.
|
// If the PHI node is dead, because it has zero entries, nuke it now.
|
||||||
if (getNumOperands() == 0 && DeletePHIIfEmpty) {
|
if (getNumOperands() == 0 && DeletePHIIfEmpty) {
|
||||||
|
Reference in New Issue
Block a user