tint: Unkeyword 'var' template args

Change the address space and access mode in ast::Var from enums
to Expressions. Have the resolver resolve these, like we do for
other template arguments.

As the AST nodes now have identifier expressions, the tint-internal
'in' and 'out' address spaces have been prefixed with underscores to
prevent input code from using this.

Change-Id: Ie8abf371ee6a7031613709b83b575d2723418fcf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/120405
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton
2023-02-18 17:13:18 +00:00
committed by Dawn LUCI CQ
parent 28ec26b678
commit 79781f26d1
40 changed files with 492 additions and 557 deletions

View File

@@ -28,6 +28,12 @@ namespace tint::type {
/// @param str the string to parse
/// @returns the parsed enum, or AddressSpace::kUndefined if the string could not be parsed.
AddressSpace ParseAddressSpace(std::string_view str) {
if (str == "__in") {
return AddressSpace::kIn;
}
if (str == "__out") {
return AddressSpace::kOut;
}
if (str == "function") {
return AddressSpace::kFunction;
}
@@ -53,14 +59,14 @@ std::ostream& operator<<(std::ostream& out, AddressSpace value) {
switch (value) {
case AddressSpace::kUndefined:
return out << "undefined";
case AddressSpace::kIn:
return out << "__in";
case AddressSpace::kOut:
return out << "__out";
case AddressSpace::kFunction:
return out << "function";
case AddressSpace::kHandle:
return out << "handle";
case AddressSpace::kIn:
return out << "in";
case AddressSpace::kOut:
return out << "out";
case AddressSpace::kPrivate:
return out << "private";
case AddressSpace::kPushConstant:

View File

@@ -30,10 +30,10 @@ namespace tint::type {
/// Address space of a given pointer.
enum class AddressSpace {
kUndefined,
kIn,
kOut,
kFunction,
kHandle, // Tint-internal enum entry - not parsed
kIn, // Tint-internal enum entry - not parsed
kOut, // Tint-internal enum entry - not parsed
kPrivate,
kPushConstant,
kStorage,
@@ -52,7 +52,7 @@ std::ostream& operator<<(std::ostream& out, AddressSpace value);
AddressSpace ParseAddressSpace(std::string_view str);
constexpr const char* kAddressSpaceStrings[] = {
"function", "private", "push_constant", "storage", "uniform", "workgroup",
"__in", "__out", "function", "private", "push_constant", "storage", "uniform", "workgroup",
};
/// @returns true if the AddressSpace is host-shareable

View File

@@ -31,15 +31,62 @@ namespace {
void AddressSpaceParser(::benchmark::State& state) {
const char* kStrings[] = {
"fccnctin", "ucti3", "functVon", "function", "1unction",
"unJtqqon", "llun77tion", "ppqqivtHH", "prcv", "bivaGe",
"private", "priviive", "8WWivate", "pxxvate", "pXh_cggnstant",
"pX_Vonstanu", "push_consta3t", "push_constant", "push_constanE", "push_TTPnstant",
"puxxdh_constan", "s44orage", "stSSraVVe", "RtoR22e", "storage",
"sFra9e", "stoage", "VOORRHge", "unfoym", "llnnrrf77rm",
"unif4r00", "uniform", "nfoom", "zzform", "uiiippo1",
"workgrouXX", "wor55gro99nII", "wrrrkgroSSaHH", "workgroup", "kkrHoup",
"jgkrouRR", "wokroub",
"ccin",
"3",
"_Vin",
"__in",
"1_in",
"_qiJ",
"_lli77",
"__qHupp",
"vt",
"G_bt",
"__out",
"__viut",
"__8WWt",
"Mxxou",
"fuXggton",
"fuXtou",
"funct3on",
"function",
"funEtion",
"PPncTTion",
"xxuncddon",
"p44ivate",
"prSSvaVVe",
"RriR22e",
"private",
"pFva9e",
"priate",
"VOORRHte",
"push_constyn",
"punnh_crr77stallt",
"pu4h_cons00ant",
"push_constant",
"puoo_costan",
"ushzzcnstant",
"push_coii11apt",
"storaXXe",
"9II5tnnrage",
"stoaSSrHHYe",
"storage",
"stkke",
"jtogRa",
"sbrag",
"unifojm",
"niform",
"qform",
"uniform",
"uniNNrm",
"nifrvv",
"QQiform",
"workrorf",
"workjroup",
"wNNorkrou2",
"workgroup",
"workgrop",
"rrorkgroup",
"workgroGp",
};
for (auto _ : state) {
for (auto* str : kStrings) {

View File

@@ -42,6 +42,8 @@ inline std::ostream& operator<<(std::ostream& out, Case c) {
}
static constexpr Case kValidCases[] = {
{"__in", AddressSpace::kIn},
{"__out", AddressSpace::kOut},
{"function", AddressSpace::kFunction},
{"private", AddressSpace::kPrivate},
{"push_constant", AddressSpace::kPushConstant},
@@ -51,15 +53,18 @@ static constexpr Case kValidCases[] = {
};
static constexpr Case kInvalidCases[] = {
{"fccnctin", AddressSpace::kUndefined}, {"ucti3", AddressSpace::kUndefined},
{"functVon", AddressSpace::kUndefined}, {"priv1te", AddressSpace::kUndefined},
{"pqiJate", AddressSpace::kUndefined}, {"privat7ll", AddressSpace::kUndefined},
{"pqqsh_pponstHnt", AddressSpace::kUndefined}, {"pus_cnstat", AddressSpace::kUndefined},
{"bus_Gonstant", AddressSpace::kUndefined}, {"storiive", AddressSpace::kUndefined},
{"8WWorage", AddressSpace::kUndefined}, {"sxxrage", AddressSpace::kUndefined},
{"uXforgg", AddressSpace::kUndefined}, {"nfoXm", AddressSpace::kUndefined},
{"unif3rm", AddressSpace::kUndefined}, {"workgroEp", AddressSpace::kUndefined},
{"woTTPkroup", AddressSpace::kUndefined}, {"ddorkroxxp", AddressSpace::kUndefined},
{"ccin", AddressSpace::kUndefined}, {"3", AddressSpace::kUndefined},
{"_Vin", AddressSpace::kUndefined}, {"__ou1", AddressSpace::kUndefined},
{"qq_Jt", AddressSpace::kUndefined}, {"__oll7t", AddressSpace::kUndefined},
{"qquntppHon", AddressSpace::kUndefined}, {"cnciv", AddressSpace::kUndefined},
{"funGion", AddressSpace::kUndefined}, {"priviive", AddressSpace::kUndefined},
{"8WWivate", AddressSpace::kUndefined}, {"pxxvate", AddressSpace::kUndefined},
{"pXh_cggnstant", AddressSpace::kUndefined}, {"pX_Vonstanu", AddressSpace::kUndefined},
{"push_consta3t", AddressSpace::kUndefined}, {"Etorage", AddressSpace::kUndefined},
{"sPTTrage", AddressSpace::kUndefined}, {"storadxx", AddressSpace::kUndefined},
{"u44iform", AddressSpace::kUndefined}, {"unSSfoVVm", AddressSpace::kUndefined},
{"RniR22m", AddressSpace::kUndefined}, {"w9rFroup", AddressSpace::kUndefined},
{"workgoup", AddressSpace::kUndefined}, {"woVROOrHup", AddressSpace::kUndefined},
};
using AddressSpaceParseTest = testing::TestWithParam<Case>;