aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/InitPreprocessor.cpp
diff options
context:
space:
mode:
authorYaxun (Sam) Liu <yaxun.liu@amd.com>2021-11-30 14:45:16 -0500
committerYaxun (Sam) Liu <yaxun.liu@amd.com>2021-12-07 18:08:16 -0500
commitd55f05d9f7dc8aa0468a9db19d84671acf05823a (patch)
treee6c1747c39ab2e436915bd781a6ec7113886ca31 /clang/lib/Frontend/InitPreprocessor.cpp
parentf75885977cefe4d5ebbe51f85b353bb9989dd777 (diff)
downloadllvm-d55f05d9f7dc8aa0468a9db19d84671acf05823a.zip
llvm-d55f05d9f7dc8aa0468a9db19d84671acf05823a.tar.gz
llvm-d55f05d9f7dc8aa0468a9db19d84671acf05823a.tar.bz2
[CUDA][HIP] Add pre-defined macro `__CLANG_RDC__`
nvcc defines __CUDACC_RDC__ for both host and device compilation when -rdc=true is specified (https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#nvcc-identification-macro) This patch defines __CLANG_RDC__ when -fgpu-rdc is specified for CUDA/HIP. Reviewed by: Artem Belevich Differential Revision: https://reviews.llvm.org/D114812
Diffstat (limited to 'clang/lib/Frontend/InitPreprocessor.cpp')
-rw-r--r--clang/lib/Frontend/InitPreprocessor.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp
index 0c15344..629f991 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -500,8 +500,12 @@ static void InitializeStandardPredefinedMacros(const TargetInfo &TI,
// Not "standard" per se, but available even with the -undef flag.
if (LangOpts.AsmPreprocessor)
Builder.defineMacro("__ASSEMBLER__");
- if (LangOpts.CUDA && !LangOpts.HIP)
- Builder.defineMacro("__CUDA__");
+ if (LangOpts.CUDA) {
+ if (LangOpts.GPURelocatableDeviceCode)
+ Builder.defineMacro("__CLANG_RDC__");
+ if (!LangOpts.HIP)
+ Builder.defineMacro("__CUDA__");
+ }
if (LangOpts.HIP) {
Builder.defineMacro("__HIP__");
Builder.defineMacro("__HIPCC__");