[docs] Fix build-docs.sh
[llvm-project.git] / clang / lib / Headers / lzcntintrin.h
blobf4ddce9d0e6834ae11ce88a9341aae4778a235e6
1 /*===---- lzcntintrin.h - LZCNT intrinsics ---------------------------------===
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
7 *===-----------------------------------------------------------------------===
8 */
10 #if !defined __X86INTRIN_H && !defined __IMMINTRIN_H
11 #error "Never use <lzcntintrin.h> directly; include <x86intrin.h> instead."
12 #endif
14 #ifndef __LZCNTINTRIN_H
15 #define __LZCNTINTRIN_H
17 /* Define the default attributes for the functions in this file. */
18 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("lzcnt")))
20 #ifndef _MSC_VER
21 /// Counts the number of leading zero bits in the operand.
22 ///
23 /// \headerfile <x86intrin.h>
24 ///
25 /// This intrinsic corresponds to the \c LZCNT instruction.
26 ///
27 /// \param __X
28 /// An unsigned 16-bit integer whose leading zeros are to be counted.
29 /// \returns An unsigned 16-bit integer containing the number of leading zero
30 /// bits in the operand.
31 #define __lzcnt16(X) __builtin_ia32_lzcnt_u16((unsigned short)(X))
32 #endif // _MSC_VER
34 /// Counts the number of leading zero bits in the operand.
35 ///
36 /// \headerfile <x86intrin.h>
37 ///
38 /// This intrinsic corresponds to the \c LZCNT instruction.
39 ///
40 /// \param __X
41 /// An unsigned 32-bit integer whose leading zeros are to be counted.
42 /// \returns An unsigned 32-bit integer containing the number of leading zero
43 /// bits in the operand.
44 /// \see _lzcnt_u32
45 static __inline__ unsigned int __DEFAULT_FN_ATTRS
46 __lzcnt32(unsigned int __X)
48 return __builtin_ia32_lzcnt_u32(__X);
51 /// Counts the number of leading zero bits in the operand.
52 ///
53 /// \headerfile <x86intrin.h>
54 ///
55 /// This intrinsic corresponds to the \c LZCNT instruction.
56 ///
57 /// \param __X
58 /// An unsigned 32-bit integer whose leading zeros are to be counted.
59 /// \returns An unsigned 32-bit integer containing the number of leading zero
60 /// bits in the operand.
61 /// \see __lzcnt32
62 static __inline__ unsigned int __DEFAULT_FN_ATTRS
63 _lzcnt_u32(unsigned int __X)
65 return __builtin_ia32_lzcnt_u32(__X);
68 #ifdef __x86_64__
69 #ifndef _MSC_VER
70 /// Counts the number of leading zero bits in the operand.
71 ///
72 /// \headerfile <x86intrin.h>
73 ///
74 /// This intrinsic corresponds to the \c LZCNT instruction.
75 ///
76 /// \param __X
77 /// An unsigned 64-bit integer whose leading zeros are to be counted.
78 /// \returns An unsigned 64-bit integer containing the number of leading zero
79 /// bits in the operand.
80 /// \see _lzcnt_u64
81 #define __lzcnt64(X) __builtin_ia32_lzcnt_u64((unsigned long long)(X))
82 #endif // _MSC_VER
84 /// Counts the number of leading zero bits in the operand.
85 ///
86 /// \headerfile <x86intrin.h>
87 ///
88 /// This intrinsic corresponds to the \c LZCNT instruction.
89 ///
90 /// \param __X
91 /// An unsigned 64-bit integer whose leading zeros are to be counted.
92 /// \returns An unsigned 64-bit integer containing the number of leading zero
93 /// bits in the operand.
94 /// \see __lzcnt64
95 static __inline__ unsigned long long __DEFAULT_FN_ATTRS
96 _lzcnt_u64(unsigned long long __X)
98 return __builtin_ia32_lzcnt_u64(__X);
100 #endif
102 #undef __DEFAULT_FN_ATTRS
104 #endif /* __LZCNTINTRIN_H */