native 0.0.1
Vectors, masks and wide register packs for C++26
Loading...
Searching...
No Matches
native.arm.fcma.ccm
1// SPDX-License-Identifier: BSD-2-Clause OR Apache-2.0
2module;
3#include "native/isa_import.h"
4#include "native/arm/neon.h"
5#include "native/arm/fcma.h"
6#include "native/detail/constexpr_float.h"
7#include "native/arm/float_control.h"
8import native.simd;
9#if NATIVE_HOST_NEON || defined(NATIVE_DOXYGEN)
10namespace native::detail {
11 template<class T> using fcma_format=std::conditional_t<std::same_as<T,fp16>,
12 constexpr_float::binary16,std::conditional_t<std::same_as<T,float>,
13 constexpr_float::binary32,constexpr_float::binary64>>;
14
15 template<class T,std::size_t N,isa<arm> Arch>
16 constexpr auto fcma_bits(simd<T,N,Arch> value) noexcept {
17 using word=typename fcma_format<T>::bits_type;
18 std::array<word,N> result{};
19 if constexpr(std::same_as<T,double>) {
20 std::array<double,N> values{};value.store(values.data());
21 result=std::bit_cast<std::array<word,N>>(values);
22 } else value.store_bits(result.data());
23 return result;
24 }
25 template<class T,std::size_t N,isa<arm> Arch>
26 constexpr simd<T,N,Arch> fcma_from_bits(std::array<typename fcma_format<T>::bits_type,N> bits) noexcept {
27 if constexpr(std::same_as<T,double>) {
28 auto values=std::bit_cast<std::array<double,N>>(bits);
29 return simd<T,N,Arch>::load(values.data());
30 } else return simd<T,N,Arch>::load_bits(bits.data());
31 }
32 template<unsigned Rotation,class T,std::size_t N,isa<arm> Arch>
33 constexpr simd<T,N,Arch> fcadd_value(simd<T,N,Arch> a,simd<T,N,Arch> b,
34 arm_float_control control={}) noexcept {
35 using F=fcma_format<T>;
36 auto av=fcma_bits(a),bv=fcma_bits(b);
37 for(std::size_t i=0;i<N;i+=2) {
38 av[i]=constexpr_float::add_bits<F>(av[i],(Rotation==90?control.negate<F>(bv[i+1]):bv[i+1]),control.rounding_mode(),control.policy<F>());
39 av[i+1]=constexpr_float::add_bits<F>(av[i+1],(Rotation==270?control.negate<F>(bv[i]):bv[i]),control.rounding_mode(),control.policy<F>());
40 }
41 return fcma_from_bits<T,N,Arch>(av);
42 }
43 template<unsigned Rotation,int Lane,class T,std::size_t N,std::size_t M,isa<arm> Arch>
44 constexpr simd<T,N,Arch> fcmla_value(simd<T,N,Arch> acc,
45 simd<T,N,Arch> a,simd<T,M,Arch> b,arm_float_control control={}) noexcept {
46 using F=fcma_format<T>;
47 auto cv=fcma_bits(acc);auto av=fcma_bits(a);auto bv=fcma_bits(b);
48 for(std::size_t i=0;i<N;i+=2) {
49 auto index=Lane<0?i:2*Lane;
50 auto factor=av[i+(Rotation==90 || Rotation==270)];
51 auto real=bv[index+(Rotation==90 || Rotation==270)];
52 auto imag=bv[index+(Rotation==0 || Rotation==180)];
53 if constexpr(Rotation==90 || Rotation==180) real=control.negate<F>(real);
54 if constexpr(Rotation==180 || Rotation==270) imag=control.negate<F>(imag);
55 cv[i]=constexpr_float::fma_bits<F>(factor,real,cv[i],control.rounding_mode(),control.policy<F>());
56 cv[i+1]=constexpr_float::fma_bits<F>(factor,imag,cv[i+1],control.rounding_mode(),control.policy<F>());
57 }
58 return fcma_from_bits<T,N,Arch>(cv);
59 }
60}
61namespace native {
77
78 // All vector operands share Arch; native registers remain implementation details.
80 template<isa<arm> Arch, unsigned Rotation> requires(Arch.has(arm_feature::complxnum)
81 && (Rotation == 90 || Rotation == 270))
82 [[nodiscard]] hint_inline hint_target("complxnum")
83 constexpr simd<float, 2, Arch> fcadd(simd<float, 2, Arch> a, simd<float, 2, Arch> b) noexcept {
84 if consteval { return detail::fcadd_value<Rotation>(a,b); } else {
85 auto result = detail::fcadd<Arch, Rotation>(
86 vget_low_f32(detail::arm_neon::to_register<float32x4_t>(a)),
87 vget_low_f32(detail::arm_neon::to_register<float32x4_t>(b)));
88 return detail::arm_neon::from_register<simd<float, 2, Arch>>(vcombine_f32(result, vdup_n_f32(0.f)));
89 }
90 }
91
93 template<isa<arm> Arch, unsigned Rotation> requires(!Arch.has(polyfill) && requires { sizeof(simd<float, 2, Arch>); } && !(Arch.has(arm_feature::complxnum))
94 && (Rotation == 90 || Rotation == 270))
95 [[nodiscard]] consteval
97 return detail::fcadd_value<Rotation>(a,b);
98 }
99
101 template<isa<arm> Arch, unsigned Rotation> requires(Arch.has(polyfill) && requires { sizeof(simd<float, 2, Arch>); } && !(Arch.has(arm_feature::complxnum))
102 && (Rotation == 90 || Rotation == 270))
103 [[nodiscard]] constexpr
105 return detail::fcadd_value<Rotation>(a,b, detail::arm_float_control::current());
106 }
107
109 template<isa<arm> Arch, unsigned Rotation> requires(Arch.has(arm_feature::complxnum)
110 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270))
111 [[nodiscard]] hint_inline hint_target("complxnum")
115 simd<float, 2, Arch> b) noexcept {
116 if consteval { return detail::fcmla_value<Rotation,-1>(acc,a,b); } else {
117 auto result = detail::fcmla<Arch, Rotation>(
118 vget_low_f32(detail::arm_neon::to_register<float32x4_t>(acc)),
119 vget_low_f32(detail::arm_neon::to_register<float32x4_t>(a)),
120 vget_low_f32(detail::arm_neon::to_register<float32x4_t>(b)));
121 return detail::arm_neon::from_register<simd<float, 2, Arch>>(vcombine_f32(result, vdup_n_f32(0.f)));
122 }
123 }
124
126 template<isa<arm> Arch, unsigned Rotation> requires(!Arch.has(polyfill) && requires { sizeof(simd<float, 2, Arch>); } && !(Arch.has(arm_feature::complxnum))
127 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270))
128 [[nodiscard]] consteval
132 simd<float, 2, Arch> b) noexcept {
133 return detail::fcmla_value<Rotation,-1>(acc,a,b);
134 }
135
137 template<isa<arm> Arch, unsigned Rotation> requires(Arch.has(polyfill) && requires { sizeof(simd<float, 2, Arch>); } && !(Arch.has(arm_feature::complxnum))
138 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270))
139 [[nodiscard]] constexpr
143 simd<float, 2, Arch> b) noexcept {
144 return detail::fcmla_value<Rotation,-1>(acc,a,b, detail::arm_float_control::current());
145 }
146
148 template<isa<arm> Arch, unsigned Rotation, unsigned Lane>
149 requires(Arch.has(arm_feature::complxnum)
150 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270)
151 && Lane < 1)
152 [[nodiscard]] hint_inline hint_target("complxnum")
156 simd<float, 2, Arch> b) noexcept {
157 if consteval { return detail::fcmla_value<Rotation,Lane>(acc,a,b); } else {
158 auto result = detail::fcmla_lane<Arch, Rotation, Lane>(
159 vget_low_f32(detail::arm_neon::to_register<float32x4_t>(acc)),
160 vget_low_f32(detail::arm_neon::to_register<float32x4_t>(a)),
161 vget_low_f32(detail::arm_neon::to_register<float32x4_t>(b)));
162 return detail::arm_neon::from_register<simd<float, 2, Arch>>(vcombine_f32(result, vdup_n_f32(0.f)));
163 }
164 }
165
167 template<isa<arm> Arch, unsigned Rotation, unsigned Lane>
168 requires(!Arch.has(polyfill) && requires { sizeof(simd<float, 2, Arch>); } && !(Arch.has(arm_feature::complxnum))
169 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270)
170 && Lane < 1)
171 [[nodiscard]] consteval
175 simd<float, 2, Arch> b) noexcept {
176 return detail::fcmla_value<Rotation,Lane>(acc,a,b);
177 }
178
180 template<isa<arm> Arch, unsigned Rotation, unsigned Lane>
181 requires(Arch.has(polyfill) && requires { sizeof(simd<float, 2, Arch>); } && !(Arch.has(arm_feature::complxnum))
182 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270)
183 && Lane < 1)
184 [[nodiscard]] constexpr
188 simd<float, 2, Arch> b) noexcept {
189 return detail::fcmla_value<Rotation,Lane>(acc,a,b, detail::arm_float_control::current());
190 }
191
193 template<isa<arm> Arch, unsigned Rotation, unsigned Lane>
194 requires(Arch.has(arm_feature::complxnum)
195 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270)
196 && Lane < 2)
197 [[nodiscard]] hint_inline hint_target("complxnum")
201 simd<float, 4, Arch> b) noexcept {
202 if consteval { return detail::fcmla_value<Rotation,Lane>(acc,a,b); } else {
203 auto result = detail::fcmla_lane<Arch, Rotation, Lane>(
204 vget_low_f32(detail::arm_neon::to_register<float32x4_t>(acc)),
205 vget_low_f32(detail::arm_neon::to_register<float32x4_t>(a)),
206 detail::arm_neon::to_register<float32x4_t>(b));
207 return detail::arm_neon::from_register<simd<float, 2, Arch>>(vcombine_f32(result, vdup_n_f32(0.f)));
208 }
209 }
210
212 template<isa<arm> Arch, unsigned Rotation, unsigned Lane>
213 requires(!Arch.has(polyfill) && requires { sizeof(simd<float, 2, Arch>); } && requires { sizeof(simd<float, 4, Arch>); } && !(Arch.has(arm_feature::complxnum))
214 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270)
215 && Lane < 2)
216 [[nodiscard]] consteval
220 simd<float, 4, Arch> b) noexcept {
221 return detail::fcmla_value<Rotation,Lane>(acc,a,b);
222 }
223
225 template<isa<arm> Arch, unsigned Rotation, unsigned Lane>
226 requires(Arch.has(polyfill) && requires { sizeof(simd<float, 2, Arch>); } && requires { sizeof(simd<float, 4, Arch>); } && !(Arch.has(arm_feature::complxnum))
227 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270)
228 && Lane < 2)
229 [[nodiscard]] constexpr
233 simd<float, 4, Arch> b) noexcept {
234 return detail::fcmla_value<Rotation,Lane>(acc,a,b, detail::arm_float_control::current());
235 }
236
238 template<isa<arm> Arch, unsigned Rotation> requires(Arch.has(arm_feature::complxnum)
239 && (Rotation == 90 || Rotation == 270))
240 [[nodiscard]] hint_inline hint_target("complxnum")
242 if consteval { return detail::fcadd_value<Rotation>(a,b); } else {
243 auto result = detail::fcadd<Arch, Rotation>(
244 detail::arm_neon::to_register<float32x4_t>(a),
245 detail::arm_neon::to_register<float32x4_t>(b));
246 return simd<float, 4, Arch>::from_native(__builtin_bit_cast(typename simd<float, 4, Arch>::native_type, result));
247 }
248 }
249
251 template<isa<arm> Arch, unsigned Rotation> requires(!Arch.has(polyfill) && requires { sizeof(simd<float, 4, Arch>); } && !(Arch.has(arm_feature::complxnum))
252 && (Rotation == 90 || Rotation == 270))
253 [[nodiscard]] consteval
255 return detail::fcadd_value<Rotation>(a,b);
256 }
257
259 template<isa<arm> Arch, unsigned Rotation> requires(Arch.has(polyfill) && requires { sizeof(simd<float, 4, Arch>); } && !(Arch.has(arm_feature::complxnum))
260 && (Rotation == 90 || Rotation == 270))
261 [[nodiscard]] constexpr
263 return detail::fcadd_value<Rotation>(a,b, detail::arm_float_control::current());
264 }
265
267 template<isa<arm> Arch, unsigned Rotation> requires(Arch.has(arm_feature::complxnum)
268 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270))
269 [[nodiscard]] hint_inline hint_target("complxnum")
273 simd<float, 4, Arch> b) noexcept {
274 if consteval { return detail::fcmla_value<Rotation,-1>(acc,a,b); } else {
275 auto result = detail::fcmla<Arch, Rotation>(
276 detail::arm_neon::to_register<float32x4_t>(acc),
277 detail::arm_neon::to_register<float32x4_t>(a),
278 detail::arm_neon::to_register<float32x4_t>(b));
279 return simd<float, 4, Arch>::from_native(__builtin_bit_cast(typename simd<float, 4, Arch>::native_type, result));
280 }
281 }
282
284 template<isa<arm> Arch, unsigned Rotation> requires(!Arch.has(polyfill) && requires { sizeof(simd<float, 4, Arch>); } && !(Arch.has(arm_feature::complxnum))
285 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270))
286 [[nodiscard]] consteval
290 simd<float, 4, Arch> b) noexcept {
291 return detail::fcmla_value<Rotation,-1>(acc,a,b);
292 }
293
295 template<isa<arm> Arch, unsigned Rotation> requires(Arch.has(polyfill) && requires { sizeof(simd<float, 4, Arch>); } && !(Arch.has(arm_feature::complxnum))
296 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270))
297 [[nodiscard]] constexpr
301 simd<float, 4, Arch> b) noexcept {
302 return detail::fcmla_value<Rotation,-1>(acc,a,b, detail::arm_float_control::current());
303 }
304
306 template<isa<arm> Arch, unsigned Rotation, unsigned Lane>
307 requires(Arch.has(arm_feature::complxnum)
308 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270)
309 && Lane < 1)
310 [[nodiscard]] hint_inline hint_target("complxnum")
314 simd<float, 2, Arch> b) noexcept {
315 if consteval { return detail::fcmla_value<Rotation,Lane>(acc,a,b); } else {
316 auto result = detail::fcmla_lane<Arch, Rotation, Lane>(
317 detail::arm_neon::to_register<float32x4_t>(acc),
318 detail::arm_neon::to_register<float32x4_t>(a),
319 vget_low_f32(detail::arm_neon::to_register<float32x4_t>(b)));
320 return simd<float, 4, Arch>::from_native(__builtin_bit_cast(typename simd<float, 4, Arch>::native_type, result));
321 }
322 }
323
325 template<isa<arm> Arch, unsigned Rotation, unsigned Lane>
326 requires(!Arch.has(polyfill) && requires { sizeof(simd<float, 4, Arch>); } && requires { sizeof(simd<float, 2, Arch>); } && !(Arch.has(arm_feature::complxnum))
327 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270)
328 && Lane < 1)
329 [[nodiscard]] consteval
333 simd<float, 2, Arch> b) noexcept {
334 return detail::fcmla_value<Rotation,Lane>(acc,a,b);
335 }
336
338 template<isa<arm> Arch, unsigned Rotation, unsigned Lane>
339 requires(Arch.has(polyfill) && requires { sizeof(simd<float, 4, Arch>); } && requires { sizeof(simd<float, 2, Arch>); } && !(Arch.has(arm_feature::complxnum))
340 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270)
341 && Lane < 1)
342 [[nodiscard]] constexpr
346 simd<float, 2, Arch> b) noexcept {
347 return detail::fcmla_value<Rotation,Lane>(acc,a,b, detail::arm_float_control::current());
348 }
349
351 template<isa<arm> Arch, unsigned Rotation, unsigned Lane>
352 requires(Arch.has(arm_feature::complxnum)
353 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270)
354 && Lane < 2)
355 [[nodiscard]] hint_inline hint_target("complxnum")
359 simd<float, 4, Arch> b) noexcept {
360 if consteval { return detail::fcmla_value<Rotation,Lane>(acc,a,b); } else {
361 auto result = detail::fcmla_lane<Arch, Rotation, Lane>(
362 detail::arm_neon::to_register<float32x4_t>(acc),
363 detail::arm_neon::to_register<float32x4_t>(a),
364 detail::arm_neon::to_register<float32x4_t>(b));
365 return simd<float, 4, Arch>::from_native(__builtin_bit_cast(typename simd<float, 4, Arch>::native_type, result));
366 }
367 }
368
370 template<isa<arm> Arch, unsigned Rotation, unsigned Lane>
371 requires(!Arch.has(polyfill) && requires { sizeof(simd<float, 4, Arch>); } && !(Arch.has(arm_feature::complxnum))
372 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270)
373 && Lane < 2)
374 [[nodiscard]] consteval
378 simd<float, 4, Arch> b) noexcept {
379 return detail::fcmla_value<Rotation,Lane>(acc,a,b);
380 }
381
383 template<isa<arm> Arch, unsigned Rotation, unsigned Lane>
384 requires(Arch.has(polyfill) && requires { sizeof(simd<float, 4, Arch>); } && !(Arch.has(arm_feature::complxnum))
385 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270)
386 && Lane < 2)
387 [[nodiscard]] constexpr
391 simd<float, 4, Arch> b) noexcept {
392 return detail::fcmla_value<Rotation,Lane>(acc,a,b, detail::arm_float_control::current());
393 }
394
396 template<isa<arm> Arch, unsigned Rotation> requires(Arch.has(arm_feature::complxnum)
397 && (Rotation == 90 || Rotation == 270))
398 [[nodiscard]] hint_inline hint_target("complxnum")
400 if consteval { return detail::fcadd_value<Rotation>(a,b); } else {
401 auto result = detail::fcadd<Arch, Rotation>(
402 detail::arm_neon::to_register<float64x2_t>(a),
403 detail::arm_neon::to_register<float64x2_t>(b));
404 return simd<double, 2, Arch>::from_native(__builtin_bit_cast(typename simd<double, 2, Arch>::native_type, result));
405 }
406 }
407
409 template<isa<arm> Arch, unsigned Rotation> requires(!Arch.has(polyfill) && requires { sizeof(simd<double, 2, Arch>); } && !(Arch.has(arm_feature::complxnum))
410 && (Rotation == 90 || Rotation == 270))
411 [[nodiscard]] consteval
413 return detail::fcadd_value<Rotation>(a,b);
414 }
415
417 template<isa<arm> Arch, unsigned Rotation> requires(Arch.has(polyfill) && requires { sizeof(simd<double, 2, Arch>); } && !(Arch.has(arm_feature::complxnum))
418 && (Rotation == 90 || Rotation == 270))
419 [[nodiscard]] constexpr
421 return detail::fcadd_value<Rotation>(a,b, detail::arm_float_control::current());
422 }
423
425 template<isa<arm> Arch, unsigned Rotation> requires(Arch.has(arm_feature::complxnum)
426 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270))
427 [[nodiscard]] hint_inline hint_target("complxnum")
431 simd<double, 2, Arch> b) noexcept {
432 if consteval { return detail::fcmla_value<Rotation,-1>(acc,a,b); } else {
433 auto result = detail::fcmla<Arch, Rotation>(
434 detail::arm_neon::to_register<float64x2_t>(acc),
435 detail::arm_neon::to_register<float64x2_t>(a),
436 detail::arm_neon::to_register<float64x2_t>(b));
437 return simd<double, 2, Arch>::from_native(__builtin_bit_cast(typename simd<double, 2, Arch>::native_type, result));
438 }
439 }
440
442 template<isa<arm> Arch, unsigned Rotation> requires(!Arch.has(polyfill) && requires { sizeof(simd<double, 2, Arch>); } && !(Arch.has(arm_feature::complxnum))
443 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270))
444 [[nodiscard]] consteval
448 simd<double, 2, Arch> b) noexcept {
449 return detail::fcmla_value<Rotation,-1>(acc,a,b);
450 }
451
453 template<isa<arm> Arch, unsigned Rotation> requires(Arch.has(polyfill) && requires { sizeof(simd<double, 2, Arch>); } && !(Arch.has(arm_feature::complxnum))
454 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270))
455 [[nodiscard]] constexpr
459 simd<double, 2, Arch> b) noexcept {
460 return detail::fcmla_value<Rotation,-1>(acc,a,b, detail::arm_float_control::current());
461 }
462
464 template<isa<arm> Arch, unsigned Rotation> requires(Arch.has(arm_feature::complxnum) && Arch.has(arm_feature::neon_fp16)
465 && (Rotation == 90 || Rotation == 270))
466 [[nodiscard]] hint_inline hint_target("complxnum,fullfp16")
468 if consteval { return detail::fcadd_value<Rotation>(a,b); } else {
469 auto result = detail::fcadd<Arch, Rotation>(
470 __builtin_bit_cast(float16x4_t, a.to_native()),
471 __builtin_bit_cast(float16x4_t, b.to_native()));
472 return simd<fp16, 4, Arch>::from_native(__builtin_bit_cast(typename simd<fp16, 4, Arch>::native_type, result));
473 }
474 }
475
477 template<isa<arm> Arch, unsigned Rotation> requires(!Arch.has(polyfill) && requires { sizeof(simd<fp16, 4, Arch>); } && !(Arch.has(arm_feature::complxnum) && Arch.has(arm_feature::neon_fp16))
478 && (Rotation == 90 || Rotation == 270))
479 [[nodiscard]] consteval
481 return detail::fcadd_value<Rotation>(a,b);
482 }
483
485 template<isa<arm> Arch, unsigned Rotation> requires(Arch.has(polyfill) && requires { sizeof(simd<fp16, 4, Arch>); } && !(Arch.has(arm_feature::complxnum) && Arch.has(arm_feature::neon_fp16))
486 && (Rotation == 90 || Rotation == 270))
487 [[nodiscard]] constexpr
489 return detail::fcadd_value<Rotation>(a,b, detail::arm_float_control::current());
490 }
491
493 template<isa<arm> Arch, unsigned Rotation> requires(Arch.has(arm_feature::complxnum) && Arch.has(arm_feature::neon_fp16)
494 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270))
495 [[nodiscard]] hint_inline hint_target("complxnum,fullfp16")
499 simd<fp16, 4, Arch> b) noexcept {
500 if consteval { return detail::fcmla_value<Rotation,-1>(acc,a,b); } else {
501 auto result = detail::fcmla<Arch, Rotation>(
502 __builtin_bit_cast(float16x4_t, acc.to_native()),
503 __builtin_bit_cast(float16x4_t, a.to_native()),
504 __builtin_bit_cast(float16x4_t, b.to_native()));
505 return simd<fp16, 4, Arch>::from_native(__builtin_bit_cast(typename simd<fp16, 4, Arch>::native_type, result));
506 }
507 }
508
510 template<isa<arm> Arch, unsigned Rotation> requires(!Arch.has(polyfill) && requires { sizeof(simd<fp16, 4, Arch>); } && !(Arch.has(arm_feature::complxnum) && Arch.has(arm_feature::neon_fp16))
511 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270))
512 [[nodiscard]] consteval
516 simd<fp16, 4, Arch> b) noexcept {
517 return detail::fcmla_value<Rotation,-1>(acc,a,b);
518 }
519
521 template<isa<arm> Arch, unsigned Rotation> requires(Arch.has(polyfill) && requires { sizeof(simd<fp16, 4, Arch>); } && !(Arch.has(arm_feature::complxnum) && Arch.has(arm_feature::neon_fp16))
522 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270))
523 [[nodiscard]] constexpr
527 simd<fp16, 4, Arch> b) noexcept {
528 return detail::fcmla_value<Rotation,-1>(acc,a,b, detail::arm_float_control::current());
529 }
530
532 template<isa<arm> Arch, unsigned Rotation, unsigned Lane>
533 requires(Arch.has(arm_feature::complxnum) && Arch.has(arm_feature::neon_fp16)
534 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270)
535 && Lane < 2)
536 [[nodiscard]] hint_inline hint_target("complxnum,fullfp16")
540 simd<fp16, 4, Arch> b) noexcept {
541 if consteval { return detail::fcmla_value<Rotation,Lane>(acc,a,b); } else {
542 auto result = detail::fcmla_lane<Arch, Rotation, Lane>(
543 __builtin_bit_cast(float16x4_t, acc.to_native()),
544 __builtin_bit_cast(float16x4_t, a.to_native()),
545 __builtin_bit_cast(float16x4_t, b.to_native()));
546 return simd<fp16, 4, Arch>::from_native(__builtin_bit_cast(typename simd<fp16, 4, Arch>::native_type, result));
547 }
548 }
549
551 template<isa<arm> Arch, unsigned Rotation, unsigned Lane>
552 requires(!Arch.has(polyfill) && requires { sizeof(simd<fp16, 4, Arch>); } && !(Arch.has(arm_feature::complxnum) && Arch.has(arm_feature::neon_fp16))
553 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270)
554 && Lane < 2)
555 [[nodiscard]] consteval
559 simd<fp16, 4, Arch> b) noexcept {
560 return detail::fcmla_value<Rotation,Lane>(acc,a,b);
561 }
562
564 template<isa<arm> Arch, unsigned Rotation, unsigned Lane>
565 requires(Arch.has(polyfill) && requires { sizeof(simd<fp16, 4, Arch>); } && !(Arch.has(arm_feature::complxnum) && Arch.has(arm_feature::neon_fp16))
566 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270)
567 && Lane < 2)
568 [[nodiscard]] constexpr
572 simd<fp16, 4, Arch> b) noexcept {
573 return detail::fcmla_value<Rotation,Lane>(acc,a,b, detail::arm_float_control::current());
574 }
575
577 template<isa<arm> Arch, unsigned Rotation, unsigned Lane>
578 requires(Arch.has(arm_feature::complxnum) && Arch.has(arm_feature::neon_fp16)
579 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270)
580 && Lane < 4)
581 [[nodiscard]] hint_inline hint_target("complxnum,fullfp16")
585 simd<fp16, 8, Arch> b) noexcept {
586 if consteval { return detail::fcmla_value<Rotation,Lane>(acc,a,b); } else {
587 auto result = detail::fcmla_lane<Arch, Rotation, Lane>(
588 __builtin_bit_cast(float16x4_t, acc.to_native()),
589 __builtin_bit_cast(float16x4_t, a.to_native()),
590 __builtin_bit_cast(float16x8_t, b.to_native()));
591 return simd<fp16, 4, Arch>::from_native(__builtin_bit_cast(typename simd<fp16, 4, Arch>::native_type, result));
592 }
593 }
594
596 template<isa<arm> Arch, unsigned Rotation, unsigned Lane>
597 requires(!Arch.has(polyfill) && requires { sizeof(simd<fp16, 4, Arch>); } && requires { sizeof(simd<fp16, 8, Arch>); } && !(Arch.has(arm_feature::complxnum) && Arch.has(arm_feature::neon_fp16))
598 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270)
599 && Lane < 4)
600 [[nodiscard]] consteval
604 simd<fp16, 8, Arch> b) noexcept {
605 return detail::fcmla_value<Rotation,Lane>(acc,a,b);
606 }
607
609 template<isa<arm> Arch, unsigned Rotation, unsigned Lane>
610 requires(Arch.has(polyfill) && requires { sizeof(simd<fp16, 4, Arch>); } && requires { sizeof(simd<fp16, 8, Arch>); } && !(Arch.has(arm_feature::complxnum) && Arch.has(arm_feature::neon_fp16))
611 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270)
612 && Lane < 4)
613 [[nodiscard]] constexpr
617 simd<fp16, 8, Arch> b) noexcept {
618 return detail::fcmla_value<Rotation,Lane>(acc,a,b, detail::arm_float_control::current());
619 }
620
622 template<isa<arm> Arch, unsigned Rotation> requires(Arch.has(arm_feature::complxnum) && Arch.has(arm_feature::neon_fp16)
623 && (Rotation == 90 || Rotation == 270))
624 [[nodiscard]] hint_inline hint_target("complxnum,fullfp16")
626 if consteval { return detail::fcadd_value<Rotation>(a,b); } else {
627 auto result = detail::fcadd<Arch, Rotation>(
628 __builtin_bit_cast(float16x8_t, a.to_native()),
629 __builtin_bit_cast(float16x8_t, b.to_native()));
630 return simd<fp16, 8, Arch>::from_native(__builtin_bit_cast(typename simd<fp16, 8, Arch>::native_type, result));
631 }
632 }
633
635 template<isa<arm> Arch, unsigned Rotation> requires(!Arch.has(polyfill) && requires { sizeof(simd<fp16, 8, Arch>); } && !(Arch.has(arm_feature::complxnum) && Arch.has(arm_feature::neon_fp16))
636 && (Rotation == 90 || Rotation == 270))
637 [[nodiscard]] consteval
639 return detail::fcadd_value<Rotation>(a,b);
640 }
641
643 template<isa<arm> Arch, unsigned Rotation> requires(Arch.has(polyfill) && requires { sizeof(simd<fp16, 8, Arch>); } && !(Arch.has(arm_feature::complxnum) && Arch.has(arm_feature::neon_fp16))
644 && (Rotation == 90 || Rotation == 270))
645 [[nodiscard]] constexpr
647 return detail::fcadd_value<Rotation>(a,b, detail::arm_float_control::current());
648 }
649
651 template<isa<arm> Arch, unsigned Rotation> requires(Arch.has(arm_feature::complxnum) && Arch.has(arm_feature::neon_fp16)
652 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270))
653 [[nodiscard]] hint_inline hint_target("complxnum,fullfp16")
657 simd<fp16, 8, Arch> b) noexcept {
658 if consteval { return detail::fcmla_value<Rotation,-1>(acc,a,b); } else {
659 auto result = detail::fcmla<Arch, Rotation>(
660 __builtin_bit_cast(float16x8_t, acc.to_native()),
661 __builtin_bit_cast(float16x8_t, a.to_native()),
662 __builtin_bit_cast(float16x8_t, b.to_native()));
663 return simd<fp16, 8, Arch>::from_native(__builtin_bit_cast(typename simd<fp16, 8, Arch>::native_type, result));
664 }
665 }
666
668 template<isa<arm> Arch, unsigned Rotation> requires(!Arch.has(polyfill) && requires { sizeof(simd<fp16, 8, Arch>); } && !(Arch.has(arm_feature::complxnum) && Arch.has(arm_feature::neon_fp16))
669 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270))
670 [[nodiscard]] consteval
674 simd<fp16, 8, Arch> b) noexcept {
675 return detail::fcmla_value<Rotation,-1>(acc,a,b);
676 }
677
679 template<isa<arm> Arch, unsigned Rotation> requires(Arch.has(polyfill) && requires { sizeof(simd<fp16, 8, Arch>); } && !(Arch.has(arm_feature::complxnum) && Arch.has(arm_feature::neon_fp16))
680 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270))
681 [[nodiscard]] constexpr
685 simd<fp16, 8, Arch> b) noexcept {
686 return detail::fcmla_value<Rotation,-1>(acc,a,b, detail::arm_float_control::current());
687 }
688
690 template<isa<arm> Arch, unsigned Rotation, unsigned Lane>
691 requires(Arch.has(arm_feature::complxnum) && Arch.has(arm_feature::neon_fp16)
692 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270)
693 && Lane < 2)
694 [[nodiscard]] hint_inline hint_target("complxnum,fullfp16")
698 simd<fp16, 4, Arch> b) noexcept {
699 if consteval { return detail::fcmla_value<Rotation,Lane>(acc,a,b); } else {
700 auto result = detail::fcmla_lane<Arch, Rotation, Lane>(
701 __builtin_bit_cast(float16x8_t, acc.to_native()),
702 __builtin_bit_cast(float16x8_t, a.to_native()),
703 __builtin_bit_cast(float16x4_t, b.to_native()));
704 return simd<fp16, 8, Arch>::from_native(__builtin_bit_cast(typename simd<fp16, 8, Arch>::native_type, result));
705 }
706 }
707
709 template<isa<arm> Arch, unsigned Rotation, unsigned Lane>
710 requires(!Arch.has(polyfill) && requires { sizeof(simd<fp16, 8, Arch>); } && requires { sizeof(simd<fp16, 4, Arch>); } && !(Arch.has(arm_feature::complxnum) && Arch.has(arm_feature::neon_fp16))
711 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270)
712 && Lane < 2)
713 [[nodiscard]] consteval
717 simd<fp16, 4, Arch> b) noexcept {
718 return detail::fcmla_value<Rotation,Lane>(acc,a,b);
719 }
720
722 template<isa<arm> Arch, unsigned Rotation, unsigned Lane>
723 requires(Arch.has(polyfill) && requires { sizeof(simd<fp16, 8, Arch>); } && requires { sizeof(simd<fp16, 4, Arch>); } && !(Arch.has(arm_feature::complxnum) && Arch.has(arm_feature::neon_fp16))
724 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270)
725 && Lane < 2)
726 [[nodiscard]] constexpr
730 simd<fp16, 4, Arch> b) noexcept {
731 return detail::fcmla_value<Rotation,Lane>(acc,a,b, detail::arm_float_control::current());
732 }
733
735 template<isa<arm> Arch, unsigned Rotation, unsigned Lane>
736 requires(Arch.has(arm_feature::complxnum) && Arch.has(arm_feature::neon_fp16)
737 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270)
738 && Lane < 4)
739 [[nodiscard]] hint_inline hint_target("complxnum,fullfp16")
743 simd<fp16, 8, Arch> b) noexcept {
744 if consteval { return detail::fcmla_value<Rotation,Lane>(acc,a,b); } else {
745 auto result = detail::fcmla_lane<Arch, Rotation, Lane>(
746 __builtin_bit_cast(float16x8_t, acc.to_native()),
747 __builtin_bit_cast(float16x8_t, a.to_native()),
748 __builtin_bit_cast(float16x8_t, b.to_native()));
749 return simd<fp16, 8, Arch>::from_native(__builtin_bit_cast(typename simd<fp16, 8, Arch>::native_type, result));
750 }
751 }
752
754 template<isa<arm> Arch, unsigned Rotation, unsigned Lane>
755 requires(!Arch.has(polyfill) && requires { sizeof(simd<fp16, 8, Arch>); } && !(Arch.has(arm_feature::complxnum) && Arch.has(arm_feature::neon_fp16))
756 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270)
757 && Lane < 4)
758 [[nodiscard]] consteval
762 simd<fp16, 8, Arch> b) noexcept {
763 return detail::fcmla_value<Rotation,Lane>(acc,a,b);
764 }
765
767 template<isa<arm> Arch, unsigned Rotation, unsigned Lane>
768 requires(Arch.has(polyfill) && requires { sizeof(simd<fp16, 8, Arch>); } && !(Arch.has(arm_feature::complxnum) && Arch.has(arm_feature::neon_fp16))
769 && (Rotation == 0 || Rotation == 90 || Rotation == 180 || Rotation == 270)
770 && Lane < 4)
771 [[nodiscard]] constexpr
775 simd<fp16, 8, Arch> b) noexcept {
776 return detail::fcmla_value<Rotation,Lane>(acc,a,b, detail::arm_float_control::current());
777 }
778
780 template<isa<arm> Arch, unsigned Rotation, class A, class B>
781 void fcadd(A, B) = delete;
782 template<isa<arm> Arch, unsigned Rotation, class A, class B, class C>
783 void fcmla(A, B, C) = delete;
784 template<isa<arm> Arch, unsigned Rotation, unsigned Lane, class A, class B, class C>
785 void fcmla_lane(A, B, C) = delete;
788}
789#endif
790
791export module native.arm.fcma;
792export import native.arm.features;
793export import native.simd;
794
795#if NATIVE_HOST_NEON || defined(NATIVE_DOXYGEN)
796export namespace native {
797 using ::native::fcadd;
798 using ::native::fcmla;
799 using ::native::fcmla_lane;
800}
801#endif
constexpr simd< float, 2, Arch > fcmla_lane(simd< float, 2, Arch > acc, simd< float, 2, Arch > a, simd< float, 2, Arch > b) noexcept
FCMLA using complex pair Lane of b (the lane indexes pairs, not scalars).
constexpr simd< float, 2, Arch > fcadd(simd< float, 2, Arch > a, simd< float, 2, Arch > b) noexcept
FCADD on 1 binary32 complex pair(s), rotation in degrees.
constexpr simd< float, 2, Arch > fcmla(simd< float, 2, Arch > acc, simd< float, 2, Arch > a, simd< float, 2, Arch > b) noexcept
FCMLA on 1 binary32 complex pair(s), rotation in degrees.
Architecture-tagged vectors, register packs and supporting value types. Native arithmetic follows its...
static constexpr simd load_bits(std::uint32_t const *p) noexcept
Load exactly the logical count of binary32 words without normalizing their representations.
static constexpr simd load(T const *p) noexcept
Read all logical lanes from an unaligned element pointer.
Omitted architecture arguments use the native.simd provider's baseline.