Skip to content

Commit ef328e9

Browse files
committed
MipsMCExpr: Migrate to MCSpecifierExpr
1 parent 5c76ae2 commit ef328e9

File tree

4 files changed

+10
-30
lines changed

4 files changed

+10
-30
lines changed

llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,7 +1305,7 @@ class MipsOperand : public MCParsedAsmOperand {
13051305
return false;
13061306
if (!getMemBase()->isGPRAsmReg())
13071307
return false;
1308-
if (isa<MCTargetExpr>(getMemOff()) ||
1308+
if (isa<MCSpecifierExpr>(getMemOff()) ||
13091309
(isConstantMemOff() &&
13101310
isShiftedInt<Bits, ShiftAmount>(getConstantMemOff())))
13111311
return true;
@@ -1320,7 +1320,7 @@ class MipsOperand : public MCParsedAsmOperand {
13201320
if (!getMemBase()->isGPRAsmReg())
13211321
return false;
13221322
const unsigned PtrBits = AsmParser.getABI().ArePtrs64bit() ? 64 : 32;
1323-
if (isa<MCTargetExpr>(getMemOff()) ||
1323+
if (isa<MCSpecifierExpr>(getMemOff()) ||
13241324
(isConstantMemOff() && isIntN(PtrBits, getConstantMemOff())))
13251325
return true;
13261326
MCValue Res;
@@ -1784,9 +1784,9 @@ static bool isEvaluated(const MCExpr *Expr) {
17841784
case MCExpr::Unary:
17851785
return isEvaluated(cast<MCUnaryExpr>(Expr)->getSubExpr());
17861786
case MCExpr::Specifier:
1787-
llvm_unreachable("unused by this backend");
1788-
case MCExpr::Target:
17891787
return true;
1788+
case MCExpr::Target:
1789+
llvm_unreachable("unused by this backend");
17901790
}
17911791
return false;
17921792
}

llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ unsigned MipsMCCodeEmitter::
580580
getExprOpValue(const MCExpr *Expr, SmallVectorImpl<MCFixup> &Fixups,
581581
const MCSubtargetInfo &STI) const {
582582
MCExpr::ExprKind Kind = Expr->getKind();
583-
if (Kind == MCExpr::Target) {
583+
if (Kind == MCExpr::Specifier) {
584584
const MipsMCExpr *MipsExpr = cast<MipsMCExpr>(Expr);
585585

586586
Mips::Fixups FixupKind = Mips::Fixups(0);
@@ -733,7 +733,7 @@ unsigned MipsMCCodeEmitter::getImmOpValue(const MCInst &MI, const MCOperand &MO,
733733
if (Expr->evaluateAsAbsolute(Res))
734734
return Res;
735735
unsigned MIFrm = MipsII::getFormat(MCII.get(MI.getOpcode()).TSFlags);
736-
if (!isa<MCTargetExpr>(Expr) && MIFrm == MipsII::FrmI) {
736+
if (!isa<MCSpecifierExpr>(Expr) && MIFrm == MipsII::FrmI) {
737737
Fixups.push_back(MCFixup::create(
738738
0, Expr, MCFixupKind(Mips::fixup_Mips_AnyImm16), Expr->getLoc()));
739739
return 0;

llvm/lib/Target/Mips/MCTargetDesc/MipsMCExpr.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,6 @@ bool MipsMCExpr::evaluateAsRelocatableImpl(MCValue &Res,
152152
return !Res.getSubSym();
153153
}
154154

155-
void MipsMCExpr::visitUsedExpr(MCStreamer &Streamer) const {
156-
Streamer.visitUsedExpr(*getSubExpr());
157-
}
158-
159155
bool MipsMCExpr::isGpOff(Specifier &S) const {
160156
if (getSpecifier() == MEK_HI || getSpecifier() == MEK_LO) {
161157
if (const MipsMCExpr *S1 = dyn_cast<const MipsMCExpr>(getSubExpr())) {

llvm/lib/Target/Mips/MCTargetDesc/MipsMCExpr.h

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414

1515
namespace llvm {
1616

17-
class MipsMCExpr : public MCTargetExpr {
17+
class MipsMCExpr : public MCSpecifierExpr {
1818
public:
19-
enum Specifier {
19+
using Specifier = Spec;
20+
enum {
2021
MEK_None,
2122
MEK_CALL_HI16,
2223
MEK_CALL_LO16,
@@ -47,11 +48,8 @@ class MipsMCExpr : public MCTargetExpr {
4748
};
4849

4950
private:
50-
const MCExpr *Expr;
51-
const Specifier specifier;
52-
5351
explicit MipsMCExpr(const MCExpr *Expr, Specifier S)
54-
: Expr(Expr), specifier(S) {}
52+
: MCSpecifierExpr(Expr, S) {}
5553

5654
public:
5755
static const MipsMCExpr *create(Specifier S, const MCExpr *Expr,
@@ -61,23 +59,9 @@ class MipsMCExpr : public MCTargetExpr {
6159
static const MipsMCExpr *createGpOff(Specifier S, const MCExpr *Expr,
6260
MCContext &Ctx);
6361

64-
Specifier getSpecifier() const { return specifier; }
65-
66-
/// Get the child of this expression.
67-
const MCExpr *getSubExpr() const { return Expr; }
68-
6962
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
7063
bool evaluateAsRelocatableImpl(MCValue &Res,
7164
const MCAssembler *Asm) const override;
72-
void visitUsedExpr(MCStreamer &Streamer) const override;
73-
74-
MCFragment *findAssociatedFragment() const override {
75-
return getSubExpr()->findAssociatedFragment();
76-
}
77-
78-
static bool classof(const MCExpr *E) {
79-
return E->getKind() == MCExpr::Target;
80-
}
8165

8266
bool isGpOff(Specifier &S) const;
8367
bool isGpOff() const {

0 commit comments

Comments
 (0)