Debian Codegraph @

third-party/simde/arm/neon/get_lane.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 Sean Maher <[email protected]> (Copyright owned by Google, LLC)
26 */
27
28 #if !defined(SIMDE_ARM_NEON_GET_LANE_H)
29 #define SIMDE_ARM_NEON_GET_LANE_H
30
31 #include "types.h"
32
33 HEDLEY_DIAGNOSTIC_PUSH
34 SIMDE_DISABLE_UNWANTED_DIAGNOSTICS
35 SIMDE_BEGIN_DECLS_
36
37 SIMDE_FUNCTION_ATTRIBUTES
38 simde_float32_t
39 simde_vget_lane_f32(simde_float32x2_t v, const int lane)
40 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 1) {
41 simde_float32_t r;
42
43 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
44 SIMDE_CONSTIFY_2_(vget_lane_f32, r, (HEDLEY_UNREACHABLE(), SIMDE_FLOAT32_C(0.0)), lane, v);
45 #else
46 simde_float32x2_private v_ = simde_float32x2_to_private(v);
47
48 r = v_.values[lane];
49 #endif
50
51 return r;
52 }
53 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
54 #undef vget_lane_f32
55 #define vget_lane_f32(v, lane) simde_vget_lane_f32((v), (lane))
56 #endif
57
58 SIMDE_FUNCTION_ATTRIBUTES
59 simde_float64_t
60 simde_vget_lane_f64(simde_float64x1_t v, const int lane)
61 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 0) {
62 simde_float64_t r;
63
64 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
65 (void) lane;
66 return vget_lane_f64(v, 0);
67 #else
68 simde_float64x1_private v_ = simde_float64x1_to_private(v);
69
70 r = v_.values[lane];
71 #endif
72
73 return r;
74 }
75 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
76 #undef vget_lane_f64
77 #define vget_lane_f64(v, lane) simde_vget_lane_f64((v), (lane))
78 #endif
79
80 SIMDE_FUNCTION_ATTRIBUTES
81 int8_t
82 simde_vget_lane_s8(simde_int8x8_t v, const int lane)
83 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 7) {
84 int8_t r;
85
86 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
87 SIMDE_CONSTIFY_8_(vget_lane_s8, r, (HEDLEY_UNREACHABLE(), INT8_C(0)), lane, v);
88 #else
89 simde_int8x8_private v_ = simde_int8x8_to_private(v);
90
91 r = v_.values[lane];
92 #endif
93
94 return r;
95 }
96 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
97 #undef vget_lane_s8
98 #define vget_lane_s8(v, lane) simde_vget_lane_s8((v), (lane))
99 #endif
100
101 SIMDE_FUNCTION_ATTRIBUTES
102 int16_t
103 simde_vget_lane_s16(simde_int16x4_t v, const int lane)
104 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 3) {
105 int16_t r;
106
107 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
108 SIMDE_CONSTIFY_4_(vget_lane_s16, r, (HEDLEY_UNREACHABLE(), INT16_C(0)), lane, v);
109 #else
110 simde_int16x4_private v_ = simde_int16x4_to_private(v);
111
112 r = v_.values[lane];
113 #endif
114
115 return r;
116 }
117 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
118 #undef vget_lane_s16
119 #define vget_lane_s16(v, lane) simde_vget_lane_s16((v), (lane))
120 #endif
121
122 SIMDE_FUNCTION_ATTRIBUTES
123 int32_t
124 simde_vget_lane_s32(simde_int32x2_t v, const int lane)
125 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 1) {
126 int32_t r;
127
128 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
129 SIMDE_CONSTIFY_2_(vget_lane_s32, r, (HEDLEY_UNREACHABLE(), INT32_C(0)), lane, v);
130 #else
131 simde_int32x2_private v_ = simde_int32x2_to_private(v);
132
133 r = v_.values[lane];
134 #endif
135
136 return r;
137 }
138 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
139 #undef vget_lane_s32
140 #define vget_lane_s32(v, lane) simde_vget_lane_s32((v), (lane))
141 #endif
142
143 SIMDE_FUNCTION_ATTRIBUTES
144 int64_t
145 simde_vget_lane_s64(simde_int64x1_t v, const int lane)
146 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 0) {
147 int64_t r;
148
149 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
150 (void) lane;
151 return vget_lane_s64(v, 0);
152 #else
153 simde_int64x1_private v_ = simde_int64x1_to_private(v);
154
155 r = v_.values[lane];
156 #endif
157
158 return r;
159 }
160 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
161 #undef vget_lane_s64
162 #define vget_lane_s64(v, lane) simde_vget_lane_s64((v), (lane))
163 #endif
164
165 SIMDE_FUNCTION_ATTRIBUTES
166 uint8_t
167 simde_vget_lane_u8(simde_uint8x8_t v, const int lane)
168 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 7) {
169 uint8_t r;
170
171 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
172 SIMDE_CONSTIFY_8_(vget_lane_u8, r, (HEDLEY_UNREACHABLE(), UINT8_C(0)), lane, v);
173 #else
174 simde_uint8x8_private v_ = simde_uint8x8_to_private(v);
175
176 r = v_.values[lane];
177 #endif
178
179 return r;
180 }
181 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
182 #undef vget_lane_u8
183 #define vget_lane_u8(v, lane) simde_vget_lane_u8((v), (lane))
184 #endif
185
186 SIMDE_FUNCTION_ATTRIBUTES
187 uint16_t
188 simde_vget_lane_u16(simde_uint16x4_t v, const int lane)
189 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 3) {
190 uint16_t r;
191
192 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
193 SIMDE_CONSTIFY_4_(vget_lane_u16, r, (HEDLEY_UNREACHABLE(), UINT16_C(0)), lane, v);
194 #else
195 simde_uint16x4_private v_ = simde_uint16x4_to_private(v);
196
197 r = v_.values[lane];
198 #endif
199
200 return r;
201 }
202 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
203 #undef vget_lane_u16
204 #define vget_lane_u16(v, lane) simde_vget_lane_u16((v), (lane))
205 #endif
206
207 SIMDE_FUNCTION_ATTRIBUTES
208 uint32_t
209 simde_vget_lane_u32(simde_uint32x2_t v, const int lane)
210 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 1) {
211 uint32_t r;
212
213 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
214 SIMDE_CONSTIFY_2_(vget_lane_u32, r, (HEDLEY_UNREACHABLE(), UINT32_C(0)), lane, v);
215 #else
216 simde_uint32x2_private v_ = simde_uint32x2_to_private(v);
217
218 r = v_.values[lane];
219 #endif
220
221 return r;
222 }
223 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
224 #undef vget_lane_u32
225 #define vget_lane_u32(v, lane) simde_vget_lane_u32((v), (lane))
226 #endif
227
228 SIMDE_FUNCTION_ATTRIBUTES
229 uint64_t
230 simde_vget_lane_u64(simde_uint64x1_t v, const int lane)
231 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 0) {
232 uint64_t r;
233
234 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
235 (void) lane;
236 return vget_lane_u64(v, 0);
237 #else
238 simde_uint64x1_private v_ = simde_uint64x1_to_private(v);
239
240 r = v_.values[lane];
241 #endif
242
243 return r;
244 }
245 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
246 #undef vget_lane_u64
247 #define vget_lane_u64(v, lane) simde_vget_lane_u64((v), (lane))
248 #endif
249
250 SIMDE_FUNCTION_ATTRIBUTES
251 simde_float32_t
252 simde_vgetq_lane_f32(simde_float32x4_t v, const int lane)
253 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 3) {
254 simde_float32_t r;
255
256 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
257 SIMDE_CONSTIFY_4_(vgetq_lane_f32, r, (HEDLEY_UNREACHABLE(), SIMDE_FLOAT32_C(0.0)), lane, v);
258 #else
259 simde_float32x4_private v_ = simde_float32x4_to_private(v);
260
261 #if defined(SIMDE_WASM_SIMD128_NATIVE)
262 SIMDE_CONSTIFY_4_(wasm_f32x4_extract_lane, r, (HEDLEY_UNREACHABLE(), SIMDE_FLOAT32_C(0.0)), lane, v_.v128);
263 #else
264 r = v_.values[lane];
265 #endif
266 #endif
267
268 return r;
269 }
270 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
271 #undef vgetq_lane_f32
272 #define vgetq_lane_f32(v, lane) simde_vgetq_lane_f32((v), (lane))
273 #endif
274
275 SIMDE_FUNCTION_ATTRIBUTES
276 simde_float64_t
277 simde_vgetq_lane_f64(simde_float64x2_t v, const int lane)
278 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 1) {
279 simde_float64_t r;
280
281 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
282 SIMDE_CONSTIFY_2_(vgetq_lane_f64, r, (HEDLEY_UNREACHABLE(), SIMDE_FLOAT64_C(0.0)), lane, v);
283 #else
284 simde_float64x2_private v_ = simde_float64x2_to_private(v);
285
286 #if defined(SIMDE_WASM_SIMD128_NATIVE)
287 SIMDE_CONSTIFY_2_(wasm_f64x2_extract_lane, r, (HEDLEY_UNREACHABLE(), SIMDE_FLOAT64_C(0.0)), lane, v_.v128);
288 #else
289 r = v_.values[lane];
290 #endif
291 #endif
292
293 return r;
294 }
295 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
296 #undef vgetq_lane_f64
297 #define vgetq_lane_f64(v, lane) simde_vgetq_lane_f64((v), (lane))
298 #endif
299
300 SIMDE_FUNCTION_ATTRIBUTES
301 int8_t
302 simde_vgetq_lane_s8(simde_int8x16_t v, const int lane)
303 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 15) {
304 int8_t r;
305
306 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
307 SIMDE_CONSTIFY_16_(vgetq_lane_s8, r, (HEDLEY_UNREACHABLE(), INT8_C(0)), lane, v);
308 #else
309 simde_int8x16_private v_ = simde_int8x16_to_private(v);
310
311 #if defined(SIMDE_WASM_SIMD128_NATIVE)
312 int r_;
313 SIMDE_CONSTIFY_16_(wasm_i8x16_extract_lane, r_, (HEDLEY_UNREACHABLE(), INT8_C(0)), lane, v_.v128);
314 r = HEDLEY_STATIC_CAST(int8_t, r_);
315 #else
316 r = v_.values[lane];
317 #endif
318 #endif
319
320 return r;
321 }
322 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
323 #undef vgetq_lane_s8
324 #define vgetq_lane_s8(v, lane) simde_vgetq_lane_s8((v), (lane))
325 #endif
326
327 SIMDE_FUNCTION_ATTRIBUTES
328 int16_t
329 simde_vgetq_lane_s16(simde_int16x8_t v, const int lane)
330 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 7) {
331 int16_t r;
332
333 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
334 SIMDE_CONSTIFY_8_(vgetq_lane_s16, r, (HEDLEY_UNREACHABLE(), INT16_C(0)), lane, v);
335 #else
336 simde_int16x8_private v_ = simde_int16x8_to_private(v);
337
338 #if defined(SIMDE_WASM_SIMD128_NATIVE)
339 int r_;
340 SIMDE_CONSTIFY_8_(wasm_i16x8_extract_lane, r_, (HEDLEY_UNREACHABLE(), INT16_C(0)), lane, v_.v128);
341 r = HEDLEY_STATIC_CAST(int16_t, r_);
342 #else
343 r = v_.values[lane];
344 #endif
345 #endif
346
347 return r;
348 }
349 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
350 #undef vgetq_lane_s16
351 #define vgetq_lane_s16(v, lane) simde_vgetq_lane_s16((v), (lane))
352 #endif
353
354 SIMDE_FUNCTION_ATTRIBUTES
355 int32_t
356 simde_vgetq_lane_s32(simde_int32x4_t v, const int lane)
357 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 3) {
358 int32_t r;
359
360 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
361 SIMDE_CONSTIFY_4_(vgetq_lane_s32, r, (HEDLEY_UNREACHABLE(), INT32_C(0)), lane, v);
362 #else
363 simde_int32x4_private v_ = simde_int32x4_to_private(v);
364
365 #if defined(SIMDE_WASM_SIMD128_NATIVE)
366 int r_;
367 SIMDE_CONSTIFY_4_(wasm_i32x4_extract_lane, r_, (HEDLEY_UNREACHABLE(), INT32_C(0)), lane, v_.v128);
368 r = HEDLEY_STATIC_CAST(int32_t, r_);
369 #else
370 r = v_.values[lane];
371 #endif
372 #endif
373
374 return r;
375 }
376 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
377 #undef vgetq_lane_s32
378 #define vgetq_lane_s32(v, lane) simde_vgetq_lane_s32((v), (lane))
379 #endif
380
381 SIMDE_FUNCTION_ATTRIBUTES
382 int64_t
383 simde_vgetq_lane_s64(simde_int64x2_t v, const int lane)
384 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 1) {
385 int64_t r;
386
387 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
388 SIMDE_CONSTIFY_2_(vgetq_lane_s64, r, (HEDLEY_UNREACHABLE(), INT64_C(0)), lane, v);
389 #else
390 simde_int64x2_private v_ = simde_int64x2_to_private(v);
391
392 #if defined(SIMDE_WASM_SIMD128_NATIVE)
393 int64_t r_;
394 SIMDE_CONSTIFY_2_(wasm_i64x2_extract_lane, r_, (HEDLEY_UNREACHABLE(), INT64_C(0)), lane, v_.v128);
395 r = HEDLEY_STATIC_CAST(int64_t, r_);
396 #else
397 r = v_.values[lane];
398 #endif
399 #endif
400
401 return r;
402 }
403 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
404 #undef vgetq_lane_s64
405 #define vgetq_lane_s64(v, lane) simde_vgetq_lane_s64((v), (lane))
406 #endif
407
408 SIMDE_FUNCTION_ATTRIBUTES
409 uint8_t
410 simde_vgetq_lane_u8(simde_uint8x16_t v, const int lane)
411 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 15) {
412 uint8_t r;
413
414 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
415 SIMDE_CONSTIFY_16_(vgetq_lane_u8, r, (HEDLEY_UNREACHABLE(), UINT8_C(0)), lane, v);
416 #else
417 simde_uint8x16_private v_ = simde_uint8x16_to_private(v);
418
419 #if defined(SIMDE_WASM_SIMD128_NATIVE)
420 int r_;
421 SIMDE_CONSTIFY_16_(wasm_i8x16_extract_lane, r_, (HEDLEY_UNREACHABLE(), UINT8_C(0)), lane, v_.v128);
422 r = HEDLEY_STATIC_CAST(uint8_t, r_);
423 #else
424 r = v_.values[lane];
425 #endif
426 #endif
427
428 return r;
429 }
430 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
431 #undef vgetq_lane_u8
432 #define vgetq_lane_u8(v, lane) simde_vgetq_lane_u8((v), (lane))
433 #endif
434
435 SIMDE_FUNCTION_ATTRIBUTES
436 uint16_t
437 simde_vgetq_lane_u16(simde_uint16x8_t v, const int lane)
438 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 7) {
439 uint16_t r;
440
441 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
442 SIMDE_CONSTIFY_8_(vgetq_lane_u16, r, (HEDLEY_UNREACHABLE(), UINT16_C(0)), lane, v);
443 #else
444 simde_uint16x8_private v_ = simde_uint16x8_to_private(v);
445
446 #if defined(SIMDE_WASM_SIMD128_NATIVE)
447 int r_;
448 SIMDE_CONSTIFY_8_(wasm_i16x8_extract_lane, r_, (HEDLEY_UNREACHABLE(), UINT16_C(0)), lane, v_.v128);
449 r = HEDLEY_STATIC_CAST(uint16_t, r_);
450 #else
451 r = v_.values[lane];
452 #endif
453 #endif
454
455 return r;
456 }
457 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
458 #undef vgetq_lane_u16
459 #define vgetq_lane_u16(v, lane) simde_vgetq_lane_u16((v), (lane))
460 #endif
461
462 SIMDE_FUNCTION_ATTRIBUTES
463 uint32_t
464 simde_vgetq_lane_u32(simde_uint32x4_t v, const int lane)
465 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 3) {
466 uint32_t r;
467
468 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
469 SIMDE_CONSTIFY_4_(vgetq_lane_u32, r, (HEDLEY_UNREACHABLE(), UINT32_C(0)), lane, v);
470 #else
471 simde_uint32x4_private v_ = simde_uint32x4_to_private(v);
472
473 #if defined(SIMDE_WASM_SIMD128_NATIVE)
474 int32_t r_;
475 SIMDE_CONSTIFY_4_(wasm_i32x4_extract_lane, r_, (HEDLEY_UNREACHABLE(), UINT32_C(0)), lane, v_.v128);
476 r = HEDLEY_STATIC_CAST(uint32_t, r_);
477 #else
478 r = v_.values[lane];
479 #endif
480 #endif
481
482 return r;
483 }
484 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
485 #undef vgetq_lane_u32
486 #define vgetq_lane_u32(v, lane) simde_vgetq_lane_u32((v), (lane))
487 #endif
488
489 SIMDE_FUNCTION_ATTRIBUTES
490 uint64_t
491 simde_vgetq_lane_u64(simde_uint64x2_t v, const int lane)
492 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 1) {
493 uint64_t r;
494
495 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
496 SIMDE_CONSTIFY_2_(vgetq_lane_u64, r, (HEDLEY_UNREACHABLE(), UINT64_C(0)), lane, v);
497 #else
498 simde_uint64x2_private v_ = simde_uint64x2_to_private(v);
499
500 #if defined(SIMDE_WASM_SIMD128_NATIVE)
501 int64_t r_;
502 SIMDE_CONSTIFY_2_(wasm_i64x2_extract_lane, r_, (HEDLEY_UNREACHABLE(), UINT64_C(0)), lane, v_.v128);
503 r = HEDLEY_STATIC_CAST(uint64_t, r_);
504 #else
505 r = v_.values[lane];
506 #endif
507 #endif
508
509 return r;
510 }
511 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
512 #undef vgetq_lane_u64
513 #define vgetq_lane_u64(v, lane) simde_vgetq_lane_u64((v), (lane))
514 #endif
515
516 SIMDE_END_DECLS_
517 HEDLEY_DIAGNOSTIC_POP
518
519 #endif /* !defined(SIMDE_ARM_NEON_GET_LANE_H) */