1 // RUN: mlir-pdll %s -I %S -I %S/../../../include -split-input-file | FileCheck %s
3 //===----------------------------------------------------------------------===//
5 //===----------------------------------------------------------------------===//
8 // CHECK: `-AttributeExpr {{.*}} Value<"10: i32">
10 let attr = attr<"10: i32">;
17 //===----------------------------------------------------------------------===//
19 //===----------------------------------------------------------------------===//
22 // CHECK: |-UserConstraintDecl {{.*}} Name<MakeRootOp> ResultType<Op<my_dialect.foo>>
23 // CHECK: `-CallExpr {{.*}} Type<Op<my_dialect.foo>>
24 // CHECK: `-DeclRefExpr {{.*}} Type<Constraint>
25 // CHECK: `-UserConstraintDecl {{.*}} Name<MakeRootOp> ResultType<Op<my_dialect.foo>>
26 Constraint MakeRootOp() => op<my_dialect.foo>;
35 // CHECK: |-UserRewriteDecl {{.*}} Name<CreateNewOp> ResultType<Op<my_dialect.foo>>
36 // CHECK: `-PatternDecl {{.*}}
37 // CHECK: `-CallExpr {{.*}} Type<Op<my_dialect.foo>>
38 // CHECK: `-DeclRefExpr {{.*}} Type<Rewrite>
39 // CHECK: `-UserRewriteDecl {{.*}} Name<CreateNewOp> ResultType<Op<my_dialect.foo>>
41 // CHECK: `-MemberAccessExpr {{.*}} Member<$results> Type<ValueRange>
42 // CHECK: `-DeclRefExpr {{.*}} Type<Op<my_dialect.bar>>
43 // CHECK: `-VariableDecl {{.*}} Name<inputOp> Type<Op<my_dialect.bar>>
44 Rewrite CreateNewOp(inputs: ValueRange) => op<my_dialect.foo>(inputs);
47 let inputOp = op<my_dialect.bar>;
48 replace op<my_dialect.bar>(inputOp) with CreateNewOp(inputOp);
53 // CHECK: Module {{.*}}
54 // CHECK: -UserConstraintDecl {{.*}} Name<TestConstraint> ResultType<Tuple<>>
55 // CHECK: `-PatternDecl {{.*}}
56 // CHECK: -CallExpr {{.*}} Type<Tuple<>> Negated
57 // CHECK: `-DeclRefExpr {{.*}} Type<Constraint>
58 // CHECK: `-UserConstraintDecl {{.*}} Name<TestConstraint> ResultType<Tuple<>>
59 Constraint TestConstraint(op: Op);
62 let inputOp = op<my_dialect.bar>;
63 not TestConstraint(inputOp);
69 //===----------------------------------------------------------------------===//
71 //===----------------------------------------------------------------------===//
74 // CHECK: `-VariableDecl {{.*}} Name<firstEltIndex> Type<Op>
75 // CHECK: `-MemberAccessExpr {{.*}} Member<0> Type<Op>
76 // CHECK: `-DeclRefExpr {{.*}} Type<Tuple<firstElt: Op>>
77 // CHECK: `-VariableDecl {{.*}} Name<firstEltName> Type<Op>
78 // CHECK: `-MemberAccessExpr {{.*}} Member<firstElt> Type<Op>
79 // CHECK: `-DeclRefExpr {{.*}} Type<Tuple<firstElt: Op>>
81 let tuple = (firstElt = _: Op);
82 let firstEltIndex = tuple.0;
83 let firstEltName = tuple.firstElt;
90 #include "include/ops.td"
93 // CHECK: `-VariableDecl {{.*}} Name<firstEltIndex> Type<Value>
94 // CHECK: `-MemberAccessExpr {{.*}} Member<0> Type<Value>
95 // CHECK: `-DeclRefExpr {{.*}} Type<Op<test.all_single>>
96 // CHECK: `-VariableDecl {{.*}} Name<firstEltName> Type<Value>
97 // CHECK: `-MemberAccessExpr {{.*}} Member<result> Type<Value>
98 // CHECK: `-DeclRefExpr {{.*}} Type<Op<test.all_single>>
100 let op: Op<test.all_single>;
101 let firstEltIndex = op.0;
102 let firstEltName = op.result;
110 // CHECK: `-VariableDecl {{.*}} Name<op> Type<Op<my_dialect.unregistered_foo>>
111 // CHECK: `-OperationExpr {{.*}} Type<Op<my_dialect.unregistered_foo>>
112 // CHECK: `-OpNameDecl {{.*}} Name<my_dialect.unregistered_foo>
114 // CHECK: `-MemberAccessExpr {{.*}} Member<0> Type<Value>
115 // CHECK: `-OperationExpr {{.*}} Type<Op<my_dialect.unregistered_bar>>
116 // CHECK: `-OpNameDecl {{.*}} Name<my_dialect.unregistered_bar>
118 // CHECK: `-DeclRefExpr {{.*}} Type<ValueRange>
119 // CHECK: `-VariableDecl {{.*}} Name<_> Type<ValueRange>
120 // CHECK: `Constraints`
121 // CHECK: `-ValueRangeConstraintDecl
123 let op = op<my_dialect.unregistered_foo>(op<my_dialect.unregistered_bar>.0);
129 //===----------------------------------------------------------------------===//
131 //===----------------------------------------------------------------------===//
133 // Test a non-constrained operation expression, and ensure that we don't treat
134 // unconstrained as "not present"(e.g. zero operands).
137 // CHECK: `-OperationExpr {{.*}} Type<Op>
138 // CHECK: `-OpNameDecl
140 // CHECK: `-DeclRefExpr {{.*}} Type<ValueRange>
141 // CHECK: `-VariableDecl {{.*}} Name<_> Type<ValueRange>
142 // CHECK: `Constraints`
143 // CHECK: `-ValueRangeConstraintDecl
144 // CHECK: `Result Types`
145 // CHECK: `-DeclRefExpr {{.*}} Type<TypeRange>
146 // CHECK: `-VariableDecl {{.*}} Name<_> Type<TypeRange>
147 // CHECK: `Constraints`
148 // CHECK: `-TypeRangeConstraintDecl
155 // Test explicitly empty operand/result/etc. lists, which are different from the
156 // "unconstrained" examples above.
159 // CHECK: `-OperationExpr {{.*}} Type<Op>
160 // CHECK: `-OpNameDecl
161 // CHECK-NOT: `Operands`
162 // CHECK-NOT: `Result Types`
170 // CHECK: `-OperationExpr {{.*}} Type<Op<my_dialect.foo>>
171 // CHECK: `-OpNameDecl {{.*}} Name<my_dialect.foo>
173 erase op<my_dialect.foo>;
179 // CHECK: `-OperationExpr {{.*}} Type<Op>
180 // CHECK: `-OpNameDecl
182 // CHECK: |-DeclRefExpr {{.*}} Type<Value>
183 // CHECK: |-DeclRefExpr {{.*}} Type<ValueRange>
184 // CHECK: `-DeclRefExpr {{.*}} Type<Value>
186 erase op<>(_: Value, _: ValueRange, _: Value);
192 // CHECK: `-OperationExpr {{.*}} Type<Op>
193 // CHECK: `-OpNameDecl
195 // CHECK: `-MemberAccessExpr {{.*}} Member<$results> Type<ValueRange>
196 // CHECK: `-OperationExpr {{.*}} Type<Op<my_dialect.bar>>
197 // CHECK: `-OpNameDecl {{.*}} Name<my_dialect.bar>
199 erase op<>(op<my_dialect.bar>);
205 // CHECK: `-OperationExpr {{.*}} Type<Op>
206 // CHECK: `-OpNameDecl
207 // CHECK: `Attributes`
208 // CHECK: |-NamedAttributeDecl {{.*}} Name<unitAttr>
209 // CHECK: `-AttributeExpr {{.*}} Value<"unit">
210 // CHECK: `-NamedAttributeDecl {{.*}} Name<normal$Attr>
211 // CHECK: `-DeclRefExpr {{.*}} Type<Attr>
214 erase op<> {unitAttr, "normal$Attr" = _: Attr};
220 // CHECK: `-OperationExpr {{.*}} Type<Op>
221 // CHECK: `-OpNameDecl
222 // CHECK: `Result Types`
223 // CHECK: |-DeclRefExpr {{.*}} Type<Type>
224 // CHECK: |-DeclRefExpr {{.*}} Type<TypeRange>
225 // CHECK: `-DeclRefExpr {{.*}} Type<Type>
227 erase op<> -> (_: Type, _: TypeRange, _: Type);
232 // Test that we don't need to provide values if all elements
235 #include "include/ops.td"
238 // CHECK: -OperationExpr {{.*}} Type<Op<test.multi_variadic>>
239 // CHECK-NOT: `Operands`
240 // CHECK-NOT: `Result Types`
241 // CHECK: -OperationExpr {{.*}} Type<Op<test.all_variadic>>
242 // CHECK-NOT: `Operands`
243 // CHECK-NOT: `Result Types`
244 // CHECK: -OperationExpr {{.*}} Type<Op<test.multi_variadic>>
246 // CHECK: -RangeExpr {{.*}} Type<ValueRange>
247 // CHECK: -RangeExpr {{.*}} Type<ValueRange>
248 // CHECK: `Result Types`
249 // CHECK: -RangeExpr {{.*}} Type<TypeRange>
250 // CHECK: -RangeExpr {{.*}} Type<TypeRange>
252 rewrite op<test.multi_variadic>() -> () with {
253 op<test.all_variadic> -> ();
254 op<test.multi_variadic> -> ();
260 //===----------------------------------------------------------------------===//
262 //===----------------------------------------------------------------------===//
265 // CHECK: `-VariableDecl {{.*}} Name<emptyTuple>
266 // CHECK: `-TupleExpr {{.*}} Type<Tuple<>>
267 // CHECK: `-VariableDecl {{.*}} Name<mixedTuple>
268 // CHECK: `-TupleExpr {{.*}} Type<Tuple<arg1: Attr, Value>>
269 // CHECK: |-DeclRefExpr {{.*}} Type<Attr>
270 // CHECK: `-DeclRefExpr {{.*}} Type<Value>
275 let mixedTuple = (arg1 = _: Attr, value);
282 //===----------------------------------------------------------------------===//
284 //===----------------------------------------------------------------------===//
288 // CHECK: -RangeExpr {{.*}} Type<ValueRange>
289 // CHECK: -RangeExpr {{.*}} Type<ValueRange>
290 // CHECK: -MemberAccessExpr {{.*}} Member<0> Type<Value>
291 // CHECK: -MemberAccessExpr {{.*}} Member<1> Type<ValueRange>
292 // CHECK: `Result Types`
293 // CHECK: -RangeExpr {{.*}} Type<TypeRange>
294 // CHECK: -RangeExpr {{.*}} Type<TypeRange>
295 // CHECK: -MemberAccessExpr {{.*}} Member<0> Type<Type>
296 // CHECK: -MemberAccessExpr {{.*}} Member<1> Type<TypeRange>
298 rewrite op<>(arg: Value, args: ValueRange) -> (type: Type, types: TypeRange) with {
299 op<test.op>((), (arg, args)) -> ((), (type, types));
305 //===----------------------------------------------------------------------===//
307 //===----------------------------------------------------------------------===//
310 // CHECK: `-TypeExpr {{.*}} Value<"i64">
312 let type = type<"i64">;