Skip to content

Commit f9520e6

Browse files
Naghasanbader
authored andcommitted
[SPIR-V] Add macro definition when -fdeclare-spirv-builtins is activated
Define __SPIRV_BUILTIN_DECLARATIONS__ when passing -fdeclare-spirv-builtins to clang. Signed-off-by: Victor Lomuller <[email protected]>
1 parent 8d593b8 commit f9520e6

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

clang/lib/Frontend/InitPreprocessor.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,10 @@ static void InitializeStandardPredefinedMacros(const TargetInfo &TI,
467467
Builder.defineMacro("CL_SYCL_LANGUAGE_VERSION", "121");
468468
}
469469

470+
if (LangOpts.DeclareSPIRVBuiltins) {
471+
Builder.defineMacro("__SPIRV_BUILTIN_DECLARATIONS__");
472+
}
473+
470474
// Not "standard" per se, but available even with the -undef flag.
471475
if (LangOpts.AsmPreprocessor)
472476
Builder.defineMacro("__ASSEMBLER__");
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: %clang_cc1 %s -E -dM | FileCheck %s
2+
// RUN: %clang_cc1 %s -fdeclare-spirv-builtins -E -dM | FileCheck --check-prefix=CHECK-SPIRV %s
3+
4+
// CHECK-NOT:#define __SPIRV_BUILTIN_DECLARATIONS__
5+
6+
// CHECK-SPIRV:#define __SPIRV_BUILTIN_DECLARATIONS__

0 commit comments

Comments
 (0)