Skip to content

Commit 8eac7f5

Browse files
committed
PPCMCExpr: Migrate to MCSpecifierExpr
1 parent cdd0a6c commit 8eac7f5

File tree

3 files changed

+9
-36
lines changed

3 files changed

+9
-36
lines changed

llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ DEFINE_PPC_REGCLASSES
3737
static int64_t
3838
EvaluateCRExpr(const MCExpr *E) {
3939
switch (E->getKind()) {
40-
case MCExpr::Target:
41-
return -1;
42-
4340
case MCExpr::Constant: {
4441
int64_t Res = cast<MCConstantExpr>(E)->getValue();
4542
return Res < 0 ? -1 : Res;
@@ -88,6 +85,8 @@ EvaluateCRExpr(const MCExpr *E) {
8885
return Res < 0 ? -1 : Res;
8986
}
9087
case MCExpr::Specifier:
88+
return -1;
89+
case MCExpr::Target:
9190
llvm_unreachable("unused by this backend");
9291
}
9392

@@ -1374,7 +1373,7 @@ const MCExpr *PPCAsmParser::extractSpecifier(const MCExpr *E,
13741373
switch (E->getKind()) {
13751374
case MCExpr::Constant:
13761375
break;
1377-
case MCExpr::Target: {
1376+
case MCExpr::Specifier: {
13781377
// Detect error but do not return a modified expression.
13791378
auto *TE = cast<PPCMCExpr>(E);
13801379
Spec = TE->getSpecifier();
@@ -1422,7 +1421,7 @@ const MCExpr *PPCAsmParser::extractSpecifier(const MCExpr *E,
14221421
return MCBinaryExpr::create(BE->getOpcode(), LHS, RHS, Context);
14231422
break;
14241423
}
1425-
case MCExpr::Specifier:
1424+
case MCExpr::Target:
14261425
llvm_unreachable("unused by this backend");
14271426
}
14281427

@@ -1437,7 +1436,7 @@ bool PPCAsmParser::parseExpression(const MCExpr *&EVal) {
14371436
if (getParser().parseExpression(EVal))
14381437
return true;
14391438

1440-
auto Spec = PPCMCExpr::VK_None;
1439+
uint16_t Spec = PPCMCExpr::VK_None;
14411440
const MCExpr *E = extractSpecifier(EVal, Spec);
14421441
if (Spec != PPCMCExpr::VK_None)
14431442
EVal = PPCMCExpr::create(Spec, E, getParser().getContext());

llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,3 @@ bool PPCMCExpr::evaluateAsRelocatableImpl(MCValue &Res,
8686

8787
return true;
8888
}
89-
90-
void PPCMCExpr::visitUsedExpr(MCStreamer &Streamer) const {
91-
Streamer.visitUsedExpr(*getSubExpr());
92-
}

llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.h

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515

1616
namespace llvm {
1717

18-
class PPCMCExpr : public MCTargetExpr {
18+
class PPCMCExpr : public MCSpecifierExpr {
1919
public:
20-
enum Specifier : uint8_t {
20+
using Specifier = uint16_t;
21+
enum {
2122
VK_None,
2223

2324
VK_LO = MCSymbolRefExpr::FirstTargetSpecifier,
@@ -100,18 +101,12 @@ class PPCMCExpr : public MCTargetExpr {
100101
};
101102

102103
private:
103-
const Specifier specifier;
104-
const MCExpr *Expr;
105-
106104
std::optional<int64_t> evaluateAsInt64(int64_t Value) const;
107105

108106
explicit PPCMCExpr(Specifier S, const MCExpr *Expr)
109-
: specifier(S), Expr(Expr) {}
107+
: MCSpecifierExpr(Expr, S) {}
110108

111109
public:
112-
/// @name Construction
113-
/// @{
114-
115110
static const PPCMCExpr *create(Specifier S, const MCExpr *Expr,
116111
MCContext &Ctx);
117112

@@ -127,28 +122,11 @@ class PPCMCExpr : public MCTargetExpr {
127122
return create(VK_HA, Expr, Ctx);
128123
}
129124

130-
/// @}
131-
/// @name Accessors
132-
/// @{
133-
134-
Specifier getSpecifier() const { return specifier; }
135-
const MCExpr *getSubExpr() const { return Expr; }
136-
137-
/// @}
138-
139125
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
140126
bool evaluateAsRelocatableImpl(MCValue &Res,
141127
const MCAssembler *Asm) const override;
142-
void visitUsedExpr(MCStreamer &Streamer) const override;
143-
MCFragment *findAssociatedFragment() const override {
144-
return getSubExpr()->findAssociatedFragment();
145-
}
146128

147129
bool evaluateAsConstant(int64_t &Res) const;
148-
149-
static bool classof(const MCExpr *E) {
150-
return E->getKind() == MCExpr::Target;
151-
}
152130
};
153131

154132
static inline PPCMCExpr::Specifier getSpecifier(const MCSymbolRefExpr *SRE) {

0 commit comments

Comments
 (0)