Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -4295,10 +4295,6 @@ def fsycl : Flag<["-"], "fsycl">, Flags<[NoXarchOption, CoreOption]>, Group<sycl
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">;
def sycl_std_EQ : Joined<["-"], "sycl-std=">, Group<sycl_Group>, Flags<[CC1Option, NoArgumentUnused, CoreOption]>,
HelpText<"SYCL language standard to compile for.">, Values<"2020,2017,121,1.2.1,sycl-1.2.1">,
NormalizedValues<["SYCL_2020", "SYCL_2017", "SYCL_2017", "SYCL_2017", "SYCL_2017"]>, NormalizedValuesScope<"LangOptions">,
MarshallingInfoString<LangOpts<"SYCLVersion">, "SYCL_None">, AutoNormalizeEnum;
defm sycl_esimd: BoolFOption<"sycl-explicit-simd",
LangOpts<"SYCLExplicitSIMD">, DefaultFalse,
PosFlag<SetTrue, [CC1Option], "Enable">, NegFlag<SetFalse, [], "Disable">,
Expand Down Expand Up @@ -5535,6 +5531,16 @@ def fenable_sycl_dae : Flag<["-"], "fenable-sycl-dae">,

} // 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<"2020,2017,121,1.2.1,sycl-1.2.1">,
NormalizedValues<["SYCL_2020", "SYCL_2017", "SYCL_2017", "SYCL_2017", "SYCL_2017"]>,
NormalizedValuesScope<"LangOptions">,
MarshallingInfoString<LangOpts<"SYCLVersion">, "SYCL_None">,
AutoNormalizeEnum,
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">,
Expand Down
22 changes: 8 additions & 14 deletions clang/unittests/Frontend/CompilerInvocationTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,46 +531,40 @@ TEST_F(CommandLineTest, ConditionalParsingIfFalseFlagPresent) {
ASSERT_FALSE(Diags->hasErrorOccurred());
ASSERT_FALSE(Invocation.getLangOpts()->SYCLIsDevice);
ASSERT_FALSE(Invocation.getLangOpts()->SYCLIsHost);
ASSERT_EQ(Invocation.getLangOpts()->getSYCLVersion(), LangOptions::SYCL_2017);
ASSERT_EQ(Invocation.getLangOpts()->getSYCLVersion(), LangOptions::SYCL_None);

Invocation.generateCC1CommandLine(GeneratedArgs, *this);

ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fsycl-is-device"))));
ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fsycl-is-host"))));

// FIXME: generateCC1CommandLine is only used by the unit test system and
// cannot handle this case. It passes along the -sycl-std because the option
// definition does not specify that it relies on -fsycl any longer (because
// there is no syntax I could find that would allow it). However, the option
// is handled properly on a real invocation. See: Clang::ConstructJob().
ASSERT_THAT(GeneratedArgs, Contains(HasSubstr("-sycl-std=")));
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_TRUE(Diags->hasErrorOccurred());
ASSERT_FALSE(Diags->hasErrorOccurred());
ASSERT_EQ(Invocation.getLangOpts()->getSYCLVersion(), LangOptions::SYCL_None);

Invocation.generateCC1CommandLine(GeneratedArgs, *this);

ASSERT_THAT(GeneratedArgs, Not(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_TRUE(Diags->hasErrorOccurred());
ASSERT_FALSE(Diags->hasErrorOccurred());
ASSERT_EQ(Invocation.getLangOpts()->getSYCLVersion(), LangOptions::SYCL_2017);

Invocation.generateCC1CommandLine(GeneratedArgs, *this);

ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fsycl"))));
ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fsycl-is-device")));
ASSERT_THAT(GeneratedArgs, Contains(StrEq("-sycl-std=2017")));
}

Expand Down