[llvm] [SystemZ] Move some SystemZTargetStreamer classes to proper file (PR #132476)

via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 21 14:48:54 PDT 2025


https://github.com/tltao updated https://github.com/llvm/llvm-project/pull/132476

>From ec8b90cc19fde39f4881fc0a7e7be2b05ae3d71d Mon Sep 17 00:00:00 2001
From: Tony Tao <tonytao at ca.ibm.com>
Date: Fri, 21 Mar 2025 17:40:40 -0400
Subject: [PATCH 1/2] Move some SystemZTargetStreamer classes to proper file

---
 .../MCTargetDesc/SystemZMCTargetDesc.cpp      | 36 +------------------
 .../MCTargetDesc/SystemZTargetStreamer.cpp    | 16 +++++++++
 .../MCTargetDesc/SystemZTargetStreamer.h      | 18 ++++++++++
 3 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp
index 0fb5c30d37d2b..c010c2c0025b8 100644
--- a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp
+++ b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp
@@ -183,47 +183,13 @@ static MCInstPrinter *createSystemZMCInstPrinter(const Triple &T,
   return new SystemZGNUInstPrinter(MAI, MII, MRI);
 }
 
-void SystemZTargetStreamer::emitConstantPools() {
-  // Emit EXRL target instructions.
-  if (EXRLTargets2Sym.empty())
-    return;
-  // Switch to the .text section.
-  const MCObjectFileInfo &OFI = *Streamer.getContext().getObjectFileInfo();
-  Streamer.switchSection(OFI.getTextSection());
-  for (auto &I : EXRLTargets2Sym) {
-    Streamer.emitLabel(I.second);
-    const MCInstSTIPair &MCI_STI = I.first;
-    Streamer.emitInstruction(MCI_STI.first, *MCI_STI.second);
-  }
-  EXRLTargets2Sym.clear();
-}
-
-namespace {
-class SystemZTargetAsmStreamer : public SystemZTargetStreamer {
-  formatted_raw_ostream &OS;
-
-public:
-  SystemZTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS)
-      : SystemZTargetStreamer(S), OS(OS) {}
-  void emitMachine(StringRef CPU) override {
-    OS << "\t.machine " << CPU << "\n";
-  }
-};
-
-class SystemZTargetELFStreamer : public SystemZTargetStreamer {
-public:
-  SystemZTargetELFStreamer(MCStreamer &S) : SystemZTargetStreamer(S) {}
-  void emitMachine(StringRef CPU) override {}
-};
-} // end namespace
-
 static MCTargetStreamer *createAsmTargetStreamer(MCStreamer &S,
                                                  formatted_raw_ostream &OS,
                                                  MCInstPrinter *InstPrint) {
   if (S.getContext().getTargetTriple().isOSzOS())
     return new SystemZTargetHLASMStreamer(S, OS);
   else
-    return new SystemZTargetAsmStreamer(S, OS);
+    return new SystemZTargetGNUStreamer(S, OS);
 }
 
 static MCStreamer *createAsmStreamer(MCContext &Ctx,
diff --git a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZTargetStreamer.cpp b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZTargetStreamer.cpp
index 1946cd1da8506..a4506eddaa69b 100644
--- a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZTargetStreamer.cpp
+++ b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZTargetStreamer.cpp
@@ -13,9 +13,25 @@
 //===----------------------------------------------------------------------===//
 
 #include "SystemZTargetStreamer.h"
+#include "llvm/MC/MCObjectFileInfo.h"
 
 using namespace llvm;
 
+void SystemZTargetStreamer::emitConstantPools() {
+  // Emit EXRL target instructions.
+  if (EXRLTargets2Sym.empty())
+    return;
+  // Switch to the .text section.
+  const MCObjectFileInfo &OFI = *Streamer.getContext().getObjectFileInfo();
+  Streamer.switchSection(OFI.getTextSection());
+  for (auto &I : EXRLTargets2Sym) {
+    Streamer.emitLabel(I.second);
+    const MCInstSTIPair &MCI_STI = I.first;
+    Streamer.emitInstruction(MCI_STI.first, *MCI_STI.second);
+  }
+  EXRLTargets2Sym.clear();
+}
+
 void SystemZTargetHLASMStreamer::emitExtern(StringRef Sym) {
   getStreamer().emitRawText(Twine(" EXTRN ") + Twine(Sym));
 }
diff --git a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZTargetStreamer.h b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZTargetStreamer.h
index 26be26e287412..ecfcff56ee9d0 100644
--- a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZTargetStreamer.h
+++ b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZTargetStreamer.h
@@ -82,6 +82,24 @@ class SystemZTargetHLASMStreamer : public SystemZTargetStreamer {
                                    const MCSymbol *Lo) override;
 };
 
+class SystemZTargetELFStreamer : public SystemZTargetStreamer {
+public:
+  SystemZTargetELFStreamer(MCStreamer &S) : SystemZTargetStreamer(S) {}
+  void emitMachine(StringRef CPU) override {}
+};
+
+class SystemZTargetGNUStreamer : public SystemZTargetStreamer {
+  formatted_raw_ostream &OS;
+
+public:
+  SystemZTargetGNUStreamer(MCStreamer &S, formatted_raw_ostream &OS)
+      : SystemZTargetStreamer(S), OS(OS) {}
+  void emitMachine(StringRef CPU) override {
+    OS << "\t.machine " << CPU << "\n";
+  }
+};
+
+
 } // end namespace llvm
 
 #endif // LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZTARGETSTREAMER_H

>From 7171b7e6b2050af0e2b19b55da0794265ab3823b Mon Sep 17 00:00:00 2001
From: Tony Tao <tonytao at ca.ibm.com>
Date: Fri, 21 Mar 2025 17:48:46 -0400
Subject: [PATCH 2/2] remove extra empty space

---
 llvm/lib/Target/SystemZ/MCTargetDesc/SystemZTargetStreamer.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZTargetStreamer.h b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZTargetStreamer.h
index ecfcff56ee9d0..15617101fd08a 100644
--- a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZTargetStreamer.h
+++ b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZTargetStreamer.h
@@ -99,7 +99,6 @@ class SystemZTargetGNUStreamer : public SystemZTargetStreamer {
   }
 };
 
-
 } // end namespace llvm
 
 #endif // LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZTARGETSTREAMER_H



More information about the llvm-commits mailing list