From c165a99a1b8861af87e0509a2e14debf2764804b Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Wed, 17 Mar 2021 08:26:07 -0400 Subject: [SYCL] Rework the SYCL driver options SYCL compilations initiated by the driver will spawn off one or more frontend compilation jobs (one for device and one for host). This patch reworks the driver options to make upstreaming this from the downstream SYCL fork easier. This patch introduces a language option to identify host executions (SYCLIsHost) and a -cc1 frontend option to enable this mode. -fsycl and -fno-sycl become driver-only options that are rejected when passed to -cc1. This is because the frontend and beyond should be looking at whether the user is doing a device or host compilation specifically. Because the frontend should only ever be in one mode or the other, -fsycl-is-device and -fsycl-is-host are mutually exclusive options. --- clang/unittests/Frontend/CompilerInvocationTest.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'clang/unittests/Frontend/CompilerInvocationTest.cpp') 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"))); } -- cgit v1.1