1 // RUN: not mlir-pdll %s -I %S -I %S/../../../include -split-input-file 2>&1 | FileCheck %s
3 // CHECK: expected top-level declaration, such as a `Pattern`
9 // CHECK: expected `;` after statement
15 //===----------------------------------------------------------------------===//
17 //===----------------------------------------------------------------------===//
20 // CHECK: expected expression
27 // CHECK: expected `Op` expression
33 //===----------------------------------------------------------------------===//
35 //===----------------------------------------------------------------------===//
38 // CHECK: expected identifier after `let` to name a new variable
45 // CHECK: `_` may only be used to define "inline" variables
52 // CHECK: expected expression
59 // CHECK: expected expression of `Type` in type constraint
60 let foo: Attr<_: Attr>;
66 // CHECK: expected `>` after variable type constraint
67 let foo: Attr<_: Type{};
73 // CHECK: the type of this variable has already been constrained
74 let foo: [Attr<_: Type>, Attr<_: Type];
80 // CHECK: expected `.` after dialect namespace
87 // CHECK: expected operation name after dialect namespace
88 let foo: Op<builtin.>;
94 // CHECK: expected `>` after operation name
95 let foo: Op<func.func<;
101 // CHECK: expected expression
108 // CHECK: expected expression of `Type` in type constraint
109 let foo: Value<_: Attr>;
115 // CHECK: expected `>` after variable type constraint
116 let foo: Value<_: Type{};
122 // CHECK: the type of this variable has already been constrained
123 let foo: [Value<_: Type>, Value<_: Type];
129 // CHECK: expected expression
130 let foo: ValueRange<10>;
136 // CHECK: expected expression of `TypeRange` in type constraint
137 let foo: ValueRange<_: Type>;
143 // CHECK: expected `>` after variable type constraint
144 let foo: ValueRange<_: Type{};
150 // CHECK: the type of this variable has already been constrained
151 let foo: [ValueRange<_: Type>, ValueRange<_: Type];
157 // CHECK: unknown reference to constraint `UnknownConstraint`
158 let foo: UnknownConstraint;
168 // CHECK: invalid reference to non-constraint
175 // CHECK: constraint type `Attr` is incompatible with the previously inferred type `Value`
176 let foo: [Value, Attr];
182 // CHECK: expected `]` after constraint list
189 // CHECK: expected expression
196 // CHECK: type constraints are not permitted on variables with initializers
197 let foo: ValueRange<_: Type> = _: Op;
203 // CHECK: unable to infer type for variable `foo`
204 // CHECK: note: the type of a variable must be inferable from the constraint list or the initializer
211 // CHECK: unable to convert expression of type `Attr` to the expected type of `Value`
212 let foo: Value = _: Attr;
218 // CHECK: :7:7: error: `foo` has already been defined
219 // CHECK: :6:7: note: see previous definition here
229 // CHECK: unable to define variable of `Constraint` type
238 // CHECK: unable to define variable of `Rewrite` type
244 Constraint MultiConstraint(arg1: Value, arg2: Value);
247 // CHECK: `Constraint`s applied via a variable constraint list must take a single input, but got 2
248 let foo: MultiConstraint;
253 #include "include/ops.td"
256 // CHECK: unable to convert expression of type `Op<test.all_empty>` to the expected type of `Value`
257 // CHECK: see the definition of `test.all_empty`, which was defined with zero results
258 let value: Value = op<test.all_empty>;
264 #include "include/ops.td"
267 // CHECK: unable to convert expression of type `Op<test.multiple_single_result>` to the expected type of `Value`
268 // CHECK: see the definition of `test.multiple_single_result`, which was defined with at least 2 results
269 let value: Value = op<test.multiple_single_result>;
275 //===----------------------------------------------------------------------===//
277 //===----------------------------------------------------------------------===//
280 // CHECK: expected `Op` expression
281 replace attr<""> with attr<"">;
287 // CHECK: expected `with` after root operation
294 // CHECK: expected `Op`, `Value` or `ValueRange` expression
295 replace op<> with attr<"">;
301 // CHECK: expected `Op`, `Value` or `ValueRange` expression
302 replace op<> with (attr<"">);
308 // CHECK: expected `)` after replacement values
309 replace op<>(input: Value) with (input;
315 // CHECK: expected at least one replacement value, consider using `erase` if no replacement values are desired
316 replace op<>(input: Value) with ();
322 // CHECK: expected dialect namespace
323 replace op<>(input: Value) with op<>;
328 //===----------------------------------------------------------------------===//
330 //===----------------------------------------------------------------------===//
332 // CHECK: expected `;` after statement
333 Constraint Foo(arg: Value) -> Value {
339 //===----------------------------------------------------------------------===//
341 //===----------------------------------------------------------------------===//
344 // CHECK: expected `Op` expression
345 rewrite attr<""> with { op<toy.reshape>; };
351 // CHECK: expected `with` before rewrite body
358 // CHECK: expected `{` to start rewrite body
365 // CHECK: expected dialect namespace
366 rewrite root: Op with {
374 // CHECK: `return` statements are only permitted within a `Constraint` or `Rewrite` body
375 rewrite root: Op with {