llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-backend-systemz Author: Aiden Grossman (boomanaiden154) <details> <summary>Changes</summary> Standard NewPM pass porting. --- Full diff: https://github.com/llvm/llvm-project/pull/240602.diff 5 Files Affected: - (modified) llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp (+31) - (modified) llvm/lib/Target/SystemZ/SystemZAsmPrinter.h (+20) - (modified) llvm/lib/Target/SystemZ/SystemZCodeGenPassBuilder.cpp (+4-3) - (modified) llvm/lib/Target/SystemZ/SystemZPassRegistry.def (+3) - (modified) llvm/test/CodeGen/SystemZ/newpm-pipeline.ll (+6) ``````````diff diff --git a/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp b/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp index 78f4ee79aa414..a29561092c68a 100644 --- a/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp +++ b/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp @@ -21,6 +21,7 @@ #include "SystemZSubtarget.h" #include "SystemZXPLINKAsmPrinter.h" #include "TargetInfo/SystemZTargetInfo.h" +#include "llvm/CodeGen/AsmPrinterAnalysis.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCInstBuilder.h" @@ -648,3 +649,33 @@ LLVMInitializeSystemZAsmPrinter() { TargetRegistry::RegisterAsmPrinter(getTheSystemZTarget(), createSystemZAsmPrinter); } + +PreservedAnalyses SystemZAsmPrinterBeginPass::run(Module &M, + ModuleAnalysisManager &MAM) { + SystemZAsmPrinter &AsmPrinter = static_cast<SystemZAsmPrinter &>( + MAM.getResult<AsmPrinterAnalysis>(M).getPrinter()); + setupModuleAsmPrinter(M, MAM, AsmPrinter); + AsmPrinter.doInitialization(M); + return PreservedAnalyses::all(); +} + +PreservedAnalyses +SystemZAsmPrinterPass::run(MachineFunction &MF, + MachineFunctionAnalysisManager &MFAM) { + SystemZAsmPrinter &AsmPrinter = static_cast<SystemZAsmPrinter &>( + MFAM.getResult<ModuleAnalysisManagerMachineFunctionProxy>(MF) + .getCachedResult<AsmPrinterAnalysis>(*MF.getFunction().getParent()) + ->getPrinter()); + setupMachineFunctionAsmPrinter(MFAM, MF, AsmPrinter); + AsmPrinter.runOnMachineFunction(MF); + return PreservedAnalyses::all(); +} + +PreservedAnalyses SystemZAsmPrinterEndPass::run(Module &M, + ModuleAnalysisManager &MAM) { + SystemZAsmPrinter &AsmPrinter = static_cast<SystemZAsmPrinter &>( + MAM.getResult<AsmPrinterAnalysis>(M).getPrinter()); + setupModuleAsmPrinter(M, MAM, AsmPrinter); + AsmPrinter.doFinalization(M); + return PreservedAnalyses::all(); +} diff --git a/llvm/lib/Target/SystemZ/SystemZAsmPrinter.h b/llvm/lib/Target/SystemZ/SystemZAsmPrinter.h index a3bc050110d26..d40b95875fdaf 100644 --- a/llvm/lib/Target/SystemZ/SystemZAsmPrinter.h +++ b/llvm/lib/Target/SystemZ/SystemZAsmPrinter.h @@ -55,6 +55,26 @@ class LLVM_LIBRARY_VISIBILITY SystemZAsmPrinter : public AsmPrinter { return false; } }; + +class SystemZAsmPrinterBeginPass + : public RequiredPassInfoMixin<SystemZAsmPrinterBeginPass> { +public: + PreservedAnalyses run(Module &M, ModuleAnalysisManager &MFAM); +}; + +class SystemZAsmPrinterPass + : public RequiredPassInfoMixin<SystemZAsmPrinterPass> { +public: + PreservedAnalyses run(MachineFunction &MF, + MachineFunctionAnalysisManager &MFAM); +}; + +class SystemZAsmPrinterEndPass + : public RequiredPassInfoMixin<SystemZAsmPrinterEndPass> { +public: + PreservedAnalyses run(Module &M, ModuleAnalysisManager &MFAM); +}; + } // end namespace llvm #endif diff --git a/llvm/lib/Target/SystemZ/SystemZCodeGenPassBuilder.cpp b/llvm/lib/Target/SystemZ/SystemZCodeGenPassBuilder.cpp index e7ad093253310..a59525cd1bfb8 100644 --- a/llvm/lib/Target/SystemZ/SystemZCodeGenPassBuilder.cpp +++ b/llvm/lib/Target/SystemZ/SystemZCodeGenPassBuilder.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include "SystemZ.h" +#include "SystemZAsmPrinter.h" #include "SystemZTargetMachine.h" #include "llvm/CodeGen/AtomicExpand.h" #include "llvm/CodeGen/EarlyIfConversion.h" @@ -143,15 +144,15 @@ void SystemZCodeGenPassBuilder::addPreEmitPass(PassManagerWrapper &PMW) { } void SystemZCodeGenPassBuilder::addAsmPrinterBegin(PassManagerWrapper &PMW) { - // TODO(boomanaiden154): Add SystemZAsmPrinterBegin + addModulePass(SystemZAsmPrinterBeginPass(), PMW, /*Force=*/true); } void SystemZCodeGenPassBuilder::addAsmPrinter(PassManagerWrapper &PMW) { - // TODO(boomanaiden154): Add SystemZAsmPrinter + addMachineFunctionPass(SystemZAsmPrinterPass(), PMW); } void SystemZCodeGenPassBuilder::addAsmPrinterEnd(PassManagerWrapper &PMW) { - // TODO(boomanaiden154): Add SystemZAsmPrinterEnd + addModulePass(SystemZAsmPrinterEndPass(), PMW, /*Force=*/true); } } // namespace diff --git a/llvm/lib/Target/SystemZ/SystemZPassRegistry.def b/llvm/lib/Target/SystemZ/SystemZPassRegistry.def index c4b066d81a84b..6d296b5844f02 100644 --- a/llvm/lib/Target/SystemZ/SystemZPassRegistry.def +++ b/llvm/lib/Target/SystemZ/SystemZPassRegistry.def @@ -17,6 +17,8 @@ #define MODULE_PASS(NAME, CREATE_PASS) #endif MODULE_PASS("systemz-align-globals", SystemZAlignGlobalsPass()) +MODULE_PASS("systemz-asm-printer-begin", SystemZAsmPrinterBeginPass()) +MODULE_PASS("systemz-asm-printer-end", SystemZAsmPrinterEndPass()) #undef MODULE_PASS #ifndef FUNCTION_PASS @@ -28,6 +30,7 @@ FUNCTION_PASS("systemz-tdc", SystemZTDCPass(*this)) #ifndef MACHINE_FUNCTION_PASS #define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) #endif +MACHINE_FUNCTION_PASS("systemz-asm-printer", SystemZAsmPrinterPass()) MACHINE_FUNCTION_PASS("systemz-copy-physregs", SystemZCopyPhysRegsPass()) MACHINE_FUNCTION_PASS("systemz-elim-compare", SystemZElimComparePass()) MACHINE_FUNCTION_PASS("systemz-isel", SystemZISelDAGToDAGPass(*this, getOptLevel())) diff --git a/llvm/test/CodeGen/SystemZ/newpm-pipeline.ll b/llvm/test/CodeGen/SystemZ/newpm-pipeline.ll index 492a558a68174..b360a04860901 100644 --- a/llvm/test/CodeGen/SystemZ/newpm-pipeline.ll +++ b/llvm/test/CodeGen/SystemZ/newpm-pipeline.ll @@ -26,6 +26,7 @@ ; O0-NEXT: safe-stack ; O0-NEXT: stack-protector ; O0-NEXT: verify +; O0-NEXT: systemz-asm-printer-begin ; O0-NEXT: function ; O0-NEXT: machine-function ; O0-NEXT: systemz-isel @@ -50,7 +51,9 @@ ; O0-NEXT: machine-sanmd ; O0-NEXT: stack-frame-layout ; O0-NEXT: verify +; O0-NEXT: systemz-asm-printer ; O0-NEXT: free-machine-function +; O0-NEXT: systemz-asm-printer-end ; O3: require<MachineModuleAnalysis> ; O3-NEXT: require<profile-summary> @@ -88,6 +91,7 @@ ; O3-NEXT: safe-stack ; O3-NEXT: stack-protector ; O3-NEXT: verify +; O3-NEXT: systemz-asm-printer-begin ; O3-NEXT: function ; O3-NEXT: machine-function ; O3-NEXT: systemz-isel @@ -149,4 +153,6 @@ ; O3-NEXT: machine-sanmd ; O3-NEXT: stack-frame-layout ; O3-NEXT: verify +; O3-NEXT: systemz-asm-printer ; O3-NEXT: free-machine-function +; O3-NEXT: systemz-asm-printer-end `````````` </details> https://github.com/llvm/llvm-project/pull/240602 _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
