[MachineOperand] Add ChangeToTargetIndex method. NFC

Differential Revision: https://reviews.llvm.org/D36301

llvm-svn: 310083
This commit is contained in:
Marcello Maggioni 2017-08-04 18:24:09 +00:00
parent 39195062c2
commit 8de4bbdaa5
2 changed files with 17 additions and 0 deletions

View 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.

View 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.