diff options
author | Justas Janickas <Justas.Janickas@arm.com> | 2021-08-24 11:59:42 +0100 |
---|---|---|
committer | Justas Janickas <Justas.Janickas@arm.com> | 2021-08-31 10:08:38 +0100 |
commit | f9bc1b3bee557de5735c745f9558c47ca568bd96 (patch) | |
tree | c220ebdefbf7a73d4d28782b930a44220f1457d8 /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | c1184ca6eb97e0ac5f7b6cdcc99e3905d27f9d95 (diff) | |
download | llvm-f9bc1b3bee557de5735c745f9558c47ca568bd96.zip llvm-f9bc1b3bee557de5735c745f9558c47ca568bd96.tar.gz llvm-f9bc1b3bee557de5735c745f9558c47ca568bd96.tar.bz2 |
[OpenCL] Defines helper function for kernel language compatible OpenCL version
This change defines a helper function getOpenCLCompatibleVersion()
inside LangOptions class. The function contains mapping between
C++ for OpenCL versions and their corresponding compatible OpenCL
versions. This mapping function should be updated each time a new
C++ for OpenCL language version is introduced. The helper function
is expected to simplify conditions on OpenCL C and C++ for OpenCL
versions inside compiler code.
Code refactoring performed.
Differential Revision: https://reviews.llvm.org/D108693
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index eb69167..9f891f2 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -504,7 +504,7 @@ static bool FixupInvocation(CompilerInvocation &Invocation, // This option should be deprecated for CL > 1.0 because // this option was added for compatibility with OpenCL 1.0. if (Args.getLastArg(OPT_cl_strict_aliasing) && - (LangOpts.OpenCLCPlusPlus || LangOpts.OpenCLVersion > 100)) + (LangOpts.getOpenCLCompatibleVersion() > 100)) Diags.Report(diag::warn_option_invalid_ocl_version) << LangOpts.getOpenCLVersionString() << Args.getLastArg(OPT_cl_strict_aliasing)->getAsString(Args); @@ -3174,9 +3174,8 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK, Opts.ZVector = 0; Opts.setDefaultFPContractMode(LangOptions::FPM_On); Opts.OpenCLCPlusPlus = Opts.CPlusPlus; - Opts.OpenCLPipes = Opts.OpenCLCPlusPlus || Opts.OpenCLVersion == 200; - Opts.OpenCLGenericAddressSpace = - Opts.OpenCLCPlusPlus || Opts.OpenCLVersion == 200; + Opts.OpenCLPipes = Opts.getOpenCLCompatibleVersion() == 200; + Opts.OpenCLGenericAddressSpace = Opts.getOpenCLCompatibleVersion() == 200; // Include default header file for OpenCL. if (Opts.IncludeDefaultHeader) { |