1251876Speter/*===---- lzcntintrin.h - LZCNT intrinsics ---------------------------------=== 2251876Speter * 3251876Speter * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4251876Speter * See https://llvm.org/LICENSE.txt for license information. 5251876Speter * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6251876Speter * 7251876Speter *===-----------------------------------------------------------------------=== 8251876Speter */ 9251876Speter 10251876Speter#if !defined __X86INTRIN_H && !defined __IMMINTRIN_H 11251876Speter#error "Never use <lzcntintrin.h> directly; include <x86intrin.h> instead." 12251876Speter#endif 13251876Speter 14251876Speter#ifndef __LZCNTINTRIN_H 15251876Speter#define __LZCNTINTRIN_H 16251876Speter 17251876Speter/* Define the default attributes for the functions in this file. */ 18251876Speter#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("lzcnt"))) 19251876Speter 20251876Speter#ifndef _MSC_VER 21251876Speter/// Counts the number of leading zero bits in the operand. 22251876Speter/// 23251876Speter/// \headerfile <x86intrin.h> 24251876Speter/// 25251876Speter/// This intrinsic corresponds to the \c LZCNT instruction. 26251876Speter/// 27251876Speter/// \param __X 28251876Speter/// An unsigned 16-bit integer whose leading zeros are to be counted. 29251876Speter/// \returns An unsigned 16-bit integer containing the number of leading zero 30251876Speter/// bits in the operand. 31251876Speter#define __lzcnt16(X) __builtin_ia32_lzcnt_u16((unsigned short)(X)) 32251876Speter#endif // _MSC_VER 33251876Speter 34251876Speter/// Counts the number of leading zero bits in the operand. 35251876Speter/// 36251876Speter/// \headerfile <x86intrin.h> 37251876Speter/// 38251876Speter/// This intrinsic corresponds to the \c LZCNT instruction. 39251876Speter/// 40251876Speter/// \param __X 41251876Speter/// An unsigned 32-bit integer whose leading zeros are to be counted. 42251876Speter/// \returns An unsigned 32-bit integer containing the number of leading zero 43251876Speter/// bits in the operand. 44251876Speter/// \see _lzcnt_u32 45251876Speterstatic __inline__ unsigned int __DEFAULT_FN_ATTRS 46251876Speter__lzcnt32(unsigned int __X) 47251876Speter{ 48251876Speter return __builtin_ia32_lzcnt_u32(__X); 49251876Speter} 50251876Speter 51251876Speter/// Counts the number of leading zero bits in the operand. 52251876Speter/// 53251876Speter/// \headerfile <x86intrin.h> 54251876Speter/// 55251876Speter/// This intrinsic corresponds to the \c LZCNT instruction. 56251876Speter/// 57251876Speter/// \param __X 58251876Speter/// An unsigned 32-bit integer whose leading zeros are to be counted. 59251876Speter/// \returns An unsigned 32-bit integer containing the number of leading zero 60251876Speter/// bits in the operand. 61251876Speter/// \see __lzcnt32 62251876Speterstatic __inline__ unsigned int __DEFAULT_FN_ATTRS 63251876Speter_lzcnt_u32(unsigned int __X) 64251876Speter{ 65251876Speter return __builtin_ia32_lzcnt_u32(__X); 66251876Speter} 67251876Speter 68251876Speter#ifdef __x86_64__ 69251876Speter#ifndef _MSC_VER 70251876Speter/// Counts the number of leading zero bits in the operand. 71251876Speter/// 72251876Speter/// \headerfile <x86intrin.h> 73251876Speter/// 74251876Speter/// This intrinsic corresponds to the \c LZCNT instruction. 75251876Speter/// 76251876Speter/// \param __X 77251876Speter/// An unsigned 64-bit integer whose leading zeros are to be counted. 78251876Speter/// \returns An unsigned 64-bit integer containing the number of leading zero 79251876Speter/// bits in the operand. 80251876Speter/// \see _lzcnt_u64 81251876Speter#define __lzcnt64(X) __builtin_ia32_lzcnt_u64((unsigned long long)(X)) 82251876Speter#endif // _MSC_VER 83251876Speter 84251876Speter/// Counts the number of leading zero bits in the operand. 85251876Speter/// 86251876Speter/// \headerfile <x86intrin.h> 87251876Speter/// 88251876Speter/// This intrinsic corresponds to the \c LZCNT instruction. 89251876Speter/// 90251876Speter/// \param __X 91251876Speter/// An unsigned 64-bit integer whose leading zeros are to be counted. 92251876Speter/// \returns An unsigned 64-bit integer containing the number of leading zero 93251876Speter/// bits in the operand. 94251876Speter/// \see __lzcnt64 95251876Speterstatic __inline__ unsigned long long __DEFAULT_FN_ATTRS 96251876Speter_lzcnt_u64(unsigned long long __X) 97251876Speter{ 98251876Speter return __builtin_ia32_lzcnt_u64(__X); 99251876Speter} 100251876Speter#endif 101251876Speter 102251876Speter#undef __DEFAULT_FN_ATTRS 103251876Speter 104251876Speter#endif /* __LZCNTINTRIN_H */ 105251876Speter