[Mlir-commits] [mlir] [MLIR][OpenMP] Add a new ComposableLoopWrapperInterface to check/set a composite unitAttr. (PR #101991)

Sergio Afonso llvmlistbot at llvm.org
Tue Aug 6 02:42:23 PDT 2024


================
@@ -142,6 +142,40 @@ def LoopWrapperInterface : OpInterface<"LoopWrapperInterface"> {
   ];
 }
 
+def ComposableLoopWrapperInterface : OpInterface<"ComposableLoopWrapperInterface"> {
+  let description = [{
+    OpenMP operations that can wrap a single loop nest. When taking a wrapper
+    role, these operations must only contain a single region with a single block
+    in which there's a single operation and a terminator. That nested operation
+    must be another loop wrapper or an `omp.loop_nest`.
+  }];
+
+  let cppNamespace = "::mlir::omp";
+
+  let methods = [
+    InterfaceMethod<
+      /*description=*/[{
+        Check whether the operation is composable.
+      }],
+      /*retTy=*/"bool",
+      /*methodName=*/"isComposite",
+      (ins ), [{}], [{
+        return $_op->hasAttr("omp.composite");
+      }]
+    >,
+    InterfaceMethod<
+      /*description=*/[{
+        Set the CompositeAttr for the op.
+      }],
+      /*retTy=*/"void",
+      /*methodName=*/"setComposite",
+      (ins), [{}], [{
+        $_op->setDiscardableAttr("omp.composite", mlir::UnitAttr::get($_op->getContext()));
----------------
skatrak wrote:

I think this method should take a boolean argument. If it's `false`, it should remove the attribute if present.

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


More information about the Mlir-commits mailing list