From fc9430f56798a53f9393a697f4ccd6bf9981b970 Mon Sep 17 00:00:00 2001 From: Martin Wickham Date: Thu, 3 Jun 2021 15:39:26 -0500 Subject: Breaking hash map changes for 0.8.0 - hash/eql functions moved into a Context object - *Context functions pass an explicit context - *Adapted functions pass specialized keys and contexts - new getPtr() function returns a pointer to value - remove functions renamed to fetchRemove - new remove functions return bool - removeAssertDiscard deleted, use assert(remove(...)) instead - Keys and values are stored in separate arrays - Entry is now {*K, *V}, the new KV is {K, V} - BufSet/BufMap functions renamed to match other set/map types - fixed iterating-while-modifying bug in src/link/C.zig --- src/codegen/spirv.zig | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/codegen/spirv.zig') diff --git a/src/codegen/spirv.zig b/src/codegen/spirv.zig index 399a314bf0..4ce5de7523 100644 --- a/src/codegen/spirv.zig +++ b/src/codegen/spirv.zig @@ -2,6 +2,7 @@ const std = @import("std"); const Allocator = std.mem.Allocator; const Target = std.Target; const log = std.log.scoped(.codegen); +const assert = std.debug.assert; const spec = @import("spirv/spec.zig"); const Opcode = spec.Opcode; @@ -17,7 +18,7 @@ const Inst = ir.Inst; pub const Word = u32; pub const ResultId = u32; -pub const TypeMap = std.HashMap(Type, ResultId, Type.hash, Type.eql, std.hash_map.default_max_load_percentage); +pub const TypeMap = std.HashMap(Type, u32, Type.HashContext, std.hash_map.default_max_load_percentage); pub const InstMap = std.AutoHashMap(*Inst, ResultId); const IncomingBlock = struct { @@ -141,16 +142,16 @@ pub const SPIRVModule = struct { const path = decl.namespace.file_scope.sub_file_path; const result = try self.file_names.getOrPut(path); if (!result.found_existing) { - result.entry.value = self.allocResultId(); - try writeInstructionWithString(&self.binary.debug_strings, .OpString, &[_]Word{result.entry.value}, path); + result.value_ptr.* = self.allocResultId(); + try writeInstructionWithString(&self.binary.debug_strings, .OpString, &[_]Word{result.value_ptr.*}, path); try writeInstruction(&self.binary.debug_strings, .OpSource, &[_]Word{ @enumToInt(spec.SourceLanguage.Unknown), // TODO: Register Zig source language. 0, // TODO: Zig version as u32? - result.entry.value, + result.value_ptr.*, }); } - return result.entry.value; + return result.value_ptr.*; } }; @@ -847,7 +848,7 @@ pub const DeclGen = struct { .incoming_blocks = &incoming_blocks, }); defer { - self.blocks.removeAssertDiscard(inst); + assert(self.blocks.remove(inst)); incoming_blocks.deinit(self.spv.gpa); } -- cgit v1.2.3