[MachineOperand] Add ChangeToTargetIndex method. NFC
authorMarcello Maggioni <hayarms@gmail.com>
Fri, 4 Aug 2017 18:24:09 +0000 (18:24 +0000)
committerMarcello Maggioni <hayarms@gmail.com>
Fri, 4 Aug 2017 18:24:09 +0000 (18:24 +0000)
Differential Revision: https://reviews.llvm.org/D36301

llvm-svn: 310083

llvm/include/llvm/CodeGen/MachineOperand.h
llvm/lib/CodeGen/MachineInstr.cpp

index f1e6ac7..8cf75f2 100644 (file)
@@ -602,6 +602,10 @@ public:
   /// Replace this operand with a frame index.
   void ChangeToFrameIndex(int Idx);
 
+  /// Replace this operand with a target index.
+  void ChangeToTargetIndex(unsigned Idx, int64_t Offset,
+                           unsigned char TargetFlags = 0);
+
   /// ChangeToRegister - Replace this operand with a new register operand of
   /// the specified value.  If an operand is known to be an register already,
   /// the setReg method should be used.
index 6fd49e3..8bf1eb9 100644 (file)
@@ -213,6 +213,19 @@ void MachineOperand::ChangeToFrameIndex(int Idx) {
   setIndex(Idx);
 }
 
+void MachineOperand::ChangeToTargetIndex(unsigned Idx, int64_t Offset,
+                                         unsigned char TargetFlags) {
+  assert((!isReg() || !isTied()) &&
+         "Cannot change a tied operand into a FrameIndex");
+
+  removeRegFromUses();
+
+  OpKind = MO_TargetIndex;
+  setIndex(Idx);
+  setOffset(Offset);
+  setTargetFlags(TargetFlags);
+}
+
 /// ChangeToRegister - Replace this operand with a new register operand of
 /// the specified value.  If an operand is known to be an register already,
 /// the setReg method should be used.