[clang-tidy][NFC]remove deps of clang in clang tidy test (#116588)
[llvm-project.git] / mlir / test / mlir-pdll / Parser / stmt.pdll
blob872301ce327240655fb93b6851b47b9c1ec17240
1 // RUN: mlir-pdll %s -I %S -split-input-file | FileCheck %s
3 //===----------------------------------------------------------------------===//
4 // CompoundStmt
5 //===----------------------------------------------------------------------===//
7 // CHECK: Module
8 // CHECK: CompoundStmt
9 // CHECK:   |-LetStmt
10 // CHECK:   `-EraseStmt
11 Pattern {
12   let root: Op;
13   erase root;
16 // -----
18 //===----------------------------------------------------------------------===//
19 // EraseStmt
20 //===----------------------------------------------------------------------===//
22 // CHECK: Module
23 // CHECK: EraseStmt
24 // CHECK:   `-DeclRefExpr {{.*}} Type<Op>
25 Pattern {
26   erase _: Op;
29 // -----
31 //===----------------------------------------------------------------------===//
32 // LetStmt
33 //===----------------------------------------------------------------------===//
35 // CHECK: Module
36 // CHECK: LetStmt
37 // CHECK:   `-VariableDecl {{.*}} Name<attrVar> Type<Attr>
38 // CHECK:     `Constraints`
39 // CHECK:       `-AttrConstraintDecl
40 // CHECK:   `-VariableDecl {{.*}} Name<var> Type<Op>
41 // CHECK:     `Constraints`
42 // CHECK:       `-OpConstraintDecl
43 // CHECK:         `-OpNameDecl
44 Pattern {
45   let attrVar: Attr;
46   let var: Op;
47   erase var;
50 // -----
52 // Check for proper refinement between constraint types.
54 // CHECK: Module
55 // CHECK: LetStmt
56 // CHECK:   `-VariableDecl {{.*}} Name<var> Type<Op<dialect.op>>
57 // CHECK:     `Constraints`
58 // CHECK:       `-OpConstraintDecl
59 // CHECK:         `-OpNameDecl
60 // CHECK:       `-OpConstraintDecl
61 // CHECK:         `-OpNameDecl {{.*}} Name<dialect.op>
62 Pattern {
63   let var: [Op, Op<dialect.op>];
64   erase var;
67 // -----
69 // Check for proper conversion between initializer and constraint type.
71 // CHECK: Module
72 // CHECK: LetStmt
73 // CHECK:   `-VariableDecl {{.*}} Name<var> Type<Op<dialect.op>>
74 // CHECK:     `-DeclRefExpr {{.*}} Type<Op<dialect.op>>
75 // CHECK:       `-VariableDecl {{.*}} Name<input>
76 // CHECK:     `Constraints`
77 // CHECK:       `-OpConstraintDecl
78 // CHECK:         `-OpNameDecl
79 Pattern {
80   let input: Op<dialect.op>;
81   let var: Op = input;
82   erase var;
85 // -----
87 // Check for proper conversion between initializer and constraint type.
89 // CHECK: Module
90 // CHECK: LetStmt
91 // CHECK:   `-VariableDecl {{.*}} Name<var> Type<Value>
92 // CHECK:     `-MemberAccessExpr {{.*}} Member<$results> Type<Value>
93 // CHECK:       `-DeclRefExpr {{.*}} Type<Op<dialect.op>>
94 // CHECK:         `-VariableDecl {{.*}} Name<input>
95 // CHECK:     `Constraints`
96 // CHECK:       `-ValueConstraintDecl
97 Pattern {
98   let input: Op<dialect.op>;
99   let var: Value = input;
100   erase _: Op;
103 // -----
105 // Check for proper conversion between initializer and constraint type.
107 // CHECK: Module
108 // CHECK: LetStmt
109 // CHECK:   `-VariableDecl {{.*}} Name<var> Type<ValueRange>
110 // CHECK:     `-MemberAccessExpr {{.*}} Member<$results> Type<ValueRange>
111 // CHECK:       `-DeclRefExpr {{.*}} Type<Op<dialect.op>>
112 // CHECK:         `-VariableDecl {{.*}} Name<input>
113 // CHECK:     `Constraints`
114 // CHECK:       `-ValueRangeConstraintDecl
115 Pattern {
116   let input: Op<dialect.op>;
117   let var: ValueRange = input;
118   erase _: Op;
121 // -----
123 // Check for proper handling of type constraints.
125 // CHECK: Module
126 // CHECK: LetStmt
127 // CHECK:   `-VariableDecl {{.*}} Name<var> Type<Value>
128 // CHECK:     `Constraints`
129 // CHECK:       `-ValueConstraintDecl
130 // CHECK:         `-DeclRefExpr {{.*}} Type<Type>
131 // CHECK:           `-VariableDecl {{.*}} Name<_> Type<Type>
132 // CHECK:             `Constraints`
133 // CHECK:               `-TypeConstraintDecl
134 Pattern {
135   let var: Value<_: Type>;
136   erase _: Op;
139 // -----
141 // Check for proper handling of type constraints.
143 // CHECK: Module
144 // CHECK: LetStmt
145 // CHECK:   `-VariableDecl {{.*}} Name<var> Type<ValueRange>
146 // CHECK:     `Constraints`
147 // CHECK:       `-ValueRangeConstraintDecl
148 // CHECK:         `-DeclRefExpr {{.*}} Type<TypeRange>
149 // CHECK:           `-VariableDecl {{.*}} Name<_> Type<TypeRange>
150 // CHECK:             `Constraints`
151 // CHECK:               `-TypeRangeConstraintDecl
152 Pattern {
153   let var: ValueRange<_: TypeRange>;
154   erase _: Op;
157 // -----
159 //===----------------------------------------------------------------------===//
160 // ReplaceStmt
161 //===----------------------------------------------------------------------===//
163 // CHECK: Module
164 // CHECK: `-ReplaceStmt
165 // CHECK:   `-DeclRefExpr {{.*}} Type<Op>
166 // CHECK:   ReplValues
167 // CHECK:     `-OperationExpr {{.*}} Type<Op<my_dialect.foo>>
168 Pattern {
169   replace _: Op with op<my_dialect.foo>;
172 // -----
174 // CHECK: Module
175 // CHECK: `-ReplaceStmt
176 // CHECK:   `-DeclRefExpr {{.*}} Type<Op>
177 // CHECK:   ReplValues
178 // CHECK:     |-DeclRefExpr {{.*}} Type<Value>
179 // CHECK:     |-DeclRefExpr {{.*}} Type<ValueRange>
180 // CHECK:     `-MemberAccessExpr {{.*}} Member<$results> Type<ValueRange>
181 // CHECK:       `-OperationExpr {{.*}} Type<Op<my_dialect.foo>>
182 Pattern {
183   replace _: Op with (_: Value, _: ValueRange, op<my_dialect.foo>);
186 // -----
188 //===----------------------------------------------------------------------===//
189 // RewriteStmt
190 //===----------------------------------------------------------------------===//
192 // CHECK: Module
193 // CHECK: `-RewriteStmt
194 // CHECK:   |-DeclRefExpr {{.*}} Type<Op>
195 // CHECK:   `-CompoundStmt
196 // CHECK:     |-OperationExpr {{.*}} Type<Op<my_dialect.some_op>>
197 // CHECK:     `-ReplaceStmt {{.*}}
198 // CHECK:       `-DeclRefExpr {{.*}} Type<Op>
199 // CHECK:       `ReplValues`
200 // CHECK:          `-OperationExpr {{.*}} Type<Op<my_dialect.foo>>
201 Pattern {
202   rewrite root: Op with {
203     op<my_dialect.some_op>;
204     replace root with op<my_dialect.foo>;
205   };