aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Frontend
diff options
context:
space:
mode:
authorAaron Ballman <aaron@aaronballman.com>2021-03-17 08:26:07 -0400
committerAaron Ballman <aaron@aaronballman.com>2021-03-17 08:27:19 -0400
commitc165a99a1b8861af87e0509a2e14debf2764804b (patch)
treefc7ba5970482aa7419d75a59f7b988a90222f34c /clang/unittests/Frontend
parentcca3167de0b6f95916fa9d2338beccb74132e526 (diff)
downloadllvm-c165a99a1b8861af87e0509a2e14debf2764804b.zip
llvm-c165a99a1b8861af87e0509a2e14debf2764804b.tar.gz
llvm-c165a99a1b8861af87e0509a2e14debf2764804b.tar.bz2
[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.
Diffstat (limited to 'clang/unittests/Frontend')
-rw-r--r--clang/unittests/Frontend/CompilerInvocationTest.cpp19
1 files changed, 10 insertions, 9 deletions
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")));
}