diff options
-rw-r--r-- | clang/include/clang/Basic/LangOptions.def | 2 | ||||
-rw-r--r-- | clang/include/clang/Driver/Options.td | 28 | ||||
-rw-r--r-- | clang/lib/Driver/ToolChains/Clang.cpp | 1 | ||||
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 5 | ||||
-rw-r--r-- | clang/lib/Frontend/InitPreprocessor.cpp | 2 | ||||
-rw-r--r-- | clang/test/CodeGenSYCL/convergent.cpp | 2 | ||||
-rw-r--r-- | clang/test/CodeGenSYCL/filescope_asm.c | 2 | ||||
-rw-r--r-- | clang/test/Frontend/sycl-aux-triple.cpp | 2 | ||||
-rw-r--r-- | clang/test/Frontend/sycl.cpp | 13 | ||||
-rw-r--r-- | clang/test/Preprocessor/sycl-macro.cpp | 7 | ||||
-rw-r--r-- | clang/test/SemaSYCL/float128.cpp | 4 | ||||
-rw-r--r-- | clang/test/SemaSYCL/int128.cpp | 2 | ||||
-rw-r--r-- | clang/test/SemaSYCL/kernel-attribute.cpp | 2 | ||||
-rw-r--r-- | clang/test/SemaSYCL/prohibit-thread-local.cpp | 2 | ||||
-rw-r--r-- | clang/unittests/Frontend/CompilerInvocationTest.cpp | 19 |
15 files changed, 59 insertions, 34 deletions
diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def index 7efc661..1560a1f 100644 --- a/clang/include/clang/Basic/LangOptions.def +++ b/clang/include/clang/Basic/LangOptions.def @@ -249,8 +249,8 @@ LANGOPT(GPUMaxThreadsPerBlock, 32, 1024, "default max threads per block for kern 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") diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index f4d4ece..a3a0d86 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -4283,15 +4283,10 @@ defm underscoring : BooleanFFlag<"underscoring">, Group<gfortran_Group>; defm whole_file : BooleanFFlag<"whole-file">, Group<gfortran_Group>; // C++ SYCL options -defm sycl : BoolOption<"f", "sycl", - LangOpts<"SYCL">, DefaultFalse, - PosFlag<SetTrue, [CC1Option], "Enable">, NegFlag<SetFalse, [], "Disable">, - BothFlags<[CoreOption], " SYCL kernels compilation for device">>, - Group<sycl_Group>; -def sycl_std_EQ : Joined<["-"], "sycl-std=">, Group<sycl_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<LangOpts<"SYCLVersion">, "SYCL_None">, ShouldParseIf<fsycl.KeyPath>; +def fsycl : Flag<["-"], "fsycl">, Flags<[NoXarchOption, CoreOption]>, + Group<sycl_Group>, HelpText<"Enables SYCL kernels compilation for device">; +def fno_sycl : Flag<["-"], "fno-sycl">, Flags<[NoXarchOption, CoreOption]>, + Group<sycl_Group>, HelpText<"Disables SYCL kernels compilation for device">; //===----------------------------------------------------------------------===// // FLangOption + CoreOption + NoXarchOption @@ -5546,11 +5541,22 @@ def fopenmp_host_ir_file_path : Separate<["-"], "fopenmp-host-ir-file-path">, def fsycl_is_device : Flag<["-"], "fsycl-is-device">, HelpText<"Generate code for SYCL device.">, - MarshallingInfoFlag<LangOpts<"SYCLIsDevice">>, - ShouldParseIf<fsycl.KeyPath>; + MarshallingInfoFlag<LangOpts<"SYCLIsDevice">>; +def fsycl_is_host : Flag<["-"], "fsycl-is-host">, + HelpText<"SYCL host compilation">, + MarshallingInfoFlag<LangOpts<"SYCLIsHost">>; } // let Flags = [CC1Option, NoDriverOption] +def sycl_std_EQ : Joined<["-"], "sycl-std=">, Group<sycl_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<LangOpts<"SYCLVersion">, "SYCL_None">, + ShouldParseIf<!strconcat(fsycl_is_device.KeyPath, "||", fsycl_is_host.KeyPath)>; + defm cuda_approx_transcendentals : BoolFOption<"cuda-approx-transcendentals", LangOpts<"CUDADeviceApproxTranscendentals">, DefaultFalse, PosFlag<SetTrue, [CC1Option], "Use">, NegFlag<SetFalse, [], "Don't use">, diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 2a3dde9..95275b1 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -4251,7 +4251,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, } 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)) { diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 5ddd54c..ffaf368 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -466,6 +466,11 @@ static bool FixupInvocation(CompilerInvocation &Invocation, 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); diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index c64a912..15f2545 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -474,7 +474,7 @@ static void InitializeStandardPredefinedMacros(const TargetInfo &TI, 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"); diff --git a/clang/test/CodeGenSYCL/convergent.cpp b/clang/test/CodeGenSYCL/convergent.cpp index 784fb89..58be1b1 100644 --- a/clang/test/CodeGenSYCL/convergent.cpp +++ b/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 diff --git a/clang/test/CodeGenSYCL/filescope_asm.c b/clang/test/CodeGenSYCL/filescope_asm.c index 5f4f670..3c1c12f 100644 --- a/clang/test/CodeGenSYCL/filescope_asm.c +++ b/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. // diff --git a/clang/test/Frontend/sycl-aux-triple.cpp b/clang/test/Frontend/sycl-aux-triple.cpp index ae36b53..38b6a24 100644 --- a/clang/test/Frontend/sycl-aux-triple.cpp +++ b/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 diff --git a/clang/test/Frontend/sycl.cpp b/clang/test/Frontend/sycl.cpp new file mode 100644 index 0000000..61a30d5 --- /dev/null +++ b/clang/test/Frontend/sycl.cpp @@ -0,0 +1,13 @@ +// Test that we disallow -cc1 -fsycl, even when specifying device or host mode. + +// RUN: not %clang_cc1 -fsycl %s 2>&1 | FileCheck --check-prefix=ERROR %s +// RUN: not %clang_cc1 -fsycl -fsycl-is-device %s 2>&1 | FileCheck --check-prefix=ERROR %s +// RUN: not %clang_cc1 -fsycl -fsycl-is-host %s 2>&1 | FileCheck --check-prefix=ERROR %s + +// ERROR: error: unknown argument: '-fsycl' + +// Test that you cannot specify -fsycl-is-device and -fsycl-is-host at the same time. +// RUN: not %clang_cc1 -fsycl-is-device -fsycl-is-host %s 2>&1 | FileCheck --check-prefix=ERROR-BOTH %s +// RUN: not %clang_cc1 -fsycl-is-host -fsycl-is-device %s 2>&1 | FileCheck --check-prefix=ERROR-BOTH %s + +// ERROR-BOTH: error: invalid argument '-fsycl-is-device' not allowed with '-fsycl-is-host' diff --git a/clang/test/Preprocessor/sycl-macro.cpp b/clang/test/Preprocessor/sycl-macro.cpp index 408dc20..d1d8302 100644 --- a/clang/test/Preprocessor/sycl-macro.cpp +++ b/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 diff --git a/clang/test/SemaSYCL/float128.cpp b/clang/test/SemaSYCL/float128.cpp index d2d520b..b91535e 100644 --- a/clang/test/SemaSYCL/float128.cpp +++ b/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; diff --git a/clang/test/SemaSYCL/int128.cpp b/clang/test/SemaSYCL/int128.cpp index 38271bc..f6f92c2 100644 --- a/clang/test/SemaSYCL/int128.cpp +++ b/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; diff --git a/clang/test/SemaSYCL/kernel-attribute.cpp b/clang/test/SemaSYCL/kernel-attribute.cpp index ae9589e..84ba69f 100644 --- a/clang/test/SemaSYCL/kernel-attribute.cpp +++ b/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}} diff --git a/clang/test/SemaSYCL/prohibit-thread-local.cpp b/clang/test/SemaSYCL/prohibit-thread-local.cpp index 4fd1136..e507489 100644 --- a/clang/test/SemaSYCL/prohibit-thread-local.cpp +++ b/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; diff --git a/clang/unittests/Frontend/CompilerInvocationTest.cpp b/clang/unittests/Frontend/CompilerInvocationTest.cpp index 89e024d..b846e6e 100644 --- a/clang/unittests/Frontend/CompilerInvocationTest.cpp +++ b/clang/unittests/Frontend/CompilerInvocationTest.cpp @@ -516,7 +516,8 @@ TEST_F(CommandLineTest, ConditionalParsingIfFalseFlagNotPresent) { CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags); ASSERT_FALSE(Diags->hasErrorOccurred()); - ASSERT_FALSE(Invocation.getLangOpts()->SYCL); + ASSERT_FALSE(Invocation.getLangOpts()->SYCLIsDevice); + ASSERT_FALSE(Invocation.getLangOpts()->SYCLIsHost); ASSERT_EQ(Invocation.getLangOpts()->getSYCLVersion(), LangOptions::SYCL_None); Invocation.generateCC1CommandLine(GeneratedArgs, *this); @@ -531,42 +532,42 @@ TEST_F(CommandLineTest, ConditionalParsingIfFalseFlagPresent) { CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags); ASSERT_FALSE(Diags->hasErrorOccurred()); - ASSERT_FALSE(Invocation.getLangOpts()->SYCL); + ASSERT_FALSE(Invocation.getLangOpts()->SYCLIsDevice); + ASSERT_FALSE(Invocation.getLangOpts()->SYCLIsHost); ASSERT_EQ(Invocation.getLangOpts()->getSYCLVersion(), LangOptions::SYCL_None); Invocation.generateCC1CommandLine(GeneratedArgs, *this); - ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fsycl")))); + ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fsycl-is-device")))); + ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fsycl-is-host")))); ASSERT_THAT(GeneratedArgs, Not(Contains(HasSubstr("-sycl-std=")))); } TEST_F(CommandLineTest, ConditionalParsingIfTrueFlagNotPresent) { - const char *Args[] = {"-fsycl"}; + const char *Args[] = {"-fsycl-is-host"}; CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags); ASSERT_FALSE(Diags->hasErrorOccurred()); - ASSERT_TRUE(Invocation.getLangOpts()->SYCL); ASSERT_EQ(Invocation.getLangOpts()->getSYCLVersion(), LangOptions::SYCL_None); Invocation.generateCC1CommandLine(GeneratedArgs, *this); - ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fsycl"))); + ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fsycl-is-host"))); ASSERT_THAT(GeneratedArgs, Not(Contains(HasSubstr("-sycl-std=")))); } TEST_F(CommandLineTest, ConditionalParsingIfTrueFlagPresent) { - const char *Args[] = {"-fsycl", "-sycl-std=2017"}; + const char *Args[] = {"-fsycl-is-device", "-sycl-std=2017"}; CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags); ASSERT_FALSE(Diags->hasErrorOccurred()); - ASSERT_TRUE(Invocation.getLangOpts()->SYCL); ASSERT_EQ(Invocation.getLangOpts()->getSYCLVersion(), LangOptions::SYCL_2017); Invocation.generateCC1CommandLine(GeneratedArgs, *this); - ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fsycl"))); + ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fsycl-is-device"))); ASSERT_THAT(GeneratedArgs, Contains(StrEq("-sycl-std=2017"))); } |