Debian Codegraph @

third-party/simde/arm/neon/mull.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_MULL_H)
29 #define SIMDE_ARM_NEON_MULL_H
30
31 #include "types.h"
32 #include "mul.h"
33 #include "movl.h"
34
35 HEDLEY_DIAGNOSTIC_PUSH
36 SIMDE_DISABLE_UNWANTED_DIAGNOSTICS
37 SIMDE_BEGIN_DECLS_
38
39 SIMDE_FUNCTION_ATTRIBUTES
40 simde_int16x8_t
41 simde_vmull_s8(simde_int8x8_t a, simde_int8x8_t b) {
42 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
43 return vmull_s8(a, b);
44 #elif SIMDE_NATURAL_VECTOR_SIZE_GE(128)
45 return simde_vmulq_s16(simde_vmovl_s8(a), simde_vmovl_s8(b));
46 #else
47 simde_int16x8_private r_;
48 simde_int8x8_private
49 a_ = simde_int8x8_to_private(a),
50 b_ = simde_int8x8_to_private(b);
51
52 #if defined(SIMDE_CONVERT_VECTOR_) && defined(SIMDE_VECTOR_SUBSCRIPT_OPS) && !defined(SIMDE_BUG_GCC_100761)
53 __typeof__(r_.values) av, bv;
54 SIMDE_CONVERT_VECTOR_(av, a_.values);
55 SIMDE_CONVERT_VECTOR_(bv, b_.values);
56 r_.values = av * bv;
57 #else
58 SIMDE_VECTORIZE
59 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
60 r_.values[i] = HEDLEY_STATIC_CAST(int16_t, a_.values[i]) * HEDLEY_STATIC_CAST(int16_t, b_.values[i]);
61 }
62 #endif
63
64 return simde_int16x8_from_private(r_);
65 #endif
66 }
67 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
68 #undef vmull_s8
69 #define vmull_s8(a, b) simde_vmull_s8((a), (b))
70 #endif
71
72 SIMDE_FUNCTION_ATTRIBUTES
73 simde_int32x4_t
74 simde_vmull_s16(simde_int16x4_t a, simde_int16x4_t b) {
75 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
76 return vmull_s16(a, b);
77 #elif SIMDE_NATURAL_VECTOR_SIZE_GE(128)
78 return simde_vmulq_s32(simde_vmovl_s16(a), simde_vmovl_s16(b));
79 #else
80 simde_int32x4_private r_;
81 simde_int16x4_private
82 a_ = simde_int16x4_to_private(a),
83 b_ = simde_int16x4_to_private(b);
84
85 #if defined(SIMDE_CONVERT_VECTOR_) && defined(SIMDE_VECTOR_SUBSCRIPT_OPS) && !defined(SIMDE_BUG_GCC_100761)
86 __typeof__(r_.values) av, bv;
87 SIMDE_CONVERT_VECTOR_(av, a_.values);
88 SIMDE_CONVERT_VECTOR_(bv, b_.values);
89 r_.values = av * bv;
90 #else
91 SIMDE_VECTORIZE
92 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
93 r_.values[i] = HEDLEY_STATIC_CAST(int32_t, a_.values[i]) * HEDLEY_STATIC_CAST(int32_t, b_.values[i]);
94 }
95 #endif
96
97 return simde_int32x4_from_private(r_);
98 #endif
99 }
100 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
101 #undef vmull_s16
102 #define vmull_s16(a, b) simde_vmull_s16((a), (b))
103 #endif
104
105 SIMDE_FUNCTION_ATTRIBUTES
106 simde_int64x2_t
107 simde_vmull_s32(simde_int32x2_t a, simde_int32x2_t b) {
108 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
109 return vmull_s32(a, b);
110 #else
111 simde_int64x2_private r_;
112 simde_int32x2_private
113 a_ = simde_int32x2_to_private(a),
114 b_ = simde_int32x2_to_private(b);
115
116 #if defined(SIMDE_CONVERT_VECTOR_) && defined(SIMDE_VECTOR_SUBSCRIPT_OPS)
117 __typeof__(r_.values) av, bv;
118 SIMDE_CONVERT_VECTOR_(av, a_.values);
119 SIMDE_CONVERT_VECTOR_(bv, b_.values);
120 r_.values = av * bv;
121 #else
122 SIMDE_VECTORIZE
123 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
124 r_.values[i] = HEDLEY_STATIC_CAST(int64_t, a_.values[i]) * HEDLEY_STATIC_CAST(int64_t, b_.values[i]);
125 }
126 #endif
127
128 return simde_int64x2_from_private(r_);
129 #endif
130 }
131 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
132 #undef vmull_s32
133 #define vmull_s32(a, b) simde_vmull_s32((a), (b))
134 #endif
135
136 SIMDE_FUNCTION_ATTRIBUTES
137 simde_uint16x8_t
138 simde_vmull_u8(simde_uint8x8_t a, simde_uint8x8_t b) {
139 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
140 return vmull_u8(a, b);
141 #elif SIMDE_NATURAL_VECTOR_SIZE_GE(128)
142 return simde_vmulq_u16(simde_vmovl_u8(a), simde_vmovl_u8(b));
143 #else
144 simde_uint16x8_private r_;
145 simde_uint8x8_private
146 a_ = simde_uint8x8_to_private(a),
147 b_ = simde_uint8x8_to_private(b);
148
149 #if defined(SIMDE_CONVERT_VECTOR_) && defined(SIMDE_VECTOR_SUBSCRIPT_OPS) && !defined(SIMDE_BUG_GCC_100761)
150 __typeof__(r_.values) av, bv;
151 SIMDE_CONVERT_VECTOR_(av, a_.values);
152 SIMDE_CONVERT_VECTOR_(bv, b_.values);
153 r_.values = av * bv;
154 #else
155 SIMDE_VECTORIZE
156 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
157 r_.values[i] = HEDLEY_STATIC_CAST(uint16_t, a_.values[i]) * HEDLEY_STATIC_CAST(uint16_t, b_.values[i]);
158 }
159 #endif
160
161 return simde_uint16x8_from_private(r_);
162 #endif
163 }
164 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
165 #undef vmull_u8
166 #define vmull_u8(a, b) simde_vmull_u8((a), (b))
167 #endif
168
169 SIMDE_FUNCTION_ATTRIBUTES
170 simde_uint32x4_t
171 simde_vmull_u16(simde_uint16x4_t a, simde_uint16x4_t b) {
172 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
173 return vmull_u16(a, b);
174 #elif SIMDE_NATURAL_VECTOR_SIZE_GE(128)
175 return simde_vmulq_u32(simde_vmovl_u16(a), simde_vmovl_u16(b));
176 #else
177 simde_uint32x4_private r_;
178 simde_uint16x4_private
179 a_ = simde_uint16x4_to_private(a),
180 b_ = simde_uint16x4_to_private(b);
181
182 #if defined(SIMDE_CONVERT_VECTOR_) && defined(SIMDE_VECTOR_SUBSCRIPT_OPS) && !defined(SIMDE_BUG_GCC_100761)
183 __typeof__(r_.values) av, bv;
184 SIMDE_CONVERT_VECTOR_(av, a_.values);
185 SIMDE_CONVERT_VECTOR_(bv, b_.values);
186 r_.values = av * bv;
187 #else
188 SIMDE_VECTORIZE
189 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
190 r_.values[i] = HEDLEY_STATIC_CAST(uint32_t, a_.values[i]) * HEDLEY_STATIC_CAST(uint32_t, b_.values[i]);
191 }
192 #endif
193
194 return simde_uint32x4_from_private(r_);
195 #endif
196 }
197 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
198 #undef vmull_u16
199 #define vmull_u16(a, b) simde_vmull_u16((a), (b))
200 #endif
201
202 SIMDE_FUNCTION_ATTRIBUTES
203 simde_uint64x2_t
204 simde_vmull_u32(simde_uint32x2_t a, simde_uint32x2_t b) {
205 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
206 return vmull_u32(a, b);
207 #else
208 simde_uint64x2_private r_;
209 simde_uint32x2_private
210 a_ = simde_uint32x2_to_private(a),
211 b_ = simde_uint32x2_to_private(b);
212
213 #if defined(SIMDE_CONVERT_VECTOR_) && defined(SIMDE_VECTOR_SUBSCRIPT_OPS)
214 __typeof__(r_.values) av, bv;
215 SIMDE_CONVERT_VECTOR_(av, a_.values);
216 SIMDE_CONVERT_VECTOR_(bv, b_.values);
217 r_.values = av * bv;
218 #else
219 SIMDE_VECTORIZE
220 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
221 r_.values[i] = HEDLEY_STATIC_CAST(uint64_t, a_.values[i]) * HEDLEY_STATIC_CAST(uint64_t, b_.values[i]);
222 }
223 #endif
224
225 return simde_uint64x2_from_private(r_);
226 #endif
227 }
228 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
229 #undef vmull_u32
230 #define vmull_u32(a, b) simde_vmull_u32((a), (b))
231 #endif
232
233 SIMDE_END_DECLS_
234 HEDLEY_DIAGNOSTIC_POP
235
236 #endif /* !defined(SIMDE_ARM_NEON_MULL_H) */