Skip to content

Commit f672b61

Browse files
committedMay 15, 2019
[MachineOperand] Add a ChangeToGA method
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
1 parent 4c50e64 commit f672b61

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed
 

‎llvm/include/llvm/CodeGen/MachineOperand.h

+4
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,10 @@ class MachineOperand {
713713
/// ChangeToES - Replace this operand with a new external symbol operand.
714714
void ChangeToES(const char *SymName, unsigned char TargetFlags = 0);
715715

716+
/// ChangeToGA - Replace this operand with a new global address operand.
717+
void ChangeToGA(const GlobalValue *GV, int64_t Offset,
718+
unsigned char TargetFlags = 0);
719+
716720
/// ChangeToMCSymbol - Replace this operand with a new MC symbol operand.
717721
void ChangeToMCSymbol(MCSymbol *Sym);
718722

‎llvm/lib/CodeGen/MachineOperand.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,19 @@ void MachineOperand::ChangeToES(const char *SymName,
181181
setTargetFlags(TargetFlags);
182182
}
183183

184+
void MachineOperand::ChangeToGA(const GlobalValue *GV, int64_t Offset,
185+
unsigned char TargetFlags) {
186+
assert((!isReg() || !isTied()) &&
187+
"Cannot change a tied operand into a global address");
188+
189+
removeRegFromUses();
190+
191+
OpKind = MO_GlobalAddress;
192+
Contents.OffsetedInfo.Val.GV = GV;
193+
setOffset(Offset);
194+
setTargetFlags(TargetFlags);
195+
}
196+
184197
void MachineOperand::ChangeToMCSymbol(MCSymbol *Sym) {
185198
assert((!isReg() || !isTied()) &&
186199
"Cannot change a tied operand into an MCSymbol");

0 commit comments

Comments
 (0)
Please sign in to comment.