aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorRuyman <ruyman@codeplay.com>2019-07-26 16:21:01 +0100
committerAlexey Bader <alexey.bader@intel.com>2020-02-27 15:08:42 +0300
commitbd97704eaaaab5a95ecb048ce343c1a4be5d94e5 (patch)
treeef53dec91525f29ea71e0f15f6119ab43cfa537c /clang/lib/Frontend/CompilerInvocation.cpp
parentee1b2e7ded12ef6e11ce35bb9929490ac9e7fa4f (diff)
downloadllvm-bd97704eaaaab5a95ecb048ce343c1a4be5d94e5.zip
llvm-bd97704eaaaab5a95ecb048ce343c1a4be5d94e5.tar.gz
llvm-bd97704eaaaab5a95ecb048ce343c1a4be5d94e5.tar.bz2
[SYCL] Driver option to select SYCL version
Summary: User can select the version of SYCL the compiler will use via the flag -sycl-std, similar to -cl-std. The flag defines the LangOpts.SYCLVersion option to the version of SYCL. The default value is undefined. If driver is building SYCL code, flag is set to the default SYCL version (1.2.1) The preprocessor uses this variable to define CL_SYCL_LANGUAGE_VERSION macro, which should be defined according to SYCL 1.2.1 standard. Only valid value at this point for the flag is 1.2.1. Co-Authored-By: David Wood <Q0KPU0H1YOEPHRY1R2SN5B5RL@david.davidtw.co> Signed-off-by: Ruyman Reyes <ruyman@codeplay.com> Subscribers: ebevhan, Anastasia, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D72857 Signed-off-by: Alexey Bader <alexey.bader@intel.com>
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 9cc41c9..76f63d0 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2535,6 +2535,24 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
LangStd = OpenCLLangStd;
}
+ Opts.SYCL = Args.hasArg(options::OPT_fsycl);
+ Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device);
+ if (Opts.SYCL) {
+ // -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);
+
+ if (Opts.SYCLVersion == 0U) {
+ // 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();
+ }
+ }
+ }
+
Opts.IncludeDefaultHeader = Args.hasArg(OPT_finclude_default_header);
Opts.DeclareOpenCLBuiltins = Args.hasArg(OPT_fdeclare_opencl_builtins);
@@ -3136,8 +3154,6 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
<< Opts.OMPHostIRFile;
}
- Opts.SYCLIsDevice = Args.hasArg(options::OPT_fsycl_is_device);
-
// Set CUDA mode for OpenMP target NVPTX if specified in options
Opts.OpenMPCUDAMode = Opts.OpenMPIsDevice && T.isNVPTX() &&
Args.hasArg(options::OPT_fopenmp_cuda_mode);