use super::{BitChunk, NativeType};
pub trait FromMaskChunk<T> {
fn from_chunk(v: T) -> Self;
}
pub unsafe trait NativeSimd: Default + Copy {
const LANES: usize;
type Native: NativeType;
type Chunk: BitChunk;
type Mask: FromMaskChunk<Self::Chunk>;
fn select(self, mask: Self::Mask, default: Self) -> Self;
fn from_chunk(v: &[Self::Native]) -> Self;
fn from_incomplete_chunk(v: &[Self::Native], remaining: Self::Native) -> Self;
fn align(values: &[Self::Native]) -> (&[Self::Native], &[Self], &[Self::Native]);
}
pub trait Simd: NativeType {
type Simd: NativeSimd<Native = Self>;
}
#[cfg(not(feature = "simd"))]
mod native;
#[cfg(not(feature = "simd"))]
pub use native::*;
#[cfg(feature = "simd")]
mod packed;
#[cfg(feature = "simd")]
pub use packed::*;
macro_rules! native {
($type:ty, $simd:ty) => {
impl Simd for $type {
type Simd = $simd;
}
};
}
native!(u8, u8x64);
native!(u16, u16x32);
native!(u32, u32x16);
native!(u64, u64x8);
native!(i8, i8x64);
native!(i16, i16x32);
native!(i32, i32x16);
native!(i64, i64x8);
native!(f32, f32x16);
native!(f64, f64x8);