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
72 changes: 72 additions & 0 deletions fearless_simd/src/generated/simd_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ pub trait Simd:
Block = f32x4<Self>,
Mask = Self::mask32s,
ByteVector = Self::u8s,
Bits = Self::u32s,
> + SimdCvtFloat<Self::u32s>
+ SimdCvtFloat<Self::i32s>
+ SimdWiden<Self, Widened = Self::f64s>;
Expand All @@ -79,6 +80,7 @@ pub trait Simd:
Block = f64x2<Self>,
Mask = Self::mask64s,
ByteVector = Self::u8s,
Bits = Self::u64s,
> + SimdCvtFloat<Self::u64s>
+ SimdCvtFloat<Self::i64s>
+ SimdNarrow<Self, Narrowed = Self::f32s>;
Expand All @@ -89,6 +91,8 @@ pub trait Simd:
Block = u8x16<Self>,
Mask = Self::mask8s,
ByteVector = Self::u8s,
Unsigned = Self::u8s,
Signed = Self::i8s,
> + SimdIntWiden<Self, Widened = Self::u16s>;
#[doc = r" A native-width SIMD vector of [`i8`]s."]
type i8s: SimdInt<
Expand All @@ -97,6 +101,8 @@ pub trait Simd:
Block = i8x16<Self>,
Mask = Self::mask8s,
ByteVector = Self::u8s,
Unsigned = Self::u8s,
Signed = Self::i8s,
> + SimdIntWiden<Self, Widened = Self::i16s>
+ core::ops::Neg<Output = Self::i8s>;
#[doc = r" A native-width SIMD vector of [`u16`]s."]
Expand All @@ -106,6 +112,8 @@ pub trait Simd:
Block = u16x8<Self>,
Mask = Self::mask16s,
ByteVector = Self::u8s,
Unsigned = Self::u16s,
Signed = Self::i16s,
> + SimdNarrow<Self, Narrowed = Self::u8s>
+ SimdIntWiden<Self, Widened = Self::u32s>;
#[doc = r" A native-width SIMD vector of [`i16`]s."]
Expand All @@ -115,6 +123,8 @@ pub trait Simd:
Block = i16x8<Self>,
Mask = Self::mask16s,
ByteVector = Self::u8s,
Unsigned = Self::u16s,
Signed = Self::i16s,
> + SimdNarrow<Self, Narrowed = Self::i8s>
+ SimdIntWiden<Self, Widened = Self::i32s>
+ core::ops::Neg<Output = Self::i16s>;
Expand All @@ -125,6 +135,8 @@ pub trait Simd:
Block = u32x4<Self>,
Mask = Self::mask32s,
ByteVector = Self::u8s,
Unsigned = Self::u32s,
Signed = Self::i32s,
> + SimdCvtTruncate<Self::f32s>
+ SimdNarrow<Self, Narrowed = Self::u16s>
+ SimdIntWiden<Self, Widened = Self::u64s>;
Expand All @@ -135,6 +147,8 @@ pub trait Simd:
Block = i32x4<Self>,
Mask = Self::mask32s,
ByteVector = Self::u8s,
Unsigned = Self::u32s,
Signed = Self::i32s,
> + SimdCvtTruncate<Self::f32s>
+ SimdNarrow<Self, Narrowed = Self::i16s>
+ SimdIntWiden<Self, Widened = Self::i64s>
Expand All @@ -146,6 +160,8 @@ pub trait Simd:
Block = u64x2<Self>,
Mask = Self::mask64s,
ByteVector = Self::u8s,
Unsigned = Self::u64s,
Signed = Self::i64s,
> + SimdCvtTruncate<Self::f64s>
+ SimdNarrow<Self, Narrowed = Self::u32s>;
#[doc = r" A native-width SIMD vector of [`i64`]s."]
Expand All @@ -155,6 +171,8 @@ pub trait Simd:
Block = i64x2<Self>,
Mask = Self::mask64s,
ByteVector = Self::u8s,
Unsigned = Self::u64s,
Signed = Self::i64s,
> + SimdCvtTruncate<Self::f64s>
+ SimdNarrow<Self, Narrowed = Self::i32s>
+ core::ops::Neg<Output = Self::i64s>;
Expand Down Expand Up @@ -13067,6 +13085,8 @@ pub trait SimdFloat<S: Simd>:
S,
Element = <Self::Element as SimdFloatElement>::Bits,
ByteVector = Self::ByteVector,
Mask = Self::Mask,
Unsigned = Self::Bits,
>;
#[doc = r" Raw transmutation to an unsigned integer vector type with the same size and number of elements."]
#[doc = r""]
Expand Down Expand Up @@ -13190,13 +13210,65 @@ pub trait SimdInt<S: Simd>:
+ core::ops::Shr<Output = Self>
+ core::ops::ShrAssign
{
#[doc = r" Corresponding unsigned integer SIMD vector type. E.g. `u8x16` for `i8x16`."]
#[doc = r""]
#[doc = r" This type is `Self` if the SIMD vector is already unsigned."]
type Unsigned: SimdInt<
S,
Element = <Self::Element as SimdIntElement>::Unsigned,
ByteVector = Self::ByteVector,
Unsigned = Self::Unsigned,
Signed = Self::Signed,
Mask = Self::Mask,
>;
#[doc = r" Corresponding signed integer SIMD vector type. E.g. `i8x16` for `u8x16`."]
#[doc = r""]
#[doc = r" This type is `Self` if the SIMD vector is already signed."]
type Signed: SimdInt<
S,
Element = <Self::Element as SimdIntElement>::Signed,
ByteVector = Self::ByteVector,
Unsigned = Self::Unsigned,
Signed = Self::Signed,
Mask = Self::Mask,
>;
#[doc = r" Reinterpret this integer SIMD vector as its corresponding signed type."]
#[inline(always)]
fn cast_signed(self) -> Self::Signed {
self.bitcast()
}
#[doc = r" Reinterpret this integer SIMD vector as its corresponding unsigned type."]
#[inline(always)]
fn cast_unsigned(self) -> Self::Unsigned {
self.bitcast()
}
#[doc = r" Convert this integer type to a floating-point type. This is a convenience method"]
#[doc = r" that delegates to [`SimdCvtFloat::float_from`], and can only be called if there"]
#[doc = r" actually exists a target type of the same bit width (`f32` or `f64`)."]
#[inline(always)]
fn to_float<T: SimdCvtFloat<Self>>(self) -> T {
T::float_from(self)
}
#[doc = r" Return the absolute value of `self` without any wrapping."]
#[doc = r""]
#[doc = r" If `Self` is an unsigned SIMD vector, this always produces the same result as `self.abs()`."]
#[doc = r""]
#[doc = r" ## Example"]
#[doc = r""]
#[doc = r" ```"]
#[doc = r" # use fearless_simd::*;"]
#[doc = r" # dispatch!(Level::new(), simd => {"]
#[doc = r" let i = i32x4::from_slice(simd, &[100, -100, i32::MAX, i32::MIN]);"]
#[doc = r" assert_eq!("]
#[doc = r" *i.unsigned_abs(),"]
#[doc = r" [100, 100, 2147483647, 2147483648],"]
#[doc = r" );"]
#[doc = r" # });"]
#[doc = r" ```"]
#[inline(always)]
fn unsigned_abs(self) -> Self::Unsigned {
self.abs().cast_unsigned()
}
#[doc = "Return the number of ones in the binary representation of each element."]
fn count_ones(self) -> Self;
#[doc = "Return the number of zeros in the binary representation of each element."]
Expand Down
48 changes: 48 additions & 0 deletions fearless_simd/src/generated/simd_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,8 @@ impl<S: Simd> SimdBase<S> for i8x16<S> {
}
}
impl<S: Simd> crate::SimdInt<S> for i8x16<S> {
type Unsigned = u8x16<S>;
type Signed = i8x16<S>;
#[inline(always)]
fn count_ones(self) -> Self {
self.simd.count_ones_i8x16(self)
Expand Down Expand Up @@ -1139,6 +1141,8 @@ impl<S: Simd> SimdBase<S> for u8x16<S> {
}
}
impl<S: Simd> crate::SimdInt<S> for u8x16<S> {
type Unsigned = u8x16<S>;
type Signed = i8x16<S>;
#[inline(always)]
fn count_ones(self) -> Self {
self.simd.count_ones_u8x16(self)
Expand Down Expand Up @@ -1661,6 +1665,8 @@ impl<S: Simd> SimdBase<S> for i16x8<S> {
}
}
impl<S: Simd> crate::SimdInt<S> for i16x8<S> {
type Unsigned = u16x8<S>;
type Signed = i16x8<S>;
#[inline(always)]
fn count_ones(self) -> Self {
self.simd.count_ones_i16x8(self)
Expand Down Expand Up @@ -2055,6 +2061,8 @@ impl<S: Simd> SimdBase<S> for u16x8<S> {
}
}
impl<S: Simd> crate::SimdInt<S> for u16x8<S> {
type Unsigned = u16x8<S>;
type Signed = i16x8<S>;
#[inline(always)]
fn count_ones(self) -> Self {
self.simd.count_ones_u16x8(self)
Expand Down Expand Up @@ -2587,6 +2595,8 @@ impl<S: Simd> SimdBase<S> for i32x4<S> {
}
}
impl<S: Simd> crate::SimdInt<S> for i32x4<S> {
type Unsigned = u32x4<S>;
type Signed = i32x4<S>;
#[inline(always)]
fn count_ones(self) -> Self {
self.simd.count_ones_i32x4(self)
Expand Down Expand Up @@ -2981,6 +2991,8 @@ impl<S: Simd> SimdBase<S> for u32x4<S> {
}
}
impl<S: Simd> crate::SimdInt<S> for u32x4<S> {
type Unsigned = u32x4<S>;
type Signed = i32x4<S>;
#[inline(always)]
fn count_ones(self) -> Self {
self.simd.count_ones_u32x4(self)
Expand Down Expand Up @@ -3955,6 +3967,8 @@ impl<S: Simd> SimdBase<S> for i64x2<S> {
}
}
impl<S: Simd> crate::SimdInt<S> for i64x2<S> {
type Unsigned = u64x2<S>;
type Signed = i64x2<S>;
#[inline(always)]
fn count_ones(self) -> Self {
self.simd.count_ones_i64x2(self)
Expand Down Expand Up @@ -4323,6 +4337,8 @@ impl<S: Simd> SimdBase<S> for u64x2<S> {
}
}
impl<S: Simd> crate::SimdInt<S> for u64x2<S> {
type Unsigned = u64x2<S>;
type Signed = i64x2<S>;
#[inline(always)]
fn count_ones(self) -> Self {
self.simd.count_ones_u64x2(self)
Expand Down Expand Up @@ -5292,6 +5308,8 @@ impl<S: Simd> SimdBase<S> for i8x32<S> {
}
}
impl<S: Simd> crate::SimdInt<S> for i8x32<S> {
type Unsigned = u8x32<S>;
type Signed = i8x32<S>;
#[inline(always)]
fn count_ones(self) -> Self {
self.simd.count_ones_i8x32(self)
Expand Down Expand Up @@ -5690,6 +5708,8 @@ impl<S: Simd> SimdBase<S> for u8x32<S> {
}
}
impl<S: Simd> crate::SimdInt<S> for u8x32<S> {
type Unsigned = u8x32<S>;
type Signed = i8x32<S>;
#[inline(always)]
fn count_ones(self) -> Self {
self.simd.count_ones_u8x32(self)
Expand Down Expand Up @@ -6209,6 +6229,8 @@ impl<S: Simd> SimdBase<S> for i16x16<S> {
}
}
impl<S: Simd> crate::SimdInt<S> for i16x16<S> {
type Unsigned = u16x16<S>;
type Signed = i16x16<S>;
#[inline(always)]
fn count_ones(self) -> Self {
self.simd.count_ones_i16x16(self)
Expand Down Expand Up @@ -6609,6 +6631,8 @@ impl<S: Simd> SimdBase<S> for u16x16<S> {
}
}
impl<S: Simd> crate::SimdInt<S> for u16x16<S> {
type Unsigned = u16x16<S>;
type Signed = i16x16<S>;
#[inline(always)]
fn count_ones(self) -> Self {
self.simd.count_ones_u16x16(self)
Expand Down Expand Up @@ -7150,6 +7174,8 @@ impl<S: Simd> SimdBase<S> for i32x8<S> {
}
}
impl<S: Simd> crate::SimdInt<S> for i32x8<S> {
type Unsigned = u32x8<S>;
type Signed = i32x8<S>;
#[inline(always)]
fn count_ones(self) -> Self {
self.simd.count_ones_i32x8(self)
Expand Down Expand Up @@ -7551,6 +7577,8 @@ impl<S: Simd> SimdBase<S> for u32x8<S> {
}
}
impl<S: Simd> crate::SimdInt<S> for u32x8<S> {
type Unsigned = u32x8<S>;
type Signed = i32x8<S>;
#[inline(always)]
fn count_ones(self) -> Self {
self.simd.count_ones_u32x8(self)
Expand Down Expand Up @@ -8522,6 +8550,8 @@ impl<S: Simd> SimdBase<S> for i64x4<S> {
}
}
impl<S: Simd> crate::SimdInt<S> for i64x4<S> {
type Unsigned = u64x4<S>;
type Signed = i64x4<S>;
#[inline(always)]
fn count_ones(self) -> Self {
self.simd.count_ones_i64x4(self)
Expand Down Expand Up @@ -8885,6 +8915,8 @@ impl<S: Simd> SimdBase<S> for u64x4<S> {
}
}
impl<S: Simd> crate::SimdInt<S> for u64x4<S> {
type Unsigned = u64x4<S>;
type Signed = i64x4<S>;
#[inline(always)]
fn count_ones(self) -> Self {
self.simd.count_ones_u64x4(self)
Expand Down Expand Up @@ -9892,6 +9924,8 @@ impl<S: Simd> SimdBase<S> for i8x64<S> {
}
}
impl<S: Simd> crate::SimdInt<S> for i8x64<S> {
type Unsigned = u8x64<S>;
type Signed = i8x64<S>;
#[inline(always)]
fn count_ones(self) -> Self {
self.simd.count_ones_i8x64(self)
Expand Down Expand Up @@ -10316,6 +10350,8 @@ impl<S: Simd> SimdBase<S> for u8x64<S> {
}
}
impl<S: Simd> crate::SimdInt<S> for u8x64<S> {
type Unsigned = u8x64<S>;
type Signed = i8x64<S>;
#[inline(always)]
fn count_ones(self) -> Self {
self.simd.count_ones_u8x64(self)
Expand Down Expand Up @@ -10838,6 +10874,8 @@ impl<S: Simd> SimdBase<S> for i16x32<S> {
}
}
impl<S: Simd> crate::SimdInt<S> for i16x32<S> {
type Unsigned = u16x32<S>;
type Signed = i16x32<S>;
#[inline(always)]
fn count_ones(self) -> Self {
self.simd.count_ones_i16x32(self)
Expand Down Expand Up @@ -11248,6 +11286,8 @@ impl<S: Simd> SimdBase<S> for u16x32<S> {
}
}
impl<S: Simd> crate::SimdInt<S> for u16x32<S> {
type Unsigned = u16x32<S>;
type Signed = i16x32<S>;
#[inline(always)]
fn count_ones(self) -> Self {
self.simd.count_ones_u16x32(self)
Expand Down Expand Up @@ -11785,6 +11825,8 @@ impl<S: Simd> SimdBase<S> for i32x16<S> {
}
}
impl<S: Simd> crate::SimdInt<S> for i32x16<S> {
type Unsigned = u32x16<S>;
type Signed = i32x16<S>;
#[inline(always)]
fn count_ones(self) -> Self {
self.simd.count_ones_i32x16(self)
Expand Down Expand Up @@ -12191,6 +12233,8 @@ impl<S: Simd> SimdBase<S> for u32x16<S> {
}
}
impl<S: Simd> crate::SimdInt<S> for u32x16<S> {
type Unsigned = u32x16<S>;
type Signed = i32x16<S>;
#[inline(always)]
fn count_ones(self) -> Self {
self.simd.count_ones_u32x16(self)
Expand Down Expand Up @@ -13176,6 +13220,8 @@ impl<S: Simd> SimdBase<S> for i64x8<S> {
}
}
impl<S: Simd> crate::SimdInt<S> for i64x8<S> {
type Unsigned = u64x8<S>;
type Signed = i64x8<S>;
#[inline(always)]
fn count_ones(self) -> Self {
self.simd.count_ones_i64x8(self)
Expand Down Expand Up @@ -13545,6 +13591,8 @@ impl<S: Simd> SimdBase<S> for u64x8<S> {
}
}
impl<S: Simd> crate::SimdInt<S> for u64x8<S> {
type Unsigned = u64x8<S>;
type Signed = i64x8<S>;
#[inline(always)]
fn count_ones(self) -> Self {
self.simd.count_ones_u64x8(self)
Expand Down
Loading
Loading