379 lines · plain
1// RUN: not mlir-pdll %s -I %S -I %S/../../../include -split-input-file 2>&1 | FileCheck %s2 3// CHECK: expected top-level declaration, such as a `Pattern`4105 6// -----7 8Pattern {9 // CHECK: expected `;` after statement10 erase _: Op11}12 13// -----14 15//===----------------------------------------------------------------------===//16// `erase`17//===----------------------------------------------------------------------===//18 19Pattern {20 // CHECK: expected expression21 erase;22}23 24// -----25 26Pattern {27 // CHECK: expected `Op` expression28 erase _: Attr;29}30 31// -----32 33//===----------------------------------------------------------------------===//34// `let`35//===----------------------------------------------------------------------===//36 37Pattern {38 // CHECK: expected identifier after `let` to name a new variable39 let 5;40}41 42// -----43 44Pattern {45 // CHECK: `_` may only be used to define "inline" variables46 let _;47}48 49// -----50 51Pattern {52 // CHECK: expected expression53 let foo: Attr<>;54}55 56// -----57 58Pattern {59 // CHECK: expected expression of `Type` in type constraint60 let foo: Attr<_: Attr>;61}62 63// -----64 65Pattern {66 // CHECK: expected `>` after variable type constraint67 let foo: Attr<_: Type{};68}69 70// -----71 72Pattern {73 // CHECK: the type of this variable has already been constrained74 let foo: [Attr<_: Type>, Attr<_: Type];75}76 77// -----78 79Pattern {80 // CHECK: expected `.` after dialect namespace81 let foo: Op<builtin>;82}83 84// -----85 86Pattern {87 // CHECK: expected operation name after dialect namespace88 let foo: Op<builtin.>;89}90 91// -----92 93Pattern {94 // CHECK: expected `>` after operation name95 let foo: Op<func.func<;96}97 98// -----99 100Pattern {101 // CHECK: expected expression102 let foo: Value<>;103}104 105// -----106 107Pattern {108 // CHECK: expected expression of `Type` in type constraint109 let foo: Value<_: Attr>;110}111 112// -----113 114Pattern {115 // CHECK: expected `>` after variable type constraint116 let foo: Value<_: Type{};117}118 119// -----120 121Pattern {122 // CHECK: the type of this variable has already been constrained123 let foo: [Value<_: Type>, Value<_: Type];124}125 126// -----127 128Pattern {129 // CHECK: expected expression130 let foo: ValueRange<10>;131}132 133// -----134 135Pattern {136 // CHECK: expected expression of `TypeRange` in type constraint137 let foo: ValueRange<_: Type>;138}139 140// -----141 142Pattern {143 // CHECK: expected `>` after variable type constraint144 let foo: ValueRange<_: Type{};145}146 147// -----148 149Pattern {150 // CHECK: the type of this variable has already been constrained151 let foo: [ValueRange<_: Type>, ValueRange<_: Type];152}153 154// -----155 156Pattern {157 // CHECK: unknown reference to constraint `UnknownConstraint`158 let foo: UnknownConstraint;159}160 161// -----162 163Pattern Foo {164 erase root: Op;165}166 167Pattern {168 // CHECK: invalid reference to non-constraint169 let foo: Foo;170}171 172// -----173 174Pattern {175 // CHECK: constraint type `Attr` is incompatible with the previously inferred type `Value`176 let foo: [Value, Attr];177}178 179// -----180 181Pattern {182 // CHECK: expected `]` after constraint list183 let foo: [Attr[];184}185 186// -----187 188Pattern {189 // CHECK: expected expression190 let foo: Attr = ;191}192 193// -----194 195Pattern {196 // CHECK: type constraints are not permitted on variables with initializers197 let foo: ValueRange<_: Type> = _: Op;198}199 200// -----201 202Pattern {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 initializer205 let foo;206}207 208// -----209 210Pattern {211 // CHECK: unable to convert expression of type `Attr` to the expected type of `Value`212 let foo: Value = _: Attr;213}214 215// -----216 217Pattern {218 // CHECK: :7:7: error: `foo` has already been defined219 // CHECK: :6:7: note: see previous definition here220 let foo: Attr;221 let foo: Attr;222}223 224// -----225 226Constraint Foo();227 228Pattern {229 // CHECK: unable to define variable of `Constraint` type230 let foo = Foo;231}232 233// -----234 235Rewrite Foo();236 237Pattern {238 // CHECK: unable to define variable of `Rewrite` type239 let foo = Foo;240}241 242// -----243 244Constraint MultiConstraint(arg1: Value, arg2: Value);245 246Pattern {247 // CHECK: `Constraint`s applied via a variable constraint list must take a single input, but got 2248 let foo: MultiConstraint;249}250 251// -----252 253#include "include/ops.td"254 255Pattern {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 results258 let value: Value = op<test.all_empty>;259 erase _: Op;260}261 262// -----263 264#include "include/ops.td"265 266Pattern {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 results269 let value: Value = op<test.multiple_single_result>;270 erase _: Op;271}272 273// -----274 275//===----------------------------------------------------------------------===//276// `replace`277//===----------------------------------------------------------------------===//278 279Pattern {280 // CHECK: expected `Op` expression281 replace attr<""> with attr<"">;282}283 284// -----285 286Pattern {287 // CHECK: expected `with` after root operation288 replace op<>;289}290 291// -----292 293Pattern {294 // CHECK: expected `Op`, `Value` or `ValueRange` expression295 replace op<> with attr<"">;296}297 298// -----299 300Pattern {301 // CHECK: expected `Op`, `Value` or `ValueRange` expression302 replace op<> with (attr<"">);303}304 305// -----306 307Pattern {308 // CHECK: expected `)` after replacement values309 replace op<>(input: Value) with (input;310}311 312// -----313 314Pattern {315 // CHECK: expected at least one replacement value, consider using `erase` if no replacement values are desired316 replace op<>(input: Value) with ();317}318 319// -----320 321Pattern {322 // CHECK: expected dialect namespace323 replace op<>(input: Value) with op<>;324}325 326// -----327 328//===----------------------------------------------------------------------===//329// `return`330//===----------------------------------------------------------------------===//331 332// CHECK: expected `;` after statement333Constraint Foo(arg: Value) -> Value {334 return arg335}336 337// -----338 339//===----------------------------------------------------------------------===//340// `rewrite`341//===----------------------------------------------------------------------===//342 343Pattern {344 // CHECK: expected `Op` expression345 rewrite attr<""> with { op<toy.reshape>; };346}347 348// -----349 350Pattern {351 // CHECK: expected `with` before rewrite body352 rewrite op<>;353}354 355// -----356 357Pattern {358 // CHECK: expected `{` to start rewrite body359 rewrite op<> with;360}361 362// -----363 364Pattern {365 // CHECK: expected dialect namespace366 rewrite root: Op with {367 op<>;368 };369}370 371// -----372 373Pattern {374 // CHECK: `return` statements are only permitted within a `Constraint` or `Rewrite` body375 rewrite root: Op with {376 return root;377 };378}379