1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

Add method MachineInstr::substituteValue() which substitutes

one Value with another one in all operands and implicit references
of the machine instruction.

llvm-svn: 3306
This commit is contained in:
Vikram S. Adve 2002-08-14 16:52:58 +00:00
parent 15f89e22b8
commit 87928f2098

View File

@ -77,6 +77,35 @@ MachineInstr::SetRegForOperand(unsigned i, int regNum)
}
// Subsitute all occurrences of Value* oldVal with newVal in all operands
// and all implicit refs. If defsOnly == true, substitute defs only.
unsigned
MachineInstr::substituteValue(const Value* oldVal, Value* newVal, bool defsOnly)
{
unsigned numSubst = 0;
// Subsitute operands
for (MachineInstr::val_op_iterator O = begin(), E = end(); O != E; ++O)
if (*O == oldVal)
if (!defsOnly || O.isDef())
{
O.getMachineOperand().value = newVal;
++numSubst;
}
// Subsitute implicit refs
for (unsigned i=0, N=implicitRefs.size(); i < N; ++i)
if (implicitRefs[i] == oldVal)
if (!defsOnly || implicitRefIsDefined(i))
{
implicitRefs[i] = newVal;
++numSubst;
}
return numSubst;
}
void
MachineInstr::dump() const
{