Index: clang/include/clang/Basic/LangOptions.def =================================================================== --- clang/include/clang/Basic/LangOptions.def +++ clang/include/clang/Basic/LangOptions.def @@ -248,8 +248,8 @@ LANGOPT(GPUDeferDiag, 1, 0, "defer host/device related diagnostic messages for CUDA/HIP") LANGOPT(GPUExcludeWrongSideOverloads, 1, 0, "always exclude wrong side overloads in overloading resolution for CUDA/HIP") -LANGOPT(SYCL , 1, 0, "SYCL") LANGOPT(SYCLIsDevice , 1, 0, "Generate code for SYCL device") +LANGOPT(SYCLIsHost , 1, 0, "SYCL host compilation") ENUM_LANGOPT(SYCLVersion , SYCLMajorVersion, 1, SYCL_None, "Version of the SYCL standard used") LANGOPT(HIPUseNewLaunchAPI, 1, 0, "Use new kernel launching API for HIP") Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -4264,15 +4264,14 @@ defm whole_file : BooleanFFlag<"whole-file">, Group; // C++ SYCL options -defm sycl : BoolOption<"f", "sycl", - LangOpts<"SYCL">, DefaultFalse, - PosFlag, NegFlag, - BothFlags<[CoreOption], " SYCL kernels compilation for device">>, - Group; +def fsycl : Flag<["-"], "fsycl">, Flags<[NoXarchOption, CoreOption]>, + Group, HelpText<"Enables SYCL kernels compilation for device">; +def fno_sycl : Flag<["-"], "fno-sycl">, Flags<[NoXarchOption, CoreOption]>, + Group, HelpText<"Disables SYCL kernels compilation for device">; def sycl_std_EQ : Joined<["-"], "sycl-std=">, Group, Flags<[CC1Option, NoArgumentUnused, CoreOption]>, HelpText<"SYCL language standard to compile for.">, Values<"2017,121,1.2.1,sycl-1.2.1">, NormalizedValues<["SYCL_2017", "SYCL_2017", "SYCL_2017", "SYCL_2017"]>, NormalizedValuesScope<"LangOptions">, - MarshallingInfoEnum, "SYCL_None">, ShouldParseIf; + MarshallingInfoEnum, "SYCL_None">; //===----------------------------------------------------------------------===// // FLangOption + CoreOption + NoXarchOption @@ -5507,8 +5506,10 @@ def fsycl_is_device : Flag<["-"], "fsycl-is-device">, HelpText<"Generate code for SYCL device.">, - MarshallingInfoFlag>, - ShouldParseIf; + MarshallingInfoFlag>; +def fsycl_is_host : Flag<["-"], "fsycl-is-host">, + HelpText<"SYCL host compilation">, + MarshallingInfoFlag>; } // let Flags = [CC1Option, NoDriverOption] Index: clang/lib/Driver/ToolChains/Clang.cpp =================================================================== --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -4246,7 +4246,6 @@ } if (Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false)) { - CmdArgs.push_back("-fsycl"); CmdArgs.push_back("-fsycl-is-device"); if (Arg *A = Args.getLastArg(options::OPT_sycl_std_EQ)) { Index: clang/lib/Frontend/CompilerInvocation.cpp =================================================================== --- clang/lib/Frontend/CompilerInvocation.cpp +++ clang/lib/Frontend/CompilerInvocation.cpp @@ -466,6 +466,11 @@ LangOpts.NewAlignOverride = 0; } + // Prevent the user from specifying both -fsycl-is-device and -fsycl-is-host. + if (LangOpts.SYCLIsDevice && LangOpts.SYCLIsHost) + Diags.Report(diag::err_drv_argument_not_allowed_with) << "-fsycl-is-device" + << "-fsycl-is-host"; + if (Args.hasArg(OPT_fgnu89_inline) && LangOpts.CPlusPlus) Diags.Report(diag::err_drv_argument_not_allowed_with) << "-fgnu89-inline" << GetInputKindName(IK); Index: clang/lib/Frontend/InitPreprocessor.cpp =================================================================== --- clang/lib/Frontend/InitPreprocessor.cpp +++ clang/lib/Frontend/InitPreprocessor.cpp @@ -474,7 +474,7 @@ Builder.defineMacro("__FAST_RELAXED_MATH__"); } - if (LangOpts.SYCL) { + if (LangOpts.SYCLIsDevice || LangOpts.SYCLIsHost) { // SYCL Version is set to a value when building SYCL applications if (LangOpts.getSYCLVersion() == LangOptions::SYCL_2017) Builder.defineMacro("CL_SYCL_LANGUAGE_VERSION", "121"); Index: clang/test/CodeGenSYCL/convergent.cpp =================================================================== --- clang/test/CodeGenSYCL/convergent.cpp +++ clang/test/CodeGenSYCL/convergent.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsycl -fsycl-is-device -emit-llvm -disable-llvm-passes \ +// RUN: %clang_cc1 -fsycl-is-device -emit-llvm -disable-llvm-passes \ // RUN: -triple spir64-unknown-unknown-sycldevice -emit-llvm %s -o - | \ // RUN: FileCheck %s Index: clang/test/CodeGenSYCL/filescope_asm.c =================================================================== --- clang/test/CodeGenSYCL/filescope_asm.c +++ clang/test/CodeGenSYCL/filescope_asm.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsycl -fsycl-is-device -triple spir64-unknown-unknown-sycldevice -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -fsycl-is-device -triple spir64-unknown-unknown-sycldevice -emit-llvm %s -o - | FileCheck %s // // Check that file-scope asm is ignored during device-side SYCL compilation. // Index: clang/test/Frontend/sycl-aux-triple.cpp =================================================================== --- clang/test/Frontend/sycl-aux-triple.cpp +++ clang/test/Frontend/sycl-aux-triple.cpp @@ -1,5 +1,5 @@ // RUN: %clang_cc1 %s -triple spir -aux-triple x86_64-unknown-linux-gnu -E -dM | FileCheck %s -// RUN: %clang_cc1 %s -fsycl -fsycl-is-device -triple spir -aux-triple x86_64-unknown-linux-gnu -E -dM | FileCheck --check-prefix=CHECK-SYCL %s +// RUN: %clang_cc1 %s -fsycl-is-device -triple spir -aux-triple x86_64-unknown-linux-gnu -E -dM | FileCheck --check-prefix=CHECK-SYCL %s // CHECK-NOT:#define __x86_64__ 1 // CHECK-SYCL:#define __x86_64__ 1 Index: clang/test/Preprocessor/sycl-macro.cpp =================================================================== --- clang/test/Preprocessor/sycl-macro.cpp +++ clang/test/Preprocessor/sycl-macro.cpp @@ -1,7 +1,8 @@ // RUN: %clang_cc1 %s -E -dM | FileCheck %s -// RUN: %clang_cc1 %s -fsycl -sycl-std=2017 -E -dM | FileCheck --check-prefix=CHECK-SYCL-STD %s -// RUN: %clang_cc1 %s -fsycl -fsycl-is-device -sycl-std=1.2.1 -E -dM | FileCheck --check-prefix=CHECK-SYCL-STD %s -// RUN: %clang_cc1 %s -fsycl -fsycl-is-device -E -dM | FileCheck --check-prefixes=CHECK-SYCL %s +// RUN: %clang_cc1 %s -fsycl-is-device -sycl-std=2017 -E -dM | FileCheck --check-prefix=CHECK-SYCL-STD %s +// RUN: %clang_cc1 %s -fsycl-is-host -sycl-std=2017 -E -dM | FileCheck --check-prefix=CHECK-SYCL-STD %s +// RUN: %clang_cc1 %s -fsycl-is-device -sycl-std=1.2.1 -E -dM | FileCheck --check-prefix=CHECK-SYCL-STD %s +// RUN: %clang_cc1 %s -fsycl-is-device -E -dM | FileCheck --check-prefixes=CHECK-SYCL %s // CHECK-NOT:#define __SYCL_DEVICE_ONLY__ 1 // CHECK-NOT:#define CL_SYCL_LANGUAGE_VERSION 121 Index: clang/test/SemaSYCL/float128.cpp =================================================================== --- clang/test/SemaSYCL/float128.cpp +++ clang/test/SemaSYCL/float128.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple spir64 -fsycl -fsycl-is-device -verify -fsyntax-only %s -// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsycl -fsycl-is-device -fsyntax-only %s +// RUN: %clang_cc1 -triple spir64 -fsycl-is-device -verify -fsyntax-only %s +// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsycl-is-device -fsyntax-only %s typedef __float128 BIGTY; Index: clang/test/SemaSYCL/int128.cpp =================================================================== --- clang/test/SemaSYCL/int128.cpp +++ clang/test/SemaSYCL/int128.cpp @@ -1,5 +1,5 @@ // RUN: %clang_cc1 -triple spir64 -aux-triple x86_64-unknown-linux-gnu \ -// RUN: -fsycl -fsycl-is-device -verify -fsyntax-only %s +// RUN: -fsycl-is-device -verify -fsyntax-only %s typedef __uint128_t BIGTY; Index: clang/test/SemaSYCL/kernel-attribute.cpp =================================================================== --- clang/test/SemaSYCL/kernel-attribute.cpp +++ clang/test/SemaSYCL/kernel-attribute.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fsycl -fsycl-is-device -verify %s +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fsycl-is-device -verify %s // Only function templates [[clang::sycl_kernel]] int gv2 = 0; // expected-warning {{'sycl_kernel' attribute only applies to function templates}} Index: clang/test/SemaSYCL/prohibit-thread-local.cpp =================================================================== --- clang/test/SemaSYCL/prohibit-thread-local.cpp +++ clang/test/SemaSYCL/prohibit-thread-local.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsycl -fsycl-is-device -triple spir64 -verify -fsyntax-only %s +// RUN: %clang_cc1 -fsycl-is-device -triple spir64 -verify -fsyntax-only %s thread_local const int prohobit_ns_scope = 0; thread_local int prohobit_ns_scope2 = 0;