[Instrumentation] Fix a warning
[llvm-project.git] / flang / test / Fir / types-to-llvm.fir
blob80bdb6ad87c7629bfbcf7959e6bc121744d4ef9c
1 // Test FIR types conversion.
3 // RUN: fir-opt --split-input-file --fir-to-llvm-ir="target=x86_64-unknown-linux-gnu" %s | FileCheck %s
6 // Test sequence types `!fir.array`
7 // Note that we're switching from column-major to row-major here.
9 func.func private @foo0(%arg0: !fir.array<10x12xi64>)
10 // CHECK-LABEL: foo0
11 // CHECK-SAME: !llvm.array<12 x array<10 x i64>>
12 func.func private @foo1(%arg0: !fir.array<?xf32>)
13 // CHECK-LABEL: foo1
14 // CHECK-SAME: f32
15 func.func private @foo2(%arg0: !fir.array<?x?xf128>)
16 // CHECK-LABEL: foo2
17 // CHECK-SAME: f128
18 func.func private @foo3(%arg0: !fir.array<*:i32>)
19 // CHECK-LABEL: foo3
20 // CHECK-SAME: i32
21 func.func private @foo4(%arg0: !fir.array<3x?xi32>)
22 // CHECK-LABEL: foo4
23 // CHECK-SAME: i32
24 func.func private @foo5(%arg0: !fir.array<?x6xi32>)
25 // CHECK-LABEL: foo5
26 // CHECK-SAME: i32
27 func.func private @foo6(%arg0: !fir.array<2x?x3x?x4xi32>)
28 // CHECK-LABEL: foo6
29 // CHECK-SAME: !llvm.array<2 x i32>
30 func.func private @foo7(%arg0: !fir.array<6x?x!fir.char<1,?>>)
31 // CHECK-LABEL: foo7
32 // CHECK-SAME: i8
33 func.func private @foo8(%arg0: !fir.array<6x?x!fir.char<1,3>>)
34 // CHECK-LABEL: foo8
35 // CHECK-SAME: !llvm.array<6 x array<3 x i8>>
37 // -----
39 // Test reference types `!fir.ref`
41 func.func private @foo0(%arg0: !fir.ref<i32>)
42 // CHECK-LABEL: foo0
43 // CHECK-SAME: !llvm.ptr
44 func.func private @foo1(%arg0: !fir.ref<!fir.array<10xf32>>)
45 // CHECK-LABEL: foo1
46 // CHECK-SAME: !llvm.ptr
47 func.func private @foo2(%arg0: !fir.ref<!fir.box<!fir.heap<!fir.type<_QMs1Ta1{x:i32,y:f32}>>>>)
48 // CHECK-LABEL: foo2
49 // CHECK-SAME: !llvm.ptr
50 func.func private @foo3(%arg0: !fir.ref<!fir.array<10x?x11xf32>>)
51 // CHECK-LABEL: foo3
52 // CHECK-SAME: !llvm.ptr
53 func.func private @foo4(%arg0: !fir.ref<!fir.array<10x11x?x?xf32>>)
54 // CHECK-LABEL: foo4
55 // CHECK-SAME: !llvm.ptr
56 func.func private @foo5(%arg0: !fir.ref<!fir.array<10x!fir.char<1,?>>>)
57 // CHECK-LABEL: foo5
58 // CHECK-SAME: !llvm.ptr
59 func.func private @foo6(%arg0: !fir.ref<!fir.array<10x!fir.char<2,8>>>)
60 // CHECK-LABEL: foo6
61 // CHECK-SAME: !llvm.ptr
62 func.func private @foo7(%arg0: !fir.ref<!fir.box<!fir.array<?xf32>>>)
63 // CHECK-LABEL: foo7
64 // CHECK-SAME: !llvm.ptr
66 // -----
68 // Test pointer types `!fir.ptr`
70 func.func private @foo0(%arg0: !fir.ptr<i32>)
71 // CHECK-LABEL: foo0
72 // CHECK-SAME: !llvm.ptr
74 func.func private @foo1(%arg0: !fir.ptr<!fir.array<10xf32>>)
75 // CHECK-LABEL: foo1
76 // CHECK-SAME: !llvm.ptr
78 // -----
80 // Test box types `!fir.box`
82 func.func private @foo0(%arg0: !fir.box<!fir.array<?xf32>>)
83 // CHECK-LABEL: foo0
84 // CHECK-SAME: !llvm.ptr
86 func.func private @foo1(%arg0: !fir.box<!fir.array<10xf32>>)
87 // CHECK-LABEL: foo1
88 // CHECK-SAME: !llvm.ptr
90 func.func private @foo2(%arg0: !fir.box<!fir.ref<i64>>)
91 // CHECK-LABEL: foo2
92 // CHECK-SAME: !llvm.ptr
94 func.func private @foo3(%arg0: !fir.box<!fir.type<derived{f:f32}>>)
95 // CHECK-LABEL: foo3
96 // CHECK-SAME: !llvm.ptr
98 func.func private @foo4(%arg0: !fir.box<!fir.heap<!fir.type<_QMs1Ta1{x:i32,y:f32}>>>)
99 // CHECK-LABEL: foo4
100 // CHECK-SAME: !llvm.ptr
102 // -----
104 // Test char types `!fir.char<k, n>`
106 func.func private @foo0(%arg0: !fir.char<1, 4>, %arg1: !fir.char<1, ?>)
107 // CHECK-LABEL: foo0
108 // CHECK-SAME: !llvm.array<4 x i8>
109 // CHECK-SAME: i8
111 func.func private @foo1(%arg0: !fir.char<2, 12>, %arg1: !fir.char<2, ?>)
112 // CHECK-LABEL: foo1
113 // CHECK-SAME: !llvm.array<12 x i16>
114 // CHECK-SAME: i16
116 func.func private @foo2(%arg0: !fir.char<4, 8>, %arg1: !fir.char<4, ?>)
117 // CHECK-LABEL: foo2
118 // CHECK-SAME: !llvm.array<8 x i32>
119 // CHECK-SAME: i32
121 // -----
123 // Test `!fir.heap<>` conversion.
124 func.func private @foo0(%arg0: !fir.heap<i32>)
125 // CHECK-LABEL: foo0
126 // CHECK-SAME: !llvm.ptr
128 func.func private @foo1(%arg0: !fir.heap<!fir.array<4xf32>>)
129 // CHECK-LABEL: foo1
130 // CHECK-SAME: !llvm.ptr
132 func.func private @foo2(%arg0: !fir.heap<!fir.array<?xf32>>)
133 // CHECK-LABEL: foo2
134 // CHECK-SAME: !llvm.ptr
136 func.func private @foo3(%arg0: !fir.heap<!fir.char<1,10>>)
137 // CHECK-LABEL: foo3
138 // CHECK-SAME: !llvm.ptr
140 func.func private @foo4(%arg0: !fir.heap<!fir.char<1,?>>)
141 // CHECK-LABEL: foo4
142 // CHECK-SAME: !llvm.ptr
144 func.func private @foo5(%arg0: !fir.heap<!fir.array<2xf32>>)
145 // CHECK-LABEL: foo5
146 // CHECK-SAME: !llvm.ptr
148 func.func private @foo6(%arg0: !fir.heap<!fir.array<?x?xf32>>)
149 // CHECK-LABEL: foo6
150 // CHECK-SAME: !llvm.ptr
152 func.func private @foo7(%arg0: !fir.heap<!fir.type<ZT>>)
153 // CHECK-LABEL: foo7
154 // CHECK-SAME: !llvm.ptr
156 func.func private @foo8(%arg0: !fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>)
157 // CHECK-LABEL: foo8
158 // CHECK-SAME: !llvm.ptr
160 // -----
162 // Test `!fir.integer<KIND>` conversion.
164 func.func private @foo0(%arg0: !fir.int<1>)
165 // CHECK-LABEL: foo0
166 // CHECK-SAME: i8
168 func.func private @foo1(%arg0: !fir.int<2>)
169 // CHECK-LABEL: foo1
170 // CHECK-SAME: i16
172 func.func private @foo2(%arg0: !fir.int<4>)
173 // CHECK-LABEL: foo2
174 // CHECK-SAME: i32
176 func.func private @foo3(%arg0: !fir.int<8>)
177 // CHECK-LABEL: foo3
178 // CHECK-SAME: i64
180 func.func private @foo4(%arg0: !fir.int<16>)
181 // CHECK-LABEL: foo4
182 // CHECK-SAME: i128
184 // -----
186 // Test `!fir.logical<KIND>` conversion.
188 func.func private @foo0(%arg0: !fir.logical<1>)
189 // CHECK-LABEL: foo0
190 // CHECK-SAME: i8
192 func.func private @foo1(%arg0: !fir.logical<2>)
193 // CHECK-LABEL: foo1
194 // CHECK-SAME: i16
196 func.func private @foo2(%arg0: !fir.logical<4>)
197 // CHECK-LABEL: foo2
198 // CHECK-SAME: i32
200 func.func private @foo3(%arg0: !fir.logical<8>)
201 // CHECK-LABEL: foo3
202 // CHECK-SAME: i64
204 func.func private @foo4(%arg0: !fir.logical<16>)
205 // CHECK-LABEL: foo4
206 // CHECK-SAME: i128
208 // -----
210 // Test `!fir.llvm_ptr` conversion.
212 func.func private @foo0(%arg0: !fir.llvm_ptr<i8>)
213 // CHECK-LABEL: foo0
214 // CHECK-SAME: !llvm.ptr
216 func.func private @foo1(%arg0: !fir.llvm_ptr<!fir.ref<f32>>)
217 // CHECK-LABEL: foo1
218 // CHECK-SAME: !llvm.ptr
220 func.func private @foo2(%arg0: !fir.llvm_ptr<!fir.ref<!fir.box<!fir.ptr<i32>>>>)
221 // CHECK-LABEL: foo2
222 // CHECK-SAME: !llvm.ptr
224 func.func private @foo3(%arg0: !fir.llvm_ptr<!fir.ptr<f32>>)
225 // CHECK-LABEL: foo3
226 // CHECK-SAME: !llvm.ptr
228 // -----
230 // Test MLIR `complex<KIND>` conversion.
232 func.func private @foo0(%arg0: complex<f16>)
233 // CHECK-LABEL: foo0
234 // CHECK-SAME: !llvm.struct<(f16, f16)>)
236 func.func private @foo1(%arg0: complex<bf16>)
237 // CHECK-LABEL: foo1
238 // CHECK-SAME: !llvm.struct<(bf16, bf16)>)
240 func.func private @foo2(%arg0: complex<f32>)
241 // CHECK-LABEL: foo2
242 // CHECK-SAME: !llvm.struct<(f32, f32)>)
244 func.func private @foo3(%arg0: complex<f64>)
245 // CHECK-LABEL: foo3
246 // CHECK-SAME: !llvm.struct<(f64, f64)>)
248 func.func private @foo4(%arg0: complex<f80>)
249 // CHECK-LABEL: foo4
250 // CHECK-SAME: !llvm.struct<(f80, f80)>)
252 func.func private @foo5(%arg0: complex<f128>)
253 // CHECK-LABEL: foo5
254 // CHECK-SAME: !llvm.struct<(f128, f128)>)
256 // -----
258 // Test `!fir.complex<KIND>` conversion.
260 func.func private @foo0(%arg0: complex<f16>)
261 // CHECK-LABEL: foo0
262 // CHECK-SAME: !llvm.struct<(f16, f16)>)
264 func.func private @foo1(%arg0: complex<bf16>)
265 // CHECK-LABEL: foo1
266 // CHECK-SAME: !llvm.struct<(bf16, bf16)>)
268 func.func private @foo2(%arg0: complex<f32>)
269 // CHECK-LABEL: foo2
270 // CHECK-SAME: !llvm.struct<(f32, f32)>)
272 func.func private @foo3(%arg0: complex<f64>)
273 // CHECK-LABEL: foo3
274 // CHECK-SAME: !llvm.struct<(f64, f64)>)
276 func.func private @foo4(%arg0: complex<f80>)
277 // CHECK-LABEL: foo4
278 // CHECK-SAME: !llvm.struct<(f80, f80)>)
280 func.func private @foo5(%arg0: complex<f128>)
281 // CHECK-LABEL: foo5
282 // CHECK-SAME: !llvm.struct<(f128, f128)>)
284 // -----
286 // Test `!fir.vector<>` conversion.
288 func.func private @foo0(%arg0: !fir.vector<2:f16>)
289 // CHECK-LABEL: foo0
290 // CHECK-SAME: vector<2xf16>
292 func.func private @foo1(%arg0: !fir.vector<20:bf16>)
293 // CHECK-LABEL: foo1
294 // CHECK-SAME: vector<20xbf16>
296 func.func private @foo2(%arg0: !fir.vector<30:f32>)
297 // CHECK-LABEL: foo2
298 // CHECK-SAME: vector<30xf32>
300 func.func private @foo3(%arg0: !fir.vector<55:f64>)
301 // CHECK-LABEL: foo3
302 // CHECK-SAME: vector<55xf64>
304 func.func private @foo4(%arg0: !fir.vector<15:f80>)
305 // CHECK-LABEL: foo4
306 // CHECK-SAME: vector<15xf80>
308 func.func private @foo5(%arg0: !fir.vector<28:f128>)
309 // CHECK-LABEL: foo5
310 // CHECK-SAME: vector<28xf128>
312 func.func private @foo6(%arg0: !fir.vector<100:i1>)
313 // CHECK-LABEL: foo6
314 // CHECK-SAME: vector<100xi1>
316 func.func private @foo7(%arg0: !fir.vector<10:i8>)
317 // CHECK-LABEL: foo7
318 // CHECK-SAME: vector<10xi8>
320 func.func private @foo8(%arg0: !fir.vector<12:i16>)
321 // CHECK-LABEL: foo8
322 // CHECK-SAME: vector<12xi16>
324 func.func private @foo9(%arg0: !fir.vector<20:i32>)
325 // CHECK-LABEL: foo9
326 // CHECK-SAME: vector<20xi32>
328 func.func private @foo10(%arg0: !fir.vector<30:i64>)
329 // CHECK-LABEL: foo10
330 // CHECK-SAME: vector<30xi64>
332 // -----
334 // Test `!fir.boxchar<n>` conversion
336 func.func private @foo0(%arg0: !fir.boxchar<1>)
337 // CHECK-LABEL: foo0
338 // CHECK-SAME: !llvm.struct<(ptr, i64)>
340 func.func private @foo1(%arg0: !fir.boxchar<2>)
341 // CHECK-LABEL: foo1
342 // CHECK-SAME: !llvm.struct<(ptr, i64)>
344 // -----
346 // Test `!fir.field` conversion
348 func.func private @foo0(%arg0: !fir.field)
349 // CHECK-LABEL: foo0
350 // CHECK-SAME: i32
352 // -----
354 // Test `!fir.len` conversion.
356 func.func private @foo0(%arg0: !fir.len)
357 // CHECK-LABEL: foo0
358 // CHECK-SAME: i64
360 // -----
362 // Test `!fir.tdesc` conversion.
364 func.func private @foo0(%arg0: !fir.tdesc<!fir.type<x>>)
365 // CHECK-LABEL: foo0
366 // CHECK-SAME:  !llvm.ptr
368 func.func private @foo1(%arg : !fir.tdesc<!fir.array<100xf32>>)
369 // CHECK-LABEL: foo1
370 // CHECK-SAME:  !llvm.ptr
372 func.func private @foo2(%arg : !fir.tdesc<f32>)
373 // CHECK-LABEL: foo2
374 // CHECK-SAME:  !llvm.ptr
376 func.func private @foo3(%arg : !fir.tdesc<!fir.type<derived7{f1:f32,f2:f32}>>)
377 // CHECK-LABEL: foo3
378 // CHECK-SAME:  !llvm.ptr
380 // -----
382 // Test nested tuple types
383 func.func private @foo0(%arg0: tuple<i64, tuple<f32, i64>>)
384 // CHECK-LABEL: foo0
385 // CHECK-SAME: !llvm.struct<(i64, struct<(f32, i64)>)>
387 // -----
389 // Test that fir.box inside tuple and derived type are lowered to struct type.
390 func.func private @foo0(%arg0: tuple<i64, !fir.box<i32>>)
391 // CHECK-LABEL: foo0
392 // CHECK-SAME: !llvm.struct<(i64, struct<(ptr, i{{.*}})>)>
394 func.func private @foo1(%arg0: !fir.type<derived8{a:i64,b:!fir.box<i32>}>)
395 // CHECK-LABEL: foo1
396 // CHECK-SAME: !llvm.struct<"derived8", (i64, struct<(ptr, i{{.*}})>)>
398 // -----
400 // Test fir.box<none> translation.
401 // `none` is used for polymorphic type.
402 func.func private @foo0(%arg0: !fir.box<none>)
403 // CHECK-LABEL: foo0
404 // CHECK-SAME: !llvm.ptr)