|
| 1 | +use crate::LanesAtMost32; |
| 2 | + |
| 3 | +macro_rules! implement_mask_ops { |
| 4 | + { $($vector:ident => $mask:ident ($inner_mask_ty:ident, $inner_ty:ident),)* } => { |
| 5 | + $( |
| 6 | + impl<const LANES: usize> crate::$vector<LANES> |
| 7 | + where |
| 8 | + crate::$vector<LANES>: LanesAtMost32, |
| 9 | + crate::$inner_ty<LANES>: LanesAtMost32, |
| 10 | + { |
| 11 | + /// Test if each lane is equal to the corresponding lane in `other`. |
| 12 | + #[inline] |
| 13 | + pub fn lanes_eq(self, other: Self) -> crate::$mask<LANES> { |
| 14 | + unsafe { |
| 15 | + crate::$inner_mask_ty::from_int_unchecked(crate::intrinsics::simd_eq(self, other)) |
| 16 | + .into() |
| 17 | + } |
| 18 | + } |
| 19 | + |
| 20 | + /// Test if each lane is not equal to the corresponding lane in `other`. |
| 21 | + #[inline] |
| 22 | + pub fn lanes_ne(self, other: Self) -> crate::$mask<LANES> { |
| 23 | + unsafe { |
| 24 | + crate::$inner_mask_ty::from_int_unchecked(crate::intrinsics::simd_ne(self, other)) |
| 25 | + .into() |
| 26 | + } |
| 27 | + } |
| 28 | + |
| 29 | + /// Test if each lane is less than the corresponding lane in `other`. |
| 30 | + #[inline] |
| 31 | + pub fn lanes_lt(self, other: Self) -> crate::$mask<LANES> { |
| 32 | + unsafe { |
| 33 | + crate::$inner_mask_ty::from_int_unchecked(crate::intrinsics::simd_lt(self, other)) |
| 34 | + .into() |
| 35 | + } |
| 36 | + } |
| 37 | + |
| 38 | + /// Test if each lane is greater than the corresponding lane in `other`. |
| 39 | + #[inline] |
| 40 | + pub fn lanes_gt(self, other: Self) -> crate::$mask<LANES> { |
| 41 | + unsafe { |
| 42 | + crate::$inner_mask_ty::from_int_unchecked(crate::intrinsics::simd_gt(self, other)) |
| 43 | + .into() |
| 44 | + } |
| 45 | + } |
| 46 | + |
| 47 | + /// Test if each lane is less than or equal to the corresponding lane in `other`. |
| 48 | + #[inline] |
| 49 | + pub fn lanes_le(self, other: Self) -> crate::$mask<LANES> { |
| 50 | + unsafe { |
| 51 | + crate::$inner_mask_ty::from_int_unchecked(crate::intrinsics::simd_le(self, other)) |
| 52 | + .into() |
| 53 | + } |
| 54 | + } |
| 55 | + |
| 56 | + /// Test if each lane is greater than or equal to the corresponding lane in `other`. |
| 57 | + #[inline] |
| 58 | + pub fn lanes_ge(self, other: Self) -> crate::$mask<LANES> { |
| 59 | + unsafe { |
| 60 | + crate::$inner_mask_ty::from_int_unchecked(crate::intrinsics::simd_ge(self, other)) |
| 61 | + .into() |
| 62 | + } |
| 63 | + } |
| 64 | + } |
| 65 | + )* |
| 66 | + } |
| 67 | +} |
| 68 | + |
| 69 | +implement_mask_ops! { |
| 70 | + SimdI8 => Mask8 (SimdMask8, SimdI8), |
| 71 | + SimdI16 => Mask16 (SimdMask16, SimdI16), |
| 72 | + SimdI32 => Mask32 (SimdMask32, SimdI32), |
| 73 | + SimdI64 => Mask64 (SimdMask64, SimdI64), |
| 74 | + SimdI128 => Mask128 (SimdMask128, SimdI128), |
| 75 | + SimdIsize => MaskSize (SimdMaskSize, SimdIsize), |
| 76 | + |
| 77 | + SimdU8 => Mask8 (SimdMask8, SimdI8), |
| 78 | + SimdU16 => Mask16 (SimdMask16, SimdI16), |
| 79 | + SimdU32 => Mask32 (SimdMask32, SimdI32), |
| 80 | + SimdU64 => Mask64 (SimdMask64, SimdI64), |
| 81 | + SimdU128 => Mask128 (SimdMask128, SimdI128), |
| 82 | + SimdUsize => MaskSize (SimdMaskSize, SimdIsize), |
| 83 | + |
| 84 | + SimdF32 => Mask32 (SimdMask32, SimdI32), |
| 85 | + SimdF64 => Mask64 (SimdMask64, SimdI64), |
| 86 | +} |
0 commit comments