core/stdarch/crates/core_arch/src/s390x/
macros.rs1#![allow(unused_macros)] #![allow(unused_imports)] macro_rules! test_impl {
5 ($fun:ident ($($v:ident : $ty:ty),*) -> $r:ty [$call:ident, _]) => {
6 #[inline]
7 #[target_feature(enable = "vector")]
8 pub unsafe fn $fun ($($v : $ty),*) -> $r {
9 $call ($($v),*)
10 }
11 };
12 ($fun:ident +($($v:ident : $ty:ty),*) -> $r:ty [$call:ident, $instr:ident]) => {
13 #[inline]
14 #[target_feature(enable = "vector")]
15 #[cfg_attr(test, assert_instr($instr))]
16 pub unsafe fn $fun ($($v : $ty),*) -> $r {
17 transmute($call ($($v),*))
18 }
19 };
20 ($fun:ident +($($v:ident : $ty:ty),*) -> $r:ty [$call:ident, $tf:literal $instr:ident]) => {
21 #[inline]
22 #[target_feature(enable = "vector")]
23 #[cfg_attr(all(test, target_feature = $tf), assert_instr($instr))]
24 pub unsafe fn $fun ($($v : $ty),*) -> $r {
25 transmute($call ($($v),*))
26 }
27 };
28 ($fun:ident ($($v:ident : $ty:ty),*) -> $r:ty [$call:ident, $tf:literal $instr:ident]) => {
29 #[inline]
30 #[target_feature(enable = "vector")]
31 #[cfg_attr(all(test, target_feature = $tf), assert_instr($instr))]
32 pub unsafe fn $fun ($($v : $ty),*) -> $r {
33 $call ($($v),*)
34 }
35 };
36 ($fun:ident ($($v:ident : $ty:ty),*) -> $r:ty [$call:ident, $instr:ident]) => {
37 #[inline]
38 #[target_feature(enable = "vector")]
39 #[cfg_attr(test, assert_instr($instr))]
40 pub unsafe fn $fun ($($v : $ty),*) -> $r {
41 $call ($($v),*)
42 }
43 };
44}
45
46#[allow(unknown_lints, unused_macro_rules)]
47macro_rules! impl_vec_trait {
48 ([$Trait:ident $m:ident] $fun:ident ($a:ty)) => {
49 #[unstable(feature = "stdarch_s390x", issue = "135681")]
50 impl $Trait for $a {
51 #[inline]
52 #[target_feature(enable = "vector")]
53 unsafe fn $m(self) -> Self {
54 $fun(transmute(self))
55 }
56 }
57 };
58 ([$Trait:ident $m:ident]+ $fun:ident ($a:ty)) => {
59 #[unstable(feature = "stdarch_s390x", issue = "135681")]
60 impl $Trait for $a {
61 #[inline]
62 #[target_feature(enable = "vector")]
63 unsafe fn $m(self) -> Self {
64 transmute($fun(transmute(self)))
65 }
66 }
67 };
68 ([$Trait:ident $m:ident] $fun:ident ($a:ty) -> $r:ty) => {
69 #[unstable(feature = "stdarch_s390x", issue = "135681")]
70 impl $Trait for $a {
71 type Result = $r;
72 #[inline]
73 #[target_feature(enable = "vector")]
74 unsafe fn $m(self) -> Self::Result {
75 $fun(transmute(self))
76 }
77 }
78 };
79 ([$Trait:ident $m:ident]+ $fun:ident ($a:ty) -> $r:ty) => {
80 #[unstable(feature = "stdarch_s390x", issue = "135681")]
81 impl $Trait for $a {
82 type Result = $r;
83 #[inline]
84 #[target_feature(enable = "vector")]
85 unsafe fn $m(self) -> Self::Result {
86 transmute($fun(transmute(self)))
87 }
88 }
89 };
90 ([$Trait:ident $m:ident] 1 ($ub:ident, $sb:ident, $uh:ident, $sh:ident, $uw:ident, $sw:ident, $sf: ident)) => {
91 impl_vec_trait!{ [$Trait $m] $ub (vector_unsigned_char) -> vector_unsigned_char }
92 impl_vec_trait!{ [$Trait $m] $sb (vector_signed_char) -> vector_signed_char }
93 impl_vec_trait!{ [$Trait $m] $uh (vector_unsigned_short) -> vector_unsigned_short }
94 impl_vec_trait!{ [$Trait $m] $sh (vector_signed_short) -> vector_signed_short }
95 impl_vec_trait!{ [$Trait $m] $uw (vector_unsigned_int) -> vector_unsigned_int }
96 impl_vec_trait!{ [$Trait $m] $sw (vector_signed_int) -> vector_signed_int }
97 impl_vec_trait!{ [$Trait $m] $uw (vector_unsigned_long_long) -> vector_unsigned_long_long }
98 impl_vec_trait!{ [$Trait $m] $sw (vector_signed_long_long) -> vector_signed_long_long }
99 impl_vec_trait!{ [$Trait $m] $sf (vector_float) -> vector_float }
100 impl_vec_trait!{ [$Trait $m] $sf (vector_double) -> vector_double }
101 };
102 ([$Trait:ident $m:ident] $fun:ident ($a:ty, $b:ty) -> $r:ty) => {
103 #[unstable(feature = "stdarch_s390x", issue = "135681")]
104 impl $Trait<$b> for $a {
105 type Result = $r;
106 #[inline]
107 #[target_feature(enable = "vector")]
108 unsafe fn $m(self, b: $b) -> Self::Result {
109 $fun(transmute(self), transmute(b))
110 }
111 }
112 };
113 ([$Trait:ident $m:ident]+ $fun:ident ($a:ty, $b:ty) -> $r:ty) => {
114 #[unstable(feature = "stdarch_s390x", issue = "135681")]
115 impl $Trait<$b> for $a {
116 type Result = $r;
117 #[inline]
118 #[target_feature(enable = "vector")]
119 unsafe fn $m(self, b: $b) -> Self::Result {
120 transmute($fun(transmute(self), transmute(b)))
121 }
122 }
123 };
124 ([$Trait:ident $m:ident] $fun:ident ($a:ty, ~$b:ty) -> $r:ty) => {
125 impl_vec_trait!{ [$Trait $m] $fun ($a, $a) -> $r }
126 impl_vec_trait!{ [$Trait $m] $fun ($a, $b) -> $r }
127 impl_vec_trait!{ [$Trait $m] $fun ($b, $a) -> $r }
128 };
129 ([$Trait:ident $m:ident] ~($ub:ident, $sb:ident, $uh:ident, $sh:ident, $uw:ident, $sw:ident, $ug:ident, $sg:ident)) => {
130 impl_vec_trait!{ [$Trait $m] $ub (vector_unsigned_char, ~vector_bool_char) -> vector_unsigned_char }
131 impl_vec_trait!{ [$Trait $m] $sb (vector_signed_char, ~vector_bool_char) -> vector_signed_char }
132 impl_vec_trait!{ [$Trait $m] $uh (vector_unsigned_short, ~vector_bool_short) -> vector_unsigned_short }
133 impl_vec_trait!{ [$Trait $m] $sh (vector_signed_short, ~vector_bool_short) -> vector_signed_short }
134 impl_vec_trait!{ [$Trait $m] $uw (vector_unsigned_int, ~vector_bool_int) -> vector_unsigned_int }
135 impl_vec_trait!{ [$Trait $m] $sw (vector_signed_int, ~vector_bool_int) -> vector_signed_int }
136 impl_vec_trait!{ [$Trait $m] $ug (vector_unsigned_long_long, ~vector_bool_long_long) -> vector_unsigned_long_long }
137 impl_vec_trait!{ [$Trait $m] $sg (vector_signed_long_long, ~vector_bool_long_long) -> vector_signed_long_long }
138 };
139 ([$Trait:ident $m:ident] ~($fn:ident)) => {
140 impl_vec_trait!{ [$Trait $m] ~($fn, $fn, $fn, $fn, $fn, $fn, $fn, $fn) }
141 };
142 ([$Trait:ident $m:ident] 2 ($ub:ident, $sb:ident, $uh:ident, $sh:ident, $uw:ident, $sw:ident, $ug:ident, $sg:ident)) => {
143 impl_vec_trait!{ [$Trait $m] $ub (vector_unsigned_char, vector_unsigned_char) -> vector_unsigned_char }
144 impl_vec_trait!{ [$Trait $m] $sb (vector_signed_char, vector_signed_char) -> vector_signed_char }
145 impl_vec_trait!{ [$Trait $m] $uh (vector_unsigned_short, vector_unsigned_short) -> vector_unsigned_short }
146 impl_vec_trait!{ [$Trait $m] $sh (vector_signed_short, vector_signed_short) -> vector_signed_short }
147 impl_vec_trait!{ [$Trait $m] $uw (vector_unsigned_int, vector_unsigned_int) -> vector_unsigned_int }
148 impl_vec_trait!{ [$Trait $m] $sw (vector_signed_int, vector_signed_int) -> vector_signed_int }
149 impl_vec_trait!{ [$Trait $m] $ug (vector_unsigned_long_long, vector_unsigned_long_long) -> vector_unsigned_long_long }
150 impl_vec_trait!{ [$Trait $m] $sg (vector_signed_long_long, vector_signed_long_long) -> vector_signed_long_long }
151 };
152 ([$Trait:ident $m:ident] 2 ($fn:ident)) => {
153 impl_vec_trait!{ [$Trait $m] ($fn, $fn, $fn, $fn, $fn, $fn, $fn, $fn) }
154 };
155 ([$Trait:ident $m:ident]+ 2b ($b:ident, $h:ident, $w:ident, $g:ident)) => {
156 impl_vec_trait!{ [$Trait $m]+ $b (vector_bool_char, vector_bool_char) -> vector_bool_char }
157 impl_vec_trait!{ [$Trait $m]+ $b (vector_unsigned_char, vector_unsigned_char) -> vector_unsigned_char }
158 impl_vec_trait!{ [$Trait $m]+ $b (vector_signed_char, vector_signed_char) -> vector_signed_char }
159 impl_vec_trait!{ [$Trait $m]+ $h (vector_bool_short, vector_bool_short) -> vector_bool_short }
160 impl_vec_trait!{ [$Trait $m]+ $h (vector_unsigned_short, vector_unsigned_short) -> vector_unsigned_short }
161 impl_vec_trait!{ [$Trait $m]+ $h (vector_signed_short, vector_signed_short) -> vector_signed_short }
162 impl_vec_trait!{ [$Trait $m]+ $w (vector_bool_int, vector_bool_int) -> vector_bool_int }
163 impl_vec_trait!{ [$Trait $m]+ $w (vector_unsigned_int, vector_unsigned_int) -> vector_unsigned_int }
164 impl_vec_trait!{ [$Trait $m]+ $w (vector_signed_int, vector_signed_int) -> vector_signed_int }
165 impl_vec_trait!{ [$Trait $m]+ $g (vector_unsigned_long_long, vector_unsigned_long_long) -> vector_unsigned_long_long }
166 impl_vec_trait!{ [$Trait $m]+ $g (vector_signed_long_long, vector_signed_long_long) -> vector_signed_long_long }
167 };
168 ([$Trait:ident $m:ident]+ 2b ($fn:ident)) => {
169 impl_vec_trait!{ [$Trait $m]+ 2b ($fn, $fn, $fn, $fn) }
170 };
171 ([$Trait:ident $m:ident]+ 2c ($b:ident, $h:ident, $w:ident, $g:ident, $s:ident, $d:ident)) => {
172 impl_vec_trait!{ [$Trait $m]+ $b (vector_bool_char, vector_bool_char) -> vector_bool_char }
173 impl_vec_trait!{ [$Trait $m]+ $b (vector_unsigned_char, vector_unsigned_char) -> vector_unsigned_char }
174 impl_vec_trait!{ [$Trait $m]+ $b (vector_signed_char, vector_signed_char) -> vector_signed_char }
175 impl_vec_trait!{ [$Trait $m]+ $h (vector_bool_short, vector_bool_short) -> vector_bool_short }
176 impl_vec_trait!{ [$Trait $m]+ $h (vector_unsigned_short, vector_unsigned_short) -> vector_unsigned_short }
177 impl_vec_trait!{ [$Trait $m]+ $h (vector_signed_short, vector_signed_short) -> vector_signed_short }
178 impl_vec_trait!{ [$Trait $m]+ $w (vector_bool_int, vector_bool_int) -> vector_bool_int }
179 impl_vec_trait!{ [$Trait $m]+ $w (vector_unsigned_int, vector_unsigned_int) -> vector_unsigned_int }
180 impl_vec_trait!{ [$Trait $m]+ $w (vector_signed_int, vector_signed_int) -> vector_signed_int }
181 impl_vec_trait!{ [$Trait $m]+ $g (vector_unsigned_long_long, vector_unsigned_long_long) -> vector_unsigned_long_long }
182 impl_vec_trait!{ [$Trait $m]+ $g (vector_signed_long_long, vector_signed_long_long) -> vector_signed_long_long }
183 impl_vec_trait!{ [$Trait $m]+ $s (vector_float, vector_float) -> vector_float }
184 impl_vec_trait!{ [$Trait $m]+ $d (vector_double, vector_double) -> vector_double }
185 };
186 ([$Trait:ident $m:ident]+ 2c ($fn:ident)) => {
187 impl_vec_trait!{ [$Trait $m]+ 2c ($fn, $fn, $fn, $fn, $fn, $fn) }
188 };
189}
190
191macro_rules! s_t_l {
192 (i64x2) => {
193 vector_signed_long_long
194 };
195 (i32x4) => {
196 vector_signed_int
197 };
198 (i16x8) => {
199 vector_signed_short
200 };
201 (i8x16) => {
202 vector_signed_char
203 };
204
205 (u64x2) => {
206 vector_unsigned_long_long
207 };
208 (u32x4) => {
209 vector_unsigned_int
210 };
211 (u16x8) => {
212 vector_unsigned_short
213 };
214 (u8x16) => {
215 vector_unsigned_char
216 };
217
218 (f32x4) => {
219 vector_float
220 };
221 (f64x2) => {
222 vector_double
223 };
224}
225
226macro_rules! l_t_t {
227 (vector_signed_long_long) => {
228 i64
229 };
230 (vector_signed_int) => {
231 i32
232 };
233 (vector_signed_short) => {
234 i16
235 };
236 (vector_signed_char) => {
237 i8
238 };
239
240 (vector_unsigned_long_long ) => {
241 u64
242 };
243 (vector_unsigned_int ) => {
244 u32
245 };
246 (vector_unsigned_short ) => {
247 u16
248 };
249 (vector_unsigned_char ) => {
250 u8
251 };
252
253 (vector_bool_long_long ) => {
254 u64
255 };
256 (vector_bool_int ) => {
257 u32
258 };
259 (vector_bool_short ) => {
260 u16
261 };
262 (vector_bool_char ) => {
263 u8
264 };
265
266 (vector_float) => {
267 f32
268 };
269 (vector_double) => {
270 f64
271 };
272}
273
274macro_rules! t_t_l {
275 (i64) => {
276 vector_signed_long_long
277 };
278 (i32) => {
279 vector_signed_int
280 };
281 (i16) => {
282 vector_signed_short
283 };
284 (i8) => {
285 vector_signed_char
286 };
287
288 (u64) => {
289 vector_unsigned_long_long
290 };
291 (u32) => {
292 vector_unsigned_int
293 };
294 (u16) => {
295 vector_unsigned_short
296 };
297 (u8) => {
298 vector_unsigned_char
299 };
300
301 (f32) => {
302 vector_float
303 };
304 (f64) => {
305 vector_double
306 };
307}
308
309macro_rules! t_t_s {
310 (i64) => {
311 i64x2
312 };
313 (i32) => {
314 i32x4
315 };
316 (i16) => {
317 i16x8
318 };
319 (i8) => {
320 i8x16
321 };
322
323 (u64) => {
324 u64x2
325 };
326 (u32) => {
327 u32x4
328 };
329 (u16) => {
330 u16x8
331 };
332 (u8) => {
333 u8x16
334 };
335
336 (f32) => {
337 f32x4
338 };
339 (f64) => {
340 f64x2
341 };
342}
343
344macro_rules! t_u {
345 (vector_bool_char) => {
346 vector_unsigned_char
347 };
348 (vector_bool_short) => {
349 vector_unsigned_short
350 };
351 (vector_bool_int) => {
352 vector_unsigned_int
353 };
354 (vector_bool_long_long) => {
355 vector_unsigned_long_long
356 };
357 (vector_unsigned_char) => {
358 vector_unsigned_char
359 };
360 (vector_unsigned_short) => {
361 vector_unsigned_short
362 };
363 (vector_unsigned_int) => {
364 vector_unsigned_int
365 };
366 (vector_unsigned_long_long) => {
367 vector_unsigned_long_long
368 };
369 (vector_signed_char) => {
370 vector_unsigned_char
371 };
372 (vector_signed_short) => {
373 vector_unsigned_short
374 };
375 (vector_signed_int) => {
376 vector_unsigned_int
377 };
378 (vector_signed_long_long) => {
379 vector_unsigned_long_long
380 };
381 (vector_float) => {
382 vector_unsigned_int
383 };
384 (vector_double) => {
385 vector_unsigned_long_long
386 };
387}
388
389macro_rules! t_b {
390 (vector_bool_char) => {
391 vector_bool_char
392 };
393 (vector_bool_short) => {
394 vector_bool_short
395 };
396 (vector_bool_int) => {
397 vector_bool_int
398 };
399 (vector_bool_long_long) => {
400 vector_bool_long_long
401 };
402 (vector_signed_char) => {
403 vector_bool_char
404 };
405 (vector_signed_short) => {
406 vector_bool_short
407 };
408 (vector_signed_int) => {
409 vector_bool_int
410 };
411 (vector_signed_long_long) => {
412 vector_bool_long_long
413 };
414 (vector_unsigned_char) => {
415 vector_bool_char
416 };
417 (vector_unsigned_short) => {
418 vector_bool_short
419 };
420 (vector_unsigned_int) => {
421 vector_bool_int
422 };
423 (vector_unsigned_long_long) => {
424 vector_bool_long_long
425 };
426 (vector_float) => {
427 vector_bool_int
428 };
429 (vector_double) => {
430 vector_bool_long_long
431 };
432}
433
434macro_rules! impl_from {
435 ($s: ident) => {
436 #[unstable(feature = "stdarch_s390x", issue = "135681")]
437 impl From<$s> for s_t_l!($s) {
438 fn from (v: $s) -> Self {
439 unsafe {
440 transmute(v)
441 }
442 }
443 }
444 };
445 ($($s: ident),*) => {
446 $(
447 impl_from! { $s }
448 )*
449 };
450}
451
452macro_rules! impl_neg {
453 ($s: ident : $zero: expr) => {
454 #[unstable(feature = "stdarch_s390x", issue = "135681")]
455 impl crate::ops::Neg for s_t_l!($s) {
456 type Output = s_t_l!($s);
457 fn neg(self) -> Self::Output {
458 unsafe { simd_neg(self) }
459 }
460 }
461 };
462}
463
464pub(crate) use impl_from;
465pub(crate) use impl_neg;
466pub(crate) use impl_vec_trait;
467pub(crate) use l_t_t;
468pub(crate) use s_t_l;
469pub(crate) use t_b;
470pub(crate) use t_t_l;
471pub(crate) use t_t_s;
472pub(crate) use t_u;
473pub(crate) use test_impl;