[llvm-branch-commits] [llvm] [WebAssembly] Port AsmPrinter (PR #210448)
Aiden Grossman via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Jul 22 07:47:28 PDT 2026
================
@@ -245,11 +249,36 @@ void WebAssemblyCodeGenPassBuilder::addPreEmitPass(
addModulePass(WebAssemblyMCLowerPrePass(), PMW);
}
+void WebAssemblyCodeGenPassBuilder::addAsmPrinterBegin(
+ PassManagerWrapper &PMW) const {
+ addModulePass(WebAssemblyAsmPrinterBeginPass(), PMW);
+}
+
+void WebAssemblyCodeGenPassBuilder::addAsmPrinter(
+ PassManagerWrapper &PMW) const {
+ addMachineFunctionPass(WebAssemblyAsmPrinterPass(), PMW);
+}
+
+void WebAssemblyCodeGenPassBuilder::addAsmPrinterEnd(
+ PassManagerWrapper &PMW) const {
+ addModulePass(WebAssemblyAsmPrinterEndPass(), PMW);
+}
+
} // namespace
-void WebAssemblyTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB){
+void WebAssemblyTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {
#define GET_PASS_REGISTRY "WebAssemblyPassRegistry.def"
#include "llvm/Passes/TargetPassRegistry.inc"
+ // TODO(boomanaiden154): Move this into the base CodeGenPassBuilder once all
+ // targets that currently implement it have a ported asm-printer pass.
+ if (PIC) {
+ PIC->addClassToPassName(WebAssemblyAsmPrinterBeginPass::name(),
+ "wasm-asm-printer-begin");
+ PIC->addClassToPassName(WebAssemblyAsmPrinterPass::name(),
+ "wasm-asm-printer");
+ PIC->addClassToPassName(WebAssemblyAsmPrinterEndPass::name(),
+ "wasm-asm-printer-end");
+ }
----------------
boomanaiden154 wrote:
PIC is `PassInstrumentationCallbacks` (https://github.com/llvm/llvm-project/blob/34436db53d3e4ad36e86019109fb5ceee9bb4d8c/llvm/include/llvm/IR/PassInstrumentation.h#L74).
I'm not too familiar with under what conditions it doesn't exist, but it's canonical to check across CodeGen.
The passes don't need to be registered to run. They get scheduled by `addAsmPrinterBegin` (and friends) inside of the `CodeGenPassBuilder` implementation.
Registering them here just gives them names one can use for things like `-start-before` or `-stop-after`.
https://github.com/llvm/llvm-project/pull/210448
More information about the llvm-branch-commits
mailing list