]> git.lizzy.rs Git - rust.git/blob - src/test/assembly/sparc-struct-abi.rs
Rollup merge of #94633 - TaKO8Ki:suggest-removing-semicolon-after-derive-attribute...
[rust.git] / src / test / assembly / sparc-struct-abi.rs
1 // Test SPARC64 ABI
2 // - float structure members are passes in floating point registers
3 // (#86163)
4
5 // assembly-output: emit-asm
6 // needs-llvm-components: sparc
7 // compile-flags: --target=sparcv9-sun-solaris -Copt-level=3
8 #![crate_type = "lib"]
9 #![feature(no_core, lang_items)]
10 #![no_core]
11
12 #[lang = "sized"]
13 pub trait Sized {}
14 #[lang = "copy"]
15 pub trait Copy {}
16
17 #[repr(C)]
18 pub struct Franta {
19     a: f32,
20     b: f32,
21     c: f32,
22     d: f32,
23 }
24
25 // NB: due to delay slots the `ld` following the call is actually executed before the call.
26 #[no_mangle]
27 pub unsafe extern "C" fn callee(arg: Franta) {
28     // CHECK-LABEL: callee:
29     // CHECK: st %f3, [[PLACE_D:.*]]
30     // CHECK: st %f2, [[PLACE_C:.*]]
31     // CHECK: st %f1, [[PLACE_B:.*]]
32     // CHECK: st %f0, [[PLACE_A:.*]]
33     // CHECK: call tst_use
34     // CHECK-NEXT: ld [[PLACE_A]], %f1
35     // CHECK: call tst_use
36     // CHECK-NEXT: ld [[PLACE_B]], %f1
37     // CHECK: call tst_use
38     // CHECK-NEXT: ld [[PLACE_C]], %f1
39     // CHECK: call tst_use
40     // CHECK-NEXT: ld [[PLACE_D]], %f1
41     clobber();
42     tst_use(arg.a);
43     tst_use(arg.b);
44     tst_use(arg.c);
45     tst_use(arg.d);
46 }
47
48 extern "C" {
49     fn opaque_callee(arg: Franta, intarg: i32);
50     fn tst_use(arg: f32);
51     fn clobber();
52 }
53
54 #[no_mangle]
55 pub unsafe extern "C" fn caller() {
56     // CHECK-LABEL: caller:
57     // CHECK: ld [{{.*}}], %f0
58     // CHECK: ld [{{.*}}], %f1
59     // CHECK: ld [{{.*}}], %f2
60     // CHECK: ld [{{.*}}], %f3
61     // CHECK: call opaque_callee
62     // CHECK: mov     3, %o2
63     opaque_callee(Franta { a: 1.0, b: 2.0, c: 3.0, d: 4.0 }, 3);
64 }