File tree Expand file tree Collapse file tree 4 files changed +29
-6
lines changed Expand file tree Collapse file tree 4 files changed +29
-6
lines changed Original file line number Diff line number Diff line change @@ -69,7 +69,8 @@ It can be used like this:
69
69
70
70
When using device offloading, a builtin is considered available if it is
71
71
available on either the host or the device targets.
72
- Use ``__has_target_builtin `` to consider only the current target.
72
+ Use ``__has_target_builtin `` to consider only the current target for an
73
+ offloading target.
73
74
74
75
``__has_constexpr_builtin ``
75
76
---------------------------
@@ -129,6 +130,8 @@ It can be used like this:
129
130
``__has_target_builtin `` should not be used to detect support for a builtin macro;
130
131
use ``#ifdef `` instead.
131
132
133
+ ``__has_target_built `` is only defined for offloading targets.
134
+
132
135
.. _langext-__has_feature-__has_extension :
133
136
134
137
``__has_feature `` and ``__has_extension ``
Original file line number Diff line number Diff line change @@ -104,6 +104,12 @@ Non-comprehensive list of changes in this release
104
104
New Compiler Flags
105
105
------------------
106
106
107
+ New Compiler Builtins
108
+ ---------------------
109
+
110
+ - The new ``__has_target_builtin `` macro can be used to check if a builtin is available
111
+ on the current offloading target.
112
+
107
113
Deprecated Compiler Flags
108
114
-------------------------
109
115
Original file line number Diff line number Diff line change @@ -357,7 +357,12 @@ void Preprocessor::RegisterBuiltinMacros() {
357
357
Ident__has_builtin = RegisterBuiltinMacro (" __has_builtin" );
358
358
Ident__has_constexpr_builtin =
359
359
RegisterBuiltinMacro (" __has_constexpr_builtin" );
360
- Ident__has_target_builtin = RegisterBuiltinMacro (" __has_target_builtin" );
360
+ if (getLangOpts ().OpenMPIsTargetDevice || getLangOpts ().CUDAIsDevice ||
361
+ getLangOpts ().SYCLIsDevice )
362
+ Ident__has_target_builtin = RegisterBuiltinMacro (" __has_target_builtin" );
363
+ else
364
+ Ident__has_target_builtin = nullptr ;
365
+
361
366
Ident__has_attribute = RegisterBuiltinMacro (" __has_attribute" );
362
367
if (!getLangOpts ().CPlusPlus )
363
368
Ident__has_c_attribute = RegisterBuiltinMacro (" __has_c_attribute" );
Original file line number Diff line number Diff line change 1
1
// RUN: %clang_cc1 -fopenmp -triple=spirv64 -fopenmp-is-target-device \
2
- // RUN: -aux-triple x86_64-linux-unknown -E %s | FileCheck -implicit-check-not=BAD %s
2
+ // RUN: -aux-triple x86_64-linux-unknown -E %s | FileCheck -implicit-check-not="{{ BAD|DOESNT}}" %s
3
3
4
4
// RUN: %clang_cc1 -fopenmp -triple=nvptx64 -fopenmp-is-target-device \
5
- // RUN: -aux-triple x86_64-linux-unknown -E %s | FileCheck -implicit-check-not=BAD %s
5
+ // RUN: -aux-triple x86_64-linux-unknown -E %s | FileCheck -implicit-check-not="{{ BAD|DOESNT}}" %s
6
6
7
7
// RUN: %clang_cc1 -fopenmp -triple=amdgcn-amd-amdhsa -fopenmp-is-target-device \
8
- // RUN: -aux-triple x86_64-linux-unknown -E %s | FileCheck -implicit-check-not=BAD %s
8
+ // RUN: -aux-triple x86_64-linux-unknown -E %s | FileCheck -implicit-check-not="{{ BAD|DOESNT}}" %s
9
9
10
10
// RUN: %clang_cc1 -fopenmp -triple=aarch64 -fopenmp-is-target-device \
11
- // RUN: -aux-triple x86_64-linux-unknown -E %s | FileCheck -implicit-check-not=BAD %s
11
+ // RUN: -aux-triple x86_64-linux-unknown -E %s | FileCheck -implicit-check-not="{{BAD|DOESNT}}" %s
12
+
13
+ // RUN: %clang_cc1 -triple=aarch64 -E %s | FileCheck -check-prefix=CHECK-NOTOFFLOAD -implicit-check-not="{{GOOD|HAS|BAD}}" %s
12
14
13
15
// CHECK: GOOD
16
+
17
+ // CHECK-NOTOFFLOAD: DOESNT
18
+ #ifdef __has_target_builtin
19
+ HAS
14
20
#if __has_target_builtin(__builtin_ia32_pause)
15
21
BAD
16
22
#else
17
23
GOOD
18
24
#endif
25
+ #else
26
+ DOESNT
27
+ #endif
You can’t perform that action at this time.
0 commit comments