summaryrefslogtreecommitdiff
path: root/mlir/test
diff options
context:
space:
mode:
authorMathieu Fehr <mathieu.fehr@gmail.com>2023-03-08 23:16:02 +0100
committerMathieu Fehr <mathieu.fehr@gmail.com>2023-05-12 19:39:13 +0100
commit52761cb99164acd4ea76f91fc16a3e40ec94b898 (patch)
treeeb4563af67822852ff707336818bce2e7364568d /mlir/test
parent13984608992246e42e66c019f09764650d60af63 (diff)
downloadllvm-52761cb99164acd4ea76f91fc16a3e40ec94b898.tar.gz
[mlir][irdl] Add verification of IRDL ops
This patch adds verification on registered IRDL operations, types, and attributes. This is done through an interface implemented by operations from the `irdl` dialect, which translate the operations into `Constraint`. This interface is then use in the `registerDialect` function to generate verifiers for the entire operation/type/attribute. Depends on D145733 Reviewed By: Mogball Differential Revision: https://reviews.llvm.org/D145734
Diffstat (limited to 'mlir/test')
-rw-r--r--mlir/test/Dialect/IRDL/testd.mlir38
1 files changed, 38 insertions, 0 deletions
diff --git a/mlir/test/Dialect/IRDL/testd.mlir b/mlir/test/Dialect/IRDL/testd.mlir
index f6d1bcb0e396..e9be54b60d0b 100644
--- a/mlir/test/Dialect/IRDL/testd.mlir
+++ b/mlir/test/Dialect/IRDL/testd.mlir
@@ -45,6 +45,13 @@ func.func @succeededEqConstraint() {
return
}
+// -----
+
+func.func @failedEqConstraint() {
+ // expected-error@+1 {{expected 'i32' but got 'i64'}}
+ "testd.eq"() : () -> i64
+ return
+}
// -----
@@ -74,6 +81,13 @@ func.func @succeededDynBaseConstraint() {
return
}
+// -----
+
+func.func @failedDynBaseConstraint() {
+ // expected-error@+1 {{expected base type 'testd.parametric' but got 'i32'}}
+ "testd.dynbase"() : () -> i32
+ return
+}
// -----
@@ -89,6 +103,22 @@ func.func @succeededDynParamsConstraint() {
// -----
+func.func @failedDynParamsConstraintBase() {
+ // expected-error@+1 {{expected base type 'testd.parametric' but got 'i32'}}
+ "testd.dynparams"() : () -> i32
+ return
+}
+
+// -----
+
+func.func @failedDynParamsConstraintParam() {
+ // expected-error@+1 {{expected 'i32' but got 'i1'}}
+ "testd.dynparams"() : () -> !testd.parametric<i1>
+ return
+}
+
+// -----
+
//===----------------------------------------------------------------------===//
// Constraint variables
//===----------------------------------------------------------------------===//
@@ -106,3 +136,11 @@ func.func @succeededConstraintVars2() {
"testd.constraint_vars"() : () -> (i64, i64)
return
}
+
+// -----
+
+func.func @failedConstraintVars() {
+ // expected-error@+1 {{expected 'i64' but got 'i32'}}
+ "testd.constraint_vars"() : () -> (i64, i32)
+ return
+}