[PATCH] D136986: X86: Implement null target streamer
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 28 14:10:09 PDT 2022
arsenm created this revision.
arsenm added reviewers: RKSimon, craig.topper, MaskRay.
Herald added subscribers: StephenFan, pengfei, hiraditya.
Herald added a project: All.
arsenm requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.
There should no need for null checks in the AsmPrinter
https://reviews.llvm.org/D136986
Files:
llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
llvm/lib/Target/X86/MCTargetDesc/X86TargetStreamer.h
llvm/lib/Target/X86/X86AsmPrinter.cpp
Index: llvm/lib/Target/X86/X86AsmPrinter.cpp
===================================================================
--- llvm/lib/Target/X86/X86AsmPrinter.cpp
+++ llvm/lib/Target/X86/X86AsmPrinter.cpp
@@ -98,19 +98,19 @@
void X86AsmPrinter::emitFunctionBodyStart() {
if (EmitFPOData) {
- if (auto *XTS =
- static_cast<X86TargetStreamer *>(OutStreamer->getTargetStreamer()))
- XTS->emitFPOProc(
- CurrentFnSym,
- MF->getInfo<X86MachineFunctionInfo>()->getArgumentStackSize());
+ auto *XTS =
+ static_cast<X86TargetStreamer *>(OutStreamer->getTargetStreamer());
+ XTS->emitFPOProc(
+ CurrentFnSym,
+ MF->getInfo<X86MachineFunctionInfo>()->getArgumentStackSize());
}
}
void X86AsmPrinter::emitFunctionBodyEnd() {
if (EmitFPOData) {
- if (auto *XTS =
- static_cast<X86TargetStreamer *>(OutStreamer->getTargetStreamer()))
- XTS->emitFPOEndProc();
+ auto *XTS =
+ static_cast<X86TargetStreamer *>(OutStreamer->getTargetStreamer());
+ XTS->emitFPOEndProc();
}
}
Index: llvm/lib/Target/X86/MCTargetDesc/X86TargetStreamer.h
===================================================================
--- llvm/lib/Target/X86/MCTargetDesc/X86TargetStreamer.h
+++ llvm/lib/Target/X86/MCTargetDesc/X86TargetStreamer.h
@@ -19,16 +19,26 @@
X86TargetStreamer(MCStreamer &S) : MCTargetStreamer(S) {}
virtual bool emitFPOProc(const MCSymbol *ProcSym, unsigned ParamsSize,
- SMLoc L = {}) = 0;
- virtual bool emitFPOEndPrologue(SMLoc L = {}) = 0;
- virtual bool emitFPOEndProc(SMLoc L = {}) = 0;
- virtual bool emitFPOData(const MCSymbol *ProcSym, SMLoc L = {}) = 0;
- virtual bool emitFPOPushReg(unsigned Reg, SMLoc L = {}) = 0;
- virtual bool emitFPOStackAlloc(unsigned StackAlloc, SMLoc L = {}) = 0;
- virtual bool emitFPOStackAlign(unsigned Align, SMLoc L = {}) = 0;
- virtual bool emitFPOSetFrame(unsigned Reg, SMLoc L = {}) = 0;
+ SMLoc L = {}) {
+ return false;
+ }
+ virtual bool emitFPOEndPrologue(SMLoc L = {}) { return false; }
+ virtual bool emitFPOEndProc(SMLoc L = {}) { return false; };
+ virtual bool emitFPOData(const MCSymbol *ProcSym, SMLoc L = {}) {
+ return false;
+ }
+ virtual bool emitFPOPushReg(unsigned Reg, SMLoc L = {}) { return false; }
+ virtual bool emitFPOStackAlloc(unsigned StackAlloc, SMLoc L = {}) {
+ return false;
+ }
+ virtual bool emitFPOStackAlign(unsigned Align, SMLoc L = {}) { return false; }
+ virtual bool emitFPOSetFrame(unsigned Reg, SMLoc L = {}) { return false; }
};
+inline MCTargetStreamer *createX86NullTargetStreamer(MCStreamer &S) {
+ return new X86TargetStreamer(S);
+}
+
} // end namespace llvm
#endif
Index: llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
===================================================================
--- llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
+++ llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
@@ -722,6 +722,9 @@
// Register the asm target streamer.
TargetRegistry::RegisterAsmTargetStreamer(*T, createX86AsmTargetStreamer);
+ // Register the null streamer.
+ TargetRegistry::RegisterNullTargetStreamer(*T, createX86NullTargetStreamer);
+
TargetRegistry::RegisterCOFFStreamer(*T, createX86WinCOFFStreamer);
// Register the MCInstPrinter.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136986.471651.patch
Type: text/x-patch
Size: 3353 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221028/f2a65813/attachment.bin>
More information about the llvm-commits
mailing list