@@ -635,11 +635,12 @@ C and C++. For example:
635635 return v;
636636 }
637637
638+
638639Boolean vectors are a Clang extension of the ext vector type. Boolean vectors
639640are intended, though not guaranteed, to map to vector mask registers. The size
640641parameter of a boolean vector type is the number of bits in the vector. The
641642boolean 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
644645The semantics of boolean vectors borrows from C bit-fields with the following
645646differences:
@@ -657,6 +658,16 @@ The size and alignment are both the number of bits rounded up to the next power
657658of two, but the alignment is at most the maximum vector alignment of the
658659target.
659660
661+ A boolean vector can be used in a ternary `?: ` operator to select vector
662+ elements of a different type.
663+
664+ .. code-block :: c++
665+
666+ typedef int int4 __attribute__((ext_vector_type(4)));
667+ typedef bool bool4 __attribute__((ext_vector_type(4)));
668+
669+ int4 blend(bool4 cond, int4 a, int4 b) { return cond ? a : b; }
670+
660671
661672Vector Literals
662673---------------
@@ -757,11 +768,12 @@ elementwise to the input.
757768
758769Unless specified otherwise operation(±0) = ±0 and operation(±infinity) = ±infinity
759770
760- The integer elementwise intrinsics, including ``__builtin_elementwise_popcount ``,
771+ The elementwise intrinsics ``__builtin_elementwise_popcount ``,
761772``__builtin_elementwise_bitreverse ``, ``__builtin_elementwise_add_sat ``,
762773``__builtin_elementwise_sub_sat ``, ``__builtin_elementwise_max ``,
763- ``__builtin_elementwise_min ``, and ``__builtin_elementwise_abs ``
764- can be called in a ``constexpr `` context.
774+ ``__builtin_elementwise_min ``, ``__builtin_elementwise_abs ``,
775+ ``__builtin_elementwise_ctlz ``, ``__builtin_elementwise_cttz ``, and
776+ ``__builtin_elementwise_fma `` can be called in a ``constexpr `` context.
765777
766778No implicit promotion of integer types takes place. The mixing of integer types
767779of different sizes and signs is forbidden in binary and ternary builtins.
@@ -870,6 +882,14 @@ T __builtin_elementwise_fshr(T x, T y, T z) perform a funnel shift right. Co
870882 significant bits of the wide value), the combined value is shifted
871883 right by z, and the least significant bits are extracted to produce
872884 a result that is the same size as the original arguments.
885+ T __builtin_elementwise_ctlz(T x[, T y]) return the number of leading 0 bits in the first argument. If integer types
886+ the first argument is 0 and an optional second argument is provided,
887+ the second argument is returned. It is undefined behaviour if the
888+ first argument is 0 and no second argument is provided.
889+ T __builtin_elementwise_cttz(T x[, T y]) return the number of trailing 0 bits in the first argument. If integer types
890+ the first argument is 0 and an optional second argument is provided,
891+ the second argument is returned. It is undefined behaviour if the
892+ first argument is 0 and no second argument is provided.
873893============================================== ====================================================================== =========================================
874894
875895
@@ -922,6 +942,24 @@ Let ``VT`` be a vector type and ``ET`` the element type of ``VT``.
922942 for the comparison.
923943======================================= ====================================================================== ==================================
924944
945+ *Masked Builtins *
946+
947+ Each builtin accesses memory according to a provided boolean mask. These are
948+ provided as ``__builtin_masked_load `` and ``__builtin_masked_store ``. The first
949+ argument is always boolean mask vector.
950+
951+ Example:
952+
953+ .. code-block :: c++
954+
955+ using v8b = bool [[clang::ext_vector_type(8)]];
956+ using v8i = int [[clang::ext_vector_type(8)]];
957+
958+ v8i load(v8b m, v8i *p) { return __builtin_masked_load(m, p); }
959+
960+ void store(v8b m, v8i v, v8i *p) { __builtin_masked_store(m, v, p); }
961+
962+
925963Matrix Types
926964============
927965
@@ -1791,6 +1829,37 @@ __make_integer_seq
17911829
17921830This alias returns ``IntSeq `` instantiated with ``IntSeqT = T``and ``Ints `` being the pack ``0, ..., N - 1 ``.
17931831
1832+ __builtin_dedup_pack
1833+ --------------------
1834+
1835+ .. code-block :: c++
1836+
1837+ template <class... Ts>
1838+ using __builtin_dedup_pack = ...;
1839+
1840+ This alias takes a template parameter pack ``Ts `` and produces a new unexpanded pack containing the unique types
1841+ from ``Ts ``, with the order of the first occurrence of each type preserved.
1842+ It is useful in template metaprogramming to normalize type lists.
1843+
1844+ The resulting pack can be expanded in contexts like template argument lists or base specifiers.
1845+
1846+ **Example of Use **:
1847+
1848+ .. code-block :: c++
1849+
1850+ template <typename...> struct TypeList;
1851+
1852+ // The resulting type is TypeList<int, double, char>
1853+ template <typename ...ExtraTypes>
1854+ using MyTypeList = TypeList<__builtin_dedup_pack<int, double, int, char, double, ExtraTypes...>...>;
1855+
1856+ **Limitations **:
1857+
1858+ * This builtin can only be used inside a template.
1859+ * The resulting pack is currently only supported for expansion in template argument lists and base specifiers.
1860+ * This builtin cannot be assigned to a template template parameter.
1861+
1862+
17941863Type Trait Primitives
17951864=====================
17961865
@@ -4370,7 +4439,7 @@ fall into one of the specified floating-point classes.
43704439
43714440 if (__builtin_isfpclass (x, 448)) {
43724441 // `x ` is positive finite value
4373- ...
4442+ ...
43744443 }
43754444
43764445**Description **:
0 commit comments