Migrate abi-sysv64 abi-sysv64-register-usage test to asm!

This commit is contained in:
Tomasz Miąsko 2022-01-12 00:00:00 +00:00
parent 0b315250b8
commit cc20dd49de

View file

@ -5,9 +5,7 @@
// ignore-android
// ignore-arm
// ignore-aarch64
#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!
#![feature(asm_sym)]
#[cfg(target_arch = "x86_64")]
pub extern "sysv64" fn all_the_registers(rdi: i64, rsi: i64, rdx: i64,
@ -54,37 +52,37 @@ pub extern "sysv64" fn large_struct_by_val(mut foo: LargeStruct) -> LargeStruct
#[cfg(target_arch = "x86_64")]
pub fn main() {
use std::arch::asm;
let result: i64;
unsafe {
llvm_asm!("mov rdi, 1;
mov rsi, 2;
mov rdx, 3;
mov rcx, 4;
mov r8, 5;
mov r9, 6;
mov eax, 0x3F800000;
movd xmm0, eax;
mov eax, 0x40000000;
movd xmm1, eax;
mov eax, 0x40800000;
movd xmm2, eax;
mov eax, 0x41000000;
movd xmm3, eax;
mov eax, 0x41800000;
movd xmm4, eax;
mov eax, 0x42000000;
movd xmm5, eax;
mov eax, 0x42800000;
movd xmm6, eax;
mov eax, 0x43000000;
movd xmm7, eax;
call r10
"
: "={rax}"(result)
: "{r10}"(all_the_registers as usize)
: "rdi", "rsi", "rdx", "rcx", "r8", "r9", "r11", "cc", "memory"
: "intel", "alignstack"
)
asm!("mov rdi, 1",
"mov rsi, 2",
"mov rdx, 3",
"mov rcx, 4",
"mov r8, 5",
"mov r9, 6",
"mov eax, 0x3F800000",
"movd xmm0, eax",
"mov eax, 0x40000000",
"movd xmm1, eax",
"mov eax, 0x40800000",
"movd xmm2, eax",
"mov eax, 0x41000000",
"movd xmm3, eax",
"mov eax, 0x41800000",
"movd xmm4, eax",
"mov eax, 0x42000000",
"movd xmm5, eax",
"mov eax, 0x42800000",
"movd xmm6, eax",
"mov eax, 0x43000000",
"movd xmm7, eax",
"call {0}",
sym all_the_registers,
out("rax") result,
clobber_abi("sysv64"),
);
}
assert_eq!(result, 42);