1 // RUN: mlir-pdll %s -I %S -split-input-file | FileCheck %s
3 //===----------------------------------------------------------------------===//
5 //===----------------------------------------------------------------------===//
18 //===----------------------------------------------------------------------===//
20 //===----------------------------------------------------------------------===//
24 // CHECK: `-DeclRefExpr {{.*}} Type<Op>
31 //===----------------------------------------------------------------------===//
33 //===----------------------------------------------------------------------===//
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
52 // Check for proper refinement between constraint types.
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>
63 let var: [Op, Op<dialect.op>];
69 // Check for proper conversion between initializer and constraint type.
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
80 let input: Op<dialect.op>;
87 // Check for proper conversion between initializer and constraint type.
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
98 let input: Op<dialect.op>;
99 let var: Value = input;
105 // Check for proper conversion between initializer and constraint type.
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
116 let input: Op<dialect.op>;
117 let var: ValueRange = input;
123 // Check for proper handling of type constraints.
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
135 let var: Value<_: Type>;
141 // Check for proper handling of type constraints.
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
153 let var: ValueRange<_: TypeRange>;
159 //===----------------------------------------------------------------------===//
161 //===----------------------------------------------------------------------===//
164 // CHECK: `-ReplaceStmt
165 // CHECK: `-DeclRefExpr {{.*}} Type<Op>
167 // CHECK: `-OperationExpr {{.*}} Type<Op<my_dialect.foo>>
169 replace _: Op with op<my_dialect.foo>;
175 // CHECK: `-ReplaceStmt
176 // CHECK: `-DeclRefExpr {{.*}} Type<Op>
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>>
183 replace _: Op with (_: Value, _: ValueRange, op<my_dialect.foo>);
188 //===----------------------------------------------------------------------===//
190 //===----------------------------------------------------------------------===//
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>>
202 rewrite root: Op with {
203 op<my_dialect.some_op>;
204 replace root with op<my_dialect.foo>;