pub trait UnderlierWithBitOps:
UnderlierType
+ BitAnd<Self, Output = Self>
+ BitAndAssign<Self>
+ BitOr<Self, Output = Self>
+ BitOrAssign<Self>
+ BitXor<Self, Output = Self>
+ BitXorAssign<Self>
+ Shr<usize, Output = Self>
+ Shl<usize, Output = Self>
+ Not<Output = Self> {
const ZERO: Self;
const ONE: Self;
const ONES: Self;
// Required methods
fn fill_with_bit(val: u8) -> Self;
fn shl_128b_lanes(self, shift: usize) -> Self;
fn shr_128b_lanes(self, shift: usize) -> Self;
// Provided methods
fn from_fn<T>(f: impl FnMut(usize) -> T) -> Self
where T: UnderlierType,
Self: From<T> { ... }
fn broadcast_subvalue<T>(value: T) -> Self
where T: UnderlierType,
Self: From<T> { ... }
unsafe fn get_subvalue<T>(&self, i: usize) -> T
where T: UnderlierType + NumCast<Self> { ... }
unsafe fn set_subvalue<T>(&mut self, i: usize, val: T)
where T: UnderlierWithBitOps,
Self: From<T> { ... }
unsafe fn spread<T>(self, log_block_len: usize, block_idx: usize) -> Self
where T: UnderlierWithBitOps + NumCast<Self>,
Self: From<T> { ... }
fn unpack_lo_128b_lanes(self, other: Self, log_block_len: usize) -> Self { ... }
fn unpack_hi_128b_lanes(self, other: Self, log_block_len: usize) -> Self { ... }
}
Expand description
Underlier type that supports bit arithmetic.
Required Associated Constants§
Required Methods§
Sourcefn fill_with_bit(val: u8) -> Self
fn fill_with_bit(val: u8) -> Self
Fill value with the given bit
val
must be 0 or 1.
Sourcefn shl_128b_lanes(self, shift: usize) -> Self
fn shl_128b_lanes(self, shift: usize) -> Self
Left shift within 128-bit lanes.
This can be more efficient than the full Shl
implementation.
Sourcefn shr_128b_lanes(self, shift: usize) -> Self
fn shr_128b_lanes(self, shift: usize) -> Self
Right shift within 128-bit lanes.
This can be more efficient than the full Shr
implementation.
Provided Methods§
fn from_fn<T>(f: impl FnMut(usize) -> T) -> Selfwhere
T: UnderlierType,
Self: From<T>,
Sourcefn broadcast_subvalue<T>(value: T) -> Selfwhere
T: UnderlierType,
Self: From<T>,
fn broadcast_subvalue<T>(value: T) -> Selfwhere
T: UnderlierType,
Self: From<T>,
Broadcast subvalue to fill Self
.
Self::BITS/T::BITS
is supposed to be a power of 2.
Sourceunsafe fn get_subvalue<T>(&self, i: usize) -> Twhere
T: UnderlierType + NumCast<Self>,
unsafe fn get_subvalue<T>(&self, i: usize) -> Twhere
T: UnderlierType + NumCast<Self>,
Gets the subvalue from the given position. Function panics in case when index is out of range.
§Safety
i
must be less than Self::BITS/T::BITS
.
Sourceunsafe fn set_subvalue<T>(&mut self, i: usize, val: T)where
T: UnderlierWithBitOps,
Self: From<T>,
unsafe fn set_subvalue<T>(&mut self, i: usize, val: T)where
T: UnderlierWithBitOps,
Self: From<T>,
Sets the subvalue in the given position. Function panics in case when index is out of range.
§Safety
i
must be less than Self::BITS/T::BITS
.
Sourceunsafe fn spread<T>(self, log_block_len: usize, block_idx: usize) -> Self
unsafe fn spread<T>(self, log_block_len: usize, block_idx: usize) -> Self
Spread takes a block of sub_elements of T
type within the current value and
repeats them to the full underlier width.
§Safety
log_block_len + T::LOG_BITS
must be less than or equal to Self::LOG_BITS
.
block_idx
must be less than 1 << (Self::LOG_BITS - log_block_len)
.
Sourcefn unpack_lo_128b_lanes(self, other: Self, log_block_len: usize) -> Self
fn unpack_lo_128b_lanes(self, other: Self, log_block_len: usize) -> Self
Unpacks 1 << log_block_len
-bit values from low parts of self
and other
within 128-bit lanes.
Example: self: [a_0, a_1, a_2, a_3, a_4, a_5, a_6, a_7] other: [b_0, b_1, b_2, b_3, b_4, b_5, b_6, b_7] log_block_len: 1
result: [a_0, a_0, b_0, b_1, a_2, a_3, b_2, b_3]
Sourcefn unpack_hi_128b_lanes(self, other: Self, log_block_len: usize) -> Self
fn unpack_hi_128b_lanes(self, other: Self, log_block_len: usize) -> Self
Unpacks 1 << log_block_len
-bit values from high parts of self
and other
within 128-bit lanes.
Example: self: [a_0, a_1, a_2, a_3, a_4, a_5, a_6, a_7] other: [b_0, b_1, b_2, b_3, b_4, b_5, b_6, b_7] log_block_len: 1
result: [a_4, a_5, b_4, b_5, a_6, a_7, b_6, b_7]
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.