[llvm] 2f1c082 - SystemZMCExpr: Migrate to MCSpecifierExpr

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 8 00:10:20 PDT 2025


Author: Fangrui Song
Date: 2025-06-08T00:10:15-07:00
New Revision: 2f1c08215fb584a27987be74e2db48761cd29ebe

URL: https://github.com/llvm/llvm-project/commit/2f1c08215fb584a27987be74e2db48761cd29ebe
DIFF: https://github.com/llvm/llvm-project/commit/2f1c08215fb584a27987be74e2db48761cd29ebe.diff

LOG: SystemZMCExpr: Migrate to MCSpecifierExpr

Added: 
    

Modified: 
    llvm/lib/Target/SystemZ/MCTargetDesc/SystemZInstPrinterCommon.cpp
    llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCExpr.cpp
    llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCExpr.h

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZInstPrinterCommon.cpp b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZInstPrinterCommon.cpp
index b03ad98f2c38e..5ba55e27a6136 100644
--- a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZInstPrinterCommon.cpp
+++ b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZInstPrinterCommon.cpp
@@ -185,7 +185,7 @@ void SystemZInstPrinterCommon::printPCRelTLSOperand(const MCInst *MI,
   if ((unsigned)OpNum + 1 < MI->getNumOperands()) {
     const MCOperand &MO = MI->getOperand(OpNum + 1);
     const MCSymbolRefExpr &refExp = cast<MCSymbolRefExpr>(*MO.getExpr());
-    switch (getSpecifier(&refExp)) {
+    switch (refExp.getSpecifier()) {
     case SystemZMCExpr::VK_TLSGD:
       O << ":tls_gdcall:";
       break;

diff  --git a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCExpr.cpp b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCExpr.cpp
index 41e41a1a7b66a..0167eae60452e 100644
--- a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCExpr.cpp
+++ b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCExpr.cpp
@@ -12,9 +12,9 @@ using namespace llvm;
 
 #define DEBUG_TYPE "systemzmcexpr"
 
-const SystemZMCExpr *SystemZMCExpr::create(SystemZMCExpr::Specifier Kind,
+const SystemZMCExpr *SystemZMCExpr::create(MCSpecifierExpr::Spec S,
                                            const MCExpr *Expr, MCContext &Ctx) {
-  return new (Ctx) SystemZMCExpr(Kind, Expr);
+  return new (Ctx) SystemZMCExpr(Expr, S);
 }
 
 StringRef SystemZMCExpr::getVariantKindName() const {

diff  --git a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCExpr.h b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCExpr.h
index 39b8ea14de0d8..ac1de97ecf0a1 100644
--- a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCExpr.h
+++ b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCExpr.h
@@ -15,9 +15,10 @@
 
 namespace llvm {
 
-class SystemZMCExpr : public MCTargetExpr {
+class SystemZMCExpr : public MCSpecifierExpr {
 public:
-  enum Specifier : uint8_t {
+  using Specifier = Spec;
+  enum {
     VK_None,
 
     VK_DTPOFF = MCSymbolRefExpr::FirstTargetSpecifier,
@@ -37,40 +38,19 @@ class SystemZMCExpr : public MCTargetExpr {
   };
 
 private:
-  const Specifier specifier;
-  const MCExpr *Expr;
-
-  explicit SystemZMCExpr(Specifier S, const MCExpr *Expr)
-      : specifier(S), Expr(Expr) {}
+  explicit SystemZMCExpr(const MCExpr *Expr, Spec S)
+      : MCSpecifierExpr(Expr, S) {}
 
 public:
-  static const SystemZMCExpr *create(Specifier Kind, const MCExpr *Expr,
+  static const SystemZMCExpr *create(Spec Kind, const MCExpr *Expr,
                                      MCContext &Ctx);
 
-  Specifier getSpecifier() const { return specifier; }
-  const MCExpr *getSubExpr() const { return Expr; }
-
   StringRef getVariantKindName() const;
 
   void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
   bool evaluateAsRelocatableImpl(MCValue &Res,
                                  const MCAssembler *Asm) const override;
-  void visitUsedExpr(MCStreamer &Streamer) const override {
-    Streamer.visitUsedExpr(*getSubExpr());
-  }
-  MCFragment *findAssociatedFragment() const override {
-    return getSubExpr()->findAssociatedFragment();
-  }
-
-  static bool classof(const MCExpr *E) {
-    return E->getKind() == MCExpr::Target;
-  }
 };
-
-static inline SystemZMCExpr::Specifier
-getSpecifier(const MCSymbolRefExpr *SRE) {
-  return SystemZMCExpr::Specifier(SRE->getKind());
-}
 } // end namespace llvm
 
 #endif


        


More information about the llvm-commits mailing list