Skip to content

Commit 3906451

Browse files
committed
AVRMCExpr: Migrate to MCSpecifierExpr
1 parent 2f1c082 commit 3906451

File tree

3 files changed

+6
-25
lines changed

3 files changed

+6
-25
lines changed

llvm/lib/Target/AVR/MCTargetDesc/AVRMCCodeEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ unsigned AVRMCCodeEmitter::getExprOpValue(const MCExpr *Expr,
230230
Kind = Expr->getKind();
231231
}
232232

233-
if (Kind == MCExpr::Target) {
233+
if (Kind == MCExpr::Specifier) {
234234
AVRMCExpr const *AVRExpr = cast<AVRMCExpr>(Expr);
235235
int64_t Result;
236236
if (AVRExpr->evaluateAsConstant(Result)) {

llvm/lib/Target/AVR/MCTargetDesc/AVRMCExpr.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ bool AVRMCExpr::evaluateAsConstant(int64_t &Result) const {
6969
bool AVRMCExpr::evaluateAsRelocatableImpl(MCValue &Result,
7070
const MCAssembler *Asm) const {
7171
MCValue Value;
72-
bool isRelocatable = SubExpr->evaluateAsRelocatable(Value, Asm);
73-
72+
bool isRelocatable = getSubExpr()->evaluateAsRelocatable(Value, Asm);
7473
if (!isRelocatable)
7574
return false;
7675

@@ -187,10 +186,6 @@ AVR::Fixups AVRMCExpr::getFixupKind() const {
187186
return Kind;
188187
}
189188

190-
void AVRMCExpr::visitUsedExpr(MCStreamer &Streamer) const {
191-
Streamer.visitUsedExpr(*getSubExpr());
192-
}
193-
194189
const char *AVRMCExpr::getName() const {
195190
const auto &Modifier =
196191
llvm::find_if(ModifierNames, [this](ModifierEntry const &Mod) {

llvm/lib/Target/AVR/MCTargetDesc/AVRMCExpr.h

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
namespace llvm {
1717

1818
/// A expression in AVR machine code.
19-
class AVRMCExpr : public MCTargetExpr {
19+
class AVRMCExpr : public MCSpecifierExpr {
2020
public:
21+
using Specifier = Spec;
2122
/// Specifies the type of an expression.
22-
enum Specifier {
23+
enum {
2324
VK_None,
2425

2526
VK_AVR_NONE = MCSymbolRefExpr::FirstTargetSpecifier,
@@ -48,11 +49,8 @@ class AVRMCExpr : public MCTargetExpr {
4849
static const AVRMCExpr *create(Specifier S, const MCExpr *Expr,
4950
bool isNegated, MCContext &Ctx);
5051

51-
/// Gets the type of the expression.
52-
Specifier getSpecifier() const { return specifier; }
5352
/// Gets the name of the expression.
5453
const char *getName() const;
55-
const MCExpr *getSubExpr() const { return SubExpr; }
5654
/// Gets the fixup which corresponds to the expression.
5755
AVR::Fixups getFixupKind() const;
5856
/// Evaluates the fixup as a constant value.
@@ -64,30 +62,18 @@ class AVRMCExpr : public MCTargetExpr {
6462
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
6563
bool evaluateAsRelocatableImpl(MCValue &Res,
6664
const MCAssembler *Asm) const override;
67-
void visitUsedExpr(MCStreamer &streamer) const override;
68-
69-
MCFragment *findAssociatedFragment() const override {
70-
return getSubExpr()->findAssociatedFragment();
71-
}
72-
73-
static bool classof(const MCExpr *E) {
74-
return E->getKind() == MCExpr::Target;
75-
}
7665

7766
public:
7867
static Specifier parseSpecifier(StringRef Name);
7968

8069
private:
8170
int64_t evaluateAsInt64(int64_t Value) const;
8271

83-
const Specifier specifier;
84-
const MCExpr *SubExpr;
8572
bool Negated;
8673

8774
private:
8875
explicit AVRMCExpr(Specifier S, const MCExpr *Expr, bool Negated)
89-
: specifier(S), SubExpr(Expr), Negated(Negated) {}
90-
~AVRMCExpr() = default;
76+
: MCSpecifierExpr(Expr, S), Negated(Negated) {}
9177
};
9278

9379
} // end namespace llvm

0 commit comments

Comments
 (0)