Debian Codegraph @

third-party/simde/arm/neon/rev64.h

raw
1 /* SPDX-License-Identifier: MIT
2 *
3 * Permission is hereby granted, free of charge, to any person
4 * obtaining a copy of this software and associated documentation
5 * files (the "Software"), to deal in the Software without
6 * restriction, including without limitation the rights to use, copy,
7 * modify, merge, publish, distribute, sublicense, and/or sell copies
8 * of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be
12 * included in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
18 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 *
23 * Copyright:
24 * 2020 Evan Nemerson <[email protected]>
25 * 2020 Christopher Moore <[email protected]>
26 */
27
28 /* N.B. CM: vrev64_f16 and vrev64q_f16 are omitted as
29 * SIMDe has no 16-bit floating point support. */
30
31 #if !defined(SIMDE_ARM_NEON_REV64_H)
32 #define SIMDE_ARM_NEON_REV64_H
33
34 #include "reinterpret.h"
35 #include "types.h"
36
37 HEDLEY_DIAGNOSTIC_PUSH
38 SIMDE_DISABLE_UNWANTED_DIAGNOSTICS
39 SIMDE_BEGIN_DECLS_
40
41 SIMDE_FUNCTION_ATTRIBUTES
42 simde_int8x8_t
43 simde_vrev64_s8(simde_int8x8_t a) {
44 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
45 return vrev64_s8(a);
46 #else
47 simde_int8x8_private
48 r_,
49 a_ = simde_int8x8_to_private(a);
50
51 #if defined(SIMDE_X86_SSSE3_NATIVE) && defined(SIMDE_X86_MMX_NATIVE)
52 r_.m64 = _mm_shuffle_pi8(a_.m64, _mm_set_pi8(0, 1, 2, 3, 4, 5, 6, 7));
53 #elif defined(SIMDE_SHUFFLE_VECTOR_) && !defined(SIMDE_BUG_GCC_100762)
54 r_.values = SIMDE_SHUFFLE_VECTOR_(8, 8, a_.values, a_.values, 7, 6, 5, 4, 3, 2, 1, 0);
55 #else
56 SIMDE_VECTORIZE
57 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
58 r_.values[i] = a_.values[i ^ 7];
59 }
60 #endif
61
62 return simde_int8x8_from_private(r_);
63 #endif
64 }
65 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
66 #undef vrev64_s8
67 #define vrev64_s8(a) simde_vrev64_s8(a)
68 #endif
69
70 SIMDE_FUNCTION_ATTRIBUTES
71 simde_int16x4_t
72 simde_vrev64_s16(simde_int16x4_t a) {
73 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
74 return vrev64_s16(a);
75 #else
76 simde_int16x4_private
77 r_,
78 a_ = simde_int16x4_to_private(a);
79
80 #if defined(SIMDE_X86_SSE_NATIVE) && defined(SIMDE_X86_MMX_NATIVE)
81 r_.m64 = _mm_shuffle_pi16(a_.m64, (0 << 6) | (1 << 4) | (2 << 2) | (3 << 0));
82 #elif defined(SIMDE_SHUFFLE_VECTOR_)
83 r_.values = SIMDE_SHUFFLE_VECTOR_(16, 8, a_.values, a_.values, 3, 2, 1, 0);
84 #else
85 SIMDE_VECTORIZE
86 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
87 r_.values[i] = a_.values[i ^ 3];
88 }
89 #endif
90
91 return simde_int16x4_from_private(r_);
92 #endif
93 }
94 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
95 #undef vrev64_s16
96 #define vrev64_s16(a) simde_vrev64_s16(a)
97 #endif
98
99 SIMDE_FUNCTION_ATTRIBUTES
100 simde_int32x2_t
101 simde_vrev64_s32(simde_int32x2_t a) {
102 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
103 return vrev64_s32(a);
104 #else
105 simde_int32x2_private
106 r_,
107 a_ = simde_int32x2_to_private(a);
108
109 #if defined(SIMDE_X86_SSE_NATIVE) && defined(SIMDE_X86_MMX_NATIVE)
110 r_.m64 = _mm_shuffle_pi16(a_.m64, (1 << 6) | (0 << 4) | (3 << 2) | (2 << 0));
111 #elif defined(SIMDE_SHUFFLE_VECTOR_) && !defined(SIMDE_BUG_GCC_100762)
112 r_.values = SIMDE_SHUFFLE_VECTOR_(32, 8, a_.values, a_.values, 1, 0);
113 #else
114 SIMDE_VECTORIZE
115 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
116 r_.values[i] = a_.values[i ^ 1];
117 }
118 #endif
119
120 return simde_int32x2_from_private(r_);
121 #endif
122 }
123 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
124 #undef vrev64_s32
125 #define vrev64_s32(a) simde_vrev64_s32(a)
126 #endif
127
128 SIMDE_FUNCTION_ATTRIBUTES
129 simde_uint8x8_t
130 simde_vrev64_u8(simde_uint8x8_t a) {
131 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
132 return vrev64_u8(a);
133 #else
134 return simde_vreinterpret_u8_s8(simde_vrev64_s8(simde_vreinterpret_s8_u8(a)));
135 #endif
136 }
137 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
138 #undef vrev64_u8
139 #define vrev64_u8(a) simde_vrev64_u8(a)
140 #endif
141
142 SIMDE_FUNCTION_ATTRIBUTES
143 simde_uint16x4_t
144 simde_vrev64_u16(simde_uint16x4_t a) {
145 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
146 return vrev64_u16(a);
147 #else
148 return simde_vreinterpret_u16_s16(simde_vrev64_s16(simde_vreinterpret_s16_u16(a)));
149 #endif
150 }
151 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
152 #undef vrev64_u16
153 #define vrev64_u16(a) simde_vrev64_u16(a)
154 #endif
155
156 SIMDE_FUNCTION_ATTRIBUTES
157 simde_uint32x2_t
158 simde_vrev64_u32(simde_uint32x2_t a) {
159 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
160 return vrev64_u32(a);
161 #else
162 return simde_vreinterpret_u32_s32(simde_vrev64_s32(simde_vreinterpret_s32_u32(a)));
163 #endif
164 }
165 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
166 #undef vrev64_u32
167 #define vrev64_u32(a) simde_vrev64_u32(a)
168 #endif
169
170 SIMDE_FUNCTION_ATTRIBUTES
171 simde_float32x2_t
172 simde_vrev64_f32(simde_float32x2_t a) {
173 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
174 return vrev64_f32(a);
175 #else
176 return simde_vreinterpret_f32_s32(simde_vrev64_s32(simde_vreinterpret_s32_f32(a)));
177 #endif
178 }
179 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
180 #undef vrev64_f32
181 #define vrev64_f32(a) simde_vrev64_f32(a)
182 #endif
183
184 SIMDE_FUNCTION_ATTRIBUTES
185 simde_int8x16_t
186 simde_vrev64q_s8(simde_int8x16_t a) {
187 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
188 return vrev64q_s8(a);
189 #elif defined(SIMDE_POWER_ALTIVEC_P8_NATIVE)
190 return HEDLEY_REINTERPRET_CAST(SIMDE_POWER_ALTIVEC_VECTOR(signed char),
191 vec_revb(HEDLEY_REINTERPRET_CAST(SIMDE_POWER_ALTIVEC_VECTOR(signed long long), a)));
192 #elif defined(SIMDE_POWER_ALTIVEC_P7_NATIVE)
193 return HEDLEY_REINTERPRET_CAST(SIMDE_POWER_ALTIVEC_VECTOR(signed char),
194 vec_reve(HEDLEY_REINTERPRET_CAST(SIMDE_POWER_ALTIVEC_VECTOR(signed long long), vec_reve(a))));
195 #else
196 simde_int8x16_private
197 r_,
198 a_ = simde_int8x16_to_private(a);
199
200 #if defined(SIMDE_X86_SSSE3_NATIVE)
201 r_.m128i = _mm_shuffle_epi8(a_.m128i, _mm_set_epi8(8, 9, 10, 11, 12, 13, 14, 15,
202 0, 1, 2, 3, 4, 5, 6, 7));
203 #elif defined(SIMDE_WASM_SIMD128_NATIVE)
204 r_.v128 = wasm_i8x16_shuffle(a_.v128, a_.v128, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8);
205 #elif defined(SIMDE_SHUFFLE_VECTOR_)
206 r_.values = SIMDE_SHUFFLE_VECTOR_(8, 16, a_.values, a_.values, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8);
207 #else
208 SIMDE_VECTORIZE
209 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
210 r_.values[i] = a_.values[i ^ 7];
211 }
212 #endif
213
214 return simde_int8x16_from_private(r_);
215 #endif
216 }
217 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
218 #undef vrev64q_s8
219 #define vrev64q_s8(a) simde_vrev64q_s8(a)
220 #endif
221
222 SIMDE_FUNCTION_ATTRIBUTES
223 simde_int16x8_t
224 simde_vrev64q_s16(simde_int16x8_t a) {
225 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
226 return vrev64q_s16(a);
227 #elif defined(SIMDE_POWER_ALTIVEC_P7_NATIVE)
228 return HEDLEY_REINTERPRET_CAST(SIMDE_POWER_ALTIVEC_VECTOR(signed short),
229 vec_reve(HEDLEY_REINTERPRET_CAST(SIMDE_POWER_ALTIVEC_VECTOR(signed long long), vec_reve(a))));
230 #else
231 simde_int16x8_private
232 r_,
233 a_ = simde_int16x8_to_private(a);
234
235 #if defined(SIMDE_X86_SSSE3_NATIVE)
236 r_.m128i = _mm_shuffle_epi8(a_.m128i, _mm_set_epi8(9, 8, 11, 10, 13, 12, 15, 14,
237 1, 0, 3, 2, 5, 4, 7, 6));
238 #elif defined(SIMDE_X86_SSE2_NATIVE)
239 r_.m128i = _mm_shufflehi_epi16(_mm_shufflelo_epi16(a_.m128i,
240 (0 << 6) | (1 << 4) | (2 << 2) | (3 << 0)),
241 (0 << 6) | (1 << 4) | (2 << 2) | (3 << 0));
242 #elif defined(SIMDE_WASM_SIMD128_NATIVE)
243 r_.v128 = wasm_i8x16_shuffle(a_.v128, a_.v128, 6, 7, 4, 5, 2, 3, 0, 1, 14, 15, 12, 13, 10, 11, 8, 9);
244 #elif defined(SIMDE_SHUFFLE_VECTOR_)
245 r_.values = SIMDE_SHUFFLE_VECTOR_(16, 16, a_.values, a_.values, 3, 2, 1, 0, 7, 6, 5, 4);
246 #else
247 SIMDE_VECTORIZE
248 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
249 r_.values[i] = a_.values[i ^ 3];
250 }
251 #endif
252
253 return simde_int16x8_from_private(r_);
254 #endif
255 }
256 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
257 #undef vrev64q_s16
258 #define vrev64q_s16(a) simde_vrev64q_s16(a)
259 #endif
260
261 SIMDE_FUNCTION_ATTRIBUTES
262 simde_int32x4_t
263 simde_vrev64q_s32(simde_int32x4_t a) {
264 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
265 return vrev64q_s32(a);
266 #elif defined(SIMDE_POWER_ALTIVEC_P7_NATIVE)
267 return HEDLEY_REINTERPRET_CAST(SIMDE_POWER_ALTIVEC_VECTOR(signed int),
268 vec_reve(HEDLEY_REINTERPRET_CAST(SIMDE_POWER_ALTIVEC_VECTOR(signed long long), vec_reve(a))));
269 #else
270 simde_int32x4_private
271 r_,
272 a_ = simde_int32x4_to_private(a);
273
274 #if defined(SIMDE_X86_SSE2_NATIVE)
275 r_.m128i = _mm_shuffle_epi32(a_.m128i, (2 << 6) | (3 << 4) | (0 << 2) | (1 << 0));
276 #elif defined(SIMDE_WASM_SIMD128_NATIVE)
277 r_.v128 = wasm_i8x16_shuffle(a_.v128, a_.v128, 4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 15, 8, 9, 10, 11);
278 #elif defined(SIMDE_SHUFFLE_VECTOR_)
279 r_.values = SIMDE_SHUFFLE_VECTOR_(32, 16, a_.values, a_.values, 1, 0, 3, 2);
280 #else
281 SIMDE_VECTORIZE
282 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
283 r_.values[i] = a_.values[i ^ 1];
284 }
285 #endif
286
287 return simde_int32x4_from_private(r_);
288 #endif
289 }
290 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
291 #undef vrev64q_s32
292 #define vrev64q_s32(a) simde_vrev64q_s32(a)
293 #endif
294
295 SIMDE_FUNCTION_ATTRIBUTES
296 simde_uint8x16_t
297 simde_vrev64q_u8(simde_uint8x16_t a) {
298 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
299 return vrev64q_u8(a);
300 #else
301 return simde_vreinterpretq_u8_s8(simde_vrev64q_s8(simde_vreinterpretq_s8_u8(a)));
302 #endif
303 }
304 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
305 #undef vrev64q_u8
306 #define vrev64q_u8(a) simde_vrev64q_u8(a)
307 #endif
308
309 SIMDE_FUNCTION_ATTRIBUTES
310 simde_uint16x8_t
311 simde_vrev64q_u16(simde_uint16x8_t a) {
312 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
313 return vrev64q_u16(a);
314 #else
315 return simde_vreinterpretq_u16_s16(simde_vrev64q_s16(simde_vreinterpretq_s16_u16(a)));
316 #endif
317 }
318 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
319 #undef vrev64q_u16
320 #define vrev64q_u16(a) simde_vrev64q_u16(a)
321 #endif
322
323 SIMDE_FUNCTION_ATTRIBUTES
324 simde_uint32x4_t
325 simde_vrev64q_u32(simde_uint32x4_t a) {
326 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
327 return vrev64q_u32(a);
328 #else
329 return simde_vreinterpretq_u32_s32(simde_vrev64q_s32(simde_vreinterpretq_s32_u32(a)));
330 #endif
331 }
332 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
333 #undef vrev64q_u32
334 #define vrev64q_u32(a) simde_vrev64q_u32(a)
335 #endif
336
337 SIMDE_FUNCTION_ATTRIBUTES
338 simde_float32x4_t
339 simde_vrev64q_f32(simde_float32x4_t a) {
340 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
341 return vrev64q_f32(a);
342 #else
343 return simde_vreinterpretq_f32_s32(simde_vrev64q_s32(simde_vreinterpretq_s32_f32(a)));
344 #endif
345 }
346 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
347 #undef vrev64q_f32
348 #define vrev64q_f32(a) simde_vrev64q_f32(a)
349 #endif
350
351 SIMDE_END_DECLS_
352 HEDLEY_DIAGNOSTIC_POP
353
354 #endif /* !defined(SIMDE_ARM_NEON_REV64_H) */