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 *===-----------------------------------------------------------------------===
10 #if !defined __X86INTRIN_H && !defined __IMMINTRIN_H
11 #error "Never use <lzcntintrin.h> directly; include <x86intrin.h> instead."
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")))
21 /// Counts the number of leading zero bits in the operand.
23 /// \headerfile <x86intrin.h>
25 /// This intrinsic corresponds to the \c LZCNT instruction.
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))
34 /// Counts the number of leading zero bits in the operand.
36 /// \headerfile <x86intrin.h>
38 /// This intrinsic corresponds to the \c LZCNT instruction.
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.
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.
53 /// \headerfile <x86intrin.h>
55 /// This intrinsic corresponds to the \c LZCNT instruction.
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.
62 static __inline__
unsigned int __DEFAULT_FN_ATTRS
63 _lzcnt_u32(unsigned int __X
)
65 return __builtin_ia32_lzcnt_u32(__X
);
70 /// Counts the number of leading zero bits in the operand.
72 /// \headerfile <x86intrin.h>
74 /// This intrinsic corresponds to the \c LZCNT instruction.
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.
81 #define __lzcnt64(X) __builtin_ia32_lzcnt_u64((unsigned long long)(X))
84 /// Counts the number of leading zero bits in the operand.
86 /// \headerfile <x86intrin.h>
88 /// This intrinsic corresponds to the \c LZCNT instruction.
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.
95 static __inline__
unsigned long long __DEFAULT_FN_ATTRS
96 _lzcnt_u64(unsigned long long __X
)
98 return __builtin_ia32_lzcnt_u64(__X
);
102 #undef __DEFAULT_FN_ATTRS
104 #endif /* __LZCNTINTRIN_H */