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