[clang][tablegen] Allow qualifiers on _Vector builtin types (#207091)

The builtin prototype parser accepts pointers to _Vector<> template
types but not const/volatile/restrict pointers. Currently, _Vector<>
types are parsed in a special way: first parsing the type itself,
consuming it, and saving the resulting type string. Then, the remaining
qualifiers are parsed while the type is removed from the input. For this
to work, parsing qualifiers must accept empty base type, which was the
case only for plain pointers and references.
This change extends this approach to const/volatile/restrict qualifiers.

Signed-off-by: Alexey Karyakin <akaryaki@qti.qualcomm.com>
This commit is contained in:
Alexey Karyakin 2026-07-06 11:33:58 -05:00 committed by GitHub
parent 8e8e4e50f5
commit 902273247d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 30 additions and 3 deletions

View file

@ -87,6 +87,30 @@ def : Builtin {
let Spellings = ["__builtin_13"];
}
def : Builtin {
// CHECK: Builtin::Info{{.*}} __builtin_14 {{.*}} /* vV2iC* */
let Prototype = "void(_Vector<2, int> const *)";
let Spellings = ["__builtin_14"];
}
def : Builtin {
// CHECK: Builtin::Info{{.*}} __builtin_15 {{.*}} /* vV2iD* */
let Prototype = "void(_Vector<2, int> volatile *)";
let Spellings = ["__builtin_15"];
}
def : Builtin {
// CHECK: Builtin::Info{{.*}} __builtin_16 {{.*}} /* vV2iR* */
let Prototype = "void(_Vector<2, int> restrict *)";
let Spellings = ["__builtin_16"];
}
def : Builtin {
// CHECK: Builtin::Info{{.*}} __builtin_17 {{.*}} /* V2iC*i */
let Prototype = "_Vector<2, int> const *(int)";
let Spellings = ["__builtin_17"];
}
#ifdef ERROR_EXPECTED_LANES
def : Builtin {
// ERROR_EXPECTED_LANES: :[[# @LINE + 1]]:7: error: Expected number of lanes after '_ExtVector<'

View file

@ -274,13 +274,16 @@ private:
if (AS)
Type += std::to_string(*AS);
} else if (T.consume_back("const")) {
ParseType(T);
if (!T.empty())
ParseType(T);
Type += "C";
} else if (T.consume_back("volatile")) {
ParseType(T);
if (!T.empty())
ParseType(T);
Type += "D";
} else if (T.consume_back("restrict")) {
ParseType(T);
if (!T.empty())
ParseType(T);
Type += "R";
} else if (T.consume_back("&")) {
// References may have an address space qualifier immediately before them.