core/portable-simd/crates/core_simd/src/
lane_count.rs1mod sealed {
2 pub trait Sealed {}
3}
4use sealed::Sealed;
5
6pub struct LaneCount<const N: usize>;
8
9impl<const N: usize> LaneCount<N> {
10 pub const BITMASK_LEN: usize = (N + 7) / 8;
12}
13
14pub trait SupportedLaneCount: Sealed {
20 #[doc(hidden)]
21 type BitMask: Copy + Default + AsRef<[u8]> + AsMut<[u8]>;
22}
23
24impl<const N: usize> Sealed for LaneCount<N> {}
25
26macro_rules! supported_lane_count {
27 ($($lanes:literal),+) => {
28 $(
29 impl SupportedLaneCount for LaneCount<$lanes> {
30 type BitMask = [u8; ($lanes + 7) / 8];
31 }
32 )+
33 };
34}
35
36supported_lane_count!(
37 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
38 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
39 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64
40);