-
Notifications
You must be signed in to change notification settings - Fork 14.1k
[AArch64] Rename VariantKind to Specifier #132595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AArch64] Rename VariantKind to Specifier #132595
Conversation
Created using spr 1.3.5-bogner
@llvm/pr-subscribers-mc @llvm/pr-subscribers-backend-aarch64 Author: Fangrui Song (MaskRay) ChangesFollow the naming of most other backends. > "Relocation modifier" suggests adjustments happen during the linker's relocation step rather than the assembler's expression evaluation. In addition, rename DarwinRefKind, which still uses MCSymbolRefExpr::VariantKind, is not renamed. Patch is 28.38 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/132595.diff 9 Files Affected:
diff --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
index 79b190388eb75..4178d00782a7e 100644
--- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
@@ -923,14 +923,14 @@ void AArch64AsmPrinter::emitHwasanMemaccessSymbols(Module &M) {
MCInstBuilder(AArch64::ADRP)
.addReg(AArch64::X16)
.addExpr(AArch64MCExpr::create(
- HwasanTagMismatchRef, AArch64MCExpr::VariantKind::VK_GOT_PAGE,
+ HwasanTagMismatchRef, AArch64MCExpr::Specifier::VK_GOT_PAGE,
OutContext)));
EmitToStreamer(
MCInstBuilder(AArch64::LDRXui)
.addReg(AArch64::X16)
.addReg(AArch64::X16)
.addExpr(AArch64MCExpr::create(
- HwasanTagMismatchRef, AArch64MCExpr::VariantKind::VK_GOT_LO12,
+ HwasanTagMismatchRef, AArch64MCExpr::Specifier::VK_GOT_LO12,
OutContext)));
EmitToStreamer(MCInstBuilder(AArch64::BR).addReg(AArch64::X16));
}
diff --git a/llvm/lib/Target/AArch64/AArch64MCInstLower.cpp b/llvm/lib/Target/AArch64/AArch64MCInstLower.cpp
index db8522cabd681..6a02a75ddbb4d 100644
--- a/llvm/lib/Target/AArch64/AArch64MCInstLower.cpp
+++ b/llvm/lib/Target/AArch64/AArch64MCInstLower.cpp
@@ -266,8 +266,8 @@ MCOperand AArch64MCInstLower::lowerSymbolOperandELF(const MachineOperand &MO,
Expr = MCBinaryExpr::createAdd(
Expr, MCConstantExpr::create(MO.getOffset(), Ctx), Ctx);
- AArch64MCExpr::VariantKind RefKind;
- RefKind = static_cast<AArch64MCExpr::VariantKind>(RefFlags);
+ AArch64MCExpr::Specifier RefKind;
+ RefKind = static_cast<AArch64MCExpr::Specifier>(RefFlags);
Expr = AArch64MCExpr::create(Expr, RefKind, Ctx);
return MCOperand::createExpr(Expr);
@@ -320,7 +320,7 @@ MCOperand AArch64MCInstLower::lowerSymbolOperandCOFF(const MachineOperand &MO,
Expr = MCBinaryExpr::createAdd(
Expr, MCConstantExpr::create(MO.getOffset(), Ctx), Ctx);
- auto RefKind = static_cast<AArch64MCExpr::VariantKind>(RefFlags);
+ auto RefKind = static_cast<AArch64MCExpr::Specifier>(RefFlags);
assert(RefKind != AArch64MCExpr::VK_INVALID &&
"Invalid relocation requested");
Expr = AArch64MCExpr::create(Expr, RefKind, Ctx);
diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
index d678dd88e05da..b107a9a9e8776 100644
--- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
+++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
@@ -338,7 +338,7 @@ class AArch64AsmParser : public MCTargetAsmParser {
bool parsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc) override;
static bool classifySymbolRef(const MCExpr *Expr,
- AArch64MCExpr::VariantKind &ELFRefKind,
+ AArch64MCExpr::Specifier &ELFSpec,
MCSymbolRefExpr::VariantKind &DarwinRefKind,
int64_t &Addend);
};
@@ -888,30 +888,26 @@ class AArch64Operand : public MCParsedAsmOperand {
}
bool isSymbolicUImm12Offset(const MCExpr *Expr) const {
- AArch64MCExpr::VariantKind ELFRefKind;
+ AArch64MCExpr::Specifier ELFSpec;
MCSymbolRefExpr::VariantKind DarwinRefKind;
int64_t Addend;
- if (!AArch64AsmParser::classifySymbolRef(Expr, ELFRefKind, DarwinRefKind,
- Addend)) {
+ if (!AArch64AsmParser::classifySymbolRef(Expr, ELFSpec, DarwinRefKind,
+ Addend)) {
// If we don't understand the expression, assume the best and
// let the fixup and relocation code deal with it.
return true;
}
if (DarwinRefKind == MCSymbolRefExpr::VK_PAGEOFF ||
- ELFRefKind == AArch64MCExpr::VK_LO12 ||
- ELFRefKind == AArch64MCExpr::VK_GOT_LO12 ||
- ELFRefKind == AArch64MCExpr::VK_GOT_AUTH_LO12 ||
- ELFRefKind == AArch64MCExpr::VK_DTPREL_LO12 ||
- ELFRefKind == AArch64MCExpr::VK_DTPREL_LO12_NC ||
- ELFRefKind == AArch64MCExpr::VK_TPREL_LO12 ||
- ELFRefKind == AArch64MCExpr::VK_TPREL_LO12_NC ||
- ELFRefKind == AArch64MCExpr::VK_GOTTPREL_LO12_NC ||
- ELFRefKind == AArch64MCExpr::VK_TLSDESC_LO12 ||
- ELFRefKind == AArch64MCExpr::VK_TLSDESC_AUTH_LO12 ||
- ELFRefKind == AArch64MCExpr::VK_SECREL_LO12 ||
- ELFRefKind == AArch64MCExpr::VK_SECREL_HI12 ||
- ELFRefKind == AArch64MCExpr::VK_GOT_PAGE_LO15) {
+ llvm::is_contained(
+ {AArch64MCExpr::VK_LO12, AArch64MCExpr::VK_GOT_LO12,
+ AArch64MCExpr::VK_GOT_AUTH_LO12, AArch64MCExpr::VK_DTPREL_LO12,
+ AArch64MCExpr::VK_DTPREL_LO12_NC, AArch64MCExpr::VK_TPREL_LO12,
+ AArch64MCExpr::VK_TPREL_LO12_NC,
+ AArch64MCExpr::VK_GOTTPREL_LO12_NC, AArch64MCExpr::VK_TLSDESC_LO12,
+ AArch64MCExpr::VK_TLSDESC_AUTH_LO12, AArch64MCExpr::VK_SECREL_LO12,
+ AArch64MCExpr::VK_SECREL_HI12, AArch64MCExpr::VK_GOT_PAGE_LO15},
+ ELFSpec)) {
// Note that we don't range-check the addend. It's adjusted modulo page
// size when converted, so there is no "out of range" condition when using
// @pageoff.
@@ -1009,26 +1005,24 @@ class AArch64Operand : public MCParsedAsmOperand {
Expr = getImm();
}
- AArch64MCExpr::VariantKind ELFRefKind;
+ AArch64MCExpr::Specifier ELFSpec;
MCSymbolRefExpr::VariantKind DarwinRefKind;
int64_t Addend;
- if (AArch64AsmParser::classifySymbolRef(Expr, ELFRefKind,
- DarwinRefKind, Addend)) {
+ if (AArch64AsmParser::classifySymbolRef(Expr, ELFSpec, DarwinRefKind,
+ Addend)) {
return DarwinRefKind == MCSymbolRefExpr::VK_PAGEOFF ||
DarwinRefKind == MCSymbolRefExpr::VK_TLVPPAGEOFF ||
(DarwinRefKind == MCSymbolRefExpr::VK_GOTPAGEOFF && Addend == 0) ||
- ELFRefKind == AArch64MCExpr::VK_LO12 ||
- ELFRefKind == AArch64MCExpr::VK_GOT_AUTH_LO12 ||
- ELFRefKind == AArch64MCExpr::VK_DTPREL_HI12 ||
- ELFRefKind == AArch64MCExpr::VK_DTPREL_LO12 ||
- ELFRefKind == AArch64MCExpr::VK_DTPREL_LO12_NC ||
- ELFRefKind == AArch64MCExpr::VK_TPREL_HI12 ||
- ELFRefKind == AArch64MCExpr::VK_TPREL_LO12 ||
- ELFRefKind == AArch64MCExpr::VK_TPREL_LO12_NC ||
- ELFRefKind == AArch64MCExpr::VK_TLSDESC_LO12 ||
- ELFRefKind == AArch64MCExpr::VK_TLSDESC_AUTH_LO12 ||
- ELFRefKind == AArch64MCExpr::VK_SECREL_HI12 ||
- ELFRefKind == AArch64MCExpr::VK_SECREL_LO12;
+ llvm::is_contained(
+ {AArch64MCExpr::VK_LO12, AArch64MCExpr::VK_GOT_AUTH_LO12,
+ AArch64MCExpr::VK_DTPREL_HI12, AArch64MCExpr::VK_DTPREL_LO12,
+ AArch64MCExpr::VK_DTPREL_LO12_NC,
+ AArch64MCExpr::VK_TPREL_HI12, AArch64MCExpr::VK_TPREL_LO12,
+ AArch64MCExpr::VK_TPREL_LO12_NC,
+ AArch64MCExpr::VK_TLSDESC_LO12,
+ AArch64MCExpr::VK_TLSDESC_AUTH_LO12,
+ AArch64MCExpr::VK_SECREL_HI12, AArch64MCExpr::VK_SECREL_LO12},
+ ELFSpec);
}
// If it's a constant, it should be a real immediate in range.
@@ -1121,22 +1115,21 @@ class AArch64Operand : public MCParsedAsmOperand {
return (Val >= -((1<<(N-1)) << 2) && Val <= (((1<<(N-1))-1) << 2));
}
- bool
- isMovWSymbol(ArrayRef<AArch64MCExpr::VariantKind> AllowedModifiers) const {
+ bool isMovWSymbol(ArrayRef<AArch64MCExpr::Specifier> AllowedModifiers) const {
if (!isImm())
return false;
- AArch64MCExpr::VariantKind ELFRefKind;
+ AArch64MCExpr::Specifier ELFSpec;
MCSymbolRefExpr::VariantKind DarwinRefKind;
int64_t Addend;
- if (!AArch64AsmParser::classifySymbolRef(getImm(), ELFRefKind,
- DarwinRefKind, Addend)) {
+ if (!AArch64AsmParser::classifySymbolRef(getImm(), ELFSpec, DarwinRefKind,
+ Addend)) {
return false;
}
if (DarwinRefKind != MCSymbolRefExpr::VK_None)
return false;
- return llvm::is_contained(AllowedModifiers, ELFRefKind);
+ return llvm::is_contained(AllowedModifiers, ELFSpec);
}
bool isMovWSymbolG3() const {
@@ -3304,12 +3297,12 @@ ParseStatus AArch64AsmParser::tryParseAdrpLabel(OperandVector &Operands) {
if (parseSymbolicImmVal(Expr))
return ParseStatus::Failure;
- AArch64MCExpr::VariantKind ELFRefKind;
+ AArch64MCExpr::Specifier ELFSpec;
MCSymbolRefExpr::VariantKind DarwinRefKind;
int64_t Addend;
- if (classifySymbolRef(Expr, ELFRefKind, DarwinRefKind, Addend)) {
+ if (classifySymbolRef(Expr, ELFSpec, DarwinRefKind, Addend)) {
if (DarwinRefKind == MCSymbolRefExpr::VK_None &&
- ELFRefKind == AArch64MCExpr::VK_INVALID) {
+ ELFSpec == AArch64MCExpr::VK_INVALID) {
// No modifier was specified at all; this is the syntax for an ELF basic
// ADRP relocation (unfortunately).
Expr =
@@ -3321,13 +3314,13 @@ ParseStatus AArch64AsmParser::tryParseAdrpLabel(OperandVector &Operands) {
} else if (DarwinRefKind != MCSymbolRefExpr::VK_PAGE &&
DarwinRefKind != MCSymbolRefExpr::VK_GOTPAGE &&
DarwinRefKind != MCSymbolRefExpr::VK_TLVPPAGE &&
- ELFRefKind != AArch64MCExpr::VK_ABS_PAGE_NC &&
- ELFRefKind != AArch64MCExpr::VK_GOT_PAGE &&
- ELFRefKind != AArch64MCExpr::VK_GOT_AUTH_PAGE &&
- ELFRefKind != AArch64MCExpr::VK_GOT_PAGE_LO15 &&
- ELFRefKind != AArch64MCExpr::VK_GOTTPREL_PAGE &&
- ELFRefKind != AArch64MCExpr::VK_TLSDESC_PAGE &&
- ELFRefKind != AArch64MCExpr::VK_TLSDESC_AUTH_PAGE) {
+ ELFSpec != AArch64MCExpr::VK_ABS_PAGE_NC &&
+ ELFSpec != AArch64MCExpr::VK_GOT_PAGE &&
+ ELFSpec != AArch64MCExpr::VK_GOT_AUTH_PAGE &&
+ ELFSpec != AArch64MCExpr::VK_GOT_PAGE_LO15 &&
+ ELFSpec != AArch64MCExpr::VK_GOTTPREL_PAGE &&
+ ELFSpec != AArch64MCExpr::VK_TLSDESC_PAGE &&
+ ELFSpec != AArch64MCExpr::VK_TLSDESC_AUTH_PAGE) {
// The operand must be an @page or @gotpage qualified symbolref.
return Error(S, "page or gotpage label reference expected");
}
@@ -3358,16 +3351,16 @@ ParseStatus AArch64AsmParser::tryParseAdrLabel(OperandVector &Operands) {
if (parseSymbolicImmVal(Expr))
return ParseStatus::Failure;
- AArch64MCExpr::VariantKind ELFRefKind;
+ AArch64MCExpr::Specifier ELFSpec;
MCSymbolRefExpr::VariantKind DarwinRefKind;
int64_t Addend;
- if (classifySymbolRef(Expr, ELFRefKind, DarwinRefKind, Addend)) {
+ if (classifySymbolRef(Expr, ELFSpec, DarwinRefKind, Addend)) {
if (DarwinRefKind == MCSymbolRefExpr::VK_None &&
- ELFRefKind == AArch64MCExpr::VK_INVALID) {
+ ELFSpec == AArch64MCExpr::VK_INVALID) {
// No modifier was specified at all; this is the syntax for an ELF basic
// ADR relocation (unfortunately).
Expr = AArch64MCExpr::create(Expr, AArch64MCExpr::VK_ABS, getContext());
- } else if (ELFRefKind != AArch64MCExpr::VK_GOT_AUTH_PAGE) {
+ } else if (ELFSpec != AArch64MCExpr::VK_GOT_AUTH_PAGE) {
// For tiny code model, we use :got_auth: operator to fill 21-bit imm of
// adr. It's not actually GOT entry page address but the GOT address
// itself - we just share the same variant kind with :got_auth: operator
@@ -4408,7 +4401,7 @@ bool AArch64AsmParser::parseRegister(OperandVector &Operands) {
bool AArch64AsmParser::parseSymbolicImmVal(const MCExpr *&ImmVal) {
bool HasELFModifier = false;
- AArch64MCExpr::VariantKind RefKind;
+ AArch64MCExpr::Specifier RefKind;
if (parseOptionalToken(AsmToken::Colon)) {
HasELFModifier = true;
@@ -4418,7 +4411,7 @@ bool AArch64AsmParser::parseSymbolicImmVal(const MCExpr *&ImmVal) {
std::string LowerCase = getTok().getIdentifier().lower();
RefKind =
- StringSwitch<AArch64MCExpr::VariantKind>(LowerCase)
+ StringSwitch<AArch64MCExpr::Specifier>(LowerCase)
.Case("lo12", AArch64MCExpr::VK_LO12)
.Case("abs_g3", AArch64MCExpr::VK_ABS_G3)
.Case("abs_g2", AArch64MCExpr::VK_ABS_G2)
@@ -5824,10 +5817,10 @@ bool AArch64AsmParser::validateInstruction(MCInst &Inst, SMLoc &IDLoc,
// some slight duplication here.
if (Inst.getOperand(2).isExpr()) {
const MCExpr *Expr = Inst.getOperand(2).getExpr();
- AArch64MCExpr::VariantKind ELFRefKind;
+ AArch64MCExpr::Specifier ELFSpec;
MCSymbolRefExpr::VariantKind DarwinRefKind;
int64_t Addend;
- if (classifySymbolRef(Expr, ELFRefKind, DarwinRefKind, Addend)) {
+ if (classifySymbolRef(Expr, ELFSpec, DarwinRefKind, Addend)) {
// Only allow these with ADDXri.
if ((DarwinRefKind == MCSymbolRefExpr::VK_PAGEOFF ||
@@ -5836,18 +5829,15 @@ bool AArch64AsmParser::validateInstruction(MCInst &Inst, SMLoc &IDLoc,
return false;
// Only allow these with ADDXri/ADDWri
- if ((ELFRefKind == AArch64MCExpr::VK_LO12 ||
- ELFRefKind == AArch64MCExpr::VK_GOT_AUTH_LO12 ||
- ELFRefKind == AArch64MCExpr::VK_DTPREL_HI12 ||
- ELFRefKind == AArch64MCExpr::VK_DTPREL_LO12 ||
- ELFRefKind == AArch64MCExpr::VK_DTPREL_LO12_NC ||
- ELFRefKind == AArch64MCExpr::VK_TPREL_HI12 ||
- ELFRefKind == AArch64MCExpr::VK_TPREL_LO12 ||
- ELFRefKind == AArch64MCExpr::VK_TPREL_LO12_NC ||
- ELFRefKind == AArch64MCExpr::VK_TLSDESC_LO12 ||
- ELFRefKind == AArch64MCExpr::VK_TLSDESC_AUTH_LO12 ||
- ELFRefKind == AArch64MCExpr::VK_SECREL_LO12 ||
- ELFRefKind == AArch64MCExpr::VK_SECREL_HI12) &&
+ if (llvm::is_contained(
+ {AArch64MCExpr::VK_LO12, AArch64MCExpr::VK_GOT_AUTH_LO12,
+ AArch64MCExpr::VK_DTPREL_HI12, AArch64MCExpr::VK_DTPREL_LO12,
+ AArch64MCExpr::VK_DTPREL_LO12_NC, AArch64MCExpr::VK_TPREL_HI12,
+ AArch64MCExpr::VK_TPREL_LO12, AArch64MCExpr::VK_TPREL_LO12_NC,
+ AArch64MCExpr::VK_TLSDESC_LO12,
+ AArch64MCExpr::VK_TLSDESC_AUTH_LO12,
+ AArch64MCExpr::VK_SECREL_LO12, AArch64MCExpr::VK_SECREL_HI12},
+ ELFSpec) &&
(Inst.getOpcode() == AArch64::ADDXri ||
Inst.getOpcode() == AArch64::ADDWri))
return false;
@@ -8203,17 +8193,15 @@ bool AArch64AsmParser::parseAuthExpr(const MCExpr *&Res, SMLoc &EndLoc) {
return false;
}
-bool
-AArch64AsmParser::classifySymbolRef(const MCExpr *Expr,
- AArch64MCExpr::VariantKind &ELFRefKind,
- MCSymbolRefExpr::VariantKind &DarwinRefKind,
- int64_t &Addend) {
- ELFRefKind = AArch64MCExpr::VK_INVALID;
+bool AArch64AsmParser::classifySymbolRef(
+ const MCExpr *Expr, AArch64MCExpr::Specifier &ELFSpec,
+ MCSymbolRefExpr::VariantKind &DarwinRefKind, int64_t &Addend) {
+ ELFSpec = AArch64MCExpr::VK_INVALID;
DarwinRefKind = MCSymbolRefExpr::VK_None;
Addend = 0;
if (const AArch64MCExpr *AE = dyn_cast<AArch64MCExpr>(Expr)) {
- ELFRefKind = AE->getKind();
+ ELFSpec = AE->getSpecifier();
Expr = AE->getSubExpr();
}
@@ -8230,9 +8218,9 @@ AArch64AsmParser::classifySymbolRef(const MCExpr *Expr,
if (!Relocatable || Res.getSymB())
return false;
- // Treat expressions with an ELFRefKind (like ":abs_g1:3", or
+ // Treat expressions with an ELFSpec (like ":abs_g1:3", or
// ":abs_g1:x" where x is constant) as symbolic even if there is no symbol.
- if (!Res.getSymA() && ELFRefKind == AArch64MCExpr::VK_INVALID)
+ if (!Res.getSymA() && ELFSpec == AArch64MCExpr::VK_INVALID)
return false;
if (Res.getSymA())
@@ -8241,7 +8229,7 @@ AArch64AsmParser::classifySymbolRef(const MCExpr *Expr,
// It's some symbol reference + a constant addend, but really
// shouldn't use both Darwin and ELF syntax.
- return ELFRefKind == AArch64MCExpr::VK_INVALID ||
+ return ELFSpec == AArch64MCExpr::VK_INVALID ||
DarwinRefKind == MCSymbolRefExpr::VK_None;
}
diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
index 8309c789d0ace..c5accb5e3b51b 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
@@ -221,8 +221,8 @@ static uint64_t adjustFixupValue(const MCFixup &Fixup, const MCValue &Target,
Ctx.reportError(Fixup.getLoc(), "fixup must be 16-byte aligned");
return Value >> 4;
case AArch64::fixup_aarch64_movw: {
- AArch64MCExpr::VariantKind RefKind =
- static_cast<AArch64MCExpr::VariantKind>(Target.getRefKind());
+ AArch64MCExpr::Specifier RefKind =
+ static_cast<AArch64MCExpr::Specifier>(Target.getRefKind());
if (AArch64MCExpr::getSymbolLoc(RefKind) != AArch64MCExpr::VK_ABS &&
AArch64MCExpr::getSymbolLoc(RefKind) != AArch64MCExpr::VK_SABS) {
if (!RefKind) {
@@ -422,8 +422,8 @@ void AArch64AsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
bool IsResolved,
const MCSubtargetInfo *STI) const {
if (Fixup.getTargetKind() == FK_Data_8 && TheTriple.isOSBinFormatELF()) {
- auto RefKind = static_cast<AArch64MCExpr::VariantKind>(Target.getRefKind());
- AArch64MCExpr::VariantKind SymLoc = AArch64MCExpr::getSymbolLoc(RefKind);
+ auto RefKind = static_cast<AArch64MCExpr::Specifier>(Target.getRefKind());
+ AArch64MCExpr::Specifier SymLoc = AArch64MCExpr::getSymbolLoc(RefKind);
if (SymLoc == AArch64AuthMCExpr::VK_AUTH ||
SymLoc == AArch64AuthMCExpr::VK_AUTHADDR) {
assert(Value == 0);
@@ -474,8 +474,8 @@ void AArch64AsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
// FIXME: getFixupKindInfo() and getFixupKindNumBytes() could be fixed to
// handle this more cleanly. This may affect the output of -show-mc-encoding.
- AArch64MCExpr::VariantKind RefKind =
- static_cast<AArch64MCExpr::VariantKind>(Target.getRefKind());
+ AArch64MCExpr::Specifier RefKind =
+ static_cast<AArch64MCExpr::Specifier>(Target.getRefKind());
if (AArch64MCExpr::getSymbolLoc(RefKind) == AArch64MCExpr::VK_SABS ||
(!RefKind && Fixup.getTargetKind() == AArch64::fixup_aarch64_movw)) {
// If the immediate is negative, generate MOVN else MOVZ.
diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp
index 19d04b4e83c23..3bee29ad00481 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp
@@ -57,8 +57,7 @@ AArch64ELFObjectWriter::AArch64ELFObjectWriter(uint8_t OSABI, bool IsILP32)
// assumes IsILP32 is true
static bool isNonILP32reloc(const MCFixup &Fixup,
- AArch64MCExpr::VariantKind RefKind,
- MCContext &Ctx) {
+ AArch64MCExpr::Specifier RefKind, MCContext &Ctx) {
if (Fixup.getTargetKind() != AArch64::fixup_aarch64_movw)
return false;
switch (RefKind) {
@@ -111,9 +110,9 @@ unsigned AArch64ELFObjectWriter::getRelocType(MCContext &Ctx,
unsigned Kind = Fixup.getTargetKind();
if (Kind >= FirstLiteralRelocationKind)
return Kind - FirstLiteralRelocationKind;
- AArch64MCExpr::VariantKind RefKind =
- static_cast<AArch64MCExpr::VariantKind>(Target.getRefKind());
- AArch64MCExpr::VariantKind SymLoc = AArch64MCExpr::getSymbolLoc(RefKind);
+ AArch64MCExpr::Specifier RefKind =
+ static_cast<AArch64MCExpr::Specifier>(Target.getRefKind());
+ AArch64MCExpr::Specifier SymLoc = AArch64MCExpr::getSymbolLoc(RefKind);
bool IsNC = AArch64MCExpr::isNotChecked(RefKind);
assert((!Target.getSymA() ||
@@ -402,7 +401,7 @@ unsigned AArch64ELFObjectWriter:...
[truncated]
|
I'll add some more AArch64 backend reviewers to get some more opinions. Not had a chance to look through the details yet, apologies. |
Adding @ostannard @davemgreen @nasherm as AArch64 maintainers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks OK to me. I can see that this does line up with the other backends including ARM.
I'll add a few Apple people to see if there's any objections on their side.
@@ -338,7 +338,7 @@ class AArch64AsmParser : public MCTargetAsmParser { | |||
bool parsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc) override; | |||
|
|||
static bool classifySymbolRef(const MCExpr *Expr, | |||
AArch64MCExpr::VariantKind &ELFRefKind, | |||
AArch64MCExpr::Specifier &ELFSpec, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it may be better to just use Spec
rather than ELFSpec
. All the other backends including ARM use Spec, and it is distinguishable from DarwinRefKind without needing ELF.
Not a strong opinion, happy either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will make a separate change to migrate DarwinRefKind
, away from MCSymbolRefExpr::VariantKind
and use AArch64MCExpr
::Specifier constants. And rename the Darwin variable to DarwinSpec
(I do not plan to completely migrate it to AArch64MCExpr and but hope someone could do so). . Therefore, I am preferring ELFSpec
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The general idea of this change seems reasonable to me, especially to avoid shadowing MCExpr::getKind
.
The enum values still all start with VK_
, would it make sense to change them too?
Sounds OK to me if Specifier is what you are changing all the backends to. There are still lots of references to VK_ and getVariantKindName - I'm not sure how many of those are worth changing too. |
Thanks for the feedback. I decide to keep the current |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think of renaming getVariantKindName? Otherwise looks good to me.
Created using spr 1.3.5-bogner
Thanks. Done. Updated some comments as well. |
Created using spr 1.3.5-bogner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, assuming you update test/MC/AArch64/coff-relocations-diags.s
which is failing in the pre-commits.
Created using spr 1.3.5-bogner
Follow the naming of most other backends. > "Relocation modifier" suggests adjustments happen during the linker's relocation step rather than the assembler's expression evaluation. > "Relocation specifier" is clear, aligns with Arm and IBM AIX's documentation, and fits the assembler's role seamlessly. In addition, rename `AArch64MCExpr::Kind` and `getKind`, which confusingly shadow the base class `Kind` and `getKind`. DarwinRefKind, which still uses MCSymbolRefExpr::VariantKind, is not renamed. Pull Request: llvm/llvm-project#132595
Shift ELF `@plt` and `@gotpcrel` references in data directives, as well as Mach-O `@specifier` notations, to use `AArch64MCExpr::Specifier` constants. This is a follow-up to llvm#132595. COFF-specific specifiers are not moved yet. In addition, partition @-specifiers into COFF, ELF, and Mach-O, so that mix-and-match is rejected at parse time. ELF and Mach-O specifiers are distinct, with `None` being the only shared value. For Mach-O-specific specifiers, we adopt the `M_xxx` naming convention. Pull Request: llvm#133214
Shift ELF `@plt` and `@gotpcrel` references in data directives, as well as Mach-O `@specifier` notations, to use `AArch64MCExpr::Specifier` constants. This is a follow-up to #132595. COFF-specific specifiers are not moved yet. In addition, partition @-specifiers into COFF, ELF, and Mach-O, so that mix-and-match is rejected at parse time. ELF and Mach-O specifiers are distinct, with `None` being the only shared value. For Mach-O-specific specifiers, we adopt the `M_xxx` naming convention. Pull Request: #133214
Rename these relocation specifier constants, aligning with the naming convention used by other targets (`S_` instead of `VK_`). * ELF/COFF: AArch64MCExpr::VK_ => AArch64::S_ (VK_ABS/VK_PAGE_ABS are also used by Mach-O as a hack) * Mach-O: AArch64MCExpr::M_ => AArch64::M_ * shared: AArch64MCExpr::None => AArch64::S_None Apologies for the churn following the recent rename in llvm#132595. This change ensures consistency after introducing MCSpecifierExpr to replace MCTargetSpecifier subclasses.
Rename these relocation specifier constants, aligning with the naming convention used by other targets (`S_` instead of `VK_`). * ELF/COFF: AArch64MCExpr::VK_ => AArch64::S_ (VK_ABS/VK_PAGE_ABS are also used by Mach-O as a hack) * Mach-O: AArch64MCExpr::M_ => AArch64::S_MACHO_ * shared: AArch64MCExpr::None => AArch64::S_None Apologies for the churn following the recent rename in llvm#132595. This change ensures consistency after introducing MCSpecifierExpr to replace MCTargetSpecifier subclasses.
Follow the naming of most other backends.
In addition, rename
AArch64MCExpr::Kind
andgetKind
, which confusingly shadow the base classKind
andgetKind
.DarwinRefKind, which still uses MCSymbolRefExpr::VariantKind, is not renamed.