• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// RUN: mlir-opt -allow-unregistered-dialect %s | mlir-opt -allow-unregistered-dialect -verify-diagnostics | FileCheck %s
2
3// CHECK: %[[I64:.*]] =
4%i64 = "foo.op"() : () -> (i64)
5// CHECK: %[[I32:.*]] =
6%i32 = "foo.op"() : () -> (i32)
7// CHECK: %[[MEMREF:.*]] =
8%memref = "foo.op"() : () -> (memref<1xf64>)
9
10// CHECK: test.format_literal_op keyword_$. -> :, = <> () []( ) ? + * {foo.some_attr}
11test.format_literal_op keyword_$. -> :, = <> () []( ) ? + * {foo.some_attr}
12
13// CHECK: test.format_attr_op 10
14// CHECK-NOT: {attr
15test.format_attr_op 10
16
17// CHECK: test.format_opt_attr_op_a(10)
18// CHECK-NOT: {opt_attr
19test.format_opt_attr_op_a(10)
20test.format_opt_attr_op_a
21
22// CHECK: test.format_opt_attr_op_b 10
23// CHECK-NOT: {opt_attr
24test.format_opt_attr_op_b 10
25test.format_opt_attr_op_b
26
27// CHECK: test.format_symbol_name_attr_op @name
28// CHECK-NOT: {attr
29test.format_symbol_name_attr_op @name
30
31// CHECK: test.format_symbol_name_attr_op @opt_name
32// CHECK-NOT: {attr
33test.format_symbol_name_attr_op @opt_name
34test.format_opt_symbol_name_attr_op
35
36// CHECK: test.format_attr_dict_w_keyword attributes {attr = 10 : i64}
37test.format_attr_dict_w_keyword attributes {attr = 10 : i64}
38
39// CHECK: test.format_attr_dict_w_keyword attributes {attr = 10 : i64, opt_attr = 10 : i64}
40test.format_attr_dict_w_keyword attributes {attr = 10 : i64, opt_attr = 10 : i64}
41
42// CHECK: test.format_buildable_type_op %[[I64]]
43%ignored = test.format_buildable_type_op %i64
44
45//===----------------------------------------------------------------------===//
46// Format regions
47//===----------------------------------------------------------------------===//
48
49// CHECK: test.format_region_a_op {
50// CHECK-NEXT: test.return
51test.format_region_a_op {
52  "test.return"() : () -> ()
53}
54
55// CHECK: test.format_region_b_op {
56// CHECK-NEXT: test.return
57test.format_region_b_op {
58  "test.return"() : () -> ()
59}
60
61// CHECK: test.format_region_c_op region {
62// CHECK-NEXT: test.return
63test.format_region_c_op region {
64  "test.return"() : () -> ()
65}
66// CHECK: test.format_region_c_op
67// CHECK-NOT: region {
68test.format_region_c_op
69
70// CHECK: test.format_variadic_region_a_op {
71// CHECK-NEXT: test.return
72// CHECK-NEXT: }, {
73// CHECK-NEXT: test.return
74// CHECK-NEXT: }
75test.format_variadic_region_a_op {
76  "test.return"() : () -> ()
77}, {
78  "test.return"() : () -> ()
79}
80// CHECK: test.format_variadic_region_b_op {
81// CHECK-NEXT: test.return
82// CHECK-NEXT: }, {
83// CHECK-NEXT: test.return
84// CHECK-NEXT: } found_regions
85test.format_variadic_region_b_op {
86  "test.return"() : () -> ()
87}, {
88  "test.return"() : () -> ()
89} found_regions
90// CHECK: test.format_variadic_region_b_op
91// CHECK-NOT: {
92// CHECK-NOT: found_regions
93test.format_variadic_region_b_op
94
95// CHECK: test.format_implicit_terminator_region_a_op {
96// CHECK-NEXT: }
97test.format_implicit_terminator_region_a_op {
98  "test.return"() : () -> ()
99}
100// CHECK: test.format_implicit_terminator_region_a_op {
101// CHECK-NEXT: test.return"() {foo.attr
102test.format_implicit_terminator_region_a_op {
103  "test.return"() {foo.attr} : () -> ()
104}
105// CHECK: test.format_implicit_terminator_region_a_op {
106// CHECK-NEXT: test.return"(%[[I64]]) : (i64)
107test.format_implicit_terminator_region_a_op {
108  "test.return"(%i64) : (i64) -> ()
109}
110
111//===----------------------------------------------------------------------===//
112// Format results
113//===----------------------------------------------------------------------===//
114
115// CHECK: test.format_result_a_op memref<1xf64>
116%ignored_a:2 = test.format_result_a_op memref<1xf64>
117
118// CHECK: test.format_result_b_op i64, memref<1xf64>
119%ignored_b:2 = test.format_result_b_op i64, memref<1xf64>
120
121// CHECK: test.format_result_c_op (i64) -> memref<1xf64>
122%ignored_c:2 = test.format_result_c_op (i64) -> memref<1xf64>
123
124// CHECK: test.format_variadic_result : i64, i64, i64
125%ignored_v:3 = test.format_variadic_result : i64, i64, i64
126
127// CHECK: test.format_multiple_variadic_results : (i64, i64, i64), (i32, i32)
128%ignored_mv:5 = test.format_multiple_variadic_results : (i64, i64, i64), (i32, i32)
129
130//===----------------------------------------------------------------------===//
131// Format operands
132//===----------------------------------------------------------------------===//
133
134// CHECK: test.format_operand_a_op %[[I64]], %[[MEMREF]] : i64, memref<1xf64>
135test.format_operand_a_op %i64, %memref : i64, memref<1xf64>
136
137// CHECK: test.format_operand_b_op %[[I64]], %[[MEMREF]] : memref<1xf64>
138test.format_operand_b_op %i64, %memref : memref<1xf64>
139
140// CHECK: test.format_operand_c_op %[[I64]], %[[MEMREF]] : i64, memref<1xf64>
141test.format_operand_c_op %i64, %memref : i64, memref<1xf64>
142
143// CHECK: test.format_operand_d_op %[[I64]], %[[MEMREF]] : memref<1xf64>
144test.format_operand_d_op %i64, %memref : memref<1xf64>
145
146// CHECK: test.format_operand_e_op %[[I64]], %[[MEMREF]] : i64, memref<1xf64>
147test.format_operand_e_op %i64, %memref : i64, memref<1xf64>
148
149// CHECK: test.format_variadic_operand %[[I64]], %[[I64]], %[[I64]] : i64, i64, i64
150test.format_variadic_operand %i64, %i64, %i64 : i64, i64, i64
151
152// CHECK: test.format_multiple_variadic_operands (%[[I64]], %[[I64]], %[[I64]]), (%[[I64]], %[[I32]] : i64, i32)
153test.format_multiple_variadic_operands (%i64, %i64, %i64), (%i64, %i32 : i64, i32)
154
155//===----------------------------------------------------------------------===//
156// Format successors
157//===----------------------------------------------------------------------===//
158
159"foo.successor_test_region"() ( {
160  ^bb0:
161    // CHECK: test.format_successor_a_op ^bb1 {attr}
162    test.format_successor_a_op ^bb1 {attr}
163
164  ^bb1:
165    // CHECK: test.format_successor_a_op ^bb1, ^bb2 {attr}
166    test.format_successor_a_op ^bb1, ^bb2 {attr}
167
168  ^bb2:
169    // CHECK: test.format_successor_a_op {attr}
170    test.format_successor_a_op {attr}
171
172}) { arg_names = ["i", "j", "k"] } : () -> ()
173
174//===----------------------------------------------------------------------===//
175// Format optional attributes
176//===----------------------------------------------------------------------===//
177
178// CHECK: test.format_optional_unit_attribute is_optional
179test.format_optional_unit_attribute is_optional
180
181// CHECK: test.format_optional_unit_attribute
182// CHECK-NOT: is_optional
183test.format_optional_unit_attribute
184
185// CHECK: test.format_optional_unit_attribute_no_elide unit
186test.format_optional_unit_attribute_no_elide unit
187
188// CHECK: test.format_optional_enum_attr "case5"
189test.format_optional_enum_attr "case5"
190
191// CHECK: test.format_optional_enum_attr
192// CHECK-NOT: "case5"
193test.format_optional_enum_attr
194
195//===----------------------------------------------------------------------===//
196// Format optional operands and results
197//===----------------------------------------------------------------------===//
198
199// CHECK: test.format_optional_operand_result_a_op(%[[I64]] : i64) : i64
200test.format_optional_operand_result_a_op(%i64 : i64) : i64
201
202// CHECK: test.format_optional_operand_result_a_op( : ) : i64
203test.format_optional_operand_result_a_op( : ) : i64
204
205// CHECK: test.format_optional_operand_result_a_op(%[[I64]] : i64) :
206// CHECK-NOT: i64
207test.format_optional_operand_result_a_op(%i64 : i64) :
208
209// CHECK: test.format_optional_operand_result_a_op(%[[I64]] : i64) : [%[[I64]], %[[I64]]]
210test.format_optional_operand_result_a_op(%i64 : i64) : [%i64, %i64]
211
212// CHECK: test.format_optional_operand_result_b_op(%[[I64]] : i64) : i64
213test.format_optional_operand_result_b_op(%i64 : i64) : i64
214
215// CHECK: test.format_optional_operand_result_b_op : i64
216test.format_optional_operand_result_b_op( : ) : i64
217
218// CHECK: test.format_optional_operand_result_b_op : i64
219test.format_optional_operand_result_b_op : i64
220
221//===----------------------------------------------------------------------===//
222// Format custom directives
223//===----------------------------------------------------------------------===//
224
225// CHECK: test.format_custom_directive_operands %[[I64]], %[[I64]] -> (%[[I64]])
226test.format_custom_directive_operands %i64, %i64 -> (%i64)
227
228// CHECK: test.format_custom_directive_operands %[[I64]] -> (%[[I64]])
229test.format_custom_directive_operands %i64 -> (%i64)
230
231// CHECK: test.format_custom_directive_operands_and_types %[[I64]], %[[I64]] -> (%[[I64]]) : i64, i64 -> (i64)
232test.format_custom_directive_operands_and_types %i64, %i64 -> (%i64) : i64, i64 -> (i64)
233
234// CHECK: test.format_custom_directive_operands_and_types %[[I64]] -> (%[[I64]]) : i64 -> (i64)
235test.format_custom_directive_operands_and_types %i64 -> (%i64) : i64 -> (i64)
236
237// CHECK: test.format_custom_directive_attributes 54 : i64
238test.format_custom_directive_attributes 54 : i64
239
240// CHECK: test.format_custom_directive_attributes 54 : i64, 46 : i64
241test.format_custom_directive_attributes 54 : i64, 46 : i64
242
243// CHECK: test.format_custom_directive_regions {
244// CHECK-NEXT: test.return
245// CHECK-NEXT: }
246test.format_custom_directive_regions {
247  "test.return"() : () -> ()
248}
249
250// CHECK: test.format_custom_directive_regions {
251// CHECK-NEXT: test.return
252// CHECK-NEXT: }, {
253// CHECK-NEXT: test.return
254// CHECK-NEXT: }
255test.format_custom_directive_regions {
256  "test.return"() : () -> ()
257}, {
258  "test.return"() : () -> ()
259}
260
261// CHECK: test.format_custom_directive_results : i64, i64 -> (i64)
262test.format_custom_directive_results : i64, i64 -> (i64)
263
264// CHECK: test.format_custom_directive_results : i64 -> (i64)
265test.format_custom_directive_results : i64 -> (i64)
266
267// CHECK: test.format_custom_directive_results_with_type_refs : i64, i64 -> (i64) type_refs_capture : i64, i64 -> (i64)
268test.format_custom_directive_results_with_type_refs : i64, i64 -> (i64) type_refs_capture : i64, i64 -> (i64)
269
270// CHECK: test.format_custom_directive_results_with_type_refs : i64 -> (i64) type_refs_capture : i64 -> (i64)
271test.format_custom_directive_results_with_type_refs : i64 -> (i64) type_refs_capture : i64 -> (i64)
272
273func @foo() {
274  // CHECK: test.format_custom_directive_successors ^bb1, ^bb2
275  test.format_custom_directive_successors ^bb1, ^bb2
276
277^bb1:
278  // CHECK: test.format_custom_directive_successors ^bb2
279  test.format_custom_directive_successors ^bb2
280
281^bb2:
282  return
283}
284
285//===----------------------------------------------------------------------===//
286// Format trait type inference
287//===----------------------------------------------------------------------===//
288
289// CHECK: test.format_infer_variadic_type_from_non_variadic %[[I64]], %[[I64]] : i64
290test.format_infer_variadic_type_from_non_variadic %i64, %i64 : i64
291
292//===----------------------------------------------------------------------===//
293// AllTypesMatch type inference
294//===----------------------------------------------------------------------===//
295
296// CHECK: test.format_all_types_match_var %[[I64]], %[[I64]] : i64
297%ignored_res1 = test.format_all_types_match_var %i64, %i64 : i64
298
299// CHECK: test.format_all_types_match_attr 1 : i64, %[[I64]]
300%ignored_res2 = test.format_all_types_match_attr 1 : i64, %i64
301
302//===----------------------------------------------------------------------===//
303// TypesMatchWith type inference
304//===----------------------------------------------------------------------===//
305
306// CHECK: test.format_types_match_var %[[I64]] : i64
307%ignored_res3 = test.format_types_match_var %i64 : i64
308
309// CHECK: test.format_types_match_attr 1 : i64
310%ignored_res4 = test.format_types_match_attr 1 : i64
311