]> git.lizzy.rs Git - rust.git/blob - tests/codegen/riscv-abi/riscv64-lp64f-lp64d-abi.rs
Rollup merge of #106960 - estebank:parse-anon-enums, r=cjgillot
[rust.git] / tests / codegen / riscv-abi / riscv64-lp64f-lp64d-abi.rs
1 //
2 // compile-flags: -C no-prepopulate-passes
3 // only-riscv64
4 // only-linux
5 #![crate_type = "lib"]
6
7 // CHECK: define void @f_fpr_tracking(float %0, float %1, float %2, float %3, float %4, float %5, float %6, float %7, i8 zeroext %i)
8 #[no_mangle]
9 pub extern "C" fn f_fpr_tracking(
10     a: f32,
11     b: f32,
12     c: f32,
13     d: f32,
14     e: f32,
15     f: f32,
16     g: f32,
17     h: f32,
18     i: u8,
19 ) {
20 }
21
22 #[repr(C)]
23 pub struct Float {
24     f: f32,
25 }
26
27 #[repr(C)]
28 pub struct FloatFloat {
29     f: f32,
30     g: f32,
31 }
32
33 // CHECK: define void @f_float_s_arg(float %0)
34 #[no_mangle]
35 pub extern "C" fn f_float_s_arg(a: Float) {}
36
37 // CHECK: define float @f_ret_float_s()
38 #[no_mangle]
39 pub extern "C" fn f_ret_float_s() -> Float {
40     Float { f: 1. }
41 }
42
43 // CHECK: define void @f_float_float_s_arg({ float, float } %0)
44 #[no_mangle]
45 pub extern "C" fn f_float_float_s_arg(a: FloatFloat) {}
46
47 // CHECK: define { float, float } @f_ret_float_float_s()
48 #[no_mangle]
49 pub extern "C" fn f_ret_float_float_s() -> FloatFloat {
50     FloatFloat { f: 1., g: 2. }
51 }
52
53 // CHECK: define void @f_float_float_s_arg_insufficient_fprs(float %0, float %1, float %2, float %3, float %4, float %5, float %6, i64 %7)
54 #[no_mangle]
55 pub extern "C" fn f_float_float_s_arg_insufficient_fprs(
56     a: f32,
57     b: f32,
58     c: f32,
59     d: f32,
60     e: f32,
61     f: f32,
62     g: f32,
63     h: FloatFloat,
64 ) {
65 }
66
67 #[repr(C)]
68 pub struct FloatInt8 {
69     f: f32,
70     i: i8,
71 }
72
73 #[repr(C)]
74 pub struct FloatUInt8 {
75     f: f32,
76     i: u8,
77 }
78
79 #[repr(C)]
80 pub struct FloatInt32 {
81     f: f32,
82     i: i32,
83 }
84
85 #[repr(C)]
86 pub struct FloatInt64 {
87     f: f32,
88     i: i64,
89 }
90
91 // CHECK: define void @f_float_int8_s_arg({ float, i8 } %0)
92 #[no_mangle]
93 pub extern "C" fn f_float_int8_s_arg(a: FloatInt8) {}
94
95 // CHECK: define { float, i8 } @f_ret_float_int8_s()
96 #[no_mangle]
97 pub extern "C" fn f_ret_float_int8_s() -> FloatInt8 {
98     FloatInt8 { f: 1., i: 2 }
99 }
100
101 // CHECK: define void @f_float_int32_s_arg({ float, i32 } %0)
102 #[no_mangle]
103 pub extern "C" fn f_float_int32_s_arg(a: FloatInt32) {}
104
105 // CHECK: define { float, i32 } @f_ret_float_int32_s()
106 #[no_mangle]
107 pub extern "C" fn f_ret_float_int32_s() -> FloatInt32 {
108     FloatInt32 { f: 1., i: 2 }
109 }
110
111 // CHECK: define void @f_float_uint8_s_arg({ float, i8 } %0)
112 #[no_mangle]
113 pub extern "C" fn f_float_uint8_s_arg(a: FloatUInt8) {}
114
115 // CHECK: define { float, i8 } @f_ret_float_uint8_s()
116 #[no_mangle]
117 pub extern "C" fn f_ret_float_uint8_s() -> FloatUInt8 {
118     FloatUInt8 { f: 1., i: 2 }
119 }
120
121 // CHECK: define void @f_float_int64_s_arg({ float, i64 } %0)
122 #[no_mangle]
123 pub extern "C" fn f_float_int64_s_arg(a: FloatInt64) {}
124
125 // CHECK: define { float, i64 } @f_ret_float_int64_s()
126 #[no_mangle]
127 pub extern "C" fn f_ret_float_int64_s() -> FloatInt64 {
128     FloatInt64 { f: 1., i: 2 }
129 }
130
131 // CHECK: define void @f_float_int8_s_arg_insufficient_gprs(i32 signext %a, i32 signext %b, i32 signext %c, i32 signext %d, i32 signext %e, i32 signext %f, i32 signext %g, i32 signext %h, i64 %0)
132 #[no_mangle]
133 pub extern "C" fn f_float_int8_s_arg_insufficient_gprs(
134     a: i32,
135     b: i32,
136     c: i32,
137     d: i32,
138     e: i32,
139     f: i32,
140     g: i32,
141     h: i32,
142     i: FloatInt8,
143 ) {
144 }
145
146 // CHECK: define void @f_struct_float_int8_insufficient_fprs(float %0, float %1, float %2,  float %3, float %4, float %5, float %6, float %7, i64 %8)
147 #[no_mangle]
148 pub extern "C" fn f_struct_float_int8_insufficient_fprs(
149     a: f32,
150     b: f32,
151     c: f32,
152     d: f32,
153     e: f32,
154     f: f32,
155     g: f32,
156     h: f32,
157     i: FloatInt8,
158 ) {
159 }
160
161 #[repr(C)]
162 pub struct FloatArr1 {
163     a: [f32; 1],
164 }
165
166 // CHECK: define void @f_floatarr1_s_arg(float %0)
167 #[no_mangle]
168 pub extern "C" fn f_floatarr1_s_arg(a: FloatArr1) {}
169
170 // CHECK: define float @f_ret_floatarr1_s()
171 #[no_mangle]
172 pub extern "C" fn f_ret_floatarr1_s() -> FloatArr1 {
173     FloatArr1 { a: [1.] }
174 }
175
176 #[repr(C)]
177 pub struct FloatArr2 {
178     a: [f32; 2],
179 }
180
181 // CHECK: define void @f_floatarr2_s_arg({ float, float } %0)
182 #[no_mangle]
183 pub extern "C" fn f_floatarr2_s_arg(a: FloatArr2) {}
184
185 // CHECK: define { float, float } @f_ret_floatarr2_s()
186 #[no_mangle]
187 pub extern "C" fn f_ret_floatarr2_s() -> FloatArr2 {
188     FloatArr2 { a: [1., 2.] }
189 }
190
191 #[repr(C)]
192 pub struct Tricky1 {
193     f: [f32; 1],
194 }
195
196 #[repr(C)]
197 pub struct FloatArr2Tricky1 {
198     g: [Tricky1; 2],
199 }
200
201 // CHECK: define void @f_floatarr2_tricky1_s_arg({ float, float } %0)
202 #[no_mangle]
203 pub extern "C" fn f_floatarr2_tricky1_s_arg(a: FloatArr2Tricky1) {}
204
205 // CHECK: define { float, float } @f_ret_floatarr2_tricky1_s()
206 #[no_mangle]
207 pub extern "C" fn f_ret_floatarr2_tricky1_s() -> FloatArr2Tricky1 {
208     FloatArr2Tricky1 { g: [Tricky1 { f: [1.] }, Tricky1 { f: [2.] }] }
209 }
210
211 #[repr(C)]
212 pub struct EmptyStruct {}
213
214 #[repr(C)]
215 pub struct FloatArr2Tricky2 {
216     s: EmptyStruct,
217     g: [Tricky1; 2],
218 }
219
220 // CHECK: define void @f_floatarr2_tricky2_s_arg({ float, float } %0)
221 #[no_mangle]
222 pub extern "C" fn f_floatarr2_tricky2_s_arg(a: FloatArr2Tricky2) {}
223
224 // CHECK: define { float, float } @f_ret_floatarr2_tricky2_s()
225 #[no_mangle]
226 pub extern "C" fn f_ret_floatarr2_tricky2_s() -> FloatArr2Tricky2 {
227     FloatArr2Tricky2 { s: EmptyStruct {}, g: [Tricky1 { f: [1.] }, Tricky1 { f: [2.] }] }
228 }
229
230 #[repr(C)]
231 pub struct IntFloatInt {
232     a: i32,
233     b: f32,
234     c: i32,
235 }
236
237 // CHECK: define void @f_int_float_int_s_arg([2 x i64] %0)
238 #[no_mangle]
239 pub extern "C" fn f_int_float_int_s_arg(a: IntFloatInt) {}
240
241 // CHECK: define [2 x i64] @f_ret_int_float_int_s()
242 #[no_mangle]
243 pub extern "C" fn f_ret_int_float_int_s() -> IntFloatInt {
244     IntFloatInt { a: 1, b: 2., c: 3 }
245 }
246
247 #[repr(C)]
248 pub struct CharCharFloat {
249     a: u8,
250     b: u8,
251     c: f32,
252 }
253
254 // CHECK: define void @f_char_char_float_s_arg(i64 %0)
255 #[no_mangle]
256 pub extern "C" fn f_char_char_float_s_arg(a: CharCharFloat) {}
257
258 // CHECK: define i64 @f_ret_char_char_float_s()
259 #[no_mangle]
260 pub extern "C" fn f_ret_char_char_float_s() -> CharCharFloat {
261     CharCharFloat { a: 1, b: 2, c: 3. }
262 }
263
264 #[repr(C)]
265 pub union FloatU {
266     a: f32,
267 }
268
269 // CHECK: define void @f_float_u_arg(i64 %0)
270 #[no_mangle]
271 pub extern "C" fn f_float_u_arg(a: FloatU) {}
272
273 // CHECK: define i64 @f_ret_float_u()
274 #[no_mangle]
275 pub extern "C" fn f_ret_float_u() -> FloatU {
276     unsafe { FloatU { a: 1. } }
277 }