1 // RUN: mlir-opt -allow-unregistered-dialect %s | FileCheck %s
3 // CHECK-DAG: #map{{[0-9]*}} = affine_map<(d0, d1, d2, d3, d4)[s0] -> (d0, d1, d2, d4, d3)>
4 #map = affine_map<(d0, d1, d2, d3, d4)[s0] -> (d0, d1, d2, d4, d3)>
6 // CHECK-DAG: #map{{[0-9]*}} = affine_map<(d0) -> (d0)>
7 #map1 = affine_map<(d0) -> (d0)>
9 // CHECK-DAG: #map{{[0-9]*}} = affine_map<(d0, d1, d2) -> (d0, d1, d2)>
10 #map2 = affine_map<(d0, d1, d2) -> (d0, d1, d2)>
12 // CHECK-DAG: #map{{[0-9]*}} = affine_map<(d0, d1, d2) -> (d1, d0, d2)>
13 #map3 = affine_map<(d0, d1, d2) -> (d1, d0, d2)>
15 // CHECK-DAG: #map{{[0-9]*}} = affine_map<()[s0] -> (0, s0 - 1)>
16 #inline_map_minmax_loop1 = affine_map<()[s0] -> (0, s0 - 1)>
18 // CHECK-DAG: #map{{[0-9]*}} = affine_map<()[s0] -> (100, s0 + 1)>
19 #inline_map_minmax_loop2 = affine_map<()[s0] -> (100, s0 + 1)>
21 // CHECK-DAG: #map{{[0-9]*}} = affine_map<(d0, d1)[s0] -> (d0 + d1 + s0)>
22 #bound_map1 = affine_map<(i, j)[s] -> (i + j + s)>
24 // CHECK-DAG: #map{{[0-9]*}} = affine_map<(d0, d1) -> (d0 + d1)>
25 #inline_map_loop_bounds2 = affine_map<(d0, d1) -> (d0 + d1)>
27 // CHECK-DAG: #map{{[0-9]*}} = affine_map<(d0)[s0] -> (d0 + s0, d0 - s0)>
28 #bound_map2 = affine_map<(i)[s] -> (i + s, i - s)>
30 // All maps appear in arbitrary order before all sets, in arbitrary order.
31 // CHECK-NOT: Placeholder
33 // CHECK-DAG: #set{{[0-9]*}} = affine_set<(d0)[s0, s1] : (d0 >= 0, -d0 + s0 >= 0, s0 - 5 == 0, -d0 + s1 + 1 >= 0)>
34 #set0 = affine_set<(i)[N, M] : (i >= 0, -i + N >= 0, N - 5 == 0, -i + M + 1 >= 0)>
36 // CHECK-DAG: #set{{[0-9]*}} = affine_set<(d0, d1)[s0] : (d0 >= 0, d1 >= 0)>
37 #set1 = affine_set<(d0, d1)[s0] : (d0 >= 0, d1 >= 0)>
39 // CHECK-DAG: #set{{[0-9]*}} = affine_set<(d0) : (d0 - 1 == 0)>
40 #set2 = affine_set<(d0) : (d0 - 1 == 0)>
42 // CHECK-DAG: [[$SET_TRUE:#set[0-9]+]] = affine_set<() : (0 == 0)>
44 // CHECK-DAG: #set{{[0-9]*}} = affine_set<(d0)[s0] : (d0 - 2 >= 0, -d0 + 4 >= 0)>
46 // CHECK: func private @foo(i32, i64) -> f32
47 func.func private @foo(i32, i64) -> f32
49 // CHECK: func private @bar()
50 func.func private @bar() -> ()
52 // CHECK: func private @baz() -> (i1, index, f32)
53 func.func private @baz() -> (i1, index, f32)
55 // CHECK: func private @missingReturn()
56 func.func private @missingReturn()
58 // CHECK: func private @int_types(i0, i1, i2, i4, i7, i87) -> (i1, index, i19)
59 func.func private @int_types(i0, i1, i2, i4, i7, i87) -> (i1, index, i19)
61 // CHECK: func private @sint_types(si2, si4) -> (si7, si1023)
62 func.func private @sint_types(si2, si4) -> (si7, si1023)
64 // CHECK: func private @uint_types(ui2, ui4) -> (ui7, ui1023)
65 func.func private @uint_types(ui2, ui4) -> (ui7, ui1023)
67 // CHECK: func private @float_types(f80, f128)
68 func.func private @float_types(f80, f128)
70 // CHECK: func private @vectors(vector<f32>, vector<1xf32>, vector<2x4xf32>)
71 func.func private @vectors(vector<f32>, vector<1 x f32>, vector<2x4xf32>)
73 // CHECK: func private @tensors(tensor<*xf32>, tensor<*xvector<2x4xf32>>, tensor<1x?x4x?x?xi32>, tensor<i8>)
74 func.func private @tensors(tensor<* x f32>, tensor<* x vector<2x4xf32>>,
75 tensor<1x?x4x?x?xi32>, tensor<i8>)
77 // CHECK: func private @tensor_encoding(tensor<16x32xf64, "sparse">)
78 func.func private @tensor_encoding(tensor<16x32xf64, "sparse">)
80 // CHECK: func private @large_shape_dimension(tensor<9223372036854775807xf32>)
81 func.func private @large_shape_dimension(tensor<9223372036854775807xf32>)
83 // CHECK: func private @functions((memref<1x?x4x?x?xi32, #map>, memref<8xi8>) -> (), () -> ())
84 func.func private @functions((memref<1x?x4x?x?xi32, #map, 0>, memref<8xi8, #map1, 0>) -> (), ()->())
86 // CHECK: func private @memrefs2(memref<2x4x8xi8, 1>)
87 func.func private @memrefs2(memref<2x4x8xi8, #map2, 1>)
89 // CHECK: func private @memrefs3(memref<2x4x8xi8>)
90 func.func private @memrefs3(memref<2x4x8xi8, affine_map<(d0, d1, d2) -> (d0, d1, d2)>>)
92 // CHECK: func private @memrefs_drop_triv_id_inline(memref<2xi8>)
93 func.func private @memrefs_drop_triv_id_inline(memref<2xi8, affine_map<(d0) -> (d0)>>)
95 // CHECK: func private @memrefs_drop_triv_id_inline0(memref<2xi8>)
96 func.func private @memrefs_drop_triv_id_inline0(memref<2xi8, affine_map<(d0) -> (d0)>, 0>)
98 // CHECK: func private @memrefs_drop_triv_id_inline1(memref<2xi8, 1>)
99 func.func private @memrefs_drop_triv_id_inline1(memref<2xi8, affine_map<(d0) -> (d0)>, 1>)
101 // Test memref with custom memory space
103 // CHECK: func private @memrefs_nomap_nospace(memref<5x6x7xf32>)
104 func.func private @memrefs_nomap_nospace(memref<5x6x7xf32>)
106 // CHECK: func private @memrefs_map_nospace(memref<5x6x7xf32, #map{{[0-9]*}}>)
107 func.func private @memrefs_map_nospace(memref<5x6x7xf32, #map3>)
109 // CHECK: func private @memrefs_nomap_intspace(memref<5x6x7xf32, 3>)
110 func.func private @memrefs_nomap_intspace(memref<5x6x7xf32, 3>)
112 // CHECK: func private @memrefs_map_intspace(memref<5x6x7xf32, #map{{[0-9]*}}, 5>)
113 func.func private @memrefs_map_intspace(memref<5x6x7xf32, #map3, 5>)
115 // CHECK: func private @memrefs_nomap_strspace(memref<5x6x7xf32, "local">)
116 func.func private @memrefs_nomap_strspace(memref<5x6x7xf32, "local">)
118 // CHECK: func private @memrefs_map_strspace(memref<5x6x7xf32, #map{{[0-9]*}}, "private">)
119 func.func private @memrefs_map_strspace(memref<5x6x7xf32, #map3, "private">)
121 // CHECK: func private @memrefs_nomap_dictspace(memref<5x6x7xf32, {memSpace = "special", subIndex = 1 : i64}>)
122 func.func private @memrefs_nomap_dictspace(memref<5x6x7xf32, {memSpace = "special", subIndex = 1}>)
124 // CHECK: func private @memrefs_map_dictspace(memref<5x6x7xf32, #map{{[0-9]*}}, {memSpace = "special", subIndex = 3 : i64}>)
125 func.func private @memrefs_map_dictspace(memref<5x6x7xf32, #map3, {memSpace = "special", subIndex = 3}>)
127 // CHECK: func private @complex_types(complex<i1>) -> complex<f32>
128 func.func private @complex_types(complex<i1>) -> complex<f32>
130 // CHECK: func private @memref_with_index_elems(memref<1x?xindex>)
131 func.func private @memref_with_index_elems(memref<1x?xindex>)
133 // CHECK: func private @memref_with_complex_elems(memref<1x?xcomplex<f32>>)
134 func.func private @memref_with_complex_elems(memref<1x?xcomplex<f32>>)
136 // CHECK: func private @memref_with_vector_elems(memref<1x?xvector<10xf32>>)
137 func.func private @memref_with_vector_elems(memref<1x?xvector<10xf32>>)
139 // CHECK: func private @memref_with_custom_elem(memref<1x?x!test.memref_element>)
140 func.func private @memref_with_custom_elem(memref<1x?x!test.memref_element>)
142 // CHECK: func private @memref_of_memref(memref<1xmemref<1xf64>>)
143 func.func private @memref_of_memref(memref<1xmemref<1xf64>>)
145 // CHECK: func private @memref_of_unranked_memref(memref<1xmemref<*xf32>>)
146 func.func private @memref_of_unranked_memref(memref<1xmemref<*xf32>>)
148 // CHECK: func private @unranked_memref_of_memref(memref<*xmemref<1xf32>>)
149 func.func private @unranked_memref_of_memref(memref<*xmemref<1xf32>>)
151 // CHECK: func private @unranked_memref_of_unranked_memref(memref<*xmemref<*xi32>>)
152 func.func private @unranked_memref_of_unranked_memref(memref<*xmemref<*xi32>>)
154 // CHECK: func private @unranked_memref_with_complex_elems(memref<*xcomplex<f32>>)
155 func.func private @unranked_memref_with_complex_elems(memref<*xcomplex<f32>>)
157 // CHECK: func private @unranked_memref_with_index_elems(memref<*xindex>)
158 func.func private @unranked_memref_with_index_elems(memref<*xindex>)
160 // CHECK: func private @unranked_memref_with_vector_elems(memref<*xvector<10xf32>>)
161 func.func private @unranked_memref_with_vector_elems(memref<*xvector<10xf32>>)
163 // CHECK-LABEL: func @simpleCFG(%{{.*}}: i32, %{{.*}}: f32) -> i1 {
164 func.func @simpleCFG(%arg0: i32, %f: f32) -> i1 {
165 // CHECK: %{{.*}} = "foo"() : () -> i64
166 %1 = "foo"() : ()->i64
167 // CHECK: "bar"(%{{.*}}) : (i64) -> (i1, i1, i1)
168 %2:3 = "bar"(%1) : (i64) -> (i1,i1,i1)
169 // CHECK: return %{{.*}}#1
174 // CHECK-LABEL: func @simpleCFGUsingBBArgs(%{{.*}}: i32, %{{.*}}: i64) {
175 func.func @simpleCFGUsingBBArgs(i32, i64) {
176 ^bb42 (%arg0: i32, %f: i64):
177 // CHECK: "bar"(%{{.*}}) : (i64) -> (i1, i1, i1)
178 %2:3 = "bar"(%f) : (i64) -> (i1,i1,i1)
179 // CHECK: return{{$}}
184 // CHECK-LABEL: func @block_label_empty_list
185 func.func @block_label_empty_list() {
190 // CHECK-LABEL: func @multiblock() {
191 func.func @multiblock() {
192 return // CHECK: return
193 ^bb1: // CHECK: ^bb1: // no predecessors
194 cf.br ^bb4 // CHECK: cf.br ^bb3
195 ^bb2: // CHECK: ^bb2: // pred: ^bb2
196 cf.br ^bb2 // CHECK: cf.br ^bb2
197 ^bb4: // CHECK: ^bb3: // pred: ^bb1
198 return // CHECK: return
201 // CHECK-LABEL: func @emptyMLF() {
202 func.func @emptyMLF() {
203 return // CHECK: return
206 // CHECK-LABEL: func @func_with_one_arg(%{{.*}}: i1) -> i2 {
207 func.func @func_with_one_arg(%c : i1) -> i2 {
208 // CHECK: %{{.*}} = "foo"(%{{.*}}) : (i1) -> i2
209 %b = "foo"(%c) : (i1) -> (i2)
210 return %b : i2 // CHECK: return %{{.*}} : i2
213 // CHECK-LABEL: func @func_with_two_args(%{{.*}}: f16, %{{.*}}: i8) -> (i1, i32) {
214 func.func @func_with_two_args(%a : f16, %b : i8) -> (i1, i32) {
215 // CHECK: %{{.*}}:2 = "foo"(%{{.*}}, %{{.*}}) : (f16, i8) -> (i1, i32)
216 %c:2 = "foo"(%a, %b) : (f16, i8)->(i1, i32)
217 return %c#0, %c#1 : i1, i32 // CHECK: return %{{.*}}#0, %{{.*}}#1 : i1, i32
220 // CHECK-LABEL: func @second_order_func() -> (() -> ()) {
221 func.func @second_order_func() -> (() -> ()) {
222 // CHECK-NEXT: %{{.*}} = constant @emptyMLF : () -> ()
223 %c = constant @emptyMLF : () -> ()
224 // CHECK-NEXT: return %{{.*}} : () -> ()
228 // CHECK-LABEL: func @third_order_func() -> (() -> (() -> ())) {
229 func.func @third_order_func() -> (() -> (() -> ())) {
230 // CHECK-NEXT: %{{.*}} = constant @second_order_func : () -> (() -> ())
231 %c = constant @second_order_func : () -> (() -> ())
232 // CHECK-NEXT: return %{{.*}} : () -> (() -> ())
233 return %c : () -> (() -> ())
236 // CHECK-LABEL: func @identity_functor(%{{.*}}: () -> ()) -> (() -> ()) {
237 func.func @identity_functor(%a : () -> ()) -> (() -> ()) {
238 // CHECK-NEXT: return %{{.*}} : () -> ()
242 // CHECK-LABEL: func @func_ops_in_loop() {
243 func.func @func_ops_in_loop() {
244 // CHECK: %{{.*}} = "foo"() : () -> i64
245 %a = "foo"() : ()->i64
246 // CHECK: affine.for %{{.*}} = 1 to 10 {
247 affine.for %i = 1 to 10 {
248 // CHECK: %{{.*}} = "doo"() : () -> f32
249 %b = "doo"() : ()->f32
250 // CHECK: "bar"(%{{.*}}, %{{.*}}) : (i64, f32) -> ()
251 "bar"(%a, %b) : (i64, f32) -> ()
260 // CHECK-LABEL: func @loops() {
262 // CHECK: affine.for %{{.*}} = 1 to 100 step 2 {
263 affine.for %i = 1 to 100 step 2 {
264 // CHECK: affine.for %{{.*}} = 1 to 200 {
265 affine.for %j = 1 to 200 {
268 return // CHECK: return
271 // CHECK-LABEL: func @complex_loops() {
272 func.func @complex_loops() {
273 affine.for %i1 = 1 to 100 { // CHECK: affine.for %{{.*}} = 1 to 100 {
274 affine.for %j1 = 1 to 100 { // CHECK: affine.for %{{.*}} = 1 to 100 {
275 // CHECK: "foo"(%{{.*}}, %{{.*}}) : (index, index) -> ()
276 "foo"(%i1, %j1) : (index,index) -> ()
278 "boo"() : () -> () // CHECK: "boo"() : () -> ()
279 affine.for %j2 = 1 to 10 { // CHECK: affine.for %{{.*}} = 1 to 10 {
280 affine.for %k2 = 1 to 10 { // CHECK: affine.for %{{.*}} = 1 to 10 {
281 "goo"() : () -> () // CHECK: "goo"() : () -> ()
285 return // CHECK: return
288 // CHECK: func @triang_loop(%{{.*}}: index, %{{.*}}: memref<?x?xi32>) {
289 func.func @triang_loop(%arg0: index, %arg1: memref<?x?xi32>) {
290 %c = arith.constant 0 : i32 // CHECK: %{{.*}} = arith.constant 0 : i32
291 affine.for %i0 = 1 to %arg0 { // CHECK: affine.for %{{.*}} = 1 to %{{.*}} {
292 affine.for %i1 = affine_map<(d0)[]->(d0)>(%i0)[] to %arg0 { // CHECK: affine.for %{{.*}} = #map{{[0-9]*}}(%{{.*}}) to %{{.*}} {
293 memref.store %c, %arg1[%i0, %i1] : memref<?x?xi32> // CHECK: memref.store %{{.*}}, %{{.*}}[%{{.*}}, %{{.*}}]
296 return // CHECK: return
299 // CHECK: func @minmax_loop(%{{.*}}: index, %{{.*}}: index, %{{.*}}: memref<100xf32>) {
300 func.func @minmax_loop(%arg0: index, %arg1: index, %arg2: memref<100xf32>) {
301 // CHECK: affine.for %{{.*}} = max #map{{.*}}()[%{{.*}}] to min #map{{.*}}()[%{{.*}}] {
302 affine.for %i0 = max affine_map<()[s]->(0,s-1)>()[%arg0] to min affine_map<()[s]->(100,s+1)>()[%arg1] {
303 // CHECK: "foo"(%{{.*}}, %{{.*}}) : (memref<100xf32>, index) -> ()
304 "foo"(%arg2, %i0) : (memref<100xf32>, index) -> ()
306 return // CHECK: return
309 // CHECK-LABEL: func @loop_bounds(%{{.*}}: index) {
310 func.func @loop_bounds(%N : index) {
311 // CHECK: %{{.*}} = "foo"(%{{.*}}) : (index) -> index
312 %s = "foo"(%N) : (index) -> index
313 // CHECK: affine.for %{{.*}} = %{{.*}} to %{{.*}}
314 affine.for %i = %s to %N {
315 // CHECK: affine.for %{{.*}} = #map{{[0-9]*}}(%{{.*}}) to 0
316 affine.for %j = affine_map<(d0)[]->(d0)>(%i)[] to 0 step 1 {
317 // CHECK: %{{.*}} = affine.apply #map{{.*}}(%{{.*}}, %{{.*}})[%{{.*}}]
318 %w1 = affine.apply affine_map<(d0, d1)[s0] -> (d0+d1)> (%i, %j) [%s]
319 // CHECK: %{{.*}} = affine.apply #map{{.*}}(%{{.*}}, %{{.*}})[%{{.*}}]
320 %w2 = affine.apply affine_map<(d0, d1)[s0] -> (s0+1)> (%i, %j) [%s]
321 // CHECK: affine.for %{{.*}} = #map{{.*}}(%{{.*}}, %{{.*}})[%{{.*}}] to #map{{.*}}(%{{.*}}, %{{.*}})[%{{.*}}] {
322 affine.for %k = #bound_map1 (%w1, %i)[%N] to affine_map<(i, j)[s] -> (i + j + s)> (%w2, %j)[%s] {
323 // CHECK: "foo"(%{{.*}}, %{{.*}}, %{{.*}}) : (index, index, index) -> ()
324 "foo"(%i, %j, %k) : (index, index, index)->()
325 // CHECK: %{{.*}} = arith.constant 30 : index
326 %c = arith.constant 30 : index
327 // CHECK: %{{.*}} = affine.apply #map{{.*}}(%{{.*}}, %{{.*}})
328 %u = affine.apply affine_map<(d0, d1)->(d0+d1)> (%N, %c)
329 // CHECK: affine.for %{{.*}} = max #map{{.*}}(%{{.*}})[%{{.*}}] to min #map{{.*}}(%{{.*}})[%{{.*}}] {
330 affine.for %l = max #bound_map2(%i)[%u] to min #bound_map2(%k)[%c] {
331 // CHECK: "bar"(%{{.*}}) : (index) -> ()
332 "bar"(%l) : (index) -> ()
337 return // CHECK: return
340 // CHECK-LABEL: func @ifinst(%{{.*}}: index) {
341 func.func @ifinst(%N: index) {
342 %c = arith.constant 200 : index // CHECK %{{.*}} = arith.constant 200
343 affine.for %i = 1 to 10 { // CHECK affine.for %{{.*}} = 1 to 10 {
344 affine.if #set0(%i)[%N, %c] { // CHECK affine.if #set0(%{{.*}})[%{{.*}}, %{{.*}}] {
345 %x = arith.constant 1 : i32
346 // CHECK: %{{.*}} = arith.constant 1 : i32
347 %y = "add"(%x, %i) : (i32, index) -> i32 // CHECK: %{{.*}} = "add"(%{{.*}}, %{{.*}}) : (i32, index) -> i32
348 %z = "mul"(%y, %y) : (i32, i32) -> i32 // CHECK: %{{.*}} = "mul"(%{{.*}}, %{{.*}}) : (i32, i32) -> i32
349 } else { // CHECK } else {
350 affine.if affine_set<(i)[N] : (i - 2 >= 0, 4 - i >= 0)>(%i)[%N] { // CHECK affine.if (#set1(%{{.*}})[%{{.*}}]) {
351 // CHECK: %{{.*}} = arith.constant 1 : index
352 %u = arith.constant 1 : index
353 // CHECK: %{{.*}} = affine.apply #map{{.*}}(%{{.*}}, %{{.*}})[%{{.*}}]
354 %w = affine.apply affine_map<(d0,d1)[s0] -> (d0+d1+s0)> (%i, %i) [%u]
355 } else { // CHECK } else {
356 %v = arith.constant 3 : i32 // %c3_i32 = arith.constant 3 : i32
360 return // CHECK return
363 // CHECK-LABEL: func @simple_ifinst(%{{.*}}: index) {
364 func.func @simple_ifinst(%N: index) {
365 %c = arith.constant 200 : index // CHECK %{{.*}} = arith.constant 200
366 affine.for %i = 1 to 10 { // CHECK affine.for %{{.*}} = 1 to 10 {
367 affine.if #set0(%i)[%N, %c] { // CHECK affine.if #set0(%{{.*}})[%{{.*}}, %{{.*}}] {
368 %x = arith.constant 1 : i32
369 // CHECK: %{{.*}} = arith.constant 1 : i32
370 %y = "add"(%x, %i) : (i32, index) -> i32 // CHECK: %{{.*}} = "add"(%{{.*}}, %{{.*}}) : (i32, index) -> i32
371 %z = "mul"(%y, %y) : (i32, i32) -> i32 // CHECK: %{{.*}} = "mul"(%{{.*}}, %{{.*}}) : (i32, i32) -> i32
374 return // CHECK return
377 // CHECK-LABEL: func @attributes() {
378 func.func @attributes() {
382 // CHECK: "foo"() {a = 1 : i64, b = -423 : i64, c = [true, false], d = 1.600000e+01 : f64} : () -> ()
383 "foo"() {a = 1, b = -423, c = [true, false], d = 16.0 } : () -> ()
385 // CHECK: "foo"() {map1 = #map{{[0-9]*}}}
386 "foo"() {map1 = #map1} : () -> ()
388 // CHECK: "foo"() {map2 = #map{{[0-9]*}}}
389 "foo"() {map2 = affine_map<(d0, d1, d2) -> (d0, d1, d2)>} : () -> ()
391 // CHECK: "foo"() {map12 = [#map{{[0-9]*}}, #map{{[0-9]*}}]}
392 "foo"() {map12 = [#map1, #map2]} : () -> ()
394 // CHECK: "foo"() {set1 = #set{{[0-9]*}}}
395 "foo"() {set1 = #set1} : () -> ()
397 // CHECK: "foo"() {set2 = #set{{[0-9]*}}}
398 "foo"() {set2 = affine_set<(d0, d1, d2) : (d0 >= 0, d1 >= 0, d2 - d1 == 0)>} : () -> ()
400 // CHECK: "foo"() {set12 = [#set{{[0-9]*}}, #set{{[0-9]*}}]}
401 "foo"() {set12 = [#set1, #set2]} : () -> ()
403 // CHECK: "foo"() {dictionary = {bool = true, fn = @ifinst}}
404 "foo"() {dictionary = {bool = true, fn = @ifinst}} : () -> ()
406 // Check that the dictionary attribute elements are sorted.
407 // CHECK: "foo"() {dictionary = {bar = false, bool = true, fn = @ifinst}}
408 "foo"() {dictionary = {fn = @ifinst, bar = false, bool = true}} : () -> ()
410 // CHECK: "foo"() {d = 1.000000e-09 : f64, func = [], i123 = 7 : i64, if = "foo"} : () -> ()
411 "foo"() {if = "foo", func = [], i123 = 7, d = 1.e-9} : () -> ()
413 // CHECK: "foo"() {fn = @attributes, if = @ifinst} : () -> ()
414 "foo"() {fn = @attributes, if = @ifinst} : () -> ()
416 // CHECK: "foo"() {int = 0 : i42} : () -> ()
417 "foo"() {int = 0 : i42} : () -> ()
421 // CHECK-LABEL: func @ssa_values() -> (i16, i8) {
422 func.func @ssa_values() -> (i16, i8) {
423 // CHECK: %{{.*}}:2 = "foo"() : () -> (i1, i17)
424 %0:2 = "foo"() : () -> (i1, i17)
427 ^bb1: // CHECK: ^bb1: // pred: ^bb2
428 // CHECK: %{{.*}}:2 = "baz"(%{{.*}}#1, %{{.*}}#0, %{{.*}}#1) : (f32, i11, i17) -> (i16, i8)
429 %1:2 = "baz"(%2#1, %2#0, %0#1) : (f32, i11, i17) -> (i16, i8)
431 // CHECK: return %{{.*}}#0, %{{.*}}#1 : i16, i8
432 return %1#0, %1#1 : i16, i8
434 ^bb2: // CHECK: ^bb2: // pred: ^bb0
435 // CHECK: %{{.*}}:2 = "bar"(%{{.*}}#0, %{{.*}}#1) : (i1, i17) -> (i11, f32)
436 %2:2 = "bar"(%0#0, %0#1) : (i1, i17) -> (i11, f32)
440 // CHECK-LABEL: func @bbargs() -> (i16, i8) {
441 func.func @bbargs() -> (i16, i8) {
442 // CHECK: %{{.*}}:2 = "foo"() : () -> (i1, i17)
443 %0:2 = "foo"() : () -> (i1, i17)
444 cf.br ^bb1(%0#1, %0#0 : i17, i1)
446 ^bb1(%x: i17, %y: i1): // CHECK: ^bb1(%{{.*}}: i17, %{{.*}}: i1):
447 // CHECK: %{{.*}}:2 = "baz"(%{{.*}}, %{{.*}}, %{{.*}}#1) : (i17, i1, i17) -> (i16, i8)
448 %1:2 = "baz"(%x, %y, %0#1) : (i17, i1, i17) -> (i16, i8)
449 return %1#0, %1#1 : i16, i8
452 // CHECK-LABEL: func @verbose_terminators() -> (i1, i17)
453 func.func @verbose_terminators() -> (i1, i17) {
454 %0:2 = "foo"() : () -> (i1, i17)
455 // CHECK: cf.br ^bb1(%{{.*}}#0, %{{.*}}#1 : i1, i17)
456 "cf.br"(%0#0, %0#1)[^bb1] : (i1, i17) -> ()
458 ^bb1(%x : i1, %y : i17):
459 // CHECK: cf.cond_br %{{.*}}, ^bb2(%{{.*}} : i17), ^bb3(%{{.*}}, %{{.*}} : i1, i17)
460 "cf.cond_br"(%x, %y, %x, %y) [^bb2, ^bb3] {operand_segment_sizes = array<i32: 1, 1, 2>} : (i1, i17, i1, i17) -> ()
463 %true = arith.constant true
464 // CHECK: return %{{.*}}, %{{.*}} : i1, i17
465 "func.return"(%true, %a) : (i1, i17) -> ()
467 ^bb3(%b : i1, %c : i17):
468 // CHECK: return %{{.*}}, %{{.*}} : i1, i17
469 "func.return"(%b, %c) : (i1, i17) -> ()
472 // CHECK-LABEL: func @condbr_simple
473 func.func @condbr_simple() -> (i32) {
474 %cond = "foo"() : () -> i1
475 %a = "bar"() : () -> i32
476 %b = "bar"() : () -> i64
477 // CHECK: cf.cond_br %{{.*}}, ^bb1(%{{.*}} : i32), ^bb2(%{{.*}} : i64)
478 cf.cond_br %cond, ^bb1(%a : i32), ^bb2(%b : i64)
480 // CHECK: ^bb1({{.*}}: i32): // pred: ^bb0
484 // CHECK: ^bb2({{.*}}: i64): // 2 preds: ^bb0, ^bb1
486 %z = "foo"() : () -> i32
490 // CHECK-LABEL: func @condbr_moarargs
491 func.func @condbr_moarargs() -> (i32) {
492 %cond = "foo"() : () -> i1
493 %a = "bar"() : () -> i32
494 %b = "bar"() : () -> i64
495 // CHECK: cf.cond_br %{{.*}}, ^bb1(%{{.*}}, %{{.*}} : i32, i64), ^bb2(%{{.*}}, %{{.*}}, %{{.*}} : i64, i32, i32)
496 cf.cond_br %cond, ^bb1(%a, %b : i32, i64), ^bb2(%b, %a, %a : i64, i32, i32)
498 ^bb1(%x : i32, %y : i64):
501 ^bb2(%x2 : i64, %y2 : i32, %z2 : i32):
502 %z = "foo"() : () -> i32
507 // Test pretty printing of constant names.
508 // CHECK-LABEL: func @constants
509 func.func @constants() -> (i32, i23, i23, i1, i1) {
510 // CHECK: %{{.*}} = arith.constant 42 : i32
511 %x = arith.constant 42 : i32
512 // CHECK: %{{.*}} = arith.constant 17 : i23
513 %y = arith.constant 17 : i23
515 // This is a redundant definition of 17, the asmprinter gives it a unique name
516 // CHECK: %{{.*}} = arith.constant 17 : i23
517 %z = arith.constant 17 : i23
519 // CHECK: %{{.*}} = arith.constant true
520 %t = arith.constant true
521 // CHECK: %{{.*}} = arith.constant false
522 %f = arith.constant false
524 // The trick to parse type declarations should not interfere with hex
526 // CHECK: %{{.*}} = arith.constant 3890 : i32
527 %h = arith.constant 0xf32 : i32
529 // CHECK: return %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}
530 return %x, %y, %z, %t, %f : i32, i23, i23, i1, i1
533 // CHECK-LABEL: func @typeattr
534 func.func @typeattr() -> () {
536 // CHECK: "foo"() {bar = tensor<*xf32>} : () -> ()
537 "foo"(){bar = tensor<*xf32>} : () -> ()
541 // CHECK-LABEL: func @stringquote
542 func.func @stringquote() -> () {
544 // CHECK: "foo"() {bar = "a\22quoted\22string"} : () -> ()
545 "foo"(){bar = "a\"quoted\"string"} : () -> ()
547 // CHECK-NEXT: "typed_string" : !foo.string
548 "foo"(){bar = "typed_string" : !foo.string} : () -> ()
552 // CHECK-LABEL: func @unitAttrs
553 func.func @unitAttrs() -> () {
554 // CHECK-NEXT: "foo"() {unitAttr}
555 "foo"() {unitAttr = unit} : () -> ()
557 // CHECK-NEXT: "foo"() {unitAttr}
558 "foo"() {unitAttr} : () -> ()
560 // CHECK-NEXT: "foo"() {nested = {unitAttr}}
561 "foo"() {nested = {unitAttr}} : () -> ()
565 // CHECK-LABEL: func @floatAttrs
566 func.func @floatAttrs() -> () {
568 // CHECK: "foo"() {a = 4.000000e+00 : f64, b = 2.000000e+00 : f64, c = 7.100000e+00 : f64, d = -0.000000e+00 : f64} : () -> ()
569 "foo"(){a = 4.0, b = 2.0, c = 7.1, d = -0.0} : () -> ()
573 // CHECK-LABEL: func private @externalfuncattr
574 func.func private @externalfuncattr() -> ()
575 // CHECK: attributes {dialect.a = "a\22quoted\22string", dialect.b = 4.000000e+00 : f64, dialect.c = tensor<*xf32>}
576 attributes {dialect.a = "a\"quoted\"string", dialect.b = 4.0, dialect.c = tensor<*xf32>}
578 // CHECK-LABEL: func private @funcattrempty
579 func.func private @funcattrempty() -> ()
582 // CHECK-LABEL: func private @funcattr
583 func.func private @funcattr() -> ()
584 // CHECK: attributes {dialect.a = "a\22quoted\22string", dialect.b = 4.000000e+00 : f64, dialect.c = tensor<*xf32>}
585 attributes {dialect.a = "a\"quoted\"string", dialect.b = 4.0, dialect.c = tensor<*xf32>} {
590 // CHECK-LABEL: func @funcattrwithblock
591 func.func @funcattrwithblock() -> ()
597 // CHECK-label func @funcsimplemap
598 #map_simple0 = affine_map<()[] -> (10)>
599 #map_simple1 = affine_map<()[s0] -> (s0)>
600 #map_non_simple0 = affine_map<(d0)[] -> (d0)>
601 #map_non_simple1 = affine_map<(d0)[s0] -> (d0 + s0)>
602 #map_non_simple2 = affine_map<()[s0, s1] -> (s0 + s1)>
603 #map_non_simple3 = affine_map<()[s0] -> (s0 + 3)>
604 func.func @funcsimplemap(%arg0: index, %arg1: index) -> () {
605 affine.for %i0 = 0 to #map_simple0()[] {
606 // CHECK: affine.for %{{.*}} = 0 to 10 {
607 affine.for %i1 = 0 to #map_simple1()[%arg1] {
608 // CHECK: affine.for %{{.*}} = 0 to %{{.*}} {
609 affine.for %i2 = 0 to #map_non_simple0(%i0)[] {
610 // CHECK: affine.for %{{.*}} = 0 to #map{{[a-z_0-9]*}}(%{{.*}}) {
611 affine.for %i3 = 0 to #map_non_simple1(%i0)[%arg1] {
612 // CHECK: affine.for %{{.*}} = 0 to #map{{[a-z_0-9]*}}(%{{.*}})[%{{.*}}] {
613 affine.for %i4 = 0 to #map_non_simple2()[%arg1, %arg0] {
614 // CHECK: affine.for %{{.*}} = 0 to #map{{[a-z_0-9]*}}()[%{{.*}}, %{{.*}}] {
615 affine.for %i5 = 0 to #map_non_simple3()[%arg0] {
616 // CHECK: affine.for %{{.*}} = 0 to #map{{[a-z_0-9]*}}()[%{{.*}}] {
617 %c42_i32 = arith.constant 42 : i32
627 // CHECK-LABEL: func @splattensorattr
628 func.func @splattensorattr() -> () {
630 // CHECK: "splatBoolTensor"() {bar = dense<false> : tensor<i1>} : () -> ()
631 "splatBoolTensor"(){bar = dense<false> : tensor<i1>} : () -> ()
633 // CHECK: "splatUIntTensor"() {bar = dense<222> : tensor<2x1x4xui8>} : () -> ()
634 "splatUIntTensor"(){bar = dense<222> : tensor<2x1x4xui8>} : () -> ()
636 // CHECK: "splatIntTensor"() {bar = dense<5> : tensor<2x1x4xi32>} : () -> ()
637 "splatIntTensor"(){bar = dense<5> : tensor<2x1x4xi32>} : () -> ()
639 // CHECK: "splatFloatTensor"() {bar = dense<-5.000000e+00> : tensor<2x1x4xf32>} : () -> ()
640 "splatFloatTensor"(){bar = dense<-5.0> : tensor<2x1x4xf32>} : () -> ()
642 // CHECK: "splatIntVector"() {bar = dense<5> : vector<2x1x4xi64>} : () -> ()
643 "splatIntVector"(){bar = dense<5> : vector<2x1x4xi64>} : () -> ()
645 // CHECK: "splatFloatVector"() {bar = dense<-5.000000e+00> : vector<2x1x4xf16>} : () -> ()
646 "splatFloatVector"(){bar = dense<-5.0> : vector<2x1x4xf16>} : () -> ()
648 // CHECK: "splatIntScalar"() {bar = dense<5> : tensor<i9>} : () -> ()
649 "splatIntScalar"() {bar = dense<5> : tensor<i9>} : () -> ()
650 // CHECK: "splatFloatScalar"() {bar = dense<-5.000000e+00> : tensor<f16>} : () -> ()
651 "splatFloatScalar"() {bar = dense<-5.0> : tensor<f16>} : () -> ()
655 // CHECK-LABEL: func @densetensorattr
656 func.func @densetensorattr() -> () {
659 // NOTE: The {{\[\[}} syntax is because "[[" confuses FileCheck.
660 // CHECK: "fooi3"() {bar = dense<{{\[\[\[}}1, -2, 1, 2]], {{\[\[}}0, 2, -1, 2]]]> : tensor<2x1x4xi3>} : () -> ()
661 "fooi3"(){bar = dense<[[[1, -2, 1, 2]], [[0, 2, -1, 2]]]> : tensor<2x1x4xi3>} : () -> ()
662 // CHECK: "fooi6"() {bar = dense<{{\[\[\[}}5, -6, 1, 2]], {{\[\[}}7, 8, 3, 4]]]> : tensor<2x1x4xi6>} : () -> ()
663 "fooi6"(){bar = dense<[[[5, -6, 1, 2]], [[7, 8, 3, 4]]]> : tensor<2x1x4xi6>} : () -> ()
664 // CHECK: "fooi8"() {bar = dense<5> : tensor<1x1x1xi8>} : () -> ()
665 "fooi8"(){bar = dense<[[[5]]]> : tensor<1x1x1xi8>} : () -> ()
666 // CHECK: "fooi13"() {bar = dense<{{\[\[\[}}1, -2, 1, 2]], {{\[\[}}0, 2, -1, 2]]]> : tensor<2x1x4xi13>} : () -> ()
667 "fooi13"(){bar = dense<[[[1, -2, 1, 2]], [[0, 2, -1, 2]]]> : tensor<2x1x4xi13>} : () -> ()
668 // CHECK: "fooi16"() {bar = dense<-5> : tensor<1x1x1xi16>} : () -> ()
669 "fooi16"(){bar = dense<[[[-5]]]> : tensor<1x1x1xi16>} : () -> ()
670 // CHECK: "fooi23"() {bar = dense<{{\[\[\[}}1, -2, 1, 2]], {{\[\[}}0, 2, -1, 2]]]> : tensor<2x1x4xi23>} : () -> ()
671 "fooi23"(){bar = dense<[[[1, -2, 1, 2]], [[0, 2, -1, 2]]]> : tensor<2x1x4xi23>} : () -> ()
672 // CHECK: "fooi32"() {bar = dense<5> : tensor<1x1x1xi32>} : () -> ()
673 "fooi32"(){bar = dense<[[[5]]]> : tensor<1x1x1xi32>} : () -> ()
674 // CHECK: "fooi33"() {bar = dense<{{\[\[\[}}1, -2, 1, 2]], {{\[\[}}0, 2, -1, 2]]]> : tensor<2x1x4xi33>} : () -> ()
675 "fooi33"(){bar = dense<[[[1, -2, 1, 2]], [[0, 2, -1, 2]]]> : tensor<2x1x4xi33>} : () -> ()
676 // CHECK: "fooi43"() {bar = dense<{{\[\[\[}}1, -2, 1, 2]], {{\[\[}}0, 2, -1, 2]]]> : tensor<2x1x4xi43>} : () -> ()
677 "fooi43"(){bar = dense<[[[1, -2, 1, 2]], [[0, 2, -1, 2]]]> : tensor<2x1x4xi43>} : () -> ()
678 // CHECK: "fooi53"() {bar = dense<{{\[\[\[}}1, -2, 1, 2]], {{\[\[}}0, 2, -1, 2]]]> : tensor<2x1x4xi53>} : () -> ()
679 "fooi53"(){bar = dense<[[[1, -2, 1, 2]], [[0, 2, -1, 2]]]> : tensor<2x1x4xi53>} : () -> ()
680 // CHECK: "fooi64"() {bar = dense<{{\[\[\[}}1, -2, 1, 2]], {{\[\[}}0, 3, -1, 2]]]> : tensor<2x1x4xi64>} : () -> ()
681 "fooi64"(){bar = dense<[[[1, -2, 1, 2]], [[0, 3, -1, 2]]]> : tensor<2x1x4xi64>} : () -> ()
682 // CHECK: "fooi64"() {bar = dense<-5> : tensor<1x1x1xi64>} : () -> ()
683 "fooi64"(){bar = dense<[[[-5]]]> : tensor<1x1x1xi64>} : () -> ()
684 // CHECK: "fooi67"() {bar = dense<{{\[\[\[}}-5, 4, 6, 2]]]> : vector<1x1x4xi67>} : () -> ()
685 "fooi67"(){bar = dense<[[[-5, 4, 6, 2]]]> : vector<1x1x4xi67>} : () -> ()
687 // CHECK: "foo2"() {bar = dense<> : tensor<0xi32>} : () -> ()
688 "foo2"(){bar = dense<> : tensor<0xi32>} : () -> ()
689 // CHECK: "foo2"() {bar = dense<> : tensor<1x0xi32>} : () -> ()
690 "foo2"(){bar = dense<> : tensor<1x0xi32>} : () -> ()
691 // CHECK: dense<> : tensor<0x512x512xi32>
692 "foo2"(){bar = dense<> : tensor<0x512x512xi32>} : () -> ()
693 // CHECK: "foo3"() {bar = dense<{{\[\[\[}}5, -6, 1, 2]], {{\[\[}}7, 8, 3, 4]]]> : tensor<2x1x4xi32>} : () -> ()
694 "foo3"(){bar = dense<[[[5, -6, 1, 2]], [[7, 8, 3, 4]]]> : tensor<2x1x4xi32>} : () -> ()
696 // CHECK: "float1"() {bar = dense<5.000000e+00> : tensor<1x1x1xf32>} : () -> ()
697 "float1"(){bar = dense<[[[5.0]]]> : tensor<1x1x1xf32>} : () -> ()
698 // CHECK: "float2"() {bar = dense<> : tensor<0xf32>} : () -> ()
699 "float2"(){bar = dense<> : tensor<0xf32>} : () -> ()
700 // CHECK: "float2"() {bar = dense<> : tensor<1x0xf32>} : () -> ()
701 "float2"(){bar = dense<> : tensor<1x0xf32>} : () -> ()
703 // CHECK: "bfloat16"() {bar = dense<{{\[\[\[}}-5.000000e+00, 6.000000e+00, 1.000000e+00, 2.000000e+00]], {{\[\[}}7.000000e+00, -8.000000e+00, 3.000000e+00, 4.000000e+00]]]> : tensor<2x1x4xbf16>} : () -> ()
704 "bfloat16"(){bar = dense<[[[-5.0, 6.0, 1.0, 2.0]], [[7.0, -8.0, 3.0, 4.0]]]> : tensor<2x1x4xbf16>} : () -> ()
705 // CHECK: "float16"() {bar = dense<{{\[\[\[}}-5.000000e+00, 6.000000e+00, 1.000000e+00, 2.000000e+00]], {{\[\[}}7.000000e+00, -8.000000e+00, 3.000000e+00, 4.000000e+00]]]> : tensor<2x1x4xf16>} : () -> ()
706 "float16"(){bar = dense<[[[-5.0, 6.0, 1.0, 2.0]], [[7.0, -8.0, 3.0, 4.0]]]> : tensor<2x1x4xf16>} : () -> ()
707 // CHECK: "float32"() {bar = dense<{{\[\[\[}}-5.000000e+00, 6.000000e+00, 1.000000e+00, 2.000000e+00]], {{\[\[}}7.000000e+00, -8.000000e+00, 3.000000e+00, 4.000000e+00]]]> : tensor<2x1x4xf32>} : () -> ()
708 "float32"(){bar = dense<[[[-5.0, 6.0, 1.0, 2.0]], [[7.0, -8.0, 3.0, 4.0]]]> : tensor<2x1x4xf32>} : () -> ()
709 // CHECK: "float64"() {bar = dense<{{\[\[\[}}-5.000000e+00, 6.000000e+00, 1.000000e+00, 2.000000e+00]], {{\[\[}}7.000000e+00, -8.000000e+00, 3.000000e+00, 4.000000e+00]]]> : tensor<2x1x4xf64>} : () -> ()
710 "float64"(){bar = dense<[[[-5.0, 6.0, 1.0, 2.0]], [[7.0, -8.0, 3.0, 4.0]]]> : tensor<2x1x4xf64>} : () -> ()
712 // CHECK: "intscalar"() {bar = dense<1> : tensor<i32>} : () -> ()
713 "intscalar"(){bar = dense<1> : tensor<i32>} : () -> ()
714 // CHECK: "floatscalar"() {bar = dense<5.000000e+00> : tensor<f32>} : () -> ()
715 "floatscalar"(){bar = dense<5.0> : tensor<f32>} : () -> ()
717 // CHECK: "index"() {bar = dense<1> : tensor<index>} : () -> ()
718 "index"(){bar = dense<1> : tensor<index>} : () -> ()
719 // CHECK: "index"() {bar = dense<[1, 2]> : tensor<2xindex>} : () -> ()
720 "index"(){bar = dense<[1, 2]> : tensor<2xindex>} : () -> ()
722 // CHECK: dense<(1,1)> : tensor<complex<i64>>
723 "complex_attr"(){bar = dense<(1,1)> : tensor<complex<i64>>} : () -> ()
724 // CHECK: dense<[(1,1), (2,2)]> : tensor<2xcomplex<i64>>
725 "complex_attr"(){bar = dense<[(1,1), (2,2)]> : tensor<2xcomplex<i64>>} : () -> ()
726 // CHECK: dense<(1.000000e+00,0.000000e+00)> : tensor<complex<f32>>
727 "complex_attr"(){bar = dense<(1.000000e+00,0.000000e+00)> : tensor<complex<f32>>} : () -> ()
728 // CHECK: dense<[(1.000000e+00,0.000000e+00), (2.000000e+00,2.000000e+00)]> : tensor<2xcomplex<f32>>
729 "complex_attr"(){bar = dense<[(1.000000e+00,0.000000e+00), (2.000000e+00,2.000000e+00)]> : tensor<2xcomplex<f32>>} : () -> ()
733 // CHECK-LABEL: func @densevectorattr
734 func.func @densevectorattr() -> () {
736 // NOTE: The {{\[\[}} syntax is because "[[" confuses FileCheck.
737 // CHECK: "fooi8"() {bar = dense<5> : vector<1x1x1xi8>} : () -> ()
738 "fooi8"(){bar = dense<[[[5]]]> : vector<1x1x1xi8>} : () -> ()
739 // CHECK: "fooi16"() {bar = dense<-5> : vector<1x1x1xi16>} : () -> ()
740 "fooi16"(){bar = dense<[[[-5]]]> : vector<1x1x1xi16>} : () -> ()
741 // CHECK: "foo32"() {bar = dense<5> : vector<1x1x1xi32>} : () -> ()
742 "foo32"(){bar = dense<[[[5]]]> : vector<1x1x1xi32>} : () -> ()
743 // CHECK: "fooi64"() {bar = dense<-5> : vector<1x1x1xi64>} : () -> ()
744 "fooi64"(){bar = dense<[[[-5]]]> : vector<1x1x1xi64>} : () -> ()
746 // CHECK: "foo3"() {bar = dense<{{\[\[\[}}5, -6, 1, 2]], {{\[\[}}7, 8, 3, 4]]]> : vector<2x1x4xi32>} : () -> ()
747 "foo3"(){bar = dense<[[[5, -6, 1, 2]], [[7, 8, 3, 4]]]> : vector<2x1x4xi32>} : () -> ()
749 // CHECK: "float1"() {bar = dense<5.000000e+00> : vector<1x1x1xf32>} : () -> ()
750 "float1"(){bar = dense<[[[5.0]]]> : vector<1x1x1xf32>} : () -> ()
752 // CHECK: "bfloat16"() {bar = dense<{{\[\[\[}}-5.000000e+00, 6.000000e+00, 1.000000e+00, 2.000000e+00]], {{\[\[}}7.000000e+00, -8.000000e+00, 3.000000e+00, 4.000000e+00]]]> : vector<2x1x4xbf16>} : () -> ()
753 "bfloat16"(){bar = dense<[[[-5.0, 6.0, 1.0, 2.0]], [[7.0, -8.0, 3.0, 4.0]]]> : vector<2x1x4xbf16>} : () -> ()
754 // CHECK: "float16"() {bar = dense<{{\[\[\[}}-5.000000e+00, 6.000000e+00, 1.000000e+00, 2.000000e+00]], {{\[\[}}7.000000e+00, -8.000000e+00, 3.000000e+00, 4.000000e+00]]]> : vector<2x1x4xf16>} : () -> ()
755 "float16"(){bar = dense<[[[-5.0, 6.0, 1.0, 2.0]], [[7.0, -8.0, 3.0, 4.0]]]> : vector<2x1x4xf16>} : () -> ()
756 // CHECK: "float32"() {bar = dense<{{\[\[\[}}-5.000000e+00, 6.000000e+00, 1.000000e+00, 2.000000e+00]], {{\[\[}}7.000000e+00, -8.000000e+00, 3.000000e+00, 4.000000e+00]]]> : vector<2x1x4xf32>} : () -> ()
757 "float32"(){bar = dense<[[[-5.0, 6.0, 1.0, 2.0]], [[7.0, -8.0, 3.0, 4.0]]]> : vector<2x1x4xf32>} : () -> ()
758 // CHECK: "float64"() {bar = dense<{{\[\[\[}}-5.000000e+00, 6.000000e+00, 1.000000e+00, 2.000000e+00]], {{\[\[}}7.000000e+00, -8.000000e+00, 3.000000e+00, 4.000000e+00]]]> : vector<2x1x4xf64>} : () -> ()
759 "float64"(){bar = dense<[[[-5.0, 6.0, 1.0, 2.0]], [[7.0, -8.0, 3.0, 4.0]]]> : vector<2x1x4xf64>} : () -> ()
763 // CHECK-LABEL: func @sparsetensorattr
764 func.func @sparsetensorattr() -> () {
766 // NOTE: The {{\[\[}} syntax is because "[[" confuses FileCheck.
767 // CHECK: "fooi8"() {bar = sparse<0, -2> : tensor<1x1x1xi8>} : () -> ()
768 "fooi8"(){bar = sparse<0, -2> : tensor<1x1x1xi8>} : () -> ()
769 // CHECK: "fooi16"() {bar = sparse<{{\[\[}}1, 1, 0], {{\[}}0, 1, 0], {{\[}}0, 0, 1]], {{\[}}2, -1, 5]> : tensor<2x2x2xi16>} : () -> ()
770 "fooi16"(){bar = sparse<[[1, 1, 0], [0, 1, 0], [0, 0, 1]], [2, -1, 5]> : tensor<2x2x2xi16>} : () -> ()
771 // CHECK: "fooi32"() {bar = sparse<> : tensor<1x1xi32>} : () -> ()
772 "fooi32"(){bar = sparse<> : tensor<1x1xi32>} : () -> ()
773 // CHECK: "fooi64"() {bar = sparse<0, -1> : tensor<1xi64>} : () -> ()
774 "fooi64"(){bar = sparse<[0], [-1]> : tensor<1xi64>} : () -> ()
775 // CHECK: "foo2"() {bar = sparse<> : tensor<0xi32>} : () -> ()
776 "foo2"(){bar = sparse<> : tensor<0xi32>} : () -> ()
777 // CHECK: "foo3"() {bar = sparse<> : tensor<i32>} : () -> ()
778 "foo3"(){bar = sparse<> : tensor<i32>} : () -> ()
780 // CHECK: "foof16"() {bar = sparse<0, -2.000000e+00> : tensor<1x1x1xf16>} : () -> ()
781 "foof16"(){bar = sparse<0, -2.0> : tensor<1x1x1xf16>} : () -> ()
782 // CHECK: "foobf16"() {bar = sparse<{{\[\[}}1, 1, 0], {{\[}}0, 1, 0], {{\[}}0, 0, 1]], {{\[}}2.000000e+00, -1.000000e+00, 5.000000e+00]> : tensor<2x2x2xbf16>} : () -> ()
783 "foobf16"(){bar = sparse<[[1, 1, 0], [0, 1, 0], [0, 0, 1]], [2.0, -1.0, 5.0]> : tensor<2x2x2xbf16>} : () -> ()
784 // CHECK: "foof32"() {bar = sparse<> : tensor<1x0x1xf32>} : () -> ()
785 "foof32"(){bar = sparse<> : tensor<1x0x1xf32>} : () -> ()
786 // CHECK: "foof64"() {bar = sparse<0, -1.000000e+00> : tensor<1xf64>} : () -> ()
787 "foof64"(){bar = sparse<[[0]], [-1.0]> : tensor<1xf64>} : () -> ()
788 // CHECK: "foof320"() {bar = sparse<> : tensor<0xf32>} : () -> ()
789 "foof320"(){bar = sparse<> : tensor<0xf32>} : () -> ()
790 // CHECK: "foof321"() {bar = sparse<> : tensor<f32>} : () -> ()
791 "foof321"(){bar = sparse<> : tensor<f32>} : () -> ()
793 // CHECK: "foostr"() {bar = sparse<0, "foo"> : tensor<1x1x1x!unknown<>>} : () -> ()
794 "foostr"(){bar = sparse<0, "foo"> : tensor<1x1x1x!unknown<>>} : () -> ()
795 // CHECK: "foostr"() {bar = sparse<{{\[\[}}1, 1, 0], {{\[}}0, 1, 0], {{\[}}0, 0, 1]], {{\[}}"a", "b", "c"]> : tensor<2x2x2x!unknown<>>} : () -> ()
796 "foostr"(){bar = sparse<[[1, 1, 0], [0, 1, 0], [0, 0, 1]], ["a", "b", "c"]> : tensor<2x2x2x!unknown<>>} : () -> ()
800 // CHECK-LABEL: func @sparsevectorattr
801 func.func @sparsevectorattr() -> () {
803 // NOTE: The {{\[\[}} syntax is because "[[" confuses FileCheck.
804 // CHECK: "fooi8"() {bar = sparse<0, -2> : vector<1x1x1xi8>} : () -> ()
805 "fooi8"(){bar = sparse<0, -2> : vector<1x1x1xi8>} : () -> ()
806 // CHECK: "fooi16"() {bar = sparse<{{\[\[}}1, 1, 0], {{\[}}0, 1, 0], {{\[}}0, 0, 1]], {{\[}}2, -1, 5]> : vector<2x2x2xi16>} : () -> ()
807 "fooi16"(){bar = sparse<[[1, 1, 0], [0, 1, 0], [0, 0, 1]], [2, -1, 5]> : vector<2x2x2xi16>} : () -> ()
808 // CHECK: "fooi32"() {bar = sparse<> : vector<1x1xi32>} : () -> ()
809 "fooi32"(){bar = sparse<> : vector<1x1xi32>} : () -> ()
810 // CHECK: "fooi64"() {bar = sparse<0, -1> : vector<1xi64>} : () -> ()
811 "fooi64"(){bar = sparse<[[0]], [-1]> : vector<1xi64>} : () -> ()
813 // CHECK: "foof16"() {bar = sparse<0, -2.000000e+00> : vector<1x1x1xf16>} : () -> ()
814 "foof16"(){bar = sparse<0, -2.0> : vector<1x1x1xf16>} : () -> ()
815 // CHECK: "foobf16"() {bar = sparse<{{\[\[}}1, 1, 0], {{\[}}0, 1, 0], {{\[}}0, 0, 1]], {{\[}}2.000000e+00, -1.000000e+00, 5.000000e+00]> : vector<2x2x2xbf16>} : () -> ()
816 "foobf16"(){bar = sparse<[[1, 1, 0], [0, 1, 0], [0, 0, 1]], [2.0, -1.0, 5.0]> : vector<2x2x2xbf16>} : () -> ()
817 // CHECK: "foof64"() {bar = sparse<0, -1.000000e+00> : vector<1xf64>} : () -> ()
818 "foof64"(){bar = sparse<0, [-1.0]> : vector<1xf64>} : () -> ()
822 // CHECK-LABEL: func @unknown_dialect_type() -> !bar<> {
823 func.func @unknown_dialect_type() -> !bar<> {
824 // Unregistered dialect 'bar'.
825 // CHECK: "foo"() : () -> !bar<>
826 %0 = "foo"() : () -> !bar<>
828 // CHECK: "foo"() : () -> !bar.baz
829 %1 = "foo"() : () -> !bar<baz>
834 // CHECK-LABEL: func @type_alias() -> i32 {
835 !i32_type_alias = i32
836 func.func @type_alias() -> !i32_type_alias {
838 // Return a non-aliased i32 type.
839 %0 = "foo"() : () -> i32
843 // CHECK-LABEL: func @no_integer_set_constraints(
844 func.func @no_integer_set_constraints() {
845 // CHECK: affine.if [[$SET_TRUE]]() {
846 affine.if affine_set<() : ()> () {
851 // CHECK-LABEL: func @verbose_if(
852 func.func @verbose_if(%N: index) {
853 %c = arith.constant 200 : index
855 // CHECK: affine.if #set{{.*}}(%{{.*}})[%{{.*}}, %{{.*}}] {
856 "affine.if"(%c, %N, %c) ({
858 %y = "add"(%c, %N) : (index, index) -> index
859 "affine.yield"() : () -> ()
860 // CHECK-NEXT: } else {
861 }, { // The else region.
863 %z = "add"(%c, %c) : (index, index) -> index
864 "affine.yield"() : () -> ()
866 { condition = #set0 } : (index, index, index) -> ()
870 // CHECK-LABEL: func @terminator_with_regions
871 func.func @terminator_with_regions() {
872 // Combine successors and regions in the same operation.
873 // CHECK: "region"()[^bb1] ({
874 // CHECK: }) : () -> ()
875 "region"()[^bb2] ({}) : () -> ()
880 // CHECK-LABEL: func @unregistered_term
881 func.func @unregistered_term(%arg0 : i1) -> i1 {
882 // CHECK-NEXT: "unregistered_br"(%{{.*}})[^bb1] : (i1) -> ()
883 "unregistered_br"(%arg0)[^bb1] : (i1) -> ()
889 // CHECK-LABEL: func @dialect_attrs
890 func.func @dialect_attrs()
891 // CHECK: attributes {dialect.attr = 10
892 attributes {dialect.attr = 10} {
896 // CHECK-LABEL: func private @_valid.function$name
897 func.func private @_valid.function$name()
899 // CHECK-LABEL: func private @external_func_arg_attrs(i32, i1 {dialect.attr = 10 : i64}, i32)
900 func.func private @external_func_arg_attrs(i32, i1 {dialect.attr = 10 : i64}, i32)
902 // CHECK-LABEL: func @func_arg_attrs(%{{.*}}: i1 {dialect.attr = 10 : i64})
903 func.func @func_arg_attrs(%arg0: i1 {dialect.attr = 10 : i64}) {
907 // CHECK-LABEL: func @func_result_attrs({{.*}}) -> (f32 {dialect.attr = 1 : i64})
908 func.func @func_result_attrs(%arg0: f32) -> (f32 {dialect.attr = 1}) {
912 // CHECK-LABEL: func private @empty_tuple(tuple<>)
913 func.func private @empty_tuple(tuple<>)
915 // CHECK-LABEL: func private @tuple_single_element(tuple<i32>)
916 func.func private @tuple_single_element(tuple<i32>)
918 // CHECK-LABEL: func private @tuple_multi_element(tuple<i32, i16, f32>)
919 func.func private @tuple_multi_element(tuple<i32, i16, f32>)
921 // CHECK-LABEL: func private @tuple_nested(tuple<tuple<tuple<i32>>>)
922 func.func private @tuple_nested(tuple<tuple<tuple<i32>>>)
924 // CHECK-LABEL: func @pretty_form_multi_result
925 func.func @pretty_form_multi_result() -> (i16, i16) {
926 // CHECK: %{{.*}}:2 = "foo_div"() : () -> (i16, i16)
927 %quot, %rem = "foo_div"() : () -> (i16, i16)
928 return %quot, %rem : i16, i16
931 // CHECK-LABEL: func @pretty_form_multi_result_groups
932 func.func @pretty_form_multi_result_groups() -> (i16, i16, i16, i16, i16) {
933 // CHECK: %[[RES:.*]]:5 =
934 // CHECK: return %[[RES]]#0, %[[RES]]#1, %[[RES]]#2, %[[RES]]#3, %[[RES]]#4
935 %group_1:2, %group_2, %group_3:2 = "foo_test"() : () -> (i16, i16, i16, i16, i16)
936 return %group_1#0, %group_1#1, %group_2, %group_3#0, %group_3#1 : i16, i16, i16, i16, i16
939 // CHECK-LABEL: func @pretty_dialect_attribute()
940 func.func @pretty_dialect_attribute() {
941 // CHECK: "foo.unknown_op"() {foo = #foo.simple_attr} : () -> ()
942 "foo.unknown_op"() {foo = #foo.simple_attr} : () -> ()
944 // CHECK: "foo.unknown_op"() {foo = #foo.complexattr<abcd>} : () -> ()
945 "foo.unknown_op"() {foo = #foo.complexattr<abcd>} : () -> ()
947 // CHECK: "foo.unknown_op"() {foo = #foo.complexattr<abcd<f32>>} : () -> ()
948 "foo.unknown_op"() {foo = #foo.complexattr<abcd<f32>>} : () -> ()
950 // CHECK: "foo.unknown_op"() {foo = #foo.complexattr<abcd<[f]$$[32]>>} : () -> ()
951 "foo.unknown_op"() {foo = #foo.complexattr<abcd<[f]$$[32]>>} : () -> ()
953 // CHECK: "foo.unknown_op"() {foo = #foo.dialect<!x@#!@#>} : () -> ()
954 "foo.unknown_op"() {foo = #foo.dialect<!x@#!@#>} : () -> ()
959 // CHECK-LABEL: func @pretty_dialect_type()
960 func.func @pretty_dialect_type() {
962 // CHECK: %{{.*}} = "foo.unknown_op"() : () -> !foo.simpletype
963 %0 = "foo.unknown_op"() : () -> !foo.simpletype
965 // CHECK: %{{.*}} = "foo.unknown_op"() : () -> !foo.complextype<abcd>
966 %1 = "foo.unknown_op"() : () -> !foo.complextype<abcd>
968 // CHECK: %{{.*}} = "foo.unknown_op"() : () -> !foo.complextype<abcd<f32>>
969 %2 = "foo.unknown_op"() : () -> !foo.complextype<abcd<f32>>
971 // CHECK: %{{.*}} = "foo.unknown_op"() : () -> !foo.complextype<abcd<[f]$$[32]>>
972 %3 = "foo.unknown_op"() : () -> !foo.complextype<abcd<[f]$$[32]>>
974 // CHECK: %{{.*}} = "foo.unknown_op"() : () -> !foo.dialect<!x@#!@#>
975 %4 = "foo.unknown_op"() : () -> !foo.dialect<!x@#!@#>
980 // CHECK-LABEL: func @none_type
981 func.func @none_type() {
982 // CHECK: "foo.unknown_op"() : () -> none
983 %none_val = "foo.unknown_op"() : () -> none
987 // CHECK-LABEL: func @scoped_names
988 func.func @scoped_names() {
989 // CHECK-NEXT: "foo.region_op"
991 // CHECK-NEXT: "foo.unknown_op"
992 %scoped_name = "foo.unknown_op"() : () -> none
993 "foo.terminator"() : () -> ()
995 // CHECK: "foo.unknown_op"
996 %scoped_name = "foo.unknown_op"() : () -> none
997 "foo.terminator"() : () -> ()
1002 // CHECK-LABEL: func @dialect_attribute_with_type
1003 func.func @dialect_attribute_with_type() {
1004 // CHECK-NEXT: foo = #foo.attr : i32
1005 "foo.unknown_op"() {foo = #foo.attr : i32} : () -> ()
1008 // CHECK-LABEL: @f16_special_values
1009 func.func @f16_special_values() {
1011 // CHECK: arith.constant 0x7C01 : f16
1012 %0 = arith.constant 0x7C01 : f16
1013 // CHECK: arith.constant 0x7FFF : f16
1014 %1 = arith.constant 0x7FFF : f16
1015 // CHECK: arith.constant 0xFFFF : f16
1016 %2 = arith.constant 0xFFFF : f16
1018 // F16 positive infinity.
1019 // CHECK: arith.constant 0x7C00 : f16
1020 %3 = arith.constant 0x7C00 : f16
1021 // F16 negative infinity.
1022 // CHECK: arith.constant 0xFC00 : f16
1023 %4 = arith.constant 0xFC00 : f16
1028 // CHECK-LABEL: @f32_special_values
1029 func.func @f32_special_values() {
1030 // F32 signaling NaNs.
1031 // CHECK: arith.constant 0x7F800001 : f32
1032 %0 = arith.constant 0x7F800001 : f32
1033 // CHECK: arith.constant 0x7FBFFFFF : f32
1034 %1 = arith.constant 0x7FBFFFFF : f32
1037 // CHECK: arith.constant 0x7FC00000 : f32
1038 %2 = arith.constant 0x7FC00000 : f32
1039 // CHECK: arith.constant 0xFFFFFFFF : f32
1040 %3 = arith.constant 0xFFFFFFFF : f32
1042 // F32 positive infinity.
1043 // CHECK: arith.constant 0x7F800000 : f32
1044 %4 = arith.constant 0x7F800000 : f32
1045 // F32 negative infinity.
1046 // CHECK: arith.constant 0xFF800000 : f32
1047 %5 = arith.constant 0xFF800000 : f32
1052 // CHECK-LABEL: @f64_special_values
1053 func.func @f64_special_values() {
1054 // F64 signaling NaNs.
1055 // CHECK: arith.constant 0x7FF0000000000001 : f64
1056 %0 = arith.constant 0x7FF0000000000001 : f64
1057 // CHECK: arith.constant 0x7FF8000000000000 : f64
1058 %1 = arith.constant 0x7FF8000000000000 : f64
1061 // CHECK: arith.constant 0x7FF0000001000000 : f64
1062 %2 = arith.constant 0x7FF0000001000000 : f64
1063 // CHECK: arith.constant 0xFFF0000001000000 : f64
1064 %3 = arith.constant 0xFFF0000001000000 : f64
1066 // F64 positive infinity.
1067 // CHECK: arith.constant 0x7FF0000000000000 : f64
1068 %4 = arith.constant 0x7FF0000000000000 : f64
1069 // F64 negative infinity.
1070 // CHECK: arith.constant 0xFFF0000000000000 : f64
1071 %5 = arith.constant 0xFFF0000000000000 : f64
1073 // Check that values that can't be represented with the default format, use
1075 // CHECK: arith.constant 0xC1CDC00000000000 : f64
1076 %6 = arith.constant 0xC1CDC00000000000 : f64
1081 // CHECK-LABEL: @bfloat16_special_values
1082 func.func @bfloat16_special_values() {
1083 // bfloat16 signaling NaNs.
1084 // CHECK: arith.constant 0x7F81 : bf16
1085 %0 = arith.constant 0x7F81 : bf16
1086 // CHECK: arith.constant 0xFF81 : bf16
1087 %1 = arith.constant 0xFF81 : bf16
1089 // bfloat16 quiet NaNs.
1090 // CHECK: arith.constant 0x7FC0 : bf16
1091 %2 = arith.constant 0x7FC0 : bf16
1092 // CHECK: arith.constant 0xFFC0 : bf16
1093 %3 = arith.constant 0xFFC0 : bf16
1095 // bfloat16 positive infinity.
1096 // CHECK: arith.constant 0x7F80 : bf16
1097 %4 = arith.constant 0x7F80 : bf16
1098 // bfloat16 negative infinity.
1099 // CHECK: arith.constant 0xFF80 : bf16
1100 %5 = arith.constant 0xFF80 : bf16
1105 // We want to print floats in exponential notation with 6 significant digits,
1106 // but it may lead to precision loss when parsing back, in which case we print
1107 // the decimal form instead.
1108 // CHECK-LABEL: @f32_potential_precision_loss()
1109 func.func @f32_potential_precision_loss() {
1110 // CHECK: arith.constant -1.23697901 : f32
1111 %0 = arith.constant -1.23697901 : f32
1115 // CHECK-LABEL: @special_float_values_in_tensors
1116 func.func @special_float_values_in_tensors() {
1117 // CHECK: dense<0xFFFFFFFF> : tensor<4x4xf32>
1118 "foo"(){bar = dense<0xFFFFFFFF> : tensor<4x4xf32>} : () -> ()
1119 // CHECK: dense<[{{\[}}0xFFFFFFFF, 0x7F800000], [0x7FBFFFFF, 0x7F800001]]> : tensor<2x2xf32>
1120 "foo"(){bar = dense<[[0xFFFFFFFF, 0x7F800000], [0x7FBFFFFF, 0x7F800001]]> : tensor<2x2xf32>} : () -> ()
1121 // CHECK: dense<[0xFFFFFFFF, 0.000000e+00]> : tensor<2xf32>
1122 "foo"(){bar = dense<[0xFFFFFFFF, 0.0]> : tensor<2xf32>} : () -> ()
1124 // CHECK: sparse<[{{\[}}1, 1, 0], [0, 1, 1]], [0xFFFFFFFF, 0x7F800001]>
1125 "foo"(){bar = sparse<[[1,1,0],[0,1,1]], [0xFFFFFFFF, 0x7F800001]> : tensor<2x2x2xf32>} : () -> ()
1128 // Test parsing of an op with multiple region arguments, and without a
1131 // CHECK-LABEL: func @op_with_region_args
1132 func.func @op_with_region_args() {
1133 // CHECK: "test.polyfor"() ({
1134 // CHECK-NEXT: ^bb{{.*}}(%{{.*}}: index, %{{.*}}: index, %{{.*}}: index):
1135 test.polyfor %i, %j, %k {
1141 // Test allowing different name scopes for regions isolated from above.
1143 // CHECK-LABEL: func @op_with_passthrough_region_args
1144 func.func @op_with_passthrough_region_args() {
1145 // CHECK: [[VAL:%.*]] = arith.constant
1146 %0 = arith.constant 10 : index
1148 // CHECK: test.isolated_region [[VAL]] {
1149 // CHECK-NEXT: "foo.consumer"([[VAL]]) : (index)
1151 test.isolated_region %0 {
1152 "foo.consumer"(%0) : (index) -> ()
1155 // CHECK: [[VAL:%.*]]:2 = "foo.op"
1156 %result:2 = "foo.op"() : () -> (index, index)
1158 // CHECK: test.isolated_region [[VAL]]#1 {
1159 // CHECK-NEXT: "foo.consumer"([[VAL]]#1) : (index)
1161 test.isolated_region %result#1 {
1162 "foo.consumer"(%result#1) : (index) -> ()
1168 // CHECK-LABEL: func private @ptr_to_function() -> !unreg.ptr<() -> ()>
1169 func.func private @ptr_to_function() -> !unreg.ptr<() -> ()>
1171 // CHECK-LABEL: func private @escaped_string_char(i1 {foo.value = "\0A"})
1172 func.func private @escaped_string_char(i1 {foo.value = "\n"})
1174 // CHECK-LABEL: func @parse_integer_literal_test
1175 func.func @parse_integer_literal_test() {
1176 // CHECK: test.parse_integer_literal : 5
1177 test.parse_integer_literal : 5
1181 // CHECK-LABEL: func @parse_wrapped_keyword_test
1182 func.func @parse_wrapped_keyword_test() {
1183 // CHECK: test.parse_wrapped_keyword foo.keyword
1184 test.parse_wrapped_keyword foo.keyword
1188 // CHECK-LABEL: func @parse_base64_test
1189 func.func @parse_base64_test() {
1190 // CHECK: test.parse_b64 "hello world"
1191 test.parse_b64 "aGVsbG8gd29ybGQ="
1195 // CHECK-LABEL: func @"\22_string_symbol_reference\22"
1196 func.func @"\"_string_symbol_reference\""() {
1197 // CHECK: ref = @"\22_string_symbol_reference\22"
1198 "foo.symbol_reference"() {ref = @"\"_string_symbol_reference\""} : () -> ()
1202 // CHECK-LABEL: func private @parse_opaque_attr_escape
1203 func.func private @parse_opaque_attr_escape() {
1204 // CHECK: value = #foo<"\"escaped\\\n\"">
1205 "foo.constant"() {value = #foo<"\"escaped\\\n\"">} : () -> ()
1208 // CHECK-LABEL: func private @string_attr_name
1209 // CHECK-SAME: {"0 . 0", nested = {"0 . 0"}}
1210 func.func private @string_attr_name() attributes {"0 . 0", nested = {"0 . 0"}}
1212 // CHECK-LABEL: func private @nested_reference
1213 // CHECK: ref = @some_symbol::@some_nested_symbol
1214 func.func private @nested_reference() attributes {test.ref = @some_symbol::@some_nested_symbol }
1216 // CHECK-LABEL: func @custom_asm_names
1217 func.func @custom_asm_names() -> (i32, i32, i32, i32, i32, i32) {
1218 // CHECK: %[[FIRST:first.*]], %[[MIDDLE:middle_results.*]]:2, %[[LAST:[0-9]+]]
1219 %0, %1:2, %2 = "test.asm_interface_op"() : () -> (i32, i32, i32, i32)
1221 // CHECK: %[[FIRST_2:first.*]], %[[LAST_2:[0-9]+]]
1222 %3, %4 = "test.asm_interface_op"() : () -> (i32, i32)
1224 // CHECK: return %[[FIRST]], %[[MIDDLE]]#0, %[[MIDDLE]]#1, %[[LAST]], %[[FIRST_2]], %[[LAST_2]]
1225 return %0, %1#0, %1#1, %2, %3, %4 : i32, i32, i32, i32, i32, i32
1229 // CHECK-LABEL: func @pretty_names
1231 // This tests the behavior
1232 func.func @pretty_names() {
1233 // Simple case, should parse and print as %x being an implied 'name'
1235 %x = test.string_attr_pretty_name
1236 // CHECK: %x = test.string_attr_pretty_name
1237 // CHECK-NOT: attributes
1239 // This specifies an explicit name, which should override the result.
1240 %YY = test.string_attr_pretty_name attributes { names = ["y"] }
1241 // CHECK: %y = test.string_attr_pretty_name
1242 // CHECK-NOT: attributes
1244 // Conflicts with the 'y' name, so need an explicit attribute.
1245 %0 = "test.string_attr_pretty_name"() { names = ["y"]} : () -> i32
1246 // CHECK: %y_0 = test.string_attr_pretty_name attributes {names = ["y"]}
1248 // Name contains a space.
1249 %1 = "test.string_attr_pretty_name"() { names = ["space name"]} : () -> i32
1250 // CHECK: %space_name = test.string_attr_pretty_name attributes {names = ["space name"]}
1252 "unknown.use"(%x, %YY, %0, %1) : (i32, i32, i32, i32) -> ()
1254 // Multi-result support.
1256 %a, %b, %c = test.string_attr_pretty_name
1257 // CHECK: %a, %b, %c = test.string_attr_pretty_name
1258 // CHECK-NOT: attributes
1260 %q:3, %r = test.string_attr_pretty_name
1261 // CHECK: %q, %q_1, %q_2, %r = test.string_attr_pretty_name attributes {names = ["q", "q", "q", "r"]}
1268 // This tests the behavior of "default dialect":
1269 // operations like `test.default_dialect` can define a default dialect
1270 // used in nested region.
1271 // CHECK-LABEL: func @default_dialect
1272 func.func @default_dialect(%bool : i1) {
1273 test.default_dialect {
1274 // The test dialect is the default in this region, the following two
1275 // operations are parsed identically.
1276 // CHECK-NOT: test.parse_integer_literal
1277 parse_integer_literal : 5
1278 // CHECK: parse_integer_literal : 6
1279 test.parse_integer_literal : 6
1280 // Verify that only an op prefix is stripped, not an attribute value for
1282 // CHECK: "test.op_with_attr"() {test.attr = "test.value"} : () -> ()
1283 "test.op_with_attr"() {test.attr = "test.value"} : () -> ()
1284 // Verify that the prefix is not stripped when it can lead to ambiguity.
1285 // CHECK: test.op.with_dot_in_name
1286 test.op.with_dot_in_name
1287 // This is an unregistered operation, the printing/parsing is handled by the
1288 // dialect, and the dialect prefix should not be stripped while printing
1289 // because of potential ambiguity.
1290 // CHECK: test.dialect_custom_printer.with.dot
1291 test.dialect_custom_printer.with.dot
1292 "test.terminator"() : ()->()
1294 // The same operation outside of the region does not have an func. prefix.
1299 // CHECK-LABEL: func @unreachable_dominance_violation_ok
1300 func.func @unreachable_dominance_violation_ok() -> i1 {
1301 // CHECK: [[VAL:%.*]] = arith.constant false
1302 // CHECK: return [[VAL]] : i1
1303 // CHECK: ^bb1: // no predecessors
1304 // CHECK: [[VAL2:%.*]]:3 = "bar"([[VAL3:%.*]]) : (i64) -> (i1, i1, i1)
1305 // CHECK: cf.br ^bb3
1306 // CHECK: ^bb2: // pred: ^bb2
1307 // CHECK: cf.br ^bb2
1308 // CHECK: ^bb3: // pred: ^bb1
1309 // CHECK: [[VAL3]] = "foo"() : () -> i64
1310 // CHECK: return [[VAL2]]#1 : i1
1312 %c = arith.constant false
1315 // %1 is not dominated by it's definition, but block is not reachable.
1316 %2:3 = "bar"(%1) : (i64) -> (i1,i1,i1)
1321 %1 = "foo"() : ()->i64
1325 // CHECK-LABEL: func @graph_region_in_hierarchy_ok
1326 func.func @graph_region_in_hierarchy_ok() -> i64 {
1327 // CHECK: cf.br ^bb2
1329 // CHECK: test.graph_region {
1330 // CHECK: [[VAL2:%.*]]:3 = "bar"([[VAL3:%.*]]) : (i64) -> (i1, i1, i1)
1332 // CHECK: cf.br ^bb3
1333 // CHECK: ^bb2: // pred: ^bb0
1334 // CHECK: [[VAL3]] = "foo"() : () -> i64
1335 // CHECK: cf.br ^bb1
1336 // CHECK: ^bb3: // pred: ^bb1
1337 // CHECK: return [[VAL3]] : i64
1342 // %1 is well-defined here, since bb2 dominates bb1.
1343 %2:3 = "bar"(%1) : (i64) -> (i1,i1,i1)
1347 %1 = "foo"() : ()->i64
1353 // CHECK-LABEL: func @graph_region_kind
1354 func.func @graph_region_kind() -> () {
1355 // CHECK: [[VAL2:%.*]]:3 = "bar"([[VAL3:%.*]]) : (i64) -> (i1, i1, i1)
1356 // CHECK: [[VAL3]] = "baz"([[VAL2]]#0) : (i1) -> i64
1358 // %1 OK here in in graph region.
1359 %2:3 = "bar"(%1) : (i64) -> (i1,i1,i1)
1360 %1 = "baz"(%2#0) : (i1) -> (i64)
1365 // CHECK-LABEL: func @graph_region_inside_ssacfg_region
1366 func.func @graph_region_inside_ssacfg_region() -> () {
1367 // CHECK: "test.ssacfg_region"
1368 // CHECK: [[VAL3:%.*]] = "baz"() : () -> i64
1369 // CHECK: test.graph_region {
1370 // CHECK: [[VAL2:%.*]]:3 = "bar"([[VAL3]]) : (i64) -> (i1, i1, i1)
1372 // CHECK: [[VAL4:.*]] = "baz"() : () -> i64
1373 "test.ssacfg_region"() ({
1374 %1 = "baz"() : () -> (i64)
1376 %2:3 = "bar"(%1) : (i64) -> (i1,i1,i1)
1378 %3 = "baz"() : () -> (i64)
1383 // CHECK-LABEL: func @graph_region_in_graph_region_ok
1384 func.func @graph_region_in_graph_region_ok() -> () {
1385 // CHECK: test.graph_region {
1386 // CHECK: test.graph_region {
1387 // CHECK: [[VAL2:%.*]]:3 = "bar"([[VAL3:%.*]]) : (i64) -> (i1, i1, i1)
1389 // CHECK: [[VAL3]] = "foo"() : () -> i64
1393 // %1 is well-defined here since defined in graph region
1394 %2:3 = "bar"(%1) : (i64) -> (i1,i1,i1)
1396 %1 = "foo"() : ()->i64
1397 "test.terminator"() : ()->()
1402 // CHECK: test.graph_region {
1404 // CHECK: [[VAL1:%.*]] = "op1"([[VAL3:%.*]]) : (i32) -> i32
1405 // CHECK: [[VAL2:%.*]] = "test.ssacfg_region"([[VAL1]], [[VAL2]], [[VAL3]], [[VAL4:%.*]]) ({
1406 // CHECK: [[VAL5:%.*]] = "op2"([[VAL1]], [[VAL2]], [[VAL3]], [[VAL4]]) : (i32, i32, i32, i32) -> i32
1407 // CHECK: }) : (i32, i32, i32, i32) -> i32
1408 // CHECK: [[VAL3]] = "op2"([[VAL1]], [[VAL4]]) : (i32, i32) -> i32
1409 // CHECK: [[VAL4]] = "op3"([[VAL1]]) : (i32) -> i32
1410 %1 = "op1"(%3) : (i32) -> (i32)
1411 %2 = "test.ssacfg_region"(%1, %2, %3, %4) ({
1412 %5 = "op2"(%1, %2, %3, %4) :
1413 (i32, i32, i32, i32) -> (i32)
1414 }) : (i32, i32, i32, i32) -> (i32)
1415 %3 = "op2"(%1, %4) : (i32, i32) -> (i32)
1416 %4 = "op3"(%1) : (i32) -> (i32)
1419 // CHECK: "unregistered_func_might_have_graph_region"() ({
1420 // CHECK: [[VAL1:%.*]] = "foo"([[VAL1]], [[VAL2:%.*]]) : (i64, i64) -> i64
1421 // CHECK: [[VAL2]] = "bar"([[VAL1]])
1422 "unregistered_func_might_have_graph_region"() ({
1423 %1 = "foo"(%1, %2) : (i64, i64) -> i64
1424 %2 = "bar"(%1) : (i64) -> i64
1425 "unregistered_terminator"() : () -> ()
1426 }) {sym_name = "unregistered_op_dominance_violation_ok", function_type = () -> i1} : () -> ()
1428 // This is an unregister operation, the printing/parsing is handled by the dialect.
1429 // CHECK: test.dialect_custom_printer custom_format
1430 test.dialect_custom_printer custom_format
1432 // This is a registered operation with no custom parser and printer, and should
1433 // be handled by the dialect.
1434 // CHECK: test.dialect_custom_format_fallback custom_format_fallback
1435 test.dialect_custom_format_fallback custom_format_fallback
1437 // Check that an op with an optional result parses f80 as type.
1438 // CHECK: test.format_optional_result_d_op : f80
1439 test.format_optional_result_d_op : f80