1 #![allow(non_camel_case_types)]
3 use crate::simd::{LaneCount, Mask, Simd, SupportedLaneCount};
5 /// Implements additional integer traits (Eq, Ord, Hash) on the specified vector `$name`, holding multiple `$lanes` of `$type`.
6 macro_rules! impl_integer_vector {
8 impl<const LANES: usize> Simd<$type, LANES>
10 LaneCount<LANES>: SupportedLaneCount,
12 /// Returns true for each positive lane and false if it is zero or negative.
14 pub fn is_positive(self) -> Mask<$type, LANES> {
15 self.lanes_gt(Self::splat(0))
18 /// Returns true for each negative lane and false if it is zero or positive.
20 pub fn is_negative(self) -> Mask<$type, LANES> {
21 self.lanes_lt(Self::splat(0))
24 /// Returns numbers representing the sign of each lane.
25 /// * `0` if the number is zero
26 /// * `1` if the number is positive
27 /// * `-1` if the number is negative
29 pub fn signum(self) -> Self {
30 self.is_positive().select(
32 self.is_negative().select(Self::splat(-1), Self::splat(0))
39 impl_integer_vector! { isize }
40 impl_integer_vector! { i16 }
41 impl_integer_vector! { i32 }
42 impl_integer_vector! { i64 }
43 impl_integer_vector! { i8 }
45 /// Vector of two `isize` values
46 pub type isizex2 = Simd<isize, 2>;
48 /// Vector of four `isize` values
49 pub type isizex4 = Simd<isize, 4>;
51 /// Vector of eight `isize` values
52 pub type isizex8 = Simd<isize, 8>;
54 /// Vector of two `i16` values
55 pub type i16x2 = Simd<i16, 2>;
57 /// Vector of four `i16` values
58 pub type i16x4 = Simd<i16, 4>;
60 /// Vector of eight `i16` values
61 pub type i16x8 = Simd<i16, 8>;
63 /// Vector of 16 `i16` values
64 pub type i16x16 = Simd<i16, 16>;
66 /// Vector of 32 `i16` values
67 pub type i16x32 = Simd<i16, 32>;
69 /// Vector of two `i32` values
70 pub type i32x2 = Simd<i32, 2>;
72 /// Vector of four `i32` values
73 pub type i32x4 = Simd<i32, 4>;
75 /// Vector of eight `i32` values
76 pub type i32x8 = Simd<i32, 8>;
78 /// Vector of 16 `i32` values
79 pub type i32x16 = Simd<i32, 16>;
81 /// Vector of two `i64` values
82 pub type i64x2 = Simd<i64, 2>;
84 /// Vector of four `i64` values
85 pub type i64x4 = Simd<i64, 4>;
87 /// Vector of eight `i64` values
88 pub type i64x8 = Simd<i64, 8>;
90 /// Vector of four `i8` values
91 pub type i8x4 = Simd<i8, 4>;
93 /// Vector of eight `i8` values
94 pub type i8x8 = Simd<i8, 8>;
96 /// Vector of 16 `i8` values
97 pub type i8x16 = Simd<i8, 16>;
99 /// Vector of 32 `i8` values
100 pub type i8x32 = Simd<i8, 32>;
102 /// Vector of 64 `i8` values
103 pub type i8x64 = Simd<i8, 64>;