Skip to content

Commit e997eb4

Browse files
committed
VEMCExpr: Migrate to MCSpecifierExpr
Follow-up to 97a32f2
1 parent 24bd4e5 commit e997eb4

File tree

5 files changed

+11
-45
lines changed

5 files changed

+11
-45
lines changed

llvm/include/llvm/MC/MCExpr.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,8 @@ class LLVM_ABI MCSpecifierExpr : public MCExpr {
523523
const MCExpr *getSubExpr() const { return Expr; }
524524

525525
virtual void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const = 0;
526-
bool evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm) const;
526+
virtual bool evaluateAsRelocatableImpl(MCValue &Res,
527+
const MCAssembler *Asm) const;
527528

528529
static bool classof(const MCExpr *E) {
529530
return E->getKind() == MCExpr::Specifier;

llvm/lib/Target/VE/AsmParser/VEAsmParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,7 @@ const MCExpr *VEAsmParser::extractSpecifier(const MCExpr *E,
10541054
case MCExpr::SymbolRef: {
10551055
const MCSymbolRefExpr *SRE = cast<MCSymbolRefExpr>(E);
10561056

1057-
switch (getSpecifier(SRE)) {
1057+
switch (SRE->getSpecifier()) {
10581058
case VEMCExpr::VK_None:
10591059
// Use VK_REFLONG to a symbol without modifiers.
10601060
Variant = VEMCExpr::VK_REFLONG;

llvm/lib/Target/VE/MCTargetDesc/VEMCCodeEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ unsigned VEMCCodeEmitter::getMachineOpValue(const MCInst &MI,
9999

100100
const MCExpr *Expr = MO.getExpr();
101101
if (const VEMCExpr *SExpr = dyn_cast<VEMCExpr>(Expr)) {
102-
MCFixupKind Kind = (MCFixupKind)SExpr->getFixupKind();
102+
auto Kind = VEMCExpr::getFixupKind(SExpr->getSpecifier());
103103
Fixups.push_back(MCFixup::create(0, Expr, Kind));
104104
return 0;
105105
}

llvm/lib/Target/VE/MCTargetDesc/VEMCExpr.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ using namespace llvm;
2222

2323
#define DEBUG_TYPE "vemcexpr"
2424

25-
const VEMCExpr *VEMCExpr::create(Specifier Kind, const MCExpr *Expr,
25+
const VEMCExpr *VEMCExpr::create(Specifier S, const MCExpr *Expr,
2626
MCContext &Ctx) {
27-
return new (Ctx) VEMCExpr(Kind, Expr);
27+
return new (Ctx) VEMCExpr(Expr, S);
2828
}
2929

3030
void VEMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
@@ -35,7 +35,7 @@ void VEMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
3535
OS << '@' << MAI->getSpecifierName(specifier);
3636
}
3737

38-
VE::Fixups VEMCExpr::getFixupKind(VEMCExpr::Specifier S) {
38+
VE::Fixups VEMCExpr::getFixupKind(MCSpecifierExpr::Spec S) {
3939
switch (S) {
4040
default:
4141
llvm_unreachable("Unhandled VEMCExpr::Specifier");
@@ -79,7 +79,3 @@ bool VEMCExpr::evaluateAsRelocatableImpl(MCValue &Res,
7979
Res.setSpecifier(specifier);
8080
return true;
8181
}
82-
83-
void VEMCExpr::visitUsedExpr(MCStreamer &Streamer) const {
84-
Streamer.visitUsedExpr(*getSubExpr());
85-
}

llvm/lib/Target/VE/MCTargetDesc/VEMCExpr.h

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
namespace llvm {
2121

2222
class StringRef;
23-
class VEMCExpr : public MCTargetExpr {
23+
class VEMCExpr : public MCSpecifierExpr {
2424
public:
2525
enum Specifier {
2626
VK_None,
@@ -43,51 +43,20 @@ class VEMCExpr : public MCTargetExpr {
4343
};
4444

4545
private:
46-
const Specifier specifier;
47-
const MCExpr *Expr;
48-
49-
explicit VEMCExpr(Specifier S, const MCExpr *Expr)
50-
: specifier(S), Expr(Expr) {}
46+
explicit VEMCExpr(const MCExpr *Expr, Specifier S)
47+
: MCSpecifierExpr(Expr, S) {}
5148

5249
public:
53-
/// @name Construction
54-
/// @{
55-
5650
static const VEMCExpr *create(Specifier Kind, const MCExpr *Expr,
5751
MCContext &Ctx);
58-
/// @}
59-
/// @name Accessors
60-
/// @{
61-
62-
/// getOpcode - Get the kind of this expression.
63-
Specifier getSpecifier() const { return specifier; }
64-
65-
/// getSubExpr - Get the child of this expression.
66-
const MCExpr *getSubExpr() const { return Expr; }
6752

68-
/// getFixupKind - Get the fixup kind of this expression.
69-
VE::Fixups getFixupKind() const { return getFixupKind(specifier); }
70-
71-
/// @}
7253
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
7354
bool evaluateAsRelocatableImpl(MCValue &Res,
7455
const MCAssembler *Asm) const override;
75-
void visitUsedExpr(MCStreamer &Streamer) const override;
76-
MCFragment *findAssociatedFragment() const override {
77-
return getSubExpr()->findAssociatedFragment();
78-
}
79-
80-
static bool classof(const MCExpr *E) {
81-
return E->getKind() == MCExpr::Target;
82-
}
8356

84-
static VE::Fixups getFixupKind(Specifier S);
57+
static VE::Fixups getFixupKind(Spec S);
8558
};
8659

87-
static inline VEMCExpr::Specifier getSpecifier(const MCSymbolRefExpr *SRE) {
88-
return VEMCExpr::Specifier(SRE->getKind());
89-
}
90-
9160
} // namespace llvm
9261

9362
#endif

0 commit comments

Comments
 (0)