Debian Codegraph @

third-party/simde/arm/neon/cage.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 * 2021 Evan Nemerson <[email protected]>
25 * 2021 Atharva Nimbalkar <[email protected]>
26 */
27
28 #if !defined(SIMDE_ARM_NEON_CAGE_H)
29 #define SIMDE_ARM_NEON_CAGE_H
30
31 #include "types.h"
32 #include "abs.h"
33 #include "cge.h"
34
35 HEDLEY_DIAGNOSTIC_PUSH
36 SIMDE_DISABLE_UNWANTED_DIAGNOSTICS
37 SIMDE_BEGIN_DECLS_
38
39 SIMDE_FUNCTION_ATTRIBUTES
40 uint16_t
41 simde_vcageh_f16(simde_float16_t a, simde_float16_t b) {
42 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE) && defined(SIMDE_ARM_NEON_FP16)
43 return vcageh_f16(a, b);
44 #else
45 simde_float32_t a_ = simde_float16_to_float32(a);
46 simde_float32_t b_ = simde_float16_to_float32(b);
47 return (simde_math_fabsf(a_) >= simde_math_fabsf(b_)) ? UINT16_MAX : UINT16_C(0);
48 #endif
49 }
50 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
51 #undef vcageh_f16
52 #define vcageh_f16(a, b) simde_vcageh_f16((a), (b))
53 #endif
54
55 SIMDE_FUNCTION_ATTRIBUTES
56 uint32_t
57 simde_vcages_f32(simde_float32_t a, simde_float32_t b) {
58 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
59 return vcages_f32(a, b);
60 #else
61 return (simde_math_fabsf(a) >= simde_math_fabsf(b)) ? ~UINT32_C(0) : UINT32_C(0);
62 #endif
63 }
64 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
65 #undef vcages_f32
66 #define vcages_f32(a, b) simde_vcages_f32((a), (b))
67 #endif
68
69 SIMDE_FUNCTION_ATTRIBUTES
70 uint64_t
71 simde_vcaged_f64(simde_float64_t a, simde_float64_t b) {
72 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
73 return vcaged_f64(a, b);
74 #else
75 return (simde_math_fabs(a) >= simde_math_fabs(b)) ? ~UINT64_C(0) : UINT64_C(0);
76 #endif
77 }
78 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
79 #undef vcaged_f64
80 #define vcaged_f64(a, b) simde_vcaged_f64((a), (b))
81 #endif
82
83 SIMDE_FUNCTION_ATTRIBUTES
84 simde_uint16x4_t
85 simde_vcage_f16(simde_float16x4_t a, simde_float16x4_t b) {
86 #if defined(SIMDE_ARM_NEON_A32V8_NATIVE) && defined(SIMDE_ARM_NEON_FP16)
87 return vcage_f16(a, b);
88 #else
89 simde_float16x4_private
90 a_ = simde_float16x4_to_private(a),
91 b_ = simde_float16x4_to_private(b);
92 simde_uint16x4_private r_;
93
94 SIMDE_VECTORIZE
95 for(size_t i = 0 ; i < (sizeof(r_) / sizeof(r_.values[0])) ; i++) {
96 r_.values[i] = simde_vcageh_f16(a_.values[i], b_.values[i]);
97 }
98
99 return simde_uint16x4_from_private(r_);
100 #endif
101 }
102 #if defined(SIMDE_ARM_NEON_A32V8_ENABLE_NATIVE_ALIASES)
103 #undef vcage_f16
104 #define vcage_f16(a, b) simde_vcage_f16((a), (b))
105 #endif
106
107 SIMDE_FUNCTION_ATTRIBUTES
108 simde_uint32x2_t
109 simde_vcage_f32(simde_float32x2_t a, simde_float32x2_t b) {
110 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
111 return vcage_f32(a, b);
112 #else
113 return simde_vcge_f32(simde_vabs_f32(a), simde_vabs_f32(b));
114 #endif
115 }
116 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
117 #undef vcage_f32
118 #define vcage_f32(a, b) simde_vcage_f32((a), (b))
119 #endif
120
121 SIMDE_FUNCTION_ATTRIBUTES
122 simde_uint64x1_t
123 simde_vcage_f64(simde_float64x1_t a, simde_float64x1_t b) {
124 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
125 return vcage_f64(a, b);
126 #else
127 return simde_vcge_f64(simde_vabs_f64(a), simde_vabs_f64(b));
128 #endif
129 }
130 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
131 #undef vcage_f64
132 #define vcage_f64(a, b) simde_vcage_f64((a), (b))
133 #endif
134
135 SIMDE_FUNCTION_ATTRIBUTES
136 simde_uint16x8_t
137 simde_vcageq_f16(simde_float16x8_t a, simde_float16x8_t b) {
138 #if defined(SIMDE_ARM_NEON_A32V8_NATIVE) && defined(SIMDE_ARM_NEON_FP16)
139 return vcageq_f16(a, b);
140 #else
141 simde_float16x8_private
142 a_ = simde_float16x8_to_private(a),
143 b_ = simde_float16x8_to_private(b);
144 simde_uint16x8_private r_;
145
146 SIMDE_VECTORIZE
147 for(size_t i = 0 ; i < (sizeof(r_) / sizeof(r_.values[0])) ; i++) {
148 r_.values[i] = simde_vcageh_f16(a_.values[i], b_.values[i]);
149 }
150 return simde_uint16x8_from_private(r_);
151 #endif
152 }
153 #if defined(SIMDE_ARM_NEON_A32V8_ENABLE_NATIVE_ALIASES)
154 #undef vcageq_f16
155 #define vcageq_f16(a, b) simde_vcageq_f16((a), (b))
156 #endif
157
158 SIMDE_FUNCTION_ATTRIBUTES
159 simde_uint32x4_t
160 simde_vcageq_f32(simde_float32x4_t a, simde_float32x4_t b) {
161 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
162 return vcageq_f32(a, b);
163 #else
164 return simde_vcgeq_f32(simde_vabsq_f32(a), simde_vabsq_f32(b));
165 #endif
166 }
167 #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
168 #undef vcageq_f32
169 #define vcageq_f32(a, b) simde_vcageq_f32((a), (b))
170 #endif
171
172 SIMDE_FUNCTION_ATTRIBUTES
173 simde_uint64x2_t
174 simde_vcageq_f64(simde_float64x2_t a, simde_float64x2_t b) {
175 #if defined(SIMDE_ARM_NEON_A64V8_NATIVE)
176 return vcageq_f64(a, b);
177 #else
178 return simde_vcgeq_f64(simde_vabsq_f64(a), simde_vabsq_f64(b));
179 #endif
180 }
181 #if defined(SIMDE_ARM_NEON_A64V8_ENABLE_NATIVE_ALIASES)
182 #undef vcageq_f64
183 #define vcageq_f64(a, b) simde_vcageq_f64((a), (b))
184 #endif
185
186 SIMDE_END_DECLS_
187 HEDLEY_DIAGNOSTIC_POP
188
189 #endif /* !defined(SIMDE_ARM_NEON_CAGE_H) */