[llvm-branch-commits] [flang] [mlir] [mlir][OpenMP] Move taskloop clauses to the context op (PR #188070)

Sergio Afonso via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Apr 1 09:02:32 PDT 2026


================
@@ -1009,27 +1015,63 @@ def TaskloopContextOp : OpenMP_Op<"taskloop.context", traits = [
       omp.terminator
     }
     ```
-  }] # clausesDescription;
 
-  let assemblyFormat = "$region attr-dict";
+    For definitions of "undeferred task", "included task", "final task" and
+    "mergeable task", please check OpenMP Specification.
+
+    When an `if` clause is present on a taskloop construct, and if the `if`
+    clause expression evaluates to `false`, undeferred tasks are generated. The
+    use of a variable in an `if` clause expression of a taskloop construct
+    causes an implicit reference to the variable in all enclosing constructs.
+  }] # clausesDescription # [{
+    If an `in_reduction` clause is present on the taskloop construct, the
+    behavior is as if each generated task was defined by a task construct on
+    which an `in_reduction` clause with the same reduction operator and list
+    items is present. Thus, the generated tasks are participants of a reduction
+    previously defined by a reduction scoping clause. In this case, accumulator
+    variables are specified in `in_reduction_vars`, symbols referring to
+    reduction declarations in `in_reduction_syms` and `in_reduction_byref`
+    indicate for each reduction variable whether it should be passed by value or
+    by reference.
+
+    If a `reduction` clause is present on the taskloop construct, the behavior
+    is as if a `task_reduction` clause with the same reduction operator and list
+    items was applied to the implicit taskgroup construct enclosing the taskloop
+    construct. The taskloop construct executes as if each generated task was
+    defined by a task construct on which an `in_reduction` clause with the same
+    reduction operator and list items is present. Thus, the generated tasks are
+    participants of the reduction defined by the `task_reduction` clause that
+    was applied to the implicit taskgroup construct.
+  }];
+
+  let builders = [
+    OpBuilder<(ins CArg<"const TaskloopContextOperands &">:$clauses)>
+  ];
+
+  let assemblyFormat = clausesAssemblyFormat # [{
+    custom<InReductionPrivateReductionRegion>(
+        $region, $in_reduction_vars, type($in_reduction_vars),
+        $in_reduction_byref, $in_reduction_syms, $private_vars,
+        type($private_vars), $private_syms, $private_needs_barrier,
+        $reduction_mod, $reduction_vars, type($reduction_vars),
+        $reduction_byref, $reduction_syms) attr-dict
+  }];
 
   let extraClassDeclaration = [{
     TaskloopOp getLoopOp();
   }] # clausesExtraClassDeclaration;
 
+  let hasVerifier = 1;
   let hasRegionVerifier = 1;
 }
 
 def TaskloopOp : OpenMP_Op<"taskloop", traits = [
-    AttrSizedOperandSegments,
     DeclareOpInterfaceMethods<ComposableOpInterface>,
     DeclareOpInterfaceMethods<LoopWrapperInterface>, NoTerminator,
     RecursiveMemoryEffects, SingleBlock
   ], clauses = [
-    OpenMP_AllocateClause, OpenMP_FinalClause, OpenMP_GrainsizeClause,
-    OpenMP_IfClause, OpenMP_InReductionClause, OpenMP_MergeableClause,
-    OpenMP_NogroupClause, OpenMP_NumTasksClause, OpenMP_PriorityClause,
-    OpenMP_PrivateClause, OpenMP_ReductionClause, OpenMP_UntiedClause
+    // See taskloop.context, which generates the runtime calls and outlined
+    // task function
----------------
skatrak wrote:

```suggestion
    // task function.
```

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


More information about the llvm-branch-commits mailing list