Debian Codegraph @

third-party/simde/arm/neon/sri_n.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 * 2021 Zhi An Ng <[email protected]> (Copyright owned by Google, LLC)
25 * 2021 Evan Nemerson <[email protected]>
26 */
27
28 #if !defined(SIMDE_ARM_NEON_SRI_N_H)
29 #define SIMDE_ARM_NEON_SRI_N_H
30
31 #include "types.h"
32 #include "shr_n.h"
33 #include "dup_n.h"
34 #include "and.h"
35 #include "orr.h"
36 #include "reinterpret.h"
37
38 HEDLEY_DIAGNOSTIC_PUSH
39 SIMDE_DISABLE_UNWANTED_DIAGNOSTICS
40 SIMDE_BEGIN_DECLS_
41
42 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
43 #define simde_vsrid_n_s64(a, b, n) vsrid_n_s64(a, b, n)
44 #else
45 #define simde_vsrid_n_s64(a, b, n) \
46 HEDLEY_STATIC_CAST(int64_t, \
47 simde_vsrid_n_u64(HEDLEY_STATIC_CAST(uint64_t, a), HEDLEY_STATIC_CAST(uint64_t, b), n))
48 #endif
49 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
50 #undef vsrid_n_s64
51 #define vsrid_n_s64(a, b, n) simde_vsrid_n_s64((a), (b), (n))
52 #endif
53
54 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
55 #define simde_vsrid_n_u64(a, b, n) vsrid_n_u64(a, b, n)
56 #else
57 #define simde_vsrid_n_u64(a, b, n) \
58 (((a & (UINT64_C(0xffffffffffffffff) >> (64 - n) << (64 - n))) | simde_vshrd_n_u64((b), (n))))
59 #endif
60 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
61 #undef vsrid_n_u64
62 #define vsrid_n_u64(a, b, n) simde_vsrid_n_u64((a), (b), (n))
63 #endif
64
65 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
66 #define simde_vsri_n_s8(a, b, n) vsri_n_s8((a), (b), (n))
67 #else
68 #define simde_vsri_n_s8(a, b, n) \
69 simde_vreinterpret_s8_u8(simde_vsri_n_u8( \
70 simde_vreinterpret_u8_s8((a)), simde_vreinterpret_u8_s8((b)), (n)))
71 #endif
72 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
73 #undef vsri_n_s8
74 #define vsri_n_s8(a, b, n) simde_vsri_n_s8((a), (b), (n))
75 #endif
76
77 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
78 #define simde_vsri_n_u8(a, b, n) vsri_n_u8((a), (b), (n))
79 #else
80 #define simde_vsri_n_u8(a, b, n) \
81 simde_vorr_u8( \
82 simde_vand_u8((a), simde_vdup_n_u8((UINT8_C(0xff) >> (8 - n) << (8 - n)))), \
83 simde_vshr_n_u8((b), (n)))
84 #endif
85 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
86 #undef vsri_n_u8
87 #define vsri_n_u8(a, b, n) simde_vsri_n_u8((a), (b), (n))
88 #endif
89
90 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
91 #define simde_vsri_n_s16(a, b, n) vsri_n_s16((a), (b), (n))
92 #else
93 #define simde_vsri_n_s16(a, b, n) \
94 simde_vreinterpret_s16_u16(simde_vsri_n_u16( \
95 simde_vreinterpret_u16_s16((a)), simde_vreinterpret_u16_s16((b)), (n)))
96 #endif
97 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
98 #undef vsri_n_s16
99 #define vsri_n_s16(a, b, n) simde_vsri_n_s16((a), (b), (n))
100 #endif
101
102 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
103 #define simde_vsri_n_u16(a, b, n) vsri_n_u16((a), (b), (n))
104 #else
105 #define simde_vsri_n_u16(a, b, n) \
106 simde_vorr_u16( \
107 simde_vand_u16((a), simde_vdup_n_u16((UINT16_C(0xffff) >> (16 - n) << (16 - n)))), \
108 simde_vshr_n_u16((b), (n)))
109 #endif
110 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
111 #undef vsri_n_u16
112 #define vsri_n_u16(a, b, n) simde_vsri_n_u16((a), (b), (n))
113 #endif
114
115 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
116 #define simde_vsri_n_s32(a, b, n) vsri_n_s32((a), (b), (n))
117 #else
118 #define simde_vsri_n_s32(a, b, n) \
119 simde_vreinterpret_s32_u32(simde_vsri_n_u32( \
120 simde_vreinterpret_u32_s32((a)), simde_vreinterpret_u32_s32((b)), (n)))
121 #endif
122 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
123 #undef vsri_n_s32
124 #define vsri_n_s32(a, b, n) simde_vsri_n_s32((a), (b), (n))
125 #endif
126
127 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
128 #define simde_vsri_n_u32(a, b, n) vsri_n_u32((a), (b), (n))
129 #else
130 #define simde_vsri_n_u32(a, b, n) \
131 simde_vorr_u32( \
132 simde_vand_u32((a), \
133 simde_vdup_n_u32((UINT32_C(0xffffffff) >> (32 - n) << (32 - n)))), \
134 simde_vshr_n_u32((b), (n)))
135 #endif
136 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
137 #undef vsri_n_u32
138 #define vsri_n_u32(a, b, n) simde_vsri_n_u32((a), (b), (n))
139 #endif
140
141 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
142 #define simde_vsri_n_s64(a, b, n) vsri_n_s64((a), (b), (n))
143 #else
144 #define simde_vsri_n_s64(a, b, n) \
145 simde_vreinterpret_s64_u64(simde_vsri_n_u64( \
146 simde_vreinterpret_u64_s64((a)), simde_vreinterpret_u64_s64((b)), (n)))
147 #endif
148 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
149 #undef vsri_n_s64
150 #define vsri_n_s64(a, b, n) simde_vsri_n_s64((a), (b), (n))
151 #endif
152
153 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
154 #define simde_vsri_n_u64(a, b, n) vsri_n_u64((a), (b), (n))
155 #else
156 #define simde_vsri_n_u64(a, b, n) \
157 simde_vorr_u64( \
158 simde_vand_u64((a), simde_vdup_n_u64( \
159 (UINT64_C(0xffffffffffffffff) >> (64 - n) << (64 - n)))), \
160 simde_vshr_n_u64((b), (n)))
161 #endif
162 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
163 #undef vsri_n_u64
164 #define vsri_n_u64(a, b, n) simde_vsri_n_u64((a), (b), (n))
165 #endif
166
167 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
168 #define simde_vsriq_n_s8(a, b, n) vsriq_n_s8((a), (b), (n))
169 #else
170 #define simde_vsriq_n_s8(a, b, n) \
171 simde_vreinterpretq_s8_u8(simde_vsriq_n_u8( \
172 simde_vreinterpretq_u8_s8((a)), simde_vreinterpretq_u8_s8((b)), (n)))
173 #endif
174 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
175 #undef vsriq_n_s8
176 #define vsriq_n_s8(a, b, n) simde_vsriq_n_s8((a), (b), (n))
177 #endif
178
179 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
180 #define simde_vsriq_n_u8(a, b, n) vsriq_n_u8((a), (b), (n))
181 #else
182 #define simde_vsriq_n_u8(a, b, n) \
183 simde_vorrq_u8( \
184 simde_vandq_u8((a), simde_vdupq_n_u8((UINT8_C(0xff) >> (8 - n) << (8 - n)))), \
185 simde_vshrq_n_u8((b), (n)))
186 #endif
187 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
188 #undef vsriq_n_u8
189 #define vsriq_n_u8(a, b, n) simde_vsriq_n_u8((a), (b), (n))
190 #endif
191
192 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
193 #define simde_vsriq_n_s16(a, b, n) vsriq_n_s16((a), (b), (n))
194 #else
195 #define simde_vsriq_n_s16(a, b, n) \
196 simde_vreinterpretq_s16_u16(simde_vsriq_n_u16( \
197 simde_vreinterpretq_u16_s16((a)), simde_vreinterpretq_u16_s16((b)), (n)))
198 #endif
199 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
200 #undef vsriq_n_s16
201 #define vsriq_n_s16(a, b, n) simde_vsriq_n_s16((a), (b), (n))
202 #endif
203
204 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
205 #define simde_vsriq_n_u16(a, b, n) vsriq_n_u16((a), (b), (n))
206 #else
207 #define simde_vsriq_n_u16(a, b, n) \
208 simde_vorrq_u16( \
209 simde_vandq_u16((a), simde_vdupq_n_u16((UINT16_C(0xffff) >> (16 - n) << (16 - n)))), \
210 simde_vshrq_n_u16((b), (n)))
211 #endif
212 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
213 #undef vsriq_n_u16
214 #define vsriq_n_u16(a, b, n) simde_vsriq_n_u16((a), (b), (n))
215 #endif
216
217 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
218 #define simde_vsriq_n_s32(a, b, n) vsriq_n_s32((a), (b), (n))
219 #else
220 #define simde_vsriq_n_s32(a, b, n) \
221 simde_vreinterpretq_s32_u32(simde_vsriq_n_u32( \
222 simde_vreinterpretq_u32_s32((a)), simde_vreinterpretq_u32_s32((b)), (n)))
223 #endif
224 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
225 #undef vsriq_n_s32
226 #define vsriq_n_s32(a, b, n) simde_vsriq_n_s32((a), (b), (n))
227 #endif
228
229 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
230 #define simde_vsriq_n_u32(a, b, n) vsriq_n_u32((a), (b), (n))
231 #else
232 #define simde_vsriq_n_u32(a, b, n) \
233 simde_vorrq_u32( \
234 simde_vandq_u32((a), \
235 simde_vdupq_n_u32((UINT32_C(0xffffffff) >> (32 - n) << (32 - n)))), \
236 simde_vshrq_n_u32((b), (n)))
237 #endif
238 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
239 #undef vsriq_n_u32
240 #define vsriq_n_u32(a, b, n) simde_vsriq_n_u32((a), (b), (n))
241 #endif
242
243 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
244 #define simde_vsriq_n_s64(a, b, n) vsriq_n_s64((a), (b), (n))
245 #else
246 #define simde_vsriq_n_s64(a, b, n) \
247 simde_vreinterpretq_s64_u64(simde_vsriq_n_u64( \
248 simde_vreinterpretq_u64_s64((a)), simde_vreinterpretq_u64_s64((b)), (n)))
249 #endif
250 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
251 #undef vsriq_n_s64
252 #define vsriq_n_s64(a, b, n) simde_vsriq_n_s64((a), (b), (n))
253 #endif
254
255 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
256 #define simde_vsriq_n_u64(a, b, n) vsriq_n_u64((a), (b), (n))
257 #else
258 #define simde_vsriq_n_u64(a, b, n) \
259 simde_vorrq_u64( \
260 simde_vandq_u64((a), simde_vdupq_n_u64( \
261 (UINT64_C(0xffffffffffffffff) >> (64 - n) << (64 - n)))), \
262 simde_vshrq_n_u64((b), (n)))
263 #endif
264 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
265 #undef vsriq_n_u64
266 #define vsriq_n_u64(a, b, n) simde_vsriq_n_u64((a), (b), (n))
267 #endif
268
269 SIMDE_END_DECLS_
270 HEDLEY_DIAGNOSTIC_POP
271
272 #endif /* !defined(SIMDE_ARM_NEON_SRI_N_H) */