Debian Codegraph @

third-party/simde/arm/neon/ld1.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 * 2021 Zhi An Ng <[email protected]> (Copyright owned by Google, LLC)
26 */
27
28 #if !defined(SIMDE_ARM_NEON_LD1_H)
29 #define SIMDE_ARM_NEON_LD1_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_float16x4_t
39 simde_vld1_f16(simde_float16 const ptr[HEDLEY_ARRAY_PARAM(4)]) {
40 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE) && defined(SIMDE_ARM_NEON_FP16)
41 return vld1_f16(ptr);
42 #else
43 simde_float16x4_private r_;
44 simde_memcpy(&r_, ptr, sizeof(r_));
45 return simde_float16x4_from_private(r_);
46 #endif
47 }
48 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
49 #undef vld1_f16
50 #define vld1_f16(a) simde_vld1_f16((a))
51 #endif
52
53 SIMDE_FUNCTION_ATTRIBUTES
54 simde_float32x2_t
55 simde_vld1_f32(simde_float32 const ptr[HEDLEY_ARRAY_PARAM(2)]) {
56 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
57 return vld1_f32(ptr);
58 #else
59 simde_float32x2_private r_;
60 simde_memcpy(&r_, ptr, sizeof(r_));
61 return simde_float32x2_from_private(r_);
62 #endif
63 }
64 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
65 #undef vld1_f32
66 #define vld1_f32(a) simde_vld1_f32((a))
67 #endif
68
69 SIMDE_FUNCTION_ATTRIBUTES
70 simde_float64x1_t
71 simde_vld1_f64(simde_float64 const ptr[HEDLEY_ARRAY_PARAM(1)]) {
72 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
73 return vld1_f64(ptr);
74 #else
75 simde_float64x1_private r_;
76 simde_memcpy(&r_, ptr, sizeof(r_));
77 return simde_float64x1_from_private(r_);
78 #endif
79 }
80 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
81 #undef vld1_f64
82 #define vld1_f64(a) simde_vld1_f64((a))
83 #endif
84
85 SIMDE_FUNCTION_ATTRIBUTES
86 simde_int8x8_t
87 simde_vld1_s8(int8_t const ptr[HEDLEY_ARRAY_PARAM(8)]) {
88 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
89 return vld1_s8(ptr);
90 #else
91 simde_int8x8_private r_;
92 simde_memcpy(&r_, ptr, sizeof(r_));
93 return simde_int8x8_from_private(r_);
94 #endif
95 }
96 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
97 #undef vld1_s8
98 #define vld1_s8(a) simde_vld1_s8((a))
99 #endif
100
101 SIMDE_FUNCTION_ATTRIBUTES
102 simde_int16x4_t
103 simde_vld1_s16(int16_t const ptr[HEDLEY_ARRAY_PARAM(4)]) {
104 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
105 return vld1_s16(ptr);
106 #else
107 simde_int16x4_private r_;
108 simde_memcpy(&r_, ptr, sizeof(r_));
109 return simde_int16x4_from_private(r_);
110 #endif
111 }
112 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
113 #undef vld1_s16
114 #define vld1_s16(a) simde_vld1_s16((a))
115 #endif
116
117 SIMDE_FUNCTION_ATTRIBUTES
118 simde_int32x2_t
119 simde_vld1_s32(int32_t const ptr[HEDLEY_ARRAY_PARAM(2)]) {
120 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
121 return vld1_s32(ptr);
122 #else
123 simde_int32x2_private r_;
124 simde_memcpy(&r_, ptr, sizeof(r_));
125 return simde_int32x2_from_private(r_);
126 #endif
127 }
128 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
129 #undef vld1_s32
130 #define vld1_s32(a) simde_vld1_s32((a))
131 #endif
132
133 SIMDE_FUNCTION_ATTRIBUTES
134 simde_int64x1_t
135 simde_vld1_s64(int64_t const ptr[HEDLEY_ARRAY_PARAM(1)]) {
136 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
137 return vld1_s64(ptr);
138 #else
139 simde_int64x1_private r_;
140 simde_memcpy(&r_, ptr, sizeof(r_));
141 return simde_int64x1_from_private(r_);
142 #endif
143 }
144 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
145 #undef vld1_s64
146 #define vld1_s64(a) simde_vld1_s64((a))
147 #endif
148
149 SIMDE_FUNCTION_ATTRIBUTES
150 simde_uint8x8_t
151 simde_vld1_u8(uint8_t const ptr[HEDLEY_ARRAY_PARAM(8)]) {
152 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
153 return vld1_u8(ptr);
154 #else
155 simde_uint8x8_private r_;
156 simde_memcpy(&r_, ptr, sizeof(r_));
157 return simde_uint8x8_from_private(r_);
158 #endif
159 }
160 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
161 #undef vld1_u8
162 #define vld1_u8(a) simde_vld1_u8((a))
163 #endif
164
165 SIMDE_FUNCTION_ATTRIBUTES
166 simde_uint16x4_t
167 simde_vld1_u16(uint16_t const ptr[HEDLEY_ARRAY_PARAM(4)]) {
168 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
169 return vld1_u16(ptr);
170 #else
171 simde_uint16x4_private r_;
172 simde_memcpy(&r_, ptr, sizeof(r_));
173 return simde_uint16x4_from_private(r_);
174 #endif
175 }
176 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
177 #undef vld1_u16
178 #define vld1_u16(a) simde_vld1_u16((a))
179 #endif
180
181 SIMDE_FUNCTION_ATTRIBUTES
182 simde_uint32x2_t
183 simde_vld1_u32(uint32_t const ptr[HEDLEY_ARRAY_PARAM(2)]) {
184 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
185 return vld1_u32(ptr);
186 #else
187 simde_uint32x2_private r_;
188 simde_memcpy(&r_, ptr, sizeof(r_));
189 return simde_uint32x2_from_private(r_);
190 #endif
191 }
192 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
193 #undef vld1_u32
194 #define vld1_u32(a) simde_vld1_u32((a))
195 #endif
196
197 SIMDE_FUNCTION_ATTRIBUTES
198 simde_uint64x1_t
199 simde_vld1_u64(uint64_t const ptr[HEDLEY_ARRAY_PARAM(1)]) {
200 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
201 return vld1_u64(ptr);
202 #else
203 simde_uint64x1_private r_;
204 simde_memcpy(&r_, ptr, sizeof(r_));
205 return simde_uint64x1_from_private(r_);
206 #endif
207 }
208 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
209 #undef vld1_u64
210 #define vld1_u64(a) simde_vld1_u64((a))
211 #endif
212
213 SIMDE_FUNCTION_ATTRIBUTES
214 simde_float16x8_t
215 simde_vld1q_f16(simde_float16 const ptr[HEDLEY_ARRAY_PARAM(8)]) {
216 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE) && defined(SIMDE_ARM_NEON_FP16)
217 return vld1q_f16(ptr);
218 #else
219 simde_float16x8_private r_;
220 #if defined(SIMDE_WASM_SIMD128_NATIVE)
221 r_.v128 = wasm_v128_load(ptr);
222 #else
223 simde_memcpy(&r_, ptr, sizeof(r_));
224 #endif
225 return simde_float16x8_from_private(r_);
226 #endif
227 }
228 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
229 #undef vld1q_f16
230 #define vld1q_f16(a) simde_vld1q_f16((a))
231 #endif
232
233 SIMDE_FUNCTION_ATTRIBUTES
234 simde_float32x4_t
235 simde_vld1q_f32(simde_float32 const ptr[HEDLEY_ARRAY_PARAM(4)]) {
236 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
237 return vld1q_f32(ptr);
238 #else
239 simde_float32x4_private r_;
240 #if defined(SIMDE_WASM_SIMD128_NATIVE)
241 r_.v128 = wasm_v128_load(ptr);
242 #else
243 simde_memcpy(&r_, ptr, sizeof(r_));
244 #endif
245 return simde_float32x4_from_private(r_);
246 #endif
247 }
248 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
249 #undef vld1q_f32
250 #define vld1q_f32(a) simde_vld1q_f32((a))
251 #endif
252
253 SIMDE_FUNCTION_ATTRIBUTES
254 simde_float64x2_t
255 simde_vld1q_f64(simde_float64 const ptr[HEDLEY_ARRAY_PARAM(2)]) {
256 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
257 return vld1q_f64(ptr);
258 #else
259 simde_float64x2_private r_;
260 #if defined(SIMDE_WASM_SIMD128_NATIVE)
261 r_.v128 = wasm_v128_load(ptr);
262 #else
263 simde_memcpy(&r_, ptr, sizeof(r_));
264 #endif
265 return simde_float64x2_from_private(r_);
266 #endif
267 }
268 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
269 #undef vld1q_f64
270 #define vld1q_f64(a) simde_vld1q_f64((a))
271 #endif
272
273 SIMDE_FUNCTION_ATTRIBUTES
274 simde_int8x16_t
275 simde_vld1q_s8(int8_t const ptr[HEDLEY_ARRAY_PARAM(16)]) {
276 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
277 return vld1q_s8(ptr);
278 #else
279 simde_int8x16_private r_;
280 #if defined(SIMDE_WASM_SIMD128_NATIVE)
281 r_.v128 = wasm_v128_load(ptr);
282 #else
283 simde_memcpy(&r_, ptr, sizeof(r_));
284 #endif
285 return simde_int8x16_from_private(r_);
286 #endif
287 }
288 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
289 #undef vld1q_s8
290 #define vld1q_s8(a) simde_vld1q_s8((a))
291 #endif
292
293 SIMDE_FUNCTION_ATTRIBUTES
294 simde_int16x8_t
295 simde_vld1q_s16(int16_t const ptr[HEDLEY_ARRAY_PARAM(8)]) {
296 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
297 return vld1q_s16(ptr);
298 #else
299 simde_int16x8_private r_;
300 #if defined(SIMDE_WASM_SIMD128_NATIVE)
301 r_.v128 = wasm_v128_load(ptr);
302 #else
303 simde_memcpy(&r_, ptr, sizeof(r_));
304 #endif
305 return simde_int16x8_from_private(r_);
306 #endif
307 }
308 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
309 #undef vld1q_s16
310 #define vld1q_s16(a) simde_vld1q_s16((a))
311 #endif
312
313 SIMDE_FUNCTION_ATTRIBUTES
314 simde_int32x4_t
315 simde_vld1q_s32(int32_t const ptr[HEDLEY_ARRAY_PARAM(4)]) {
316 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
317 return vld1q_s32(ptr);
318 #else
319 simde_int32x4_private r_;
320 #if defined(SIMDE_WASM_SIMD128_NATIVE)
321 r_.v128 = wasm_v128_load(ptr);
322 #else
323 simde_memcpy(&r_, ptr, sizeof(r_));
324 #endif
325 return simde_int32x4_from_private(r_);
326 #endif
327 }
328 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
329 #undef vld1q_s32
330 #define vld1q_s32(a) simde_vld1q_s32((a))
331 #endif
332
333 SIMDE_FUNCTION_ATTRIBUTES
334 simde_int64x2_t
335 simde_vld1q_s64(int64_t const ptr[HEDLEY_ARRAY_PARAM(2)]) {
336 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
337 return vld1q_s64(ptr);
338 #else
339 simde_int64x2_private r_;
340 #if defined(SIMDE_WASM_SIMD128_NATIVE)
341 r_.v128 = wasm_v128_load(ptr);
342 #else
343 simde_memcpy(&r_, ptr, sizeof(r_));
344 #endif
345 return simde_int64x2_from_private(r_);
346 #endif
347 }
348 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
349 #undef vld1q_s64
350 #define vld1q_s64(a) simde_vld1q_s64((a))
351 #endif
352
353 SIMDE_FUNCTION_ATTRIBUTES
354 simde_uint8x16_t
355 simde_vld1q_u8(uint8_t const ptr[HEDLEY_ARRAY_PARAM(16)]) {
356 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
357 return vld1q_u8(ptr);
358 #else
359 simde_uint8x16_private r_;
360 #if defined(SIMDE_WASM_SIMD128_NATIVE)
361 r_.v128 = wasm_v128_load(ptr);
362 #else
363 simde_memcpy(&r_, ptr, sizeof(r_));
364 #endif
365 return simde_uint8x16_from_private(r_);
366 #endif
367 }
368 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
369 #undef vld1q_u8
370 #define vld1q_u8(a) simde_vld1q_u8((a))
371 #endif
372
373 #if !defined(SIMDE_BUG_INTEL_857088)
374
375 SIMDE_FUNCTION_ATTRIBUTES
376 simde_uint8x16x2_t
377 simde_vld1q_u8_x2(uint8_t const ptr[HEDLEY_ARRAY_PARAM(32)]) {
378 #if \
379 defined(SIMDE_ARM_NEON_A32V7_NATIVE) && \
380 (!defined(HEDLEY_GCC_VERSION) || (HEDLEY_GCC_VERSION_CHECK(8,0,0) && defined(SIMDE_ARM_NEON_A64V8_NATIVE))) && \
381 (!defined(__clang__) || SIMDE_DETECT_CLANG_VERSION_CHECK(7,0,0))
382 return vld1q_u8_x2(ptr);
383 #else
384 simde_uint8x16_private a_[2];
385 for (size_t i = 0; i < 32; i++) {
386 a_[i / 16].values[i % 16] = ptr[i];
387 }
388 simde_uint8x16x2_t s_ = { { simde_uint8x16_from_private(a_[0]),
389 simde_uint8x16_from_private(a_[1]) } };
390 return s_;
391 #endif
392 }
393 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
394 #undef vld1q_u8_x2
395 #define vld1q_u8_x2(a) simde_vld1q_u8_x2((a))
396 #endif
397
398 SIMDE_FUNCTION_ATTRIBUTES
399 simde_uint8x16x3_t
400 simde_vld1q_u8_x3(uint8_t const ptr[HEDLEY_ARRAY_PARAM(48)]) {
401 #if \
402 defined(SIMDE_ARM_NEON_A32V7_NATIVE) && \
403 (!defined(HEDLEY_GCC_VERSION) || (HEDLEY_GCC_VERSION_CHECK(8,0,0) && defined(SIMDE_ARM_NEON_A64V8_NATIVE))) && \
404 (!defined(__clang__) || SIMDE_DETECT_CLANG_VERSION_CHECK(7,0,0))
405 return vld1q_u8_x3(ptr);
406 #else
407 simde_uint8x16_private a_[3];
408 for (size_t i = 0; i < 48; i++) {
409 a_[i / 16].values[i % 16] = ptr[i];
410 }
411 simde_uint8x16x3_t s_ = { { simde_uint8x16_from_private(a_[0]),
412 simde_uint8x16_from_private(a_[1]),
413 simde_uint8x16_from_private(a_[2]) } };
414 return s_;
415 #endif
416 }
417 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
418 #undef vld1q_u8_x3
419 #define vld1q_u8_x3(a) simde_vld1q_u8_x3((a))
420 #endif
421
422 SIMDE_FUNCTION_ATTRIBUTES
423 simde_uint8x16x4_t
424 simde_vld1q_u8_x4(uint8_t const ptr[HEDLEY_ARRAY_PARAM(64)]) {
425 #if \
426 defined(SIMDE_ARM_NEON_A32V7_NATIVE) && \
427 (!defined(HEDLEY_GCC_VERSION) || (HEDLEY_GCC_VERSION_CHECK(8,0,0) && defined(SIMDE_ARM_NEON_A64V8_NATIVE))) && \
428 (!defined(__clang__) || SIMDE_DETECT_CLANG_VERSION_CHECK(7,0,0))
429 return vld1q_u8_x4(ptr);
430 #else
431 simde_uint8x16_private a_[4];
432 for (size_t i = 0; i < 64; i++) {
433 a_[i / 16].values[i % 16] = ptr[i];
434 }
435 simde_uint8x16x4_t s_ = { { simde_uint8x16_from_private(a_[0]),
436 simde_uint8x16_from_private(a_[1]),
437 simde_uint8x16_from_private(a_[2]),
438 simde_uint8x16_from_private(a_[3]) } };
439 return s_;
440 #endif
441 }
442 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
443 #undef vld1q_u8_x4
444 #define vld1q_u8_x4(a) simde_vld1q_u8_x4((a))
445 #endif
446
447 #endif /* !defined(SIMDE_BUG_INTEL_857088) */
448
449 SIMDE_FUNCTION_ATTRIBUTES
450 simde_uint16x8_t
451 simde_vld1q_u16(uint16_t const ptr[HEDLEY_ARRAY_PARAM(8)]) {
452 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
453 return vld1q_u16(ptr);
454 #else
455 simde_uint16x8_private r_;
456 #if defined(SIMDE_WASM_SIMD128_NATIVE)
457 r_.v128 = wasm_v128_load(ptr);
458 #else
459 simde_memcpy(&r_, ptr, sizeof(r_));
460 #endif
461 return simde_uint16x8_from_private(r_);
462 #endif
463 }
464 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
465 #undef vld1q_u16
466 #define vld1q_u16(a) simde_vld1q_u16((a))
467 #endif
468
469 SIMDE_FUNCTION_ATTRIBUTES
470 simde_uint32x4_t
471 simde_vld1q_u32(uint32_t const ptr[HEDLEY_ARRAY_PARAM(4)]) {
472 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
473 return vld1q_u32(ptr);
474 #else
475 simde_uint32x4_private r_;
476 #if defined(SIMDE_WASM_SIMD128_NATIVE)
477 r_.v128 = wasm_v128_load(ptr);
478 #else
479 simde_memcpy(&r_, ptr, sizeof(r_));
480 #endif
481 return simde_uint32x4_from_private(r_);
482 #endif
483 }
484 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
485 #undef vld1q_u32
486 #define vld1q_u32(a) simde_vld1q_u32((a))
487 #endif
488
489 SIMDE_FUNCTION_ATTRIBUTES
490 simde_uint64x2_t
491 simde_vld1q_u64(uint64_t const ptr[HEDLEY_ARRAY_PARAM(2)]) {
492 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
493 return vld1q_u64(ptr);
494 #else
495 simde_uint64x2_private r_;
496 #if defined(SIMDE_WASM_SIMD128_NATIVE)
497 r_.v128 = wasm_v128_load(ptr);
498 #else
499 simde_memcpy(&r_, ptr, sizeof(r_));
500 #endif
501 return simde_uint64x2_from_private(r_);
502 #endif
503 }
504 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
505 #undef vld1q_u64
506 #define vld1q_u64(a) simde_vld1q_u64((a))
507 #endif
508
509 SIMDE_END_DECLS_
510 HEDLEY_DIAGNOSTIC_POP
511
512 #endif /* !defined(SIMDE_ARM_NEON_LD1_H) */