[llvm] 0ebab8b - PPC: Implement null target streamer
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 18 19:07:01 PST 2022
Author: Matt Arsenault
Date: 2022-12-18T22:06:56-05:00
New Revision: 0ebab8bae4215000ec73c0233f929466fc05a038
URL: https://github.com/llvm/llvm-project/commit/0ebab8bae4215000ec73c0233f929466fc05a038
DIFF: https://github.com/llvm/llvm-project/commit/0ebab8bae4215000ec73c0233f929466fc05a038.diff
LOG: PPC: Implement null target streamer
Added:
Modified:
llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp
llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
llvm/lib/Target/PowerPC/PPCTargetStreamer.h
Removed:
################################################################################
diff --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp
index 9b37c862dbd0b..10e352923c1a9 100644
--- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp
+++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp
@@ -352,6 +352,10 @@ static MCTargetStreamer *createAsmTargetStreamer(MCStreamer &S,
return new PPCTargetAsmStreamer(S, OS);
}
+static MCTargetStreamer *createNullTargetStreamer(MCStreamer &S) {
+ return new PPCTargetStreamer(S);
+}
+
static MCTargetStreamer *
createObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI) {
const Triple &TT = STI.getTargetTriple();
@@ -432,6 +436,9 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializePowerPCTargetMC() {
// Register the asm target streamer.
TargetRegistry::RegisterAsmTargetStreamer(*T, createAsmTargetStreamer);
+ // Register the null target streamer.
+ TargetRegistry::RegisterNullTargetStreamer(*T, createNullTargetStreamer);
+
// Register the MCInstPrinter.
TargetRegistry::RegisterMCInstPrinter(*T, createPPCMCInstPrinter);
}
diff --git a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
index 955f8cd44e8d2..30e96cff9e2c3 100644
--- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
@@ -1572,9 +1572,7 @@ void PPCLinuxAsmPrinter::emitStartOfAsmFile(Module &M) {
if (static_cast<const PPCTargetMachine &>(TM).isELFv2ABI()) {
PPCTargetStreamer *TS =
static_cast<PPCTargetStreamer *>(OutStreamer->getTargetStreamer());
-
- if (TS)
- TS->emitAbiVersion(2);
+ TS->emitAbiVersion(2);
}
if (static_cast<const PPCTargetMachine &>(TM).isPPC64() ||
@@ -1700,7 +1698,7 @@ void PPCLinuxAsmPrinter::emitEndOfAsmFile(Module &M) {
MCSymbol *const TOCEntryLabel = TOCMapPair.second;
OutStreamer->emitLabel(TOCEntryLabel);
- if (isPPC64 && TS != nullptr)
+ if (isPPC64)
TS->emitTCEntry(*TOCEntryTarget, TOCMapPair.first.second);
else
OutStreamer->emitSymbolValue(TOCEntryTarget, 4);
@@ -1806,9 +1804,7 @@ void PPCLinuxAsmPrinter::emitFunctionBodyStart() {
PPCTargetStreamer *TS =
static_cast<PPCTargetStreamer *>(OutStreamer->getTargetStreamer());
-
- if (TS)
- TS->emitLocalEntry(cast<MCSymbolELF>(CurrentFnSym), LocalOffsetExp);
+ TS->emitLocalEntry(cast<MCSymbolELF>(CurrentFnSym), LocalOffsetExp);
} else if (Subtarget->isUsingPCRelativeCalls()) {
// When generating the entry point for a function we have a few scenarios
// based on whether or not that function uses R2 and whether or not that
@@ -1835,9 +1831,8 @@ void PPCLinuxAsmPrinter::emitFunctionBodyStart() {
MF->hasInlineAsm() || (!PPCFI->usesTOCBasePtr() && UsesX2OrR2)) {
PPCTargetStreamer *TS =
static_cast<PPCTargetStreamer *>(OutStreamer->getTargetStreamer());
- if (TS)
- TS->emitLocalEntry(cast<MCSymbolELF>(CurrentFnSym),
- MCConstantExpr::create(1, OutContext));
+ TS->emitLocalEntry(cast<MCSymbolELF>(CurrentFnSym),
+ MCConstantExpr::create(1, OutContext));
}
}
}
@@ -2568,8 +2563,7 @@ void PPCAIXAsmPrinter::emitEndOfAsmFile(Module &M) {
OutStreamer->switchSection(TCEntry);
OutStreamer->emitLabel(I.second);
- if (TS != nullptr)
- TS->emitTCEntry(*I.first.first, I.first.second);
+ TS->emitTCEntry(*I.first.first, I.first.second);
}
for (const auto *GV : TOCDataGlobalVars)
diff --git a/llvm/lib/Target/PowerPC/PPCTargetStreamer.h b/llvm/lib/Target/PowerPC/PPCTargetStreamer.h
index e3fc6285494c5..daf5b93ff21f0 100644
--- a/llvm/lib/Target/PowerPC/PPCTargetStreamer.h
+++ b/llvm/lib/Target/PowerPC/PPCTargetStreamer.h
@@ -25,10 +25,10 @@ class PPCTargetStreamer : public MCTargetStreamer {
~PPCTargetStreamer() override;
virtual void emitTCEntry(const MCSymbol &S,
- MCSymbolRefExpr::VariantKind Kind) = 0;
- virtual void emitMachine(StringRef CPU) = 0;
- virtual void emitAbiVersion(int AbiVersion) = 0;
- virtual void emitLocalEntry(MCSymbolELF *S, const MCExpr *LocalOffset) = 0;
+ MCSymbolRefExpr::VariantKind Kind){};
+ virtual void emitMachine(StringRef CPU){};
+ virtual void emitAbiVersion(int AbiVersion){};
+ virtual void emitLocalEntry(MCSymbolELF *S, const MCExpr *LocalOffset){};
};
} // end namespace llvm
More information about the llvm-commits
mailing list