Author: Joseph Huber
Date: 2025-08-20T13:33:02-05:00
New Revision: 2f6b747997ddaa749f5cc83651ec7b950262bf23

URL: 
https://github.com/llvm/llvm-project/commit/2f6b747997ddaa749f5cc83651ec7b950262bf23
DIFF: 
https://github.com/llvm/llvm-project/commit/2f6b747997ddaa749f5cc83651ec7b950262bf23.diff

LOG: [Clang] Add queryable feature 'ext_vector_type_boolean' for SIMD masks 
(#154227)

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.

Added: 
    

Modified: 
    clang/docs/LanguageExtensions.rst
    clang/include/clang/Basic/Features.def
    clang/test/SemaCXX/vector-bool.cpp

Removed: 
    


################################################################################
diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index b4116c7c77399..eedbec39cfa4d 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(ext_vector_type_boolean)``.
 
 The semantics of boolean vectors borrows from C bit-fields with the following
 
diff erences:

diff  --git a/clang/include/clang/Basic/Features.def 
b/clang/include/clang/Basic/Features.def
index c983f2b75fe34..0e91b42a132c1 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(ext_vector_type_boolean, 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..0db04dcdb014f 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(ext_vector_type_boolean)
+#error "FAIL"
+#endif


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to