|  | 
| 60 | 60 |     } | 
| 61 | 61 | 
 | 
| 62 | 62 |     /// The name (e.g. "A_VALS" or "a_vals") for the array of possible test inputs. | 
| 63 |  | -    fn rust_vals_array_name(&self) -> impl std::fmt::Display { | 
|  | 63 | +    pub(crate) fn rust_vals_array_name(&self) -> impl std::fmt::Display { | 
| 64 | 64 |         if self.ty.is_rust_vals_array_const() { | 
| 65 |  | -            format!("{}_VALS", self.name.to_uppercase()) | 
|  | 65 | +            let loads = crate::common::gen_rust::PASSES; | 
|  | 66 | +            format!( | 
|  | 67 | +                "{}_{ty}_{load_size}", | 
|  | 68 | +                self.name.to_uppercase(), | 
|  | 69 | +                ty = self.ty.rust_scalar_type(), | 
|  | 70 | +                load_size = self.ty.num_lanes() * self.ty.num_vectors() + loads - 1, | 
|  | 71 | +            ) | 
| 66 | 72 |         } else { | 
| 67 | 73 |             format!("{}_vals", self.name.to_lowercase()) | 
| 68 | 74 |         } | 
| @@ -134,20 +140,34 @@ where | 
| 134 | 140 |         loads: u32, | 
| 135 | 141 |     ) -> std::io::Result<()> { | 
| 136 | 142 |         for arg in self.iter().filter(|&arg| !arg.has_constraint()) { | 
| 137 |  | -            writeln!( | 
| 138 |  | -                w, | 
| 139 |  | -                "{indentation}{bind} {name}: [{ty}; {load_size}] = {values};", | 
| 140 |  | -                bind = arg.rust_vals_array_binding(), | 
| 141 |  | -                name = arg.rust_vals_array_name(), | 
| 142 |  | -                ty = arg.ty.rust_scalar_type(), | 
| 143 |  | -                load_size = arg.ty.num_lanes() * arg.ty.num_vectors() + loads - 1, | 
| 144 |  | -                values = arg.ty.populate_random(indentation, loads, &Language::Rust) | 
| 145 |  | -            )? | 
|  | 143 | +            // Constants are defined globally. | 
|  | 144 | +            if arg.ty.is_rust_vals_array_const() { | 
|  | 145 | +                continue; | 
|  | 146 | +            } | 
|  | 147 | + | 
|  | 148 | +            Self::gen_arg_rust(arg, w, indentation, loads)?; | 
| 146 | 149 |         } | 
| 147 | 150 | 
 | 
| 148 | 151 |         Ok(()) | 
| 149 | 152 |     } | 
| 150 | 153 | 
 | 
|  | 154 | +    pub fn gen_arg_rust( | 
|  | 155 | +        arg: &Argument<T>, | 
|  | 156 | +        w: &mut impl std::io::Write, | 
|  | 157 | +        indentation: Indentation, | 
|  | 158 | +        loads: u32, | 
|  | 159 | +    ) -> std::io::Result<()> { | 
|  | 160 | +        writeln!( | 
|  | 161 | +            w, | 
|  | 162 | +            "{indentation}{bind} {name}: [{ty}; {load_size}] = {values};\n", | 
|  | 163 | +            bind = arg.rust_vals_array_binding(), | 
|  | 164 | +            name = arg.rust_vals_array_name(), | 
|  | 165 | +            ty = arg.ty.rust_scalar_type(), | 
|  | 166 | +            load_size = arg.ty.num_lanes() * arg.ty.num_vectors() + loads - 1, | 
|  | 167 | +            values = arg.ty.populate_random(indentation, loads, &Language::Rust) | 
|  | 168 | +        ) | 
|  | 169 | +    } | 
|  | 170 | + | 
| 151 | 171 |     /// Creates a line for each argument that initializes the argument from an array `[arg]_vals` at | 
| 152 | 172 |     /// an offset `i` using a load intrinsic, in C. | 
| 153 | 173 |     /// e.g `uint8x8_t a = vld1_u8(&a_vals[i]);` | 
|  | 
0 commit comments