Pirama Arumuga Nainar | ec8c89d | 2022-02-23 09:26:16 -0800 | [diff] [blame] | 1 | /*===---- crc32intrin.h - SSE4.2 Accumulate CRC32 intrinsics ---------------=== |
| 2 | * |
| 3 | * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | * See https://llvm.org/LICENSE.txt for license information. |
| 5 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | * |
| 7 | *===-----------------------------------------------------------------------=== |
| 8 | */ |
| 9 | |
| 10 | #ifndef __CRC32INTRIN_H |
| 11 | #define __CRC32INTRIN_H |
| 12 | |
| 13 | #define __DEFAULT_FN_ATTRS \ |
| 14 | __attribute__((__always_inline__, __nodebug__, __target__("crc32"))) |
| 15 | |
| 16 | /// Adds the unsigned integer operand to the CRC-32C checksum of the |
| 17 | /// unsigned char operand. |
| 18 | /// |
| 19 | /// \headerfile <x86intrin.h> |
| 20 | /// |
| 21 | /// This intrinsic corresponds to the <c> CRC32B </c> instruction. |
| 22 | /// |
| 23 | /// \param __C |
| 24 | /// An unsigned integer operand to add to the CRC-32C checksum of operand |
| 25 | /// \a __D. |
| 26 | /// \param __D |
| 27 | /// An unsigned 8-bit integer operand used to compute the CRC-32C checksum. |
| 28 | /// \returns The result of adding operand \a __C to the CRC-32C checksum of |
| 29 | /// operand \a __D. |
| 30 | static __inline__ unsigned int __DEFAULT_FN_ATTRS |
| 31 | _mm_crc32_u8(unsigned int __C, unsigned char __D) |
| 32 | { |
| 33 | return __builtin_ia32_crc32qi(__C, __D); |
| 34 | } |
| 35 | |
| 36 | /// Adds the unsigned integer operand to the CRC-32C checksum of the |
| 37 | /// unsigned short operand. |
| 38 | /// |
| 39 | /// \headerfile <x86intrin.h> |
| 40 | /// |
| 41 | /// This intrinsic corresponds to the <c> CRC32W </c> instruction. |
| 42 | /// |
| 43 | /// \param __C |
| 44 | /// An unsigned integer operand to add to the CRC-32C checksum of operand |
| 45 | /// \a __D. |
| 46 | /// \param __D |
| 47 | /// An unsigned 16-bit integer operand used to compute the CRC-32C checksum. |
| 48 | /// \returns The result of adding operand \a __C to the CRC-32C checksum of |
| 49 | /// operand \a __D. |
| 50 | static __inline__ unsigned int __DEFAULT_FN_ATTRS |
| 51 | _mm_crc32_u16(unsigned int __C, unsigned short __D) |
| 52 | { |
| 53 | return __builtin_ia32_crc32hi(__C, __D); |
| 54 | } |
| 55 | |
| 56 | /// Adds the first unsigned integer operand to the CRC-32C checksum of |
| 57 | /// the second unsigned integer operand. |
| 58 | /// |
| 59 | /// \headerfile <x86intrin.h> |
| 60 | /// |
| 61 | /// This intrinsic corresponds to the <c> CRC32L </c> instruction. |
| 62 | /// |
| 63 | /// \param __C |
| 64 | /// An unsigned integer operand to add to the CRC-32C checksum of operand |
| 65 | /// \a __D. |
| 66 | /// \param __D |
| 67 | /// An unsigned 32-bit integer operand used to compute the CRC-32C checksum. |
| 68 | /// \returns The result of adding operand \a __C to the CRC-32C checksum of |
| 69 | /// operand \a __D. |
| 70 | static __inline__ unsigned int __DEFAULT_FN_ATTRS |
| 71 | _mm_crc32_u32(unsigned int __C, unsigned int __D) |
| 72 | { |
| 73 | return __builtin_ia32_crc32si(__C, __D); |
| 74 | } |
| 75 | |
| 76 | #ifdef __x86_64__ |
| 77 | /// Adds the unsigned integer operand to the CRC-32C checksum of the |
| 78 | /// unsigned 64-bit integer operand. |
| 79 | /// |
| 80 | /// \headerfile <x86intrin.h> |
| 81 | /// |
| 82 | /// This intrinsic corresponds to the <c> CRC32Q </c> instruction. |
| 83 | /// |
| 84 | /// \param __C |
| 85 | /// An unsigned integer operand to add to the CRC-32C checksum of operand |
| 86 | /// \a __D. |
| 87 | /// \param __D |
| 88 | /// An unsigned 64-bit integer operand used to compute the CRC-32C checksum. |
| 89 | /// \returns The result of adding operand \a __C to the CRC-32C checksum of |
| 90 | /// operand \a __D. |
| 91 | static __inline__ unsigned long long __DEFAULT_FN_ATTRS |
| 92 | _mm_crc32_u64(unsigned long long __C, unsigned long long __D) |
| 93 | { |
| 94 | return __builtin_ia32_crc32di(__C, __D); |
| 95 | } |
| 96 | #endif /* __x86_64__ */ |
| 97 | |
| 98 | #undef __DEFAULT_FN_ATTRS |
| 99 | |
| 100 | #endif /* __CRC32INTRIN_H */ |