mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
spirv: get rid of function_types cache
This deep hash map doesn't work
This commit is contained in:
parent
aec0f9b3e7
commit
fe5a78691f
@ -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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user