4#include "native/config.h"
7#include "native/detail/crc.h"
13#if NATIVE_HOST_X86 || defined(NATIVE_DOXYGEN)
25 template<isa<x86> Arch>
requires(Arch.has(x86_feature::crc32))
26 [[nodiscard]] hint_inline hint_const hint_target(
"crc32")
27 constexpr
std::uint32_t
crc32c(
std::uint32_t accumulator,
std::uint8_t value) noexcept {
28 if (__builtin_is_constant_evaluated()) {
29 return detail::crc_update(accumulator, value,
sizeof(value) * 8, 0x82f63b78u);
31 return _mm_crc32_u8(accumulator, value);
36 template<isa<x86> Arch>
requires(Arch.has(x86_feature::crc32))
37 [[nodiscard]] hint_inline hint_const hint_target(
"crc32")
38 constexpr std::uint32_t
crc32c(std::uint32_t accumulator, std::uint16_t value)
noexcept {
39 if (__builtin_is_constant_evaluated()) {
40 return detail::crc_update(accumulator, value,
sizeof(value) * 8, 0x82f63b78u);
42 return _mm_crc32_u16(accumulator, value);
47 template<isa<x86> Arch>
requires(Arch.has(x86_feature::crc32))
48 [[nodiscard]] hint_inline hint_const hint_target(
"crc32")
49 constexpr std::uint32_t
crc32c(std::uint32_t accumulator, std::uint32_t value)
noexcept {
50 if (__builtin_is_constant_evaluated()) {
51 return detail::crc_update(accumulator, value,
sizeof(value) * 8, 0x82f63b78u);
53 return _mm_crc32_u32(accumulator, value);
57#if defined(__x86_64__) || defined(_M_X64) || defined(NATIVE_DOXYGEN)
60 template<isa<x86> Arch>
requires(Arch.has(x86_feature::crc32))
61 [[nodiscard]] hint_inline hint_const hint_target(
"crc32")
62 constexpr std::uint32_t
crc32c(std::uint32_t accumulator, std::uint64_t value)
noexcept {
63 if (__builtin_is_constant_evaluated()) {
64 return detail::crc_update(accumulator, value,
sizeof(value) * 8, 0x82f63b78u);
66 return static_cast<std::uint32_t
>(_mm_crc32_u64(accumulator, value));
72 template<isa<x86> Arch>
requires(!Arch.has(x86_feature::crc32) && !Arch.has(polyfill))
74 consteval std::uint32_t
crc32c(std::uint32_t accumulator, std::uint8_t value)
noexcept {
79 template<isa<x86> Arch>
requires(!Arch.has(x86_feature::crc32) && Arch.has(polyfill))
80 [[nodiscard]] hint_inline hint_const
81 constexpr std::uint32_t
crc32c(std::uint32_t accumulator, std::uint8_t value)
noexcept {
82 return detail::crc_update(accumulator, value,
sizeof(value) * 8, 0x82f63b78u);
86 template<isa<x86> Arch>
requires(!Arch.has(x86_feature::crc32) && !Arch.has(polyfill))
88 consteval std::uint32_t
crc32c(std::uint32_t accumulator, std::uint16_t value)
noexcept {
93 template<isa<x86> Arch>
requires(!Arch.has(x86_feature::crc32) && Arch.has(polyfill))
94 [[nodiscard]] hint_inline hint_const
95 constexpr std::uint32_t
crc32c(std::uint32_t accumulator, std::uint16_t value)
noexcept {
96 return detail::crc_update(accumulator, value,
sizeof(value) * 8, 0x82f63b78u);
100 template<isa<x86> Arch>
requires(!Arch.has(x86_feature::crc32) && !Arch.has(polyfill))
102 consteval std::uint32_t
crc32c(std::uint32_t accumulator, std::uint32_t value)
noexcept {
107 template<isa<x86> Arch>
requires(!Arch.has(x86_feature::crc32) && Arch.has(polyfill))
108 [[nodiscard]] hint_inline hint_const
109 constexpr std::uint32_t
crc32c(std::uint32_t accumulator, std::uint32_t value)
noexcept {
110 return detail::crc_update(accumulator, value,
sizeof(value) * 8, 0x82f63b78u);
113#if defined(__x86_64__) || defined(_M_X64) || defined(NATIVE_DOXYGEN)
115 template<isa<x86> Arch>
requires(!Arch.has(x86_feature::crc32) && !Arch.has(polyfill))
117 consteval std::uint32_t
crc32c(std::uint32_t accumulator, std::uint64_t value)
noexcept {
122 template<isa<x86> Arch>
requires(!Arch.has(x86_feature::crc32) && Arch.has(polyfill))
123 [[nodiscard]] hint_inline hint_const
124 constexpr std::uint32_t
crc32c(std::uint32_t accumulator, std::uint64_t value)
noexcept {
125 return detail::crc_update(accumulator, value,
sizeof(value) * 8, 0x82f63b78u);
constexpr std::uint32_t crc32c(std::uint32_t accumulator, std::uint8_t value) noexcept
Update a 32-bit CRC32C accumulator with exactly eight bits.
Architecture-tagged vectors, register packs and supporting value types. Native arithmetic follows its...
Standard-library adaptations documented here for SIMD value types.