File tree Expand file tree Collapse file tree 3 files changed +32
-5
lines changed Expand file tree Collapse file tree 3 files changed +32
-5
lines changed Original file line number Diff line number Diff line change @@ -153,6 +153,12 @@ CUDA Support in Clang
153
153
154
154
- ...
155
155
156
+ X86 Support in Clang
157
+ --------------------
158
+
159
+ - The x86 intrinsics ``_mm_popcnt_u32 `` and ``_mm_popcnt_u64 `` may now be used
160
+ within constexpr expressions.
161
+
156
162
Internal API Changes
157
163
--------------------
158
164
Original file line number Diff line number Diff line change 13
13
/* Define the default attributes for the functions in this file. */
14
14
#define __DEFAULT_FN_ATTRS __attribute__ ((__always_inline__, __nodebug__, __target__(" popcnt" )))
15
15
16
+ #if defined(__cplusplus) && (__cplusplus >= 201103L)
17
+ #define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS constexpr
18
+ #else
19
+ #define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS
20
+ #endif
21
+
16
22
// / Counts the number of bits in the source operand having a value of 1.
17
23
// /
18
24
// / \headerfile <x86intrin.h>
23
29
// / An unsigned 32-bit integer operand.
24
30
// / \returns A 32-bit integer containing the number of bits with value 1 in the
25
31
// / source operand.
26
- static __inline__ int __DEFAULT_FN_ATTRS
32
+ static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR
27
33
_mm_popcnt_u32 (unsigned int __A)
28
34
{
29
35
return __builtin_popcount (__A);
@@ -40,13 +46,14 @@ _mm_popcnt_u32(unsigned int __A)
40
46
// / An unsigned 64-bit integer operand.
41
47
// / \returns A 64-bit integer containing the number of bits with value 1 in the
42
48
// / source operand.
43
- static __inline__ long long __DEFAULT_FN_ATTRS
49
+ static __inline__ long long __DEFAULT_FN_ATTRS_CONSTEXPR
44
50
_mm_popcnt_u64 (unsigned long long __A)
45
51
{
46
52
return __builtin_popcountll (__A);
47
53
}
48
54
#endif /* __x86_64__ */
49
55
50
56
#undef __DEFAULT_FN_ATTRS
57
+ #undef __DEFAULT_FN_ATTRS_CONSTEXPR
51
58
52
59
#endif /* __POPCNTINTRIN_H */
Original file line number Diff line number Diff line change 1
- // RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +popcnt -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-POPCNT
2
- // RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -emit-llvm -o - | FileCheck %s
3
-
1
+ // RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +popcnt -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-POPCNT
2
+ // RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +popcnt -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-POPCNT
3
+ // RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-apple-darwin -emit-llvm -o - | FileCheck %s
4
+ // RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin -emit-llvm -o - | FileCheck %s
4
5
5
6
#include <x86intrin.h>
6
7
@@ -39,3 +40,16 @@ long long test__popcntq(unsigned long long __X) {
39
40
return __popcntq (__X );
40
41
}
41
42
#endif
43
+
44
+ // Test constexpr handling.
45
+ #if defined(__cplusplus ) && (__cplusplus >= 201103L )
46
+ #if defined(__POPCNT__ )
47
+ char ctpop32_0 [_mm_popcnt_u32 (0x00000000 ) == 0 ? 1 : -1 ];
48
+ char ctpop32_1 [_mm_popcnt_u32 (0x000000F0 ) == 4 ? 1 : -1 ];
49
+
50
+ #ifdef __x86_64__
51
+ char ctpop64_0 [_mm_popcnt_u64 (0x0000000000000000ULL ) == 0 ? 1 : -1 ];
52
+ char ctpop64_1 [_mm_popcnt_u64 (0xF000000000000001ULL ) == 5 ? 1 : -1 ];
53
+ #endif
54
+ #endif
55
+ #endif
You can’t perform that action at this time.
0 commit comments