diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 514d725..5192da0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,9 +58,6 @@ jobs: matrix: target: [x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu] flags: [--no-default-features, "", --all-features, --features force-generic] - exclude: - # miri doesn't implement neon intrinsics. - - target: aarch64-unknown-linux-gnu env: MIRIFLAGS: -Zmiri-strict-provenance steps: diff --git a/src/aarch64.rs b/src/aarch64.rs index 69c5141..5495223 100644 --- a/src/aarch64.rs +++ b/src/aarch64.rs @@ -6,18 +6,16 @@ use core::arch::aarch64::*; pub(super) const USE_CHECK_FN: bool = false; const CHUNK_SIZE: usize = core::mem::size_of::(); -/// Hex encoding function using aarch64 intrisics. -/// -/// # Safety -/// -/// `output` must be a valid pointer to at least `2 * input.len()` bytes. -// SAFETY: this is only compiled when the target feature is enabled. -#[target_feature(enable = "neon")] +#[inline] pub(super) unsafe fn encode(input: &[u8], output: *mut u8) { - if input.len() < CHUNK_SIZE { + if input.len() < CHUNK_SIZE || !cfg!(target_feature = "neon") || cfg!(miri) { return generic::encode::(input, output); } + _encode::(input, output); +} +#[target_feature(enable = "neon")] +pub(super) unsafe fn _encode(input: &[u8], output: *mut u8) { // Load table. let hex_table = vld1q_u8(super::get_chars_table::().as_ptr()); diff --git a/src/lib.rs b/src/lib.rs index e61b1ab..cde7c32 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -64,7 +64,7 @@ cfg_if! { } else if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { mod x86; use x86 as imp; - } else if #[cfg(all(target_arch = "aarch64", target_feature = "neon"))] { + } else if #[cfg(target_arch = "aarch64")] { mod aarch64; use aarch64 as imp; } else { diff --git a/src/portable_simd.rs b/src/portable_simd.rs index cfff1d6..38887e6 100644 --- a/src/portable_simd.rs +++ b/src/portable_simd.rs @@ -5,11 +5,6 @@ use core::slice; pub(super) const USE_CHECK_FN: bool = false; const CHUNK_SIZE: usize = core::mem::size_of::(); -/// Hex encoding function using [`std::simd`][core::simd]. -/// -/// # Safety -/// -/// `output` must be a valid pointer to at least `2 * input.len()` bytes. pub(super) unsafe fn encode(input: &[u8], output: *mut u8) { let mut i = 0; let (prefix, chunks, suffix) = input.as_simd::(); diff --git a/src/x86.rs b/src/x86.rs index d9b9c0b..4801d67 100644 --- a/src/x86.rs +++ b/src/x86.rs @@ -15,11 +15,6 @@ const T_MASK: i32 = 65535; cpufeatures::new!(cpuid_sse2, "sse2"); cpufeatures::new!(cpuid_ssse3, "sse2", "ssse3"); -/// Hex encoding function using x86 intrisics. -/// -/// # Safety -/// -/// `output` must be a valid pointer to at least `2 * input.len()` bytes. #[inline] pub(super) unsafe fn encode(input: &[u8], output: *mut u8) { if input.len() < CHUNK_SIZE || !cpuid_ssse3::get() {