Skip to content

Commit

Permalink
Remove bitmasks from LaneCount
Browse files Browse the repository at this point in the history
  • Loading branch information
calebzulawski committed Feb 11, 2022
1 parent 744169a commit b7f93cf
Showing 1 changed file with 8 additions and 30 deletions.
38 changes: 8 additions & 30 deletions crates/core_simd/src/lane_count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,15 @@ use sealed::Sealed;
/// A type representing a vector lane count.
pub struct LaneCount<const LANES: usize>;

impl<const LANES: usize> LaneCount<LANES> {
/// The number of bytes in a bitmask with this many lanes.
pub const BITMASK_LEN: usize = (LANES + 7) / 8;
}

/// Helper trait for vector lane counts.
pub trait SupportedLaneCount: Sealed {
#[doc(hidden)]
type BitMask: Copy + Default + AsRef<[u8]> + AsMut<[u8]>;
}
pub trait SupportedLaneCount: Sealed {}

impl<const LANES: usize> Sealed for LaneCount<LANES> {}

impl SupportedLaneCount for LaneCount<1> {
type BitMask = [u8; 1];
}
impl SupportedLaneCount for LaneCount<2> {
type BitMask = [u8; 1];
}
impl SupportedLaneCount for LaneCount<4> {
type BitMask = [u8; 1];
}
impl SupportedLaneCount for LaneCount<8> {
type BitMask = [u8; 1];
}
impl SupportedLaneCount for LaneCount<16> {
type BitMask = [u8; 2];
}
impl SupportedLaneCount for LaneCount<32> {
type BitMask = [u8; 4];
}
impl SupportedLaneCount for LaneCount<64> {
type BitMask = [u8; 8];
}
impl SupportedLaneCount for LaneCount<1> {}
impl SupportedLaneCount for LaneCount<2> {}
impl SupportedLaneCount for LaneCount<4> {}
impl SupportedLaneCount for LaneCount<8> {}
impl SupportedLaneCount for LaneCount<16> {}
impl SupportedLaneCount for LaneCount<32> {}
impl SupportedLaneCount for LaneCount<64> {}

0 comments on commit b7f93cf

Please sign in to comment.