3#include "native/isa_import.h"
4#include "native/config.h"
6#include "native/targets.h"
13namespace native::detail {
14 constexpr std::int32_t jcvt_constant(
double value)
noexcept {
15 auto bits = std::bit_cast<std::uint64_t>(value);
16 auto exponent = unsigned((bits >> 52) & 0x7ff);
18 if (exponent == 0x7ff || exponent < 1023)
return 0;
19 int shift = int(exponent) - 1023 - 52;
20 if (shift >= 32)
return 0;
21 auto significand = (bits & 0x000fffffffffffffULL) | 0x0010000000000000ULL;
22 auto result = shift >= 0 ? std::uint32_t(significand) << shift
23 : std::uint32_t(significand >> -shift);
24 if (bits >> 63) result = std::uint32_t(0) - result;
25 return std::bit_cast<std::int32_t>(result);
29#if NATIVE_HOST_NEON || defined(NATIVE_DOXYGEN)
39 template<isa<arm> Arch = NATIVE_BA
SELINE>
requires(Arch.has(arm_feature::jsconv))
41 jcvt(
double value) noexcept {
43 return detail::jcvt_constant(value);
45 return __builtin_arm_jcvt(value);
50 template<isa<arm> Arch = NATIVE_BA
SELINE>
requires(!Arch.has(arm_feature::jsconv))
52 return detail::jcvt_constant(value);
Compiler attributes for host code, with shader-safe shared modifiers.
constexpr std::int32_t jcvt(double value) noexcept
Convert a double using FJCVTZS; requires the jsconv feature and matching compiler target.
#define native_inline
inline [[always_inline]]
#define native_nodiscard
C++17 [[nodiscard]].
#define native_target(x)
this indicates a required feature set for the current multiversioned function.
Architecture-tagged vectors, register packs and supporting value types. Native arithmetic follows its...