Skip to content

Commit f2d8f7c

Browse files
committed
move to array-simd for more architectures
1 parent 92a0be5 commit f2d8f7c

File tree

7 files changed

+60
-104
lines changed

7 files changed

+60
-104
lines changed

crates/core_arch/src/aarch64/neon/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ use stdarch_test::assert_instr;
2121
types! {
2222
/// ARM-specific 64-bit wide vector of one packed `f64`.
2323
#[stable(feature = "neon_intrinsics", since = "1.59.0")]
24-
pub struct float64x1_t(f64); // FIXME: check this!
24+
pub struct float64x1_t([f64; 1]); // FIXME: check this!
2525
/// ARM-specific 128-bit wide vector of two packed `f64`.
2626
#[stable(feature = "neon_intrinsics", since = "1.59.0")]
27-
pub struct float64x2_t(f64, f64);
27+
pub struct float64x2_t([f64; 2]);
2828
}
2929

3030
/// ARM-specific type containing two `float64x1_t` vectors.
@@ -1980,7 +1980,7 @@ pub unsafe fn vdup_n_p64(value: p64) -> poly64x1_t {
19801980
#[cfg_attr(test, assert_instr(nop))]
19811981
#[stable(feature = "neon_intrinsics", since = "1.59.0")]
19821982
pub unsafe fn vdup_n_f64(value: f64) -> float64x1_t {
1983-
float64x1_t(value)
1983+
float64x1_t([value])
19841984
}
19851985

19861986
/// Duplicate vector element to vector or scalar
@@ -1998,7 +1998,7 @@ pub unsafe fn vdupq_n_p64(value: p64) -> poly64x2_t {
19981998
#[cfg_attr(test, assert_instr(dup))]
19991999
#[stable(feature = "neon_intrinsics", since = "1.59.0")]
20002000
pub unsafe fn vdupq_n_f64(value: f64) -> float64x2_t {
2001-
float64x2_t(value, value)
2001+
float64x2_t([value, value])
20022002
}
20032003

20042004
/// Duplicate vector element to vector or scalar

crates/core_arch/src/arm/dsp.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ use crate::mem::transmute;
2727

2828
types! {
2929
/// ARM-specific 32-bit wide vector of two packed `i16`.
30-
pub struct int16x2_t(i16, i16);
30+
pub struct int16x2_t([i16; 2]);
3131
/// ARM-specific 32-bit wide vector of two packed `u16`.
32-
pub struct uint16x2_t(u16, u16);
32+
pub struct uint16x2_t([u16; 2]);
3333
}
3434

3535
extern "unadjusted" {

crates/core_arch/src/arm/simd32.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ use crate::{core_arch::arm::dsp::int16x2_t, mem::transmute};
6969

7070
types! {
7171
/// ARM-specific 32-bit wide vector of four packed `i8`.
72-
pub struct int8x4_t(i8, i8, i8, i8);
72+
pub struct int8x4_t([i8; 4]);
7373
/// ARM-specific 32-bit wide vector of four packed `u8`.
74-
pub struct uint8x4_t(u8, u8, u8, u8);
74+
pub struct uint8x4_t([u8; 4]);
7575
}
7676

7777
macro_rules! dsp_call {

crates/core_arch/src/arm_shared/neon/mod.rs

+28-47
Original file line numberDiff line numberDiff line change
@@ -19,90 +19,81 @@ pub(crate) type p128 = u128;
1919
types! {
2020
/// ARM-specific 64-bit wide vector of eight packed `i8`.
2121
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
22-
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);
22+
pub struct int8x8_t(pub(crate) [i8; 8]);
2323
/// ARM-specific 64-bit wide vector of eight packed `u8`.
2424
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
25-
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);
25+
pub struct uint8x8_t(pub(crate) [u8; 8]);
2626
/// ARM-specific 64-bit wide polynomial vector of eight packed `p8`.
2727
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
28-
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);
28+
pub struct poly8x8_t(pub(crate) [p8; 8]);
2929
/// ARM-specific 64-bit wide vector of four packed `i16`.
3030
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
31-
pub struct int16x4_t(pub(crate) i16, pub(crate) i16, pub(crate) i16, pub(crate) i16);
31+
pub struct int16x4_t(pub(crate) [i16; 4]);
3232
/// ARM-specific 64-bit wide vector of four packed `u16`.
3333
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
34-
pub struct uint16x4_t(pub(crate) u16, pub(crate) u16, pub(crate) u16, pub(crate) u16);
34+
pub struct uint16x4_t(pub(crate) [u16; 4]);
3535
// FIXME: ARM-specific 64-bit wide vector of four packed `f16`.
3636
// pub struct float16x4_t(f16, f16, f16, f16);
3737
/// ARM-specific 64-bit wide vector of four packed `p16`.
3838
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
39-
pub struct poly16x4_t(pub(crate) p16, pub(crate) p16, pub(crate) p16, pub(crate) p16);
39+
pub struct poly16x4_t(pub(crate) [p16; 4]);
4040
/// ARM-specific 64-bit wide vector of two packed `i32`.
4141
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
42-
pub struct int32x2_t(pub(crate) i32, pub(crate) i32);
42+
pub struct int32x2_t(pub(crate) [i32; 2]);
4343
/// ARM-specific 64-bit wide vector of two packed `u32`.
4444
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
45-
pub struct uint32x2_t(pub(crate) u32, pub(crate) u32);
45+
pub struct uint32x2_t(pub(crate) [u32; 2]);
4646
/// ARM-specific 64-bit wide vector of two packed `f32`.
4747
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
48-
pub struct float32x2_t(pub(crate) f32, pub(crate) f32);
48+
pub struct float32x2_t(pub(crate) [f32; 2]);
4949
/// ARM-specific 64-bit wide vector of one packed `i64`.
5050
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
51-
pub struct int64x1_t(pub(crate) i64);
51+
pub struct int64x1_t(pub(crate) [i64; 1]);
5252
/// ARM-specific 64-bit wide vector of one packed `u64`.
5353
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
54-
pub struct uint64x1_t(pub(crate) u64);
54+
pub struct uint64x1_t(pub(crate) [u64; 1]);
5555
/// ARM-specific 64-bit wide vector of one packed `p64`.
5656
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
57-
pub struct poly64x1_t(pub(crate) p64);
57+
pub struct poly64x1_t(pub(crate) [p64; 1]);
5858

5959
/// ARM-specific 128-bit wide vector of sixteen packed `i8`.
6060
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
61-
pub struct int8x16_t(
62-
pub(crate) i8, pub(crate) i8, pub(crate) i8, pub(crate) i8, pub(crate) i8, pub(crate) i8 , pub(crate) i8, pub(crate) i8,
63-
pub(crate) i8, pub(crate) i8, pub(crate) i8, pub(crate) i8, pub(crate) i8, pub(crate) i8 , pub(crate) i8, pub(crate) i8,
64-
);
61+
pub struct int8x16_t(pub(crate) [i8; 16]);
6562
/// ARM-specific 128-bit wide vector of sixteen packed `u8`.
6663
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
67-
pub struct uint8x16_t(
68-
pub(crate) u8, pub(crate) u8 , pub(crate) u8, pub(crate) u8, pub(crate) u8, pub(crate) u8 , pub(crate) u8, pub(crate) u8,
69-
pub(crate) u8, pub(crate) u8 , pub(crate) u8, pub(crate) u8, pub(crate) u8, pub(crate) u8 , pub(crate) u8, pub(crate) u8,
70-
);
64+
pub struct uint8x16_t(pub(crate) [u8; 16]);
7165
/// ARM-specific 128-bit wide vector of sixteen packed `p8`.
7266
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
73-
pub struct poly8x16_t(
74-
pub(crate) p8, pub(crate) p8, pub(crate) p8, pub(crate) p8, pub(crate) p8, pub(crate) p8, pub(crate) p8, pub(crate) p8,
75-
pub(crate) p8, pub(crate) p8, pub(crate) p8, pub(crate) p8, pub(crate) p8, pub(crate) p8, pub(crate) p8, pub(crate) p8,
76-
);
67+
pub struct poly8x16_t(pub(crate) [p8; 16]);
7768
/// ARM-specific 128-bit wide vector of eight packed `i16`.
7869
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
79-
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);
70+
pub struct int16x8_t(pub(crate) [i16; 8]);
8071
/// ARM-specific 128-bit wide vector of eight packed `u16`.
8172
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
82-
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);
73+
pub struct uint16x8_t(pub(crate) [u16; 8]);
8374
// FIXME: ARM-specific 128-bit wide vector of eight packed `f16`.
8475
// pub struct float16x8_t(f16, f16, f16, f16, f16, f16, f16);
8576
/// ARM-specific 128-bit wide vector of eight packed `p16`.
8677
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
87-
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);
78+
pub struct poly16x8_t(pub(crate) [p16; 8]);
8879
/// ARM-specific 128-bit wide vector of four packed `i32`.
8980
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
90-
pub struct int32x4_t(pub(crate) i32, pub(crate) i32, pub(crate) i32, pub(crate) i32);
81+
pub struct int32x4_t(pub(crate) [i32; 4]);
9182
/// ARM-specific 128-bit wide vector of four packed `u32`.
9283
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
93-
pub struct uint32x4_t(pub(crate) u32, pub(crate) u32, pub(crate) u32, pub(crate) u32);
84+
pub struct uint32x4_t(pub(crate) [u32; 4]);
9485
/// ARM-specific 128-bit wide vector of four packed `f32`.
9586
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
96-
pub struct float32x4_t(pub(crate) f32, pub(crate) f32, pub(crate) f32, pub(crate) f32);
87+
pub struct float32x4_t(pub(crate) [f32; 4]);
9788
/// ARM-specific 128-bit wide vector of two packed `i64`.
9889
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
99-
pub struct int64x2_t(pub(crate) i64, pub(crate) i64);
90+
pub struct int64x2_t(pub(crate) [i64; 2]);
10091
/// ARM-specific 128-bit wide vector of two packed `u64`.
10192
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
102-
pub struct uint64x2_t(pub(crate) u64, pub(crate) u64);
93+
pub struct uint64x2_t(pub(crate) [u64; 2]);
10394
/// ARM-specific 128-bit wide vector of two packed `p64`.
10495
#[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))]
105-
pub struct poly64x2_t(pub(crate) p64, pub(crate) p64);
96+
pub struct poly64x2_t(pub(crate) [p64; 2]);
10697
}
10798

10899
/// 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);
738729
not(target_arch = "arm"),
739730
stable(feature = "neon_intrinsics", since = "1.59.0")
740731
)]
741-
pub struct poly64x1x4_t(
742-
pub poly64x1_t,
743-
pub poly64x1_t,
744-
pub poly64x1_t,
745-
pub poly64x1_t,
746-
);
732+
pub struct poly64x1x4_t(pub [poly64x1_t; 4]);
747733

748734
/// ARM-specific type containing four `poly64x2_t` vectors.
749735
#[repr(C)]
@@ -752,28 +738,23 @@ pub struct poly64x1x4_t(
752738
not(target_arch = "arm"),
753739
stable(feature = "neon_intrinsics", since = "1.59.0")
754740
)]
755-
pub struct poly64x2x2_t(pub poly64x2_t, pub poly64x2_t);
741+
pub struct poly64x2x2_t(pub [poly64x2_t; 2]);
756742
/// ARM-specific type containing four `poly64x2_t` vectors.
757743
#[repr(C)]
758744
#[derive(Copy, Clone, Debug)]
759745
#[cfg_attr(
760746
not(target_arch = "arm"),
761747
stable(feature = "neon_intrinsics", since = "1.59.0")
762748
)]
763-
pub struct poly64x2x3_t(pub poly64x2_t, pub poly64x2_t, pub poly64x2_t);
749+
pub struct poly64x2x3_t(pub [poly64x2_t; 3]);
764750
/// ARM-specific type containing four `poly64x2_t` vectors.
765751
#[repr(C)]
766752
#[derive(Copy, Clone, Debug)]
767753
#[cfg_attr(
768754
not(target_arch = "arm"),
769755
stable(feature = "neon_intrinsics", since = "1.59.0")
770756
)]
771-
pub struct poly64x2x4_t(
772-
pub poly64x2_t,
773-
pub poly64x2_t,
774-
pub poly64x2_t,
775-
pub poly64x2_t,
776-
);
757+
pub struct poly64x2x4_t(pub [poly64x2_t; 4]);
777758

778759
#[allow(improper_ctypes)]
779760
extern "unadjusted" {

crates/core_arch/src/mips/msa.rs

+10-32
Original file line numberDiff line numberDiff line change
@@ -12,56 +12,34 @@ use crate::mem;
1212

1313
types! {
1414
// / MIPS-specific 128-bit wide vector of 16 packed `i8`.
15-
pub struct v16i8(
16-
i8, i8, i8, i8, i8, i8, i8, i8,
17-
i8, i8, i8, i8, i8, i8, i8, i8,
18-
);
15+
pub struct v16i8([i8; 16]);
1916

2017
// / MIPS-specific 128-bit wide vector of 8 packed `i16`.
21-
pub struct v8i16(
22-
i16, i16, i16, i16, i16, i16, i16, i16,
23-
);
18+
pub struct v8i16([i16; 8]);
2419

2520
// / MIPS-specific 128-bit wide vector of 4 packed `i32`.
26-
pub struct v4i32(
27-
i32, i32, i32, i32,
28-
);
21+
pub struct v4i32([i32; 4]);
2922

3023
// / MIPS-specific 128-bit wide vector of 2 packed `i64`.
31-
pub struct v2i64(
32-
i64, i64,
33-
);
24+
pub struct v2i64([i64; 2]);
3425

3526
// / MIPS-specific 128-bit wide vector of 16 packed `u8`.
36-
pub struct v16u8(
37-
u8, u8, u8, u8, u8, u8, u8, u8,
38-
u8, u8, u8, u8, u8, u8, u8, u8,
39-
);
27+
pub struct v16u8([u8; 16]);
4028

4129
// / MIPS-specific 128-bit wide vector of 8 packed `u16`.
42-
pub struct v8u16(
43-
u16, u16, u16, u16, u16, u16, u16, u16,
44-
);
30+
pub struct v8u16([u16; 8]);
4531

4632
// / MIPS-specific 128-bit wide vector of 4 packed `u32`.
47-
pub struct v4u32(
48-
u32, u32, u32, u32,
49-
);
33+
pub struct v4u32([u32; 4]);
5034

5135
// / MIPS-specific 128-bit wide vector of 2 packed `u64`.
52-
pub struct v2u64(
53-
u64, u64,
54-
);
36+
pub struct v2u64([u64; 2]);
5537

5638
// / MIPS-specific 128-bit wide vector of 4 packed `f32`.
57-
pub struct v4f32(
58-
f32, f32, f32, f32,
59-
);
39+
pub struct v4f32([f32; 4]);
6040

6141
// / MIPS-specific 128-bit wide vector of 2 packed `f64`.
62-
pub struct v2f64(
63-
f64, f64,
64-
);
42+
pub struct v2f64([f64; 2]);
6543
}
6644

6745
#[allow(improper_ctypes)]

crates/core_arch/src/powerpc/altivec.rs

+10-13
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,27 @@ use stdarch_test::assert_instr;
2323

2424
types! {
2525
/// PowerPC-specific 128-bit wide vector of sixteen packed `i8`
26-
pub struct vector_signed_char(i8, i8, i8, i8, i8, i8, i8, i8,
27-
i8, i8, i8, i8, i8, i8, i8, i8);
26+
pub struct vector_signed_char([i8; 16]);
2827
/// PowerPC-specific 128-bit wide vector of sixteen packed `u8`
29-
pub struct vector_unsigned_char(u8, u8, u8, u8, u8, u8, u8, u8,
30-
u8, u8, u8, u8, u8, u8, u8, u8);
28+
pub struct vector_unsigned_char([u8; 16]);
3129

3230
/// PowerPC-specific 128-bit wide vector mask of sixteen packed elements
33-
pub struct vector_bool_char(i8, i8, i8, i8, i8, i8, i8, i8,
34-
i8, i8, i8, i8, i8, i8, i8, i8);
31+
pub struct vector_bool_char([i8; 16]);
3532
/// PowerPC-specific 128-bit wide vector of eight packed `i16`
36-
pub struct vector_signed_short(i16, i16, i16, i16, i16, i16, i16, i16);
33+
pub struct vector_signed_short([i16; 8]);
3734
/// PowerPC-specific 128-bit wide vector of eight packed `u16`
38-
pub struct vector_unsigned_short(u16, u16, u16, u16, u16, u16, u16, u16);
35+
pub struct vector_unsigned_short([u16; 8]);
3936
/// PowerPC-specific 128-bit wide vector mask of eight packed elements
40-
pub struct vector_bool_short(i16, i16, i16, i16, i16, i16, i16, i16);
37+
pub struct vector_bool_short([i16; 8]);
4138
// pub struct vector_pixel(???);
4239
/// PowerPC-specific 128-bit wide vector of four packed `i32`
43-
pub struct vector_signed_int(i32, i32, i32, i32);
40+
pub struct vector_signed_int([i32; 4]);
4441
/// PowerPC-specific 128-bit wide vector of four packed `u32`
45-
pub struct vector_unsigned_int(u32, u32, u32, u32);
42+
pub struct vector_unsigned_int([u32; 4]);
4643
/// PowerPC-specific 128-bit wide vector mask of four packed elements
47-
pub struct vector_bool_int(i32, i32, i32, i32);
44+
pub struct vector_bool_int([i32; 4]);
4845
/// PowerPC-specific 128-bit wide vector of four packed `f32`
49-
pub struct vector_float(f32, f32, f32, f32);
46+
pub struct vector_float([f32; 4]);
5047
}
5148

5249
#[allow(improper_ctypes)]

crates/core_arch/src/powerpc/vsx.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ use crate::mem::transmute;
1818
types! {
1919
// pub struct vector_Float16 = f16x8;
2020
/// PowerPC-specific 128-bit wide vector of two packed `i64`
21-
pub struct vector_signed_long(i64, i64);
21+
pub struct vector_signed_long([i64; 2]);
2222
/// PowerPC-specific 128-bit wide vector of two packed `u64`
23-
pub struct vector_unsigned_long(u64, u64);
23+
pub struct vector_unsigned_long([u64; 2]);
2424
/// PowerPC-specific 128-bit wide vector mask of two `i64`
25-
pub struct vector_bool_long(i64, i64);
25+
pub struct vector_bool_long([i64; 2]);
2626
/// PowerPC-specific 128-bit wide vector of two packed `f64`
27-
pub struct vector_double(f64, f64);
27+
pub struct vector_double([f64; 2]);
2828
// pub struct vector_signed_long_long = vector_signed_long;
2929
// pub struct vector_unsigned_long_long = vector_unsigned_long;
3030
// pub struct vector_bool_long_long = vector_bool_long;

0 commit comments

Comments
 (0)