Debian Codegraph @

third-party/simde/arm/neon/rev32.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_REV32_H)
29 #define SIMDE_ARM_NEON_REV32_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_vrev32_s8(simde_int8x8_t a) {
41 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
42 return vrev32_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(4, 5, 6, 7, 0, 1, 2, 3));
50 #elif defined(SIMDE_SHUFFLE_VECTOR_) && !defined(SIMDE_BUG_GCC_100762)
51 r_.values = SIMDE_SHUFFLE_VECTOR_(8, 8, a_.values, a_.values, 3, 2, 1, 0, 7, 6, 5, 4);
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 ^ 3];
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 vrev32_s8
64 #define vrev32_s8(a) simde_vrev32_s8(a)
65 #endif
66
67 SIMDE_FUNCTION_ATTRIBUTES
68 simde_int16x4_t
69 simde_vrev32_s16(simde_int16x4_t a) {
70 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
71 return vrev32_s16(a);
72 #else
73 simde_int16x4_private
74 r_,
75 a_ = simde_int16x4_to_private(a);
76
77 #if defined(SIMDE_X86_SSE_NATIVE) && defined(SIMDE_X86_MMX_NATIVE)
78 r_.m64 = _mm_shuffle_pi16(a_.m64, (2 << 6) | (3 << 4) | (0 << 2) | (1 << 0));
79 #elif defined(SIMDE_SHUFFLE_VECTOR_)
80 r_.values = SIMDE_SHUFFLE_VECTOR_(16, 8, a_.values, a_.values, 1, 0, 3, 2);
81 #else
82 SIMDE_VECTORIZE
83 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
84 r_.values[i] = a_.values[i ^ 1];
85 }
86 #endif
87
88 return simde_int16x4_from_private(r_);
89 #endif
90 }
91 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
92 #undef vrev32_s16
93 #define vrev32_s16(a) simde_vrev32_s16(a)
94 #endif
95
96 SIMDE_FUNCTION_ATTRIBUTES
97 simde_uint8x8_t
98 simde_vrev32_u8(simde_uint8x8_t a) {
99 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
100 return vrev32_u8(a);
101 #else
102 return simde_vreinterpret_u8_s8(simde_vrev32_s8(simde_vreinterpret_s8_u8(a)));
103 #endif
104 }
105 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
106 #undef vrev32_u8
107 #define vrev32_u8(a) simde_vrev32_u8(a)
108 #endif
109
110 SIMDE_FUNCTION_ATTRIBUTES
111 simde_uint16x4_t
112 simde_vrev32_u16(simde_uint16x4_t a) {
113 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
114 return vrev32_u16(a);
115 #else
116 return simde_vreinterpret_u16_s16(simde_vrev32_s16(simde_vreinterpret_s16_u16(a)));
117 #endif
118 }
119 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
120 #undef vrev32_u16
121 #define vrev32_u16(a) simde_vrev32_u16(a)
122 #endif
123
124 SIMDE_FUNCTION_ATTRIBUTES
125 simde_int8x16_t
126 simde_vrev32q_s8(simde_int8x16_t a) {
127 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
128 return vrev32q_s8(a);
129 #elif defined(SIMDE_POWER_ALTIVEC_P8_NATIVE)
130 return HEDLEY_REINTERPRET_CAST(SIMDE_POWER_ALTIVEC_VECTOR(signed char),
131 vec_revb(HEDLEY_REINTERPRET_CAST(SIMDE_POWER_ALTIVEC_VECTOR(signed int), a)));
132 #elif defined(SIMDE_POWER_ALTIVEC_P7_NATIVE)
133 return HEDLEY_REINTERPRET_CAST(SIMDE_POWER_ALTIVEC_VECTOR(signed char),
134 vec_reve(HEDLEY_REINTERPRET_CAST(SIMDE_POWER_ALTIVEC_VECTOR(signed int), vec_reve(a))));
135 #else
136 simde_int8x16_private
137 r_,
138 a_ = simde_int8x16_to_private(a);
139
140 #if defined(SIMDE_X86_SSSE3_NATIVE)
141 r_.m128i = _mm_shuffle_epi8(a_.m128i, _mm_set_epi8(12, 13, 14, 15, 8, 9, 10, 11,
142 4, 5, 6, 7, 0, 1, 2, 3));
143 #elif defined(SIMDE_WASM_SIMD128_NATIVE)
144 r_.v128 = wasm_i8x16_shuffle(a_.v128, a_.v128, 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12);
145 #elif defined(SIMDE_SHUFFLE_VECTOR_)
146 r_.values = SIMDE_SHUFFLE_VECTOR_(8, 16, a_.values, a_.values, 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12);
147 #else
148 SIMDE_VECTORIZE
149 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
150 r_.values[i] = a_.values[i ^ 3];
151 }
152 #endif
153
154 return simde_int8x16_from_private(r_);
155 #endif
156 }
157 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
158 #undef vrev32q_s8
159 #define vrev32q_s8(a) simde_vrev32q_s8(a)
160 #endif
161
162 SIMDE_FUNCTION_ATTRIBUTES
163 simde_int16x8_t
164 simde_vrev32q_s16(simde_int16x8_t a) {
165 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
166 return vrev32q_s16(a);
167 #elif defined(SIMDE_POWER_ALTIVEC_P7_NATIVE)
168 return HEDLEY_REINTERPRET_CAST(SIMDE_POWER_ALTIVEC_VECTOR(signed short),
169 vec_reve(HEDLEY_REINTERPRET_CAST(SIMDE_POWER_ALTIVEC_VECTOR(signed int), vec_reve(a))));
170 #else
171 simde_int16x8_private
172 r_,
173 a_ = simde_int16x8_to_private(a);
174
175 #if defined(SIMDE_X86_SSSE3_NATIVE)
176 r_.m128i = _mm_shuffle_epi8(a_.m128i, _mm_set_epi8(13, 12, 15, 14, 9, 8, 11, 10,
177 5, 4, 7, 6, 1, 0, 3, 2));
178 #elif defined(SIMDE_X86_SSE2_NATIVE)
179 r_.m128i = _mm_shufflehi_epi16(_mm_shufflelo_epi16(a_.m128i,
180 (2 << 6) | (3 << 4) | (0 << 2) | (1 << 0)),
181 (2 << 6) | (3 << 4) | (0 << 2) | (1 << 0));
182 #elif defined(SIMDE_WASM_SIMD128_NATIVE)
183 r_.v128 = wasm_i8x16_shuffle(a_.v128, a_.v128, 2, 3, 0, 1, 6, 7, 4, 5, 10, 11, 8, 9, 14, 15, 12, 13);
184 #elif defined(SIMDE_SHUFFLE_VECTOR_)
185 r_.values = SIMDE_SHUFFLE_VECTOR_(16, 16, a_.values, a_.values, 1, 0, 3, 2, 5, 4, 7, 6);
186 #else
187 SIMDE_VECTORIZE
188 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
189 r_.values[i] = a_.values[i ^ 1];
190 }
191 #endif
192
193 return simde_int16x8_from_private(r_);
194 #endif
195 }
196 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
197 #undef vrev32q_s16
198 #define vrev32q_s16(a) simde_vrev32q_s16(a)
199 #endif
200
201 SIMDE_FUNCTION_ATTRIBUTES
202 simde_uint8x16_t
203 simde_vrev32q_u8(simde_uint8x16_t a) {
204 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
205 return vrev32q_u8(a);
206 #else
207 return simde_vreinterpretq_u8_s8(simde_vrev32q_s8(simde_vreinterpretq_s8_u8(a)));
208 #endif
209 }
210 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
211 #undef vrev32q_u8
212 #define vrev32q_u8(a) simde_vrev32q_u8(a)
213 #endif
214
215 SIMDE_FUNCTION_ATTRIBUTES
216 simde_uint16x8_t
217 simde_vrev32q_u16(simde_uint16x8_t a) {
218 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
219 return vrev32q_u16(a);
220 #else
221 return simde_vreinterpretq_u16_s16(simde_vrev32q_s16(simde_vreinterpretq_s16_u16(a)));
222 #endif
223 }
224 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
225 #undef vrev32q_u16
226 #define vrev32q_u16(a) simde_vrev32q_u16(a)
227 #endif
228
229 SIMDE_END_DECLS_
230 HEDLEY_DIAGNOSTIC_POP
231
232 #endif /* !defined(SIMDE_ARM_NEON_REV32_H) */