Skip to content

Commit b7a6e89

Browse files
committed
Import the asm! macro from core::arch
It is going to be removed from the prelude due to the decision in rust-lang/rust#87228
1 parent 44d53ad commit b7a6e89

File tree

13 files changed

+21
-9
lines changed

13 files changed

+21
-9
lines changed

crates/core_arch/src/aarch64/armclang.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ use stdarch_test::assert_instr;
1919
#[rustc_legacy_const_generics(0)]
2020
pub unsafe fn __breakpoint<const VAL: i32>() {
2121
static_assert_imm16!(VAL);
22-
asm!("brk {}", const VAL);
22+
crate::arch::asm!("brk {}", const VAL);
2323
}

crates/core_arch/src/arm/armclang.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ use stdarch_test::assert_instr;
3131
#[rustc_legacy_const_generics(0)]
3232
pub unsafe fn __breakpoint<const VAL: i32>() {
3333
static_assert_imm8!(VAL);
34-
asm!("bkpt #{}", const VAL);
34+
crate::arch::asm!("bkpt #{}", const VAL);
3535
}

crates/core_arch/src/arm_shared/barrier/cp15.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Reference: ARM11 MPCore Processor Technical Reference Manual (ARM DDI 0360E) Section 3.5 "Summary
22
// of CP15 instructions"
33

4+
use crate::arch::asm;
5+
46
/// Full system is the required shareability domain, reads and writes are the
57
/// required access types
68
pub struct SY;

crates/core_arch/src/arm_shared/hints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ pub unsafe fn __yield() {
7777
/// will increase execution time.
7878
#[inline(always)]
7979
pub unsafe fn __nop() {
80-
asm!("nop", options(nomem, nostack, preserves_flags));
80+
crate::arch::asm!("nop", options(nomem, nostack, preserves_flags));
8181
}
8282

8383
extern "unadjusted" {

crates/core_arch/src/arm_shared/registers/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ macro_rules! rsr {
44
impl super::super::sealed::Rsr for $R {
55
unsafe fn __rsr(&self) -> u32 {
66
let r: u32;
7-
asm!(concat!("mrs {},", stringify!($R)), out(reg) r, options(nomem, nostack));
7+
crate::arch::asm!(concat!("mrs {},", stringify!($R)), out(reg) r, options(nomem, nostack));
88
r
99
}
1010
}
@@ -17,7 +17,7 @@ macro_rules! rsrp {
1717
impl super::super::sealed::Rsrp for $R {
1818
unsafe fn __rsrp(&self) -> *const u8 {
1919
let r: *const u8;
20-
asm!(concat!("mrs {},", stringify!($R)), out(reg) r, options(nomem, nostack));
20+
crate::arch::asm!(concat!("mrs {},", stringify!($R)), out(reg) r, options(nomem, nostack));
2121
r
2222
}
2323
}
@@ -29,7 +29,7 @@ macro_rules! wsr {
2929
($R:ident) => {
3030
impl super::super::sealed::Wsr for $R {
3131
unsafe fn __wsr(&self, value: u32) {
32-
asm!(concat!("msr ", stringify!($R), ", {}"), in(reg) value, options(nomem, nostack));
32+
crate::arch::asm!(concat!("msr ", stringify!($R), ", {}"), in(reg) value, options(nomem, nostack));
3333
}
3434
}
3535
};
@@ -40,7 +40,7 @@ macro_rules! wsrp {
4040
($R:ident) => {
4141
impl super::super::sealed::Wsrp for $R {
4242
unsafe fn __wsrp(&self, value: *const u8) {
43-
asm!(concat!("msr ", stringify!($R), ", {}"), in(reg) value, options(nomem, nostack));
43+
crate::arch::asm!(concat!("msr ", stringify!($R), ", {}"), in(reg) value, options(nomem, nostack));
4444
}
4545
}
4646
};

crates/core_arch/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ extern crate std_detect;
6868
#[path = "mod.rs"]
6969
mod core_arch;
7070

71-
pub use self::core_arch::arch;
71+
pub mod arch {
72+
pub use crate::core_arch::arch::*;
73+
pub use core::arch::asm;
74+
}
7275

7376
#[allow(unused_imports)]
7477
use core::{convert, ffi, hint, intrinsics, marker, mem, ops, ptr, sync};

crates/core_arch/src/riscv/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
/// should be temporarily reduced or paused. The duration of its effect must be bounded and may be zero.
77
#[inline]
88
pub fn pause() {
9-
unsafe { asm!(".word 0x0100000F", options(nomem, nostack)) }
9+
unsafe { crate::arch::asm!(".word 0x0100000F", options(nomem, nostack)) }
1010
}

crates/core_arch/src/x86/avx512bw.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::{
2+
arch::asm,
23
core_arch::{simd::*, simd_llvm::*, x86::*},
34
mem::{self, transmute},
45
ptr,

crates/core_arch/src/x86/avx512f.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::{
2+
arch::asm,
23
core_arch::{simd::*, simd_llvm::*, x86::*},
34
mem::{self, transmute},
45
ptr,

crates/core_arch/src/x86/bt.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::arch::asm;
12
#[cfg(test)]
23
use stdarch_test::assert_instr;
34

crates/core_arch/src/x86/cpuid.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! `cpuid` intrinsics
22
#![allow(clippy::module_name_repetitions)]
33

4+
use crate::arch::asm;
45
#[cfg(test)]
56
use stdarch_test::assert_instr;
67

crates/core_arch/src/x86/eflags.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! `i386` intrinsics
22
3+
use crate::arch::asm;
4+
35
/// Reads EFLAGS.
46
///
57
/// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=__readeflags)

crates/core_arch/src/x86_64/bt.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::arch::asm;
12
#[cfg(test)]
23
use stdarch_test::assert_instr;
34

0 commit comments

Comments
 (0)