1macro_rules! number {
2 { 1 } => { "one" };
3 { 2 } => { "two" };
4 { 4 } => { "four" };
5 { 8 } => { "eight" };
6 { $x:literal } => { stringify!($x) };
7}
8
9macro_rules! plural {
10 { 1 } => { "" };
11 { $x:literal } => { "s" };
12}
13
14macro_rules! alias {
15 {
16 $(
17 $element_ty:ty = {
18 $($alias:ident $num_elements:tt)*
19 }
20 )*
21 } => {
22 $(
23 $(
24 #[doc = concat!("A SIMD vector with ", number!($num_elements), " element", plural!($num_elements), " of type [`", stringify!($element_ty), "`].")]
25 #[allow(non_camel_case_types)]
26 pub type $alias = $crate::simd::Simd<$element_ty, $num_elements>;
27 )*
28 )*
29 }
30}
31
32macro_rules! mask_alias {
33 {
34 $(
35 $element_ty:ty : $size:literal = {
36 $($alias:ident $num_elements:tt)*
37 }
38 )*
39 } => {
40 $(
41 $(
42 #[doc = concat!("A SIMD mask with ", number!($num_elements), " element", plural!($num_elements), " for vectors with ", $size, " element types.")]
43 ///
44 #[doc = concat!(
45 "The layout of this type is unspecified, and may change between platforms and/or Rust versions, and code should not assume that it is equivalent to `[",
46 stringify!($element_ty), "; ", $num_elements, "]`."
47 )]
48 #[allow(non_camel_case_types)]
49 pub type $alias = $crate::simd::Mask<$element_ty, $num_elements>;
50 )*
51 )*
52 }
53}
54
55alias! {
56 i8 = {
57 i8x1 1
58 i8x2 2
59 i8x4 4
60 i8x8 8
61 i8x16 16
62 i8x32 32
63 i8x64 64
64 }
65
66 i16 = {
67 i16x1 1
68 i16x2 2
69 i16x4 4
70 i16x8 8
71 i16x16 16
72 i16x32 32
73 i16x64 64
74 }
75
76 i32 = {
77 i32x1 1
78 i32x2 2
79 i32x4 4
80 i32x8 8
81 i32x16 16
82 i32x32 32
83 i32x64 64
84 }
85
86 i64 = {
87 i64x1 1
88 i64x2 2
89 i64x4 4
90 i64x8 8
91 i64x16 16
92 i64x32 32
93 i64x64 64
94 }
95
96 isize = {
97 isizex1 1
98 isizex2 2
99 isizex4 4
100 isizex8 8
101 isizex16 16
102 isizex32 32
103 isizex64 64
104 }
105
106 u8 = {
107 u8x1 1
108 u8x2 2
109 u8x4 4
110 u8x8 8
111 u8x16 16
112 u8x32 32
113 u8x64 64
114 }
115
116 u16 = {
117 u16x1 1
118 u16x2 2
119 u16x4 4
120 u16x8 8
121 u16x16 16
122 u16x32 32
123 u16x64 64
124 }
125
126 u32 = {
127 u32x1 1
128 u32x2 2
129 u32x4 4
130 u32x8 8
131 u32x16 16
132 u32x32 32
133 u32x64 64
134 }
135
136 u64 = {
137 u64x1 1
138 u64x2 2
139 u64x4 4
140 u64x8 8
141 u64x16 16
142 u64x32 32
143 u64x64 64
144 }
145
146 usize = {
147 usizex1 1
148 usizex2 2
149 usizex4 4
150 usizex8 8
151 usizex16 16
152 usizex32 32
153 usizex64 64
154 }
155
156 f32 = {
157 f32x1 1
158 f32x2 2
159 f32x4 4
160 f32x8 8
161 f32x16 16
162 f32x32 32
163 f32x64 64
164 }
165
166 f64 = {
167 f64x1 1
168 f64x2 2
169 f64x4 4
170 f64x8 8
171 f64x16 16
172 f64x32 32
173 f64x64 64
174 }
175}
176
177mask_alias! {
178 i8 : "8-bit" = {
179 mask8x1 1
180 mask8x2 2
181 mask8x4 4
182 mask8x8 8
183 mask8x16 16
184 mask8x32 32
185 mask8x64 64
186 }
187
188 i16 : "16-bit" = {
189 mask16x1 1
190 mask16x2 2
191 mask16x4 4
192 mask16x8 8
193 mask16x16 16
194 mask16x32 32
195 mask16x64 64
196 }
197
198 i32 : "32-bit" = {
199 mask32x1 1
200 mask32x2 2
201 mask32x4 4
202 mask32x8 8
203 mask32x16 16
204 mask32x32 32
205 mask32x64 64
206 }
207
208 i64 : "64-bit" = {
209 mask64x1 1
210 mask64x2 2
211 mask64x4 4
212 mask64x8 8
213 mask64x16 16
214 mask64x32 32
215 mask64x64 64
216 }
217
218 isize : "pointer-sized" = {
219 masksizex1 1
220 masksizex2 2
221 masksizex4 4
222 masksizex8 8
223 masksizex16 16
224 masksizex32 32
225 masksizex64 64
226 }
227}
228