Remove mask aliases
This commit is contained in:
parent
40142ac034
commit
00165ed5be
@ -452,74 +452,59 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
/// A SIMD mask of `LANES` 8-bit values.
|
||||
pub type Mask8<const LANES: usize> = Mask<i8, LANES>;
|
||||
|
||||
/// A SIMD mask of `LANES` 16-bit values.
|
||||
pub type Mask16<const LANES: usize> = Mask<i16, LANES>;
|
||||
|
||||
/// A SIMD mask of `LANES` 32-bit values.
|
||||
pub type Mask32<const LANES: usize> = Mask<i32, LANES>;
|
||||
|
||||
/// A SIMD mask of `LANES` 64-bit values.
|
||||
pub type Mask64<const LANES: usize> = Mask<i64, LANES>;
|
||||
|
||||
/// A SIMD mask of `LANES` pointer-width values.
|
||||
pub type MaskSize<const LANES: usize> = Mask<isize, LANES>;
|
||||
|
||||
/// Vector of eight 8-bit masks
|
||||
pub type mask8x8 = Mask8<8>;
|
||||
pub type mask8x8 = Mask<i8, 8>;
|
||||
|
||||
/// Vector of 16 8-bit masks
|
||||
pub type mask8x16 = Mask8<16>;
|
||||
pub type mask8x16 = Mask<i8, 16>;
|
||||
|
||||
/// Vector of 32 8-bit masks
|
||||
pub type mask8x32 = Mask8<32>;
|
||||
pub type mask8x32 = Mask<i8, 32>;
|
||||
|
||||
/// Vector of 16 8-bit masks
|
||||
pub type mask8x64 = Mask8<64>;
|
||||
pub type mask8x64 = Mask<i8, 64>;
|
||||
|
||||
/// Vector of four 16-bit masks
|
||||
pub type mask16x4 = Mask16<4>;
|
||||
pub type mask16x4 = Mask<i16, 4>;
|
||||
|
||||
/// Vector of eight 16-bit masks
|
||||
pub type mask16x8 = Mask16<8>;
|
||||
pub type mask16x8 = Mask<i16, 8>;
|
||||
|
||||
/// Vector of 16 16-bit masks
|
||||
pub type mask16x16 = Mask16<16>;
|
||||
pub type mask16x16 = Mask<i16, 16>;
|
||||
|
||||
/// Vector of 32 16-bit masks
|
||||
pub type mask16x32 = Mask32<32>;
|
||||
pub type mask16x32 = Mask<i32, 32>;
|
||||
|
||||
/// Vector of two 32-bit masks
|
||||
pub type mask32x2 = Mask32<2>;
|
||||
pub type mask32x2 = Mask<i32, 2>;
|
||||
|
||||
/// Vector of four 32-bit masks
|
||||
pub type mask32x4 = Mask32<4>;
|
||||
pub type mask32x4 = Mask<i32, 4>;
|
||||
|
||||
/// Vector of eight 32-bit masks
|
||||
pub type mask32x8 = Mask32<8>;
|
||||
pub type mask32x8 = Mask<i32, 8>;
|
||||
|
||||
/// Vector of 16 32-bit masks
|
||||
pub type mask32x16 = Mask32<16>;
|
||||
pub type mask32x16 = Mask<i32, 16>;
|
||||
|
||||
/// Vector of two 64-bit masks
|
||||
pub type mask64x2 = Mask64<2>;
|
||||
pub type mask64x2 = Mask<i64, 2>;
|
||||
|
||||
/// Vector of four 64-bit masks
|
||||
pub type mask64x4 = Mask64<4>;
|
||||
pub type mask64x4 = Mask<i64, 4>;
|
||||
|
||||
/// Vector of eight 64-bit masks
|
||||
pub type mask64x8 = Mask64<8>;
|
||||
pub type mask64x8 = Mask<i64, 8>;
|
||||
|
||||
/// Vector of two pointer-width masks
|
||||
pub type masksizex2 = MaskSize<2>;
|
||||
pub type masksizex2 = Mask<isize, 2>;
|
||||
|
||||
/// Vector of four pointer-width masks
|
||||
pub type masksizex4 = MaskSize<4>;
|
||||
pub type masksizex4 = Mask<isize, 4>;
|
||||
|
||||
/// Vector of eight pointer-width masks
|
||||
pub type masksizex8 = MaskSize<8>;
|
||||
pub type masksizex8 = Mask<isize, 8>;
|
||||
|
||||
macro_rules! impl_from {
|
||||
{ $from:ty => $($to:ty),* } => {
|
||||
|
@ -7,9 +7,9 @@ use wasm_bindgen_test::*;
|
||||
wasm_bindgen_test_configure!(run_in_browser);
|
||||
|
||||
macro_rules! test_mask_api {
|
||||
{ $name:ident } => {
|
||||
{ $type:ident } => {
|
||||
#[allow(non_snake_case)]
|
||||
mod $name {
|
||||
mod $type {
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
use wasm_bindgen_test::*;
|
||||
|
||||
@ -17,7 +17,7 @@ macro_rules! test_mask_api {
|
||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
|
||||
fn set_and_test() {
|
||||
let values = [true, false, false, true, false, false, true, false];
|
||||
let mut mask = core_simd::$name::<8>::splat(false);
|
||||
let mut mask = core_simd::Mask::<$type, 8>::splat(false);
|
||||
for (lane, value) in values.iter().copied().enumerate() {
|
||||
mask.set(lane, value);
|
||||
}
|
||||
@ -29,7 +29,7 @@ macro_rules! test_mask_api {
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn set_invalid_lane() {
|
||||
let mut mask = core_simd::$name::<8>::splat(false);
|
||||
let mut mask = core_simd::Mask::<$type, 8>::splat(false);
|
||||
mask.set(8, true);
|
||||
let _ = mask;
|
||||
}
|
||||
@ -37,24 +37,24 @@ macro_rules! test_mask_api {
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn test_invalid_lane() {
|
||||
let mask = core_simd::$name::<8>::splat(false);
|
||||
let mask = core_simd::Mask::<$type, 8>::splat(false);
|
||||
let _ = mask.test(8);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn any() {
|
||||
assert!(!core_simd::$name::<8>::splat(false).any());
|
||||
assert!(core_simd::$name::<8>::splat(true).any());
|
||||
let mut v = core_simd::$name::<8>::splat(false);
|
||||
assert!(!core_simd::Mask::<$type, 8>::splat(false).any());
|
||||
assert!(core_simd::Mask::<$type, 8>::splat(true).any());
|
||||
let mut v = core_simd::Mask::<$type, 8>::splat(false);
|
||||
v.set(2, true);
|
||||
assert!(v.any());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn all() {
|
||||
assert!(!core_simd::$name::<8>::splat(false).all());
|
||||
assert!(core_simd::$name::<8>::splat(true).all());
|
||||
let mut v = core_simd::$name::<8>::splat(false);
|
||||
assert!(!core_simd::Mask::<$type, 8>::splat(false).all());
|
||||
assert!(core_simd::Mask::<$type, 8>::splat(true).all());
|
||||
let mut v = core_simd::Mask::<$type, 8>::splat(false);
|
||||
v.set(2, true);
|
||||
assert!(!v.all());
|
||||
}
|
||||
@ -62,10 +62,10 @@ macro_rules! test_mask_api {
|
||||
#[test]
|
||||
fn roundtrip_int_conversion() {
|
||||
let values = [true, false, false, true, false, false, true, false];
|
||||
let mask = core_simd::$name::<8>::from_array(values);
|
||||
let mask = core_simd::Mask::<$type, 8>::from_array(values);
|
||||
let int = mask.to_int();
|
||||
assert_eq!(int.to_array(), [-1, 0, 0, -1, 0, 0, -1, 0]);
|
||||
assert_eq!(core_simd::$name::<8>::from_int(int), mask);
|
||||
assert_eq!(core_simd::Mask::<$type, 8>::from_int(int), mask);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -74,24 +74,24 @@ macro_rules! test_mask_api {
|
||||
true, false, false, true, false, false, true, false,
|
||||
true, true, false, false, false, false, false, true,
|
||||
];
|
||||
let mask = core_simd::$name::<16>::from_array(values);
|
||||
let mask = core_simd::Mask::<$type, 16>::from_array(values);
|
||||
let bitmask = mask.to_bitmask();
|
||||
assert_eq!(bitmask, [0b01001001, 0b10000011]);
|
||||
assert_eq!(core_simd::$name::<16>::from_bitmask(bitmask), mask);
|
||||
assert_eq!(core_simd::Mask::<$type, 16>::from_bitmask(bitmask), mask);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod mask_api {
|
||||
test_mask_api! { Mask8 }
|
||||
test_mask_api! { i8 }
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn convert() {
|
||||
let values = [true, false, false, true, false, false, true, false];
|
||||
assert_eq!(
|
||||
core_simd::Mask8::from_array(values),
|
||||
core_simd::Mask32::from_array(values).into()
|
||||
core_simd::Mask::<i8, 8>::from_array(values),
|
||||
core_simd::Mask::<i32, 8>::from_array(values).into()
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user