[OpenCL] Add std flag aliases clc++1.0 and CLC++1.0

Renamed language standard from openclcpp to openclcpp10.
Added new std values i.e. '-cl-std=clc++1.0' and
'-cl-std=CLC++1.0'.

Patch by Topotuna (Justas Janickas)!

Differential Revision: https://reviews.llvm.org/D106266
This commit is contained in:
Anastasia Stulova 2021-07-29 15:10:13 +01:00
parent 1a7ed9561a
commit 577220e898
7 changed files with 19 additions and 12 deletions

View File

@ -3297,8 +3297,9 @@ or in `the official release
<https://github.com/KhronosGroup/OpenCL-Docs/releases/tag/cxxforopencl-v1.0-r2>`_.
To enable the C++ for OpenCL mode, pass one of following command line options when
compiling ``.cl`` file ``-cl-std=clc++``, ``-cl-std=CLC++``, ``-std=clc++`` or
``-std=CLC++``.
compiling ``.cl`` file ``-cl-std=clc++``, ``-cl-std=CLC++``, ``-cl-std=clc++1.0``,
``-cl-std=CLC++1.0``, ``-std=clc++``, ``-std=CLC++``, ``-std=clc++1.0`` or
``-std=CLC++1.0``.
.. code-block:: c++

View File

@ -180,17 +180,19 @@ LANGSTANDARD(opencl20, "cl2.0",
LANGSTANDARD(opencl30, "cl3.0",
OpenCL, "OpenCL 3.0",
LineComment | C99 | Digraphs | HexFloat | OpenCL)
LANGSTANDARD(openclcpp, "clc++",
OpenCL, "C++ for OpenCL",
LANGSTANDARD(openclcpp10, "clc++1.0",
OpenCL, "C++ for OpenCL 1.0",
LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus17 |
Digraphs | HexFloat | OpenCL)
LANGSTANDARD_ALIAS(openclcpp10, "clc++")
LANGSTANDARD_ALIAS_DEPR(opencl10, "CL")
LANGSTANDARD_ALIAS_DEPR(opencl11, "CL1.1")
LANGSTANDARD_ALIAS_DEPR(opencl12, "CL1.2")
LANGSTANDARD_ALIAS_DEPR(opencl20, "CL2.0")
LANGSTANDARD_ALIAS_DEPR(opencl30, "CL3.0")
LANGSTANDARD_ALIAS_DEPR(openclcpp, "CLC++")
LANGSTANDARD_ALIAS_DEPR(openclcpp10, "CLC++")
LANGSTANDARD_ALIAS_DEPR(openclcpp10, "CLC++1.0")
// CUDA
LANGSTANDARD(cuda, "cuda", CUDA, "NVIDIA CUDA(tm)",

View File

@ -843,7 +843,8 @@ def cl_no_signed_zeros : Flag<["-"], "cl-no-signed-zeros">, Group<opencl_Group>,
HelpText<"OpenCL only. Allow use of less precise no signed zeros computations in the generated binary.">,
MarshallingInfoFlag<LangOpts<"CLNoSignedZero">>;
def cl_std_EQ : Joined<["-"], "cl-std=">, Group<opencl_Group>, Flags<[CC1Option]>,
HelpText<"OpenCL language standard to compile for.">, Values<"cl,CL,cl1.0,CL1.0,cl1.1,CL1.1,cl1.2,CL1.2,cl2.0,CL2.0,cl3.0,CL3.0,clc++,CLC++">;
HelpText<"OpenCL language standard to compile for.">,
Values<"cl,CL,cl1.0,CL1.0,cl1.1,CL1.1,cl1.2,CL1.2,cl2.0,CL2.0,cl3.0,CL3.0,clc++,CLC++,clc++1.0,CLC++1.0">;
def cl_denorms_are_zero : Flag<["-"], "cl-denorms-are-zero">, Group<opencl_Group>,
HelpText<"OpenCL only. Allow denormals to be flushed to zero.">;
def cl_fp32_correctly_rounded_divide_sqrt : Flag<["-"], "cl-fp32-correctly-rounded-divide-sqrt">, Group<opencl_Group>, Flags<[CC1Option]>,

View File

@ -3091,7 +3091,7 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
LangStd = LangStandard::lang_opencl12;
break;
case Language::OpenCLCXX:
LangStd = LangStandard::lang_openclcpp;
LangStd = LangStandard::lang_openclcpp10;
break;
case Language::CUDA:
LangStd = LangStandard::lang_cuda;
@ -3164,7 +3164,7 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
Opts.OpenCLVersion = 200;
else if (LangStd == LangStandard::lang_opencl30)
Opts.OpenCLVersion = 300;
else if (LangStd == LangStandard::lang_openclcpp)
else if (LangStd == LangStandard::lang_openclcpp10)
Opts.OpenCLCPlusPlusVersion = 100;
// OpenCL has some additional defaults.
@ -3314,7 +3314,7 @@ void CompilerInvocation::GenerateLangArgs(const LangOptions &Opts,
case LangStandard::lang_opencl12:
case LangStandard::lang_opencl20:
case LangStandard::lang_opencl30:
case LangStandard::lang_openclcpp:
case LangStandard::lang_openclcpp10:
StdOpt = OPT_cl_std_EQ;
break;
default:
@ -3608,7 +3608,8 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
.Cases("cl1.2", "CL1.2", LangStandard::lang_opencl12)
.Cases("cl2.0", "CL2.0", LangStandard::lang_opencl20)
.Cases("cl3.0", "CL3.0", LangStandard::lang_opencl30)
.Cases("clc++", "CLC++", LangStandard::lang_openclcpp)
.Cases("clc++", "CLC++", LangStandard::lang_openclcpp10)
.Cases("clc++1.0", "CLC++1.0", LangStandard::lang_openclcpp10)
.Default(LangStandard::lang_unspecified);
if (OpenCLLangStd == LangStandard::lang_unspecified) {

View File

@ -49,6 +49,8 @@
// CLSTDALL-NEXT: CL3.0
// CLSTDALL-NEXT: clc++
// CLSTDALL-NEXT: CLC++
// CLSTDALL-NEXT: clc++1.0
// CLSTDALL-NEXT: CLC++1.0
// RUN: %clang --autocomplete=-fno-sanitize-coverage=,f | FileCheck %s -check-prefix=FNOSANICOVER
// FNOSANICOVER: func
// RUN: %clang --autocomplete=-fno-sanitize-coverage= | FileCheck %s -check-prefix=FNOSANICOVERALL

View File

@ -11,7 +11,7 @@
// CHECK-NEXT: note: use 'cl1.2' for 'OpenCL 1.2' standard
// CHECK-NEXT: note: use 'cl2.0' for 'OpenCL 2.0' standard
// CHECK-NEXT: note: use 'cl3.0' for 'OpenCL 3.0' standard
// CHECK-NEXT: note: use 'clc++' for 'C++ for OpenCL' standard
// CHECK-NEXT: note: use 'clc++1.0' or 'clc++' for 'C++ for OpenCL 1.0' standard
// Make sure that no other output is present.
// CHECK-NOT: {{^.+$}}

View File

@ -478,7 +478,7 @@ static void ParseLangArgs(LangOptions &Opts, InputKind IK, const char *triple) {
LangStd = LangStandard::lang_opencl10;
break;
case clang::Language::OpenCLCXX:
LangStd = LangStandard::lang_openclcpp;
LangStd = LangStandard::lang_openclcpp10;
break;
case clang::Language::CUDA:
LangStd = LangStandard::lang_cuda;