1 // RUN: mlir-opt -allow-unregistered-dialect %s | FileCheck %s
2 // RUN: mlir-opt -allow-unregistered-dialect %s | mlir-opt -allow-unregistered-dialect | FileCheck %s
3 // RUN: mlir-opt -allow-unregistered-dialect -mlir-print-op-generic %s | FileCheck %s -check-prefix GENERIC
4 // RUN: mlir-opt -allow-unregistered-dialect %s | mlir-opt -allow-unregistered-dialect -mlir-print-op-generic | FileCheck %s -check-prefix GENERIC
6 // CHECK-DAG: #map{{[0-9]*}} = affine_map<(d0, d1, d2, d3, d4)[s0] -> (d0, d1, d2, d4, d3)>
7 #map = affine_map<(d0, d1, d2, d3, d4)[s0] -> (d0, d1, d2, d4, d3)>
9 // CHECK-DAG: #map{{[0-9]*}} = affine_map<(d0) -> (d0)>
10 #map1 = affine_map<(d0) -> (d0)>
12 // CHECK-DAG: #map{{[0-9]*}} = affine_map<(d0, d1, d2) -> (d0, d1, d2)>
13 #map2 = affine_map<(d0, d1, d2) -> (d0, d1, d2)>
15 // CHECK-DAG: #map{{[0-9]*}} = affine_map<(d0, d1, d2) -> (d1, d0, d2)>
16 #map3 = affine_map<(d0, d1, d2) -> (d1, d0, d2)>
18 // CHECK-DAG: #map{{[0-9]*}} = affine_map<()[s0] -> (0, s0 - 1)>
19 #inline_map_minmax_loop1 = affine_map<()[s0] -> (0, s0 - 1)>
21 // CHECK-DAG: #map{{[0-9]*}} = affine_map<()[s0] -> (100, s0 + 1)>
22 #inline_map_minmax_loop2 = affine_map<()[s0] -> (100, s0 + 1)>
24 // CHECK-DAG: #map{{[0-9]*}} = affine_map<(d0, d1)[s0] -> (d0 + d1 + s0)>
25 #bound_map1 = affine_map<(i, j)[s] -> (i + j + s)>
27 // CHECK-DAG: #map{{[0-9]*}} = affine_map<(d0, d1) -> (d0 + d1)>
28 #inline_map_loop_bounds2 = affine_map<(d0, d1) -> (d0 + d1)>
30 // CHECK-DAG: #map{{[0-9]*}} = affine_map<(d0)[s0] -> (d0 + s0, d0 - s0)>
31 #bound_map2 = affine_map<(i)[s] -> (i + s, i - s)>
33 // All maps appear in arbitrary order before all sets, in arbitrary order.
34 // CHECK-NOT: Placeholder
36 // CHECK-DAG: #set{{[0-9]*}} = affine_set<(d0)[s0, s1] : (d0 >= 0, -d0 + s0 >= 0, s0 - 5 == 0, -d0 + s1 + 1 >= 0)>
37 #set0 = affine_set<(i)[N, M] : (i >= 0, -i + N >= 0, N - 5 == 0, -i + M + 1 >= 0)>
39 // CHECK-DAG: #set{{[0-9]*}} = affine_set<(d0, d1)[s0] : (d0 >= 0, d1 >= 0)>
40 #set1 = affine_set<(d0, d1)[s0] : (d0 >= 0, d1 >= 0)>
42 // CHECK-DAG: #set{{[0-9]*}} = affine_set<(d0) : (d0 - 1 == 0)>
43 #set2 = affine_set<(d0) : (d0 - 1 == 0)>
45 // CHECK-DAG: [[$SET_TRUE:#set[0-9]+]] = affine_set<() : (0 == 0)>
47 // CHECK-DAG: #set{{[0-9]*}} = affine_set<(d0)[s0] : (d0 - 2 >= 0, -d0 + 4 >= 0)>
49 // CHECK: func private @foo(i32, i64) -> f32
50 func.func private @foo(i32, i64) -> f32
52 // CHECK: func private @bar()
53 func.func private @bar() -> ()
55 // CHECK: func private @baz() -> (i1, index, f32)
56 func.func private @baz() -> (i1, index, f32)
58 // CHECK: func private @missingReturn()
59 func.func private @missingReturn()
61 // CHECK: func private @int_types(i0, i1, i2, i4, i7, i87) -> (i1, index, i19)
62 func.func private @int_types(i0, i1, i2, i4, i7, i87) -> (i1, index, i19)
64 // CHECK: func private @sint_types(si2, si4) -> (si7, si1023)
65 func.func private @sint_types(si2, si4) -> (si7, si1023)
67 // CHECK: func private @uint_types(ui2, ui4) -> (ui7, ui1023)
68 func.func private @uint_types(ui2, ui4) -> (ui7, ui1023)
70 // CHECK: func private @float_types(f80, f128)
71 func.func private @float_types(f80, f128)
73 // CHECK: func private @vectors(vector<f32>, vector<1xf32>, vector<2x4xf32>)
74 func.func private @vectors(vector<f32>, vector<1 x f32>, vector<2x4xf32>)
76 // CHECK: func private @tensors(tensor<*xf32>, tensor<*xvector<2x4xf32>>, tensor<1x?x4x?x?xi32>, tensor<i8>)
77 func.func private @tensors(tensor<* x f32>, tensor<* x vector<2x4xf32>>,
78 tensor<1x?x4x?x?xi32>, tensor<i8>)
80 // CHECK: func private @tensor_encoding(tensor<16x32xf64, "sparse">)
81 func.func private @tensor_encoding(tensor<16x32xf64, "sparse">)
83 // CHECK: func private @large_shape_dimension(tensor<9223372036854775807xf32>)
84 func.func private @large_shape_dimension(tensor<9223372036854775807xf32>)
86 // CHECK: func private @functions((memref<1x?x4x?x?xi32, #map>, memref<8xi8>) -> (), () -> ())
87 func.func private @functions((memref<1x?x4x?x?xi32, #map, 0>, memref<8xi8, #map1, 0>) -> (), ()->())
89 // CHECK: func private @memrefs2(memref<2x4x8xi8, 1>)
90 func.func private @memrefs2(memref<2x4x8xi8, #map2, 1>)
92 // CHECK: func private @memrefs3(memref<2x4x8xi8>)
93 func.func private @memrefs3(memref<2x4x8xi8, affine_map<(d0, d1, d2) -> (d0, d1, d2)>>)
95 // CHECK: func private @memrefs_drop_triv_id_inline(memref<2xi8>)
96 func.func private @memrefs_drop_triv_id_inline(memref<2xi8, affine_map<(d0) -> (d0)>>)
98 // CHECK: func private @memrefs_drop_triv_id_inline0(memref<2xi8>)
99 func.func private @memrefs_drop_triv_id_inline0(memref<2xi8, affine_map<(d0) -> (d0)>, 0>)
101 // CHECK: func private @memrefs_drop_triv_id_inline1(memref<2xi8, 1>)
102 func.func private @memrefs_drop_triv_id_inline1(memref<2xi8, affine_map<(d0) -> (d0)>, 1>)
104 // Test memref with custom memory space
106 // CHECK: func private @memrefs_nomap_nospace(memref<5x6x7xf32>)
107 func.func private @memrefs_nomap_nospace(memref<5x6x7xf32>)
109 // CHECK: func private @memrefs_map_nospace(memref<5x6x7xf32, #map{{[0-9]*}}>)
110 func.func private @memrefs_map_nospace(memref<5x6x7xf32, #map3>)
112 // CHECK: func private @memrefs_nomap_intspace(memref<5x6x7xf32, 3>)
113 func.func private @memrefs_nomap_intspace(memref<5x6x7xf32, 3>)
115 // CHECK: func private @memrefs_map_intspace(memref<5x6x7xf32, #map{{[0-9]*}}, 5>)
116 func.func private @memrefs_map_intspace(memref<5x6x7xf32, #map3, 5>)
118 // CHECK: func private @memrefs_nomap_strspace(memref<5x6x7xf32, "local">)
119 func.func private @memrefs_nomap_strspace(memref<5x6x7xf32, "local">)
121 // CHECK: func private @memrefs_map_strspace(memref<5x6x7xf32, #map{{[0-9]*}}, "private">)
122 func.func private @memrefs_map_strspace(memref<5x6x7xf32, #map3, "private">)
124 // CHECK: func private @memrefs_nomap_dictspace(memref<5x6x7xf32, {memSpace = "special", subIndex = 1 : i64}>)
125 func.func private @memrefs_nomap_dictspace(memref<5x6x7xf32, {memSpace = "special", subIndex = 1}>)
127 // CHECK: func private @memrefs_map_dictspace(memref<5x6x7xf32, #map{{[0-9]*}}, {memSpace = "special", subIndex = 3 : i64}>)
128 func.func private @memrefs_map_dictspace(memref<5x6x7xf32, #map3, {memSpace = "special", subIndex = 3}>)
130 // CHECK: func private @complex_types(complex<i1>) -> complex<f32>
131 func.func private @complex_types(complex<i1>) -> complex<f32>
133 // CHECK: func private @memref_with_index_elems(memref<1x?xindex>)
134 func.func private @memref_with_index_elems(memref<1x?xindex>)
136 // CHECK: func private @memref_with_complex_elems(memref<1x?xcomplex<f32>>)
137 func.func private @memref_with_complex_elems(memref<1x?xcomplex<f32>>)
139 // CHECK: func private @memref_with_vector_elems(memref<1x?xvector<10xf32>>)
140 func.func private @memref_with_vector_elems(memref<1x?xvector<10xf32>>)
142 // CHECK: func private @memref_with_custom_elem(memref<1x?x!test.memref_element>)
143 func.func private @memref_with_custom_elem(memref<1x?x!test.memref_element>)
145 // CHECK: func private @memref_of_memref(memref<1xmemref<1xf64>>)
146 func.func private @memref_of_memref(memref<1xmemref<1xf64>>)
148 // CHECK: func private @memref_of_unranked_memref(memref<1xmemref<*xf32>>)
149 func.func private @memref_of_unranked_memref(memref<1xmemref<*xf32>>)
151 // CHECK: func private @unranked_memref_of_memref(memref<*xmemref<1xf32>>)
152 func.func private @unranked_memref_of_memref(memref<*xmemref<1xf32>>)
154 // CHECK: func private @unranked_memref_of_unranked_memref(memref<*xmemref<*xi32>>)
155 func.func private @unranked_memref_of_unranked_memref(memref<*xmemref<*xi32>>)
157 // CHECK: func private @unranked_memref_with_complex_elems(memref<*xcomplex<f32>>)
158 func.func private @unranked_memref_with_complex_elems(memref<*xcomplex<f32>>)
160 // CHECK: func private @unranked_memref_with_index_elems(memref<*xindex>)
161 func.func private @unranked_memref_with_index_elems(memref<*xindex>)
163 // CHECK: func private @unranked_memref_with_vector_elems(memref<*xvector<10xf32>>)
164 func.func private @unranked_memref_with_vector_elems(memref<*xvector<10xf32>>)
166 // CHECK-LABEL: func @simpleCFG(%{{.*}}: i32, %{{.*}}: f32) -> i1 {
167 func.func @simpleCFG(%arg0: i32, %f: f32) -> i1 {
168 // CHECK: %{{.*}} = "foo"() : () -> i64
169 %1 = "foo"() : ()->i64
170 // CHECK: "bar"(%{{.*}}) : (i64) -> (i1, i1, i1)
171 %2:3 = "bar"(%1) : (i64) -> (i1,i1,i1)
172 // CHECK: return %{{.*}}#1
177 // CHECK-LABEL: func @simpleCFGUsingBBArgs(%{{.*}}: i32, %{{.*}}: i64) {
178 func.func @simpleCFGUsingBBArgs(i32, i64) {
179 ^bb42 (%arg0: i32, %f: i64):
180 // CHECK: "bar"(%{{.*}}) : (i64) -> (i1, i1, i1)
181 %2:3 = "bar"(%f) : (i64) -> (i1,i1,i1)
182 // CHECK: return{{$}}
187 // CHECK-LABEL: func @block_label_empty_list
188 func.func @block_label_empty_list() {
193 // CHECK-LABEL: func @multiblock() {
194 func.func @multiblock() {
195 return // CHECK: return
196 ^bb1: // CHECK: ^bb1: // no predecessors
197 cf.br ^bb4 // CHECK: cf.br ^bb3
198 ^bb2: // CHECK: ^bb2: // pred: ^bb2
199 cf.br ^bb2 // CHECK: cf.br ^bb2
200 ^bb4: // CHECK: ^bb3: // pred: ^bb1
201 return // CHECK: return
204 // CHECK-LABEL: func @emptyMLF() {
205 func.func @emptyMLF() {
206 return // CHECK: return
209 // CHECK-LABEL: func @func_with_one_arg(%{{.*}}: i1) -> i2 {
210 func.func @func_with_one_arg(%c : i1) -> i2 {
211 // CHECK: %{{.*}} = "foo"(%{{.*}}) : (i1) -> i2
212 %b = "foo"(%c) : (i1) -> (i2)
213 return %b : i2 // CHECK: return %{{.*}} : i2
216 // CHECK-LABEL: func @func_with_two_args(%{{.*}}: f16, %{{.*}}: i8) -> (i1, i32) {
217 func.func @func_with_two_args(%a : f16, %b : i8) -> (i1, i32) {
218 // CHECK: %{{.*}}:2 = "foo"(%{{.*}}, %{{.*}}) : (f16, i8) -> (i1, i32)
219 %c:2 = "foo"(%a, %b) : (f16, i8)->(i1, i32)
220 return %c#0, %c#1 : i1, i32 // CHECK: return %{{.*}}#0, %{{.*}}#1 : i1, i32
223 // CHECK-LABEL: func @second_order_func() -> (() -> ()) {
224 func.func @second_order_func() -> (() -> ()) {
225 // CHECK-NEXT: %{{.*}} = constant @emptyMLF : () -> ()
226 %c = constant @emptyMLF : () -> ()
227 // CHECK-NEXT: return %{{.*}} : () -> ()
231 // CHECK-LABEL: func @third_order_func() -> (() -> (() -> ())) {
232 func.func @third_order_func() -> (() -> (() -> ())) {
233 // CHECK-NEXT: %{{.*}} = constant @second_order_func : () -> (() -> ())
234 %c = constant @second_order_func : () -> (() -> ())
235 // CHECK-NEXT: return %{{.*}} : () -> (() -> ())
236 return %c : () -> (() -> ())
239 // CHECK-LABEL: func @identity_functor(%{{.*}}: () -> ()) -> (() -> ()) {
240 func.func @identity_functor(%a : () -> ()) -> (() -> ()) {
241 // CHECK-NEXT: return %{{.*}} : () -> ()
245 // CHECK-LABEL: func @func_ops_in_loop() {
246 func.func @func_ops_in_loop() {
247 // CHECK: %{{.*}} = "foo"() : () -> i64
248 %a = "foo"() : ()->i64
249 // CHECK: affine.for %{{.*}} = 1 to 10 {
250 affine.for %i = 1 to 10 {
251 // CHECK: %{{.*}} = "doo"() : () -> f32
252 %b = "doo"() : ()->f32
253 // CHECK: "bar"(%{{.*}}, %{{.*}}) : (i64, f32) -> ()
254 "bar"(%a, %b) : (i64, f32) -> ()
263 // CHECK-LABEL: func @loops() {
265 // CHECK: affine.for %{{.*}} = 1 to 100 step 2 {
266 affine.for %i = 1 to 100 step 2 {
267 // CHECK: affine.for %{{.*}} = 1 to 200 {
268 affine.for %j = 1 to 200 {
271 return // CHECK: return
274 // CHECK-LABEL: func @complex_loops() {
275 func.func @complex_loops() {
276 affine.for %i1 = 1 to 100 { // CHECK: affine.for %{{.*}} = 1 to 100 {
277 affine.for %j1 = 1 to 100 { // CHECK: affine.for %{{.*}} = 1 to 100 {
278 // CHECK: "foo"(%{{.*}}, %{{.*}}) : (index, index) -> ()
279 "foo"(%i1, %j1) : (index,index) -> ()
281 "boo"() : () -> () // CHECK: "boo"() : () -> ()
282 affine.for %j2 = 1 to 10 { // CHECK: affine.for %{{.*}} = 1 to 10 {
283 affine.for %k2 = 1 to 10 { // CHECK: affine.for %{{.*}} = 1 to 10 {
284 "goo"() : () -> () // CHECK: "goo"() : () -> ()
288 return // CHECK: return
291 // CHECK: func @triang_loop(%{{.*}}: index, %{{.*}}: memref<?x?xi32>) {
292 func.func @triang_loop(%arg0: index, %arg1: memref<?x?xi32>) {
293 %c = arith.constant 0 : i32 // CHECK: %{{.*}} = arith.constant 0 : i32
294 affine.for %i0 = 1 to %arg0 { // CHECK: affine.for %{{.*}} = 1 to %{{.*}} {
295 affine.for %i1 = affine_map<(d0)[]->(d0)>(%i0)[] to %arg0 { // CHECK: affine.for %{{.*}} = #map{{[0-9]*}}(%{{.*}}) to %{{.*}} {
296 memref.store %c, %arg1[%i0, %i1] : memref<?x?xi32> // CHECK: memref.store %{{.*}}, %{{.*}}[%{{.*}}, %{{.*}}]
299 return // CHECK: return
302 // CHECK: func @minmax_loop(%{{.*}}: index, %{{.*}}: index, %{{.*}}: memref<100xf32>) {
303 func.func @minmax_loop(%arg0: index, %arg1: index, %arg2: memref<100xf32>) {
304 // CHECK: affine.for %{{.*}} = max #map{{.*}}()[%{{.*}}] to min #map{{.*}}()[%{{.*}}] {
305 affine.for %i0 = max affine_map<()[s]->(0,s-1)>()[%arg0] to min affine_map<()[s]->(100,s+1)>()[%arg1] {
306 // CHECK: "foo"(%{{.*}}, %{{.*}}) : (memref<100xf32>, index) -> ()
307 "foo"(%arg2, %i0) : (memref<100xf32>, index) -> ()
309 return // CHECK: return
312 // CHECK-LABEL: func @loop_bounds(%{{.*}}: index) {
313 func.func @loop_bounds(%N : index) {
314 // CHECK: %{{.*}} = "foo"(%{{.*}}) : (index) -> index
315 %s = "foo"(%N) : (index) -> index
316 // CHECK: affine.for %{{.*}} = %{{.*}} to %{{.*}}
317 affine.for %i = %s to %N {
318 // CHECK: affine.for %{{.*}} = #map{{[0-9]*}}(%{{.*}}) to 0
319 affine.for %j = affine_map<(d0)[]->(d0)>(%i)[] to 0 step 1 {
320 // CHECK: %{{.*}} = affine.apply #map{{.*}}(%{{.*}}, %{{.*}})[%{{.*}}]
321 %w1 = affine.apply affine_map<(d0, d1)[s0] -> (d0+d1)> (%i, %j) [%s]
322 // CHECK: %{{.*}} = affine.apply #map{{.*}}(%{{.*}}, %{{.*}})[%{{.*}}]
323 %w2 = affine.apply affine_map<(d0, d1)[s0] -> (s0+1)> (%i, %j) [%s]
324 // CHECK: affine.for %{{.*}} = #map{{.*}}(%{{.*}}, %{{.*}})[%{{.*}}] to #map{{.*}}(%{{.*}}, %{{.*}})[%{{.*}}] {
325 affine.for %k = #bound_map1 (%w1, %i)[%N] to affine_map<(i, j)[s] -> (i + j + s)> (%w2, %j)[%s] {
326 // CHECK: "foo"(%{{.*}}, %{{.*}}, %{{.*}}) : (index, index, index) -> ()
327 "foo"(%i, %j, %k) : (index, index, index)->()
328 // CHECK: %{{.*}} = arith.constant 30 : index
329 %c = arith.constant 30 : index
330 // CHECK: %{{.*}} = affine.apply #map{{.*}}(%{{.*}}, %{{.*}})
331 %u = affine.apply affine_map<(d0, d1)->(d0+d1)> (%N, %c)
332 // CHECK: affine.for %{{.*}} = max #map{{.*}}(%{{.*}})[%{{.*}}] to min #map{{.*}}(%{{.*}})[%{{.*}}] {
333 affine.for %l = max #bound_map2(%i)[%u] to min #bound_map2(%k)[%c] {
334 // CHECK: "bar"(%{{.*}}) : (index) -> ()
335 "bar"(%l) : (index) -> ()
340 return // CHECK: return
343 // CHECK-LABEL: func @ifinst(%{{.*}}: index) {
344 func.func @ifinst(%N: index) {
345 %c = arith.constant 200 : index // CHECK: %{{.*}} = arith.constant 200
346 affine.for %i = 1 to 10 { // CHECK: affine.for %{{.*}} = 1 to 10 {
347 affine.if #set0(%i)[%N, %c] { // CHECK: affine.if #set(%{{.*}})[%{{.*}}, %{{.*}}] {
348 %x = arith.constant 1 : i32
349 // CHECK: %{{.*}} = arith.constant 1 : i32
350 %y = "add"(%x, %i) : (i32, index) -> i32 // CHECK: %{{.*}} = "add"(%{{.*}}, %{{.*}}) : (i32, index) -> i32
351 %z = "mul"(%y, %y) : (i32, i32) -> i32 // CHECK: %{{.*}} = "mul"(%{{.*}}, %{{.*}}) : (i32, i32) -> i32
352 } else { // CHECK } else {
353 affine.if affine_set<(i)[N] : (i - 2 >= 0, 4 - i >= 0)>(%i)[%N] { // CHECK: affine.if #set1(%{{.*}})[%{{.*}}] {
354 // CHECK: %{{.*}} = arith.constant 1 : index
355 %u = arith.constant 1 : index
356 // CHECK: %{{.*}} = affine.apply #map{{.*}}(%{{.*}}, %{{.*}})[%{{.*}}]
357 %w = affine.apply affine_map<(d0,d1)[s0] -> (d0+d1+s0)> (%i, %i) [%u]
358 } else { // CHECK } else {
359 %v = arith.constant 3 : i32 // %c3_i32 = arith.constant 3 : i32
363 return // CHECK: return
366 // CHECK-LABEL: func @simple_ifinst(%{{.*}}: index) {
367 func.func @simple_ifinst(%N: index) {
368 %c = arith.constant 200 : index // CHECK: %{{.*}} = arith.constant 200
369 affine.for %i = 1 to 10 { // CHECK: affine.for %{{.*}} = 1 to 10 {
370 affine.if #set0(%i)[%N, %c] { // CHECK: affine.if #set(%{{.*}})[%{{.*}}, %{{.*}}] {
371 %x = arith.constant 1 : i32
372 // CHECK: %{{.*}} = arith.constant 1 : i32
373 %y = "add"(%x, %i) : (i32, index) -> i32 // CHECK: %{{.*}} = "add"(%{{.*}}, %{{.*}}) : (i32, index) -> i32
374 %z = "mul"(%y, %y) : (i32, i32) -> i32 // CHECK: %{{.*}} = "mul"(%{{.*}}, %{{.*}}) : (i32, i32) -> i32
377 return // CHECK: return
380 // CHECK-LABEL: func @attributes() {
381 func.func @attributes() {
385 // CHECK: "foo"() {a = 1 : i64, b = -423 : i64, c = [true, false], d = 1.600000e+01 : f64} : () -> ()
386 "foo"() {a = 1, b = -423, c = [true, false], d = 16.0 } : () -> ()
388 // CHECK: "foo"() {map1 = #map{{[0-9]*}}}
389 "foo"() {map1 = #map1} : () -> ()
391 // CHECK: "foo"() {map2 = #map{{[0-9]*}}}
392 "foo"() {map2 = affine_map<(d0, d1, d2) -> (d0, d1, d2)>} : () -> ()
394 // CHECK: "foo"() {map12 = [#map{{[0-9]*}}, #map{{[0-9]*}}]}
395 "foo"() {map12 = [#map1, #map2]} : () -> ()
397 // CHECK: "foo"() {set1 = #set{{[0-9]*}}}
398 "foo"() {set1 = #set1} : () -> ()
400 // CHECK: "foo"() {set2 = #set{{[0-9]*}}}
401 "foo"() {set2 = affine_set<(d0, d1, d2) : (d0 >= 0, d1 >= 0, d2 - d1 == 0)>} : () -> ()
403 // CHECK: "foo"() {set12 = [#set{{[0-9]*}}, #set{{[0-9]*}}]}
404 "foo"() {set12 = [#set1, #set2]} : () -> ()
406 // CHECK: "foo"() {dictionary = {bool = true, fn = @ifinst}}
407 "foo"() {dictionary = {bool = true, fn = @ifinst}} : () -> ()
409 // Check that the dictionary attribute elements are sorted.
410 // CHECK: "foo"() {dictionary = {bar = false, bool = true, fn = @ifinst}}
411 "foo"() {dictionary = {fn = @ifinst, bar = false, bool = true}} : () -> ()
413 // CHECK: "foo"() {d = 1.000000e-09 : f64, func = [], i123 = 7 : i64, if = "foo"} : () -> ()
414 "foo"() {if = "foo", func = [], i123 = 7, d = 1.e-9} : () -> ()
416 // CHECK: "foo"() {fn = @attributes, if = @ifinst} : () -> ()
417 "foo"() {fn = @attributes, if = @ifinst} : () -> ()
419 // CHECK: "foo"() {int = 0 : i42} : () -> ()
420 "foo"() {int = 0 : i42} : () -> ()
424 // CHECK-LABEL: func @ssa_values() -> (i16, i8) {
425 func.func @ssa_values() -> (i16, i8) {
426 // CHECK: %{{.*}}:2 = "foo"() : () -> (i1, i17)
427 %0:2 = "foo"() : () -> (i1, i17)
430 ^bb1: // CHECK: ^bb1: // pred: ^bb2
431 // CHECK: %{{.*}}:2 = "baz"(%{{.*}}#1, %{{.*}}#0, %{{.*}}#1) : (f32, i11, i17) -> (i16, i8)
432 %1:2 = "baz"(%2#1, %2#0, %0#1) : (f32, i11, i17) -> (i16, i8)
434 // CHECK: return %{{.*}}#0, %{{.*}}#1 : i16, i8
435 return %1#0, %1#1 : i16, i8
437 ^bb2: // CHECK: ^bb2: // pred: ^bb0
438 // CHECK: %{{.*}}:2 = "bar"(%{{.*}}#0, %{{.*}}#1) : (i1, i17) -> (i11, f32)
439 %2:2 = "bar"(%0#0, %0#1) : (i1, i17) -> (i11, f32)
443 // CHECK-LABEL: func @bbargs() -> (i16, i8) {
444 func.func @bbargs() -> (i16, i8) {
445 // CHECK: %{{.*}}:2 = "foo"() : () -> (i1, i17)
446 %0:2 = "foo"() : () -> (i1, i17)
447 cf.br ^bb1(%0#1, %0#0 : i17, i1)
449 ^bb1(%x: i17, %y: i1): // CHECK: ^bb1(%{{.*}}: i17, %{{.*}}: i1):
450 // CHECK: %{{.*}}:2 = "baz"(%{{.*}}, %{{.*}}, %{{.*}}#1) : (i17, i1, i17) -> (i16, i8)
451 %1:2 = "baz"(%x, %y, %0#1) : (i17, i1, i17) -> (i16, i8)
452 return %1#0, %1#1 : i16, i8
455 // CHECK-LABEL: func @verbose_terminators() -> (i1, i17)
456 func.func @verbose_terminators() -> (i1, i17) {
457 %0:2 = "foo"() : () -> (i1, i17)
458 // CHECK: cf.br ^bb1(%{{.*}}#0, %{{.*}}#1 : i1, i17)
459 "cf.br"(%0#0, %0#1)[^bb1] : (i1, i17) -> ()
461 ^bb1(%x : i1, %y : i17):
462 // CHECK: cf.cond_br %{{.*}}, ^bb2(%{{.*}} : i17), ^bb3(%{{.*}}, %{{.*}} : i1, i17)
463 "cf.cond_br"(%x, %y, %x, %y) [^bb2, ^bb3] {operandSegmentSizes = array<i32: 1, 1, 2>} : (i1, i17, i1, i17) -> ()
466 %true = arith.constant true
467 // CHECK: return %{{.*}}, %{{.*}} : i1, i17
468 "func.return"(%true, %a) : (i1, i17) -> ()
470 ^bb3(%b : i1, %c : i17):
471 // CHECK: return %{{.*}}, %{{.*}} : i1, i17
472 "func.return"(%b, %c) : (i1, i17) -> ()
475 // CHECK-LABEL: func @condbr_simple
476 func.func @condbr_simple() -> (i32) {
477 %cond = "foo"() : () -> i1
478 %a = "bar"() : () -> i32
479 %b = "bar"() : () -> i64
480 // CHECK: cf.cond_br %{{.*}}, ^bb1(%{{.*}} : i32), ^bb2(%{{.*}} : i64)
481 cf.cond_br %cond, ^bb1(%a : i32), ^bb2(%b : i64)
483 // CHECK: ^bb1({{.*}}: i32): // pred: ^bb0
487 // CHECK: ^bb2({{.*}}: i64): // 2 preds: ^bb0, ^bb1
489 %z = "foo"() : () -> i32
493 // CHECK-LABEL: func @condbr_moarargs
494 func.func @condbr_moarargs() -> (i32) {
495 %cond = "foo"() : () -> i1
496 %a = "bar"() : () -> i32
497 %b = "bar"() : () -> i64
498 // CHECK: cf.cond_br %{{.*}}, ^bb1(%{{.*}}, %{{.*}} : i32, i64), ^bb2(%{{.*}}, %{{.*}}, %{{.*}} : i64, i32, i32)
499 cf.cond_br %cond, ^bb1(%a, %b : i32, i64), ^bb2(%b, %a, %a : i64, i32, i32)
501 ^bb1(%x : i32, %y : i64):
504 ^bb2(%x2 : i64, %y2 : i32, %z2 : i32):
505 %z = "foo"() : () -> i32
510 // Test pretty printing of constant names.
511 // CHECK-LABEL: func @constants
512 func.func @constants() -> (i32, i23, i23, i1, i1) {
513 // CHECK: %{{.*}} = arith.constant 42 : i32
514 %x = arith.constant 42 : i32
515 // CHECK: %{{.*}} = arith.constant 17 : i23
516 %y = arith.constant 17 : i23
518 // This is a redundant definition of 17, the asmprinter gives it a unique name
519 // CHECK: %{{.*}} = arith.constant 17 : i23
520 %z = arith.constant 17 : i23
522 // CHECK: %{{.*}} = arith.constant true
523 %t = arith.constant true
524 // CHECK: %{{.*}} = arith.constant false
525 %f = arith.constant false
527 // The trick to parse type declarations should not interfere with hex
529 // CHECK: %{{.*}} = arith.constant 3890 : i32
530 %h = arith.constant 0xf32 : i32
532 // CHECK: return %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}
533 return %x, %y, %z, %t, %f : i32, i23, i23, i1, i1
536 // CHECK-LABEL: func @typeattr
537 func.func @typeattr() -> () {
539 // CHECK: "foo"() {bar = tensor<*xf32>} : () -> ()
540 "foo"(){bar = tensor<*xf32>} : () -> ()
544 // CHECK-LABEL: func @stringquote
545 func.func @stringquote() -> () {
547 // CHECK: "foo"() {bar = "a\22quoted\22string"} : () -> ()
548 "foo"(){bar = "a\"quoted\"string"} : () -> ()
550 // CHECK-NEXT: "typed_string" : !foo.string
551 "foo"(){bar = "typed_string" : !foo.string} : () -> ()
555 // CHECK-LABEL: func @unitAttrs
556 func.func @unitAttrs() -> () {
557 // CHECK-NEXT: "foo"() {unitAttr}
558 "foo"() {unitAttr = unit} : () -> ()
560 // CHECK-NEXT: "foo"() {unitAttr}
561 "foo"() {unitAttr} : () -> ()
563 // CHECK-NEXT: "foo"() {nested = {unitAttr}}
564 "foo"() {nested = {unitAttr}} : () -> ()
568 // CHECK-LABEL: func @floatAttrs
569 func.func @floatAttrs() -> () {
571 // CHECK: "foo"() {a = 4.000000e+00 : f64, b = 2.000000e+00 : f64, c = 7.100000e+00 : f64, d = -0.000000e+00 : f64} : () -> ()
572 "foo"(){a = 4.0, b = 2.0, c = 7.1, d = -0.0} : () -> ()
576 // CHECK-LABEL: func private @externalfuncattr
577 func.func private @externalfuncattr() -> ()
578 // CHECK: attributes {dialect.a = "a\22quoted\22string", dialect.b = 4.000000e+00 : f64, dialect.c = tensor<*xf32>}
579 attributes {dialect.a = "a\"quoted\"string", dialect.b = 4.0, dialect.c = tensor<*xf32>}
581 // CHECK-LABEL: func private @funcattrempty
582 func.func private @funcattrempty() -> ()
585 // CHECK-LABEL: func private @funcattr
586 func.func private @funcattr() -> ()
587 // CHECK: attributes {dialect.a = "a\22quoted\22string", dialect.b = 4.000000e+00 : f64, dialect.c = tensor<*xf32>}
588 attributes {dialect.a = "a\"quoted\"string", dialect.b = 4.0, dialect.c = tensor<*xf32>} {
593 // CHECK-LABEL: func @funcattrwithblock
594 func.func @funcattrwithblock() -> ()
600 // CHECK-LABEL: func @funcsimplemap
601 #map_simple0 = affine_map<()[] -> (10)>
602 #map_simple1 = affine_map<()[s0] -> (s0)>
603 #map_non_simple0 = affine_map<(d0)[] -> (d0)>
604 #map_non_simple1 = affine_map<(d0)[s0] -> (d0 + s0)>
605 #map_non_simple2 = affine_map<()[s0, s1] -> (s0 + s1)>
606 #map_non_simple3 = affine_map<()[s0] -> (s0 + 3)>
607 func.func @funcsimplemap(%arg0: index, %arg1: index) -> () {
608 affine.for %i0 = 0 to #map_simple0()[] {
609 // CHECK: affine.for %{{.*}} = 0 to 10 {
610 affine.for %i1 = 0 to #map_simple1()[%arg1] {
611 // CHECK: affine.for %{{.*}} = 0 to %{{.*}} {
612 affine.for %i2 = 0 to #map_non_simple0(%i0)[] {
613 // CHECK: affine.for %{{.*}} = 0 to #map{{[a-z_0-9]*}}(%{{.*}}) {
614 affine.for %i3 = 0 to #map_non_simple1(%i0)[%arg1] {
615 // CHECK: affine.for %{{.*}} = 0 to #map{{[a-z_0-9]*}}(%{{.*}})[%{{.*}}] {
616 affine.for %i4 = 0 to #map_non_simple2()[%arg1, %arg0] {
617 // CHECK: affine.for %{{.*}} = 0 to #map{{[a-z_0-9]*}}()[%{{.*}}, %{{.*}}] {
618 affine.for %i5 = 0 to #map_non_simple3()[%arg0] {
619 // CHECK: affine.for %{{.*}} = 0 to #map{{[a-z_0-9]*}}()[%{{.*}}] {
620 %c42_i32 = arith.constant 42 : i32
630 // CHECK-LABEL: func @splattensorattr
631 func.func @splattensorattr() -> () {
633 // CHECK: "splatBoolTensor"() {bar = dense<false> : tensor<i1>} : () -> ()
634 "splatBoolTensor"(){bar = dense<false> : tensor<i1>} : () -> ()
636 // CHECK: "splatUIntTensor"() {bar = dense<222> : tensor<2x1x4xui8>} : () -> ()
637 "splatUIntTensor"(){bar = dense<222> : tensor<2x1x4xui8>} : () -> ()
639 // CHECK: "splatIntTensor"() {bar = dense<5> : tensor<2x1x4xi32>} : () -> ()
640 "splatIntTensor"(){bar = dense<5> : tensor<2x1x4xi32>} : () -> ()
642 // CHECK: "splatFloatTensor"() {bar = dense<-5.000000e+00> : tensor<2x1x4xf32>} : () -> ()
643 "splatFloatTensor"(){bar = dense<-5.0> : tensor<2x1x4xf32>} : () -> ()
645 // CHECK: "splatIntVector"() {bar = dense<5> : vector<2x1x4xi64>} : () -> ()
646 "splatIntVector"(){bar = dense<5> : vector<2x1x4xi64>} : () -> ()
648 // CHECK: "splatFloatVector"() {bar = dense<-5.000000e+00> : vector<2x1x4xf16>} : () -> ()
649 "splatFloatVector"(){bar = dense<-5.0> : vector<2x1x4xf16>} : () -> ()
651 // CHECK: "splatIntScalar"() {bar = dense<5> : tensor<i9>} : () -> ()
652 "splatIntScalar"() {bar = dense<5> : tensor<i9>} : () -> ()
653 // CHECK: "splatFloatScalar"() {bar = dense<-5.000000e+00> : tensor<f16>} : () -> ()
654 "splatFloatScalar"() {bar = dense<-5.0> : tensor<f16>} : () -> ()
658 // CHECK-LABEL: func @densetensorattr
659 func.func @densetensorattr() -> () {
662 // NOTE: The {{\[\[}} syntax is because "[[" confuses FileCheck.
663 // CHECK: "fooi3"() {bar = dense<{{\[\[\[}}1, -2, 1, 2]], {{\[\[}}0, 2, -1, 2]]]> : tensor<2x1x4xi3>} : () -> ()
664 "fooi3"(){bar = dense<[[[1, -2, 1, 2]], [[0, 2, -1, 2]]]> : tensor<2x1x4xi3>} : () -> ()
665 // CHECK: "fooi6"() {bar = dense<{{\[\[\[}}5, -6, 1, 2]], {{\[\[}}7, 8, 3, 4]]]> : tensor<2x1x4xi6>} : () -> ()
666 "fooi6"(){bar = dense<[[[5, -6, 1, 2]], [[7, 8, 3, 4]]]> : tensor<2x1x4xi6>} : () -> ()
667 // CHECK: "fooi8"() {bar = dense<5> : tensor<1x1x1xi8>} : () -> ()
668 "fooi8"(){bar = dense<[[[5]]]> : tensor<1x1x1xi8>} : () -> ()
669 // CHECK: "fooi13"() {bar = dense<{{\[\[\[}}1, -2, 1, 2]], {{\[\[}}0, 2, -1, 2]]]> : tensor<2x1x4xi13>} : () -> ()
670 "fooi13"(){bar = dense<[[[1, -2, 1, 2]], [[0, 2, -1, 2]]]> : tensor<2x1x4xi13>} : () -> ()
671 // CHECK: "fooi16"() {bar = dense<-5> : tensor<1x1x1xi16>} : () -> ()
672 "fooi16"(){bar = dense<[[[-5]]]> : tensor<1x1x1xi16>} : () -> ()
673 // CHECK: "fooi23"() {bar = dense<{{\[\[\[}}1, -2, 1, 2]], {{\[\[}}0, 2, -1, 2]]]> : tensor<2x1x4xi23>} : () -> ()
674 "fooi23"(){bar = dense<[[[1, -2, 1, 2]], [[0, 2, -1, 2]]]> : tensor<2x1x4xi23>} : () -> ()
675 // CHECK: "fooi32"() {bar = dense<5> : tensor<1x1x1xi32>} : () -> ()
676 "fooi32"(){bar = dense<[[[5]]]> : tensor<1x1x1xi32>} : () -> ()
677 // CHECK: "fooi33"() {bar = dense<{{\[\[\[}}1, -2, 1, 2]], {{\[\[}}0, 2, -1, 2]]]> : tensor<2x1x4xi33>} : () -> ()
678 "fooi33"(){bar = dense<[[[1, -2, 1, 2]], [[0, 2, -1, 2]]]> : tensor<2x1x4xi33>} : () -> ()
679 // CHECK: "fooi43"() {bar = dense<{{\[\[\[}}1, -2, 1, 2]], {{\[\[}}0, 2, -1, 2]]]> : tensor<2x1x4xi43>} : () -> ()
680 "fooi43"(){bar = dense<[[[1, -2, 1, 2]], [[0, 2, -1, 2]]]> : tensor<2x1x4xi43>} : () -> ()
681 // CHECK: "fooi53"() {bar = dense<{{\[\[\[}}1, -2, 1, 2]], {{\[\[}}0, 2, -1, 2]]]> : tensor<2x1x4xi53>} : () -> ()
682 "fooi53"(){bar = dense<[[[1, -2, 1, 2]], [[0, 2, -1, 2]]]> : tensor<2x1x4xi53>} : () -> ()
683 // CHECK: "fooi64"() {bar = dense<{{\[\[\[}}1, -2, 1, 2]], {{\[\[}}0, 3, -1, 2]]]> : tensor<2x1x4xi64>} : () -> ()
684 "fooi64"(){bar = dense<[[[1, -2, 1, 2]], [[0, 3, -1, 2]]]> : tensor<2x1x4xi64>} : () -> ()
685 // CHECK: "fooi64"() {bar = dense<-5> : tensor<1x1x1xi64>} : () -> ()
686 "fooi64"(){bar = dense<[[[-5]]]> : tensor<1x1x1xi64>} : () -> ()
687 // CHECK: "fooi67"() {bar = dense<{{\[\[\[}}-5, 4, 6, 2]]]> : vector<1x1x4xi67>} : () -> ()
688 "fooi67"(){bar = dense<[[[-5, 4, 6, 2]]]> : vector<1x1x4xi67>} : () -> ()
690 // CHECK: "foo2"() {bar = dense<> : tensor<0xi32>} : () -> ()
691 "foo2"(){bar = dense<> : tensor<0xi32>} : () -> ()
692 // CHECK: "foo2"() {bar = dense<> : tensor<1x0xi32>} : () -> ()
693 "foo2"(){bar = dense<> : tensor<1x0xi32>} : () -> ()
694 // CHECK: dense<> : tensor<0x512x512xi32>
695 "foo2"(){bar = dense<> : tensor<0x512x512xi32>} : () -> ()
696 // CHECK: "foo3"() {bar = dense<{{\[\[\[}}5, -6, 1, 2]], {{\[\[}}7, 8, 3, 4]]]> : tensor<2x1x4xi32>} : () -> ()
697 "foo3"(){bar = dense<[[[5, -6, 1, 2]], [[7, 8, 3, 4]]]> : tensor<2x1x4xi32>} : () -> ()
699 // CHECK: "float1"() {bar = dense<5.000000e+00> : tensor<1x1x1xf32>} : () -> ()
700 "float1"(){bar = dense<[[[5.0]]]> : tensor<1x1x1xf32>} : () -> ()
701 // CHECK: "float2"() {bar = dense<> : tensor<0xf32>} : () -> ()
702 "float2"(){bar = dense<> : tensor<0xf32>} : () -> ()
703 // CHECK: "float2"() {bar = dense<> : tensor<1x0xf32>} : () -> ()
704 "float2"(){bar = dense<> : tensor<1x0xf32>} : () -> ()
706 // 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>} : () -> ()
707 "bfloat16"(){bar = dense<[[[-5.0, 6.0, 1.0, 2.0]], [[7.0, -8.0, 3.0, 4.0]]]> : tensor<2x1x4xbf16>} : () -> ()
708 // 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>} : () -> ()
709 "float16"(){bar = dense<[[[-5.0, 6.0, 1.0, 2.0]], [[7.0, -8.0, 3.0, 4.0]]]> : tensor<2x1x4xf16>} : () -> ()
710 // 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>} : () -> ()
711 "float32"(){bar = dense<[[[-5.0, 6.0, 1.0, 2.0]], [[7.0, -8.0, 3.0, 4.0]]]> : tensor<2x1x4xf32>} : () -> ()
712 // 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>} : () -> ()
713 "float64"(){bar = dense<[[[-5.0, 6.0, 1.0, 2.0]], [[7.0, -8.0, 3.0, 4.0]]]> : tensor<2x1x4xf64>} : () -> ()
715 // CHECK: "intscalar"() {bar = dense<1> : tensor<i32>} : () -> ()
716 "intscalar"(){bar = dense<1> : tensor<i32>} : () -> ()
717 // CHECK: "floatscalar"() {bar = dense<5.000000e+00> : tensor<f32>} : () -> ()
718 "floatscalar"(){bar = dense<5.0> : tensor<f32>} : () -> ()
720 // CHECK: "index"() {bar = dense<1> : tensor<index>} : () -> ()
721 "index"(){bar = dense<1> : tensor<index>} : () -> ()
722 // CHECK: "index"() {bar = dense<[1, 2]> : tensor<2xindex>} : () -> ()
723 "index"(){bar = dense<[1, 2]> : tensor<2xindex>} : () -> ()
725 // CHECK: dense<(1,1)> : tensor<complex<i64>>
726 "complex_attr"(){bar = dense<(1,1)> : tensor<complex<i64>>} : () -> ()
727 // CHECK: dense<[(1,1), (2,2)]> : tensor<2xcomplex<i64>>
728 "complex_attr"(){bar = dense<[(1,1), (2,2)]> : tensor<2xcomplex<i64>>} : () -> ()
729 // CHECK: dense<(1.000000e+00,0.000000e+00)> : tensor<complex<f32>>
730 "complex_attr"(){bar = dense<(1.000000e+00,0.000000e+00)> : tensor<complex<f32>>} : () -> ()
731 // CHECK: dense<[(1.000000e+00,0.000000e+00), (2.000000e+00,2.000000e+00)]> : tensor<2xcomplex<f32>>
732 "complex_attr"(){bar = dense<[(1.000000e+00,0.000000e+00), (2.000000e+00,2.000000e+00)]> : tensor<2xcomplex<f32>>} : () -> ()
736 // CHECK-LABEL: func @densevectorattr
737 func.func @densevectorattr() -> () {
739 // NOTE: The {{\[\[}} syntax is because "[[" confuses FileCheck.
740 // CHECK: "fooi8"() {bar = dense<5> : vector<1x1x1xi8>} : () -> ()
741 "fooi8"(){bar = dense<[[[5]]]> : vector<1x1x1xi8>} : () -> ()
742 // CHECK: "fooi16"() {bar = dense<-5> : vector<1x1x1xi16>} : () -> ()
743 "fooi16"(){bar = dense<[[[-5]]]> : vector<1x1x1xi16>} : () -> ()
744 // CHECK: "foo32"() {bar = dense<5> : vector<1x1x1xi32>} : () -> ()
745 "foo32"(){bar = dense<[[[5]]]> : vector<1x1x1xi32>} : () -> ()
746 // CHECK: "fooi64"() {bar = dense<-5> : vector<1x1x1xi64>} : () -> ()
747 "fooi64"(){bar = dense<[[[-5]]]> : vector<1x1x1xi64>} : () -> ()
749 // CHECK: "foo3"() {bar = dense<{{\[\[\[}}5, -6, 1, 2]], {{\[\[}}7, 8, 3, 4]]]> : vector<2x1x4xi32>} : () -> ()
750 "foo3"(){bar = dense<[[[5, -6, 1, 2]], [[7, 8, 3, 4]]]> : vector<2x1x4xi32>} : () -> ()
752 // CHECK: "float1"() {bar = dense<5.000000e+00> : vector<1x1x1xf32>} : () -> ()
753 "float1"(){bar = dense<[[[5.0]]]> : vector<1x1x1xf32>} : () -> ()
755 // 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>} : () -> ()
756 "bfloat16"(){bar = dense<[[[-5.0, 6.0, 1.0, 2.0]], [[7.0, -8.0, 3.0, 4.0]]]> : vector<2x1x4xbf16>} : () -> ()
757 // 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>} : () -> ()
758 "float16"(){bar = dense<[[[-5.0, 6.0, 1.0, 2.0]], [[7.0, -8.0, 3.0, 4.0]]]> : vector<2x1x4xf16>} : () -> ()
759 // 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>} : () -> ()
760 "float32"(){bar = dense<[[[-5.0, 6.0, 1.0, 2.0]], [[7.0, -8.0, 3.0, 4.0]]]> : vector<2x1x4xf32>} : () -> ()
761 // 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>} : () -> ()
762 "float64"(){bar = dense<[[[-5.0, 6.0, 1.0, 2.0]], [[7.0, -8.0, 3.0, 4.0]]]> : vector<2x1x4xf64>} : () -> ()
766 // CHECK-LABEL: func @sparsetensorattr
767 func.func @sparsetensorattr() -> () {
769 // NOTE: The {{\[\[}} syntax is because "[[" confuses FileCheck.
770 // CHECK: "fooi8"() {bar = sparse<0, -2> : tensor<1x1x1xi8>} : () -> ()
771 "fooi8"(){bar = sparse<0, -2> : tensor<1x1x1xi8>} : () -> ()
772 // CHECK: "fooi16"() {bar = sparse<{{\[\[}}1, 1, 0], {{\[}}0, 1, 0], {{\[}}0, 0, 1]], {{\[}}2, -1, 5]> : tensor<2x2x2xi16>} : () -> ()
773 "fooi16"(){bar = sparse<[[1, 1, 0], [0, 1, 0], [0, 0, 1]], [2, -1, 5]> : tensor<2x2x2xi16>} : () -> ()
774 // CHECK: "fooi32"() {bar = sparse<> : tensor<1x1xi32>} : () -> ()
775 "fooi32"(){bar = sparse<> : tensor<1x1xi32>} : () -> ()
776 // CHECK: "fooi64"() {bar = sparse<0, -1> : tensor<1xi64>} : () -> ()
777 "fooi64"(){bar = sparse<[0], [-1]> : tensor<1xi64>} : () -> ()
778 // CHECK: "foo2"() {bar = sparse<> : tensor<0xi32>} : () -> ()
779 "foo2"(){bar = sparse<> : tensor<0xi32>} : () -> ()
780 // CHECK: "foo3"() {bar = sparse<> : tensor<i32>} : () -> ()
781 "foo3"(){bar = sparse<> : tensor<i32>} : () -> ()
783 // CHECK: "foof16"() {bar = sparse<0, -2.000000e+00> : tensor<1x1x1xf16>} : () -> ()
784 "foof16"(){bar = sparse<0, -2.0> : tensor<1x1x1xf16>} : () -> ()
785 // CHECK: "foobf16"() {bar = sparse<{{\[\[}}1, 1, 0], {{\[}}0, 1, 0], {{\[}}0, 0, 1]], {{\[}}2.000000e+00, -1.000000e+00, 5.000000e+00]> : tensor<2x2x2xbf16>} : () -> ()
786 "foobf16"(){bar = sparse<[[1, 1, 0], [0, 1, 0], [0, 0, 1]], [2.0, -1.0, 5.0]> : tensor<2x2x2xbf16>} : () -> ()
787 // CHECK: "foof32"() {bar = sparse<> : tensor<1x0x1xf32>} : () -> ()
788 "foof32"(){bar = sparse<> : tensor<1x0x1xf32>} : () -> ()
789 // CHECK: "foof64"() {bar = sparse<0, -1.000000e+00> : tensor<1xf64>} : () -> ()
790 "foof64"(){bar = sparse<[[0]], [-1.0]> : tensor<1xf64>} : () -> ()
791 // CHECK: "foof320"() {bar = sparse<> : tensor<0xf32>} : () -> ()
792 "foof320"(){bar = sparse<> : tensor<0xf32>} : () -> ()
793 // CHECK: "foof321"() {bar = sparse<> : tensor<f32>} : () -> ()
794 "foof321"(){bar = sparse<> : tensor<f32>} : () -> ()
796 // CHECK: "foostr"() {bar = sparse<0, "foo"> : tensor<1x1x1x!unknown<>>} : () -> ()
797 "foostr"(){bar = sparse<0, "foo"> : tensor<1x1x1x!unknown<>>} : () -> ()
798 // CHECK: "foostr"() {bar = sparse<{{\[\[}}1, 1, 0], {{\[}}0, 1, 0], {{\[}}0, 0, 1]], {{\[}}"a", "b", "c"]> : tensor<2x2x2x!unknown<>>} : () -> ()
799 "foostr"(){bar = sparse<[[1, 1, 0], [0, 1, 0], [0, 0, 1]], ["a", "b", "c"]> : tensor<2x2x2x!unknown<>>} : () -> ()
803 // CHECK-LABEL: func @sparsevectorattr
804 func.func @sparsevectorattr() -> () {
806 // NOTE: The {{\[\[}} syntax is because "[[" confuses FileCheck.
807 // CHECK: "fooi8"() {bar = sparse<0, -2> : vector<1x1x1xi8>} : () -> ()
808 "fooi8"(){bar = sparse<0, -2> : vector<1x1x1xi8>} : () -> ()
809 // CHECK: "fooi16"() {bar = sparse<{{\[\[}}1, 1, 0], {{\[}}0, 1, 0], {{\[}}0, 0, 1]], {{\[}}2, -1, 5]> : vector<2x2x2xi16>} : () -> ()
810 "fooi16"(){bar = sparse<[[1, 1, 0], [0, 1, 0], [0, 0, 1]], [2, -1, 5]> : vector<2x2x2xi16>} : () -> ()
811 // CHECK: "fooi32"() {bar = sparse<> : vector<1x1xi32>} : () -> ()
812 "fooi32"(){bar = sparse<> : vector<1x1xi32>} : () -> ()
813 // CHECK: "fooi64"() {bar = sparse<0, -1> : vector<1xi64>} : () -> ()
814 "fooi64"(){bar = sparse<[[0]], [-1]> : vector<1xi64>} : () -> ()
816 // CHECK: "foof16"() {bar = sparse<0, -2.000000e+00> : vector<1x1x1xf16>} : () -> ()
817 "foof16"(){bar = sparse<0, -2.0> : vector<1x1x1xf16>} : () -> ()
818 // CHECK: "foobf16"() {bar = sparse<{{\[\[}}1, 1, 0], {{\[}}0, 1, 0], {{\[}}0, 0, 1]], {{\[}}2.000000e+00, -1.000000e+00, 5.000000e+00]> : vector<2x2x2xbf16>} : () -> ()
819 "foobf16"(){bar = sparse<[[1, 1, 0], [0, 1, 0], [0, 0, 1]], [2.0, -1.0, 5.0]> : vector<2x2x2xbf16>} : () -> ()
820 // CHECK: "foof64"() {bar = sparse<0, -1.000000e+00> : vector<1xf64>} : () -> ()
821 "foof64"(){bar = sparse<0, [-1.0]> : vector<1xf64>} : () -> ()
825 // CHECK-LABEL: func @unknown_dialect_type() -> !bar<> {
826 func.func @unknown_dialect_type() -> !bar<> {
827 // Unregistered dialect 'bar'.
828 // CHECK: "foo"() : () -> !bar<>
829 %0 = "foo"() : () -> !bar<>
831 // CHECK: "foo"() : () -> !bar.baz
832 %1 = "foo"() : () -> !bar<baz>
837 // CHECK-LABEL: func @type_alias() -> i32 {
838 !i32_type_alias = i32
839 func.func @type_alias() -> !i32_type_alias {
841 // Return a non-aliased i32 type.
842 %0 = "foo"() : () -> i32
846 // CHECK-LABEL: func @no_integer_set_constraints(
847 func.func @no_integer_set_constraints() {
848 // CHECK: affine.if [[$SET_TRUE]]() {
849 affine.if affine_set<() : ()> () {
854 // CHECK-LABEL: func @verbose_if(
855 func.func @verbose_if(%N: index) {
856 %c = arith.constant 200 : index
858 // CHECK: affine.if #set{{.*}}(%{{.*}})[%{{.*}}, %{{.*}}] {
859 "affine.if"(%c, %N, %c) ({
861 %y = "add"(%c, %N) : (index, index) -> index
862 "affine.yield"() : () -> ()
863 // CHECK-NEXT: } else {
864 }, { // The else region.
866 %z = "add"(%c, %c) : (index, index) -> index
867 "affine.yield"() : () -> ()
869 { condition = #set0 } : (index, index, index) -> ()
873 // CHECK-LABEL: func @terminator_with_regions
874 func.func @terminator_with_regions() {
875 // Combine successors and regions in the same operation.
876 // CHECK: "region"()[^bb1] ({
877 // CHECK: }) : () -> ()
878 "region"()[^bb2] ({}) : () -> ()
883 // CHECK-LABEL: func @unregistered_term
884 func.func @unregistered_term(%arg0 : i1) -> i1 {
885 // CHECK-NEXT: "unregistered_br"(%{{.*}})[^bb1] : (i1) -> ()
886 "unregistered_br"(%arg0)[^bb1] : (i1) -> ()
892 // CHECK-LABEL: func @dialect_attrs
893 func.func @dialect_attrs()
894 // CHECK: attributes {dialect.attr = 10
895 attributes {dialect.attr = 10} {
899 // CHECK-LABEL: func private @_valid.function$name
900 func.func private @_valid.function$name()
902 // CHECK-LABEL: func private @external_func_arg_attrs(i32, i1 {dialect.attr = 10 : i64}, i32)
903 func.func private @external_func_arg_attrs(i32, i1 {dialect.attr = 10 : i64}, i32)
905 // CHECK-LABEL: func @func_arg_attrs(%{{.*}}: i1 {dialect.attr = 10 : i64})
906 func.func @func_arg_attrs(%arg0: i1 {dialect.attr = 10 : i64}) {
910 // CHECK-LABEL: func @func_result_attrs({{.*}}) -> (f32 {dialect.attr = 1 : i64})
911 func.func @func_result_attrs(%arg0: f32) -> (f32 {dialect.attr = 1}) {
915 // CHECK-LABEL: func private @empty_tuple(tuple<>)
916 func.func private @empty_tuple(tuple<>)
918 // CHECK-LABEL: func private @tuple_single_element(tuple<i32>)
919 func.func private @tuple_single_element(tuple<i32>)
921 // CHECK-LABEL: func private @tuple_multi_element(tuple<i32, i16, f32>)
922 func.func private @tuple_multi_element(tuple<i32, i16, f32>)
924 // CHECK-LABEL: func private @tuple_nested(tuple<tuple<tuple<i32>>>)
925 func.func private @tuple_nested(tuple<tuple<tuple<i32>>>)
927 // CHECK-LABEL: func @pretty_form_multi_result
928 func.func @pretty_form_multi_result() -> (i16, i16) {
929 // CHECK: %{{.*}}:2 = "foo_div"() : () -> (i16, i16)
930 %quot, %rem = "foo_div"() : () -> (i16, i16)
931 return %quot, %rem : i16, i16
934 // CHECK-LABEL: func @pretty_form_multi_result_groups
935 func.func @pretty_form_multi_result_groups() -> (i16, i16, i16, i16, i16) {
936 // CHECK: %[[RES:.*]]:5 =
937 // CHECK: return %[[RES]]#0, %[[RES]]#1, %[[RES]]#2, %[[RES]]#3, %[[RES]]#4
938 %group_1:2, %group_2, %group_3:2 = "foo_test"() : () -> (i16, i16, i16, i16, i16)
939 return %group_1#0, %group_1#1, %group_2, %group_3#0, %group_3#1 : i16, i16, i16, i16, i16
942 // CHECK-LABEL: func @pretty_dialect_attribute()
943 func.func @pretty_dialect_attribute() {
944 // CHECK: "foo.unknown_op"() {foo = #foo.simple_attr} : () -> ()
945 "foo.unknown_op"() {foo = #foo.simple_attr} : () -> ()
947 // CHECK: "foo.unknown_op"() {foo = #foo.complexattr<abcd>} : () -> ()
948 "foo.unknown_op"() {foo = #foo.complexattr<abcd>} : () -> ()
950 // CHECK: "foo.unknown_op"() {foo = #foo.complexattr<abcd<f32>>} : () -> ()
951 "foo.unknown_op"() {foo = #foo.complexattr<abcd<f32>>} : () -> ()
953 // CHECK: "foo.unknown_op"() {foo = #foo.complexattr<abcd<[f]$$[32]>>} : () -> ()
954 "foo.unknown_op"() {foo = #foo.complexattr<abcd<[f]$$[32]>>} : () -> ()
956 // CHECK: "foo.unknown_op"() {foo = #foo.dialect<!x@#!@#>} : () -> ()
957 "foo.unknown_op"() {foo = #foo.dialect<!x@#!@#>} : () -> ()
962 // CHECK-LABEL: func @pretty_dialect_type()
963 func.func @pretty_dialect_type() {
965 // CHECK: %{{.*}} = "foo.unknown_op"() : () -> !foo.simpletype
966 %0 = "foo.unknown_op"() : () -> !foo.simpletype
968 // CHECK: %{{.*}} = "foo.unknown_op"() : () -> !foo.complextype<abcd>
969 %1 = "foo.unknown_op"() : () -> !foo.complextype<abcd>
971 // CHECK: %{{.*}} = "foo.unknown_op"() : () -> !foo.complextype<abcd<f32>>
972 %2 = "foo.unknown_op"() : () -> !foo.complextype<abcd<f32>>
974 // CHECK: %{{.*}} = "foo.unknown_op"() : () -> !foo.complextype<abcd<[f]$$[32]>>
975 %3 = "foo.unknown_op"() : () -> !foo.complextype<abcd<[f]$$[32]>>
977 // CHECK: %{{.*}} = "foo.unknown_op"() : () -> !foo.dialect<!x@#!@#>
978 %4 = "foo.unknown_op"() : () -> !foo.dialect<!x@#!@#>
983 // CHECK-LABEL: func @none_type
984 func.func @none_type() {
985 // CHECK: "foo.unknown_op"() : () -> none
986 %none_val = "foo.unknown_op"() : () -> none
990 // CHECK-LABEL: func @scoped_names
991 func.func @scoped_names() {
992 // CHECK-NEXT: "foo.region_op"
994 // CHECK-NEXT: "foo.unknown_op"
995 %scoped_name = "foo.unknown_op"() : () -> none
996 "foo.terminator"() : () -> ()
998 // CHECK: "foo.unknown_op"
999 %scoped_name = "foo.unknown_op"() : () -> none
1000 "foo.terminator"() : () -> ()
1005 // CHECK-LABEL: func @dialect_attribute_with_type
1006 func.func @dialect_attribute_with_type() {
1007 // CHECK-NEXT: foo = #foo.attr : i32
1008 "foo.unknown_op"() {foo = #foo.attr : i32} : () -> ()
1011 // CHECK-LABEL: @f16_special_values
1012 func.func @f16_special_values() {
1014 // CHECK: arith.constant 0x7C01 : f16
1015 %0 = arith.constant 0x7C01 : f16
1016 // CHECK: arith.constant 0x7FFF : f16
1017 %1 = arith.constant 0x7FFF : f16
1018 // CHECK: arith.constant 0xFFFF : f16
1019 %2 = arith.constant 0xFFFF : f16
1021 // F16 positive infinity.
1022 // CHECK: arith.constant 0x7C00 : f16
1023 %3 = arith.constant 0x7C00 : f16
1024 // F16 negative infinity.
1025 // CHECK: arith.constant 0xFC00 : f16
1026 %4 = arith.constant 0xFC00 : f16
1031 // CHECK-LABEL: @f32_special_values
1032 func.func @f32_special_values() {
1033 // F32 signaling NaNs.
1034 // CHECK: arith.constant 0x7F800001 : f32
1035 %0 = arith.constant 0x7F800001 : f32
1036 // CHECK: arith.constant 0x7FBFFFFF : f32
1037 %1 = arith.constant 0x7FBFFFFF : f32
1040 // CHECK: arith.constant 0x7FC00000 : f32
1041 %2 = arith.constant 0x7FC00000 : f32
1042 // CHECK: arith.constant 0xFFFFFFFF : f32
1043 %3 = arith.constant 0xFFFFFFFF : f32
1045 // F32 positive infinity.
1046 // CHECK: arith.constant 0x7F800000 : f32
1047 %4 = arith.constant 0x7F800000 : f32
1048 // F32 negative infinity.
1049 // CHECK: arith.constant 0xFF800000 : f32
1050 %5 = arith.constant 0xFF800000 : f32
1055 // CHECK-LABEL: @f64_special_values
1056 func.func @f64_special_values() {
1057 // F64 signaling NaNs.
1058 // CHECK: arith.constant 0x7FF0000000000001 : f64
1059 %0 = arith.constant 0x7FF0000000000001 : f64
1060 // CHECK: arith.constant 0x7FF8000000000000 : f64
1061 %1 = arith.constant 0x7FF8000000000000 : f64
1064 // CHECK: arith.constant 0x7FF0000001000000 : f64
1065 %2 = arith.constant 0x7FF0000001000000 : f64
1066 // CHECK: arith.constant 0xFFF0000001000000 : f64
1067 %3 = arith.constant 0xFFF0000001000000 : f64
1069 // F64 positive infinity.
1070 // CHECK: arith.constant 0x7FF0000000000000 : f64
1071 %4 = arith.constant 0x7FF0000000000000 : f64
1072 // F64 negative infinity.
1073 // CHECK: arith.constant 0xFFF0000000000000 : f64
1074 %5 = arith.constant 0xFFF0000000000000 : f64
1076 // Check that values that can't be represented with the default format, use
1078 // CHECK: arith.constant 0xC1CDC00000000000 : f64
1079 %6 = arith.constant 0xC1CDC00000000000 : f64
1084 // CHECK-LABEL: @bfloat16_special_values
1085 func.func @bfloat16_special_values() {
1086 // bfloat16 signaling NaNs.
1087 // CHECK: arith.constant 0x7F81 : bf16
1088 %0 = arith.constant 0x7F81 : bf16
1089 // CHECK: arith.constant 0xFF81 : bf16
1090 %1 = arith.constant 0xFF81 : bf16
1092 // bfloat16 quiet NaNs.
1093 // CHECK: arith.constant 0x7FC0 : bf16
1094 %2 = arith.constant 0x7FC0 : bf16
1095 // CHECK: arith.constant 0xFFC0 : bf16
1096 %3 = arith.constant 0xFFC0 : bf16
1098 // bfloat16 positive infinity.
1099 // CHECK: arith.constant 0x7F80 : bf16
1100 %4 = arith.constant 0x7F80 : bf16
1101 // bfloat16 negative infinity.
1102 // CHECK: arith.constant 0xFF80 : bf16
1103 %5 = arith.constant 0xFF80 : bf16
1108 // CHECK-LABEL: @f80_special_values
1109 func.func @f80_special_values() {
1110 // F80 signaling NaNs.
1111 // CHECK: arith.constant 0x7FFFE000000000000001 : f80
1112 %0 = arith.constant 0x7FFFE000000000000001 : f80
1113 // CHECK: arith.constant 0x7FFFB000000000000011 : f80
1114 %1 = arith.constant 0x7FFFB000000000000011 : f80
1117 // CHECK: arith.constant 0x7FFFC000000000100000 : f80
1118 %2 = arith.constant 0x7FFFC000000000100000 : f80
1119 // CHECK: arith.constant 0x7FFFE000000001000000 : f80
1120 %3 = arith.constant 0x7FFFE000000001000000 : f80
1122 // F80 positive infinity.
1123 // CHECK: arith.constant 0x7FFF8000000000000000 : f80
1124 %4 = arith.constant 0x7FFF8000000000000000 : f80
1125 // F80 negative infinity.
1126 // CHECK: arith.constant 0xFFFF8000000000000000 : f80
1127 %5 = arith.constant 0xFFFF8000000000000000 : f80
1132 // We want to print floats in exponential notation with 6 significant digits,
1133 // but it may lead to precision loss when parsing back, in which case we print
1134 // the decimal form instead.
1135 // CHECK-LABEL: @f32_potential_precision_loss()
1136 func.func @f32_potential_precision_loss() {
1137 // CHECK: arith.constant -1.23697901 : f32
1138 %0 = arith.constant -1.23697901 : f32
1142 // CHECK-LABEL: @special_float_values_in_tensors
1143 func.func @special_float_values_in_tensors() {
1144 // CHECK: dense<0xFFFFFFFF> : tensor<4x4xf32>
1145 "foo"(){bar = dense<0xFFFFFFFF> : tensor<4x4xf32>} : () -> ()
1146 // CHECK: dense<[{{\[}}0xFFFFFFFF, 0x7F800000], [0x7FBFFFFF, 0x7F800001]]> : tensor<2x2xf32>
1147 "foo"(){bar = dense<[[0xFFFFFFFF, 0x7F800000], [0x7FBFFFFF, 0x7F800001]]> : tensor<2x2xf32>} : () -> ()
1148 // CHECK: dense<[0xFFFFFFFF, 0.000000e+00]> : tensor<2xf32>
1149 "foo"(){bar = dense<[0xFFFFFFFF, 0.0]> : tensor<2xf32>} : () -> ()
1151 // CHECK: sparse<[{{\[}}1, 1, 0], [0, 1, 1]], [0xFFFFFFFF, 0x7F800001]>
1152 "foo"(){bar = sparse<[[1,1,0],[0,1,1]], [0xFFFFFFFF, 0x7F800001]> : tensor<2x2x2xf32>} : () -> ()
1155 // Test parsing of an op with multiple region arguments, and without a
1158 // GENERIC-LABEL: op_with_region_args
1159 func.func @op_with_region_args() {
1160 // GENERIC: "test.polyfor"() ({
1161 // GENERIC-NEXT: ^bb{{.*}}(%{{.*}}: index, %{{.*}}: index, %{{.*}}: index):
1162 test.polyfor %i, %j, %k {
1168 // Test allowing different name scopes for regions isolated from above.
1170 // CHECK-LABEL: func @op_with_passthrough_region_args
1171 func.func @op_with_passthrough_region_args() {
1172 // CHECK: [[VAL:%.*]] = arith.constant
1173 %0 = arith.constant 10 : index
1175 // CHECK: test.isolated_region [[VAL]] {
1176 // CHECK-NEXT: "foo.consumer"([[VAL]]) : (index)
1178 test.isolated_region %0 {
1179 "foo.consumer"(%0) : (index) -> ()
1182 // CHECK: [[VAL:%.*]]:2 = "foo.op"
1183 %result:2 = "foo.op"() : () -> (index, index)
1185 // CHECK: test.isolated_region [[VAL]]#1 {
1186 // CHECK-NEXT: "foo.consumer"([[VAL]]#1) : (index)
1188 test.isolated_region %result#1 {
1189 "foo.consumer"(%result#1) : (index) -> ()
1195 // CHECK-LABEL: func private @ptr_to_function() -> !unreg.ptr<() -> ()>
1196 func.func private @ptr_to_function() -> !unreg.ptr<() -> ()>
1198 // CHECK-LABEL: func private @escaped_string_char(i1 {foo.value = "\0A"})
1199 func.func private @escaped_string_char(i1 {foo.value = "\n"})
1201 // CHECK-LABEL: func @parse_integer_literal_test
1202 func.func @parse_integer_literal_test() {
1203 // CHECK: test.parse_integer_literal : 5
1204 test.parse_integer_literal : 5
1208 // CHECK-LABEL: func @parse_wrapped_keyword_test
1209 func.func @parse_wrapped_keyword_test() {
1210 // CHECK: test.parse_wrapped_keyword foo.keyword
1211 test.parse_wrapped_keyword foo.keyword
1215 // GENERIC-LABEL: parse_base64_test
1216 func.func @parse_base64_test() {
1217 // GENERIC: "test.parse_b64"() <{b64 = "hello world"}>
1218 test.parse_b64 "aGVsbG8gd29ybGQ="
1222 // CHECK-LABEL: func @"\22_string_symbol_reference\22"
1223 func.func @"\"_string_symbol_reference\""() {
1224 // CHECK: ref = @"\22_string_symbol_reference\22"
1225 "foo.symbol_reference"() {ref = @"\"_string_symbol_reference\""} : () -> ()
1229 // CHECK-LABEL: func private @parse_opaque_attr_escape
1230 func.func private @parse_opaque_attr_escape() {
1231 // CHECK: value = #foo<"\"escaped\\\n\"">
1232 "foo.constant"() {value = #foo<"\"escaped\\\n\"">} : () -> ()
1235 // CHECK-LABEL: func private @string_attr_name
1236 // CHECK-SAME: {"0 . 0", nested = {"0 . 0"}}
1237 func.func private @string_attr_name() attributes {"0 . 0", nested = {"0 . 0"}}
1239 // CHECK-LABEL: func private @nested_reference
1240 // CHECK: ref = @some_symbol::@some_nested_symbol
1241 func.func private @nested_reference() attributes {test.ref = @some_symbol::@some_nested_symbol }
1243 // CHECK-LABEL: func @custom_asm_names
1244 func.func @custom_asm_names() -> (i32, i32, i32, i32, i32, i32) {
1245 // CHECK: %[[FIRST:first.*]], %[[MIDDLE:middle_results.*]]:2, %[[LAST:[0-9]+]]
1246 %0, %1:2, %2 = "test.asm_interface_op"() : () -> (i32, i32, i32, i32)
1248 // CHECK: %[[FIRST_2:first.*]], %[[LAST_2:[0-9]+]]
1249 %3, %4 = "test.asm_interface_op"() : () -> (i32, i32)
1251 // CHECK: return %[[FIRST]], %[[MIDDLE]]#0, %[[MIDDLE]]#1, %[[LAST]], %[[FIRST_2]], %[[LAST_2]]
1252 return %0, %1#0, %1#1, %2, %3, %4 : i32, i32, i32, i32, i32, i32
1256 // CHECK-LABEL: func @pretty_names
1258 // This tests the behavior
1259 func.func @pretty_names() {
1260 // Simple case, should parse and print as %x being an implied 'name'
1262 %x = test.string_attr_pretty_name
1263 // CHECK: %x = test.string_attr_pretty_name
1264 // CHECK-NOT: attributes
1266 // This specifies an explicit name, which should override the result.
1267 %YY = test.string_attr_pretty_name attributes { names = ["y"] }
1268 // CHECK: %y = test.string_attr_pretty_name
1269 // CHECK-NOT: attributes
1271 // Conflicts with the 'y' name, so need an explicit attribute.
1272 %0 = "test.string_attr_pretty_name"() { names = ["y"]} : () -> i32
1273 // CHECK: %y_0 = test.string_attr_pretty_name attributes {names = ["y"]}
1275 // Name contains a space.
1276 %1 = "test.string_attr_pretty_name"() { names = ["space name"]} : () -> i32
1277 // CHECK: %space_name = test.string_attr_pretty_name attributes {names = ["space name"]}
1279 "unknown.use"(%x, %YY, %0, %1) : (i32, i32, i32, i32) -> ()
1281 // Multi-result support.
1283 %a, %b, %c = test.string_attr_pretty_name
1284 // CHECK: %a, %b, %c = test.string_attr_pretty_name
1285 // CHECK-NOT: attributes
1287 %q:3, %r = test.string_attr_pretty_name
1288 // CHECK: %q, %q_1, %q_2, %r = test.string_attr_pretty_name attributes {names = ["q", "q", "q", "r"]}
1295 // This tests the behavior of "default dialect":
1296 // operations like `test.default_dialect` can define a default dialect
1297 // used in nested region.
1298 // CHECK-LABEL: func @default_dialect
1299 func.func @default_dialect(%bool : i1) {
1300 test.default_dialect {
1301 // The test dialect is the default in this region, the following two
1302 // operations are parsed identically.
1303 // CHECK-NOT: test.parse_integer_literal
1304 parse_integer_literal : 5
1305 // CHECK: parse_integer_literal : 6
1306 test.parse_integer_literal : 6
1307 // Verify that only an op prefix is stripped, not an attribute value for
1309 // CHECK: "test.op_with_attr"() {test.attr = "test.value"} : () -> ()
1310 "test.op_with_attr"() {test.attr = "test.value"} : () -> ()
1311 // Verify that the prefix is not stripped when it can lead to ambiguity.
1312 // CHECK: test.op.with_dot_in_name
1313 test.op.with_dot_in_name
1314 // This is an unregistered operation, the printing/parsing is handled by the
1315 // dialect, and the dialect prefix should not be stripped while printing
1316 // because of potential ambiguity.
1317 // CHECK: test.dialect_custom_printer.with.dot
1318 test.dialect_custom_printer.with.dot
1319 "test.terminator"() : ()->()
1321 // The same operation outside of the region does not have an func. prefix.
1326 // CHECK-LABEL: func @unreachable_dominance_violation_ok
1327 func.func @unreachable_dominance_violation_ok() -> i1 {
1328 // CHECK: [[VAL:%.*]] = arith.constant false
1329 // CHECK: return [[VAL]] : i1
1330 // CHECK: ^bb1: // no predecessors
1331 // CHECK: [[VAL2:%.*]]:3 = "bar"([[VAL3:%.*]]) : (i64) -> (i1, i1, i1)
1332 // CHECK: cf.br ^bb3
1333 // CHECK: ^bb2: // pred: ^bb2
1334 // CHECK: cf.br ^bb2
1335 // CHECK: ^bb3: // pred: ^bb1
1336 // CHECK: [[VAL3]] = "foo"() : () -> i64
1337 // CHECK: return [[VAL2]]#1 : i1
1339 %c = arith.constant false
1342 // %1 is not dominated by it's definition, but block is not reachable.
1343 %2:3 = "bar"(%1) : (i64) -> (i1,i1,i1)
1348 %1 = "foo"() : ()->i64
1352 // CHECK-LABEL: func @graph_region_in_hierarchy_ok
1353 func.func @graph_region_in_hierarchy_ok() -> i64 {
1354 // CHECK: cf.br ^bb2
1356 // CHECK: test.graph_region {
1357 // CHECK: [[VAL2:%.*]]:3 = "bar"([[VAL3:%.*]]) : (i64) -> (i1, i1, i1)
1359 // CHECK: cf.br ^bb3
1360 // CHECK: ^bb2: // pred: ^bb0
1361 // CHECK: [[VAL3]] = "foo"() : () -> i64
1362 // CHECK: cf.br ^bb1
1363 // CHECK: ^bb3: // pred: ^bb1
1364 // CHECK: return [[VAL3]] : i64
1369 // %1 is well-defined here, since bb2 dominates bb1.
1370 %2:3 = "bar"(%1) : (i64) -> (i1,i1,i1)
1374 %1 = "foo"() : ()->i64
1380 // CHECK-LABEL: func @graph_region_kind
1381 func.func @graph_region_kind() -> () {
1382 // CHECK: [[VAL2:%.*]]:3 = "bar"([[VAL3:%.*]]) : (i64) -> (i1, i1, i1)
1383 // CHECK: [[VAL3]] = "baz"([[VAL2]]#0) : (i1) -> i64
1385 // %1 OK here in graph region.
1386 %2:3 = "bar"(%1) : (i64) -> (i1,i1,i1)
1387 %1 = "baz"(%2#0) : (i1) -> (i64)
1392 // CHECK-LABEL: func @graph_region_inside_ssacfg_region
1393 func.func @graph_region_inside_ssacfg_region() -> () {
1394 // CHECK: "test.ssacfg_region"
1395 // CHECK: [[VAL3:%.*]] = "baz"() : () -> i64
1396 // CHECK: test.graph_region {
1397 // CHECK: [[VAL2:%.*]]:3 = "bar"([[VAL3]]) : (i64) -> (i1, i1, i1)
1399 // CHECK: [[VAL4:.*]] = "baz"() : () -> i64
1400 "test.ssacfg_region"() ({
1401 %1 = "baz"() : () -> (i64)
1403 %2:3 = "bar"(%1) : (i64) -> (i1,i1,i1)
1405 %3 = "baz"() : () -> (i64)
1410 // CHECK-LABEL: func @graph_region_in_graph_region_ok
1411 func.func @graph_region_in_graph_region_ok() -> () {
1412 // CHECK: test.graph_region {
1413 // CHECK: test.graph_region {
1414 // CHECK: [[VAL2:%.*]]:3 = "bar"([[VAL3:%.*]]) : (i64) -> (i1, i1, i1)
1416 // CHECK: [[VAL3]] = "foo"() : () -> i64
1420 // %1 is well-defined here since defined in graph region
1421 %2:3 = "bar"(%1) : (i64) -> (i1,i1,i1)
1423 %1 = "foo"() : ()->i64
1424 "test.terminator"() : ()->()
1429 // CHECK: test.graph_region {
1431 // CHECK: [[VAL1:%.*]] = "op1"([[VAL3:%.*]]) : (i32) -> i32
1432 // CHECK: [[VAL2:%.*]] = "test.ssacfg_region"([[VAL1]], [[VAL2]], [[VAL3]], [[VAL4:%.*]]) ({
1433 // CHECK: [[VAL5:%.*]] = "op2"([[VAL1]], [[VAL2]], [[VAL3]], [[VAL4]]) : (i32, i32, i32, i32) -> i32
1434 // CHECK: }) : (i32, i32, i32, i32) -> i32
1435 // CHECK: [[VAL3]] = "op2"([[VAL1]], [[VAL4]]) : (i32, i32) -> i32
1436 // CHECK: [[VAL4]] = "op3"([[VAL1]]) : (i32) -> i32
1437 %1 = "op1"(%3) : (i32) -> (i32)
1438 %2 = "test.ssacfg_region"(%1, %2, %3, %4) ({
1439 %5 = "op2"(%1, %2, %3, %4) :
1440 (i32, i32, i32, i32) -> (i32)
1441 }) : (i32, i32, i32, i32) -> (i32)
1442 %3 = "op2"(%1, %4) : (i32, i32) -> (i32)
1443 %4 = "op3"(%1) : (i32) -> (i32)
1446 // CHECK: "unregistered_func_might_have_graph_region"() ({
1447 // CHECK: [[VAL1:%.*]] = "foo"([[VAL1]], [[VAL2:%.*]]) : (i64, i64) -> i64
1448 // CHECK: [[VAL2]] = "bar"([[VAL1]])
1449 "unregistered_func_might_have_graph_region"() ({
1450 %1 = "foo"(%1, %2) : (i64, i64) -> i64
1451 %2 = "bar"(%1) : (i64) -> i64
1452 "unregistered_terminator"() : () -> ()
1453 }) {sym_name = "unregistered_op_dominance_violation_ok", function_type = () -> i1} : () -> ()
1455 // This is an unregister operation, the printing/parsing is handled by the dialect.
1456 // CHECK: test.dialect_custom_printer custom_format
1457 test.dialect_custom_printer custom_format
1459 // This is a registered operation with no custom parser and printer, and should
1460 // be handled by the dialect.
1461 // CHECK: test.dialect_custom_format_fallback custom_format_fallback
1462 test.dialect_custom_format_fallback custom_format_fallback
1464 // Check that an op with an optional result parses f80 as type.
1465 // CHECK: test.format_optional_result_d_op : f80
1466 test.format_optional_result_d_op : f80