diff --git a/crates/core_arch/src/arm_shared/hints.rs b/crates/core_arch/src/arm_shared/hints.rs index ce64e8341e..36928564c6 100644 --- a/crates/core_arch/src/arm_shared/hints.rs +++ b/crates/core_arch/src/arm_shared/hints.rs @@ -10,15 +10,20 @@ // Section 10.1 of ACLE says that the supported arches are: 8, 6K, 6-M // LLVM says "instruction requires: armv6k" #[cfg(any( - target_feature = "v6", + all(target_feature = "v6k", not(target_feature = "thumb-mode")), + target_feature = "v6t2", + all(target_feature = "v6", target_feature = "mclass"), target_arch = "aarch64", target_arch = "arm64ec", doc ))] #[inline(always)] #[unstable(feature = "stdarch_arm_hints", issue = "117218")] -pub unsafe fn __wfi() { - hint(HINT_WFI); +pub fn __wfi() { + // SAFETY: The right HINT_WFI constant is passed to the llvm intrinsic。 + unsafe { + hint(HINT_WFI); + } } /// Generates a WFE (wait for event) hint instruction, or nothing. @@ -29,15 +34,20 @@ pub unsafe fn __wfi() { // Section 10.1 of ACLE says that the supported arches are: 8, 6K, 6-M // LLVM says "instruction requires: armv6k" #[cfg(any( - target_feature = "v6", + all(target_feature = "v6k", not(target_feature = "thumb-mode")), + target_feature = "v6t2", + all(target_feature = "v6", target_feature = "mclass"), target_arch = "aarch64", target_arch = "arm64ec", doc ))] #[inline(always)] #[unstable(feature = "stdarch_arm_hints", issue = "117218")] -pub unsafe fn __wfe() { - hint(HINT_WFE); +pub fn __wfe() { + // SAFETY: The right HINT_WFE constant is passed to the llvm intrinsic。 + unsafe { + hint(HINT_WFE); + } } /// Generates a SEV (send a global event) hint instruction. @@ -47,15 +57,20 @@ pub unsafe fn __wfe() { // Section 10.1 of ACLE says that the supported arches are: 8, 6K, 6-M, 7-M // LLVM says "instruction requires: armv6k" #[cfg(any( - target_feature = "v6", + all(target_feature = "v6k", not(target_feature = "thumb-mode")), + target_feature = "v6t2", + all(target_feature = "v6", target_feature = "mclass"), target_arch = "aarch64", target_arch = "arm64ec", doc ))] #[inline(always)] #[unstable(feature = "stdarch_arm_hints", issue = "117218")] -pub unsafe fn __sev() { - hint(HINT_SEV); +pub fn __sev() { + // SAFETY: The right HINT_SEV constant is passed to the llvm intrinsic。 + unsafe { + hint(HINT_SEV); + } } /// Generates a send a local event hint instruction. @@ -72,8 +87,11 @@ pub unsafe fn __sev() { ))] #[inline(always)] #[unstable(feature = "stdarch_arm_hints", issue = "117218")] -pub unsafe fn __sevl() { - hint(HINT_SEVL); +pub fn __sevl() { + // SAFETY: The right HINT_SEVL constant is passed to the llvm intrinsic。 + unsafe { + hint(HINT_SEVL); + } } /// Generates a YIELD hint instruction. @@ -94,8 +112,11 @@ pub unsafe fn __sevl() { ))] #[inline(always)] #[unstable(feature = "stdarch_arm_hints", issue = "117218")] -pub unsafe fn __yield() { - hint(HINT_YIELD); +pub fn __yield() { + // SAFETY: The right HINT_YIELD constant is passed to the llvm intrinsic。 + unsafe { + hint(HINT_YIELD); + } } /// Generates an unspecified no-op instruction. @@ -106,8 +127,11 @@ pub unsafe fn __yield() { /// will increase execution time. #[inline(always)] #[unstable(feature = "stdarch_arm_hints", issue = "117218")] -pub unsafe fn __nop() { - crate::arch::asm!("nop", options(nomem, nostack, preserves_flags)); +pub fn __nop() { + // SAFETY: `nop` performs no operation. + unsafe { + crate::arch::asm!("nop", options(nomem, nostack, preserves_flags)); + } } unsafe extern "llvm-intrinsic" {