From: Marcello Maggioni Date: Fri, 4 Aug 2017 18:24:09 +0000 (+0000) Subject: [MachineOperand] Add ChangeToTargetIndex method. NFC X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3b0297768d9db9577207ccb84e180c3f9d0992e1;p=llvm [MachineOperand] Add ChangeToTargetIndex method. NFC Differential Revision: https://reviews.llvm.org/D36301 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310083 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/CodeGen/MachineOperand.h b/include/llvm/CodeGen/MachineOperand.h index f1e6ac77860..8cf75f23ed5 100644 --- a/include/llvm/CodeGen/MachineOperand.h +++ b/include/llvm/CodeGen/MachineOperand.h @@ -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. diff --git a/lib/CodeGen/MachineInstr.cpp b/lib/CodeGen/MachineInstr.cpp index 6fd49e30aae..8bf1eb9e33d 100644 --- a/lib/CodeGen/MachineInstr.cpp +++ b/lib/CodeGen/MachineInstr.cpp @@ -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.