Debian Codegraph @

third-party/simde/arm/neon/mull_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 Sean Maher <[email protected]> (Copyright owned by Google, LLC)
26 */
27
28 #if !defined(SIMDE_ARM_NEON_MULL_N_H)
29 #define SIMDE_ARM_NEON_MULL_N_H
30
31 #include "types.h"
32 #include "mul_n.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_int32x4_t
41 simde_vmull_n_s16(simde_int16x4_t a, int16_t b) {
42 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
43 return vmull_n_s16(a, b);
44 #elif SIMDE_NATURAL_VECTOR_SIZE_GE(128)
45 return simde_vmulq_n_s32(simde_vmovl_s16(a), b);
46 #else
47 simde_int32x4_private r_;
48 simde_int16x4_private a_ = simde_int16x4_to_private(a);
49
50 #if defined(SIMDE_CONVERT_VECTOR_) && defined(SIMDE_VECTOR_SUBSCRIPT_SCALAR) && !defined(SIMDE_BUG_GCC_100761)
51 __typeof__(r_.values) av;
52 SIMDE_CONVERT_VECTOR_(av, a_.values);
53 r_.values = av * b;
54 #else
55 SIMDE_VECTORIZE
56 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
57 r_.values[i] = HEDLEY_STATIC_CAST(int32_t, a_.values[i]) * HEDLEY_STATIC_CAST(int32_t, b);
58 }
59 #endif
60
61 return simde_int32x4_from_private(r_);
62 #endif
63 }
64 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
65 #undef vmull_n_s16
66 #define vmull_n_s16(a, b) simde_vmull_n_s16((a), (b))
67 #endif
68
69 SIMDE_FUNCTION_ATTRIBUTES
70 simde_int64x2_t
71 simde_vmull_n_s32(simde_int32x2_t a, int32_t b) {
72 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
73 return vmull_n_s32(a, b);
74 #else
75 simde_int64x2_private r_;
76 simde_int32x2_private a_ = simde_int32x2_to_private(a);
77
78 #if defined(SIMDE_CONVERT_VECTOR_) && defined(SIMDE_VECTOR_SUBSCRIPT_SCALAR) && !defined(SIMDE_BUG_GCC_100761)
79 __typeof__(r_.values) av;
80 SIMDE_CONVERT_VECTOR_(av, a_.values);
81 r_.values = av * b;
82 #else
83 SIMDE_VECTORIZE
84 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
85 r_.values[i] = HEDLEY_STATIC_CAST(int64_t, a_.values[i]) * HEDLEY_STATIC_CAST(int64_t, b);
86 }
87 #endif
88
89 return simde_int64x2_from_private(r_);
90 #endif
91 }
92 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
93 #undef vmull_n_s32
94 #define vmull_n_s32(a, b) simde_vmull_n_s32((a), (b))
95 #endif
96
97 SIMDE_FUNCTION_ATTRIBUTES
98 simde_uint32x4_t
99 simde_vmull_n_u16(simde_uint16x4_t a, uint16_t b) {
100 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
101 return vmull_n_u16(a, b);
102 #elif SIMDE_NATURAL_VECTOR_SIZE_GE(128)
103 return simde_vmulq_n_u32(simde_vmovl_u16(a), b);
104 #else
105 simde_uint32x4_private r_;
106 simde_uint16x4_private a_ = simde_uint16x4_to_private(a);
107
108 #if defined(SIMDE_CONVERT_VECTOR_) && defined(SIMDE_VECTOR_SUBSCRIPT_SCALAR) && !defined(SIMDE_BUG_GCC_100761)
109 __typeof__(r_.values) av;
110 SIMDE_CONVERT_VECTOR_(av, a_.values);
111 r_.values = av * b;
112 #else
113 SIMDE_VECTORIZE
114 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
115 r_.values[i] = HEDLEY_STATIC_CAST(uint32_t, a_.values[i]) * HEDLEY_STATIC_CAST(uint32_t, b);
116 }
117 #endif
118
119 return simde_uint32x4_from_private(r_);
120 #endif
121 }
122 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
123 #undef vmull_n_u16
124 #define vmull_n_u16(a, b) simde_vmull_n_u16((a), (b))
125 #endif
126
127 SIMDE_FUNCTION_ATTRIBUTES
128 simde_uint64x2_t
129 simde_vmull_n_u32(simde_uint32x2_t a, uint32_t b) {
130 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
131 return vmull_n_u32(a, b);
132 #else
133 simde_uint64x2_private r_;
134 simde_uint32x2_private a_ = simde_uint32x2_to_private(a);
135
136 #if defined(SIMDE_CONVERT_VECTOR_) && defined(SIMDE_VECTOR_SUBSCRIPT_SCALAR)
137 __typeof__(r_.values) av;
138 SIMDE_CONVERT_VECTOR_(av, a_.values);
139 r_.values = av * b;
140 #else
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(uint64_t, a_.values[i]) * HEDLEY_STATIC_CAST(uint64_t, b);
144 }
145 #endif
146
147 return simde_uint64x2_from_private(r_);
148 #endif
149 }
150 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
151 #undef vmull_n_u32
152 #define vmull_n_u32(a, b) simde_vmull_n_u32((a), (b))
153 #endif
154
155 SIMDE_END_DECLS_
156 HEDLEY_DIAGNOSTIC_POP
157
158 #endif /* !defined(SIMDE_ARM_NEON_MULL_H) */