[Mlir-commits] [mlir] [mlir][acc] Introduce createAndPopulate for recipe creation (PR #162917)

Razvan Lupusoru llvmlistbot at llvm.org
Tue Oct 14 09:42:54 PDT 2025


================
@@ -1316,6 +1316,22 @@ def OpenACC_PrivateRecipeOp
   }];
 
   let hasRegionVerifier = 1;
+
+  let extraClassDeclaration = [{
+    /// Creates a PrivateRecipeOp and populates its regions based on the
+    /// variable type as long as the type implements MappableType or
+    /// PointerLikeType interface. If a type implements both, the MappableType
+    /// API will be preferred. Returns std::nullopt if the recipe cannot be
+    /// created or populated. The builder's current insertion point will be used
+    /// and it must be a valid place for this operation to be inserted.
+    static std::optional<PrivateRecipeOp> createAndPopulate(
+        ::mlir::OpBuilder &builder,
+        ::mlir::Location loc,
+        ::llvm::StringRef recipeName,
+        ::mlir::Value var,
----------------
razvanlupusoru wrote:

> but it comes with slightly more misuse risks

You convinced me - `createAndPopulate` should not permit this misuse without stronger use case since anyway it needs to feed block arguments to MappableType/PointerLikeType APIs to avoid generating code that uses incorrect ssa value. That said, I still think that the MappableType/PointerLikeType APIs should still have access to the original variable since those may be generated inline without the use of recipes.

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


More information about the Mlir-commits mailing list