#ifndef _LIBCPP_SRC_INCLUDE_RYU_DS2_INTRINSICS_H
#define _LIBCPP_SRC_INCLUDE_RYU_DS2_INTRINSICS_H
#include <__assert>
#include <__config>
#include "include/ryu/ryu.h"
_LIBCPP_BEGIN_NAMESPACE_STD
#if defined(_M_X64) && defined(_MSC_VER)
#define _LIBCPP_INTRINSIC128 …
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __ryu_umul128(const uint64_t __a, const uint64_t __b, uint64_t* const __productHi) {
return _umul128(__a, __b, __productHi);
}
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __ryu_shiftright128(const uint64_t __lo, const uint64_t __hi, const uint32_t __dist) {
_LIBCPP_ASSERT_INTERNAL(__dist < 64, "");
return __shiftright128(__lo, __hi, static_cast<unsigned char>(__dist));
}
#elif defined(__SIZEOF_INT128__) && ( \
(defined(__clang__) && !defined(_MSC_VER)) || \
(defined(__GNUC__) && !defined(__clang__) && !defined(__CUDACC__)))
#define _LIBCPP_INTRINSIC128 …
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __ryu_umul128(const uint64_t __a, const uint64_t __b, uint64_t* const __productHi) { … }
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __ryu_shiftright128(const uint64_t __lo, const uint64_t __hi, const uint32_t __dist) { … }
#else
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline _LIBCPP_ALWAYS_INLINE uint64_t __ryu_umul128(const uint64_t __a, const uint64_t __b, uint64_t* const __productHi) {
const uint32_t __aLo = static_cast<uint32_t>(__a);
const uint32_t __aHi = static_cast<uint32_t>(__a >> 32);
const uint32_t __bLo = static_cast<uint32_t>(__b);
const uint32_t __bHi = static_cast<uint32_t>(__b >> 32);
const uint64_t __b00 = static_cast<uint64_t>(__aLo) * __bLo;
const uint64_t __b01 = static_cast<uint64_t>(__aLo) * __bHi;
const uint64_t __b10 = static_cast<uint64_t>(__aHi) * __bLo;
const uint64_t __b11 = static_cast<uint64_t>(__aHi) * __bHi;
const uint32_t __b00Lo = static_cast<uint32_t>(__b00);
const uint32_t __b00Hi = static_cast<uint32_t>(__b00 >> 32);
const uint64_t __mid1 = __b10 + __b00Hi;
const uint32_t __mid1Lo = static_cast<uint32_t>(__mid1);
const uint32_t __mid1Hi = static_cast<uint32_t>(__mid1 >> 32);
const uint64_t __mid2 = __b01 + __mid1Lo;
const uint32_t __mid2Lo = static_cast<uint32_t>(__mid2);
const uint32_t __mid2Hi = static_cast<uint32_t>(__mid2 >> 32);
const uint64_t __pHi = __b11 + __mid1Hi + __mid2Hi;
const uint64_t __pLo = (static_cast<uint64_t>(__mid2Lo) << 32) | __b00Lo;
*__productHi = __pHi;
return __pLo;
}
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __ryu_shiftright128(const uint64_t __lo, const uint64_t __hi, const uint32_t __dist) {
_LIBCPP_ASSERT_INTERNAL(__dist < 64, "");
#ifdef _LIBCPP_64_BIT
_LIBCPP_ASSERT_INTERNAL(__dist > 0, "");
return (__hi << (64 - __dist)) | (__lo >> __dist);
#else
_LIBCPP_ASSERT_INTERNAL(__dist >= 32, "");
return (__hi << (64 - __dist)) | (static_cast<uint32_t>(__lo >> 32) >> (__dist - 32));
#endif
}
#endif
#ifndef _LIBCPP_64_BIT
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __umulh(const uint64_t __a, const uint64_t __b) { … }
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __div5(const uint64_t __x) { … }
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __div10(const uint64_t __x) { … }
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __div100(const uint64_t __x) { … }
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __div1e8(const uint64_t __x) { … }
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __div1e9(const uint64_t __x) { … }
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint32_t __mod1e9(const uint64_t __x) { … }
#else
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __div5(const uint64_t __x) {
return __x / 5;
}
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __div10(const uint64_t __x) {
return __x / 10;
}
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __div100(const uint64_t __x) {
return __x / 100;
}
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __div1e8(const uint64_t __x) {
return __x / 100000000;
}
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __div1e9(const uint64_t __x) {
return __x / 1000000000;
}
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint32_t __mod1e9(const uint64_t __x) {
return static_cast<uint32_t>(__x - 1000000000 * __div1e9(__x));
}
#endif
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint32_t __pow5Factor(uint64_t __value) { … }
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline bool __multipleOfPowerOf5(const uint64_t __value, const uint32_t __p) { … }
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline bool __multipleOfPowerOf2(const uint64_t __value, const uint32_t __p) { … }
_LIBCPP_END_NAMESPACE_STD
#endif