diff --git a/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td b/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td --- a/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td +++ b/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td @@ -212,8 +212,6 @@ ( `attach` `(` $attachOperands^ `:` type($attachOperands) `)` )? $region attr-dict-with-keyword }]; - - let verifier = ?; } def OpenACC_TerminatorOp : OpenACC_Op<"terminator", [Terminator]> { diff --git a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp --- a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp +++ b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp @@ -634,5 +634,21 @@ return success(); } +//===----------------------------------------------------------------------===// +// DataOp +//===----------------------------------------------------------------------===// + +static LogicalResult verify(acc::DataOp dataOp) { + // 2.6.5. Data Construct restriction + // At least one copy, copyin, copyout, create, no_create, present, deviceptr, + // attach, or default clause must appear on a data construct. + if (dataOp.getOperands().size() == 0 && !dataOp.defaultAttr()) { + return dataOp.emitError("at least one operand or the default attribute " + "must appear on the data operation"); + } + + return success(); +} + #define GET_OP_CLASSES #include "mlir/Dialect/OpenACC/OpenACCOps.cpp.inc" diff --git a/mlir/test/Dialect/OpenACC/invalid.mlir b/mlir/test/Dialect/OpenACC/invalid.mlir --- a/mlir/test/Dialect/OpenACC/invalid.mlir +++ b/mlir/test/Dialect/OpenACC/invalid.mlir @@ -68,3 +68,10 @@ } attributes {auto_, seq} // ----- + +// expected-error@+1 {{at least one operand or the default attribute must appear on the data operation}} +acc.data { + acc.yield +} + +// ----- diff --git a/mlir/test/Dialect/OpenACC/ops.mlir b/mlir/test/Dialect/OpenACC/ops.mlir --- a/mlir/test/Dialect/OpenACC/ops.mlir +++ b/mlir/test/Dialect/OpenACC/ops.mlir @@ -485,6 +485,8 @@ } attributes { defaultAttr = "none" } acc.data present(%a : memref<10xf32>) { } attributes { defaultAttr = "present" } + acc.data { + } attributes { defaultAttr = "none" } return } @@ -520,3 +522,5 @@ // CHECK-NEXT: } attributes {defaultAttr = "none"} // CHECK: acc.data present([[ARGA]] : memref<10xf32>) { // CHECK-NEXT: } attributes {defaultAttr = "present"} +// CHECK: acc.data { +// CHECK-NEXT: } attributes {defaultAttr = "none"}