Skip to content

Commit 9cd3e17

Browse files
committed
[clang][Builtins] Parse clang extended vectors types.
Clang extended vector types are mangled as follows: ext_vector_type_<lanes>_<scalar type> This is used to defetmine the builtins signature for builtins that use parmeters defined as typedef <scalar type> ext_vector_type_<lanes>_<scalar type> __attribute__((ext_vector_type(<lanes>))) For example: typedef double ext_vector_type_4_double __attribute__((ext_vector_type(4)))
1 parent 2b4d67b commit 9cd3e17

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: clang-tblgen -I %p/../../../clang/include/ %s --gen-clang-builtins | FileCheck %s
2+
// RUN: not clang-tblgen -I %p/../../../clang/include/ %s --gen-clang-builtins -DERROR_EXPECTED_LANES 2>&1 | FileCheck %s --check-prefix=ERROR_EXPECTED_LANES
3+
4+
include "clang/Basic/BuiltinsBase.td"
5+
6+
def : Builtin {
7+
let Prototype = "ext_vector_type_8_int(double, ext_vector_type_4_bool)";
8+
let Spellings = ["__builtin_test_use_clang_extended_vectors"];
9+
}
10+
11+
// CHECK: BUILTIN(__builtin_test_use_clang_extended_vectors, "E8idE4b", "")
12+
13+
#ifdef ERROR_EXPECTED_LANES
14+
def : Builtin {
15+
// ERROR_EXPECTED_LANES: :[[# @LINE + 1]]:7: error: Expected number of lanes
16+
let Prototype = "ext_vector_type__int(double, ext_vector_type_4_bool)";
17+
let Spellings = ["__builtin_test_use_clang_extended_vectors"];
18+
}
19+
#endif
20+

clang/utils/TableGen/ClangBuiltinsEmitter.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,16 @@ class PrototypeParser {
8585
if (Substitution.empty())
8686
PrintFatalError(Loc, "Not a template");
8787
ParseType(Substitution);
88+
} else if (T.consume_front("ext_vector_type_")) {
89+
// Clang extended vector types are mangled as follows:
90+
//
91+
// ext_vector_type_<lanes>_<scalar type>
92+
unsigned long long Lanes;
93+
if (llvm::consumeUnsignedInteger(T, 10, Lanes))
94+
PrintFatalError(Loc, "Expected number of lanes ");
95+
Type += "E" + std::to_string(Lanes);
96+
T.consume_front("_");
97+
ParseType(T);
8898
} else {
8999
auto ReturnTypeVal = StringSwitch<std::string>(T)
90100
.Case("__builtin_va_list_ref", "A")

0 commit comments

Comments
 (0)