diff --git a/src/tint/BUILD.gn b/src/tint/BUILD.gn index 23566b915b..e148a49824 100644 --- a/src/tint/BUILD.gn +++ b/src/tint/BUILD.gn @@ -415,7 +415,6 @@ libtint_source_set("libtint_core_all_src") { "scope_stack.h", "sem/array.h", "sem/array_count.h", - "sem/atomic.h", "sem/behavior.h", "sem/binding_point.h", "sem/break_if_statement.h", @@ -557,6 +556,7 @@ libtint_source_set("libtint_core_all_src") { "type/abstract_int.h", "type/abstract_numeric.h", "type/array_count.h", + "type/atomic.h", "type/bool.h", "type/depth_multisampled_texture.h", "type/depth_texture.h", @@ -636,8 +636,6 @@ libtint_source_set("libtint_sem_src") { "sem/array.h", "sem/array_count.cc", "sem/array_count.h", - "sem/atomic.cc", - "sem/atomic.h", "sem/behavior.cc", "sem/behavior.h", "sem/binding_point.h", @@ -706,6 +704,8 @@ libtint_source_set("libtint_type_src") { "type/abstract_numeric.h", "type/array_count.cc", "type/array_count.h", + "type/atomic.cc", + "type/atomic.h", "type/bool.cc", "type/bool.h", "type/depth_multisampled_texture.cc", @@ -1204,7 +1204,6 @@ if (tint_build_unittests) { tint_unittests_source_set("tint_unittests_sem_src") { sources = [ "sem/array_test.cc", - "sem/atomic_test.cc", "sem/builtin_test.cc", "sem/expression_test.cc", "sem/struct_test.cc", @@ -1213,6 +1212,7 @@ if (tint_build_unittests) { tint_unittests_source_set("tint_unittests_type_src") { sources = [ + "type/atomic_test.cc", "type/bool_test.cc", "type/depth_multisampled_texture_test.cc", "type/depth_texture_test.cc", diff --git a/src/tint/CMakeLists.txt b/src/tint/CMakeLists.txt index 3d50b99fda..bc279cd864 100644 --- a/src/tint/CMakeLists.txt +++ b/src/tint/CMakeLists.txt @@ -295,8 +295,6 @@ list(APPEND TINT_LIB_SRCS sem/array.h sem/array_count.cc sem/array_count.h - sem/atomic.cc - sem/atomic.h sem/behavior.cc sem/behavior.h sem/binding_point.h @@ -463,6 +461,8 @@ list(APPEND TINT_LIB_SRCS type/abstract_numeric.h type/array_count.cc type/array_count.h + type/atomic.cc + type/atomic.h type/bool.cc type/bool.h type/depth_multisampled_texture.cc @@ -921,7 +921,6 @@ if(TINT_BUILD_TESTS) resolver/variable_validation_test.cc scope_stack_test.cc sem/array_test.cc - sem/atomic.cc sem/builtin_test.cc sem/expression_test.cc sem/struct_test.cc @@ -932,6 +931,7 @@ if(TINT_BUILD_TESTS) text/unicode_test.cc traits_test.cc transform/transform_test.cc + type/atomic.cc type/bool_test.cc type/depth_multisampled_texture_test.cc type/depth_texture_test.cc diff --git a/src/tint/resolver/atomics_test.cc b/src/tint/resolver/atomics_test.cc index ac0de88a0c..a7d4f073ad 100644 --- a/src/tint/resolver/atomics_test.cc +++ b/src/tint/resolver/atomics_test.cc @@ -14,7 +14,7 @@ #include "src/tint/resolver/resolver.h" #include "src/tint/resolver/resolver_test_helper.h" -#include "src/tint/sem/atomic.h" +#include "src/tint/type/atomic.h" #include "src/tint/type/reference.h" #include "gmock/gmock.h" @@ -31,7 +31,7 @@ TEST_F(ResolverAtomicTest, GlobalWorkgroupI32) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_TRUE(TypeOf(g)->Is()); - auto* atomic = TypeOf(g)->UnwrapRef()->As(); + auto* atomic = TypeOf(g)->UnwrapRef()->As(); ASSERT_NE(atomic, nullptr); EXPECT_TRUE(atomic->Type()->Is()); } @@ -41,7 +41,7 @@ TEST_F(ResolverAtomicTest, GlobalWorkgroupU32) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_TRUE(TypeOf(g)->Is()); - auto* atomic = TypeOf(g)->UnwrapRef()->As(); + auto* atomic = TypeOf(g)->UnwrapRef()->As(); ASSERT_NE(atomic, nullptr); EXPECT_TRUE(atomic->Type()->Is()); } @@ -56,7 +56,7 @@ TEST_F(ResolverAtomicTest, GlobalStorageStruct) { auto* str = TypeOf(g)->UnwrapRef()->As(); ASSERT_NE(str, nullptr); ASSERT_EQ(str->Members().Length(), 1u); - auto* atomic = str->Members()[0]->Type()->As(); + auto* atomic = str->Members()[0]->Type()->As(); ASSERT_NE(atomic, nullptr); ASSERT_TRUE(atomic->Type()->Is()); } diff --git a/src/tint/resolver/atomics_validation_test.cc b/src/tint/resolver/atomics_validation_test.cc index afc44c9116..13509350eb 100644 --- a/src/tint/resolver/atomics_validation_test.cc +++ b/src/tint/resolver/atomics_validation_test.cc @@ -14,7 +14,7 @@ #include "src/tint/resolver/resolver.h" #include "src/tint/resolver/resolver_test_helper.h" -#include "src/tint/sem/atomic.h" +#include "src/tint/type/atomic.h" #include "src/tint/type/reference.h" #include "gmock/gmock.h" diff --git a/src/tint/resolver/intrinsic_table.cc b/src/tint/resolver/intrinsic_table.cc index 4ce974f9d0..99ea338749 100644 --- a/src/tint/resolver/intrinsic_table.cc +++ b/src/tint/resolver/intrinsic_table.cc @@ -20,7 +20,6 @@ #include "src/tint/ast/binary_expression.h" #include "src/tint/program_builder.h" -#include "src/tint/sem/atomic.h" #include "src/tint/sem/evaluation_stage.h" #include "src/tint/sem/pipeline_stage_set.h" #include "src/tint/sem/type_conversion.h" @@ -28,6 +27,7 @@ #include "src/tint/type/abstract_float.h" #include "src/tint/type/abstract_int.h" #include "src/tint/type/abstract_numeric.h" +#include "src/tint/type/atomic.h" #include "src/tint/type/depth_multisampled_texture.h" #include "src/tint/type/depth_texture.h" #include "src/tint/type/external_texture.h" @@ -569,15 +569,15 @@ bool match_atomic(MatchState&, const type::Type* ty, const type::Type*& T) { return true; } - if (auto* a = ty->As()) { + if (auto* a = ty->As()) { T = a->Type(); return true; } return false; } -const sem::Atomic* build_atomic(MatchState& state, const type::Type* T) { - return state.builder.create(T); +const type::Atomic* build_atomic(MatchState& state, const type::Type* T) { + return state.builder.create(T); } bool match_sampler(MatchState&, const type::Type* ty) { diff --git a/src/tint/resolver/intrinsic_table_test.cc b/src/tint/resolver/intrinsic_table_test.cc index c24606e320..6e12ed6c02 100644 --- a/src/tint/resolver/intrinsic_table_test.cc +++ b/src/tint/resolver/intrinsic_table_test.cc @@ -19,9 +19,9 @@ #include "gmock/gmock.h" #include "src/tint/program_builder.h" #include "src/tint/resolver/resolver_test_helper.h" -#include "src/tint/sem/atomic.h" #include "src/tint/sem/type_conversion.h" #include "src/tint/sem/type_initializer.h" +#include "src/tint/type/atomic.h" #include "src/tint/type/depth_multisampled_texture.h" #include "src/tint/type/depth_texture.h" #include "src/tint/type/external_texture.h" @@ -229,7 +229,7 @@ TEST_F(IntrinsicTableTest, MismatchBool) { TEST_F(IntrinsicTableTest, MatchPointer) { auto* i32 = create(); - auto* atomicI32 = create(i32); + auto* atomicI32 = create(i32); auto* ptr = create(atomicI32, ast::AddressSpace::kWorkgroup, ast::Access::kReadWrite); auto result = table->Lookup(BuiltinType::kAtomicLoad, utils::Vector{ptr}, @@ -244,7 +244,7 @@ TEST_F(IntrinsicTableTest, MatchPointer) { TEST_F(IntrinsicTableTest, MismatchPointer) { auto* i32 = create(); - auto* atomicI32 = create(i32); + auto* atomicI32 = create(i32); auto result = table->Lookup(BuiltinType::kAtomicLoad, utils::Vector{atomicI32}, sem::EvaluationStage::kConstant, Source{}); ASSERT_EQ(result.sem, nullptr); diff --git a/src/tint/resolver/is_host_shareable_test.cc b/src/tint/resolver/is_host_shareable_test.cc index f4efbe910b..1344379d6c 100644 --- a/src/tint/resolver/is_host_shareable_test.cc +++ b/src/tint/resolver/is_host_shareable_test.cc @@ -16,7 +16,7 @@ #include "gmock/gmock.h" #include "src/tint/resolver/resolver_test_helper.h" -#include "src/tint/sem/atomic.h" +#include "src/tint/type/atomic.h" namespace tint::resolver { namespace { @@ -101,8 +101,8 @@ TEST_F(ResolverIsHostShareable, Pointer) { } TEST_F(ResolverIsHostShareable, Atomic) { - EXPECT_TRUE(r()->IsHostShareable(create(create()))); - EXPECT_TRUE(r()->IsHostShareable(create(create()))); + EXPECT_TRUE(r()->IsHostShareable(create(create()))); + EXPECT_TRUE(r()->IsHostShareable(create(create()))); } TEST_F(ResolverIsHostShareable, ArraySizedOfHostShareable) { diff --git a/src/tint/resolver/is_storeable_test.cc b/src/tint/resolver/is_storeable_test.cc index 793b8b11df..7ed4877954 100644 --- a/src/tint/resolver/is_storeable_test.cc +++ b/src/tint/resolver/is_storeable_test.cc @@ -16,7 +16,7 @@ #include "gmock/gmock.h" #include "src/tint/resolver/resolver_test_helper.h" -#include "src/tint/sem/atomic.h" +#include "src/tint/type/atomic.h" namespace tint::resolver { namespace { @@ -84,8 +84,8 @@ TEST_F(ResolverIsStorableTest, Pointer) { } TEST_F(ResolverIsStorableTest, Atomic) { - EXPECT_TRUE(r()->IsStorable(create(create()))); - EXPECT_TRUE(r()->IsStorable(create(create()))); + EXPECT_TRUE(r()->IsStorable(create(create()))); + EXPECT_TRUE(r()->IsStorable(create(create()))); } TEST_F(ResolverIsStorableTest, ArraySizedOfStorable) { diff --git a/src/tint/resolver/resolver.cc b/src/tint/resolver/resolver.cc index 826d6ce64a..3c9d54279a 100644 --- a/src/tint/resolver/resolver.cc +++ b/src/tint/resolver/resolver.cc @@ -53,7 +53,6 @@ #include "src/tint/ast/workgroup_attribute.h" #include "src/tint/resolver/uniformity.h" #include "src/tint/sem/array.h" -#include "src/tint/sem/atomic.h" #include "src/tint/sem/break_if_statement.h" #include "src/tint/sem/call.h" #include "src/tint/sem/for_loop_statement.h" @@ -73,6 +72,7 @@ #include "src/tint/sem/while_statement.h" #include "src/tint/type/abstract_float.h" #include "src/tint/type/abstract_int.h" +#include "src/tint/type/atomic.h" #include "src/tint/type/depth_multisampled_texture.h" #include "src/tint/type/depth_texture.h" #include "src/tint/type/multisampled_texture.h" @@ -247,9 +247,9 @@ type::Type* Resolver::Type(const ast::Type* ty) { return nullptr; }, [&](const ast::Array* t) { return Array(t); }, - [&](const ast::Atomic* t) -> sem::Atomic* { + [&](const ast::Atomic* t) -> type::Atomic* { if (auto* el = Type(t->type)) { - auto* a = builder_->create(el); + auto* a = builder_->create(el); if (!validator_.Atomic(t, a)) { return nullptr; } @@ -2964,7 +2964,7 @@ sem::Array* Resolver::Array(const ast::Array* arr) { return nullptr; } - if (el_ty->Is()) { + if (el_ty->Is()) { atomic_composite_info_.Add(out, &arr->type->source); } else { if (auto found = atomic_composite_info_.Get(el_ty)) { @@ -3309,7 +3309,7 @@ sem::Struct* Resolver::Structure(const ast::Struct* str) { for (size_t i = 0; i < sem_members.Length(); i++) { auto* mem_type = sem_members[i]->Type(); - if (mem_type->Is()) { + if (mem_type->Is()) { atomic_composite_info_.Add(out, &sem_members[i]->Source()); break; } else { diff --git a/src/tint/resolver/resolver.h b/src/tint/resolver/resolver.h index 5592405ebb..fdc706ccb4 100644 --- a/src/tint/resolver/resolver.h +++ b/src/tint/resolver/resolver.h @@ -59,7 +59,6 @@ class WhileStatement; } // namespace tint::ast namespace tint::sem { class Array; -class Atomic; class BlockStatement; class Builtin; class CaseStatement; @@ -72,6 +71,9 @@ class SwitchStatement; class TypeInitializer; class WhileStatement; } // namespace tint::sem +namespace tint::type { +class Atomic; +} // namespace tint::type namespace tint::resolver { diff --git a/src/tint/resolver/validator.cc b/src/tint/resolver/validator.cc index 06e0b64ea6..82586cc936 100644 --- a/src/tint/resolver/validator.cc +++ b/src/tint/resolver/validator.cc @@ -48,7 +48,6 @@ #include "src/tint/ast/vector.h" #include "src/tint/ast/workgroup_attribute.h" #include "src/tint/sem/array.h" -#include "src/tint/sem/atomic.h" #include "src/tint/sem/break_if_statement.h" #include "src/tint/sem/call.h" #include "src/tint/sem/for_loop_statement.h" @@ -65,6 +64,7 @@ #include "src/tint/sem/variable.h" #include "src/tint/sem/while_statement.h" #include "src/tint/type/abstract_numeric.h" +#include "src/tint/type/atomic.h" #include "src/tint/type/depth_multisampled_texture.h" #include "src/tint/type/depth_texture.h" #include "src/tint/type/multisampled_texture.h" @@ -183,7 +183,7 @@ void Validator::AddNote(const std::string& msg, const Source& source) const { // https://gpuweb.github.io/gpuweb/wgsl/#plain-types-section bool Validator::IsPlain(const type::Type* type) const { return type->is_scalar() || - type->IsAnyOf(); + type->IsAnyOf(); } // https://gpuweb.github.io/gpuweb/wgsl/#fixed-footprint-types @@ -192,7 +192,7 @@ bool Validator::IsFixedFootprint(const type::Type* type) const { type, // [&](const type::Vector*) { return true; }, // [&](const type::Matrix*) { return true; }, // - [&](const sem::Atomic*) { return true; }, + [&](const type::Atomic*) { return true; }, [&](const sem::Array* arr) { return !arr->Count()->Is() && IsFixedFootprint(arr->ElemType()); @@ -226,7 +226,7 @@ bool Validator::IsHostShareable(const type::Type* type) const { } return true; }, - [&](const sem::Atomic* atomic) { return IsHostShareable(atomic->Type()); }); + [&](const type::Atomic* atomic) { return IsHostShareable(atomic->Type()); }); } // https://gpuweb.github.io/gpuweb/wgsl.html#storable-types @@ -260,7 +260,7 @@ const ast::Statement* Validator::ClosestContinuing(bool stop_at_loop, return nullptr; } -bool Validator::Atomic(const ast::Atomic* a, const sem::Atomic* s) const { +bool Validator::Atomic(const ast::Atomic* a, const type::Atomic* s) const { // https://gpuweb.github.io/gpuweb/wgsl/#atomic-types // T must be either u32 or i32. if (!s->Type()->IsAnyOf()) { @@ -2466,7 +2466,7 @@ bool Validator::CheckTypeAccessAddressSpace( return Switch( store_ty, // - [&](const sem::Atomic*) { + [&](const type::Atomic*) { if (auto* err = atomic_error()) { AddError(err, source); return false; diff --git a/src/tint/resolver/validator.h b/src/tint/resolver/validator.h index bed1c15691..1ecf573669 100644 --- a/src/tint/resolver/validator.h +++ b/src/tint/resolver/validator.h @@ -49,7 +49,6 @@ class WhileStatement; } // namespace tint::ast namespace tint::sem { class Array; -class Atomic; class BlockStatement; class BreakIfStatement; class Builtin; @@ -64,6 +63,9 @@ class SwitchStatement; class TypeInitializer; class WhileStatement; } // namespace tint::sem +namespace tint::type { +class Atomic; +} // namespace tint::type namespace tint::resolver { @@ -167,7 +169,7 @@ class Validator { /// @param a the atomic ast node /// @param s the atomic sem node /// @returns true on success, false otherwise. - bool Atomic(const ast::Atomic* a, const sem::Atomic* s) const; + bool Atomic(const ast::Atomic* a, const type::Atomic* s) const; /// Validates a pointer type /// @param a the pointer ast node diff --git a/src/tint/resolver/validator_is_storeable_test.cc b/src/tint/resolver/validator_is_storeable_test.cc index 81299f156e..dccdcea84e 100644 --- a/src/tint/resolver/validator_is_storeable_test.cc +++ b/src/tint/resolver/validator_is_storeable_test.cc @@ -16,7 +16,7 @@ #include "gmock/gmock.h" #include "src/tint/resolver/resolver_test_helper.h" -#include "src/tint/sem/atomic.h" +#include "src/tint/type/atomic.h" namespace tint::resolver { namespace { @@ -84,8 +84,8 @@ TEST_F(ValidatorIsStorableTest, Pointer) { } TEST_F(ValidatorIsStorableTest, Atomic) { - EXPECT_TRUE(v()->IsStorable(create(create()))); - EXPECT_TRUE(v()->IsStorable(create(create()))); + EXPECT_TRUE(v()->IsStorable(create(create()))); + EXPECT_TRUE(v()->IsStorable(create(create()))); } TEST_F(ValidatorIsStorableTest, ArraySizedOfStorable) { diff --git a/src/tint/transform/decompose_memory_access.cc b/src/tint/transform/decompose_memory_access.cc index 832fb05930..16d6388ff8 100644 --- a/src/tint/transform/decompose_memory_access.cc +++ b/src/tint/transform/decompose_memory_access.cc @@ -27,12 +27,12 @@ #include "src/tint/ast/unary_op.h" #include "src/tint/program_builder.h" #include "src/tint/sem/array.h" -#include "src/tint/sem/atomic.h" #include "src/tint/sem/call.h" #include "src/tint/sem/member_accessor_expression.h" #include "src/tint/sem/statement.h" #include "src/tint/sem/struct.h" #include "src/tint/sem/variable.h" +#include "src/tint/type/atomic.h" #include "src/tint/type/reference.h" #include "src/tint/utils/block_allocator.h" #include "src/tint/utils/hash.h" @@ -994,7 +994,7 @@ Transform::ApplyResult DecomposeMemoryAccess::Apply(const Program* src, auto* buf = access.var->Declaration(); auto* offset = access.offset->Build(ctx); auto* buf_ty = access.var->Type()->UnwrapRef(); - auto* el_ty = access.type->UnwrapRef()->As()->Type(); + auto* el_ty = access.type->UnwrapRef()->As()->Type(); Symbol func = state.AtomicFunc(buf_ty, el_ty, builtin, access.var->As()); diff --git a/src/tint/transform/transform.cc b/src/tint/transform/transform.cc index d2bb8ebc2d..b47f687b08 100644 --- a/src/tint/transform/transform.cc +++ b/src/tint/transform/transform.cc @@ -18,10 +18,10 @@ #include #include "src/tint/program_builder.h" -#include "src/tint/sem/atomic.h" #include "src/tint/sem/block_statement.h" #include "src/tint/sem/for_loop_statement.h" #include "src/tint/sem/variable.h" +#include "src/tint/type/atomic.h" #include "src/tint/type/depth_multisampled_texture.h" #include "src/tint/type/reference.h" #include "src/tint/type/sampler.h" @@ -142,7 +142,7 @@ const ast::Type* Transform::CreateASTTypeFor(CloneContext& ctx, const type::Type if (auto* s = ty->As()) { return CreateASTTypeFor(ctx, s->StoreType()); } - if (auto* a = ty->As()) { + if (auto* a = ty->As()) { return ctx.dst->create(CreateASTTypeFor(ctx, a->Type())); } if (auto* t = ty->As()) { diff --git a/src/tint/transform/zero_init_workgroup_memory.cc b/src/tint/transform/zero_init_workgroup_memory.cc index 0ae63d6c41..3f1a4febf2 100644 --- a/src/tint/transform/zero_init_workgroup_memory.cc +++ b/src/tint/transform/zero_init_workgroup_memory.cc @@ -22,9 +22,9 @@ #include "src/tint/ast/workgroup_attribute.h" #include "src/tint/program_builder.h" -#include "src/tint/sem/atomic.h" #include "src/tint/sem/function.h" #include "src/tint/sem/variable.h" +#include "src/tint/type/atomic.h" #include "src/tint/utils/map.h" #include "src/tint/utils/unique_vector.h" @@ -303,7 +303,7 @@ struct ZeroInitWorkgroupMemory::State { return true; } - if (auto* atomic = ty->As()) { + if (auto* atomic = ty->As()) { auto* zero_init = b.Construct(CreateASTTypeFor(ctx, atomic->Type())); auto expr = get_expr(1u); if (!expr) { @@ -439,7 +439,7 @@ struct ZeroInitWorkgroupMemory::State { /// sub-initializations. /// @param ty the type to inspect bool CanTriviallyZero(const type::Type* ty) { - if (ty->Is()) { + if (ty->Is()) { return false; } if (auto* str = ty->As()) { diff --git a/src/tint/sem/atomic.cc b/src/tint/type/atomic.cc similarity index 90% rename from src/tint/sem/atomic.cc rename to src/tint/type/atomic.cc index 7f7178e979..ee6c98bfc4 100644 --- a/src/tint/sem/atomic.cc +++ b/src/tint/type/atomic.cc @@ -1,4 +1,4 @@ -// Copyright 2021 The Tint Authors. +// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,15 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/sem/atomic.h" +#include "src/tint/type/atomic.h" #include "src/tint/program_builder.h" #include "src/tint/type/reference.h" #include "src/tint/utils/hash.h" -TINT_INSTANTIATE_TYPEINFO(tint::sem::Atomic); +TINT_INSTANTIATE_TYPEINFO(tint::type::Atomic); -namespace tint::sem { +namespace tint::type { Atomic::Atomic(const type::Type* subtype) : Base(type::TypeFlags{ @@ -60,4 +60,4 @@ Atomic::Atomic(Atomic&&) = default; Atomic::~Atomic() = default; -} // namespace tint::sem +} // namespace tint::type diff --git a/src/tint/sem/atomic.h b/src/tint/type/atomic.h similarity index 90% rename from src/tint/sem/atomic.h rename to src/tint/type/atomic.h index f1e89e94de..df05a0aed3 100644 --- a/src/tint/sem/atomic.h +++ b/src/tint/type/atomic.h @@ -1,4 +1,4 @@ -// Copyright 2021 The Tint Authors. +// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,14 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef SRC_TINT_SEM_ATOMIC_H_ -#define SRC_TINT_SEM_ATOMIC_H_ +#ifndef SRC_TINT_TYPE_ATOMIC_H_ +#define SRC_TINT_TYPE_ATOMIC_H_ #include #include "src/tint/type/type.h" -namespace tint::sem { +namespace tint::type { /// A atomic type. class Atomic final : public Castable { @@ -57,6 +57,6 @@ class Atomic final : public Castable { type::Type const* const subtype_; }; -} // namespace tint::sem +} // namespace tint::type -#endif // SRC_TINT_SEM_ATOMIC_H_ +#endif // SRC_TINT_TYPE_ATOMIC_H_ diff --git a/src/tint/sem/atomic_test.cc b/src/tint/type/atomic_test.cc similarity index 90% rename from src/tint/sem/atomic_test.cc rename to src/tint/type/atomic_test.cc index 436f185d9b..065cf52a7f 100644 --- a/src/tint/sem/atomic_test.cc +++ b/src/tint/type/atomic_test.cc @@ -1,4 +1,4 @@ -// Copyright 2021 The Tint Authors. +// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/sem/atomic.h" +#include "src/tint/type/atomic.h" -#include "src/tint/sem/test_helper.h" +#include "src/tint/type/test_helper.h" -namespace tint::sem { +namespace tint::type { namespace { using AtomicTest = TestHelper; @@ -53,4 +53,4 @@ TEST_F(AtomicTest, FriendlyName) { } } // namespace -} // namespace tint::sem +} // namespace tint::type diff --git a/src/tint/writer/glsl/generator_impl.cc b/src/tint/writer/glsl/generator_impl.cc index f4f4beff3d..7b8a53fe2c 100644 --- a/src/tint/writer/glsl/generator_impl.cc +++ b/src/tint/writer/glsl/generator_impl.cc @@ -28,7 +28,6 @@ #include "src/tint/ast/variable_decl_statement.h" #include "src/tint/debug.h" #include "src/tint/sem/array.h" -#include "src/tint/sem/atomic.h" #include "src/tint/sem/block_statement.h" #include "src/tint/sem/call.h" #include "src/tint/sem/constant.h" @@ -64,6 +63,7 @@ #include "src/tint/transform/std140.h" #include "src/tint/transform/unshadow.h" #include "src/tint/transform/zero_init_workgroup_memory.h" +#include "src/tint/type/atomic.h" #include "src/tint/type/depth_multisampled_texture.h" #include "src/tint/type/depth_texture.h" #include "src/tint/type/multisampled_texture.h" @@ -2977,7 +2977,7 @@ bool GeneratorImpl::EmitType(std::ostream& out, } out << ", " << width << ">"; } - } else if (auto* atomic = type->As()) { + } else if (auto* atomic = type->As()) { if (!EmitType(out, atomic->Type(), address_space, access, name)) { return false; } diff --git a/src/tint/writer/hlsl/generator_impl.cc b/src/tint/writer/hlsl/generator_impl.cc index a92b2f6164..f783ad7b70 100644 --- a/src/tint/writer/hlsl/generator_impl.cc +++ b/src/tint/writer/hlsl/generator_impl.cc @@ -29,7 +29,6 @@ #include "src/tint/ast/variable_decl_statement.h" #include "src/tint/debug.h" #include "src/tint/sem/array.h" -#include "src/tint/sem/atomic.h" #include "src/tint/sem/block_statement.h" #include "src/tint/sem/call.h" #include "src/tint/sem/constant.h" @@ -64,6 +63,7 @@ #include "src/tint/transform/unshadow.h" #include "src/tint/transform/vectorize_scalar_matrix_initializers.h" #include "src/tint/transform/zero_init_workgroup_memory.h" +#include "src/tint/type/atomic.h" #include "src/tint/type/depth_multisampled_texture.h" #include "src/tint/type/depth_texture.h" #include "src/tint/type/multisampled_texture.h" @@ -4104,7 +4104,7 @@ bool GeneratorImpl::EmitType(std::ostream& out, } return true; }, - [&](const sem::Atomic* atomic) { + [&](const type::Atomic* atomic) { return EmitType(out, atomic->Type(), address_space, access, name); }, [&](const type::Void*) { diff --git a/src/tint/writer/msl/generator_impl.cc b/src/tint/writer/msl/generator_impl.cc index 10c91acf54..3a0c6705af 100644 --- a/src/tint/writer/msl/generator_impl.cc +++ b/src/tint/writer/msl/generator_impl.cc @@ -32,7 +32,6 @@ #include "src/tint/ast/variable_decl_statement.h" #include "src/tint/ast/void.h" #include "src/tint/sem/array.h" -#include "src/tint/sem/atomic.h" #include "src/tint/sem/call.h" #include "src/tint/sem/constant.h" #include "src/tint/sem/function.h" @@ -60,6 +59,7 @@ #include "src/tint/transform/unshadow.h" #include "src/tint/transform/vectorize_scalar_matrix_initializers.h" #include "src/tint/transform/zero_init_workgroup_memory.h" +#include "src/tint/type/atomic.h" #include "src/tint/type/bool.h" #include "src/tint/type/depth_multisampled_texture.h" #include "src/tint/type/depth_texture.h" @@ -2523,7 +2523,7 @@ bool GeneratorImpl::EmitType(std::ostream& out, return Switch( type, - [&](const sem::Atomic* atomic) { + [&](const type::Atomic* atomic) { if (atomic->Type()->Is()) { out << "atomic_int"; return true; @@ -3187,7 +3187,7 @@ GeneratorImpl::SizeAndAlign GeneratorImpl::MslPackedTypeSizeAndAlign(const type: return SizeAndAlign{str->Size(), str->Align()}; }, - [&](const sem::Atomic* atomic) { return MslPackedTypeSizeAndAlign(atomic->Type()); }, + [&](const type::Atomic* atomic) { return MslPackedTypeSizeAndAlign(atomic->Type()); }, [&](Default) { TINT_UNREACHABLE(Writer, diagnostics_) << "Unhandled type " << ty->TypeInfo().name; diff --git a/src/tint/writer/spirv/builder.cc b/src/tint/writer/spirv/builder.cc index b018316ba5..5403f7bb00 100644 --- a/src/tint/writer/spirv/builder.cc +++ b/src/tint/writer/spirv/builder.cc @@ -23,7 +23,6 @@ #include "src/tint/ast/internal_attribute.h" #include "src/tint/ast/traverse_expressions.h" #include "src/tint/sem/array.h" -#include "src/tint/sem/atomic.h" #include "src/tint/sem/builtin.h" #include "src/tint/sem/call.h" #include "src/tint/sem/constant.h" @@ -38,6 +37,7 @@ #include "src/tint/sem/type_initializer.h" #include "src/tint/sem/variable.h" #include "src/tint/transform/add_block_attribute.h" +#include "src/tint/type/atomic.h" #include "src/tint/type/depth_multisampled_texture.h" #include "src/tint/type/depth_texture.h" #include "src/tint/type/multisampled_texture.h" @@ -3637,7 +3637,7 @@ uint32_t Builder::GenerateTypeIfNeeded(const type::Type* type) { // Atomics are a type in WGSL, but aren't a distinct type in SPIR-V. // Just emit the type inside the atomic. - if (auto* atomic = type->As()) { + if (auto* atomic = type->As()) { return GenerateTypeIfNeeded(atomic->Type()); }