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 | 33f5af09e4d7a6fd447b9f204eb2b17e598794c6 (patch) | |
tree | 69ffa93d97c2fded3eacd1edde3c2779ef130f16 /llvm/lib/CodeGen/MachineInstr.cpp | |
parent | 0f4db78dfec0f57beee7cc5af3a55a30e884228c (diff) | |
download | bcm5719-llvm-33f5af09e4d7a6fd447b9f204eb2b17e598794c6.tar.gz bcm5719-llvm-33f5af09e4d7a6fd447b9f204eb2b17e598794c6.zip |
implement MachineOperand::isIdenticalTo
llvm-svn: 31088
Diffstat (limited to 'llvm/lib/CodeGen/MachineInstr.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineInstr.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp index 182e664e675..9affc696c1b 100644 --- a/llvm/lib/CodeGen/MachineInstr.cpp +++ b/llvm/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; } |