| 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_N_H) |
| 29 |
#define SIMDE_ARM_NEON_MLA_N_H |
| 30 |
|
| 31 |
#include "types.h" |
| 32 |
#include "add.h" |
| 33 |
#include "mul.h" |
| 34 |
#include "mul_n.h" |
| 35 |
|
| 36 |
HEDLEY_DIAGNOSTIC_PUSH |
| 37 |
SIMDE_DISABLE_UNWANTED_DIAGNOSTICS |
| 38 |
SIMDE_BEGIN_DECLS_ |
| 39 |
|
| 40 |
SIMDE_FUNCTION_ATTRIBUTES |
| 41 |
simde_float32x2_t |
| 42 |
simde_vmla_n_f32(simde_float32x2_t a, simde_float32x2_t b, simde_float32 c) { |
| 43 |
#if defined(SIMDE_ARM_NEON_A32V7_NATIVE) |
| 44 |
return vmla_n_f32(a, b, c); |
| 45 |
#else |
| 46 |
simde_float32x2_private |
| 47 |
r_, |
| 48 |
a_ = simde_float32x2_to_private(a), |
| 49 |
b_ = simde_float32x2_to_private(b); |
| 50 |
|
| 51 |
#if defined(SIMDE_VECTOR_SUBSCRIPT_SCALAR) && !defined(SIMDE_BUG_GCC_53784) |
| 52 |
r_.values = (b_.values * c) + a_.values; |
| 53 |
#else |
| 54 |
SIMDE_VECTORIZE |
| 55 |
for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) { |
| 56 |
r_.values[i] = (b_.values[i] * c) + a_.values[i]; |
| 57 |
} |
| 58 |
#endif |
| 59 |
|
| 60 |
return simde_float32x2_from_private(r_); |
| 61 |
#endif |
| 62 |
} |
| 63 |
#if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES) |
| 64 |
#undef vmla_n_f32 |
| 65 |
#define vmla_n_f32(a, b, c) simde_vmla_n_f32((a), (b), (c)) |
| 66 |
#endif |
| 67 |
|
| 68 |
SIMDE_FUNCTION_ATTRIBUTES |
| 69 |
simde_int16x4_t |
| 70 |
simde_vmla_n_s16(simde_int16x4_t a, simde_int16x4_t b, int16_t c) { |
| 71 |
#if defined(SIMDE_ARM_NEON_A32V7_NATIVE) |
| 72 |
return vmla_n_s16(a, b, c); |
| 73 |
#else |
| 74 |
simde_int16x4_private |
| 75 |
r_, |
| 76 |
a_ = simde_int16x4_to_private(a), |
| 77 |
b_ = simde_int16x4_to_private(b); |
| 78 |
|
| 79 |
#if defined(SIMDE_VECTOR_SUBSCRIPT_SCALAR) && !defined(SIMDE_BUG_GCC_53784) && !defined(SIMDE_BUG_GCC_100762) |
| 80 |
r_.values = (b_.values * c) + a_.values; |
| 81 |
#else |
| 82 |
SIMDE_VECTORIZE |
| 83 |
for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) { |
| 84 |
r_.values[i] = (b_.values[i] * c) + a_.values[i]; |
| 85 |
} |
| 86 |
#endif |
| 87 |
|
| 88 |
return simde_int16x4_from_private(r_); |
| 89 |
#endif |
| 90 |
} |
| 91 |
#if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES) |
| 92 |
#undef vmla_n_s16 |
| 93 |
#define vmla_n_s16(a, b, c) simde_vmla_n_s16((a), (b), (c)) |
| 94 |
#endif |
| 95 |
|
| 96 |
SIMDE_FUNCTION_ATTRIBUTES |
| 97 |
simde_int32x2_t |
| 98 |
simde_vmla_n_s32(simde_int32x2_t a, simde_int32x2_t b, int32_t c) { |
| 99 |
#if defined(SIMDE_ARM_NEON_A32V7_NATIVE) |
| 100 |
return vmla_n_s32(a, b, c); |
| 101 |
#else |
| 102 |
simde_int32x2_private |
| 103 |
r_, |
| 104 |
a_ = simde_int32x2_to_private(a), |
| 105 |
b_ = simde_int32x2_to_private(b); |
| 106 |
|
| 107 |
#if defined(SIMDE_VECTOR_SUBSCRIPT_SCALAR) && !defined(SIMDE_BUG_GCC_100762) |
| 108 |
r_.values = (b_.values * c) + a_.values; |
| 109 |
#else |
| 110 |
SIMDE_VECTORIZE |
| 111 |
for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) { |
| 112 |
r_.values[i] = (b_.values[i] * c) + a_.values[i]; |
| 113 |
} |
| 114 |
#endif |
| 115 |
|
| 116 |
return simde_int32x2_from_private(r_); |
| 117 |
#endif |
| 118 |
} |
| 119 |
#if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES) |
| 120 |
#undef vmla_n_s32 |
| 121 |
#define vmla_n_s32(a, b, c) simde_vmla_n_s32((a), (b), (c)) |
| 122 |
#endif |
| 123 |
|
| 124 |
SIMDE_FUNCTION_ATTRIBUTES |
| 125 |
simde_uint16x4_t |
| 126 |
simde_vmla_n_u16(simde_uint16x4_t a, simde_uint16x4_t b, uint16_t c) { |
| 127 |
#if defined(SIMDE_ARM_NEON_A32V7_NATIVE) |
| 128 |
return vmla_n_u16(a, b, c); |
| 129 |
#else |
| 130 |
simde_uint16x4_private |
| 131 |
r_, |
| 132 |
a_ = simde_uint16x4_to_private(a), |
| 133 |
b_ = simde_uint16x4_to_private(b); |
| 134 |
|
| 135 |
#if defined(SIMDE_VECTOR_SUBSCRIPT_SCALAR) && !defined(SIMDE_BUG_GCC_100762) |
| 136 |
r_.values = (b_.values * c) + a_.values; |
| 137 |
#else |
| 138 |
SIMDE_VECTORIZE |
| 139 |
for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) { |
| 140 |
r_.values[i] = (b_.values[i] * c) + a_.values[i]; |
| 141 |
} |
| 142 |
#endif |
| 143 |
|
| 144 |
return simde_uint16x4_from_private(r_); |
| 145 |
#endif |
| 146 |
} |
| 147 |
#if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES) |
| 148 |
#undef vmla_n_u16 |
| 149 |
#define vmla_n_u16(a, b, c) simde_vmla_n_u16((a), (b), (c)) |
| 150 |
#endif |
| 151 |
|
| 152 |
SIMDE_FUNCTION_ATTRIBUTES |
| 153 |
simde_uint32x2_t |
| 154 |
simde_vmla_n_u32(simde_uint32x2_t a, simde_uint32x2_t b, uint32_t c) { |
| 155 |
#if defined(SIMDE_ARM_NEON_A32V7_NATIVE) |
| 156 |
return vmla_n_u32(a, b, c); |
| 157 |
#else |
| 158 |
simde_uint32x2_private |
| 159 |
r_, |
| 160 |
a_ = simde_uint32x2_to_private(a), |
| 161 |
b_ = simde_uint32x2_to_private(b); |
| 162 |
|
| 163 |
#if defined(SIMDE_VECTOR_SUBSCRIPT_SCALAR) && !defined(SIMDE_BUG_GCC_100762) |
| 164 |
r_.values = (b_.values * c) + a_.values; |
| 165 |
#else |
| 166 |
SIMDE_VECTORIZE |
| 167 |
for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) { |
| 168 |
r_.values[i] = (b_.values[i] * c) + a_.values[i]; |
| 169 |
} |
| 170 |
#endif |
| 171 |
|
| 172 |
return simde_uint32x2_from_private(r_); |
| 173 |
#endif |
| 174 |
} |
| 175 |
#if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES) |
| 176 |
#undef vmla_n_u32 |
| 177 |
#define vmla_n_u32(a, b, c) simde_vmla_n_u32((a), (b), (c)) |
| 178 |
#endif |
| 179 |
|
| 180 |
SIMDE_FUNCTION_ATTRIBUTES |
| 181 |
simde_float32x4_t |
| 182 |
simde_vmlaq_n_f32(simde_float32x4_t a, simde_float32x4_t b, simde_float32 c) { |
| 183 |
#if defined(SIMDE_ARM_NEON_A32V7_NATIVE) |
| 184 |
return vmlaq_n_f32(a, b, c); |
| 185 |
#elif SIMDE_NATURAL_VECTOR_SIZE_LE(128) |
| 186 |
return simde_vaddq_f32(simde_vmulq_n_f32(b, c), a); |
| 187 |
#else |
| 188 |
simde_float32x4_private |
| 189 |
r_, |
| 190 |
a_ = simde_float32x4_to_private(a), |
| 191 |
b_ = simde_float32x4_to_private(b); |
| 192 |
|
| 193 |
#if defined(SIMDE_VECTOR_SUBSCRIPT_SCALAR) && !defined(SIMDE_BUG_GCC_53784) |
| 194 |
r_.values = (b_.values * c) + a_.values; |
| 195 |
#else |
| 196 |
SIMDE_VECTORIZE |
| 197 |
for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) { |
| 198 |
r_.values[i] = (b_.values[i] * c) + a_.values[i]; |
| 199 |
} |
| 200 |
#endif |
| 201 |
|
| 202 |
return simde_float32x4_from_private(r_); |
| 203 |
#endif |
| 204 |
} |
| 205 |
#if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES) |
| 206 |
#undef vmlaq_n_f32 |
| 207 |
#define vmlaq_n_f32(a, b, c) simde_vmlaq_n_f32((a), (b), (c)) |
| 208 |
#endif |
| 209 |
|
| 210 |
SIMDE_FUNCTION_ATTRIBUTES |
| 211 |
simde_int16x8_t |
| 212 |
simde_vmlaq_n_s16(simde_int16x8_t a, simde_int16x8_t b, int16_t c) { |
| 213 |
#if defined(SIMDE_ARM_NEON_A32V7_NATIVE) |
| 214 |
return vmlaq_n_s16(a, b, c); |
| 215 |
#elif SIMDE_NATURAL_VECTOR_SIZE_LE(128) |
| 216 |
return simde_vaddq_s16(simde_vmulq_n_s16(b, c), a); |
| 217 |
#else |
| 218 |
simde_int16x8_private |
| 219 |
r_, |
| 220 |
a_ = simde_int16x8_to_private(a), |
| 221 |
b_ = simde_int16x8_to_private(b); |
| 222 |
|
| 223 |
#if defined(SIMDE_VECTOR_SUBSCRIPT_SCALAR) && !defined(SIMDE_BUG_GCC_53784) |
| 224 |
r_.values = (b_.values * c) + a_.values; |
| 225 |
#else |
| 226 |
SIMDE_VECTORIZE |
| 227 |
for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) { |
| 228 |
r_.values[i] = (b_.values[i] * c) + a_.values[i]; |
| 229 |
} |
| 230 |
#endif |
| 231 |
|
| 232 |
return simde_int16x8_from_private(r_); |
| 233 |
#endif |
| 234 |
} |
| 235 |
#if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES) |
| 236 |
#undef vmlaq_n_s16 |
| 237 |
#define vmlaq_n_s16(a, b, c) simde_vmlaq_n_s16((a), (b), (c)) |
| 238 |
#endif |
| 239 |
|
| 240 |
SIMDE_FUNCTION_ATTRIBUTES |
| 241 |
simde_int32x4_t |
| 242 |
simde_vmlaq_n_s32(simde_int32x4_t a, simde_int32x4_t b, int32_t c) { |
| 243 |
#if defined(SIMDE_ARM_NEON_A32V7_NATIVE) |
| 244 |
return vmlaq_n_s32(a, b, c); |
| 245 |
#elif SIMDE_NATURAL_VECTOR_SIZE_LE(128) |
| 246 |
return simde_vaddq_s32(simde_vmulq_n_s32(b, c), a); |
| 247 |
#else |
| 248 |
simde_int32x4_private |
| 249 |
r_, |
| 250 |
a_ = simde_int32x4_to_private(a), |
| 251 |
b_ = simde_int32x4_to_private(b); |
| 252 |
|
| 253 |
#if defined(SIMDE_VECTOR_SUBSCRIPT_SCALAR) |
| 254 |
r_.values = (b_.values * c) + a_.values; |
| 255 |
#else |
| 256 |
SIMDE_VECTORIZE |
| 257 |
for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) { |
| 258 |
r_.values[i] = (b_.values[i] * c) + a_.values[i]; |
| 259 |
} |
| 260 |
#endif |
| 261 |
|
| 262 |
return simde_int32x4_from_private(r_); |
| 263 |
#endif |
| 264 |
} |
| 265 |
#if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES) |
| 266 |
#undef vmlaq_n_s32 |
| 267 |
#define vmlaq_n_s32(a, b, c) simde_vmlaq_n_s32((a), (b), (c)) |
| 268 |
#endif |
| 269 |
|
| 270 |
SIMDE_FUNCTION_ATTRIBUTES |
| 271 |
simde_uint16x8_t |
| 272 |
simde_vmlaq_n_u16(simde_uint16x8_t a, simde_uint16x8_t b, uint16_t c) { |
| 273 |
#if defined(SIMDE_ARM_NEON_A32V7_NATIVE) |
| 274 |
return vmlaq_n_u16(a, b, c); |
| 275 |
#elif SIMDE_NATURAL_VECTOR_SIZE_LE(128) |
| 276 |
return simde_vaddq_u16(simde_vmulq_n_u16(b, c), a); |
| 277 |
#else |
| 278 |
simde_uint16x8_private |
| 279 |
r_, |
| 280 |
a_ = simde_uint16x8_to_private(a), |
| 281 |
b_ = simde_uint16x8_to_private(b); |
| 282 |
|
| 283 |
#if defined(SIMDE_VECTOR_SUBSCRIPT_SCALAR) |
| 284 |
r_.values = (b_.values * c) + a_.values; |
| 285 |
#else |
| 286 |
SIMDE_VECTORIZE |
| 287 |
for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) { |
| 288 |
r_.values[i] = (b_.values[i] * c) + a_.values[i]; |
| 289 |
} |
| 290 |
#endif |
| 291 |
|
| 292 |
return simde_uint16x8_from_private(r_); |
| 293 |
#endif |
| 294 |
} |
| 295 |
#if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES) |
| 296 |
#undef vmlaq_n_u16 |
| 297 |
#define vmlaq_n_u16(a, b, c) simde_vmlaq_n_u16((a), (b), (c)) |
| 298 |
#endif |
| 299 |
|
| 300 |
SIMDE_FUNCTION_ATTRIBUTES |
| 301 |
simde_uint32x4_t |
| 302 |
simde_vmlaq_n_u32(simde_uint32x4_t a, simde_uint32x4_t b, uint32_t c) { |
| 303 |
#if defined(SIMDE_ARM_NEON_A32V7_NATIVE) |
| 304 |
return vmlaq_n_u32(a, b, c); |
| 305 |
#elif SIMDE_NATURAL_VECTOR_SIZE_LE(128) |
| 306 |
return simde_vaddq_u32(simde_vmulq_n_u32(b, c), a); |
| 307 |
#else |
| 308 |
simde_uint32x4_private |
| 309 |
r_, |
| 310 |
a_ = simde_uint32x4_to_private(a), |
| 311 |
b_ = simde_uint32x4_to_private(b); |
| 312 |
|
| 313 |
#if defined(SIMDE_VECTOR_SUBSCRIPT_SCALAR) |
| 314 |
r_.values = (b_.values * c) + a_.values; |
| 315 |
#else |
| 316 |
SIMDE_VECTORIZE |
| 317 |
for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) { |
| 318 |
r_.values[i] = (b_.values[i] * c) + a_.values[i]; |
| 319 |
} |
| 320 |
#endif |
| 321 |
|
| 322 |
return simde_uint32x4_from_private(r_); |
| 323 |
#endif |
| 324 |
} |
| 325 |
#if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES) |
| 326 |
#undef vmlaq_n_u32 |
| 327 |
#define vmlaq_n_u32(a, b, c) simde_vmlaq_n_u32((a), (b), (c)) |
| 328 |
#endif |
| 329 |
|
| 330 |
SIMDE_END_DECLS_ |
| 331 |
HEDLEY_DIAGNOSTIC_POP |
| 332 |
|
| 333 |
#endif /* !defined(SIMDE_ARM_NEON_MLA_N_H) */ |