forked from OSchip/llvm-project
[clang] Use enum for LangOptions::SYCLVersion instead of unsigned
`LangOptions::SYCLVersion` can only have two values. This patch introduces an enum that allows us to reduce the member size from 32 bits to 1 bit. Consequently, this also makes marshalling of this option fit into our model for enums: D84674. Reviewed By: bader Differential Revision: https://reviews.llvm.org/D93540
This commit is contained in:
parent
70410a2649
commit
5a85526728
|
@ -246,7 +246,7 @@ LANGOPT(GPUExcludeWrongSideOverloads, 1, 0, "always exclude wrong side overloads
|
|||
|
||||
LANGOPT(SYCL , 1, 0, "SYCL")
|
||||
LANGOPT(SYCLIsDevice , 1, 0, "Generate code for SYCL device")
|
||||
LANGOPT(SYCLVersion , 32, 0, "Version of the SYCL standard used")
|
||||
ENUM_LANGOPT(SYCLVersion , SYCLMajorVersion, 1, SYCL_None, "Version of the SYCL standard used")
|
||||
|
||||
LANGOPT(HIPUseNewLaunchAPI, 1, 0, "Use new kernel launching API for HIP")
|
||||
|
||||
|
|
|
@ -125,6 +125,11 @@ public:
|
|||
MSVC2019 = 1920,
|
||||
};
|
||||
|
||||
enum SYCLMajorVersion {
|
||||
SYCL_None,
|
||||
SYCL_2017,
|
||||
};
|
||||
|
||||
/// Clang versions with different platform ABI conformance.
|
||||
enum class ClangABI {
|
||||
/// Attempt to be ABI-compatible with code generated by Clang 3.8.x
|
||||
|
|
|
@ -2277,11 +2277,13 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
|
|||
// -sycl-std applies to any SYCL source, not only those containing kernels,
|
||||
// but also those using the SYCL API
|
||||
if (const Arg *A = Args.getLastArg(OPT_sycl_std_EQ)) {
|
||||
Opts.SYCLVersion = llvm::StringSwitch<unsigned>(A->getValue())
|
||||
.Cases("2017", "1.2.1", "121", "sycl-1.2.1", 2017)
|
||||
.Default(0U);
|
||||
Opts.setSYCLVersion(
|
||||
llvm::StringSwitch<LangOptions::SYCLMajorVersion>(A->getValue())
|
||||
.Cases("2017", "1.2.1", "121", "sycl-1.2.1",
|
||||
LangOptions::SYCL_2017)
|
||||
.Default(LangOptions::SYCL_None));
|
||||
|
||||
if (Opts.SYCLVersion == 0U) {
|
||||
if (Opts.getSYCLVersion() == LangOptions::SYCL_None) {
|
||||
// User has passed an invalid value to the flag, this is an error
|
||||
Diags.Report(diag::err_drv_invalid_value)
|
||||
<< A->getAsString(Args) << A->getValue();
|
||||
|
|
|
@ -476,7 +476,7 @@ static void InitializeStandardPredefinedMacros(const TargetInfo &TI,
|
|||
|
||||
if (LangOpts.SYCL) {
|
||||
// SYCL Version is set to a value when building SYCL applications
|
||||
if (LangOpts.SYCLVersion == 2017)
|
||||
if (LangOpts.getSYCLVersion() == LangOptions::SYCL_2017)
|
||||
Builder.defineMacro("CL_SYCL_LANGUAGE_VERSION", "121");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue