]> git.lizzy.rs Git - rust.git/blob - tests/assembly/sparc-struct-abi.rs
Rollup merge of #107740 - oli-obk:lock_tcx, r=petrochenkov
[rust.git] / tests / 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 impl Copy for f32 {}
17
18 #[repr(C)]
19 pub struct Franta {
20     a: f32,
21     b: f32,
22     c: f32,
23     d: f32,
24 }
25
26 // NB: due to delay slots the `ld` following the call is actually executed before the call.
27 #[no_mangle]
28 pub unsafe extern "C" fn callee(arg: Franta) {
29     // CHECK-LABEL: callee:
30     // CHECK: st %f3, [[PLACE_D:.*]]
31     // CHECK: st %f2, [[PLACE_C:.*]]
32     // CHECK: st %f1, [[PLACE_B:.*]]
33     // CHECK: st %f0, [[PLACE_A:.*]]
34     // CHECK: call tst_use
35     // CHECK-NEXT: ld [[PLACE_A]], %f1
36     // CHECK: call tst_use
37     // CHECK-NEXT: ld [[PLACE_B]], %f1
38     // CHECK: call tst_use
39     // CHECK-NEXT: ld [[PLACE_C]], %f1
40     // CHECK: call tst_use
41     // CHECK-NEXT: ld [[PLACE_D]], %f1
42     clobber();
43     tst_use(arg.a);
44     tst_use(arg.b);
45     tst_use(arg.c);
46     tst_use(arg.d);
47     tail_call_avoidance_fn();
48 }
49
50 extern "C" {
51     fn opaque_callee(arg: Franta, intarg: i32);
52     fn tst_use(arg: f32);
53     fn clobber();
54     // This exists so that post-https://reviews.llvm.org/D138741 LLVM doesn't
55     // tail-call away some of our assertions.
56     fn tail_call_avoidance_fn();
57 }
58
59 #[no_mangle]
60 pub unsafe extern "C" fn caller() {
61     // CHECK-LABEL: caller:
62     // CHECK: ld [{{.*}}], %f0
63     // CHECK: ld [{{.*}}], %f1
64     // CHECK: ld [{{.*}}], %f2
65     // CHECK: ld [{{.*}}], %f3
66     // CHECK: call opaque_callee
67     // CHECK: mov     3, %o2
68     opaque_callee(Franta { a: 1.0, b: 2.0, c: 3.0, d: 4.0 }, 3);
69     tail_call_avoidance_fn();
70 }