Skip to content

Commit 72e9447

Browse files
[MLIR][OpenMP] Allow the single operation to have a region
The OpenMP standard specifies the region inside to be a structured block. This means that branches into or out of the region is not permitted but branches are permitted inside the OpenMP single region. This is currently modeled by having a region of kind `AnyRegion` for all the OpenMP ops. In future we can have a more strictly defined region. Fixes #58396. Reviewed By: peixin Differential Revision: https://reviews.llvm.org/D137023
1 parent da5ded4 commit 72e9447

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def SingleOp : OpenMP_Op<"single", [AttrSizedOperandSegments]> {
229229
Variadic<AnyType>:$allocators_vars,
230230
UnitAttr:$nowait);
231231

232-
let regions = (region SizedRegion<1>:$region);
232+
let regions = (region AnyRegion:$region);
233233

234234
let assemblyFormat = [{
235235
oilist(`allocate` `(`

mlir/test/Dialect/OpenMP/ops.mlir

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,6 +1349,18 @@ func.func @omp_single_allocate_nowait(%data_var: memref<i32>) {
13491349
return
13501350
}
13511351

1352+
// CHECK-LABEL: func @omp_single_multiple_blocks
1353+
func.func @omp_single_multiple_blocks() {
1354+
// CHECK: omp.single {
1355+
omp.single {
1356+
cf.br ^bb2
1357+
^bb2:
1358+
// CHECK: omp.terminator
1359+
omp.terminator
1360+
}
1361+
return
1362+
}
1363+
13521364
// CHECK-LABEL: @omp_task
13531365
// CHECK-SAME: (%[[bool_var:.*]]: i1, %[[i64_var:.*]]: i64, %[[i32_var:.*]]: i32, %[[data_var:.*]]: memref<i32>)
13541366
func.func @omp_task(%bool_var: i1, %i64_var: i64, %i32_var: i32, %data_var: memref<i32>) {

0 commit comments

Comments
 (0)