diff --git a/src/tint/BUILD.gn b/src/tint/BUILD.gn index b7022b300d..58749a7ddc 100644 --- a/src/tint/BUILD.gn +++ b/src/tint/BUILD.gn @@ -695,6 +695,8 @@ libtint_source_set("libtint_builtins_src") { sources = [ "builtin/access.cc", "builtin/access.h", + "builtin/address_space.cc", + "builtin/address_space.h", "builtin/builtin_value.cc", "builtin/builtin_value.h", "builtin/extension.cc", @@ -711,8 +713,6 @@ libtint_source_set("libtint_type_src") { "type/abstract_int.h", "type/abstract_numeric.cc", "type/abstract_numeric.h", - "type/address_space.cc", - "type/address_space.h", "type/array.cc", "type/array.h", "type/array_count.cc", @@ -1295,6 +1295,7 @@ if (tint_build_unittests) { tint_unittests_source_set("tint_unittests_builtins_src") { sources = [ "builtin/access_test.cc", + "builtin/address_space_test.cc", "builtin/builtin_value_test.cc", "builtin/extension_test.cc", ] @@ -1413,7 +1414,6 @@ if (tint_build_unittests) { tint_unittests_source_set("tint_unittests_type_src") { sources = [ - "type/address_space_test.cc", "type/atomic_test.cc", "type/bool_test.cc", "type/builtin_test.cc", @@ -1438,7 +1438,10 @@ if (tint_build_unittests) { "type/u32_test.cc", "type/vector_test.cc", ] - deps = [ ":libtint_base_src" ] + deps = [ + ":libtint_base_src", + ":libtint_builtins_src", + ] } tint_unittests_source_set("tint_unittests_text_src") { diff --git a/src/tint/CMakeLists.txt b/src/tint/CMakeLists.txt index 149505d0d8..83ee2560d9 100644 --- a/src/tint/CMakeLists.txt +++ b/src/tint/CMakeLists.txt @@ -549,6 +549,7 @@ list(APPEND TINT_LIB_SRCS ) tint_generated(builtin/access BENCH TEST) +tint_generated(builtin/address_space BENCH TEST) tint_generated(builtin/builtin_value BENCH TEST) tint_generated(builtin/extension BENCH TEST) tint_generated(ast/diagnostic_control BENCH TEST) @@ -556,7 +557,6 @@ tint_generated(ast/interpolate_attribute BENCH TEST) tint_generated(resolver/init_conv_intrinsic) tint_generated(sem/builtin_type) tint_generated(sem/parameter_usage) -tint_generated(type/address_space BENCH TEST) tint_generated(type/builtin BENCH TEST) tint_generated(type/texel_format BENCH TEST) diff --git a/src/tint/ast/module_test.cc b/src/tint/ast/module_test.cc index 24faaee434..d80033d76c 100644 --- a/src/tint/ast/module_test.cc +++ b/src/tint/ast/module_test.cc @@ -73,7 +73,7 @@ TEST_F(ModuleTest, Assert_DifferentProgramID_GlobalVariable) { { ProgramBuilder b1; ProgramBuilder b2; - b1.AST().AddGlobalVariable(b2.Var("var", b2.ty.i32(), type::AddressSpace::kPrivate)); + b1.AST().AddGlobalVariable(b2.Var("var", b2.ty.i32(), builtin::AddressSpace::kPrivate)); }, "internal compiler error"); } @@ -93,7 +93,7 @@ TEST_F(ModuleTest, CloneOrder) { ProgramBuilder b; b.Func("F", {}, b.ty.void_(), {}); b.Alias("A", b.ty.u32()); - b.GlobalVar("V", b.ty.i32(), type::AddressSpace::kPrivate); + b.GlobalVar("V", b.ty.i32(), builtin::AddressSpace::kPrivate); return Program(std::move(b)); }(); diff --git a/src/tint/ast/variable.h b/src/tint/ast/variable.h index 78e3b758fe..f8a17a3dcc 100644 --- a/src/tint/ast/variable.h +++ b/src/tint/ast/variable.h @@ -24,7 +24,7 @@ #include "src/tint/ast/group_attribute.h" #include "src/tint/ast/type.h" #include "src/tint/builtin/access.h" -#include "src/tint/type/address_space.h" +#include "src/tint/builtin/address_space.h" // Forward declarations namespace tint::ast { diff --git a/src/tint/ast/variable_test.cc b/src/tint/ast/variable_test.cc index dcbf1e5a24..35fca4ac53 100644 --- a/src/tint/ast/variable_test.cc +++ b/src/tint/ast/variable_test.cc @@ -25,7 +25,7 @@ namespace { using VariableTest = TestHelper; TEST_F(VariableTest, Creation) { - auto* v = Var("my_var", ty.i32(), type::AddressSpace::kFunction); + auto* v = Var("my_var", ty.i32(), builtin::AddressSpace::kFunction); CheckIdentifier(Symbols(), v->name, "my_var"); CheckIdentifier(Symbols(), v->declared_address_space, "function"); @@ -39,7 +39,7 @@ TEST_F(VariableTest, Creation) { TEST_F(VariableTest, CreationWithSource) { auto* v = Var(Source{Source::Range{Source::Location{27, 4}, Source::Location{27, 5}}}, "i", - ty.f32(), type::AddressSpace::kPrivate, utils::Empty); + ty.f32(), builtin::AddressSpace::kPrivate, utils::Empty); CheckIdentifier(Symbols(), v->name, "i"); CheckIdentifier(Symbols(), v->declared_address_space, "private"); @@ -52,7 +52,7 @@ TEST_F(VariableTest, CreationWithSource) { TEST_F(VariableTest, CreationEmpty) { auto* v = Var(Source{Source::Range{Source::Location{27, 4}, Source::Location{27, 7}}}, "a_var", - ty.i32(), type::AddressSpace::kWorkgroup, utils::Empty); + ty.i32(), builtin::AddressSpace::kWorkgroup, utils::Empty); CheckIdentifier(Symbols(), v->name, "a_var"); CheckIdentifier(Symbols(), v->declared_address_space, "workgroup"); @@ -93,7 +93,7 @@ TEST_F(VariableTest, Assert_DifferentProgramID_Initializer) { } TEST_F(VariableTest, WithAttributes) { - auto* var = Var("my_var", ty.i32(), type::AddressSpace::kFunction, Location(1_u), + auto* var = Var("my_var", ty.i32(), builtin::AddressSpace::kFunction, Location(1_u), Builtin(builtin::BuiltinValue::kPosition), Id(1200_u)); auto& attributes = var->attributes; @@ -108,22 +108,22 @@ TEST_F(VariableTest, WithAttributes) { } TEST_F(VariableTest, HasBindingPoint_BothProvided) { - auto* var = Var("my_var", ty.i32(), type::AddressSpace::kFunction, Binding(2_a), Group(1_a)); + auto* var = Var("my_var", ty.i32(), builtin::AddressSpace::kFunction, Binding(2_a), Group(1_a)); EXPECT_TRUE(var->HasBindingPoint()); } TEST_F(VariableTest, HasBindingPoint_NeitherProvided) { - auto* var = Var("my_var", ty.i32(), type::AddressSpace::kFunction, utils::Empty); + auto* var = Var("my_var", ty.i32(), builtin::AddressSpace::kFunction, utils::Empty); EXPECT_FALSE(var->HasBindingPoint()); } TEST_F(VariableTest, HasBindingPoint_MissingGroupAttribute) { - auto* var = Var("my_var", ty.i32(), type::AddressSpace::kFunction, Binding(2_a)); + auto* var = Var("my_var", ty.i32(), builtin::AddressSpace::kFunction, Binding(2_a)); EXPECT_FALSE(var->HasBindingPoint()); } TEST_F(VariableTest, HasBindingPoint_MissingBindingAttribute) { - auto* var = Var("my_var", ty.i32(), type::AddressSpace::kFunction, Group(1_a)); + auto* var = Var("my_var", ty.i32(), builtin::AddressSpace::kFunction, Group(1_a)); EXPECT_FALSE(var->HasBindingPoint()); } diff --git a/src/tint/type/address_space.cc b/src/tint/builtin/address_space.cc similarity index 94% rename from src/tint/type/address_space.cc rename to src/tint/builtin/address_space.cc index c3cfcc67ed..3b386b8311 100644 --- a/src/tint/type/address_space.cc +++ b/src/tint/builtin/address_space.cc @@ -15,14 +15,14 @@ //////////////////////////////////////////////////////////////////////////////// // File generated by tools/src/cmd/gen // using the template: -// src/tint/type/address_space.cc.tmpl +// src/tint/builtin/address_space.cc.tmpl // // Do not modify this file directly //////////////////////////////////////////////////////////////////////////////// -#include "src/tint/type/address_space.h" +#include "src/tint/builtin/address_space.h" -namespace tint::type { +namespace tint::builtin { /// ParseAddressSpace parses a AddressSpace from a string. /// @param str the string to parse @@ -81,4 +81,4 @@ std::ostream& operator<<(std::ostream& out, AddressSpace value) { return out << ""; } -} // namespace tint::type +} // namespace tint::builtin diff --git a/src/tint/type/address_space.cc.tmpl b/src/tint/builtin/address_space.cc.tmpl similarity index 85% rename from src/tint/type/address_space.cc.tmpl rename to src/tint/builtin/address_space.cc.tmpl index f9036b7df7..a137718dd4 100644 --- a/src/tint/type/address_space.cc.tmpl +++ b/src/tint/builtin/address_space.cc.tmpl @@ -14,12 +14,12 @@ See: {{- Import "src/tint/templates/enums.tmpl.inc" -}} {{- $enum := (Sem.Enum "address_space") -}} -#include "src/tint/type/address_space.h" +#include "src/tint/builtin/address_space.h" -namespace tint::type { +namespace tint::builtin { {{ Eval "ParseEnum" $enum}} {{ Eval "EnumOStream" $enum}} -} // namespace tint::type +} // namespace tint::builtin diff --git a/src/tint/type/address_space.h b/src/tint/builtin/address_space.h similarity index 90% rename from src/tint/type/address_space.h rename to src/tint/builtin/address_space.h index f0b0224591..55b1557140 100644 --- a/src/tint/type/address_space.h +++ b/src/tint/builtin/address_space.h @@ -15,17 +15,17 @@ //////////////////////////////////////////////////////////////////////////////// // File generated by tools/src/cmd/gen // using the template: -// src/tint/type/address_space.h.tmpl +// src/tint/builtin/address_space.h.tmpl // // Do not modify this file directly //////////////////////////////////////////////////////////////////////////////// -#ifndef SRC_TINT_TYPE_ADDRESS_SPACE_H_ -#define SRC_TINT_TYPE_ADDRESS_SPACE_H_ +#ifndef SRC_TINT_BUILTIN_ADDRESS_SPACE_H_ +#define SRC_TINT_BUILTIN_ADDRESS_SPACE_H_ #include -namespace tint::type { +namespace tint::builtin { /// Address space of a given pointer. enum class AddressSpace { @@ -63,6 +63,6 @@ inline bool IsHostShareable(AddressSpace address_space) { address_space == AddressSpace::kPushConstant; } -} // namespace tint::type +} // namespace tint::builtin -#endif // SRC_TINT_TYPE_ADDRESS_SPACE_H_ +#endif // SRC_TINT_BUILTIN_ADDRESS_SPACE_H_ diff --git a/src/tint/type/address_space.h.tmpl b/src/tint/builtin/address_space.h.tmpl similarity index 84% rename from src/tint/type/address_space.h.tmpl rename to src/tint/builtin/address_space.h.tmpl index 70e308af13..1dd7d35e58 100644 --- a/src/tint/type/address_space.h.tmpl +++ b/src/tint/builtin/address_space.h.tmpl @@ -14,12 +14,12 @@ See: {{- Import "src/tint/templates/enums.tmpl.inc" -}} {{- $enum := (Sem.Enum "address_space") -}} -#ifndef SRC_TINT_TYPE_ADDRESS_SPACE_H_ -#define SRC_TINT_TYPE_ADDRESS_SPACE_H_ +#ifndef SRC_TINT_BUILTIN_ADDRESS_SPACE_H_ +#define SRC_TINT_BUILTIN_ADDRESS_SPACE_H_ #include -namespace tint::type { +namespace tint::builtin { /// Address space of a given pointer. {{ Eval "DeclareEnum" $enum}} @@ -33,6 +33,6 @@ inline bool IsHostShareable(AddressSpace address_space) { address_space == AddressSpace::kPushConstant; } -} // namespace tint::type +} // namespace tint::builtin -#endif // SRC_TINT_TYPE_ADDRESS_SPACE_H_ +#endif // SRC_TINT_BUILTIN_ADDRESS_SPACE_H_ diff --git a/src/tint/type/address_space_bench.cc b/src/tint/builtin/address_space_bench.cc similarity index 93% rename from src/tint/type/address_space_bench.cc rename to src/tint/builtin/address_space_bench.cc index 6f33497ee2..18cc9d241b 100644 --- a/src/tint/type/address_space_bench.cc +++ b/src/tint/builtin/address_space_bench.cc @@ -15,18 +15,18 @@ //////////////////////////////////////////////////////////////////////////////// // File generated by tools/src/cmd/gen // using the template: -// src/tint/type/address_space_bench.cc.tmpl +// src/tint/builtin/address_space_bench.cc.tmpl // // Do not modify this file directly //////////////////////////////////////////////////////////////////////////////// -#include "src/tint/type/address_space.h" +#include "src/tint/builtin/address_space.h" #include #include "benchmark/benchmark.h" -namespace tint::type { +namespace tint::builtin { namespace { void AddressSpaceParser(::benchmark::State& state) { @@ -99,4 +99,4 @@ void AddressSpaceParser(::benchmark::State& state) { BENCHMARK(AddressSpaceParser); } // namespace -} // namespace tint::type +} // namespace tint::builtin diff --git a/src/tint/type/address_space_bench.cc.tmpl b/src/tint/builtin/address_space_bench.cc.tmpl similarity index 87% rename from src/tint/type/address_space_bench.cc.tmpl rename to src/tint/builtin/address_space_bench.cc.tmpl index 554b2b2da1..34f786901b 100644 --- a/src/tint/type/address_space_bench.cc.tmpl +++ b/src/tint/builtin/address_space_bench.cc.tmpl @@ -14,16 +14,16 @@ See: {{- Import "src/tint/templates/enums.tmpl.inc" -}} {{- $enum := (Sem.Enum "address_space") -}} -#include "src/tint/type/address_space.h" +#include "src/tint/builtin/address_space.h" #include #include "benchmark/benchmark.h" -namespace tint::type { +namespace tint::builtin { namespace { {{ Eval "BenchmarkParseEnum" $enum }} } // namespace -} // namespace tint::type +} // namespace tint::builtin diff --git a/src/tint/type/address_space_test.cc b/src/tint/builtin/address_space_test.cc similarity index 95% rename from src/tint/type/address_space_test.cc rename to src/tint/builtin/address_space_test.cc index 7909f0ec45..1ca70236cf 100644 --- a/src/tint/type/address_space_test.cc +++ b/src/tint/builtin/address_space_test.cc @@ -15,19 +15,20 @@ //////////////////////////////////////////////////////////////////////////////// // File generated by tools/src/cmd/gen // using the template: -// src/tint/type/address_space_test.cc.tmpl +// src/tint/builtin/address_space_test.cc.tmpl // // Do not modify this file directly //////////////////////////////////////////////////////////////////////////////// -#include "src/tint/type/address_space.h" +#include "src/tint/builtin/address_space.h" + +#include #include -#include "src/tint/type/test_helper.h" #include "src/tint/utils/string.h" -namespace tint::type { +namespace tint::builtin { namespace { namespace parse_print_tests { @@ -91,4 +92,4 @@ INSTANTIATE_TEST_SUITE_P(ValidCases, AddressSpacePrintTest, testing::ValuesIn(kV } // namespace parse_print_tests } // namespace -} // namespace tint::type +} // namespace tint::builtin diff --git a/src/tint/type/address_space_test.cc.tmpl b/src/tint/builtin/address_space_test.cc.tmpl similarity index 83% rename from src/tint/type/address_space_test.cc.tmpl rename to src/tint/builtin/address_space_test.cc.tmpl index 75f16f2b4d..5f7a437df0 100644 --- a/src/tint/type/address_space_test.cc.tmpl +++ b/src/tint/builtin/address_space_test.cc.tmpl @@ -14,17 +14,18 @@ See: {{- Import "src/tint/templates/enums.tmpl.inc" -}} {{- $enum := (Sem.Enum "address_space") -}} -#include "src/tint/type/address_space.h" +#include "src/tint/builtin/address_space.h" + +#include #include -#include "src/tint/type/test_helper.h" #include "src/tint/utils/string.h" -namespace tint::type { +namespace tint::builtin { namespace { {{ Eval "TestParsePrintEnum" $enum}} } // namespace -} // namespace tint::type +} // namespace tint::builtin diff --git a/src/tint/inspector/inspector.cc b/src/tint/inspector/inspector.cc index 396d0e50db..0863db38a1 100644 --- a/src/tint/inspector/inspector.cc +++ b/src/tint/inspector/inspector.cc @@ -587,7 +587,7 @@ uint32_t Inspector::GetWorkgroupStorageSize(const std::string& entry_point) { uint32_t total_size = 0; auto* func_sem = program_->Sem().Get(func); for (const sem::Variable* var : func_sem->TransitivelyReferencedGlobals()) { - if (var->AddressSpace() == type::AddressSpace::kWorkgroup) { + if (var->AddressSpace() == builtin::AddressSpace::kWorkgroup) { auto* ty = var->Type()->UnwrapRef(); uint32_t align = ty->Align(); uint32_t size = ty->Size(); diff --git a/src/tint/inspector/inspector_test.cc b/src/tint/inspector/inspector_test.cc index 22f1332881..44e13b0389 100644 --- a/src/tint/inspector/inspector_test.cc +++ b/src/tint/inspector/inspector_test.cc @@ -743,7 +743,7 @@ TEST_F(InspectorGetEntryPointTest, OverrideReferencedIndirectly) { TEST_F(InspectorGetEntryPointTest, OverrideReferencedIndirectly_ViaPrivateInitializer) { Override("foo", ty.f32()); - GlobalVar("bar", type::AddressSpace::kPrivate, ty.f32(), Mul(2_a, "foo")); + GlobalVar("bar", builtin::AddressSpace::kPrivate, ty.f32(), Mul(2_a, "foo")); MakePlainGlobalReferenceBodyFunction("ep_func", "bar", ty.f32(), utils::Vector{ Stage(ast::PipelineStage::kCompute), @@ -834,7 +834,7 @@ TEST_F(InspectorGetEntryPointTest, OverrideReferencedByAttributeIndirectly) { TEST_F(InspectorGetEntryPointTest, OverrideReferencedByArraySize) { Override("size", ty.u32()); - GlobalVar("v", type::AddressSpace::kWorkgroup, ty.array(ty.f32(), "size")); + GlobalVar("v", builtin::AddressSpace::kWorkgroup, ty.array(ty.f32(), "size")); Func("ep", utils::Empty, ty.void_(), utils::Vector{ Assign(Phony(), IndexAccessor("v", 0_a)), @@ -857,7 +857,7 @@ TEST_F(InspectorGetEntryPointTest, OverrideReferencedByArraySize) { TEST_F(InspectorGetEntryPointTest, OverrideReferencedByArraySizeIndirectly) { Override("foo", ty.u32()); Override("bar", ty.u32(), Mul(2_a, "foo")); - GlobalVar("v", type::AddressSpace::kWorkgroup, ty.array(ty.f32(), Mul(2_a, Expr("bar")))); + GlobalVar("v", builtin::AddressSpace::kWorkgroup, ty.array(ty.f32(), Mul(2_a, Expr("bar")))); Func("ep", utils::Empty, ty.void_(), utils::Vector{ Assign(Phony(), IndexAccessor("v", 0_a)), @@ -885,7 +885,7 @@ TEST_F(InspectorGetEntryPointTest, OverrideReferencedByArraySizeViaAlias) { Alias("MyArray", ty.array(ty.f32(), Mul(2_a, Expr("bar")))); Override("zoo", ty.u32()); Alias("MyArrayUnused", ty.array(ty.f32(), Mul(2_a, Expr("zoo")))); - GlobalVar("v", type::AddressSpace::kWorkgroup, ty("MyArray")); + GlobalVar("v", builtin::AddressSpace::kWorkgroup, ty("MyArray")); Func("ep", utils::Empty, ty.void_(), utils::Vector{ Assign(Phony(), IndexAccessor("v", 0_a)), diff --git a/src/tint/inspector/test_inspector_builder.cc b/src/tint/inspector/test_inspector_builder.cc index 1de6dd3ea8..b1c8dd4b77 100644 --- a/src/tint/inspector/test_inspector_builder.cc +++ b/src/tint/inspector/test_inspector_builder.cc @@ -125,11 +125,12 @@ void InspectorBuilder::AddUniformBuffer(const std::string& name, ast::Type type, uint32_t group, uint32_t binding) { - GlobalVar(name, type, type::AddressSpace::kUniform, Binding(AInt(binding)), Group(AInt(group))); + GlobalVar(name, type, builtin::AddressSpace::kUniform, Binding(AInt(binding)), + Group(AInt(group))); } void InspectorBuilder::AddWorkgroupStorage(const std::string& name, ast::Type type) { - GlobalVar(name, type, type::AddressSpace::kWorkgroup); + GlobalVar(name, type, builtin::AddressSpace::kWorkgroup); } void InspectorBuilder::AddStorageBuffer(const std::string& name, @@ -137,7 +138,7 @@ void InspectorBuilder::AddStorageBuffer(const std::string& name, builtin::Access access, uint32_t group, uint32_t binding) { - GlobalVar(name, type, type::AddressSpace::kStorage, access, Binding(AInt(binding)), + GlobalVar(name, type, builtin::AddressSpace::kStorage, access, Binding(AInt(binding)), Group(AInt(group))); } @@ -189,7 +190,7 @@ void InspectorBuilder::AddResource(const std::string& name, } void InspectorBuilder::AddGlobalVariable(const std::string& name, ast::Type type) { - GlobalVar(name, type, type::AddressSpace::kPrivate); + GlobalVar(name, type, builtin::AddressSpace::kPrivate); } const ast::Function* InspectorBuilder::MakeSamplerReferenceBodyFunction( diff --git a/src/tint/ir/builder_impl_test.cc b/src/tint/ir/builder_impl_test.cc index 6430c5847a..ccf0ccf339 100644 --- a/src/tint/ir/builder_impl_test.cc +++ b/src/tint/ir/builder_impl_test.cc @@ -1468,7 +1468,7 @@ FunctionEnd TEST_F(IR_BuilderImplTest, EmitLiteral_Bool_True) { auto* expr = Expr(true); - GlobalVar("a", ty.bool_(), type::AddressSpace::kPrivate, expr); + GlobalVar("a", ty.bool_(), builtin::AddressSpace::kPrivate, expr); auto& b = CreateBuilder(); auto r = b.EmitLiteral(expr); @@ -1482,7 +1482,7 @@ TEST_F(IR_BuilderImplTest, EmitLiteral_Bool_True) { TEST_F(IR_BuilderImplTest, EmitLiteral_Bool_False) { auto* expr = Expr(false); - GlobalVar("a", ty.bool_(), type::AddressSpace::kPrivate, expr); + GlobalVar("a", ty.bool_(), builtin::AddressSpace::kPrivate, expr); auto& b = CreateBuilder(); auto r = b.EmitLiteral(expr); @@ -1496,7 +1496,7 @@ TEST_F(IR_BuilderImplTest, EmitLiteral_Bool_False) { TEST_F(IR_BuilderImplTest, EmitLiteral_F32) { auto* expr = Expr(1.2_f); - GlobalVar("a", ty.f32(), type::AddressSpace::kPrivate, expr); + GlobalVar("a", ty.f32(), builtin::AddressSpace::kPrivate, expr); auto& b = CreateBuilder(); auto r = b.EmitLiteral(expr); @@ -1511,7 +1511,7 @@ TEST_F(IR_BuilderImplTest, EmitLiteral_F32) { TEST_F(IR_BuilderImplTest, EmitLiteral_F16) { Enable(builtin::Extension::kF16); auto* expr = Expr(1.2_h); - GlobalVar("a", ty.f16(), type::AddressSpace::kPrivate, expr); + GlobalVar("a", ty.f16(), builtin::AddressSpace::kPrivate, expr); auto& b = CreateBuilder(); auto r = b.EmitLiteral(expr); @@ -1525,7 +1525,7 @@ TEST_F(IR_BuilderImplTest, EmitLiteral_F16) { TEST_F(IR_BuilderImplTest, EmitLiteral_I32) { auto* expr = Expr(-2_i); - GlobalVar("a", ty.i32(), type::AddressSpace::kPrivate, expr); + GlobalVar("a", ty.i32(), builtin::AddressSpace::kPrivate, expr); auto& b = CreateBuilder(); auto r = b.EmitLiteral(expr); @@ -1539,7 +1539,7 @@ TEST_F(IR_BuilderImplTest, EmitLiteral_I32) { TEST_F(IR_BuilderImplTest, EmitLiteral_U32) { auto* expr = Expr(2_u); - GlobalVar("a", ty.u32(), type::AddressSpace::kPrivate, expr); + GlobalVar("a", ty.u32(), builtin::AddressSpace::kPrivate, expr); auto& b = CreateBuilder(); auto r = b.EmitLiteral(expr); diff --git a/src/tint/program_builder.h b/src/tint/program_builder.h index 481656778f..4444428170 100644 --- a/src/tint/program_builder.h +++ b/src/tint/program_builder.h @@ -232,8 +232,8 @@ class ProgramBuilder { private: void Set(ProgramBuilder&, ast::Type t) { type = t; } - void Set(ProgramBuilder& b, type::AddressSpace addr_space) { - if (addr_space != type::AddressSpace::kUndefined) { + void Set(ProgramBuilder& b, builtin::AddressSpace addr_space) { + if (addr_space != builtin::AddressSpace::kUndefined) { address_space = b.Expr(addr_space); } } @@ -1199,9 +1199,9 @@ class ProgramBuilder { /// @param type the type of the pointer /// @param address_space the address space of the pointer /// @param access the optional access control of the pointer - /// @return the pointer to `type` with the given type::AddressSpace + /// @return the pointer to `type` with the given builtin::AddressSpace ast::Type pointer(ast::Type type, - type::AddressSpace address_space, + builtin::AddressSpace address_space, builtin::Access access = builtin::Access::kUndefined) const { return pointer(builder->source_, type, address_space, access); } @@ -1210,10 +1210,10 @@ class ProgramBuilder { /// @param type the type of the pointer /// @param address_space the address space of the pointer /// @param access the optional access control of the pointer - /// @return the pointer to `type` with the given type::AddressSpace + /// @return the pointer to `type` with the given builtin::AddressSpace ast::Type pointer(const Source& source, ast::Type type, - type::AddressSpace address_space, + builtin::AddressSpace address_space, builtin::Access access = builtin::Access::kUndefined) const { if (access != builtin::Access::kUndefined) { return (*this)(source, "ptr", address_space, type, access); @@ -1224,9 +1224,9 @@ class ProgramBuilder { /// @param address_space the address space of the pointer /// @param access the optional access control of the pointer - /// @return the pointer to type `T` with the given type::AddressSpace. + /// @return the pointer to type `T` with the given builtin::AddressSpace. template - ast::Type pointer(type::AddressSpace address_space, + ast::Type pointer(builtin::AddressSpace address_space, builtin::Access access = builtin::Access::kUndefined) const { return pointer(builder->source_, address_space, access); } @@ -1234,10 +1234,10 @@ class ProgramBuilder { /// @param source the Source of the node /// @param address_space the address space of the pointer /// @param access the optional access control of the pointer - /// @return the pointer to type `T` with the given type::AddressSpace. + /// @return the pointer to type `T` with the given builtin::AddressSpace. template ast::Type pointer(const Source& source, - type::AddressSpace address_space, + builtin::AddressSpace address_space, builtin::Access access = builtin::Access::kUndefined) const { if (access != builtin::Access::kUndefined) { return (*this)(source, "ptr", address_space, Of(), access); @@ -2066,7 +2066,7 @@ class ProgramBuilder { /// @param options the extra options passed to the ast::Var initializer /// Can be any of the following, in any order: /// * ast::Type - specifies the variable's type - /// * type::AddressSpace - specifies the variable's address space + /// * builtin::AddressSpace - specifies the variable's address space /// * builtin::Access - specifies the variable's access control /// * ast::Expression* - specifies the variable's initializer expression /// * ast::Attribute* - specifies the variable's attributes (repeatable, or vector) @@ -2083,7 +2083,7 @@ class ProgramBuilder { /// @param options the extra options passed to the ast::Var initializer /// Can be any of the following, in any order: /// * ast::Type - specifies the variable's type - /// * type::AddressSpace - specifies the variable's address space + /// * builtin::AddressSpace - specifies the variable's address space /// * builtin::Access - specifies the variable's access control /// * ast::Expression* - specifies the variable's initializer expression /// * ast::Attribute* - specifies the variable's attributes (repeatable, or vector) @@ -2185,7 +2185,7 @@ class ProgramBuilder { /// @param options the extra options passed to the ast::Var initializer /// Can be any of the following, in any order: /// * ast::Type - specifies the variable's type - /// * type::AddressSpace - specifies the variable address space + /// * builtin::AddressSpace - specifies the variable address space /// * builtin::Access - specifies the variable's access control /// * ast::Expression* - specifies the variable's initializer expression /// * ast::Attribute* - specifies the variable's attributes (repeatable, or vector) @@ -2202,7 +2202,7 @@ class ProgramBuilder { /// @param options the extra options passed to the ast::Var initializer /// Can be any of the following, in any order: /// * ast::Type - specifies the variable's type - /// * type::AddressSpace - specifies the variable address space + /// * builtin::AddressSpace - specifies the variable address space /// * builtin::Access - specifies the variable's access control /// * ast::Expression* - specifies the variable's initializer expression /// * ast::Attribute* - specifies the variable's attributes (repeatable, or vector) diff --git a/src/tint/program_test.cc b/src/tint/program_test.cc index f856504786..0267bccf82 100644 --- a/src/tint/program_test.cc +++ b/src/tint/program_test.cc @@ -46,7 +46,7 @@ TEST_F(ProgramTest, IDsAreUnique) { } TEST_F(ProgramTest, Assert_GlobalVariable) { - GlobalVar("var", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("var", ty.f32(), builtin::AddressSpace::kPrivate); Program program(std::move(*this)); EXPECT_TRUE(program.IsValid()); diff --git a/src/tint/reader/spirv/enum_converter.cc b/src/tint/reader/spirv/enum_converter.cc index 4f9e07bdb6..1aeaf88ed7 100644 --- a/src/tint/reader/spirv/enum_converter.cc +++ b/src/tint/reader/spirv/enum_converter.cc @@ -38,30 +38,30 @@ ast::PipelineStage EnumConverter::ToPipelineStage(spv::ExecutionModel model) { return ast::PipelineStage::kNone; } -type::AddressSpace EnumConverter::ToAddressSpace(const spv::StorageClass sc) { +builtin::AddressSpace EnumConverter::ToAddressSpace(const spv::StorageClass sc) { switch (sc) { case spv::StorageClass::Input: - return type::AddressSpace::kIn; + return builtin::AddressSpace::kIn; case spv::StorageClass::Output: - return type::AddressSpace::kOut; + return builtin::AddressSpace::kOut; case spv::StorageClass::Uniform: - return type::AddressSpace::kUniform; + return builtin::AddressSpace::kUniform; case spv::StorageClass::Workgroup: - return type::AddressSpace::kWorkgroup; + return builtin::AddressSpace::kWorkgroup; case spv::StorageClass::UniformConstant: - return type::AddressSpace::kUndefined; + return builtin::AddressSpace::kUndefined; case spv::StorageClass::StorageBuffer: - return type::AddressSpace::kStorage; + return builtin::AddressSpace::kStorage; case spv::StorageClass::Private: - return type::AddressSpace::kPrivate; + return builtin::AddressSpace::kPrivate; case spv::StorageClass::Function: - return type::AddressSpace::kFunction; + return builtin::AddressSpace::kFunction; default: break; } Fail() << "unknown SPIR-V storage class: " << uint32_t(sc); - return type::AddressSpace::kUndefined; + return builtin::AddressSpace::kUndefined; } builtin::BuiltinValue EnumConverter::ToBuiltin(spv::BuiltIn b) { diff --git a/src/tint/reader/spirv/enum_converter.h b/src/tint/reader/spirv/enum_converter.h index 7cdbfac339..12b50af0e8 100644 --- a/src/tint/reader/spirv/enum_converter.h +++ b/src/tint/reader/spirv/enum_converter.h @@ -18,9 +18,9 @@ #include "spirv/unified1/spirv.h" #include "spirv/unified1/spirv.hpp11" #include "src/tint/ast/pipeline_stage.h" +#include "src/tint/builtin/address_space.h" #include "src/tint/builtin/builtin_value.h" #include "src/tint/reader/spirv/fail_stream.h" -#include "src/tint/type/address_space.h" #include "src/tint/type/storage_texture.h" #include "src/tint/type/texture_dimension.h" @@ -45,7 +45,7 @@ class EnumConverter { /// On failure, logs an error and returns kNone /// @param sc the SPIR-V storage class /// @returns a Tint AST address space - type::AddressSpace ToAddressSpace(const spv::StorageClass sc); + builtin::AddressSpace ToAddressSpace(const spv::StorageClass sc); /// Converts a SPIR-V Builtin value a Tint Builtin. /// On failure, logs an error and returns kNone diff --git a/src/tint/reader/spirv/enum_converter_test.cc b/src/tint/reader/spirv/enum_converter_test.cc index 66e99ff721..c5da495dc3 100644 --- a/src/tint/reader/spirv/enum_converter_test.cc +++ b/src/tint/reader/spirv/enum_converter_test.cc @@ -85,7 +85,7 @@ INSTANTIATE_TEST_SUITE_P(EnumConverterBad, struct StorageClassCase { spv::StorageClass sc; bool expect_success; - type::AddressSpace expected; + builtin::AddressSpace expected; }; inline std::ostream& operator<<(std::ostream& out, StorageClassCase scc) { out << "StorageClassCase{ spv::StorageClass:::" << int(scc.sc) @@ -126,19 +126,21 @@ INSTANTIATE_TEST_SUITE_P( EnumConverterGood, SpvStorageClassTest, testing::Values( - StorageClassCase{spv::StorageClass::Input, true, type::AddressSpace::kIn}, - StorageClassCase{spv::StorageClass::Output, true, type::AddressSpace::kOut}, - StorageClassCase{spv::StorageClass::Uniform, true, type::AddressSpace::kUniform}, - StorageClassCase{spv::StorageClass::Workgroup, true, type::AddressSpace::kWorkgroup}, - StorageClassCase{spv::StorageClass::UniformConstant, true, type::AddressSpace::kUndefined}, - StorageClassCase{spv::StorageClass::StorageBuffer, true, type::AddressSpace::kStorage}, - StorageClassCase{spv::StorageClass::Private, true, type::AddressSpace::kPrivate}, - StorageClassCase{spv::StorageClass::Function, true, type::AddressSpace::kFunction})); + StorageClassCase{spv::StorageClass::Input, true, builtin::AddressSpace::kIn}, + StorageClassCase{spv::StorageClass::Output, true, builtin::AddressSpace::kOut}, + StorageClassCase{spv::StorageClass::Uniform, true, builtin::AddressSpace::kUniform}, + StorageClassCase{spv::StorageClass::Workgroup, true, builtin::AddressSpace::kWorkgroup}, + StorageClassCase{spv::StorageClass::UniformConstant, true, + builtin::AddressSpace::kUndefined}, + StorageClassCase{spv::StorageClass::StorageBuffer, true, builtin::AddressSpace::kStorage}, + StorageClassCase{spv::StorageClass::Private, true, builtin::AddressSpace::kPrivate}, + StorageClassCase{spv::StorageClass::Function, true, builtin::AddressSpace::kFunction})); INSTANTIATE_TEST_SUITE_P(EnumConverterBad, SpvStorageClassTest, testing::Values(StorageClassCase{static_cast(9999), - false, type::AddressSpace::kUndefined})); + false, + builtin::AddressSpace::kUndefined})); // Builtin diff --git a/src/tint/reader/spirv/function.cc b/src/tint/reader/spirv/function.cc index ca35917e39..12c46c1745 100644 --- a/src/tint/reader/spirv/function.cc +++ b/src/tint/reader/spirv/function.cc @@ -2521,12 +2521,12 @@ bool FunctionEmitter::EmitFunctionVariables() { return false; } } - auto* var = parser_impl_.MakeVar(inst.result_id(), type::AddressSpace::kUndefined, + auto* var = parser_impl_.MakeVar(inst.result_id(), builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, var_store_type, initializer, AttributeList{}); auto* var_decl_stmt = create(Source{}, var); AddStatement(var_decl_stmt); - auto* var_type = ty_.Reference(var_store_type, type::AddressSpace::kUndefined); + auto* var_type = ty_.Reference(var_store_type, builtin::AddressSpace::kUndefined); identifier_types_.emplace(inst.result_id(), var_type); } return success(); @@ -3369,9 +3369,9 @@ bool FunctionEmitter::EmitStatementsInBasicBlock(const BlockInfo& block_info, auto* store_type = parser_impl_.ConvertType(def_inst->type_id()); AddStatement(create( Source{}, - parser_impl_.MakeVar(id, type::AddressSpace::kUndefined, builtin::Access::kUndefined, + parser_impl_.MakeVar(id, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, store_type, nullptr, AttributeList{}))); - auto* type = ty_.Reference(store_type, type::AddressSpace::kUndefined); + auto* type = ty_.Reference(store_type, builtin::AddressSpace::kUndefined); identifier_types_.emplace(id, type); } @@ -4842,7 +4842,8 @@ DefInfo::Pointer FunctionEmitter::GetPointerInfo(uint32_t id) { } // Local variables are always Function storage class, with default // access mode. - return DefInfo::Pointer{type::AddressSpace::kFunction, builtin::Access::kUndefined}; + return DefInfo::Pointer{builtin::AddressSpace::kFunction, + builtin::Access::kUndefined}; } case spv::Op::OpFunctionParameter: { const auto* type = As(parser_impl_.ConvertType(inst.type_id())); @@ -5082,7 +5083,7 @@ void FunctionEmitter::FindValuesNeedingNamedOrHoistedDefinition() { // Avoid moving combinatorial values across constructs. This is a // simple heuristic to avoid changing the cost of an operation // by moving it into or out of a loop, for example. - if ((def_info->pointer.address_space == type::AddressSpace::kUndefined) && + if ((def_info->pointer.address_space == builtin::AddressSpace::kUndefined) && local_def.used_in_another_construct) { should_hoist_to_let = true; } @@ -6192,7 +6193,7 @@ bool FunctionEmitter::MakeVectorInsertDynamic(const spvtools::opt::Instruction& var_name = namer_.MakeDerivedName(original_value_name); auto* temp_var = builder_.Var(var_name, type->Build(builder_), - type::AddressSpace::kUndefined, src_vector.expr); + builtin::AddressSpace::kUndefined, src_vector.expr); AddStatement(builder_.Decl({}, temp_var)); } @@ -6262,7 +6263,7 @@ bool FunctionEmitter::MakeCompositeInsert(const spvtools::opt::Instruction& inst // API in parser_impl_. var_name = namer_.MakeDerivedName(original_value_name); auto* temp_var = builder_.Var(var_name, type->Build(builder_), - type::AddressSpace::kUndefined, src_composite.expr); + builtin::AddressSpace::kUndefined, src_composite.expr); AddStatement(builder_.Decl({}, temp_var)); } diff --git a/src/tint/reader/spirv/function.h b/src/tint/reader/spirv/function.h index 5879859ff1..345896a2ea 100644 --- a/src/tint/reader/spirv/function.h +++ b/src/tint/reader/spirv/function.h @@ -331,7 +331,7 @@ struct DefInfo { /// buffer expressed in the old style (with Uniform address space) /// that needs to be remapped to StorageBuffer address space. /// This is kInvalid for non-pointers. - type::AddressSpace address_space = type::AddressSpace::kUndefined; + builtin::AddressSpace address_space = builtin::AddressSpace::kUndefined; /// The declared access mode. builtin::Access access = builtin::Access::kUndefined; @@ -368,7 +368,7 @@ inline std::ostream& operator<<(std::ostream& o, const DefInfo& di) { } o << " requires_named_let_def: " << (di.requires_named_let_def ? "true" : "false") << " requires_hoisted_var_def: " << (di.requires_hoisted_var_def ? "true" : "false"); - if (di.pointer.address_space != type::AddressSpace::kUndefined) { + if (di.pointer.address_space != builtin::AddressSpace::kUndefined) { o << " sc:" << int(di.pointer.address_space); } switch (di.skip) { diff --git a/src/tint/reader/spirv/parser_impl.cc b/src/tint/reader/spirv/parser_impl.cc index 282e2854fb..a34d14a62a 100644 --- a/src/tint/reader/spirv/parser_impl.cc +++ b/src/tint/reader/spirv/parser_impl.cc @@ -1222,16 +1222,16 @@ const Type* ParserImpl::ConvertType(uint32_t type_id, } auto ast_address_space = enum_converter_.ToAddressSpace(storage_class); - if (ast_address_space == type::AddressSpace::kUniform && + if (ast_address_space == builtin::AddressSpace::kUniform && remap_buffer_block_type_.count(pointee_type_id)) { - ast_address_space = type::AddressSpace::kStorage; + ast_address_space = builtin::AddressSpace::kStorage; remap_buffer_block_type_.insert(type_id); } // Pipeline input and output variables map to private variables. - if (ast_address_space == type::AddressSpace::kIn || - ast_address_space == type::AddressSpace::kOut) { - ast_address_space = type::AddressSpace::kPrivate; + if (ast_address_space == builtin::AddressSpace::kIn || + ast_address_space == builtin::AddressSpace::kOut) { + ast_address_space = builtin::AddressSpace::kPrivate; } switch (ptr_as) { case PtrAs::Ref: @@ -1454,14 +1454,14 @@ bool ParserImpl::EmitModuleScopeVariables() { continue; } switch (enum_converter_.ToAddressSpace(spirv_storage_class)) { - case type::AddressSpace::kUndefined: - case type::AddressSpace::kIn: - case type::AddressSpace::kOut: - case type::AddressSpace::kUniform: - case type::AddressSpace::kHandle: - case type::AddressSpace::kStorage: - case type::AddressSpace::kWorkgroup: - case type::AddressSpace::kPrivate: + case builtin::AddressSpace::kUndefined: + case builtin::AddressSpace::kIn: + case builtin::AddressSpace::kOut: + case builtin::AddressSpace::kUniform: + case builtin::AddressSpace::kHandle: + case builtin::AddressSpace::kStorage: + case builtin::AddressSpace::kWorkgroup: + case builtin::AddressSpace::kPrivate: break; default: return Fail() << "invalid SPIR-V storage class " << int(spirv_storage_class) @@ -1471,7 +1471,7 @@ bool ParserImpl::EmitModuleScopeVariables() { return false; } const Type* ast_store_type = nullptr; - type::AddressSpace ast_address_space = type::AddressSpace::kUndefined; + builtin::AddressSpace ast_address_space = builtin::AddressSpace::kUndefined; if (spirv_storage_class == spv::StorageClass::UniformConstant) { // These are opaque handles: samplers or textures ast_store_type = GetHandleTypeForSpirvHandle(var); @@ -1576,8 +1576,9 @@ const spvtools::opt::analysis::IntConstant* ParserImpl::GetArraySize(uint32_t va return size->AsIntConstant(); } -builtin::Access ParserImpl::VarAccess(const Type* storage_type, type::AddressSpace address_space) { - if (address_space != type::AddressSpace::kStorage) { +builtin::Access ParserImpl::VarAccess(const Type* storage_type, + builtin::AddressSpace address_space) { + if (address_space != builtin::AddressSpace::kStorage) { return builtin::Access::kUndefined; } @@ -1591,7 +1592,7 @@ builtin::Access ParserImpl::VarAccess(const Type* storage_type, type::AddressSpa } const ast::Var* ParserImpl::MakeVar(uint32_t id, - type::AddressSpace address_space, + builtin::AddressSpace address_space, builtin::Access access, const Type* storage_type, const ast::Expression* initializer, @@ -1603,12 +1604,12 @@ const ast::Var* ParserImpl::MakeVar(uint32_t id, // Handle variables (textures and samplers) are always in the handle // address space, so we don't mention the address space. - if (address_space == type::AddressSpace::kHandle) { - address_space = type::AddressSpace::kUndefined; + if (address_space == builtin::AddressSpace::kHandle) { + address_space = builtin::AddressSpace::kUndefined; } if (!ConvertDecorationsForVariable(id, &storage_type, &decorations, - address_space != type::AddressSpace::kPrivate)) { + address_space != builtin::AddressSpace::kPrivate)) { return nullptr; } diff --git a/src/tint/reader/spirv/parser_impl.h b/src/tint/reader/spirv/parser_impl.h index 7f934970ed..12b852a2a0 100644 --- a/src/tint/reader/spirv/parser_impl.h +++ b/src/tint/reader/spirv/parser_impl.h @@ -424,12 +424,12 @@ class ParserImpl : Reader { /// @param address_space the 'var' address space /// @returns the access mode for a 'var' declaration with the given storage type and address /// space. - builtin::Access VarAccess(const Type* storage_type, type::AddressSpace address_space); + builtin::Access VarAccess(const Type* storage_type, builtin::AddressSpace address_space); /// Creates an AST 'var' node for a SPIR-V ID, including any attached decorations, unless it's /// an ignorable builtin variable. /// @param id the SPIR-V result ID - /// @param address_space the address space, which cannot be type::AddressSpace::kUndefined + /// @param address_space the address space, which cannot be builtin::AddressSpace::kUndefined /// @param access the access /// @param storage_type the storage type of the variable /// @param initializer the variable initializer @@ -437,7 +437,7 @@ class ParserImpl : Reader { /// @returns a new Variable node, or null in the ignorable variable case and /// in the error case const ast::Var* MakeVar(uint32_t id, - type::AddressSpace address_space, + builtin::AddressSpace address_space, builtin::Access access, const Type* storage_type, const ast::Expression* initializer, @@ -672,7 +672,7 @@ class ParserImpl : Reader { /// The AST variable node. const ast::Var* var = nullptr; /// The address space of the var - type::AddressSpace address_space = type::AddressSpace::kUndefined; + builtin::AddressSpace address_space = builtin::AddressSpace::kUndefined; /// The access mode of the var builtin::Access access = builtin::Access::kUndefined; }; diff --git a/src/tint/reader/spirv/parser_impl_convert_type_test.cc b/src/tint/reader/spirv/parser_impl_convert_type_test.cc index 8530b774bd..fd9a406ce5 100644 --- a/src/tint/reader/spirv/parser_impl_convert_type_test.cc +++ b/src/tint/reader/spirv/parser_impl_convert_type_test.cc @@ -731,7 +731,7 @@ TEST_F(SpvParserTest, ConvertType_PointerInput) { auto* ptr_ty = type->As(); EXPECT_NE(ptr_ty, nullptr); EXPECT_TRUE(ptr_ty->type->Is()); - EXPECT_EQ(ptr_ty->address_space, type::AddressSpace::kPrivate); + EXPECT_EQ(ptr_ty->address_space, builtin::AddressSpace::kPrivate); EXPECT_TRUE(p->error().empty()); } @@ -747,7 +747,7 @@ TEST_F(SpvParserTest, ConvertType_PointerOutput) { auto* ptr_ty = type->As(); EXPECT_NE(ptr_ty, nullptr); EXPECT_TRUE(ptr_ty->type->Is()); - EXPECT_EQ(ptr_ty->address_space, type::AddressSpace::kPrivate); + EXPECT_EQ(ptr_ty->address_space, builtin::AddressSpace::kPrivate); EXPECT_TRUE(p->error().empty()); } @@ -763,7 +763,7 @@ TEST_F(SpvParserTest, ConvertType_PointerUniform) { auto* ptr_ty = type->As(); EXPECT_NE(ptr_ty, nullptr); EXPECT_TRUE(ptr_ty->type->Is()); - EXPECT_EQ(ptr_ty->address_space, type::AddressSpace::kUniform); + EXPECT_EQ(ptr_ty->address_space, builtin::AddressSpace::kUniform); EXPECT_TRUE(p->error().empty()); } @@ -779,7 +779,7 @@ TEST_F(SpvParserTest, ConvertType_PointerWorkgroup) { auto* ptr_ty = type->As(); EXPECT_NE(ptr_ty, nullptr); EXPECT_TRUE(ptr_ty->type->Is()); - EXPECT_EQ(ptr_ty->address_space, type::AddressSpace::kWorkgroup); + EXPECT_EQ(ptr_ty->address_space, builtin::AddressSpace::kWorkgroup); EXPECT_TRUE(p->error().empty()); } @@ -795,7 +795,7 @@ TEST_F(SpvParserTest, ConvertType_PointerStorageBuffer) { auto* ptr_ty = type->As(); EXPECT_NE(ptr_ty, nullptr); EXPECT_TRUE(ptr_ty->type->Is()); - EXPECT_EQ(ptr_ty->address_space, type::AddressSpace::kStorage); + EXPECT_EQ(ptr_ty->address_space, builtin::AddressSpace::kStorage); EXPECT_TRUE(p->error().empty()); } @@ -811,7 +811,7 @@ TEST_F(SpvParserTest, ConvertType_PointerPrivate) { auto* ptr_ty = type->As(); EXPECT_NE(ptr_ty, nullptr); EXPECT_TRUE(ptr_ty->type->Is()); - EXPECT_EQ(ptr_ty->address_space, type::AddressSpace::kPrivate); + EXPECT_EQ(ptr_ty->address_space, builtin::AddressSpace::kPrivate); EXPECT_TRUE(p->error().empty()); } @@ -827,7 +827,7 @@ TEST_F(SpvParserTest, ConvertType_PointerFunction) { auto* ptr_ty = type->As(); EXPECT_NE(ptr_ty, nullptr); EXPECT_TRUE(ptr_ty->type->Is()); - EXPECT_EQ(ptr_ty->address_space, type::AddressSpace::kFunction); + EXPECT_EQ(ptr_ty->address_space, builtin::AddressSpace::kFunction); EXPECT_TRUE(p->error().empty()); } @@ -846,12 +846,12 @@ TEST_F(SpvParserTest, ConvertType_PointerToPointer) { auto* ptr_ty = type->As(); EXPECT_NE(ptr_ty, nullptr); - EXPECT_EQ(ptr_ty->address_space, type::AddressSpace::kPrivate); + EXPECT_EQ(ptr_ty->address_space, builtin::AddressSpace::kPrivate); EXPECT_TRUE(ptr_ty->type->Is()); auto* ptr_ptr_ty = ptr_ty->type->As(); EXPECT_NE(ptr_ptr_ty, nullptr); - EXPECT_EQ(ptr_ptr_ty->address_space, type::AddressSpace::kPrivate); + EXPECT_EQ(ptr_ptr_ty->address_space, builtin::AddressSpace::kPrivate); EXPECT_TRUE(ptr_ptr_ty->type->Is()); EXPECT_TRUE(p->error().empty()); diff --git a/src/tint/reader/spirv/parser_type.cc b/src/tint/reader/spirv/parser_type.cc index 3164c6e5ce..acfaa88cba 100644 --- a/src/tint/reader/spirv/parser_type.cc +++ b/src/tint/reader/spirv/parser_type.cc @@ -175,7 +175,7 @@ Type::~Type() = default; Texture::~Texture() = default; -Pointer::Pointer(const Type* t, type::AddressSpace s, builtin::Access a) +Pointer::Pointer(const Type* t, builtin::AddressSpace s, builtin::Access a) : type(t), address_space(s), access(a) {} Pointer::Pointer(const Pointer&) = default; @@ -189,7 +189,7 @@ ast::Type Pointer::Build(ProgramBuilder& b) const { return b.ty.pointer(type->Build(b), address_space, access); } -Reference::Reference(const Type* t, type::AddressSpace s, builtin::Access a) +Reference::Reference(const Type* t, builtin::AddressSpace s, builtin::Access a) : type(t), address_space(s), access(a) {} Reference::Reference(const Reference&) = default; @@ -474,13 +474,13 @@ const Type* TypeManager::AsUnsigned(const Type* ty) { } const spirv::Pointer* TypeManager::Pointer(const Type* el, - type::AddressSpace address_space, + builtin::AddressSpace address_space, builtin::Access access) { return state->pointers_.Get(el, address_space, access); } const spirv::Reference* TypeManager::Reference(const Type* el, - type::AddressSpace address_space, + builtin::AddressSpace address_space, builtin::Access access) { return state->references_.Get(el, address_space, access); } diff --git a/src/tint/reader/spirv/parser_type.h b/src/tint/reader/spirv/parser_type.h index 18f47d38ef..54991dc3ee 100644 --- a/src/tint/reader/spirv/parser_type.h +++ b/src/tint/reader/spirv/parser_type.h @@ -21,9 +21,9 @@ #include "src/tint/ast/type.h" #include "src/tint/builtin/access.h" +#include "src/tint/builtin/address_space.h" #include "src/tint/castable.h" #include "src/tint/symbol.h" -#include "src/tint/type/address_space.h" #include "src/tint/type/sampler_kind.h" #include "src/tint/type/texel_format.h" #include "src/tint/type/texture_dimension.h" @@ -162,7 +162,7 @@ struct Pointer final : public Castable { /// @param ty the store type /// @param sc the pointer address space /// @param access the declared access mode - Pointer(const Type* ty, type::AddressSpace sc, builtin::Access access); + Pointer(const Type* ty, builtin::AddressSpace sc, builtin::Access access); /// Copy constructor /// @param other the other type to copy @@ -180,7 +180,7 @@ struct Pointer final : public Castable { /// the store type Type const* const type; /// the pointer address space - type::AddressSpace const address_space; + builtin::AddressSpace const address_space; /// the pointer declared access mode builtin::Access const access; }; @@ -193,7 +193,7 @@ struct Reference final : public Castable { /// @param ty the referenced type /// @param sc the reference address space /// @param access the reference declared access mode - Reference(const Type* ty, type::AddressSpace sc, builtin::Access access); + Reference(const Type* ty, builtin::AddressSpace sc, builtin::Access access); /// Copy constructor /// @param other the other type to copy @@ -211,7 +211,7 @@ struct Reference final : public Castable { /// the store type Type const* const type; /// the pointer address space - type::AddressSpace const address_space; + builtin::AddressSpace const address_space; /// the pointer declared access mode builtin::Access const access; }; @@ -549,7 +549,7 @@ class TypeManager { /// @return a Pointer type. Repeated calls with the same arguments will return /// the same pointer. const spirv::Pointer* Pointer(const Type* ty, - type::AddressSpace address_space, + builtin::AddressSpace address_space, builtin::Access access = builtin::Access::kUndefined); /// @param ty the referenced type /// @param address_space the reference address space @@ -557,7 +557,7 @@ class TypeManager { /// @return a Reference type. Repeated calls with the same arguments will /// return the same pointer. const spirv::Reference* Reference(const Type* ty, - type::AddressSpace address_space, + builtin::AddressSpace address_space, 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 560b24eda1..68492bbcd8 100644 --- a/src/tint/reader/spirv/parser_type_test.cc +++ b/src/tint/reader/spirv/parser_type_test.cc @@ -29,8 +29,8 @@ TEST(SpvParserTypeTest, SameArgumentsGivesSamePointer) { EXPECT_EQ(ty.U32(), ty.U32()); EXPECT_EQ(ty.F32(), ty.F32()); EXPECT_EQ(ty.I32(), ty.I32()); - EXPECT_EQ(ty.Pointer(ty.I32(), type::AddressSpace::kUndefined), - ty.Pointer(ty.I32(), type::AddressSpace::kUndefined)); + EXPECT_EQ(ty.Pointer(ty.I32(), builtin::AddressSpace::kUndefined), + ty.Pointer(ty.I32(), builtin::AddressSpace::kUndefined)); 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 @@ TEST(SpvParserTypeTest, DifferentArgumentsGivesDifferentPointer) { Symbol sym_b(Symbol(2, {})); TypeManager ty; - EXPECT_NE(ty.Pointer(ty.I32(), type::AddressSpace::kUndefined), - ty.Pointer(ty.U32(), type::AddressSpace::kUndefined)); - EXPECT_NE(ty.Pointer(ty.I32(), type::AddressSpace::kUndefined), - ty.Pointer(ty.I32(), type::AddressSpace::kIn)); + 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.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/reader/wgsl/parser_impl_variable_qualifier_test.cc b/src/tint/reader/wgsl/parser_impl_variable_qualifier_test.cc index 9708f0d5ed..3c25d858eb 100644 --- a/src/tint/reader/wgsl/parser_impl_variable_qualifier_test.cc +++ b/src/tint/reader/wgsl/parser_impl_variable_qualifier_test.cc @@ -20,7 +20,7 @@ namespace { struct VariableStorageData { const char* input; - type::AddressSpace address_space; + builtin::AddressSpace address_space; builtin::Access access; }; inline std::ostream& operator<<(std::ostream& out, VariableStorageData data) { @@ -38,7 +38,7 @@ TEST_P(VariableQualifierTest, ParsesAddressSpace) { EXPECT_FALSE(p->has_error()); EXPECT_FALSE(sc.errored); EXPECT_TRUE(sc.matched); - if (params.address_space != type::AddressSpace::kUndefined) { + if (params.address_space != builtin::AddressSpace::kUndefined) { ast::CheckIdentifier(p->builder().Symbols(), sc->address_space, utils::ToString(params.address_space)); } else { @@ -56,18 +56,22 @@ TEST_P(VariableQualifierTest, ParsesAddressSpace) { INSTANTIATE_TEST_SUITE_P( ParserImplTest, VariableQualifierTest, - testing::Values( - VariableStorageData{"uniform", type::AddressSpace::kUniform, builtin::Access::kUndefined}, - VariableStorageData{"workgroup", type::AddressSpace::kWorkgroup, - builtin::Access::kUndefined}, - VariableStorageData{"storage", type::AddressSpace::kStorage, builtin::Access::kUndefined}, - VariableStorageData{"private", type::AddressSpace::kPrivate, builtin::Access::kUndefined}, - VariableStorageData{"function", type::AddressSpace::kFunction, builtin::Access::kUndefined}, - VariableStorageData{"storage, read", type::AddressSpace::kStorage, builtin::Access::kRead}, - VariableStorageData{"storage, write", type::AddressSpace::kStorage, - builtin::Access::kWrite}, - VariableStorageData{"storage, read_write", type::AddressSpace::kStorage, - builtin::Access::kReadWrite})); + testing::Values(VariableStorageData{"uniform", builtin::AddressSpace::kUniform, + builtin::Access::kUndefined}, + VariableStorageData{"workgroup", builtin::AddressSpace::kWorkgroup, + builtin::Access::kUndefined}, + VariableStorageData{"storage", builtin::AddressSpace::kStorage, + builtin::Access::kUndefined}, + VariableStorageData{"private", builtin::AddressSpace::kPrivate, + builtin::Access::kUndefined}, + VariableStorageData{"function", builtin::AddressSpace::kFunction, + builtin::Access::kUndefined}, + VariableStorageData{"storage, read", builtin::AddressSpace::kStorage, + builtin::Access::kRead}, + VariableStorageData{"storage, write", builtin::AddressSpace::kStorage, + builtin::Access::kWrite}, + VariableStorageData{"storage, read_write", builtin::AddressSpace::kStorage, + builtin::Access::kReadWrite})); TEST_F(ParserImplTest, VariableQualifier_Empty) { auto p = parser("var<> name"); diff --git a/src/tint/resolver/address_space_layout_validation_test.cc b/src/tint/resolver/address_space_layout_validation_test.cc index 041e566d21..48d0633a3d 100644 --- a/src/tint/resolver/address_space_layout_validation_test.cc +++ b/src/tint/resolver/address_space_layout_validation_test.cc @@ -39,7 +39,7 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, StorageBuffer_UnalignedMember) Member(Source{{34, 56}}, "b", ty.f32(), utils::Vector{MemberAlign(1_i)}), }); - GlobalVar(Source{{78, 90}}, "a", ty("S"), type::AddressSpace::kStorage, Group(0_a), + GlobalVar(Source{{78, 90}}, "a", ty("S"), builtin::AddressSpace::kStorage, Group(0_a), Binding(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -69,7 +69,7 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, StorageBuffer_UnalignedMember_S Member(Source{{34, 56}}, "b", ty.f32(), utils::Vector{MemberAlign(4_i)}), }); - GlobalVar(Source{{78, 90}}, "a", ty("S"), type::AddressSpace::kStorage, Group(0_a), + GlobalVar(Source{{78, 90}}, "a", ty("S"), builtin::AddressSpace::kStorage, Group(0_a), Binding(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -100,7 +100,7 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_UnalignedMember_S Member(Source{{56, 78}}, "inner", ty("Inner")), }); - GlobalVar(Source{{78, 90}}, "a", ty("Outer"), type::AddressSpace::kUniform, Group(0_a), + GlobalVar(Source{{78, 90}}, "a", ty("Outer"), builtin::AddressSpace::kUniform, Group(0_a), Binding(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -144,7 +144,7 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, Member(Source{{56, 78}}, "inner", ty("Inner"), utils::Vector{MemberAlign(16_i)}), }); - GlobalVar(Source{{78, 90}}, "a", ty("Outer"), type::AddressSpace::kUniform, Group(0_a), + GlobalVar(Source{{78, 90}}, "a", ty("Outer"), builtin::AddressSpace::kUniform, Group(0_a), Binding(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -169,7 +169,7 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_UnalignedMember_A Member(Source{{56, 78}}, "inner", ty("Inner")), }); - GlobalVar(Source{{78, 90}}, "a", ty("Outer"), type::AddressSpace::kUniform, Group(0_a), + GlobalVar(Source{{78, 90}}, "a", ty("Outer"), builtin::AddressSpace::kUniform, Group(0_a), Binding(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -202,7 +202,7 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_UnalignedMember_A Member(Source{{34, 56}}, "inner", ty("Inner"), utils::Vector{MemberAlign(16_i)}), }); - GlobalVar(Source{{78, 90}}, "a", ty("Outer"), type::AddressSpace::kUniform, Group(0_a), + GlobalVar(Source{{78, 90}}, "a", ty("Outer"), builtin::AddressSpace::kUniform, Group(0_a), Binding(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -234,7 +234,7 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_MembersOffsetNotM Member(Source{{78, 90}}, "scalar", ty.i32()), }); - GlobalVar(Source{{22, 24}}, "a", ty("Outer"), type::AddressSpace::kUniform, Group(0_a), + GlobalVar(Source{{22, 24}}, "a", ty("Outer"), builtin::AddressSpace::kUniform, Group(0_a), Binding(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -286,7 +286,7 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, Member(Source{{78, 90}}, "scalar", ty.i32()), }); - GlobalVar(Source{{22, 24}}, "a", ty("Outer"), type::AddressSpace::kUniform, Group(0_a), + GlobalVar(Source{{22, 24}}, "a", ty("Outer"), builtin::AddressSpace::kUniform, Group(0_a), Binding(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -334,7 +334,7 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, Member(Source{{78, 90}}, "scalar", ty.i32(), utils::Vector{MemberAlign(16_i)}), }); - GlobalVar(Source{{22, 34}}, "a", ty("Outer"), type::AddressSpace::kUniform, Group(0_a), + GlobalVar(Source{{22, 34}}, "a", ty("Outer"), builtin::AddressSpace::kUniform, Group(0_a), Binding(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -355,7 +355,7 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_Vec3MemberOffset_ Member("s", ty.f32()), }); - GlobalVar(Source{{78, 90}}, "a", ty("ScalarPackedAtEndOfVec3"), type::AddressSpace::kUniform, + GlobalVar(Source{{78, 90}}, "a", ty("ScalarPackedAtEndOfVec3"), builtin::AddressSpace::kUniform, Group(0_a), Binding(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -378,7 +378,7 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_Vec3F16MemberOffs Member("s", ty.f16()), }); - GlobalVar(Source{{78, 90}}, "a", ty("ScalarPackedAtEndOfVec3"), type::AddressSpace::kUniform, + GlobalVar(Source{{78, 90}}, "a", ty("ScalarPackedAtEndOfVec3"), builtin::AddressSpace::kUniform, Group(0_a), Binding(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -404,7 +404,7 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_InvalidArrayStrid Member("scalar", ty.i32()), }); - GlobalVar(Source{{78, 90}}, "a", ty("Outer"), type::AddressSpace::kUniform, Group(0_a), + GlobalVar(Source{{78, 90}}, "a", ty("Outer"), builtin::AddressSpace::kUniform, Group(0_a), Binding(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -438,7 +438,7 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_InvalidArrayStrid Member("scalar", ty.i32()), }); - GlobalVar(Source{{78, 90}}, "a", ty("Outer"), type::AddressSpace::kUniform, Group(0_a), + GlobalVar(Source{{78, 90}}, "a", ty("Outer"), builtin::AddressSpace::kUniform, Group(0_a), Binding(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -481,7 +481,7 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_InvalidArrayStrid Member("scalar", ty.i32()), }); - GlobalVar(Source{{78, 90}}, "a", ty("Outer"), type::AddressSpace::kUniform, Group(0_a), + GlobalVar(Source{{78, 90}}, "a", ty("Outer"), builtin::AddressSpace::kUniform, Group(0_a), Binding(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -500,7 +500,7 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_InvalidArrayStrid // @group(0) @binding(0) // var a : array; GlobalVar(Source{{78, 90}}, "a", ty.array(Source{{34, 56}}, ty.f32(), 4_u), - type::AddressSpace::kUniform, Group(0_a), Binding(0_a)); + builtin::AddressSpace::kUniform, Group(0_a), Binding(0_a)); ASSERT_FALSE(r()->Resolve()); EXPECT_EQ( @@ -521,7 +521,7 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_InvalidArrayStrid Member("inner", ty.array(Source{{34, 56}}, ty.array(), 4_u)), }); - GlobalVar(Source{{78, 90}}, "a", ty("Outer"), type::AddressSpace::kUniform, Group(0_a), + GlobalVar(Source{{78, 90}}, "a", ty("Outer"), builtin::AddressSpace::kUniform, Group(0_a), Binding(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -554,7 +554,7 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_InvalidArrayStrid Member("scalar", ty.i32()), }); - GlobalVar(Source{{78, 90}}, "a", ty("Outer"), type::AddressSpace::kUniform, Group(0_a), + GlobalVar(Source{{78, 90}}, "a", ty("Outer"), builtin::AddressSpace::kUniform, Group(0_a), Binding(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -573,7 +573,7 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, PushConstant_UnalignedMember) { Source{{12, 34}}, "S", utils::Vector{Member("a", ty.f32(), utils::Vector{MemberSize(5_a)}), Member(Source{{34, 56}}, "b", ty.f32(), utils::Vector{MemberAlign(1_i)})}); - GlobalVar(Source{{78, 90}}, "a", ty("S"), type::AddressSpace::kPushConstant); + GlobalVar(Source{{78, 90}}, "a", ty("S"), builtin::AddressSpace::kPushConstant); ASSERT_FALSE(r()->Resolve()); EXPECT_EQ( @@ -598,7 +598,7 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, PushConstant_Aligned) { Enable(builtin::Extension::kChromiumExperimentalPushConstant); Structure("S", utils::Vector{Member("a", ty.f32(), utils::Vector{MemberSize(5_a)}), Member("b", ty.f32(), utils::Vector{MemberAlign(4_i)})}); - GlobalVar("a", ty("S"), type::AddressSpace::kPushConstant); + GlobalVar("a", ty("S"), builtin::AddressSpace::kPushConstant); ASSERT_TRUE(r()->Resolve()) << r()->error(); } diff --git a/src/tint/resolver/address_space_validation_test.cc b/src/tint/resolver/address_space_validation_test.cc index b0c27e7557..3078d89501 100644 --- a/src/tint/resolver/address_space_validation_test.cc +++ b/src/tint/resolver/address_space_validation_test.cc @@ -47,7 +47,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_NoAddressSpace_Fail) { TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_FunctionAddressSpace_Fail) { // var g : f32; - GlobalVar(Source{{12, 34}}, "g", ty.f32(), type::AddressSpace::kFunction); + GlobalVar(Source{{12, 34}}, "g", ty.f32(), builtin::AddressSpace::kFunction); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -57,7 +57,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_FunctionAddressSpace_F TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Private_RuntimeArray) { // var v : array; GlobalVar(Source{{56, 78}}, "v", ty.array(Source{{12, 34}}, ty.i32()), - type::AddressSpace::kPrivate); + builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -68,7 +68,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Private_RuntimeArray) TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Private_RuntimeArray) { // type t : ptr>; Alias("t", ty.pointer(Source{{56, 78}}, ty.array(Source{{12, 34}}, ty.i32()), - type::AddressSpace::kPrivate)); + builtin::AddressSpace::kPrivate)); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -80,7 +80,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Private_RuntimeArrayIn // struct S { m : array }; // var v : S; Structure("S", utils::Vector{Member(Source{{12, 34}}, "m", ty.array(ty.i32()))}); - GlobalVar(Source{{56, 78}}, "v", ty("S"), type::AddressSpace::kPrivate); + GlobalVar(Source{{56, 78}}, "v", ty("S"), builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -93,7 +93,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Private_RuntimeArrayInSt // struct S { m : array }; // type t = ptr; Structure("S", utils::Vector{Member(Source{{12, 34}}, "m", ty.array(ty.i32()))}); - Alias("t", ty.pointer(ty("S"), type::AddressSpace::kPrivate)); + Alias("t", ty.pointer(ty("S"), builtin::AddressSpace::kPrivate)); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -105,7 +105,7 @@ note: while instantiating ptr)"); TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Workgroup_RuntimeArray) { // var v : array; GlobalVar(Source{{56, 78}}, "v", ty.array(Source{{12, 34}}, ty.i32()), - type::AddressSpace::kWorkgroup); + builtin::AddressSpace::kWorkgroup); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -115,7 +115,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Workgroup_RuntimeArray TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Workgroup_RuntimeArray) { // type t = ptr>; - Alias("t", ty.pointer(ty.array(Source{{12, 34}}, ty.i32()), type::AddressSpace::kWorkgroup)); + Alias("t", ty.pointer(ty.array(Source{{12, 34}}, ty.i32()), builtin::AddressSpace::kWorkgroup)); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -127,7 +127,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Workgroup_RuntimeArray // struct S { m : array }; // var v : S; Structure("S", utils::Vector{Member(Source{{12, 34}}, "m", ty.array(ty.i32()))}); - GlobalVar(Source{{56, 78}}, "v", ty("S"), type::AddressSpace::kWorkgroup); + GlobalVar(Source{{56, 78}}, "v", ty("S"), builtin::AddressSpace::kWorkgroup); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -140,7 +140,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Workgroup_RuntimeArrayIn // struct S { m : array }; // type t = ptr; Structure("S", utils::Vector{Member(Source{{12, 34}}, "m", ty.array(ty.i32()))}); - Alias(Source{{56, 78}}, "t", ty.pointer(ty("S"), type::AddressSpace::kWorkgroup)); + Alias(Source{{56, 78}}, "t", ty.pointer(ty("S"), builtin::AddressSpace::kWorkgroup)); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -151,7 +151,7 @@ note: while instantiating ptr)"); TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_Bool) { // var g : bool; - GlobalVar(Source{{56, 78}}, "g", ty.bool_(Source{{12, 34}}), type::AddressSpace::kStorage, + GlobalVar(Source{{56, 78}}, "g", ty.bool_(Source{{12, 34}}), builtin::AddressSpace::kStorage, Binding(0_a), Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -165,7 +165,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_Bool) { TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_Bool) { // type t = ptr; Alias(Source{{56, 78}}, "t", - ty.pointer(ty.bool_(Source{{12, 34}}), type::AddressSpace::kStorage)); + ty.pointer(ty.bool_(Source{{12, 34}}), builtin::AddressSpace::kStorage)); ASSERT_FALSE(r()->Resolve()); @@ -179,7 +179,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_BoolAlias) { // type a = bool; // @binding(0) @group(0) var g : a; Alias("a", ty.bool_()); - GlobalVar(Source{{56, 78}}, "g", ty(Source{{12, 34}}, "a"), type::AddressSpace::kStorage, + GlobalVar(Source{{56, 78}}, "g", ty(Source{{12, 34}}, "a"), builtin::AddressSpace::kStorage, Binding(0_a), Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -195,7 +195,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_BoolAlias) { // type t = ptr; Alias("a", ty.bool_()); Alias(Source{{56, 78}}, "t", - ty.pointer(ty(Source{{12, 34}}, "a"), type::AddressSpace::kStorage)); + ty.pointer(ty(Source{{12, 34}}, "a"), builtin::AddressSpace::kStorage)); ASSERT_FALSE(r()->Resolve()); @@ -208,8 +208,8 @@ note: while instantiating ptr)"); TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_Pointer) { // var g : ptr; GlobalVar(Source{{56, 78}}, "g", - ty.pointer(Source{{12, 34}}, ty.f32(), type::AddressSpace::kPrivate), - type::AddressSpace::kStorage, Binding(0_a), Group(0_a)); + ty.pointer(Source{{12, 34}}, ty.f32(), builtin::AddressSpace::kPrivate), + builtin::AddressSpace::kStorage, Binding(0_a), Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -222,8 +222,8 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_Pointer) { TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_Pointer) { // type t = ptr>; Alias("t", ty.pointer(Source{{56, 78}}, - ty.pointer(Source{{12, 34}}, ty.f32(), type::AddressSpace::kPrivate), - type::AddressSpace::kStorage)); + ty.pointer(Source{{12, 34}}, ty.f32(), builtin::AddressSpace::kPrivate), + builtin::AddressSpace::kStorage)); ASSERT_FALSE(r()->Resolve()); @@ -235,14 +235,14 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_Pointer) { TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_IntScalar) { // var g : i32; - GlobalVar("g", ty.i32(), type::AddressSpace::kStorage, Binding(0_a), Group(0_a)); + GlobalVar("g", ty.i32(), builtin::AddressSpace::kStorage, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_IntScalar) { // type t = ptrResolve()) << r()->error(); } @@ -252,7 +252,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_F16) { // var g : f16; Enable(builtin::Extension::kF16); - GlobalVar("g", ty.f16(), type::AddressSpace::kStorage, Binding(0_a), Group(0_a)); + GlobalVar("g", ty.f16(), builtin::AddressSpace::kStorage, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -262,7 +262,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_F16) { // type t = ptr; Enable(builtin::Extension::kF16); - Alias("t", ty.pointer(ty.f16(), type::AddressSpace::kStorage)); + Alias("t", ty.pointer(ty.f16(), builtin::AddressSpace::kStorage)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -274,7 +274,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_F16Alias) { Enable(builtin::Extension::kF16); Alias("a", ty.f16()); - GlobalVar("g", ty("a"), type::AddressSpace::kStorage, Binding(0_a), Group(0_a)); + GlobalVar("g", ty("a"), builtin::AddressSpace::kStorage, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -286,21 +286,21 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_F16Alias) { Enable(builtin::Extension::kF16); Alias("a", ty.f16()); - Alias("t", ty.pointer(ty("a"), type::AddressSpace::kStorage)); + Alias("t", ty.pointer(ty("a"), builtin::AddressSpace::kStorage)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_VectorF32) { // var g : vec4; - GlobalVar("g", ty.vec4(), type::AddressSpace::kStorage, Binding(0_a), Group(0_a)); + GlobalVar("g", ty.vec4(), builtin::AddressSpace::kStorage, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_VectorF32) { // type t = ptr>; - Alias("t", ty.pointer(ty.vec4(), type::AddressSpace::kStorage)); + Alias("t", ty.pointer(ty.vec4(), builtin::AddressSpace::kStorage)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -308,7 +308,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_VectorF32) { TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_VectorF16) { // var g : vec4; Enable(builtin::Extension::kF16); - GlobalVar("g", ty.vec(ty.f16(), 4u), type::AddressSpace::kStorage, Binding(0_a), Group(0_a)); + GlobalVar("g", ty.vec(ty.f16(), 4u), builtin::AddressSpace::kStorage, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -316,7 +316,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_VectorF16) { TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_VectorF16) { // type t = ptr>; Enable(builtin::Extension::kF16); - Alias("t", ty.pointer(ty.vec(ty.f16(), 4u), type::AddressSpace::kStorage)); + Alias("t", ty.pointer(ty.vec(ty.f16(), 4u), builtin::AddressSpace::kStorage)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -325,7 +325,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_ArrayF32) { // struct S{ a : f32 }; // var g : array; Structure("S", utils::Vector{Member("a", ty.f32())}); - GlobalVar("g", ty.array(ty("S"), 3_u), type::AddressSpace::kStorage, builtin::Access::kRead, + GlobalVar("g", ty.array(ty("S"), 3_u), builtin::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -335,7 +335,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_ArrayF32) { // struct S{ a : f32 }; // type t = ptr>; Structure("S", utils::Vector{Member("a", ty.f32())}); - Alias("t", ty.pointer(ty.array(ty("S"), 3_u), type::AddressSpace::kStorage)); + Alias("t", ty.pointer(ty.array(ty("S"), 3_u), builtin::AddressSpace::kStorage)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -347,7 +347,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_ArrayF16) { Enable(builtin::Extension::kF16); Structure("S", utils::Vector{Member("a", ty.f16())}); - GlobalVar("g", ty.array(ty("S"), 3_u), type::AddressSpace::kStorage, builtin::Access::kRead, + GlobalVar("g", ty.array(ty("S"), 3_u), builtin::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -360,8 +360,8 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_ArrayF16) { Enable(builtin::Extension::kF16); Structure("S", utils::Vector{Member("a", ty.f16())}); - Alias("t", - ty.pointer(ty.array(ty("S"), 3_u), type::AddressSpace::kStorage, builtin::Access::kRead)); + Alias("t", ty.pointer(ty.array(ty("S"), 3_u), builtin::AddressSpace::kStorage, + builtin::Access::kRead)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -370,7 +370,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_StructI32) { // struct S { x : i32 }; // var g : S; Structure("S", utils::Vector{Member("x", ty.i32())}); - GlobalVar("g", ty("S"), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), + GlobalVar("g", ty("S"), builtin::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -380,7 +380,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_StructI32) { // struct S { x : i32 }; // type t = ptr; Structure("S", utils::Vector{Member("x", ty.i32())}); - Alias("t", ty.pointer(ty("S"), type::AddressSpace::kStorage, builtin::Access::kRead)); + Alias("t", ty.pointer(ty("S"), builtin::AddressSpace::kStorage, builtin::Access::kRead)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -392,7 +392,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_StructI32Alias Structure("S", utils::Vector{Member("x", ty.i32())}); Alias("a1", ty("S")); Alias("a2", ty("a1")); - GlobalVar("g", ty("a2"), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), + GlobalVar("g", ty("a2"), builtin::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -405,7 +405,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_StructI32Aliases Structure("S", utils::Vector{Member("x", ty.i32())}); Alias("a1", ty("S")); Alias("a2", ty("a1")); - Alias("t", ty.pointer(ty("a2"), type::AddressSpace::kStorage, builtin::Access::kRead)); + Alias("t", ty.pointer(ty("a2"), builtin::AddressSpace::kStorage, builtin::Access::kRead)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -416,7 +416,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_StructF16) { Enable(builtin::Extension::kF16); Structure("S", utils::Vector{Member("x", ty.f16())}); - GlobalVar("g", ty("S"), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), + GlobalVar("g", ty("S"), builtin::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -428,7 +428,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_StructF16) { Enable(builtin::Extension::kF16); Structure("S", utils::Vector{Member("x", ty.f16())}); - Alias("t", ty.pointer(ty("S"), type::AddressSpace::kStorage, builtin::Access::kRead)); + Alias("t", ty.pointer(ty("S"), builtin::AddressSpace::kStorage, builtin::Access::kRead)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -442,7 +442,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_StructF16Alias Structure("S", utils::Vector{Member("x", ty.f16())}); Alias("a1", ty("S")); Alias("a2", ty("a1")); - GlobalVar("g", ty("a2"), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), + GlobalVar("g", ty("a2"), builtin::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -457,14 +457,14 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_StructF16Aliases Structure("S", utils::Vector{Member("x", ty.f16())}); Alias("a1", ty("S")); Alias("a2", ty("a1")); - Alias("g", ty.pointer(ty("a2"), type::AddressSpace::kStorage, builtin::Access::kRead)); + Alias("g", ty.pointer(ty("a2"), builtin::AddressSpace::kStorage, builtin::Access::kRead)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_NotStorage_AccessMode) { // var g : a; - GlobalVar(Source{{12, 34}}, "g", ty.i32(), type::AddressSpace::kPrivate, + GlobalVar(Source{{12, 34}}, "g", ty.i32(), builtin::AddressSpace::kPrivate, builtin::Access::kRead); ASSERT_FALSE(r()->Resolve()); @@ -476,7 +476,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_NotStorage_AccessMode) TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_NotStorage_AccessMode) { // type t = ptr; - Alias("t", ty.pointer(Source{{12, 34}}, ty.i32(), type::AddressSpace::kPrivate, + Alias("t", ty.pointer(Source{{12, 34}}, ty.i32(), builtin::AddressSpace::kPrivate, builtin::Access::kRead)); ASSERT_FALSE(r()->Resolve()); @@ -488,7 +488,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_NotStorage_AccessMode) { TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_ReadAccessMode) { // @group(0) @binding(0) var a : i32; - GlobalVar("a", ty.i32(), type::AddressSpace::kStorage, builtin::Access::kRead, Group(0_a), + GlobalVar("a", ty.i32(), builtin::AddressSpace::kStorage, builtin::Access::kRead, Group(0_a), Binding(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -496,29 +496,29 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_ReadAccessMode TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_ReadAccessMode) { // type t = ptr; - Alias("t", ty.pointer(ty.i32(), type::AddressSpace::kStorage, builtin::Access::kRead)); + Alias("t", ty.pointer(ty.i32(), builtin::AddressSpace::kStorage, builtin::Access::kRead)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_ReadWriteAccessMode) { // @group(0) @binding(0) var a : i32; - GlobalVar("a", ty.i32(), type::AddressSpace::kStorage, builtin::Access::kReadWrite, Group(0_a), - Binding(0_a)); + GlobalVar("a", ty.i32(), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, + Group(0_a), Binding(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_ReadWriteAccessMode) { // type t = ptr; - Alias("t", ty.pointer(ty.i32(), type::AddressSpace::kStorage, builtin::Access::kReadWrite)); + Alias("t", ty.pointer(ty.i32(), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_WriteAccessMode) { // @group(0) @binding(0) var a : i32; - GlobalVar(Source{{12, 34}}, "a", ty.i32(), type::AddressSpace::kStorage, + GlobalVar(Source{{12, 34}}, "a", ty.i32(), builtin::AddressSpace::kStorage, builtin::Access::kWrite, Group(0_a), Binding(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -529,7 +529,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_WriteAccessMod TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_WriteAccessMode) { // type t = ptr; - Alias("t", ty.pointer(Source{{12, 34}}, ty.i32(), type::AddressSpace::kStorage, + Alias("t", ty.pointer(Source{{12, 34}}, ty.i32(), builtin::AddressSpace::kStorage, builtin::Access::kWrite)); ASSERT_FALSE(r()->Resolve()); @@ -545,7 +545,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_UniformBuffer_Struct_R Structure("S", utils::Vector{Member(Source{{56, 78}}, "m", ty.array(Source{{12, 34}}, ty.i32()))}); - GlobalVar(Source{{90, 12}}, "svar", ty("S"), type::AddressSpace::kUniform, Binding(0_a), + GlobalVar(Source{{90, 12}}, "svar", ty("S"), builtin::AddressSpace::kUniform, Binding(0_a), Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -562,7 +562,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_UniformBuffer_Struct_Run 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"), type::AddressSpace::kUniform)); + Alias("t", ty.pointer(Source{{90, 12}}, ty("S"), builtin::AddressSpace::kUniform)); ASSERT_FALSE(r()->Resolve()); EXPECT_EQ( @@ -577,7 +577,7 @@ note: see layout of struct: TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_UniformBufferBool) { // var g : bool; - GlobalVar(Source{{56, 78}}, "g", ty.bool_(Source{{12, 34}}), type::AddressSpace::kUniform, + GlobalVar(Source{{56, 78}}, "g", ty.bool_(Source{{12, 34}}), builtin::AddressSpace::kUniform, Binding(0_a), Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -590,8 +590,8 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_UniformBufferBool) { TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_UniformBufferBool) { // type t = ptr; - Alias("t", - ty.pointer(Source{{56, 78}}, ty.bool_(Source{{12, 34}}), type::AddressSpace::kUniform)); + Alias("t", ty.pointer(Source{{56, 78}}, ty.bool_(Source{{12, 34}}), + builtin::AddressSpace::kUniform)); ASSERT_FALSE(r()->Resolve()); @@ -605,7 +605,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_UniformBufferBoolAlias // type a = bool; // var g : a; Alias("a", ty.bool_()); - GlobalVar(Source{{56, 78}}, "g", ty(Source{{12, 34}}, "a"), type::AddressSpace::kUniform, + GlobalVar(Source{{56, 78}}, "g", ty(Source{{12, 34}}, "a"), builtin::AddressSpace::kUniform, Binding(0_a), Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -621,7 +621,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_UniformBufferBoolAlias) // type t = ptr; Alias("a", ty.bool_()); Alias("t", - ty.pointer(Source{{56, 78}}, ty(Source{{12, 34}}, "a"), type::AddressSpace::kUniform)); + ty.pointer(Source{{56, 78}}, ty(Source{{12, 34}}, "a"), builtin::AddressSpace::kUniform)); ASSERT_FALSE(r()->Resolve()); @@ -634,8 +634,8 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_UniformBufferBoolAlias) TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_UniformPointer) { // var g : ptr; GlobalVar(Source{{56, 78}}, "g", - ty.pointer(Source{{12, 34}}, ty.f32(), type::AddressSpace::kPrivate), - type::AddressSpace::kUniform, Binding(0_a), Group(0_a)); + ty.pointer(Source{{12, 34}}, ty.f32(), builtin::AddressSpace::kPrivate), + builtin::AddressSpace::kUniform, Binding(0_a), Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -648,8 +648,8 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_UniformPointer) { TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_UniformPointer) { // type t = ptr>; Alias("t", ty.pointer(Source{{56, 78}}, - ty.pointer(Source{{12, 34}}, ty.f32(), type::AddressSpace::kPrivate), - type::AddressSpace::kUniform)); + ty.pointer(Source{{12, 34}}, ty.f32(), builtin::AddressSpace::kPrivate), + builtin::AddressSpace::kUniform)); ASSERT_FALSE(r()->Resolve()); @@ -661,7 +661,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_UniformPointer) { TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_UniformBufferIntScalar) { // var g : i32; - GlobalVar(Source{{56, 78}}, "g", ty.i32(), type::AddressSpace::kUniform, Binding(0_a), + GlobalVar(Source{{56, 78}}, "g", ty.i32(), builtin::AddressSpace::kUniform, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -669,7 +669,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_UniformBufferIntScalar TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_UniformBufferIntScalar) { // type t = ptr; - Alias("t", ty.pointer(ty.i32(), type::AddressSpace::kUniform)); + Alias("t", ty.pointer(ty.i32(), builtin::AddressSpace::kUniform)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -679,7 +679,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_UniformBufferF16) { // var g : f16; Enable(builtin::Extension::kF16); - GlobalVar("g", ty.f16(), type::AddressSpace::kUniform, Binding(0_a), Group(0_a)); + GlobalVar("g", ty.f16(), builtin::AddressSpace::kUniform, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -689,21 +689,21 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_UniformBufferF16) { // type t = ptr; Enable(builtin::Extension::kF16); - Alias("t", ty.pointer(ty.f16(), type::AddressSpace::kUniform)); + Alias("t", ty.pointer(ty.f16(), builtin::AddressSpace::kUniform)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_UniformBufferVectorF32) { // var g : vec4; - GlobalVar("g", ty.vec4(), type::AddressSpace::kUniform, Binding(0_a), Group(0_a)); + GlobalVar("g", ty.vec4(), builtin::AddressSpace::kUniform, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_UniformBufferVectorF32) { // type t = ptr>; - Alias("t", ty.pointer(ty.vec4(), type::AddressSpace::kUniform)); + Alias("t", ty.pointer(ty.vec4(), builtin::AddressSpace::kUniform)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -713,7 +713,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_UniformBufferVectorF16 // var g : vec4; Enable(builtin::Extension::kF16); - GlobalVar("g", ty.vec4(), type::AddressSpace::kUniform, Binding(0_a), Group(0_a)); + GlobalVar("g", ty.vec4(), builtin::AddressSpace::kUniform, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -723,7 +723,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_UniformBufferVectorF16) // type t = ptr>; Enable(builtin::Extension::kF16); - Alias("t", ty.pointer(ty.vec4(), type::AddressSpace::kUniform)); + Alias("t", ty.pointer(ty.vec4(), builtin::AddressSpace::kUniform)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -734,7 +734,8 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_UniformBufferArrayF32) // } // var g : array; Structure("S", utils::Vector{Member("a", ty.f32(), utils::Vector{MemberSize(16_a)})}); - GlobalVar("g", ty.array(ty("S"), 3_u), type::AddressSpace::kUniform, Binding(0_a), Group(0_a)); + GlobalVar("g", ty.array(ty("S"), 3_u), builtin::AddressSpace::kUniform, Binding(0_a), + Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -745,7 +746,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_UniformBufferArrayF32) { // } // type t = ptr>; Structure("S", utils::Vector{Member("a", ty.f32(), utils::Vector{MemberSize(16_a)})}); - Alias("t", ty.pointer(ty.array(ty("S"), 3_u), type::AddressSpace::kUniform)); + Alias("t", ty.pointer(ty.array(ty("S"), 3_u), builtin::AddressSpace::kUniform)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -759,7 +760,8 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_UniformBufferArrayF16) Enable(builtin::Extension::kF16); Structure("S", utils::Vector{Member("a", ty.f16(), utils::Vector{MemberSize(16_a)})}); - GlobalVar("g", ty.array(ty("S"), 3_u), type::AddressSpace::kUniform, Binding(0_a), Group(0_a)); + GlobalVar("g", ty.array(ty("S"), 3_u), builtin::AddressSpace::kUniform, Binding(0_a), + Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -773,7 +775,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_UniformBufferArrayF16) { 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), type::AddressSpace::kUniform)); + Alias("t", ty.pointer(ty.array(ty("S"), 3_u), builtin::AddressSpace::kUniform)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -782,7 +784,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_UniformBufferStructI32 // struct S { x : i32 }; // var g : S; Structure("S", utils::Vector{Member("x", ty.i32())}); - GlobalVar("g", ty("S"), type::AddressSpace::kUniform, Binding(0_a), Group(0_a)); + GlobalVar("g", ty("S"), builtin::AddressSpace::kUniform, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -791,7 +793,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_UniformBufferStructI32) // struct S { x : i32 }; // type t = ptr; Structure("S", utils::Vector{Member("x", ty.i32())}); - Alias("t", ty.pointer(ty("S"), type::AddressSpace::kUniform)); + Alias("t", ty.pointer(ty("S"), builtin::AddressSpace::kUniform)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -802,7 +804,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_UniformBufferStructI32 // var g : a1; Structure("S", utils::Vector{Member("x", ty.i32())}); Alias("a1", ty("S")); - GlobalVar("g", ty("a1"), type::AddressSpace::kUniform, Binding(0_a), Group(0_a)); + GlobalVar("g", ty("a1"), builtin::AddressSpace::kUniform, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -813,7 +815,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_UniformBufferStructI32Al // type t = ptr; Structure("S", utils::Vector{Member("x", ty.i32())}); Alias("a1", ty("S")); - Alias("t", ty.pointer(ty("a1"), type::AddressSpace::kUniform)); + Alias("t", ty.pointer(ty("a1"), builtin::AddressSpace::kUniform)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -825,7 +827,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_UniformBufferStructF16 Enable(builtin::Extension::kF16); Structure("S", utils::Vector{Member("x", ty.f16())}); - GlobalVar("g", ty("S"), type::AddressSpace::kUniform, Binding(0_a), Group(0_a)); + GlobalVar("g", ty("S"), builtin::AddressSpace::kUniform, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -837,7 +839,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_UniformBufferStructF16) Enable(builtin::Extension::kF16); Structure("S", utils::Vector{Member("x", ty.f16())}); - Alias("t", ty.pointer(ty("S"), type::AddressSpace::kUniform)); + Alias("t", ty.pointer(ty("S"), builtin::AddressSpace::kUniform)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -851,7 +853,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_UniformBufferStructF16 Structure("S", utils::Vector{Member("x", ty.f16())}); Alias("a1", ty("S")); - GlobalVar("g", ty("a1"), type::AddressSpace::kUniform, Binding(0_a), Group(0_a)); + GlobalVar("g", ty("a1"), builtin::AddressSpace::kUniform, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -865,7 +867,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_UniformBufferStructF16Al Structure("S", utils::Vector{Member("x", ty.f16())}); Alias("a1", ty("S")); - Alias("t", ty.pointer(ty("a1"), type::AddressSpace::kUniform)); + Alias("t", ty.pointer(ty("a1"), builtin::AddressSpace::kUniform)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -874,7 +876,8 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_PushConstantBool) { // enable chromium_experimental_push_constant; // var g : bool; Enable(builtin::Extension::kChromiumExperimentalPushConstant); - GlobalVar(Source{{56, 78}}, "g", ty.bool_(Source{{12, 34}}), type::AddressSpace::kPushConstant); + GlobalVar(Source{{56, 78}}, "g", ty.bool_(Source{{12, 34}}), + builtin::AddressSpace::kPushConstant); ASSERT_FALSE(r()->Resolve()); EXPECT_EQ( @@ -888,7 +891,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_PushConstantBool) { // type t = ptr; Enable(builtin::Extension::kChromiumExperimentalPushConstant); Alias(Source{{56, 78}}, "t", - ty.pointer(ty.bool_(Source{{12, 34}}), type::AddressSpace::kPushConstant)); + ty.pointer(ty.bool_(Source{{12, 34}}), builtin::AddressSpace::kPushConstant)); ASSERT_FALSE(r()->Resolve()); EXPECT_EQ( @@ -903,7 +906,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_PushConstantF16) { // var g : f16; Enable(builtin::Extension::kF16); Enable(builtin::Extension::kChromiumExperimentalPushConstant); - GlobalVar("g", ty.f16(Source{{56, 78}}), type::AddressSpace::kPushConstant); + GlobalVar("g", ty.f16(Source{{56, 78}}), builtin::AddressSpace::kPushConstant); ASSERT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -916,7 +919,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_PushConstantF16) { // type t = ptr; Enable(builtin::Extension::kF16); Enable(builtin::Extension::kChromiumExperimentalPushConstant); - Alias("t", ty.pointer(ty.f16(Source{{56, 78}}), type::AddressSpace::kPushConstant)); + Alias("t", ty.pointer(ty.f16(Source{{56, 78}}), builtin::AddressSpace::kPushConstant)); ASSERT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -928,8 +931,8 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_PushConstantPointer) { // var g : ptr; Enable(builtin::Extension::kChromiumExperimentalPushConstant); GlobalVar(Source{{56, 78}}, "g", - ty.pointer(Source{{12, 34}}, ty.f32(), type::AddressSpace::kPrivate), - type::AddressSpace::kPushConstant); + ty.pointer(Source{{12, 34}}, ty.f32(), builtin::AddressSpace::kPrivate), + builtin::AddressSpace::kPushConstant); ASSERT_FALSE(r()->Resolve()); EXPECT_EQ( @@ -943,8 +946,8 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_PushConstantPointer) { // type t = ptr>; Enable(builtin::Extension::kChromiumExperimentalPushConstant); Alias(Source{{56, 78}}, "t", - ty.pointer(ty.pointer(Source{{12, 34}}, ty.f32(), type::AddressSpace::kPrivate), - type::AddressSpace::kPushConstant)); + ty.pointer(ty.pointer(Source{{12, 34}}, ty.f32(), builtin::AddressSpace::kPrivate), + builtin::AddressSpace::kPushConstant)); ASSERT_FALSE(r()->Resolve()); EXPECT_EQ( @@ -957,7 +960,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_PushConstantIntScalar) // enable chromium_experimental_push_constant; // var g : i32; Enable(builtin::Extension::kChromiumExperimentalPushConstant); - GlobalVar("g", ty.i32(), type::AddressSpace::kPushConstant); + GlobalVar("g", ty.i32(), builtin::AddressSpace::kPushConstant); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -966,7 +969,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_PushConstantIntScalar) { // enable chromium_experimental_push_constant; // type t = ptr; Enable(builtin::Extension::kChromiumExperimentalPushConstant); - Alias("t", ty.pointer(ty.i32(), type::AddressSpace::kPushConstant)); + Alias("t", ty.pointer(ty.i32(), builtin::AddressSpace::kPushConstant)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -975,7 +978,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_PushConstantVectorF32) // enable chromium_experimental_push_constant; // var g : vec4; Enable(builtin::Extension::kChromiumExperimentalPushConstant); - GlobalVar("g", ty.vec4(), type::AddressSpace::kPushConstant); + GlobalVar("g", ty.vec4(), builtin::AddressSpace::kPushConstant); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -984,7 +987,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_PushConstantVectorF32) { // enable chromium_experimental_push_constant; // var g : vec4; Enable(builtin::Extension::kChromiumExperimentalPushConstant); - Alias("t", ty.pointer(ty.vec4(), type::AddressSpace::kPushConstant)); + Alias("t", ty.pointer(ty.vec4(), builtin::AddressSpace::kPushConstant)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -995,7 +998,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_PushConstantArrayF32) // var g : array; Enable(builtin::Extension::kChromiumExperimentalPushConstant); Structure("S", utils::Vector{Member("a", ty.f32())}); - GlobalVar("g", ty.array(ty("S"), 3_u), type::AddressSpace::kPushConstant); + GlobalVar("g", ty.array(ty("S"), 3_u), builtin::AddressSpace::kPushConstant); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -1006,7 +1009,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_PushConstantArrayF32) { // type t = ptr>; Enable(builtin::Extension::kChromiumExperimentalPushConstant); Structure("S", utils::Vector{Member("a", ty.f32())}); - Alias("t", ty.pointer(ty.array(ty("S"), 3_u), type::AddressSpace::kPushConstant)); + Alias("t", ty.pointer(ty.array(ty("S"), 3_u), builtin::AddressSpace::kPushConstant)); 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 cc55f0b7c9..e1e86308b1 100644 --- a/src/tint/resolver/alias_analysis_test.cc +++ b/src/tint/resolver/alias_analysis_test.cc @@ -35,19 +35,19 @@ struct ResolverAliasAnalysisTest : public resolver::TestHelper, public testing:: // target(&v1, aliased ? &v1 : &v2); // } struct TwoPointerConfig { - type::AddressSpace address_space; // The address space for the pointers. - bool aliased; // Whether the pointers alias or not. + builtin::AddressSpace address_space; // The address space for the pointers. + bool aliased; // Whether the pointers alias or not. }; class TwoPointers : public ResolverTestWithParam { protected: void SetUp() override { utils::Vector body; - if (GetParam().address_space == type::AddressSpace::kFunction) { + if (GetParam().address_space == builtin::AddressSpace::kFunction) { body.Push(Decl(Var("v1", ty.i32()))); body.Push(Decl(Var("v2", ty.i32()))); } else { - GlobalVar("v1", type::AddressSpace::kPrivate, ty.i32()); - GlobalVar("v2", type::AddressSpace::kPrivate, ty.i32()); + GlobalVar("v1", builtin::AddressSpace::kPrivate, ty.i32()); + GlobalVar("v2", builtin::AddressSpace::kPrivate, ty.i32()); } body.Push(CallStmt(Call("target", AddressOf(Source{{12, 34}}, "v1"), AddressOf(Source{{56, 78}}, GetParam().aliased ? "v1" : "v2")))); @@ -190,10 +190,11 @@ TEST_P(TwoPointers, ReadWriteAcrossDifferentFunctions) { INSTANTIATE_TEST_SUITE_P(ResolverAliasAnalysisTest, TwoPointers, - ::testing::Values(TwoPointerConfig{type::AddressSpace::kFunction, false}, - TwoPointerConfig{type::AddressSpace::kFunction, true}, - TwoPointerConfig{type::AddressSpace::kPrivate, false}, - TwoPointerConfig{type::AddressSpace::kPrivate, true}), + ::testing::Values(TwoPointerConfig{builtin::AddressSpace::kFunction, + false}, + TwoPointerConfig{builtin::AddressSpace::kFunction, true}, + TwoPointerConfig{builtin::AddressSpace::kPrivate, false}, + TwoPointerConfig{builtin::AddressSpace::kPrivate, true}), [](const ::testing::TestParamInfo& p) { std::stringstream ss; ss << (p.param.aliased ? "Aliased" : "Unaliased") << "_" @@ -214,8 +215,8 @@ INSTANTIATE_TEST_SUITE_P(ResolverAliasAnalysisTest, class OnePointerOneModuleScope : public ResolverTestWithParam { protected: void SetUp() override { - GlobalVar("global_1", type::AddressSpace::kPrivate, ty.i32()); - GlobalVar("global_2", type::AddressSpace::kPrivate, ty.i32()); + GlobalVar("global_1", builtin::AddressSpace::kPrivate, ty.i32()); + GlobalVar("global_2", builtin::AddressSpace::kPrivate, ty.i32()); Func("caller", utils::Empty, ty.void_(), utils::Vector{ CallStmt(Call("target", @@ -226,7 +227,7 @@ class OnePointerOneModuleScope : public ResolverTestWithParam { void Run(utils::Vector&& body, const char* err = nullptr) { Func("target", utils::Vector{ - Param("p1", ty.pointer(type::AddressSpace::kPrivate)), + Param("p1", ty.pointer(builtin::AddressSpace::kPrivate)), }, ty.void_(), std::move(body)); if (GetParam() && err) { @@ -295,7 +296,7 @@ TEST_P(OnePointerOneModuleScope, ReadWriteThroughChain_GlobalViaArg) { // f1(p1); Func("f2", utils::Vector{ - Param("p1", ty.pointer(type::AddressSpace::kPrivate)), + Param("p1", ty.pointer(builtin::AddressSpace::kPrivate)), }, ty.void_(), utils::Vector{ @@ -303,7 +304,7 @@ TEST_P(OnePointerOneModuleScope, ReadWriteThroughChain_GlobalViaArg) { }); Func("f1", utils::Vector{ - Param("p1", ty.pointer(type::AddressSpace::kPrivate)), + Param("p1", ty.pointer(builtin::AddressSpace::kPrivate)), }, ty.void_(), utils::Vector{ @@ -330,7 +331,7 @@ TEST_P(OnePointerOneModuleScope, ReadWriteThroughChain_Both) { // f1(p1); Func("f2", utils::Vector{ - Param("p1", ty.pointer(type::AddressSpace::kPrivate)), + Param("p1", ty.pointer(builtin::AddressSpace::kPrivate)), }, ty.void_(), utils::Vector{ @@ -339,7 +340,7 @@ TEST_P(OnePointerOneModuleScope, ReadWriteThroughChain_Both) { }); Func("f1", utils::Vector{ - Param("p1", ty.pointer(type::AddressSpace::kPrivate)), + Param("p1", ty.pointer(builtin::AddressSpace::kPrivate)), }, ty.void_(), utils::Vector{ @@ -365,7 +366,7 @@ TEST_P(OnePointerOneModuleScope, WriteReadThroughChain_GlobalViaArg) { // f1(p1); Func("f2", utils::Vector{ - Param("p1", ty.pointer(type::AddressSpace::kPrivate)), + Param("p1", ty.pointer(builtin::AddressSpace::kPrivate)), }, ty.void_(), utils::Vector{ @@ -373,7 +374,7 @@ TEST_P(OnePointerOneModuleScope, WriteReadThroughChain_GlobalViaArg) { }); Func("f1", utils::Vector{ - Param("p1", ty.pointer(type::AddressSpace::kPrivate)), + Param("p1", ty.pointer(builtin::AddressSpace::kPrivate)), }, ty.void_(), utils::Vector{ @@ -400,7 +401,7 @@ TEST_P(OnePointerOneModuleScope, WriteReadThroughChain_Both) { // f1(p1); Func("f2", utils::Vector{ - Param("p1", ty.pointer(type::AddressSpace::kPrivate)), + Param("p1", ty.pointer(builtin::AddressSpace::kPrivate)), }, ty.void_(), utils::Vector{ @@ -409,7 +410,7 @@ TEST_P(OnePointerOneModuleScope, WriteReadThroughChain_Both) { }); Func("f1", utils::Vector{ - Param("p1", ty.pointer(type::AddressSpace::kPrivate)), + Param("p1", ty.pointer(builtin::AddressSpace::kPrivate)), }, ty.void_(), utils::Vector{ @@ -435,7 +436,7 @@ TEST_P(OnePointerOneModuleScope, ReadWriteAcrossDifferentFunctions) { // f2(); Func("f1", utils::Vector{ - Param("p1", ty.pointer(type::AddressSpace::kPrivate)), + Param("p1", ty.pointer(builtin::AddressSpace::kPrivate)), }, ty.void_(), utils::Vector{ @@ -487,8 +488,8 @@ class Use : public ResolverTestWithParam { void Run(const ast::Statement* stmt, const char* err = nullptr) { Func("target", utils::Vector{ - Param("p1", ty.pointer(type::AddressSpace::kFunction)), - Param("p2", ty.pointer(type::AddressSpace::kFunction)), + Param("p1", ty.pointer(builtin::AddressSpace::kFunction)), + Param("p2", ty.pointer(builtin::AddressSpace::kFunction)), }, ty.void_(), utils::Vector{ @@ -531,7 +532,7 @@ TEST_P(Use, Write_CompoundAssignment_LHS) { TEST_P(Use, Read_CompoundAssignment_RHS) { // var global : i32; // global += *p2; - GlobalVar("global", type::AddressSpace::kPrivate, ty.i32()); + GlobalVar("global", builtin::AddressSpace::kPrivate, ty.i32()); Run(CompoundAssign("global", Deref("p2"), ast::BinaryOp::kAdd), R"(56:78 error: invalid aliased pointer argument 12:34 note: aliases with another argument passed here)"); @@ -578,7 +579,7 @@ TEST_P(Use, Read_Convert) { TEST_P(Use, Read_IndexAccessor) { // var data : array; // _ = data[*p2]; - GlobalVar("data", type::AddressSpace::kPrivate, ty.array()); + GlobalVar("data", builtin::AddressSpace::kPrivate, ty.array()); Run(Assign(Phony(), IndexAccessor("data", Deref("p2"))), R"(56:78 error: invalid aliased pointer argument 12:34 note: aliases with another argument passed here)"); @@ -592,7 +593,7 @@ TEST_P(Use, Read_LetInitializer) { TEST_P(Use, Read_VarInitializer) { // var x = *p2; - Run(Decl(Var("x", type::AddressSpace::kFunction, Deref("p2"))), + Run(Decl(Var("x", builtin::AddressSpace::kFunction, Deref("p2"))), R"(56:78 error: invalid aliased pointer argument 12:34 note: aliases with another argument passed here)"); } @@ -602,7 +603,7 @@ TEST_P(Use, Read_ReturnValue) { // foo(p2); Func("foo", utils::Vector{ - Param("p", ty.pointer(type::AddressSpace::kFunction)), + Param("p", ty.pointer(builtin::AddressSpace::kFunction)), }, ty.i32(), utils::Vector{ @@ -659,8 +660,8 @@ class UseBool : public ResolverTestWithParam { void Run(const ast::Statement* stmt, const char* err = nullptr) { Func("target", utils::Vector{ - Param("p1", ty.pointer(type::AddressSpace::kFunction)), - Param("p2", ty.pointer(type::AddressSpace::kFunction)), + Param("p1", ty.pointer(builtin::AddressSpace::kFunction)), + Param("p2", ty.pointer(builtin::AddressSpace::kFunction)), }, ty.void_(), utils::Vector{ @@ -724,8 +725,8 @@ TEST_F(ResolverAliasAnalysisTest, NoAccess_MemberAccessor) { Structure("S", utils::Vector{Member("a", ty.i32())}); Func("f2", utils::Vector{ - Param("p1", ty.pointer(ty("S"), type::AddressSpace::kFunction)), - Param("p2", ty.pointer(ty("S"), type::AddressSpace::kFunction)), + Param("p1", ty.pointer(ty("S"), builtin::AddressSpace::kFunction)), + Param("p2", ty.pointer(ty("S"), builtin::AddressSpace::kFunction)), }, ty.void_(), utils::Vector{ @@ -753,8 +754,8 @@ TEST_F(ResolverAliasAnalysisTest, Read_MemberAccessor) { Structure("S", utils::Vector{Member("a", ty.i32())}); Func("f2", utils::Vector{ - Param("p1", ty.pointer(ty("S"), type::AddressSpace::kFunction)), - Param("p2", ty.pointer(ty("S"), type::AddressSpace::kFunction)), + Param("p1", ty.pointer(ty("S"), builtin::AddressSpace::kFunction)), + Param("p2", ty.pointer(ty("S"), builtin::AddressSpace::kFunction)), }, ty.void_(), utils::Vector{ @@ -785,8 +786,8 @@ TEST_F(ResolverAliasAnalysisTest, Write_MemberAccessor) { Structure("S", utils::Vector{Member("a", ty.i32())}); Func("f2", utils::Vector{ - Param("p1", ty.pointer(ty("S"), type::AddressSpace::kFunction)), - Param("p2", ty.pointer(ty("S"), type::AddressSpace::kFunction)), + Param("p1", ty.pointer(ty("S"), builtin::AddressSpace::kFunction)), + Param("p2", ty.pointer(ty("S"), builtin::AddressSpace::kFunction)), }, ty.void_(), utils::Vector{ @@ -816,8 +817,8 @@ TEST_F(ResolverAliasAnalysisTest, Read_MultiComponentSwizzle) { Structure("S", utils::Vector{Member("a", ty.i32())}); Func("f2", utils::Vector{ - Param("p1", ty.pointer(ty.vec4(), type::AddressSpace::kFunction)), - Param("p2", ty.pointer(ty.vec4(), type::AddressSpace::kFunction)), + Param("p1", ty.pointer(ty.vec4(), builtin::AddressSpace::kFunction)), + Param("p2", ty.pointer(ty.vec4(), builtin::AddressSpace::kFunction)), }, ty.void_(), utils::Vector{ @@ -848,7 +849,7 @@ TEST_F(ResolverAliasAnalysisTest, SinglePointerReadWrite) { // } Func("f1", utils::Vector{ - Param("p", ty.pointer(type::AddressSpace::kFunction)), + Param("p", ty.pointer(builtin::AddressSpace::kFunction)), }, ty.void_(), utils::Vector{ @@ -901,7 +902,7 @@ TEST_F(ResolverAliasAnalysisTest, NonOverlappingCalls) { // } Func("f2", utils::Vector{ - Param("p", ty.pointer(type::AddressSpace::kFunction)), + Param("p", ty.pointer(builtin::AddressSpace::kFunction)), }, ty.void_(), utils::Vector{ @@ -909,7 +910,7 @@ TEST_F(ResolverAliasAnalysisTest, NonOverlappingCalls) { }); Func("f3", utils::Vector{ - Param("p", ty.pointer(type::AddressSpace::kFunction)), + Param("p", ty.pointer(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 fc7bdeb03d..e18a618500 100644 --- a/src/tint/resolver/array_accessor_test.cc +++ b/src/tint/resolver/array_accessor_test.cc @@ -27,7 +27,7 @@ namespace { using ResolverIndexAccessorTest = ResolverTest; TEST_F(ResolverIndexAccessorTest, Matrix_Dynamic_F32) { - GlobalVar("my_var", ty.mat2x3(), type::AddressSpace::kPrivate); + GlobalVar("my_var", ty.mat2x3(), builtin::AddressSpace::kPrivate); auto* acc = IndexAccessor("my_var", Expr(Source{{12, 34}}, 1_f)); WrapInFunction(acc); @@ -36,7 +36,7 @@ TEST_F(ResolverIndexAccessorTest, Matrix_Dynamic_F32) { } TEST_F(ResolverIndexAccessorTest, Matrix_Dynamic_Ref) { - GlobalVar("my_var", ty.mat2x3(), type::AddressSpace::kPrivate); + GlobalVar("my_var", ty.mat2x3(), builtin::AddressSpace::kPrivate); auto* idx = Var("idx", ty.i32(), Call()); auto* acc = IndexAccessor("my_var", idx); WrapInFunction(Decl(idx), acc); @@ -50,7 +50,7 @@ TEST_F(ResolverIndexAccessorTest, Matrix_Dynamic_Ref) { } TEST_F(ResolverIndexAccessorTest, Matrix_BothDimensions_Dynamic_Ref) { - GlobalVar("my_var", ty.mat4x4(), type::AddressSpace::kPrivate); + GlobalVar("my_var", ty.mat4x4(), builtin::AddressSpace::kPrivate); auto* idx = Var("idx", ty.u32(), Expr(3_u)); auto* idy = Var("idy", ty.u32(), Expr(2_u)); auto* acc = IndexAccessor(IndexAccessor("my_var", idx), idy); @@ -100,7 +100,7 @@ TEST_F(ResolverIndexAccessorTest, Matrix_BothDimension_Dynamic) { } TEST_F(ResolverIndexAccessorTest, Matrix) { - GlobalVar("my_var", ty.mat2x3(), type::AddressSpace::kPrivate); + GlobalVar("my_var", ty.mat2x3(), builtin::AddressSpace::kPrivate); auto* acc = IndexAccessor("my_var", 1_i); WrapInFunction(acc); @@ -118,7 +118,7 @@ TEST_F(ResolverIndexAccessorTest, Matrix) { } TEST_F(ResolverIndexAccessorTest, Matrix_BothDimensions) { - GlobalVar("my_var", ty.mat2x3(), type::AddressSpace::kPrivate); + GlobalVar("my_var", ty.mat2x3(), builtin::AddressSpace::kPrivate); auto* acc = IndexAccessor(IndexAccessor("my_var", 0_i), 1_i); WrapInFunction(acc); @@ -135,7 +135,7 @@ TEST_F(ResolverIndexAccessorTest, Matrix_BothDimensions) { } TEST_F(ResolverIndexAccessorTest, Vector_F32) { - GlobalVar("my_var", ty.vec3(), type::AddressSpace::kPrivate); + GlobalVar("my_var", ty.vec3(), builtin::AddressSpace::kPrivate); auto* acc = IndexAccessor("my_var", Expr(Source{{12, 34}}, 2_f)); WrapInFunction(acc); @@ -144,7 +144,7 @@ TEST_F(ResolverIndexAccessorTest, Vector_F32) { } TEST_F(ResolverIndexAccessorTest, Vector_Dynamic_Ref) { - GlobalVar("my_var", ty.vec3(), type::AddressSpace::kPrivate); + GlobalVar("my_var", ty.vec3(), builtin::AddressSpace::kPrivate); auto* idx = Var("idx", ty.i32(), Expr(2_i)); auto* acc = IndexAccessor("my_var", idx); WrapInFunction(Decl(idx), acc); @@ -167,7 +167,7 @@ TEST_F(ResolverIndexAccessorTest, Vector_Dynamic) { } TEST_F(ResolverIndexAccessorTest, Vector) { - GlobalVar("my_var", ty.vec3(), type::AddressSpace::kPrivate); + GlobalVar("my_var", ty.vec3(), builtin::AddressSpace::kPrivate); auto* acc = IndexAccessor("my_var", 2_i); WrapInFunction(acc); @@ -184,7 +184,7 @@ TEST_F(ResolverIndexAccessorTest, Vector) { } TEST_F(ResolverIndexAccessorTest, Array_Literal_i32) { - GlobalVar("my_var", ty.array(), type::AddressSpace::kPrivate); + GlobalVar("my_var", ty.array(), builtin::AddressSpace::kPrivate); auto* acc = IndexAccessor("my_var", 2_i); WrapInFunction(acc); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -197,7 +197,7 @@ TEST_F(ResolverIndexAccessorTest, Array_Literal_i32) { } TEST_F(ResolverIndexAccessorTest, Array_Literal_u32) { - GlobalVar("my_var", ty.array(), type::AddressSpace::kPrivate); + GlobalVar("my_var", ty.array(), builtin::AddressSpace::kPrivate); auto* acc = IndexAccessor("my_var", 2_u); WrapInFunction(acc); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -210,7 +210,7 @@ TEST_F(ResolverIndexAccessorTest, Array_Literal_u32) { } TEST_F(ResolverIndexAccessorTest, Array_Literal_AInt) { - GlobalVar("my_var", ty.array(), type::AddressSpace::kPrivate); + GlobalVar("my_var", ty.array(), builtin::AddressSpace::kPrivate); auto* acc = IndexAccessor("my_var", 2_a); WrapInFunction(acc); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -225,7 +225,7 @@ TEST_F(ResolverIndexAccessorTest, Array_Literal_AInt) { TEST_F(ResolverIndexAccessorTest, Alias_Array) { auto* aary = Alias("myarrty", ty.array()); - GlobalVar("my_var", ty.Of(aary), type::AddressSpace::kPrivate); + GlobalVar("my_var", ty.Of(aary), builtin::AddressSpace::kPrivate); auto* acc = IndexAccessor("my_var", 2_i); WrapInFunction(acc); @@ -316,7 +316,7 @@ TEST_F(ResolverIndexAccessorTest, Expr_Deref_FuncGoodParent) { // let x: f32 = (*p)[idx]; // return x; // } - auto* p = Param("p", ty.pointer(ty.vec4(), type::AddressSpace::kFunction)); + auto* p = Param("p", ty.pointer(ty.vec4(), builtin::AddressSpace::kFunction)); auto* idx = Let("idx", ty.u32(), Call()); auto* star_p = Deref(p); auto* acc = IndexAccessor(Source{{12, 34}}, star_p, idx); @@ -337,7 +337,7 @@ TEST_F(ResolverIndexAccessorTest, Expr_Deref_FuncBadParent) { // let x: f32 = *p[idx]; // return x; // } - auto* p = Param("p", ty.pointer(ty.vec4(), type::AddressSpace::kFunction)); + auto* p = Param("p", ty.pointer(ty.vec4(), builtin::AddressSpace::kFunction)); auto* idx = Let("idx", ty.u32(), Call()); 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 f8f663bcaf..b549daf4dd 100644 --- a/src/tint/resolver/assignment_validation_test.cc +++ b/src/tint/resolver/assignment_validation_test.cc @@ -33,8 +33,8 @@ TEST_F(ResolverAssignmentValidationTest, ReadOnlyBuffer) { auto* s = Structure("S", utils::Vector{ Member("m", ty.i32()), }); - GlobalVar(Source{{12, 34}}, "a", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, - Binding(0_a), Group(0_a)); + GlobalVar(Source{{12, 34}}, "a", ty.Of(s), builtin::AddressSpace::kStorage, + builtin::Access::kRead, Binding(0_a), Group(0_a)); WrapInFunction(Assign(Source{{56, 78}}, MemberAccessor("a", "m"), 1_i)); @@ -193,7 +193,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignThroughPointer_Pass) { // var a : i32; // let b : ptr = &a; // *b = 2i; - const auto func = type::AddressSpace::kFunction; + const auto func = builtin::AddressSpace::kFunction; WrapInFunction(Var("a", ty.i32(), func, Expr(2_i)), // Let("b", ty.pointer(func), AddressOf(Expr("a"))), // Assign(Deref("b"), 2_i)); @@ -205,7 +205,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignMaterializedThroughPointer_Pass) // var a : i32; // let b : ptr = &a; // *b = 2; - const auto func = type::AddressSpace::kFunction; + const auto func = builtin::AddressSpace::kFunction; auto* var_a = Var("a", ty.i32(), func, Expr(2_i)); auto* var_b = Let("b", ty.pointer(func), AddressOf(Expr("a"))); WrapInFunction(var_a, var_b, Assign(Deref("b"), 2_a)); @@ -252,7 +252,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_Atomic) { auto* s = Structure("S", utils::Vector{ Member("a", ty.atomic(ty.i32())), }); - GlobalVar(Source{{12, 34}}, "v", ty.Of(s), type::AddressSpace::kStorage, + GlobalVar(Source{{12, 34}}, "v", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, Binding(0_a), Group(0_a)); WrapInFunction(Assign(Source{{56, 78}}, MemberAccessor("v", "a"), MemberAccessor("v", "a"))); @@ -269,7 +269,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_RuntimeArray) { auto* s = Structure("S", utils::Vector{ Member("a", ty.array(ty.f32())), }); - GlobalVar(Source{{12, 34}}, "v", ty.Of(s), type::AddressSpace::kStorage, + GlobalVar(Source{{12, 34}}, "v", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, Binding(0_a), Group(0_a)); WrapInFunction(Assign(Source{{56, 78}}, MemberAccessor("v", "a"), MemberAccessor("v", "a"))); @@ -289,7 +289,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignToPhony_NonConstructibleStruct_Fa auto* s = Structure("S", utils::Vector{ Member("arr", ty.array()), }); - GlobalVar("s", ty.Of(s), type::AddressSpace::kStorage, Group(0_a), Binding(0_a)); + GlobalVar("s", ty.Of(s), builtin::AddressSpace::kStorage, Group(0_a), Binding(0_a)); WrapInFunction(Assign(Phony(), Expr(Source{{12, 34}}, "s"))); @@ -311,7 +311,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignToPhony_DynamicArray_Fail) { auto* s = Structure("S", utils::Vector{ Member("arr", ty.array()), }); - GlobalVar("s", ty.Of(s), type::AddressSpace::kStorage, Group(0_a), Binding(0_a)); + GlobalVar("s", ty.Of(s), builtin::AddressSpace::kStorage, Group(0_a), Binding(0_a)); WrapInFunction(Assign(Phony(), MemberAccessor(Source{{12, 34}}, "s", "arr"))); @@ -364,9 +364,9 @@ TEST_F(ResolverAssignmentValidationTest, AssignToPhony_Pass) { GlobalVar("tex", ty.sampled_texture(type::TextureDimension::k2d, ty.f32()), Group(0_a), Binding(0_a)); GlobalVar("smp", ty.sampler(type::SamplerKind::kSampler), Group(0_a), Binding(1_a)); - GlobalVar("u", ty.Of(U), type::AddressSpace::kUniform, Group(0_a), Binding(2_a)); - GlobalVar("s", ty.Of(S), type::AddressSpace::kStorage, Group(0_a), Binding(3_a)); - GlobalVar("wg", ty.array(), type::AddressSpace::kWorkgroup); + GlobalVar("u", ty.Of(U), builtin::AddressSpace::kUniform, Group(0_a), Binding(2_a)); + GlobalVar("s", ty.Of(S), builtin::AddressSpace::kStorage, Group(0_a), Binding(3_a)); + GlobalVar("wg", ty.array(), builtin::AddressSpace::kWorkgroup); WrapInFunction(Assign(Phony(), 1_i), // Assign(Phony(), 2_u), // diff --git a/src/tint/resolver/atomics_test.cc b/src/tint/resolver/atomics_test.cc index 45d56bf377..f0791595ad 100644 --- a/src/tint/resolver/atomics_test.cc +++ b/src/tint/resolver/atomics_test.cc @@ -27,7 +27,8 @@ using namespace tint::number_suffixes; // NOLINT struct ResolverAtomicTest : public resolver::TestHelper, public testing::Test {}; TEST_F(ResolverAtomicTest, GlobalWorkgroupI32) { - auto* g = GlobalVar("a", ty.atomic(Source{{12, 34}}, ty.i32()), type::AddressSpace::kWorkgroup); + auto* g = + GlobalVar("a", ty.atomic(Source{{12, 34}}, ty.i32()), builtin::AddressSpace::kWorkgroup); EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_TRUE(TypeOf(g)->Is()); @@ -37,7 +38,8 @@ TEST_F(ResolverAtomicTest, GlobalWorkgroupI32) { } TEST_F(ResolverAtomicTest, GlobalWorkgroupU32) { - auto* g = GlobalVar("a", ty.atomic(Source{{12, 34}}, ty.u32()), type::AddressSpace::kWorkgroup); + auto* g = + GlobalVar("a", ty.atomic(Source{{12, 34}}, ty.u32()), builtin::AddressSpace::kWorkgroup); EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_TRUE(TypeOf(g)->Is()); @@ -48,7 +50,7 @@ TEST_F(ResolverAtomicTest, GlobalWorkgroupU32) { TEST_F(ResolverAtomicTest, GlobalStorageStruct) { auto* s = Structure("s", utils::Vector{Member("a", ty.atomic(Source{{12, 34}}, ty.i32()))}); - auto* g = GlobalVar("g", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + auto* g = GlobalVar("g", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, Binding(0_a), Group(0_a)); EXPECT_TRUE(r()->Resolve()) << r()->error(); diff --git a/src/tint/resolver/atomics_validation_test.cc b/src/tint/resolver/atomics_validation_test.cc index 919722b4ea..a557956531 100644 --- a/src/tint/resolver/atomics_validation_test.cc +++ b/src/tint/resolver/atomics_validation_test.cc @@ -27,13 +27,13 @@ namespace { struct ResolverAtomicValidationTest : public resolver::TestHelper, public testing::Test {}; TEST_F(ResolverAtomicValidationTest, AddressSpace_WorkGroup) { - GlobalVar("a", ty.atomic(Source{{12, 34}}, ty.i32()), type::AddressSpace::kWorkgroup); + GlobalVar("a", ty.atomic(Source{{12, 34}}, ty.i32()), builtin::AddressSpace::kWorkgroup); EXPECT_TRUE(r()->Resolve()); } TEST_F(ResolverAtomicValidationTest, AddressSpace_Storage) { - GlobalVar("g", ty.atomic(Source{{12, 34}}, ty.i32()), type::AddressSpace::kStorage, + GlobalVar("g", ty.atomic(Source{{12, 34}}, ty.i32()), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, Group(0_a), Binding(0_a)); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -41,21 +41,21 @@ TEST_F(ResolverAtomicValidationTest, AddressSpace_Storage) { TEST_F(ResolverAtomicValidationTest, AddressSpace_Storage_Struct) { auto* s = Structure("s", utils::Vector{Member(Source{{12, 34}}, "a", ty.atomic(ty.i32()))}); - GlobalVar("g", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, Group(0_a), - Binding(0_a)); + GlobalVar("g", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, + Group(0_a), Binding(0_a)); EXPECT_TRUE(r()->Resolve()) << r()->error(); } TEST_F(ResolverAtomicValidationTest, InvalidType) { - GlobalVar("a", ty.atomic(ty.f32(Source{{12, 34}})), type::AddressSpace::kWorkgroup); + GlobalVar("a", ty.atomic(ty.f32(Source{{12, 34}})), builtin::AddressSpace::kWorkgroup); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), "12:34 error: atomic only supports i32 or u32 types"); } TEST_F(ResolverAtomicValidationTest, InvalidAddressSpace_Simple) { - GlobalVar(Source{{12, 34}}, "a", ty.atomic(ty.i32()), type::AddressSpace::kPrivate); + GlobalVar(Source{{12, 34}}, "a", ty.atomic(ty.i32()), builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -63,7 +63,7 @@ TEST_F(ResolverAtomicValidationTest, InvalidAddressSpace_Simple) { } TEST_F(ResolverAtomicValidationTest, InvalidAddressSpace_Array) { - GlobalVar(Source{{12, 34}}, "a", ty.atomic(ty.i32()), type::AddressSpace::kPrivate); + GlobalVar(Source{{12, 34}}, "a", ty.atomic(ty.i32()), builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -72,7 +72,7 @@ TEST_F(ResolverAtomicValidationTest, InvalidAddressSpace_Array) { TEST_F(ResolverAtomicValidationTest, InvalidAddressSpace_Struct) { auto* s = Structure("s", utils::Vector{Member("a", ty.atomic(ty.i32()))}); - GlobalVar(Source{{56, 78}}, "g", ty.Of(s), type::AddressSpace::kPrivate); + GlobalVar(Source{{56, 78}}, "g", ty.Of(s), builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -88,7 +88,7 @@ TEST_F(ResolverAtomicValidationTest, InvalidAddressSpace_StructOfStruct) { auto* Inner = Structure("Inner", utils::Vector{Member("m", ty.atomic(Source{{12, 34}}, ty.i32()))}); auto* Outer = Structure("Outer", utils::Vector{Member("m", ty.Of(Inner))}); - GlobalVar(Source{{56, 78}}, "g", ty.Of(Outer), type::AddressSpace::kPrivate); + GlobalVar(Source{{56, 78}}, "g", ty.Of(Outer), builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -104,7 +104,7 @@ TEST_F(ResolverAtomicValidationTest, InvalidAddressSpace_StructOfStructOfArray) auto* Inner = Structure("Inner", utils::Vector{Member(Source{{12, 34}}, "m", ty.atomic(ty.i32()))}); auto* Outer = Structure("Outer", utils::Vector{Member("m", ty.Of(Inner))}); - GlobalVar(Source{{56, 78}}, "g", ty.Of(Outer), type::AddressSpace::kPrivate); + GlobalVar(Source{{56, 78}}, "g", ty.Of(Outer), builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -118,7 +118,7 @@ TEST_F(ResolverAtomicValidationTest, InvalidAddressSpace_ArrayOfArray) { auto* atomic_array = Alias(Source{{12, 34}}, "AtomicArray", ty.atomic(Source{{12, 34}}, ty.i32())); - GlobalVar(Source{{56, 78}}, "v", ty.Of(atomic_array), type::AddressSpace::kPrivate); + GlobalVar(Source{{56, 78}}, "v", ty.Of(atomic_array), builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -132,7 +132,7 @@ TEST_F(ResolverAtomicValidationTest, InvalidAddressSpace_ArrayOfStruct) { // var v: array; auto* s = Structure("S", utils::Vector{Member(Source{{12, 34}}, "m", ty.atomic())}); - GlobalVar(Source{{56, 78}}, "v", ty.array(ty.Of(s), 5_u), type::AddressSpace::kPrivate); + GlobalVar(Source{{56, 78}}, "v", ty.array(ty.Of(s), 5_u), builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -149,7 +149,7 @@ TEST_F(ResolverAtomicValidationTest, InvalidAddressSpace_ArrayOfStructOfArray) { auto* atomic_array = Alias("AtomicArray", ty.atomic(ty.i32())); auto* s = Structure("S", utils::Vector{Member(Source{{12, 34}}, "m", ty.Of(atomic_array))}); - GlobalVar(Source{{56, 78}}, "v", ty.array(ty.Of(s), 5_u), type::AddressSpace::kPrivate); + GlobalVar(Source{{56, 78}}, "v", ty.array(ty.Of(s), 5_u), builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -188,7 +188,7 @@ TEST_F(ResolverAtomicValidationTest, InvalidAddressSpace_Complex) { auto* s2 = Structure("S2", utils::Vector{Member("x", ty.Of(s3))}); auto* s1 = Structure("S1", utils::Vector{Member("x", ty.Of(s2))}); auto* s0 = Structure("S0", utils::Vector{Member("x", ty.Of(s1))}); - GlobalVar(Source{{56, 78}}, "g", ty.Of(s0), type::AddressSpace::kPrivate); + GlobalVar(Source{{56, 78}}, "g", ty.Of(s0), builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -198,8 +198,8 @@ TEST_F(ResolverAtomicValidationTest, InvalidAddressSpace_Complex) { TEST_F(ResolverAtomicValidationTest, Struct_AccessMode_Read) { auto* s = Structure("s", utils::Vector{Member(Source{{12, 34}}, "a", ty.atomic(ty.i32()))}); - GlobalVar(Source{{56, 78}}, "g", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, - Group(0_a), Binding(0_a)); + GlobalVar(Source{{56, 78}}, "g", ty.Of(s), builtin::AddressSpace::kStorage, + builtin::Access::kRead, Group(0_a), Binding(0_a)); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ( @@ -210,8 +210,8 @@ TEST_F(ResolverAtomicValidationTest, Struct_AccessMode_Read) { TEST_F(ResolverAtomicValidationTest, InvalidAccessMode_Struct) { auto* s = Structure("s", utils::Vector{Member(Source{{12, 34}}, "a", ty.atomic(ty.i32()))}); - GlobalVar(Source{{56, 78}}, "g", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, - Group(0_a), Binding(0_a)); + GlobalVar(Source{{56, 78}}, "g", ty.Of(s), builtin::AddressSpace::kStorage, + builtin::Access::kRead, Group(0_a), Binding(0_a)); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ( @@ -228,7 +228,7 @@ TEST_F(ResolverAtomicValidationTest, InvalidAccessMode_StructOfStruct) { auto* Inner = Structure("Inner", utils::Vector{Member(Source{{12, 34}}, "m", ty.atomic(ty.i32()))}); auto* Outer = Structure("Outer", utils::Vector{Member("m", ty.Of(Inner))}); - GlobalVar(Source{{56, 78}}, "g", ty.Of(Outer), type::AddressSpace::kStorage, + GlobalVar(Source{{56, 78}}, "g", ty.Of(Outer), builtin::AddressSpace::kStorage, builtin::Access::kRead, Group(0_a), Binding(0_a)); EXPECT_FALSE(r()->Resolve()); @@ -246,7 +246,7 @@ TEST_F(ResolverAtomicValidationTest, InvalidAccessMode_StructOfStructOfArray) { auto* Inner = Structure("Inner", utils::Vector{Member(Source{{12, 34}}, "m", ty.atomic(ty.i32()))}); auto* Outer = Structure("Outer", utils::Vector{Member("m", ty.Of(Inner))}); - GlobalVar(Source{{56, 78}}, "g", ty.Of(Outer), type::AddressSpace::kStorage, + GlobalVar(Source{{56, 78}}, "g", ty.Of(Outer), builtin::AddressSpace::kStorage, builtin::Access::kRead, Group(0_a), Binding(0_a)); EXPECT_FALSE(r()->Resolve()); @@ -287,7 +287,7 @@ TEST_F(ResolverAtomicValidationTest, InvalidAccessMode_Complex) { auto* s2 = Structure("S2", utils::Vector{Member("x", ty.Of(s3))}); auto* s1 = Structure("S1", utils::Vector{Member("x", ty.Of(s2))}); auto* s0 = Structure("S0", utils::Vector{Member("x", ty.Of(s1))}); - GlobalVar(Source{{12, 34}}, "g", ty.Of(s0), type::AddressSpace::kStorage, + GlobalVar(Source{{12, 34}}, "g", ty.Of(s0), builtin::AddressSpace::kStorage, builtin::Access::kRead, Group(0_a), Binding(0_a)); EXPECT_FALSE(r()->Resolve()); diff --git a/src/tint/resolver/attribute_validation_test.cc b/src/tint/resolver/attribute_validation_test.cc index 85257f96b0..fa7664bc5f 100644 --- a/src/tint/resolver/attribute_validation_test.cc +++ b/src/tint/resolver/attribute_validation_test.cc @@ -734,7 +734,7 @@ TEST_F(StructMemberAttributeTest, Align_Attribute_ConstAFloat) { } TEST_F(StructMemberAttributeTest, Align_Attribute_Var) { - GlobalVar(Source{{1, 2}}, "val", ty.f32(), type::AddressSpace::kPrivate, + GlobalVar(Source{{1, 2}}, "val", ty.f32(), builtin::AddressSpace::kPrivate, builtin::Access::kUndefined, Expr(1.23_f)); Structure(Source{{6, 4}}, "mystruct", @@ -808,7 +808,7 @@ TEST_F(StructMemberAttributeTest, Size_Attribute_ConstAFloat) { } TEST_F(StructMemberAttributeTest, Size_Attribute_Var) { - GlobalVar(Source{{1, 2}}, "val", ty.f32(), type::AddressSpace::kPrivate, + GlobalVar(Source{{1, 2}}, "val", ty.f32(), builtin::AddressSpace::kPrivate, builtin::Access::kUndefined, Expr(1.23_f)); Structure(Source{{6, 4}}, "mystruct", @@ -888,7 +888,7 @@ TEST_P(VariableAttributeTest, IsValid) { if (IsBindingAttribute(params.kind)) { GlobalVar("a", ty.sampler(type::SamplerKind::kSampler), attrs); } else { - GlobalVar("a", ty.f32(), type::AddressSpace::kPrivate, attrs); + GlobalVar("a", ty.f32(), builtin::AddressSpace::kPrivate, attrs); } if (params.should_pass) { @@ -1157,7 +1157,7 @@ TEST_P(ArrayStrideTest, All) { create(Source{{12, 34}}, params.stride), }); - GlobalVar("myarray", arr, type::AddressSpace::kPrivate); + GlobalVar("myarray", arr, builtin::AddressSpace::kPrivate); if (params.should_pass) { EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -1240,7 +1240,7 @@ TEST_F(ArrayStrideTest, DuplicateAttribute) { create(Source{{56, 78}}, 4u), }); - GlobalVar("myarray", arr, type::AddressSpace::kPrivate); + GlobalVar("myarray", arr, builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -1259,7 +1259,7 @@ TEST_F(ResourceAttributeTest, UniformBufferMissingBinding) { auto* s = Structure("S", utils::Vector{ Member("x", ty.i32()), }); - GlobalVar(Source{{12, 34}}, "G", ty.Of(s), type::AddressSpace::kUniform); + GlobalVar(Source{{12, 34}}, "G", ty.Of(s), builtin::AddressSpace::kUniform); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -1270,7 +1270,7 @@ TEST_F(ResourceAttributeTest, StorageBufferMissingBinding) { auto* s = Structure("S", utils::Vector{ Member("x", ty.i32()), }); - GlobalVar(Source{{12, 34}}, "G", ty.Of(s), type::AddressSpace::kStorage, + GlobalVar(Source{{12, 34}}, "G", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kRead); EXPECT_FALSE(r()->Resolve()); @@ -1357,7 +1357,7 @@ TEST_F(ResourceAttributeTest, BindingPointUsedTwiceByDifferentEntryPoints) { } TEST_F(ResourceAttributeTest, BindingPointOnNonResource) { - GlobalVar(Source{{12, 34}}, "G", ty.f32(), type::AddressSpace::kPrivate, Binding(1_a), + GlobalVar(Source{{12, 34}}, "G", ty.f32(), builtin::AddressSpace::kPrivate, Binding(1_a), Group(2_a)); EXPECT_FALSE(r()->Resolve()); diff --git a/src/tint/resolver/builtin_test.cc b/src/tint/resolver/builtin_test.cc index 475fd4d14f..0193596de7 100644 --- a/src/tint/resolver/builtin_test.cc +++ b/src/tint/resolver/builtin_test.cc @@ -81,7 +81,7 @@ using ResolverBuiltinTest_BoolMethod = ResolverTestWithParam; TEST_P(ResolverBuiltinTest_BoolMethod, Scalar) { auto name = GetParam(); - GlobalVar("my_var", ty.bool_(), type::AddressSpace::kPrivate); + GlobalVar("my_var", ty.bool_(), builtin::AddressSpace::kPrivate); auto* expr = Call(name, "my_var"); WrapInFunction(expr); @@ -94,7 +94,7 @@ TEST_P(ResolverBuiltinTest_BoolMethod, Scalar) { TEST_P(ResolverBuiltinTest_BoolMethod, Vector) { auto name = GetParam(); - GlobalVar("my_var", ty.vec3(), type::AddressSpace::kPrivate); + GlobalVar("my_var", ty.vec3(), builtin::AddressSpace::kPrivate); auto* expr = Call(name, "my_var"); WrapInFunction(expr); @@ -109,9 +109,9 @@ INSTANTIATE_TEST_SUITE_P(ResolverTest, testing::Values("any", "all")); TEST_F(ResolverBuiltinTest, Select) { - GlobalVar("my_var", ty.vec3(), type::AddressSpace::kPrivate); + GlobalVar("my_var", ty.vec3(), builtin::AddressSpace::kPrivate); - GlobalVar("bool_var", ty.vec3(), type::AddressSpace::kPrivate); + GlobalVar("bool_var", ty.vec3(), builtin::AddressSpace::kPrivate); auto* expr = Call("select", "my_var", "my_var", "bool_var"); WrapInFunction(expr); @@ -215,8 +215,8 @@ using ResolverBuiltinArrayTest = ResolverTest; TEST_F(ResolverBuiltinArrayTest, ArrayLength_Vector) { auto ary = ty.array(); auto* str = Structure("S", utils::Vector{Member("x", ary)}); - GlobalVar("a", ty.Of(str), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), - Group(0_a)); + GlobalVar("a", ty.Of(str), builtin::AddressSpace::kStorage, builtin::Access::kRead, + Binding(0_a), Group(0_a)); auto* call = Call("arrayLength", AddressOf(MemberAccessor("a", "x"))); WrapInFunction(call); @@ -228,7 +228,7 @@ TEST_F(ResolverBuiltinArrayTest, ArrayLength_Vector) { } TEST_F(ResolverBuiltinArrayTest, ArrayLength_Error_ArraySized) { - GlobalVar("arr", ty.array(), type::AddressSpace::kPrivate); + GlobalVar("arr", ty.array(), builtin::AddressSpace::kPrivate); auto* call = Call("arrayLength", AddressOf("arr")); WrapInFunction(call); @@ -1048,7 +1048,7 @@ TEST_F(ResolverBuiltinFloatTest, FrexpVector_f16) { } TEST_F(ResolverBuiltinFloatTest, Frexp_Error_FirstParamInt) { - GlobalVar("v", ty.i32(), type::AddressSpace::kWorkgroup); + GlobalVar("v", ty.i32(), builtin::AddressSpace::kWorkgroup); auto* call = Call("frexp", 1_i, AddressOf("v")); WrapInFunction(call); @@ -1297,7 +1297,7 @@ TEST_F(ResolverBuiltinFloatTest, ModfVector_f16) { } TEST_F(ResolverBuiltinFloatTest, Modf_Error_FirstParamInt) { - GlobalVar("whole", ty.f32(), type::AddressSpace::kWorkgroup); + GlobalVar("whole", ty.f32(), builtin::AddressSpace::kWorkgroup); auto* call = Call("modf", 1_i, AddressOf("whole")); WrapInFunction(call); @@ -1313,7 +1313,7 @@ TEST_F(ResolverBuiltinFloatTest, Modf_Error_FirstParamInt) { } TEST_F(ResolverBuiltinFloatTest, Modf_Error_SecondParamIntPtr) { - GlobalVar("whole", ty.i32(), type::AddressSpace::kWorkgroup); + GlobalVar("whole", ty.i32(), builtin::AddressSpace::kWorkgroup); auto* call = Call("modf", 1_f, AddressOf("whole")); WrapInFunction(call); @@ -1343,7 +1343,7 @@ TEST_F(ResolverBuiltinFloatTest, Modf_Error_SecondParamNotAPointer) { } TEST_F(ResolverBuiltinFloatTest, Modf_Error_VectorSizesDontMatch) { - GlobalVar("whole", ty.vec4(), type::AddressSpace::kWorkgroup); + GlobalVar("whole", ty.vec4(), builtin::AddressSpace::kWorkgroup); auto* call = Call("modf", vec2(1_f, 2_f), AddressOf("whole")); WrapInFunction(call); @@ -1823,7 +1823,7 @@ INSTANTIATE_TEST_SUITE_P( namespace matrix_builtin_tests { TEST_F(ResolverBuiltinTest, Determinant_2x2_f32) { - GlobalVar("var", ty.mat2x2(), type::AddressSpace::kPrivate); + GlobalVar("var", ty.mat2x2(), builtin::AddressSpace::kPrivate); auto* call = Call("determinant", "var"); WrapInFunction(call); @@ -1837,7 +1837,7 @@ TEST_F(ResolverBuiltinTest, Determinant_2x2_f32) { TEST_F(ResolverBuiltinTest, Determinant_2x2_f16) { Enable(builtin::Extension::kF16); - GlobalVar("var", ty.mat2x2(), type::AddressSpace::kPrivate); + GlobalVar("var", ty.mat2x2(), builtin::AddressSpace::kPrivate); auto* call = Call("determinant", "var"); WrapInFunction(call); @@ -1849,7 +1849,7 @@ TEST_F(ResolverBuiltinTest, Determinant_2x2_f16) { } TEST_F(ResolverBuiltinTest, Determinant_3x3_f32) { - GlobalVar("var", ty.mat3x3(), type::AddressSpace::kPrivate); + GlobalVar("var", ty.mat3x3(), builtin::AddressSpace::kPrivate); auto* call = Call("determinant", "var"); WrapInFunction(call); @@ -1863,7 +1863,7 @@ TEST_F(ResolverBuiltinTest, Determinant_3x3_f32) { TEST_F(ResolverBuiltinTest, Determinant_3x3_f16) { Enable(builtin::Extension::kF16); - GlobalVar("var", ty.mat3x3(), type::AddressSpace::kPrivate); + GlobalVar("var", ty.mat3x3(), builtin::AddressSpace::kPrivate); auto* call = Call("determinant", "var"); WrapInFunction(call); @@ -1875,7 +1875,7 @@ TEST_F(ResolverBuiltinTest, Determinant_3x3_f16) { } TEST_F(ResolverBuiltinTest, Determinant_4x4_f32) { - GlobalVar("var", ty.mat4x4(), type::AddressSpace::kPrivate); + GlobalVar("var", ty.mat4x4(), builtin::AddressSpace::kPrivate); auto* call = Call("determinant", "var"); WrapInFunction(call); @@ -1889,7 +1889,7 @@ TEST_F(ResolverBuiltinTest, Determinant_4x4_f32) { TEST_F(ResolverBuiltinTest, Determinant_4x4_f16) { Enable(builtin::Extension::kF16); - GlobalVar("var", ty.mat4x4(), type::AddressSpace::kPrivate); + GlobalVar("var", ty.mat4x4(), builtin::AddressSpace::kPrivate); auto* call = Call("determinant", "var"); WrapInFunction(call); @@ -1901,7 +1901,7 @@ TEST_F(ResolverBuiltinTest, Determinant_4x4_f16) { } TEST_F(ResolverBuiltinTest, Determinant_NotSquare) { - GlobalVar("var", ty.mat2x3(), type::AddressSpace::kPrivate); + GlobalVar("var", ty.mat2x3(), builtin::AddressSpace::kPrivate); auto* call = Call("determinant", "var"); WrapInFunction(call); @@ -1916,7 +1916,7 @@ TEST_F(ResolverBuiltinTest, Determinant_NotSquare) { } TEST_F(ResolverBuiltinTest, Determinant_NotMatrix) { - GlobalVar("var", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("var", ty.f32(), builtin::AddressSpace::kPrivate); auto* call = Call("determinant", "var"); WrapInFunction(call); @@ -1936,7 +1936,7 @@ TEST_F(ResolverBuiltinTest, Determinant_NotMatrix) { namespace vector_builtin_tests { TEST_F(ResolverBuiltinTest, Dot_Vec2_f32) { - GlobalVar("my_var", ty.vec2(), type::AddressSpace::kPrivate); + GlobalVar("my_var", ty.vec2(), builtin::AddressSpace::kPrivate); auto* expr = Call("dot", "my_var", "my_var"); WrapInFunction(expr); @@ -1950,7 +1950,7 @@ TEST_F(ResolverBuiltinTest, Dot_Vec2_f32) { TEST_F(ResolverBuiltinTest, Dot_Vec2_f16) { Enable(builtin::Extension::kF16); - GlobalVar("my_var", ty.vec2(), type::AddressSpace::kPrivate); + GlobalVar("my_var", ty.vec2(), builtin::AddressSpace::kPrivate); auto* expr = Call("dot", "my_var", "my_var"); WrapInFunction(expr); @@ -1962,7 +1962,7 @@ TEST_F(ResolverBuiltinTest, Dot_Vec2_f16) { } TEST_F(ResolverBuiltinTest, Dot_Vec3_i32) { - GlobalVar("my_var", ty.vec3(), type::AddressSpace::kPrivate); + GlobalVar("my_var", ty.vec3(), builtin::AddressSpace::kPrivate); auto* expr = Call("dot", "my_var", "my_var"); WrapInFunction(expr); @@ -1974,7 +1974,7 @@ TEST_F(ResolverBuiltinTest, Dot_Vec3_i32) { } TEST_F(ResolverBuiltinTest, Dot_Vec4_u32) { - GlobalVar("my_var", ty.vec4(), type::AddressSpace::kPrivate); + GlobalVar("my_var", ty.vec4(), builtin::AddressSpace::kPrivate); auto* expr = Call("dot", "my_var", "my_var"); WrapInFunction(expr); @@ -2009,7 +2009,7 @@ using ResolverBuiltinDerivativeTest = ResolverTestWithParam; TEST_P(ResolverBuiltinDerivativeTest, Scalar) { auto name = GetParam(); - GlobalVar("ident", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("ident", ty.f32(), builtin::AddressSpace::kPrivate); auto* expr = Call(name, "ident"); Func("func", utils::Empty, ty.void_(), utils::Vector{Ignore(expr)}, @@ -2023,7 +2023,7 @@ TEST_P(ResolverBuiltinDerivativeTest, Scalar) { TEST_P(ResolverBuiltinDerivativeTest, Vector) { auto name = GetParam(); - GlobalVar("ident", ty.vec4(), type::AddressSpace::kPrivate); + GlobalVar("ident", ty.vec4(), builtin::AddressSpace::kPrivate); auto* expr = Call(name, "ident"); Func("func", utils::Empty, ty.void_(), utils::Vector{Ignore(expr)}, @@ -2119,7 +2119,7 @@ class ResolverBuiltinTest_TextureOperation : public ResolverTestWithParamPush(Expr(name)); diff --git a/src/tint/resolver/builtin_validation_test.cc b/src/tint/resolver/builtin_validation_test.cc index 4158bf1b5b..bfa61c31c3 100644 --- a/src/tint/resolver/builtin_validation_test.cc +++ b/src/tint/resolver/builtin_validation_test.cc @@ -132,7 +132,7 @@ TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsGlobalConstUsedAsVariab TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsGlobalVarUsedAsVariable) { auto* mix = - GlobalVar(Source{{12, 34}}, "mix", ty.i32(), Expr(1_i), type::AddressSpace::kPrivate); + GlobalVar(Source{{12, 34}}, "mix", ty.i32(), Expr(1_i), builtin::AddressSpace::kPrivate); auto* use = Expr("mix"); WrapInFunction(Decl(Var("v", use))); @@ -410,7 +410,7 @@ TEST_P(BuiltinTextureConstExprArgValidationTest, GlobalVar) { overload.BuildSamplerVariable(this); // Build the module-scope var 'G' with the offset value - GlobalVar("G", expr({}, *this), type::AddressSpace::kPrivate); + GlobalVar("G", expr({}, *this), builtin::AddressSpace::kPrivate); auto args = overload.args(this); auto*& arg_to_replace = (param.position == Position::kFirst) ? args.Front() : args.Back(); @@ -581,7 +581,7 @@ TEST_F(ResolverBuiltinValidationTest, WorkgroupUniformLoad_WrongAddressSpace) { // fn foo() { // workgroupUniformLoad(&v); // } - GlobalVar("v", ty.i32(), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + GlobalVar("v", ty.i32(), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, utils::Vector{Group(0_a), Binding(0_a)}); WrapInFunction(CallStmt(Call("workgroupUniformLoad", AddressOf(Source{{12, 34}}, "v")))); @@ -599,7 +599,7 @@ TEST_F(ResolverBuiltinValidationTest, WorkgroupUniformLoad_Atomic) { // fn foo() { // workgroupUniformLoad(&v); // } - GlobalVar("v", ty.atomic(), type::AddressSpace::kWorkgroup); + GlobalVar("v", ty.atomic(), builtin::AddressSpace::kWorkgroup); WrapInFunction(CallStmt(Call("workgroupUniformLoad", AddressOf(Source{{12, 34}}, "v")))); EXPECT_FALSE(r()->Resolve()); @@ -613,7 +613,7 @@ TEST_F(ResolverBuiltinValidationTest, WorkgroupUniformLoad_AtomicInArray) { // fn foo() { // workgroupUniformLoad(&v); // } - GlobalVar("v", ty.array(ty.atomic(), 4_a), type::AddressSpace::kWorkgroup); + GlobalVar("v", ty.array(ty.atomic(), 4_a), builtin::AddressSpace::kWorkgroup); WrapInFunction(CallStmt(Call("workgroupUniformLoad", AddressOf(Source{{12, 34}}, "v")))); EXPECT_FALSE(r()->Resolve()); @@ -631,7 +631,7 @@ TEST_F(ResolverBuiltinValidationTest, WorkgroupUniformLoad_AtomicInStruct) { // } Structure("Inner", utils::Vector{Member("a", ty.array(ty.atomic(), 4_a))}); Structure("S", utils::Vector{Member("i", ty("Inner"))}); - GlobalVar(Source{{12, 34}}, "v", ty.array(ty("S"), 4_a), type::AddressSpace::kWorkgroup); + GlobalVar(Source{{12, 34}}, "v", ty.array(ty("S"), 4_a), builtin::AddressSpace::kWorkgroup); WrapInFunction(CallStmt(Call("workgroupUniformLoad", AddressOf("v")))); EXPECT_FALSE(r()->Resolve()); diff --git a/src/tint/resolver/builtins_validation_test.cc b/src/tint/resolver/builtins_validation_test.cc index 0921c2ef7d..a6f5889772 100644 --- a/src/tint/resolver/builtins_validation_test.cc +++ b/src/tint/resolver/builtins_validation_test.cc @@ -112,7 +112,7 @@ using ResolverBuiltinsStageTest = ResolverTestWithParam; TEST_P(ResolverBuiltinsStageTest, All_input) { const Params& params = GetParam(); - auto* p = GlobalVar("p", ty.vec4(), type::AddressSpace::kPrivate); + auto* p = GlobalVar("p", ty.vec4(), builtin::AddressSpace::kPrivate); auto* input = Param("input", params.type(*this), utils::Vector{Builtin(Source{{12, 34}}, params.builtin)}); switch (params.stage) { diff --git a/src/tint/resolver/call_validation_test.cc b/src/tint/resolver/call_validation_test.cc index b0b8cce1b0..549bf9682e 100644 --- a/src/tint/resolver/call_validation_test.cc +++ b/src/tint/resolver/call_validation_test.cc @@ -103,7 +103,7 @@ TEST_F(ResolverCallValidationTest, PointerArgument_VariableIdentExpr) { // var z: i32 = 1i; // foo(&z); // } - auto* param = Param("p", ty.pointer(type::AddressSpace::kFunction)); + auto* param = Param("p", ty.pointer(builtin::AddressSpace::kFunction)); Func("foo", utils::Vector{param}, ty.void_(), utils::Empty); Func("main", utils::Empty, ty.void_(), utils::Vector{ @@ -120,7 +120,7 @@ TEST_F(ResolverCallValidationTest, PointerArgument_LetIdentExpr) { // let z: i32 = 1i; // foo(&z); // } - auto* param = Param("p", ty.pointer(type::AddressSpace::kFunction)); + auto* param = Param("p", ty.pointer(builtin::AddressSpace::kFunction)); Func("foo", utils::Vector{param}, ty.void_(), utils::Empty); Func("main", utils::Empty, ty.void_(), utils::Vector{ @@ -142,7 +142,7 @@ TEST_F(ResolverCallValidationTest, PointerArgument_AddressOfFunctionMember) { auto* S = Structure("S", utils::Vector{ Member("m", ty.i32()), }); - auto* param = Param("p", ty.pointer(type::AddressSpace::kFunction)); + auto* param = Param("p", ty.pointer(builtin::AddressSpace::kFunction)); Func("foo", utils::Vector{param}, ty.void_(), utils::Empty); Func("main", utils::Empty, ty.void_(), utils::Vector{ @@ -169,7 +169,7 @@ TEST_F(ResolverCallValidationTest, auto* S = Structure("S", utils::Vector{ Member("m", ty.i32()), }); - auto* param = Param("p", ty.pointer(type::AddressSpace::kFunction)); + auto* param = Param("p", ty.pointer(builtin::AddressSpace::kFunction)); Func("foo", utils::Vector{param}, ty.void_(), utils::Empty); Func("main", utils::Empty, ty.void_(), utils::Vector{ @@ -189,7 +189,7 @@ TEST_F(ResolverCallValidationTest, PointerArgument_AddressOfLetMember) { auto* S = Structure("S", utils::Vector{ Member("m", ty.i32()), }); - auto* param = Param("p", ty.pointer(type::AddressSpace::kFunction)); + auto* param = Param("p", ty.pointer(builtin::AddressSpace::kFunction)); Func("foo", utils::Vector{param}, ty.void_(), utils::Empty); Func("main", utils::Empty, ty.void_(), utils::Vector{ @@ -208,12 +208,12 @@ TEST_F(ResolverCallValidationTest, PointerArgument_FunctionParam) { // } Func("foo", utils::Vector{ - Param("p", ty.pointer(type::AddressSpace::kFunction)), + Param("p", ty.pointer(builtin::AddressSpace::kFunction)), }, ty.void_(), utils::Empty); Func("bar", utils::Vector{ - Param("p", ty.pointer(type::AddressSpace::kFunction)), + Param("p", ty.pointer(builtin::AddressSpace::kFunction)), }, ty.void_(), utils::Vector{ @@ -235,12 +235,12 @@ TEST_F(ResolverCallValidationTest, PointerArgument_FunctionParamWithMain) { // } Func("foo", utils::Vector{ - Param("p", ty.pointer(type::AddressSpace::kFunction)), + Param("p", ty.pointer(builtin::AddressSpace::kFunction)), }, ty.void_(), utils::Empty); Func("bar", utils::Vector{ - Param("p", ty.pointer(type::AddressSpace::kFunction)), + Param("p", ty.pointer(builtin::AddressSpace::kFunction)), }, ty.void_(), utils::Vector{ @@ -268,13 +268,13 @@ TEST_F(ResolverCallValidationTest, LetPointer) { // } Func("x", utils::Vector{ - Param("p", ty.pointer(type::AddressSpace::kFunction)), + Param("p", ty.pointer(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(), type::AddressSpace::kFunction), AddressOf("v"))), + Decl(Let("p", ty.pointer(ty.i32(), builtin::AddressSpace::kFunction), AddressOf("v"))), CallStmt(Call("x", "p")), }, utils::Vector{ @@ -293,13 +293,13 @@ TEST_F(ResolverCallValidationTest, LetPointerPrivate) { // } Func("foo", utils::Vector{ - Param("p", ty.pointer(type::AddressSpace::kPrivate)), + Param("p", ty.pointer(builtin::AddressSpace::kPrivate)), }, ty.void_(), utils::Empty); - GlobalVar("v", ty.i32(), type::AddressSpace::kPrivate); + GlobalVar("v", ty.i32(), builtin::AddressSpace::kPrivate); Func("main", utils::Empty, ty.void_(), utils::Vector{ - Decl(Let("p", ty.pointer(ty.i32(), type::AddressSpace::kPrivate), AddressOf("v"))), + Decl(Let("p", ty.pointer(ty.i32(), builtin::AddressSpace::kPrivate), AddressOf("v"))), CallStmt(Call("foo", Expr(Source{{12, 34}}, "p"))), }, utils::Vector{ @@ -318,13 +318,13 @@ TEST_F(ResolverCallValidationTest, LetPointer_NotWholeVar) { // } Func("foo", utils::Vector{ - Param("p", ty.pointer(type::AddressSpace::kFunction)), + Param("p", ty.pointer(builtin::AddressSpace::kFunction)), }, ty.void_(), utils::Empty); Func("main", utils::Empty, ty.void_(), utils::Vector{ Decl(Var("v", ty.array())), - Decl(Let("p", ty.pointer(ty.i32(), type::AddressSpace::kFunction), + Decl(Let("p", ty.pointer(ty.i32(), builtin::AddressSpace::kFunction), AddressOf(IndexAccessor("v", 0_a)))), CallStmt(Call("foo", Expr(Source{{12, 34}}, "p"))), }, @@ -349,13 +349,13 @@ TEST_F(ResolverCallValidationTest, LetPointer_NotWholeVar_WithFullPtrParametersE Enable(builtin::Extension::kChromiumExperimentalFullPtrParameters); Func("foo", utils::Vector{ - Param("p", ty.pointer(type::AddressSpace::kFunction)), + Param("p", ty.pointer(builtin::AddressSpace::kFunction)), }, ty.void_(), utils::Empty); Func("main", utils::Empty, ty.void_(), utils::Vector{ Decl(Var("v", ty.array())), - Decl(Let("p", ty.pointer(ty.i32(), type::AddressSpace::kFunction), + Decl(Let("p", ty.pointer(ty.i32(), builtin::AddressSpace::kFunction), AddressOf(IndexAccessor("v", 0_a)))), CallStmt(Call("foo", Expr(Source{{12, 34}}, "p"))), }, @@ -377,7 +377,7 @@ TEST_F(ResolverCallValidationTest, ComplexPointerChain) { // } Func("foo", utils::Vector{ - Param("p", ty.pointer(ty.array(), type::AddressSpace::kFunction)), + Param("p", ty.pointer(ty.array(), builtin::AddressSpace::kFunction)), }, ty.void_(), utils::Empty); Func("main", utils::Empty, ty.void_(), @@ -406,7 +406,7 @@ TEST_F(ResolverCallValidationTest, ComplexPointerChain_NotWholeVar) { // } Func("foo", utils::Vector{ - Param("p", ty.pointer(type::AddressSpace::kFunction)), + Param("p", ty.pointer(builtin::AddressSpace::kFunction)), }, ty.void_(), utils::Empty); Func("main", utils::Empty, ty.void_(), @@ -440,7 +440,7 @@ TEST_F(ResolverCallValidationTest, ComplexPointerChain_NotWholeVar_WithFullPtrPa Enable(builtin::Extension::kChromiumExperimentalFullPtrParameters); Func("foo", utils::Vector{ - Param("p", ty.pointer(type::AddressSpace::kFunction)), + Param("p", ty.pointer(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 58f479df2d..cb42adee14 100644 --- a/src/tint/resolver/compound_assignment_validation_test.cc +++ b/src/tint/resolver/compound_assignment_validation_test.cc @@ -51,7 +51,7 @@ TEST_F(ResolverCompoundAssignmentValidationTest, CompatibleTypesAssignThroughPoi // var a : i32; // let b : ptr = &a; // *b += 2; - const auto func = type::AddressSpace::kFunction; + const auto func = builtin::AddressSpace::kFunction; auto* var_a = Var("a", ty.i32(), func, Expr(2_i)); auto* var_b = Let("b", ty.pointer(func), AddressOf(Expr("a"))); WrapInFunction(var_a, var_b, @@ -233,8 +233,8 @@ TEST_F(ResolverCompoundAssignmentValidationTest, ReadOnlyBuffer) { // { // a += 1i; // } - GlobalVar(Source{{12, 34}}, "a", ty.i32(), type::AddressSpace::kStorage, builtin::Access::kRead, - Group(0_a), Binding(0_a)); + GlobalVar(Source{{12, 34}}, "a", ty.i32(), builtin::AddressSpace::kStorage, + builtin::Access::kRead, Group(0_a), Binding(0_a)); WrapInFunction(CompoundAssign(Source{{56, 78}}, "a", 1_i, ast::BinaryOp::kAdd)); EXPECT_FALSE(r()->Resolve()); @@ -264,7 +264,7 @@ TEST_F(ResolverCompoundAssignmentValidationTest, LhsLiteral) { TEST_F(ResolverCompoundAssignmentValidationTest, LhsAtomic) { // var a : atomic; // a += a; - GlobalVar(Source{{12, 34}}, "a", ty.atomic(ty.i32()), type::AddressSpace::kWorkgroup); + GlobalVar(Source{{12, 34}}, "a", ty.atomic(ty.i32()), builtin::AddressSpace::kWorkgroup); WrapInFunction(CompoundAssign(Source{{56, 78}}, "a", "a", ast::BinaryOp::kAdd)); EXPECT_FALSE(r()->Resolve()); diff --git a/src/tint/resolver/const_assert_test.cc b/src/tint/resolver/const_assert_test.cc index fb08b8bfd1..9b072f9dde 100644 --- a/src/tint/resolver/const_assert_test.cc +++ b/src/tint/resolver/const_assert_test.cc @@ -84,7 +84,7 @@ TEST_F(ResolverConstAssertTest, Local_Const_Fail) { } TEST_F(ResolverConstAssertTest, Local_NonConst) { - GlobalVar("V", ty.bool_(), Expr(true), type::AddressSpace::kPrivate); + GlobalVar("V", ty.bool_(), Expr(true), builtin::AddressSpace::kPrivate); WrapInFunction(ConstAssert(Expr(Source{{12, 34}}, "V"))); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), diff --git a/src/tint/resolver/const_eval_indexing_test.cc b/src/tint/resolver/const_eval_indexing_test.cc index cfd7aa1c03..4d8c8cb216 100644 --- a/src/tint/resolver/const_eval_indexing_test.cc +++ b/src/tint/resolver/const_eval_indexing_test.cc @@ -279,7 +279,7 @@ TEST_F(ResolverConstEvalTest, Array_vec3_f32_Index_OOB_Low) { TEST_F(ResolverConstEvalTest, RuntimeArray_vec3_f32_Index_OOB_Low) { auto* sb = GlobalVar("sb", ty.array(ty.vec3()), Group(0_a), Binding(0_a), - type::AddressSpace::kStorage); + builtin::AddressSpace::kStorage); auto* expr = IndexAccessor(sb, Expr(Source{{12, 34}}, -2_i)); WrapInFunction(expr); diff --git a/src/tint/resolver/dependency_graph.cc b/src/tint/resolver/dependency_graph.cc index 37a22449fe..7fddf16275 100644 --- a/src/tint/resolver/dependency_graph.cc +++ b/src/tint/resolver/dependency_graph.cc @@ -479,7 +479,8 @@ class DependencyScanner { graph_.resolved_identifiers.Add(from, ResolvedIdentifier(builtin_ty)); return; } - if (auto addr = type::ParseAddressSpace(s); addr != type::AddressSpace::kUndefined) { + if (auto addr = builtin::ParseAddressSpace(s); + addr != builtin::AddressSpace::kUndefined) { graph_.resolved_identifiers.Add(from, ResolvedIdentifier(addr)); return; } @@ -864,7 +865,7 @@ std::string ResolvedIdentifier::String(const SymbolTable& symbols, diag::List& d if (auto access = Access(); access != builtin::Access::kUndefined) { return "access '" + utils::ToString(access) + "'"; } - if (auto addr = AddressSpace(); addr != type::AddressSpace::kUndefined) { + if (auto addr = AddressSpace(); addr != builtin::AddressSpace::kUndefined) { return "address space '" + utils::ToString(addr) + "'"; } if (auto fmt = TexelFormat(); fmt != type::TexelFormat::kUndefined) { diff --git a/src/tint/resolver/dependency_graph.h b/src/tint/resolver/dependency_graph.h index 189e7c2a62..9cf8819e72 100644 --- a/src/tint/resolver/dependency_graph.h +++ b/src/tint/resolver/dependency_graph.h @@ -36,7 +36,7 @@ namespace tint::resolver { /// - const ast::Function* (as const ast::Node*) /// - sem::BuiltinType /// - builtin::Access -/// - type::AddressSpace +/// - builtin::AddressSpace /// - type::Builtin /// - type::TexelFormat class ResolvedIdentifier { @@ -77,13 +77,13 @@ class ResolvedIdentifier { return builtin::Access::kUndefined; } - /// @return the address space if the ResolvedIdentifier holds type::AddressSpace, otherwise - /// type::AddressSpace::kUndefined - type::AddressSpace AddressSpace() const { - if (auto n = std::get_if(&value_)) { + /// @return the address space if the ResolvedIdentifier holds builtin::AddressSpace, otherwise + /// builtin::AddressSpace::kUndefined + builtin::AddressSpace AddressSpace() const { + if (auto n = std::get_if(&value_)) { return *n; } - return type::AddressSpace::kUndefined; + return builtin::AddressSpace::kUndefined; } /// @return the builtin type if the ResolvedIdentifier holds type::Builtin, otherwise @@ -131,7 +131,7 @@ class ResolvedIdentifier { const ast::Node*, sem::BuiltinType, builtin::Access, - type::AddressSpace, + builtin::AddressSpace, type::Builtin, type::TexelFormat> value_; diff --git a/src/tint/resolver/dependency_graph_test.cc b/src/tint/resolver/dependency_graph_test.cc index e9ef46bddd..03d1a69a27 100644 --- a/src/tint/resolver/dependency_graph_test.cc +++ b/src/tint/resolver/dependency_graph_test.cc @@ -17,6 +17,7 @@ #include #include "gmock/gmock.h" +#include "src/tint/builtin/address_space.h" #include "src/tint/resolver/dependency_graph.h" #include "src/tint/resolver/resolver_test_helper.h" #include "src/tint/type/texture_dimension.h" @@ -425,7 +426,7 @@ const ast::Node* SymbolTestHelper::Add(SymbolDeclKind kind, Symbol symbol, Sourc auto& b = *builder; switch (kind) { case SymbolDeclKind::GlobalVar: - return b.GlobalVar(source, symbol, b.ty.i32(), type::AddressSpace::kPrivate); + return b.GlobalVar(source, symbol, b.ty.i32(), builtin::AddressSpace::kPrivate); case SymbolDeclKind::GlobalConst: return b.GlobalConst(source, symbol, b.ty.i32(), b.Expr(1_i)); case SymbolDeclKind::Alias: @@ -470,27 +471,27 @@ const ast::Identifier* SymbolTestHelper::Add(SymbolUseKind kind, switch (kind) { case SymbolUseKind::GlobalVarType: { auto node = b.ty(source, symbol); - b.GlobalVar(b.Sym(), node, type::AddressSpace::kPrivate); + b.GlobalVar(b.Sym(), node, builtin::AddressSpace::kPrivate); return node->identifier; } case SymbolUseKind::GlobalVarArrayElemType: { auto node = b.ty(source, symbol); - b.GlobalVar(b.Sym(), b.ty.array(node, 4_i), type::AddressSpace::kPrivate); + b.GlobalVar(b.Sym(), b.ty.array(node, 4_i), builtin::AddressSpace::kPrivate); return node->identifier; } case SymbolUseKind::GlobalVarArraySizeValue: { auto* node = b.Expr(source, symbol); - b.GlobalVar(b.Sym(), b.ty.array(b.ty.i32(), node), type::AddressSpace::kPrivate); + b.GlobalVar(b.Sym(), b.ty.array(b.ty.i32(), node), builtin::AddressSpace::kPrivate); return node->identifier; } case SymbolUseKind::GlobalVarVectorElemType: { auto node = b.ty(source, symbol); - b.GlobalVar(b.Sym(), b.ty.vec3(node), type::AddressSpace::kPrivate); + b.GlobalVar(b.Sym(), b.ty.vec3(node), builtin::AddressSpace::kPrivate); return node->identifier; } case SymbolUseKind::GlobalVarMatrixElemType: { ast::Type node = b.ty(source, symbol); - b.GlobalVar(b.Sym(), b.ty.mat3x4(node), type::AddressSpace::kPrivate); + b.GlobalVar(b.Sym(), b.ty.mat3x4(node), builtin::AddressSpace::kPrivate); return node->identifier; } case SymbolUseKind::GlobalVarSampledTexElemType: { @@ -505,7 +506,7 @@ const ast::Identifier* SymbolTestHelper::Add(SymbolUseKind kind, } case SymbolUseKind::GlobalVarValue: { auto* node = b.Expr(source, symbol); - b.GlobalVar(b.Sym(), b.ty.i32(), type::AddressSpace::kPrivate, node); + b.GlobalVar(b.Sym(), b.ty.i32(), builtin::AddressSpace::kPrivate, node); return node->identifier; } case SymbolUseKind::GlobalConstType: { @@ -726,7 +727,7 @@ TEST_F(ResolverDependencyGraphUsedBeforeDeclTest, VarUsed) { Block(Assign(Expr(Source{{12, 34}}, "G"), 3.14_f)), }); - GlobalVar(Source{{56, 78}}, "G", ty.f32(), type::AddressSpace::kPrivate, Expr(2.1_f)); + GlobalVar(Source{{56, 78}}, "G", ty.f32(), builtin::AddressSpace::kPrivate, Expr(2.1_f)); Build(); } @@ -1268,7 +1269,7 @@ TEST_P(ResolverDependencyGraphResolveToBuiltinType, ShadowedByGlobalVar) { const auto symbol = Symbols().New(name); auto* decl = - GlobalVar(symbol, name == "i32" ? ty.u32() : ty.i32(), type::AddressSpace::kPrivate); + GlobalVar(symbol, name == "i32" ? ty.u32() : ty.i32(), builtin::AddressSpace::kPrivate); SymbolTestHelper helper(this); auto* ident = helper.Add(use, symbol); @@ -1415,7 +1416,7 @@ INSTANTIATE_TEST_SUITE_P(Functions, } // namespace resolve_to_access //////////////////////////////////////////////////////////////////////////////// -// Resolve to type::AddressSpace tests +// Resolve to builtin::AddressSpace tests //////////////////////////////////////////////////////////////////////////////// namespace resolve_to_address_space { @@ -1433,7 +1434,7 @@ TEST_P(ResolverDependencyGraphResolveToAddressSpace, Resolve) { auto resolved = Build().resolved_identifiers.Get(ident); ASSERT_TRUE(resolved); - EXPECT_EQ(resolved->AddressSpace(), type::ParseAddressSpace(name)) + EXPECT_EQ(resolved->AddressSpace(), builtin::ParseAddressSpace(name)) << resolved->String(Symbols(), Diagnostics()); } @@ -1485,17 +1486,17 @@ TEST_P(ResolverDependencyGraphResolveToAddressSpace, ShadowedByFunc) { INSTANTIATE_TEST_SUITE_P(Types, ResolverDependencyGraphResolveToAddressSpace, testing::Combine(testing::ValuesIn(kTypeUseKinds), - testing::ValuesIn(type::kAddressSpaceStrings))); + testing::ValuesIn(builtin::kAddressSpaceStrings))); INSTANTIATE_TEST_SUITE_P(Values, ResolverDependencyGraphResolveToAddressSpace, testing::Combine(testing::ValuesIn(kValueUseKinds), - testing::ValuesIn(type::kAddressSpaceStrings))); + testing::ValuesIn(builtin::kAddressSpaceStrings))); INSTANTIATE_TEST_SUITE_P(Functions, ResolverDependencyGraphResolveToAddressSpace, testing::Combine(testing::ValuesIn(kFuncUseKinds), - testing::ValuesIn(type::kAddressSpaceStrings))); + testing::ValuesIn(builtin::kAddressSpaceStrings))); } // namespace resolve_to_address_space @@ -1649,7 +1650,7 @@ TEST_F(ResolverDependencyGraphTraversalTest, SymbolsReached) { const auto type_sym = Sym("TYPE"); const auto func_sym = Sym("FUNC"); - const auto* value_decl = GlobalVar(value_sym, ty.i32(), type::AddressSpace::kPrivate); + const auto* value_decl = GlobalVar(value_sym, ty.i32(), builtin::AddressSpace::kPrivate); const auto* type_decl = Alias(type_sym, ty.i32()); const auto* func_decl = Func(func_sym, utils::Empty, ty.void_(), utils::Empty); @@ -1728,7 +1729,7 @@ TEST_F(ResolverDependencyGraphTraversalTest, SymbolsReached) { GlobalVar(Sym(), ty.array(T, V)); GlobalVar(Sym(), ty.vec3(T)); GlobalVar(Sym(), ty.mat3x2(T)); - GlobalVar(Sym(), ty.pointer(T, type::AddressSpace::kPrivate)); + GlobalVar(Sym(), ty.pointer(T, builtin::AddressSpace::kPrivate)); 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/entry_point_validation_test.cc b/src/tint/resolver/entry_point_validation_test.cc index 98012ad018..be027d8ef9 100644 --- a/src/tint/resolver/entry_point_validation_test.cc +++ b/src/tint/resolver/entry_point_validation_test.cc @@ -456,14 +456,14 @@ TEST_F(ResolverEntryPointValidationTest, PushConstantAllowedWithEnable) { // enable chromium_experimental_push_constant; // var a : u32; Enable(builtin::Extension::kChromiumExperimentalPushConstant); - GlobalVar("a", ty.u32(), type::AddressSpace::kPushConstant); + GlobalVar("a", ty.u32(), builtin::AddressSpace::kPushConstant); EXPECT_TRUE(r()->Resolve()); } TEST_F(ResolverEntryPointValidationTest, PushConstantDisallowedWithoutEnable) { // var a : u32; - GlobalVar(Source{{1, 2}}, "a", ty.u32(), type::AddressSpace::kPushConstant); + GlobalVar(Source{{1, 2}}, "a", ty.u32(), builtin::AddressSpace::kPushConstant); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -473,7 +473,7 @@ TEST_F(ResolverEntryPointValidationTest, PushConstantDisallowedWithoutEnable) { TEST_F(ResolverEntryPointValidationTest, PushConstantAllowedWithIgnoreAddressSpaceAttribute) { // var a : u32; // With ast::DisabledValidation::kIgnoreAddressSpace - GlobalVar("a", ty.u32(), type::AddressSpace::kPushConstant, + GlobalVar("a", ty.u32(), builtin::AddressSpace::kPushConstant, utils::Vector{Disable(ast::DisabledValidation::kIgnoreAddressSpace)}); EXPECT_TRUE(r()->Resolve()); @@ -486,7 +486,7 @@ TEST_F(ResolverEntryPointValidationTest, PushConstantOneVariableUsedInEntryPoint // _ = a; // } Enable(builtin::Extension::kChromiumExperimentalPushConstant); - GlobalVar("a", ty.u32(), type::AddressSpace::kPushConstant); + GlobalVar("a", ty.u32(), builtin::AddressSpace::kPushConstant); Func("main", {}, ty.void_(), utils::Vector{Assign(Phony(), "a")}, utils::Vector{Stage(ast::PipelineStage::kCompute), @@ -504,8 +504,8 @@ TEST_F(ResolverEntryPointValidationTest, PushConstantTwoVariablesUsedInEntryPoin // _ = b; // } Enable(builtin::Extension::kChromiumExperimentalPushConstant); - GlobalVar(Source{{1, 2}}, "a", ty.u32(), type::AddressSpace::kPushConstant); - GlobalVar(Source{{3, 4}}, "b", ty.u32(), type::AddressSpace::kPushConstant); + GlobalVar(Source{{1, 2}}, "a", ty.u32(), builtin::AddressSpace::kPushConstant); + GlobalVar(Source{{3, 4}}, "b", ty.u32(), builtin::AddressSpace::kPushConstant); Func(Source{{5, 6}}, "main", {}, ty.void_(), utils::Vector{Assign(Phony(), "a"), Assign(Phony(), "b")}, @@ -535,8 +535,8 @@ TEST_F(ResolverEntryPointValidationTest, // uses_b(); // } Enable(builtin::Extension::kChromiumExperimentalPushConstant); - GlobalVar(Source{{1, 2}}, "a", ty.u32(), type::AddressSpace::kPushConstant); - GlobalVar(Source{{3, 4}}, "b", ty.u32(), type::AddressSpace::kPushConstant); + GlobalVar(Source{{1, 2}}, "a", ty.u32(), builtin::AddressSpace::kPushConstant); + GlobalVar(Source{{3, 4}}, "b", ty.u32(), builtin::AddressSpace::kPushConstant); Func(Source{{5, 6}}, "uses_a", {}, ty.void_(), utils::Vector{Assign(Phony(), "a")}); Func(Source{{7, 8}}, "uses_b", {}, ty.void_(), utils::Vector{Assign(Phony(), "b")}); @@ -568,8 +568,8 @@ TEST_F(ResolverEntryPointValidationTest, PushConstantTwoVariablesUsedInDifferent // _ = a; // } Enable(builtin::Extension::kChromiumExperimentalPushConstant); - GlobalVar("a", ty.u32(), type::AddressSpace::kPushConstant); - GlobalVar("b", ty.u32(), type::AddressSpace::kPushConstant); + GlobalVar("a", ty.u32(), builtin::AddressSpace::kPushConstant); + GlobalVar("b", ty.u32(), builtin::AddressSpace::kPushConstant); Func("uses_a", {}, ty.void_(), utils::Vector{Assign(Phony(), "a")}, utils::Vector{Stage(ast::PipelineStage::kCompute), diff --git a/src/tint/resolver/expression_kind_test.cc b/src/tint/resolver/expression_kind_test.cc index 183597133d..c3b14f208c 100644 --- a/src/tint/resolver/expression_kind_test.cc +++ b/src/tint/resolver/expression_kind_test.cc @@ -135,9 +135,9 @@ TEST_P(ResolverExpressionKindTest, Test) { sym = Sym("workgroup"); check_expr = [](const sem::Expression* expr) { ASSERT_NE(expr, nullptr); - auto* enum_expr = expr->As>(); + auto* enum_expr = expr->As>(); ASSERT_NE(enum_expr, nullptr); - EXPECT_EQ(enum_expr->Value(), type::AddressSpace::kWorkgroup); + EXPECT_EQ(enum_expr->Value(), builtin::AddressSpace::kWorkgroup); }; break; } @@ -231,7 +231,7 @@ TEST_P(ResolverExpressionKindTest, Test) { Func("f", utils::Empty, ty.void_(), CallStmt(Call(expr))); break; case Use::kBinaryOp: - GlobalVar("v", type::AddressSpace::kPrivate, Mul(1_a, expr)); + GlobalVar("v", builtin::AddressSpace::kPrivate, Mul(1_a, expr)); break; case Use::kFunctionReturnType: Func("f", utils::Empty, ty(expr), Return(Call(sym))); @@ -243,13 +243,13 @@ TEST_P(ResolverExpressionKindTest, Test) { GlobalVar("v", ty("texture_storage_2d", ty(expr), "write"), Group(0_u), Binding(0_u)); break; case Use::kValueExpression: - GlobalVar("v", type::AddressSpace::kPrivate, expr); + GlobalVar("v", builtin::AddressSpace::kPrivate, expr); break; case Use::kVariableType: - GlobalVar("v", type::AddressSpace::kPrivate, ty(expr)); + GlobalVar("v", builtin::AddressSpace::kPrivate, ty(expr)); break; case Use::kUnaryOp: - GlobalVar("v", type::AddressSpace::kPrivate, Negation(expr)); + GlobalVar("v", builtin::AddressSpace::kPrivate, Negation(expr)); break; } diff --git a/src/tint/resolver/f16_extension_test.cc b/src/tint/resolver/f16_extension_test.cc index d76791959d..0868208954 100644 --- a/src/tint/resolver/f16_extension_test.cc +++ b/src/tint/resolver/f16_extension_test.cc @@ -29,14 +29,14 @@ TEST_F(ResolverF16ExtensionTest, TypeUsedWithExtension) { // var v : f16; Enable(builtin::Extension::kF16); - GlobalVar("v", ty.f16(), type::AddressSpace::kPrivate); + GlobalVar("v", ty.f16(), builtin::AddressSpace::kPrivate); EXPECT_TRUE(r()->Resolve()) << r()->error(); } TEST_F(ResolverF16ExtensionTest, TypeUsedWithoutExtension) { // var v : f16; - GlobalVar("v", ty.f16(Source{{12, 34}}), type::AddressSpace::kPrivate); + GlobalVar("v", ty.f16(Source{{12, 34}}), builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), "12:34 error: f16 type used without 'f16' extension enabled"); @@ -47,14 +47,14 @@ TEST_F(ResolverF16ExtensionTest, Vec2TypeUsedWithExtension) { // var v : vec2; Enable(builtin::Extension::kF16); - GlobalVar("v", ty.vec2(), type::AddressSpace::kPrivate); + GlobalVar("v", ty.vec2(), builtin::AddressSpace::kPrivate); EXPECT_TRUE(r()->Resolve()) << r()->error(); } TEST_F(ResolverF16ExtensionTest, Vec2TypeUsedWithoutExtension) { // var v : vec2; - GlobalVar("v", ty.vec2(ty.f16(Source{{12, 34}})), type::AddressSpace::kPrivate); + GlobalVar("v", ty.vec2(ty.f16(Source{{12, 34}})), builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), "12:34 error: f16 type used without 'f16' extension enabled"); @@ -65,14 +65,14 @@ TEST_F(ResolverF16ExtensionTest, Vec2TypeInitUsedWithExtension) { // var v = vec2(); Enable(builtin::Extension::kF16); - GlobalVar("v", vec2(), type::AddressSpace::kPrivate); + GlobalVar("v", vec2(), builtin::AddressSpace::kPrivate); EXPECT_TRUE(r()->Resolve()) << r()->error(); } TEST_F(ResolverF16ExtensionTest, Vec2TypeInitUsedWithoutExtension) { // var v = vec2(); - GlobalVar("v", Call(ty.vec2(ty.f16(Source{{12, 34}}))), type::AddressSpace::kPrivate); + GlobalVar("v", Call(ty.vec2(ty.f16(Source{{12, 34}}))), builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), "12:34 error: f16 type used without 'f16' extension enabled"); @@ -83,14 +83,14 @@ TEST_F(ResolverF16ExtensionTest, Vec2TypeConvUsedWithExtension) { // var v = vec2(vec2()); Enable(builtin::Extension::kF16); - GlobalVar("v", vec2(vec2()), type::AddressSpace::kPrivate); + GlobalVar("v", vec2(vec2()), builtin::AddressSpace::kPrivate); EXPECT_TRUE(r()->Resolve()) << r()->error(); } TEST_F(ResolverF16ExtensionTest, Vec2TypeConvUsedWithoutExtension) { // var v = vec2(vec2()); - GlobalVar("v", vec2(ty.f16(Source{{12, 34}}), vec2()), type::AddressSpace::kPrivate); + GlobalVar("v", vec2(ty.f16(Source{{12, 34}}), vec2()), builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), "12:34 error: f16 type used without 'f16' extension enabled"); @@ -101,14 +101,14 @@ TEST_F(ResolverF16ExtensionTest, F16LiteralUsedWithExtension) { // var v = 16h; Enable(builtin::Extension::kF16); - GlobalVar("v", Expr(16_h), type::AddressSpace::kPrivate); + GlobalVar("v", Expr(16_h), builtin::AddressSpace::kPrivate); EXPECT_TRUE(r()->Resolve()) << r()->error(); } TEST_F(ResolverF16ExtensionTest, F16LiteralUsedWithoutExtension) { // var v = 16h; - GlobalVar("v", Expr(Source{{12, 34}}, 16_h), type::AddressSpace::kPrivate); + GlobalVar("v", Expr(Source{{12, 34}}, 16_h), builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), "12:34 error: f16 type used without 'f16' extension enabled"); @@ -121,14 +121,14 @@ TEST_P(ResolverF16ExtensionBuiltinTypeAliasTest, Vec2hTypeUsedWithExtension) { // var v : vec2h; Enable(builtin::Extension::kF16); - GlobalVar("v", ty(Source{{12, 34}}, GetParam()), type::AddressSpace::kPrivate); + GlobalVar("v", ty(Source{{12, 34}}, GetParam()), builtin::AddressSpace::kPrivate); EXPECT_TRUE(r()->Resolve()) << r()->error(); } TEST_P(ResolverF16ExtensionBuiltinTypeAliasTest, Vec2hTypeUsedWithoutExtension) { // var v : vec2h; - GlobalVar("v", ty(Source{{12, 34}}, GetParam()), type::AddressSpace::kPrivate); + GlobalVar("v", ty(Source{{12, 34}}, GetParam()), builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), "12:34 error: f16 type used without 'f16' extension enabled"); diff --git a/src/tint/resolver/function_validation_test.cc b/src/tint/resolver/function_validation_test.cc index 1062958a7d..b6b5ed6422 100644 --- a/src/tint/resolver/function_validation_test.cc +++ b/src/tint/resolver/function_validation_test.cc @@ -39,7 +39,7 @@ TEST_F(ResolverFunctionValidationTest, DuplicateParameterName) { TEST_F(ResolverFunctionValidationTest, ParameterMayShadowGlobal) { // var common_name : f32; // fn func(common_name : f32) { } - GlobalVar("common_name", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("common_name", ty.f32(), builtin::AddressSpace::kPrivate); Func("func", utils::Vector{Param("common_name", ty.f32())}, ty.void_(), utils::Empty); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -420,7 +420,7 @@ TEST_F(ResolverFunctionValidationTest, CannotCallFunctionAtModuleScope) { utils::Vector{ Return(1_i), }); - GlobalVar("x", Call(Source{{12, 34}}, "F"), type::AddressSpace::kPrivate); + GlobalVar("x", Call(Source{{12, 34}}, "F"), builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), R"(12:34 error: functions cannot be called at module-scope)"); @@ -874,7 +874,7 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_NonConst) { // var x = 64i; // @compute @workgroup_size(x) // fn main() {} - GlobalVar("x", ty.i32(), type::AddressSpace::kPrivate, Expr(64_i)); + GlobalVar("x", ty.i32(), builtin::AddressSpace::kPrivate, Expr(64_i)); Func("main", utils::Empty, ty.void_(), utils::Empty, utils::Vector{ Stage(ast::PipelineStage::kCompute), @@ -890,7 +890,7 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_NonConst) { TEST_F(ResolverFunctionValidationTest, WorkgroupSize_InvalidExpr_x) { // @compute @workgroup_size(1 << 2 + 4) // fn main() {} - GlobalVar("x", ty.i32(), type::AddressSpace::kPrivate, Expr(0_i)); + GlobalVar("x", ty.i32(), builtin::AddressSpace::kPrivate, Expr(0_i)); Func("main", utils::Empty, ty.void_(), utils::Empty, utils::Vector{ Stage(ast::PipelineStage::kCompute), @@ -906,7 +906,7 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_InvalidExpr_x) { TEST_F(ResolverFunctionValidationTest, WorkgroupSize_InvalidExpr_y) { // @compute @workgroup_size(1, 1 << 2 + 4) // fn main() {} - GlobalVar("x", ty.i32(), type::AddressSpace::kPrivate, Expr(0_i)); + GlobalVar("x", ty.i32(), builtin::AddressSpace::kPrivate, Expr(0_i)); Func("main", utils::Empty, ty.void_(), utils::Empty, utils::Vector{ Stage(ast::PipelineStage::kCompute), @@ -922,7 +922,7 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_InvalidExpr_y) { TEST_F(ResolverFunctionValidationTest, WorkgroupSize_InvalidExpr_z) { // @compute @workgroup_size(1, 1, 1 << 2 + 4) // fn main() {} - GlobalVar("x", ty.i32(), type::AddressSpace::kPrivate, Expr(0_i)); + GlobalVar("x", ty.i32(), builtin::AddressSpace::kPrivate, Expr(0_i)); Func("main", utils::Empty, ty.void_(), utils::Empty, utils::Vector{ Stage(ast::PipelineStage::kCompute), @@ -936,7 +936,7 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_InvalidExpr_z) { } TEST_F(ResolverFunctionValidationTest, ReturnIsConstructible_NonPlain) { - auto ret_type = ty.pointer(Source{{12, 34}}, ty.i32(), type::AddressSpace::kFunction); + auto ret_type = ty.pointer(Source{{12, 34}}, ty.i32(), builtin::AddressSpace::kFunction); Func("f", utils::Empty, ret_type, utils::Empty); EXPECT_FALSE(r()->Resolve()); @@ -1049,7 +1049,7 @@ enum class Expectation { kInvalid, }; struct TestParams { - type::AddressSpace address_space; + builtin::AddressSpace address_space; Expectation expectation; }; @@ -1102,16 +1102,18 @@ TEST_P(ResolverFunctionParameterValidationTest, AddressSpaceWithExtension) { INSTANTIATE_TEST_SUITE_P( ResolverTest, ResolverFunctionParameterValidationTest, - testing::Values( - TestParams{type::AddressSpace::kUndefined, Expectation::kInvalid}, - TestParams{type::AddressSpace::kIn, Expectation::kAlwaysFail}, - TestParams{type::AddressSpace::kOut, Expectation::kAlwaysFail}, - TestParams{type::AddressSpace::kUniform, Expectation::kPassWithFullPtrParameterExtension}, - TestParams{type::AddressSpace::kWorkgroup, Expectation::kPassWithFullPtrParameterExtension}, - TestParams{type::AddressSpace::kHandle, Expectation::kInvalid}, - TestParams{type::AddressSpace::kStorage, Expectation::kPassWithFullPtrParameterExtension}, - TestParams{type::AddressSpace::kPrivate, Expectation::kAlwaysPass}, - TestParams{type::AddressSpace::kFunction, Expectation::kAlwaysPass})); + testing::Values(TestParams{builtin::AddressSpace::kUndefined, Expectation::kInvalid}, + TestParams{builtin::AddressSpace::kIn, Expectation::kAlwaysFail}, + TestParams{builtin::AddressSpace::kOut, Expectation::kAlwaysFail}, + TestParams{builtin::AddressSpace::kUniform, + Expectation::kPassWithFullPtrParameterExtension}, + TestParams{builtin::AddressSpace::kWorkgroup, + Expectation::kPassWithFullPtrParameterExtension}, + TestParams{builtin::AddressSpace::kHandle, Expectation::kInvalid}, + TestParams{builtin::AddressSpace::kStorage, + Expectation::kPassWithFullPtrParameterExtension}, + TestParams{builtin::AddressSpace::kPrivate, Expectation::kAlwaysPass}, + TestParams{builtin::AddressSpace::kFunction, Expectation::kAlwaysPass})); } // namespace } // namespace tint::resolver diff --git a/src/tint/resolver/host_shareable_validation_test.cc b/src/tint/resolver/host_shareable_validation_test.cc index 059a3e5b3b..b32c6693ee 100644 --- a/src/tint/resolver/host_shareable_validation_test.cc +++ b/src/tint/resolver/host_shareable_validation_test.cc @@ -29,8 +29,8 @@ TEST_F(ResolverHostShareableValidationTest, BoolMember) { auto* s = Structure("S", utils::Vector{Member(Source{{56, 78}}, "x", ty.bool_(Source{{12, 34}}))}); - GlobalVar(Source{{90, 12}}, "g", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, - Binding(0_a), Group(0_a)); + GlobalVar(Source{{90, 12}}, "g", ty.Of(s), builtin::AddressSpace::kStorage, + builtin::Access::kRead, Binding(0_a), Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -45,8 +45,8 @@ TEST_F(ResolverHostShareableValidationTest, BoolVectorMember) { auto* s = Structure( "S", utils::Vector{Member(Source{{56, 78}}, "x", ty.vec3(Source{{12, 34}}))}); - GlobalVar(Source{{90, 12}}, "g", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, - Binding(0_a), Group(0_a)); + GlobalVar(Source{{90, 12}}, "g", ty.Of(s), builtin::AddressSpace::kStorage, + builtin::Access::kRead, Binding(0_a), Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -62,7 +62,7 @@ TEST_F(ResolverHostShareableValidationTest, Aliases) { auto* s = Structure("S", utils::Vector{Member(Source{{56, 78}}, "x", ty(Source{{12, 34}}, "a1"))}); auto* a2 = Alias("a2", ty.Of(s)); - GlobalVar(Source{{90, 12}}, "g", ty.Of(a2), type::AddressSpace::kStorage, + GlobalVar(Source{{90, 12}}, "g", ty.Of(a2), builtin::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -81,8 +81,8 @@ TEST_F(ResolverHostShareableValidationTest, NestedStructures) { auto* s = Structure("S", utils::Vector{Member(Source{{7, 8}}, "m", ty.Of(i3))}); - GlobalVar(Source{{9, 10}}, "g", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, - Binding(0_a), Group(0_a)); + GlobalVar(Source{{9, 10}}, "g", ty.Of(s), builtin::AddressSpace::kStorage, + builtin::Access::kRead, Binding(0_a), Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -120,8 +120,8 @@ TEST_F(ResolverHostShareableValidationTest, NoError) { auto* s = Structure("S", utils::Vector{Member(Source{{7, 8}}, "m", ty.Of(i3))}); - GlobalVar(Source{{9, 10}}, "g", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, - Binding(0_a), Group(0_a)); + GlobalVar(Source{{9, 10}}, "g", ty.Of(s), builtin::AddressSpace::kStorage, + builtin::Access::kRead, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } diff --git a/src/tint/resolver/increment_decrement_validation_test.cc b/src/tint/resolver/increment_decrement_validation_test.cc index 7848daabd3..c5a6c98f75 100644 --- a/src/tint/resolver/increment_decrement_validation_test.cc +++ b/src/tint/resolver/increment_decrement_validation_test.cc @@ -64,8 +64,8 @@ TEST_F(ResolverIncrementDecrementValidationTest, ThroughPointer) { // var a : i32; // let b : ptr = &a; // *b++; - auto* var_a = Var("a", ty.i32(), type::AddressSpace::kFunction); - auto* var_b = Let("b", ty.pointer(type::AddressSpace::kFunction), AddressOf(Expr("a"))); + auto* var_a = Var("a", ty.i32(), builtin::AddressSpace::kFunction); + auto* var_b = Let("b", ty.pointer(builtin::AddressSpace::kFunction), AddressOf(Expr("a"))); WrapInFunction(var_a, var_b, Increment(Source{{12, 34}}, Deref("b"))); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -127,7 +127,7 @@ TEST_F(ResolverIncrementDecrementValidationTest, Vector) { TEST_F(ResolverIncrementDecrementValidationTest, Atomic) { // var a : atomic; // a++; - GlobalVar(Source{{12, 34}}, "a", ty.atomic(ty.i32()), type::AddressSpace::kWorkgroup); + GlobalVar(Source{{12, 34}}, "a", ty.atomic(ty.i32()), builtin::AddressSpace::kWorkgroup); WrapInFunction(Increment(Expr(Source{{56, 78}}, "a"))); EXPECT_FALSE(r()->Resolve()); @@ -193,8 +193,8 @@ TEST_F(ResolverIncrementDecrementValidationTest, ReadOnlyBuffer) { // { // a++; // } - GlobalVar(Source{{12, 34}}, "a", ty.i32(), type::AddressSpace::kStorage, builtin::Access::kRead, - Group(0_a), Binding(0_a)); + GlobalVar(Source{{12, 34}}, "a", ty.i32(), builtin::AddressSpace::kStorage, + builtin::Access::kRead, Group(0_a), Binding(0_a)); WrapInFunction(Increment(Source{{56, 78}}, "a")); EXPECT_FALSE(r()->Resolve()); diff --git a/src/tint/resolver/inferred_type_test.cc b/src/tint/resolver/inferred_type_test.cc index 8a609d25b9..ab2478bb2e 100644 --- a/src/tint/resolver/inferred_type_test.cc +++ b/src/tint/resolver/inferred_type_test.cc @@ -97,7 +97,7 @@ TEST_P(ResolverInferredTypeParamTest, GlobalVar_Pass) { // var a = ; auto* ctor_expr = params.create_value(*this, 0); - auto* var = GlobalVar("a", type::AddressSpace::kPrivate, ctor_expr); + auto* var = GlobalVar("a", builtin::AddressSpace::kPrivate, ctor_expr); EXPECT_TRUE(r()->Resolve()) << r()->error(); EXPECT_EQ(TypeOf(var)->UnwrapRef(), expected_type); @@ -124,7 +124,7 @@ TEST_P(ResolverInferredTypeParamTest, LocalVar_Pass) { // var a = ; auto* ctor_expr = params.create_value(*this, 0); - auto* var = Var("a", type::AddressSpace::kFunction, ctor_expr); + auto* var = Var("a", builtin::AddressSpace::kFunction, ctor_expr); WrapInFunction(var); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -139,7 +139,7 @@ TEST_F(ResolverInferredTypeTest, InferArray_Pass) { create(), create(10u), 4u, 4u * 10u, 4u, 4u); auto* ctor_expr = Call(type); - auto* var = Var("a", type::AddressSpace::kFunction, ctor_expr); + auto* var = Var("a", builtin::AddressSpace::kFunction, ctor_expr); WrapInFunction(var); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -158,7 +158,7 @@ TEST_F(ResolverInferredTypeTest, InferStruct_Pass) { auto* ctor_expr = Call(ty.Of(str)); - auto* var = Var("a", type::AddressSpace::kFunction, ctor_expr); + auto* var = Var("a", builtin::AddressSpace::kFunction, ctor_expr); WrapInFunction(var); EXPECT_TRUE(r()->Resolve()) << r()->error(); diff --git a/src/tint/resolver/intrinsic_table.cc b/src/tint/resolver/intrinsic_table.cc index 12d07acc3f..febd6108ca 100644 --- a/src/tint/resolver/intrinsic_table.cc +++ b/src/tint/resolver/intrinsic_table.cc @@ -330,7 +330,7 @@ class TemplateNumberMatcher : public NumberMatcher { //////////////////////////////////////////////////////////////////////////////// using TexelFormat = type::TexelFormat; using Access = builtin::Access; -using AddressSpace = type::AddressSpace; +using AddressSpace = builtin::AddressSpace; using ParameterUsage = sem::ParameterUsage; using PipelineStage = ast::PipelineStage; @@ -560,7 +560,7 @@ bool match_ptr(MatchState&, const type::Type* ty, Number& S, const type::Type*& } const type::Pointer* build_ptr(MatchState& state, Number S, const type::Type* T, Number& A) { - return state.builder.create(T, static_cast(S.Value()), + return state.builder.create(T, static_cast(S.Value()), static_cast(A.Value())); } @@ -1276,7 +1276,7 @@ Impl::Builtin Impl::Lookup(sem::BuiltinType builtin_type, for (auto& p : match.parameters) { params.Push(builder.create( nullptr, static_cast(params.Length()), p.type, - type::AddressSpace::kUndefined, builtin::Access::kUndefined, p.usage)); + builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, p.usage)); } sem::PipelineStageSet supported_stages; if (match.overload->flags.Contains(OverloadFlag::kSupportsVertexPipeline)) { @@ -1477,7 +1477,7 @@ IntrinsicTable::InitOrConv Impl::Lookup(InitConvIntrinsic type, for (auto& p : match.parameters) { params.Push(builder.create( nullptr, static_cast(params.Length()), p.type, - type::AddressSpace::kUndefined, builtin::Access::kUndefined, p.usage)); + builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, p.usage)); } auto eval_stage = match.overload->const_eval_fn ? sem::EvaluationStage::kConstant : sem::EvaluationStage::kRuntime; @@ -1491,7 +1491,7 @@ IntrinsicTable::InitOrConv Impl::Lookup(InitConvIntrinsic type, // Conversion. auto* target = converters.GetOrCreate(match, [&]() { auto param = builder.create( - nullptr, 0u, match.parameters[0].type, type::AddressSpace::kUndefined, + nullptr, 0u, match.parameters[0].type, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, match.parameters[0].usage); auto eval_stage = match.overload->const_eval_fn ? sem::EvaluationStage::kConstant : sem::EvaluationStage::kRuntime; diff --git a/src/tint/resolver/intrinsic_table_test.cc b/src/tint/resolver/intrinsic_table_test.cc index 624a208e68..d1b5530a73 100644 --- a/src/tint/resolver/intrinsic_table_test.cc +++ b/src/tint/resolver/intrinsic_table_test.cc @@ -231,7 +231,7 @@ TEST_F(IntrinsicTableTest, MismatchBool) { TEST_F(IntrinsicTableTest, MatchPointer) { auto* i32 = create(); auto* atomicI32 = create(i32); - auto* ptr = create(atomicI32, type::AddressSpace::kWorkgroup, + auto* ptr = create(atomicI32, builtin::AddressSpace::kWorkgroup, builtin::Access::kReadWrite); auto result = table->Lookup(BuiltinType::kAtomicLoad, utils::Vector{ptr}, sem::EvaluationStage::kConstant, Source{}); @@ -256,7 +256,7 @@ TEST_F(IntrinsicTableTest, MatchArray) { auto* arr = create(create(), create(), 4u, 4u, 4u, 4u); auto* arr_ptr = - create(arr, type::AddressSpace::kStorage, builtin::Access::kReadWrite); + create(arr, builtin::AddressSpace::kStorage, builtin::Access::kReadWrite); auto result = table->Lookup(BuiltinType::kArrayLength, utils::Vector{arr_ptr}, sem::EvaluationStage::kConstant, Source{}); ASSERT_NE(result.sem, nullptr) << Diagnostics().str(); @@ -448,7 +448,7 @@ TEST_F(IntrinsicTableTest, ImplicitLoadOnReference) { auto* f32 = create(); auto result = table->Lookup(BuiltinType::kCos, utils::Vector{ - create(f32, type::AddressSpace::kFunction, + create(f32, builtin::AddressSpace::kFunction, builtin::Access::kReadWrite), }, sem::EvaluationStage::kConstant, Source{}); @@ -549,7 +549,7 @@ TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Builtin_ConstantEval) { TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Builtin_RuntimeEval) { auto* af = create(); - auto* bool_ref = create(create(), type::AddressSpace::kFunction, + auto* bool_ref = create(create(), builtin::AddressSpace::kFunction, builtin::Access::kReadWrite); auto result = table->Lookup(BuiltinType::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 0d6511113a..4570d4d362 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, Matrix) { } TEST_F(ResolverIsHostShareable, Pointer) { - auto* ptr = create(create(), type::AddressSpace::kPrivate, + auto* ptr = create(create(), builtin::AddressSpace::kPrivate, 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 af48077c84..43abdbcaad 100644 --- a/src/tint/resolver/is_storeable_test.cc +++ b/src/tint/resolver/is_storeable_test.cc @@ -78,7 +78,7 @@ TEST_F(ResolverIsStorableTest, Matrix) { } TEST_F(ResolverIsStorableTest, Pointer) { - auto* ptr = create(create(), type::AddressSpace::kPrivate, + auto* ptr = create(create(), builtin::AddressSpace::kPrivate, builtin::Access::kReadWrite); EXPECT_FALSE(r()->IsStorable(ptr)); } @@ -112,7 +112,7 @@ TEST_F(ResolverIsStorableTest, Struct_AllMembersStorable) { TEST_F(ResolverIsStorableTest, Struct_SomeMembersNonStorable) { Structure("S", utils::Vector{ Member("a", ty.i32()), - Member("b", ty.pointer(type::AddressSpace::kPrivate)), + Member("b", ty.pointer(builtin::AddressSpace::kPrivate)), }); EXPECT_FALSE(r()->Resolve()); @@ -138,7 +138,7 @@ TEST_F(ResolverIsStorableTest, Struct_NestedNonStorable) { auto* non_storable = Structure("nonstorable", utils::Vector{ Member("a", ty.i32()), - Member("b", ty.pointer(type::AddressSpace::kPrivate)), + Member("b", ty.pointer(builtin::AddressSpace::kPrivate)), }); Structure("S", utils::Vector{ Member("a", ty.i32()), diff --git a/src/tint/resolver/materialize_test.cc b/src/tint/resolver/materialize_test.cc index 4824549342..3a4fdbba75 100644 --- a/src/tint/resolver/materialize_test.cc +++ b/src/tint/resolver/materialize_test.cc @@ -929,7 +929,7 @@ TEST_P(MaterializeAbstractNumericToDefaultType, Test) { break; } case Method::kIndex: { - GlobalVar("arr", ty.array(), type::AddressSpace::kPrivate); + GlobalVar("arr", ty.array(), builtin::AddressSpace::kPrivate); WrapInFunction(IndexAccessor("arr", abstract_expr())); break; } diff --git a/src/tint/resolver/override_test.cc b/src/tint/resolver/override_test.cc index a9518d27d4..fd0f649d52 100644 --- a/src/tint/resolver/override_test.cc +++ b/src/tint/resolver/override_test.cc @@ -159,7 +159,7 @@ TEST_F(ResolverOverrideTest, TransitiveReferences_ViaOverrideInit) { TEST_F(ResolverOverrideTest, TransitiveReferences_ViaPrivateInit) { auto* a = Override("a", ty.f32()); - auto* b = GlobalVar("b", type::AddressSpace::kPrivate, ty.f32(), Mul(2_a, "a")); + auto* b = GlobalVar("b", builtin::AddressSpace::kPrivate, ty.f32(), Mul(2_a, "a")); Override("unused", ty.f32(), Expr(1_f)); auto* func = Func("foo", utils::Empty, ty.void_(), utils::Vector{ @@ -208,7 +208,8 @@ TEST_F(ResolverOverrideTest, TransitiveReferences_ViaAttribute) { TEST_F(ResolverOverrideTest, TransitiveReferences_ViaArraySize) { auto* a = Override("a", ty.i32()); auto* b = Override("b", ty.i32(), Mul(2_a, "a")); - auto* arr = GlobalVar("arr", type::AddressSpace::kWorkgroup, ty.array(ty.i32(), Mul(2_a, "b"))); + auto* arr = + GlobalVar("arr", builtin::AddressSpace::kWorkgroup, ty.array(ty.i32(), Mul(2_a, "b"))); auto arr_ty = arr->type; Override("unused", ty.i32(), Expr(1_a)); auto* func = Func("foo", utils::Empty, ty.void_(), @@ -249,7 +250,7 @@ TEST_F(ResolverOverrideTest, TransitiveReferences_ViaArraySize_Alias) { auto* a = Override("a", ty.i32()); auto* b = Override("b", ty.i32(), Mul(2_a, "a")); Alias("arr_ty", ty.array(ty.i32(), Mul(2_a, "b"))); - auto* arr = GlobalVar("arr", type::AddressSpace::kWorkgroup, ty("arr_ty")); + auto* arr = GlobalVar("arr", builtin::AddressSpace::kWorkgroup, ty("arr_ty")); auto arr_ty = arr->type; Override("unused", ty.i32(), Expr(1_a)); auto* func = Func("foo", utils::Empty, ty.void_(), @@ -295,8 +296,8 @@ TEST_F(ResolverOverrideTest, TransitiveReferences_MultipleEntryPoints) { auto* d = Override("d", ty.i32()); Alias("arr_ty1", ty.array(ty.i32(), Mul("b1", "c1"))); Alias("arr_ty2", ty.array(ty.i32(), Mul("b2", "c2"))); - auto* arr1 = GlobalVar("arr1", type::AddressSpace::kWorkgroup, ty("arr_ty1")); - auto* arr2 = GlobalVar("arr2", type::AddressSpace::kWorkgroup, ty("arr_ty2")); + auto* arr1 = GlobalVar("arr1", builtin::AddressSpace::kWorkgroup, ty("arr_ty1")); + auto* arr2 = GlobalVar("arr2", builtin::AddressSpace::kWorkgroup, ty("arr_ty2")); Override("unused", ty.i32(), Expr(1_a)); auto* func1 = Func("foo1", utils::Empty, ty.void_(), utils::Vector{ diff --git a/src/tint/resolver/ptr_ref_test.cc b/src/tint/resolver/ptr_ref_test.cc index 7f9c9573ca..1e702a5158 100644 --- a/src/tint/resolver/ptr_ref_test.cc +++ b/src/tint/resolver/ptr_ref_test.cc @@ -39,7 +39,7 @@ TEST_F(ResolverPtrRefTest, AddressOf) { ASSERT_TRUE(TypeOf(expr)->Is()); EXPECT_TRUE(TypeOf(expr)->As()->StoreType()->Is()); - EXPECT_EQ(TypeOf(expr)->As()->AddressSpace(), type::AddressSpace::kFunction); + EXPECT_EQ(TypeOf(expr)->As()->AddressSpace(), builtin::AddressSpace::kFunction); } TEST_F(ResolverPtrRefTest, AddressOfThenDeref) { @@ -68,23 +68,23 @@ TEST_F(ResolverPtrRefTest, DefaultPtrAddressSpace) { auto* buf = Structure("S", utils::Vector{Member("m", ty.i32())}); auto* function = Var("f", ty.i32()); - auto* private_ = GlobalVar("p", ty.i32(), type::AddressSpace::kPrivate); - auto* workgroup = GlobalVar("w", ty.i32(), type::AddressSpace::kWorkgroup); + auto* private_ = GlobalVar("p", ty.i32(), builtin::AddressSpace::kPrivate); + auto* workgroup = GlobalVar("w", ty.i32(), builtin::AddressSpace::kWorkgroup); auto* uniform = - GlobalVar("ub", ty.Of(buf), type::AddressSpace::kUniform, Binding(0_a), Group(0_a)); + GlobalVar("ub", ty.Of(buf), builtin::AddressSpace::kUniform, Binding(0_a), Group(0_a)); auto* storage = - GlobalVar("sb", ty.Of(buf), type::AddressSpace::kStorage, Binding(1_a), Group(0_a)); + GlobalVar("sb", ty.Of(buf), builtin::AddressSpace::kStorage, Binding(1_a), Group(0_a)); auto* function_ptr = - Let("f_ptr", ty.pointer(ty.i32(), type::AddressSpace::kFunction), AddressOf(function)); + Let("f_ptr", ty.pointer(ty.i32(), builtin::AddressSpace::kFunction), AddressOf(function)); auto* private_ptr = - Let("p_ptr", ty.pointer(ty.i32(), type::AddressSpace::kPrivate), AddressOf(private_)); + Let("p_ptr", ty.pointer(ty.i32(), builtin::AddressSpace::kPrivate), AddressOf(private_)); auto* workgroup_ptr = - Let("w_ptr", ty.pointer(ty.i32(), type::AddressSpace::kWorkgroup), AddressOf(workgroup)); + Let("w_ptr", ty.pointer(ty.i32(), builtin::AddressSpace::kWorkgroup), AddressOf(workgroup)); auto* uniform_ptr = - Let("ub_ptr", ty.pointer(ty.Of(buf), type::AddressSpace::kUniform), AddressOf(uniform)); + Let("ub_ptr", ty.pointer(ty.Of(buf), builtin::AddressSpace::kUniform), AddressOf(uniform)); auto* storage_ptr = - Let("sb_ptr", ty.pointer(ty.Of(buf), type::AddressSpace::kStorage), AddressOf(storage)); + Let("sb_ptr", ty.pointer(ty.Of(buf), builtin::AddressSpace::kStorage), 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 078782c156..d042402ff9 100644 --- a/src/tint/resolver/ptr_ref_validation_test.cc +++ b/src/tint/resolver/ptr_ref_validation_test.cc @@ -143,12 +143,12 @@ TEST_F(ResolverPtrRefValidationTest, InferredPtrAccessMismatch) { // } auto* inner = Structure("Inner", utils::Vector{Member("arr", ty.array())}); auto* buf = Structure("S", utils::Vector{Member("inner", ty.Of(inner))}); - auto* storage = GlobalVar("s", ty.Of(buf), type::AddressSpace::kStorage, + auto* storage = GlobalVar("s", ty.Of(buf), builtin::AddressSpace::kStorage, 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(type::AddressSpace::kStorage), AddressOf(expr)); + auto* ptr = Let(Source{{12, 34}}, "p", ty.pointer(builtin::AddressSpace::kStorage), + AddressOf(expr)); WrapInFunction(ptr); diff --git a/src/tint/resolver/resolver.cc b/src/tint/resolver/resolver.cc index 5f4e89dee2..a664334b7e 100644 --- a/src/tint/resolver/resolver.cc +++ b/src/tint/resolver/resolver.cc @@ -88,7 +88,7 @@ #include "src/tint/utils/vector.h" TINT_INSTANTIATE_TYPEINFO(tint::sem::BuiltinEnumExpression); -TINT_INSTANTIATE_TYPEINFO(tint::sem::BuiltinEnumExpression); +TINT_INSTANTIATE_TYPEINFO(tint::sem::BuiltinEnumExpression); TINT_INSTANTIATE_TYPEINFO(tint::sem::BuiltinEnumExpression); namespace tint::resolver { @@ -255,12 +255,12 @@ sem::Variable* Resolver::Let(const ast::Let* v, bool is_global) { ty = rhs->Type()->UnwrapRef(); // Implicit load of RHS } - if (rhs && !validator_.VariableInitializer(v, type::AddressSpace::kUndefined, ty, rhs)) { + if (rhs && !validator_.VariableInitializer(v, builtin::AddressSpace::kUndefined, ty, rhs)) { return nullptr; } - if (!ApplyAddressSpaceUsageToType(type::AddressSpace::kUndefined, const_cast(ty), - v->source)) { + if (!ApplyAddressSpaceUsageToType(builtin::AddressSpace::kUndefined, + const_cast(ty), v->source)) { AddNote("while instantiating 'let' " + builder_->Symbols().NameFor(v->name->symbol), v->source); return nullptr; @@ -269,12 +269,12 @@ sem::Variable* Resolver::Let(const ast::Let* v, bool is_global) { sem::Variable* sem = nullptr; if (is_global) { sem = builder_->create( - v, ty, sem::EvaluationStage::kRuntime, type::AddressSpace::kUndefined, + v, ty, sem::EvaluationStage::kRuntime, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, /* constant_value */ nullptr, sem::BindingPoint{}, std::nullopt); } else { sem = builder_->create(v, ty, sem::EvaluationStage::kRuntime, - type::AddressSpace::kUndefined, + builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, current_statement_, /* constant_value */ nullptr); } @@ -318,19 +318,19 @@ sem::Variable* Resolver::Override(const ast::Override* v) { return nullptr; } - if (rhs && !validator_.VariableInitializer(v, type::AddressSpace::kUndefined, ty, rhs)) { + if (rhs && !validator_.VariableInitializer(v, builtin::AddressSpace::kUndefined, ty, rhs)) { return nullptr; } - if (!ApplyAddressSpaceUsageToType(type::AddressSpace::kUndefined, const_cast(ty), - v->source)) { + if (!ApplyAddressSpaceUsageToType(builtin::AddressSpace::kUndefined, + const_cast(ty), v->source)) { AddNote("while instantiating 'override' " + builder_->Symbols().NameFor(v->name->symbol), v->source); return nullptr; } auto* sem = builder_->create( - v, ty, sem::EvaluationStage::kOverride, type::AddressSpace::kUndefined, + v, ty, sem::EvaluationStage::kOverride, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, /* constant_value */ nullptr, sem::BindingPoint{}, std::nullopt); sem->SetInitializer(rhs); @@ -412,12 +412,12 @@ sem::Variable* Resolver::Const(const ast::Const* c, bool is_global) { ty = rhs->Type(); } - if (!validator_.VariableInitializer(c, type::AddressSpace::kUndefined, ty, rhs)) { + if (!validator_.VariableInitializer(c, builtin::AddressSpace::kUndefined, ty, rhs)) { return nullptr; } - if (!ApplyAddressSpaceUsageToType(type::AddressSpace::kUndefined, const_cast(ty), - c->source)) { + if (!ApplyAddressSpaceUsageToType(builtin::AddressSpace::kUndefined, + const_cast(ty), c->source)) { AddNote("while instantiating 'const' " + builder_->Symbols().NameFor(c->name->symbol), c->source); return nullptr; @@ -426,10 +426,10 @@ sem::Variable* Resolver::Const(const ast::Const* c, bool is_global) { const auto value = rhs->ConstantValue(); auto* sem = is_global ? static_cast(builder_->create( - c, ty, sem::EvaluationStage::kConstant, type::AddressSpace::kUndefined, + c, ty, sem::EvaluationStage::kConstant, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, value, sem::BindingPoint{}, std::nullopt)) : static_cast(builder_->create( - c, ty, sem::EvaluationStage::kConstant, type::AddressSpace::kUndefined, + c, ty, sem::EvaluationStage::kConstant, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, current_statement_, value)); sem->SetInitializer(rhs); @@ -473,7 +473,7 @@ sem::Variable* Resolver::Var(const ast::Var* var, bool is_global) { return nullptr; } - auto address_space = type::AddressSpace::kUndefined; + auto address_space = builtin::AddressSpace::kUndefined; if (var->declared_address_space) { auto expr = AddressSpaceExpression(var->declared_address_space); if (!expr) { @@ -483,17 +483,17 @@ sem::Variable* Resolver::Var(const ast::Var* var, bool is_global) { } else { // No declared address space. Infer from usage / type. if (!is_global) { - address_space = type::AddressSpace::kFunction; + address_space = builtin::AddressSpace::kFunction; } else if (storage_ty->UnwrapRef()->is_handle()) { // https://gpuweb.github.io/gpuweb/wgsl/#module-scope-variables // If the store type is a texture type or a sampler type, then the // variable declaration must not have a address space attribute. The // address space will always be handle. - address_space = type::AddressSpace::kHandle; + address_space = builtin::AddressSpace::kHandle; } } - if (!is_global && address_space != type::AddressSpace::kFunction && + if (!is_global && address_space != builtin::AddressSpace::kFunction && validator_.IsValidationEnabled(var->attributes, ast::DisabledValidation::kIgnoreAddressSpace)) { AddError("function-scope 'var' declaration must use 'function' address space", var->source); @@ -622,7 +622,7 @@ sem::Parameter* Resolver::Parameter(const ast::Parameter* param, uint32_t index) return nullptr; } - if (!ApplyAddressSpaceUsageToType(type::AddressSpace::kUndefined, ty, param->type->source)) { + if (!ApplyAddressSpaceUsageToType(builtin::AddressSpace::kUndefined, ty, param->type->source)) { add_note(); return nullptr; } @@ -673,7 +673,7 @@ sem::Parameter* Resolver::Parameter(const ast::Parameter* param, uint32_t index) } auto* sem = builder_->create( - param, index, ty, type::AddressSpace::kUndefined, builtin::Access::kUndefined, + param, index, ty, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, sem::ParameterUsage::kNone, binding_point, location); builder_->Sem().Add(param, sem); return sem; @@ -703,12 +703,12 @@ utils::Result Resolver::LocationAttribute(const ast::LocationAttribute return static_cast(value); } -builtin::Access Resolver::DefaultAccessForAddressSpace(type::AddressSpace address_space) { +builtin::Access Resolver::DefaultAccessForAddressSpace(builtin::AddressSpace address_space) { // https://gpuweb.github.io/gpuweb/wgsl/#storage-class switch (address_space) { - case type::AddressSpace::kStorage: - case type::AddressSpace::kUniform: - case type::AddressSpace::kHandle: + case builtin::AddressSpace::kStorage: + case builtin::AddressSpace::kUniform: + case builtin::AddressSpace::kHandle: return builtin::Access::kRead; default: break; @@ -933,7 +933,7 @@ sem::Function* Resolver::Function(const ast::Function* decl) { } if (auto* str = return_type->As()) { - if (!ApplyAddressSpaceUsageToType(type::AddressSpace::kUndefined, str, decl->source)) { + if (!ApplyAddressSpaceUsageToType(builtin::AddressSpace::kUndefined, str, decl->source)) { AddNote("while instantiating return type for " + builder_->Symbols().NameFor(decl->name->symbol), decl->source); @@ -1497,7 +1497,7 @@ type::Type* Resolver::Type(const ast::Expression* ast) { return const_cast(type_expr->Type()); } -sem::BuiltinEnumExpression* Resolver::AddressSpaceExpression( +sem::BuiltinEnumExpression* Resolver::AddressSpaceExpression( const ast::Expression* expr) { return sem_.AsAddressSpace(Expression(expr)); } @@ -2024,10 +2024,10 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) { [&]() -> sem::TypeInitializer* { auto params = utils::Transform(args, [&](auto, size_t i) { return builder_->create( - nullptr, // declaration - static_cast(i), // index - arr->ElemType(), // type - type::AddressSpace::kUndefined, // address_space + nullptr, // declaration + static_cast(i), // index + arr->ElemType(), // type + builtin::AddressSpace::kUndefined, // address_space builtin::Access::kUndefined); }); return builder_->create(arr, std::move(params), @@ -2053,11 +2053,11 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) { params.Resize(std::min(args.Length(), str->Members().Length())); for (size_t i = 0, n = params.Length(); i < n; i++) { params[i] = builder_->create( - nullptr, // declaration - static_cast(i), // index - str->Members()[i]->Type(), // type - type::AddressSpace::kUndefined, // address_space - builtin::Access::kUndefined); // access + nullptr, // declaration + static_cast(i), // index + str->Members()[i]->Type(), // type + builtin::AddressSpace::kUndefined, // address_space + builtin::Access::kUndefined); // access } return builder_->create(str, std::move(params), args_stage); @@ -2982,8 +2982,8 @@ sem::Expression* Resolver::Identifier(const ast::IdentifierExpression* expr) { expr, current_statement_, access); } - if (auto addr = resolved->AddressSpace(); addr != type::AddressSpace::kUndefined) { - return builder_->create>( + if (auto addr = resolved->AddressSpace(); addr != builtin::AddressSpace::kUndefined) { + return builder_->create>( expr, current_statement_, addr); } @@ -3980,7 +3980,7 @@ sem::Statement* Resolver::IncrementDecrementStatement( }); } -bool Resolver::ApplyAddressSpaceUsageToType(type::AddressSpace address_space, +bool Resolver::ApplyAddressSpaceUsageToType(builtin::AddressSpace address_space, type::Type* ty, const Source& usage) { ty = const_cast(ty->UnwrapRef()); @@ -4008,7 +4008,7 @@ bool Resolver::ApplyAddressSpaceUsageToType(type::AddressSpace address_space, } if (auto* arr = ty->As()) { - if (address_space != type::AddressSpace::kStorage) { + if (address_space != builtin::AddressSpace::kStorage) { if (arr->Count()->Is()) { AddError("runtime-sized arrays can only be used in the address space", usage); @@ -4027,7 +4027,7 @@ bool Resolver::ApplyAddressSpaceUsageToType(type::AddressSpace address_space, usage); } - if (type::IsHostShareable(address_space) && !validator_.IsHostShareable(ty)) { + if (builtin::IsHostShareable(address_space) && !validator_.IsHostShareable(ty)) { std::stringstream err; err << "Type '" << sem_.TypeNameOf(ty) << "' cannot be used in address space '" << address_space << "' as it is non-host-shareable"; diff --git a/src/tint/resolver/resolver.h b/src/tint/resolver/resolver.h index 4057f73a64..b94467de20 100644 --- a/src/tint/resolver/resolver.h +++ b/src/tint/resolver/resolver.h @@ -138,10 +138,11 @@ class Resolver { /// @returns the resolved type from an expression, or nullptr on error type::Type* Type(const ast::Expression* ast); - /// @returns the call of Expression() cast to a sem::BuiltinEnumExpression. - /// If the sem::Expression is not a sem::BuiltinEnumExpression, then an - /// error diagnostic is raised and nullptr is returned. - sem::BuiltinEnumExpression* AddressSpaceExpression( + /// @returns the call of Expression() cast to a + /// sem::BuiltinEnumExpression. If the sem::Expression is not a + /// sem::BuiltinEnumExpression, then an error diagnostic is raised and + /// nullptr is returned. + sem::BuiltinEnumExpression* AddressSpaceExpression( const ast::Expression* expr); /// @returns the call of Expression() cast to a sem::BuiltinEnumExpression. @@ -401,11 +402,13 @@ class Resolver { /// given type and address space. Used for generating sensible error /// messages. /// @returns true on success, false on error - bool ApplyAddressSpaceUsageToType(type::AddressSpace sc, type::Type* ty, const Source& usage); + bool ApplyAddressSpaceUsageToType(builtin::AddressSpace sc, + type::Type* ty, + const Source& usage); /// @param address_space the address space /// @returns the default access control for the given address space - builtin::Access DefaultAccessForAddressSpace(type::AddressSpace address_space); + builtin::Access DefaultAccessForAddressSpace(builtin::AddressSpace address_space); /// Allocate constant IDs for pipeline-overridable constants. /// @returns true on success, false on error diff --git a/src/tint/resolver/resolver_test.cc b/src/tint/resolver/resolver_test.cc index 1d14498804..87bb8d0067 100644 --- a/src/tint/resolver/resolver_test.cc +++ b/src/tint/resolver/resolver_test.cc @@ -325,7 +325,7 @@ TEST_F(ResolverTest, Stmt_VariableDecl_Alias) { TEST_F(ResolverTest, Stmt_VariableDecl_ModuleScope) { auto* init = Expr(2_i); - GlobalVar("my_var", ty.i32(), type::AddressSpace::kPrivate, init); + GlobalVar("my_var", ty.i32(), builtin::AddressSpace::kPrivate, init); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -405,7 +405,7 @@ TEST_F(ResolverTest, Stmt_VariableDecl_ModuleScopeAfterFunctionScope) { Func("func_i32", utils::Empty, ty.void_(), utils::Vector{fn_i32_decl}); // Declare f32 "foo" at module scope - auto* mod_f32 = Var("foo", ty.f32(), type::AddressSpace::kPrivate, Expr(2_f)); + auto* mod_f32 = Var("foo", ty.f32(), builtin::AddressSpace::kPrivate, Expr(2_f)); auto* mod_init = mod_f32->initializer; AST().AddGlobalVariable(mod_f32); @@ -433,7 +433,7 @@ TEST_F(ResolverTest, Stmt_VariableDecl_ModuleScopeAfterFunctionScope) { TEST_F(ResolverTest, ArraySize_UnsignedLiteral) { // var a : array; - auto* a = GlobalVar("a", ty.array(ty.f32(), Expr(10_u)), type::AddressSpace::kPrivate); + auto* a = GlobalVar("a", ty.array(ty.f32(), Expr(10_u)), builtin::AddressSpace::kPrivate); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -446,7 +446,7 @@ TEST_F(ResolverTest, ArraySize_UnsignedLiteral) { TEST_F(ResolverTest, ArraySize_SignedLiteral) { // var a : array; - auto* a = GlobalVar("a", ty.array(ty.f32(), Expr(10_i)), type::AddressSpace::kPrivate); + auto* a = GlobalVar("a", ty.array(ty.f32(), Expr(10_i)), builtin::AddressSpace::kPrivate); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -461,7 +461,7 @@ TEST_F(ResolverTest, ArraySize_UnsignedConst) { // const size = 10u; // var a : array; GlobalConst("size", Expr(10_u)); - auto* a = GlobalVar("a", ty.array(ty.f32(), Expr("size")), type::AddressSpace::kPrivate); + auto* a = GlobalVar("a", ty.array(ty.f32(), Expr("size")), builtin::AddressSpace::kPrivate); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -476,7 +476,7 @@ TEST_F(ResolverTest, ArraySize_SignedConst) { // const size = 0; // var a : array; GlobalConst("size", Expr(10_i)); - auto* a = GlobalVar("a", ty.array(ty.f32(), Expr("size")), type::AddressSpace::kPrivate); + auto* a = GlobalVar("a", ty.array(ty.f32(), Expr("size")), builtin::AddressSpace::kPrivate); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -491,7 +491,7 @@ TEST_F(ResolverTest, ArraySize_NamedOverride) { // override size = 10i; // var a : array; auto* override = Override("size", Expr(10_i)); - auto* a = GlobalVar("a", ty.array(ty.f32(), Expr("size")), type::AddressSpace::kWorkgroup); + auto* a = GlobalVar("a", ty.array(ty.f32(), Expr("size")), builtin::AddressSpace::kWorkgroup); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -509,8 +509,8 @@ TEST_F(ResolverTest, ArraySize_NamedOverride_Equivalence) { // var a : array; // var b : array; auto* override = Override("size", Expr(10_i)); - auto* a = GlobalVar("a", ty.array(ty.f32(), Expr("size")), type::AddressSpace::kWorkgroup); - auto* b = GlobalVar("b", ty.array(ty.f32(), Expr("size")), type::AddressSpace::kWorkgroup); + auto* a = GlobalVar("a", ty.array(ty.f32(), Expr("size")), builtin::AddressSpace::kWorkgroup); + auto* b = GlobalVar("b", ty.array(ty.f32(), Expr("size")), builtin::AddressSpace::kWorkgroup); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -536,7 +536,7 @@ TEST_F(ResolverTest, ArraySize_UnnamedOverride) { // var a : array; auto* override = Override("size", Expr(10_i)); auto* cnt = Mul("size", 2_a); - auto* a = GlobalVar("a", ty.array(ty.f32(), cnt), type::AddressSpace::kWorkgroup); + auto* a = GlobalVar("a", ty.array(ty.f32(), cnt), builtin::AddressSpace::kWorkgroup); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -556,8 +556,8 @@ TEST_F(ResolverTest, ArraySize_UnamedOverride_Equivalence) { auto* override = Override("size", Expr(10_i)); auto* a_cnt = Mul("size", 2_a); auto* b_cnt = Mul("size", 2_a); - auto* a = GlobalVar("a", ty.array(ty.f32(), a_cnt), type::AddressSpace::kWorkgroup); - auto* b = GlobalVar("b", ty.array(ty.f32(), b_cnt), type::AddressSpace::kWorkgroup); + auto* a = GlobalVar("a", ty.array(ty.f32(), a_cnt), builtin::AddressSpace::kWorkgroup); + auto* b = GlobalVar("b", ty.array(ty.f32(), b_cnt), builtin::AddressSpace::kWorkgroup); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -579,7 +579,7 @@ TEST_F(ResolverTest, ArraySize_UnamedOverride_Equivalence) { } TEST_F(ResolverTest, Expr_Bitcast) { - GlobalVar("name", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("name", ty.f32(), builtin::AddressSpace::kPrivate); auto* bitcast = Bitcast(Expr("name")); WrapInFunction(bitcast); @@ -642,7 +642,7 @@ TEST_F(ResolverTest, Expr_Call_Builtin) { } TEST_F(ResolverTest, Expr_Cast) { - GlobalVar("name", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("name", ty.f32(), builtin::AddressSpace::kPrivate); auto* cast = Call("name"); WrapInFunction(cast); @@ -700,7 +700,7 @@ TEST_F(ResolverTest, Expr_Initializer_Type_Vec4) { } TEST_F(ResolverTest, Expr_Identifier_GlobalVariable) { - auto* my_var = GlobalVar("my_var", ty.f32(), type::AddressSpace::kPrivate); + auto* my_var = GlobalVar("my_var", ty.f32(), builtin::AddressSpace::kPrivate); auto* ident = Expr("my_var"); WrapInFunction(ident); @@ -801,7 +801,7 @@ TEST_F(ResolverTest, Expr_Identifier_Function_Ptr) { auto* v = Expr("v"); auto* p = Expr("p"); auto* v_decl = Decl(Var("v", ty.f32())); - auto* p_decl = Decl(Let("p", ty.pointer(type::AddressSpace::kFunction), AddressOf(v))); + auto* p_decl = Decl(Let("p", ty.pointer(builtin::AddressSpace::kFunction), AddressOf(v))); auto* assign = Assign(Deref(p), 1.23_f); Func("my_func", utils::Empty, ty.void_(), utils::Vector{ @@ -877,7 +877,7 @@ TEST_F(ResolverTest, Function_Parameters_Locations) { Param("b", ty.u32(), utils::Vector{Builtin(builtin::BuiltinValue::kVertexIndex)}); auto* param_c = Param("c", ty.u32(), utils::Vector{Location(1_a)}); - GlobalVar("my_vec", ty.vec4(), type::AddressSpace::kPrivate); + GlobalVar("my_vec", ty.vec4(), builtin::AddressSpace::kPrivate); auto* func = Func("my_func", utils::Vector{ param_a, @@ -907,7 +907,7 @@ TEST_F(ResolverTest, Function_Parameters_Locations) { TEST_F(ResolverTest, Function_GlobalVariable_Location) { auto* var = GlobalVar( - "my_vec", ty.vec4(), type::AddressSpace::kIn, + "my_vec", ty.vec4(), builtin::AddressSpace::kIn, utils::Vector{Location(3_a), Disable(ast::DisabledValidation::kIgnoreAddressSpace)}); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -920,10 +920,10 @@ TEST_F(ResolverTest, Function_GlobalVariable_Location) { TEST_F(ResolverTest, Function_RegisterInputOutputVariables) { auto* s = Structure("S", utils::Vector{Member("m", ty.u32())}); - auto* sb_var = GlobalVar("sb_var", ty.Of(s), type::AddressSpace::kStorage, + auto* sb_var = GlobalVar("sb_var", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, Binding(0_a), Group(0_a)); - auto* wg_var = GlobalVar("wg_var", ty.f32(), type::AddressSpace::kWorkgroup); - auto* priv_var = GlobalVar("priv_var", ty.f32(), type::AddressSpace::kPrivate); + auto* wg_var = GlobalVar("wg_var", ty.f32(), builtin::AddressSpace::kWorkgroup); + auto* priv_var = GlobalVar("priv_var", ty.f32(), builtin::AddressSpace::kPrivate); auto* func = Func("my_func", utils::Empty, ty.void_(), utils::Vector{ @@ -966,7 +966,7 @@ TEST_F(ResolverTest, Function_ReturnType_Location) { } TEST_F(ResolverTest, Function_ReturnType_NoLocation) { - GlobalVar("my_vec", ty.vec4(), type::AddressSpace::kPrivate); + GlobalVar("my_vec", ty.vec4(), builtin::AddressSpace::kPrivate); auto* func = Func("my_func", utils::Empty, ty.vec4(), utils::Vector{ Return("my_vec"), @@ -988,10 +988,10 @@ TEST_F(ResolverTest, Function_ReturnType_NoLocation) { TEST_F(ResolverTest, Function_RegisterInputOutputVariables_SubFunction) { auto* s = Structure("S", utils::Vector{Member("m", ty.u32())}); - auto* sb_var = GlobalVar("sb_var", ty.Of(s), type::AddressSpace::kStorage, + auto* sb_var = GlobalVar("sb_var", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, Binding(0_a), Group(0_a)); - auto* wg_var = GlobalVar("wg_var", ty.f32(), type::AddressSpace::kWorkgroup); - auto* priv_var = GlobalVar("priv_var", ty.f32(), type::AddressSpace::kPrivate); + auto* wg_var = GlobalVar("wg_var", ty.f32(), builtin::AddressSpace::kWorkgroup); + auto* priv_var = GlobalVar("priv_var", ty.f32(), builtin::AddressSpace::kPrivate); Func("my_func", utils::Empty, ty.f32(), utils::Vector{Assign("wg_var", "wg_var"), Assign("sb_var", "sb_var"), @@ -1240,7 +1240,7 @@ TEST_F(ResolverTest, Function_WorkgroupSize_Mixed) { TEST_F(ResolverTest, Expr_MemberAccessor_Struct) { auto* st = Structure( "S", utils::Vector{Member("first_member", ty.i32()), Member("second_member", ty.f32())}); - GlobalVar("my_struct", ty.Of(st), type::AddressSpace::kPrivate); + GlobalVar("my_struct", ty.Of(st), builtin::AddressSpace::kPrivate); auto* mem = MemberAccessor("my_struct", "second_member"); WrapInFunction(mem); @@ -1261,7 +1261,7 @@ TEST_F(ResolverTest, Expr_MemberAccessor_Struct_Alias) { auto* st = Structure( "S", utils::Vector{Member("first_member", ty.i32()), Member("second_member", ty.f32())}); auto* alias = Alias("alias", ty.Of(st)); - GlobalVar("my_struct", ty.Of(alias), type::AddressSpace::kPrivate); + GlobalVar("my_struct", ty.Of(alias), builtin::AddressSpace::kPrivate); auto* mem = MemberAccessor("my_struct", "second_member"); WrapInFunction(mem); @@ -1278,7 +1278,7 @@ TEST_F(ResolverTest, Expr_MemberAccessor_Struct_Alias) { } TEST_F(ResolverTest, Expr_MemberAccessor_VectorSwizzle) { - GlobalVar("my_vec", ty.vec4(), type::AddressSpace::kPrivate); + GlobalVar("my_vec", ty.vec4(), builtin::AddressSpace::kPrivate); auto* mem = MemberAccessor("my_vec", "xzyw"); WrapInFunction(mem); @@ -1296,7 +1296,7 @@ TEST_F(ResolverTest, Expr_MemberAccessor_VectorSwizzle) { } TEST_F(ResolverTest, Expr_MemberAccessor_VectorSwizzle_SingleElement) { - GlobalVar("my_vec", ty.vec3(), type::AddressSpace::kPrivate); + GlobalVar("my_vec", ty.vec3(), builtin::AddressSpace::kPrivate); auto* mem = MemberAccessor("my_vec", "b"); WrapInFunction(mem); @@ -1329,7 +1329,7 @@ TEST_F(ResolverTest, Expr_Accessor_MultiLevel) { auto* stB = Structure("B", utils::Vector{Member("foo", ty.vec4())}); auto* stA = Structure("A", utils::Vector{Member("mem", ty.array(ty.Of(stB), 3_i))}); - GlobalVar("c", ty.Of(stA), type::AddressSpace::kPrivate); + GlobalVar("c", ty.Of(stA), builtin::AddressSpace::kPrivate); auto* mem = MemberAccessor(MemberAccessor(IndexAccessor(MemberAccessor("c", "mem"), 0_i), "foo"), "yx"); @@ -1347,7 +1347,7 @@ TEST_F(ResolverTest, Expr_Accessor_MultiLevel) { TEST_F(ResolverTest, Expr_MemberAccessor_InBinaryOp) { auto* st = Structure( "S", utils::Vector{Member("first_member", ty.f32()), Member("second_member", ty.f32())}); - GlobalVar("my_struct", ty.Of(st), type::AddressSpace::kPrivate); + GlobalVar("my_struct", ty.Of(st), builtin::AddressSpace::kPrivate); auto* expr = Add(MemberAccessor("my_struct", "first_member"), MemberAccessor("my_struct", "second_member")); @@ -1650,8 +1650,8 @@ TEST_P(Expr_Binary_Test_Valid, All) { ss << FriendlyName(lhs_type) << " " << params.op << " " << FriendlyName(rhs_type); SCOPED_TRACE(ss.str()); - GlobalVar("lhs", lhs_type, type::AddressSpace::kPrivate); - GlobalVar("rhs", rhs_type, type::AddressSpace::kPrivate); + GlobalVar("lhs", lhs_type, builtin::AddressSpace::kPrivate); + GlobalVar("rhs", rhs_type, builtin::AddressSpace::kPrivate); auto* expr = create(params.op, Expr("lhs"), Expr("rhs")); WrapInFunction(expr); @@ -1685,8 +1685,8 @@ TEST_P(Expr_Binary_Test_WithAlias_Valid, All) { << FriendlyName(rhs_type); SCOPED_TRACE(ss.str()); - GlobalVar("lhs", lhs_type, type::AddressSpace::kPrivate); - GlobalVar("rhs", rhs_type, type::AddressSpace::kPrivate); + GlobalVar("lhs", lhs_type, builtin::AddressSpace::kPrivate); + GlobalVar("rhs", rhs_type, builtin::AddressSpace::kPrivate); auto* expr = create(params.op, Expr("lhs"), Expr("rhs")); WrapInFunction(expr); @@ -1731,8 +1731,8 @@ TEST_P(Expr_Binary_Test_Invalid, All) { ss << FriendlyName(lhs_type) << " " << op << " " << FriendlyName(rhs_type); SCOPED_TRACE(ss.str()); - GlobalVar("lhs", lhs_type, type::AddressSpace::kPrivate); - GlobalVar("rhs", rhs_type, type::AddressSpace::kPrivate); + GlobalVar("lhs", lhs_type, builtin::AddressSpace::kPrivate); + GlobalVar("rhs", rhs_type, builtin::AddressSpace::kPrivate); auto* expr = create(Source{{12, 34}}, op, Expr("lhs"), Expr("rhs")); WrapInFunction(expr); @@ -1771,8 +1771,8 @@ TEST_P(Expr_Binary_Test_Invalid_VectorMatrixMultiply, All) { is_valid_expr = vec_size == mat_cols; } - GlobalVar("lhs", lhs_type, type::AddressSpace::kPrivate); - GlobalVar("rhs", rhs_type, type::AddressSpace::kPrivate); + GlobalVar("lhs", lhs_type, builtin::AddressSpace::kPrivate); + GlobalVar("rhs", rhs_type, builtin::AddressSpace::kPrivate); auto* expr = Mul(Source{{12, 34}}, Expr("lhs"), Expr("rhs")); WrapInFunction(expr); @@ -1808,8 +1808,8 @@ TEST_P(Expr_Binary_Test_Invalid_MatrixMatrixMultiply, All) { auto* col = create(f32, lhs_mat_rows); auto* result_type = create(col, rhs_mat_cols); - GlobalVar("lhs", lhs_type, type::AddressSpace::kPrivate); - GlobalVar("rhs", rhs_type, type::AddressSpace::kPrivate); + GlobalVar("lhs", lhs_type, builtin::AddressSpace::kPrivate); + GlobalVar("rhs", rhs_type, builtin::AddressSpace::kPrivate); auto* expr = Mul(Source{{12, 34}}, Expr("lhs"), Expr("rhs")); WrapInFunction(expr); @@ -1837,11 +1837,11 @@ TEST_P(UnaryOpExpressionTest, Expr_UnaryOp) { auto op = GetParam(); if (op == ast::UnaryOp::kNot) { - GlobalVar("ident", ty.vec4(), type::AddressSpace::kPrivate); + GlobalVar("ident", ty.vec4(), builtin::AddressSpace::kPrivate); } else if (op == ast::UnaryOp::kNegation || op == ast::UnaryOp::kComplement) { - GlobalVar("ident", ty.vec4(), type::AddressSpace::kPrivate); + GlobalVar("ident", ty.vec4(), builtin::AddressSpace::kPrivate); } else { - GlobalVar("ident", ty.vec4(), type::AddressSpace::kPrivate); + GlobalVar("ident", ty.vec4(), builtin::AddressSpace::kPrivate); } auto* der = create(op, Expr("ident")); WrapInFunction(der); @@ -1873,7 +1873,7 @@ TEST_F(ResolverTest, AddressSpace_SetsIfMissing) { EXPECT_TRUE(r()->Resolve()) << r()->error(); - EXPECT_EQ(Sem().Get(var)->AddressSpace(), type::AddressSpace::kFunction); + EXPECT_EQ(Sem().Get(var)->AddressSpace(), builtin::AddressSpace::kFunction); } TEST_F(ResolverTest, AddressSpace_SetForSampler) { @@ -1882,7 +1882,7 @@ TEST_F(ResolverTest, AddressSpace_SetForSampler) { EXPECT_TRUE(r()->Resolve()) << r()->error(); - EXPECT_EQ(Sem().Get(var)->AddressSpace(), type::AddressSpace::kHandle); + EXPECT_EQ(Sem().Get(var)->AddressSpace(), builtin::AddressSpace::kHandle); } TEST_F(ResolverTest, AddressSpace_SetForTexture) { @@ -1891,7 +1891,7 @@ TEST_F(ResolverTest, AddressSpace_SetForTexture) { EXPECT_TRUE(r()->Resolve()) << r()->error(); - EXPECT_EQ(Sem().Get(var)->AddressSpace(), type::AddressSpace::kHandle); + EXPECT_EQ(Sem().Get(var)->AddressSpace(), builtin::AddressSpace::kHandle); } TEST_F(ResolverTest, AddressSpace_DoesNotSetOnConst) { @@ -1901,14 +1901,14 @@ TEST_F(ResolverTest, AddressSpace_DoesNotSetOnConst) { EXPECT_TRUE(r()->Resolve()) << r()->error(); - EXPECT_EQ(Sem().Get(var)->AddressSpace(), type::AddressSpace::kUndefined); + EXPECT_EQ(Sem().Get(var)->AddressSpace(), builtin::AddressSpace::kUndefined); } TEST_F(ResolverTest, Access_SetForStorageBuffer) { // struct S { x : i32 }; // var g : S; auto* s = Structure("S", utils::Vector{Member(Source{{12, 34}}, "x", ty.i32())}); - auto* var = GlobalVar(Source{{56, 78}}, "g", ty.Of(s), type::AddressSpace::kStorage, + auto* var = GlobalVar(Source{{56, 78}}, "g", ty.Of(s), builtin::AddressSpace::kStorage, Binding(0_a), Group(0_a)); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -1941,11 +1941,11 @@ TEST_F(ResolverTest, Function_EntryPoints_StageAttribute) { // ep_1 -> {} // ep_2 -> {} - GlobalVar("first", ty.f32(), type::AddressSpace::kPrivate); - GlobalVar("second", ty.f32(), type::AddressSpace::kPrivate); - GlobalVar("call_a", ty.f32(), type::AddressSpace::kPrivate); - GlobalVar("call_b", ty.f32(), type::AddressSpace::kPrivate); - GlobalVar("call_c", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("first", ty.f32(), builtin::AddressSpace::kPrivate); + GlobalVar("second", ty.f32(), builtin::AddressSpace::kPrivate); + GlobalVar("call_a", ty.f32(), builtin::AddressSpace::kPrivate); + GlobalVar("call_b", ty.f32(), builtin::AddressSpace::kPrivate); + GlobalVar("call_c", ty.f32(), builtin::AddressSpace::kPrivate); auto* func_b = Func("b", utils::Empty, ty.f32(), utils::Vector{ @@ -2085,8 +2085,8 @@ TEST_F(ResolverTest, ASTNodeReachedTwice) { { ProgramBuilder b; auto* expr = b.Expr(1_i); - b.GlobalVar("a", b.ty.i32(), type::AddressSpace::kPrivate, expr); - b.GlobalVar("b", b.ty.i32(), type::AddressSpace::kPrivate, expr); + b.GlobalVar("a", b.ty.i32(), builtin::AddressSpace::kPrivate, expr); + b.GlobalVar("b", b.ty.i32(), builtin::AddressSpace::kPrivate, expr); Resolver(&b).Resolve(); }, "internal compiler error: AST node 'tint::ast::IntLiteralExpression' was encountered twice " @@ -2094,7 +2094,7 @@ TEST_F(ResolverTest, ASTNodeReachedTwice) { } TEST_F(ResolverTest, UnaryOp_Not) { - GlobalVar("ident", ty.vec4(), type::AddressSpace::kPrivate); + GlobalVar("ident", ty.vec4(), builtin::AddressSpace::kPrivate); auto* der = create(ast::UnaryOp::kNot, Expr(Source{{12, 34}}, "ident")); WrapInFunction(der); @@ -2103,7 +2103,7 @@ TEST_F(ResolverTest, UnaryOp_Not) { } TEST_F(ResolverTest, UnaryOp_Complement) { - GlobalVar("ident", ty.vec4(), type::AddressSpace::kPrivate); + GlobalVar("ident", ty.vec4(), builtin::AddressSpace::kPrivate); auto* der = create(ast::UnaryOp::kComplement, Expr(Source{{12, 34}}, "ident")); WrapInFunction(der); @@ -2113,7 +2113,7 @@ TEST_F(ResolverTest, UnaryOp_Complement) { } TEST_F(ResolverTest, UnaryOp_Negation) { - GlobalVar("ident", ty.u32(), type::AddressSpace::kPrivate); + GlobalVar("ident", ty.u32(), builtin::AddressSpace::kPrivate); auto* der = create(ast::UnaryOp::kNegation, Expr(Source{{12, 34}}, "ident")); WrapInFunction(der); @@ -2272,7 +2272,7 @@ TEST_F(ResolverTest, TextureSampler_Bug1715) { // crbug.com/tint/1715 GlobalVar("s", ty.sampler(type::SamplerKind::kSampler), Group(0_a), Binding(0_a)); GlobalVar("t", ty.sampled_texture(type::TextureDimension::k2d, ty.f32()), Group(0_a), Binding(1_a)); - GlobalVar("c", ty.vec2(), type::AddressSpace::kUniform, Group(0_a), Binding(2_a)); + GlobalVar("c", ty.vec2(), builtin::AddressSpace::kUniform, Group(0_a), Binding(2_a)); Func("main", utils::Empty, ty.vec4(), utils::Vector{ @@ -2288,9 +2288,9 @@ TEST_F(ResolverTest, TextureSampler_Bug1715) { // crbug.com/tint/1715 Func("helper", utils::Vector{ Param("sl", ty.pointer(ty.sampler(type::SamplerKind::kSampler), - type::AddressSpace::kFunction)), + builtin::AddressSpace::kFunction)), Param("tl", ty.pointer(ty.sampled_texture(type::TextureDimension::k2d, ty.f32()), - type::AddressSpace::kFunction)), + builtin::AddressSpace::kFunction)), }, ty.vec4(), utils::Vector{ @@ -2303,15 +2303,15 @@ TEST_F(ResolverTest, TextureSampler_Bug1715) { // crbug.com/tint/1715 TEST_F(ResolverTest, ModuleDependencyOrderedDeclarations) { auto* f0 = Func("f0", utils::Empty, ty.void_(), utils::Empty); - auto* v0 = GlobalVar("v0", ty.i32(), type::AddressSpace::kPrivate); + auto* v0 = GlobalVar("v0", ty.i32(), builtin::AddressSpace::kPrivate); auto* a0 = Alias("a0", ty.i32()); auto* s0 = Structure("s0", utils::Vector{Member("m", ty.i32())}); auto* f1 = Func("f1", utils::Empty, ty.void_(), utils::Empty); - auto* v1 = GlobalVar("v1", ty.i32(), type::AddressSpace::kPrivate); + auto* v1 = GlobalVar("v1", ty.i32(), builtin::AddressSpace::kPrivate); auto* a1 = Alias("a1", ty.i32()); auto* s1 = Structure("s1", utils::Vector{Member("m", ty.i32())}); auto* f2 = Func("f2", utils::Empty, ty.void_(), utils::Empty); - auto* v2 = GlobalVar("v2", ty.i32(), type::AddressSpace::kPrivate); + auto* v2 = GlobalVar("v2", ty.i32(), builtin::AddressSpace::kPrivate); auto* a2 = Alias("a2", ty.i32()); auto* s2 = Structure("s2", utils::Vector{Member("m", ty.i32())}); diff --git a/src/tint/resolver/resolver_test_helper.h b/src/tint/resolver/resolver_test_helper.h index 7f68f251bd..0e1b7d5a6d 100644 --- a/src/tint/resolver/resolver_test_helper.h +++ b/src/tint/resolver/resolver_test_helper.h @@ -628,13 +628,13 @@ struct DataType> { /// @param b the ProgramBuilder /// @return a new AST alias type static inline ast::Type AST(ProgramBuilder& b) { - return b.ty.pointer(DataType::AST(b), type::AddressSpace::kPrivate, + return b.ty.pointer(DataType::AST(b), builtin::AddressSpace::kPrivate, builtin::Access::kUndefined); } /// @param b the ProgramBuilder /// @return the semantic aliased type static inline const type::Type* Sem(ProgramBuilder& b) { - return b.create(DataType::Sem(b), type::AddressSpace::kPrivate, + return b.create(DataType::Sem(b), builtin::AddressSpace::kPrivate, builtin::Access::kReadWrite); } @@ -643,7 +643,7 @@ struct DataType> { static inline const ast::Expression* Expr(ProgramBuilder& b, utils::VectorRef /*unused*/) { auto sym = b.Symbols().New("global_for_ptr"); - b.GlobalVar(sym, DataType::AST(b), type::AddressSpace::kPrivate); + b.GlobalVar(sym, DataType::AST(b), builtin::AddressSpace::kPrivate); return b.AddressOf(sym); } diff --git a/src/tint/resolver/root_identifier_test.cc b/src/tint/resolver/root_identifier_test.cc index 4f4a42067e..0353ff53e3 100644 --- a/src/tint/resolver/root_identifier_test.cc +++ b/src/tint/resolver/root_identifier_test.cc @@ -27,7 +27,7 @@ namespace { class ResolverRootIdentifierTest : public ResolverTest {}; TEST_F(ResolverRootIdentifierTest, GlobalPrivateVar) { - auto* a = GlobalVar("a", ty.f32(), type::AddressSpace::kPrivate); + auto* a = GlobalVar("a", ty.f32(), builtin::AddressSpace::kPrivate); auto* expr = Expr(a); WrapInFunction(expr); @@ -38,7 +38,7 @@ TEST_F(ResolverRootIdentifierTest, GlobalPrivateVar) { } TEST_F(ResolverRootIdentifierTest, GlobalWorkgroupVar) { - auto* a = GlobalVar("a", ty.f32(), type::AddressSpace::kWorkgroup); + auto* a = GlobalVar("a", ty.f32(), builtin::AddressSpace::kWorkgroup); auto* expr = Expr(a); WrapInFunction(expr); @@ -49,7 +49,7 @@ TEST_F(ResolverRootIdentifierTest, GlobalWorkgroupVar) { } TEST_F(ResolverRootIdentifierTest, GlobalStorageVar) { - auto* a = GlobalVar("a", ty.f32(), type::AddressSpace::kStorage, Group(0_a), Binding(0_a)); + auto* a = GlobalVar("a", ty.f32(), builtin::AddressSpace::kStorage, Group(0_a), Binding(0_a)); auto* expr = Expr(a); WrapInFunction(expr); @@ -60,7 +60,7 @@ TEST_F(ResolverRootIdentifierTest, GlobalStorageVar) { } TEST_F(ResolverRootIdentifierTest, GlobalUniformVar) { - auto* a = GlobalVar("a", ty.f32(), type::AddressSpace::kUniform, Group(0_a), Binding(0_a)); + auto* a = GlobalVar("a", ty.f32(), builtin::AddressSpace::kUniform, Group(0_a), Binding(0_a)); auto* expr = Expr(a); WrapInFunction(expr); @@ -72,7 +72,7 @@ TEST_F(ResolverRootIdentifierTest, GlobalUniformVar) { TEST_F(ResolverRootIdentifierTest, GlobalTextureVar) { auto* a = GlobalVar("a", ty.sampled_texture(type::TextureDimension::k2d, ty.f32()), - type::AddressSpace::kUndefined, Group(0_a), Binding(0_a)); + builtin::AddressSpace::kUndefined, Group(0_a), Binding(0_a)); auto* expr = Expr(a); WrapInFunction(Call("textureDimensions", expr)); @@ -142,7 +142,7 @@ TEST_F(ResolverRootIdentifierTest, PointerParameter) { // { // let b = a; // } - auto* param = Param("a", ty.pointer(ty.f32(), type::AddressSpace::kFunction)); + auto* param = Param("a", ty.pointer(ty.f32(), builtin::AddressSpace::kFunction)); auto* expr_param = Expr(param); auto* let = Let("b", expr_param); auto* expr_let = Expr("b"); @@ -199,7 +199,7 @@ TEST_F(ResolverRootIdentifierTest, ThroughIndexAccessor) { // { // a[2i] // } - auto* a = GlobalVar("a", ty.array(), type::AddressSpace::kPrivate); + auto* a = GlobalVar("a", ty.array(), builtin::AddressSpace::kPrivate); auto* expr = IndexAccessor(a, 2_i); WrapInFunction(expr); @@ -216,7 +216,7 @@ TEST_F(ResolverRootIdentifierTest, ThroughMemberAccessor) { // a.f // } auto* S = Structure("S", utils::Vector{Member("f", ty.f32())}); - auto* a = GlobalVar("a", ty.Of(S), type::AddressSpace::kPrivate); + auto* a = GlobalVar("a", ty.Of(S), builtin::AddressSpace::kPrivate); auto* expr = MemberAccessor(a, "f"); WrapInFunction(expr); @@ -232,7 +232,7 @@ TEST_F(ResolverRootIdentifierTest, ThroughPointers) { // let a_ptr1 = &*&a; // let a_ptr2 = &*a_ptr1; // } - auto* a = GlobalVar("a", ty.f32(), type::AddressSpace::kPrivate); + auto* a = GlobalVar("a", ty.f32(), builtin::AddressSpace::kPrivate); auto* address_of_1 = AddressOf(a); auto* deref_1 = Deref(address_of_1); auto* address_of_2 = AddressOf(deref_1); diff --git a/src/tint/resolver/sem_helper.cc b/src/tint/resolver/sem_helper.cc index 1515812d05..87f506b259 100644 --- a/src/tint/resolver/sem_helper.cc +++ b/src/tint/resolver/sem_helper.cc @@ -79,7 +79,7 @@ void SemHelper::ErrorUnexpectedExprKind(const sem::Expression* expr, std::string(wanted), access->Declaration()->source); }, - [&](const sem::BuiltinEnumExpression* addr) { + [&](const sem::BuiltinEnumExpression* addr) { AddError("cannot use address space '" + utils::ToString(addr->Value()) + "' as " + std::string(wanted), addr->Declaration()->source); diff --git a/src/tint/resolver/sem_helper.h b/src/tint/resolver/sem_helper.h index a1de91be22..9aedcd1ef3 100644 --- a/src/tint/resolver/sem_helper.h +++ b/src/tint/resolver/sem_helper.h @@ -105,11 +105,11 @@ class SemHelper { /// @param expr the semantic node /// @returns nullptr if @p expr is nullptr, or @p expr cast to - /// sem::BuiltinEnumExpression if the cast is successful, otherwise an error - /// diagnostic is raised. - sem::BuiltinEnumExpression* AsAddressSpace(sem::Expression* expr) const { + /// sem::BuiltinEnumExpression if the cast is successful, otherwise an + /// error diagnostic is raised. + sem::BuiltinEnumExpression* AsAddressSpace(sem::Expression* expr) const { if (TINT_LIKELY(expr)) { - auto* enum_expr = expr->As>(); + auto* enum_expr = expr->As>(); if (TINT_LIKELY(enum_expr)) { return enum_expr; } diff --git a/src/tint/resolver/side_effects_test.cc b/src/tint/resolver/side_effects_test.cc index 90fcdb980a..88c51efe32 100644 --- a/src/tint/resolver/side_effects_test.cc +++ b/src/tint/resolver/side_effects_test.cc @@ -15,6 +15,7 @@ #include "src/tint/resolver/resolver.h" #include "gtest/gtest.h" +#include "src/tint/builtin/address_space.h" #include "src/tint/builtin/extension.h" #include "src/tint/resolver/resolver_test_helper.h" #include "src/tint/sem/index_accessor_expression.h" @@ -32,7 +33,7 @@ struct SideEffectsTest : ResolverTest { template void MakeSideEffectFunc(const char* name) { auto global = Sym(); - GlobalVar(global, ty.Of(), type::AddressSpace::kPrivate); + GlobalVar(global, ty.Of(), builtin::AddressSpace::kPrivate); auto local = Sym(); Func(name, utils::Empty, ty.Of(), utils::Vector{ @@ -45,7 +46,7 @@ struct SideEffectsTest : ResolverTest { template void MakeSideEffectFunc(const char* name, MAKE_TYPE_FUNC make_type) { auto global = Sym(); - GlobalVar(global, make_type(), type::AddressSpace::kPrivate); + GlobalVar(global, make_type(), builtin::AddressSpace::kPrivate); auto local = Sym(); Func(name, utils::Empty, make_type(), utils::Vector{ @@ -90,7 +91,7 @@ TEST_F(SideEffectsTest, VariableUser) { } TEST_F(SideEffectsTest, Call_Builtin_NoSE) { - GlobalVar("a", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("a", ty.f32(), builtin::AddressSpace::kPrivate); auto* expr = Call("dpdx", "a"); Func("f", utils::Empty, ty.void_(), utils::Vector{Ignore(expr)}, utils::Vector{create(ast::PipelineStage::kFragment)}); @@ -116,7 +117,7 @@ TEST_F(SideEffectsTest, Call_Builtin_NoSE_WithSEArg) { } TEST_F(SideEffectsTest, Call_Builtin_SE) { - GlobalVar("a", ty.atomic(ty.i32()), type::AddressSpace::kWorkgroup); + GlobalVar("a", ty.atomic(ty.i32()), builtin::AddressSpace::kWorkgroup); auto* expr = Call("atomicAdd", AddressOf("a"), 1_i); WrapInFunction(expr); @@ -165,21 +166,21 @@ TEST_P(SideEffectsBuiltinTest, Test) { auto& c = GetParam(); uint32_t next_binding = 0; - GlobalVar("f", ty.f32(), type::AddressSpace::kPrivate); - GlobalVar("i", ty.i32(), type::AddressSpace::kPrivate); - GlobalVar("u", ty.u32(), type::AddressSpace::kPrivate); - GlobalVar("b", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("vf", ty.vec3(), type::AddressSpace::kPrivate); - GlobalVar("vf2", ty.vec2(), type::AddressSpace::kPrivate); - GlobalVar("vi2", ty.vec2(), type::AddressSpace::kPrivate); - GlobalVar("vf4", ty.vec4(), type::AddressSpace::kPrivate); - GlobalVar("vb", ty.vec3(), type::AddressSpace::kPrivate); - GlobalVar("m", ty.mat3x3(), type::AddressSpace::kPrivate); - GlobalVar("arr", ty.array(), type::AddressSpace::kPrivate); - GlobalVar("storage_arr", ty.array(), type::AddressSpace::kStorage, Group(0_a), + GlobalVar("f", ty.f32(), tint::builtin::AddressSpace::kPrivate); + GlobalVar("i", ty.i32(), tint::builtin::AddressSpace::kPrivate); + GlobalVar("u", ty.u32(), tint::builtin::AddressSpace::kPrivate); + GlobalVar("b", ty.bool_(), tint::builtin::AddressSpace::kPrivate); + GlobalVar("vf", ty.vec3(), tint::builtin::AddressSpace::kPrivate); + GlobalVar("vf2", ty.vec2(), tint::builtin::AddressSpace::kPrivate); + GlobalVar("vi2", ty.vec2(), tint::builtin::AddressSpace::kPrivate); + GlobalVar("vf4", ty.vec4(), tint::builtin::AddressSpace::kPrivate); + GlobalVar("vb", ty.vec3(), tint::builtin::AddressSpace::kPrivate); + GlobalVar("m", ty.mat3x3(), tint::builtin::AddressSpace::kPrivate); + GlobalVar("arr", ty.array(), tint::builtin::AddressSpace::kPrivate); + GlobalVar("storage_arr", ty.array(), tint::builtin::AddressSpace::kStorage, Group(0_a), Binding(AInt(next_binding++))); - GlobalVar("workgroup_arr", ty.array(), type::AddressSpace::kWorkgroup); - GlobalVar("a", ty.atomic(ty.i32()), type::AddressSpace::kStorage, + GlobalVar("workgroup_arr", ty.array(), tint::builtin::AddressSpace::kWorkgroup); + GlobalVar("a", ty.atomic(ty.i32()), tint::builtin::AddressSpace::kStorage, tint::builtin::Access::kReadWrite, Group(0_a), Binding(AInt(next_binding++))); if (c.pipeline_stage != ast::PipelineStage::kCompute) { GlobalVar("t2d", ty.sampled_texture(type::TextureDimension::k2d, ty.f32()), Group(0_a), diff --git a/src/tint/resolver/struct_address_space_use_test.cc b/src/tint/resolver/struct_address_space_use_test.cc index 1b42e75522..aeb5c31f98 100644 --- a/src/tint/resolver/struct_address_space_use_test.cc +++ b/src/tint/resolver/struct_address_space_use_test.cc @@ -46,7 +46,7 @@ TEST_F(ResolverAddressSpaceUseTest, StructReachableFromParameter) { auto* sem = TypeOf(s)->As(); ASSERT_NE(sem, nullptr); - EXPECT_THAT(sem->AddressSpaceUsage(), UnorderedElementsAre(type::AddressSpace::kUndefined)); + EXPECT_THAT(sem->AddressSpaceUsage(), UnorderedElementsAre(builtin::AddressSpace::kUndefined)); } TEST_F(ResolverAddressSpaceUseTest, StructReachableFromReturnType) { @@ -58,55 +58,55 @@ TEST_F(ResolverAddressSpaceUseTest, StructReachableFromReturnType) { auto* sem = TypeOf(s)->As(); ASSERT_NE(sem, nullptr); - EXPECT_THAT(sem->AddressSpaceUsage(), UnorderedElementsAre(type::AddressSpace::kUndefined)); + EXPECT_THAT(sem->AddressSpaceUsage(), UnorderedElementsAre(builtin::AddressSpace::kUndefined)); } TEST_F(ResolverAddressSpaceUseTest, StructReachableFromGlobal) { auto* s = Structure("S", utils::Vector{Member("a", ty.f32())}); - GlobalVar("g", ty.Of(s), type::AddressSpace::kPrivate); + GlobalVar("g", ty.Of(s), builtin::AddressSpace::kPrivate); ASSERT_TRUE(r()->Resolve()) << r()->error(); auto* sem = TypeOf(s)->As(); ASSERT_NE(sem, nullptr); - EXPECT_THAT(sem->AddressSpaceUsage(), UnorderedElementsAre(type::AddressSpace::kPrivate)); + EXPECT_THAT(sem->AddressSpaceUsage(), UnorderedElementsAre(builtin::AddressSpace::kPrivate)); } TEST_F(ResolverAddressSpaceUseTest, StructReachableViaGlobalAlias) { auto* s = Structure("S", utils::Vector{Member("a", ty.f32())}); auto* a = Alias("A", ty.Of(s)); - GlobalVar("g", ty.Of(a), type::AddressSpace::kPrivate); + GlobalVar("g", ty.Of(a), builtin::AddressSpace::kPrivate); ASSERT_TRUE(r()->Resolve()) << r()->error(); auto* sem = TypeOf(s)->As(); ASSERT_NE(sem, nullptr); - EXPECT_THAT(sem->AddressSpaceUsage(), UnorderedElementsAre(type::AddressSpace::kPrivate)); + EXPECT_THAT(sem->AddressSpaceUsage(), UnorderedElementsAre(builtin::AddressSpace::kPrivate)); } TEST_F(ResolverAddressSpaceUseTest, StructReachableViaGlobalStruct) { auto* s = Structure("S", utils::Vector{Member("a", ty.f32())}); auto* o = Structure("O", utils::Vector{Member("a", ty.Of(s))}); - GlobalVar("g", ty.Of(o), type::AddressSpace::kPrivate); + GlobalVar("g", ty.Of(o), builtin::AddressSpace::kPrivate); ASSERT_TRUE(r()->Resolve()) << r()->error(); auto* sem = TypeOf(s)->As(); ASSERT_NE(sem, nullptr); - EXPECT_THAT(sem->AddressSpaceUsage(), UnorderedElementsAre(type::AddressSpace::kPrivate)); + EXPECT_THAT(sem->AddressSpaceUsage(), UnorderedElementsAre(builtin::AddressSpace::kPrivate)); } TEST_F(ResolverAddressSpaceUseTest, StructReachableViaGlobalArray) { auto* s = Structure("S", utils::Vector{Member("a", ty.f32())}); auto a = ty.array(ty.Of(s), 3_u); - GlobalVar("g", a, type::AddressSpace::kPrivate); + GlobalVar("g", a, builtin::AddressSpace::kPrivate); ASSERT_TRUE(r()->Resolve()) << r()->error(); auto* sem = TypeOf(s)->As(); ASSERT_NE(sem, nullptr); - EXPECT_THAT(sem->AddressSpaceUsage(), UnorderedElementsAre(type::AddressSpace::kPrivate)); + EXPECT_THAT(sem->AddressSpaceUsage(), UnorderedElementsAre(builtin::AddressSpace::kPrivate)); } TEST_F(ResolverAddressSpaceUseTest, StructReachableFromLocal) { @@ -118,7 +118,7 @@ TEST_F(ResolverAddressSpaceUseTest, StructReachableFromLocal) { auto* sem = TypeOf(s)->As(); ASSERT_NE(sem, nullptr); - EXPECT_THAT(sem->AddressSpaceUsage(), UnorderedElementsAre(type::AddressSpace::kFunction)); + EXPECT_THAT(sem->AddressSpaceUsage(), UnorderedElementsAre(builtin::AddressSpace::kFunction)); } TEST_F(ResolverAddressSpaceUseTest, StructReachableViaLocalAlias) { @@ -130,7 +130,7 @@ TEST_F(ResolverAddressSpaceUseTest, StructReachableViaLocalAlias) { auto* sem = TypeOf(s)->As(); ASSERT_NE(sem, nullptr); - EXPECT_THAT(sem->AddressSpaceUsage(), UnorderedElementsAre(type::AddressSpace::kFunction)); + EXPECT_THAT(sem->AddressSpaceUsage(), UnorderedElementsAre(builtin::AddressSpace::kFunction)); } TEST_F(ResolverAddressSpaceUseTest, StructReachableViaLocalStruct) { @@ -142,7 +142,7 @@ TEST_F(ResolverAddressSpaceUseTest, StructReachableViaLocalStruct) { auto* sem = TypeOf(s)->As(); ASSERT_NE(sem, nullptr); - EXPECT_THAT(sem->AddressSpaceUsage(), UnorderedElementsAre(type::AddressSpace::kFunction)); + EXPECT_THAT(sem->AddressSpaceUsage(), UnorderedElementsAre(builtin::AddressSpace::kFunction)); } TEST_F(ResolverAddressSpaceUseTest, StructReachableViaLocalArray) { @@ -154,13 +154,13 @@ TEST_F(ResolverAddressSpaceUseTest, StructReachableViaLocalArray) { auto* sem = TypeOf(s)->As(); ASSERT_NE(sem, nullptr); - EXPECT_THAT(sem->AddressSpaceUsage(), UnorderedElementsAre(type::AddressSpace::kFunction)); + EXPECT_THAT(sem->AddressSpaceUsage(), UnorderedElementsAre(builtin::AddressSpace::kFunction)); } TEST_F(ResolverAddressSpaceUseTest, StructMultipleAddressSpaceUses) { auto* s = Structure("S", utils::Vector{Member("a", ty.f32())}); - GlobalVar("x", ty.Of(s), type::AddressSpace::kUniform, Binding(0_a), Group(0_a)); - GlobalVar("y", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), + GlobalVar("x", ty.Of(s), builtin::AddressSpace::kUniform, Binding(0_a), Group(0_a)); + GlobalVar("y", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), Group(0_a)); WrapInFunction(Var("g", ty.Of(s))); @@ -168,9 +168,9 @@ TEST_F(ResolverAddressSpaceUseTest, StructMultipleAddressSpaceUses) { auto* sem = TypeOf(s)->As(); ASSERT_NE(sem, nullptr); - EXPECT_THAT(sem->AddressSpaceUsage(), - UnorderedElementsAre(type::AddressSpace::kUniform, type::AddressSpace::kStorage, - type::AddressSpace::kFunction)); + EXPECT_THAT(sem->AddressSpaceUsage(), UnorderedElementsAre(builtin::AddressSpace::kUniform, + builtin::AddressSpace::kStorage, + builtin::AddressSpace::kFunction)); } } // namespace diff --git a/src/tint/resolver/type_initializer_validation_test.cc b/src/tint/resolver/type_initializer_validation_test.cc index f269aa2413..10d6ae4f90 100644 --- a/src/tint/resolver/type_initializer_validation_test.cc +++ b/src/tint/resolver/type_initializer_validation_test.cc @@ -70,11 +70,11 @@ TEST_F(ResolverTypeInitializerValidationTest, InferTypeTest_Simple) { ASSERT_TRUE(TypeOf(a_ident)->Is()); EXPECT_TRUE(TypeOf(a_ident)->As()->StoreType()->Is()); EXPECT_EQ(TypeOf(a_ident)->As()->AddressSpace(), - type::AddressSpace::kFunction); + builtin::AddressSpace::kFunction); ASSERT_TRUE(TypeOf(b_ident)->Is()); EXPECT_TRUE(TypeOf(b_ident)->As()->StoreType()->Is()); EXPECT_EQ(TypeOf(b_ident)->As()->AddressSpace(), - type::AddressSpace::kFunction); + builtin::AddressSpace::kFunction); } using InferTypeTest_FromInitializerExpression = ResolverTestWithParam; @@ -98,7 +98,7 @@ TEST_P(InferTypeTest_FromInitializerExpression, All) { ASSERT_TRUE(r()->Resolve()) << r()->error(); auto* got = TypeOf(a_ident); auto* expected = - create(params.create_rhs_sem_type(*this), type::AddressSpace::kFunction, + create(params.create_rhs_sem_type(*this), builtin::AddressSpace::kFunction, builtin::Access::kReadWrite); ASSERT_EQ(got, expected) << "got: " << FriendlyName(got) << "\n" << "expected: " << FriendlyName(expected) << "\n"; @@ -153,7 +153,7 @@ TEST_P(InferTypeTest_FromArithmeticExpression, All) { ASSERT_TRUE(r()->Resolve()) << r()->error(); auto* got = TypeOf(a_ident); auto* expected = - create(params.create_rhs_sem_type(*this), type::AddressSpace::kFunction, + create(params.create_rhs_sem_type(*this), builtin::AddressSpace::kFunction, builtin::Access::kReadWrite); ASSERT_EQ(got, expected) << "got: " << FriendlyName(got) << "\n" << "expected: " << FriendlyName(expected) << "\n"; @@ -202,7 +202,7 @@ TEST_P(InferTypeTest_FromCallExpression, All) { ASSERT_TRUE(r()->Resolve()) << r()->error(); auto* got = TypeOf(a_ident); auto* expected = - create(params.create_rhs_sem_type(*this), type::AddressSpace::kFunction, + create(params.create_rhs_sem_type(*this), builtin::AddressSpace::kFunction, builtin::Access::kReadWrite); ASSERT_EQ(got, expected) << "got: " << FriendlyName(got) << "\n" << "expected: " << FriendlyName(expected) << "\n"; @@ -1971,7 +1971,7 @@ TEST_F(ResolverTypeInitializerValidationTest, NestedVectorInitializers_Success) TEST_F(ResolverTypeInitializerValidationTest, Vector_Alias_Argument_Error) { auto* alias = Alias("UnsignedInt", ty.u32()); - GlobalVar("uint_var", ty.Of(alias), type::AddressSpace::kPrivate); + GlobalVar("uint_var", ty.Of(alias), builtin::AddressSpace::kPrivate); auto* tc = vec2(Source{{12, 34}}, "uint_var"); WrapInFunction(tc); @@ -1983,8 +1983,8 @@ TEST_F(ResolverTypeInitializerValidationTest, Vector_Alias_Argument_Error) { TEST_F(ResolverTypeInitializerValidationTest, Vector_Alias_Argument_Success) { auto* f32_alias = Alias("Float32", ty.f32()); auto* vec2_alias = Alias("VectorFloat2", ty.vec2()); - GlobalVar("my_f32", ty.Of(f32_alias), type::AddressSpace::kPrivate); - GlobalVar("my_vec2", ty.Of(vec2_alias), type::AddressSpace::kPrivate); + GlobalVar("my_f32", ty.Of(f32_alias), builtin::AddressSpace::kPrivate); + GlobalVar("my_vec2", ty.Of(vec2_alias), builtin::AddressSpace::kPrivate); auto* tc = vec3("my_vec2", "my_f32"); WrapInFunction(tc); diff --git a/src/tint/resolver/type_validation_test.cc b/src/tint/resolver/type_validation_test.cc index 8559b9a143..5e46134e55 100644 --- a/src/tint/resolver/type_validation_test.cc +++ b/src/tint/resolver/type_validation_test.cc @@ -95,7 +95,7 @@ TEST_F(ResolverTypeValidationTest, GlobalOverrideNoInitializer_Pass) { TEST_F(ResolverTypeValidationTest, GlobalVariableWithAddressSpace_Pass) { // var global_var: f32; - GlobalVar(Source{{12, 34}}, "global_var", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar(Source{{12, 34}}, "global_var", ty.f32(), builtin::AddressSpace::kPrivate); EXPECT_TRUE(r()->Resolve()) << r()->error(); } @@ -111,9 +111,10 @@ TEST_F(ResolverTypeValidationTest, GlobalVariableUnique_Pass) { // var global_var0 : f32 = 0.1; // var global_var1 : i32 = 0; - GlobalVar("global_var0", ty.f32(), type::AddressSpace::kPrivate, Expr(0.1_f)); + GlobalVar("global_var0", ty.f32(), builtin::AddressSpace::kPrivate, Expr(0.1_f)); - GlobalVar(Source{{12, 34}}, "global_var1", ty.f32(), type::AddressSpace::kPrivate, Expr(1_f)); + GlobalVar(Source{{12, 34}}, "global_var1", ty.f32(), builtin::AddressSpace::kPrivate, + Expr(1_f)); EXPECT_TRUE(r()->Resolve()) << r()->error(); } @@ -129,7 +130,7 @@ TEST_F(ResolverTypeValidationTest, GlobalVariableFunctionVariableNotUnique_Pass) Decl(Var("a", ty.f32(), Expr(2_f))), }); - GlobalVar("a", ty.f32(), type::AddressSpace::kPrivate, Expr(2.1_f)); + GlobalVar("a", ty.f32(), builtin::AddressSpace::kPrivate, Expr(2.1_f)); EXPECT_TRUE(r()->Resolve()) << r()->error(); } @@ -193,19 +194,22 @@ TEST_F(ResolverTypeValidationTest, RedeclaredIdentifierDifferentFunctions_Pass) TEST_F(ResolverTypeValidationTest, ArraySize_AIntLiteral_Pass) { // var a : array; - GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 4_a)), type::AddressSpace::kPrivate); + GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 4_a)), + builtin::AddressSpace::kPrivate); EXPECT_TRUE(r()->Resolve()) << r()->error(); } TEST_F(ResolverTypeValidationTest, ArraySize_UnsignedLiteral_Pass) { // var a : array; - GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 4_u)), type::AddressSpace::kPrivate); + GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 4_u)), + builtin::AddressSpace::kPrivate); EXPECT_TRUE(r()->Resolve()) << r()->error(); } TEST_F(ResolverTypeValidationTest, ArraySize_SignedLiteral_Pass) { // var a : array; - GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 4_i)), type::AddressSpace::kPrivate); + GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 4_i)), + builtin::AddressSpace::kPrivate); EXPECT_TRUE(r()->Resolve()) << r()->error(); } @@ -214,7 +218,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_UnsignedConst_Pass) { // var a : array; GlobalConst("size", Expr(4_u)); GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), - type::AddressSpace::kPrivate); + builtin::AddressSpace::kPrivate); EXPECT_TRUE(r()->Resolve()) << r()->error(); } @@ -223,34 +227,38 @@ TEST_F(ResolverTypeValidationTest, ArraySize_SignedConst_Pass) { // var a : array; GlobalConst("size", Expr(4_i)); GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), - type::AddressSpace::kPrivate); + builtin::AddressSpace::kPrivate); EXPECT_TRUE(r()->Resolve()) << r()->error(); } TEST_F(ResolverTypeValidationTest, ArraySize_AIntLiteral_Zero) { // var a : array; - GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 0_a)), type::AddressSpace::kPrivate); + GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 0_a)), + builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), "12:34 error: array count (0) must be greater than 0"); } TEST_F(ResolverTypeValidationTest, ArraySize_UnsignedLiteral_Zero) { // var a : array; - GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 0_u)), type::AddressSpace::kPrivate); + GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 0_u)), + builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), "12:34 error: array count (0) must be greater than 0"); } TEST_F(ResolverTypeValidationTest, ArraySize_SignedLiteral_Zero) { // var a : array; - GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 0_i)), type::AddressSpace::kPrivate); + GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 0_i)), + builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), "12:34 error: array count (0) must be greater than 0"); } TEST_F(ResolverTypeValidationTest, ArraySize_SignedLiteral_Negative) { // var a : array; - GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, -10_i)), type::AddressSpace::kPrivate); + GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, -10_i)), + builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), "12:34 error: array count (-10) must be greater than 0"); } @@ -260,7 +268,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_UnsignedConst_Zero) { // var a : array; GlobalConst("size", Expr(0_u)); GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), - type::AddressSpace::kPrivate); + builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), "12:34 error: array count (0) must be greater than 0"); } @@ -270,7 +278,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_SignedConst_Zero) { // var a : array; GlobalConst("size", Expr(0_i)); GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), - type::AddressSpace::kPrivate); + builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), "12:34 error: array count (0) must be greater than 0"); } @@ -280,14 +288,15 @@ TEST_F(ResolverTypeValidationTest, ArraySize_SignedConst_Negative) { // var a : array; GlobalConst("size", Expr(-10_i)); GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), - type::AddressSpace::kPrivate); + builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), "12:34 error: array count (-10) must be greater than 0"); } TEST_F(ResolverTypeValidationTest, ArraySize_FloatLiteral) { // var a : array; - GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 10_f)), type::AddressSpace::kPrivate); + GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 10_f)), + builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ( r()->error(), @@ -298,7 +307,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_FloatLiteral) { TEST_F(ResolverTypeValidationTest, ArraySize_IVecLiteral) { // var a : array(10, 10)>; GlobalVar("a", ty.array(ty.f32(), Call(Source{{12, 34}}, ty.vec2(), 10_i, 10_i)), - type::AddressSpace::kPrivate); + builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ( r()->error(), @@ -311,7 +320,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_FloatConst) { // var a : array; GlobalConst("size", Expr(10_f)); GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), - type::AddressSpace::kPrivate); + builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ( r()->error(), @@ -324,7 +333,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_IVecConst) { // var a : array; GlobalConst("size", Call(ty.vec2(), 100_i, 100_i)); GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), - type::AddressSpace::kPrivate); + builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ( r()->error(), @@ -335,14 +344,14 @@ TEST_F(ResolverTypeValidationTest, ArraySize_IVecConst) { TEST_F(ResolverTypeValidationTest, ArraySize_UnderElementCountLimit) { // var a : array; GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 65535_a)), - type::AddressSpace::kPrivate); + builtin::AddressSpace::kPrivate); EXPECT_TRUE(r()->Resolve()) << r()->error(); } TEST_F(ResolverTypeValidationTest, ArraySize_OverElementCountLimit) { // var a : array; GlobalVar(Source{{56, 78}}, "a", ty.array(Source{{12, 34}}, ty.f32(), Expr(65536_a)), - type::AddressSpace::kPrivate); + builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), R"(12:34 error: array count (65536) must be less than 65536 56:78 note: while instantiating 'var' a)"); @@ -351,7 +360,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_OverElementCountLimit) { TEST_F(ResolverTypeValidationTest, ArraySize_StorageBufferLargeArray) { // var a : array; GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 65536_a)), - type::AddressSpace::kStorage, utils::Vector{Binding(0_u), Group(0_u)}); + builtin::AddressSpace::kStorage, utils::Vector{Binding(0_u), Group(0_u)}); EXPECT_TRUE(r()->Resolve()) << r()->error(); } @@ -362,7 +371,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_NestedStorageBufferLargeArray) { // var a : S; Structure("S", utils::Vector{Member(Source{{12, 34}}, "a", ty.array(Source{{12, 20}}, ty.f32(), 65536_a))}); - GlobalVar("a", ty(Source{{12, 30}}, "S"), type::AddressSpace::kStorage, + GlobalVar("a", ty(Source{{12, 30}}, "S"), builtin::AddressSpace::kStorage, utils::Vector{Binding(0_u), Group(0_u)}); EXPECT_TRUE(r()->Resolve()) << r()->error(); } @@ -375,7 +384,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_TooBig_ImplicitStride) { Structure("S", utils::Vector{Member(Source{{12, 34}}, "a", ty.f32(), utils::Vector{MemberOffset(800000_a)})}); GlobalVar("a", ty.array(ty(Source{{12, 30}}, "S"), Expr(Source{{12, 34}}, 65535_a)), - type::AddressSpace::kPrivate); + builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), "12:34 error: array byte size (0xc34f7cafc) must not exceed 0xffffffff bytes"); @@ -385,7 +394,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_TooBig_ExplicitStride) { // var a : @stride(8000000) array; GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 65535_a), utils::Vector{Stride(8000000)}), - type::AddressSpace::kPrivate); + builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), "12:34 error: array byte size (0x7a1185ee00) must not exceed 0xffffffff bytes"); @@ -395,7 +404,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_NamedOverride_PrivateVar) { // override size = 10i; // var a : array; Override("size", Expr(10_i)); - GlobalVar("a", ty.array(Source{{12, 34}}, ty.f32(), "size"), type::AddressSpace::kPrivate); + GlobalVar("a", ty.array(Source{{12, 34}}, ty.f32(), "size"), builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), "12:34 error: array with an 'override' element count can only be used as the store " @@ -407,7 +416,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_NamedOverride_InArray) { // var a : array, 4>; Override("size", Expr(10_i)); GlobalVar("a", ty.array(ty.array(Source{{12, 34}}, ty.f32(), "size"), 4_a), - type::AddressSpace::kWorkgroup); + builtin::AddressSpace::kWorkgroup); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), "12:34 error: array with an 'override' element count can only be used as the store " @@ -466,7 +475,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_NamedOverride_FunctionVar_Implicit) // var a = w; // } Override("size", Expr(10_i)); - GlobalVar("w", ty.array(ty.f32(), "size"), type::AddressSpace::kWorkgroup); + GlobalVar("w", ty.array(ty.f32(), "size"), builtin::AddressSpace::kWorkgroup); Func("f", utils::Empty, ty.void_(), utils::Vector{ Decl(Var("a", Expr(Source{{12, 34}}, "w"))), @@ -484,7 +493,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_NamedOverride_FunctionLet_Implicit) // let a = w; // } Override("size", Expr(10_i)); - GlobalVar("w", ty.array(ty.f32(), "size"), type::AddressSpace::kWorkgroup); + GlobalVar("w", ty.array(ty.f32(), "size"), builtin::AddressSpace::kWorkgroup); Func("f", utils::Empty, ty.void_(), utils::Vector{ Decl(Let("a", Expr(Source{{12, 34}}, "w"))), @@ -503,8 +512,8 @@ TEST_F(ResolverTypeValidationTest, ArraySize_UnnamedOverride_Equivalence) { // a = b; // } Override("size", Expr(10_i)); - GlobalVar("a", ty.array(ty.f32(), Add("size", 1_i)), type::AddressSpace::kWorkgroup); - GlobalVar("b", ty.array(ty.f32(), Add("size", 1_i)), type::AddressSpace::kWorkgroup); + GlobalVar("a", ty.array(ty.f32(), Add("size", 1_i)), builtin::AddressSpace::kWorkgroup); + GlobalVar("b", ty.array(ty.f32(), Add("size", 1_i)), builtin::AddressSpace::kWorkgroup); WrapInFunction(Assign(Source{{12, 34}}, "a", "b")); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -538,16 +547,16 @@ TEST_F(ResolverTypeValidationTest, ArraySize_Workgroup_Overridable) { // var a : array; Override("size", Expr(10_i)); GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), - type::AddressSpace::kWorkgroup); + builtin::AddressSpace::kWorkgroup); EXPECT_TRUE(r()->Resolve()) << r()->error(); } TEST_F(ResolverTypeValidationTest, ArraySize_ModuleVar) { // var size : i32 = 10i; // var a : array; - GlobalVar("size", ty.i32(), Expr(10_i), type::AddressSpace::kPrivate); + GlobalVar("size", ty.i32(), Expr(10_i), builtin::AddressSpace::kPrivate); GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), - type::AddressSpace::kPrivate); + builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), R"(12:34 error: var 'size' cannot be referenced at module-scope @@ -704,7 +713,7 @@ TEST_F(ResolverTypeValidationTest, RuntimeArrayInStructInArray) { // var a : array; Structure("Foo", utils::Vector{Member("rt", ty.array())}); - GlobalVar("v", ty.array(ty(Source{{12, 34}}, "Foo"), 4_u), type::AddressSpace::kPrivate); + GlobalVar("v", ty.array(ty(Source{{12, 34}}, "Foo"), 4_u), builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()) << r()->error(); EXPECT_EQ(r()->error(), @@ -750,7 +759,7 @@ TEST_F(ResolverTypeValidationTest, RuntimeArrayIsNotLast_Fail) { TEST_F(ResolverTypeValidationTest, RuntimeArrayAsGlobalVariable) { GlobalVar(Source{{56, 78}}, "g", ty.array(Source{{12, 34}}, ty.i32()), - type::AddressSpace::kPrivate); + builtin::AddressSpace::kPrivate); ASSERT_FALSE(r()->Resolve()); @@ -799,7 +808,7 @@ TEST_F(ResolverTypeValidationTest, PtrToRuntimeArrayAsPointerParameter_Fail) { // fn func(a : ptr>) {} auto* param = Param("a", ty.pointer(Source{{56, 78}}, ty.array(Source{{12, 34}}, ty.i32()), - type::AddressSpace::kWorkgroup)); + builtin::AddressSpace::kWorkgroup)); Func("func", utils::Vector{param}, ty.void_(), utils::Vector{ @@ -864,7 +873,7 @@ TEST_F(ResolverTypeValidationTest, AliasRuntimeArrayIsLast_Pass) { TEST_F(ResolverTypeValidationTest, ArrayOfNonStorableType) { auto tex_ty = ty.sampled_texture(Source{{12, 34}}, type::TextureDimension::k2d, ty.f32()); - GlobalVar("arr", ty.array(tex_ty, 4_i), type::AddressSpace::kPrivate); + GlobalVar("arr", ty.array(tex_ty, 4_i), builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -872,9 +881,9 @@ TEST_F(ResolverTypeValidationTest, ArrayOfNonStorableType) { } TEST_F(ResolverTypeValidationTest, ArrayOfNonStorableTypeWithStride) { - auto ptr_ty = ty.pointer(Source{{12, 34}}, type::AddressSpace::kUniform); + auto ptr_ty = ty.pointer(Source{{12, 34}}, builtin::AddressSpace::kUniform); GlobalVar("arr", ty.array(ptr_ty, 4_i, utils::Vector{Stride(16)}), - type::AddressSpace::kPrivate); + builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -1235,7 +1244,7 @@ TEST_P(ValidMatrixTypes, Okay) { ast::Type el_ty = params.elem_ty(*this); - GlobalVar("a", ty.mat(el_ty, params.columns, params.rows), type::AddressSpace::kPrivate); + GlobalVar("a", ty.mat(el_ty, params.columns, params.rows), builtin::AddressSpace::kPrivate); EXPECT_TRUE(r()->Resolve()) << r()->error(); } INSTANTIATE_TEST_SUITE_P(ResolverTypeValidationTest, @@ -1276,7 +1285,7 @@ TEST_P(InvalidMatrixElementTypes, InvalidElementType) { ast::Type el_ty = params.elem_ty(*this); GlobalVar("a", ty.mat(Source{{12, 34}}, el_ty, params.columns, params.rows), - type::AddressSpace::kPrivate); + builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), "12:34 error: matrix element type must be 'f32' or 'f16'"); } @@ -1318,7 +1327,7 @@ TEST_P(ValidVectorTypes, Okay) { Enable(builtin::Extension::kF16); - GlobalVar("a", ty.vec(params.elem_ty(*this), params.width), type::AddressSpace::kPrivate); + GlobalVar("a", ty.vec(params.elem_ty(*this), params.width), builtin::AddressSpace::kPrivate); EXPECT_TRUE(r()->Resolve()) << r()->error(); } INSTANTIATE_TEST_SUITE_P(ResolverTypeValidationTest, @@ -1353,7 +1362,7 @@ TEST_P(InvalidVectorElementTypes, InvalidElementType) { Enable(builtin::Extension::kF16); GlobalVar("a", ty.vec(Source{{12, 34}}, params.elem_ty(*this), params.width), - type::AddressSpace::kPrivate); + builtin::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), "12:34 error: vector element type must be 'bool', 'f32', 'f16', 'i32' " @@ -1450,7 +1459,7 @@ TEST_P(ResolverUntemplatedTypeUsedWithTemplateArgs, Builtin_UseWithTemplateArgs) // var v : f32; Enable(builtin::Extension::kF16); - GlobalVar("v", type::AddressSpace::kPrivate, ty(Source{{12, 34}}, GetParam(), true)); + GlobalVar("v", builtin::AddressSpace::kPrivate, ty(Source{{12, 34}}, GetParam(), true)); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), "12:34 error: type '" + std::string(GetParam()) + @@ -1464,7 +1473,7 @@ TEST_P(ResolverUntemplatedTypeUsedWithTemplateArgs, BuiltinAlias_UseWithTemplate Enable(builtin::Extension::kF16); Alias(Source{{56, 78}}, "A", ty(GetParam())); - GlobalVar("v", type::AddressSpace::kPrivate, ty(Source{{12, 34}}, "A", true)); + GlobalVar("v", builtin::AddressSpace::kPrivate, ty(Source{{12, 34}}, "A", true)); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -1517,7 +1526,7 @@ TEST_F(ResolverUntemplatedTypeUsedWithTemplateArgs, Struct_UseWithTemplateArgs) // var v : S; Structure(Source{{56, 78}}, "S", utils::Vector{Member("i", ty.i32())}); - GlobalVar("v", type::AddressSpace::kPrivate, ty(Source{{12, 34}}, "S", true)); + GlobalVar("v", builtin::AddressSpace::kPrivate, ty(Source{{12, 34}}, "S", true)); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), diff --git a/src/tint/resolver/uniformity.cc b/src/tint/resolver/uniformity.cc index 1fe67c8de2..35763ef3b6 100644 --- a/src/tint/resolver/uniformity.cc +++ b/src/tint/resolver/uniformity.cc @@ -1749,11 +1749,11 @@ class UniformityGraph { auto var_type = [&](const sem::Variable* var) { switch (var->AddressSpace()) { - case type::AddressSpace::kStorage: + case builtin::AddressSpace::kStorage: return "read_write storage buffer "; - case type::AddressSpace::kWorkgroup: + case builtin::AddressSpace::kWorkgroup: return "workgroup storage variable "; - case type::AddressSpace::kPrivate: + case builtin::AddressSpace::kPrivate: return "module-scope private variable "; default: return ""; diff --git a/src/tint/resolver/uniformity_test.cc b/src/tint/resolver/uniformity_test.cc index fbd091226d..26154a7bf0 100644 --- a/src/tint/resolver/uniformity_test.cc +++ b/src/tint/resolver/uniformity_test.cc @@ -5301,8 +5301,8 @@ TEST_F(UniformityAnalysisTest, MaximumNumberOfPointerParameters) { } 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(), type::AddressSpace::kFunction))); + params.Push(b.Param("p" + std::to_string(i), + ty.pointer(ty.i32(), builtin::AddressSpace::kFunction))); if (i > 0) { foo_body.Push(b.Assign(b.Deref("p" + std::to_string(i)), "rhs")); } @@ -5321,7 +5321,7 @@ TEST_F(UniformityAnalysisTest, MaximumNumberOfPointerParameters) { // workgroupBarrier(); // } // } - b.GlobalVar("non_uniform_global", ty.i32(), type::AddressSpace::kPrivate); + b.GlobalVar("non_uniform_global", ty.i32(), builtin::AddressSpace::kPrivate); utils::Vector main_body; utils::Vector args; for (int i = 0; i < 255; i++) { @@ -7847,7 +7847,7 @@ TEST_F(UniformityAnalysisTest, StressGraphTraversalDepth) { // workgroupBarrier(); // } // } - b.GlobalVar("v0", ty.i32(), type::AddressSpace::kPrivate, b.Expr(0_i)); + b.GlobalVar("v0", ty.i32(), builtin::AddressSpace::kPrivate, b.Expr(0_i)); utils::Vector foo_body; std::string v_last = "v0"; for (int i = 1; i < 100000; i++) { diff --git a/src/tint/resolver/validation_test.cc b/src/tint/resolver/validation_test.cc index 8ee795ce91..0e239dd2e6 100644 --- a/src/tint/resolver/validation_test.cc +++ b/src/tint/resolver/validation_test.cc @@ -62,8 +62,8 @@ class FakeExpr final : public Castable { }; TEST_F(ResolverValidationTest, WorkgroupMemoryUsedInVertexStage) { - GlobalVar(Source{{1, 2}}, "wg", ty.vec4(), type::AddressSpace::kWorkgroup); - GlobalVar("dst", ty.vec4(), type::AddressSpace::kPrivate); + GlobalVar(Source{{1, 2}}, "wg", ty.vec4(), builtin::AddressSpace::kWorkgroup); + GlobalVar("dst", ty.vec4(), builtin::AddressSpace::kPrivate); auto* stmt = Assign(Expr("dst"), Expr(Source{{3, 4}}, "wg")); Func(Source{{9, 10}}, "f0", utils::Empty, ty.vec4(), @@ -94,8 +94,8 @@ TEST_F(ResolverValidationTest, WorkgroupMemoryUsedInFragmentStage) { // f1(); //} - GlobalVar(Source{{1, 2}}, "wg", ty.vec4(), type::AddressSpace::kWorkgroup); - GlobalVar("dst", ty.vec4(), type::AddressSpace::kPrivate); + GlobalVar(Source{{1, 2}}, "wg", ty.vec4(), builtin::AddressSpace::kWorkgroup); + GlobalVar("dst", ty.vec4(), builtin::AddressSpace::kPrivate); auto* stmt = Assign(Expr("dst"), Expr(Source{{3, 4}}, "wg")); Func(Source{{5, 6}}, "f2", utils::Empty, ty.void_(), utils::Vector{stmt}); @@ -192,7 +192,7 @@ TEST_F(ResolverValidationTest, UsingUndefinedVariableGlobalVariable_Pass) { // return; // } - GlobalVar("global_var", ty.f32(), type::AddressSpace::kPrivate, Expr(2.1_f)); + GlobalVar("global_var", ty.f32(), builtin::AddressSpace::kPrivate, Expr(2.1_f)); Func("my_func", utils::Empty, ty.void_(), utils::Vector{ @@ -266,7 +266,7 @@ TEST_F(ResolverValidationTest, UsingUndefinedVariableDifferentScope_Fail) { } TEST_F(ResolverValidationTest, AddressSpace_FunctionVariableWorkgroupClass) { - auto* var = Var("var", ty.i32(), type::AddressSpace::kWorkgroup); + auto* var = Var("var", ty.i32(), builtin::AddressSpace::kWorkgroup); Func("func", utils::Empty, ty.void_(), utils::Vector{ @@ -280,7 +280,7 @@ TEST_F(ResolverValidationTest, AddressSpace_FunctionVariableWorkgroupClass) { } TEST_F(ResolverValidationTest, AddressSpace_FunctionVariableI32) { - auto* var = Var("s", ty.i32(), type::AddressSpace::kPrivate); + auto* var = Var("s", ty.i32(), builtin::AddressSpace::kPrivate); Func("func", utils::Empty, ty.void_(), utils::Vector{ @@ -295,7 +295,8 @@ TEST_F(ResolverValidationTest, AddressSpace_FunctionVariableI32) { TEST_F(ResolverValidationTest, AddressSpace_SamplerExplicitAddressSpace) { auto t = ty.sampler(type::SamplerKind::kSampler); - GlobalVar(Source{{12, 34}}, "var", t, type::AddressSpace::kPrivate, Binding(0_a), Group(0_a)); + GlobalVar(Source{{12, 34}}, "var", t, builtin::AddressSpace::kPrivate, Binding(0_a), + Group(0_a)); EXPECT_FALSE(r()->Resolve()); @@ -305,7 +306,8 @@ TEST_F(ResolverValidationTest, AddressSpace_SamplerExplicitAddressSpace) { TEST_F(ResolverValidationTest, AddressSpace_TextureExplicitAddressSpace) { auto t = ty.sampled_texture(type::TextureDimension::k1d, ty.f32()); - GlobalVar(Source{{12, 34}}, "var", t, type::AddressSpace::kFunction, Binding(0_a), Group(0_a)); + GlobalVar(Source{{12, 34}}, "var", t, builtin::AddressSpace::kFunction, Binding(0_a), + Group(0_a)); EXPECT_FALSE(r()->Resolve()) << r()->error(); @@ -315,7 +317,7 @@ TEST_F(ResolverValidationTest, AddressSpace_TextureExplicitAddressSpace) { } TEST_F(ResolverValidationTest, Expr_MemberAccessor_VectorSwizzle_BadChar) { - GlobalVar("my_vec", ty.vec3(), type::AddressSpace::kPrivate); + GlobalVar("my_vec", ty.vec3(), builtin::AddressSpace::kPrivate); auto* mem = MemberAccessor("my_vec", Ident(Source{{{3, 3}, {3, 7}}}, "xyqz")); WrapInFunction(mem); @@ -325,7 +327,7 @@ TEST_F(ResolverValidationTest, Expr_MemberAccessor_VectorSwizzle_BadChar) { } TEST_F(ResolverValidationTest, Expr_MemberAccessor_VectorSwizzle_MixedChars) { - GlobalVar("my_vec", ty.vec4(), type::AddressSpace::kPrivate); + GlobalVar("my_vec", ty.vec4(), builtin::AddressSpace::kPrivate); auto* mem = MemberAccessor("my_vec", Ident(Source{{{3, 3}, {3, 7}}}, "rgyw")); WrapInFunction(mem); @@ -336,7 +338,7 @@ TEST_F(ResolverValidationTest, Expr_MemberAccessor_VectorSwizzle_MixedChars) { } TEST_F(ResolverValidationTest, Expr_MemberAccessor_VectorSwizzle_BadLength) { - GlobalVar("my_vec", ty.vec3(), type::AddressSpace::kPrivate); + GlobalVar("my_vec", ty.vec3(), builtin::AddressSpace::kPrivate); auto* mem = MemberAccessor("my_vec", Ident(Source{{{3, 3}, {3, 8}}}, "zzzzz")); WrapInFunction(mem); @@ -346,7 +348,7 @@ TEST_F(ResolverValidationTest, Expr_MemberAccessor_VectorSwizzle_BadLength) { } TEST_F(ResolverValidationTest, Expr_MemberAccessor_VectorSwizzle_BadIndex) { - GlobalVar("my_vec", ty.vec2(), type::AddressSpace::kPrivate); + GlobalVar("my_vec", ty.vec2(), builtin::AddressSpace::kPrivate); auto* mem = MemberAccessor("my_vec", Ident(Source{{3, 3}}, "z")); WrapInFunction(mem); @@ -377,7 +379,7 @@ TEST_F(ResolverValidationTest, EXpr_MemberAccessor_FuncGoodParent) { // let x: f32 = (*p).z; // return x; // } - auto* p = Param("p", ty.pointer(ty.vec4(), type::AddressSpace::kFunction)); + auto* p = Param("p", ty.pointer(ty.vec4(), builtin::AddressSpace::kFunction)); auto* star_p = Deref(p); auto* accessor_expr = MemberAccessor(star_p, "z"); auto* x = Var("x", ty.f32(), accessor_expr); @@ -394,7 +396,7 @@ TEST_F(ResolverValidationTest, EXpr_MemberAccessor_FuncBadParent) { // let x: f32 = *p.z; // return x; // } - auto* p = Param("p", ty.pointer(ty.vec4(), type::AddressSpace::kFunction)); + auto* p = Param("p", ty.pointer(ty.vec4(), builtin::AddressSpace::kFunction)); auto* accessor_expr = MemberAccessor(p, Ident(Source{{12, 34}}, "z")); auto* star_p = Deref(accessor_expr); auto* x = Var("x", ty.f32(), star_p); @@ -1231,8 +1233,9 @@ TEST_F(ResolverValidationTest, OffsetAndAlignAndSizeAttribute) { TEST_F(ResolverTest, Expr_Initializer_Cast_Pointer) { auto* vf = Var("vf", ty.f32()); - auto* c = Call(Source{{12, 34}}, ty.pointer(type::AddressSpace::kFunction), ExprList(vf)); - auto* ip = Let("ip", ty.pointer(type::AddressSpace::kFunction), c); + auto* c = + Call(Source{{12, 34}}, ty.pointer(builtin::AddressSpace::kFunction), ExprList(vf)); + auto* ip = Let("ip", ty.pointer(builtin::AddressSpace::kFunction), c); WrapInFunction(Decl(vf), Decl(ip)); EXPECT_FALSE(r()->Resolve()); @@ -1240,21 +1243,22 @@ TEST_F(ResolverTest, Expr_Initializer_Cast_Pointer) { } TEST_F(ResolverTest, I32_Overflow) { - GlobalVar("v", ty.i32(), type::AddressSpace::kPrivate, Expr(Source{{12, 24}}, 2147483648_a)); + GlobalVar("v", ty.i32(), builtin::AddressSpace::kPrivate, Expr(Source{{12, 24}}, 2147483648_a)); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), R"(12:24 error: value 2147483648 cannot be represented as 'i32')"); } TEST_F(ResolverTest, I32_Underflow) { - GlobalVar("v", ty.i32(), type::AddressSpace::kPrivate, Expr(Source{{12, 24}}, -2147483649_a)); + GlobalVar("v", ty.i32(), builtin::AddressSpace::kPrivate, + Expr(Source{{12, 24}}, -2147483649_a)); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), R"(12:24 error: value -2147483649 cannot be represented as 'i32')"); } TEST_F(ResolverTest, U32_Overflow) { - GlobalVar("v", ty.u32(), type::AddressSpace::kPrivate, Expr(Source{{12, 24}}, 4294967296_a)); + GlobalVar("v", ty.u32(), builtin::AddressSpace::kPrivate, Expr(Source{{12, 24}}, 4294967296_a)); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), R"(12:24 error: value 4294967296 cannot be represented as 'u32')"); diff --git a/src/tint/resolver/validator.cc b/src/tint/resolver/validator.cc index c7f790be90..242a462c52 100644 --- a/src/tint/resolver/validator.cc +++ b/src/tint/resolver/validator.cc @@ -288,7 +288,7 @@ bool Validator::Atomic(const ast::TemplatedIdentifier* a, const type::Atomic* s) } bool Validator::Pointer(const ast::TemplatedIdentifier* a, const type::Pointer* s) const { - if (s->AddressSpace() == type::AddressSpace::kUndefined) { + if (s->AddressSpace() == builtin::AddressSpace::kUndefined) { AddError("ptr missing address space", a->source); return false; } @@ -298,7 +298,7 @@ bool Validator::Pointer(const ast::TemplatedIdentifier* a, const type::Pointer* // When writing a variable declaration or a pointer type in WGSL source: // * For the storage address space, the access mode is optional, and defaults to read. // * For other address spaces, the access mode must not be written. - if (s->AddressSpace() != type::AddressSpace::kStorage) { + if (s->AddressSpace() != builtin::AddressSpace::kStorage) { AddError("only pointers in address space may specify an access mode", a->source); return false; @@ -373,7 +373,7 @@ bool Validator::Materialize(const type::Type* to, } bool Validator::VariableInitializer(const ast::Variable* v, - type::AddressSpace address_space, + builtin::AddressSpace address_space, const type::Type* storage_ty, const sem::ValueExpression* initializer) const { auto* initializer_ty = initializer->Type(); @@ -390,8 +390,8 @@ bool Validator::VariableInitializer(const ast::Variable* v, if (v->Is()) { switch (address_space) { - case type::AddressSpace::kPrivate: - case type::AddressSpace::kFunction: + case builtin::AddressSpace::kPrivate: + case builtin::AddressSpace::kFunction: break; // Allowed an initializer default: // https://gpuweb.github.io/gpuweb/wgsl/#var-and-let @@ -409,17 +409,17 @@ bool Validator::VariableInitializer(const ast::Variable* v, } bool Validator::AddressSpaceLayout(const type::Type* store_ty, - type::AddressSpace address_space, + builtin::AddressSpace address_space, Source source) const { // https://gpuweb.github.io/gpuweb/wgsl/#storage-class-layout-constraints auto is_uniform_struct_or_array = [address_space](const type::Type* ty) { - return address_space == type::AddressSpace::kUniform && + return address_space == builtin::AddressSpace::kUniform && ty->IsAnyOf(); }; auto is_uniform_struct = [address_space](const type::Type* ty) { - return address_space == type::AddressSpace::kUniform && ty->Is(); + return address_space == builtin::AddressSpace::kUniform && ty->Is(); }; auto required_alignment_of = [&](const type::Type* ty) { @@ -440,7 +440,7 @@ bool Validator::AddressSpaceLayout(const type::Type* store_ty, return true; } - if (!type::IsHostShareable(address_space)) { + if (!builtin::IsHostShareable(address_space)) { return true; } @@ -453,7 +453,7 @@ bool Validator::AddressSpaceLayout(const type::Type* store_ty, // Among three host-shareable address spaces, f16 is supported in "uniform" and // "storage" address space, but not "push_constant" address space yet. if (Is(type::Type::DeepestElementOf(store_ty)) && - address_space == type::AddressSpace::kPushConstant) { + address_space == builtin::AddressSpace::kPushConstant) { AddError("using f16 types in 'push_constant' address space is not implemented yet", source); return false; } @@ -530,7 +530,7 @@ bool Validator::AddressSpaceLayout(const type::Type* store_ty, return false; } - if (address_space == type::AddressSpace::kUniform) { + if (address_space == builtin::AddressSpace::kUniform) { // We already validated that this array member is itself aligned to 16 bytes above, so // we only need to validate that stride is a multiple of 16 bytes. if (arr->Stride() % 16 != 0) { @@ -596,7 +596,7 @@ bool Validator::GlobalVariable( const sem::GlobalVariable* global, const utils::Hashmap& override_ids) const { auto* decl = global->Declaration(); - if (global->AddressSpace() != type::AddressSpace::kWorkgroup && + if (global->AddressSpace() != builtin::AddressSpace::kWorkgroup && IsArrayWithOverrideCount(global->Type())) { RaiseArrayWithOverrideCountError(decl->type ? decl->type->source : decl->initializer->source); @@ -624,8 +624,8 @@ bool Validator::GlobalVariable( bool is_shader_io_attribute = attr->IsAnyOf(); - bool has_io_address_space = global->AddressSpace() == type::AddressSpace::kIn || - global->AddressSpace() == type::AddressSpace::kOut; + bool has_io_address_space = global->AddressSpace() == builtin::AddressSpace::kIn || + global->AddressSpace() == builtin::AddressSpace::kOut; if (!attr->IsAnyOf() && (!is_shader_io_attribute || !has_io_address_space)) { @@ -657,15 +657,15 @@ bool Validator::GlobalVariable( return false; } - if (global->AddressSpace() == type::AddressSpace::kFunction) { + if (global->AddressSpace() == builtin::AddressSpace::kFunction) { AddError("module-scope 'var' must not use address space 'function'", decl->source); return false; } switch (global->AddressSpace()) { - case type::AddressSpace::kUniform: - case type::AddressSpace::kStorage: - case type::AddressSpace::kHandle: { + case builtin::AddressSpace::kUniform: + case builtin::AddressSpace::kStorage: + case builtin::AddressSpace::kHandle: { // https://gpuweb.github.io/gpuweb/wgsl/#resource-interface // Each resource variable must be declared with both group and binding attributes. if (!decl->HasBindingPoint()) { @@ -714,7 +714,7 @@ bool Validator::Var(const sem::Variable* v) const { // When writing a variable declaration or a pointer type in WGSL source: // * For the storage address space, the access mode is optional, and defaults to read. // * For other address spaces, the access mode must not be written. - if (v->AddressSpace() != type::AddressSpace::kStorage) { + if (v->AddressSpace() != builtin::AddressSpace::kStorage) { AddError("only variables in address space may specify an access mode", var->source); return false; @@ -727,8 +727,8 @@ bool Validator::Var(const sem::Variable* v) const { } if (IsValidationEnabled(var->attributes, ast::DisabledValidation::kIgnoreAddressSpace) && - (v->AddressSpace() == type::AddressSpace::kIn || - v->AddressSpace() == type::AddressSpace::kOut)) { + (v->AddressSpace() == builtin::AddressSpace::kIn || + v->AddressSpace() == builtin::AddressSpace::kOut)) { AddError("invalid use of input/output address space", var->source); return false; } @@ -822,13 +822,13 @@ bool Validator::Parameter(const ast::Function* func, const sem::Variable* var) c auto sc = ref->AddressSpace(); switch (sc) { - case type::AddressSpace::kFunction: - case type::AddressSpace::kPrivate: + case builtin::AddressSpace::kFunction: + case builtin::AddressSpace::kPrivate: ok = true; break; - case type::AddressSpace::kStorage: - case type::AddressSpace::kUniform: - case type::AddressSpace::kWorkgroup: + case builtin::AddressSpace::kStorage: + case builtin::AddressSpace::kUniform: + case builtin::AddressSpace::kWorkgroup: ok = enabled_extensions_.Contains( builtin::Extension::kChromiumExperimentalFullPtrParameters); break; @@ -1883,7 +1883,7 @@ bool Validator::PipelineStages(utils::VectorRef entry_points) co auto stage = entry_point->Declaration()->PipelineStage(); if (stage != ast::PipelineStage::kCompute) { for (auto* var : func->DirectlyReferencedGlobals()) { - if (var->AddressSpace() == type::AddressSpace::kWorkgroup) { + if (var->AddressSpace() == builtin::AddressSpace::kWorkgroup) { std::stringstream stage_name; stage_name << stage; for (auto* user : var->Users()) { @@ -1969,7 +1969,7 @@ bool Validator::PushConstants(utils::VectorRef entry_points) con auto check_push_constant = [&](const sem::Function* func, const sem::Function* ep) { for (auto* var : func->DirectlyReferencedGlobals()) { - if (var->AddressSpace() != type::AddressSpace::kPushConstant || + if (var->AddressSpace() != builtin::AddressSpace::kPushConstant || var == push_constant_var) { continue; } @@ -2506,14 +2506,14 @@ std::string Validator::VectorPretty(uint32_t size, const type::Type* element_typ bool Validator::CheckTypeAccessAddressSpace( const type::Type* store_ty, builtin::Access access, - type::AddressSpace address_space, + builtin::AddressSpace address_space, utils::VectorRef attributes, const Source& source) const { if (!AddressSpaceLayout(store_ty, address_space, source)) { return false; } - if (address_space == type::AddressSpace::kPushConstant && + if (address_space == builtin::AddressSpace::kPushConstant && !enabled_extensions_.Contains(builtin::Extension::kChromiumExperimentalPushConstant) && IsValidationEnabled(attributes, ast::DisabledValidation::kIgnoreAddressSpace)) { AddError( @@ -2523,7 +2523,7 @@ bool Validator::CheckTypeAccessAddressSpace( return false; } - if (address_space == type::AddressSpace::kStorage && access == builtin::Access::kWrite) { + if (address_space == builtin::AddressSpace::kStorage && access == builtin::Access::kWrite) { // The access mode for the storage address space can only be 'read' or // 'read_write'. AddError("access mode 'write' is not valid for the 'storage' address space", source); @@ -2531,11 +2531,11 @@ bool Validator::CheckTypeAccessAddressSpace( } auto atomic_error = [&]() -> const char* { - if (address_space != type::AddressSpace::kStorage && - address_space != type::AddressSpace::kWorkgroup) { + if (address_space != builtin::AddressSpace::kStorage && + address_space != builtin::AddressSpace::kWorkgroup) { return "atomic variables must have or address space"; } - if (address_space == type::AddressSpace::kStorage && + if (address_space == builtin::AddressSpace::kStorage && access != builtin::Access::kReadWrite) { return "atomic variables in address space must have read_write access " "mode"; diff --git a/src/tint/resolver/validator.h b/src/tint/resolver/validator.h index 55be986a43..6757c06421 100644 --- a/src/tint/resolver/validator.h +++ b/src/tint/resolver/validator.h @@ -75,7 +75,7 @@ struct TypeAndAddressSpace { /// The type const type::Type* type; /// The address space - type::AddressSpace address_space; + builtin::AddressSpace address_space; /// Equality operator /// @param other the other TypeAndAddressSpace to compare this TypeAndAddressSpace to @@ -435,7 +435,7 @@ class Validator { /// @param initializer the RHS initializer expression /// @returns true on succes, false otherwise bool VariableInitializer(const ast::Variable* v, - type::AddressSpace address_space, + builtin::AddressSpace address_space, const type::Type* storage_type, const sem::ValueExpression* initializer) const; @@ -488,7 +488,7 @@ class Validator { /// @param sc the address space /// @param source the source of the type /// @returns true on success, false otherwise - bool AddressSpaceLayout(const type::Type* type, type::AddressSpace sc, Source source) const; + bool AddressSpaceLayout(const type::Type* type, builtin::AddressSpace sc, Source source) const; /// @returns true if the attribute list contains a /// ast::DisableValidationAttribute with the validation mode equal to @@ -543,7 +543,7 @@ class Validator { /// @returns true on success, false if an error was raised. bool CheckTypeAccessAddressSpace(const type::Type* store_ty, builtin::Access access, - type::AddressSpace address_space, + builtin::AddressSpace address_space, utils::VectorRef attributes, const Source& source) const; SymbolTable& symbols_; diff --git a/src/tint/resolver/validator_is_storeable_test.cc b/src/tint/resolver/validator_is_storeable_test.cc index 558953e497..d01d21c8fc 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, Matrix) { } TEST_F(ValidatorIsStorableTest, Pointer) { - auto* ptr = create(create(), type::AddressSpace::kPrivate, + auto* ptr = create(create(), builtin::AddressSpace::kPrivate, builtin::Access::kReadWrite); EXPECT_FALSE(v()->IsStorable(ptr)); } diff --git a/src/tint/resolver/variable_test.cc b/src/tint/resolver/variable_test.cc index dbfc94fc10..7af6027b44 100644 --- a/src/tint/resolver/variable_test.cc +++ b/src/tint/resolver/variable_test.cc @@ -238,7 +238,7 @@ TEST_F(ResolverVariableTest, LocalVar_ShadowsGlobalVar) { // var a = a; // } - auto* g = GlobalVar("a", ty.i32(), type::AddressSpace::kPrivate); + auto* g = GlobalVar("a", ty.i32(), builtin::AddressSpace::kPrivate); auto* v = Var("a", Expr("a")); Func("F", utils::Empty, ty.void_(), utils::Vector{Decl(v)}); @@ -421,7 +421,7 @@ TEST_F(ResolverVariableTest, LocalLet) { 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(type::AddressSpace::kFunction), p_c); + auto* p = Let("p", ty.pointer(builtin::AddressSpace::kFunction), p_c); Func("F", utils::Empty, ty.void_(), utils::Vector{ @@ -472,7 +472,7 @@ TEST_F(ResolverVariableTest, LocalLet_InheritsAccessFromOriginatingVariable) { // } auto* inner = Structure("Inner", utils::Vector{Member("arr", ty.array())}); auto* buf = Structure("S", utils::Vector{Member("inner", ty.Of(inner))}); - auto* storage = GlobalVar("s", ty.Of(buf), type::AddressSpace::kStorage, + auto* storage = GlobalVar("s", ty.Of(buf), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, Binding(0_a), Group(0_a)); auto* expr = IndexAccessor(MemberAccessor(MemberAccessor(storage, "inner"), "arr"), 3_i); @@ -554,7 +554,7 @@ TEST_F(ResolverVariableTest, LocalLet_ShadowsGlobalVar) { // let a = a; // } - auto* g = GlobalVar("a", ty.i32(), type::AddressSpace::kPrivate); + auto* g = GlobalVar("a", ty.i32(), builtin::AddressSpace::kPrivate); auto* l = Let("a", Expr("a")); Func("F", utils::Empty, ty.void_(), utils::Vector{Decl(l)}); @@ -766,7 +766,7 @@ TEST_F(ResolverVariableTest, LocalConst_ShadowsGlobalVar) { // const a = 1i; // } - auto* g = GlobalVar("a", ty.i32(), type::AddressSpace::kPrivate); + auto* g = GlobalVar("a", ty.i32(), builtin::AddressSpace::kPrivate); auto* c = Const("a", Expr(1_i)); Func("F", utils::Empty, ty.void_(), utils::Vector{Decl(c)}); @@ -1037,12 +1037,12 @@ TEST_F(ResolverVariableTest, GlobalVar_AddressSpace) { // https://gpuweb.github.io/gpuweb/wgsl/#storage-class auto* buf = Structure("S", utils::Vector{Member("m", ty.i32())}); - auto* private_ = GlobalVar("p", ty.i32(), type::AddressSpace::kPrivate); - auto* workgroup = GlobalVar("w", ty.i32(), type::AddressSpace::kWorkgroup); + auto* private_ = GlobalVar("p", ty.i32(), builtin::AddressSpace::kPrivate); + auto* workgroup = GlobalVar("w", ty.i32(), builtin::AddressSpace::kWorkgroup); auto* uniform = - GlobalVar("ub", ty.Of(buf), type::AddressSpace::kUniform, Binding(0_a), Group(0_a)); + GlobalVar("ub", ty.Of(buf), builtin::AddressSpace::kUniform, Binding(0_a), Group(0_a)); auto* storage = - GlobalVar("sb", ty.Of(buf), type::AddressSpace::kStorage, Binding(1_a), Group(0_a)); + GlobalVar("sb", ty.Of(buf), builtin::AddressSpace::kStorage, Binding(1_a), Group(0_a)); auto* handle = GlobalVar("h", ty.depth_texture(type::TextureDimension::k2d), Binding(2_a), Group(0_a)); @@ -1065,7 +1065,7 @@ TEST_F(ResolverVariableTest, GlobalVar_ExplicitAddressSpace) { // https://gpuweb.github.io/gpuweb/wgsl/#storage-class auto* buf = Structure("S", utils::Vector{Member("m", ty.i32())}); - auto* storage = GlobalVar("sb", ty.Of(buf), type::AddressSpace::kStorage, + auto* storage = GlobalVar("sb", ty.Of(buf), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, Binding(1_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -1222,7 +1222,7 @@ TEST_F(ResolverVariableTest, Param_ShadowsGlobalVar) { // fn F(a : bool) { // } - auto* g = GlobalVar("a", ty.i32(), type::AddressSpace::kPrivate); + auto* g = GlobalVar("a", ty.i32(), builtin::AddressSpace::kPrivate); auto* p = Param("a", ty.bool_()); Func("F", utils::Vector{p}, ty.void_(), utils::Empty); diff --git a/src/tint/resolver/variable_validation_test.cc b/src/tint/resolver/variable_validation_test.cc index 1d0837d141..6ca3a08665 100644 --- a/src/tint/resolver/variable_validation_test.cc +++ b/src/tint/resolver/variable_validation_test.cc @@ -61,8 +61,8 @@ TEST_F(ResolverVariableValidationTest, GlobalVarInitializerNoReturnValueBuiltin) TEST_F(ResolverVariableValidationTest, GlobalVarUsedAtModuleScope) { // var a : i32; // var b : i32 = a; - GlobalVar(Source{{12, 34}}, "a", ty.i32(), type::AddressSpace::kPrivate); - GlobalVar("b", ty.i32(), type::AddressSpace::kPrivate, Expr(Source{{56, 78}}, "a")); + GlobalVar(Source{{12, 34}}, "a", ty.i32(), builtin::AddressSpace::kPrivate); + GlobalVar("b", ty.i32(), builtin::AddressSpace::kPrivate, Expr(Source{{56, 78}}, "a")); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), R"(56:78 error: var 'a' cannot be referenced at module-scope @@ -112,8 +112,8 @@ TEST_F(ResolverVariableValidationTest, VarTypeNotConstructible) { // var i : i32; // var p : pointer = &v; auto* i = Var("i", ty.i32()); - auto* p = Var("a", ty.pointer(Source{{56, 78}}, type::AddressSpace::kFunction), - type::AddressSpace::kUndefined, AddressOf(Source{{12, 34}}, "i")); + auto* p = Var("a", ty.pointer(Source{{56, 78}}, builtin::AddressSpace::kFunction), + builtin::AddressSpace::kUndefined, AddressOf(Source{{12, 34}}, "i")); WrapInFunction(i, p); EXPECT_FALSE(r()->Resolve()); @@ -205,7 +205,7 @@ TEST_F(ResolverVariableValidationTest, VarInitializerWrongTypeViaAlias) { TEST_F(ResolverVariableValidationTest, LetOfPtrConstructedWithRef) { // var a : f32; // let b : ptr = a; - const auto priv = type::AddressSpace::kFunction; + const auto priv = builtin::AddressSpace::kFunction; auto* var_a = Var("a", ty.f32(), priv); auto* var_b = Let(Source{{12, 34}}, "b", ty.pointer(priv), Expr("a")); WrapInFunction(var_a, var_b); @@ -236,7 +236,7 @@ TEST_F(ResolverVariableValidationTest, GlobalVarRedeclaredAsLocal) { // return 0; // } - GlobalVar("v", ty.f32(), type::AddressSpace::kPrivate, Expr(2.1_f)); + GlobalVar("v", ty.f32(), builtin::AddressSpace::kPrivate, Expr(2.1_f)); WrapInFunction(Var(Source{{12, 34}}, "v", ty.f32(), Expr(2_f))); @@ -295,11 +295,11 @@ TEST_F(ResolverVariableValidationTest, InferredPtrStorageAccessMismatch) { Member("inner", ty.Of(inner)), }); auto* storage = - GlobalVar("s", ty.Of(buf), type::AddressSpace::kStorage, Binding(0_a), Group(0_a)); + GlobalVar("s", ty.Of(buf), builtin::AddressSpace::kStorage, 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(type::AddressSpace::kStorage, builtin::Access::kReadWrite), + ty.pointer(builtin::AddressSpace::kStorage, builtin::Access::kReadWrite), AddressOf(expr)); WrapInFunction(ptr); @@ -359,7 +359,7 @@ TEST_F(ResolverVariableValidationTest, NonConstructibleType_InferredType) { TEST_F(ResolverVariableValidationTest, InvalidAddressSpaceForInitializer) { // var v : f32 = 1.23; - GlobalVar(Source{{12, 34}}, "v", ty.f32(), type::AddressSpace::kWorkgroup, Expr(1.23_f)); + GlobalVar(Source{{12, 34}}, "v", ty.f32(), builtin::AddressSpace::kWorkgroup, Expr(1.23_f)); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -489,7 +489,7 @@ TEST_F(ResolverVariableValidationTest, GlobalVariable_PushConstantWithInitialize // enable chromium_experimental_push_constant; // var a : u32 = 0u; Enable(builtin::Extension::kChromiumExperimentalPushConstant); - GlobalVar(Source{{1u, 2u}}, "a", ty.u32(), type::AddressSpace::kPushConstant, + GlobalVar(Source{{1u, 2u}}, "a", ty.u32(), builtin::AddressSpace::kPushConstant, Expr(Source{{3u, 4u}}, u32(0))); ASSERT_FALSE(r()->Resolve()); diff --git a/src/tint/sem/function.cc b/src/tint/sem/function.cc index e7bf889ea2..5191c5fd54 100644 --- a/src/tint/sem/function.cc +++ b/src/tint/sem/function.cc @@ -69,7 +69,7 @@ Function::VariableBindings Function::TransitivelyReferencedUniformVariables() co VariableBindings ret; for (auto* global : TransitivelyReferencedGlobals()) { - if (global->AddressSpace() != type::AddressSpace::kUniform) { + if (global->AddressSpace() != builtin::AddressSpace::kUniform) { continue; } @@ -84,7 +84,7 @@ Function::VariableBindings Function::TransitivelyReferencedStorageBufferVariable VariableBindings ret; for (auto* global : TransitivelyReferencedGlobals()) { - if (global->AddressSpace() != type::AddressSpace::kStorage) { + if (global->AddressSpace() != builtin::AddressSpace::kStorage) { continue; } diff --git a/src/tint/sem/struct.h b/src/tint/sem/struct.h index 42a111713c..d1d20cc61a 100644 --- a/src/tint/sem/struct.h +++ b/src/tint/sem/struct.h @@ -18,8 +18,8 @@ #include #include "src/tint/ast/struct.h" +#include "src/tint/builtin/address_space.h" #include "src/tint/symbol.h" -#include "src/tint/type/address_space.h" #include "src/tint/type/struct.h" #include "src/tint/type/type.h" #include "src/tint/utils/vector.h" diff --git a/src/tint/sem/variable.cc b/src/tint/sem/variable.cc index e3f5f75268..8f8248ca31 100644 --- a/src/tint/sem/variable.cc +++ b/src/tint/sem/variable.cc @@ -31,7 +31,7 @@ namespace tint::sem { Variable::Variable(const ast::Variable* declaration, const type::Type* type, EvaluationStage stage, - type::AddressSpace address_space, + builtin::AddressSpace address_space, builtin::Access access, const constant::Value* constant_value) : declaration_(declaration), @@ -46,7 +46,7 @@ Variable::~Variable() = default; LocalVariable::LocalVariable(const ast::Variable* declaration, const type::Type* type, EvaluationStage stage, - type::AddressSpace address_space, + builtin::AddressSpace address_space, builtin::Access access, const sem::Statement* statement, const constant::Value* constant_value) @@ -58,7 +58,7 @@ LocalVariable::~LocalVariable() = default; GlobalVariable::GlobalVariable(const ast::Variable* declaration, const type::Type* type, EvaluationStage stage, - type::AddressSpace address_space, + builtin::AddressSpace address_space, builtin::Access access, const constant::Value* constant_value, sem::BindingPoint binding_point, @@ -72,7 +72,7 @@ GlobalVariable::~GlobalVariable() = default; Parameter::Parameter(const ast::Parameter* declaration, uint32_t index, const type::Type* type, - type::AddressSpace address_space, + builtin::AddressSpace address_space, builtin::Access access, const ParameterUsage usage /* = ParameterUsage::kNone */, sem::BindingPoint binding_point /* = {} */, diff --git a/src/tint/sem/variable.h b/src/tint/sem/variable.h index fcaf1455fe..701a3f1107 100644 --- a/src/tint/sem/variable.h +++ b/src/tint/sem/variable.h @@ -23,10 +23,10 @@ #include "src/tint/ast/parameter.h" #include "src/tint/builtin/access.h" +#include "src/tint/builtin/address_space.h" #include "src/tint/sem/binding_point.h" #include "src/tint/sem/parameter_usage.h" #include "src/tint/sem/value_expression.h" -#include "src/tint/type/address_space.h" #include "src/tint/type/type.h" #include "src/tint/utils/unique_vector.h" @@ -57,7 +57,7 @@ class Variable : public Castable { Variable(const ast::Variable* declaration, const type::Type* type, EvaluationStage stage, - type::AddressSpace address_space, + builtin::AddressSpace address_space, builtin::Access access, const constant::Value* constant_value); @@ -74,7 +74,7 @@ class Variable : public Castable { EvaluationStage Stage() const { return stage_; } /// @returns the address space for the variable - type::AddressSpace AddressSpace() const { return address_space_; } + builtin::AddressSpace AddressSpace() const { return address_space_; } /// @returns the access control for the variable builtin::Access Access() const { return access_; } @@ -100,7 +100,7 @@ class Variable : public Castable { const ast::Variable* const declaration_; const type::Type* const type_; const EvaluationStage stage_; - const type::AddressSpace address_space_; + const builtin::AddressSpace address_space_; const builtin::Access access_; const constant::Value* constant_value_; const ValueExpression* initializer_ = nullptr; @@ -121,7 +121,7 @@ class LocalVariable final : public Castable { LocalVariable(const ast::Variable* declaration, const type::Type* type, EvaluationStage stage, - type::AddressSpace address_space, + builtin::AddressSpace address_space, builtin::Access access, const sem::Statement* statement, const constant::Value* constant_value); @@ -162,7 +162,7 @@ class GlobalVariable final : public Castable { GlobalVariable(const ast::Variable* declaration, const type::Type* type, EvaluationStage stage, - type::AddressSpace address_space, + builtin::AddressSpace address_space, builtin::Access access, const constant::Value* constant_value, sem::BindingPoint binding_point = {}, @@ -205,7 +205,7 @@ class Parameter final : public Castable { Parameter(const ast::Parameter* declaration, uint32_t index, const type::Type* type, - type::AddressSpace address_space, + builtin::AddressSpace address_space, builtin::Access access, const ParameterUsage usage = ParameterUsage::kNone, sem::BindingPoint binding_point = {}, diff --git a/src/tint/transform/add_block_attribute.cc b/src/tint/transform/add_block_attribute.cc index 2b1ec31b4e..c63bd04f9e 100644 --- a/src/tint/transform/add_block_attribute.cc +++ b/src/tint/transform/add_block_attribute.cc @@ -47,7 +47,7 @@ Transform::ApplyResult AddBlockAttribute::Apply(const Program* src, bool made_changes = false; for (auto* global : src->AST().GlobalVariables()) { auto* var = sem.Get(global); - if (!type::IsHostShareable(var->AddressSpace())) { + if (!builtin::IsHostShareable(var->AddressSpace())) { // Not declared in a host-sharable address space continue; } diff --git a/src/tint/transform/array_length_from_uniform.cc b/src/tint/transform/array_length_from_uniform.cc index 444a328efe..78535f186a 100644 --- a/src/tint/transform/array_length_from_uniform.cc +++ b/src/tint/transform/array_length_from_uniform.cc @@ -106,10 +106,10 @@ struct ArrayLengthFromUniform::State { b.ty.array(b.ty.vec4(b.ty.u32()), u32((max_buffer_size_index / 4) + 1))), }); - buffer_size_ubo = - b.GlobalVar(b.Sym(), b.ty.Of(buffer_size_struct), type::AddressSpace::kUniform, - b.Group(AInt(cfg->ubo_binding.group)), - b.Binding(AInt(cfg->ubo_binding.binding))); + buffer_size_ubo = b.GlobalVar(b.Sym(), b.ty.Of(buffer_size_struct), + builtin::AddressSpace::kUniform, + b.Group(AInt(cfg->ubo_binding.group)), + b.Binding(AInt(cfg->ubo_binding.binding))); } return buffer_size_ubo; }; diff --git a/src/tint/transform/binding_remapper.cc b/src/tint/transform/binding_remapper.cc index e4f2e6e692..ecbd5cd6f9 100644 --- a/src/tint/transform/binding_remapper.cc +++ b/src/tint/transform/binding_remapper.cc @@ -131,7 +131,7 @@ Transform::ApplyResult BindingRemapper::Apply(const Program* src, return Program(std::move(b)); } auto* sem = src->Sem().Get(var); - if (sem->AddressSpace() != type::AddressSpace::kStorage) { + if (sem->AddressSpace() != builtin::AddressSpace::kStorage) { b.Diagnostics().add_error( diag::System::Transform, "cannot apply access control to variable with address space " + diff --git a/src/tint/transform/builtin_polyfill.cc b/src/tint/transform/builtin_polyfill.cc index 917d418108..2da1a84a2d 100644 --- a/src/tint/transform/builtin_polyfill.cc +++ b/src/tint/transform/builtin_polyfill.cc @@ -679,7 +679,7 @@ struct BuiltinPolyfill::State { auto name = b.Symbols().New("tint_workgroupUniformLoad"); b.Func(name, utils::Vector{ - b.Param("p", b.ty.pointer(T(type), type::AddressSpace::kWorkgroup)), + b.Param("p", b.ty.pointer(T(type), builtin::AddressSpace::kWorkgroup)), }, T(type), utils::Vector{ diff --git a/src/tint/transform/calculate_array_length.cc b/src/tint/transform/calculate_array_length.cc index 5ed6547f1a..a25c89eca8 100644 --- a/src/tint/transform/calculate_array_length.cc +++ b/src/tint/transform/calculate_array_length.cc @@ -112,7 +112,7 @@ Transform::ApplyResult CalculateArrayLength::Apply(const Program* src, 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(), type::AddressSpace::kFunction)), + b.Param("result", b.ty.pointer(b.ty.u32(), builtin::AddressSpace::kFunction)), }, b.ty.void_(), nullptr, utils::Vector{ diff --git a/src/tint/transform/canonicalize_entry_point_io.cc b/src/tint/transform/canonicalize_entry_point_io.cc index 049e9ca1dd..2df79665ed 100644 --- a/src/tint/transform/canonicalize_entry_point_io.cc +++ b/src/tint/transform/canonicalize_entry_point_io.cc @@ -234,7 +234,7 @@ struct CanonicalizeEntryPointIO::State { auto* builtin = ast::GetAttribute(attributes); if (cfg.shader_style == ShaderStyle::kGlsl && builtin) { name = GLSLBuiltinToString(builtin->builtin, func_ast->PipelineStage(), - type::AddressSpace::kIn); + builtin::AddressSpace::kIn); } auto symbol = ctx.dst->Symbols().New(name); @@ -251,7 +251,7 @@ struct CanonicalizeEntryPointIO::State { value = ctx.dst->IndexAccessor(value, 0_i); } } - ctx.dst->GlobalVar(symbol, ast_type, type::AddressSpace::kIn, std::move(attributes)); + ctx.dst->GlobalVar(symbol, ast_type, builtin::AddressSpace::kIn, std::move(attributes)); return value; } else if (cfg.shader_style == ShaderStyle::kMsl && ast::HasAttribute(attributes)) { @@ -300,7 +300,7 @@ struct CanonicalizeEntryPointIO::State { if (cfg.shader_style == ShaderStyle::kGlsl) { if (auto* b = ast::GetAttribute(attributes)) { name = GLSLBuiltinToString(b->builtin, func_ast->PipelineStage(), - type::AddressSpace::kOut); + builtin::AddressSpace::kOut); value = ToGLSLBuiltin(b->builtin, value, type); } } @@ -532,7 +532,7 @@ struct CanonicalizeEntryPointIO::State { type = ctx.dst->ty.array(type, 1_u); lhs = ctx.dst->IndexAccessor(lhs, 0_i); } - ctx.dst->GlobalVar(name, type, type::AddressSpace::kOut, std::move(attributes)); + ctx.dst->GlobalVar(name, type, builtin::AddressSpace::kOut, std::move(attributes)); wrapper_body.Push(ctx.dst->Assign(lhs, outval.value)); } } @@ -677,7 +677,7 @@ struct CanonicalizeEntryPointIO::State { /// @returns the gl_ string corresponding to that builtin const char* GLSLBuiltinToString(builtin::BuiltinValue builtin, ast::PipelineStage stage, - type::AddressSpace address_space) { + builtin::AddressSpace address_space) { switch (builtin) { case builtin::BuiltinValue::kPosition: switch (stage) { @@ -709,7 +709,7 @@ struct CanonicalizeEntryPointIO::State { case builtin::BuiltinValue::kSampleIndex: return "gl_SampleID"; case builtin::BuiltinValue::kSampleMask: - if (address_space == type::AddressSpace::kIn) { + if (address_space == builtin::AddressSpace::kIn) { return "gl_SampleMaskIn"; } else { return "gl_SampleMask"; diff --git a/src/tint/transform/clamp_frag_depth.cc b/src/tint/transform/clamp_frag_depth.cc index 8d84ed3654..951dc3046e 100644 --- a/src/tint/transform/clamp_frag_depth.cc +++ b/src/tint/transform/clamp_frag_depth.cc @@ -89,7 +89,7 @@ Transform::ApplyResult ClampFragDepth::Apply(const Program* src, const DataMap&, for (auto* global : src->AST().GlobalVariables()) { if (auto* var = global->As()) { auto* v = src->Sem().Get(var); - if (TINT_UNLIKELY(v->AddressSpace() == type::AddressSpace::kPushConstant)) { + if (TINT_UNLIKELY(v->AddressSpace() == builtin::AddressSpace::kPushConstant)) { TINT_ICE(Transform, b.Diagnostics()) << "ClampFragDepth doesn't know how to handle module that already use push " "constants"; @@ -124,7 +124,7 @@ Transform::ApplyResult ClampFragDepth::Apply(const Program* src, const DataMap&, utils::Vector{b.Member("min", b.ty.f32()), b.Member("max", b.ty.f32())}); auto args_sym = b.Symbols().New("frag_depth_clamp_args"); - b.GlobalVar(args_sym, b.ty("FragDepthClampArgs"), type::AddressSpace::kPushConstant); + b.GlobalVar(args_sym, b.ty("FragDepthClampArgs"), builtin::AddressSpace::kPushConstant); auto base_fn_sym = b.Symbols().New("clamp_frag_depth"); b.Func(base_fn_sym, utils::Vector{b.Param("v", b.ty.f32())}, b.ty.f32(), diff --git a/src/tint/transform/decompose_memory_access.cc b/src/tint/transform/decompose_memory_access.cc index 47cefcf1f7..b3c2292149 100644 --- a/src/tint/transform/decompose_memory_access.cc +++ b/src/tint/transform/decompose_memory_access.cc @@ -49,8 +49,8 @@ namespace { bool ShouldRun(const Program* program) { for (auto* decl : program->AST().GlobalDeclarations()) { if (auto* var = program->Sem().Get(decl)) { - if (var->AddressSpace() == type::AddressSpace::kStorage || - var->AddressSpace() == type::AddressSpace::kUniform) { + if (var->AddressSpace() == builtin::AddressSpace::kStorage || + var->AddressSpace() == builtin::AddressSpace::kUniform) { return true; } } @@ -108,10 +108,10 @@ struct OffsetBinOp : Offset { /// LoadStoreKey is the unordered map key to a load or store intrinsic. struct LoadStoreKey { - type::AddressSpace const address_space; // buffer address space - builtin::Access const access; // buffer access - type::Type const* buf_ty = nullptr; // buffer type - type::Type const* el_ty = nullptr; // element type + builtin::AddressSpace const address_space; // buffer address space + builtin::Access const access; // buffer access + type::Type const* buf_ty = nullptr; // buffer type + type::Type const* el_ty = nullptr; // element type bool operator==(const LoadStoreKey& rhs) const { return address_space == rhs.address_space && access == rhs.access && buf_ty == rhs.buf_ty && el_ty == rhs.el_ty; @@ -222,7 +222,7 @@ bool IntrinsicDataTypeFor(const type::Type* ty, DecomposeMemoryAccess::Intrinsic /// @returns a DecomposeMemoryAccess::Intrinsic attribute that can be applied /// to a stub function to load the type `ty`. DecomposeMemoryAccess::Intrinsic* IntrinsicLoadFor(ProgramBuilder* builder, - type::AddressSpace address_space, + builtin::AddressSpace address_space, const type::Type* ty) { DecomposeMemoryAccess::Intrinsic::DataType type; if (!IntrinsicDataTypeFor(ty, type)) { @@ -236,7 +236,7 @@ DecomposeMemoryAccess::Intrinsic* IntrinsicLoadFor(ProgramBuilder* builder, /// @returns a DecomposeMemoryAccess::Intrinsic attribute that can be applied /// to a stub function to store the type `ty`. DecomposeMemoryAccess::Intrinsic* IntrinsicStoreFor(ProgramBuilder* builder, - type::AddressSpace address_space, + builtin::AddressSpace address_space, const type::Type* ty) { DecomposeMemoryAccess::Intrinsic::DataType type; if (!IntrinsicDataTypeFor(ty, type)) { @@ -299,7 +299,7 @@ DecomposeMemoryAccess::Intrinsic* IntrinsicAtomicFor(ProgramBuilder* builder, return nullptr; } return builder->ASTNodes().Create( - builder->ID(), builder->AllocateNodeID(), op, type::AddressSpace::kStorage, type); + builder->ID(), builder->AllocateNodeID(), op, builtin::AddressSpace::kStorage, type); } /// BufferAccess describes a single storage or uniform buffer access @@ -465,7 +465,7 @@ struct DecomposeMemoryAccess::State { const sem::VariableUser* var_user) { auto address_space = var_user->Variable()->AddressSpace(); auto access = var_user->Variable()->Access(); - if (address_space != type::AddressSpace::kStorage) { + if (address_space != builtin::AddressSpace::kStorage) { access = builtin::Access::kUndefined; } return utils::GetOrCreate( @@ -561,7 +561,7 @@ struct DecomposeMemoryAccess::State { const sem::VariableUser* var_user) { auto address_space = var_user->Variable()->AddressSpace(); auto access = var_user->Variable()->Access(); - if (address_space != type::AddressSpace::kStorage) { + if (address_space != builtin::AddressSpace::kStorage) { access = builtin::Access::kUndefined; } return utils::GetOrCreate( @@ -671,7 +671,7 @@ struct DecomposeMemoryAccess::State { auto op = intrinsic->Type(); auto address_space = var_user->Variable()->AddressSpace(); auto access = var_user->Variable()->Access(); - if (address_space != type::AddressSpace::kStorage) { + if (address_space != builtin::AddressSpace::kStorage) { access = builtin::Access::kUndefined; } return utils::GetOrCreate(atomic_funcs, AtomicKey{access, buf_ty, el_ty, op}, [&] { @@ -679,7 +679,7 @@ struct DecomposeMemoryAccess::State { // atomic. This is replaced with two parameters: the buffer and offset. utils::Vector params{ b.Param("buffer", - b.ty.pointer(CreateASTTypeFor(ctx, buf_ty), type::AddressSpace::kStorage, + b.ty.pointer(CreateASTTypeFor(ctx, buf_ty), builtin::AddressSpace::kStorage, access), utils::Vector{b.Disable(ast::DisabledValidation::kFunctionParameter)}), b.Param("offset", b.ty.u32()), @@ -734,7 +734,7 @@ struct DecomposeMemoryAccess::State { DecomposeMemoryAccess::Intrinsic::Intrinsic(ProgramID pid, ast::NodeID nid, Op o, - type::AddressSpace sc, + builtin::AddressSpace sc, DataType ty) : Base(pid, nid), op(o), address_space(sc), type(ty) {} DecomposeMemoryAccess::Intrinsic::~Intrinsic() = default; @@ -873,8 +873,8 @@ Transform::ApplyResult DecomposeMemoryAccess::Apply(const Program* src, // X if (auto* sem_ident = sem.GetVal(ident)) { if (auto* var = sem_ident->UnwrapLoad()->As()) { - if (var->Variable()->AddressSpace() == type::AddressSpace::kStorage || - var->Variable()->AddressSpace() == type::AddressSpace::kUniform) { + if (var->Variable()->AddressSpace() == builtin::AddressSpace::kStorage || + var->Variable()->AddressSpace() == builtin::AddressSpace::kUniform) { // Variable to a storage or uniform buffer state.AddAccess(ident, { var, diff --git a/src/tint/transform/decompose_memory_access.h b/src/tint/transform/decompose_memory_access.h index 3a51035d09..b251ed8397 100644 --- a/src/tint/transform/decompose_memory_access.h +++ b/src/tint/transform/decompose_memory_access.h @@ -81,7 +81,7 @@ class DecomposeMemoryAccess final : public Castable arr : array ProgramBuilder b; - b.GlobalVar("arr", b.ty.array(), type::AddressSpace::kPrivate); + b.GlobalVar("arr", b.ty.array(), builtin::AddressSpace::kPrivate); EXPECT_FALSE(ShouldRun(Program(std::move(b)))); } @@ -51,7 +51,7 @@ TEST_F(DecomposeStridedArrayTest, ShouldRunDefaultStridedArray) { b.ty.array(utils::Vector{ b.Stride(4), }), - type::AddressSpace::kPrivate); + builtin::AddressSpace::kPrivate); EXPECT_TRUE(ShouldRun(Program(std::move(b)))); } @@ -63,7 +63,7 @@ TEST_F(DecomposeStridedArrayTest, ShouldRunExplicitStridedArray) { b.ty.array(utils::Vector{ b.Stride(16), }), - type::AddressSpace::kPrivate); + builtin::AddressSpace::kPrivate); EXPECT_TRUE(ShouldRun(Program(std::move(b)))); } @@ -90,7 +90,7 @@ TEST_F(DecomposeStridedArrayTest, PrivateDefaultStridedArray) { b.ty.array(utils::Vector{ b.Stride(4), }), - type::AddressSpace::kPrivate); + builtin::AddressSpace::kPrivate); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ b.Decl(b.Let("a", @@ -134,7 +134,7 @@ TEST_F(DecomposeStridedArrayTest, PrivateStridedArray) { b.ty.array(utils::Vector{ b.Stride(32), }), - type::AddressSpace::kPrivate); + builtin::AddressSpace::kPrivate); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ b.Decl(b.Let("a", @@ -184,7 +184,7 @@ TEST_F(DecomposeStridedArrayTest, ReadUniformStridedArray) { auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty.array(utils::Vector{ b.Stride(32), }))}); - b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kUniform, b.Group(0_a), b.Binding(0_a)); + b.GlobalVar("s", b.ty.Of(S), builtin::AddressSpace::kUniform, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ b.Decl(b.Let("a", @@ -239,7 +239,7 @@ TEST_F(DecomposeStridedArrayTest, ReadUniformDefaultStridedArray) { utils::Vector{ b.Stride(16), }))}); - b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kUniform, b.Group(0_a), b.Binding(0_a)); + b.GlobalVar("s", b.ty.Of(S), builtin::AddressSpace::kUniform, b.Group(0_a), b.Binding(0_a)); b.Func( "f", utils::Empty, b.ty.void_(), utils::Vector{ @@ -292,7 +292,7 @@ TEST_F(DecomposeStridedArrayTest, ReadStorageStridedArray) { auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty.array(utils::Vector{ b.Stride(32), }))}); - b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, b.Group(0_a), b.Binding(0_a)); + b.GlobalVar("s", b.ty.Of(S), builtin::AddressSpace::kStorage, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ b.Decl(b.Let("a", @@ -346,7 +346,7 @@ TEST_F(DecomposeStridedArrayTest, ReadStorageDefaultStridedArray) { auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty.array(utils::Vector{ b.Stride(4), }))}); - b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, b.Group(0_a), b.Binding(0_a)); + b.GlobalVar("s", b.ty.Of(S), builtin::AddressSpace::kStorage, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ b.Decl(b.Let("a", @@ -396,7 +396,7 @@ TEST_F(DecomposeStridedArrayTest, WriteStorageStridedArray) { auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty.array(utils::Vector{ b.Stride(32), }))}); - b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + b.GlobalVar("s", b.ty.Of(S), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ @@ -458,7 +458,7 @@ TEST_F(DecomposeStridedArrayTest, WriteStorageDefaultStridedArray) { b.Stride(4), })), }); - b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + b.GlobalVar("s", b.ty.Of(S), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ @@ -516,7 +516,7 @@ TEST_F(DecomposeStridedArrayTest, ReadWriteViaPointerLets) { auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty.array(utils::Vector{ b.Stride(32), }))}); - b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + b.GlobalVar("s", b.ty.Of(S), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ @@ -582,7 +582,7 @@ TEST_F(DecomposeStridedArrayTest, PrivateAliasedStridedArray) { b.Stride(32), })); auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty("ARR"))}); - b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + b.GlobalVar("s", b.ty.Of(S), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ @@ -658,7 +658,7 @@ TEST_F(DecomposeStridedArrayTest, PrivateNestedStridedArray) { b.Stride(128), })); auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty("ARR_B"))}); - b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + b.GlobalVar("s", b.ty.Of(S), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ diff --git a/src/tint/transform/decompose_strided_matrix.cc b/src/tint/transform/decompose_strided_matrix.cc index 4642c57dca..dd03dc232d 100644 --- a/src/tint/transform/decompose_strided_matrix.cc +++ b/src/tint/transform/decompose_strided_matrix.cc @@ -74,8 +74,8 @@ Transform::ApplyResult DecomposeStridedMatrix::Apply(const Program* src, for (auto* node : src->ASTNodes().Objects()) { if (auto* str = node->As()) { auto* str_ty = src->Sem().Get(str); - if (!str_ty->UsedAs(type::AddressSpace::kUniform) && - !str_ty->UsedAs(type::AddressSpace::kStorage)) { + if (!str_ty->UsedAs(builtin::AddressSpace::kUniform) && + !str_ty->UsedAs(builtin::AddressSpace::kStorage)) { continue; } for (auto* member : str_ty->Members()) { diff --git a/src/tint/transform/decompose_strided_matrix_test.cc b/src/tint/transform/decompose_strided_matrix_test.cc index 0da9e71afb..12ca02e6a8 100644 --- a/src/tint/transform/decompose_strided_matrix_test.cc +++ b/src/tint/transform/decompose_strided_matrix_test.cc @@ -76,7 +76,7 @@ TEST_F(DecomposeStridedMatrixTest, ReadUniformMatrix) { b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), }), }); - b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kUniform, b.Group(0_a), b.Binding(0_a)); + b.GlobalVar("s", b.ty.Of(S), builtin::AddressSpace::kUniform, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ b.Decl(b.Let("x", b.ty.mat2x2(), b.MemberAccessor("s", "m"))), @@ -133,7 +133,7 @@ TEST_F(DecomposeStridedMatrixTest, ReadUniformColumn) { b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), }), }); - b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kUniform, b.Group(0_a), b.Binding(0_a)); + b.GlobalVar("s", b.ty.Of(S), builtin::AddressSpace::kUniform, b.Group(0_a), b.Binding(0_a)); b.Func( "f", utils::Empty, b.ty.void_(), utils::Vector{ @@ -187,7 +187,7 @@ TEST_F(DecomposeStridedMatrixTest, ReadUniformMatrix_DefaultStride) { b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), }), }); - b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kUniform, b.Group(0_a), b.Binding(0_a)); + b.GlobalVar("s", b.ty.Of(S), builtin::AddressSpace::kUniform, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ b.Decl(b.Let("x", b.ty.mat2x2(), b.MemberAccessor("s", "m"))), @@ -241,7 +241,7 @@ TEST_F(DecomposeStridedMatrixTest, ReadStorageMatrix) { b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), }), }); - b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + b.GlobalVar("s", b.ty.Of(S), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ @@ -299,7 +299,7 @@ TEST_F(DecomposeStridedMatrixTest, ReadStorageColumn) { b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), }), }); - b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + b.GlobalVar("s", b.ty.Of(S), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, b.Group(0_a), b.Binding(0_a)); b.Func( "f", utils::Empty, b.ty.void_(), @@ -354,7 +354,7 @@ TEST_F(DecomposeStridedMatrixTest, WriteStorageMatrix) { b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), }), }); - b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + b.GlobalVar("s", b.ty.Of(S), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ @@ -413,7 +413,7 @@ TEST_F(DecomposeStridedMatrixTest, WriteStorageColumn) { b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), }), }); - b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + b.GlobalVar("s", b.ty.Of(S), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ @@ -473,7 +473,7 @@ TEST_F(DecomposeStridedMatrixTest, ReadWriteViaPointerLets) { b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), }), }); - b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + b.GlobalVar("s", b.ty.Of(S), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ @@ -545,7 +545,7 @@ TEST_F(DecomposeStridedMatrixTest, ReadPrivateMatrix) { b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), }), }); - b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kPrivate); + b.GlobalVar("s", b.ty.Of(S), builtin::AddressSpace::kPrivate); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ b.Decl(b.Let("x", b.ty.mat2x2(), b.MemberAccessor("s", "m"))), @@ -599,7 +599,7 @@ TEST_F(DecomposeStridedMatrixTest, WritePrivateMatrix) { b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), }), }); - b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kPrivate); + b.GlobalVar("s", b.ty.Of(S), builtin::AddressSpace::kPrivate); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ b.Assign(b.MemberAccessor("s", "m"), diff --git a/src/tint/transform/demote_to_helper.cc b/src/tint/transform/demote_to_helper.cc index dc5384b101..ac3c15eb5b 100644 --- a/src/tint/transform/demote_to_helper.cc +++ b/src/tint/transform/demote_to_helper.cc @@ -81,7 +81,7 @@ Transform::ApplyResult DemoteToHelper::Apply(const Program* src, const DataMap&, // Create a module-scope flag that indicates whether the current invocation has been discarded. auto flag = b.Symbols().New("tint_discarded"); - b.GlobalVar(flag, type::AddressSpace::kPrivate, b.Expr(false)); + b.GlobalVar(flag, builtin::AddressSpace::kPrivate, b.Expr(false)); // Replace all discard statements with a statement that marks the invocation as discarded. ctx.ReplaceAll([&](const ast::DiscardStatement*) -> const ast::Statement* { @@ -125,12 +125,12 @@ Transform::ApplyResult DemoteToHelper::Apply(const Program* src, const DataMap&, // Skip writes to invocation-private address spaces. auto* ref = sem.GetVal(assign->lhs)->Type()->As(); switch (ref->AddressSpace()) { - case type::AddressSpace::kStorage: + case builtin::AddressSpace::kStorage: // Need to mask these. break; - case type::AddressSpace::kFunction: - case type::AddressSpace::kPrivate: - case type::AddressSpace::kOut: + case builtin::AddressSpace::kFunction: + case builtin::AddressSpace::kPrivate: + case builtin::AddressSpace::kOut: // Skip these. return; default: diff --git a/src/tint/transform/direct_variable_access.cc b/src/tint/transform/direct_variable_access.cc index 8ae3e22ef8..a6ef9d8f22 100644 --- a/src/tint/transform/direct_variable_access.cc +++ b/src/tint/transform/direct_variable_access.cc @@ -50,7 +50,7 @@ struct AccessRoot { /// function-scope variable ('function'), or pointer parameter in the source program. tint::sem::Variable const* variable = nullptr; /// The address space of the variable or pointer type. - tint::type::AddressSpace address_space = tint::type::AddressSpace::kUndefined; + tint::builtin::AddressSpace address_space = tint::builtin::AddressSpace::kUndefined; }; /// Inequality operator for AccessRoot @@ -450,7 +450,7 @@ struct DirectVariableAccess::State { Switch( variable->Declaration(), [&](const ast::Var*) { - if (variable->AddressSpace() != type::AddressSpace::kHandle) { + if (variable->AddressSpace() != builtin::AddressSpace::kHandle) { // Start a new access chain for the non-handle 'var' access create_new_chain(); } @@ -749,15 +749,15 @@ struct DirectVariableAccess::State { /// @returns true if the address space @p address_space requires transforming given the /// transform's options. - bool AddressSpaceRequiresTransform(type::AddressSpace address_space) const { + bool AddressSpaceRequiresTransform(builtin::AddressSpace address_space) const { switch (address_space) { - case type::AddressSpace::kUniform: - case type::AddressSpace::kStorage: - case type::AddressSpace::kWorkgroup: + case builtin::AddressSpace::kUniform: + case builtin::AddressSpace::kStorage: + case builtin::AddressSpace::kWorkgroup: return true; - case type::AddressSpace::kPrivate: + case builtin::AddressSpace::kPrivate: return opts.transform_private; - case type::AddressSpace::kFunction: + case builtin::AddressSpace::kFunction: return opts.transform_function; default: return false; @@ -1180,9 +1180,9 @@ struct DirectVariableAccess::State { for (auto* param : fn->Parameters()) { if (auto* ptr = param->Type()->As()) { switch (ptr->AddressSpace()) { - case type::AddressSpace::kUniform: - case type::AddressSpace::kStorage: - case type::AddressSpace::kWorkgroup: + case builtin::AddressSpace::kUniform: + case builtin::AddressSpace::kStorage: + case builtin::AddressSpace::kWorkgroup: return true; default: return false; @@ -1193,8 +1193,8 @@ struct DirectVariableAccess::State { } /// @returns true if the given address space is 'private' or 'function'. - static bool IsPrivateOrFunction(const type::AddressSpace sc) { - return sc == type::AddressSpace::kPrivate || sc == type::AddressSpace::kFunction; + static bool IsPrivateOrFunction(const builtin::AddressSpace sc) { + return sc == builtin::AddressSpace::kPrivate || sc == builtin::AddressSpace::kFunction; } }; diff --git a/src/tint/transform/first_index_offset.cc b/src/tint/transform/first_index_offset.cc index e739faec79..cac1299204 100644 --- a/src/tint/transform/first_index_offset.cc +++ b/src/tint/transform/first_index_offset.cc @@ -130,7 +130,7 @@ Transform::ApplyResult FirstIndexOffset::Apply(const Program* src, // Create a global to hold the uniform buffer Symbol buffer_name = b.Sym(); - b.GlobalVar(buffer_name, b.ty.Of(struct_), type::AddressSpace::kUniform, + b.GlobalVar(buffer_name, b.ty.Of(struct_), builtin::AddressSpace::kUniform, utils::Vector{ b.Binding(AInt(ub_binding)), b.Group(AInt(ub_group)), diff --git a/src/tint/transform/localize_struct_array_assignment.cc b/src/tint/transform/localize_struct_array_assignment.cc index 5f70731827..f5f87444a2 100644 --- a/src/tint/transform/localize_struct_array_assignment.cc +++ b/src/tint/transform/localize_struct_array_assignment.cc @@ -60,8 +60,9 @@ struct LocalizeStructArrayAssignment::State { continue; } auto og = GetOriginatingTypeAndAddressSpace(assign_stmt); - if (!(og.first->Is() && (og.second == type::AddressSpace::kFunction || - og.second == type::AddressSpace::kPrivate))) { + if (!(og.first->Is() && + (og.second == builtin::AddressSpace::kFunction || + og.second == builtin::AddressSpace::kPrivate))) { continue; } @@ -184,7 +185,7 @@ struct LocalizeStructArrayAssignment::State { // Returns the type and address space of the originating variable of the lhs // of the assignment statement. // See https://www.w3.org/TR/WGSL/#originating-variable-section - std::pair GetOriginatingTypeAndAddressSpace( + std::pair GetOriginatingTypeAndAddressSpace( const ast::AssignmentStatement* assign_stmt) { auto* root_ident = src->Sem().GetVal(assign_stmt->lhs)->RootIdentifier(); if (TINT_UNLIKELY(!root_ident)) { @@ -206,7 +207,7 @@ struct LocalizeStructArrayAssignment::State { TINT_ICE(Transform, b.Diagnostics()) << "Expecting to find variable of type pointer or reference on lhs " "of assignment statement"; - return std::pair{}; + return std::pair{}; }); } }; diff --git a/src/tint/transform/module_scope_var_to_entry_point_param.cc b/src/tint/transform/module_scope_var_to_entry_point_param.cc index 47356e9626..044133c413 100644 --- a/src/tint/transform/module_scope_var_to_entry_point_param.cc +++ b/src/tint/transform/module_scope_var_to_entry_point_param.cc @@ -122,9 +122,9 @@ struct ModuleScopeVarToEntryPointParam::State { // Helper to create an AST node for the store type of the variable. auto store_type = [&]() { return CreateASTTypeFor(ctx, ty); }; - type::AddressSpace sc = var->AddressSpace(); + builtin::AddressSpace sc = var->AddressSpace(); switch (sc) { - case type::AddressSpace::kHandle: { + case builtin::AddressSpace::kHandle: { // For a texture or sampler variable, redeclare it as an entry point parameter. // Disable entry point parameter validation. auto* disable_validation = @@ -136,8 +136,8 @@ struct ModuleScopeVarToEntryPointParam::State { break; } - case type::AddressSpace::kStorage: - case type::AddressSpace::kUniform: { + case builtin::AddressSpace::kStorage: + case builtin::AddressSpace::kUniform: { // Variables into the Storage and Uniform address spaces are redeclared as entry // point parameters with a pointer type. auto attributes = ctx.Clone(var->Declaration()->attributes); @@ -159,7 +159,7 @@ struct ModuleScopeVarToEntryPointParam::State { is_wrapped = true; } - param_type = sc == type::AddressSpace::kStorage + param_type = sc == builtin::AddressSpace::kStorage ? ctx.dst->ty.pointer(param_type, sc, var->Access()) : ctx.dst->ty.pointer(param_type, sc); auto* param = ctx.dst->Param(new_var_symbol, param_type, attributes); @@ -168,7 +168,7 @@ struct ModuleScopeVarToEntryPointParam::State { break; } - case type::AddressSpace::kWorkgroup: { + case builtin::AddressSpace::kWorkgroup: { if (ContainsMatrix(var->Type())) { // Due to a bug in the MSL compiler, we use a threadgroup memory argument for // any workgroup allocation that contains a matrix. See crbug.com/tint/938. @@ -184,7 +184,7 @@ struct ModuleScopeVarToEntryPointParam::State { ctx.dst->MemberAccessor(ctx.dst->Deref(workgroup_param()), member)); auto* local_var = ctx.dst->Let( new_var_symbol, - ctx.dst->ty.pointer(store_type(), type::AddressSpace::kWorkgroup), + ctx.dst->ty.pointer(store_type(), builtin::AddressSpace::kWorkgroup), member_ptr); ctx.InsertFront(func->body->statements, ctx.dst->Decl(local_var)); is_pointer = true; @@ -193,7 +193,7 @@ struct ModuleScopeVarToEntryPointParam::State { } [[fallthrough]]; } - case type::AddressSpace::kPrivate: { + case builtin::AddressSpace::kPrivate: { // Variables in the Private and Workgroup address spaces are redeclared at function // scope. Disable address space validation on this variable. auto* disable_validation = @@ -205,7 +205,7 @@ struct ModuleScopeVarToEntryPointParam::State { break; } - case type::AddressSpace::kPushConstant: { + case builtin::AddressSpace::kPushConstant: { ctx.dst->Diagnostics().add_error( diag::System::Transform, "unhandled module-scope address space (" + utils::ToString(sc) + ")"); @@ -233,13 +233,13 @@ struct ModuleScopeVarToEntryPointParam::State { auto param_type = CreateASTTypeFor(ctx, ty); auto sc = var->AddressSpace(); switch (sc) { - case type::AddressSpace::kPrivate: - case type::AddressSpace::kStorage: - case type::AddressSpace::kUniform: - case type::AddressSpace::kHandle: - case type::AddressSpace::kWorkgroup: + case builtin::AddressSpace::kPrivate: + case builtin::AddressSpace::kStorage: + case builtin::AddressSpace::kUniform: + case builtin::AddressSpace::kHandle: + case builtin::AddressSpace::kWorkgroup: break; - case type::AddressSpace::kPushConstant: { + case builtin::AddressSpace::kPushConstant: { ctx.dst->Diagnostics().add_error( diag::System::Transform, "unhandled module-scope address space (" + utils::ToString(sc) + ")"); @@ -254,7 +254,7 @@ struct ModuleScopeVarToEntryPointParam::State { // Use a pointer for non-handle types. utils::Vector attributes; if (!ty->is_handle()) { - param_type = sc == type::AddressSpace::kStorage + param_type = sc == builtin::AddressSpace::kStorage ? ctx.dst->ty.pointer(param_type, sc, var->Access()) : ctx.dst->ty.pointer(param_type, sc); is_pointer = true; @@ -323,7 +323,7 @@ struct ModuleScopeVarToEntryPointParam::State { bool needs_processing = false; for (auto* var : func_sem->TransitivelyReferencedGlobals()) { - if (var->AddressSpace() != type::AddressSpace::kUndefined) { + if (var->AddressSpace() != builtin::AddressSpace::kUndefined) { needs_processing = true; break; } @@ -380,7 +380,7 @@ struct ModuleScopeVarToEntryPointParam::State { // Process and redeclare all variables referenced by the function. for (auto* var : func_sem->TransitivelyReferencedGlobals()) { - if (var->AddressSpace() == type::AddressSpace::kUndefined) { + if (var->AddressSpace() == builtin::AddressSpace::kUndefined) { continue; } if (local_private_vars_.count(var)) { @@ -398,7 +398,7 @@ struct ModuleScopeVarToEntryPointParam::State { // Check if this is a private variable that is only referenced by this function. bool local_private = false; - if (var->AddressSpace() == type::AddressSpace::kPrivate) { + if (var->AddressSpace() == builtin::AddressSpace::kPrivate) { local_private = true; for (auto* user : var->Users()) { auto* stmt = user->Stmt(); @@ -416,7 +416,7 @@ struct ModuleScopeVarToEntryPointParam::State { auto* initializer = ctx.Clone(var->Declaration()->initializer); auto* local_var = ctx.dst->Var(new_var_symbol, CreateASTTypeFor(ctx, var->Type()->UnwrapRef()), - type::AddressSpace::kPrivate, initializer, + builtin::AddressSpace::kPrivate, initializer, utils::Vector{disable_validation}); ctx.InsertFront(func_ast->body->statements, ctx.dst->Decl(local_var)); local_private_vars_.insert(var); @@ -428,7 +428,7 @@ struct ModuleScopeVarToEntryPointParam::State { is_wrapped); } else { ProcessVariableInUserFunction(func_ast, var, new_var_symbol, is_pointer); - if (var->AddressSpace() == type::AddressSpace::kWorkgroup) { + if (var->AddressSpace() == builtin::AddressSpace::kWorkgroup) { needs_pointer_aliasing = true; } } @@ -453,7 +453,7 @@ struct ModuleScopeVarToEntryPointParam::State { 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), type::AddressSpace::kWorkgroup); + ctx.dst->ty.pointer(ctx.dst->ty.Of(str), builtin::AddressSpace::kWorkgroup); auto* param = ctx.dst->Param( workgroup_param(), param_type, utils::Vector{ @@ -472,7 +472,7 @@ struct ModuleScopeVarToEntryPointParam::State { // For entry points, pass non-handle types as pointers. for (auto* target_var : target_sem->TransitivelyReferencedGlobals()) { auto sc = target_var->AddressSpace(); - if (sc == type::AddressSpace::kUndefined) { + if (sc == builtin::AddressSpace::kUndefined) { continue; } @@ -503,7 +503,7 @@ struct ModuleScopeVarToEntryPointParam::State { // Now remove all module-scope variables with these address spaces. for (auto* var_ast : ctx.src->AST().GlobalVariables()) { auto* var_sem = ctx.src->Sem().Get(var_ast); - if (var_sem->AddressSpace() != type::AddressSpace::kUndefined) { + if (var_sem->AddressSpace() != builtin::AddressSpace::kUndefined) { ctx.Remove(ctx.src->AST().GlobalDeclarations(), var_ast); } } diff --git a/src/tint/transform/multiplanar_external_texture.cc b/src/tint/transform/multiplanar_external_texture.cc index 06dfba4735..cf8092d71a 100644 --- a/src/tint/transform/multiplanar_external_texture.cc +++ b/src/tint/transform/multiplanar_external_texture.cc @@ -144,7 +144,7 @@ struct MultiplanarExternalTexture::State { b.GlobalVar(syms.plane_1, b.ty.sampled_texture(type::TextureDimension::k2d, b.ty.f32()), b.Group(AInt(bps.plane_1.group)), b.Binding(AInt(bps.plane_1.binding))); syms.params = b.Symbols().New("ext_tex_params"); - b.GlobalVar(syms.params, b.ty("ExternalTextureParams"), type::AddressSpace::kUniform, + b.GlobalVar(syms.params, b.ty("ExternalTextureParams"), builtin::AddressSpace::kUniform, b.Group(AInt(bps.params.group)), b.Binding(AInt(bps.params.binding))); // Replace the original texture_external binding with a texture_2d binding. diff --git a/src/tint/transform/num_workgroups_from_uniform.cc b/src/tint/transform/num_workgroups_from_uniform.cc index 35e59fbc30..a62cf429fc 100644 --- a/src/tint/transform/num_workgroups_from_uniform.cc +++ b/src/tint/transform/num_workgroups_from_uniform.cc @@ -158,9 +158,9 @@ Transform::ApplyResult NumWorkgroupsFromUniform::Apply(const Program* src, binding = 0; } - num_workgroups_ubo = - b.GlobalVar(b.Sym(), b.ty.Of(num_workgroups_struct), type::AddressSpace::kUniform, - b.Group(AInt(group)), b.Binding(AInt(binding))); + num_workgroups_ubo = b.GlobalVar(b.Sym(), b.ty.Of(num_workgroups_struct), + builtin::AddressSpace::kUniform, b.Group(AInt(group)), + b.Binding(AInt(binding))); } return num_workgroups_ubo; }; diff --git a/src/tint/transform/pad_structs.cc b/src/tint/transform/pad_structs.cc index 954069cc00..eef67eb49c 100644 --- a/src/tint/transform/pad_structs.cc +++ b/src/tint/transform/pad_structs.cc @@ -80,7 +80,7 @@ Transform::ApplyResult PadStructs::Apply(const Program* src, const DataMap&, Dat new_members.Push(b.Member(name, type)); uint32_t size = ty->Size(); - if (ty->Is() && str->UsedAs(type::AddressSpace::kUniform)) { + if (ty->Is() && str->UsedAs(builtin::AddressSpace::kUniform)) { // std140 structs should be padded out to 16 bytes. size = utils::RoundUp(16u, size); } else if (auto* array_ty = ty->As()) { @@ -93,7 +93,7 @@ Transform::ApplyResult PadStructs::Apply(const Program* src, const DataMap&, Dat // Add any required padding after the last member, if it's not a runtime-sized array. uint32_t struct_size = str->Size(); - if (str->UsedAs(type::AddressSpace::kUniform)) { + if (str->UsedAs(builtin::AddressSpace::kUniform)) { struct_size = utils::RoundUp(16u, struct_size); } if (offset < struct_size && !has_runtime_sized_array) { diff --git a/src/tint/transform/preserve_padding.cc b/src/tint/transform/preserve_padding.cc index 1dbd2afad0..cb5a8ee028 100644 --- a/src/tint/transform/preserve_padding.cc +++ b/src/tint/transform/preserve_padding.cc @@ -53,7 +53,8 @@ struct PreservePadding::State { // Ignore phony assignment. return; } - if (ty->As()->AddressSpace() != type::AddressSpace::kStorage) { + if (ty->As()->AddressSpace() != + builtin::AddressSpace::kStorage) { // We only care about assignments that write to variables in the storage // address space, as nothing else is host-visible. return; @@ -120,7 +121,7 @@ struct PreservePadding::State { auto helper_name = b.Symbols().New("assign_and_preserve_padding"); utils::Vector params = { b.Param(kDestParamName, - b.ty.pointer(CreateASTTypeFor(ctx, ty), type::AddressSpace::kStorage, + b.ty.pointer(CreateASTTypeFor(ctx, ty), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite)), b.Param(kValueParamName, CreateASTTypeFor(ctx, ty)), }; diff --git a/src/tint/transform/renamer_test.cc b/src/tint/transform/renamer_test.cc index d4b681cda2..04e2b9931d 100644 --- a/src/tint/transform/renamer_test.cc +++ b/src/tint/transform/renamer_test.cc @@ -1926,7 +1926,7 @@ std::vector Identifiers() { for (auto* ident : type::kBuiltinStrings) { out.push_back(ident); } - for (auto* ident : type::kAddressSpaceStrings) { + for (auto* ident : builtin::kAddressSpaceStrings) { if (!utils::HasPrefix(ident, "_")) { out.push_back(ident); } diff --git a/src/tint/transform/robustness.cc b/src/tint/transform/robustness.cc index 579d6843d6..c6bf218d68 100644 --- a/src/tint/transform/robustness.cc +++ b/src/tint/transform/robustness.cc @@ -38,7 +38,7 @@ struct Robustness::State { /// Constructor /// @param program the source program /// @param omitted the omitted address spaces - State(const Program* program, std::unordered_set&& omitted) + State(const Program* program, std::unordered_set&& omitted) : src(program), omitted_address_spaces(std::move(omitted)) {} /// Runs the transform @@ -60,7 +60,7 @@ struct Robustness::State { CloneContext ctx = {&b, src, /* auto_clone_symbols */ true}; /// Set of address spaces to not apply the transform to - std::unordered_set omitted_address_spaces; + std::unordered_set omitted_address_spaces; /// Apply bounds clamping to array, vector and matrix indexing /// @param expr the array, vector or matrix index expression @@ -294,14 +294,14 @@ Transform::ApplyResult Robustness::Apply(const Program* src, cfg = *cfg_data; } - std::unordered_set omitted_address_spaces; + std::unordered_set omitted_address_spaces; for (auto sc : cfg.omitted_address_spaces) { switch (sc) { case AddressSpace::kUniform: - omitted_address_spaces.insert(type::AddressSpace::kUniform); + omitted_address_spaces.insert(builtin::AddressSpace::kUniform); break; case AddressSpace::kStorage: - omitted_address_spaces.insert(type::AddressSpace::kStorage); + omitted_address_spaces.insert(builtin::AddressSpace::kStorage); break; } } diff --git a/src/tint/transform/std140.cc b/src/tint/transform/std140.cc index a19d78f73c..7a9cffc1d6 100644 --- a/src/tint/transform/std140.cc +++ b/src/tint/transform/std140.cc @@ -144,7 +144,7 @@ struct Std140::State { // Scan structures for members that need forking for (auto* ty : src->Types()) { if (auto* str = ty->As()) { - if (str->UsedAs(type::AddressSpace::kUniform)) { + if (str->UsedAs(builtin::AddressSpace::kUniform)) { for (auto* member : str->Members()) { if (needs_fork(member->Type())) { return true; @@ -157,7 +157,7 @@ struct Std140::State { // Scan uniform variables that have types that need forking for (auto* decl : src->AST().GlobalVariables()) { auto* global = src->Sem().Get(decl); - if (global->AddressSpace() == type::AddressSpace::kUniform) { + if (global->AddressSpace() == builtin::AddressSpace::kUniform) { if (needs_fork(global->Type()->UnwrapRef())) { return true; } @@ -280,7 +280,7 @@ struct Std140::State { for (auto* global : src->Sem().Module()->DependencyOrderedDeclarations()) { // Check to see if this is a structure used by a uniform buffer... auto* str = sem.Get(global); - if (str && str->UsedAs(type::AddressSpace::kUniform)) { + if (str && str->UsedAs(builtin::AddressSpace::kUniform)) { // Should this uniform buffer be forked for std140 usage? bool fork_std140 = false; utils::Vector members; @@ -351,7 +351,7 @@ struct Std140::State { for (auto* global : src->AST().GlobalVariables()) { if (auto* var = global->As()) { auto* v = sem.Get(var); - if (v->AddressSpace() == type::AddressSpace::kUniform) { + if (v->AddressSpace() == builtin::AddressSpace::kUniform) { if (auto std140_ty = Std140Type(v->Type()->UnwrapRef())) { ctx.Replace(global->type.expr, b.Expr(std140_ty)); std140_uniforms.Add(v); diff --git a/src/tint/transform/vertex_pulling.cc b/src/tint/transform/vertex_pulling.cc index 6a1b5b4506..9faddb7f15 100644 --- a/src/tint/transform/vertex_pulling.cc +++ b/src/tint/transform/vertex_pulling.cc @@ -321,8 +321,8 @@ struct VertexPulling::State { }); for (uint32_t i = 0; i < cfg.vertex_state.size(); ++i) { // The decorated variable with struct type - b.GlobalVar(GetVertexBufferName(i), b.ty.Of(struct_type), type::AddressSpace::kStorage, - builtin::Access::kRead, b.Binding(AInt(i)), + b.GlobalVar(GetVertexBufferName(i), b.ty.Of(struct_type), + builtin::AddressSpace::kStorage, builtin::Access::kRead, b.Binding(AInt(i)), b.Group(AInt(cfg.pulling_group))); } } diff --git a/src/tint/transform/zero_init_workgroup_memory.cc b/src/tint/transform/zero_init_workgroup_memory.cc index 015a25bfd7..2071abcb46 100644 --- a/src/tint/transform/zero_init_workgroup_memory.cc +++ b/src/tint/transform/zero_init_workgroup_memory.cc @@ -37,7 +37,7 @@ bool ShouldRun(const Program* program) { for (auto* global : program->AST().GlobalVariables()) { if (auto* var = global->As()) { auto* v = program->Sem().Get(var); - if (v->AddressSpace() == type::AddressSpace::kWorkgroup) { + if (v->AddressSpace() == builtin::AddressSpace::kWorkgroup) { return true; } } @@ -140,7 +140,7 @@ struct ZeroInitWorkgroupMemory::State { // workgroup storage variables used by `fn`. This will populate #statements. auto* func = sem.Get(fn); for (auto* var : func->TransitivelyReferencedGlobals()) { - if (var->AddressSpace() == type::AddressSpace::kWorkgroup) { + if (var->AddressSpace() == builtin::AddressSpace::kWorkgroup) { auto get_expr = [&](uint32_t num_values) { auto var_name = ctx.Clone(var->Declaration()->name->symbol); return Expression{b.Expr(var_name), num_values, ArrayIndices{}}; diff --git a/src/tint/type/pointer.cc b/src/tint/type/pointer.cc index 1175961f0f..17bbe1a33c 100644 --- a/src/tint/type/pointer.cc +++ b/src/tint/type/pointer.cc @@ -24,7 +24,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::Pointer); namespace tint::type { -Pointer::Pointer(const Type* subtype, type::AddressSpace address_space, builtin::Access access) +Pointer::Pointer(const Type* subtype, builtin::AddressSpace address_space, builtin::Access access) : Base(utils::Hash(TypeInfo::Of().full_hashcode, address_space, subtype, access), type::Flags{}), subtype_(subtype), @@ -45,7 +45,7 @@ bool Pointer::Equals(const UniqueNode& other) const { std::string Pointer::FriendlyName(const SymbolTable& symbols) const { std::ostringstream out; out << "ptr<"; - if (address_space_ != AddressSpace::kUndefined) { + if (address_space_ != builtin::AddressSpace::kUndefined) { out << address_space_ << ", "; } out << subtype_->FriendlyName(symbols) << ", " << access_; diff --git a/src/tint/type/pointer.h b/src/tint/type/pointer.h index 8a4d1c9340..6e73999629 100644 --- a/src/tint/type/pointer.h +++ b/src/tint/type/pointer.h @@ -18,7 +18,7 @@ #include #include "src/tint/builtin/access.h" -#include "src/tint/type/address_space.h" +#include "src/tint/builtin/address_space.h" #include "src/tint/type/type.h" namespace tint::type { @@ -30,7 +30,7 @@ class Pointer final : public Castable { /// @param subtype the pointee type /// @param address_space the address space of the pointer /// @param access the resolved access control of the reference - Pointer(const Type* subtype, type::AddressSpace address_space, builtin::Access access); + Pointer(const Type* subtype, builtin::AddressSpace address_space, builtin::Access access); /// Destructor ~Pointer() override; @@ -43,7 +43,7 @@ class Pointer final : public Castable { const Type* StoreType() const { return subtype_; } /// @returns the address space of the pointer - type::AddressSpace AddressSpace() const { return address_space_; } + builtin::AddressSpace AddressSpace() const { return address_space_; } /// @returns the access control of the reference builtin::Access Access() const { return access_; } @@ -59,7 +59,7 @@ class Pointer final : public Castable { private: Type const* const subtype_; - type::AddressSpace const address_space_; + builtin::AddressSpace const address_space_; builtin::Access const access_; }; diff --git a/src/tint/type/pointer_test.cc b/src/tint/type/pointer_test.cc index 932548ae1c..ff030cc66d 100644 --- a/src/tint/type/pointer_test.cc +++ b/src/tint/type/pointer_test.cc @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "src/tint/builtin/address_space.h" #include "src/tint/type/test_helper.h" #include "src/tint/type/texture.h" @@ -21,14 +22,19 @@ namespace { using PointerTest = TestHelper; TEST_F(PointerTest, Creation) { - auto* a = create(create(), AddressSpace::kStorage, builtin::Access::kReadWrite); - auto* b = create(create(), AddressSpace::kStorage, builtin::Access::kReadWrite); - auto* c = create(create(), AddressSpace::kStorage, builtin::Access::kReadWrite); - auto* d = create(create(), AddressSpace::kPrivate, builtin::Access::kReadWrite); - auto* e = create(create(), AddressSpace::kStorage, builtin::Access::kRead); + auto* a = create(create(), builtin::AddressSpace::kStorage, + builtin::Access::kReadWrite); + auto* b = create(create(), builtin::AddressSpace::kStorage, + builtin::Access::kReadWrite); + auto* c = create(create(), builtin::AddressSpace::kStorage, + builtin::Access::kReadWrite); + auto* d = create(create(), builtin::AddressSpace::kPrivate, + builtin::Access::kReadWrite); + auto* e = + create(create(), builtin::AddressSpace::kStorage, builtin::Access::kRead); EXPECT_TRUE(a->StoreType()->Is()); - EXPECT_EQ(a->AddressSpace(), AddressSpace::kStorage); + EXPECT_EQ(a->AddressSpace(), builtin::AddressSpace::kStorage); EXPECT_EQ(a->Access(), builtin::Access::kReadWrite); EXPECT_EQ(a, b); @@ -38,18 +44,25 @@ TEST_F(PointerTest, Creation) { } TEST_F(PointerTest, Hash) { - auto* a = create(create(), AddressSpace::kStorage, builtin::Access::kReadWrite); - auto* b = create(create(), AddressSpace::kStorage, builtin::Access::kReadWrite); + auto* a = create(create(), builtin::AddressSpace::kStorage, + builtin::Access::kReadWrite); + auto* b = create(create(), builtin::AddressSpace::kStorage, + builtin::Access::kReadWrite); EXPECT_EQ(a->unique_hash, b->unique_hash); } TEST_F(PointerTest, Equals) { - auto* a = create(create(), AddressSpace::kStorage, builtin::Access::kReadWrite); - auto* b = create(create(), AddressSpace::kStorage, builtin::Access::kReadWrite); - auto* c = create(create(), AddressSpace::kStorage, builtin::Access::kReadWrite); - auto* d = create(create(), AddressSpace::kPrivate, builtin::Access::kReadWrite); - auto* e = create(create(), AddressSpace::kStorage, builtin::Access::kRead); + auto* a = create(create(), builtin::AddressSpace::kStorage, + builtin::Access::kReadWrite); + auto* b = create(create(), builtin::AddressSpace::kStorage, + builtin::Access::kReadWrite); + auto* c = create(create(), builtin::AddressSpace::kStorage, + builtin::Access::kReadWrite); + auto* d = create(create(), builtin::AddressSpace::kPrivate, + builtin::Access::kReadWrite); + auto* e = + create(create(), builtin::AddressSpace::kStorage, builtin::Access::kRead); EXPECT_TRUE(a->Equals(*b)); EXPECT_FALSE(a->Equals(*c)); @@ -59,24 +72,27 @@ TEST_F(PointerTest, Equals) { } TEST_F(PointerTest, FriendlyName) { - auto* r = create(create(), AddressSpace::kUndefined, builtin::Access::kRead); + auto* r = + create(create(), builtin::AddressSpace::kUndefined, builtin::Access::kRead); EXPECT_EQ(r->FriendlyName(Symbols()), "ptr"); } TEST_F(PointerTest, FriendlyNameWithAddressSpace) { - auto* r = create(create(), AddressSpace::kWorkgroup, builtin::Access::kRead); + auto* r = + create(create(), builtin::AddressSpace::kWorkgroup, builtin::Access::kRead); EXPECT_EQ(r->FriendlyName(Symbols()), "ptr"); } TEST_F(PointerTest, Clone) { - auto* a = create(create(), AddressSpace::kStorage, builtin::Access::kReadWrite); + auto* a = create(create(), builtin::AddressSpace::kStorage, + builtin::Access::kReadWrite); type::Manager mgr; type::CloneContext ctx{{nullptr}, {nullptr, &mgr}}; auto* ptr = a->Clone(ctx); EXPECT_TRUE(ptr->StoreType()->Is()); - EXPECT_EQ(ptr->AddressSpace(), AddressSpace::kStorage); + EXPECT_EQ(ptr->AddressSpace(), builtin::AddressSpace::kStorage); EXPECT_EQ(ptr->Access(), builtin::Access::kReadWrite); } diff --git a/src/tint/type/reference.cc b/src/tint/type/reference.cc index ca676ccedb..5db6300512 100644 --- a/src/tint/type/reference.cc +++ b/src/tint/type/reference.cc @@ -23,7 +23,9 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::Reference); namespace tint::type { -Reference::Reference(const Type* subtype, type::AddressSpace address_space, builtin::Access access) +Reference::Reference(const Type* subtype, + builtin::AddressSpace address_space, + builtin::Access access) : Base(utils::Hash(TypeInfo::Of().full_hashcode, address_space, subtype, access), type::Flags{}), subtype_(subtype), @@ -44,7 +46,7 @@ bool Reference::Equals(const UniqueNode& other) const { std::string Reference::FriendlyName(const SymbolTable& symbols) const { std::ostringstream out; out << "ref<"; - if (address_space_ != AddressSpace::kUndefined) { + if (address_space_ != builtin::AddressSpace::kUndefined) { out << address_space_ << ", "; } out << subtype_->FriendlyName(symbols) << ", " << access_; diff --git a/src/tint/type/reference.h b/src/tint/type/reference.h index b1981ab059..8bc5e33e28 100644 --- a/src/tint/type/reference.h +++ b/src/tint/type/reference.h @@ -18,7 +18,7 @@ #include #include "src/tint/builtin/access.h" -#include "src/tint/type/address_space.h" +#include "src/tint/builtin/address_space.h" #include "src/tint/type/type.h" namespace tint::type { @@ -30,7 +30,7 @@ class Reference final : public Castable { /// @param subtype the pointee type /// @param address_space the address space of the reference /// @param access the resolved access control of the reference - Reference(const Type* subtype, type::AddressSpace address_space, builtin::Access access); + Reference(const Type* subtype, builtin::AddressSpace address_space, builtin::Access access); /// Destructor ~Reference() override; @@ -43,7 +43,7 @@ class Reference final : public Castable { const Type* StoreType() const { return subtype_; } /// @returns the address space of the reference - type::AddressSpace AddressSpace() const { return address_space_; } + builtin::AddressSpace AddressSpace() const { return address_space_; } /// @returns the resolved access control of the reference. builtin::Access Access() const { return access_; } @@ -59,7 +59,7 @@ class Reference final : public Castable { private: Type const* const subtype_; - type::AddressSpace const address_space_; + builtin::AddressSpace const address_space_; builtin::Access const access_; }; diff --git a/src/tint/type/reference_test.cc b/src/tint/type/reference_test.cc index 65dde2bd9a..634b17ae73 100644 --- a/src/tint/type/reference_test.cc +++ b/src/tint/type/reference_test.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "src/tint/type/reference.h" +#include "src/tint/builtin/address_space.h" #include "src/tint/type/test_helper.h" namespace tint::type { @@ -21,14 +22,19 @@ namespace { using ReferenceTest = TestHelper; TEST_F(ReferenceTest, Creation) { - auto* a = create(create(), AddressSpace::kStorage, builtin::Access::kReadWrite); - auto* b = create(create(), AddressSpace::kStorage, builtin::Access::kReadWrite); - auto* c = create(create(), AddressSpace::kStorage, builtin::Access::kReadWrite); - auto* d = create(create(), AddressSpace::kPrivate, builtin::Access::kReadWrite); - auto* e = create(create(), AddressSpace::kStorage, builtin::Access::kRead); + auto* a = create(create(), builtin::AddressSpace::kStorage, + builtin::Access::kReadWrite); + auto* b = create(create(), builtin::AddressSpace::kStorage, + builtin::Access::kReadWrite); + auto* c = create(create(), builtin::AddressSpace::kStorage, + builtin::Access::kReadWrite); + auto* d = create(create(), builtin::AddressSpace::kPrivate, + builtin::Access::kReadWrite); + auto* e = + create(create(), builtin::AddressSpace::kStorage, builtin::Access::kRead); EXPECT_TRUE(a->StoreType()->Is()); - EXPECT_EQ(a->AddressSpace(), AddressSpace::kStorage); + EXPECT_EQ(a->AddressSpace(), builtin::AddressSpace::kStorage); EXPECT_EQ(a->Access(), builtin::Access::kReadWrite); EXPECT_EQ(a, b); @@ -38,18 +44,25 @@ TEST_F(ReferenceTest, Creation) { } TEST_F(ReferenceTest, Hash) { - auto* a = create(create(), AddressSpace::kStorage, builtin::Access::kReadWrite); - auto* b = create(create(), AddressSpace::kStorage, builtin::Access::kReadWrite); + auto* a = create(create(), builtin::AddressSpace::kStorage, + builtin::Access::kReadWrite); + auto* b = create(create(), builtin::AddressSpace::kStorage, + builtin::Access::kReadWrite); EXPECT_EQ(a->unique_hash, b->unique_hash); } TEST_F(ReferenceTest, Equals) { - auto* a = create(create(), AddressSpace::kStorage, builtin::Access::kReadWrite); - auto* b = create(create(), AddressSpace::kStorage, builtin::Access::kReadWrite); - auto* c = create(create(), AddressSpace::kStorage, builtin::Access::kReadWrite); - auto* d = create(create(), AddressSpace::kPrivate, builtin::Access::kReadWrite); - auto* e = create(create(), AddressSpace::kStorage, builtin::Access::kRead); + auto* a = create(create(), builtin::AddressSpace::kStorage, + builtin::Access::kReadWrite); + auto* b = create(create(), builtin::AddressSpace::kStorage, + builtin::Access::kReadWrite); + auto* c = create(create(), builtin::AddressSpace::kStorage, + builtin::Access::kReadWrite); + auto* d = create(create(), builtin::AddressSpace::kPrivate, + builtin::Access::kReadWrite); + auto* e = + create(create(), builtin::AddressSpace::kStorage, builtin::Access::kRead); EXPECT_TRUE(a->Equals(*b)); EXPECT_FALSE(a->Equals(*c)); @@ -59,24 +72,27 @@ TEST_F(ReferenceTest, Equals) { } TEST_F(ReferenceTest, FriendlyName) { - auto* r = create(create(), AddressSpace::kUndefined, builtin::Access::kRead); + auto* r = + create(create(), builtin::AddressSpace::kUndefined, builtin::Access::kRead); EXPECT_EQ(r->FriendlyName(Symbols()), "ref"); } TEST_F(ReferenceTest, FriendlyNameWithAddressSpace) { - auto* r = create(create(), AddressSpace::kWorkgroup, builtin::Access::kRead); + auto* r = + create(create(), builtin::AddressSpace::kWorkgroup, builtin::Access::kRead); EXPECT_EQ(r->FriendlyName(Symbols()), "ref"); } TEST_F(ReferenceTest, Clone) { - auto* a = create(create(), AddressSpace::kStorage, builtin::Access::kReadWrite); + auto* a = create(create(), builtin::AddressSpace::kStorage, + builtin::Access::kReadWrite); type::Manager mgr; type::CloneContext ctx{{nullptr}, {nullptr, &mgr}}; auto* ref = a->Clone(ctx); EXPECT_TRUE(ref->StoreType()->Is()); - EXPECT_EQ(ref->AddressSpace(), AddressSpace::kStorage); + EXPECT_EQ(ref->AddressSpace(), builtin::AddressSpace::kStorage); EXPECT_EQ(ref->Access(), builtin::Access::kReadWrite); } diff --git a/src/tint/type/struct.h b/src/tint/type/struct.h index e80dcc1ea9..013011134a 100644 --- a/src/tint/type/struct.h +++ b/src/tint/type/struct.h @@ -21,8 +21,8 @@ #include #include +#include "src/tint/builtin/address_space.h" #include "src/tint/symbol.h" -#include "src/tint/type/address_space.h" #include "src/tint/type/node.h" #include "src/tint/type/type.h" #include "src/tint/utils/vector.h" @@ -100,22 +100,22 @@ class Struct : public Castable { /// Adds the AddressSpace usage to the structure. /// @param usage the storage usage - void AddUsage(AddressSpace usage) { address_space_usage_.emplace(usage); } + void AddUsage(builtin::AddressSpace usage) { address_space_usage_.emplace(usage); } /// @returns the set of address space uses of this structure - const std::unordered_set& AddressSpaceUsage() const { + const std::unordered_set& AddressSpaceUsage() const { return address_space_usage_; } /// @param usage the AddressSpace usage type to query /// @returns true iff this structure has been used as the given address space - bool UsedAs(AddressSpace usage) const { return address_space_usage_.count(usage) > 0; } + bool UsedAs(builtin::AddressSpace usage) const { return address_space_usage_.count(usage) > 0; } /// @returns true iff this structure has been used by address space that's /// host-shareable. bool IsHostShareable() const { for (auto sc : address_space_usage_) { - if (type::IsHostShareable(sc)) { + if (builtin::IsHostShareable(sc)) { return true; } } @@ -160,7 +160,7 @@ class Struct : public Castable { const uint32_t align_; const uint32_t size_; const uint32_t size_no_padding_; - std::unordered_set address_space_usage_; + std::unordered_set address_space_usage_; std::unordered_set pipeline_stage_uses_; utils::Vector concrete_types_; }; diff --git a/src/tint/type/type_test.cc b/src/tint/type/type_test.cc index f6adb9378a..1565e10902 100644 --- a/src/tint/type/type_test.cc +++ b/src/tint/type/type_test.cc @@ -44,7 +44,7 @@ struct TypeTest : public TestHelper { const Matrix* mat4x3_f16 = create(vec3_f16, 4u); const Matrix* mat4x3_af = create(vec3_af, 4u); const Reference* ref_u32 = - create(u32, AddressSpace::kPrivate, builtin::Access::kReadWrite); + create(u32, builtin::AddressSpace::kPrivate, builtin::Access::kReadWrite); const Struct* str_f32 = create(Source{}, Sym("str_f32"), utils::Vector{ diff --git a/src/tint/writer/append_vector.cc b/src/tint/writer/append_vector.cc index 53f11dbe67..c212378be1 100644 --- a/src/tint/writer/append_vector.cc +++ b/src/tint/writer/append_vector.cc @@ -137,7 +137,8 @@ const sem::Call* AppendVector(ProgramBuilder* b, auto* scalar_cast_target = b->create( packed_el_sem_ty, b->create(nullptr, 0u, scalar_sem->Type()->UnwrapRef(), - type::AddressSpace::kUndefined, builtin::Access::kUndefined), + builtin::AddressSpace::kUndefined, + builtin::Access::kUndefined), sem::EvaluationStage::kRuntime); auto* scalar_cast_sem = b->create( scalar_cast_ast, scalar_cast_target, sem::EvaluationStage::kRuntime, @@ -160,7 +161,7 @@ const sem::Call* AppendVector(ProgramBuilder* b, [&](const tint::sem::ValueExpression* arg, size_t i) -> const sem::Parameter* { return b->create( nullptr, static_cast(i), arg->Type()->UnwrapRef(), - type::AddressSpace::kUndefined, builtin::Access::kUndefined); + builtin::AddressSpace::kUndefined, builtin::Access::kUndefined); }), sem::EvaluationStage::kRuntime); auto* initializer_sem = diff --git a/src/tint/writer/append_vector_test.cc b/src/tint/writer/append_vector_test.cc index feded0c854..8f2491684d 100644 --- a/src/tint/writer/append_vector_test.cc +++ b/src/tint/writer/append_vector_test.cc @@ -252,7 +252,7 @@ TEST_F(AppendVectorTest, Vec3i32_i32) { // AppendVector(vec_12, 3) -> vec3(vec_12, 3) TEST_F(AppendVectorTest, Vec2i32Var_i32) { - GlobalVar("vec_12", ty.vec2(), type::AddressSpace::kPrivate); + GlobalVar("vec_12", ty.vec2(), builtin::AddressSpace::kPrivate); auto* vec_12 = Expr("vec_12"); auto* scalar_3 = Expr(3_i); WrapInFunction(vec_12, scalar_3); @@ -288,7 +288,7 @@ TEST_F(AppendVectorTest, Vec2i32Var_i32) { // AppendVector(1, 2, scalar_3) -> vec3(1, 2, scalar_3) TEST_F(AppendVectorTest, Vec2i32_i32Var) { - GlobalVar("scalar_3", ty.i32(), type::AddressSpace::kPrivate); + GlobalVar("scalar_3", ty.i32(), builtin::AddressSpace::kPrivate); auto* scalar_1 = Expr(1_i); auto* scalar_2 = Expr(2_i); auto* scalar_3 = Expr("scalar_3"); @@ -329,8 +329,8 @@ TEST_F(AppendVectorTest, Vec2i32_i32Var) { // AppendVector(vec_12, scalar_3) -> vec3(vec_12, scalar_3) TEST_F(AppendVectorTest, Vec2i32Var_i32Var) { - GlobalVar("vec_12", ty.vec2(), type::AddressSpace::kPrivate); - GlobalVar("scalar_3", ty.i32(), type::AddressSpace::kPrivate); + GlobalVar("vec_12", ty.vec2(), builtin::AddressSpace::kPrivate); + GlobalVar("scalar_3", ty.i32(), builtin::AddressSpace::kPrivate); auto* vec_12 = Expr("vec_12"); auto* scalar_3 = Expr("scalar_3"); WrapInFunction(vec_12, scalar_3); @@ -366,8 +366,8 @@ TEST_F(AppendVectorTest, Vec2i32Var_i32Var) { // AppendVector(vec_12, scalar_3) -> vec3(vec_12, i32(scalar_3)) TEST_F(AppendVectorTest, Vec2i32Var_f32Var) { - GlobalVar("vec_12", ty.vec2(), type::AddressSpace::kPrivate); - GlobalVar("scalar_3", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("vec_12", ty.vec2(), builtin::AddressSpace::kPrivate); + GlobalVar("scalar_3", ty.f32(), builtin::AddressSpace::kPrivate); auto* vec_12 = Expr("vec_12"); auto* scalar_3 = Expr("scalar_3"); WrapInFunction(vec_12, scalar_3); @@ -407,8 +407,8 @@ TEST_F(AppendVectorTest, Vec2i32Var_f32Var) { // AppendVector(vec_12, scalar_3) -> vec3(vec_12, scalar_3) TEST_F(AppendVectorTest, Vec2boolVar_boolVar) { - GlobalVar("vec_12", ty.vec2(), type::AddressSpace::kPrivate); - GlobalVar("scalar_3", ty.bool_(), type::AddressSpace::kPrivate); + GlobalVar("vec_12", ty.vec2(), builtin::AddressSpace::kPrivate); + GlobalVar("scalar_3", ty.bool_(), builtin::AddressSpace::kPrivate); auto* vec_12 = Expr("vec_12"); auto* scalar_3 = Expr("scalar_3"); WrapInFunction(vec_12, scalar_3); diff --git a/src/tint/writer/flatten_bindings_test.cc b/src/tint/writer/flatten_bindings_test.cc index 3b0c7a6d73..53d1a7ab95 100644 --- a/src/tint/writer/flatten_bindings_test.cc +++ b/src/tint/writer/flatten_bindings_test.cc @@ -39,9 +39,9 @@ TEST_F(FlattenBindingsTest, NoBindings) { TEST_F(FlattenBindingsTest, AlreadyFlat) { ProgramBuilder b; - b.GlobalVar("a", b.ty.i32(), type::AddressSpace::kUniform, b.Group(0_a), b.Binding(0_a)); - b.GlobalVar("b", b.ty.i32(), type::AddressSpace::kUniform, b.Group(0_a), b.Binding(1_a)); - b.GlobalVar("c", b.ty.i32(), type::AddressSpace::kUniform, b.Group(0_a), b.Binding(2_a)); + b.GlobalVar("a", b.ty.i32(), builtin::AddressSpace::kUniform, b.Group(0_a), b.Binding(0_a)); + b.GlobalVar("b", b.ty.i32(), builtin::AddressSpace::kUniform, b.Group(0_a), b.Binding(1_a)); + b.GlobalVar("c", b.ty.i32(), builtin::AddressSpace::kUniform, b.Group(0_a), b.Binding(2_a)); Program program(std::move(b)); ASSERT_TRUE(program.IsValid()) << program.Diagnostics().str(); @@ -52,9 +52,9 @@ TEST_F(FlattenBindingsTest, AlreadyFlat) { TEST_F(FlattenBindingsTest, NotFlat_SingleNamespace) { ProgramBuilder b; - b.GlobalVar("a", b.ty.i32(), type::AddressSpace::kUniform, b.Group(0_a), b.Binding(0_a)); - b.GlobalVar("b", b.ty.i32(), type::AddressSpace::kUniform, b.Group(1_a), b.Binding(1_a)); - b.GlobalVar("c", b.ty.i32(), type::AddressSpace::kUniform, b.Group(2_a), b.Binding(2_a)); + b.GlobalVar("a", b.ty.i32(), builtin::AddressSpace::kUniform, b.Group(0_a), b.Binding(0_a)); + b.GlobalVar("b", b.ty.i32(), builtin::AddressSpace::kUniform, b.Group(1_a), b.Binding(1_a)); + b.GlobalVar("c", b.ty.i32(), builtin::AddressSpace::kUniform, b.Group(2_a), b.Binding(2_a)); b.WrapInFunction(b.Expr("a"), b.Expr("b"), b.Expr("c")); Program program(std::move(b)); @@ -85,9 +85,11 @@ TEST_F(FlattenBindingsTest, NotFlat_MultipleNamespaces) { ProgramBuilder b; const size_t num_buffers = 3; - b.GlobalVar("buffer1", b.ty.i32(), type::AddressSpace::kUniform, b.Group(0_a), b.Binding(0_a)); - b.GlobalVar("buffer2", b.ty.i32(), type::AddressSpace::kStorage, b.Group(1_a), b.Binding(1_a)); - b.GlobalVar("buffer3", b.ty.i32(), type::AddressSpace::kStorage, builtin::Access::kRead, + b.GlobalVar("buffer1", b.ty.i32(), builtin::AddressSpace::kUniform, b.Group(0_a), + b.Binding(0_a)); + b.GlobalVar("buffer2", b.ty.i32(), builtin::AddressSpace::kStorage, b.Group(1_a), + b.Binding(1_a)); + b.GlobalVar("buffer3", b.ty.i32(), builtin::AddressSpace::kStorage, builtin::Access::kRead, b.Group(2_a), b.Binding(2_a)); const size_t num_samplers = 2; diff --git a/src/tint/writer/generate_external_texture_bindings_test.cc b/src/tint/writer/generate_external_texture_bindings_test.cc index e4415172c6..d6b22acb8b 100644 --- a/src/tint/writer/generate_external_texture_bindings_test.cc +++ b/src/tint/writer/generate_external_texture_bindings_test.cc @@ -23,7 +23,7 @@ namespace { using namespace tint::number_suffixes; // NOLINT -constexpr auto kUniform = type::AddressSpace::kUniform; +constexpr auto kUniform = builtin::AddressSpace::kUniform; class GenerateExternalTextureBindingsTest : public ::testing::Test {}; diff --git a/src/tint/writer/glsl/generator_impl.cc b/src/tint/writer/glsl/generator_impl.cc index 76a0d18753..c06d82f537 100644 --- a/src/tint/writer/glsl/generator_impl.cc +++ b/src/tint/writer/glsl/generator_impl.cc @@ -374,7 +374,7 @@ bool GeneratorImpl::EmitBitcast(std::ostream& out, const ast::BitcastExpression* dst_type->is_float_scalar_or_vector()) { out << "uintBitsToFloat"; } else { - if (!EmitType(out, dst_type, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, + if (!EmitType(out, dst_type, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) { return false; } @@ -438,13 +438,13 @@ bool GeneratorImpl::EmitBitwiseBoolOp(std::ostream& out, const ast::BinaryExpres auto* uint_type = BoolTypeToUint(bool_type); // Cast result to bool scalar or vector type. - if (!EmitType(out, bool_type, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, + if (!EmitType(out, bool_type, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) { return false; } ScopedParen outerCastParen(out); // Cast LHS to uint scalar or vector type. - if (!EmitType(out, uint_type, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, + if (!EmitType(out, uint_type, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) { return false; } @@ -465,7 +465,7 @@ bool GeneratorImpl::EmitBitwiseBoolOp(std::ostream& out, const ast::BinaryExpres return false; } // Cast RHS to uint scalar or vector type. - if (!EmitType(out, uint_type, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, + if (!EmitType(out, uint_type, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) { return false; } @@ -493,20 +493,20 @@ bool GeneratorImpl::EmitFloatModulo(std::ostream& out, const ast::BinaryExpressi std::vector parameter_names; { auto decl = line(&b); - if (!EmitTypeAndName(decl, ret_ty, type::AddressSpace::kUndefined, + if (!EmitTypeAndName(decl, ret_ty, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, fn_name)) { return ""; } { ScopedParen sp(decl); const auto* ty = TypeOf(expr->lhs)->UnwrapRef(); - if (!EmitTypeAndName(decl, ty, type::AddressSpace::kUndefined, + if (!EmitTypeAndName(decl, ty, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, "lhs")) { return ""; } decl << ", "; ty = TypeOf(expr->rhs)->UnwrapRef(); - if (!EmitTypeAndName(decl, ty, type::AddressSpace::kUndefined, + if (!EmitTypeAndName(decl, ty, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, "rhs")) { return ""; } @@ -830,8 +830,8 @@ bool GeneratorImpl::EmitBuiltinCall(std::ostream& out, bool GeneratorImpl::EmitTypeConversion(std::ostream& out, const sem::Call* call, const sem::TypeConversion* conv) { - if (!EmitType(out, conv->Target(), type::AddressSpace::kUndefined, builtin::Access::kReadWrite, - "")) { + if (!EmitType(out, conv->Target(), builtin::AddressSpace::kUndefined, + builtin::Access::kReadWrite, "")) { return false; } ScopedParen sp(out); @@ -854,7 +854,7 @@ bool GeneratorImpl::EmitTypeInitializer(std::ostream& out, return EmitZeroValue(out, type); } - if (!EmitType(out, type, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) { + if (!EmitType(out, type, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) { return false; } ScopedParen sp(out); @@ -924,7 +924,7 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out, { auto pre = line(); - if (!EmitTypeAndName(pre, builtin->ReturnType(), type::AddressSpace::kUndefined, + if (!EmitTypeAndName(pre, builtin->ReturnType(), builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, result)) { return false; } @@ -1062,7 +1062,7 @@ bool GeneratorImpl::EmitEmulatedFMA(std::ostream& out, const ast::CallExpression bool GeneratorImpl::EmitCountOneBitsCall(std::ostream& out, const ast::CallExpression* expr) { // GLSL's bitCount returns an integer type, so cast it to the appropriate // unsigned type. - if (!EmitType(out, TypeOf(expr)->UnwrapRef(), type::AddressSpace::kUndefined, + if (!EmitType(out, TypeOf(expr)->UnwrapRef(), builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) { return false; } @@ -1134,7 +1134,7 @@ bool GeneratorImpl::EmitDotCall(std::ostream& out, std::string v; { std::stringstream s; - if (!EmitType(s, vec_ty->type(), type::AddressSpace::kUndefined, + if (!EmitType(s, vec_ty->type(), builtin::AddressSpace::kUndefined, builtin::Access::kRead, "")) { return ""; } @@ -1142,17 +1142,17 @@ bool GeneratorImpl::EmitDotCall(std::ostream& out, } { // (u)int tint_int_dot([i|u]vecN a, [i|u]vecN b) { auto l = line(&b); - if (!EmitType(l, vec_ty->type(), type::AddressSpace::kUndefined, + if (!EmitType(l, vec_ty->type(), builtin::AddressSpace::kUndefined, builtin::Access::kRead, "")) { return ""; } l << " " << fn_name << "("; - if (!EmitType(l, vec_ty, type::AddressSpace::kUndefined, builtin::Access::kRead, + if (!EmitType(l, vec_ty, builtin::AddressSpace::kUndefined, builtin::Access::kRead, "")) { return ""; } l << " a, "; - if (!EmitType(l, vec_ty, type::AddressSpace::kUndefined, builtin::Access::kRead, + if (!EmitType(l, vec_ty, builtin::AddressSpace::kUndefined, builtin::Access::kRead, "")) { return ""; } @@ -1204,7 +1204,7 @@ bool GeneratorImpl::EmitModfCall(std::ostream& out, { auto l = line(b); - if (!EmitType(l, builtin->ReturnType(), type::AddressSpace::kUndefined, + if (!EmitType(l, builtin->ReturnType(), builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, "")) { return false; } @@ -1230,7 +1230,7 @@ bool GeneratorImpl::EmitFrexpCall(std::ostream& out, { auto l = line(b); - if (!EmitType(l, builtin->ReturnType(), type::AddressSpace::kUndefined, + if (!EmitType(l, builtin->ReturnType(), builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, "")) { return false; } @@ -1888,7 +1888,7 @@ bool GeneratorImpl::EmitFunction(const ast::Function* func) { { auto out = line(); auto name = builder_.Symbols().NameFor(func->name->symbol); - if (!EmitType(out, sem->ReturnType(), type::AddressSpace::kUndefined, + if (!EmitType(out, sem->ReturnType(), builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) { return false; } @@ -1944,20 +1944,20 @@ bool GeneratorImpl::EmitGlobalVariable(const ast::Variable* global) { [&](const ast::Var* var) { auto* sem = builder_.Sem().Get(global); switch (sem->AddressSpace()) { - case type::AddressSpace::kUniform: + case builtin::AddressSpace::kUniform: return EmitUniformVariable(var, sem); - case type::AddressSpace::kStorage: + case builtin::AddressSpace::kStorage: return EmitStorageVariable(var, sem); - case type::AddressSpace::kHandle: + case builtin::AddressSpace::kHandle: return EmitHandleVariable(var, sem); - case type::AddressSpace::kPrivate: + case builtin::AddressSpace::kPrivate: return EmitPrivateVariable(sem); - case type::AddressSpace::kWorkgroup: + case builtin::AddressSpace::kWorkgroup: return EmitWorkgroupVariable(sem); - case type::AddressSpace::kIn: - case type::AddressSpace::kOut: + case builtin::AddressSpace::kIn: + case builtin::AddressSpace::kOut: return EmitIOVariable(sem); - case type::AddressSpace::kPushConstant: + case builtin::AddressSpace::kPushConstant: diagnostics_.add_error( diag::System::Writer, "unhandled address space " + utils::ToString(sem->AddressSpace())); @@ -2265,7 +2265,7 @@ bool GeneratorImpl::EmitEntryPointFunction(const ast::Function* func) { // Emit original entry point signature { auto out = line(); - if (!EmitTypeAndName(out, func_sem->ReturnType(), type::AddressSpace::kUndefined, + if (!EmitTypeAndName(out, func_sem->ReturnType(), builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, builder_.Symbols().NameFor(func->name->symbol))) { return false; @@ -2346,7 +2346,7 @@ bool GeneratorImpl::EmitConstant(std::ostream& out, const constant::Value* const return true; }, [&](const type::Vector* v) { - if (!EmitType(out, v, type::AddressSpace::kUndefined, builtin::Access::kUndefined, + if (!EmitType(out, v, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, "")) { return false; } @@ -2368,7 +2368,7 @@ bool GeneratorImpl::EmitConstant(std::ostream& out, const constant::Value* const return true; }, [&](const type::Matrix* m) { - if (!EmitType(out, m, type::AddressSpace::kUndefined, builtin::Access::kUndefined, + if (!EmitType(out, m, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, "")) { return false; } @@ -2386,7 +2386,7 @@ bool GeneratorImpl::EmitConstant(std::ostream& out, const constant::Value* const return true; }, [&](const type::Array* a) { - if (!EmitType(out, a, type::AddressSpace::kUndefined, builtin::Access::kUndefined, + if (!EmitType(out, a, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, "")) { return false; } @@ -2479,7 +2479,8 @@ bool GeneratorImpl::EmitZeroValue(std::ostream& out, const type::Type* type) { } else if (type->Is()) { out << "0u"; } else if (auto* vec = type->As()) { - if (!EmitType(out, type, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) { + if (!EmitType(out, type, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, + "")) { return false; } ScopedParen sp(out); @@ -2492,7 +2493,8 @@ bool GeneratorImpl::EmitZeroValue(std::ostream& out, const type::Type* type) { } } } else if (auto* mat = type->As()) { - if (!EmitType(out, type, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) { + if (!EmitType(out, type, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, + "")) { return false; } ScopedParen sp(out); @@ -2505,7 +2507,8 @@ bool GeneratorImpl::EmitZeroValue(std::ostream& out, const type::Type* type) { } } } else if (auto* str = type->As()) { - if (!EmitType(out, type, type::AddressSpace::kUndefined, builtin::Access::kUndefined, "")) { + if (!EmitType(out, type, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, + "")) { return false; } bool first = true; @@ -2519,7 +2522,8 @@ bool GeneratorImpl::EmitZeroValue(std::ostream& out, const type::Type* type) { EmitZeroValue(out, member->Type()); } } else if (auto* arr = type->As()) { - if (!EmitType(out, type, type::AddressSpace::kUndefined, builtin::Access::kUndefined, "")) { + if (!EmitType(out, type, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, + "")) { return false; } ScopedParen sp(out); @@ -2844,7 +2848,7 @@ bool GeneratorImpl::EmitSwitch(const ast::SwitchStatement* stmt) { bool GeneratorImpl::EmitType(std::ostream& out, const type::Type* type, - type::AddressSpace address_space, + builtin::AddressSpace address_space, builtin::Access access, const std::string& name, bool* name_printed /* = nullptr */) { @@ -2852,16 +2856,16 @@ bool GeneratorImpl::EmitType(std::ostream& out, *name_printed = false; } switch (address_space) { - case type::AddressSpace::kIn: { + case builtin::AddressSpace::kIn: { out << "in "; break; } - case type::AddressSpace::kOut: { + case builtin::AddressSpace::kOut: { out << "out "; break; } - case type::AddressSpace::kUniform: - case type::AddressSpace::kHandle: { + case builtin::AddressSpace::kUniform: + case builtin::AddressSpace::kHandle: { out << "uniform "; break; } @@ -3025,7 +3029,7 @@ bool GeneratorImpl::EmitType(std::ostream& out, bool GeneratorImpl::EmitTypeAndName(std::ostream& out, const type::Type* type, - type::AddressSpace address_space, + builtin::AddressSpace address_space, builtin::Access access, const std::string& name) { bool printed_name = false; @@ -3062,8 +3066,8 @@ bool GeneratorImpl::EmitStructMembers(TextBuffer* b, const sem::Struct* str) { auto out = line(b); - if (!EmitTypeAndName(out, ty, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, - name)) { + if (!EmitTypeAndName(out, ty, builtin::AddressSpace::kUndefined, + builtin::Access::kReadWrite, name)) { return false; } out << ";"; @@ -3131,7 +3135,7 @@ bool GeneratorImpl::EmitLet(const ast::Let* let) { auto out = line(); // TODO(senorblanco): handle const - if (!EmitTypeAndName(out, type, type::AddressSpace::kUndefined, builtin::Access::kUndefined, + if (!EmitTypeAndName(out, type, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, builder_.Symbols().NameFor(let->name->symbol))) { return false; } @@ -3153,7 +3157,7 @@ bool GeneratorImpl::EmitProgramConstVariable(const ast::Variable* var) { auto out = line(); out << "const "; - if (!EmitTypeAndName(out, type, type::AddressSpace::kUndefined, builtin::Access::kUndefined, + if (!EmitTypeAndName(out, type, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, builder_.Symbols().NameFor(var->name->symbol))) { return false; } @@ -3180,7 +3184,7 @@ bool GeneratorImpl::CallBuiltinHelper(std::ostream& out, std::vector parameter_names; { auto decl = line(&b); - if (!EmitTypeAndName(decl, builtin->ReturnType(), type::AddressSpace::kUndefined, + if (!EmitTypeAndName(decl, builtin->ReturnType(), builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, fn_name)) { return ""; } @@ -3196,7 +3200,7 @@ bool GeneratorImpl::CallBuiltinHelper(std::ostream& out, decl << "inout "; ty = ptr->StoreType(); } - if (!EmitTypeAndName(decl, ty, type::AddressSpace::kUndefined, + if (!EmitTypeAndName(decl, ty, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, param_name)) { return ""; } diff --git a/src/tint/writer/glsl/generator_impl.h b/src/tint/writer/glsl/generator_impl.h index d01500012e..629566d8ae 100644 --- a/src/tint/writer/glsl/generator_impl.h +++ b/src/tint/writer/glsl/generator_impl.h @@ -414,7 +414,7 @@ class GeneratorImpl : public TextGenerator { /// @returns true if the type is emitted bool EmitType(std::ostream& out, const type::Type* type, - type::AddressSpace address_space, + builtin::AddressSpace address_space, builtin::Access access, const std::string& name, bool* name_printed = nullptr); @@ -427,7 +427,7 @@ class GeneratorImpl : public TextGenerator { /// @returns true if the type is emitted bool EmitTypeAndName(std::ostream& out, const type::Type* type, - type::AddressSpace address_space, + builtin::AddressSpace address_space, builtin::Access access, const std::string& name); /// Handles generating a structure declaration. If the structure has already been emitted, then diff --git a/src/tint/writer/glsl/generator_impl_array_accessor_test.cc b/src/tint/writer/glsl/generator_impl_array_accessor_test.cc index cee4506c32..bd405d38e9 100644 --- a/src/tint/writer/glsl/generator_impl_array_accessor_test.cc +++ b/src/tint/writer/glsl/generator_impl_array_accessor_test.cc @@ -22,7 +22,7 @@ namespace { using GlslGeneratorImplTest_Expression = TestHelper; TEST_F(GlslGeneratorImplTest_Expression, IndexAccessor) { - GlobalVar("ary", ty.array(), type::AddressSpace::kPrivate); + GlobalVar("ary", ty.array(), builtin::AddressSpace::kPrivate); auto* expr = IndexAccessor("ary", 5_i); WrapInFunction(expr); diff --git a/src/tint/writer/glsl/generator_impl_assign_test.cc b/src/tint/writer/glsl/generator_impl_assign_test.cc index 73d950cb62..d53d39f742 100644 --- a/src/tint/writer/glsl/generator_impl_assign_test.cc +++ b/src/tint/writer/glsl/generator_impl_assign_test.cc @@ -20,8 +20,8 @@ namespace { using GlslGeneratorImplTest_Assign = TestHelper; TEST_F(GlslGeneratorImplTest_Assign, Emit_Assign) { - GlobalVar("lhs", ty.i32(), type::AddressSpace::kPrivate); - GlobalVar("rhs", ty.i32(), type::AddressSpace::kPrivate); + GlobalVar("lhs", ty.i32(), builtin::AddressSpace::kPrivate); + GlobalVar("rhs", ty.i32(), builtin::AddressSpace::kPrivate); auto* assign = Assign("lhs", "rhs"); WrapInFunction(assign); diff --git a/src/tint/writer/glsl/generator_impl_binary_test.cc b/src/tint/writer/glsl/generator_impl_binary_test.cc index 72eddc7dcc..f90a428ad9 100644 --- a/src/tint/writer/glsl/generator_impl_binary_test.cc +++ b/src/tint/writer/glsl/generator_impl_binary_test.cc @@ -43,8 +43,8 @@ TEST_P(GlslBinaryTest, Emit_f32) { return; } - GlobalVar("left", ty.f32(), type::AddressSpace::kPrivate); - GlobalVar("right", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("left", ty.f32(), builtin::AddressSpace::kPrivate); + GlobalVar("right", ty.f32(), builtin::AddressSpace::kPrivate); auto* left = Expr("left"); auto* right = Expr("right"); @@ -71,8 +71,8 @@ TEST_P(GlslBinaryTest, Emit_f16) { Enable(builtin::Extension::kF16); - GlobalVar("left", ty.f16(), type::AddressSpace::kPrivate); - GlobalVar("right", ty.f16(), type::AddressSpace::kPrivate); + GlobalVar("left", ty.f16(), builtin::AddressSpace::kPrivate); + GlobalVar("right", ty.f16(), builtin::AddressSpace::kPrivate); auto* left = Expr("left"); auto* right = Expr("right"); @@ -90,8 +90,8 @@ TEST_P(GlslBinaryTest, Emit_f16) { TEST_P(GlslBinaryTest, Emit_u32) { auto params = GetParam(); - GlobalVar("left", ty.u32(), type::AddressSpace::kPrivate); - GlobalVar("right", ty.u32(), type::AddressSpace::kPrivate); + GlobalVar("left", ty.u32(), builtin::AddressSpace::kPrivate); + GlobalVar("right", ty.u32(), builtin::AddressSpace::kPrivate); auto* left = Expr("left"); auto* right = Expr("right"); @@ -114,8 +114,8 @@ TEST_P(GlslBinaryTest, Emit_i32) { return; } - GlobalVar("left", ty.i32(), type::AddressSpace::kPrivate); - GlobalVar("right", ty.i32(), type::AddressSpace::kPrivate); + GlobalVar("left", ty.i32(), builtin::AddressSpace::kPrivate); + GlobalVar("right", ty.i32(), builtin::AddressSpace::kPrivate); auto* left = Expr("left"); auto* right = Expr("right"); @@ -151,7 +151,7 @@ INSTANTIATE_TEST_SUITE_P( BinaryData{"(left % right)", ast::BinaryOp::kModulo})); TEST_F(GlslGeneratorImplTest_Binary, Multiply_VectorScalar_f32) { - GlobalVar("a", vec3(1_f, 1_f, 1_f), type::AddressSpace::kPrivate); + GlobalVar("a", vec3(1_f, 1_f, 1_f), builtin::AddressSpace::kPrivate); auto* lhs = Expr("a"); auto* rhs = Expr(1_f); @@ -169,7 +169,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_VectorScalar_f32) { TEST_F(GlslGeneratorImplTest_Binary, Multiply_VectorScalar_f16) { Enable(builtin::Extension::kF16); - GlobalVar("a", vec3(1_h, 1_h, 1_h), type::AddressSpace::kPrivate); + GlobalVar("a", vec3(1_h, 1_h, 1_h), builtin::AddressSpace::kPrivate); auto* lhs = Expr("a"); auto* rhs = Expr(1_h); @@ -185,7 +185,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_VectorScalar_f16) { } TEST_F(GlslGeneratorImplTest_Binary, Multiply_ScalarVector_f32) { - GlobalVar("a", vec3(1_f, 1_f, 1_f), type::AddressSpace::kPrivate); + GlobalVar("a", vec3(1_f, 1_f, 1_f), builtin::AddressSpace::kPrivate); auto* lhs = Expr(1_f); auto* rhs = Expr("a"); @@ -203,7 +203,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_ScalarVector_f32) { TEST_F(GlslGeneratorImplTest_Binary, Multiply_ScalarVector_f16) { Enable(builtin::Extension::kF16); - GlobalVar("a", vec3(1_h, 1_h, 1_h), type::AddressSpace::kPrivate); + GlobalVar("a", vec3(1_h, 1_h, 1_h), builtin::AddressSpace::kPrivate); auto* lhs = Expr(1_h); auto* rhs = Expr("a"); @@ -219,7 +219,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_ScalarVector_f16) { } TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixScalar_f32) { - GlobalVar("mat", ty.mat3x3(), type::AddressSpace::kPrivate); + GlobalVar("mat", ty.mat3x3(), builtin::AddressSpace::kPrivate); auto* lhs = Expr("mat"); auto* rhs = Expr(1_f); @@ -236,7 +236,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixScalar_f32) { TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixScalar_f16) { Enable(builtin::Extension::kF16); - GlobalVar("mat", ty.mat3x3(), type::AddressSpace::kPrivate); + GlobalVar("mat", ty.mat3x3(), builtin::AddressSpace::kPrivate); auto* lhs = Expr("mat"); auto* rhs = Expr(1_h); @@ -251,7 +251,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixScalar_f16) { } TEST_F(GlslGeneratorImplTest_Binary, Multiply_ScalarMatrix_f32) { - GlobalVar("mat", ty.mat3x3(), type::AddressSpace::kPrivate); + GlobalVar("mat", ty.mat3x3(), builtin::AddressSpace::kPrivate); auto* lhs = Expr(1_f); auto* rhs = Expr("mat"); @@ -268,7 +268,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_ScalarMatrix_f32) { TEST_F(GlslGeneratorImplTest_Binary, Multiply_ScalarMatrix_f16) { Enable(builtin::Extension::kF16); - GlobalVar("mat", ty.mat3x3(), type::AddressSpace::kPrivate); + GlobalVar("mat", ty.mat3x3(), builtin::AddressSpace::kPrivate); auto* lhs = Expr(1_h); auto* rhs = Expr("mat"); @@ -283,7 +283,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_ScalarMatrix_f16) { } TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixVector_f32) { - GlobalVar("mat", ty.mat3x3(), type::AddressSpace::kPrivate); + GlobalVar("mat", ty.mat3x3(), builtin::AddressSpace::kPrivate); auto* lhs = Expr("mat"); auto* rhs = vec3(1_f, 1_f, 1_f); @@ -300,7 +300,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixVector_f32) { TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixVector_f16) { Enable(builtin::Extension::kF16); - GlobalVar("mat", ty.mat3x3(), type::AddressSpace::kPrivate); + GlobalVar("mat", ty.mat3x3(), builtin::AddressSpace::kPrivate); auto* lhs = Expr("mat"); auto* rhs = vec3(1_h, 1_h, 1_h); @@ -315,7 +315,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixVector_f16) { } TEST_F(GlslGeneratorImplTest_Binary, Multiply_VectorMatrix_f32) { - GlobalVar("mat", ty.mat3x3(), type::AddressSpace::kPrivate); + GlobalVar("mat", ty.mat3x3(), builtin::AddressSpace::kPrivate); auto* lhs = vec3(1_f, 1_f, 1_f); auto* rhs = Expr("mat"); @@ -332,7 +332,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_VectorMatrix_f32) { TEST_F(GlslGeneratorImplTest_Binary, Multiply_VectorMatrix_f16) { Enable(builtin::Extension::kF16); - GlobalVar("mat", ty.mat3x3(), type::AddressSpace::kPrivate); + GlobalVar("mat", ty.mat3x3(), builtin::AddressSpace::kPrivate); auto* lhs = vec3(1_h, 1_h, 1_h); auto* rhs = Expr("mat"); @@ -347,8 +347,8 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_VectorMatrix_f16) { } TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixMatrix_f32) { - GlobalVar("lhs", ty.mat3x3(), type::AddressSpace::kPrivate); - GlobalVar("rhs", ty.mat3x3(), type::AddressSpace::kPrivate); + GlobalVar("lhs", ty.mat3x3(), builtin::AddressSpace::kPrivate); + GlobalVar("rhs", ty.mat3x3(), builtin::AddressSpace::kPrivate); auto* expr = create(ast::BinaryOp::kMultiply, Expr("lhs"), Expr("rhs")); WrapInFunction(expr); @@ -363,8 +363,8 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixMatrix_f32) { TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixMatrix_f16) { Enable(builtin::Extension::kF16); - GlobalVar("lhs", ty.mat3x3(), type::AddressSpace::kPrivate); - GlobalVar("rhs", ty.mat3x3(), type::AddressSpace::kPrivate); + GlobalVar("lhs", ty.mat3x3(), builtin::AddressSpace::kPrivate); + GlobalVar("rhs", ty.mat3x3(), builtin::AddressSpace::kPrivate); auto* expr = create(ast::BinaryOp::kMultiply, Expr("lhs"), Expr("rhs")); WrapInFunction(expr); @@ -377,8 +377,8 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixMatrix_f16) { } TEST_F(GlslGeneratorImplTest_Binary, ModF32) { - GlobalVar("a", ty.f32(), type::AddressSpace::kPrivate); - GlobalVar("b", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("a", ty.f32(), builtin::AddressSpace::kPrivate); + GlobalVar("b", ty.f32(), builtin::AddressSpace::kPrivate); auto* expr = create(ast::BinaryOp::kModulo, Expr("a"), Expr("b")); WrapInFunction(expr); @@ -393,8 +393,8 @@ TEST_F(GlslGeneratorImplTest_Binary, ModF32) { TEST_F(GlslGeneratorImplTest_Binary, ModF16) { Enable(builtin::Extension::kF16); - GlobalVar("a", ty.f16(), type::AddressSpace::kPrivate); - GlobalVar("b", ty.f16(), type::AddressSpace::kPrivate); + GlobalVar("a", ty.f16(), builtin::AddressSpace::kPrivate); + GlobalVar("b", ty.f16(), builtin::AddressSpace::kPrivate); auto* expr = create(ast::BinaryOp::kModulo, Expr("a"), Expr("b")); WrapInFunction(expr); @@ -407,8 +407,8 @@ TEST_F(GlslGeneratorImplTest_Binary, ModF16) { } TEST_F(GlslGeneratorImplTest_Binary, ModVec3F32) { - GlobalVar("a", ty.vec3(), type::AddressSpace::kPrivate); - GlobalVar("b", ty.vec3(), type::AddressSpace::kPrivate); + GlobalVar("a", ty.vec3(), builtin::AddressSpace::kPrivate); + GlobalVar("b", ty.vec3(), builtin::AddressSpace::kPrivate); auto* expr = create(ast::BinaryOp::kModulo, Expr("a"), Expr("b")); WrapInFunction(expr); @@ -423,8 +423,8 @@ TEST_F(GlslGeneratorImplTest_Binary, ModVec3F32) { TEST_F(GlslGeneratorImplTest_Binary, ModVec3F16) { Enable(builtin::Extension::kF16); - GlobalVar("a", ty.vec3(), type::AddressSpace::kPrivate); - GlobalVar("b", ty.vec3(), type::AddressSpace::kPrivate); + GlobalVar("a", ty.vec3(), builtin::AddressSpace::kPrivate); + GlobalVar("b", ty.vec3(), builtin::AddressSpace::kPrivate); auto* expr = create(ast::BinaryOp::kModulo, Expr("a"), Expr("b")); WrapInFunction(expr); @@ -437,8 +437,8 @@ TEST_F(GlslGeneratorImplTest_Binary, ModVec3F16) { } TEST_F(GlslGeneratorImplTest_Binary, ModVec3F32ScalarF32) { - GlobalVar("a", ty.vec3(), type::AddressSpace::kPrivate); - GlobalVar("b", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("a", ty.vec3(), builtin::AddressSpace::kPrivate); + GlobalVar("b", ty.f32(), builtin::AddressSpace::kPrivate); auto* expr = create(ast::BinaryOp::kModulo, Expr("a"), Expr("b")); WrapInFunction(expr); @@ -453,8 +453,8 @@ TEST_F(GlslGeneratorImplTest_Binary, ModVec3F32ScalarF32) { TEST_F(GlslGeneratorImplTest_Binary, ModVec3F16ScalarF16) { Enable(builtin::Extension::kF16); - GlobalVar("a", ty.vec3(), type::AddressSpace::kPrivate); - GlobalVar("b", ty.f16(), type::AddressSpace::kPrivate); + GlobalVar("a", ty.vec3(), builtin::AddressSpace::kPrivate); + GlobalVar("b", ty.f16(), builtin::AddressSpace::kPrivate); auto* expr = create(ast::BinaryOp::kModulo, Expr("a"), Expr("b")); WrapInFunction(expr); @@ -467,8 +467,8 @@ TEST_F(GlslGeneratorImplTest_Binary, ModVec3F16ScalarF16) { } TEST_F(GlslGeneratorImplTest_Binary, ModScalarF32Vec3F32) { - GlobalVar("a", ty.f32(), type::AddressSpace::kPrivate); - GlobalVar("b", ty.vec3(), type::AddressSpace::kPrivate); + GlobalVar("a", ty.f32(), builtin::AddressSpace::kPrivate); + GlobalVar("b", ty.vec3(), builtin::AddressSpace::kPrivate); auto* expr = create(ast::BinaryOp::kModulo, Expr("a"), Expr("b")); WrapInFunction(expr); @@ -483,8 +483,8 @@ TEST_F(GlslGeneratorImplTest_Binary, ModScalarF32Vec3F32) { TEST_F(GlslGeneratorImplTest_Binary, ModScalarF16Vec3F16) { Enable(builtin::Extension::kF16); - GlobalVar("a", ty.f16(), type::AddressSpace::kPrivate); - GlobalVar("b", ty.vec3(), type::AddressSpace::kPrivate); + GlobalVar("a", ty.f16(), builtin::AddressSpace::kPrivate); + GlobalVar("b", ty.vec3(), builtin::AddressSpace::kPrivate); auto* expr = create(ast::BinaryOp::kModulo, Expr("a"), Expr("b")); WrapInFunction(expr); @@ -497,8 +497,8 @@ TEST_F(GlslGeneratorImplTest_Binary, ModScalarF16Vec3F16) { } TEST_F(GlslGeneratorImplTest_Binary, ModMixedVec3ScalarF32) { - GlobalVar("a", ty.vec3(), type::AddressSpace::kPrivate); - GlobalVar("b", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("a", ty.vec3(), builtin::AddressSpace::kPrivate); + GlobalVar("b", ty.f32(), builtin::AddressSpace::kPrivate); auto* expr_vec_mod_vec = create(ast::BinaryOp::kModulo, Expr("a"), Expr("a")); @@ -541,8 +541,8 @@ void test_function() { TEST_F(GlslGeneratorImplTest_Binary, ModMixedVec3ScalarF16) { Enable(builtin::Extension::kF16); - GlobalVar("a", ty.vec3(), type::AddressSpace::kPrivate); - GlobalVar("b", ty.f16(), type::AddressSpace::kPrivate); + GlobalVar("a", ty.vec3(), builtin::AddressSpace::kPrivate); + GlobalVar("b", ty.f16(), builtin::AddressSpace::kPrivate); auto* expr_vec_mod_vec = create(ast::BinaryOp::kModulo, Expr("a"), Expr("a")); @@ -584,8 +584,8 @@ void test_function() { } TEST_F(GlslGeneratorImplTest_Binary, Logical_And) { - GlobalVar("a", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("b", ty.bool_(), type::AddressSpace::kPrivate); + GlobalVar("a", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("b", ty.bool_(), builtin::AddressSpace::kPrivate); auto* expr = create(ast::BinaryOp::kLogicalAnd, Expr("a"), Expr("b")); WrapInFunction(expr); @@ -604,10 +604,10 @@ if (tint_tmp) { TEST_F(GlslGeneratorImplTest_Binary, Logical_Multi) { // (a && b) || (c || d) - GlobalVar("a", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("b", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("c", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("d", ty.bool_(), type::AddressSpace::kPrivate); + GlobalVar("a", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("b", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("c", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("d", ty.bool_(), builtin::AddressSpace::kPrivate); auto* expr = create( ast::BinaryOp::kLogicalOr, @@ -636,8 +636,8 @@ if (!tint_tmp) { } TEST_F(GlslGeneratorImplTest_Binary, Logical_Or) { - GlobalVar("a", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("b", ty.bool_(), type::AddressSpace::kPrivate); + GlobalVar("a", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("b", ty.bool_(), builtin::AddressSpace::kPrivate); auto* expr = create(ast::BinaryOp::kLogicalOr, Expr("a"), Expr("b")); WrapInFunction(expr); @@ -663,9 +663,9 @@ TEST_F(GlslGeneratorImplTest_Binary, If_WithLogical) { // return 3i; // } - GlobalVar("a", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("b", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("c", ty.bool_(), type::AddressSpace::kPrivate); + GlobalVar("a", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("b", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("c", ty.bool_(), builtin::AddressSpace::kPrivate); auto* expr = If(create(ast::BinaryOp::kLogicalAnd, Expr("a"), Expr("b")), @@ -700,9 +700,9 @@ if ((tint_tmp)) { TEST_F(GlslGeneratorImplTest_Binary, Return_WithLogical) { // return (a && b) || c; - GlobalVar("a", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("b", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("c", ty.bool_(), type::AddressSpace::kPrivate); + GlobalVar("a", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("b", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("c", ty.bool_(), builtin::AddressSpace::kPrivate); auto* expr = Return(create( ast::BinaryOp::kLogicalOr, @@ -728,10 +728,10 @@ return (tint_tmp); TEST_F(GlslGeneratorImplTest_Binary, Assign_WithLogical) { // a = (b || c) && d; - GlobalVar("a", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("b", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("c", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("d", ty.bool_(), type::AddressSpace::kPrivate); + GlobalVar("a", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("b", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("c", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("d", ty.bool_(), builtin::AddressSpace::kPrivate); auto* expr = Assign(Expr("a"), @@ -759,9 +759,9 @@ a = (tint_tmp); TEST_F(GlslGeneratorImplTest_Binary, Decl_WithLogical) { // var a : bool = (b && c) || d; - GlobalVar("b", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("c", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("d", ty.bool_(), type::AddressSpace::kPrivate); + GlobalVar("b", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("c", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("d", ty.bool_(), builtin::AddressSpace::kPrivate); auto* var = Var("a", ty.bool_(), @@ -798,10 +798,10 @@ TEST_F(GlslGeneratorImplTest_Binary, Call_WithLogical) { Param(Sym(), ty.bool_()), }, ty.void_(), utils::Empty, utils::Empty); - GlobalVar("a", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("b", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("c", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("d", ty.bool_(), type::AddressSpace::kPrivate); + GlobalVar("a", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("b", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("c", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("d", ty.bool_(), builtin::AddressSpace::kPrivate); utils::Vector params{ create(ast::BinaryOp::kLogicalAnd, Expr("a"), Expr("b")), diff --git a/src/tint/writer/glsl/generator_impl_builtin_test.cc b/src/tint/writer/glsl/generator_impl_builtin_test.cc index 7526494c04..dc6f28b209 100644 --- a/src/tint/writer/glsl/generator_impl_builtin_test.cc +++ b/src/tint/writer/glsl/generator_impl_builtin_test.cc @@ -198,19 +198,19 @@ TEST_P(GlslBuiltinTest, Emit) { if (param.type == CallParamType::kF16) { Enable(builtin::Extension::kF16); - GlobalVar("h2", ty.vec2(), type::AddressSpace::kPrivate); - GlobalVar("h3", ty.vec3(), type::AddressSpace::kPrivate); - GlobalVar("hm2x2", ty.mat2x2(), type::AddressSpace::kPrivate); - GlobalVar("hm3x2", ty.mat3x2(), type::AddressSpace::kPrivate); + GlobalVar("h2", ty.vec2(), builtin::AddressSpace::kPrivate); + GlobalVar("h3", ty.vec3(), builtin::AddressSpace::kPrivate); + GlobalVar("hm2x2", ty.mat2x2(), builtin::AddressSpace::kPrivate); + GlobalVar("hm3x2", ty.mat3x2(), builtin::AddressSpace::kPrivate); } - GlobalVar("f2", ty.vec2(), type::AddressSpace::kPrivate); - GlobalVar("f3", ty.vec3(), type::AddressSpace::kPrivate); - GlobalVar("u2", ty.vec2(), type::AddressSpace::kPrivate); - GlobalVar("i2", ty.vec2(), type::AddressSpace::kPrivate); - GlobalVar("b2", ty.vec2(), type::AddressSpace::kPrivate); - GlobalVar("m2x2", ty.mat2x2(), type::AddressSpace::kPrivate); - GlobalVar("m3x2", ty.mat3x2(), type::AddressSpace::kPrivate); + GlobalVar("f2", ty.vec2(), builtin::AddressSpace::kPrivate); + GlobalVar("f3", ty.vec3(), builtin::AddressSpace::kPrivate); + GlobalVar("u2", ty.vec2(), builtin::AddressSpace::kPrivate); + GlobalVar("i2", ty.vec2(), builtin::AddressSpace::kPrivate); + GlobalVar("b2", ty.vec2(), builtin::AddressSpace::kPrivate); + GlobalVar("m2x2", ty.mat2x2(), builtin::AddressSpace::kPrivate); + GlobalVar("m3x2", ty.mat3x2(), builtin::AddressSpace::kPrivate); auto* call = GenerateCall(param.builtin, param.type, this); ASSERT_NE(nullptr, call) << "Unhandled builtin"; @@ -342,8 +342,8 @@ INSTANTIATE_TEST_SUITE_P( TEST_F(GlslGeneratorImplTest_Builtin, Builtin_Call) { auto* call = Call("dot", "param1", "param2"); - GlobalVar("param1", ty.vec3(), type::AddressSpace::kPrivate); - GlobalVar("param2", ty.vec3(), type::AddressSpace::kPrivate); + GlobalVar("param1", ty.vec3(), builtin::AddressSpace::kPrivate); + GlobalVar("param2", ty.vec3(), builtin::AddressSpace::kPrivate); WrapInFunction(CallStmt(call)); @@ -356,8 +356,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Builtin_Call) { } TEST_F(GlslGeneratorImplTest_Builtin, Select_Scalar) { - GlobalVar("a", Expr(1_f), type::AddressSpace::kPrivate); - GlobalVar("b", Expr(2_f), type::AddressSpace::kPrivate); + GlobalVar("a", Expr(1_f), builtin::AddressSpace::kPrivate); + GlobalVar("b", Expr(2_f), builtin::AddressSpace::kPrivate); auto* call = Call("select", "a", "b", true); WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); @@ -369,8 +369,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Select_Scalar) { } TEST_F(GlslGeneratorImplTest_Builtin, Select_Vector) { - GlobalVar("a", vec2(1_i, 2_i), type::AddressSpace::kPrivate); - GlobalVar("b", vec2(3_i, 4_i), type::AddressSpace::kPrivate); + GlobalVar("a", vec2(1_i, 2_i), builtin::AddressSpace::kPrivate); + GlobalVar("b", vec2(3_i, 4_i), builtin::AddressSpace::kPrivate); auto* call = Call("select", "a", "b", vec2(true, false)); WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); @@ -384,9 +384,9 @@ TEST_F(GlslGeneratorImplTest_Builtin, Select_Vector) { TEST_F(GlslGeneratorImplTest_Builtin, FMA_f32) { auto* call = Call("fma", "a", "b", "c"); - GlobalVar("a", ty.vec3(), type::AddressSpace::kPrivate); - GlobalVar("b", ty.vec3(), type::AddressSpace::kPrivate); - GlobalVar("c", ty.vec3(), type::AddressSpace::kPrivate); + GlobalVar("a", ty.vec3(), builtin::AddressSpace::kPrivate); + GlobalVar("b", ty.vec3(), builtin::AddressSpace::kPrivate); + GlobalVar("c", ty.vec3(), builtin::AddressSpace::kPrivate); WrapInFunction(CallStmt(call)); @@ -401,9 +401,9 @@ TEST_F(GlslGeneratorImplTest_Builtin, FMA_f32) { TEST_F(GlslGeneratorImplTest_Builtin, FMA_f16) { Enable(builtin::Extension::kF16); - GlobalVar("a", ty.vec3(), type::AddressSpace::kPrivate); - GlobalVar("b", ty.vec3(), type::AddressSpace::kPrivate); - GlobalVar("c", ty.vec3(), type::AddressSpace::kPrivate); + GlobalVar("a", ty.vec3(), builtin::AddressSpace::kPrivate); + GlobalVar("b", ty.vec3(), builtin::AddressSpace::kPrivate); + GlobalVar("c", ty.vec3(), builtin::AddressSpace::kPrivate); auto* call = Call("fma", "a", "b", "c"); WrapInFunction(CallStmt(call)); @@ -1226,7 +1226,7 @@ void main() { TEST_F(GlslGeneratorImplTest_Builtin, Pack4x8Snorm) { auto* call = Call("pack4x8snorm", "p1"); - GlobalVar("p1", ty.vec4(), type::AddressSpace::kPrivate); + GlobalVar("p1", ty.vec4(), builtin::AddressSpace::kPrivate); WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); @@ -1244,7 +1244,7 @@ void test_function() { TEST_F(GlslGeneratorImplTest_Builtin, Pack4x8Unorm) { auto* call = Call("pack4x8unorm", "p1"); - GlobalVar("p1", ty.vec4(), type::AddressSpace::kPrivate); + GlobalVar("p1", ty.vec4(), builtin::AddressSpace::kPrivate); WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); @@ -1262,7 +1262,7 @@ void test_function() { TEST_F(GlslGeneratorImplTest_Builtin, Pack2x16Snorm) { auto* call = Call("pack2x16snorm", "p1"); - GlobalVar("p1", ty.vec2(), type::AddressSpace::kPrivate); + GlobalVar("p1", ty.vec2(), builtin::AddressSpace::kPrivate); WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); @@ -1280,7 +1280,7 @@ void test_function() { TEST_F(GlslGeneratorImplTest_Builtin, Pack2x16Unorm) { auto* call = Call("pack2x16unorm", "p1"); - GlobalVar("p1", ty.vec2(), type::AddressSpace::kPrivate); + GlobalVar("p1", ty.vec2(), builtin::AddressSpace::kPrivate); WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); @@ -1298,7 +1298,7 @@ void test_function() { TEST_F(GlslGeneratorImplTest_Builtin, Pack2x16Float) { auto* call = Call("pack2x16float", "p1"); - GlobalVar("p1", ty.vec2(), type::AddressSpace::kPrivate); + GlobalVar("p1", ty.vec2(), builtin::AddressSpace::kPrivate); WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); @@ -1316,7 +1316,7 @@ void test_function() { TEST_F(GlslGeneratorImplTest_Builtin, Unpack4x8Snorm) { auto* call = Call("unpack4x8snorm", "p1"); - GlobalVar("p1", ty.u32(), type::AddressSpace::kPrivate); + GlobalVar("p1", ty.u32(), builtin::AddressSpace::kPrivate); WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); @@ -1334,7 +1334,7 @@ void test_function() { TEST_F(GlslGeneratorImplTest_Builtin, Unpack4x8Unorm) { auto* call = Call("unpack4x8unorm", "p1"); - GlobalVar("p1", ty.u32(), type::AddressSpace::kPrivate); + GlobalVar("p1", ty.u32(), builtin::AddressSpace::kPrivate); WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); @@ -1352,7 +1352,7 @@ void test_function() { TEST_F(GlslGeneratorImplTest_Builtin, Unpack2x16Snorm) { auto* call = Call("unpack2x16snorm", "p1"); - GlobalVar("p1", ty.u32(), type::AddressSpace::kPrivate); + GlobalVar("p1", ty.u32(), builtin::AddressSpace::kPrivate); WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); @@ -1370,7 +1370,7 @@ void test_function() { TEST_F(GlslGeneratorImplTest_Builtin, Unpack2x16Unorm) { auto* call = Call("unpack2x16unorm", "p1"); - GlobalVar("p1", ty.u32(), type::AddressSpace::kPrivate); + GlobalVar("p1", ty.u32(), builtin::AddressSpace::kPrivate); WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); @@ -1388,7 +1388,7 @@ void test_function() { TEST_F(GlslGeneratorImplTest_Builtin, Unpack2x16Float) { auto* call = Call("unpack2x16float", "p1"); - GlobalVar("p1", ty.u32(), type::AddressSpace::kPrivate); + GlobalVar("p1", ty.u32(), builtin::AddressSpace::kPrivate); WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); @@ -1451,7 +1451,7 @@ void main() { } TEST_F(GlslGeneratorImplTest_Builtin, DotI32) { - GlobalVar("v", ty.vec3(), type::AddressSpace::kPrivate); + GlobalVar("v", ty.vec3(), builtin::AddressSpace::kPrivate); WrapInFunction(CallStmt(Call("dot", "v", "v"))); GeneratorImpl& gen = SanitizeAndBuild(); @@ -1477,7 +1477,7 @@ void main() { } TEST_F(GlslGeneratorImplTest_Builtin, DotU32) { - GlobalVar("v", ty.vec3(), type::AddressSpace::kPrivate); + GlobalVar("v", ty.vec3(), builtin::AddressSpace::kPrivate); WrapInFunction(CallStmt(Call("dot", "v", "v"))); GeneratorImpl& gen = SanitizeAndBuild(); @@ -1503,7 +1503,7 @@ void main() { } TEST_F(GlslGeneratorImplTest_Builtin, QuantizeToF16_Scalar) { - GlobalVar("v", Expr(2_f), type::AddressSpace::kPrivate); + GlobalVar("v", Expr(2_f), builtin::AddressSpace::kPrivate); WrapInFunction(Call("quantizeToF16", "v")); GeneratorImpl& gen = SanitizeAndBuild(); @@ -1530,7 +1530,7 @@ void main() { } TEST_F(GlslGeneratorImplTest_Builtin, QuantizeToF16_Vec2) { - GlobalVar("v", vec2(2_f), type::AddressSpace::kPrivate); + GlobalVar("v", vec2(2_f), builtin::AddressSpace::kPrivate); WrapInFunction(Call("quantizeToF16", "v")); GeneratorImpl& gen = SanitizeAndBuild(); @@ -1557,7 +1557,7 @@ void main() { } TEST_F(GlslGeneratorImplTest_Builtin, QuantizeToF16_Vec3) { - GlobalVar("v", vec3(2_f), type::AddressSpace::kPrivate); + GlobalVar("v", vec3(2_f), builtin::AddressSpace::kPrivate); WrapInFunction(Call("quantizeToF16", "v")); GeneratorImpl& gen = SanitizeAndBuild(); @@ -1586,7 +1586,7 @@ void main() { } TEST_F(GlslGeneratorImplTest_Builtin, QuantizeToF16_Vec4) { - GlobalVar("v", vec4(2_f), type::AddressSpace::kPrivate); + GlobalVar("v", vec4(2_f), builtin::AddressSpace::kPrivate); WrapInFunction(Call("quantizeToF16", "v")); GeneratorImpl& gen = SanitizeAndBuild(); diff --git a/src/tint/writer/glsl/generator_impl_call_test.cc b/src/tint/writer/glsl/generator_impl_call_test.cc index 4ea3790fa4..2f81463de9 100644 --- a/src/tint/writer/glsl/generator_impl_call_test.cc +++ b/src/tint/writer/glsl/generator_impl_call_test.cc @@ -42,8 +42,8 @@ TEST_F(GlslGeneratorImplTest_Call, EmitExpression_Call_WithParams) { Param(Sym(), ty.f32()), }, ty.f32(), utils::Vector{Return(1.23_f)}); - GlobalVar("param1", ty.f32(), type::AddressSpace::kPrivate); - GlobalVar("param2", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("param1", ty.f32(), builtin::AddressSpace::kPrivate); + GlobalVar("param2", ty.f32(), builtin::AddressSpace::kPrivate); auto* call = Call("my_func", "param1", "param2"); WrapInFunction(call); @@ -62,8 +62,8 @@ TEST_F(GlslGeneratorImplTest_Call, EmitStatement_Call) { Param(Sym(), ty.f32()), }, ty.void_(), utils::Empty, utils::Empty); - GlobalVar("param1", ty.f32(), type::AddressSpace::kPrivate); - GlobalVar("param2", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("param1", ty.f32(), builtin::AddressSpace::kPrivate); + GlobalVar("param2", ty.f32(), builtin::AddressSpace::kPrivate); auto* call = CallStmt(Call("my_func", "param1", "param2")); WrapInFunction(call); diff --git a/src/tint/writer/glsl/generator_impl_function_test.cc b/src/tint/writer/glsl/generator_impl_function_test.cc index be96c9bca6..05d1460d34 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 @@ TEST_F(GlslGeneratorImplTest_Function, PtrParameter) { // fn f(foo : ptr) -> f32 { // return *foo; // } - Func("f", utils::Vector{Param("foo", ty.pointer(type::AddressSpace::kFunction))}, ty.f32(), - utils::Vector{Return(Deref("foo"))}); + Func("f", utils::Vector{Param("foo", ty.pointer(builtin::AddressSpace::kFunction))}, + ty.f32(), utils::Vector{Return(Deref("foo"))}); GeneratorImpl& gen = SanitizeAndBuild(); @@ -352,7 +352,7 @@ tint_symbol_2 vert_main2() { TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_Uniform) { auto* ubo_ty = Structure("UBO", utils::Vector{Member("coord", ty.vec4())}); auto* ubo = - GlobalVar("ubo", ty.Of(ubo_ty), type::AddressSpace::kUniform, Binding(0_a), Group(1_a)); + GlobalVar("ubo", ty.Of(ubo_ty), builtin::AddressSpace::kUniform, Binding(0_a), Group(1_a)); Func("sub_func", utils::Vector{ @@ -402,7 +402,7 @@ void frag_main() { TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_UniformStruct) { auto* s = Structure("Uniforms", utils::Vector{Member("coord", ty.vec4())}); - GlobalVar("uniforms", ty.Of(s), type::AddressSpace::kUniform, Binding(0_a), Group(1_a)); + GlobalVar("uniforms", ty.Of(s), builtin::AddressSpace::kUniform, Binding(0_a), Group(1_a)); auto* var = Var("v", ty.f32(), MemberAccessor(MemberAccessor("uniforms", "coord"), "x")); @@ -442,7 +442,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RW_Storage Member("b", ty.f32()), }); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + GlobalVar("coord", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, Binding(0_a), Group(1_a)); auto* var = Var("v", ty.f32(), MemberAccessor("coord", "b")); @@ -489,8 +489,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RO_Storage Member("b", ty.f32()), }); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), - Group(1_a)); + GlobalVar("coord", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kRead, + Binding(0_a), Group(1_a)); auto* var = Var("v", ty.f32(), MemberAccessor("coord", "b")); @@ -537,7 +537,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_WO_Storage Member("b", ty.f32()), }); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + GlobalVar("coord", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, Binding(0_a), Group(1_a)); Func("frag_main", utils::Empty, ty.void_(), @@ -582,7 +582,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_StorageBuf Member("b", ty.f32()), }); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + GlobalVar("coord", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, Binding(0_a), Group(1_a)); Func("frag_main", utils::Empty, ty.void_(), @@ -623,7 +623,7 @@ void main() { TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_Uniform) { auto* s = Structure("S", utils::Vector{Member("x", ty.f32())}); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kUniform, Binding(0_a), Group(1_a)); + GlobalVar("coord", ty.Of(s), builtin::AddressSpace::kUniform, Binding(0_a), Group(1_a)); Func("sub_func", utils::Vector{Param("param", ty.f32())}, ty.f32(), utils::Vector{ @@ -668,7 +668,7 @@ void frag_main() { TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_StorageBuffer) { auto* s = Structure("S", utils::Vector{Member("x", ty.f32())}); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + GlobalVar("coord", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, Binding(0_a), Group(1_a)); Func("sub_func", utils::Vector{Param("param", ty.f32())}, ty.f32(), @@ -879,7 +879,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Multiple_EntryPoint_With_Same_Module auto* s = Structure("Data", utils::Vector{Member("d", ty.f32())}); - GlobalVar("data", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + GlobalVar("data", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, Binding(0_a), Group(0_a)); { diff --git a/src/tint/writer/glsl/generator_impl_identifier_test.cc b/src/tint/writer/glsl/generator_impl_identifier_test.cc index 7e528ace34..cd0b109aff 100644 --- a/src/tint/writer/glsl/generator_impl_identifier_test.cc +++ b/src/tint/writer/glsl/generator_impl_identifier_test.cc @@ -20,7 +20,7 @@ namespace { using GlslGeneratorImplTest_Identifier = TestHelper; TEST_F(GlslGeneratorImplTest_Identifier, EmitIdentifierExpression) { - GlobalVar("foo", ty.i32(), type::AddressSpace::kPrivate); + GlobalVar("foo", ty.i32(), builtin::AddressSpace::kPrivate); auto* i = Expr("foo"); WrapInFunction(i); diff --git a/src/tint/writer/glsl/generator_impl_if_test.cc b/src/tint/writer/glsl/generator_impl_if_test.cc index a0957e15f0..0713ab7670 100644 --- a/src/tint/writer/glsl/generator_impl_if_test.cc +++ b/src/tint/writer/glsl/generator_impl_if_test.cc @@ -20,7 +20,7 @@ namespace { using GlslGeneratorImplTest_If = TestHelper; TEST_F(GlslGeneratorImplTest_If, Emit_If) { - GlobalVar("cond", ty.bool_(), type::AddressSpace::kPrivate); + GlobalVar("cond", ty.bool_(), builtin::AddressSpace::kPrivate); auto* cond = Expr("cond"); auto* body = Block(Return()); @@ -38,8 +38,8 @@ TEST_F(GlslGeneratorImplTest_If, Emit_If) { } TEST_F(GlslGeneratorImplTest_If, Emit_IfWithElseIf) { - GlobalVar("cond", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("else_cond", ty.bool_(), type::AddressSpace::kPrivate); + GlobalVar("cond", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("else_cond", ty.bool_(), builtin::AddressSpace::kPrivate); auto* else_cond = Expr("else_cond"); auto* else_body = Block(Return()); @@ -65,7 +65,7 @@ TEST_F(GlslGeneratorImplTest_If, Emit_IfWithElseIf) { } TEST_F(GlslGeneratorImplTest_If, Emit_IfWithElse) { - GlobalVar("cond", ty.bool_(), type::AddressSpace::kPrivate); + GlobalVar("cond", ty.bool_(), builtin::AddressSpace::kPrivate); auto* else_body = Block(Return()); @@ -88,8 +88,8 @@ TEST_F(GlslGeneratorImplTest_If, Emit_IfWithElse) { } TEST_F(GlslGeneratorImplTest_If, Emit_IfWithMultiple) { - GlobalVar("cond", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("else_cond", ty.bool_(), type::AddressSpace::kPrivate); + GlobalVar("cond", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("else_cond", ty.bool_(), builtin::AddressSpace::kPrivate); auto* else_cond = Expr("else_cond"); diff --git a/src/tint/writer/glsl/generator_impl_import_test.cc b/src/tint/writer/glsl/generator_impl_import_test.cc index adfebe409d..10da8aa57a 100644 --- a/src/tint/writer/glsl/generator_impl_import_test.cc +++ b/src/tint/writer/glsl/generator_impl_import_test.cc @@ -251,7 +251,7 @@ INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_Import, testing::Values(GlslImportData{"clamp", "clamp"})); TEST_F(GlslGeneratorImplTest_Import, GlslImportData_Determinant) { - GlobalVar("var", ty.mat3x3(), type::AddressSpace::kPrivate); + GlobalVar("var", ty.mat3x3(), builtin::AddressSpace::kPrivate); auto* expr = Call("determinant", "var"); WrapInFunction(expr); diff --git a/src/tint/writer/glsl/generator_impl_loop_test.cc b/src/tint/writer/glsl/generator_impl_loop_test.cc index 79374a2aaa..0979f53825 100644 --- a/src/tint/writer/glsl/generator_impl_loop_test.cc +++ b/src/tint/writer/glsl/generator_impl_loop_test.cc @@ -93,8 +93,8 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_LoopWithContinuing_BreakIf) { TEST_F(GlslGeneratorImplTest_Loop, Emit_LoopNestedWithContinuing) { Func("a_statement", {}, ty.void_(), {}); - GlobalVar("lhs", ty.f32(), type::AddressSpace::kPrivate); - GlobalVar("rhs", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("lhs", ty.f32(), builtin::AddressSpace::kPrivate); + GlobalVar("rhs", ty.f32(), builtin::AddressSpace::kPrivate); auto* body = Block(Break()); auto* continuing = Block(CallStmt(Call("a_statement"))); @@ -142,7 +142,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_LoopWithVarUsedInContinuing) { // } // } - GlobalVar("rhs", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("rhs", ty.f32(), builtin::AddressSpace::kPrivate); auto* body = Block(Decl(Var("lhs", ty.f32(), Expr(2.4_f))), // Decl(Var("other", ty.f32())), // diff --git a/src/tint/writer/glsl/generator_impl_member_accessor_test.cc b/src/tint/writer/glsl/generator_impl_member_accessor_test.cc index 37005e8464..e551c7585c 100644 --- a/src/tint/writer/glsl/generator_impl_member_accessor_test.cc +++ b/src/tint/writer/glsl/generator_impl_member_accessor_test.cc @@ -91,8 +91,8 @@ class GlslGeneratorImplTest_MemberAccessorBase : public BASE { auto* s = b.Structure("Data", members); - b.GlobalVar("data", b.ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, - b.Group(1_a), b.Binding(0_a)); + b.GlobalVar("data", b.ty.Of(s), builtin::AddressSpace::kStorage, + builtin::Access::kReadWrite, b.Group(1_a), b.Binding(0_a)); } void SetupFunction(utils::VectorRef statements) { @@ -112,7 +112,7 @@ using GlslGeneratorImplTest_MemberAccessorWithParam = TEST_F(GlslGeneratorImplTest_MemberAccessor, EmitExpression_MemberAccessor) { auto* s = Structure("Data", utils::Vector{Member("mem", ty.f32())}); - GlobalVar("str", ty.Of(s), type::AddressSpace::kPrivate); + GlobalVar("str", ty.Of(s), builtin::AddressSpace::kPrivate); auto* expr = MemberAccessor("str", "mem"); WrapInFunction(Var("expr", ty.f32(), expr)); diff --git a/src/tint/writer/glsl/generator_impl_sanitizer_test.cc b/src/tint/writer/glsl/generator_impl_sanitizer_test.cc index cd4d821b15..e85d0507d5 100644 --- a/src/tint/writer/glsl/generator_impl_sanitizer_test.cc +++ b/src/tint/writer/glsl/generator_impl_sanitizer_test.cc @@ -26,7 +26,7 @@ using GlslSanitizerTest = TestHelper; TEST_F(GlslSanitizerTest, Call_ArrayLength) { auto* s = Structure("my_struct", utils::Vector{Member(0, "a", ty.array())}); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), Group(2_a)); Func("a_func", utils::Empty, ty.void_(), @@ -66,7 +66,7 @@ TEST_F(GlslSanitizerTest, Call_ArrayLength_OtherMembersInStruct) { Member(0, "z", ty.f32()), Member(4, "a", ty.array()), }); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), Group(2_a)); Func("a_func", utils::Empty, ty.void_(), @@ -105,7 +105,7 @@ void main() { TEST_F(GlslSanitizerTest, Call_ArrayLength_ViaLets) { auto* s = Structure("my_struct", utils::Vector{Member(0, "a", ty.array())}); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), Group(2_a)); auto* p = Let("p", AddressOf("b")); @@ -233,7 +233,7 @@ TEST_F(GlslSanitizerTest, InlinePtrLetsBasic) { // let p : ptr = &v; // let x : i32 = *p; auto* v = Var("v", ty.i32()); - auto* p = Let("p", ty.pointer(type::AddressSpace::kFunction), AddressOf(v)); + auto* p = Let("p", ty.pointer(builtin::AddressSpace::kFunction), AddressOf(v)); auto* x = Var("x", ty.i32(), Deref(p)); Func("main", utils::Empty, ty.void_(), @@ -274,11 +274,12 @@ TEST_F(GlslSanitizerTest, InlinePtrLetsComplexChain) { // let vp : ptr> = &(*mp)[2i]; // let v : vec4 = *vp; auto* a = Var("a", ty.array(ty.mat4x4(), 4_u)); - auto* ap = Let("ap", ty.pointer(ty.array(ty.mat4x4(), 4_u), type::AddressSpace::kFunction), - AddressOf(a)); - auto* mp = Let("mp", ty.pointer(ty.mat4x4(), type::AddressSpace::kFunction), + auto* ap = + Let("ap", ty.pointer(ty.array(ty.mat4x4(), 4_u), builtin::AddressSpace::kFunction), + AddressOf(a)); + auto* mp = Let("mp", ty.pointer(ty.mat4x4(), builtin::AddressSpace::kFunction), AddressOf(IndexAccessor(Deref(ap), 3_i))); - auto* vp = Let("vp", ty.pointer(ty.vec4(), type::AddressSpace::kFunction), + auto* vp = Let("vp", ty.pointer(ty.vec4(), builtin::AddressSpace::kFunction), AddressOf(IndexAccessor(Deref(mp), 2_i))); auto* v = Var("v", ty.vec4(), Deref(vp)); diff --git a/src/tint/writer/glsl/generator_impl_storage_buffer_test.cc b/src/tint/writer/glsl/generator_impl_storage_buffer_test.cc index 3572da48c9..7513e9423e 100644 --- a/src/tint/writer/glsl/generator_impl_storage_buffer_test.cc +++ b/src/tint/writer/glsl/generator_impl_storage_buffer_test.cc @@ -37,8 +37,8 @@ void TestAlign(ProgramBuilder* ctx) { ctx->Member("dewey", ctx->ty.f32(), utils::Vector{ctx->MemberAlign(256_i)}), ctx->Member("louie", ctx->ty.f32(), utils::Vector{ctx->MemberAlign(256_i)}), }); - ctx->GlobalVar("nephews", ctx->ty.Of(nephews), type::AddressSpace::kStorage, ctx->Binding(0_a), - ctx->Group(0_a)); + ctx->GlobalVar("nephews", ctx->ty.Of(nephews), builtin::AddressSpace::kStorage, + ctx->Binding(0_a), ctx->Group(0_a)); } TEST_F(GlslGeneratorImplTest_StorageBuffer, Align) { diff --git a/src/tint/writer/glsl/generator_impl_switch_test.cc b/src/tint/writer/glsl/generator_impl_switch_test.cc index 2f90c8f8c0..b9ff49d261 100644 --- a/src/tint/writer/glsl/generator_impl_switch_test.cc +++ b/src/tint/writer/glsl/generator_impl_switch_test.cc @@ -22,7 +22,7 @@ namespace { using GlslGeneratorImplTest_Switch = TestHelper; TEST_F(GlslGeneratorImplTest_Switch, Emit_Switch) { - GlobalVar("cond", ty.i32(), type::AddressSpace::kPrivate); + GlobalVar("cond", ty.i32(), builtin::AddressSpace::kPrivate); auto* def_body = Block(create()); auto* def = create(utils::Vector{DefaultCaseSelector()}, def_body); @@ -51,7 +51,7 @@ TEST_F(GlslGeneratorImplTest_Switch, Emit_Switch) { } TEST_F(GlslGeneratorImplTest_Switch, Emit_Switch_MixedDefault) { - GlobalVar("cond", ty.i32(), type::AddressSpace::kPrivate); + GlobalVar("cond", ty.i32(), builtin::AddressSpace::kPrivate); auto* def_body = Block(create()); auto* def = create(utils::Vector{CaseSelector(5_i), DefaultCaseSelector()}, diff --git a/src/tint/writer/glsl/generator_impl_test.cc b/src/tint/writer/glsl/generator_impl_test.cc index b449253d70..9a24471f9d 100644 --- a/src/tint/writer/glsl/generator_impl_test.cc +++ b/src/tint/writer/glsl/generator_impl_test.cc @@ -62,7 +62,7 @@ TEST_F(GlslGeneratorImplTest, GenerateSampleIndexES) { Builtin(builtin::BuiltinValue::kSampleIndex), Disable(ast::DisabledValidation::kIgnoreAddressSpace), }, - type::AddressSpace::kIn); + builtin::AddressSpace::kIn); Func("my_func", utils::Empty, ty.i32(), utils::Vector{ Return(Expr("gl_SampleID")), @@ -87,7 +87,7 @@ TEST_F(GlslGeneratorImplTest, GenerateSampleIndexDesktop) { Builtin(builtin::BuiltinValue::kSampleIndex), Disable(ast::DisabledValidation::kIgnoreAddressSpace), }, - type::AddressSpace::kIn); + builtin::AddressSpace::kIn); Func("my_func", utils::Empty, ty.i32(), utils::Vector{ Return(Expr("gl_SampleID")), diff --git a/src/tint/writer/glsl/generator_impl_type_test.cc b/src/tint/writer/glsl/generator_impl_type_test.cc index 72c5048c3a..84972d6b70 100644 --- a/src/tint/writer/glsl/generator_impl_type_test.cc +++ b/src/tint/writer/glsl/generator_impl_type_test.cc @@ -34,12 +34,12 @@ using GlslGeneratorImplTest_Type = TestHelper; TEST_F(GlslGeneratorImplTest_Type, EmitType_Array) { auto arr = ty.array(); - ast::Type ty = GlobalVar("G", arr, type::AddressSpace::kPrivate)->type; + ast::Type ty = GlobalVar("G", arr, builtin::AddressSpace::kPrivate)->type; GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE(gen.EmitType(out, program->TypeOf(ty), type::AddressSpace::kUndefined, + ASSERT_TRUE(gen.EmitType(out, program->TypeOf(ty), builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "ary")) << gen.error(); EXPECT_EQ(out.str(), "bool ary[4]"); @@ -47,12 +47,12 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Array) { TEST_F(GlslGeneratorImplTest_Type, EmitType_ArrayOfArray) { auto arr = ty.array(ty.array(), 5_u); - ast::Type ty = GlobalVar("G", arr, type::AddressSpace::kPrivate)->type; + ast::Type ty = GlobalVar("G", arr, builtin::AddressSpace::kPrivate)->type; GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE(gen.EmitType(out, program->TypeOf(ty), type::AddressSpace::kUndefined, + ASSERT_TRUE(gen.EmitType(out, program->TypeOf(ty), builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "ary")) << gen.error(); EXPECT_EQ(out.str(), "bool ary[5][4]"); @@ -60,12 +60,12 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_ArrayOfArray) { TEST_F(GlslGeneratorImplTest_Type, EmitType_ArrayOfArrayOfArray) { auto arr = ty.array(ty.array(ty.array(), 5_u), 6_u); - ast::Type ty = GlobalVar("G", arr, type::AddressSpace::kPrivate)->type; + ast::Type ty = GlobalVar("G", arr, builtin::AddressSpace::kPrivate)->type; GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE(gen.EmitType(out, program->TypeOf(ty), type::AddressSpace::kUndefined, + ASSERT_TRUE(gen.EmitType(out, program->TypeOf(ty), builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "ary")) << gen.error(); EXPECT_EQ(out.str(), "bool ary[6][5][4]"); @@ -73,12 +73,12 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_ArrayOfArrayOfArray) { TEST_F(GlslGeneratorImplTest_Type, EmitType_Array_WithoutName) { auto arr = ty.array(); - ast::Type ty = GlobalVar("G", arr, type::AddressSpace::kPrivate)->type; + ast::Type ty = GlobalVar("G", arr, builtin::AddressSpace::kPrivate)->type; GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE(gen.EmitType(out, program->TypeOf(ty), type::AddressSpace::kUndefined, + ASSERT_TRUE(gen.EmitType(out, program->TypeOf(ty), builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "bool[4]"); @@ -90,8 +90,8 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Bool) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE( - gen.EmitType(out, bool_, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) + ASSERT_TRUE(gen.EmitType(out, bool_, builtin::AddressSpace::kUndefined, + builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "bool"); } @@ -103,7 +103,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_F32) { std::stringstream out; ASSERT_TRUE( - gen.EmitType(out, f32, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) + gen.EmitType(out, f32, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "float"); } @@ -117,7 +117,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_F16) { std::stringstream out; ASSERT_TRUE( - gen.EmitType(out, f16, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) + gen.EmitType(out, f16, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "float16_t"); } @@ -129,7 +129,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_I32) { std::stringstream out; ASSERT_TRUE( - gen.EmitType(out, i32, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) + gen.EmitType(out, i32, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "int"); } @@ -142,8 +142,8 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Matrix_F32) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE( - gen.EmitType(out, mat2x3, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) + ASSERT_TRUE(gen.EmitType(out, mat2x3, builtin::AddressSpace::kUndefined, + builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "mat2x3"); } @@ -158,8 +158,8 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Matrix_F16) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE( - gen.EmitType(out, mat2x3, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) + ASSERT_TRUE(gen.EmitType(out, mat2x3, builtin::AddressSpace::kUndefined, + builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "f16mat2x3"); } @@ -169,7 +169,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_StructDecl) { Member("a", ty.i32()), Member("b", ty.f32()), }); - GlobalVar("g", ty.Of(s), type::AddressSpace::kPrivate); + GlobalVar("g", ty.Of(s), builtin::AddressSpace::kPrivate); GeneratorImpl& gen = Build(); @@ -189,14 +189,14 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Struct) { Member("a", ty.i32()), Member("b", ty.f32()), }); - GlobalVar("g", ty.Of(s), type::AddressSpace::kPrivate); + GlobalVar("g", ty.Of(s), builtin::AddressSpace::kPrivate); GeneratorImpl& gen = Build(); auto* sem_s = program->TypeOf(s)->As(); std::stringstream out; - ASSERT_TRUE( - gen.EmitType(out, sem_s, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) + ASSERT_TRUE(gen.EmitType(out, sem_s, builtin::AddressSpace::kUndefined, + builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "S"); } @@ -206,7 +206,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Struct_NameCollision) { Member("double", ty.i32()), Member("float", ty.f32()), }); - GlobalVar("g", ty.Of(s), type::AddressSpace::kPrivate); + GlobalVar("g", ty.Of(s), builtin::AddressSpace::kPrivate); GeneratorImpl& gen = SanitizeAndBuild(); @@ -223,7 +223,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Struct_WithOffsetAttributes) { Member("a", ty.i32(), utils::Vector{MemberOffset(0_a)}), Member("b", ty.f32(), utils::Vector{MemberOffset(8_a)}), }); - GlobalVar("g", ty.Of(s), type::AddressSpace::kPrivate); + GlobalVar("g", ty.Of(s), builtin::AddressSpace::kPrivate); GeneratorImpl& gen = Build(); @@ -245,7 +245,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_U32) { std::stringstream out; ASSERT_TRUE( - gen.EmitType(out, u32, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) + gen.EmitType(out, u32, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "uint"); } @@ -258,7 +258,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Vector_F32) { std::stringstream out; ASSERT_TRUE( - gen.EmitType(out, vec3, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) + gen.EmitType(out, vec3, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "vec3"); } @@ -273,7 +273,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Vector_F16) { std::stringstream out; ASSERT_TRUE( - gen.EmitType(out, vec3, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) + gen.EmitType(out, vec3, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "f16vec3"); } @@ -284,8 +284,8 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Void) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE( - gen.EmitType(out, void_, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) + ASSERT_TRUE(gen.EmitType(out, void_, builtin::AddressSpace::kUndefined, + builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "void"); } @@ -296,8 +296,8 @@ TEST_F(GlslGeneratorImplTest_Type, EmitSampler) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_FALSE( - gen.EmitType(out, sampler, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) + ASSERT_FALSE(gen.EmitType(out, sampler, builtin::AddressSpace::kUndefined, + builtin::Access::kReadWrite, "")) << gen.error(); } @@ -307,8 +307,8 @@ TEST_F(GlslGeneratorImplTest_Type, EmitSamplerComparison) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_FALSE( - gen.EmitType(out, sampler, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) + ASSERT_FALSE(gen.EmitType(out, sampler, builtin::AddressSpace::kUndefined, + builtin::Access::kReadWrite, "")) << gen.error(); } @@ -515,7 +515,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitMultisampledTexture) { std::stringstream out; ASSERT_TRUE( - gen.EmitType(out, s, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) + gen.EmitType(out, s, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "highp sampler2DMS"); } diff --git a/src/tint/writer/glsl/generator_impl_unary_op_test.cc b/src/tint/writer/glsl/generator_impl_unary_op_test.cc index c0eb7b1783..18f180e0ba 100644 --- a/src/tint/writer/glsl/generator_impl_unary_op_test.cc +++ b/src/tint/writer/glsl/generator_impl_unary_op_test.cc @@ -20,7 +20,7 @@ namespace { using GlslUnaryOpTest = TestHelper; TEST_F(GlslUnaryOpTest, AddressOf) { - GlobalVar("expr", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("expr", ty.f32(), builtin::AddressSpace::kPrivate); auto* op = create(ast::UnaryOp::kAddressOf, Expr("expr")); WrapInFunction(op); @@ -32,7 +32,7 @@ TEST_F(GlslUnaryOpTest, AddressOf) { } TEST_F(GlslUnaryOpTest, Complement) { - GlobalVar("expr", ty.u32(), type::AddressSpace::kPrivate); + GlobalVar("expr", ty.u32(), builtin::AddressSpace::kPrivate); auto* op = create(ast::UnaryOp::kComplement, Expr("expr")); WrapInFunction(op); @@ -44,7 +44,7 @@ TEST_F(GlslUnaryOpTest, Complement) { } TEST_F(GlslUnaryOpTest, Indirection) { - GlobalVar("G", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("G", ty.f32(), builtin::AddressSpace::kPrivate); auto* p = Let("expr", create(ast::UnaryOp::kAddressOf, Expr("G"))); auto* op = create(ast::UnaryOp::kIndirection, Expr("expr")); WrapInFunction(p, op); @@ -57,7 +57,7 @@ TEST_F(GlslUnaryOpTest, Indirection) { } TEST_F(GlslUnaryOpTest, Not) { - GlobalVar("expr", ty.bool_(), type::AddressSpace::kPrivate); + GlobalVar("expr", ty.bool_(), builtin::AddressSpace::kPrivate); auto* op = create(ast::UnaryOp::kNot, Expr("expr")); WrapInFunction(op); @@ -69,7 +69,7 @@ TEST_F(GlslUnaryOpTest, Not) { } TEST_F(GlslUnaryOpTest, Negation) { - GlobalVar("expr", ty.i32(), type::AddressSpace::kPrivate); + GlobalVar("expr", ty.i32(), builtin::AddressSpace::kPrivate); auto* op = create(ast::UnaryOp::kNegation, Expr("expr")); WrapInFunction(op); diff --git a/src/tint/writer/glsl/generator_impl_uniform_buffer_test.cc b/src/tint/writer/glsl/generator_impl_uniform_buffer_test.cc index 48f635a34f..2ace33c612 100644 --- a/src/tint/writer/glsl/generator_impl_uniform_buffer_test.cc +++ b/src/tint/writer/glsl/generator_impl_uniform_buffer_test.cc @@ -26,7 +26,7 @@ using GlslGeneratorImplTest_UniformBuffer = TestHelper; TEST_F(GlslGeneratorImplTest_UniformBuffer, Simple) { auto* simple = Structure("Simple", utils::Vector{Member("member", ty.f32())}); - GlobalVar("simple", ty.Of(simple), type::AddressSpace::kUniform, Group(0_a), Binding(0_a)); + GlobalVar("simple", ty.Of(simple), builtin::AddressSpace::kUniform, Group(0_a), Binding(0_a)); GeneratorImpl& gen = Build(); @@ -46,7 +46,7 @@ layout(binding = 0, std140) uniform Simple_ubo { TEST_F(GlslGeneratorImplTest_UniformBuffer, Simple_Desktop) { auto* simple = Structure("Simple", utils::Vector{Member("member", ty.f32())}); - GlobalVar("simple", ty.Of(simple), type::AddressSpace::kUniform, Group(0_a), Binding(0_a)); + GlobalVar("simple", ty.Of(simple), builtin::AddressSpace::kUniform, Group(0_a), Binding(0_a)); GeneratorImpl& gen = Build(Version(Version::Standard::kDesktop, 4, 4)); diff --git a/src/tint/writer/glsl/generator_impl_variable_decl_statement_test.cc b/src/tint/writer/glsl/generator_impl_variable_decl_statement_test.cc index a4d11cb663..5691312a22 100644 --- a/src/tint/writer/glsl/generator_impl_variable_decl_statement_test.cc +++ b/src/tint/writer/glsl/generator_impl_variable_decl_statement_test.cc @@ -475,7 +475,7 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Array) { } TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Private) { - GlobalVar("a", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("a", ty.f32(), builtin::AddressSpace::kPrivate); WrapInFunction(Expr("a")); diff --git a/src/tint/writer/glsl/generator_impl_workgroup_var_test.cc b/src/tint/writer/glsl/generator_impl_workgroup_var_test.cc index 97f8cf87d2..676025ca7d 100644 --- a/src/tint/writer/glsl/generator_impl_workgroup_var_test.cc +++ b/src/tint/writer/glsl/generator_impl_workgroup_var_test.cc @@ -27,7 +27,7 @@ namespace { using GlslGeneratorImplTest_WorkgroupVar = TestHelper; TEST_F(GlslGeneratorImplTest_WorkgroupVar, Basic) { - GlobalVar("wg", ty.f32(), type::AddressSpace::kWorkgroup); + GlobalVar("wg", ty.f32(), builtin::AddressSpace::kWorkgroup); Func("main", utils::Empty, ty.void_(), utils::Vector{Assign("wg", 1.2_f)}, utils::Vector{ @@ -43,7 +43,7 @@ TEST_F(GlslGeneratorImplTest_WorkgroupVar, Basic) { TEST_F(GlslGeneratorImplTest_WorkgroupVar, Aliased) { auto* alias = Alias("F32", ty.f32()); - GlobalVar("wg", ty.Of(alias), type::AddressSpace::kWorkgroup); + GlobalVar("wg", ty.Of(alias), builtin::AddressSpace::kWorkgroup); Func("main", utils::Empty, ty.void_(), utils::Vector{Assign("wg", 1.2_f)}, utils::Vector{ diff --git a/src/tint/writer/hlsl/generator_impl.cc b/src/tint/writer/hlsl/generator_impl.cc index f75cf06575..4d074970e9 100644 --- a/src/tint/writer/hlsl/generator_impl.cc +++ b/src/tint/writer/hlsl/generator_impl.cc @@ -335,8 +335,8 @@ bool GeneratorImpl::Generate() { auto* ty = builder_.Sem().Get(str); auto address_space_uses = ty->AddressSpaceUsage(); if (address_space_uses.size() != - (address_space_uses.count(type::AddressSpace::kStorage) + - address_space_uses.count(type::AddressSpace::kUniform))) { + (address_space_uses.count(builtin::AddressSpace::kStorage) + + address_space_uses.count(builtin::AddressSpace::kUniform))) { // The structure is used as something other than a storage buffer or // uniform buffer, so it needs to be emitted. // Storage buffer are read and written to via a ByteAddressBuffer @@ -377,7 +377,7 @@ bool GeneratorImpl::EmitDynamicVectorAssignment(const ast::AssignmentStatement* std::string fn; { std::ostringstream ss; - if (!EmitType(ss, vec, tint::type::AddressSpace::kUndefined, + if (!EmitType(ss, vec, tint::builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, "")) { return ""; } @@ -386,12 +386,12 @@ bool GeneratorImpl::EmitDynamicVectorAssignment(const ast::AssignmentStatement* { auto out = line(&helpers_); out << "void " << fn << "(inout "; - if (!EmitTypeAndName(out, vec, type::AddressSpace::kUndefined, + if (!EmitTypeAndName(out, vec, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, "vec")) { return ""; } out << ", int idx, "; - if (!EmitTypeAndName(out, vec->type(), type::AddressSpace::kUndefined, + if (!EmitTypeAndName(out, vec->type(), builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, "val")) { return ""; } @@ -451,7 +451,7 @@ bool GeneratorImpl::EmitDynamicMatrixVectorAssignment(const ast::AssignmentState std::string fn; { std::ostringstream ss; - if (!EmitType(ss, mat, tint::type::AddressSpace::kUndefined, + if (!EmitType(ss, mat, tint::builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, "")) { return ""; } @@ -460,12 +460,12 @@ bool GeneratorImpl::EmitDynamicMatrixVectorAssignment(const ast::AssignmentState { auto out = line(&helpers_); out << "void " << fn << "(inout "; - if (!EmitTypeAndName(out, mat, type::AddressSpace::kUndefined, + if (!EmitTypeAndName(out, mat, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, "mat")) { return ""; } out << ", int col, "; - if (!EmitTypeAndName(out, mat->ColumnType(), type::AddressSpace::kUndefined, + if (!EmitTypeAndName(out, mat->ColumnType(), builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, "val")) { return ""; } @@ -520,7 +520,7 @@ bool GeneratorImpl::EmitDynamicMatrixScalarAssignment(const ast::AssignmentState std::string fn; { std::ostringstream ss; - if (!EmitType(ss, mat, tint::type::AddressSpace::kUndefined, + if (!EmitType(ss, mat, tint::builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, "")) { return ""; } @@ -529,12 +529,12 @@ bool GeneratorImpl::EmitDynamicMatrixScalarAssignment(const ast::AssignmentState { auto out = line(&helpers_); out << "void " << fn << "(inout "; - if (!EmitTypeAndName(out, mat, type::AddressSpace::kUndefined, + if (!EmitTypeAndName(out, mat, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, "mat")) { return ""; } out << ", int col, int row, "; - if (!EmitTypeAndName(out, mat->type(), type::AddressSpace::kUndefined, + if (!EmitTypeAndName(out, mat->type(), builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, "val")) { return ""; } @@ -642,7 +642,7 @@ bool GeneratorImpl::EmitBitcast(std::ostream& out, const ast::BitcastExpression* } out << "as"; - if (!EmitType(out, type, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) { + if (!EmitType(out, type, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) { return false; } out << "("; @@ -909,9 +909,9 @@ bool GeneratorImpl::EmitFunctionCall(std::ostream& out, if (auto* intrinsic = ast::GetAttribute( func->Declaration()->attributes)) { switch (intrinsic->address_space) { - case type::AddressSpace::kUniform: + case builtin::AddressSpace::kUniform: return EmitUniformBufferAccess(out, expr, intrinsic); - case type::AddressSpace::kStorage: + case builtin::AddressSpace::kStorage: if (!intrinsic->IsAtomic()) { return EmitStorageBufferAccess(out, expr, intrinsic); } @@ -1030,8 +1030,8 @@ bool GeneratorImpl::EmitBuiltinCall(std::ostream& out, bool GeneratorImpl::EmitTypeConversion(std::ostream& out, const sem::Call* call, const sem::TypeConversion* conv) { - if (!EmitType(out, conv->Target(), type::AddressSpace::kUndefined, builtin::Access::kReadWrite, - "")) { + if (!EmitType(out, conv->Target(), builtin::AddressSpace::kUndefined, + builtin::Access::kReadWrite, "")) { return false; } out << "("; @@ -1076,7 +1076,8 @@ bool GeneratorImpl::EmitTypeInitializer(std::ostream& out, if (brackets) { out << "{"; } else { - if (!EmitType(out, type, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) { + if (!EmitType(out, type, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, + "")) { return false; } out << "("; @@ -1593,12 +1594,12 @@ bool GeneratorImpl::EmitStorageAtomicIntrinsic( auto rmw = [&](const char* hlsl) -> bool { { auto fn = line(&buf); - if (!EmitTypeAndName(fn, result_ty, type::AddressSpace::kUndefined, + if (!EmitTypeAndName(fn, result_ty, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, name)) { return false; } fn << "(RWByteAddressBuffer buffer, uint offset, "; - if (!EmitTypeAndName(fn, result_ty, type::AddressSpace::kUndefined, + if (!EmitTypeAndName(fn, result_ty, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, "value")) { return false; } @@ -1614,7 +1615,7 @@ bool GeneratorImpl::EmitStorageAtomicIntrinsic( { auto l = line(&buf); - if (!EmitTypeAndName(l, result_ty, type::AddressSpace::kUndefined, + if (!EmitTypeAndName(l, result_ty, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, "original_value")) { return false; } @@ -1663,7 +1664,7 @@ bool GeneratorImpl::EmitStorageAtomicIntrinsic( // InterlockedOr using 0 as the OR value { auto fn = line(&buf); - if (!EmitTypeAndName(fn, result_ty, type::AddressSpace::kUndefined, + if (!EmitTypeAndName(fn, result_ty, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, name)) { return false; } @@ -1679,7 +1680,7 @@ bool GeneratorImpl::EmitStorageAtomicIntrinsic( { auto l = line(&buf); - if (!EmitTypeAndName(l, result_ty, type::AddressSpace::kUndefined, + if (!EmitTypeAndName(l, result_ty, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, "value")) { return false; } @@ -1697,7 +1698,7 @@ bool GeneratorImpl::EmitStorageAtomicIntrinsic( { auto fn = line(&buf); fn << "void " << name << "(RWByteAddressBuffer buffer, uint offset, "; - if (!EmitTypeAndName(fn, value_ty, type::AddressSpace::kUndefined, + if (!EmitTypeAndName(fn, value_ty, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, "value")) { return false; } @@ -1713,7 +1714,7 @@ bool GeneratorImpl::EmitStorageAtomicIntrinsic( { auto l = line(&buf); - if (!EmitTypeAndName(l, value_ty, type::AddressSpace::kUndefined, + if (!EmitTypeAndName(l, value_ty, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, "ignored")) { return false; } @@ -1728,17 +1729,17 @@ bool GeneratorImpl::EmitStorageAtomicIntrinsic( auto* value_ty = params[2]->Type()->UnwrapRef(); { auto fn = line(&buf); - if (!EmitTypeAndName(fn, result_ty, type::AddressSpace::kUndefined, + if (!EmitTypeAndName(fn, result_ty, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, name)) { return false; } fn << "(RWByteAddressBuffer buffer, uint offset, "; - if (!EmitTypeAndName(fn, value_ty, type::AddressSpace::kUndefined, + if (!EmitTypeAndName(fn, value_ty, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, "compare")) { return false; } fn << ", "; - if (!EmitTypeAndName(fn, value_ty, type::AddressSpace::kUndefined, + if (!EmitTypeAndName(fn, value_ty, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, "value")) { return false; } @@ -1754,7 +1755,7 @@ bool GeneratorImpl::EmitStorageAtomicIntrinsic( { // T result = {0}; auto l = line(&buf); - if (!EmitTypeAndName(l, result_ty, type::AddressSpace::kUndefined, + if (!EmitTypeAndName(l, result_ty, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, "result")) { return false; } @@ -1789,7 +1790,7 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out, if (!builtin->ReturnType()->Is()) { auto pre = line(); - if (!EmitTypeAndName(pre, builtin->ReturnType(), type::AddressSpace::kUndefined, + if (!EmitTypeAndName(pre, builtin->ReturnType(), builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, result)) { return false; } @@ -1853,7 +1854,7 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out, { // T result = 0; auto pre = line(); auto* value_ty = builtin->Parameters()[1]->Type()->UnwrapRef(); - if (!EmitTypeAndName(pre, value_ty, type::AddressSpace::kUndefined, + if (!EmitTypeAndName(pre, value_ty, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, result)) { return false; } @@ -1892,7 +1893,7 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out, { // T compare_value = ; auto pre = line(); if (!EmitTypeAndName(pre, TypeOf(compare_value)->UnwrapRef(), - type::AddressSpace::kUndefined, builtin::Access::kUndefined, + builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, compare)) { return false; } @@ -2002,7 +2003,7 @@ bool GeneratorImpl::EmitModfCall(std::ostream& out, { auto l = line(b); - if (!EmitType(l, builtin->ReturnType(), type::AddressSpace::kUndefined, + if (!EmitType(l, builtin->ReturnType(), builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, "")) { return false; } @@ -2044,7 +2045,7 @@ bool GeneratorImpl::EmitFrexpCall(std::ostream& out, line(b) << member_type << " fract = frexp(" << in << ", exp);"; { auto l = line(b); - if (!EmitType(l, builtin->ReturnType(), type::AddressSpace::kUndefined, + if (!EmitType(l, builtin->ReturnType(), builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, "")) { return false; } @@ -2082,7 +2083,7 @@ bool GeneratorImpl::EmitRadiansCall(std::ostream& out, // type after the call to `sign`. bool GeneratorImpl::EmitSignCall(std::ostream& out, const sem::Call* call, const sem::Builtin*) { auto* arg = call->Arguments()[0]; - if (!EmitType(out, arg->Type(), type::AddressSpace::kUndefined, builtin::Access::kReadWrite, + if (!EmitType(out, arg->Type(), builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) { return false; } @@ -2863,7 +2864,7 @@ bool GeneratorImpl::EmitFunction(const ast::Function* func) { // Emit storage atomic helpers if (auto* intrinsic = ast::GetAttribute(func->attributes)) { - if (intrinsic->address_space == type::AddressSpace::kStorage && intrinsic->IsAtomic()) { + if (intrinsic->address_space == builtin::AddressSpace::kStorage && intrinsic->IsAtomic()) { if (!EmitStorageAtomicIntrinsic(func, intrinsic)) { return false; } @@ -2885,14 +2886,14 @@ bool GeneratorImpl::EmitFunction(const ast::Function* func) { auto typedef_name = UniqueIdentifier(name + "_ret"); auto pre = line(); pre << "typedef "; - if (!EmitTypeAndName(pre, sem->ReturnType(), type::AddressSpace::kUndefined, + if (!EmitTypeAndName(pre, sem->ReturnType(), builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, typedef_name)) { return false; } pre << ";"; out << typedef_name; } else { - if (!EmitType(out, sem->ReturnType(), type::AddressSpace::kUndefined, + if (!EmitType(out, sem->ReturnType(), builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) { return false; } @@ -2909,14 +2910,14 @@ bool GeneratorImpl::EmitFunction(const ast::Function* func) { first = false; auto const* type = v->Type(); - auto address_space = type::AddressSpace::kUndefined; + auto address_space = builtin::AddressSpace::kUndefined; auto access = builtin::Access::kUndefined; if (auto* ptr = type->As()) { type = ptr->StoreType(); switch (ptr->AddressSpace()) { - case type::AddressSpace::kStorage: - case type::AddressSpace::kUniform: + case builtin::AddressSpace::kStorage: + case builtin::AddressSpace::kUniform: // Not allowed by WGSL, but is used by certain transforms (e.g. DMA) to pass // storage buffers and uniform buffers down into transform-generated // functions. In this situation we want to generate the parameter without an @@ -2983,7 +2984,7 @@ bool GeneratorImpl::EmitFunctionBodyWithDiscard(const ast::Function* func) { auto name = builder_.Symbols().NameFor(builder_.Symbols().New("unused")); { auto out = line(); - if (!EmitTypeAndName(out, sem->ReturnType(), type::AddressSpace::kUndefined, + if (!EmitTypeAndName(out, sem->ReturnType(), builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, name)) { return false; } @@ -3000,17 +3001,17 @@ bool GeneratorImpl::EmitGlobalVariable(const ast::Variable* global) { [&](const ast::Var* var) { auto* sem = builder_.Sem().Get(global); switch (sem->AddressSpace()) { - case type::AddressSpace::kUniform: + case builtin::AddressSpace::kUniform: return EmitUniformVariable(var, sem); - case type::AddressSpace::kStorage: + case builtin::AddressSpace::kStorage: return EmitStorageVariable(var, sem); - case type::AddressSpace::kHandle: + case builtin::AddressSpace::kHandle: return EmitHandleVariable(var, sem); - case type::AddressSpace::kPrivate: + case builtin::AddressSpace::kPrivate: return EmitPrivateVariable(sem); - case type::AddressSpace::kWorkgroup: + case builtin::AddressSpace::kWorkgroup: return EmitWorkgroupVariable(sem); - case type::AddressSpace::kPushConstant: + case builtin::AddressSpace::kPushConstant: diagnostics_.add_error( diag::System::Writer, "unhandled address space " + utils::ToString(sem->AddressSpace())); @@ -3049,7 +3050,7 @@ bool GeneratorImpl::EmitUniformVariable(const ast::Var* var, const sem::Variable { ScopedIndent si(this); auto out = line(); - if (!EmitTypeAndName(out, type, type::AddressSpace::kUniform, sem->Access(), name)) { + if (!EmitTypeAndName(out, type, builtin::AddressSpace::kUniform, sem->Access(), name)) { return false; } out << ";"; @@ -3063,7 +3064,7 @@ bool GeneratorImpl::EmitUniformVariable(const ast::Var* var, const sem::Variable bool GeneratorImpl::EmitStorageVariable(const ast::Var* var, const sem::Variable* sem) { auto* type = sem->Type()->UnwrapRef(); auto out = line(); - if (!EmitTypeAndName(out, type, type::AddressSpace::kStorage, sem->Access(), + if (!EmitTypeAndName(out, type, builtin::AddressSpace::kStorage, sem->Access(), builder_.Symbols().NameFor(var->name->symbol))) { return false; } @@ -3241,7 +3242,7 @@ bool GeneratorImpl::EmitEntryPointFunction(const ast::Function* func) { out << ")]" << std::endl; } - if (!EmitTypeAndName(out, func_sem->ReturnType(), type::AddressSpace::kUndefined, + if (!EmitTypeAndName(out, func_sem->ReturnType(), builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, builder_.Symbols().NameFor(func->name->symbol))) { return false; @@ -3337,7 +3338,7 @@ bool GeneratorImpl::EmitConstant(std::ostream& out, return true; } - if (!EmitType(out, v, type::AddressSpace::kUndefined, builtin::Access::kUndefined, + if (!EmitType(out, v, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, "")) { return false; } @@ -3355,7 +3356,7 @@ bool GeneratorImpl::EmitConstant(std::ostream& out, return true; }, [&](const type::Matrix* m) { - if (!EmitType(out, m, type::AddressSpace::kUndefined, builtin::Access::kUndefined, + if (!EmitType(out, m, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, "")) { return false; } @@ -3375,8 +3376,8 @@ bool GeneratorImpl::EmitConstant(std::ostream& out, [&](const type::Array* a) { if (constant->AllZero()) { out << "("; - if (!EmitType(out, a, type::AddressSpace::kUndefined, builtin::Access::kUndefined, - "")) { + if (!EmitType(out, a, builtin::AddressSpace::kUndefined, + builtin::Access::kUndefined, "")) { return false; } out << ")0"; @@ -3516,7 +3517,7 @@ bool GeneratorImpl::EmitValue(std::ostream& out, const type::Type* type, int val return true; }, [&](const type::Vector* vec) { - if (!EmitType(out, type, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, + if (!EmitType(out, type, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) { return false; } @@ -3532,7 +3533,7 @@ bool GeneratorImpl::EmitValue(std::ostream& out, const type::Type* type, int val return true; }, [&](const type::Matrix* mat) { - if (!EmitType(out, type, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, + if (!EmitType(out, type, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) { return false; } @@ -3550,14 +3551,14 @@ bool GeneratorImpl::EmitValue(std::ostream& out, const type::Type* type, int val [&](const sem::Struct*) { out << "("; TINT_DEFER(out << ")" << value); - return EmitType(out, type, type::AddressSpace::kUndefined, builtin::Access::kUndefined, - ""); + return EmitType(out, type, builtin::AddressSpace::kUndefined, + builtin::Access::kUndefined, ""); }, [&](const type::Array*) { out << "("; TINT_DEFER(out << ")" << value); - return EmitType(out, type, type::AddressSpace::kUndefined, builtin::Access::kUndefined, - ""); + return EmitType(out, type, builtin::AddressSpace::kUndefined, + builtin::Access::kUndefined, ""); }, [&](Default) { diagnostics_.add_error( @@ -3931,7 +3932,7 @@ bool GeneratorImpl::EmitSwitch(const ast::SwitchStatement* stmt) { bool GeneratorImpl::EmitType(std::ostream& out, const type::Type* type, - type::AddressSpace address_space, + builtin::AddressSpace address_space, builtin::Access access, const std::string& name, bool* name_printed /* = nullptr */) { @@ -3939,13 +3940,13 @@ bool GeneratorImpl::EmitType(std::ostream& out, *name_printed = false; } switch (address_space) { - case type::AddressSpace::kStorage: + case builtin::AddressSpace::kStorage: if (access != builtin::Access::kRead) { out << "RW"; } out << "ByteAddressBuffer"; return true; - case type::AddressSpace::kUniform: { + case builtin::AddressSpace::kUniform: { auto array_length = (type->Size() + 15) / 16; out << "uint4 " << name << "[" << array_length << "]"; if (name_printed) { @@ -4158,7 +4159,7 @@ bool GeneratorImpl::EmitType(std::ostream& out, bool GeneratorImpl::EmitTypeAndName(std::ostream& out, const type::Type* type, - type::AddressSpace address_space, + builtin::AddressSpace address_space, builtin::Access access, const std::string& name) { bool name_printed = false; @@ -4241,7 +4242,7 @@ bool GeneratorImpl::EmitStructType(TextBuffer* b, const sem::Struct* str) { } out << pre; - if (!EmitTypeAndName(out, ty, type::AddressSpace::kUndefined, + if (!EmitTypeAndName(out, ty, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, mem_name)) { return false; } @@ -4311,7 +4312,7 @@ bool GeneratorImpl::EmitLet(const ast::Let* let) { auto out = line(); out << "const "; - if (!EmitTypeAndName(out, type, type::AddressSpace::kUndefined, builtin::Access::kUndefined, + if (!EmitTypeAndName(out, type, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, builder_.Symbols().NameFor(let->name->symbol))) { return false; } @@ -4338,7 +4339,7 @@ bool GeneratorImpl::CallBuiltinHelper(std::ostream& out, std::vector parameter_names; { auto decl = line(&b); - if (!EmitTypeAndName(decl, builtin->ReturnType(), type::AddressSpace::kUndefined, + if (!EmitTypeAndName(decl, builtin->ReturnType(), builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, fn_name)) { return ""; } @@ -4354,7 +4355,7 @@ bool GeneratorImpl::CallBuiltinHelper(std::ostream& out, decl << "inout "; ty = ptr->StoreType(); } - if (!EmitTypeAndName(decl, ty, type::AddressSpace::kUndefined, + if (!EmitTypeAndName(decl, ty, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, param_name)) { return ""; } diff --git a/src/tint/writer/hlsl/generator_impl.h b/src/tint/writer/hlsl/generator_impl.h index 1e2faa120f..da846f424a 100644 --- a/src/tint/writer/hlsl/generator_impl.h +++ b/src/tint/writer/hlsl/generator_impl.h @@ -413,7 +413,7 @@ class GeneratorImpl : public TextGenerator { /// @returns true if the type is emitted bool EmitType(std::ostream& out, const type::Type* type, - type::AddressSpace address_space, + builtin::AddressSpace address_space, builtin::Access access, const std::string& name, bool* name_printed = nullptr); @@ -426,7 +426,7 @@ class GeneratorImpl : public TextGenerator { /// @returns true if the type is emitted bool EmitTypeAndName(std::ostream& out, const type::Type* type, - type::AddressSpace address_space, + builtin::AddressSpace address_space, builtin::Access access, const std::string& name); /// Handles generating a structure declaration. If the structure has already been emitted, then diff --git a/src/tint/writer/hlsl/generator_impl_array_accessor_test.cc b/src/tint/writer/hlsl/generator_impl_array_accessor_test.cc index 71bf057567..73eea9675c 100644 --- a/src/tint/writer/hlsl/generator_impl_array_accessor_test.cc +++ b/src/tint/writer/hlsl/generator_impl_array_accessor_test.cc @@ -22,7 +22,7 @@ namespace { using HlslGeneratorImplTest_Expression = TestHelper; TEST_F(HlslGeneratorImplTest_Expression, IndexAccessor) { - GlobalVar("ary", ty.array(), type::AddressSpace::kPrivate); + GlobalVar("ary", ty.array(), builtin::AddressSpace::kPrivate); auto* expr = IndexAccessor("ary", 5_i); WrapInFunction(expr); diff --git a/src/tint/writer/hlsl/generator_impl_binary_test.cc b/src/tint/writer/hlsl/generator_impl_binary_test.cc index eee3fedd0a..c99ae54524 100644 --- a/src/tint/writer/hlsl/generator_impl_binary_test.cc +++ b/src/tint/writer/hlsl/generator_impl_binary_test.cc @@ -50,8 +50,8 @@ TEST_P(HlslBinaryTest, Emit_f32) { return; } - GlobalVar("left", ty.f32(), type::AddressSpace::kPrivate); - GlobalVar("right", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("left", ty.f32(), builtin::AddressSpace::kPrivate); + GlobalVar("right", ty.f32(), builtin::AddressSpace::kPrivate); auto* left = Expr("left"); auto* right = Expr("right"); @@ -82,8 +82,8 @@ TEST_P(HlslBinaryTest, Emit_f16) { Enable(builtin::Extension::kF16); - GlobalVar("left", ty.f16(), type::AddressSpace::kPrivate); - GlobalVar("right", ty.f16(), type::AddressSpace::kPrivate); + GlobalVar("left", ty.f16(), builtin::AddressSpace::kPrivate); + GlobalVar("right", ty.f16(), builtin::AddressSpace::kPrivate); auto* left = Expr("left"); auto* right = Expr("right"); @@ -105,8 +105,8 @@ TEST_P(HlslBinaryTest, Emit_u32) { return; } - GlobalVar("left", ty.u32(), type::AddressSpace::kPrivate); - GlobalVar("right", ty.u32(), type::AddressSpace::kPrivate); + GlobalVar("left", ty.u32(), builtin::AddressSpace::kPrivate); + GlobalVar("right", ty.u32(), builtin::AddressSpace::kPrivate); auto* left = Expr("left"); auto* right = Expr("right"); @@ -133,8 +133,8 @@ TEST_P(HlslBinaryTest, Emit_i32) { return; } - GlobalVar("left", ty.i32(), type::AddressSpace::kPrivate); - GlobalVar("right", ty.i32(), type::AddressSpace::kPrivate); + GlobalVar("left", ty.i32(), builtin::AddressSpace::kPrivate); + GlobalVar("right", ty.i32(), builtin::AddressSpace::kPrivate); auto* left = Expr("left"); auto* right = Expr("right"); @@ -237,7 +237,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_ScalarVector_f16) { } TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixScalar_f32) { - GlobalVar("mat", ty.mat3x3(), type::AddressSpace::kPrivate); + GlobalVar("mat", ty.mat3x3(), builtin::AddressSpace::kPrivate); auto* lhs = Expr("mat"); auto* rhs = Expr(1_f); @@ -254,7 +254,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixScalar_f32) { TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixScalar_f16) { Enable(builtin::Extension::kF16); - GlobalVar("mat", ty.mat3x3(), type::AddressSpace::kPrivate); + GlobalVar("mat", ty.mat3x3(), builtin::AddressSpace::kPrivate); auto* lhs = Expr("mat"); auto* rhs = Expr(1_h); @@ -269,7 +269,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixScalar_f16) { } TEST_F(HlslGeneratorImplTest_Binary, Multiply_ScalarMatrix_f32) { - GlobalVar("mat", ty.mat3x3(), type::AddressSpace::kPrivate); + GlobalVar("mat", ty.mat3x3(), builtin::AddressSpace::kPrivate); auto* lhs = Expr(1_f); auto* rhs = Expr("mat"); @@ -286,7 +286,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_ScalarMatrix_f32) { TEST_F(HlslGeneratorImplTest_Binary, Multiply_ScalarMatrix_f16) { Enable(builtin::Extension::kF16); - GlobalVar("mat", ty.mat3x3(), type::AddressSpace::kPrivate); + GlobalVar("mat", ty.mat3x3(), builtin::AddressSpace::kPrivate); auto* lhs = Expr(1_h); auto* rhs = Expr("mat"); @@ -301,7 +301,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_ScalarMatrix_f16) { } TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixVector_f32) { - GlobalVar("mat", ty.mat3x3(), type::AddressSpace::kPrivate); + GlobalVar("mat", ty.mat3x3(), builtin::AddressSpace::kPrivate); auto* lhs = Expr("mat"); auto* rhs = vec3(1_f, 1_f, 1_f); @@ -318,7 +318,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixVector_f32) { TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixVector_f16) { Enable(builtin::Extension::kF16); - GlobalVar("mat", ty.mat3x3(), type::AddressSpace::kPrivate); + GlobalVar("mat", ty.mat3x3(), builtin::AddressSpace::kPrivate); auto* lhs = Expr("mat"); auto* rhs = vec3(1_h, 1_h, 1_h); @@ -333,7 +333,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixVector_f16) { } TEST_F(HlslGeneratorImplTest_Binary, Multiply_VectorMatrix_f32) { - GlobalVar("mat", ty.mat3x3(), type::AddressSpace::kPrivate); + GlobalVar("mat", ty.mat3x3(), builtin::AddressSpace::kPrivate); auto* lhs = vec3(1_f, 1_f, 1_f); auto* rhs = Expr("mat"); @@ -350,7 +350,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_VectorMatrix_f32) { TEST_F(HlslGeneratorImplTest_Binary, Multiply_VectorMatrix_f16) { Enable(builtin::Extension::kF16); - GlobalVar("mat", ty.mat3x3(), type::AddressSpace::kPrivate); + GlobalVar("mat", ty.mat3x3(), builtin::AddressSpace::kPrivate); auto* lhs = vec3(1_h, 1_h, 1_h); auto* rhs = Expr("mat"); @@ -365,8 +365,8 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_VectorMatrix_f16) { } TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixMatrix_f32) { - GlobalVar("lhs", ty.mat3x3(), type::AddressSpace::kPrivate); - GlobalVar("rhs", ty.mat3x3(), type::AddressSpace::kPrivate); + GlobalVar("lhs", ty.mat3x3(), builtin::AddressSpace::kPrivate); + GlobalVar("rhs", ty.mat3x3(), builtin::AddressSpace::kPrivate); auto* expr = create(ast::BinaryOp::kMultiply, Expr("lhs"), Expr("rhs")); WrapInFunction(expr); @@ -381,8 +381,8 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixMatrix_f32) { TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixMatrix_f16) { Enable(builtin::Extension::kF16); - GlobalVar("lhs", ty.mat3x3(), type::AddressSpace::kPrivate); - GlobalVar("rhs", ty.mat3x3(), type::AddressSpace::kPrivate); + GlobalVar("lhs", ty.mat3x3(), builtin::AddressSpace::kPrivate); + GlobalVar("rhs", ty.mat3x3(), builtin::AddressSpace::kPrivate); auto* expr = create(ast::BinaryOp::kMultiply, Expr("lhs"), Expr("rhs")); WrapInFunction(expr); @@ -395,8 +395,8 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixMatrix_f16) { } TEST_F(HlslGeneratorImplTest_Binary, Logical_And) { - GlobalVar("a", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("b", ty.bool_(), type::AddressSpace::kPrivate); + GlobalVar("a", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("b", ty.bool_(), builtin::AddressSpace::kPrivate); auto* expr = create(ast::BinaryOp::kLogicalAnd, Expr("a"), Expr("b")); WrapInFunction(expr); @@ -415,10 +415,10 @@ if (tint_tmp) { TEST_F(HlslGeneratorImplTest_Binary, Logical_Multi) { // (a && b) || (c || d) - GlobalVar("a", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("b", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("c", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("d", ty.bool_(), type::AddressSpace::kPrivate); + GlobalVar("a", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("b", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("c", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("d", ty.bool_(), builtin::AddressSpace::kPrivate); auto* expr = create( ast::BinaryOp::kLogicalOr, @@ -447,8 +447,8 @@ if (!tint_tmp) { } TEST_F(HlslGeneratorImplTest_Binary, Logical_Or) { - GlobalVar("a", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("b", ty.bool_(), type::AddressSpace::kPrivate); + GlobalVar("a", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("b", ty.bool_(), builtin::AddressSpace::kPrivate); auto* expr = create(ast::BinaryOp::kLogicalOr, Expr("a"), Expr("b")); WrapInFunction(expr); @@ -474,9 +474,9 @@ TEST_F(HlslGeneratorImplTest_Binary, If_WithLogical) { // return 3i; // } - GlobalVar("a", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("b", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("c", ty.bool_(), type::AddressSpace::kPrivate); + GlobalVar("a", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("b", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("c", ty.bool_(), builtin::AddressSpace::kPrivate); auto* expr = If(create(ast::BinaryOp::kLogicalAnd, Expr("a"), Expr("b")), @@ -511,9 +511,9 @@ if ((tint_tmp)) { TEST_F(HlslGeneratorImplTest_Binary, Return_WithLogical) { // return (a && b) || c; - GlobalVar("a", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("b", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("c", ty.bool_(), type::AddressSpace::kPrivate); + GlobalVar("a", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("b", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("c", ty.bool_(), builtin::AddressSpace::kPrivate); auto* expr = Return(create( ast::BinaryOp::kLogicalOr, @@ -539,10 +539,10 @@ return (tint_tmp); TEST_F(HlslGeneratorImplTest_Binary, Assign_WithLogical) { // a = (b || c) && d; - GlobalVar("a", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("b", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("c", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("d", ty.bool_(), type::AddressSpace::kPrivate); + GlobalVar("a", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("b", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("c", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("d", ty.bool_(), builtin::AddressSpace::kPrivate); auto* expr = Assign(Expr("a"), @@ -570,12 +570,12 @@ a = (tint_tmp); TEST_F(HlslGeneratorImplTest_Binary, Decl_WithLogical) { // var a : bool = (b && c) || d; - GlobalVar("b", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("c", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("d", ty.bool_(), type::AddressSpace::kPrivate); + GlobalVar("b", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("c", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("d", ty.bool_(), builtin::AddressSpace::kPrivate); auto* var = - Var("a", ty.bool_(), type::AddressSpace::kUndefined, + Var("a", ty.bool_(), builtin::AddressSpace::kUndefined, create( ast::BinaryOp::kLogicalOr, create(ast::BinaryOp::kLogicalAnd, Expr("b"), Expr("c")), @@ -609,10 +609,10 @@ TEST_F(HlslGeneratorImplTest_Binary, Call_WithLogical) { Param(Sym(), ty.bool_()), }, ty.void_(), utils::Empty, utils::Empty); - GlobalVar("a", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("b", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("c", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("d", ty.bool_(), type::AddressSpace::kPrivate); + GlobalVar("a", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("b", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("c", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("d", ty.bool_(), builtin::AddressSpace::kPrivate); utils::Vector params{ create(ast::BinaryOp::kLogicalAnd, Expr("a"), Expr("b")), diff --git a/src/tint/writer/hlsl/generator_impl_builtin_test.cc b/src/tint/writer/hlsl/generator_impl_builtin_test.cc index 9811b79eb2..c3b5b4911a 100644 --- a/src/tint/writer/hlsl/generator_impl_builtin_test.cc +++ b/src/tint/writer/hlsl/generator_impl_builtin_test.cc @@ -197,19 +197,19 @@ TEST_P(HlslBuiltinTest, Emit) { if (param.type == CallParamType::kF16) { Enable(builtin::Extension::kF16); - GlobalVar("h2", ty.vec2(), type::AddressSpace::kPrivate); - GlobalVar("h3", ty.vec3(), type::AddressSpace::kPrivate); - GlobalVar("hm2x2", ty.mat2x2(), type::AddressSpace::kPrivate); - GlobalVar("hm3x2", ty.mat3x2(), type::AddressSpace::kPrivate); + GlobalVar("h2", ty.vec2(), builtin::AddressSpace::kPrivate); + GlobalVar("h3", ty.vec3(), builtin::AddressSpace::kPrivate); + GlobalVar("hm2x2", ty.mat2x2(), builtin::AddressSpace::kPrivate); + GlobalVar("hm3x2", ty.mat3x2(), builtin::AddressSpace::kPrivate); } - GlobalVar("f2", ty.vec2(), type::AddressSpace::kPrivate); - GlobalVar("f3", ty.vec3(), type::AddressSpace::kPrivate); - GlobalVar("u2", ty.vec2(), type::AddressSpace::kPrivate); - GlobalVar("i2", ty.vec2(), type::AddressSpace::kPrivate); - GlobalVar("b2", ty.vec2(), type::AddressSpace::kPrivate); - GlobalVar("m2x2", ty.mat2x2(), type::AddressSpace::kPrivate); - GlobalVar("m3x2", ty.mat3x2(), type::AddressSpace::kPrivate); + GlobalVar("f2", ty.vec2(), builtin::AddressSpace::kPrivate); + GlobalVar("f3", ty.vec3(), builtin::AddressSpace::kPrivate); + GlobalVar("u2", ty.vec2(), builtin::AddressSpace::kPrivate); + GlobalVar("i2", ty.vec2(), builtin::AddressSpace::kPrivate); + GlobalVar("b2", ty.vec2(), builtin::AddressSpace::kPrivate); + GlobalVar("m2x2", ty.mat2x2(), builtin::AddressSpace::kPrivate); + GlobalVar("m3x2", ty.mat3x2(), builtin::AddressSpace::kPrivate); auto* call = GenerateCall(param.builtin, param.type, this); ASSERT_NE(nullptr, call) << "Unhandled builtin"; @@ -339,8 +339,8 @@ INSTANTIATE_TEST_SUITE_P( TEST_F(HlslGeneratorImplTest_Builtin, Builtin_Call) { auto* call = Call("dot", "param1", "param2"); - GlobalVar("param1", ty.vec3(), type::AddressSpace::kPrivate); - GlobalVar("param2", ty.vec3(), type::AddressSpace::kPrivate); + GlobalVar("param1", ty.vec3(), builtin::AddressSpace::kPrivate); + GlobalVar("param2", ty.vec3(), builtin::AddressSpace::kPrivate); WrapInFunction(CallStmt(call)); @@ -353,8 +353,8 @@ TEST_F(HlslGeneratorImplTest_Builtin, Builtin_Call) { } TEST_F(HlslGeneratorImplTest_Builtin, Select_Scalar) { - GlobalVar("a", Expr(1_f), type::AddressSpace::kPrivate); - GlobalVar("b", Expr(2_f), type::AddressSpace::kPrivate); + GlobalVar("a", Expr(1_f), builtin::AddressSpace::kPrivate); + GlobalVar("b", Expr(2_f), builtin::AddressSpace::kPrivate); auto* call = Call("select", "a", "b", true); WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); @@ -366,8 +366,8 @@ TEST_F(HlslGeneratorImplTest_Builtin, Select_Scalar) { } TEST_F(HlslGeneratorImplTest_Builtin, Select_Vector) { - GlobalVar("a", vec2(1_i, 2_i), type::AddressSpace::kPrivate); - GlobalVar("b", vec2(3_i, 4_i), type::AddressSpace::kPrivate); + GlobalVar("a", vec2(1_i, 2_i), builtin::AddressSpace::kPrivate); + GlobalVar("b", vec2(3_i, 4_i), builtin::AddressSpace::kPrivate); auto* call = Call("select", "a", "b", vec2(true, false)); WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); @@ -1086,7 +1086,7 @@ void test_function() { TEST_F(HlslGeneratorImplTest_Builtin, Pack4x8Snorm) { auto* call = Call("pack4x8snorm", "p1"); - GlobalVar("p1", ty.vec4(), type::AddressSpace::kPrivate); + GlobalVar("p1", ty.vec4(), builtin::AddressSpace::kPrivate); WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); @@ -1108,7 +1108,7 @@ void test_function() { TEST_F(HlslGeneratorImplTest_Builtin, Pack4x8Unorm) { auto* call = Call("pack4x8unorm", "p1"); - GlobalVar("p1", ty.vec4(), type::AddressSpace::kPrivate); + GlobalVar("p1", ty.vec4(), builtin::AddressSpace::kPrivate); WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); @@ -1130,7 +1130,7 @@ void test_function() { TEST_F(HlslGeneratorImplTest_Builtin, Pack2x16Snorm) { auto* call = Call("pack2x16snorm", "p1"); - GlobalVar("p1", ty.vec2(), type::AddressSpace::kPrivate); + GlobalVar("p1", ty.vec2(), builtin::AddressSpace::kPrivate); WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); @@ -1152,7 +1152,7 @@ void test_function() { TEST_F(HlslGeneratorImplTest_Builtin, Pack2x16Unorm) { auto* call = Call("pack2x16unorm", "p1"); - GlobalVar("p1", ty.vec2(), type::AddressSpace::kPrivate); + GlobalVar("p1", ty.vec2(), builtin::AddressSpace::kPrivate); WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); @@ -1174,7 +1174,7 @@ void test_function() { TEST_F(HlslGeneratorImplTest_Builtin, Pack2x16Float) { auto* call = Call("pack2x16float", "p1"); - GlobalVar("p1", ty.vec2(), type::AddressSpace::kPrivate); + GlobalVar("p1", ty.vec2(), builtin::AddressSpace::kPrivate); WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); @@ -1196,7 +1196,7 @@ void test_function() { TEST_F(HlslGeneratorImplTest_Builtin, Unpack4x8Snorm) { auto* call = Call("unpack4x8snorm", "p1"); - GlobalVar("p1", ty.u32(), type::AddressSpace::kPrivate); + GlobalVar("p1", ty.u32(), builtin::AddressSpace::kPrivate); WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); @@ -1219,7 +1219,7 @@ void test_function() { TEST_F(HlslGeneratorImplTest_Builtin, Unpack4x8Unorm) { auto* call = Call("unpack4x8unorm", "p1"); - GlobalVar("p1", ty.u32(), type::AddressSpace::kPrivate); + GlobalVar("p1", ty.u32(), builtin::AddressSpace::kPrivate); WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); @@ -1242,7 +1242,7 @@ void test_function() { TEST_F(HlslGeneratorImplTest_Builtin, Unpack2x16Snorm) { auto* call = Call("unpack2x16snorm", "p1"); - GlobalVar("p1", ty.u32(), type::AddressSpace::kPrivate); + GlobalVar("p1", ty.u32(), builtin::AddressSpace::kPrivate); WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); @@ -1265,7 +1265,7 @@ void test_function() { TEST_F(HlslGeneratorImplTest_Builtin, Unpack2x16Unorm) { auto* call = Call("unpack2x16unorm", "p1"); - GlobalVar("p1", ty.u32(), type::AddressSpace::kPrivate); + GlobalVar("p1", ty.u32(), builtin::AddressSpace::kPrivate); WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); @@ -1288,7 +1288,7 @@ void test_function() { TEST_F(HlslGeneratorImplTest_Builtin, Unpack2x16Float) { auto* call = Call("unpack2x16float", "p1"); - GlobalVar("p1", ty.u32(), type::AddressSpace::kPrivate); + GlobalVar("p1", ty.u32(), builtin::AddressSpace::kPrivate); WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); diff --git a/src/tint/writer/hlsl/generator_impl_call_test.cc b/src/tint/writer/hlsl/generator_impl_call_test.cc index 46b14061ed..9947a081bf 100644 --- a/src/tint/writer/hlsl/generator_impl_call_test.cc +++ b/src/tint/writer/hlsl/generator_impl_call_test.cc @@ -42,8 +42,8 @@ TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithParams) { Param(Sym(), ty.f32()), }, ty.f32(), utils::Vector{Return(1.23_f)}); - GlobalVar("param1", ty.f32(), type::AddressSpace::kPrivate); - GlobalVar("param2", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("param1", ty.f32(), builtin::AddressSpace::kPrivate); + GlobalVar("param2", ty.f32(), builtin::AddressSpace::kPrivate); auto* call = Call("my_func", "param1", "param2"); WrapInFunction(call); @@ -62,8 +62,8 @@ TEST_F(HlslGeneratorImplTest_Call, EmitStatement_Call) { Param(Sym(), ty.f32()), }, ty.void_(), utils::Empty, utils::Empty); - GlobalVar("param1", ty.f32(), type::AddressSpace::kPrivate); - GlobalVar("param2", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("param1", ty.f32(), builtin::AddressSpace::kPrivate); + GlobalVar("param2", ty.f32(), builtin::AddressSpace::kPrivate); auto* call = CallStmt(Call("my_func", "param1", "param2")); WrapInFunction(call); diff --git a/src/tint/writer/hlsl/generator_impl_function_test.cc b/src/tint/writer/hlsl/generator_impl_function_test.cc index 43e474ad16..fbef3f2961 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 @@ TEST_F(HlslGeneratorImplTest_Function, PtrParameter) { // fn f(foo : ptr) -> f32 { // return *foo; // } - Func("f", utils::Vector{Param("foo", ty.pointer(type::AddressSpace::kFunction))}, ty.f32(), - utils::Vector{Return(Deref("foo"))}); + Func("f", utils::Vector{Param("foo", ty.pointer(builtin::AddressSpace::kFunction))}, + ty.f32(), utils::Vector{Return(Deref("foo"))}); GeneratorImpl& gen = SanitizeAndBuild(); @@ -360,7 +360,7 @@ tint_symbol_1 vert_main2() { TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_Uniform) { auto* ubo_ty = Structure("UBO", utils::Vector{Member("coord", ty.vec4())}); auto* ubo = - GlobalVar("ubo", ty.Of(ubo_ty), type::AddressSpace::kUniform, Binding(0_a), Group(1_a)); + GlobalVar("ubo", ty.Of(ubo_ty), builtin::AddressSpace::kUniform, Binding(0_a), Group(1_a)); Func("sub_func", utils::Vector{ @@ -403,7 +403,7 @@ void frag_main() { TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_UniformStruct) { auto* s = Structure("Uniforms", utils::Vector{Member("coord", ty.vec4())}); - GlobalVar("uniforms", ty.Of(s), type::AddressSpace::kUniform, Binding(0_a), Group(1_a)); + GlobalVar("uniforms", ty.Of(s), builtin::AddressSpace::kUniform, Binding(0_a), Group(1_a)); auto* var = Var("v", ty.f32(), MemberAccessor(MemberAccessor("uniforms", "coord"), "x")); @@ -436,7 +436,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RW_Storage Member("b", ty.f32()), }); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + GlobalVar("coord", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, Binding(0_a), Group(1_a)); auto* var = Var("v", ty.f32(), MemberAccessor("coord", "b")); @@ -469,8 +469,8 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RO_Storage Member("b", ty.f32()), }); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), - Group(1_a)); + GlobalVar("coord", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kRead, + Binding(0_a), Group(1_a)); auto* var = Var("v", ty.f32(), MemberAccessor("coord", "b")); @@ -502,7 +502,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_WO_Storage Member("b", ty.f32()), }); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + GlobalVar("coord", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, Binding(0_a), Group(1_a)); Func("frag_main", utils::Empty, ty.void_(), @@ -533,7 +533,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_StorageBuf Member("b", ty.f32()), }); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + GlobalVar("coord", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, Binding(0_a), Group(1_a)); Func("frag_main", utils::Empty, ty.void_(), @@ -560,7 +560,7 @@ void frag_main() { TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_Uniform) { auto* s = Structure("S", utils::Vector{Member("x", ty.f32())}); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kUniform, Binding(0_a), Group(1_a)); + GlobalVar("coord", ty.Of(s), builtin::AddressSpace::kUniform, Binding(0_a), Group(1_a)); Func("sub_func", utils::Vector{ @@ -602,7 +602,7 @@ void frag_main() { TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_StorageBuffer) { auto* s = Structure("S", utils::Vector{Member("x", ty.f32())}); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + GlobalVar("coord", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, Binding(0_a), Group(1_a)); Func("sub_func", @@ -830,7 +830,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Multiple_EntryPoint_With_Same_Module auto* s = Structure("Data", utils::Vector{Member("d", ty.f32())}); - GlobalVar("data", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + GlobalVar("data", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, Binding(0_a), Group(0_a)); { diff --git a/src/tint/writer/hlsl/generator_impl_identifier_test.cc b/src/tint/writer/hlsl/generator_impl_identifier_test.cc index c28e757cc6..1e2b47b01d 100644 --- a/src/tint/writer/hlsl/generator_impl_identifier_test.cc +++ b/src/tint/writer/hlsl/generator_impl_identifier_test.cc @@ -20,7 +20,7 @@ namespace { using HlslGeneratorImplTest_Identifier = TestHelper; TEST_F(HlslGeneratorImplTest_Identifier, EmitIdentifierExpression) { - GlobalVar("foo", ty.i32(), type::AddressSpace::kPrivate); + GlobalVar("foo", ty.i32(), builtin::AddressSpace::kPrivate); auto* i = Expr("foo"); WrapInFunction(i); diff --git a/src/tint/writer/hlsl/generator_impl_if_test.cc b/src/tint/writer/hlsl/generator_impl_if_test.cc index c599648c62..9feb41ef11 100644 --- a/src/tint/writer/hlsl/generator_impl_if_test.cc +++ b/src/tint/writer/hlsl/generator_impl_if_test.cc @@ -20,7 +20,7 @@ namespace { using HlslGeneratorImplTest_If = TestHelper; TEST_F(HlslGeneratorImplTest_If, Emit_If) { - GlobalVar("cond", ty.bool_(), type::AddressSpace::kPrivate); + GlobalVar("cond", ty.bool_(), builtin::AddressSpace::kPrivate); auto* cond = Expr("cond"); auto* body = Block(Return()); @@ -38,8 +38,8 @@ TEST_F(HlslGeneratorImplTest_If, Emit_If) { } TEST_F(HlslGeneratorImplTest_If, Emit_IfWithElseIf) { - GlobalVar("cond", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("else_cond", ty.bool_(), type::AddressSpace::kPrivate); + GlobalVar("cond", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("else_cond", ty.bool_(), builtin::AddressSpace::kPrivate); auto* else_cond = Expr("else_cond"); auto* else_body = Block(Return()); @@ -65,7 +65,7 @@ TEST_F(HlslGeneratorImplTest_If, Emit_IfWithElseIf) { } TEST_F(HlslGeneratorImplTest_If, Emit_IfWithElse) { - GlobalVar("cond", ty.bool_(), type::AddressSpace::kPrivate); + GlobalVar("cond", ty.bool_(), builtin::AddressSpace::kPrivate); auto* else_body = Block(Return()); @@ -88,8 +88,8 @@ TEST_F(HlslGeneratorImplTest_If, Emit_IfWithElse) { } TEST_F(HlslGeneratorImplTest_If, Emit_IfWithMultiple) { - GlobalVar("cond", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("else_cond", ty.bool_(), type::AddressSpace::kPrivate); + GlobalVar("cond", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("else_cond", ty.bool_(), builtin::AddressSpace::kPrivate); auto* else_cond = Expr("else_cond"); diff --git a/src/tint/writer/hlsl/generator_impl_import_test.cc b/src/tint/writer/hlsl/generator_impl_import_test.cc index de864c426a..425c6639ae 100644 --- a/src/tint/writer/hlsl/generator_impl_import_test.cc +++ b/src/tint/writer/hlsl/generator_impl_import_test.cc @@ -252,7 +252,7 @@ INSTANTIATE_TEST_SUITE_P(HlslGeneratorImplTest_Import, testing::Values(HlslImportData{"clamp", "clamp"})); TEST_F(HlslGeneratorImplTest_Import, HlslImportData_Determinant) { - GlobalVar("var", ty.mat3x3(), type::AddressSpace::kPrivate); + GlobalVar("var", ty.mat3x3(), builtin::AddressSpace::kPrivate); auto* expr = Call("determinant", "var"); WrapInFunction(expr); @@ -265,7 +265,7 @@ TEST_F(HlslGeneratorImplTest_Import, HlslImportData_Determinant) { } TEST_F(HlslGeneratorImplTest_Import, HlslImportData_QuantizeToF16_Scalar) { - GlobalVar("v", Expr(2_f), type::AddressSpace::kPrivate); + GlobalVar("v", Expr(2_f), builtin::AddressSpace::kPrivate); auto* expr = Call("quantizeToF16", "v"); WrapInFunction(expr); @@ -278,7 +278,7 @@ TEST_F(HlslGeneratorImplTest_Import, HlslImportData_QuantizeToF16_Scalar) { } TEST_F(HlslGeneratorImplTest_Import, HlslImportData_QuantizeToF16_Vector) { - GlobalVar("v", vec3(2_f), type::AddressSpace::kPrivate); + GlobalVar("v", vec3(2_f), builtin::AddressSpace::kPrivate); auto* expr = Call("quantizeToF16", "v"); WrapInFunction(expr); diff --git a/src/tint/writer/hlsl/generator_impl_loop_test.cc b/src/tint/writer/hlsl/generator_impl_loop_test.cc index 620543d12b..45bf04ad8f 100644 --- a/src/tint/writer/hlsl/generator_impl_loop_test.cc +++ b/src/tint/writer/hlsl/generator_impl_loop_test.cc @@ -93,8 +93,8 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_LoopWithContinuing_BreakIf) { TEST_F(HlslGeneratorImplTest_Loop, Emit_LoopNestedWithContinuing) { Func("a_statement", {}, ty.void_(), {}); - GlobalVar("lhs", ty.f32(), type::AddressSpace::kPrivate); - GlobalVar("rhs", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("lhs", ty.f32(), builtin::AddressSpace::kPrivate); + GlobalVar("rhs", ty.f32(), builtin::AddressSpace::kPrivate); auto* body = Block(Break()); auto* continuing = Block(CallStmt(Call("a_statement"))); @@ -142,7 +142,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_LoopWithVarUsedInContinuing) { // } // } - GlobalVar("rhs", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("rhs", ty.f32(), builtin::AddressSpace::kPrivate); auto* body = Block(Decl(Var("lhs", ty.f32(), Expr(2.4_f))), // Decl(Var("other", ty.f32())), // diff --git a/src/tint/writer/hlsl/generator_impl_member_accessor_test.cc b/src/tint/writer/hlsl/generator_impl_member_accessor_test.cc index 2c11fc28df..0a2112b334 100644 --- a/src/tint/writer/hlsl/generator_impl_member_accessor_test.cc +++ b/src/tint/writer/hlsl/generator_impl_member_accessor_test.cc @@ -93,16 +93,16 @@ class HlslGeneratorImplTest_MemberAccessorBase : public BASE { ProgramBuilder& b = *this; auto* s = b.Structure("Data", members); - b.GlobalVar("data", b.ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, - b.Group(1_a), b.Binding(0_a)); + b.GlobalVar("data", b.ty.Of(s), builtin::AddressSpace::kStorage, + builtin::Access::kReadWrite, b.Group(1_a), b.Binding(0_a)); } void SetupUniformBuffer(utils::VectorRef members) { ProgramBuilder& b = *this; auto* s = b.Structure("Data", members); - b.GlobalVar("data", b.ty.Of(s), type::AddressSpace::kUniform, builtin::Access::kUndefined, - b.Group(1_a), b.Binding(1_a)); + b.GlobalVar("data", b.ty.Of(s), builtin::AddressSpace::kUniform, + builtin::Access::kUndefined, b.Group(1_a), b.Binding(1_a)); } void SetupFunction(utils::VectorRef statements) { @@ -122,7 +122,7 @@ using HlslGeneratorImplTest_MemberAccessorWithParam = TEST_F(HlslGeneratorImplTest_MemberAccessor, EmitExpression_MemberAccessor) { auto* s = Structure("Data", utils::Vector{Member("mem", ty.f32())}); - GlobalVar("str", ty.Of(s), type::AddressSpace::kPrivate); + GlobalVar("str", ty.Of(s), builtin::AddressSpace::kPrivate); auto* expr = MemberAccessor("str", "mem"); WrapInFunction(Var("expr", ty.f32(), expr)); diff --git a/src/tint/writer/hlsl/generator_impl_sanitizer_test.cc b/src/tint/writer/hlsl/generator_impl_sanitizer_test.cc index 8013045570..b7d1bb9556 100644 --- a/src/tint/writer/hlsl/generator_impl_sanitizer_test.cc +++ b/src/tint/writer/hlsl/generator_impl_sanitizer_test.cc @@ -26,7 +26,7 @@ using HlslSanitizerTest = TestHelper; TEST_F(HlslSanitizerTest, Call_ArrayLength) { auto* s = Structure("my_struct", utils::Vector{Member(0, "a", ty.array())}); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), Group(2_a)); Func("a_func", utils::Empty, ty.void_(), @@ -60,7 +60,7 @@ TEST_F(HlslSanitizerTest, Call_ArrayLength_OtherMembersInStruct) { Member(0, "z", ty.f32()), Member(4, "a", ty.array()), }); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), Group(2_a)); Func("a_func", utils::Empty, ty.void_(), @@ -92,7 +92,7 @@ void a_func() { TEST_F(HlslSanitizerTest, Call_ArrayLength_ViaLets) { auto* s = Structure("my_struct", utils::Vector{Member(0, "a", ty.array())}); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), Group(2_a)); auto* p = Let("p", AddressOf("b")); @@ -129,9 +129,9 @@ void a_func() { TEST_F(HlslSanitizerTest, Call_ArrayLength_ArrayLengthFromUniform) { auto* s = Structure("my_struct", utils::Vector{Member(0, "a", ty.array())}); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), Group(2_a)); - GlobalVar("c", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(2_a), + GlobalVar("c", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kRead, Binding(2_a), Group(2_a)); Func("a_func", utils::Empty, ty.void_(), @@ -242,7 +242,7 @@ TEST_F(HlslSanitizerTest, InlinePtrLetsBasic) { // let p : ptr = &v; // let x : i32 = *p; auto* v = Var("v", ty.i32()); - auto* p = Let("p", ty.pointer(type::AddressSpace::kFunction), AddressOf(v)); + auto* p = Let("p", ty.pointer(builtin::AddressSpace::kFunction), AddressOf(v)); auto* x = Var("x", ty.i32(), Deref(p)); Func("main", utils::Empty, ty.void_(), @@ -276,11 +276,12 @@ TEST_F(HlslSanitizerTest, InlinePtrLetsComplexChain) { // let vp : ptr> = &(*mp)[2i]; // let v : vec4 = *vp; auto* a = Var("a", ty.array(ty.mat4x4(), 4_u)); - auto* ap = Let("ap", ty.pointer(ty.array(ty.mat4x4(), 4_u), type::AddressSpace::kFunction), - AddressOf(a)); - auto* mp = Let("mp", ty.pointer(ty.mat4x4(), type::AddressSpace::kFunction), + auto* ap = + Let("ap", ty.pointer(ty.array(ty.mat4x4(), 4_u), builtin::AddressSpace::kFunction), + AddressOf(a)); + auto* mp = Let("mp", ty.pointer(ty.mat4x4(), builtin::AddressSpace::kFunction), AddressOf(IndexAccessor(Deref(ap), 3_i))); - auto* vp = Let("vp", ty.pointer(ty.vec4(), type::AddressSpace::kFunction), + auto* vp = Let("vp", ty.pointer(ty.vec4(), builtin::AddressSpace::kFunction), AddressOf(IndexAccessor(Deref(mp), 2_i))); auto* v = Var("v", ty.vec4(), Deref(vp)); diff --git a/src/tint/writer/hlsl/generator_impl_switch_test.cc b/src/tint/writer/hlsl/generator_impl_switch_test.cc index 6426b7c343..810a99bc9e 100644 --- a/src/tint/writer/hlsl/generator_impl_switch_test.cc +++ b/src/tint/writer/hlsl/generator_impl_switch_test.cc @@ -22,7 +22,7 @@ namespace { using HlslGeneratorImplTest_Switch = TestHelper; TEST_F(HlslGeneratorImplTest_Switch, Emit_Switch) { - GlobalVar("cond", ty.i32(), type::AddressSpace::kPrivate); + GlobalVar("cond", ty.i32(), builtin::AddressSpace::kPrivate); auto* s = Switch( // Expr("cond"), // Case(CaseSelector(5_i), Block(Break())), // @@ -46,7 +46,7 @@ TEST_F(HlslGeneratorImplTest_Switch, Emit_Switch) { } TEST_F(HlslGeneratorImplTest_Switch, Emit_Switch_MixedDefault) { - GlobalVar("cond", ty.i32(), type::AddressSpace::kPrivate); + GlobalVar("cond", ty.i32(), builtin::AddressSpace::kPrivate); auto* s = Switch( // Expr("cond"), // Case(utils::Vector{CaseSelector(5_i), DefaultCaseSelector()}, Block(Break()))); @@ -76,8 +76,8 @@ TEST_F(HlslGeneratorImplTest_Switch, Emit_Switch_OnlyDefaultCase_NoSideEffectsCo // } // } // } - GlobalVar("cond", ty.i32(), type::AddressSpace::kPrivate); - GlobalVar("a", ty.i32(), type::AddressSpace::kPrivate); + GlobalVar("cond", ty.i32(), builtin::AddressSpace::kPrivate); + GlobalVar("a", ty.i32(), builtin::AddressSpace::kPrivate); auto* s = Switch( // Expr("cond"), // DefaultCase(Block(Assign(Expr("a"), Expr(42_i))))); @@ -109,13 +109,13 @@ TEST_F(HlslGeneratorImplTest_Switch, Emit_Switch_OnlyDefaultCase_SideEffectsCond // } // } // } - GlobalVar("global", ty.i32(), type::AddressSpace::kPrivate); + GlobalVar("global", ty.i32(), builtin::AddressSpace::kPrivate); Func("bar", {}, ty.i32(), utils::Vector{ // Assign("global", Expr(84_i)), // Return("global")}); - GlobalVar("a", ty.i32(), type::AddressSpace::kPrivate); + GlobalVar("a", ty.i32(), builtin::AddressSpace::kPrivate); auto* s = Switch( // Call("bar"), // DefaultCase(Block(Assign(Expr("a"), Expr(42_i))))); diff --git a/src/tint/writer/hlsl/generator_impl_type_test.cc b/src/tint/writer/hlsl/generator_impl_type_test.cc index 0aa019ef23..30ca0104ad 100644 --- a/src/tint/writer/hlsl/generator_impl_type_test.cc +++ b/src/tint/writer/hlsl/generator_impl_type_test.cc @@ -34,12 +34,12 @@ using HlslGeneratorImplTest_Type = TestHelper; TEST_F(HlslGeneratorImplTest_Type, EmitType_Array) { auto arr = ty.array(); - ast::Type ty = GlobalVar("G", arr, type::AddressSpace::kPrivate)->type; + ast::Type ty = GlobalVar("G", arr, builtin::AddressSpace::kPrivate)->type; GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE(gen.EmitType(out, program->TypeOf(ty), type::AddressSpace::kUndefined, + ASSERT_TRUE(gen.EmitType(out, program->TypeOf(ty), builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "ary")) << gen.error(); EXPECT_EQ(out.str(), "bool ary[4]"); @@ -47,12 +47,12 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Array) { TEST_F(HlslGeneratorImplTest_Type, EmitType_ArrayOfArray) { auto arr = ty.array(ty.array(), 5_u); - ast::Type ty = GlobalVar("G", arr, type::AddressSpace::kPrivate)->type; + ast::Type ty = GlobalVar("G", arr, builtin::AddressSpace::kPrivate)->type; GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE(gen.EmitType(out, program->TypeOf(ty), type::AddressSpace::kUndefined, + ASSERT_TRUE(gen.EmitType(out, program->TypeOf(ty), builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "ary")) << gen.error(); EXPECT_EQ(out.str(), "bool ary[5][4]"); @@ -60,12 +60,12 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_ArrayOfArray) { TEST_F(HlslGeneratorImplTest_Type, EmitType_ArrayOfArrayOfArray) { auto arr = ty.array(ty.array(ty.array(), 5_u), 6_u); - ast::Type ty = GlobalVar("G", arr, type::AddressSpace::kPrivate)->type; + ast::Type ty = GlobalVar("G", arr, builtin::AddressSpace::kPrivate)->type; GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE(gen.EmitType(out, program->TypeOf(ty), type::AddressSpace::kUndefined, + ASSERT_TRUE(gen.EmitType(out, program->TypeOf(ty), builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "ary")) << gen.error(); EXPECT_EQ(out.str(), "bool ary[6][5][4]"); @@ -73,12 +73,12 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_ArrayOfArrayOfArray) { TEST_F(HlslGeneratorImplTest_Type, EmitType_Array_WithoutName) { auto arr = ty.array(); - ast::Type ty = GlobalVar("G", arr, type::AddressSpace::kPrivate)->type; + ast::Type ty = GlobalVar("G", arr, builtin::AddressSpace::kPrivate)->type; GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE(gen.EmitType(out, program->TypeOf(ty), type::AddressSpace::kUndefined, + ASSERT_TRUE(gen.EmitType(out, program->TypeOf(ty), builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "bool[4]"); @@ -90,8 +90,8 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Bool) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE( - gen.EmitType(out, bool_, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) + ASSERT_TRUE(gen.EmitType(out, bool_, builtin::AddressSpace::kUndefined, + builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "bool"); } @@ -103,7 +103,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_F16) { std::stringstream out; ASSERT_TRUE( - gen.EmitType(out, f16, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) + gen.EmitType(out, f16, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "float16_t"); } @@ -115,7 +115,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_F32) { std::stringstream out; ASSERT_TRUE( - gen.EmitType(out, f32, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) + gen.EmitType(out, f32, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "float"); } @@ -127,7 +127,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_I32) { std::stringstream out; ASSERT_TRUE( - gen.EmitType(out, i32, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) + gen.EmitType(out, i32, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "int"); } @@ -140,8 +140,8 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Matrix_F16) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE( - gen.EmitType(out, mat2x3, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) + ASSERT_TRUE(gen.EmitType(out, mat2x3, builtin::AddressSpace::kUndefined, + builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "matrix"); } @@ -154,8 +154,8 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Matrix_F32) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE( - gen.EmitType(out, mat2x3, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) + ASSERT_TRUE(gen.EmitType(out, mat2x3, builtin::AddressSpace::kUndefined, + builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "float2x3"); } @@ -165,7 +165,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_StructDecl) { Member("a", ty.i32()), Member("b", ty.f32()), }); - GlobalVar("g", ty.Of(s), type::AddressSpace::kPrivate); + GlobalVar("g", ty.Of(s), builtin::AddressSpace::kPrivate); GeneratorImpl& gen = Build(); @@ -184,7 +184,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_StructDecl_OmittedIfStorageBuffer) { Member("a", ty.i32()), Member("b", ty.f32()), }); - GlobalVar("g", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + GlobalVar("g", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, Binding(0_a), Group(0_a)); GeneratorImpl& gen = Build(); @@ -198,14 +198,14 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct) { Member("a", ty.i32()), Member("b", ty.f32()), }); - GlobalVar("g", ty.Of(s), type::AddressSpace::kPrivate); + GlobalVar("g", ty.Of(s), builtin::AddressSpace::kPrivate); GeneratorImpl& gen = Build(); auto* sem_s = program->TypeOf(s)->As(); std::stringstream out; - ASSERT_TRUE( - gen.EmitType(out, sem_s, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) + ASSERT_TRUE(gen.EmitType(out, sem_s, builtin::AddressSpace::kUndefined, + builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "S"); } @@ -215,7 +215,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct_NameCollision) { Member("double", ty.i32()), Member("float", ty.f32()), }); - GlobalVar("g", ty.Of(s), type::AddressSpace::kPrivate); + GlobalVar("g", ty.Of(s), builtin::AddressSpace::kPrivate); GeneratorImpl& gen = SanitizeAndBuild(); @@ -232,7 +232,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct_WithOffsetAttributes) { Member("a", ty.i32(), utils::Vector{MemberOffset(0_a)}), Member("b", ty.f32(), utils::Vector{MemberOffset(8_a)}), }); - GlobalVar("g", ty.Of(s), type::AddressSpace::kPrivate); + GlobalVar("g", ty.Of(s), builtin::AddressSpace::kPrivate); GeneratorImpl& gen = Build(); @@ -253,7 +253,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_U32) { std::stringstream out; ASSERT_TRUE( - gen.EmitType(out, u32, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) + gen.EmitType(out, u32, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "uint"); } @@ -266,7 +266,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Vector) { std::stringstream out; ASSERT_TRUE( - gen.EmitType(out, vec3, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) + gen.EmitType(out, vec3, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "float3"); } @@ -277,8 +277,8 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Void) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE( - gen.EmitType(out, void_, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) + ASSERT_TRUE(gen.EmitType(out, void_, builtin::AddressSpace::kUndefined, + builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "void"); } @@ -289,8 +289,8 @@ TEST_F(HlslGeneratorImplTest_Type, EmitSampler) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE( - gen.EmitType(out, sampler, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) + ASSERT_TRUE(gen.EmitType(out, sampler, builtin::AddressSpace::kUndefined, + builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "SamplerState"); } @@ -301,8 +301,8 @@ TEST_F(HlslGeneratorImplTest_Type, EmitSamplerComparison) { GeneratorImpl& gen = Build(); std::stringstream out; - ASSERT_TRUE( - gen.EmitType(out, sampler, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) + ASSERT_TRUE(gen.EmitType(out, sampler, builtin::AddressSpace::kUndefined, + builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "SamplerComparisonState"); } @@ -513,7 +513,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitMultisampledTexture) { std::stringstream out; ASSERT_TRUE( - gen.EmitType(out, s, type::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) + gen.EmitType(out, s, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) << gen.error(); EXPECT_EQ(out.str(), "Texture2DMS"); } diff --git a/src/tint/writer/hlsl/generator_impl_unary_op_test.cc b/src/tint/writer/hlsl/generator_impl_unary_op_test.cc index 93a61dcc60..4bf4329b23 100644 --- a/src/tint/writer/hlsl/generator_impl_unary_op_test.cc +++ b/src/tint/writer/hlsl/generator_impl_unary_op_test.cc @@ -20,7 +20,7 @@ namespace { using HlslUnaryOpTest = TestHelper; TEST_F(HlslUnaryOpTest, AddressOf) { - GlobalVar("expr", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("expr", ty.f32(), builtin::AddressSpace::kPrivate); auto* op = create(ast::UnaryOp::kAddressOf, Expr("expr")); WrapInFunction(op); @@ -32,7 +32,7 @@ TEST_F(HlslUnaryOpTest, AddressOf) { } TEST_F(HlslUnaryOpTest, Complement) { - GlobalVar("expr", ty.u32(), type::AddressSpace::kPrivate); + GlobalVar("expr", ty.u32(), builtin::AddressSpace::kPrivate); auto* op = create(ast::UnaryOp::kComplement, Expr("expr")); WrapInFunction(op); @@ -44,7 +44,7 @@ TEST_F(HlslUnaryOpTest, Complement) { } TEST_F(HlslUnaryOpTest, Indirection) { - GlobalVar("G", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("G", ty.f32(), builtin::AddressSpace::kPrivate); auto* p = Let("expr", create(ast::UnaryOp::kAddressOf, Expr("G"))); auto* op = create(ast::UnaryOp::kIndirection, Expr("expr")); WrapInFunction(p, op); @@ -57,7 +57,7 @@ TEST_F(HlslUnaryOpTest, Indirection) { } TEST_F(HlslUnaryOpTest, Not) { - GlobalVar("expr", ty.bool_(), type::AddressSpace::kPrivate); + GlobalVar("expr", ty.bool_(), builtin::AddressSpace::kPrivate); auto* op = create(ast::UnaryOp::kNot, Expr("expr")); WrapInFunction(op); @@ -69,7 +69,7 @@ TEST_F(HlslUnaryOpTest, Not) { } TEST_F(HlslUnaryOpTest, Negation) { - GlobalVar("expr", ty.i32(), type::AddressSpace::kPrivate); + GlobalVar("expr", ty.i32(), builtin::AddressSpace::kPrivate); auto* op = create(ast::UnaryOp::kNegation, Expr("expr")); WrapInFunction(op); diff --git a/src/tint/writer/hlsl/generator_impl_variable_decl_statement_test.cc b/src/tint/writer/hlsl/generator_impl_variable_decl_statement_test.cc index fedf476b4c..f8420ae398 100644 --- a/src/tint/writer/hlsl/generator_impl_variable_decl_statement_test.cc +++ b/src/tint/writer/hlsl/generator_impl_variable_decl_statement_test.cc @@ -357,7 +357,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Array) { } TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Private) { - GlobalVar("a", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("a", ty.f32(), builtin::AddressSpace::kPrivate); WrapInFunction(Expr("a")); diff --git a/src/tint/writer/hlsl/generator_impl_workgroup_var_test.cc b/src/tint/writer/hlsl/generator_impl_workgroup_var_test.cc index ea30962dd5..3895aba7c3 100644 --- a/src/tint/writer/hlsl/generator_impl_workgroup_var_test.cc +++ b/src/tint/writer/hlsl/generator_impl_workgroup_var_test.cc @@ -27,7 +27,7 @@ namespace { using HlslGeneratorImplTest_WorkgroupVar = TestHelper; TEST_F(HlslGeneratorImplTest_WorkgroupVar, Basic) { - GlobalVar("wg", ty.f32(), type::AddressSpace::kWorkgroup); + GlobalVar("wg", ty.f32(), builtin::AddressSpace::kWorkgroup); Func("main", utils::Empty, ty.void_(), utils::Vector{Assign("wg", 1.2_f)}, utils::Vector{ @@ -43,7 +43,7 @@ TEST_F(HlslGeneratorImplTest_WorkgroupVar, Basic) { TEST_F(HlslGeneratorImplTest_WorkgroupVar, Aliased) { auto* alias = Alias("F32", ty.f32()); - GlobalVar("wg", ty.Of(alias), type::AddressSpace::kWorkgroup); + GlobalVar("wg", ty.Of(alias), builtin::AddressSpace::kWorkgroup); Func("main", utils::Empty, ty.void_(), utils::Vector{Assign("wg", 1.2_f)}, utils::Vector{ diff --git a/src/tint/writer/msl/generator_impl.cc b/src/tint/writer/msl/generator_impl.cc index 5fc779ad3f..5c77e4795f 100644 --- a/src/tint/writer/msl/generator_impl.cc +++ b/src/tint/writer/msl/generator_impl.cc @@ -204,7 +204,7 @@ SanitizedResult Sanitize(const Program* in, const Options& options) { // Use the SSBO binding numbers as the indices for the buffer size lookups. for (auto* var : in->AST().GlobalVariables()) { auto* global = in->Sem().Get(var); - if (global && global->AddressSpace() == type::AddressSpace::kStorage) { + if (global && global->AddressSpace() == builtin::AddressSpace::kStorage) { array_length_from_uniform_cfg.bindpoint_to_size_index.emplace( global->BindingPoint(), global->BindingPoint().binding); } @@ -2048,15 +2048,15 @@ bool GeneratorImpl::EmitEntryPointFunction(const ast::Function* func) { }, [&](const type::Pointer* ptr) { switch (ptr->AddressSpace()) { - case type::AddressSpace::kWorkgroup: { + case builtin::AddressSpace::kWorkgroup: { auto& allocations = workgroup_allocations_[func_name]; out << " [[threadgroup(" << allocations.size() << ")]]"; allocations.push_back(ptr->StoreType()->Size()); return true; } - case type::AddressSpace::kStorage: - case type::AddressSpace::kUniform: { + case builtin::AddressSpace::kStorage: + case builtin::AddressSpace::kUniform: { uint32_t binding = get_binding_index(param); if (binding == kInvalidBindingIndex) { return false; @@ -2760,20 +2760,20 @@ bool GeneratorImpl::EmitTypeAndName(std::ostream& out, return true; } -bool GeneratorImpl::EmitAddressSpace(std::ostream& out, type::AddressSpace sc) { +bool GeneratorImpl::EmitAddressSpace(std::ostream& out, builtin::AddressSpace sc) { switch (sc) { - case type::AddressSpace::kFunction: - case type::AddressSpace::kPrivate: - case type::AddressSpace::kHandle: + case builtin::AddressSpace::kFunction: + case builtin::AddressSpace::kPrivate: + case builtin::AddressSpace::kHandle: out << "thread"; return true; - case type::AddressSpace::kWorkgroup: + case builtin::AddressSpace::kWorkgroup: out << "threadgroup"; return true; - case type::AddressSpace::kStorage: + case builtin::AddressSpace::kStorage: out << "device"; return true; - case type::AddressSpace::kUniform: + case builtin::AddressSpace::kUniform: out << "constant"; return true; default: @@ -3025,13 +3025,13 @@ bool GeneratorImpl::EmitVar(const ast::Var* var) { auto out = line(); switch (sem->AddressSpace()) { - case type::AddressSpace::kFunction: - case type::AddressSpace::kHandle: + case builtin::AddressSpace::kFunction: + case builtin::AddressSpace::kHandle: break; - case type::AddressSpace::kPrivate: + case builtin::AddressSpace::kPrivate: out << "thread "; break; - case type::AddressSpace::kWorkgroup: + case builtin::AddressSpace::kWorkgroup: out << "threadgroup "; break; default: @@ -3053,9 +3053,9 @@ bool GeneratorImpl::EmitVar(const ast::Var* var) { if (!EmitExpression(out, var->initializer)) { return false; } - } else if (sem->AddressSpace() == type::AddressSpace::kPrivate || - sem->AddressSpace() == type::AddressSpace::kFunction || - sem->AddressSpace() == type::AddressSpace::kUndefined) { + } else if (sem->AddressSpace() == builtin::AddressSpace::kPrivate || + sem->AddressSpace() == builtin::AddressSpace::kFunction || + sem->AddressSpace() == builtin::AddressSpace::kUndefined) { out << " = "; if (!EmitZeroValue(out, type)) { return false; @@ -3073,14 +3073,14 @@ bool GeneratorImpl::EmitLet(const ast::Let* let) { auto out = line(); switch (sem->AddressSpace()) { - case type::AddressSpace::kFunction: - case type::AddressSpace::kHandle: - case type::AddressSpace::kUndefined: + case builtin::AddressSpace::kFunction: + case builtin::AddressSpace::kHandle: + case builtin::AddressSpace::kUndefined: break; - case type::AddressSpace::kPrivate: + case builtin::AddressSpace::kPrivate: out << "thread "; break; - case type::AddressSpace::kWorkgroup: + case builtin::AddressSpace::kWorkgroup: out << "threadgroup "; break; default: diff --git a/src/tint/writer/msl/generator_impl.h b/src/tint/writer/msl/generator_impl.h index 750bed561f..0e9b261ea2 100644 --- a/src/tint/writer/msl/generator_impl.h +++ b/src/tint/writer/msl/generator_impl.h @@ -326,7 +326,7 @@ class GeneratorImpl : public TextGenerator { /// @param out the output of the type stream /// @param sc the address space to generate /// @returns true if the address space is emitted - bool EmitAddressSpace(std::ostream& out, type::AddressSpace sc); + bool EmitAddressSpace(std::ostream& out, builtin::AddressSpace sc); /// Handles generating a struct declaration. If the structure has already been emitted, then /// this function will simply return `true` without emitting anything. /// @param buffer the text buffer that the type declaration will be written to @@ -410,7 +410,7 @@ class GeneratorImpl : public TextGenerator { /// Name of atomicCompareExchangeWeak() helper for the given pointer storage /// class and struct return type using ACEWKeyType = - utils::UnorderedKeyWrapper>; + utils::UnorderedKeyWrapper>; std::unordered_map atomicCompareExchangeWeak_; /// Unique name of the 'TINT_INVARIANT' preprocessor define. diff --git a/src/tint/writer/msl/generator_impl_array_accessor_test.cc b/src/tint/writer/msl/generator_impl_array_accessor_test.cc index eae2c17bd8..47145d17e0 100644 --- a/src/tint/writer/msl/generator_impl_array_accessor_test.cc +++ b/src/tint/writer/msl/generator_impl_array_accessor_test.cc @@ -34,7 +34,7 @@ TEST_F(MslGeneratorImplTest, IndexAccessor) { } TEST_F(MslGeneratorImplTest, IndexAccessor_OfDref) { - GlobalVar("ary", ty.array(), type::AddressSpace::kPrivate); + GlobalVar("ary", ty.array(), builtin::AddressSpace::kPrivate); auto* p = Let("p", AddressOf("ary")); auto* expr = IndexAccessor(Deref("p"), 5_i); diff --git a/src/tint/writer/msl/generator_impl_builtin_test.cc b/src/tint/writer/msl/generator_impl_builtin_test.cc index 0eabc02c96..694ade7d70 100644 --- a/src/tint/writer/msl/generator_impl_builtin_test.cc +++ b/src/tint/writer/msl/generator_impl_builtin_test.cc @@ -216,21 +216,21 @@ TEST_P(MslBuiltinTest, Emit) { if (param.type == CallParamType::kF16) { Enable(builtin::Extension::kF16); - GlobalVar("h2", ty.vec2(), type::AddressSpace::kPrivate); - GlobalVar("h3", ty.vec3(), type::AddressSpace::kPrivate); - GlobalVar("hm2x2", ty.mat2x2(), type::AddressSpace::kPrivate); - GlobalVar("hm3x2", ty.mat3x2(), type::AddressSpace::kPrivate); + GlobalVar("h2", ty.vec2(), builtin::AddressSpace::kPrivate); + GlobalVar("h3", ty.vec3(), builtin::AddressSpace::kPrivate); + GlobalVar("hm2x2", ty.mat2x2(), builtin::AddressSpace::kPrivate); + GlobalVar("hm3x2", ty.mat3x2(), builtin::AddressSpace::kPrivate); } - GlobalVar("f2", ty.vec2(), type::AddressSpace::kPrivate); - GlobalVar("f3", ty.vec3(), type::AddressSpace::kPrivate); - GlobalVar("f4", ty.vec4(), type::AddressSpace::kPrivate); - GlobalVar("u1", ty.u32(), type::AddressSpace::kPrivate); - GlobalVar("u2", ty.vec2(), type::AddressSpace::kPrivate); - GlobalVar("i2", ty.vec2(), type::AddressSpace::kPrivate); - GlobalVar("b2", ty.vec2(), type::AddressSpace::kPrivate); - GlobalVar("m2x2", ty.mat2x2(), type::AddressSpace::kPrivate); - GlobalVar("m3x2", ty.mat3x2(), type::AddressSpace::kPrivate); + GlobalVar("f2", ty.vec2(), builtin::AddressSpace::kPrivate); + GlobalVar("f3", ty.vec3(), builtin::AddressSpace::kPrivate); + GlobalVar("f4", ty.vec4(), builtin::AddressSpace::kPrivate); + GlobalVar("u1", ty.u32(), builtin::AddressSpace::kPrivate); + GlobalVar("u2", ty.vec2(), builtin::AddressSpace::kPrivate); + GlobalVar("i2", ty.vec2(), builtin::AddressSpace::kPrivate); + GlobalVar("b2", ty.vec2(), builtin::AddressSpace::kPrivate); + GlobalVar("m2x2", ty.mat2x2(), builtin::AddressSpace::kPrivate); + GlobalVar("m3x2", ty.mat3x2(), builtin::AddressSpace::kPrivate); auto* call = GenerateCall(param.builtin, param.type, this); ASSERT_NE(nullptr, call) << "Unhandled builtin"; @@ -370,8 +370,8 @@ INSTANTIATE_TEST_SUITE_P( "unpack_unorm2x16_to_float"})); TEST_F(MslGeneratorImplTest, Builtin_Call) { - GlobalVar("param1", ty.vec2(), type::AddressSpace::kPrivate); - GlobalVar("param2", ty.vec2(), type::AddressSpace::kPrivate); + GlobalVar("param1", ty.vec2(), builtin::AddressSpace::kPrivate); + GlobalVar("param2", ty.vec2(), builtin::AddressSpace::kPrivate); auto* call = Call("dot", "param1", "param2"); WrapInFunction(CallStmt(call)); @@ -1047,7 +1047,7 @@ kernel void test_function() { TEST_F(MslGeneratorImplTest, Pack2x16Float) { auto* call = Call("pack2x16float", "p1"); - GlobalVar("p1", ty.vec2(), type::AddressSpace::kPrivate); + GlobalVar("p1", ty.vec2(), builtin::AddressSpace::kPrivate); WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); @@ -1059,7 +1059,7 @@ TEST_F(MslGeneratorImplTest, Pack2x16Float) { TEST_F(MslGeneratorImplTest, Unpack2x16Float) { auto* call = Call("unpack2x16float", "p1"); - GlobalVar("p1", ty.u32(), type::AddressSpace::kPrivate); + GlobalVar("p1", ty.u32(), builtin::AddressSpace::kPrivate); WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); @@ -1070,7 +1070,7 @@ TEST_F(MslGeneratorImplTest, Unpack2x16Float) { } TEST_F(MslGeneratorImplTest, DotI32) { - GlobalVar("v", ty.vec3(), type::AddressSpace::kPrivate); + GlobalVar("v", ty.vec3(), builtin::AddressSpace::kPrivate); WrapInFunction(CallStmt(Call("dot", "v", "v"))); GeneratorImpl& gen = SanitizeAndBuild(); diff --git a/src/tint/writer/msl/generator_impl_call_test.cc b/src/tint/writer/msl/generator_impl_call_test.cc index 4449c2b22b..26da4e494e 100644 --- a/src/tint/writer/msl/generator_impl_call_test.cc +++ b/src/tint/writer/msl/generator_impl_call_test.cc @@ -45,8 +45,8 @@ TEST_F(MslGeneratorImplTest, EmitExpression_Call_WithParams) { utils::Vector{ Return(1.23_f), }); - GlobalVar("param1", ty.f32(), type::AddressSpace::kPrivate); - GlobalVar("param2", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("param1", ty.f32(), builtin::AddressSpace::kPrivate); + GlobalVar("param2", ty.f32(), builtin::AddressSpace::kPrivate); auto* call = Call("my_func", "param1", "param2"); WrapInFunction(call); @@ -65,8 +65,8 @@ TEST_F(MslGeneratorImplTest, EmitStatement_Call) { Param(Sym(), ty.f32()), }, ty.void_(), utils::Empty, utils::Empty); - GlobalVar("param1", ty.f32(), type::AddressSpace::kPrivate); - GlobalVar("param2", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("param1", ty.f32(), builtin::AddressSpace::kPrivate); + GlobalVar("param2", ty.f32(), builtin::AddressSpace::kPrivate); auto* call = Call("my_func", "param1", "param2"); auto* stmt = CallStmt(call); diff --git a/src/tint/writer/msl/generator_impl_function_test.cc b/src/tint/writer/msl/generator_impl_function_test.cc index 05e85311db..3eb809be7e 100644 --- a/src/tint/writer/msl/generator_impl_function_test.cc +++ b/src/tint/writer/msl/generator_impl_function_test.cc @@ -341,7 +341,7 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionAttribute_EntryPoint_With_RW_StorageBu Member("b", ty.f32()), }); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + GlobalVar("coord", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, Group(0_a), Binding(0_a)); auto* var = Var("v", ty.f32(), MemberAccessor("coord", "b")); @@ -380,8 +380,8 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionAttribute_EntryPoint_With_RO_StorageBu Member("b", ty.f32()), }); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Group(0_a), - Binding(0_a)); + GlobalVar("coord", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kRead, + Group(0_a), Binding(0_a)); auto* var = Var("v", ty.f32(), MemberAccessor("coord", "b")); @@ -416,7 +416,7 @@ fragment void frag_main(const device Data* tint_symbol [[buffer(0)]]) { TEST_F(MslGeneratorImplTest, Emit_Attribute_Called_By_EntryPoint_With_Uniform) { auto* ubo_ty = Structure("UBO", utils::Vector{Member("coord", ty.vec4())}); auto* ubo = - GlobalVar("ubo", ty.Of(ubo_ty), type::AddressSpace::kUniform, Group(0_a), Binding(0_a)); + GlobalVar("ubo", ty.Of(ubo_ty), builtin::AddressSpace::kUniform, Group(0_a), Binding(0_a)); Func("sub_func", utils::Vector{ @@ -466,7 +466,7 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionAttribute_Called_By_EntryPoint_With_RW Member("b", ty.f32()), }); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + GlobalVar("coord", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, Group(0_a), Binding(0_a)); Func("sub_func", @@ -518,8 +518,8 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionAttribute_Called_By_EntryPoint_With_RO Member("b", ty.f32()), }); - GlobalVar("coord", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Group(0_a), - Binding(0_a)); + GlobalVar("coord", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kRead, + Group(0_a), Binding(0_a)); Func("sub_func", utils::Vector{ @@ -656,7 +656,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_Multiple_EntryPoint_With_Same_ModuleV auto* s = Structure("Data", utils::Vector{Member("d", ty.f32())}); - GlobalVar("data", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + GlobalVar("data", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, Group(0_a), Binding(0_a)); { diff --git a/src/tint/writer/msl/generator_impl_import_test.cc b/src/tint/writer/msl/generator_impl_import_test.cc index 6fd95ae5f1..d00acd50c6 100644 --- a/src/tint/writer/msl/generator_impl_import_test.cc +++ b/src/tint/writer/msl/generator_impl_import_test.cc @@ -234,7 +234,7 @@ INSTANTIATE_TEST_SUITE_P(MslGeneratorImplTest, MslImportData{"clamp", "clamp"})); TEST_F(MslGeneratorImplTest, MslImportData_Determinant) { - GlobalVar("var", ty.mat3x3(), type::AddressSpace::kPrivate); + GlobalVar("var", ty.mat3x3(), builtin::AddressSpace::kPrivate); auto* expr = Call("determinant", "var"); @@ -248,7 +248,7 @@ TEST_F(MslGeneratorImplTest, MslImportData_Determinant) { } TEST_F(MslGeneratorImplTest, MslImportData_QuantizeToF16_Scalar) { - GlobalVar("v", Expr(2_f), type::AddressSpace::kPrivate); + GlobalVar("v", Expr(2_f), builtin::AddressSpace::kPrivate); auto* expr = Call("quantizeToF16", "v"); WrapInFunction(expr); @@ -261,7 +261,7 @@ TEST_F(MslGeneratorImplTest, MslImportData_QuantizeToF16_Scalar) { } TEST_F(MslGeneratorImplTest, MslImportData_QuantizeToF16_Vector) { - GlobalVar("v", vec3(2_f), type::AddressSpace::kPrivate); + GlobalVar("v", vec3(2_f), builtin::AddressSpace::kPrivate); auto* expr = Call("quantizeToF16", "v"); WrapInFunction(expr); diff --git a/src/tint/writer/msl/generator_impl_loop_test.cc b/src/tint/writer/msl/generator_impl_loop_test.cc index cac1306565..6d2959c88c 100644 --- a/src/tint/writer/msl/generator_impl_loop_test.cc +++ b/src/tint/writer/msl/generator_impl_loop_test.cc @@ -93,8 +93,8 @@ TEST_F(MslGeneratorImplTest, Emit_LoopWithContinuing_BreakIf) { TEST_F(MslGeneratorImplTest, Emit_LoopNestedWithContinuing) { Func("a_statement", {}, ty.void_(), utils::Empty); - GlobalVar("lhs", ty.f32(), type::AddressSpace::kPrivate); - GlobalVar("rhs", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("lhs", ty.f32(), builtin::AddressSpace::kPrivate); + GlobalVar("rhs", ty.f32(), builtin::AddressSpace::kPrivate); auto* body = Block(Break()); auto* continuing = Block(CallStmt(Call("a_statement"))); @@ -139,7 +139,7 @@ TEST_F(MslGeneratorImplTest, Emit_LoopWithVarUsedInContinuing) { // } // - GlobalVar("rhs", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("rhs", ty.f32(), builtin::AddressSpace::kPrivate); auto* body = Block(Decl(Var("lhs", ty.f32(), Expr(2.4_f))), // Decl(Var("other", ty.f32())), // @@ -216,7 +216,7 @@ TEST_F(MslGeneratorImplTest, Emit_ForLoopWithMultiStmtInit) { Func("f", utils::Vector{Param("i", ty.i32())}, ty.void_(), utils::Empty); auto f = [&](auto&& expr) { return CallStmt(Call("f", expr)); }; - GlobalVar("a", ty.atomic(), type::AddressSpace::kWorkgroup); + GlobalVar("a", ty.atomic(), builtin::AddressSpace::kWorkgroup); auto* multi_stmt = Block(f(1_i), f(2_i)); auto* loop = For(multi_stmt, nullptr, nullptr, // Block(Return())); @@ -292,7 +292,7 @@ TEST_F(MslGeneratorImplTest, Emit_ForLoopWithMultiStmtCont) { Func("f", utils::Vector{Param("i", ty.i32())}, ty.void_(), utils::Empty); auto f = [&](auto&& expr) { return CallStmt(Call("f", expr)); }; - GlobalVar("a", ty.atomic(), type::AddressSpace::kWorkgroup); + GlobalVar("a", ty.atomic(), builtin::AddressSpace::kWorkgroup); auto* multi_stmt = Block(f(1_i), f(2_i)); auto* loop = For(nullptr, nullptr, multi_stmt, // Block(Return())); @@ -347,7 +347,7 @@ TEST_F(MslGeneratorImplTest, Emit_ForLoopWithMultiStmtInitCondCont) { Func("f", utils::Vector{Param("i", ty.i32())}, ty.void_(), utils::Empty); auto f = [&](auto&& expr) { return CallStmt(Call("f", expr)); }; - GlobalVar("a", ty.atomic(), type::AddressSpace::kWorkgroup); + GlobalVar("a", ty.atomic(), builtin::AddressSpace::kWorkgroup); auto* multi_stmt_a = Block(f(1_i), f(2_i)); auto* multi_stmt_b = Block(f(3_i), f(4_i)); auto* loop = For(multi_stmt_a, Expr(true), multi_stmt_b, // diff --git a/src/tint/writer/msl/generator_impl_member_accessor_test.cc b/src/tint/writer/msl/generator_impl_member_accessor_test.cc index 0b54a52f56..1e1136e944 100644 --- a/src/tint/writer/msl/generator_impl_member_accessor_test.cc +++ b/src/tint/writer/msl/generator_impl_member_accessor_test.cc @@ -21,7 +21,7 @@ using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, EmitExpression_MemberAccessor) { GlobalVar("str", ty.Of(Structure("my_str", utils::Vector{Member("mem", ty.f32())})), - type::AddressSpace::kPrivate); + builtin::AddressSpace::kPrivate); auto* expr = MemberAccessor("str", "mem"); WrapInFunction(expr); @@ -33,7 +33,7 @@ TEST_F(MslGeneratorImplTest, EmitExpression_MemberAccessor) { } TEST_F(MslGeneratorImplTest, EmitExpression_MemberAccessor_Swizzle_xyz) { - GlobalVar("my_vec", ty.vec4(), type::AddressSpace::kPrivate); + GlobalVar("my_vec", ty.vec4(), builtin::AddressSpace::kPrivate); auto* expr = MemberAccessor("my_vec", "xyz"); WrapInFunction(expr); @@ -45,7 +45,7 @@ TEST_F(MslGeneratorImplTest, EmitExpression_MemberAccessor_Swizzle_xyz) { } TEST_F(MslGeneratorImplTest, EmitExpression_MemberAccessor_Swizzle_gbr) { - GlobalVar("my_vec", ty.vec4(), type::AddressSpace::kPrivate); + GlobalVar("my_vec", ty.vec4(), builtin::AddressSpace::kPrivate); auto* expr = MemberAccessor("my_vec", "gbr"); WrapInFunction(expr); diff --git a/src/tint/writer/msl/generator_impl_sanitizer_test.cc b/src/tint/writer/msl/generator_impl_sanitizer_test.cc index 05708dde66..f72e0e9927 100644 --- a/src/tint/writer/msl/generator_impl_sanitizer_test.cc +++ b/src/tint/writer/msl/generator_impl_sanitizer_test.cc @@ -28,7 +28,7 @@ using MslSanitizerTest = TestHelper; TEST_F(MslSanitizerTest, Call_ArrayLength) { auto* s = Structure("my_struct", utils::Vector{Member(0, "a", ty.array())}); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), Group(2_a)); Func("a_func", utils::Empty, ty.void_(), @@ -82,7 +82,7 @@ TEST_F(MslSanitizerTest, Call_ArrayLength_OtherMembersInStruct) { Member(0, "z", ty.f32()), Member(4, "a", ty.array()), }); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), Group(2_a)); Func("a_func", utils::Empty, ty.void_(), @@ -135,7 +135,7 @@ fragment void a_func(const constant tint_symbol* tint_symbol_2 [[buffer(30)]]) { TEST_F(MslSanitizerTest, Call_ArrayLength_ViaLets) { auto* s = Structure("my_struct", utils::Vector{Member(0, "a", ty.array())}); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), Group(2_a)); auto* p = Let("p", AddressOf("b")); @@ -192,9 +192,9 @@ fragment void a_func(const constant tint_symbol* tint_symbol_2 [[buffer(30)]]) { TEST_F(MslSanitizerTest, Call_ArrayLength_ArrayLengthFromUniform) { auto* s = Structure("my_struct", utils::Vector{Member(0, "a", ty.array())}); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), Group(0_a)); - GlobalVar("c", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(2_a), + GlobalVar("c", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kRead, Binding(2_a), Group(0_a)); Func("a_func", utils::Empty, ty.void_(), @@ -251,9 +251,9 @@ fragment void a_func(const constant tint_symbol* tint_symbol_2 [[buffer(29)]]) { TEST_F(MslSanitizerTest, Call_ArrayLength_ArrayLengthFromUniformMissingBinding) { auto* s = Structure("my_struct", utils::Vector{Member(0, "a", ty.array())}); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), Group(0_a)); - GlobalVar("c", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(2_a), + GlobalVar("c", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kRead, Binding(2_a), Group(0_a)); Func("a_func", utils::Empty, ty.void_(), diff --git a/src/tint/writer/msl/generator_impl_test.cc b/src/tint/writer/msl/generator_impl_test.cc index 71d58587d0..52ae3810bf 100644 --- a/src/tint/writer/msl/generator_impl_test.cc +++ b/src/tint/writer/msl/generator_impl_test.cc @@ -163,7 +163,7 @@ vertex Out vert_main() { } TEST_F(MslGeneratorImplTest, WorkgroupMatrix) { - GlobalVar("m", ty.mat2x2(), type::AddressSpace::kWorkgroup); + GlobalVar("m", ty.mat2x2(), builtin::AddressSpace::kWorkgroup); Func("comp_main", utils::Empty, ty.void_(), utils::Vector{Decl(Let("x", Expr("m")))}, utils::Vector{ Stage(ast::PipelineStage::kCompute), @@ -203,7 +203,7 @@ kernel void comp_main(threadgroup tint_symbol_3* tint_symbol_2 [[threadgroup(0)] } TEST_F(MslGeneratorImplTest, WorkgroupMatrixInArray) { - GlobalVar("m", ty.array(ty.mat2x2(), 4_i), type::AddressSpace::kWorkgroup); + GlobalVar("m", ty.array(ty.mat2x2(), 4_i), builtin::AddressSpace::kWorkgroup); Func("comp_main", utils::Empty, ty.void_(), utils::Vector{Decl(Let("x", Expr("m")))}, utils::Vector{ Stage(ast::PipelineStage::kCompute), @@ -264,7 +264,7 @@ TEST_F(MslGeneratorImplTest, WorkgroupMatrixInStruct) { Structure("S2", utils::Vector{ Member("s", ty("S1")), }); - GlobalVar("s", ty("S2"), type::AddressSpace::kWorkgroup); + GlobalVar("s", ty("S2"), builtin::AddressSpace::kWorkgroup); Func("comp_main", utils::Empty, ty.void_(), utils::Vector{Decl(Let("x", Expr("s")))}, utils::Vector{ Stage(ast::PipelineStage::kCompute), @@ -314,15 +314,15 @@ kernel void comp_main(threadgroup tint_symbol_4* tint_symbol_3 [[threadgroup(0)] } TEST_F(MslGeneratorImplTest, WorkgroupMatrix_Multiples) { - GlobalVar("m1", ty.mat2x2(), type::AddressSpace::kWorkgroup); - GlobalVar("m2", ty.mat2x3(), type::AddressSpace::kWorkgroup); - GlobalVar("m3", ty.mat2x4(), type::AddressSpace::kWorkgroup); - GlobalVar("m4", ty.mat3x2(), type::AddressSpace::kWorkgroup); - GlobalVar("m5", ty.mat3x3(), type::AddressSpace::kWorkgroup); - GlobalVar("m6", ty.mat3x4(), type::AddressSpace::kWorkgroup); - GlobalVar("m7", ty.mat4x2(), type::AddressSpace::kWorkgroup); - GlobalVar("m8", ty.mat4x3(), type::AddressSpace::kWorkgroup); - GlobalVar("m9", ty.mat4x4(), type::AddressSpace::kWorkgroup); + GlobalVar("m1", ty.mat2x2(), builtin::AddressSpace::kWorkgroup); + GlobalVar("m2", ty.mat2x3(), builtin::AddressSpace::kWorkgroup); + GlobalVar("m3", ty.mat2x4(), builtin::AddressSpace::kWorkgroup); + GlobalVar("m4", ty.mat3x2(), builtin::AddressSpace::kWorkgroup); + GlobalVar("m5", ty.mat3x3(), builtin::AddressSpace::kWorkgroup); + GlobalVar("m6", ty.mat3x4(), builtin::AddressSpace::kWorkgroup); + GlobalVar("m7", ty.mat4x2(), builtin::AddressSpace::kWorkgroup); + GlobalVar("m8", ty.mat4x3(), builtin::AddressSpace::kWorkgroup); + GlobalVar("m9", ty.mat4x4(), builtin::AddressSpace::kWorkgroup); Func("main1", utils::Empty, ty.void_(), utils::Vector{ Decl(Let("a1", Expr("m1"))), diff --git a/src/tint/writer/msl/generator_impl_type_test.cc b/src/tint/writer/msl/generator_impl_type_test.cc index 1062fcd9a6..8f056f497e 100644 --- a/src/tint/writer/msl/generator_impl_type_test.cc +++ b/src/tint/writer/msl/generator_impl_type_test.cc @@ -90,7 +90,7 @@ using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, EmitType_Array) { auto arr = ty.array(); - ast::Type type = GlobalVar("G", arr, type::AddressSpace::kPrivate)->type; + ast::Type type = GlobalVar("G", arr, builtin::AddressSpace::kPrivate)->type; GeneratorImpl& gen = Build(); @@ -102,7 +102,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Array) { TEST_F(MslGeneratorImplTest, EmitType_ArrayOfArray) { auto a = ty.array(); auto b = ty.array(a, 5_u); - ast::Type type = GlobalVar("G", b, type::AddressSpace::kPrivate)->type; + ast::Type type = GlobalVar("G", b, builtin::AddressSpace::kPrivate)->type; GeneratorImpl& gen = Build(); @@ -115,7 +115,7 @@ TEST_F(MslGeneratorImplTest, EmitType_ArrayOfArrayOfArray) { auto a = ty.array(); auto b = ty.array(a, 5_u); auto c = ty.array(b, 6_u); - ast::Type type = GlobalVar("G", c, type::AddressSpace::kPrivate)->type; + ast::Type type = GlobalVar("G", c, builtin::AddressSpace::kPrivate)->type; GeneratorImpl& gen = Build(); @@ -126,7 +126,7 @@ TEST_F(MslGeneratorImplTest, EmitType_ArrayOfArrayOfArray) { TEST_F(MslGeneratorImplTest, EmitType_Array_WithoutName) { auto arr = ty.array(); - ast::Type type = GlobalVar("G", arr, type::AddressSpace::kPrivate)->type; + ast::Type type = GlobalVar("G", arr, builtin::AddressSpace::kPrivate)->type; GeneratorImpl& gen = Build(); @@ -137,7 +137,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Array_WithoutName) { TEST_F(MslGeneratorImplTest, EmitType_RuntimeArray) { auto arr = ty.array(); - ast::Type type = GlobalVar("G", arr, type::AddressSpace::kPrivate)->type; + ast::Type type = GlobalVar("G", arr, builtin::AddressSpace::kPrivate)->type; GeneratorImpl& gen = Build(); @@ -213,7 +213,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Matrix_F16) { TEST_F(MslGeneratorImplTest, EmitType_Pointer) { auto* f32 = create(); auto* p = - create(f32, type::AddressSpace::kWorkgroup, builtin::Access::kReadWrite); + create(f32, builtin::AddressSpace::kWorkgroup, builtin::Access::kReadWrite); GeneratorImpl& gen = Build(); @@ -284,8 +284,8 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_NonComposites) { Member("z", ty.f32()), }); - ast::Type type = GlobalVar("G", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, - Binding(0_a), Group(0_a)) + ast::Type type = GlobalVar("G", ty.Of(s), builtin::AddressSpace::kStorage, + builtin::Access::kRead, Binding(0_a), Group(0_a)) ->type; GeneratorImpl& gen = Build(); @@ -393,8 +393,8 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_Structures) { Member("e", ty.f32()), }); - ast::Type type = GlobalVar("G", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, - Binding(0_a), Group(0_a)) + ast::Type type = GlobalVar("G", ty.Of(s), builtin::AddressSpace::kStorage, + builtin::Access::kRead, Binding(0_a), Group(0_a)) ->type; GeneratorImpl& gen = Build(); @@ -485,8 +485,8 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_ArrayDefaultStride) { Member("f", array_z), }); - ast::Type type = GlobalVar("G", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, - Binding(0_a), Group(0_a)) + ast::Type type = GlobalVar("G", ty.Of(s), builtin::AddressSpace::kStorage, + builtin::Access::kRead, Binding(0_a), Group(0_a)) ->type; GeneratorImpl& gen = Build(); @@ -569,8 +569,8 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_ArrayVec3DefaultStride) { Member("c", ty.i32()), }); - ast::Type type = GlobalVar("G", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, - Binding(0_a), Group(0_a)) + ast::Type type = GlobalVar("G", ty.Of(s), builtin::AddressSpace::kStorage, + builtin::Access::kRead, Binding(0_a), Group(0_a)) ->type; GeneratorImpl& gen = Build(); @@ -631,8 +631,8 @@ TEST_F(MslGeneratorImplTest, AttemptTintPadSymbolCollision) { Member("tint_pad_21", ty.f32()), }); - ast::Type type = GlobalVar("G", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, - Binding(0_a), Group(0_a)) + ast::Type type = GlobalVar("G", ty.Of(s), builtin::AddressSpace::kStorage, + builtin::Access::kRead, Binding(0_a), Group(0_a)) ->type; GeneratorImpl& gen = Build(); @@ -690,8 +690,8 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_WithAttribute) { Member("b", ty.f32()), }); - ast::Type type = GlobalVar("G", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, - Binding(0_a), Group(0_a)) + ast::Type type = GlobalVar("G", ty.Of(s), builtin::AddressSpace::kStorage, + builtin::Access::kRead, Binding(0_a), Group(0_a)) ->type; GeneratorImpl& gen = Build(); diff --git a/src/tint/writer/msl/generator_impl_unary_op_test.cc b/src/tint/writer/msl/generator_impl_unary_op_test.cc index ff4ac50dc7..95801a8dfb 100644 --- a/src/tint/writer/msl/generator_impl_unary_op_test.cc +++ b/src/tint/writer/msl/generator_impl_unary_op_test.cc @@ -20,7 +20,7 @@ namespace { using MslUnaryOpTest = TestHelper; TEST_F(MslUnaryOpTest, AddressOf) { - GlobalVar("expr", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("expr", ty.f32(), builtin::AddressSpace::kPrivate); auto* op = create(ast::UnaryOp::kAddressOf, Expr("expr")); WrapInFunction(op); @@ -32,7 +32,7 @@ TEST_F(MslUnaryOpTest, AddressOf) { } TEST_F(MslUnaryOpTest, Complement) { - GlobalVar("expr", ty.i32(), type::AddressSpace::kPrivate); + GlobalVar("expr", ty.i32(), builtin::AddressSpace::kPrivate); auto* op = create(ast::UnaryOp::kComplement, Expr("expr")); WrapInFunction(op); @@ -44,7 +44,7 @@ TEST_F(MslUnaryOpTest, Complement) { } TEST_F(MslUnaryOpTest, Indirection) { - GlobalVar("G", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("G", ty.f32(), builtin::AddressSpace::kPrivate); auto* p = Let("expr", create(ast::UnaryOp::kAddressOf, Expr("G"))); auto* op = create(ast::UnaryOp::kIndirection, Expr("expr")); WrapInFunction(p, op); @@ -57,7 +57,7 @@ TEST_F(MslUnaryOpTest, Indirection) { } TEST_F(MslUnaryOpTest, Not) { - GlobalVar("expr", ty.bool_(), type::AddressSpace::kPrivate); + GlobalVar("expr", ty.bool_(), builtin::AddressSpace::kPrivate); auto* op = create(ast::UnaryOp::kNot, Expr("expr")); WrapInFunction(op); @@ -69,7 +69,7 @@ TEST_F(MslUnaryOpTest, Not) { } TEST_F(MslUnaryOpTest, Negation) { - GlobalVar("expr", ty.i32(), type::AddressSpace::kPrivate); + GlobalVar("expr", ty.i32(), builtin::AddressSpace::kPrivate); auto* op = create(ast::UnaryOp::kNegation, Expr("expr")); WrapInFunction(op); diff --git a/src/tint/writer/msl/generator_impl_variable_decl_statement_test.cc b/src/tint/writer/msl/generator_impl_variable_decl_statement_test.cc index 1386abbde9..fa0c53f255 100644 --- a/src/tint/writer/msl/generator_impl_variable_decl_statement_test.cc +++ b/src/tint/writer/msl/generator_impl_variable_decl_statement_test.cc @@ -518,7 +518,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Initializer_ZeroMat_f16) } TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Private) { - GlobalVar("a", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("a", ty.f32(), builtin::AddressSpace::kPrivate); WrapInFunction(Expr("a")); @@ -531,7 +531,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Private) { } TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Workgroup) { - GlobalVar("a", ty.f32(), type::AddressSpace::kWorkgroup); + GlobalVar("a", ty.f32(), builtin::AddressSpace::kWorkgroup); WrapInFunction(Expr("a")); diff --git a/src/tint/writer/spirv/builder.cc b/src/tint/writer/spirv/builder.cc index 33b7cbf839..46838892b4 100644 --- a/src/tint/writer/spirv/builder.cc +++ b/src/tint/writer/spirv/builder.cc @@ -506,8 +506,8 @@ bool Builder::GenerateEntryPoint(const ast::Function* func, uint32_t id) { for (const auto* var : func_sem->TransitivelyReferencedGlobals()) { // For SPIR-V 1.3 we only output Input/output variables. If we update to // SPIR-V 1.4 or later this should be all variables. - if (var->AddressSpace() != type::AddressSpace::kIn && - var->AddressSpace() != type::AddressSpace::kOut) { + if (var->AddressSpace() != builtin::AddressSpace::kIn && + var->AddressSpace() != builtin::AddressSpace::kOut) { continue; } @@ -718,7 +718,7 @@ bool Builder::GenerateFunctionVariable(const ast::Variable* v) { auto result = result_op(); auto var_id = std::get(result); - auto sc = type::AddressSpace::kFunction; + auto sc = builtin::AddressSpace::kFunction; auto* type = sem->Type(); auto type_id = GenerateTypeIfNeeded(type); if (type_id == 0) { @@ -778,8 +778,9 @@ bool Builder::GenerateGlobalVariable(const ast::Variable* v) { auto result = result_op(); auto var_id = std::get(result); - auto sc = sem->AddressSpace() == type::AddressSpace::kUndefined ? type::AddressSpace::kPrivate - : sem->AddressSpace(); + auto sc = sem->AddressSpace() == builtin::AddressSpace::kUndefined + ? builtin::AddressSpace::kPrivate + : sem->AddressSpace(); auto type_id = GenerateTypeIfNeeded(sem->Type()); if (type_id == 0) { @@ -818,10 +819,10 @@ bool Builder::GenerateGlobalVariable(const ast::Variable* v) { // If we're a Workgroup variable, and the // VK_KHR_zero_initialize_workgroup_memory extension is enabled, we should // also zero-initialize. - if (sem->AddressSpace() == type::AddressSpace::kPrivate || - sem->AddressSpace() == type::AddressSpace::kOut || + if (sem->AddressSpace() == builtin::AddressSpace::kPrivate || + sem->AddressSpace() == builtin::AddressSpace::kOut || (zero_initialize_workgroup_memory_ && - sem->AddressSpace() == type::AddressSpace::kWorkgroup)) { + sem->AddressSpace() == builtin::AddressSpace::kWorkgroup)) { init_id = GenerateConstantNullIfNeeded(type); if (init_id == 0) { return 0; @@ -1900,9 +1901,9 @@ 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( - vec_type, type::AddressSpace::kFunction, builtin::Access::kReadWrite); + vec_type, builtin::AddressSpace::kFunction, builtin::Access::kReadWrite); push_function_var({Operand(GenerateTypeIfNeeded(splat_vector_type)), splat_vector, - U32Operand(ConvertAddressSpace(type::AddressSpace::kFunction)), + U32Operand(ConvertAddressSpace(builtin::AddressSpace::kFunction)), Operand(GenerateConstantNullIfNeeded(vec_type))}); // Splat scalar into vector @@ -3069,11 +3070,11 @@ bool Builder::GenerateAtomicBuiltin(const sem::Call* call, uint32_t memory_id = 0; switch (builtin->Parameters()[0]->Type()->As()->AddressSpace()) { - case type::AddressSpace::kWorkgroup: + case builtin::AddressSpace::kWorkgroup: memory_id = GenerateConstantIfNeeded( ScalarConstant::U32(static_cast(spv::Scope::Workgroup))); break; - case type::AddressSpace::kStorage: + case builtin::AddressSpace::kStorage: memory_id = GenerateConstantIfNeeded( ScalarConstant::U32(static_cast(spv::Scope::Device))); break; @@ -3977,38 +3978,38 @@ bool Builder::GenerateVectorType(const type::Vector* vec, const Operand& result) return true; } -SpvStorageClass Builder::ConvertAddressSpace(type::AddressSpace klass) const { +SpvStorageClass Builder::ConvertAddressSpace(builtin::AddressSpace klass) const { switch (klass) { - case type::AddressSpace::kIn: + case builtin::AddressSpace::kIn: return SpvStorageClassInput; - case type::AddressSpace::kOut: + case builtin::AddressSpace::kOut: return SpvStorageClassOutput; - case type::AddressSpace::kUniform: + case builtin::AddressSpace::kUniform: return SpvStorageClassUniform; - case type::AddressSpace::kWorkgroup: + case builtin::AddressSpace::kWorkgroup: return SpvStorageClassWorkgroup; - case type::AddressSpace::kPushConstant: + case builtin::AddressSpace::kPushConstant: return SpvStorageClassPushConstant; - case type::AddressSpace::kHandle: + case builtin::AddressSpace::kHandle: return SpvStorageClassUniformConstant; - case type::AddressSpace::kStorage: + case builtin::AddressSpace::kStorage: return SpvStorageClassStorageBuffer; - case type::AddressSpace::kPrivate: + case builtin::AddressSpace::kPrivate: return SpvStorageClassPrivate; - case type::AddressSpace::kFunction: + case builtin::AddressSpace::kFunction: return SpvStorageClassFunction; - case type::AddressSpace::kUndefined: + case builtin::AddressSpace::kUndefined: break; } return SpvStorageClassMax; } -SpvBuiltIn Builder::ConvertBuiltin(builtin::BuiltinValue builtin, type::AddressSpace storage) { +SpvBuiltIn Builder::ConvertBuiltin(builtin::BuiltinValue builtin, builtin::AddressSpace storage) { switch (builtin) { case builtin::BuiltinValue::kPosition: - if (storage == type::AddressSpace::kIn) { + if (storage == builtin::AddressSpace::kIn) { return SpvBuiltInFragCoord; - } else if (TINT_LIKELY(storage == type::AddressSpace::kOut)) { + } else if (TINT_LIKELY(storage == builtin::AddressSpace::kOut)) { return SpvBuiltInPosition; } else { TINT_ICE(Writer, builder_.Diagnostics()) << "invalid address space for builtin"; diff --git a/src/tint/writer/spirv/builder.h b/src/tint/writer/spirv/builder.h index c56085a567..57df396b4b 100644 --- a/src/tint/writer/spirv/builder.h +++ b/src/tint/writer/spirv/builder.h @@ -208,12 +208,12 @@ class Builder { /// Converts a address space to a SPIR-V address space. /// @param klass the address space to convert /// @returns the SPIR-V address space or SpvStorageClassMax on error. - SpvStorageClass ConvertAddressSpace(type::AddressSpace klass) const; + SpvStorageClass ConvertAddressSpace(builtin::AddressSpace klass) const; /// Converts a builtin to a SPIR-V builtin and pushes a capability if needed. /// @param builtin the builtin to convert /// @param storage the address space that this builtin is being used with /// @returns the SPIR-V builtin or SpvBuiltInMax on error. - SpvBuiltIn ConvertBuiltin(builtin::BuiltinValue builtin, type::AddressSpace storage); + SpvBuiltIn ConvertBuiltin(builtin::BuiltinValue builtin, builtin::AddressSpace storage); /// Converts an interpolate attribute to SPIR-V decorations and pushes a /// capability if needed. diff --git a/src/tint/writer/spirv/builder_assign_test.cc b/src/tint/writer/spirv/builder_assign_test.cc index a82d4b9f76..a6b8bc900c 100644 --- a/src/tint/writer/spirv/builder_assign_test.cc +++ b/src/tint/writer/spirv/builder_assign_test.cc @@ -23,7 +23,7 @@ namespace { using BuilderTest = TestHelper; TEST_F(BuilderTest, Assign_Var) { - auto* v = GlobalVar("var", ty.f32(), type::AddressSpace::kPrivate); + auto* v = GlobalVar("var", ty.f32(), builtin::AddressSpace::kPrivate); auto* assign = Assign("var", 1_f); @@ -51,7 +51,7 @@ TEST_F(BuilderTest, Assign_Var) { } TEST_F(BuilderTest, Assign_Var_OutsideFunction_IsError) { - auto* v = GlobalVar("var", ty.f32(), type::AddressSpace::kPrivate); + auto* v = GlobalVar("var", ty.f32(), builtin::AddressSpace::kPrivate); auto* assign = Assign("var", Expr(1_f)); @@ -70,7 +70,7 @@ TEST_F(BuilderTest, Assign_Var_OutsideFunction_IsError) { } TEST_F(BuilderTest, Assign_Var_ZeroInitializer) { - auto* v = GlobalVar("var", ty.vec3(), type::AddressSpace::kPrivate); + auto* v = GlobalVar("var", ty.vec3(), builtin::AddressSpace::kPrivate); auto* val = vec3(); auto* assign = Assign("var", val); @@ -101,7 +101,7 @@ TEST_F(BuilderTest, Assign_Var_ZeroInitializer) { TEST_F(BuilderTest, Assign_Var_Complex_InitializerNestedVector) { auto* init = vec3(vec2(1_f, 2_f), 3_f); - auto* v = GlobalVar("var", ty.vec3(), type::AddressSpace::kPrivate); + auto* v = GlobalVar("var", ty.vec3(), builtin::AddressSpace::kPrivate); auto* assign = Assign("var", init); @@ -134,7 +134,7 @@ TEST_F(BuilderTest, Assign_Var_Complex_InitializerNestedVector) { TEST_F(BuilderTest, Assign_Var_Complex_Initializer) { auto* init = vec3(1_f, 2_f, 3_f); - auto* v = GlobalVar("var", ty.vec3(), type::AddressSpace::kPrivate); + auto* v = GlobalVar("var", ty.vec3(), builtin::AddressSpace::kPrivate); auto* assign = Assign("var", init); @@ -209,7 +209,7 @@ OpStore %9 %10 } TEST_F(BuilderTest, Assign_Vector) { - auto* v = GlobalVar("var", ty.vec3(), type::AddressSpace::kPrivate); + auto* v = GlobalVar("var", ty.vec3(), builtin::AddressSpace::kPrivate); auto* val = vec3(1_f, 1_f, 3_f); auto* assign = Assign("var", val); @@ -243,7 +243,7 @@ TEST_F(BuilderTest, Assign_Vector) { TEST_F(BuilderTest, Assign_Vector_MemberByName) { // var.y = 1 - auto* v = GlobalVar("var", ty.vec3(), type::AddressSpace::kPrivate); + auto* v = GlobalVar("var", ty.vec3(), builtin::AddressSpace::kPrivate); auto* assign = Assign(MemberAccessor("var", "y"), Expr(1_f)); @@ -278,7 +278,7 @@ OpStore %9 %10 TEST_F(BuilderTest, Assign_Vector_MemberByIndex) { // var[1] = 1 - auto* v = GlobalVar("var", ty.vec3(), type::AddressSpace::kPrivate); + auto* v = GlobalVar("var", ty.vec3(), builtin::AddressSpace::kPrivate); auto* assign = Assign(IndexAccessor("var", 1_i), Expr(1_f)); diff --git a/src/tint/writer/spirv/builder_binary_expression_test.cc b/src/tint/writer/spirv/builder_binary_expression_test.cc index b6dfb6256c..7251929bf4 100644 --- a/src/tint/writer/spirv/builder_binary_expression_test.cc +++ b/src/tint/writer/spirv/builder_binary_expression_test.cc @@ -1031,8 +1031,8 @@ OpBranch %17 } TEST_F(BuilderTest, Binary_LogicalAnd_WithLoads) { - auto* a_var = GlobalVar("a", ty.bool_(), type::AddressSpace::kPrivate, Expr(true)); - auto* b_var = GlobalVar("b", ty.bool_(), type::AddressSpace::kPrivate, Expr(false)); + auto* a_var = GlobalVar("a", ty.bool_(), builtin::AddressSpace::kPrivate, Expr(true)); + auto* b_var = GlobalVar("b", ty.bool_(), builtin::AddressSpace::kPrivate, Expr(false)); auto* expr = create(ast::BinaryOp::kLogicalAnd, Expr("a"), Expr("b")); WrapInFunction(expr); @@ -1207,8 +1207,8 @@ OpBranch %17 } TEST_F(BuilderTest, Binary_LogicalOr_WithLoads) { - auto* a_var = GlobalVar("a", ty.bool_(), type::AddressSpace::kPrivate, Expr(true)); - auto* b_var = GlobalVar("b", ty.bool_(), type::AddressSpace::kPrivate, Expr(false)); + auto* a_var = GlobalVar("a", ty.bool_(), builtin::AddressSpace::kPrivate, Expr(true)); + auto* b_var = GlobalVar("b", ty.bool_(), builtin::AddressSpace::kPrivate, Expr(false)); auto* expr = create(ast::BinaryOp::kLogicalOr, Expr("a"), Expr("b")); @@ -1251,19 +1251,19 @@ static const ast::Expression* MakeVectorExpr(ProgramBuilder* builder, Type type) switch (type) { case Type::f32: builder->GlobalVar(name, builder->ty.vec3(), builder->vec3(1_f, 1_f, 1_f), - type::AddressSpace::kPrivate); + builtin::AddressSpace::kPrivate); break; case Type::f16: builder->GlobalVar(name, builder->ty.vec3(), builder->vec3(1_h, 1_h, 1_h), - type::AddressSpace::kPrivate); + builtin::AddressSpace::kPrivate); break; case Type::i32: builder->GlobalVar(name, builder->ty.vec3(), builder->vec3(1_i, 1_i, 1_i), - type::AddressSpace::kPrivate); + builtin::AddressSpace::kPrivate); break; case Type::u32: builder->GlobalVar(name, builder->ty.vec3(), builder->vec3(1_u, 1_u, 1_u), - type::AddressSpace::kPrivate); + builtin::AddressSpace::kPrivate); break; } return builder->Expr(name); @@ -1273,19 +1273,19 @@ static const ast::Expression* MakeScalarExpr(ProgramBuilder* builder, Type type) switch (type) { case Type::f32: builder->GlobalVar(name, builder->ty.f32(), builder->Expr(1_f), - type::AddressSpace::kPrivate); + builtin::AddressSpace::kPrivate); break; case Type::f16: builder->GlobalVar(name, builder->ty.f16(), builder->Expr(1_h), - type::AddressSpace::kPrivate); + builtin::AddressSpace::kPrivate); break; case Type::i32: builder->GlobalVar(name, builder->ty.i32(), builder->Expr(1_i), - type::AddressSpace::kPrivate); + builtin::AddressSpace::kPrivate); break; case Type::u32: builder->GlobalVar(name, builder->ty.u32(), builder->Expr(1_u), - type::AddressSpace::kPrivate); + builtin::AddressSpace::kPrivate); break; } return builder->Expr(name); @@ -1580,11 +1580,11 @@ static const ast::Expression* MakeMat3x4Expr(ProgramBuilder* builder, Type type) switch (type) { case Type::f32: builder->GlobalVar(name, builder->ty.mat3x4(), builder->mat3x4(), - type::AddressSpace::kPrivate); + builtin::AddressSpace::kPrivate); break; case Type::f16: builder->GlobalVar(name, builder->ty.mat3x4(), builder->mat3x4(), - type::AddressSpace::kPrivate); + builtin::AddressSpace::kPrivate); break; } return builder->Expr(name); @@ -1594,11 +1594,11 @@ static const ast::Expression* MakeMat4x3Expr(ProgramBuilder* builder, Type type) switch (type) { case Type::f32: builder->GlobalVar(name, builder->ty.mat4x3(), builder->mat4x3(), - type::AddressSpace::kPrivate); + builtin::AddressSpace::kPrivate); break; case Type::f16: builder->GlobalVar(name, builder->ty.mat4x3(), builder->mat4x3(), - type::AddressSpace::kPrivate); + builtin::AddressSpace::kPrivate); } return builder->Expr(name); } diff --git a/src/tint/writer/spirv/builder_builtin_test.cc b/src/tint/writer/spirv/builder_builtin_test.cc index a895e5f2d6..869a8c61c0 100644 --- a/src/tint/writer/spirv/builder_builtin_test.cc +++ b/src/tint/writer/spirv/builder_builtin_test.cc @@ -98,7 +98,7 @@ TEST_F(BuiltinBuilderTest, Call_TextureSampleCompare_Twice) { } TEST_F(BuiltinBuilderTest, Call_GLSLMethod_WithLoad_f32) { - auto* var = GlobalVar("ident", ty.f32(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("ident", ty.f32(), builtin::AddressSpace::kPrivate); auto* expr = Call("round", "ident"); auto* func = Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -134,7 +134,7 @@ OpFunctionEnd TEST_F(BuiltinBuilderTest, Call_GLSLMethod_WithLoad_f16) { Enable(builtin::Extension::kF16); - auto* var = GlobalVar("ident", ty.f16(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("ident", ty.f16(), builtin::AddressSpace::kPrivate); auto* expr = Call("round", "ident"); auto* func = Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -173,7 +173,7 @@ namespace logical_builtin_tests { using BuiltinBoolTest = BuiltinBuilderTestWithParam; TEST_P(BuiltinBoolTest, Call_Bool_Scalar) { auto param = GetParam(); - auto* var = GlobalVar("v", ty.bool_(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("v", ty.bool_(), builtin::AddressSpace::kPrivate); auto* expr = Call(param.name, "v"); auto* func = Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -199,7 +199,7 @@ TEST_P(BuiltinBoolTest, Call_Bool_Scalar) { TEST_P(BuiltinBoolTest, Call_Bool_Vector) { auto param = GetParam(); - auto* var = GlobalVar("v", ty.vec3(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("v", ty.vec3(), builtin::AddressSpace::kPrivate); auto* expr = Call(param.name, "v"); auto* func = Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -232,9 +232,9 @@ INSTANTIATE_TEST_SUITE_P(BuiltinBuilderTest, testing::Values(BuiltinData{"any", "OpAny"}, BuiltinData{"all", "OpAll"})); TEST_F(BuiltinBuilderTest, Call_Select) { - auto* v3 = GlobalVar("v3", ty.vec3(), type::AddressSpace::kPrivate); + auto* v3 = GlobalVar("v3", ty.vec3(), builtin::AddressSpace::kPrivate); - auto* bool_v3 = GlobalVar("bool_v3", ty.vec3(), type::AddressSpace::kPrivate); + auto* bool_v3 = GlobalVar("bool_v3", ty.vec3(), builtin::AddressSpace::kPrivate); auto* expr = Call("select", "v3", "v3", "bool_v3"); auto* func = Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -278,7 +278,7 @@ TEST_F(BuiltinBuilderTest, Call_ArrayLength) { auto* s = Structure("my_struct", utils::Vector{ Member("a", ty.array()), }); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), Group(2_a)); auto* expr = Call("arrayLength", AddressOf(MemberAccessor("b", "a"))); @@ -322,7 +322,7 @@ TEST_F(BuiltinBuilderTest, Call_ArrayLength_OtherMembersInStruct) { Member("z", ty.f32()), Member(4, "a", ty.array()), }); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), Group(2_a)); auto* expr = Call("arrayLength", AddressOf(MemberAccessor("b", "a"))); @@ -365,7 +365,7 @@ TEST_F(BuiltinBuilderTest, Call_ArrayLength_ViaLets) { auto* s = Structure("my_struct", utils::Vector{ Member("a", ty.array()), }); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), Group(2_a)); auto* p = Let("p", AddressOf("b")); @@ -424,7 +424,7 @@ TEST_F(BuiltinBuilderTest, Call_ArrayLength_ViaLets_WithPtrNoise) { auto* s = Structure("my_struct", utils::Vector{ Member("a", ty.array()), }); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), + GlobalVar("b", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kRead, Binding(1_a), Group(2_a)); auto* p = Let("p", AddressOf(Deref(AddressOf("b")))); @@ -2046,7 +2046,7 @@ OpFunctionEnd } TEST_F(BuiltinBuilderTest, Call_QuantizeToF16_Scalar) { - GlobalVar("v", Expr(2_f), type::AddressSpace::kPrivate); + GlobalVar("v", Expr(2_f), builtin::AddressSpace::kPrivate); Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -2085,7 +2085,7 @@ OpFunctionEnd } TEST_F(BuiltinBuilderTest, Call_QuantizeToF16_Vector) { - GlobalVar("v", vec3(2_f), type::AddressSpace::kPrivate); + GlobalVar("v", vec3(2_f), builtin::AddressSpace::kPrivate); Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -2152,7 +2152,7 @@ namespace integer_builtin_tests { using BuiltinIntTest = BuiltinBuilderTestWithParam; TEST_P(BuiltinIntTest, Call_SInt_Scalar) { auto param = GetParam(); - auto* var = GlobalVar("v", ty.i32(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("v", ty.i32(), builtin::AddressSpace::kPrivate); auto* expr = Call(param.name, "v"); auto* func = Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -2182,7 +2182,7 @@ OpReturn TEST_P(BuiltinIntTest, Call_SInt_Vector) { auto param = GetParam(); - auto* var = GlobalVar("v", ty.vec3(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("v", ty.vec3(), builtin::AddressSpace::kPrivate); auto* expr = Call(param.name, "v"); auto* func = Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -2213,7 +2213,7 @@ OpReturn TEST_P(BuiltinIntTest, Call_UInt_Scalar) { auto param = GetParam(); - auto* var = GlobalVar("v", ty.u32(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("v", ty.u32(), builtin::AddressSpace::kPrivate); auto* expr = Call(param.name, "v"); auto* func = Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -2243,7 +2243,7 @@ OpReturn TEST_P(BuiltinIntTest, Call_UInt_Vector) { auto param = GetParam(); - auto* var = GlobalVar("v", ty.vec3(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("v", ty.vec3(), builtin::AddressSpace::kPrivate); auto* expr = Call(param.name, "v"); auto* func = Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -3114,7 +3114,7 @@ OpFunctionEnd namespace matrix_builtin_tests { TEST_F(BuiltinBuilderTest, Call_Determinant_f32) { - auto* var = GlobalVar("var", ty.mat3x3(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("var", ty.mat3x3(), builtin::AddressSpace::kPrivate); auto* expr = Call("determinant", "var"); auto* func = Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -3151,7 +3151,7 @@ OpFunctionEnd TEST_F(BuiltinBuilderTest, Call_Determinant_f16) { Enable(builtin::Extension::kF16); - auto* var = GlobalVar("var", ty.mat3x3(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("var", ty.mat3x3(), builtin::AddressSpace::kPrivate); auto* expr = Call("determinant", "var"); auto* func = Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -3186,7 +3186,7 @@ OpFunctionEnd } TEST_F(BuiltinBuilderTest, Call_Transpose_f32) { - auto* var = GlobalVar("var", ty.mat2x3(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("var", ty.mat2x3(), builtin::AddressSpace::kPrivate); auto* expr = Call("transpose", "var"); auto* func = Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -3224,7 +3224,7 @@ OpFunctionEnd TEST_F(BuiltinBuilderTest, Call_Transpose_f16) { Enable(builtin::Extension::kF16); - auto* var = GlobalVar("var", ty.mat2x3(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("var", ty.mat2x3(), builtin::AddressSpace::kPrivate); auto* expr = Call("transpose", "var"); auto* func = Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -3265,7 +3265,7 @@ OpFunctionEnd namespace vector_builtin_tests { TEST_F(BuiltinBuilderTest, Call_Dot_F32) { - auto* var = GlobalVar("v", ty.vec3(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("v", ty.vec3(), builtin::AddressSpace::kPrivate); auto* expr = Call("dot", "v", "v"); auto* func = Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -3296,7 +3296,7 @@ OpReturn TEST_F(BuiltinBuilderTest, Call_Dot_F16) { Enable(builtin::Extension::kF16); - auto* var = GlobalVar("v", ty.vec3(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("v", ty.vec3(), builtin::AddressSpace::kPrivate); auto* expr = Call("dot", "v", "v"); auto* func = Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -3325,7 +3325,7 @@ OpReturn } TEST_F(BuiltinBuilderTest, Call_Dot_U32) { - auto* var = GlobalVar("v", ty.vec3(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("v", ty.vec3(), builtin::AddressSpace::kPrivate); auto* expr = Call("dot", "v", "v"); auto* func = Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -3364,7 +3364,7 @@ OpReturn } TEST_F(BuiltinBuilderTest, Call_Dot_I32) { - auto* var = GlobalVar("v", ty.vec3(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("v", ty.vec3(), builtin::AddressSpace::kPrivate); auto* expr = Call("dot", "v", "v"); auto* func = Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -3410,7 +3410,7 @@ namespace derivative_builtin_tests { using BuiltinDeriveTest = BuiltinBuilderTestWithParam; TEST_P(BuiltinDeriveTest, Call_Derivative_Scalar) { auto param = GetParam(); - auto* var = GlobalVar("v", ty.f32(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("v", ty.f32(), builtin::AddressSpace::kPrivate); auto* expr = Call(param.name, "v"); auto* func = Func("func", utils::Empty, ty.void_(), utils::Vector{ @@ -3443,7 +3443,7 @@ OpReturn TEST_P(BuiltinDeriveTest, Call_Derivative_Vector) { auto param = GetParam(); - auto* var = GlobalVar("v", ty.vec3(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("v", ty.vec3(), builtin::AddressSpace::kPrivate); auto* expr = Call(param.name, "v"); auto* func = Func("func", utils::Empty, ty.void_(), utils::Vector{ @@ -3513,7 +3513,7 @@ TEST_F(BuiltinBuilderTest, Call_AtomicLoad) { Member("u", ty.atomic()), Member("i", ty.atomic()), }); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + GlobalVar("b", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, Binding(1_a), Group(2_a)); Func("a_func", utils::Empty, ty.void_(), @@ -3577,7 +3577,7 @@ TEST_F(BuiltinBuilderTest, Call_AtomicStore) { Member("u", ty.atomic()), Member("i", ty.atomic()), }); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + GlobalVar("b", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, Binding(1_a), Group(2_a)); Func("a_func", utils::Empty, ty.void_(), @@ -3649,7 +3649,7 @@ TEST_P(Builtin_Builder_AtomicRMW_i32, Test) { auto* s = Structure("S", utils::Vector{ Member("v", ty.atomic()), }); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + GlobalVar("b", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, Binding(1_a), Group(2_a)); Func("a_func", utils::Empty, ty.void_(), @@ -3722,7 +3722,7 @@ TEST_P(Builtin_Builder_AtomicRMW_u32, Test) { auto* s = Structure("S", utils::Vector{ Member("v", ty.atomic()), }); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + GlobalVar("b", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, Binding(1_a), Group(2_a)); Func("a_func", utils::Empty, ty.void_(), @@ -3797,7 +3797,7 @@ TEST_F(BuiltinBuilderTest, Call_AtomicExchange) { Member("u", ty.atomic()), Member("i", ty.atomic()), }); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + GlobalVar("b", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, Binding(1_a), Group(2_a)); Func("a_func", utils::Empty, ty.void_(), @@ -3873,7 +3873,7 @@ TEST_F(BuiltinBuilderTest, Call_AtomicCompareExchangeWeak) { Member("u", ty.atomic()), Member("i", ty.atomic()), }); - GlobalVar("b", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + GlobalVar("b", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, Binding(1_a), Group(2_a)); Func("a_func", utils::Empty, ty.void_(), diff --git a/src/tint/writer/spirv/builder_entry_point_test.cc b/src/tint/writer/spirv/builder_entry_point_test.cc index 59e1848e2b..085a6f24d9 100644 --- a/src/tint/writer/spirv/builder_entry_point_test.cc +++ b/src/tint/writer/spirv/builder_entry_point_test.cc @@ -20,9 +20,9 @@ #include "src/tint/ast/return_statement.h" #include "src/tint/ast/stage_attribute.h" #include "src/tint/ast/variable.h" +#include "src/tint/builtin/address_space.h" #include "src/tint/builtin/builtin_value.h" #include "src/tint/program.h" -#include "src/tint/type/address_space.h" #include "src/tint/type/f32.h" #include "src/tint/type/vector.h" #include "src/tint/writer/spirv/builder.h" diff --git a/src/tint/writer/spirv/builder_function_test.cc b/src/tint/writer/spirv/builder_function_test.cc index bdfc412686..5cf97ea03a 100644 --- a/src/tint/writer/spirv/builder_function_test.cc +++ b/src/tint/writer/spirv/builder_function_test.cc @@ -61,7 +61,7 @@ OpFunctionEnd } TEST_F(BuilderTest, Function_Terminator_ReturnValue) { - GlobalVar("a", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("a", ty.f32(), builtin::AddressSpace::kPrivate); Func("a_func", utils::Empty, ty.f32(), utils::Vector{Return("a")}, utils::Empty); @@ -198,7 +198,7 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) { auto* s = Structure("Data", utils::Vector{Member("d", ty.f32())}); - GlobalVar("data", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + GlobalVar("data", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, Binding(0_a), Group(0_a)); { diff --git a/src/tint/writer/spirv/builder_function_variable_test.cc b/src/tint/writer/spirv/builder_function_variable_test.cc index 47f1ed2099..72cf12b8c6 100644 --- a/src/tint/writer/spirv/builder_function_variable_test.cc +++ b/src/tint/writer/spirv/builder_function_variable_test.cc @@ -23,7 +23,7 @@ namespace { using BuilderTest = TestHelper; TEST_F(BuilderTest, FunctionVar_NoAddressSpace) { - auto* v = Var("var", ty.f32(), type::AddressSpace::kFunction); + auto* v = Var("var", ty.f32(), builtin::AddressSpace::kFunction); WrapInFunction(v); spirv::Builder& b = Build(); @@ -45,7 +45,7 @@ TEST_F(BuilderTest, FunctionVar_NoAddressSpace) { TEST_F(BuilderTest, FunctionVar_WithConstantInitializer) { auto* init = vec3(1_f, 1_f, 3_f); - auto* v = Var("var", ty.vec3(), type::AddressSpace::kFunction, init); + auto* v = Var("var", ty.vec3(), builtin::AddressSpace::kFunction, init); WrapInFunction(v); spirv::Builder& b = Build(); diff --git a/src/tint/writer/spirv/builder_global_variable_test.cc b/src/tint/writer/spirv/builder_global_variable_test.cc index d412db2f25..f9f9c4b666 100644 --- a/src/tint/writer/spirv/builder_global_variable_test.cc +++ b/src/tint/writer/spirv/builder_global_variable_test.cc @@ -26,7 +26,7 @@ namespace { using BuilderTest = TestHelper; TEST_F(BuilderTest, GlobalVar_WithAddressSpace) { - auto* v = GlobalVar("var", ty.f32(), type::AddressSpace::kPrivate); + auto* v = GlobalVar("var", ty.f32(), builtin::AddressSpace::kPrivate); spirv::Builder& b = Build(); @@ -43,7 +43,7 @@ TEST_F(BuilderTest, GlobalVar_WithAddressSpace) { TEST_F(BuilderTest, GlobalVar_WithInitializer) { auto* init = vec3(1_f, 1_f, 3_f); - auto* v = GlobalVar("var", ty.vec3(), type::AddressSpace::kPrivate, init); + auto* v = GlobalVar("var", ty.vec3(), builtin::AddressSpace::kPrivate, init); spirv::Builder& b = Build(); @@ -67,7 +67,7 @@ TEST_F(BuilderTest, GlobalConst) { // var v = c; auto* c = GlobalConst("c", Expr(42_a)); - GlobalVar("v", type::AddressSpace::kPrivate, Expr(c)); + GlobalVar("v", builtin::AddressSpace::kPrivate, Expr(c)); spirv::Builder& b = SanitizeAndBuild(); @@ -92,7 +92,7 @@ TEST_F(BuilderTest, GlobalConst_Vec_Initializer) { // var v = c; auto* c = GlobalConst("c", vec3(1_f, 2_f, 3_f)); - GlobalVar("v", type::AddressSpace::kPrivate, Expr(c)); + GlobalVar("v", builtin::AddressSpace::kPrivate, Expr(c)); spirv::Builder& b = SanitizeAndBuild(); @@ -122,7 +122,7 @@ TEST_F(BuilderTest, GlobalConst_Vec_F16_Initializer) { Enable(builtin::Extension::kF16); auto* c = GlobalConst("c", vec3(1_h, 2_h, 3_h)); - GlobalVar("v", type::AddressSpace::kPrivate, Expr(c)); + GlobalVar("v", builtin::AddressSpace::kPrivate, Expr(c)); spirv::Builder& b = SanitizeAndBuild(); @@ -151,7 +151,7 @@ TEST_F(BuilderTest, GlobalConst_Vec_AInt_Initializer) { // var v = c; auto* c = GlobalConst("c", Call(ty.vec3(), 1_a, 2_a, 3_a)); - GlobalVar("v", type::AddressSpace::kPrivate, Expr(c)); + GlobalVar("v", builtin::AddressSpace::kPrivate, Expr(c)); spirv::Builder& b = SanitizeAndBuild(); @@ -180,7 +180,7 @@ TEST_F(BuilderTest, GlobalConst_Vec_AFloat_Initializer) { // var v = c; auto* c = GlobalConst("c", Call(ty.vec3(), 1._a, 2._a, 3._a)); - GlobalVar("v", type::AddressSpace::kPrivate, Expr(c)); + GlobalVar("v", builtin::AddressSpace::kPrivate, Expr(c)); spirv::Builder& b = SanitizeAndBuild(); @@ -209,7 +209,7 @@ TEST_F(BuilderTest, GlobalConst_Nested_Vec_Initializer) { // var v = c; auto* c = GlobalConst("c", vec3(vec2(1_f, 2_f), 3_f)); - GlobalVar("v", type::AddressSpace::kPrivate, Expr(c)); + GlobalVar("v", builtin::AddressSpace::kPrivate, Expr(c)); spirv::Builder& b = SanitizeAndBuild(); @@ -252,7 +252,7 @@ OpDecorate %1 DescriptorSet 3 struct BuiltinData { builtin::BuiltinValue builtin; - type::AddressSpace storage; + builtin::AddressSpace storage; SpvBuiltIn result; }; inline std::ostream& operator<<(std::ostream& out, BuiltinData data) { @@ -270,38 +270,39 @@ TEST_P(BuiltinDataTest, Convert) { INSTANTIATE_TEST_SUITE_P( BuilderTest_Type, BuiltinDataTest, - testing::Values( - BuiltinData{builtin::BuiltinValue::kUndefined, type::AddressSpace::kUndefined, - SpvBuiltInMax}, - BuiltinData{builtin::BuiltinValue::kPosition, type::AddressSpace::kIn, SpvBuiltInFragCoord}, - BuiltinData{builtin::BuiltinValue::kPosition, type::AddressSpace::kOut, SpvBuiltInPosition}, - BuiltinData{ - builtin::BuiltinValue::kVertexIndex, - type::AddressSpace::kIn, - SpvBuiltInVertexIndex, - }, - BuiltinData{builtin::BuiltinValue::kInstanceIndex, type::AddressSpace::kIn, - SpvBuiltInInstanceIndex}, - BuiltinData{builtin::BuiltinValue::kFrontFacing, type::AddressSpace::kIn, - SpvBuiltInFrontFacing}, - BuiltinData{builtin::BuiltinValue::kFragDepth, type::AddressSpace::kOut, - SpvBuiltInFragDepth}, - BuiltinData{builtin::BuiltinValue::kLocalInvocationId, type::AddressSpace::kIn, - SpvBuiltInLocalInvocationId}, - BuiltinData{builtin::BuiltinValue::kLocalInvocationIndex, type::AddressSpace::kIn, - SpvBuiltInLocalInvocationIndex}, - BuiltinData{builtin::BuiltinValue::kGlobalInvocationId, type::AddressSpace::kIn, - SpvBuiltInGlobalInvocationId}, - BuiltinData{builtin::BuiltinValue::kWorkgroupId, type::AddressSpace::kIn, - SpvBuiltInWorkgroupId}, - BuiltinData{builtin::BuiltinValue::kNumWorkgroups, type::AddressSpace::kIn, - SpvBuiltInNumWorkgroups}, - BuiltinData{builtin::BuiltinValue::kSampleIndex, type::AddressSpace::kIn, - SpvBuiltInSampleId}, - BuiltinData{builtin::BuiltinValue::kSampleMask, type::AddressSpace::kIn, - SpvBuiltInSampleMask}, - BuiltinData{builtin::BuiltinValue::kSampleMask, type::AddressSpace::kOut, - SpvBuiltInSampleMask})); + testing::Values(BuiltinData{builtin::BuiltinValue::kUndefined, + builtin::AddressSpace::kUndefined, SpvBuiltInMax}, + BuiltinData{builtin::BuiltinValue::kPosition, builtin::AddressSpace::kIn, + SpvBuiltInFragCoord}, + BuiltinData{builtin::BuiltinValue::kPosition, builtin::AddressSpace::kOut, + SpvBuiltInPosition}, + BuiltinData{ + builtin::BuiltinValue::kVertexIndex, + builtin::AddressSpace::kIn, + SpvBuiltInVertexIndex, + }, + BuiltinData{builtin::BuiltinValue::kInstanceIndex, builtin::AddressSpace::kIn, + SpvBuiltInInstanceIndex}, + BuiltinData{builtin::BuiltinValue::kFrontFacing, builtin::AddressSpace::kIn, + SpvBuiltInFrontFacing}, + BuiltinData{builtin::BuiltinValue::kFragDepth, builtin::AddressSpace::kOut, + SpvBuiltInFragDepth}, + BuiltinData{builtin::BuiltinValue::kLocalInvocationId, + builtin::AddressSpace::kIn, SpvBuiltInLocalInvocationId}, + BuiltinData{builtin::BuiltinValue::kLocalInvocationIndex, + builtin::AddressSpace::kIn, SpvBuiltInLocalInvocationIndex}, + BuiltinData{builtin::BuiltinValue::kGlobalInvocationId, + builtin::AddressSpace::kIn, SpvBuiltInGlobalInvocationId}, + BuiltinData{builtin::BuiltinValue::kWorkgroupId, builtin::AddressSpace::kIn, + SpvBuiltInWorkgroupId}, + BuiltinData{builtin::BuiltinValue::kNumWorkgroups, builtin::AddressSpace::kIn, + SpvBuiltInNumWorkgroups}, + BuiltinData{builtin::BuiltinValue::kSampleIndex, builtin::AddressSpace::kIn, + SpvBuiltInSampleId}, + BuiltinData{builtin::BuiltinValue::kSampleMask, builtin::AddressSpace::kIn, + SpvBuiltInSampleMask}, + BuiltinData{builtin::BuiltinValue::kSampleMask, builtin::AddressSpace::kOut, + SpvBuiltInSampleMask})); TEST_F(BuilderTest, GlobalVar_DeclReadOnly) { // struct A { @@ -314,7 +315,7 @@ TEST_F(BuilderTest, GlobalVar_DeclReadOnly) { Member("b", ty.i32()), }); - GlobalVar("b", ty.Of(A), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), + GlobalVar("b", ty.Of(A), builtin::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), Group(0_a)); spirv::Builder& b = SanitizeAndBuild(); @@ -356,7 +357,7 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasDeclReadOnly) { auto* A = Structure("A", utils::Vector{Member("a", ty.i32())}); auto* B = Alias("B", ty.Of(A)); - GlobalVar("b", ty.Of(B), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), + GlobalVar("b", ty.Of(B), builtin::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), Group(0_a)); spirv::Builder& b = SanitizeAndBuild(); @@ -396,7 +397,7 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasAssignReadOnly) { auto* A = Structure("A", utils::Vector{Member("a", ty.i32())}); auto* B = Alias("B", ty.Of(A)); - GlobalVar("b", ty.Of(B), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), + GlobalVar("b", ty.Of(B), builtin::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), Group(0_a)); spirv::Builder& b = SanitizeAndBuild(); @@ -435,10 +436,10 @@ TEST_F(BuilderTest, GlobalVar_TwoVarDeclReadOnly) { // var c : A auto* A = Structure("A", utils::Vector{Member("a", ty.i32())}); - GlobalVar("b", ty.Of(A), type::AddressSpace::kStorage, builtin::Access::kRead, Group(0_a), - Binding(0_a)); - GlobalVar("c", ty.Of(A), type::AddressSpace::kStorage, builtin::Access::kReadWrite, Group(1_a), + GlobalVar("b", ty.Of(A), builtin::AddressSpace::kStorage, builtin::Access::kRead, Group(0_a), Binding(0_a)); + GlobalVar("c", ty.Of(A), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, + Group(1_a), Binding(0_a)); spirv::Builder& b = SanitizeAndBuild(); @@ -498,16 +499,16 @@ OpDecorate %1 DescriptorSet 0 TEST_F(BuilderTest, GlobalVar_WorkgroupWithZeroInit) { auto type_scalar = ty.i32(); - auto* var_scalar = GlobalVar("a", type_scalar, type::AddressSpace::kWorkgroup); + auto* var_scalar = GlobalVar("a", type_scalar, builtin::AddressSpace::kWorkgroup); auto type_array = ty.array(); - auto* var_array = GlobalVar("b", type_array, type::AddressSpace::kWorkgroup); + auto* var_array = GlobalVar("b", type_array, builtin::AddressSpace::kWorkgroup); auto* type_struct = Structure("C", utils::Vector{ Member("a", ty.i32()), Member("b", ty.i32()), }); - auto* var_struct = GlobalVar("c", ty.Of(type_struct), type::AddressSpace::kWorkgroup); + auto* var_struct = GlobalVar("c", ty.Of(type_struct), builtin::AddressSpace::kWorkgroup); program = std::make_unique(std::move(*this)); diff --git a/src/tint/writer/spirv/builder_ident_expression_test.cc b/src/tint/writer/spirv/builder_ident_expression_test.cc index 4db5d425f7..7c56ba1693 100644 --- a/src/tint/writer/spirv/builder_ident_expression_test.cc +++ b/src/tint/writer/spirv/builder_ident_expression_test.cc @@ -41,7 +41,7 @@ TEST_F(BuilderTest, IdentifierExpression_GlobalConst) { } TEST_F(BuilderTest, IdentifierExpression_GlobalVar) { - auto* v = GlobalVar("var", ty.f32(), type::AddressSpace::kPrivate); + auto* v = GlobalVar("var", ty.f32(), builtin::AddressSpace::kPrivate); auto* expr = Expr("var"); WrapInFunction(expr); @@ -85,7 +85,7 @@ TEST_F(BuilderTest, IdentifierExpression_FunctionConst) { } TEST_F(BuilderTest, IdentifierExpression_FunctionVar) { - auto* v = Var("var", ty.f32(), type::AddressSpace::kFunction); + auto* v = Var("var", ty.f32(), builtin::AddressSpace::kFunction); auto* expr = Expr("var"); WrapInFunction(v, expr); @@ -109,7 +109,7 @@ TEST_F(BuilderTest, IdentifierExpression_FunctionVar) { } TEST_F(BuilderTest, IdentifierExpression_Load) { - auto* var = GlobalVar("var", ty.i32(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("var", ty.i32(), builtin::AddressSpace::kPrivate); auto* expr = Add("var", "var"); WrapInFunction(expr); diff --git a/src/tint/writer/spirv/builder_if_test.cc b/src/tint/writer/spirv/builder_if_test.cc index 6462200c6e..031ed68ca5 100644 --- a/src/tint/writer/spirv/builder_if_test.cc +++ b/src/tint/writer/spirv/builder_if_test.cc @@ -68,7 +68,7 @@ TEST_F(BuilderTest, If_WithStatements) { // v = 2; // } - auto* var = GlobalVar("v", ty.i32(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("v", ty.i32(), builtin::AddressSpace::kPrivate); auto* body = Block(Assign("v", 2_i)); auto* expr = If(true, body); WrapInFunction(expr); @@ -104,7 +104,7 @@ TEST_F(BuilderTest, If_WithElse) { // v = 3i; // } - auto* var = GlobalVar("v", ty.i32(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("v", ty.i32(), builtin::AddressSpace::kPrivate); auto* body = Block(Assign("v", 2_i)); auto* else_body = Block(Assign("v", 3_i)); @@ -146,7 +146,7 @@ TEST_F(BuilderTest, If_WithElseIf) { // v = 3i; // } - auto* var = GlobalVar("v", ty.i32(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("v", ty.i32(), builtin::AddressSpace::kPrivate); auto* body = Block(Assign("v", 2_i)); auto* else_body = Block(Assign("v", 3_i)); @@ -197,7 +197,7 @@ TEST_F(BuilderTest, If_WithMultiple) { // v = 5i; // } - auto* var = GlobalVar("v", ty.i32(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("v", ty.i32(), builtin::AddressSpace::kPrivate); auto* body = Block(Assign("v", 2_i)); auto* elseif_1_body = Block(Assign("v", 3_i)); auto* elseif_2_body = Block(Assign("v", 4_i)); @@ -562,7 +562,7 @@ TEST_F(BuilderTest, If_WithLoad_Bug327) { // if (a) { // } - auto* var = GlobalVar("a", ty.bool_(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("a", ty.bool_(), builtin::AddressSpace::kPrivate); auto* fn = Func("f", utils::Empty, ty.void_(), utils::Vector{ If("a", Block()), diff --git a/src/tint/writer/spirv/builder_initializer_expression_test.cc b/src/tint/writer/spirv/builder_initializer_expression_test.cc index 9fdc4fced4..cf382e0fd2 100644 --- a/src/tint/writer/spirv/builder_initializer_expression_test.cc +++ b/src/tint/writer/spirv/builder_initializer_expression_test.cc @@ -24,7 +24,7 @@ using SpvBuilderInitializerTest = TestHelper; TEST_F(SpvBuilderInitializerTest, Const) { auto* c = Expr(42.2_f); - auto* g = GlobalVar("g", ty.f32(), c, type::AddressSpace::kPrivate); + auto* g = GlobalVar("g", ty.f32(), c, builtin::AddressSpace::kPrivate); spirv::Builder& b = Build(); @@ -1935,7 +1935,7 @@ OpReturn TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_F32_With_F32) { auto* ctor = Call(2_f); - GlobalVar("g", ty.f32(), type::AddressSpace::kPrivate, ctor); + GlobalVar("g", ty.f32(), builtin::AddressSpace::kPrivate, ctor); spirv::Builder& b = SanitizeAndBuild(); ASSERT_TRUE(b.Build()); @@ -1954,7 +1954,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_F16_With_F16) { Enable(builtin::Extension::kF16); auto* ctor = Call(2_h); - GlobalVar("g", ty.f16(), type::AddressSpace::kPrivate, ctor); + GlobalVar("g", ty.f16(), builtin::AddressSpace::kPrivate, ctor); spirv::Builder& b = SanitizeAndBuild(); ASSERT_TRUE(b.Build()); @@ -2015,7 +2015,7 @@ OpReturn TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_U32_With_F32) { auto* ctor = Call(1.5_f); - GlobalVar("g", ty.u32(), type::AddressSpace::kPrivate, ctor); + GlobalVar("g", ty.u32(), builtin::AddressSpace::kPrivate, ctor); spirv::Builder& b = SanitizeAndBuild(); ASSERT_TRUE(b.Build()); @@ -2034,7 +2034,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_U32_With_F16) { Enable(builtin::Extension::kF16); auto* ctor = Call(1.5_h); - GlobalVar("g", ty.u32(), type::AddressSpace::kPrivate, ctor); + GlobalVar("g", ty.u32(), builtin::AddressSpace::kPrivate, ctor); spirv::Builder& b = SanitizeAndBuild(); ASSERT_TRUE(b.Build()); @@ -2099,7 +2099,7 @@ OpReturn TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec2_With_F32) { auto* cast = vec2(2_f); - auto* g = GlobalVar("g", ty.vec2(), type::AddressSpace::kPrivate, cast); + auto* g = GlobalVar("g", ty.vec2(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = Build(); @@ -2117,7 +2117,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec2_With_F16) { Enable(builtin::Extension::kF16); auto* cast = vec2(2_h); - auto* g = GlobalVar("g", ty.vec2(), type::AddressSpace::kPrivate, cast); + auto* g = GlobalVar("g", ty.vec2(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = Build(); @@ -2181,7 +2181,7 @@ OpReturn TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec2_F32_With_Vec2) { auto* cast = vec2(vec2(2_f, 2_f)); - GlobalVar("a", ty.vec2(), type::AddressSpace::kPrivate, cast); + GlobalVar("a", ty.vec2(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = SanitizeAndBuild(); ASSERT_TRUE(b.Build()); @@ -2203,7 +2203,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec2_F16_With_Vec2) { Enable(builtin::Extension::kF16); auto* cast = vec2(vec2(2_h, 2_h)); - GlobalVar("a", ty.vec2(), type::AddressSpace::kPrivate, cast); + GlobalVar("a", ty.vec2(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = SanitizeAndBuild(); ASSERT_TRUE(b.Build()); @@ -2271,7 +2271,7 @@ OpReturn TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec3_F32_With_Vec3) { auto* cast = vec3(vec3(2_f, 2_f, 2_f)); - GlobalVar("a", ty.vec3(), type::AddressSpace::kPrivate, cast); + GlobalVar("a", ty.vec3(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = SanitizeAndBuild(); ASSERT_TRUE(b.Build()); @@ -2293,7 +2293,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec3_F16_With_Vec3) { Enable(builtin::Extension::kF16); auto* cast = vec3(vec3(2_h, 2_h, 2_h)); - GlobalVar("a", ty.vec3(), type::AddressSpace::kPrivate, cast); + GlobalVar("a", ty.vec3(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = SanitizeAndBuild(); ASSERT_TRUE(b.Build()); @@ -2361,7 +2361,7 @@ OpReturn TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_F32_With_Vec4) { auto* cast = vec4(vec4(2_f, 2_f, 2_f, 2_f)); - GlobalVar("a", ty.vec4(), type::AddressSpace::kPrivate, cast); + GlobalVar("a", ty.vec4(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = SanitizeAndBuild(); ASSERT_TRUE(b.Build()); @@ -2383,7 +2383,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_F16_With_Vec4) { Enable(builtin::Extension::kF16); auto* cast = vec4(vec4(2_h, 2_h, 2_h, 2_h)); - GlobalVar("a", ty.vec4(), type::AddressSpace::kPrivate, cast); + GlobalVar("a", ty.vec4(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = SanitizeAndBuild(); ASSERT_TRUE(b.Build()); @@ -2451,7 +2451,7 @@ OpReturn TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec3_With_F32) { auto* cast = vec3(2_f); - auto* g = GlobalVar("g", ty.vec3(), type::AddressSpace::kPrivate, cast); + auto* g = GlobalVar("g", ty.vec3(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = Build(); @@ -2469,7 +2469,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec3_With_F16) { Enable(builtin::Extension::kF16); auto* cast = vec3(2_h); - auto* g = GlobalVar("g", ty.vec3(), type::AddressSpace::kPrivate, cast); + auto* g = GlobalVar("g", ty.vec3(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = Build(); @@ -2533,7 +2533,7 @@ OpReturn TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec3_With_F32_Vec2) { auto* cast = vec3(2_f, vec2(2_f, 2_f)); - auto* g = GlobalVar("g", ty.vec3(), type::AddressSpace::kPrivate, cast); + auto* g = GlobalVar("g", ty.vec3(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = Build(); @@ -2551,7 +2551,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec3_With_F16_Vec2) { Enable(builtin::Extension::kF16); auto* cast = vec3(2_h, vec2(2_h, 2_h)); - auto* g = GlobalVar("g", ty.vec3(), type::AddressSpace::kPrivate, cast); + auto* g = GlobalVar("g", ty.vec3(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = Build(); @@ -2615,7 +2615,7 @@ OpReturn TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec3_With_Vec2_F32) { auto* cast = vec3(vec2(2_f, 2_f), 2_f); - auto* g = GlobalVar("g", ty.vec3(), type::AddressSpace::kPrivate, cast); + auto* g = GlobalVar("g", ty.vec3(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = Build(); @@ -2633,7 +2633,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec3_With_Vec2_F16) { Enable(builtin::Extension::kF16); auto* cast = vec3(vec2(2_h, 2_h), 2_h); - auto* g = GlobalVar("g", ty.vec3(), type::AddressSpace::kPrivate, cast); + auto* g = GlobalVar("g", ty.vec3(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = Build(); @@ -2697,7 +2697,7 @@ OpReturn TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_F32) { auto* cast = vec4(2_f); - auto* g = GlobalVar("g", ty.vec4(), type::AddressSpace::kPrivate, cast); + auto* g = GlobalVar("g", ty.vec4(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = Build(); @@ -2715,7 +2715,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_F16) { Enable(builtin::Extension::kF16); auto* cast = vec4(2_h); - auto* g = GlobalVar("g", ty.vec4(), type::AddressSpace::kPrivate, cast); + auto* g = GlobalVar("g", ty.vec4(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = Build(); @@ -2779,7 +2779,7 @@ OpReturn TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_F32_F32_Vec2) { auto* cast = vec4(2_f, 2_f, vec2(2_f, 2_f)); - auto* g = GlobalVar("g", ty.vec4(), type::AddressSpace::kPrivate, cast); + auto* g = GlobalVar("g", ty.vec4(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = Build(); @@ -2797,7 +2797,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_F16_F16_Vec2) { Enable(builtin::Extension::kF16); auto* cast = vec4(2_h, 2_h, vec2(2_h, 2_h)); - auto* g = GlobalVar("g", ty.vec4(), type::AddressSpace::kPrivate, cast); + auto* g = GlobalVar("g", ty.vec4(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = Build(); @@ -2861,7 +2861,7 @@ OpReturn TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_F32_Vec2_F32) { auto* cast = vec4(2_f, vec2(2_f, 2_f), 2_f); - auto* g = GlobalVar("g", ty.vec4(), type::AddressSpace::kPrivate, cast); + auto* g = GlobalVar("g", ty.vec4(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = Build(); @@ -2879,7 +2879,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_F16_Vec2_F16) { Enable(builtin::Extension::kF16); auto* cast = vec4(2_h, vec2(2_h, 2_h), 2_h); - auto* g = GlobalVar("g", ty.vec4(), type::AddressSpace::kPrivate, cast); + auto* g = GlobalVar("g", ty.vec4(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = Build(); @@ -2943,7 +2943,7 @@ OpReturn TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_Vec2_F32_F32) { auto* cast = vec4(vec2(2_f, 2_f), 2_f, 2_f); - auto* g = GlobalVar("g", ty.vec4(), type::AddressSpace::kPrivate, cast); + auto* g = GlobalVar("g", ty.vec4(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = Build(); @@ -2961,7 +2961,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_Vec2_F16_F16) { Enable(builtin::Extension::kF16); auto* cast = vec4(vec2(2_h, 2_h), 2_h, 2_h); - auto* g = GlobalVar("g", ty.vec4(), type::AddressSpace::kPrivate, cast); + auto* g = GlobalVar("g", ty.vec4(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = Build(); @@ -3025,7 +3025,7 @@ OpReturn TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_F32_With_Vec2_Vec2) { auto* cast = vec4(vec2(2_f, 2_f), vec2(2_f, 2_f)); - auto* g = GlobalVar("g", ty.vec4(), type::AddressSpace::kPrivate, cast); + auto* g = GlobalVar("g", ty.vec4(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = Build(); @@ -3043,7 +3043,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_F16_With_Vec2_Vec2) { Enable(builtin::Extension::kF16); auto* cast = vec4(vec2(2_h, 2_h), vec2(2_h, 2_h)); - auto* g = GlobalVar("g", ty.vec4(), type::AddressSpace::kPrivate, cast); + auto* g = GlobalVar("g", ty.vec4(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = Build(); @@ -3082,7 +3082,7 @@ OpReturn TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_F32_Vec3) { auto* cast = vec4(2_f, vec3(2_f, 2_f, 2_f)); - auto* g = GlobalVar("g", ty.vec4(), type::AddressSpace::kPrivate, cast); + auto* g = GlobalVar("g", ty.vec4(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = Build(); @@ -3100,7 +3100,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_F16_Vec3) { Enable(builtin::Extension::kF16); auto* cast = vec4(2_h, vec3(2_h, 2_h, 2_h)); - auto* g = GlobalVar("g", ty.vec4(), type::AddressSpace::kPrivate, cast); + auto* g = GlobalVar("g", ty.vec4(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = Build(); @@ -3164,7 +3164,7 @@ OpReturn TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_Vec3_F32) { auto* cast = vec4(vec3(2_f, 2_f, 2_f), 2_f); - auto* g = GlobalVar("g", ty.vec4(), type::AddressSpace::kPrivate, cast); + auto* g = GlobalVar("g", ty.vec4(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = Build(); @@ -3182,7 +3182,7 @@ TEST_F(SpvBuilderInitializerTest, Type_GlobalVar_Vec4_With_Vec3_F16) { Enable(builtin::Extension::kF16); auto* cast = vec4(vec3(2_h, 2_h, 2_h), 2_h); - auto* g = GlobalVar("g", ty.vec4(), type::AddressSpace::kPrivate, cast); + auto* g = GlobalVar("g", ty.vec4(), builtin::AddressSpace::kPrivate, cast); spirv::Builder& b = Build(); @@ -4204,7 +4204,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Convert_F32_To_F16) { } TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_U32_to_I32) { - auto* var = GlobalVar("i", ty.vec3(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("i", ty.vec3(), builtin::AddressSpace::kPrivate); auto* cast = vec3("i"); WrapInFunction(cast); @@ -4230,7 +4230,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_U32_to_I32) { } TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_F32_to_I32) { - auto* var = GlobalVar("i", ty.vec3(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("i", ty.vec3(), builtin::AddressSpace::kPrivate); auto* cast = vec3("i"); WrapInFunction(cast); @@ -4258,7 +4258,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_F32_to_I32) { TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_F16_to_I32) { Enable(builtin::Extension::kF16); - auto* var = GlobalVar("i", ty.vec3(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("i", ty.vec3(), builtin::AddressSpace::kPrivate); auto* cast = vec3("i"); WrapInFunction(cast); @@ -4284,7 +4284,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_F16_to_I32) { } TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_I32_to_U32) { - auto* var = GlobalVar("i", ty.vec3(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("i", ty.vec3(), builtin::AddressSpace::kPrivate); auto* cast = vec3("i"); WrapInFunction(cast); @@ -4310,7 +4310,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_I32_to_U32) { } TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_F32_to_U32) { - auto* var = GlobalVar("i", ty.vec3(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("i", ty.vec3(), builtin::AddressSpace::kPrivate); auto* cast = vec3("i"); WrapInFunction(cast); @@ -4338,7 +4338,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_F32_to_U32) { TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_F16_to_U32) { Enable(builtin::Extension::kF16); - auto* var = GlobalVar("i", ty.vec3(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("i", ty.vec3(), builtin::AddressSpace::kPrivate); auto* cast = vec3("i"); WrapInFunction(cast); @@ -4364,7 +4364,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_F16_to_U32) { } TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_I32_to_F32) { - auto* var = GlobalVar("i", ty.vec3(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("i", ty.vec3(), builtin::AddressSpace::kPrivate); auto* cast = vec3("i"); WrapInFunction(cast); @@ -4390,7 +4390,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_I32_to_F32) { } TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_U32_to_F32) { - auto* var = GlobalVar("i", ty.vec3(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("i", ty.vec3(), builtin::AddressSpace::kPrivate); auto* cast = vec3("i"); WrapInFunction(cast); @@ -4418,7 +4418,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_U32_to_F32) { TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_F16_to_F32) { Enable(builtin::Extension::kF16); - auto* var = GlobalVar("i", ty.vec3(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("i", ty.vec3(), builtin::AddressSpace::kPrivate); auto* cast = vec3("i"); WrapInFunction(cast); @@ -4446,7 +4446,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_F16_to_F32) { TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_I32_to_F16) { Enable(builtin::Extension::kF16); - auto* var = GlobalVar("i", ty.vec3(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("i", ty.vec3(), builtin::AddressSpace::kPrivate); auto* cast = vec3("i"); WrapInFunction(cast); @@ -4474,7 +4474,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_I32_to_F16) { TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_U32_to_F16) { Enable(builtin::Extension::kF16); - auto* var = GlobalVar("i", ty.vec3(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("i", ty.vec3(), builtin::AddressSpace::kPrivate); auto* cast = vec3("i"); WrapInFunction(cast); @@ -4502,7 +4502,7 @@ TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_U32_to_F16) { TEST_F(SpvBuilderInitializerTest, Type_Convert_Vectors_F32_to_F16) { Enable(builtin::Extension::kF16); - auto* var = GlobalVar("i", ty.vec3(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("i", ty.vec3(), builtin::AddressSpace::kPrivate); auto* cast = vec3("i"); WrapInFunction(cast); @@ -4590,9 +4590,9 @@ TEST_F(SpvBuilderInitializerTest, IsInitializerConst_VectorWithAllConstInitializ TEST_F(SpvBuilderInitializerTest, IsInitializerConst_Vector_WithIdent) { // vec3(a, b, c) -> false - GlobalVar("a", ty.f32(), type::AddressSpace::kPrivate); - GlobalVar("b", ty.f32(), type::AddressSpace::kPrivate); - GlobalVar("c", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("a", ty.f32(), builtin::AddressSpace::kPrivate); + GlobalVar("b", ty.f32(), builtin::AddressSpace::kPrivate); + GlobalVar("c", ty.f32(), builtin::AddressSpace::kPrivate); auto* t = vec3("a", "b", "c"); WrapInFunction(t); @@ -4662,8 +4662,8 @@ TEST_F(SpvBuilderInitializerTest, IsInitializerConst_Struct_WithIdentSubExpressi Member("b", ty.vec3()), }); - GlobalVar("a", ty.f32(), type::AddressSpace::kPrivate); - GlobalVar("b", ty.vec3(), type::AddressSpace::kPrivate); + GlobalVar("a", ty.f32(), builtin::AddressSpace::kPrivate); + GlobalVar("b", ty.vec3(), builtin::AddressSpace::kPrivate); auto* t = Call(ty.Of(s), "a", "b"); WrapInFunction(t); diff --git a/src/tint/writer/spirv/builder_loop_test.cc b/src/tint/writer/spirv/builder_loop_test.cc index ef8dfa8715..5fc15b8b4d 100644 --- a/src/tint/writer/spirv/builder_loop_test.cc +++ b/src/tint/writer/spirv/builder_loop_test.cc @@ -54,7 +54,7 @@ TEST_F(BuilderTest, Loop_WithoutContinuing) { // break; // } - auto* var = GlobalVar("v", ty.i32(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("v", ty.i32(), builtin::AddressSpace::kPrivate); auto* body = Block(Assign("v", 2_i), // Break()); @@ -96,7 +96,7 @@ TEST_F(BuilderTest, Loop_WithContinuing) { // } // } - auto* var = GlobalVar("v", ty.i32(), type::AddressSpace::kPrivate); + auto* var = GlobalVar("v", ty.i32(), builtin::AddressSpace::kPrivate); auto* body = Block(Assign("v", 2_i), // Break()); auto* continuing = Block(Assign("v", 3_i)); diff --git a/src/tint/writer/spirv/builder_switch_test.cc b/src/tint/writer/spirv/builder_switch_test.cc index a04a194906..7e0bd18287 100644 --- a/src/tint/writer/spirv/builder_switch_test.cc +++ b/src/tint/writer/spirv/builder_switch_test.cc @@ -56,8 +56,8 @@ TEST_F(BuilderTest, Switch_WithCase) { // default: {} // } - auto* v = GlobalVar("v", ty.i32(), type::AddressSpace::kPrivate); - auto* a = GlobalVar("a", ty.i32(), type::AddressSpace::kPrivate); + auto* v = GlobalVar("v", ty.i32(), builtin::AddressSpace::kPrivate); + auto* a = GlobalVar("a", ty.i32(), builtin::AddressSpace::kPrivate); auto* func = Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -113,8 +113,8 @@ TEST_F(BuilderTest, Switch_WithCase_Unsigned) { // default: {} // } - auto* v = GlobalVar("v", ty.i32(), type::AddressSpace::kPrivate); - auto* a = GlobalVar("a", ty.u32(), type::AddressSpace::kPrivate); + auto* v = GlobalVar("v", ty.i32(), builtin::AddressSpace::kPrivate); + auto* a = GlobalVar("a", ty.u32(), builtin::AddressSpace::kPrivate); auto* func = Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -170,8 +170,8 @@ TEST_F(BuilderTest, Switch_WithDefault) { // v = 1i; // } - auto* v = GlobalVar("v", ty.i32(), type::AddressSpace::kPrivate); - auto* a = GlobalVar("a", ty.i32(), type::AddressSpace::kPrivate); + auto* v = GlobalVar("v", ty.i32(), builtin::AddressSpace::kPrivate); + auto* a = GlobalVar("a", ty.i32(), builtin::AddressSpace::kPrivate); auto* func = Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -220,8 +220,8 @@ TEST_F(BuilderTest, Switch_WithCaseAndDefault) { // v = 3i; // } - auto* v = GlobalVar("v", ty.i32(), type::AddressSpace::kPrivate); - auto* a = GlobalVar("a", ty.i32(), type::AddressSpace::kPrivate); + auto* v = GlobalVar("v", ty.i32(), builtin::AddressSpace::kPrivate); + auto* a = GlobalVar("a", ty.i32(), builtin::AddressSpace::kPrivate); auto* func = Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -280,8 +280,8 @@ TEST_F(BuilderTest, Switch_WithCaseAndMixedDefault) { // v = 2i; // } - auto* v = GlobalVar("v", ty.i32(), type::AddressSpace::kPrivate); - auto* a = GlobalVar("a", ty.i32(), type::AddressSpace::kPrivate); + auto* v = GlobalVar("v", ty.i32(), builtin::AddressSpace::kPrivate); + auto* a = GlobalVar("a", ty.i32(), builtin::AddressSpace::kPrivate); auto* func = Func("a_func", utils::Empty, ty.void_(), utils::Vector{Switch(Expr("a"), // @@ -337,8 +337,8 @@ TEST_F(BuilderTest, Switch_WithNestedBreak) { // default: {} // } - auto* v = GlobalVar("v", ty.i32(), type::AddressSpace::kPrivate); - auto* a = GlobalVar("a", ty.i32(), type::AddressSpace::kPrivate); + auto* v = GlobalVar("v", ty.i32(), builtin::AddressSpace::kPrivate); + auto* a = GlobalVar("a", ty.i32(), builtin::AddressSpace::kPrivate); auto* func = Func("a_func", utils::Empty, ty.void_(), utils::Vector{ diff --git a/src/tint/writer/spirv/builder_type_test.cc b/src/tint/writer/spirv/builder_type_test.cc index a6c7b2b53e..1b3e4714ab 100644 --- a/src/tint/writer/spirv/builder_type_test.cc +++ b/src/tint/writer/spirv/builder_type_test.cc @@ -29,8 +29,8 @@ using BuilderTest_Type = TestHelper; TEST_F(BuilderTest_Type, GenerateRuntimeArray) { auto ary = ty.array(ty.i32()); auto* str = Structure("S", utils::Vector{Member("x", ary)}); - GlobalVar("a", ty.Of(str), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), - Group(0_a)); + GlobalVar("a", ty.Of(str), builtin::AddressSpace::kStorage, builtin::Access::kRead, + Binding(0_a), Group(0_a)); ast::Type type = str->members[0]->type; spirv::Builder& b = Build(); @@ -47,8 +47,8 @@ TEST_F(BuilderTest_Type, GenerateRuntimeArray) { TEST_F(BuilderTest_Type, ReturnsGeneratedRuntimeArray) { auto ary = ty.array(ty.i32()); auto* str = Structure("S", utils::Vector{Member("x", ary)}); - GlobalVar("a", ty.Of(str), type::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), - Group(0_a)); + GlobalVar("a", ty.Of(str), builtin::AddressSpace::kStorage, builtin::Access::kRead, + Binding(0_a), Group(0_a)); ast::Type type = str->members[0]->type; spirv::Builder& b = Build(); @@ -64,7 +64,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedRuntimeArray) { TEST_F(BuilderTest_Type, GenerateArray) { auto ary = ty.array(); - ast::Type type = GlobalVar("a", ary, type::AddressSpace::kPrivate)->type; + ast::Type type = GlobalVar("a", ary, builtin::AddressSpace::kPrivate)->type; spirv::Builder& b = Build(); @@ -81,7 +81,7 @@ TEST_F(BuilderTest_Type, GenerateArray) { TEST_F(BuilderTest_Type, GenerateArray_WithStride) { auto ary = ty.array(utils::Vector{Stride(16)}); - ast::Type ty = GlobalVar("a", ary, type::AddressSpace::kPrivate)->type; + ast::Type ty = GlobalVar("a", ary, builtin::AddressSpace::kPrivate)->type; spirv::Builder& b = Build(); @@ -101,7 +101,7 @@ TEST_F(BuilderTest_Type, GenerateArray_WithStride) { TEST_F(BuilderTest_Type, ReturnsGeneratedArray) { auto ary = ty.array(); - ast::Type ty = GlobalVar("a", ary, type::AddressSpace::kPrivate)->type; + ast::Type ty = GlobalVar("a", ary, builtin::AddressSpace::kPrivate)->type; spirv::Builder& b = Build(); @@ -296,7 +296,8 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedF16Matrix) { TEST_F(BuilderTest_Type, GeneratePtr) { auto* i32 = create(); - auto* ptr = create(i32, type::AddressSpace::kOut, builtin::Access::kReadWrite); + auto* ptr = + create(i32, builtin::AddressSpace::kOut, builtin::Access::kReadWrite); spirv::Builder& b = Build(); @@ -311,7 +312,8 @@ TEST_F(BuilderTest_Type, GeneratePtr) { TEST_F(BuilderTest_Type, ReturnsGeneratedPtr) { auto* i32 = create(); - auto* ptr = create(i32, type::AddressSpace::kOut, builtin::Access::kReadWrite); + auto* ptr = + create(i32, builtin::AddressSpace::kOut, builtin::Access::kReadWrite); spirv::Builder& b = Build(); @@ -605,7 +607,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedVoid) { } struct PtrData { - type::AddressSpace ast_class; + builtin::AddressSpace ast_class; SpvStorageClass result; }; inline std::ostream& operator<<(std::ostream& out, PtrData data) { @@ -623,15 +625,15 @@ TEST_P(PtrDataTest, ConvertAddressSpace) { INSTANTIATE_TEST_SUITE_P( BuilderTest_Type, PtrDataTest, - testing::Values(PtrData{type::AddressSpace::kUndefined, SpvStorageClassMax}, - PtrData{type::AddressSpace::kIn, SpvStorageClassInput}, - PtrData{type::AddressSpace::kOut, SpvStorageClassOutput}, - PtrData{type::AddressSpace::kUniform, SpvStorageClassUniform}, - PtrData{type::AddressSpace::kWorkgroup, SpvStorageClassWorkgroup}, - PtrData{type::AddressSpace::kHandle, SpvStorageClassUniformConstant}, - PtrData{type::AddressSpace::kStorage, SpvStorageClassStorageBuffer}, - PtrData{type::AddressSpace::kPrivate, SpvStorageClassPrivate}, - PtrData{type::AddressSpace::kFunction, SpvStorageClassFunction})); + testing::Values(PtrData{builtin::AddressSpace::kUndefined, SpvStorageClassMax}, + PtrData{builtin::AddressSpace::kIn, SpvStorageClassInput}, + PtrData{builtin::AddressSpace::kOut, SpvStorageClassOutput}, + PtrData{builtin::AddressSpace::kUniform, SpvStorageClassUniform}, + PtrData{builtin::AddressSpace::kWorkgroup, SpvStorageClassWorkgroup}, + PtrData{builtin::AddressSpace::kHandle, SpvStorageClassUniformConstant}, + PtrData{builtin::AddressSpace::kStorage, SpvStorageClassStorageBuffer}, + PtrData{builtin::AddressSpace::kPrivate, SpvStorageClassPrivate}, + PtrData{builtin::AddressSpace::kFunction, SpvStorageClassFunction})); TEST_F(BuilderTest_Type, DepthTexture_Generate_2d) { auto* two_d = create(type::TextureDimension::k2d); diff --git a/src/tint/writer/wgsl/generator_impl_array_accessor_test.cc b/src/tint/writer/wgsl/generator_impl_array_accessor_test.cc index ed05a2d644..31e7e6b354 100644 --- a/src/tint/writer/wgsl/generator_impl_array_accessor_test.cc +++ b/src/tint/writer/wgsl/generator_impl_array_accessor_test.cc @@ -22,7 +22,7 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, IndexAccessor) { - GlobalVar("ary", ty.array(), type::AddressSpace::kPrivate); + GlobalVar("ary", ty.array(), builtin::AddressSpace::kPrivate); auto* expr = IndexAccessor("ary", 5_i); WrapInFunction(expr); @@ -34,7 +34,7 @@ TEST_F(WgslGeneratorImplTest, IndexAccessor) { } TEST_F(WgslGeneratorImplTest, IndexAccessor_OfDref) { - GlobalVar("ary", ty.array(), type::AddressSpace::kPrivate); + GlobalVar("ary", ty.array(), builtin::AddressSpace::kPrivate); auto* p = Let("p", AddressOf("ary")); auto* expr = IndexAccessor(Deref("p"), 5_i); diff --git a/src/tint/writer/wgsl/generator_impl_assign_test.cc b/src/tint/writer/wgsl/generator_impl_assign_test.cc index 3a6dd1aa72..c802cb1a6c 100644 --- a/src/tint/writer/wgsl/generator_impl_assign_test.cc +++ b/src/tint/writer/wgsl/generator_impl_assign_test.cc @@ -20,8 +20,8 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, Emit_Assign) { - auto* lhs = GlobalVar("lhs", ty.i32(), type::AddressSpace::kPrivate); - auto* rhs = GlobalVar("rhs", ty.i32(), type::AddressSpace::kPrivate); + auto* lhs = GlobalVar("lhs", ty.i32(), builtin::AddressSpace::kPrivate); + auto* rhs = GlobalVar("rhs", ty.i32(), builtin::AddressSpace::kPrivate); auto* assign = Assign(lhs, rhs); WrapInFunction(assign); diff --git a/src/tint/writer/wgsl/generator_impl_binary_test.cc b/src/tint/writer/wgsl/generator_impl_binary_test.cc index 2770e5ce16..d86b1c4032 100644 --- a/src/tint/writer/wgsl/generator_impl_binary_test.cc +++ b/src/tint/writer/wgsl/generator_impl_binary_test.cc @@ -37,8 +37,8 @@ TEST_P(WgslBinaryTest, Emit) { } }; - GlobalVar("left", op_ty(), type::AddressSpace::kPrivate); - GlobalVar("right", op_ty(), type::AddressSpace::kPrivate); + GlobalVar("left", op_ty(), builtin::AddressSpace::kPrivate); + GlobalVar("right", op_ty(), builtin::AddressSpace::kPrivate); auto* left = Expr("left"); auto* right = Expr("right"); diff --git a/src/tint/writer/wgsl/generator_impl_call_test.cc b/src/tint/writer/wgsl/generator_impl_call_test.cc index 39a287c59f..4492628c56 100644 --- a/src/tint/writer/wgsl/generator_impl_call_test.cc +++ b/src/tint/writer/wgsl/generator_impl_call_test.cc @@ -48,8 +48,8 @@ TEST_F(WgslGeneratorImplTest, EmitExpression_Call_WithParams) { utils::Vector{ Return(1.23_f), }); - GlobalVar("param1", ty.f32(), type::AddressSpace::kPrivate); - GlobalVar("param2", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("param1", ty.f32(), builtin::AddressSpace::kPrivate); + GlobalVar("param2", ty.f32(), builtin::AddressSpace::kPrivate); auto* call = Call("my_func", "param1", "param2"); WrapInFunction(call); @@ -68,8 +68,8 @@ TEST_F(WgslGeneratorImplTest, EmitStatement_Call) { Param(Sym(), ty.f32()), }, ty.void_(), utils::Empty, utils::Empty); - GlobalVar("param1", ty.f32(), type::AddressSpace::kPrivate); - GlobalVar("param2", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("param1", ty.f32(), builtin::AddressSpace::kPrivate); + GlobalVar("param2", ty.f32(), builtin::AddressSpace::kPrivate); auto* call = Call("my_func", "param1", "param2"); auto* stmt = CallStmt(call); diff --git a/src/tint/writer/wgsl/generator_impl_function_test.cc b/src/tint/writer/wgsl/generator_impl_function_test.cc index e29f0f4713..53131cdf40 100644 --- a/src/tint/writer/wgsl/generator_impl_function_test.cc +++ b/src/tint/writer/wgsl/generator_impl_function_test.cc @@ -179,7 +179,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Function_Multiple_EntryPoint_With_Same_Module Member("d", ty.f32()), }); - GlobalVar("data", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + GlobalVar("data", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, Binding(0_a), Group(0_a)); { diff --git a/src/tint/writer/wgsl/generator_impl_global_decl_test.cc b/src/tint/writer/wgsl/generator_impl_global_decl_test.cc index 5654ebecb4..cef2c7452b 100644 --- a/src/tint/writer/wgsl/generator_impl_global_decl_test.cc +++ b/src/tint/writer/wgsl/generator_impl_global_decl_test.cc @@ -29,7 +29,7 @@ TEST_F(WgslGeneratorImplTest, Emit_GlobalDeclAfterFunction) { auto* func_var = Var("a", ty.f32()); WrapInFunction(func_var); - GlobalVar("a", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("a", ty.f32(), builtin::AddressSpace::kPrivate); GeneratorImpl& gen = Build(); @@ -46,7 +46,7 @@ TEST_F(WgslGeneratorImplTest, Emit_GlobalDeclAfterFunction) { } TEST_F(WgslGeneratorImplTest, Emit_GlobalsInterleaved) { - GlobalVar("a0", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("a0", ty.f32(), builtin::AddressSpace::kPrivate); auto* s0 = Structure("S0", utils::Vector{ Member("a", ty.i32()), @@ -58,7 +58,7 @@ TEST_F(WgslGeneratorImplTest, Emit_GlobalsInterleaved) { }, utils::Empty); - GlobalVar("a1", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("a1", ty.f32(), builtin::AddressSpace::kPrivate); auto* s1 = Structure("S1", utils::Vector{ Member("a", ty.i32()), diff --git a/src/tint/writer/wgsl/generator_impl_identifier_test.cc b/src/tint/writer/wgsl/generator_impl_identifier_test.cc index e0b167f663..7b60b6305b 100644 --- a/src/tint/writer/wgsl/generator_impl_identifier_test.cc +++ b/src/tint/writer/wgsl/generator_impl_identifier_test.cc @@ -20,7 +20,7 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, EmitIdentifierExpression_Single) { - GlobalVar("glsl", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("glsl", ty.f32(), builtin::AddressSpace::kPrivate); auto* i = Expr("glsl"); WrapInFunction(i); diff --git a/src/tint/writer/wgsl/generator_impl_if_test.cc b/src/tint/writer/wgsl/generator_impl_if_test.cc index 0831f8909a..8b9d443944 100644 --- a/src/tint/writer/wgsl/generator_impl_if_test.cc +++ b/src/tint/writer/wgsl/generator_impl_if_test.cc @@ -20,7 +20,7 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, Emit_If) { - GlobalVar("cond", ty.bool_(), type::AddressSpace::kPrivate); + GlobalVar("cond", ty.bool_(), builtin::AddressSpace::kPrivate); auto* cond = Expr("cond"); auto* body = Block(Return()); @@ -39,8 +39,8 @@ TEST_F(WgslGeneratorImplTest, Emit_If) { } TEST_F(WgslGeneratorImplTest, Emit_IfWithElseIf) { - GlobalVar("cond", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("else_cond", ty.bool_(), type::AddressSpace::kPrivate); + GlobalVar("cond", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("else_cond", ty.bool_(), builtin::AddressSpace::kPrivate); auto* else_cond = Expr("else_cond"); auto* else_body = Block(Return()); @@ -64,7 +64,7 @@ TEST_F(WgslGeneratorImplTest, Emit_IfWithElseIf) { } TEST_F(WgslGeneratorImplTest, Emit_IfWithElse) { - GlobalVar("cond", ty.bool_(), type::AddressSpace::kPrivate); + GlobalVar("cond", ty.bool_(), builtin::AddressSpace::kPrivate); auto* else_body = Block(Return()); @@ -87,8 +87,8 @@ TEST_F(WgslGeneratorImplTest, Emit_IfWithElse) { } TEST_F(WgslGeneratorImplTest, Emit_IfWithMultiple) { - GlobalVar("cond", ty.bool_(), type::AddressSpace::kPrivate); - GlobalVar("else_cond", ty.bool_(), type::AddressSpace::kPrivate); + GlobalVar("cond", ty.bool_(), builtin::AddressSpace::kPrivate); + GlobalVar("else_cond", ty.bool_(), builtin::AddressSpace::kPrivate); auto* else_cond = Expr("else_cond"); diff --git a/src/tint/writer/wgsl/generator_impl_loop_test.cc b/src/tint/writer/wgsl/generator_impl_loop_test.cc index 46dbbdb7bf..62910fc818 100644 --- a/src/tint/writer/wgsl/generator_impl_loop_test.cc +++ b/src/tint/writer/wgsl/generator_impl_loop_test.cc @@ -96,7 +96,7 @@ TEST_F(WgslGeneratorImplTest, Emit_ForLoopWithMultiStmtInit) { // for({ignore(1i); ignore(2i);}; ; ) { // return; // } - GlobalVar("a", ty.atomic(), type::AddressSpace::kWorkgroup); + GlobalVar("a", ty.atomic(), builtin::AddressSpace::kWorkgroup); auto* multi_stmt = Block(Ignore(1_i), Ignore(2_i)); auto* f = For(multi_stmt, nullptr, nullptr, Block(Return())); WrapInFunction(f); @@ -160,7 +160,7 @@ TEST_F(WgslGeneratorImplTest, Emit_ForLoopWithMultiStmtCont) { // return; // } - GlobalVar("a", ty.atomic(), type::AddressSpace::kWorkgroup); + GlobalVar("a", ty.atomic(), builtin::AddressSpace::kWorkgroup); auto* multi_stmt = Block(Ignore(1_i), Ignore(2_i)); auto* f = For(nullptr, nullptr, multi_stmt, Block(Return())); WrapInFunction(f); @@ -203,7 +203,7 @@ TEST_F(WgslGeneratorImplTest, Emit_ForLoopWithMultiStmtInitCondCont) { // for({ ignore(1i); ignore(2i); }; true; { ignore(3i); ignore(4i); }) { // return; // } - GlobalVar("a", ty.atomic(), type::AddressSpace::kWorkgroup); + GlobalVar("a", ty.atomic(), builtin::AddressSpace::kWorkgroup); auto* multi_stmt_a = Block(Ignore(1_i), Ignore(2_i)); auto* multi_stmt_b = Block(Ignore(3_i), Ignore(4_i)); auto* f = For(multi_stmt_a, Expr(true), multi_stmt_b, Block(Return())); diff --git a/src/tint/writer/wgsl/generator_impl_member_accessor_test.cc b/src/tint/writer/wgsl/generator_impl_member_accessor_test.cc index 5f7ebb584a..208be35e44 100644 --- a/src/tint/writer/wgsl/generator_impl_member_accessor_test.cc +++ b/src/tint/writer/wgsl/generator_impl_member_accessor_test.cc @@ -21,7 +21,7 @@ using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, EmitExpression_MemberAccessor) { auto* s = Structure("Data", utils::Vector{Member("mem", ty.f32())}); - GlobalVar("str", ty.Of(s), type::AddressSpace::kPrivate); + GlobalVar("str", ty.Of(s), builtin::AddressSpace::kPrivate); auto* expr = MemberAccessor("str", "mem"); WrapInFunction(expr); @@ -35,7 +35,7 @@ TEST_F(WgslGeneratorImplTest, EmitExpression_MemberAccessor) { TEST_F(WgslGeneratorImplTest, EmitExpression_MemberAccessor_OfDref) { auto* s = Structure("Data", utils::Vector{Member("mem", ty.f32())}); - GlobalVar("str", ty.Of(s), type::AddressSpace::kPrivate); + GlobalVar("str", ty.Of(s), builtin::AddressSpace::kPrivate); auto* p = Let("p", AddressOf("str")); auto* expr = MemberAccessor(Deref("p"), "mem"); diff --git a/src/tint/writer/wgsl/generator_impl_switch_test.cc b/src/tint/writer/wgsl/generator_impl_switch_test.cc index 24dbae16c4..d16808a9a9 100644 --- a/src/tint/writer/wgsl/generator_impl_switch_test.cc +++ b/src/tint/writer/wgsl/generator_impl_switch_test.cc @@ -22,7 +22,7 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, Emit_Switch) { - GlobalVar("cond", ty.i32(), type::AddressSpace::kPrivate); + GlobalVar("cond", ty.i32(), builtin::AddressSpace::kPrivate); auto* def_body = Block(create()); auto* def = Case(DefaultCaseSelector(), def_body); @@ -56,7 +56,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Switch) { } TEST_F(WgslGeneratorImplTest, Emit_Switch_MixedDefault) { - GlobalVar("cond", ty.i32(), type::AddressSpace::kPrivate); + GlobalVar("cond", ty.i32(), builtin::AddressSpace::kPrivate); auto* def_body = Block(create()); auto* def = Case(utils::Vector{CaseSelector(5_i), DefaultCaseSelector()}, def_body); diff --git a/src/tint/writer/wgsl/generator_impl_type_test.cc b/src/tint/writer/wgsl/generator_impl_type_test.cc index 18fb678d28..455cbbc226 100644 --- a/src/tint/writer/wgsl/generator_impl_type_test.cc +++ b/src/tint/writer/wgsl/generator_impl_type_test.cc @@ -132,7 +132,8 @@ TEST_F(WgslGeneratorImplTest, EmitType_Matrix_F16) { } TEST_F(WgslGeneratorImplTest, EmitType_Pointer) { - auto type = Alias("make_type_reachable", ty.pointer(type::AddressSpace::kWorkgroup))->type; + auto type = + Alias("make_type_reachable", ty.pointer(builtin::AddressSpace::kWorkgroup))->type; GeneratorImpl& gen = Build(); @@ -143,7 +144,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Pointer) { TEST_F(WgslGeneratorImplTest, EmitType_PointerAccessMode) { auto type = Alias("make_type_reachable", - ty.pointer(type::AddressSpace::kStorage, builtin::Access::kReadWrite)) + ty.pointer(builtin::AddressSpace::kStorage, builtin::Access::kReadWrite)) ->type; GeneratorImpl& gen = Build(); diff --git a/src/tint/writer/wgsl/generator_impl_unary_op_test.cc b/src/tint/writer/wgsl/generator_impl_unary_op_test.cc index 544e1e3e87..a9cd10c49c 100644 --- a/src/tint/writer/wgsl/generator_impl_unary_op_test.cc +++ b/src/tint/writer/wgsl/generator_impl_unary_op_test.cc @@ -20,7 +20,7 @@ namespace { using WgslUnaryOpTest = TestHelper; TEST_F(WgslUnaryOpTest, AddressOf) { - GlobalVar("expr", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("expr", ty.f32(), builtin::AddressSpace::kPrivate); auto* op = create(ast::UnaryOp::kAddressOf, Expr("expr")); WrapInFunction(op); @@ -32,7 +32,7 @@ TEST_F(WgslUnaryOpTest, AddressOf) { } TEST_F(WgslUnaryOpTest, Complement) { - GlobalVar("expr", ty.u32(), type::AddressSpace::kPrivate); + GlobalVar("expr", ty.u32(), builtin::AddressSpace::kPrivate); auto* op = create(ast::UnaryOp::kComplement, Expr("expr")); WrapInFunction(op); @@ -44,7 +44,7 @@ TEST_F(WgslUnaryOpTest, Complement) { } TEST_F(WgslUnaryOpTest, Indirection) { - GlobalVar("G", ty.f32(), type::AddressSpace::kPrivate); + GlobalVar("G", ty.f32(), builtin::AddressSpace::kPrivate); auto* p = Let("expr", create(ast::UnaryOp::kAddressOf, Expr("G"))); auto* op = create(ast::UnaryOp::kIndirection, Expr("expr")); WrapInFunction(p, op); @@ -57,7 +57,7 @@ TEST_F(WgslUnaryOpTest, Indirection) { } TEST_F(WgslUnaryOpTest, Not) { - GlobalVar("expr", ty.bool_(), type::AddressSpace::kPrivate); + GlobalVar("expr", ty.bool_(), builtin::AddressSpace::kPrivate); auto* op = create(ast::UnaryOp::kNot, Expr("expr")); WrapInFunction(op); @@ -69,7 +69,7 @@ TEST_F(WgslUnaryOpTest, Not) { } TEST_F(WgslUnaryOpTest, Negation) { - GlobalVar("expr", ty.i32(), type::AddressSpace::kPrivate); + GlobalVar("expr", ty.i32(), builtin::AddressSpace::kPrivate); auto* op = create(ast::UnaryOp::kNegation, Expr("expr")); WrapInFunction(op); diff --git a/src/tint/writer/wgsl/generator_impl_variable_test.cc b/src/tint/writer/wgsl/generator_impl_variable_test.cc index 33ead1d03c..5c9506f985 100644 --- a/src/tint/writer/wgsl/generator_impl_variable_test.cc +++ b/src/tint/writer/wgsl/generator_impl_variable_test.cc @@ -22,7 +22,7 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, EmitVariable) { - auto* v = GlobalVar("a", ty.f32(), type::AddressSpace::kPrivate); + auto* v = GlobalVar("a", ty.f32(), builtin::AddressSpace::kPrivate); GeneratorImpl& gen = Build(); @@ -32,7 +32,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable) { } TEST_F(WgslGeneratorImplTest, EmitVariable_AddressSpace) { - auto* v = GlobalVar("a", ty.f32(), type::AddressSpace::kPrivate); + auto* v = GlobalVar("a", ty.f32(), builtin::AddressSpace::kPrivate); GeneratorImpl& gen = Build(); @@ -43,7 +43,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_AddressSpace) { TEST_F(WgslGeneratorImplTest, EmitVariable_Access_Read) { auto* s = Structure("S", utils::Vector{Member("a", ty.i32())}); - auto* v = GlobalVar("a", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kRead, + auto* v = GlobalVar("a", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kRead, Binding(0_a), Group(0_a)); GeneratorImpl& gen = Build(); @@ -55,7 +55,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Access_Read) { TEST_F(WgslGeneratorImplTest, EmitVariable_Access_ReadWrite) { auto* s = Structure("S", utils::Vector{Member("a", ty.i32())}); - auto* v = GlobalVar("a", ty.Of(s), type::AddressSpace::kStorage, builtin::Access::kReadWrite, + auto* v = GlobalVar("a", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite, Binding(0_a), Group(0_a)); GeneratorImpl& gen = Build(); @@ -76,7 +76,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Decorated) { } TEST_F(WgslGeneratorImplTest, EmitVariable_Initializer) { - auto* v = GlobalVar("a", ty.f32(), type::AddressSpace::kPrivate, Expr(1_f)); + auto* v = GlobalVar("a", ty.f32(), builtin::AddressSpace::kPrivate, Expr(1_f)); GeneratorImpl& gen = Build();