Move all classes from namespace type to namespace sem

Bug: tint:724
Change-Id: I4eeabab9b00b6b28f61645bd95d326fb48609bf0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48362
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
Antonio Maiorano
2021-04-19 22:51:23 +00:00
committed by Commit Bot service account
parent 3aa226138e
commit 3751fd2290
198 changed files with 3322 additions and 3367 deletions

View File

@@ -65,13 +65,13 @@ Output BindingRemapper::Run(const Program* in, const DataMap& datamap) {
if (ac_it != remappings->access_controls.end()) {
ast::AccessControl ac = ac_it->second;
auto* ty = in->Sem().Get(var)->Type();
type::Type* inner_ty = nullptr;
if (auto* old_ac = ty->As<type::AccessControl>()) {
sem::Type* inner_ty = nullptr;
if (auto* old_ac = ty->As<sem::AccessControl>()) {
inner_ty = ctx.Clone(old_ac->type());
} else {
inner_ty = ctx.Clone(ty);
}
auto* new_ty = ctx.dst->create<type::AccessControl>(ac, inner_ty);
auto* new_ty = ctx.dst->create<sem::AccessControl>(ac, inner_ty);
auto* new_var = ctx.dst->create<ast::Variable>(
ctx.Clone(var->source()), ctx.Clone(var->symbol()),
var->declared_storage_class(), new_ty, var->is_const(),

View File

@@ -42,8 +42,8 @@ ast::ArrayAccessorExpression* BoundArrayAccessors::Transform(
auto& diags = ctx->dst->Diagnostics();
auto* ret_type = ctx->src->Sem().Get(expr->array())->Type()->UnwrapAll();
if (!ret_type->Is<type::ArrayType>() && !ret_type->Is<type::Matrix>() &&
!ret_type->Is<type::Vector>()) {
if (!ret_type->Is<sem::ArrayType>() && !ret_type->Is<sem::Matrix>() &&
!ret_type->Is<sem::Vector>()) {
return nullptr;
}
@@ -51,15 +51,15 @@ ast::ArrayAccessorExpression* BoundArrayAccessors::Transform(
using u32 = ProgramBuilder::u32;
uint32_t size = 0;
bool is_vec = ret_type->Is<type::Vector>();
bool is_arr = ret_type->Is<type::ArrayType>();
bool is_vec = ret_type->Is<sem::Vector>();
bool is_arr = ret_type->Is<sem::ArrayType>();
if (is_vec || is_arr) {
size = is_vec ? ret_type->As<type::Vector>()->size()
: ret_type->As<type::ArrayType>()->size();
size = is_vec ? ret_type->As<sem::Vector>()->size()
: ret_type->As<sem::ArrayType>()->size();
} else {
// The row accessor would have been an embedded array accessor and already
// handled, so we just need to do columns here.
size = ret_type->As<type::Matrix>()->columns();
size = ret_type->As<sem::Matrix>()->columns();
}
auto* const old_idx = expr->idx_expr();

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::StructType*, Symbol> buffer_size_intrinsics;
auto get_buffer_size_intrinsic = [&](type::StructType* buffer_type) {
std::unordered_map<sem::StructType*, Symbol> buffer_size_intrinsics;
auto get_buffer_size_intrinsic = [&](sem::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::StructType>();
storage_buffer_sem->Type()->UnwrapAll()->As<sem::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::StructType, got "
<< "arrayLength(X.Y) expected X to be sem::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::StructType>()) {
if (auto* struct_ty = ty->As<sem::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::StructType>(
auto* new_struct = ctx.dst->create<sem::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::StructType>()) {
if (auto* struct_ty = param_ty->As<sem::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::StructType>()) {
if (member->type()->UnwrapAll()->Is<sem::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::StructType>(
auto* in_struct = ctx.dst->create<sem::StructType>(
ctx.dst->Symbols().New(),
ctx.dst->create<ast::Struct>(new_struct_members,
ast::DecorationList{}));
@@ -187,16 +187,16 @@ Output CanonicalizeEntryPointIO::Run(const Program* in, const DataMap&) {
// Handle return type.
auto* ret_type = func->return_type()->UnwrapAliasIfNeeded();
type::Type* new_ret_type;
if (ret_type->Is<type::Void>()) {
sem::Type* new_ret_type;
if (ret_type->Is<sem::Void>()) {
new_ret_type = ctx.dst->ty.void_();
} else {
ast::StructMemberList new_struct_members;
if (auto* struct_ty = ret_type->As<type::StructType>()) {
if (auto* struct_ty = ret_type->As<sem::StructType>()) {
// Rebuild struct with only the entry point IO attributes.
for (auto* member : struct_ty->impl()->members()) {
if (member->type()->UnwrapAll()->Is<type::StructType>()) {
if (member->type()->UnwrapAll()->Is<sem::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::StructType>(
auto* out_struct = ctx.dst->create<sem::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::StructType>()) {
if (ret_type->Is<sem::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

@@ -57,7 +57,7 @@ struct OffsetExpr : Offset {
ast::Expression* Build(CloneContext& ctx) override {
auto* type = ctx.src->Sem().Get(expr)->Type()->UnwrapAll();
auto* res = ctx.Clone(expr);
if (!type->Is<type::U32>()) {
if (!type->Is<sem::U32>()) {
res = ctx.dst->Construct<ProgramBuilder::u32>(res);
}
return res;
@@ -174,8 +174,8 @@ std::unique_ptr<Offset> Mul(LHS&& lhs_, RHS&& rhs_) {
/// TypePair is a pair of types that can be used as a unordered map or set key.
struct TypePair {
type::Type* first;
type::Type* second;
sem::Type* first;
sem::Type* second;
bool operator==(const TypePair& rhs) const {
return first == rhs.first && second == rhs.second;
}
@@ -187,67 +187,67 @@ struct TypePair {
};
/// @returns the size in bytes of a scalar
uint32_t ScalarSize(type::Type*) {
uint32_t ScalarSize(sem::Type*) {
// TODO(bclayton): Assumes 32-bit elements
return 4;
}
/// @returns the numer of bytes between columns of the given matrix
uint32_t MatrixColumnStride(type::Matrix* mat) {
uint32_t MatrixColumnStride(sem::Matrix* mat) {
return ScalarSize(mat->type()) * ((mat->rows() == 2) ? 2 : 4);
}
/// @returns a DecomposeStorageAccess::Intrinsic decoration that can be applied
/// to a stub function to load the type `ty`.
DecomposeStorageAccess::Intrinsic* IntrinsicLoadFor(ProgramBuilder* builder,
type::Type* ty) {
sem::Type* ty) {
using Intrinsic = DecomposeStorageAccess::Intrinsic;
auto intrinsic = [builder](Intrinsic::Type type) {
return builder->ASTNodes().Create<Intrinsic>(builder->ID(), type);
};
if (ty->Is<type::I32>()) {
if (ty->Is<sem::I32>()) {
return intrinsic(Intrinsic::kLoadI32);
}
if (ty->Is<type::U32>()) {
if (ty->Is<sem::U32>()) {
return intrinsic(Intrinsic::kLoadU32);
}
if (ty->Is<type::F32>()) {
if (ty->Is<sem::F32>()) {
return intrinsic(Intrinsic::kLoadF32);
}
if (auto* vec = ty->As<type::Vector>()) {
if (auto* vec = ty->As<sem::Vector>()) {
switch (vec->size()) {
case 2:
if (vec->type()->Is<type::I32>()) {
if (vec->type()->Is<sem::I32>()) {
return intrinsic(Intrinsic::kLoadVec2I32);
}
if (vec->type()->Is<type::U32>()) {
if (vec->type()->Is<sem::U32>()) {
return intrinsic(Intrinsic::kLoadVec2U32);
}
if (vec->type()->Is<type::F32>()) {
if (vec->type()->Is<sem::F32>()) {
return intrinsic(Intrinsic::kLoadVec2F32);
}
break;
case 3:
if (vec->type()->Is<type::I32>()) {
if (vec->type()->Is<sem::I32>()) {
return intrinsic(Intrinsic::kLoadVec3I32);
}
if (vec->type()->Is<type::U32>()) {
if (vec->type()->Is<sem::U32>()) {
return intrinsic(Intrinsic::kLoadVec3U32);
}
if (vec->type()->Is<type::F32>()) {
if (vec->type()->Is<sem::F32>()) {
return intrinsic(Intrinsic::kLoadVec3F32);
}
break;
case 4:
if (vec->type()->Is<type::I32>()) {
if (vec->type()->Is<sem::I32>()) {
return intrinsic(Intrinsic::kLoadVec4I32);
}
if (vec->type()->Is<type::U32>()) {
if (vec->type()->Is<sem::U32>()) {
return intrinsic(Intrinsic::kLoadVec4U32);
}
if (vec->type()->Is<type::F32>()) {
if (vec->type()->Is<sem::F32>()) {
return intrinsic(Intrinsic::kLoadVec4F32);
}
break;
@@ -259,54 +259,54 @@ DecomposeStorageAccess::Intrinsic* IntrinsicLoadFor(ProgramBuilder* builder,
/// @returns a DecomposeStorageAccess::Intrinsic decoration that can be applied
/// to a stub function to store the type `ty`.
DecomposeStorageAccess::Intrinsic* IntrinsicStoreFor(ProgramBuilder* builder,
type::Type* ty) {
sem::Type* ty) {
using Intrinsic = DecomposeStorageAccess::Intrinsic;
auto intrinsic = [builder](Intrinsic::Type type) {
return builder->ASTNodes().Create<Intrinsic>(builder->ID(), type);
};
if (ty->Is<type::I32>()) {
if (ty->Is<sem::I32>()) {
return intrinsic(Intrinsic::kStoreI32);
}
if (ty->Is<type::U32>()) {
if (ty->Is<sem::U32>()) {
return intrinsic(Intrinsic::kStoreU32);
}
if (ty->Is<type::F32>()) {
if (ty->Is<sem::F32>()) {
return intrinsic(Intrinsic::kStoreF32);
}
if (auto* vec = ty->As<type::Vector>()) {
if (auto* vec = ty->As<sem::Vector>()) {
switch (vec->size()) {
case 2:
if (vec->type()->Is<type::I32>()) {
if (vec->type()->Is<sem::I32>()) {
return intrinsic(Intrinsic::kStoreVec2U32);
}
if (vec->type()->Is<type::U32>()) {
if (vec->type()->Is<sem::U32>()) {
return intrinsic(Intrinsic::kStoreVec2F32);
}
if (vec->type()->Is<type::F32>()) {
if (vec->type()->Is<sem::F32>()) {
return intrinsic(Intrinsic::kStoreVec2I32);
}
break;
case 3:
if (vec->type()->Is<type::I32>()) {
if (vec->type()->Is<sem::I32>()) {
return intrinsic(Intrinsic::kStoreVec3U32);
}
if (vec->type()->Is<type::U32>()) {
if (vec->type()->Is<sem::U32>()) {
return intrinsic(Intrinsic::kStoreVec3F32);
}
if (vec->type()->Is<type::F32>()) {
if (vec->type()->Is<sem::F32>()) {
return intrinsic(Intrinsic::kStoreVec3I32);
}
break;
case 4:
if (vec->type()->Is<type::I32>()) {
if (vec->type()->Is<sem::I32>()) {
return intrinsic(Intrinsic::kStoreVec4U32);
}
if (vec->type()->Is<type::U32>()) {
if (vec->type()->Is<sem::U32>()) {
return intrinsic(Intrinsic::kStoreVec4F32);
}
if (vec->type()->Is<type::F32>()) {
if (vec->type()->Is<sem::F32>()) {
return intrinsic(Intrinsic::kStoreVec4I32);
}
break;
@@ -328,20 +328,20 @@ void InsertGlobal(CloneContext& ctx, Cloneable* insert_after, Cloneable* node) {
}
/// @returns the unwrapped, user-declared constructed type of ty.
type::Type* ConstructedTypeOf(type::Type* ty) {
sem::Type* ConstructedTypeOf(sem::Type* ty) {
while (true) {
if (auto* ptr = ty->As<type::Pointer>()) {
if (auto* ptr = ty->As<sem::Pointer>()) {
ty = ptr->type();
continue;
}
if (auto* access = ty->As<type::AccessControl>()) {
if (auto* access = ty->As<sem::AccessControl>()) {
ty = access->type();
continue;
}
if (auto* alias = ty->As<type::Alias>()) {
if (auto* alias = ty->As<sem::Alias>()) {
return alias;
}
if (auto* str = ty->As<type::StructType>()) {
if (auto* str = ty->As<sem::StructType>()) {
return str;
}
// Not a constructed type
@@ -350,7 +350,7 @@ type::Type* ConstructedTypeOf(type::Type* ty) {
}
/// @returns the given type with all pointers and aliases removed.
type::Type* UnwrapPtrAndAlias(type::Type* ty) {
sem::Type* UnwrapPtrAndAlias(sem::Type* ty) {
return ty->UnwrapPtrIfNeeded()->UnwrapAliasIfNeeded()->UnwrapPtrIfNeeded();
}
@@ -358,7 +358,7 @@ type::Type* UnwrapPtrAndAlias(type::Type* ty) {
struct StorageBufferAccess {
sem::Expression const* var = nullptr; // Storage buffer variable
std::unique_ptr<Offset> offset; // The byte offset on var
type::Type* type = nullptr; // The type of the access
sem::Type* type = nullptr; // The type of the access
operator bool() const { return var; } // Returns true if valid
};
@@ -410,8 +410,8 @@ struct State {
/// the signature: `fn load(buf : buf_ty, offset : u32) -> el_ty`
Symbol LoadFunc(CloneContext& ctx,
Cloneable* insert_after,
type::Type* buf_ty,
type::Type* el_ty) {
sem::Type* buf_ty,
sem::Type* el_ty) {
return utils::GetOrCreate(load_funcs, TypePair{buf_ty, el_ty}, [&] {
ast::VariableList params = {
// Note: The buffer parameter requires the kStorage StorageClass in
@@ -429,16 +429,16 @@ struct State {
ast::DecorationList{intrinsic}, ast::DecorationList{});
} else {
ast::ExpressionList values;
if (auto* mat_ty = el_ty->As<type::Matrix>()) {
auto* vec_ty = ctx.dst->create<type::Vector>(
ctx.Clone(mat_ty->type()), mat_ty->rows());
if (auto* mat_ty = el_ty->As<sem::Matrix>()) {
auto* vec_ty = ctx.dst->create<sem::Vector>(ctx.Clone(mat_ty->type()),
mat_ty->rows());
Symbol load = LoadFunc(ctx, insert_after, buf_ty, vec_ty);
for (uint32_t i = 0; i < mat_ty->columns(); i++) {
auto* offset =
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::StructType>()) {
} else if (auto* str_ty = el_ty->As<sem::StructType>()) {
auto& sem = ctx.src->Sem();
auto* str = sem.Get(str_ty);
for (auto* member : str->Members()) {
@@ -447,7 +447,7 @@ struct State {
member->Declaration()->type()->UnwrapAll());
values.emplace_back(ctx.dst->Call(load, "buffer", offset));
}
} else if (auto* arr_ty = el_ty->As<type::ArrayType>()) {
} else if (auto* arr_ty = el_ty->As<sem::ArrayType>()) {
auto& sem = ctx.src->Sem();
auto* arr = sem.Get(arr_ty);
for (uint32_t i = 0; i < arr_ty->size(); i++) {
@@ -474,8 +474,8 @@ struct State {
/// has the signature: `fn store(buf : buf_ty, offset : u32, value : el_ty)`
Symbol StoreFunc(CloneContext& ctx,
Cloneable* insert_after,
type::Type* buf_ty,
type::Type* el_ty) {
sem::Type* buf_ty,
sem::Type* el_ty) {
return utils::GetOrCreate(store_funcs, TypePair{buf_ty, el_ty}, [&] {
ast::VariableList params{
// Note: The buffer parameter requires the kStorage StorageClass in
@@ -494,9 +494,9 @@ struct State {
} else {
ast::StatementList body;
if (auto* mat_ty = el_ty->As<type::Matrix>()) {
auto* vec_ty = ctx.dst->create<type::Vector>(
ctx.Clone(mat_ty->type()), mat_ty->rows());
if (auto* mat_ty = el_ty->As<sem::Matrix>()) {
auto* vec_ty = ctx.dst->create<sem::Vector>(ctx.Clone(mat_ty->type()),
mat_ty->rows());
Symbol store = StoreFunc(ctx, insert_after, buf_ty, vec_ty);
for (uint32_t i = 0; i < mat_ty->columns(); i++) {
auto* offset =
@@ -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::StructType>()) {
} else if (auto* str_ty = el_ty->As<sem::StructType>()) {
auto& sem = ctx.src->Sem();
auto* str = sem.Get(str_ty);
for (auto* member : str->Members()) {
@@ -518,7 +518,7 @@ struct State {
auto* call = ctx.dst->Call(store, "buffer", offset, access);
body.emplace_back(ctx.dst->create<ast::CallStatement>(call));
}
} else if (auto* arr_ty = el_ty->As<type::ArrayType>()) {
} else if (auto* arr_ty = el_ty->As<sem::ArrayType>()) {
auto& sem = ctx.src->Sem();
auto* arr = sem.Get(arr_ty);
for (uint32_t i = 0; i < arr_ty->size(); i++) {
@@ -647,7 +647,7 @@ Output DecomposeStorageAccess::Run(const Program* in, const DataMap&) {
if (auto* swizzle = accessor_sem->As<sem::Swizzle>()) {
if (swizzle->Indices().size() == 1) {
if (auto access = state.TakeAccess(accessor->structure())) {
auto* vec_ty = access.type->As<type::Vector>();
auto* vec_ty = access.type->As<sem::Vector>();
auto offset =
Mul(ScalarSize(vec_ty->type()), swizzle->Indices()[0]);
state.AddAccesss(
@@ -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::StructType>();
auto* str_ty = access.type->As<sem::StructType>();
auto* member =
sem.Get(str_ty)->FindMember(accessor->member()->symbol());
auto offset = member->Offset();
@@ -678,7 +678,7 @@ Output DecomposeStorageAccess::Run(const Program* in, const DataMap&) {
if (auto* accessor = node->As<ast::ArrayAccessorExpression>()) {
if (auto access = state.TakeAccess(accessor->array())) {
// X[Y]
if (auto* arr_ty = access.type->As<type::ArrayType>()) {
if (auto* arr_ty = access.type->As<sem::ArrayType>()) {
auto stride = sem.Get(arr_ty)->Stride();
auto offset = Mul(stride, accessor->idx_expr());
state.AddAccesss(accessor,
@@ -689,7 +689,7 @@ Output DecomposeStorageAccess::Run(const Program* in, const DataMap&) {
});
continue;
}
if (auto* vec_ty = access.type->As<type::Vector>()) {
if (auto* vec_ty = access.type->As<sem::Vector>()) {
auto offset = Mul(ScalarSize(vec_ty->type()), accessor->idx_expr());
state.AddAccesss(accessor,
{
@@ -699,9 +699,9 @@ Output DecomposeStorageAccess::Run(const Program* in, const DataMap&) {
});
continue;
}
if (auto* mat_ty = access.type->As<type::Matrix>()) {
if (auto* mat_ty = access.type->As<sem::Matrix>()) {
auto offset = Mul(MatrixColumnStride(mat_ty), accessor->idx_expr());
auto* vec_ty = ctx.dst->create<type::Vector>(
auto* vec_ty = ctx.dst->create<sem::Vector>(
ctx.Clone(mat_ty->type()->UnwrapAll()), mat_ty->rows());
state.AddAccesss(accessor,
{

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::StructType>()) {
if (src_ty->IsAnyOf<sem::ArrayType, sem::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::StructType>()) {
if (auto* struct_ty = ty->As<sem::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::StructType>(
auto* new_struct = ctx.dst->create<sem::StructType>(
ctx.Clone(struct_ty->symbol()),
ctx.dst->create<ast::Struct>(
new_struct_members, ctx.Clone(struct_ty->impl()->decorations())));
@@ -151,7 +151,7 @@ void Spirv::HandleEntryPointIOTypes(CloneContext& ctx) const {
}
}
if (!func->return_type()->Is<type::Void>()) {
if (!func->return_type()->Is<sem::Void>()) {
ast::StatementList stores;
auto store_value_symbol = ctx.dst->Symbols().New();
HoistToOutputVariables(
@@ -252,10 +252,10 @@ void Spirv::AddEmptyEntryPoint(CloneContext& ctx) const {
Symbol Spirv::HoistToInputVariables(
CloneContext& ctx,
const ast::Function* func,
type::Type* ty,
type::Type* declared_ty,
sem::Type* ty,
sem::Type* declared_ty,
const ast::DecorationList& decorations) const {
if (!ty->Is<type::StructType>()) {
if (!ty->Is<sem::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::StructType>();
auto* struct_ty = ty->As<sem::StructType>();
for (auto* member : struct_ty->impl()->members()) {
auto member_var = HoistToInputVariables(
ctx, func, member->type(), member->type(), member->decorations());
@@ -301,14 +301,14 @@ Symbol Spirv::HoistToInputVariables(
void Spirv::HoistToOutputVariables(CloneContext& ctx,
const ast::Function* func,
type::Type* ty,
type::Type* declared_ty,
sem::Type* ty,
sem::Type* declared_ty,
const ast::DecorationList& decorations,
std::vector<Symbol> member_accesses,
Symbol store_value,
ast::StatementList& stores) const {
// Base case.
if (!ty->Is<type::StructType>()) {
if (!ty->Is<sem::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::StructType>();
auto* struct_ty = ty->As<sem::StructType>();
for (auto* member : struct_ty->impl()->members()) {
member_accesses.push_back(ctx.Clone(member->symbol()));
HoistToOutputVariables(ctx, func, member->type(), member->type(),

View File

@@ -59,8 +59,8 @@ class Spirv : public Transform {
/// Return the symbol for the variable that was created.
Symbol HoistToInputVariables(CloneContext& ctx,
const ast::Function* func,
type::Type* ty,
type::Type* declared_ty,
sem::Type* ty,
sem::Type* declared_ty,
const ast::DecorationList& decorations) const;
/// Recursively create module-scope output variables for `ty` and build a list
@@ -73,8 +73,8 @@ class Spirv : public Transform {
/// Returns the list of variable assignments in `stores`.
void HoistToOutputVariables(CloneContext& ctx,
const ast::Function* func,
type::Type* ty,
type::Type* declared_ty,
sem::Type* ty,
sem::Type* declared_ty,
const ast::DecorationList& decorations,
std::vector<Symbol> member_accesses,
Symbol store_value,

View File

@@ -367,7 +367,7 @@ struct State {
/// @param count how many elements the vector has
ast::Expression* AccessVec(uint32_t buffer,
uint32_t element_stride,
type::Type* base_type,
sem::Type* base_type,
VertexFormat base_format,
uint32_t count) {
ast::ExpressionList expr_list;
@@ -379,7 +379,7 @@ struct State {
}
return ctx.dst->create<ast::TypeConstructorExpression>(
ctx.dst->create<type::Vector>(base_type, count), std::move(expr_list));
ctx.dst->create<sem::Vector>(base_type, count), std::move(expr_list));
}
};