[llvm] beab1a6 - [CSKY] Migrate away from legacy MCSymbolRefExpr::VariantKind
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 22 21:03:07 PDT 2025
Author: Fangrui Song
Date: 2025-03-22T21:03:02-07:00
New Revision: beab1a6ddebafdba906bf222b628033a9b8f6e3d
URL: https://github.com/llvm/llvm-project/commit/beab1a6ddebafdba906bf222b628033a9b8f6e3d
DIFF: https://github.com/llvm/llvm-project/commit/beab1a6ddebafdba906bf222b628033a9b8f6e3d.diff
LOG: [CSKY] Migrate away from legacy MCSymbolRefExpr::VariantKind
Added:
Modified:
llvm/lib/Target/CSKY/AsmParser/CSKYAsmParser.cpp
llvm/lib/Target/CSKY/MCTargetDesc/CSKYELFObjectWriter.cpp
llvm/lib/Target/CSKY/MCTargetDesc/CSKYMCAsmInfo.cpp
llvm/lib/Target/CSKY/MCTargetDesc/CSKYMCExpr.cpp
llvm/lib/Target/CSKY/MCTargetDesc/CSKYMCExpr.h
llvm/lib/Target/CSKY/MCTargetDesc/CSKYTargetStreamer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/CSKY/AsmParser/CSKYAsmParser.cpp b/llvm/lib/Target/CSKY/AsmParser/CSKYAsmParser.cpp
index 88bec214f92c9..0e14eabbd5cf3 100644
--- a/llvm/lib/Target/CSKY/AsmParser/CSKYAsmParser.cpp
+++ b/llvm/lib/Target/CSKY/AsmParser/CSKYAsmParser.cpp
@@ -850,9 +850,9 @@ bool CSKYAsmParser::processLRW(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out) {
const MCExpr *AdjustExpr = nullptr;
if (const CSKYMCExpr *CSKYExpr =
dyn_cast<CSKYMCExpr>(Inst.getOperand(1).getExpr())) {
- if (CSKYExpr->getKind() == CSKYMCExpr::VK_TLSGD ||
- CSKYExpr->getKind() == CSKYMCExpr::VK_TLSIE ||
- CSKYExpr->getKind() == CSKYMCExpr::VK_TLSLDM) {
+ if (CSKYExpr->getSpecifier() == CSKYMCExpr::VK_TLSGD ||
+ CSKYExpr->getSpecifier() == CSKYMCExpr::VK_TLSIE ||
+ CSKYExpr->getSpecifier() == CSKYMCExpr::VK_TLSLDM) {
MCSymbol *Dot = getContext().createNamedTempSymbol();
Out.emitLabel(Dot);
AdjustExpr = MCSymbolRefExpr::create(Dot, getContext());
diff --git a/llvm/lib/Target/CSKY/MCTargetDesc/CSKYELFObjectWriter.cpp b/llvm/lib/Target/CSKY/MCTargetDesc/CSKYELFObjectWriter.cpp
index f305770bf559a..4471c1cc05d99 100644
--- a/llvm/lib/Target/CSKY/MCTargetDesc/CSKYELFObjectWriter.cpp
+++ b/llvm/lib/Target/CSKY/MCTargetDesc/CSKYELFObjectWriter.cpp
@@ -38,7 +38,7 @@ unsigned CSKYELFObjectWriter::getRelocType(MCContext &Ctx,
const MCExpr *Expr = Fixup.getValue();
// Determine the type of the relocation
unsigned Kind = Fixup.getTargetKind();
- MCSymbolRefExpr::VariantKind Modifier = Target.getAccessVariant();
+ uint8_t Modifier = Target.getAccessVariant();
if (IsPCRel) {
switch (Kind) {
@@ -79,7 +79,7 @@ unsigned CSKYELFObjectWriter::getRelocType(MCContext &Ctx,
return ELF::R_CKCORE_NONE;
case FK_Data_4:
if (Expr->getKind() == MCExpr::Target) {
- auto TK = cast<CSKYMCExpr>(Expr)->getKind();
+ auto TK = cast<CSKYMCExpr>(Expr)->getSpecifier();
if (TK == CSKYMCExpr::VK_ADDR)
return ELF::R_CKCORE_ADDR32;
if (TK == CSKYMCExpr::VK_GOT)
@@ -111,19 +111,19 @@ unsigned CSKYELFObjectWriter::getRelocType(MCContext &Ctx,
Ctx.reportError(Fixup.getLoc(),
"invalid fixup for 4-byte data relocation");
return ELF::R_CKCORE_NONE;
- case MCSymbolRefExpr::VK_GOT:
+ case CSKYMCExpr::VK_GOT:
return ELF::R_CKCORE_GOT32;
- case MCSymbolRefExpr::VK_GOTOFF:
+ case CSKYMCExpr::VK_GOTOFF:
return ELF::R_CKCORE_GOTOFF;
- case MCSymbolRefExpr::VK_PLT:
+ case CSKYMCExpr::VK_PLT:
return ELF::R_CKCORE_PLT32;
- case MCSymbolRefExpr::VK_TLSGD:
+ case CSKYMCExpr::VK_TLSGD:
return ELF::R_CKCORE_TLS_GD32;
- case MCSymbolRefExpr::VK_TLSLDM:
+ case CSKYMCExpr::VK_TLSLDM:
return ELF::R_CKCORE_TLS_LDM32;
- case MCSymbolRefExpr::VK_TPOFF:
+ case CSKYMCExpr::VK_TPOFF:
return ELF::R_CKCORE_TLS_LE32;
- case MCSymbolRefExpr::VK_None:
+ case CSKYMCExpr::VK_None:
return ELF::R_CKCORE_ADDR32;
}
}
diff --git a/llvm/lib/Target/CSKY/MCTargetDesc/CSKYMCAsmInfo.cpp b/llvm/lib/Target/CSKY/MCTargetDesc/CSKYMCAsmInfo.cpp
index a036000c0e6af..796bac33419b2 100644
--- a/llvm/lib/Target/CSKY/MCTargetDesc/CSKYMCAsmInfo.cpp
+++ b/llvm/lib/Target/CSKY/MCTargetDesc/CSKYMCAsmInfo.cpp
@@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//
#include "CSKYMCAsmInfo.h"
+#include "MCTargetDesc/CSKYMCExpr.h"
#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCStreamer.h"
@@ -18,13 +19,9 @@
using namespace llvm;
const MCAsmInfo::VariantKindDesc variantKindDescs[] = {
- {MCSymbolRefExpr::VK_GOT, "GOT"},
- {MCSymbolRefExpr::VK_GOTOFF, "GOTOFF"},
- {MCSymbolRefExpr::VK_PLT, "PLT"},
- {MCSymbolRefExpr::VK_TLSGD, "TLSGD"},
- {MCSymbolRefExpr::VK_TLSLD, "TLSLD"},
- {MCSymbolRefExpr::VK_TLSLDM, "TLSLDM"},
- {MCSymbolRefExpr::VK_TPOFF, "TPOFF"},
+ {CSKYMCExpr::VK_GOT, "GOT"}, {CSKYMCExpr::VK_GOTOFF, "GOTOFF"},
+ {CSKYMCExpr::VK_PLT, "PLT"}, {CSKYMCExpr::VK_TLSGD, "TLSGD"},
+ {CSKYMCExpr::VK_TLSLDM, "TLSLDM"}, {CSKYMCExpr::VK_TPOFF, "TPOFF"},
};
void CSKYMCAsmInfo::anchor() {}
diff --git a/llvm/lib/Target/CSKY/MCTargetDesc/CSKYMCExpr.cpp b/llvm/lib/Target/CSKY/MCTargetDesc/CSKYMCExpr.cpp
index daed79f3aa58c..0d864d061029b 100644
--- a/llvm/lib/Target/CSKY/MCTargetDesc/CSKYMCExpr.cpp
+++ b/llvm/lib/Target/CSKY/MCTargetDesc/CSKYMCExpr.cpp
@@ -64,7 +64,7 @@ void CSKYMCExpr::visitUsedExpr(MCStreamer &Streamer) const {
void CSKYMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
Expr->print(OS, MAI);
- OS << getVariantKindName(getKind());
+ OS << getVariantKindName(getSpecifier());
}
static void fixELFSymbolsInTLSFixupsImpl(const MCExpr *Expr, MCAssembler &Asm) {
@@ -97,7 +97,7 @@ static void fixELFSymbolsInTLSFixupsImpl(const MCExpr *Expr, MCAssembler &Asm) {
}
void CSKYMCExpr::fixELFSymbolsInTLSFixups(MCAssembler &Asm) const {
- switch (getKind()) {
+ switch (getSpecifier()) {
default:
return;
case VK_TLSLE:
@@ -116,7 +116,7 @@ bool CSKYMCExpr::evaluateAsRelocatableImpl(MCValue &Res,
// Some custom fixup types are not valid with symbol
diff erence expressions
if (Res.getSymA() && Res.getSymB()) {
- switch (getKind()) {
+ switch (getSpecifier()) {
default:
return true;
case VK_GOT:
diff --git a/llvm/lib/Target/CSKY/MCTargetDesc/CSKYMCExpr.h b/llvm/lib/Target/CSKY/MCTargetDesc/CSKYMCExpr.h
index e24c7589a1fa3..08c5737fae418 100644
--- a/llvm/lib/Target/CSKY/MCTargetDesc/CSKYMCExpr.h
+++ b/llvm/lib/Target/CSKY/MCTargetDesc/CSKYMCExpr.h
@@ -33,6 +33,7 @@ class CSKYMCExpr : public MCTargetExpr {
VK_TLSGD,
VK_TLSLDO,
VK_TLSLDM,
+ VK_TPOFF,
VK_Invalid
};
@@ -48,7 +49,7 @@ class CSKYMCExpr : public MCTargetExpr {
MCContext &Ctx);
// Returns the kind of this expression.
- Specifier getKind() const { return specifier; }
+ Specifier getSpecifier() const { return specifier; }
// Returns the child of this expression.
const MCExpr *getSubExpr() const { return Expr; }
diff --git a/llvm/lib/Target/CSKY/MCTargetDesc/CSKYTargetStreamer.cpp b/llvm/lib/Target/CSKY/MCTargetDesc/CSKYTargetStreamer.cpp
index 796d60c815b31..42876b3891271 100644
--- a/llvm/lib/Target/CSKY/MCTargetDesc/CSKYTargetStreamer.cpp
+++ b/llvm/lib/Target/CSKY/MCTargetDesc/CSKYTargetStreamer.cpp
@@ -61,7 +61,7 @@ const MCExpr *CSKYConstantPool::addEntry(MCStreamer &Streamer,
Value = MCBinaryExpr::createSub(AdjustExpr, SymRef, Context);
Value = MCBinaryExpr::createSub(CSKYExpr->getSubExpr(), Value, Context);
- Value = CSKYMCExpr::create(Value, CSKYExpr->getKind(), Context);
+ Value = CSKYMCExpr::create(Value, CSKYExpr->getSpecifier(), Context);
}
Entries.push_back(ConstantPoolEntry(CPEntryLabel, Value, Size, Loc));
@@ -91,7 +91,7 @@ CSKYTargetStreamer::addConstantPoolEntry(const MCExpr *Expr, SMLoc Loc,
if (const CSKYMCExpr *CE = dyn_cast<CSKYMCExpr>(Expr)) {
Expr = CE->getSubExpr();
- ELFRefKind = CE->getKind();
+ ELFRefKind = CE->getSpecifier();
}
if (const MCSymbolRefExpr *SymExpr = dyn_cast<MCSymbolRefExpr>(Expr)) {
More information about the llvm-commits
mailing list