Use StorageClass::kNone for ast local var decls

To declare a local variable, we write `var name : type`, not `var<function> name : type`.
This change fixes all the places where we were feeding StorageClass::kFunction into variable declarations.

Note that the resolved, semantic variable correctly infers the `kFunction` StorageClass.

Change-Id: I6221fabae1de0435044f29b9a91808421d5cace6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50821
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
Ben Clayton
2021-05-12 21:08:22 +00:00
committed by Commit Bot service account
parent 884a4e2172
commit f6c84e4d45
54 changed files with 380 additions and 410 deletions

View File

@@ -181,9 +181,9 @@ Output CalculateArrayLength::Run(const Program* in, const DataMap&) {
// Construct the variable that'll hold the result of
// RWByteAddressBuffer.GetDimensions()
auto* buffer_size_result = ctx.dst->Decl(ctx.dst->Var(
ctx.dst->Sym(), ctx.dst->ty.u32(),
ast::StorageClass::kFunction, ctx.dst->Expr(0u)));
auto* buffer_size_result = ctx.dst->Decl(
ctx.dst->Var(ctx.dst->Sym(), ctx.dst->ty.u32(),
ast::StorageClass::kNone, ctx.dst->Expr(0u)));
// Call storage_buffer.GetDimensions(buffer_size_result)
auto* call_get_dims =

View File

@@ -234,9 +234,8 @@ struct State {
ast::StatementList stmts;
// Declare the pulling position variable in the shader
stmts.emplace_back(
ctx.dst->Decl(ctx.dst->Var(GetPullingPositionName(), ctx.dst->ty.u32(),
ast::StorageClass::kFunction)));
stmts.emplace_back(ctx.dst->Decl(
ctx.dst->Var(GetPullingPositionName(), ctx.dst->ty.u32())));
for (uint32_t i = 0; i < cfg.vertex_state.size(); ++i) {
const VertexBufferLayoutDescriptor& buffer_layout = cfg.vertex_state[i];
@@ -396,8 +395,7 @@ struct State {
// Create a function-scope variable to replace the parameter.
auto func_var_sym = ctx.Clone(param->symbol());
auto* func_var_type = ctx.Clone(param->type());
auto* func_var = ctx.dst->Var(func_var_sym, func_var_type,
ast::StorageClass::kFunction);
auto* func_var = ctx.dst->Var(func_var_sym, func_var_type);
ctx.InsertBefore(func->body()->statements(), *func->body()->begin(),
ctx.dst->Decl(func_var));
// Capture mapping from location to the new variable.
@@ -471,8 +469,7 @@ struct State {
}
// Create a function-scope variable to replace the parameter.
auto* func_var = ctx.dst->Var(param_sym, ctx.Clone(param->type()),
ast::StorageClass::kFunction);
auto* func_var = ctx.dst->Var(param_sym, ctx.Clone(param->type()));
ctx.InsertBefore(func->body()->statements(), *func->body()->begin(),
ctx.dst->Decl(func_var));