Skip to content

Commit ca15e4f

Browse files
cat vector types by kind
Rearrange aliases to bottom of files
1 parent 27f094f commit ca15e4f

15 files changed

+262
-295
lines changed

crates/core_simd/src/vector.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,3 @@
1-
mod vectors_f64;
2-
mod vectors_i128;
3-
mod vectors_i16;
4-
mod vectors_i32;
5-
mod vectors_i64;
6-
mod vectors_i8;
7-
mod vectors_u128;
8-
mod vectors_u16;
9-
mod vectors_u32;
10-
mod vectors_u64;
11-
mod vectors_u8;
12-
13-
pub use vectors_f64::*;
14-
pub use vectors_i128::*;
15-
pub use vectors_i16::*;
16-
pub use vectors_i32::*;
17-
pub use vectors_i64::*;
18-
pub use vectors_i8::*;
19-
pub use vectors_u128::*;
20-
pub use vectors_u16::*;
21-
pub use vectors_u32::*;
22-
pub use vectors_u64::*;
23-
pub use vectors_u8::*;
24-
251
mod float;
262
mod int;
273
mod uint;

crates/core_simd/src/vector/float.rs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,22 @@ where
88

99
impl_float_vector! { SimdF32, f32, SimdU32 }
1010

11+
from_transmute_x86! { unsafe f32x4 => __m128 }
12+
from_transmute_x86! { unsafe f32x8 => __m256 }
13+
//from_transmute_x86! { unsafe f32x16 => __m512 }
14+
15+
/// A SIMD vector of containing `LANES` `f64` values.
16+
#[repr(simd)]
17+
pub struct SimdF64<const LANES: usize>([f64; LANES])
18+
where
19+
Self: crate::LanesAtMost64;
20+
21+
impl_float_vector! { SimdF64, f64, SimdU64 }
22+
23+
from_transmute_x86! { unsafe f64x2 => __m128d }
24+
from_transmute_x86! { unsafe f64x4 => __m256d }
25+
//from_transmute_x86! { unsafe f64x8 => __m512d }
26+
1127
/// Vector of two `f32` values
1228
pub type f32x2 = SimdF32<2>;
1329

@@ -20,6 +36,11 @@ pub type f32x8 = SimdF32<8>;
2036
/// Vector of 16 `f32` values
2137
pub type f32x16 = SimdF32<16>;
2238

23-
from_transmute_x86! { unsafe f32x4 => __m128 }
24-
from_transmute_x86! { unsafe f32x8 => __m256 }
25-
//from_transmute_x86! { unsafe f32x16 => __m512 }
39+
/// Vector of two `f64` values
40+
pub type f64x2 = SimdF64<2>;
41+
42+
/// Vector of four `f64` values
43+
pub type f64x4 = SimdF64<4>;
44+
45+
/// Vector of eight `f64` values
46+
pub type f64x8 = SimdF64<8>;

crates/core_simd/src/vector/int.rs

Lines changed: 119 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,6 @@ where
88

99
impl_integer_vector! { SimdIsize, isize }
1010

11-
/// Vector of two `isize` values
12-
pub type isizex2 = SimdIsize<2>;
13-
14-
/// Vector of four `isize` values
15-
pub type isizex4 = SimdIsize<4>;
16-
17-
/// Vector of eight `isize` values
18-
pub type isizex8 = SimdIsize<8>;
19-
2011
#[cfg(target_pointer_width = "32")]
2112
from_transmute_x86! { unsafe isizex4 => __m128i }
2213
#[cfg(target_pointer_width = "32")]
@@ -28,3 +19,122 @@ from_transmute_x86! { unsafe isizex2 => __m128i }
2819
from_transmute_x86! { unsafe isizex4 => __m256i }
2920
//#[cfg(target_pointer_width = "64")]
3021
//from_transmute_x86! { unsafe isizex8 => __m512i }
22+
23+
/// A SIMD vector of containing `LANES` `i128` values.
24+
#[repr(simd)]
25+
pub struct SimdI128<const LANES: usize>([i128; LANES])
26+
where
27+
Self: crate::LanesAtMost64;
28+
29+
impl_integer_vector! { SimdI128, i128 }
30+
31+
from_transmute_x86! { unsafe i128x2 => __m256i }
32+
//from_transmute_x86! { unsafe i128x4 => __m512i }
33+
34+
/// A SIMD vector of containing `LANES` `i16` values.
35+
#[repr(simd)]
36+
pub struct SimdI16<const LANES: usize>([i16; LANES])
37+
where
38+
Self: crate::LanesAtMost64;
39+
40+
impl_integer_vector! { SimdI16, i16 }
41+
42+
from_transmute_x86! { unsafe i16x8 => __m128i }
43+
from_transmute_x86! { unsafe i16x16 => __m256i }
44+
//from_transmute_x86! { unsafe i16x32 => __m512i }
45+
46+
/// A SIMD vector of containing `LANES` `i32` values.
47+
#[repr(simd)]
48+
pub struct SimdI32<const LANES: usize>([i32; LANES])
49+
where
50+
Self: crate::LanesAtMost64;
51+
52+
impl_integer_vector! { SimdI32, i32 }
53+
54+
from_transmute_x86! { unsafe i32x4 => __m128i }
55+
from_transmute_x86! { unsafe i32x8 => __m256i }
56+
//from_transmute_x86! { unsafe i32x16 => __m512i }
57+
58+
/// A SIMD vector of containing `LANES` `i64` values.
59+
#[repr(simd)]
60+
pub struct SimdI64<const LANES: usize>([i64; LANES])
61+
where
62+
Self: crate::LanesAtMost64;
63+
64+
impl_integer_vector! { SimdI64, i64 }
65+
66+
from_transmute_x86! { unsafe i64x2 => __m128i }
67+
from_transmute_x86! { unsafe i64x4 => __m256i }
68+
//from_transmute_x86! { unsafe i64x8 => __m512i }
69+
70+
/// A SIMD vector of containing `LANES` `i8` values.
71+
#[repr(simd)]
72+
pub struct SimdI8<const LANES: usize>([i8; LANES])
73+
where
74+
Self: crate::LanesAtMost64;
75+
76+
impl_integer_vector! { SimdI8, i8 }
77+
78+
from_transmute_x86! { unsafe i8x16 => __m128i }
79+
from_transmute_x86! { unsafe i8x32 => __m256i }
80+
//from_transmute_x86! { unsafe i8x64 => __m512i }
81+
82+
/// Vector of two `isize` values
83+
pub type isizex2 = SimdIsize<2>;
84+
85+
/// Vector of four `isize` values
86+
pub type isizex4 = SimdIsize<4>;
87+
88+
/// Vector of eight `isize` values
89+
pub type isizex8 = SimdIsize<8>;
90+
91+
/// Vector of two `i128` values
92+
pub type i128x2 = SimdI128<2>;
93+
94+
/// Vector of four `i128` values
95+
pub type i128x4 = SimdI128<4>;
96+
97+
/// Vector of four `i16` values
98+
pub type i16x4 = SimdI16<4>;
99+
100+
/// Vector of eight `i16` values
101+
pub type i16x8 = SimdI16<8>;
102+
103+
/// Vector of 16 `i16` values
104+
pub type i16x16 = SimdI16<16>;
105+
106+
/// Vector of 32 `i16` values
107+
pub type i16x32 = SimdI16<32>;
108+
109+
/// Vector of two `i32` values
110+
pub type i32x2 = SimdI32<2>;
111+
112+
/// Vector of four `i32` values
113+
pub type i32x4 = SimdI32<4>;
114+
115+
/// Vector of eight `i32` values
116+
pub type i32x8 = SimdI32<8>;
117+
118+
/// Vector of 16 `i32` values
119+
pub type i32x16 = SimdI32<16>;
120+
121+
/// Vector of two `i64` values
122+
pub type i64x2 = SimdI64<2>;
123+
124+
/// Vector of four `i64` values
125+
pub type i64x4 = SimdI64<4>;
126+
127+
/// Vector of eight `i64` values
128+
pub type i64x8 = SimdI64<8>;
129+
130+
/// Vector of eight `i8` values
131+
pub type i8x8 = SimdI8<8>;
132+
133+
/// Vector of 16 `i8` values
134+
pub type i8x16 = SimdI8<16>;
135+
136+
/// Vector of 32 `i8` values
137+
pub type i8x32 = SimdI8<32>;
138+
139+
/// Vector of 64 `i8` values
140+
pub type i8x64 = SimdI8<64>;

crates/core_simd/src/vector/uint.rs

Lines changed: 119 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,6 @@ where
88

99
impl_integer_vector! { SimdUsize, usize }
1010

11-
/// Vector of two `usize` values
12-
pub type usizex2 = SimdUsize<2>;
13-
14-
/// Vector of four `usize` values
15-
pub type usizex4 = SimdUsize<4>;
16-
17-
/// Vector of eight `usize` values
18-
pub type usizex8 = SimdUsize<8>;
19-
2011
#[cfg(target_pointer_width = "32")]
2112
from_transmute_x86! { unsafe usizex4 => __m128i }
2213
#[cfg(target_pointer_width = "32")]
@@ -28,3 +19,122 @@ from_transmute_x86! { unsafe usizex2 => __m128i }
2819
from_transmute_x86! { unsafe usizex4 => __m256i }
2920
//#[cfg(target_pointer_width = "64")]
3021
//from_transmute_x86! { unsafe usizex8 => __m512i }
22+
23+
/// A SIMD vector of containing `LANES` `u128` values.
24+
#[repr(simd)]
25+
pub struct SimdU128<const LANES: usize>([u128; LANES])
26+
where
27+
Self: crate::LanesAtMost64;
28+
29+
impl_integer_vector! { SimdU128, u128 }
30+
31+
from_transmute_x86! { unsafe u128x2 => __m256i }
32+
//from_transmute_x86! { unsafe u128x4 => __m512i }
33+
34+
/// A SIMD vector of containing `LANES` `u16` values.
35+
#[repr(simd)]
36+
pub struct SimdU16<const LANES: usize>([u16; LANES])
37+
where
38+
Self: crate::LanesAtMost64;
39+
40+
impl_integer_vector! { SimdU16, u16 }
41+
42+
from_transmute_x86! { unsafe u16x8 => __m128i }
43+
from_transmute_x86! { unsafe u16x16 => __m256i }
44+
//from_transmute_x86! { unsafe u16x32 => __m512i }
45+
46+
/// A SIMD vector of containing `LANES` `u32` values.
47+
#[repr(simd)]
48+
pub struct SimdU32<const LANES: usize>([u32; LANES])
49+
where
50+
Self: crate::LanesAtMost64;
51+
52+
impl_integer_vector! { SimdU32, u32 }
53+
54+
from_transmute_x86! { unsafe u32x4 => __m128i }
55+
from_transmute_x86! { unsafe u32x8 => __m256i }
56+
//from_transmute_x86! { unsafe u32x16 => __m512i }
57+
58+
/// A SIMD vector of containing `LANES` `u64` values.
59+
#[repr(simd)]
60+
pub struct SimdU64<const LANES: usize>([u64; LANES])
61+
where
62+
Self: crate::LanesAtMost64;
63+
64+
impl_integer_vector! { SimdU64, u64 }
65+
66+
from_transmute_x86! { unsafe u64x2 => __m128i }
67+
from_transmute_x86! { unsafe u64x4 => __m256i }
68+
//from_transmute_x86! { unsafe u64x8 => __m512i }
69+
70+
/// A SIMD vector of containing `LANES` `u8` values.
71+
#[repr(simd)]
72+
pub struct SimdU8<const LANES: usize>([u8; LANES])
73+
where
74+
Self: crate::LanesAtMost64;
75+
76+
impl_integer_vector! { SimdU8, u8 }
77+
78+
from_transmute_x86! { unsafe u8x16 => __m128i }
79+
from_transmute_x86! { unsafe u8x32 => __m256i }
80+
//from_transmute_x86! { unsafe u8x64 => __m512i }
81+
82+
/// Vector of two `usize` values
83+
pub type usizex2 = SimdUsize<2>;
84+
85+
/// Vector of four `usize` values
86+
pub type usizex4 = SimdUsize<4>;
87+
88+
/// Vector of eight `usize` values
89+
pub type usizex8 = SimdUsize<8>;
90+
91+
/// Vector of two `u128` values
92+
pub type u128x2 = SimdU128<2>;
93+
94+
/// Vector of four `u128` values
95+
pub type u128x4 = SimdU128<4>;
96+
97+
/// Vector of four `u16` values
98+
pub type u16x4 = SimdU16<4>;
99+
100+
/// Vector of eight `u16` values
101+
pub type u16x8 = SimdU16<8>;
102+
103+
/// Vector of 16 `u16` values
104+
pub type u16x16 = SimdU16<16>;
105+
106+
/// Vector of 32 `u16` values
107+
pub type u16x32 = SimdU16<32>;
108+
109+
/// Vector of two `u32` values
110+
pub type u32x2 = SimdU32<2>;
111+
112+
/// Vector of four `u32` values
113+
pub type u32x4 = SimdU32<4>;
114+
115+
/// Vector of eight `u32` values
116+
pub type u32x8 = SimdU32<8>;
117+
118+
/// Vector of 16 `u32` values
119+
pub type u32x16 = SimdU32<16>;
120+
121+
/// Vector of two `u64` values
122+
pub type u64x2 = SimdU64<2>;
123+
124+
/// Vector of four `u64` values
125+
pub type u64x4 = SimdU64<4>;
126+
127+
/// Vector of eight `u64` values
128+
pub type u64x8 = SimdU64<8>;
129+
130+
/// Vector of eight `u8` values
131+
pub type u8x8 = SimdU8<8>;
132+
133+
/// Vector of 16 `u8` values
134+
pub type u8x16 = SimdU8<16>;
135+
136+
/// Vector of 32 `u8` values
137+
pub type u8x32 = SimdU8<32>;
138+
139+
/// Vector of 64 `u8` values
140+
pub type u8x64 = SimdU8<64>;

crates/core_simd/src/vector/vectors_f64.rs

Lines changed: 0 additions & 22 deletions
This file was deleted.

crates/core_simd/src/vector/vectors_i128.rs

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)