From 4cb132918164902690a03281dc58252793ddcf46 Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Fri, 4 Mar 2022 21:09:24 +0000 Subject: [PATCH] Move BlockAllocator from src/tint to src/tint/utils Change-Id: I4bca9413d73d0095a3e0de23bcc4de956bf3b98e Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/82740 Auto-Submit: Ben Clayton Reviewed-by: James Price Kokoro: Kokoro Commit-Queue: Ben Clayton --- src/tint/BUILD.gn | 2 +- src/tint/CMakeLists.txt | 4 ++-- src/tint/clone_context_test.cc | 2 +- src/tint/program.h | 4 ++-- src/tint/program_builder.h | 4 ++-- src/tint/reader/spirv/parser_type.cc | 2 +- src/tint/reader/spirv/parser_type.h | 2 +- src/tint/resolver/dependency_graph.cc | 2 +- src/tint/sem/type_manager.h | 6 +++--- src/tint/transform/decompose_memory_access.cc | 4 ++-- src/tint/{ => utils}/block_allocator.h | 10 +++++----- src/tint/{ => utils}/block_allocator_test.cc | 6 +++--- test/tint/BUILD.gn | 2 +- 13 files changed, 25 insertions(+), 25 deletions(-) rename src/tint/{ => utils}/block_allocator.h (98%) rename src/tint/{ => utils}/block_allocator_test.cc (97%) diff --git a/src/tint/BUILD.gn b/src/tint/BUILD.gn index 53f557a523..91784c41b7 100644 --- a/src/tint/BUILD.gn +++ b/src/tint/BUILD.gn @@ -336,7 +336,6 @@ libtint_source_set("libtint_core_all_src") { "ast/void.h", "ast/workgroup_attribute.cc", "ast/workgroup_attribute.h", - "block_allocator.h", "builtin_table.cc", "builtin_table.h", "builtin_table.inl", @@ -502,6 +501,7 @@ libtint_source_set("libtint_core_all_src") { "transform/wrap_arrays_in_structs.h", "transform/zero_init_workgroup_memory.cc", "transform/zero_init_workgroup_memory.h", + "utils/block_allocator.h", "utils/crc32.h", "utils/debugger.cc", "utils/debugger.h", diff --git a/src/tint/CMakeLists.txt b/src/tint/CMakeLists.txt index 8abbc93743..0735873ad2 100644 --- a/src/tint/CMakeLists.txt +++ b/src/tint/CMakeLists.txt @@ -225,7 +225,6 @@ set(TINT_LIB_SRCS ast/void.h ast/workgroup_attribute.cc ast/workgroup_attribute.h - block_allocator.h builtin_table.cc builtin_table.h builtin_table.inl @@ -428,6 +427,7 @@ set(TINT_LIB_SRCS sem/vector_type.h sem/void_type.cc sem/void_type.h + utils/block_allocator.h utils/crc32.h utils/enum_set.h utils/hash.h @@ -705,7 +705,6 @@ if(TINT_BUILD_TESTS) ast/variable_test.cc ast/vector_test.cc ast/workgroup_attribute_test.cc - block_allocator_test.cc builtin_table_test.cc castable_test.cc clone_context_test.cc @@ -783,6 +782,7 @@ if(TINT_BUILD_TESTS) text/unicode_test.cc traits_test.cc transform/transform_test.cc + utils/block_allocator_test.cc utils/crc32_test.cc utils/defer_test.cc utils/enum_set_test.cc diff --git a/src/tint/clone_context_test.cc b/src/tint/clone_context_test.cc index 5339d6496b..3a5a8c9096 100644 --- a/src/tint/clone_context_test.cc +++ b/src/tint/clone_context_test.cc @@ -27,7 +27,7 @@ struct Allocator { } private: - BlockAllocator alloc; + utils::BlockAllocator alloc; }; struct Node : public Castable { diff --git a/src/tint/program.h b/src/tint/program.h index 9531ca44a4..23e0945b99 100644 --- a/src/tint/program.h +++ b/src/tint/program.h @@ -39,10 +39,10 @@ class Module; class Program { public: /// ASTNodeAllocator is an alias to BlockAllocator - using ASTNodeAllocator = BlockAllocator; + using ASTNodeAllocator = utils::BlockAllocator; /// SemNodeAllocator is an alias to BlockAllocator - using SemNodeAllocator = BlockAllocator; + using SemNodeAllocator = utils::BlockAllocator; /// Constructor Program(); diff --git a/src/tint/program_builder.h b/src/tint/program_builder.h index c245c4287a..b791d05236 100644 --- a/src/tint/program_builder.h +++ b/src/tint/program_builder.h @@ -149,10 +149,10 @@ class ProgramBuilder { public: /// ASTNodeAllocator is an alias to BlockAllocator - using ASTNodeAllocator = BlockAllocator; + using ASTNodeAllocator = utils::BlockAllocator; /// SemNodeAllocator is an alias to BlockAllocator - using SemNodeAllocator = BlockAllocator; + using SemNodeAllocator = utils::BlockAllocator; /// `i32` is a type alias to `int`. /// Useful for passing to template methods such as `vec2()` to imitate diff --git a/src/tint/reader/spirv/parser_type.cc b/src/tint/reader/spirv/parser_type.cc index 06d56c74ca..42fe6fa0c8 100644 --- a/src/tint/reader/spirv/parser_type.cc +++ b/src/tint/reader/spirv/parser_type.cc @@ -268,7 +268,7 @@ const ast::Type* Struct::Build(ProgramBuilder& b) const { /// The PIMPL state of the Types object. struct TypeManager::State { /// The allocator of types - BlockAllocator allocator_; + utils::BlockAllocator allocator_; /// The lazily-created Void type spirv::Void const* void_ = nullptr; /// The lazily-created Bool type diff --git a/src/tint/reader/spirv/parser_type.h b/src/tint/reader/spirv/parser_type.h index 59e6444759..c550ad0309 100644 --- a/src/tint/reader/spirv/parser_type.h +++ b/src/tint/reader/spirv/parser_type.h @@ -24,8 +24,8 @@ #include "src/tint/ast/storage_class.h" #include "src/tint/ast/storage_texture.h" #include "src/tint/ast/texture.h" -#include "src/tint/block_allocator.h" #include "src/tint/castable.h" +#include "src/tint/utils/block_allocator.h" // Forward declarations namespace tint { diff --git a/src/tint/resolver/dependency_graph.cc b/src/tint/resolver/dependency_graph.cc index 8d580184f4..4e18ce630c 100644 --- a/src/tint/resolver/dependency_graph.cc +++ b/src/tint/resolver/dependency_graph.cc @@ -702,7 +702,7 @@ struct DependencyAnalysis { DependencyGraph& graph_; /// Allocator of Globals - BlockAllocator allocator_; + utils::BlockAllocator allocator_; /// Global map, keyed by name. Populated by GatherGlobals(). GlobalMap globals_; diff --git a/src/tint/sem/type_manager.h b/src/tint/sem/type_manager.h index a248d449f1..7cdce6649e 100644 --- a/src/tint/sem/type_manager.h +++ b/src/tint/sem/type_manager.h @@ -19,8 +19,8 @@ #include #include -#include "src/tint/block_allocator.h" #include "src/tint/sem/type.h" +#include "src/tint/utils/block_allocator.h" namespace tint { namespace sem { @@ -29,7 +29,7 @@ namespace sem { class Manager { public: /// Iterator is the type returned by begin() and end() - using Iterator = BlockAllocator::ConstIterator; + using Iterator = utils::BlockAllocator::ConstIterator; /// Constructor Manager(); @@ -91,7 +91,7 @@ class Manager { private: std::unordered_map by_name_; - BlockAllocator types_; + utils::BlockAllocator types_; }; } // namespace sem diff --git a/src/tint/transform/decompose_memory_access.cc b/src/tint/transform/decompose_memory_access.cc index f251a22439..a2e3b71e36 100644 --- a/src/tint/transform/decompose_memory_access.cc +++ b/src/tint/transform/decompose_memory_access.cc @@ -25,7 +25,6 @@ #include "src/tint/ast/disable_validation_attribute.h" #include "src/tint/ast/type_name.h" #include "src/tint/ast/unary_op.h" -#include "src/tint/block_allocator.h" #include "src/tint/program_builder.h" #include "src/tint/sem/array.h" #include "src/tint/sem/atomic_type.h" @@ -35,6 +34,7 @@ #include "src/tint/sem/statement.h" #include "src/tint/sem/struct.h" #include "src/tint/sem/variable.h" +#include "src/tint/utils/block_allocator.h" #include "src/tint/utils/hash.h" #include "src/tint/utils/map.h" @@ -315,7 +315,7 @@ struct DecomposeMemoryAccess::State { /// List of storage or uniform buffer writes std::vector stores; /// Allocations for offsets - BlockAllocator offsets_; + utils::BlockAllocator offsets_; /// Constructor /// @param context the CloneContext diff --git a/src/tint/block_allocator.h b/src/tint/utils/block_allocator.h similarity index 98% rename from src/tint/block_allocator.h rename to src/tint/utils/block_allocator.h index c6bf3776dd..4823fae621 100644 --- a/src/tint/block_allocator.h +++ b/src/tint/utils/block_allocator.h @@ -12,15 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef SRC_TINT_BLOCK_ALLOCATOR_H_ -#define SRC_TINT_BLOCK_ALLOCATOR_H_ +#ifndef SRC_TINT_UTILS_BLOCK_ALLOCATOR_H_ +#define SRC_TINT_UTILS_BLOCK_ALLOCATOR_H_ #include #include #include "src/tint/utils/math.h" -namespace tint { +namespace tint::utils { /// A container and allocator of objects of (or deriving from) the template /// type `T`. Objects are allocated by calling Create(), and are owned by the @@ -289,6 +289,6 @@ class BlockAllocator { } pointers_; }; -} // namespace tint +} // namespace tint::utils -#endif // SRC_TINT_BLOCK_ALLOCATOR_H_ +#endif // SRC_TINT_UTILS_BLOCK_ALLOCATOR_H_ diff --git a/src/tint/block_allocator_test.cc b/src/tint/utils/block_allocator_test.cc similarity index 97% rename from src/tint/block_allocator_test.cc rename to src/tint/utils/block_allocator_test.cc index 8b3ded04f1..ace0e9f76d 100644 --- a/src/tint/block_allocator_test.cc +++ b/src/tint/utils/block_allocator_test.cc @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/block_allocator.h" +#include "src/tint/utils/block_allocator.h" #include "gtest/gtest.h" -namespace tint { +namespace tint::utils { namespace { struct LifetimeCounter { @@ -144,4 +144,4 @@ TEST_F(BlockAllocatorTest, ObjectOrder) { } } // namespace -} // namespace tint +} // namespace tint::utils diff --git a/test/tint/BUILD.gn b/test/tint/BUILD.gn index d34430d542..8099317083 100644 --- a/test/tint/BUILD.gn +++ b/test/tint/BUILD.gn @@ -701,7 +701,6 @@ tint_unittests_source_set("tint_unittests_glsl_writer_src") { tint_unittests_source_set("tint_unittests_core_src") { sources = [ - "../../src/tint/block_allocator_test.cc", "../../src/tint/builtin_table_test.cc", "../../src/tint/castable_test.cc", "../../src/tint/clone_context_test.cc", @@ -714,6 +713,7 @@ tint_unittests_source_set("tint_unittests_core_src") { "../../src/tint/symbol_table_test.cc", "../../src/tint/symbol_test.cc", "../../src/tint/traits_test.cc", + "../../src/tint/utils/block_allocator_test.cc", ] deps = [ ":tint_unittests_ast_src" ]