@@ -29,7 +29,7 @@ macro_rules! from_transmute_x86 {
29
29
/// Implements common traits on the specified vector `$name`, holding multiple `$lanes` of `$type`.
30
30
macro_rules! impl_vector {
31
31
{ $name: ident, $type: ty } => {
32
- impl <const LANES : usize > $name<LANES > {
32
+ impl <const LANES : usize > $name<LANES > where Self : crate :: LanesAtMost64 {
33
33
/// Construct a SIMD vector by setting all lanes to the given value.
34
34
pub const fn splat( value: $type) -> Self {
35
35
Self ( [ value; LANES ] )
@@ -72,31 +72,31 @@ macro_rules! impl_vector {
72
72
}
73
73
}
74
74
75
- impl <const LANES : usize > Copy for $name<LANES > { }
75
+ impl <const LANES : usize > Copy for $name<LANES > where Self : crate :: LanesAtMost64 { }
76
76
77
- impl <const LANES : usize > Clone for $name<LANES > {
77
+ impl <const LANES : usize > Clone for $name<LANES > where Self : crate :: LanesAtMost64 {
78
78
#[ inline]
79
79
fn clone( & self ) -> Self {
80
80
* self
81
81
}
82
82
}
83
83
84
- impl <const LANES : usize > Default for $name<LANES > {
84
+ impl <const LANES : usize > Default for $name<LANES > where Self : crate :: LanesAtMost64 {
85
85
#[ inline]
86
86
fn default ( ) -> Self {
87
87
Self :: splat( <$type>:: default ( ) )
88
88
}
89
89
}
90
90
91
- impl <const LANES : usize > PartialEq for $name<LANES > {
91
+ impl <const LANES : usize > PartialEq for $name<LANES > where Self : crate :: LanesAtMost64 {
92
92
#[ inline]
93
93
fn eq( & self , other: & Self ) -> bool {
94
94
// TODO use SIMD equality
95
95
self . to_array( ) == other. to_array( )
96
96
}
97
97
}
98
98
99
- impl <const LANES : usize > PartialOrd for $name<LANES > {
99
+ impl <const LANES : usize > PartialOrd for $name<LANES > where Self : crate :: LanesAtMost64 {
100
100
#[ inline]
101
101
fn partial_cmp( & self , other: & Self ) -> Option <core:: cmp:: Ordering > {
102
102
// TODO use SIMD equalitya
@@ -105,44 +105,44 @@ macro_rules! impl_vector {
105
105
}
106
106
107
107
// array references
108
- impl <const LANES : usize > AsRef <[ $type; LANES ] > for $name<LANES > {
108
+ impl <const LANES : usize > AsRef <[ $type; LANES ] > for $name<LANES > where Self : crate :: LanesAtMost64 {
109
109
#[ inline]
110
110
fn as_ref( & self ) -> & [ $type; LANES ] {
111
111
& self . 0
112
112
}
113
113
}
114
114
115
- impl <const LANES : usize > AsMut <[ $type; LANES ] > for $name<LANES > {
115
+ impl <const LANES : usize > AsMut <[ $type; LANES ] > for $name<LANES > where Self : crate :: LanesAtMost64 {
116
116
#[ inline]
117
117
fn as_mut( & mut self ) -> & mut [ $type; LANES ] {
118
118
& mut self . 0
119
119
}
120
120
}
121
121
122
122
// slice references
123
- impl <const LANES : usize > AsRef <[ $type] > for $name<LANES > {
123
+ impl <const LANES : usize > AsRef <[ $type] > for $name<LANES > where Self : crate :: LanesAtMost64 {
124
124
#[ inline]
125
125
fn as_ref( & self ) -> & [ $type] {
126
126
& self . 0
127
127
}
128
128
}
129
129
130
- impl <const LANES : usize > AsMut <[ $type] > for $name<LANES > {
130
+ impl <const LANES : usize > AsMut <[ $type] > for $name<LANES > where Self : crate :: LanesAtMost64 {
131
131
#[ inline]
132
132
fn as_mut( & mut self ) -> & mut [ $type] {
133
133
& mut self . 0
134
134
}
135
135
}
136
136
137
137
// vector/array conversion
138
- impl <const LANES : usize > From <[ $type; LANES ] > for $name<LANES > {
138
+ impl <const LANES : usize > From <[ $type; LANES ] > for $name<LANES > where Self : crate :: LanesAtMost64 {
139
139
fn from( array: [ $type; LANES ] ) -> Self {
140
140
Self ( array)
141
141
}
142
142
}
143
143
144
144
// splat
145
- impl <const LANES : usize > From <$type> for $name<LANES > {
145
+ impl <const LANES : usize > From <$type> for $name<LANES > where Self : crate :: LanesAtMost64 {
146
146
#[ inline]
147
147
fn from( value: $type) -> Self {
148
148
Self :: splat( value)
@@ -158,17 +158,17 @@ macro_rules! impl_integer_vector {
158
158
{ $name: ident, $type: ty } => {
159
159
impl_vector! { $name, $type }
160
160
161
- impl <const LANES : usize > Eq for $name<LANES > { }
161
+ impl <const LANES : usize > Eq for $name<LANES > where Self : crate :: LanesAtMost64 { }
162
162
163
- impl <const LANES : usize > Ord for $name<LANES > {
163
+ impl <const LANES : usize > Ord for $name<LANES > where Self : crate :: LanesAtMost64 {
164
164
#[ inline]
165
165
fn cmp( & self , other: & Self ) -> core:: cmp:: Ordering {
166
166
// TODO use SIMD cmp
167
167
self . to_array( ) . cmp( other. as_ref( ) )
168
168
}
169
169
}
170
170
171
- impl <const LANES : usize > core:: hash:: Hash for $name<LANES > {
171
+ impl <const LANES : usize > core:: hash:: Hash for $name<LANES > where Self : crate :: LanesAtMost64 {
172
172
#[ inline]
173
173
fn hash<H >( & self , state: & mut H )
174
174
where
@@ -187,7 +187,11 @@ macro_rules! impl_float_vector {
187
187
{ $name: ident, $type: ty, $bits_ty: ident } => {
188
188
impl_vector! { $name, $type }
189
189
190
- impl <const LANES : usize > $name<LANES > {
190
+ impl <const LANES : usize > $name<LANES >
191
+ where
192
+ Self : crate :: LanesAtMost64 ,
193
+ crate :: $bits_ty<LANES >: crate :: LanesAtMost64 ,
194
+ {
191
195
/// Raw transmutation to an unsigned integer vector type with the
192
196
/// same size and number of lanes.
193
197
#[ inline]
0 commit comments