diff --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td --- a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td +++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td @@ -257,6 +257,40 @@ let assemblyFormat = [{ ( `(` $varList^ `:` type($varList) `)` )? attr-dict}]; } +//===----------------------------------------------------------------------===// +// 2.14.5 target construct +//===----------------------------------------------------------------------===// + +def TargetOp : OpenMP_Op<"target",[AttrSizedOperandSegments]> { + let summary = "target construct"; + let description = [{ + The target construct includes a region of code which is to be executed + on a device. + + The optional $if_expr parameter specifies a boolean result of a + conditional check. If this value is 1 or is not provided then the target + region runs on a device, if it is 0 then the target region is executed on the + host device. + + The optional $device parameter specifies the device number for the target region. + + The optional $thread_limit specifies the limit on the number of threads + + The optional $nowait elliminates the implicit barrier so the parent task can make progress + even if the target task is not yet completed. + + TODO: private, map, is_device_ptr, firstprivate, depend, defaultmap, in_reduction + + }]; + + let arguments = (ins Optional:$if_expr, + Optional:$device, + Optional:$thread_limit, + UnitAttr:$nowait); + + let regions = (region AnyRegion:$region); +} + //===----------------------------------------------------------------------===// // 2.16 master Construct diff --git a/mlir/test/Dialect/OpenMP/ops.mlir b/mlir/test/Dialect/OpenMP/ops.mlir --- a/mlir/test/Dialect/OpenMP/ops.mlir +++ b/mlir/test/Dialect/OpenMP/ops.mlir @@ -278,3 +278,19 @@ return } + +// CHECK-LABEL: omp_target +func @omp_target(%if_cond : si32, %device : si32, %num_threads : si32) -> () { + + // Test with optional operands; if_expr, device, thread_limit, and nowait. + // CHECK: omp.target + "omp.target"(%if_cond, %device, %num_threads) ({ + // CHECK: omp.terminator + omp.terminator + }) {operand_segment_sizes = dense<[1,1,1]>: vector<3xi32>, nowait } : ( si32, si32, si32 ) -> () + + // CHECK: omp.barrier + omp.barrier + + return +}