Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ This release has an [MSRV][] of 1.89.
### Added

- Added `Native<S>` to `SimdFloatElement` and `SimdIntElement` to select native-width vectors in scalar-generic code.
- Added the public `ExtractToken` trait for SIMD tokens, vectors, masks, references, and user-defined wrappers. `#[simd]` now extracts its token from the first non-receiver parameter, allowing vector arguments without a separate token parameter.
- Added `reverse` for all SIMD vector and mask types. ([#356][] by [@Shnatsel][])
- Added `rotate_elements_left` and `rotate_elements_right` to mask types. Rotations wrap the offset, matching the existing non-mask vector operations. ([#360][] by [@Shnatsel][])
- Added lane-wise `saturating_add` and `saturating_sub` for all integer vector types and backends. ([#352][] by [@Shnatsel][])
Expand All @@ -29,6 +30,7 @@ This release has an [MSRV][] of 1.89.

### Changed

- Breaking change: `witness()` has moved from `SimdBase` and `SimdMask` to their new `ExtractToken` supertrait and has been renamed to `token()`.
- Breaking change: `SimdBase::N` and `SimdMask::N` have been renamed to `LEN`, matching the `std::simd` naming. ([#366][] by [@Shnatsel][])
- Breaking change: `SimdBase::as_array` now borrows the vector and returns an array reference, while owned extraction has moved to `to_array`. The old `as_array_ref` and `as_array_mut` methods have been replaced by `as_array` and `as_mut_array`, matching the `std::simd` API. ([#351][] by [@Shnatsel][])
- Breaking change: `abs` has moved from `SimdFloat` to `SimdBase` and is now available on integer vectors. Signed integers use wrapping absolute value, leaving the minimum representable value unchanged; unsigned integers are unchanged. ([#371][] by [@Shnatsel][])
Expand Down
7 changes: 7 additions & 0 deletions fearless_simd/src/generated/avx2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ impl Avx2 {
}
}
impl Seal for Avx2 {}
impl ExtractToken for Avx2 {
type S = Self;
#[inline]
fn token(&self) -> Self {
*self
}
}
impl ArchTypes for Avx2 {
type f32x4 = crate::support::Aligned128<__m128>;
type i8x16 = crate::support::Aligned128<__m128i>;
Expand Down
7 changes: 7 additions & 0 deletions fearless_simd/src/generated/avx512.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ impl Avx512 {
}
}
impl Seal for Avx512 {}
impl ExtractToken for Avx512 {
type S = Self;
#[inline]
fn token(&self) -> Self {
*self
}
}
impl ArchTypes for Avx512 {
type f32x4 = crate::support::Aligned128<__m128>;
type i8x16 = crate::support::Aligned128<__m128i>;
Expand Down
7 changes: 7 additions & 0 deletions fearless_simd/src/generated/fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ impl Fallback {
}
}
impl Seal for Fallback {}
impl ExtractToken for Fallback {
type S = Self;
#[inline]
fn token(&self) -> Self {
*self
}
}
impl ArchTypes for Fallback {
type f32x4 = crate::support::Aligned128<[f32; 4usize]>;
type i8x16 = crate::support::Aligned128<[i8; 16usize]>;
Expand Down
7 changes: 7 additions & 0 deletions fearless_simd/src/generated/neon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ impl Neon {
}
}
impl Seal for Neon {}
impl ExtractToken for Neon {
type S = Self;
#[inline]
fn token(&self) -> Self {
*self
}
}
impl ArchTypes for Neon {
type f32x4 = crate::support::Aligned128<float32x4_t>;
type i8x16 = crate::support::Aligned128<int8x16_t>;
Expand Down
27 changes: 17 additions & 10 deletions fearless_simd/src/generated/simd_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// This file is autogenerated by fearless_simd_gen

use crate::{
Bytes, Level, Select, SimdCvtFloat, SimdCvtTruncate, SimdElement, SimdFloatElement, SimdFrom,
SimdIntElement, SimdInto, SimdNarrow, SimdWiden, seal::Seal,
Bytes, ExtractToken, Level, Select, SimdCvtFloat, SimdCvtTruncate, SimdElement,
SimdFloatElement, SimdFrom, SimdIntElement, SimdInto, SimdNarrow, SimdWiden, seal::Seal,
};
use crate::{
f32x4, f32x8, f32x16, f64x2, f64x4, f64x8, i8x16, i8x32, i8x64, i16x8, i16x16, i16x32, i32x4,
Expand Down Expand Up @@ -50,7 +50,16 @@ use core::fmt::Debug;
#[doc = r" });"]
#[doc = r" ```"]
pub trait Simd:
Sized + Clone + Copy + Send + Sync + Debug + Seal + arch_types::ArchTypes + 'static
ExtractToken<S = Self>
+ Sized
+ Clone
+ Copy
+ Send
+ Sync
+ Debug
+ Seal
+ arch_types::ArchTypes
+ 'static
{
#[doc = r" A native-width SIMD vector of [`f32`]s."]
type f32s: SimdFloat<
Expand Down Expand Up @@ -9564,7 +9573,8 @@ pub(crate) mod arch_types {
}
#[doc = r" Base functionality implemented by all SIMD vectors."]
pub trait SimdBase<S: Simd>:
Copy
ExtractToken<S = S>
+ Copy
+ Sync
+ Send
+ Debug
Expand Down Expand Up @@ -9622,8 +9632,6 @@ pub trait SimdBase<S: Simd>:
+ AsRef<[Self::Element]>
+ AsMut<[Self::Element]>
+ From<Self>;
#[doc = r" Get the [`Simd`] implementation associated with this type."]
fn witness(&self) -> S;
fn as_slice(&self) -> &[Self::Element];
fn as_mut_slice(&mut self) -> &mut [Self::Element];
#[doc = r" Create a SIMD vector from a slice."]
Expand Down Expand Up @@ -9896,7 +9904,7 @@ pub trait SimdBase<S: Simd>:
#[doc = r" If `OFFSET` is greater than or equal to `Self::LEN`, all lanes are filled with `padding`."]
#[inline(always)]
fn shift_elements_right<const OFFSET: usize>(self, padding: Self::Element) -> Self {
let padding = Self::splat(self.witness(), padding);
let padding = Self::splat(self.token(), padding);
match Self::LEN.saturating_sub(OFFSET) {
0 => padding.slide::<0>(self),
1 => padding.slide::<1>(self),
Expand Down Expand Up @@ -10131,7 +10139,8 @@ pub trait SimdInt<S: Simd>:
#[doc = r" current backends may use all-zero/all-one integer vectors internally, while future"]
#[doc = r" predicate-register backends may use a compact representation."]
pub trait SimdMask<S: Simd>:
Copy
ExtractToken<S = S>
+ Copy
+ Sync
+ Send
+ 'static
Expand All @@ -10152,8 +10161,6 @@ pub trait SimdMask<S: Simd>:
type Element: SimdElement;
#[doc = r" This mask type's lane count."]
const LEN: usize;
#[doc = r" Get the [`Simd`] implementation associated with this type."]
fn witness(&self) -> S;
#[doc = r" Create a SIMD mask with all lanes set to the given boolean value."]
fn splat(simd: S, val: bool) -> Self;
#[doc = r" Create a mask from a compact bitmask."]
Expand Down
Loading
Loading