Skip to content

Commit

Permalink
Merge pull request #6 from DaniPopes/cleanup-aarch64
Browse files Browse the repository at this point in the history
Clean up aarch64
  • Loading branch information
DaniPopes authored Oct 27, 2023
2 parents e32ec85 + 52225a6 commit d74afb6
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 22 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 6 additions & 8 deletions src/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,16 @@ use core::arch::aarch64::*;
pub(super) const USE_CHECK_FN: bool = false;
const CHUNK_SIZE: usize = core::mem::size_of::<uint8x16_t>();

/// 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<const UPPER: bool>(input: &[u8], output: *mut u8) {
if input.len() < CHUNK_SIZE {
if input.len() < CHUNK_SIZE || !cfg!(target_feature = "neon") || cfg!(miri) {
return generic::encode::<UPPER>(input, output);
}
_encode::<UPPER>(input, output);
}

#[target_feature(enable = "neon")]
pub(super) unsafe fn _encode<const UPPER: bool>(input: &[u8], output: *mut u8) {
// Load table.
let hex_table = vld1q_u8(super::get_chars_table::<UPPER>().as_ptr());

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 0 additions & 5 deletions src/portable_simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ use core::slice;
pub(super) const USE_CHECK_FN: bool = false;
const CHUNK_SIZE: usize = core::mem::size_of::<u8x16>();

/// 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<const UPPER: bool>(input: &[u8], output: *mut u8) {
let mut i = 0;
let (prefix, chunks, suffix) = input.as_simd::<CHUNK_SIZE>();
Expand Down
5 changes: 0 additions & 5 deletions src/x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<const UPPER: bool>(input: &[u8], output: *mut u8) {
if input.len() < CHUNK_SIZE || !cpuid_ssse3::get() {
Expand Down

0 comments on commit d74afb6

Please sign in to comment.