From 9b8f2ef109a173adae267744b5ea4a6546fd9049 Mon Sep 17 00:00:00 2001 From: Wenju He Date: Fri, 14 Nov 2025 05:36:20 +0100 Subject: [PATCH 1/8] [OpenCL] Add missing OpenCL C 3.0 optional features to OpenCLExtensions.def Adds the remaining optional feature macros from the OpenCL C 3.0 spec (section 6.2.1 table). Targets can now enable these via OpenCLFeaturesMap returned by getSupportedOpenCLOpts(). --- clang/include/clang/Basic/OpenCLExtensions.def | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/clang/include/clang/Basic/OpenCLExtensions.def b/clang/include/clang/Basic/OpenCLExtensions.def index 6f73b26137500..b705e256fbbfe 100644 --- a/clang/include/clang/Basic/OpenCLExtensions.def +++ b/clang/include/clang/Basic/OpenCLExtensions.def @@ -104,6 +104,8 @@ OPENCL_OPTIONALCOREFEATURE(__opencl_c_pipes, false, 300, OCL_C_30) OPENCL_OPTIONALCOREFEATURE(__opencl_c_generic_address_space, false, 300, OCL_C_30) OPENCL_OPTIONALCOREFEATURE(__opencl_c_atomic_order_acq_rel, false, 300, OCL_C_30) OPENCL_OPTIONALCOREFEATURE(__opencl_c_atomic_order_seq_cst, false, 300, OCL_C_30) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_atomic_scope_device, false, 300, OCL_C_30) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_atomic_scope_all_devices, false, 300, OCL_C_30) OPENCL_OPTIONALCOREFEATURE(__opencl_c_subgroups, false, 300, OCL_C_30) OPENCL_OPTIONALCOREFEATURE(__opencl_c_3d_image_writes, false, 300, OCL_C_30) OPENCL_OPTIONALCOREFEATURE(__opencl_c_device_enqueue, false, 300, OCL_C_30) @@ -111,6 +113,14 @@ OPENCL_OPTIONALCOREFEATURE(__opencl_c_read_write_images, false, 300, OCL_C_30) OPENCL_OPTIONALCOREFEATURE(__opencl_c_program_scope_global_variables, false, 300, OCL_C_30) OPENCL_OPTIONALCOREFEATURE(__opencl_c_fp64, false, 300, OCL_C_30) OPENCL_OPTIONALCOREFEATURE(__opencl_c_images, false, 300, OCL_C_30) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_work_group_collective_functions, false, 300, OCL_C_30) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_integer_dot_product_input_4x8bit_packed, false, 300, OCL_C_30) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_integer_dot_product_input_4x8bit, false, 300, OCL_C_30) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_kernel_clock_scope_device, false, 300, OCL_C_30) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_kernel_clock_scope_work_group, false, 300, OCL_C_30) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_kernel_clock_scope_sub_group, false, 300, OCL_C_30) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_image_unorm_int_2_101010, false, 300, OCL_C_30) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_image_unsigned_10x6_12x4_14x2, false, 300, OCL_C_30) #undef OPENCL_OPTIONALCOREFEATURE #undef OPENCL_COREFEATURE From da29d83cd4b1dd536a5bf966bcfd8968f498f875 Mon Sep 17 00:00:00 2001 From: Wenju He Date: Tue, 18 Nov 2025 06:41:36 +0100 Subject: [PATCH 2/8] revert header-only feature macros for OpenCL C 3.0 --- clang/lib/Headers/opencl-c-base.h | 13 ------- clang/test/SemaOpenCL/features.cl | 65 ++++++++++++++++++++----------- 2 files changed, 43 insertions(+), 35 deletions(-) diff --git a/clang/lib/Headers/opencl-c-base.h b/clang/lib/Headers/opencl-c-base.h index 414f10ad832ce..09e5cdbd2dd48 100644 --- a/clang/lib/Headers/opencl-c-base.h +++ b/clang/lib/Headers/opencl-c-base.h @@ -71,19 +71,6 @@ #define __opencl_c_images 1 #endif -// Define header-only feature macros for OpenCL C 3.0. -#if (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) -// For the SPIR and SPIR-V target all features are supported. -#if defined(__SPIR__) || defined(__SPIRV__) -#define __opencl_c_work_group_collective_functions 1 -#define __opencl_c_atomic_order_seq_cst 1 -#define __opencl_c_atomic_scope_device 1 -#define __opencl_c_atomic_scope_all_devices 1 -#define __opencl_c_read_write_images 1 -#endif // defined(__SPIR__) - -#endif // (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) - // Undefine any feature macros that have been explicitly disabled using // an __undef_ macro. #ifdef __undef___opencl_c_work_group_collective_functions diff --git a/clang/test/SemaOpenCL/features.cl b/clang/test/SemaOpenCL/features.cl index dd82689c415ad..d880d168be570 100644 --- a/clang/test/SemaOpenCL/features.cl +++ b/clang/test/SemaOpenCL/features.cl @@ -34,12 +34,12 @@ // For OpenCL C 3.0, header-only features can be disabled using macros. // RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=CL3.0 -fdeclare-opencl-builtins -finclude-default-header \ -// RUN: -D__undef___opencl_c_work_group_collective_functions=1 \ -// RUN: -D__undef___opencl_c_atomic_order_seq_cst=1 \ -// RUN: -D__undef___opencl_c_atomic_scope_device=1 \ -// RUN: -D__undef___opencl_c_atomic_scope_all_devices=1 \ -// RUN: -D__undef___opencl_c_read_write_images=1 \ -// RUN: | FileCheck %s --check-prefix=NO-HEADERONLY-FEATURES +// RUN: -cl-ext=-__opencl_c_work_group_collective_functions, \ +// RUN: -cl-ext=-__opencl_c_atomic_order_seq_cst \ +// RUN: -cl-ext=-__opencl_c_atomic_scope_device \ +// RUN: -cl-ext=-__opencl_c_atomic_scope_all_devices \ +// RUN: -cl-ext=-__opencl_c_read_write_images \ +// RUN: | FileCheck %s --check-prefix=DISABLE-FEATURES // Note that __opencl_c_int64 is always defined assuming // always compiling for FULL OpenCL profile @@ -47,34 +47,55 @@ // FEATURES: #define __opencl_c_3d_image_writes 1 // FEATURES: #define __opencl_c_atomic_order_acq_rel 1 // FEATURES: #define __opencl_c_atomic_order_seq_cst 1 +// FEATURES: #define __opencl_c_atomic_scope_all_devices 1 +// FEATURES: #define __opencl_c_atomic_scope_device 1 // FEATURES: #define __opencl_c_device_enqueue 1 +// FEATURES: #define __opencl_c_ext_image_unorm_int_2_101010 1 +// FEATURES: #define __opencl_c_ext_image_unsigned_10x6_12x4_14x2 1 // FEATURES: #define __opencl_c_fp64 1 // FEATURES: #define __opencl_c_generic_address_space 1 // FEATURES: #define __opencl_c_images 1 // FEATURES: #define __opencl_c_int64 1 +// FEATURES: #define __opencl_c_integer_dot_product_input_4x8bit 1 +// FEATURES: #define __opencl_c_integer_dot_product_input_4x8bit_packed 1 +// FEATURES: #define __opencl_c_kernel_clock_scope_device 1 +// FEATURES: #define __opencl_c_kernel_clock_scope_sub_group 1 +// FEATURES: #define __opencl_c_kernel_clock_scope_work_group 1 // FEATURES: #define __opencl_c_pipes 1 // FEATURES: #define __opencl_c_program_scope_global_variables 1 // FEATURES: #define __opencl_c_read_write_images 1 // FEATURES: #define __opencl_c_subgroups 1 +// FEATURES: #define __opencl_c_work_group_collective_functions 1 // NO-FEATURES: #define __opencl_c_int64 1 -// NO-FEATURES-NOT: #define __opencl_c_3d_image_writes -// NO-FEATURES-NOT: #define __opencl_c_atomic_order_acq_rel -// NO-FEATURES-NOT: #define __opencl_c_atomic_order_seq_cst -// NO-FEATURES-NOT: #define __opencl_c_device_enqueue -// NO-FEATURES-NOT: #define __opencl_c_fp64 -// NO-FEATURES-NOT: #define __opencl_c_generic_address_space -// NO-FEATURES-NOT: #define __opencl_c_images -// NO-FEATURES-NOT: #define __opencl_c_pipes -// NO-FEATURES-NOT: #define __opencl_c_program_scope_global_variables -// NO-FEATURES-NOT: #define __opencl_c_read_write_images -// NO-FEATURES-NOT: #define __opencl_c_subgroups +// NO-FEATURES-NOT: #define __opencl_c_3d_image_writes 1 +// NO-FEATURES-NOT: #define __opencl_c_atomic_order_acq_rel 1 +// NO-FEATURES-NOT: #define __opencl_c_atomic_order_seq_cst 1 +// NO-FEATURES-NOT: #define __opencl_c_atomic_scope_all_devices 1 +// NO-FEATURES-NOT: #define __opencl_c_atomic_scope_device 1 +// NO-FEATURES-NOT: #define __opencl_c_device_enqueue 1 +// NO-FEATURES-NOT: #define __opencl_c_ext_image_unorm_int_2_101010 1 +// NO-FEATURES-NOT: #define __opencl_c_ext_image_unsigned_10x6_12x4_14x2 1 +// NO-FEATURES-NOT: #define __opencl_c_fp64 1 +// NO-FEATURES-NOT: #define __opencl_c_generic_address_space 1 +// NO-FEATURES-NOT: #define __opencl_c_images 1 +// NO-FEATURES-NOT: #define __opencl_c_int64 1 +// NO-FEATURES-NOT: #define __opencl_c_integer_dot_product_input_4x8bit 1 +// NO-FEATURES-NOT: #define __opencl_c_integer_dot_product_input_4x8bit_packed 1 +// NO-FEATURES-NOT: #define __opencl_c_kernel_clock_scope_device 1 +// NO-FEATURES-NOT: #define __opencl_c_kernel_clock_scope_sub_group 1 +// NO-FEATURES-NOT: #define __opencl_c_kernel_clock_scope_work_group 1 +// NO-FEATURES-NOT: #define __opencl_c_pipes 1 +// NO-FEATURES-NOT: #define __opencl_c_program_scope_global_variables 1 +// NO-FEATURES-NOT: #define __opencl_c_read_write_images 1 +// NO-FEATURES-NOT: #define __opencl_c_subgroups 1 +// NO-FEATURES-NOT: #define __opencl_c_work_group_collective_functions 1 // NO-HEADERONLY-FEATURES-CL20-NOT: #define __opencl_c_integer_dot_product_input_4x8bit // NO-HEADERONLY-FEATURES-CL20-NOT: #define __opencl_c_integer_dot_product_input_4x8bit_packed -// NO-HEADERONLY-FEATURES-NOT: #define __opencl_c_work_group_collective_functions -// NO-HEADERONLY-FEATURES-NOT: #define __opencl_c_atomic_order_seq_cst -// NO-HEADERONLY-FEATURES-NOT: #define __opencl_c_atomic_scope_device -// NO-HEADERONLY-FEATURES-NOT: #define __opencl_c_atomic_scope_all_devices -// NO-HEADERONLY-FEATURES-NOT: #define __opencl_c_read_write_images +// DISABLE-FEATURES-NOT: #define __opencl_c_work_group_collective_functions +// DISABLE-FEATURES-NOT: #define __opencl_c_atomic_order_seq_cst +// DISABLE-FEATURES-NOT: #define __opencl_c_atomic_scope_all_devices +// DISABLE-FEATURES-NOT: #define __opencl_c_atomic_scope_device +// DISABLE-FEATURES-NOT: #define __opencl_c_read_write_images From 8118731a4962be2f9373627e0379e59182118743 Mon Sep 17 00:00:00 2001 From: Wenju He Date: Tue, 18 Nov 2025 08:52:51 +0100 Subject: [PATCH 3/8] revert header-only feature macros for OpenCL C 2.0 --- .../include/clang/Basic/OpenCLExtensions.def | 65 +++-- clang/lib/Basic/Targets/AMDGPU.h | 2 + clang/lib/Headers/opencl-c-base.h | 86 ------ clang/test/Headers/opencl-c-header.cl | 6 +- clang/test/SemaOpenCL/extension-version.cl | 244 ++++++++++++++++++ clang/test/SemaOpenCL/features.cl | 35 ++- 6 files changed, 318 insertions(+), 120 deletions(-) diff --git a/clang/include/clang/Basic/OpenCLExtensions.def b/clang/include/clang/Basic/OpenCLExtensions.def index b705e256fbbfe..9fc8c31056f4d 100644 --- a/clang/include/clang/Basic/OpenCLExtensions.def +++ b/clang/include/clang/Basic/OpenCLExtensions.def @@ -78,10 +78,55 @@ OPENCL_EXTENSION(cl_khr_depth_images, true, 120) OPENCL_EXTENSION(cl_khr_gl_msaa_sharing,true, 120) // OpenCL 2.0. +OPENCL_EXTENSION(cl_ext_float_atomics, true, 200) +OPENCL_EXTENSION(cl_khr_extended_bit_ops, true, 200) +OPENCL_EXTENSION(cl_khr_integer_dot_product, true, 200) +OPENCL_EXTENSION(cl_khr_kernel_clock, true, 200) OPENCL_EXTENSION(cl_khr_mipmap_image, true, 200) OPENCL_EXTENSION(cl_khr_mipmap_image_writes, true, 200) OPENCL_EXTENSION(cl_khr_srgb_image_writes, true, 200) +OPENCL_EXTENSION(cl_khr_subgroup_ballot, true, 200) +OPENCL_EXTENSION(cl_khr_subgroup_clustered_reduce, true, 200) +OPENCL_EXTENSION(cl_khr_subgroup_extended_types, true, 200) +OPENCL_EXTENSION(cl_khr_subgroup_non_uniform_arithmetic, true, 200) +OPENCL_EXTENSION(cl_khr_subgroup_non_uniform_vote, true, 200) +OPENCL_EXTENSION(cl_khr_subgroup_rotate, true, 200) +OPENCL_EXTENSION(cl_khr_subgroup_shuffle_relative, true, 200) +OPENCL_EXTENSION(cl_khr_subgroup_shuffle, true, 200) OPENCL_EXTENSION(cl_khr_subgroups, true, 200) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_atomic_order_acq_rel, false, 200, OCL_C_20) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_atomic_order_seq_cst, false, 200, OCL_C_20) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_atomic_scope_all_devices, false, 200, OCL_C_20) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_atomic_scope_device, false, 200, OCL_C_20) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_device_enqueue, false, 200, OCL_C_20) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_fp16_global_atomic_add, false, 200, OCL_C_20) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_fp16_global_atomic_load_store, false, 200, OCL_C_20) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_fp16_global_atomic_min_max, false, 200, OCL_C_20) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_fp16_local_atomic_add, false, 200, OCL_C_20) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_fp16_local_atomic_load_store, false, 200, OCL_C_20) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_fp16_local_atomic_min_max, false, 200, OCL_C_20) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_fp32_global_atomic_add, false, 200, OCL_C_20) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_fp32_global_atomic_min_max, false, 200, OCL_C_20) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_fp32_local_atomic_add, false, 200, OCL_C_20) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_fp32_local_atomic_min_max, false, 200, OCL_C_20) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_fp64_global_atomic_add, false, 200, OCL_C_20) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_fp64_global_atomic_min_max, false, 200, OCL_C_20) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_fp64_local_atomic_add, false, 200, OCL_C_20) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_fp64_local_atomic_min_max, false, 200, OCL_C_20) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_image_raw10_raw12, false, 200, OCL_C_20) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_image_unorm_int_2_101010, false, 200, OCL_C_20) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_image_unsigned_10x6_12x4_14x2, false, 200, OCL_C_20) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_generic_address_space, false, 200, OCL_C_20) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_images, false, 200, OCL_C_20) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_integer_dot_product_input_4x8bit, false, 200, OCL_C_20) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_integer_dot_product_input_4x8bit_packed, false, 200, OCL_C_20) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_kernel_clock_scope_device, false, 200, OCL_C_20) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_kernel_clock_scope_sub_group, false, 200, OCL_C_20) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_kernel_clock_scope_work_group, false, 200, OCL_C_20) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_pipes, false, 200, OCL_C_20) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_program_scope_global_variables, false, 200, OCL_C_20) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_read_write_images, false, 200, OCL_C_20) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_work_group_collective_functions, false, 200, OCL_C_20) // Clang Extensions. OPENCL_EXTENSION(cl_clang_storage_class_specifiers, true, 100) @@ -100,27 +145,9 @@ OPENCL_EXTENSION(cl_intel_subgroups_short, true, 120) OPENCL_EXTENSION(cl_intel_device_side_avc_motion_estimation, true, 120) // OpenCL C 3.0 features (6.2.1. Features) -OPENCL_OPTIONALCOREFEATURE(__opencl_c_pipes, false, 300, OCL_C_30) -OPENCL_OPTIONALCOREFEATURE(__opencl_c_generic_address_space, false, 300, OCL_C_30) -OPENCL_OPTIONALCOREFEATURE(__opencl_c_atomic_order_acq_rel, false, 300, OCL_C_30) -OPENCL_OPTIONALCOREFEATURE(__opencl_c_atomic_order_seq_cst, false, 300, OCL_C_30) -OPENCL_OPTIONALCOREFEATURE(__opencl_c_atomic_scope_device, false, 300, OCL_C_30) -OPENCL_OPTIONALCOREFEATURE(__opencl_c_atomic_scope_all_devices, false, 300, OCL_C_30) -OPENCL_OPTIONALCOREFEATURE(__opencl_c_subgroups, false, 300, OCL_C_30) OPENCL_OPTIONALCOREFEATURE(__opencl_c_3d_image_writes, false, 300, OCL_C_30) -OPENCL_OPTIONALCOREFEATURE(__opencl_c_device_enqueue, false, 300, OCL_C_30) -OPENCL_OPTIONALCOREFEATURE(__opencl_c_read_write_images, false, 300, OCL_C_30) -OPENCL_OPTIONALCOREFEATURE(__opencl_c_program_scope_global_variables, false, 300, OCL_C_30) OPENCL_OPTIONALCOREFEATURE(__opencl_c_fp64, false, 300, OCL_C_30) -OPENCL_OPTIONALCOREFEATURE(__opencl_c_images, false, 300, OCL_C_30) -OPENCL_OPTIONALCOREFEATURE(__opencl_c_work_group_collective_functions, false, 300, OCL_C_30) -OPENCL_OPTIONALCOREFEATURE(__opencl_c_integer_dot_product_input_4x8bit_packed, false, 300, OCL_C_30) -OPENCL_OPTIONALCOREFEATURE(__opencl_c_integer_dot_product_input_4x8bit, false, 300, OCL_C_30) -OPENCL_OPTIONALCOREFEATURE(__opencl_c_kernel_clock_scope_device, false, 300, OCL_C_30) -OPENCL_OPTIONALCOREFEATURE(__opencl_c_kernel_clock_scope_work_group, false, 300, OCL_C_30) -OPENCL_OPTIONALCOREFEATURE(__opencl_c_kernel_clock_scope_sub_group, false, 300, OCL_C_30) -OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_image_unorm_int_2_101010, false, 300, OCL_C_30) -OPENCL_OPTIONALCOREFEATURE(__opencl_c_ext_image_unsigned_10x6_12x4_14x2, false, 300, OCL_C_30) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_subgroups, false, 300, OCL_C_30) #undef OPENCL_OPTIONALCOREFEATURE #undef OPENCL_COREFEATURE diff --git a/clang/lib/Basic/Targets/AMDGPU.h b/clang/lib/Basic/Targets/AMDGPU.h index dfcc79402257a..95a3d133c07ac 100644 --- a/clang/lib/Basic/Targets/AMDGPU.h +++ b/clang/lib/Basic/Targets/AMDGPU.h @@ -320,6 +320,8 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo { Opts["__opencl_c_3d_image_writes"] = true; Opts["cl_khr_3d_image_writes"] = true; Opts["__opencl_c_program_scope_global_variables"] = true; + Opts["__opencl_c_atomic_scope_all_devices"] = true; + Opts["__opencl_c_atomic_order_seq_cst"] = true; if (GPUKind >= llvm::AMDGPU::GK_GFX700) { Opts["__opencl_c_generic_address_space"] = true; diff --git a/clang/lib/Headers/opencl-c-base.h b/clang/lib/Headers/opencl-c-base.h index 09e5cdbd2dd48..898026c66614a 100644 --- a/clang/lib/Headers/opencl-c-base.h +++ b/clang/lib/Headers/opencl-c-base.h @@ -9,92 +9,6 @@ #ifndef _OPENCL_BASE_H_ #define _OPENCL_BASE_H_ -// Define extension macros - -#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) -// For SPIR and SPIR-V all extensions are supported. -#if defined(__SPIR__) || defined(__SPIRV__) -#define cl_khr_subgroup_extended_types 1 -#define cl_khr_subgroup_non_uniform_vote 1 -#define cl_khr_subgroup_ballot 1 -#define cl_khr_subgroup_non_uniform_arithmetic 1 -#define cl_khr_subgroup_shuffle 1 -#define cl_khr_subgroup_shuffle_relative 1 -#define cl_khr_subgroup_clustered_reduce 1 -#define cl_khr_subgroup_rotate 1 -#define cl_khr_extended_bit_ops 1 -#define cl_khr_integer_dot_product 1 -#define __opencl_c_integer_dot_product_input_4x8bit 1 -#define __opencl_c_integer_dot_product_input_4x8bit_packed 1 -#define cl_ext_float_atomics 1 -#ifdef cl_khr_fp16 -#define __opencl_c_ext_fp16_global_atomic_load_store 1 -#define __opencl_c_ext_fp16_local_atomic_load_store 1 -#define __opencl_c_ext_fp16_global_atomic_add 1 -#define __opencl_c_ext_fp16_local_atomic_add 1 -#define __opencl_c_ext_fp16_global_atomic_min_max 1 -#define __opencl_c_ext_fp16_local_atomic_min_max 1 -#endif -#ifdef cl_khr_fp64 -#define __opencl_c_ext_fp64_global_atomic_add 1 -#define __opencl_c_ext_fp64_local_atomic_add 1 -#define __opencl_c_ext_fp64_global_atomic_min_max 1 -#define __opencl_c_ext_fp64_local_atomic_min_max 1 -#endif -#define __opencl_c_ext_fp32_global_atomic_add 1 -#define __opencl_c_ext_fp32_local_atomic_add 1 -#define __opencl_c_ext_fp32_global_atomic_min_max 1 -#define __opencl_c_ext_fp32_local_atomic_min_max 1 -#define __opencl_c_ext_image_raw10_raw12 1 -#define __opencl_c_ext_image_unorm_int_2_101010 1 -#define __opencl_c_ext_image_unsigned_10x6_12x4_14x2 1 -#define cl_khr_kernel_clock 1 -#define __opencl_c_kernel_clock_scope_device 1 -#define __opencl_c_kernel_clock_scope_work_group 1 -#define __opencl_c_kernel_clock_scope_sub_group 1 - -#endif // defined(__SPIR__) || defined(__SPIRV__) -#endif // (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) - -// Define feature macros for OpenCL C 2.0 -#if (__OPENCL_CPP_VERSION__ == 100 || __OPENCL_C_VERSION__ == 200) -#define __opencl_c_pipes 1 -#define __opencl_c_generic_address_space 1 -#define __opencl_c_work_group_collective_functions 1 -#define __opencl_c_atomic_order_acq_rel 1 -#define __opencl_c_atomic_order_seq_cst 1 -#define __opencl_c_atomic_scope_device 1 -#define __opencl_c_atomic_scope_all_devices 1 -#define __opencl_c_device_enqueue 1 -#define __opencl_c_read_write_images 1 -#define __opencl_c_program_scope_global_variables 1 -#define __opencl_c_images 1 -#endif - -// Undefine any feature macros that have been explicitly disabled using -// an __undef_ macro. -#ifdef __undef___opencl_c_work_group_collective_functions -#undef __opencl_c_work_group_collective_functions -#endif -#ifdef __undef___opencl_c_atomic_order_seq_cst -#undef __opencl_c_atomic_order_seq_cst -#endif -#ifdef __undef___opencl_c_atomic_scope_device -#undef __opencl_c_atomic_scope_device -#endif -#ifdef __undef___opencl_c_atomic_scope_all_devices -#undef __opencl_c_atomic_scope_all_devices -#endif -#ifdef __undef___opencl_c_read_write_images -#undef __opencl_c_read_write_images -#endif -#ifdef __undef___opencl_c_integer_dot_product_input_4x8bit -#undef __opencl_c_integer_dot_product_input_4x8bit -#endif -#ifdef __undef___opencl_c_integer_dot_product_input_4x8bit_packed -#undef __opencl_c_integer_dot_product_input_4x8bit_packed -#endif - #if !defined(__opencl_c_generic_address_space) // Internal feature macro to provide named (global, local, private) address // space overloads for builtin functions that take a pointer argument. diff --git a/clang/test/Headers/opencl-c-header.cl b/clang/test/Headers/opencl-c-header.cl index 17cbb67f26038..e26f16827b20f 100644 --- a/clang/test/Headers/opencl-c-header.cl +++ b/clang/test/Headers/opencl-c-header.cl @@ -33,7 +33,7 @@ // === // Compile for OpenCL 2.0 for the first time. The module should change. // RUN: %clang_cc1 -triple spir-unknown-unknown -O0 -emit-llvm -o - -cl-std=CL2.0 -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK20 --check-prefix=CHECK-MOD %s -// RUN: not diff %t/1_0.pcm %t/opencl_c.pcm +// RUN: not diff %t/1_0.pcm %t/opencl_c.pcm > /dev/null // RUN: chmod u-w %t/opencl_c.pcm // === @@ -44,10 +44,10 @@ // RUN: rm -rf %t // RUN: mkdir -p %t // RUN: %clang_cc1 -triple spir64-unknown-unknown -emit-llvm -o - -cl-std=CL1.2 -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK --check-prefix=CHECK-MOD %s -// RUN: %clang_cc1 -triple amdgcn--amdhsa -O0 -emit-llvm -o - -cl-std=CL2.0 -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK20 --check-prefix=CHECK-MOD %s +// RUN: %clang_cc1 -triple amdgcn--amdhsa -target-cpu gfx700 -O0 -emit-llvm -o - -cl-std=CL2.0 -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK20 --check-prefix=CHECK-MOD %s // RUN: chmod u-w %t // RUN: %clang_cc1 -triple spir64-unknown-unknown -emit-llvm -o - -cl-std=CL1.2 -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK --check-prefix=CHECK-MOD %s -// RUN: %clang_cc1 -triple amdgcn--amdhsa -O0 -emit-llvm -o - -cl-std=CL2.0 -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK20 --check-prefix=CHECK-MOD %s +// RUN: %clang_cc1 -triple amdgcn--amdhsa -target-cpu gfx700 -O0 -emit-llvm -o - -cl-std=CL2.0 -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK20 --check-prefix=CHECK-MOD %s // RUN: chmod u+w %t // Verify that called builtins occur in the generated IR. diff --git a/clang/test/SemaOpenCL/extension-version.cl b/clang/test/SemaOpenCL/extension-version.cl index 4d92eff6ae3ac..35a1818706f35 100644 --- a/clang/test/SemaOpenCL/extension-version.cl +++ b/clang/test/SemaOpenCL/extension-version.cl @@ -165,6 +165,150 @@ #endif #pragma OPENCL EXTENSION cl_khr_subgroups : enable +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) +#ifndef cl_ext_float_atomics +#error "Missing cl_ext_float_atomics define" +#endif +#else +#ifdef cl_ext_float_atomics +#error "Incorrect cl_ext_float_atomics define" +#endif +// expected-warning@+2{{unsupported OpenCL extension 'cl_ext_float_atomics' - ignoring}} +#endif +#pragma OPENCL EXTENSION cl_ext_float_atomics : enable + +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) +#ifndef cl_khr_extended_bit_ops +#error "Missing cl_khr_extended_bit_ops define" +#endif +#else +#ifdef cl_khr_extended_bit_ops +#error "Incorrect cl_khr_extended_bit_ops define" +#endif +// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_extended_bit_ops' - ignoring}} +#endif +#pragma OPENCL EXTENSION cl_khr_extended_bit_ops : enable + +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) +#ifndef cl_khr_integer_dot_product +#error "Missing cl_khr_integer_dot_product define" +#endif +#else +#ifdef cl_khr_integer_dot_product +#error "Incorrect cl_khr_integer_dot_product define" +#endif +// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_integer_dot_product' - ignoring}} +#endif +#pragma OPENCL EXTENSION cl_khr_integer_dot_product : enable + +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) +#ifndef cl_khr_kernel_clock +#error "Missing cl_khr_kernel_clock define" +#endif +#else +#ifdef cl_khr_kernel_clock +#error "Incorrect cl_khr_kernel_clock define" +#endif +// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_kernel_clock' - ignoring}} +#endif +#pragma OPENCL EXTENSION cl_khr_kernel_clock : enable + +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) +#ifndef cl_khr_subgroup_ballot +#error "Missing cl_khr_subgroup_ballot define" +#endif +#else +#ifdef cl_khr_subgroup_ballot +#error "Incorrect cl_khr_subgroup_ballot define" +#endif +// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_subgroup_ballot' - ignoring}} +#endif +#pragma OPENCL EXTENSION cl_khr_subgroup_ballot : enable + +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) +#ifndef cl_khr_subgroup_clustered_reduce +#error "Missing cl_khr_subgroup_clustered_reduce define" +#endif +#else +#ifdef cl_khr_subgroup_clustered_reduce +#error "Incorrect cl_khr_subgroup_clustered_reduce define" +#endif +// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_subgroup_clustered_reduce' - ignoring}} +#endif +#pragma OPENCL EXTENSION cl_khr_subgroup_clustered_reduce : enable + +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) +#ifndef cl_khr_subgroup_extended_types +#error "Missing cl_khr_subgroup_extended_types define" +#endif +#else +#ifdef cl_khr_subgroup_extended_types +#error "Incorrect cl_khr_subgroup_extended_types define" +#endif +// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_subgroup_extended_types' - ignoring}} +#endif +#pragma OPENCL EXTENSION cl_khr_subgroup_extended_types : enable + +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) +#ifndef cl_khr_subgroup_non_uniform_arithmetic +#error "Missing cl_khr_subgroup_non_uniform_arithmetic define" +#endif +#else +#ifdef cl_khr_subgroup_non_uniform_arithmetic +#error "Incorrect cl_khr_subgroup_non_uniform_arithmetic define" +#endif +// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_subgroup_non_uniform_arithmetic' - ignoring}} +#endif +#pragma OPENCL EXTENSION cl_khr_subgroup_non_uniform_arithmetic : enable + +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) +#ifndef cl_khr_subgroup_non_uniform_vote +#error "Missing cl_khr_subgroup_non_uniform_vote define" +#endif +#else +#ifdef cl_khr_subgroup_non_uniform_vote +#error "Incorrect cl_khr_subgroup_non_uniform_vote define" +#endif +// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_subgroup_non_uniform_vote' - ignoring}} +#endif +#pragma OPENCL EXTENSION cl_khr_subgroup_non_uniform_vote : enable + +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) +#ifndef cl_khr_subgroup_rotate +#error "Missing cl_khr_subgroup_rotate define" +#endif +#else +#ifdef cl_khr_subgroup_rotate +#error "Incorrect cl_khr_subgroup_rotate define" +#endif +// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_subgroup_rotate' - ignoring}} +#endif +#pragma OPENCL EXTENSION cl_khr_subgroup_rotate : enable + +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) +#ifndef cl_khr_subgroup_shuffle_relative +#error "Missing cl_khr_subgroup_shuffle_relative define" +#endif +#else +#ifdef cl_khr_subgroup_shuffle_relative +#error "Incorrect cl_khr_subgroup_shuffle_relative define" +#endif +// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_subgroup_shuffle_relative' - ignoring}} +#endif +#pragma OPENCL EXTENSION cl_khr_subgroup_shuffle_relative : enable + +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) +#ifndef cl_khr_subgroup_shuffle +#error "Missing cl_khr_subgroup_shuffle define" +#endif +#else +#ifdef cl_khr_subgroup_shuffle +#error "Incorrect cl_khr_subgroup_shuffle define" +#endif +// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_subgroup_shuffle' - ignoring}} +#endif +#pragma OPENCL EXTENSION cl_khr_subgroup_shuffle : enable + #ifndef cl_amd_media_ops #error "Missing cl_amd_media_ops define" #endif @@ -224,14 +368,62 @@ //expected-warning@-1{{OpenCL extension '__opencl_c_atomic_order_acq_rel' unknown or does not require pragma - ignoring}} #pragma OPENCL EXTENSION __opencl_c_atomic_order_seq_cst : disable //expected-warning@-1{{OpenCL extension '__opencl_c_atomic_order_seq_cst' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_atomic_scope_all_devices : disable +//expected-warning@-1{{OpenCL extension '__opencl_c_atomic_scope_all_devices' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_atomic_scope_device : disable +//expected-warning@-1{{OpenCL extension '__opencl_c_atomic_scope_device' unknown or does not require pragma - ignoring}} #pragma OPENCL EXTENSION __opencl_c_device_enqueue : disable //expected-warning@-1{{OpenCL extension '__opencl_c_device_enqueue' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_ext_fp16_global_atomic_add : disable +//expected-warning@-1{{OpenCL extension '__opencl_c_ext_fp16_global_atomic_add' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_ext_fp16_global_atomic_load_store : disable +//expected-warning@-1{{OpenCL extension '__opencl_c_ext_fp16_global_atomic_load_store' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_ext_fp16_global_atomic_min_max : disable +//expected-warning@-1{{OpenCL extension '__opencl_c_ext_fp16_global_atomic_min_max' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_ext_fp16_local_atomic_add : disable +//expected-warning@-1{{OpenCL extension '__opencl_c_ext_fp16_local_atomic_add' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_ext_fp16_local_atomic_load_store : disable +//expected-warning@-1{{OpenCL extension '__opencl_c_ext_fp16_local_atomic_load_store' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_ext_fp16_local_atomic_min_max : disable +//expected-warning@-1{{OpenCL extension '__opencl_c_ext_fp16_local_atomic_min_max' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_ext_fp32_global_atomic_add : disable +//expected-warning@-1{{OpenCL extension '__opencl_c_ext_fp32_global_atomic_add' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_ext_fp32_global_atomic_min_max : disable +//expected-warning@-1{{OpenCL extension '__opencl_c_ext_fp32_global_atomic_min_max' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_ext_fp32_local_atomic_add : disable +//expected-warning@-1{{OpenCL extension '__opencl_c_ext_fp32_local_atomic_add' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_ext_fp32_local_atomic_min_max : disable +//expected-warning@-1{{OpenCL extension '__opencl_c_ext_fp32_local_atomic_min_max' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_ext_fp64_global_atomic_add : disable +//expected-warning@-1{{OpenCL extension '__opencl_c_ext_fp64_global_atomic_add' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_ext_fp64_global_atomic_min_max : disable +//expected-warning@-1{{OpenCL extension '__opencl_c_ext_fp64_global_atomic_min_max' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_ext_fp64_local_atomic_add : disable +//expected-warning@-1{{OpenCL extension '__opencl_c_ext_fp64_local_atomic_add' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_ext_fp64_local_atomic_min_max : disable +//expected-warning@-1{{OpenCL extension '__opencl_c_ext_fp64_local_atomic_min_max' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_ext_image_raw10_raw12 : disable +//expected-warning@-1{{OpenCL extension '__opencl_c_ext_image_raw10_raw12' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_ext_image_unorm_int_2_101010 : disable +//expected-warning@-1{{OpenCL extension '__opencl_c_ext_image_unorm_int_2_101010' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_ext_image_unsigned_10x6_12x4_14x2 : disable +//expected-warning@-1{{OpenCL extension '__opencl_c_ext_image_unsigned_10x6_12x4_14x2' unknown or does not require pragma - ignoring}} #pragma OPENCL EXTENSION __opencl_c_fp64 : disable //expected-warning@-1{{OpenCL extension '__opencl_c_fp64' unknown or does not require pragma - ignoring}} #pragma OPENCL EXTENSION __opencl_c_generic_address_space : disable //expected-warning@-1{{OpenCL extension '__opencl_c_generic_address_space' unknown or does not require pragma - ignoring}} #pragma OPENCL EXTENSION __opencl_c_images : disable //expected-warning@-1{{OpenCL extension '__opencl_c_images' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_integer_dot_product_input_4x8bit : disable +//expected-warning@-1{{OpenCL extension '__opencl_c_integer_dot_product_input_4x8bit' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_integer_dot_product_input_4x8bit_packed : disable +//expected-warning@-1{{OpenCL extension '__opencl_c_integer_dot_product_input_4x8bit_packed' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_kernel_clock_scope_device : disable +//expected-warning@-1{{OpenCL extension '__opencl_c_kernel_clock_scope_device' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_kernel_clock_scope_sub_group : disable +//expected-warning@-1{{OpenCL extension '__opencl_c_kernel_clock_scope_sub_group' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_kernel_clock_scope_work_group : disable +//expected-warning@-1{{OpenCL extension '__opencl_c_kernel_clock_scope_work_group' unknown or does not require pragma - ignoring}} #pragma OPENCL EXTENSION __opencl_c_pipes : disable //expected-warning@-1{{OpenCL extension '__opencl_c_pipes' unknown or does not require pragma - ignoring}} #pragma OPENCL EXTENSION __opencl_c_program_scope_global_variables : disable @@ -240,6 +432,8 @@ //expected-warning@-1{{OpenCL extension '__opencl_c_read_write_images' unknown or does not require pragma - ignoring}} #pragma OPENCL EXTENSION __opencl_c_subgroups : disable //expected-warning@-1{{OpenCL extension '__opencl_c_subgroups' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_work_group_collective_functions : disable +//expected-warning@-1{{OpenCL extension '__opencl_c_work_group_collective_functions' unknown or does not require pragma - ignoring}} #pragma OPENCL EXTENSION __opencl_c_int64 : enable //expected-warning@-1{{OpenCL extension '__opencl_c_int64' unknown or does not require pragma - ignoring}} @@ -249,14 +443,62 @@ //expected-warning@-1{{OpenCL extension '__opencl_c_atomic_order_acq_rel' unknown or does not require pragma - ignoring}} #pragma OPENCL EXTENSION __opencl_c_atomic_order_seq_cst : enable //expected-warning@-1{{OpenCL extension '__opencl_c_atomic_order_seq_cst' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_atomic_scope_all_devices : enable +//expected-warning@-1{{OpenCL extension '__opencl_c_atomic_scope_all_devices' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_atomic_scope_device : enable +//expected-warning@-1{{OpenCL extension '__opencl_c_atomic_scope_device' unknown or does not require pragma - ignoring}} #pragma OPENCL EXTENSION __opencl_c_device_enqueue : enable //expected-warning@-1{{OpenCL extension '__opencl_c_device_enqueue' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_ext_fp16_global_atomic_add : enable +//expected-warning@-1{{OpenCL extension '__opencl_c_ext_fp16_global_atomic_add' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_ext_fp16_global_atomic_load_store : enable +//expected-warning@-1{{OpenCL extension '__opencl_c_ext_fp16_global_atomic_load_store' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_ext_fp16_global_atomic_min_max : enable +//expected-warning@-1{{OpenCL extension '__opencl_c_ext_fp16_global_atomic_min_max' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_ext_fp16_local_atomic_add : enable +//expected-warning@-1{{OpenCL extension '__opencl_c_ext_fp16_local_atomic_add' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_ext_fp16_local_atomic_load_store : enable +//expected-warning@-1{{OpenCL extension '__opencl_c_ext_fp16_local_atomic_load_store' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_ext_fp16_local_atomic_min_max : enable +//expected-warning@-1{{OpenCL extension '__opencl_c_ext_fp16_local_atomic_min_max' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_ext_fp32_global_atomic_add : enable +//expected-warning@-1{{OpenCL extension '__opencl_c_ext_fp32_global_atomic_add' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_ext_fp32_global_atomic_min_max : enable +//expected-warning@-1{{OpenCL extension '__opencl_c_ext_fp32_global_atomic_min_max' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_ext_fp32_local_atomic_add : enable +//expected-warning@-1{{OpenCL extension '__opencl_c_ext_fp32_local_atomic_add' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_ext_fp32_local_atomic_min_max : enable +//expected-warning@-1{{OpenCL extension '__opencl_c_ext_fp32_local_atomic_min_max' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_ext_fp64_global_atomic_add : enable +//expected-warning@-1{{OpenCL extension '__opencl_c_ext_fp64_global_atomic_add' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_ext_fp64_global_atomic_min_max : enable +//expected-warning@-1{{OpenCL extension '__opencl_c_ext_fp64_global_atomic_min_max' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_ext_fp64_local_atomic_add : enable +//expected-warning@-1{{OpenCL extension '__opencl_c_ext_fp64_local_atomic_add' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_ext_fp64_local_atomic_min_max : enable +//expected-warning@-1{{OpenCL extension '__opencl_c_ext_fp64_local_atomic_min_max' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_ext_image_raw10_raw12 : enable +//expected-warning@-1{{OpenCL extension '__opencl_c_ext_image_raw10_raw12' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_ext_image_unorm_int_2_101010 : enable +//expected-warning@-1{{OpenCL extension '__opencl_c_ext_image_unorm_int_2_101010' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_ext_image_unsigned_10x6_12x4_14x2 : enable +//expected-warning@-1{{OpenCL extension '__opencl_c_ext_image_unsigned_10x6_12x4_14x2' unknown or does not require pragma - ignoring}} #pragma OPENCL EXTENSION __opencl_c_fp64 : enable //expected-warning@-1{{OpenCL extension '__opencl_c_fp64' unknown or does not require pragma - ignoring}} #pragma OPENCL EXTENSION __opencl_c_generic_address_space : enable //expected-warning@-1{{OpenCL extension '__opencl_c_generic_address_space' unknown or does not require pragma - ignoring}} #pragma OPENCL EXTENSION __opencl_c_images : enable //expected-warning@-1{{OpenCL extension '__opencl_c_images' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_integer_dot_product_input_4x8bit : enable +//expected-warning@-1{{OpenCL extension '__opencl_c_integer_dot_product_input_4x8bit' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_integer_dot_product_input_4x8bit_packed : enable +//expected-warning@-1{{OpenCL extension '__opencl_c_integer_dot_product_input_4x8bit_packed' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_kernel_clock_scope_device : enable +//expected-warning@-1{{OpenCL extension '__opencl_c_kernel_clock_scope_device' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_kernel_clock_scope_sub_group : enable +//expected-warning@-1{{OpenCL extension '__opencl_c_kernel_clock_scope_sub_group' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_kernel_clock_scope_work_group : enable +//expected-warning@-1{{OpenCL extension '__opencl_c_kernel_clock_scope_work_group' unknown or does not require pragma - ignoring}} #pragma OPENCL EXTENSION __opencl_c_pipes : enable //expected-warning@-1{{OpenCL extension '__opencl_c_pipes' unknown or does not require pragma - ignoring}} #pragma OPENCL EXTENSION __opencl_c_program_scope_global_variables : enable @@ -265,3 +507,5 @@ //expected-warning@-1{{OpenCL extension '__opencl_c_read_write_images' unknown or does not require pragma - ignoring}} #pragma OPENCL EXTENSION __opencl_c_subgroups : enable //expected-warning@-1{{OpenCL extension '__opencl_c_subgroups' unknown or does not require pragma - ignoring}} +#pragma OPENCL EXTENSION __opencl_c_work_group_collective_functions : enable +//expected-warning@-1{{OpenCL extension '__opencl_c_work_group_collective_functions' unknown or does not require pragma - ignoring}} diff --git a/clang/test/SemaOpenCL/features.cl b/clang/test/SemaOpenCL/features.cl index d880d168be570..ec70f955f36ba 100644 --- a/clang/test/SemaOpenCL/features.cl +++ b/clang/test/SemaOpenCL/features.cl @@ -15,24 +15,22 @@ // RUN: %clang_cc1 -triple r600-unknown-unknown %s -E -dM -o - -x cl -cl-std=clc++2021 -cl-ext=+all \ // RUN: | FileCheck -match-full-lines %s --check-prefix=FEATURES -// For OpenCL C 2.0 feature macros are defined only in header, so test that earlier OpenCL -// versions don't define feature macros accidentally and CL2.0 don't define them without header +// For OpenCL C 2.0 feature macros, test that CL2.0 define them but earlier OpenCL +// versions don't define feature macros accidentally. // RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=CL1.1 \ // RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES // RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=CL1.2 \ // RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES // RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=CL2.0 \ -// RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES +// RUN: | FileCheck -match-full-lines %s --check-prefix=FEATURES-CL20 // RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=clc++1.0 \ -// RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES +// RUN: | FileCheck -match-full-lines %s --check-prefix=FEATURES-CL20 -// For OpenCL C 2.0, header-only features can be disabled using macros. +// Features can be disabled using -cl-ext. // RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=CL2.0 -fdeclare-opencl-builtins -finclude-default-header \ -// RUN: -D__undef___opencl_c_integer_dot_product_input_4x8bit \ -// RUN: -D__undef___opencl_c_integer_dot_product_input_4x8bit_packed \ -// RUN: | FileCheck %s --check-prefix=NO-HEADERONLY-FEATURES-CL20 - -// For OpenCL C 3.0, header-only features can be disabled using macros. +// RUN: -cl-ext=-__opencl_c_integer_dot_product_input_4x8bit \ +// RUN: -cl-ext=-__opencl_c_integer_dot_product_input_4x8bit_packed \ +// RUN: | FileCheck %s --check-prefix=NO-FEATURES-CL20 // RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=CL3.0 -fdeclare-opencl-builtins -finclude-default-header \ // RUN: -cl-ext=-__opencl_c_work_group_collective_functions, \ // RUN: -cl-ext=-__opencl_c_atomic_order_seq_cst \ @@ -67,6 +65,19 @@ // FEATURES: #define __opencl_c_subgroups 1 // FEATURES: #define __opencl_c_work_group_collective_functions 1 +// FEATURES-CL20: #define __opencl_c_atomic_order_acq_rel 1 +// FEATURES-CL20: #define __opencl_c_atomic_order_seq_cst 1 +// FEATURES-CL20: #define __opencl_c_atomic_scope_all_devices 1 +// FEATURES-CL20: #define __opencl_c_atomic_scope_device 1 +// FEATURES-CL20: #define __opencl_c_device_enqueue 1 +// FEATURES-CL20: #define __opencl_c_generic_address_space 1 +// FEATURES-CL20: #define __opencl_c_images 1 +// FEATURES-CL20: #define __opencl_c_int64 1 +// FEATURES-CL20: #define __opencl_c_pipes 1 +// FEATURES-CL20: #define __opencl_c_program_scope_global_variables 1 +// FEATURES-CL20: #define __opencl_c_read_write_images 1 +// FEATURES-CL20: #define __opencl_c_work_group_collective_functions 1 + // NO-FEATURES: #define __opencl_c_int64 1 // NO-FEATURES-NOT: #define __opencl_c_3d_image_writes 1 // NO-FEATURES-NOT: #define __opencl_c_atomic_order_acq_rel 1 @@ -91,8 +102,8 @@ // NO-FEATURES-NOT: #define __opencl_c_subgroups 1 // NO-FEATURES-NOT: #define __opencl_c_work_group_collective_functions 1 -// NO-HEADERONLY-FEATURES-CL20-NOT: #define __opencl_c_integer_dot_product_input_4x8bit -// NO-HEADERONLY-FEATURES-CL20-NOT: #define __opencl_c_integer_dot_product_input_4x8bit_packed +// NO-FEATURES-CL20-NOT: #define __opencl_c_integer_dot_product_input_4x8bit +// NO-FEATURES-CL20-NOT: #define __opencl_c_integer_dot_product_input_4x8bit_packed // DISABLE-FEATURES-NOT: #define __opencl_c_work_group_collective_functions // DISABLE-FEATURES-NOT: #define __opencl_c_atomic_order_seq_cst From ad2eaad364944dd48ba0cfb47c3c6fa0472d5be8 Mon Sep 17 00:00:00 2001 From: Wenju He Date: Tue, 18 Nov 2025 09:28:49 +0100 Subject: [PATCH 4/8] reorder options in AMDGPU.h --- clang/lib/Basic/Targets/AMDGPU.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/Basic/Targets/AMDGPU.h b/clang/lib/Basic/Targets/AMDGPU.h index 95a3d133c07ac..a51d8d2375cfe 100644 --- a/clang/lib/Basic/Targets/AMDGPU.h +++ b/clang/lib/Basic/Targets/AMDGPU.h @@ -320,8 +320,8 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo { Opts["__opencl_c_3d_image_writes"] = true; Opts["cl_khr_3d_image_writes"] = true; Opts["__opencl_c_program_scope_global_variables"] = true; - Opts["__opencl_c_atomic_scope_all_devices"] = true; Opts["__opencl_c_atomic_order_seq_cst"] = true; + Opts["__opencl_c_atomic_scope_all_devices"] = true; if (GPUKind >= llvm::AMDGPU::GK_GFX700) { Opts["__opencl_c_generic_address_space"] = true; From f1998788b04297e161b348a1ec7b7cac630fe266 Mon Sep 17 00:00:00 2001 From: Wenju He Date: Tue, 18 Nov 2025 09:58:39 +0100 Subject: [PATCH 5/8] cl_khr_extended_subgroup extensions don't require pragma --- clang/include/clang/Basic/OpenCLExtensions.def | 16 ++++++++-------- clang/test/SemaOpenCL/extension-version.cl | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/clang/include/clang/Basic/OpenCLExtensions.def b/clang/include/clang/Basic/OpenCLExtensions.def index 9fc8c31056f4d..18bba5d641ad5 100644 --- a/clang/include/clang/Basic/OpenCLExtensions.def +++ b/clang/include/clang/Basic/OpenCLExtensions.def @@ -85,14 +85,14 @@ OPENCL_EXTENSION(cl_khr_kernel_clock, true, 200) OPENCL_EXTENSION(cl_khr_mipmap_image, true, 200) OPENCL_EXTENSION(cl_khr_mipmap_image_writes, true, 200) OPENCL_EXTENSION(cl_khr_srgb_image_writes, true, 200) -OPENCL_EXTENSION(cl_khr_subgroup_ballot, true, 200) -OPENCL_EXTENSION(cl_khr_subgroup_clustered_reduce, true, 200) -OPENCL_EXTENSION(cl_khr_subgroup_extended_types, true, 200) -OPENCL_EXTENSION(cl_khr_subgroup_non_uniform_arithmetic, true, 200) -OPENCL_EXTENSION(cl_khr_subgroup_non_uniform_vote, true, 200) -OPENCL_EXTENSION(cl_khr_subgroup_rotate, true, 200) -OPENCL_EXTENSION(cl_khr_subgroup_shuffle_relative, true, 200) -OPENCL_EXTENSION(cl_khr_subgroup_shuffle, true, 200) +OPENCL_EXTENSION(cl_khr_subgroup_ballot, false, 200) +OPENCL_EXTENSION(cl_khr_subgroup_clustered_reduce, false, 200) +OPENCL_EXTENSION(cl_khr_subgroup_extended_types, false, 200) +OPENCL_EXTENSION(cl_khr_subgroup_non_uniform_arithmetic, false, 200) +OPENCL_EXTENSION(cl_khr_subgroup_non_uniform_vote, false, 200) +OPENCL_EXTENSION(cl_khr_subgroup_rotate, false, 200) +OPENCL_EXTENSION(cl_khr_subgroup_shuffle_relative, false, 200) +OPENCL_EXTENSION(cl_khr_subgroup_shuffle, false, 200) OPENCL_EXTENSION(cl_khr_subgroups, true, 200) OPENCL_OPTIONALCOREFEATURE(__opencl_c_atomic_order_acq_rel, false, 200, OCL_C_20) OPENCL_OPTIONALCOREFEATURE(__opencl_c_atomic_order_seq_cst, false, 200, OCL_C_20) diff --git a/clang/test/SemaOpenCL/extension-version.cl b/clang/test/SemaOpenCL/extension-version.cl index 35a1818706f35..8a9f47ab414df 100644 --- a/clang/test/SemaOpenCL/extension-version.cl +++ b/clang/test/SemaOpenCL/extension-version.cl @@ -221,8 +221,8 @@ #ifdef cl_khr_subgroup_ballot #error "Incorrect cl_khr_subgroup_ballot define" #endif -// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_subgroup_ballot' - ignoring}} #endif +// expected-warning@+1{{OpenCL extension 'cl_khr_subgroup_ballot' unknown or does not require pragma - ignoring}} #pragma OPENCL EXTENSION cl_khr_subgroup_ballot : enable #if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) @@ -233,8 +233,8 @@ #ifdef cl_khr_subgroup_clustered_reduce #error "Incorrect cl_khr_subgroup_clustered_reduce define" #endif -// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_subgroup_clustered_reduce' - ignoring}} #endif +// expected-warning@+1{{OpenCL extension 'cl_khr_subgroup_clustered_reduce' unknown or does not require pragma - ignoring}} #pragma OPENCL EXTENSION cl_khr_subgroup_clustered_reduce : enable #if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) @@ -245,8 +245,8 @@ #ifdef cl_khr_subgroup_extended_types #error "Incorrect cl_khr_subgroup_extended_types define" #endif -// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_subgroup_extended_types' - ignoring}} #endif +// expected-warning@+1{{OpenCL extension 'cl_khr_subgroup_extended_types' unknown or does not require pragma - ignoring}} #pragma OPENCL EXTENSION cl_khr_subgroup_extended_types : enable #if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) @@ -257,8 +257,8 @@ #ifdef cl_khr_subgroup_non_uniform_arithmetic #error "Incorrect cl_khr_subgroup_non_uniform_arithmetic define" #endif -// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_subgroup_non_uniform_arithmetic' - ignoring}} #endif +// expected-warning@+1{{OpenCL extension 'cl_khr_subgroup_non_uniform_arithmetic' unknown or does not require pragma - ignoring}} #pragma OPENCL EXTENSION cl_khr_subgroup_non_uniform_arithmetic : enable #if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) @@ -269,8 +269,8 @@ #ifdef cl_khr_subgroup_non_uniform_vote #error "Incorrect cl_khr_subgroup_non_uniform_vote define" #endif -// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_subgroup_non_uniform_vote' - ignoring}} #endif +// expected-warning@+1{{OpenCL extension 'cl_khr_subgroup_non_uniform_vote' unknown or does not require pragma - ignoring}} #pragma OPENCL EXTENSION cl_khr_subgroup_non_uniform_vote : enable #if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) @@ -281,8 +281,8 @@ #ifdef cl_khr_subgroup_rotate #error "Incorrect cl_khr_subgroup_rotate define" #endif -// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_subgroup_rotate' - ignoring}} #endif +// expected-warning@+1{{OpenCL extension 'cl_khr_subgroup_rotate' unknown or does not require pragma - ignoring}} #pragma OPENCL EXTENSION cl_khr_subgroup_rotate : enable #if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) @@ -293,8 +293,8 @@ #ifdef cl_khr_subgroup_shuffle_relative #error "Incorrect cl_khr_subgroup_shuffle_relative define" #endif -// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_subgroup_shuffle_relative' - ignoring}} #endif +// expected-warning@+1{{OpenCL extension 'cl_khr_subgroup_shuffle_relative' unknown or does not require pragma - ignoring}} #pragma OPENCL EXTENSION cl_khr_subgroup_shuffle_relative : enable #if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) @@ -305,8 +305,8 @@ #ifdef cl_khr_subgroup_shuffle #error "Incorrect cl_khr_subgroup_shuffle define" #endif -// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_subgroup_shuffle' - ignoring}} #endif +// expected-warning@+1{{OpenCL extension 'cl_khr_subgroup_shuffle' unknown or does not require pragma - ignoring}} #pragma OPENCL EXTENSION cl_khr_subgroup_shuffle : enable #ifndef cl_amd_media_ops From a41b88acc48649f1e605d1807ca6137c2e07794b Mon Sep 17 00:00:00 2001 From: Wenju He Date: Tue, 18 Nov 2025 10:07:29 +0100 Subject: [PATCH 6/8] change pragma to false --- clang/include/clang/Basic/OpenCLExtensions.def | 8 ++++---- clang/test/SemaOpenCL/extension-version.cl | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/clang/include/clang/Basic/OpenCLExtensions.def b/clang/include/clang/Basic/OpenCLExtensions.def index 18bba5d641ad5..809f73be90c4e 100644 --- a/clang/include/clang/Basic/OpenCLExtensions.def +++ b/clang/include/clang/Basic/OpenCLExtensions.def @@ -78,10 +78,10 @@ OPENCL_EXTENSION(cl_khr_depth_images, true, 120) OPENCL_EXTENSION(cl_khr_gl_msaa_sharing,true, 120) // OpenCL 2.0. -OPENCL_EXTENSION(cl_ext_float_atomics, true, 200) -OPENCL_EXTENSION(cl_khr_extended_bit_ops, true, 200) -OPENCL_EXTENSION(cl_khr_integer_dot_product, true, 200) -OPENCL_EXTENSION(cl_khr_kernel_clock, true, 200) +OPENCL_EXTENSION(cl_ext_float_atomics, false, 200) +OPENCL_EXTENSION(cl_khr_extended_bit_ops, false, 200) +OPENCL_EXTENSION(cl_khr_integer_dot_product, false, 200) +OPENCL_EXTENSION(cl_khr_kernel_clock, false, 200) OPENCL_EXTENSION(cl_khr_mipmap_image, true, 200) OPENCL_EXTENSION(cl_khr_mipmap_image_writes, true, 200) OPENCL_EXTENSION(cl_khr_srgb_image_writes, true, 200) diff --git a/clang/test/SemaOpenCL/extension-version.cl b/clang/test/SemaOpenCL/extension-version.cl index 8a9f47ab414df..c634cf313b36d 100644 --- a/clang/test/SemaOpenCL/extension-version.cl +++ b/clang/test/SemaOpenCL/extension-version.cl @@ -173,8 +173,8 @@ #ifdef cl_ext_float_atomics #error "Incorrect cl_ext_float_atomics define" #endif -// expected-warning@+2{{unsupported OpenCL extension 'cl_ext_float_atomics' - ignoring}} #endif +// expected-warning@+1{{OpenCL extension 'cl_ext_float_atomics' unknown or does not require pragma - ignoring}} #pragma OPENCL EXTENSION cl_ext_float_atomics : enable #if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) @@ -185,8 +185,8 @@ #ifdef cl_khr_extended_bit_ops #error "Incorrect cl_khr_extended_bit_ops define" #endif -// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_extended_bit_ops' - ignoring}} #endif +// expected-warning@+1{{OpenCL extension 'cl_khr_extended_bit_ops' unknown or does not require pragma - ignoring}} #pragma OPENCL EXTENSION cl_khr_extended_bit_ops : enable #if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) @@ -197,8 +197,8 @@ #ifdef cl_khr_integer_dot_product #error "Incorrect cl_khr_integer_dot_product define" #endif -// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_integer_dot_product' - ignoring}} #endif +// expected-warning@+1{{OpenCL extension 'cl_khr_integer_dot_product' unknown or does not require pragma - ignoring}} #pragma OPENCL EXTENSION cl_khr_integer_dot_product : enable #if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) @@ -209,8 +209,8 @@ #ifdef cl_khr_kernel_clock #error "Incorrect cl_khr_kernel_clock define" #endif -// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_kernel_clock' - ignoring}} #endif +// expected-warning@+1{{OpenCL extension 'cl_khr_kernel_clock' unknown or does not require pragma - ignoring}} #pragma OPENCL EXTENSION cl_khr_kernel_clock : enable #if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) From 28dd2a0827a01b72044f083fe579b1ec52424309 Mon Sep 17 00:00:00 2001 From: Wenju He Date: Tue, 18 Nov 2025 13:10:00 +0100 Subject: [PATCH 7/8] update clang release note and OpenCLSupport doc --- clang/docs/OpenCLSupport.rst | 16 +++++----------- clang/docs/ReleaseNotes.rst | 5 +++++ clang/test/SemaOpenCL/features.cl | 2 +- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/clang/docs/OpenCLSupport.rst b/clang/docs/OpenCLSupport.rst index f9b6564a9ebaa..6ffb646fe0246 100644 --- a/clang/docs/OpenCLSupport.rst +++ b/clang/docs/OpenCLSupport.rst @@ -217,9 +217,9 @@ This section explains how to extend clang with the new functionality. **Parsing functionality** -If an extension modifies the standard parsing it needs to be added to -the clang frontend source code. This also means that the associated macro -indicating the presence of the extension should be added to clang. +If a new extension is added it needs to be added to the clang frontend source +code. This also means that the associated macro indicating the presence of the +extension should be added to clang. The default flow for adding a new extension into the frontend is to modify `OpenCLExtensions.def @@ -242,7 +242,7 @@ with :option:`-cl-ext` command-line flags. **Library functionality** If an extension adds functionality that does not modify standard language -parsing it should not require modifying anything other than header files and +parsing it may not require modifying anything other than header files and ``OpenCLBuiltins.td`` detailed in :ref:`OpenCL builtins `. Most commonly such extensions add functionality via libraries (by adding non-native types or functions) parsed regularly. Similar to other languages this @@ -250,13 +250,7 @@ is the most common way to add new functionality. Clang has standard headers where new types and functions are being added, for more details refer to -:ref:`the section on the OpenCL Header `. The macros indicating -the presence of such extensions can be added in the standard header files -conditioned on target specific predefined macros or/and language version -predefined macros (see `feature/extension preprocessor macros defined in -opencl-c-base.h -`__). - +:ref:`the section on the OpenCL Header `. **Pragmas** Some extensions alter standard parsing dynamically via pragmas. diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 09eed889b01a8..cf899a7c42fc1 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -234,6 +234,11 @@ C23 Feature Support Non-comprehensive list of changes in this release ------------------------------------------------- +- Removed OpenCL header-only feature macros (previously unconditionally enabled + on SPIR-V and only selectively disabled via -D__undef_). All OpenCL + extensions and features are now centralized in OpenCLExtensions.def, allowing + consistent control via getSupportedOpenCLOpts and -cl-ext. + - Added ``__builtin_elementwise_ldexp``. - Added ``__builtin_elementwise_fshl`` and ``__builtin_elementwise_fshr``. diff --git a/clang/test/SemaOpenCL/features.cl b/clang/test/SemaOpenCL/features.cl index ec70f955f36ba..e95f94d56c8d9 100644 --- a/clang/test/SemaOpenCL/features.cl +++ b/clang/test/SemaOpenCL/features.cl @@ -26,7 +26,7 @@ // RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=clc++1.0 \ // RUN: | FileCheck -match-full-lines %s --check-prefix=FEATURES-CL20 -// Features can be disabled using -cl-ext. +// Features can be disabled using -cl-ext=-. // RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=CL2.0 -fdeclare-opencl-builtins -finclude-default-header \ // RUN: -cl-ext=-__opencl_c_integer_dot_product_input_4x8bit \ // RUN: -cl-ext=-__opencl_c_integer_dot_product_input_4x8bit_packed \ From 6dd8e41c28771e34dde507497d1e372e7793dd80 Mon Sep 17 00:00:00 2001 From: Wenju He Date: Wed, 19 Nov 2025 11:21:41 +0100 Subject: [PATCH 8/8] apply review suggestions --- clang/docs/ReleaseNotes.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index cf899a7c42fc1..54768d6efe927 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -235,9 +235,9 @@ C23 Feature Support Non-comprehensive list of changes in this release ------------------------------------------------- - Removed OpenCL header-only feature macros (previously unconditionally enabled - on SPIR-V and only selectively disabled via -D__undef_). All OpenCL - extensions and features are now centralized in OpenCLExtensions.def, allowing - consistent control via getSupportedOpenCLOpts and -cl-ext. + on SPIR-V and only selectively disabled via ``-D__undef_``). All + OpenCL extensions and features are now centralized in OpenCLExtensions.def, + allowing consistent control via ``getSupportedOpenCLOpts`` and ``-cl-ext``. - Added ``__builtin_elementwise_ldexp``.