brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.6 KiB · 123a42a Raw
110 lines · c
1/*===---- lzcntintrin.h - LZCNT 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-exception6 *7 *===-----------------------------------------------------------------------===8 */9 10#if !defined __X86INTRIN_H && !defined __IMMINTRIN_H11#error "Never use <lzcntintrin.h> directly; include <x86intrin.h> instead."12#endif13 14#ifndef __LZCNTINTRIN_H15#define __LZCNTINTRIN_H16 17/* Define the default attributes for the functions in this file.18   Allow using the lzcnt intrinsics even for non-LZCNT targets. Since the LZCNT19   intrinsics are mapped to llvm.ctlz.*, false, which can be lowered to BSR on20   non-LZCNT targets with zero-value input handled correctly. */21#if defined(__cplusplus) && (__cplusplus >= 201103L)22#define __DEFAULT_FN_ATTRS                                                     \23  __attribute__((__always_inline__, __nodebug__)) constexpr24#else25#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))26#endif27 28#ifndef _MSC_VER29/// Counts the number of leading zero bits in the operand.30///31/// \headerfile <x86intrin.h>32///33/// This intrinsic corresponds to the \c LZCNT instruction.34///35/// \param __X36///    An unsigned 16-bit integer whose leading zeros are to be counted.37/// \returns An unsigned 16-bit integer containing the number of leading zero38///    bits in the operand.39#define __lzcnt16(X) __builtin_ia32_lzcnt_u16((unsigned short)(X))40#endif // _MSC_VER41 42/// Counts the number of leading zero bits in the operand.43///44/// \headerfile <x86intrin.h>45///46/// This intrinsic corresponds to the \c LZCNT instruction.47///48/// \param __X49///    An unsigned 32-bit integer whose leading zeros are to be counted.50/// \returns An unsigned 32-bit integer containing the number of leading zero51///    bits in the operand.52/// \see _lzcnt_u3253static __inline__ unsigned int __DEFAULT_FN_ATTRS54__lzcnt32(unsigned int __X) {55  return __builtin_ia32_lzcnt_u32(__X);56}57 58/// Counts the number of leading zero bits in the operand.59///60/// \headerfile <x86intrin.h>61///62/// This intrinsic corresponds to the \c LZCNT instruction.63///64/// \param __X65///    An unsigned 32-bit integer whose leading zeros are to be counted.66/// \returns An unsigned 32-bit integer containing the number of leading zero67///    bits in the operand.68/// \see __lzcnt3269static __inline__ unsigned int __DEFAULT_FN_ATTRS70_lzcnt_u32(unsigned int __X) {71  return __builtin_ia32_lzcnt_u32(__X);72}73 74#ifdef __x86_64__75#ifndef _MSC_VER76/// Counts the number of leading zero bits in the operand.77///78/// \headerfile <x86intrin.h>79///80/// This intrinsic corresponds to the \c LZCNT instruction.81///82/// \param __X83///    An unsigned 64-bit integer whose leading zeros are to be counted.84/// \returns An unsigned 64-bit integer containing the number of leading zero85///    bits in the operand.86/// \see _lzcnt_u6487#define __lzcnt64(X) __builtin_ia32_lzcnt_u64((unsigned long long)(X))88#endif // _MSC_VER89 90/// Counts the number of leading zero bits in the operand.91///92/// \headerfile <x86intrin.h>93///94/// This intrinsic corresponds to the \c LZCNT instruction.95///96/// \param __X97///    An unsigned 64-bit integer whose leading zeros are to be counted.98/// \returns An unsigned 64-bit integer containing the number of leading zero99///    bits in the operand.100/// \see __lzcnt64101static __inline__ unsigned long long __DEFAULT_FN_ATTRS102_lzcnt_u64(unsigned long long __X) {103  return __builtin_ia32_lzcnt_u64(__X);104}105#endif106 107#undef __DEFAULT_FN_ATTRS108 109#endif /* __LZCNTINTRIN_H */110