use std::ops::{BitAnd, BitOr, BitOrAssign};
pub trait Simd: Sized {
const LANES: usize;
type Element;
type Mask: Mask;
unsafe fn from_slice_unaligned_unchecked(slice: &[u8]) -> Self {
debug_assert!(slice.len() >= Self::LANES);
Self::loadu(slice.as_ptr())
}
unsafe fn write_to_slice_unaligned_unchecked(&self, slice: &mut [u8]) {
debug_assert!(slice.len() >= Self::LANES);
self.storeu(slice.as_mut_ptr());
}
unsafe fn loadu(ptr: *const u8) -> Self;
unsafe fn storeu(&self, ptr: *mut u8);
fn eq(&self, rhs: &Self) -> Self::Mask;
fn splat(elem: Self::Element) -> Self;
fn gt(&self, rhs: &Self) -> Self::Mask;
fn le(&self, rhs: &Self) -> Self::Mask;
}
pub trait Mask: Sized + BitOr<Self> + BitOrAssign + BitAnd<Self> {
type Element;
type BitMask: BitMask;
fn bitmask(self) -> Self::BitMask;
fn splat(b: bool) -> Self;
}
pub trait BitMask {
const LEN: usize;
fn first_offset(&self) -> usize;
fn before(&self, rhs: &Self) -> bool;
fn as_little_endian(&self) -> Self;
fn all_zero(&self) -> bool;
fn clear_high_bits(&self, n: usize) -> Self;
}