Add a utility function to MachineInstr for testing whether an instruction
[oota-llvm.git] / include / llvm / CodeGen / MachineInstr.h
index 88116d2bb21bbdfc41a00027a9234ec26fb45a34..31f497469918ee0f6adc8fd816fbbe7258beaeb4 100644 (file)
@@ -115,6 +115,13 @@ public:
   { return MemOperands.end(); }
   bool memoperands_empty() const { return MemOperands.empty(); }
 
+  /// hasOneMemOperand - Return true if this instruction has exactly one
+  /// MachineMemOperand.
+  bool hasOneMemOperand() const {
+    return !memoperands_empty() &&
+           next(memoperands_begin()) == memoperands_end();
+  }
+
   /// isIdenticalTo - Return true if this instruction is identical to (same
   /// opcode and same operands as) the specified instruction.
   bool isIdenticalTo(const MachineInstr *Other) const {