Debian Codegraph @

third-party/simde/arm/neon/mla.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_MLA_H)
29 #define SIMDE_ARM_NEON_MLA_H
30
31 #include "types.h"
32 #include "add.h"
33 #include "mul.h"
34
35 HEDLEY_DIAGNOSTIC_PUSH
36 SIMDE_DISABLE_UNWANTED_DIAGNOSTICS
37 SIMDE_BEGIN_DECLS_
38
39 SIMDE_FUNCTION_ATTRIBUTES
40 simde_float32x2_t
41 simde_vmla_f32(simde_float32x2_t a, simde_float32x2_t b, simde_float32x2_t c) {
42 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
43 return vmla_f32(a, b, c);
44 #else
45 return simde_vadd_f32(simde_vmul_f32(b, c), a);
46 #endif
47 }
48 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
49 #undef vmla_f32
50 #define vmla_f32(a, b, c) simde_vmla_f32((a), (b), (c))
51 #endif
52
53 SIMDE_FUNCTION_ATTRIBUTES
54 simde_float64x1_t
55 simde_vmla_f64(simde_float64x1_t a, simde_float64x1_t b, simde_float64x1_t c) {
56 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
57 return vmla_f64(a, b, c);
58 #else
59 return simde_vadd_f64(simde_vmul_f64(b, c), a);
60 #endif
61 }
62 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
63 #undef vmla_f64
64 #define vmla_f64(a, b, c) simde_vmla_f64((a), (b), (c))
65 #endif
66
67 SIMDE_FUNCTION_ATTRIBUTES
68 simde_int8x8_t
69 simde_vmla_s8(simde_int8x8_t a, simde_int8x8_t b, simde_int8x8_t c) {
70 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
71 return vmla_s8(a, b, c);
72 #else
73 return simde_vadd_s8(simde_vmul_s8(b, c), a);
74 #endif
75 }
76 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
77 #undef vmla_s8
78 #define vmla_s8(a, b, c) simde_vmla_s8((a), (b), (c))
79 #endif
80
81 SIMDE_FUNCTION_ATTRIBUTES
82 simde_int16x4_t
83 simde_vmla_s16(simde_int16x4_t a, simde_int16x4_t b, simde_int16x4_t c) {
84 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
85 return vmla_s16(a, b, c);
86 #else
87 return simde_vadd_s16(simde_vmul_s16(b, c), a);
88 #endif
89 }
90 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
91 #undef vmla_s16
92 #define vmla_s16(a, b, c) simde_vmla_s16((a), (b), (c))
93 #endif
94
95 SIMDE_FUNCTION_ATTRIBUTES
96 simde_int32x2_t
97 simde_vmla_s32(simde_int32x2_t a, simde_int32x2_t b, simde_int32x2_t c) {
98 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
99 return vmla_s32(a, b, c);
100 #else
101 return simde_vadd_s32(simde_vmul_s32(b, c), a);
102 #endif
103 }
104 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
105 #undef vmla_s32
106 #define vmla_s32(a, b, c) simde_vmla_s32((a), (b), (c))
107 #endif
108
109 SIMDE_FUNCTION_ATTRIBUTES
110 simde_uint8x8_t
111 simde_vmla_u8(simde_uint8x8_t a, simde_uint8x8_t b, simde_uint8x8_t c) {
112 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
113 return vmla_u8(a, b, c);
114 #else
115 return simde_vadd_u8(simde_vmul_u8(b, c), a);
116 #endif
117 }
118 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
119 #undef vmla_u8
120 #define vmla_u8(a, b, c) simde_vmla_u8((a), (b), (c))
121 #endif
122
123 SIMDE_FUNCTION_ATTRIBUTES
124 simde_uint16x4_t
125 simde_vmla_u16(simde_uint16x4_t a, simde_uint16x4_t b, simde_uint16x4_t c) {
126 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
127 return vmla_u16(a, b, c);
128 #else
129 return simde_vadd_u16(simde_vmul_u16(b, c), a);
130 #endif
131 }
132 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
133 #undef vmla_u16
134 #define vmla_u16(a, b, c) simde_vmla_u16((a), (b), (c))
135 #endif
136
137 SIMDE_FUNCTION_ATTRIBUTES
138 simde_uint32x2_t
139 simde_vmla_u32(simde_uint32x2_t a, simde_uint32x2_t b, simde_uint32x2_t c) {
140 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
141 return vmla_u32(a, b, c);
142 #else
143 return simde_vadd_u32(simde_vmul_u32(b, c), a);
144 #endif
145 }
146 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
147 #undef vmla_u32
148 #define vmla_u32(a, b, c) simde_vmla_u32((a), (b), (c))
149 #endif
150
151 SIMDE_FUNCTION_ATTRIBUTES
152 simde_float32x4_t
153 simde_vmlaq_f32(simde_float32x4_t a, simde_float32x4_t b, simde_float32x4_t c) {
154 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
155 return vmlaq_f32(a, b, c);
156 #elif defined(SIMDE_POWER_ALTIVEC_P6_NATIVE)
157 return vec_madd(b, c, a);
158 #elif \
159 defined(SIMDE_X86_FMA_NATIVE)
160 simde_float32x4_private
161 r_,
162 a_ = simde_float32x4_to_private(a),
163 b_ = simde_float32x4_to_private(b),
164 c_ = simde_float32x4_to_private(c);
165
166 #if defined(SIMDE_X86_FMA_NATIVE)
167 r_.m128 = _mm_fmadd_ps(b_.m128, c_.m128, a_.m128);
168 #endif
169
170 return simde_float32x4_from_private(r_);
171 #else
172 return simde_vaddq_f32(simde_vmulq_f32(b, c), a);
173 #endif
174 }
175 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
176 #undef vmlaq_f32
177 #define vmlaq_f32(a, b, c) simde_vmlaq_f32((a), (b), (c))
178 #endif
179
180 SIMDE_FUNCTION_ATTRIBUTES
181 simde_float64x2_t
182 simde_vmlaq_f64(simde_float64x2_t a, simde_float64x2_t b, simde_float64x2_t c) {
183 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
184 return vmlaq_f64(a, b, c);
185 #elif defined(SIMDE_POWER_ALTIVEC_P7_NATIVE)
186 return vec_madd(b, c, a);
187 #elif \
188 defined(SIMDE_X86_FMA_NATIVE)
189 simde_float64x2_private
190 r_,
191 a_ = simde_float64x2_to_private(a),
192 b_ = simde_float64x2_to_private(b),
193 c_ = simde_float64x2_to_private(c);
194
195 #if defined(SIMDE_X86_FMA_NATIVE)
196 r_.m128d = _mm_fmadd_pd(b_.m128d, c_.m128d, a_.m128d);
197 #endif
198
199 return simde_float64x2_from_private(r_);
200 #else
201 return simde_vaddq_f64(simde_vmulq_f64(b, c), a);
202 #endif
203 }
204 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
205 #undef vmlaq_f64
206 #define vmlaq_f64(a, b, c) simde_vmlaq_f64((a), (b), (c))
207 #endif
208
209 SIMDE_FUNCTION_ATTRIBUTES
210 simde_int8x16_t
211 simde_vmlaq_s8(simde_int8x16_t a, simde_int8x16_t b, simde_int8x16_t c) {
212 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
213 return vmlaq_s8(a, b, c);
214 #else
215 return simde_vaddq_s8(simde_vmulq_s8(b, c), a);
216 #endif
217 }
218 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
219 #undef vmlaq_s8
220 #define vmlaq_s8(a, b, c) simde_vmlaq_s8((a), (b), (c))
221 #endif
222
223 SIMDE_FUNCTION_ATTRIBUTES
224 simde_int16x8_t
225 simde_vmlaq_s16(simde_int16x8_t a, simde_int16x8_t b, simde_int16x8_t c) {
226 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
227 return vmlaq_s16(a, b, c);
228 #else
229 return simde_vaddq_s16(simde_vmulq_s16(b, c), a);
230 #endif
231 }
232 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
233 #undef vmlaq_s16
234 #define vmlaq_s16(a, b, c) simde_vmlaq_s16((a), (b), (c))
235 #endif
236
237 SIMDE_FUNCTION_ATTRIBUTES
238 simde_int32x4_t
239 simde_vmlaq_s32(simde_int32x4_t a, simde_int32x4_t b, simde_int32x4_t c) {
240 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
241 return vmlaq_s32(a, b, c);
242 #else
243 return simde_vaddq_s32(simde_vmulq_s32(b, c), a);
244 #endif
245 }
246 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
247 #undef vmlaq_s32
248 #define vmlaq_s32(a, b, c) simde_vmlaq_s32((a), (b), (c))
249 #endif
250
251 SIMDE_FUNCTION_ATTRIBUTES
252 simde_uint8x16_t
253 simde_vmlaq_u8(simde_uint8x16_t a, simde_uint8x16_t b, simde_uint8x16_t c) {
254 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
255 return vmlaq_u8(a, b, c);
256 #else
257 return simde_vaddq_u8(simde_vmulq_u8(b, c), a);
258 #endif
259 }
260 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
261 #undef vmlaq_u8
262 #define vmlaq_u8(a, b, c) simde_vmlaq_u8((a), (b), (c))
263 #endif
264
265 SIMDE_FUNCTION_ATTRIBUTES
266 simde_uint16x8_t
267 simde_vmlaq_u16(simde_uint16x8_t a, simde_uint16x8_t b, simde_uint16x8_t c) {
268 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
269 return vmlaq_u16(a, b, c);
270 #else
271 return simde_vaddq_u16(simde_vmulq_u16(b, c), a);
272 #endif
273 }
274 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
275 #undef vmlaq_u16
276 #define vmlaq_u16(a, b, c) simde_vmlaq_u16((a), (b), (c))
277 #endif
278
279 SIMDE_FUNCTION_ATTRIBUTES
280 simde_uint32x4_t
281 simde_vmlaq_u32(simde_uint32x4_t a, simde_uint32x4_t b, simde_uint32x4_t c) {
282 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
283 return vmlaq_u32(a, b, c);
284 #else
285 return simde_vaddq_u32(simde_vmulq_u32(b, c), a);
286 #endif
287 }
288 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
289 #undef vmlaq_u32
290 #define vmlaq_u32(a, b, c) simde_vmlaq_u32((a), (b), (c))
291 #endif
292
293 SIMDE_END_DECLS_
294 HEDLEY_DIAGNOSTIC_POP
295
296 #endif /* !defined(SIMDE_ARM_NEON_MLA_H) */