[all-commits] [llvm/llvm-project] de65b6: [Clang] Add __builtin_vectorelements to get number...
Lawrence Benson via All-commits
all-commits at lists.llvm.org
Thu Oct 19 01:45:21 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: de65b6bec6771fe50f3aa73fdb79594f675be456
https://github.com/llvm/llvm-project/commit/de65b6bec6771fe50f3aa73fdb79594f675be456
Author: Lawrence Benson <github at lawben.com>
Date: 2023-10-19 (Thu, 19 Oct 2023)
Changed paths:
M clang/docs/LanguageExtensions.rst
M clang/docs/ReleaseNotes.rst
M clang/include/clang/AST/Type.h
M clang/include/clang/Basic/Builtins.def
M clang/include/clang/Basic/DiagnosticASTKinds.td
M clang/include/clang/Basic/DiagnosticSemaKinds.td
M clang/include/clang/Basic/TokenKinds.def
M clang/lib/AST/ExprConstant.cpp
M clang/lib/AST/ItaniumMangle.cpp
M clang/lib/AST/Type.cpp
M clang/lib/CodeGen/CGExprScalar.cpp
M clang/lib/Parse/ParseExpr.cpp
M clang/lib/Sema/SemaChecking.cpp
M clang/lib/Sema/SemaExpr.cpp
A clang/test/CodeGen/builtin_vectorelements.c
A clang/test/Sema/builtin_vectorelements.c
M clang/test/Sema/convertvector.c
A clang/test/SemaCXX/builtin_vectorelements.cpp
Log Message:
-----------
[Clang] Add __builtin_vectorelements to get number of elements in vector (#69010)
Adds a new `__builtin_vectorelements()` function which returns the
number of elements for a given vector either at compile-time for
fixed-sized vectors, e.g., created via `__attribute__((vector_size(N)))`
or at runtime via a call to `@llvm.vscale.i32()` for scalable vectors,
e.g., SVE or RISCV V.
The new builtin follows a similar path as `sizeof()`, as it essentially
does the same thing but for the number of elements in vector instead of
the number of bytes. This allows us to re-use a lot of the existing
logic to handle types etc.
A small side addition is `Type::isSizelessVectorType()`, which we need
to distinguish between sizeless vectors (SVE, RISCV V) and sizeless
types (WASM).
This is the [corresponding
discussion](https://discourse.llvm.org/t/new-builtin-function-to-get-number-of-lanes-in-simd-vectors/73911).
More information about the All-commits
mailing list