[llvm] 3906451 - AVRMCExpr: Migrate to MCSpecifierExpr
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 8 00:15:36 PDT 2025
Author: Fangrui Song
Date: 2025-06-08T00:15:32-07:00
New Revision: 39064519cb65b5248fcb27b2fd9fa4397d518331
URL: https://github.com/llvm/llvm-project/commit/39064519cb65b5248fcb27b2fd9fa4397d518331
DIFF: https://github.com/llvm/llvm-project/commit/39064519cb65b5248fcb27b2fd9fa4397d518331.diff
LOG: AVRMCExpr: Migrate to MCSpecifierExpr
Added:
Modified:
llvm/lib/Target/AVR/MCTargetDesc/AVRMCCodeEmitter.cpp
llvm/lib/Target/AVR/MCTargetDesc/AVRMCExpr.cpp
llvm/lib/Target/AVR/MCTargetDesc/AVRMCExpr.h
Removed:
################################################################################
diff --git a/llvm/lib/Target/AVR/MCTargetDesc/AVRMCCodeEmitter.cpp b/llvm/lib/Target/AVR/MCTargetDesc/AVRMCCodeEmitter.cpp
index 98ddacb31a348..fa01dad5ec128 100644
--- a/llvm/lib/Target/AVR/MCTargetDesc/AVRMCCodeEmitter.cpp
+++ b/llvm/lib/Target/AVR/MCTargetDesc/AVRMCCodeEmitter.cpp
@@ -230,7 +230,7 @@ unsigned AVRMCCodeEmitter::getExprOpValue(const MCExpr *Expr,
Kind = Expr->getKind();
}
- if (Kind == MCExpr::Target) {
+ if (Kind == MCExpr::Specifier) {
AVRMCExpr const *AVRExpr = cast<AVRMCExpr>(Expr);
int64_t Result;
if (AVRExpr->evaluateAsConstant(Result)) {
diff --git a/llvm/lib/Target/AVR/MCTargetDesc/AVRMCExpr.cpp b/llvm/lib/Target/AVR/MCTargetDesc/AVRMCExpr.cpp
index 01bd8973170cd..49784e806b887 100644
--- a/llvm/lib/Target/AVR/MCTargetDesc/AVRMCExpr.cpp
+++ b/llvm/lib/Target/AVR/MCTargetDesc/AVRMCExpr.cpp
@@ -69,8 +69,7 @@ bool AVRMCExpr::evaluateAsConstant(int64_t &Result) const {
bool AVRMCExpr::evaluateAsRelocatableImpl(MCValue &Result,
const MCAssembler *Asm) const {
MCValue Value;
- bool isRelocatable = SubExpr->evaluateAsRelocatable(Value, Asm);
-
+ bool isRelocatable = getSubExpr()->evaluateAsRelocatable(Value, Asm);
if (!isRelocatable)
return false;
@@ -187,10 +186,6 @@ AVR::Fixups AVRMCExpr::getFixupKind() const {
return Kind;
}
-void AVRMCExpr::visitUsedExpr(MCStreamer &Streamer) const {
- Streamer.visitUsedExpr(*getSubExpr());
-}
-
const char *AVRMCExpr::getName() const {
const auto &Modifier =
llvm::find_if(ModifierNames, [this](ModifierEntry const &Mod) {
diff --git a/llvm/lib/Target/AVR/MCTargetDesc/AVRMCExpr.h b/llvm/lib/Target/AVR/MCTargetDesc/AVRMCExpr.h
index e3c36d20f8516..69c60cde1f746 100644
--- a/llvm/lib/Target/AVR/MCTargetDesc/AVRMCExpr.h
+++ b/llvm/lib/Target/AVR/MCTargetDesc/AVRMCExpr.h
@@ -16,10 +16,11 @@
namespace llvm {
/// A expression in AVR machine code.
-class AVRMCExpr : public MCTargetExpr {
+class AVRMCExpr : public MCSpecifierExpr {
public:
+ using Specifier = Spec;
/// Specifies the type of an expression.
- enum Specifier {
+ enum {
VK_None,
VK_AVR_NONE = MCSymbolRefExpr::FirstTargetSpecifier,
@@ -48,11 +49,8 @@ class AVRMCExpr : public MCTargetExpr {
static const AVRMCExpr *create(Specifier S, const MCExpr *Expr,
bool isNegated, MCContext &Ctx);
- /// Gets the type of the expression.
- Specifier getSpecifier() const { return specifier; }
/// Gets the name of the expression.
const char *getName() const;
- const MCExpr *getSubExpr() const { return SubExpr; }
/// Gets the fixup which corresponds to the expression.
AVR::Fixups getFixupKind() const;
/// Evaluates the fixup as a constant value.
@@ -64,15 +62,6 @@ class AVRMCExpr : public MCTargetExpr {
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
bool evaluateAsRelocatableImpl(MCValue &Res,
const MCAssembler *Asm) const override;
- void visitUsedExpr(MCStreamer &streamer) const override;
-
- MCFragment *findAssociatedFragment() const override {
- return getSubExpr()->findAssociatedFragment();
- }
-
- static bool classof(const MCExpr *E) {
- return E->getKind() == MCExpr::Target;
- }
public:
static Specifier parseSpecifier(StringRef Name);
@@ -80,14 +69,11 @@ class AVRMCExpr : public MCTargetExpr {
private:
int64_t evaluateAsInt64(int64_t Value) const;
- const Specifier specifier;
- const MCExpr *SubExpr;
bool Negated;
private:
explicit AVRMCExpr(Specifier S, const MCExpr *Expr, bool Negated)
- : specifier(S), SubExpr(Expr), Negated(Negated) {}
- ~AVRMCExpr() = default;
+ : MCSpecifierExpr(Expr, S), Negated(Negated) {}
};
} // end namespace llvm
More information about the llvm-commits
mailing list