forked from OSchip/llvm-project
[OpenCL] C++ for OpenCL version 2021 introduced to command line.
Introduces language standard `lang_openclcpp2021` and allows `clc++2021` as a version flag for `-cl-std` in command line. Defines macros related to C++ for OpenCL version 2021. C++ for OpenCL version 2021 has been proposed in an RFC: https://lists.llvm.org/pipermail/cfe-dev/2021-August/068593.html Differential Revision: https://reviews.llvm.org/D108038
This commit is contained in:
parent
593275c93c
commit
0d0628b2d2
|
@ -180,12 +180,18 @@ LANGSTANDARD(opencl20, "cl2.0",
|
|||
LANGSTANDARD(opencl30, "cl3.0",
|
||||
OpenCL, "OpenCL 3.0",
|
||||
LineComment | C99 | Digraphs | HexFloat | 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(openclcpp2021, "clc++2021",
|
||||
OpenCL, "C++ for OpenCL 2021",
|
||||
LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus17 |
|
||||
Digraphs | HexFloat | OpenCL)
|
||||
|
||||
LANGSTANDARD_ALIAS_DEPR(opencl10, "CL")
|
||||
LANGSTANDARD_ALIAS_DEPR(opencl11, "CL1.1")
|
||||
LANGSTANDARD_ALIAS_DEPR(opencl12, "CL1.2")
|
||||
|
@ -193,6 +199,7 @@ LANGSTANDARD_ALIAS_DEPR(opencl20, "CL2.0")
|
|||
LANGSTANDARD_ALIAS_DEPR(opencl30, "CL3.0")
|
||||
LANGSTANDARD_ALIAS_DEPR(openclcpp10, "CLC++")
|
||||
LANGSTANDARD_ALIAS_DEPR(openclcpp10, "CLC++1.0")
|
||||
LANGSTANDARD_ALIAS_DEPR(openclcpp2021, "CLC++2021")
|
||||
|
||||
// CUDA
|
||||
LANGSTANDARD(cuda, "cuda", CUDA, "NVIDIA CUDA(tm)",
|
||||
|
|
|
@ -866,7 +866,7 @@ def cl_no_signed_zeros : Flag<["-"], "cl-no-signed-zeros">, Group<opencl_Group>,
|
|||
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++,clc++1.0,CLC++1.0">;
|
||||
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,clc++2021,CLC++2021">;
|
||||
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]>,
|
||||
|
|
|
@ -3165,6 +3165,8 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
|
|||
Opts.OpenCLVersion = 300;
|
||||
else if (LangStd == LangStandard::lang_openclcpp10)
|
||||
Opts.OpenCLCPlusPlusVersion = 100;
|
||||
else if (LangStd == LangStandard::lang_openclcpp2021)
|
||||
Opts.OpenCLCPlusPlusVersion = 202100;
|
||||
|
||||
// OpenCL has some additional defaults.
|
||||
if (Opts.OpenCL) {
|
||||
|
@ -3314,6 +3316,7 @@ void CompilerInvocation::GenerateLangArgs(const LangOptions &Opts,
|
|||
case LangStandard::lang_opencl20:
|
||||
case LangStandard::lang_opencl30:
|
||||
case LangStandard::lang_openclcpp10:
|
||||
case LangStandard::lang_openclcpp2021:
|
||||
StdOpt = OPT_cl_std_EQ;
|
||||
break;
|
||||
default:
|
||||
|
@ -3612,6 +3615,7 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
|
|||
.Cases("cl3.0", "CL3.0", LangStandard::lang_opencl30)
|
||||
.Cases("clc++", "CLC++", LangStandard::lang_openclcpp10)
|
||||
.Cases("clc++1.0", "CLC++1.0", LangStandard::lang_openclcpp10)
|
||||
.Cases("clc++2021", "CLC++2021", LangStandard::lang_openclcpp2021)
|
||||
.Default(LangStandard::lang_unspecified);
|
||||
|
||||
if (OpenCLLangStd == LangStandard::lang_unspecified) {
|
||||
|
|
|
@ -433,11 +433,18 @@ static void InitializeStandardPredefinedMacros(const TargetInfo &TI,
|
|||
// OpenCL v1.0/1.1 s6.9, v1.2/2.0 s6.10: Preprocessor Directives and Macros.
|
||||
if (LangOpts.OpenCL) {
|
||||
if (LangOpts.CPlusPlus) {
|
||||
if (LangOpts.OpenCLCPlusPlusVersion == 100)
|
||||
switch (LangOpts.OpenCLCPlusPlusVersion) {
|
||||
case 100:
|
||||
Builder.defineMacro("__OPENCL_CPP_VERSION__", "100");
|
||||
else
|
||||
break;
|
||||
case 202100:
|
||||
Builder.defineMacro("__OPENCL_CPP_VERSION__", "202100");
|
||||
break;
|
||||
default:
|
||||
llvm_unreachable("Unsupported C++ version for OpenCL");
|
||||
}
|
||||
Builder.defineMacro("__CL_CPP_VERSION_1_0__", "100");
|
||||
Builder.defineMacro("__CL_CPP_VERSION_2021__", "202100");
|
||||
} else {
|
||||
// OpenCL v1.0 and v1.1 do not have a predefined macro to indicate the
|
||||
// language standard with which the program is compiled. __OPENCL_VERSION__
|
||||
|
|
|
@ -51,6 +51,8 @@
|
|||
// CLSTDALL-NEXT: CLC++
|
||||
// CLSTDALL-NEXT: clc++1.0
|
||||
// CLSTDALL-NEXT: CLC++1.0
|
||||
// CLSTDALL-NEXT: clc++2021
|
||||
// CLSTDALL-NEXT: CLC++2021
|
||||
// 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
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
// 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++1.0' or 'clc++' for 'C++ for OpenCL 1.0' standard
|
||||
// CHECK-NEXT: note: use 'clc++2021' for 'C++ for OpenCL 2021' standard
|
||||
|
||||
// Make sure that no other output is present.
|
||||
// CHECK-NOT: {{^.+$}}
|
||||
|
|
|
@ -7,12 +7,16 @@
|
|||
// RUN: %clang_cc1 -x cl -cl-std=cl2.0 -DOPENCL %s
|
||||
// RUN: %clang_cc1 -x cl -cl-std=cl3.0 -DOPENCL %s
|
||||
// RUN: %clang_cc1 -x cl -cl-std=clc++ -DOPENCL %s
|
||||
// RUN: %clang_cc1 -x cl -cl-std=clc++1.0 -DOPENCL %s
|
||||
// RUN: %clang_cc1 -x cl -cl-std=clc++2021 -DOPENCL %s
|
||||
// RUN: %clang_cc1 -x cl -cl-std=CL -DOPENCL %s
|
||||
// RUN: %clang_cc1 -x cl -cl-std=CL1.1 -DOPENCL %s
|
||||
// RUN: %clang_cc1 -x cl -cl-std=CL1.2 -DOPENCL %s
|
||||
// RUN: %clang_cc1 -x cl -cl-std=CL2.0 -DOPENCL %s
|
||||
// RUN: %clang_cc1 -x cl -cl-std=CL3.0 -DOPENCL %s
|
||||
// RUN: %clang_cc1 -x cl -cl-std=CLC++ -DOPENCL %s
|
||||
// RUN: %clang_cc1 -x cl -cl-std=CLC++1.0 -DOPENCL %s
|
||||
// RUN: %clang_cc1 -x cl -cl-std=CLC++2021 -DOPENCL %s
|
||||
// RUN: not %clang_cc1 -x cl -std=c99 -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-C99 %s
|
||||
// RUN: not %clang_cc1 -x cl -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID %s
|
||||
// CHECK-C99: error: invalid argument '-std=c99' not allowed with 'OpenCL'
|
||||
|
|
Loading…
Reference in New Issue