brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · b276b4d Raw
60 lines · c
1/*===---- popcntintrin.h - POPCNT 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#ifndef __POPCNTINTRIN_H11#define __POPCNTINTRIN_H12 13/* Define the default attributes for the functions in this file. */14#if defined(__cplusplus) && (__cplusplus >= 201103L)15#define __DEFAULT_FN_ATTRS                                                     \16  __attribute__((__always_inline__, __nodebug__,                               \17                 __target__("popcnt"))) constexpr18#else19#define __DEFAULT_FN_ATTRS                                                     \20  __attribute__((__always_inline__, __nodebug__, __target__("popcnt")))21#endif22 23/// Counts the number of bits in the source operand having a value of 1.24///25/// \headerfile <x86intrin.h>26///27/// This intrinsic corresponds to the <c> POPCNT </c> instruction.28///29/// \param __A30///    An unsigned 32-bit integer operand.31/// \returns A 32-bit integer containing the number of bits with value 1 in the32///    source operand.33static __inline__ int __DEFAULT_FN_ATTRS34_mm_popcnt_u32(unsigned int __A)35{36  return __builtin_popcount(__A);37}38 39#ifdef __x86_64__40/// Counts the number of bits in the source operand having a value of 1.41///42/// \headerfile <x86intrin.h>43///44/// This intrinsic corresponds to the <c> POPCNT </c> instruction.45///46/// \param __A47///    An unsigned 64-bit integer operand.48/// \returns A 64-bit integer containing the number of bits with value 1 in the49///    source operand.50static __inline__ long long __DEFAULT_FN_ATTRS51_mm_popcnt_u64(unsigned long long __A)52{53  return __builtin_popcountll(__A);54}55#endif /* __x86_64__ */56 57#undef __DEFAULT_FN_ATTRS58 59#endif /* __POPCNTINTRIN_H */60