Debian Codegraph @

third-party/simde/x86/avx512/cast.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 Himanshi Mathur <[email protected]>
26 * 2020 Hidayat Khan <[email protected]>
27 * 2020 Christopher Moore <[email protected]>
28 */
29
30 #if !defined(SIMDE_X86_AVX512_CAST_H)
31 #define SIMDE_X86_AVX512_CAST_H
32
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__m512
41 simde_mm512_castpd_ps (simde__m512d a) {
42 #if defined(SIMDE_X86_AVX512F_NATIVE)
43 return _mm512_castpd_ps(a);
44 #else
45 simde__m512 r;
46 simde_memcpy(&r, &a, sizeof(r));
47 return r;
48 #endif
49 }
50 #if defined(SIMDE_X86_AVX512F_ENABLE_NATIVE_ALIASES)
51 #undef _mm512_castpd_ps
52 #define _mm512_castpd_ps(a) simde_mm512_castpd_ps(a)
53 #endif
54
55 SIMDE_FUNCTION_ATTRIBUTES
56 simde__m512i
57 simde_mm512_castpd_si512 (simde__m512d a) {
58 #if defined(SIMDE_X86_AVX512F_NATIVE)
59 return _mm512_castpd_si512(a);
60 #else
61 simde__m512i r;
62 simde_memcpy(&r, &a, sizeof(r));
63 return r;
64 #endif
65 }
66 #if defined(SIMDE_X86_AVX512F_ENABLE_NATIVE_ALIASES)
67 #undef _mm512_castpd_si512
68 #define _mm512_castpd_si512(a) simde_mm512_castpd_si512(a)
69 #endif
70
71 SIMDE_FUNCTION_ATTRIBUTES
72 simde__m512d
73 simde_mm512_castps_pd (simde__m512 a) {
74 #if defined(SIMDE_X86_AVX512F_NATIVE)
75 return _mm512_castps_pd(a);
76 #else
77 simde__m512d r;
78 simde_memcpy(&r, &a, sizeof(r));
79 return r;
80 #endif
81 }
82 #if defined(SIMDE_X86_AVX512F_ENABLE_NATIVE_ALIASES)
83 #undef _mm512_castps_pd
84 #define _mm512_castps_pd(a) simde_mm512_castps_pd(a)
85 #endif
86
87 SIMDE_FUNCTION_ATTRIBUTES
88 simde__m512i
89 simde_mm512_castps_si512 (simde__m512 a) {
90 #if defined(SIMDE_X86_AVX512F_NATIVE)
91 return _mm512_castps_si512(a);
92 #else
93 simde__m512i r;
94 simde_memcpy(&r, &a, sizeof(r));
95 return r;
96 #endif
97 }
98 #if defined(SIMDE_X86_AVX512F_ENABLE_NATIVE_ALIASES)
99 #undef _mm512_castps_si512
100 #define _mm512_castps_si512(a) simde_mm512_castps_si512(a)
101 #endif
102
103 SIMDE_FUNCTION_ATTRIBUTES
104 simde__m512
105 simde_mm512_castsi512_ps (simde__m512i a) {
106 #if defined(SIMDE_X86_AVX512F_NATIVE)
107 return _mm512_castsi512_ps(a);
108 #else
109 simde__m512 r;
110 simde_memcpy(&r, &a, sizeof(r));
111 return r;
112 #endif
113 }
114 #if defined(SIMDE_X86_AVX512F_ENABLE_NATIVE_ALIASES)
115 #undef _mm512_castsi512_ps
116 #define _mm512_castsi512_ps(a) simde_mm512_castsi512_ps(a)
117 #endif
118
119 SIMDE_FUNCTION_ATTRIBUTES
120 simde__m512d
121 simde_mm512_castsi512_pd (simde__m512i a) {
122 #if defined(SIMDE_X86_AVX512F_NATIVE)
123 return _mm512_castsi512_pd(a);
124 #else
125 simde__m512d r;
126 simde_memcpy(&r, &a, sizeof(r));
127 return r;
128 #endif
129 }
130 #if defined(SIMDE_X86_AVX512F_ENABLE_NATIVE_ALIASES)
131 #undef _mm512_castsi512_pd
132 #define _mm512_castsi512_pd(a) simde_mm512_castsi512_pd(a)
133 #endif
134
135 SIMDE_FUNCTION_ATTRIBUTES
136 simde__m512d
137 simde_mm512_castpd128_pd512 (simde__m128d a) {
138 #if defined(SIMDE_X86_AVX512F_NATIVE)
139 return _mm512_castpd128_pd512(a);
140 #else
141 simde__m512d_private r_;
142 r_.m128d[0] = a;
143 return simde__m512d_from_private(r_);
144 #endif
145 }
146 #if defined(SIMDE_X86_AVX512F_ENABLE_NATIVE_ALIASES)
147 #undef _mm512_castpd128_pd512
148 #define _mm512_castpd128_pd512(a) simde_mm512_castpd128_pd512(a)
149 #endif
150
151 SIMDE_FUNCTION_ATTRIBUTES
152 simde__m512d
153 simde_mm512_castpd256_pd512 (simde__m256d a) {
154 #if defined(SIMDE_X86_AVX512F_NATIVE)
155 return _mm512_castpd256_pd512(a);
156 #else
157 simde__m512d_private r_;
158 r_.m256d[0] = a;
159 return simde__m512d_from_private(r_);
160 #endif
161 }
162 #if defined(SIMDE_X86_AVX512F_ENABLE_NATIVE_ALIASES)
163 #undef _mm512_castpd256_pd512
164 #define _mm512_castpd256_pd512(a) simde_mm512_castpd256_pd512(a)
165 #endif
166
167 SIMDE_FUNCTION_ATTRIBUTES
168 simde__m128d
169 simde_mm512_castpd512_pd128 (simde__m512d a) {
170 #if defined(SIMDE_X86_AVX512F_NATIVE)
171 return _mm512_castpd512_pd128(a);
172 #else
173 simde__m512d_private a_ = simde__m512d_to_private(a);
174 return a_.m128d[0];
175 #endif
176 }
177 #if defined(SIMDE_X86_AVX512F_ENABLE_NATIVE_ALIASES)
178 #undef _mm512_castpd512_pd128
179 #define _mm512_castpd512_pd128(a) simde_mm512_castpd512_pd128(a)
180 #endif
181
182 SIMDE_FUNCTION_ATTRIBUTES
183 simde__m256d
184 simde_mm512_castpd512_pd256 (simde__m512d a) {
185 #if defined(SIMDE_X86_AVX512F_NATIVE)
186 return _mm512_castpd512_pd256(a);
187 #else
188 simde__m512d_private a_ = simde__m512d_to_private(a);
189 return a_.m256d[0];
190 #endif
191 }
192 #if defined(SIMDE_X86_AVX512F_ENABLE_NATIVE_ALIASES)
193 #undef _mm512_castpd512_pd256
194 #define _mm512_castpd512_pd256(a) simde_mm512_castpd512_pd256(a)
195 #endif
196
197 SIMDE_FUNCTION_ATTRIBUTES
198 simde__m512
199 simde_mm512_castps128_ps512 (simde__m128 a) {
200 #if defined(SIMDE_X86_AVX512F_NATIVE)
201 return _mm512_castps128_ps512(a);
202 #else
203 simde__m512_private r_;
204 r_.m128[0] = a;
205 return simde__m512_from_private(r_);
206 #endif
207 }
208 #if defined(SIMDE_X86_AVX512F_ENABLE_NATIVE_ALIASES)
209 #undef _mm512_castps128_ps512
210 #define _mm512_castps128_ps512(a) simde_mm512_castps128_ps512(a)
211 #endif
212
213 SIMDE_FUNCTION_ATTRIBUTES
214 simde__m512
215 simde_mm512_castps256_ps512 (simde__m256 a) {
216 #if defined(SIMDE_X86_AVX512F_NATIVE)
217 return _mm512_castps256_ps512(a);
218 #else
219 simde__m512_private r_;
220 r_.m256[0] = a;
221 return simde__m512_from_private(r_);
222 #endif
223 }
224 #if defined(SIMDE_X86_AVX512F_ENABLE_NATIVE_ALIASES)
225 #undef _mm512_castps256_ps512
226 #define _mm512_castps256_ps512(a) simde_mm512_castps256_ps512(a)
227 #endif
228
229 SIMDE_FUNCTION_ATTRIBUTES
230 simde__m128
231 simde_mm512_castps512_ps128 (simde__m512 a) {
232 #if defined(SIMDE_X86_AVX512F_NATIVE)
233 return _mm512_castps512_ps128(a);
234 #else
235 simde__m512_private a_ = simde__m512_to_private(a);
236 return a_.m128[0];
237 #endif
238 }
239 #if defined(SIMDE_X86_AVX512F_ENABLE_NATIVE_ALIASES)
240 #undef _mm512_castps512_ps128
241 #define _mm512_castps512_ps128(a) simde_mm512_castps512_ps128(a)
242 #endif
243
244 SIMDE_FUNCTION_ATTRIBUTES
245 simde__m256
246 simde_mm512_castps512_ps256 (simde__m512 a) {
247 #if defined(SIMDE_X86_AVX512F_NATIVE)
248 return _mm512_castps512_ps256(a);
249 #else
250 simde__m512_private a_ = simde__m512_to_private(a);
251 return a_.m256[0];
252 #endif
253 }
254 #if defined(SIMDE_X86_AVX512F_ENABLE_NATIVE_ALIASES)
255 #undef _mm512_castps512_ps256
256 #define _mm512_castps512_ps256(a) simde_mm512_castps512_ps256(a)
257 #endif
258
259 SIMDE_FUNCTION_ATTRIBUTES
260 simde__m512i
261 simde_mm512_castsi128_si512 (simde__m128i a) {
262 #if defined(SIMDE_X86_AVX512F_NATIVE)
263 return _mm512_castsi128_si512(a);
264 #else
265 simde__m512i_private r_;
266 r_.m128i[0] = a;
267 return simde__m512i_from_private(r_);
268 #endif
269 }
270 #if defined(SIMDE_X86_AVX512F_ENABLE_NATIVE_ALIASES)
271 #undef _mm512_castsi128_si512
272 #define _mm512_castsi128_si512(a) simde_mm512_castsi128_si512(a)
273 #endif
274
275 SIMDE_FUNCTION_ATTRIBUTES
276 simde__m512i
277 simde_mm512_castsi256_si512 (simde__m256i a) {
278 #if defined(SIMDE_X86_AVX512F_NATIVE)
279 return _mm512_castsi256_si512(a);
280 #else
281 simde__m512i_private r_;
282 r_.m256i[0] = a;
283 return simde__m512i_from_private(r_);
284 #endif
285 }
286 #if defined(SIMDE_X86_AVX512F_ENABLE_NATIVE_ALIASES)
287 #undef _mm512_castsi256_si512
288 #define _mm512_castsi256_si512(a) simde_mm512_castsi256_si512(a)
289 #endif
290
291 SIMDE_FUNCTION_ATTRIBUTES
292 simde__m128i
293 simde_mm512_castsi512_si128 (simde__m512i a) {
294 #if defined(SIMDE_X86_AVX512F_NATIVE)
295 return _mm512_castsi512_si128(a);
296 #else
297 simde__m512i_private a_ = simde__m512i_to_private(a);
298 return a_.m128i[0];
299 #endif
300 }
301 #if defined(SIMDE_X86_AVX512F_ENABLE_NATIVE_ALIASES)
302 #undef _mm512_castsi512_si128
303 #define _mm512_castsi512_si128(a) simde_mm512_castsi512_si128(a)
304 #endif
305
306 SIMDE_FUNCTION_ATTRIBUTES
307 simde__m256i
308 simde_mm512_castsi512_si256 (simde__m512i a) {
309 #if defined(SIMDE_X86_AVX512F_NATIVE)
310 return _mm512_castsi512_si256(a);
311 #else
312 simde__m512i_private a_ = simde__m512i_to_private(a);
313 return a_.m256i[0];
314 #endif
315 }
316 #if defined(SIMDE_X86_AVX512F_ENABLE_NATIVE_ALIASES)
317 #undef _mm512_castsi512_si256
318 #define _mm512_castsi512_si256(a) simde_mm512_castsi512_si256(a)
319 #endif
320
321 SIMDE_END_DECLS_
322 HEDLEY_DIAGNOSTIC_POP
323
324 #endif /* !defined(SIMDE_X86_AVX512_CAST_H) */