Debian Codegraph @

third-party/simde/arm/neon/shll_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 * 2020 Evan Nemerson <[email protected]>
25 * 2020 Christopher Moore <[email protected]>
26 */
27
28 #if !defined(SIMDE_ARM_NEON_SHLL_N_H)
29 #define SIMDE_ARM_NEON_SHLL_N_H
30
31 #include "types.h"
32
33 /*
34 * The constant range requirements for the shift amount *n* looks strange.
35 * The ARM Neon Intrinsics Reference states that for *_s8, 0 << n << 7. This
36 * does not match the actual instruction decoding in the ARM Reference manual,
37 * which states that the shift amount "must be equal to the source element width
38 * in bits" (ARM DDI 0487F.b C7-1959). So for *_s8 instructions, *n* must be 8,
39 * for *_s16, it must be 16, and *_s32 must be 32 (similarly for unsigned).
40 */
41
42 HEDLEY_DIAGNOSTIC_PUSH
43 SIMDE_DISABLE_UNWANTED_DIAGNOSTICS
44 SIMDE_BEGIN_DECLS_
45
46 SIMDE_FUNCTION_ATTRIBUTES
47 simde_int16x8_t
48 simde_vshll_n_s8 (const simde_int8x8_t a, const int n)
49 SIMDE_REQUIRE_CONSTANT_RANGE(n, 1, 7) {
50 simde_int16x8_private r_;
51 simde_int8x8_private a_ = simde_int8x8_to_private(a);
52
53 SIMDE_VECTORIZE
54 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
55 r_.values[i] = HEDLEY_STATIC_CAST(int16_t, HEDLEY_STATIC_CAST(int16_t, a_.values[i]) << n);
56 }
57
58 return simde_int16x8_from_private(r_);
59 }
60 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
61 #define simde_vshll_n_s8(a, n) vshll_n_s8((a), (n))
62 #endif
63 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
64 #undef vshll_n_s8
65 #define vshll_n_s8(a, n) simde_vshll_n_s8((a), (n))
66 #endif
67
68 SIMDE_FUNCTION_ATTRIBUTES
69 simde_int32x4_t
70 simde_vshll_n_s16 (const simde_int16x4_t a, const int n)
71 SIMDE_REQUIRE_CONSTANT_RANGE(n, 1, 15) {
72 simde_int32x4_private r_;
73 simde_int16x4_private a_ = simde_int16x4_to_private(a);
74
75 SIMDE_VECTORIZE
76 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
77 r_.values[i] = HEDLEY_STATIC_CAST(int32_t, a_.values[i]) << n;
78 }
79
80 return simde_int32x4_from_private(r_);
81 }
82 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
83 #define simde_vshll_n_s16(a, n) vshll_n_s16((a), (n))
84 #endif
85 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
86 #undef vshll_n_s16
87 #define vshll_n_s16(a, n) simde_vshll_n_s16((a), (n))
88 #endif
89
90 SIMDE_FUNCTION_ATTRIBUTES
91 simde_int64x2_t
92 simde_vshll_n_s32 (const simde_int32x2_t a, const int n)
93 SIMDE_REQUIRE_CONSTANT_RANGE(n, 1, 31) {
94 simde_int64x2_private r_;
95 simde_int32x2_private a_ = simde_int32x2_to_private(a);
96
97 SIMDE_VECTORIZE
98 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
99 r_.values[i] = HEDLEY_STATIC_CAST(int64_t, a_.values[i]) << n;
100 }
101
102 return simde_int64x2_from_private(r_);
103 }
104 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
105 #define simde_vshll_n_s32(a, n) vshll_n_s32((a), (n))
106 #endif
107 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
108 #undef vshll_n_s32
109 #define vshll_n_s32(a, n) simde_vshll_n_s32((a), (n))
110 #endif
111
112 SIMDE_FUNCTION_ATTRIBUTES
113 simde_uint16x8_t
114 simde_vshll_n_u8 (const simde_uint8x8_t a, const int n)
115 SIMDE_REQUIRE_CONSTANT_RANGE(n, 1, 7) {
116 simde_uint16x8_private r_;
117 simde_uint8x8_private a_ = simde_uint8x8_to_private(a);
118
119 SIMDE_VECTORIZE
120 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
121 r_.values[i] = HEDLEY_STATIC_CAST(uint16_t, HEDLEY_STATIC_CAST(uint16_t, a_.values[i]) << n);
122 }
123
124 return simde_uint16x8_from_private(r_);
125 }
126 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
127 #define simde_vshll_n_u8(a, n) vshll_n_u8((a), (n))
128 #endif
129 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
130 #undef vshll_n_u8
131 #define vshll_n_u8(a, n) simde_vshll_n_u8((a), (n))
132 #endif
133
134 SIMDE_FUNCTION_ATTRIBUTES
135 simde_uint32x4_t
136 simde_vshll_n_u16 (const simde_uint16x4_t a, const int n)
137 SIMDE_REQUIRE_CONSTANT_RANGE(n, 1, 15) {
138 simde_uint32x4_private r_;
139 simde_uint16x4_private a_ = simde_uint16x4_to_private(a);
140
141 SIMDE_VECTORIZE
142 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
143 r_.values[i] = HEDLEY_STATIC_CAST(uint32_t, a_.values[i]) << n;
144 }
145
146 return simde_uint32x4_from_private(r_);
147 }
148 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
149 #define simde_vshll_n_u16(a, n) vshll_n_u16((a), (n))
150 #endif
151 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
152 #undef vshll_n_u16
153 #define vshll_n_u16(a, n) simde_vshll_n_u16((a), (n))
154 #endif
155
156 SIMDE_FUNCTION_ATTRIBUTES
157 simde_uint64x2_t
158 simde_vshll_n_u32 (const simde_uint32x2_t a, const int n)
159 SIMDE_REQUIRE_CONSTANT_RANGE(n, 1, 31) {
160 simde_uint64x2_private r_;
161 simde_uint32x2_private a_ = simde_uint32x2_to_private(a);
162
163 SIMDE_VECTORIZE
164 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
165 r_.values[i] = HEDLEY_STATIC_CAST(uint64_t, a_.values[i]) << n;
166 }
167
168 return simde_uint64x2_from_private(r_);
169 }
170 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
171 #define simde_vshll_n_u32(a, n) vshll_n_u32((a), (n))
172 #endif
173 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
174 #undef vshll_n_u32
175 #define vshll_n_u32(a, n) simde_vshll_n_u32((a), (n))
176 #endif
177
178 SIMDE_END_DECLS_
179 HEDLEY_DIAGNOSTIC_POP
180
181 #endif /* !defined(SIMDE_ARM_NEON_SHLL_N_H) */