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 <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
diff --git a/src/tint/BUILD.gn b/src/tint/BUILD.gn
index 53f557a..91784c4 100644
--- a/src/tint/BUILD.gn
+++ b/src/tint/BUILD.gn
@@ -336,7 +336,6 @@
"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 @@
"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 8abbc93..0735873 100644
--- a/src/tint/CMakeLists.txt
+++ b/src/tint/CMakeLists.txt
@@ -225,7 +225,6 @@
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 @@
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 @@
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 @@
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 5339d64..3a5a8c9 100644
--- a/src/tint/clone_context_test.cc
+++ b/src/tint/clone_context_test.cc
@@ -27,7 +27,7 @@
}
private:
- BlockAllocator<Cloneable> alloc;
+ utils::BlockAllocator<Cloneable> alloc;
};
struct Node : public Castable<Node, Cloneable> {
diff --git a/src/tint/program.h b/src/tint/program.h
index 9531ca4..23e0945 100644
--- a/src/tint/program.h
+++ b/src/tint/program.h
@@ -39,10 +39,10 @@
class Program {
public:
/// ASTNodeAllocator is an alias to BlockAllocator<ast::Node>
- using ASTNodeAllocator = BlockAllocator<ast::Node>;
+ using ASTNodeAllocator = utils::BlockAllocator<ast::Node>;
/// SemNodeAllocator is an alias to BlockAllocator<sem::Node>
- using SemNodeAllocator = BlockAllocator<sem::Node>;
+ using SemNodeAllocator = utils::BlockAllocator<sem::Node>;
/// Constructor
Program();
diff --git a/src/tint/program_builder.h b/src/tint/program_builder.h
index c245c42..b791d05 100644
--- a/src/tint/program_builder.h
+++ b/src/tint/program_builder.h
@@ -149,10 +149,10 @@
public:
/// ASTNodeAllocator is an alias to BlockAllocator<ast::Node>
- using ASTNodeAllocator = BlockAllocator<ast::Node>;
+ using ASTNodeAllocator = utils::BlockAllocator<ast::Node>;
/// SemNodeAllocator is an alias to BlockAllocator<sem::Node>
- using SemNodeAllocator = BlockAllocator<sem::Node>;
+ using SemNodeAllocator = utils::BlockAllocator<sem::Node>;
/// `i32` is a type alias to `int`.
/// Useful for passing to template methods such as `vec2<i32>()` to imitate
diff --git a/src/tint/reader/spirv/parser_type.cc b/src/tint/reader/spirv/parser_type.cc
index 06d56c7..42fe6fa 100644
--- a/src/tint/reader/spirv/parser_type.cc
+++ b/src/tint/reader/spirv/parser_type.cc
@@ -268,7 +268,7 @@
/// The PIMPL state of the Types object.
struct TypeManager::State {
/// The allocator of types
- BlockAllocator<Type> allocator_;
+ utils::BlockAllocator<Type> 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 59e6444..c550ad0 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 8d58018..4e18ce6 100644
--- a/src/tint/resolver/dependency_graph.cc
+++ b/src/tint/resolver/dependency_graph.cc
@@ -702,7 +702,7 @@
DependencyGraph& graph_;
/// Allocator of Globals
- BlockAllocator<Global> allocator_;
+ utils::BlockAllocator<Global> 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 a248d44..7cdce66 100644
--- a/src/tint/sem/type_manager.h
+++ b/src/tint/sem/type_manager.h
@@ -19,8 +19,8 @@
#include <unordered_map>
#include <utility>
-#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 @@
class Manager {
public:
/// Iterator is the type returned by begin() and end()
- using Iterator = BlockAllocator<sem::Type>::ConstIterator;
+ using Iterator = utils::BlockAllocator<sem::Type>::ConstIterator;
/// Constructor
Manager();
@@ -91,7 +91,7 @@
private:
std::unordered_map<std::string, sem::Type*> by_name_;
- BlockAllocator<sem::Type> types_;
+ utils::BlockAllocator<sem::Type> types_;
};
} // namespace sem
diff --git a/src/tint/transform/decompose_memory_access.cc b/src/tint/transform/decompose_memory_access.cc
index f251a22..a2e3b71 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 @@
/// List of storage or uniform buffer writes
std::vector<Store> stores;
/// Allocations for offsets
- BlockAllocator<Offset> offsets_;
+ utils::BlockAllocator<Offset> offsets_;
/// Constructor
/// @param context the CloneContext
diff --git a/src/tint/block_allocator.h b/src/tint/utils/block_allocator.h
similarity index 97%
rename from src/tint/block_allocator.h
rename to src/tint/utils/block_allocator.h
index c6bf377..4823fae 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 <array>
#include <utility>
#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 @@
} 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 96%
rename from src/tint/block_allocator_test.cc
rename to src/tint/utils/block_allocator_test.cc
index 8b3ded0..ace0e9f 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 @@
}
} // namespace
-} // namespace tint
+} // namespace tint::utils
diff --git a/test/tint/BUILD.gn b/test/tint/BUILD.gn
index d34430d..8099317 100644
--- a/test/tint/BUILD.gn
+++ b/test/tint/BUILD.gn
@@ -701,7 +701,6 @@
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 @@
"../../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" ]