Debian Codegraph @

third-party/simde/arm/neon/mlal_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 */
26
27 #if !defined(SIMDE_ARM_NEON_MLAL_N_H)
28 #define SIMDE_ARM_NEON_MLAL_N_H
29
30 #include "movl.h"
31 #include "dup_n.h"
32 #include "mla.h"
33 #include "types.h"
34
35 HEDLEY_DIAGNOSTIC_PUSH
36 SIMDE_DISABLE_UNWANTED_DIAGNOSTICS
37 SIMDE_BEGIN_DECLS_
38
39 SIMDE_FUNCTION_ATTRIBUTES
40 simde_int32x4_t
41 simde_vmlal_n_s16(simde_int32x4_t a, simde_int16x4_t b, int16_t c) {
42 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
43 return vmlal_n_s16(a, b, c);
44 #else
45 return simde_vmlaq_s32(a, simde_vmovl_s16(b), simde_vdupq_n_s32(c));
46 #endif
47 }
48 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
49 #undef vmlal_n_s16
50 #define vmlal_n_s16(a, b, c) simde_vmlal_n_s16((a), (b), (c))
51 #endif
52
53 SIMDE_FUNCTION_ATTRIBUTES
54 simde_int64x2_t
55 simde_vmlal_n_s32(simde_int64x2_t a, simde_int32x2_t b, int32_t c) {
56 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
57 return vmlal_n_s32(a, b, c);
58 #else
59 simde_int64x2_private
60 r_,
61 a_ = simde_int64x2_to_private(a),
62 b_ = simde_int64x2_to_private(simde_vmovl_s32(b)),
63 c_ = simde_int64x2_to_private(simde_vdupq_n_s64(c));
64
65 #if defined(SIMDE_VECTOR_SUBSCRIPT_OPS)
66 r_.values = (b_.values * c_.values) + a_.values;
67 #else
68 SIMDE_VECTORIZE
69 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
70 r_.values[i] = (b_.values[i] * c_.values[i]) + a_.values[i];
71 }
72 #endif
73
74 return simde_int64x2_from_private(r_);
75 #endif
76 }
77 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
78 #undef vmlal_n_s32
79 #define vmlal_n_s32(a, b, c) simde_vmlal_n_s32((a), (b), (c))
80 #endif
81
82 SIMDE_FUNCTION_ATTRIBUTES
83 simde_uint32x4_t
84 simde_vmlal_n_u16(simde_uint32x4_t a, simde_uint16x4_t b, uint16_t c) {
85 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
86 return vmlal_n_u16(a, b, c);
87 #else
88 return simde_vmlaq_u32(a, simde_vmovl_u16(b), simde_vdupq_n_u32(c));
89 #endif
90 }
91 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
92 #undef vmlal_n_u16
93 #define vmlal_n_u16(a, b, c) simde_vmlal_n_u16((a), (b), (c))
94 #endif
95
96 SIMDE_FUNCTION_ATTRIBUTES
97 simde_uint64x2_t
98 simde_vmlal_n_u32(simde_uint64x2_t a, simde_uint32x2_t b, uint32_t c) {
99 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
100 return vmlal_n_u32(a, b, c);
101 #else
102 simde_uint64x2_private
103 r_,
104 a_ = simde_uint64x2_to_private(a),
105 b_ = simde_uint64x2_to_private(simde_vmovl_u32(b)),
106 c_ = simde_uint64x2_to_private(simde_vdupq_n_u64(c));
107
108 #if defined(SIMDE_VECTOR_SUBSCRIPT_OPS)
109 r_.values = (b_.values * c_.values) + a_.values;
110 #else
111 SIMDE_VECTORIZE
112 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
113 r_.values[i] = (b_.values[i] * c_.values[i]) + a_.values[i];
114 }
115 #endif
116
117 return simde_uint64x2_from_private(r_);
118 #endif
119 }
120 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
121 #undef vmlal_n_u32
122 #define vmlal_n_u32(a, b, c) simde_vmlal_n_u32((a), (b), (c))
123 #endif
124
125 SIMDE_END_DECLS_
126 HEDLEY_DIAGNOSTIC_POP
127
128 #endif /* !defined(SIMDE_ARM_NEON_MLAL_N_H) */