[mlir][openacc] Add acc.data operation verifier

Add a basic verifier for the data operation following the restriction from the standard.

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D88334
This commit is contained in:
Valentin Clement 2020-09-28 21:22:07 -04:00 committed by clementval
parent cc6d1f8029
commit bbb5dc4923
4 changed files with 26 additions and 2 deletions

View File

@ -212,8 +212,6 @@ def OpenACC_DataOp : OpenACC_Op<"data",
( `attach` `(` $attachOperands^ `:` type($attachOperands) `)` )?
$region attr-dict-with-keyword
}];
let verifier = ?;
}
def OpenACC_TerminatorOp : OpenACC_Op<"terminator", [Terminator]> {

View File

@ -634,5 +634,20 @@ static LogicalResult verifyLoopOp(acc::LoopOp loopOp) {
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"

View File

@ -68,3 +68,10 @@ acc.loop {
} attributes {auto_, seq}
// -----
// expected-error@+1 {{at least one operand or the default attribute must appear on the data operation}}
acc.data {
acc.yield
}
// -----

View File

@ -485,6 +485,8 @@ func @testdataop(%a: memref<10xf32>, %b: memref<10xf32>, %c: memref<10x10xf32>)
} attributes { defaultAttr = "none" }
acc.data present(%a : memref<10xf32>) {
} attributes { defaultAttr = "present" }
acc.data {
} attributes { defaultAttr = "none" }
return
}
@ -520,3 +522,5 @@ func @testdataop(%a: memref<10xf32>, %b: memref<10xf32>, %c: memref<10x10xf32>)
// 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"}