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 @@ -14,6 +14,7 @@ #ifndef OPENMP_OPS #define OPENMP_OPS + include "mlir/IR/OpBase.td" include "mlir/Interfaces/SideEffectInterfaces.td" include "mlir/Interfaces/ControlFlowInterfaces.td" @@ -257,6 +258,42 @@ 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_op 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_op parameter specifies the device number for the target region. + + The optional $thread_limit_op specifies the limit on the number of threads + + The optional $nowait_op 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_op, + Optional:$device_op, + Optional:$thread_limit_op, + Optional:$nowait_op); + + 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,20 @@ return } + +// CHECK-LABEL: omp_target +func @omp_target(%if_cond : si32, %device : si32, %num_threads : si32, %nowait : si32) -> () { + +// test with all optional operands-the basic test +// CHECK: omp.target + "omp.target"(%if_cond,%device, %num_threads, %nowait) ({ + +// CHECK: omp.terminator + omp.terminator + }) {operand_segment_sizes = dense<[1,1,1,1]>: vector<4xi32> } : ( si32, si32, si32 , si32 ) -> () + +// CHECK: omp.barrier + omp.barrier + + return +}