#ifndef LLVM_LIBC_SRC___SUPPORT_UINT_H
#define LLVM_LIBC_SRC___SUPPORT_UINT_H
#include "src/__support/CPP/array.h"
#include "src/__support/CPP/bit.h"
#include "src/__support/CPP/limits.h"
#include "src/__support/CPP/optional.h"
#include "src/__support/CPP/type_traits.h"
#include "src/__support/macros/attributes.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/optimization.h"
#include "src/__support/macros/properties/compiler.h"
#include "src/__support/macros/properties/types.h"
#include "src/__support/math_extras.h"
#include "src/__support/number_pair.h"
#include <stddef.h>
#include <stdint.h>
namespace LIBC_NAMESPACE_DECL {
multiword
template <size_t Bits, bool Signed, typename WordType = uint64_t>
struct BigInt { … };
namespace internal {
template <size_t Bits>
struct WordTypeSelector : cpp::type_identity<
#ifdef LIBC_TYPES_HAS_INT64
uint64_t
#else
uint32_t
#endif
> { … };
template <> struct WordTypeSelector<16> : cpp::type_identity<uint16_t> { … };
template <> struct WordTypeSelector<32> : cpp::type_identity<uint32_t> { … };
WordTypeSelectorT;
}
UInt;
Int;
numeric_limits<BigInt<Bits, Signed, T>>;
template <typename T> struct is_big_int : cpp::false_type { … };
is_big_int<BigInt<Bits, Signed, T>>;
is_big_int_v;
template <typename T>
struct is_integral_or_big_int
: cpp::bool_constant<(cpp::is_integral_v<T> || is_big_int_v<T>)> { … };
is_integral_or_big_int_v;
template <typename T> struct make_big_int_unsigned;
make_big_int_unsigned<BigInt<Bits, Signed, T>>;
make_big_int_unsigned_t;
template <typename T> struct make_big_int_signed;
make_big_int_signed<BigInt<Bits, Signed, T>>;
make_big_int_signed_t;
template <typename T, class = void> struct make_integral_or_big_int_unsigned;
make_integral_or_big_int_unsigned<T, cpp::enable_if_t<cpp::is_integral_v<T>>>;
make_integral_or_big_int_unsigned<T, cpp::enable_if_t<is_big_int_v<T>>>;
make_integral_or_big_int_unsigned_t;
template <typename T, class = void> struct make_integral_or_big_int_signed;
make_integral_or_big_int_signed<T, cpp::enable_if_t<cpp::is_integral_v<T>>>;
make_integral_or_big_int_signed<T, cpp::enable_if_t<is_big_int_v<T>>>;
make_integral_or_big_int_signed_t;
template <typename T>
struct is_unsigned_integral_or_big_int
: cpp::bool_constant<
cpp::is_same_v<T, make_integral_or_big_int_unsigned_t<T>>> { … };
is_unsigned_integral_or_big_int_v;
namespace cpp {
template <typename To, typename From>
LIBC_INLINE constexpr cpp::enable_if_t<
(sizeof(To) == sizeof(From)) && cpp::is_trivially_copyable<To>::value &&
cpp::is_trivially_copyable<From>::value && is_big_int<To>::value,
To>
bit_cast(const From &from) { … }
template <typename To, size_t Bits>
LIBC_INLINE constexpr cpp::enable_if_t<
sizeof(To) == sizeof(UInt<Bits>) &&
cpp::is_trivially_constructible<To>::value &&
cpp::is_trivially_copyable<To>::value &&
cpp::is_trivially_copyable<UInt<Bits>>::value,
To>
bit_cast(const UInt<Bits> &from) { … }
template <typename T>
[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, int>
popcount(T value) { … }
template <typename T>
[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, bool>
has_single_bit(T value) { … }
template <typename T>
[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, int>
countr_zero(const T &value) { … }
template <typename T>
[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, int>
countl_zero(const T &value) { … }
template <typename T>
[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, int>
countl_one(T value) { … }
template <typename T>
[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, int>
countr_one(T value) { … }
template <typename T>
[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, int>
bit_width(T value) { … }
template <typename T>
[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, T>
rotr(T value, int rotate);
template <typename T>
[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, T>
rotl(T value, int rotate) { … }
template <typename T>
[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, T>
rotr(T value, int rotate) { … }
}
template <typename T, size_t count>
LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, T>
mask_trailing_ones() { … }
template <typename T, size_t count>
LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, T> mask_leading_ones() { … }
template <typename T, size_t count>
LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, T>
mask_trailing_zeros() { … }
template <typename T, size_t count>
LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, T>
mask_leading_zeros() { … }
template <typename T>
[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, int>
count_zeros(T value) { … }
template <typename T>
[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, int>
first_leading_zero(T value) { … }
template <typename T>
[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, int>
first_leading_one(T value) { … }
template <typename T>
[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, int>
first_trailing_zero(T value) { … }
template <typename T>
[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, int>
first_trailing_one(T value) { … }
}
#endif