xref: /llvm-project/mlir/test/mlir-pdll/Parser/pattern-failure.pdll (revision faf42264e5401a1dfca95b701e5c2bf951d7f8a7)
1// RUN: not mlir-pdll %s -split-input-file 2>&1 | FileCheck %s
2
3// CHECK: expected `{` or `=>` to start pattern body
4Pattern }
5
6// -----
7
8// CHECK: :6:9: error: `Foo` has already been defined
9// CHECK: :5:9: note: see previous definition here
10Pattern Foo { erase root: Op; }
11Pattern Foo { erase root: Op; }
12
13// -----
14
15// CHECK: `return` statements are only permitted within a `Constraint` or `Rewrite` body
16Pattern {
17  return _: Value;
18}
19
20// -----
21
22// CHECK: expected Pattern body to terminate with an operation rewrite statement
23Pattern {
24  let value: Value;
25}
26
27// -----
28
29// CHECK: Pattern body was terminated by an operation rewrite statement, but found trailing statements
30Pattern {
31  erase root: Op;
32  let value: Value;
33}
34
35// -----
36
37// CHECK: expected Pattern lambda body to contain a single operation rewrite statement, such as `erase`, `replace`, or `rewrite`
38Pattern => op<>;
39
40// -----
41
42Rewrite SomeRewrite();
43
44// CHECK: unable to invoke `Rewrite` within a match section
45Pattern {
46  SomeRewrite();
47}
48
49// -----
50
51//===----------------------------------------------------------------------===//
52// Metadata
53//===----------------------------------------------------------------------===//
54
55// CHECK: expected pattern metadata identifier
56Pattern with {}
57
58// -----
59
60// CHECK: unknown pattern metadata
61Pattern with unknown {}
62
63// -----
64
65// CHECK: expected `(` before pattern benefit
66Pattern with benefit) {}
67
68// -----
69
70// CHECK: expected integral pattern benefit
71Pattern with benefit(foo) {}
72
73// -----
74
75// CHECK: expected pattern benefit to fit within a 16-bit integer
76Pattern with benefit(65536) {}
77
78// -----
79
80// CHECK: expected `)` after pattern benefit
81Pattern with benefit(1( {}
82
83// -----
84
85// CHECK: pattern benefit has already been specified
86// CHECK: see previous definition here
87Pattern with benefit(1), benefit(1) {}
88
89// -----
90
91// CHECK: pattern recursion metadata has already been specified
92// CHECK: see previous definition here
93Pattern with recursion, recursion {}
94