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>)
11 // CHECK-SAME: !llvm.array<12 x array<10 x i64>>
12 func.func private @foo1(%arg0: !fir.array<?xf32>)
15 func.func private @foo2(%arg0: !fir.array<?x?xf128>)
18 func.func private @foo3(%arg0: !fir.array<*:i32>)
21 func.func private @foo4(%arg0: !fir.array<3x?xi32>)
24 func.func private @foo5(%arg0: !fir.array<?x6xi32>)
27 func.func private @foo6(%arg0: !fir.array<2x?x3x?x4xi32>)
29 // CHECK-SAME: !llvm.array<2 x i32>
30 func.func private @foo7(%arg0: !fir.array<6x?x!fir.char<1,?>>)
33 func.func private @foo8(%arg0: !fir.array<6x?x!fir.char<1,3>>)
35 // CHECK-SAME: !llvm.array<6 x array<3 x i8>>
39 // Test reference types `!fir.ref`
41 func.func private @foo0(%arg0: !fir.ref<i32>)
43 // CHECK-SAME: !llvm.ptr
44 func.func private @foo1(%arg0: !fir.ref<!fir.array<10xf32>>)
46 // CHECK-SAME: !llvm.ptr
47 func.func private @foo2(%arg0: !fir.ref<!fir.box<!fir.heap<!fir.type<_QMs1Ta1{x:i32,y:f32}>>>>)
49 // CHECK-SAME: !llvm.ptr
50 func.func private @foo3(%arg0: !fir.ref<!fir.array<10x?x11xf32>>)
52 // CHECK-SAME: !llvm.ptr
53 func.func private @foo4(%arg0: !fir.ref<!fir.array<10x11x?x?xf32>>)
55 // CHECK-SAME: !llvm.ptr
56 func.func private @foo5(%arg0: !fir.ref<!fir.array<10x!fir.char<1,?>>>)
58 // CHECK-SAME: !llvm.ptr
59 func.func private @foo6(%arg0: !fir.ref<!fir.array<10x!fir.char<2,8>>>)
61 // CHECK-SAME: !llvm.ptr
62 func.func private @foo7(%arg0: !fir.ref<!fir.box<!fir.array<?xf32>>>)
64 // CHECK-SAME: !llvm.ptr
68 // Test pointer types `!fir.ptr`
70 func.func private @foo0(%arg0: !fir.ptr<i32>)
72 // CHECK-SAME: !llvm.ptr
74 func.func private @foo1(%arg0: !fir.ptr<!fir.array<10xf32>>)
76 // CHECK-SAME: !llvm.ptr
80 // Test box types `!fir.box`
82 func.func private @foo0(%arg0: !fir.box<!fir.array<?xf32>>)
84 // CHECK-SAME: !llvm.ptr
86 func.func private @foo1(%arg0: !fir.box<!fir.array<10xf32>>)
88 // CHECK-SAME: !llvm.ptr
90 func.func private @foo2(%arg0: !fir.box<!fir.ref<i64>>)
92 // CHECK-SAME: !llvm.ptr
94 func.func private @foo3(%arg0: !fir.box<!fir.type<derived{f:f32}>>)
96 // CHECK-SAME: !llvm.ptr
98 func.func private @foo4(%arg0: !fir.box<!fir.heap<!fir.type<_QMs1Ta1{x:i32,y:f32}>>>)
100 // CHECK-SAME: !llvm.ptr
104 // Test char types `!fir.char<k, n>`
106 func.func private @foo0(%arg0: !fir.char<1, 4>, %arg1: !fir.char<1, ?>)
108 // CHECK-SAME: !llvm.array<4 x i8>
111 func.func private @foo1(%arg0: !fir.char<2, 12>, %arg1: !fir.char<2, ?>)
113 // CHECK-SAME: !llvm.array<12 x i16>
116 func.func private @foo2(%arg0: !fir.char<4, 8>, %arg1: !fir.char<4, ?>)
118 // CHECK-SAME: !llvm.array<8 x i32>
123 // Test `!fir.heap<>` conversion.
124 func.func private @foo0(%arg0: !fir.heap<i32>)
126 // CHECK-SAME: !llvm.ptr
128 func.func private @foo1(%arg0: !fir.heap<!fir.array<4xf32>>)
130 // CHECK-SAME: !llvm.ptr
132 func.func private @foo2(%arg0: !fir.heap<!fir.array<?xf32>>)
134 // CHECK-SAME: !llvm.ptr
136 func.func private @foo3(%arg0: !fir.heap<!fir.char<1,10>>)
138 // CHECK-SAME: !llvm.ptr
140 func.func private @foo4(%arg0: !fir.heap<!fir.char<1,?>>)
142 // CHECK-SAME: !llvm.ptr
144 func.func private @foo5(%arg0: !fir.heap<!fir.array<2xf32>>)
146 // CHECK-SAME: !llvm.ptr
148 func.func private @foo6(%arg0: !fir.heap<!fir.array<?x?xf32>>)
150 // CHECK-SAME: !llvm.ptr
152 func.func private @foo7(%arg0: !fir.heap<!fir.type<ZT>>)
154 // CHECK-SAME: !llvm.ptr
156 func.func private @foo8(%arg0: !fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>)
158 // CHECK-SAME: !llvm.ptr
162 // Test `!fir.integer<KIND>` conversion.
164 func.func private @foo0(%arg0: !fir.int<1>)
168 func.func private @foo1(%arg0: !fir.int<2>)
172 func.func private @foo2(%arg0: !fir.int<4>)
176 func.func private @foo3(%arg0: !fir.int<8>)
180 func.func private @foo4(%arg0: !fir.int<16>)
186 // Test `!fir.logical<KIND>` conversion.
188 func.func private @foo0(%arg0: !fir.logical<1>)
192 func.func private @foo1(%arg0: !fir.logical<2>)
196 func.func private @foo2(%arg0: !fir.logical<4>)
200 func.func private @foo3(%arg0: !fir.logical<8>)
204 func.func private @foo4(%arg0: !fir.logical<16>)
210 // Test `!fir.llvm_ptr` conversion.
212 func.func private @foo0(%arg0: !fir.llvm_ptr<i8>)
214 // CHECK-SAME: !llvm.ptr
216 func.func private @foo1(%arg0: !fir.llvm_ptr<!fir.ref<f32>>)
218 // CHECK-SAME: !llvm.ptr
220 func.func private @foo2(%arg0: !fir.llvm_ptr<!fir.ref<!fir.box<!fir.ptr<i32>>>>)
222 // CHECK-SAME: !llvm.ptr
224 func.func private @foo3(%arg0: !fir.llvm_ptr<!fir.ptr<f32>>)
226 // CHECK-SAME: !llvm.ptr
230 // Test MLIR `complex<KIND>` conversion.
232 func.func private @foo0(%arg0: complex<f16>)
234 // CHECK-SAME: !llvm.struct<(f16, f16)>)
236 func.func private @foo1(%arg0: complex<bf16>)
238 // CHECK-SAME: !llvm.struct<(bf16, bf16)>)
240 func.func private @foo2(%arg0: complex<f32>)
242 // CHECK-SAME: !llvm.struct<(f32, f32)>)
244 func.func private @foo3(%arg0: complex<f64>)
246 // CHECK-SAME: !llvm.struct<(f64, f64)>)
248 func.func private @foo4(%arg0: complex<f80>)
250 // CHECK-SAME: !llvm.struct<(f80, f80)>)
252 func.func private @foo5(%arg0: complex<f128>)
254 // CHECK-SAME: !llvm.struct<(f128, f128)>)
258 // Test `!fir.complex<KIND>` conversion.
260 func.func private @foo0(%arg0: complex<f16>)
262 // CHECK-SAME: !llvm.struct<(f16, f16)>)
264 func.func private @foo1(%arg0: complex<bf16>)
266 // CHECK-SAME: !llvm.struct<(bf16, bf16)>)
268 func.func private @foo2(%arg0: complex<f32>)
270 // CHECK-SAME: !llvm.struct<(f32, f32)>)
272 func.func private @foo3(%arg0: complex<f64>)
274 // CHECK-SAME: !llvm.struct<(f64, f64)>)
276 func.func private @foo4(%arg0: complex<f80>)
278 // CHECK-SAME: !llvm.struct<(f80, f80)>)
280 func.func private @foo5(%arg0: complex<f128>)
282 // CHECK-SAME: !llvm.struct<(f128, f128)>)
286 // Test `!fir.vector<>` conversion.
288 func.func private @foo0(%arg0: !fir.vector<2:f16>)
290 // CHECK-SAME: vector<2xf16>
292 func.func private @foo1(%arg0: !fir.vector<20:bf16>)
294 // CHECK-SAME: vector<20xbf16>
296 func.func private @foo2(%arg0: !fir.vector<30:f32>)
298 // CHECK-SAME: vector<30xf32>
300 func.func private @foo3(%arg0: !fir.vector<55:f64>)
302 // CHECK-SAME: vector<55xf64>
304 func.func private @foo4(%arg0: !fir.vector<15:f80>)
306 // CHECK-SAME: vector<15xf80>
308 func.func private @foo5(%arg0: !fir.vector<28:f128>)
310 // CHECK-SAME: vector<28xf128>
312 func.func private @foo6(%arg0: !fir.vector<100:i1>)
314 // CHECK-SAME: vector<100xi1>
316 func.func private @foo7(%arg0: !fir.vector<10:i8>)
318 // CHECK-SAME: vector<10xi8>
320 func.func private @foo8(%arg0: !fir.vector<12:i16>)
322 // CHECK-SAME: vector<12xi16>
324 func.func private @foo9(%arg0: !fir.vector<20:i32>)
326 // CHECK-SAME: vector<20xi32>
328 func.func private @foo10(%arg0: !fir.vector<30:i64>)
329 // CHECK-LABEL: foo10
330 // CHECK-SAME: vector<30xi64>
334 // Test `!fir.boxchar<n>` conversion
336 func.func private @foo0(%arg0: !fir.boxchar<1>)
338 // CHECK-SAME: !llvm.struct<(ptr, i64)>
340 func.func private @foo1(%arg0: !fir.boxchar<2>)
342 // CHECK-SAME: !llvm.struct<(ptr, i64)>
346 // Test `!fir.field` conversion
348 func.func private @foo0(%arg0: !fir.field)
354 // Test `!fir.len` conversion.
356 func.func private @foo0(%arg0: !fir.len)
362 // Test `!fir.tdesc` conversion.
364 func.func private @foo0(%arg0: !fir.tdesc<!fir.type<x>>)
366 // CHECK-SAME: !llvm.ptr
368 func.func private @foo1(%arg : !fir.tdesc<!fir.array<100xf32>>)
370 // CHECK-SAME: !llvm.ptr
372 func.func private @foo2(%arg : !fir.tdesc<f32>)
374 // CHECK-SAME: !llvm.ptr
376 func.func private @foo3(%arg : !fir.tdesc<!fir.type<derived7{f1:f32,f2:f32}>>)
378 // CHECK-SAME: !llvm.ptr
382 // Test nested tuple types
383 func.func private @foo0(%arg0: tuple<i64, tuple<f32, i64>>)
385 // CHECK-SAME: !llvm.struct<(i64, struct<(f32, i64)>)>
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>>)
392 // CHECK-SAME: !llvm.struct<(i64, struct<(ptr, i{{.*}})>)>
394 func.func private @foo1(%arg0: !fir.type<derived8{a:i64,b:!fir.box<i32>}>)
396 // CHECK-SAME: !llvm.struct<"derived8", (i64, struct<(ptr, i{{.*}})>)>
400 // Test fir.box<none> translation.
401 // `none` is used for polymorphic type.
402 func.func private @foo0(%arg0: !fir.box<none>)
404 // CHECK-SAME: !llvm.ptr)