[Mlir-commits] [mlir] [mlir][spirv] Add gpu printf op lowering to spirv.CL.printf op (PR #78510)

Jakub Kuderski llvmlistbot at llvm.org
Wed Sep 18 06:50:45 PDT 2024


================
@@ -597,6 +606,120 @@ class GPUSubgroupReduceConversion final
   }
 };
 
+/// Pattern to convert a gpu.printf op into a SPIR-V CLPrintf op.
+
+LogicalResult GPUPrintfConversion::matchAndRewrite(
+    gpu::PrintfOp gpuPrintfOp, OpAdaptor adaptor,
+    ConversionPatternRewriter &rewriter) const {
+
+  Location loc = gpuPrintfOp.getLoc();
+
+  auto moduleOp = gpuPrintfOp->getParentOfType<spirv::ModuleOp>();
+
+  if (!moduleOp) {
+    return success();
+  }
+
+  const char formatStringPrefix[] = "printfMsg";
----------------
kuhar wrote:

```suggestion
  StringRef formatStringPrefix = "printfMsg";
```

https://github.com/llvm/llvm-project/pull/78510


More information about the Mlir-commits mailing list