Skip to content

Commit 107bbd0

Browse files
authored
[SYCL] Move __ENABLE_USM_ADDR_SPACE__ initialization into FE (#3993)
Also restores unit-level testing for this target-specific macro. Signed-off-by: Artem Gindinson <[email protected]>
1 parent 887370e commit 107bbd0

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4676,12 +4676,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
46764676
if (HasFPGA)
46774677
CmdArgs.push_back("-fsycl-disable-range-rounding");
46784678

4679-
// Enable generation of USM address spaces for FPGA.
4680-
// __ENABLE_USM_ADDR_SPACE__ will be used during compilation of SYCL headers
4681-
if (getToolChain().getTriple().getSubArch() ==
4682-
llvm::Triple::SPIRSubArch_fpga)
4683-
CmdArgs.push_back("-D__ENABLE_USM_ADDR_SPACE__");
4684-
46854679
// Add any options that are needed specific to SYCL offload while
46864680
// performing the host side compilation.
46874681
if (!IsSYCLOffloadDevice) {

clang/lib/Frontend/InitPreprocessor.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,6 +1184,9 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
11841184
if (DeviceTriple.isSPIR() &&
11851185
DeviceSubArch != llvm::Triple::SPIRSubArch_fpga)
11861186
Builder.defineMacro("SYCL_USE_NATIVE_FP_ATOMICS");
1187+
// Enable generation of USM address spaces for FPGA.
1188+
if (DeviceSubArch == llvm::Triple::SPIRSubArch_fpga)
1189+
Builder.defineMacro("__ENABLE_USM_ADDR_SPACE__");
11871190
}
11881191
if (LangOpts.SYCLUnnamedLambda)
11891192
Builder.defineMacro("__SYCL_UNNAMED_LAMBDA__");

clang/test/Preprocessor/sycl-macro-target-specific.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,16 @@
2323
// RUN: | FileCheck --check-prefix=CHECK-SYCL-FP-ATOMICS-NEG %s
2424
// CHECK-SYCL-FP-ATOMICS: #define SYCL_USE_NATIVE_FP_ATOMICS
2525
// CHECK-SYCL-FP-ATOMICS-NEG-NOT: #define SYCL_USE_NATIVE_FP_ATOMICS
26+
27+
// RUN: %clang_cc1 %s -fsycl-is-device -triple spir64_fpga-unknown-unknown-sycldevice -E -dM \
28+
// RUN: | FileCheck --check-prefix=CHECK-USM-ADDR-SPACE %s
29+
// RUN: %clang_cc1 %s -fsycl-is-device -triple spir64-unknown-unknown-sycldevice -E -dM \
30+
// RUN: | FileCheck --check-prefix=CHECK-USM-ADDR-SPACE-NEG %s
31+
// RUN: %clang_cc1 %s -fsycl-is-device -triple spir64_gen-unknown-unknown-sycldevice -E -dM \
32+
// RUN: | FileCheck --check-prefix=CHECK-USM-ADDR-SPACE-NEG %s
33+
// RUN: %clang_cc1 %s -fsycl-is-device -triple spir64_x86_64-unknown-unknown-sycldevice -E -dM \
34+
// RUN: | FileCheck --check-prefix=CHECK-USM-ADDR-SPACE-NEG %s
35+
// RUN: %clang_cc1 %s -fsycl-is-device -triple nvptx64-nvidia-nvcl-sycldevice -E -dM \
36+
// RUN: | FileCheck --check-prefix=CHECK-USM-ADDR-SPACE-NEG %s
37+
// CHECK-USM-ADDR-SPACE: #define __ENABLE_USM_ADDR_SPACE__
38+
// CHECK-USM-ADDR-SPACE-NEG-NOT: #define __ENABLE_USM_ADDR_SPACE__

0 commit comments

Comments
 (0)