Commit de65b6b
authored
[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).1 parent 9ea2fd2 commit de65b6b
File tree
18 files changed
+283
-8
lines changed- clang
- docs
- include/clang
- AST
- Basic
- lib
- AST
- CodeGen
- Parse
- Sema
- test
- CodeGen
- SemaCXX
- Sema
18 files changed
+283
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
619 | 619 | | |
620 | 620 | | |
621 | 621 | | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
622 | 630 | | |
623 | 631 | | |
624 | 632 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
185 | 191 | | |
186 | 192 | | |
187 | 193 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2060 | 2060 | | |
2061 | 2061 | | |
2062 | 2062 | | |
| 2063 | + | |
| 2064 | + | |
| 2065 | + | |
2063 | 2066 | | |
2064 | 2067 | | |
2065 | 2068 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
674 | 674 | | |
675 | 675 | | |
676 | 676 | | |
| 677 | + | |
677 | 678 | | |
678 | 679 | | |
679 | 680 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
394 | 394 | | |
395 | 395 | | |
396 | 396 | | |
| 397 | + | |
| 398 | + | |
397 | 399 | | |
398 | 400 | | |
399 | 401 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10169 | 10169 | | |
10170 | 10170 | | |
10171 | 10171 | | |
10172 | | - | |
10173 | | - | |
| 10172 | + | |
| 10173 | + | |
10174 | 10174 | | |
10175 | 10175 | | |
10176 | 10176 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
746 | 746 | | |
747 | 747 | | |
748 | 748 | | |
| 749 | + | |
749 | 750 | | |
750 | 751 | | |
751 | 752 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13595 | 13595 | | |
13596 | 13596 | | |
13597 | 13597 | | |
| 13598 | + | |
| 13599 | + | |
| 13600 | + | |
| 13601 | + | |
| 13602 | + | |
| 13603 | + | |
| 13604 | + | |
| 13605 | + | |
| 13606 | + | |
| 13607 | + | |
| 13608 | + | |
| 13609 | + | |
| 13610 | + | |
| 13611 | + | |
13598 | 13612 | | |
13599 | 13613 | | |
13600 | 13614 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5127 | 5127 | | |
5128 | 5128 | | |
5129 | 5129 | | |
| 5130 | + | |
| 5131 | + | |
| 5132 | + | |
| 5133 | + | |
| 5134 | + | |
| 5135 | + | |
| 5136 | + | |
| 5137 | + | |
5130 | 5138 | | |
5131 | 5139 | | |
5132 | 5140 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2369 | 2369 | | |
2370 | 2370 | | |
2371 | 2371 | | |
2372 | | - | |
| 2372 | + | |
2373 | 2373 | | |
2374 | 2374 | | |
2375 | 2375 | | |
| |||
2403 | 2403 | | |
2404 | 2404 | | |
2405 | 2405 | | |
| 2406 | + | |
| 2407 | + | |
| 2408 | + | |
| 2409 | + | |
2406 | 2410 | | |
2407 | 2411 | | |
2408 | 2412 | | |
| |||
0 commit comments