File tree 3 files changed +33
-100
lines changed
3 files changed +33
-100
lines changed Original file line number Diff line number Diff line change 4
4
#![ warn( missing_docs) ]
5
5
//! Portable SIMD module.
6
6
7
- #[ macro_use]
8
- mod first;
9
7
#[ macro_use]
10
8
mod permute;
11
9
#[ macro_use]
Original file line number Diff line number Diff line change
1
+ #[ macro_use]
2
+ mod vector_impl;
3
+
1
4
mod float;
2
5
mod int;
3
6
mod uint;
@@ -31,101 +34,3 @@ pub trait Vector: sealed::Sealed {
31
34
#[ must_use]
32
35
fn splat ( val : Self :: Scalar ) -> Self ;
33
36
}
34
-
35
- macro_rules! impl_vector_for {
36
- ( $simd: ident { type Scalar = $scalar: ident; } ) => {
37
- impl_vector_for! { $simd<1 > { type Scalar = $scalar; type BitMask = u8 ; } }
38
- impl_vector_for! { $simd<2 > { type Scalar = $scalar; type BitMask = u8 ; } }
39
- impl_vector_for! { $simd<4 > { type Scalar = $scalar; type BitMask = u8 ; } }
40
- impl_vector_for! { $simd<8 > { type Scalar = $scalar; type BitMask = u8 ; } }
41
- impl_vector_for! { $simd<16 > { type Scalar = $scalar; type BitMask = u16 ; } }
42
- impl_vector_for! { $simd<32 > { type Scalar = $scalar; type BitMask = u32 ; } }
43
- } ;
44
- ( $simd: ident<$lanes: literal> { type Scalar = $scalar: ident; type BitMask = $bitmask: ident; } ) => {
45
- impl sealed:: Sealed for $simd<$lanes> { }
46
-
47
- impl Vector for $simd<$lanes> {
48
- type Scalar = $scalar;
49
- const LANES : usize = $lanes;
50
-
51
- type BitMask = $bitmask;
52
-
53
- #[ inline]
54
- fn splat( val: Self :: Scalar ) -> Self {
55
- Self :: splat( val)
56
- }
57
- }
58
- } ;
59
- }
60
-
61
- impl_vector_for ! {
62
- SimdUsize {
63
- type Scalar = usize ;
64
- }
65
- }
66
-
67
- impl_vector_for ! {
68
- SimdIsize {
69
- type Scalar = isize ;
70
- }
71
- }
72
-
73
- impl_vector_for ! {
74
- SimdI8 {
75
- type Scalar = i8 ;
76
- }
77
- }
78
-
79
- impl_vector_for ! {
80
- SimdI16 {
81
- type Scalar = i16 ;
82
- }
83
- }
84
-
85
- impl_vector_for ! {
86
- SimdI32 {
87
- type Scalar = i32 ;
88
- }
89
- }
90
-
91
- impl_vector_for ! {
92
- SimdI64 {
93
- type Scalar = i64 ;
94
- }
95
- }
96
-
97
- impl_vector_for ! {
98
- SimdU8 {
99
- type Scalar = u8 ;
100
- }
101
- }
102
-
103
- impl_vector_for ! {
104
- SimdU16 {
105
- type Scalar = u16 ;
106
- }
107
- }
108
-
109
- impl_vector_for ! {
110
- SimdU32 {
111
- type Scalar = u32 ;
112
- }
113
- }
114
-
115
- impl_vector_for ! {
116
- SimdU64 {
117
- type Scalar = u64 ;
118
- }
119
- }
120
-
121
- impl_vector_for ! {
122
- SimdF32 {
123
- type Scalar = f32 ;
124
- }
125
- }
126
-
127
- impl_vector_for ! {
128
- SimdF64 {
129
- type Scalar = f64 ;
130
- }
131
- }
Original file line number Diff line number Diff line change
1
+ macro_rules! impl_vector_trait {
2
+ ( $simd: ident { type Scalar = $scalar: ty; } ) => {
3
+ impl_vector_trait! { $simd<1 > { type Scalar = $scalar; type BitMask = u8 ; } }
4
+ impl_vector_trait! { $simd<2 > { type Scalar = $scalar; type BitMask = u8 ; } }
5
+ impl_vector_trait! { $simd<4 > { type Scalar = $scalar; type BitMask = u8 ; } }
6
+ impl_vector_trait! { $simd<8 > { type Scalar = $scalar; type BitMask = u8 ; } }
7
+ impl_vector_trait! { $simd<16 > { type Scalar = $scalar; type BitMask = u16 ; } }
8
+ impl_vector_trait! { $simd<32 > { type Scalar = $scalar; type BitMask = u32 ; } }
9
+ } ;
10
+ ( $simd: ident<$lanes: literal> { type Scalar = $scalar: ty; type BitMask = $bitmask: ident; } ) => {
11
+ impl crate :: vector:: sealed:: Sealed for $simd<$lanes> { }
12
+
13
+ impl crate :: vector:: Vector for $simd<$lanes> {
14
+ type Scalar = $scalar;
15
+ const LANES : usize = $lanes;
16
+
17
+ type BitMask = $bitmask;
18
+
19
+ #[ inline]
20
+ fn splat( val: Self :: Scalar ) -> Self {
21
+ Self :: splat( val)
22
+ }
23
+ }
24
+ } ;
25
+ }
26
+
1
27
/// Implements common traits on the specified vector `$name`, holding multiple `$lanes` of `$type`.
2
28
macro_rules! impl_vector {
3
29
{ $name: ident, $type: ty } => {
30
+ impl_vector_trait! {
31
+ $name { type Scalar = $type; }
32
+ }
33
+
4
34
impl <const LANES : usize > $name<LANES > where Self : crate :: Vector {
5
35
/// Construct a SIMD vector by setting all lanes to the given value.
6
36
pub const fn splat( value: $type) -> Self {
You can’t perform that action at this time.
0 commit comments