Skip to content

Commit 62de0c4

Browse files
stevemerrbader
authored andcommitted
[SYCL] Add clang driver option -fsycl-device-only
The new option "-fsycl-device-only" is simply an alternate spelling of "--sycl" but it was determined to be a more appropriate spelling to propose to the LLVM community. Supporting both options here is intended to ease any transition of tests, etc. Signed-off-by: Steve Merritt <[email protected]>
1 parent 8535b24 commit 62de0c4

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3273,8 +3273,9 @@ defm stack_arrays : BooleanFFlag<"stack-arrays">, Group<gfortran_Group>;
32733273
defm underscoring : BooleanFFlag<"underscoring">, Group<gfortran_Group>;
32743274
defm whole_file : BooleanFFlag<"whole-file">, Group<gfortran_Group>;
32753275

3276-
def sycl : Flag<["--"], "sycl">,
3276+
def sycl_device_only : Flag<["-"], "fsycl-device-only">,
32773277
HelpText<"Compile SYCL kernels for device">;
3278+
def sycl : Flag<["--"], "sycl">, Alias<sycl_device_only>;
32783279

32793280
def reuse_exe_EQ : Joined<["-"], "reuse-exe=">,
32803281
HelpText<"Speed up FPGA aoc compile if the device code in <exe> is unchanged.">,

clang/lib/Driver/Driver.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ phases::ID Driver::getFinalPhase(const DerivedArgList &DAL,
295295

296296
// -S only runs up to the backend.
297297
} else if ((PhaseArg = DAL.getLastArg(options::OPT_S)) ||
298-
(PhaseArg = DAL.getLastArg(options::OPT_sycl))) {
298+
(PhaseArg = DAL.getLastArg(options::OPT_sycl_device_only))) {
299299
FinalPhase = phases::Backend;
300300

301301
// -c compilation only runs up to the assembler.
@@ -1180,7 +1180,7 @@ Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) {
11801180
T.setObjectFormat(llvm::Triple::COFF);
11811181
TargetTriple = T.str();
11821182
}
1183-
if (Args.hasArg(options::OPT_sycl)) {
1183+
if (Args.hasArg(options::OPT_sycl_device_only)) {
11841184
// --sycl implies spir arch and SYCL Device
11851185
llvm::Triple T(TargetTriple);
11861186
// FIXME: defaults to spir64, should probably have a way to set spir
@@ -4357,7 +4357,7 @@ Action *Driver::ConstructPhaseAction(
43574357
Args.hasArg(options::OPT_S) ? types::TY_LLVM_IR : types::TY_LLVM_BC;
43584358
return C.MakeAction<BackendJobAction>(Input, Output);
43594359
}
4360-
if (Args.hasArg(options::OPT_sycl)) {
4360+
if (Args.hasArg(options::OPT_sycl_device_only)) {
43614361
if (Args.hasFlag(options::OPT_fsycl_use_bitcode,
43624362
options::OPT_fno_sycl_use_bitcode, true))
43634363
return C.MakeAction<BackendJobAction>(Input, types::TY_LLVM_BC);

clang/test/Driver/sycl-device.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/// Check that compiling for sycl device is disabled by default:
2+
// RUN: %clang -### %s 2>&1 \
3+
// RUN: | FileCheck -check-prefix=CHECK-DEFAULT %s
4+
// CHECK-DEFAULT-NOT: "-fsycl-is-device"
5+
6+
/// Check "-fsycl-is-device" is passed when compiling for device:
7+
// RUN: %clang -### -fsycl-device-only %s 2>&1 \
8+
// RUN: | FileCheck -check-prefix=CHECK-SYCL-DEV %s
9+
// CHECK-SYCL-DEV: "-fsycl-is-device"

0 commit comments

Comments
 (0)