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

Valentin Clement バレンタイン クレメン llvmlistbot at llvm.org
Fri Oct 10 17:30:29 PDT 2025


================
@@ -1050,6 +1202,61 @@ LogicalResult acc::PrivateRecipeOp::verifyRegions() {
   return success();
 }
 
+std::optional<PrivateRecipeOp>
+PrivateRecipeOp::createAndPopulate(OpBuilder &builder, Location loc,
+                                   StringRef recipeName, Value var,
+                                   StringRef varName, ValueRange bounds) {
+
+  Type varType = var.getType();
+
+  // First, validate that we can handle this variable type
+  bool isMappable = isa<MappableType>(varType);
+  bool isPointerLike = isa<PointerLikeType>(varType);
+
+  if (!isMappable && !isPointerLike) {
+    // Unsupported type
+    return std::nullopt;
+  }
+
+  // Create init and destroy blocks using shared helpers
+  OpBuilder::InsertionGuard guard(builder);
+
+  // Save the original insertion point for creating the recipe operation later
+  auto originalInsertionPoint = builder.saveInsertionPoint();
+
+  bool needsFree = false;
+  auto initBlock =
+      createInitRegion(builder, loc, var, varName, bounds, varType, needsFree);
+  if (!initBlock) {
+    return std::nullopt;
+  }
----------------
clementval wrote:

no brace

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


More information about the Mlir-commits mailing list