Skip to content

Commit

Permalink
fix: use simd representation structs
Browse files Browse the repository at this point in the history
  • Loading branch information
theoparis committed Sep 21, 2024
1 parent 1b7c8bc commit f1001fb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
11 changes: 7 additions & 4 deletions simd/src/arm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,20 @@ use std::ops::{Add, BitAnd, BitOr, Div, Index, IndexMut, Mul, Not, Shr, Sub};
mod swizzle_f32x4;
mod swizzle_i32x4;

#[repr(simd)]
struct Simd<T, const N: usize>([T; N]);

macro_rules! simd_shuffle2 {
($x:expr, $y:expr, <$(const $imm:ident : $ty:ty),+> $idx:expr $(,)?) => {{
struct ConstParam<$(const $imm: $ty),+>;
impl<$(const $imm: $ty),+> ConstParam<$($imm),+> {
const IDX: [u32; 2] = $idx;
const IDX: Simd<u32, 2> = Simd($idx);
}

simd_shuffle($x, $y, ConstParam::<$($imm),+>::IDX)
}};
($x:expr, $y:expr, $idx:expr $(,)?) => {{
const IDX: [u32; 2] = $idx;
const IDX: Simd<u32, 2> = Simd($idx);
simd_shuffle($x, $y, IDX)
}};
}
Expand All @@ -38,13 +41,13 @@ macro_rules! simd_shuffle4 {
($x:expr, $y:expr, <$(const $imm:ident : $ty:ty),+> $idx:expr $(,)?) => {{
struct ConstParam<$(const $imm: $ty),+>;
impl<$(const $imm: $ty),+> ConstParam<$($imm),+> {
const IDX: [u32; 4] = $idx;
const IDX: Simd<u32; 4> = Simd($idx);
}

simd_shuffle($x, $y, ConstParam::<$($imm),+>::IDX)
}};
($x:expr, $y:expr, $idx:expr $(,)?) => {{
const IDX: [u32; 4] = $idx;
const IDX: Simd<u32, 4> = Simd($idx);
simd_shuffle($x, $y, IDX)
}};
}
Expand Down
1 change: 1 addition & 0 deletions simd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#![cfg_attr(pf_rustc_nightly, allow(internal_features))]
#![cfg_attr(pf_rustc_nightly, feature(link_llvm_intrinsics, core_intrinsics))]
#![cfg_attr(pf_rustc_nightly, feature(simd_ffi))]
#![feature(repr_simd)]

//! A minimal SIMD abstraction, usable outside of Pathfinder.

Expand Down

0 comments on commit f1001fb

Please sign in to comment.