diff options
author | Anuj Mittal <anuj.mittal@intel.com> | 2022-04-19 15:43:41 +0800 |
---|---|---|
committer | Anuj Mittal <anuj.mittal@intel.com> | 2022-04-19 20:56:14 +0800 |
commit | b9da851fa5b713e8eb5d6b1b0b03c9e9fbfff5d0 (patch) | |
tree | 045240395c45a1064639fe4bff0f9549bacbd6b2 /dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm12-0007-OpenCL-3.0-support.patch | |
parent | 10944d53081884fedb3242f37fa6e9964f33586f (diff) | |
download | meta-intel-b9da851fa5b713e8eb5d6b1b0b03c9e9fbfff5d0.tar.gz |
llvm-project-source: refresh patches
Refresh the patches as recommended by the opencl-clang and include
support for OpenCL 3.0.
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
Diffstat (limited to 'dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm12-0007-OpenCL-3.0-support.patch')
-rw-r--r-- | dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm12-0007-OpenCL-3.0-support.patch | 4628 |
1 files changed, 4628 insertions, 0 deletions
diff --git a/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm12-0007-OpenCL-3.0-support.patch b/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm12-0007-OpenCL-3.0-support.patch new file mode 100644 index 00000000..567db40d --- /dev/null +++ b/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm12-0007-OpenCL-3.0-support.patch | |||
@@ -0,0 +1,4628 @@ | |||
1 | From cc23dafd55bfe102e490c719f8b088e6b2a52561 Mon Sep 17 00:00:00 2001 | ||
2 | From: Haonan Yang <haonan.yang@intel.com> | ||
3 | Date: Fri, 15 Apr 2022 15:52:37 +0800 | ||
4 | Subject: [PATCH] OpenCL 3.0 support | ||
5 | |||
6 | Signed-off-by: Haonan Yang <haonan.yang@intel.com> | ||
7 | |||
8 | Upstream-Status: Submitted | ||
9 | Signed-off-by: Anuj Mittal <anuj.mittal@intel.com> | ||
10 | --- | ||
11 | clang/docs/OpenCLSupport.rst | 19 +- | ||
12 | .../clang/Basic/DiagnosticCommonKinds.td | 10 + | ||
13 | clang/include/clang/Basic/DiagnosticGroups.td | 2 + | ||
14 | .../clang/Basic/DiagnosticParseKinds.td | 5 +- | ||
15 | .../clang/Basic/DiagnosticSemaKinds.td | 13 +- | ||
16 | clang/include/clang/Basic/LangOptions.def | 2 + | ||
17 | .../include/clang/Basic/OpenCLExtensions.def | 82 +-- | ||
18 | clang/include/clang/Basic/OpenCLOptions.h | 71 ++- | ||
19 | clang/include/clang/Basic/TargetInfo.h | 18 +- | ||
20 | clang/include/clang/Sema/Overload.h | 3 - | ||
21 | clang/include/clang/Sema/Sema.h | 82 --- | ||
22 | clang/include/clang/Serialization/ASTWriter.h | 2 - | ||
23 | clang/lib/Basic/OpenCLOptions.cpp | 103 +++- | ||
24 | clang/lib/Basic/TargetInfo.cpp | 26 + | ||
25 | clang/lib/Basic/Targets.cpp | 43 +- | ||
26 | clang/lib/Basic/Targets/AMDGPU.h | 6 +- | ||
27 | clang/lib/Basic/Targets/NVPTX.h | 1 + | ||
28 | clang/lib/Basic/Targets/X86.cpp | 10 +- | ||
29 | clang/lib/Frontend/CompilerInstance.cpp | 5 + | ||
30 | clang/lib/Frontend/CompilerInvocation.cpp | 3 + | ||
31 | clang/lib/Frontend/InitPreprocessor.cpp | 25 +- | ||
32 | clang/lib/Headers/opencl-c-base.h | 15 + | ||
33 | clang/lib/Headers/opencl-c.h | 493 ++++++++++-------- | ||
34 | clang/lib/Parse/ParseDecl.cpp | 16 +- | ||
35 | clang/lib/Parse/ParsePragma.cpp | 17 +- | ||
36 | clang/lib/Parse/Parser.cpp | 2 - | ||
37 | clang/lib/Sema/DeclSpec.cpp | 3 +- | ||
38 | clang/lib/Sema/Sema.cpp | 185 ++----- | ||
39 | clang/lib/Sema/SemaCast.cpp | 4 +- | ||
40 | clang/lib/Sema/SemaChecking.cpp | 3 +- | ||
41 | clang/lib/Sema/SemaDecl.cpp | 36 +- | ||
42 | clang/lib/Sema/SemaDeclAttr.cpp | 17 +- | ||
43 | clang/lib/Sema/SemaExpr.cpp | 26 +- | ||
44 | clang/lib/Sema/SemaInit.cpp | 8 +- | ||
45 | clang/lib/Sema/SemaLookup.cpp | 22 +- | ||
46 | clang/lib/Sema/SemaOverload.cpp | 17 - | ||
47 | clang/lib/Sema/SemaType.cpp | 56 +- | ||
48 | clang/lib/Serialization/ASTReader.cpp | 27 +- | ||
49 | clang/lib/Serialization/ASTWriter.cpp | 71 +-- | ||
50 | .../CodeGenOpenCL/addr-space-struct-arg.cl | 6 +- | ||
51 | .../address-spaces-conversions.cl | 2 + | ||
52 | .../CodeGenOpenCL/address-spaces-mangling.cl | 6 +- | ||
53 | clang/test/CodeGenOpenCL/address-spaces.cl | 4 + | ||
54 | .../CodeGenOpenCL/amdgpu-sizeof-alignof.cl | 21 +- | ||
55 | .../CodeGenOpenCL/arm-integer-dot-product.cl | 11 +- | ||
56 | clang/test/CodeGenOpenCL/extension-begin.cl | 25 - | ||
57 | clang/test/CodeGenOpenCL/overload.cl | 1 + | ||
58 | clang/test/CodeGenOpenCL/printf.cl | 6 +- | ||
59 | clang/test/Headers/opencl-c-header.cl | 84 +++ | ||
60 | clang/test/Misc/nvptx.unsupported_core.cl | 7 + | ||
61 | clang/test/Misc/warning-flags.c | 2 +- | ||
62 | clang/test/Parser/opencl-atomics-cl20.cl | 104 ++-- | ||
63 | clang/test/SemaOpenCL/access-qualifier.cl | 40 +- | ||
64 | .../address-spaces-conversions-cl2.0.cl | 3 + | ||
65 | clang/test/SemaOpenCL/address-spaces.cl | 1 + | ||
66 | .../SemaOpenCL/arm-integer-dot-product.cl | 42 +- | ||
67 | .../SemaOpenCL/cl20-device-side-enqueue.cl | 4 +- | ||
68 | clang/test/SemaOpenCL/extension-begin.cl | 28 +- | ||
69 | clang/test/SemaOpenCL/extension-begin.h | 9 +- | ||
70 | clang/test/SemaOpenCL/extension-version.cl | 62 ++- | ||
71 | clang/test/SemaOpenCL/extensions.cl | 71 ++- | ||
72 | .../SemaOpenCL/fdeclare-opencl-builtins.cl | 27 +- | ||
73 | clang/test/SemaOpenCL/features.cl | 48 ++ | ||
74 | .../intel-subgroup-avc-ext-types.cl | 69 ++- | ||
75 | clang/test/SemaOpenCL/storageclass.cl | 234 ++++++++- | ||
76 | clang/test/SemaOpenCL/unsupported-image.cl | 69 +++ | ||
77 | 66 files changed, 1502 insertions(+), 1033 deletions(-) | ||
78 | delete mode 100644 clang/test/CodeGenOpenCL/extension-begin.cl | ||
79 | create mode 100644 clang/test/Misc/nvptx.unsupported_core.cl | ||
80 | create mode 100644 clang/test/SemaOpenCL/features.cl | ||
81 | create mode 100644 clang/test/SemaOpenCL/unsupported-image.cl | ||
82 | |||
83 | diff --git a/clang/docs/OpenCLSupport.rst b/clang/docs/OpenCLSupport.rst | ||
84 | index 0eaf0f300ee4..cba2539a6d11 100644 | ||
85 | --- a/clang/docs/OpenCLSupport.rst | ||
86 | +++ b/clang/docs/OpenCLSupport.rst | ||
87 | @@ -61,7 +61,24 @@ Missing features or with limited support | ||
88 | |||
89 | .. _opencl_300: | ||
90 | |||
91 | -OpenCL 3.0 Implementation Status | ||
92 | +OpenCL C 3.0 Usage | ||
93 | +================================ | ||
94 | + | ||
95 | +OpenCL C 3.0 language standard makes most OpenCL C 2.0 features optional. Optional | ||
96 | +functionality in OpenCL C 3.0 is indicated with the presence of feature-test macros | ||
97 | +(list of feature-test macros is `here <https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_C.html#features>`_). | ||
98 | +Command-line flag :ref:`-cl-ext <opencl_cl_ext>` can be used to override features supported by a target. | ||
99 | + | ||
100 | +For cases when there is an associated extension for a specific feature (fp64 and 3d image writes) | ||
101 | +user should specify both (extension and feature) in command-line flag: | ||
102 | + | ||
103 | + .. code-block:: console | ||
104 | + | ||
105 | + $ clang -cc1 -cl-std=CL3.0 -cl-ext=+cl_khr_fp64,+__opencl_c_fp64 ... | ||
106 | + $ clang -cc1 -cl-std=CL3.0 -cl-ext=-cl_khr_fp64,-__opencl_c_fp64 ... | ||
107 | + | ||
108 | + | ||
109 | +OpenCL C 3.0 Implementation Status | ||
110 | ================================ | ||
111 | |||
112 | The following table provides an overview of features in OpenCL C 3.0 and their | ||
113 | diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td b/clang/include/clang/Basic/DiagnosticCommonKinds.td | ||
114 | index a4f96a97991e..734701ce9d9d 100644 | ||
115 | --- a/clang/include/clang/Basic/DiagnosticCommonKinds.td | ||
116 | +++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td | ||
117 | @@ -347,4 +347,14 @@ def note_suggest_disabling_all_checkers : Note< | ||
118 | def warn_poison_system_directories : Warning < | ||
119 | "include location '%0' is unsafe for cross-compilation">, | ||
120 | InGroup<DiagGroup<"poison-system-directories">>, DefaultIgnore; | ||
121 | + | ||
122 | +def warn_opencl_unsupported_core_feature : Warning< | ||
123 | + "%0 is a core feature in %select{OpenCL C|C++ for OpenCL}1 version %2 but not supported on this target">, | ||
124 | + InGroup<OpenCLCoreFeaturesDiagGroup>, DefaultIgnore; | ||
125 | + | ||
126 | +def err_opencl_extension_and_feature_differs : Error< | ||
127 | + "options %0 and %1 are set to different values">; | ||
128 | + | ||
129 | +def err_opencl_feature_requires : Error< | ||
130 | + "feature %0 requires support of %1 feature">; | ||
131 | } | ||
132 | diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td | ||
133 | index 04ba89aa457e..93099dd19a80 100644 | ||
134 | --- a/clang/include/clang/Basic/DiagnosticGroups.td | ||
135 | +++ b/clang/include/clang/Basic/DiagnosticGroups.td | ||
136 | @@ -1247,3 +1247,5 @@ in addition with the pragmas or -fmax-tokens flag to get any warnings. | ||
137 | def WebAssemblyExceptionSpec : DiagGroup<"wasm-exception-spec">; | ||
138 | |||
139 | def RTTI : DiagGroup<"rtti">; | ||
140 | + | ||
141 | +def OpenCLCoreFeaturesDiagGroup : DiagGroup<"pedantic-core-features">; | ||
142 | diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td | ||
143 | index 0ed80a481e78..5887cc81e32a 100644 | ||
144 | --- a/clang/include/clang/Basic/DiagnosticParseKinds.td | ||
145 | +++ b/clang/include/clang/Basic/DiagnosticParseKinds.td | ||
146 | @@ -1228,14 +1228,13 @@ def warn_pragma_expected_colon : Warning< | ||
147 | "missing ':' after %0 - ignoring">, InGroup<IgnoredPragmas>; | ||
148 | def warn_pragma_expected_predicate : Warning< | ||
149 | "expected %select{'enable', 'disable', 'begin' or 'end'|'disable'}0 - ignoring">, InGroup<IgnoredPragmas>; | ||
150 | -def warn_pragma_begin_end_mismatch : Warning< | ||
151 | - "OpenCL extension end directive mismatches begin directive - ignoring">, InGroup<IgnoredPragmas>; | ||
152 | def warn_pragma_unknown_extension : Warning< | ||
153 | "unknown OpenCL extension %0 - ignoring">, InGroup<IgnoredPragmas>; | ||
154 | def warn_pragma_unsupported_extension : Warning< | ||
155 | "unsupported OpenCL extension %0 - ignoring">, InGroup<IgnoredPragmas>; | ||
156 | def warn_pragma_extension_is_core : Warning< | ||
157 | - "OpenCL extension %0 is core feature or supported optional core feature - ignoring">, InGroup<DiagGroup<"pedantic-core-features">>, DefaultIgnore; | ||
158 | + "OpenCL extension %0 is core feature or supported optional core feature - ignoring">, | ||
159 | + InGroup<OpenCLCoreFeaturesDiagGroup>, DefaultIgnore; | ||
160 | |||
161 | // OpenCL errors. | ||
162 | def err_opencl_taking_function_address_parser : Error< | ||
163 | diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td | ||
164 | index 67c59f3ca09a..7d45654f5ea2 100644 | ||
165 | --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td | ||
166 | +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td | ||
167 | @@ -118,7 +118,8 @@ def warn_float_underflow : Warning< | ||
168 | "magnitude of floating-point constant too small for type %0; minimum is %1">, | ||
169 | InGroup<LiteralRange>; | ||
170 | def warn_double_const_requires_fp64 : Warning< | ||
171 | - "double precision constant requires cl_khr_fp64, casting to single precision">; | ||
172 | + "double precision constant requires %select{cl_khr_fp64|cl_khr_fp64 and __opencl_c_fp64}0, " | ||
173 | + "casting to single precision">; | ||
174 | def err_half_const_requires_fp16 : Error< | ||
175 | "half precision constant requires cl_khr_fp16">; | ||
176 | |||
177 | @@ -4279,8 +4280,6 @@ def warn_diagnose_if_succeeded : Warning<"%0">, InGroup<UserDefinedWarnings>, | ||
178 | ShowInSystemHeader; | ||
179 | def note_ovl_candidate_disabled_by_function_cond_attr : Note< | ||
180 | "candidate disabled: %0">; | ||
181 | -def note_ovl_candidate_disabled_by_extension : Note< | ||
182 | - "candidate unavailable as it requires OpenCL extension '%0' to be enabled">; | ||
183 | def err_addrof_function_disabled_by_enable_if_attr : Error< | ||
184 | "cannot take address of function %0 because it has one or more " | ||
185 | "non-tautological enable_if conditions">; | ||
186 | @@ -9892,7 +9891,10 @@ def warn_opencl_attr_deprecated_ignored : Warning < | ||
187 | def err_opencl_variadic_function : Error< | ||
188 | "invalid prototype, variadic arguments are not allowed in OpenCL">; | ||
189 | def err_opencl_requires_extension : Error< | ||
190 | - "use of %select{type|declaration}0 %1 requires %2 extension to be enabled">; | ||
191 | + "use of %select{type|declaration}0 %1 requires %2 support">; | ||
192 | +def ext_opencl_double_without_pragma : Extension< | ||
193 | + "Clang permits use of type 'double' regardless pragma if 'cl_khr_fp64' is" | ||
194 | + " supported">; | ||
195 | def warn_opencl_generic_address_space_arg : Warning< | ||
196 | "passing non-generic address space pointer to %0" | ||
197 | " may cause dynamic conversion affecting performance">, | ||
198 | @@ -9912,7 +9914,8 @@ def err_opencl_builtin_pipe_invalid_access_modifier : Error< | ||
199 | def err_opencl_invalid_access_qualifier : Error< | ||
200 | "access qualifier can only be used for pipe and image type">; | ||
201 | def err_opencl_invalid_read_write : Error< | ||
202 | - "access qualifier %0 can not be used for %1 %select{|prior to OpenCL version 2.0}2">; | ||
203 | + "access qualifier %0 can not be used for %1 %select{|prior to OpenCL C version 2.0 or in version 3.0 " | ||
204 | + "and without __opencl_c_read_write_images feature}2">; | ||
205 | def err_opencl_multiple_access_qualifiers : Error< | ||
206 | "multiple access qualifiers">; | ||
207 | def note_opencl_typedef_access_qualifier : Note< | ||
208 | diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def | ||
209 | index c01f0cca9c9c..d41ef34ad5df 100644 | ||
210 | --- a/clang/include/clang/Basic/LangOptions.def | ||
211 | +++ b/clang/include/clang/Basic/LangOptions.def | ||
212 | @@ -215,6 +215,8 @@ LANGOPT(OpenCL , 1, 0, "OpenCL") | ||
213 | LANGOPT(OpenCLVersion , 32, 0, "OpenCL C version") | ||
214 | LANGOPT(OpenCLCPlusPlus , 1, 0, "C++ for OpenCL") | ||
215 | LANGOPT(OpenCLCPlusPlusVersion , 32, 0, "C++ for OpenCL version") | ||
216 | +LANGOPT(OpenCLPipe , 1, 0, "OpenCL pipe keyword") | ||
217 | +LANGOPT(OpenCLGenericAddressSpace, 1, 0, "OpenCL generic keyword") | ||
218 | LANGOPT(NativeHalfType , 1, 0, "Native half type support") | ||
219 | LANGOPT(NativeHalfArgsAndReturns, 1, 0, "Native half args and returns") | ||
220 | LANGOPT(HalfArgsAndReturns, 1, 0, "half args and returns") | ||
221 | diff --git a/clang/include/clang/Basic/OpenCLExtensions.def b/clang/include/clang/Basic/OpenCLExtensions.def | ||
222 | index 801916c3ab94..c5352dadc0de 100644 | ||
223 | --- a/clang/include/clang/Basic/OpenCLExtensions.def | ||
224 | +++ b/clang/include/clang/Basic/OpenCLExtensions.def | ||
225 | @@ -16,8 +16,12 @@ | ||
226 | // If extensions are to be enumerated with information about whether | ||
227 | // an extension is core or optional core and minimum OpenCL version | ||
228 | // when an extension becomes available, | ||
229 | -// define OPENCL_GENERIC_EXTENSION(ext, avail, core, opt) where | ||
230 | +// define OPENCL_GENERIC_EXTENSION(ext, pragma, avail, core, opt) where | ||
231 | // ext - name of the extension or optional core feature. | ||
232 | +// pragma - true if extension needs pragmas or false otherwise. | ||
233 | +// NOTE: extension pragma without any documentation detailing | ||
234 | +// its behavior explicitly is deprecated. Therefore the default | ||
235 | +// value is false. | ||
236 | // avail - minimum OpenCL version supporting it. | ||
237 | // core - OpenCL versions mask when the extension becomes core feature. | ||
238 | // 0U indicates not a core feature. | ||
239 | @@ -50,55 +54,67 @@ | ||
240 | #endif // OPENCL_GENERIC_EXTENSION | ||
241 | |||
242 | // Declaration helpers | ||
243 | -#define OPENCL_EXTENSION(ext, avail) OPENCL_GENERIC_EXTENSION(ext, avail, 0U, 0U) | ||
244 | -#define OPENCL_COREFEATURE(ext, avail, core) OPENCL_GENERIC_EXTENSION(ext, avail, core, 0U) | ||
245 | -#define OPENCL_OPTIONALCOREFEATURE(ext, avail, opt) OPENCL_GENERIC_EXTENSION(ext, avail, 0U, opt) | ||
246 | +#define OPENCL_EXTENSION(ext, pragma, avail) OPENCL_GENERIC_EXTENSION(ext, pragma, avail, 0U, 0U) | ||
247 | +#define OPENCL_COREFEATURE(ext, pragma, avail, core) OPENCL_GENERIC_EXTENSION(ext, pragma, avail, core, 0U) | ||
248 | +#define OPENCL_OPTIONALCOREFEATURE(ext, pragma, avail, opt) OPENCL_GENERIC_EXTENSION(ext, pragma, avail, 0U, opt) | ||
249 | |||
250 | // OpenCL 1.0. | ||
251 | -OPENCL_COREFEATURE(cl_khr_byte_addressable_store, 100, OCL_C_11P) | ||
252 | -OPENCL_COREFEATURE(cl_khr_global_int32_base_atomics, 100, OCL_C_11P) | ||
253 | -OPENCL_COREFEATURE(cl_khr_global_int32_extended_atomics, 100, OCL_C_11P) | ||
254 | -OPENCL_COREFEATURE(cl_khr_local_int32_base_atomics, 100, OCL_C_11P) | ||
255 | -OPENCL_COREFEATURE(cl_khr_local_int32_extended_atomics, 100, OCL_C_11P) | ||
256 | -OPENCL_OPTIONALCOREFEATURE(cl_khr_fp64, 100, OCL_C_12P) | ||
257 | -OPENCL_EXTENSION(cl_khr_fp16, 100) | ||
258 | -OPENCL_EXTENSION(cl_khr_int64_base_atomics, 100) | ||
259 | -OPENCL_EXTENSION(cl_khr_int64_extended_atomics, 100) | ||
260 | -OPENCL_GENERIC_EXTENSION(cl_khr_3d_image_writes, 100, OCL_C_20, OCL_C_30) | ||
261 | +OPENCL_COREFEATURE(cl_khr_byte_addressable_store, true, 100, OCL_C_11P) | ||
262 | +OPENCL_COREFEATURE(cl_khr_global_int32_base_atomics, true, 100, OCL_C_11P) | ||
263 | +OPENCL_COREFEATURE(cl_khr_global_int32_extended_atomics, true, 100, OCL_C_11P) | ||
264 | +OPENCL_COREFEATURE(cl_khr_local_int32_base_atomics, true, 100, OCL_C_11P) | ||
265 | +OPENCL_COREFEATURE(cl_khr_local_int32_extended_atomics, true, 100, OCL_C_11P) | ||
266 | +OPENCL_OPTIONALCOREFEATURE(cl_khr_fp64, true, 100, OCL_C_12P) | ||
267 | +OPENCL_EXTENSION(cl_khr_fp16, true, 100) | ||
268 | +OPENCL_EXTENSION(cl_khr_int64_base_atomics, true, 100) | ||
269 | +OPENCL_EXTENSION(cl_khr_int64_extended_atomics, true, 100) | ||
270 | +OPENCL_COREFEATURE(cl_khr_3d_image_writes, true, 100, OCL_C_20) | ||
271 | |||
272 | // EMBEDDED_PROFILE | ||
273 | -OPENCL_EXTENSION(cles_khr_int64, 110) | ||
274 | +OPENCL_EXTENSION(cles_khr_int64, true, 110) | ||
275 | |||
276 | // OpenCL 1.2. | ||
277 | -OPENCL_EXTENSION(cl_khr_depth_images, 120) | ||
278 | -OPENCL_EXTENSION(cl_khr_gl_msaa_sharing, 120) | ||
279 | +OPENCL_EXTENSION(cl_khr_depth_images, true, 120) | ||
280 | +OPENCL_EXTENSION(cl_khr_gl_msaa_sharing,true, 120) | ||
281 | |||
282 | // OpenCL 2.0. | ||
283 | -OPENCL_EXTENSION(cl_khr_mipmap_image, 200) | ||
284 | -OPENCL_EXTENSION(cl_khr_mipmap_image_writes, 200) | ||
285 | -OPENCL_EXTENSION(cl_khr_srgb_image_writes, 200) | ||
286 | -OPENCL_EXTENSION(cl_khr_subgroups, 200) | ||
287 | +OPENCL_EXTENSION(cl_khr_mipmap_image, true, 200) | ||
288 | +OPENCL_EXTENSION(cl_khr_mipmap_image_writes, true, 200) | ||
289 | +OPENCL_EXTENSION(cl_khr_srgb_image_writes, true, 200) | ||
290 | +OPENCL_EXTENSION(cl_khr_subgroups, true, 200) | ||
291 | |||
292 | // Clang Extensions. | ||
293 | -OPENCL_EXTENSION(cl_clang_storage_class_specifiers, 100) | ||
294 | -OPENCL_EXTENSION(__cl_clang_function_pointers, 100) | ||
295 | -OPENCL_EXTENSION(__cl_clang_variadic_functions, 100) | ||
296 | +OPENCL_EXTENSION(cl_clang_storage_class_specifiers, true, 100) | ||
297 | +OPENCL_EXTENSION(__cl_clang_function_pointers, true, 100) | ||
298 | +OPENCL_EXTENSION(__cl_clang_variadic_functions, true, 100) | ||
299 | |||
300 | // AMD OpenCL extensions | ||
301 | -OPENCL_EXTENSION(cl_amd_media_ops, 100) | ||
302 | -OPENCL_EXTENSION(cl_amd_media_ops2, 100) | ||
303 | +OPENCL_EXTENSION(cl_amd_media_ops, true, 100) | ||
304 | +OPENCL_EXTENSION(cl_amd_media_ops2, true, 100) | ||
305 | |||
306 | // ARM OpenCL extensions | ||
307 | -OPENCL_EXTENSION(cl_arm_integer_dot_product_int8, 120) | ||
308 | -OPENCL_EXTENSION(cl_arm_integer_dot_product_accumulate_int8, 120) | ||
309 | -OPENCL_EXTENSION(cl_arm_integer_dot_product_accumulate_int16, 120) | ||
310 | -OPENCL_EXTENSION(cl_arm_integer_dot_product_accumulate_saturate_int8, 120) | ||
311 | +OPENCL_EXTENSION(cl_arm_integer_dot_product_int8, true, 120) | ||
312 | +OPENCL_EXTENSION(cl_arm_integer_dot_product_accumulate_int8, true, 120) | ||
313 | +OPENCL_EXTENSION(cl_arm_integer_dot_product_accumulate_int16, true, 120) | ||
314 | +OPENCL_EXTENSION(cl_arm_integer_dot_product_accumulate_saturate_int8, true, 120) | ||
315 | |||
316 | // Intel OpenCL extensions | ||
317 | -OPENCL_EXTENSION(cl_intel_subgroups, 120) | ||
318 | -OPENCL_EXTENSION(cl_intel_subgroups_short, 120) | ||
319 | -OPENCL_EXTENSION(cl_intel_device_side_avc_motion_estimation, 120) | ||
320 | +OPENCL_EXTENSION(cl_intel_subgroups, true, 120) | ||
321 | +OPENCL_EXTENSION(cl_intel_subgroups_short, true, 120) | ||
322 | +OPENCL_EXTENSION(cl_intel_device_side_avc_motion_estimation, true, 120) | ||
323 | |||
324 | +// OpenCL C 3.0 features (6.2.1. Features) | ||
325 | +OPENCL_OPTIONALCOREFEATURE(__opencl_c_pipes, false, 300, OCL_C_30) | ||
326 | +OPENCL_OPTIONALCOREFEATURE(__opencl_c_generic_address_space, false, 300, OCL_C_30) | ||
327 | +OPENCL_OPTIONALCOREFEATURE(__opencl_c_atomic_order_acq_rel, false, 300, OCL_C_30) | ||
328 | +OPENCL_OPTIONALCOREFEATURE(__opencl_c_atomic_order_seq_cst, false, 300, OCL_C_30) | ||
329 | +OPENCL_OPTIONALCOREFEATURE(__opencl_c_subgroups, false, 300, OCL_C_30) | ||
330 | +OPENCL_OPTIONALCOREFEATURE(__opencl_c_3d_image_writes, false, 300, OCL_C_30) | ||
331 | +OPENCL_OPTIONALCOREFEATURE(__opencl_c_device_enqueue, false, 300, OCL_C_30) | ||
332 | +OPENCL_OPTIONALCOREFEATURE(__opencl_c_read_write_images, false, 300, OCL_C_30) | ||
333 | +OPENCL_OPTIONALCOREFEATURE(__opencl_c_program_scope_global_variables, false, 300, OCL_C_30) | ||
334 | +OPENCL_OPTIONALCOREFEATURE(__opencl_c_fp64, false, 300, OCL_C_30) | ||
335 | +OPENCL_OPTIONALCOREFEATURE(__opencl_c_images, false, 300, OCL_C_30) | ||
336 | |||
337 | #undef OPENCL_OPTIONALCOREFEATURE | ||
338 | #undef OPENCL_COREFEATURE | ||
339 | diff --git a/clang/include/clang/Basic/OpenCLOptions.h b/clang/include/clang/Basic/OpenCLOptions.h | ||
340 | index fe27ef19d4d5..4779ad4d6507 100644 | ||
341 | --- a/clang/include/clang/Basic/OpenCLOptions.h | ||
342 | +++ b/clang/include/clang/Basic/OpenCLOptions.h | ||
343 | @@ -19,6 +19,9 @@ | ||
344 | |||
345 | namespace clang { | ||
346 | |||
347 | +class DiagnosticsEngine; | ||
348 | +class TargetInfo; | ||
349 | + | ||
350 | namespace { | ||
351 | // This enum maps OpenCL version(s) into value. These values are used as | ||
352 | // a mask to indicate in which OpenCL version(s) extension is a core or | ||
353 | @@ -64,15 +67,33 @@ static inline bool isOpenCLVersionIsContainedInMask(const LangOptions &LO, | ||
354 | /// OpenCL supported extensions and optional core features | ||
355 | class OpenCLOptions { | ||
356 | public: | ||
357 | + // OpenCL C v1.2 s6.5 - All program scope variables must be declared in the | ||
358 | + // __constant address space. | ||
359 | + // OpenCL C v2.0 s6.5.1 - Variables defined at program scope and static | ||
360 | + // variables inside a function can also be declared in the global | ||
361 | + // address space. | ||
362 | + // OpenCL C v3.0 s6.7.1 - Variables at program scope or static or extern | ||
363 | + // variables inside functions can be declared in global address space if | ||
364 | + // the __opencl_c_program_scope_global_variables feature is supported | ||
365 | + // C++ for OpenCL inherits rule from OpenCL C v2.0. | ||
366 | + bool areProgramScopeVariablesSupported(const LangOptions &Opts) const { | ||
367 | + return Opts.OpenCLCPlusPlus || Opts.OpenCLVersion == 200 || | ||
368 | + (Opts.OpenCLVersion == 300 && | ||
369 | + isSupported("__opencl_c_program_scope_global_variables", Opts)); | ||
370 | + } | ||
371 | + | ||
372 | struct OpenCLOptionInfo { | ||
373 | + // Does this option have pragma. | ||
374 | + bool WithPragma = false; | ||
375 | + | ||
376 | // Option starts to be available in this OpenCL version | ||
377 | - unsigned Avail; | ||
378 | + unsigned Avail = 100U; | ||
379 | |||
380 | // Option becomes core feature in this OpenCL versions | ||
381 | - unsigned Core; | ||
382 | + unsigned Core = 0U; | ||
383 | |||
384 | // Option becomes optional core feature in this OpenCL versions | ||
385 | - unsigned Opt; | ||
386 | + unsigned Opt = 0U; | ||
387 | |||
388 | // Is this option supported | ||
389 | bool Supported = false; | ||
390 | @@ -80,8 +101,10 @@ public: | ||
391 | // Is this option enabled | ||
392 | bool Enabled = false; | ||
393 | |||
394 | - OpenCLOptionInfo(unsigned A = 100, unsigned C = 0U, unsigned O = 0U) | ||
395 | - : Avail(A), Core(C), Opt(O) {} | ||
396 | + OpenCLOptionInfo() = default; | ||
397 | + OpenCLOptionInfo(bool Pragma, unsigned AvailV, unsigned CoreV, | ||
398 | + unsigned OptV) | ||
399 | + : WithPragma(Pragma), Avail(AvailV), Core(CoreV), Opt(OptV) {} | ||
400 | |||
401 | bool isCore() const { return Core != 0U; } | ||
402 | |||
403 | @@ -107,7 +130,12 @@ public: | ||
404 | |||
405 | bool isKnown(llvm::StringRef Ext) const; | ||
406 | |||
407 | - bool isEnabled(llvm::StringRef Ext) const; | ||
408 | + // For core or optional core feature check that it is supported | ||
409 | + // by a target, for any other option (extension) check that it is | ||
410 | + // enabled via pragma | ||
411 | + bool isAvailableOption(llvm::StringRef Ext, const LangOptions &LO) const; | ||
412 | + | ||
413 | + bool isWithPragma(llvm::StringRef Ext) const; | ||
414 | |||
415 | // Is supported as either an extension or an (optional) core feature for | ||
416 | // OpenCL version \p LO. | ||
417 | @@ -131,6 +159,11 @@ public: | ||
418 | // For supported core or optional core feature, return false. | ||
419 | bool isSupportedExtension(llvm::StringRef Ext, const LangOptions &LO) const; | ||
420 | |||
421 | + // FIXME: Whether extension should accept pragma should not | ||
422 | + // be reset dynamically. But it currently required when | ||
423 | + // registering new extensions via pragmas. | ||
424 | + void acceptsPragma(llvm::StringRef Ext, bool V = true); | ||
425 | + | ||
426 | void enable(llvm::StringRef Ext, bool V = true); | ||
427 | |||
428 | /// Enable or disable support for OpenCL extensions | ||
429 | @@ -148,15 +181,35 @@ public: | ||
430 | // Disable all extensions | ||
431 | void disableAll(); | ||
432 | |||
433 | - // Enable supported core and optional core features | ||
434 | - void enableSupportedCore(const LangOptions &LO); | ||
435 | - | ||
436 | friend class ASTWriter; | ||
437 | friend class ASTReader; | ||
438 | |||
439 | using OpenCLOptionInfoMap = llvm::StringMap<OpenCLOptionInfo>; | ||
440 | |||
441 | + template <typename... Args> | ||
442 | + static bool isOpenCLOptionCoreIn(const LangOptions &LO, Args &&... args) { | ||
443 | + return OpenCLOptionInfo(std::forward<Args>(args)...).isCoreIn(LO); | ||
444 | + } | ||
445 | + | ||
446 | + template <typename... Args> | ||
447 | + static bool isOpenCLOptionAvailableIn(const LangOptions &LO, | ||
448 | + Args &&... args) { | ||
449 | + return OpenCLOptionInfo(std::forward<Args>(args)...).isAvailableIn(LO); | ||
450 | + } | ||
451 | + | ||
452 | + // Diagnose feature dependencies for OpenCL C 3.0. Return false if target | ||
453 | + // doesn't follow these requirements. | ||
454 | + static bool diagnoseUnsupportedFeatureDependencies(const TargetInfo &TI, | ||
455 | + DiagnosticsEngine &Diags); | ||
456 | + | ||
457 | + // Diagnose that features and equivalent extension are set to same values. | ||
458 | + // Return false if target doesn't follow these requirements. | ||
459 | + static bool diagnoseFeatureExtensionDifferences(const TargetInfo &TI, | ||
460 | + DiagnosticsEngine &Diags); | ||
461 | + | ||
462 | private: | ||
463 | + // Option is enabled via pragma | ||
464 | + bool isEnabled(llvm::StringRef Ext) const; | ||
465 | OpenCLOptionInfoMap OptMap; | ||
466 | }; | ||
467 | |||
468 | diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h | ||
469 | index b782172d93a3..ec51758a35d4 100644 | ||
470 | --- a/clang/include/clang/Basic/TargetInfo.h | ||
471 | +++ b/clang/include/clang/Basic/TargetInfo.h | ||
472 | @@ -1192,6 +1192,12 @@ public: | ||
473 | return false; | ||
474 | } | ||
475 | |||
476 | + /// Check if target has a given feature enabled | ||
477 | + virtual bool hasFeatureEnabled(const llvm::StringMap<bool> &Features, | ||
478 | + StringRef Name) const { | ||
479 | + return Features.lookup(Name); | ||
480 | + } | ||
481 | + | ||
482 | /// Enable or disable a specific target feature; | ||
483 | /// the feature name must be valid. | ||
484 | virtual void setFeatureEnabled(llvm::StringMap<bool> &Features, | ||
485 | @@ -1439,7 +1445,8 @@ public: | ||
486 | virtual void setSupportedOpenCLOpts() {} | ||
487 | |||
488 | virtual void supportAllOpenCLOpts(bool V = true) { | ||
489 | -#define OPENCLEXTNAME(Ext) getTargetOpts().OpenCLFeaturesMap[#Ext] = V; | ||
490 | +#define OPENCLEXTNAME(Ext) \ | ||
491 | + setFeatureEnabled(getTargetOpts().OpenCLFeaturesMap, #Ext, V); | ||
492 | #include "clang/Basic/OpenCLExtensions.def" | ||
493 | } | ||
494 | |||
495 | @@ -1459,10 +1466,6 @@ public: | ||
496 | } | ||
497 | } | ||
498 | |||
499 | - /// Define OpenCL macros based on target settings and language version | ||
500 | - void getOpenCLFeatureDefines(const LangOptions &Opts, | ||
501 | - MacroBuilder &Builder) const; | ||
502 | - | ||
503 | /// Get supported OpenCL extensions and optional core features. | ||
504 | llvm::StringMap<bool> &getSupportedOpenCLOpts() { | ||
505 | return getTargetOpts().OpenCLFeaturesMap; | ||
506 | @@ -1502,6 +1505,11 @@ public: | ||
507 | return true; | ||
508 | } | ||
509 | |||
510 | + /// Check that OpenCL target has valid options setting based on OpenCL | ||
511 | + /// version. | ||
512 | + virtual bool validateOpenCLTarget(const LangOptions &Opts, | ||
513 | + DiagnosticsEngine &Diags) const; | ||
514 | + | ||
515 | virtual void setAuxTarget(const TargetInfo *Aux) {} | ||
516 | |||
517 | /// Whether target allows debuginfo types for decl only variables. | ||
518 | diff --git a/clang/include/clang/Sema/Overload.h b/clang/include/clang/Sema/Overload.h | ||
519 | index 5be6a618711c..699c3e808872 100644 | ||
520 | --- a/clang/include/clang/Sema/Overload.h | ||
521 | +++ b/clang/include/clang/Sema/Overload.h | ||
522 | @@ -760,9 +760,6 @@ class Sema; | ||
523 | /// This candidate was not viable because its address could not be taken. | ||
524 | ovl_fail_addr_not_available, | ||
525 | |||
526 | - /// This candidate was not viable because its OpenCL extension is disabled. | ||
527 | - ovl_fail_ext_disabled, | ||
528 | - | ||
529 | /// This inherited constructor is not viable because it would slice the | ||
530 | /// argument. | ||
531 | ovl_fail_inhctor_slice, | ||
532 | diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h | ||
533 | index 2530a2776373..7e7348d6de2a 100644 | ||
534 | --- a/clang/include/clang/Sema/Sema.h | ||
535 | +++ b/clang/include/clang/Sema/Sema.h | ||
536 | @@ -10106,73 +10106,6 @@ public: | ||
537 | /// potentially-throwing. | ||
538 | bool checkFinalSuspendNoThrow(const Stmt *FinalSuspend); | ||
539 | |||
540 | - //===--------------------------------------------------------------------===// | ||
541 | - // OpenCL extensions. | ||
542 | - // | ||
543 | -private: | ||
544 | - std::string CurrOpenCLExtension; | ||
545 | - /// Extensions required by an OpenCL type. | ||
546 | - llvm::DenseMap<const Type*, std::set<std::string>> OpenCLTypeExtMap; | ||
547 | - /// Extensions required by an OpenCL declaration. | ||
548 | - llvm::DenseMap<const Decl*, std::set<std::string>> OpenCLDeclExtMap; | ||
549 | -public: | ||
550 | - llvm::StringRef getCurrentOpenCLExtension() const { | ||
551 | - return CurrOpenCLExtension; | ||
552 | - } | ||
553 | - | ||
554 | - /// Check if a function declaration \p FD associates with any | ||
555 | - /// extensions present in OpenCLDeclExtMap and if so return the | ||
556 | - /// extension(s) name(s). | ||
557 | - std::string getOpenCLExtensionsFromDeclExtMap(FunctionDecl *FD); | ||
558 | - | ||
559 | - /// Check if a function type \p FT associates with any | ||
560 | - /// extensions present in OpenCLTypeExtMap and if so return the | ||
561 | - /// extension(s) name(s). | ||
562 | - std::string getOpenCLExtensionsFromTypeExtMap(FunctionType *FT); | ||
563 | - | ||
564 | - /// Find an extension in an appropriate extension map and return its name | ||
565 | - template<typename T, typename MapT> | ||
566 | - std::string getOpenCLExtensionsFromExtMap(T* FT, MapT &Map); | ||
567 | - | ||
568 | - void setCurrentOpenCLExtension(llvm::StringRef Ext) { | ||
569 | - CurrOpenCLExtension = std::string(Ext); | ||
570 | - } | ||
571 | - | ||
572 | - /// Set OpenCL extensions for a type which can only be used when these | ||
573 | - /// OpenCL extensions are enabled. If \p Exts is empty, do nothing. | ||
574 | - /// \param Exts A space separated list of OpenCL extensions. | ||
575 | - void setOpenCLExtensionForType(QualType T, llvm::StringRef Exts); | ||
576 | - | ||
577 | - /// Set OpenCL extensions for a declaration which can only be | ||
578 | - /// used when these OpenCL extensions are enabled. If \p Exts is empty, do | ||
579 | - /// nothing. | ||
580 | - /// \param Exts A space separated list of OpenCL extensions. | ||
581 | - void setOpenCLExtensionForDecl(Decl *FD, llvm::StringRef Exts); | ||
582 | - | ||
583 | - /// Set current OpenCL extensions for a type which can only be used | ||
584 | - /// when these OpenCL extensions are enabled. If current OpenCL extension is | ||
585 | - /// empty, do nothing. | ||
586 | - void setCurrentOpenCLExtensionForType(QualType T); | ||
587 | - | ||
588 | - /// Set current OpenCL extensions for a declaration which | ||
589 | - /// can only be used when these OpenCL extensions are enabled. If current | ||
590 | - /// OpenCL extension is empty, do nothing. | ||
591 | - void setCurrentOpenCLExtensionForDecl(Decl *FD); | ||
592 | - | ||
593 | - bool isOpenCLDisabledDecl(Decl *FD); | ||
594 | - | ||
595 | - /// Check if type \p T corresponding to declaration specifier \p DS | ||
596 | - /// is disabled due to required OpenCL extensions being disabled. If so, | ||
597 | - /// emit diagnostics. | ||
598 | - /// \return true if type is disabled. | ||
599 | - bool checkOpenCLDisabledTypeDeclSpec(const DeclSpec &DS, QualType T); | ||
600 | - | ||
601 | - /// Check if declaration \p D used by expression \p E | ||
602 | - /// is disabled due to required OpenCL extensions being disabled. If so, | ||
603 | - /// emit diagnostics. | ||
604 | - /// \return true if type is disabled. | ||
605 | - bool checkOpenCLDisabledDecl(const NamedDecl &D, const Expr &E); | ||
606 | - | ||
607 | //===--------------------------------------------------------------------===// | ||
608 | // OpenMP directives and clauses. | ||
609 | // | ||
610 | @@ -10203,21 +10136,6 @@ private: | ||
611 | /// Pop OpenMP function region for non-capturing function. | ||
612 | void popOpenMPFunctionRegion(const sema::FunctionScopeInfo *OldFSI); | ||
613 | |||
614 | - /// Checks if a type or a declaration is disabled due to the owning extension | ||
615 | - /// being disabled, and emits diagnostic messages if it is disabled. | ||
616 | - /// \param D type or declaration to be checked. | ||
617 | - /// \param DiagLoc source location for the diagnostic message. | ||
618 | - /// \param DiagInfo information to be emitted for the diagnostic message. | ||
619 | - /// \param SrcRange source range of the declaration. | ||
620 | - /// \param Map maps type or declaration to the extensions. | ||
621 | - /// \param Selector selects diagnostic message: 0 for type and 1 for | ||
622 | - /// declaration. | ||
623 | - /// \return true if the type or declaration is disabled. | ||
624 | - template <typename T, typename DiagLocT, typename DiagInfoT, typename MapT> | ||
625 | - bool checkOpenCLDisabledTypeOrDecl(T D, DiagLocT DiagLoc, DiagInfoT DiagInfo, | ||
626 | - MapT &Map, unsigned Selector = 0, | ||
627 | - SourceRange SrcRange = SourceRange()); | ||
628 | - | ||
629 | /// Helper to keep information about the current `omp begin/end declare | ||
630 | /// variant` nesting. | ||
631 | struct OMPDeclareVariantScope { | ||
632 | diff --git a/clang/include/clang/Serialization/ASTWriter.h b/clang/include/clang/Serialization/ASTWriter.h | ||
633 | index 12073a38a77a..176badf7a0d1 100644 | ||
634 | --- a/clang/include/clang/Serialization/ASTWriter.h | ||
635 | +++ b/clang/include/clang/Serialization/ASTWriter.h | ||
636 | @@ -510,8 +510,6 @@ private: | ||
637 | void WriteDeclContextVisibleUpdate(const DeclContext *DC); | ||
638 | void WriteFPPragmaOptions(const FPOptionsOverride &Opts); | ||
639 | void WriteOpenCLExtensions(Sema &SemaRef); | ||
640 | - void WriteOpenCLExtensionTypes(Sema &SemaRef); | ||
641 | - void WriteOpenCLExtensionDecls(Sema &SemaRef); | ||
642 | void WriteCUDAPragmas(Sema &SemaRef); | ||
643 | void WriteObjCCategories(); | ||
644 | void WriteLateParsedTemplates(Sema &SemaRef); | ||
645 | diff --git a/clang/lib/Basic/OpenCLOptions.cpp b/clang/lib/Basic/OpenCLOptions.cpp | ||
646 | index 266acc5fe477..d7729ffb09ce 100644 | ||
647 | --- a/clang/lib/Basic/OpenCLOptions.cpp | ||
648 | +++ b/clang/lib/Basic/OpenCLOptions.cpp | ||
649 | @@ -7,6 +7,8 @@ | ||
650 | //===----------------------------------------------------------------------===// | ||
651 | |||
652 | #include "clang/Basic/OpenCLOptions.h" | ||
653 | +#include "clang/Basic/Diagnostic.h" | ||
654 | +#include "clang/Basic/TargetInfo.h" | ||
655 | |||
656 | namespace clang { | ||
657 | |||
658 | @@ -14,9 +16,26 @@ bool OpenCLOptions::isKnown(llvm::StringRef Ext) const { | ||
659 | return OptMap.find(Ext) != OptMap.end(); | ||
660 | } | ||
661 | |||
662 | +bool OpenCLOptions::isAvailableOption(llvm::StringRef Ext, | ||
663 | + const LangOptions &LO) const { | ||
664 | + if (!isKnown(Ext)) | ||
665 | + return false; | ||
666 | + | ||
667 | + auto &OptInfo = OptMap.find(Ext)->getValue(); | ||
668 | + if (OptInfo.isCoreIn(LO) || OptInfo.isOptionalCoreIn(LO)) | ||
669 | + return isSupported(Ext, LO); | ||
670 | + | ||
671 | + return isEnabled(Ext); | ||
672 | +} | ||
673 | + | ||
674 | bool OpenCLOptions::isEnabled(llvm::StringRef Ext) const { | ||
675 | + auto I = OptMap.find(Ext); | ||
676 | + return I != OptMap.end() && I->getValue().Enabled; | ||
677 | +} | ||
678 | + | ||
679 | +bool OpenCLOptions::isWithPragma(llvm::StringRef Ext) const { | ||
680 | auto E = OptMap.find(Ext); | ||
681 | - return E != OptMap.end() && E->second.Enabled; | ||
682 | + return E != OptMap.end() && E->second.WithPragma; | ||
683 | } | ||
684 | |||
685 | bool OpenCLOptions::isSupported(llvm::StringRef Ext, | ||
686 | @@ -31,22 +50,16 @@ bool OpenCLOptions::isSupported(llvm::StringRef Ext, | ||
687 | |||
688 | bool OpenCLOptions::isSupportedCore(llvm::StringRef Ext, | ||
689 | const LangOptions &LO) const { | ||
690 | - auto E = OptMap.find(Ext); | ||
691 | - if (E == OptMap.end()) { | ||
692 | - return false; | ||
693 | - } | ||
694 | - auto I = OptMap.find(Ext)->getValue(); | ||
695 | - return I.Supported && I.isCoreIn(LO); | ||
696 | + auto I = OptMap.find(Ext); | ||
697 | + return I != OptMap.end() && I->getValue().Supported && | ||
698 | + I->getValue().isCoreIn(LO); | ||
699 | } | ||
700 | |||
701 | bool OpenCLOptions::isSupportedOptionalCore(llvm::StringRef Ext, | ||
702 | const LangOptions &LO) const { | ||
703 | - auto E = OptMap.find(Ext); | ||
704 | - if (E == OptMap.end()) { | ||
705 | - return false; | ||
706 | - } | ||
707 | - auto I = OptMap.find(Ext)->getValue(); | ||
708 | - return I.Supported && I.isOptionalCoreIn(LO); | ||
709 | + auto I = OptMap.find(Ext); | ||
710 | + return I != OptMap.end() && I->getValue().Supported && | ||
711 | + I->getValue().isOptionalCoreIn(LO); | ||
712 | } | ||
713 | |||
714 | bool OpenCLOptions::isSupportedCoreOrOptionalCore(llvm::StringRef Ext, | ||
715 | @@ -56,12 +69,9 @@ bool OpenCLOptions::isSupportedCoreOrOptionalCore(llvm::StringRef Ext, | ||
716 | |||
717 | bool OpenCLOptions::isSupportedExtension(llvm::StringRef Ext, | ||
718 | const LangOptions &LO) const { | ||
719 | - auto E = OptMap.find(Ext); | ||
720 | - if (E == OptMap.end()) { | ||
721 | - return false; | ||
722 | - } | ||
723 | - auto I = OptMap.find(Ext)->getValue(); | ||
724 | - return I.Supported && I.isAvailableIn(LO) && | ||
725 | + auto I = OptMap.find(Ext); | ||
726 | + return I != OptMap.end() && I->getValue().Supported && | ||
727 | + I->getValue().isAvailableIn(LO) && | ||
728 | !isSupportedCoreOrOptionalCore(Ext, LO); | ||
729 | } | ||
730 | |||
731 | @@ -69,6 +79,10 @@ void OpenCLOptions::enable(llvm::StringRef Ext, bool V) { | ||
732 | OptMap[Ext].Enabled = V; | ||
733 | } | ||
734 | |||
735 | +void OpenCLOptions::acceptsPragma(llvm::StringRef Ext, bool V) { | ||
736 | + OptMap[Ext].WithPragma = V; | ||
737 | +} | ||
738 | + | ||
739 | void OpenCLOptions::support(llvm::StringRef Ext, bool V) { | ||
740 | assert(!Ext.empty() && "Extension is empty."); | ||
741 | assert(Ext[0] != '+' && Ext[0] != '-'); | ||
742 | @@ -76,11 +90,9 @@ void OpenCLOptions::support(llvm::StringRef Ext, bool V) { | ||
743 | } | ||
744 | |||
745 | OpenCLOptions::OpenCLOptions() { | ||
746 | -#define OPENCL_GENERIC_EXTENSION(Ext, AvailVer, CoreVer, OptVer) \ | ||
747 | - OptMap[#Ext].Avail = AvailVer; \ | ||
748 | - OptMap[#Ext].Core = CoreVer; \ | ||
749 | - OptMap[#Ext].Opt = OptVer; | ||
750 | -#include "clang/Basic/OpenCLExtensions.def" | ||
751 | +#define OPENCL_GENERIC_EXTENSION(Ext, ...) \ | ||
752 | + OptMap.insert_or_assign(#Ext, OpenCLOptionInfo{__VA_ARGS__}); | ||
753 | + #include "clang/Basic/OpenCLExtensions.def" | ||
754 | } | ||
755 | |||
756 | void OpenCLOptions::addSupport(const llvm::StringMap<bool> &FeaturesMap, | ||
757 | @@ -97,10 +109,45 @@ void OpenCLOptions::disableAll() { | ||
758 | Opt.getValue().Enabled = false; | ||
759 | } | ||
760 | |||
761 | -void OpenCLOptions::enableSupportedCore(const LangOptions &LO) { | ||
762 | - for (auto &Opt : OptMap) | ||
763 | - if (isSupportedCoreOrOptionalCore(Opt.getKey(), LO)) | ||
764 | - Opt.getValue().Enabled = true; | ||
765 | +bool OpenCLOptions::diagnoseUnsupportedFeatureDependencies( | ||
766 | + const TargetInfo &TI, DiagnosticsEngine &Diags) { | ||
767 | + // Feature pairs. First feature in a pair requires the second one to be | ||
768 | + // supported. | ||
769 | + static const llvm::StringMap<llvm::StringRef> DependentFeaturesMap = { | ||
770 | + {"__opencl_c_read_write_images", "__opencl_c_images"}, | ||
771 | + {"__opencl_c_3d_image_writes", "__opencl_c_images"}}; | ||
772 | + | ||
773 | + auto OpenCLFeaturesMap = TI.getSupportedOpenCLOpts(); | ||
774 | + | ||
775 | + bool IsValid = true; | ||
776 | + for (auto &FeaturePair : DependentFeaturesMap) | ||
777 | + if (TI.hasFeatureEnabled(OpenCLFeaturesMap, FeaturePair.getKey()) && | ||
778 | + !TI.hasFeatureEnabled(OpenCLFeaturesMap, FeaturePair.getValue())) { | ||
779 | + IsValid = false; | ||
780 | + Diags.Report(diag::err_opencl_feature_requires) | ||
781 | + << FeaturePair.getKey() << FeaturePair.getValue(); | ||
782 | + } | ||
783 | + return IsValid; | ||
784 | +} | ||
785 | + | ||
786 | +bool OpenCLOptions::diagnoseFeatureExtensionDifferences( | ||
787 | + const TargetInfo &TI, DiagnosticsEngine &Diags) { | ||
788 | + // Extensions and equivalent feature pairs. | ||
789 | + static const llvm::StringMap<llvm::StringRef> FeatureExtensionMap = { | ||
790 | + {"cl_khr_fp64", "__opencl_c_fp64"}, | ||
791 | + {"cl_khr_3d_image_writes", "__opencl_c_3d_image_writes"}}; | ||
792 | + | ||
793 | + auto OpenCLFeaturesMap = TI.getSupportedOpenCLOpts(); | ||
794 | + | ||
795 | + bool IsValid = true; | ||
796 | + for (auto &ExtAndFeat : FeatureExtensionMap) | ||
797 | + if (TI.hasFeatureEnabled(OpenCLFeaturesMap, ExtAndFeat.getKey()) != | ||
798 | + TI.hasFeatureEnabled(OpenCLFeaturesMap, ExtAndFeat.getValue())) { | ||
799 | + IsValid = false; | ||
800 | + Diags.Report(diag::err_opencl_extension_and_feature_differs) | ||
801 | + << ExtAndFeat.getKey() << ExtAndFeat.getValue(); | ||
802 | + } | ||
803 | + return IsValid; | ||
804 | } | ||
805 | |||
806 | } // end namespace clang | ||
807 | diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp | ||
808 | index 642ee753d224..61cfd59ccf28 100644 | ||
809 | --- a/clang/lib/Basic/TargetInfo.cpp | ||
810 | +++ b/clang/lib/Basic/TargetInfo.cpp | ||
811 | @@ -366,6 +366,19 @@ void TargetInfo::adjust(LangOptions &Opts) { | ||
812 | HalfWidth = HalfAlign = 16; | ||
813 | FloatWidth = FloatAlign = 32; | ||
814 | |||
815 | + // OpenCL C v3.0 s6.7.5 - The generic address space requires support for | ||
816 | + // OpenCL C 2.0 or OpenCL C 3.0 with the __opencl_c_generic_address_space | ||
817 | + // feature | ||
818 | + // FIXME: OpenCLGenericAddressSpace is also defined in setLangDefaults() | ||
819 | + // for OpenCL C 2.0 but with no access to target capabilities. Target | ||
820 | + // should be immutable once created and thus this language option needs | ||
821 | + // to be defined only once. | ||
822 | + if (Opts.OpenCLVersion >= 300) { | ||
823 | + const auto &OpenCLFeaturesMap = getSupportedOpenCLOpts(); | ||
824 | + Opts.OpenCLGenericAddressSpace = hasFeatureEnabled( | ||
825 | + OpenCLFeaturesMap, "__opencl_c_generic_address_space"); | ||
826 | + } | ||
827 | + | ||
828 | // Embedded 32-bit targets (OpenCL EP) might have double C type | ||
829 | // defined as float. Let's not override this as it might lead | ||
830 | // to generating illegal code that uses 64bit doubles. | ||
831 | @@ -388,6 +401,19 @@ void TargetInfo::adjust(LangOptions &Opts) { | ||
832 | HalfFormat = &llvm::APFloat::IEEEhalf(); | ||
833 | FloatFormat = &llvm::APFloat::IEEEsingle(); | ||
834 | LongDoubleFormat = &llvm::APFloat::IEEEquad(); | ||
835 | + | ||
836 | + // OpenCL C v3.0 s6.7.5 - The generic address space requires support for | ||
837 | + // OpenCL C 2.0 or OpenCL C 3.0 with the __opencl_c_generic_address_space | ||
838 | + // feature | ||
839 | + // FIXME: OpenCLGenericAddressSpace is also defined in setLangDefaults() | ||
840 | + // for OpenCL C 2.0 but with no access to target capabilities. Target | ||
841 | + // should be immutable once created and thus this language option needs | ||
842 | + // to be defined only once. | ||
843 | + if (Opts.OpenCLVersion >= 300) { | ||
844 | + const auto &OpenCLFeaturesMap = getSupportedOpenCLOpts(); | ||
845 | + Opts.OpenCLGenericAddressSpace = hasFeatureEnabled( | ||
846 | + OpenCLFeaturesMap, "__opencl_c_generic_address_space"); | ||
847 | + } | ||
848 | } | ||
849 | |||
850 | if (Opts.DoubleSize) { | ||
851 | diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp | ||
852 | index 90a67d03b7b2..c171d2ed7c95 100644 | ||
853 | --- a/clang/lib/Basic/Targets.cpp | ||
854 | +++ b/clang/lib/Basic/Targets.cpp | ||
855 | @@ -715,29 +715,28 @@ TargetInfo::CreateTargetInfo(DiagnosticsEngine &Diags, | ||
856 | |||
857 | return Target.release(); | ||
858 | } | ||
859 | - | ||
860 | -/// getOpenCLFeatureDefines - Define OpenCL macros based on target settings | ||
861 | -/// and language version | ||
862 | -void TargetInfo::getOpenCLFeatureDefines(const LangOptions &Opts, | ||
863 | - MacroBuilder &Builder) const { | ||
864 | - | ||
865 | - auto defineOpenCLExtMacro = [&](llvm::StringRef Name, unsigned AvailVer, | ||
866 | - unsigned CoreVersions, | ||
867 | - unsigned OptionalVersions) { | ||
868 | - // Check if extension is supported by target and is available in this | ||
869 | - // OpenCL version | ||
870 | - auto It = getTargetOpts().OpenCLFeaturesMap.find(Name); | ||
871 | - if ((It != getTargetOpts().OpenCLFeaturesMap.end()) && It->getValue() && | ||
872 | - OpenCLOptions::OpenCLOptionInfo(AvailVer, CoreVersions, | ||
873 | - OptionalVersions) | ||
874 | - .isAvailableIn(Opts)) | ||
875 | - Builder.defineMacro(Name); | ||
876 | +/// validateOpenCLTarget - Check that OpenCL target has valid | ||
877 | +/// options setting based on OpenCL version. | ||
878 | +bool TargetInfo::validateOpenCLTarget(const LangOptions &Opts, | ||
879 | + DiagnosticsEngine &Diags) const { | ||
880 | + const llvm::StringMap<bool> &OpenCLFeaturesMap = getSupportedOpenCLOpts(); | ||
881 | + | ||
882 | + auto diagnoseNotSupportedCore = [&](llvm::StringRef Name, auto... OptArgs) { | ||
883 | + if (OpenCLOptions::isOpenCLOptionCoreIn(Opts, OptArgs...) && | ||
884 | + !hasFeatureEnabled(OpenCLFeaturesMap, Name)) | ||
885 | + Diags.Report(diag::warn_opencl_unsupported_core_feature) | ||
886 | + << Name << Opts.OpenCLCPlusPlus | ||
887 | + << Opts.getOpenCLVersionTuple().getAsString(); | ||
888 | }; | ||
889 | -#define OPENCL_GENERIC_EXTENSION(Ext, Avail, Core, Opt) \ | ||
890 | - defineOpenCLExtMacro(#Ext, Avail, Core, Opt); | ||
891 | +#define OPENCL_GENERIC_EXTENSION(Ext, ...) \ | ||
892 | + diagnoseNotSupportedCore(#Ext, __VA_ARGS__); | ||
893 | #include "clang/Basic/OpenCLExtensions.def" | ||
894 | |||
895 | - // FIXME: OpenCL options which affect language semantics/syntax | ||
896 | - // should be moved into LangOptions, thus macro definitions of | ||
897 | - // such options is better to be done in clang::InitializePreprocessor | ||
898 | + // Validate that feature macros are set properly for OpenCL C 3.0. | ||
899 | + // In other cases assume that target is always valid. | ||
900 | + if (Opts.OpenCLCPlusPlus || Opts.OpenCLVersion < 300) | ||
901 | + return true; | ||
902 | + | ||
903 | + return OpenCLOptions::diagnoseUnsupportedFeatureDependencies(*this, Diags) && | ||
904 | + OpenCLOptions::diagnoseFeatureExtensionDifferences(*this, Diags); | ||
905 | } | ||
906 | diff --git a/clang/lib/Basic/Targets/AMDGPU.h b/clang/lib/Basic/Targets/AMDGPU.h | ||
907 | index 8ee0ca30d305..b11fe212c3a2 100644 | ||
908 | --- a/clang/lib/Basic/Targets/AMDGPU.h | ||
909 | +++ b/clang/lib/Basic/Targets/AMDGPU.h | ||
910 | @@ -291,6 +291,7 @@ public: | ||
911 | bool IsAMDGCN = isAMDGCN(getTriple()); | ||
912 | |||
913 | Opts["cl_khr_fp64"] = hasFP64(); | ||
914 | + Opts["__opencl_c_fp64"] = hasFP64(); | ||
915 | |||
916 | if (IsAMDGCN || GPUKind >= llvm::AMDGPU::GK_CEDAR) { | ||
917 | Opts["cl_khr_byte_addressable_store"] = true; | ||
918 | @@ -307,9 +308,12 @@ public: | ||
919 | Opts["cl_khr_mipmap_image"] = true; | ||
920 | Opts["cl_khr_mipmap_image_writes"] = true; | ||
921 | Opts["cl_khr_subgroups"] = true; | ||
922 | - Opts["cl_khr_3d_image_writes"] = true; | ||
923 | Opts["cl_amd_media_ops"] = true; | ||
924 | Opts["cl_amd_media_ops2"] = true; | ||
925 | + | ||
926 | + Opts["__opencl_c_images"] = true; | ||
927 | + Opts["__opencl_c_3d_image_writes"] = true; | ||
928 | + Opts["cl_khr_3d_image_writes"] = true; | ||
929 | } | ||
930 | } | ||
931 | |||
932 | diff --git a/clang/lib/Basic/Targets/NVPTX.h b/clang/lib/Basic/Targets/NVPTX.h | ||
933 | index 038dec4a28bd..010e640804bf 100644 | ||
934 | --- a/clang/lib/Basic/Targets/NVPTX.h | ||
935 | +++ b/clang/lib/Basic/Targets/NVPTX.h | ||
936 | @@ -132,6 +132,7 @@ public: | ||
937 | Opts["__cl_clang_variadic_functions"] = true; | ||
938 | |||
939 | Opts["cl_khr_fp64"] = true; | ||
940 | + Opts["__opencl_c_fp64"] = true; | ||
941 | Opts["cl_khr_byte_addressable_store"] = true; | ||
942 | Opts["cl_khr_global_int32_base_atomics"] = true; | ||
943 | Opts["cl_khr_global_int32_extended_atomics"] = true; | ||
944 | diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp | ||
945 | index c5ad1c7d2c2e..701b03c868d1 100644 | ||
946 | --- a/clang/lib/Basic/Targets/X86.cpp | ||
947 | +++ b/clang/lib/Basic/Targets/X86.cpp | ||
948 | @@ -1397,13 +1397,13 @@ bool X86TargetInfo::validateOperandSize(const llvm::StringMap<bool> &FeatureMap, | ||
949 | return Size <= 64; | ||
950 | case 'z': | ||
951 | // XMM0/YMM/ZMM0 | ||
952 | - if (FeatureMap.lookup("avx512f")) | ||
953 | + if (hasFeatureEnabled(FeatureMap, "avx512f")) | ||
954 | // ZMM0 can be used if target supports AVX512F. | ||
955 | return Size <= 512U; | ||
956 | - else if (FeatureMap.lookup("avx")) | ||
957 | + else if (hasFeatureEnabled(FeatureMap, "avx")) | ||
958 | // YMM0 can be used if target supports AVX. | ||
959 | return Size <= 256U; | ||
960 | - else if (FeatureMap.lookup("sse")) | ||
961 | + else if (hasFeatureEnabled(FeatureMap, "sse")) | ||
962 | return Size <= 128U; | ||
963 | return false; | ||
964 | case 'i': | ||
965 | @@ -1417,10 +1417,10 @@ bool X86TargetInfo::validateOperandSize(const llvm::StringMap<bool> &FeatureMap, | ||
966 | break; | ||
967 | case 'v': | ||
968 | case 'x': | ||
969 | - if (FeatureMap.lookup("avx512f")) | ||
970 | + if (hasFeatureEnabled(FeatureMap, "avx512f")) | ||
971 | // 512-bit zmm registers can be used if target supports AVX512F. | ||
972 | return Size <= 512U; | ||
973 | - else if (FeatureMap.lookup("avx")) | ||
974 | + else if (hasFeatureEnabled(FeatureMap, "avx")) | ||
975 | // 256-bit ymm registers can be used if target supports AVX. | ||
976 | return Size <= 256U; | ||
977 | return Size <= 128U; | ||
978 | diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp | ||
979 | index 956877d34680..3e5c07538662 100644 | ||
980 | --- a/clang/lib/Frontend/CompilerInstance.cpp | ||
981 | +++ b/clang/lib/Frontend/CompilerInstance.cpp | ||
982 | @@ -910,6 +910,11 @@ bool CompilerInstance::ExecuteAction(FrontendAction &Act) { | ||
983 | } | ||
984 | // FIXME: can we disable FEnvAccess? | ||
985 | } | ||
986 | + // We should do it here because target knows nothing about | ||
987 | + // language options when it's being created. | ||
988 | + if (getLangOpts().OpenCL && | ||
989 | + !getTarget().validateOpenCLTarget(getLangOpts(), getDiagnostics())) | ||
990 | + return false; | ||
991 | |||
992 | // Inform the target of the language options. | ||
993 | // | ||
994 | diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp | ||
995 | index 5c5cf46150e2..e1580b60dd89 100644 | ||
996 | --- a/clang/lib/Frontend/CompilerInvocation.cpp | ||
997 | +++ b/clang/lib/Frontend/CompilerInvocation.cpp | ||
998 | @@ -2041,6 +2041,9 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK, | ||
999 | Opts.ZVector = 0; | ||
1000 | Opts.setDefaultFPContractMode(LangOptions::FPM_On); | ||
1001 | Opts.OpenCLCPlusPlus = Opts.CPlusPlus; | ||
1002 | + Opts.OpenCLPipe = Opts.OpenCLCPlusPlus || Opts.OpenCLVersion == 200; | ||
1003 | + Opts.OpenCLGenericAddressSpace = | ||
1004 | + Opts.OpenCLCPlusPlus || Opts.OpenCLVersion == 200; | ||
1005 | |||
1006 | // Include default header file for OpenCL. | ||
1007 | if (Opts.IncludeDefaultHeader) { | ||
1008 | diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp | ||
1009 | index c60972c96e5d..faa02c608540 100644 | ||
1010 | --- a/clang/lib/Frontend/InitPreprocessor.cpp | ||
1011 | +++ b/clang/lib/Frontend/InitPreprocessor.cpp | ||
1012 | @@ -598,6 +598,29 @@ static void InitializeCPlusPlusFeatureTestMacros(const LangOptions &LangOpts, | ||
1013 | Builder.defineMacro("__cpp_coroutines", "201703L"); | ||
1014 | } | ||
1015 | |||
1016 | +/// InitializeOpenCLFeatureTestMacros - Define OpenCL macros based on target | ||
1017 | +/// settings and language version | ||
1018 | +void InitializeOpenCLFeatureTestMacros(const TargetInfo &TI, | ||
1019 | + const LangOptions &Opts, | ||
1020 | + MacroBuilder &Builder) { | ||
1021 | + const llvm::StringMap<bool> &OpenCLFeaturesMap = TI.getSupportedOpenCLOpts(); | ||
1022 | + // FIXME: OpenCL options which affect language semantics/syntax | ||
1023 | + // should be moved into LangOptions. | ||
1024 | + auto defineOpenCLExtMacro = [&](llvm::StringRef Name, auto... OptArgs) { | ||
1025 | + // Check if extension is supported by target and is available in this | ||
1026 | + // OpenCL version | ||
1027 | + if (TI.hasFeatureEnabled(OpenCLFeaturesMap, Name) && | ||
1028 | + OpenCLOptions::isOpenCLOptionAvailableIn(Opts, OptArgs...)) | ||
1029 | + Builder.defineMacro(Name); | ||
1030 | + }; | ||
1031 | +#define OPENCL_GENERIC_EXTENSION(Ext, ...) \ | ||
1032 | + defineOpenCLExtMacro(#Ext, __VA_ARGS__); | ||
1033 | +#include "clang/Basic/OpenCLExtensions.def" | ||
1034 | + | ||
1035 | + // Assume compiling for FULL profile | ||
1036 | + Builder.defineMacro("__opencl_c_int64"); | ||
1037 | +} | ||
1038 | + | ||
1039 | static void InitializePredefinedMacros(const TargetInfo &TI, | ||
1040 | const LangOptions &LangOpts, | ||
1041 | const FrontendOptions &FEOpts, | ||
1042 | @@ -1120,7 +1143,7 @@ static void InitializePredefinedMacros(const TargetInfo &TI, | ||
1043 | |||
1044 | // OpenCL definitions. | ||
1045 | if (LangOpts.OpenCL) { | ||
1046 | - TI.getOpenCLFeatureDefines(LangOpts, Builder); | ||
1047 | + InitializeOpenCLFeatureTestMacros(TI, LangOpts, Builder); | ||
1048 | } | ||
1049 | |||
1050 | if (TI.hasInt128Type() && LangOpts.CPlusPlus && LangOpts.GNUMode) { | ||
1051 | diff --git a/clang/lib/Headers/opencl-c-base.h b/clang/lib/Headers/opencl-c-base.h | ||
1052 | index b55d9601a452..e8f293a0301b 100644 | ||
1053 | --- a/clang/lib/Headers/opencl-c-base.h | ||
1054 | +++ b/clang/lib/Headers/opencl-c-base.h | ||
1055 | @@ -46,6 +46,21 @@ | ||
1056 | #endif // defined(__SPIR__) | ||
1057 | #endif // (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) | ||
1058 | |||
1059 | +// Define feature macros for OpenCL C 2.0 | ||
1060 | +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ == 200) | ||
1061 | +#define __opencl_c_pipes 1 | ||
1062 | +#define __opencl_c_generic_address_space 1 | ||
1063 | +#define __opencl_c_work_group_collective_functions 1 | ||
1064 | +#define __opencl_c_atomic_order_acq_rel 1 | ||
1065 | +#define __opencl_c_atomic_order_seq_cst 1 | ||
1066 | +#define __opencl_c_atomic_scope_device 1 | ||
1067 | +#define __opencl_c_atomic_scope_all_devices 1 | ||
1068 | +#define __opencl_c_device_enqueue 1 | ||
1069 | +#define __opencl_c_read_write_images 1 | ||
1070 | +#define __opencl_c_program_scope_global_variables 1 | ||
1071 | +#define __opencl_c_images 1 | ||
1072 | +#endif | ||
1073 | + | ||
1074 | // built-in scalar data types: | ||
1075 | |||
1076 | /** | ||
1077 | diff --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h | ||
1078 | index 80d318b16f57..62ff0aab1d40 100644 | ||
1079 | --- a/clang/lib/Headers/opencl-c.h | ||
1080 | +++ b/clang/lib/Headers/opencl-c.h | ||
1081 | @@ -11,11 +11,11 @@ | ||
1082 | |||
1083 | #include "opencl-c-base.h" | ||
1084 | |||
1085 | -#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1086 | +#if defined(__opencl_c_images) | ||
1087 | #ifndef cl_khr_depth_images | ||
1088 | #define cl_khr_depth_images | ||
1089 | #endif //cl_khr_depth_images | ||
1090 | -#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1091 | +#endif //defined(__opencl_c_images) | ||
1092 | |||
1093 | #if __OPENCL_C_VERSION__ < CL_VERSION_2_0 | ||
1094 | #ifdef cl_khr_3d_image_writes | ||
1095 | @@ -7354,7 +7354,7 @@ half16 __ovld __cnfn fmod(half16 x, half16 y); | ||
1096 | * Returns fmin(x - floor (x), 0x1.fffffep-1f ). | ||
1097 | * floor(x) is returned in iptr. | ||
1098 | */ | ||
1099 | -#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1100 | +#if defined(__opencl_c_generic_address_space) | ||
1101 | float __ovld fract(float x, float *iptr); | ||
1102 | float2 __ovld fract(float2 x, float2 *iptr); | ||
1103 | float3 __ovld fract(float3 x, float3 *iptr); | ||
1104 | @@ -7444,7 +7444,7 @@ half16 __ovld fract(half16 x, __private half16 *iptr); | ||
1105 | * magnitude in the interval [1/2, 1) or 0. Each | ||
1106 | * component of x equals mantissa returned * 2^exp. | ||
1107 | */ | ||
1108 | -#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1109 | +#if defined(__opencl_c_generic_address_space) | ||
1110 | float __ovld frexp(float x, int *exp); | ||
1111 | float2 __ovld frexp(float2 x, int2 *exp); | ||
1112 | float3 __ovld frexp(float3 x, int3 *exp); | ||
1113 | @@ -7651,7 +7651,7 @@ half8 __ovld __cnfn lgamma(half8 x); | ||
1114 | half16 __ovld __cnfn lgamma(half16 x); | ||
1115 | #endif //cl_khr_fp16 | ||
1116 | |||
1117 | -#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1118 | +#if defined(__opencl_c_generic_address_space) | ||
1119 | float __ovld lgamma_r(float x, int *signp); | ||
1120 | float2 __ovld lgamma_r(float2 x, int2 *signp); | ||
1121 | float3 __ovld lgamma_r(float3 x, int3 *signp); | ||
1122 | @@ -7957,7 +7957,7 @@ half16 __ovld __cnfn minmag(half16 x, half16 y); | ||
1123 | * the argument. It stores the integral part in the object | ||
1124 | * pointed to by iptr. | ||
1125 | */ | ||
1126 | -#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1127 | +#if defined(__opencl_c_generic_address_space) | ||
1128 | float __ovld modf(float x, float *iptr); | ||
1129 | float2 __ovld modf(float2 x, float2 *iptr); | ||
1130 | float3 __ovld modf(float3 x, float3 *iptr); | ||
1131 | @@ -8217,7 +8217,7 @@ half16 __ovld __cnfn remainder(half16 x, half16 y); | ||
1132 | * sign as x/y. It stores this signed value in the object | ||
1133 | * pointed to by quo. | ||
1134 | */ | ||
1135 | -#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1136 | +#if defined(__opencl_c_generic_address_space) | ||
1137 | float __ovld remquo(float x, float y, int *quo); | ||
1138 | float2 __ovld remquo(float2 x, float2 y, int2 *quo); | ||
1139 | float3 __ovld remquo(float3 x, float3 y, int3 *quo); | ||
1140 | @@ -8441,7 +8441,7 @@ half16 __ovld __cnfn sin(half16); | ||
1141 | * is the return value and computed cosine is returned | ||
1142 | * in cosval. | ||
1143 | */ | ||
1144 | -#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1145 | +#if defined(__opencl_c_generic_address_space) | ||
1146 | float __ovld sincos(float x, float *cosval); | ||
1147 | float2 __ovld sincos(float2 x, float2 *cosval); | ||
1148 | float3 __ovld sincos(float3 x, float3 *cosval); | ||
1149 | @@ -11342,7 +11342,7 @@ half8 __ovld vload8(size_t offset, const __constant half *p); | ||
1150 | half16 __ovld vload16(size_t offset, const __constant half *p); | ||
1151 | #endif //cl_khr_fp16 | ||
1152 | |||
1153 | -#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1154 | +#if defined(__opencl_c_generic_address_space) | ||
1155 | char2 __ovld vload2(size_t offset, const char *p); | ||
1156 | uchar2 __ovld vload2(size_t offset, const uchar *p); | ||
1157 | short2 __ovld vload2(size_t offset, const short *p); | ||
1158 | @@ -11582,7 +11582,7 @@ half16 __ovld vload16(size_t offset, const __private half *p); | ||
1159 | #endif //cl_khr_fp16 | ||
1160 | #endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1161 | |||
1162 | -#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1163 | +#if defined(__opencl_c_generic_address_space) | ||
1164 | void __ovld vstore2(char2 data, size_t offset, char *p); | ||
1165 | void __ovld vstore2(uchar2 data, size_t offset, uchar *p); | ||
1166 | void __ovld vstore2(short2 data, size_t offset, short *p); | ||
1167 | @@ -11827,7 +11827,7 @@ void __ovld vstore16(half16 data, size_t offset, __private half *p); | ||
1168 | * must be 16-bit aligned. | ||
1169 | */ | ||
1170 | float __ovld vload_half(size_t offset, const __constant half *p); | ||
1171 | -#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1172 | +#if defined(__opencl_c_generic_address_space) | ||
1173 | float __ovld vload_half(size_t offset, const half *p); | ||
1174 | #else | ||
1175 | float __ovld vload_half(size_t offset, const __global half *p); | ||
1176 | @@ -11848,7 +11848,7 @@ float3 __ovld vload_half3(size_t offset, const __constant half *p); | ||
1177 | float4 __ovld vload_half4(size_t offset, const __constant half *p); | ||
1178 | float8 __ovld vload_half8(size_t offset, const __constant half *p); | ||
1179 | float16 __ovld vload_half16(size_t offset, const __constant half *p); | ||
1180 | -#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1181 | +#if defined(__opencl_c_generic_address_space) | ||
1182 | float2 __ovld vload_half2(size_t offset, const half *p); | ||
1183 | float3 __ovld vload_half3(size_t offset, const half *p); | ||
1184 | float4 __ovld vload_half4(size_t offset, const half *p); | ||
1185 | @@ -11883,7 +11883,7 @@ float16 __ovld vload_half16(size_t offset, const __private half *p); | ||
1186 | * The default current rounding mode is round to | ||
1187 | * nearest even. | ||
1188 | */ | ||
1189 | -#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1190 | +#if defined(__opencl_c_generic_address_space) | ||
1191 | void __ovld vstore_half(float data, size_t offset, half *p); | ||
1192 | void __ovld vstore_half_rte(float data, size_t offset, half *p); | ||
1193 | void __ovld vstore_half_rtz(float data, size_t offset, half *p); | ||
1194 | @@ -11942,7 +11942,7 @@ void __ovld vstore_half_rtn(double data, size_t offset, __private half *p); | ||
1195 | * The default current rounding mode is round to | ||
1196 | * nearest even. | ||
1197 | */ | ||
1198 | -#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1199 | +#if defined(__opencl_c_generic_address_space) | ||
1200 | void __ovld vstore_half2(float2 data, size_t offset, half *p); | ||
1201 | void __ovld vstore_half3(float3 data, size_t offset, half *p); | ||
1202 | void __ovld vstore_half4(float4 data, size_t offset, half *p); | ||
1203 | @@ -12169,7 +12169,7 @@ float3 __ovld vloada_half3(size_t offset, const __constant half *p); | ||
1204 | float4 __ovld vloada_half4(size_t offset, const __constant half *p); | ||
1205 | float8 __ovld vloada_half8(size_t offset, const __constant half *p); | ||
1206 | float16 __ovld vloada_half16(size_t offset, const __constant half *p); | ||
1207 | -#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1208 | +#if defined(__opencl_c_generic_address_space) | ||
1209 | float __ovld vloada_half(size_t offset, const half *p); | ||
1210 | float2 __ovld vloada_half2(size_t offset, const half *p); | ||
1211 | float3 __ovld vloada_half3(size_t offset, const half *p); | ||
1212 | @@ -12213,7 +12213,7 @@ float16 __ovld vloada_half16(size_t offset, const __private half *p); | ||
1213 | * mode. The default current rounding mode is | ||
1214 | * round to nearest even. | ||
1215 | */ | ||
1216 | -#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1217 | +#if defined(__opencl_c_generic_address_space) | ||
1218 | void __ovld vstorea_half(float data, size_t offset, half *p); | ||
1219 | void __ovld vstorea_half2(float2 data, size_t offset, half *p); | ||
1220 | void __ovld vstorea_half3(float3 data, size_t offset, half *p); | ||
1221 | @@ -12582,7 +12582,7 @@ void __ovld write_mem_fence(cl_mem_fence_flags flags); | ||
1222 | |||
1223 | // OpenCL v2.0 s6.13.9 - Address Space Qualifier Functions | ||
1224 | |||
1225 | -#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1226 | +#if defined(__opencl_c_generic_address_space) | ||
1227 | cl_mem_fence_flags __ovld get_fence(const void *ptr); | ||
1228 | cl_mem_fence_flags __ovld get_fence(void *ptr); | ||
1229 | |||
1230 | @@ -13397,138 +13397,113 @@ void __ovld atomic_init(volatile atomic_double *object, double value); | ||
1231 | void __ovld atomic_work_item_fence(cl_mem_fence_flags flags, memory_order order, memory_scope scope); | ||
1232 | |||
1233 | // atomic_fetch() | ||
1234 | +// OpenCL v2.0 s6.13.11.7.5: | ||
1235 | +// add/sub: atomic type argument can be uintptr_t/intptr_t, value type argument can be ptrdiff_t. | ||
1236 | |||
1237 | +#if defined(__opencl_c_atomic_order_seq_cst) && defined(__opencl_c_atomic_scope_device) | ||
1238 | int __ovld atomic_fetch_add(volatile atomic_int *object, int operand); | ||
1239 | -int __ovld atomic_fetch_add_explicit(volatile atomic_int *object, int operand, memory_order order); | ||
1240 | -int __ovld atomic_fetch_add_explicit(volatile atomic_int *object, int operand, memory_order order, memory_scope scope); | ||
1241 | uint __ovld atomic_fetch_add(volatile atomic_uint *object, uint operand); | ||
1242 | -uint __ovld atomic_fetch_add_explicit(volatile atomic_uint *object, uint operand, memory_order order); | ||
1243 | -uint __ovld atomic_fetch_add_explicit(volatile atomic_uint *object, uint operand, memory_order order, memory_scope scope); | ||
1244 | int __ovld atomic_fetch_sub(volatile atomic_int *object, int operand); | ||
1245 | -int __ovld atomic_fetch_sub_explicit(volatile atomic_int *object, int operand, memory_order order); | ||
1246 | -int __ovld atomic_fetch_sub_explicit(volatile atomic_int *object, int operand, memory_order order, memory_scope scope); | ||
1247 | uint __ovld atomic_fetch_sub(volatile atomic_uint *object, uint operand); | ||
1248 | -uint __ovld atomic_fetch_sub_explicit(volatile atomic_uint *object, uint operand, memory_order order); | ||
1249 | -uint __ovld atomic_fetch_sub_explicit(volatile atomic_uint *object, uint operand, memory_order order, memory_scope scope); | ||
1250 | int __ovld atomic_fetch_or(volatile atomic_int *object, int operand); | ||
1251 | -int __ovld atomic_fetch_or_explicit(volatile atomic_int *object, int operand, memory_order order); | ||
1252 | -int __ovld atomic_fetch_or_explicit(volatile atomic_int *object, int operand, memory_order order, memory_scope scope); | ||
1253 | uint __ovld atomic_fetch_or(volatile atomic_uint *object, uint operand); | ||
1254 | -uint __ovld atomic_fetch_or_explicit(volatile atomic_uint *object, uint operand, memory_order order); | ||
1255 | -uint __ovld atomic_fetch_or_explicit(volatile atomic_uint *object, uint operand, memory_order order, memory_scope scope); | ||
1256 | int __ovld atomic_fetch_xor(volatile atomic_int *object, int operand); | ||
1257 | -int __ovld atomic_fetch_xor_explicit(volatile atomic_int *object, int operand, memory_order order); | ||
1258 | -int __ovld atomic_fetch_xor_explicit(volatile atomic_int *object, int operand, memory_order order, memory_scope scope); | ||
1259 | uint __ovld atomic_fetch_xor(volatile atomic_uint *object, uint operand); | ||
1260 | -uint __ovld atomic_fetch_xor_explicit(volatile atomic_uint *object, uint operand, memory_order order); | ||
1261 | -uint __ovld atomic_fetch_xor_explicit(volatile atomic_uint *object, uint operand, memory_order order, memory_scope scope); | ||
1262 | int __ovld atomic_fetch_and(volatile atomic_int *object, int operand); | ||
1263 | -int __ovld atomic_fetch_and_explicit(volatile atomic_int *object, int operand, memory_order order); | ||
1264 | -int __ovld atomic_fetch_and_explicit(volatile atomic_int *object, int operand, memory_order order, memory_scope scope); | ||
1265 | uint __ovld atomic_fetch_and(volatile atomic_uint *object, uint operand); | ||
1266 | -uint __ovld atomic_fetch_and_explicit(volatile atomic_uint *object, uint operand, memory_order order); | ||
1267 | -uint __ovld atomic_fetch_and_explicit(volatile atomic_uint *object, uint operand, memory_order order, memory_scope scope); | ||
1268 | int __ovld atomic_fetch_min(volatile atomic_int *object, int operand); | ||
1269 | -int __ovld atomic_fetch_min_explicit(volatile atomic_int *object, int operand, memory_order order); | ||
1270 | -int __ovld atomic_fetch_min_explicit(volatile atomic_int *object, int operand, memory_order order, memory_scope scope); | ||
1271 | uint __ovld atomic_fetch_min(volatile atomic_uint *object, uint operand); | ||
1272 | -uint __ovld atomic_fetch_min_explicit(volatile atomic_uint *object, uint operand, memory_order order); | ||
1273 | -uint __ovld atomic_fetch_min_explicit(volatile atomic_uint *object, uint operand, memory_order order, memory_scope scope); | ||
1274 | int __ovld atomic_fetch_max(volatile atomic_int *object, int operand); | ||
1275 | -int __ovld atomic_fetch_max_explicit(volatile atomic_int *object, int operand, memory_order order); | ||
1276 | -int __ovld atomic_fetch_max_explicit(volatile atomic_int *object, int operand, memory_order order, memory_scope scope); | ||
1277 | uint __ovld atomic_fetch_max(volatile atomic_uint *object, uint operand); | ||
1278 | -uint __ovld atomic_fetch_max_explicit(volatile atomic_uint *object, uint operand, memory_order order); | ||
1279 | -uint __ovld atomic_fetch_max_explicit(volatile atomic_uint *object, uint operand, memory_order order, memory_scope scope); | ||
1280 | |||
1281 | #if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) | ||
1282 | long __ovld atomic_fetch_add(volatile atomic_long *object, long operand); | ||
1283 | -long __ovld atomic_fetch_add_explicit(volatile atomic_long *object, long operand, memory_order order); | ||
1284 | -long __ovld atomic_fetch_add_explicit(volatile atomic_long *object, long operand, memory_order order, memory_scope scope); | ||
1285 | ulong __ovld atomic_fetch_add(volatile atomic_ulong *object, ulong operand); | ||
1286 | -ulong __ovld atomic_fetch_add_explicit(volatile atomic_ulong *object, ulong operand, memory_order order); | ||
1287 | -ulong __ovld atomic_fetch_add_explicit(volatile atomic_ulong *object, ulong operand, memory_order order, memory_scope scope); | ||
1288 | long __ovld atomic_fetch_sub(volatile atomic_long *object, long operand); | ||
1289 | -long __ovld atomic_fetch_sub_explicit(volatile atomic_long *object, long operand, memory_order order); | ||
1290 | -long __ovld atomic_fetch_sub_explicit(volatile atomic_long *object, long operand, memory_order order, memory_scope scope); | ||
1291 | ulong __ovld atomic_fetch_sub(volatile atomic_ulong *object, ulong operand); | ||
1292 | -ulong __ovld atomic_fetch_sub_explicit(volatile atomic_ulong *object, ulong operand, memory_order order); | ||
1293 | -ulong __ovld atomic_fetch_sub_explicit(volatile atomic_ulong *object, ulong operand, memory_order order, memory_scope scope); | ||
1294 | long __ovld atomic_fetch_or(volatile atomic_long *object, long operand); | ||
1295 | -long __ovld atomic_fetch_or_explicit(volatile atomic_long *object, long operand, memory_order order); | ||
1296 | -long __ovld atomic_fetch_or_explicit(volatile atomic_long *object, long operand, memory_order order, memory_scope scope); | ||
1297 | ulong __ovld atomic_fetch_or(volatile atomic_ulong *object, ulong operand); | ||
1298 | -ulong __ovld atomic_fetch_or_explicit(volatile atomic_ulong *object, ulong operand, memory_order order); | ||
1299 | -ulong __ovld atomic_fetch_or_explicit(volatile atomic_ulong *object, ulong operand, memory_order order, memory_scope scope); | ||
1300 | long __ovld atomic_fetch_xor(volatile atomic_long *object, long operand); | ||
1301 | -long __ovld atomic_fetch_xor_explicit(volatile atomic_long *object, long operand, memory_order order); | ||
1302 | -long __ovld atomic_fetch_xor_explicit(volatile atomic_long *object, long operand, memory_order order, memory_scope scope); | ||
1303 | ulong __ovld atomic_fetch_xor(volatile atomic_ulong *object, ulong operand); | ||
1304 | -ulong __ovld atomic_fetch_xor_explicit(volatile atomic_ulong *object, ulong operand, memory_order order); | ||
1305 | -ulong __ovld atomic_fetch_xor_explicit(volatile atomic_ulong *object, ulong operand, memory_order order, memory_scope scope); | ||
1306 | long __ovld atomic_fetch_and(volatile atomic_long *object, long operand); | ||
1307 | -long __ovld atomic_fetch_and_explicit(volatile atomic_long *object, long operand, memory_order order); | ||
1308 | -long __ovld atomic_fetch_and_explicit(volatile atomic_long *object, long operand, memory_order order, memory_scope scope); | ||
1309 | ulong __ovld atomic_fetch_and(volatile atomic_ulong *object, ulong operand); | ||
1310 | -ulong __ovld atomic_fetch_and_explicit(volatile atomic_ulong *object, ulong operand, memory_order order); | ||
1311 | -ulong __ovld atomic_fetch_and_explicit(volatile atomic_ulong *object, ulong operand, memory_order order, memory_scope scope); | ||
1312 | long __ovld atomic_fetch_min(volatile atomic_long *object, long operand); | ||
1313 | -long __ovld atomic_fetch_min_explicit(volatile atomic_long *object, long operand, memory_order order); | ||
1314 | -long __ovld atomic_fetch_min_explicit(volatile atomic_long *object, long operand, memory_order order, memory_scope scope); | ||
1315 | ulong __ovld atomic_fetch_min(volatile atomic_ulong *object, ulong operand); | ||
1316 | -ulong __ovld atomic_fetch_min_explicit(volatile atomic_ulong *object, ulong operand, memory_order order); | ||
1317 | -ulong __ovld atomic_fetch_min_explicit(volatile atomic_ulong *object, ulong operand, memory_order order, memory_scope scope); | ||
1318 | long __ovld atomic_fetch_max(volatile atomic_long *object, long operand); | ||
1319 | -long __ovld atomic_fetch_max_explicit(volatile atomic_long *object, long operand, memory_order order); | ||
1320 | -long __ovld atomic_fetch_max_explicit(volatile atomic_long *object, long operand, memory_order order, memory_scope scope); | ||
1321 | ulong __ovld atomic_fetch_max(volatile atomic_ulong *object, ulong operand); | ||
1322 | -ulong __ovld atomic_fetch_max_explicit(volatile atomic_ulong *object, ulong operand, memory_order order); | ||
1323 | -ulong __ovld atomic_fetch_max_explicit(volatile atomic_ulong *object, ulong operand, memory_order order, memory_scope scope); | ||
1324 | +uintptr_t __ovld atomic_fetch_add(volatile atomic_uintptr_t *object, ptrdiff_t operand); | ||
1325 | +uintptr_t __ovld atomic_fetch_sub(volatile atomic_uintptr_t *object, ptrdiff_t operand); | ||
1326 | #endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) | ||
1327 | +#endif | ||
1328 | |||
1329 | -// OpenCL v2.0 s6.13.11.7.5: | ||
1330 | -// add/sub: atomic type argument can be uintptr_t/intptr_t, value type argument can be ptrdiff_t. | ||
1331 | -// or/xor/and/min/max: atomic type argument can be intptr_t/uintptr_t, value type argument can be intptr_t/uintptr_t. | ||
1332 | - | ||
1333 | +#if defined(__opencl_c_atomic_scope_device) | ||
1334 | +int __ovld atomic_fetch_add_explicit(volatile atomic_int *object, int operand, memory_order order); | ||
1335 | +uint __ovld atomic_fetch_add_explicit(volatile atomic_uint *object, uint operand, memory_order order); | ||
1336 | +int __ovld atomic_fetch_sub_explicit(volatile atomic_int *object, int operand, memory_order order); | ||
1337 | +uint __ovld atomic_fetch_sub_explicit(volatile atomic_uint *object, uint operand, memory_order order); | ||
1338 | +int __ovld atomic_fetch_or_explicit(volatile atomic_int *object, int operand, memory_order order); | ||
1339 | +uint __ovld atomic_fetch_or_explicit(volatile atomic_uint *object, uint operand, memory_order order); | ||
1340 | +int __ovld atomic_fetch_xor_explicit(volatile atomic_int *object, int operand, memory_order order); | ||
1341 | +uint __ovld atomic_fetch_xor_explicit(volatile atomic_uint *object, uint operand, memory_order order); | ||
1342 | +int __ovld atomic_fetch_and_explicit(volatile atomic_int *object, int operand, memory_order order); | ||
1343 | +uint __ovld atomic_fetch_and_explicit(volatile atomic_uint *object, uint operand, memory_order order); | ||
1344 | +int __ovld atomic_fetch_min_explicit(volatile atomic_int *object, int operand, memory_order order); | ||
1345 | +uint __ovld atomic_fetch_min_explicit(volatile atomic_uint *object, uint operand, memory_order order); | ||
1346 | +int __ovld atomic_fetch_max_explicit(volatile atomic_int *object, int operand, memory_order order); | ||
1347 | +uint __ovld atomic_fetch_max_explicit(volatile atomic_uint *object, uint operand, memory_order order); | ||
1348 | #if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) | ||
1349 | -uintptr_t __ovld atomic_fetch_add(volatile atomic_uintptr_t *object, ptrdiff_t operand); | ||
1350 | +long __ovld atomic_fetch_add_explicit(volatile atomic_long *object, long operand, memory_order order); | ||
1351 | +ulong __ovld atomic_fetch_add_explicit(volatile atomic_ulong *object, ulong operand, memory_order order); | ||
1352 | +long __ovld atomic_fetch_sub_explicit(volatile atomic_long *object, long operand, memory_order order); | ||
1353 | +ulong __ovld atomic_fetch_sub_explicit(volatile atomic_ulong *object, ulong operand, memory_order order); | ||
1354 | +long __ovld atomic_fetch_or_explicit(volatile atomic_long *object, long operand, memory_order order); | ||
1355 | +ulong __ovld atomic_fetch_or_explicit(volatile atomic_ulong *object, ulong operand, memory_order order); | ||
1356 | +long __ovld atomic_fetch_xor_explicit(volatile atomic_long *object, long operand, memory_order order); | ||
1357 | +ulong __ovld atomic_fetch_xor_explicit(volatile atomic_ulong *object, ulong operand, memory_order order); | ||
1358 | +long __ovld atomic_fetch_and_explicit(volatile atomic_long *object, long operand, memory_order order); | ||
1359 | +ulong __ovld atomic_fetch_and_explicit(volatile atomic_ulong *object, ulong operand, memory_order order); | ||
1360 | +long __ovld atomic_fetch_min_explicit(volatile atomic_long *object, long operand, memory_order order); | ||
1361 | +ulong __ovld atomic_fetch_min_explicit(volatile atomic_ulong *object, ulong operand, memory_order order); | ||
1362 | +long __ovld atomic_fetch_max_explicit(volatile atomic_long *object, long operand, memory_order order); | ||
1363 | +ulong __ovld atomic_fetch_max_explicit(volatile atomic_ulong *object, ulong operand, memory_order order); | ||
1364 | uintptr_t __ovld atomic_fetch_add_explicit(volatile atomic_uintptr_t *object, ptrdiff_t operand, memory_order order); | ||
1365 | -uintptr_t __ovld atomic_fetch_add_explicit(volatile atomic_uintptr_t *object, ptrdiff_t operand, memory_order order, memory_scope scope); | ||
1366 | -uintptr_t __ovld atomic_fetch_sub(volatile atomic_uintptr_t *object, ptrdiff_t operand); | ||
1367 | uintptr_t __ovld atomic_fetch_sub_explicit(volatile atomic_uintptr_t *object, ptrdiff_t operand, memory_order order); | ||
1368 | -uintptr_t __ovld atomic_fetch_sub_explicit(volatile atomic_uintptr_t *object, ptrdiff_t operand, memory_order order, memory_scope scope); | ||
1369 | +#endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) | ||
1370 | +#endif | ||
1371 | |||
1372 | -uintptr_t __ovld atomic_fetch_or(volatile atomic_uintptr_t *object, intptr_t operand); | ||
1373 | -uintptr_t __ovld atomic_fetch_or_explicit(volatile atomic_uintptr_t *object, intptr_t operand, memory_order order); | ||
1374 | -uintptr_t __ovld atomic_fetch_or_explicit(volatile atomic_uintptr_t *object, intptr_t operand, memory_order order, memory_scope scope); | ||
1375 | -uintptr_t __ovld atomic_fetch_xor(volatile atomic_uintptr_t *object, intptr_t operand); | ||
1376 | -uintptr_t __ovld atomic_fetch_xor_explicit(volatile atomic_uintptr_t *object, intptr_t operand, memory_order order); | ||
1377 | -uintptr_t __ovld atomic_fetch_xor_explicit(volatile atomic_uintptr_t *object, intptr_t operand, memory_order order, memory_scope scope); | ||
1378 | -uintptr_t __ovld atomic_fetch_and(volatile atomic_uintptr_t *object, intptr_t operand); | ||
1379 | -uintptr_t __ovld atomic_fetch_and_explicit(volatile atomic_uintptr_t *object, intptr_t operand, memory_order order); | ||
1380 | -uintptr_t __ovld atomic_fetch_and_explicit(volatile atomic_uintptr_t *object, intptr_t operand, memory_order order, memory_scope scope); | ||
1381 | -uintptr_t __ovld atomic_fetch_min(volatile atomic_uintptr_t *object, intptr_t opermax); | ||
1382 | -uintptr_t __ovld atomic_fetch_min_explicit(volatile atomic_uintptr_t *object, intptr_t opermax, memory_order minder); | ||
1383 | -uintptr_t __ovld atomic_fetch_min_explicit(volatile atomic_uintptr_t *object, intptr_t opermax, memory_order minder, memory_scope scope); | ||
1384 | -uintptr_t __ovld atomic_fetch_max(volatile atomic_uintptr_t *object, intptr_t opermax); | ||
1385 | -uintptr_t __ovld atomic_fetch_max_explicit(volatile atomic_uintptr_t *object, intptr_t opermax, memory_order minder); | ||
1386 | -uintptr_t __ovld atomic_fetch_max_explicit(volatile atomic_uintptr_t *object, intptr_t opermax, memory_order minder, memory_scope scope); | ||
1387 | - | ||
1388 | -intptr_t __ovld atomic_fetch_or(volatile atomic_intptr_t *object, uintptr_t operand); | ||
1389 | -intptr_t __ovld atomic_fetch_or_explicit(volatile atomic_intptr_t *object, uintptr_t operand, memory_order order); | ||
1390 | -intptr_t __ovld atomic_fetch_or_explicit(volatile atomic_intptr_t *object, uintptr_t operand, memory_order order, memory_scope scope); | ||
1391 | -intptr_t __ovld atomic_fetch_xor(volatile atomic_intptr_t *object, uintptr_t operand); | ||
1392 | -intptr_t __ovld atomic_fetch_xor_explicit(volatile atomic_intptr_t *object, uintptr_t operand, memory_order order); | ||
1393 | -intptr_t __ovld atomic_fetch_xor_explicit(volatile atomic_intptr_t *object, uintptr_t operand, memory_order order, memory_scope scope); | ||
1394 | -intptr_t __ovld atomic_fetch_and(volatile atomic_intptr_t *object, uintptr_t operand); | ||
1395 | -intptr_t __ovld atomic_fetch_and_explicit(volatile atomic_intptr_t *object, uintptr_t operand, memory_order order); | ||
1396 | -intptr_t __ovld atomic_fetch_and_explicit(volatile atomic_intptr_t *object, uintptr_t operand, memory_order order, memory_scope scope); | ||
1397 | -intptr_t __ovld atomic_fetch_min(volatile atomic_intptr_t *object, uintptr_t opermax); | ||
1398 | -intptr_t __ovld atomic_fetch_min_explicit(volatile atomic_intptr_t *object, uintptr_t opermax, memory_order minder); | ||
1399 | -intptr_t __ovld atomic_fetch_min_explicit(volatile atomic_intptr_t *object, uintptr_t opermax, memory_order minder, memory_scope scope); | ||
1400 | -intptr_t __ovld atomic_fetch_max(volatile atomic_intptr_t *object, uintptr_t opermax); | ||
1401 | -intptr_t __ovld atomic_fetch_max_explicit(volatile atomic_intptr_t *object, uintptr_t opermax, memory_order minder); | ||
1402 | -intptr_t __ovld atomic_fetch_max_explicit(volatile atomic_intptr_t *object, uintptr_t opermax, memory_order minder, memory_scope scope); | ||
1403 | +int __ovld atomic_fetch_add_explicit(volatile atomic_int *object, int operand, memory_order order, memory_scope scope); | ||
1404 | +uint __ovld atomic_fetch_add_explicit(volatile atomic_uint *object, uint operand, memory_order order, memory_scope scope); | ||
1405 | +int __ovld atomic_fetch_sub_explicit(volatile atomic_int *object, int operand, memory_order order, memory_scope scope); | ||
1406 | +uint __ovld atomic_fetch_sub_explicit(volatile atomic_uint *object, uint operand, memory_order order, memory_scope scope); | ||
1407 | +int __ovld atomic_fetch_or_explicit(volatile atomic_int *object, int operand, memory_order order, memory_scope scope); | ||
1408 | +uint __ovld atomic_fetch_or_explicit(volatile atomic_uint *object, uint operand, memory_order order, memory_scope scope); | ||
1409 | +int __ovld atomic_fetch_xor_explicit(volatile atomic_int *object, int operand, memory_order order, memory_scope scope); | ||
1410 | +uint __ovld atomic_fetch_xor_explicit(volatile atomic_uint *object, uint operand, memory_order order, memory_scope scope); | ||
1411 | +int __ovld atomic_fetch_and_explicit(volatile atomic_int *object, int operand, memory_order order, memory_scope scope); | ||
1412 | +uint __ovld atomic_fetch_and_explicit(volatile atomic_uint *object, uint operand, memory_order order, memory_scope scope); | ||
1413 | +int __ovld atomic_fetch_min_explicit(volatile atomic_int *object, int operand, memory_order order, memory_scope scope); | ||
1414 | +uint __ovld atomic_fetch_min_explicit(volatile atomic_uint *object, uint operand, memory_order order, memory_scope scope); | ||
1415 | +int __ovld atomic_fetch_max_explicit(volatile atomic_int *object, int operand, memory_order order, memory_scope scope); | ||
1416 | +uint __ovld atomic_fetch_max_explicit(volatile atomic_uint *object, uint operand, memory_order order, memory_scope scope); | ||
1417 | +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) | ||
1418 | +long __ovld atomic_fetch_add_explicit(volatile atomic_long *object, long operand, memory_order order, memory_scope scope); | ||
1419 | +ulong __ovld atomic_fetch_add_explicit(volatile atomic_ulong *object, ulong operand, memory_order order, memory_scope scope); | ||
1420 | +long __ovld atomic_fetch_sub_explicit(volatile atomic_long *object, long operand, memory_order order, memory_scope scope); | ||
1421 | +ulong __ovld atomic_fetch_sub_explicit(volatile atomic_ulong *object, ulong operand, memory_order order, memory_scope scope); | ||
1422 | +long __ovld atomic_fetch_or_explicit(volatile atomic_long *object, long operand, memory_order order, memory_scope scope); | ||
1423 | +ulong __ovld atomic_fetch_or_explicit(volatile atomic_ulong *object, ulong operand, memory_order order, memory_scope scope); | ||
1424 | +long __ovld atomic_fetch_xor_explicit(volatile atomic_long *object, long operand, memory_order order, memory_scope scope); | ||
1425 | +ulong __ovld atomic_fetch_xor_explicit(volatile atomic_ulong *object, ulong operand, memory_order order, memory_scope scope); | ||
1426 | +long __ovld atomic_fetch_and_explicit(volatile atomic_long *object, long operand, memory_order order, memory_scope scope); | ||
1427 | +ulong __ovld atomic_fetch_and_explicit(volatile atomic_ulong *object, ulong operand, memory_order order, memory_scope scope); | ||
1428 | +long __ovld atomic_fetch_min_explicit(volatile atomic_long *object, long operand, memory_order order, memory_scope scope); | ||
1429 | +ulong __ovld atomic_fetch_min_explicit(volatile atomic_ulong *object, ulong operand, memory_order order, memory_scope scope); | ||
1430 | +long __ovld atomic_fetch_max_explicit(volatile atomic_long *object, long operand, memory_order order, memory_scope scope); | ||
1431 | +ulong __ovld atomic_fetch_max_explicit(volatile atomic_ulong *object, ulong operand, memory_order order, memory_scope scope); | ||
1432 | +#endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) | ||
1433 | +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) | ||
1434 | +uintptr_t __ovld atomic_fetch_add_explicit(volatile atomic_uintptr_t *object, ptrdiff_t operand, memory_order order, memory_scope scope); | ||
1435 | +uintptr_t __ovld atomic_fetch_sub_explicit(volatile atomic_uintptr_t *object, ptrdiff_t operand, memory_order order, memory_scope scope); | ||
1436 | #endif | ||
1437 | |||
1438 | // The functionality added by cl_ext_float_atomics extension | ||
1439 | @@ -13911,155 +13886,213 @@ double __ovld atomic_fetch_sub_explicit(volatile atomic_double *object, | ||
1440 | |||
1441 | // atomic_store() | ||
1442 | |||
1443 | +#if defined(__opencl_c_atomic_order_seq_cst) && defined(__opencl_c_atomic_scope_device) | ||
1444 | void __ovld atomic_store(volatile atomic_int *object, int desired); | ||
1445 | -void __ovld atomic_store_explicit(volatile atomic_int *object, int desired, memory_order order); | ||
1446 | -void __ovld atomic_store_explicit(volatile atomic_int *object, int desired, memory_order order, memory_scope scope); | ||
1447 | void __ovld atomic_store(volatile atomic_uint *object, uint desired); | ||
1448 | -void __ovld atomic_store_explicit(volatile atomic_uint *object, uint desired, memory_order order); | ||
1449 | -void __ovld atomic_store_explicit(volatile atomic_uint *object, uint desired, memory_order order, memory_scope scope); | ||
1450 | void __ovld atomic_store(volatile atomic_float *object, float desired); | ||
1451 | -void __ovld atomic_store_explicit(volatile atomic_float *object, float desired, memory_order order); | ||
1452 | -void __ovld atomic_store_explicit(volatile atomic_float *object, float desired, memory_order order, memory_scope scope); | ||
1453 | + | ||
1454 | #if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) | ||
1455 | #ifdef cl_khr_fp64 | ||
1456 | void __ovld atomic_store(volatile atomic_double *object, double desired); | ||
1457 | -void __ovld atomic_store_explicit(volatile atomic_double *object, double desired, memory_order order); | ||
1458 | -void __ovld atomic_store_explicit(volatile atomic_double *object, double desired, memory_order order, memory_scope scope); | ||
1459 | #endif //cl_khr_fp64 | ||
1460 | void __ovld atomic_store(volatile atomic_long *object, long desired); | ||
1461 | -void __ovld atomic_store_explicit(volatile atomic_long *object, long desired, memory_order order); | ||
1462 | -void __ovld atomic_store_explicit(volatile atomic_long *object, long desired, memory_order order, memory_scope scope); | ||
1463 | void __ovld atomic_store(volatile atomic_ulong *object, ulong desired); | ||
1464 | +#endif | ||
1465 | +#endif | ||
1466 | + | ||
1467 | +#if defined(__opencl_c_atomic_scope_device) | ||
1468 | +void __ovld atomic_store_explicit(volatile atomic_int *object, int desired, memory_order order); | ||
1469 | +void __ovld atomic_store_explicit(volatile atomic_uint *object, uint desired, memory_order order); | ||
1470 | +void __ovld atomic_store_explicit(volatile atomic_float *object, float desired, memory_order order); | ||
1471 | +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) | ||
1472 | +#ifdef cl_khr_fp64 | ||
1473 | +void __ovld atomic_store_explicit(volatile atomic_double *object, double desired, memory_order order); | ||
1474 | +#endif //cl_khr_fp64 | ||
1475 | +void __ovld atomic_store_explicit(volatile atomic_long *object, long desired, memory_order order); | ||
1476 | void __ovld atomic_store_explicit(volatile atomic_ulong *object, ulong desired, memory_order order); | ||
1477 | +#endif | ||
1478 | +#endif | ||
1479 | + | ||
1480 | +void __ovld atomic_store_explicit(volatile atomic_int *object, int desired, memory_order order, memory_scope scope); | ||
1481 | +void __ovld atomic_store_explicit(volatile atomic_uint *object, uint desired, memory_order order, memory_scope scope); | ||
1482 | +void __ovld atomic_store_explicit(volatile atomic_float *object, float desired, memory_order order, memory_scope scope); | ||
1483 | +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) | ||
1484 | +#ifdef cl_khr_fp64 | ||
1485 | +void __ovld atomic_store_explicit(volatile atomic_double *object, double desired, memory_order order, memory_scope scope); | ||
1486 | +#endif //cl_khr_fp64 | ||
1487 | +void __ovld atomic_store_explicit(volatile atomic_long *object, long desired, memory_order order, memory_scope scope); | ||
1488 | void __ovld atomic_store_explicit(volatile atomic_ulong *object, ulong desired, memory_order order, memory_scope scope); | ||
1489 | #endif | ||
1490 | |||
1491 | // atomic_load() | ||
1492 | - | ||
1493 | +#if defined(__opencl_c_atomic_order_seq_cst) && defined(__opencl_c_atomic_scope_device) | ||
1494 | int __ovld atomic_load(volatile atomic_int *object); | ||
1495 | -int __ovld atomic_load_explicit(volatile atomic_int *object, memory_order order); | ||
1496 | -int __ovld atomic_load_explicit(volatile atomic_int *object, memory_order order, memory_scope scope); | ||
1497 | uint __ovld atomic_load(volatile atomic_uint *object); | ||
1498 | -uint __ovld atomic_load_explicit(volatile atomic_uint *object, memory_order order); | ||
1499 | -uint __ovld atomic_load_explicit(volatile atomic_uint *object, memory_order order, memory_scope scope); | ||
1500 | float __ovld atomic_load(volatile atomic_float *object); | ||
1501 | -float __ovld atomic_load_explicit(volatile atomic_float *object, memory_order order); | ||
1502 | -float __ovld atomic_load_explicit(volatile atomic_float *object, memory_order order, memory_scope scope); | ||
1503 | #if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) | ||
1504 | #ifdef cl_khr_fp64 | ||
1505 | double __ovld atomic_load(volatile atomic_double *object); | ||
1506 | -double __ovld atomic_load_explicit(volatile atomic_double *object, memory_order order); | ||
1507 | -double __ovld atomic_load_explicit(volatile atomic_double *object, memory_order order, memory_scope scope); | ||
1508 | #endif //cl_khr_fp64 | ||
1509 | long __ovld atomic_load(volatile atomic_long *object); | ||
1510 | -long __ovld atomic_load_explicit(volatile atomic_long *object, memory_order order); | ||
1511 | -long __ovld atomic_load_explicit(volatile atomic_long *object, memory_order order, memory_scope scope); | ||
1512 | ulong __ovld atomic_load(volatile atomic_ulong *object); | ||
1513 | +#endif | ||
1514 | +#endif | ||
1515 | + | ||
1516 | +#if defined(__opencl_c_atomic_scope_device) | ||
1517 | +int __ovld atomic_load_explicit(volatile atomic_int *object, memory_order order); | ||
1518 | +uint __ovld atomic_load_explicit(volatile atomic_uint *object, memory_order order); | ||
1519 | +float __ovld atomic_load_explicit(volatile atomic_float *object, memory_order order); | ||
1520 | +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) | ||
1521 | +#ifdef cl_khr_fp64 | ||
1522 | +double __ovld atomic_load_explicit(volatile atomic_double *object, memory_order order); | ||
1523 | +#endif //cl_khr_fp64 | ||
1524 | +long __ovld atomic_load_explicit(volatile atomic_long *object, memory_order order); | ||
1525 | ulong __ovld atomic_load_explicit(volatile atomic_ulong *object, memory_order order); | ||
1526 | +#endif | ||
1527 | +#endif | ||
1528 | + | ||
1529 | +int __ovld atomic_load_explicit(volatile atomic_int *object, memory_order order, memory_scope scope); | ||
1530 | +uint __ovld atomic_load_explicit(volatile atomic_uint *object, memory_order order, memory_scope scope); | ||
1531 | +float __ovld atomic_load_explicit(volatile atomic_float *object, memory_order order, memory_scope scope); | ||
1532 | +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) | ||
1533 | +#ifdef cl_khr_fp64 | ||
1534 | +double __ovld atomic_load_explicit(volatile atomic_double *object, memory_order order, memory_scope scope); | ||
1535 | +#endif //cl_khr_fp64 | ||
1536 | +long __ovld atomic_load_explicit(volatile atomic_long *object, memory_order order, memory_scope scope); | ||
1537 | ulong __ovld atomic_load_explicit(volatile atomic_ulong *object, memory_order order, memory_scope scope); | ||
1538 | #endif | ||
1539 | |||
1540 | // atomic_exchange() | ||
1541 | |||
1542 | +#if defined(__opencl_c_atomic_order_seq_cst) && defined(__opencl_c_atomic_scope_device) | ||
1543 | int __ovld atomic_exchange(volatile atomic_int *object, int desired); | ||
1544 | -int __ovld atomic_exchange_explicit(volatile atomic_int *object, int desired, memory_order order); | ||
1545 | -int __ovld atomic_exchange_explicit(volatile atomic_int *object, int desired, memory_order order, memory_scope scope); | ||
1546 | uint __ovld atomic_exchange(volatile atomic_uint *object, uint desired); | ||
1547 | -uint __ovld atomic_exchange_explicit(volatile atomic_uint *object, uint desired, memory_order order); | ||
1548 | -uint __ovld atomic_exchange_explicit(volatile atomic_uint *object, uint desired, memory_order order, memory_scope scope); | ||
1549 | float __ovld atomic_exchange(volatile atomic_float *object, float desired); | ||
1550 | -float __ovld atomic_exchange_explicit(volatile atomic_float *object, float desired, memory_order order); | ||
1551 | -float __ovld atomic_exchange_explicit(volatile atomic_float *object, float desired, memory_order order, memory_scope scope); | ||
1552 | #if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) | ||
1553 | #ifdef cl_khr_fp64 | ||
1554 | double __ovld atomic_exchange(volatile atomic_double *object, double desired); | ||
1555 | -double __ovld atomic_exchange_explicit(volatile atomic_double *object, double desired, memory_order order); | ||
1556 | -double __ovld atomic_exchange_explicit(volatile atomic_double *object, double desired, memory_order order, memory_scope scope); | ||
1557 | #endif //cl_khr_fp64 | ||
1558 | long __ovld atomic_exchange(volatile atomic_long *object, long desired); | ||
1559 | -long __ovld atomic_exchange_explicit(volatile atomic_long *object, long desired, memory_order order); | ||
1560 | -long __ovld atomic_exchange_explicit(volatile atomic_long *object, long desired, memory_order order, memory_scope scope); | ||
1561 | ulong __ovld atomic_exchange(volatile atomic_ulong *object, ulong desired); | ||
1562 | +#endif | ||
1563 | +#endif | ||
1564 | + | ||
1565 | +#if defined(__opencl_c_atomic_scope_device) | ||
1566 | +int __ovld atomic_exchange_explicit(volatile atomic_int *object, int desired, memory_order order); | ||
1567 | +uint __ovld atomic_exchange_explicit(volatile atomic_uint *object, uint desired, memory_order order); | ||
1568 | +float __ovld atomic_exchange_explicit(volatile atomic_float *object, float desired, memory_order order); | ||
1569 | +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) | ||
1570 | +#ifdef cl_khr_fp64 | ||
1571 | +double __ovld atomic_exchange_explicit(volatile atomic_double *object, double desired, memory_order order); | ||
1572 | +#endif //cl_khr_fp64 | ||
1573 | +long __ovld atomic_exchange_explicit(volatile atomic_long *object, long desired, memory_order order); | ||
1574 | ulong __ovld atomic_exchange_explicit(volatile atomic_ulong *object, ulong desired, memory_order order); | ||
1575 | +#endif | ||
1576 | +#endif | ||
1577 | + | ||
1578 | +int __ovld atomic_exchange_explicit(volatile atomic_int *object, int desired, memory_order order, memory_scope scope); | ||
1579 | +uint __ovld atomic_exchange_explicit(volatile atomic_uint *object, uint desired, memory_order order, memory_scope scope); | ||
1580 | +float __ovld atomic_exchange_explicit(volatile atomic_float *object, float desired, memory_order order, memory_scope scope); | ||
1581 | +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) | ||
1582 | +#ifdef cl_khr_fp64 | ||
1583 | +double __ovld atomic_exchange_explicit(volatile atomic_double *object, double desired, memory_order order, memory_scope scope); | ||
1584 | +#endif //cl_khr_fp64 | ||
1585 | +long __ovld atomic_exchange_explicit(volatile atomic_long *object, long desired, memory_order order, memory_scope scope); | ||
1586 | ulong __ovld atomic_exchange_explicit(volatile atomic_ulong *object, ulong desired, memory_order order, memory_scope scope); | ||
1587 | #endif | ||
1588 | |||
1589 | // atomic_compare_exchange_strong() and atomic_compare_exchange_weak() | ||
1590 | - | ||
1591 | +#if defined(__opencl_c_atomic_order_seq_cst) && defined(__opencl_c_atomic_scope_device) | ||
1592 | bool __ovld atomic_compare_exchange_strong(volatile atomic_int *object, int *expected, int desired); | ||
1593 | +bool __ovld atomic_compare_exchange_strong(volatile atomic_uint *object, uint *expected, uint desired); | ||
1594 | +bool __ovld atomic_compare_exchange_weak(volatile atomic_int *object, int *expected, int desired); | ||
1595 | +bool __ovld atomic_compare_exchange_weak(volatile atomic_uint *object, uint *expected, uint desired); | ||
1596 | +bool __ovld atomic_compare_exchange_strong(volatile atomic_float *object, float *expected, float desired); | ||
1597 | +bool __ovld atomic_compare_exchange_weak(volatile atomic_float *object, float *expected, float desired); | ||
1598 | + | ||
1599 | +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) | ||
1600 | +#ifdef cl_khr_fp64 | ||
1601 | +bool __ovld atomic_compare_exchange_strong(volatile atomic_double *object, double *expected, double desired); | ||
1602 | +bool __ovld atomic_compare_exchange_weak(volatile atomic_double *object, double *expected, double desired); | ||
1603 | +#endif //cl_khr_fp64 | ||
1604 | +bool __ovld atomic_compare_exchange_strong(volatile atomic_long *object, long *expected, long desired); | ||
1605 | +bool __ovld atomic_compare_exchange_weak(volatile atomic_long *object, long *expected, long desired); | ||
1606 | +bool __ovld atomic_compare_exchange_strong(volatile atomic_ulong *object, ulong *expected, ulong desired); | ||
1607 | +bool __ovld atomic_compare_exchange_weak(volatile atomic_ulong *object, ulong *expected, ulong desired); | ||
1608 | +#endif | ||
1609 | +#endif | ||
1610 | + | ||
1611 | bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_int *object, int *expected, | ||
1612 | int desired, memory_order success, memory_order failure); | ||
1613 | -bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_int *object, int *expected, | ||
1614 | - int desired, memory_order success, memory_order failure, memory_scope scope); | ||
1615 | -bool __ovld atomic_compare_exchange_strong(volatile atomic_uint *object, uint *expected, uint desired); | ||
1616 | bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_uint *object, uint *expected, | ||
1617 | uint desired, memory_order success, memory_order failure); | ||
1618 | -bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_uint *object, uint *expected, | ||
1619 | - uint desired, memory_order success, memory_order failure, memory_scope scope); | ||
1620 | -bool __ovld atomic_compare_exchange_weak(volatile atomic_int *object, int *expected, int desired); | ||
1621 | bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_int *object, int *expected, | ||
1622 | int desired, memory_order success, memory_order failure); | ||
1623 | -bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_int *object, int *expected, | ||
1624 | - int desired, memory_order success, memory_order failure, memory_scope scope); | ||
1625 | -bool __ovld atomic_compare_exchange_weak(volatile atomic_uint *object, uint *expected, uint desired); | ||
1626 | bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_uint *object, uint *expected, | ||
1627 | uint desired, memory_order success, memory_order failure); | ||
1628 | -bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_uint *object, uint *expected, | ||
1629 | - uint desired, memory_order success, memory_order failure, memory_scope scope); | ||
1630 | -bool __ovld atomic_compare_exchange_strong(volatile atomic_float *object, float *expected, float desired); | ||
1631 | bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_float *object, float *expected, | ||
1632 | float desired, memory_order success, memory_order failure); | ||
1633 | -bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_float *object, float *expected, | ||
1634 | - float desired, memory_order success, memory_order failure, memory_scope scope); | ||
1635 | -bool __ovld atomic_compare_exchange_weak(volatile atomic_float *object, float *expected, float desired); | ||
1636 | bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_float *object, float *expected, | ||
1637 | float desired, memory_order success, memory_order failure); | ||
1638 | -bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_float *object, float *expected, | ||
1639 | - float desired, memory_order success, memory_order failure, memory_scope scope); | ||
1640 | #if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) | ||
1641 | #ifdef cl_khr_fp64 | ||
1642 | -bool __ovld atomic_compare_exchange_strong(volatile atomic_double *object, double *expected, double desired); | ||
1643 | bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_double *object, double *expected, | ||
1644 | double desired, memory_order success, memory_order failure); | ||
1645 | -bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_double *object, double *expected, | ||
1646 | - double desired, memory_order success, memory_order failure, memory_scope scope); | ||
1647 | -bool __ovld atomic_compare_exchange_weak(volatile atomic_double *object, double *expected, double desired); | ||
1648 | bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_double *object, double *expected, | ||
1649 | double desired, memory_order success, memory_order failure); | ||
1650 | -bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_double *object, double *expected, | ||
1651 | - double desired, memory_order success, memory_order failure, memory_scope scope); | ||
1652 | #endif //cl_khr_fp64 | ||
1653 | -bool __ovld atomic_compare_exchange_strong(volatile atomic_long *object, long *expected, long desired); | ||
1654 | bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_long *object, long *expected, | ||
1655 | long desired, memory_order success, memory_order failure); | ||
1656 | -bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_long *object, long *expected, | ||
1657 | - long desired, memory_order success, memory_order failure, memory_scope scope); | ||
1658 | -bool __ovld atomic_compare_exchange_weak(volatile atomic_long *object, long *expected, long desired); | ||
1659 | bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_long *object, long *expected, | ||
1660 | long desired, memory_order success, memory_order failure); | ||
1661 | -bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_long *object, long *expected, | ||
1662 | - long desired, memory_order success, memory_order failure, memory_scope scope); | ||
1663 | -bool __ovld atomic_compare_exchange_strong(volatile atomic_ulong *object, ulong *expected, ulong desired); | ||
1664 | bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_ulong *object, ulong *expected, | ||
1665 | ulong desired, memory_order success, memory_order failure); | ||
1666 | -bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_ulong *object, ulong *expected, | ||
1667 | - ulong desired, memory_order success, memory_order failure, memory_scope scope); | ||
1668 | -bool __ovld atomic_compare_exchange_weak(volatile atomic_ulong *object, ulong *expected, ulong desired); | ||
1669 | bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_ulong *object, ulong *expected, | ||
1670 | ulong desired, memory_order success, memory_order failure); | ||
1671 | +#endif | ||
1672 | + | ||
1673 | +bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_int *object, int *expected, | ||
1674 | + int desired, memory_order success, memory_order failure, memory_scope scope); | ||
1675 | +bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_uint *object, uint *expected, | ||
1676 | + uint desired, memory_order success, memory_order failure, memory_scope scope); | ||
1677 | +bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_int *object, int *expected, | ||
1678 | + int desired, memory_order success, memory_order failure, memory_scope scope); | ||
1679 | +bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_uint *object, uint *expected, | ||
1680 | + uint desired, memory_order success, memory_order failure, memory_scope scope); | ||
1681 | +bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_float *object, float *expected, | ||
1682 | + float desired, memory_order success, memory_order failure, memory_scope scope); | ||
1683 | +bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_float *object, float *expected, | ||
1684 | + float desired, memory_order success, memory_order failure, memory_scope scope); | ||
1685 | +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) | ||
1686 | +#ifdef cl_khr_fp64 | ||
1687 | +bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_double *object, double *expected, | ||
1688 | + double desired, memory_order success, memory_order failure, memory_scope scope); | ||
1689 | +bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_double *object, double *expected, | ||
1690 | + double desired, memory_order success, memory_order failure, memory_scope scope); | ||
1691 | +#endif //cl_khr_fp64 | ||
1692 | +bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_long *object, long *expected, | ||
1693 | + long desired, memory_order success, memory_order failure, memory_scope scope); | ||
1694 | +bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_long *object, long *expected, | ||
1695 | + long desired, memory_order success, memory_order failure, memory_scope scope); | ||
1696 | +bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_ulong *object, ulong *expected, | ||
1697 | + ulong desired, memory_order success, memory_order failure, memory_scope scope); | ||
1698 | bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_ulong *object, ulong *expected, | ||
1699 | ulong desired, memory_order success, memory_order failure, memory_scope scope); | ||
1700 | #endif | ||
1701 | |||
1702 | // atomic_flag_test_and_set() and atomic_flag_clear() | ||
1703 | - | ||
1704 | +#if defined(__opencl_c_atomic_order_seq_cst) && defined(__opencl_c_atomic_scope_device) | ||
1705 | bool __ovld atomic_flag_test_and_set(volatile atomic_flag *object); | ||
1706 | -bool __ovld atomic_flag_test_and_set_explicit(volatile atomic_flag *object, memory_order order); | ||
1707 | -bool __ovld atomic_flag_test_and_set_explicit(volatile atomic_flag *object, memory_order order, memory_scope scope); | ||
1708 | void __ovld atomic_flag_clear(volatile atomic_flag *object); | ||
1709 | +#endif | ||
1710 | + | ||
1711 | +#if defined(__opencl_c_atomic_scope_device) | ||
1712 | +bool __ovld atomic_flag_test_and_set_explicit(volatile atomic_flag *object, memory_order order); | ||
1713 | void __ovld atomic_flag_clear_explicit(volatile atomic_flag *object, memory_order order); | ||
1714 | -void __ovld atomic_flag_clear_explicit(volatile atomic_flag *object, memory_order order, memory_scope scope); | ||
1715 | +#endif | ||
1716 | |||
1717 | +bool __ovld atomic_flag_test_and_set_explicit(volatile atomic_flag *object, memory_order order, memory_scope scope); | ||
1718 | +void __ovld atomic_flag_clear_explicit(volatile atomic_flag *object, memory_order order, memory_scope scope); | ||
1719 | #endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1720 | |||
1721 | // OpenCL v1.1 s6.11.12, v1.2 s6.12.12, v2.0 s6.13.12 - Miscellaneous Vector Functions | ||
1722 | @@ -14843,7 +14876,7 @@ half4 __purefn __ovld read_imageh(read_only image1d_buffer_t image, int coord); | ||
1723 | #endif //cl_khr_fp16 | ||
1724 | |||
1725 | // Image read functions for read_write images | ||
1726 | -#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1727 | +#if defined(__opencl_c_read_write_images) | ||
1728 | float4 __purefn __ovld read_imagef(read_write image1d_t image, int coord); | ||
1729 | int4 __purefn __ovld read_imagei(read_write image1d_t image, int coord); | ||
1730 | uint4 __purefn __ovld read_imageui(read_write image1d_t image, int coord); | ||
1731 | @@ -14886,7 +14919,6 @@ float __purefn __ovld read_imagef(read_write image2d_msaa_depth_t image, int2 co | ||
1732 | float __purefn __ovld read_imagef(read_write image2d_array_msaa_depth_t image, int4 coord, int sample); | ||
1733 | #endif //cl_khr_gl_msaa_sharing | ||
1734 | |||
1735 | -#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1736 | #ifdef cl_khr_mipmap_image | ||
1737 | float4 __purefn __ovld read_imagef(read_write image1d_t image, sampler_t sampler, float coord, float lod); | ||
1738 | int4 __purefn __ovld read_imagei(read_write image1d_t image, sampler_t sampler, float coord, float lod); | ||
1739 | @@ -14937,7 +14969,6 @@ int4 __purefn __ovld read_imagei(read_write image3d_t image, sampler_t sampler, | ||
1740 | uint4 __purefn __ovld read_imageui(read_write image3d_t image, sampler_t sampler, float4 coord, float4 gradientX, float4 gradientY); | ||
1741 | |||
1742 | #endif //cl_khr_mipmap_image | ||
1743 | -#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1744 | |||
1745 | // Image read functions returning half4 type | ||
1746 | #ifdef cl_khr_fp16 | ||
1747 | @@ -14948,7 +14979,7 @@ half4 __purefn __ovld read_imageh(read_write image1d_array_t image, int2 coord); | ||
1748 | half4 __purefn __ovld read_imageh(read_write image2d_array_t image, int4 coord); | ||
1749 | half4 __purefn __ovld read_imageh(read_write image1d_buffer_t image, int coord); | ||
1750 | #endif //cl_khr_fp16 | ||
1751 | -#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1752 | +#endif //defined(__opencl_c_read_write_images | ||
1753 | |||
1754 | /** | ||
1755 | * Write color value to location specified by coordinate | ||
1756 | @@ -15092,7 +15123,7 @@ void __ovld write_imageh(write_only image1d_buffer_t image, int coord, half4 col | ||
1757 | #endif //cl_khr_fp16 | ||
1758 | |||
1759 | // Image write functions for read_write images | ||
1760 | -#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1761 | +#if defined(__opencl_c_read_write_images) | ||
1762 | void __ovld write_imagef(read_write image2d_t image, int2 coord, float4 color); | ||
1763 | void __ovld write_imagei(read_write image2d_t image, int2 coord, int4 color); | ||
1764 | void __ovld write_imageui(read_write image2d_t image, int2 coord, uint4 color); | ||
1765 | @@ -15124,7 +15155,6 @@ void __ovld write_imagef(read_write image2d_depth_t image, int2 coord, float col | ||
1766 | void __ovld write_imagef(read_write image2d_array_depth_t image, int4 coord, float color); | ||
1767 | #endif //cl_khr_depth_images | ||
1768 | |||
1769 | -#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1770 | #if defined(cl_khr_mipmap_image_writes) | ||
1771 | void __ovld write_imagef(read_write image1d_t image, int coord, int lod, float4 color); | ||
1772 | void __ovld write_imagei(read_write image1d_t image, int coord, int lod, int4 color); | ||
1773 | @@ -15152,7 +15182,6 @@ void __ovld write_imageui(read_write image3d_t image, int4 coord, int lod, uint4 | ||
1774 | #endif //cl_khr_3d_image_writes | ||
1775 | |||
1776 | #endif //cl_khr_mipmap_image_writes | ||
1777 | -#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1778 | |||
1779 | // Image write functions for half4 type | ||
1780 | #ifdef cl_khr_fp16 | ||
1781 | @@ -15165,7 +15194,7 @@ void __ovld write_imageh(read_write image1d_array_t image, int2 coord, half4 col | ||
1782 | void __ovld write_imageh(read_write image2d_array_t image, int4 coord, half4 color); | ||
1783 | void __ovld write_imageh(read_write image1d_buffer_t image, int coord, half4 color); | ||
1784 | #endif //cl_khr_fp16 | ||
1785 | -#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1786 | +#endif //defined(__opencl_c_read_write_images) | ||
1787 | |||
1788 | // Note: In OpenCL v1.0/1.1/1.2, image argument of image query builtin functions does not have | ||
1789 | // access qualifier, which by default assume read_only access qualifier. Image query builtin | ||
1790 | @@ -15213,7 +15242,7 @@ int __ovld __cnfn get_image_width(write_only image2d_array_msaa_t image); | ||
1791 | int __ovld __cnfn get_image_width(write_only image2d_array_msaa_depth_t image); | ||
1792 | #endif //cl_khr_gl_msaa_sharing | ||
1793 | |||
1794 | -#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1795 | +#if defined(__opencl_c_read_write_images) | ||
1796 | int __ovld __cnfn get_image_width(read_write image1d_t image); | ||
1797 | int __ovld __cnfn get_image_width(read_write image1d_buffer_t image); | ||
1798 | int __ovld __cnfn get_image_width(read_write image2d_t image); | ||
1799 | @@ -15230,7 +15259,7 @@ int __ovld __cnfn get_image_width(read_write image2d_msaa_depth_t image); | ||
1800 | int __ovld __cnfn get_image_width(read_write image2d_array_msaa_t image); | ||
1801 | int __ovld __cnfn get_image_width(read_write image2d_array_msaa_depth_t image); | ||
1802 | #endif //cl_khr_gl_msaa_sharing | ||
1803 | -#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1804 | +#endif //defined(__opencl_c_read_write_images) | ||
1805 | |||
1806 | /** | ||
1807 | * Return the image height in pixels. | ||
1808 | @@ -15265,7 +15294,7 @@ int __ovld __cnfn get_image_height(write_only image2d_array_msaa_t image); | ||
1809 | int __ovld __cnfn get_image_height(write_only image2d_array_msaa_depth_t image); | ||
1810 | #endif //cl_khr_gl_msaa_sharing | ||
1811 | |||
1812 | -#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1813 | +#if defined(__opencl_c_read_write_images) | ||
1814 | int __ovld __cnfn get_image_height(read_write image2d_t image); | ||
1815 | int __ovld __cnfn get_image_height(read_write image3d_t image); | ||
1816 | int __ovld __cnfn get_image_height(read_write image2d_array_t image); | ||
1817 | @@ -15279,7 +15308,7 @@ int __ovld __cnfn get_image_height(read_write image2d_msaa_depth_t image); | ||
1818 | int __ovld __cnfn get_image_height(read_write image2d_array_msaa_t image); | ||
1819 | int __ovld __cnfn get_image_height(read_write image2d_array_msaa_depth_t image); | ||
1820 | #endif //cl_khr_gl_msaa_sharing | ||
1821 | -#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1822 | +#endif //defined(__opencl_c_read_write_images) | ||
1823 | |||
1824 | /** | ||
1825 | * Return the image depth in pixels. | ||
1826 | @@ -15290,9 +15319,9 @@ int __ovld __cnfn get_image_depth(read_only image3d_t image); | ||
1827 | int __ovld __cnfn get_image_depth(write_only image3d_t image); | ||
1828 | #endif | ||
1829 | |||
1830 | -#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1831 | +#if defined(__opencl_c_read_write_images) | ||
1832 | int __ovld __cnfn get_image_depth(read_write image3d_t image); | ||
1833 | -#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1834 | +#endif //defined(__opencl_c_read_write_images) | ||
1835 | |||
1836 | // OpenCL Extension v2.0 s9.18 - Mipmaps | ||
1837 | #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1838 | @@ -15388,7 +15417,7 @@ int __ovld __cnfn get_image_channel_data_type(write_only image2d_array_msaa_t im | ||
1839 | int __ovld __cnfn get_image_channel_data_type(write_only image2d_array_msaa_depth_t image); | ||
1840 | #endif //cl_khr_gl_msaa_sharing | ||
1841 | |||
1842 | -#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1843 | +#if defined(__opencl_c_read_write_images) | ||
1844 | int __ovld __cnfn get_image_channel_data_type(read_write image1d_t image); | ||
1845 | int __ovld __cnfn get_image_channel_data_type(read_write image1d_buffer_t image); | ||
1846 | int __ovld __cnfn get_image_channel_data_type(read_write image2d_t image); | ||
1847 | @@ -15405,7 +15434,7 @@ int __ovld __cnfn get_image_channel_data_type(read_write image2d_msaa_depth_t im | ||
1848 | int __ovld __cnfn get_image_channel_data_type(read_write image2d_array_msaa_t image); | ||
1849 | int __ovld __cnfn get_image_channel_data_type(read_write image2d_array_msaa_depth_t image); | ||
1850 | #endif //cl_khr_gl_msaa_sharing | ||
1851 | -#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1852 | +#endif //defined(__opencl_c_read_write_images) | ||
1853 | |||
1854 | /** | ||
1855 | * Return the image channel order. Valid values are: | ||
1856 | @@ -15460,7 +15489,7 @@ int __ovld __cnfn get_image_channel_order(write_only image2d_array_msaa_t image) | ||
1857 | int __ovld __cnfn get_image_channel_order(write_only image2d_array_msaa_depth_t image); | ||
1858 | #endif //cl_khr_gl_msaa_sharing | ||
1859 | |||
1860 | -#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1861 | +#if defined(__opencl_c_read_write_images) | ||
1862 | int __ovld __cnfn get_image_channel_order(read_write image1d_t image); | ||
1863 | int __ovld __cnfn get_image_channel_order(read_write image1d_buffer_t image); | ||
1864 | int __ovld __cnfn get_image_channel_order(read_write image2d_t image); | ||
1865 | @@ -15477,7 +15506,7 @@ int __ovld __cnfn get_image_channel_order(read_write image2d_msaa_depth_t image) | ||
1866 | int __ovld __cnfn get_image_channel_order(read_write image2d_array_msaa_t image); | ||
1867 | int __ovld __cnfn get_image_channel_order(read_write image2d_array_msaa_depth_t image); | ||
1868 | #endif //cl_khr_gl_msaa_sharing | ||
1869 | -#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1870 | +#endif //defined(__opencl_c_read_write_images) | ||
1871 | |||
1872 | /** | ||
1873 | * Return the 2D image width and height as an int2 | ||
1874 | @@ -15510,7 +15539,7 @@ int2 __ovld __cnfn get_image_dim(write_only image2d_array_msaa_t image); | ||
1875 | int2 __ovld __cnfn get_image_dim(write_only image2d_array_msaa_depth_t image); | ||
1876 | #endif //cl_khr_gl_msaa_sharing | ||
1877 | |||
1878 | -#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1879 | +#if defined(__opencl_c_read_write_images) | ||
1880 | int2 __ovld __cnfn get_image_dim(read_write image2d_t image); | ||
1881 | int2 __ovld __cnfn get_image_dim(read_write image2d_array_t image); | ||
1882 | #ifdef cl_khr_depth_images | ||
1883 | @@ -15523,7 +15552,7 @@ int2 __ovld __cnfn get_image_dim(read_write image2d_msaa_depth_t image); | ||
1884 | int2 __ovld __cnfn get_image_dim(read_write image2d_array_msaa_t image); | ||
1885 | int2 __ovld __cnfn get_image_dim(read_write image2d_array_msaa_depth_t image); | ||
1886 | #endif //cl_khr_gl_msaa_sharing | ||
1887 | -#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1888 | +#endif //defined(__opencl_c_read_write_images) | ||
1889 | |||
1890 | /** | ||
1891 | * Return the 3D image width, height, and depth as an | ||
1892 | @@ -15535,9 +15564,9 @@ int4 __ovld __cnfn get_image_dim(read_only image3d_t image); | ||
1893 | #ifdef cl_khr_3d_image_writes | ||
1894 | int4 __ovld __cnfn get_image_dim(write_only image3d_t image); | ||
1895 | #endif | ||
1896 | -#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1897 | +#if defined(__opencl_c_read_write_images) | ||
1898 | int4 __ovld __cnfn get_image_dim(read_write image3d_t image); | ||
1899 | -#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1900 | +#endif //defined(__opencl_c_read_write_images) | ||
1901 | |||
1902 | /** | ||
1903 | * Return the image array size. | ||
1904 | @@ -15563,7 +15592,7 @@ size_t __ovld __cnfn get_image_array_size(write_only image2d_array_msaa_t image_ | ||
1905 | size_t __ovld __cnfn get_image_array_size(write_only image2d_array_msaa_depth_t image_array); | ||
1906 | #endif //cl_khr_gl_msaa_sharing | ||
1907 | |||
1908 | -#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1909 | +#if defined(__opencl_c_read_write_images) | ||
1910 | size_t __ovld __cnfn get_image_array_size(read_write image1d_array_t image_array); | ||
1911 | size_t __ovld __cnfn get_image_array_size(read_write image2d_array_t image_array); | ||
1912 | #ifdef cl_khr_depth_images | ||
1913 | @@ -15573,7 +15602,7 @@ size_t __ovld __cnfn get_image_array_size(read_write image2d_array_depth_t image | ||
1914 | size_t __ovld __cnfn get_image_array_size(read_write image2d_array_msaa_t image_array); | ||
1915 | size_t __ovld __cnfn get_image_array_size(read_write image2d_array_msaa_depth_t image_array); | ||
1916 | #endif //cl_khr_gl_msaa_sharing | ||
1917 | -#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1918 | +#endif //defined(__opencl_c_read_write_images) | ||
1919 | |||
1920 | /** | ||
1921 | * Return the number of samples associated with image | ||
1922 | @@ -15589,12 +15618,12 @@ int __ovld get_image_num_samples(write_only image2d_msaa_depth_t image); | ||
1923 | int __ovld get_image_num_samples(write_only image2d_array_msaa_t image); | ||
1924 | int __ovld get_image_num_samples(write_only image2d_array_msaa_depth_t image); | ||
1925 | |||
1926 | -#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1927 | +#if defined(__opencl_c_read_write_images) | ||
1928 | int __ovld get_image_num_samples(read_write image2d_msaa_t image); | ||
1929 | int __ovld get_image_num_samples(read_write image2d_msaa_depth_t image); | ||
1930 | int __ovld get_image_num_samples(read_write image2d_array_msaa_t image); | ||
1931 | int __ovld get_image_num_samples(read_write image2d_array_msaa_depth_t image); | ||
1932 | -#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1933 | +#endif //defined(__opencl_c_read_write_images) | ||
1934 | #endif | ||
1935 | |||
1936 | // OpenCL v2.0 s6.13.15 - Work-group Functions | ||
1937 | @@ -16630,34 +16659,38 @@ uint16 __ovld __conv intel_sub_group_shuffle_xor( uint16 x, uint c ); | ||
1938 | long __ovld __conv intel_sub_group_shuffle_xor( long x, uint c ); | ||
1939 | ulong __ovld __conv intel_sub_group_shuffle_xor( ulong x, uint c ); | ||
1940 | |||
1941 | +#if defined(__opencl_c_images) | ||
1942 | uint __ovld __conv intel_sub_group_block_read( read_only image2d_t image, int2 coord ); | ||
1943 | uint2 __ovld __conv intel_sub_group_block_read2( read_only image2d_t image, int2 coord ); | ||
1944 | uint4 __ovld __conv intel_sub_group_block_read4( read_only image2d_t image, int2 coord ); | ||
1945 | uint8 __ovld __conv intel_sub_group_block_read8( read_only image2d_t image, int2 coord ); | ||
1946 | +#endif | ||
1947 | |||
1948 | -#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1949 | +#if defined(__opencl_c_read_write_images) | ||
1950 | uint __ovld __conv intel_sub_group_block_read(read_write image2d_t image, int2 coord); | ||
1951 | uint2 __ovld __conv intel_sub_group_block_read2(read_write image2d_t image, int2 coord); | ||
1952 | uint4 __ovld __conv intel_sub_group_block_read4(read_write image2d_t image, int2 coord); | ||
1953 | uint8 __ovld __conv intel_sub_group_block_read8(read_write image2d_t image, int2 coord); | ||
1954 | -#endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1955 | +#endif // defined(__opencl_c_read_write_images) | ||
1956 | |||
1957 | uint __ovld __conv intel_sub_group_block_read( const __global uint* p ); | ||
1958 | uint2 __ovld __conv intel_sub_group_block_read2( const __global uint* p ); | ||
1959 | uint4 __ovld __conv intel_sub_group_block_read4( const __global uint* p ); | ||
1960 | uint8 __ovld __conv intel_sub_group_block_read8( const __global uint* p ); | ||
1961 | |||
1962 | +#if defined(__opencl_c_images) | ||
1963 | void __ovld __conv intel_sub_group_block_write(write_only image2d_t image, int2 coord, uint data); | ||
1964 | void __ovld __conv intel_sub_group_block_write2(write_only image2d_t image, int2 coord, uint2 data); | ||
1965 | void __ovld __conv intel_sub_group_block_write4(write_only image2d_t image, int2 coord, uint4 data); | ||
1966 | void __ovld __conv intel_sub_group_block_write8(write_only image2d_t image, int2 coord, uint8 data); | ||
1967 | +#endif // defined(__opencl_c_images) | ||
1968 | |||
1969 | -#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1970 | +#if defined(__opencl_c_read_write_images) | ||
1971 | void __ovld __conv intel_sub_group_block_write(read_write image2d_t image, int2 coord, uint data); | ||
1972 | void __ovld __conv intel_sub_group_block_write2(read_write image2d_t image, int2 coord, uint2 data); | ||
1973 | void __ovld __conv intel_sub_group_block_write4(read_write image2d_t image, int2 coord, uint4 data); | ||
1974 | void __ovld __conv intel_sub_group_block_write8(read_write image2d_t image, int2 coord, uint8 data); | ||
1975 | -#endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1976 | +#endif // defined(__opencl_c_read_write_images) | ||
1977 | |||
1978 | void __ovld __conv intel_sub_group_block_write( __global uint* p, uint data ); | ||
1979 | void __ovld __conv intel_sub_group_block_write2( __global uint* p, uint2 data ); | ||
1980 | @@ -16770,68 +16803,76 @@ ushort __ovld __conv intel_sub_group_scan_inclusive_min( ushort x ); | ||
1981 | short __ovld __conv intel_sub_group_scan_inclusive_max( short x ); | ||
1982 | ushort __ovld __conv intel_sub_group_scan_inclusive_max( ushort x ); | ||
1983 | |||
1984 | +#if defined(__opencl_c_images) | ||
1985 | uint __ovld __conv intel_sub_group_block_read_ui( read_only image2d_t image, int2 byte_coord ); | ||
1986 | uint2 __ovld __conv intel_sub_group_block_read_ui2( read_only image2d_t image, int2 byte_coord ); | ||
1987 | uint4 __ovld __conv intel_sub_group_block_read_ui4( read_only image2d_t image, int2 byte_coord ); | ||
1988 | uint8 __ovld __conv intel_sub_group_block_read_ui8( read_only image2d_t image, int2 byte_coord ); | ||
1989 | +#endif // defined(__opencl_c_images) | ||
1990 | |||
1991 | -#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1992 | +#if defined(__opencl_c_read_write_images) | ||
1993 | uint __ovld __conv intel_sub_group_block_read_ui( read_write image2d_t image, int2 byte_coord ); | ||
1994 | uint2 __ovld __conv intel_sub_group_block_read_ui2( read_write image2d_t image, int2 byte_coord ); | ||
1995 | uint4 __ovld __conv intel_sub_group_block_read_ui4( read_write image2d_t image, int2 byte_coord ); | ||
1996 | uint8 __ovld __conv intel_sub_group_block_read_ui8( read_write image2d_t image, int2 byte_coord ); | ||
1997 | -#endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
1998 | +#endif // defined(__opencl_c_read_write_images) | ||
1999 | |||
2000 | uint __ovld __conv intel_sub_group_block_read_ui( const __global uint* p ); | ||
2001 | uint2 __ovld __conv intel_sub_group_block_read_ui2( const __global uint* p ); | ||
2002 | uint4 __ovld __conv intel_sub_group_block_read_ui4( const __global uint* p ); | ||
2003 | uint8 __ovld __conv intel_sub_group_block_read_ui8( const __global uint* p ); | ||
2004 | |||
2005 | +#if defined(__opencl_c_images) | ||
2006 | void __ovld __conv intel_sub_group_block_write_ui( read_only image2d_t image, int2 byte_coord, uint data ); | ||
2007 | void __ovld __conv intel_sub_group_block_write_ui2( read_only image2d_t image, int2 byte_coord, uint2 data ); | ||
2008 | void __ovld __conv intel_sub_group_block_write_ui4( read_only image2d_t image, int2 byte_coord, uint4 data ); | ||
2009 | void __ovld __conv intel_sub_group_block_write_ui8( read_only image2d_t image, int2 byte_coord, uint8 data ); | ||
2010 | +#endif //defined(__opencl_c_images) | ||
2011 | |||
2012 | -#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
2013 | +#if defined(__opencl_c_read_write_images) | ||
2014 | void __ovld __conv intel_sub_group_block_write_ui( read_write image2d_t image, int2 byte_coord, uint data ); | ||
2015 | void __ovld __conv intel_sub_group_block_write_ui2( read_write image2d_t image, int2 byte_coord, uint2 data ); | ||
2016 | void __ovld __conv intel_sub_group_block_write_ui4( read_write image2d_t image, int2 byte_coord, uint4 data ); | ||
2017 | void __ovld __conv intel_sub_group_block_write_ui8( read_write image2d_t image, int2 byte_coord, uint8 data ); | ||
2018 | -#endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
2019 | +#endif // defined(__opencl_c_read_write_images) | ||
2020 | |||
2021 | void __ovld __conv intel_sub_group_block_write_ui( __global uint* p, uint data ); | ||
2022 | void __ovld __conv intel_sub_group_block_write_ui2( __global uint* p, uint2 data ); | ||
2023 | void __ovld __conv intel_sub_group_block_write_ui4( __global uint* p, uint4 data ); | ||
2024 | void __ovld __conv intel_sub_group_block_write_ui8( __global uint* p, uint8 data ); | ||
2025 | |||
2026 | +#if defined(__opencl_c_images) | ||
2027 | ushort __ovld __conv intel_sub_group_block_read_us( read_only image2d_t image, int2 coord ); | ||
2028 | ushort2 __ovld __conv intel_sub_group_block_read_us2( read_only image2d_t image, int2 coord ); | ||
2029 | ushort4 __ovld __conv intel_sub_group_block_read_us4( read_only image2d_t image, int2 coord ); | ||
2030 | ushort8 __ovld __conv intel_sub_group_block_read_us8( read_only image2d_t image, int2 coord ); | ||
2031 | +#endif // defined(__opencl_c_images) | ||
2032 | |||
2033 | -#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
2034 | +#if defined(__opencl_c_read_write_images) | ||
2035 | ushort __ovld __conv intel_sub_group_block_read_us(read_write image2d_t image, int2 coord); | ||
2036 | ushort2 __ovld __conv intel_sub_group_block_read_us2(read_write image2d_t image, int2 coord); | ||
2037 | ushort4 __ovld __conv intel_sub_group_block_read_us4(read_write image2d_t image, int2 coord); | ||
2038 | ushort8 __ovld __conv intel_sub_group_block_read_us8(read_write image2d_t image, int2 coord); | ||
2039 | -#endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
2040 | +#endif // defined(__opencl_c_read_write_images) | ||
2041 | |||
2042 | ushort __ovld __conv intel_sub_group_block_read_us( const __global ushort* p ); | ||
2043 | ushort2 __ovld __conv intel_sub_group_block_read_us2( const __global ushort* p ); | ||
2044 | ushort4 __ovld __conv intel_sub_group_block_read_us4( const __global ushort* p ); | ||
2045 | ushort8 __ovld __conv intel_sub_group_block_read_us8( const __global ushort* p ); | ||
2046 | |||
2047 | +#if defined(__opencl_c_images) | ||
2048 | void __ovld __conv intel_sub_group_block_write_us(write_only image2d_t image, int2 coord, ushort data); | ||
2049 | void __ovld __conv intel_sub_group_block_write_us2(write_only image2d_t image, int2 coord, ushort2 data); | ||
2050 | void __ovld __conv intel_sub_group_block_write_us4(write_only image2d_t image, int2 coord, ushort4 data); | ||
2051 | void __ovld __conv intel_sub_group_block_write_us8(write_only image2d_t image, int2 coord, ushort8 data); | ||
2052 | +#endif // defined(__opencl_c_images) | ||
2053 | |||
2054 | -#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
2055 | +#if defined(__opencl_c_read_write_images) | ||
2056 | void __ovld __conv intel_sub_group_block_write_us(read_write image2d_t image, int2 coord, ushort data); | ||
2057 | void __ovld __conv intel_sub_group_block_write_us2(read_write image2d_t image, int2 coord, ushort2 data); | ||
2058 | void __ovld __conv intel_sub_group_block_write_us4(read_write image2d_t image, int2 coord, ushort4 data); | ||
2059 | void __ovld __conv intel_sub_group_block_write_us8(read_write image2d_t image, int2 coord, ushort8 data); | ||
2060 | -#endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) | ||
2061 | +#endif // defined(__opencl_c_read_write_images) | ||
2062 | |||
2063 | void __ovld __conv intel_sub_group_block_write_us( __global ushort* p, ushort data ); | ||
2064 | void __ovld __conv intel_sub_group_block_write_us2( __global ushort* p, ushort2 data ); | ||
2065 | @@ -16949,6 +16990,7 @@ short2 __ovld intel_sub_group_avc_ime_adjust_ref_offset( | ||
2066 | short2 ref_offset, ushort2 src_coord, ushort2 ref_window_size, | ||
2067 | ushort2 image_size); | ||
2068 | |||
2069 | +#if defined(__opencl_c_images) | ||
2070 | intel_sub_group_avc_ime_result_t __ovld | ||
2071 | intel_sub_group_avc_ime_evaluate_with_single_reference( | ||
2072 | read_only image2d_t src_image, read_only image2d_t ref_image, | ||
2073 | @@ -16989,6 +17031,7 @@ intel_sub_group_avc_ime_evaluate_with_dual_reference_streaminout( | ||
2074 | read_only image2d_t bwd_ref_image, sampler_t vme_media_sampler, | ||
2075 | intel_sub_group_avc_ime_payload_t payload, | ||
2076 | intel_sub_group_avc_ime_dual_reference_streamin_t streamin_components); | ||
2077 | +#endif | ||
2078 | |||
2079 | intel_sub_group_avc_ime_single_reference_streamin_t __ovld | ||
2080 | intel_sub_group_avc_ime_get_single_reference_streamin( | ||
2081 | @@ -17053,6 +17096,7 @@ intel_sub_group_avc_ref_payload_t __ovld | ||
2082 | intel_sub_group_avc_ref_set_bilinear_filter_enable( | ||
2083 | intel_sub_group_avc_ref_payload_t payload); | ||
2084 | |||
2085 | +#if defined(__opencl_c_images) | ||
2086 | intel_sub_group_avc_ref_result_t __ovld | ||
2087 | intel_sub_group_avc_ref_evaluate_with_single_reference( | ||
2088 | read_only image2d_t src_image, read_only image2d_t ref_image, | ||
2089 | @@ -17071,6 +17115,7 @@ intel_sub_group_avc_ref_evaluate_with_multi_reference( | ||
2090 | read_only image2d_t src_image, uint packed_reference_ids, | ||
2091 | uchar packed_reference_field_polarities, sampler_t vme_media_sampler, | ||
2092 | intel_sub_group_avc_ref_payload_t payload); | ||
2093 | +#endif //defined(__opencl_c_images) | ||
2094 | |||
2095 | // SIC built-in functions | ||
2096 | intel_sub_group_avc_sic_payload_t __ovld | ||
2097 | @@ -17121,6 +17166,7 @@ intel_sub_group_avc_sic_set_block_based_raw_skip_sad( | ||
2098 | uchar block_based_skip_type, | ||
2099 | intel_sub_group_avc_sic_payload_t payload); | ||
2100 | |||
2101 | +#if defined(__opencl_c_images) | ||
2102 | intel_sub_group_avc_sic_result_t __ovld | ||
2103 | intel_sub_group_avc_sic_evaluate_ipe( | ||
2104 | read_only image2d_t src_image, sampler_t vme_media_sampler, | ||
2105 | @@ -17143,6 +17189,7 @@ intel_sub_group_avc_sic_evaluate_with_multi_reference( | ||
2106 | read_only image2d_t src_image, uint packed_reference_ids, | ||
2107 | uchar packed_reference_field_polarities, sampler_t vme_media_sampler, | ||
2108 | intel_sub_group_avc_sic_payload_t payload); | ||
2109 | +#endif //defined(__opencl_c_images) | ||
2110 | |||
2111 | uchar __ovld intel_sub_group_avc_sic_get_ipe_luma_shape( | ||
2112 | intel_sub_group_avc_sic_result_t result); | ||
2113 | @@ -17529,31 +17576,23 @@ uint16 __ovld amd_sadw(uint16 src0, uint16 src1, uint16 src2); | ||
2114 | #endif // cl_amd_media_ops2 | ||
2115 | |||
2116 | #if defined(cl_arm_integer_dot_product_int8) | ||
2117 | -#pragma OPENCL EXTENSION cl_arm_integer_dot_product_int8 : begin | ||
2118 | uint __ovld arm_dot(uchar4 a, uchar4 b); | ||
2119 | int __ovld arm_dot(char4 a, char4 b); | ||
2120 | -#pragma OPENCL EXTENSION cl_arm_integer_dot_product_int8 : end | ||
2121 | #endif // defined(cl_arm_integer_dot_product_int8) | ||
2122 | |||
2123 | #if defined(cl_arm_integer_dot_product_accumulate_int8) | ||
2124 | -#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_int8 : begin | ||
2125 | uint __ovld arm_dot_acc(uchar4 a, uchar4 b, uint c); | ||
2126 | int __ovld arm_dot_acc(char4 a, char4 b, int c); | ||
2127 | -#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_int8 : end | ||
2128 | #endif // defined(cl_arm_integer_dot_product_accumulate_int8) | ||
2129 | |||
2130 | #if defined(cl_arm_integer_dot_product_accumulate_int16) | ||
2131 | -#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_int16 : begin | ||
2132 | uint __ovld arm_dot_acc(ushort2 a, ushort2 b, uint c); | ||
2133 | int __ovld arm_dot_acc(short2 a, short2 b, int c); | ||
2134 | -#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_int16 : end | ||
2135 | #endif // defined(cl_arm_integer_dot_product_accumulate_int16) | ||
2136 | |||
2137 | #if defined(cl_arm_integer_dot_product_accumulate_saturate_int8) | ||
2138 | -#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_saturate_int8 : begin | ||
2139 | uint __ovld arm_dot_acc_sat(uchar4 a, uchar4 b, uint c); | ||
2140 | int __ovld arm_dot_acc_sat(char4 a, char4 b, int c); | ||
2141 | -#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_saturate_int8 : end | ||
2142 | #endif // defined(cl_arm_integer_dot_product_accumulate_saturate_int8) | ||
2143 | |||
2144 | // Disable any extensions we may have enabled previously. | ||
2145 | diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp | ||
2146 | index 347d992b1643..c489c8c75623 100644 | ||
2147 | --- a/clang/lib/Parse/ParseDecl.cpp | ||
2148 | +++ b/clang/lib/Parse/ParseDecl.cpp | ||
2149 | @@ -3631,8 +3631,8 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, | ||
2150 | // C++ for OpenCL does not allow virtual function qualifier, to avoid | ||
2151 | // function pointers restricted in OpenCL v2.0 s6.9.a. | ||
2152 | if (getLangOpts().OpenCLCPlusPlus && | ||
2153 | - !getActions().getOpenCLOptions().isEnabled( | ||
2154 | - "__cl_clang_function_pointers")) { | ||
2155 | + !getActions().getOpenCLOptions().isAvailableOption( | ||
2156 | + "__cl_clang_function_pointers", getLangOpts())) { | ||
2157 | DiagID = diag::err_openclcxx_virtual_function; | ||
2158 | PrevSpec = Tok.getIdentifierInfo()->getNameStart(); | ||
2159 | isInvalid = true; | ||
2160 | @@ -4002,8 +4002,9 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, | ||
2161 | case tok::kw___generic: | ||
2162 | // generic address space is introduced only in OpenCL v2.0 | ||
2163 | // see OpenCL C Spec v2.0 s6.5.5 | ||
2164 | - if (Actions.getLangOpts().OpenCLVersion < 200 && | ||
2165 | - !Actions.getLangOpts().OpenCLCPlusPlus) { | ||
2166 | + // OpenCL v3.0 introduces __opencl_c_generic_address_space | ||
2167 | + // feature macro to indicate if generic address space is supported | ||
2168 | + if (!Actions.getLangOpts().OpenCLGenericAddressSpace) { | ||
2169 | DiagID = diag::err_opencl_unknown_type_specifier; | ||
2170 | PrevSpec = Tok.getIdentifierInfo()->getNameStart(); | ||
2171 | isInvalid = true; | ||
2172 | @@ -5059,8 +5060,7 @@ bool Parser::isDeclarationSpecifier(bool DisambiguatingWithExpression) { | ||
2173 | default: return false; | ||
2174 | |||
2175 | case tok::kw_pipe: | ||
2176 | - return (getLangOpts().OpenCL && getLangOpts().OpenCLVersion >= 200) || | ||
2177 | - getLangOpts().OpenCLCPlusPlus; | ||
2178 | + return getLangOpts().OpenCLPipe; | ||
2179 | |||
2180 | case tok::identifier: // foo::bar | ||
2181 | // Unfortunate hack to support "Class.factoryMethod" notation. | ||
2182 | @@ -5587,9 +5587,7 @@ static bool isPtrOperatorToken(tok::TokenKind Kind, const LangOptions &Lang, | ||
2183 | DeclaratorContext TheContext) { | ||
2184 | if (Kind == tok::star || Kind == tok::caret) | ||
2185 | return true; | ||
2186 | - | ||
2187 | - if (Kind == tok::kw_pipe && | ||
2188 | - ((Lang.OpenCL && Lang.OpenCLVersion >= 200) || Lang.OpenCLCPlusPlus)) | ||
2189 | + if (Kind == tok::kw_pipe && Lang.OpenCLPipe) | ||
2190 | return true; | ||
2191 | |||
2192 | if (!Lang.CPlusPlus) | ||
2193 | diff --git a/clang/lib/Parse/ParsePragma.cpp b/clang/lib/Parse/ParsePragma.cpp | ||
2194 | index f9b852826775..948e04eafa41 100644 | ||
2195 | --- a/clang/lib/Parse/ParsePragma.cpp | ||
2196 | +++ b/clang/lib/Parse/ParsePragma.cpp | ||
2197 | @@ -771,22 +771,21 @@ void Parser::HandlePragmaOpenCLExtension() { | ||
2198 | // overriding all previously issued extension directives, but only if the | ||
2199 | // behavior is set to disable." | ||
2200 | if (Name == "all") { | ||
2201 | - if (State == Disable) { | ||
2202 | + if (State == Disable) | ||
2203 | Opt.disableAll(); | ||
2204 | - Opt.enableSupportedCore(getLangOpts()); | ||
2205 | - } else { | ||
2206 | + else | ||
2207 | PP.Diag(NameLoc, diag::warn_pragma_expected_predicate) << 1; | ||
2208 | - } | ||
2209 | } else if (State == Begin) { | ||
2210 | if (!Opt.isKnown(Name) || !Opt.isSupported(Name, getLangOpts())) { | ||
2211 | Opt.support(Name); | ||
2212 | + // FIXME: Default behavior of the extension pragma is not defined. | ||
2213 | + // Therefore, it should never be added by default. | ||
2214 | + Opt.acceptsPragma(Name); | ||
2215 | } | ||
2216 | - Actions.setCurrentOpenCLExtension(Name); | ||
2217 | } else if (State == End) { | ||
2218 | - if (Name != Actions.getCurrentOpenCLExtension()) | ||
2219 | - PP.Diag(NameLoc, diag::warn_pragma_begin_end_mismatch); | ||
2220 | - Actions.setCurrentOpenCLExtension(""); | ||
2221 | - } else if (!Opt.isKnown(Name)) | ||
2222 | + // There is no behavior for this directive. We only accept this for | ||
2223 | + // backward compatibility. | ||
2224 | + } else if (!Opt.isKnown(Name) || !Opt.isWithPragma(Name)) | ||
2225 | PP.Diag(NameLoc, diag::warn_pragma_unknown_extension) << Ident; | ||
2226 | else if (Opt.isSupportedExtension(Name, getLangOpts())) | ||
2227 | Opt.enable(Name, State == Enable); | ||
2228 | diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp | ||
2229 | index 9b0f921b4269..b3b02f8d266a 100644 | ||
2230 | --- a/clang/lib/Parse/Parser.cpp | ||
2231 | +++ b/clang/lib/Parse/Parser.cpp | ||
2232 | @@ -1079,8 +1079,6 @@ Parser::ParseDeclOrFunctionDefInternal(ParsedAttributesWithRange &attrs, | ||
2233 | Decl *TheDecl = Actions.ParsedFreeStandingDeclSpec(getCurScope(), AS_none, | ||
2234 | DS, AnonRecord); | ||
2235 | DS.complete(TheDecl); | ||
2236 | - if (getLangOpts().OpenCL) | ||
2237 | - Actions.setCurrentOpenCLExtensionForDecl(TheDecl); | ||
2238 | if (AnonRecord) { | ||
2239 | Decl* decls[] = {AnonRecord, TheDecl}; | ||
2240 | return Actions.BuildDeclaratorGroup(decls); | ||
2241 | diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp | ||
2242 | index da42db3e8f7b..f60708d7dc01 100644 | ||
2243 | --- a/clang/lib/Sema/DeclSpec.cpp | ||
2244 | +++ b/clang/lib/Sema/DeclSpec.cpp | ||
2245 | @@ -625,7 +625,8 @@ bool DeclSpec::SetStorageClassSpec(Sema &S, SCS SC, SourceLocation Loc, | ||
2246 | // OpenCL v1.2 s6.8 changes this to "The auto and register storage-class | ||
2247 | // specifiers are not supported." | ||
2248 | if (S.getLangOpts().OpenCL && | ||
2249 | - !S.getOpenCLOptions().isEnabled("cl_clang_storage_class_specifiers")) { | ||
2250 | + !S.getOpenCLOptions().isAvailableOption( | ||
2251 | + "cl_clang_storage_class_specifiers", S.getLangOpts())) { | ||
2252 | switch (SC) { | ||
2253 | case SCS_extern: | ||
2254 | case SCS_private_extern: | ||
2255 | diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp | ||
2256 | index a91291c7af38..95ba22ddf2a7 100644 | ||
2257 | --- a/clang/lib/Sema/Sema.cpp | ||
2258 | +++ b/clang/lib/Sema/Sema.cpp | ||
2259 | @@ -299,7 +299,6 @@ void Sema::Initialize() { | ||
2260 | if (getLangOpts().OpenCL) { | ||
2261 | getOpenCLOptions().addSupport( | ||
2262 | Context.getTargetInfo().getSupportedOpenCLOpts(), getLangOpts()); | ||
2263 | - getOpenCLOptions().enableSupportedCore(getLangOpts()); | ||
2264 | addImplicitTypedef("sampler_t", Context.OCLSamplerTy); | ||
2265 | addImplicitTypedef("event_t", Context.OCLEventTy); | ||
2266 | if (getLangOpts().OpenCLCPlusPlus || getLangOpts().OpenCLVersion >= 200) { | ||
2267 | @@ -309,28 +308,13 @@ void Sema::Initialize() { | ||
2268 | addImplicitTypedef("atomic_int", Context.getAtomicType(Context.IntTy)); | ||
2269 | addImplicitTypedef("atomic_uint", | ||
2270 | Context.getAtomicType(Context.UnsignedIntTy)); | ||
2271 | - auto AtomicLongT = Context.getAtomicType(Context.LongTy); | ||
2272 | - addImplicitTypedef("atomic_long", AtomicLongT); | ||
2273 | - auto AtomicULongT = Context.getAtomicType(Context.UnsignedLongTy); | ||
2274 | - addImplicitTypedef("atomic_ulong", AtomicULongT); | ||
2275 | auto AtomicHalfT = Context.getAtomicType(Context.HalfTy); | ||
2276 | addImplicitTypedef("atomic_half", AtomicHalfT); | ||
2277 | - setOpenCLExtensionForType(AtomicHalfT, "cl_khr_fp16"); | ||
2278 | addImplicitTypedef("atomic_float", | ||
2279 | Context.getAtomicType(Context.FloatTy)); | ||
2280 | - auto AtomicDoubleT = Context.getAtomicType(Context.DoubleTy); | ||
2281 | - addImplicitTypedef("atomic_double", AtomicDoubleT); | ||
2282 | // OpenCLC v2.0, s6.13.11.6 requires that atomic_flag is implemented as | ||
2283 | // 32-bit integer and OpenCLC v2.0, s6.1.1 int is always 32-bit wide. | ||
2284 | addImplicitTypedef("atomic_flag", Context.getAtomicType(Context.IntTy)); | ||
2285 | - auto AtomicIntPtrT = Context.getAtomicType(Context.getIntPtrType()); | ||
2286 | - addImplicitTypedef("atomic_intptr_t", AtomicIntPtrT); | ||
2287 | - auto AtomicUIntPtrT = Context.getAtomicType(Context.getUIntPtrType()); | ||
2288 | - addImplicitTypedef("atomic_uintptr_t", AtomicUIntPtrT); | ||
2289 | - auto AtomicSizeT = Context.getAtomicType(Context.getSizeType()); | ||
2290 | - addImplicitTypedef("atomic_size_t", AtomicSizeT); | ||
2291 | - auto AtomicPtrDiffT = Context.getAtomicType(Context.getPointerDiffType()); | ||
2292 | - addImplicitTypedef("atomic_ptrdiff_t", AtomicPtrDiffT); | ||
2293 | |||
2294 | // OpenCL v2.0 s6.13.11.6: | ||
2295 | // - The atomic_long and atomic_ulong types are supported if the | ||
2296 | @@ -343,31 +327,47 @@ void Sema::Initialize() { | ||
2297 | // atomic_intptr_t, atomic_uintptr_t, atomic_size_t and | ||
2298 | // atomic_ptrdiff_t are supported if the cl_khr_int64_base_atomics and | ||
2299 | // cl_khr_int64_extended_atomics extensions are supported. | ||
2300 | - std::vector<QualType> Atomic64BitTypes; | ||
2301 | - Atomic64BitTypes.push_back(AtomicLongT); | ||
2302 | - Atomic64BitTypes.push_back(AtomicULongT); | ||
2303 | - Atomic64BitTypes.push_back(AtomicDoubleT); | ||
2304 | - if (Context.getTypeSize(AtomicSizeT) == 64) { | ||
2305 | - Atomic64BitTypes.push_back(AtomicSizeT); | ||
2306 | - Atomic64BitTypes.push_back(AtomicIntPtrT); | ||
2307 | - Atomic64BitTypes.push_back(AtomicUIntPtrT); | ||
2308 | - Atomic64BitTypes.push_back(AtomicPtrDiffT); | ||
2309 | + auto AddPointerSizeDependentTypes = [&]() { | ||
2310 | + auto AtomicSizeT = Context.getAtomicType(Context.getSizeType()); | ||
2311 | + auto AtomicIntPtrT = Context.getAtomicType(Context.getIntPtrType()); | ||
2312 | + auto AtomicUIntPtrT = Context.getAtomicType(Context.getUIntPtrType()); | ||
2313 | + auto AtomicPtrDiffT = | ||
2314 | + Context.getAtomicType(Context.getPointerDiffType()); | ||
2315 | + addImplicitTypedef("atomic_size_t", AtomicSizeT); | ||
2316 | + addImplicitTypedef("atomic_intptr_t", AtomicIntPtrT); | ||
2317 | + addImplicitTypedef("atomic_uintptr_t", AtomicUIntPtrT); | ||
2318 | + addImplicitTypedef("atomic_ptrdiff_t", AtomicPtrDiffT); | ||
2319 | + }; | ||
2320 | + | ||
2321 | + if (Context.getTypeSize(Context.getSizeType()) == 32) { | ||
2322 | + AddPointerSizeDependentTypes(); | ||
2323 | } | ||
2324 | - for (auto &I : Atomic64BitTypes) | ||
2325 | - setOpenCLExtensionForType(I, | ||
2326 | - "cl_khr_int64_base_atomics cl_khr_int64_extended_atomics"); | ||
2327 | |||
2328 | - setOpenCLExtensionForType(AtomicDoubleT, "cl_khr_fp64"); | ||
2329 | + std::vector<QualType> Atomic64BitTypes; | ||
2330 | + if (getOpenCLOptions().isSupported("cl_khr_int64_base_atomics", | ||
2331 | + getLangOpts()) && | ||
2332 | + getOpenCLOptions().isSupported("cl_khr_int64_extended_atomics", | ||
2333 | + getLangOpts())) { | ||
2334 | + if (getOpenCLOptions().isSupported("cl_khr_fp64", getLangOpts())) { | ||
2335 | + auto AtomicDoubleT = Context.getAtomicType(Context.DoubleTy); | ||
2336 | + addImplicitTypedef("atomic_double", AtomicDoubleT); | ||
2337 | + Atomic64BitTypes.push_back(AtomicDoubleT); | ||
2338 | + } | ||
2339 | + auto AtomicLongT = Context.getAtomicType(Context.LongTy); | ||
2340 | + auto AtomicULongT = Context.getAtomicType(Context.UnsignedLongTy); | ||
2341 | + | ||
2342 | + addImplicitTypedef("atomic_long", AtomicLongT); | ||
2343 | + addImplicitTypedef("atomic_ulong", AtomicULongT); | ||
2344 | + if (Context.getTypeSize(Context.getSizeType()) == 64) { | ||
2345 | + AddPointerSizeDependentTypes(); | ||
2346 | + } | ||
2347 | + } | ||
2348 | } | ||
2349 | |||
2350 | - setOpenCLExtensionForType(Context.DoubleTy, "cl_khr_fp64"); | ||
2351 | - | ||
2352 | -#define GENERIC_IMAGE_TYPE_EXT(Type, Id, Ext) \ | ||
2353 | - setOpenCLExtensionForType(Context.Id, Ext); | ||
2354 | -#include "clang/Basic/OpenCLImageTypes.def" | ||
2355 | -#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ | ||
2356 | - addImplicitTypedef(#ExtType, Context.Id##Ty); \ | ||
2357 | - setOpenCLExtensionForType(Context.Id##Ty, #Ext); | ||
2358 | +#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ | ||
2359 | + if (getOpenCLOptions().isSupported(#Ext, getLangOpts())) { \ | ||
2360 | + addImplicitTypedef(#ExtType, Context.Id##Ty); \ | ||
2361 | + } | ||
2362 | #include "clang/Basic/OpenCLExtensionTypes.def" | ||
2363 | } | ||
2364 | |||
2365 | @@ -2451,114 +2451,3 @@ const llvm::MapVector<FieldDecl *, Sema::DeleteLocs> & | ||
2366 | Sema::getMismatchingDeleteExpressions() const { | ||
2367 | return DeleteExprs; | ||
2368 | } | ||
2369 | - | ||
2370 | -void Sema::setOpenCLExtensionForType(QualType T, llvm::StringRef ExtStr) { | ||
2371 | - if (ExtStr.empty()) | ||
2372 | - return; | ||
2373 | - llvm::SmallVector<StringRef, 1> Exts; | ||
2374 | - ExtStr.split(Exts, " ", /* limit */ -1, /* keep empty */ false); | ||
2375 | - auto CanT = T.getCanonicalType().getTypePtr(); | ||
2376 | - for (auto &I : Exts) | ||
2377 | - OpenCLTypeExtMap[CanT].insert(I.str()); | ||
2378 | -} | ||
2379 | - | ||
2380 | -void Sema::setOpenCLExtensionForDecl(Decl *FD, StringRef ExtStr) { | ||
2381 | - llvm::SmallVector<StringRef, 1> Exts; | ||
2382 | - ExtStr.split(Exts, " ", /* limit */ -1, /* keep empty */ false); | ||
2383 | - if (Exts.empty()) | ||
2384 | - return; | ||
2385 | - for (auto &I : Exts) | ||
2386 | - OpenCLDeclExtMap[FD].insert(I.str()); | ||
2387 | -} | ||
2388 | - | ||
2389 | -void Sema::setCurrentOpenCLExtensionForType(QualType T) { | ||
2390 | - if (CurrOpenCLExtension.empty()) | ||
2391 | - return; | ||
2392 | - setOpenCLExtensionForType(T, CurrOpenCLExtension); | ||
2393 | -} | ||
2394 | - | ||
2395 | -void Sema::setCurrentOpenCLExtensionForDecl(Decl *D) { | ||
2396 | - if (CurrOpenCLExtension.empty()) | ||
2397 | - return; | ||
2398 | - setOpenCLExtensionForDecl(D, CurrOpenCLExtension); | ||
2399 | -} | ||
2400 | - | ||
2401 | -std::string Sema::getOpenCLExtensionsFromDeclExtMap(FunctionDecl *FD) { | ||
2402 | - if (!OpenCLDeclExtMap.empty()) | ||
2403 | - return getOpenCLExtensionsFromExtMap(FD, OpenCLDeclExtMap); | ||
2404 | - | ||
2405 | - return ""; | ||
2406 | -} | ||
2407 | - | ||
2408 | -std::string Sema::getOpenCLExtensionsFromTypeExtMap(FunctionType *FT) { | ||
2409 | - if (!OpenCLTypeExtMap.empty()) | ||
2410 | - return getOpenCLExtensionsFromExtMap(FT, OpenCLTypeExtMap); | ||
2411 | - | ||
2412 | - return ""; | ||
2413 | -} | ||
2414 | - | ||
2415 | -template <typename T, typename MapT> | ||
2416 | -std::string Sema::getOpenCLExtensionsFromExtMap(T *FDT, MapT &Map) { | ||
2417 | - auto Loc = Map.find(FDT); | ||
2418 | - return llvm::join(Loc->second, " "); | ||
2419 | -} | ||
2420 | - | ||
2421 | -bool Sema::isOpenCLDisabledDecl(Decl *FD) { | ||
2422 | - auto Loc = OpenCLDeclExtMap.find(FD); | ||
2423 | - if (Loc == OpenCLDeclExtMap.end()) | ||
2424 | - return false; | ||
2425 | - for (auto &I : Loc->second) { | ||
2426 | - if (!getOpenCLOptions().isEnabled(I)) | ||
2427 | - return true; | ||
2428 | - } | ||
2429 | - return false; | ||
2430 | -} | ||
2431 | - | ||
2432 | -template <typename T, typename DiagLocT, typename DiagInfoT, typename MapT> | ||
2433 | -bool Sema::checkOpenCLDisabledTypeOrDecl(T D, DiagLocT DiagLoc, | ||
2434 | - DiagInfoT DiagInfo, MapT &Map, | ||
2435 | - unsigned Selector, | ||
2436 | - SourceRange SrcRange) { | ||
2437 | - auto Loc = Map.find(D); | ||
2438 | - if (Loc == Map.end()) | ||
2439 | - return false; | ||
2440 | - bool Disabled = false; | ||
2441 | - for (auto &I : Loc->second) { | ||
2442 | - if (I != CurrOpenCLExtension && !getOpenCLOptions().isEnabled(I)) { | ||
2443 | - Diag(DiagLoc, diag::err_opencl_requires_extension) << Selector << DiagInfo | ||
2444 | - << I << SrcRange; | ||
2445 | - Disabled = true; | ||
2446 | - } | ||
2447 | - } | ||
2448 | - return Disabled; | ||
2449 | -} | ||
2450 | - | ||
2451 | -bool Sema::checkOpenCLDisabledTypeDeclSpec(const DeclSpec &DS, QualType QT) { | ||
2452 | - // Check extensions for declared types. | ||
2453 | - Decl *Decl = nullptr; | ||
2454 | - if (auto TypedefT = dyn_cast<TypedefType>(QT.getTypePtr())) | ||
2455 | - Decl = TypedefT->getDecl(); | ||
2456 | - if (auto TagT = dyn_cast<TagType>(QT.getCanonicalType().getTypePtr())) | ||
2457 | - Decl = TagT->getDecl(); | ||
2458 | - auto Loc = DS.getTypeSpecTypeLoc(); | ||
2459 | - | ||
2460 | - // Check extensions for vector types. | ||
2461 | - // e.g. double4 is not allowed when cl_khr_fp64 is absent. | ||
2462 | - if (QT->isExtVectorType()) { | ||
2463 | - auto TypePtr = QT->castAs<ExtVectorType>()->getElementType().getTypePtr(); | ||
2464 | - return checkOpenCLDisabledTypeOrDecl(TypePtr, Loc, QT, OpenCLTypeExtMap); | ||
2465 | - } | ||
2466 | - | ||
2467 | - if (checkOpenCLDisabledTypeOrDecl(Decl, Loc, QT, OpenCLDeclExtMap)) | ||
2468 | - return true; | ||
2469 | - | ||
2470 | - // Check extensions for builtin types. | ||
2471 | - return checkOpenCLDisabledTypeOrDecl(QT.getCanonicalType().getTypePtr(), Loc, | ||
2472 | - QT, OpenCLTypeExtMap); | ||
2473 | -} | ||
2474 | - | ||
2475 | -bool Sema::checkOpenCLDisabledDecl(const NamedDecl &D, const Expr &E) { | ||
2476 | - IdentifierInfo *FnName = D.getIdentifier(); | ||
2477 | - return checkOpenCLDisabledTypeOrDecl(&D, E.getBeginLoc(), FnName, | ||
2478 | - OpenCLDeclExtMap, 1, D.getSourceRange()); | ||
2479 | -} | ||
2480 | diff --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp | ||
2481 | index 671820afd485..22ec2c7ed8bb 100644 | ||
2482 | --- a/clang/lib/Sema/SemaCast.cpp | ||
2483 | +++ b/clang/lib/Sema/SemaCast.cpp | ||
2484 | @@ -2916,8 +2916,8 @@ void CastOperation::CheckCStyleCast() { | ||
2485 | } | ||
2486 | } | ||
2487 | |||
2488 | - if (Self.getLangOpts().OpenCL && | ||
2489 | - !Self.getOpenCLOptions().isEnabled("cl_khr_fp16")) { | ||
2490 | + if (Self.getLangOpts().OpenCL && !Self.getOpenCLOptions().isAvailableOption( | ||
2491 | + "cl_khr_fp16", Self.getLangOpts())) { | ||
2492 | if (DestType->isHalfType()) { | ||
2493 | Self.Diag(SrcExpr.get()->getBeginLoc(), diag::err_opencl_cast_to_half) | ||
2494 | << DestType << SrcExpr.get()->getSourceRange(); | ||
2495 | diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp | ||
2496 | index 2b55712d44c2..b35ac5af9d75 100644 | ||
2497 | --- a/clang/lib/Sema/SemaChecking.cpp | ||
2498 | +++ b/clang/lib/Sema/SemaChecking.cpp | ||
2499 | @@ -837,7 +837,8 @@ static bool checkOpenCLBlockArgs(Sema &S, Expr *BlockArg) { | ||
2500 | } | ||
2501 | |||
2502 | static bool checkOpenCLSubgroupExt(Sema &S, CallExpr *Call) { | ||
2503 | - if (!S.getOpenCLOptions().isEnabled("cl_khr_subgroups")) { | ||
2504 | + if (!S.getOpenCLOptions().isAvailableOption("cl_khr_subgroups", | ||
2505 | + S.getLangOpts())) { | ||
2506 | S.Diag(Call->getBeginLoc(), diag::err_opencl_requires_extension) | ||
2507 | << 1 << Call->getDirectCallee() << "cl_khr_subgroups"; | ||
2508 | return true; | ||
2509 | diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp | ||
2510 | index 1f7ab49ccdd7..420ba7a5498f 100644 | ||
2511 | --- a/clang/lib/Sema/SemaDecl.cpp | ||
2512 | +++ b/clang/lib/Sema/SemaDecl.cpp | ||
2513 | @@ -5559,9 +5559,6 @@ Decl *Sema::ActOnDeclarator(Scope *S, Declarator &D) { | ||
2514 | Dcl && Dcl->getDeclContext()->isFileContext()) | ||
2515 | Dcl->setTopLevelDeclInObjCContainer(); | ||
2516 | |||
2517 | - if (getLangOpts().OpenCL) | ||
2518 | - setCurrentOpenCLExtensionForDecl(Dcl); | ||
2519 | - | ||
2520 | return Dcl; | ||
2521 | } | ||
2522 | |||
2523 | @@ -6341,7 +6338,11 @@ void Sema::deduceOpenCLAddressSpace(ValueDecl *Decl) { | ||
2524 | if (Type->isSamplerT() || Type->isVoidType()) | ||
2525 | return; | ||
2526 | LangAS ImplAS = LangAS::opencl_private; | ||
2527 | - if ((getLangOpts().OpenCLCPlusPlus || getLangOpts().OpenCLVersion >= 200) && | ||
2528 | + // OpenCL C v3.0 s6.7.8 - For OpenCL C 2.0 or with the | ||
2529 | + // __opencl_c_program_scope_global_variables feature, the address space | ||
2530 | + // for a variable at program scope or a static or extern variable inside | ||
2531 | + // a function are inferred to be __global. | ||
2532 | + if (getOpenCLOptions().areProgramScopeVariablesSupported(getLangOpts()) && | ||
2533 | Var->hasGlobalStorage()) | ||
2534 | ImplAS = LangAS::opencl_global; | ||
2535 | // If the original type from a decayed type is an array type and that array | ||
2536 | @@ -6757,7 +6758,8 @@ static bool diagnoseOpenCLTypes(Scope *S, Sema &Se, Declarator &D, | ||
2537 | } | ||
2538 | |||
2539 | // OpenCL v1.0 s6.8.a.3: Pointers to functions are not allowed. | ||
2540 | - if (!Se.getOpenCLOptions().isEnabled("__cl_clang_function_pointers")) { | ||
2541 | + if (!Se.getOpenCLOptions().isAvailableOption("__cl_clang_function_pointers", | ||
2542 | + Se.getLangOpts())) { | ||
2543 | QualType NR = R; | ||
2544 | while (NR->isPointerType() || NR->isMemberFunctionPointerType()) { | ||
2545 | if (NR->isFunctionPointerType() || NR->isMemberFunctionPointerType()) { | ||
2546 | @@ -6769,7 +6771,8 @@ static bool diagnoseOpenCLTypes(Scope *S, Sema &Se, Declarator &D, | ||
2547 | } | ||
2548 | } | ||
2549 | |||
2550 | - if (!Se.getOpenCLOptions().isEnabled("cl_khr_fp16")) { | ||
2551 | + if (!Se.getOpenCLOptions().isAvailableOption("cl_khr_fp16", | ||
2552 | + Se.getLangOpts())) { | ||
2553 | // OpenCL v1.2 s6.1.1.1: reject declaring variables of the half and | ||
2554 | // half array type (unless the cl_khr_fp16 extension is enabled). | ||
2555 | if (Se.Context.getBaseElementType(R)->isHalfType()) { | ||
2556 | @@ -7878,7 +7881,8 @@ void Sema::CheckVariableDeclarationType(VarDecl *NewVD) { | ||
2557 | // OpenCL v1.2 s6.8 - The static qualifier is valid only in program | ||
2558 | // scope. | ||
2559 | if (getLangOpts().OpenCLVersion == 120 && | ||
2560 | - !getOpenCLOptions().isEnabled("cl_clang_storage_class_specifiers") && | ||
2561 | + !getOpenCLOptions().isAvailableOption("cl_clang_storage_class_specifiers", | ||
2562 | + getLangOpts()) && | ||
2563 | NewVD->isStaticLocal()) { | ||
2564 | Diag(NewVD->getLocation(), diag::err_static_function_scope); | ||
2565 | NewVD->setInvalidDecl(); | ||
2566 | @@ -7907,23 +7911,16 @@ void Sema::CheckVariableDeclarationType(VarDecl *NewVD) { | ||
2567 | return; | ||
2568 | } | ||
2569 | } | ||
2570 | - // OpenCL C v1.2 s6.5 - All program scope variables must be declared in the | ||
2571 | - // __constant address space. | ||
2572 | - // OpenCL C v2.0 s6.5.1 - Variables defined at program scope and static | ||
2573 | - // variables inside a function can also be declared in the global | ||
2574 | - // address space. | ||
2575 | - // C++ for OpenCL inherits rule from OpenCL C v2.0. | ||
2576 | // FIXME: Adding local AS in C++ for OpenCL might make sense. | ||
2577 | if (NewVD->isFileVarDecl() || NewVD->isStaticLocal() || | ||
2578 | NewVD->hasExternalStorage()) { | ||
2579 | - if (!T->isSamplerT() && | ||
2580 | - !T->isDependentType() && | ||
2581 | + if (!T->isSamplerT() && !T->isDependentType() && | ||
2582 | !(T.getAddressSpace() == LangAS::opencl_constant || | ||
2583 | (T.getAddressSpace() == LangAS::opencl_global && | ||
2584 | - (getLangOpts().OpenCLVersion == 200 || | ||
2585 | - getLangOpts().OpenCLCPlusPlus)))) { | ||
2586 | + getOpenCLOptions().areProgramScopeVariablesSupported( | ||
2587 | + getLangOpts())))) { | ||
2588 | int Scope = NewVD->isStaticLocal() | NewVD->hasExternalStorage() << 1; | ||
2589 | - if (getLangOpts().OpenCLVersion == 200 || getLangOpts().OpenCLCPlusPlus) | ||
2590 | + if (getOpenCLOptions().areProgramScopeVariablesSupported(getLangOpts())) | ||
2591 | Diag(NewVD->getLocation(), diag::err_opencl_global_invalid_addr_space) | ||
2592 | << Scope << "global or constant"; | ||
2593 | else | ||
2594 | @@ -8650,7 +8647,8 @@ static OpenCLParamType getOpenCLKernelParameterType(Sema &S, QualType PT) { | ||
2595 | // OpenCL extension spec v1.2 s9.5: | ||
2596 | // This extension adds support for half scalar and vector types as built-in | ||
2597 | // types that can be used for arithmetic operations, conversions etc. | ||
2598 | - if (!S.getOpenCLOptions().isEnabled("cl_khr_fp16") && PT->isHalfType()) | ||
2599 | + if (!S.getOpenCLOptions().isAvailableOption("cl_khr_fp16", S.getLangOpts()) && | ||
2600 | + PT->isHalfType()) | ||
2601 | return InvalidKernelParam; | ||
2602 | |||
2603 | if (PT->isRecordType()) | ||
2604 | diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp | ||
2605 | index 30d08b3d4ac0..a06fcfb8cc22 100644 | ||
2606 | --- a/clang/lib/Sema/SemaDeclAttr.cpp | ||
2607 | +++ b/clang/lib/Sema/SemaDeclAttr.cpp | ||
2608 | @@ -7308,16 +7308,21 @@ static void handleOpenCLAccessAttr(Sema &S, Decl *D, const ParsedAttr &AL) { | ||
2609 | } | ||
2610 | } | ||
2611 | |||
2612 | - // OpenCL v2.0 s6.6 - read_write can be used for image types to specify that an | ||
2613 | - // image object can be read and written. | ||
2614 | - // OpenCL v2.0 s6.13.6 - A kernel cannot read from and write to the same pipe | ||
2615 | - // object. Using the read_write (or __read_write) qualifier with the pipe | ||
2616 | - // qualifier is a compilation error. | ||
2617 | + // OpenCL v2.0 s6.6 - read_write can be used for image types to specify that | ||
2618 | + // an image object can be read and written. OpenCL v2.0 s6.13.6 - A kernel | ||
2619 | + // cannot read from and write to the same pipe object. Using the read_write | ||
2620 | + // (or __read_write) qualifier with the pipe qualifier is a compilation error. | ||
2621 | + // OpenCL v3.0 s6.8 - For OpenCL C 2.0, or with the | ||
2622 | + // __opencl_c_read_write_images feature, image objects specified as arguments | ||
2623 | + // to a kernel can additionally be declared to be read-write. | ||
2624 | if (const auto *PDecl = dyn_cast<ParmVarDecl>(D)) { | ||
2625 | const Type *DeclTy = PDecl->getType().getCanonicalType().getTypePtr(); | ||
2626 | if (AL.getAttrName()->getName().find("read_write") != StringRef::npos) { | ||
2627 | if ((!S.getLangOpts().OpenCLCPlusPlus && | ||
2628 | - S.getLangOpts().OpenCLVersion < 200) || | ||
2629 | + (S.getLangOpts().OpenCLVersion < 200) || | ||
2630 | + (S.getLangOpts().OpenCLVersion == 300 && | ||
2631 | + !S.getOpenCLOptions().isSupported("__opencl_c_read_write_images", | ||
2632 | + S.getLangOpts()))) || | ||
2633 | DeclTy->isPipeType()) { | ||
2634 | S.Diag(AL.getLoc(), diag::err_opencl_invalid_read_write) | ||
2635 | << AL << PDecl->getType() << DeclTy->isImageType(); | ||
2636 | diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp | ||
2637 | index ae8508d6c601..cc29938c5ea5 100644 | ||
2638 | --- a/clang/lib/Sema/SemaExpr.cpp | ||
2639 | +++ b/clang/lib/Sema/SemaExpr.cpp | ||
2640 | @@ -657,7 +657,8 @@ ExprResult Sema::DefaultLvalueConversion(Expr *E) { | ||
2641 | return E; | ||
2642 | |||
2643 | // OpenCL usually rejects direct accesses to values of 'half' type. | ||
2644 | - if (getLangOpts().OpenCL && !getOpenCLOptions().isEnabled("cl_khr_fp16") && | ||
2645 | + if (getLangOpts().OpenCL && | ||
2646 | + !getOpenCLOptions().isAvailableOption("cl_khr_fp16", getLangOpts()) && | ||
2647 | T->isHalfType()) { | ||
2648 | Diag(E->getExprLoc(), diag::err_opencl_half_load_store) | ||
2649 | << 0 << T; | ||
2650 | @@ -829,10 +830,10 @@ ExprResult Sema::DefaultArgumentPromotion(Expr *E) { | ||
2651 | if (BTy && (BTy->getKind() == BuiltinType::Half || | ||
2652 | BTy->getKind() == BuiltinType::Float)) { | ||
2653 | if (getLangOpts().OpenCL && | ||
2654 | - !getOpenCLOptions().isEnabled("cl_khr_fp64")) { | ||
2655 | - if (BTy->getKind() == BuiltinType::Half) { | ||
2656 | - E = ImpCastExprToType(E, Context.FloatTy, CK_FloatingCast).get(); | ||
2657 | - } | ||
2658 | + !getOpenCLOptions().isAvailableOption("cl_khr_fp64", getLangOpts())) { | ||
2659 | + if (BTy->getKind() == BuiltinType::Half) { | ||
2660 | + E = ImpCastExprToType(E, Context.FloatTy, CK_FloatingCast).get(); | ||
2661 | + } | ||
2662 | } else { | ||
2663 | E = ImpCastExprToType(E, Context.DoubleTy, CK_FloatingCast).get(); | ||
2664 | } | ||
2665 | @@ -3819,7 +3820,7 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) { | ||
2666 | } else if (Literal.isFloatingLiteral()) { | ||
2667 | QualType Ty; | ||
2668 | if (Literal.isHalf){ | ||
2669 | - if (getOpenCLOptions().isEnabled("cl_khr_fp16")) | ||
2670 | + if (getOpenCLOptions().isAvailableOption("cl_khr_fp16", getLangOpts())) | ||
2671 | Ty = Context.HalfTy; | ||
2672 | else { | ||
2673 | Diag(Tok.getLocation(), diag::err_half_const_requires_fp16); | ||
2674 | @@ -3843,10 +3844,11 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) { | ||
2675 | if (Ty->castAs<BuiltinType>()->getKind() != BuiltinType::Float) { | ||
2676 | Res = ImpCastExprToType(Res, Context.FloatTy, CK_FloatingCast).get(); | ||
2677 | } | ||
2678 | - } else if (getLangOpts().OpenCL && | ||
2679 | - !getOpenCLOptions().isEnabled("cl_khr_fp64")) { | ||
2680 | + } else if (getLangOpts().OpenCL && !getOpenCLOptions().isAvailableOption( | ||
2681 | + "cl_khr_fp64", getLangOpts())) { | ||
2682 | // Impose single-precision float type when cl_khr_fp64 is not enabled. | ||
2683 | - Diag(Tok.getLocation(), diag::warn_double_const_requires_fp64); | ||
2684 | + Diag(Tok.getLocation(), diag::warn_double_const_requires_fp64) | ||
2685 | + << (getLangOpts().OpenCLVersion >= 300); | ||
2686 | Res = ImpCastExprToType(Res, Context.FloatTy, CK_FloatingCast).get(); | ||
2687 | } | ||
2688 | } | ||
2689 | @@ -6468,9 +6470,6 @@ ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, SourceLocation LParenLoc, | ||
2690 | FD, /*Complain=*/true, Fn->getBeginLoc())) | ||
2691 | return ExprError(); | ||
2692 | |||
2693 | - if (getLangOpts().OpenCL && checkOpenCLDisabledDecl(*FD, *Fn)) | ||
2694 | - return ExprError(); | ||
2695 | - | ||
2696 | checkDirectCallValidity(*this, Fn, FD, ArgExprs); | ||
2697 | } | ||
2698 | |||
2699 | @@ -12900,7 +12899,8 @@ QualType Sema::CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS, | ||
2700 | // OpenCL v1.2 s6.1.1.1 p2: | ||
2701 | // The half data type can only be used to declare a pointer to a buffer that | ||
2702 | // contains half values | ||
2703 | - if (getLangOpts().OpenCL && !getOpenCLOptions().isEnabled("cl_khr_fp16") && | ||
2704 | + if (getLangOpts().OpenCL && | ||
2705 | + !getOpenCLOptions().isAvailableOption("cl_khr_fp16", getLangOpts()) && | ||
2706 | LHSType->isHalfType()) { | ||
2707 | Diag(Loc, diag::err_opencl_half_load_store) << 1 | ||
2708 | << LHSType.getUnqualifiedType(); | ||
2709 | diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp | ||
2710 | index f4493d84238d..0e4259bfce09 100644 | ||
2711 | --- a/clang/lib/Sema/SemaInit.cpp | ||
2712 | +++ b/clang/lib/Sema/SemaInit.cpp | ||
2713 | @@ -5572,8 +5572,8 @@ static bool TryOCLZeroOpaqueTypeInitialization(Sema &S, | ||
2714 | // We should allow zero initialization for all types defined in the | ||
2715 | // cl_intel_device_side_avc_motion_estimation extension, except | ||
2716 | // intel_sub_group_avc_mce_payload_t and intel_sub_group_avc_mce_result_t. | ||
2717 | - if (S.getOpenCLOptions().isEnabled( | ||
2718 | - "cl_intel_device_side_avc_motion_estimation") && | ||
2719 | + if (S.getOpenCLOptions().isAvailableOption( | ||
2720 | + "cl_intel_device_side_avc_motion_estimation", S.getLangOpts()) && | ||
2721 | DestType->isOCLIntelSubgroupAVCType()) { | ||
2722 | if (DestType->isOCLIntelSubgroupAVCMcePayloadType() || | ||
2723 | DestType->isOCLIntelSubgroupAVCMceResultType()) | ||
2724 | @@ -8758,8 +8758,8 @@ ExprResult InitializationSequence::Perform(Sema &S, | ||
2725 | unsigned AddressingMode = (0x0E & SamplerValue) >> 1; | ||
2726 | unsigned FilterMode = (0x30 & SamplerValue) >> 4; | ||
2727 | if (FilterMode != 1 && FilterMode != 2 && | ||
2728 | - !S.getOpenCLOptions().isEnabled( | ||
2729 | - "cl_intel_device_side_avc_motion_estimation")) | ||
2730 | + !S.getOpenCLOptions().isAvailableOption( | ||
2731 | + "cl_intel_device_side_avc_motion_estimation", S.getLangOpts())) | ||
2732 | S.Diag(Kind.getLocation(), | ||
2733 | diag::warn_sampler_initializer_invalid_bits) | ||
2734 | << "Filter Mode"; | ||
2735 | diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp | ||
2736 | index 29038ab9fe1c..12f58556c9dd 100644 | ||
2737 | --- a/clang/lib/Sema/SemaLookup.cpp | ||
2738 | +++ b/clang/lib/Sema/SemaLookup.cpp | ||
2739 | @@ -743,18 +743,6 @@ static void GetOpenCLBuiltinFctOverloads( | ||
2740 | } | ||
2741 | } | ||
2742 | |||
2743 | -/// Add extensions to the function declaration. | ||
2744 | -/// \param S (in/out) The Sema instance. | ||
2745 | -/// \param BIDecl (in) Description of the builtin. | ||
2746 | -/// \param FDecl (in/out) FunctionDecl instance. | ||
2747 | -static void AddOpenCLExtensions(Sema &S, const OpenCLBuiltinStruct &BIDecl, | ||
2748 | - FunctionDecl *FDecl) { | ||
2749 | - // Fetch extension associated with a function prototype. | ||
2750 | - StringRef E = FunctionExtensionTable[BIDecl.Extension]; | ||
2751 | - if (E != "") | ||
2752 | - S.setOpenCLExtensionForDecl(FDecl, E); | ||
2753 | -} | ||
2754 | - | ||
2755 | /// When trying to resolve a function name, if isOpenCLBuiltin() returns a | ||
2756 | /// non-null <Index, Len> pair, then the name is referencing an OpenCL | ||
2757 | /// builtin function. Add all candidate signatures to the LookUpResult. | ||
2758 | @@ -789,7 +777,13 @@ static void InsertOCLBuiltinDeclarationsFromTable(Sema &S, LookupResult &LR, | ||
2759 | if ((OpenCLBuiltin.MaxVersion != 0) && | ||
2760 | (OpenCLVersion >= OpenCLBuiltin.MaxVersion)) | ||
2761 | continue; | ||
2762 | - | ||
2763 | + | ||
2764 | + // Ignore this builtin function if it carries an extension macro that is | ||
2765 | + // not defined. This indicates that the extension is not supported by the | ||
2766 | + // target, so the builtin function should not be available. | ||
2767 | + StringRef Ext = FunctionExtensionTable[OpenCLBuiltin.Extension]; | ||
2768 | + if (!Ext.empty() && !S.getPreprocessor().isMacroDefined(Ext)) | ||
2769 | + continue; | ||
2770 | SmallVector<QualType, 1> RetTypes; | ||
2771 | SmallVector<SmallVector<QualType, 1>, 5> ArgTypes; | ||
2772 | |||
2773 | @@ -843,8 +837,6 @@ static void InsertOCLBuiltinDeclarationsFromTable(Sema &S, LookupResult &LR, | ||
2774 | if (!S.getLangOpts().OpenCLCPlusPlus) | ||
2775 | NewOpenCLBuiltin->addAttr(OverloadableAttr::CreateImplicit(Context)); | ||
2776 | |||
2777 | - AddOpenCLExtensions(S, OpenCLBuiltin, NewOpenCLBuiltin); | ||
2778 | - | ||
2779 | LR.addDecl(NewOpenCLBuiltin); | ||
2780 | } | ||
2781 | } | ||
2782 | diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp | ||
2783 | index 7fe7466725fa..05815bb6e38d 100644 | ||
2784 | --- a/clang/lib/Sema/SemaOverload.cpp | ||
2785 | +++ b/clang/lib/Sema/SemaOverload.cpp | ||
2786 | @@ -6479,12 +6479,6 @@ void Sema::AddOverloadCandidate( | ||
2787 | Candidate.DeductionFailure.Data = FailedAttr; | ||
2788 | return; | ||
2789 | } | ||
2790 | - | ||
2791 | - if (LangOpts.OpenCL && isOpenCLDisabledDecl(Function)) { | ||
2792 | - Candidate.Viable = false; | ||
2793 | - Candidate.FailureKind = ovl_fail_ext_disabled; | ||
2794 | - return; | ||
2795 | - } | ||
2796 | } | ||
2797 | |||
2798 | ObjCMethodDecl * | ||
2799 | @@ -11092,14 +11086,6 @@ static void DiagnoseFailedExplicitSpec(Sema &S, OverloadCandidate *Cand) { | ||
2800 | << (ES.getExpr() ? ES.getExpr()->getSourceRange() : SourceRange()); | ||
2801 | } | ||
2802 | |||
2803 | -static void DiagnoseOpenCLExtensionDisabled(Sema &S, OverloadCandidate *Cand) { | ||
2804 | - FunctionDecl *Callee = Cand->Function; | ||
2805 | - | ||
2806 | - S.Diag(Callee->getLocation(), | ||
2807 | - diag::note_ovl_candidate_disabled_by_extension) | ||
2808 | - << S.getOpenCLExtensionsFromDeclExtMap(Callee); | ||
2809 | -} | ||
2810 | - | ||
2811 | /// Generates a 'note' diagnostic for an overload candidate. We've | ||
2812 | /// already generated a primary error at the call site. | ||
2813 | /// | ||
2814 | @@ -11195,9 +11181,6 @@ static void NoteFunctionCandidate(Sema &S, OverloadCandidate *Cand, | ||
2815 | case ovl_fail_explicit: | ||
2816 | return DiagnoseFailedExplicitSpec(S, Cand); | ||
2817 | |||
2818 | - case ovl_fail_ext_disabled: | ||
2819 | - return DiagnoseOpenCLExtensionDisabled(S, Cand); | ||
2820 | - | ||
2821 | case ovl_fail_inhctor_slice: | ||
2822 | // It's generally not interesting to note copy/move constructors here. | ||
2823 | if (cast<CXXConstructorDecl>(Fn)->isCopyOrMoveConstructor()) | ||
2824 | diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp | ||
2825 | index 4178024d1264..e44a25c6aead 100644 | ||
2826 | --- a/clang/lib/Sema/SemaType.cpp | ||
2827 | +++ b/clang/lib/Sema/SemaType.cpp | ||
2828 | @@ -1548,6 +1548,16 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) { | ||
2829 | Result = Context.LongDoubleTy; | ||
2830 | else | ||
2831 | Result = Context.DoubleTy; | ||
2832 | + if (S.getLangOpts().OpenCL) { | ||
2833 | + if (!S.getOpenCLOptions().isSupported("cl_khr_fp64", S.getLangOpts())) | ||
2834 | + S.Diag(DS.getTypeSpecTypeLoc(), diag::err_opencl_requires_extension) | ||
2835 | + << 0 << Result | ||
2836 | + << (S.getLangOpts().OpenCLVersion == 300 | ||
2837 | + ? "cl_khr_fp64 and __opencl_c_fp64" | ||
2838 | + : "cl_khr_fp64"); | ||
2839 | + else if (!S.getOpenCLOptions().isAvailableOption("cl_khr_fp64", S.getLangOpts())) | ||
2840 | + S.Diag(DS.getTypeSpecTypeLoc(), diag::ext_opencl_double_without_pragma); | ||
2841 | + } | ||
2842 | break; | ||
2843 | case DeclSpec::TST_float128: | ||
2844 | if (!S.Context.getTargetInfo().hasFloat128Type() && | ||
2845 | @@ -1723,10 +1733,33 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) { | ||
2846 | if (Result->containsErrors()) | ||
2847 | declarator.setInvalidType(); | ||
2848 | |||
2849 | - if (S.getLangOpts().OpenCL && | ||
2850 | - S.checkOpenCLDisabledTypeDeclSpec(DS, Result)) | ||
2851 | - declarator.setInvalidType(true); | ||
2852 | - | ||
2853 | + if (S.getLangOpts().OpenCL) { | ||
2854 | + const auto &OpenCLOptions = S.getOpenCLOptions(); | ||
2855 | + bool IsOpenCLC30 = (S.getLangOpts().OpenCLVersion == 300); | ||
2856 | + // OpenCL C v3.0 s6.3.3 - OpenCL image types require __opencl_c_images | ||
2857 | + // support. | ||
2858 | + // OpenCL C v3.0 s6.2.1 - OpenCL 3d image write types requires support | ||
2859 | + // for OpenCL C 2.0, or OpenCL C 3.0 or newer and the | ||
2860 | + // __opencl_c_3d_image_writes feature. OpenCL C v3.0 API s4.2 - For devices | ||
2861 | + // that support OpenCL 3.0, cl_khr_3d_image_writes must be returned when and | ||
2862 | + // only when the optional feature is supported | ||
2863 | + if ((Result->isImageType() || Result->isSamplerT()) && | ||
2864 | + (IsOpenCLC30 && | ||
2865 | + !OpenCLOptions.isSupported("__opencl_c_images", S.getLangOpts()))) { | ||
2866 | + S.Diag(DS.getTypeSpecTypeLoc(), diag::err_opencl_requires_extension) | ||
2867 | + << 0 << Result << "__opencl_c_images"; | ||
2868 | + declarator.setInvalidType(); | ||
2869 | + } else if (Result->isOCLImage3dWOType() && | ||
2870 | + !OpenCLOptions.isSupported("cl_khr_3d_image_writes", | ||
2871 | + S.getLangOpts())) { | ||
2872 | + S.Diag(DS.getTypeSpecTypeLoc(), diag::err_opencl_requires_extension) | ||
2873 | + << 0 << Result | ||
2874 | + << (IsOpenCLC30 | ||
2875 | + ? "cl_khr_3d_image_writes and __opencl_c_3d_image_writes" | ||
2876 | + : "cl_khr_3d_image_writes"); | ||
2877 | + declarator.setInvalidType(); | ||
2878 | + } | ||
2879 | + } | ||
2880 | bool IsFixedPointType = DS.getTypeSpecType() == DeclSpec::TST_accum || | ||
2881 | DS.getTypeSpecType() == DeclSpec::TST_fract; | ||
2882 | |||
2883 | @@ -2060,8 +2093,7 @@ static QualType deduceOpenCLPointeeAddrSpace(Sema &S, QualType PointeeType) { | ||
2884 | !PointeeType->isSamplerT() && | ||
2885 | !PointeeType.hasAddressSpace()) | ||
2886 | PointeeType = S.getASTContext().getAddrSpaceQualType( | ||
2887 | - PointeeType, | ||
2888 | - S.getLangOpts().OpenCLCPlusPlus || S.getLangOpts().OpenCLVersion == 200 | ||
2889 | + PointeeType, S.getLangOpts().OpenCLGenericAddressSpace | ||
2890 | ? LangAS::opencl_generic | ||
2891 | : LangAS::opencl_private); | ||
2892 | return PointeeType; | ||
2893 | @@ -2090,7 +2122,8 @@ QualType Sema::BuildPointerType(QualType T, | ||
2894 | } | ||
2895 | |||
2896 | if (T->isFunctionType() && getLangOpts().OpenCL && | ||
2897 | - !getOpenCLOptions().isEnabled("__cl_clang_function_pointers")) { | ||
2898 | + !getOpenCLOptions().isAvailableOption("__cl_clang_function_pointers", | ||
2899 | + getLangOpts())) { | ||
2900 | Diag(Loc, diag::err_opencl_function_pointer); | ||
2901 | return QualType(); | ||
2902 | } | ||
2903 | @@ -4994,7 +5027,8 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, | ||
2904 | // FIXME: This really should be in BuildFunctionType. | ||
2905 | if (T->isHalfType()) { | ||
2906 | if (S.getLangOpts().OpenCL) { | ||
2907 | - if (!S.getOpenCLOptions().isEnabled("cl_khr_fp16")) { | ||
2908 | + if (!S.getOpenCLOptions().isAvailableOption("cl_khr_fp16", | ||
2909 | + S.getLangOpts())) { | ||
2910 | S.Diag(D.getIdentifierLoc(), diag::err_opencl_invalid_return) | ||
2911 | << T << 0 /*pointer hint*/; | ||
2912 | D.setInvalidType(true); | ||
2913 | @@ -5019,7 +5053,8 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, | ||
2914 | // (s6.9.e and s6.12.5 OpenCL v2.0) except for printf. | ||
2915 | // We also allow here any toolchain reserved identifiers. | ||
2916 | if (FTI.isVariadic && | ||
2917 | - !S.getOpenCLOptions().isEnabled("__cl_clang_variadic_functions") && | ||
2918 | + !S.getOpenCLOptions().isAvailableOption( | ||
2919 | + "__cl_clang_variadic_functions", S.getLangOpts()) && | ||
2920 | !(D.getIdentifier() && | ||
2921 | ((D.getIdentifier()->getName() == "printf" && | ||
2922 | (LangOpts.OpenCLCPlusPlus || LangOpts.OpenCLVersion >= 120)) || | ||
2923 | @@ -5214,7 +5249,8 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, | ||
2924 | // Disallow half FP parameters. | ||
2925 | // FIXME: This really should be in BuildFunctionType. | ||
2926 | if (S.getLangOpts().OpenCL) { | ||
2927 | - if (!S.getOpenCLOptions().isEnabled("cl_khr_fp16")) { | ||
2928 | + if (!S.getOpenCLOptions().isAvailableOption("cl_khr_fp16", | ||
2929 | + S.getLangOpts())) { | ||
2930 | S.Diag(Param->getLocation(), diag::err_opencl_invalid_param) | ||
2931 | << ParamTy << 0; | ||
2932 | D.setInvalidType(); | ||
2933 | diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp | ||
2934 | index 1f68f6bc3e38..aa5eaf7fe2dc 100644 | ||
2935 | --- a/clang/lib/Serialization/ASTReader.cpp | ||
2936 | +++ b/clang/lib/Serialization/ASTReader.cpp | ||
2937 | @@ -3611,36 +3611,13 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { | ||
2938 | auto &OptInfo = OpenCLExtensions.OptMap[Name]; | ||
2939 | OptInfo.Supported = Record[I++] != 0; | ||
2940 | OptInfo.Enabled = Record[I++] != 0; | ||
2941 | + OptInfo.WithPragma = Record[I++] != 0; | ||
2942 | OptInfo.Avail = Record[I++]; | ||
2943 | OptInfo.Core = Record[I++]; | ||
2944 | OptInfo.Opt = Record[I++]; | ||
2945 | } | ||
2946 | break; | ||
2947 | |||
2948 | - case OPENCL_EXTENSION_TYPES: | ||
2949 | - for (unsigned I = 0, E = Record.size(); I != E;) { | ||
2950 | - auto TypeID = static_cast<::TypeID>(Record[I++]); | ||
2951 | - auto *Type = GetType(TypeID).getTypePtr(); | ||
2952 | - auto NumExt = static_cast<unsigned>(Record[I++]); | ||
2953 | - for (unsigned II = 0; II != NumExt; ++II) { | ||
2954 | - auto Ext = ReadString(Record, I); | ||
2955 | - OpenCLTypeExtMap[Type].insert(Ext); | ||
2956 | - } | ||
2957 | - } | ||
2958 | - break; | ||
2959 | - | ||
2960 | - case OPENCL_EXTENSION_DECLS: | ||
2961 | - for (unsigned I = 0, E = Record.size(); I != E;) { | ||
2962 | - auto DeclID = static_cast<::DeclID>(Record[I++]); | ||
2963 | - auto *Decl = GetDecl(DeclID); | ||
2964 | - auto NumExt = static_cast<unsigned>(Record[I++]); | ||
2965 | - for (unsigned II = 0; II != NumExt; ++II) { | ||
2966 | - auto Ext = ReadString(Record, I); | ||
2967 | - OpenCLDeclExtMap[Decl].insert(Ext); | ||
2968 | - } | ||
2969 | - } | ||
2970 | - break; | ||
2971 | - | ||
2972 | case TENTATIVE_DEFINITIONS: | ||
2973 | for (unsigned I = 0, N = Record.size(); I != N; ++I) | ||
2974 | TentativeDefinitions.push_back(getGlobalDeclID(F, Record[I])); | ||
2975 | @@ -7869,8 +7846,6 @@ void ASTReader::InitializeSema(Sema &S) { | ||
2976 | } | ||
2977 | |||
2978 | SemaObj->OpenCLFeatures = OpenCLExtensions; | ||
2979 | - SemaObj->OpenCLTypeExtMap = OpenCLTypeExtMap; | ||
2980 | - SemaObj->OpenCLDeclExtMap = OpenCLDeclExtMap; | ||
2981 | |||
2982 | UpdateSema(); | ||
2983 | } | ||
2984 | diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp | ||
2985 | index 40900af6f9e0..d6e5269d24fd 100644 | ||
2986 | --- a/clang/lib/Serialization/ASTWriter.cpp | ||
2987 | +++ b/clang/lib/Serialization/ASTWriter.cpp | ||
2988 | @@ -3976,6 +3976,7 @@ void ASTWriter::WriteOpenCLExtensions(Sema &SemaRef) { | ||
2989 | auto V = I.getValue(); | ||
2990 | Record.push_back(V.Supported ? 1 : 0); | ||
2991 | Record.push_back(V.Enabled ? 1 : 0); | ||
2992 | + Record.push_back(V.WithPragma ? 1 : 0); | ||
2993 | Record.push_back(V.Avail); | ||
2994 | Record.push_back(V.Core); | ||
2995 | Record.push_back(V.Opt); | ||
2996 | @@ -3983,71 +3984,6 @@ void ASTWriter::WriteOpenCLExtensions(Sema &SemaRef) { | ||
2997 | Stream.EmitRecord(OPENCL_EXTENSIONS, Record); | ||
2998 | } | ||
2999 | |||
3000 | -void ASTWriter::WriteOpenCLExtensionTypes(Sema &SemaRef) { | ||
3001 | - if (!SemaRef.Context.getLangOpts().OpenCL) | ||
3002 | - return; | ||
3003 | - | ||
3004 | - // Sort the elements of the map OpenCLTypeExtMap by TypeIDs, | ||
3005 | - // without copying them. | ||
3006 | - const llvm::DenseMap<const Type *, std::set<std::string>> &OpenCLTypeExtMap = | ||
3007 | - SemaRef.OpenCLTypeExtMap; | ||
3008 | - using ElementTy = std::pair<TypeID, const std::set<std::string> *>; | ||
3009 | - llvm::SmallVector<ElementTy, 8> StableOpenCLTypeExtMap; | ||
3010 | - StableOpenCLTypeExtMap.reserve(OpenCLTypeExtMap.size()); | ||
3011 | - | ||
3012 | - for (const auto &I : OpenCLTypeExtMap) | ||
3013 | - StableOpenCLTypeExtMap.emplace_back( | ||
3014 | - getTypeID(I.first->getCanonicalTypeInternal()), &I.second); | ||
3015 | - | ||
3016 | - auto CompareByTypeID = [](const ElementTy &E1, const ElementTy &E2) -> bool { | ||
3017 | - return E1.first < E2.first; | ||
3018 | - }; | ||
3019 | - llvm::sort(StableOpenCLTypeExtMap, CompareByTypeID); | ||
3020 | - | ||
3021 | - RecordData Record; | ||
3022 | - for (const ElementTy &E : StableOpenCLTypeExtMap) { | ||
3023 | - Record.push_back(E.first); // TypeID | ||
3024 | - const std::set<std::string> *ExtSet = E.second; | ||
3025 | - Record.push_back(static_cast<unsigned>(ExtSet->size())); | ||
3026 | - for (const std::string &Ext : *ExtSet) | ||
3027 | - AddString(Ext, Record); | ||
3028 | - } | ||
3029 | - | ||
3030 | - Stream.EmitRecord(OPENCL_EXTENSION_TYPES, Record); | ||
3031 | -} | ||
3032 | - | ||
3033 | -void ASTWriter::WriteOpenCLExtensionDecls(Sema &SemaRef) { | ||
3034 | - if (!SemaRef.Context.getLangOpts().OpenCL) | ||
3035 | - return; | ||
3036 | - | ||
3037 | - // Sort the elements of the map OpenCLDeclExtMap by DeclIDs, | ||
3038 | - // without copying them. | ||
3039 | - const llvm::DenseMap<const Decl *, std::set<std::string>> &OpenCLDeclExtMap = | ||
3040 | - SemaRef.OpenCLDeclExtMap; | ||
3041 | - using ElementTy = std::pair<DeclID, const std::set<std::string> *>; | ||
3042 | - llvm::SmallVector<ElementTy, 8> StableOpenCLDeclExtMap; | ||
3043 | - StableOpenCLDeclExtMap.reserve(OpenCLDeclExtMap.size()); | ||
3044 | - | ||
3045 | - for (const auto &I : OpenCLDeclExtMap) | ||
3046 | - StableOpenCLDeclExtMap.emplace_back(getDeclID(I.first), &I.second); | ||
3047 | - | ||
3048 | - auto CompareByDeclID = [](const ElementTy &E1, const ElementTy &E2) -> bool { | ||
3049 | - return E1.first < E2.first; | ||
3050 | - }; | ||
3051 | - llvm::sort(StableOpenCLDeclExtMap, CompareByDeclID); | ||
3052 | - | ||
3053 | - RecordData Record; | ||
3054 | - for (const ElementTy &E : StableOpenCLDeclExtMap) { | ||
3055 | - Record.push_back(E.first); // DeclID | ||
3056 | - const std::set<std::string> *ExtSet = E.second; | ||
3057 | - Record.push_back(static_cast<unsigned>(ExtSet->size())); | ||
3058 | - for (const std::string &Ext : *ExtSet) | ||
3059 | - AddString(Ext, Record); | ||
3060 | - } | ||
3061 | - | ||
3062 | - Stream.EmitRecord(OPENCL_EXTENSION_DECLS, Record); | ||
3063 | -} | ||
3064 | - | ||
3065 | void ASTWriter::WriteCUDAPragmas(Sema &SemaRef) { | ||
3066 | if (SemaRef.ForceCUDAHostDeviceDepth > 0) { | ||
3067 | RecordData::value_type Record[] = {SemaRef.ForceCUDAHostDeviceDepth}; | ||
3068 | @@ -4792,17 +4728,12 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot, | ||
3069 | WriteIdentifierTable(PP, SemaRef.IdResolver, isModule); | ||
3070 | WriteFPPragmaOptions(SemaRef.CurFPFeatureOverrides()); | ||
3071 | WriteOpenCLExtensions(SemaRef); | ||
3072 | - WriteOpenCLExtensionTypes(SemaRef); | ||
3073 | WriteCUDAPragmas(SemaRef); | ||
3074 | |||
3075 | // If we're emitting a module, write out the submodule information. | ||
3076 | if (WritingModule) | ||
3077 | WriteSubmodules(WritingModule); | ||
3078 | |||
3079 | - // We need to have information about submodules to correctly deserialize | ||
3080 | - // decls from OpenCLExtensionDecls block | ||
3081 | - WriteOpenCLExtensionDecls(SemaRef); | ||
3082 | - | ||
3083 | Stream.EmitRecord(SPECIAL_TYPES, SpecialTypes); | ||
3084 | |||
3085 | // Write the record containing external, unnamed definitions. | ||
3086 | diff --git a/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl b/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl | ||
3087 | index 21e0f2b05747..d24c9c5f85a4 100644 | ||
3088 | --- a/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl | ||
3089 | +++ b/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl | ||
3090 | @@ -2,6 +2,8 @@ | ||
3091 | // RUN: %clang_cc1 %s -emit-llvm -o - -O0 -triple amdgcn | FileCheck -enable-var-scope -check-prefixes=ALL,AMDGCN %s | ||
3092 | // RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL2.0 -O0 -triple amdgcn | FileCheck -enable-var-scope -check-prefixes=ALL,AMDGCN,AMDGCN20 %s | ||
3093 | // RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL1.2 -O0 -triple spir-unknown-unknown-unknown | FileCheck -enable-var-scope -check-prefixes=SPIR %s | ||
3094 | +// RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL3.0 -O0 -triple amdgcn -cl-ext=+__opencl_c_program_scope_global_variables | FileCheck -enable-var-scope -check-prefixes=ALL,AMDGCN,AMDGCN20 %s | ||
3095 | +// RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL3.0 -O0 -triple amdgcn | FileCheck -enable-var-scope -check-prefixes=ALL,AMDGCN %s | ||
3096 | |||
3097 | typedef int int2 __attribute__((ext_vector_type(2))); | ||
3098 | |||
3099 | @@ -39,7 +41,7 @@ struct LargeStructTwoMember { | ||
3100 | int2 y[20]; | ||
3101 | }; | ||
3102 | |||
3103 | -#if __OPENCL_C_VERSION__ >= 200 | ||
3104 | +#if (__OPENCL_C_VERSION__ == 200) || (__OPENCL_C_VERSION__ >= 300 && defined(__opencl_c_program_scope_global_variables)) | ||
3105 | struct LargeStructOneMember g_s; | ||
3106 | #endif | ||
3107 | |||
3108 | @@ -98,7 +100,7 @@ void FuncOneLargeMember(struct LargeStructOneMember u) { | ||
3109 | // AMDGCN20: %[[r0:.*]] = bitcast %struct.LargeStructOneMember addrspace(5)* %[[byval_temp]] to i8 addrspace(5)* | ||
3110 | // AMDGCN20: call void @llvm.memcpy.p5i8.p1i8.i64(i8 addrspace(5)* align 8 %[[r0]], i8 addrspace(1)* align 8 bitcast (%struct.LargeStructOneMember addrspace(1)* @g_s to i8 addrspace(1)*), i64 800, i1 false) | ||
3111 | // AMDGCN20: call void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* byval(%struct.LargeStructOneMember) align 8 %[[byval_temp]]) | ||
3112 | -#if __OPENCL_C_VERSION__ >= 200 | ||
3113 | +#if (__OPENCL_C_VERSION__ == 200) || (__OPENCL_C_VERSION__ >= 300 && defined(__opencl_c_program_scope_global_variables)) | ||
3114 | void test_indirect_arg_globl(void) { | ||
3115 | FuncOneLargeMember(g_s); | ||
3116 | } | ||
3117 | diff --git a/clang/test/CodeGenOpenCL/address-spaces-conversions.cl b/clang/test/CodeGenOpenCL/address-spaces-conversions.cl | ||
3118 | index cd3099e0a1a4..8fdb46184bed 100644 | ||
3119 | --- a/clang/test/CodeGenOpenCL/address-spaces-conversions.cl | ||
3120 | +++ b/clang/test/CodeGenOpenCL/address-spaces-conversions.cl | ||
3121 | @@ -1,5 +1,7 @@ | ||
3122 | // RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -O0 -ffake-address-space-map -cl-std=CL2.0 -emit-llvm -o - | FileCheck %s | ||
3123 | +// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -O0 -ffake-address-space-map -cl-std=CL3.0 -cl-ext=+__opencl_c_generic_address_space -emit-llvm -o - | FileCheck %s | ||
3124 | // RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -O0 -cl-std=CL2.0 -emit-llvm -o - | FileCheck --check-prefix=CHECK-NOFAKE %s | ||
3125 | +// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -O0 -cl-std=CL3.0 -cl-ext=+__opencl_c_generic_address_space -emit-llvm -o - | FileCheck --check-prefix=CHECK-NOFAKE %s | ||
3126 | // When -ffake-address-space-map is not used, all addr space mapped to 0 for x86_64. | ||
3127 | |||
3128 | // test that we generate address space casts everywhere we need conversions of | ||
3129 | diff --git a/clang/test/CodeGenOpenCL/address-spaces-mangling.cl b/clang/test/CodeGenOpenCL/address-spaces-mangling.cl | ||
3130 | index 50622f099143..b46834c2a678 100644 | ||
3131 | --- a/clang/test/CodeGenOpenCL/address-spaces-mangling.cl | ||
3132 | +++ b/clang/test/CodeGenOpenCL/address-spaces-mangling.cl | ||
3133 | @@ -2,10 +2,14 @@ | ||
3134 | // RUN: %clang_cc1 %s -cl-std=CL2.0 -ffake-address-space-map -faddress-space-map-mangling=yes -triple %itanium_abi_triple -emit-llvm -o - | FileCheck -check-prefixes="ASMANG,ASMANG20" %s | ||
3135 | // RUN: %clang_cc1 %s -ffake-address-space-map -faddress-space-map-mangling=no -triple %itanium_abi_triple -emit-llvm -o - | FileCheck -check-prefixes="NOASMANG,NOASMANG10" %s | ||
3136 | // RUN: %clang_cc1 %s -cl-std=CL2.0 -ffake-address-space-map -faddress-space-map-mangling=no -triple %itanium_abi_triple -emit-llvm -o - | FileCheck -check-prefixes="NOASMANG,NOASMANG20" %s | ||
3137 | +// RUN: %clang_cc1 %s -cl-std=CL3.0 -cl-std=CL3.0 -cl-ext=+__opencl_c_generic_address_space -ffake-address-space-map -faddress-space-map-mangling=no -triple %itanium_abi_triple -emit-llvm -o - | FileCheck -check-prefixes="NOASMANG,NOASMANG20" %s | ||
3138 | +// RUN: %clang_cc1 %s -cl-std=CL3.0 -cl-ext=+__opencl_c_generic_address_space -ffake-address-space-map -faddress-space-map-mangling=yes -triple %itanium_abi_triple -emit-llvm -o - | FileCheck -check-prefixes="ASMANG,ASMANG20" %s | ||
3139 | |||
3140 | // We check that the address spaces are mangled the same in both version of OpenCL | ||
3141 | // RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=CL2.0 -emit-llvm -o - | FileCheck -check-prefix=OCL-20 %s | ||
3142 | // RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=CL1.2 -emit-llvm -o - | FileCheck -check-prefix=OCL-12 %s | ||
3143 | +// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=CL3.0 -cl-ext=+__opencl_c_generic_address_space -emit-llvm -o - | FileCheck -check-prefix=OCL-20 %s | ||
3144 | +// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=CL3.0 -cl-ext=-__opencl_c_generic_address_space -emit-llvm -o - | FileCheck -check-prefix=OCL-12 %s | ||
3145 | |||
3146 | // We can't name this f as private is equivalent to default | ||
3147 | // no specifier given address space so we get multiple definition | ||
3148 | @@ -47,7 +51,7 @@ void f(constant int *arg) { } | ||
3149 | // OCL-20-DAG: @_Z1fPU3AS2i | ||
3150 | // OCL-12-DAG: @_Z1fPU3AS2i | ||
3151 | |||
3152 | -#if __OPENCL_C_VERSION__ >= 200 | ||
3153 | +#if (__OPENCL_C_VERSION__ == 200) || defined(__opencl_c_generic_address_space) | ||
3154 | __attribute__((overloadable)) | ||
3155 | void f(generic int *arg) { } | ||
3156 | // ASMANG20: @_Z1fPU3AS4i | ||
3157 | diff --git a/clang/test/CodeGenOpenCL/address-spaces.cl b/clang/test/CodeGenOpenCL/address-spaces.cl | ||
3158 | index ebd227a6a9c7..be131c7820f9 100644 | ||
3159 | --- a/clang/test/CodeGenOpenCL/address-spaces.cl | ||
3160 | +++ b/clang/test/CodeGenOpenCL/address-spaces.cl | ||
3161 | @@ -1,9 +1,13 @@ | ||
3162 | // RUN: %clang_cc1 %s -O0 -ffake-address-space-map -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,SPIR | ||
3163 | +// RUN: %clang_cc1 %s -O0 -cl-std=CL3.0 -cl-ext=-__opencl_c_generic_address_space -ffake-address-space-map -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,SPIR | ||
3164 | // RUN: %clang_cc1 %s -O0 -DCL20 -cl-std=CL2.0 -ffake-address-space-map -emit-llvm -o - | FileCheck %s --check-prefixes=CL20,CL20SPIR | ||
3165 | // RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-amdhsa -emit-llvm -o - | FileCheck --check-prefixes=CHECK,AMDGCN %s | ||
3166 | +// RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-amdhsa -cl-std=CL3.0 -emit-llvm -o - | FileCheck --check-prefixes=CHECK,AMDGCN %s | ||
3167 | // RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-amdhsa -DCL20 -cl-std=CL2.0 -emit-llvm -o - | FileCheck %s --check-prefixes=CL20,CL20AMDGCN | ||
3168 | // RUN: %clang_cc1 %s -O0 -triple amdgcn-mesa-mesa3d -emit-llvm -o - | FileCheck --check-prefixes=CHECK,AMDGCN %s | ||
3169 | +// RUN: %clang_cc1 %s -O0 -triple amdgcn-mesa-mesa3d -cl-std=CL3.0 -emit-llvm -o - | FileCheck --check-prefixes=CHECK,AMDGCN %s | ||
3170 | // RUN: %clang_cc1 %s -O0 -triple r600-- -emit-llvm -o - | FileCheck --check-prefixes=CHECK,AMDGCN %s | ||
3171 | +// RUN: %clang_cc1 %s -O0 -triple r600-- -emit-llvm -cl-std=CL3.0 -o - | FileCheck --check-prefixes=CHECK,AMDGCN %s | ||
3172 | |||
3173 | // SPIR: %struct.S = type { i32, i32, i32* } | ||
3174 | // CL20SPIR: %struct.S = type { i32, i32, i32 addrspace(4)* } | ||
3175 | diff --git a/clang/test/CodeGenOpenCL/amdgpu-sizeof-alignof.cl b/clang/test/CodeGenOpenCL/amdgpu-sizeof-alignof.cl | ||
3176 | index a5d438933fa4..3bd395da6d45 100644 | ||
3177 | --- a/clang/test/CodeGenOpenCL/amdgpu-sizeof-alignof.cl | ||
3178 | +++ b/clang/test/CodeGenOpenCL/amdgpu-sizeof-alignof.cl | ||
3179 | @@ -5,6 +5,18 @@ | ||
3180 | // RUN: %clang_cc1 -triple amdgcn---amdgizcl -cl-std=CL1.2 %s -emit-llvm -o - | FileCheck %s | ||
3181 | // RUN: %clang_cc1 -triple amdgcn---amdgizcl -cl-std=CL2.0 %s -emit-llvm -o - | FileCheck %s | ||
3182 | |||
3183 | +// RUN: %clang_cc1 -triple r600 -cl-std=CL3.0 %s -emit-llvm -o - | FileCheck %s | ||
3184 | +// RUN: %clang_cc1 -triple amdgcn-mesa-mesa3d -cl-std=CL3.0 %s -emit-llvm -o - | FileCheck %s | ||
3185 | +// RUN: %clang_cc1 -triple amdgcn---opencl -cl-std=CL3.0 %s -emit-llvm -o - | FileCheck %s | ||
3186 | +// RUN: %clang_cc1 -triple amdgcn---amdgizcl -cl-std=CL3.0 %s -emit-llvm -o - | FileCheck %s | ||
3187 | +// RUN: %clang_cc1 -triple amdgcn-mesa-mesa3d -cl-ext=+__opencl_c_generic_address_space -cl-std=CL3.0 %s -emit-llvm -o - | FileCheck %s | ||
3188 | +// RUN: %clang_cc1 -triple amdgcn---opencl -cl-ext=+__opencl_c_generic_address_space -cl-std=CL3.0 %s -emit-llvm -o - | FileCheck %s | ||
3189 | +// RUN: %clang_cc1 -triple amdgcn---amdgizcl -cl-ext=+__opencl_c_generic_address_space -cl-std=CL3.0 %s -emit-llvm -o - | FileCheck %s | ||
3190 | +// RUN: %clang_cc1 -triple r600 -cl-ext=+cl_khr_fp64,+__opencl_c_fp64 -cl-std=CL3.0 %s -emit-llvm -o - | FileCheck %s | ||
3191 | +// RUN: %clang_cc1 -triple amdgcn-mesa-mesa3d -cl-ext=+cl_khr_fp64,+__opencl_c_fp64 -cl-std=CL3.0 %s -emit-llvm -o - | FileCheck %s | ||
3192 | +// RUN: %clang_cc1 -triple amdgcn---opencl -cl-ext=+cl_khr_fp64,+__opencl_c_fp64 -cl-std=CL3.0 %s -emit-llvm -o - | FileCheck %s | ||
3193 | +// RUN: %clang_cc1 -triple amdgcn---amdgizcl -cl-ext=+cl_khr_fp64,+__opencl_c_fp64 -cl-std=CL3.0 %s -emit-llvm -o - | FileCheck %s | ||
3194 | + | ||
3195 | #ifdef __AMDGCN__ | ||
3196 | #define PTSIZE 8 | ||
3197 | #else | ||
3198 | @@ -58,9 +70,12 @@ void test() { | ||
3199 | check(sizeof(double) == 8); | ||
3200 | check(__alignof__(double) == 8); | ||
3201 | #endif | ||
3202 | - | ||
3203 | - check(sizeof(void*) == (__OPENCL_C_VERSION__ >= 200 ? 8 : 4)); | ||
3204 | - check(__alignof__(void*) == (__OPENCL_C_VERSION__ >= 200 ? 8 : 4)); | ||
3205 | + check(sizeof(private void*) == 4); | ||
3206 | + check(__alignof__(private void*) == 4); | ||
3207 | +#if (__OPENCL_C_VERSION__ == 200) || defined(__opencl_c_generic_address_space) | ||
3208 | + check(sizeof(generic void*) == 8); | ||
3209 | + check(__alignof__(generic void*) == 8); | ||
3210 | +#endif | ||
3211 | check(sizeof(global_ptr_t) == PTSIZE); | ||
3212 | check(__alignof__(global_ptr_t) == PTSIZE); | ||
3213 | check(sizeof(constant_ptr_t) == PTSIZE); | ||
3214 | diff --git a/clang/test/CodeGenOpenCL/arm-integer-dot-product.cl b/clang/test/CodeGenOpenCL/arm-integer-dot-product.cl | ||
3215 | index d1ab6aceac5c..cc62d1df4275 100644 | ||
3216 | --- a/clang/test/CodeGenOpenCL/arm-integer-dot-product.cl | ||
3217 | +++ b/clang/test/CodeGenOpenCL/arm-integer-dot-product.cl | ||
3218 | @@ -1,38 +1,39 @@ | ||
3219 | // RUN: %clang_cc1 %s -triple spir-unknown-unknown -finclude-default-header -cl-std=CL1.2 -emit-llvm -o - -O0 | FileCheck %s | ||
3220 | |||
3221 | +// Pragmas are only accepted for backward compatibility. | ||
3222 | + | ||
3223 | #pragma OPENCL EXTENSION cl_arm_integer_dot_product_int8 : enable | ||
3224 | +#pragma OPENCL EXTENSION cl_arm_integer_dot_product_int8 : disable | ||
3225 | void test_int8(uchar4 ua, uchar4 ub, char4 sa, char4 sb) { | ||
3226 | uint ur = arm_dot(ua, ub); | ||
3227 | // CHECK: call spir_func i32 @_Z7arm_dotDv4_hS_ | ||
3228 | int sr = arm_dot(sa, sb); | ||
3229 | // CHECK: call spir_func i32 @_Z7arm_dotDv4_cS_ | ||
3230 | } | ||
3231 | -#pragma OPENCL EXTENSION cl_arm_integer_dot_product_int8 : disable | ||
3232 | |||
3233 | #pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_int8 : enable | ||
3234 | +#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_int8 : disable | ||
3235 | void test_accumulate_int8(uchar4 ua, uchar4 ub, uint uc, char4 sa, char4 sb, int c) { | ||
3236 | uint ur = arm_dot_acc(ua, ub, uc); | ||
3237 | // CHECK: call spir_func i32 @_Z11arm_dot_accDv4_hS_j | ||
3238 | int sr = arm_dot_acc(sa, sb, c); | ||
3239 | // CHECK: call spir_func i32 @_Z11arm_dot_accDv4_cS_i | ||
3240 | } | ||
3241 | -#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_int8 : disable | ||
3242 | |||
3243 | #pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_int16 : enable | ||
3244 | +#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_int16 : disable | ||
3245 | void test_accumulate_int16(ushort2 ua, ushort2 ub, uint uc, short2 sa, short2 sb, int c) { | ||
3246 | uint ur = arm_dot_acc(ua, ub, uc); | ||
3247 | // CHECK: call spir_func i32 @_Z11arm_dot_accDv2_tS_j | ||
3248 | int sr = arm_dot_acc(sa, sb, c); | ||
3249 | // CHECK: call spir_func i32 @_Z11arm_dot_accDv2_sS_i | ||
3250 | } | ||
3251 | -#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_int16 : disable | ||
3252 | |||
3253 | #pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_saturate_int8 : enable | ||
3254 | +#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_saturate_int8 : disable | ||
3255 | void test_accumulate_saturate_int8(uchar4 ua, uchar4 ub, uint uc, char4 sa, char4 sb, int c) { | ||
3256 | uint ur = arm_dot_acc_sat(ua, ub, uc); | ||
3257 | // CHECK: call spir_func i32 @_Z15arm_dot_acc_satDv4_hS_j | ||
3258 | int sr = arm_dot_acc_sat(sa, sb, c); | ||
3259 | // CHECK: call spir_func i32 @_Z15arm_dot_acc_satDv4_cS_i | ||
3260 | } | ||
3261 | -#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_saturate_int8 : disable | ||
3262 | - | ||
3263 | diff --git a/clang/test/CodeGenOpenCL/extension-begin.cl b/clang/test/CodeGenOpenCL/extension-begin.cl | ||
3264 | deleted file mode 100644 | ||
3265 | index 89b4256b2b11..000000000000 | ||
3266 | --- a/clang/test/CodeGenOpenCL/extension-begin.cl | ||
3267 | +++ /dev/null | ||
3268 | @@ -1,25 +0,0 @@ | ||
3269 | -// RUN: %clang_cc1 %s -triple spir-unknown-unknown -emit-llvm -o - | FileCheck %s | ||
3270 | - | ||
3271 | -__attribute__((overloadable)) void f(int x); | ||
3272 | - | ||
3273 | -#pragma OPENCL EXTENSION my_ext : begin | ||
3274 | - | ||
3275 | -__attribute__((overloadable)) void f(long x); | ||
3276 | - | ||
3277 | -#pragma OPENCL EXTENSION my_ext : end | ||
3278 | - | ||
3279 | -#pragma OPENCL EXTENSION my_ext : enable | ||
3280 | - | ||
3281 | -//CHECK: define{{.*}} spir_func void @test_f1(i64 %x) | ||
3282 | -//CHECK: call spir_func void @_Z1fl(i64 %{{.*}}) | ||
3283 | -void test_f1(long x) { | ||
3284 | - f(x); | ||
3285 | -} | ||
3286 | - | ||
3287 | -#pragma OPENCL EXTENSION my_ext : disable | ||
3288 | - | ||
3289 | -//CHECK: define{{.*}} spir_func void @test_f2(i64 %x) | ||
3290 | -//CHECK: call spir_func void @_Z1fi(i32 %{{.*}}) | ||
3291 | -void test_f2(long x) { | ||
3292 | - f(x); | ||
3293 | -} | ||
3294 | diff --git a/clang/test/CodeGenOpenCL/overload.cl b/clang/test/CodeGenOpenCL/overload.cl | ||
3295 | index f182cb5fd2af..bc844595a59a 100644 | ||
3296 | --- a/clang/test/CodeGenOpenCL/overload.cl | ||
3297 | +++ b/clang/test/CodeGenOpenCL/overload.cl | ||
3298 | @@ -1,4 +1,5 @@ | ||
3299 | // RUN: %clang_cc1 -cl-std=CL2.0 -emit-llvm -o - -triple spir-unknown-unknown %s | FileCheck %s | ||
3300 | +// RUN: %clang_cc1 -cl-std=CL3.0 -cl-ext=+__opencl_c_generic_address_space -emit-llvm -o - -triple spir-unknown-unknown %s | FileCheck %s | ||
3301 | |||
3302 | typedef short short4 __attribute__((ext_vector_type(4))); | ||
3303 | |||
3304 | diff --git a/clang/test/CodeGenOpenCL/printf.cl b/clang/test/CodeGenOpenCL/printf.cl | ||
3305 | index fc139d776db6..c68c43bcc286 100644 | ||
3306 | --- a/clang/test/CodeGenOpenCL/printf.cl | ||
3307 | +++ b/clang/test/CodeGenOpenCL/printf.cl | ||
3308 | @@ -1,10 +1,12 @@ | ||
3309 | // RUN: %clang_cc1 -cl-std=CL1.2 -cl-ext=-+cl_khr_fp64 -triple spir-unknown-unknown -disable-llvm-passes -emit-llvm -o - %s | FileCheck -check-prefixes=FP64,ALL %s | ||
3310 | // RUN: %clang_cc1 -cl-std=CL1.2 -cl-ext=-cl_khr_fp64 -triple spir-unknown-unknown -disable-llvm-passes -emit-llvm -o - %s | FileCheck -check-prefixes=NOFP64,ALL %s | ||
3311 | +// RUN: %clang_cc1 -cl-std=CL3.0 -cl-ext=+__opencl_c_fp64,+cl_khr_fp64 -triple spir-unknown-unknown -disable-llvm-passes -emit-llvm -o - %s | FileCheck -check-prefixes=FP64,ALL %s | ||
3312 | +// RUN: %clang_cc1 -cl-std=CL3.0 -cl-ext=-__opencl_c_fp64,-cl_khr_fp64 -triple spir-unknown-unknown -disable-llvm-passes -emit-llvm -o - %s | FileCheck -check-prefixes=NOFP64,ALL %s | ||
3313 | |||
3314 | typedef __attribute__((ext_vector_type(2))) float float2; | ||
3315 | typedef __attribute__((ext_vector_type(2))) half half2; | ||
3316 | |||
3317 | -#ifdef cl_khr_fp64 | ||
3318 | +#if defined(cl_khr_fp64) || defined(__opencl_c_fp64) | ||
3319 | typedef __attribute__((ext_vector_type(2))) double double2; | ||
3320 | #endif | ||
3321 | |||
3322 | @@ -28,7 +30,7 @@ kernel void test_printf_half2(half2 arg) { | ||
3323 | printf("%v2hf", arg); | ||
3324 | } | ||
3325 | |||
3326 | -#ifdef cl_khr_fp64 | ||
3327 | +#if defined(cl_khr_fp64) || defined(__opencl_c_fp64) | ||
3328 | // FP64-LABEL: @test_printf_double2( | ||
3329 | // FP64: call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 addrspace(2)* getelementptr inbounds ([6 x i8], [6 x i8] addrspace(2)* @.str.2, i32 0, i32 0), <2 x double> %0) | ||
3330 | kernel void test_printf_double2(double2 arg) { | ||
3331 | diff --git a/clang/test/Headers/opencl-c-header.cl b/clang/test/Headers/opencl-c-header.cl | ||
3332 | index 184eefd9f9c3..1c671acb174e 100644 | ||
3333 | --- a/clang/test/Headers/opencl-c-header.cl | ||
3334 | +++ b/clang/test/Headers/opencl-c-header.cl | ||
3335 | @@ -253,4 +253,88 @@ global atomic_int z = ATOMIC_VAR_INIT(99); | ||
3336 | |||
3337 | #endif //(defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) | ||
3338 | |||
3339 | +// OpenCL C features. | ||
3340 | +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ == 200) | ||
3341 | + | ||
3342 | +#ifndef __opencl_c_pipes | ||
3343 | +#error "Feature macro __opencl_c_pipes should be defined" | ||
3344 | +#endif | ||
3345 | +#ifndef __opencl_c_generic_address_space | ||
3346 | +#error "Feature macro __opencl_c_generic_address_space should be defined" | ||
3347 | +#endif | ||
3348 | +#ifndef __opencl_c_work_group_collective_functions | ||
3349 | +#error "Feature macro __opencl_c_work_group_collective_functions should be defined" | ||
3350 | +#endif | ||
3351 | +#ifndef __opencl_c_atomic_order_acq_rel | ||
3352 | +#error "Feature macro __opencl_c_atomic_order_acq_rel should be defined" | ||
3353 | +#endif | ||
3354 | +#ifndef __opencl_c_atomic_order_seq_cst | ||
3355 | +#error "Feature macro __opencl_c_atomic_order_seq_cst should be defined" | ||
3356 | +#endif | ||
3357 | +#ifndef __opencl_c_atomic_scope_device | ||
3358 | +#error "Feature macro __opencl_c_atomic_scope_device should be defined" | ||
3359 | +#endif | ||
3360 | +#ifndef __opencl_c_atomic_scope_all_devices | ||
3361 | +#error "Feature macro __opencl_c_atomic_scope_all_devices should be defined" | ||
3362 | +#endif | ||
3363 | +#ifndef __opencl_c_device_enqueue | ||
3364 | +#error "Feature macro __opencl_c_device_enqueue should be defined" | ||
3365 | +#endif | ||
3366 | +#ifndef __opencl_c_read_write_images | ||
3367 | +#error "Feature macro __opencl_c_read_write_images should be defined" | ||
3368 | +#endif | ||
3369 | +#ifndef __opencl_c_program_scope_global_variables | ||
3370 | +#error "Feature macro __opencl_c_program_scope_global_variables should be defined" | ||
3371 | +#endif | ||
3372 | +#ifndef __opencl_c_images | ||
3373 | +#error "Feature macro __opencl_c_images should be defined" | ||
3374 | +#endif | ||
3375 | + | ||
3376 | +#elif (__OPENCL_C_VERSION__ < 200) | ||
3377 | + | ||
3378 | +#ifdef __opencl_c_pipes | ||
3379 | +#error "Incorret feature macro __opencl_c_pipes define" | ||
3380 | +#endif | ||
3381 | +#ifdef __opencl_c_generic_address_space | ||
3382 | +#error "Incorret feature macro __opencl_c_generic_address_space define" | ||
3383 | +#endif | ||
3384 | +#ifdef __opencl_c_work_group_collective_functions | ||
3385 | +#error "Incorret feature macro __opencl_c_work_group_collective_functions define" | ||
3386 | +#endif | ||
3387 | +#ifdef __opencl_c_atomic_order_acq_rel | ||
3388 | +#error "Incorret feature macro __opencl_c_atomic_order_acq_rel define" | ||
3389 | +#endif | ||
3390 | +#ifdef __opencl_c_atomic_order_seq_cst | ||
3391 | +#error "Incorret feature macro __opencl_c_atomic_order_seq_cst define" | ||
3392 | +#endif | ||
3393 | +#ifdef __opencl_c_atomic_scope_device | ||
3394 | +#error "Incorret feature macro __opencl_c_atomic_scope_device define" | ||
3395 | +#endif | ||
3396 | +#ifdef __opencl_c_atomic_scope_all_devices | ||
3397 | +#error "Incorret feature macro __opencl_c_atomic_scope_all_devices define" | ||
3398 | +#endif | ||
3399 | +#ifdef __opencl_c_device_enqueue | ||
3400 | +#error "Incorret feature macro __opencl_c_device_enqueue define" | ||
3401 | +#endif | ||
3402 | +#ifdef __opencl_c_read_write_images | ||
3403 | +#error "Incorret feature macro __opencl_c_read_write_images define" | ||
3404 | +#endif | ||
3405 | +#ifdef __opencl_c_program_scope_global_variables | ||
3406 | +#error "Incorret feature macro __opencl_c_program_scope_global_variables define" | ||
3407 | +#endif | ||
3408 | +#ifdef __opencl_c_images | ||
3409 | +#error "Incorret feature macro __opencl_c_images define" | ||
3410 | +#endif | ||
3411 | +#ifdef __opencl_c_3d_image_writes | ||
3412 | +#error "Incorret feature macro __opencl_c_3d_image_writes define" | ||
3413 | +#endif | ||
3414 | +#ifdef __opencl_c_fp64 | ||
3415 | +#error "Incorret feature macro __opencl_c_fp64 define" | ||
3416 | +#endif | ||
3417 | +#ifdef __opencl_c_subgroups | ||
3418 | +#error "Incorret feature macro __opencl_c_subgroups define" | ||
3419 | +#endif | ||
3420 | + | ||
3421 | +#endif //(defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ == 200) | ||
3422 | + | ||
3423 | #endif // defined(__SPIR__) | ||
3424 | diff --git a/clang/test/Misc/nvptx.unsupported_core.cl b/clang/test/Misc/nvptx.unsupported_core.cl | ||
3425 | new file mode 100644 | ||
3426 | index 000000000000..b56a4828914e | ||
3427 | --- /dev/null | ||
3428 | +++ b/clang/test/Misc/nvptx.unsupported_core.cl | ||
3429 | @@ -0,0 +1,7 @@ | ||
3430 | +// RUN: %clang_cc1 -cl-std=CL2.0 -triple nvptx-unknown-unknown -Wpedantic-core-features %s 2> %t | ||
3431 | +// RUN: FileCheck --check-prefixes=CHECK-C < %t %s | ||
3432 | +// RUN: %clang_cc1 -cl-std=CLC++ -triple nvptx-unknown-unknown -Wpedantic-core-features %s 2> %t | ||
3433 | +// RUN: FileCheck --check-prefixes=CHECK-CPP < %t %s | ||
3434 | + | ||
3435 | +// CHECK-C: cl_khr_3d_image_writes is a core feature in OpenCL C version 2.0 but not supported on this target | ||
3436 | +// CHECK-CPP: cl_khr_3d_image_writes is a core feature in C++ for OpenCL version 1.0 but not supported on this target | ||
3437 | diff --git a/clang/test/Misc/warning-flags.c b/clang/test/Misc/warning-flags.c | ||
3438 | index 54e36e1e0884..e4f9069b88c8 100644 | ||
3439 | --- a/clang/test/Misc/warning-flags.c | ||
3440 | +++ b/clang/test/Misc/warning-flags.c | ||
3441 | @@ -91,4 +91,4 @@ CHECK-NEXT: warn_weak_import | ||
3442 | |||
3443 | The list of warnings in -Wpedantic should NEVER grow. | ||
3444 | |||
3445 | -CHECK: Number in -Wpedantic (not covered by other -W flags): 26 | ||
3446 | +CHECK: Number in -Wpedantic (not covered by other -W flags): 27 | ||
3447 | diff --git a/clang/test/Parser/opencl-atomics-cl20.cl b/clang/test/Parser/opencl-atomics-cl20.cl | ||
3448 | index 844902e847f7..c3f86b6a44c4 100644 | ||
3449 | --- a/clang/test/Parser/opencl-atomics-cl20.cl | ||
3450 | +++ b/clang/test/Parser/opencl-atomics-cl20.cl | ||
3451 | @@ -1,66 +1,78 @@ | ||
3452 | // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only | ||
3453 | -// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -fsyntax-only -cl-std=CL2.0 -DCL20 | ||
3454 | -// RUN: %clang_cc1 %s -triple spir64-unknown-unknown -verify -fsyntax-only -cl-std=CL2.0 -DCL20 | ||
3455 | -// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -fsyntax-only -cl-std=CL2.0 -DCL20 -DEXT -Wpedantic-core-features | ||
3456 | +// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -fsyntax-only -cl-std=CL2.0 -cl-ext=-cl_khr_int64_base_atomics | ||
3457 | +// RUN: %clang_cc1 %s -triple spir64-unknown-unknown -verify -fsyntax-only -cl-std=CL2.0 | ||
3458 | +// RUN: %clang_cc1 %s -triple spir64-unknown-unknown -verify -fsyntax-only -cl-std=CLC++ | ||
3459 | +// RUN: %clang_cc1 %s -triple spir64-unknown-unknown -verify -fsyntax-only -cl-std=CL2.0 -cl-ext=-cl_khr_int64_base_atomics | ||
3460 | |||
3461 | -#ifdef EXT | ||
3462 | -#pragma OPENCL EXTENSION cl_khr_int64_base_atomics:enable | ||
3463 | -#pragma OPENCL EXTENSION cl_khr_int64_extended_atomics:enable | ||
3464 | -#pragma OPENCL EXTENSION cl_khr_fp64:enable | ||
3465 | -#if __OPENCL_C_VERSION__ >= CL_VERSION_1_2 | ||
3466 | -// expected-warning@-2{{OpenCL extension 'cl_khr_fp64' is core feature or supported optional core feature - ignoring}} | ||
3467 | -#endif | ||
3468 | +#if defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= CL_VERSION_1_2 | ||
3469 | +#define LANG_VER_OK | ||
3470 | #endif | ||
3471 | |||
3472 | void atomic_types_test() { | ||
3473 | // OpenCL v2.0 s6.13.11.6 defines supported atomic types. | ||
3474 | + | ||
3475 | +// Non-optional types | ||
3476 | atomic_int i; | ||
3477 | atomic_uint ui; | ||
3478 | + atomic_float f; | ||
3479 | + atomic_flag fl; | ||
3480 | +#if !defined(LANG_VER_OK) | ||
3481 | +// expected-error@-5 {{use of undeclared identifier 'atomic_int'}} | ||
3482 | +// expected-error@-5 {{use of undeclared identifier 'atomic_uint'}} | ||
3483 | +// expected-error@-5 {{use of undeclared identifier 'atomic_float'}} | ||
3484 | +// expected-error@-5 {{use of undeclared identifier 'atomic_flag'}} | ||
3485 | +#endif | ||
3486 | + | ||
3487 | +// Optional types | ||
3488 | atomic_long l; | ||
3489 | atomic_ulong ul; | ||
3490 | - atomic_float f; | ||
3491 | atomic_double d; | ||
3492 | - atomic_flag fl; | ||
3493 | + atomic_size_t s; | ||
3494 | atomic_intptr_t ip; | ||
3495 | atomic_uintptr_t uip; | ||
3496 | - atomic_size_t s; | ||
3497 | atomic_ptrdiff_t pd; | ||
3498 | -// OpenCL v2.0 s6.13.11.8, _Atomic type specifier and _Atomic type qualifier | ||
3499 | -// are not supported by OpenCL. | ||
3500 | - _Atomic int i; // expected-error {{use of undeclared identifier '_Atomic'}} | ||
3501 | -} | ||
3502 | -#ifndef CL20 | ||
3503 | -// expected-error@-16 {{use of undeclared identifier 'atomic_int'}} | ||
3504 | -// expected-error@-16 {{use of undeclared identifier 'atomic_uint'}} | ||
3505 | -// expected-error@-16 {{use of undeclared identifier 'atomic_long'}} | ||
3506 | -// expected-error@-16 {{use of undeclared identifier 'atomic_ulong'}} | ||
3507 | -// expected-error@-16 {{use of undeclared identifier 'atomic_float'}} | ||
3508 | -// expected-error@-16 {{use of undeclared identifier 'atomic_double'}} | ||
3509 | -// expected-error@-16 {{use of undeclared identifier 'atomic_flag'}} | ||
3510 | -// expected-error@-16 {{use of undeclared identifier 'atomic_intptr_t'}} | ||
3511 | -// expected-error@-16 {{use of undeclared identifier 'atomic_uintptr_t'}} | ||
3512 | -// expected-error@-16 {{use of undeclared identifier 'atomic_size_t'}} | ||
3513 | +// Optional type identifiers are not added in earlier version or if at least | ||
3514 | +// one of the extensions is not supported. Here we check with | ||
3515 | +// `cl_khr_int64_base_atomics` only. | ||
3516 | +#if !defined(LANG_VER_OK) || !defined(cl_khr_int64_base_atomics) | ||
3517 | +// expected-error@-11 {{use of undeclared identifier 'atomic_long'}} | ||
3518 | +// expected-error@-11 {{use of undeclared identifier 'atomic_ulong'}} | ||
3519 | +// expected-error@-11 {{use of undeclared identifier 'atomic_double'}} | ||
3520 | +#if defined(LANG_VER_OK) | ||
3521 | +// expected-error@-15 {{expected ';' after expression}} | ||
3522 | +// expected-error@-16 {{use of undeclared identifier 'l'}} | ||
3523 | +// expected-error@-16 {{expected ';' after expression}} | ||
3524 | +// expected-error@-17 {{use of undeclared identifier 'ul'}} | ||
3525 | +#endif | ||
3526 | +#if !defined(LANG_VER_OK) || defined(__SPIR64__) | ||
3527 | +// expected-error@-18 {{use of undeclared identifier 'atomic_size_t'}} | ||
3528 | // expected-error@-16 {{use of undeclared identifier 'atomic_ptrdiff_t'}} | ||
3529 | -#elif !EXT | ||
3530 | -// expected-error@-26 {{use of type 'atomic_long' (aka '_Atomic(long)') requires cl_khr_int64_base_atomics extension to be enabled}} | ||
3531 | -// expected-error@-27 {{use of type 'atomic_long' (aka '_Atomic(long)') requires cl_khr_int64_extended_atomics extension to be enabled}} | ||
3532 | -// expected-error@-27 {{use of type 'atomic_ulong' (aka '_Atomic(unsigned long)') requires cl_khr_int64_base_atomics extension to be enabled}} | ||
3533 | -// expected-error@-28 {{use of type 'atomic_ulong' (aka '_Atomic(unsigned long)') requires cl_khr_int64_extended_atomics extension to be enabled}} | ||
3534 | -// expected-error@-27 {{use of type 'atomic_double' (aka '_Atomic(double)') requires cl_khr_int64_base_atomics extension to be enabled}} | ||
3535 | -// expected-error@-28 {{use of type 'atomic_double' (aka '_Atomic(double)') requires cl_khr_int64_extended_atomics extension to be enabled}} | ||
3536 | -#if __LP64__ | ||
3537 | -// expected-error-re@-28 {{use of type 'atomic_intptr_t' (aka '_Atomic({{.+}})') requires cl_khr_int64_base_atomics extension to be enabled}} | ||
3538 | -// expected-error-re@-29 {{use of type 'atomic_intptr_t' (aka '_Atomic({{.+}})') requires cl_khr_int64_extended_atomics extension to be enabled}} | ||
3539 | -// expected-error-re@-29 {{use of type 'atomic_uintptr_t' (aka '_Atomic({{.+}})') requires cl_khr_int64_base_atomics extension to be enabled}} | ||
3540 | -// expected-error-re@-30 {{use of type 'atomic_uintptr_t' (aka '_Atomic({{.+}})') requires cl_khr_int64_extended_atomics extension to be enabled}} | ||
3541 | -// expected-error-re@-30 {{use of type 'atomic_size_t' (aka '_Atomic({{.+}})') requires cl_khr_int64_base_atomics extension to be enabled}} | ||
3542 | -// expected-error-re@-31 {{use of type 'atomic_size_t' (aka '_Atomic({{.+}})') requires cl_khr_int64_extended_atomics extension to be enabled}} | ||
3543 | -// expected-error-re@-31 {{use of type 'atomic_ptrdiff_t' (aka '_Atomic({{.+}})') requires cl_khr_int64_base_atomics extension to be enabled}} | ||
3544 | -// expected-error-re@-32 {{use of type 'atomic_ptrdiff_t' (aka '_Atomic({{.+}})') requires cl_khr_int64_extended_atomics extension to be enabled}} | ||
3545 | +#if !defined(LANG_VER_OK) | ||
3546 | +// expected-error@-20 {{use of undeclared identifier 'atomic_intptr_t'}} | ||
3547 | +// expected-error@-20 {{use of undeclared identifier 'atomic_uintptr_t'}} | ||
3548 | +#else | ||
3549 | +// expected-error@-24 {{expected ';' after expression}} | ||
3550 | +// expected-error@-25 {{use of undeclared identifier 's'}} | ||
3551 | +// expected-error@-25 {{unknown type name 'atomic_intptr_t'; did you mean 'atomic_int'?}} | ||
3552 | +// expected-note@* {{'atomic_int' declared here}} | ||
3553 | +// expected-error@-26 {{unknown type name 'atomic_uintptr_t'; did you mean 'atomic_uint'?}} | ||
3554 | +// expected-note@* {{'atomic_uint' declared here}} | ||
3555 | +#endif | ||
3556 | #endif | ||
3557 | #endif | ||
3558 | |||
3559 | -#ifdef CL20 | ||
3560 | +// OpenCL v2.0 s6.13.11.8, _Atomic type specifier and _Atomic type qualifier | ||
3561 | +// are not supported by OpenCL. | ||
3562 | + _Atomic int i; | ||
3563 | +#ifdef __OPENCL_C_VERSION__ | ||
3564 | +// expected-error@-2 {{use of undeclared identifier '_Atomic'}} | ||
3565 | +#else | ||
3566 | + // expected-error@-4 {{unknown type name '_Atomic'}} | ||
3567 | +#endif | ||
3568 | +} | ||
3569 | + | ||
3570 | +#if defined(LANG_VER_OK) | ||
3571 | +int atomic_uint; //expected-error{{redefinition of 'atomic_uint' as different kind of symbol}} | ||
3572 | void foo(atomic_int * ptr) {} | ||
3573 | void atomic_ops_test() { | ||
3574 | atomic_int i; | ||
3575 | @@ -71,4 +83,6 @@ void atomic_ops_test() { | ||
3576 | i += 1; // expected-error {{invalid operands to binary expression ('__private atomic_int' (aka '__private _Atomic(int)') and 'int')}} | ||
3577 | i = i + i; // expected-error {{invalid operands to binary expression ('__private atomic_int' (aka '__private _Atomic(int)') and '__private atomic_int')}} | ||
3578 | } | ||
3579 | +#else | ||
3580 | +__constant int atomic_uint = 1; | ||
3581 | #endif | ||
3582 | diff --git a/clang/test/SemaOpenCL/access-qualifier.cl b/clang/test/SemaOpenCL/access-qualifier.cl | ||
3583 | index a5e1b65daf70..c538e73253ce 100644 | ||
3584 | --- a/clang/test/SemaOpenCL/access-qualifier.cl | ||
3585 | +++ b/clang/test/SemaOpenCL/access-qualifier.cl | ||
3586 | @@ -1,12 +1,14 @@ | ||
3587 | -// RUN: %clang_cc1 -verify -pedantic -fsyntax-only -cl-std=CL1.2 %s | ||
3588 | -// RUN: %clang_cc1 -verify -pedantic -fsyntax-only -cl-std=CL2.0 %s | ||
3589 | +// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL1.2 %s -cl-ext=-cl_khr_3d_image_writes | ||
3590 | +// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL2.0 %s | ||
3591 | +// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL3.0 %s | ||
3592 | +// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL3.0 %s -cl-ext=-__opencl_c_read_write_images | ||
3593 | |||
3594 | typedef image1d_t img1d_ro_default; // expected-note {{previously declared 'read_only' here}} | ||
3595 | |||
3596 | typedef write_only image1d_t img1d_wo; // expected-note {{previously declared 'write_only' here}} | ||
3597 | typedef read_only image1d_t img1d_ro; | ||
3598 | |||
3599 | -#if __OPENCL_C_VERSION__ >= 200 | ||
3600 | +#if (__OPENCL_C_VERSION__ == 200) || (__OPENCL_C_VERSION__ == 300 && defined(__opencl_c_read_write_images)) | ||
3601 | typedef read_write image1d_t img1d_rw; | ||
3602 | #endif | ||
3603 | |||
3604 | @@ -17,10 +19,10 @@ typedef read_only int IntRO; // expected-error {{access qualifier can only be us | ||
3605 | void myWrite(write_only image1d_t); // expected-note {{passing argument to parameter here}} expected-note {{passing argument to parameter here}} | ||
3606 | void myRead(read_only image1d_t); // expected-note {{passing argument to parameter here}} | ||
3607 | |||
3608 | -#if __OPENCL_C_VERSION__ >= 200 | ||
3609 | +#if (__OPENCL_C_VERSION__ == 200) || (__OPENCL_C_VERSION__ == 300 && defined(__opencl_c_read_write_images)) | ||
3610 | void myReadWrite(read_write image1d_t); | ||
3611 | #else | ||
3612 | -void myReadWrite(read_write image1d_t); // expected-error {{access qualifier 'read_write' can not be used for '__read_write image1d_t' prior to OpenCL version 2.0}} | ||
3613 | +void myReadWrite(read_write image1d_t); // expected-error {{access qualifier 'read_write' can not be used for '__read_write image1d_t' prior to OpenCL C version 2.0 or in version 3.0 and without __opencl_c_read_write_images feature}} | ||
3614 | #endif | ||
3615 | |||
3616 | |||
3617 | @@ -36,7 +38,7 @@ kernel void k3(img1d_wo img) { | ||
3618 | myWrite(img); | ||
3619 | } | ||
3620 | |||
3621 | -#if __OPENCL_C_VERSION__ >= 200 | ||
3622 | +#if (__OPENCL_C_VERSION__ == 200) || (__OPENCL_C_VERSION__ == 300 && defined(__opencl_c_read_write_images)) | ||
3623 | kernel void k4(img1d_rw img) { | ||
3624 | myReadWrite(img); | ||
3625 | } | ||
3626 | @@ -62,26 +64,26 @@ kernel void k11(read_only write_only image1d_t i){} // expected-error{{multiple | ||
3627 | |||
3628 | kernel void k12(read_only read_only image1d_t i){} // expected-warning {{duplicate 'read_only' declaration specifier}} | ||
3629 | |||
3630 | -#if __OPENCL_C_VERSION__ >= 200 | ||
3631 | +#if (__OPENCL_C_VERSION__ == 200) || (__OPENCL_C_VERSION__ == 300 && defined(__opencl_c_read_write_images)) | ||
3632 | kernel void k13(read_write pipe int i){} // expected-error{{access qualifier 'read_write' can not be used for 'read_only pipe int'}} | ||
3633 | #else | ||
3634 | -kernel void k13(__read_write image1d_t i){} // expected-error{{access qualifier '__read_write' can not be used for '__read_write image1d_t' prior to OpenCL version 2.0}} | ||
3635 | -#endif | ||
3636 | - | ||
3637 | -#if __OPENCL_C_VERSION__ >= 200 | ||
3638 | -void myPipeWrite(write_only pipe int); // expected-note {{passing argument to parameter here}} | ||
3639 | -kernel void k14(read_only pipe int p) { | ||
3640 | - myPipeWrite(p); // expected-error {{passing '__private read_only pipe int' to parameter of incompatible type 'write_only pipe int'}} | ||
3641 | -} | ||
3642 | +kernel void k13(__read_write image1d_t i){} // expected-error{{access qualifier '__read_write' can not be used for '__read_write image1d_t' prior to OpenCL C version 2.0 or in version 3.0 and without __opencl_c_read_write_images feature}} | ||
3643 | #endif | ||
3644 | |||
3645 | #if __OPENCL_C_VERSION__ < 200 | ||
3646 | -kernel void test_image3d_wo(write_only image3d_t img) {} // expected-error {{use of type '__write_only image3d_t' requires cl_khr_3d_image_writes extension to be enabled}} | ||
3647 | +kernel void test_image3d_wo(write_only image3d_t img) {} // expected-error {{use of type '__write_only image3d_t' requires cl_khr_3d_image_writes support}} | ||
3648 | #endif | ||
3649 | |||
3650 | -#if __OPENCL_C_VERSION__ >= 200 | ||
3651 | +#if (__OPENCL_C_VERSION__ == 200) || (__OPENCL_C_VERSION__ == 300 && defined(__opencl_c_read_write_images)) | ||
3652 | kernel void read_write_twice_typedef(read_write img1d_rw i){} // expected-warning {{duplicate 'read_write' declaration specifier}} | ||
3653 | -// expected-note@-74 {{previously declared 'read_write' here}} | ||
3654 | +// expected-note@-67 {{previously declared 'read_write' here}} | ||
3655 | +#endif | ||
3656 | + | ||
3657 | +#if OPENCL_C_VERSION__ >= 200 | ||
3658 | +void myPipeWrite(write_only pipe int); // expected-note {{passing argument to parameter here}} | ||
3659 | +kernel void k14(read_only pipe int p) { | ||
3660 | + myPipeWrite(p); // expected-error {{passing '__private read_only pipe int' to parameter of incompatible type 'write_only pipe int'}} | ||
3661 | +} | ||
3662 | |||
3663 | kernel void pipe_ro_twice(read_only read_only pipe int i){} // expected-warning{{duplicate 'read_only' declaration specifier}} | ||
3664 | // Conflicting access qualifiers | ||
3665 | @@ -94,7 +96,7 @@ kernel void pipe_ro_twice_typedef(read_only ROPipeInt i){} // expected-warning{{ | ||
3666 | |||
3667 | kernel void pass_ro_typedef_to_wo(ROPipeInt p) { | ||
3668 | myPipeWrite(p); // expected-error {{passing '__private ROPipeInt' (aka '__private read_only pipe int') to parameter of incompatible type 'write_only pipe int'}} | ||
3669 | - // expected-note@-25 {{passing argument to parameter here}} | ||
3670 | + // expected-note@-16 {{passing argument to parameter here}} | ||
3671 | } | ||
3672 | #endif | ||
3673 | |||
3674 | diff --git a/clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl b/clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl | ||
3675 | index a5a838241347..daedce8459aa 100644 | ||
3676 | --- a/clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl | ||
3677 | +++ b/clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl | ||
3678 | @@ -4,6 +4,9 @@ | ||
3679 | // RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DCONSTANT -cl-std=clc++ | ||
3680 | // RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGLOBAL -cl-std=clc++ | ||
3681 | // RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGENERIC -cl-std=clc++ | ||
3682 | +// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DCONSTANT -cl-std=CL3.0 -cl-ext=+__opencl_c_generic_address_space | ||
3683 | +// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGLOBAL -cl-std=CL3.0 -cl-ext=+__opencl_c_generic_address_space | ||
3684 | +// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGENERIC -cl-std=CL3.0 -cl-ext=+__opencl_c_generic_address_space | ||
3685 | |||
3686 | /* OpenCLC v2.0 adds a set of restrictions for conversions between pointers to | ||
3687 | * different address spaces, mainly described in Sections 6.5.5 and 6.5.6. | ||
3688 | diff --git a/clang/test/SemaOpenCL/address-spaces.cl b/clang/test/SemaOpenCL/address-spaces.cl | ||
3689 | index 2c4f0fdec524..98b9a39e78ea 100644 | ||
3690 | --- a/clang/test/SemaOpenCL/address-spaces.cl | ||
3691 | +++ b/clang/test/SemaOpenCL/address-spaces.cl | ||
3692 | @@ -1,5 +1,6 @@ | ||
3693 | // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only | ||
3694 | // RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only | ||
3695 | +// RUN: %clang_cc1 %s -cl-std=CL3.0 -cl-ext=+__opencl_c_generic_address_space -verify -pedantic -fsyntax-only | ||
3696 | // RUN: %clang_cc1 %s -cl-std=clc++ -verify -pedantic -fsyntax-only | ||
3697 | |||
3698 | __constant int ci = 1; | ||
3699 | diff --git a/clang/test/SemaOpenCL/arm-integer-dot-product.cl b/clang/test/SemaOpenCL/arm-integer-dot-product.cl | ||
3700 | index d7219d7402a9..5552f7777954 100644 | ||
3701 | --- a/clang/test/SemaOpenCL/arm-integer-dot-product.cl | ||
3702 | +++ b/clang/test/SemaOpenCL/arm-integer-dot-product.cl | ||
3703 | @@ -1,4 +1,4 @@ | ||
3704 | -// RUN: %clang_cc1 %s -triple spir-unknown-unknown -finclude-default-header -verify -cl-std=CL1.2 -emit-llvm -o - -O0 | ||
3705 | +// RUN: %clang_cc1 %s -triple spir-unknown-unknown -finclude-default-header -fdeclare-opencl-builtins -verify -cl-std=CL1.2 -emit-llvm -o - -cl-ext=-all | ||
3706 | |||
3707 | void test_negative() { | ||
3708 | uchar4 ua8, ub8; | ||
3709 | @@ -7,37 +7,13 @@ void test_negative() { | ||
3710 | short2 sa16, sb16; | ||
3711 | uint ur; | ||
3712 | int sr; | ||
3713 | - ur = arm_dot(ua8, ub8); // expected-error{{no matching function for call to 'arm_dot'}} | ||
3714 | - // expected-note@opencl-c.h:* {{candidate function not viable}} | ||
3715 | - // expected-note@opencl-c.h:* {{candidate unavailable as it requires OpenCL extension 'cl_arm_integer_dot_product_int8' to be enabled}} | ||
3716 | - sr = arm_dot(sa8, sb8); // expected-error{{no matching function for call to 'arm_dot'}} | ||
3717 | - // expected-note@opencl-c.h:* {{candidate function not viable}} | ||
3718 | - // expected-note@opencl-c.h:* {{candidate unavailable as it requires OpenCL extension 'cl_arm_integer_dot_product_int8' to be enabled}} | ||
3719 | - ur = arm_dot_acc(ua8, ub8, ur); // expected-error{{no matching function for call to 'arm_dot_acc'}} | ||
3720 | - // expected-note@opencl-c.h:* {{candidate function not viable}} | ||
3721 | - // expected-note@opencl-c.h:* {{candidate function not viable}} | ||
3722 | - // expected-note@opencl-c.h:* {{candidate function not viable}} | ||
3723 | - // expected-note@opencl-c.h:* {{candidate unavailable as it requires OpenCL extension 'cl_arm_integer_dot_product_accumulate_int8' to be enabled}} | ||
3724 | - sr = arm_dot_acc(sa8, sb8, sr); // expected-error{{no matching function for call to 'arm_dot_acc'}} | ||
3725 | - // expected-note@opencl-c.h:* {{candidate function not viable}} | ||
3726 | - // expected-note@opencl-c.h:* {{candidate function not viable}} | ||
3727 | - // expected-note@opencl-c.h:* {{candidate function not viable}} | ||
3728 | - // expected-note@opencl-c.h:* {{candidate unavailable as it requires OpenCL extension 'cl_arm_integer_dot_product_accumulate_int8' to be enabled}} | ||
3729 | - ur = arm_dot_acc(ua16, ub16, ur); // expected-error{{no matching function for call to 'arm_dot_acc'}} | ||
3730 | - // expected-note@opencl-c.h:* {{candidate function not viable}} | ||
3731 | - // expected-note@opencl-c.h:* {{candidate function not viable}} | ||
3732 | - // expected-note@opencl-c.h:* {{candidate function not viable}} | ||
3733 | - // expected-note@opencl-c.h:* {{candidate unavailable as it requires OpenCL extension 'cl_arm_integer_dot_product_accumulate_int16' to be enabled}} | ||
3734 | - sr = arm_dot_acc(sa16, sb16, sr); // expected-error{{no matching function for call to 'arm_dot_acc'}} | ||
3735 | - // expected-note@opencl-c.h:* {{candidate function not viable}} | ||
3736 | - // expected-note@opencl-c.h:* {{candidate function not viable}} | ||
3737 | - // expected-note@opencl-c.h:* {{candidate function not viable}} | ||
3738 | - // expected-note@opencl-c.h:* {{candidate unavailable as it requires OpenCL extension 'cl_arm_integer_dot_product_accumulate_int16' to be enabled}} | ||
3739 | - ur = arm_dot_acc_sat(ua8, ub8, ur); // expected-error{{no matching function for call to 'arm_dot_acc_sat'}} | ||
3740 | - // expected-note@opencl-c.h:* {{candidate function not viable}} | ||
3741 | - // expected-note@opencl-c.h:* {{candidate unavailable as it requires OpenCL extension 'cl_arm_integer_dot_product_accumulate_saturate_int8' to be enabled}} | ||
3742 | - sr = arm_dot_acc_sat(sa8, sb8, sr); // expected-error{{no matching function for call to 'arm_dot_acc_sat'}} | ||
3743 | - // expected-note@opencl-c.h:* {{candidate function not viable}} | ||
3744 | - // expected-note@opencl-c.h:* {{candidate unavailable as it requires OpenCL extension 'cl_arm_integer_dot_product_accumulate_saturate_int8' to be enabled}} | ||
3745 | + ur = arm_dot(ua8, ub8); // expected-error{{implicit declaration of function 'arm_dot' is invalid in OpenCL}} | ||
3746 | + sr = arm_dot(sa8, sb8); | ||
3747 | + ur = arm_dot_acc(ua8, ub8, ur); // expected-error{{implicit declaration of function 'arm_dot_acc' is invalid in OpenCL}} //expected-note{{'arm_dot_acc' declared here}} | ||
3748 | + sr = arm_dot_acc(sa8, sb8, sr); | ||
3749 | + ur = arm_dot_acc(ua16, ub16, ur); | ||
3750 | + sr = arm_dot_acc(sa16, sb16, sr); | ||
3751 | + ur = arm_dot_acc_sat(ua8, ub8, ur); // expected-error{{implicit declaration of function 'arm_dot_acc_sat' is invalid in OpenCL}} //expected-note{{did you mean 'arm_dot_acc'?}} | ||
3752 | + sr = arm_dot_acc_sat(sa8, sb8, sr); | ||
3753 | } | ||
3754 | |||
3755 | diff --git a/clang/test/SemaOpenCL/cl20-device-side-enqueue.cl b/clang/test/SemaOpenCL/cl20-device-side-enqueue.cl | ||
3756 | index f63e2913c749..d25a03504c03 100644 | ||
3757 | --- a/clang/test/SemaOpenCL/cl20-device-side-enqueue.cl | ||
3758 | +++ b/clang/test/SemaOpenCL/cl20-device-side-enqueue.cl | ||
3759 | @@ -235,11 +235,11 @@ kernel void bar(global unsigned int *buf) | ||
3760 | kernel void foo1(global unsigned int *buf) | ||
3761 | { | ||
3762 | ndrange_t n; | ||
3763 | - buf[0] = get_kernel_max_sub_group_size_for_ndrange(n, ^(){}); // expected-error {{use of declaration 'get_kernel_max_sub_group_size_for_ndrange' requires cl_khr_subgroups extension to be enabled}} | ||
3764 | + buf[0] = get_kernel_max_sub_group_size_for_ndrange(n, ^(){}); // expected-error {{use of declaration 'get_kernel_max_sub_group_size_for_ndrange' requires cl_khr_subgroups support}} | ||
3765 | } | ||
3766 | |||
3767 | kernel void bar1(global unsigned int *buf) | ||
3768 | { | ||
3769 | ndrange_t n; | ||
3770 | - buf[0] = get_kernel_sub_group_count_for_ndrange(n, ^(){}); // expected-error {{use of declaration 'get_kernel_sub_group_count_for_ndrange' requires cl_khr_subgroups extension to be enabled}} | ||
3771 | + buf[0] = get_kernel_sub_group_count_for_ndrange(n, ^(){}); // expected-error {{use of declaration 'get_kernel_sub_group_count_for_ndrange' requires cl_khr_subgroups support}} | ||
3772 | } | ||
3773 | diff --git a/clang/test/SemaOpenCL/extension-begin.cl b/clang/test/SemaOpenCL/extension-begin.cl | ||
3774 | index fdb481f8e092..9124ceba4e2a 100644 | ||
3775 | --- a/clang/test/SemaOpenCL/extension-begin.cl | ||
3776 | +++ b/clang/test/SemaOpenCL/extension-begin.cl | ||
3777 | @@ -29,25 +29,23 @@ | ||
3778 | #ifndef USE_PCH | ||
3779 | // expected-warning@extension-begin.h:4 {{expected 'disable' - ignoring}} | ||
3780 | // expected-warning@extension-begin.h:5 {{expected 'disable' - ignoring}} | ||
3781 | -// expected-warning@extension-begin.h:21 {{OpenCL extension end directive mismatches begin directive - ignoring}} | ||
3782 | #endif // USE_PCH | ||
3783 | |||
3784 | +#if defined(IMPLICIT_INCLUDE) && defined(USE_PCH) | ||
3785 | +//expected-no-diagnostics | ||
3786 | +#endif | ||
3787 | + | ||
3788 | +// Tests that the pragmas are accepted for backward compatibility. | ||
3789 | #pragma OPENCL EXTENSION my_ext : enable | ||
3790 | -void test_f1(void) { | ||
3791 | +#pragma OPENCL EXTENSION my_ext : disable | ||
3792 | + | ||
3793 | +#ifndef my_ext | ||
3794 | +#error "Missing my_ext macro" | ||
3795 | +#endif | ||
3796 | + | ||
3797 | +// When extension is supported its functionality can be used freely. | ||
3798 | +void test(void) { | ||
3799 | struct A test_A1; | ||
3800 | f(); | ||
3801 | g(0); | ||
3802 | } | ||
3803 | - | ||
3804 | -#pragma OPENCL EXTENSION my_ext : disable | ||
3805 | -void test_f2(void) { | ||
3806 | - struct A test_A2; // expected-error {{use of type 'struct A' requires my_ext extension to be enabled}} | ||
3807 | - const struct A test_A_local; // expected-error {{use of type 'struct A' requires my_ext extension to be enabled}} | ||
3808 | - TypedefOfA test_typedef_A; // expected-error {{use of type 'TypedefOfA' (aka 'struct A') requires my_ext extension to be enabled}} | ||
3809 | - PointerOfA test_A_pointer; // expected-error {{use of type 'PointerOfA' (aka 'const __private struct A *') requires my_ext extension to be enabled}} | ||
3810 | - f(); // expected-error {{use of declaration 'f' requires my_ext extension to be enabled}} | ||
3811 | - g(0); // expected-error {{no matching function for call to 'g'}} | ||
3812 | - // expected-note@extension-begin.h:18 {{candidate unavailable as it requires OpenCL extension 'my_ext' to be enabled}} | ||
3813 | - // expected-note@extension-begin.h:23 {{candidate function not viable: requires 0 arguments, but 1 was provided}} | ||
3814 | -} | ||
3815 | - | ||
3816 | diff --git a/clang/test/SemaOpenCL/extension-begin.h b/clang/test/SemaOpenCL/extension-begin.h | ||
3817 | index d9865ba0b33a..0e262e4adb93 100644 | ||
3818 | --- a/clang/test/SemaOpenCL/extension-begin.h | ||
3819 | +++ b/clang/test/SemaOpenCL/extension-begin.h | ||
3820 | @@ -5,10 +5,13 @@ | ||
3821 | #pragma OPENCL EXTENSION all : end | ||
3822 | |||
3823 | #pragma OPENCL EXTENSION my_ext : begin | ||
3824 | - | ||
3825 | struct A { | ||
3826 | int a; | ||
3827 | }; | ||
3828 | +#pragma OPENCL EXTENSION my_ext : end | ||
3829 | +#pragma OPENCL EXTENSION my_ext : end | ||
3830 | + | ||
3831 | +#define my_ext | ||
3832 | |||
3833 | typedef struct A TypedefOfA; | ||
3834 | typedef const __private TypedefOfA* PointerOfA; | ||
3835 | @@ -17,10 +20,8 @@ void f(void); | ||
3836 | |||
3837 | __attribute__((overloadable)) void g(long x); | ||
3838 | |||
3839 | -#pragma OPENCL EXTENSION my_ext : end | ||
3840 | -#pragma OPENCL EXTENSION my_ext : end | ||
3841 | + | ||
3842 | |||
3843 | __attribute__((overloadable)) void g(void); | ||
3844 | |||
3845 | #endif // INCLUDED | ||
3846 | - | ||
3847 | diff --git a/clang/test/SemaOpenCL/extension-version.cl b/clang/test/SemaOpenCL/extension-version.cl | ||
3848 | index b997a00145ef..6f26a23c4192 100644 | ||
3849 | --- a/clang/test/SemaOpenCL/extension-version.cl | ||
3850 | +++ b/clang/test/SemaOpenCL/extension-version.cl | ||
3851 | @@ -3,15 +3,13 @@ | ||
3852 | // RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple spir-unknown-unknown | ||
3853 | // RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple spir-unknown-unknown | ||
3854 | // RUN: %clang_cc1 -x cl -cl-std=clc++ %s -verify -triple spir-unknown-unknown | ||
3855 | +// RUN: %clang_cc1 -x cl -cl-std=CL3.0 %s -verify -triple spir-unknown-unknown | ||
3856 | // RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES | ||
3857 | // RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES | ||
3858 | // RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES | ||
3859 | // RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES | ||
3860 | // RUN: %clang_cc1 -x cl -cl-std=clc++ %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES | ||
3861 | - | ||
3862 | -#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) && !defined(TEST_CORE_FEATURES) | ||
3863 | -// expected-no-diagnostics | ||
3864 | -#endif | ||
3865 | +// RUN: %clang_cc1 -x cl -cl-std=CL3.0 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES | ||
3866 | |||
3867 | // Extensions in all versions | ||
3868 | #ifndef cl_clang_storage_class_specifiers | ||
3869 | @@ -95,12 +93,12 @@ | ||
3870 | // expected-warning@-2{{OpenCL extension 'cl_khr_fp64' is core feature or supported optional core feature - ignoring}} | ||
3871 | #endif | ||
3872 | |||
3873 | -//Core feature in CL 2.0 | ||
3874 | +//Core feature in CL 2.0, optional core feature in CL 3.0 | ||
3875 | #ifndef cl_khr_3d_image_writes | ||
3876 | #error "Missing cl_khr_3d_image_writes define" | ||
3877 | #endif | ||
3878 | #pragma OPENCL EXTENSION cl_khr_3d_image_writes : enable | ||
3879 | -#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) && defined TEST_CORE_FEATURES | ||
3880 | +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ == 200) && defined TEST_CORE_FEATURES | ||
3881 | // expected-warning@-2{{OpenCL extension 'cl_khr_3d_image_writes' is core feature or supported optional core feature - ignoring}} | ||
3882 | #endif | ||
3883 | |||
3884 | @@ -215,3 +213,55 @@ | ||
3885 | // expected-warning@+2{{unsupported OpenCL extension 'cl_intel_device_side_avc_motion_estimation' - ignoring}} | ||
3886 | #endif | ||
3887 | #pragma OPENCL EXTENSION cl_intel_device_side_avc_motion_estimation : enable | ||
3888 | + | ||
3889 | +// Check that pragmas for the OpenCL 3.0 features are rejected. | ||
3890 | + | ||
3891 | +#pragma OPENCL EXTENSION __opencl_c_int64 : disable | ||
3892 | +//expected-warning@-1{{unknown OpenCL extension '__opencl_c_int64' - ignoring}} | ||
3893 | +#pragma OPENCL EXTENSION __opencl_c_3d_image_writes : disable | ||
3894 | +//expected-warning@-1{{unknown OpenCL extension '__opencl_c_3d_image_writes' - ignoring}} | ||
3895 | +#pragma OPENCL EXTENSION __opencl_c_atomic_order_acq_rel : disable | ||
3896 | +//expected-warning@-1{{unknown OpenCL extension '__opencl_c_atomic_order_acq_rel' - ignoring}} | ||
3897 | +#pragma OPENCL EXTENSION __opencl_c_atomic_order_seq_cst : disable | ||
3898 | +//expected-warning@-1{{unknown OpenCL extension '__opencl_c_atomic_order_seq_cst' - ignoring}} | ||
3899 | +#pragma OPENCL EXTENSION __opencl_c_device_enqueue : disable | ||
3900 | +//expected-warning@-1{{unknown OpenCL extension '__opencl_c_device_enqueue' - ignoring}} | ||
3901 | +#pragma OPENCL EXTENSION __opencl_c_fp64 : disable | ||
3902 | +//expected-warning@-1{{unknown OpenCL extension '__opencl_c_fp64' - ignoring}} | ||
3903 | +#pragma OPENCL EXTENSION __opencl_c_generic_address_space : disable | ||
3904 | +//expected-warning@-1{{unknown OpenCL extension '__opencl_c_generic_address_space' - ignoring}} | ||
3905 | +#pragma OPENCL EXTENSION __opencl_c_images : disable | ||
3906 | +//expected-warning@-1{{unknown OpenCL extension '__opencl_c_images' - ignoring}} | ||
3907 | +#pragma OPENCL EXTENSION __opencl_c_pipes : disable | ||
3908 | +//expected-warning@-1{{unknown OpenCL extension '__opencl_c_pipes' - ignoring}} | ||
3909 | +#pragma OPENCL EXTENSION __opencl_c_program_scope_global_variables : disable | ||
3910 | +//expected-warning@-1{{unknown OpenCL extension '__opencl_c_program_scope_global_variables' - ignoring}} | ||
3911 | +#pragma OPENCL EXTENSION __opencl_c_read_write_images : disable | ||
3912 | +//expected-warning@-1{{unknown OpenCL extension '__opencl_c_read_write_images' - ignoring}} | ||
3913 | +#pragma OPENCL EXTENSION __opencl_c_subgroups : disable | ||
3914 | +//expected-warning@-1{{unknown OpenCL extension '__opencl_c_subgroups' - ignoring}} | ||
3915 | + | ||
3916 | +#pragma OPENCL EXTENSION __opencl_c_int64 : enable | ||
3917 | +//expected-warning@-1{{unknown OpenCL extension '__opencl_c_int64' - ignoring}} | ||
3918 | +#pragma OPENCL EXTENSION __opencl_c_3d_image_writes : enable | ||
3919 | +//expected-warning@-1{{unknown OpenCL extension '__opencl_c_3d_image_writes' - ignoring}} | ||
3920 | +#pragma OPENCL EXTENSION __opencl_c_atomic_order_acq_rel : enable | ||
3921 | +//expected-warning@-1{{unknown OpenCL extension '__opencl_c_atomic_order_acq_rel' - ignoring}} | ||
3922 | +#pragma OPENCL EXTENSION __opencl_c_atomic_order_seq_cst : enable | ||
3923 | +//expected-warning@-1{{unknown OpenCL extension '__opencl_c_atomic_order_seq_cst' - ignoring}} | ||
3924 | +#pragma OPENCL EXTENSION __opencl_c_device_enqueue : enable | ||
3925 | +//expected-warning@-1{{unknown OpenCL extension '__opencl_c_device_enqueue' - ignoring}} | ||
3926 | +#pragma OPENCL EXTENSION __opencl_c_fp64 : enable | ||
3927 | +//expected-warning@-1{{unknown OpenCL extension '__opencl_c_fp64' - ignoring}} | ||
3928 | +#pragma OPENCL EXTENSION __opencl_c_generic_address_space : enable | ||
3929 | +//expected-warning@-1{{unknown OpenCL extension '__opencl_c_generic_address_space' - ignoring}} | ||
3930 | +#pragma OPENCL EXTENSION __opencl_c_images : enable | ||
3931 | +//expected-warning@-1{{unknown OpenCL extension '__opencl_c_images' - ignoring}} | ||
3932 | +#pragma OPENCL EXTENSION __opencl_c_pipes : enable | ||
3933 | +//expected-warning@-1{{unknown OpenCL extension '__opencl_c_pipes' - ignoring}} | ||
3934 | +#pragma OPENCL EXTENSION __opencl_c_program_scope_global_variables : enable | ||
3935 | +//expected-warning@-1{{unknown OpenCL extension '__opencl_c_program_scope_global_variables' - ignoring}} | ||
3936 | +#pragma OPENCL EXTENSION __opencl_c_read_write_images : enable | ||
3937 | +//expected-warning@-1{{unknown OpenCL extension '__opencl_c_read_write_images' - ignoring}} | ||
3938 | +#pragma OPENCL EXTENSION __opencl_c_subgroups : enable | ||
3939 | +//expected-warning@-1{{unknown OpenCL extension '__opencl_c_subgroups' - ignoring}} | ||
3940 | diff --git a/clang/test/SemaOpenCL/extensions.cl b/clang/test/SemaOpenCL/extensions.cl | ||
3941 | index 55dbd1d5eede..d43cdcece2e4 100644 | ||
3942 | --- a/clang/test/SemaOpenCL/extensions.cl | ||
3943 | +++ b/clang/test/SemaOpenCL/extensions.cl | ||
3944 | @@ -1,26 +1,34 @@ | ||
3945 | -// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only | ||
3946 | +// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL1.0 | ||
3947 | // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL1.1 | ||
3948 | +// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -fsyntax-only -cl-std=CL1.1 -DNOPEDANTIC | ||
3949 | // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL1.2 -DFP64 | ||
3950 | |||
3951 | // Test with a target not supporting fp64. | ||
3952 | -// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64 -DNOFP16 | ||
3953 | +// RUN: %clang_cc1 %s -cl-std=CL1.0 -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64 -DNOFP16 | ||
3954 | +// RUN: %clang_cc1 -cl-std=CL3.0 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64 -DNOFP16 | ||
3955 | |||
3956 | // Test with some extensions enabled or disabled by cmd-line args | ||
3957 | // | ||
3958 | // Target does not support fp64 and fp16 - override it | ||
3959 | -// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+cl_khr_fp64,+cl_khr_fp16 | ||
3960 | +// RUN: %clang_cc1 %s -cl-std=CL1.0 -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+cl_khr_fp64,+cl_khr_fp16 | ||
3961 | // | ||
3962 | // Disable or enable all extensions | ||
3963 | -// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -DNOFP64 -DNOFP16 | ||
3964 | -// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all | ||
3965 | -// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all,-cl_khr_fp64 -DNOFP64 | ||
3966 | -// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=-all,+cl_khr_fp64 -DNOFP16 | ||
3967 | +// RUN: %clang_cc1 %s -cl-std=CL1.0 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -DNOFP64 -DNOFP16 | ||
3968 | +// RUN: %clang_cc1 %s -cl-std=CL1.0 -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all | ||
3969 | +// RUN: %clang_cc1 %s -cl-std=CL1.0 -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all,-cl_khr_fp64 -DNOFP64 | ||
3970 | +// RUN: %clang_cc1 %s -cl-std=CL1.0 -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=-all,+cl_khr_fp64 -DNOFP16 | ||
3971 | +// RUN: %clang_cc1 -cl-std=CL3.0 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -DNOFP64 -DNOFP16 | ||
3972 | +// RUN: %clang_cc1 -cl-std=CL3.0 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all -DFP64 | ||
3973 | +// RUN: %clang_cc1 -cl-std=CL3.0 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all,-__opencl_c_fp64,-cl_khr_fp64 -DNOFP64 | ||
3974 | // | ||
3975 | // Concatenating | ||
3976 | -// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-cl_khr_fp64 -cl-ext=+cl_khr_fp64 | ||
3977 | -// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-cl_khr_fp64,+cl_khr_fp64 | ||
3978 | -// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -cl-ext=+cl_khr_fp64 -cl-ext=+cl_khr_fp16 -cl-ext=-cl_khr_fp64 -DNOFP64 | ||
3979 | +// RUN: %clang_cc1 %s -cl-std=CL1.0 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-cl_khr_fp64 -cl-ext=+cl_khr_fp64 | ||
3980 | +// RUN: %clang_cc1 %s -cl-std=CL1.0 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-cl_khr_fp64,+cl_khr_fp64 | ||
3981 | +// RUN: %clang_cc1 %s -cl-std=CL1.0 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -cl-ext=+cl_khr_fp64 -cl-ext=+cl_khr_fp16 -cl-ext=-cl_khr_fp64 -DNOFP64 | ||
3982 | // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -cl-ext=+cl_khr_fp64,-cl_khr_fp64,+cl_khr_fp16 -DNOFP64 | ||
3983 | +// RUN: %clang_cc1 -cl-std=CL3.0 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-__opencl_c_fp64,-cl_khr_fp64 -cl-ext=+__opencl_c_fp64,+cl_khr_fp64 -DFP64 | ||
3984 | +// RUN: %clang_cc1 -cl-std=CL3.0 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-__opencl_c_fp64,+__opencl_c_fp64,+cl_khr_fp64 -DFP64 | ||
3985 | +// RUN: %clang_cc1 -cl-std=CL3.0 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-__opencl_c_fp64,-cl_khr_fp64 -DNOFP64 | ||
3986 | |||
3987 | // Test with -finclude-default-header, which includes opencl-c.h. opencl-c.h | ||
3988 | // disables all extensions by default, but supported core extensions for a | ||
3989 | @@ -43,8 +51,20 @@ | ||
3990 | #endif | ||
3991 | |||
3992 | #if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 120) | ||
3993 | -void f1(double da) { // expected-error {{type 'double' requires cl_khr_fp64 extension}} | ||
3994 | - double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}} | ||
3995 | +void f1(double da) { | ||
3996 | +#ifdef NOFP64 | ||
3997 | +// expected-error@-2 {{type 'double' requires cl_khr_fp64 support}} | ||
3998 | +#elif !defined(NOPEDANTIC) | ||
3999 | +// expected-warning@-4{{Clang permits use of type 'double' regardless pragma if 'cl_khr_fp64' is supported}} | ||
4000 | +#endif | ||
4001 | + double d; | ||
4002 | +#ifdef NOFP64 | ||
4003 | +// expected-error@-2 {{type 'double' requires cl_khr_fp64 support}} | ||
4004 | +#elif !defined(NOPEDANTIC) | ||
4005 | +// expected-warning@-4{{Clang permits use of type 'double' regardless pragma if 'cl_khr_fp64' is supported}} | ||
4006 | +#endif | ||
4007 | + // FIXME: this diagnostic depends on the extension pragma in the earlier versions. | ||
4008 | + // There is no indication that this behavior is expected. | ||
4009 | (void) 1.0; // expected-warning {{double precision constant requires cl_khr_fp64}} | ||
4010 | } | ||
4011 | #endif | ||
4012 | @@ -72,20 +92,30 @@ int isfinite(float x) { | ||
4013 | void f2(void) { | ||
4014 | double d; | ||
4015 | #ifdef NOFP64 | ||
4016 | -// expected-error@-2{{use of type 'double' requires cl_khr_fp64 extension to be enabled}} | ||
4017 | +#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ >= 300) | ||
4018 | +// expected-error@-3{{use of type 'double' requires cl_khr_fp64 and __opencl_c_fp64 support}} | ||
4019 | +#else | ||
4020 | +// expected-error@-5{{use of type 'double' requires cl_khr_fp64 support}} | ||
4021 | +#endif | ||
4022 | #endif | ||
4023 | |||
4024 | typedef double double4 __attribute__((ext_vector_type(4))); | ||
4025 | double4 d4 = {0.0f, 2.0f, 3.0f, 1.0f}; | ||
4026 | #ifdef NOFP64 | ||
4027 | -// expected-error@-3 {{use of type 'double' requires cl_khr_fp64 extension to be enabled}} | ||
4028 | -// expected-error@-3 {{use of type 'double4' (vector of 4 'double' values) requires cl_khr_fp64 extension to be enabled}} | ||
4029 | +#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ >= 300) | ||
4030 | +// expected-error@-4 {{use of type 'double' requires cl_khr_fp64 and __opencl_c_fp64 support}} | ||
4031 | +#else | ||
4032 | +// expected-error@-6 {{use of type 'double' requires cl_khr_fp64 support}} | ||
4033 | +#endif | ||
4034 | #endif | ||
4035 | |||
4036 | (void) 1.0; | ||
4037 | - | ||
4038 | #ifdef NOFP64 | ||
4039 | -// expected-warning@-3{{double precision constant requires cl_khr_fp64, casting to single precision}} | ||
4040 | +#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ >= 300) | ||
4041 | +// expected-warning@-3{{double precision constant requires cl_khr_fp64 and __opencl_c_fp64, casting to single precision}} | ||
4042 | +#else | ||
4043 | +// expected-warning@-5{{double precision constant requires cl_khr_fp64, casting to single precision}} | ||
4044 | +#endif | ||
4045 | #endif | ||
4046 | } | ||
4047 | |||
4048 | @@ -96,6 +126,11 @@ void f2(void) { | ||
4049 | |||
4050 | #if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 120) | ||
4051 | void f3(void) { | ||
4052 | - double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}} | ||
4053 | + double d; | ||
4054 | +#ifdef NOFP64 | ||
4055 | +// expected-error@-2 {{type 'double' requires cl_khr_fp64 support}} | ||
4056 | +#elif !defined(NOPEDANTIC) | ||
4057 | +// expected-warning@-4 {{Clang permits use of type 'double' regardless pragma if 'cl_khr_fp64' is supported}} | ||
4058 | +#endif | ||
4059 | } | ||
4060 | #endif | ||
4061 | diff --git a/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl b/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl | ||
4062 | index d1dcdfe8cb35..2db651836cb1 100644 | ||
4063 | --- a/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl | ||
4064 | +++ b/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl | ||
4065 | @@ -39,26 +39,7 @@ kernel void test_pointers(volatile global void *global_p, global const int4 *a) | ||
4066 | prefetch(a, 2); | ||
4067 | |||
4068 | atom_add((volatile __global int *)global_p, i); | ||
4069 | -#if !defined(__OPENCL_CPP_VERSION__) && __OPENCL_C_VERSION__ < CL_VERSION_1_1 | ||
4070 | -// expected-error@-2{{no matching function for call to 'atom_add'}} | ||
4071 | - | ||
4072 | -// There are two potential definitions of the function "atom_add", both are | ||
4073 | -// currently disabled because the associated extension is disabled. | ||
4074 | -// expected-note@-6{{candidate function not viable: cannot pass pointer to address space '__global' as a pointer to address space '__local' in 1st argument}} | ||
4075 | -// expected-note@-7{{candidate function not viable: no known conversion}} | ||
4076 | -// expected-note@-8{{candidate function not viable: no known conversion}} | ||
4077 | -// expected-note@-9{{candidate function not viable: no known conversion}} | ||
4078 | -// expected-note@-10{{candidate unavailable as it requires OpenCL extension 'cl_khr_global_int32_base_atomics' to be enabled}} | ||
4079 | -// expected-note@-11{{candidate unavailable as it requires OpenCL extension 'cl_khr_global_int32_base_atomics' to be enabled}} | ||
4080 | -// expected-note@-12{{candidate unavailable as it requires OpenCL extension 'cl_khr_int64_base_atomics' to be enabled}} | ||
4081 | -// expected-note@-13{{candidate unavailable as it requires OpenCL extension 'cl_khr_int64_base_atomics' to be enabled}} | ||
4082 | -#endif | ||
4083 | - | ||
4084 | -#if __OPENCL_C_VERSION__ < CL_VERSION_1_1 | ||
4085 | -#pragma OPENCL EXTENSION cl_khr_global_int32_base_atomics : enable | ||
4086 | -#endif | ||
4087 | |||
4088 | - atom_add((volatile __global int *)global_p, i); | ||
4089 | atom_cmpxchg((volatile __global unsigned int *)global_p, ui, ui); | ||
4090 | } | ||
4091 | |||
4092 | @@ -140,11 +121,9 @@ kernel void basic_image_writeonly(write_only image1d_buffer_t image_write_only_i | ||
4093 | |||
4094 | kernel void basic_subgroup(global uint *out) { | ||
4095 | out[0] = get_sub_group_size(); | ||
4096 | -#if defined(__OPENCL_CPP_VERSION__) | ||
4097 | - // expected-error@-2{{no matching function for call to 'get_sub_group_size'}} | ||
4098 | - // expected-note@-3{{candidate unavailable as it requires OpenCL extension 'cl_khr_subgroups' to be enabled}} | ||
4099 | -#else | ||
4100 | - // expected-error@-5{{use of declaration 'get_sub_group_size' requires cl_khr_subgroups extension to be enabled}} | ||
4101 | +#if __OPENCL_C_VERSION__ <= CL_VERSION_1_2 && !defined(__OPENCL_CPP_VERSION__) | ||
4102 | + // expected-error@-2{{implicit declaration of function 'get_sub_group_size' is invalid in OpenCL}} | ||
4103 | + // expected-error@-3{{implicit conversion changes signedness}} | ||
4104 | #endif | ||
4105 | } | ||
4106 | |||
4107 | diff --git a/clang/test/SemaOpenCL/features.cl b/clang/test/SemaOpenCL/features.cl | ||
4108 | new file mode 100644 | ||
4109 | index 000000000000..57c52694b685 | ||
4110 | --- /dev/null | ||
4111 | +++ b/clang/test/SemaOpenCL/features.cl | ||
4112 | @@ -0,0 +1,48 @@ | ||
4113 | +// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=CL3.0 -cl-ext=-all \ | ||
4114 | +// RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES | ||
4115 | +// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=CL3.0 -cl-ext=+all \ | ||
4116 | +// RUN: | FileCheck -match-full-lines %s --check-prefix=FEATURES | ||
4117 | +// RUN: %clang_cc1 -triple r600-unknown-unknown %s -E -dM -o - -x cl -cl-std=CL3.0 \ | ||
4118 | +// RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES | ||
4119 | +// RUN: %clang_cc1 -triple r600-unknown-unknown %s -E -dM -o - -x cl -cl-std=CL3.0 -cl-ext=+all \ | ||
4120 | +// RUN: | FileCheck -match-full-lines %s --check-prefix=FEATURES | ||
4121 | + | ||
4122 | +// For OpenCL C 2.0 feature macros are defined only in header, so test that earlier OpenCL | ||
4123 | +// versions don't define feature macros accidentally and CL2.0 don't define them without header | ||
4124 | +// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=CL1.1 \ | ||
4125 | +// RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES | ||
4126 | +// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=CL1.2 \ | ||
4127 | +// RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES | ||
4128 | +// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=CL2.0 \ | ||
4129 | +// RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES | ||
4130 | +// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=CLC++ \ | ||
4131 | +// RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES | ||
4132 | + | ||
4133 | +// Note that __opencl_c_int64 is always defined assuming | ||
4134 | +// always compiling for FULL OpenCL profile | ||
4135 | + | ||
4136 | +// FEATURES: #define __opencl_c_3d_image_writes 1 | ||
4137 | +// FEATURES: #define __opencl_c_atomic_order_acq_rel 1 | ||
4138 | +// FEATURES: #define __opencl_c_atomic_order_seq_cst 1 | ||
4139 | +// FEATURES: #define __opencl_c_device_enqueue 1 | ||
4140 | +// FEATURES: #define __opencl_c_fp64 1 | ||
4141 | +// FEATURES: #define __opencl_c_generic_address_space 1 | ||
4142 | +// FEATURES: #define __opencl_c_images 1 | ||
4143 | +// FEATURES: #define __opencl_c_int64 1 | ||
4144 | +// FEATURES: #define __opencl_c_pipes 1 | ||
4145 | +// FEATURES: #define __opencl_c_program_scope_global_variables 1 | ||
4146 | +// FEATURES: #define __opencl_c_read_write_images 1 | ||
4147 | +// FEATURES: #define __opencl_c_subgroups 1 | ||
4148 | + | ||
4149 | +// NO-FEATURES: #define __opencl_c_int64 1 | ||
4150 | +// NO-FEATURES-NOT: __opencl_c_3d_image_writes | ||
4151 | +// NO-FEATURES-NOT: __opencl_c_atomic_order_acq_rel | ||
4152 | +// NO-FEATURES-NOT: __opencl_c_atomic_order_seq_cst | ||
4153 | +// NO-FEATURES-NOT: __opencl_c_device_enqueue | ||
4154 | +// NO-FEATURES-NOT: __opencl_c_fp64 | ||
4155 | +// NO-FEATURES-NOT: __opencl_c_generic_address_space | ||
4156 | +// NO-FEATURES-NOT: __opencl_c_images | ||
4157 | +// NO-FEATURES-NOT: __opencl_c_pipes | ||
4158 | +// NO-FEATURES-NOT: __opencl_c_program_scope_global_variables | ||
4159 | +// NO-FEATURES-NOT: __opencl_c_read_write_images | ||
4160 | +// NO-FEATURES-NOT: __opencl_c_subgroups | ||
4161 | diff --git a/clang/test/SemaOpenCL/intel-subgroup-avc-ext-types.cl b/clang/test/SemaOpenCL/intel-subgroup-avc-ext-types.cl | ||
4162 | index e76d54763016..48ed4c0594d6 100644 | ||
4163 | --- a/clang/test/SemaOpenCL/intel-subgroup-avc-ext-types.cl | ||
4164 | +++ b/clang/test/SemaOpenCL/intel-subgroup-avc-ext-types.cl | ||
4165 | @@ -1,6 +1,9 @@ | ||
4166 | -// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=CL1.2 -cl-ext=+cl_intel_device_side_avc_motion_estimation -fsyntax-only -verify %s | ||
4167 | +// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=CL1.2 -cl-ext=+cl_intel_device_side_avc_motion_estimation -fsyntax-only -verify -DEXT %s | ||
4168 | +// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=CL1.2 -cl-ext=-cl_intel_device_side_avc_motion_estimation -fsyntax-only -verify %s | ||
4169 | |||
4170 | +#ifdef cl_intel_device_side_avc_motion_estimation | ||
4171 | #pragma OPENCL EXTENSION cl_intel_device_side_avc_motion_estimation : enable | ||
4172 | +#endif | ||
4173 | |||
4174 | // All intel_sub_group_avc_* types can only be used as argument or return value | ||
4175 | // of built-in functions defined in the extension. | ||
4176 | @@ -16,55 +19,77 @@ struct st{}; | ||
4177 | // negative test cases for initializers | ||
4178 | void foo(char c, float f, void* v, struct st ss) { | ||
4179 | intel_sub_group_avc_mce_payload_t payload_mce = 0; // No zero initializer for mce types | ||
4180 | - // expected-error@-1 {{initializing '__private intel_sub_group_avc_mce_payload_t' with an expression of incompatible type 'int'}} | ||
4181 | intel_sub_group_avc_ime_payload_t payload_ime = 1; // No literal initializer for *payload_t types | ||
4182 | - // expected-error@-1 {{initializing '__private intel_sub_group_avc_ime_payload_t' with an expression of incompatible type 'int'}} | ||
4183 | intel_sub_group_avc_ref_payload_t payload_ref = f; | ||
4184 | - // expected-error@-1 {{initializing '__private intel_sub_group_avc_ref_payload_t' with an expression of incompatible type '__private float'}} | ||
4185 | intel_sub_group_avc_sic_payload_t payload_sic = ss; | ||
4186 | - // expected-error@-1 {{initializing '__private intel_sub_group_avc_sic_payload_t' with an expression of incompatible type '__private struct st'}} | ||
4187 | - | ||
4188 | intel_sub_group_avc_mce_result_t result_mce = 0; // No zero initializer for mce types | ||
4189 | - // expected-error@-1 {{initializing '__private intel_sub_group_avc_mce_result_t' with an expression of incompatible type 'int'}} | ||
4190 | intel_sub_group_avc_ime_result_t result_ime = 1; // No literal initializer for *result_t types | ||
4191 | - // expected-error@-1 {{initializing '__private intel_sub_group_avc_ime_result_t' with an expression of incompatible type 'int'}} | ||
4192 | intel_sub_group_avc_ref_result_t result_ref = f; | ||
4193 | - // expected-error@-1 {{initializing '__private intel_sub_group_avc_ref_result_t' with an expression of incompatible type '__private float'}} | ||
4194 | intel_sub_group_avc_sic_result_t result_sic = ss; | ||
4195 | - // expected-error@-1 {{initializing '__private intel_sub_group_avc_sic_result_t' with an expression of incompatible type '__private struct st'}} | ||
4196 | - | ||
4197 | intel_sub_group_avc_ime_result_single_reference_streamout_t sstreamout = v; | ||
4198 | - // expected-error@-1 {{initializing '__private intel_sub_group_avc_ime_result_single_reference_streamout_t' with an expression of incompatible type '__private void *__private'}} | ||
4199 | - | ||
4200 | intel_sub_group_avc_ime_result_dual_reference_streamout_t dstreamin_list = {0x0, 0x1}; | ||
4201 | - // expected-warning@-1 {{excess elements in struct initializer}} | ||
4202 | intel_sub_group_avc_ime_dual_reference_streamin_t dstreamin_list2 = {}; | ||
4203 | - // expected-error@-1 {{scalar initializer cannot be empty}} | ||
4204 | intel_sub_group_avc_ime_single_reference_streamin_t dstreamin_list3 = {c}; | ||
4205 | - // expected-error@-1 {{initializing '__private intel_sub_group_avc_ime_single_reference_streamin_t' with an expression of incompatible type '__private char'}} | ||
4206 | intel_sub_group_avc_ime_dual_reference_streamin_t dstreamin_list4 = {1}; | ||
4207 | - // expected-error@-1 {{initializing '__private intel_sub_group_avc_ime_dual_reference_streamin_t' with an expression of incompatible type 'int'}} | ||
4208 | +#ifdef EXT | ||
4209 | +// expected-error@-14 {{initializing '__private intel_sub_group_avc_mce_payload_t' with an expression of incompatible type 'int'}} | ||
4210 | +// expected-error@-14 {{initializing '__private intel_sub_group_avc_ime_payload_t' with an expression of incompatible type 'int'}} | ||
4211 | +// expected-error@-14 {{initializing '__private intel_sub_group_avc_ref_payload_t' with an expression of incompatible type '__private float'}} | ||
4212 | +// expected-error@-14 {{initializing '__private intel_sub_group_avc_sic_payload_t' with an expression of incompatible type '__private struct st'}} | ||
4213 | +// expected-error@-14 {{initializing '__private intel_sub_group_avc_mce_result_t' with an expression of incompatible type 'int'}} | ||
4214 | +// expected-error@-14 {{initializing '__private intel_sub_group_avc_ime_result_t' with an expression of incompatible type 'int'}} | ||
4215 | +// expected-error@-14 {{initializing '__private intel_sub_group_avc_ref_result_t' with an expression of incompatible type '__private float'}} | ||
4216 | +// expected-error@-14 {{initializing '__private intel_sub_group_avc_sic_result_t' with an expression of incompatible type '__private struct st'}} | ||
4217 | +// expected-error@-14 {{initializing '__private intel_sub_group_avc_ime_result_single_reference_streamout_t' with an expression of incompatible type '__private void *__private'}} | ||
4218 | +// expected-warning@-14 {{excess elements in struct initializer}} | ||
4219 | +// expected-error@-14 {{scalar initializer cannot be empty}} | ||
4220 | +// expected-error@-14 {{initializing '__private intel_sub_group_avc_ime_single_reference_streamin_t' with an expression of incompatible type '__private char'}} | ||
4221 | +// expected-error@-14 {{initializing '__private intel_sub_group_avc_ime_dual_reference_streamin_t' with an expression of incompatible type 'int'}} | ||
4222 | +#else | ||
4223 | +// expected-error@-28 {{use of undeclared identifier 'intel_sub_group_avc_mce_payload_t'}} | ||
4224 | +// expected-error@-28 {{use of undeclared identifier 'intel_sub_group_avc_ime_payload_t'}} | ||
4225 | +// expected-error@-28 {{use of undeclared identifier 'intel_sub_group_avc_ref_payload_t'}} | ||
4226 | +// expected-error@-28 {{use of undeclared identifier 'intel_sub_group_avc_sic_payload_t'}} | ||
4227 | +// expected-error@-28 {{use of undeclared identifier 'intel_sub_group_avc_mce_result_t'}} | ||
4228 | +// expected-error@-28 {{use of undeclared identifier 'intel_sub_group_avc_ime_result_t'}} | ||
4229 | +// expected-error@-28 {{use of undeclared identifier 'intel_sub_group_avc_ref_result_t'}} | ||
4230 | +// expected-error@-28 {{use of undeclared identifier 'intel_sub_group_avc_sic_result_t'}} | ||
4231 | +// expected-error@-28 {{use of undeclared identifier 'intel_sub_group_avc_ime_result_single_reference_streamout_t'}} | ||
4232 | +// expected-error@-28 {{use of undeclared identifier 'intel_sub_group_avc_ime_result_dual_reference_streamout_t'}} | ||
4233 | +// expected-error@-28 {{use of undeclared identifier 'intel_sub_group_avc_ime_dual_reference_streamin_t'}} | ||
4234 | +// expected-error@-28 {{use of undeclared identifier 'intel_sub_group_avc_ime_single_reference_streamin_t'}} | ||
4235 | +// expected-error@-28 {{use of undeclared identifier 'intel_sub_group_avc_ime_dual_reference_streamin_t'}} | ||
4236 | +#endif | ||
4237 | } | ||
4238 | |||
4239 | // negative tests for initializers and assignment | ||
4240 | void far() { | ||
4241 | intel_sub_group_avc_mce_payload_t payload_mce; | ||
4242 | intel_sub_group_avc_mce_payload_t payload_mce2 = payload_mce; | ||
4243 | - | ||
4244 | intel_sub_group_avc_ime_payload_t payload_ime; | ||
4245 | intel_sub_group_avc_ref_payload_t payload_ref = payload_ime; | ||
4246 | - // expected-error@-1 {{initializing '__private intel_sub_group_avc_ref_payload_t' with an expression of incompatible type '__private intel_sub_group_avc_ime_payload_t'}} | ||
4247 | - | ||
4248 | intel_sub_group_avc_sic_result_t result_sic; | ||
4249 | intel_sub_group_avc_ime_result_t result_ime; | ||
4250 | result_sic = result_ime; | ||
4251 | - // expected-error@-1 {{assigning to '__private intel_sub_group_avc_sic_result_t' from incompatible type '__private intel_sub_group_avc_ime_result_t'}} | ||
4252 | +#ifdef EXT | ||
4253 | +// expected-error@-5 {{initializing '__private intel_sub_group_avc_ref_payload_t' with an expression of incompatible type '__private intel_sub_group_avc_ime_payload_t'}} | ||
4254 | +// expected-error@-3 {{assigning to '__private intel_sub_group_avc_sic_result_t' from incompatible type '__private intel_sub_group_avc_ime_result_t'}} | ||
4255 | +#else | ||
4256 | +// expected-error@-11 {{use of undeclared identifier 'intel_sub_group_avc_mce_payload_t'}} | ||
4257 | +// expected-error@-11 {{use of undeclared identifier 'intel_sub_group_avc_mce_payload_t'}} | ||
4258 | +// expected-error@-11 {{use of undeclared identifier 'intel_sub_group_avc_ime_payload_t'}} | ||
4259 | +// expected-error@-11 {{use of undeclared identifier 'intel_sub_group_avc_ref_payload_t'}} | ||
4260 | +// expected-error@-11 {{use of undeclared identifier 'intel_sub_group_avc_sic_result_t'}} | ||
4261 | +// expected-error@-11 {{use of undeclared identifier 'intel_sub_group_avc_ime_result_t'}} | ||
4262 | +// expected-error@-11 {{use of undeclared identifier 'result_sic'}} expected-error@-11 {{use of undeclared identifier 'result_ime'}} | ||
4263 | +#endif | ||
4264 | } | ||
4265 | |||
4266 | // Using 0x0 directly allows us not to include opencl-c.h header and not to | ||
4267 | // redefine all of these CLK_AVC_*_INTITIALIZE_INTEL macro. '0x0' value must | ||
4268 | // be in sync with ones defined in opencl-c.h | ||
4269 | |||
4270 | +#ifdef EXT | ||
4271 | // positive test cases | ||
4272 | void bar() { | ||
4273 | const sampler_t vme_sampler = 0x0; | ||
4274 | @@ -102,4 +127,4 @@ void bar() { | ||
4275 | intel_sub_group_avc_ime_single_reference_streamin_t sstreamin_list = {0}; | ||
4276 | intel_sub_group_avc_ime_dual_reference_streamin_t dstreamin_list = {0}; | ||
4277 | } | ||
4278 | - | ||
4279 | +#endif //EXT | ||
4280 | diff --git a/clang/test/SemaOpenCL/storageclass.cl b/clang/test/SemaOpenCL/storageclass.cl | ||
4281 | index f35ab9c2e08c..060aff2354d1 100644 | ||
4282 | --- a/clang/test/SemaOpenCL/storageclass.cl | ||
4283 | +++ b/clang/test/SemaOpenCL/storageclass.cl | ||
4284 | @@ -1,28 +1,118 @@ | ||
4285 | // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2 | ||
4286 | - | ||
4287 | +// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=-__opencl_c_program_scope_global_variables,-__opencl_c_generic_address_space | ||
4288 | +// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_program_scope_global_variables,-__opencl_c_generic_address_space | ||
4289 | +// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=-__opencl_c_program_scope_global_variables,+__opencl_c_generic_address_space | ||
4290 | +// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_program_scope_global_variables,+__opencl_c_generic_address_space | ||
4291 | static constant int G1 = 0; | ||
4292 | constant int G2 = 0; | ||
4293 | -int G3 = 0; // expected-error{{program scope variable must reside in constant address space}} | ||
4294 | -global int G4 = 0; // expected-error{{program scope variable must reside in constant address space}} | ||
4295 | |||
4296 | -static float g_implicit_static_var = 0; // expected-error {{program scope variable must reside in constant address space}} | ||
4297 | +int G3 = 0; | ||
4298 | +#ifndef __opencl_c_program_scope_global_variables | ||
4299 | +// expected-error@-2 {{program scope variable must reside in constant address space}} | ||
4300 | +#endif | ||
4301 | + | ||
4302 | +global int G4 = 0; | ||
4303 | +#ifndef __opencl_c_program_scope_global_variables | ||
4304 | +// expected-error@-2 {{program scope variable must reside in constant address space}} | ||
4305 | +#endif | ||
4306 | + | ||
4307 | +static float g_implicit_static_var = 0; | ||
4308 | +#ifndef __opencl_c_program_scope_global_variables | ||
4309 | +// expected-error@-2 {{program scope variable must reside in constant address space}} | ||
4310 | +#endif | ||
4311 | + | ||
4312 | static constant float g_constant_static_var = 0; | ||
4313 | -static global float g_global_static_var = 0; // expected-error {{program scope variable must reside in constant address space}} | ||
4314 | -static local float g_local_static_var = 0; // expected-error {{program scope variable must reside in constant address space}} | ||
4315 | -static private float g_private_static_var = 0; // expected-error {{program scope variable must reside in constant address space}} | ||
4316 | -static generic float g_generic_static_var = 0; // expected-error{{OpenCL C version 1.2 does not support the 'generic' type qualifier}} // expected-error {{program scope variable must reside in constant address space}} | ||
4317 | |||
4318 | -extern float g_implicit_extern_var; // expected-error {{extern variable must reside in constant address space}} | ||
4319 | +static global float g_global_static_var = 0; | ||
4320 | +#ifndef __opencl_c_program_scope_global_variables | ||
4321 | +// expected-error@-2 {{program scope variable must reside in constant address space}} | ||
4322 | +#endif | ||
4323 | + | ||
4324 | +static local float g_local_static_var = 0; | ||
4325 | +#ifndef __opencl_c_program_scope_global_variables | ||
4326 | +// expected-error@-2 {{program scope variable must reside in constant address space}} | ||
4327 | +#else | ||
4328 | +// expected-error@-4 {{program scope variable must reside in global or constant address space}} | ||
4329 | +#endif | ||
4330 | + | ||
4331 | +static private float g_private_static_var = 0; | ||
4332 | +#ifndef __opencl_c_program_scope_global_variables | ||
4333 | +// expected-error@-2 {{program scope variable must reside in constant address space}} | ||
4334 | +#else | ||
4335 | +// expected-error@-4 {{program scope variable must reside in global or constant address space}} | ||
4336 | +#endif | ||
4337 | + | ||
4338 | +static generic float g_generic_static_var = 0; | ||
4339 | +#if (__OPENCL_C_VERSION__ < 300) | ||
4340 | +// expected-error@-2 {{OpenCL C version 1.2 does not support the 'generic' type qualifier}} | ||
4341 | +// expected-error@-3 {{program scope variable must reside in constant address space}} | ||
4342 | +#elif (__OPENCL_C_VERSION__ == 300) | ||
4343 | + #if !defined(__opencl_c_generic_address_space) | ||
4344 | +// expected-error@-6 {{OpenCL C version 3.0 does not support the 'generic' type qualifier}} | ||
4345 | + #endif | ||
4346 | + #if !defined(__opencl_c_program_scope_global_variables) | ||
4347 | +// expected-error@-9 {{program scope variable must reside in constant address space}} | ||
4348 | + #endif | ||
4349 | + #if defined(__opencl_c_generic_address_space) && defined(__opencl_c_program_scope_global_variables) | ||
4350 | +// expected-error@-12 {{program scope variable must reside in global or constant address space}} | ||
4351 | + #endif | ||
4352 | +#endif | ||
4353 | + | ||
4354 | +extern float g_implicit_extern_var; | ||
4355 | +#ifndef __opencl_c_program_scope_global_variables | ||
4356 | +// expected-error@-2 {{extern variable must reside in constant address space}} | ||
4357 | +#endif | ||
4358 | + | ||
4359 | extern constant float g_constant_extern_var; | ||
4360 | -extern global float g_global_extern_var; // expected-error {{extern variable must reside in constant address space}} | ||
4361 | -extern local float g_local_extern_var; // expected-error {{extern variable must reside in constant address space}} | ||
4362 | -extern private float g_private_extern_var; // expected-error {{extern variable must reside in constant address space}} | ||
4363 | -extern generic float g_generic_extern_var; // expected-error{{OpenCL C version 1.2 does not support the 'generic' type qualifier}} // expected-error {{extern variable must reside in constant address space}} | ||
4364 | + | ||
4365 | +extern global float g_global_extern_var; | ||
4366 | +#ifndef __opencl_c_program_scope_global_variables | ||
4367 | +// expected-error@-2 {{extern variable must reside in constant address space}} | ||
4368 | +#endif | ||
4369 | + | ||
4370 | +extern local float g_local_extern_var; | ||
4371 | +#ifndef __opencl_c_program_scope_global_variables | ||
4372 | +// expected-error@-2 {{extern variable must reside in constant address space}} | ||
4373 | +#else | ||
4374 | +// expected-error@-4 {{extern variable must reside in global or constant address space}} | ||
4375 | +#endif | ||
4376 | + | ||
4377 | +extern private float g_private_extern_var; | ||
4378 | +#ifndef __opencl_c_program_scope_global_variables | ||
4379 | +// expected-error@-2 {{extern variable must reside in constant address space}} | ||
4380 | +#else | ||
4381 | +// expected-error@-4 {{extern variable must reside in global or constant address space}} | ||
4382 | +#endif | ||
4383 | + | ||
4384 | +extern generic float g_generic_extern_var; | ||
4385 | +#if (__OPENCL_C_VERSION__ < 300) | ||
4386 | +// expected-error@-2 {{OpenCL C version 1.2 does not support the 'generic' type qualifier}} | ||
4387 | +// expected-error@-3 {{extern variable must reside in constant address space}} | ||
4388 | +#elif (__OPENCL_C_VERSION__ == 300) | ||
4389 | + #if !defined(__opencl_c_generic_address_space) | ||
4390 | +// expected-error@-6 {{OpenCL C version 3.0 does not support the 'generic' type qualifier}} | ||
4391 | + #endif | ||
4392 | + #if !defined(__opencl_c_program_scope_global_variables) | ||
4393 | +// expected-error@-9 {{extern variable must reside in constant address space}} | ||
4394 | + #endif | ||
4395 | + #if defined(__opencl_c_generic_address_space) && defined(__opencl_c_program_scope_global_variables) | ||
4396 | +// expected-error@-12 {{extern variable must reside in global or constant address space}} | ||
4397 | + #endif | ||
4398 | +#endif | ||
4399 | |||
4400 | void kernel foo(int x) { | ||
4401 | // static is not allowed at local scope before CL2.0 | ||
4402 | - static int S1 = 5; // expected-error{{variables in function scope cannot be declared static}} | ||
4403 | - static constant int S2 = 5; // expected-error{{variables in function scope cannot be declared static}} | ||
4404 | + static int S1 = 5; | ||
4405 | +#if __OPENCL_C_VERSION__ < 300 | ||
4406 | +// expected-error@-2 {{variables in function scope cannot be declared static}} | ||
4407 | +#elif !defined(__opencl_c_program_scope_global_variables) | ||
4408 | +// expected-error@-4 {{static local variable must reside in constant address space}} | ||
4409 | +#endif | ||
4410 | + | ||
4411 | + static constant int S2 = 5; | ||
4412 | +#if __OPENCL_C_VERSION__ < 300 | ||
4413 | +// expected-error@-2 {{variables in function scope cannot be declared static}} | ||
4414 | +#endif | ||
4415 | |||
4416 | constant int L1 = 0; | ||
4417 | local int L2; | ||
4418 | @@ -32,12 +122,13 @@ void kernel foo(int x) { | ||
4419 | constant int L1 = 42; // expected-error {{variables in the constant address space can only be declared in the outermost scope of a kernel function}} | ||
4420 | } | ||
4421 | |||
4422 | - auto int L3 = 7; // expected-error{{OpenCL C version 1.2 does not support the 'auto' storage class specifier}} | ||
4423 | + auto int L3 = 7; // expected-error-re{{OpenCL C version {{1.2|3.0}} does not support the 'auto' storage class specifier}} | ||
4424 | global int L4; // expected-error{{function scope variable cannot be declared in global address space}} | ||
4425 | __attribute__((address_space(100))) int L5; // expected-error{{automatic variable qualified with an invalid address space}} | ||
4426 | |||
4427 | constant int L6 = x; // expected-error {{initializer element is not a compile-time constant}} | ||
4428 | global int *constant L7 = &G4; | ||
4429 | + | ||
4430 | private int *constant L8 = &x; // expected-error {{initializer element is not a compile-time constant}} | ||
4431 | constant int *constant L9 = &L1; | ||
4432 | local int *constant L10 = &L2; // expected-error {{initializer element is not a compile-time constant}} | ||
4433 | @@ -59,17 +150,106 @@ void f() { | ||
4434 | __attribute__((address_space(100))) int L4; // expected-error{{automatic variable qualified with an invalid address space}} | ||
4435 | } | ||
4436 | |||
4437 | - static float l_implicit_static_var = 0; // expected-error {{variables in function scope cannot be declared static}} | ||
4438 | - static constant float l_constant_static_var = 0; // expected-error {{variables in function scope cannot be declared static}} | ||
4439 | - static global float l_global_static_var = 0; // expected-error {{variables in function scope cannot be declared static}} | ||
4440 | - static local float l_local_static_var = 0; // expected-error {{variables in function scope cannot be declared static}} | ||
4441 | - static private float l_private_static_var = 0; // expected-error {{variables in function scope cannot be declared static}} | ||
4442 | - static generic float l_generic_static_var = 0; // expected-error{{OpenCL C version 1.2 does not support the 'generic' type qualifier}} // expected-error {{variables in function scope cannot be declared static}} | ||
4443 | + static float l_implicit_static_var = 0; | ||
4444 | +#if __OPENCL_C_VERSION__ < 300 | ||
4445 | +// expected-error@-2 {{variables in function scope cannot be declared static}} | ||
4446 | +#elif !defined(__opencl_c_program_scope_global_variables) | ||
4447 | +// expected-error@-4 {{static local variable must reside in constant address space}} | ||
4448 | +#endif | ||
4449 | + | ||
4450 | + static constant float l_constant_static_var = 0; | ||
4451 | +#if __OPENCL_C_VERSION__ < 300 | ||
4452 | +// expected-error@-2 {{variables in function scope cannot be declared static}} | ||
4453 | +#endif | ||
4454 | + | ||
4455 | + static global float l_global_static_var = 0; | ||
4456 | +#if __OPENCL_C_VERSION__ < 300 | ||
4457 | +// expected-error@-2 {{variables in function scope cannot be declared static}} | ||
4458 | +#elif !defined(__opencl_c_program_scope_global_variables) | ||
4459 | +// expected-error@-4 {{static local variable must reside in constant address space}} | ||
4460 | +#endif | ||
4461 | + | ||
4462 | + static local float l_local_static_var = 0; | ||
4463 | +#if __OPENCL_C_VERSION__ < 300 | ||
4464 | +// expected-error@-2 {{variables in function scope cannot be declared static}} | ||
4465 | +#elif !defined(__opencl_c_program_scope_global_variables) | ||
4466 | +// expected-error@-4 {{static local variable must reside in constant address space}} | ||
4467 | +#elif defined(__opencl_c_program_scope_global_variables) | ||
4468 | +// expected-error@-6 {{static local variable must reside in global or constant address space}} | ||
4469 | +#endif | ||
4470 | + | ||
4471 | + static private float l_private_static_var = 0; | ||
4472 | +#if __OPENCL_C_VERSION__ < 300 | ||
4473 | +// expected-error@-2 {{variables in function scope cannot be declared static}} | ||
4474 | +#elif !defined(__opencl_c_program_scope_global_variables) | ||
4475 | +// expected-error@-4 {{static local variable must reside in constant address space}} | ||
4476 | +#elif defined(__opencl_c_program_scope_global_variables) | ||
4477 | +// expected-error@-6 {{static local variable must reside in global or constant address space}} | ||
4478 | +#endif | ||
4479 | + | ||
4480 | + static generic float l_generic_static_var = 0; | ||
4481 | +#if (__OPENCL_C_VERSION__ < 300) | ||
4482 | +// expected-error@-2 {{OpenCL C version 1.2 does not support the 'generic' type qualifier}} | ||
4483 | +// expected-error@-3 {{variables in function scope cannot be declared static}} | ||
4484 | +#elif (__OPENCL_C_VERSION__ == 300) | ||
4485 | + #if !defined(__opencl_c_generic_address_space) | ||
4486 | +// expected-error@-6 {{OpenCL C version 3.0 does not support the 'generic' type qualifier}} | ||
4487 | + #endif | ||
4488 | + #if !defined(__opencl_c_program_scope_global_variables) | ||
4489 | +// expected-error@-9 {{static local variable must reside in constant address space}} | ||
4490 | + #endif | ||
4491 | + #if defined(__opencl_c_generic_address_space) && defined(__opencl_c_program_scope_global_variables) | ||
4492 | +// expected-error@-12 {{static local variable must reside in global or constant address space}} | ||
4493 | + #endif | ||
4494 | +#endif | ||
4495 | + | ||
4496 | + extern float l_implicit_extern_var; | ||
4497 | +#if __OPENCL_C_VERSION__ < 300 | ||
4498 | +// expected-error@-2 {{extern variable must reside in constant address space}} | ||
4499 | +#elif !defined(__opencl_c_program_scope_global_variables) | ||
4500 | +// expected-error@-4 {{extern variable must reside in constant address space}} | ||
4501 | +#endif | ||
4502 | |||
4503 | - extern float l_implicit_extern_var; // expected-error {{extern variable must reside in constant address space}} | ||
4504 | extern constant float l_constant_extern_var; | ||
4505 | - extern global float l_global_extern_var; // expected-error {{extern variable must reside in constant address space}} | ||
4506 | - extern local float l_local_extern_var; // expected-error {{extern variable must reside in constant address space}} | ||
4507 | - extern private float l_private_extern_var; // expected-error {{extern variable must reside in constant address space}} | ||
4508 | - extern generic float l_generic_extern_var; // expected-error{{OpenCL C version 1.2 does not support the 'generic' type qualifier}} // expected-error {{extern variable must reside in constant address space}} | ||
4509 | + | ||
4510 | + extern global float l_global_extern_var; | ||
4511 | +#if __OPENCL_C_VERSION__ < 300 | ||
4512 | +// expected-error@-2 {{extern variable must reside in constant address space}} | ||
4513 | +#elif !defined(__opencl_c_program_scope_global_variables) | ||
4514 | +// expected-error@-4 {{extern variable must reside in constant address space}} | ||
4515 | +#endif | ||
4516 | + | ||
4517 | + extern local float l_local_extern_var; | ||
4518 | +#if __OPENCL_C_VERSION__ < 300 | ||
4519 | +// expected-error@-2 {{extern variable must reside in constant address space}} | ||
4520 | +#elif !defined(__opencl_c_program_scope_global_variables) | ||
4521 | +// expected-error@-4 {{extern variable must reside in constant address space}} | ||
4522 | +#elif defined(__opencl_c_program_scope_global_variables) | ||
4523 | +// expected-error@-6 {{extern variable must reside in global or constant address space}} | ||
4524 | +#endif | ||
4525 | + | ||
4526 | + extern private float l_private_extern_var; | ||
4527 | +#if __OPENCL_C_VERSION__ < 300 | ||
4528 | +// expected-error@-2 {{extern variable must reside in constant address space}} | ||
4529 | +#elif !defined(__opencl_c_program_scope_global_variables) | ||
4530 | +// expected-error@-4 {{extern variable must reside in constant address space}} | ||
4531 | +#elif defined(__opencl_c_program_scope_global_variables) | ||
4532 | +// expected-error@-6 {{extern variable must reside in global or constant address space}} | ||
4533 | +#endif | ||
4534 | + | ||
4535 | + extern generic float l_generic_extern_var; | ||
4536 | +#if (__OPENCL_C_VERSION__ < 300) | ||
4537 | +// expected-error@-2 {{OpenCL C version 1.2 does not support the 'generic' type qualifier}} | ||
4538 | +// expected-error@-3 {{extern variable must reside in constant address space}} | ||
4539 | +#elif (__OPENCL_C_VERSION__ == 300) | ||
4540 | + #if !defined(__opencl_c_generic_address_space) | ||
4541 | +// expected-error@-6 {{OpenCL C version 3.0 does not support the 'generic' type qualifier}} | ||
4542 | + #endif | ||
4543 | + #if !defined(__opencl_c_program_scope_global_variables) | ||
4544 | +// expected-error@-9 {{extern variable must reside in constant address space}} | ||
4545 | + #endif | ||
4546 | + #if defined(__opencl_c_generic_address_space) && defined(__opencl_c_program_scope_global_variables) | ||
4547 | +// expected-error@-12 {{extern variable must reside in global or constant address space}} | ||
4548 | + #endif | ||
4549 | +#endif | ||
4550 | } | ||
4551 | diff --git a/clang/test/SemaOpenCL/unsupported-image.cl b/clang/test/SemaOpenCL/unsupported-image.cl | ||
4552 | new file mode 100644 | ||
4553 | index 000000000000..40772460e54d | ||
4554 | --- /dev/null | ||
4555 | +++ b/clang/test/SemaOpenCL/unsupported-image.cl | ||
4556 | @@ -0,0 +1,69 @@ | ||
4557 | +// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 -cl-ext=-__opencl_c_images,-__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes %s | ||
4558 | +// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 -cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,+cl_khr_3d_image_writes,+__opencl_c_3d_image_writes %s | ||
4559 | +// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 -cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes %s | ||
4560 | + | ||
4561 | +#if defined(__opencl_c_images) && defined(__opencl_c_3d_image_writes) | ||
4562 | +//expected-no-diagnostics | ||
4563 | +#endif | ||
4564 | + | ||
4565 | +void test1(image1d_t i) {} | ||
4566 | +#if !defined(__opencl_c_images) | ||
4567 | +// expected-error@-2{{use of type '__read_only image1d_t' requires __opencl_c_images support}} | ||
4568 | +#endif | ||
4569 | + | ||
4570 | +void test2(image2d_t i) {} | ||
4571 | +#if !defined(__opencl_c_images) | ||
4572 | +// expected-error@-2{{use of type '__read_only image2d_t' requires __opencl_c_images support}} | ||
4573 | +#endif | ||
4574 | + | ||
4575 | +void test3(image1d_array_t i) {} | ||
4576 | +#if !defined(__opencl_c_images) | ||
4577 | +// expected-error@-2{{use of type '__read_only image1d_array_t' requires __opencl_c_images support}} | ||
4578 | +#endif | ||
4579 | + | ||
4580 | +void test4(image2d_array_t i) {} | ||
4581 | +#if !defined(__opencl_c_images) | ||
4582 | +// expected-error@-2{{use of type '__read_only image2d_array_t' requires __opencl_c_images support}} | ||
4583 | +#endif | ||
4584 | + | ||
4585 | +void test5(image2d_depth_t i) {} | ||
4586 | +#if !defined(__opencl_c_images) | ||
4587 | +// expected-error@-2{{use of type '__read_only image2d_depth_t' requires __opencl_c_images support}} | ||
4588 | +#endif | ||
4589 | + | ||
4590 | +void test6(image1d_buffer_t i) {} | ||
4591 | +#if !defined(__opencl_c_images) | ||
4592 | +// expected-error@-2{{use of type '__read_only image1d_buffer_t' requires __opencl_c_images support}} | ||
4593 | +#endif | ||
4594 | + | ||
4595 | +void test7(image2d_msaa_t i) {} | ||
4596 | +#if !defined(__opencl_c_images) | ||
4597 | +// expected-error@-2{{use of type '__read_only image2d_msaa_t' requires __opencl_c_images support}} | ||
4598 | +#endif | ||
4599 | + | ||
4600 | +void test8(image2d_array_msaa_t i) {} | ||
4601 | +#if !defined(__opencl_c_images) | ||
4602 | +// expected-error@-2{{use of type '__read_only image2d_array_msaa_t' requires __opencl_c_images support}} | ||
4603 | +#endif | ||
4604 | + | ||
4605 | +void test9(image2d_msaa_depth_t i) {} | ||
4606 | +#if !defined(__opencl_c_images) | ||
4607 | +// expected-error@-2{{use of type '__read_only image2d_msaa_depth_t' requires __opencl_c_images support}} | ||
4608 | +#endif | ||
4609 | + | ||
4610 | +void test10(image2d_array_msaa_depth_t i) {} | ||
4611 | +#if !defined(__opencl_c_images) | ||
4612 | +// expected-error@-2{{use of type '__read_only image2d_array_msaa_depth_t' requires __opencl_c_images support}} | ||
4613 | +#endif | ||
4614 | + | ||
4615 | +void test11(sampler_t s) {} | ||
4616 | +#if !defined(__opencl_c_images) | ||
4617 | +// expected-error@-2{{use of type 'sampler_t' requires __opencl_c_images support}} | ||
4618 | +#endif | ||
4619 | + | ||
4620 | +void test12(write_only image3d_t i) {} | ||
4621 | +#if !defined(__opencl_c_images) | ||
4622 | +// expected-error@-2{{use of type '__write_only image3d_t' requires __opencl_c_images support}} | ||
4623 | +#elif !defined(__opencl_c_3d_image_writes) | ||
4624 | +// expected-error@-4{{use of type '__write_only image3d_t' requires cl_khr_3d_image_writes and __opencl_c_3d_image_writes support}} | ||
4625 | +#endif | ||
4626 | -- | ||
4627 | 2.18.1 | ||
4628 | |||