aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/spirv/Module.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-05-12 14:46:20 -0700
committerGitHub <noreply@github.com>2023-05-12 14:46:20 -0700
commit88d275199c8807912f859e9f2b689700e3866689 (patch)
tree61157f4fb8ab135930ebfee3d40f4eede9b568ae /src/codegen/spirv/Module.zig
parent6547d233125199b16644c0f7504793490af67926 (diff)
parentd61dc3a5a2320d1adda759cf5f90aaf817cb9ca2 (diff)
downloadzig-88d275199c8807912f859e9f2b689700e3866689.tar.gz
zig-88d275199c8807912f859e9f2b689700e3866689.zip
Merge pull request #15240 from Snektron/spirv-basic
spirv: attempting to get the 'basic' behavior tests running
Diffstat (limited to 'src/codegen/spirv/Module.zig')
-rw-r--r--src/codegen/spirv/Module.zig13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/codegen/spirv/Module.zig b/src/codegen/spirv/Module.zig
index 7ae6cb0c6a..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
@@ -393,11 +393,14 @@ pub fn resolveSourceFileName(self: *Module, decl: *ZigDecl) !IdRef {
/// be emitted at this point.
pub fn resolveType(self: *Module, ty: Type) !Type.Ref {
const result = try self.type_cache.getOrPut(self.gpa, ty);
+ const index = @intToEnum(Type.Ref, result.index);
+
if (!result.found_existing) {
- result.value_ptr.* = try self.emitType(ty);
+ const ref = try self.emitType(ty);
+ self.type_cache.values()[result.index] = ref;
}
- return @intToEnum(Type.Ref, result.index);
+ return index;
}
pub fn resolveTypeId(self: *Module, ty: Type) !IdResultType {