From f2d8f7c405b6ab520e6550221f865c1b15e73f1c Mon Sep 17 00:00:00 2001 From: Ezra Shaw Date: Sat, 6 May 2023 12:24:59 +1200 Subject: [PATCH] move to array-simd for more architectures --- crates/core_arch/src/aarch64/neon/mod.rs | 8 +-- crates/core_arch/src/arm/dsp.rs | 4 +- crates/core_arch/src/arm/simd32.rs | 4 +- crates/core_arch/src/arm_shared/neon/mod.rs | 75 ++++++++------------- crates/core_arch/src/mips/msa.rs | 42 +++--------- crates/core_arch/src/powerpc/altivec.rs | 23 +++---- crates/core_arch/src/powerpc/vsx.rs | 8 +-- 7 files changed, 60 insertions(+), 104 deletions(-) diff --git a/crates/core_arch/src/aarch64/neon/mod.rs b/crates/core_arch/src/aarch64/neon/mod.rs index 8506570337..c5f941d3dc 100644 --- a/crates/core_arch/src/aarch64/neon/mod.rs +++ b/crates/core_arch/src/aarch64/neon/mod.rs @@ -21,10 +21,10 @@ use stdarch_test::assert_instr; types! { /// ARM-specific 64-bit wide vector of one packed `f64`. #[stable(feature = "neon_intrinsics", since = "1.59.0")] - pub struct float64x1_t(f64); // FIXME: check this! + pub struct float64x1_t([f64; 1]); // FIXME: check this! /// ARM-specific 128-bit wide vector of two packed `f64`. #[stable(feature = "neon_intrinsics", since = "1.59.0")] - pub struct float64x2_t(f64, f64); + pub struct float64x2_t([f64; 2]); } /// ARM-specific type containing two `float64x1_t` vectors. @@ -1980,7 +1980,7 @@ pub unsafe fn vdup_n_p64(value: p64) -> poly64x1_t { #[cfg_attr(test, assert_instr(nop))] #[stable(feature = "neon_intrinsics", since = "1.59.0")] pub unsafe fn vdup_n_f64(value: f64) -> float64x1_t { - float64x1_t(value) + float64x1_t([value]) } /// Duplicate vector element to vector or scalar @@ -1998,7 +1998,7 @@ pub unsafe fn vdupq_n_p64(value: p64) -> poly64x2_t { #[cfg_attr(test, assert_instr(dup))] #[stable(feature = "neon_intrinsics", since = "1.59.0")] pub unsafe fn vdupq_n_f64(value: f64) -> float64x2_t { - float64x2_t(value, value) + float64x2_t([value, value]) } /// Duplicate vector element to vector or scalar diff --git a/crates/core_arch/src/arm/dsp.rs b/crates/core_arch/src/arm/dsp.rs index 6720f97a53..670742c002 100644 --- a/crates/core_arch/src/arm/dsp.rs +++ b/crates/core_arch/src/arm/dsp.rs @@ -27,9 +27,9 @@ use crate::mem::transmute; types! { /// ARM-specific 32-bit wide vector of two packed `i16`. - pub struct int16x2_t(i16, i16); + pub struct int16x2_t([i16; 2]); /// ARM-specific 32-bit wide vector of two packed `u16`. - pub struct uint16x2_t(u16, u16); + pub struct uint16x2_t([u16; 2]); } extern "unadjusted" { diff --git a/crates/core_arch/src/arm/simd32.rs b/crates/core_arch/src/arm/simd32.rs index 2d867acc83..74e1e92a9b 100644 --- a/crates/core_arch/src/arm/simd32.rs +++ b/crates/core_arch/src/arm/simd32.rs @@ -69,9 +69,9 @@ use crate::{core_arch::arm::dsp::int16x2_t, mem::transmute}; types! { /// ARM-specific 32-bit wide vector of four packed `i8`. - pub struct int8x4_t(i8, i8, i8, i8); + pub struct int8x4_t([i8; 4]); /// ARM-specific 32-bit wide vector of four packed `u8`. - pub struct uint8x4_t(u8, u8, u8, u8); + pub struct uint8x4_t([u8; 4]); } macro_rules! dsp_call { diff --git a/crates/core_arch/src/arm_shared/neon/mod.rs b/crates/core_arch/src/arm_shared/neon/mod.rs index 8a8f4febf6..21abdca815 100644 --- a/crates/core_arch/src/arm_shared/neon/mod.rs +++ b/crates/core_arch/src/arm_shared/neon/mod.rs @@ -19,90 +19,81 @@ pub(crate) type p128 = u128; types! { /// ARM-specific 64-bit wide vector of eight packed `i8`. #[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))] - pub struct int8x8_t(pub(crate) i8, pub(crate) i8, pub(crate) i8, pub(crate) i8, pub(crate) i8, pub(crate) i8, pub(crate) i8, pub(crate) i8); + pub struct int8x8_t(pub(crate) [i8; 8]); /// ARM-specific 64-bit wide vector of eight packed `u8`. #[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))] - pub struct uint8x8_t(pub(crate) u8, pub(crate) u8, pub(crate) u8, pub(crate) u8, pub(crate) u8, pub(crate) u8, pub(crate) u8, pub(crate) u8); + pub struct uint8x8_t(pub(crate) [u8; 8]); /// ARM-specific 64-bit wide polynomial vector of eight packed `p8`. #[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))] - pub struct poly8x8_t(pub(crate) p8, pub(crate) p8, pub(crate) p8, pub(crate) p8, pub(crate) p8, pub(crate) p8, pub(crate) p8, pub(crate) p8); + pub struct poly8x8_t(pub(crate) [p8; 8]); /// ARM-specific 64-bit wide vector of four packed `i16`. #[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))] - pub struct int16x4_t(pub(crate) i16, pub(crate) i16, pub(crate) i16, pub(crate) i16); + pub struct int16x4_t(pub(crate) [i16; 4]); /// ARM-specific 64-bit wide vector of four packed `u16`. #[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))] - pub struct uint16x4_t(pub(crate) u16, pub(crate) u16, pub(crate) u16, pub(crate) u16); + pub struct uint16x4_t(pub(crate) [u16; 4]); // FIXME: ARM-specific 64-bit wide vector of four packed `f16`. // pub struct float16x4_t(f16, f16, f16, f16); /// ARM-specific 64-bit wide vector of four packed `p16`. #[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))] - pub struct poly16x4_t(pub(crate) p16, pub(crate) p16, pub(crate) p16, pub(crate) p16); + pub struct poly16x4_t(pub(crate) [p16; 4]); /// ARM-specific 64-bit wide vector of two packed `i32`. #[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))] - pub struct int32x2_t(pub(crate) i32, pub(crate) i32); + pub struct int32x2_t(pub(crate) [i32; 2]); /// ARM-specific 64-bit wide vector of two packed `u32`. #[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))] - pub struct uint32x2_t(pub(crate) u32, pub(crate) u32); + pub struct uint32x2_t(pub(crate) [u32; 2]); /// ARM-specific 64-bit wide vector of two packed `f32`. #[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))] - pub struct float32x2_t(pub(crate) f32, pub(crate) f32); + pub struct float32x2_t(pub(crate) [f32; 2]); /// ARM-specific 64-bit wide vector of one packed `i64`. #[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))] - pub struct int64x1_t(pub(crate) i64); + pub struct int64x1_t(pub(crate) [i64; 1]); /// ARM-specific 64-bit wide vector of one packed `u64`. #[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))] - pub struct uint64x1_t(pub(crate) u64); + pub struct uint64x1_t(pub(crate) [u64; 1]); /// ARM-specific 64-bit wide vector of one packed `p64`. #[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))] - pub struct poly64x1_t(pub(crate) p64); + pub struct poly64x1_t(pub(crate) [p64; 1]); /// ARM-specific 128-bit wide vector of sixteen packed `i8`. #[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))] - pub struct int8x16_t( - pub(crate) i8, pub(crate) i8, pub(crate) i8, pub(crate) i8, pub(crate) i8, pub(crate) i8 , pub(crate) i8, pub(crate) i8, - pub(crate) i8, pub(crate) i8, pub(crate) i8, pub(crate) i8, pub(crate) i8, pub(crate) i8 , pub(crate) i8, pub(crate) i8, - ); + pub struct int8x16_t(pub(crate) [i8; 16]); /// ARM-specific 128-bit wide vector of sixteen packed `u8`. #[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))] - pub struct uint8x16_t( - pub(crate) u8, pub(crate) u8 , pub(crate) u8, pub(crate) u8, pub(crate) u8, pub(crate) u8 , pub(crate) u8, pub(crate) u8, - pub(crate) u8, pub(crate) u8 , pub(crate) u8, pub(crate) u8, pub(crate) u8, pub(crate) u8 , pub(crate) u8, pub(crate) u8, - ); + pub struct uint8x16_t(pub(crate) [u8; 16]); /// ARM-specific 128-bit wide vector of sixteen packed `p8`. #[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))] - pub struct poly8x16_t( - pub(crate) p8, pub(crate) p8, pub(crate) p8, pub(crate) p8, pub(crate) p8, pub(crate) p8, pub(crate) p8, pub(crate) p8, - pub(crate) p8, pub(crate) p8, pub(crate) p8, pub(crate) p8, pub(crate) p8, pub(crate) p8, pub(crate) p8, pub(crate) p8, - ); + pub struct poly8x16_t(pub(crate) [p8; 16]); /// ARM-specific 128-bit wide vector of eight packed `i16`. #[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))] - pub struct int16x8_t(pub(crate) i16, pub(crate) i16, pub(crate) i16, pub(crate) i16, pub(crate) i16, pub(crate) i16, pub(crate) i16, pub(crate) i16); + pub struct int16x8_t(pub(crate) [i16; 8]); /// ARM-specific 128-bit wide vector of eight packed `u16`. #[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))] - pub struct uint16x8_t(pub(crate) u16, pub(crate) u16, pub(crate) u16, pub(crate) u16, pub(crate) u16, pub(crate) u16, pub(crate) u16, pub(crate) u16); + pub struct uint16x8_t(pub(crate) [u16; 8]); // FIXME: ARM-specific 128-bit wide vector of eight packed `f16`. // pub struct float16x8_t(f16, f16, f16, f16, f16, f16, f16); /// ARM-specific 128-bit wide vector of eight packed `p16`. #[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))] - pub struct poly16x8_t(pub(crate) p16, pub(crate) p16, pub(crate) p16, pub(crate) p16, pub(crate) p16, pub(crate) p16, pub(crate) p16, pub(crate) p16); + pub struct poly16x8_t(pub(crate) [p16; 8]); /// ARM-specific 128-bit wide vector of four packed `i32`. #[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))] - pub struct int32x4_t(pub(crate) i32, pub(crate) i32, pub(crate) i32, pub(crate) i32); + pub struct int32x4_t(pub(crate) [i32; 4]); /// ARM-specific 128-bit wide vector of four packed `u32`. #[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))] - pub struct uint32x4_t(pub(crate) u32, pub(crate) u32, pub(crate) u32, pub(crate) u32); + pub struct uint32x4_t(pub(crate) [u32; 4]); /// ARM-specific 128-bit wide vector of four packed `f32`. #[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))] - pub struct float32x4_t(pub(crate) f32, pub(crate) f32, pub(crate) f32, pub(crate) f32); + pub struct float32x4_t(pub(crate) [f32; 4]); /// ARM-specific 128-bit wide vector of two packed `i64`. #[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))] - pub struct int64x2_t(pub(crate) i64, pub(crate) i64); + pub struct int64x2_t(pub(crate) [i64; 2]); /// ARM-specific 128-bit wide vector of two packed `u64`. #[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))] - pub struct uint64x2_t(pub(crate) u64, pub(crate) u64); + pub struct uint64x2_t(pub(crate) [u64; 2]); /// ARM-specific 128-bit wide vector of two packed `p64`. #[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))] - pub struct poly64x2_t(pub(crate) p64, pub(crate) p64); + pub struct poly64x2_t(pub(crate) [p64; 2]); } /// ARM-specific type containing two `int8x8_t` vectors. @@ -738,12 +729,7 @@ pub struct poly64x1x3_t(pub poly64x1_t, pub poly64x1_t, pub poly64x1_t); not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0") )] -pub struct poly64x1x4_t( - pub poly64x1_t, - pub poly64x1_t, - pub poly64x1_t, - pub poly64x1_t, -); +pub struct poly64x1x4_t(pub [poly64x1_t; 4]); /// ARM-specific type containing four `poly64x2_t` vectors. #[repr(C)] @@ -752,7 +738,7 @@ pub struct poly64x1x4_t( not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0") )] -pub struct poly64x2x2_t(pub poly64x2_t, pub poly64x2_t); +pub struct poly64x2x2_t(pub [poly64x2_t; 2]); /// ARM-specific type containing four `poly64x2_t` vectors. #[repr(C)] #[derive(Copy, Clone, Debug)] @@ -760,7 +746,7 @@ pub struct poly64x2x2_t(pub poly64x2_t, pub poly64x2_t); not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0") )] -pub struct poly64x2x3_t(pub poly64x2_t, pub poly64x2_t, pub poly64x2_t); +pub struct poly64x2x3_t(pub [poly64x2_t; 3]); /// ARM-specific type containing four `poly64x2_t` vectors. #[repr(C)] #[derive(Copy, Clone, Debug)] @@ -768,12 +754,7 @@ pub struct poly64x2x3_t(pub poly64x2_t, pub poly64x2_t, pub poly64x2_t); not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0") )] -pub struct poly64x2x4_t( - pub poly64x2_t, - pub poly64x2_t, - pub poly64x2_t, - pub poly64x2_t, -); +pub struct poly64x2x4_t(pub [poly64x2_t; 4]); #[allow(improper_ctypes)] extern "unadjusted" { diff --git a/crates/core_arch/src/mips/msa.rs b/crates/core_arch/src/mips/msa.rs index 3e93db85e2..67a13de1e8 100644 --- a/crates/core_arch/src/mips/msa.rs +++ b/crates/core_arch/src/mips/msa.rs @@ -12,56 +12,34 @@ use crate::mem; types! { // / MIPS-specific 128-bit wide vector of 16 packed `i8`. - pub struct v16i8( - i8, i8, i8, i8, i8, i8, i8, i8, - i8, i8, i8, i8, i8, i8, i8, i8, - ); + pub struct v16i8([i8; 16]); // / MIPS-specific 128-bit wide vector of 8 packed `i16`. - pub struct v8i16( - i16, i16, i16, i16, i16, i16, i16, i16, - ); + pub struct v8i16([i16; 8]); // / MIPS-specific 128-bit wide vector of 4 packed `i32`. - pub struct v4i32( - i32, i32, i32, i32, - ); + pub struct v4i32([i32; 4]); // / MIPS-specific 128-bit wide vector of 2 packed `i64`. - pub struct v2i64( - i64, i64, - ); + pub struct v2i64([i64; 2]); // / MIPS-specific 128-bit wide vector of 16 packed `u8`. - pub struct v16u8( - u8, u8, u8, u8, u8, u8, u8, u8, - u8, u8, u8, u8, u8, u8, u8, u8, - ); + pub struct v16u8([u8; 16]); // / MIPS-specific 128-bit wide vector of 8 packed `u16`. - pub struct v8u16( - u16, u16, u16, u16, u16, u16, u16, u16, - ); + pub struct v8u16([u16; 8]); // / MIPS-specific 128-bit wide vector of 4 packed `u32`. - pub struct v4u32( - u32, u32, u32, u32, - ); + pub struct v4u32([u32; 4]); // / MIPS-specific 128-bit wide vector of 2 packed `u64`. - pub struct v2u64( - u64, u64, - ); + pub struct v2u64([u64; 2]); // / MIPS-specific 128-bit wide vector of 4 packed `f32`. - pub struct v4f32( - f32, f32, f32, f32, - ); + pub struct v4f32([f32; 4]); // / MIPS-specific 128-bit wide vector of 2 packed `f64`. - pub struct v2f64( - f64, f64, - ); + pub struct v2f64([f64; 2]); } #[allow(improper_ctypes)] diff --git a/crates/core_arch/src/powerpc/altivec.rs b/crates/core_arch/src/powerpc/altivec.rs index 8f6daf13f1..396b2afe6b 100644 --- a/crates/core_arch/src/powerpc/altivec.rs +++ b/crates/core_arch/src/powerpc/altivec.rs @@ -23,30 +23,27 @@ use stdarch_test::assert_instr; types! { /// PowerPC-specific 128-bit wide vector of sixteen packed `i8` - pub struct vector_signed_char(i8, i8, i8, i8, i8, i8, i8, i8, - i8, i8, i8, i8, i8, i8, i8, i8); + pub struct vector_signed_char([i8; 16]); /// PowerPC-specific 128-bit wide vector of sixteen packed `u8` - pub struct vector_unsigned_char(u8, u8, u8, u8, u8, u8, u8, u8, - u8, u8, u8, u8, u8, u8, u8, u8); + pub struct vector_unsigned_char([u8; 16]); /// PowerPC-specific 128-bit wide vector mask of sixteen packed elements - pub struct vector_bool_char(i8, i8, i8, i8, i8, i8, i8, i8, - i8, i8, i8, i8, i8, i8, i8, i8); + pub struct vector_bool_char([i8; 16]); /// PowerPC-specific 128-bit wide vector of eight packed `i16` - pub struct vector_signed_short(i16, i16, i16, i16, i16, i16, i16, i16); + pub struct vector_signed_short([i16; 8]); /// PowerPC-specific 128-bit wide vector of eight packed `u16` - pub struct vector_unsigned_short(u16, u16, u16, u16, u16, u16, u16, u16); + pub struct vector_unsigned_short([u16; 8]); /// PowerPC-specific 128-bit wide vector mask of eight packed elements - pub struct vector_bool_short(i16, i16, i16, i16, i16, i16, i16, i16); + pub struct vector_bool_short([i16; 8]); // pub struct vector_pixel(???); /// PowerPC-specific 128-bit wide vector of four packed `i32` - pub struct vector_signed_int(i32, i32, i32, i32); + pub struct vector_signed_int([i32; 4]); /// PowerPC-specific 128-bit wide vector of four packed `u32` - pub struct vector_unsigned_int(u32, u32, u32, u32); + pub struct vector_unsigned_int([u32; 4]); /// PowerPC-specific 128-bit wide vector mask of four packed elements - pub struct vector_bool_int(i32, i32, i32, i32); + pub struct vector_bool_int([i32; 4]); /// PowerPC-specific 128-bit wide vector of four packed `f32` - pub struct vector_float(f32, f32, f32, f32); + pub struct vector_float([f32; 4]); } #[allow(improper_ctypes)] diff --git a/crates/core_arch/src/powerpc/vsx.rs b/crates/core_arch/src/powerpc/vsx.rs index f2ebc23b21..bfb8057796 100644 --- a/crates/core_arch/src/powerpc/vsx.rs +++ b/crates/core_arch/src/powerpc/vsx.rs @@ -18,13 +18,13 @@ use crate::mem::transmute; types! { // pub struct vector_Float16 = f16x8; /// PowerPC-specific 128-bit wide vector of two packed `i64` - pub struct vector_signed_long(i64, i64); + pub struct vector_signed_long([i64; 2]); /// PowerPC-specific 128-bit wide vector of two packed `u64` - pub struct vector_unsigned_long(u64, u64); + pub struct vector_unsigned_long([u64; 2]); /// PowerPC-specific 128-bit wide vector mask of two `i64` - pub struct vector_bool_long(i64, i64); + pub struct vector_bool_long([i64; 2]); /// PowerPC-specific 128-bit wide vector of two packed `f64` - pub struct vector_double(f64, f64); + pub struct vector_double([f64; 2]); // pub struct vector_signed_long_long = vector_signed_long; // pub struct vector_unsigned_long_long = vector_unsigned_long; // pub struct vector_bool_long_long = vector_bool_long;