Skip to content

Commit 12e6b26

Browse files
committed
Make floats static, as rounding is not a real concern here anymore
1 parent 8bd7567 commit 12e6b26

3 files changed

Lines changed: 9 additions & 62 deletions

File tree

crates/intrinsic-test/src/common/argument.rs

Lines changed: 8 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -51,28 +51,15 @@ where
5151
self.constraint.is_some()
5252
}
5353

54-
/// The binding keyword (e.g. "const" or "let") for the array of possible test inputs.
55-
fn rust_vals_array_binding(&self) -> impl std::fmt::Display {
56-
if self.ty.is_rust_vals_array_const() {
57-
"const"
58-
} else {
59-
"let"
60-
}
61-
}
62-
6354
/// The name (e.g. "A_VALS" or "a_vals") for the array of possible test inputs.
6455
pub(crate) fn rust_vals_array_name(&self) -> impl std::fmt::Display {
65-
if self.ty.is_rust_vals_array_const() {
66-
let loads = crate::common::gen_rust::PASSES;
67-
format!(
68-
"{}_{ty}_{load_size}",
69-
self.name.to_uppercase(),
70-
ty = self.ty.rust_scalar_type(),
71-
load_size = self.ty.num_lanes() * self.ty.num_vectors() + loads - 1,
72-
)
73-
} else {
74-
format!("{}_vals", self.name.to_lowercase())
75-
}
56+
let loads = crate::common::gen_rust::PASSES;
57+
format!(
58+
"{}_{ty}_{load_size}",
59+
self.name.to_uppercase(),
60+
ty = self.ty.rust_scalar_type(),
61+
load_size = self.ty.num_lanes() * self.ty.num_vectors() + loads - 1,
62+
)
7663
}
7764
}
7865

@@ -137,26 +124,6 @@ where
137124
.join("")
138125
}
139126

140-
/// Creates a line for each argument that initializes an array for Rust from which `loads` argument
141-
/// values can be loaded as a sliding window, e.g `const A_VALS: [u32; 20] = [...];`
142-
pub fn gen_arglists_rust(
143-
&self,
144-
w: &mut impl std::io::Write,
145-
indentation: Indentation,
146-
loads: u32,
147-
) -> std::io::Result<()> {
148-
for arg in self.iter().filter(|&arg| !arg.has_constraint()) {
149-
// Constants are defined globally.
150-
if arg.ty.is_rust_vals_array_const() {
151-
continue;
152-
}
153-
154-
Self::gen_arg_rust(arg, w, indentation, loads)?;
155-
}
156-
157-
Ok(())
158-
}
159-
160127
pub fn gen_arg_rust(
161128
arg: &Argument<T>,
162129
w: &mut impl std::io::Write,
@@ -165,8 +132,7 @@ where
165132
) -> std::io::Result<()> {
166133
writeln!(
167134
w,
168-
"{indentation}{bind} {name}: [{ty}; {load_size}] = {values};\n",
169-
bind = arg.rust_vals_array_binding(),
135+
"{indentation}static {name}: [{ty}; {load_size}] = {values};\n",
170136
name = arg.rust_vals_array_name(),
171137
ty = arg.ty.rust_scalar_type(),
172138
load_size = arg.ty.num_lanes() * arg.ty.num_vectors() + loads - 1,

crates/intrinsic-test/src/common/gen_rust.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ pub fn write_lib_rs<T: IntrinsicTypeDefinition>(
101101

102102
for intrinsic in intrinsics {
103103
for arg in &intrinsic.arguments.args {
104-
if !arg.has_constraint() && arg.ty.is_rust_vals_array_const() {
104+
if !arg.has_constraint() {
105105
let name = arg.rust_vals_array_name().to_string();
106106

107107
if seen.insert(name) {
@@ -227,10 +227,6 @@ fn create_rust_test<T: IntrinsicTypeDefinition>(
227227
intrinsic_name = intrinsic.name,
228228
)?;
229229

230-
// Define the arrays of arguments.
231-
let arguments = &intrinsic.arguments;
232-
arguments.gen_arglists_rust(w, Indentation::default().nested(), PASSES)?;
233-
234230
generate_rust_test_loop(w, intrinsic, PASSES)?;
235231

236232
writeln!(w, "}}")?;

crates/intrinsic-test/src/common/intrinsic_helpers.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -231,21 +231,6 @@ impl IntrinsicType {
231231
_ => unimplemented!("populate random: {self:#?}"),
232232
}
233233
}
234-
235-
pub fn is_rust_vals_array_const(&self) -> bool {
236-
match self {
237-
// Floats have to be loaded at runtime for stable NaN conversion.
238-
IntrinsicType {
239-
kind: TypeKind::Float,
240-
..
241-
} => false,
242-
IntrinsicType {
243-
kind: TypeKind::Int(_) | TypeKind::Poly,
244-
..
245-
} => true,
246-
_ => true,
247-
}
248-
}
249234
}
250235

251236
pub trait IntrinsicTypeDefinition: Deref<Target = IntrinsicType> {

0 commit comments

Comments
 (0)