[clang] [Clang][TableGen] Add missing __bf16 type to the builtins parser (PR #120662)
https://github.com/vmustya created https://github.com/llvm/llvm-project/pull/120662 The Clang tablegen built-in function prototype parser has the `__bf16` type missing. This patch adds the missing type to the parser. >From df1fe8e7e6cb978ff52d71c36cea9af207b11224 Mon Sep 17 00:00:00 2001 From: Victor Mustya Date: Thu, 19 Dec 2024 16:56:04 -0800 Subject: [PATCH] [Clang][TableGen] Add missing __bf16 type to the builtins parser The Clang tablegen built-in function prototype parser has the `__bf16` type missing. This patch adds the missing type to the parser. --- clang/test/TableGen/target-builtins-prototype-parser.td | 7 ++- clang/utils/TableGen/ClangBuiltinsEmitter.cpp | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/clang/test/TableGen/target-builtins-prototype-parser.td b/clang/test/TableGen/target-builtins-prototype-parser.td index 555aebb3ccfb1f..a753f906a674fe 100644 --- a/clang/test/TableGen/target-builtins-prototype-parser.td +++ b/clang/test/TableGen/target-builtins-prototype-parser.td @@ -57,6 +57,12 @@ def : Builtin { let Spellings = ["__builtin_08"]; } +def : Builtin { +// CHECK: BUILTIN(__builtin_09, "V2yy", "") + let Prototype = "_Vector<2, __bf16>(__bf16)"; + let Spellings = ["__builtin_09"]; +} + #ifdef ERROR_EXPECTED_LANES def : Builtin { // ERROR_EXPECTED_LANES: :[[# @LINE + 1]]:7: error: Expected number of lanes after '_ExtVector<' @@ -112,4 +118,3 @@ def : Builtin { let Spellings = ["__builtin_test_use_clang_extended_vectors"]; } #endif - diff --git a/clang/utils/TableGen/ClangBuiltinsEmitter.cpp b/clang/utils/TableGen/ClangBuiltinsEmitter.cpp index 6c3604adc92b99..f8dec02ea12197 100644 --- a/clang/utils/TableGen/ClangBuiltinsEmitter.cpp +++ b/clang/utils/TableGen/ClangBuiltinsEmitter.cpp @@ -155,6 +155,7 @@ class PrototypeParser { .Case("__fp16", "h") .Case("__int128_t", "LLLi") .Case("_Float16", "x") + .Case("__bf16", "y") .Case("bool", "b") .Case("char", "c") .Case("constant_CFString", "F") ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][OpenCL] Wrap image functions with the macro (PR #129171)
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 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 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
[clang] [Clang][OpenCL] Wrap image functions with the macro (PR #129177)
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 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) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][OpenCL] Wrap image functions with the macro (PR #129171)
https://github.com/vmustya closed https://github.com/llvm/llvm-project/pull/129171 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Add support for missing OpenCL extensions (PR #129777)
vmustya wrote: > That way, header-only extensions don't need to be added to > `OpenCLExtensions.def` @svenvh, in any case, we need a list of all the supported extensions, including the header ones. When someone passes the `-Xclang -cl-ext=+all`, the compiler should add defines for all the supported extensions. https://github.com/llvm/llvm-project/pull/129777 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Add support for missing OpenCL extensions (PR #129777)
vmustya wrote: > What is the motivation for this change? We are trying to move away from > adding extensions to this file for extensions that only add builtin > functions, see e.g. https://reviews.llvm.org/D92231 . What functionality are > you gaining by adding them here? @svenvh, I'm trying to unify the extensions enablement in the user interface. We can enable or disable some of the extensions with the `-Xclang -cl-ext=+extension` command line options. For example, a user can pass `-Xclang -cl-ext=+cl_khr_subgroups` successfully, but the `-Xclang -cl-ext=+cl_khr_subgroup_ballot` has no effect on the compiler. https://github.com/llvm/llvm-project/pull/129777 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits