Skip to content

Commit 863d975

Browse files
committed
[SYCL][Driver] Add clang driver option to enable SYCL compilation mode
Summary: As a first step this implementation enables compilation of the offload code. Reviewers: ABataev Subscribers: ebevhan, Anastasia, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D74048
1 parent 67905fc commit 863d975

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ def pedantic_Group : OptionGroup<"<pedantic group>">, Group<f_Group>,
124124
def opencl_Group : OptionGroup<"<opencl group>">, Group<f_Group>,
125125
DocName<"OpenCL flags">;
126126

127+
def sycl_Group : OptionGroup<"<SYCL group>">, Group<f_Group>,
128+
DocName<"SYCL flags">;
129+
127130
def m_Group : OptionGroup<"<m group>">, Group<CompileOnly_Group>,
128131
DocName<"Target-dependent compilation options">;
129132

@@ -3407,6 +3410,11 @@ defm stack_arrays : BooleanFFlag<"stack-arrays">, Group<gfortran_Group>;
34073410
defm underscoring : BooleanFFlag<"underscoring">, Group<gfortran_Group>;
34083411
defm whole_file : BooleanFFlag<"whole-file">, Group<gfortran_Group>;
34093412

3413+
// C++ SYCL options
3414+
def fsycl : Flag<["-"], "fsycl">, Group<sycl_Group>,
3415+
HelpText<"Enable SYCL kernels compilation for device">;
3416+
def fno_sycl : Flag<["-"], "fno-sycl">, Group<sycl_Group>,
3417+
HelpText<"Disable SYCL kernels compilation for device">;
34103418

34113419
include "CC1Options.td"
34123420

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4023,6 +4023,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
40234023
CmdArgs.push_back(Args.MakeArgString(NormalizedTriple));
40244024
}
40254025

4026+
if (Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false))
4027+
CmdArgs.push_back("-fsycl-is-device");
4028+
40264029
if (IsOpenMPDevice) {
40274030
// We have to pass the triple of the host if compiling for an OpenMP device.
40284031
std::string NormalizedTriple =

clang/test/Driver/sycl.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: %clang -### -fsycl -c %s 2>&1 | FileCheck %s --check-prefix=ENABLED
2+
// RUN: %clang -### -fsycl %s 2>&1 | FileCheck %s --check-prefix=ENABLED
3+
// RUN: %clang -### -fno-sycl -fsycl %s 2>&1 | FileCheck %s --check-prefix=ENABLED
4+
// RUN: %clangxx -### -fsycl %s 2>&1 | FileCheck %s --check-prefix=ENABLED
5+
// RUN: %clangxx -### -fno-sycl %s 2>&1 | FileCheck %s --check-prefix=DISABLED
6+
// RUN: %clangxx -### -fsycl -fno-sycl %s 2>&1 | FileCheck %s --check-prefix=DISABLED
7+
// RUN: %clangxx -### %s 2>&1 | FileCheck %s --check-prefix=DISABLED
8+
9+
// ENABLED: "-cc1"{{.*}} "-fsycl-is-device"
10+
// DISABLED-NOT: "-fsycl-is-device"

0 commit comments

Comments
 (0)