tint: Have ast::CallExpression use ast::Identifier

Instead of ast::IdentifierExpression.
The name is not an expression, as it resolves to a function, builtin or
type.

Bug: tint:1257
Change-Id: I13143f2bbc208e9e2934dad20fe5c9aa59520b68
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118341
Kokoro: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
Ben Clayton
2023-02-02 15:16:28 +00:00
committed by Dawn LUCI CQ
parent 6e31bc24b1
commit 999db74a24
18 changed files with 105 additions and 103 deletions

View File

@@ -434,14 +434,13 @@ struct MultiplanarExternalTexture::State {
buildTextureBuiltinBody(sem::BuiltinType::kTextureSampleBaseClampToEdge));
}
const ast::IdentifierExpression* exp = b.Expr(texture_sample_external_sym);
return b.Call(exp, utils::Vector{
plane_0_binding_param,
b.Expr(syms.plane_1),
ctx.Clone(expr->args[1]),
ctx.Clone(expr->args[2]),
b.Expr(syms.params),
});
return b.Call(texture_sample_external_sym, utils::Vector{
plane_0_binding_param,
b.Expr(syms.plane_1),
ctx.Clone(expr->args[1]),
ctx.Clone(expr->args[2]),
b.Expr(syms.params),
});
}
/// Creates the textureLoadExternal function if needed and returns a call expression to it.

View File

@@ -512,9 +512,6 @@ class DecomposeSideEffects::DecomposeState : public StateBase {
return clone_maybe_hoisted(bitcast);
},
[&](const ast::CallExpression* call) {
if (call->target.name) {
ctx.Replace(call->target.name, decompose(call->target.name));
}
for (auto* a : call->args) {
ctx.Replace(a, decompose(a));
}

View File

@@ -1262,7 +1262,9 @@ Transform::ApplyResult Renamer::Apply(const Program* src,
CloneContext ctx{&b, src, /* auto_clone_symbols */ false};
// Identifiers that need to keep their symbols preserved.
utils::Hashset<const ast::IdentifierExpression*, 8> preserved_identifiers;
utils::Hashset<const ast::Identifier*, 8> preserved_identifiers;
// Identifiers expressions that need to keep their symbols preserved.
utils::Hashset<const ast::IdentifierExpression*, 8> preserved_identifiers_expressions;
// Type names that need to keep their symbols preserved.
utils::Hashset<const ast::TypeName*, 8> preserved_type_names;
@@ -1287,11 +1289,11 @@ Transform::ApplyResult Renamer::Apply(const Program* src,
[&](const ast::MemberAccessorExpression* accessor) {
auto* sem = src->Sem().Get(accessor)->UnwrapLoad();
if (sem->Is<sem::Swizzle>()) {
preserved_identifiers.Add(accessor->member);
preserved_identifiers_expressions.Add(accessor->member);
} else if (auto* str_expr = src->Sem().Get(accessor->structure)) {
if (auto* ty = str_expr->Type()->UnwrapRef()->As<sem::Struct>()) {
if (ty->Declaration() == nullptr) { // Builtin structure
preserved_identifiers.Add(accessor->member);
preserved_identifiers_expressions.Add(accessor->member);
}
}
}
@@ -1314,7 +1316,7 @@ Transform::ApplyResult Renamer::Apply(const Program* src,
}
},
[&](const ast::DiagnosticControl* diagnostic) {
preserved_identifiers.Add(diagnostic->rule_name);
preserved_identifiers_expressions.Add(diagnostic->rule_name);
},
[&](const ast::TypeName* type_name) {
if (is_type_short_name(type_name->name)) {
@@ -1376,8 +1378,18 @@ Transform::ApplyResult Renamer::Apply(const Program* src,
return sym_out;
});
ctx.ReplaceAll([&](const ast::IdentifierExpression* ident) -> const ast::IdentifierExpression* {
ctx.ReplaceAll([&](const ast::Identifier* ident) -> const ast::Identifier* {
if (preserved_identifiers.Contains(ident)) {
auto sym_in = ident->symbol;
auto str = src->Symbols().NameFor(sym_in);
auto sym_out = b.Symbols().Register(str);
return ctx.dst->create<ast::Identifier>(ctx.Clone(ident->source), sym_out);
}
return nullptr; // Clone ident. Uses the symbol remapping above.
});
ctx.ReplaceAll([&](const ast::IdentifierExpression* ident) -> const ast::IdentifierExpression* {
if (preserved_identifiers_expressions.Contains(ident)) {
auto sym_in = ident->symbol;
auto str = src->Symbols().NameFor(sym_in);
auto sym_out = b.Symbols().Register(str);