[tint] Rename pointer builders to 'ptr', match WGSL order
Rename ProgramBuilder::TypesBuilder::pointer() to ptr()
Rename type::Manager::pointer() to ptr()
Reorder parameters for these, the SPIR-V reader types and the type
constructors to be: [address-space, storage type, access-control]
to match WGSL.
Change-Id: I8644d6b7a0c56669cf18d111d530773e2dbf56a5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/137060
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
diff --git a/src/tint/ast/transform/builtin_polyfill.cc b/src/tint/ast/transform/builtin_polyfill.cc
index c578631..05f5da9 100644
--- a/src/tint/ast/transform/builtin_polyfill.cc
+++ b/src/tint/ast/transform/builtin_polyfill.cc
@@ -814,7 +814,7 @@
auto name = b.Symbols().New("tint_workgroupUniformLoad");
b.Func(name,
utils::Vector{
- b.Param("p", b.ty.pointer(T(type), builtin::AddressSpace::kWorkgroup)),
+ b.Param("p", b.ty.ptr(builtin::AddressSpace::kWorkgroup, T(type))),
},
T(type),
utils::Vector{
diff --git a/src/tint/ast/transform/calculate_array_length.cc b/src/tint/ast/transform/calculate_array_length.cc
index 59f684a..0e11ad4 100644
--- a/src/tint/ast/transform/calculate_array_length.cc
+++ b/src/tint/ast/transform/calculate_array_length.cc
@@ -107,18 +107,17 @@
auto name = b.Sym();
auto type = CreateASTTypeFor(ctx, buffer_type);
auto* disable_validation = b.Disable(DisabledValidation::kFunctionParameter);
- b.Func(
- name,
- utils::Vector{
- b.Param("buffer",
- b.ty.pointer(type, buffer_type->AddressSpace(), buffer_type->Access()),
- utils::Vector{disable_validation}),
- b.Param("result", b.ty.pointer(b.ty.u32(), builtin::AddressSpace::kFunction)),
- },
- b.ty.void_(), nullptr,
- utils::Vector{
- b.ASTNodes().Create<BufferSizeIntrinsic>(b.ID(), b.AllocateNodeID()),
- });
+ b.Func(name,
+ utils::Vector{
+ b.Param("buffer",
+ b.ty.ptr(buffer_type->AddressSpace(), type, buffer_type->Access()),
+ utils::Vector{disable_validation}),
+ b.Param("result", b.ty.ptr(builtin::AddressSpace::kFunction, b.ty.u32())),
+ },
+ b.ty.void_(), nullptr,
+ utils::Vector{
+ b.ASTNodes().Create<BufferSizeIntrinsic>(b.ID(), b.AllocateNodeID()),
+ });
return name;
});
diff --git a/src/tint/ast/transform/direct_variable_access.cc b/src/tint/ast/transform/direct_variable_access.cc
index f4160d4..3267ae2 100644
--- a/src/tint/ast/transform/direct_variable_access.cc
+++ b/src/tint/ast/transform/direct_variable_access.cc
@@ -832,8 +832,8 @@
auto& symbols = *variant.ptr_param_symbols.Find(param);
if (symbols.base_ptr.IsValid()) {
auto base_ptr_ty =
- b.ty.pointer(CreateASTTypeFor(ctx, incoming_shape->root.type),
- incoming_shape->root.address_space);
+ b.ty.ptr(incoming_shape->root.address_space,
+ CreateASTTypeFor(ctx, incoming_shape->root.type));
params.Push(b.Param(symbols.base_ptr, base_ptr_ty));
}
if (symbols.indices.IsValid()) {
diff --git a/src/tint/ast/transform/module_scope_var_to_entry_point_param.cc b/src/tint/ast/transform/module_scope_var_to_entry_point_param.cc
index 16257ba..db06414 100644
--- a/src/tint/ast/transform/module_scope_var_to_entry_point_param.cc
+++ b/src/tint/ast/transform/module_scope_var_to_entry_point_param.cc
@@ -160,8 +160,8 @@
}
param_type = sc == builtin::AddressSpace::kStorage
- ? ctx.dst->ty.pointer(param_type, sc, var->Access())
- : ctx.dst->ty.pointer(param_type, sc);
+ ? ctx.dst->ty.ptr(sc, param_type, var->Access())
+ : ctx.dst->ty.ptr(sc, param_type);
auto* param = ctx.dst->Param(new_var_symbol, param_type, attributes);
ctx.InsertFront(func->params, param);
is_pointer = true;
@@ -184,7 +184,7 @@
ctx.dst->MemberAccessor(ctx.dst->Deref(workgroup_param()), member));
auto* local_var = ctx.dst->Let(
new_var_symbol,
- ctx.dst->ty.pointer(store_type(), builtin::AddressSpace::kWorkgroup),
+ ctx.dst->ty.ptr(builtin::AddressSpace::kWorkgroup, store_type()),
member_ptr);
ctx.InsertFront(func->body->statements, ctx.dst->Decl(local_var));
is_pointer = true;
@@ -250,8 +250,8 @@
utils::Vector<const Attribute*, 2> attributes;
if (!ty->is_handle()) {
param_type = sc == builtin::AddressSpace::kStorage
- ? ctx.dst->ty.pointer(param_type, sc, var->Access())
- : ctx.dst->ty.pointer(param_type, sc);
+ ? ctx.dst->ty.ptr(sc, param_type, var->Access())
+ : ctx.dst->ty.ptr(sc, param_type);
is_pointer = true;
// Disable validation of the parameter's address space and of arguments passed to it.
@@ -427,8 +427,8 @@
}
} else {
// Create a parameter that is a pointer to the private variable struct.
- auto ptr = ctx.dst->ty.pointer(ctx.dst->ty(PrivateStructName()),
- builtin::AddressSpace::kPrivate);
+ auto ptr = ctx.dst->ty.ptr(builtin::AddressSpace::kPrivate,
+ ctx.dst->ty(PrivateStructName()));
auto* param = ctx.dst->Param(PrivateStructVariableName(), ptr);
ctx.InsertBack(func_ast->params, param);
}
@@ -490,7 +490,7 @@
auto* str =
ctx.dst->Structure(ctx.dst->Sym(), std::move(workgroup_parameter_members));
auto param_type =
- ctx.dst->ty.pointer(ctx.dst->ty.Of(str), builtin::AddressSpace::kWorkgroup);
+ ctx.dst->ty.ptr(builtin::AddressSpace::kWorkgroup, ctx.dst->ty.Of(str));
auto* param =
ctx.dst->Param(workgroup_param(), param_type,
utils::Vector{
diff --git a/src/tint/ast/transform/packed_vec3.cc b/src/tint/ast/transform/packed_vec3.cc
index 30f3e1c..62f82d2 100644
--- a/src/tint/ast/transform/packed_vec3.cc
+++ b/src/tint/ast/transform/packed_vec3.cc
@@ -382,7 +382,7 @@
? ptr->Access()
: builtin::Access::kUndefined;
auto new_ptr_type =
- b.ty.pointer(new_store_type, ptr->AddressSpace(), access);
+ b.ty.ptr(ptr->AddressSpace(), new_store_type, access);
ctx.Replace(node, new_ptr_type.expr);
}
}
diff --git a/src/tint/ast/transform/preserve_padding.cc b/src/tint/ast/transform/preserve_padding.cc
index ee266a7..7d9143c 100644
--- a/src/tint/ast/transform/preserve_padding.cc
+++ b/src/tint/ast/transform/preserve_padding.cc
@@ -122,8 +122,8 @@
auto helper_name = b.Symbols().New("assign_and_preserve_padding");
utils::Vector<const Parameter*, 2> params = {
b.Param(kDestParamName,
- b.ty.pointer(CreateASTTypeFor(ctx, ty), builtin::AddressSpace::kStorage,
- builtin::Access::kReadWrite)),
+ b.ty.ptr(builtin::AddressSpace::kStorage, CreateASTTypeFor(ctx, ty),
+ builtin::Access::kReadWrite)),
b.Param(kValueParamName, CreateASTTypeFor(ctx, ty)),
};
b.Func(helper_name, params, b.ty.void_(), body());
diff --git a/src/tint/ast/transform/spirv_atomic.cc b/src/tint/ast/transform/spirv_atomic.cc
index aff4a7c..3ee89f2 100644
--- a/src/tint/ast/transform/spirv_atomic.cc
+++ b/src/tint/ast/transform/spirv_atomic.cc
@@ -215,8 +215,8 @@
return b.ty.array(AtomicTypeFor(arr->ElemType()), u32(count.value()));
},
[&](const type::Pointer* ptr) {
- return b.ty.pointer(AtomicTypeFor(ptr->StoreType()), ptr->AddressSpace(),
- ptr->Access());
+ return b.ty.ptr(ptr->AddressSpace(), AtomicTypeFor(ptr->StoreType()),
+ ptr->Access());
},
[&](const type::Reference* ref) { return AtomicTypeFor(ref->StoreType()); },
[&](Default) {
diff --git a/src/tint/ast/transform/transform.cc b/src/tint/ast/transform/transform.cc
index bee1f39..6a9eebc 100644
--- a/src/tint/ast/transform/transform.cc
+++ b/src/tint/ast/transform/transform.cc
@@ -169,7 +169,7 @@
auto access = address_space == builtin::AddressSpace::kStorage
? p->Access()
: builtin::Access::kUndefined;
- return ctx.dst->ty.pointer(CreateASTTypeFor(ctx, p->StoreType()), address_space, access);
+ return ctx.dst->ty.ptr(address_space, CreateASTTypeFor(ctx, p->StoreType()), access);
}
TINT_UNREACHABLE(Transform, ctx.dst->Diagnostics())
<< "Unhandled type: " << ty->TypeInfo().name;
diff --git a/src/tint/ast/transform/transform_test.cc b/src/tint/ast/transform/transform_test.cc
index c61a321..8f86596 100644
--- a/src/tint/ast/transform/transform_test.cc
+++ b/src/tint/ast/transform/transform_test.cc
@@ -127,7 +127,7 @@
TEST_F(CreateASTTypeForTest, PrivatePointer) {
auto ptr = create([](ProgramBuilder& b) {
- return b.create<type::Pointer>(b.create<type::I32>(), builtin::AddressSpace::kPrivate,
+ return b.create<type::Pointer>(builtin::AddressSpace::kPrivate, b.create<type::I32>(),
builtin::Access::kReadWrite);
});
@@ -136,7 +136,7 @@
TEST_F(CreateASTTypeForTest, StorageReadWritePointer) {
auto ptr = create([](ProgramBuilder& b) {
- return b.create<type::Pointer>(b.create<type::I32>(), builtin::AddressSpace::kStorage,
+ return b.create<type::Pointer>(builtin::AddressSpace::kStorage, b.create<type::I32>(),
builtin::Access::kReadWrite);
});
diff --git a/src/tint/ir/from_program.cc b/src/tint/ir/from_program.cc
index 3a4539e..8ffa513 100644
--- a/src/tint/ir/from_program.cc
+++ b/src/tint/ir/from_program.cc
@@ -950,7 +950,7 @@
const type::Type* ty = nullptr;
if (auto* ptr = info.object->Type()->As<type::Pointer>();
ptr && !info.result_type->Is<type::Pointer>()) {
- ty = builder_.ir.Types().pointer(info.result_type, ptr->AddressSpace(), ptr->Access());
+ ty = builder_.ir.Types().ptr(ptr->AddressSpace(), info.result_type, ptr->Access());
} else {
ty = info.result_type;
}
@@ -1078,7 +1078,7 @@
[&](const ast::Var* v) {
auto* ref = sem->Type()->As<type::Reference>();
auto* ty = builder_.ir.Types().Get<type::Pointer>(
- ref->StoreType()->Clone(clone_ctx_.type_ctx), ref->AddressSpace(),
+ ref->AddressSpace(), ref->StoreType()->Clone(clone_ctx_.type_ctx),
ref->Access());
auto* val = builder_.Var(ty);
diff --git a/src/tint/ir/load_test.cc b/src/tint/ir/load_test.cc
index 1430e11..0cfba85 100644
--- a/src/tint/ir/load_test.cc
+++ b/src/tint/ir/load_test.cc
@@ -26,9 +26,9 @@
using IR_LoadTest = IRTestHelper;
TEST_F(IR_LoadTest, Create) {
- auto* store_type = mod.Types().i32();
- auto* var = b.Var(mod.Types().pointer(store_type, builtin::AddressSpace::kFunction,
- builtin::Access::kReadWrite));
+ auto* store_type = ty.i32();
+ auto* var =
+ b.Var(ty.ptr(builtin::AddressSpace::kFunction, store_type, builtin::Access::kReadWrite));
auto* inst = b.Load(var);
ASSERT_TRUE(inst->Is<Load>());
@@ -41,9 +41,9 @@
}
TEST_F(IR_LoadTest, Usage) {
- auto* store_type = mod.Types().i32();
- auto* var = b.Var(mod.Types().pointer(store_type, builtin::AddressSpace::kFunction,
- builtin::Access::kReadWrite));
+ auto* store_type = ty.i32();
+ auto* var =
+ b.Var(ty.ptr(builtin::AddressSpace::kFunction, store_type, builtin::Access::kReadWrite));
auto* inst = b.Load(var);
ASSERT_NE(inst->From(), nullptr);
diff --git a/src/tint/ir/module_test.cc b/src/tint/ir/module_test.cc
index 457042c..61cd5d4 100644
--- a/src/tint/ir/module_test.cc
+++ b/src/tint/ir/module_test.cc
@@ -24,7 +24,7 @@
class IR_ModuleTest : public IRTestHelper {
protected:
const type::Pointer* ptr(const type::Type* elem) {
- return ty.pointer(elem, builtin::AddressSpace::kFunction, builtin::Access::kReadWrite);
+ return ty.ptr(builtin::AddressSpace::kFunction, elem, builtin::Access::kReadWrite);
}
};
diff --git a/src/tint/ir/store_test.cc b/src/tint/ir/store_test.cc
index b257dac..5578005 100644
--- a/src/tint/ir/store_test.cc
+++ b/src/tint/ir/store_test.cc
@@ -26,8 +26,8 @@
using IR_StoreTest = IRTestHelper;
TEST_F(IR_StoreTest, CreateStore) {
- auto* to = b.Var(mod.Types().pointer(mod.Types().i32(), builtin::AddressSpace::kPrivate,
- builtin::Access::kReadWrite));
+ auto* to = b.Var(mod.Types().ptr(builtin::AddressSpace::kPrivate, mod.Types().i32(),
+ builtin::Access::kReadWrite));
auto* inst = b.Store(to, 4_i);
ASSERT_TRUE(inst->Is<Store>());
@@ -65,8 +65,8 @@
{
Module mod;
Builder b{mod};
- auto* to = b.Var(mod.Types().pointer(mod.Types().i32(), builtin::AddressSpace::kPrivate,
- builtin::Access::kReadWrite));
+ auto* to = b.Var(mod.Types().ptr(builtin::AddressSpace::kPrivate, mod.Types().i32(),
+ builtin::Access::kReadWrite));
b.Store(to, nullptr);
},
"");
diff --git a/src/tint/ir/to_program.cc b/src/tint/ir/to_program.cc
index e3a85f1..c536ae6 100644
--- a/src/tint/ir/to_program.cc
+++ b/src/tint/ir/to_program.cc
@@ -538,7 +538,7 @@
auto access = address_space == builtin::AddressSpace::kStorage
? p->Access()
: builtin::Access::kUndefined;
- return b.ty.pointer(el, address_space, access);
+ return b.ty.ptr(address_space, el, access);
},
[&](const type::Reference*) {
TINT_ICE(IR, b.Diagnostics()) << "reference types should never appear in the IR";
diff --git a/src/tint/ir/transform/block_decorated_structs.cc b/src/tint/ir/transform/block_decorated_structs.cc
index 618d624..5c466a5 100644
--- a/src/tint/ir/transform/block_decorated_structs.cc
+++ b/src/tint/ir/transform/block_decorated_structs.cc
@@ -93,7 +93,7 @@
// Replace the old variable declaration with one that uses the block-decorated struct type.
auto* new_var =
- builder.Var(ir->Types().pointer(block_struct, ptr->AddressSpace(), ptr->Access()));
+ builder.Var(ir->Types().ptr(ptr->AddressSpace(), block_struct, ptr->Access()));
new_var->SetBindingPoint(var->BindingPoint()->group, var->BindingPoint()->binding);
var->ReplaceWith(new_var);
diff --git a/src/tint/ir/transform/block_decorated_structs_test.cc b/src/tint/ir/transform/block_decorated_structs_test.cc
index 7aa010e..e86c563 100644
--- a/src/tint/ir/transform/block_decorated_structs_test.cc
+++ b/src/tint/ir/transform/block_decorated_structs_test.cc
@@ -116,8 +116,7 @@
}
TEST_F(IR_BlockDecoratedStructsTest, RuntimeArray) {
- auto* buffer =
- b.Var(ty.pointer(ty.runtime_array(ty.i32()), storage, builtin::Access::kReadWrite));
+ auto* buffer = b.Var(ty.ptr(storage, ty.runtime_array(ty.i32()), builtin::Access::kReadWrite));
buffer->SetBindingPoint(0, 0);
b.RootBlock()->Append(buffer);
@@ -161,7 +160,7 @@
4u, 4u, type::StructMemberAttributes{}));
auto* structure = ty.Get<type::Struct>(mod.symbols.New(), members, 4u, 8u, 8u);
- auto* buffer = b.Var(ty.pointer(structure, storage, builtin::Access::kReadWrite));
+ auto* buffer = b.Var(ty.ptr(storage, structure, builtin::Access::kReadWrite));
buffer->SetBindingPoint(0, 0);
b.RootBlock()->Append(buffer);
@@ -216,12 +215,12 @@
type::StructMemberAttributes{}));
auto* structure = ty.Get<type::Struct>(mod.symbols.New(), members, 4u, 8u, 8u);
- auto* buffer = b.Var(ty.pointer(structure, storage, builtin::Access::kReadWrite));
+ auto* buffer = b.Var(ty.ptr(storage, structure, builtin::Access::kReadWrite));
buffer->SetBindingPoint(0, 0);
b.RootBlock()->Append(buffer);
auto* private_var =
- b.Var(ty.pointer(structure, builtin::AddressSpace::kPrivate, builtin::Access::kReadWrite));
+ b.Var(ty.ptr(builtin::AddressSpace::kPrivate, structure, builtin::Access::kReadWrite));
b.RootBlock()->Append(private_var);
auto* func = b.Function("foo", ty.void_());
diff --git a/src/tint/ir/transform/var_for_dynamic_index.cc b/src/tint/ir/transform/var_for_dynamic_index.cc
index 11f521d..b72dc34 100644
--- a/src/tint/ir/transform/var_for_dynamic_index.cc
+++ b/src/tint/ir/transform/var_for_dynamic_index.cc
@@ -131,9 +131,9 @@
// Declare a local variable and copy the source object to it.
auto* local = object_to_local.GetOrCreate(source_object, [&]() {
- auto* decl = builder.Var(ir->Types().pointer(source_object->Type(),
- builtin::AddressSpace::kFunction,
- builtin::Access::kReadWrite));
+ auto* decl =
+ builder.Var(ir->Types().ptr(builtin::AddressSpace::kFunction, source_object->Type(),
+ builtin::Access::kReadWrite));
decl->SetInitializer(source_object);
decl->InsertBefore(access);
return decl;
@@ -142,8 +142,8 @@
// Create a new access instruction using the local variable as the source.
utils::Vector<Value*, 4> indices{access->Indices().Offset(to_replace.first_dynamic_index)};
auto* new_access =
- builder.Access(ir->Types().pointer(access->Type(), builtin::AddressSpace::kFunction,
- builtin::Access::kReadWrite),
+ builder.Access(ir->Types().ptr(builtin::AddressSpace::kFunction, access->Type(),
+ builtin::Access::kReadWrite),
local, indices);
access->ReplaceWith(new_access);
diff --git a/src/tint/ir/transform/var_for_dynamic_index_test.cc b/src/tint/ir/transform/var_for_dynamic_index_test.cc
index 8ee56bb..6b64025 100644
--- a/src/tint/ir/transform/var_for_dynamic_index_test.cc
+++ b/src/tint/ir/transform/var_for_dynamic_index_test.cc
@@ -29,7 +29,7 @@
class IR_VarForDynamicIndexTest : public TransformTest {
protected:
const type::Type* ptr(const type::Type* elem) {
- return ty.pointer(elem, builtin::AddressSpace::kFunction, builtin::Access::kReadWrite);
+ return ty.ptr(builtin::AddressSpace::kFunction, elem, builtin::Access::kReadWrite);
}
};
diff --git a/src/tint/ir/validate_test.cc b/src/tint/ir/validate_test.cc
index a89c1f2..d2f07d0 100644
--- a/src/tint/ir/validate_test.cc
+++ b/src/tint/ir/validate_test.cc
@@ -32,7 +32,7 @@
TEST_F(IR_ValidateTest, RootBlock_Var) {
mod.root_block = b.RootBlock();
mod.root_block->Append(
- b.Var(ty.pointer(ty.i32(), builtin::AddressSpace::kPrivate, builtin::Access::kReadWrite)));
+ b.Var(ty.ptr(builtin::AddressSpace::kPrivate, ty.i32(), builtin::Access::kReadWrite)));
auto res = ir::Validate(mod);
EXPECT_TRUE(res) << res.Failure().str();
}
@@ -112,7 +112,7 @@
TEST_F(IR_ValidateTest, Valid_Access_Ptr) {
auto* f = b.Function("my_func", ty.void_());
auto* obj = b.FunctionParam(
- ty.pointer(ty.mat3x2<f32>(), builtin::AddressSpace::kPrivate, builtin::Access::kReadWrite));
+ ty.ptr(builtin::AddressSpace::kPrivate, ty.mat3x2<f32>(), builtin::Access::kReadWrite));
f->SetParams({obj});
mod.functions.Push(f);
@@ -188,7 +188,7 @@
TEST_F(IR_ValidateTest, Access_OOB_Index_Ptr) {
auto* f = b.Function("my_func", ty.void_());
auto* obj = b.FunctionParam(
- ty.pointer(ty.mat3x2<f32>(), builtin::AddressSpace::kPrivate, builtin::Access::kReadWrite));
+ ty.ptr(builtin::AddressSpace::kPrivate, ty.mat3x2<f32>(), builtin::Access::kReadWrite));
f->SetParams({obj});
mod.functions.Push(f);
@@ -333,7 +333,7 @@
auto* f = b.Function("my_func", ty.void_());
auto* obj = b.FunctionParam(
- ty.pointer(str_ty, builtin::AddressSpace::kPrivate, builtin::Access::kReadWrite));
+ ty.ptr(builtin::AddressSpace::kPrivate, str_ty, builtin::Access::kReadWrite));
auto* idx = b.FunctionParam(ty.i32());
f->SetParams({obj, idx});
mod.functions.Push(f);
@@ -400,7 +400,7 @@
TEST_F(IR_ValidateTest, Access_Incorrect_Type_Ptr_Ptr) {
auto* f = b.Function("my_func", ty.void_());
auto* obj = b.FunctionParam(
- ty.pointer(ty.mat3x2<f32>(), builtin::AddressSpace::kPrivate, builtin::Access::kReadWrite));
+ ty.ptr(builtin::AddressSpace::kPrivate, ty.mat3x2<f32>(), builtin::Access::kReadWrite));
f->SetParams({obj});
mod.functions.Push(f);
@@ -432,7 +432,7 @@
TEST_F(IR_ValidateTest, Access_Incorrect_Type_Ptr_Value) {
auto* f = b.Function("my_func", ty.void_());
auto* obj = b.FunctionParam(
- ty.pointer(ty.mat3x2<f32>(), builtin::AddressSpace::kPrivate, builtin::Access::kReadWrite));
+ ty.ptr(builtin::AddressSpace::kPrivate, ty.mat3x2<f32>(), builtin::Access::kReadWrite));
f->SetParams({obj});
mod.functions.Push(f);
diff --git a/src/tint/program_builder.h b/src/tint/program_builder.h
index 2a79cb9..52a73b3 100644
--- a/src/tint/program_builder.h
+++ b/src/tint/program_builder.h
@@ -1124,25 +1124,25 @@
type);
}
- /// @param type the type of the pointer
/// @param address_space the address space of the pointer
+ /// @param type the type of the pointer
/// @param access the optional access control of the pointer
/// @return the pointer to `type` with the given builtin::AddressSpace
- ast::Type pointer(ast::Type type,
- builtin::AddressSpace address_space,
- builtin::Access access = builtin::Access::kUndefined) const {
- return pointer(builder->source_, type, address_space, access);
+ ast::Type ptr(builtin::AddressSpace address_space,
+ ast::Type type,
+ builtin::Access access = builtin::Access::kUndefined) const {
+ return ptr(builder->source_, address_space, type, access);
}
/// @param source the Source of the node
- /// @param type the type of the pointer
/// @param address_space the address space of the pointer
+ /// @param type the type of the pointer
/// @param access the optional access control of the pointer
/// @return the pointer to `type` with the given builtin::AddressSpace
- ast::Type pointer(const Source& source,
- ast::Type type,
- builtin::AddressSpace address_space,
- builtin::Access access = builtin::Access::kUndefined) const {
+ ast::Type ptr(const Source& source,
+ builtin::AddressSpace address_space,
+ ast::Type type,
+ builtin::Access access = builtin::Access::kUndefined) const {
if (access != builtin::Access::kUndefined) {
return (*this)(source, "ptr", address_space, type, access);
} else {
@@ -1154,9 +1154,9 @@
/// @param access the optional access control of the pointer
/// @return the pointer to type `T` with the given builtin::AddressSpace.
template <typename T>
- ast::Type pointer(builtin::AddressSpace address_space,
- builtin::Access access = builtin::Access::kUndefined) const {
- return pointer<T>(builder->source_, address_space, access);
+ ast::Type ptr(builtin::AddressSpace address_space,
+ builtin::Access access = builtin::Access::kUndefined) const {
+ return ptr<T>(builder->source_, address_space, access);
}
/// @param source the Source of the node
@@ -1164,9 +1164,9 @@
/// @param access the optional access control of the pointer
/// @return the pointer to type `T` with the given builtin::AddressSpace.
template <typename T>
- ast::Type pointer(const Source& source,
- builtin::AddressSpace address_space,
- builtin::Access access = builtin::Access::kUndefined) const {
+ ast::Type ptr(const Source& source,
+ builtin::AddressSpace address_space,
+ builtin::Access access = builtin::Access::kUndefined) const {
if (access != builtin::Access::kUndefined) {
return (*this)(source, "ptr", address_space, Of<T>(), access);
} else {
diff --git a/src/tint/reader/spirv/function.cc b/src/tint/reader/spirv/function.cc
index d0268c6..c78b9a0 100644
--- a/src/tint/reader/spirv/function.cc
+++ b/src/tint/reader/spirv/function.cc
@@ -2512,7 +2512,7 @@
Attributes{});
auto* var_decl_stmt = create<ast::VariableDeclStatement>(Source{}, var);
AddStatement(var_decl_stmt);
- auto* var_type = ty_.Reference(var_store_type, builtin::AddressSpace::kUndefined);
+ auto* var_type = ty_.Reference(builtin::AddressSpace::kUndefined, var_store_type);
identifier_types_.emplace(inst.result_id(), var_type);
}
return success();
@@ -3358,7 +3358,7 @@
Source{},
parser_impl_.MakeVar(id, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined,
store_type, nullptr, Attributes{})));
- auto* type = ty_.Reference(store_type, builtin::AddressSpace::kUndefined);
+ auto* type = ty_.Reference(builtin::AddressSpace::kUndefined, store_type);
identifier_types_.emplace(id, type);
}
@@ -4892,11 +4892,11 @@
const Type* FunctionEmitter::RemapPointerProperties(const Type* type, uint32_t result_id) {
if (auto* ast_ptr_type = As<Pointer>(type)) {
const auto pi = GetPointerInfo(result_id);
- return ty_.Pointer(ast_ptr_type->type, pi.address_space, pi.access);
+ return ty_.Pointer(pi.address_space, ast_ptr_type->type, pi.access);
}
if (auto* ast_ptr_type = As<Reference>(type)) {
const auto pi = GetPointerInfo(result_id);
- return ty_.Reference(ast_ptr_type->type, pi.address_space, pi.access);
+ return ty_.Reference(pi.address_space, ast_ptr_type->type, pi.access);
}
return type;
}
@@ -6338,7 +6338,7 @@
return {};
}
return {
- ty_.Pointer(ref->type, ref->address_space),
+ ty_.Pointer(ref->address_space, ref->type),
create<ast::UnaryOpExpression>(Source{}, ast::UnaryOp::kAddressOf, expr.expr),
};
}
diff --git a/src/tint/reader/spirv/parser_impl.cc b/src/tint/reader/spirv/parser_impl.cc
index fa9572a..7a3089d 100644
--- a/src/tint/reader/spirv/parser_impl.cc
+++ b/src/tint/reader/spirv/parser_impl.cc
@@ -1226,9 +1226,9 @@
}
switch (ptr_as) {
case PtrAs::Ref:
- return ty_.Reference(ast_elem_ty, ast_address_space);
+ return ty_.Reference(ast_address_space, ast_elem_ty);
case PtrAs::Ptr:
- return ty_.Pointer(ast_elem_ty, ast_address_space);
+ return ty_.Pointer(ast_address_space, ast_elem_ty);
}
Fail() << "invalid value for ptr_as: " << static_cast<int>(ptr_as);
return nullptr;
diff --git a/src/tint/reader/spirv/parser_type.cc b/src/tint/reader/spirv/parser_type.cc
index 5abd739..8ace8a0 100644
--- a/src/tint/reader/spirv/parser_type.cc
+++ b/src/tint/reader/spirv/parser_type.cc
@@ -55,13 +55,13 @@
namespace {
struct PointerHasher {
size_t operator()(const Pointer& t) const {
- return utils::Hash(t.type, t.address_space, t.access);
+ return utils::Hash(t.address_space, t.type, t.access);
}
};
struct ReferenceHasher {
size_t operator()(const Reference& t) const {
- return utils::Hash(t.type, t.address_space, t.access);
+ return utils::Hash(t.address_space, t.type, t.access);
}
};
@@ -178,8 +178,8 @@
Texture::~Texture() = default;
-Pointer::Pointer(const Type* t, builtin::AddressSpace s, builtin::Access a)
- : type(t), address_space(s), access(a) {}
+Pointer::Pointer(builtin::AddressSpace s, const Type* t, builtin::Access a)
+ : address_space(s), type(t), access(a) {}
Pointer::Pointer(const Pointer&) = default;
ast::Type Pointer::Build(ProgramBuilder& b) const {
@@ -189,11 +189,11 @@
// types.
return b.ty("invalid_spirv_ptr_type");
}
- return b.ty.pointer(type->Build(b), address_space, access);
+ return b.ty.ptr(address_space, type->Build(b), access);
}
-Reference::Reference(const Type* t, builtin::AddressSpace s, builtin::Access a)
- : type(t), address_space(s), access(a) {}
+Reference::Reference(builtin::AddressSpace s, const Type* t, builtin::Access a)
+ : address_space(s), type(t), access(a) {}
Reference::Reference(const Reference&) = default;
ast::Type Reference::Build(ProgramBuilder& b) const {
@@ -487,16 +487,16 @@
});
}
-const spirv::Pointer* TypeManager::Pointer(const Type* el,
- builtin::AddressSpace address_space,
+const spirv::Pointer* TypeManager::Pointer(builtin::AddressSpace address_space,
+ const Type* el,
builtin::Access access) {
- return state->pointers_.Get(el, address_space, access);
+ return state->pointers_.Get(address_space, el, access);
}
-const spirv::Reference* TypeManager::Reference(const Type* el,
- builtin::AddressSpace address_space,
+const spirv::Reference* TypeManager::Reference(builtin::AddressSpace address_space,
+ const Type* el,
builtin::Access access) {
- return state->references_.Get(el, address_space, access);
+ return state->references_.Get(address_space, el, access);
}
const spirv::Vector* TypeManager::Vector(const Type* el, uint32_t size) {
diff --git a/src/tint/reader/spirv/parser_type.h b/src/tint/reader/spirv/parser_type.h
index d3295ee..e47646b 100644
--- a/src/tint/reader/spirv/parser_type.h
+++ b/src/tint/reader/spirv/parser_type.h
@@ -159,10 +159,10 @@
/// `ptr<SC, T, AM>` type
struct Pointer final : public utils::Castable<Pointer, Type> {
/// Constructor
- /// @param ty the store type
/// @param sc the pointer address space
+ /// @param ty the store type
/// @param access the declared access mode
- Pointer(const Type* ty, builtin::AddressSpace sc, builtin::Access access);
+ Pointer(builtin::AddressSpace sc, const Type* ty, builtin::Access access);
/// Copy constructor
/// @param other the other type to copy
@@ -177,10 +177,10 @@
std::string String() const override;
#endif // NDEBUG
- /// the store type
- Type const* const type;
/// the pointer address space
builtin::AddressSpace const address_space;
+ /// the store type
+ Type const* const type;
/// the pointer declared access mode
builtin::Access const access;
};
@@ -190,10 +190,10 @@
/// reader.
struct Reference final : public utils::Castable<Reference, Type> {
/// Constructor
- /// @param ty the referenced type
/// @param sc the reference address space
+ /// @param ty the referenced type
/// @param access the reference declared access mode
- Reference(const Type* ty, builtin::AddressSpace sc, builtin::Access access);
+ Reference(builtin::AddressSpace sc, const Type* ty, builtin::Access access);
/// Copy constructor
/// @param other the other type to copy
@@ -208,10 +208,10 @@
std::string String() const override;
#endif // NDEBUG
- /// the store type
- Type const* const type;
/// the pointer address space
builtin::AddressSpace const address_space;
+ /// the store type
+ Type const* const type;
/// the pointer declared access mode
builtin::Access const access;
};
@@ -543,21 +543,21 @@
/// otherwise nullptr.
const Type* AsUnsigned(const Type* ty);
- /// @param ty the store type
/// @param address_space the pointer address space
+ /// @param ty the store type
/// @param access the declared access mode
/// @return a Pointer type. Repeated calls with the same arguments will return
/// the same pointer.
- const spirv::Pointer* Pointer(const Type* ty,
- builtin::AddressSpace address_space,
+ const spirv::Pointer* Pointer(builtin::AddressSpace address_space,
+ const Type* ty,
builtin::Access access = builtin::Access::kUndefined);
- /// @param ty the referenced type
/// @param address_space the reference address space
+ /// @param ty the referenced type
/// @param access the declared access mode
/// @return a Reference type. Repeated calls with the same arguments will
/// return the same pointer.
- const spirv::Reference* Reference(const Type* ty,
- builtin::AddressSpace address_space,
+ const spirv::Reference* Reference(builtin::AddressSpace address_space,
+ const Type* ty,
builtin::Access access = builtin::Access::kUndefined);
/// @param ty the element type
/// @param sz the number of elements in the vector
diff --git a/src/tint/reader/spirv/parser_type_test.cc b/src/tint/reader/spirv/parser_type_test.cc
index f864818..9ebb047 100644
--- a/src/tint/reader/spirv/parser_type_test.cc
+++ b/src/tint/reader/spirv/parser_type_test.cc
@@ -29,8 +29,8 @@
EXPECT_EQ(ty.U32(), ty.U32());
EXPECT_EQ(ty.F32(), ty.F32());
EXPECT_EQ(ty.I32(), ty.I32());
- EXPECT_EQ(ty.Pointer(ty.I32(), builtin::AddressSpace::kUndefined),
- ty.Pointer(ty.I32(), builtin::AddressSpace::kUndefined));
+ EXPECT_EQ(ty.Pointer(builtin::AddressSpace::kUndefined, ty.I32()),
+ ty.Pointer(builtin::AddressSpace::kUndefined, ty.I32()));
EXPECT_EQ(ty.Vector(ty.I32(), 3), ty.Vector(ty.I32(), 3));
EXPECT_EQ(ty.Matrix(ty.I32(), 3, 2), ty.Matrix(ty.I32(), 3, 2));
EXPECT_EQ(ty.Array(ty.I32(), 3, 2), ty.Array(ty.I32(), 3, 2));
@@ -54,10 +54,10 @@
Symbol sym_b(Symbol(2, {}, "2"));
TypeManager ty;
- EXPECT_NE(ty.Pointer(ty.I32(), builtin::AddressSpace::kUndefined),
- ty.Pointer(ty.U32(), builtin::AddressSpace::kUndefined));
- EXPECT_NE(ty.Pointer(ty.I32(), builtin::AddressSpace::kUndefined),
- ty.Pointer(ty.I32(), builtin::AddressSpace::kIn));
+ EXPECT_NE(ty.Pointer(builtin::AddressSpace::kUndefined, ty.I32()),
+ ty.Pointer(builtin::AddressSpace::kUndefined, ty.U32()));
+ EXPECT_NE(ty.Pointer(builtin::AddressSpace::kUndefined, ty.I32()),
+ ty.Pointer(builtin::AddressSpace::kIn, ty.I32()));
EXPECT_NE(ty.Vector(ty.I32(), 3), ty.Vector(ty.U32(), 3));
EXPECT_NE(ty.Vector(ty.I32(), 3), ty.Vector(ty.I32(), 2));
EXPECT_NE(ty.Matrix(ty.I32(), 3, 2), ty.Matrix(ty.U32(), 3, 2));
diff --git a/src/tint/resolver/address_space_validation_test.cc b/src/tint/resolver/address_space_validation_test.cc
index a1b5ea8..fae4a25 100644
--- a/src/tint/resolver/address_space_validation_test.cc
+++ b/src/tint/resolver/address_space_validation_test.cc
@@ -67,8 +67,8 @@
TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Private_RuntimeArray) {
// type t : ptr<private, array<i32>>;
- Alias("t", ty.pointer(Source{{56, 78}}, ty.array(Source{{12, 34}}, ty.i32()),
- builtin::AddressSpace::kPrivate));
+ Alias("t", ty.ptr(Source{{56, 78}}, builtin::AddressSpace::kPrivate,
+ ty.array(Source{{12, 34}}, ty.i32())));
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@@ -93,7 +93,7 @@
// struct S { m : array<i32> };
// type t = ptr<private, S>;
Structure("S", utils::Vector{Member(Source{{12, 34}}, "m", ty.array(ty.i32()))});
- Alias("t", ty.pointer(ty("S"), builtin::AddressSpace::kPrivate));
+ Alias("t", ty.ptr(builtin::AddressSpace::kPrivate, ty("S")));
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@@ -115,7 +115,7 @@
TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Workgroup_RuntimeArray) {
// type t = ptr<workgroup, array<i32>>;
- Alias("t", ty.pointer(ty.array(Source{{12, 34}}, ty.i32()), builtin::AddressSpace::kWorkgroup));
+ Alias("t", ty.ptr(builtin::AddressSpace::kWorkgroup, ty.array(Source{{12, 34}}, ty.i32())));
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@@ -140,7 +140,7 @@
// struct S { m : array<i32> };
// type t = ptr<workgroup, S>;
Structure("S", utils::Vector{Member(Source{{12, 34}}, "m", ty.array(ty.i32()))});
- Alias(Source{{56, 78}}, "t", ty.pointer(ty("S"), builtin::AddressSpace::kWorkgroup));
+ Alias(Source{{56, 78}}, "t", ty.ptr(builtin::AddressSpace::kWorkgroup, ty("S")));
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@@ -165,7 +165,7 @@
TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_Bool) {
// type t = ptr<storage, bool>;
Alias(Source{{56, 78}}, "t",
- ty.pointer(ty.bool_(Source{{12, 34}}), builtin::AddressSpace::kStorage));
+ ty.ptr(builtin::AddressSpace::kStorage, ty.bool_(Source{{12, 34}})));
ASSERT_FALSE(r()->Resolve());
@@ -195,7 +195,7 @@
// type t = ptr<storage, a>;
Alias("a", ty.bool_());
Alias(Source{{56, 78}}, "t",
- ty.pointer(ty(Source{{12, 34}}, "a"), builtin::AddressSpace::kStorage));
+ ty.ptr(builtin::AddressSpace::kStorage, ty(Source{{12, 34}}, "a")));
ASSERT_FALSE(r()->Resolve());
@@ -208,7 +208,7 @@
TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_Pointer) {
// var<storage> g : ptr<private, f32>;
GlobalVar(Source{{56, 78}}, "g",
- ty.pointer(Source{{12, 34}}, ty.f32(), builtin::AddressSpace::kPrivate),
+ ty.ptr(Source{{12, 34}}, builtin::AddressSpace::kPrivate, ty.f32()),
builtin::AddressSpace::kStorage, Binding(0_a), Group(0_a));
ASSERT_FALSE(r()->Resolve());
@@ -221,9 +221,8 @@
TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_Pointer) {
// type t = ptr<storage, ptr<private, f32>>;
- Alias("t", ty.pointer(Source{{56, 78}},
- ty.pointer(Source{{12, 34}}, ty.f32(), builtin::AddressSpace::kPrivate),
- builtin::AddressSpace::kStorage));
+ Alias("t", ty.ptr(Source{{56, 78}}, builtin::AddressSpace::kStorage,
+ ty.ptr(Source{{12, 34}}, builtin::AddressSpace::kPrivate, ty.f32())));
ASSERT_FALSE(r()->Resolve());
@@ -242,7 +241,7 @@
TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_IntScalar) {
// type t = ptr<storage, i32;
- Alias("t", ty.pointer(ty.i32(), builtin::AddressSpace::kStorage));
+ Alias("t", ty.ptr(builtin::AddressSpace::kStorage, ty.i32()));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@@ -262,7 +261,7 @@
// type t = ptr<storage, f16>;
Enable(builtin::Extension::kF16);
- Alias("t", ty.pointer(ty.f16(), builtin::AddressSpace::kStorage));
+ Alias("t", ty.ptr(builtin::AddressSpace::kStorage, ty.f16()));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@@ -286,7 +285,7 @@
Enable(builtin::Extension::kF16);
Alias("a", ty.f16());
- Alias("t", ty.pointer(ty("a"), builtin::AddressSpace::kStorage));
+ Alias("t", ty.ptr(builtin::AddressSpace::kStorage, ty("a")));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@@ -300,7 +299,7 @@
TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_VectorF32) {
// type t = ptr<storage, vec4<f32>>;
- Alias("t", ty.pointer(ty.vec4<f32>(), builtin::AddressSpace::kStorage));
+ Alias("t", ty.ptr(builtin::AddressSpace::kStorage, ty.vec4<f32>()));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@@ -316,7 +315,7 @@
TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_VectorF16) {
// type t = ptr<storage, vec4<f16>>;
Enable(builtin::Extension::kF16);
- Alias("t", ty.pointer(ty.vec(ty.f16(), 4u), builtin::AddressSpace::kStorage));
+ Alias("t", ty.ptr(builtin::AddressSpace::kStorage, ty.vec(ty.f16(), 4u)));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@@ -335,7 +334,7 @@
// struct S{ a : f32 };
// type t = ptr<storage, array<S, 3u>>;
Structure("S", utils::Vector{Member("a", ty.f32())});
- Alias("t", ty.pointer(ty.array(ty("S"), 3_u), builtin::AddressSpace::kStorage));
+ Alias("t", ty.ptr(builtin::AddressSpace::kStorage, ty.array(ty("S"), 3_u)));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@@ -356,12 +355,12 @@
TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_ArrayF16) {
// enable f16;
// struct S{ a : f16 };
- // type t = ptr<storage, read, array<S, 3u>>;
+ // type t = ptr<storage, array<S, 3u>, read>;
Enable(builtin::Extension::kF16);
Structure("S", utils::Vector{Member("a", ty.f16())});
- Alias("t", ty.pointer(ty.array(ty("S"), 3_u), builtin::AddressSpace::kStorage,
- builtin::Access::kRead));
+ Alias("t",
+ ty.ptr(builtin::AddressSpace::kStorage, ty.array(ty("S"), 3_u), builtin::Access::kRead));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@@ -378,9 +377,9 @@
TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_StructI32) {
// struct S { x : i32 };
- // type t = ptr<storage, read, S>;
+ // type t = ptr<storage, S, read>;
Structure("S", utils::Vector{Member("x", ty.i32())});
- Alias("t", ty.pointer(ty("S"), builtin::AddressSpace::kStorage, builtin::Access::kRead));
+ Alias("t", ty.ptr(builtin::AddressSpace::kStorage, ty("S"), builtin::Access::kRead));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@@ -401,11 +400,11 @@
TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_StructI32Aliases) {
// struct S { x : i32 };
// type a1 = S;
- // type t = ptr<storage, read, a1>;
+ // type t = ptr<storage, a1, read>;
Structure("S", utils::Vector{Member("x", ty.i32())});
Alias("a1", ty("S"));
Alias("a2", ty("a1"));
- Alias("t", ty.pointer(ty("a2"), builtin::AddressSpace::kStorage, builtin::Access::kRead));
+ Alias("t", ty.ptr(builtin::AddressSpace::kStorage, ty("a2"), builtin::Access::kRead));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@@ -424,11 +423,11 @@
TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_StructF16) {
// struct S { x : f16 };
- // type t = ptr<storage, read, S>;
+ // type t = ptr<storage, S, read>;
Enable(builtin::Extension::kF16);
Structure("S", utils::Vector{Member("x", ty.f16())});
- Alias("t", ty.pointer(ty("S"), builtin::AddressSpace::kStorage, builtin::Access::kRead));
+ Alias("t", ty.ptr(builtin::AddressSpace::kStorage, ty("S"), builtin::Access::kRead));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@@ -451,13 +450,13 @@
TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_StructF16Aliases) {
// struct S { x : f16 };
// type a1 = S;
- // type t = ptr<storage, read, a1>;
+ // type t = ptr<storage, a1, read>;
Enable(builtin::Extension::kF16);
Structure("S", utils::Vector{Member("x", ty.f16())});
Alias("a1", ty("S"));
Alias("a2", ty("a1"));
- Alias("g", ty.pointer(ty("a2"), builtin::AddressSpace::kStorage, builtin::Access::kRead));
+ Alias("g", ty.ptr(builtin::AddressSpace::kStorage, ty("a2"), builtin::Access::kRead));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@@ -476,8 +475,8 @@
TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_NotStorage_AccessMode) {
// type t = ptr<private, i32, read>;
- Alias("t", ty.pointer(Source{{12, 34}}, ty.i32(), builtin::AddressSpace::kPrivate,
- builtin::Access::kRead));
+ Alias("t", ty.ptr(Source{{12, 34}}, builtin::AddressSpace::kPrivate, ty.i32(),
+ builtin::Access::kRead));
ASSERT_FALSE(r()->Resolve());
@@ -495,8 +494,8 @@
}
TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_ReadAccessMode) {
- // type t = ptr<storage, read, i32>;
- Alias("t", ty.pointer(ty.i32(), builtin::AddressSpace::kStorage, builtin::Access::kRead));
+ // type t = ptr<storage, i32, read>;
+ Alias("t", ty.ptr(builtin::AddressSpace::kStorage, ty.i32(), builtin::Access::kRead));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@@ -510,8 +509,8 @@
}
TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_ReadWriteAccessMode) {
- // type t = ptr<storage, read_write, i32>;
- Alias("t", ty.pointer(ty.i32(), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite));
+ // type t = ptr<storage, i32, read_write>;
+ Alias("t", ty.ptr(builtin::AddressSpace::kStorage, ty.i32(), builtin::Access::kReadWrite));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@@ -528,9 +527,9 @@
}
TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_WriteAccessMode) {
- // type t = ptr<storage, read_write, i32>;
- Alias("t", ty.pointer(Source{{12, 34}}, ty.i32(), builtin::AddressSpace::kStorage,
- builtin::Access::kWrite));
+ // type t = ptr<storage, i32, read_write>;
+ Alias("t", ty.ptr(Source{{12, 34}}, builtin::AddressSpace::kStorage, ty.i32(),
+ builtin::Access::kWrite));
ASSERT_FALSE(r()->Resolve());
@@ -562,7 +561,7 @@
Structure("S",
utils::Vector{Member(Source{{56, 78}}, "m", ty.array(Source{{12, 34}}, ty.i32()))});
- Alias("t", ty.pointer(Source{{90, 12}}, ty("S"), builtin::AddressSpace::kUniform));
+ Alias("t", ty.ptr(Source{{90, 12}}, builtin::AddressSpace::kUniform, ty("S")));
ASSERT_FALSE(r()->Resolve());
EXPECT_EQ(
@@ -590,8 +589,8 @@
TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_UniformBufferBool) {
// type t = ptr<uniform, bool>;
- Alias("t", ty.pointer(Source{{56, 78}}, ty.bool_(Source{{12, 34}}),
- builtin::AddressSpace::kUniform));
+ Alias("t",
+ ty.ptr(Source{{56, 78}}, builtin::AddressSpace::kUniform, ty.bool_(Source{{12, 34}})));
ASSERT_FALSE(r()->Resolve());
@@ -621,7 +620,7 @@
// type t = ptr<uniform, a>;
Alias("a", ty.bool_());
Alias("t",
- ty.pointer(Source{{56, 78}}, ty(Source{{12, 34}}, "a"), builtin::AddressSpace::kUniform));
+ ty.ptr(Source{{56, 78}}, builtin::AddressSpace::kUniform, ty(Source{{12, 34}}, "a")));
ASSERT_FALSE(r()->Resolve());
@@ -634,7 +633,7 @@
TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_UniformPointer) {
// var<uniform> g : ptr<private, f32>;
GlobalVar(Source{{56, 78}}, "g",
- ty.pointer(Source{{12, 34}}, ty.f32(), builtin::AddressSpace::kPrivate),
+ ty.ptr(Source{{12, 34}}, builtin::AddressSpace::kPrivate, ty.f32()),
builtin::AddressSpace::kUniform, Binding(0_a), Group(0_a));
ASSERT_FALSE(r()->Resolve());
@@ -647,9 +646,8 @@
TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_UniformPointer) {
// type t = ptr<uniform, ptr<private, f32>>;
- Alias("t", ty.pointer(Source{{56, 78}},
- ty.pointer(Source{{12, 34}}, ty.f32(), builtin::AddressSpace::kPrivate),
- builtin::AddressSpace::kUniform));
+ Alias("t", ty.ptr(Source{{56, 78}}, builtin::AddressSpace::kUniform,
+ ty.ptr(Source{{12, 34}}, builtin::AddressSpace::kPrivate, ty.f32())));
ASSERT_FALSE(r()->Resolve());
@@ -669,7 +667,7 @@
TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_UniformBufferIntScalar) {
// type t = ptr<uniform, i32>;
- Alias("t", ty.pointer(ty.i32(), builtin::AddressSpace::kUniform));
+ Alias("t", ty.ptr(builtin::AddressSpace::kUniform, ty.i32()));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@@ -689,7 +687,7 @@
// type t = ptr<uniform, f16>;
Enable(builtin::Extension::kF16);
- Alias("t", ty.pointer(ty.f16(), builtin::AddressSpace::kUniform));
+ Alias("t", ty.ptr(builtin::AddressSpace::kUniform, ty.f16()));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@@ -703,7 +701,7 @@
TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_UniformBufferVectorF32) {
// type t = ptr<uniform, vec4<f32>>;
- Alias("t", ty.pointer(ty.vec4<f32>(), builtin::AddressSpace::kUniform));
+ Alias("t", ty.ptr(builtin::AddressSpace::kUniform, ty.vec4<f32>()));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@@ -723,7 +721,7 @@
// type t = ptr<uniform, vec4<f16>>;
Enable(builtin::Extension::kF16);
- Alias("t", ty.pointer(ty.vec4<f16>(), builtin::AddressSpace::kUniform));
+ Alias("t", ty.ptr(builtin::AddressSpace::kUniform, ty.vec4<f16>()));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@@ -746,7 +744,7 @@
// }
// type t = ptr<uniform, array<S, 3u>>;
Structure("S", utils::Vector{Member("a", ty.f32(), utils::Vector{MemberSize(16_a)})});
- Alias("t", ty.pointer(ty.array(ty("S"), 3_u), builtin::AddressSpace::kUniform));
+ Alias("t", ty.ptr(builtin::AddressSpace::kUniform, ty.array(ty("S"), 3_u)));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@@ -775,7 +773,7 @@
Enable(builtin::Extension::kF16);
Structure("S", utils::Vector{Member("a", ty.f16(), utils::Vector{MemberSize(16_a)})});
- Alias("t", ty.pointer(ty.array(ty("S"), 3_u), builtin::AddressSpace::kUniform));
+ Alias("t", ty.ptr(builtin::AddressSpace::kUniform, ty.array(ty("S"), 3_u)));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@@ -793,7 +791,7 @@
// struct S { x : i32 };
// type t = ptr<uniform, S>;
Structure("S", utils::Vector{Member("x", ty.i32())});
- Alias("t", ty.pointer(ty("S"), builtin::AddressSpace::kUniform));
+ Alias("t", ty.ptr(builtin::AddressSpace::kUniform, ty("S")));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@@ -815,7 +813,7 @@
// type t = ptr<uniform, a1>;
Structure("S", utils::Vector{Member("x", ty.i32())});
Alias("a1", ty("S"));
- Alias("t", ty.pointer(ty("a1"), builtin::AddressSpace::kUniform));
+ Alias("t", ty.ptr(builtin::AddressSpace::kUniform, ty("a1")));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@@ -839,7 +837,7 @@
Enable(builtin::Extension::kF16);
Structure("S", utils::Vector{Member("x", ty.f16())});
- Alias("t", ty.pointer(ty("S"), builtin::AddressSpace::kUniform));
+ Alias("t", ty.ptr(builtin::AddressSpace::kUniform, ty("S")));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@@ -867,7 +865,7 @@
Structure("S", utils::Vector{Member("x", ty.f16())});
Alias("a1", ty("S"));
- Alias("t", ty.pointer(ty("a1"), builtin::AddressSpace::kUniform));
+ Alias("t", ty.ptr(builtin::AddressSpace::kUniform, ty("a1")));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@@ -891,7 +889,7 @@
// type t = ptr<push_constant, bool>;
Enable(builtin::Extension::kChromiumExperimentalPushConstant);
Alias(Source{{56, 78}}, "t",
- ty.pointer(ty.bool_(Source{{12, 34}}), builtin::AddressSpace::kPushConstant));
+ ty.ptr(builtin::AddressSpace::kPushConstant, ty.bool_(Source{{12, 34}})));
ASSERT_FALSE(r()->Resolve());
EXPECT_EQ(
@@ -919,7 +917,7 @@
// type t = ptr<push_constant, f16>;
Enable(builtin::Extension::kF16);
Enable(builtin::Extension::kChromiumExperimentalPushConstant);
- Alias("t", ty.pointer(ty.f16(Source{{56, 78}}), builtin::AddressSpace::kPushConstant));
+ Alias("t", ty.ptr(builtin::AddressSpace::kPushConstant, ty.f16(Source{{56, 78}})));
ASSERT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@@ -931,7 +929,7 @@
// var<push_constant> g : ptr<private, f32>;
Enable(builtin::Extension::kChromiumExperimentalPushConstant);
GlobalVar(Source{{56, 78}}, "g",
- ty.pointer(Source{{12, 34}}, ty.f32(), builtin::AddressSpace::kPrivate),
+ ty.ptr(Source{{12, 34}}, builtin::AddressSpace::kPrivate, ty.f32()),
builtin::AddressSpace::kPushConstant);
ASSERT_FALSE(r()->Resolve());
@@ -946,8 +944,8 @@
// type t = ptr<push_constant, ptr<private, f32>>;
Enable(builtin::Extension::kChromiumExperimentalPushConstant);
Alias(Source{{56, 78}}, "t",
- ty.pointer(ty.pointer(Source{{12, 34}}, ty.f32(), builtin::AddressSpace::kPrivate),
- builtin::AddressSpace::kPushConstant));
+ ty.ptr(builtin::AddressSpace::kPushConstant,
+ ty.ptr(Source{{12, 34}}, builtin::AddressSpace::kPrivate, ty.f32())));
ASSERT_FALSE(r()->Resolve());
EXPECT_EQ(
@@ -969,7 +967,7 @@
// enable chromium_experimental_push_constant;
// type t = ptr<push_constant, i32>;
Enable(builtin::Extension::kChromiumExperimentalPushConstant);
- Alias("t", ty.pointer(ty.i32(), builtin::AddressSpace::kPushConstant));
+ Alias("t", ty.ptr(builtin::AddressSpace::kPushConstant, ty.i32()));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@@ -987,7 +985,7 @@
// enable chromium_experimental_push_constant;
// var<push_constant> g : vec4<f32>;
Enable(builtin::Extension::kChromiumExperimentalPushConstant);
- Alias("t", ty.pointer(ty.vec4<f32>(), builtin::AddressSpace::kPushConstant));
+ Alias("t", ty.ptr(builtin::AddressSpace::kPushConstant, ty.vec4<f32>()));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@@ -1009,7 +1007,7 @@
// type t = ptr<push_constant, array<S, 3u>>;
Enable(builtin::Extension::kChromiumExperimentalPushConstant);
Structure("S", utils::Vector{Member("a", ty.f32())});
- Alias("t", ty.pointer(ty.array(ty("S"), 3_u), builtin::AddressSpace::kPushConstant));
+ Alias("t", ty.ptr(builtin::AddressSpace::kPushConstant, ty.array(ty("S"), 3_u)));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
diff --git a/src/tint/resolver/alias_analysis_test.cc b/src/tint/resolver/alias_analysis_test.cc
index 895ed88..7eab9bc 100644
--- a/src/tint/resolver/alias_analysis_test.cc
+++ b/src/tint/resolver/alias_analysis_test.cc
@@ -59,8 +59,8 @@
auto addrspace = GetParam().address_space;
Func("target",
utils::Vector{
- Param("p1", ty.pointer<i32>(addrspace)),
- Param("p2", ty.pointer<i32>(addrspace)),
+ Param("p1", ty.ptr<i32>(addrspace)),
+ Param("p2", ty.ptr<i32>(addrspace)),
},
ty.void_(), std::move(body));
if (GetParam().aliased && err) {
@@ -129,8 +129,8 @@
// f1(p1, p2);
Func("f2",
utils::Vector{
- Param("p1", ty.pointer<i32>(GetParam().address_space)),
- Param("p2", ty.pointer<i32>(GetParam().address_space)),
+ Param("p1", ty.ptr<i32>(GetParam().address_space)),
+ Param("p2", ty.ptr<i32>(GetParam().address_space)),
},
ty.void_(),
utils::Vector{
@@ -139,8 +139,8 @@
});
Func("f1",
utils::Vector{
- Param("p1", ty.pointer<i32>(GetParam().address_space)),
- Param("p2", ty.pointer<i32>(GetParam().address_space)),
+ Param("p1", ty.ptr<i32>(GetParam().address_space)),
+ Param("p2", ty.ptr<i32>(GetParam().address_space)),
},
ty.void_(),
utils::Vector{
@@ -166,7 +166,7 @@
// f2(p2);
Func("f1",
utils::Vector<const ast::Parameter*, 4>{
- Param("p1", ty.pointer<i32>(GetParam().address_space)),
+ Param("p1", ty.ptr<i32>(GetParam().address_space)),
},
ty.void_(),
utils::Vector{
@@ -174,7 +174,7 @@
});
Func("f2",
utils::Vector<const ast::Parameter*, 4>{
- Param("p2", ty.pointer<i32>(GetParam().address_space)),
+ Param("p2", ty.ptr<i32>(GetParam().address_space)),
},
ty.void_(),
utils::Vector{
@@ -228,7 +228,7 @@
void Run(utils::Vector<const ast::Statement*, 4>&& body, const char* err = nullptr) {
Func("target",
utils::Vector<const ast::Parameter*, 4>{
- Param("p1", ty.pointer<i32>(builtin::AddressSpace::kPrivate)),
+ Param("p1", ty.ptr<i32>(builtin::AddressSpace::kPrivate)),
},
ty.void_(), std::move(body));
if (GetParam() && err) {
@@ -297,7 +297,7 @@
// f1(p1);
Func("f2",
utils::Vector<const ast::Parameter*, 4>{
- Param("p1", ty.pointer<i32>(builtin::AddressSpace::kPrivate)),
+ Param("p1", ty.ptr<i32>(builtin::AddressSpace::kPrivate)),
},
ty.void_(),
utils::Vector{
@@ -305,7 +305,7 @@
});
Func("f1",
utils::Vector<const ast::Parameter*, 4>{
- Param("p1", ty.pointer<i32>(builtin::AddressSpace::kPrivate)),
+ Param("p1", ty.ptr<i32>(builtin::AddressSpace::kPrivate)),
},
ty.void_(),
utils::Vector{
@@ -332,7 +332,7 @@
// f1(p1);
Func("f2",
utils::Vector<const ast::Parameter*, 4>{
- Param("p1", ty.pointer<i32>(builtin::AddressSpace::kPrivate)),
+ Param("p1", ty.ptr<i32>(builtin::AddressSpace::kPrivate)),
},
ty.void_(),
utils::Vector{
@@ -341,7 +341,7 @@
});
Func("f1",
utils::Vector<const ast::Parameter*, 4>{
- Param("p1", ty.pointer<i32>(builtin::AddressSpace::kPrivate)),
+ Param("p1", ty.ptr<i32>(builtin::AddressSpace::kPrivate)),
},
ty.void_(),
utils::Vector{
@@ -367,7 +367,7 @@
// f1(p1);
Func("f2",
utils::Vector<const ast::Parameter*, 4>{
- Param("p1", ty.pointer<i32>(builtin::AddressSpace::kPrivate)),
+ Param("p1", ty.ptr<i32>(builtin::AddressSpace::kPrivate)),
},
ty.void_(),
utils::Vector{
@@ -375,7 +375,7 @@
});
Func("f1",
utils::Vector<const ast::Parameter*, 4>{
- Param("p1", ty.pointer<i32>(builtin::AddressSpace::kPrivate)),
+ Param("p1", ty.ptr<i32>(builtin::AddressSpace::kPrivate)),
},
ty.void_(),
utils::Vector{
@@ -402,7 +402,7 @@
// f1(p1);
Func("f2",
utils::Vector{
- Param("p1", ty.pointer<i32>(builtin::AddressSpace::kPrivate)),
+ Param("p1", ty.ptr<i32>(builtin::AddressSpace::kPrivate)),
},
ty.void_(),
utils::Vector{
@@ -411,7 +411,7 @@
});
Func("f1",
utils::Vector{
- Param("p1", ty.pointer<i32>(builtin::AddressSpace::kPrivate)),
+ Param("p1", ty.ptr<i32>(builtin::AddressSpace::kPrivate)),
},
ty.void_(),
utils::Vector{
@@ -437,7 +437,7 @@
// f2();
Func("f1",
utils::Vector{
- Param("p1", ty.pointer<i32>(builtin::AddressSpace::kPrivate)),
+ Param("p1", ty.ptr<i32>(builtin::AddressSpace::kPrivate)),
},
ty.void_(),
utils::Vector{
@@ -489,8 +489,8 @@
void Run(const ast::Statement* stmt, const char* err = nullptr) {
Func("target",
utils::Vector{
- Param("p1", ty.pointer<i32>(builtin::AddressSpace::kFunction)),
- Param("p2", ty.pointer<i32>(builtin::AddressSpace::kFunction)),
+ Param("p1", ty.ptr<i32>(builtin::AddressSpace::kFunction)),
+ Param("p2", ty.ptr<i32>(builtin::AddressSpace::kFunction)),
},
ty.void_(),
utils::Vector{
@@ -604,7 +604,7 @@
// foo(p2);
Func("foo",
utils::Vector{
- Param("p", ty.pointer<i32>(builtin::AddressSpace::kFunction)),
+ Param("p", ty.ptr<i32>(builtin::AddressSpace::kFunction)),
},
ty.i32(),
utils::Vector{
@@ -661,8 +661,8 @@
void Run(const ast::Statement* stmt, const char* err = nullptr) {
Func("target",
utils::Vector{
- Param("p1", ty.pointer<bool>(builtin::AddressSpace::kFunction)),
- Param("p2", ty.pointer<bool>(builtin::AddressSpace::kFunction)),
+ Param("p1", ty.ptr<bool>(builtin::AddressSpace::kFunction)),
+ Param("p2", ty.ptr<bool>(builtin::AddressSpace::kFunction)),
},
ty.void_(),
utils::Vector{
@@ -726,8 +726,8 @@
Structure("S", utils::Vector{Member("a", ty.i32())});
Func("f2",
utils::Vector{
- Param("p1", ty.pointer(ty("S"), builtin::AddressSpace::kFunction)),
- Param("p2", ty.pointer(ty("S"), builtin::AddressSpace::kFunction)),
+ Param("p1", ty.ptr(builtin::AddressSpace::kFunction, ty("S"))),
+ Param("p2", ty.ptr(builtin::AddressSpace::kFunction, ty("S"))),
},
ty.void_(),
utils::Vector{
@@ -755,8 +755,8 @@
Structure("S", utils::Vector{Member("a", ty.i32())});
Func("f2",
utils::Vector{
- Param("p1", ty.pointer(ty("S"), builtin::AddressSpace::kFunction)),
- Param("p2", ty.pointer(ty("S"), builtin::AddressSpace::kFunction)),
+ Param("p1", ty.ptr(builtin::AddressSpace::kFunction, ty("S"))),
+ Param("p2", ty.ptr(builtin::AddressSpace::kFunction, ty("S"))),
},
ty.void_(),
utils::Vector{
@@ -787,8 +787,8 @@
Structure("S", utils::Vector{Member("a", ty.i32())});
Func("f2",
utils::Vector{
- Param("p1", ty.pointer(ty("S"), builtin::AddressSpace::kFunction)),
- Param("p2", ty.pointer(ty("S"), builtin::AddressSpace::kFunction)),
+ Param("p1", ty.ptr(builtin::AddressSpace::kFunction, ty("S"))),
+ Param("p2", ty.ptr(builtin::AddressSpace::kFunction, ty("S"))),
},
ty.void_(),
utils::Vector{
@@ -818,8 +818,8 @@
Structure("S", utils::Vector{Member("a", ty.i32())});
Func("f2",
utils::Vector{
- Param("p1", ty.pointer(ty.vec4<f32>(), builtin::AddressSpace::kFunction)),
- Param("p2", ty.pointer(ty.vec4<f32>(), builtin::AddressSpace::kFunction)),
+ Param("p1", ty.ptr(builtin::AddressSpace::kFunction, ty.vec4<f32>())),
+ Param("p2", ty.ptr(builtin::AddressSpace::kFunction, ty.vec4<f32>())),
},
ty.void_(),
utils::Vector{
@@ -850,7 +850,7 @@
// }
Func("f1",
utils::Vector{
- Param("p", ty.pointer<i32>(builtin::AddressSpace::kFunction)),
+ Param("p", ty.ptr<i32>(builtin::AddressSpace::kFunction)),
},
ty.void_(),
utils::Vector{
@@ -903,7 +903,7 @@
// }
Func("f2",
utils::Vector{
- Param("p", ty.pointer<i32>(builtin::AddressSpace::kFunction)),
+ Param("p", ty.ptr<i32>(builtin::AddressSpace::kFunction)),
},
ty.void_(),
utils::Vector{
@@ -911,7 +911,7 @@
});
Func("f3",
utils::Vector{
- Param("p", ty.pointer<i32>(builtin::AddressSpace::kFunction)),
+ Param("p", ty.ptr<i32>(builtin::AddressSpace::kFunction)),
},
ty.void_(),
utils::Vector{
diff --git a/src/tint/resolver/array_accessor_test.cc b/src/tint/resolver/array_accessor_test.cc
index e18a618..118bcff 100644
--- a/src/tint/resolver/array_accessor_test.cc
+++ b/src/tint/resolver/array_accessor_test.cc
@@ -316,7 +316,7 @@
// let x: f32 = (*p)[idx];
// return x;
// }
- auto* p = Param("p", ty.pointer(ty.vec4<f32>(), builtin::AddressSpace::kFunction));
+ auto* p = Param("p", ty.ptr(builtin::AddressSpace::kFunction, ty.vec4<f32>()));
auto* idx = Let("idx", ty.u32(), Call<u32>());
auto* star_p = Deref(p);
auto* acc = IndexAccessor(Source{{12, 34}}, star_p, idx);
@@ -337,7 +337,7 @@
// let x: f32 = *p[idx];
// return x;
// }
- auto* p = Param("p", ty.pointer(ty.vec4<f32>(), builtin::AddressSpace::kFunction));
+ auto* p = Param("p", ty.ptr(builtin::AddressSpace::kFunction, ty.vec4<f32>()));
auto* idx = Let("idx", ty.u32(), Call<u32>());
auto* accessor_expr = IndexAccessor(Source{{12, 34}}, p, idx);
auto* star_p = Deref(accessor_expr);
diff --git a/src/tint/resolver/assignment_validation_test.cc b/src/tint/resolver/assignment_validation_test.cc
index 1c57463..bd4cd71 100644
--- a/src/tint/resolver/assignment_validation_test.cc
+++ b/src/tint/resolver/assignment_validation_test.cc
@@ -183,8 +183,8 @@
// let b : ptr<function,i32> = &a;
// *b = 2i;
const auto func = builtin::AddressSpace::kFunction;
- WrapInFunction(Var("a", ty.i32(), func, Expr(2_i)), //
- Let("b", ty.pointer<i32>(func), AddressOf(Expr("a"))), //
+ WrapInFunction(Var("a", ty.i32(), func, Expr(2_i)), //
+ Let("b", ty.ptr<i32>(func), AddressOf(Expr("a"))), //
Assign(Deref("b"), 2_i));
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -196,7 +196,7 @@
// *b = 2;
const auto func = builtin::AddressSpace::kFunction;
auto* var_a = Var("a", ty.i32(), func, Expr(2_i));
- auto* var_b = Let("b", ty.pointer<i32>(func), AddressOf(Expr("a")));
+ auto* var_b = Let("b", ty.ptr<i32>(func), AddressOf(Expr("a")));
WrapInFunction(var_a, var_b, Assign(Deref("b"), 2_a));
EXPECT_TRUE(r()->Resolve()) << r()->error();
diff --git a/src/tint/resolver/call_validation_test.cc b/src/tint/resolver/call_validation_test.cc
index b00db68..bf533cc 100644
--- a/src/tint/resolver/call_validation_test.cc
+++ b/src/tint/resolver/call_validation_test.cc
@@ -103,7 +103,7 @@
// var z: i32 = 1i;
// foo(&z);
// }
- auto* param = Param("p", ty.pointer<i32>(builtin::AddressSpace::kFunction));
+ auto* param = Param("p", ty.ptr<i32>(builtin::AddressSpace::kFunction));
Func("foo", utils::Vector{param}, ty.void_(), utils::Empty);
Func("main", utils::Empty, ty.void_(),
utils::Vector{
@@ -120,7 +120,7 @@
// let z: i32 = 1i;
// foo(&z);
// }
- auto* param = Param("p", ty.pointer<i32>(builtin::AddressSpace::kFunction));
+ auto* param = Param("p", ty.ptr<i32>(builtin::AddressSpace::kFunction));
Func("foo", utils::Vector{param}, ty.void_(), utils::Empty);
Func("main", utils::Empty, ty.void_(),
utils::Vector{
@@ -142,7 +142,7 @@
auto* S = Structure("S", utils::Vector{
Member("m", ty.i32()),
});
- auto* param = Param("p", ty.pointer<i32>(builtin::AddressSpace::kFunction));
+ auto* param = Param("p", ty.ptr<i32>(builtin::AddressSpace::kFunction));
Func("foo", utils::Vector{param}, ty.void_(), utils::Empty);
Func("main", utils::Empty, ty.void_(),
utils::Vector{
@@ -169,7 +169,7 @@
auto* S = Structure("S", utils::Vector{
Member("m", ty.i32()),
});
- auto* param = Param("p", ty.pointer<i32>(builtin::AddressSpace::kFunction));
+ auto* param = Param("p", ty.ptr<i32>(builtin::AddressSpace::kFunction));
Func("foo", utils::Vector{param}, ty.void_(), utils::Empty);
Func("main", utils::Empty, ty.void_(),
utils::Vector{
@@ -189,7 +189,7 @@
auto* S = Structure("S", utils::Vector{
Member("m", ty.i32()),
});
- auto* param = Param("p", ty.pointer<i32>(builtin::AddressSpace::kFunction));
+ auto* param = Param("p", ty.ptr<i32>(builtin::AddressSpace::kFunction));
Func("foo", utils::Vector{param}, ty.void_(), utils::Empty);
Func("main", utils::Empty, ty.void_(),
utils::Vector{
@@ -208,12 +208,12 @@
// }
Func("foo",
utils::Vector{
- Param("p", ty.pointer<i32>(builtin::AddressSpace::kFunction)),
+ Param("p", ty.ptr<i32>(builtin::AddressSpace::kFunction)),
},
ty.void_(), utils::Empty);
Func("bar",
utils::Vector{
- Param("p", ty.pointer<i32>(builtin::AddressSpace::kFunction)),
+ Param("p", ty.ptr<i32>(builtin::AddressSpace::kFunction)),
},
ty.void_(),
utils::Vector{
@@ -235,12 +235,12 @@
// }
Func("foo",
utils::Vector{
- Param("p", ty.pointer<i32>(builtin::AddressSpace::kFunction)),
+ Param("p", ty.ptr<i32>(builtin::AddressSpace::kFunction)),
},
ty.void_(), utils::Empty);
Func("bar",
utils::Vector{
- Param("p", ty.pointer<i32>(builtin::AddressSpace::kFunction)),
+ Param("p", ty.ptr<i32>(builtin::AddressSpace::kFunction)),
},
ty.void_(),
utils::Vector{
@@ -268,13 +268,13 @@
// }
Func("x",
utils::Vector{
- Param("p", ty.pointer<i32>(builtin::AddressSpace::kFunction)),
+ Param("p", ty.ptr<i32>(builtin::AddressSpace::kFunction)),
},
ty.void_(), utils::Empty);
Func("main", utils::Empty, ty.void_(),
utils::Vector{
Decl(Var("v", ty.i32())),
- Decl(Let("p", ty.pointer(ty.i32(), builtin::AddressSpace::kFunction), AddressOf("v"))),
+ Decl(Let("p", ty.ptr(builtin::AddressSpace::kFunction, ty.i32()), AddressOf("v"))),
CallStmt(Call("x", "p")),
},
utils::Vector{
@@ -293,13 +293,13 @@
// }
Func("foo",
utils::Vector{
- Param("p", ty.pointer<i32>(builtin::AddressSpace::kPrivate)),
+ Param("p", ty.ptr<i32>(builtin::AddressSpace::kPrivate)),
},
ty.void_(), utils::Empty);
GlobalVar("v", ty.i32(), builtin::AddressSpace::kPrivate);
Func("main", utils::Empty, ty.void_(),
utils::Vector{
- Decl(Let("p", ty.pointer(ty.i32(), builtin::AddressSpace::kPrivate), AddressOf("v"))),
+ Decl(Let("p", ty.ptr(builtin::AddressSpace::kPrivate, ty.i32()), AddressOf("v"))),
CallStmt(Call("foo", Expr(Source{{12, 34}}, "p"))),
},
utils::Vector{
@@ -318,13 +318,13 @@
// }
Func("foo",
utils::Vector{
- Param("p", ty.pointer<i32>(builtin::AddressSpace::kFunction)),
+ Param("p", ty.ptr<i32>(builtin::AddressSpace::kFunction)),
},
ty.void_(), utils::Empty);
Func("main", utils::Empty, ty.void_(),
utils::Vector{
Decl(Var("v", ty.array<i32, 4>())),
- Decl(Let("p", ty.pointer(ty.i32(), builtin::AddressSpace::kFunction),
+ Decl(Let("p", ty.ptr(builtin::AddressSpace::kFunction, ty.i32()),
AddressOf(IndexAccessor("v", 0_a)))),
CallStmt(Call("foo", Expr(Source{{12, 34}}, "p"))),
},
@@ -349,13 +349,13 @@
Enable(builtin::Extension::kChromiumExperimentalFullPtrParameters);
Func("foo",
utils::Vector{
- Param("p", ty.pointer<i32>(builtin::AddressSpace::kFunction)),
+ Param("p", ty.ptr<i32>(builtin::AddressSpace::kFunction)),
},
ty.void_(), utils::Empty);
Func("main", utils::Empty, ty.void_(),
utils::Vector{
Decl(Var("v", ty.array<i32, 4>())),
- Decl(Let("p", ty.pointer(ty.i32(), builtin::AddressSpace::kFunction),
+ Decl(Let("p", ty.ptr(builtin::AddressSpace::kFunction, ty.i32()),
AddressOf(IndexAccessor("v", 0_a)))),
CallStmt(Call("foo", Expr(Source{{12, 34}}, "p"))),
},
@@ -377,7 +377,7 @@
// }
Func("foo",
utils::Vector{
- Param("p", ty.pointer(ty.array<i32, 4>(), builtin::AddressSpace::kFunction)),
+ Param("p", ty.ptr(builtin::AddressSpace::kFunction, ty.array<i32, 4>())),
},
ty.void_(), utils::Empty);
Func("main", utils::Empty, ty.void_(),
@@ -406,7 +406,7 @@
// }
Func("foo",
utils::Vector{
- Param("p", ty.pointer<i32>(builtin::AddressSpace::kFunction)),
+ Param("p", ty.ptr<i32>(builtin::AddressSpace::kFunction)),
},
ty.void_(), utils::Empty);
Func("main", utils::Empty, ty.void_(),
@@ -440,7 +440,7 @@
Enable(builtin::Extension::kChromiumExperimentalFullPtrParameters);
Func("foo",
utils::Vector{
- Param("p", ty.pointer<i32>(builtin::AddressSpace::kFunction)),
+ Param("p", ty.ptr<i32>(builtin::AddressSpace::kFunction)),
},
ty.void_(), utils::Empty);
Func("main", utils::Empty, ty.void_(),
diff --git a/src/tint/resolver/compound_assignment_validation_test.cc b/src/tint/resolver/compound_assignment_validation_test.cc
index ee18de3..0343f08 100644
--- a/src/tint/resolver/compound_assignment_validation_test.cc
+++ b/src/tint/resolver/compound_assignment_validation_test.cc
@@ -53,7 +53,7 @@
// *b += 2;
const auto func = builtin::AddressSpace::kFunction;
auto* var_a = Var("a", ty.i32(), func, Expr(2_i));
- auto* var_b = Let("b", ty.pointer<i32>(func), AddressOf(Expr("a")));
+ auto* var_b = Let("b", ty.ptr<i32>(func), AddressOf(Expr("a")));
WrapInFunction(var_a, var_b,
CompoundAssign(Source{{12, 34}}, Deref("b"), 2_i, ast::BinaryOp::kAdd));
diff --git a/src/tint/resolver/dependency_graph_test.cc b/src/tint/resolver/dependency_graph_test.cc
index 1850d6f..ee509a7 100644
--- a/src/tint/resolver/dependency_graph_test.cc
+++ b/src/tint/resolver/dependency_graph_test.cc
@@ -1732,7 +1732,7 @@
GlobalVar(Sym(), ty.array(T, V));
GlobalVar(Sym(), ty.vec3(T));
GlobalVar(Sym(), ty.mat3x2(T));
- GlobalVar(Sym(), ty.pointer(T, builtin::AddressSpace::kPrivate));
+ GlobalVar(Sym(), ty.ptr(builtin::AddressSpace::kPrivate, T));
GlobalVar(Sym(), ty.sampled_texture(type::TextureDimension::k2d, T));
GlobalVar(Sym(), ty.depth_texture(type::TextureDimension::k2d));
GlobalVar(Sym(), ty.depth_multisampled_texture(type::TextureDimension::k2d));
diff --git a/src/tint/resolver/function_validation_test.cc b/src/tint/resolver/function_validation_test.cc
index 6654c43..b97e7f3 100644
--- a/src/tint/resolver/function_validation_test.cc
+++ b/src/tint/resolver/function_validation_test.cc
@@ -926,7 +926,7 @@
}
TEST_F(ResolverFunctionValidationTest, ReturnIsConstructible_NonPlain) {
- auto ret_type = ty.pointer(Source{{12, 34}}, ty.i32(), builtin::AddressSpace::kFunction);
+ auto ret_type = ty.ptr(Source{{12, 34}}, builtin::AddressSpace::kFunction, ty.i32());
Func("f", utils::Empty, ret_type, utils::Empty);
EXPECT_FALSE(r()->Resolve());
diff --git a/src/tint/resolver/increment_decrement_validation_test.cc b/src/tint/resolver/increment_decrement_validation_test.cc
index c5a6c98..c3a0c78 100644
--- a/src/tint/resolver/increment_decrement_validation_test.cc
+++ b/src/tint/resolver/increment_decrement_validation_test.cc
@@ -65,7 +65,7 @@
// let b : ptr<function,i32> = &a;
// *b++;
auto* var_a = Var("a", ty.i32(), builtin::AddressSpace::kFunction);
- auto* var_b = Let("b", ty.pointer<i32>(builtin::AddressSpace::kFunction), AddressOf(Expr("a")));
+ auto* var_b = Let("b", ty.ptr<i32>(builtin::AddressSpace::kFunction), AddressOf(Expr("a")));
WrapInFunction(var_a, var_b, Increment(Source{{12, 34}}, Deref("b")));
EXPECT_TRUE(r()->Resolve()) << r()->error();
diff --git a/src/tint/resolver/intrinsic_table.cc b/src/tint/resolver/intrinsic_table.cc
index 4295bb3..27cf5cf 100644
--- a/src/tint/resolver/intrinsic_table.cc
+++ b/src/tint/resolver/intrinsic_table.cc
@@ -586,7 +586,7 @@
}
const type::Pointer* build_ptr(MatchState& state, Number S, const type::Type* T, Number& A) {
- return state.builder.create<type::Pointer>(T, static_cast<builtin::AddressSpace>(S.Value()),
+ return state.builder.create<type::Pointer>(static_cast<builtin::AddressSpace>(S.Value()), T,
static_cast<builtin::Access>(A.Value()));
}
diff --git a/src/tint/resolver/intrinsic_table_test.cc b/src/tint/resolver/intrinsic_table_test.cc
index 19ead21..1d5627c 100644
--- a/src/tint/resolver/intrinsic_table_test.cc
+++ b/src/tint/resolver/intrinsic_table_test.cc
@@ -230,7 +230,7 @@
TEST_F(IntrinsicTableTest, MatchPointer) {
auto* i32 = create<type::I32>();
auto* atomicI32 = create<type::Atomic>(i32);
- auto* ptr = create<type::Pointer>(atomicI32, builtin::AddressSpace::kWorkgroup,
+ auto* ptr = create<type::Pointer>(builtin::AddressSpace::kWorkgroup, atomicI32,
builtin::Access::kReadWrite);
auto result = table->Lookup(builtin::Function::kAtomicLoad, utils::Vector{ptr},
sem::EvaluationStage::kConstant, Source{});
@@ -255,7 +255,7 @@
auto* arr =
create<type::Array>(create<type::U32>(), create<type::RuntimeArrayCount>(), 4u, 4u, 4u, 4u);
auto* arr_ptr =
- create<type::Pointer>(arr, builtin::AddressSpace::kStorage, builtin::Access::kReadWrite);
+ create<type::Pointer>(builtin::AddressSpace::kStorage, arr, builtin::Access::kReadWrite);
auto result = table->Lookup(builtin::Function::kArrayLength, utils::Vector{arr_ptr},
sem::EvaluationStage::kConstant, Source{});
ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
@@ -450,7 +450,7 @@
auto* f32 = create<type::F32>();
auto result = table->Lookup(builtin::Function::kCos,
utils::Vector{
- create<type::Reference>(f32, builtin::AddressSpace::kFunction,
+ create<type::Reference>(builtin::AddressSpace::kFunction, f32,
builtin::Access::kReadWrite),
},
sem::EvaluationStage::kConstant, Source{});
@@ -552,7 +552,7 @@
TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Builtin_RuntimeEval) {
auto* af = create<type::AbstractFloat>();
- auto* bool_ref = create<type::Reference>(create<type::Bool>(), builtin::AddressSpace::kFunction,
+ auto* bool_ref = create<type::Reference>(builtin::AddressSpace::kFunction, create<type::Bool>(),
builtin::Access::kReadWrite);
auto result = table->Lookup(builtin::Function::kSelect, utils::Vector{af, af, bool_ref},
sem::EvaluationStage::kRuntime, Source{});
diff --git a/src/tint/resolver/is_host_shareable_test.cc b/src/tint/resolver/is_host_shareable_test.cc
index 4570d4d..32ff06d 100644
--- a/src/tint/resolver/is_host_shareable_test.cc
+++ b/src/tint/resolver/is_host_shareable_test.cc
@@ -95,7 +95,7 @@
}
TEST_F(ResolverIsHostShareable, Pointer) {
- auto* ptr = create<type::Pointer>(create<type::I32>(), builtin::AddressSpace::kPrivate,
+ auto* ptr = create<type::Pointer>(builtin::AddressSpace::kPrivate, create<type::I32>(),
builtin::Access::kReadWrite);
EXPECT_FALSE(r()->IsHostShareable(ptr));
}
diff --git a/src/tint/resolver/is_storeable_test.cc b/src/tint/resolver/is_storeable_test.cc
index 43abdbc..65c1ab9 100644
--- a/src/tint/resolver/is_storeable_test.cc
+++ b/src/tint/resolver/is_storeable_test.cc
@@ -78,7 +78,7 @@
}
TEST_F(ResolverIsStorableTest, Pointer) {
- auto* ptr = create<type::Pointer>(create<type::I32>(), builtin::AddressSpace::kPrivate,
+ auto* ptr = create<type::Pointer>(builtin::AddressSpace::kPrivate, create<type::I32>(),
builtin::Access::kReadWrite);
EXPECT_FALSE(r()->IsStorable(ptr));
}
@@ -112,7 +112,7 @@
TEST_F(ResolverIsStorableTest, Struct_SomeMembersNonStorable) {
Structure("S", utils::Vector{
Member("a", ty.i32()),
- Member("b", ty.pointer<i32>(builtin::AddressSpace::kPrivate)),
+ Member("b", ty.ptr<i32>(builtin::AddressSpace::kPrivate)),
});
EXPECT_FALSE(r()->Resolve());
@@ -138,7 +138,7 @@
auto* non_storable =
Structure("nonstorable", utils::Vector{
Member("a", ty.i32()),
- Member("b", ty.pointer<i32>(builtin::AddressSpace::kPrivate)),
+ Member("b", ty.ptr<i32>(builtin::AddressSpace::kPrivate)),
});
Structure("S", utils::Vector{
Member("a", ty.i32()),
diff --git a/src/tint/resolver/ptr_ref_test.cc b/src/tint/resolver/ptr_ref_test.cc
index 1e702a5..ddb2e3b 100644
--- a/src/tint/resolver/ptr_ref_test.cc
+++ b/src/tint/resolver/ptr_ref_test.cc
@@ -76,15 +76,15 @@
GlobalVar("sb", ty.Of(buf), builtin::AddressSpace::kStorage, Binding(1_a), Group(0_a));
auto* function_ptr =
- Let("f_ptr", ty.pointer(ty.i32(), builtin::AddressSpace::kFunction), AddressOf(function));
+ Let("f_ptr", ty.ptr(builtin::AddressSpace::kFunction, ty.i32()), AddressOf(function));
auto* private_ptr =
- Let("p_ptr", ty.pointer(ty.i32(), builtin::AddressSpace::kPrivate), AddressOf(private_));
+ Let("p_ptr", ty.ptr(builtin::AddressSpace::kPrivate, ty.i32()), AddressOf(private_));
auto* workgroup_ptr =
- Let("w_ptr", ty.pointer(ty.i32(), builtin::AddressSpace::kWorkgroup), AddressOf(workgroup));
+ Let("w_ptr", ty.ptr(builtin::AddressSpace::kWorkgroup, ty.i32()), AddressOf(workgroup));
auto* uniform_ptr =
- Let("ub_ptr", ty.pointer(ty.Of(buf), builtin::AddressSpace::kUniform), AddressOf(uniform));
+ Let("ub_ptr", ty.ptr(builtin::AddressSpace::kUniform, ty.Of(buf)), AddressOf(uniform));
auto* storage_ptr =
- Let("sb_ptr", ty.pointer(ty.Of(buf), builtin::AddressSpace::kStorage), AddressOf(storage));
+ Let("sb_ptr", ty.ptr(builtin::AddressSpace::kStorage, ty.Of(buf)), AddressOf(storage));
WrapInFunction(function, function_ptr, private_ptr, workgroup_ptr, uniform_ptr, storage_ptr);
diff --git a/src/tint/resolver/ptr_ref_validation_test.cc b/src/tint/resolver/ptr_ref_validation_test.cc
index d042402..f6da233 100644
--- a/src/tint/resolver/ptr_ref_validation_test.cc
+++ b/src/tint/resolver/ptr_ref_validation_test.cc
@@ -147,8 +147,8 @@
builtin::Access::kReadWrite, Binding(0_a), Group(0_a));
auto* expr = IndexAccessor(MemberAccessor(MemberAccessor(storage, "inner"), "arr"), 2_i);
- auto* ptr = Let(Source{{12, 34}}, "p", ty.pointer<i32>(builtin::AddressSpace::kStorage),
- AddressOf(expr));
+ auto* ptr =
+ Let(Source{{12, 34}}, "p", ty.ptr<i32>(builtin::AddressSpace::kStorage), AddressOf(expr));
WrapInFunction(ptr);
diff --git a/src/tint/resolver/resolver.cc b/src/tint/resolver/resolver.cc
index 8a57ec8..74a462a 100644
--- a/src/tint/resolver/resolver.cc
+++ b/src/tint/resolver/resolver.cc
@@ -559,7 +559,7 @@
return nullptr;
}
- auto* var_ty = builder_->create<type::Reference>(storage_ty, address_space, access);
+ auto* var_ty = builder_->create<type::Reference>(address_space, storage_ty, access);
if (!ApplyAddressSpaceUsageToType(address_space, var_ty,
var->type ? var->type->source : var->source)) {
@@ -1939,7 +1939,7 @@
// If we're extracting from a reference, we return a reference.
if (auto* ref = obj_raw_ty->As<type::Reference>()) {
- ty = builder_->create<type::Reference>(ty, ref->AddressSpace(), ref->Access());
+ ty = builder_->create<type::Reference>(ref->AddressSpace(), ty, ref->Access());
}
const constant::Value* val = nullptr;
@@ -2583,7 +2583,7 @@
access = access_expr->Value();
}
- auto* out = b.create<type::Pointer>(store_ty, address_space, access);
+ auto* out = b.create<type::Pointer>(address_space, store_ty, access);
if (!validator_.Pointer(tmpl_ident, out)) {
return nullptr;
}
@@ -3275,7 +3275,7 @@
// If we're extracting from a reference, we return a reference.
if (auto* ref = object_ty->As<type::Reference>()) {
- ty = builder_->create<type::Reference>(ty, ref->AddressSpace(), ref->Access());
+ ty = builder_->create<type::Reference>(ref->AddressSpace(), ty, ref->Access());
}
auto val = const_eval_.MemberAccess(object, member);
@@ -3344,7 +3344,7 @@
ty = vec->type();
// If we're extracting from a reference, we return a reference.
if (auto* ref = object_ty->As<type::Reference>()) {
- ty = builder_->create<type::Reference>(ty, ref->AddressSpace(), ref->Access());
+ ty = builder_->create<type::Reference>(ref->AddressSpace(), ty, ref->Access());
}
} else {
// The vector will have a number of components equal to the length of
@@ -3480,7 +3480,7 @@
return nullptr;
}
- ty = builder_->create<type::Pointer>(ref->StoreType(), ref->AddressSpace(),
+ ty = builder_->create<type::Pointer>(ref->AddressSpace(), ref->StoreType(),
ref->Access());
root_ident = expr->RootIdentifier();
@@ -3492,7 +3492,7 @@
case ast::UnaryOp::kIndirection:
if (auto* ptr = expr_ty->As<type::Pointer>()) {
- ty = builder_->create<type::Reference>(ptr->StoreType(), ptr->AddressSpace(),
+ ty = builder_->create<type::Reference>(ptr->AddressSpace(), ptr->StoreType(),
ptr->Access());
root_ident = expr->RootIdentifier();
} else {
diff --git a/src/tint/resolver/resolver_test.cc b/src/tint/resolver/resolver_test.cc
index dfe42ae..eab9b86 100644
--- a/src/tint/resolver/resolver_test.cc
+++ b/src/tint/resolver/resolver_test.cc
@@ -803,7 +803,7 @@
auto* v = Expr("v");
auto* p = Expr("p");
auto* v_decl = Decl(Var("v", ty.f32()));
- auto* p_decl = Decl(Let("p", ty.pointer<f32>(builtin::AddressSpace::kFunction), AddressOf(v)));
+ auto* p_decl = Decl(Let("p", ty.ptr<f32>(builtin::AddressSpace::kFunction), AddressOf(v)));
auto* assign = Assign(Deref(p), 1.23_f);
Func("my_func", utils::Empty, ty.void_(),
utils::Vector{
@@ -2299,10 +2299,10 @@
Func("helper",
utils::Vector{
- Param("sl", ty.pointer(ty.sampler(type::SamplerKind::kSampler),
- builtin::AddressSpace::kFunction)),
- Param("tl", ty.pointer(ty.sampled_texture(type::TextureDimension::k2d, ty.f32()),
- builtin::AddressSpace::kFunction)),
+ Param("sl", ty.ptr(builtin::AddressSpace::kFunction,
+ ty.sampler(type::SamplerKind::kSampler))),
+ Param("tl", ty.ptr(builtin::AddressSpace::kFunction,
+ ty.sampled_texture(type::TextureDimension::k2d, ty.f32()))),
},
ty.vec4<f32>(),
utils::Vector{
diff --git a/src/tint/resolver/resolver_test_helper.h b/src/tint/resolver/resolver_test_helper.h
index c4aec90..706ba89 100644
--- a/src/tint/resolver/resolver_test_helper.h
+++ b/src/tint/resolver/resolver_test_helper.h
@@ -628,13 +628,13 @@
/// @param b the ProgramBuilder
/// @return a new AST alias type
static inline ast::Type AST(ProgramBuilder& b) {
- return b.ty.pointer(DataType<T>::AST(b), builtin::AddressSpace::kPrivate,
- builtin::Access::kUndefined);
+ return b.ty.ptr(builtin::AddressSpace::kPrivate, DataType<T>::AST(b),
+ builtin::Access::kUndefined);
}
/// @param b the ProgramBuilder
/// @return the semantic aliased type
static inline const type::Type* Sem(ProgramBuilder& b) {
- return b.create<type::Pointer>(DataType<T>::Sem(b), builtin::AddressSpace::kPrivate,
+ return b.create<type::Pointer>(builtin::AddressSpace::kPrivate, DataType<T>::Sem(b),
builtin::Access::kReadWrite);
}
diff --git a/src/tint/resolver/root_identifier_test.cc b/src/tint/resolver/root_identifier_test.cc
index 0353ff5..4ff43cb 100644
--- a/src/tint/resolver/root_identifier_test.cc
+++ b/src/tint/resolver/root_identifier_test.cc
@@ -142,7 +142,7 @@
// {
// let b = a;
// }
- auto* param = Param("a", ty.pointer(ty.f32(), builtin::AddressSpace::kFunction));
+ auto* param = Param("a", ty.ptr(builtin::AddressSpace::kFunction, ty.f32()));
auto* expr_param = Expr(param);
auto* let = Let("b", expr_param);
auto* expr_let = Expr("b");
diff --git a/src/tint/resolver/type_validation_test.cc b/src/tint/resolver/type_validation_test.cc
index fe9622b..de79f85 100644
--- a/src/tint/resolver/type_validation_test.cc
+++ b/src/tint/resolver/type_validation_test.cc
@@ -807,8 +807,8 @@
TEST_F(ResolverTypeValidationTest, PtrToRuntimeArrayAsPointerParameter_Fail) {
// fn func(a : ptr<workgroup, array<u32>>) {}
- auto* param = Param("a", ty.pointer(Source{{56, 78}}, ty.array(Source{{12, 34}}, ty.i32()),
- builtin::AddressSpace::kWorkgroup));
+ auto* param = Param("a", ty.ptr(Source{{56, 78}}, builtin::AddressSpace::kWorkgroup,
+ ty.array(Source{{12, 34}}, ty.i32())));
Func("func", utils::Vector{param}, ty.void_(),
utils::Vector{
@@ -881,7 +881,7 @@
}
TEST_F(ResolverTypeValidationTest, ArrayOfNonStorableTypeWithStride) {
- auto ptr_ty = ty.pointer<u32>(Source{{12, 34}}, builtin::AddressSpace::kUniform);
+ auto ptr_ty = ty.ptr<u32>(Source{{12, 34}}, builtin::AddressSpace::kUniform);
GlobalVar("arr", ty.array(ptr_ty, 4_i, utils::Vector{Stride(16)}),
builtin::AddressSpace::kPrivate);
diff --git a/src/tint/resolver/uniformity_test.cc b/src/tint/resolver/uniformity_test.cc
index 0bf2436..e890bcb 100644
--- a/src/tint/resolver/uniformity_test.cc
+++ b/src/tint/resolver/uniformity_test.cc
@@ -5301,8 +5301,8 @@
}
foo_body.Push(b.Decl(b.Let("rhs", rhs_init)));
for (int i = 0; i < 255; i++) {
- params.Push(b.Param("p" + std::to_string(i),
- ty.pointer(ty.i32(), builtin::AddressSpace::kFunction)));
+ params.Push(
+ b.Param("p" + std::to_string(i), ty.ptr(builtin::AddressSpace::kFunction, ty.i32())));
if (i > 0) {
foo_body.Push(b.Assign(b.Deref("p" + std::to_string(i)), "rhs"));
}
diff --git a/src/tint/resolver/validation_test.cc b/src/tint/resolver/validation_test.cc
index 6b84d85..ca958ad 100644
--- a/src/tint/resolver/validation_test.cc
+++ b/src/tint/resolver/validation_test.cc
@@ -380,7 +380,7 @@
// let x: f32 = (*p).z;
// return x;
// }
- auto* p = Param("p", ty.pointer(ty.vec4<f32>(), builtin::AddressSpace::kFunction));
+ auto* p = Param("p", ty.ptr(builtin::AddressSpace::kFunction, ty.vec4<f32>()));
auto* star_p = Deref(p);
auto* accessor_expr = MemberAccessor(star_p, "z");
auto* x = Var("x", ty.f32(), accessor_expr);
@@ -397,7 +397,7 @@
// let x: f32 = *p.z;
// return x;
// }
- auto* p = Param("p", ty.pointer(ty.vec4<f32>(), builtin::AddressSpace::kFunction));
+ auto* p = Param("p", ty.ptr(builtin::AddressSpace::kFunction, ty.vec4<f32>()));
auto* accessor_expr = MemberAccessor(p, Ident(Source{{12, 34}}, "z"));
auto* star_p = Deref(accessor_expr);
auto* x = Var("x", ty.f32(), star_p);
@@ -1234,9 +1234,8 @@
TEST_F(ResolverTest, Expr_Initializer_Cast_Pointer) {
auto* vf = Var("vf", ty.f32());
- auto* c =
- Call(Source{{12, 34}}, ty.pointer<i32>(builtin::AddressSpace::kFunction), ExprList(vf));
- auto* ip = Let("ip", ty.pointer<i32>(builtin::AddressSpace::kFunction), c);
+ auto* c = Call(Source{{12, 34}}, ty.ptr<i32>(builtin::AddressSpace::kFunction), ExprList(vf));
+ auto* ip = Let("ip", ty.ptr<i32>(builtin::AddressSpace::kFunction), c);
WrapInFunction(Decl(vf), Decl(ip));
EXPECT_FALSE(r()->Resolve());
diff --git a/src/tint/resolver/validator_is_storeable_test.cc b/src/tint/resolver/validator_is_storeable_test.cc
index d01d21c..826ac57 100644
--- a/src/tint/resolver/validator_is_storeable_test.cc
+++ b/src/tint/resolver/validator_is_storeable_test.cc
@@ -78,7 +78,7 @@
}
TEST_F(ValidatorIsStorableTest, Pointer) {
- auto* ptr = create<type::Pointer>(create<type::I32>(), builtin::AddressSpace::kPrivate,
+ auto* ptr = create<type::Pointer>(builtin::AddressSpace::kPrivate, create<type::I32>(),
builtin::Access::kReadWrite);
EXPECT_FALSE(v()->IsStorable(ptr));
}
diff --git a/src/tint/resolver/value_constructor_validation_test.cc b/src/tint/resolver/value_constructor_validation_test.cc
index 772b9c1..3b7ad64 100644
--- a/src/tint/resolver/value_constructor_validation_test.cc
+++ b/src/tint/resolver/value_constructor_validation_test.cc
@@ -99,7 +99,7 @@
ASSERT_TRUE(r()->Resolve()) << r()->error();
auto* got = TypeOf(a_ident);
auto* expected =
- create<type::Reference>(params.create_rhs_sem_type(*this), builtin::AddressSpace::kFunction,
+ create<type::Reference>(builtin::AddressSpace::kFunction, params.create_rhs_sem_type(*this),
builtin::Access::kReadWrite);
ASSERT_EQ(got, expected) << "got: " << FriendlyName(got) << "\n"
<< "expected: " << FriendlyName(expected) << "\n";
@@ -154,7 +154,7 @@
ASSERT_TRUE(r()->Resolve()) << r()->error();
auto* got = TypeOf(a_ident);
auto* expected =
- create<type::Reference>(params.create_rhs_sem_type(*this), builtin::AddressSpace::kFunction,
+ create<type::Reference>(builtin::AddressSpace::kFunction, params.create_rhs_sem_type(*this),
builtin::Access::kReadWrite);
ASSERT_EQ(got, expected) << "got: " << FriendlyName(got) << "\n"
<< "expected: " << FriendlyName(expected) << "\n";
@@ -203,7 +203,7 @@
ASSERT_TRUE(r()->Resolve()) << r()->error();
auto* got = TypeOf(a_ident);
auto* expected =
- create<type::Reference>(params.create_rhs_sem_type(*this), builtin::AddressSpace::kFunction,
+ create<type::Reference>(builtin::AddressSpace::kFunction, params.create_rhs_sem_type(*this),
builtin::Access::kReadWrite);
ASSERT_EQ(got, expected) << "got: " << FriendlyName(got) << "\n"
<< "expected: " << FriendlyName(expected) << "\n";
diff --git a/src/tint/resolver/variable_test.cc b/src/tint/resolver/variable_test.cc
index 5daee08..7095cfe 100644
--- a/src/tint/resolver/variable_test.cc
+++ b/src/tint/resolver/variable_test.cc
@@ -421,7 +421,7 @@
auto* b = Let("b", ty.bool_(), b_c);
auto* s = Let("s", ty.Of(S), s_c);
auto* a = Let("a", ty.Of(A), a_c);
- auto* p = Let("p", ty.pointer<i32>(builtin::AddressSpace::kFunction), p_c);
+ auto* p = Let("p", ty.ptr<i32>(builtin::AddressSpace::kFunction), p_c);
Func("F", utils::Empty, ty.void_(),
utils::Vector{
diff --git a/src/tint/resolver/variable_validation_test.cc b/src/tint/resolver/variable_validation_test.cc
index 7f62e8e..9656574 100644
--- a/src/tint/resolver/variable_validation_test.cc
+++ b/src/tint/resolver/variable_validation_test.cc
@@ -132,7 +132,7 @@
// var i : i32;
// var p : pointer<function, i32> = &v;
auto* i = Var("i", ty.i32());
- auto* p = Var("a", ty.pointer<i32>(Source{{56, 78}}, builtin::AddressSpace::kFunction),
+ auto* p = Var("a", ty.ptr<i32>(Source{{56, 78}}, builtin::AddressSpace::kFunction),
builtin::AddressSpace::kUndefined, AddressOf(Source{{12, 34}}, "i"));
WrapInFunction(i, p);
@@ -227,7 +227,7 @@
// let b : ptr<function,f32> = a;
const auto priv = builtin::AddressSpace::kFunction;
auto* var_a = Var("a", ty.f32(), priv);
- auto* var_b = Let(Source{{12, 34}}, "b", ty.pointer<f32>(priv), Expr("a"));
+ auto* var_b = Let(Source{{12, 34}}, "b", ty.ptr<f32>(priv), Expr("a"));
WrapInFunction(var_a, var_b);
ASSERT_FALSE(r()->Resolve());
@@ -319,7 +319,7 @@
auto* expr = IndexAccessor(MemberAccessor(MemberAccessor(storage, "inner"), "arr"), 2_i);
auto* ptr = Let(Source{{12, 34}}, "p",
- ty.pointer<i32>(builtin::AddressSpace::kStorage, builtin::Access::kReadWrite),
+ ty.ptr<i32>(builtin::AddressSpace::kStorage, builtin::Access::kReadWrite),
AddressOf(expr));
WrapInFunction(ptr);
diff --git a/src/tint/type/manager.cc b/src/tint/type/manager.cc
index d9c8667..f5f382b 100644
--- a/src/tint/type/manager.cc
+++ b/src/tint/type/manager.cc
@@ -156,10 +156,10 @@
/* implicit stride */ elem_ty->Align());
}
-const type::Pointer* Manager::pointer(const type::Type* subtype,
- builtin::AddressSpace address_space,
- builtin::Access access) {
- return Get<type::Pointer>(subtype, address_space, access);
+const type::Pointer* Manager::ptr(builtin::AddressSpace address_space,
+ const type::Type* subtype,
+ builtin::Access access) {
+ return Get<type::Pointer>(address_space, subtype, access);
}
} // namespace tint::type
diff --git a/src/tint/type/manager.h b/src/tint/type/manager.h
index 513680e..a9bdbeb 100644
--- a/src/tint/type/manager.h
+++ b/src/tint/type/manager.h
@@ -319,13 +319,13 @@
}
}
- /// @param subtype the pointer subtype
/// @param address_space the address space
+ /// @param subtype the pointer subtype
/// @param access the access settings
/// @returns the pointer type
- const type::Pointer* pointer(const type::Type* subtype,
- builtin::AddressSpace address_space,
- builtin::Access access);
+ const type::Pointer* ptr(builtin::AddressSpace address_space,
+ const type::Type* subtype,
+ builtin::Access access);
/// @tparam SPACE the address space
/// @tparam T the storage type
@@ -335,7 +335,7 @@
typename T,
builtin::Access ACCESS = builtin::Access::kReadWrite>
const type::Pointer* ptr() {
- return pointer(Get<T>(), SPACE, ACCESS);
+ return ptr(SPACE, Get<T>(), ACCESS);
}
/// @returns an iterator to the beginning of the types
diff --git a/src/tint/type/pointer.cc b/src/tint/type/pointer.cc
index 636f8e5..95f4556 100644
--- a/src/tint/type/pointer.cc
+++ b/src/tint/type/pointer.cc
@@ -25,7 +25,7 @@
namespace tint::type {
-Pointer::Pointer(const Type* subtype, builtin::AddressSpace address_space, builtin::Access access)
+Pointer::Pointer(builtin::AddressSpace address_space, const Type* subtype, builtin::Access access)
: Base(
utils::Hash(utils::TypeInfo::Of<Pointer>().full_hashcode, address_space, subtype, access),
type::Flags{}),
@@ -59,7 +59,7 @@
Pointer* Pointer::Clone(CloneContext& ctx) const {
auto* ty = subtype_->Clone(ctx);
- return ctx.dst.mgr->Get<Pointer>(ty, address_space_, access_);
+ return ctx.dst.mgr->Get<Pointer>(address_space_, ty, access_);
}
} // namespace tint::type
diff --git a/src/tint/type/pointer.h b/src/tint/type/pointer.h
index 80626e9..e22db02 100644
--- a/src/tint/type/pointer.h
+++ b/src/tint/type/pointer.h
@@ -27,10 +27,10 @@
class Pointer final : public utils::Castable<Pointer, Type> {
public:
/// Constructor
- /// @param subtype the pointee type
/// @param address_space the address space of the pointer
+ /// @param subtype the pointee type
/// @param access the resolved access control of the reference
- Pointer(const Type* subtype, builtin::AddressSpace address_space, builtin::Access access);
+ Pointer(builtin::AddressSpace address_space, const Type* subtype, builtin::Access access);
/// Destructor
~Pointer() override;
diff --git a/src/tint/type/pointer_test.cc b/src/tint/type/pointer_test.cc
index 6399242..322fac5 100644
--- a/src/tint/type/pointer_test.cc
+++ b/src/tint/type/pointer_test.cc
@@ -22,16 +22,16 @@
using PointerTest = TestHelper;
TEST_F(PointerTest, Creation) {
- auto* a = create<Pointer>(create<I32>(), builtin::AddressSpace::kStorage,
+ auto* a = create<Pointer>(builtin::AddressSpace::kStorage, create<I32>(),
builtin::Access::kReadWrite);
- auto* b = create<Pointer>(create<I32>(), builtin::AddressSpace::kStorage,
+ auto* b = create<Pointer>(builtin::AddressSpace::kStorage, create<I32>(),
builtin::Access::kReadWrite);
- auto* c = create<Pointer>(create<F32>(), builtin::AddressSpace::kStorage,
+ auto* c = create<Pointer>(builtin::AddressSpace::kStorage, create<F32>(),
builtin::Access::kReadWrite);
- auto* d = create<Pointer>(create<I32>(), builtin::AddressSpace::kPrivate,
+ auto* d = create<Pointer>(builtin::AddressSpace::kPrivate, create<I32>(),
builtin::Access::kReadWrite);
auto* e =
- create<Pointer>(create<I32>(), builtin::AddressSpace::kStorage, builtin::Access::kRead);
+ create<Pointer>(builtin::AddressSpace::kStorage, create<I32>(), builtin::Access::kRead);
EXPECT_TRUE(a->StoreType()->Is<I32>());
EXPECT_EQ(a->AddressSpace(), builtin::AddressSpace::kStorage);
@@ -44,25 +44,25 @@
}
TEST_F(PointerTest, Hash) {
- auto* a = create<Pointer>(create<I32>(), builtin::AddressSpace::kStorage,
+ auto* a = create<Pointer>(builtin::AddressSpace::kStorage, create<I32>(),
builtin::Access::kReadWrite);
- auto* b = create<Pointer>(create<I32>(), builtin::AddressSpace::kStorage,
+ auto* b = create<Pointer>(builtin::AddressSpace::kStorage, create<I32>(),
builtin::Access::kReadWrite);
EXPECT_EQ(a->unique_hash, b->unique_hash);
}
TEST_F(PointerTest, Equals) {
- auto* a = create<Pointer>(create<I32>(), builtin::AddressSpace::kStorage,
+ auto* a = create<Pointer>(builtin::AddressSpace::kStorage, create<I32>(),
builtin::Access::kReadWrite);
- auto* b = create<Pointer>(create<I32>(), builtin::AddressSpace::kStorage,
+ auto* b = create<Pointer>(builtin::AddressSpace::kStorage, create<I32>(),
builtin::Access::kReadWrite);
- auto* c = create<Pointer>(create<F32>(), builtin::AddressSpace::kStorage,
+ auto* c = create<Pointer>(builtin::AddressSpace::kStorage, create<F32>(),
builtin::Access::kReadWrite);
- auto* d = create<Pointer>(create<I32>(), builtin::AddressSpace::kPrivate,
+ auto* d = create<Pointer>(builtin::AddressSpace::kPrivate, create<I32>(),
builtin::Access::kReadWrite);
auto* e =
- create<Pointer>(create<I32>(), builtin::AddressSpace::kStorage, builtin::Access::kRead);
+ create<Pointer>(builtin::AddressSpace::kStorage, create<I32>(), builtin::Access::kRead);
EXPECT_TRUE(a->Equals(*b));
EXPECT_FALSE(a->Equals(*c));
@@ -73,18 +73,18 @@
TEST_F(PointerTest, FriendlyName) {
auto* r =
- create<Pointer>(create<I32>(), builtin::AddressSpace::kUndefined, builtin::Access::kRead);
+ create<Pointer>(builtin::AddressSpace::kUndefined, create<I32>(), builtin::Access::kRead);
EXPECT_EQ(r->FriendlyName(), "ptr<i32, read>");
}
TEST_F(PointerTest, FriendlyNameWithAddressSpace) {
auto* r =
- create<Pointer>(create<I32>(), builtin::AddressSpace::kWorkgroup, builtin::Access::kRead);
+ create<Pointer>(builtin::AddressSpace::kWorkgroup, create<I32>(), builtin::Access::kRead);
EXPECT_EQ(r->FriendlyName(), "ptr<workgroup, i32, read>");
}
TEST_F(PointerTest, Clone) {
- auto* a = create<Pointer>(create<I32>(), builtin::AddressSpace::kStorage,
+ auto* a = create<Pointer>(builtin::AddressSpace::kStorage, create<I32>(),
builtin::Access::kReadWrite);
type::Manager mgr;
diff --git a/src/tint/type/reference.cc b/src/tint/type/reference.cc
index e0fd92a..a8d26a5 100644
--- a/src/tint/type/reference.cc
+++ b/src/tint/type/reference.cc
@@ -24,8 +24,8 @@
namespace tint::type {
-Reference::Reference(const Type* subtype,
- builtin::AddressSpace address_space,
+Reference::Reference(builtin::AddressSpace address_space,
+ const Type* subtype,
builtin::Access access)
: Base(utils::Hash(utils::TypeInfo::Of<Reference>().full_hashcode,
address_space,
@@ -62,7 +62,7 @@
Reference* Reference::Clone(CloneContext& ctx) const {
auto* ty = subtype_->Clone(ctx);
- return ctx.dst.mgr->Get<Reference>(ty, address_space_, access_);
+ return ctx.dst.mgr->Get<Reference>(address_space_, ty, access_);
}
} // namespace tint::type
diff --git a/src/tint/type/reference.h b/src/tint/type/reference.h
index 617b2ca..4a1de4d 100644
--- a/src/tint/type/reference.h
+++ b/src/tint/type/reference.h
@@ -27,10 +27,10 @@
class Reference final : public utils::Castable<Reference, Type> {
public:
/// Constructor
- /// @param subtype the pointee type
/// @param address_space the address space of the reference
+ /// @param subtype the pointee type
/// @param access the resolved access control of the reference
- Reference(const Type* subtype, builtin::AddressSpace address_space, builtin::Access access);
+ Reference(builtin::AddressSpace address_space, const Type* subtype, builtin::Access access);
/// Destructor
~Reference() override;
diff --git a/src/tint/type/reference_test.cc b/src/tint/type/reference_test.cc
index a34ffa1..608e2ee 100644
--- a/src/tint/type/reference_test.cc
+++ b/src/tint/type/reference_test.cc
@@ -22,16 +22,16 @@
using ReferenceTest = TestHelper;
TEST_F(ReferenceTest, Creation) {
- auto* a = create<Reference>(create<I32>(), builtin::AddressSpace::kStorage,
+ auto* a = create<Reference>(builtin::AddressSpace::kStorage, create<I32>(),
builtin::Access::kReadWrite);
- auto* b = create<Reference>(create<I32>(), builtin::AddressSpace::kStorage,
+ auto* b = create<Reference>(builtin::AddressSpace::kStorage, create<I32>(),
builtin::Access::kReadWrite);
- auto* c = create<Reference>(create<F32>(), builtin::AddressSpace::kStorage,
+ auto* c = create<Reference>(builtin::AddressSpace::kStorage, create<F32>(),
builtin::Access::kReadWrite);
- auto* d = create<Reference>(create<I32>(), builtin::AddressSpace::kPrivate,
+ auto* d = create<Reference>(builtin::AddressSpace::kPrivate, create<I32>(),
builtin::Access::kReadWrite);
auto* e =
- create<Reference>(create<I32>(), builtin::AddressSpace::kStorage, builtin::Access::kRead);
+ create<Reference>(builtin::AddressSpace::kStorage, create<I32>(), builtin::Access::kRead);
EXPECT_TRUE(a->StoreType()->Is<I32>());
EXPECT_EQ(a->AddressSpace(), builtin::AddressSpace::kStorage);
@@ -44,25 +44,25 @@
}
TEST_F(ReferenceTest, Hash) {
- auto* a = create<Reference>(create<I32>(), builtin::AddressSpace::kStorage,
+ auto* a = create<Reference>(builtin::AddressSpace::kStorage, create<I32>(),
builtin::Access::kReadWrite);
- auto* b = create<Reference>(create<I32>(), builtin::AddressSpace::kStorage,
+ auto* b = create<Reference>(builtin::AddressSpace::kStorage, create<I32>(),
builtin::Access::kReadWrite);
EXPECT_EQ(a->unique_hash, b->unique_hash);
}
TEST_F(ReferenceTest, Equals) {
- auto* a = create<Reference>(create<I32>(), builtin::AddressSpace::kStorage,
+ auto* a = create<Reference>(builtin::AddressSpace::kStorage, create<I32>(),
builtin::Access::kReadWrite);
- auto* b = create<Reference>(create<I32>(), builtin::AddressSpace::kStorage,
+ auto* b = create<Reference>(builtin::AddressSpace::kStorage, create<I32>(),
builtin::Access::kReadWrite);
- auto* c = create<Reference>(create<F32>(), builtin::AddressSpace::kStorage,
+ auto* c = create<Reference>(builtin::AddressSpace::kStorage, create<F32>(),
builtin::Access::kReadWrite);
- auto* d = create<Reference>(create<I32>(), builtin::AddressSpace::kPrivate,
+ auto* d = create<Reference>(builtin::AddressSpace::kPrivate, create<I32>(),
builtin::Access::kReadWrite);
auto* e =
- create<Reference>(create<I32>(), builtin::AddressSpace::kStorage, builtin::Access::kRead);
+ create<Reference>(builtin::AddressSpace::kStorage, create<I32>(), builtin::Access::kRead);
EXPECT_TRUE(a->Equals(*b));
EXPECT_FALSE(a->Equals(*c));
@@ -73,18 +73,18 @@
TEST_F(ReferenceTest, FriendlyName) {
auto* r =
- create<Reference>(create<I32>(), builtin::AddressSpace::kUndefined, builtin::Access::kRead);
+ create<Reference>(builtin::AddressSpace::kUndefined, create<I32>(), builtin::Access::kRead);
EXPECT_EQ(r->FriendlyName(), "ref<i32, read>");
}
TEST_F(ReferenceTest, FriendlyNameWithAddressSpace) {
auto* r =
- create<Reference>(create<I32>(), builtin::AddressSpace::kWorkgroup, builtin::Access::kRead);
+ create<Reference>(builtin::AddressSpace::kWorkgroup, create<I32>(), builtin::Access::kRead);
EXPECT_EQ(r->FriendlyName(), "ref<workgroup, i32, read>");
}
TEST_F(ReferenceTest, Clone) {
- auto* a = create<Reference>(create<I32>(), builtin::AddressSpace::kStorage,
+ auto* a = create<Reference>(builtin::AddressSpace::kStorage, create<I32>(),
builtin::Access::kReadWrite);
type::Manager mgr;
diff --git a/src/tint/type/type_test.cc b/src/tint/type/type_test.cc
index 407c181..f260675 100644
--- a/src/tint/type/type_test.cc
+++ b/src/tint/type/type_test.cc
@@ -44,7 +44,7 @@
const Matrix* mat4x3_f16 = create<Matrix>(vec3_f16, 4u);
const Matrix* mat4x3_af = create<Matrix>(vec3_af, 4u);
const Reference* ref_u32 =
- create<Reference>(u32, builtin::AddressSpace::kPrivate, builtin::Access::kReadWrite);
+ create<Reference>(builtin::AddressSpace::kPrivate, u32, builtin::Access::kReadWrite);
const Struct* str_f32 = create<Struct>(Sym("str_f32"),
utils::Vector{
create<StructMember>(
diff --git a/src/tint/writer/glsl/generator_impl_function_test.cc b/src/tint/writer/glsl/generator_impl_function_test.cc
index a0bfef9..34375f7 100644
--- a/src/tint/writer/glsl/generator_impl_function_test.cc
+++ b/src/tint/writer/glsl/generator_impl_function_test.cc
@@ -110,8 +110,8 @@
// fn f(foo : ptr<function, f32>) -> f32 {
// return *foo;
// }
- Func("f", utils::Vector{Param("foo", ty.pointer<f32>(builtin::AddressSpace::kFunction))},
- ty.f32(), utils::Vector{Return(Deref("foo"))});
+ Func("f", utils::Vector{Param("foo", ty.ptr<f32>(builtin::AddressSpace::kFunction))}, ty.f32(),
+ utils::Vector{Return(Deref("foo"))});
GeneratorImpl& gen = SanitizeAndBuild();
gen.Generate();
diff --git a/src/tint/writer/glsl/generator_impl_sanitizer_test.cc b/src/tint/writer/glsl/generator_impl_sanitizer_test.cc
index 5a690a5..fdd216f 100644
--- a/src/tint/writer/glsl/generator_impl_sanitizer_test.cc
+++ b/src/tint/writer/glsl/generator_impl_sanitizer_test.cc
@@ -235,7 +235,7 @@
// let p : ptr<function, i32> = &v;
// let x : i32 = *p;
auto* v = Var("v", ty.i32());
- auto* p = Let("p", ty.pointer<i32>(builtin::AddressSpace::kFunction), AddressOf(v));
+ auto* p = Let("p", ty.ptr<i32>(builtin::AddressSpace::kFunction), AddressOf(v));
auto* x = Var("x", ty.i32(), Deref(p));
Func("main", utils::Empty, ty.void_(),
@@ -276,12 +276,11 @@
// let vp : ptr<function, vec4<f32>> = &(*mp)[2i];
// let v : vec4<f32> = *vp;
auto* a = Var("a", ty.array(ty.mat4x4<f32>(), 4_u));
- auto* ap =
- Let("ap", ty.pointer(ty.array(ty.mat4x4<f32>(), 4_u), builtin::AddressSpace::kFunction),
- AddressOf(a));
- auto* mp = Let("mp", ty.pointer(ty.mat4x4<f32>(), builtin::AddressSpace::kFunction),
+ auto* ap = Let("ap", ty.ptr(builtin::AddressSpace::kFunction, ty.array(ty.mat4x4<f32>(), 4_u)),
+ AddressOf(a));
+ auto* mp = Let("mp", ty.ptr(builtin::AddressSpace::kFunction, ty.mat4x4<f32>()),
AddressOf(IndexAccessor(Deref(ap), 3_i)));
- auto* vp = Let("vp", ty.pointer(ty.vec4<f32>(), builtin::AddressSpace::kFunction),
+ auto* vp = Let("vp", ty.ptr(builtin::AddressSpace::kFunction, ty.vec4<f32>()),
AddressOf(IndexAccessor(Deref(mp), 2_i)));
auto* v = Var("v", ty.vec4<f32>(), Deref(vp));
diff --git a/src/tint/writer/hlsl/generator_impl_function_test.cc b/src/tint/writer/hlsl/generator_impl_function_test.cc
index 17df895..37d94c3 100644
--- a/src/tint/writer/hlsl/generator_impl_function_test.cc
+++ b/src/tint/writer/hlsl/generator_impl_function_test.cc
@@ -101,8 +101,8 @@
// fn f(foo : ptr<function, f32>) -> f32 {
// return *foo;
// }
- Func("f", utils::Vector{Param("foo", ty.pointer<f32>(builtin::AddressSpace::kFunction))},
- ty.f32(), utils::Vector{Return(Deref("foo"))});
+ Func("f", utils::Vector{Param("foo", ty.ptr<f32>(builtin::AddressSpace::kFunction))}, ty.f32(),
+ utils::Vector{Return(Deref("foo"))});
GeneratorImpl& gen = SanitizeAndBuild();
diff --git a/src/tint/writer/hlsl/generator_impl_sanitizer_test.cc b/src/tint/writer/hlsl/generator_impl_sanitizer_test.cc
index c511a83..b1fef10 100644
--- a/src/tint/writer/hlsl/generator_impl_sanitizer_test.cc
+++ b/src/tint/writer/hlsl/generator_impl_sanitizer_test.cc
@@ -242,7 +242,7 @@
// let p : ptr<function, i32> = &v;
// let x : i32 = *p;
auto* v = Var("v", ty.i32());
- auto* p = Let("p", ty.pointer<i32>(builtin::AddressSpace::kFunction), AddressOf(v));
+ auto* p = Let("p", ty.ptr<i32>(builtin::AddressSpace::kFunction), AddressOf(v));
auto* x = Var("x", ty.i32(), Deref(p));
Func("main", utils::Empty, ty.void_(),
@@ -276,12 +276,11 @@
// let vp : ptr<function, vec4<f32>> = &(*mp)[2i];
// let v : vec4<f32> = *vp;
auto* a = Var("a", ty.array(ty.mat4x4<f32>(), 4_u));
- auto* ap =
- Let("ap", ty.pointer(ty.array(ty.mat4x4<f32>(), 4_u), builtin::AddressSpace::kFunction),
- AddressOf(a));
- auto* mp = Let("mp", ty.pointer(ty.mat4x4<f32>(), builtin::AddressSpace::kFunction),
+ auto* ap = Let("ap", ty.ptr(builtin::AddressSpace::kFunction, ty.array(ty.mat4x4<f32>(), 4_u)),
+ AddressOf(a));
+ auto* mp = Let("mp", ty.ptr(builtin::AddressSpace::kFunction, ty.mat4x4<f32>()),
AddressOf(IndexAccessor(Deref(ap), 3_i)));
- auto* vp = Let("vp", ty.pointer(ty.vec4<f32>(), builtin::AddressSpace::kFunction),
+ auto* vp = Let("vp", ty.ptr(builtin::AddressSpace::kFunction, ty.vec4<f32>()),
AddressOf(IndexAccessor(Deref(mp), 2_i)));
auto* v = Var("v", ty.vec4<f32>(), Deref(vp));
diff --git a/src/tint/writer/msl/generator_impl_type_test.cc b/src/tint/writer/msl/generator_impl_type_test.cc
index 3b9b652..52d02ee 100644
--- a/src/tint/writer/msl/generator_impl_type_test.cc
+++ b/src/tint/writer/msl/generator_impl_type_test.cc
@@ -214,7 +214,7 @@
TEST_F(MslGeneratorImplTest, EmitType_Pointer) {
auto* f32 = create<type::F32>();
auto* p =
- create<type::Pointer>(f32, builtin::AddressSpace::kWorkgroup, builtin::Access::kReadWrite);
+ create<type::Pointer>(builtin::AddressSpace::kWorkgroup, f32, builtin::Access::kReadWrite);
GeneratorImpl& gen = Build();
diff --git a/src/tint/writer/spirv/builder.cc b/src/tint/writer/spirv/builder.cc
index 663fde1..a0ce6f0 100644
--- a/src/tint/writer/spirv/builder.cc
+++ b/src/tint/writer/spirv/builder.cc
@@ -1855,8 +1855,8 @@
uint32_t Builder::GenerateSplat(uint32_t scalar_id, const type::Type* vec_type) {
// Create a new vector to splat scalar into
auto splat_vector = result_op();
- auto* splat_vector_type = builder_.create<type::Pointer>(
- vec_type, builtin::AddressSpace::kFunction, builtin::Access::kReadWrite);
+ auto* splat_vector_type = builder_.create<type::Pointer>(builtin::AddressSpace::kFunction,
+ vec_type, builtin::Access::kReadWrite);
push_function_var({Operand(GenerateTypeIfNeeded(splat_vector_type)), splat_vector,
U32Operand(ConvertAddressSpace(builtin::AddressSpace::kFunction)),
Operand(GenerateConstantNullIfNeeded(vec_type))});
@@ -3620,10 +3620,10 @@
// references are not legal in WGSL, so only considering the top-level type is
// fine.
if (auto* ptr = type->As<type::Pointer>()) {
- type = builder_.create<type::Pointer>(ptr->StoreType(), ptr->AddressSpace(),
+ type = builder_.create<type::Pointer>(ptr->AddressSpace(), ptr->StoreType(),
builtin::Access::kReadWrite);
} else if (auto* ref = type->As<type::Reference>()) {
- type = builder_.create<type::Pointer>(ref->StoreType(), ref->AddressSpace(),
+ type = builder_.create<type::Pointer>(ref->AddressSpace(), ref->StoreType(),
builtin::Access::kReadWrite);
}
diff --git a/src/tint/writer/spirv/builder_type_test.cc b/src/tint/writer/spirv/builder_type_test.cc
index 87c4cf3..0bf5280 100644
--- a/src/tint/writer/spirv/builder_type_test.cc
+++ b/src/tint/writer/spirv/builder_type_test.cc
@@ -297,7 +297,7 @@
TEST_F(BuilderTest_Type, GeneratePtr) {
auto* i32 = create<type::I32>();
auto* ptr =
- create<type::Pointer>(i32, builtin::AddressSpace::kOut, builtin::Access::kReadWrite);
+ create<type::Pointer>(builtin::AddressSpace::kOut, i32, builtin::Access::kReadWrite);
spirv::Builder& b = Build();
@@ -313,7 +313,7 @@
TEST_F(BuilderTest_Type, ReturnsGeneratedPtr) {
auto* i32 = create<type::I32>();
auto* ptr =
- create<type::Pointer>(i32, builtin::AddressSpace::kOut, builtin::Access::kReadWrite);
+ create<type::Pointer>(builtin::AddressSpace::kOut, i32, builtin::Access::kReadWrite);
spirv::Builder& b = Build();
diff --git a/src/tint/writer/spirv/ir/generator_impl_ir_access_test.cc b/src/tint/writer/spirv/ir/generator_impl_ir_access_test.cc
index 3a2ceb4..4318147 100644
--- a/src/tint/writer/spirv/ir/generator_impl_ir_access_test.cc
+++ b/src/tint/writer/spirv/ir/generator_impl_ir_access_test.cc
@@ -22,7 +22,7 @@
class SpvGeneratorImplTest_Access : public SpvGeneratorImplTest {
protected:
const type::Pointer* ptr(const type::Type* elem) {
- return ty.pointer(elem, builtin::AddressSpace::kFunction, builtin::Access::kReadWrite);
+ return ty.ptr(builtin::AddressSpace::kFunction, elem, builtin::Access::kReadWrite);
}
};
diff --git a/src/tint/writer/spirv/ir/generator_impl_ir_var_test.cc b/src/tint/writer/spirv/ir/generator_impl_ir_var_test.cc
index 82e24f7..5f161be 100644
--- a/src/tint/writer/spirv/ir/generator_impl_ir_var_test.cc
+++ b/src/tint/writer/spirv/ir/generator_impl_ir_var_test.cc
@@ -24,7 +24,7 @@
auto* func = b.Function("foo", ty.void_());
func->StartTarget()->SetInstructions(
- {b.Var(ty.pointer(ty.i32(), builtin::AddressSpace::kFunction, builtin::Access::kReadWrite)),
+ {b.Var(ty.ptr(builtin::AddressSpace::kFunction, ty.i32(), builtin::Access::kReadWrite)),
b.Return(func)});
ASSERT_TRUE(IRIsValid()) << Error();
@@ -47,7 +47,7 @@
auto* func = b.Function("foo", ty.void_());
auto* v =
- b.Var(ty.pointer(ty.i32(), builtin::AddressSpace::kFunction, builtin::Access::kReadWrite));
+ b.Var(ty.ptr(builtin::AddressSpace::kFunction, ty.i32(), builtin::Access::kReadWrite));
v->SetInitializer(b.Constant(42_i));
func->StartTarget()->SetInstructions({v, b.Return(func)});
@@ -74,7 +74,7 @@
auto* func = b.Function("foo", ty.void_());
auto* v =
- b.Var(ty.pointer(ty.i32(), builtin::AddressSpace::kFunction, builtin::Access::kReadWrite));
+ b.Var(ty.ptr(builtin::AddressSpace::kFunction, ty.i32(), builtin::Access::kReadWrite));
func->StartTarget()->SetInstructions({v, b.Return(func)});
mod.SetName(v, "myvar");
@@ -99,7 +99,7 @@
auto* func = b.Function("foo", ty.void_());
auto* v =
- b.Var(ty.pointer(ty.i32(), builtin::AddressSpace::kFunction, builtin::Access::kReadWrite));
+ b.Var(ty.ptr(builtin::AddressSpace::kFunction, ty.i32(), builtin::Access::kReadWrite));
v->SetInitializer(b.Constant(42_i));
auto* i = b.If(true);
@@ -141,7 +141,7 @@
auto* store_ty = ty.i32();
auto* v =
- b.Var(ty.pointer(store_ty, builtin::AddressSpace::kFunction, builtin::Access::kReadWrite));
+ b.Var(ty.ptr(builtin::AddressSpace::kFunction, store_ty, builtin::Access::kReadWrite));
func->StartTarget()->SetInstructions({v, b.Load(v), b.Return(func)});
ASSERT_TRUE(IRIsValid()) << Error();
@@ -165,7 +165,7 @@
auto* func = b.Function("foo", ty.void_());
auto* v =
- b.Var(ty.pointer(ty.i32(), builtin::AddressSpace::kFunction, builtin::Access::kReadWrite));
+ b.Var(ty.ptr(builtin::AddressSpace::kFunction, ty.i32(), builtin::Access::kReadWrite));
func->StartTarget()->SetInstructions({v, b.Store(v, 42_i), b.Return(func)});
ASSERT_TRUE(IRIsValid()) << Error();
@@ -187,8 +187,8 @@
}
TEST_F(SpvGeneratorImplTest, PrivateVar_NoInit) {
- b.RootBlock()->SetInstructions({b.Var(
- ty.pointer(ty.i32(), builtin::AddressSpace::kPrivate, builtin::Access::kReadWrite))});
+ b.RootBlock()->SetInstructions(
+ {b.Var(ty.ptr(builtin::AddressSpace::kPrivate, ty.i32(), builtin::Access::kReadWrite))});
ASSERT_TRUE(generator_.Generate()) << generator_.Diagnostics().str();
EXPECT_EQ(DumpModule(generator_.Module()), R"(OpCapability Shader
@@ -209,8 +209,7 @@
}
TEST_F(SpvGeneratorImplTest, PrivateVar_WithInit) {
- auto* v =
- b.Var(ty.pointer(ty.i32(), builtin::AddressSpace::kPrivate, builtin::Access::kReadWrite));
+ auto* v = b.Var(ty.ptr(builtin::AddressSpace::kPrivate, ty.i32(), builtin::Access::kReadWrite));
b.RootBlock()->SetInstructions({v});
v->SetInitializer(b.Constant(42_i));
@@ -234,8 +233,7 @@
}
TEST_F(SpvGeneratorImplTest, PrivateVar_Name) {
- auto* v =
- b.Var(ty.pointer(ty.i32(), builtin::AddressSpace::kPrivate, builtin::Access::kReadWrite));
+ auto* v = b.Var(ty.ptr(builtin::AddressSpace::kPrivate, ty.i32(), builtin::Access::kReadWrite));
b.RootBlock()->SetInstructions({v});
v->SetInitializer(b.Constant(42_i));
mod.SetName(v, "myvar");
@@ -265,8 +263,7 @@
mod.functions.Push(func);
auto* store_ty = ty.i32();
- auto* v =
- b.Var(ty.pointer(store_ty, builtin::AddressSpace::kPrivate, builtin::Access::kReadWrite));
+ auto* v = b.Var(ty.ptr(builtin::AddressSpace::kPrivate, store_ty, builtin::Access::kReadWrite));
b.RootBlock()->SetInstructions({v});
v->SetInitializer(b.Constant(42_i));
@@ -299,8 +296,8 @@
}
TEST_F(SpvGeneratorImplTest, WorkgroupVar) {
- b.RootBlock()->SetInstructions({b.Var(
- ty.pointer(ty.i32(), builtin::AddressSpace::kWorkgroup, builtin::Access::kReadWrite))});
+ b.RootBlock()->SetInstructions(
+ {b.Var(ty.ptr(builtin::AddressSpace::kWorkgroup, ty.i32(), builtin::Access::kReadWrite))});
ASSERT_TRUE(generator_.Generate()) << generator_.Diagnostics().str();
EXPECT_EQ(DumpModule(generator_.Module()), R"(OpCapability Shader
@@ -322,7 +319,7 @@
TEST_F(SpvGeneratorImplTest, WorkgroupVar_Name) {
auto* v =
- b.Var(ty.pointer(ty.i32(), builtin::AddressSpace::kWorkgroup, builtin::Access::kReadWrite));
+ b.Var(ty.ptr(builtin::AddressSpace::kWorkgroup, ty.i32(), builtin::Access::kReadWrite));
b.RootBlock()->SetInstructions({v});
mod.SetName(v, "myvar");
@@ -352,7 +349,7 @@
auto* store_ty = ty.i32();
auto* v =
- b.Var(ty.pointer(store_ty, builtin::AddressSpace::kWorkgroup, builtin::Access::kReadWrite));
+ b.Var(ty.ptr(builtin::AddressSpace::kWorkgroup, store_ty, builtin::Access::kReadWrite));
b.RootBlock()->SetInstructions({v});
auto* load = b.Load(v);
@@ -383,8 +380,8 @@
}
TEST_F(SpvGeneratorImplTest, WorkgroupVar_ZeroInitializeWithExtension) {
- b.RootBlock()->SetInstructions({b.Var(
- ty.pointer(ty.i32(), builtin::AddressSpace::kWorkgroup, builtin::Access::kReadWrite))});
+ b.RootBlock()->SetInstructions(
+ {b.Var(ty.ptr(builtin::AddressSpace::kWorkgroup, ty.i32(), builtin::Access::kReadWrite))});
// Create a generator with the zero_init_workgroup_memory flag set to `true`.
spirv::GeneratorImplIr gen(&mod, true);
@@ -408,8 +405,7 @@
}
TEST_F(SpvGeneratorImplTest, StorageVar) {
- auto* v =
- b.Var(ty.pointer(ty.i32(), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite));
+ auto* v = b.Var(ty.ptr(builtin::AddressSpace::kStorage, ty.i32(), builtin::Access::kReadWrite));
v->SetBindingPoint(0, 0);
b.RootBlock()->SetInstructions({v});
@@ -439,8 +435,7 @@
}
TEST_F(SpvGeneratorImplTest, StorageVar_Name) {
- auto* v =
- b.Var(ty.pointer(ty.i32(), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite));
+ auto* v = b.Var(ty.ptr(builtin::AddressSpace::kStorage, ty.i32(), builtin::Access::kReadWrite));
v->SetBindingPoint(0, 0);
b.RootBlock()->SetInstructions({v});
mod.SetName(v, "myvar");
@@ -471,8 +466,7 @@
}
TEST_F(SpvGeneratorImplTest, StorageVar_LoadAndStore) {
- auto* v =
- b.Var(ty.pointer(ty.i32(), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite));
+ auto* v = b.Var(ty.ptr(builtin::AddressSpace::kStorage, ty.i32(), builtin::Access::kReadWrite));
v->SetBindingPoint(0, 0);
b.RootBlock()->SetInstructions({v});
@@ -521,8 +515,7 @@
}
TEST_F(SpvGeneratorImplTest, UniformVar) {
- auto* v =
- b.Var(ty.pointer(ty.i32(), builtin::AddressSpace::kUniform, builtin::Access::kReadWrite));
+ auto* v = b.Var(ty.ptr(builtin::AddressSpace::kUniform, ty.i32(), builtin::Access::kReadWrite));
v->SetBindingPoint(0, 0);
b.RootBlock()->SetInstructions({v});
@@ -552,8 +545,7 @@
}
TEST_F(SpvGeneratorImplTest, UniformVar_Name) {
- auto* v =
- b.Var(ty.pointer(ty.i32(), builtin::AddressSpace::kUniform, builtin::Access::kReadWrite));
+ auto* v = b.Var(ty.ptr(builtin::AddressSpace::kUniform, ty.i32(), builtin::Access::kReadWrite));
v->SetBindingPoint(0, 0);
b.RootBlock()->SetInstructions({v});
mod.SetName(v, "myvar");
@@ -584,8 +576,7 @@
}
TEST_F(SpvGeneratorImplTest, UniformVar_Load) {
- auto* v =
- b.Var(ty.pointer(ty.i32(), builtin::AddressSpace::kUniform, builtin::Access::kReadWrite));
+ auto* v = b.Var(ty.ptr(builtin::AddressSpace::kUniform, ty.i32(), builtin::Access::kReadWrite));
v->SetBindingPoint(0, 0);
b.RootBlock()->SetInstructions({v});
diff --git a/src/tint/writer/wgsl/generator_impl_type_test.cc b/src/tint/writer/wgsl/generator_impl_type_test.cc
index 9bf9a4c..cb790cb 100644
--- a/src/tint/writer/wgsl/generator_impl_type_test.cc
+++ b/src/tint/writer/wgsl/generator_impl_type_test.cc
@@ -146,8 +146,7 @@
}
TEST_F(WgslGeneratorImplTest, EmitType_Pointer) {
- auto type =
- Alias("make_type_reachable", ty.pointer<f32>(builtin::AddressSpace::kWorkgroup))->type;
+ auto type = Alias("make_type_reachable", ty.ptr<f32>(builtin::AddressSpace::kWorkgroup))->type;
GeneratorImpl& gen = Build();
@@ -159,7 +158,7 @@
TEST_F(WgslGeneratorImplTest, EmitType_PointerAccessMode) {
auto type = Alias("make_type_reachable",
- ty.pointer<f32>(builtin::AddressSpace::kStorage, builtin::Access::kReadWrite))
+ ty.ptr<f32>(builtin::AddressSpace::kStorage, builtin::Access::kReadWrite))
->type;
GeneratorImpl& gen = Build();