https://github.com/vmustya updated https://github.com/llvm/llvm-project/pull/129171
>From 98ae8631af5d672fc7a86c19f2b84c2efb6ceea0 Mon Sep 17 00:00:00 2001 From: Victor Mustya <victor.mus...@intel.com> Date: Thu, 27 Feb 2025 17:28:36 -0800 Subject: [PATCH 1/2] [Clang][OpenCL] Wrap image functions with the macro According to the OpenCL C 3.0 spec, the image functions are optional. If they are supported, the `__opencl_c_images` macro is defined. This patch wraps the image functions with the macro. Without the wrapping, the frontend emit errors, when a user tries to disable the images support. --- clang/lib/Headers/opencl-c.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h index 20719b74b6b8d..d77cf3c7b2faa 100644 --- a/clang/lib/Headers/opencl-c.h +++ b/clang/lib/Headers/opencl-c.h @@ -15082,6 +15082,7 @@ half16 __ovld __cnfn shuffle2(half16, half16, ushort16); #pragma OPENCL EXTENSION cl_khr_gl_msaa_sharing : enable #endif //cl_khr_gl_msaa_sharing +#if defined(__opencl_c_images) /** * Use the coordinate (coord.xy) to do an element lookup in * the 2D image object specified by image. @@ -16143,6 +16144,8 @@ int __ovld __cnfn get_image_num_samples(read_write image2d_array_msaa_depth_t); #endif //defined(__opencl_c_read_write_images) #endif +#endif // defined(__opencl_c_images) + // OpenCL v2.0 s6.13.15 - Work-group Functions #if defined(__opencl_c_work_group_collective_functions) >From 1145dc35c481875e3994f9367070f564606db464 Mon Sep 17 00:00:00 2001 From: Victor Mustya <victor.mus...@intel.com> Date: Thu, 27 Feb 2025 18:47:18 -0800 Subject: [PATCH 2/2] Enable images for OpenCL C 1.2 --- clang/lib/Headers/opencl-c-base.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/clang/lib/Headers/opencl-c-base.h b/clang/lib/Headers/opencl-c-base.h index b6bcf32c09c08..1c66342f82808 100644 --- a/clang/lib/Headers/opencl-c-base.h +++ b/clang/lib/Headers/opencl-c-base.h @@ -55,6 +55,10 @@ #endif // defined(__SPIR__) || defined(__SPIRV__) #endif // (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) +#if (__OPENCL_C_VERSION__ == 120) +#define __opencl_c_images 1 +#endif // (__OPENCL_C_VERSION__ == 120) + // Define feature macros for OpenCL C 2.0 #if (__OPENCL_CPP_VERSION__ == 100 || __OPENCL_C_VERSION__ == 200) #define __opencl_c_pipes 1 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits