Skip to content

Commit

Permalink
Check out struct_target_features
Browse files Browse the repository at this point in the history
  • Loading branch information
shepmaster committed Oct 22, 2024
1 parent 75f9e5f commit 607d85c
Show file tree
Hide file tree
Showing 3 changed files with 157 additions and 203 deletions.
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![doc = include_str!("../README.md")]

#![allow(incomplete_features)]
#![feature(target_feature_11, struct_target_features)]
#![deny(rust_2018_idioms)]
#![deny(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)]
Expand Down
21 changes: 3 additions & 18 deletions src/xxhash3_64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ impl StripeAccumulator {
}

#[inline]
#[target_feature(from_args)]
fn process_stripe(
&mut self,
vector: impl Vector,
Expand Down Expand Up @@ -555,22 +556,6 @@ macro_rules! dispatch {
$fn_name(scalar::Impl, $($arg_name),*)
}

/// # Safety
///
/// You must ensure that the CPU has the NEON feature
#[inline]
#[target_feature(enable = "neon")]
#[cfg(all(target_arch = "aarch64", feature = "std"))]
unsafe fn do_neon<$($gen),*>($($arg_name : $arg_ty),*) $(-> $ret_ty)?
where
$($wheres)*
{
// Safety: The caller has ensured we have the NEON feature
unsafe {
$fn_name(neon::Impl::new_unchecked(), $($arg_name),*)
}
}

/// # Safety
///
/// You must ensure that the CPU has the AVX2 feature
Expand Down Expand Up @@ -606,7 +591,7 @@ macro_rules! dispatch {
// Now we invoke the right function

#[cfg(_internal_xxhash3_force_neon)]
return unsafe { do_neon($($arg_name),*) };
return unsafe { $fn_name(neon::Impl, $($arg_name),*) };

#[cfg(_internal_xxhash3_force_avx2)]
return unsafe { do_avx2($($arg_name),*) };
Expand All @@ -625,7 +610,7 @@ macro_rules! dispatch {
{
if std::arch::is_aarch64_feature_detected!("neon") {
// Safety: We just ensured we have the NEON feature
return unsafe { do_neon($($arg_name),*) };
return unsafe { $fn_name(neon::Impl, $($arg_name),*) };
}
}

Expand Down
Loading

0 comments on commit 607d85c

Please sign in to comment.