Navigation Menu

Skip to content

Commit

Permalink
Migrate abi-sysv64 abi-sysv64-register-usage test to asm!
Browse files Browse the repository at this point in the history
  • Loading branch information
tmiasko committed Jan 12, 2022
1 parent 0b31525 commit cc20dd4
Showing 1 changed file with 30 additions and 32 deletions.
62 changes: 30 additions & 32 deletions src/test/ui/abi/abi-sysv64-register-usage.rs
Expand Up @@ -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,
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit cc20dd4

Please sign in to comment.