| author | |
| committer | |
| log | 1c1feba08edf1ded85af0ec003939a7756f4ab0b |
| tree | 5bf36c67a1271f74e5e2bbec44ae9f737a91217a |
| parent | 9868ed44b31483b21236623e16e5a73b8c026a47 |
| signature |
10 files changed, 139 insertions(+), 143 deletions(-)
src/Compilation.zig+6-6| ... | @@ -4350,8 +4350,8 @@ fn workerCheckEmbedFile(comp: *Compilation, embed_file: *Zcu.EmbedFile) void { | ... | @@ -4350,8 +4350,8 @@ fn workerCheckEmbedFile(comp: *Compilation, embed_file: *Zcu.EmbedFile) void { |
| 4350 | } | 4350 | } |
| 4351 | 4351 | ||
| 4352 | fn detectEmbedFileUpdate(comp: *Compilation, embed_file: *Zcu.EmbedFile) !void { | 4352 | fn detectEmbedFileUpdate(comp: *Compilation, embed_file: *Zcu.EmbedFile) !void { |
| 4353 | const mod = comp.zcu.?; | 4353 | const zcu = comp.zcu.?; |
| 4354 | const ip = &mod.intern_pool; | 4354 | const ip = &zcu.intern_pool; |
| 4355 | var file = try embed_file.owner.root.openFile(embed_file.sub_file_path.toSlice(ip), .{}); | 4355 | var file = try embed_file.owner.root.openFile(embed_file.sub_file_path.toSlice(ip), .{}); |
| 4356 | defer file.close(); | 4356 | defer file.close(); |
| 4357 | 4357 | ||
| ... | @@ -4663,10 +4663,10 @@ fn reportRetryableEmbedFileError( | ... | @@ -4663,10 +4663,10 @@ fn reportRetryableEmbedFileError( |
| 4663 | embed_file: *Zcu.EmbedFile, | 4663 | embed_file: *Zcu.EmbedFile, |
| 4664 | err: anyerror, | 4664 | err: anyerror, |
| 4665 | ) error{OutOfMemory}!void { | 4665 | ) error{OutOfMemory}!void { |
| 4666 | const mod = comp.zcu.?; | 4666 | const zcu = comp.zcu.?; |
| 4667 | const gpa = mod.gpa; | 4667 | const gpa = zcu.gpa; |
| 4668 | const src_loc = embed_file.src_loc; | 4668 | const src_loc = embed_file.src_loc; |
| 4669 | const ip = &mod.intern_pool; | 4669 | const ip = &zcu.intern_pool; |
| 4670 | const err_msg = try Zcu.ErrorMsg.create(gpa, src_loc, "unable to load '{}/{s}': {s}", .{ | 4670 | const err_msg = try Zcu.ErrorMsg.create(gpa, src_loc, "unable to load '{}/{s}': {s}", .{ |
| 4671 | embed_file.owner.root, | 4671 | embed_file.owner.root, |
| 4672 | embed_file.sub_file_path.toSlice(ip), | 4672 | embed_file.sub_file_path.toSlice(ip), |
| ... | @@ -4678,7 +4678,7 @@ fn reportRetryableEmbedFileError( | ... | @@ -4678,7 +4678,7 @@ fn reportRetryableEmbedFileError( |
| 4678 | { | 4678 | { |
| 4679 | comp.mutex.lock(); | 4679 | comp.mutex.lock(); |
| 4680 | defer comp.mutex.unlock(); | 4680 | defer comp.mutex.unlock(); |
| 4681 | try mod.failed_embed_files.putNoClobber(gpa, embed_file, err_msg); | 4681 | try zcu.failed_embed_files.putNoClobber(gpa, embed_file, err_msg); |
| 4682 | } | 4682 | } |
| 4683 | } | 4683 | } |
| 4684 | 4684 |
src/Type.zig+14-14| ... | @@ -3028,9 +3028,9 @@ pub fn getParentNamespace(ty: Type, zcu: *Zcu) InternPool.OptionalNamespaceIndex | ... | @@ -3028,9 +3028,9 @@ pub fn getParentNamespace(ty: Type, zcu: *Zcu) InternPool.OptionalNamespaceIndex |
| 3028 | 3028 | ||
| 3029 | // Works for vectors and vectors of integers. | 3029 | // Works for vectors and vectors of integers. |
| 3030 | pub fn minInt(ty: Type, pt: Zcu.PerThread, dest_ty: Type) !Value { | 3030 | pub fn minInt(ty: Type, pt: Zcu.PerThread, dest_ty: Type) !Value { |
| 3031 | const mod = pt.zcu; | 3031 | const zcu = pt.zcu; |
| 3032 | const scalar = try minIntScalar(ty.scalarType(mod), pt, dest_ty.scalarType(mod)); | 3032 | const scalar = try minIntScalar(ty.scalarType(zcu), pt, dest_ty.scalarType(zcu)); |
| 3033 | return if (ty.zigTypeTag(mod) == .Vector) Value.fromInterned(try pt.intern(.{ .aggregate = .{ | 3033 | return if (ty.zigTypeTag(zcu) == .Vector) Value.fromInterned(try pt.intern(.{ .aggregate = .{ |
| 3034 | .ty = dest_ty.toIntern(), | 3034 | .ty = dest_ty.toIntern(), |
| 3035 | .storage = .{ .repeated_elem = scalar.toIntern() }, | 3035 | .storage = .{ .repeated_elem = scalar.toIntern() }, |
| 3036 | } })) else scalar; | 3036 | } })) else scalar; |
| ... | @@ -3038,8 +3038,8 @@ pub fn minInt(ty: Type, pt: Zcu.PerThread, dest_ty: Type) !Value { | ... | @@ -3038,8 +3038,8 @@ pub fn minInt(ty: Type, pt: Zcu.PerThread, dest_ty: Type) !Value { |
| 3038 | 3038 | ||
| 3039 | /// Asserts that the type is an integer. | 3039 | /// Asserts that the type is an integer. |
| 3040 | pub fn minIntScalar(ty: Type, pt: Zcu.PerThread, dest_ty: Type) !Value { | 3040 | pub fn minIntScalar(ty: Type, pt: Zcu.PerThread, dest_ty: Type) !Value { |
| 3041 | const mod = pt.zcu; | 3041 | const zcu = pt.zcu; |
| 3042 | const info = ty.intInfo(mod); | 3042 | const info = ty.intInfo(zcu); |
| 3043 | if (info.signedness == .unsigned) return pt.intValue(dest_ty, 0); | 3043 | if (info.signedness == .unsigned) return pt.intValue(dest_ty, 0); |
| 3044 | if (info.bits == 0) return pt.intValue(dest_ty, -1); | 3044 | if (info.bits == 0) return pt.intValue(dest_ty, -1); |
| 3045 | 3045 | ||
| ... | @@ -3048,7 +3048,7 @@ pub fn minIntScalar(ty: Type, pt: Zcu.PerThread, dest_ty: Type) !Value { | ... | @@ -3048,7 +3048,7 @@ pub fn minIntScalar(ty: Type, pt: Zcu.PerThread, dest_ty: Type) !Value { |
| 3048 | return pt.intValue(dest_ty, n); | 3048 | return pt.intValue(dest_ty, n); |
| 3049 | } | 3049 | } |
| 3050 | 3050 | ||
| 3051 | var res = try std.math.big.int.Managed.init(mod.gpa); | 3051 | var res = try std.math.big.int.Managed.init(zcu.gpa); |
| 3052 | defer res.deinit(); | 3052 | defer res.deinit(); |
| 3053 | 3053 | ||
| 3054 | try res.setTwosCompIntLimit(.min, info.signedness, info.bits); | 3054 | try res.setTwosCompIntLimit(.min, info.signedness, info.bits); |
| ... | @@ -3059,9 +3059,9 @@ pub fn minIntScalar(ty: Type, pt: Zcu.PerThread, dest_ty: Type) !Value { | ... | @@ -3059,9 +3059,9 @@ pub fn minIntScalar(ty: Type, pt: Zcu.PerThread, dest_ty: Type) !Value { |
| 3059 | // Works for vectors and vectors of integers. | 3059 | // Works for vectors and vectors of integers. |
| 3060 | /// The returned Value will have type dest_ty. | 3060 | /// The returned Value will have type dest_ty. |
| 3061 | pub fn maxInt(ty: Type, pt: Zcu.PerThread, dest_ty: Type) !Value { | 3061 | pub fn maxInt(ty: Type, pt: Zcu.PerThread, dest_ty: Type) !Value { |
| 3062 | const mod = pt.zcu; | 3062 | const zcu = pt.zcu; |
| 3063 | const scalar = try maxIntScalar(ty.scalarType(mod), pt, dest_ty.scalarType(mod)); | 3063 | const scalar = try maxIntScalar(ty.scalarType(zcu), pt, dest_ty.scalarType(zcu)); |
| 3064 | return if (ty.zigTypeTag(mod) == .Vector) Value.fromInterned(try pt.intern(.{ .aggregate = .{ | 3064 | return if (ty.zigTypeTag(zcu) == .Vector) Value.fromInterned(try pt.intern(.{ .aggregate = .{ |
| 3065 | .ty = dest_ty.toIntern(), | 3065 | .ty = dest_ty.toIntern(), |
| 3066 | .storage = .{ .repeated_elem = scalar.toIntern() }, | 3066 | .storage = .{ .repeated_elem = scalar.toIntern() }, |
| 3067 | } })) else scalar; | 3067 | } })) else scalar; |
| ... | @@ -3546,12 +3546,12 @@ pub fn optEuBaseType(ty: Type, zcu: *const Zcu) Type { | ... | @@ -3546,12 +3546,12 @@ pub fn optEuBaseType(ty: Type, zcu: *const Zcu) Type { |
| 3546 | } | 3546 | } |
| 3547 | 3547 | ||
| 3548 | pub fn toUnsigned(ty: Type, pt: Zcu.PerThread) !Type { | 3548 | pub fn toUnsigned(ty: Type, pt: Zcu.PerThread) !Type { |
| 3549 | const mod = pt.zcu; | 3549 | const zcu = pt.zcu; |
| 3550 | return switch (ty.zigTypeTag(mod)) { | 3550 | return switch (ty.zigTypeTag(zcu)) { |
| 3551 | .Int => pt.intType(.unsigned, ty.intInfo(mod).bits), | 3551 | .Int => pt.intType(.unsigned, ty.intInfo(zcu).bits), |
| 3552 | .Vector => try pt.vectorType(.{ | 3552 | .Vector => try pt.vectorType(.{ |
| 3553 | .len = ty.vectorLen(mod), | 3553 | .len = ty.vectorLen(zcu), |
| 3554 | .child = (try ty.childType(mod).toUnsigned(pt)).toIntern(), | 3554 | .child = (try ty.childType(zcu).toUnsigned(pt)).toIntern(), |
| 3555 | }), | 3555 | }), |
| 3556 | else => unreachable, | 3556 | else => unreachable, |
| 3557 | }; | 3557 | }; |
src/Zcu/PerThread.zig+16-16| ... | @@ -1555,8 +1555,8 @@ pub fn embedFile( | ... | @@ -1555,8 +1555,8 @@ pub fn embedFile( |
| 1555 | import_string: []const u8, | 1555 | import_string: []const u8, |
| 1556 | src_loc: Zcu.LazySrcLoc, | 1556 | src_loc: Zcu.LazySrcLoc, |
| 1557 | ) !InternPool.Index { | 1557 | ) !InternPool.Index { |
| 1558 | const mod = pt.zcu; | 1558 | const zcu = pt.zcu; |
| 1559 | const gpa = mod.gpa; | 1559 | const gpa = zcu.gpa; |
| 1560 | 1560 | ||
| 1561 | if (cur_file.mod.deps.get(import_string)) |pkg| { | 1561 | if (cur_file.mod.deps.get(import_string)) |pkg| { |
| 1562 | const resolved_path = try std.fs.path.resolve(gpa, &.{ | 1562 | const resolved_path = try std.fs.path.resolve(gpa, &.{ |
| ... | @@ -1567,9 +1567,9 @@ pub fn embedFile( | ... | @@ -1567,9 +1567,9 @@ pub fn embedFile( |
| 1567 | var keep_resolved_path = false; | 1567 | var keep_resolved_path = false; |
| 1568 | defer if (!keep_resolved_path) gpa.free(resolved_path); | 1568 | defer if (!keep_resolved_path) gpa.free(resolved_path); |
| 1569 | 1569 | ||
| 1570 | const gop = try mod.embed_table.getOrPut(gpa, resolved_path); | 1570 | const gop = try zcu.embed_table.getOrPut(gpa, resolved_path); |
| 1571 | errdefer { | 1571 | errdefer { |
| 1572 | assert(std.mem.eql(u8, mod.embed_table.pop().key, resolved_path)); | 1572 | assert(std.mem.eql(u8, zcu.embed_table.pop().key, resolved_path)); |
| 1573 | keep_resolved_path = false; | 1573 | keep_resolved_path = false; |
| 1574 | } | 1574 | } |
| 1575 | if (gop.found_existing) return gop.value_ptr.*.val; | 1575 | if (gop.found_existing) return gop.value_ptr.*.val; |
| ... | @@ -1594,9 +1594,9 @@ pub fn embedFile( | ... | @@ -1594,9 +1594,9 @@ pub fn embedFile( |
| 1594 | var keep_resolved_path = false; | 1594 | var keep_resolved_path = false; |
| 1595 | defer if (!keep_resolved_path) gpa.free(resolved_path); | 1595 | defer if (!keep_resolved_path) gpa.free(resolved_path); |
| 1596 | 1596 | ||
| 1597 | const gop = try mod.embed_table.getOrPut(gpa, resolved_path); | 1597 | const gop = try zcu.embed_table.getOrPut(gpa, resolved_path); |
| 1598 | errdefer { | 1598 | errdefer { |
| 1599 | assert(std.mem.eql(u8, mod.embed_table.pop().key, resolved_path)); | 1599 | assert(std.mem.eql(u8, zcu.embed_table.pop().key, resolved_path)); |
| 1600 | keep_resolved_path = false; | 1600 | keep_resolved_path = false; |
| 1601 | } | 1601 | } |
| 1602 | if (gop.found_existing) return gop.value_ptr.*.val; | 1602 | if (gop.found_existing) return gop.value_ptr.*.val; |
| ... | @@ -1631,9 +1631,9 @@ fn newEmbedFile( | ... | @@ -1631,9 +1631,9 @@ fn newEmbedFile( |
| 1631 | result: **Zcu.EmbedFile, | 1631 | result: **Zcu.EmbedFile, |
| 1632 | src_loc: Zcu.LazySrcLoc, | 1632 | src_loc: Zcu.LazySrcLoc, |
| 1633 | ) !InternPool.Index { | 1633 | ) !InternPool.Index { |
| 1634 | const mod = pt.zcu; | 1634 | const zcu = pt.zcu; |
| 1635 | const gpa = mod.gpa; | 1635 | const gpa = zcu.gpa; |
| 1636 | const ip = &mod.intern_pool; | 1636 | const ip = &zcu.intern_pool; |
| 1637 | 1637 | ||
| 1638 | const new_file = try gpa.create(Zcu.EmbedFile); | 1638 | const new_file = try gpa.create(Zcu.EmbedFile); |
| 1639 | errdefer gpa.destroy(new_file); | 1639 | errdefer gpa.destroy(new_file); |
| ... | @@ -1655,7 +1655,7 @@ fn newEmbedFile( | ... | @@ -1655,7 +1655,7 @@ fn newEmbedFile( |
| 1655 | if (actual_read != size) return error.UnexpectedEndOfFile; | 1655 | if (actual_read != size) return error.UnexpectedEndOfFile; |
| 1656 | bytes[0][size] = 0; | 1656 | bytes[0][size] = 0; |
| 1657 | 1657 | ||
| 1658 | const comp = mod.comp; | 1658 | const comp = zcu.comp; |
| 1659 | switch (comp.cache_use) { | 1659 | switch (comp.cache_use) { |
| 1660 | .whole => |whole| if (whole.cache_manifest) |man| { | 1660 | .whole => |whole| if (whole.cache_manifest) |man| { |
| 1661 | const copied_resolved_path = try gpa.dupe(u8, resolved_path); | 1661 | const copied_resolved_path = try gpa.dupe(u8, resolved_path); |
| ... | @@ -2857,9 +2857,9 @@ pub fn errorSetFromUnsortedNames( | ... | @@ -2857,9 +2857,9 @@ pub fn errorSetFromUnsortedNames( |
| 2857 | 2857 | ||
| 2858 | /// Supports only pointers, not pointer-like optionals. | 2858 | /// Supports only pointers, not pointer-like optionals. |
| 2859 | pub fn ptrIntValue(pt: Zcu.PerThread, ty: Type, x: u64) Allocator.Error!Value { | 2859 | pub fn ptrIntValue(pt: Zcu.PerThread, ty: Type, x: u64) Allocator.Error!Value { |
| 2860 | const mod = pt.zcu; | 2860 | const zcu = pt.zcu; |
| 2861 | assert(ty.zigTypeTag(mod) == .Pointer and !ty.isSlice(mod)); | 2861 | assert(ty.zigTypeTag(zcu) == .Pointer and !ty.isSlice(zcu)); |
| 2862 | assert(x != 0 or ty.isAllowzeroPtr(mod)); | 2862 | assert(x != 0 or ty.isAllowzeroPtr(zcu)); |
| 2863 | return Value.fromInterned(try pt.intern(.{ .ptr = .{ | 2863 | return Value.fromInterned(try pt.intern(.{ .ptr = .{ |
| 2864 | .ty = ty.toIntern(), | 2864 | .ty = ty.toIntern(), |
| 2865 | .base_addr = .int, | 2865 | .base_addr = .int, |
| ... | @@ -3008,10 +3008,10 @@ pub fn intFittingRange(pt: Zcu.PerThread, min: Value, max: Value) !Type { | ... | @@ -3008,10 +3008,10 @@ pub fn intFittingRange(pt: Zcu.PerThread, min: Value, max: Value) !Type { |
| 3008 | /// twos-complement integer; otherwise in an unsigned integer. | 3008 | /// twos-complement integer; otherwise in an unsigned integer. |
| 3009 | /// Asserts that `val` is not undef. If `val` is negative, asserts that `sign` is true. | 3009 | /// Asserts that `val` is not undef. If `val` is negative, asserts that `sign` is true. |
| 3010 | pub fn intBitsForValue(pt: Zcu.PerThread, val: Value, sign: bool) u16 { | 3010 | pub fn intBitsForValue(pt: Zcu.PerThread, val: Value, sign: bool) u16 { |
| 3011 | const mod = pt.zcu; | 3011 | const zcu = pt.zcu; |
| 3012 | assert(!val.isUndef(mod)); | 3012 | assert(!val.isUndef(zcu)); |
| 3013 | 3013 | ||
| 3014 | const key = mod.intern_pool.indexToKey(val.toIntern()); | 3014 | const key = zcu.intern_pool.indexToKey(val.toIntern()); |
| 3015 | switch (key.int.storage) { | 3015 | switch (key.int.storage) { |
| 3016 | .i64 => |x| { | 3016 | .i64 => |x| { |
| 3017 | if (std.math.cast(u64, x)) |casted| return Type.smallestUnsignedBits(casted) + @intFromBool(sign); | 3017 | if (std.math.cast(u64, x)) |casted| return Type.smallestUnsignedBits(casted) + @intFromBool(sign); |
src/arch/sparc64/CodeGen.zig+40-44| ... | @@ -365,8 +365,8 @@ pub fn generate( | ... | @@ -365,8 +365,8 @@ pub fn generate( |
| 365 | 365 | ||
| 366 | fn gen(self: *Self) !void { | 366 | fn gen(self: *Self) !void { |
| 367 | const pt = self.pt; | 367 | const pt = self.pt; |
| 368 | const mod = pt.zcu; | 368 | const zcu = pt.zcu; |
| 369 | const cc = self.fn_type.fnCallingConvention(mod); | 369 | const cc = self.fn_type.fnCallingConvention(zcu); |
| 370 | if (cc != .Naked) { | 370 | if (cc != .Naked) { |
| 371 | // TODO Finish function prologue and epilogue for sparc64. | 371 | // TODO Finish function prologue and epilogue for sparc64. |
| 372 | 372 | ||
| ... | @@ -494,8 +494,8 @@ fn gen(self: *Self) !void { | ... | @@ -494,8 +494,8 @@ fn gen(self: *Self) !void { |
| 494 | 494 | ||
| 495 | fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void { | 495 | fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void { |
| 496 | const pt = self.pt; | 496 | const pt = self.pt; |
| 497 | const mod = pt.zcu; | 497 | const zcu = pt.zcu; |
| 498 | const ip = &mod.intern_pool; | 498 | const ip = &zcu.intern_pool; |
| 499 | const air_tags = self.air.instructions.items(.tag); | 499 | const air_tags = self.air.instructions.items(.tag); |
| 500 | 500 | ||
| 501 | for (body) |inst| { | 501 | for (body) |inst| { |
| ... | @@ -760,18 +760,18 @@ fn airAddSubWithOverflow(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -760,18 +760,18 @@ fn airAddSubWithOverflow(self: *Self, inst: Air.Inst.Index) !void { |
| 760 | const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; | 760 | const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 761 | const extra = self.air.extraData(Air.Bin, ty_pl.payload).data; | 761 | const extra = self.air.extraData(Air.Bin, ty_pl.payload).data; |
| 762 | const pt = self.pt; | 762 | const pt = self.pt; |
| 763 | const mod = pt.zcu; | 763 | const zcu = pt.zcu; |
| 764 | const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: { | 764 | const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: { |
| 765 | const lhs = try self.resolveInst(extra.lhs); | 765 | const lhs = try self.resolveInst(extra.lhs); |
| 766 | const rhs = try self.resolveInst(extra.rhs); | 766 | const rhs = try self.resolveInst(extra.rhs); |
| 767 | const lhs_ty = self.typeOf(extra.lhs); | 767 | const lhs_ty = self.typeOf(extra.lhs); |
| 768 | const rhs_ty = self.typeOf(extra.rhs); | 768 | const rhs_ty = self.typeOf(extra.rhs); |
| 769 | 769 | ||
| 770 | switch (lhs_ty.zigTypeTag(mod)) { | 770 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 771 | .Vector => return self.fail("TODO implement add_with_overflow/sub_with_overflow for vectors", .{}), | 771 | .Vector => return self.fail("TODO implement add_with_overflow/sub_with_overflow for vectors", .{}), |
| 772 | .Int => { | 772 | .Int => { |
| 773 | assert(lhs_ty.eql(rhs_ty, mod)); | 773 | assert(lhs_ty.eql(rhs_ty, zcu)); |
| 774 | const int_info = lhs_ty.intInfo(mod); | 774 | const int_info = lhs_ty.intInfo(zcu); |
| 775 | switch (int_info.bits) { | 775 | switch (int_info.bits) { |
| 776 | 32, 64 => { | 776 | 32, 64 => { |
| 777 | // Only say yes if the operation is | 777 | // Only say yes if the operation is |
| ... | @@ -839,9 +839,9 @@ fn airAddSubWithOverflow(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -839,9 +839,9 @@ fn airAddSubWithOverflow(self: *Self, inst: Air.Inst.Index) !void { |
| 839 | 839 | ||
| 840 | fn airAggregateInit(self: *Self, inst: Air.Inst.Index) !void { | 840 | fn airAggregateInit(self: *Self, inst: Air.Inst.Index) !void { |
| 841 | const pt = self.pt; | 841 | const pt = self.pt; |
| 842 | const mod = pt.zcu; | 842 | const zcu = pt.zcu; |
| 843 | const vector_ty = self.typeOfIndex(inst); | 843 | const vector_ty = self.typeOfIndex(inst); |
| 844 | const len = vector_ty.vectorLen(mod); | 844 | const len = vector_ty.vectorLen(zcu); |
| 845 | const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; | 845 | const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 846 | const elements = @as([]const Air.Inst.Ref, @ptrCast(self.air.extra[ty_pl.payload..][0..len])); | 846 | const elements = @as([]const Air.Inst.Ref, @ptrCast(self.air.extra[ty_pl.payload..][0..len])); |
| 847 | const result: MCValue = res: { | 847 | const result: MCValue = res: { |
| ... | @@ -874,13 +874,13 @@ fn airArrayElemVal(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -874,13 +874,13 @@ fn airArrayElemVal(self: *Self, inst: Air.Inst.Index) !void { |
| 874 | 874 | ||
| 875 | fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void { | 875 | fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void { |
| 876 | const pt = self.pt; | 876 | const pt = self.pt; |
| 877 | const mod = pt.zcu; | 877 | const zcu = pt.zcu; |
| 878 | const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; | 878 | const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; |
| 879 | const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: { | 879 | const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: { |
| 880 | const ptr_ty = self.typeOf(ty_op.operand); | 880 | const ptr_ty = self.typeOf(ty_op.operand); |
| 881 | const ptr = try self.resolveInst(ty_op.operand); | 881 | const ptr = try self.resolveInst(ty_op.operand); |
| 882 | const array_ty = ptr_ty.childType(mod); | 882 | const array_ty = ptr_ty.childType(zcu); |
| 883 | const array_len = @as(u32, @intCast(array_ty.arrayLen(mod))); | 883 | const array_len = @as(u32, @intCast(array_ty.arrayLen(zcu))); |
| 884 | const ptr_bytes = 8; | 884 | const ptr_bytes = 8; |
| 885 | const stack_offset = try self.allocMem(inst, ptr_bytes * 2, .@"8"); | 885 | const stack_offset = try self.allocMem(inst, ptr_bytes * 2, .@"8"); |
| 886 | try self.genSetStack(ptr_ty, stack_offset, ptr); | 886 | try self.genSetStack(ptr_ty, stack_offset, ptr); |
| ... | @@ -1305,11 +1305,11 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier | ... | @@ -1305,11 +1305,11 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier |
| 1305 | const args = @as([]const Air.Inst.Ref, @ptrCast(self.air.extra[extra.end .. extra.end + extra.data.args_len])); | 1305 | const args = @as([]const Air.Inst.Ref, @ptrCast(self.air.extra[extra.end .. extra.end + extra.data.args_len])); |
| 1306 | const ty = self.typeOf(callee); | 1306 | const ty = self.typeOf(callee); |
| 1307 | const pt = self.pt; | 1307 | const pt = self.pt; |
| 1308 | const mod = pt.zcu; | 1308 | const zcu = pt.zcu; |
| 1309 | const ip = &mod.intern_pool; | 1309 | const ip = &zcu.intern_pool; |
| 1310 | const fn_ty = switch (ty.zigTypeTag(mod)) { | 1310 | const fn_ty = switch (ty.zigTypeTag(zcu)) { |
| 1311 | .Fn => ty, | 1311 | .Fn => ty, |
| 1312 | .Pointer => ty.childType(mod), | 1312 | .Pointer => ty.childType(zcu), |
| 1313 | else => unreachable, | 1313 | else => unreachable, |
| 1314 | }; | 1314 | }; |
| 1315 | 1315 | ||
| ... | @@ -1361,7 +1361,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier | ... | @@ -1361,7 +1361,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier |
| 1361 | return self.fail("TODO implement calling bitcasted functions", .{}); | 1361 | return self.fail("TODO implement calling bitcasted functions", .{}); |
| 1362 | }, | 1362 | }, |
| 1363 | } else { | 1363 | } else { |
| 1364 | assert(ty.zigTypeTag(mod) == .Pointer); | 1364 | assert(ty.zigTypeTag(zcu) == .Pointer); |
| 1365 | const mcv = try self.resolveInst(callee); | 1365 | const mcv = try self.resolveInst(callee); |
| 1366 | try self.genSetReg(ty, .o7, mcv); | 1366 | try self.genSetReg(ty, .o7, mcv); |
| 1367 | 1367 | ||
| ... | @@ -1636,13 +1636,9 @@ fn airCtz(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -1636,13 +1636,9 @@ fn airCtz(self: *Self, inst: Air.Inst.Index) !void { |
| 1636 | } | 1636 | } |
| 1637 | 1637 | ||
| 1638 | fn airDbgInlineBlock(self: *Self, inst: Air.Inst.Index) !void { | 1638 | fn airDbgInlineBlock(self: *Self, inst: Air.Inst.Index) !void { |
| 1639 | const pt = self.pt; | ||
| 1640 | const mod = pt.zcu; | ||
| 1641 | const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; | 1639 | const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 1642 | const extra = self.air.extraData(Air.DbgInlineBlock, ty_pl.payload); | 1640 | const extra = self.air.extraData(Air.DbgInlineBlock, ty_pl.payload); |
| 1643 | const func = mod.funcInfo(extra.data.func); | ||
| 1644 | // TODO emit debug info for function change | 1641 | // TODO emit debug info for function change |
| 1645 | _ = func; | ||
| 1646 | try self.lowerBlock(inst, @ptrCast(self.air.extra[extra.end..][0..extra.data.body_len])); | 1642 | try self.lowerBlock(inst, @ptrCast(self.air.extra[extra.end..][0..extra.data.body_len])); |
| 1647 | } | 1643 | } |
| 1648 | 1644 | ||
| ... | @@ -1736,11 +1732,11 @@ fn airIntCast(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -1736,11 +1732,11 @@ fn airIntCast(self: *Self, inst: Air.Inst.Index) !void { |
| 1736 | return self.finishAir(inst, .dead, .{ ty_op.operand, .none, .none }); | 1732 | return self.finishAir(inst, .dead, .{ ty_op.operand, .none, .none }); |
| 1737 | 1733 | ||
| 1738 | const pt = self.pt; | 1734 | const pt = self.pt; |
| 1739 | const mod = pt.zcu; | 1735 | const zcu = pt.zcu; |
| 1740 | const operand_ty = self.typeOf(ty_op.operand); | 1736 | const operand_ty = self.typeOf(ty_op.operand); |
| 1741 | const operand = try self.resolveInst(ty_op.operand); | 1737 | const operand = try self.resolveInst(ty_op.operand); |
| 1742 | const info_a = operand_ty.intInfo(mod); | 1738 | const info_a = operand_ty.intInfo(zcu); |
| 1743 | const info_b = self.typeOfIndex(inst).intInfo(mod); | 1739 | const info_b = self.typeOfIndex(inst).intInfo(zcu); |
| 1744 | if (info_a.signedness != info_b.signedness) | 1740 | if (info_a.signedness != info_b.signedness) |
| 1745 | return self.fail("TODO gen intcast sign safety in semantic analysis", .{}); | 1741 | return self.fail("TODO gen intcast sign safety in semantic analysis", .{}); |
| 1746 | 1742 | ||
| ... | @@ -2025,18 +2021,18 @@ fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -2025,18 +2021,18 @@ fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void { |
| 2025 | const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; | 2021 | const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 2026 | const extra = self.air.extraData(Air.Bin, ty_pl.payload).data; | 2022 | const extra = self.air.extraData(Air.Bin, ty_pl.payload).data; |
| 2027 | const pt = self.pt; | 2023 | const pt = self.pt; |
| 2028 | const mod = pt.zcu; | 2024 | const zcu = pt.zcu; |
| 2029 | const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: { | 2025 | const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: { |
| 2030 | const lhs = try self.resolveInst(extra.lhs); | 2026 | const lhs = try self.resolveInst(extra.lhs); |
| 2031 | const rhs = try self.resolveInst(extra.rhs); | 2027 | const rhs = try self.resolveInst(extra.rhs); |
| 2032 | const lhs_ty = self.typeOf(extra.lhs); | 2028 | const lhs_ty = self.typeOf(extra.lhs); |
| 2033 | const rhs_ty = self.typeOf(extra.rhs); | 2029 | const rhs_ty = self.typeOf(extra.rhs); |
| 2034 | 2030 | ||
| 2035 | switch (lhs_ty.zigTypeTag(mod)) { | 2031 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 2036 | .Vector => return self.fail("TODO implement mul_with_overflow for vectors", .{}), | 2032 | .Vector => return self.fail("TODO implement mul_with_overflow for vectors", .{}), |
| 2037 | .Int => { | 2033 | .Int => { |
| 2038 | assert(lhs_ty.eql(rhs_ty, mod)); | 2034 | assert(lhs_ty.eql(rhs_ty, zcu)); |
| 2039 | const int_info = lhs_ty.intInfo(mod); | 2035 | const int_info = lhs_ty.intInfo(zcu); |
| 2040 | switch (int_info.bits) { | 2036 | switch (int_info.bits) { |
| 2041 | 1...32 => { | 2037 | 1...32 => { |
| 2042 | try self.spillConditionFlagsIfOccupied(); | 2038 | try self.spillConditionFlagsIfOccupied(); |
| ... | @@ -2090,7 +2086,7 @@ fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -2090,7 +2086,7 @@ fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void { |
| 2090 | fn airNot(self: *Self, inst: Air.Inst.Index) !void { | 2086 | fn airNot(self: *Self, inst: Air.Inst.Index) !void { |
| 2091 | const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; | 2087 | const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; |
| 2092 | const pt = self.pt; | 2088 | const pt = self.pt; |
| 2093 | const mod = pt.zcu; | 2089 | const zcu = pt.zcu; |
| 2094 | const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: { | 2090 | const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: { |
| 2095 | const operand = try self.resolveInst(ty_op.operand); | 2091 | const operand = try self.resolveInst(ty_op.operand); |
| 2096 | const operand_ty = self.typeOf(ty_op.operand); | 2092 | const operand_ty = self.typeOf(ty_op.operand); |
| ... | @@ -2106,7 +2102,7 @@ fn airNot(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -2106,7 +2102,7 @@ fn airNot(self: *Self, inst: Air.Inst.Index) !void { |
| 2106 | }; | 2102 | }; |
| 2107 | }, | 2103 | }, |
| 2108 | else => { | 2104 | else => { |
| 2109 | switch (operand_ty.zigTypeTag(mod)) { | 2105 | switch (operand_ty.zigTypeTag(zcu)) { |
| 2110 | .Bool => { | 2106 | .Bool => { |
| 2111 | const op_reg = switch (operand) { | 2107 | const op_reg = switch (operand) { |
| 2112 | .register => |r| r, | 2108 | .register => |r| r, |
| ... | @@ -2140,7 +2136,7 @@ fn airNot(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -2140,7 +2136,7 @@ fn airNot(self: *Self, inst: Air.Inst.Index) !void { |
| 2140 | }, | 2136 | }, |
| 2141 | .Vector => return self.fail("TODO bitwise not for vectors", .{}), | 2137 | .Vector => return self.fail("TODO bitwise not for vectors", .{}), |
| 2142 | .Int => { | 2138 | .Int => { |
| 2143 | const int_info = operand_ty.intInfo(mod); | 2139 | const int_info = operand_ty.intInfo(zcu); |
| 2144 | if (int_info.bits <= 64) { | 2140 | if (int_info.bits <= 64) { |
| 2145 | const op_reg = switch (operand) { | 2141 | const op_reg = switch (operand) { |
| 2146 | .register => |r| r, | 2142 | .register => |r| r, |
| ... | @@ -2323,17 +2319,17 @@ fn airShlWithOverflow(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -2323,17 +2319,17 @@ fn airShlWithOverflow(self: *Self, inst: Air.Inst.Index) !void { |
| 2323 | const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; | 2319 | const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 2324 | const extra = self.air.extraData(Air.Bin, ty_pl.payload).data; | 2320 | const extra = self.air.extraData(Air.Bin, ty_pl.payload).data; |
| 2325 | const pt = self.pt; | 2321 | const pt = self.pt; |
| 2326 | const mod = pt.zcu; | 2322 | const zcu = pt.zcu; |
| 2327 | const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: { | 2323 | const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: { |
| 2328 | const lhs = try self.resolveInst(extra.lhs); | 2324 | const lhs = try self.resolveInst(extra.lhs); |
| 2329 | const rhs = try self.resolveInst(extra.rhs); | 2325 | const rhs = try self.resolveInst(extra.rhs); |
| 2330 | const lhs_ty = self.typeOf(extra.lhs); | 2326 | const lhs_ty = self.typeOf(extra.lhs); |
| 2331 | const rhs_ty = self.typeOf(extra.rhs); | 2327 | const rhs_ty = self.typeOf(extra.rhs); |
| 2332 | 2328 | ||
| 2333 | switch (lhs_ty.zigTypeTag(mod)) { | 2329 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 2334 | .Vector => return self.fail("TODO implement mul_with_overflow for vectors", .{}), | 2330 | .Vector => return self.fail("TODO implement mul_with_overflow for vectors", .{}), |
| 2335 | .Int => { | 2331 | .Int => { |
| 2336 | const int_info = lhs_ty.intInfo(mod); | 2332 | const int_info = lhs_ty.intInfo(zcu); |
| 2337 | if (int_info.bits <= 64) { | 2333 | if (int_info.bits <= 64) { |
| 2338 | try self.spillConditionFlagsIfOccupied(); | 2334 | try self.spillConditionFlagsIfOccupied(); |
| 2339 | 2335 | ||
| ... | @@ -4328,13 +4324,13 @@ fn minMax( | ... | @@ -4328,13 +4324,13 @@ fn minMax( |
| 4328 | rhs_ty: Type, | 4324 | rhs_ty: Type, |
| 4329 | ) InnerError!MCValue { | 4325 | ) InnerError!MCValue { |
| 4330 | const pt = self.pt; | 4326 | const pt = self.pt; |
| 4331 | const mod = pt.zcu; | 4327 | const zcu = pt.zcu; |
| 4332 | assert(lhs_ty.eql(rhs_ty, mod)); | 4328 | assert(lhs_ty.eql(rhs_ty, zcu)); |
| 4333 | switch (lhs_ty.zigTypeTag(mod)) { | 4329 | switch (lhs_ty.zigTypeTag(zcu)) { |
| 4334 | .Float => return self.fail("TODO min/max on floats", .{}), | 4330 | .Float => return self.fail("TODO min/max on floats", .{}), |
| 4335 | .Vector => return self.fail("TODO min/max on vectors", .{}), | 4331 | .Vector => return self.fail("TODO min/max on vectors", .{}), |
| 4336 | .Int => { | 4332 | .Int => { |
| 4337 | const int_info = lhs_ty.intInfo(mod); | 4333 | const int_info = lhs_ty.intInfo(zcu); |
| 4338 | if (int_info.bits <= 64) { | 4334 | if (int_info.bits <= 64) { |
| 4339 | // TODO skip register setting when one of the operands | 4335 | // TODO skip register setting when one of the operands |
| 4340 | // is a small (fits in i13) immediate. | 4336 | // is a small (fits in i13) immediate. |
| ... | @@ -4556,8 +4552,8 @@ fn resolveInst(self: *Self, ref: Air.Inst.Ref) InnerError!MCValue { | ... | @@ -4556,8 +4552,8 @@ fn resolveInst(self: *Self, ref: Air.Inst.Ref) InnerError!MCValue { |
| 4556 | 4552 | ||
| 4557 | fn ret(self: *Self, mcv: MCValue) !void { | 4553 | fn ret(self: *Self, mcv: MCValue) !void { |
| 4558 | const pt = self.pt; | 4554 | const pt = self.pt; |
| 4559 | const mod = pt.zcu; | 4555 | const zcu = pt.zcu; |
| 4560 | const ret_ty = self.fn_type.fnReturnType(mod); | 4556 | const ret_ty = self.fn_type.fnReturnType(zcu); |
| 4561 | try self.setRegOrMem(ret_ty, self.ret_mcv, mcv); | 4557 | try self.setRegOrMem(ret_ty, self.ret_mcv, mcv); |
| 4562 | 4558 | ||
| 4563 | // Just add space for a branch instruction, patch this later | 4559 | // Just add space for a branch instruction, patch this later |
| ... | @@ -4744,9 +4740,9 @@ fn trunc( | ... | @@ -4744,9 +4740,9 @@ fn trunc( |
| 4744 | dest_ty: Type, | 4740 | dest_ty: Type, |
| 4745 | ) !MCValue { | 4741 | ) !MCValue { |
| 4746 | const pt = self.pt; | 4742 | const pt = self.pt; |
| 4747 | const mod = pt.zcu; | 4743 | const zcu = pt.zcu; |
| 4748 | const info_a = operand_ty.intInfo(mod); | 4744 | const info_a = operand_ty.intInfo(zcu); |
| 4749 | const info_b = dest_ty.intInfo(mod); | 4745 | const info_b = dest_ty.intInfo(zcu); |
| 4750 | 4746 | ||
| 4751 | if (info_b.bits <= 64) { | 4747 | if (info_b.bits <= 64) { |
| 4752 | const operand_reg = switch (operand) { | 4748 | const operand_reg = switch (operand) { |
src/link/Elf/ZigObject.zig+16-16| ... | @@ -1382,8 +1382,8 @@ fn updateLazySymbol( | ... | @@ -1382,8 +1382,8 @@ fn updateLazySymbol( |
| 1382 | sym: link.File.LazySymbol, | 1382 | sym: link.File.LazySymbol, |
| 1383 | symbol_index: Symbol.Index, | 1383 | symbol_index: Symbol.Index, |
| 1384 | ) !void { | 1384 | ) !void { |
| 1385 | const mod = pt.zcu; | 1385 | const zcu = pt.zcu; |
| 1386 | const gpa = mod.gpa; | 1386 | const gpa = zcu.gpa; |
| 1387 | 1387 | ||
| 1388 | var required_alignment: InternPool.Alignment = .none; | 1388 | var required_alignment: InternPool.Alignment = .none; |
| 1389 | var code_buffer = std.ArrayList(u8).init(gpa); | 1389 | var code_buffer = std.ArrayList(u8).init(gpa); |
| ... | @@ -1398,7 +1398,7 @@ fn updateLazySymbol( | ... | @@ -1398,7 +1398,7 @@ fn updateLazySymbol( |
| 1398 | break :blk try self.strtab.insert(gpa, name); | 1398 | break :blk try self.strtab.insert(gpa, name); |
| 1399 | }; | 1399 | }; |
| 1400 | 1400 | ||
| 1401 | const src = Type.fromInterned(sym.ty).srcLocOrNull(mod) orelse Zcu.LazySrcLoc.unneeded; | 1401 | const src = Type.fromInterned(sym.ty).srcLocOrNull(zcu) orelse Zcu.LazySrcLoc.unneeded; |
| 1402 | const res = try codegen.generateLazySymbol( | 1402 | const res = try codegen.generateLazySymbol( |
| 1403 | &elf_file.base, | 1403 | &elf_file.base, |
| 1404 | pt, | 1404 | pt, |
| ... | @@ -1513,7 +1513,7 @@ pub fn updateExports( | ... | @@ -1513,7 +1513,7 @@ pub fn updateExports( |
| 1513 | const tracy = trace(@src()); | 1513 | const tracy = trace(@src()); |
| 1514 | defer tracy.end(); | 1514 | defer tracy.end(); |
| 1515 | 1515 | ||
| 1516 | const mod = pt.zcu; | 1516 | const zcu = pt.zcu; |
| 1517 | const gpa = elf_file.base.comp.gpa; | 1517 | const gpa = elf_file.base.comp.gpa; |
| 1518 | const metadata = switch (exported) { | 1518 | const metadata = switch (exported) { |
| 1519 | .nav => |nav| blk: { | 1519 | .nav => |nav| blk: { |
| ... | @@ -1521,15 +1521,15 @@ pub fn updateExports( | ... | @@ -1521,15 +1521,15 @@ pub fn updateExports( |
| 1521 | break :blk self.navs.getPtr(nav).?; | 1521 | break :blk self.navs.getPtr(nav).?; |
| 1522 | }, | 1522 | }, |
| 1523 | .uav => |uav| self.uavs.getPtr(uav) orelse blk: { | 1523 | .uav => |uav| self.uavs.getPtr(uav) orelse blk: { |
| 1524 | const first_exp = mod.all_exports.items[export_indices[0]]; | 1524 | const first_exp = zcu.all_exports.items[export_indices[0]]; |
| 1525 | const res = try self.lowerUav(elf_file, pt, uav, .none, first_exp.src); | 1525 | const res = try self.lowerUav(elf_file, pt, uav, .none, first_exp.src); |
| 1526 | switch (res) { | 1526 | switch (res) { |
| 1527 | .mcv => {}, | 1527 | .mcv => {}, |
| 1528 | .fail => |em| { | 1528 | .fail => |em| { |
| 1529 | // TODO maybe it's enough to return an error here and let Zcu.processExportsInner | 1529 | // TODO maybe it's enough to return an error here and let Zcu.processExportsInner |
| 1530 | // handle the error? | 1530 | // handle the error? |
| 1531 | try mod.failed_exports.ensureUnusedCapacity(mod.gpa, 1); | 1531 | try zcu.failed_exports.ensureUnusedCapacity(zcu.gpa, 1); |
| 1532 | mod.failed_exports.putAssumeCapacityNoClobber(export_indices[0], em); | 1532 | zcu.failed_exports.putAssumeCapacityNoClobber(export_indices[0], em); |
| 1533 | return; | 1533 | return; |
| 1534 | }, | 1534 | }, |
| 1535 | } | 1535 | } |
| ... | @@ -1542,11 +1542,11 @@ pub fn updateExports( | ... | @@ -1542,11 +1542,11 @@ pub fn updateExports( |
| 1542 | const esym_shndx = self.symtab.items(.shndx)[esym_index]; | 1542 | const esym_shndx = self.symtab.items(.shndx)[esym_index]; |
| 1543 | 1543 | ||
| 1544 | for (export_indices) |export_idx| { | 1544 | for (export_indices) |export_idx| { |
| 1545 | const exp = mod.all_exports.items[export_idx]; | 1545 | const exp = zcu.all_exports.items[export_idx]; |
| 1546 | if (exp.opts.section.unwrap()) |section_name| { | 1546 | if (exp.opts.section.unwrap()) |section_name| { |
| 1547 | if (!section_name.eqlSlice(".text", &mod.intern_pool)) { | 1547 | if (!section_name.eqlSlice(".text", &zcu.intern_pool)) { |
| 1548 | try mod.failed_exports.ensureUnusedCapacity(mod.gpa, 1); | 1548 | try zcu.failed_exports.ensureUnusedCapacity(zcu.gpa, 1); |
| 1549 | mod.failed_exports.putAssumeCapacityNoClobber(export_idx, try Zcu.ErrorMsg.create( | 1549 | zcu.failed_exports.putAssumeCapacityNoClobber(export_idx, try Zcu.ErrorMsg.create( |
| 1550 | gpa, | 1550 | gpa, |
| 1551 | exp.src, | 1551 | exp.src, |
| 1552 | "Unimplemented: ExportOptions.section", | 1552 | "Unimplemented: ExportOptions.section", |
| ... | @@ -1560,8 +1560,8 @@ pub fn updateExports( | ... | @@ -1560,8 +1560,8 @@ pub fn updateExports( |
| 1560 | .strong => elf.STB_GLOBAL, | 1560 | .strong => elf.STB_GLOBAL, |
| 1561 | .weak => elf.STB_WEAK, | 1561 | .weak => elf.STB_WEAK, |
| 1562 | .link_once => { | 1562 | .link_once => { |
| 1563 | try mod.failed_exports.ensureUnusedCapacity(mod.gpa, 1); | 1563 | try zcu.failed_exports.ensureUnusedCapacity(zcu.gpa, 1); |
| 1564 | mod.failed_exports.putAssumeCapacityNoClobber(export_idx, try Zcu.ErrorMsg.create( | 1564 | zcu.failed_exports.putAssumeCapacityNoClobber(export_idx, try Zcu.ErrorMsg.create( |
| 1565 | gpa, | 1565 | gpa, |
| 1566 | exp.src, | 1566 | exp.src, |
| 1567 | "Unimplemented: GlobalLinkage.LinkOnce", | 1567 | "Unimplemented: GlobalLinkage.LinkOnce", |
| ... | @@ -1571,7 +1571,7 @@ pub fn updateExports( | ... | @@ -1571,7 +1571,7 @@ pub fn updateExports( |
| 1571 | }, | 1571 | }, |
| 1572 | }; | 1572 | }; |
| 1573 | const stt_bits: u8 = @as(u4, @truncate(esym.st_info)); | 1573 | const stt_bits: u8 = @as(u4, @truncate(esym.st_info)); |
| 1574 | const exp_name = exp.opts.name.toSlice(&mod.intern_pool); | 1574 | const exp_name = exp.opts.name.toSlice(&zcu.intern_pool); |
| 1575 | const name_off = try self.strtab.insert(gpa, exp_name); | 1575 | const name_off = try self.strtab.insert(gpa, exp_name); |
| 1576 | const global_sym_index = if (metadata.@"export"(self, exp_name)) |exp_index| | 1576 | const global_sym_index = if (metadata.@"export"(self, exp_name)) |exp_index| |
| 1577 | exp_index.* | 1577 | exp_index.* |
| ... | @@ -1626,8 +1626,8 @@ pub fn deleteExport( | ... | @@ -1626,8 +1626,8 @@ pub fn deleteExport( |
| 1626 | .nav => |nav| self.navs.getPtr(nav), | 1626 | .nav => |nav| self.navs.getPtr(nav), |
| 1627 | .uav => |uav| self.uavs.getPtr(uav), | 1627 | .uav => |uav| self.uavs.getPtr(uav), |
| 1628 | } orelse return; | 1628 | } orelse return; |
| 1629 | const mod = elf_file.base.comp.zcu.?; | 1629 | const zcu = elf_file.base.comp.zcu.?; |
| 1630 | const exp_name = name.toSlice(&mod.intern_pool); | 1630 | const exp_name = name.toSlice(&zcu.intern_pool); |
| 1631 | const esym_index = metadata.@"export"(self, exp_name) orelse return; | 1631 | const esym_index = metadata.@"export"(self, exp_name) orelse return; |
| 1632 | log.debug("deleting export '{s}'", .{exp_name}); | 1632 | log.debug("deleting export '{s}'", .{exp_name}); |
| 1633 | const esym = &self.symtab.items(.elf_sym)[esym_index.*]; | 1633 | const esym = &self.symtab.items(.elf_sym)[esym_index.*]; |
src/link/MachO/ZigObject.zig+13-13| ... | @@ -1256,7 +1256,7 @@ pub fn updateExports( | ... | @@ -1256,7 +1256,7 @@ pub fn updateExports( |
| 1256 | const tracy = trace(@src()); | 1256 | const tracy = trace(@src()); |
| 1257 | defer tracy.end(); | 1257 | defer tracy.end(); |
| 1258 | 1258 | ||
| 1259 | const mod = pt.zcu; | 1259 | const zcu = pt.zcu; |
| 1260 | const gpa = macho_file.base.comp.gpa; | 1260 | const gpa = macho_file.base.comp.gpa; |
| 1261 | const metadata = switch (exported) { | 1261 | const metadata = switch (exported) { |
| 1262 | .nav => |nav| blk: { | 1262 | .nav => |nav| blk: { |
| ... | @@ -1264,15 +1264,15 @@ pub fn updateExports( | ... | @@ -1264,15 +1264,15 @@ pub fn updateExports( |
| 1264 | break :blk self.navs.getPtr(nav).?; | 1264 | break :blk self.navs.getPtr(nav).?; |
| 1265 | }, | 1265 | }, |
| 1266 | .uav => |uav| self.uavs.getPtr(uav) orelse blk: { | 1266 | .uav => |uav| self.uavs.getPtr(uav) orelse blk: { |
| 1267 | const first_exp = mod.all_exports.items[export_indices[0]]; | 1267 | const first_exp = zcu.all_exports.items[export_indices[0]]; |
| 1268 | const res = try self.lowerUav(macho_file, pt, uav, .none, first_exp.src); | 1268 | const res = try self.lowerUav(macho_file, pt, uav, .none, first_exp.src); |
| 1269 | switch (res) { | 1269 | switch (res) { |
| 1270 | .mcv => {}, | 1270 | .mcv => {}, |
| 1271 | .fail => |em| { | 1271 | .fail => |em| { |
| 1272 | // TODO maybe it's enough to return an error here and let Zcu.processExportsInner | 1272 | // TODO maybe it's enough to return an error here and let Zcu.processExportsInner |
| 1273 | // handle the error? | 1273 | // handle the error? |
| 1274 | try mod.failed_exports.ensureUnusedCapacity(mod.gpa, 1); | 1274 | try zcu.failed_exports.ensureUnusedCapacity(zcu.gpa, 1); |
| 1275 | mod.failed_exports.putAssumeCapacityNoClobber(export_indices[0], em); | 1275 | zcu.failed_exports.putAssumeCapacityNoClobber(export_indices[0], em); |
| 1276 | return; | 1276 | return; |
| 1277 | }, | 1277 | }, |
| 1278 | } | 1278 | } |
| ... | @@ -1284,11 +1284,11 @@ pub fn updateExports( | ... | @@ -1284,11 +1284,11 @@ pub fn updateExports( |
| 1284 | const nlist = self.symtab.items(.nlist)[nlist_idx]; | 1284 | const nlist = self.symtab.items(.nlist)[nlist_idx]; |
| 1285 | 1285 | ||
| 1286 | for (export_indices) |export_idx| { | 1286 | for (export_indices) |export_idx| { |
| 1287 | const exp = mod.all_exports.items[export_idx]; | 1287 | const exp = zcu.all_exports.items[export_idx]; |
| 1288 | if (exp.opts.section.unwrap()) |section_name| { | 1288 | if (exp.opts.section.unwrap()) |section_name| { |
| 1289 | if (!section_name.eqlSlice("__text", &mod.intern_pool)) { | 1289 | if (!section_name.eqlSlice("__text", &zcu.intern_pool)) { |
| 1290 | try mod.failed_exports.ensureUnusedCapacity(mod.gpa, 1); | 1290 | try zcu.failed_exports.ensureUnusedCapacity(zcu.gpa, 1); |
| 1291 | mod.failed_exports.putAssumeCapacityNoClobber(export_idx, try Zcu.ErrorMsg.create( | 1291 | zcu.failed_exports.putAssumeCapacityNoClobber(export_idx, try Zcu.ErrorMsg.create( |
| 1292 | gpa, | 1292 | gpa, |
| 1293 | exp.src, | 1293 | exp.src, |
| 1294 | "Unimplemented: ExportOptions.section", | 1294 | "Unimplemented: ExportOptions.section", |
| ... | @@ -1298,7 +1298,7 @@ pub fn updateExports( | ... | @@ -1298,7 +1298,7 @@ pub fn updateExports( |
| 1298 | } | 1298 | } |
| 1299 | } | 1299 | } |
| 1300 | if (exp.opts.linkage == .link_once) { | 1300 | if (exp.opts.linkage == .link_once) { |
| 1301 | try mod.failed_exports.putNoClobber(mod.gpa, export_idx, try Zcu.ErrorMsg.create( | 1301 | try zcu.failed_exports.putNoClobber(zcu.gpa, export_idx, try Zcu.ErrorMsg.create( |
| 1302 | gpa, | 1302 | gpa, |
| 1303 | exp.src, | 1303 | exp.src, |
| 1304 | "Unimplemented: GlobalLinkage.link_once", | 1304 | "Unimplemented: GlobalLinkage.link_once", |
| ... | @@ -1307,7 +1307,7 @@ pub fn updateExports( | ... | @@ -1307,7 +1307,7 @@ pub fn updateExports( |
| 1307 | continue; | 1307 | continue; |
| 1308 | } | 1308 | } |
| 1309 | 1309 | ||
| 1310 | const exp_name = exp.opts.name.toSlice(&mod.intern_pool); | 1310 | const exp_name = exp.opts.name.toSlice(&zcu.intern_pool); |
| 1311 | const global_nlist_index = if (metadata.@"export"(self, exp_name)) |exp_index| | 1311 | const global_nlist_index = if (metadata.@"export"(self, exp_name)) |exp_index| |
| 1312 | exp_index.* | 1312 | exp_index.* |
| 1313 | else blk: { | 1313 | else blk: { |
| ... | @@ -1437,15 +1437,15 @@ pub fn deleteExport( | ... | @@ -1437,15 +1437,15 @@ pub fn deleteExport( |
| 1437 | exported: Zcu.Exported, | 1437 | exported: Zcu.Exported, |
| 1438 | name: InternPool.NullTerminatedString, | 1438 | name: InternPool.NullTerminatedString, |
| 1439 | ) void { | 1439 | ) void { |
| 1440 | const mod = macho_file.base.comp.zcu.?; | 1440 | const zcu = macho_file.base.comp.zcu.?; |
| 1441 | 1441 | ||
| 1442 | const metadata = switch (exported) { | 1442 | const metadata = switch (exported) { |
| 1443 | .nav => |nav| self.navs.getPtr(nav), | 1443 | .nav => |nav| self.navs.getPtr(nav), |
| 1444 | .uav => |uav| self.uavs.getPtr(uav), | 1444 | .uav => |uav| self.uavs.getPtr(uav), |
| 1445 | } orelse return; | 1445 | } orelse return; |
| 1446 | const nlist_index = metadata.@"export"(self, name.toSlice(&mod.intern_pool)) orelse return; | 1446 | const nlist_index = metadata.@"export"(self, name.toSlice(&zcu.intern_pool)) orelse return; |
| 1447 | 1447 | ||
| 1448 | log.debug("deleting export '{}'", .{name.fmt(&mod.intern_pool)}); | 1448 | log.debug("deleting export '{}'", .{name.fmt(&zcu.intern_pool)}); |
| 1449 | 1449 | ||
| 1450 | const nlist = &self.symtab.items(.nlist)[nlist_index.*]; | 1450 | const nlist = &self.symtab.items(.nlist)[nlist_index.*]; |
| 1451 | self.symtab.items(.size)[nlist_index.*] = 0; | 1451 | self.symtab.items(.size)[nlist_index.*] = 0; |
src/link/Plan9.zig+16-16| ... | @@ -317,8 +317,8 @@ pub fn createEmpty( | ... | @@ -317,8 +317,8 @@ pub fn createEmpty( |
| 317 | 317 | ||
| 318 | fn putFn(self: *Plan9, nav_index: InternPool.Nav.Index, out: FnNavOutput) !void { | 318 | fn putFn(self: *Plan9, nav_index: InternPool.Nav.Index, out: FnNavOutput) !void { |
| 319 | const gpa = self.base.comp.gpa; | 319 | const gpa = self.base.comp.gpa; |
| 320 | const mod = self.base.comp.zcu.?; | 320 | const zcu = self.base.comp.zcu.?; |
| 321 | const file_scope = mod.navFileScopeIndex(nav_index); | 321 | const file_scope = zcu.navFileScopeIndex(nav_index); |
| 322 | const fn_map_res = try self.fn_nav_table.getOrPut(gpa, file_scope); | 322 | const fn_map_res = try self.fn_nav_table.getOrPut(gpa, file_scope); |
| 323 | if (fn_map_res.found_existing) { | 323 | if (fn_map_res.found_existing) { |
| 324 | if (try fn_map_res.value_ptr.functions.fetchPut(gpa, nav_index, out)) |old_entry| { | 324 | if (try fn_map_res.value_ptr.functions.fetchPut(gpa, nav_index, out)) |old_entry| { |
| ... | @@ -326,7 +326,7 @@ fn putFn(self: *Plan9, nav_index: InternPool.Nav.Index, out: FnNavOutput) !void | ... | @@ -326,7 +326,7 @@ fn putFn(self: *Plan9, nav_index: InternPool.Nav.Index, out: FnNavOutput) !void |
| 326 | gpa.free(old_entry.value.lineinfo); | 326 | gpa.free(old_entry.value.lineinfo); |
| 327 | } | 327 | } |
| 328 | } else { | 328 | } else { |
| 329 | const file = mod.fileByIndex(file_scope); | 329 | const file = zcu.fileByIndex(file_scope); |
| 330 | const arena = self.path_arena.allocator(); | 330 | const arena = self.path_arena.allocator(); |
| 331 | // each file gets a symbol | 331 | // each file gets a symbol |
| 332 | fn_map_res.value_ptr.* = .{ | 332 | fn_map_res.value_ptr.* = .{ |
| ... | @@ -391,10 +391,10 @@ pub fn updateFunc(self: *Plan9, pt: Zcu.PerThread, func_index: InternPool.Index, | ... | @@ -391,10 +391,10 @@ pub fn updateFunc(self: *Plan9, pt: Zcu.PerThread, func_index: InternPool.Index, |
| 391 | @panic("Attempted to compile for object format that was disabled by build configuration"); | 391 | @panic("Attempted to compile for object format that was disabled by build configuration"); |
| 392 | } | 392 | } |
| 393 | 393 | ||
| 394 | const mod = pt.zcu; | 394 | const zcu = pt.zcu; |
| 395 | const gpa = mod.gpa; | 395 | const gpa = zcu.gpa; |
| 396 | const target = self.base.comp.root_mod.resolved_target.result; | 396 | const target = self.base.comp.root_mod.resolved_target.result; |
| 397 | const func = mod.funcInfo(func_index); | 397 | const func = zcu.funcInfo(func_index); |
| 398 | 398 | ||
| 399 | const atom_idx = try self.seeNav(pt, func.owner_nav); | 399 | const atom_idx = try self.seeNav(pt, func.owner_nav); |
| 400 | 400 | ||
| ... | @@ -413,7 +413,7 @@ pub fn updateFunc(self: *Plan9, pt: Zcu.PerThread, func_index: InternPool.Index, | ... | @@ -413,7 +413,7 @@ pub fn updateFunc(self: *Plan9, pt: Zcu.PerThread, func_index: InternPool.Index, |
| 413 | const res = try codegen.generateFunction( | 413 | const res = try codegen.generateFunction( |
| 414 | &self.base, | 414 | &self.base, |
| 415 | pt, | 415 | pt, |
| 416 | mod.navSrcLoc(func.owner_nav), | 416 | zcu.navSrcLoc(func.owner_nav), |
| 417 | func_index, | 417 | func_index, |
| 418 | air, | 418 | air, |
| 419 | liveness, | 419 | liveness, |
| ... | @@ -423,7 +423,7 @@ pub fn updateFunc(self: *Plan9, pt: Zcu.PerThread, func_index: InternPool.Index, | ... | @@ -423,7 +423,7 @@ pub fn updateFunc(self: *Plan9, pt: Zcu.PerThread, func_index: InternPool.Index, |
| 423 | const code = switch (res) { | 423 | const code = switch (res) { |
| 424 | .ok => try code_buffer.toOwnedSlice(), | 424 | .ok => try code_buffer.toOwnedSlice(), |
| 425 | .fail => |em| { | 425 | .fail => |em| { |
| 426 | try mod.failed_codegen.put(gpa, func.owner_nav, em); | 426 | try zcu.failed_codegen.put(gpa, func.owner_nav, em); |
| 427 | return; | 427 | return; |
| 428 | }, | 428 | }, |
| 429 | }; | 429 | }; |
| ... | @@ -952,11 +952,11 @@ pub fn freeDecl(self: *Plan9, decl_index: InternPool.DeclIndex) void { | ... | @@ -952,11 +952,11 @@ pub fn freeDecl(self: *Plan9, decl_index: InternPool.DeclIndex) void { |
| 952 | const gpa = self.base.comp.gpa; | 952 | const gpa = self.base.comp.gpa; |
| 953 | // TODO audit the lifetimes of decls table entries. It's possible to get | 953 | // TODO audit the lifetimes of decls table entries. It's possible to get |
| 954 | // freeDecl without any updateDecl in between. | 954 | // freeDecl without any updateDecl in between. |
| 955 | const mod = self.base.comp.zcu.?; | 955 | const zcu = self.base.comp.zcu.?; |
| 956 | const decl = mod.declPtr(decl_index); | 956 | const decl = zcu.declPtr(decl_index); |
| 957 | const is_fn = decl.val.isFuncBody(mod); | 957 | const is_fn = decl.val.isFuncBody(zcu); |
| 958 | if (is_fn) { | 958 | if (is_fn) { |
| 959 | const symidx_and_submap = self.fn_decl_table.get(decl.getFileScope(mod)).?; | 959 | const symidx_and_submap = self.fn_decl_table.get(decl.getFileScope(zcu)).?; |
| 960 | var submap = symidx_and_submap.functions; | 960 | var submap = symidx_and_submap.functions; |
| 961 | if (submap.fetchSwapRemove(decl_index)) |removed_entry| { | 961 | if (submap.fetchSwapRemove(decl_index)) |removed_entry| { |
| 962 | gpa.free(removed_entry.value.code); | 962 | gpa.free(removed_entry.value.code); |
| ... | @@ -1256,8 +1256,8 @@ pub fn writeSym(self: *Plan9, w: anytype, sym: aout.Sym) !void { | ... | @@ -1256,8 +1256,8 @@ pub fn writeSym(self: *Plan9, w: anytype, sym: aout.Sym) !void { |
| 1256 | } | 1256 | } |
| 1257 | 1257 | ||
| 1258 | pub fn writeSyms(self: *Plan9, buf: *std.ArrayList(u8)) !void { | 1258 | pub fn writeSyms(self: *Plan9, buf: *std.ArrayList(u8)) !void { |
| 1259 | const mod = self.base.comp.zcu.?; | 1259 | const zcu = self.base.comp.zcu.?; |
| 1260 | const ip = &mod.intern_pool; | 1260 | const ip = &zcu.intern_pool; |
| 1261 | const writer = buf.writer(); | 1261 | const writer = buf.writer(); |
| 1262 | // write __GOT | 1262 | // write __GOT |
| 1263 | try self.writeSym(writer, self.syms.items[0]); | 1263 | try self.writeSym(writer, self.syms.items[0]); |
| ... | @@ -1284,7 +1284,7 @@ pub fn writeSyms(self: *Plan9, buf: *std.ArrayList(u8)) !void { | ... | @@ -1284,7 +1284,7 @@ pub fn writeSyms(self: *Plan9, buf: *std.ArrayList(u8)) !void { |
| 1284 | try self.writeSym(writer, sym); | 1284 | try self.writeSym(writer, sym); |
| 1285 | if (self.nav_exports.get(nav_index)) |export_indices| { | 1285 | if (self.nav_exports.get(nav_index)) |export_indices| { |
| 1286 | for (export_indices) |export_idx| { | 1286 | for (export_indices) |export_idx| { |
| 1287 | const exp = mod.all_exports.items[export_idx]; | 1287 | const exp = zcu.all_exports.items[export_idx]; |
| 1288 | if (nav_metadata.getExport(self, exp.opts.name.toSlice(ip))) |exp_i| { | 1288 | if (nav_metadata.getExport(self, exp.opts.name.toSlice(ip))) |exp_i| { |
| 1289 | try self.writeSym(writer, self.syms.items[exp_i]); | 1289 | try self.writeSym(writer, self.syms.items[exp_i]); |
| 1290 | } | 1290 | } |
| ... | @@ -1323,7 +1323,7 @@ pub fn writeSyms(self: *Plan9, buf: *std.ArrayList(u8)) !void { | ... | @@ -1323,7 +1323,7 @@ pub fn writeSyms(self: *Plan9, buf: *std.ArrayList(u8)) !void { |
| 1323 | try self.writeSym(writer, sym); | 1323 | try self.writeSym(writer, sym); |
| 1324 | if (self.nav_exports.get(nav_index)) |export_indices| { | 1324 | if (self.nav_exports.get(nav_index)) |export_indices| { |
| 1325 | for (export_indices) |export_idx| { | 1325 | for (export_indices) |export_idx| { |
| 1326 | const exp = mod.all_exports.items[export_idx]; | 1326 | const exp = zcu.all_exports.items[export_idx]; |
| 1327 | if (nav_metadata.getExport(self, exp.opts.name.toSlice(ip))) |exp_i| { | 1327 | if (nav_metadata.getExport(self, exp.opts.name.toSlice(ip))) |exp_i| { |
| 1328 | const s = self.syms.items[exp_i]; | 1328 | const s = self.syms.items[exp_i]; |
| 1329 | if (mem.eql(u8, s.name, "_start")) | 1329 | if (mem.eql(u8, s.name, "_start")) |
src/link/Wasm/ZigObject.zig+8-8| ... | @@ -803,9 +803,9 @@ pub fn getUavVAddr( | ... | @@ -803,9 +803,9 @@ pub fn getUavVAddr( |
| 803 | const parent_atom_index = wasm_file.symbol_atom.get(.{ .file = zig_object.index, .index = @enumFromInt(reloc_info.parent_atom_index) }).?; | 803 | const parent_atom_index = wasm_file.symbol_atom.get(.{ .file = zig_object.index, .index = @enumFromInt(reloc_info.parent_atom_index) }).?; |
| 804 | const parent_atom = wasm_file.getAtomPtr(parent_atom_index); | 804 | const parent_atom = wasm_file.getAtomPtr(parent_atom_index); |
| 805 | const is_wasm32 = target.cpu.arch == .wasm32; | 805 | const is_wasm32 = target.cpu.arch == .wasm32; |
| 806 | const mod = wasm_file.base.comp.zcu.?; | 806 | const zcu = wasm_file.base.comp.zcu.?; |
| 807 | const ty = Type.fromInterned(mod.intern_pool.typeOf(uav)); | 807 | const ty = Type.fromInterned(zcu.intern_pool.typeOf(uav)); |
| 808 | if (ty.zigTypeTag(mod) == .Fn) { | 808 | if (ty.zigTypeTag(zcu) == .Fn) { |
| 809 | std.debug.assert(reloc_info.addend == 0); // addend not allowed for function relocations | 809 | std.debug.assert(reloc_info.addend == 0); // addend not allowed for function relocations |
| 810 | try parent_atom.relocs.append(gpa, .{ | 810 | try parent_atom.relocs.append(gpa, .{ |
| 811 | .index = target_symbol_index, | 811 | .index = target_symbol_index, |
| ... | @@ -834,13 +834,13 @@ pub fn deleteExport( | ... | @@ -834,13 +834,13 @@ pub fn deleteExport( |
| 834 | exported: Zcu.Exported, | 834 | exported: Zcu.Exported, |
| 835 | name: InternPool.NullTerminatedString, | 835 | name: InternPool.NullTerminatedString, |
| 836 | ) void { | 836 | ) void { |
| 837 | const mod = wasm_file.base.comp.zcu.?; | 837 | const zcu = wasm_file.base.comp.zcu.?; |
| 838 | const nav_index = switch (exported) { | 838 | const nav_index = switch (exported) { |
| 839 | .nav => |nav_index| nav_index, | 839 | .nav => |nav_index| nav_index, |
| 840 | .uav => @panic("TODO: implement Wasm linker code for exporting a constant value"), | 840 | .uav => @panic("TODO: implement Wasm linker code for exporting a constant value"), |
| 841 | }; | 841 | }; |
| 842 | const nav_info = zig_object.navs.getPtr(nav_index) orelse return; | 842 | const nav_info = zig_object.navs.getPtr(nav_index) orelse return; |
| 843 | if (nav_info.@"export"(zig_object, name.toSlice(&mod.intern_pool))) |sym_index| { | 843 | if (nav_info.@"export"(zig_object, name.toSlice(&zcu.intern_pool))) |sym_index| { |
| 844 | const sym = zig_object.symbol(sym_index); | 844 | const sym = zig_object.symbol(sym_index); |
| 845 | nav_info.deleteExport(sym_index); | 845 | nav_info.deleteExport(sym_index); |
| 846 | std.debug.assert(zig_object.global_syms.remove(sym.name)); | 846 | std.debug.assert(zig_object.global_syms.remove(sym.name)); |
| ... | @@ -930,8 +930,8 @@ pub fn updateExports( | ... | @@ -930,8 +930,8 @@ pub fn updateExports( |
| 930 | 930 | ||
| 931 | pub fn freeNav(zig_object: *ZigObject, wasm_file: *Wasm, nav_index: InternPool.Nav.Index) void { | 931 | pub fn freeNav(zig_object: *ZigObject, wasm_file: *Wasm, nav_index: InternPool.Nav.Index) void { |
| 932 | const gpa = wasm_file.base.comp.gpa; | 932 | const gpa = wasm_file.base.comp.gpa; |
| 933 | const mod = wasm_file.base.comp.zcu.?; | 933 | const zcu = wasm_file.base.comp.zcu.?; |
| 934 | const ip = &mod.intern_pool; | 934 | const ip = &zcu.intern_pool; |
| 935 | const nav_info = zig_object.navs.getPtr(nav_index).?; | 935 | const nav_info = zig_object.navs.getPtr(nav_index).?; |
| 936 | const atom_index = nav_info.atom; | 936 | const atom_index = nav_info.atom; |
| 937 | const atom = wasm_file.getAtomPtr(atom_index); | 937 | const atom = wasm_file.getAtomPtr(atom_index); |
| ... | @@ -956,7 +956,7 @@ pub fn freeNav(zig_object: *ZigObject, wasm_file: *Wasm, nav_index: InternPool.N | ... | @@ -956,7 +956,7 @@ pub fn freeNav(zig_object: *ZigObject, wasm_file: *Wasm, nav_index: InternPool.N |
| 956 | segment.name = &.{}; // Ensure no accidental double free | 956 | segment.name = &.{}; // Ensure no accidental double free |
| 957 | } | 957 | } |
| 958 | 958 | ||
| 959 | const nav_val = mod.navValue(nav_index).toIntern(); | 959 | const nav_val = zcu.navValue(nav_index).toIntern(); |
| 960 | if (ip.indexToKey(nav_val) == .@"extern") { | 960 | if (ip.indexToKey(nav_val) == .@"extern") { |
| 961 | std.debug.assert(zig_object.imports.remove(atom.sym_index)); | 961 | std.debug.assert(zig_object.imports.remove(atom.sym_index)); |
| 962 | } | 962 | } |
src/print_air.zig+6-6| ... | @@ -428,10 +428,10 @@ const Writer = struct { | ... | @@ -428,10 +428,10 @@ const Writer = struct { |
| 428 | } | 428 | } |
| 429 | 429 | ||
| 430 | fn writeAggregateInit(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 430 | fn writeAggregateInit(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { |
| 431 | const mod = w.pt.zcu; | 431 | const zcu = w.pt.zcu; |
| 432 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; | 432 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 433 | const vector_ty = ty_pl.ty.toType(); | 433 | const vector_ty = ty_pl.ty.toType(); |
| 434 | const len = @as(usize, @intCast(vector_ty.arrayLen(mod))); | 434 | const len = @as(usize, @intCast(vector_ty.arrayLen(zcu))); |
| 435 | const elements = @as([]const Air.Inst.Ref, @ptrCast(w.air.extra[ty_pl.payload..][0..len])); | 435 | const elements = @as([]const Air.Inst.Ref, @ptrCast(w.air.extra[ty_pl.payload..][0..len])); |
| 436 | 436 | ||
| 437 | try w.writeType(s, vector_ty); | 437 | try w.writeType(s, vector_ty); |
| ... | @@ -508,11 +508,11 @@ const Writer = struct { | ... | @@ -508,11 +508,11 @@ const Writer = struct { |
| 508 | } | 508 | } |
| 509 | 509 | ||
| 510 | fn writeSelect(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 510 | fn writeSelect(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { |
| 511 | const mod = w.pt.zcu; | 511 | const zcu = w.pt.zcu; |
| 512 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; | 512 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; |
| 513 | const extra = w.air.extraData(Air.Bin, pl_op.payload).data; | 513 | const extra = w.air.extraData(Air.Bin, pl_op.payload).data; |
| 514 | 514 | ||
| 515 | const elem_ty = w.typeOfIndex(inst).childType(mod); | 515 | const elem_ty = w.typeOfIndex(inst).childType(zcu); |
| 516 | try w.writeType(s, elem_ty); | 516 | try w.writeType(s, elem_ty); |
| 517 | try s.writeAll(", "); | 517 | try s.writeAll(", "); |
| 518 | try w.writeOperand(s, inst, 0, pl_op.operand); | 518 | try w.writeOperand(s, inst, 0, pl_op.operand); |
| ... | @@ -974,7 +974,7 @@ const Writer = struct { | ... | @@ -974,7 +974,7 @@ const Writer = struct { |
| 974 | } | 974 | } |
| 975 | 975 | ||
| 976 | fn typeOfIndex(w: *Writer, inst: Air.Inst.Index) Type { | 976 | fn typeOfIndex(w: *Writer, inst: Air.Inst.Index) Type { |
| 977 | const mod = w.pt.zcu; | 977 | const zcu = w.pt.zcu; |
| 978 | return w.air.typeOfIndex(inst, &mod.intern_pool); | 978 | return w.air.typeOfIndex(inst, &zcu.intern_pool); |
| 979 | } | 979 | } |
| 980 | }; | 980 | }; |
src/print_value.zig+4-4| ... | @@ -62,8 +62,8 @@ pub fn print( | ... | @@ -62,8 +62,8 @@ pub fn print( |
| 62 | comptime have_sema: bool, | 62 | comptime have_sema: bool, |
| 63 | sema: if (have_sema) *Sema else void, | 63 | sema: if (have_sema) *Sema else void, |
| 64 | ) (@TypeOf(writer).Error || Zcu.CompileError)!void { | 64 | ) (@TypeOf(writer).Error || Zcu.CompileError)!void { |
| 65 | const mod = pt.zcu; | 65 | const zcu = pt.zcu; |
| 66 | const ip = &mod.intern_pool; | 66 | const ip = &zcu.intern_pool; |
| 67 | switch (ip.indexToKey(val.toIntern())) { | 67 | switch (ip.indexToKey(val.toIntern())) { |
| 68 | .int_type, | 68 | .int_type, |
| 69 | .ptr_type, | 69 | .ptr_type, |
| ... | @@ -116,7 +116,7 @@ pub fn print( | ... | @@ -116,7 +116,7 @@ pub fn print( |
| 116 | enum_literal.fmt(ip), | 116 | enum_literal.fmt(ip), |
| 117 | }), | 117 | }), |
| 118 | .enum_tag => |enum_tag| { | 118 | .enum_tag => |enum_tag| { |
| 119 | const enum_type = ip.loadEnumType(val.typeOf(mod).toIntern()); | 119 | const enum_type = ip.loadEnumType(val.typeOf(zcu).toIntern()); |
| 120 | if (enum_type.tagValueIndex(ip, val.toIntern())) |tag_index| { | 120 | if (enum_type.tagValueIndex(ip, val.toIntern())) |tag_index| { |
| 121 | return writer.print(".{i}", .{enum_type.names.get(ip)[tag_index].fmt(ip)}); | 121 | return writer.print(".{i}", .{enum_type.names.get(ip)[tag_index].fmt(ip)}); |
| 122 | } | 122 | } |
| ... | @@ -173,7 +173,7 @@ pub fn print( | ... | @@ -173,7 +173,7 @@ pub fn print( |
| 173 | return; | 173 | return; |
| 174 | } | 174 | } |
| 175 | if (un.tag == .none) { | 175 | if (un.tag == .none) { |
| 176 | const backing_ty = try val.typeOf(mod).unionBackingType(pt); | 176 | const backing_ty = try val.typeOf(zcu).unionBackingType(pt); |
| 177 | try writer.print("@bitCast(@as({}, ", .{backing_ty.fmt(pt)}); | 177 | try writer.print("@bitCast(@as({}, ", .{backing_ty.fmt(pt)}); |
| 178 | try print(Value.fromInterned(un.val), writer, level - 1, pt, have_sema, sema); | 178 | try print(Value.fromInterned(un.val), writer, level - 1, pt, have_sema, sema); |
| 179 | try writer.writeAll("))"); | 179 | try writer.writeAll("))"); |