Skip to content

Commit 2f6b747

Browse files
authored
[Clang] Add queryable feature 'ext_vector_type_boolean' for SIMD masks (llvm#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.
1 parent 410a134 commit 2f6b747

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

clang/docs/LanguageExtensions.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,11 +635,12 @@ C and C++. For example:
635635
return v;
636636
}
637637

638+
638639
Boolean vectors are a Clang extension of the ext vector type. Boolean vectors
639640
are intended, though not guaranteed, to map to vector mask registers. The size
640641
parameter of a boolean vector type is the number of bits in the vector. The
641642
boolean vector is dense and each bit in the boolean vector is one vector
642-
element.
643+
element. Query for this feature with ``__has_feature(ext_vector_type_boolean)``.
643644

644645
The semantics of boolean vectors borrows from C bit-fields with the following
645646
differences:

clang/include/clang/Basic/Features.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ FEATURE(attribute_overloadable, true)
128128
FEATURE(attribute_unavailable_with_message, true)
129129
FEATURE(attribute_unused_on_fields, true)
130130
FEATURE(attribute_diagnose_if_objc, true)
131+
FEATURE(ext_vector_type_boolean, true)
131132
FEATURE(blocks, LangOpts.Blocks)
132133
FEATURE(c_thread_safety_attributes, true)
133134
FEATURE(cxx_exceptions, LangOpts.CXXExceptions)

clang/test/SemaCXX/vector-bool.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,7 @@ void Sizeof() {
112112
static_assert(sizeof(Bool195) == 32);
113113
static_assert(sizeof(Bool257) == 64);
114114
}
115+
116+
#if !__has_feature(ext_vector_type_boolean)
117+
#error "FAIL"
118+
#endif

0 commit comments

Comments
 (0)