Skip to content

Commit

Permalink
move to array-simd for more architectures
Browse files Browse the repository at this point in the history
  • Loading branch information
Ezrashaw committed May 6, 2023
1 parent 92a0be5 commit f2d8f7c
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 104 deletions.
8 changes: 4 additions & 4 deletions crates/core_arch/src/aarch64/neon/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions crates/core_arch/src/arm/dsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
4 changes: 2 additions & 2 deletions crates/core_arch/src/arm/simd32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
75 changes: 28 additions & 47 deletions crates/core_arch/src/arm_shared/neon/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)]
Expand All @@ -752,28 +738,23 @@ 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)]
#[cfg_attr(
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)]
#[cfg_attr(
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" {
Expand Down
42 changes: 10 additions & 32 deletions crates/core_arch/src/mips/msa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
23 changes: 10 additions & 13 deletions crates/core_arch/src/powerpc/altivec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
8 changes: 4 additions & 4 deletions crates/core_arch/src/powerpc/vsx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f2d8f7c

Please sign in to comment.