From 62f6d93ba7aedd7be5bd779bc7404849a5372014 Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Sun, 9 May 2021 22:26:04 -0700 Subject: [PATCH] fix crate::stdsimd --- src/stdsimd.rs | 84 ++++++++++++++++++++++---------------------------- 1 file changed, 37 insertions(+), 47 deletions(-) diff --git a/src/stdsimd.rs b/src/stdsimd.rs index e1a389e..3d757cc 100644 --- a/src/stdsimd.rs +++ b/src/stdsimd.rs @@ -2,8 +2,7 @@ use crate::f16::panic_f16_feature_disabled; use crate::{ f16::F16, - ieee754::FloatEncoding, - scalar, + prim::PrimFloat, traits::{ Bool, Compare, Context, ConvertFrom, ConvertTo, Float, Int, Make, SInt, Select, UInt, }, @@ -566,10 +565,11 @@ macro_rules! impl_int_vector { }; } -macro_rules! impl_uint_vector { - ($ty:ident) => { - impl_int_vector!($ty); - impl UInt for Wrapper<$ty, LANES> +macro_rules! impl_uint_sint_vector { + ($uint:ident, $sint:ident) => { + impl_int_vector!($uint); + impl_int_vector!($sint); + impl UInt for Wrapper<$uint, LANES> where SimdI8: LanesAtMost32, SimdU8: LanesAtMost32, @@ -586,19 +586,11 @@ macro_rules! impl_uint_vector { SimdF64: LanesAtMost32, Mask64: Mask, { + type PrimUInt = Self::Prim; + type SignedType = Wrapper<$sint, LANES>; } - }; -} -impl_uint_vector!(SimdU8); -impl_uint_vector!(SimdU16); -impl_uint_vector!(SimdU32); -impl_uint_vector!(SimdU64); - -macro_rules! impl_uint_scalar { - ($ty:ident) => { - impl_int_scalar!($ty); - impl UInt for Wrapper<$ty, LANES> + impl SInt for Wrapper<$sint, LANES> where SimdI8: LanesAtMost32, SimdU8: LanesAtMost32, @@ -615,19 +607,22 @@ macro_rules! impl_uint_scalar { SimdF64: LanesAtMost32, Mask64: Mask, { + type PrimSInt = Self::Prim; + type UnsignedType = Wrapper<$uint, LANES>; } }; } -impl_uint_scalar!(u8); -impl_uint_scalar!(u16); -impl_uint_scalar!(u32); -impl_uint_scalar!(u64); +impl_uint_sint_vector!(SimdU8, SimdI8); +impl_uint_sint_vector!(SimdU16, SimdI16); +impl_uint_sint_vector!(SimdU32, SimdI32); +impl_uint_sint_vector!(SimdU64, SimdI64); -macro_rules! impl_sint_vector { - ($ty:ident) => { - impl_int_vector!($ty); - impl SInt for Wrapper<$ty, LANES> +macro_rules! impl_uint_sint_scalar { + ($uint:ident, $sint:ident) => { + impl_int_scalar!($uint); + impl_int_scalar!($sint); + impl UInt for Wrapper<$uint, LANES> where SimdI8: LanesAtMost32, SimdU8: LanesAtMost32, @@ -644,19 +639,11 @@ macro_rules! impl_sint_vector { SimdF64: LanesAtMost32, Mask64: Mask, { + type PrimUInt = Self::Prim; + type SignedType = Wrapper<$sint, LANES>; } - }; -} -impl_sint_vector!(SimdI8); -impl_sint_vector!(SimdI16); -impl_sint_vector!(SimdI32); -impl_sint_vector!(SimdI64); - -macro_rules! impl_sint_scalar { - ($ty:ident) => { - impl_int_scalar!($ty); - impl SInt for Wrapper<$ty, LANES> + impl SInt for Wrapper<$sint, LANES> where SimdI8: LanesAtMost32, SimdU8: LanesAtMost32, @@ -673,14 +660,16 @@ macro_rules! impl_sint_scalar { SimdF64: LanesAtMost32, Mask64: Mask, { + type PrimSInt = Self::Prim; + type UnsignedType = Wrapper<$uint, LANES>; } }; } -impl_sint_scalar!(i8); -impl_sint_scalar!(i16); -impl_sint_scalar!(i32); -impl_sint_scalar!(i64); +impl_uint_sint_scalar!(u8, i8); +impl_uint_sint_scalar!(u16, i16); +impl_uint_sint_scalar!(u32, i32); +impl_uint_sint_scalar!(u64, i64); macro_rules! impl_float { ($ty:ident, $prim:ident, $uint:ident, $sint:ident) => { @@ -701,11 +690,11 @@ macro_rules! impl_float { SimdF64: LanesAtMost32, Mask64: Mask, { - type FloatEncoding = $prim; + type PrimFloat = $prim; - type BitsType = Wrapper<<$prim as FloatEncoding>::BitsType, LANES>; + type BitsType = Wrapper<<$prim as PrimFloat>::BitsType, LANES>; - type SignedBitsType = Wrapper<<$prim as FloatEncoding>::SignedBitsType, LANES>; + type SignedBitsType = Wrapper<<$prim as PrimFloat>::SignedBitsType, LANES>; fn abs(self) -> Self { self.0.abs().into() @@ -729,9 +718,10 @@ macro_rules! impl_float { #[cfg(feature = "fma")] fn fma(self, a: Self, b: Self) -> Self { - let a = scalar::Value(a.0); - let b = scalar::Value(b.0); - scalar::Value(self.0).fma(a, b).0.into() + use crate::scalar::Value; + let a = Value(a.0); + let b = Value(b.0); + Value(self.0).fma(a, b).0.into() } fn is_finite(self) -> Self::Bool { @@ -764,7 +754,7 @@ macro_rules! impl_float { SimdF64: LanesAtMost32, Mask64: Mask, { - type FloatEncoding = $prim; + type PrimFloat = $prim; type BitsType = Wrapper<$uint, LANES>; -- 2.30.2