Skip to content

Commit 00a1318

Browse files
committed
LoongArchMCExpr: Migrate to MCSpecifierExpr
1 parent df46140 commit 00a1318

File tree

3 files changed

+3
-35
lines changed

3 files changed

+3
-35
lines changed

llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCCodeEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ LoongArchMCCodeEmitter::getExprOpValue(const MCInst &MI, const MCOperand &MO,
130130
const MCExpr *Expr = MO.getExpr();
131131
MCExpr::ExprKind Kind = Expr->getKind();
132132
unsigned FixupKind = LoongArch::fixup_loongarch_invalid;
133-
if (Kind == MCExpr::Target) {
133+
if (Kind == MCExpr::Specifier) {
134134
const LoongArchMCExpr *LAExpr = cast<LoongArchMCExpr>(Expr);
135135
FixupKind = LAExpr->getSpecifier();
136136
RelaxCandidate = LAExpr->getRelaxHint();

llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCExpr.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,6 @@ void LoongArchMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
3838
OS << ')';
3939
}
4040

41-
bool LoongArchMCExpr::evaluateAsRelocatableImpl(
42-
MCValue &Res,
43-
const MCAssembler *Asm) const { // Explicitly drop the layout and assembler
44-
// to prevent any symbolic folding in
45-
// the expression handling. This is required to preserve symbolic difference
46-
// expressions to emit the paired relocations.
47-
if (!getSubExpr()->evaluateAsRelocatable(Res, nullptr))
48-
return false;
49-
50-
Res.setSpecifier(specifier);
51-
// Custom fixup types are not valid with symbol difference expressions.
52-
return !Res.getSubSym();
53-
}
54-
55-
void LoongArchMCExpr::visitUsedExpr(MCStreamer &Streamer) const {
56-
Streamer.visitUsedExpr(*getSubExpr());
57-
}
58-
5941
StringRef LoongArchMCExpr::getSpecifierName(uint16_t S) {
6042
switch (S) {
6143
default:

llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCExpr.h

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,38 +20,24 @@ namespace llvm {
2020

2121
class StringRef;
2222

23-
class LoongArchMCExpr : public MCTargetExpr {
23+
class LoongArchMCExpr : public MCSpecifierExpr {
2424
public:
2525
using Specifier = uint16_t;
2626
enum { VK_None };
2727

2828
private:
29-
const MCExpr *Expr;
30-
const Specifier specifier;
3129
const bool RelaxHint;
3230

3331
explicit LoongArchMCExpr(const MCExpr *Expr, Specifier S, bool Hint)
34-
: Expr(Expr), specifier(S), RelaxHint(Hint) {}
32+
: MCSpecifierExpr(Expr, S), RelaxHint(Hint) {}
3533

3634
public:
3735
static const LoongArchMCExpr *create(const MCExpr *Expr, uint16_t S,
3836
MCContext &Ctx, bool Hint = false);
3937

40-
Specifier getSpecifier() const { return specifier; }
41-
const MCExpr *getSubExpr() const { return Expr; }
4238
bool getRelaxHint() const { return RelaxHint; }
4339

4440
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
45-
bool evaluateAsRelocatableImpl(MCValue &Res,
46-
const MCAssembler *Asm) const override;
47-
void visitUsedExpr(MCStreamer &Streamer) const override;
48-
MCFragment *findAssociatedFragment() const override {
49-
return getSubExpr()->findAssociatedFragment();
50-
}
51-
52-
static bool classof(const MCExpr *E) {
53-
return E->getKind() == MCExpr::Target;
54-
}
5541

5642
static StringRef getSpecifierName(uint16_t S);
5743
static Specifier parseSpecifier(StringRef name);

0 commit comments

Comments
 (0)