Skip to content

Commit 6ac9665

Browse files
committed
Consistently take VecType by reference
1 parent faf722a commit 6ac9665

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

fearless_simd_gen/src/arch/x86.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl X86 {
5656
let sign_aware = matches!(op, "max" | "min");
5757

5858
let suffix = match op_name {
59-
"and" | "or" | "xor" => coarse_type(*ty),
59+
"and" | "or" | "xor" => coarse_type(ty),
6060
"blendv" if ty.scalar != ScalarType::Float => "epi8",
6161
_ => op_suffix(ty.scalar, ty.scalar_bits, sign_aware),
6262
};
@@ -78,7 +78,7 @@ impl X86 {
7878
}
7979
}
8080
ScalarType::Int => {
81-
let set0 = intrinsic_ident("setzero", coarse_type(*ty), ty.n_bits());
81+
let set0 = intrinsic_ident("setzero", coarse_type(ty), ty.n_bits());
8282
let sub = simple_intrinsic("sub", ty);
8383
let arg = &args[0];
8484
quote! {
@@ -153,7 +153,7 @@ pub(crate) fn op_suffix(mut ty: ScalarType, bits: usize, sign_aware: bool) -> &'
153153
}
154154

155155
/// Intrinsic name for the "int, float, or double" type (not as fine-grained as [`op_suffix`]).
156-
pub(crate) fn coarse_type(vec_ty: VecType) -> &'static str {
156+
pub(crate) fn coarse_type(vec_ty: &VecType) -> &'static str {
157157
use ScalarType::*;
158158
match (vec_ty.scalar, vec_ty.n_bits()) {
159159
(Int | Unsigned | Mask, 128) => "si128",
@@ -197,7 +197,7 @@ pub(crate) fn extend_intrinsic(
197197
intrinsic_ident(&format!("cvt{from_suffix}"), to_suffix, ty_bits)
198198
}
199199

200-
pub(crate) fn cvt_intrinsic(from: VecType, to: VecType) -> Ident {
200+
pub(crate) fn cvt_intrinsic(from: &VecType, to: &VecType) -> Ident {
201201
let from_suffix = op_suffix(from.scalar, from.scalar_bits, false);
202202
let to_suffix = op_suffix(to.scalar, to.scalar_bits, false);
203203

@@ -250,12 +250,12 @@ pub(crate) fn cast_ident(
250250
512 => "512",
251251
_ => unreachable!(),
252252
};
253-
let src_name = coarse_type(VecType::new(
253+
let src_name = coarse_type(&VecType::new(
254254
src_scalar_ty,
255255
scalar_bits,
256256
ty_bits / scalar_bits,
257257
));
258-
let dst_name = coarse_type(VecType::new(
258+
let dst_name = coarse_type(&VecType::new(
259259
dst_scalar_ty,
260260
scalar_bits,
261261
ty_bits / scalar_bits,

fearless_simd_gen/src/mk_avx2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ pub(crate) fn handle_split(method_sig: TokenStream, vec_ty: &VecType) -> TokenSt
226226
ScalarType::Float => "extractf128",
227227
_ => "extracti128",
228228
};
229-
let extract_intrinsic = intrinsic_ident(extract_op, coarse_type(*vec_ty), 256);
229+
let extract_intrinsic = intrinsic_ident(extract_op, coarse_type(vec_ty), 256);
230230
quote! {
231231
#method_sig {
232232
unsafe {

fearless_simd_gen/src/mk_sse4_2.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ pub(crate) fn handle_compare(
251251
32 => quote! { 0x80000000u32 },
252252
_ => unimplemented!(),
253253
};
254-
let xor_op = intrinsic_ident("xor", coarse_type(*vec_ty), vec_ty.n_bits());
254+
let xor_op = intrinsic_ident("xor", coarse_type(vec_ty), vec_ty.n_bits());
255255
let args = if method == "simd_lt" {
256256
quote! { b_signed, a_signed }
257257
} else {
@@ -401,8 +401,8 @@ pub(crate) fn handle_binary(
401401
// https://stackoverflow.com/questions/8193601/sse-multiplication-16-x-uint8-t
402402
let mullo = intrinsic_ident("mullo", "epi16", vec_ty.n_bits());
403403
let set1 = intrinsic_ident("set1", "epi16", vec_ty.n_bits());
404-
let and = intrinsic_ident("and", coarse_type(*vec_ty), vec_ty.n_bits());
405-
let or = intrinsic_ident("or", coarse_type(*vec_ty), vec_ty.n_bits());
404+
let and = intrinsic_ident("and", coarse_type(vec_ty), vec_ty.n_bits());
405+
let or = intrinsic_ident("or", coarse_type(vec_ty), vec_ty.n_bits());
406406
let slli = intrinsic_ident("slli", "epi16", vec_ty.n_bits());
407407
let srli = intrinsic_ident("srli", "epi16", vec_ty.n_bits());
408408
quote! {
@@ -444,7 +444,7 @@ pub(crate) fn handle_shift(method_sig: TokenStream, method: &str, vec_ty: &VecTy
444444
let unpack_hi = unpack_intrinsic(ScalarType::Int, 8, false, ty_bits);
445445
let unpack_lo = unpack_intrinsic(ScalarType::Int, 8, true, ty_bits);
446446

447-
let set0 = intrinsic_ident("setzero", coarse_type(*vec_ty), ty_bits);
447+
let set0 = intrinsic_ident("setzero", coarse_type(vec_ty), ty_bits);
448448
let extend_expr = |expr| match vec_ty.scalar {
449449
ScalarType::Unsigned => quote! {
450450
#expr(val, #set0())
@@ -578,7 +578,7 @@ pub(crate) fn handle_zip(method_sig: TokenStream, vec_ty: &VecType, zip1: bool)
578578
ScalarType::Float => "permute2f128",
579579
_ => "permute2x128",
580580
},
581-
coarse_type(*vec_ty),
581+
coarse_type(vec_ty),
582582
256,
583583
);
584584

@@ -695,7 +695,7 @@ pub(crate) fn handle_unzip(
695695
ScalarType::Float => "permute2f128",
696696
_ => "permute2x128",
697697
},
698-
coarse_type(*vec_ty),
698+
coarse_type(vec_ty),
699699
256,
700700
);
701701
let high_shuffle_immediate = if select_even {
@@ -767,8 +767,8 @@ pub(crate) fn handle_cvt(
767767
// IMPORTANT TODO: for f32 to u32, we are currently converting it to i32 instead
768768
// of u32. We need to properly polyfill this.
769769
let cvt_intrinsic = cvt_intrinsic(
770-
*vec_ty,
771-
VecType::new(target_scalar, target_scalar_bits, vec_ty.len),
770+
vec_ty,
771+
&VecType::new(target_scalar, target_scalar_bits, vec_ty.len),
772772
);
773773

774774
let expr = if vec_ty.scalar == ScalarType::Float {

0 commit comments

Comments
 (0)