150
|
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-exception
|
|
6 *
|
|
7 *===-----------------------------------------------------------------------===
|
|
8 */
|
|
9
|
|
10 #ifndef __POPCNTINTRIN_H
|
|
11 #define __POPCNTINTRIN_H
|
|
12
|
|
13 /* Define the default attributes for the functions in this file. */
|
|
14 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("popcnt")))
|
|
15
|
|
16 /// Counts the number of bits in the source operand having a value of 1.
|
|
17 ///
|
|
18 /// \headerfile <x86intrin.h>
|
|
19 ///
|
|
20 /// This intrinsic corresponds to the <c> POPCNT </c> instruction.
|
|
21 ///
|
|
22 /// \param __A
|
|
23 /// An unsigned 32-bit integer operand.
|
|
24 /// \returns A 32-bit integer containing the number of bits with value 1 in the
|
|
25 /// source operand.
|
|
26 static __inline__ int __DEFAULT_FN_ATTRS
|
|
27 _mm_popcnt_u32(unsigned int __A)
|
|
28 {
|
|
29 return __builtin_popcount(__A);
|
|
30 }
|
|
31
|
|
32 #ifdef __x86_64__
|
|
33 /// Counts the number of bits in the source operand having a value of 1.
|
|
34 ///
|
|
35 /// \headerfile <x86intrin.h>
|
|
36 ///
|
|
37 /// This intrinsic corresponds to the <c> POPCNT </c> instruction.
|
|
38 ///
|
|
39 /// \param __A
|
|
40 /// An unsigned 64-bit integer operand.
|
|
41 /// \returns A 64-bit integer containing the number of bits with value 1 in the
|
|
42 /// source operand.
|
|
43 static __inline__ long long __DEFAULT_FN_ATTRS
|
|
44 _mm_popcnt_u64(unsigned long long __A)
|
|
45 {
|
|
46 return __builtin_popcountll(__A);
|
|
47 }
|
|
48 #endif /* __x86_64__ */
|
|
49
|
|
50 #undef __DEFAULT_FN_ATTRS
|
|
51
|
|
52 #endif /* __POPCNTINTRIN_H */
|