diff options
author | Chris Lattner <sabre@nondot.org> | 2006-10-20 22:39:36 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-10-20 22:39:36 +0000 |
commit | 0f4db78dfec0f57beee7cc5af3a55a30e884228c (patch) | |
tree | 283c452fc1bbb9ffb94def3c5d3024da515e69fa | |
parent | af1222c1a7862add472700784dbff077785b4088 (diff) | |
download | bcm5719-llvm-0f4db78dfec0f57beee7cc5af3a55a30e884228c.tar.gz bcm5719-llvm-0f4db78dfec0f57beee7cc5af3a55a30e884228c.zip |
add isIdenticalTo method to machineinstr/operand.
llvm-svn: 31087
-rw-r--r-- | llvm/include/llvm/CodeGen/MachineInstr.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/include/llvm/CodeGen/MachineInstr.h b/llvm/include/llvm/CodeGen/MachineInstr.h index b3955b6c198..ca38fe68f71 100644 --- a/llvm/include/llvm/CodeGen/MachineInstr.h +++ b/llvm/include/llvm/CodeGen/MachineInstr.h @@ -118,6 +118,10 @@ public: assert(isImm() && "Wrong MachineOperand accessor"); return contents.immedVal; } + MachineBasicBlock *getMBB() const { + assert(isMachineBasicBlock() && "Wrong MachineOperand accessor"); + return contents.MBB; + } MachineBasicBlock *getMachineBasicBlock() const { assert(isMachineBasicBlock() && "Wrong MachineOperand accessor"); return contents.MBB; @@ -203,6 +207,9 @@ public: contents.immedVal = Idx; } + /// isIdenticalTo - Return true if this operand is identical to the specified + /// operand. + bool isIdenticalTo(const MachineOperand &Other) const; /// ChangeToImmediate - Replace this operand with a new immediate operand of /// the specified value. If an operand is known to be an immediate already, @@ -279,6 +286,18 @@ public: return Operands[i]; } + + /// isIdenticalTo - Return true if this instruction is identical to (same + /// opcode and same operands as) the specified instruction. + bool isIdenticalTo(const MachineInstr *Other) const { + if (Other->getOpcode() != getOpcode() || + getNumOperands() != getNumOperands()) + return false; + for (unsigned i = 0, e = getNumOperands(); i != e; ++i) + if (!getOperand(i).isIdenticalTo(Other->getOperand(i))) + return false; + return true; + } /// clone - Create a copy of 'this' instruction that is identical in /// all ways except the the instruction has no parent, prev, or next. |