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"
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>>;
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());
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);
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>());
41 return fcma_from_bits<T,N,Arch>(av);
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>());
58 return fcma_from_bits<T,N,Arch>(cv);
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)));
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);
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());
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")
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)));
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
133 return detail::fcmla_value<Rotation,-1>(acc,a,b);
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
144 return detail::fcmla_value<Rotation,-1>(acc,a,b, detail::arm_float_control::current());
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)
152 [[nodiscard]] hint_inline hint_target(
"complxnum")
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)));
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)
171 [[nodiscard]]
consteval
176 return detail::fcmla_value<Rotation,Lane>(acc,a,b);
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)
184 [[nodiscard]]
constexpr
189 return detail::fcmla_value<Rotation,Lane>(acc,a,b, detail::arm_float_control::current());
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)
197 [[nodiscard]] hint_inline hint_target(
"complxnum")
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)));
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)
216 [[nodiscard]]
consteval
221 return detail::fcmla_value<Rotation,Lane>(acc,a,b);
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)
229 [[nodiscard]]
constexpr
234 return detail::fcmla_value<Rotation,Lane>(acc,a,b, detail::arm_float_control::current());
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));
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);
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());
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")
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));
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
291 return detail::fcmla_value<Rotation,-1>(acc,a,b);
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
302 return detail::fcmla_value<Rotation,-1>(acc,a,b, detail::arm_float_control::current());
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)
310 [[nodiscard]] hint_inline hint_target(
"complxnum")
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)));
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)
329 [[nodiscard]]
consteval
334 return detail::fcmla_value<Rotation,Lane>(acc,a,b);
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)
342 [[nodiscard]]
constexpr
347 return detail::fcmla_value<Rotation,Lane>(acc,a,b, detail::arm_float_control::current());
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)
355 [[nodiscard]] hint_inline hint_target(
"complxnum")
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));
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)
374 [[nodiscard]]
consteval
379 return detail::fcmla_value<Rotation,Lane>(acc,a,b);
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)
387 [[nodiscard]]
constexpr
392 return detail::fcmla_value<Rotation,Lane>(acc,a,b, detail::arm_float_control::current());
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));
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);
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());
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")
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));
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
449 return detail::fcmla_value<Rotation,-1>(acc,a,b);
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
460 return detail::fcmla_value<Rotation,-1>(acc,a,b, detail::arm_float_control::current());
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()));
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);
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());
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")
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()));
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
517 return detail::fcmla_value<Rotation,-1>(acc,a,b);
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
528 return detail::fcmla_value<Rotation,-1>(acc,a,b, detail::arm_float_control::current());
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)
536 [[nodiscard]] hint_inline hint_target(
"complxnum,fullfp16")
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()));
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)
555 [[nodiscard]]
consteval
560 return detail::fcmla_value<Rotation,Lane>(acc,a,b);
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)
568 [[nodiscard]]
constexpr
573 return detail::fcmla_value<Rotation,Lane>(acc,a,b, detail::arm_float_control::current());
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)
581 [[nodiscard]] hint_inline hint_target(
"complxnum,fullfp16")
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()));
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)
600 [[nodiscard]]
consteval
605 return detail::fcmla_value<Rotation,Lane>(acc,a,b);
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)
613 [[nodiscard]]
constexpr
618 return detail::fcmla_value<Rotation,Lane>(acc,a,b, detail::arm_float_control::current());
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()));
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);
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());
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")
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()));
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
675 return detail::fcmla_value<Rotation,-1>(acc,a,b);
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
686 return detail::fcmla_value<Rotation,-1>(acc,a,b, detail::arm_float_control::current());
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)
694 [[nodiscard]] hint_inline hint_target(
"complxnum,fullfp16")
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()));
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)
713 [[nodiscard]]
consteval
718 return detail::fcmla_value<Rotation,Lane>(acc,a,b);
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)
726 [[nodiscard]]
constexpr
731 return detail::fcmla_value<Rotation,Lane>(acc,a,b, detail::arm_float_control::current());
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)
739 [[nodiscard]] hint_inline hint_target(
"complxnum,fullfp16")
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()));
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)
758 [[nodiscard]]
consteval
763 return detail::fcmla_value<Rotation,Lane>(acc,a,b);
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)
771 [[nodiscard]]
constexpr
776 return detail::fcmla_value<Rotation,Lane>(acc,a,b, detail::arm_float_control::current());
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;
795#if NATIVE_HOST_NEON || defined(NATIVE_DOXYGEN)
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.