Debian Codegraph @

third-party/simde/arm/neon/rev16.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 #if !defined(SIMDE_ARM_NEON_REV16_H)
29 #define SIMDE_ARM_NEON_REV16_H
30
31 #include "reinterpret.h"
32 #include "types.h"
33
34 HEDLEY_DIAGNOSTIC_PUSH
35 SIMDE_DISABLE_UNWANTED_DIAGNOSTICS
36 SIMDE_BEGIN_DECLS_
37
38 SIMDE_FUNCTION_ATTRIBUTES
39 simde_int8x8_t
40 simde_vrev16_s8(simde_int8x8_t a) {
41 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
42 return vrev16_s8(a);
43 #else
44 simde_int8x8_private
45 r_,
46 a_ = simde_int8x8_to_private(a);
47
48 #if defined(SIMDE_X86_SSSE3_NATIVE) && defined(SIMDE_X86_MMX_NATIVE)
49 r_.m64 = _mm_shuffle_pi8(a_.m64, _mm_set_pi8(6, 7, 4, 5, 2, 3, 0, 1));
50 #elif defined(SIMDE_SHUFFLE_VECTOR_) && !defined(SIMDE_BUG_GCC_100762)
51 r_.values = SIMDE_SHUFFLE_VECTOR_(8, 8, a_.values, a_.values, 1, 0, 3, 2, 5, 4, 7, 6);
52 #else
53 SIMDE_VECTORIZE
54 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
55 r_.values[i] = a_.values[i ^ 1];
56 }
57 #endif
58
59 return simde_int8x8_from_private(r_);
60 #endif
61 }
62 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
63 #undef vrev16_s8
64 #define vrev16_s8(a) simde_vrev16_s8(a)
65 #endif
66
67 SIMDE_FUNCTION_ATTRIBUTES
68 simde_uint8x8_t
69 simde_vrev16_u8(simde_uint8x8_t a) {
70 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
71 return vrev16_u8(a);
72 #else
73 return simde_vreinterpret_u8_s8(simde_vrev16_s8(simde_vreinterpret_s8_u8(a)));
74 #endif
75 }
76 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
77 #undef vrev16_u8
78 #define vrev16_u8(a) simde_vrev16_u8(a)
79 #endif
80
81 SIMDE_FUNCTION_ATTRIBUTES
82 simde_int8x16_t
83 simde_vrev16q_s8(simde_int8x16_t a) {
84 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
85 return vrev16q_s8(a);
86 #elif defined(SIMDE_POWER_ALTIVEC_P8_NATIVE)
87 return HEDLEY_REINTERPRET_CAST(SIMDE_POWER_ALTIVEC_VECTOR(signed char),
88 vec_revb(HEDLEY_REINTERPRET_CAST(SIMDE_POWER_ALTIVEC_VECTOR(signed short), a)));
89 #elif defined(SIMDE_POWER_ALTIVEC_P7_NATIVE)
90 return HEDLEY_REINTERPRET_CAST(SIMDE_POWER_ALTIVEC_VECTOR(signed char),
91 vec_reve(HEDLEY_REINTERPRET_CAST(SIMDE_POWER_ALTIVEC_VECTOR(signed short), vec_reve(a))));
92 #else
93 simde_int8x16_private
94 r_,
95 a_ = simde_int8x16_to_private(a);
96
97 #if defined(SIMDE_X86_SSSE3_NATIVE)
98 r_.m128i = _mm_shuffle_epi8(a_.m128i, _mm_set_epi8(14, 15, 12, 13, 10, 11, 8, 9, 6, 7, 4, 5, 2, 3, 0, 1));
99 #elif defined(SIMDE_WASM_SIMD128_NATIVE)
100 r_.v128 = wasm_i8x16_shuffle(a_.v128, a_.v128, 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
101 #elif defined(SIMDE_SHUFFLE_VECTOR_)
102 r_.values = SIMDE_SHUFFLE_VECTOR_(8, 16, a_.values, a_.values, 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
103 #else
104 SIMDE_VECTORIZE
105 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
106 r_.values[i] = a_.values[i ^ 1];
107 }
108 #endif
109
110 return simde_int8x16_from_private(r_);
111 #endif
112 }
113 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
114 #undef vrev16q_s8
115 #define vrev16q_s8(a) simde_vrev16q_s8(a)
116 #endif
117
118 SIMDE_FUNCTION_ATTRIBUTES
119 simde_uint8x16_t
120 simde_vrev16q_u8(simde_uint8x16_t a) {
121 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
122 return vrev16q_u8(a);
123 #else
124 return simde_vreinterpretq_u8_s8(simde_vrev16q_s8(simde_vreinterpretq_s8_u8(a)));
125 #endif
126 }
127 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
128 #undef vrev16q_u8
129 #define vrev16q_u8(a) simde_vrev16q_u8(a)
130 #endif
131
132 SIMDE_END_DECLS_
133 HEDLEY_DIAGNOSTIC_POP
134
135 #endif /* !defined(SIMDE_ARM_NEON_REV16_H) */