| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,160 @@ | ||
| // RUN: not mlir-pdll %s -split-input-file 2>&1 | FileCheck %s | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // Constraint Structure | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| // CHECK: expected identifier name | ||
| Constraint {} | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: :6:12: error: `Foo` has already been defined | ||
| // CHECK: :5:12: note: see previous definition here | ||
| Constraint Foo() { op<>; } | ||
| Constraint Foo() { op<>; } | ||
|
|
||
| // ----- | ||
|
|
||
| Constraint Foo() { | ||
| // CHECK: `erase` cannot be used within a Constraint | ||
| erase op<>; | ||
| } | ||
|
|
||
| // ----- | ||
|
|
||
| Constraint Foo() { | ||
| // CHECK: `replace` cannot be used within a Constraint | ||
| replace; | ||
| } | ||
|
|
||
| // ----- | ||
|
|
||
| Constraint Foo() { | ||
| // CHECK: `rewrite` cannot be used within a Constraint | ||
| rewrite; | ||
| } | ||
|
|
||
| // ----- | ||
|
|
||
| Constraint Foo() -> Value { | ||
| // CHECK: `return` terminated the `Constraint` body, but found trailing statements afterwards | ||
| return _: Value; | ||
| return _: Value; | ||
| } | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: missing return in a `Constraint` expected to return `Value` | ||
| Constraint Foo() -> Value { | ||
| let value: Value; | ||
| } | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: expected `Constraint` lambda body to contain a single expression | ||
| Constraint Foo() -> Value => let foo: Value; | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: unable to convert expression of type `Op` to the expected type of `Attr` | ||
| Constraint Foo() -> Attr => op<>; | ||
|
|
||
| // ----- | ||
|
|
||
| Rewrite SomeRewrite(); | ||
|
|
||
| // CHECK: unable to invoke `Rewrite` within a match section | ||
| Constraint Foo() { | ||
| SomeRewrite(); | ||
| } | ||
|
|
||
| // ----- | ||
|
|
||
| Constraint Foo() { | ||
| Constraint Foo() {}; | ||
| } | ||
|
|
||
| // ----- | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // Arguments | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| // CHECK: expected `(` to start argument list | ||
| Constraint Foo {} | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: expected identifier argument name | ||
| Constraint Foo(10{} | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: expected `:` before argument constraint | ||
| Constraint Foo(arg{} | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: inline `Attr`, `Value`, and `ValueRange` type constraints are not permitted on arguments or results | ||
| Constraint Foo(arg: Value<type>){} | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: expected `)` to end argument list | ||
| Constraint Foo(arg: Value{} | ||
|
|
||
| // ----- | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // Results | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| // CHECK: expected identifier constraint | ||
| Constraint Foo() -> {} | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: cannot create a single-element tuple with an element label | ||
| Constraint Foo() -> result: Value; | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: cannot create a single-element tuple with an element label | ||
| Constraint Foo() -> (result: Value); | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: expected identifier constraint | ||
| Constraint Foo() -> (); | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: expected `:` before result constraint | ||
| Constraint Foo() -> (result{}; | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: expected `)` to end result list | ||
| Constraint Foo() -> (Op{}; | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: inline `Attr`, `Value`, and `ValueRange` type constraints are not permitted on arguments or results | ||
| Constraint Foo() -> Value<type>){} | ||
|
|
||
| // ----- | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // Native Constraints | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| Pattern { | ||
| // CHECK: external declarations must be declared in global scope | ||
| Constraint ExternalConstraint(); | ||
| } | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: expected `;` after native declaration | ||
| Constraint Foo() [{}] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| // RUN: mlir-pdll %s -I %S -split-input-file | FileCheck %s | ||
|
|
||
| // CHECK: Module | ||
| // CHECK: `-UserConstraintDecl {{.*}} Name<Foo> ResultType<Tuple<>> | ||
| Constraint Foo(); | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: Module | ||
| // CHECK: `-UserConstraintDecl {{.*}} Name<Foo> ResultType<Tuple<>> Code< /* Native Code */ > | ||
| Constraint Foo() [{ /* Native Code */ }]; | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: Module | ||
| // CHECK: `-UserConstraintDecl {{.*}} Name<Foo> ResultType<Value> | ||
| // CHECK: `Inputs` | ||
| // CHECK: `-VariableDecl {{.*}} Name<arg> Type<Value> | ||
| // CHECK: `Results` | ||
| // CHECK: `-VariableDecl {{.*}} Name<> Type<Value> | ||
| // CHECK: `-CompoundStmt {{.*}} | ||
| // CHECK: `-ReturnStmt {{.*}} | ||
| // CHECK: `-DeclRefExpr {{.*}} Type<Value> | ||
| // CHECK: `-VariableDecl {{.*}} Name<arg> Type<Value> | ||
| Constraint Foo(arg: Value) -> Value => arg; | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: Module | ||
| // CHECK: `-UserConstraintDecl {{.*}} Name<Foo> ResultType<Tuple<result1: Value, result2: Attr>> | ||
| // CHECK: `Results` | ||
| // CHECK: |-VariableDecl {{.*}} Name<result1> Type<Value> | ||
| // CHECK: | `Constraints` | ||
| // CHECK: | `-ValueConstraintDecl {{.*}} | ||
| // CHECK: `-VariableDecl {{.*}} Name<result2> Type<Attr> | ||
| // CHECK: `Constraints` | ||
| // CHECK: `-AttrConstraintDecl {{.*}} | ||
| // CHECK: `-CompoundStmt {{.*}} | ||
| // CHECK: `-ReturnStmt {{.*}} | ||
| // CHECK: `-TupleExpr {{.*}} Type<Tuple<result1: Value, result2: Attr>> | ||
| // CHECK: |-MemberAccessExpr {{.*}} Member<0> Type<Value> | ||
| // CHECK: | `-TupleExpr {{.*}} Type<Tuple<Value, Attr>> | ||
| // CHECK: `-MemberAccessExpr {{.*}} Member<1> Type<Attr> | ||
| // CHECK: `-TupleExpr {{.*}} Type<Tuple<Value, Attr>> | ||
| Constraint Foo() -> (result1: Value, result2: Attr) => (_: Value, attr<"10">); | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: Module | ||
| // CHECK: |-UserConstraintDecl {{.*}} Name<Bar> ResultType<Tuple<>> | ||
| // CHECK: `-UserConstraintDecl {{.*}} Name<Foo> ResultType<Value> | ||
| // CHECK: `Inputs` | ||
| // CHECK: `-VariableDecl {{.*}} Name<arg> Type<Value> | ||
| // CHECK: `Constraints` | ||
| // CHECK: `-UserConstraintDecl {{.*}} Name<Bar> ResultType<Tuple<>> | ||
| // CHECK: `Results` | ||
| // CHECK: `-VariableDecl {{.*}} Name<> Type<Value> | ||
| // CHECK: `Constraints` | ||
| // CHECK: `-UserConstraintDecl {{.*}} Name<Bar> ResultType<Tuple<>> | ||
| Constraint Bar(input: Value); | ||
|
|
||
| Constraint Foo(arg: Bar) -> Bar => arg; | ||
|
|
||
| // ----- | ||
|
|
||
| // Test that anonymous constraints are uniquely named. | ||
|
|
||
| // CHECK: Module | ||
| // CHECK: UserConstraintDecl {{.*}} Name<<anonymous_constraint_0>> ResultType<Tuple<>> | ||
| // CHECK: UserConstraintDecl {{.*}} Name<<anonymous_constraint_1>> ResultType<Attr> | ||
| Constraint Outer() { | ||
| Constraint() {}; | ||
| Constraint() => attr<"10">; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,161 @@ | ||
| // RUN: not mlir-pdll %s -split-input-file 2>&1 | FileCheck %s | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // Rewrite Structure | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| // CHECK: expected identifier name | ||
| Rewrite {} | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: :6:9: error: `Foo` has already been defined | ||
| // CHECK: :5:9: note: see previous definition here | ||
| Rewrite Foo(); | ||
| Rewrite Foo(); | ||
|
|
||
| // ----- | ||
|
|
||
| Rewrite Foo() -> Value { | ||
| // CHECK: `return` terminated the `Rewrite` body, but found trailing statements afterwards | ||
| return _: Value; | ||
| return _: Value; | ||
| } | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: missing return in a `Rewrite` expected to return `Value` | ||
| Rewrite Foo() -> Value { | ||
| let value: Value; | ||
| } | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: missing return in a `Rewrite` expected to return `Value` | ||
| Rewrite Foo() -> Value => erase op<my_dialect.foo>; | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: unable to convert expression of type `Op<my_dialect.foo>` to the expected type of `Attr` | ||
| Rewrite Foo() -> Attr => op<my_dialect.foo>; | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: expected `Rewrite` lambda body to contain a single expression or an operation rewrite statement; such as `erase`, `replace`, or `rewrite` | ||
| Rewrite Foo() => let foo = op<my_dialect.foo>; | ||
|
|
||
| // ----- | ||
|
|
||
| Constraint ValueConstraint(value: Value); | ||
|
|
||
| // CHECK: unable to invoke `Constraint` within a rewrite section | ||
| Rewrite Foo(value: Value) { | ||
| ValueConstraint(value); | ||
| } | ||
|
|
||
| // ----- | ||
|
|
||
| Rewrite Bar(); | ||
|
|
||
| // CHECK: `Bar` has already been defined | ||
| Rewrite Foo() { | ||
| Rewrite Bar() {}; | ||
| } | ||
|
|
||
| // ----- | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // Arguments | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| // CHECK: expected `(` to start argument list | ||
| Rewrite Foo {} | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: expected identifier argument name | ||
| Rewrite Foo(10{} | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: expected `:` before argument constraint | ||
| Rewrite Foo(arg{} | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: inline `Attr`, `Value`, and `ValueRange` type constraints are not permitted on arguments or results | ||
| Rewrite Foo(arg: Value<type>){} | ||
|
|
||
| // ----- | ||
|
|
||
| Constraint ValueConstraint(value: Value); | ||
|
|
||
| // CHECK: arguments and results are only permitted to use core constraints, such as `Attr`, `Op`, `Type`, `TypeRange`, `Value`, `ValueRange` | ||
| Rewrite Foo(arg: ValueConstraint); | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: expected `)` to end argument list | ||
| Rewrite Foo(arg: Value{} | ||
|
|
||
| // ----- | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // Results | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| // CHECK: expected identifier constraint | ||
| Rewrite Foo() -> {} | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: cannot create a single-element tuple with an element label | ||
| Rewrite Foo() -> result: Value; | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: cannot create a single-element tuple with an element label | ||
| Rewrite Foo() -> (result: Value); | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: expected identifier constraint | ||
| Rewrite Foo() -> (); | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: expected `:` before result constraint | ||
| Rewrite Foo() -> (result{}; | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: expected `)` to end result list | ||
| Rewrite Foo() -> (Op{}; | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: inline `Attr`, `Value`, and `ValueRange` type constraints are not permitted on arguments or results | ||
| Rewrite Foo() -> Value<type>){} | ||
|
|
||
| // ----- | ||
|
|
||
| Constraint ValueConstraint(value: Value); | ||
|
|
||
| // CHECK: results are only permitted to use core constraints, such as `Attr`, `Op`, `Type`, `TypeRange`, `Value`, `ValueRange` | ||
| Rewrite Foo() -> ValueConstraint; | ||
|
|
||
| // ----- | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // Native Rewrites | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| Pattern { | ||
| // CHECK: external declarations must be declared in global scope | ||
| Rewrite ExternalConstraint(); | ||
| } | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: expected `;` after native declaration | ||
| Rewrite Foo() [{}] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| // RUN: mlir-pdll %s -I %S -split-input-file | FileCheck %s | ||
|
|
||
| // CHECK: Module | ||
| // CHECK: `-UserRewriteDecl {{.*}} Name<Foo> ResultType<Tuple<>> | ||
| Rewrite Foo(); | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: Module | ||
| // CHECK: `-UserRewriteDecl {{.*}} Name<Foo> ResultType<Tuple<>> Code< /* Native Code */ > | ||
| Rewrite Foo() [{ /* Native Code */ }]; | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: Module | ||
| // CHECK: `-UserRewriteDecl {{.*}} Name<Foo> ResultType<Value> | ||
| // CHECK: `Inputs` | ||
| // CHECK: `-VariableDecl {{.*}} Name<arg> Type<Op> | ||
| // CHECK: `Results` | ||
| // CHECK: `-VariableDecl {{.*}} Name<> Type<Value> | ||
| // CHECK: `-CompoundStmt {{.*}} | ||
| // CHECK: `-ReturnStmt {{.*}} | ||
| // CHECK: `-MemberAccessExpr {{.*}} Member<$results> Type<Value> | ||
| // CHECK: `-DeclRefExpr {{.*}} Type<Op> | ||
| // CHECK: `-VariableDecl {{.*}} Name<arg> Type<Op> | ||
| Rewrite Foo(arg: Op) -> Value => arg; | ||
|
|
||
| // ----- | ||
|
|
||
| // CHECK: Module | ||
| // CHECK: `-UserRewriteDecl {{.*}} Name<Foo> ResultType<Tuple<result1: Value, result2: Attr>> | ||
| // CHECK: `Results` | ||
| // CHECK: |-VariableDecl {{.*}} Name<result1> Type<Value> | ||
| // CHECK: | `Constraints` | ||
| // CHECK: | `-ValueConstraintDecl {{.*}} | ||
| // CHECK: `-VariableDecl {{.*}} Name<result2> Type<Attr> | ||
| // CHECK: `Constraints` | ||
| // CHECK: `-AttrConstraintDecl {{.*}} | ||
| // CHECK: `-CompoundStmt {{.*}} | ||
| // CHECK: `-ReturnStmt {{.*}} | ||
| // CHECK: `-TupleExpr {{.*}} Type<Tuple<result1: Value, result2: Attr>> | ||
| // CHECK: |-MemberAccessExpr {{.*}} Member<0> Type<Value> | ||
| // CHECK: | `-TupleExpr {{.*}} Type<Tuple<Value, Attr>> | ||
| // CHECK: `-MemberAccessExpr {{.*}} Member<1> Type<Attr> | ||
| // CHECK: `-TupleExpr {{.*}} Type<Tuple<Value, Attr>> | ||
| Rewrite Foo() -> (result1: Value, result2: Attr) => (_: Value, attr<"10">); | ||
|
|
||
| // ----- | ||
|
|
||
| // Test that anonymous Rewrites are uniquely named. | ||
|
|
||
| // CHECK: Module | ||
| // CHECK: UserRewriteDecl {{.*}} Name<<anonymous_rewrite_0>> ResultType<Tuple<>> | ||
| // CHECK: UserRewriteDecl {{.*}} Name<<anonymous_rewrite_1>> ResultType<Attr> | ||
| Rewrite Outer() { | ||
| Rewrite() {}; | ||
| Rewrite() => attr<"10">; | ||
| } |