11use itertools:: Itertools ;
22
33use crate :: common:: intrinsic_helpers:: TypeKind ;
4+ use crate :: common:: values:: test_values_array_name;
45
6+ use super :: PASSES ;
57use super :: constraint:: Constraint ;
6- use super :: gen_rust:: PASSES ;
78use super :: intrinsic_helpers:: IntrinsicTypeDefinition ;
89
910/// An argument for the intrinsic.
5253 self . constraint . is_some ( )
5354 }
5455
55- /// Returns a string with the name of the static variable containing test values for intrinsic
56- /// arguments of this type.
57- pub ( crate ) fn rust_vals_array_name ( & self ) -> impl std:: fmt:: Display {
58- let loads = crate :: common:: gen_rust:: PASSES ;
59- format ! (
60- "{ty}_{load_size}" ,
61- ty = self . ty. rust_scalar_type( ) . to_uppercase( ) ,
62- load_size = self . ty. num_lanes( ) * self . ty. num_vectors( ) + loads - 1 ,
63- )
64- }
65-
6656 /// Should this argument be passed by reference in C wrapper function declarations?
6757 ///
6858 /// SIMD types and `f16` are currently passed by reference.
@@ -165,41 +155,6 @@ where
165155 . join ( "" )
166156 }
167157
168- /// Returns a string defining a static variable with test values used for all intrinsics with
169- /// arguments of `arg`'s type.
170- ///
171- /// e.g.
172- /// ```rust,ignore
173- /// static U8_20: [u8; 20] = [
174- /// 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0xf0,
175- /// 0x80, 0x3b, 0xff,
176- /// ];
177- /// ```
178- ///
179- /// `num_lanes * num_vectors + loads - 1` elements are present in the array, which is sufficient
180- /// for a `loads` number of `num_lanes * num_vectors` windows into the array to be loaded:
181- ///
182- /// ```text
183- /// [0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0xf0, 0x80, 0x3b, 0xff]
184- /// ^^^^^^^^^^^^^^^^^^^ first window of `num_lanes * num_vectors` elements (e.g. four elements)
185- /// ^^^^^^^^^^^^^^^^^^ second window
186- /// `loads`th window ^^^^^^^^^^^^^^^^^^^^^^
187- /// ```
188- pub fn gen_arg_rust (
189- arg : & Argument < T > ,
190- w : & mut impl std:: io:: Write ,
191- loads : u32 ,
192- ) -> std:: io:: Result < ( ) > {
193- writeln ! (
194- w,
195- "static {name}: [{ty}; {load_size}] = {values};\n " ,
196- name = arg. rust_vals_array_name( ) ,
197- ty = arg. ty. rust_scalar_type( ) ,
198- load_size = arg. ty. num_lanes( ) * arg. ty. num_vectors( ) + loads - 1 ,
199- values = arg. ty. populate_random( loads)
200- )
201- }
202-
203158 /// Returns a string defining a local variable for each argument and loading a value into each
204159 /// using a load intrinsic.
205160 ///
@@ -226,14 +181,14 @@ where
226181 format ! (
227182 "let {name} = {load}({vals_name}.as_ptr().add((i+{idx}) % {PASSES}) as _);\n " ,
228183 name = arg. generate_name( ) ,
229- vals_name = arg. rust_vals_array_name ( ) ,
184+ vals_name = test_values_array_name ( & arg. ty ) ,
230185 load = arg. ty. get_load_function( ) ,
231186 )
232187 } else {
233188 format ! (
234189 "let {name} = {vals_name}[(i+{idx}) % {PASSES}];\n " ,
235190 name = arg. generate_name( ) ,
236- vals_name = arg. rust_vals_array_name ( ) ,
191+ vals_name = test_values_array_name ( & arg. ty ) ,
237192 )
238193 }
239194 } )
0 commit comments