-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Conversation
@llvm/pr-subscribers-backend-systemz Author: None (tltao) ChangesNow 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:
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
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Now that we have a SystemZTargetStreamer file from #130535, move some TargetStreamer classes and methods from TargetDesc to the proper file.