Remove name fields

This CL removes the name fields from the various AST nodes now that the
symbols are used everywhere.

Change-Id: I73e8fa8958aa6e6f0159b12b63176b12c418f525
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36762
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
This commit is contained in:
dan sinclair
2021-01-11 16:24:32 +00:00
committed by dan sinclair
parent e65e4bd2c5
commit c8c31560de
23 changed files with 117 additions and 171 deletions

View File

@@ -53,7 +53,6 @@ Transform::Output EmitVertexPointSize::Run(ast::Module* in) {
auto* pointsize_var = out.module.create<ast::Variable>(
Source{}, // source
out.module.RegisterSymbol(kPointSizeVar), // symbol
kPointSizeVar, // name
ast::StorageClass::kOutput, // storage_class
f32, // type
false, // is_const
@@ -69,7 +68,7 @@ Transform::Output EmitVertexPointSize::Run(ast::Module* in) {
auto* one = out.module.create<ast::ScalarConstructorExpression>(
Source{}, out.module.create<ast::FloatLiteral>(Source{}, f32, 1.0f));
auto* pointsize_ident = out.module.create<ast::IdentifierExpression>(
Source{}, out.module.RegisterSymbol(kPointSizeVar), kPointSizeVar);
Source{}, out.module.RegisterSymbol(kPointSizeVar));
auto* pointsize_assign = out.module.create<ast::AssignmentStatement>(
Source{}, pointsize_ident, one);

View File

@@ -67,7 +67,6 @@ ast::Variable* clone_variable_with_new_name(ast::CloneContext* ctx,
return ctx->mod->create<ast::Variable>(
ctx->Clone(in->source()), // source
ctx->mod->RegisterSymbol(new_name), // symbol
new_name, // name
in->storage_class(), // storage_class
ctx->Clone(in->type()), // type
in->is_const(), // is_const
@@ -205,8 +204,8 @@ ast::Variable* FirstIndexOffset::AddUniformBuffer(ast::Module* mod) {
member_dec.push_back(
mod->create<ast::StructMemberOffsetDecoration>(Source{}, offset));
members.push_back(mod->create<ast::StructMember>(
Source{}, mod->RegisterSymbol(kFirstVertexName), kFirstVertexName,
u32_type, std::move(member_dec)));
Source{}, mod->RegisterSymbol(kFirstVertexName), u32_type,
std::move(member_dec)));
vertex_index_offset_ = offset;
offset += 4;
}
@@ -216,8 +215,8 @@ ast::Variable* FirstIndexOffset::AddUniformBuffer(ast::Module* mod) {
member_dec.push_back(
mod->create<ast::StructMemberOffsetDecoration>(Source{}, offset));
members.push_back(mod->create<ast::StructMember>(
Source{}, mod->RegisterSymbol(kFirstInstanceName), kFirstInstanceName,
u32_type, std::move(member_dec)));
Source{}, mod->RegisterSymbol(kFirstInstanceName), u32_type,
std::move(member_dec)));
instance_index_offset_ = offset;
offset += 4;
}
@@ -226,13 +225,12 @@ ast::Variable* FirstIndexOffset::AddUniformBuffer(ast::Module* mod) {
decos.push_back(mod->create<ast::StructBlockDecoration>(Source{}));
auto* struct_type = mod->create<ast::type::Struct>(
mod->RegisterSymbol(kStructName), kStructName,
mod->RegisterSymbol(kStructName),
mod->create<ast::Struct>(Source{}, std::move(members), std::move(decos)));
auto* idx_var = mod->create<ast::Variable>(
Source{}, // source
mod->RegisterSymbol(kBufferName), // symbol
kBufferName, // name
ast::StorageClass::kUniform, // storage_class
struct_type, // type
false, // is_const
@@ -254,22 +252,21 @@ ast::VariableDeclStatement* FirstIndexOffset::CreateFirstIndexOffset(
const std::string& field_name,
ast::Variable* buffer_var,
ast::Module* mod) {
auto* buffer = mod->create<ast::IdentifierExpression>(
Source{}, buffer_var->symbol(), mod->SymbolToName(buffer_var->symbol()));
auto* buffer =
mod->create<ast::IdentifierExpression>(Source{}, buffer_var->symbol());
auto lhs_name = kIndexOffsetPrefix + original_name;
auto* constructor = mod->create<ast::BinaryExpression>(
Source{}, ast::BinaryOp::kAdd,
mod->create<ast::IdentifierExpression>(
Source{}, mod->RegisterSymbol(lhs_name), lhs_name),
mod->create<ast::IdentifierExpression>(Source{},
mod->RegisterSymbol(lhs_name)),
mod->create<ast::MemberAccessorExpression>(
Source{}, buffer,
mod->create<ast::IdentifierExpression>(
Source{}, mod->RegisterSymbol(field_name), field_name)));
Source{}, mod->RegisterSymbol(field_name))));
auto* var =
mod->create<ast::Variable>(Source{}, // source
mod->RegisterSymbol(original_name), // symbol
original_name, // name
ast::StorageClass::kNone, // storage_class
mod->create<ast::type::U32>(), // type
true, // is_const

View File

@@ -32,7 +32,7 @@ ast::Function* Transform::CloneWithStatementsAtStart(
statements.emplace_back(ctx->Clone(s));
}
return ctx->mod->create<ast::Function>(
ctx->Clone(in->source()), ctx->Clone(in->symbol()), in->name_for_clone(),
ctx->Clone(in->source()), ctx->Clone(in->symbol()),
ctx->Clone(in->params()), ctx->Clone(in->return_type()),
ctx->mod->create<ast::BlockStatement>(ctx->Clone(in->body()->source()),
statements),

View File

@@ -168,7 +168,6 @@ void VertexPulling::State::FindOrInsertVertexIndexIfUsed() {
auto* var = out->create<ast::Variable>(
Source{}, // source
out->RegisterSymbol(vertex_index_name), // symbol
vertex_index_name, // name
ast::StorageClass::kInput, // storage_class
GetI32Type(), // type
false, // is_const
@@ -216,7 +215,6 @@ void VertexPulling::State::FindOrInsertInstanceIndexIfUsed() {
auto* var = out->create<ast::Variable>(
Source{}, // source
out->RegisterSymbol(instance_index_name), // symbol
instance_index_name, // name
ast::StorageClass::kInput, // storage_class
GetI32Type(), // type
false, // is_const
@@ -244,7 +242,6 @@ void VertexPulling::State::ConvertVertexInputVariablesToPrivate() {
v = out->create<ast::Variable>(
Source{}, // source
v->symbol(), // symbol
out->SymbolToName(v->symbol()), // name
ast::StorageClass::kPrivate, // storage_class
v->type(), // type
false, // is_const
@@ -273,14 +270,14 @@ void VertexPulling::State::AddVertexStorageBuffers() {
out->create<ast::StructMemberOffsetDecoration>(Source{}, 0u));
members.push_back(out->create<ast::StructMember>(
Source{}, out->RegisterSymbol(kStructBufferName), kStructBufferName,
internal_array_type, std::move(member_dec)));
Source{}, out->RegisterSymbol(kStructBufferName), internal_array_type,
std::move(member_dec)));
ast::StructDecorationList decos;
decos.push_back(out->create<ast::StructBlockDecoration>(Source{}));
auto* struct_type = out->create<ast::type::Struct>(
out->RegisterSymbol(kStructName), kStructName,
out->RegisterSymbol(kStructName),
out->create<ast::Struct>(Source{}, std::move(members), std::move(decos)));
for (uint32_t i = 0; i < cfg.vertex_state.size(); ++i) {
@@ -289,7 +286,6 @@ void VertexPulling::State::AddVertexStorageBuffers() {
auto* var = out->create<ast::Variable>(
Source{}, // source
out->RegisterSymbol(name), // symbol
name, // name
ast::StorageClass::kStorageBuffer, // storage_class
struct_type, // type
false, // is_const
@@ -315,7 +311,6 @@ ast::BlockStatement* VertexPulling::State::CreateVertexPullingPreamble() const {
Source{}, out->create<ast::Variable>(
Source{}, // source
out->RegisterSymbol(kPullingPosVarName), // symbol
kPullingPosVarName, // name
ast::StorageClass::kFunction, // storage_class
GetI32Type(), // type
false, // is_const
@@ -343,7 +338,7 @@ ast::BlockStatement* VertexPulling::State::CreateVertexPullingPreamble() const {
: instance_index_name;
// Identifier to index by
auto* index_identifier = out->create<ast::IdentifierExpression>(
Source{}, out->RegisterSymbol(name), name);
Source{}, out->RegisterSymbol(name));
// An expression for the start of the read in the buffer in bytes
auto* pos_value = out->create<ast::BinaryExpression>(
@@ -362,7 +357,7 @@ ast::BlockStatement* VertexPulling::State::CreateVertexPullingPreamble() const {
stmts.emplace_back(out->create<ast::AssignmentStatement>(
Source{},
out->create<ast::IdentifierExpression>(
Source{}, out->RegisterSymbol(ident_name), ident_name),
Source{}, out->RegisterSymbol(ident_name)),
AccessByFormat(i, attribute_desc.format)));
}
}
@@ -377,7 +372,7 @@ ast::Expression* VertexPulling::State::GenUint(uint32_t value) const {
ast::Expression* VertexPulling::State::CreatePullingPositionIdent() const {
return out->create<ast::IdentifierExpression>(
Source{}, out->RegisterSymbol(kPullingPosVarName), kPullingPosVarName);
Source{}, out->RegisterSymbol(kPullingPosVarName));
}
ast::Expression* VertexPulling::State::AccessByFormat(
@@ -421,10 +416,9 @@ ast::Expression* VertexPulling::State::AccessU32(uint32_t buffer,
out->create<ast::MemberAccessorExpression>(
Source{},
out->create<ast::IdentifierExpression>(
Source{}, out->RegisterSymbol(vbuf_name), vbuf_name),
Source{}, out->RegisterSymbol(vbuf_name)),
out->create<ast::IdentifierExpression>(
Source{}, out->RegisterSymbol(kStructBufferName),
kStructBufferName)),
Source{}, out->RegisterSymbol(kStructBufferName))),
out->create<ast::BinaryExpression>(Source{}, ast::BinaryOp::kDivide, pos,
GenUint(4)));
}