Skip to content

Commit 532facc

Browse files
committed
ARMMCExpr: Migrate to MCSpecifierExpr
1 parent 49a706d commit 532facc

File tree

5 files changed

+8
-38
lines changed

5 files changed

+8
-38
lines changed

llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ unsigned ARMAsmBackend::adjustFixupValue(const MCAssembler &Asm,
619619
// Offset by 8 just as above.
620620
if (const MCSymbolRefExpr *SRE =
621621
dyn_cast<MCSymbolRefExpr>(Fixup.getValue()))
622-
if (getSpecifier(SRE) == ARMMCExpr::VK_TLSCALL)
622+
if (SRE->getSpecifier() == ARMMCExpr::VK_TLSCALL)
623623
return 0;
624624
return 0xffffff & (Value >> 2);
625625
case ARM::fixup_t2_uncondbranch: {
@@ -746,7 +746,7 @@ unsigned ARMAsmBackend::adjustFixupValue(const MCAssembler &Asm,
746746
uint32_t offset = (Value - 4) >> 2;
747747
if (const MCSymbolRefExpr *SRE =
748748
dyn_cast<MCSymbolRefExpr>(Fixup.getValue()))
749-
if (getSpecifier(SRE) == ARMMCExpr::VK_TLSCALL)
749+
if (SRE->getSpecifier() == ARMMCExpr::VK_TLSCALL)
750750
offset = 0;
751751
uint32_t signBit = (offset & 0x400000) >> 22;
752752
uint32_t I1Bit = (offset & 0x200000) >> 21;

llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ class ARMELFStreamer : public MCELFStreamer {
590590
/// necessary.
591591
void emitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc) override {
592592
if (const MCSymbolRefExpr *SRE = dyn_cast_or_null<MCSymbolRefExpr>(Value)) {
593-
if (getSpecifier(SRE) == ARMMCExpr::VK_SBREL && !(Size == 4)) {
593+
if (SRE->getSpecifier() == ARMMCExpr::VK_SBREL && !(Size == 4)) {
594594
getContext().reportError(Loc, "relocated expression must be 32-bit");
595595
return;
596596
}

llvm/lib/Target/ARM/MCTargetDesc/ARMMCCodeEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1191,7 +1191,7 @@ uint32_t ARMMCCodeEmitter::getHiLoImmOpValue(const MCInst &MI, unsigned OpIdx,
11911191
// :lower0_7: assembly prefixes.
11921192
const MCExpr *E = MO.getExpr();
11931193
MCFixupKind Kind;
1194-
if (E->getKind() == MCExpr::Target) {
1194+
if (E->getKind() == MCExpr::Specifier) {
11951195
const ARMMCExpr *ARM16Expr = cast<ARMMCExpr>(E);
11961196
E = ARM16Expr->getSubExpr();
11971197

llvm/lib/Target/ARM/MCTargetDesc/ARMMCExpr.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,3 @@ void ARMMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
4848
if (Expr->getKind() != MCExpr::SymbolRef)
4949
OS << ')';
5050
}
51-
52-
void ARMMCExpr::visitUsedExpr(MCStreamer &Streamer) const {
53-
Streamer.visitUsedExpr(*getSubExpr());
54-
}

llvm/lib/Target/ARM/MCTargetDesc/ARMMCExpr.h

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313

1414
namespace llvm {
1515

16-
class ARMMCExpr : public MCTargetExpr {
16+
class ARMMCExpr : public MCSpecifierExpr {
1717
public:
18-
enum Specifier {
18+
using Specifier = uint16_t;
19+
enum {
1920
VK_None,
2021
VK_HI16 =
2122
MCSymbolRefExpr::FirstTargetSpecifier, // The R_ARM_MOVT_ABS relocation
@@ -57,16 +58,10 @@ class ARMMCExpr : public MCTargetExpr {
5758
};
5859

5960
private:
60-
const Specifier specifier;
61-
const MCExpr *Expr;
62-
6361
explicit ARMMCExpr(Specifier S, const MCExpr *Expr)
64-
: specifier(S), Expr(Expr) {}
62+
: MCSpecifierExpr(Expr, S) {}
6563

6664
public:
67-
/// @name Construction
68-
/// @{
69-
7065
static const ARMMCExpr *create(Specifier S, const MCExpr *Expr,
7166
MCContext &Ctx);
7267

@@ -94,33 +89,12 @@ class ARMMCExpr : public MCTargetExpr {
9489
return create(VK_LO_0_7, Expr, Ctx);
9590
}
9691

97-
/// @}
98-
/// @name Accessors
99-
/// @{
100-
101-
Specifier getSpecifier() const { return specifier; }
102-
const MCExpr *getSubExpr() const { return Expr; }
103-
104-
/// @}
105-
10692
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
10793
bool evaluateAsRelocatableImpl(MCValue &Res,
10894
const MCAssembler *Asm) const override {
10995
return false;
11096
}
111-
void visitUsedExpr(MCStreamer &Streamer) const override;
112-
MCFragment *findAssociatedFragment() const override {
113-
return getSubExpr()->findAssociatedFragment();
114-
}
115-
116-
static bool classof(const MCExpr *E) {
117-
return E->getKind() == MCExpr::Target;
118-
}
11997
};
120-
121-
static inline ARMMCExpr::Specifier getSpecifier(const MCSymbolRefExpr *SRE) {
122-
return ARMMCExpr::Specifier(SRE->getKind());
123-
}
12498
} // end namespace llvm
12599

126100
#endif

0 commit comments

Comments
 (0)