Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SystemZ] Move some SystemZTargetStreamer classes to proper file #132476

Merged
merged 2 commits into from
Mar 22, 2025

Conversation

tltao
Copy link
Contributor

@tltao tltao commented Mar 21, 2025

Now that we have a SystemZTargetStreamer file from #130535, move some TargetStreamer classes and methods from TargetDesc to the proper file.

@llvmbot
Copy link
Member

llvmbot commented Mar 21, 2025

@llvm/pr-subscribers-backend-systemz

Author: None (tltao)

Changes

Now that we have a SystemZTargetStreamer file from #130535, move some TargetStreamer classes from TargetDesc to the proper file.


Full diff: https://github.com/llvm/llvm-project/pull/132476.diff

3 Files Affected:

  • (modified) llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp (+1-35)
  • (modified) llvm/lib/Target/SystemZ/MCTargetDesc/SystemZTargetStreamer.cpp (+16)
  • (modified) llvm/lib/Target/SystemZ/MCTargetDesc/SystemZTargetStreamer.h (+18)
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

@tltao tltao requested a review from uweigand March 21, 2025 21:43
Copy link

github-actions bot commented Mar 21, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link
Member

@uweigand uweigand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@tltao tltao merged commit b9180c5 into llvm:main Mar 22, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants