[llvm] c403cf1 - VE: Replace VEMCExpr::printImpl with printSpecifierExpr
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 13 09:50:00 PDT 2025
Author: Fangrui Song
Date: 2025-06-13T09:49:55-07:00
New Revision: c403cf1e38faa456fdd6f1301efabea3f36c3e6b
URL: https://github.com/llvm/llvm-project/commit/c403cf1e38faa456fdd6f1301efabea3f36c3e6b
DIFF: https://github.com/llvm/llvm-project/commit/c403cf1e38faa456fdd6f1301efabea3f36c3e6b.diff
LOG: VE: Replace VEMCExpr::printImpl with printSpecifierExpr
Prepare for removing the VEMCExpr subclass.
VEMCExpr overrides evaluateAsRelocatableImpl, so it cannot be removed
yet.
Added:
Modified:
llvm/lib/Target/VE/MCTargetDesc/VEInstPrinter.cpp
llvm/lib/Target/VE/MCTargetDesc/VEMCAsmInfo.cpp
llvm/lib/Target/VE/MCTargetDesc/VEMCAsmInfo.h
llvm/lib/Target/VE/MCTargetDesc/VEMCExpr.cpp
llvm/lib/Target/VE/MCTargetDesc/VEMCExpr.h
Removed:
################################################################################
diff --git a/llvm/lib/Target/VE/MCTargetDesc/VEInstPrinter.cpp b/llvm/lib/Target/VE/MCTargetDesc/VEInstPrinter.cpp
index 77bd30e96f7b2..b78b86f70f39c 100644
--- a/llvm/lib/Target/VE/MCTargetDesc/VEInstPrinter.cpp
+++ b/llvm/lib/Target/VE/MCTargetDesc/VEInstPrinter.cpp
@@ -12,6 +12,7 @@
#include "VEInstPrinter.h"
#include "VE.h"
+#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCRegisterInfo.h"
@@ -61,7 +62,7 @@ void VEInstPrinter::printOperand(const MCInst *MI, int OpNum,
}
assert(MO.isExpr() && "Unknown operand kind in printOperand");
- MO.getExpr()->print(O, &MAI);
+ MAI.printExpr(O, *MO.getExpr());
}
void VEInstPrinter::printMemASXOperand(const MCInst *MI, int OpNum,
diff --git a/llvm/lib/Target/VE/MCTargetDesc/VEMCAsmInfo.cpp b/llvm/lib/Target/VE/MCTargetDesc/VEMCAsmInfo.cpp
index f290804ae4497..fdde46f09d5b1 100644
--- a/llvm/lib/Target/VE/MCTargetDesc/VEMCAsmInfo.cpp
+++ b/llvm/lib/Target/VE/MCTargetDesc/VEMCAsmInfo.cpp
@@ -56,3 +56,11 @@ VEELFMCAsmInfo::VEELFMCAsmInfo(const Triple &TheTriple) {
initializeVariantKinds(variantKindDescs);
}
+
+void VEELFMCAsmInfo::printSpecifierExpr(raw_ostream &OS,
+ const MCSpecifierExpr &Expr) const {
+ printExpr(OS, *Expr.getSubExpr());
+ auto specifier = Expr.getSpecifier();
+ if (specifier && specifier != VEMCExpr::VK_REFLONG)
+ OS << '@' << getSpecifierName(specifier);
+}
diff --git a/llvm/lib/Target/VE/MCTargetDesc/VEMCAsmInfo.h b/llvm/lib/Target/VE/MCTargetDesc/VEMCAsmInfo.h
index 6557d68b383cd..444f422c7ec12 100644
--- a/llvm/lib/Target/VE/MCTargetDesc/VEMCAsmInfo.h
+++ b/llvm/lib/Target/VE/MCTargetDesc/VEMCAsmInfo.h
@@ -24,6 +24,8 @@ class VEELFMCAsmInfo : public MCAsmInfoELF {
public:
explicit VEELFMCAsmInfo(const Triple &TheTriple);
+ void printSpecifierExpr(raw_ostream &OS,
+ const MCSpecifierExpr &Expr) const override;
};
} // namespace llvm
diff --git a/llvm/lib/Target/VE/MCTargetDesc/VEMCExpr.cpp b/llvm/lib/Target/VE/MCTargetDesc/VEMCExpr.cpp
index a7986ab9006dc..fa4d9b18a9ad9 100644
--- a/llvm/lib/Target/VE/MCTargetDesc/VEMCExpr.cpp
+++ b/llvm/lib/Target/VE/MCTargetDesc/VEMCExpr.cpp
@@ -27,14 +27,6 @@ const VEMCExpr *VEMCExpr::create(Specifier S, const MCExpr *Expr,
return new (Ctx) VEMCExpr(Expr, S);
}
-void VEMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
-
- const MCExpr *Expr = getSubExpr();
- Expr->print(OS, MAI);
- if (specifier != VK_None && specifier != VK_REFLONG)
- OS << '@' << MAI->getSpecifierName(specifier);
-}
-
VE::Fixups VEMCExpr::getFixupKind(MCSpecifierExpr::Spec S) {
switch (S) {
default:
diff --git a/llvm/lib/Target/VE/MCTargetDesc/VEMCExpr.h b/llvm/lib/Target/VE/MCTargetDesc/VEMCExpr.h
index 80ea350a61661..4d191149d4aa0 100644
--- a/llvm/lib/Target/VE/MCTargetDesc/VEMCExpr.h
+++ b/llvm/lib/Target/VE/MCTargetDesc/VEMCExpr.h
@@ -50,7 +50,6 @@ class VEMCExpr : public MCSpecifierExpr {
static const VEMCExpr *create(Specifier Kind, const MCExpr *Expr,
MCContext &Ctx);
- void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
bool evaluateAsRelocatableImpl(MCValue &Res,
const MCAssembler *Asm) const override;
More information about the llvm-commits
mailing list