mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 10:49:14 +00:00
Move pointer and ref to type/
This CL moves the pointer and reference files over to type/ and updates the namespaces. Bug: tint:1718 Change-Id: I487a37ef2f6a3884d2ff51af4ac63869c3e03698 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/113420 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
92ccab037f
commit
4d56b48bbf
@@ -23,11 +23,11 @@
|
||||
#include "src/tint/sem/block_statement.h"
|
||||
#include "src/tint/sem/call.h"
|
||||
#include "src/tint/sem/function.h"
|
||||
#include "src/tint/sem/reference.h"
|
||||
#include "src/tint/sem/statement.h"
|
||||
#include "src/tint/sem/struct.h"
|
||||
#include "src/tint/sem/variable.h"
|
||||
#include "src/tint/transform/simplify_pointers.h"
|
||||
#include "src/tint/type/reference.h"
|
||||
#include "src/tint/utils/hash.h"
|
||||
#include "src/tint/utils/map.h"
|
||||
|
||||
@@ -100,8 +100,8 @@ Transform::ApplyResult CalculateArrayLength::Apply(const Program* src,
|
||||
// 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<const sem::Reference*, Symbol> buffer_size_intrinsics;
|
||||
auto get_buffer_size_intrinsic = [&](const sem::Reference* buffer_type) {
|
||||
std::unordered_map<const type::Reference*, Symbol> buffer_size_intrinsics;
|
||||
auto get_buffer_size_intrinsic = [&](const type::Reference* buffer_type) {
|
||||
return utils::GetOrCreate(buffer_size_intrinsics, buffer_type, [&] {
|
||||
auto name = b.Sym();
|
||||
auto* type = CreateASTTypeFor(ctx, buffer_type);
|
||||
@@ -168,7 +168,7 @@ Transform::ApplyResult CalculateArrayLength::Apply(const Program* src,
|
||||
break;
|
||||
}
|
||||
auto* storage_buffer_var = storage_buffer_sem->Variable();
|
||||
auto* storage_buffer_type = storage_buffer_sem->Type()->As<sem::Reference>();
|
||||
auto* storage_buffer_type = storage_buffer_sem->Type()->As<type::Reference>();
|
||||
|
||||
// Generate BufferSizeIntrinsic for this storage type if we haven't already
|
||||
auto buffer_size = get_buffer_size_intrinsic(storage_buffer_type);
|
||||
|
||||
@@ -30,10 +30,10 @@
|
||||
#include "src/tint/sem/atomic.h"
|
||||
#include "src/tint/sem/call.h"
|
||||
#include "src/tint/sem/member_accessor_expression.h"
|
||||
#include "src/tint/sem/reference.h"
|
||||
#include "src/tint/sem/statement.h"
|
||||
#include "src/tint/sem/struct.h"
|
||||
#include "src/tint/sem/variable.h"
|
||||
#include "src/tint/type/reference.h"
|
||||
#include "src/tint/utils/block_allocator.h"
|
||||
#include "src/tint/utils/hash.h"
|
||||
#include "src/tint/utils/map.h"
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
#include "src/tint/sem/block_statement.h"
|
||||
#include "src/tint/sem/call.h"
|
||||
#include "src/tint/sem/function.h"
|
||||
#include "src/tint/sem/reference.h"
|
||||
#include "src/tint/sem/statement.h"
|
||||
#include "src/tint/transform/utils/hoist_to_decl_before.h"
|
||||
#include "src/tint/type/reference.h"
|
||||
#include "src/tint/utils/map.h"
|
||||
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::DemoteToHelper);
|
||||
@@ -123,7 +123,7 @@ Transform::ApplyResult DemoteToHelper::Apply(const Program* src, const DataMap&,
|
||||
}
|
||||
|
||||
// Skip writes to invocation-private address spaces.
|
||||
auto* ref = sem.Get(assign->lhs)->Type()->As<sem::Reference>();
|
||||
auto* ref = sem.Get(assign->lhs)->Type()->As<type::Reference>();
|
||||
switch (ref->AddressSpace()) {
|
||||
case ast::AddressSpace::kStorage:
|
||||
// Need to mask these.
|
||||
|
||||
@@ -441,7 +441,7 @@ struct DirectVariableAccess::State {
|
||||
chain->root.variable = variable;
|
||||
chain->root.type = variable->Type();
|
||||
chain->root.address_space = variable->AddressSpace();
|
||||
if (auto* ptr = chain->root.type->As<sem::Pointer>()) {
|
||||
if (auto* ptr = chain->root.type->As<type::Pointer>()) {
|
||||
chain->root.address_space = ptr->AddressSpace();
|
||||
}
|
||||
access_chains.Add(expr, chain);
|
||||
@@ -456,13 +456,13 @@ struct DirectVariableAccess::State {
|
||||
}
|
||||
},
|
||||
[&](const ast::Parameter*) {
|
||||
if (variable->Type()->Is<sem::Pointer>()) {
|
||||
if (variable->Type()->Is<type::Pointer>()) {
|
||||
// Start a new access chain for the pointer parameter access
|
||||
create_new_chain();
|
||||
}
|
||||
},
|
||||
[&](const ast::Let*) {
|
||||
if (variable->Type()->Is<sem::Pointer>()) {
|
||||
if (variable->Type()->Is<type::Pointer>()) {
|
||||
// variable is a pointer-let.
|
||||
auto* init = sem.Get(variable->Declaration()->initializer);
|
||||
// Note: We do not use take_chain() here, as we need to preserve the
|
||||
@@ -637,7 +637,7 @@ struct DirectVariableAccess::State {
|
||||
for (size_t i = 0; i < call->Arguments().Length(); i++) {
|
||||
const auto* arg = call->Arguments()[i];
|
||||
const auto* param = target->Parameters()[i];
|
||||
const auto* param_ty = param->Type()->As<sem::Pointer>();
|
||||
const auto* param_ty = param->Type()->As<type::Pointer>();
|
||||
if (!param_ty) {
|
||||
continue; // Parameter type is not a pointer.
|
||||
}
|
||||
@@ -880,7 +880,7 @@ struct DirectVariableAccess::State {
|
||||
for (size_t arg_idx = 0; arg_idx < call->Arguments().Length(); arg_idx++) {
|
||||
auto* arg = call->Arguments()[arg_idx];
|
||||
auto* param = call->Target()->Parameters()[arg_idx];
|
||||
auto* param_ty = param->Type()->As<sem::Pointer>();
|
||||
auto* param_ty = param->Type()->As<type::Pointer>();
|
||||
if (!param_ty) {
|
||||
// Parameter is not a pointer.
|
||||
// Just clone the unaltered argument.
|
||||
@@ -1048,7 +1048,7 @@ struct DirectVariableAccess::State {
|
||||
|
||||
// BuildAccessExpr() always returns a non-pointer.
|
||||
// If the expression we're replacing is a pointer, take the address.
|
||||
if (expr->Type()->Is<sem::Pointer>()) {
|
||||
if (expr->Type()->Is<type::Pointer>()) {
|
||||
chain_expr = b.AddressOf(chain_expr);
|
||||
}
|
||||
|
||||
@@ -1123,7 +1123,7 @@ struct DirectVariableAccess::State {
|
||||
|
||||
const ast::Expression* expr = b.Expr(ctx.Clone(root.variable->Declaration()->symbol));
|
||||
if (deref) {
|
||||
if (root.variable->Type()->Is<sem::Pointer>()) {
|
||||
if (root.variable->Type()->Is<type::Pointer>()) {
|
||||
expr = b.Deref(expr);
|
||||
}
|
||||
}
|
||||
@@ -1164,7 +1164,7 @@ struct DirectVariableAccess::State {
|
||||
/// @returns true if the function @p fn has at least one pointer parameter.
|
||||
static bool HasPointerParameter(const sem::Function* fn) {
|
||||
for (auto* param : fn->Parameters()) {
|
||||
if (param->Type()->Is<sem::Pointer>()) {
|
||||
if (param->Type()->Is<type::Pointer>()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1176,7 +1176,7 @@ struct DirectVariableAccess::State {
|
||||
/// generated, and must be stripped.
|
||||
static bool MustBeCalled(const sem::Function* fn) {
|
||||
for (auto* param : fn->Parameters()) {
|
||||
if (auto* ptr = param->Type()->As<sem::Pointer>()) {
|
||||
if (auto* ptr = param->Type()->As<type::Pointer>()) {
|
||||
switch (ptr->AddressSpace()) {
|
||||
case ast::AddressSpace::kUniform:
|
||||
case ast::AddressSpace::kStorage:
|
||||
|
||||
@@ -22,10 +22,10 @@
|
||||
#include "src/tint/program_builder.h"
|
||||
#include "src/tint/sem/expression.h"
|
||||
#include "src/tint/sem/member_accessor_expression.h"
|
||||
#include "src/tint/sem/reference.h"
|
||||
#include "src/tint/sem/statement.h"
|
||||
#include "src/tint/sem/variable.h"
|
||||
#include "src/tint/transform/simplify_pointers.h"
|
||||
#include "src/tint/type/reference.h"
|
||||
#include "src/tint/utils/scoped_assignment.h"
|
||||
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::LocalizeStructArrayAssignment);
|
||||
@@ -183,9 +183,9 @@ struct LocalizeStructArrayAssignment::State {
|
||||
}
|
||||
|
||||
auto* type = root_ident->Type();
|
||||
if (auto* ref = type->As<sem::Reference>()) {
|
||||
if (auto* ref = type->As<type::Reference>()) {
|
||||
return {ref->StoreType(), ref->AddressSpace()};
|
||||
} else if (auto* ptr = type->As<sem::Pointer>()) {
|
||||
} else if (auto* ptr = type->As<type::Pointer>()) {
|
||||
return {ptr->StoreType(), ptr->AddressSpace()};
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ struct PackedVec3::State {
|
||||
[&](const sem::VariableUser* user) {
|
||||
auto* v = user->Variable();
|
||||
if (v->Declaration()->Is<ast::Let>() && // if variable is let...
|
||||
v->Type()->Is<sem::Pointer>() && // and let is a pointer...
|
||||
v->Type()->Is<type::Pointer>() && // and let is a pointer...
|
||||
refs.Contains(v->Initializer())) { // and pointer is to a packed vector...
|
||||
refs.Add(user); // then propagate tracking to pointer usage
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
#include <utility>
|
||||
|
||||
#include "src/tint/program_builder.h"
|
||||
#include "src/tint/sem/reference.h"
|
||||
#include "src/tint/sem/struct.h"
|
||||
#include "src/tint/type/reference.h"
|
||||
#include "src/tint/utils/map.h"
|
||||
#include "src/tint/utils/vector.h"
|
||||
|
||||
@@ -53,7 +53,7 @@ struct PreservePadding::State {
|
||||
// Ignore phony assignment.
|
||||
return;
|
||||
}
|
||||
if (ty->As<sem::Reference>()->AddressSpace() != ast::AddressSpace::kStorage) {
|
||||
if (ty->As<type::Reference>()->AddressSpace() != ast::AddressSpace::kStorage) {
|
||||
// We only care about assignments that write to variables in the storage
|
||||
// address space, as nothing else is host-visible.
|
||||
return;
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
#include "src/tint/sem/call.h"
|
||||
#include "src/tint/sem/expression.h"
|
||||
#include "src/tint/sem/index_accessor_expression.h"
|
||||
#include "src/tint/sem/reference.h"
|
||||
#include "src/tint/sem/statement.h"
|
||||
#include "src/tint/type/reference.h"
|
||||
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::Robustness);
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::Robustness::Config);
|
||||
@@ -70,7 +70,7 @@ struct Robustness::State {
|
||||
auto* sem = src->Sem().Get(expr)->UnwrapMaterialize()->As<sem::IndexAccessorExpression>();
|
||||
auto* ret_type = sem->Type();
|
||||
|
||||
auto* ref = ret_type->As<sem::Reference>();
|
||||
auto* ref = ret_type->As<type::Reference>();
|
||||
if (ref && omitted_address_spaces.count(ref->AddressSpace()) != 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ struct SimplifyPointers::State {
|
||||
auto* var = user->Variable();
|
||||
if (var->Is<sem::LocalVariable>() && //
|
||||
var->Declaration()->Is<ast::Let>() && //
|
||||
var->Type()->Is<sem::Pointer>()) {
|
||||
var->Type()->Is<type::Pointer>()) {
|
||||
op.expr = var->Declaration()->initializer;
|
||||
continue;
|
||||
}
|
||||
@@ -170,7 +170,7 @@ struct SimplifyPointers::State {
|
||||
}
|
||||
|
||||
auto* var = ctx.src->Sem().Get(let->variable);
|
||||
if (!var->Type()->Is<sem::Pointer>()) {
|
||||
if (!var->Type()->Is<type::Pointer>()) {
|
||||
continue; // Not a pointer type. Ignore.
|
||||
}
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
#include "src/tint/sem/function.h"
|
||||
#include "src/tint/sem/index_accessor_expression.h"
|
||||
#include "src/tint/sem/member_accessor_expression.h"
|
||||
#include "src/tint/sem/reference.h"
|
||||
#include "src/tint/sem/statement.h"
|
||||
#include "src/tint/type/reference.h"
|
||||
#include "src/tint/utils/map.h"
|
||||
#include "src/tint/utils/unique_vector.h"
|
||||
|
||||
@@ -218,11 +218,11 @@ struct SpirvAtomic::State {
|
||||
}
|
||||
return b.ty.array(AtomicTypeFor(arr->ElemType()), u32(count.value()));
|
||||
},
|
||||
[&](const sem::Pointer* ptr) {
|
||||
[&](const type::Pointer* ptr) {
|
||||
return b.ty.pointer(AtomicTypeFor(ptr->StoreType()), ptr->AddressSpace(),
|
||||
ptr->Access());
|
||||
},
|
||||
[&](const sem::Reference* ref) { return AtomicTypeFor(ref->StoreType()); },
|
||||
[&](const type::Reference* ref) { return AtomicTypeFor(ref->StoreType()); },
|
||||
[&](Default) {
|
||||
TINT_ICE(Transform, b.Diagnostics())
|
||||
<< "unhandled type: " << ty->FriendlyName(ctx.src->Symbols());
|
||||
@@ -233,7 +233,7 @@ struct SpirvAtomic::State {
|
||||
void ReplaceLoadsAndStores() {
|
||||
// Returns true if 'e' is a reference to an atomic variable or struct member
|
||||
auto is_ref_to_atomic_var = [&](const sem::Expression* e) {
|
||||
if (tint::Is<sem::Reference>(e->Type()) && e->RootIdentifier() &&
|
||||
if (tint::Is<type::Reference>(e->Type()) && e->RootIdentifier() &&
|
||||
(atomic_variables.count(e->RootIdentifier()) != 0)) {
|
||||
// If it's a struct member, make sure it's one we marked as atomic
|
||||
if (auto* ma = e->As<sem::StructMemberAccess>()) {
|
||||
|
||||
@@ -516,7 +516,7 @@ struct Std140::State {
|
||||
access.indices.Push(UniformVariable{});
|
||||
return Action::kStop;
|
||||
}
|
||||
if (user->Variable()->Type()->Is<sem::Pointer>()) {
|
||||
if (user->Variable()->Type()->Is<type::Pointer>()) {
|
||||
// Found a pointer. As the root identifier is a uniform buffer variable,
|
||||
// this must be a pointer-let. Continue traversing from the let
|
||||
// initializer.
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
#include "src/tint/sem/atomic.h"
|
||||
#include "src/tint/sem/block_statement.h"
|
||||
#include "src/tint/sem/for_loop_statement.h"
|
||||
#include "src/tint/sem/reference.h"
|
||||
#include "src/tint/sem/variable.h"
|
||||
#include "src/tint/type/depth_multisampled_texture.h"
|
||||
#include "src/tint/type/reference.h"
|
||||
#include "src/tint/type/sampler.h"
|
||||
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::Transform);
|
||||
@@ -139,7 +139,7 @@ const ast::Type* Transform::CreateASTTypeFor(CloneContext& ctx, const type::Type
|
||||
if (auto* s = ty->As<sem::Struct>()) {
|
||||
return ctx.dst->create<ast::TypeName>(ctx.Clone(s->Declaration()->name));
|
||||
}
|
||||
if (auto* s = ty->As<sem::Reference>()) {
|
||||
if (auto* s = ty->As<type::Reference>()) {
|
||||
return CreateASTTypeFor(ctx, s->StoreType());
|
||||
}
|
||||
if (auto* a = ty->As<sem::Atomic>()) {
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
#include "src/tint/sem/block_statement.h"
|
||||
#include "src/tint/sem/for_loop_statement.h"
|
||||
#include "src/tint/sem/if_statement.h"
|
||||
#include "src/tint/sem/reference.h"
|
||||
#include "src/tint/sem/variable.h"
|
||||
#include "src/tint/sem/while_statement.h"
|
||||
#include "src/tint/type/reference.h"
|
||||
#include "src/tint/utils/hashmap.h"
|
||||
#include "src/tint/utils/reverse.h"
|
||||
#include "src/tint/utils/transform.h"
|
||||
|
||||
Reference in New Issue
Block a user