mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-13 06:39:12 +00:00
Make removeUser more efficient, add a matching addUser.
Fix the setOperands methods I added to update use/def information correctly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22832 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
02659d2363
commit
8c3484c518
@ -641,25 +641,33 @@ protected:
|
||||
void setOperands(SDOperand Op0) {
|
||||
Operands.reserve(1);
|
||||
Operands.push_back(Op0);
|
||||
Op0.Val->Uses.push_back(this);
|
||||
}
|
||||
void setOperands(SDOperand Op0, SDOperand Op1) {
|
||||
Operands.reserve(2);
|
||||
Operands.push_back(Op0);
|
||||
Operands.push_back(Op1);
|
||||
Op0.Val->Uses.push_back(this); Op1.Val->Uses.push_back(this);
|
||||
}
|
||||
void setOperands(SDOperand Op0, SDOperand Op1, SDOperand Op2) {
|
||||
Operands.reserve(3);
|
||||
Operands.push_back(Op0);
|
||||
Operands.push_back(Op1);
|
||||
Operands.push_back(Op2);
|
||||
Op0.Val->Uses.push_back(this); Op1.Val->Uses.push_back(this);
|
||||
Op2.Val->Uses.push_back(this);
|
||||
}
|
||||
void addUser(SDNode *User) {
|
||||
Uses.push_back(User);
|
||||
}
|
||||
void removeUser(SDNode *User) {
|
||||
// Remove this user from the operand's use list.
|
||||
for (unsigned i = Uses.size(); ; --i) {
|
||||
assert(i != 0 && "Didn't find user!");
|
||||
if (Uses[i-1] == User) {
|
||||
Uses.erase(Uses.begin()+i-1);
|
||||
break;
|
||||
Uses[i-1] = Uses.back();
|
||||
Uses.pop_back();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user