[llvm-commits] CVS: llvm/lib/CodeGen/MachineInstr.cpp

Chris Lattner sabre at nondot.org
Fri Oct 20 15:40:14 PDT 2006



Changes in directory llvm/lib/CodeGen:

MachineInstr.cpp updated: 1.125 -> 1.126
---
Log message:

implement MachineOperand::isIdenticalTo


---
Diffs of the changes:  (+29 -0)

 MachineInstr.cpp |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+)


Index: llvm/lib/CodeGen/MachineInstr.cpp
diff -u llvm/lib/CodeGen/MachineInstr.cpp:1.125 llvm/lib/CodeGen/MachineInstr.cpp:1.126
--- llvm/lib/CodeGen/MachineInstr.cpp:1.125	Tue Sep  5 15:19:27 2006
+++ llvm/lib/CodeGen/MachineInstr.cpp	Fri Oct 20 17:39:59 2006
@@ -97,6 +97,35 @@
   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;
 }






More information about the llvm-commits mailing list