6 /// Specifies the number of lanes in a SIMD vector as a type.
7 pub struct LaneCount<const LANES: usize>;
9 impl<const LANES: usize> LaneCount<LANES> {
10 /// The number of bytes in a bitmask with this many lanes.
11 pub const BITMASK_LEN: usize = (LANES + 7) / 8;
14 /// Statically guarantees that a lane count is marked as supported.
16 /// This trait is *sealed*: the list of implementors below is total.
17 /// Users do not have the ability to mark additional `LaneCount<N>` values as supported.
18 /// Only SIMD vectors with supported lane counts are constructable.
19 pub trait SupportedLaneCount: Sealed {
21 type BitMask: Copy + Default + AsRef<[u8]> + AsMut<[u8]>;
24 impl<const LANES: usize> Sealed for LaneCount<LANES> {}
26 impl SupportedLaneCount for LaneCount<1> {
27 type BitMask = [u8; 1];
29 impl SupportedLaneCount for LaneCount<2> {
30 type BitMask = [u8; 1];
32 impl SupportedLaneCount for LaneCount<4> {
33 type BitMask = [u8; 1];
35 impl SupportedLaneCount for LaneCount<8> {
36 type BitMask = [u8; 1];
38 impl SupportedLaneCount for LaneCount<16> {
39 type BitMask = [u8; 2];
41 impl SupportedLaneCount for LaneCount<32> {
42 type BitMask = [u8; 4];
44 impl SupportedLaneCount for LaneCount<64> {
45 type BitMask = [u8; 8];