diff options
| author | Robin Voetter <robin@voetter.nl> | 2025-02-24 20:39:13 +0100 |
|---|---|---|
| committer | Robin Voetter <robin@voetter.nl> | 2025-02-24 20:58:13 +0100 |
| commit | fe5a78691fc3cebf8fcefa3498a4b594dbb28c65 (patch) | |
| tree | 69ad58cd94f28e6bffd05f1029695048e7bbeeeb /src/codegen | |
| parent | aec0f9b3e7790c2e3b66d519e4d8e438208b5406 (diff) | |
| download | zig-fe5a78691fc3cebf8fcefa3498a4b594dbb28c65.tar.gz zig-fe5a78691fc3cebf8fcefa3498a4b594dbb28c65.zip | |
spirv: get rid of function_types cache
This deep hash map doesn't work
Diffstat (limited to 'src/codegen')
| -rw-r--r-- | src/codegen/spirv/Module.zig | 33 |
1 files changed, 7 insertions, 26 deletions
diff --git a/src/codegen/spirv/Module.zig b/src/codegen/spirv/Module.zig index 30f9b0bc54..5ed1e2df1a 100644 --- a/src/codegen/spirv/Module.zig +++ b/src/codegen/spirv/Module.zig @@ -21,19 +21,6 @@ const IdResultType = spec.IdResultType; const Section = @import("Section.zig"); -/// Helper HashMap type to hash deeply -fn DeepHashMap(K: type, V: type) type { - return std.HashMapUnmanaged(K, V, struct { - pub fn hash(ctx: @This(), key: K) u64 { - _ = ctx; - var hasher = Wyhash.init(0); - autoHashStrat(&hasher, key, .Deep); - return hasher.final(); - } - pub const eql = std.hash_map.getAutoEqlFn(K, @This()); - }, std.hash_map.default_max_load_percentage); -} - /// This structure represents a function that isc in-progress of being emitted. /// Commonly, the contents of this structure will be merged with the appropriate /// sections of the module and re-used. Note that the SPIR-V module system makes @@ -181,7 +168,6 @@ cache: struct { // same ID as @Vector(X, bool) in indirect representation. vector_types: std.AutoHashMapUnmanaged(struct { IdRef, u32 }, IdRef) = .empty, array_types: std.AutoHashMapUnmanaged(struct { IdRef, IdRef }, IdRef) = .empty, - function_types: DeepHashMap(struct { IdRef, []const IdRef }, IdRef) = .empty, capabilities: std.AutoHashMapUnmanaged(spec.Capability, void) = .empty, extensions: std.StringHashMapUnmanaged(void) = .empty, @@ -241,7 +227,6 @@ pub fn deinit(self: *Module) void { self.cache.float_types.deinit(self.gpa); self.cache.vector_types.deinit(self.gpa); self.cache.array_types.deinit(self.gpa); - self.cache.function_types.deinit(self.gpa); self.cache.capabilities.deinit(self.gpa); self.cache.extensions.deinit(self.gpa); self.cache.extended_instruction_set.deinit(self.gpa); @@ -616,17 +601,13 @@ pub fn arrayType(self: *Module, len_id: IdRef, child_ty_id: IdRef) !IdRef { } pub fn functionType(self: *Module, return_ty_id: IdRef, param_type_ids: []const IdRef) !IdRef { - const entry = try self.cache.function_types.getOrPut(self.gpa, .{ return_ty_id, param_type_ids }); - if (!entry.found_existing) { - const result_id = self.allocId(); - entry.value_ptr.* = result_id; - try self.sections.types_globals_constants.emit(self.gpa, .OpTypeFunction, .{ - .id_result = result_id, - .return_type = return_ty_id, - .id_ref_2 = param_type_ids, - }); - } - return entry.value_ptr.*; + const result_id = self.allocId(); + try self.sections.types_globals_constants.emit(self.gpa, .OpTypeFunction, .{ + .id_result = result_id, + .return_type = return_ty_id, + .id_ref_2 = param_type_ids, + }); + return result_id; } pub fn constBool(self: *Module, value: bool) !IdRef { |
