aboutsummaryrefslogtreecommitdiff
path: root/src/codegen
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-06-04 01:12:38 -0400
committerGitHub <noreply@github.com>2021-06-04 01:12:38 -0400
commit7d15a3ac71c5d8dc8c08dfd8ea8ad43d4eae188a (patch)
treeae007106526e300bb7143be003fe8d847ba7230c /src/codegen
parent87dae0ce98fde1957a9290c22866b3101ce419d8 (diff)
parent6953c8544b68c788dca4ed065e4a15eccbd4446b (diff)
downloadzig-7d15a3ac71c5d8dc8c08dfd8ea8ad43d4eae188a.tar.gz
zig-7d15a3ac71c5d8dc8c08dfd8ea8ad43d4eae188a.zip
Merge pull request #8975 from SpexGuy/hash-map-updates
Breaking hash map changes for 0.8.0
Diffstat (limited to 'src/codegen')
-rw-r--r--src/codegen/c.zig17
-rw-r--r--src/codegen/llvm.zig2
-rw-r--r--src/codegen/spirv.zig13
-rw-r--r--src/codegen/wasm.zig6
4 files changed, 21 insertions, 17 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig
index 55c9c5b641..68b74d7659 100644
--- a/src/codegen/c.zig
+++ b/src/codegen/c.zig
@@ -39,7 +39,7 @@ const BlockData = struct {
};
pub const CValueMap = std.AutoHashMap(*Inst, CValue);
-pub const TypedefMap = std.HashMap(Type, struct { name: []const u8, rendered: []u8 }, Type.hash, Type.eql, std.hash_map.default_max_load_percentage);
+pub const TypedefMap = std.HashMap(Type, struct { name: []const u8, rendered: []u8 }, Type.HashContext, std.hash_map.default_max_load_percentage);
fn formatTypeAsCIdentifier(
data: Type,
@@ -309,7 +309,7 @@ pub const DeclGen = struct {
.enum_full, .enum_nonexhaustive => {
const enum_full = t.cast(Type.Payload.EnumFull).?.data;
if (enum_full.values.count() != 0) {
- const tag_val = enum_full.values.entries.items[field_index].key;
+ const tag_val = enum_full.values.keys()[field_index];
return dg.renderValue(writer, enum_full.tag_ty, tag_val);
} else {
return writer.print("{d}", .{field_index});
@@ -493,10 +493,13 @@ pub const DeclGen = struct {
defer buffer.deinit();
try buffer.appendSlice("typedef struct {\n");
- for (struct_obj.fields.entries.items) |entry| {
- try buffer.append(' ');
- try dg.renderType(buffer.writer(), entry.value.ty);
- try buffer.writer().print(" {s};\n", .{fmtIdent(entry.key)});
+ {
+ var it = struct_obj.fields.iterator();
+ while (it.next()) |entry| {
+ try buffer.append(' ');
+ try dg.renderType(buffer.writer(), entry.value_ptr.ty);
+ try buffer.writer().print(" {s};\n", .{fmtIdent(entry.key_ptr.*)});
+ }
}
try buffer.appendSlice("} ");
@@ -1186,7 +1189,7 @@ fn genStructFieldPtr(o: *Object, inst: *Inst.StructFieldPtr) !CValue {
const writer = o.writer();
const struct_ptr = try o.resolveInst(inst.struct_ptr);
const struct_obj = inst.struct_ptr.ty.elemType().castTag(.@"struct").?.data;
- const field_name = struct_obj.fields.entries.items[inst.field_index].key;
+ const field_name = struct_obj.fields.keys()[inst.field_index];
const local = try o.allocLocal(inst.base.ty, .Const);
switch (struct_ptr) {
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig
index a7e61f6baa..4e4621ca29 100644
--- a/src/codegen/llvm.zig
+++ b/src/codegen/llvm.zig
@@ -789,7 +789,7 @@ pub const FuncGen = struct {
.break_vals = &break_vals,
});
defer {
- self.blocks.removeAssertDiscard(inst);
+ assert(self.blocks.remove(inst));
break_bbs.deinit(self.gpa());
break_vals.deinit(self.gpa());
}
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);
}
diff --git a/src/codegen/wasm.zig b/src/codegen/wasm.zig
index 528b233589..d7fe239d3b 100644
--- a/src/codegen/wasm.zig
+++ b/src/codegen/wasm.zig
@@ -625,10 +625,10 @@ pub const Context = struct {
const struct_data: *Module.Struct = ty.castTag(.@"struct").?.data;
const fields_len = @intCast(u32, struct_data.fields.count());
try self.locals.ensureCapacity(self.gpa, self.locals.items.len + fields_len);
- for (struct_data.fields.items()) |entry| {
+ for (struct_data.fields.values()) |*value| {
const val_type = try self.genValtype(
.{ .node_offset = struct_data.node_offset },
- entry.value.ty,
+ value.ty,
);
self.locals.appendAssumeCapacity(val_type);
self.local_index += 1;
@@ -1018,7 +1018,7 @@ pub const Context = struct {
.enum_full, .enum_nonexhaustive => {
const enum_full = ty.cast(Type.Payload.EnumFull).?.data;
if (enum_full.values.count() != 0) {
- const tag_val = enum_full.values.entries.items[field_index.data].key;
+ const tag_val = enum_full.values.keys()[field_index.data];
try self.emitConstant(src, tag_val, enum_full.tag_ty);
} else {
try writer.writeByte(wasm.opcode(.i32_const));