[llvm] a74fe4a - NVPTX: Register null target streamer
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 31 20:08:21 PDT 2022
Author: Matt Arsenault
Date: 2022-10-31T18:32:33-07:00
New Revision: a74fe4a6a90d60b83c3eb8a55b9fa70dc4963276
URL: https://github.com/llvm/llvm-project/commit/a74fe4a6a90d60b83c3eb8a55b9fa70dc4963276
DIFF: https://github.com/llvm/llvm-project/commit/a74fe4a6a90d60b83c3eb8a55b9fa70dc4963276.diff
LOG: NVPTX: Register null target streamer
Added:
Modified:
llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCTargetDesc.cpp
llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp
llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.h
llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCTargetDesc.cpp b/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCTargetDesc.cpp
index 0ba29fb48b055..50e7cc6371253 100644
--- a/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCTargetDesc.cpp
+++ b/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCTargetDesc.cpp
@@ -63,6 +63,10 @@ static MCInstPrinter *createNVPTXMCInstPrinter(const Triple &T,
static MCTargetStreamer *createTargetAsmStreamer(MCStreamer &S,
formatted_raw_ostream &,
MCInstPrinter *, bool) {
+ return new NVPTXAsmTargetStreamer(S);
+}
+
+static MCTargetStreamer *createNullTargetStreamer(MCStreamer &S) {
return new NVPTXTargetStreamer(S);
}
@@ -86,5 +90,8 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeNVPTXTargetMC() {
// Register the MCTargetStreamer.
TargetRegistry::RegisterAsmTargetStreamer(*T, createTargetAsmStreamer);
+
+ // Register the MCTargetStreamer.
+ TargetRegistry::RegisterNullTargetStreamer(*T, createNullTargetStreamer);
}
}
diff --git a/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp b/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp
index b72cea5d03f13..1aff608cfffbe 100644
--- a/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp
+++ b/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp
@@ -21,9 +21,12 @@ using namespace llvm;
// NVPTXTargetStreamer Implemenation
//
NVPTXTargetStreamer::NVPTXTargetStreamer(MCStreamer &S) : MCTargetStreamer(S) {}
-
NVPTXTargetStreamer::~NVPTXTargetStreamer() = default;
+NVPTXAsmTargetStreamer::NVPTXAsmTargetStreamer(MCStreamer &S)
+ : NVPTXTargetStreamer(S) {}
+NVPTXAsmTargetStreamer::~NVPTXAsmTargetStreamer() = default;
+
void NVPTXTargetStreamer::outputDwarfFileDirectives() {
for (const std::string &S : DwarfFiles)
getStreamer().emitRawText(S);
diff --git a/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.h b/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.h
index 8185efadefdb3..b0d8978ee6857 100644
--- a/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.h
+++ b/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.h
@@ -50,6 +50,12 @@ class NVPTXTargetStreamer : public MCTargetStreamer {
void emitRawBytes(StringRef Data) override;
};
+class NVPTXAsmTargetStreamer : public NVPTXTargetStreamer {
+public:
+ NVPTXAsmTargetStreamer(MCStreamer &S);
+ ~NVPTXAsmTargetStreamer() override;
+};
+
} // end namespace llvm
#endif
diff --git a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
index 968b3a98485b3..55a3626a30b64 100644
--- a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
@@ -895,19 +895,18 @@ bool NVPTXAsmPrinter::doFinalization(Module &M) {
clearAnnotationCache(&M);
- if (auto *TS = static_cast<NVPTXTargetStreamer *>(
- OutStreamer->getTargetStreamer())) {
- // Close the last emitted section
- if (HasDebugInfo) {
- TS->closeLastSection();
- // Emit empty .debug_loc section for better support of the empty files.
- OutStreamer->emitRawText("\t.section\t.debug_loc\t{\t}");
- }
-
- // Output last DWARF .file directives, if any.
- TS->outputDwarfFileDirectives();
+ auto *TS =
+ static_cast<NVPTXTargetStreamer *>(OutStreamer->getTargetStreamer());
+ // Close the last emitted section
+ if (HasDebugInfo) {
+ TS->closeLastSection();
+ // Emit empty .debug_loc section for better support of the empty files.
+ OutStreamer->emitRawText("\t.section\t.debug_loc\t{\t}");
}
+ // Output last DWARF .file directives, if any.
+ TS->outputDwarfFileDirectives();
+
return ret;
//bool Result = AsmPrinter::doFinalization(M);
More information about the llvm-commits
mailing list