https://github.com/jhuber6 updated https://github.com/llvm/llvm-project/pull/154227
>From 9e4dc9de57df323534b90b5c790401468b8c094d Mon Sep 17 00:00:00 2001 From: Joseph Huber <hube...@outlook.com> Date: Mon, 18 Aug 2025 18:36:57 -0500 Subject: [PATCH 1/2] [Clang] Add queryable feature 'boolean_vectors' for SIMD masks Summary: We added boolean vectors in clang 15 and wish to extend them further in clang-22. However, there's no way to query for their support as they are separate to the normal extended vector type. This adds a feature so we can check for it as a feature directly. --- clang/docs/LanguageExtensions.rst | 3 ++- clang/include/clang/Basic/Features.def | 1 + clang/test/SemaCXX/vector-bool.cpp | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/clang/docs/LanguageExtensions.rst b/clang/docs/LanguageExtensions.rst index 97413588fea15..953278aa62c6c 100644 --- a/clang/docs/LanguageExtensions.rst +++ b/clang/docs/LanguageExtensions.rst @@ -635,11 +635,12 @@ C and C++. For example: return v; } + Boolean vectors are a Clang extension of the ext vector type. Boolean vectors are intended, though not guaranteed, to map to vector mask registers. The size parameter of a boolean vector type is the number of bits in the vector. The boolean vector is dense and each bit in the boolean vector is one vector -element. +element. Query for this feature with ``__has_feature(boolean_vectors)```. The semantics of boolean vectors borrows from C bit-fields with the following differences: diff --git a/clang/include/clang/Basic/Features.def b/clang/include/clang/Basic/Features.def index b9efc6a6a2e9d..d3c7642e53963 100644 --- a/clang/include/clang/Basic/Features.def +++ b/clang/include/clang/Basic/Features.def @@ -128,6 +128,7 @@ FEATURE(attribute_overloadable, true) FEATURE(attribute_unavailable_with_message, true) FEATURE(attribute_unused_on_fields, true) FEATURE(attribute_diagnose_if_objc, true) +FEATURE(boolean_vectors, true) FEATURE(blocks, LangOpts.Blocks) FEATURE(c_thread_safety_attributes, true) FEATURE(cxx_exceptions, LangOpts.CXXExceptions) diff --git a/clang/test/SemaCXX/vector-bool.cpp b/clang/test/SemaCXX/vector-bool.cpp index cd638056f348b..b5160c4cee540 100644 --- a/clang/test/SemaCXX/vector-bool.cpp +++ b/clang/test/SemaCXX/vector-bool.cpp @@ -112,3 +112,7 @@ void Sizeof() { static_assert(sizeof(Bool195) == 32); static_assert(sizeof(Bool257) == 64); } + +#if !__has_feature(boolean_vectors) +#error "FAIL" +#endif >From 0baa0851bd51dc44c0c17b9c63bf23e5e2ff6895 Mon Sep 17 00:00:00 2001 From: Joseph Huber <hube...@outlook.com> Date: Tue, 19 Aug 2025 08:24:01 -0500 Subject: [PATCH 2/2] Update LanguageExtensions.rst --- clang/docs/LanguageExtensions.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/clang/docs/LanguageExtensions.rst b/clang/docs/LanguageExtensions.rst index 953278aa62c6c..42c7e84d2d617 100644 --- a/clang/docs/LanguageExtensions.rst +++ b/clang/docs/LanguageExtensions.rst @@ -635,7 +635,6 @@ C and C++. For example: return v; } - Boolean vectors are a Clang extension of the ext vector type. Boolean vectors are intended, though not guaranteed, to map to vector mask registers. The size parameter of a boolean vector type is the number of bits in the vector. The _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits