1 // compile-flags: -C no-prepopulate-passes
2 // only-loongarch64
3 // only-linux
4
5 #![crate_type = "lib"]
6
7 // CHECK: define void @f_fpr_tracking(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, i8 noundef zeroext %i)
8 #[no_mangle]
f_fpr_tracking( a: f64, b: f64, c: f64, d: f64, e: f64, f: f64, g: f64, h: f64, i: u8, )9 pub extern "C" fn f_fpr_tracking(
10 a: f64,
11 b: f64,
12 c: f64,
13 d: f64,
14 e: f64,
15 f: f64,
16 g: f64,
17 h: f64,
18 i: u8,
19 ) {
20 }
21
22 #[repr(C)]
23 pub struct Double {
24 f: f64,
25 }
26
27 #[repr(C)]
28 pub struct DoubleDouble {
29 f: f64,
30 g: f64,
31 }
32
33 #[repr(C)]
34 pub struct DoubleFloat {
35 f: f64,
36 g: f32,
37 }
38
39 // CHECK: define void @f_double_s_arg(double %0)
40 #[no_mangle]
f_double_s_arg(a: Double)41 pub extern "C" fn f_double_s_arg(a: Double) {}
42
43 // CHECK: define double @f_ret_double_s()
44 #[no_mangle]
f_ret_double_s() -> Double45 pub extern "C" fn f_ret_double_s() -> Double {
46 Double { f: 1. }
47 }
48
49 // CHECK: define void @f_double_double_s_arg({ double, double } %0)
50 #[no_mangle]
f_double_double_s_arg(a: DoubleDouble)51 pub extern "C" fn f_double_double_s_arg(a: DoubleDouble) {}
52
53 // CHECK: define { double, double } @f_ret_double_double_s()
54 #[no_mangle]
f_ret_double_double_s() -> DoubleDouble55 pub extern "C" fn f_ret_double_double_s() -> DoubleDouble {
56 DoubleDouble { f: 1., g: 2. }
57 }
58
59 // CHECK: define void @f_double_float_s_arg({ double, float } %0)
60 #[no_mangle]
f_double_float_s_arg(a: DoubleFloat)61 pub extern "C" fn f_double_float_s_arg(a: DoubleFloat) {}
62
63 // CHECK: define { double, float } @f_ret_double_float_s()
64 #[no_mangle]
f_ret_double_float_s() -> DoubleFloat65 pub extern "C" fn f_ret_double_float_s() -> DoubleFloat {
66 DoubleFloat { f: 1., g: 2. }
67 }
68
69 // CHECK: define void @f_double_double_s_arg_insufficient_fprs(double %0, double %1, double %2, double %3, double %4, double %5, double %6, [2 x i64] %7)
70 #[no_mangle]
f_double_double_s_arg_insufficient_fprs( a: f64, b: f64, c: f64, d: f64, e: f64, f: f64, g: f64, h: DoubleDouble, )71 pub extern "C" fn f_double_double_s_arg_insufficient_fprs(
72 a: f64,
73 b: f64,
74 c: f64,
75 d: f64,
76 e: f64,
77 f: f64,
78 g: f64,
79 h: DoubleDouble,
80 ) {
81 }
82
83 #[repr(C)]
84 pub struct DoubleInt8 {
85 f: f64,
86 i: i8,
87 }
88
89 #[repr(C)]
90 pub struct DoubleUInt8 {
91 f: f64,
92 i: u8,
93 }
94
95 #[repr(C)]
96 pub struct DoubleInt32 {
97 f: f64,
98 i: i32,
99 }
100
101 #[repr(C)]
102 pub struct DoubleInt64 {
103 f: f64,
104 i: i64,
105 }
106
107 // CHECK: define void @f_double_int8_s_arg({ double, i8 } %0)
108 #[no_mangle]
f_double_int8_s_arg(a: DoubleInt8)109 pub extern "C" fn f_double_int8_s_arg(a: DoubleInt8) {}
110
111 // CHECK: define { double, i8 } @f_ret_double_int8_s()
112 #[no_mangle]
f_ret_double_int8_s() -> DoubleInt8113 pub extern "C" fn f_ret_double_int8_s() -> DoubleInt8 {
114 DoubleInt8 { f: 1., i: 2 }
115 }
116
117 // CHECK: define void @f_double_int32_s_arg({ double, i32 } %0)
118 #[no_mangle]
f_double_int32_s_arg(a: DoubleInt32)119 pub extern "C" fn f_double_int32_s_arg(a: DoubleInt32) {}
120
121 // CHECK: define { double, i32 } @f_ret_double_int32_s()
122 #[no_mangle]
f_ret_double_int32_s() -> DoubleInt32123 pub extern "C" fn f_ret_double_int32_s() -> DoubleInt32 {
124 DoubleInt32 { f: 1., i: 2 }
125 }
126
127 // CHECK: define void @f_double_uint8_s_arg({ double, i8 } %0)
128 #[no_mangle]
f_double_uint8_s_arg(a: DoubleUInt8)129 pub extern "C" fn f_double_uint8_s_arg(a: DoubleUInt8) {}
130
131 // CHECK: define { double, i8 } @f_ret_double_uint8_s()
132 #[no_mangle]
f_ret_double_uint8_s() -> DoubleUInt8133 pub extern "C" fn f_ret_double_uint8_s() -> DoubleUInt8 {
134 DoubleUInt8 { f: 1., i: 2 }
135 }
136
137 // CHECK: define void @f_double_int64_s_arg({ double, i64 } %0)
138 #[no_mangle]
f_double_int64_s_arg(a: DoubleInt64)139 pub extern "C" fn f_double_int64_s_arg(a: DoubleInt64) {}
140
141 // CHECK: define { double, i64 } @f_ret_double_int64_s()
142 #[no_mangle]
f_ret_double_int64_s() -> DoubleInt64143 pub extern "C" fn f_ret_double_int64_s() -> DoubleInt64 {
144 DoubleInt64 { f: 1., i: 2 }
145 }
146
147 // CHECK: define void @f_double_int8_s_arg_insufficient_gprs(i32 noundef signext %a, i32 noundef signext %b, i32 noundef signext %c, i32 noundef signext %d, i32 noundef signext %e, i32 noundef signext %f, i32 noundef signext %g, i32 noundef signext %h, [2 x i64] %0)
148 #[no_mangle]
f_double_int8_s_arg_insufficient_gprs( a: i32, b: i32, c: i32, d: i32, e: i32, f: i32, g: i32, h: i32, i: DoubleInt8, )149 pub extern "C" fn f_double_int8_s_arg_insufficient_gprs(
150 a: i32,
151 b: i32,
152 c: i32,
153 d: i32,
154 e: i32,
155 f: i32,
156 g: i32,
157 h: i32,
158 i: DoubleInt8,
159 ) {
160 }
161
162 // CHECK: define void @f_struct_double_int8_insufficient_fprs(float %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, [2 x i64] %8)
163 #[no_mangle]
f_struct_double_int8_insufficient_fprs( a: f32, b: f64, c: f64, d: f64, e: f64, f: f64, g: f64, h: f64, i: DoubleInt8, )164 pub extern "C" fn f_struct_double_int8_insufficient_fprs(
165 a: f32,
166 b: f64,
167 c: f64,
168 d: f64,
169 e: f64,
170 f: f64,
171 g: f64,
172 h: f64,
173 i: DoubleInt8,
174 ) {
175 }
176
177 #[repr(C)]
178 pub struct DoubleArr1 {
179 a: [f64; 1],
180 }
181
182 // CHECK: define void @f_doublearr1_s_arg(double %0)
183 #[no_mangle]
f_doublearr1_s_arg(a: DoubleArr1)184 pub extern "C" fn f_doublearr1_s_arg(a: DoubleArr1) {}
185
186 // CHECK: define double @f_ret_doublearr1_s()
187 #[no_mangle]
f_ret_doublearr1_s() -> DoubleArr1188 pub extern "C" fn f_ret_doublearr1_s() -> DoubleArr1 {
189 DoubleArr1 { a: [1.] }
190 }
191
192 #[repr(C)]
193 pub struct DoubleArr2 {
194 a: [f64; 2],
195 }
196
197 // CHECK: define void @f_doublearr2_s_arg({ double, double } %0)
198 #[no_mangle]
f_doublearr2_s_arg(a: DoubleArr2)199 pub extern "C" fn f_doublearr2_s_arg(a: DoubleArr2) {}
200
201 // CHECK: define { double, double } @f_ret_doublearr2_s()
202 #[no_mangle]
f_ret_doublearr2_s() -> DoubleArr2203 pub extern "C" fn f_ret_doublearr2_s() -> DoubleArr2 {
204 DoubleArr2 { a: [1., 2.] }
205 }
206
207 #[repr(C)]
208 pub struct Tricky1 {
209 f: [f64; 1],
210 }
211
212 #[repr(C)]
213 pub struct DoubleArr2Tricky1 {
214 g: [Tricky1; 2],
215 }
216
217 // CHECK: define void @f_doublearr2_tricky1_s_arg({ double, double } %0)
218 #[no_mangle]
f_doublearr2_tricky1_s_arg(a: DoubleArr2Tricky1)219 pub extern "C" fn f_doublearr2_tricky1_s_arg(a: DoubleArr2Tricky1) {}
220
221 // CHECK: define { double, double } @f_ret_doublearr2_tricky1_s()
222 #[no_mangle]
f_ret_doublearr2_tricky1_s() -> DoubleArr2Tricky1223 pub extern "C" fn f_ret_doublearr2_tricky1_s() -> DoubleArr2Tricky1 {
224 DoubleArr2Tricky1 { g: [Tricky1 { f: [1.] }, Tricky1 { f: [2.] }] }
225 }
226
227 #[repr(C)]
228 pub struct EmptyStruct {}
229
230 #[repr(C)]
231 pub struct DoubleArr2Tricky2 {
232 s: EmptyStruct,
233 g: [Tricky1; 2],
234 }
235
236 // CHECK: define void @f_doublearr2_tricky2_s_arg({ double, double } %0)
237 #[no_mangle]
f_doublearr2_tricky2_s_arg(a: DoubleArr2Tricky2)238 pub extern "C" fn f_doublearr2_tricky2_s_arg(a: DoubleArr2Tricky2) {}
239
240 // CHECK: define { double, double } @f_ret_doublearr2_tricky2_s()
241 #[no_mangle]
f_ret_doublearr2_tricky2_s() -> DoubleArr2Tricky2242 pub extern "C" fn f_ret_doublearr2_tricky2_s() -> DoubleArr2Tricky2 {
243 DoubleArr2Tricky2 { s: EmptyStruct {}, g: [Tricky1 { f: [1.] }, Tricky1 { f: [2.] }] }
244 }
245
246 #[repr(C)]
247 pub struct IntDoubleInt {
248 a: i32,
249 b: f64,
250 c: i32,
251 }
252
253 // CHECK: define void @f_int_double_int_s_arg(ptr noalias nocapture noundef dereferenceable(24) %a)
254 #[no_mangle]
f_int_double_int_s_arg(a: IntDoubleInt)255 pub extern "C" fn f_int_double_int_s_arg(a: IntDoubleInt) {}
256
257 // CHECK: define void @f_ret_int_double_int_s(ptr noalias nocapture noundef sret(%IntDoubleInt) dereferenceable(24) %0)
258 #[no_mangle]
f_ret_int_double_int_s() -> IntDoubleInt259 pub extern "C" fn f_ret_int_double_int_s() -> IntDoubleInt {
260 IntDoubleInt { a: 1, b: 2., c: 3 }
261 }
262
263 #[repr(C)]
264 pub struct CharCharDouble {
265 a: u8,
266 b: u8,
267 c: f64,
268 }
269
270 // CHECK: define void @f_char_char_double_s_arg([2 x i64] %0)
271 #[no_mangle]
f_char_char_double_s_arg(a: CharCharDouble)272 pub extern "C" fn f_char_char_double_s_arg(a: CharCharDouble) {}
273
274 // CHECK: define [2 x i64] @f_ret_char_char_double_s()
275 #[no_mangle]
f_ret_char_char_double_s() -> CharCharDouble276 pub extern "C" fn f_ret_char_char_double_s() -> CharCharDouble {
277 CharCharDouble { a: 1, b: 2, c: 3. }
278 }
279
280 #[repr(C)]
281 pub union DoubleU {
282 a: f64,
283 }
284
285 // CHECK: define void @f_double_u_arg(i64 %0)
286 #[no_mangle]
f_double_u_arg(a: DoubleU)287 pub extern "C" fn f_double_u_arg(a: DoubleU) {}
288
289 // CHECK: define i64 @f_ret_double_u()
290 #[no_mangle]
f_ret_double_u() -> DoubleU291 pub extern "C" fn f_ret_double_u() -> DoubleU {
292 unsafe { DoubleU { a: 1. } }
293 }
294