aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/spirv/Module.zig
diff options
context:
space:
mode:
authorRobin Voetter <robin@voetter.nl>2023-04-22 11:18:58 +0200
committerRobin Voetter <robin@voetter.nl>2023-05-11 20:31:51 +0200
commite26d8d060410ff5f62356c41f3c782f8a9081495 (patch)
tree7bfe6f191108e2191d79c5f64fecaab4a0bdbc6e /src/codegen/spirv/Module.zig
parentd961b11cde81e92ed3d35c98f7b191255aac58a6 (diff)
downloadzig-e26d8d060410ff5f62356c41f3c782f8a9081495.tar.gz
zig-e26d8d060410ff5f62356c41f3c782f8a9081495.zip
spirv: make decl deps a hash map instead of an arraylist
The same declaration can be added to the dependency set multiple times, and in this case we still need to emit it once. By making this list a hash map instead, we can do that quite easily. This commit also introduces some additional debug logging regarding decls.
Diffstat (limited to 'src/codegen/spirv/Module.zig')
-rw-r--r--src/codegen/spirv/Module.zig6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/codegen/spirv/Module.zig b/src/codegen/spirv/Module.zig
index be8e5b24d1..4bd6c834ce 100644
--- a/src/codegen/spirv/Module.zig
+++ b/src/codegen/spirv/Module.zig
@@ -40,14 +40,14 @@ pub const Fn = struct {
/// the end of this function definition.
body: Section = .{},
/// The decl dependencies that this function depends on.
- decl_deps: std.ArrayListUnmanaged(Decl.Index) = .{},
+ decl_deps: std.AutoArrayHashMapUnmanaged(Decl.Index, void) = .{},
/// Reset this function without deallocating resources, so that
/// it may be used to emit code for another function.
pub fn reset(self: *Fn) void {
self.prologue.reset();
self.body.reset();
- self.decl_deps.items.len = 0;
+ self.decl_deps.clearRetainingCapacity();
}
/// Free the resources owned by this function.
@@ -358,7 +358,7 @@ pub fn flush(self: *Module, file: std.fs.File) !void {
pub fn addFunction(self: *Module, decl_index: Decl.Index, func: Fn) !void {
try self.sections.functions.append(self.gpa, func.prologue);
try self.sections.functions.append(self.gpa, func.body);
- try self.declareDeclDeps(decl_index, func.decl_deps.items);
+ try self.declareDeclDeps(decl_index, func.decl_deps.keys());
}
/// Fetch the result-id of an OpString instruction that encodes the path of the source