aboutsummaryrefslogtreecommitdiff
path: root/src/Module.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-12-06 20:35:50 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-12-06 20:38:54 -0700
commit50eb7983cde6e07d2613a6f3ab164ca055d9306f (patch)
treebe9361a684543867bf3fd1711e64c7974660d074 /src/Module.zig
parentc8aba15c222e5bb8cf5d2d48678761197f564351 (diff)
downloadzig-50eb7983cde6e07d2613a6f3ab164ca055d9306f.tar.gz
zig-50eb7983cde6e07d2613a6f3ab164ca055d9306f.zip
remove most conditional compilation based on stage1
There are still a few occurrences of "stage1" in the standard library and self-hosted compiler source, however, these instances need a bit more careful inspection to ensure no breakage.
Diffstat (limited to 'src/Module.zig')
-rw-r--r--src/Module.zig14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/Module.zig b/src/Module.zig
index 68d0ac8af5..074e25470c 100644
--- a/src/Module.zig
+++ b/src/Module.zig
@@ -71,7 +71,7 @@ import_table: std.StringArrayHashMapUnmanaged(*File) = .{},
/// Keys are fully resolved file paths. This table owns the keys and values.
embed_table: std.StringHashMapUnmanaged(*EmbedFile) = .{},
-/// This is a temporary addition to stage2 in order to match stage1 behavior,
+/// This is a temporary addition to stage2 in order to match legacy behavior,
/// however the end-game once the lang spec is settled will be to use a global
/// InternPool for comptime memoized objects, making this behavior consistent across all types,
/// not only string literals. Or, we might decide to not guarantee string literals
@@ -3544,17 +3544,15 @@ fn freeExportList(gpa: Allocator, export_list: *ArrayListUnmanaged(*Export)) voi
export_list.deinit(gpa);
}
+// TODO https://github.com/ziglang/zig/issues/8643
const data_has_safety_tag = @sizeOf(Zir.Inst.Data) != 8;
-// TODO This is taking advantage of matching stage1 debug union layout.
-// We need a better language feature for initializing a union with
-// a runtime-known tag.
-const Stage1DataLayout = extern struct {
+const HackDataLayout = extern struct {
data: [8]u8 align(@alignOf(Zir.Inst.Data)),
safety_tag: u8,
};
comptime {
if (data_has_safety_tag) {
- assert(@sizeOf(Stage1DataLayout) == @sizeOf(Zir.Inst.Data));
+ assert(@sizeOf(HackDataLayout) == @sizeOf(Zir.Inst.Data));
}
}
@@ -3695,7 +3693,7 @@ pub fn astGenFile(mod: *Module, file: *File) !void {
const tags = zir.instructions.items(.tag);
for (zir.instructions.items(.data)) |*data, i| {
const union_tag = Zir.Inst.Tag.data_tags[@enumToInt(tags[i])];
- const as_struct = @ptrCast(*Stage1DataLayout, data);
+ const as_struct = @ptrCast(*HackDataLayout, data);
as_struct.* = .{
.safety_tag = @enumToInt(union_tag),
.data = safety_buffer[i],
@@ -3881,7 +3879,7 @@ pub fn astGenFile(mod: *Module, file: *File) !void {
if (data_has_safety_tag) {
// The `Data` union has a safety tag but in the file format we store it without.
for (file.zir.instructions.items(.data)) |*data, i| {
- const as_struct = @ptrCast(*const Stage1DataLayout, data);
+ const as_struct = @ptrCast(*const HackDataLayout, data);
safety_buffer[i] = as_struct.data;
}
}