Skip to content

Commit 57c1d8f

Browse files
committed
add mask types for ppc
1 parent cb8163e commit 57c1d8f

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

coresimd/simd.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,41 @@ macro_rules! simd_ty {
3131
}
3232
}
3333

34+
macro_rules! simd_m_ty {
35+
($id:ident [$ety:ident]: $($elem_ty:ident),* | $($elem_name:ident),*) => {
36+
#[repr(simd)]
37+
#[derive(Copy, Clone, Debug, PartialEq)]
38+
pub(crate) struct $id($(pub $elem_ty),*);
39+
40+
impl $id {
41+
#[inline]
42+
const fn bool_to_internal(x: bool) -> $ety {
43+
[0 as $ety, !(0 as $ety)][x as usize]
44+
}
45+
46+
#[inline]
47+
pub(crate) const fn new($($elem_name: bool),*) -> Self {
48+
$id($(Self::bool_to_internal($elem_name)),*)
49+
}
50+
51+
#[inline]
52+
pub(crate) const fn splat(value: bool) -> Self {
53+
$id($({
54+
#[allow(non_camel_case_types, dead_code)]
55+
struct $elem_name;
56+
Self::bool_to_internal(value)
57+
}),*)
58+
}
59+
60+
#[inline]
61+
pub(crate) fn extract(self, index: usize) -> bool {
62+
let r: $ety = unsafe { ::coresimd::simd_llvm::simd_extract(self, index as u32) };
63+
r != 0
64+
}
65+
}
66+
}
67+
}
68+
3469
// 16-bit wide types:
3570

3671
simd_ty!(u8x2[u8]: u8, u8 | x0, x1);
@@ -81,6 +116,15 @@ simd_ty!(i64x2[i64]: i64, i64 | x0, x1);
81116
simd_ty!(f32x4[f32]: f32, f32, f32, f32 | x0, x1, x2, x3);
82117
simd_ty!(f64x2[f64]: f64, f64 | x0, x1);
83118

119+
simd_m_ty!(m8x16[i8]:
120+
i8, i8, i8, i8, i8, i8, i8, i8,
121+
i8, i8, i8, i8, i8, i8, i8, i8
122+
| x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15
123+
);
124+
simd_ty!(m16x8[i16]: i16, i16, i16, i16, i16, i16, i16, i16 | x0, x1, x2, x3, x4, x5, x6, x7);
125+
simd_m_ty!(m32x4[i32]: i32, i32, i32, i32 | x0, x1, x2, x3);
126+
127+
84128
// 256-bit wide types:
85129

86130
simd_ty!(u8x32[u8]:

0 commit comments

Comments
 (0)