Skip to content

Commit 30350af

Browse files
committed
MCSpecifierExpr: Remove unused virtual functions
... now that all targets using MCSpecifierExpr have migrated to XXXMCAsmInfo::printExpr/evaluateAsRelocatableImpl.
1 parent 199428e commit 30350af

File tree

4 files changed

+11
-28
lines changed

4 files changed

+11
-28
lines changed

llvm/include/llvm/MC/MCAsmInfo.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,10 @@ class LLVM_ABI MCAsmInfo {
715715
std::optional<uint32_t> getSpecifierForName(StringRef Name) const;
716716

717717
void printExpr(raw_ostream &, const MCExpr &) const;
718-
virtual void printSpecifierExpr(raw_ostream &, const MCSpecifierExpr &) const;
718+
virtual void printSpecifierExpr(raw_ostream &,
719+
const MCSpecifierExpr &) const {
720+
llvm_unreachable("Need to implement hook if target uses MCSpecifierExpr");
721+
}
719722
virtual bool evaluateAsRelocatableImpl(const MCSpecifierExpr &, MCValue &Res,
720723
const MCAssembler *Asm) const;
721724
};

llvm/include/llvm/MC/MCExpr.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,6 @@ class LLVM_ABI MCSpecifierExpr : public MCExpr {
512512

513513
explicit MCSpecifierExpr(const MCExpr *Expr, Spec S, SMLoc Loc = SMLoc())
514514
: MCExpr(Specifier, Loc), Expr(Expr), specifier(S) {}
515-
virtual ~MCSpecifierExpr() = default;
516515

517516
public:
518517
LLVM_ABI static const MCSpecifierExpr *
@@ -523,12 +522,6 @@ class LLVM_ABI MCSpecifierExpr : public MCExpr {
523522
Spec getSpecifier() const { return specifier; }
524523
const MCExpr *getSubExpr() const { return Expr; }
525524

526-
virtual void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
527-
llvm_unreachable("Replace MCExpr::print calls with MCAsmInfo::printExpr");
528-
}
529-
virtual bool evaluateAsRelocatableImpl(MCValue &Res,
530-
const MCAssembler *Asm) const;
531-
532525
static bool classof(const MCExpr *E) {
533526
return E->getKind() == MCExpr::Specifier;
534527
}

llvm/lib/MC/MCAsmInfo.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "llvm/MC/MCContext.h"
1818
#include "llvm/MC/MCExpr.h"
1919
#include "llvm/MC/MCStreamer.h"
20+
#include "llvm/MC/MCValue.h"
2021
#include "llvm/Support/Casting.h"
2122
#include "llvm/Support/CommandLine.h"
2223

@@ -157,17 +158,12 @@ void MCAsmInfo::printExpr(raw_ostream &OS, const MCExpr &Expr) const {
157158
Expr.print(OS, this);
158159
}
159160

160-
void MCAsmInfo::printSpecifierExpr(raw_ostream &OS,
161-
const MCSpecifierExpr &Expr) const {
162-
// TODO: Switch to unreachable after all targets that use MCSpecifierExpr
163-
// migrate to MCAsmInfo::printSpecifierExpr.
164-
Expr.printImpl(OS, this);
165-
}
166-
167-
bool MCAsmInfo::evaluateAsRelocatableImpl(const MCSpecifierExpr &Expr,
161+
bool MCAsmInfo::evaluateAsRelocatableImpl(const MCSpecifierExpr &E,
168162
MCValue &Res,
169163
const MCAssembler *Asm) const {
170-
// TODO: Remove after all targets that use MCSpecifierExpr migrate to
171-
// MCAsmInfo::evaluateAsRelocatableImpl.
172-
return Expr.evaluateAsRelocatableImpl(Res, Asm);
164+
if (!E.getSubExpr()->evaluateAsRelocatable(Res, Asm))
165+
return false;
166+
167+
Res.setSpecifier(E.getSpecifier());
168+
return !Res.getSubSym();
173169
}

llvm/lib/MC/MCExpr.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -754,12 +754,3 @@ const MCSpecifierExpr *MCSpecifierExpr::create(const MCSymbol *Sym, Spec S,
754754
MCContext &Ctx, SMLoc Loc) {
755755
return new (Ctx) MCSpecifierExpr(MCSymbolRefExpr::create(Sym, Ctx), S, Loc);
756756
}
757-
758-
bool MCSpecifierExpr::evaluateAsRelocatableImpl(MCValue &Res,
759-
const MCAssembler *Asm) const {
760-
if (!getSubExpr()->evaluateAsRelocatable(Res, Asm))
761-
return false;
762-
763-
Res.setSpecifier(specifier);
764-
return !Res.getSubSym();
765-
}

0 commit comments

Comments
 (0)