Rename type::Struct to type::StructType

This is to avoid name conflicts once we move all classes from namespace
`type` to `sem`.

Bug: tint:724
Change-Id: I23cdec636cb5bcf0bbba03ee7bb7c44252ddade7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48361
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
Antonio Maiorano
2021-04-19 21:31:43 +00:00
committed by Commit Bot service account
parent cf4057be01
commit 3aa226138e
47 changed files with 187 additions and 182 deletions

View File

@@ -77,8 +77,8 @@ Output CalculateArrayLength::Run(const Program* in, const DataMap&) {
// get_buffer_size_intrinsic() emits the function decorated with
// BufferSizeIntrinsic that is transformed by the HLSL writer into a call to
// [RW]ByteAddressBuffer.GetDimensions().
std::unordered_map<type::Struct*, Symbol> buffer_size_intrinsics;
auto get_buffer_size_intrinsic = [&](type::Struct* buffer_type) {
std::unordered_map<type::StructType*, Symbol> buffer_size_intrinsics;
auto get_buffer_size_intrinsic = [&](type::StructType* buffer_type) {
return utils::GetOrCreate(buffer_size_intrinsics, buffer_type, [&] {
auto name = ctx.dst->Symbols().New();
auto* func = ctx.dst->create<ast::Function>(
@@ -138,7 +138,7 @@ Output CalculateArrayLength::Run(const Program* in, const DataMap&) {
auto* storage_buffer_expr = accessor->structure();
auto* storage_buffer_sem = sem.Get(storage_buffer_expr);
auto* storage_buffer_type =
storage_buffer_sem->Type()->UnwrapAll()->As<type::Struct>();
storage_buffer_sem->Type()->UnwrapAll()->As<type::StructType>();
// Generate BufferSizeIntrinsic for this storage type if we haven't
// already
@@ -146,7 +146,7 @@ Output CalculateArrayLength::Run(const Program* in, const DataMap&) {
if (!storage_buffer_type) {
TINT_ICE(ctx.dst->Diagnostics())
<< "arrayLength(X.Y) expected X to be type::Struct, got "
<< "arrayLength(X.Y) expected X to be type::StructType, got "
<< storage_buffer_type->FriendlyName(ctx.src->Symbols());
break;
}

View File

@@ -66,7 +66,7 @@ Output CanonicalizeEntryPointIO::Run(const Program* in, const DataMap&) {
// Strip entry point IO decorations from struct declarations.
// TODO(jrprice): This code is duplicated with the SPIR-V transform.
for (auto* ty : ctx.src->AST().ConstructedTypes()) {
if (auto* struct_ty = ty->As<type::Struct>()) {
if (auto* struct_ty = ty->As<type::StructType>()) {
// Build new list of struct members without entry point IO decorations.
ast::StructMemberList new_struct_members;
for (auto* member : struct_ty->impl()->members()) {
@@ -81,7 +81,7 @@ Output CanonicalizeEntryPointIO::Run(const Program* in, const DataMap&) {
}
// Redeclare the struct.
auto* new_struct = ctx.dst->create<type::Struct>(
auto* new_struct = ctx.dst->create<type::StructType>(
ctx.Clone(struct_ty->symbol()),
ctx.dst->create<ast::Struct>(
new_struct_members, ctx.Clone(struct_ty->impl()->decorations())));
@@ -107,11 +107,11 @@ Output CanonicalizeEntryPointIO::Run(const Program* in, const DataMap&) {
std::function<ast::Expression*()> func_const_initializer;
if (auto* struct_ty = param_ty->As<type::Struct>()) {
if (auto* struct_ty = param_ty->As<type::StructType>()) {
// Pull out all struct members and build initializer list.
std::vector<Symbol> member_names;
for (auto* member : struct_ty->impl()->members()) {
if (member->type()->UnwrapAll()->Is<type::Struct>()) {
if (member->type()->UnwrapAll()->Is<type::StructType>()) {
TINT_ICE(ctx.dst->Diagnostics()) << "nested pipeline IO struct";
}
@@ -174,7 +174,7 @@ Output CanonicalizeEntryPointIO::Run(const Program* in, const DataMap&) {
StructMemberComparator);
// Create the new struct type.
auto* in_struct = ctx.dst->create<type::Struct>(
auto* in_struct = ctx.dst->create<type::StructType>(
ctx.dst->Symbols().New(),
ctx.dst->create<ast::Struct>(new_struct_members,
ast::DecorationList{}));
@@ -193,10 +193,10 @@ Output CanonicalizeEntryPointIO::Run(const Program* in, const DataMap&) {
} else {
ast::StructMemberList new_struct_members;
if (auto* struct_ty = ret_type->As<type::Struct>()) {
if (auto* struct_ty = ret_type->As<type::StructType>()) {
// Rebuild struct with only the entry point IO attributes.
for (auto* member : struct_ty->impl()->members()) {
if (member->type()->UnwrapAll()->Is<type::Struct>()) {
if (member->type()->UnwrapAll()->Is<type::StructType>()) {
TINT_ICE(ctx.dst->Diagnostics()) << "nested pipeline IO struct";
}
@@ -220,7 +220,7 @@ Output CanonicalizeEntryPointIO::Run(const Program* in, const DataMap&) {
StructMemberComparator);
// Create the new struct type.
auto* out_struct = ctx.dst->create<type::Struct>(
auto* out_struct = ctx.dst->create<type::StructType>(
ctx.dst->Symbols().New(),
ctx.dst->create<ast::Struct>(new_struct_members,
ast::DecorationList{}));
@@ -237,7 +237,7 @@ Output CanonicalizeEntryPointIO::Run(const Program* in, const DataMap&) {
};
ast::ExpressionList ret_values;
if (ret_type->Is<type::Struct>()) {
if (ret_type->Is<type::StructType>()) {
if (!ret->value()->Is<ast::IdentifierExpression>()) {
// Create a const to hold the return value expression to avoid
// re-evaluating it multiple times.

View File

@@ -341,7 +341,7 @@ type::Type* ConstructedTypeOf(type::Type* ty) {
if (auto* alias = ty->As<type::Alias>()) {
return alias;
}
if (auto* str = ty->As<type::Struct>()) {
if (auto* str = ty->As<type::StructType>()) {
return str;
}
// Not a constructed type
@@ -438,7 +438,7 @@ struct State {
ctx.dst->Add("offset", i * MatrixColumnStride(mat_ty));
values.emplace_back(ctx.dst->Call(load, "buffer", offset));
}
} else if (auto* str_ty = el_ty->As<type::Struct>()) {
} else if (auto* str_ty = el_ty->As<type::StructType>()) {
auto& sem = ctx.src->Sem();
auto* str = sem.Get(str_ty);
for (auto* member : str->Members()) {
@@ -505,7 +505,7 @@ struct State {
auto* call = ctx.dst->Call(store, "buffer", offset, access);
body.emplace_back(ctx.dst->create<ast::CallStatement>(call));
}
} else if (auto* str_ty = el_ty->As<type::Struct>()) {
} else if (auto* str_ty = el_ty->As<type::StructType>()) {
auto& sem = ctx.src->Sem();
auto* str = sem.Get(str_ty);
for (auto* member : str->Members()) {
@@ -660,7 +660,7 @@ Output DecomposeStorageAccess::Run(const Program* in, const DataMap&) {
}
} else {
if (auto access = state.TakeAccess(accessor->structure())) {
auto* str_ty = access.type->As<type::Struct>();
auto* str_ty = access.type->As<type::StructType>();
auto* member =
sem.Get(str_ty)->FindMember(accessor->member()->symbol());
auto offset = member->Offset();

View File

@@ -96,7 +96,7 @@ void Hlsl::PromoteInitializersToConstVar(CloneContext& ctx) const {
}
auto* src_ty = src_sem_expr->Type();
if (src_ty->IsAnyOf<type::ArrayType, type::Struct>()) {
if (src_ty->IsAnyOf<type::ArrayType, type::StructType>()) {
// Create a new symbol for the constant
auto dst_symbol = ctx.dst->Symbols().New();
// Clone the type

View File

@@ -111,7 +111,7 @@ void Spirv::HandleEntryPointIOTypes(CloneContext& ctx) const {
// Strip entry point IO decorations from struct declarations.
for (auto* ty : ctx.src->AST().ConstructedTypes()) {
if (auto* struct_ty = ty->As<type::Struct>()) {
if (auto* struct_ty = ty->As<type::StructType>()) {
// Build new list of struct members without entry point IO decorations.
ast::StructMemberList new_struct_members;
for (auto* member : struct_ty->impl()->members()) {
@@ -126,7 +126,7 @@ void Spirv::HandleEntryPointIOTypes(CloneContext& ctx) const {
}
// Redeclare the struct.
auto* new_struct = ctx.dst->create<type::Struct>(
auto* new_struct = ctx.dst->create<type::StructType>(
ctx.Clone(struct_ty->symbol()),
ctx.dst->create<ast::Struct>(
new_struct_members, ctx.Clone(struct_ty->impl()->decorations())));
@@ -255,7 +255,7 @@ Symbol Spirv::HoistToInputVariables(
type::Type* ty,
type::Type* declared_ty,
const ast::DecorationList& decorations) const {
if (!ty->Is<type::Struct>()) {
if (!ty->Is<type::StructType>()) {
// Base case: create a global variable and return.
ast::DecorationList new_decorations =
RemoveDecorations(&ctx, decorations, [](const ast::Decoration* deco) {
@@ -272,7 +272,7 @@ Symbol Spirv::HoistToInputVariables(
// Recurse into struct members and build the initializer list.
std::vector<Symbol> init_value_names;
auto* struct_ty = ty->As<type::Struct>();
auto* struct_ty = ty->As<type::StructType>();
for (auto* member : struct_ty->impl()->members()) {
auto member_var = HoistToInputVariables(
ctx, func, member->type(), member->type(), member->decorations());
@@ -308,7 +308,7 @@ void Spirv::HoistToOutputVariables(CloneContext& ctx,
Symbol store_value,
ast::StatementList& stores) const {
// Base case.
if (!ty->Is<type::Struct>()) {
if (!ty->Is<type::StructType>()) {
// Create a global variable.
ast::DecorationList new_decorations =
RemoveDecorations(&ctx, decorations, [](const ast::Decoration* deco) {
@@ -332,7 +332,7 @@ void Spirv::HoistToOutputVariables(CloneContext& ctx,
}
// Recurse into struct members.
auto* struct_ty = ty->As<type::Struct>();
auto* struct_ty = ty->As<type::StructType>();
for (auto* member : struct_ty->impl()->members()) {
member_accesses.push_back(ctx.Clone(member->symbol()));
HoistToOutputVariables(ctx, func, member->type(), member->type(),