diff options
author | Evan Cheng <evan.cheng@apple.com> | 2010-03-03 21:54:14 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2010-03-03 21:54:14 +0000 |
commit | 0f260e1785c87f1e117609cf40b212bdfb3d3f47 (patch) | |
tree | ad1ece1c07bee6b9e6de300e005d3b84bc085ad6 /llvm/lib/CodeGen/MachineInstr.cpp | |
parent | 576def7fbe757b62742de5dbe9787a82983ffb8e (diff) | |
download | bcm5719-llvm-0f260e1785c87f1e117609cf40b212bdfb3d3f47.tar.gz bcm5719-llvm-0f260e1785c87f1e117609cf40b212bdfb3d3f47.zip |
Fix funky indentation and add comments.
llvm-svn: 97670
Diffstat (limited to 'llvm/lib/CodeGen/MachineInstr.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineInstr.cpp | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp index cba93f14a0b..08c6b774b92 100644 --- a/llvm/lib/CodeGen/MachineInstr.cpp +++ b/llvm/lib/CodeGen/MachineInstr.cpp @@ -704,24 +704,31 @@ void MachineInstr::addMemOperand(MachineFunction &MF, bool MachineInstr::isIdenticalTo(const MachineInstr *Other, MICheckType Check) const { - if (Other->getOpcode() != getOpcode() || - Other->getNumOperands() != getNumOperands()) + // If opcodes or number of operands are not the same then the two + // instructions are obviously not identical. + if (Other->getOpcode() != getOpcode() || + Other->getNumOperands() != getNumOperands()) + return false; + + // Check operands to make sure they match. + for (unsigned i = 0, e = getNumOperands(); i != e; ++i) { + const MachineOperand &MO = getOperand(i); + const MachineOperand &OMO = Other->getOperand(i); + // Clients may or may not want to ignore defs when testing for equality. + // For example, machine CSE pass only cares about finding common + // subexpressions, so it's safe to ignore virtual register defs. + if (Check != CheckDefs && MO.isReg() && MO.isDef()) { + if (Check == IgnoreDefs) + continue; + // Check == IgnoreVRegDefs + if (TargetRegisterInfo::isPhysicalRegister(MO.getReg()) || + TargetRegisterInfo::isPhysicalRegister(OMO.getReg())) + if (MO.getReg() != OMO.getReg()) + return false; + } else if (!MO.isIdenticalTo(OMO)) return false; - for (unsigned i = 0, e = getNumOperands(); i != e; ++i) { - const MachineOperand &MO = getOperand(i); - const MachineOperand &OMO = Other->getOperand(i); - if (Check != CheckDefs && MO.isReg() && MO.isDef()) { - if (Check == IgnoreDefs) - continue; - // Check == IgnoreVRegDefs - if (TargetRegisterInfo::isPhysicalRegister(MO.getReg()) || - TargetRegisterInfo::isPhysicalRegister(OMO.getReg())) - if (MO.getReg() != OMO.getReg()) - return false; - } else if (!MO.isIdenticalTo(OMO)) - return false; - } - return true; + } + return true; } /// removeFromParent - This method unlinks 'this' from the containing basic |