aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/spirv.zig
diff options
context:
space:
mode:
authorMartin Wickham <spexguy070@gmail.com>2021-06-03 15:39:26 -0500
committerMartin Wickham <spexguy070@gmail.com>2021-06-03 17:02:16 -0500
commitfc9430f56798a53f9393a697f4ccd6bf9981b970 (patch)
tree69a1a3b359e970349f9466f85a370918d78b7217 /src/codegen/spirv.zig
parent87dae0ce98fde1957a9290c22866b3101ce419d8 (diff)
downloadzig-fc9430f56798a53f9393a697f4ccd6bf9981b970.tar.gz
zig-fc9430f56798a53f9393a697f4ccd6bf9981b970.zip
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
Diffstat (limited to 'src/codegen/spirv.zig')
-rw-r--r--src/codegen/spirv.zig13
1 files changed, 7 insertions, 6 deletions
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);
}