]>
git.proxmox.com Git - rustc.git/blob - src/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
);
94 u8, u8, u8, u8, u8, u8, u8, u8
95 | x0
, x1
, x2
, x3
, x4
, x5
, x6
, x7
);
96 simd_ty
!(u16x4
[u16]: u16, u16, u16, u16 | x0
, x1
, x2
, x3
);
97 simd_ty
!(u32x2
[u32]: u32, u32 | x0
, x1
);
98 simd_ty
!(u64x1
[u64]: u64 | x1
);
101 i8, i8, i8, i8, i8, i8, i8, i8
102 | x0
, x1
, x2
, x3
, x4
, x5
, x6
, x7
);
103 simd_ty
!(i16x4
[i16]: i16, i16, i16, i16 | x0
, x1
, x2
, x3
);
104 simd_ty
!(i32x2
[i32]: i32, i32 | x0
, x1
);
105 simd_ty
!(i64x1
[i64]: i64 | x1
);
107 simd_ty
!(f32x2
[f32]: f32, f32 | x0
, x1
);
109 // 128-bit wide types:
112 u8, u8, u8, u8, u8, u8, u8, u8,
113 u8, u8, u8, u8, u8, u8, u8, u8
114 | x0
, x1
, x2
, x3
, x4
, x5
, x6
, x7
, x8
, x9
, x10
, x11
, x12
, x13
, x14
, x15
117 u16, u16, u16, u16, u16, u16, u16, u16
118 | x0
, x1
, x2
, x3
, x4
, x5
, x6
, x7
);
119 simd_ty
!(u32x4
[u32]: u32, u32, u32, u32 | x0
, x1
, x2
, x3
);
120 simd_ty
!(u64x2
[u64]: u64, u64 | x0
, x1
);
123 i8, i8, i8, i8, i8, i8, i8, i8,
124 i8, i8, i8, i8, i8, i8, i8, i8
125 | x0
, x1
, x2
, x3
, x4
, x5
, x6
, x7
, x8
, x9
, x10
, x11
, x12
, x13
, x14
, x15
128 i16, i16, i16, i16, i16, i16, i16, i16
129 | x0
, x1
, x2
, x3
, x4
, x5
, x6
, x7
);
130 simd_ty
!(i32x4
[i32]: i32, i32, i32, i32 | x0
, x1
, x2
, x3
);
131 simd_ty
!(i64x2
[i64]: i64, i64 | x0
, x1
);
133 simd_ty
!(f32x4
[f32]: f32, f32, f32, f32 | x0
, x1
, x2
, x3
);
134 simd_ty
!(f64x2
[f64]: f64, f64 | x0
, x1
);
136 simd_m_ty
!(m8x16
[i8]:
137 i8, i8, i8, i8, i8, i8, i8, i8,
138 i8, i8, i8, i8, i8, i8, i8, i8
139 | x0
, x1
, x2
, x3
, x4
, x5
, x6
, x7
, x8
, x9
, x10
, x11
, x12
, x13
, x14
, x15
141 simd_m_ty
!(m16x8
[i16]:
142 i16, i16, i16, i16, i16, i16, i16, i16
143 | x0
, x1
, x2
, x3
, x4
, x5
, x6
, x7
);
144 simd_m_ty
!(m32x4
[i32]: i32, i32, i32, i32 | x0
, x1
, x2
, x3
);
145 simd_m_ty
!(m64x2
[i64]: i64, i64 | x0
, x1
);
147 // 256-bit wide types:
150 u8, u8, u8, u8, u8, u8, u8, u8,
151 u8, u8, u8, u8, u8, u8, u8, u8,
152 u8, u8, u8, u8, u8, u8, u8, u8,
153 u8, u8, u8, u8, u8, u8, u8, u8
154 | x0
, x1
, x2
, x3
, x4
, x5
, x6
, x7
,
155 x8
, x9
, x10
, x11
, x12
, x13
, x14
, x15
,
156 x16
, x17
, x18
, x19
, x20
, x21
, x22
, x23
,
157 x24
, x25
, x26
, x27
, x28
, x29
, x30
, x31
159 simd_ty
!(u16x16
[u16]:
160 u16, u16, u16, u16, u16, u16, u16, u16,
161 u16, u16, u16, u16, u16, u16, u16, u16
162 | x0
, x1
, x2
, x3
, x4
, x5
, x6
, x7
, x8
, x9
, x10
, x11
, x12
, x13
, x14
, x15
165 u32, u32, u32, u32, u32, u32, u32, u32
166 | x0
, x1
, x2
, x3
, x4
, x5
, x6
, x7
);
167 simd_ty
!(u64x4
[u64]: u64, u64, u64, u64 | x0
, x1
, x2
, x3
);
170 i8, i8, i8, i8, i8, i8, i8, i8,
171 i8, i8, i8, i8, i8, i8, i8, i8,
172 i8, i8, i8, i8, i8, i8, i8, i8,
173 i8, i8, i8, i8, i8, i8, i8, i8
174 | x0
, x1
, x2
, x3
, x4
, x5
, x6
, x7
,
175 x8
, x9
, x10
, x11
, x12
, x13
, x14
, x15
,
176 x16
, x17
, x18
, x19
, x20
, x21
, x22
, x23
,
177 x24
, x25
, x26
, x27
, x28
, x29
, x30
, x31
179 simd_ty
!(i16x16
[i16]:
180 i16, i16, i16, i16, i16, i16, i16, i16,
181 i16, i16, i16, i16, i16, i16, i16, i16
182 | x0
, x1
, x2
, x3
, x4
, x5
, x6
, x7
, x8
, x9
, x10
, x11
, x12
, x13
, x14
, x15
185 i32, i32, i32, i32, i32, i32, i32, i32
186 | x0
, x1
, x2
, x3
, x4
, x5
, x6
, x7
);
187 simd_ty
!(i64x4
[i64]: i64, i64, i64, i64 | x0
, x1
, x2
, x3
);
190 f32, f32, f32, f32, f32, f32, f32, f32 |
191 x0
, x1
, x2
, x3
, x4
, x5
, x6
, x7
);
193 // 512-bit wide types:
195 simd_ty
!(i32x16
[i32]:
196 i32, i32, i32, i32, i32, i32, i32, i32,
197 i32, i32, i32, i32, i32, i32, i32, i32
198 | x0
, x1
, x2
, x3
, x4
, x5
, x6
, x7
,
199 x8
, x9
, x10
, x11
, x12
, x13
, x14
, x15
);
202 i64, i64, i64, i64, i64, i64, i64, i64
203 | x0
, x1
, x2
, x3
, x4
, x5
, x6
, x7
);