3333 }
3434
3535 pub fn has_constraint ( & self ) -> bool {
36- !self . constraint . is_some ( )
36+ // TODO: investigation (is_none is okay?)
37+ self . constraint . is_none ( )
3738 }
3839
3940 pub fn type_and_name_from_c ( arg : & str ) -> ( & str , & str ) {
@@ -127,15 +128,14 @@ where
127128 /// e.g `const int32x2_t a_vals = {0x3effffff, 0x3effffff, 0x3f7fffff}`, if loads=2.
128129 pub fn gen_arglists_c ( & self , indentation : Indentation , loads : u32 ) -> String {
129130 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- } )
131+ . filter ( |& arg| ( !arg. has_constraint ( ) ) )
132+ . map ( |arg| {
133+ format ! (
134+ "{indentation}const {ty} {name}_vals[] = {values};" ,
135+ ty = arg. ty. c_scalar_type( ) ,
136+ name = arg. name,
137+ values = arg. ty. populate_random( indentation, loads, & Language :: C )
138+ )
139139 } )
140140 . collect :: < Vec < _ > > ( )
141141 . join ( "\n " )
@@ -145,17 +145,16 @@ where
145145 /// values can be loaded as a sliding window, e.g `const A_VALS: [u32; 20] = [...];`
146146 pub fn gen_arglists_rust ( & self , indentation : Indentation , loads : u32 ) -> String {
147147 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- } )
148+ . filter ( |& arg| ( !arg. has_constraint ( ) ) )
149+ . map ( |arg| {
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+ )
159158 } )
160159 . collect :: < Vec < _ > > ( )
161160 . join ( "\n " )
@@ -168,22 +167,18 @@ where
168167 /// ARM-specific
169168 pub fn load_values_c ( & self , indentation : Indentation ) -> String {
170169 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- } )
170+ . filter ( |& arg| ( !arg. has_constraint ( ) ) )
171+ . map ( |arg| {
172+ format ! (
173+ "{indentation}{ty} {name} = cast<{ty}>({load}(&{name}_vals[i]));\n " ,
174+ ty = arg. to_c_type( ) ,
175+ name = arg. name,
176+ load = if arg. is_simd( ) {
177+ arg. ty. get_load_function( Language :: C )
178+ } else {
179+ "*" . to_string( )
180+ }
181+ )
187182 } )
188183 . collect ( )
189184 }
@@ -193,19 +188,18 @@ where
193188 /// e.g `let a = vld1_u8(A_VALS.as_ptr().offset(i));`
194189 pub fn load_values_rust ( & self , indentation : Indentation ) -> String {
195190 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- } )
191+ . filter ( |& arg| ( !arg. has_constraint ( ) ) )
192+ . map ( |arg| {
193+ format ! (
194+ "{indentation}let {name} = {load}({vals_name}.as_ptr().offset(i));\n " ,
195+ name = arg. name,
196+ vals_name = arg. rust_vals_array_name( ) ,
197+ load = if arg. is_simd( ) {
198+ arg. ty. get_load_function( Language :: Rust )
199+ } else {
200+ "*" . to_string( )
201+ } ,
202+ )
209203 } )
210204 . collect ( )
211205 }
0 commit comments