diff options
Diffstat (limited to 'lib/CodeGen/MachineInstr.cpp')
| -rw-r--r-- | lib/CodeGen/MachineInstr.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/lib/CodeGen/MachineInstr.cpp b/lib/CodeGen/MachineInstr.cpp index d909fb0ef3..553b13938c 100644 --- a/lib/CodeGen/MachineInstr.cpp +++ b/lib/CodeGen/MachineInstr.cpp @@ -781,7 +781,30 @@ int MachineInstr::findRegisterUseOperandIdx(unsigned Reg, bool isKill, } return -1; } - + +/// readsVirtualRegister - Return true if the MachineInstr reads the specified +/// virtual register. Take into account that a partial define is a +/// read-modify-write operation. +bool MachineInstr::readsVirtualRegister(unsigned Reg) const { + bool PartDef = false; // Partial redefine + bool FullDef = false; // Full define + + for (unsigned i = 0, e = getNumOperands(); i != e; ++i) { + const MachineOperand &MO = getOperand(i); + if (!MO.isReg() || MO.getReg() != Reg) + continue; + if (MO.isUse()) + return true; + if (MO.getSubReg()) + PartDef = true; + else + FullDef = true; + } + // A partial register definition causes a read unless the full register is + // also defined. + return PartDef && !FullDef; +} + /// findRegisterDefOperandIdx() - Returns the operand index that is a def of /// the specified register or -1 if it is not found. If isDead is true, defs /// that are not dead are skipped. If TargetRegisterInfo is non-null, then it |
