Skip to content

Commit

Permalink
Migrate asm! to llvm_asm!
Browse files Browse the repository at this point in the history
Replace uses of asm! with llvm_asm!, add the llvm_asm feature
[Tracking Issue for LLVM-style inline
assembly](rust-lang/rust#70173)
`cargo test` now passes for me with rustc 1.45.0-nightly
(9310e3bd4 2020-05-21)
  • Loading branch information
Paul Kernfeld authored and Xudong-Huang committed Jun 10, 2020
1 parent a414fbe commit 97ba715
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/detail/x86_64_unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ mod asm_impl {
/// prefetch data
#[inline]
pub unsafe extern "C" fn prefetch(data: *const usize) {
asm!(
llvm_asm!(
"prefetcht1 $0"
: // no output
: "m"(*data)
Expand All @@ -28,7 +28,7 @@ mod asm_impl {
#[naked]
#[inline(never)]
pub unsafe extern "C" fn bootstrap_green_task() {
asm!(
llvm_asm!(
"
mov %r12, %rdi // setup the function arg
mov %r13, %rsi // setup the function arg
Expand All @@ -46,7 +46,7 @@ mod asm_impl {
#[inline(never)]
pub unsafe extern "C" fn swap_registers(out_regs: *mut Registers, in_regs: *const Registers) {
// The first argument is in %rdi, and the second one is in %rsi
asm!(
llvm_asm!(
""
:
: "{rdi}"(out_regs), "{rsi}"(in_regs)
Expand All @@ -58,7 +58,7 @@ mod asm_impl {
#[naked]
unsafe extern "C" fn _swap_reg() {
// Save registers
asm!(
llvm_asm!(
"
mov %rbx, (0*8)(%rdi)
mov %rsp, (1*8)(%rdi)
Expand Down
8 changes: 4 additions & 4 deletions src/detail/x86_64_windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ mod asm_impl {
/// prefetch data
#[inline]
pub unsafe extern "C" fn prefetch_asm(data: *const usize) {
asm!(
llvm_asm!(
"prefetcht1 $0"
: // no output
: "m"(*data)
Expand All @@ -34,7 +34,7 @@ mod asm_impl {
#[naked]
#[inline(never)]
pub unsafe extern "C" fn bootstrap_green_task() {
asm!(
llvm_asm!(
"
mov %r12, %rcx // setup the function arg
mov %r13, %rdx // setup the function arg
Expand All @@ -52,7 +52,7 @@ mod asm_impl {
#[inline(never)]
pub unsafe extern "C" fn swap_registers(out_regs: *mut Registers, in_regs: *const Registers) {
// The first argument is in %rcx, and the second one is in %rdx
asm!(
llvm_asm!(
""
:
: "{rcx}"(out_regs), "{rdx}"(in_regs)
Expand All @@ -64,7 +64,7 @@ mod asm_impl {
#[naked]
unsafe extern "C" fn _swap_reg() {
// Save registers
asm!(
llvm_asm!(
"
mov %rbx, (0*8)(%rcx)
mov %rsp, (1*8)(%rcx)
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//!
#![cfg_attr(nightly, feature(asm))]
#![cfg_attr(nightly, feature(llvm_asm))]
#![cfg_attr(nightly, feature(repr_simd))]
#![cfg_attr(nightly, feature(core_intrinsics))]
#![cfg_attr(nightly, feature(naked_functions))]
Expand Down

0 comments on commit 97ba715

Please sign in to comment.