Skip to content

Commit

Permalink
[MachineOperand] Add a ChangeToGA method
Browse files Browse the repository at this point in the history
Summary:
Analogous to the other ChangeToXXX methods. See the next patch for a
use case.

Change-Id: I6548d614706834fb9109ab3c8fe915e9c6ece2a7

Reviewers: arsenm, kzhuravl

Subscribers: wdng, llvm-commits

Tags: #llvm

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

llvm-svn: 360789
  • Loading branch information
nhaehnle committed May 15, 2019
1 parent 4c50e64 commit f672b61
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions llvm/include/llvm/CodeGen/MachineOperand.h
Expand Up @@ -713,6 +713,10 @@ class MachineOperand {
/// ChangeToES - Replace this operand with a new external symbol operand.
void ChangeToES(const char *SymName, unsigned char TargetFlags = 0);

/// ChangeToGA - Replace this operand with a new global address operand.
void ChangeToGA(const GlobalValue *GV, int64_t Offset,
unsigned char TargetFlags = 0);

/// ChangeToMCSymbol - Replace this operand with a new MC symbol operand.
void ChangeToMCSymbol(MCSymbol *Sym);

Expand Down
13 changes: 13 additions & 0 deletions llvm/lib/CodeGen/MachineOperand.cpp
Expand Up @@ -181,6 +181,19 @@ void MachineOperand::ChangeToES(const char *SymName,
setTargetFlags(TargetFlags);
}

void MachineOperand::ChangeToGA(const GlobalValue *GV, int64_t Offset,
unsigned char TargetFlags) {
assert((!isReg() || !isTied()) &&
"Cannot change a tied operand into a global address");

removeRegFromUses();

OpKind = MO_GlobalAddress;
Contents.OffsetedInfo.Val.GV = GV;
setOffset(Offset);
setTargetFlags(TargetFlags);
}

void MachineOperand::ChangeToMCSymbol(MCSymbol *Sym) {
assert((!isReg() || !isTied()) &&
"Cannot change a tied operand into an MCSymbol");
Expand Down

0 comments on commit f672b61

Please sign in to comment.