]>
git.proxmox.com Git - rustc.git/blob - library/stdarch/crates/core_arch/src/simd.rs
1 //! Internal `#[repr(simd)]` types
3 #![allow(non_camel_case_types)]
6 ($id
:ident
[$ety
:ident
]: $
($elem_ty
:ident
),* | $
($elem_name
:ident
),*) => {
8 #[derive(Copy, Clone, Debug, PartialEq)]
9 pub(crate) struct $
id($
(pub $elem_ty
),*);
11 #[allow(clippy::use_self)]
14 pub(crate) const fn new($
($elem_name
: $elem_ty
),*) -> Self {
17 // FIXME: Workaround rust@60637
19 pub(crate) const fn splat(value
: $ety
) -> Self {
21 #[allow(non_camel_case_types, dead_code)]
27 // FIXME: Workaround rust@60637
29 pub(crate) fn extract(self, index
: usize) -> $ety
{
31 crate::core_arch
::simd_llvm
::simd_extract(self, index
as u32)
38 macro_rules
! simd_m_ty
{
39 ($id
:ident
[$ety
:ident
]: $
($elem_ty
:ident
),* | $
($elem_name
:ident
),*) => {
41 #[derive(Copy, Clone, Debug, PartialEq)]
42 pub(crate) struct $
id($
(pub $elem_ty
),*);
44 #[allow(clippy::use_self)]
47 const fn bool_to_internal(x
: bool
) -> $ety
{
48 [0 as $ety
, !(0 as $ety
)][x
as usize]
52 pub(crate) const fn new($
($elem_name
: bool
),*) -> Self {
53 $
id($
(Self::bool_to_internal($elem_name
)),*)
56 // FIXME: Workaround rust@60637
58 pub(crate) const fn splat(value
: bool
) -> Self {
60 #[allow(non_camel_case_types, dead_code)]
62 Self::bool_to_internal(value
)
66 // FIXME: Workaround rust@60637
68 pub(crate) fn extract(self, index
: usize) -> bool
{
69 let r
: $ety
= unsafe {
70 crate::core_arch
::simd_llvm
::simd_extract(self, index
as u32)
80 simd_ty
!(u8x2
[u8]: u8, u8 | x0
, x1
);
81 simd_ty
!(i8x2
[i8]: i8, i8 | x0
, x1
);
85 simd_ty
!(u8x4
[u8]: u8, u8, u8, u8 | x0
, x1
, x2
, x3
);
86 simd_ty
!(u16x2
[u16]: u16, u16 | x0
, x1
);
88 simd_ty
!(i8x4
[i8]: i8, i8, i8, i8 | x0
, x1
, x2
, x3
);
89 simd_ty
!(i16x2
[i16]: i16, i16 | x0
, x1
);
110 simd_ty
!(u16x4
[u16]: u16, u16, u16, u16 | x0
, x1
, x2
, x3
);
111 simd_ty
!(u32x2
[u32]: u32, u32 | x0
, x1
);
112 simd_ty
!(u64x1
[u64]: u64 | x1
);
131 simd_ty
!(i16x4
[i16]: i16, i16, i16, i16 | x0
, x1
, x2
, x3
);
132 simd_ty
!(i32x2
[i32]: i32, i32 | x0
, x1
);
133 simd_ty
!(i64x1
[i64]: i64 | x1
);
135 simd_ty
!(f32x2
[f32]: f32, f32 | x0
, x1
);
137 // 128-bit wide types:
189 simd_ty
!(u32x4
[u32]: u32, u32, u32, u32 | x0
, x1
, x2
, x3
);
190 simd_ty
!(u64x2
[u64]: u64, u64 | x0
, x1
);
242 simd_ty
!(i32x4
[i32]: i32, i32, i32, i32 | x0
, x1
, x2
, x3
);
243 simd_ty
!(i64x2
[i64]: i64, i64 | x0
, x1
);
245 simd_ty
!(f32x4
[f32]: f32, f32, f32, f32 | x0
, x1
, x2
, x3
);
246 simd_ty
!(f64x2
[f64]: f64, f64 | x0
, x1
);
298 simd_m_ty
!(m32x4
[i32]: i32, i32, i32, i32 | x0
, x1
, x2
, x3
);
299 simd_m_ty
!(m64x2
[i64]: i64, i64 | x0
, x1
);
301 // 256-bit wide types:
418 simd_ty
!(u64x4
[u64]: u64, u64, u64, u64 | x0
, x1
, x2
, x3
);
535 simd_ty
!(i64x4
[i64]: i64, i64, i64, i64 | x0
, x1
, x2
, x3
);
555 // 512-bit wide types: