Debian Codegraph @

third-party/simde/arm/neon/set_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_SET_LANE_H)
29 #define SIMDE_ARM_NEON_SET_LANE_H
30 #include "types.h"
31
32 HEDLEY_DIAGNOSTIC_PUSH
33 SIMDE_DISABLE_UNWANTED_DIAGNOSTICS
34 SIMDE_BEGIN_DECLS_
35
36 SIMDE_FUNCTION_ATTRIBUTES
37 simde_float32x2_t
38 simde_vset_lane_f32(simde_float32_t a, simde_float32x2_t v, const int lane)
39 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 1) {
40 simde_float32x2_t r;
41 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
42 SIMDE_CONSTIFY_2_(vset_lane_f32, r, (HEDLEY_UNREACHABLE(), v), lane, a, v);
43 #else
44 simde_float32x2_private v_ = simde_float32x2_to_private(v);
45 v_.values[lane] = a;
46 r = simde_float32x2_from_private(v_);
47 #endif
48 return r;
49 }
50 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
51 #undef vset_lane_f32
52 #define vset_lane_f32(a, b, c) simde_vset_lane_f32((a), (b), (c))
53 #endif
54
55 SIMDE_FUNCTION_ATTRIBUTES
56 simde_float64x1_t
57 simde_vset_lane_f64(simde_float64_t a, simde_float64x1_t v, const int lane)
58 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 0) {
59 simde_float64x1_t r;
60 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
61 (void) lane;
62 r = vset_lane_f64(a, v, 0);
63 #else
64 simde_float64x1_private v_ = simde_float64x1_to_private(v);
65 v_.values[lane] = a;
66 r = simde_float64x1_from_private(v_);
67 #endif
68 return r;
69 }
70 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
71 #undef vset_lane_f64
72 #define vset_lane_f64(a, b, c) simde_vset_lane_f64((a), (b), (c))
73 #endif
74
75 SIMDE_FUNCTION_ATTRIBUTES
76 simde_int8x8_t
77 simde_vset_lane_s8(int8_t a, simde_int8x8_t v, const int lane)
78 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 7) {
79 simde_int8x8_t r;
80 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
81 SIMDE_CONSTIFY_8_(vset_lane_s8, r, (HEDLEY_UNREACHABLE(), v), lane, a, v);
82 #else
83 simde_int8x8_private v_ = simde_int8x8_to_private(v);
84 v_.values[lane] = a;
85 r = simde_int8x8_from_private(v_);
86 #endif
87 return r;
88 }
89 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
90 #undef vset_lane_s8
91 #define vset_lane_s8(a, b, c) simde_vset_lane_s8((a), (b), (c))
92 #endif
93
94 SIMDE_FUNCTION_ATTRIBUTES
95 simde_int16x4_t
96 simde_vset_lane_s16(int16_t a, simde_int16x4_t v, const int lane)
97 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 3) {
98 simde_int16x4_t r;
99 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
100 SIMDE_CONSTIFY_4_(vset_lane_s16, r, (HEDLEY_UNREACHABLE(), v), lane, a, v);
101 #else
102 simde_int16x4_private v_ = simde_int16x4_to_private(v);
103 v_.values[lane] = a;
104 r = simde_int16x4_from_private(v_);
105 #endif
106 return r;
107 }
108 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
109 #undef vset_lane_s16
110 #define vset_lane_s16(a, b, c) simde_vset_lane_s16((a), (b), (c))
111 #endif
112
113 SIMDE_FUNCTION_ATTRIBUTES
114 simde_int32x2_t
115 simde_vset_lane_s32(int32_t a, simde_int32x2_t v, const int lane)
116 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 1) {
117 simde_int32x2_t r;
118 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
119 SIMDE_CONSTIFY_2_(vset_lane_s32, r, (HEDLEY_UNREACHABLE(), v), lane, a, v);
120 #else
121 simde_int32x2_private v_ = simde_int32x2_to_private(v);
122 v_.values[lane] = a;
123 r = simde_int32x2_from_private(v_);
124 #endif
125 return r;
126 }
127 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
128 #undef vset_lane_s32
129 #define vset_lane_s32(a, b, c) simde_vset_lane_s32((a), (b), (c))
130 #endif
131
132 SIMDE_FUNCTION_ATTRIBUTES
133 simde_int64x1_t
134 simde_vset_lane_s64(int64_t a, simde_int64x1_t v, const int lane)
135 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 0) {
136 simde_int64x1_t r;
137 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
138 (void) lane;
139 r = vset_lane_s64(a, v, 0);
140 #else
141 simde_int64x1_private v_ = simde_int64x1_to_private(v);
142 v_.values[lane] = a;
143 r = simde_int64x1_from_private(v_);
144 #endif
145 return r;
146 }
147 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
148 #undef vset_lane_s64
149 #define vset_lane_s64(a, b, c) simde_vset_lane_s64((a), (b), (c))
150 #endif
151
152 SIMDE_FUNCTION_ATTRIBUTES
153 simde_uint8x8_t
154 simde_vset_lane_u8(uint8_t a, simde_uint8x8_t v, const int lane)
155 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 7) {
156 simde_uint8x8_t r;
157 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
158 SIMDE_CONSTIFY_8_(vset_lane_u8, r, (HEDLEY_UNREACHABLE(), v), lane, a, v);
159 #else
160 simde_uint8x8_private v_ = simde_uint8x8_to_private(v);
161 v_.values[lane] = a;
162 r = simde_uint8x8_from_private(v_);
163 #endif
164 return r;
165 }
166 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
167 #undef vset_lane_u8
168 #define vset_lane_u8(a, b, c) simde_vset_lane_u8((a), (b), (c))
169 #endif
170
171 SIMDE_FUNCTION_ATTRIBUTES
172 simde_uint16x4_t
173 simde_vset_lane_u16(uint16_t a, simde_uint16x4_t v, const int lane)
174 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 3) {
175 simde_uint16x4_t r;
176 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
177 SIMDE_CONSTIFY_4_(vset_lane_u16, r, (HEDLEY_UNREACHABLE(), v), lane, a, v);
178 #else
179 simde_uint16x4_private v_ = simde_uint16x4_to_private(v);
180 v_.values[lane] = a;
181 r = simde_uint16x4_from_private(v_);
182 #endif
183 return r;
184 }
185 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
186 #undef vset_lane_u16
187 #define vset_lane_u16(a, b, c) simde_vset_lane_u16((a), (b), (c))
188 #endif
189
190 SIMDE_FUNCTION_ATTRIBUTES
191 simde_uint32x2_t
192 simde_vset_lane_u32(uint32_t a, simde_uint32x2_t v, const int lane)
193 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 1) {
194 simde_uint32x2_t r;
195 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
196 SIMDE_CONSTIFY_2_(vset_lane_u32, r, (HEDLEY_UNREACHABLE(), v), lane, a, v);
197 #else
198 simde_uint32x2_private v_ = simde_uint32x2_to_private(v);
199 v_.values[lane] = a;
200 r = simde_uint32x2_from_private(v_);
201 #endif
202 return r;
203 }
204 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
205 #undef vset_lane_u32
206 #define vset_lane_u32(a, b, c) simde_vset_lane_u32((a), (b), (c))
207 #endif
208
209 SIMDE_FUNCTION_ATTRIBUTES
210 simde_uint64x1_t
211 simde_vset_lane_u64(uint64_t a, simde_uint64x1_t v, const int lane)
212 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 0) {
213 simde_uint64x1_t r;
214 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
215 (void) lane;
216 r = vset_lane_u64(a, v, 0);
217 #else
218 simde_uint64x1_private v_ = simde_uint64x1_to_private(v);
219 v_.values[lane] = a;
220 r = simde_uint64x1_from_private(v_);
221 #endif
222 return r;
223 }
224 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
225 #undef vset_lane_u64
226 #define vset_lane_u64(a, b, c) simde_vset_lane_u64((a), (b), (c))
227 #endif
228
229 SIMDE_FUNCTION_ATTRIBUTES
230 simde_float32x4_t
231 simde_vsetq_lane_f32(simde_float32_t a, simde_float32x4_t v, const int lane)
232 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 3) {
233 simde_float32x4_t r;
234 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
235 SIMDE_CONSTIFY_4_(vsetq_lane_f32, r, (HEDLEY_UNREACHABLE(), v), lane, a, v);
236 #else
237 simde_float32x4_private v_ = simde_float32x4_to_private(v);
238 v_.values[lane] = a;
239 r = simde_float32x4_from_private(v_);
240 #endif
241 return r;
242 }
243 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
244 #undef vsetq_lane_f32
245 #define vsetq_lane_f32(a, b, c) simde_vsetq_lane_f32((a), (b), (c))
246 #endif
247
248 SIMDE_FUNCTION_ATTRIBUTES
249 simde_float64x2_t
250 simde_vsetq_lane_f64(simde_float64_t a, simde_float64x2_t v, const int lane)
251 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 1) {
252 simde_float64x2_t r;
253 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
254 SIMDE_CONSTIFY_2_(vsetq_lane_f64, r, (HEDLEY_UNREACHABLE(), v), lane, a, v);
255 #else
256 simde_float64x2_private v_ = simde_float64x2_to_private(v);
257 v_.values[lane] = a;
258 r = simde_float64x2_from_private(v_);
259 #endif
260 return r;
261 }
262 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
263 #undef vsetq_lane_f64
264 #define vsetq_lane_f64(a, b, c) simde_vsetq_lane_f64((a), (b), (c))
265 #endif
266
267 SIMDE_FUNCTION_ATTRIBUTES
268 simde_int8x16_t
269 simde_vsetq_lane_s8(int8_t a, simde_int8x16_t v, const int lane)
270 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 15) {
271 simde_int8x16_t r;
272 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
273 SIMDE_CONSTIFY_16_(vsetq_lane_s8, r, (HEDLEY_UNREACHABLE(), v), lane, a, v);
274 #else
275 simde_int8x16_private v_ = simde_int8x16_to_private(v);
276 v_.values[lane] = a;
277 r = simde_int8x16_from_private(v_);
278 #endif
279 return r;
280 }
281 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
282 #undef vsetq_lane_s8
283 #define vsetq_lane_s8(a, b, c) simde_vsetq_lane_s8((a), (b), (c))
284 #endif
285
286 SIMDE_FUNCTION_ATTRIBUTES
287 simde_int16x8_t
288 simde_vsetq_lane_s16(int16_t a, simde_int16x8_t v, const int lane)
289 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 7) {
290 simde_int16x8_t r;
291 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
292 SIMDE_CONSTIFY_8_(vsetq_lane_s16, r, (HEDLEY_UNREACHABLE(), v), lane, a, v);
293 #else
294 simde_int16x8_private v_ = simde_int16x8_to_private(v);
295 v_.values[lane] = a;
296 r = simde_int16x8_from_private(v_);
297 #endif
298 return r;
299 }
300 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
301 #undef vsetq_lane_s16
302 #define vsetq_lane_s16(a, b, c) simde_vsetq_lane_s16((a), (b), (c))
303 #endif
304
305 SIMDE_FUNCTION_ATTRIBUTES
306 simde_int32x4_t
307 simde_vsetq_lane_s32(int32_t a, simde_int32x4_t v, const int lane)
308 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 3) {
309 simde_int32x4_t r;
310 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
311 SIMDE_CONSTIFY_4_(vsetq_lane_s32, r, (HEDLEY_UNREACHABLE(), v), lane, a, v);
312 #else
313 simde_int32x4_private v_ = simde_int32x4_to_private(v);
314 v_.values[lane] = a;
315 r = simde_int32x4_from_private(v_);
316 #endif
317 return r;
318 }
319 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
320 #undef vsetq_lane_s32
321 #define vsetq_lane_s32(a, b, c) simde_vsetq_lane_s32((a), (b), (c))
322 #endif
323
324 SIMDE_FUNCTION_ATTRIBUTES
325 simde_int64x2_t
326 simde_vsetq_lane_s64(int64_t a, simde_int64x2_t v, const int lane)
327 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 1) {
328 simde_int64x2_t r;
329 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
330 SIMDE_CONSTIFY_2_(vsetq_lane_s64, r, (HEDLEY_UNREACHABLE(), v), lane, a, v);
331 #else
332 simde_int64x2_private v_ = simde_int64x2_to_private(v);
333 v_.values[lane] = a;
334 r = simde_int64x2_from_private(v_);
335 #endif
336 return r;
337 }
338 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
339 #undef vsetq_lane_s64
340 #define vsetq_lane_s64(a, b, c) simde_vsetq_lane_s64((a), (b), (c))
341 #endif
342
343 SIMDE_FUNCTION_ATTRIBUTES
344 simde_uint8x16_t
345 simde_vsetq_lane_u8(uint8_t a, simde_uint8x16_t v, const int lane)
346 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 15) {
347 simde_uint8x16_t r;
348 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
349 SIMDE_CONSTIFY_16_(vsetq_lane_u8, r, (HEDLEY_UNREACHABLE(), v), lane, a, v);
350 #else
351 simde_uint8x16_private v_ = simde_uint8x16_to_private(v);
352 v_.values[lane] = a;
353 r = simde_uint8x16_from_private(v_);
354 #endif
355 return r;
356 }
357 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
358 #undef vsetq_lane_u8
359 #define vsetq_lane_u8(a, b, c) simde_vsetq_lane_u8((a), (b), (c))
360 #endif
361
362 SIMDE_FUNCTION_ATTRIBUTES
363 simde_uint16x8_t
364 simde_vsetq_lane_u16(uint16_t a, simde_uint16x8_t v, const int lane)
365 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 7) {
366 simde_uint16x8_t r;
367 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
368 SIMDE_CONSTIFY_8_(vsetq_lane_u16, r, (HEDLEY_UNREACHABLE(), v), lane, a, v);
369 #else
370 simde_uint16x8_private v_ = simde_uint16x8_to_private(v);
371 v_.values[lane] = a;
372 r = simde_uint16x8_from_private(v_);
373 #endif
374 return r;
375 }
376 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
377 #undef vsetq_lane_u16
378 #define vsetq_lane_u16(a, b, c) simde_vsetq_lane_u16((a), (b), (c))
379 #endif
380
381 SIMDE_FUNCTION_ATTRIBUTES
382 simde_uint32x4_t
383 simde_vsetq_lane_u32(uint32_t a, simde_uint32x4_t v, const int lane)
384 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 3) {
385 simde_uint32x4_t r;
386 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
387 SIMDE_CONSTIFY_4_(vsetq_lane_u32, r, (HEDLEY_UNREACHABLE(), v), lane, a, v);
388 #else
389 simde_uint32x4_private v_ = simde_uint32x4_to_private(v);
390 v_.values[lane] = a;
391 r = simde_uint32x4_from_private(v_);
392 #endif
393 return r;
394 }
395 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
396 #undef vsetq_lane_u32
397 #define vsetq_lane_u32(a, b, c) simde_vsetq_lane_u32((a), (b), (c))
398 #endif
399
400 SIMDE_FUNCTION_ATTRIBUTES
401 simde_uint64x2_t
402 simde_vsetq_lane_u64(uint64_t a, simde_uint64x2_t v, const int lane)
403 SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 1) {
404 simde_uint64x2_t r;
405 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
406 SIMDE_CONSTIFY_2_(vsetq_lane_u64, r, (HEDLEY_UNREACHABLE(), v), lane, a, v);
407 #else
408 simde_uint64x2_private v_ = simde_uint64x2_to_private(v);
409 v_.values[lane] = a;
410 r = simde_uint64x2_from_private(v_);
411 #endif
412 return r;
413 }
414 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
415 #undef vsetq_lane_u64
416 #define vsetq_lane_u64(a, b, c) simde_vsetq_lane_u64((a), (b), (c))
417 #endif
418
419 SIMDE_END_DECLS_
420 HEDLEY_DIAGNOSTIC_POP
421
422 #endif /* !defined(SIMDE_ARM_NEON_SET_LANE_H) */