Skip to content

Commit f0da67f

Browse files
committed
rebase
Created using spr 1.3.5-bogner
2 parents a2a1b26 + c0b4a8e commit f0da67f

38 files changed

+111
-120
lines changed

llvm/include/llvm/MC/MCExpr.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,8 @@ class MCSymbolRefExpr : public MCExpr {
256256
const MCSymbol &getSymbol() const { return *Symbol; }
257257

258258
// Some targets encode the relocation specifier within SymA using
259-
// MCSymbolRefExpr::SubclassData and access it via getAccessVariant(), though
260-
// this method is now deprecated.
259+
// MCSymbolRefExpr::SubclassData, which is copied to MCValue::Specifier,
260+
// though this method is now deprecated.
261261
VariantKind getKind() const {
262262
return (VariantKind)(getSubclassData() & VariantKindMask);
263263
}

llvm/include/llvm/MC/MCValue.h

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,16 @@ class MCValue {
3232
int64_t Cst = 0;
3333
uint32_t Specifier = 0;
3434

35+
void print(raw_ostream &OS) const;
36+
37+
/// Print the value to stderr.
38+
void dump() const;
39+
3540
public:
3641
friend class MCAssembler;
3742
friend class MCExpr;
3843
MCValue() = default;
3944
int64_t getConstant() const { return Cst; }
40-
uint32_t getRefKind() const { return Specifier; }
4145
uint32_t getSpecifier() const { return Specifier; }
4246
void setSpecifier(uint32_t S) { Specifier = S; }
4347

@@ -47,18 +51,6 @@ class MCValue {
4751
/// Is this an absolute (as opposed to relocatable) value.
4852
bool isAbsolute() const { return !SymA && !SymB; }
4953

50-
/// Print the value to the stream \p OS.
51-
void print(raw_ostream &OS) const;
52-
53-
/// Print the value to stderr.
54-
void dump() const;
55-
56-
// Get the relocation specifier from SymA. This is a workaround for targets
57-
// that do not use MCValue::Specifier.
58-
uint16_t getSymSpecifier() const { return Specifier; }
59-
// Get the relocation specifier from SymA, or 0 when SymA is null.
60-
uint16_t getAccessVariant() const { return Specifier; }
61-
6254
static MCValue get(const MCSymbol *SymA, const MCSymbol *SymB = nullptr,
6355
int64_t Val = 0, uint32_t Specifier = 0) {
6456
MCValue R;

llvm/lib/MC/MCAssembler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@ bool MCAssembler::isThumbFunc(const MCSymbol *Symbol) const {
122122
if (!Expr->evaluateAsRelocatable(V, nullptr))
123123
return false;
124124

125-
if (V.getSubSym() || V.getRefKind() != MCSymbolRefExpr::VK_None)
125+
if (V.getSubSym() || V.getSpecifier() != MCSymbolRefExpr::VK_None)
126126
return false;
127127

128128
auto *Sym = V.getAddSym();
129-
if (!Sym || V.getSymSpecifier())
129+
if (!Sym || V.getSpecifier())
130130
return false;
131131

132132
if (!isThumbFunc(Sym))

llvm/lib/MC/MCExpr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ bool MCExpr::evaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm,
291291
// Value with RefKind (e.g. %hi(0xdeadbeef) in MIPS) is not considered
292292
// absolute (the value is unknown at parse time), even if it might be resolved
293293
// by evaluateFixup.
294-
return IsRelocatable && Value.isAbsolute() && Value.getRefKind() == 0;
294+
return IsRelocatable && Value.isAbsolute() && Value.getSpecifier() == 0;
295295
}
296296

297297
/// Helper method for \see EvaluateSymbolAdd().
@@ -533,7 +533,7 @@ bool MCExpr::evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm,
533533
// If the reference has a variant kind, we can only handle expressions
534534
// which evaluate exactly to a single unadorned symbol. Attach the
535535
// original VariantKind to SymA of the result.
536-
if (Res.getRefKind() != MCSymbolRefExpr::VK_None ||
536+
if (Res.getSpecifier() != MCSymbolRefExpr::VK_None ||
537537
!Res.getAddSym() || Res.getSubSym() || Res.getConstant())
538538
return false;
539539
Res.Specifier = Kind;

llvm/lib/MC/MCValue.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ void MCValue::print(raw_ostream &OS) const {
2424

2525
// FIXME: prints as a number, which isn't ideal. But the meaning will be
2626
// target-specific anyway.
27-
if (getRefKind())
28-
OS << ':' << getRefKind() << ':';
27+
if (getSpecifier())
28+
OS << ':' << getSpecifier() << ':';
2929

3030
SymA->print(OS, nullptr);
3131

llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8224,7 +8224,7 @@ bool AArch64AsmParser::classifySymbolRef(const MCExpr *Expr,
82248224
return false;
82258225

82268226
if (Res.getAddSym())
8227-
DarwinSpec = AArch64MCExpr::Specifier(Res.getSymSpecifier());
8227+
DarwinSpec = AArch64MCExpr::Specifier(Res.getSpecifier());
82288228
Addend = Res.getConstant();
82298229

82308230
// It's some symbol reference + a constant addend, but really

llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ static uint64_t adjustFixupValue(const MCFixup &Fixup, const MCValue &Target,
222222
return Value >> 4;
223223
case AArch64::fixup_aarch64_movw: {
224224
AArch64MCExpr::Specifier RefKind =
225-
static_cast<AArch64MCExpr::Specifier>(Target.getRefKind());
225+
static_cast<AArch64MCExpr::Specifier>(Target.getSpecifier());
226226
if (AArch64MCExpr::getSymbolLoc(RefKind) != AArch64MCExpr::VK_ABS &&
227227
AArch64MCExpr::getSymbolLoc(RefKind) != AArch64MCExpr::VK_SABS) {
228228
if (!RefKind) {
@@ -422,7 +422,7 @@ void AArch64AsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
422422
bool IsResolved,
423423
const MCSubtargetInfo *STI) const {
424424
if (Fixup.getTargetKind() == FK_Data_8 && TheTriple.isOSBinFormatELF()) {
425-
auto RefKind = static_cast<AArch64MCExpr::Specifier>(Target.getRefKind());
425+
auto RefKind = static_cast<AArch64MCExpr::Specifier>(Target.getSpecifier());
426426
AArch64MCExpr::Specifier SymLoc = AArch64MCExpr::getSymbolLoc(RefKind);
427427
if (SymLoc == AArch64AuthMCExpr::VK_AUTH ||
428428
SymLoc == AArch64AuthMCExpr::VK_AUTHADDR) {
@@ -480,7 +480,7 @@ void AArch64AsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
480480
// FIXME: getFixupKindInfo() and getFixupKindNumBytes() could be fixed to
481481
// handle this more cleanly. This may affect the output of -show-mc-encoding.
482482
AArch64MCExpr::Specifier RefKind =
483-
static_cast<AArch64MCExpr::Specifier>(Target.getRefKind());
483+
static_cast<AArch64MCExpr::Specifier>(Target.getSpecifier());
484484
if (AArch64MCExpr::getSymbolLoc(RefKind) == AArch64MCExpr::VK_SABS ||
485485
(!RefKind && Fixup.getTargetKind() == AArch64::fixup_aarch64_movw)) {
486486
// If the immediate is negative, generate MOVN else MOVZ.

llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ unsigned AArch64ELFObjectWriter::getRelocType(MCContext &Ctx,
112112
if (Kind >= FirstLiteralRelocationKind)
113113
return Kind - FirstLiteralRelocationKind;
114114
AArch64MCExpr::Specifier RefKind =
115-
static_cast<AArch64MCExpr::Specifier>(Target.getRefKind());
115+
static_cast<AArch64MCExpr::Specifier>(Target.getSpecifier());
116116
AArch64MCExpr::Specifier SymLoc = AArch64MCExpr::getSymbolLoc(RefKind);
117117
bool IsNC = AArch64MCExpr::isNotChecked(RefKind);
118118

@@ -137,7 +137,7 @@ unsigned AArch64ELFObjectWriter::getRelocType(MCContext &Ctx,
137137
case FK_Data_2:
138138
return R_CLS(PREL16);
139139
case FK_Data_4: {
140-
return AArch64MCExpr::Specifier(Target.getAccessVariant()) ==
140+
return AArch64MCExpr::Specifier(Target.getSpecifier()) ==
141141
AArch64MCExpr::VK_PLT
142142
? R_CLS(PLT32)
143143
: R_CLS(PREL32);
@@ -249,7 +249,7 @@ unsigned AArch64ELFObjectWriter::getRelocType(MCContext &Ctx,
249249
case FK_Data_2:
250250
return R_CLS(ABS16);
251251
case FK_Data_4:
252-
return (!IsILP32 && AArch64MCExpr::Specifier(Target.getAccessVariant()) ==
252+
return (!IsILP32 && AArch64MCExpr::Specifier(Target.getSpecifier()) ==
253253
AArch64MCExpr::VK_GOTPCREL)
254254
? ELF::R_AARCH64_GOTPCREL32
255255
: R_CLS(ABS32);
@@ -543,10 +543,10 @@ bool AArch64ELFObjectWriter::needsRelocateWithSymbol(const MCValue &Val,
543543
if (Val.getAddSym() && cast<MCSymbolELF>(Val.getAddSym())->isMemtag())
544544
return true;
545545

546-
if ((Val.getRefKind() & AArch64MCExpr::VK_GOT) == AArch64MCExpr::VK_GOT)
546+
if ((Val.getSpecifier() & AArch64MCExpr::VK_GOT) == AArch64MCExpr::VK_GOT)
547547
return true;
548548
return is_contained({AArch64MCExpr::VK_GOTPCREL, AArch64MCExpr::VK_PLT},
549-
AArch64MCExpr::Specifier(Val.getAccessVariant()));
549+
AArch64MCExpr::Specifier(Val.getSpecifier()));
550550
}
551551

552552
std::unique_ptr<MCObjectTargetWriter>

llvm/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ void AArch64MachObjectWriter::recordRelocation(
192192
}
193193

194194
if (!getAArch64FixupKindMachOInfo(
195-
Fixup, Type, AArch64MCExpr::Specifier(Target.getSymSpecifier()),
195+
Fixup, Type, AArch64MCExpr::Specifier(Target.getSpecifier()),
196196
Log2Size, Asm)) {
197197
Asm.getContext().reportError(Fixup.getLoc(), "unknown AArch64 fixup kind!");
198198
return;
@@ -221,7 +221,7 @@ void AArch64MachObjectWriter::recordRelocation(
221221
// Check for "_foo@got - .", which comes through here as:
222222
// Ltmp0:
223223
// ... _foo@got - Ltmp0
224-
if (Target.getSymSpecifier() == AArch64MCExpr::M_GOT &&
224+
if (Target.getSpecifier() == AArch64MCExpr::M_GOT &&
225225
Asm.getSymbolOffset(*B) ==
226226
Asm.getFragmentOffset(*Fragment) + Fixup.getOffset()) {
227227
// SymB is the PC, so use a PC-rel pointer-to-GOT relocation.
@@ -232,7 +232,7 @@ void AArch64MachObjectWriter::recordRelocation(
232232
MRE.r_word1 = (IsPCRel << 24) | (Log2Size << 25) | (Type << 28);
233233
Writer->addRelocation(A_Base, Fragment->getParent(), MRE);
234234
return;
235-
} else if (Target.getSymSpecifier() != AArch64MCExpr::None) {
235+
} else if (Target.getSpecifier() != AArch64MCExpr::None) {
236236
// Otherwise, neither symbol can be modified.
237237
Asm.getContext().reportError(Fixup.getLoc(),
238238
"unsupported relocation of modified symbol");
@@ -391,8 +391,8 @@ void AArch64MachObjectWriter::recordRelocation(
391391
Value = 0;
392392
}
393393

394-
if (Target.getRefKind() == AArch64MCExpr::VK_AUTH ||
395-
Target.getRefKind() == AArch64MCExpr::VK_AUTHADDR) {
394+
if (Target.getSpecifier() == AArch64MCExpr::VK_AUTH ||
395+
Target.getSpecifier() == AArch64MCExpr::VK_AUTHADDR) {
396396
auto *Expr = cast<AArch64AuthMCExpr>(Fixup.getValue());
397397

398398
assert(Type == MachO::ARM64_RELOC_UNSIGNED);

llvm/lib/Target/AArch64/MCTargetDesc/AArch64WinCOFFObjectWriter.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ unsigned AArch64WinCOFFObjectWriter::getRelocType(
6161
FixupKind = FK_PCRel_4;
6262
}
6363

64-
auto Modifier =
65-
Target.isAbsolute() ? AArch64MCExpr::None : Target.getSymSpecifier();
64+
auto Spec = Target.getSpecifier();
6665
const MCExpr *Expr = Fixup.getValue();
6766

6867
if (const AArch64MCExpr *A64E = dyn_cast<AArch64MCExpr>(Expr)) {
@@ -98,7 +97,7 @@ unsigned AArch64WinCOFFObjectWriter::getRelocType(
9897
return COFF::IMAGE_REL_ARM64_REL32;
9998

10099
case FK_Data_4:
101-
switch (Modifier) {
100+
switch (Spec) {
102101
default:
103102
return COFF::IMAGE_REL_ARM64_ADDR32;
104103
case MCSymbolRefExpr::VK_COFF_IMGREL32:

0 commit comments

Comments
 (0)