[clang] fefb685 - [Clang][Docs] Fix ``ext_vector_type`` code block documentation

Joseph Huber via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 7 11:55:57 PST 2025


Author: Joseph Huber
Date: 2025-03-07T13:55:39-06:00
New Revision: fefb6858da42053268b53c07aff8e1cf84dc1ada

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

LOG: [Clang][Docs] Fix ``ext_vector_type`` code block documentation

Added: 
    

Modified: 
    clang/include/clang/Basic/AttrDocs.td

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td
index a1b08ac23ee9d..1f2f02a4453fc 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -1116,10 +1116,10 @@ template instantiation, so the value for ``T::number`` is known.
 def ExtVectorTypeDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{
-The ext_vector_type(N) attribute specifies that a type is a vector with N
+The ``ext_vector_type(N)`` attribute specifies that a type is a vector with N
 elements, directly mapping to an LLVM vector type. Originally from OpenCL, it
-allows element access the array subscript operator ``[]``, ``sN`` where ``N`` is
-a hexadecimal value, or ``x``, ``y``, ``z``, ``w`` for graphics-style indexing.
+allows element access the array subscript operator ``[]``, ``sN`` where N is
+a hexadecimal value, or ``x, y, z, w`` for graphics-style indexing.
 This attribute enables efficient SIMD operations and is usable in
 general-purpose code.
 
@@ -1128,17 +1128,16 @@ general-purpose code.
   template <typename T, uint32_t N>
   constexpr T simd_reduce(T [[clang::ext_vector_type(N)]] v) {
     static_assert((N & (N - 1)) == 0, "N must be a power of two");
-    if constexpr (N == 1) {
+    if constexpr (N == 1)
       return v[0];
-    } else {
-      T [[clang::ext_vector_type(N / 2)]] reduced = v.hi + v.lo;
-      return simd_reduce(reduced);
-    }
+    else
+      return simd_reduce<T, N / 2>(v.hi + v.lo);
   }
 
 The vector type also supports swizzling up to sixteen elements. This can be done
-using the object accessors. The OpenCL documentation lists the full list of
-accepted values.
+using the object accessors. The OpenCL documentation lists all of the accepted
+values.
+
 .. code-block:: c++
 
   using f16_x16 = _Float16 __attribute__((ext_vector_type(16)));


        


More information about the cfe-commits mailing list