From 72e9447e29abf111c742da59afe4152150a2f8e7 Mon Sep 17 00:00:00 2001 From: Kiran Chandramohan Date: Mon, 31 Oct 2022 10:34:39 +0000 Subject: [PATCH] [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 --- mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | 2 +- mlir/test/Dialect/OpenMP/ops.mlir | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td index 800da7c..e6fde2d 100644 --- a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td +++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td @@ -229,7 +229,7 @@ def SingleOp : OpenMP_Op<"single", [AttrSizedOperandSegments]> { Variadic:$allocators_vars, UnitAttr:$nowait); - let regions = (region SizedRegion<1>:$region); + let regions = (region AnyRegion:$region); let assemblyFormat = [{ oilist(`allocate` `(` diff --git a/mlir/test/Dialect/OpenMP/ops.mlir b/mlir/test/Dialect/OpenMP/ops.mlir index 51b7dba..74dc12e 100644 --- a/mlir/test/Dialect/OpenMP/ops.mlir +++ b/mlir/test/Dialect/OpenMP/ops.mlir @@ -1349,6 +1349,18 @@ func.func @omp_single_allocate_nowait(%data_var: memref) { return } +// CHECK-LABEL: func @omp_single_multiple_blocks +func.func @omp_single_multiple_blocks() { + // CHECK: omp.single { + omp.single { + cf.br ^bb2 + ^bb2: + // CHECK: omp.terminator + omp.terminator + } + return +} + // CHECK-LABEL: @omp_task // CHECK-SAME: (%[[bool_var:.*]]: i1, %[[i64_var:.*]]: i64, %[[i32_var:.*]]: i32, %[[data_var:.*]]: memref) func.func @omp_task(%bool_var: i1, %i64_var: i64, %i32_var: i32, %data_var: memref) { -- 2.7.4