Skip to content

Commit ca3bebd

Browse files
committed
[OpenCL] Supports optional writing to 3d images in C++ for OpenCL 2021
Adds support for a feature macro __opencl_c_3d_image_writes in C++ for OpenCL 2021 enabling a respective optional core feature from OpenCL 3.0. This change aims to achieve compatibility between C++ for OpenCL 2021 and OpenCL 3.0. Differential Revision: https://reviews.llvm.org/D109328
1 parent 13aa102 commit ca3bebd

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

clang/lib/Sema/SemaType.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1732,10 +1732,6 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) {
17321732

17331733
if (S.getLangOpts().OpenCL) {
17341734
const auto &OpenCLOptions = S.getOpenCLOptions();
1735-
// FIXME: both variables IsOpenCLC30 and IsOpenCLC30Compatible should be
1736-
// unified into one when __opencl_c_3d_image_writes option is enabled in
1737-
// C++ for OpenCL 2021
1738-
bool IsOpenCLC30 = (S.getLangOpts().OpenCLVersion == 300);
17391735
bool IsOpenCLC30Compatible =
17401736
S.getLangOpts().getOpenCLCompatibleVersion() == 300;
17411737
// OpenCL C v3.0 s6.3.3 - OpenCL image types require __opencl_c_images
@@ -1756,7 +1752,7 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) {
17561752
S.getLangOpts())) {
17571753
S.Diag(DS.getTypeSpecTypeLoc(), diag::err_opencl_requires_extension)
17581754
<< 0 << Result
1759-
<< (IsOpenCLC30
1755+
<< (IsOpenCLC30Compatible
17601756
? "cl_khr_3d_image_writes and __opencl_c_3d_image_writes"
17611757
: "cl_khr_3d_image_writes");
17621758
declarator.setInvalidType();

clang/test/Misc/opencl-c-3.0.incorrect_options.cl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// RUN: not %clang_cc1 -cl-std=clc++2021 -triple spir-unknown-unknown -cl-ext=+__opencl_c_pipes,-__opencl_c_generic_address_space %s 2>&1 | FileCheck -check-prefix=CHECK-PIPES %s
99
// RUN: not %clang_cc1 -cl-std=CL3.0 -triple spir-unknown-unknown -cl-ext=+__opencl_c_3d_image_writes,+__opencl_c_images,-cl_khr_3d_image_writes %s 2>&1 | FileCheck -check-prefix=CHECK-3D-WRITE-IMAGES-DIFF %s
1010
// RUN: not %clang_cc1 -cl-std=CL3.0 -triple spir-unknown-unknown -cl-ext=+__opencl_c_3d_image_writes,-__opencl_c_images %s 2>&1 | FileCheck -check-prefix=CHECK-3D-WRITE-IMAGES-DEPS %s
11+
// RUN: not %clang_cc1 -cl-std=clc++2021 -triple spir-unknown-unknown -cl-ext=+__opencl_c_3d_image_writes,+__opencl_c_images,-cl_khr_3d_image_writes %s 2>&1 | FileCheck -check-prefix=CHECK-3D-WRITE-IMAGES-DIFF %s
12+
// RUN: not %clang_cc1 -cl-std=clc++2021 -triple spir-unknown-unknown -cl-ext=+__opencl_c_3d_image_writes,-__opencl_c_images %s 2>&1 | FileCheck -check-prefix=CHECK-3D-WRITE-IMAGES-DEPS %s
1113

1214
// CHECK-FP64: error: options cl_khr_fp64 and __opencl_c_fp64 are set to different values
1315

clang/test/SemaOpenCL/unsupported-image.cl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
// 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
33
// 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
44
// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 -cl-ext=-__opencl_c_images,-__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes %s
5-
// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 -cl-ext=+__opencl_c_images %s
5+
// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 -cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,+cl_khr_3d_image_writes,+__opencl_c_3d_image_writes %s
6+
// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 -cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes %s
67

78
#if defined(__opencl_c_images) && defined(__opencl_c_3d_image_writes)
89
//expected-no-diagnostics

0 commit comments

Comments
 (0)