================
@@ -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
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to