[clang] [Clang][OpenCL] Wrap image functions with the macro (PR #129177)

Victor Mustya via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 27 19:21:04 PST 2025


https://github.com/vmustya created https://github.com/llvm/llvm-project/pull/129177

According to the OpenCL C spec, the image functions are optional.
For OpenCL C 1.2, the image functions are guarded by the
`__IMAGE_SUPPORT__` macro. For the OpenCL C 3.0 and later, the
`__opencl_c_images` macro is used.

>From 781a2a826cc7ebb29d91c8b7143affe7c94cac24 Mon Sep 17 00:00:00 2001
From: Victor Mustya <victor.mustya at intel.com>
Date: Thu, 27 Feb 2025 17:28:36 -0800
Subject: [PATCH] [Clang][OpenCL] Wrap image functions with the macro

According to the OpenCL C spec, the image functions are optional.
For OpenCL C 1.2, the image functions are guarded by the
`__IMAGE_SUPPORT__` macro. For the OpenCL C 3.0 and later, the
`__opencl_c_images` macro is used.
---
 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..8d8ef497cec49 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) || defined(__IMAGE_SUPPORT__))
 /**
  * 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) || defined(__IMAGE_SUPPORT__))
+
 // OpenCL v2.0 s6.13.15 - Work-group Functions
 
 #if defined(__opencl_c_work_group_collective_functions)



More information about the cfe-commits mailing list