diff options
author | Chris Lattner <sabre@nondot.org> | 2006-10-20 22:39:59 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-10-20 22:39:59 +0000 |
commit | 8ace2cd034be10c09be51daf08c3dda327f54262 (patch) | |
tree | 75e31fcadda3e92f45adccf3fb62e2cb0e0f7763 /lib/CodeGen/MachineInstr.cpp | |
parent | fcfcb6cb502fd4562b57425a5802dc52f358c451 (diff) |
implement MachineOperand::isIdenticalTo
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31088 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/MachineInstr.cpp')
-rw-r--r-- | lib/CodeGen/MachineInstr.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/CodeGen/MachineInstr.cpp b/lib/CodeGen/MachineInstr.cpp index 182e664e67..9affc696c1 100644 --- a/lib/CodeGen/MachineInstr.cpp +++ b/lib/CodeGen/MachineInstr.cpp @@ -97,6 +97,35 @@ bool MachineInstr::OperandsComplete() const { return false; } +/// isIdenticalTo - Return true if this operand is identical to the specified +/// operand. +bool MachineOperand::isIdenticalTo(const MachineOperand &Other) const { + if (getType() != Other.getType()) return false; + + switch (getType()) { + default: assert(0 && "Unrecognized operand type"); + case MachineOperand::MO_Register: + return getReg() == Other.getReg() && isDef() == Other.isDef(); + case MachineOperand::MO_Immediate: + return getImm() == Other.getImm(); + case MachineOperand::MO_MachineBasicBlock: + return getMBB() == Other.getMBB(); + case MachineOperand::MO_FrameIndex: + return getFrameIndex() == Other.getFrameIndex(); + case MachineOperand::MO_ConstantPoolIndex: + return getConstantPoolIndex() == Other.getConstantPoolIndex() && + getOffset() == Other.getOffset(); + case MachineOperand::MO_JumpTableIndex: + return getJumpTableIndex() == Other.getJumpTableIndex(); + case MachineOperand::MO_GlobalAddress: + return getGlobal() == Other.getGlobal() && getOffset() == Other.getOffset(); + case MachineOperand::MO_ExternalSymbol: + return getSymbolName() == Other.getSymbolName() && + getOffset() == Other.getOffset(); + } +} + + void MachineInstr::dump() const { std::cerr << " " << *this; } |