forked from OSchip/llvm-project
[OpenCL] Add new compilation mode for OpenCL 3.0.
Extended -cl-std/std flag with CL3.0 and added predefined version macros. Patch by Anton Zabaznov (azabaznov)! Tags: #clang Differential Revision: https://reviews.llvm.org/D88300
This commit is contained in:
parent
ddb2baf9fb
commit
71d3b7ec7b
|
@ -167,6 +167,9 @@ LANGSTANDARD(opencl12, "cl1.2",
|
|||
LANGSTANDARD(opencl20, "cl2.0",
|
||||
OpenCL, "OpenCL 2.0",
|
||||
LineComment | C99 | Digraphs | HexFloat | OpenCL)
|
||||
LANGSTANDARD(opencl30, "cl3.0",
|
||||
OpenCL, "OpenCL 3.0",
|
||||
LineComment | C99 | Digraphs | HexFloat | OpenCL)
|
||||
LANGSTANDARD(openclcpp, "clc++",
|
||||
OpenCL, "C++ for OpenCL",
|
||||
LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus17 |
|
||||
|
@ -176,6 +179,7 @@ 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++")
|
||||
|
||||
// CUDA
|
||||
|
|
|
@ -573,7 +573,7 @@ def cl_mad_enable : Flag<["-"], "cl-mad-enable">, Group<opencl_Group>, Flags<[CC
|
|||
def cl_no_signed_zeros : Flag<["-"], "cl-no-signed-zeros">, Group<opencl_Group>, Flags<[CC1Option]>,
|
||||
HelpText<"OpenCL only. Allow use of less precise no signed zeros computations in the generated binary.">;
|
||||
def cl_std_EQ : Joined<["-"], "cl-std=">, Group<opencl_Group>, Flags<[CC1Option]>,
|
||||
HelpText<"OpenCL language standard to compile for.">, Values<"cl,CL,cl1.1,CL1.1,cl1.2,CL1.2,cl2.0,CL2.0,clc++,CLC++">;
|
||||
HelpText<"OpenCL language standard to compile for.">, Values<"cl,CL,cl1.1,CL1.1,cl1.2,CL1.2,cl2.0,CL2.0,cl3.0,CL3.0,clc++,CLC++">;
|
||||
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]>,
|
||||
|
|
|
@ -2368,6 +2368,8 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
|
|||
Opts.OpenCLVersion = 120;
|
||||
else if (LangStd == LangStandard::lang_opencl20)
|
||||
Opts.OpenCLVersion = 200;
|
||||
else if (LangStd == LangStandard::lang_opencl30)
|
||||
Opts.OpenCLVersion = 300;
|
||||
else if (LangStd == LangStandard::lang_openclcpp)
|
||||
Opts.OpenCLCPlusPlusVersion = 100;
|
||||
|
||||
|
@ -2574,6 +2576,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
|
|||
.Cases("cl1.1", "CL1.1", LangStandard::lang_opencl11)
|
||||
.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)
|
||||
.Default(LangStandard::lang_unspecified);
|
||||
|
||||
|
|
|
@ -445,6 +445,9 @@ static void InitializeStandardPredefinedMacros(const TargetInfo &TI,
|
|||
case 200:
|
||||
Builder.defineMacro("__OPENCL_C_VERSION__", "200");
|
||||
break;
|
||||
case 300:
|
||||
Builder.defineMacro("__OPENCL_C_VERSION__", "300");
|
||||
break;
|
||||
default:
|
||||
llvm_unreachable("Unsupported OpenCL version");
|
||||
}
|
||||
|
@ -453,6 +456,7 @@ static void InitializeStandardPredefinedMacros(const TargetInfo &TI,
|
|||
Builder.defineMacro("CL_VERSION_1_1", "110");
|
||||
Builder.defineMacro("CL_VERSION_1_2", "120");
|
||||
Builder.defineMacro("CL_VERSION_2_0", "200");
|
||||
Builder.defineMacro("CL_VERSION_3_0", "300");
|
||||
|
||||
if (TI.isLittleEndian())
|
||||
Builder.defineMacro("__ENDIAN_LITTLE__");
|
||||
|
|
|
@ -43,6 +43,8 @@
|
|||
// CLSTDALL-NEXT: CL1.2
|
||||
// CLSTDALL-NEXT: cl2.0
|
||||
// CLSTDALL-NEXT: CL2.0
|
||||
// CLSTDALL-NEXT: cl3.0
|
||||
// CLSTDALL-NEXT: CL3.0
|
||||
// CLSTDALL-NEXT: clc++
|
||||
// CLSTDALL-NEXT: CLC++
|
||||
// RUN: %clang --autocomplete=-fno-sanitize-coverage=,f | FileCheck %s -check-prefix=FNOSANICOVER
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// RUN: %clang -S -### -cl-std=CL1.1 %s 2>&1 | FileCheck --check-prefix=CHECK-CL11 %s
|
||||
// RUN: %clang -S -### -cl-std=CL1.2 %s 2>&1 | FileCheck --check-prefix=CHECK-CL12 %s
|
||||
// RUN: %clang -S -### -cl-std=CL2.0 %s 2>&1 | FileCheck --check-prefix=CHECK-CL20 %s
|
||||
// RUN: %clang -S -### -cl-std=CL3.0 %s 2>&1 | FileCheck --check-prefix=CHECK-CL30 %s
|
||||
// RUN: %clang -S -### -cl-std=clc++ %s 2>&1 | FileCheck --check-prefix=CHECK-CLCPP %s
|
||||
// RUN: %clang -S -### -cl-opt-disable %s 2>&1 | FileCheck --check-prefix=CHECK-OPT-DISABLE %s
|
||||
// RUN: %clang -S -### -cl-strict-aliasing %s 2>&1 | FileCheck --check-prefix=CHECK-STRICT-ALIASING %s
|
||||
|
@ -22,6 +23,7 @@
|
|||
// CHECK-CL11: "-cc1" {{.*}} "-cl-std=CL1.1"
|
||||
// CHECK-CL12: "-cc1" {{.*}} "-cl-std=CL1.2"
|
||||
// CHECK-CL20: "-cc1" {{.*}} "-cl-std=CL2.0"
|
||||
// CHECK-CL30: "-cc1" {{.*}} "-cl-std=CL3.0"
|
||||
// CHECK-CLCPP: "-cc1" {{.*}} "-cl-std=clc++"
|
||||
// CHECK-OPT-DISABLE: "-cc1" {{.*}} "-cl-opt-disable"
|
||||
// CHECK-STRICT-ALIASING: "-cc1" {{.*}} "-cl-strict-aliasing"
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
// CHECK-NEXT: note: use 'cl1.1' for 'OpenCL 1.1' standard
|
||||
// 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
|
||||
|
||||
// Make sure that no other output is present.
|
||||
|
|
|
@ -4,11 +4,13 @@
|
|||
// 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=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: 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
|
||||
|
|
|
@ -129,6 +129,8 @@
|
|||
// RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-CL12
|
||||
// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=CL2.0 \
|
||||
// RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-CL20
|
||||
// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=CL3.0 \
|
||||
// RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-CL30
|
||||
// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-fast-relaxed-math \
|
||||
// RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-FRM
|
||||
// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++ \
|
||||
|
@ -137,26 +139,37 @@
|
|||
// CHECK-CL10: #define CL_VERSION_1_1 110
|
||||
// CHECK-CL10: #define CL_VERSION_1_2 120
|
||||
// CHECK-CL10: #define CL_VERSION_2_0 200
|
||||
// CHECK-CL10: #define CL_VERSION_3_0 300
|
||||
// CHECK-CL10: #define __OPENCL_C_VERSION__ 100
|
||||
// CHECK-CL10-NOT: #define __FAST_RELAXED_MATH__ 1
|
||||
// CHECK-CL11: #define CL_VERSION_1_0 100
|
||||
// CHECK-CL11: #define CL_VERSION_1_1 110
|
||||
// CHECK-CL11: #define CL_VERSION_1_2 120
|
||||
// CHECK-CL11: #define CL_VERSION_2_0 200
|
||||
// CHECK-CL11: #define CL_VERSION_3_0 300
|
||||
// CHECK-CL11: #define __OPENCL_C_VERSION__ 110
|
||||
// CHECK-CL11-NOT: #define __FAST_RELAXED_MATH__ 1
|
||||
// CHECK-CL12: #define CL_VERSION_1_0 100
|
||||
// CHECK-CL12: #define CL_VERSION_1_1 110
|
||||
// CHECK-CL12: #define CL_VERSION_1_2 120
|
||||
// CHECK-CL12: #define CL_VERSION_2_0 200
|
||||
// CHECK-CL12: #define CL_VERSION_3_0 300
|
||||
// CHECK-CL12: #define __OPENCL_C_VERSION__ 120
|
||||
// CHECK-CL12-NOT: #define __FAST_RELAXED_MATH__ 1
|
||||
// CHECK-CL20: #define CL_VERSION_1_0 100
|
||||
// CHECK-CL20: #define CL_VERSION_1_1 110
|
||||
// CHECK-CL20: #define CL_VERSION_1_2 120
|
||||
// CHECK-CL20: #define CL_VERSION_2_0 200
|
||||
// CHECK-CL20: #define CL_VERSION_3_0 300
|
||||
// CHECK-CL20: #define __OPENCL_C_VERSION__ 200
|
||||
// CHECK-CL20-NOT: #define __FAST_RELAXED_MATH__ 1
|
||||
// CHECK-CL30: #define CL_VERSION_1_0 100
|
||||
// CHECK-CL30: #define CL_VERSION_1_1 110
|
||||
// CHECK-CL30: #define CL_VERSION_1_2 120
|
||||
// CHECK-CL30: #define CL_VERSION_2_0 200
|
||||
// CHECK-CL30: #define CL_VERSION_3_0 300
|
||||
// CHECK-CL30: #define __OPENCL_C_VERSION__ 300
|
||||
// CHECK-CL30-NOT: #define __FAST_RELAXED_MATH__ 1
|
||||
// CHECK-FRM: #define __FAST_RELAXED_MATH__ 1
|
||||
// CHECK-CLCPP10: #define __CL_CPP_VERSION_1_0__ 100
|
||||
// CHECK-CLCPP10: #define __OPENCL_CPP_VERSION__ 100
|
||||
|
|
Loading…
Reference in New Issue