2 // Checks if the correct registers are being used to pass arguments
3 // when the sysv64 ABI is specified.
10 #![allow(deprecated)] // llvm_asm!
12 #[cfg(target_arch = "x86_64")]
13 pub extern "sysv64" fn all_the_registers(rdi: i64, rsi: i64, rdx: i64,
14 rcx: i64, r8 : i64, r9 : i64,
15 xmm0: f32, xmm1: f32, xmm2: f32,
16 xmm3: f32, xmm4: f32, xmm5: f32,
17 xmm6: f32, xmm7: f32) -> i64 {
24 assert_eq!(xmm0, 1.0f32);
25 assert_eq!(xmm1, 2.0f32);
26 assert_eq!(xmm2, 4.0f32);
27 assert_eq!(xmm3, 8.0f32);
28 assert_eq!(xmm4, 16.0f32);
29 assert_eq!(xmm5, 32.0f32);
30 assert_eq!(xmm6, 64.0f32);
31 assert_eq!(xmm7, 128.0f32);
35 // this struct contains 8 i64's, while only 6 can be passed in registers.
36 #[cfg(target_arch = "x86_64")]
37 #[derive(PartialEq, Eq, Debug)]
38 pub struct LargeStruct(i64, i64, i64, i64, i64, i64, i64, i64);
40 #[cfg(target_arch = "x86_64")]
42 #[allow(improper_ctypes_definitions)]
43 pub extern "sysv64" fn large_struct_by_val(mut foo: LargeStruct) -> LargeStruct {
55 #[cfg(target_arch = "x86_64")]
59 llvm_asm!("mov rdi, 1;
84 : "{r10}"(all_the_registers as usize)
85 : "rdi", "rsi", "rdx", "rcx", "r8", "r9", "r11", "cc", "memory"
86 : "intel", "alignstack"
89 assert_eq!(result, 42);
92 large_struct_by_val(LargeStruct(1, 2, 3, 4, 5, 6, 7, 8)),
93 LargeStruct(1, 4, 9, 16, 25, 36, 49, 64)
97 #[cfg(not(target_arch = "x86_64"))]