mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-20 10:25:28 +00:00
tint: Have ast::IdentifierExpression use ast::Identifier
The additional nesting is somewhat unfortunate for pointer indirection overhead, but this simplfies logic like transform::Renamer, which can continue to find all the identifier nodes in the program. Bug: tint:1257 Change-Id: I8d51dd80dc4c51ef59238959029b8511f1edf70d Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118342 Reviewed-by: James Price <jrprice@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Dan Sinclair <dsinclair@chromium.org> Commit-Queue: Ben Clayton <bclayton@chromium.org>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
08027c662e
commit
6cba18b0fc
@@ -354,7 +354,7 @@ class DependencyScanner {
|
||||
Switch(
|
||||
expr,
|
||||
[&](const ast::IdentifierExpression* ident) {
|
||||
AddDependency(ident, ident->symbol, "identifier", "references");
|
||||
AddDependency(ident, ident->identifier->symbol, "identifier", "references");
|
||||
},
|
||||
[&](const ast::CallExpression* call) {
|
||||
if (call->target.name) {
|
||||
|
||||
@@ -2660,7 +2660,8 @@ sem::Expression* Resolver::Literal(const ast::LiteralExpression* literal) {
|
||||
}
|
||||
|
||||
sem::Expression* Resolver::Identifier(const ast::IdentifierExpression* expr) {
|
||||
auto symbol = expr->symbol;
|
||||
Mark(expr->identifier);
|
||||
auto symbol = expr->identifier->symbol;
|
||||
auto* sem_resolved = sem_.ResolvedSymbol<sem::Node>(expr);
|
||||
if (auto* variable = As<sem::Variable>(sem_resolved)) {
|
||||
auto* user = builder_->create<sem::VariableUser>(expr, current_statement_, variable);
|
||||
@@ -2765,11 +2766,13 @@ sem::Expression* Resolver::MemberAccessor(const ast::MemberAccessorExpression* e
|
||||
// Object may be a side-effecting expression (e.g. function call).
|
||||
bool has_side_effects = object && object->HasSideEffects();
|
||||
|
||||
Mark(expr->member);
|
||||
Mark(expr->member->identifier);
|
||||
|
||||
return Switch(
|
||||
storage_ty, //
|
||||
[&](const sem::Struct* str) -> sem::Expression* {
|
||||
Mark(expr->member);
|
||||
auto symbol = expr->member->symbol;
|
||||
auto symbol = expr->member->identifier->symbol;
|
||||
|
||||
const sem::StructMember* member = nullptr;
|
||||
for (auto* m : str->Members()) {
|
||||
@@ -2802,8 +2805,7 @@ sem::Expression* Resolver::MemberAccessor(const ast::MemberAccessorExpression* e
|
||||
},
|
||||
|
||||
[&](const type::Vector* vec) -> sem::Expression* {
|
||||
Mark(expr->member);
|
||||
std::string s = builder_->Symbols().NameFor(expr->member->symbol);
|
||||
std::string s = builder_->Symbols().NameFor(expr->member->identifier->symbol);
|
||||
auto size = s.size();
|
||||
utils::Vector<uint32_t, 4> swizzle;
|
||||
swizzle.Reserve(s.size());
|
||||
@@ -3059,7 +3061,9 @@ sem::Expression* Resolver::UnaryOp(const ast::UnaryOpExpression* unary) {
|
||||
|
||||
bool Resolver::DiagnosticControl(const ast::DiagnosticControl* control) {
|
||||
Mark(control->rule_name);
|
||||
auto rule_name = builder_->Symbols().NameFor(control->rule_name->symbol);
|
||||
Mark(control->rule_name->identifier);
|
||||
|
||||
auto rule_name = builder_->Symbols().NameFor(control->rule_name->identifier->symbol);
|
||||
auto rule = ast::ParseDiagnosticRule(rule_name);
|
||||
if (rule != ast::DiagnosticRule::kUndefined) {
|
||||
validator_.DiagnosticFilters().Set(rule, control->severity);
|
||||
|
||||
@@ -2074,11 +2074,11 @@ TEST_F(ResolverTest, ASTNodeNotReached) {
|
||||
EXPECT_FATAL_FAILURE(
|
||||
{
|
||||
ProgramBuilder b;
|
||||
b.Expr("expr");
|
||||
b.Ident("ident");
|
||||
Resolver(&b).Resolve();
|
||||
},
|
||||
"internal compiler error: AST node 'tint::ast::IdentifierExpression' was not reached by "
|
||||
"the resolver");
|
||||
"internal compiler error: AST node 'tint::ast::Identifier' was not reached by the "
|
||||
"resolver");
|
||||
}
|
||||
|
||||
TEST_F(ResolverTest, ASTNodeReachedTwice) {
|
||||
|
||||
@@ -1144,7 +1144,7 @@ class UniformityGraph {
|
||||
|
||||
auto* var_user = sem_.Get(ident)->Unwrap()->As<sem::VariableUser>();
|
||||
auto* sem = var_user->Variable();
|
||||
auto* node = CreateNode({NameFor(ident), "_ident_expr"}, ident);
|
||||
auto* node = CreateNode({NameFor(ident->identifier), "_ident_expr"}, ident);
|
||||
return Switch(
|
||||
sem,
|
||||
|
||||
@@ -1365,7 +1365,7 @@ class UniformityGraph {
|
||||
return std::make_pair(cf, current_function_->may_be_non_uniform);
|
||||
} else if (auto* local = sem->Variable()->As<sem::LocalVariable>()) {
|
||||
// Create a new value node for this variable.
|
||||
auto* value = CreateNode({NameFor(i), "_lvalue"});
|
||||
auto* value = CreateNode({NameFor(i->identifier), "_lvalue"});
|
||||
auto* old_value = current_function_->variables.Set(local, value);
|
||||
|
||||
// If i is part of an expression that is a partial reference to a variable (e.g.
|
||||
@@ -1769,10 +1769,10 @@ class UniformityGraph {
|
||||
std::ostringstream ss;
|
||||
if (auto* param = var->As<sem::Parameter>()) {
|
||||
auto* func = param->Owner()->As<sem::Function>();
|
||||
ss << param_type(param) << "'" << NameFor(ident) << "' of '"
|
||||
ss << param_type(param) << "'" << NameFor(ident->identifier) << "' of '"
|
||||
<< NameFor(func->Declaration()) << "' may be non-uniform";
|
||||
} else {
|
||||
ss << "reading from " << var_type(var) << "'" << NameFor(ident)
|
||||
ss << "reading from " << var_type(var) << "'" << NameFor(ident->identifier)
|
||||
<< "' may result in a non-uniform value";
|
||||
}
|
||||
diagnostics_.add_note(diag::System::Resolver, ss.str(), ident->source);
|
||||
|
||||
@@ -2452,7 +2452,7 @@ bool Validator::DiagnosticControls(utils::VectorRef<const ast::DiagnosticControl
|
||||
// They conflict if the rule name is the same and the severity is different.
|
||||
utils::Hashmap<Symbol, const ast::DiagnosticControl*, 8> diagnostics;
|
||||
for (auto* dc : controls) {
|
||||
auto diag_added = diagnostics.Add(dc->rule_name->symbol, dc);
|
||||
auto diag_added = diagnostics.Add(dc->rule_name->identifier->symbol, dc);
|
||||
if (!diag_added && (*diag_added.value)->severity != dc->severity) {
|
||||
{
|
||||
std::ostringstream ss;
|
||||
@@ -2461,8 +2461,8 @@ bool Validator::DiagnosticControls(utils::VectorRef<const ast::DiagnosticControl
|
||||
}
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << "severity of '" << symbols_.NameFor(dc->rule_name->symbol) << "' set to '"
|
||||
<< dc->severity << "' here";
|
||||
ss << "severity of '" << symbols_.NameFor(dc->rule_name->identifier->symbol)
|
||||
<< "' set to '" << dc->severity << "' here";
|
||||
AddNote(ss.str(), (*diag_added.value)->source);
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user