[Mlir-commits] [mlir] bbb5dc4 - [mlir][openacc] Add acc.data operation verifier
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Sep 28 18:22:40 PDT 2020
Author: Valentin Clement
Date: 2020-09-28T21:22:32-04:00
New Revision: bbb5dc4923cf01f7f5760e1917b09b0487c64b72
URL: https://github.com/llvm/llvm-project/commit/bbb5dc4923cf01f7f5760e1917b09b0487c64b72
DIFF: https://github.com/llvm/llvm-project/commit/bbb5dc4923cf01f7f5760e1917b09b0487c64b72.diff
LOG: [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
Added:
Modified:
mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp
mlir/test/Dialect/OpenACC/invalid.mlir
mlir/test/Dialect/OpenACC/ops.mlir
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td b/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
index 913b80f26adb..85499834e5a2 100644
--- a/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
+++ b/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
@@ -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]> {
diff --git a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp
index 270baa9bfa87..ca2acca974e8 100644
--- a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp
+++ b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp
@@ -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"
diff --git a/mlir/test/Dialect/OpenACC/invalid.mlir b/mlir/test/Dialect/OpenACC/invalid.mlir
index 61a13211ba26..22345d279f0d 100644
--- a/mlir/test/Dialect/OpenACC/invalid.mlir
+++ b/mlir/test/Dialect/OpenACC/invalid.mlir
@@ -68,3 +68,10 @@ acc.loop {
} attributes {auto_, seq}
// -----
+
+// expected-error at +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
index 7bd6db3d3909..a4fecf619a77 100644
--- a/mlir/test/Dialect/OpenACC/ops.mlir
+++ b/mlir/test/Dialect/OpenACC/ops.mlir
@@ -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"}
More information about the Mlir-commits
mailing list