33
33
}
34
34
35
35
pub fn has_constraint ( & self ) -> bool {
36
- ! self . constraint . is_some ( )
36
+ self . constraint . is_none ( )
37
37
}
38
38
39
39
pub fn type_and_name_from_c ( arg : & str ) -> ( & str , & str ) {
65
65
pub fn from_c (
66
66
pos : usize ,
67
67
arg : & str ,
68
- target : & String ,
68
+ target : & str ,
69
69
constraint : Option < Constraint > ,
70
70
) -> Argument < T > {
71
71
let ( ty, var_name) = Self :: type_and_name_from_c ( arg) ;
@@ -127,15 +127,14 @@ where
127
127
/// e.g `const int32x2_t a_vals = {0x3effffff, 0x3effffff, 0x3f7fffff}`, if loads=2.
128
128
pub fn gen_arglists_c ( & self , indentation : Indentation , loads : u32 ) -> String {
129
129
self . iter ( )
130
- . filter_map ( |arg| {
131
- ( !arg. has_constraint ( ) ) . then ( || {
132
- format ! (
133
- "{indentation}const {ty} {name}_vals[] = {values};" ,
134
- ty = arg. ty. c_scalar_type( ) ,
135
- name = arg. name,
136
- values = arg. ty. populate_random( indentation, loads, & Language :: C )
137
- )
138
- } )
130
+ . filter ( |& arg| !arg. has_constraint ( ) )
131
+ . map ( |arg| {
132
+ format ! (
133
+ "{indentation}const {ty} {name}_vals[] = {values};" ,
134
+ ty = arg. ty. c_scalar_type( ) ,
135
+ name = arg. name,
136
+ values = arg. ty. populate_random( indentation, loads, & Language :: C )
137
+ )
139
138
} )
140
139
. collect :: < Vec < _ > > ( )
141
140
. join ( "\n " )
@@ -145,17 +144,16 @@ where
145
144
/// values can be loaded as a sliding window, e.g `const A_VALS: [u32; 20] = [...];`
146
145
pub fn gen_arglists_rust ( & self , indentation : Indentation , loads : u32 ) -> String {
147
146
self . iter ( )
148
- . filter_map ( |arg| {
149
- ( !arg. has_constraint ( ) ) . then ( || {
150
- format ! (
151
- "{indentation}{bind} {name}: [{ty}; {load_size}] = {values};" ,
152
- bind = arg. rust_vals_array_binding( ) ,
153
- name = arg. rust_vals_array_name( ) ,
154
- ty = arg. ty. rust_scalar_type( ) ,
155
- load_size = arg. ty. num_lanes( ) * arg. ty. num_vectors( ) + loads - 1 ,
156
- values = arg. ty. populate_random( indentation, loads, & Language :: Rust )
157
- )
158
- } )
147
+ . filter ( |& arg| !arg. has_constraint ( ) )
148
+ . map ( |arg| {
149
+ format ! (
150
+ "{indentation}{bind} {name}: [{ty}; {load_size}] = {values};" ,
151
+ bind = arg. rust_vals_array_binding( ) ,
152
+ name = arg. rust_vals_array_name( ) ,
153
+ ty = arg. ty. rust_scalar_type( ) ,
154
+ load_size = arg. ty. num_lanes( ) * arg. ty. num_vectors( ) + loads - 1 ,
155
+ values = arg. ty. populate_random( indentation, loads, & Language :: Rust )
156
+ )
159
157
} )
160
158
. collect :: < Vec < _ > > ( )
161
159
. join ( "\n " )
@@ -168,22 +166,18 @@ where
168
166
/// ARM-specific
169
167
pub fn load_values_c ( & self , indentation : Indentation ) -> String {
170
168
self . iter ( )
171
- . filter_map ( |arg| {
172
- // The ACLE doesn't support 64-bit polynomial loads on Armv7
173
- // This and the cast are a workaround for this
174
-
175
- ( !arg. has_constraint ( ) ) . then ( || {
176
- format ! (
177
- "{indentation}{ty} {name} = cast<{ty}>({load}(&{name}_vals[i]));\n " ,
178
- ty = arg. to_c_type( ) ,
179
- name = arg. name,
180
- load = if arg. is_simd( ) {
181
- arg. ty. get_load_function( Language :: C )
182
- } else {
183
- "*" . to_string( )
184
- }
185
- )
186
- } )
169
+ . filter ( |& arg| !arg. has_constraint ( ) )
170
+ . map ( |arg| {
171
+ format ! (
172
+ "{indentation}{ty} {name} = cast<{ty}>({load}(&{name}_vals[i]));\n " ,
173
+ ty = arg. to_c_type( ) ,
174
+ name = arg. name,
175
+ load = if arg. is_simd( ) {
176
+ arg. ty. get_load_function( Language :: C )
177
+ } else {
178
+ "*" . to_string( )
179
+ }
180
+ )
187
181
} )
188
182
. collect ( )
189
183
}
@@ -193,19 +187,18 @@ where
193
187
/// e.g `let a = vld1_u8(A_VALS.as_ptr().offset(i));`
194
188
pub fn load_values_rust ( & self , indentation : Indentation ) -> String {
195
189
self . iter ( )
196
- . filter_map ( |arg| {
197
- ( !arg. has_constraint ( ) ) . then ( || {
198
- format ! (
199
- "{indentation}let {name} = {load}({vals_name}.as_ptr().offset(i));\n " ,
200
- name = arg. name,
201
- vals_name = arg. rust_vals_array_name( ) ,
202
- load = if arg. is_simd( ) {
203
- arg. ty. get_load_function( Language :: Rust )
204
- } else {
205
- "*" . to_string( )
206
- } ,
207
- )
208
- } )
190
+ . filter ( |& arg| !arg. has_constraint ( ) )
191
+ . map ( |arg| {
192
+ format ! (
193
+ "{indentation}let {name} = {load}({vals_name}.as_ptr().offset(i));\n " ,
194
+ name = arg. name,
195
+ vals_name = arg. rust_vals_array_name( ) ,
196
+ load = if arg. is_simd( ) {
197
+ arg. ty. get_load_function( Language :: Rust )
198
+ } else {
199
+ "*" . to_string( )
200
+ } ,
201
+ )
209
202
} )
210
203
. collect ( )
211
204
}
0 commit comments