| author | |
| committer | |
| log | 78ffc70621910dcdecf5252d9ae4d9b3c8f38f9c |
| tree | befb3f8c6a8a7a038d791049d468c004f1b4ee2c |
| parent | ac77c23aff39272f99369c247ded29d960122ecd |
| parent | 1ecbc16172649c5f11c2c5173a42f04a3c7e5d2b |
| signature | Commit is signed but in an unrecognized format. |
Manual merge of https://codeberg.org/ziglang/zig/pulls/36996 to resolve
conflicts.31 files changed, 1682 insertions(+), 1527 deletions(-)
src/Air/Verify.zig+1-1| ... | @@ -41,7 +41,7 @@ pub fn run(pt: Zcu.PerThread, func_index: InternPool.Index, air: *const Air) voi | ... | @@ -41,7 +41,7 @@ pub fn run(pt: Zcu.PerThread, func_index: InternPool.Index, air: *const Air) voi |
| 41 | error.Canceled => return io.recancel(), | 41 | error.Canceled => return io.recancel(), |
| 42 | }; | 42 | }; |
| 43 | defer io.unlockStderr(); | 43 | defer io.unlockStderr(); |
| 44 | air.write(&stderr.file_writer.interface, pt, null) catch |err| switch (err) { | 44 | air.write(&stderr.file_writer.interface, zcu, null) catch |err| switch (err) { |
| 45 | error.WriteFailed => switch (stderr.file_writer.err.?) { | 45 | error.WriteFailed => switch (stderr.file_writer.err.?) { |
| 46 | error.Canceled => return io.recancel(), | 46 | error.Canceled => return io.recancel(), |
| 47 | else => {}, | 47 | else => {}, |
src/Air/print.zig+20-20| ... | @@ -9,7 +9,7 @@ const Type = @import("../Type.zig"); | ... | @@ -9,7 +9,7 @@ const Type = @import("../Type.zig"); |
| 9 | const Air = @import("../Air.zig"); | 9 | const Air = @import("../Air.zig"); |
| 10 | const InternPool = @import("../InternPool.zig"); | 10 | const InternPool = @import("../InternPool.zig"); |
| 11 | 11 | ||
| 12 | pub fn write(air: Air, stream: *std.Io.Writer, pt: Zcu.PerThread, liveness: ?Air.Liveness) !void { | 12 | pub fn write(air: Air, stream: *std.Io.Writer, zcu: *Zcu, liveness: ?Air.Liveness) !void { |
| 13 | comptime assert(build_options.enable_debug_extensions); | 13 | comptime assert(build_options.enable_debug_extensions); |
| 14 | const instruction_bytes = air.instructions.len * | 14 | const instruction_bytes = air.instructions.len * |
| 15 | // Here we don't use @sizeOf(Air.Inst.Data) because it would include | 15 | // Here we don't use @sizeOf(Air.Inst.Data) because it would include |
| ... | @@ -43,8 +43,8 @@ pub fn write(air: Air, stream: *std.Io.Writer, pt: Zcu.PerThread, liveness: ?Air | ... | @@ -43,8 +43,8 @@ pub fn write(air: Air, stream: *std.Io.Writer, pt: Zcu.PerThread, liveness: ?Air |
| 43 | // zig fmt: on | 43 | // zig fmt: on |
| 44 | 44 | ||
| 45 | var writer: Writer = .{ | 45 | var writer: Writer = .{ |
| 46 | .pt = pt, | 46 | .zcu = zcu, |
| 47 | .gpa = pt.zcu.gpa, | 47 | .gpa = zcu.comp.gpa, |
| 48 | .air = air, | 48 | .air = air, |
| 49 | .liveness = liveness, | 49 | .liveness = liveness, |
| 50 | .indent = 2, | 50 | .indent = 2, |
| ... | @@ -57,13 +57,13 @@ pub fn writeInst( | ... | @@ -57,13 +57,13 @@ pub fn writeInst( |
| 57 | air: Air, | 57 | air: Air, |
| 58 | stream: *std.Io.Writer, | 58 | stream: *std.Io.Writer, |
| 59 | inst: Air.Inst.Index, | 59 | inst: Air.Inst.Index, |
| 60 | pt: Zcu.PerThread, | 60 | zcu: *Zcu, |
| 61 | liveness: ?Air.Liveness, | 61 | liveness: ?Air.Liveness, |
| 62 | ) void { | 62 | ) void { |
| 63 | comptime assert(build_options.enable_debug_extensions); | 63 | comptime assert(build_options.enable_debug_extensions); |
| 64 | var writer: Writer = .{ | 64 | var writer: Writer = .{ |
| 65 | .pt = pt, | 65 | .zcu = zcu, |
| 66 | .gpa = pt.zcu.gpa, | 66 | .gpa = zcu.comp.gpa, |
| 67 | .air = air, | 67 | .air = air, |
| 68 | .liveness = liveness, | 68 | .liveness = liveness, |
| 69 | .indent = 2, | 69 | .indent = 2, |
| ... | @@ -89,7 +89,7 @@ pub fn dumpInst(air: Air, inst: Air.Inst.Index, pt: Zcu.PerThread, liveness: ?Ai | ... | @@ -89,7 +89,7 @@ pub fn dumpInst(air: Air, inst: Air.Inst.Index, pt: Zcu.PerThread, liveness: ?Ai |
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | const Writer = struct { | 91 | const Writer = struct { |
| 92 | pt: Zcu.PerThread, | 92 | zcu: *Zcu, |
| 93 | gpa: Allocator, | 93 | gpa: Allocator, |
| 94 | air: Air, | 94 | air: Air, |
| 95 | liveness: ?Air.Liveness, | 95 | liveness: ?Air.Liveness, |
| ... | @@ -377,7 +377,7 @@ const Writer = struct { | ... | @@ -377,7 +377,7 @@ const Writer = struct { |
| 377 | } | 377 | } |
| 378 | 378 | ||
| 379 | fn writeType(w: *Writer, s: *std.Io.Writer, ty: Type) !void { | 379 | fn writeType(w: *Writer, s: *std.Io.Writer, ty: Type) !void { |
| 380 | return ty.print(s, w.pt, null); | 380 | return ty.print(s, w.zcu, null); |
| 381 | } | 381 | } |
| 382 | 382 | ||
| 383 | fn writeTy(w: *Writer, s: *std.Io.Writer, inst: Air.Inst.Index) Error!void { | 383 | fn writeTy(w: *Writer, s: *std.Io.Writer, inst: Air.Inst.Index) Error!void { |
| ... | @@ -446,7 +446,7 @@ const Writer = struct { | ... | @@ -446,7 +446,7 @@ const Writer = struct { |
| 446 | } | 446 | } |
| 447 | 447 | ||
| 448 | fn writeAggregateInit(w: *Writer, s: *std.Io.Writer, inst: Air.Inst.Index) Error!void { | 448 | fn writeAggregateInit(w: *Writer, s: *std.Io.Writer, inst: Air.Inst.Index) Error!void { |
| 449 | const zcu = w.pt.zcu; | 449 | const zcu = w.zcu; |
| 450 | const ty_pl = w.air.instructions.items(.data)[@backingInt(inst)].ty_pl; | 450 | const ty_pl = w.air.instructions.items(.data)[@backingInt(inst)].ty_pl; |
| 451 | const vector_ty = ty_pl.ty; | 451 | const vector_ty = ty_pl.ty; |
| 452 | const len = @as(usize, @intCast(vector_ty.arrayLen(zcu))); | 452 | const len = @as(usize, @intCast(vector_ty.arrayLen(zcu))); |
| ... | @@ -539,7 +539,7 @@ const Writer = struct { | ... | @@ -539,7 +539,7 @@ const Writer = struct { |
| 539 | } | 539 | } |
| 540 | 540 | ||
| 541 | fn writeShuffleOne(w: *Writer, s: *std.Io.Writer, inst: Air.Inst.Index) Error!void { | 541 | fn writeShuffleOne(w: *Writer, s: *std.Io.Writer, inst: Air.Inst.Index) Error!void { |
| 542 | const unwrapped = w.air.unwrapShuffleOne(w.pt.zcu, inst); | 542 | const unwrapped = w.air.unwrapShuffleOne(w.zcu, inst); |
| 543 | try w.writeType(s, unwrapped.result_ty); | 543 | try w.writeType(s, unwrapped.result_ty); |
| 544 | try s.writeAll(", "); | 544 | try s.writeAll(", "); |
| 545 | try w.writeOperand(s, inst, 0, unwrapped.operand); | 545 | try w.writeOperand(s, inst, 0, unwrapped.operand); |
| ... | @@ -548,14 +548,14 @@ const Writer = struct { | ... | @@ -548,14 +548,14 @@ const Writer = struct { |
| 548 | if (mask_idx > 0) try s.writeAll(", "); | 548 | if (mask_idx > 0) try s.writeAll(", "); |
| 549 | switch (mask_elem.unwrap()) { | 549 | switch (mask_elem.unwrap()) { |
| 550 | .elem => |idx| try s.print("elem {d}", .{idx}), | 550 | .elem => |idx| try s.print("elem {d}", .{idx}), |
| 551 | .value => |val| try s.print("val {f}", .{Value.fromInterned(val).fmtValue(w.pt)}), | 551 | .value => |val| try s.print("val {f}", .{Value.fromInterned(val).fmtValue(w.zcu)}), |
| 552 | } | 552 | } |
| 553 | } | 553 | } |
| 554 | try s.writeByte(']'); | 554 | try s.writeByte(']'); |
| 555 | } | 555 | } |
| 556 | 556 | ||
| 557 | fn writeShuffleTwo(w: *Writer, s: *std.Io.Writer, inst: Air.Inst.Index) Error!void { | 557 | fn writeShuffleTwo(w: *Writer, s: *std.Io.Writer, inst: Air.Inst.Index) Error!void { |
| 558 | const unwrapped = w.air.unwrapShuffleTwo(w.pt.zcu, inst); | 558 | const unwrapped = w.air.unwrapShuffleTwo(w.zcu, inst); |
| 559 | try w.writeType(s, unwrapped.result_ty); | 559 | try w.writeType(s, unwrapped.result_ty); |
| 560 | try s.writeAll(", "); | 560 | try s.writeAll(", "); |
| 561 | try w.writeOperand(s, inst, 0, unwrapped.operand_a); | 561 | try w.writeOperand(s, inst, 0, unwrapped.operand_a); |
| ... | @@ -574,7 +574,7 @@ const Writer = struct { | ... | @@ -574,7 +574,7 @@ const Writer = struct { |
| 574 | } | 574 | } |
| 575 | 575 | ||
| 576 | fn writeSelect(w: *Writer, s: *std.Io.Writer, inst: Air.Inst.Index) Error!void { | 576 | fn writeSelect(w: *Writer, s: *std.Io.Writer, inst: Air.Inst.Index) Error!void { |
| 577 | const zcu = w.pt.zcu; | 577 | const zcu = w.zcu; |
| 578 | const pl_op = w.air.instructions.items(.data)[@backingInt(inst)].pl_op; | 578 | const pl_op = w.air.instructions.items(.data)[@backingInt(inst)].pl_op; |
| 579 | const extra = w.air.extraData(Air.Bin, pl_op.payload).data; | 579 | const extra = w.air.extraData(Air.Bin, pl_op.payload).data; |
| 580 | 580 | ||
| ... | @@ -606,7 +606,7 @@ const Writer = struct { | ... | @@ -606,7 +606,7 @@ const Writer = struct { |
| 606 | } | 606 | } |
| 607 | 607 | ||
| 608 | fn writeRuntimeNavPtr(w: *Writer, s: *std.Io.Writer, inst: Air.Inst.Index) Error!void { | 608 | fn writeRuntimeNavPtr(w: *Writer, s: *std.Io.Writer, inst: Air.Inst.Index) Error!void { |
| 609 | const ip = &w.pt.zcu.intern_pool; | 609 | const ip = &w.zcu.intern_pool; |
| 610 | const ty_nav = w.air.instructions.items(.data)[@backingInt(inst)].ty_nav; | 610 | const ty_nav = w.air.instructions.items(.data)[@backingInt(inst)].ty_nav; |
| 611 | try w.writeType(s, ty_nav.ty); | 611 | try w.writeType(s, ty_nav.ty); |
| 612 | try s.print(", '{f}'", .{ip.getNav(ty_nav.nav).fqn.fmt(ip)}); | 612 | try s.print(", '{f}'", .{ip.getNav(ty_nav.nav).fqn.fmt(ip)}); |
| ... | @@ -695,7 +695,7 @@ const Writer = struct { | ... | @@ -695,7 +695,7 @@ const Writer = struct { |
| 695 | try s.writeByte(')'); | 695 | try s.writeByte(')'); |
| 696 | } | 696 | } |
| 697 | 697 | ||
| 698 | const zcu = w.pt.zcu; | 698 | const zcu = w.zcu; |
| 699 | const ip = &zcu.intern_pool; | 699 | const ip = &zcu.intern_pool; |
| 700 | const clobbers_val: Value = .fromInterned(unwrapped_asm.clobbers); | 700 | const clobbers_val: Value = .fromInterned(unwrapped_asm.clobbers); |
| 701 | const clobbers_ty = clobbers_val.typeOf(zcu); | 701 | const clobbers_ty = clobbers_val.typeOf(zcu); |
| ... | @@ -1019,11 +1019,11 @@ const Writer = struct { | ... | @@ -1019,11 +1019,11 @@ const Writer = struct { |
| 1019 | if (@backingInt(operand) < InternPool.static_len) { | 1019 | if (@backingInt(operand) < InternPool.static_len) { |
| 1020 | return s.print("@{}", .{operand}); | 1020 | return s.print("@{}", .{operand}); |
| 1021 | } else if (operand.toInterned()) |ip_index| { | 1021 | } else if (operand.toInterned()) |ip_index| { |
| 1022 | const pt = w.pt; | 1022 | const zcu = w.zcu; |
| 1023 | const ty = Type.fromInterned(pt.zcu.intern_pool.indexToKey(ip_index).typeOf()); | 1023 | const ty = Type.fromInterned(zcu.intern_pool.indexToKey(ip_index).typeOf()); |
| 1024 | try s.print("<{f}, {f}>", .{ | 1024 | try s.print("<{f}, {f}>", .{ |
| 1025 | ty.fmt(pt), | 1025 | ty.fmt(zcu), |
| 1026 | Value.fromInterned(ip_index).fmtValue(pt), | 1026 | Value.fromInterned(ip_index).fmtValue(w.zcu), |
| 1027 | }); | 1027 | }); |
| 1028 | } else { | 1028 | } else { |
| 1029 | return w.writeInstIndex(s, operand.toIndex().?, dies); | 1029 | return w.writeInstIndex(s, operand.toIndex().?, dies); |
| ... | @@ -1042,7 +1042,7 @@ const Writer = struct { | ... | @@ -1042,7 +1042,7 @@ const Writer = struct { |
| 1042 | } | 1042 | } |
| 1043 | 1043 | ||
| 1044 | fn typeOfIndex(w: *Writer, inst: Air.Inst.Index) Type { | 1044 | fn typeOfIndex(w: *Writer, inst: Air.Inst.Index) Type { |
| 1045 | const zcu = w.pt.zcu; | 1045 | const zcu = w.zcu; |
| 1046 | return w.air.typeOfIndex(inst, &zcu.intern_pool); | 1046 | return w.air.typeOfIndex(inst, &zcu.intern_pool); |
| 1047 | } | 1047 | } |
| 1048 | }; | 1048 | }; |
src/Compilation.zig+1-1| ... | @@ -4427,7 +4427,7 @@ fn performAllTheWork( | ... | @@ -4427,7 +4427,7 @@ fn performAllTheWork( |
| 4427 | comp.windows_libs_num_done = @intCast(comp.windows_libs.count()); | 4427 | comp.windows_libs_num_done = @intCast(comp.windows_libs.count()); |
| 4428 | try misc_group.await(io); | 4428 | try misc_group.await(io); |
| 4429 | 4429 | ||
| 4430 | comp.link_queue.wait(io); | 4430 | try comp.link_queue.wait(io); |
| 4431 | } | 4431 | } |
| 4432 | 4432 | ||
| 4433 | fn dispatchPrelinkWork(comp: *Compilation, main_progress_node: std.Progress.Node) void { | 4433 | fn dispatchPrelinkWork(comp: *Compilation, main_progress_node: std.Progress.Node) void { |
src/Sema.zig+384-381| ... | @@ -910,6 +910,7 @@ const ComptimeReason = union(enum) { | ... | @@ -910,6 +910,7 @@ const ComptimeReason = union(enum) { |
| 910 | }, | 910 | }, |
| 911 | 911 | ||
| 912 | fn explain(reason: ComptimeReason, sema: *Sema, src: LazySrcLoc, err_msg: *Zcu.ErrorMsg) !void { | 912 | fn explain(reason: ComptimeReason, sema: *Sema, src: LazySrcLoc, err_msg: *Zcu.ErrorMsg) !void { |
| 913 | const zcu = sema.pt.zcu; | ||
| 913 | switch (reason) { | 914 | switch (reason) { |
| 914 | .simple => |simple| { | 915 | .simple => |simple| { |
| 915 | try sema.errNote(src, err_msg, "{s}", .{simple.message()}); | 916 | try sema.errNote(src, err_msg, "{s}", .{simple.message()}); |
| ... | @@ -920,17 +921,17 @@ const ComptimeReason = union(enum) { | ... | @@ -920,17 +921,17 @@ const ComptimeReason = union(enum) { |
| 920 | .struct_init => .{ "initializer of comptime-only struct", "must be comptime-known" }, | 921 | .struct_init => .{ "initializer of comptime-only struct", "must be comptime-known" }, |
| 921 | .tuple_init => .{ "initializer of comptime-only tuple", "must be comptime-known" }, | 922 | .tuple_init => .{ "initializer of comptime-only tuple", "must be comptime-known" }, |
| 922 | }; | 923 | }; |
| 923 | try sema.errNote(src, err_msg, "{s} '{f}' {s}", .{ pre, co.ty.fmt(sema.pt), post }); | 924 | try sema.errNote(src, err_msg, "{s} '{f}' {s}", .{ pre, co.ty.fmt(zcu), post }); |
| 924 | try sema.explainWhyTypeIsComptime(err_msg, src, co.ty); | 925 | try sema.explainWhyTypeIsComptime(err_msg, src, co.ty); |
| 925 | }, | 926 | }, |
| 926 | .comptime_only_param_ty => |co| { | 927 | .comptime_only_param_ty => |co| { |
| 927 | try sema.errNote(src, err_msg, "argument to parameter with comptime-only type '{f}' must be comptime-known", .{co.ty.fmt(sema.pt)}); | 928 | try sema.errNote(src, err_msg, "argument to parameter with comptime-only type '{f}' must be comptime-known", .{co.ty.fmt(zcu)}); |
| 928 | try sema.errNote(co.param_ty_src, err_msg, "parameter type declared here", .{}); | 929 | try sema.errNote(co.param_ty_src, err_msg, "parameter type declared here", .{}); |
| 929 | try sema.explainWhyTypeIsComptime(err_msg, src, co.ty); | 930 | try sema.explainWhyTypeIsComptime(err_msg, src, co.ty); |
| 930 | }, | 931 | }, |
| 931 | .comptime_only_ret_ty => |co| { | 932 | .comptime_only_ret_ty => |co| { |
| 932 | const function_with: []const u8 = if (co.is_generic_inst) "generic function instantiated with" else "function with"; | 933 | const function_with: []const u8 = if (co.is_generic_inst) "generic function instantiated with" else "function with"; |
| 933 | try sema.errNote(src, err_msg, "call to {s} comptime-only return type '{f}' is evaluated at comptime", .{ function_with, co.ty.fmt(sema.pt) }); | 934 | try sema.errNote(src, err_msg, "call to {s} comptime-only return type '{f}' is evaluated at comptime", .{ function_with, co.ty.fmt(zcu) }); |
| 934 | try sema.errNote(co.ret_ty_src, err_msg, "return type declared here", .{}); | 935 | try sema.errNote(co.ret_ty_src, err_msg, "return type declared here", .{}); |
| 935 | try sema.explainWhyTypeIsComptime(err_msg, src, co.ty); | 936 | try sema.explainWhyTypeIsComptime(err_msg, src, co.ty); |
| 936 | }, | 937 | }, |
| ... | @@ -1900,7 +1901,7 @@ fn analyzeBodyInner( | ... | @@ -1900,7 +1901,7 @@ fn analyzeBodyInner( |
| 1900 | const err_union_ty = sema.typeOf(err_union); | 1901 | const err_union_ty = sema.typeOf(err_union); |
| 1901 | if (err_union_ty.zigTypeTag(zcu) != .error_union) { | 1902 | if (err_union_ty.zigTypeTag(zcu) != .error_union) { |
| 1902 | return sema.failWithOwnedErrorMsg(block, msg: { | 1903 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 1903 | const msg = try sema.errMsg(operand_src, "expected error union type, found '{f}'", .{err_union_ty.fmt(pt)}); | 1904 | const msg = try sema.errMsg(operand_src, "expected error union type, found '{f}'", .{err_union_ty.fmt(zcu)}); |
| 1904 | errdefer msg.destroy(gpa); | 1905 | errdefer msg.destroy(gpa); |
| 1905 | try sema.addDeclaredHereNote(msg, err_union_ty); | 1906 | try sema.addDeclaredHereNote(msg, err_union_ty); |
| 1906 | try sema.errNote(operand_src, msg, "consider omitting 'try'", .{}); | 1907 | try sema.errNote(operand_src, msg, "consider omitting 'try'", .{}); |
| ... | @@ -2365,7 +2366,7 @@ pub fn failWithTooLargeShiftAmount( | ... | @@ -2365,7 +2366,7 @@ pub fn failWithTooLargeShiftAmount( |
| 2365 | const msg = try sema.errMsg( | 2366 | const msg = try sema.errMsg( |
| 2366 | shift_src, | 2367 | shift_src, |
| 2367 | "shift amount '{f}' is too large for operand type '{f}'", | 2368 | "shift amount '{f}' is too large for operand type '{f}'", |
| 2368 | .{ shift_amt.fmtValueSema(sema.pt, sema), operand_ty.fmt(sema.pt) }, | 2369 | .{ shift_amt.fmtValueSema(sema), operand_ty.fmt(sema.pt.zcu) }, |
| 2369 | ); | 2370 | ); |
| 2370 | errdefer msg.destroy(sema.gpa); | 2371 | errdefer msg.destroy(sema.gpa); |
| 2371 | if (vector_index) |i| try sema.errNote(shift_src, msg, "when computing vector element at index '{d}'", .{i}); | 2372 | if (vector_index) |i| try sema.errNote(shift_src, msg, "when computing vector element at index '{d}'", .{i}); |
| ... | @@ -2375,7 +2376,7 @@ pub fn failWithTooLargeShiftAmount( | ... | @@ -2375,7 +2376,7 @@ pub fn failWithTooLargeShiftAmount( |
| 2375 | 2376 | ||
| 2376 | pub fn failWithNegativeShiftAmount(sema: *Sema, block: *Block, src: LazySrcLoc, shift_amt: Value, vector_index: ?usize) CompileError { | 2377 | pub fn failWithNegativeShiftAmount(sema: *Sema, block: *Block, src: LazySrcLoc, shift_amt: Value, vector_index: ?usize) CompileError { |
| 2377 | return sema.failWithOwnedErrorMsg(block, msg: { | 2378 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 2378 | const msg = try sema.errMsg(src, "shift by negative amount '{f}'", .{shift_amt.fmtValueSema(sema.pt, sema)}); | 2379 | const msg = try sema.errMsg(src, "shift by negative amount '{f}'", .{shift_amt.fmtValueSema(sema)}); |
| 2379 | errdefer msg.destroy(sema.gpa); | 2380 | errdefer msg.destroy(sema.gpa); |
| 2380 | if (vector_index) |i| try sema.errNote(src, msg, "when computing vector element at index '{d}'", .{i}); | 2381 | if (vector_index) |i| try sema.errNote(src, msg, "when computing vector element at index '{d}'", .{i}); |
| 2381 | break :msg msg; | 2382 | break :msg msg; |
| ... | @@ -2396,9 +2397,9 @@ pub fn failWithUnsupportedComptimeShiftAmount(sema: *Sema, block: *Block, src: L | ... | @@ -2396,9 +2397,9 @@ pub fn failWithUnsupportedComptimeShiftAmount(sema: *Sema, block: *Block, src: L |
| 2396 | } | 2397 | } |
| 2397 | 2398 | ||
| 2398 | fn failWithModRemNegative(sema: *Sema, block: *Block, src: LazySrcLoc, lhs_ty: Type, rhs_ty: Type) CompileError { | 2399 | fn failWithModRemNegative(sema: *Sema, block: *Block, src: LazySrcLoc, lhs_ty: Type, rhs_ty: Type) CompileError { |
| 2399 | const pt = sema.pt; | 2400 | const zcu = sema.pt.zcu; |
| 2400 | return sema.fail(block, src, "remainder division with '{f}' and '{f}': signed integers and floats must use @rem or @mod", .{ | 2401 | return sema.fail(block, src, "remainder division with '{f}' and '{f}': signed integers and floats must use @rem or @mod", .{ |
| 2401 | lhs_ty.fmt(pt), rhs_ty.fmt(pt), | 2402 | lhs_ty.fmt(zcu), rhs_ty.fmt(zcu), |
| 2402 | }); | 2403 | }); |
| 2403 | } | 2404 | } |
| 2404 | 2405 | ||
| ... | @@ -2420,7 +2421,7 @@ fn failWithInvalidSwitchTagCapture(sema: *Sema, block: *Block, tag_capture_src: | ... | @@ -2420,7 +2421,7 @@ fn failWithInvalidSwitchTagCapture(sema: *Sema, block: *Block, tag_capture_src: |
| 2420 | } | 2421 | } |
| 2421 | return sema.failWithOwnedErrorMsg(block, msg: { | 2422 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 2422 | const msg = try sema.errMsg(tag_capture_src, "cannot capture tag of non-union type '{f}'", .{ | 2423 | const msg = try sema.errMsg(tag_capture_src, "cannot capture tag of non-union type '{f}'", .{ |
| 2423 | operand_ty.fmt(pt), | 2424 | operand_ty.fmt(zcu), |
| 2424 | }); | 2425 | }); |
| 2425 | errdefer msg.destroy(sema.gpa); | 2426 | errdefer msg.destroy(sema.gpa); |
| 2426 | try sema.addDeclaredHereNote(msg, operand_ty); | 2427 | try sema.addDeclaredHereNote(msg, operand_ty); |
| ... | @@ -2439,7 +2440,7 @@ fn failWithAmbiguousBackingIntType( | ... | @@ -2439,7 +2440,7 @@ fn failWithAmbiguousBackingIntType( |
| 2439 | const zcu = pt.zcu; | 2440 | const zcu = pt.zcu; |
| 2440 | return sema.failWithOwnedErrorMsg(block, msg: { | 2441 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 2441 | const msg = try sema.errMsg(src, "{s} is ambiguous for type '{f}'", .{ | 2442 | const msg = try sema.errMsg(src, "{s} is ambiguous for type '{f}'", .{ |
| 2442 | builtin_name, int_backed_ty.fmt(pt), | 2443 | builtin_name, int_backed_ty.fmt(zcu), |
| 2443 | }); | 2444 | }); |
| 2444 | errdefer msg.destroy(sema.gpa); | 2445 | errdefer msg.destroy(sema.gpa); |
| 2445 | try sema.errNote(int_backed_ty.srcLoc(zcu), msg, "backing integer type of {t} is inferred", .{ | 2446 | try sema.errNote(int_backed_ty.srcLoc(zcu), msg, "backing integer type of {t} is inferred", .{ |
| ... | @@ -2451,13 +2452,13 @@ fn failWithAmbiguousBackingIntType( | ... | @@ -2451,13 +2452,13 @@ fn failWithAmbiguousBackingIntType( |
| 2451 | } | 2452 | } |
| 2452 | 2453 | ||
| 2453 | fn failWithExpectedOptionalType(sema: *Sema, block: *Block, src: LazySrcLoc, non_optional_ty: Type) CompileError { | 2454 | fn failWithExpectedOptionalType(sema: *Sema, block: *Block, src: LazySrcLoc, non_optional_ty: Type) CompileError { |
| 2454 | const pt = sema.pt; | 2455 | const zcu = sema.pt.zcu; |
| 2455 | const msg = msg: { | 2456 | const msg = msg: { |
| 2456 | const msg = try sema.errMsg(src, "expected optional type, found '{f}'", .{ | 2457 | const msg = try sema.errMsg(src, "expected optional type, found '{f}'", .{ |
| 2457 | non_optional_ty.fmt(pt), | 2458 | non_optional_ty.fmt(zcu), |
| 2458 | }); | 2459 | }); |
| 2459 | errdefer msg.destroy(sema.gpa); | 2460 | errdefer msg.destroy(sema.gpa); |
| 2460 | if (non_optional_ty.zigTypeTag(pt.zcu) == .error_union) { | 2461 | if (non_optional_ty.zigTypeTag(zcu) == .error_union) { |
| 2461 | try sema.errNote(src, msg, "consider using 'try', 'catch', or 'if'", .{}); | 2462 | try sema.errNote(src, msg, "consider using 'try', 'catch', or 'if'", .{}); |
| 2462 | } | 2463 | } |
| 2463 | try addDeclaredHereNote(sema, msg, non_optional_ty); | 2464 | try addDeclaredHereNote(sema, msg, non_optional_ty); |
| ... | @@ -2467,15 +2468,14 @@ fn failWithExpectedOptionalType(sema: *Sema, block: *Block, src: LazySrcLoc, non | ... | @@ -2467,15 +2468,14 @@ fn failWithExpectedOptionalType(sema: *Sema, block: *Block, src: LazySrcLoc, non |
| 2467 | } | 2468 | } |
| 2468 | 2469 | ||
| 2469 | fn failWithArrayInitNotSupported(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) CompileError { | 2470 | fn failWithArrayInitNotSupported(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) CompileError { |
| 2470 | const pt = sema.pt; | 2471 | const zcu = sema.pt.zcu; |
| 2471 | const zcu = pt.zcu; | ||
| 2472 | const msg = msg: { | 2472 | const msg = msg: { |
| 2473 | const msg = try sema.errMsg(src, "type '{f}' does not support array initialization syntax", .{ | 2473 | const msg = try sema.errMsg(src, "type '{f}' does not support array initialization syntax", .{ |
| 2474 | ty.fmt(pt), | 2474 | ty.fmt(zcu), |
| 2475 | }); | 2475 | }); |
| 2476 | errdefer msg.destroy(sema.gpa); | 2476 | errdefer msg.destroy(sema.gpa); |
| 2477 | if (ty.isSlice(zcu)) { | 2477 | if (ty.isSlice(zcu)) { |
| 2478 | try sema.errNote(src, msg, "inferred array length is specified with an underscore: '[_]{f}'", .{ty.childType(zcu).fmt(pt)}); | 2478 | try sema.errNote(src, msg, "inferred array length is specified with an underscore: '[_]{f}'", .{ty.childType(zcu).fmt(zcu)}); |
| 2479 | } | 2479 | } |
| 2480 | break :msg msg; | 2480 | break :msg msg; |
| 2481 | }; | 2481 | }; |
| ... | @@ -2483,17 +2483,17 @@ fn failWithArrayInitNotSupported(sema: *Sema, block: *Block, src: LazySrcLoc, ty | ... | @@ -2483,17 +2483,17 @@ fn failWithArrayInitNotSupported(sema: *Sema, block: *Block, src: LazySrcLoc, ty |
| 2483 | } | 2483 | } |
| 2484 | 2484 | ||
| 2485 | fn failWithStructInitNotSupported(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) CompileError { | 2485 | fn failWithStructInitNotSupported(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) CompileError { |
| 2486 | const pt = sema.pt; | 2486 | const zcu = sema.pt.zcu; |
| 2487 | return sema.fail(block, src, "type '{f}' does not support struct initialization syntax", .{ | 2487 | return sema.fail(block, src, "type '{f}' does not support struct initialization syntax", .{ |
| 2488 | ty.fmt(pt), | 2488 | ty.fmt(zcu), |
| 2489 | }); | 2489 | }); |
| 2490 | } | 2490 | } |
| 2491 | 2491 | ||
| 2492 | pub fn failWithIntegerOverflow(sema: *Sema, block: *Block, src: LazySrcLoc, int_ty: Type, val: Value, vector_index: ?usize) CompileError { | 2492 | pub fn failWithIntegerOverflow(sema: *Sema, block: *Block, src: LazySrcLoc, int_ty: Type, val: Value, vector_index: ?usize) CompileError { |
| 2493 | const pt = sema.pt; | 2493 | const zcu = sema.pt.zcu; |
| 2494 | return sema.failWithOwnedErrorMsg(block, msg: { | 2494 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 2495 | const msg = try sema.errMsg(src, "overflow of integer type '{f}' with value '{f}'", .{ | 2495 | const msg = try sema.errMsg(src, "overflow of integer type '{f}' with value '{f}'", .{ |
| 2496 | int_ty.fmt(pt), val.fmtValueSema(pt, sema), | 2496 | int_ty.fmt(zcu), val.fmtValueSema(sema), |
| 2497 | }); | 2497 | }); |
| 2498 | errdefer msg.destroy(sema.gpa); | 2498 | errdefer msg.destroy(sema.gpa); |
| 2499 | if (vector_index) |i| try sema.errNote(src, msg, "when computing vector element at index '{d}'", .{i}); | 2499 | if (vector_index) |i| try sema.errNote(src, msg, "when computing vector element at index '{d}'", .{i}); |
| ... | @@ -2542,7 +2542,7 @@ fn failWithInvalidFieldAccess( | ... | @@ -2542,7 +2542,7 @@ fn failWithInvalidFieldAccess( |
| 2542 | const child_ty = inner_ty.optionalChild(zcu); | 2542 | const child_ty = inner_ty.optionalChild(zcu); |
| 2543 | if (!typeSupportsFieldAccess(zcu, child_ty, field_name)) break :opt; | 2543 | if (!typeSupportsFieldAccess(zcu, child_ty, field_name)) break :opt; |
| 2544 | const msg = msg: { | 2544 | const msg = msg: { |
| 2545 | const msg = try sema.errMsg(src, "optional type '{f}' does not support field access", .{object_ty.fmt(pt)}); | 2545 | const msg = try sema.errMsg(src, "optional type '{f}' does not support field access", .{object_ty.fmt(zcu)}); |
| 2546 | errdefer msg.destroy(sema.gpa); | 2546 | errdefer msg.destroy(sema.gpa); |
| 2547 | try sema.errNote(src, msg, "consider using '.?', 'orelse', or 'if'", .{}); | 2547 | try sema.errNote(src, msg, "consider using '.?', 'orelse', or 'if'", .{}); |
| 2548 | break :msg msg; | 2548 | break :msg msg; |
| ... | @@ -2552,14 +2552,14 @@ fn failWithInvalidFieldAccess( | ... | @@ -2552,14 +2552,14 @@ fn failWithInvalidFieldAccess( |
| 2552 | const child_ty = inner_ty.errorUnionPayload(zcu); | 2552 | const child_ty = inner_ty.errorUnionPayload(zcu); |
| 2553 | if (!typeSupportsFieldAccess(zcu, child_ty, field_name)) break :err; | 2553 | if (!typeSupportsFieldAccess(zcu, child_ty, field_name)) break :err; |
| 2554 | const msg = msg: { | 2554 | const msg = msg: { |
| 2555 | const msg = try sema.errMsg(src, "error union type '{f}' does not support field access", .{object_ty.fmt(pt)}); | 2555 | const msg = try sema.errMsg(src, "error union type '{f}' does not support field access", .{object_ty.fmt(zcu)}); |
| 2556 | errdefer msg.destroy(sema.gpa); | 2556 | errdefer msg.destroy(sema.gpa); |
| 2557 | try sema.errNote(src, msg, "consider using 'try', 'catch', or 'if'", .{}); | 2557 | try sema.errNote(src, msg, "consider using 'try', 'catch', or 'if'", .{}); |
| 2558 | break :msg msg; | 2558 | break :msg msg; |
| 2559 | }; | 2559 | }; |
| 2560 | return sema.failWithOwnedErrorMsg(block, msg); | 2560 | return sema.failWithOwnedErrorMsg(block, msg); |
| 2561 | } | 2561 | } |
| 2562 | return sema.fail(block, src, "type '{f}' does not support field access", .{object_ty.fmt(pt)}); | 2562 | return sema.fail(block, src, "type '{f}' does not support field access", .{object_ty.fmt(zcu)}); |
| 2563 | } | 2563 | } |
| 2564 | 2564 | ||
| 2565 | fn typeSupportsFieldAccess(zcu: *const Zcu, ty: Type, field_name: InternPool.NullTerminatedString) bool { | 2565 | fn typeSupportsFieldAccess(zcu: *const Zcu, ty: Type, field_name: InternPool.NullTerminatedString) bool { |
| ... | @@ -2649,20 +2649,20 @@ pub fn errMsg( | ... | @@ -2649,20 +2649,20 @@ pub fn errMsg( |
| 2649 | } | 2649 | } |
| 2650 | 2650 | ||
| 2651 | fn typeMismatchErrMsg(sema: *Sema, src: LazySrcLoc, expected: Type, found: Type) Allocator.Error!*Zcu.ErrorMsg { | 2651 | fn typeMismatchErrMsg(sema: *Sema, src: LazySrcLoc, expected: Type, found: Type) Allocator.Error!*Zcu.ErrorMsg { |
| 2652 | const pt = sema.pt; | 2652 | const zcu = sema.pt.zcu; |
| 2653 | var cmp: Type.Comparison = try .init(&.{ expected, found }, pt); | 2653 | var cmp: Type.Comparison = try .init(&.{ expected, found }, zcu); |
| 2654 | defer cmp.deinit(pt); | 2654 | defer cmp.deinit(zcu.comp.gpa); |
| 2655 | 2655 | ||
| 2656 | const msg = try sema.errMsg(src, "expected type '{f}', found '{f}'", .{ | 2656 | const msg = try sema.errMsg(src, "expected type '{f}', found '{f}'", .{ |
| 2657 | cmp.fmtType(expected, pt), | 2657 | cmp.fmtType(expected, zcu), |
| 2658 | cmp.fmtType(found, pt), | 2658 | cmp.fmtType(found, zcu), |
| 2659 | }); | 2659 | }); |
| 2660 | errdefer msg.destroy(sema.gpa); | 2660 | errdefer msg.destroy(sema.gpa); |
| 2661 | 2661 | ||
| 2662 | for (cmp.type_dedupe_cache.keys(), cmp.type_dedupe_cache.values()) |ty, value| { | 2662 | for (cmp.type_dedupe_cache.keys(), cmp.type_dedupe_cache.values()) |ty, value| { |
| 2663 | if (value == .dont_dedupe) continue; | 2663 | if (value == .dont_dedupe) continue; |
| 2664 | const placeholder = value.dedupe; | 2664 | const placeholder = value.dedupe; |
| 2665 | try sema.errNote(src, msg, "{f} = {f}", .{ placeholder, ty.fmt(pt) }); | 2665 | try sema.errNote(src, msg, "{f} = {f}", .{ placeholder, ty.fmt(zcu) }); |
| 2666 | } | 2666 | } |
| 2667 | 2667 | ||
| 2668 | return msg; | 2668 | return msg; |
| ... | @@ -2678,7 +2678,7 @@ pub fn fail( | ... | @@ -2678,7 +2678,7 @@ pub fn fail( |
| 2678 | const err_msg = try sema.errMsg(src, format, args); | 2678 | const err_msg = try sema.errMsg(src, format, args); |
| 2679 | inline for (args) |arg| { | 2679 | inline for (args) |arg| { |
| 2680 | if (@TypeOf(arg) == Type.Formatter) { | 2680 | if (@TypeOf(arg) == Type.Formatter) { |
| 2681 | try addDeclaredHereNote(sema, err_msg, arg.data.ty); | 2681 | try addDeclaredHereNote(sema, err_msg, arg.ty); |
| 2682 | } | 2682 | } |
| 2683 | } | 2683 | } |
| 2684 | return sema.failWithOwnedErrorMsg(block, err_msg); | 2684 | return sema.failWithOwnedErrorMsg(block, err_msg); |
| ... | @@ -3152,11 +3152,11 @@ fn validateDeref( | ... | @@ -3152,11 +3152,11 @@ fn validateDeref( |
| 3152 | const zcu = pt.zcu; | 3152 | const zcu = pt.zcu; |
| 3153 | const ip = &zcu.intern_pool; | 3153 | const ip = &zcu.intern_pool; |
| 3154 | if (ty.zigTypeTag(zcu) != .pointer) { | 3154 | if (ty.zigTypeTag(zcu) != .pointer) { |
| 3155 | return sema.fail(block, src, "cannot dereference non-pointer type '{f}'", .{ty.fmt(pt)}); | 3155 | return sema.fail(block, src, "cannot dereference non-pointer type '{f}'", .{ty.fmt(zcu)}); |
| 3156 | } | 3156 | } |
| 3157 | const size = ty.ptrSize(zcu); | 3157 | const size = ty.ptrSize(zcu); |
| 3158 | switch (size) { | 3158 | switch (size) { |
| 3159 | .many => return sema.fail(block, src, "index syntax required for unknown-length pointer type '{f}'", .{ty.fmt(pt)}), | 3159 | .many => return sema.fail(block, src, "index syntax required for unknown-length pointer type '{f}'", .{ty.fmt(zcu)}), |
| 3160 | .one, .c, .slice => {}, | 3160 | .one, .c, .slice => {}, |
| 3161 | } | 3161 | } |
| 3162 | if (sema.resolveValue(ref)) |val| { | 3162 | if (sema.resolveValue(ref)) |val| { |
| ... | @@ -3192,11 +3192,11 @@ fn ensureResultUsed( | ... | @@ -3192,11 +3192,11 @@ fn ensureResultUsed( |
| 3192 | switch (ty.zigTypeTag(zcu)) { | 3192 | switch (ty.zigTypeTag(zcu)) { |
| 3193 | .void, .noreturn => return, | 3193 | .void, .noreturn => return, |
| 3194 | .error_set => { | 3194 | .error_set => { |
| 3195 | return sema.fail(block, src, "error set of type '{f}' is ignored", .{ty.fmt(pt)}); | 3195 | return sema.fail(block, src, "error set of type '{f}' is ignored", .{ty.fmt(zcu)}); |
| 3196 | }, | 3196 | }, |
| 3197 | .error_union => { | 3197 | .error_union => { |
| 3198 | const msg = msg: { | 3198 | const msg = msg: { |
| 3199 | const msg = try sema.errMsg(src, "error union of type '{f}' is ignored", .{ty.fmt(pt)}); | 3199 | const msg = try sema.errMsg(src, "error union of type '{f}' is ignored", .{ty.fmt(zcu)}); |
| 3200 | errdefer msg.destroy(sema.gpa); | 3200 | errdefer msg.destroy(sema.gpa); |
| 3201 | try sema.errNote(src, msg, "consider using 'try', 'catch', or 'if'", .{}); | 3201 | try sema.errNote(src, msg, "consider using 'try', 'catch', or 'if'", .{}); |
| 3202 | break :msg msg; | 3202 | break :msg msg; |
| ... | @@ -3205,7 +3205,7 @@ fn ensureResultUsed( | ... | @@ -3205,7 +3205,7 @@ fn ensureResultUsed( |
| 3205 | }, | 3205 | }, |
| 3206 | else => { | 3206 | else => { |
| 3207 | const msg = msg: { | 3207 | const msg = msg: { |
| 3208 | const msg = try sema.errMsg(src, "value of type '{f}' ignored", .{ty.fmt(pt)}); | 3208 | const msg = try sema.errMsg(src, "value of type '{f}' ignored", .{ty.fmt(zcu)}); |
| 3209 | errdefer msg.destroy(sema.gpa); | 3209 | errdefer msg.destroy(sema.gpa); |
| 3210 | try sema.errNote(src, msg, "all non-void values must be used", .{}); | 3210 | try sema.errNote(src, msg, "all non-void values must be used", .{}); |
| 3211 | try sema.errNote(src, msg, "to discard the value, assign it to '_'", .{}); | 3211 | try sema.errNote(src, msg, "to discard the value, assign it to '_'", .{}); |
| ... | @@ -3467,7 +3467,7 @@ fn zirMakePtrConst(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro | ... | @@ -3467,7 +3467,7 @@ fn zirMakePtrConst(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro |
| 3467 | // The value was initialized through RLS, so we didn't detect the runtime condition earlier. | 3467 | // The value was initialized through RLS, so we didn't detect the runtime condition earlier. |
| 3468 | // TODO: source location of runtime control flow | 3468 | // TODO: source location of runtime control flow |
| 3469 | const init_src = block.src(.{ .node_offset_var_decl_init = inst_data.src_node }); | 3469 | const init_src = block.src(.{ .node_offset_var_decl_init = inst_data.src_node }); |
| 3470 | return sema.fail(block, init_src, "value with comptime-only type '{f}' depends on runtime control flow", .{elem_ty.fmt(pt)}); | 3470 | return sema.fail(block, init_src, "value with comptime-only type '{f}' depends on runtime control flow", .{elem_ty.fmt(zcu)}); |
| 3471 | } | 3471 | } |
| 3472 | 3472 | ||
| 3473 | // This is a runtime value. | 3473 | // This is a runtime value. |
| ... | @@ -3988,7 +3988,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com | ... | @@ -3988,7 +3988,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com |
| 3988 | // The alloc wasn't comptime-known per the above logic, so the | 3988 | // The alloc wasn't comptime-known per the above logic, so the |
| 3989 | // type cannot be comptime-only. | 3989 | // type cannot be comptime-only. |
| 3990 | // TODO: source location of runtime control flow | 3990 | // TODO: source location of runtime control flow |
| 3991 | return sema.fail(block, src, "value with comptime-only type '{f}' depends on runtime control flow", .{final_elem_ty.fmt(pt)}); | 3991 | return sema.fail(block, src, "value with comptime-only type '{f}' depends on runtime control flow", .{final_elem_ty.fmt(zcu)}); |
| 3992 | } | 3992 | } |
| 3993 | if (sema.func_is_naked and final_elem_ty.hasRuntimeBits(zcu)) { | 3993 | if (sema.func_is_naked and final_elem_ty.hasRuntimeBits(zcu)) { |
| 3994 | const mut_src = block.src(.{ .node_offset_store_ptr = inst_data.src_node }); | 3994 | const mut_src = block.src(.{ .node_offset_store_ptr = inst_data.src_node }); |
| ... | @@ -4088,7 +4088,7 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -4088,7 +4088,7 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 4088 | if (!object_ty.isIndexable(zcu)) { | 4088 | if (!object_ty.isIndexable(zcu)) { |
| 4089 | // Instead of using checkIndexable we customize this error. | 4089 | // Instead of using checkIndexable we customize this error. |
| 4090 | const msg = msg: { | 4090 | const msg = msg: { |
| 4091 | const msg = try sema.errMsg(arg_src, "type '{f}' is not indexable and not a range", .{object_ty.fmt(pt)}); | 4091 | const msg = try sema.errMsg(arg_src, "type '{f}' is not indexable and not a range", .{object_ty.fmt(zcu)}); |
| 4092 | errdefer msg.destroy(sema.gpa); | 4092 | errdefer msg.destroy(sema.gpa); |
| 4093 | try sema.errNote(arg_src, msg, "for loop operand must be a range, array, slice, tuple, or vector", .{}); | 4093 | try sema.errNote(arg_src, msg, "for loop operand must be a range, array, slice, tuple, or vector", .{}); |
| 4094 | 4094 | ||
| ... | @@ -4127,10 +4127,10 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -4127,10 +4127,10 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 4127 | .input_index = len_idx, | 4127 | .input_index = len_idx, |
| 4128 | } }); | 4128 | } }); |
| 4129 | try sema.errNote(a_src, msg, "length {f} here", .{ | 4129 | try sema.errNote(a_src, msg, "length {f} here", .{ |
| 4130 | v.fmtValueSema(pt, sema), | 4130 | v.fmtValueSema(sema), |
| 4131 | }); | 4131 | }); |
| 4132 | try sema.errNote(arg_src, msg, "length {f} here", .{ | 4132 | try sema.errNote(arg_src, msg, "length {f} here", .{ |
| 4133 | arg_val.fmtValueSema(pt, sema), | 4133 | arg_val.fmtValueSema(sema), |
| 4134 | }); | 4134 | }); |
| 4135 | break :msg msg; | 4135 | break :msg msg; |
| 4136 | }; | 4136 | }; |
| ... | @@ -4162,7 +4162,7 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -4162,7 +4162,7 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 4162 | .input_index = i, | 4162 | .input_index = i, |
| 4163 | } }); | 4163 | } }); |
| 4164 | try sema.errNote(arg_src, msg, "type '{f}' has no upper bound", .{ | 4164 | try sema.errNote(arg_src, msg, "type '{f}' has no upper bound", .{ |
| 4165 | object_ty.fmt(pt), | 4165 | object_ty.fmt(zcu), |
| 4166 | }); | 4166 | }); |
| 4167 | } | 4167 | } |
| 4168 | break :msg msg; | 4168 | break :msg msg; |
| ... | @@ -4247,7 +4247,7 @@ fn zirCoercePtrElemTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE | ... | @@ -4247,7 +4247,7 @@ fn zirCoercePtrElemTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE |
| 4247 | switch (val_ty.zigTypeTag(zcu)) { | 4247 | switch (val_ty.zigTypeTag(zcu)) { |
| 4248 | .array, .vector => {}, | 4248 | .array, .vector => {}, |
| 4249 | else => if (!val_ty.isTuple(zcu)) { | 4249 | else => if (!val_ty.isTuple(zcu)) { |
| 4250 | return sema.fail(block, src, "expected array of '{f}', found '{f}'", .{ elem_ty.fmt(pt), val_ty.fmt(pt) }); | 4250 | return sema.fail(block, src, "expected array of '{f}', found '{f}'", .{ elem_ty.fmt(zcu), val_ty.fmt(zcu) }); |
| 4251 | }, | 4251 | }, |
| 4252 | } | 4252 | } |
| 4253 | const want_ty = try pt.arrayType(.{ | 4253 | const want_ty = try pt.arrayType(.{ |
| ... | @@ -4325,7 +4325,7 @@ fn zirValidateRefTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr | ... | @@ -4325,7 +4325,7 @@ fn zirValidateRefTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr |
| 4325 | const ty_operand = try sema.resolveTypeOrPoison(block, src, un_tok.operand) orelse return; | 4325 | const ty_operand = try sema.resolveTypeOrPoison(block, src, un_tok.operand) orelse return; |
| 4326 | if (ty_operand.optEuBaseType(zcu).zigTypeTag(zcu) != .pointer) { | 4326 | if (ty_operand.optEuBaseType(zcu).zigTypeTag(zcu) != .pointer) { |
| 4327 | return sema.failWithOwnedErrorMsg(block, msg: { | 4327 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 4328 | const msg = try sema.errMsg(src, "expected type '{f}', found pointer", .{ty_operand.fmt(pt)}); | 4328 | const msg = try sema.errMsg(src, "expected type '{f}', found pointer", .{ty_operand.fmt(zcu)}); |
| 4329 | errdefer msg.destroy(sema.gpa); | 4329 | errdefer msg.destroy(sema.gpa); |
| 4330 | try sema.errNote(src, msg, "address-of operator always returns a pointer", .{}); | 4330 | try sema.errNote(src, msg, "address-of operator always returns a pointer", .{}); |
| 4331 | break :msg msg; | 4331 | break :msg msg; |
| ... | @@ -4711,7 +4711,7 @@ fn zirValidateDestructure(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp | ... | @@ -4711,7 +4711,7 @@ fn zirValidateDestructure(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp |
| 4711 | 4711 | ||
| 4712 | if (!operand_ty.destructurable(zcu)) { | 4712 | if (!operand_ty.destructurable(zcu)) { |
| 4713 | return sema.failWithOwnedErrorMsg(block, msg: { | 4713 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 4714 | const msg = try sema.errMsg(src, "type '{f}' cannot be destructured", .{operand_ty.fmt(pt)}); | 4714 | const msg = try sema.errMsg(src, "type '{f}' cannot be destructured", .{operand_ty.fmt(zcu)}); |
| 4715 | errdefer msg.destroy(sema.gpa); | 4715 | errdefer msg.destroy(sema.gpa); |
| 4716 | try sema.errNote(destructure_src, msg, "result destructured here", .{}); | 4716 | try sema.errNote(destructure_src, msg, "result destructured here", .{}); |
| 4717 | if (operand_ty.zigTypeTag(pt.zcu) == .error_union) { | 4717 | if (operand_ty.zigTypeTag(pt.zcu) == .error_union) { |
| ... | @@ -4756,13 +4756,13 @@ fn failWithBadMemberAccess( | ... | @@ -4756,13 +4756,13 @@ fn failWithBadMemberAccess( |
| 4756 | const inst_index = inst.resolve(ip) orelse return sema.failTransitive(.{ .lost_tracking = inst }); | 4756 | const inst_index = inst.resolve(ip) orelse return sema.failTransitive(.{ .lost_tracking = inst }); |
| 4757 | if (inst_index == .main_struct_inst) { | 4757 | if (inst_index == .main_struct_inst) { |
| 4758 | return sema.fail(block, field_src, "root source file struct '{f}' has no member named '{f}'", .{ | 4758 | return sema.fail(block, field_src, "root source file struct '{f}' has no member named '{f}'", .{ |
| 4759 | agg_ty.fmt(pt), field_name.fmt(ip), | 4759 | agg_ty.fmt(zcu), field_name.fmt(ip), |
| 4760 | }); | 4760 | }); |
| 4761 | } | 4761 | } |
| 4762 | } | 4762 | } |
| 4763 | 4763 | ||
| 4764 | return sema.fail(block, field_src, "{s} '{f}' has no member named '{f}'", .{ | 4764 | return sema.fail(block, field_src, "{s} '{f}' has no member named '{f}'", .{ |
| 4765 | kw_name, agg_ty.fmt(pt), field_name.fmt(ip), | 4765 | kw_name, agg_ty.fmt(zcu), field_name.fmt(ip), |
| 4766 | }); | 4766 | }); |
| 4767 | } | 4767 | } |
| 4768 | 4768 | ||
| ... | @@ -5059,10 +5059,10 @@ fn zirCompileLog( | ... | @@ -5059,10 +5059,10 @@ fn zirCompileLog( |
| 5059 | const arg_ty = sema.typeOf(arg); | 5059 | const arg_ty = sema.typeOf(arg); |
| 5060 | if (sema.resolveValue(arg)) |val| { | 5060 | if (sema.resolveValue(arg)) |val| { |
| 5061 | writer.print("@as({f}, {f})", .{ | 5061 | writer.print("@as({f}, {f})", .{ |
| 5062 | arg_ty.fmt(pt), val.fmtValueSema(pt, sema), | 5062 | arg_ty.fmt(zcu), val.fmtValueSema(sema), |
| 5063 | }) catch return error.OutOfMemory; | 5063 | }) catch return error.OutOfMemory; |
| 5064 | } else { | 5064 | } else { |
| 5065 | writer.print("@as({f}, [runtime value])", .{arg_ty.fmt(pt)}) catch return error.OutOfMemory; | 5065 | writer.print("@as({f}, [runtime value])", .{arg_ty.fmt(zcu)}) catch return error.OutOfMemory; |
| 5066 | } | 5066 | } |
| 5067 | } | 5067 | } |
| 5068 | 5068 | ||
| ... | @@ -5503,7 +5503,7 @@ fn resolveAnalyzedBlock( | ... | @@ -5503,7 +5503,7 @@ fn resolveAnalyzedBlock( |
| 5503 | const type_src = src; // TODO: better source location | 5503 | const type_src = src; // TODO: better source location |
| 5504 | if (resolved_ty.comptimeOnly(zcu)) { | 5504 | if (resolved_ty.comptimeOnly(zcu)) { |
| 5505 | const msg = msg: { | 5505 | const msg = msg: { |
| 5506 | const msg = try sema.errMsg(type_src, "value with comptime-only type '{f}' depends on runtime control flow", .{resolved_ty.fmt(pt)}); | 5506 | const msg = try sema.errMsg(type_src, "value with comptime-only type '{f}' depends on runtime control flow", .{resolved_ty.fmt(zcu)}); |
| 5507 | errdefer msg.destroy(sema.gpa); | 5507 | errdefer msg.destroy(sema.gpa); |
| 5508 | 5508 | ||
| 5509 | const runtime_src = child_block.runtime_cond orelse child_block.runtime_loop.?; | 5509 | const runtime_src = child_block.runtime_cond orelse child_block.runtime_loop.?; |
| ... | @@ -5617,7 +5617,7 @@ fn zirExport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void | ... | @@ -5617,7 +5617,7 @@ fn zirExport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void |
| 5617 | 5617 | ||
| 5618 | { | 5618 | { |
| 5619 | if (ptr_ty.zigTypeTag(zcu) != .pointer) { | 5619 | if (ptr_ty.zigTypeTag(zcu) != .pointer) { |
| 5620 | return sema.fail(block, ptr_src, "expected pointer type, found '{f}'", .{ptr_ty.fmt(pt)}); | 5620 | return sema.fail(block, ptr_src, "expected pointer type, found '{f}'", .{ptr_ty.fmt(zcu)}); |
| 5621 | } | 5621 | } |
| 5622 | const ptr_ty_info = ptr_ty.ptrInfo(zcu); | 5622 | const ptr_ty_info = ptr_ty.ptrInfo(zcu); |
| 5623 | if (ptr_ty_info.flags.size == .slice) { | 5623 | if (ptr_ty_info.flags.size == .slice) { |
| ... | @@ -5632,7 +5632,7 @@ fn zirExport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void | ... | @@ -5632,7 +5632,7 @@ fn zirExport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void |
| 5632 | try sema.ensureLayoutResolved(export_ty, src, .@"export"); | 5632 | try sema.ensureLayoutResolved(export_ty, src, .@"export"); |
| 5633 | if (!export_ty.validateExtern(.other, zcu)) { | 5633 | if (!export_ty.validateExtern(.other, zcu)) { |
| 5634 | return sema.failWithOwnedErrorMsg(block, msg: { | 5634 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 5635 | const msg = try sema.errMsg(src, "unable to export type '{f}'", .{export_ty.fmt(pt)}); | 5635 | const msg = try sema.errMsg(src, "unable to export type '{f}'", .{export_ty.fmt(zcu)}); |
| 5636 | errdefer msg.destroy(sema.gpa); | 5636 | errdefer msg.destroy(sema.gpa); |
| 5637 | try sema.explainWhyTypeIsNotExtern(msg, src, export_ty, .other); | 5637 | try sema.explainWhyTypeIsNotExtern(msg, src, export_ty, .other); |
| 5638 | try sema.addDeclaredHereNote(msg, export_ty); | 5638 | try sema.addDeclaredHereNote(msg, export_ty); |
| ... | @@ -5689,7 +5689,7 @@ pub fn analyzeExportSelfNav( | ... | @@ -5689,7 +5689,7 @@ pub fn analyzeExportSelfNav( |
| 5689 | 5689 | ||
| 5690 | if (!export_ty.validateExtern(.other, zcu)) { | 5690 | if (!export_ty.validateExtern(.other, zcu)) { |
| 5691 | return sema.failWithOwnedErrorMsg(block, msg: { | 5691 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 5692 | const msg = try sema.errMsg(src, "unable to export type '{f}'", .{export_ty.fmt(pt)}); | 5692 | const msg = try sema.errMsg(src, "unable to export type '{f}'", .{export_ty.fmt(zcu)}); |
| 5693 | errdefer msg.destroy(gpa); | 5693 | errdefer msg.destroy(gpa); |
| 5694 | try sema.explainWhyTypeIsNotExtern(msg, src, export_ty, .other); | 5694 | try sema.explainWhyTypeIsNotExtern(msg, src, export_ty, .other); |
| 5695 | try sema.addDeclaredHereNote(msg, export_ty); | 5695 | try sema.addDeclaredHereNote(msg, export_ty); |
| ... | @@ -6327,7 +6327,7 @@ fn checkCallArgumentCount( | ... | @@ -6327,7 +6327,7 @@ fn checkCallArgumentCount( |
| 6327 | { | 6327 | { |
| 6328 | const msg = msg: { | 6328 | const msg = msg: { |
| 6329 | const msg = try sema.errMsg(func_src, "cannot call optional type '{f}'", .{ | 6329 | const msg = try sema.errMsg(func_src, "cannot call optional type '{f}'", .{ |
| 6330 | callee_ty.fmt(pt), | 6330 | callee_ty.fmt(zcu), |
| 6331 | }); | 6331 | }); |
| 6332 | errdefer msg.destroy(sema.gpa); | 6332 | errdefer msg.destroy(sema.gpa); |
| 6333 | try sema.errNote(func_src, msg, "consider using '.?', 'orelse' or 'if'", .{}); | 6333 | try sema.errNote(func_src, msg, "consider using '.?', 'orelse' or 'if'", .{}); |
| ... | @@ -6338,7 +6338,7 @@ fn checkCallArgumentCount( | ... | @@ -6338,7 +6338,7 @@ fn checkCallArgumentCount( |
| 6338 | }, | 6338 | }, |
| 6339 | else => {}, | 6339 | else => {}, |
| 6340 | } | 6340 | } |
| 6341 | return sema.fail(block, func_src, "type '{f}' not a function", .{callee_ty.fmt(pt)}); | 6341 | return sema.fail(block, func_src, "type '{f}' not a function", .{callee_ty.fmt(zcu)}); |
| 6342 | }; | 6342 | }; |
| 6343 | 6343 | ||
| 6344 | const func_ty_info = zcu.typeToFunc(func_ty).?; | 6344 | const func_ty_info = zcu.typeToFunc(func_ty).?; |
| ... | @@ -6401,7 +6401,7 @@ fn callBuiltin( | ... | @@ -6401,7 +6401,7 @@ fn callBuiltin( |
| 6401 | }, | 6401 | }, |
| 6402 | else => {}, | 6402 | else => {}, |
| 6403 | } | 6403 | } |
| 6404 | std.debug.panic("type '{f}' is not a function calling builtin fn", .{callee_ty.fmt(pt)}); | 6404 | std.debug.panic("type '{f}' is not a function calling builtin fn", .{callee_ty.fmt(zcu)}); |
| 6405 | }; | 6405 | }; |
| 6406 | 6406 | ||
| 6407 | const func_ty_info = zcu.typeToFunc(func_ty).?; | 6407 | const func_ty_info = zcu.typeToFunc(func_ty).?; |
| ... | @@ -6827,7 +6827,7 @@ fn analyzeCall( | ... | @@ -6827,7 +6827,7 @@ fn analyzeCall( |
| 6827 | if (!param_ty.isValidParamType(zcu)) { | 6827 | if (!param_ty.isValidParamType(zcu)) { |
| 6828 | const opaque_str = if (param_ty.zigTypeTag(zcu) == .@"opaque") "opaque " else ""; | 6828 | const opaque_str = if (param_ty.zigTypeTag(zcu) == .@"opaque") "opaque " else ""; |
| 6829 | return sema.fail(block, param_src, "parameter of {s}type '{f}' not allowed", .{ | 6829 | return sema.fail(block, param_src, "parameter of {s}type '{f}' not allowed", .{ |
| 6830 | opaque_str, param_ty.fmt(pt), | 6830 | opaque_str, param_ty.fmt(zcu), |
| 6831 | }); | 6831 | }); |
| 6832 | } | 6832 | } |
| 6833 | 6833 | ||
| ... | @@ -6931,7 +6931,7 @@ fn analyzeCall( | ... | @@ -6931,7 +6931,7 @@ fn analyzeCall( |
| 6931 | if (!full_ty.isValidReturnType(zcu)) { | 6931 | if (!full_ty.isValidReturnType(zcu)) { |
| 6932 | const opaque_str = if (full_ty.zigTypeTag(zcu) == .@"opaque") "opaque " else ""; | 6932 | const opaque_str = if (full_ty.zigTypeTag(zcu) == .@"opaque") "opaque " else ""; |
| 6933 | return sema.fail(block, func_ret_ty_src, "{s}return type '{f}' not allowed", .{ | 6933 | return sema.fail(block, func_ret_ty_src, "{s}return type '{f}' not allowed", .{ |
| 6934 | opaque_str, full_ty.fmt(pt), | 6934 | opaque_str, full_ty.fmt(zcu), |
| 6935 | }); | 6935 | }); |
| 6936 | } | 6936 | } |
| 6937 | 6937 | ||
| ... | @@ -7431,7 +7431,7 @@ fn handleTailCall(sema: *Sema, block: *Block, call_src: LazySrcLoc, func_ty: Typ | ... | @@ -7431,7 +7431,7 @@ fn handleTailCall(sema: *Sema, block: *Block, call_src: LazySrcLoc, func_ty: Typ |
| 7431 | const owner_func_ty: Type = .fromInterned(zcu.funcInfo(sema.owner.unwrap().func).ty); | 7431 | const owner_func_ty: Type = .fromInterned(zcu.funcInfo(sema.owner.unwrap().func).ty); |
| 7432 | if (owner_func_ty.toIntern() != func_ty.toIntern()) { | 7432 | if (owner_func_ty.toIntern() != func_ty.toIntern()) { |
| 7433 | return sema.fail(block, call_src, "unable to perform tail call: type of function being called '{f}' does not match type of calling function '{f}'", .{ | 7433 | return sema.fail(block, call_src, "unable to perform tail call: type of function being called '{f}' does not match type of calling function '{f}'", .{ |
| 7434 | func_ty.fmt(pt), owner_func_ty.fmt(pt), | 7434 | func_ty.fmt(zcu), owner_func_ty.fmt(zcu), |
| 7435 | }); | 7435 | }); |
| 7436 | } | 7436 | } |
| 7437 | _ = try block.addUnOp(.ret, result); | 7437 | _ = try block.addUnOp(.ret, result); |
| ... | @@ -7451,9 +7451,9 @@ fn zirOptionalType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro | ... | @@ -7451,9 +7451,9 @@ fn zirOptionalType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro |
| 7451 | const operand_src = block.src(.{ .node_offset_un_op = inst_data.src_node }); | 7451 | const operand_src = block.src(.{ .node_offset_un_op = inst_data.src_node }); |
| 7452 | const child_type = try sema.resolveType(block, operand_src, inst_data.operand); | 7452 | const child_type = try sema.resolveType(block, operand_src, inst_data.operand); |
| 7453 | if (child_type.zigTypeTag(zcu) == .@"opaque") { | 7453 | if (child_type.zigTypeTag(zcu) == .@"opaque") { |
| 7454 | return sema.fail(block, operand_src, "opaque type '{f}' cannot be optional", .{child_type.fmt(pt)}); | 7454 | return sema.fail(block, operand_src, "opaque type '{f}' cannot be optional", .{child_type.fmt(zcu)}); |
| 7455 | } else if (child_type.zigTypeTag(zcu) == .null) { | 7455 | } else if (child_type.zigTypeTag(zcu) == .null) { |
| 7456 | return sema.fail(block, operand_src, "type '{f}' cannot be optional", .{child_type.fmt(pt)}); | 7456 | return sema.fail(block, operand_src, "type '{f}' cannot be optional", .{child_type.fmt(zcu)}); |
| 7457 | } | 7457 | } |
| 7458 | const opt_type = try pt.optionalType(child_type.toIntern()); | 7458 | const opt_type = try pt.optionalType(child_type.toIntern()); |
| 7459 | 7459 | ||
| ... | @@ -7514,7 +7514,7 @@ fn zirSplatOpResultType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compil | ... | @@ -7514,7 +7514,7 @@ fn zirSplatOpResultType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compil |
| 7514 | 7514 | ||
| 7515 | switch (vec_ty.zigTypeTag(zcu)) { | 7515 | switch (vec_ty.zigTypeTag(zcu)) { |
| 7516 | .array, .vector => {}, | 7516 | .array, .vector => {}, |
| 7517 | else => return sema.fail(block, block.nodeOffset(un_node.src_node), "expected array or vector type, found '{f}'", .{vec_ty.fmt(pt)}), | 7517 | else => return sema.fail(block, block.nodeOffset(un_node.src_node), "expected array or vector type, found '{f}'", .{vec_ty.fmt(zcu)}), |
| 7518 | } | 7518 | } |
| 7519 | return Air.internedToRef(vec_ty.childType(zcu).toIntern()); | 7519 | return Air.internedToRef(vec_ty.childType(zcu).toIntern()); |
| 7520 | } | 7520 | } |
| ... | @@ -7587,7 +7587,7 @@ fn validateArrayElemType(sema: *Sema, block: *Block, elem_type: Type, elem_src: | ... | @@ -7587,7 +7587,7 @@ fn validateArrayElemType(sema: *Sema, block: *Block, elem_type: Type, elem_src: |
| 7587 | const pt = sema.pt; | 7587 | const pt = sema.pt; |
| 7588 | const zcu = pt.zcu; | 7588 | const zcu = pt.zcu; |
| 7589 | if (elem_type.zigTypeTag(zcu) == .@"opaque") { | 7589 | if (elem_type.zigTypeTag(zcu) == .@"opaque") { |
| 7590 | return sema.fail(block, elem_src, "array of opaque type '{f}' not allowed", .{elem_type.fmt(pt)}); | 7590 | return sema.fail(block, elem_src, "array of opaque type '{f}' not allowed", .{elem_type.fmt(zcu)}); |
| 7591 | } else if (elem_type.zigTypeTag(zcu) == .noreturn) { | 7591 | } else if (elem_type.zigTypeTag(zcu) == .noreturn) { |
| 7592 | return sema.fail(block, elem_src, "array of 'noreturn' not allowed", .{}); | 7592 | return sema.fail(block, elem_src, "array of 'noreturn' not allowed", .{}); |
| 7593 | } | 7593 | } |
| ... | @@ -7618,7 +7618,7 @@ fn zirErrorUnionType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr | ... | @@ -7618,7 +7618,7 @@ fn zirErrorUnionType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr |
| 7618 | 7618 | ||
| 7619 | if (error_set.zigTypeTag(zcu) != .error_set) { | 7619 | if (error_set.zigTypeTag(zcu) != .error_set) { |
| 7620 | return sema.fail(block, lhs_src, "expected error set type, found '{f}'", .{ | 7620 | return sema.fail(block, lhs_src, "expected error set type, found '{f}'", .{ |
| 7621 | error_set.fmt(pt), | 7621 | error_set.fmt(zcu), |
| 7622 | }); | 7622 | }); |
| 7623 | } | 7623 | } |
| 7624 | try sema.validateErrorUnionPayloadType(block, payload, rhs_src); | 7624 | try sema.validateErrorUnionPayloadType(block, payload, rhs_src); |
| ... | @@ -7631,11 +7631,11 @@ fn validateErrorUnionPayloadType(sema: *Sema, block: *Block, payload_ty: Type, p | ... | @@ -7631,11 +7631,11 @@ fn validateErrorUnionPayloadType(sema: *Sema, block: *Block, payload_ty: Type, p |
| 7631 | const zcu = pt.zcu; | 7631 | const zcu = pt.zcu; |
| 7632 | if (payload_ty.zigTypeTag(zcu) == .@"opaque") { | 7632 | if (payload_ty.zigTypeTag(zcu) == .@"opaque") { |
| 7633 | return sema.fail(block, payload_src, "error union with payload of opaque type '{f}' not allowed", .{ | 7633 | return sema.fail(block, payload_src, "error union with payload of opaque type '{f}' not allowed", .{ |
| 7634 | payload_ty.fmt(pt), | 7634 | payload_ty.fmt(zcu), |
| 7635 | }); | 7635 | }); |
| 7636 | } else if (payload_ty.zigTypeTag(zcu) == .error_set) { | 7636 | } else if (payload_ty.zigTypeTag(zcu) == .error_set) { |
| 7637 | return sema.fail(block, payload_src, "error union with payload of error set type '{f}' not allowed", .{ | 7637 | return sema.fail(block, payload_src, "error union with payload of error set type '{f}' not allowed", .{ |
| 7638 | payload_ty.fmt(pt), | 7638 | payload_ty.fmt(zcu), |
| 7639 | }); | 7639 | }); |
| 7640 | } | 7640 | } |
| 7641 | } | 7641 | } |
| ... | @@ -7766,9 +7766,9 @@ fn zirMergeErrorSets(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr | ... | @@ -7766,9 +7766,9 @@ fn zirMergeErrorSets(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr |
| 7766 | const lhs_ty = try sema.analyzeAsType(block, lhs_src, .type, lhs); | 7766 | const lhs_ty = try sema.analyzeAsType(block, lhs_src, .type, lhs); |
| 7767 | const rhs_ty = try sema.analyzeAsType(block, rhs_src, .type, rhs); | 7767 | const rhs_ty = try sema.analyzeAsType(block, rhs_src, .type, rhs); |
| 7768 | if (lhs_ty.zigTypeTag(zcu) != .error_set) | 7768 | if (lhs_ty.zigTypeTag(zcu) != .error_set) |
| 7769 | return sema.fail(block, lhs_src, "expected error set type, found '{f}'", .{lhs_ty.fmt(pt)}); | 7769 | return sema.fail(block, lhs_src, "expected error set type, found '{f}'", .{lhs_ty.fmt(zcu)}); |
| 7770 | if (rhs_ty.zigTypeTag(zcu) != .error_set) | 7770 | if (rhs_ty.zigTypeTag(zcu) != .error_set) |
| 7771 | return sema.fail(block, rhs_src, "expected error set type, found '{f}'", .{rhs_ty.fmt(pt)}); | 7771 | return sema.fail(block, rhs_src, "expected error set type, found '{f}'", .{rhs_ty.fmt(zcu)}); |
| 7772 | 7772 | ||
| 7773 | // Anything merged with anyerror is anyerror. | 7773 | // Anything merged with anyerror is anyerror. |
| 7774 | if (lhs_ty.toIntern() == .anyerror_type or rhs_ty.toIntern() == .anyerror_type) { | 7774 | if (lhs_ty.toIntern() == .anyerror_type or rhs_ty.toIntern() == .anyerror_type) { |
| ... | @@ -7894,7 +7894,7 @@ fn zirIntFromEnum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -7894,7 +7894,7 @@ fn zirIntFromEnum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 7894 | block, | 7894 | block, |
| 7895 | operand_src, | 7895 | operand_src, |
| 7896 | "untagged union '{f}' cannot be converted to integer", | 7896 | "untagged union '{f}' cannot be converted to integer", |
| 7897 | .{operand_ty.fmt(pt)}, | 7897 | .{operand_ty.fmt(zcu)}, |
| 7898 | ); | 7898 | ); |
| 7899 | } | 7899 | } |
| 7900 | 7900 | ||
| ... | @@ -7902,7 +7902,7 @@ fn zirIntFromEnum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -7902,7 +7902,7 @@ fn zirIntFromEnum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 7902 | }, | 7902 | }, |
| 7903 | else => { | 7903 | else => { |
| 7904 | return sema.fail(block, operand_src, "expected enum or tagged union, found '{f}'", .{ | 7904 | return sema.fail(block, operand_src, "expected enum or tagged union, found '{f}'", .{ |
| 7905 | operand_ty.fmt(pt), | 7905 | operand_ty.fmt(zcu), |
| 7906 | }); | 7906 | }); |
| 7907 | }, | 7907 | }, |
| 7908 | }; | 7908 | }; |
| ... | @@ -7931,7 +7931,7 @@ fn zirEnumFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -7931,7 +7931,7 @@ fn zirEnumFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 7931 | const operand_ty = sema.typeOf(operand); | 7931 | const operand_ty = sema.typeOf(operand); |
| 7932 | 7932 | ||
| 7933 | if (dest_ty.zigTypeTag(zcu) != .@"enum") { | 7933 | if (dest_ty.zigTypeTag(zcu) != .@"enum") { |
| 7934 | return sema.fail(block, src, "expected enum, found '{f}'", .{dest_ty.fmt(pt)}); | 7934 | return sema.fail(block, src, "expected enum, found '{f}'", .{dest_ty.fmt(zcu)}); |
| 7935 | } | 7935 | } |
| 7936 | try sema.ensureLayoutResolved(dest_ty, src, .init); | 7936 | try sema.ensureLayoutResolved(dest_ty, src, .init); |
| 7937 | _ = try sema.checkIntType(block, operand_src, operand_ty); | 7937 | _ = try sema.checkIntType(block, operand_src, operand_ty); |
| ... | @@ -7943,7 +7943,7 @@ fn zirEnumFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -7943,7 +7943,7 @@ fn zirEnumFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 7943 | return Air.internedToRef((try pt.getCoerced(int_val, dest_ty)).toIntern()); | 7943 | return Air.internedToRef((try pt.getCoerced(int_val, dest_ty)).toIntern()); |
| 7944 | } | 7944 | } |
| 7945 | return sema.fail(block, src, "int value '{f}' out of range of non-exhaustive enum '{f}'", .{ | 7945 | return sema.fail(block, src, "int value '{f}' out of range of non-exhaustive enum '{f}'", .{ |
| 7946 | int_val.fmtValueSema(pt, sema), dest_ty.fmt(pt), | 7946 | int_val.fmtValueSema(sema), dest_ty.fmt(zcu), |
| 7947 | }); | 7947 | }); |
| 7948 | } | 7948 | } |
| 7949 | if (int_val.isUndef(zcu)) { | 7949 | if (int_val.isUndef(zcu)) { |
| ... | @@ -7951,7 +7951,7 @@ fn zirEnumFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -7951,7 +7951,7 @@ fn zirEnumFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 7951 | } | 7951 | } |
| 7952 | if (!(try sema.enumHasInt(dest_ty, int_val))) { | 7952 | if (!(try sema.enumHasInt(dest_ty, int_val))) { |
| 7953 | return sema.fail(block, src, "enum '{f}' has no tag with value '{f}'", .{ | 7953 | return sema.fail(block, src, "enum '{f}' has no tag with value '{f}'", .{ |
| 7954 | dest_ty.fmt(pt), int_val.fmtValueSema(pt, sema), | 7954 | dest_ty.fmt(zcu), int_val.fmtValueSema(sema), |
| 7955 | }); | 7955 | }); |
| 7956 | } | 7956 | } |
| 7957 | return Air.internedToRef((try pt.getCoerced(int_val, dest_ty)).toIntern()); | 7957 | return Air.internedToRef((try pt.getCoerced(int_val, dest_ty)).toIntern()); |
| ... | @@ -8129,7 +8129,7 @@ fn zirErrUnionPayload( | ... | @@ -8129,7 +8129,7 @@ fn zirErrUnionPayload( |
| 8129 | const err_union_ty = sema.typeOf(operand); | 8129 | const err_union_ty = sema.typeOf(operand); |
| 8130 | if (err_union_ty.zigTypeTag(zcu) != .error_union) { | 8130 | if (err_union_ty.zigTypeTag(zcu) != .error_union) { |
| 8131 | return sema.fail(block, operand_src, "expected error union type, found '{f}'", .{ | 8131 | return sema.fail(block, operand_src, "expected error union type, found '{f}'", .{ |
| 8132 | err_union_ty.fmt(pt), | 8132 | err_union_ty.fmt(zcu), |
| 8133 | }); | 8133 | }); |
| 8134 | } | 8134 | } |
| 8135 | return sema.analyzeErrUnionPayload(block, src, err_union_ty, operand, operand_src, false); | 8135 | return sema.analyzeErrUnionPayload(block, src, err_union_ty, operand, operand_src, false); |
| ... | @@ -8203,7 +8203,7 @@ fn analyzeErrUnionPayloadPtr( | ... | @@ -8203,7 +8203,7 @@ fn analyzeErrUnionPayloadPtr( |
| 8203 | 8203 | ||
| 8204 | if (operand_ty.childType(zcu).zigTypeTag(zcu) != .error_union) { | 8204 | if (operand_ty.childType(zcu).zigTypeTag(zcu) != .error_union) { |
| 8205 | return sema.fail(block, src, "expected error union type, found '{f}'", .{ | 8205 | return sema.fail(block, src, "expected error union type, found '{f}'", .{ |
| 8206 | operand_ty.childType(zcu).fmt(pt), | 8206 | operand_ty.childType(zcu).fmt(zcu), |
| 8207 | }); | 8207 | }); |
| 8208 | } | 8208 | } |
| 8209 | 8209 | ||
| ... | @@ -8278,7 +8278,7 @@ fn analyzeErrUnionCode(sema: *Sema, block: *Block, src: LazySrcLoc, operand: Air | ... | @@ -8278,7 +8278,7 @@ fn analyzeErrUnionCode(sema: *Sema, block: *Block, src: LazySrcLoc, operand: Air |
| 8278 | const operand_ty = sema.typeOf(operand); | 8278 | const operand_ty = sema.typeOf(operand); |
| 8279 | if (operand_ty.zigTypeTag(zcu) != .error_union) { | 8279 | if (operand_ty.zigTypeTag(zcu) != .error_union) { |
| 8280 | return sema.fail(block, src, "expected error union type, found '{f}'", .{ | 8280 | return sema.fail(block, src, "expected error union type, found '{f}'", .{ |
| 8281 | operand_ty.fmt(pt), | 8281 | operand_ty.fmt(zcu), |
| 8282 | }); | 8282 | }); |
| 8283 | } | 8283 | } |
| 8284 | 8284 | ||
| ... | @@ -8312,7 +8312,7 @@ fn analyzeErrUnionCodePtr(sema: *Sema, block: *Block, src: LazySrcLoc, operand: | ... | @@ -8312,7 +8312,7 @@ fn analyzeErrUnionCodePtr(sema: *Sema, block: *Block, src: LazySrcLoc, operand: |
| 8312 | 8312 | ||
| 8313 | if (operand_ty.childType(zcu).zigTypeTag(zcu) != .error_union) { | 8313 | if (operand_ty.childType(zcu).zigTypeTag(zcu) != .error_union) { |
| 8314 | return sema.fail(block, src, "expected error union type, found '{f}'", .{ | 8314 | return sema.fail(block, src, "expected error union type, found '{f}'", .{ |
| 8315 | operand_ty.childType(zcu).fmt(pt), | 8315 | operand_ty.childType(zcu).fmt(zcu), |
| 8316 | }); | 8316 | }); |
| 8317 | } | 8317 | } |
| 8318 | 8318 | ||
| ... | @@ -8640,7 +8640,7 @@ fn checkParamType( | ... | @@ -8640,7 +8640,7 @@ fn checkParamType( |
| 8640 | if (!param_ty.isValidParamType(zcu)) { | 8640 | if (!param_ty.isValidParamType(zcu)) { |
| 8641 | const opaque_str = if (param_ty.zigTypeTag(zcu) == .@"opaque") "opaque " else ""; | 8641 | const opaque_str = if (param_ty.zigTypeTag(zcu) == .@"opaque") "opaque " else ""; |
| 8642 | return sema.fail(block, param_src, "parameter of {s}type '{f}' not allowed", .{ | 8642 | return sema.fail(block, param_src, "parameter of {s}type '{f}' not allowed", .{ |
| 8643 | opaque_str, param_ty.fmt(pt), | 8643 | opaque_str, param_ty.fmt(zcu), |
| 8644 | }); | 8644 | }); |
| 8645 | } | 8645 | } |
| 8646 | if (!target_util.fnCallConvAllowsZigTypes(cc)) { | 8646 | if (!target_util.fnCallConvAllowsZigTypes(cc)) { |
| ... | @@ -8721,12 +8721,12 @@ fn checkReturnTypeAndCallConv( | ... | @@ -8721,12 +8721,12 @@ fn checkReturnTypeAndCallConv( |
| 8721 | if (!bare_ret_ty.isValidReturnType(zcu)) { | 8721 | if (!bare_ret_ty.isValidReturnType(zcu)) { |
| 8722 | const opaque_str = if (bare_ret_ty.zigTypeTag(zcu) == .@"opaque") "opaque " else ""; | 8722 | const opaque_str = if (bare_ret_ty.zigTypeTag(zcu) == .@"opaque") "opaque " else ""; |
| 8723 | return sema.fail(block, ret_ty_src, "{s}return type '{s}{f}' not allowed", .{ | 8723 | return sema.fail(block, ret_ty_src, "{s}return type '{s}{f}' not allowed", .{ |
| 8724 | opaque_str, ies_ret_ty_prefix, bare_ret_ty.fmt(pt), | 8724 | opaque_str, ies_ret_ty_prefix, bare_ret_ty.fmt(zcu), |
| 8725 | }); | 8725 | }); |
| 8726 | } | 8726 | } |
| 8727 | if (!target_util.fnCallConvAllowsZigTypes(@"callconv")) { | 8727 | if (!target_util.fnCallConvAllowsZigTypes(@"callconv")) { |
| 8728 | if (inferred_error_set) { | 8728 | if (inferred_error_set) { |
| 8729 | return sema.fail(block, ret_ty_src, "return type '!{f}' not allowed in function with calling convention '{t}'", .{ bare_ret_ty.fmt(pt), @"callconv" }); | 8729 | return sema.fail(block, ret_ty_src, "return type '!{f}' not allowed in function with calling convention '{t}'", .{ bare_ret_ty.fmt(zcu), @"callconv" }); |
| 8730 | } | 8730 | } |
| 8731 | if (bare_ret_ty.isGenericPoison()) { | 8731 | if (bare_ret_ty.isGenericPoison()) { |
| 8732 | return sema.fail(block, ret_ty_src, "generic return type not allowed in function with calling convention '{t}'", .{@"callconv"}); | 8732 | return sema.fail(block, ret_ty_src, "generic return type not allowed in function with calling convention '{t}'", .{@"callconv"}); |
| ... | @@ -8858,7 +8858,7 @@ fn validateResolvedFuncType( | ... | @@ -8858,7 +8858,7 @@ fn validateResolvedFuncType( |
| 8858 | } else src; | 8858 | } else src; |
| 8859 | return sema.failWithOwnedErrorMsg(block, msg: { | 8859 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 8860 | const msg = try sema.errMsg(param_src, "parameter of type '{f}' not allowed in function with calling convention '{t}'", .{ | 8860 | const msg = try sema.errMsg(param_src, "parameter of type '{f}' not allowed in function with calling convention '{t}'", .{ |
| 8861 | param_ty.fmt(pt), @"callconv", | 8861 | param_ty.fmt(zcu), @"callconv", |
| 8862 | }); | 8862 | }); |
| 8863 | errdefer msg.destroy(gpa); | 8863 | errdefer msg.destroy(gpa); |
| 8864 | try sema.explainWhyTypeIsNotExtern(msg, param_src, param_ty, .param_ty); | 8864 | try sema.explainWhyTypeIsNotExtern(msg, param_src, param_ty, .param_ty); |
| ... | @@ -8875,7 +8875,7 @@ fn validateResolvedFuncType( | ... | @@ -8875,7 +8875,7 @@ fn validateResolvedFuncType( |
| 8875 | } else src; | 8875 | } else src; |
| 8876 | return sema.failWithOwnedErrorMsg(block, msg: { | 8876 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 8877 | const msg = try sema.errMsg(ret_ty_src, "return type '{f}' not allowed in function with calling convention '{t}'", .{ | 8877 | const msg = try sema.errMsg(ret_ty_src, "return type '{f}' not allowed in function with calling convention '{t}'", .{ |
| 8878 | ret_ty.fmt(pt), @"callconv", | 8878 | ret_ty.fmt(zcu), @"callconv", |
| 8879 | }); | 8879 | }); |
| 8880 | errdefer msg.destroy(gpa); | 8880 | errdefer msg.destroy(gpa); |
| 8881 | try sema.explainWhyTypeIsNotExtern(msg, ret_ty_src, ret_ty, .ret_ty); | 8881 | try sema.explainWhyTypeIsNotExtern(msg, ret_ty_src, ret_ty, .ret_ty); |
| ... | @@ -8934,7 +8934,7 @@ fn checkMergeAllowed(sema: *Sema, block: *Block, src: LazySrcLoc, peer_ty: Type) | ... | @@ -8934,7 +8934,7 @@ fn checkMergeAllowed(sema: *Sema, block: *Block, src: LazySrcLoc, peer_ty: Type) |
| 8934 | } | 8934 | } |
| 8935 | 8935 | ||
| 8936 | return sema.failWithOwnedErrorMsg(block, msg: { | 8936 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 8937 | const msg = try sema.errMsg(src, "value with non-mergable pointer type '{f}' depends on runtime control flow", .{peer_ty.fmt(pt)}); | 8937 | const msg = try sema.errMsg(src, "value with non-mergable pointer type '{f}' depends on runtime control flow", .{peer_ty.fmt(zcu)}); |
| 8938 | errdefer msg.destroy(sema.gpa); | 8938 | errdefer msg.destroy(sema.gpa); |
| 8939 | 8939 | ||
| 8940 | const runtime_src = block.runtime_cond orelse block.runtime_loop.?; | 8940 | const runtime_src = block.runtime_cond orelse block.runtime_loop.?; |
| ... | @@ -9167,7 +9167,7 @@ fn analyzeAs( | ... | @@ -9167,7 +9167,7 @@ fn analyzeAs( |
| 9167 | const operand = sema.resolveInst(zir_operand); | 9167 | const operand = sema.resolveInst(zir_operand); |
| 9168 | const dest_ty = try sema.resolveTypeOrPoison(block, src, zir_dest_type) orelse return operand; | 9168 | const dest_ty = try sema.resolveTypeOrPoison(block, src, zir_dest_type) orelse return operand; |
| 9169 | switch (dest_ty.zigTypeTag(zcu)) { | 9169 | switch (dest_ty.zigTypeTag(zcu)) { |
| 9170 | .@"opaque" => return sema.fail(block, src, "cannot cast to opaque type '{f}'", .{dest_ty.fmt(pt)}), | 9170 | .@"opaque" => return sema.fail(block, src, "cannot cast to opaque type '{f}'", .{dest_ty.fmt(zcu)}), |
| 9171 | .noreturn => return sema.fail(block, src, "cannot cast to noreturn", .{}), | 9171 | .noreturn => return sema.fail(block, src, "cannot cast to noreturn", .{}), |
| 9172 | else => {}, | 9172 | else => {}, |
| 9173 | } | 9173 | } |
| ... | @@ -9192,7 +9192,7 @@ fn zirIntFromPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -9192,7 +9192,7 @@ fn zirIntFromPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 9192 | const ptr_ty = operand_ty.scalarType(zcu); | 9192 | const ptr_ty = operand_ty.scalarType(zcu); |
| 9193 | const is_vector = operand_ty.zigTypeTag(zcu) == .vector; | 9193 | const is_vector = operand_ty.zigTypeTag(zcu) == .vector; |
| 9194 | if (!ptr_ty.isPtrAtRuntime(zcu)) { | 9194 | if (!ptr_ty.isPtrAtRuntime(zcu)) { |
| 9195 | return sema.fail(block, ptr_src, "expected pointer, found '{f}'", .{ptr_ty.fmt(pt)}); | 9195 | return sema.fail(block, ptr_src, "expected pointer, found '{f}'", .{ptr_ty.fmt(zcu)}); |
| 9196 | } | 9196 | } |
| 9197 | 9197 | ||
| 9198 | const len = if (is_vector) operand_ty.vectorLen(zcu) else undefined; | 9198 | const len = if (is_vector) operand_ty.vectorLen(zcu) else undefined; |
| ... | @@ -9415,45 +9415,45 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -9415,45 +9415,45 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 9415 | // Check for pointers before checking `hasBitRepresentation` so we can emit a better message for slices. | 9415 | // Check for pointers before checking `hasBitRepresentation` so we can emit a better message for slices. |
| 9416 | switch (dest_ty.scalarType(zcu).zigTypeTag(zcu)) { | 9416 | switch (dest_ty.scalarType(zcu).zigTypeTag(zcu)) { |
| 9417 | .pointer, .optional => return sema.failWithOwnedErrorMsg(block, msg: { | 9417 | .pointer, .optional => return sema.failWithOwnedErrorMsg(block, msg: { |
| 9418 | const msg = try sema.errMsg(src, "cannot @bitCast to '{f}'", .{dest_ty.fmt(pt)}); | 9418 | const msg = try sema.errMsg(src, "cannot @bitCast to '{f}'", .{dest_ty.fmt(zcu)}); |
| 9419 | errdefer msg.destroy(sema.gpa); | 9419 | errdefer msg.destroy(sema.gpa); |
| 9420 | switch (operand_ty.zigTypeTag(zcu)) { | 9420 | switch (operand_ty.zigTypeTag(zcu)) { |
| 9421 | .int, .comptime_int => try sema.errNote(src, msg, "use @ptrFromInt to cast from '{f}'", .{operand_ty.fmt(pt)}), | 9421 | .int, .comptime_int => try sema.errNote(src, msg, "use @ptrFromInt to cast from '{f}'", .{operand_ty.fmt(zcu)}), |
| 9422 | .pointer => try sema.errNote(src, msg, "use @ptrCast to cast from '{f}'", .{operand_ty.fmt(pt)}), | 9422 | .pointer => try sema.errNote(src, msg, "use @ptrCast to cast from '{f}'", .{operand_ty.fmt(zcu)}), |
| 9423 | else => {}, | 9423 | else => {}, |
| 9424 | } | 9424 | } |
| 9425 | break :msg msg; | 9425 | break :msg msg; |
| 9426 | }), | 9426 | }), |
| 9427 | .array => switch (dest_ty.arrayBase(zcu)[0].zigTypeTag(zcu)) { | 9427 | .array => switch (dest_ty.arrayBase(zcu)[0].zigTypeTag(zcu)) { |
| 9428 | .pointer, .optional => return sema.fail(block, src, "cannot @bitCast to '{f}'", .{dest_ty.fmt(pt)}), | 9428 | .pointer, .optional => return sema.fail(block, src, "cannot @bitCast to '{f}'", .{dest_ty.fmt(zcu)}), |
| 9429 | else => {}, | 9429 | else => {}, |
| 9430 | }, | 9430 | }, |
| 9431 | else => {}, | 9431 | else => {}, |
| 9432 | } | 9432 | } |
| 9433 | if (!dest_ty.hasBitRepresentation(zcu)) { | 9433 | if (!dest_ty.hasBitRepresentation(zcu)) { |
| 9434 | return sema.fail(block, src, "cannot @bitCast to '{f}'", .{dest_ty.fmt(pt)}); | 9434 | return sema.fail(block, src, "cannot @bitCast to '{f}'", .{dest_ty.fmt(zcu)}); |
| 9435 | } | 9435 | } |
| 9436 | 9436 | ||
| 9437 | // Check for pointers before checking `hasBitRepresentation` so we can emit a better message for slices. | 9437 | // Check for pointers before checking `hasBitRepresentation` so we can emit a better message for slices. |
| 9438 | switch (operand_ty.scalarType(zcu).zigTypeTag(zcu)) { | 9438 | switch (operand_ty.scalarType(zcu).zigTypeTag(zcu)) { |
| 9439 | .pointer, .optional => return sema.failWithOwnedErrorMsg(block, msg: { | 9439 | .pointer, .optional => return sema.failWithOwnedErrorMsg(block, msg: { |
| 9440 | const msg = try sema.errMsg(operand_src, "cannot @bitCast from '{f}'", .{operand_ty.fmt(pt)}); | 9440 | const msg = try sema.errMsg(operand_src, "cannot @bitCast from '{f}'", .{operand_ty.fmt(zcu)}); |
| 9441 | errdefer msg.destroy(sema.gpa); | 9441 | errdefer msg.destroy(sema.gpa); |
| 9442 | switch (dest_ty.zigTypeTag(zcu)) { | 9442 | switch (dest_ty.zigTypeTag(zcu)) { |
| 9443 | .int, .comptime_int => try sema.errNote(operand_src, msg, "use @intFromPtr to cast to '{f}'", .{dest_ty.fmt(pt)}), | 9443 | .int, .comptime_int => try sema.errNote(operand_src, msg, "use @intFromPtr to cast to '{f}'", .{dest_ty.fmt(zcu)}), |
| 9444 | .pointer => try sema.errNote(operand_src, msg, "use @ptrCast to cast to '{f}'", .{dest_ty.fmt(pt)}), | 9444 | .pointer => try sema.errNote(operand_src, msg, "use @ptrCast to cast to '{f}'", .{dest_ty.fmt(zcu)}), |
| 9445 | else => {}, | 9445 | else => {}, |
| 9446 | } | 9446 | } |
| 9447 | break :msg msg; | 9447 | break :msg msg; |
| 9448 | }), | 9448 | }), |
| 9449 | .array => switch (operand_ty.arrayBase(zcu)[0].zigTypeTag(zcu)) { | 9449 | .array => switch (operand_ty.arrayBase(zcu)[0].zigTypeTag(zcu)) { |
| 9450 | .pointer, .optional => return sema.fail(block, operand_src, "cannot @bitCast from '{f}'", .{dest_ty.fmt(pt)}), | 9450 | .pointer, .optional => return sema.fail(block, operand_src, "cannot @bitCast from '{f}'", .{dest_ty.fmt(zcu)}), |
| 9451 | else => {}, | 9451 | else => {}, |
| 9452 | }, | 9452 | }, |
| 9453 | else => {}, | 9453 | else => {}, |
| 9454 | } | 9454 | } |
| 9455 | if (!operand_ty.hasBitRepresentation(zcu)) { | 9455 | if (!operand_ty.hasBitRepresentation(zcu)) { |
| 9456 | return sema.fail(block, operand_src, "cannot @bitCast from '{f}'", .{operand_ty.fmt(pt)}); | 9456 | return sema.fail(block, operand_src, "cannot @bitCast from '{f}'", .{operand_ty.fmt(zcu)}); |
| 9457 | } | 9457 | } |
| 9458 | 9458 | ||
| 9459 | operand_ty.assertHasLayout(zcu); | 9459 | operand_ty.assertHasLayout(zcu); |
| ... | @@ -9463,9 +9463,9 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -9463,9 +9463,9 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 9463 | const dest_bits = dest_ty.bitSize(zcu); | 9463 | const dest_bits = dest_ty.bitSize(zcu); |
| 9464 | if (operand_bits != dest_bits) { | 9464 | if (operand_bits != dest_bits) { |
| 9465 | return sema.fail(block, src, "@bitCast size mismatch: destination type '{f}' has {d} bits but source type '{f}' has {d} bits", .{ | 9465 | return sema.fail(block, src, "@bitCast size mismatch: destination type '{f}' has {d} bits but source type '{f}' has {d} bits", .{ |
| 9466 | dest_ty.fmt(pt), | 9466 | dest_ty.fmt(zcu), |
| 9467 | dest_bits, | 9467 | dest_bits, |
| 9468 | operand_ty.fmt(pt), | 9468 | operand_ty.fmt(zcu), |
| 9469 | operand_bits, | 9469 | operand_bits, |
| 9470 | }); | 9470 | }); |
| 9471 | } | 9471 | } |
| ... | @@ -9483,7 +9483,7 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -9483,7 +9483,7 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 9483 | dest_ty.enumTagFieldIndex(result_val, zcu) == null) | 9483 | dest_ty.enumTagFieldIndex(result_val, zcu) == null) |
| 9484 | { | 9484 | { |
| 9485 | return sema.fail(block, src, "enum '{f}' has no tag with value '{f}'", .{ | 9485 | return sema.fail(block, src, "enum '{f}' has no tag with value '{f}'", .{ |
| 9486 | dest_ty.fmt(pt), result_val.backingInt(zcu).fmtValueSema(pt, sema), | 9486 | dest_ty.fmt(zcu), result_val.backingInt(zcu).fmtValueSema(sema), |
| 9487 | }); | 9487 | }); |
| 9488 | } | 9488 | } |
| 9489 | 9489 | ||
| ... | @@ -9516,9 +9516,9 @@ fn zirBackingInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -9516,9 +9516,9 @@ fn zirBackingInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 9516 | if (union_obj.tag_usage == .tagged) break :ref try sema.unionToTag(block, operand); | 9516 | if (union_obj.tag_usage == .tagged) break :ref try sema.unionToTag(block, operand); |
| 9517 | if (union_obj.layout == .@"packed") break :ref operand; | 9517 | if (union_obj.layout == .@"packed") break :ref operand; |
| 9518 | return sema.failWithOwnedErrorMsg(block, msg: { | 9518 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 9519 | const msg = try sema.errMsg(operand_src, "non-packed union '{f}' does not have a backing integer", .{operand_ty.fmt(pt)}); | 9519 | const msg = try sema.errMsg(operand_src, "non-packed union '{f}' does not have a backing integer", .{operand_ty.fmt(zcu)}); |
| 9520 | errdefer msg.deinit(gpa); | 9520 | errdefer msg.deinit(gpa); |
| 9521 | try sema.errNote(operand_src, msg, "untagged union '{f}' does not have an enum tag with a backing integer", .{operand_ty.fmt(pt)}); | 9521 | try sema.errNote(operand_src, msg, "untagged union '{f}' does not have an enum tag with a backing integer", .{operand_ty.fmt(zcu)}); |
| 9522 | try sema.addDeclaredHereNote(msg, operand_ty); | 9522 | try sema.addDeclaredHereNote(msg, operand_ty); |
| 9523 | break :msg msg; | 9523 | break :msg msg; |
| 9524 | }); | 9524 | }); |
| ... | @@ -9526,14 +9526,14 @@ fn zirBackingInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -9526,14 +9526,14 @@ fn zirBackingInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 9526 | .@"struct" => { | 9526 | .@"struct" => { |
| 9527 | if (operand_ty.containerLayout(zcu) != .@"packed") { | 9527 | if (operand_ty.containerLayout(zcu) != .@"packed") { |
| 9528 | return sema.fail(block, operand_src, "non-packed struct '{f}' does not have a backing integer", .{ | 9528 | return sema.fail(block, operand_src, "non-packed struct '{f}' does not have a backing integer", .{ |
| 9529 | operand_ty.fmt(pt), | 9529 | operand_ty.fmt(zcu), |
| 9530 | }); | 9530 | }); |
| 9531 | } | 9531 | } |
| 9532 | break :ref operand; | 9532 | break :ref operand; |
| 9533 | }, | 9533 | }, |
| 9534 | else => { | 9534 | else => { |
| 9535 | return sema.fail(block, operand_src, "expected enum, tagged union, packed union or packed struct, found '{f}'", .{ | 9535 | return sema.fail(block, operand_src, "expected enum, tagged union, packed union or packed struct, found '{f}'", .{ |
| 9536 | operand_ty.fmt(pt), | 9536 | operand_ty.fmt(zcu), |
| 9537 | }); | 9537 | }); |
| 9538 | }, | 9538 | }, |
| 9539 | }; | 9539 | }; |
| ... | @@ -9569,12 +9569,12 @@ fn zirFromBackingIntArgTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp | ... | @@ -9569,12 +9569,12 @@ fn zirFromBackingIntArgTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp |
| 9569 | .@"enum" => {}, | 9569 | .@"enum" => {}, |
| 9570 | .@"struct", .@"union" => |type_tag| if (dest_ty.containerLayout(zcu) != .@"packed") { | 9570 | .@"struct", .@"union" => |type_tag| if (dest_ty.containerLayout(zcu) != .@"packed") { |
| 9571 | return sema.fail(block, src, "non-packed {t} '{f}' does not have a backing integer", .{ | 9571 | return sema.fail(block, src, "non-packed {t} '{f}' does not have a backing integer", .{ |
| 9572 | type_tag, dest_ty.fmt(pt), | 9572 | type_tag, dest_ty.fmt(zcu), |
| 9573 | }); | 9573 | }); |
| 9574 | }, | 9574 | }, |
| 9575 | else => { | 9575 | else => { |
| 9576 | return sema.fail(block, src, "expected enum, packed union or packed struct, found '{f}'", .{ | 9576 | return sema.fail(block, src, "expected enum, packed union or packed struct, found '{f}'", .{ |
| 9577 | dest_ty.fmt(pt), | 9577 | dest_ty.fmt(zcu), |
| 9578 | }); | 9578 | }); |
| 9579 | }, | 9579 | }, |
| 9580 | } | 9580 | } |
| ... | @@ -9615,7 +9615,7 @@ fn zirFromBackingInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr | ... | @@ -9615,7 +9615,7 @@ fn zirFromBackingInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr |
| 9615 | enum_obj.tagValueIndex(ip, backing_int_val.toIntern()) == null) | 9615 | enum_obj.tagValueIndex(ip, backing_int_val.toIntern()) == null) |
| 9616 | { | 9616 | { |
| 9617 | return sema.fail(block, src, "enum '{f}' has no tag with value '{f}'", .{ | 9617 | return sema.fail(block, src, "enum '{f}' has no tag with value '{f}'", .{ |
| 9618 | dest_ty.fmt(pt), backing_int_val.fmtValueSema(pt, sema), | 9618 | dest_ty.fmt(zcu), backing_int_val.fmtValueSema(sema), |
| 9619 | }); | 9619 | }); |
| 9620 | } | 9620 | } |
| 9621 | return .fromValue(try pt.enumValue(dest_ty, backing_int_val)); | 9621 | return .fromValue(try pt.enumValue(dest_ty, backing_int_val)); |
| ... | @@ -9661,7 +9661,7 @@ fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -9661,7 +9661,7 @@ fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 9661 | block, | 9661 | block, |
| 9662 | src, | 9662 | src, |
| 9663 | "expected float or vector type, found '{f}'", | 9663 | "expected float or vector type, found '{f}'", |
| 9664 | .{dest_ty.fmt(pt)}, | 9664 | .{dest_ty.fmt(zcu)}, |
| 9665 | ), | 9665 | ), |
| 9666 | }; | 9666 | }; |
| 9667 | 9667 | ||
| ... | @@ -9671,7 +9671,7 @@ fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -9671,7 +9671,7 @@ fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 9671 | block, | 9671 | block, |
| 9672 | operand_src, | 9672 | operand_src, |
| 9673 | "expected float or vector type, found '{f}'", | 9673 | "expected float or vector type, found '{f}'", |
| 9674 | .{operand_ty.fmt(pt)}, | 9674 | .{operand_ty.fmt(zcu)}, |
| 9675 | ), | 9675 | ), |
| 9676 | } | 9676 | } |
| 9677 | 9677 | ||
| ... | @@ -9748,7 +9748,7 @@ fn zirElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -9748,7 +9748,7 @@ fn zirElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 9748 | const capture_src = block.src(.{ .for_capture_from_input = inst_data.src_node }); | 9748 | const capture_src = block.src(.{ .for_capture_from_input = inst_data.src_node }); |
| 9749 | const msg = msg: { | 9749 | const msg = msg: { |
| 9750 | const msg = try sema.errMsg(capture_src, "pointer capture of non pointer type '{f}'", .{ | 9750 | const msg = try sema.errMsg(capture_src, "pointer capture of non pointer type '{f}'", .{ |
| 9751 | indexable_ty.fmt(pt), | 9751 | indexable_ty.fmt(zcu), |
| 9752 | }); | 9752 | }); |
| 9753 | errdefer msg.destroy(sema.gpa); | 9753 | errdefer msg.destroy(sema.gpa); |
| 9754 | if (indexable_ty.isIndexable(zcu)) { | 9754 | if (indexable_ty.isIndexable(zcu)) { |
| ... | @@ -9870,7 +9870,7 @@ fn zirSliceSentinelTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE | ... | @@ -9870,7 +9870,7 @@ fn zirSliceSentinelTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE |
| 9870 | const lhs_ptr_ty = sema.typeOf(sema.resolveInst(inst_data.operand)); | 9870 | const lhs_ptr_ty = sema.typeOf(sema.resolveInst(inst_data.operand)); |
| 9871 | const lhs_ty = switch (lhs_ptr_ty.zigTypeTag(zcu)) { | 9871 | const lhs_ty = switch (lhs_ptr_ty.zigTypeTag(zcu)) { |
| 9872 | .pointer => lhs_ptr_ty.childType(zcu), | 9872 | .pointer => lhs_ptr_ty.childType(zcu), |
| 9873 | else => return sema.fail(block, ptr_src, "expected pointer, found '{f}'", .{lhs_ptr_ty.fmt(pt)}), | 9873 | else => return sema.fail(block, ptr_src, "expected pointer, found '{f}'", .{lhs_ptr_ty.fmt(zcu)}), |
| 9874 | }; | 9874 | }; |
| 9875 | 9875 | ||
| 9876 | const sentinel_ty: Type = switch (lhs_ty.zigTypeTag(zcu)) { | 9876 | const sentinel_ty: Type = switch (lhs_ty.zigTypeTag(zcu)) { |
| ... | @@ -9885,7 +9885,7 @@ fn zirSliceSentinelTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE | ... | @@ -9885,7 +9885,7 @@ fn zirSliceSentinelTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE |
| 9885 | }; | 9885 | }; |
| 9886 | }, | 9886 | }, |
| 9887 | }, | 9887 | }, |
| 9888 | else => return sema.fail(block, src, "slice of non-array type '{f}'", .{lhs_ty.fmt(pt)}), | 9888 | else => return sema.fail(block, src, "slice of non-array type '{f}'", .{lhs_ty.fmt(zcu)}), |
| 9889 | }; | 9889 | }; |
| 9890 | 9890 | ||
| 9891 | return Air.internedToRef(sentinel_ty.toIntern()); | 9891 | return Air.internedToRef(sentinel_ty.toIntern()); |
| ... | @@ -9955,7 +9955,7 @@ fn zirSwitchBlockErrUnion(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp | ... | @@ -9955,7 +9955,7 @@ fn zirSwitchBlockErrUnion(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp |
| 9955 | }; | 9955 | }; |
| 9956 | if (err_union_ty.zigTypeTag(zcu) != .error_union) { | 9956 | if (err_union_ty.zigTypeTag(zcu) != .error_union) { |
| 9957 | return sema.fail(block, operand_src, "expected error union type, found '{f}'", .{ | 9957 | return sema.fail(block, operand_src, "expected error union type, found '{f}'", .{ |
| 9958 | err_union_ty.fmt(pt), | 9958 | err_union_ty.fmt(zcu), |
| 9959 | }); | 9959 | }); |
| 9960 | } | 9960 | } |
| 9961 | 9961 | ||
| ... | @@ -10817,7 +10817,7 @@ fn finishSwitchBr( | ... | @@ -10817,7 +10817,7 @@ fn finishSwitchBr( |
| 10817 | else => {}, | 10817 | else => {}, |
| 10818 | } | 10818 | } |
| 10819 | return sema.fail(block, else_prong_src, "cannot enumerate values of type '{f}' for 'inline else'", .{ | 10819 | return sema.fail(block, else_prong_src, "cannot enumerate values of type '{f}' for 'inline else'", .{ |
| 10820 | item_ty.fmt(pt), | 10820 | item_ty.fmt(zcu), |
| 10821 | }); | 10821 | }); |
| 10822 | }; | 10822 | }; |
| 10823 | var unhandled_it = validated_switch.iterateUnhandledItems(error_names, min_int); | 10823 | var unhandled_it = validated_switch.iterateUnhandledItems(error_names, min_int); |
| ... | @@ -11253,7 +11253,7 @@ fn validateSwitchBlock( | ... | @@ -11253,7 +11253,7 @@ fn validateSwitchBlock( |
| 11253 | 11253 | ||
| 11254 | .optional => return sema.failWithOwnedErrorMsg(block, msg: { | 11254 | .optional => return sema.failWithOwnedErrorMsg(block, msg: { |
| 11255 | const msg = try sema.errMsg(operand_src, "switch on optional type '{f}'", .{ | 11255 | const msg = try sema.errMsg(operand_src, "switch on optional type '{f}'", .{ |
| 11256 | operand_ty.fmt(pt), | 11256 | operand_ty.fmt(zcu), |
| 11257 | }); | 11257 | }); |
| 11258 | errdefer msg.destroy(gpa); | 11258 | errdefer msg.destroy(gpa); |
| 11259 | try sema.errNote(operand_src, msg, "consider using '.?', 'orelse', or 'if'", .{}); | 11259 | try sema.errNote(operand_src, msg, "consider using '.?', 'orelse', or 'if'", .{}); |
| ... | @@ -11262,7 +11262,7 @@ fn validateSwitchBlock( | ... | @@ -11262,7 +11262,7 @@ fn validateSwitchBlock( |
| 11262 | 11262 | ||
| 11263 | .error_union => return sema.failWithOwnedErrorMsg(block, msg: { | 11263 | .error_union => return sema.failWithOwnedErrorMsg(block, msg: { |
| 11264 | const msg = try sema.errMsg(operand_src, "switch on error union type '{f}'", .{ | 11264 | const msg = try sema.errMsg(operand_src, "switch on error union type '{f}'", .{ |
| 11265 | operand_ty.fmt(pt), | 11265 | operand_ty.fmt(zcu), |
| 11266 | }); | 11266 | }); |
| 11267 | errdefer msg.destroy(gpa); | 11267 | errdefer msg.destroy(gpa); |
| 11268 | try sema.errNote(operand_src, msg, "consider using 'try', 'catch', or 'if'", .{}); | 11268 | try sema.errNote(operand_src, msg, "consider using 'try', 'catch', or 'if'", .{}); |
| ... | @@ -11282,14 +11282,14 @@ fn validateSwitchBlock( | ... | @@ -11282,14 +11282,14 @@ fn validateSwitchBlock( |
| 11282 | .spirv, | 11282 | .spirv, |
| 11283 | => {}, | 11283 | => {}, |
| 11284 | } | 11284 | } |
| 11285 | return sema.fail(block, operand_src, "switch on type '{f}'", .{operand_ty.fmt(pt)}); | 11285 | return sema.fail(block, operand_src, "switch on type '{f}'", .{operand_ty.fmt(zcu)}); |
| 11286 | }; | 11286 | }; |
| 11287 | 11287 | ||
| 11288 | if (zir_switch.has_continue and !block.isComptime()) { | 11288 | if (zir_switch.has_continue and !block.isComptime()) { |
| 11289 | if (operand_ty.comptimeOnly(zcu)) { | 11289 | if (operand_ty.comptimeOnly(zcu)) { |
| 11290 | // Even if the operand is comptime-known, this `switch` is runtime. | 11290 | // Even if the operand is comptime-known, this `switch` is runtime. |
| 11291 | return sema.failWithOwnedErrorMsg(block, msg: { | 11291 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 11292 | const msg = try sema.errMsg(operand_src, "operand of switch loop has comptime-only type '{f}'", .{operand_ty.fmt(pt)}); | 11292 | const msg = try sema.errMsg(operand_src, "operand of switch loop has comptime-only type '{f}'", .{operand_ty.fmt(zcu)}); |
| 11293 | errdefer msg.destroy(gpa); | 11293 | errdefer msg.destroy(gpa); |
| 11294 | try sema.errNote(operand_src, msg, "switch loops are evaluated at runtime outside of comptime scopes", .{}); | 11294 | try sema.errNote(operand_src, msg, "switch loops are evaluated at runtime outside of comptime scopes", .{}); |
| 11295 | try sema.explainWhyTypeIsComptime(msg, operand_src, operand_ty); | 11295 | try sema.explainWhyTypeIsComptime(msg, operand_src, operand_ty); |
| ... | @@ -11405,7 +11405,7 @@ fn validateSwitchBlock( | ... | @@ -11405,7 +11405,7 @@ fn validateSwitchBlock( |
| 11405 | const msg = try sema.errMsg( | 11405 | const msg = try sema.errMsg( |
| 11406 | operand_src, | 11406 | operand_src, |
| 11407 | "ranges not allowed when switching on type '{f}'", | 11407 | "ranges not allowed when switching on type '{f}'", |
| 11408 | .{operand_ty.fmt(pt)}, | 11408 | .{operand_ty.fmt(zcu)}, |
| 11409 | ); | 11409 | ); |
| 11410 | errdefer msg.destroy(gpa); | 11410 | errdefer msg.destroy(gpa); |
| 11411 | try sema.errNote( | 11411 | try sema.errNote( |
| ... | @@ -11467,7 +11467,7 @@ fn validateSwitchBlock( | ... | @@ -11467,7 +11467,7 @@ fn validateSwitchBlock( |
| 11467 | item_ty.srcLoc(zcu), | 11467 | item_ty.srcLoc(zcu), |
| 11468 | msg, | 11468 | msg, |
| 11469 | "enum '{f}' declared here", | 11469 | "enum '{f}' declared here", |
| 11470 | .{item_ty.fmt(pt)}, | 11470 | .{item_ty.fmt(zcu)}, |
| 11471 | ); | 11471 | ); |
| 11472 | break :msg msg; | 11472 | break :msg msg; |
| 11473 | }; | 11473 | }; |
| ... | @@ -11590,7 +11590,7 @@ fn validateSwitchBlock( | ... | @@ -11590,7 +11590,7 @@ fn validateSwitchBlock( |
| 11590 | block, | 11590 | block, |
| 11591 | src, | 11591 | src, |
| 11592 | "else prong required when switching on type '{f}'", | 11592 | "else prong required when switching on type '{f}'", |
| 11593 | .{item_ty.fmt(pt)}, | 11593 | .{item_ty.fmt(zcu)}, |
| 11594 | ); | 11594 | ); |
| 11595 | } | 11595 | } |
| 11596 | }, | 11596 | }, |
| ... | @@ -12656,7 +12656,7 @@ fn validateSwitchItemOrRange( | ... | @@ -12656,7 +12656,7 @@ fn validateSwitchItemOrRange( |
| 12656 | if (overlap_start.eql(overlap_end, item_ty, zcu)) { | 12656 | if (overlap_start.eql(overlap_end, item_ty, zcu)) { |
| 12657 | return sema.failWithOwnedErrorMsg(block, msg: { | 12657 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 12658 | const msg = try sema.errMsg(item_src, "duplicate switch value '{f}'", .{ | 12658 | const msg = try sema.errMsg(item_src, "duplicate switch value '{f}'", .{ |
| 12659 | overlap_start.fmtValueSema(pt, sema), | 12659 | overlap_start.fmtValueSema(sema), |
| 12660 | }); | 12660 | }); |
| 12661 | errdefer msg.destroy(sema.gpa); | 12661 | errdefer msg.destroy(sema.gpa); |
| 12662 | if (prev_range.first.eql(prev_range.last, item_ty, zcu)) { | 12662 | if (prev_range.first.eql(prev_range.last, item_ty, zcu)) { |
| ... | @@ -12678,7 +12678,7 @@ fn validateSwitchItemOrRange( | ... | @@ -12678,7 +12678,7 @@ fn validateSwitchItemOrRange( |
| 12678 | } else { | 12678 | } else { |
| 12679 | try sema.errNote(prev_range.src, msg, "overlaps with previous range here", .{}); | 12679 | try sema.errNote(prev_range.src, msg, "overlaps with previous range here", .{}); |
| 12680 | try sema.errNote(prev_range.src, msg, "ranges overlap from '{f}' to '{f}'", .{ | 12680 | try sema.errNote(prev_range.src, msg, "ranges overlap from '{f}' to '{f}'", .{ |
| 12681 | overlap_start.fmtValueSema(pt, sema), overlap_end.fmtValueSema(pt, sema), | 12681 | overlap_start.fmtValueSema(sema), overlap_end.fmtValueSema(sema), |
| 12682 | }); | 12682 | }); |
| 12683 | } | 12683 | } |
| 12684 | break :msg msg; | 12684 | break :msg msg; |
| ... | @@ -12720,7 +12720,7 @@ fn validateSwitchItemOrRange( | ... | @@ -12720,7 +12720,7 @@ fn validateSwitchItemOrRange( |
| 12720 | if (maybe_prev_src) |prev_src| { | 12720 | if (maybe_prev_src) |prev_src| { |
| 12721 | return sema.failWithOwnedErrorMsg(block, msg: { | 12721 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 12722 | const msg = try sema.errMsg(item_src, "duplicate switch value '{f}'", .{ | 12722 | const msg = try sema.errMsg(item_src, "duplicate switch value '{f}'", .{ |
| 12723 | item_val.fmtValueSema(pt, sema), | 12723 | item_val.fmtValueSema(sema), |
| 12724 | }); | 12724 | }); |
| 12725 | errdefer msg.destroy(sema.gpa); | 12725 | errdefer msg.destroy(sema.gpa); |
| 12726 | try sema.errNote(prev_src, msg, "previous value here", .{}); | 12726 | try sema.errNote(prev_src, msg, "previous value here", .{}); |
| ... | @@ -12877,7 +12877,7 @@ fn zirHasField(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -12877,7 +12877,7 @@ fn zirHasField(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 12877 | else => {}, | 12877 | else => {}, |
| 12878 | } | 12878 | } |
| 12879 | return sema.fail(block, ty_src, "type '{f}' does not support '@hasField'", .{ | 12879 | return sema.fail(block, ty_src, "type '{f}' does not support '@hasField'", .{ |
| 12880 | ty.fmt(pt), | 12880 | ty.fmt(zcu), |
| 12881 | }); | 12881 | }); |
| 12882 | }; | 12882 | }; |
| 12883 | return if (has_field) .bool_true else .bool_false; | 12883 | return if (has_field) .bool_true else .bool_false; |
| ... | @@ -13088,7 +13088,7 @@ fn zirShl( | ... | @@ -13088,7 +13088,7 @@ fn zirShl( |
| 13088 | break :rs lhs_src; | 13088 | break :rs lhs_src; |
| 13089 | } else { | 13089 | } else { |
| 13090 | if (air_tag == .shl_sat and scalar_rhs_ty.isSignedInt(zcu)) { | 13090 | if (air_tag == .shl_sat and scalar_rhs_ty.isSignedInt(zcu)) { |
| 13091 | return sema.fail(block, rhs_src, "shift by signed type '{f}'", .{rhs_ty.fmt(pt)}); | 13091 | return sema.fail(block, rhs_src, "shift by signed type '{f}'", .{rhs_ty.fmt(zcu)}); |
| 13092 | } | 13092 | } |
| 13093 | if (scalar_ty.toIntern() == .comptime_int_type) { | 13093 | if (scalar_ty.toIntern() == .comptime_int_type) { |
| 13094 | return sema.fail(block, src, "LHS of shift must be a fixed-width integer type, or RHS must be comptime-known", .{}); | 13094 | return sema.fail(block, src, "LHS of shift must be a fixed-width integer type, or RHS must be comptime-known", .{}); |
| ... | @@ -13370,7 +13370,7 @@ fn zirBitNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -13370,7 +13370,7 @@ fn zirBitNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 13370 | const scalar_tag = scalar_ty.zigTypeTag(zcu); | 13370 | const scalar_tag = scalar_ty.zigTypeTag(zcu); |
| 13371 | 13371 | ||
| 13372 | if (scalar_tag != .int and scalar_tag != .bool) | 13372 | if (scalar_tag != .int and scalar_tag != .bool) |
| 13373 | return sema.fail(block, operand_src, "bitwise not operation on type '{f}'", .{operand_ty.fmt(pt)}); | 13373 | return sema.fail(block, operand_src, "bitwise not operation on type '{f}'", .{operand_ty.fmt(zcu)}); |
| 13374 | 13374 | ||
| 13375 | return analyzeBitNot(sema, block, operand, src); | 13375 | return analyzeBitNot(sema, block, operand, src); |
| 13376 | } | 13376 | } |
| ... | @@ -13506,11 +13506,11 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -13506,11 +13506,11 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 13506 | 13506 | ||
| 13507 | const lhs_info = try sema.getArrayCatInfo(block, lhs_src, lhs, rhs_ty) orelse lhs_info: { | 13507 | const lhs_info = try sema.getArrayCatInfo(block, lhs_src, lhs, rhs_ty) orelse lhs_info: { |
| 13508 | if (lhs_is_tuple) break :lhs_info undefined; | 13508 | if (lhs_is_tuple) break :lhs_info undefined; |
| 13509 | return sema.fail(block, lhs_src, "expected indexable; found '{f}'", .{lhs_ty.fmt(pt)}); | 13509 | return sema.fail(block, lhs_src, "expected indexable; found '{f}'", .{lhs_ty.fmt(zcu)}); |
| 13510 | }; | 13510 | }; |
| 13511 | const rhs_info = try sema.getArrayCatInfo(block, rhs_src, rhs, lhs_ty) orelse { | 13511 | const rhs_info = try sema.getArrayCatInfo(block, rhs_src, rhs, lhs_ty) orelse { |
| 13512 | assert(!rhs_is_tuple); | 13512 | assert(!rhs_is_tuple); |
| 13513 | return sema.fail(block, rhs_src, "expected indexable; found '{f}'", .{rhs_ty.fmt(pt)}); | 13513 | return sema.fail(block, rhs_src, "expected indexable; found '{f}'", .{rhs_ty.fmt(zcu)}); |
| 13514 | }; | 13514 | }; |
| 13515 | 13515 | ||
| 13516 | const resolved_elem_ty = t: { | 13516 | const resolved_elem_ty = t: { |
| ... | @@ -13934,7 +13934,7 @@ fn zirNegate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -13934,7 +13934,7 @@ fn zirNegate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 13934 | .int, .comptime_int, .float, .comptime_float => false, | 13934 | .int, .comptime_int, .float, .comptime_float => false, |
| 13935 | else => true, | 13935 | else => true, |
| 13936 | }) { | 13936 | }) { |
| 13937 | return sema.fail(block, src, "negation of type '{f}'", .{rhs_ty.fmt(pt)}); | 13937 | return sema.fail(block, src, "negation of type '{f}'", .{rhs_ty.fmt(zcu)}); |
| 13938 | } | 13938 | } |
| 13939 | 13939 | ||
| 13940 | if (rhs_scalar_ty.isAnyFloat()) { | 13940 | if (rhs_scalar_ty.isAnyFloat()) { |
| ... | @@ -13965,7 +13965,7 @@ fn zirNegateWrap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -13965,7 +13965,7 @@ fn zirNegateWrap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 13965 | 13965 | ||
| 13966 | switch (rhs_scalar_ty.zigTypeTag(zcu)) { | 13966 | switch (rhs_scalar_ty.zigTypeTag(zcu)) { |
| 13967 | .int, .comptime_int, .float, .comptime_float => {}, | 13967 | .int, .comptime_int, .float, .comptime_float => {}, |
| 13968 | else => return sema.fail(block, src, "negation of type '{f}'", .{rhs_ty.fmt(pt)}), | 13968 | else => return sema.fail(block, src, "negation of type '{f}'", .{rhs_ty.fmt(zcu)}), |
| 13969 | } | 13969 | } |
| 13970 | 13970 | ||
| 13971 | const lhs = Air.internedToRef((try sema.splat(rhs_ty, try pt.intValue(rhs_scalar_ty, 0))).toIntern()); | 13971 | const lhs = Air.internedToRef((try sema.splat(rhs_ty, try pt.intValue(rhs_scalar_ty, 0))).toIntern()); |
| ... | @@ -14037,7 +14037,7 @@ fn zirDiv(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins | ... | @@ -14037,7 +14037,7 @@ fn zirDiv(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins |
| 14037 | block, | 14037 | block, |
| 14038 | src, | 14038 | src, |
| 14039 | "ambiguous coercion of division operands '{f}' and '{f}'; non-zero remainder '{f}'", | 14039 | "ambiguous coercion of division operands '{f}' and '{f}'; non-zero remainder '{f}'", |
| 14040 | .{ lhs_ty.fmt(pt), rhs_ty.fmt(pt), rem.fmtValueSema(pt, sema) }, | 14040 | .{ lhs_ty.fmt(zcu), rhs_ty.fmt(zcu), rem.fmtValueSema(sema) }, |
| 14041 | ); | 14041 | ); |
| 14042 | } | 14042 | } |
| 14043 | } | 14043 | } |
| ... | @@ -14088,7 +14088,7 @@ fn zirDiv(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins | ... | @@ -14088,7 +14088,7 @@ fn zirDiv(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins |
| 14088 | block, | 14088 | block, |
| 14089 | src, | 14089 | src, |
| 14090 | "division with '{f}' and '{f}': signed integers must use @divTrunc, @divFloor, @divCeil, or @divExact", | 14090 | "division with '{f}' and '{f}': signed integers must use @divTrunc, @divFloor, @divCeil, or @divExact", |
| 14091 | .{ lhs_ty.fmt(pt), rhs_ty.fmt(pt) }, | 14091 | .{ lhs_ty.fmt(zcu), rhs_ty.fmt(zcu) }, |
| 14092 | ); | 14092 | ); |
| 14093 | } | 14093 | } |
| 14094 | break :blk .div_trunc; | 14094 | break :blk .div_trunc; |
| ... | @@ -14805,7 +14805,7 @@ fn zirOverflowArithmetic( | ... | @@ -14805,7 +14805,7 @@ fn zirOverflowArithmetic( |
| 14805 | const rhs = try sema.coerce(block, rhs_dest_ty, uncasted_rhs, rhs_src); | 14805 | const rhs = try sema.coerce(block, rhs_dest_ty, uncasted_rhs, rhs_src); |
| 14806 | 14806 | ||
| 14807 | if (dest_ty.scalarType(zcu).zigTypeTag(zcu) != .int) { | 14807 | if (dest_ty.scalarType(zcu).zigTypeTag(zcu) != .int) { |
| 14808 | return sema.fail(block, src, "expected vector of integers or integer tag type, found '{f}'", .{dest_ty.fmt(pt)}); | 14808 | return sema.fail(block, src, "expected vector of integers or integer tag type, found '{f}'", .{dest_ty.fmt(zcu)}); |
| 14809 | } | 14809 | } |
| 14810 | 14810 | ||
| 14811 | const maybe_lhs_val = sema.resolveValue(lhs); | 14811 | const maybe_lhs_val = sema.resolveValue(lhs); |
| ... | @@ -15065,7 +15065,7 @@ fn analyzeArithmetic( | ... | @@ -15065,7 +15065,7 @@ fn analyzeArithmetic( |
| 15065 | }; | 15065 | }; |
| 15066 | if (lhs_elem_ty.toIntern() != rhs_elem_ty.toIntern()) { | 15066 | if (lhs_elem_ty.toIntern() != rhs_elem_ty.toIntern()) { |
| 15067 | return sema.fail(block, src, "incompatible pointer arithmetic operands '{f}' and '{f}'", .{ | 15067 | return sema.fail(block, src, "incompatible pointer arithmetic operands '{f}' and '{f}'", .{ |
| 15068 | lhs_ty.fmt(pt), rhs_ty.fmt(pt), | 15068 | lhs_ty.fmt(zcu), rhs_ty.fmt(zcu), |
| 15069 | }); | 15069 | }); |
| 15070 | } | 15070 | } |
| 15071 | 15071 | ||
| ... | @@ -15073,7 +15073,7 @@ fn analyzeArithmetic( | ... | @@ -15073,7 +15073,7 @@ fn analyzeArithmetic( |
| 15073 | const elem_size = lhs_elem_ty.abiSize(zcu); | 15073 | const elem_size = lhs_elem_ty.abiSize(zcu); |
| 15074 | if (elem_size == 0) { | 15074 | if (elem_size == 0) { |
| 15075 | return sema.fail(block, src, "pointer subtraction requires element type '{f}' to have runtime bits", .{ | 15075 | return sema.fail(block, src, "pointer subtraction requires element type '{f}' to have runtime bits", .{ |
| 15076 | lhs_elem_ty.fmt(pt), | 15076 | lhs_elem_ty.fmt(zcu), |
| 15077 | }); | 15077 | }); |
| 15078 | } | 15078 | } |
| 15079 | 15079 | ||
| ... | @@ -15380,20 +15380,20 @@ fn zirAsm( | ... | @@ -15380,20 +15380,20 @@ fn zirAsm( |
| 15380 | .int, .float, .bool, .vector => {}, | 15380 | .int, .float, .bool, .vector => {}, |
| 15381 | 15381 | ||
| 15382 | .pointer => if (out_ty.isSlice(zcu)) return sema.failWithOwnedErrorMsg(block, msg: { | 15382 | .pointer => if (out_ty.isSlice(zcu)) return sema.failWithOwnedErrorMsg(block, msg: { |
| 15383 | const msg = try sema.errMsg(output_src, "invalid inline assembly output type '{f}'", .{out_ty.fmt(pt)}); | 15383 | const msg = try sema.errMsg(output_src, "invalid inline assembly output type '{f}'", .{out_ty.fmt(zcu)}); |
| 15384 | errdefer msg.destroy(gpa); | 15384 | errdefer msg.destroy(gpa); |
| 15385 | try sema.errNote(output_src, msg, "consider separate outputs for 'ptr' and 'len'", .{}); | 15385 | try sema.errNote(output_src, msg, "consider separate outputs for 'ptr' and 'len'", .{}); |
| 15386 | break :msg msg; | 15386 | break :msg msg; |
| 15387 | }), | 15387 | }), |
| 15388 | 15388 | ||
| 15389 | .optional => if (!out_ty.isPtrLikeOptional(zcu)) { | 15389 | .optional => if (!out_ty.isPtrLikeOptional(zcu)) { |
| 15390 | return sema.fail(block, output_src, "invalid inline assembly output type '{f}'", .{out_ty.fmt(pt)}); | 15390 | return sema.fail(block, output_src, "invalid inline assembly output type '{f}'", .{out_ty.fmt(zcu)}); |
| 15391 | }, | 15391 | }, |
| 15392 | 15392 | ||
| 15393 | .@"enum" => switch (ip.loadEnumType(out_ty.toIntern()).int_tag_mode) { | 15393 | .@"enum" => switch (ip.loadEnumType(out_ty.toIntern()).int_tag_mode) { |
| 15394 | .explicit => {}, | 15394 | .explicit => {}, |
| 15395 | .auto => return sema.failWithOwnedErrorMsg(block, msg: { | 15395 | .auto => return sema.failWithOwnedErrorMsg(block, msg: { |
| 15396 | const msg = try sema.errMsg(output_src, "invalid inline assembly output type '{f}'", .{out_ty.fmt(pt)}); | 15396 | const msg = try sema.errMsg(output_src, "invalid inline assembly output type '{f}'", .{out_ty.fmt(zcu)}); |
| 15397 | errdefer msg.destroy(gpa); | 15397 | errdefer msg.destroy(gpa); |
| 15398 | try sema.errNote(out_ty.srcLoc(zcu), msg, "integer tag type of enum is inferred", .{}); | 15398 | try sema.errNote(out_ty.srcLoc(zcu), msg, "integer tag type of enum is inferred", .{}); |
| 15399 | try sema.errNote(out_ty.srcLoc(zcu), msg, "consider explicitly specifying the integer tag type", .{}); | 15399 | try sema.errNote(out_ty.srcLoc(zcu), msg, "consider explicitly specifying the integer tag type", .{}); |
| ... | @@ -15404,7 +15404,7 @@ fn zirAsm( | ... | @@ -15404,7 +15404,7 @@ fn zirAsm( |
| 15404 | .@"struct" => switch (out_ty.containerLayout(zcu)) { | 15404 | .@"struct" => switch (out_ty.containerLayout(zcu)) { |
| 15405 | .@"packed" => {}, | 15405 | .@"packed" => {}, |
| 15406 | .auto, .@"extern" => return sema.failWithOwnedErrorMsg(block, msg: { | 15406 | .auto, .@"extern" => return sema.failWithOwnedErrorMsg(block, msg: { |
| 15407 | const msg = try sema.errMsg(output_src, "invalid inline assembly output type '{f}'", .{out_ty.fmt(pt)}); | 15407 | const msg = try sema.errMsg(output_src, "invalid inline assembly output type '{f}'", .{out_ty.fmt(zcu)}); |
| 15408 | errdefer msg.destroy(gpa); | 15408 | errdefer msg.destroy(gpa); |
| 15409 | try sema.errNote(output_src, msg, "struct types cannot be passed to inline assembly", .{}); | 15409 | try sema.errNote(output_src, msg, "struct types cannot be passed to inline assembly", .{}); |
| 15410 | try sema.addDeclaredHereNote(msg, out_ty); | 15410 | try sema.addDeclaredHereNote(msg, out_ty); |
| ... | @@ -15415,7 +15415,7 @@ fn zirAsm( | ... | @@ -15415,7 +15415,7 @@ fn zirAsm( |
| 15415 | .@"union" => switch (out_ty.containerLayout(zcu)) { | 15415 | .@"union" => switch (out_ty.containerLayout(zcu)) { |
| 15416 | .@"packed" => {}, | 15416 | .@"packed" => {}, |
| 15417 | .auto, .@"extern" => return sema.failWithOwnedErrorMsg(block, msg: { | 15417 | .auto, .@"extern" => return sema.failWithOwnedErrorMsg(block, msg: { |
| 15418 | const msg = try sema.errMsg(output_src, "invalid inline assembly output type '{f}'", .{out_ty.fmt(pt)}); | 15418 | const msg = try sema.errMsg(output_src, "invalid inline assembly output type '{f}'", .{out_ty.fmt(zcu)}); |
| 15419 | errdefer msg.destroy(gpa); | 15419 | errdefer msg.destroy(gpa); |
| 15420 | try sema.errNote(output_src, msg, "union types cannot be passed to inline assembly", .{}); | 15420 | try sema.errNote(output_src, msg, "union types cannot be passed to inline assembly", .{}); |
| 15421 | try sema.addDeclaredHereNote(msg, out_ty); | 15421 | try sema.addDeclaredHereNote(msg, out_ty); |
| ... | @@ -15424,7 +15424,7 @@ fn zirAsm( | ... | @@ -15424,7 +15424,7 @@ fn zirAsm( |
| 15424 | }, | 15424 | }, |
| 15425 | 15425 | ||
| 15426 | .array => return sema.failWithOwnedErrorMsg(block, msg: { | 15426 | .array => return sema.failWithOwnedErrorMsg(block, msg: { |
| 15427 | const msg = try sema.errMsg(output_src, "invalid inline assembly output type '{f}'", .{out_ty.fmt(pt)}); | 15427 | const msg = try sema.errMsg(output_src, "invalid inline assembly output type '{f}'", .{out_ty.fmt(zcu)}); |
| 15428 | errdefer msg.destroy(gpa); | 15428 | errdefer msg.destroy(gpa); |
| 15429 | try sema.errNote(output_src, msg, "array types cannot be passed to inline assembly", .{}); | 15429 | try sema.errNote(output_src, msg, "array types cannot be passed to inline assembly", .{}); |
| 15430 | break :msg msg; | 15430 | break :msg msg; |
| ... | @@ -15445,7 +15445,7 @@ fn zirAsm( | ... | @@ -15445,7 +15445,7 @@ fn zirAsm( |
| 15445 | .@"anyframe", | 15445 | .@"anyframe", |
| 15446 | .enum_literal, | 15446 | .enum_literal, |
| 15447 | .spirv, | 15447 | .spirv, |
| 15448 | => return sema.fail(block, output_src, "invalid inline assembly output type '{f}'", .{out_ty.fmt(pt)}), | 15448 | => return sema.fail(block, output_src, "invalid inline assembly output type '{f}'", .{out_ty.fmt(zcu)}), |
| 15449 | } | 15449 | } |
| 15450 | 15450 | ||
| 15451 | const constraint = sema.code.nullTerminatedString(output.data.constraint); | 15451 | const constraint = sema.code.nullTerminatedString(output.data.constraint); |
| ... | @@ -15501,7 +15501,7 @@ fn zirAsm( | ... | @@ -15501,7 +15501,7 @@ fn zirAsm( |
| 15501 | }, | 15501 | }, |
| 15502 | else => true, | 15502 | else => true, |
| 15503 | }; | 15503 | }; |
| 15504 | if (bad_type) return sema.fail(block, input_src, "unsupported type '{f}' for 'c' constraint", .{uncasted_arg_ty.fmt(pt)}); | 15504 | if (bad_type) return sema.fail(block, input_src, "unsupported type '{f}' for 'c' constraint", .{uncasted_arg_ty.fmt(zcu)}); |
| 15505 | } | 15505 | } |
| 15506 | needed_capacity += (constraint.len + name.len + (2 + 3)) / 4; | 15506 | needed_capacity += (constraint.len + name.len + (2 + 3)) / 4; |
| 15507 | inputs[arg_i] = .{ .c = constraint, .n = name }; | 15507 | inputs[arg_i] = .{ .c = constraint, .n = name }; |
| ... | @@ -15599,7 +15599,7 @@ fn zirCmpEq( | ... | @@ -15599,7 +15599,7 @@ fn zirCmpEq( |
| 15599 | 15599 | ||
| 15600 | if (lhs_ty_tag == .null or rhs_ty_tag == .null) { | 15600 | if (lhs_ty_tag == .null or rhs_ty_tag == .null) { |
| 15601 | const non_null_type = if (lhs_ty_tag == .null) rhs_ty else lhs_ty; | 15601 | const non_null_type = if (lhs_ty_tag == .null) rhs_ty else lhs_ty; |
| 15602 | return sema.fail(block, src, "comparison of '{f}' with null", .{non_null_type.fmt(pt)}); | 15602 | return sema.fail(block, src, "comparison of '{f}' with null", .{non_null_type.fmt(zcu)}); |
| 15603 | } | 15603 | } |
| 15604 | 15604 | ||
| 15605 | if (lhs_ty_tag == .@"union" and (rhs_ty_tag == .enum_literal or rhs_ty_tag == .@"enum")) { | 15605 | if (lhs_ty_tag == .@"union" and (rhs_ty_tag == .enum_literal or rhs_ty_tag == .@"enum")) { |
| ... | @@ -15655,7 +15655,7 @@ fn analyzeCmpUnionTag( | ... | @@ -15655,7 +15655,7 @@ fn analyzeCmpUnionTag( |
| 15655 | const msg = msg: { | 15655 | const msg = msg: { |
| 15656 | const msg = try sema.errMsg(un_src, "comparison of union and enum literal is only valid for tagged union types", .{}); | 15656 | const msg = try sema.errMsg(un_src, "comparison of union and enum literal is only valid for tagged union types", .{}); |
| 15657 | errdefer msg.destroy(sema.gpa); | 15657 | errdefer msg.destroy(sema.gpa); |
| 15658 | try sema.errNote(union_ty.srcLoc(zcu), msg, "union '{f}' is not a tagged union", .{union_ty.fmt(pt)}); | 15658 | try sema.errNote(union_ty.srcLoc(zcu), msg, "union '{f}' is not a tagged union", .{union_ty.fmt(zcu)}); |
| 15659 | break :msg msg; | 15659 | break :msg msg; |
| 15660 | }; | 15660 | }; |
| 15661 | return sema.failWithOwnedErrorMsg(block, msg); | 15661 | return sema.failWithOwnedErrorMsg(block, msg); |
| ... | @@ -15739,7 +15739,7 @@ fn analyzeCmp( | ... | @@ -15739,7 +15739,7 @@ fn analyzeCmp( |
| 15739 | const resolved_type = try sema.resolvePeerTypes(block, src, instructions, .{ .override = &[_]?LazySrcLoc{ lhs_src, rhs_src } }); | 15739 | const resolved_type = try sema.resolvePeerTypes(block, src, instructions, .{ .override = &[_]?LazySrcLoc{ lhs_src, rhs_src } }); |
| 15740 | if (!resolved_type.isSelfComparable(zcu, is_equality_cmp)) { | 15740 | if (!resolved_type.isSelfComparable(zcu, is_equality_cmp)) { |
| 15741 | return sema.fail(block, src, "operator {s} not allowed for type '{f}'", .{ | 15741 | return sema.fail(block, src, "operator {s} not allowed for type '{f}'", .{ |
| 15742 | compareOperatorName(op), resolved_type.fmt(pt), | 15742 | compareOperatorName(op), resolved_type.fmt(zcu), |
| 15743 | }); | 15743 | }); |
| 15744 | } | 15744 | } |
| 15745 | const casted_lhs = try sema.coerce(block, resolved_type, lhs, lhs_src); | 15745 | const casted_lhs = try sema.coerce(block, resolved_type, lhs, lhs_src); |
| ... | @@ -15845,11 +15845,11 @@ fn zirSizeOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -15845,11 +15845,11 @@ fn zirSizeOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 15845 | try sema.ensureLayoutResolved(ty, operand_src, .size_of); | 15845 | try sema.ensureLayoutResolved(ty, operand_src, .size_of); |
| 15846 | switch (ty.classify(zcu)) { | 15846 | switch (ty.classify(zcu)) { |
| 15847 | .no_possible_value, | 15847 | .no_possible_value, |
| 15848 | => return sema.fail(block, operand_src, "no size available for uninstantiable type '{f}'", .{ty.fmt(pt)}), | 15848 | => return sema.fail(block, operand_src, "no size available for uninstantiable type '{f}'", .{ty.fmt(zcu)}), |
| 15849 | 15849 | ||
| 15850 | .partially_comptime, | 15850 | .partially_comptime, |
| 15851 | .fully_comptime, | 15851 | .fully_comptime, |
| 15852 | => return sema.fail(block, operand_src, "no size available for comptime-only type '{f}'", .{ty.fmt(pt)}), | 15852 | => return sema.fail(block, operand_src, "no size available for comptime-only type '{f}'", .{ty.fmt(zcu)}), |
| 15853 | 15853 | ||
| 15854 | .one_possible_value => { | 15854 | .one_possible_value => { |
| 15855 | assert(ty.abiSize(zcu) == 0); | 15855 | assert(ty.abiSize(zcu) == 0); |
| ... | @@ -15872,7 +15872,7 @@ fn zirBitSizeOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -15872,7 +15872,7 @@ fn zirBitSizeOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 15872 | operand_ty.zigTypeTag(zcu) != .error_set and | 15872 | operand_ty.zigTypeTag(zcu) != .error_set and |
| 15873 | operand_ty.zigTypeTag(zcu) != .@"enum") | 15873 | operand_ty.zigTypeTag(zcu) != .@"enum") |
| 15874 | { | 15874 | { |
| 15875 | return sema.fail(block, operand_src, "no bit size available for type '{f}'", .{operand_ty.fmt(pt)}); | 15875 | return sema.fail(block, operand_src, "no bit size available for type '{f}'", .{operand_ty.fmt(zcu)}); |
| 15876 | } | 15876 | } |
| 15877 | try sema.ensureLayoutResolved(operand_ty, operand_src, .size_of); | 15877 | try sema.ensureLayoutResolved(operand_ty, operand_src, .size_of); |
| 15878 | return .fromValue(try pt.intValue(.comptime_int, operand_ty.bitSize(zcu))); | 15878 | return .fromValue(try pt.intValue(.comptime_int, operand_ty.bitSize(zcu))); |
| ... | @@ -17357,7 +17357,7 @@ fn log2IntType(sema: *Sema, block: *Block, operand: Type, src: LazySrcLoc) Compi | ... | @@ -17357,7 +17357,7 @@ fn log2IntType(sema: *Sema, block: *Block, operand: Type, src: LazySrcLoc) Compi |
| 17357 | block, | 17357 | block, |
| 17358 | src, | 17358 | src, |
| 17359 | "bit shifting operation expected integer type, found '{f}'", | 17359 | "bit shifting operation expected integer type, found '{f}'", |
| 17360 | .{operand.fmt(pt)}, | 17360 | .{operand.fmt(zcu)}, |
| 17361 | ); | 17361 | ); |
| 17362 | } | 17362 | } |
| 17363 | 17363 | ||
| ... | @@ -17414,7 +17414,7 @@ fn zirBoolNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -17414,7 +17414,7 @@ fn zirBoolNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 17414 | if (uncasted_ty.isVector(zcu)) { | 17414 | if (uncasted_ty.isVector(zcu)) { |
| 17415 | if (uncasted_ty.scalarType(zcu).zigTypeTag(zcu) != .bool) { | 17415 | if (uncasted_ty.scalarType(zcu).zigTypeTag(zcu) != .bool) { |
| 17416 | return sema.fail(block, operand_src, "boolean not operation on type '{f}'", .{ | 17416 | return sema.fail(block, operand_src, "boolean not operation on type '{f}'", .{ |
| 17417 | uncasted_ty.fmt(pt), | 17417 | uncasted_ty.fmt(zcu), |
| 17418 | }); | 17418 | }); |
| 17419 | } | 17419 | } |
| 17420 | return analyzeBitNot(sema, block, uncasted_operand, src); | 17420 | return analyzeBitNot(sema, block, uncasted_operand, src); |
| ... | @@ -17590,7 +17590,7 @@ fn checkSentinelType(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) !voi | ... | @@ -17590,7 +17590,7 @@ fn checkSentinelType(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) !voi |
| 17590 | const pt = sema.pt; | 17590 | const pt = sema.pt; |
| 17591 | const zcu = pt.zcu; | 17591 | const zcu = pt.zcu; |
| 17592 | if (!ty.isSelfComparable(zcu, true)) { | 17592 | if (!ty.isSelfComparable(zcu, true)) { |
| 17593 | return sema.fail(block, src, "non-scalar sentinel type '{f}'", .{ty.fmt(pt)}); | 17593 | return sema.fail(block, src, "non-scalar sentinel type '{f}'", .{ty.fmt(zcu)}); |
| 17594 | } | 17594 | } |
| 17595 | } | 17595 | } |
| 17596 | 17596 | ||
| ... | @@ -17642,7 +17642,7 @@ fn checkErrorType(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) !void { | ... | @@ -17642,7 +17642,7 @@ fn checkErrorType(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) !void { |
| 17642 | switch (ty.zigTypeTag(zcu)) { | 17642 | switch (ty.zigTypeTag(zcu)) { |
| 17643 | .error_set, .error_union, .undefined => return, | 17643 | .error_set, .error_union, .undefined => return, |
| 17644 | else => return sema.fail(block, src, "expected error union type, found '{f}'", .{ | 17644 | else => return sema.fail(block, src, "expected error union type, found '{f}'", .{ |
| 17645 | ty.fmt(pt), | 17645 | ty.fmt(zcu), |
| 17646 | }), | 17646 | }), |
| 17647 | } | 17647 | } |
| 17648 | } | 17648 | } |
| ... | @@ -17780,7 +17780,7 @@ fn zirTry(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -17780,7 +17780,7 @@ fn zirTry(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError! |
| 17780 | const zcu = pt.zcu; | 17780 | const zcu = pt.zcu; |
| 17781 | if (err_union_ty.zigTypeTag(zcu) != .error_union) { | 17781 | if (err_union_ty.zigTypeTag(zcu) != .error_union) { |
| 17782 | return sema.failWithOwnedErrorMsg(parent_block, msg: { | 17782 | return sema.failWithOwnedErrorMsg(parent_block, msg: { |
| 17783 | const msg = try sema.errMsg(operand_src, "expected error union type, found '{f}'", .{err_union_ty.fmt(pt)}); | 17783 | const msg = try sema.errMsg(operand_src, "expected error union type, found '{f}'", .{err_union_ty.fmt(zcu)}); |
| 17784 | errdefer msg.destroy(sema.gpa); | 17784 | errdefer msg.destroy(sema.gpa); |
| 17785 | try sema.addDeclaredHereNote(msg, err_union_ty); | 17785 | try sema.addDeclaredHereNote(msg, err_union_ty); |
| 17786 | try sema.errNote(operand_src, msg, "consider omitting 'try'", .{}); | 17786 | try sema.errNote(operand_src, msg, "consider omitting 'try'", .{}); |
| ... | @@ -17848,7 +17848,7 @@ fn zirTryPtr(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErr | ... | @@ -17848,7 +17848,7 @@ fn zirTryPtr(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErr |
| 17848 | const zcu = pt.zcu; | 17848 | const zcu = pt.zcu; |
| 17849 | if (err_union_ty.zigTypeTag(zcu) != .error_union) { | 17849 | if (err_union_ty.zigTypeTag(zcu) != .error_union) { |
| 17850 | return sema.failWithOwnedErrorMsg(parent_block, msg: { | 17850 | return sema.failWithOwnedErrorMsg(parent_block, msg: { |
| 17851 | const msg = try sema.errMsg(operand_src, "expected error union type, found '{f}'", .{err_union_ty.fmt(pt)}); | 17851 | const msg = try sema.errMsg(operand_src, "expected error union type, found '{f}'", .{err_union_ty.fmt(zcu)}); |
| 17852 | errdefer msg.destroy(sema.gpa); | 17852 | errdefer msg.destroy(sema.gpa); |
| 17853 | try sema.addDeclaredHereNote(msg, err_union_ty); | 17853 | try sema.addDeclaredHereNote(msg, err_union_ty); |
| 17854 | try sema.errNote(operand_src, msg, "consider omitting 'try'", .{}); | 17854 | try sema.errNote(operand_src, msg, "consider omitting 'try'", .{}); |
| ... | @@ -18047,7 +18047,7 @@ fn zirRetImplicit( | ... | @@ -18047,7 +18047,7 @@ fn zirRetImplicit( |
| 18047 | if (base_tag == .noreturn) { | 18047 | if (base_tag == .noreturn) { |
| 18048 | const msg = msg: { | 18048 | const msg = msg: { |
| 18049 | const msg = try sema.errMsg(ret_ty_src, "function declared '{f}' implicitly returns", .{ | 18049 | const msg = try sema.errMsg(ret_ty_src, "function declared '{f}' implicitly returns", .{ |
| 18050 | sema.fn_ret_ty.fmt(pt), | 18050 | sema.fn_ret_ty.fmt(zcu), |
| 18051 | }); | 18051 | }); |
| 18052 | errdefer msg.destroy(sema.gpa); | 18052 | errdefer msg.destroy(sema.gpa); |
| 18053 | try sema.errNote(r_brace_src, msg, "control flow reaches end of body here", .{}); | 18053 | try sema.errNote(r_brace_src, msg, "control flow reaches end of body here", .{}); |
| ... | @@ -18057,7 +18057,7 @@ fn zirRetImplicit( | ... | @@ -18057,7 +18057,7 @@ fn zirRetImplicit( |
| 18057 | } else if (base_tag != .void) { | 18057 | } else if (base_tag != .void) { |
| 18058 | const msg = msg: { | 18058 | const msg = msg: { |
| 18059 | const msg = try sema.errMsg(ret_ty_src, "function with non-void return type '{f}' implicitly returns", .{ | 18059 | const msg = try sema.errMsg(ret_ty_src, "function with non-void return type '{f}' implicitly returns", .{ |
| 18060 | sema.fn_ret_ty.fmt(pt), | 18060 | sema.fn_ret_ty.fmt(zcu), |
| 18061 | }); | 18061 | }); |
| 18062 | errdefer msg.destroy(sema.gpa); | 18062 | errdefer msg.destroy(sema.gpa); |
| 18063 | try sema.errNote(r_brace_src, msg, "control flow reaches end of body here", .{}); | 18063 | try sema.errNote(r_brace_src, msg, "control flow reaches end of body here", .{}); |
| ... | @@ -18468,7 +18468,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -18468,7 +18468,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 18468 | if (host_size != 0) { | 18468 | if (host_size != 0) { |
| 18469 | try sema.ensureLayoutResolved(elem_ty, elem_ty_src, .bit_ptr_child); | 18469 | try sema.ensureLayoutResolved(elem_ty, elem_ty_src, .bit_ptr_child); |
| 18470 | if (elem_ty.unpackable(zcu)) |reason| return sema.failWithOwnedErrorMsg(block, msg: { | 18470 | if (elem_ty.unpackable(zcu)) |reason| return sema.failWithOwnedErrorMsg(block, msg: { |
| 18471 | const msg = try sema.errMsg(elem_ty_src, "bit-pointer cannot refer to value of type '{f}'", .{elem_ty.fmt(pt)}); | 18471 | const msg = try sema.errMsg(elem_ty_src, "bit-pointer cannot refer to value of type '{f}'", .{elem_ty.fmt(zcu)}); |
| 18472 | errdefer msg.destroy(sema.gpa); | 18472 | errdefer msg.destroy(sema.gpa); |
| 18473 | try sema.explainWhyTypeIsUnpackable(msg, elem_ty_src, reason); | 18473 | try sema.explainWhyTypeIsUnpackable(msg, elem_ty_src, reason); |
| 18474 | break :msg msg; | 18474 | break :msg msg; |
| ... | @@ -18476,12 +18476,12 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -18476,12 +18476,12 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 18476 | const elem_bit_size = elem_ty.bitSize(zcu); | 18476 | const elem_bit_size = elem_ty.bitSize(zcu); |
| 18477 | if (bit_offset >= host_size * 8) { | 18477 | if (bit_offset >= host_size * 8) { |
| 18478 | return sema.fail(block, bitoffset_src, "packed type '{f}' at bit offset {d} starts {d} bits after the end of a {d} byte host integer", .{ | 18478 | return sema.fail(block, bitoffset_src, "packed type '{f}' at bit offset {d} starts {d} bits after the end of a {d} byte host integer", .{ |
| 18479 | elem_ty.fmt(pt), bit_offset, bit_offset - host_size * 8, host_size, | 18479 | elem_ty.fmt(zcu), bit_offset, bit_offset - host_size * 8, host_size, |
| 18480 | }); | 18480 | }); |
| 18481 | } | 18481 | } |
| 18482 | if (elem_bit_size > host_size * 8 - bit_offset) { | 18482 | if (elem_bit_size > host_size * 8 - bit_offset) { |
| 18483 | return sema.fail(block, bitoffset_src, "packed type '{f}' at bit offset {d} ends {d} bits after the end of a {d} byte host integer", .{ | 18483 | return sema.fail(block, bitoffset_src, "packed type '{f}' at bit offset {d} ends {d} bits after the end of a {d} byte host integer", .{ |
| 18484 | elem_ty.fmt(pt), bit_offset, elem_bit_size - (host_size * 8 - bit_offset), host_size, | 18484 | elem_ty.fmt(zcu), bit_offset, elem_bit_size - (host_size * 8 - bit_offset), host_size, |
| 18485 | }); | 18485 | }); |
| 18486 | } | 18486 | } |
| 18487 | } | 18487 | } |
| ... | @@ -18491,7 +18491,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -18491,7 +18491,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 18491 | return sema.fail(block, elem_ty_src, "function pointers must be single pointers", .{}); | 18491 | return sema.fail(block, elem_ty_src, "function pointers must be single pointers", .{}); |
| 18492 | } | 18492 | } |
| 18493 | } else if (inst_data.size != .one and elem_ty.zigTypeTag(zcu) == .@"opaque") { | 18493 | } else if (inst_data.size != .one and elem_ty.zigTypeTag(zcu) == .@"opaque") { |
| 18494 | return sema.fail(block, elem_ty_src, "indexable pointer to opaque type '{f}' not allowed", .{elem_ty.fmt(pt)}); | 18494 | return sema.fail(block, elem_ty_src, "indexable pointer to opaque type '{f}' not allowed", .{elem_ty.fmt(zcu)}); |
| 18495 | } | 18495 | } |
| 18496 | 18496 | ||
| 18497 | const ty = try pt.ptrType(.{ | 18497 | const ty = try pt.ptrType(.{ |
| ... | @@ -18653,7 +18653,7 @@ fn zirUnionInit(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -18653,7 +18653,7 @@ fn zirUnionInit(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 18653 | const extra = sema.code.extraData(Zir.Inst.UnionInit, inst_data.payload_index).data; | 18653 | const extra = sema.code.extraData(Zir.Inst.UnionInit, inst_data.payload_index).data; |
| 18654 | const union_ty = try sema.resolveType(block, ty_src, extra.union_type); | 18654 | const union_ty = try sema.resolveType(block, ty_src, extra.union_type); |
| 18655 | if (union_ty.zigTypeTag(pt.zcu) != .@"union") { | 18655 | if (union_ty.zigTypeTag(pt.zcu) != .@"union") { |
| 18656 | return sema.fail(block, ty_src, "expected union type, found '{f}'", .{union_ty.fmt(pt)}); | 18656 | return sema.fail(block, ty_src, "expected union type, found '{f}'", .{union_ty.fmt(zcu)}); |
| 18657 | } | 18657 | } |
| 18658 | union_ty.assertHasLayout(zcu); // from a previous `field_type_ref` instruction | 18658 | union_ty.assertHasLayout(zcu); // from a previous `field_type_ref` instruction |
| 18659 | const field_name = try sema.resolveConstStringIntern(block, field_src, extra.field_name, .{ .simple = .union_field_names }); | 18659 | const field_name = try sema.resolveConstStringIntern(block, field_src, extra.field_name, .{ .simple = .union_field_names }); |
| ... | @@ -18785,7 +18785,7 @@ fn zirStructInit( | ... | @@ -18785,7 +18785,7 @@ fn zirStructInit( |
| 18785 | 18785 | ||
| 18786 | if (field_ty.classify(zcu) == .no_possible_value) { | 18786 | if (field_ty.classify(zcu) == .no_possible_value) { |
| 18787 | return sema.failWithOwnedErrorMsg(block, msg: { | 18787 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 18788 | const msg = try sema.errMsg(src, "cannot initialize union field with uninstantiable type '{f}'", .{field_ty.fmt(pt)}); | 18788 | const msg = try sema.errMsg(src, "cannot initialize union field with uninstantiable type '{f}'", .{field_ty.fmt(zcu)}); |
| 18789 | errdefer msg.destroy(sema.gpa); | 18789 | errdefer msg.destroy(sema.gpa); |
| 18790 | 18790 | ||
| 18791 | try sema.addFieldErrNote(resolved_ty, field_index, msg, "field '{f}' declared here", .{ | 18791 | try sema.addFieldErrNote(resolved_ty, field_index, msg, "field '{f}' declared here", .{ |
| ... | @@ -19574,7 +19574,7 @@ fn fieldType( | ... | @@ -19574,7 +19574,7 @@ fn fieldType( |
| 19574 | else => {}, | 19574 | else => {}, |
| 19575 | } | 19575 | } |
| 19576 | return sema.fail(block, ty_src, "expected struct or union; found '{f}'", .{ | 19576 | return sema.fail(block, ty_src, "expected struct or union; found '{f}'", .{ |
| 19577 | cur_ty.fmt(pt), | 19577 | cur_ty.fmt(zcu), |
| 19578 | }); | 19578 | }); |
| 19579 | } | 19579 | } |
| 19580 | } | 19580 | } |
| ... | @@ -19628,7 +19628,7 @@ fn zirAlignOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -19628,7 +19628,7 @@ fn zirAlignOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 19628 | const ty = try sema.resolveType(block, operand_src, inst_data.operand); | 19628 | const ty = try sema.resolveType(block, operand_src, inst_data.operand); |
| 19629 | try sema.ensureLayoutResolved(ty, operand_src, .align_of); | 19629 | try sema.ensureLayoutResolved(ty, operand_src, .align_of); |
| 19630 | if (ty.isNoReturn(zcu)) { | 19630 | if (ty.isNoReturn(zcu)) { |
| 19631 | return sema.fail(block, operand_src, "no align available for uninstantiable type '{f}'", .{ty.fmt(sema.pt)}); | 19631 | return sema.fail(block, operand_src, "no align available for uninstantiable type '{f}'", .{ty.fmt(zcu)}); |
| 19632 | } | 19632 | } |
| 19633 | return .fromValue(try pt.intValue(.comptime_int, ty.abiAlignment(zcu).toByteUnits().?)); | 19633 | return .fromValue(try pt.intValue(.comptime_int, ty.abiAlignment(zcu).toByteUnits().?)); |
| 19634 | } | 19634 | } |
| ... | @@ -19703,7 +19703,7 @@ fn zirAbs( | ... | @@ -19703,7 +19703,7 @@ fn zirAbs( |
| 19703 | block, | 19703 | block, |
| 19704 | operand_src, | 19704 | operand_src, |
| 19705 | "expected integer, float, or vector of either integers or floats, found '{f}'", | 19705 | "expected integer, float, or vector of either integers or floats, found '{f}'", |
| 19706 | .{operand_ty.fmt(pt)}, | 19706 | .{operand_ty.fmt(zcu)}, |
| 19707 | ), | 19707 | ), |
| 19708 | }; | 19708 | }; |
| 19709 | 19709 | ||
| ... | @@ -19764,7 +19764,7 @@ fn unaryMath( | ... | @@ -19764,7 +19764,7 @@ fn unaryMath( |
| 19764 | block, | 19764 | block, |
| 19765 | operand_src, | 19765 | operand_src, |
| 19766 | "expected vector of floats or float type, found '{f}'", | 19766 | "expected vector of floats or float type, found '{f}'", |
| 19767 | .{operand_ty.fmt(pt)}, | 19767 | .{operand_ty.fmt(zcu)}, |
| 19768 | ), | 19768 | ), |
| 19769 | } | 19769 | } |
| 19770 | 19770 | ||
| ... | @@ -19805,9 +19805,9 @@ fn zirTagName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -19805,9 +19805,9 @@ fn zirTagName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 19805 | }, | 19805 | }, |
| 19806 | .@"enum" => operand_ty, | 19806 | .@"enum" => operand_ty, |
| 19807 | .@"union" => operand_ty.unionTagType(zcu) orelse | 19807 | .@"union" => operand_ty.unionTagType(zcu) orelse |
| 19808 | return sema.fail(block, src, "union '{f}' is untagged", .{operand_ty.fmt(pt)}), | 19808 | return sema.fail(block, src, "union '{f}' is untagged", .{operand_ty.fmt(zcu)}), |
| 19809 | else => return sema.fail(block, operand_src, "expected enum or union; found '{f}'", .{ | 19809 | else => return sema.fail(block, operand_src, "expected enum or union; found '{f}'", .{ |
| 19810 | operand_ty.fmt(pt), | 19810 | operand_ty.fmt(zcu), |
| 19811 | }), | 19811 | }), |
| 19812 | }; | 19812 | }; |
| 19813 | const casted_operand = try sema.coerce(block, enum_ty, operand, operand_src); | 19813 | const casted_operand = try sema.coerce(block, enum_ty, operand, operand_src); |
| ... | @@ -19815,7 +19815,7 @@ fn zirTagName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -19815,7 +19815,7 @@ fn zirTagName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 19815 | const field_index = enum_ty.enumTagFieldIndex(val, zcu) orelse { | 19815 | const field_index = enum_ty.enumTagFieldIndex(val, zcu) orelse { |
| 19816 | const msg = msg: { | 19816 | const msg = msg: { |
| 19817 | const msg = try sema.errMsg(src, "no field with value '{f}' in enum '{f}'", .{ | 19817 | const msg = try sema.errMsg(src, "no field with value '{f}' in enum '{f}'", .{ |
| 19818 | val.fmtValueSema(pt, sema), enum_ty.fmt(pt), | 19818 | val.fmtValueSema(sema), enum_ty.fmt(zcu), |
| 19819 | }); | 19819 | }); |
| 19820 | errdefer msg.destroy(sema.gpa); | 19820 | errdefer msg.destroy(sema.gpa); |
| 19821 | try sema.errNote(enum_ty.srcLoc(zcu), msg, "declared here", .{}); | 19821 | try sema.errNote(enum_ty.srcLoc(zcu), msg, "declared here", .{}); |
| ... | @@ -20027,7 +20027,7 @@ fn zirReifyPointer( | ... | @@ -20027,7 +20027,7 @@ fn zirReifyPointer( |
| 20027 | }, | 20027 | }, |
| 20028 | .@"opaque" => switch (size) { | 20028 | .@"opaque" => switch (size) { |
| 20029 | .one => {}, | 20029 | .one => {}, |
| 20030 | .many, .c, .slice => return sema.fail(block, src, "indexable pointer to opaque type '{f}' not allowed", .{elem_ty.fmt(pt)}), | 20030 | .many, .c, .slice => return sema.fail(block, src, "indexable pointer to opaque type '{f}' not allowed", .{elem_ty.fmt(zcu)}), |
| 20031 | }, | 20031 | }, |
| 20032 | else => {}, | 20032 | else => {}, |
| 20033 | } | 20033 | } |
| ... | @@ -20963,7 +20963,7 @@ fn zirReifySpirvType( | ... | @@ -20963,7 +20963,7 @@ fn zirReifySpirvType( |
| 20963 | if (sampled_type.toIntern() != .void_type and | 20963 | if (sampled_type.toIntern() != .void_type and |
| 20964 | (!sampled_type.hasRuntimeBits(zcu) or (!sampled_type.isRuntimeFloat() and !sampled_type.isInt(zcu)))) | 20964 | (!sampled_type.hasRuntimeBits(zcu) or (!sampled_type.isRuntimeFloat() and !sampled_type.isInt(zcu)))) |
| 20965 | { | 20965 | { |
| 20966 | return sema.fail(block, operand_src, "invalid '{t}' field value '{f}'", .{ usage_tag, sampled_type.fmt(pt) }); | 20966 | return sema.fail(block, operand_src, "invalid '{t}' field value '{f}'", .{ usage_tag, sampled_type.fmt(zcu) }); |
| 20967 | } | 20967 | } |
| 20968 | 20968 | ||
| 20969 | if (target.os.tag == .vulkan) { | 20969 | if (target.os.tag == .vulkan) { |
| ... | @@ -20995,7 +20995,7 @@ fn zirReifySpirvType( | ... | @@ -20995,7 +20995,7 @@ fn zirReifySpirvType( |
| 20995 | block, | 20995 | block, |
| 20996 | operand_src, | 20996 | operand_src, |
| 20997 | "image 'format' '.{t}' does not match '{t}' type '{f}' under the 'vulkan' OS", | 20997 | "image 'format' '.{t}' does not match '{t}' type '{f}' under the 'vulkan' OS", |
| 20998 | .{ format, usage_tag, sampled_type.fmt(pt) }, | 20998 | .{ format, usage_tag, sampled_type.fmt(zcu) }, |
| 20999 | ); | 20999 | ); |
| 21000 | } | 21000 | } |
| 21001 | } | 21001 | } |
| ... | @@ -21018,7 +21018,7 @@ fn zirReifySpirvType( | ... | @@ -21018,7 +21018,7 @@ fn zirReifySpirvType( |
| 21018 | .sampled_image => blk: { | 21018 | .sampled_image => blk: { |
| 21019 | const image_ty = Value.fromInterned(union_val.val).toType(); | 21019 | const image_ty = Value.fromInterned(union_val.val).toType(); |
| 21020 | if (image_ty.zigTypeTag(zcu) != .spirv or ip.loadSpirvType(image_ty.toIntern()).flags.tag != .image) { | 21020 | if (image_ty.zigTypeTag(zcu) != .spirv or ip.loadSpirvType(image_ty.toIntern()).flags.tag != .image) { |
| 21021 | return sema.fail(block, operand_src, "'sampled_image' element must be an @SpirvType image, found '{f}'", .{image_ty.fmt(pt)}); | 21021 | return sema.fail(block, operand_src, "'sampled_image' element must be an @SpirvType image, found '{f}'", .{image_ty.fmt(zcu)}); |
| 21022 | } | 21022 | } |
| 21023 | const image_info = ip.loadSpirvType(image_ty.toIntern()).flags; | 21023 | const image_info = ip.loadSpirvType(image_ty.toIntern()).flags; |
| 21024 | if (image_info.usage != .sampled) { | 21024 | if (image_info.usage != .sampled) { |
| ... | @@ -21078,6 +21078,7 @@ fn resolveVaListRef(sema: *Sema, block: *Block, src: LazySrcLoc, zir_ref: Zir.In | ... | @@ -21078,6 +21078,7 @@ fn resolveVaListRef(sema: *Sema, block: *Block, src: LazySrcLoc, zir_ref: Zir.In |
| 21078 | } | 21078 | } |
| 21079 | 21079 | ||
| 21080 | fn zirCVaArg(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref { | 21080 | fn zirCVaArg(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref { |
| 21081 | const zcu = sema.pt.zcu; | ||
| 21081 | const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data; | 21082 | const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data; |
| 21082 | const src = block.nodeOffset(extra.node); | 21083 | const src = block.nodeOffset(extra.node); |
| 21083 | const va_list_src = block.builtinCallArgSrc(extra.node, 0); | 21084 | const va_list_src = block.builtinCallArgSrc(extra.node, 0); |
| ... | @@ -21086,9 +21087,9 @@ fn zirCVaArg(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) C | ... | @@ -21086,9 +21087,9 @@ fn zirCVaArg(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) C |
| 21086 | const va_list_ref = try sema.resolveVaListRef(block, va_list_src, extra.lhs); | 21087 | const va_list_ref = try sema.resolveVaListRef(block, va_list_src, extra.lhs); |
| 21087 | const arg_ty = try sema.resolveType(block, ty_src, extra.rhs); | 21088 | const arg_ty = try sema.resolveType(block, ty_src, extra.rhs); |
| 21088 | try sema.ensureLayoutResolved(arg_ty, ty_src, .parameter); | 21089 | try sema.ensureLayoutResolved(arg_ty, ty_src, .parameter); |
| 21089 | if (!arg_ty.validateExtern(.param_ty, sema.pt.zcu)) { | 21090 | if (!arg_ty.validateExtern(.param_ty, zcu)) { |
| 21090 | const msg = msg: { | 21091 | const msg = msg: { |
| 21091 | const msg = try sema.errMsg(ty_src, "cannot get '{f}' from variadic argument", .{arg_ty.fmt(sema.pt)}); | 21092 | const msg = try sema.errMsg(ty_src, "cannot get '{f}' from variadic argument", .{arg_ty.fmt(zcu)}); |
| 21092 | errdefer msg.destroy(sema.gpa); | 21093 | errdefer msg.destroy(sema.gpa); |
| 21093 | 21094 | ||
| 21094 | try sema.explainWhyTypeIsNotExtern(msg, ty_src, arg_ty, .param_ty); | 21095 | try sema.explainWhyTypeIsNotExtern(msg, ty_src, arg_ty, .param_ty); |
| ... | @@ -21151,7 +21152,7 @@ fn zirTypeName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -21151,7 +21152,7 @@ fn zirTypeName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 21151 | const ty_src = block.builtinCallArgSrc(inst_data.src_node, 0); | 21152 | const ty_src = block.builtinCallArgSrc(inst_data.src_node, 0); |
| 21152 | const ty = try sema.resolveType(block, ty_src, inst_data.operand); | 21153 | const ty = try sema.resolveType(block, ty_src, inst_data.operand); |
| 21153 | 21154 | ||
| 21154 | const type_name = try ip.getOrPutStringFmt(gpa, io, pt.tid, "{f}", .{ty.fmt(pt)}, .no_embedded_nulls); | 21155 | const type_name = try ip.getOrPutStringFmt(gpa, io, pt.tid, "{f}", .{ty.fmt(zcu)}, .no_embedded_nulls); |
| 21155 | return sema.addNullTerminatedStrLit(type_name); | 21156 | return sema.addNullTerminatedStrLit(type_name); |
| 21156 | } | 21157 | } |
| 21157 | 21158 | ||
| ... | @@ -21180,7 +21181,7 @@ fn zirIntFromFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro | ... | @@ -21180,7 +21181,7 @@ fn zirIntFromFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro |
| 21180 | 21181 | ||
| 21181 | switch (dest_scalar_ty.zigTypeTag(zcu)) { | 21182 | switch (dest_scalar_ty.zigTypeTag(zcu)) { |
| 21182 | .comptime_int, .int => {}, | 21183 | .comptime_int, .int => {}, |
| 21183 | else => return sema.fail(block, src, "expected integer result type, found '{f}'", .{dest_scalar_ty.fmt(pt)}), | 21184 | else => return sema.fail(block, src, "expected integer result type, found '{f}'", .{dest_scalar_ty.fmt(zcu)}), |
| 21184 | } | 21185 | } |
| 21185 | try sema.checkFloatType(block, operand_src, operand_scalar_ty); | 21186 | try sema.checkFloatType(block, operand_src, operand_scalar_ty); |
| 21186 | 21187 | ||
| ... | @@ -21261,7 +21262,7 @@ fn zirRoundCast( | ... | @@ -21261,7 +21262,7 @@ fn zirRoundCast( |
| 21261 | block, | 21262 | block, |
| 21262 | operand_src, | 21263 | operand_src, |
| 21263 | "expected float or vector type, found '{f}'", | 21264 | "expected float or vector type, found '{f}'", |
| 21264 | .{operand_ty.fmt(pt)}, | 21265 | .{operand_ty.fmt(zcu)}, |
| 21265 | ), | 21266 | ), |
| 21266 | } | 21267 | } |
| 21267 | 21268 | ||
| ... | @@ -21295,7 +21296,7 @@ fn zirRoundCast( | ... | @@ -21295,7 +21296,7 @@ fn zirRoundCast( |
| 21295 | block, | 21296 | block, |
| 21296 | src, | 21297 | src, |
| 21297 | "expected integer, float, or vector of either integers or floats, found '{f}'", | 21298 | "expected integer, float, or vector of either integers or floats, found '{f}'", |
| 21298 | .{dest_ty.fmt(pt)}, | 21299 | .{dest_ty.fmt(zcu)}, |
| 21299 | ), | 21300 | ), |
| 21300 | } | 21301 | } |
| 21301 | 21302 | ||
| ... | @@ -21359,7 +21360,7 @@ fn zirFloatFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro | ... | @@ -21359,7 +21360,7 @@ fn zirFloatFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro |
| 21359 | 21360 | ||
| 21360 | switch (dest_scalar_ty.zigTypeTag(zcu)) { | 21361 | switch (dest_scalar_ty.zigTypeTag(zcu)) { |
| 21361 | .comptime_float, .float => {}, | 21362 | .comptime_float, .float => {}, |
| 21362 | else => return sema.fail(block, src, "expected float result type, found '{f}'", .{dest_scalar_ty.fmt(pt)}), | 21363 | else => return sema.fail(block, src, "expected float result type, found '{f}'", .{dest_scalar_ty.fmt(zcu)}), |
| 21363 | } | 21364 | } |
| 21364 | _ = try sema.checkIntType(block, operand_src, operand_scalar_ty); | 21365 | _ = try sema.checkIntType(block, operand_src, operand_scalar_ty); |
| 21365 | 21366 | ||
| ... | @@ -21419,7 +21420,7 @@ fn zirPtrFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -21419,7 +21420,7 @@ fn zirPtrFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 21419 | 21420 | ||
| 21420 | if (ptr_ty.isSlice(zcu)) { | 21421 | if (ptr_ty.isSlice(zcu)) { |
| 21421 | const msg = msg: { | 21422 | const msg = msg: { |
| 21422 | const msg = try sema.errMsg(src, "integer cannot be converted to slice type '{f}'", .{ptr_ty.fmt(pt)}); | 21423 | const msg = try sema.errMsg(src, "integer cannot be converted to slice type '{f}'", .{ptr_ty.fmt(zcu)}); |
| 21423 | errdefer msg.destroy(sema.gpa); | 21424 | errdefer msg.destroy(sema.gpa); |
| 21424 | try sema.errNote(src, msg, "slice length cannot be inferred from address", .{}); | 21425 | try sema.errNote(src, msg, "slice length cannot be inferred from address", .{}); |
| 21425 | break :msg msg; | 21426 | break :msg msg; |
| ... | @@ -21492,7 +21493,7 @@ fn ptrFromIntVal( | ... | @@ -21492,7 +21493,7 @@ fn ptrFromIntVal( |
| 21492 | } | 21493 | } |
| 21493 | const addr = operand_val.toUnsignedInt(zcu); | 21494 | const addr = operand_val.toUnsignedInt(zcu); |
| 21494 | if (!ptr_ty.isAllowzeroPtr(zcu) and addr == 0) | 21495 | if (!ptr_ty.isAllowzeroPtr(zcu) and addr == 0) |
| 21495 | return sema.fail(block, operand_src, "pointer type '{f}' does not allow address zero", .{ptr_ty.fmt(pt)}); | 21496 | return sema.fail(block, operand_src, "pointer type '{f}' does not allow address zero", .{ptr_ty.fmt(zcu)}); |
| 21496 | if (addr != 0 and ptr_align != .none) { | 21497 | if (addr != 0 and ptr_align != .none) { |
| 21497 | const masked_addr = if (ptr_ty.childType(zcu).fnPtrMaskOrNull(zcu)) |mask| | 21498 | const masked_addr = if (ptr_ty.childType(zcu).fnPtrMaskOrNull(zcu)) |mask| |
| 21498 | addr & mask | 21499 | addr & mask |
| ... | @@ -21500,7 +21501,7 @@ fn ptrFromIntVal( | ... | @@ -21500,7 +21501,7 @@ fn ptrFromIntVal( |
| 21500 | addr; | 21501 | addr; |
| 21501 | 21502 | ||
| 21502 | if (!ptr_align.check(masked_addr)) { | 21503 | if (!ptr_align.check(masked_addr)) { |
| 21503 | return sema.fail(block, operand_src, "pointer type '{f}' requires aligned address", .{ptr_ty.fmt(pt)}); | 21504 | return sema.fail(block, operand_src, "pointer type '{f}' requires aligned address", .{ptr_ty.fmt(zcu)}); |
| 21504 | } | 21505 | } |
| 21505 | } | 21506 | } |
| 21506 | 21507 | ||
| ... | @@ -21545,8 +21546,8 @@ fn zirErrorCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData | ... | @@ -21545,8 +21546,8 @@ fn zirErrorCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData |
| 21545 | errdefer msg.destroy(sema.gpa); | 21546 | errdefer msg.destroy(sema.gpa); |
| 21546 | const dest_payload_ty = dest_ty.errorUnionPayload(zcu); | 21547 | const dest_payload_ty = dest_ty.errorUnionPayload(zcu); |
| 21547 | const operand_payload_ty = operand_ty.errorUnionPayload(zcu); | 21548 | const operand_payload_ty = operand_ty.errorUnionPayload(zcu); |
| 21548 | try sema.errNote(src, msg, "destination payload is '{f}'", .{dest_payload_ty.fmt(pt)}); | 21549 | try sema.errNote(src, msg, "destination payload is '{f}'", .{dest_payload_ty.fmt(zcu)}); |
| 21549 | try sema.errNote(src, msg, "operand payload is '{f}'", .{operand_payload_ty.fmt(pt)}); | 21550 | try sema.errNote(src, msg, "operand payload is '{f}'", .{operand_payload_ty.fmt(zcu)}); |
| 21550 | try addDeclaredHereNote(sema, msg, dest_ty); | 21551 | try addDeclaredHereNote(sema, msg, dest_ty); |
| 21551 | try addDeclaredHereNote(sema, msg, operand_ty); | 21552 | try addDeclaredHereNote(sema, msg, operand_ty); |
| 21552 | break :msg msg; | 21553 | break :msg msg; |
| ... | @@ -21620,7 +21621,7 @@ fn zirErrorCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData | ... | @@ -21620,7 +21621,7 @@ fn zirErrorCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData |
| 21620 | 21621 | ||
| 21621 | if (result == .disjoint and !(operand_tag == .error_union and dest_tag == .error_union)) { | 21622 | if (result == .disjoint and !(operand_tag == .error_union and dest_tag == .error_union)) { |
| 21622 | return sema.fail(block, src, "error sets '{f}' and '{f}' have no common errors", .{ | 21623 | return sema.fail(block, src, "error sets '{f}' and '{f}' have no common errors", .{ |
| 21623 | operand_err_ty.fmt(pt), dest_err_ty.fmt(pt), | 21624 | operand_err_ty.fmt(zcu), dest_err_ty.fmt(zcu), |
| 21624 | }); | 21625 | }); |
| 21625 | } | 21626 | } |
| 21626 | 21627 | ||
| ... | @@ -21645,7 +21646,7 @@ fn zirErrorCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData | ... | @@ -21645,7 +21646,7 @@ fn zirErrorCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData |
| 21645 | 21646 | ||
| 21646 | if (result != .superset and !dest_err_ty.errorSetHasField(err_name, zcu)) { | 21647 | if (result != .superset and !dest_err_ty.errorSetHasField(err_name, zcu)) { |
| 21647 | return sema.fail(block, src, "'error.{f}' not a member of error set '{f}'", .{ | 21648 | return sema.fail(block, src, "'error.{f}' not a member of error set '{f}'", .{ |
| 21648 | err_name.fmt(ip), dest_err_ty.fmt(pt), | 21649 | err_name.fmt(ip), dest_err_ty.fmt(zcu), |
| 21649 | }); | 21650 | }); |
| 21650 | } | 21651 | } |
| 21651 | 21652 | ||
| ... | @@ -21810,7 +21811,7 @@ fn ptrCastFull( | ... | @@ -21810,7 +21811,7 @@ fn ptrCastFull( |
| 21810 | if (src_elem_ty.zigTypeTag(zcu) == .@"opaque") { | 21811 | if (src_elem_ty.zigTypeTag(zcu) == .@"opaque") { |
| 21811 | return sema.failWithOwnedErrorMsg(block, msg: { | 21812 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 21812 | const msg = try sema.errMsg(src, "cannot infer length of slice of '{f}' from pointer to opaque type '{f}' with unknown size", .{ | 21813 | const msg = try sema.errMsg(src, "cannot infer length of slice of '{f}' from pointer to opaque type '{f}' with unknown size", .{ |
| 21813 | dest_elem_ty.fmt(pt), src_elem_ty.fmt(pt), | 21814 | dest_elem_ty.fmt(zcu), src_elem_ty.fmt(zcu), |
| 21814 | }); | 21815 | }); |
| 21815 | errdefer msg.destroy(gpa); | 21816 | errdefer msg.destroy(gpa); |
| 21816 | try sema.addDeclaredHereNote(msg, src_elem_ty); | 21817 | try sema.addDeclaredHereNote(msg, src_elem_ty); |
| ... | @@ -21821,14 +21822,14 @@ fn ptrCastFull( | ... | @@ -21821,14 +21822,14 @@ fn ptrCastFull( |
| 21821 | const dest_elem_size = dest_elem_ty.abiSize(zcu); | 21822 | const dest_elem_size = dest_elem_ty.abiSize(zcu); |
| 21822 | if (dest_elem_size == 0) { | 21823 | if (dest_elem_size == 0) { |
| 21823 | return sema.fail(block, src, "cannot infer length of slice of zero-bit '{f}' from '{f}'", .{ | 21824 | return sema.fail(block, src, "cannot infer length of slice of zero-bit '{f}' from '{f}'", .{ |
| 21824 | dest_elem_ty.fmt(pt), operand_ty.fmt(pt), | 21825 | dest_elem_ty.fmt(zcu), operand_ty.fmt(zcu), |
| 21825 | }); | 21826 | }); |
| 21826 | } | 21827 | } |
| 21827 | if (opt_src_len) |src_len| { | 21828 | if (opt_src_len) |src_len| { |
| 21828 | const bytes = src_len * src_elem_size; | 21829 | const bytes = src_len * src_elem_size; |
| 21829 | const dest_len = std.math.divExact(u64, bytes, dest_elem_size) catch switch (src_info.flags.size) { | 21830 | const dest_len = std.math.divExact(u64, bytes, dest_elem_size) catch switch (src_info.flags.size) { |
| 21830 | .slice => return sema.fail(block, src, "slice length '{d}' does not divide exactly into destination elements", .{src_len}), | 21831 | .slice => return sema.fail(block, src, "slice length '{d}' does not divide exactly into destination elements", .{src_len}), |
| 21831 | .one => return sema.fail(block, src, "type '{f}' does not divide exactly into destination elements", .{Type.fromInterned(src_info.child).fmt(pt)}), | 21832 | .one => return sema.fail(block, src, "type '{f}' does not divide exactly into destination elements", .{Type.fromInterned(src_info.child).fmt(zcu)}), |
| 21832 | else => unreachable, | 21833 | else => unreachable, |
| 21833 | }; | 21834 | }; |
| 21834 | break :len .{ .constant = dest_len }; | 21835 | break :len .{ .constant = dest_len }; |
| ... | @@ -21847,7 +21848,7 @@ fn ptrCastFull( | ... | @@ -21847,7 +21848,7 @@ fn ptrCastFull( |
| 21847 | // The result value will have `dest_len * dest_base_per_elem` values of type `dest_base_ty`. | 21848 | // The result value will have `dest_len * dest_base_per_elem` values of type `dest_base_ty`. |
| 21848 | if (dest_base_ty.toIntern() != src_base_ty.toIntern()) { | 21849 | if (dest_base_ty.toIntern() != src_base_ty.toIntern()) { |
| 21849 | return sema.fail(block, src, "cannot infer length of comptime-only '{f}' from incompatible '{f}'", .{ | 21850 | return sema.fail(block, src, "cannot infer length of comptime-only '{f}' from incompatible '{f}'", .{ |
| 21850 | dest_ty.fmt(pt), operand_ty.fmt(pt), | 21851 | dest_ty.fmt(zcu), operand_ty.fmt(zcu), |
| 21851 | }); | 21852 | }); |
| 21852 | } | 21853 | } |
| 21853 | // `src_base_ty` is comptime-only, so `src_elem_ty` is comptime-only, so `operand_ty` is | 21854 | // `src_base_ty` is comptime-only, so `src_elem_ty` is comptime-only, so `operand_ty` is |
| ... | @@ -21856,7 +21857,7 @@ fn ptrCastFull( | ... | @@ -21856,7 +21857,7 @@ fn ptrCastFull( |
| 21856 | const base_len = src_len * src_base_per_elem; | 21857 | const base_len = src_len * src_base_per_elem; |
| 21857 | const dest_len = std.math.divExact(u64, base_len, dest_base_per_elem) catch switch (src_info.flags.size) { | 21858 | const dest_len = std.math.divExact(u64, base_len, dest_base_per_elem) catch switch (src_info.flags.size) { |
| 21858 | .slice => return sema.fail(block, src, "slice length '{d}' does not divide exactly into destination elements", .{src_len}), | 21859 | .slice => return sema.fail(block, src, "slice length '{d}' does not divide exactly into destination elements", .{src_len}), |
| 21859 | .one => return sema.fail(block, src, "type '{f}' does not divide exactly into destination elements", .{src_elem_ty.fmt(pt)}), | 21860 | .one => return sema.fail(block, src, "type '{f}' does not divide exactly into destination elements", .{src_elem_ty.fmt(zcu)}), |
| 21860 | else => unreachable, | 21861 | else => unreachable, |
| 21861 | }; | 21862 | }; |
| 21862 | break :len .{ .constant = dest_len }; | 21863 | break :len .{ .constant = dest_len }; |
| ... | @@ -21918,7 +21919,7 @@ fn ptrCastFull( | ... | @@ -21918,7 +21919,7 @@ fn ptrCastFull( |
| 21918 | if (imc_res == .ok) break :check_child; | 21919 | if (imc_res == .ok) break :check_child; |
| 21919 | return sema.failWithOwnedErrorMsg(block, msg: { | 21920 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 21920 | const msg = try sema.errMsg(src, "pointer element type '{f}' cannot coerce into element type '{f}'", .{ | 21921 | const msg = try sema.errMsg(src, "pointer element type '{f}' cannot coerce into element type '{f}'", .{ |
| 21921 | src_child.fmt(pt), dest_child.fmt(pt), | 21922 | src_child.fmt(zcu), dest_child.fmt(zcu), |
| 21922 | }); | 21923 | }); |
| 21923 | errdefer msg.destroy(sema.gpa); | 21924 | errdefer msg.destroy(sema.gpa); |
| 21924 | try imc_res.report(sema, src, msg); | 21925 | try imc_res.report(sema, src, msg); |
| ... | @@ -21945,12 +21946,12 @@ fn ptrCastFull( | ... | @@ -21945,12 +21946,12 @@ fn ptrCastFull( |
| 21945 | return sema.failWithOwnedErrorMsg(block, msg: { | 21946 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 21946 | const msg = if (src_info.sentinel == .none) blk: { | 21947 | const msg = if (src_info.sentinel == .none) blk: { |
| 21947 | break :blk try sema.errMsg(src, "destination pointer requires '{f}' sentinel", .{ | 21948 | break :blk try sema.errMsg(src, "destination pointer requires '{f}' sentinel", .{ |
| 21948 | Value.fromInterned(dest_info.sentinel).fmtValueSema(pt, sema), | 21949 | Value.fromInterned(dest_info.sentinel).fmtValueSema(sema), |
| 21949 | }); | 21950 | }); |
| 21950 | } else blk: { | 21951 | } else blk: { |
| 21951 | break :blk try sema.errMsg(src, "pointer sentinel '{f}' cannot coerce into pointer sentinel '{f}'", .{ | 21952 | break :blk try sema.errMsg(src, "pointer sentinel '{f}' cannot coerce into pointer sentinel '{f}'", .{ |
| 21952 | Value.fromInterned(src_info.sentinel).fmtValueSema(pt, sema), | 21953 | Value.fromInterned(src_info.sentinel).fmtValueSema(sema), |
| 21953 | Value.fromInterned(dest_info.sentinel).fmtValueSema(pt, sema), | 21954 | Value.fromInterned(dest_info.sentinel).fmtValueSema(sema), |
| 21954 | }); | 21955 | }); |
| 21955 | }; | 21956 | }; |
| 21956 | errdefer msg.destroy(sema.gpa); | 21957 | errdefer msg.destroy(sema.gpa); |
| ... | @@ -21991,8 +21992,8 @@ fn ptrCastFull( | ... | @@ -21991,8 +21992,8 @@ fn ptrCastFull( |
| 21991 | 21992 | ||
| 21992 | return sema.failWithOwnedErrorMsg(block, msg: { | 21993 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 21993 | const msg = try sema.errMsg(src, "'{f}' could have null values which are illegal in type '{f}'", .{ | 21994 | const msg = try sema.errMsg(src, "'{f}' could have null values which are illegal in type '{f}'", .{ |
| 21994 | operand_ty.fmt(pt), | 21995 | operand_ty.fmt(zcu), |
| 21995 | dest_ty.fmt(pt), | 21996 | dest_ty.fmt(zcu), |
| 21996 | }); | 21997 | }); |
| 21997 | errdefer msg.destroy(sema.gpa); | 21998 | errdefer msg.destroy(sema.gpa); |
| 21998 | try sema.errNote(src, msg, "use @ptrCast to assert the pointer is not null", .{}); | 21999 | try sema.errNote(src, msg, "use @ptrCast to assert the pointer is not null", .{}); |
| ... | @@ -22019,10 +22020,10 @@ fn ptrCastFull( | ... | @@ -22019,10 +22020,10 @@ fn ptrCastFull( |
| 22019 | const msg = try sema.errMsg(src, "{s} increases pointer alignment", .{operation}); | 22020 | const msg = try sema.errMsg(src, "{s} increases pointer alignment", .{operation}); |
| 22020 | errdefer msg.destroy(sema.gpa); | 22021 | errdefer msg.destroy(sema.gpa); |
| 22021 | try sema.errNote(operand_src, msg, "'{f}' has alignment '{d}'", .{ | 22022 | try sema.errNote(operand_src, msg, "'{f}' has alignment '{d}'", .{ |
| 22022 | operand_ty.fmt(pt), src_align.toByteUnits() orelse 0, | 22023 | operand_ty.fmt(zcu), src_align.toByteUnits() orelse 0, |
| 22023 | }); | 22024 | }); |
| 22024 | try sema.errNote(src, msg, "'{f}' has alignment '{d}'", .{ | 22025 | try sema.errNote(src, msg, "'{f}' has alignment '{d}'", .{ |
| 22025 | dest_ty.fmt(pt), dest_align.toByteUnits() orelse 0, | 22026 | dest_ty.fmt(zcu), dest_align.toByteUnits() orelse 0, |
| 22026 | }); | 22027 | }); |
| 22027 | try sema.errNote(src, msg, "use @alignCast to assert pointer alignment", .{}); | 22028 | try sema.errNote(src, msg, "use @alignCast to assert pointer alignment", .{}); |
| 22028 | break :msg msg; | 22029 | break :msg msg; |
| ... | @@ -22036,10 +22037,10 @@ fn ptrCastFull( | ... | @@ -22036,10 +22037,10 @@ fn ptrCastFull( |
| 22036 | const msg = try sema.errMsg(src, "{s} changes pointer address space", .{operation}); | 22037 | const msg = try sema.errMsg(src, "{s} changes pointer address space", .{operation}); |
| 22037 | errdefer msg.destroy(sema.gpa); | 22038 | errdefer msg.destroy(sema.gpa); |
| 22038 | try sema.errNote(operand_src, msg, "'{f}' has address space '{s}'", .{ | 22039 | try sema.errNote(operand_src, msg, "'{f}' has address space '{s}'", .{ |
| 22039 | operand_ty.fmt(pt), @tagName(src_info.flags.address_space), | 22040 | operand_ty.fmt(zcu), @tagName(src_info.flags.address_space), |
| 22040 | }); | 22041 | }); |
| 22041 | try sema.errNote(src, msg, "'{f}' has address space '{s}'", .{ | 22042 | try sema.errNote(src, msg, "'{f}' has address space '{s}'", .{ |
| 22042 | dest_ty.fmt(pt), @tagName(dest_info.flags.address_space), | 22043 | dest_ty.fmt(zcu), @tagName(dest_info.flags.address_space), |
| 22043 | }); | 22044 | }); |
| 22044 | try sema.errNote(src, msg, "use @addrSpaceCast to cast pointer address space", .{}); | 22045 | try sema.errNote(src, msg, "use @addrSpaceCast to cast pointer address space", .{}); |
| 22045 | break :msg msg; | 22046 | break :msg msg; |
| ... | @@ -22105,7 +22106,7 @@ fn ptrCastFull( | ... | @@ -22105,7 +22106,7 @@ fn ptrCastFull( |
| 22105 | 22106 | ||
| 22106 | if (operand_val.isNull(zcu)) { | 22107 | if (operand_val.isNull(zcu)) { |
| 22107 | if (!dest_ty.ptrAllowsZero(zcu)) { | 22108 | if (!dest_ty.ptrAllowsZero(zcu)) { |
| 22108 | return sema.fail(block, operand_src, "null pointer casted to type '{f}'", .{dest_ty.fmt(pt)}); | 22109 | return sema.fail(block, operand_src, "null pointer casted to type '{f}'", .{dest_ty.fmt(zcu)}); |
| 22109 | } | 22110 | } |
| 22110 | if (dest_ty.zigTypeTag(zcu) == .optional) { | 22111 | if (dest_ty.zigTypeTag(zcu) == .optional) { |
| 22111 | return Air.internedToRef((try pt.nullValue(dest_ty)).toIntern()); | 22112 | return Air.internedToRef((try pt.nullValue(dest_ty)).toIntern()); |
| ... | @@ -22419,7 +22420,7 @@ fn zirTruncate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -22419,7 +22420,7 @@ fn zirTruncate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 22419 | 22420 | ||
| 22420 | if (operand_info.signedness != dest_info.signedness) { | 22421 | if (operand_info.signedness != dest_info.signedness) { |
| 22421 | return sema.fail(block, operand_src, "expected {s} integer type, found '{f}'", .{ | 22422 | return sema.fail(block, operand_src, "expected {s} integer type, found '{f}'", .{ |
| 22422 | @tagName(dest_info.signedness), operand_ty.fmt(pt), | 22423 | @tagName(dest_info.signedness), operand_ty.fmt(zcu), |
| 22423 | }); | 22424 | }); |
| 22424 | } | 22425 | } |
| 22425 | if (dest_info.bits >= operand_info.bits) { | 22426 | if (dest_info.bits >= operand_info.bits) { |
| ... | @@ -22504,7 +22505,7 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -22504,7 +22505,7 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 22504 | block, | 22505 | block, |
| 22505 | operand_src, | 22506 | operand_src, |
| 22506 | "@byteSwap requires the number of bits to be evenly divisible by 8, but {f} has {d} bits", | 22507 | "@byteSwap requires the number of bits to be evenly divisible by 8, but {f} has {d} bits", |
| 22507 | .{ scalar_ty.fmt(pt), bits }, | 22508 | .{ scalar_ty.fmt(zcu), bits }, |
| 22508 | ); | 22509 | ); |
| 22509 | } | 22510 | } |
| 22510 | if (sema.resolveValue(operand)) |operand_val| { | 22511 | if (sema.resolveValue(operand)) |operand_val| { |
| ... | @@ -22554,7 +22555,7 @@ fn bitOffsetOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!u6 | ... | @@ -22554,7 +22555,7 @@ fn bitOffsetOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!u6 |
| 22554 | const ip = &zcu.intern_pool; | 22555 | const ip = &zcu.intern_pool; |
| 22555 | switch (ty.zigTypeTag(zcu)) { | 22556 | switch (ty.zigTypeTag(zcu)) { |
| 22556 | .@"struct" => {}, | 22557 | .@"struct" => {}, |
| 22557 | else => return sema.fail(block, ty_src, "expected struct type, found '{f}'", .{ty.fmt(pt)}), | 22558 | else => return sema.fail(block, ty_src, "expected struct type, found '{f}'", .{ty.fmt(zcu)}), |
| 22558 | } | 22559 | } |
| 22559 | 22560 | ||
| 22560 | const field_index = if (ty.isTuple(zcu)) blk: { | 22561 | const field_index = if (ty.isTuple(zcu)) blk: { |
| ... | @@ -22589,7 +22590,7 @@ fn checkNamespaceType(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) Com | ... | @@ -22589,7 +22590,7 @@ fn checkNamespaceType(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) Com |
| 22589 | const zcu = pt.zcu; | 22590 | const zcu = pt.zcu; |
| 22590 | switch (ty.zigTypeTag(zcu)) { | 22591 | switch (ty.zigTypeTag(zcu)) { |
| 22591 | .@"struct", .@"enum", .@"union", .@"opaque" => return, | 22592 | .@"struct", .@"enum", .@"union", .@"opaque" => return, |
| 22592 | else => return sema.fail(block, src, "expected struct, enum, union, or opaque; found '{f}'", .{ty.fmt(pt)}), | 22593 | else => return sema.fail(block, src, "expected struct, enum, union, or opaque; found '{f}'", .{ty.fmt(zcu)}), |
| 22593 | } | 22594 | } |
| 22594 | } | 22595 | } |
| 22595 | 22596 | ||
| ... | @@ -22600,7 +22601,7 @@ fn checkIntType(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) CompileEr | ... | @@ -22600,7 +22601,7 @@ fn checkIntType(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) CompileEr |
| 22600 | switch (ty.zigTypeTag(zcu)) { | 22601 | switch (ty.zigTypeTag(zcu)) { |
| 22601 | .comptime_int => return true, | 22602 | .comptime_int => return true, |
| 22602 | .int => return false, | 22603 | .int => return false, |
| 22603 | else => return sema.fail(block, src, "expected integer type, found '{f}'", .{ty.fmt(pt)}), | 22604 | else => return sema.fail(block, src, "expected integer type, found '{f}'", .{ty.fmt(zcu)}), |
| 22604 | } | 22605 | } |
| 22605 | } | 22606 | } |
| 22606 | 22607 | ||
| ... | @@ -22655,7 +22656,7 @@ fn checkPtrOperand( | ... | @@ -22655,7 +22656,7 @@ fn checkPtrOperand( |
| 22655 | const msg = try sema.errMsg( | 22656 | const msg = try sema.errMsg( |
| 22656 | ty_src, | 22657 | ty_src, |
| 22657 | "expected pointer, found '{f}'", | 22658 | "expected pointer, found '{f}'", |
| 22658 | .{ty.fmt(pt)}, | 22659 | .{ty.fmt(zcu)}, |
| 22659 | ); | 22660 | ); |
| 22660 | errdefer msg.destroy(sema.gpa); | 22661 | errdefer msg.destroy(sema.gpa); |
| 22661 | 22662 | ||
| ... | @@ -22668,7 +22669,7 @@ fn checkPtrOperand( | ... | @@ -22668,7 +22669,7 @@ fn checkPtrOperand( |
| 22668 | .optional => if (ty.childType(zcu).zigTypeTag(zcu) == .pointer) return, | 22669 | .optional => if (ty.childType(zcu).zigTypeTag(zcu) == .pointer) return, |
| 22669 | else => {}, | 22670 | else => {}, |
| 22670 | } | 22671 | } |
| 22671 | return sema.fail(block, ty_src, "expected pointer type, found '{f}'", .{ty.fmt(pt)}); | 22672 | return sema.fail(block, ty_src, "expected pointer type, found '{f}'", .{ty.fmt(zcu)}); |
| 22672 | } | 22673 | } |
| 22673 | 22674 | ||
| 22674 | fn checkPtrType( | 22675 | fn checkPtrType( |
| ... | @@ -22687,7 +22688,7 @@ fn checkPtrType( | ... | @@ -22687,7 +22688,7 @@ fn checkPtrType( |
| 22687 | const msg = try sema.errMsg( | 22688 | const msg = try sema.errMsg( |
| 22688 | ty_src, | 22689 | ty_src, |
| 22689 | "expected pointer type, found '{f}'", | 22690 | "expected pointer type, found '{f}'", |
| 22690 | .{ty.fmt(pt)}, | 22691 | .{ty.fmt(zcu)}, |
| 22691 | ); | 22692 | ); |
| 22692 | errdefer msg.destroy(sema.gpa); | 22693 | errdefer msg.destroy(sema.gpa); |
| 22693 | 22694 | ||
| ... | @@ -22700,7 +22701,7 @@ fn checkPtrType( | ... | @@ -22700,7 +22701,7 @@ fn checkPtrType( |
| 22700 | .optional => if (ty.childType(zcu).zigTypeTag(zcu) == .pointer) return, | 22701 | .optional => if (ty.childType(zcu).zigTypeTag(zcu) == .pointer) return, |
| 22701 | else => {}, | 22702 | else => {}, |
| 22702 | } | 22703 | } |
| 22703 | return sema.fail(block, ty_src, "expected pointer type, found '{f}'", .{ty.fmt(pt)}); | 22704 | return sema.fail(block, ty_src, "expected pointer type, found '{f}'", .{ty.fmt(zcu)}); |
| 22704 | } | 22705 | } |
| 22705 | 22706 | ||
| 22706 | fn checkLogicalPtrOperation(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) !void { | 22707 | fn checkLogicalPtrOperation(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) !void { |
| ... | @@ -22713,7 +22714,7 @@ fn checkLogicalPtrOperation(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Typ | ... | @@ -22713,7 +22714,7 @@ fn checkLogicalPtrOperation(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Typ |
| 22713 | const as = ty.ptrAddressSpace(zcu); | 22714 | const as = ty.ptrAddressSpace(zcu); |
| 22714 | if (target_util.shouldBlockPointerOps(target, as)) { | 22715 | if (target_util.shouldBlockPointerOps(target, as)) { |
| 22715 | return sema.failWithOwnedErrorMsg(block, msg: { | 22716 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 22716 | const msg = try sema.errMsg(src, "illegal operation on logical pointer of type '{f}'", .{ty.fmt(pt)}); | 22717 | const msg = try sema.errMsg(src, "illegal operation on logical pointer of type '{f}'", .{ty.fmt(zcu)}); |
| 22717 | errdefer msg.destroy(sema.gpa); | 22718 | errdefer msg.destroy(sema.gpa); |
| 22718 | try sema.errNote( | 22719 | try sema.errNote( |
| 22719 | src, | 22720 | src, |
| ... | @@ -22762,9 +22763,9 @@ fn checkLogicalPtrCast( | ... | @@ -22762,9 +22763,9 @@ fn checkLogicalPtrCast( |
| 22762 | }, | 22763 | }, |
| 22763 | else => null, | 22764 | else => null, |
| 22764 | } orelse return sema.failWithOwnedErrorMsg(block, msg: { | 22765 | } orelse return sema.failWithOwnedErrorMsg(block, msg: { |
| 22765 | const msg = try sema.errMsg(src, "cannot cast pointer '{f}' to '{f}'", .{ operand_ty.fmt(pt), dest_ty.fmt(pt) }); | 22766 | const msg = try sema.errMsg(src, "cannot cast pointer '{f}' to '{f}'", .{ operand_ty.fmt(zcu), dest_ty.fmt(zcu) }); |
| 22766 | errdefer msg.destroy(sema.gpa); | 22767 | errdefer msg.destroy(sema.gpa); |
| 22767 | try sema.errNote(src, msg, "'{f}' must appear at offset 0 inside '{f}'", .{ dest_child.fmt(pt), src_child.fmt(pt) }); | 22768 | try sema.errNote(src, msg, "'{f}' must appear at offset 0 inside '{f}'", .{ dest_child.fmt(zcu), src_child.fmt(zcu) }); |
| 22768 | break :msg msg; | 22769 | break :msg msg; |
| 22769 | }); | 22770 | }); |
| 22770 | } | 22771 | } |
| ... | @@ -22783,7 +22784,7 @@ fn checkVectorElemType( | ... | @@ -22783,7 +22784,7 @@ fn checkVectorElemType( |
| 22783 | .optional, .pointer => if (ty.isPtrAtRuntime(zcu)) return, | 22784 | .optional, .pointer => if (ty.isPtrAtRuntime(zcu)) return, |
| 22784 | else => {}, | 22785 | else => {}, |
| 22785 | } | 22786 | } |
| 22786 | return sema.fail(block, ty_src, "expected integer, float, bool, or pointer for the vector element type; found '{f}'", .{ty.fmt(pt)}); | 22787 | return sema.fail(block, ty_src, "expected integer, float, bool, or pointer for the vector element type; found '{f}'", .{ty.fmt(zcu)}); |
| 22787 | } | 22788 | } |
| 22788 | 22789 | ||
| 22789 | fn checkFloatType( | 22790 | fn checkFloatType( |
| ... | @@ -22796,7 +22797,7 @@ fn checkFloatType( | ... | @@ -22796,7 +22797,7 @@ fn checkFloatType( |
| 22796 | const zcu = pt.zcu; | 22797 | const zcu = pt.zcu; |
| 22797 | switch (ty.zigTypeTag(zcu)) { | 22798 | switch (ty.zigTypeTag(zcu)) { |
| 22798 | .comptime_int, .comptime_float, .float => {}, | 22799 | .comptime_int, .comptime_float, .float => {}, |
| 22799 | else => return sema.fail(block, ty_src, "expected float type, found '{f}'", .{ty.fmt(pt)}), | 22800 | else => return sema.fail(block, ty_src, "expected float type, found '{f}'", .{ty.fmt(zcu)}), |
| 22800 | } | 22801 | } |
| 22801 | } | 22802 | } |
| 22802 | 22803 | ||
| ... | @@ -22814,7 +22815,7 @@ fn checkNumericType( | ... | @@ -22814,7 +22815,7 @@ fn checkNumericType( |
| 22814 | .comptime_float, .float, .comptime_int, .int => {}, | 22815 | .comptime_float, .float, .comptime_int, .int => {}, |
| 22815 | else => |t| return sema.fail(block, ty_src, "expected number, found '{t}'", .{t}), | 22816 | else => |t| return sema.fail(block, ty_src, "expected number, found '{t}'", .{t}), |
| 22816 | }, | 22817 | }, |
| 22817 | else => return sema.fail(block, ty_src, "expected number, found '{f}'", .{ty.fmt(pt)}), | 22818 | else => return sema.fail(block, ty_src, "expected number, found '{f}'", .{ty.fmt(zcu)}), |
| 22818 | } | 22819 | } |
| 22819 | } | 22820 | } |
| 22820 | 22821 | ||
| ... | @@ -22850,7 +22851,7 @@ fn checkAtomicPtrOperand( | ... | @@ -22850,7 +22851,7 @@ fn checkAtomicPtrOperand( |
| 22850 | block, | 22851 | block, |
| 22851 | elem_ty_src, | 22852 | elem_ty_src, |
| 22852 | "expected bool, integer, float, enum, packed struct, or pointer type; found '{f}'", | 22853 | "expected bool, integer, float, enum, packed struct, or pointer type; found '{f}'", |
| 22853 | .{elem_ty.fmt(pt)}, | 22854 | .{elem_ty.fmt(zcu)}, |
| 22854 | ), | 22855 | ), |
| 22855 | }; | 22856 | }; |
| 22856 | 22857 | ||
| ... | @@ -22911,12 +22912,12 @@ fn checkIntOrVector( | ... | @@ -22911,12 +22912,12 @@ fn checkIntOrVector( |
| 22911 | switch (elem_ty.zigTypeTag(zcu)) { | 22912 | switch (elem_ty.zigTypeTag(zcu)) { |
| 22912 | .int => return elem_ty, | 22913 | .int => return elem_ty, |
| 22913 | else => return sema.fail(block, operand_src, "expected vector of integers; found vector of '{f}'", .{ | 22914 | else => return sema.fail(block, operand_src, "expected vector of integers; found vector of '{f}'", .{ |
| 22914 | elem_ty.fmt(pt), | 22915 | elem_ty.fmt(zcu), |
| 22915 | }), | 22916 | }), |
| 22916 | } | 22917 | } |
| 22917 | }, | 22918 | }, |
| 22918 | else => return sema.fail(block, operand_src, "expected integer or vector, found '{f}'", .{ | 22919 | else => return sema.fail(block, operand_src, "expected integer or vector, found '{f}'", .{ |
| 22919 | operand_ty.fmt(pt), | 22920 | operand_ty.fmt(zcu), |
| 22920 | }), | 22921 | }), |
| 22921 | } | 22922 | } |
| 22922 | } | 22923 | } |
| ... | @@ -22936,12 +22937,12 @@ fn checkIntOrVectorAllowComptime( | ... | @@ -22936,12 +22937,12 @@ fn checkIntOrVectorAllowComptime( |
| 22936 | switch (elem_ty.zigTypeTag(zcu)) { | 22937 | switch (elem_ty.zigTypeTag(zcu)) { |
| 22937 | .int, .comptime_int => return elem_ty, | 22938 | .int, .comptime_int => return elem_ty, |
| 22938 | else => return sema.fail(block, operand_src, "expected vector of integers; found vector of '{f}'", .{ | 22939 | else => return sema.fail(block, operand_src, "expected vector of integers; found vector of '{f}'", .{ |
| 22939 | elem_ty.fmt(pt), | 22940 | elem_ty.fmt(zcu), |
| 22940 | }), | 22941 | }), |
| 22941 | } | 22942 | } |
| 22942 | }, | 22943 | }, |
| 22943 | else => return sema.fail(block, operand_src, "expected integer or vector, found '{f}'", .{ | 22944 | else => return sema.fail(block, operand_src, "expected integer or vector, found '{f}'", .{ |
| 22944 | operand_ty.fmt(pt), | 22945 | operand_ty.fmt(zcu), |
| 22945 | }), | 22946 | }), |
| 22946 | } | 22947 | } |
| 22947 | } | 22948 | } |
| ... | @@ -23032,7 +23033,7 @@ fn checkVectorizableBinaryOperands( | ... | @@ -23032,7 +23033,7 @@ fn checkVectorizableBinaryOperands( |
| 23032 | } else { | 23033 | } else { |
| 23033 | const msg = msg: { | 23034 | const msg = msg: { |
| 23034 | const msg = try sema.errMsg(src, "mixed scalar and vector operands: '{f}' and '{f}'", .{ | 23035 | const msg = try sema.errMsg(src, "mixed scalar and vector operands: '{f}' and '{f}'", .{ |
| 23035 | lhs_ty.fmt(pt), rhs_ty.fmt(pt), | 23036 | lhs_ty.fmt(zcu), rhs_ty.fmt(zcu), |
| 23036 | }); | 23037 | }); |
| 23037 | errdefer msg.destroy(sema.gpa); | 23038 | errdefer msg.destroy(sema.gpa); |
| 23038 | if (lhs_is_vector) { | 23039 | if (lhs_is_vector) { |
| ... | @@ -23179,7 +23180,7 @@ fn zirCmpxchg( | ... | @@ -23179,7 +23180,7 @@ fn zirCmpxchg( |
| 23179 | block, | 23180 | block, |
| 23180 | elem_ty_src, | 23181 | elem_ty_src, |
| 23181 | "expected bool, integer, enum, packed struct, or pointer type; found '{f}'", | 23182 | "expected bool, integer, enum, packed struct, or pointer type; found '{f}'", |
| 23182 | .{elem_ty.fmt(pt)}, | 23183 | .{elem_ty.fmt(zcu)}, |
| 23183 | ); | 23184 | ); |
| 23184 | } | 23185 | } |
| 23185 | const uncasted_ptr = sema.resolveInst(extra.ptr); | 23186 | const uncasted_ptr = sema.resolveInst(extra.ptr); |
| ... | @@ -23259,7 +23260,7 @@ fn zirSplat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I | ... | @@ -23259,7 +23260,7 @@ fn zirSplat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I |
| 23259 | 23260 | ||
| 23260 | switch (dest_ty.zigTypeTag(zcu)) { | 23261 | switch (dest_ty.zigTypeTag(zcu)) { |
| 23261 | .array, .vector => {}, | 23262 | .array, .vector => {}, |
| 23262 | else => return sema.fail(block, src, "expected array or vector type, found '{f}'", .{dest_ty.fmt(pt)}), | 23263 | else => return sema.fail(block, src, "expected array or vector type, found '{f}'", .{dest_ty.fmt(zcu)}), |
| 23263 | } | 23264 | } |
| 23264 | 23265 | ||
| 23265 | const operand = sema.resolveInst(extra.rhs); | 23266 | const operand = sema.resolveInst(extra.rhs); |
| ... | @@ -23308,7 +23309,7 @@ fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -23308,7 +23309,7 @@ fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 23308 | const zcu = pt.zcu; | 23309 | const zcu = pt.zcu; |
| 23309 | 23310 | ||
| 23310 | if (operand_ty.zigTypeTag(zcu) != .vector) { | 23311 | if (operand_ty.zigTypeTag(zcu) != .vector) { |
| 23311 | return sema.fail(block, operand_src, "expected vector, found '{f}'", .{operand_ty.fmt(pt)}); | 23312 | return sema.fail(block, operand_src, "expected vector, found '{f}'", .{operand_ty.fmt(zcu)}); |
| 23312 | } | 23313 | } |
| 23313 | 23314 | ||
| 23314 | const scalar_ty = operand_ty.childType(zcu); | 23315 | const scalar_ty = operand_ty.childType(zcu); |
| ... | @@ -23318,13 +23319,13 @@ fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -23318,13 +23319,13 @@ fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 23318 | .And, .Or, .Xor => switch (scalar_ty.zigTypeTag(zcu)) { | 23319 | .And, .Or, .Xor => switch (scalar_ty.zigTypeTag(zcu)) { |
| 23319 | .int, .bool => {}, | 23320 | .int, .bool => {}, |
| 23320 | else => return sema.fail(block, operand_src, "@reduce operation '{s}' requires integer or boolean operand; found '{f}'", .{ | 23321 | else => return sema.fail(block, operand_src, "@reduce operation '{s}' requires integer or boolean operand; found '{f}'", .{ |
| 23321 | @tagName(operation), operand_ty.fmt(pt), | 23322 | @tagName(operation), operand_ty.fmt(zcu), |
| 23322 | }), | 23323 | }), |
| 23323 | }, | 23324 | }, |
| 23324 | .Min, .Max, .Add, .Mul => switch (scalar_ty.zigTypeTag(zcu)) { | 23325 | .Min, .Max, .Add, .Mul => switch (scalar_ty.zigTypeTag(zcu)) { |
| 23325 | .int, .float => {}, | 23326 | .int, .float => {}, |
| 23326 | else => return sema.fail(block, operand_src, "@reduce operation '{s}' requires integer or float operand; found '{f}'", .{ | 23327 | else => return sema.fail(block, operand_src, "@reduce operation '{s}' requires integer or float operand; found '{f}'", .{ |
| 23327 | @tagName(operation), operand_ty.fmt(pt), | 23328 | @tagName(operation), operand_ty.fmt(zcu), |
| 23328 | }), | 23329 | }), |
| 23329 | }, | 23330 | }, |
| 23330 | } | 23331 | } |
| ... | @@ -23379,7 +23380,7 @@ fn zirShuffle(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -23379,7 +23380,7 @@ fn zirShuffle(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 23379 | 23380 | ||
| 23380 | const mask_len = switch (sema.typeOf(mask).zigTypeTag(zcu)) { | 23381 | const mask_len = switch (sema.typeOf(mask).zigTypeTag(zcu)) { |
| 23381 | .array, .vector => sema.typeOf(mask).arrayLen(zcu), | 23382 | .array, .vector => sema.typeOf(mask).arrayLen(zcu), |
| 23382 | else => return sema.fail(block, mask_src, "expected vector or array, found '{f}'", .{sema.typeOf(mask).fmt(pt)}), | 23383 | else => return sema.fail(block, mask_src, "expected vector or array, found '{f}'", .{sema.typeOf(mask).fmt(zcu)}), |
| 23383 | }; | 23384 | }; |
| 23384 | mask_ty = try pt.vectorType(.{ | 23385 | mask_ty = try pt.vectorType(.{ |
| 23385 | .len = @intCast(mask_len), | 23386 | .len = @intCast(mask_len), |
| ... | @@ -23412,7 +23413,7 @@ fn analyzeShuffle( | ... | @@ -23412,7 +23413,7 @@ fn analyzeShuffle( |
| 23412 | .array, .vector => @intCast(sema.typeOf(a_uncoerced).arrayLen(zcu)), | 23413 | .array, .vector => @intCast(sema.typeOf(a_uncoerced).arrayLen(zcu)), |
| 23413 | .undefined => 0, | 23414 | .undefined => 0, |
| 23414 | else => return sema.fail(block, a_src, "expected vector of '{f}', found '{f}'", .{ | 23415 | else => return sema.fail(block, a_src, "expected vector of '{f}', found '{f}'", .{ |
| 23415 | elem_ty.fmt(pt), sema.typeOf(a_uncoerced).fmt(pt), | 23416 | elem_ty.fmt(zcu), sema.typeOf(a_uncoerced).fmt(zcu), |
| 23416 | }), | 23417 | }), |
| 23417 | }; | 23418 | }; |
| 23418 | const a_ty = try pt.vectorType(.{ .len = a_len, .child = elem_ty.toIntern() }); | 23419 | const a_ty = try pt.vectorType(.{ .len = a_len, .child = elem_ty.toIntern() }); |
| ... | @@ -23423,7 +23424,7 @@ fn analyzeShuffle( | ... | @@ -23423,7 +23424,7 @@ fn analyzeShuffle( |
| 23423 | .array, .vector => @intCast(sema.typeOf(b_uncoerced).arrayLen(zcu)), | 23424 | .array, .vector => @intCast(sema.typeOf(b_uncoerced).arrayLen(zcu)), |
| 23424 | .undefined => 0, | 23425 | .undefined => 0, |
| 23425 | else => return sema.fail(block, b_src, "expected vector of '{f}', found '{f}'", .{ | 23426 | else => return sema.fail(block, b_src, "expected vector of '{f}', found '{f}'", .{ |
| 23426 | elem_ty.fmt(pt), sema.typeOf(b_uncoerced).fmt(pt), | 23427 | elem_ty.fmt(zcu), sema.typeOf(b_uncoerced).fmt(zcu), |
| 23427 | }), | 23428 | }), |
| 23428 | }; | 23429 | }; |
| 23429 | const b_ty = try pt.vectorType(.{ .len = b_len, .child = elem_ty.toIntern() }); | 23430 | const b_ty = try pt.vectorType(.{ .len = b_len, .child = elem_ty.toIntern() }); |
| ... | @@ -23462,7 +23463,7 @@ fn analyzeShuffle( | ... | @@ -23462,7 +23463,7 @@ fn analyzeShuffle( |
| 23462 | if (idx >= a_len) return sema.failWithOwnedErrorMsg(block, msg: { | 23463 | if (idx >= a_len) return sema.failWithOwnedErrorMsg(block, msg: { |
| 23463 | const msg = try sema.errMsg(mask_src, "mask element at index '{d}' selects out-of-bounds index", .{mask_idx}); | 23464 | const msg = try sema.errMsg(mask_src, "mask element at index '{d}' selects out-of-bounds index", .{mask_idx}); |
| 23464 | errdefer msg.destroy(sema.gpa); | 23465 | errdefer msg.destroy(sema.gpa); |
| 23465 | try sema.errNote(a_src, msg, "index '{d}' exceeds bounds of '{f}' given here", .{ idx, a_ty.fmt(pt) }); | 23466 | try sema.errNote(a_src, msg, "index '{d}' exceeds bounds of '{f}' given here", .{ idx, a_ty.fmt(zcu) }); |
| 23466 | if (idx < b_len) { | 23467 | if (idx < b_len) { |
| 23467 | try sema.errNote(b_src, msg, "use '~@as(u32, {d})' to index into second vector given here", .{idx}); | 23468 | try sema.errNote(b_src, msg, "use '~@as(u32, {d})' to index into second vector given here", .{idx}); |
| 23468 | } | 23469 | } |
| ... | @@ -23475,7 +23476,7 @@ fn analyzeShuffle( | ... | @@ -23475,7 +23476,7 @@ fn analyzeShuffle( |
| 23475 | if (idx >= b_len) return sema.failWithOwnedErrorMsg(block, msg: { | 23476 | if (idx >= b_len) return sema.failWithOwnedErrorMsg(block, msg: { |
| 23476 | const msg = try sema.errMsg(mask_src, "mask element at index '{d}' selects out-of-bounds index", .{mask_idx}); | 23477 | const msg = try sema.errMsg(mask_src, "mask element at index '{d}' selects out-of-bounds index", .{mask_idx}); |
| 23477 | errdefer msg.destroy(sema.gpa); | 23478 | errdefer msg.destroy(sema.gpa); |
| 23478 | try sema.errNote(b_src, msg, "index '{d}' exceeds bounds of '{f}' given here", .{ idx, b_ty.fmt(pt) }); | 23479 | try sema.errNote(b_src, msg, "index '{d}' exceeds bounds of '{f}' given here", .{ idx, b_ty.fmt(zcu) }); |
| 23479 | break :msg msg; | 23480 | break :msg msg; |
| 23480 | }); | 23481 | }); |
| 23481 | } | 23482 | } |
| ... | @@ -23577,7 +23578,7 @@ fn zirSelect(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) C | ... | @@ -23577,7 +23578,7 @@ fn zirSelect(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) C |
| 23577 | 23578 | ||
| 23578 | const vec_len_u64 = switch (pred_ty.zigTypeTag(zcu)) { | 23579 | const vec_len_u64 = switch (pred_ty.zigTypeTag(zcu)) { |
| 23579 | .vector, .array => pred_ty.arrayLen(zcu), | 23580 | .vector, .array => pred_ty.arrayLen(zcu), |
| 23580 | else => return sema.fail(block, pred_src, "expected vector or array, found '{f}'", .{pred_ty.fmt(pt)}), | 23581 | else => return sema.fail(block, pred_src, "expected vector or array, found '{f}'", .{pred_ty.fmt(zcu)}), |
| 23581 | }; | 23582 | }; |
| 23582 | const vec_len: u32 = @intCast(try sema.usizeCast(block, pred_src, vec_len_u64)); | 23583 | const vec_len: u32 = @intCast(try sema.usizeCast(block, pred_src, vec_len_u64)); |
| 23583 | 23584 | ||
| ... | @@ -23835,7 +23836,7 @@ fn zirMulAdd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -23835,7 +23836,7 @@ fn zirMulAdd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 23835 | 23836 | ||
| 23836 | switch (ty.scalarType(zcu).zigTypeTag(zcu)) { | 23837 | switch (ty.scalarType(zcu).zigTypeTag(zcu)) { |
| 23837 | .comptime_float, .float => {}, | 23838 | .comptime_float, .float => {}, |
| 23838 | else => return sema.fail(block, src, "expected vector of floats or float type, found '{f}'", .{ty.fmt(pt)}), | 23839 | else => return sema.fail(block, src, "expected vector of floats or float type, found '{f}'", .{ty.fmt(zcu)}), |
| 23839 | } | 23840 | } |
| 23840 | 23841 | ||
| 23841 | const runtime_src = if (maybe_mulend1) |mulend1_val| rs: { | 23842 | const runtime_src = if (maybe_mulend1) |mulend1_val| rs: { |
| ... | @@ -23933,7 +23934,7 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -23933,7 +23934,7 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 23933 | 23934 | ||
| 23934 | const args_ty = sema.typeOf(args); | 23935 | const args_ty = sema.typeOf(args); |
| 23935 | if (!args_ty.isTuple(zcu)) { | 23936 | if (!args_ty.isTuple(zcu)) { |
| 23936 | return sema.fail(block, args_src, "expected a tuple, found '{f}'", .{args_ty.fmt(pt)}); | 23937 | return sema.fail(block, args_src, "expected a tuple, found '{f}'", .{args_ty.fmt(zcu)}); |
| 23937 | } | 23938 | } |
| 23938 | 23939 | ||
| 23939 | const resolved_args: []Air.Inst.Ref = try sema.arena.alloc(Air.Inst.Ref, args_ty.structFieldCount(zcu)); | 23940 | const resolved_args: []Air.Inst.Ref = try sema.arena.alloc(Air.Inst.Ref, args_ty.structFieldCount(zcu)); |
| ... | @@ -23983,13 +23984,13 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins | ... | @@ -23983,13 +23984,13 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins |
| 23983 | }; | 23984 | }; |
| 23984 | const parent_ptr_info = parent_ptr_ty.ptrInfo(zcu); | 23985 | const parent_ptr_info = parent_ptr_ty.ptrInfo(zcu); |
| 23985 | if (parent_ptr_info.flags.size != .one) { | 23986 | if (parent_ptr_info.flags.size != .one) { |
| 23986 | return sema.fail(block, inst_src, "expected single pointer type, found '{f}'", .{parent_ptr_ty.fmt(pt)}); | 23987 | return sema.fail(block, inst_src, "expected single pointer type, found '{f}'", .{parent_ptr_ty.fmt(zcu)}); |
| 23987 | } | 23988 | } |
| 23988 | const parent_ty: Type = .fromInterned(parent_ptr_info.child); | 23989 | const parent_ty: Type = .fromInterned(parent_ptr_info.child); |
| 23989 | try sema.ensureLayoutResolved(parent_ty, inst_src, .field_used); | 23990 | try sema.ensureLayoutResolved(parent_ty, inst_src, .field_used); |
| 23990 | switch (parent_ty.zigTypeTag(zcu)) { | 23991 | switch (parent_ty.zigTypeTag(zcu)) { |
| 23991 | .@"struct", .@"union" => {}, | 23992 | .@"struct", .@"union" => {}, |
| 23992 | else => return sema.fail(block, inst_src, "expected pointer to struct or union type, found '{f}'", .{parent_ptr_ty.fmt(pt)}), | 23993 | else => return sema.fail(block, inst_src, "expected pointer to struct or union type, found '{f}'", .{parent_ptr_ty.fmt(zcu)}), |
| 23993 | } | 23994 | } |
| 23994 | 23995 | ||
| 23995 | const field_name = try sema.resolveConstStringIntern(block, field_name_src, extra.field_name, .{ .simple = .field_name }); | 23996 | const field_name = try sema.resolveConstStringIntern(block, field_name_src, extra.field_name, .{ .simple = .field_name }); |
| ... | @@ -24072,7 +24073,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins | ... | @@ -24072,7 +24073,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins |
| 24072 | 24073 | ||
| 24073 | if (field.index != field_index) { | 24074 | if (field.index != field_index) { |
| 24074 | return sema.fail(block, inst_src, "field '{f}' has index '{d}' but pointer value is index '{d}' of struct '{f}'", .{ | 24075 | return sema.fail(block, inst_src, "field '{f}' has index '{d}' but pointer value is index '{d}' of struct '{f}'", .{ |
| 24075 | field_name.fmt(ip), field_index, field.index, parent_ty.fmt(pt), | 24076 | field_name.fmt(ip), field_index, field.index, parent_ty.fmt(zcu), |
| 24076 | }); | 24077 | }); |
| 24077 | } | 24078 | } |
| 24078 | break :result .fromValue(try pt.getCoerced(.fromInterned(field.base), unaligned_parent_ptr_ty)); | 24079 | break :result .fromValue(try pt.getCoerced(.fromInterned(field.base), unaligned_parent_ptr_ty)); |
| ... | @@ -24114,7 +24115,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins | ... | @@ -24114,7 +24115,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins |
| 24114 | const msg = try sema.errMsg(inst_src, "@fieldParentPtr increases pointer alignment", .{}); | 24115 | const msg = try sema.errMsg(inst_src, "@fieldParentPtr increases pointer alignment", .{}); |
| 24115 | errdefer msg.destroy(sema.gpa); | 24116 | errdefer msg.destroy(sema.gpa); |
| 24116 | try sema.errNote(inst_src, msg, "parent pointer type '{f}' has alignment '{d}'", .{ | 24117 | try sema.errNote(inst_src, msg, "parent pointer type '{f}' has alignment '{d}'", .{ |
| 24117 | parent_ptr_ty.fmt(pt), | 24118 | parent_ptr_ty.fmt(zcu), |
| 24118 | parent_ptr_ty.abiAlignment(zcu), | 24119 | parent_ptr_ty.abiAlignment(zcu), |
| 24119 | }); | 24120 | }); |
| 24120 | if (parent_ty.isTuple(zcu)) { | 24121 | if (parent_ty.isTuple(zcu)) { |
| ... | @@ -24241,7 +24242,7 @@ fn analyzeMinMax( | ... | @@ -24241,7 +24242,7 @@ fn analyzeMinMax( |
| 24241 | try sema.checkNumericType(block, operand_src, operand_ty); | 24242 | try sema.checkNumericType(block, operand_src, operand_ty); |
| 24242 | if (operand_ty.zigTypeTag(zcu) != .vector) { | 24243 | if (operand_ty.zigTypeTag(zcu) != .vector) { |
| 24243 | return sema.failWithOwnedErrorMsg(block, msg: { | 24244 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 24244 | const msg = try sema.errMsg(operand_src, "expected vector, found '{f}'", .{operand_ty.fmt(pt)}); | 24245 | const msg = try sema.errMsg(operand_src, "expected vector, found '{f}'", .{operand_ty.fmt(zcu)}); |
| 24245 | errdefer msg.destroy(zcu.gpa); | 24246 | errdefer msg.destroy(zcu.gpa); |
| 24246 | try sema.errNote(operand_srcs[0], msg, "vector operand here", .{}); | 24247 | try sema.errNote(operand_srcs[0], msg, "vector operand here", .{}); |
| 24247 | break :msg msg; | 24248 | break :msg msg; |
| ... | @@ -24249,7 +24250,7 @@ fn analyzeMinMax( | ... | @@ -24249,7 +24250,7 @@ fn analyzeMinMax( |
| 24249 | } | 24250 | } |
| 24250 | if (operand_ty.vectorLen(zcu) != vec_len) { | 24251 | if (operand_ty.vectorLen(zcu) != vec_len) { |
| 24251 | return sema.failWithOwnedErrorMsg(block, msg: { | 24252 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 24252 | const msg = try sema.errMsg(operand_src, "expected vector of length '{d}', found '{f}'", .{ vec_len, operand_ty.fmt(pt) }); | 24253 | const msg = try sema.errMsg(operand_src, "expected vector of length '{d}', found '{f}'", .{ vec_len, operand_ty.fmt(zcu) }); |
| 24253 | errdefer msg.destroy(zcu.gpa); | 24254 | errdefer msg.destroy(zcu.gpa); |
| 24254 | try sema.errNote(operand_srcs[0], msg, "vector of length '{d}' here", .{vec_len}); | 24255 | try sema.errNote(operand_srcs[0], msg, "vector of length '{d}' here", .{vec_len}); |
| 24255 | break :msg msg; | 24256 | break :msg msg; |
| ... | @@ -24263,7 +24264,7 @@ fn analyzeMinMax( | ... | @@ -24263,7 +24264,7 @@ fn analyzeMinMax( |
| 24263 | try sema.checkNumericType(block, operand_src, operand_ty); | 24264 | try sema.checkNumericType(block, operand_src, operand_ty); |
| 24264 | if (operand_ty.zigTypeTag(zcu) == .vector) { | 24265 | if (operand_ty.zigTypeTag(zcu) == .vector) { |
| 24265 | return sema.failWithOwnedErrorMsg(block, msg: { | 24266 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 24266 | const msg = try sema.errMsg(operand_srcs[0], "expected vector, found '{f}'", .{first_operand_ty.fmt(pt)}); | 24267 | const msg = try sema.errMsg(operand_srcs[0], "expected vector, found '{f}'", .{first_operand_ty.fmt(zcu)}); |
| 24267 | errdefer msg.destroy(zcu.gpa); | 24268 | errdefer msg.destroy(zcu.gpa); |
| 24268 | try sema.errNote(operand_src, msg, "vector operand here", .{}); | 24269 | try sema.errNote(operand_src, msg, "vector operand here", .{}); |
| 24269 | break :msg msg; | 24270 | break :msg msg; |
| ... | @@ -24581,10 +24582,10 @@ fn zirMemcpy( | ... | @@ -24581,10 +24582,10 @@ fn zirMemcpy( |
| 24581 | const msg = try sema.errMsg(src, "unknown copy length", .{}); | 24582 | const msg = try sema.errMsg(src, "unknown copy length", .{}); |
| 24582 | errdefer msg.destroy(sema.gpa); | 24583 | errdefer msg.destroy(sema.gpa); |
| 24583 | try sema.errNote(dest_src, msg, "destination type '{f}' provides no length", .{ | 24584 | try sema.errNote(dest_src, msg, "destination type '{f}' provides no length", .{ |
| 24584 | dest_ty.fmt(pt), | 24585 | dest_ty.fmt(zcu), |
| 24585 | }); | 24586 | }); |
| 24586 | try sema.errNote(src_src, msg, "source type '{f}' provides no length", .{ | 24587 | try sema.errNote(src_src, msg, "source type '{f}' provides no length", .{ |
| 24587 | src_ty.fmt(pt), | 24588 | src_ty.fmt(zcu), |
| 24588 | }); | 24589 | }); |
| 24589 | break :msg msg; | 24590 | break :msg msg; |
| 24590 | }; | 24591 | }; |
| ... | @@ -24611,7 +24612,7 @@ fn zirMemcpy( | ... | @@ -24611,7 +24612,7 @@ fn zirMemcpy( |
| 24611 | const msg = try sema.errMsg( | 24612 | const msg = try sema.errMsg( |
| 24612 | src, | 24613 | src, |
| 24613 | "pointer element type '{f}' cannot coerce into element type '{f}'", | 24614 | "pointer element type '{f}' cannot coerce into element type '{f}'", |
| 24614 | .{ src_elem_ty.fmt(pt), dest_elem_ty.fmt(pt) }, | 24615 | .{ src_elem_ty.fmt(zcu), dest_elem_ty.fmt(zcu) }, |
| 24615 | ); | 24616 | ); |
| 24616 | errdefer msg.destroy(sema.gpa); | 24617 | errdefer msg.destroy(sema.gpa); |
| 24617 | try imc.report(sema, src, msg); | 24618 | try imc.report(sema, src, msg); |
| ... | @@ -24630,10 +24631,10 @@ fn zirMemcpy( | ... | @@ -24630,10 +24631,10 @@ fn zirMemcpy( |
| 24630 | const msg = try sema.errMsg(src, "non-matching copy lengths", .{}); | 24631 | const msg = try sema.errMsg(src, "non-matching copy lengths", .{}); |
| 24631 | errdefer msg.destroy(sema.gpa); | 24632 | errdefer msg.destroy(sema.gpa); |
| 24632 | try sema.errNote(dest_src, msg, "length {f} here", .{ | 24633 | try sema.errNote(dest_src, msg, "length {f} here", .{ |
| 24633 | dest_len_val.fmtValueSema(pt, sema), | 24634 | dest_len_val.fmtValueSema(sema), |
| 24634 | }); | 24635 | }); |
| 24635 | try sema.errNote(src_src, msg, "length {f} here", .{ | 24636 | try sema.errNote(src_src, msg, "length {f} here", .{ |
| 24636 | src_len_val.fmtValueSema(pt, sema), | 24637 | src_len_val.fmtValueSema(sema), |
| 24637 | }); | 24638 | }); |
| 24638 | break :msg msg; | 24639 | break :msg msg; |
| 24639 | }; | 24640 | }; |
| ... | @@ -24851,7 +24852,7 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void | ... | @@ -24851,7 +24852,7 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void |
| 24851 | const msg = try sema.errMsg(src, "unknown @memset length", .{}); | 24852 | const msg = try sema.errMsg(src, "unknown @memset length", .{}); |
| 24852 | errdefer msg.destroy(sema.gpa); | 24853 | errdefer msg.destroy(sema.gpa); |
| 24853 | try sema.errNote(dest_src, msg, "destination type '{f}' provides no length", .{ | 24854 | try sema.errNote(dest_src, msg, "destination type '{f}' provides no length", .{ |
| 24854 | dest_ptr_ty.fmt(pt), | 24855 | dest_ptr_ty.fmt(zcu), |
| 24855 | }); | 24856 | }); |
| 24856 | break :msg msg; | 24857 | break :msg msg; |
| 24857 | }); | 24858 | }); |
| ... | @@ -24897,7 +24898,7 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void | ... | @@ -24897,7 +24898,7 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void |
| 24897 | 24898 | ||
| 24898 | if (comptime_only_elem) { | 24899 | if (comptime_only_elem) { |
| 24899 | return sema.failWithOwnedErrorMsg(block, msg: { | 24900 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 24900 | const msg = try sema.errMsg(src, "cannot store comptime-only element '{f}' at runtime", .{dest_elem_ty.fmt(pt)}); | 24901 | const msg = try sema.errMsg(src, "cannot store comptime-only element '{f}' at runtime", .{dest_elem_ty.fmt(zcu)}); |
| 24901 | errdefer msg.destroy(sema.gpa); | 24902 | errdefer msg.destroy(sema.gpa); |
| 24902 | try sema.errNote(dest_src, msg, "operation is runtime due to destination pointer", .{}); | 24903 | try sema.errNote(dest_src, msg, "operation is runtime due to destination pointer", .{}); |
| 24903 | break :msg msg; | 24904 | break :msg msg; |
| ... | @@ -25268,16 +25269,16 @@ fn zirBuiltinExtern( | ... | @@ -25268,16 +25269,16 @@ fn zirBuiltinExtern( |
| 25268 | 25269 | ||
| 25269 | if (!elem_ty.validateExtern(.other, zcu)) { | 25270 | if (!elem_ty.validateExtern(.other, zcu)) { |
| 25270 | return sema.failWithOwnedErrorMsg(block, msg: { | 25271 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 25271 | const msg = try sema.errMsg(ty_src, "extern symbol cannot have type '{f}'", .{ptr_ty.fmt(pt)}); | 25272 | const msg = try sema.errMsg(ty_src, "extern symbol cannot have type '{f}'", .{ptr_ty.fmt(zcu)}); |
| 25272 | errdefer msg.destroy(sema.gpa); | 25273 | errdefer msg.destroy(sema.gpa); |
| 25273 | try sema.errNote(ty_src, msg, "pointer element type '{f}' is not extern compatible", .{elem_ty.fmt(pt)}); | 25274 | try sema.errNote(ty_src, msg, "pointer element type '{f}' is not extern compatible", .{elem_ty.fmt(zcu)}); |
| 25274 | try sema.explainWhyTypeIsNotExtern(msg, ty_src, elem_ty, .other); | 25275 | try sema.explainWhyTypeIsNotExtern(msg, ty_src, elem_ty, .other); |
| 25275 | break :msg msg; | 25276 | break :msg msg; |
| 25276 | }); | 25277 | }); |
| 25277 | } | 25278 | } |
| 25278 | if (elem_ty.zigTypeTag(zcu) == .@"fn" and !ptr_info.flags.is_const) { | 25279 | if (elem_ty.zigTypeTag(zcu) == .@"fn" and !ptr_info.flags.is_const) { |
| 25279 | return sema.failWithOwnedErrorMsg(block, msg: { | 25280 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 25280 | const msg = try sema.errMsg(ty_src, "extern symbol cannot have type '{f}'", .{ptr_ty.fmt(pt)}); | 25281 | const msg = try sema.errMsg(ty_src, "extern symbol cannot have type '{f}'", .{ptr_ty.fmt(zcu)}); |
| 25281 | errdefer msg.destroy(sema.gpa); | 25282 | errdefer msg.destroy(sema.gpa); |
| 25282 | try sema.errNote(ty_src, msg, "pointer to extern function must be 'const'", .{}); | 25283 | try sema.errNote(ty_src, msg, "pointer to extern function must be 'const'", .{}); |
| 25283 | break :msg msg; | 25284 | break :msg msg; |
| ... | @@ -25541,7 +25542,7 @@ fn zirFloatOpResultType(sema: *Sema, block: *Block, extended: Zir.Inst.Extended. | ... | @@ -25541,7 +25542,7 @@ fn zirFloatOpResultType(sema: *Sema, block: *Block, extended: Zir.Inst.Extended. |
| 25541 | block, | 25542 | block, |
| 25542 | operand_src, | 25543 | operand_src, |
| 25543 | "expected vector of floats or float type, found '{f}'", | 25544 | "expected vector of floats or float type, found '{f}'", |
| 25544 | .{float_ty.fmt(sema.pt)}, | 25545 | .{float_ty.fmt(zcu)}, |
| 25545 | ), | 25546 | ), |
| 25546 | } | 25547 | } |
| 25547 | 25548 | ||
| ... | @@ -25598,7 +25599,7 @@ pub fn validateVarType( | ... | @@ -25598,7 +25599,7 @@ pub fn validateVarType( |
| 25598 | if (is_extern) { | 25599 | if (is_extern) { |
| 25599 | if (!var_ty.validateExtern(.other, zcu)) { | 25600 | if (!var_ty.validateExtern(.other, zcu)) { |
| 25600 | const msg = msg: { | 25601 | const msg = msg: { |
| 25601 | const msg = try sema.errMsg(src, "extern variable cannot have type '{f}'", .{var_ty.fmt(pt)}); | 25602 | const msg = try sema.errMsg(src, "extern variable cannot have type '{f}'", .{var_ty.fmt(zcu)}); |
| 25602 | errdefer msg.destroy(sema.gpa); | 25603 | errdefer msg.destroy(sema.gpa); |
| 25603 | try sema.explainWhyTypeIsNotExtern(msg, src, var_ty, .other); | 25604 | try sema.explainWhyTypeIsNotExtern(msg, src, var_ty, .other); |
| 25604 | break :msg msg; | 25605 | break :msg msg; |
| ... | @@ -25611,7 +25612,7 @@ pub fn validateVarType( | ... | @@ -25611,7 +25612,7 @@ pub fn validateVarType( |
| 25611 | block, | 25612 | block, |
| 25612 | src, | 25613 | src, |
| 25613 | "non-extern variable with opaque type '{f}'", | 25614 | "non-extern variable with opaque type '{f}'", |
| 25614 | .{var_ty.fmt(pt)}, | 25615 | .{var_ty.fmt(zcu)}, |
| 25615 | ); | 25616 | ); |
| 25616 | } | 25617 | } |
| 25617 | } | 25618 | } |
| ... | @@ -25619,7 +25620,7 @@ pub fn validateVarType( | ... | @@ -25619,7 +25620,7 @@ pub fn validateVarType( |
| 25619 | if (!var_ty.comptimeOnly(zcu)) return; | 25620 | if (!var_ty.comptimeOnly(zcu)) return; |
| 25620 | 25621 | ||
| 25621 | const msg = msg: { | 25622 | const msg = msg: { |
| 25622 | const msg = try sema.errMsg(src, "variable of type '{f}' must be const or comptime", .{var_ty.fmt(pt)}); | 25623 | const msg = try sema.errMsg(src, "variable of type '{f}' must be const or comptime", .{var_ty.fmt(zcu)}); |
| 25623 | errdefer msg.destroy(sema.gpa); | 25624 | errdefer msg.destroy(sema.gpa); |
| 25624 | 25625 | ||
| 25625 | try sema.explainWhyTypeIsComptime(msg, src, var_ty); | 25626 | try sema.explainWhyTypeIsComptime(msg, src, var_ty); |
| ... | @@ -25668,7 +25669,7 @@ fn explainWhyTypeIsComptime( | ... | @@ -25668,7 +25669,7 @@ fn explainWhyTypeIsComptime( |
| 25668 | .optional => try sema.explainWhyTypeIsComptime(msg, src, ty.optionalChild(zcu)), | 25669 | .optional => try sema.explainWhyTypeIsComptime(msg, src, ty.optionalChild(zcu)), |
| 25669 | .error_union => try sema.explainWhyTypeIsComptime(msg, src, ty.errorUnionPayload(zcu)), | 25670 | .error_union => try sema.explainWhyTypeIsComptime(msg, src, ty.errorUnionPayload(zcu)), |
| 25670 | 25671 | ||
| 25671 | .@"fn" => try sema.errNote(src, msg, "use '*const {f}' for a function pointer type", .{ty.fmt(pt)}), | 25672 | .@"fn" => try sema.errNote(src, msg, "use '*const {f}' for a function pointer type", .{ty.fmt(zcu)}), |
| 25672 | .type => try sema.errNote(src, msg, "types are not available at runtime", .{}), | 25673 | .type => try sema.errNote(src, msg, "types are not available at runtime", .{}), |
| 25673 | 25674 | ||
| 25674 | .@"struct" => if (zcu.typeToStruct(ty)) |struct_type| { | 25675 | .@"struct" => if (zcu.typeToStruct(ty)) |struct_type| { |
| ... | @@ -25690,7 +25691,7 @@ fn explainWhyTypeIsComptime( | ... | @@ -25690,7 +25691,7 @@ fn explainWhyTypeIsComptime( |
| 25690 | if (field_val_ip != .none) continue; | 25691 | if (field_val_ip != .none) continue; |
| 25691 | const field_ty: Type = .fromInterned(field_ty_ip); | 25692 | const field_ty: Type = .fromInterned(field_ty_ip); |
| 25692 | if (!field_ty.comptimeOnly(zcu)) continue; | 25693 | if (!field_ty.comptimeOnly(zcu)) continue; |
| 25693 | try sema.errNote(src, msg, "tuple requires comptime because of field of type '{f}'", .{field_ty.fmt(pt)}); | 25694 | try sema.errNote(src, msg, "tuple requires comptime because of field of type '{f}'", .{field_ty.fmt(zcu)}); |
| 25694 | return sema.explainWhyTypeIsComptime(msg, src, field_ty); | 25695 | return sema.explainWhyTypeIsComptime(msg, src, field_ty); |
| 25695 | } | 25696 | } |
| 25696 | unreachable; | 25697 | unreachable; |
| ... | @@ -25751,7 +25752,7 @@ pub fn explainWhyTypeIsNotExtern( | ... | @@ -25751,7 +25752,7 @@ pub fn explainWhyTypeIsNotExtern( |
| 25751 | } | 25752 | } |
| 25752 | }, | 25753 | }, |
| 25753 | 25754 | ||
| 25754 | .float => try sema.errNote(src_loc, msg, "'{f}' is not extern compatible on this target", .{ty.fmt(pt)}), | 25755 | .float => try sema.errNote(src_loc, msg, "'{f}' is not extern compatible on this target", .{ty.fmt(zcu)}), |
| 25755 | .pointer => if (ty.isSlice(zcu)) { | 25756 | .pointer => if (ty.isSlice(zcu)) { |
| 25756 | try sema.errNote(src_loc, msg, "slices have no guaranteed in-memory representation", .{}); | 25757 | try sema.errNote(src_loc, msg, "slices have no guaranteed in-memory representation", .{}); |
| 25757 | } else { | 25758 | } else { |
| ... | @@ -25783,7 +25784,7 @@ pub fn explainWhyTypeIsNotExtern( | ... | @@ -25783,7 +25784,7 @@ pub fn explainWhyTypeIsNotExtern( |
| 25783 | }, | 25784 | }, |
| 25784 | .explicit => { | 25785 | .explicit => { |
| 25785 | const tag_ty: Type = .fromInterned(enum_obj.int_tag_type); | 25786 | const tag_ty: Type = .fromInterned(enum_obj.int_tag_type); |
| 25786 | try sema.errNote(ty.srcLoc(zcu), msg, "enum tag type '{f}' is not extern compatible", .{tag_ty.fmt(pt)}); | 25787 | try sema.errNote(ty.srcLoc(zcu), msg, "enum tag type '{f}' is not extern compatible", .{tag_ty.fmt(zcu)}); |
| 25787 | try sema.explainWhyTypeIsNotExtern(msg, ty.srcLoc(zcu), tag_ty, position); | 25788 | try sema.explainWhyTypeIsNotExtern(msg, ty.srcLoc(zcu), tag_ty, position); |
| 25788 | }, | 25789 | }, |
| 25789 | } | 25790 | } |
| ... | @@ -25801,7 +25802,7 @@ pub fn explainWhyTypeIsNotExtern( | ... | @@ -25801,7 +25802,7 @@ pub fn explainWhyTypeIsNotExtern( |
| 25801 | .auto => try sema.errNote(src_loc, msg, "inferred backing integer of packed struct has unspecified signedness", .{}), | 25802 | .auto => try sema.errNote(src_loc, msg, "inferred backing integer of packed struct has unspecified signedness", .{}), |
| 25802 | .explicit => { | 25803 | .explicit => { |
| 25803 | const backing_int_ty: Type = .fromInterned(struct_obj.packed_backing_int_type); | 25804 | const backing_int_ty: Type = .fromInterned(struct_obj.packed_backing_int_type); |
| 25804 | try sema.errNote(src_loc, msg, "packed struct backing integer type '{f}' is not extern compatible", .{backing_int_ty.fmt(pt)}); | 25805 | try sema.errNote(src_loc, msg, "packed struct backing integer type '{f}' is not extern compatible", .{backing_int_ty.fmt(zcu)}); |
| 25805 | try sema.explainWhyTypeIsNotExtern(msg, src_loc, backing_int_ty, position); | 25806 | try sema.explainWhyTypeIsNotExtern(msg, src_loc, backing_int_ty, position); |
| 25806 | }, | 25807 | }, |
| 25807 | }, | 25808 | }, |
| ... | @@ -25816,7 +25817,7 @@ pub fn explainWhyTypeIsNotExtern( | ... | @@ -25816,7 +25817,7 @@ pub fn explainWhyTypeIsNotExtern( |
| 25816 | .auto => try sema.errNote(src_loc, msg, "inferred backing integer of packed union has unspecified signedness", .{}), | 25817 | .auto => try sema.errNote(src_loc, msg, "inferred backing integer of packed union has unspecified signedness", .{}), |
| 25817 | .explicit => { | 25818 | .explicit => { |
| 25818 | const backing_int_ty: Type = .fromInterned(union_obj.packed_backing_int_type); | 25819 | const backing_int_ty: Type = .fromInterned(union_obj.packed_backing_int_type); |
| 25819 | try sema.errNote(src_loc, msg, "packed union backing integer type '{f}' is not extern compatible", .{backing_int_ty.fmt(pt)}); | 25820 | try sema.errNote(src_loc, msg, "packed union backing integer type '{f}' is not extern compatible", .{backing_int_ty.fmt(zcu)}); |
| 25820 | try sema.explainWhyTypeIsNotExtern(msg, src_loc, backing_int_ty, position); | 25821 | try sema.explainWhyTypeIsNotExtern(msg, src_loc, backing_int_ty, position); |
| 25821 | }, | 25822 | }, |
| 25822 | }, | 25823 | }, |
| ... | @@ -26270,7 +26271,7 @@ fn fieldVal( | ... | @@ -26270,7 +26271,7 @@ fn fieldVal( |
| 26270 | block, | 26271 | block, |
| 26271 | field_name_src, | 26272 | field_name_src, |
| 26272 | "no member named '{f}' in '{f}'", | 26273 | "no member named '{f}' in '{f}'", |
| 26273 | .{ field_name.fmt(ip), object_ty.fmt(pt) }, | 26274 | .{ field_name.fmt(ip), object_ty.fmt(zcu) }, |
| 26274 | ); | 26275 | ); |
| 26275 | } | 26276 | } |
| 26276 | }, | 26277 | }, |
| ... | @@ -26294,7 +26295,7 @@ fn fieldVal( | ... | @@ -26294,7 +26295,7 @@ fn fieldVal( |
| 26294 | block, | 26295 | block, |
| 26295 | field_name_src, | 26296 | field_name_src, |
| 26296 | "no member named '{f}' in '{f}'", | 26297 | "no member named '{f}' in '{f}'", |
| 26297 | .{ field_name.fmt(ip), object_ty.fmt(pt) }, | 26298 | .{ field_name.fmt(ip), object_ty.fmt(zcu) }, |
| 26298 | ); | 26299 | ); |
| 26299 | } | 26300 | } |
| 26300 | } | 26301 | } |
| ... | @@ -26318,7 +26319,7 @@ fn fieldVal( | ... | @@ -26318,7 +26319,7 @@ fn fieldVal( |
| 26318 | }, | 26319 | }, |
| 26319 | .error_set_type => |err_set| if (err_set.nameIndex(ip, field_name) == null) { | 26320 | .error_set_type => |err_set| if (err_set.nameIndex(ip, field_name) == null) { |
| 26320 | return sema.fail(block, src, "no error named '{f}' in '{f}'", .{ | 26321 | return sema.fail(block, src, "no error named '{f}' in '{f}'", .{ |
| 26321 | field_name.fmt(ip), child_type.fmt(pt), | 26322 | field_name.fmt(ip), child_type.fmt(zcu), |
| 26322 | }); | 26323 | }); |
| 26323 | } else child_type, | 26324 | } else child_type, |
| 26324 | .simple_type => |t| { | 26325 | .simple_type => |t| { |
| ... | @@ -26366,7 +26367,7 @@ fn fieldVal( | ... | @@ -26366,7 +26367,7 @@ fn fieldVal( |
| 26366 | return sema.failWithBadMemberAccess(block, child_type, src, field_name); | 26367 | return sema.failWithBadMemberAccess(block, child_type, src, field_name); |
| 26367 | }, | 26368 | }, |
| 26368 | else => return sema.failWithOwnedErrorMsg(block, msg: { | 26369 | else => return sema.failWithOwnedErrorMsg(block, msg: { |
| 26369 | const msg = try sema.errMsg(src, "type '{f}' has no members", .{child_type.fmt(pt)}); | 26370 | const msg = try sema.errMsg(src, "type '{f}' has no members", .{child_type.fmt(zcu)}); |
| 26370 | errdefer msg.destroy(sema.gpa); | 26371 | errdefer msg.destroy(sema.gpa); |
| 26371 | if (child_type.isSlice(zcu)) try sema.errNote(src, msg, "slice values have 'len' and 'ptr' members", .{}); | 26372 | if (child_type.isSlice(zcu)) try sema.errNote(src, msg, "slice values have 'len' and 'ptr' members", .{}); |
| 26372 | if (child_type.zigTypeTag(zcu) == .array) try sema.errNote(src, msg, "array values have 'len' member", .{}); | 26373 | if (child_type.zigTypeTag(zcu) == .array) try sema.errNote(src, msg, "array values have 'len' member", .{}); |
| ... | @@ -26526,7 +26527,7 @@ fn fieldPtr( | ... | @@ -26526,7 +26527,7 @@ fn fieldPtr( |
| 26526 | const object_ptr_ty = sema.typeOf(object_ptr); | 26527 | const object_ptr_ty = sema.typeOf(object_ptr); |
| 26527 | const object_ty = switch (object_ptr_ty.zigTypeTag(zcu)) { | 26528 | const object_ty = switch (object_ptr_ty.zigTypeTag(zcu)) { |
| 26528 | .pointer => object_ptr_ty.childType(zcu), | 26529 | .pointer => object_ptr_ty.childType(zcu), |
| 26529 | else => return sema.fail(block, object_ptr_src, "expected pointer, found '{f}'", .{object_ptr_ty.fmt(pt)}), | 26530 | else => return sema.fail(block, object_ptr_src, "expected pointer, found '{f}'", .{object_ptr_ty.fmt(zcu)}), |
| 26530 | }; | 26531 | }; |
| 26531 | 26532 | ||
| 26532 | // Zig allows dereferencing a single pointer during field lookup. Note that | 26533 | // Zig allows dereferencing a single pointer during field lookup. Note that |
| ... | @@ -26581,7 +26582,7 @@ fn fieldPtr( | ... | @@ -26581,7 +26582,7 @@ fn fieldPtr( |
| 26581 | block, | 26582 | block, |
| 26582 | field_name_src, | 26583 | field_name_src, |
| 26583 | "no member named '{f}' in '{f}'", | 26584 | "no member named '{f}' in '{f}'", |
| 26584 | .{ field_name.fmt(ip), object_ty.fmt(pt) }, | 26585 | .{ field_name.fmt(ip), object_ty.fmt(zcu) }, |
| 26585 | ); | 26586 | ); |
| 26586 | } | 26587 | } |
| 26587 | }, | 26588 | }, |
| ... | @@ -26618,7 +26619,7 @@ fn fieldPtr( | ... | @@ -26618,7 +26619,7 @@ fn fieldPtr( |
| 26618 | block, | 26619 | block, |
| 26619 | field_name_src, | 26620 | field_name_src, |
| 26620 | "no member named '{f}' in '{f}'", | 26621 | "no member named '{f}' in '{f}'", |
| 26621 | .{ field_name.fmt(ip), object_ty.fmt(pt) }, | 26622 | .{ field_name.fmt(ip), object_ty.fmt(zcu) }, |
| 26622 | ); | 26623 | ); |
| 26623 | } | 26624 | } |
| 26624 | }, | 26625 | }, |
| ... | @@ -26642,7 +26643,7 @@ fn fieldPtr( | ... | @@ -26642,7 +26643,7 @@ fn fieldPtr( |
| 26642 | }, | 26643 | }, |
| 26643 | .error_set_type => |err_set| if (err_set.nameIndex(ip, field_name) == null) { | 26644 | .error_set_type => |err_set| if (err_set.nameIndex(ip, field_name) == null) { |
| 26644 | return sema.fail(block, src, "no error named '{f}' in '{f}'", .{ | 26645 | return sema.fail(block, src, "no error named '{f}' in '{f}'", .{ |
| 26645 | field_name.fmt(ip), child_type.fmt(pt), | 26646 | field_name.fmt(ip), child_type.fmt(zcu), |
| 26646 | }); | 26647 | }); |
| 26647 | } else child_type, | 26648 | } else child_type, |
| 26648 | .simple_type => |t| { | 26649 | .simple_type => |t| { |
| ... | @@ -26689,7 +26690,7 @@ fn fieldPtr( | ... | @@ -26689,7 +26690,7 @@ fn fieldPtr( |
| 26689 | } | 26690 | } |
| 26690 | return sema.failWithBadMemberAccess(block, child_type, field_name_src, field_name); | 26691 | return sema.failWithBadMemberAccess(block, child_type, field_name_src, field_name); |
| 26691 | }, | 26692 | }, |
| 26692 | else => return sema.fail(block, src, "type '{f}' has no members", .{child_type.fmt(pt)}), | 26693 | else => return sema.fail(block, src, "type '{f}' has no members", .{child_type.fmt(zcu)}), |
| 26693 | } | 26694 | } |
| 26694 | }, | 26695 | }, |
| 26695 | .@"struct" => { | 26696 | .@"struct" => { |
| ... | @@ -26746,7 +26747,7 @@ fn fieldCallBind( | ... | @@ -26746,7 +26747,7 @@ fn fieldCallBind( |
| 26746 | const inner_ty = if (raw_ptr_ty.zigTypeTag(zcu) == .pointer and (raw_ptr_ty.ptrSize(zcu) == .one or raw_ptr_ty.ptrSize(zcu) == .c)) | 26747 | const inner_ty = if (raw_ptr_ty.zigTypeTag(zcu) == .pointer and (raw_ptr_ty.ptrSize(zcu) == .one or raw_ptr_ty.ptrSize(zcu) == .c)) |
| 26747 | raw_ptr_ty.childType(zcu) | 26748 | raw_ptr_ty.childType(zcu) |
| 26748 | else | 26749 | else |
| 26749 | return sema.fail(block, raw_ptr_src, "expected single pointer, found '{f}'", .{raw_ptr_ty.fmt(pt)}); | 26750 | return sema.fail(block, raw_ptr_src, "expected single pointer, found '{f}'", .{raw_ptr_ty.fmt(zcu)}); |
| 26750 | 26751 | ||
| 26751 | // Optionally dereference a second pointer to get the concrete type. | 26752 | // Optionally dereference a second pointer to get the concrete type. |
| 26752 | const is_double_ptr = inner_ty.zigTypeTag(zcu) == .pointer and inner_ty.ptrSize(zcu) == .one; | 26753 | const is_double_ptr = inner_ty.zigTypeTag(zcu) == .pointer and inner_ty.ptrSize(zcu) == .one; |
| ... | @@ -26864,7 +26865,7 @@ fn fieldCallBind( | ... | @@ -26864,7 +26865,7 @@ fn fieldCallBind( |
| 26864 | const msg = msg: { | 26865 | const msg = msg: { |
| 26865 | const msg = try sema.errMsg(src, "no field or member function named '{f}' in '{f}'", .{ | 26866 | const msg = try sema.errMsg(src, "no field or member function named '{f}' in '{f}'", .{ |
| 26866 | field_name.fmt(ip), | 26867 | field_name.fmt(ip), |
| 26867 | concrete_ty.fmt(pt), | 26868 | concrete_ty.fmt(zcu), |
| 26868 | }); | 26869 | }); |
| 26869 | errdefer msg.destroy(sema.gpa); | 26870 | errdefer msg.destroy(sema.gpa); |
| 26870 | try sema.addDeclaredHereNote(msg, concrete_ty); | 26871 | try sema.addDeclaredHereNote(msg, concrete_ty); |
| ... | @@ -27100,18 +27101,18 @@ fn tupleFieldIndex( | ... | @@ -27100,18 +27101,18 @@ fn tupleFieldIndex( |
| 27100 | field_name: InternPool.NullTerminatedString, | 27101 | field_name: InternPool.NullTerminatedString, |
| 27101 | field_name_src: LazySrcLoc, | 27102 | field_name_src: LazySrcLoc, |
| 27102 | ) CompileError!u32 { | 27103 | ) CompileError!u32 { |
| 27103 | const pt = sema.pt; | 27104 | const zcu = sema.pt.zcu; |
| 27104 | const ip = &pt.zcu.intern_pool; | 27105 | const ip = &zcu.intern_pool; |
| 27105 | assert(!field_name.eqlSlice("len", ip)); | 27106 | assert(!field_name.eqlSlice("len", ip)); |
| 27106 | if (field_name.toUnsigned(ip)) |field_index| { | 27107 | if (field_name.toUnsigned(ip)) |field_index| { |
| 27107 | if (field_index < tuple_ty.structFieldCount(pt.zcu)) return field_index; | 27108 | if (field_index < tuple_ty.structFieldCount(zcu)) return field_index; |
| 27108 | return sema.fail(block, field_name_src, "index '{f}' out of bounds of tuple '{f}'", .{ | 27109 | return sema.fail(block, field_name_src, "index '{f}' out of bounds of tuple '{f}'", .{ |
| 27109 | field_name.fmt(ip), tuple_ty.fmt(pt), | 27110 | field_name.fmt(ip), tuple_ty.fmt(zcu), |
| 27110 | }); | 27111 | }); |
| 27111 | } | 27112 | } |
| 27112 | 27113 | ||
| 27113 | return sema.fail(block, field_name_src, "no field named '{f}' in tuple '{f}'", .{ | 27114 | return sema.fail(block, field_name_src, "no field named '{f}' in tuple '{f}'", .{ |
| 27114 | field_name.fmt(ip), tuple_ty.fmt(pt), | 27115 | field_name.fmt(ip), tuple_ty.fmt(zcu), |
| 27115 | }); | 27116 | }); |
| 27116 | } | 27117 | } |
| 27117 | 27118 | ||
| ... | @@ -27173,7 +27174,7 @@ fn unionFieldPtr( | ... | @@ -27173,7 +27174,7 @@ fn unionFieldPtr( |
| 27173 | 27174 | ||
| 27174 | if (initializing and field_ty.classify(zcu) == .no_possible_value) { | 27175 | if (initializing and field_ty.classify(zcu) == .no_possible_value) { |
| 27175 | const msg = msg: { | 27176 | const msg = msg: { |
| 27176 | const msg = try sema.errMsg(src, "cannot initialize union field with uninstantiable type '{f}'", .{field_ty.fmt(pt)}); | 27177 | const msg = try sema.errMsg(src, "cannot initialize union field with uninstantiable type '{f}'", .{field_ty.fmt(zcu)}); |
| 27177 | errdefer msg.destroy(sema.gpa); | 27178 | errdefer msg.destroy(sema.gpa); |
| 27178 | 27179 | ||
| 27179 | try sema.addFieldErrNote(union_ty, field_index, msg, "field '{f}' declared here", .{ | 27180 | try sema.addFieldErrNote(union_ty, field_index, msg, "field '{f}' declared here", .{ |
| ... | @@ -27328,7 +27329,7 @@ fn elemPtr( | ... | @@ -27328,7 +27329,7 @@ fn elemPtr( |
| 27328 | 27329 | ||
| 27329 | const indexable_ty = switch (indexable_ptr_ty.zigTypeTag(zcu)) { | 27330 | const indexable_ty = switch (indexable_ptr_ty.zigTypeTag(zcu)) { |
| 27330 | .pointer => indexable_ptr_ty.childType(zcu), | 27331 | .pointer => indexable_ptr_ty.childType(zcu), |
| 27331 | else => return sema.fail(block, indexable_ptr_src, "expected pointer, found '{f}'", .{indexable_ptr_ty.fmt(pt)}), | 27332 | else => return sema.fail(block, indexable_ptr_src, "expected pointer, found '{f}'", .{indexable_ptr_ty.fmt(zcu)}), |
| 27332 | }; | 27333 | }; |
| 27333 | try sema.checkIndexable(block, src, indexable_ty); | 27334 | try sema.checkIndexable(block, src, indexable_ty); |
| 27334 | try sema.ensureLayoutResolved(indexable_ty, src, .ptr_access); | 27335 | try sema.ensureLayoutResolved(indexable_ty, src, .ptr_access); |
| ... | @@ -27454,8 +27455,8 @@ fn elemVal( | ... | @@ -27454,8 +27455,8 @@ fn elemVal( |
| 27454 | .runtime => {}, | 27455 | .runtime => {}, |
| 27455 | .one_possible_value => return .fromValue((try child_ty.onePossibleValue(pt)).?), | 27456 | .one_possible_value => return .fromValue((try child_ty.onePossibleValue(pt)).?), |
| 27456 | .no_possible_value => switch (child_ty.zigTypeTag(zcu)) { | 27457 | .no_possible_value => switch (child_ty.zigTypeTag(zcu)) { |
| 27457 | .@"opaque" => return sema.fail(block, src, "cannot load opaque type '{f}'", .{child_ty.fmt(pt)}), | 27458 | .@"opaque" => return sema.fail(block, src, "cannot load opaque type '{f}'", .{child_ty.fmt(zcu)}), |
| 27458 | else => return sema.fail(block, src, "cannot load uninstantiable type '{f}'", .{child_ty.fmt(pt)}), | 27459 | else => return sema.fail(block, src, "cannot load uninstantiable type '{f}'", .{child_ty.fmt(zcu)}), |
| 27459 | }, | 27460 | }, |
| 27460 | .partially_comptime, .fully_comptime => unreachable, // caught by `validateRuntimeElemAccess` | 27461 | .partially_comptime, .fully_comptime => unreachable, // caught by `validateRuntimeElemAccess` |
| 27461 | } | 27462 | } |
| ... | @@ -27508,7 +27509,7 @@ fn validateRuntimeElemAccess( | ... | @@ -27508,7 +27509,7 @@ fn validateRuntimeElemAccess( |
| 27508 | const msg = try sema.errMsg( | 27509 | const msg = try sema.errMsg( |
| 27509 | elem_index_src, | 27510 | elem_index_src, |
| 27510 | "values of type '{f}' must be comptime-known, but index value is runtime-known", | 27511 | "values of type '{f}' must be comptime-known, but index value is runtime-known", |
| 27511 | .{elem_ty.fmt(sema.pt)}, | 27512 | .{elem_ty.fmt(zcu)}, |
| 27512 | ); | 27513 | ); |
| 27513 | errdefer msg.destroy(sema.gpa); | 27514 | errdefer msg.destroy(sema.gpa); |
| 27514 | 27515 | ||
| ... | @@ -27547,7 +27548,7 @@ fn tupleElemPtr( | ... | @@ -27547,7 +27548,7 @@ fn tupleElemPtr( |
| 27547 | const index = elem_index_val.getUnsignedInt(zcu); | 27548 | const index = elem_index_val.getUnsignedInt(zcu); |
| 27548 | if (index == null or index.? >= field_count) { | 27549 | if (index == null or index.? >= field_count) { |
| 27549 | return sema.fail(block, elem_index_src, "index '{f}' out of bounds of tuple '{f}'", .{ | 27550 | return sema.fail(block, elem_index_src, "index '{f}' out of bounds of tuple '{f}'", .{ |
| 27550 | elem_index_val.fmtValueSema(pt, sema), tuple_ty.fmt(pt), | 27551 | elem_index_val.fmtValueSema(sema), tuple_ty.fmt(zcu), |
| 27551 | }); | 27552 | }); |
| 27552 | } | 27553 | } |
| 27553 | 27554 | ||
| ... | @@ -28296,7 +28297,7 @@ fn coerceExtra( | ... | @@ -28296,7 +28297,7 @@ fn coerceExtra( |
| 28296 | block, | 28297 | block, |
| 28297 | inst_src, | 28298 | inst_src, |
| 28298 | "coercion from slice to array pointer type '{f}' requires length to be known at compile-time", | 28299 | "coercion from slice to array pointer type '{f}' requires length to be known at compile-time", |
| 28299 | .{dest_ty.fmt(pt)}, | 28300 | .{dest_ty.fmt(zcu)}, |
| 28300 | ); | 28301 | ); |
| 28301 | }; | 28302 | }; |
| 28302 | 28303 | ||
| ... | @@ -28309,7 +28310,7 @@ fn coerceExtra( | ... | @@ -28309,7 +28310,7 @@ fn coerceExtra( |
| 28309 | if (!opts.report_err) return error.NotCoercible; | 28310 | if (!opts.report_err) return error.NotCoercible; |
| 28310 | return sema.failWithOwnedErrorMsg(block, msg: { | 28311 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 28311 | const msg = try sema.errMsg(inst_src, "slice with undefined length cannot cast into array pointer type '{f}'", .{ | 28312 | const msg = try sema.errMsg(inst_src, "slice with undefined length cannot cast into array pointer type '{f}'", .{ |
| 28312 | dest_ty.fmt(pt), | 28313 | dest_ty.fmt(zcu), |
| 28313 | }); | 28314 | }); |
| 28314 | errdefer msg.destroy(gpa); | 28315 | errdefer msg.destroy(gpa); |
| 28315 | try sema.errNote(inst_src, msg, "length of slice must be defined and match length of array type", .{}); | 28316 | try sema.errNote(inst_src, msg, "length of slice must be defined and match length of array type", .{}); |
| ... | @@ -28321,7 +28322,7 @@ fn coerceExtra( | ... | @@ -28321,7 +28322,7 @@ fn coerceExtra( |
| 28321 | if (!opts.report_err) return error.NotCoercible; | 28322 | if (!opts.report_err) return error.NotCoercible; |
| 28322 | return sema.failWithOwnedErrorMsg(block, msg: { | 28323 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 28323 | const msg = try sema.errMsg(inst_src, "slice of length {d} cannot cast into array pointer type '{f}'", .{ | 28324 | const msg = try sema.errMsg(inst_src, "slice of length {d} cannot cast into array pointer type '{f}'", .{ |
| 28324 | slice_len, dest_ty.fmt(pt), | 28325 | slice_len, dest_ty.fmt(zcu), |
| 28325 | }); | 28326 | }); |
| 28326 | errdefer msg.destroy(gpa); | 28327 | errdefer msg.destroy(gpa); |
| 28327 | try sema.errNote(inst_src, msg, "length of slice must match length of array type", .{}); | 28328 | try sema.errNote(inst_src, msg, "length of slice must match length of array type", .{}); |
| ... | @@ -28376,7 +28377,7 @@ fn coerceExtra( | ... | @@ -28376,7 +28377,7 @@ fn coerceExtra( |
| 28376 | block, | 28377 | block, |
| 28377 | inst_src, | 28378 | inst_src, |
| 28378 | "array literal requires address-of operator (&) to coerce to slice type '{f}'", | 28379 | "array literal requires address-of operator (&) to coerce to slice type '{f}'", |
| 28379 | .{dest_ty.fmt(pt)}, | 28380 | .{dest_ty.fmt(zcu)}, |
| 28380 | ); | 28381 | ); |
| 28381 | } | 28382 | } |
| 28382 | 28383 | ||
| ... | @@ -28401,7 +28402,7 @@ fn coerceExtra( | ... | @@ -28401,7 +28402,7 @@ fn coerceExtra( |
| 28401 | if (!dest_info.flags.is_const) { | 28402 | if (!dest_info.flags.is_const) { |
| 28402 | if (!opts.report_err) return error.NotCoercible; | 28403 | if (!opts.report_err) return error.NotCoercible; |
| 28403 | const err_msg = err_msg: { | 28404 | const err_msg = err_msg: { |
| 28404 | const err_msg = try sema.errMsg(inst_src, "cannot cast pointer to tuple to '{f}'", .{dest_ty.fmt(pt)}); | 28405 | const err_msg = try sema.errMsg(inst_src, "cannot cast pointer to tuple to '{f}'", .{dest_ty.fmt(zcu)}); |
| 28405 | errdefer err_msg.destroy(sema.gpa); | 28406 | errdefer err_msg.destroy(sema.gpa); |
| 28406 | try sema.errNote(dest_ty_src, err_msg, "pointers to tuples can only coerce to constant pointers", .{}); | 28407 | try sema.errNote(dest_ty_src, err_msg, "pointers to tuples can only coerce to constant pointers", .{}); |
| 28407 | break :err_msg err_msg; | 28408 | break :err_msg err_msg; |
| ... | @@ -28456,7 +28457,7 @@ fn coerceExtra( | ... | @@ -28456,7 +28457,7 @@ fn coerceExtra( |
| 28456 | // comptime-known integer to other number | 28457 | // comptime-known integer to other number |
| 28457 | if (!val.intFitsInType(dest_ty, null, zcu)) { | 28458 | if (!val.intFitsInType(dest_ty, null, zcu)) { |
| 28458 | if (!opts.report_err) return error.NotCoercible; | 28459 | if (!opts.report_err) return error.NotCoercible; |
| 28459 | return sema.fail(block, inst_src, "type '{f}' cannot represent integer value '{f}'", .{ dest_ty.fmt(pt), val.fmtValueSema(pt, sema) }); | 28460 | return sema.fail(block, inst_src, "type '{f}' cannot represent integer value '{f}'", .{ dest_ty.fmt(zcu), val.fmtValueSema(sema) }); |
| 28460 | } | 28461 | } |
| 28461 | return switch (zcu.intern_pool.indexToKey(val.toIntern())) { | 28462 | return switch (zcu.intern_pool.indexToKey(val.toIntern())) { |
| 28462 | .undef => .fromValue(try dest_ty.onePossibleValue(pt) orelse try pt.undefValue(dest_ty)), | 28463 | .undef => .fromValue(try dest_ty.onePossibleValue(pt) orelse try pt.undefValue(dest_ty)), |
| ... | @@ -28500,7 +28501,7 @@ fn coerceExtra( | ... | @@ -28500,7 +28501,7 @@ fn coerceExtra( |
| 28500 | block, | 28501 | block, |
| 28501 | inst_src, | 28502 | inst_src, |
| 28502 | "type '{f}' cannot represent float value '{f}'", | 28503 | "type '{f}' cannot represent float value '{f}'", |
| 28503 | .{ dest_ty.fmt(pt), val.fmtValueSema(pt, sema) }, | 28504 | .{ dest_ty.fmt(zcu), val.fmtValueSema(sema) }, |
| 28504 | ); | 28505 | ); |
| 28505 | } | 28506 | } |
| 28506 | return Air.internedToRef(result_val.toIntern()); | 28507 | return Air.internedToRef(result_val.toIntern()); |
| ... | @@ -28559,7 +28560,7 @@ fn coerceExtra( | ... | @@ -28559,7 +28560,7 @@ fn coerceExtra( |
| 28559 | block, | 28560 | block, |
| 28560 | inst_src, | 28561 | inst_src, |
| 28561 | "type '{f}' cannot represent integer value '{f}'", | 28562 | "type '{f}' cannot represent integer value '{f}'", |
| 28562 | .{ dest_ty.fmt(pt), val.fmtValue(pt) }, | 28563 | .{ dest_ty.fmt(zcu), val.fmtValue(zcu) }, |
| 28563 | ); | 28564 | ); |
| 28564 | } | 28565 | } |
| 28565 | return .fromValue(result_val); | 28566 | return .fromValue(result_val); |
| ... | @@ -28574,7 +28575,7 @@ fn coerceExtra( | ... | @@ -28574,7 +28575,7 @@ fn coerceExtra( |
| 28574 | const field_index = dest_ty.enumFieldIndex(string, zcu) orelse { | 28575 | const field_index = dest_ty.enumFieldIndex(string, zcu) orelse { |
| 28575 | if (!opts.report_err) return error.NotCoercible; | 28576 | if (!opts.report_err) return error.NotCoercible; |
| 28576 | return sema.fail(block, inst_src, "no field named '{f}' in enum '{f}'", .{ | 28577 | return sema.fail(block, inst_src, "no field named '{f}' in enum '{f}'", .{ |
| 28577 | string.fmt(&zcu.intern_pool), dest_ty.fmt(pt), | 28578 | string.fmt(&zcu.intern_pool), dest_ty.fmt(zcu), |
| 28578 | }); | 28579 | }); |
| 28579 | }; | 28580 | }; |
| 28580 | return Air.internedToRef((try pt.enumValueFieldIndex(dest_ty, @intCast(field_index))).toIntern()); | 28581 | return Air.internedToRef((try pt.enumValueFieldIndex(dest_ty, @intCast(field_index))).toIntern()); |
| ... | @@ -28703,7 +28704,7 @@ fn coerceExtra( | ... | @@ -28703,7 +28704,7 @@ fn coerceExtra( |
| 28703 | errdefer msg.destroy(sema.gpa); | 28704 | errdefer msg.destroy(sema.gpa); |
| 28704 | 28705 | ||
| 28705 | if (dest_is_npv) { | 28706 | if (dest_is_npv) { |
| 28706 | try sema.errNote(inst_src, msg, "cannot coerce to uninstantiable type '{f}'", .{dest_ty.fmt(pt)}); | 28707 | try sema.errNote(inst_src, msg, "cannot coerce to uninstantiable type '{f}'", .{dest_ty.fmt(zcu)}); |
| 28707 | } | 28708 | } |
| 28708 | 28709 | ||
| 28709 | // E!T to T | 28710 | // E!T to T |
| ... | @@ -28887,6 +28888,7 @@ const InMemoryCoercionResult = union(enum) { | ... | @@ -28887,6 +28888,7 @@ const InMemoryCoercionResult = union(enum) { |
| 28887 | 28888 | ||
| 28888 | fn report(res: *const InMemoryCoercionResult, sema: *Sema, src: LazySrcLoc, msg: *Zcu.ErrorMsg) !void { | 28889 | fn report(res: *const InMemoryCoercionResult, sema: *Sema, src: LazySrcLoc, msg: *Zcu.ErrorMsg) !void { |
| 28889 | const pt = sema.pt; | 28890 | const pt = sema.pt; |
| 28891 | const zcu = pt.zcu; | ||
| 28890 | var cur = res; | 28892 | var cur = res; |
| 28891 | while (true) switch (cur.*) { | 28893 | while (true) switch (cur.*) { |
| 28892 | .ok => unreachable, | 28894 | .ok => unreachable, |
| ... | @@ -28903,13 +28905,13 @@ const InMemoryCoercionResult = union(enum) { | ... | @@ -28903,13 +28905,13 @@ const InMemoryCoercionResult = union(enum) { |
| 28903 | }, | 28905 | }, |
| 28904 | .comptime_int_not_coercible => |int| { | 28906 | .comptime_int_not_coercible => |int| { |
| 28905 | try sema.errNote(src, msg, "type '{f}' cannot represent value '{f}'", .{ | 28907 | try sema.errNote(src, msg, "type '{f}' cannot represent value '{f}'", .{ |
| 28906 | int.wanted.fmt(pt), int.actual.fmtValueSema(pt, sema), | 28908 | int.wanted.fmt(zcu), int.actual.fmtValueSema(sema), |
| 28907 | }); | 28909 | }); |
| 28908 | break; | 28910 | break; |
| 28909 | }, | 28911 | }, |
| 28910 | .error_union_payload => |pair| { | 28912 | .error_union_payload => |pair| { |
| 28911 | try sema.errNote(src, msg, "error union payload '{f}' cannot cast into error union payload '{f}'", .{ | 28913 | try sema.errNote(src, msg, "error union payload '{f}' cannot cast into error union payload '{f}'", .{ |
| 28912 | pair.actual.fmt(pt), pair.wanted.fmt(pt), | 28914 | pair.actual.fmt(zcu), pair.wanted.fmt(zcu), |
| 28913 | }); | 28915 | }); |
| 28914 | cur = pair.child; | 28916 | cur = pair.child; |
| 28915 | }, | 28917 | }, |
| ... | @@ -28922,22 +28924,22 @@ const InMemoryCoercionResult = union(enum) { | ... | @@ -28922,22 +28924,22 @@ const InMemoryCoercionResult = union(enum) { |
| 28922 | .array_sentinel => |sentinel| { | 28924 | .array_sentinel => |sentinel| { |
| 28923 | if (sentinel.wanted.toIntern() == .unreachable_value) { | 28925 | if (sentinel.wanted.toIntern() == .unreachable_value) { |
| 28924 | try sema.errNote(src, msg, "source array cannot be guaranteed to maintain '{f}' sentinel", .{ | 28926 | try sema.errNote(src, msg, "source array cannot be guaranteed to maintain '{f}' sentinel", .{ |
| 28925 | sentinel.actual.fmtValueSema(pt, sema), | 28927 | sentinel.actual.fmtValueSema(sema), |
| 28926 | }); | 28928 | }); |
| 28927 | } else if (sentinel.actual.toIntern() == .unreachable_value) { | 28929 | } else if (sentinel.actual.toIntern() == .unreachable_value) { |
| 28928 | try sema.errNote(src, msg, "destination array requires '{f}' sentinel", .{ | 28930 | try sema.errNote(src, msg, "destination array requires '{f}' sentinel", .{ |
| 28929 | sentinel.wanted.fmtValueSema(pt, sema), | 28931 | sentinel.wanted.fmtValueSema(sema), |
| 28930 | }); | 28932 | }); |
| 28931 | } else { | 28933 | } else { |
| 28932 | try sema.errNote(src, msg, "array sentinel '{f}' cannot cast into array sentinel '{f}'", .{ | 28934 | try sema.errNote(src, msg, "array sentinel '{f}' cannot cast into array sentinel '{f}'", .{ |
| 28933 | sentinel.actual.fmtValueSema(pt, sema), sentinel.wanted.fmtValueSema(pt, sema), | 28935 | sentinel.actual.fmtValueSema(sema), sentinel.wanted.fmtValueSema(sema), |
| 28934 | }); | 28936 | }); |
| 28935 | } | 28937 | } |
| 28936 | break; | 28938 | break; |
| 28937 | }, | 28939 | }, |
| 28938 | .array_elem => |pair| { | 28940 | .array_elem => |pair| { |
| 28939 | try sema.errNote(src, msg, "array element type '{f}' cannot cast into array element type '{f}'", .{ | 28941 | try sema.errNote(src, msg, "array element type '{f}' cannot cast into array element type '{f}'", .{ |
| 28940 | pair.actual.fmt(pt), pair.wanted.fmt(pt), | 28942 | pair.actual.fmt(zcu), pair.wanted.fmt(zcu), |
| 28941 | }); | 28943 | }); |
| 28942 | cur = pair.child; | 28944 | cur = pair.child; |
| 28943 | }, | 28945 | }, |
| ... | @@ -28949,19 +28951,19 @@ const InMemoryCoercionResult = union(enum) { | ... | @@ -28949,19 +28951,19 @@ const InMemoryCoercionResult = union(enum) { |
| 28949 | }, | 28951 | }, |
| 28950 | .vector_elem => |pair| { | 28952 | .vector_elem => |pair| { |
| 28951 | try sema.errNote(src, msg, "vector element type '{f}' cannot cast into vector element type '{f}'", .{ | 28953 | try sema.errNote(src, msg, "vector element type '{f}' cannot cast into vector element type '{f}'", .{ |
| 28952 | pair.actual.fmt(pt), pair.wanted.fmt(pt), | 28954 | pair.actual.fmt(zcu), pair.wanted.fmt(zcu), |
| 28953 | }); | 28955 | }); |
| 28954 | cur = pair.child; | 28956 | cur = pair.child; |
| 28955 | }, | 28957 | }, |
| 28956 | .optional_shape => |pair| { | 28958 | .optional_shape => |pair| { |
| 28957 | try sema.errNote(src, msg, "optional type child '{f}' cannot cast into optional type child '{f}'", .{ | 28959 | try sema.errNote(src, msg, "optional type child '{f}' cannot cast into optional type child '{f}'", .{ |
| 28958 | pair.actual.optionalChild(pt.zcu).fmt(pt), pair.wanted.optionalChild(pt.zcu).fmt(pt), | 28960 | pair.actual.optionalChild(pt.zcu).fmt(zcu), pair.wanted.optionalChild(pt.zcu).fmt(zcu), |
| 28959 | }); | 28961 | }); |
| 28960 | break; | 28962 | break; |
| 28961 | }, | 28963 | }, |
| 28962 | .optional_child => |pair| { | 28964 | .optional_child => |pair| { |
| 28963 | try sema.errNote(src, msg, "optional type child '{f}' cannot cast into optional type child '{f}'", .{ | 28965 | try sema.errNote(src, msg, "optional type child '{f}' cannot cast into optional type child '{f}'", .{ |
| 28964 | pair.actual.fmt(pt), pair.wanted.fmt(pt), | 28966 | pair.actual.fmt(zcu), pair.wanted.fmt(zcu), |
| 28965 | }); | 28967 | }); |
| 28966 | cur = pair.child; | 28968 | cur = pair.child; |
| 28967 | }, | 28969 | }, |
| ... | @@ -29025,7 +29027,7 @@ const InMemoryCoercionResult = union(enum) { | ... | @@ -29025,7 +29027,7 @@ const InMemoryCoercionResult = union(enum) { |
| 29025 | }, | 29027 | }, |
| 29026 | .fn_param => |param| { | 29028 | .fn_param => |param| { |
| 29027 | try sema.errNote(src, msg, "parameter {d} '{f}' cannot cast into '{f}'", .{ | 29029 | try sema.errNote(src, msg, "parameter {d} '{f}' cannot cast into '{f}'", .{ |
| 29028 | param.index, param.actual.fmt(pt), param.wanted.fmt(pt), | 29030 | param.index, param.actual.fmt(zcu), param.wanted.fmt(zcu), |
| 29029 | }); | 29031 | }); |
| 29030 | cur = param.child; | 29032 | cur = param.child; |
| 29031 | }, | 29033 | }, |
| ... | @@ -29035,13 +29037,13 @@ const InMemoryCoercionResult = union(enum) { | ... | @@ -29035,13 +29037,13 @@ const InMemoryCoercionResult = union(enum) { |
| 29035 | }, | 29037 | }, |
| 29036 | .fn_return_type => |pair| { | 29038 | .fn_return_type => |pair| { |
| 29037 | try sema.errNote(src, msg, "return type '{f}' cannot cast into return type '{f}'", .{ | 29039 | try sema.errNote(src, msg, "return type '{f}' cannot cast into return type '{f}'", .{ |
| 29038 | pair.actual.fmt(pt), pair.wanted.fmt(pt), | 29040 | pair.actual.fmt(zcu), pair.wanted.fmt(zcu), |
| 29039 | }); | 29041 | }); |
| 29040 | cur = pair.child; | 29042 | cur = pair.child; |
| 29041 | }, | 29043 | }, |
| 29042 | .ptr_child => |pair| { | 29044 | .ptr_child => |pair| { |
| 29043 | try sema.errNote(src, msg, "pointer type child '{f}' cannot cast into pointer type child '{f}'", .{ | 29045 | try sema.errNote(src, msg, "pointer type child '{f}' cannot cast into pointer type child '{f}'", .{ |
| 29044 | pair.actual.fmt(pt), pair.wanted.fmt(pt), | 29046 | pair.actual.fmt(zcu), pair.wanted.fmt(zcu), |
| 29045 | }); | 29047 | }); |
| 29046 | cur = pair.child; | 29048 | cur = pair.child; |
| 29047 | }, | 29049 | }, |
| ... | @@ -29052,11 +29054,11 @@ const InMemoryCoercionResult = union(enum) { | ... | @@ -29052,11 +29054,11 @@ const InMemoryCoercionResult = union(enum) { |
| 29052 | .ptr_sentinel => |sentinel| { | 29054 | .ptr_sentinel => |sentinel| { |
| 29053 | if (sentinel.actual.toIntern() != .unreachable_value) { | 29055 | if (sentinel.actual.toIntern() != .unreachable_value) { |
| 29054 | try sema.errNote(src, msg, "pointer sentinel '{f}' cannot cast into pointer sentinel '{f}'", .{ | 29056 | try sema.errNote(src, msg, "pointer sentinel '{f}' cannot cast into pointer sentinel '{f}'", .{ |
| 29055 | sentinel.actual.fmtValueSema(pt, sema), sentinel.wanted.fmtValueSema(pt, sema), | 29057 | sentinel.actual.fmtValueSema(sema), sentinel.wanted.fmtValueSema(sema), |
| 29056 | }); | 29058 | }); |
| 29057 | } else { | 29059 | } else { |
| 29058 | try sema.errNote(src, msg, "destination pointer requires '{f}' sentinel", .{ | 29060 | try sema.errNote(src, msg, "destination pointer requires '{f}' sentinel", .{ |
| 29059 | sentinel.wanted.fmtValueSema(pt, sema), | 29061 | sentinel.wanted.fmtValueSema(sema), |
| 29060 | }); | 29062 | }); |
| 29061 | } | 29063 | } |
| 29062 | break; | 29064 | break; |
| ... | @@ -29070,11 +29072,11 @@ const InMemoryCoercionResult = union(enum) { | ... | @@ -29070,11 +29072,11 @@ const InMemoryCoercionResult = union(enum) { |
| 29070 | const actual_allow_zero = pair.actual.ptrAllowsZero(pt.zcu); | 29072 | const actual_allow_zero = pair.actual.ptrAllowsZero(pt.zcu); |
| 29071 | if (actual_allow_zero and !wanted_allow_zero) { | 29073 | if (actual_allow_zero and !wanted_allow_zero) { |
| 29072 | try sema.errNote(src, msg, "'{f}' could have null values which are illegal in type '{f}'", .{ | 29074 | try sema.errNote(src, msg, "'{f}' could have null values which are illegal in type '{f}'", .{ |
| 29073 | pair.actual.fmt(pt), pair.wanted.fmt(pt), | 29075 | pair.actual.fmt(zcu), pair.wanted.fmt(zcu), |
| 29074 | }); | 29076 | }); |
| 29075 | } else { | 29077 | } else { |
| 29076 | try sema.errNote(src, msg, "mutable '{f}' would allow illegal null values stored to type '{f}'", .{ | 29078 | try sema.errNote(src, msg, "mutable '{f}' would allow illegal null values stored to type '{f}'", .{ |
| 29077 | pair.wanted.fmt(pt), pair.actual.fmt(pt), | 29079 | pair.wanted.fmt(zcu), pair.actual.fmt(zcu), |
| 29078 | }); | 29080 | }); |
| 29079 | } | 29081 | } |
| 29080 | break; | 29082 | break; |
| ... | @@ -29086,7 +29088,7 @@ const InMemoryCoercionResult = union(enum) { | ... | @@ -29086,7 +29088,7 @@ const InMemoryCoercionResult = union(enum) { |
| 29086 | try sema.errNote(src, msg, "cast discards const qualifier", .{}); | 29088 | try sema.errNote(src, msg, "cast discards const qualifier", .{}); |
| 29087 | } else { | 29089 | } else { |
| 29088 | try sema.errNote(src, msg, "mutable '{f}' would allow illegal const pointers stored to type '{f}'", .{ | 29090 | try sema.errNote(src, msg, "mutable '{f}' would allow illegal const pointers stored to type '{f}'", .{ |
| 29089 | pair.wanted.fmt(pt), pair.actual.fmt(pt), | 29091 | pair.wanted.fmt(zcu), pair.actual.fmt(zcu), |
| 29090 | }); | 29092 | }); |
| 29091 | } | 29093 | } |
| 29092 | break; | 29094 | break; |
| ... | @@ -29098,7 +29100,7 @@ const InMemoryCoercionResult = union(enum) { | ... | @@ -29098,7 +29100,7 @@ const InMemoryCoercionResult = union(enum) { |
| 29098 | try sema.errNote(src, msg, "cast discards volatile qualifier", .{}); | 29100 | try sema.errNote(src, msg, "cast discards volatile qualifier", .{}); |
| 29099 | } else { | 29101 | } else { |
| 29100 | try sema.errNote(src, msg, "mutable '{f}' would allow illegal volatile pointers stored to type '{f}'", .{ | 29102 | try sema.errNote(src, msg, "mutable '{f}' would allow illegal volatile pointers stored to type '{f}'", .{ |
| 29101 | pair.wanted.fmt(pt), pair.actual.fmt(pt), | 29103 | pair.wanted.fmt(zcu), pair.actual.fmt(zcu), |
| 29102 | }); | 29104 | }); |
| 29103 | } | 29105 | } |
| 29104 | break; | 29106 | break; |
| ... | @@ -29124,13 +29126,13 @@ const InMemoryCoercionResult = union(enum) { | ... | @@ -29124,13 +29126,13 @@ const InMemoryCoercionResult = union(enum) { |
| 29124 | }, | 29126 | }, |
| 29125 | .double_ptr_to_anyopaque => |pair| { | 29127 | .double_ptr_to_anyopaque => |pair| { |
| 29126 | try sema.errNote(src, msg, "cannot implicitly cast double pointer '{f}' to anyopaque pointer '{f}'", .{ | 29128 | try sema.errNote(src, msg, "cannot implicitly cast double pointer '{f}' to anyopaque pointer '{f}'", .{ |
| 29127 | pair.actual.fmt(pt), pair.wanted.fmt(pt), | 29129 | pair.actual.fmt(zcu), pair.wanted.fmt(zcu), |
| 29128 | }); | 29130 | }); |
| 29129 | break; | 29131 | break; |
| 29130 | }, | 29132 | }, |
| 29131 | .slice_to_anyopaque => |pair| { | 29133 | .slice_to_anyopaque => |pair| { |
| 29132 | try sema.errNote(src, msg, "cannot implicitly cast slice '{f}' to anyopaque pointer '{f}'", .{ | 29134 | try sema.errNote(src, msg, "cannot implicitly cast slice '{f}' to anyopaque pointer '{f}'", .{ |
| 29133 | pair.actual.fmt(pt), pair.wanted.fmt(pt), | 29135 | pair.actual.fmt(zcu), pair.wanted.fmt(zcu), |
| 29134 | }); | 29136 | }); |
| 29135 | try sema.errNote(src, msg, "consider using '.ptr'", .{}); | 29137 | try sema.errNote(src, msg, "consider using '.ptr'", .{}); |
| 29136 | break; | 29138 | break; |
| ... | @@ -29881,7 +29883,7 @@ fn coerceVarArgParam( | ... | @@ -29881,7 +29883,7 @@ fn coerceVarArgParam( |
| 29881 | const coerced_ty = sema.typeOf(coerced); | 29883 | const coerced_ty = sema.typeOf(coerced); |
| 29882 | if (!coerced_ty.validateExtern(.param_ty, zcu)) { | 29884 | if (!coerced_ty.validateExtern(.param_ty, zcu)) { |
| 29883 | const msg = msg: { | 29885 | const msg = msg: { |
| 29884 | const msg = try sema.errMsg(inst_src, "cannot pass '{f}' to variadic function", .{coerced_ty.fmt(pt)}); | 29886 | const msg = try sema.errMsg(inst_src, "cannot pass '{f}' to variadic function", .{coerced_ty.fmt(zcu)}); |
| 29885 | errdefer msg.destroy(sema.gpa); | 29887 | errdefer msg.destroy(sema.gpa); |
| 29886 | 29888 | ||
| 29887 | try sema.explainWhyTypeIsNotExtern(msg, inst_src, coerced_ty, .param_ty); | 29889 | try sema.explainWhyTypeIsNotExtern(msg, inst_src, coerced_ty, .param_ty); |
| ... | @@ -29948,7 +29950,7 @@ fn storePtr2( | ... | @@ -29948,7 +29950,7 @@ fn storePtr2( |
| 29948 | 29950 | ||
| 29949 | // We're performing the store at runtime, so the pointee type must not be comptime-only. | 29951 | // We're performing the store at runtime, so the pointee type must not be comptime-only. |
| 29950 | if (comptime_only) return sema.failWithOwnedErrorMsg(block, msg: { | 29952 | if (comptime_only) return sema.failWithOwnedErrorMsg(block, msg: { |
| 29951 | const msg = try sema.errMsg(src, "cannot store comptime-only type '{f}' at runtime", .{elem_ty.fmt(pt)}); | 29953 | const msg = try sema.errMsg(src, "cannot store comptime-only type '{f}' at runtime", .{elem_ty.fmt(zcu)}); |
| 29952 | errdefer msg.destroy(zcu.gpa); | 29954 | errdefer msg.destroy(zcu.gpa); |
| 29953 | try sema.errNote(ptr_src, msg, "operation is runtime due to this pointer", .{}); | 29955 | try sema.errNote(ptr_src, msg, "operation is runtime due to this pointer", .{}); |
| 29954 | break :msg msg; | 29956 | break :msg msg; |
| ... | @@ -30104,13 +30106,13 @@ fn storePtrVal( | ... | @@ -30104,13 +30106,13 @@ fn storePtrVal( |
| 30104 | block, | 30106 | block, |
| 30105 | src, | 30107 | src, |
| 30106 | "comptime dereference requires '{f}' to have a well-defined layout", | 30108 | "comptime dereference requires '{f}' to have a well-defined layout", |
| 30107 | .{ty.fmt(pt)}, | 30109 | .{ty.fmt(zcu)}, |
| 30108 | ), | 30110 | ), |
| 30109 | .out_of_bounds => |ty| return sema.fail( | 30111 | .out_of_bounds => |ty| return sema.fail( |
| 30110 | block, | 30112 | block, |
| 30111 | src, | 30113 | src, |
| 30112 | "dereference of '{f}' exceeds bounds of containing decl of type '{f}'", | 30114 | "dereference of '{f}' exceeds bounds of containing decl of type '{f}'", |
| 30113 | .{ ptr_ty.fmt(pt), ty.fmt(pt) }, | 30115 | .{ ptr_ty.fmt(zcu), ty.fmt(zcu) }, |
| 30114 | ), | 30116 | ), |
| 30115 | .exceeds_host_size => return sema.fail(block, src, "bit-pointer target exceeds host size", .{}), | 30117 | .exceeds_host_size => return sema.fail(block, src, "bit-pointer target exceeds host size", .{}), |
| 30116 | } | 30118 | } |
| ... | @@ -30322,7 +30324,7 @@ fn coerceCompatiblePtrs( | ... | @@ -30322,7 +30324,7 @@ fn coerceCompatiblePtrs( |
| 30322 | const inst_ty = sema.typeOf(inst); | 30324 | const inst_ty = sema.typeOf(inst); |
| 30323 | if (sema.resolveValue(inst)) |val| { | 30325 | if (sema.resolveValue(inst)) |val| { |
| 30324 | if (!val.isUndef(zcu) and val.isNull(zcu) and !dest_ty.isAllowzeroPtr(zcu)) { | 30326 | if (!val.isUndef(zcu) and val.isNull(zcu) and !dest_ty.isAllowzeroPtr(zcu)) { |
| 30325 | return sema.fail(block, inst_src, "null pointer casted to type '{f}'", .{dest_ty.fmt(pt)}); | 30327 | return sema.fail(block, inst_src, "null pointer casted to type '{f}'", .{dest_ty.fmt(zcu)}); |
| 30326 | } | 30328 | } |
| 30327 | // The comptime Value representation is compatible with both types. | 30329 | // The comptime Value representation is compatible with both types. |
| 30328 | return Air.internedToRef( | 30330 | return Air.internedToRef( |
| ... | @@ -30393,7 +30395,7 @@ fn coerceEnumToUnion( | ... | @@ -30393,7 +30395,7 @@ fn coerceEnumToUnion( |
| 30393 | if (try sema.resolveDefinedValue(block, inst_src, enum_tag)) |val| { | 30395 | if (try sema.resolveDefinedValue(block, inst_src, enum_tag)) |val| { |
| 30394 | const field_index = union_ty.unionTagFieldIndex(val, pt.zcu) orelse { | 30396 | const field_index = union_ty.unionTagFieldIndex(val, pt.zcu) orelse { |
| 30395 | return sema.fail(block, inst_src, "union '{f}' has no tag with value '{f}'", .{ | 30397 | return sema.fail(block, inst_src, "union '{f}' has no tag with value '{f}'", .{ |
| 30396 | union_ty.fmt(pt), val.fmtValueSema(pt, sema), | 30398 | union_ty.fmt(zcu), val.fmtValueSema(sema), |
| 30397 | }); | 30399 | }); |
| 30398 | }; | 30400 | }; |
| 30399 | 30401 | ||
| ... | @@ -30407,7 +30409,7 @@ fn coerceEnumToUnion( | ... | @@ -30407,7 +30409,7 @@ fn coerceEnumToUnion( |
| 30407 | )), | 30409 | )), |
| 30408 | 30410 | ||
| 30409 | .no_possible_value => return sema.failWithOwnedErrorMsg(block, msg: { | 30411 | .no_possible_value => return sema.failWithOwnedErrorMsg(block, msg: { |
| 30410 | const msg = try sema.errMsg(inst_src, "cannot initialize union field with uninstantiable type '{f}'", .{field_ty.fmt(pt)}); | 30412 | const msg = try sema.errMsg(inst_src, "cannot initialize union field with uninstantiable type '{f}'", .{field_ty.fmt(zcu)}); |
| 30411 | errdefer msg.destroy(sema.gpa); | 30413 | errdefer msg.destroy(sema.gpa); |
| 30412 | try sema.addFieldErrNote(union_ty, field_index, msg, "field '{f}' declared here", .{ | 30414 | try sema.addFieldErrNote(union_ty, field_index, msg, "field '{f}' declared here", .{ |
| 30413 | field_name.fmt(ip), | 30415 | field_name.fmt(ip), |
| ... | @@ -30418,8 +30420,8 @@ fn coerceEnumToUnion( | ... | @@ -30418,8 +30420,8 @@ fn coerceEnumToUnion( |
| 30418 | 30420 | ||
| 30419 | else => return sema.failWithOwnedErrorMsg(block, msg: { | 30421 | else => return sema.failWithOwnedErrorMsg(block, msg: { |
| 30420 | const msg = try sema.errMsg(inst_src, "coercion from enum '{f}' to union '{f}' must initialize '{f}' field '{f}'", .{ | 30422 | const msg = try sema.errMsg(inst_src, "coercion from enum '{f}' to union '{f}' must initialize '{f}' field '{f}'", .{ |
| 30421 | inst_ty.fmt(pt), union_ty.fmt(pt), | 30423 | inst_ty.fmt(zcu), union_ty.fmt(zcu), |
| 30422 | field_ty.fmt(pt), field_name.fmt(ip), | 30424 | field_ty.fmt(zcu), field_name.fmt(ip), |
| 30423 | }); | 30425 | }); |
| 30424 | errdefer msg.destroy(sema.gpa); | 30426 | errdefer msg.destroy(sema.gpa); |
| 30425 | 30427 | ||
| ... | @@ -30435,7 +30437,7 @@ fn coerceEnumToUnion( | ... | @@ -30435,7 +30437,7 @@ fn coerceEnumToUnion( |
| 30435 | if (enum_ty.isNonexhaustiveEnum(zcu)) { | 30437 | if (enum_ty.isNonexhaustiveEnum(zcu)) { |
| 30436 | const msg = msg: { | 30438 | const msg = msg: { |
| 30437 | const msg = try sema.errMsg(inst_src, "runtime coercion to union '{f}' from non-exhaustive enum", .{ | 30439 | const msg = try sema.errMsg(inst_src, "runtime coercion to union '{f}' from non-exhaustive enum", .{ |
| 30438 | union_ty.fmt(pt), | 30440 | union_ty.fmt(zcu), |
| 30439 | }); | 30441 | }); |
| 30440 | errdefer msg.destroy(sema.gpa); | 30442 | errdefer msg.destroy(sema.gpa); |
| 30441 | try sema.addDeclaredHereNote(msg, enum_ty); | 30443 | try sema.addDeclaredHereNote(msg, enum_ty); |
| ... | @@ -30463,7 +30465,7 @@ fn coerceEnumToUnion( | ... | @@ -30463,7 +30465,7 @@ fn coerceEnumToUnion( |
| 30463 | const msg = try sema.errMsg( | 30465 | const msg = try sema.errMsg( |
| 30464 | inst_src, | 30466 | inst_src, |
| 30465 | "runtime coercion from enum '{f}' to union '{f}' which has non-void fields", | 30467 | "runtime coercion from enum '{f}' to union '{f}' which has non-void fields", |
| 30466 | .{ enum_ty.fmt(pt), union_ty.fmt(pt) }, | 30468 | .{ enum_ty.fmt(zcu), union_ty.fmt(zcu) }, |
| 30467 | ); | 30469 | ); |
| 30468 | errdefer msg.destroy(sema.gpa); | 30470 | errdefer msg.destroy(sema.gpa); |
| 30469 | 30471 | ||
| ... | @@ -30479,7 +30481,7 @@ fn coerceEnumToUnion( | ... | @@ -30479,7 +30481,7 @@ fn coerceEnumToUnion( |
| 30479 | try sema.addFieldErrNote(union_ty, field_index, msg, "field '{f}' has {s} '{f}'", .{ | 30481 | try sema.addFieldErrNote(union_ty, field_index, msg, "field '{f}' has {s} '{f}'", .{ |
| 30480 | field_name.fmt(ip), | 30482 | field_name.fmt(ip), |
| 30481 | ty_description, | 30483 | ty_description, |
| 30482 | field_ty.fmt(pt), | 30484 | field_ty.fmt(zcu), |
| 30483 | }); | 30485 | }); |
| 30484 | } | 30486 | } |
| 30485 | try sema.addDeclaredHereNote(msg, union_ty); | 30487 | try sema.addDeclaredHereNote(msg, union_ty); |
| ... | @@ -31089,7 +31091,7 @@ fn analyzeLoad( | ... | @@ -31089,7 +31091,7 @@ fn analyzeLoad( |
| 31089 | const ptr_ty = sema.typeOf(ptr); | 31091 | const ptr_ty = sema.typeOf(ptr); |
| 31090 | const elem_ty = switch (ptr_ty.zigTypeTag(zcu)) { | 31092 | const elem_ty = switch (ptr_ty.zigTypeTag(zcu)) { |
| 31091 | .pointer => ptr_ty.childType(zcu), | 31093 | .pointer => ptr_ty.childType(zcu), |
| 31092 | else => return sema.fail(block, ptr_src, "expected pointer, found '{f}'", .{ptr_ty.fmt(pt)}), | 31094 | else => return sema.fail(block, ptr_src, "expected pointer, found '{f}'", .{ptr_ty.fmt(zcu)}), |
| 31093 | }; | 31095 | }; |
| 31094 | 31096 | ||
| 31095 | try sema.ensureLayoutResolved(elem_ty, src, .ptr_access); | 31097 | try sema.ensureLayoutResolved(elem_ty, src, .ptr_access); |
| ... | @@ -31100,11 +31102,11 @@ fn analyzeLoad( | ... | @@ -31100,11 +31102,11 @@ fn analyzeLoad( |
| 31100 | 31102 | ||
| 31101 | const comptime_only = switch (elem_ty.classify(zcu)) { | 31103 | const comptime_only = switch (elem_ty.classify(zcu)) { |
| 31102 | .no_possible_value => switch (elem_ty.zigTypeTag(zcu)) { | 31104 | .no_possible_value => switch (elem_ty.zigTypeTag(zcu)) { |
| 31103 | .@"opaque" => return sema.fail(block, src, "cannot load opaque type '{f}'", .{elem_ty.fmt(pt)}), | 31105 | .@"opaque" => return sema.fail(block, src, "cannot load opaque type '{f}'", .{elem_ty.fmt(zcu)}), |
| 31104 | else => { | 31106 | else => { |
| 31105 | // Loading an uninstantiable type always invokes Illegal Behavior. | 31107 | // Loading an uninstantiable type always invokes Illegal Behavior. |
| 31106 | if (block.isComptime()) { | 31108 | if (block.isComptime()) { |
| 31107 | return sema.fail(block, src, "cannot load uninstantiable type '{f}'", .{elem_ty.fmt(pt)}); | 31109 | return sema.fail(block, src, "cannot load uninstantiable type '{f}'", .{elem_ty.fmt(zcu)}); |
| 31108 | } else if (block.wantSafety()) { | 31110 | } else if (block.wantSafety()) { |
| 31109 | try sema.safetyPanic(block, src, .load_uninstantiable_type); | 31111 | try sema.safetyPanic(block, src, .load_uninstantiable_type); |
| 31110 | return .unreachable_value; | 31112 | return .unreachable_value; |
| ... | @@ -31129,9 +31131,9 @@ fn analyzeLoad( | ... | @@ -31129,9 +31131,9 @@ fn analyzeLoad( |
| 31129 | } | 31131 | } |
| 31130 | 31132 | ||
| 31131 | if (comptime_only) return sema.failWithOwnedErrorMsg(block, msg: { | 31133 | if (comptime_only) return sema.failWithOwnedErrorMsg(block, msg: { |
| 31132 | const msg = try sema.errMsg(src, "cannot load comptime-only type '{f}'", .{elem_ty.fmt(pt)}); | 31134 | const msg = try sema.errMsg(src, "cannot load comptime-only type '{f}'", .{elem_ty.fmt(zcu)}); |
| 31133 | errdefer msg.destroy(zcu.gpa); | 31135 | errdefer msg.destroy(zcu.gpa); |
| 31134 | try sema.errNote(ptr_src, msg, "pointer of type '{f}' is runtime-known", .{ptr_ty.fmt(pt)}); | 31136 | try sema.errNote(ptr_src, msg, "pointer of type '{f}' is runtime-known", .{ptr_ty.fmt(zcu)}); |
| 31135 | break :msg msg; | 31137 | break :msg msg; |
| 31136 | }); | 31138 | }); |
| 31137 | 31139 | ||
| ... | @@ -31439,7 +31441,7 @@ fn analyzeSlice( | ... | @@ -31439,7 +31441,7 @@ fn analyzeSlice( |
| 31439 | const ptr_ptr_ty = sema.typeOf(ptr_ptr); | 31441 | const ptr_ptr_ty = sema.typeOf(ptr_ptr); |
| 31440 | const ptr_ptr_child_ty = switch (ptr_ptr_ty.zigTypeTag(zcu)) { | 31442 | const ptr_ptr_child_ty = switch (ptr_ptr_ty.zigTypeTag(zcu)) { |
| 31441 | .pointer => ptr_ptr_ty.childType(zcu), | 31443 | .pointer => ptr_ptr_ty.childType(zcu), |
| 31442 | else => return sema.fail(block, ptr_src, "expected pointer, found '{f}'", .{ptr_ptr_ty.fmt(pt)}), | 31444 | else => return sema.fail(block, ptr_src, "expected pointer, found '{f}'", .{ptr_ptr_ty.fmt(zcu)}), |
| 31443 | }; | 31445 | }; |
| 31444 | 31446 | ||
| 31445 | var array_ty = ptr_ptr_child_ty; | 31447 | var array_ty = ptr_ptr_child_ty; |
| ... | @@ -31490,8 +31492,8 @@ fn analyzeSlice( | ... | @@ -31490,8 +31492,8 @@ fn analyzeSlice( |
| 31490 | msg, | 31492 | msg, |
| 31491 | "expected '{f}', found '{f}'", | 31493 | "expected '{f}', found '{f}'", |
| 31492 | .{ | 31494 | .{ |
| 31493 | Value.zero_comptime_int.fmtValueSema(pt, sema), | 31495 | Value.zero_comptime_int.fmtValueSema(sema), |
| 31494 | start_value.fmtValueSema(pt, sema), | 31496 | start_value.fmtValueSema(sema), |
| 31495 | }, | 31497 | }, |
| 31496 | ); | 31498 | ); |
| 31497 | break :msg msg; | 31499 | break :msg msg; |
| ... | @@ -31506,8 +31508,8 @@ fn analyzeSlice( | ... | @@ -31506,8 +31508,8 @@ fn analyzeSlice( |
| 31506 | msg, | 31508 | msg, |
| 31507 | "expected '{f}', found '{f}'", | 31509 | "expected '{f}', found '{f}'", |
| 31508 | .{ | 31510 | .{ |
| 31509 | Value.one_comptime_int.fmtValueSema(pt, sema), | 31511 | Value.one_comptime_int.fmtValueSema(sema), |
| 31510 | end_value.fmtValueSema(pt, sema), | 31512 | end_value.fmtValueSema(sema), |
| 31511 | }, | 31513 | }, |
| 31512 | ); | 31514 | ); |
| 31513 | break :msg msg; | 31515 | break :msg msg; |
| ... | @@ -31520,7 +31522,7 @@ fn analyzeSlice( | ... | @@ -31520,7 +31522,7 @@ fn analyzeSlice( |
| 31520 | block, | 31522 | block, |
| 31521 | end_src, | 31523 | end_src, |
| 31522 | "end index {f} out of bounds for slice of single-item pointer", | 31524 | "end index {f} out of bounds for slice of single-item pointer", |
| 31523 | .{end_value.fmtValueSema(pt, sema)}, | 31525 | .{end_value.fmtValueSema(sema)}, |
| 31524 | ); | 31526 | ); |
| 31525 | } | 31527 | } |
| 31526 | } | 31528 | } |
| ... | @@ -31566,7 +31568,7 @@ fn analyzeSlice( | ... | @@ -31566,7 +31568,7 @@ fn analyzeSlice( |
| 31566 | elem_ty = ptr_ptr_child_ty.childType(zcu); | 31568 | elem_ty = ptr_ptr_child_ty.childType(zcu); |
| 31567 | }, | 31569 | }, |
| 31568 | }, | 31570 | }, |
| 31569 | else => return sema.fail(block, src, "slice of non-array type '{f}'", .{ptr_ptr_child_ty.fmt(pt)}), | 31571 | else => return sema.fail(block, src, "slice of non-array type '{f}'", .{ptr_ptr_child_ty.fmt(zcu)}), |
| 31570 | } | 31572 | } |
| 31571 | 31573 | ||
| 31572 | try sema.ensureLayoutResolved(elem_ty, src, .ptr_access); | 31574 | try sema.ensureLayoutResolved(elem_ty, src, .ptr_access); |
| ... | @@ -31618,8 +31620,8 @@ fn analyzeSlice( | ... | @@ -31618,8 +31620,8 @@ fn analyzeSlice( |
| 31618 | end_src, | 31620 | end_src, |
| 31619 | "end index {f} out of bounds for array of length {f}{s}", | 31621 | "end index {f} out of bounds for array of length {f}{s}", |
| 31620 | .{ | 31622 | .{ |
| 31621 | end_val.fmtValueSema(pt, sema), | 31623 | end_val.fmtValueSema(sema), |
| 31622 | len_val.fmtValueSema(pt, sema), | 31624 | len_val.fmtValueSema(sema), |
| 31623 | sentinel_label, | 31625 | sentinel_label, |
| 31624 | }, | 31626 | }, |
| 31625 | ); | 31627 | ); |
| ... | @@ -31663,7 +31665,7 @@ fn analyzeSlice( | ... | @@ -31663,7 +31665,7 @@ fn analyzeSlice( |
| 31663 | end_src, | 31665 | end_src, |
| 31664 | "end index {f} out of bounds for slice of length {d}{s}", | 31666 | "end index {f} out of bounds for slice of length {d}{s}", |
| 31665 | .{ | 31667 | .{ |
| 31666 | end_val.fmtValueSema(pt, sema), | 31668 | end_val.fmtValueSema(sema), |
| 31667 | slice_val.sliceLen(zcu), | 31669 | slice_val.sliceLen(zcu), |
| 31668 | sentinel_label, | 31670 | sentinel_label, |
| 31669 | }, | 31671 | }, |
| ... | @@ -31714,9 +31716,9 @@ fn analyzeSlice( | ... | @@ -31714,9 +31716,9 @@ fn analyzeSlice( |
| 31714 | const msg = try sema.errMsg(sentinel_src, "sentinel-terminated slicing of many-item pointer must match existing sentinel", .{}); | 31716 | const msg = try sema.errMsg(sentinel_src, "sentinel-terminated slicing of many-item pointer must match existing sentinel", .{}); |
| 31715 | errdefer msg.destroy(sema.gpa); | 31717 | errdefer msg.destroy(sema.gpa); |
| 31716 | if (ptr_sentinel) |current| { | 31718 | if (ptr_sentinel) |current| { |
| 31717 | try sema.errNote(sentinel_src, msg, "expected sentinel '{f}', found '{f}'", .{ current.fmtValue(pt), provided.fmtValue(pt) }); | 31719 | try sema.errNote(sentinel_src, msg, "expected sentinel '{f}', found '{f}'", .{ current.fmtValue(zcu), provided.fmtValue(zcu) }); |
| 31718 | } else { | 31720 | } else { |
| 31719 | try sema.errNote(ptr_src, msg, "type '{f}' does not have a sentinel", .{slice_ty.fmt(pt)}); | 31721 | try sema.errNote(ptr_src, msg, "type '{f}' does not have a sentinel", .{slice_ty.fmt(zcu)}); |
| 31720 | } | 31722 | } |
| 31721 | try sema.errNote(src, msg, "use @ptrCast to cast pointer sentinel", .{}); | 31723 | try sema.errNote(src, msg, "use @ptrCast to cast pointer sentinel", .{}); |
| 31722 | break :msg msg; | 31724 | break :msg msg; |
| ... | @@ -31760,8 +31762,8 @@ fn analyzeSlice( | ... | @@ -31760,8 +31762,8 @@ fn analyzeSlice( |
| 31760 | start_src, | 31762 | start_src, |
| 31761 | "start index {f} is larger than end index {f}", | 31763 | "start index {f} is larger than end index {f}", |
| 31762 | .{ | 31764 | .{ |
| 31763 | start_val.fmtValueSema(pt, sema), | 31765 | start_val.fmtValueSema(sema), |
| 31764 | end_val.fmtValueSema(pt, sema), | 31766 | end_val.fmtValueSema(sema), |
| 31765 | }, | 31767 | }, |
| 31766 | ); | 31768 | ); |
| 31767 | } | 31769 | } |
| ... | @@ -31783,13 +31785,13 @@ fn analyzeSlice( | ... | @@ -31783,13 +31785,13 @@ fn analyzeSlice( |
| 31783 | block, | 31785 | block, |
| 31784 | src, | 31786 | src, |
| 31785 | "comptime dereference requires '{f}' to have a well-defined layout", | 31787 | "comptime dereference requires '{f}' to have a well-defined layout", |
| 31786 | .{ty.fmt(pt)}, | 31788 | .{ty.fmt(zcu)}, |
| 31787 | ), | 31789 | ), |
| 31788 | .out_of_bounds => |ty| return sema.fail( | 31790 | .out_of_bounds => |ty| return sema.fail( |
| 31789 | block, | 31791 | block, |
| 31790 | end_src, | 31792 | end_src, |
| 31791 | "slice end index {d} exceeds bounds of containing decl of type '{f}'", | 31793 | "slice end index {d} exceeds bounds of containing decl of type '{f}'", |
| 31792 | .{ end_int, ty.fmt(pt) }, | 31794 | .{ end_int, ty.fmt(zcu) }, |
| 31793 | ), | 31795 | ), |
| 31794 | }; | 31796 | }; |
| 31795 | 31797 | ||
| ... | @@ -31798,8 +31800,8 @@ fn analyzeSlice( | ... | @@ -31798,8 +31800,8 @@ fn analyzeSlice( |
| 31798 | const msg = try sema.errMsg(src, "value in memory does not match slice sentinel", .{}); | 31800 | const msg = try sema.errMsg(src, "value in memory does not match slice sentinel", .{}); |
| 31799 | errdefer msg.destroy(sema.gpa); | 31801 | errdefer msg.destroy(sema.gpa); |
| 31800 | try sema.errNote(src, msg, "expected '{f}', found '{f}'", .{ | 31802 | try sema.errNote(src, msg, "expected '{f}', found '{f}'", .{ |
| 31801 | expected_sentinel.fmtValueSema(pt, sema), | 31803 | expected_sentinel.fmtValueSema(sema), |
| 31802 | actual_sentinel.fmtValueSema(pt, sema), | 31804 | actual_sentinel.fmtValueSema(sema), |
| 31803 | }); | 31805 | }); |
| 31804 | 31806 | ||
| 31805 | break :msg msg; | 31807 | break :msg msg; |
| ... | @@ -32611,7 +32613,7 @@ const PeerResolveResult = union(enum) { | ... | @@ -32611,7 +32613,7 @@ const PeerResolveResult = union(enum) { |
| 32611 | instructions: []const Air.Inst.Ref, | 32613 | instructions: []const Air.Inst.Ref, |
| 32612 | candidate_srcs: PeerTypeCandidateSrc, | 32614 | candidate_srcs: PeerTypeCandidateSrc, |
| 32613 | ) !*Zcu.ErrorMsg { | 32615 | ) !*Zcu.ErrorMsg { |
| 32614 | const pt = sema.pt; | 32616 | const zcu = sema.pt.zcu; |
| 32615 | 32617 | ||
| 32616 | var opt_msg: ?*Zcu.ErrorMsg = null; | 32618 | var opt_msg: ?*Zcu.ErrorMsg = null; |
| 32617 | errdefer if (opt_msg) |msg| msg.destroy(sema.gpa); | 32619 | errdefer if (opt_msg) |msg| msg.destroy(sema.gpa); |
| ... | @@ -32637,7 +32639,7 @@ const PeerResolveResult = union(enum) { | ... | @@ -32637,7 +32639,7 @@ const PeerResolveResult = union(enum) { |
| 32637 | }, | 32639 | }, |
| 32638 | .field_error => |field_error| { | 32640 | .field_error => |field_error| { |
| 32639 | const fmt = "struct field '{f}' has conflicting types"; | 32641 | const fmt = "struct field '{f}' has conflicting types"; |
| 32640 | const args = .{field_error.field_name.fmt(&pt.zcu.intern_pool)}; | 32642 | const args = .{field_error.field_name.fmt(&zcu.intern_pool)}; |
| 32641 | if (opt_msg) |msg| { | 32643 | if (opt_msg) |msg| { |
| 32642 | try sema.errNote(src, msg, fmt, args); | 32644 | try sema.errNote(src, msg, fmt, args); |
| 32643 | } else { | 32645 | } else { |
| ... | @@ -32669,8 +32671,8 @@ const PeerResolveResult = union(enum) { | ... | @@ -32669,8 +32671,8 @@ const PeerResolveResult = union(enum) { |
| 32669 | 32671 | ||
| 32670 | const fmt = "incompatible types: '{f}' and '{f}'"; | 32672 | const fmt = "incompatible types: '{f}' and '{f}'"; |
| 32671 | const args = .{ | 32673 | const args = .{ |
| 32672 | conflict_tys[0].fmt(pt), | 32674 | conflict_tys[0].fmt(zcu), |
| 32673 | conflict_tys[1].fmt(pt), | 32675 | conflict_tys[1].fmt(zcu), |
| 32674 | }; | 32676 | }; |
| 32675 | const msg = if (opt_msg) |msg| msg: { | 32677 | const msg = if (opt_msg) |msg| msg: { |
| 32676 | try sema.errNote(src, msg, fmt, args); | 32678 | try sema.errNote(src, msg, fmt, args); |
| ... | @@ -32681,8 +32683,8 @@ const PeerResolveResult = union(enum) { | ... | @@ -32681,8 +32683,8 @@ const PeerResolveResult = union(enum) { |
| 32681 | break :msg msg; | 32683 | break :msg msg; |
| 32682 | }; | 32684 | }; |
| 32683 | 32685 | ||
| 32684 | if (conflict_srcs[0]) |src_loc| try sema.errNote(src_loc, msg, "type '{f}' here", .{conflict_tys[0].fmt(pt)}); | 32686 | if (conflict_srcs[0]) |src_loc| try sema.errNote(src_loc, msg, "type '{f}' here", .{conflict_tys[0].fmt(zcu)}); |
| 32685 | if (conflict_srcs[1]) |src_loc| try sema.errNote(src_loc, msg, "type '{f}' here", .{conflict_tys[1].fmt(pt)}); | 32687 | if (conflict_srcs[1]) |src_loc| try sema.errNote(src_loc, msg, "type '{f}' here", .{conflict_tys[1].fmt(zcu)}); |
| 32686 | 32688 | ||
| 32687 | // No child error | 32689 | // No child error |
| 32688 | break; | 32690 | break; |
| ... | @@ -33911,10 +33913,10 @@ fn typeIsArrayLike(sema: *Sema, ty: Type) ?ArrayLike { | ... | @@ -33911,10 +33913,10 @@ fn typeIsArrayLike(sema: *Sema, ty: Type) ?ArrayLike { |
| 33911 | } | 33913 | } |
| 33912 | 33914 | ||
| 33913 | fn checkIndexable(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) !void { | 33915 | fn checkIndexable(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) !void { |
| 33914 | const pt = sema.pt; | 33916 | const zcu = sema.pt.zcu; |
| 33915 | if (!ty.isIndexable(pt.zcu)) { | 33917 | if (!ty.isIndexable(zcu)) { |
| 33916 | const msg = msg: { | 33918 | const msg = msg: { |
| 33917 | const msg = try sema.errMsg(src, "type '{f}' does not support indexing", .{ty.fmt(pt)}); | 33919 | const msg = try sema.errMsg(src, "type '{f}' does not support indexing", .{ty.fmt(zcu)}); |
| 33918 | errdefer msg.destroy(sema.gpa); | 33920 | errdefer msg.destroy(sema.gpa); |
| 33919 | try sema.errNote(src, msg, "operand must be an array, slice, tuple, or vector", .{}); | 33921 | try sema.errNote(src, msg, "operand must be an array, slice, tuple, or vector", .{}); |
| 33920 | try sema.addDeclaredHereNote(msg, ty); | 33922 | try sema.addDeclaredHereNote(msg, ty); |
| ... | @@ -33939,7 +33941,7 @@ fn checkMemOperand(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) !void | ... | @@ -33939,7 +33941,7 @@ fn checkMemOperand(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) !void |
| 33939 | } | 33941 | } |
| 33940 | } | 33942 | } |
| 33941 | const msg = msg: { | 33943 | const msg = msg: { |
| 33942 | const msg = try sema.errMsg(src, "type '{f}' is not an indexable pointer", .{ty.fmt(pt)}); | 33944 | const msg = try sema.errMsg(src, "type '{f}' is not an indexable pointer", .{ty.fmt(zcu)}); |
| 33943 | errdefer msg.destroy(sema.gpa); | 33945 | errdefer msg.destroy(sema.gpa); |
| 33944 | try sema.errNote(src, msg, "operand must be a slice, a many pointer or a pointer to an array", .{}); | 33946 | try sema.errNote(src, msg, "operand must be a slice, a many pointer or a pointer to an array", .{}); |
| 33945 | break :msg msg; | 33947 | break :msg msg; |
| ... | @@ -34222,8 +34224,9 @@ pub fn analyzeAsAddressSpace( | ... | @@ -34222,8 +34224,9 @@ pub fn analyzeAsAddressSpace( |
| 34222 | /// Asserts the value is a pointer and dereferences it. | 34224 | /// Asserts the value is a pointer and dereferences it. |
| 34223 | /// Returns `null` if the pointer contents cannot be loaded at comptime. | 34225 | /// Returns `null` if the pointer contents cannot be loaded at comptime. |
| 34224 | fn pointerDeref(sema: *Sema, block: *Block, src: LazySrcLoc, ptr_val: Value, ptr_ty: Type) CompileError!?Value { | 34226 | fn pointerDeref(sema: *Sema, block: *Block, src: LazySrcLoc, ptr_val: Value, ptr_ty: Type) CompileError!?Value { |
| 34225 | // TODO: audit use sites to eliminate this coercion | ||
| 34226 | const pt = sema.pt; | 34227 | const pt = sema.pt; |
| 34228 | const zcu = pt.zcu; | ||
| 34229 | // TODO: audit use sites to eliminate this coercion | ||
| 34227 | const coerced_ptr_val = try pt.getCoerced(ptr_val, ptr_ty); | 34230 | const coerced_ptr_val = try pt.getCoerced(ptr_val, ptr_ty); |
| 34228 | switch (try sema.pointerDerefExtra(block, src, coerced_ptr_val)) { | 34231 | switch (try sema.pointerDerefExtra(block, src, coerced_ptr_val)) { |
| 34229 | .runtime_load => return null, | 34232 | .runtime_load => return null, |
| ... | @@ -34232,13 +34235,13 @@ fn pointerDeref(sema: *Sema, block: *Block, src: LazySrcLoc, ptr_val: Value, ptr | ... | @@ -34232,13 +34235,13 @@ fn pointerDeref(sema: *Sema, block: *Block, src: LazySrcLoc, ptr_val: Value, ptr |
| 34232 | block, | 34235 | block, |
| 34233 | src, | 34236 | src, |
| 34234 | "comptime dereference requires '{f}' to have a well-defined layout", | 34237 | "comptime dereference requires '{f}' to have a well-defined layout", |
| 34235 | .{ty.fmt(pt)}, | 34238 | .{ty.fmt(zcu)}, |
| 34236 | ), | 34239 | ), |
| 34237 | .out_of_bounds => |ty| return sema.fail( | 34240 | .out_of_bounds => |ty| return sema.fail( |
| 34238 | block, | 34241 | block, |
| 34239 | src, | 34242 | src, |
| 34240 | "dereference of '{f}' exceeds bounds of containing decl of type '{f}'", | 34243 | "dereference of '{f}' exceeds bounds of containing decl of type '{f}'", |
| 34241 | .{ ptr_ty.fmt(pt), ty.fmt(pt) }, | 34244 | .{ ptr_ty.fmt(zcu), ty.fmt(zcu) }, |
| 34242 | ), | 34245 | ), |
| 34243 | } | 34246 | } |
| 34244 | } | 34247 | } |
| ... | @@ -34361,12 +34364,12 @@ fn intFromFloatScalar( | ... | @@ -34361,12 +34364,12 @@ fn intFromFloatScalar( |
| 34361 | 34364 | ||
| 34362 | if (std.math.isNan(float)) { | 34365 | if (std.math.isNan(float)) { |
| 34363 | return sema.fail(block, src, "float value NaN cannot be stored in integer type '{f}'", .{ | 34366 | return sema.fail(block, src, "float value NaN cannot be stored in integer type '{f}'", .{ |
| 34364 | int_ty.fmt(pt), | 34367 | int_ty.fmt(zcu), |
| 34365 | }); | 34368 | }); |
| 34366 | } | 34369 | } |
| 34367 | if (std.math.isInf(float)) { | 34370 | if (std.math.isInf(float)) { |
| 34368 | return sema.fail(block, src, "float value Inf cannot be stored in integer type '{f}'", .{ | 34371 | return sema.fail(block, src, "float value Inf cannot be stored in integer type '{f}'", .{ |
| 34369 | int_ty.fmt(pt), | 34372 | int_ty.fmt(zcu), |
| 34370 | }); | 34373 | }); |
| 34371 | } | 34374 | } |
| 34372 | 34375 | ||
| ... | @@ -34381,7 +34384,7 @@ fn intFromFloatScalar( | ... | @@ -34381,7 +34384,7 @@ fn intFromFloatScalar( |
| 34381 | block, | 34384 | block, |
| 34382 | src, | 34385 | src, |
| 34383 | "fractional component prevents float value '{f}' from coercion to type '{f}'", | 34386 | "fractional component prevents float value '{f}' from coercion to type '{f}'", |
| 34384 | .{ val.fmtValueSema(pt, sema), int_ty.fmt(pt) }, | 34387 | .{ val.fmtValueSema(sema), int_ty.fmt(zcu) }, |
| 34385 | ), | 34388 | ), |
| 34386 | .truncate, .round, .floor, .ceil => {}, | 34389 | .truncate, .round, .floor, .ceil => {}, |
| 34387 | }, | 34390 | }, |
| ... | @@ -34393,7 +34396,7 @@ fn intFromFloatScalar( | ... | @@ -34393,7 +34396,7 @@ fn intFromFloatScalar( |
| 34393 | const int_info = int_ty.intInfo(zcu); | 34396 | const int_info = int_ty.intInfo(zcu); |
| 34394 | if (!big_int.toConst().fitsInTwosComp(int_info.signedness, int_info.bits)) { | 34397 | if (!big_int.toConst().fitsInTwosComp(int_info.signedness, int_info.bits)) { |
| 34395 | return sema.fail(block, src, "float value '{f}' cannot be stored in integer type '{f}'", .{ | 34398 | return sema.fail(block, src, "float value '{f}' cannot be stored in integer type '{f}'", .{ |
| 34396 | val.fmtValueSema(pt, sema), int_ty.fmt(pt), | 34399 | val.fmtValueSema(sema), int_ty.fmt(zcu), |
| 34397 | }); | 34400 | }); |
| 34398 | } | 34401 | } |
| 34399 | return pt.getCoerced(cti_result, int_ty); | 34402 | return pt.getCoerced(cti_result, int_ty); |
| ... | @@ -34639,7 +34642,7 @@ fn notePathToComptimeAllocPtr( | ... | @@ -34639,7 +34642,7 @@ fn notePathToComptimeAllocPtr( |
| 34639 | else => {}, // there will be another stage | 34642 | else => {}, // there will be another stage |
| 34640 | } | 34643 | } |
| 34641 | 34644 | ||
| 34642 | const derivation = try comptime_ptr.pointerDerivation(arena, pt, sema); | 34645 | const derivation = try comptime_ptr.pointerDerivation(arena, zcu, sema); |
| 34643 | 34646 | ||
| 34644 | var second_path_aw: std.Io.Writer.Allocating = .init(arena); | 34647 | var second_path_aw: std.Io.Writer.Allocating = .init(arena); |
| 34645 | defer second_path_aw.deinit(); | 34648 | defer second_path_aw.deinit(); |
| ... | @@ -34647,19 +34650,19 @@ fn notePathToComptimeAllocPtr( | ... | @@ -34647,19 +34650,19 @@ fn notePathToComptimeAllocPtr( |
| 34647 | const deriv_start = @import("print_value.zig").printPtrDerivation( | 34650 | const deriv_start = @import("print_value.zig").printPtrDerivation( |
| 34648 | derivation, | 34651 | derivation, |
| 34649 | &second_path_aw.writer, | 34652 | &second_path_aw.writer, |
| 34650 | pt, | 34653 | zcu, |
| 34651 | .lvalue, | 34654 | .lvalue, |
| 34652 | .{ .str = inter_name }, | 34655 | .{ .str = inter_name }, |
| 34653 | 20, | 34656 | 20, |
| 34654 | ) catch return error.OutOfMemory; | 34657 | ) catch return error.OutOfMemory; |
| 34655 | 34658 | ||
| 34656 | switch (deriv_start) { | 34659 | switch (deriv_start.addr) { |
| 34657 | .int, .nav_ptr => unreachable, | 34660 | .int, .nav => unreachable, |
| 34658 | .uav_ptr => |uav| { | 34661 | .uav => |uav| { |
| 34659 | try sema.errNote(src, msg, "'{s}' points to '{s}', where", .{ first_path.items, second_path_aw.written() }); | 34662 | try sema.errNote(src, msg, "'{s}' points to '{s}', where", .{ first_path.items, second_path_aw.written() }); |
| 34660 | return .{ .new_val = .fromInterned(uav.val) }; | 34663 | return .{ .new_val = uav }; |
| 34661 | }, | 34664 | }, |
| 34662 | .comptime_alloc_ptr => |cta_info| { | 34665 | .comptime_alloc => |cta_info| { |
| 34663 | try sema.errNote(src, msg, "'{s}' points to '{s}', where", .{ first_path.items, second_path_aw.written() }); | 34666 | try sema.errNote(src, msg, "'{s}' points to '{s}', where", .{ first_path.items, second_path_aw.written() }); |
| 34664 | const cta = sema.getComptimeAlloc(cta_info.idx); | 34667 | const cta = sema.getComptimeAlloc(cta_info.idx); |
| 34665 | if (cta.is_const) { | 34668 | if (cta.is_const) { |
| ... | @@ -34669,15 +34672,15 @@ fn notePathToComptimeAllocPtr( | ... | @@ -34669,15 +34672,15 @@ fn notePathToComptimeAllocPtr( |
| 34669 | return .done; | 34672 | return .done; |
| 34670 | } | 34673 | } |
| 34671 | }, | 34674 | }, |
| 34672 | .comptime_field_ptr => { | 34675 | .comptime_field => { |
| 34673 | try sema.errNote(src, msg, "'{s}' points to '{s}', where", .{ first_path.items, second_path_aw.written() }); | 34676 | try sema.errNote(src, msg, "'{s}' points to '{s}', where", .{ first_path.items, second_path_aw.written() }); |
| 34674 | try sema.errNote(src, msg, "'{s}' is a comptime field", .{inter_name}); | 34677 | try sema.errNote(src, msg, "'{s}' is a comptime field", .{inter_name}); |
| 34675 | return .done; | 34678 | return .done; |
| 34676 | }, | 34679 | }, |
| 34677 | .eu_payload_ptr, | 34680 | .eu_payload, |
| 34678 | .opt_payload_ptr, | 34681 | .opt_payload, |
| 34679 | .field_ptr, | 34682 | .field, |
| 34680 | .elem_ptr, | 34683 | .elem, |
| 34681 | .offset_and_cast, | 34684 | .offset_and_cast, |
| 34682 | => unreachable, | 34685 | => unreachable, |
| 34683 | } | 34686 | } |
| ... | @@ -35293,7 +35296,7 @@ pub fn setTypeName( | ... | @@ -35293,7 +35296,7 @@ pub fn setTypeName( |
| 35293 | // some tooling may not support very long symbol names. | 35296 | // some tooling may not support very long symbol names. |
| 35294 | w.print("{f}", .{Value.fmtValueSemaFull(.{ | 35297 | w.print("{f}", .{Value.fmtValueSemaFull(.{ |
| 35295 | .val = arg_val, | 35298 | .val = arg_val, |
| 35296 | .pt = pt, | 35299 | .zcu = zcu, |
| 35297 | .opt_sema = sema, | 35300 | .opt_sema = sema, |
| 35298 | .depth = 1, | 35301 | .depth = 1, |
| 35299 | })}) catch return error.OutOfMemory; | 35302 | })}) catch return error.OutOfMemory; |
src/Sema/LowerZon.zig+21-19| ... | @@ -321,10 +321,11 @@ fn failUnsupportedResultType( | ... | @@ -321,10 +321,11 @@ fn failUnsupportedResultType( |
| 321 | ) Zcu.SemaError { | 321 | ) Zcu.SemaError { |
| 322 | @branchHint(.cold); | 322 | @branchHint(.cold); |
| 323 | const sema = self.sema; | 323 | const sema = self.sema; |
| 324 | const gpa = sema.gpa; | ||
| 325 | const pt = sema.pt; | 324 | const pt = sema.pt; |
| 325 | const zcu = pt.zcu; | ||
| 326 | const gpa = zcu.comp.gpa; | ||
| 326 | return sema.failWithOwnedErrorMsg(self.block, msg: { | 327 | return sema.failWithOwnedErrorMsg(self.block, msg: { |
| 327 | const msg = try sema.errMsg(self.import_src, "type '{f}' is not available in ZON", .{ty.fmt(pt)}); | 328 | const msg = try sema.errMsg(self.import_src, "type '{f}' is not available in ZON", .{ty.fmt(zcu)}); |
| 328 | errdefer msg.destroy(gpa); | 329 | errdefer msg.destroy(gpa); |
| 329 | if (opt_note) |n| try sema.errNote(self.import_src, msg, "{s}", .{n}); | 330 | if (opt_note) |n| try sema.errNote(self.import_src, msg, "{s}", .{n}); |
| 330 | break :msg msg; | 331 | break :msg msg; |
| ... | @@ -344,9 +345,9 @@ fn fail( | ... | @@ -344,9 +345,9 @@ fn fail( |
| 344 | } | 345 | } |
| 345 | 346 | ||
| 346 | fn lowerExprKnownResTy(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) CompileError!InternPool.Index { | 347 | fn lowerExprKnownResTy(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) CompileError!InternPool.Index { |
| 347 | const pt = self.sema.pt; | 348 | const zcu = self.sema.pt.zcu; |
| 348 | return self.lowerExprKnownResTyInner(node, res_ty) catch |err| switch (err) { | 349 | return self.lowerExprKnownResTyInner(node, res_ty) catch |err| switch (err) { |
| 349 | error.WrongType => return self.fail(node, "expected type '{f}'", .{res_ty.fmt(pt)}), | 350 | error.WrongType => return self.fail(node, "expected type '{f}'", .{res_ty.fmt(zcu)}), |
| 350 | else => |e| return e, | 351 | else => |e| return e, |
| 351 | }; | 352 | }; |
| 352 | } | 353 | } |
| ... | @@ -357,20 +358,21 @@ fn lowerExprKnownResTyInner( | ... | @@ -357,20 +358,21 @@ fn lowerExprKnownResTyInner( |
| 357 | res_ty: Type, | 358 | res_ty: Type, |
| 358 | ) (CompileError || error{WrongType})!InternPool.Index { | 359 | ) (CompileError || error{WrongType})!InternPool.Index { |
| 359 | const pt = self.sema.pt; | 360 | const pt = self.sema.pt; |
| 360 | switch (res_ty.zigTypeTag(pt.zcu)) { | 361 | const zcu = pt.zcu; |
| 362 | switch (res_ty.zigTypeTag(zcu)) { | ||
| 361 | .optional => return pt.intern(.{ | 363 | .optional => return pt.intern(.{ |
| 362 | .opt = .{ | 364 | .opt = .{ |
| 363 | .ty = res_ty.toIntern(), | 365 | .ty = res_ty.toIntern(), |
| 364 | .val = if (node.get(self.zoir.*) == .null) b: { | 366 | .val = if (node.get(self.zoir.*) == .null) b: { |
| 365 | break :b .none; | 367 | break :b .none; |
| 366 | } else b: { | 368 | } else b: { |
| 367 | const child_type = res_ty.optionalChild(pt.zcu); | 369 | const child_type = res_ty.optionalChild(zcu); |
| 368 | break :b try self.lowerExprKnownResTyInner(node, child_type); | 370 | break :b try self.lowerExprKnownResTyInner(node, child_type); |
| 369 | }, | 371 | }, |
| 370 | }, | 372 | }, |
| 371 | }), | 373 | }), |
| 372 | .pointer => { | 374 | .pointer => { |
| 373 | const ptr_info = res_ty.ptrInfo(pt.zcu); | 375 | const ptr_info = res_ty.ptrInfo(zcu); |
| 374 | switch (ptr_info.flags.size) { | 376 | switch (ptr_info.flags.size) { |
| 375 | .one => return pt.intern(.{ .ptr = .{ | 377 | .one => return pt.intern(.{ .ptr = .{ |
| 376 | .ty = res_ty.toIntern(), | 378 | .ty = res_ty.toIntern(), |
| ... | @@ -411,7 +413,7 @@ fn lowerExprKnownResTyInner( | ... | @@ -411,7 +413,7 @@ fn lowerExprKnownResTyInner( |
| 411 | .frame, | 413 | .frame, |
| 412 | .@"anyframe", | 414 | .@"anyframe", |
| 413 | .void, | 415 | .void, |
| 414 | => return self.fail(node, "type '{f}' not available in ZON", .{res_ty.fmt(pt)}), | 416 | => return self.fail(node, "type '{f}' not available in ZON", .{res_ty.fmt(zcu)}), |
| 415 | } | 417 | } |
| 416 | } | 418 | } |
| 417 | 419 | ||
| ... | @@ -442,7 +444,7 @@ fn lowerInt( | ... | @@ -442,7 +444,7 @@ fn lowerInt( |
| 442 | if (lhs_info.signedness == .unsigned and rhs < 0) return self.fail( | 444 | if (lhs_info.signedness == .unsigned and rhs < 0) return self.fail( |
| 443 | node, | 445 | node, |
| 444 | "type '{f}' cannot represent integer value '{d}'", | 446 | "type '{f}' cannot represent integer value '{d}'", |
| 445 | .{ res_ty.fmt(self.sema.pt), rhs }, | 447 | .{ res_ty.fmt(self.sema.pt.zcu), rhs }, |
| 446 | ); | 448 | ); |
| 447 | 449 | ||
| 448 | // If lhs has less than the 32 bits rhs can hold, we need to check the max and | 450 | // If lhs has less than the 32 bits rhs can hold, we need to check the max and |
| ... | @@ -458,7 +460,7 @@ fn lowerInt( | ... | @@ -458,7 +460,7 @@ fn lowerInt( |
| 458 | return self.fail( | 460 | return self.fail( |
| 459 | node, | 461 | node, |
| 460 | "type '{f}' cannot represent integer value '{d}'", | 462 | "type '{f}' cannot represent integer value '{d}'", |
| 461 | .{ res_ty.fmt(self.sema.pt), rhs }, | 463 | .{ res_ty.fmt(self.sema.pt.zcu), rhs }, |
| 462 | ); | 464 | ); |
| 463 | } | 465 | } |
| 464 | } | 466 | } |
| ... | @@ -476,7 +478,7 @@ fn lowerInt( | ... | @@ -476,7 +478,7 @@ fn lowerInt( |
| 476 | return self.fail( | 478 | return self.fail( |
| 477 | node, | 479 | node, |
| 478 | "type '{f}' cannot represent integer value '{d}'", | 480 | "type '{f}' cannot represent integer value '{d}'", |
| 479 | .{ res_ty.fmt(self.sema.pt), val }, | 481 | .{ res_ty.fmt(self.sema.pt.zcu), val }, |
| 480 | ); | 482 | ); |
| 481 | } | 483 | } |
| 482 | } | 484 | } |
| ... | @@ -497,7 +499,7 @@ fn lowerInt( | ... | @@ -497,7 +499,7 @@ fn lowerInt( |
| 497 | .inexact => return self.fail( | 499 | .inexact => return self.fail( |
| 498 | node, | 500 | node, |
| 499 | "fractional component prevents float value '{d}' from coercion to type '{f}'", | 501 | "fractional component prevents float value '{d}' from coercion to type '{f}'", |
| 500 | .{ val, res_ty.fmt(self.sema.pt) }, | 502 | .{ val, res_ty.fmt(self.sema.pt.zcu) }, |
| 501 | ), | 503 | ), |
| 502 | .exact => {}, | 504 | .exact => {}, |
| 503 | } | 505 | } |
| ... | @@ -508,7 +510,7 @@ fn lowerInt( | ... | @@ -508,7 +510,7 @@ fn lowerInt( |
| 508 | return self.fail( | 510 | return self.fail( |
| 509 | node, | 511 | node, |
| 510 | "type '{f}' cannot represent integer value '{d}'", | 512 | "type '{f}' cannot represent integer value '{d}'", |
| 511 | .{ res_ty.fmt(self.sema.pt), val }, | 513 | .{ res_ty.fmt(self.sema.pt.zcu), val }, |
| 512 | ); | 514 | ); |
| 513 | } | 515 | } |
| 514 | 516 | ||
| ... | @@ -530,7 +532,7 @@ fn lowerInt( | ... | @@ -530,7 +532,7 @@ fn lowerInt( |
| 530 | return self.fail( | 532 | return self.fail( |
| 531 | node, | 533 | node, |
| 532 | "type '{f}' cannot represent integer value '{d}'", | 534 | "type '{f}' cannot represent integer value '{d}'", |
| 533 | .{ res_ty.fmt(self.sema.pt), val }, | 535 | .{ res_ty.fmt(self.sema.pt.zcu), val }, |
| 534 | ); | 536 | ); |
| 535 | } | 537 | } |
| 536 | } | 538 | } |
| ... | @@ -564,7 +566,7 @@ fn lowerFloat( | ... | @@ -564,7 +566,7 @@ fn lowerFloat( |
| 564 | if (res_ty.toIntern() == .comptime_float_type) return self.fail( | 566 | if (res_ty.toIntern() == .comptime_float_type) return self.fail( |
| 565 | node, | 567 | node, |
| 566 | "expected type '{f}'", | 568 | "expected type '{f}'", |
| 567 | .{res_ty.fmt(self.sema.pt)}, | 569 | .{res_ty.fmt(self.sema.pt.zcu)}, |
| 568 | ); | 570 | ); |
| 569 | break :b try self.sema.pt.floatValue(res_ty, std.math.inf(f128)); | 571 | break :b try self.sema.pt.floatValue(res_ty, std.math.inf(f128)); |
| 570 | }, | 572 | }, |
| ... | @@ -572,7 +574,7 @@ fn lowerFloat( | ... | @@ -572,7 +574,7 @@ fn lowerFloat( |
| 572 | if (res_ty.toIntern() == .comptime_float_type) return self.fail( | 574 | if (res_ty.toIntern() == .comptime_float_type) return self.fail( |
| 573 | node, | 575 | node, |
| 574 | "expected type '{f}'", | 576 | "expected type '{f}'", |
| 575 | .{res_ty.fmt(self.sema.pt)}, | 577 | .{res_ty.fmt(self.sema.pt.zcu)}, |
| 576 | ); | 578 | ); |
| 577 | break :b try self.sema.pt.floatValue(res_ty, -std.math.inf(f128)); | 579 | break :b try self.sema.pt.floatValue(res_ty, -std.math.inf(f128)); |
| 578 | }, | 580 | }, |
| ... | @@ -580,7 +582,7 @@ fn lowerFloat( | ... | @@ -580,7 +582,7 @@ fn lowerFloat( |
| 580 | if (res_ty.toIntern() == .comptime_float_type) return self.fail( | 582 | if (res_ty.toIntern() == .comptime_float_type) return self.fail( |
| 581 | node, | 583 | node, |
| 582 | "expected type '{f}'", | 584 | "expected type '{f}'", |
| 583 | .{res_ty.fmt(self.sema.pt)}, | 585 | .{res_ty.fmt(self.sema.pt.zcu)}, |
| 584 | ); | 586 | ); |
| 585 | break :b try self.sema.pt.floatValue(res_ty, std.math.nan(f128)); | 587 | break :b try self.sema.pt.floatValue(res_ty, std.math.nan(f128)); |
| 586 | }, | 588 | }, |
| ... | @@ -645,7 +647,7 @@ fn lowerEnum(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool.I | ... | @@ -645,7 +647,7 @@ fn lowerEnum(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool.I |
| 645 | node, | 647 | node, |
| 646 | "enum {f} has no member named '{f}'", | 648 | "enum {f} has no member named '{f}'", |
| 647 | .{ | 649 | .{ |
| 648 | res_ty.fmt(self.sema.pt), | 650 | res_ty.fmt(self.sema.pt.zcu), |
| 649 | std.zig.fmtId(field_name.get(self.zoir.*)), | 651 | std.zig.fmtId(field_name.get(self.zoir.*)), |
| 650 | }, | 652 | }, |
| 651 | ); | 653 | ); |
| ... | @@ -939,7 +941,7 @@ fn lowerUnion(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool. | ... | @@ -939,7 +941,7 @@ fn lowerUnion(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool. |
| 939 | .struct_literal => b: { | 941 | .struct_literal => b: { |
| 940 | const fields: @FieldType(Zoir.Node, "struct_literal") = switch (node.get(self.zoir.*)) { | 942 | const fields: @FieldType(Zoir.Node, "struct_literal") = switch (node.get(self.zoir.*)) { |
| 941 | .struct_literal => |fields| fields, | 943 | .struct_literal => |fields| fields, |
| 942 | else => return self.fail(node, "expected type '{f}'", .{res_ty.fmt(self.sema.pt)}), | 944 | else => return self.fail(node, "expected type '{f}'", .{res_ty.fmt(self.sema.pt.zcu)}), |
| 943 | }; | 945 | }; |
| 944 | if (fields.names.len != 1) { | 946 | if (fields.names.len != 1) { |
| 945 | return error.WrongType; | 947 | return error.WrongType; |
src/Sema/type_resolution.zig+25-25| ... | @@ -317,7 +317,7 @@ pub fn resolveStructLayout(sema: *Sema, struct_ty: Type) CompileError!void { | ... | @@ -317,7 +317,7 @@ pub fn resolveStructLayout(sema: *Sema, struct_ty: Type) CompileError!void { |
| 317 | try sema.ensureLayoutResolved(field_ty, field_ty_src, .field); | 317 | try sema.ensureLayoutResolved(field_ty, field_ty_src, .field); |
| 318 | if (field_ty.zigTypeTag(zcu) == .@"opaque") { | 318 | if (field_ty.zigTypeTag(zcu) == .@"opaque") { |
| 319 | return sema.failWithOwnedErrorMsg(&block, msg: { | 319 | return sema.failWithOwnedErrorMsg(&block, msg: { |
| 320 | const msg = try sema.errMsg(field_ty_src, "cannot directly embed opaque type '{f}' in struct", .{field_ty.fmt(pt)}); | 320 | const msg = try sema.errMsg(field_ty_src, "cannot directly embed opaque type '{f}' in struct", .{field_ty.fmt(zcu)}); |
| 321 | errdefer msg.destroy(gpa); | 321 | errdefer msg.destroy(gpa); |
| 322 | try sema.errNote(field_ty_src, msg, "opaque types have unknown size", .{}); | 322 | try sema.errNote(field_ty_src, msg, "opaque types have unknown size", .{}); |
| 323 | try sema.addDeclaredHereNote(msg, field_ty); | 323 | try sema.addDeclaredHereNote(msg, field_ty); |
| ... | @@ -328,7 +328,7 @@ pub fn resolveStructLayout(sema: *Sema, struct_ty: Type) CompileError!void { | ... | @@ -328,7 +328,7 @@ pub fn resolveStructLayout(sema: *Sema, struct_ty: Type) CompileError!void { |
| 328 | if (field_ty.isSpirvRuntimeArray(zcu)) { | 328 | if (field_ty.isSpirvRuntimeArray(zcu)) { |
| 329 | if (struct_obj.layout != .@"extern") { | 329 | if (struct_obj.layout != .@"extern") { |
| 330 | return sema.failWithOwnedErrorMsg(&block, msg: { | 330 | return sema.failWithOwnedErrorMsg(&block, msg: { |
| 331 | const msg = try sema.errMsg(struct_ty.srcLoc(zcu), "non-extern struct cannot contain fields of type '{f}'", .{field_ty.fmt(pt)}); | 331 | const msg = try sema.errMsg(struct_ty.srcLoc(zcu), "non-extern struct cannot contain fields of type '{f}'", .{field_ty.fmt(zcu)}); |
| 332 | errdefer msg.destroy(gpa); | 332 | errdefer msg.destroy(gpa); |
| 333 | try sema.errNote(field_name_src, msg, "while checking this field", .{}); | 333 | try sema.errNote(field_name_src, msg, "while checking this field", .{}); |
| 334 | break :msg msg; | 334 | break :msg msg; |
| ... | @@ -336,7 +336,7 @@ pub fn resolveStructLayout(sema: *Sema, struct_ty: Type) CompileError!void { | ... | @@ -336,7 +336,7 @@ pub fn resolveStructLayout(sema: *Sema, struct_ty: Type) CompileError!void { |
| 336 | } | 336 | } |
| 337 | if (field_index != fields_len - 1) { | 337 | if (field_index != fields_len - 1) { |
| 338 | return sema.failWithOwnedErrorMsg(&block, msg: { | 338 | return sema.failWithOwnedErrorMsg(&block, msg: { |
| 339 | const msg = try sema.errMsg(struct_ty.srcLoc(zcu), "struct field of type '{f}' must be the last field", .{field_ty.fmt(pt)}); | 339 | const msg = try sema.errMsg(struct_ty.srcLoc(zcu), "struct field of type '{f}' must be the last field", .{field_ty.fmt(zcu)}); |
| 340 | errdefer msg.destroy(gpa); | 340 | errdefer msg.destroy(gpa); |
| 341 | try sema.errNote(field_name_src, msg, "while checking this field", .{}); | 341 | try sema.errNote(field_name_src, msg, "while checking this field", .{}); |
| 342 | break :msg msg; | 342 | break :msg msg; |
| ... | @@ -346,7 +346,7 @@ pub fn resolveStructLayout(sema: *Sema, struct_ty: Type) CompileError!void { | ... | @@ -346,7 +346,7 @@ pub fn resolveStructLayout(sema: *Sema, struct_ty: Type) CompileError!void { |
| 346 | const elem_ty: Type = field_ty.childType(zcu); | 346 | const elem_ty: Type = field_ty.childType(zcu); |
| 347 | if (elem_ty.zigTypeTag(zcu) == .spirv) { | 347 | if (elem_ty.zigTypeTag(zcu) == .spirv) { |
| 348 | return sema.failWithOwnedErrorMsg(&block, msg: { | 348 | return sema.failWithOwnedErrorMsg(&block, msg: { |
| 349 | const msg = try sema.errMsg(field_ty_src, "cannot embed SPIR-V type '{f}' in struct", .{elem_ty.fmt(pt)}); | 349 | const msg = try sema.errMsg(field_ty_src, "cannot embed SPIR-V type '{f}' in struct", .{elem_ty.fmt(zcu)}); |
| 350 | errdefer msg.destroy(gpa); | 350 | errdefer msg.destroy(gpa); |
| 351 | try sema.errNote(field_ty_src, msg, "opaque types have unknown size", .{}); | 351 | try sema.errNote(field_ty_src, msg, "opaque types have unknown size", .{}); |
| 352 | try sema.addDeclaredHereNote(msg, field_ty); | 352 | try sema.addDeclaredHereNote(msg, field_ty); |
| ... | @@ -355,7 +355,7 @@ pub fn resolveStructLayout(sema: *Sema, struct_ty: Type) CompileError!void { | ... | @@ -355,7 +355,7 @@ pub fn resolveStructLayout(sema: *Sema, struct_ty: Type) CompileError!void { |
| 355 | } | 355 | } |
| 356 | } else { | 356 | } else { |
| 357 | return sema.failWithOwnedErrorMsg(&block, msg: { | 357 | return sema.failWithOwnedErrorMsg(&block, msg: { |
| 358 | const msg = try sema.errMsg(field_ty_src, "cannot directly embed SPIR-V type '{f}' in struct", .{field_ty.fmt(pt)}); | 358 | const msg = try sema.errMsg(field_ty_src, "cannot directly embed SPIR-V type '{f}' in struct", .{field_ty.fmt(zcu)}); |
| 359 | errdefer msg.destroy(gpa); | 359 | errdefer msg.destroy(gpa); |
| 360 | try sema.errNote(field_ty_src, msg, "opaque types have unknown size", .{}); | 360 | try sema.errNote(field_ty_src, msg, "opaque types have unknown size", .{}); |
| 361 | try sema.addDeclaredHereNote(msg, field_ty); | 361 | try sema.addDeclaredHereNote(msg, field_ty); |
| ... | @@ -366,7 +366,7 @@ pub fn resolveStructLayout(sema: *Sema, struct_ty: Type) CompileError!void { | ... | @@ -366,7 +366,7 @@ pub fn resolveStructLayout(sema: *Sema, struct_ty: Type) CompileError!void { |
| 366 | 366 | ||
| 367 | if (struct_obj.layout == .@"extern" and !field_ty.validateExtern(.struct_field, zcu)) { | 367 | if (struct_obj.layout == .@"extern" and !field_ty.validateExtern(.struct_field, zcu)) { |
| 368 | return sema.failWithOwnedErrorMsg(&block, msg: { | 368 | return sema.failWithOwnedErrorMsg(&block, msg: { |
| 369 | const msg = try sema.errMsg(field_ty_src, "extern structs cannot contain fields of type '{f}'", .{field_ty.fmt(pt)}); | 369 | const msg = try sema.errMsg(field_ty_src, "extern structs cannot contain fields of type '{f}'", .{field_ty.fmt(zcu)}); |
| 370 | errdefer msg.destroy(gpa); | 370 | errdefer msg.destroy(gpa); |
| 371 | try sema.explainWhyTypeIsNotExtern(msg, field_ty_src, field_ty, .struct_field); | 371 | try sema.explainWhyTypeIsNotExtern(msg, field_ty_src, field_ty, .struct_field); |
| 372 | try sema.addDeclaredHereNote(msg, field_ty); | 372 | try sema.addDeclaredHereNote(msg, field_ty); |
| ... | @@ -523,7 +523,7 @@ fn resolvePackedStructLayout( | ... | @@ -523,7 +523,7 @@ fn resolvePackedStructLayout( |
| 523 | try sema.ensureLayoutResolved(field_ty, field_ty_src, .field); | 523 | try sema.ensureLayoutResolved(field_ty, field_ty_src, .field); |
| 524 | if (field_ty.zigTypeTag(zcu) == .@"opaque") { | 524 | if (field_ty.zigTypeTag(zcu) == .@"opaque") { |
| 525 | return sema.failWithOwnedErrorMsg(block, msg: { | 525 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 526 | const msg = try sema.errMsg(field_ty_src, "cannot directly embed opaque type '{f}' in struct", .{field_ty.fmt(pt)}); | 526 | const msg = try sema.errMsg(field_ty_src, "cannot directly embed opaque type '{f}' in struct", .{field_ty.fmt(zcu)}); |
| 527 | errdefer msg.destroy(gpa); | 527 | errdefer msg.destroy(gpa); |
| 528 | try sema.errNote(field_ty_src, msg, "opaque types have unknown size", .{}); | 528 | try sema.errNote(field_ty_src, msg, "opaque types have unknown size", .{}); |
| 529 | try sema.addDeclaredHereNote(msg, field_ty); | 529 | try sema.addDeclaredHereNote(msg, field_ty); |
| ... | @@ -531,7 +531,7 @@ fn resolvePackedStructLayout( | ... | @@ -531,7 +531,7 @@ fn resolvePackedStructLayout( |
| 531 | }); | 531 | }); |
| 532 | } | 532 | } |
| 533 | if (field_ty.unpackable(zcu)) |reason| return sema.failWithOwnedErrorMsg(block, msg: { | 533 | if (field_ty.unpackable(zcu)) |reason| return sema.failWithOwnedErrorMsg(block, msg: { |
| 534 | const msg = try sema.errMsg(field_ty_src, "packed structs cannot contain fields of type '{f}'", .{field_ty.fmt(pt)}); | 534 | const msg = try sema.errMsg(field_ty_src, "packed structs cannot contain fields of type '{f}'", .{field_ty.fmt(zcu)}); |
| 535 | errdefer msg.destroy(gpa); | 535 | errdefer msg.destroy(gpa); |
| 536 | try sema.explainWhyTypeIsUnpackable(msg, field_ty_src, reason); | 536 | try sema.explainWhyTypeIsUnpackable(msg, field_ty_src, reason); |
| 537 | break :msg msg; | 537 | break :msg msg; |
| ... | @@ -575,7 +575,7 @@ fn resolvePackedStructLayout( | ... | @@ -575,7 +575,7 @@ fn resolvePackedStructLayout( |
| 575 | block, | 575 | block, |
| 576 | backing_int_ty_src, | 576 | backing_int_ty_src, |
| 577 | "expected backing integer type, found '{f}'", | 577 | "expected backing integer type, found '{f}'", |
| 578 | .{backing_ty.fmt(pt)}, | 578 | .{backing_ty.fmt(zcu)}, |
| 579 | ); | 579 | ); |
| 580 | if (field_bits != backing_ty.intInfo(zcu).bits) return sema.failWithOwnedErrorMsg(block, msg: { | 580 | if (field_bits != backing_ty.intInfo(zcu).bits) return sema.failWithOwnedErrorMsg(block, msg: { |
| 581 | const src = struct_ty.srcLoc(zcu); | 581 | const src = struct_ty.srcLoc(zcu); |
| ... | @@ -585,7 +585,7 @@ fn resolvePackedStructLayout( | ... | @@ -585,7 +585,7 @@ fn resolvePackedStructLayout( |
| 585 | backing_int_ty_src, | 585 | backing_int_ty_src, |
| 586 | msg, | 586 | msg, |
| 587 | "backing integer '{f}' has bit width '{d}'", | 587 | "backing integer '{f}' has bit width '{d}'", |
| 588 | .{ backing_ty.fmt(pt), backing_ty.bitSize(zcu) }, | 588 | .{ backing_ty.fmt(zcu), backing_ty.bitSize(zcu) }, |
| 589 | ); | 589 | ); |
| 590 | try sema.errNote(src, msg, "struct fields have total bit width '{d}'", .{field_bits}); | 590 | try sema.errNote(src, msg, "struct fields have total bit width '{d}'", .{field_bits}); |
| 591 | break :msg msg; | 591 | break :msg msg; |
| ... | @@ -798,7 +798,7 @@ pub fn resolveUnionLayout(sema: *Sema, union_ty: Type) CompileError!void { | ... | @@ -798,7 +798,7 @@ pub fn resolveUnionLayout(sema: *Sema, union_ty: Type) CompileError!void { |
| 798 | &block, | 798 | &block, |
| 799 | block.src(.container_arg), | 799 | block.src(.container_arg), |
| 800 | "expected enum tag type, found '{f}'", | 800 | "expected enum tag type, found '{f}'", |
| 801 | .{tag_ty.fmt(pt)}, | 801 | .{tag_ty.fmt(zcu)}, |
| 802 | ); | 802 | ); |
| 803 | break :validated_tag_ty tag_ty; | 803 | break :validated_tag_ty tag_ty; |
| 804 | }, | 804 | }, |
| ... | @@ -947,7 +947,7 @@ pub fn resolveUnionLayout(sema: *Sema, union_ty: Type) CompileError!void { | ... | @@ -947,7 +947,7 @@ pub fn resolveUnionLayout(sema: *Sema, union_ty: Type) CompileError!void { |
| 947 | try sema.ensureLayoutResolved(field_ty, field_ty_src, .field); | 947 | try sema.ensureLayoutResolved(field_ty, field_ty_src, .field); |
| 948 | if (field_ty.zigTypeTag(zcu) == .@"opaque") { | 948 | if (field_ty.zigTypeTag(zcu) == .@"opaque") { |
| 949 | return sema.failWithOwnedErrorMsg(&block, msg: { | 949 | return sema.failWithOwnedErrorMsg(&block, msg: { |
| 950 | const msg = try sema.errMsg(field_ty_src, "cannot directly embed opaque type '{f}' in union", .{field_ty.fmt(pt)}); | 950 | const msg = try sema.errMsg(field_ty_src, "cannot directly embed opaque type '{f}' in union", .{field_ty.fmt(zcu)}); |
| 951 | errdefer msg.destroy(gpa); | 951 | errdefer msg.destroy(gpa); |
| 952 | try sema.errNote(field_ty_src, msg, "opaque types have unknown size", .{}); | 952 | try sema.errNote(field_ty_src, msg, "opaque types have unknown size", .{}); |
| 953 | try sema.addDeclaredHereNote(msg, field_ty); | 953 | try sema.addDeclaredHereNote(msg, field_ty); |
| ... | @@ -956,7 +956,7 @@ pub fn resolveUnionLayout(sema: *Sema, union_ty: Type) CompileError!void { | ... | @@ -956,7 +956,7 @@ pub fn resolveUnionLayout(sema: *Sema, union_ty: Type) CompileError!void { |
| 956 | } | 956 | } |
| 957 | if (field_ty.zigTypeTag(zcu) == .spirv) { | 957 | if (field_ty.zigTypeTag(zcu) == .spirv) { |
| 958 | return sema.failWithOwnedErrorMsg(&block, msg: { | 958 | return sema.failWithOwnedErrorMsg(&block, msg: { |
| 959 | const msg = try sema.errMsg(field_ty_src, "SPIR-V type '{f}' have unknown size and therefore cannot be directly embedded in unions", .{field_ty.fmt(pt)}); | 959 | const msg = try sema.errMsg(field_ty_src, "SPIR-V type '{f}' have unknown size and therefore cannot be directly embedded in unions", .{field_ty.fmt(zcu)}); |
| 960 | errdefer msg.destroy(gpa); | 960 | errdefer msg.destroy(gpa); |
| 961 | try sema.addDeclaredHereNote(msg, field_ty); | 961 | try sema.addDeclaredHereNote(msg, field_ty); |
| 962 | break :msg msg; | 962 | break :msg msg; |
| ... | @@ -964,7 +964,7 @@ pub fn resolveUnionLayout(sema: *Sema, union_ty: Type) CompileError!void { | ... | @@ -964,7 +964,7 @@ pub fn resolveUnionLayout(sema: *Sema, union_ty: Type) CompileError!void { |
| 964 | } | 964 | } |
| 965 | if (union_obj.layout == .@"extern" and !field_ty.validateExtern(.union_field, zcu)) { | 965 | if (union_obj.layout == .@"extern" and !field_ty.validateExtern(.union_field, zcu)) { |
| 966 | return sema.failWithOwnedErrorMsg(&block, msg: { | 966 | return sema.failWithOwnedErrorMsg(&block, msg: { |
| 967 | const msg = try sema.errMsg(field_ty_src, "extern unions cannot contain fields of type '{f}'", .{field_ty.fmt(pt)}); | 967 | const msg = try sema.errMsg(field_ty_src, "extern unions cannot contain fields of type '{f}'", .{field_ty.fmt(zcu)}); |
| 968 | errdefer msg.destroy(gpa); | 968 | errdefer msg.destroy(gpa); |
| 969 | try sema.explainWhyTypeIsNotExtern(msg, field_ty_src, field_ty, .union_field); | 969 | try sema.explainWhyTypeIsNotExtern(msg, field_ty_src, field_ty, .union_field); |
| 970 | try sema.addDeclaredHereNote(msg, field_ty); | 970 | try sema.addDeclaredHereNote(msg, field_ty); |
| ... | @@ -1081,7 +1081,7 @@ fn failUnionFieldMismatch(sema: *Sema, block: *Block, union_field_names: []const | ... | @@ -1081,7 +1081,7 @@ fn failUnionFieldMismatch(sema: *Sema, block: *Block, union_field_names: []const |
| 1081 | } | 1081 | } |
| 1082 | const union_field_src = block.src(.{ .container_field_name = @intCast(union_field_index) }); | 1082 | const union_field_src = block.src(.{ .container_field_name = @intCast(union_field_index) }); |
| 1083 | return sema.failWithOwnedErrorMsg(block, msg: { | 1083 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 1084 | const msg = try sema.errMsg(union_field_src, "no field named '{f}' in enum '{f}'", .{ field_name.fmt(ip), enum_tag_ty.fmt(pt) }); | 1084 | const msg = try sema.errMsg(union_field_src, "no field named '{f}' in enum '{f}'", .{ field_name.fmt(ip), enum_tag_ty.fmt(zcu) }); |
| 1085 | errdefer msg.destroy(gpa); | 1085 | errdefer msg.destroy(gpa); |
| 1086 | try sema.addDeclaredHereNote(msg, enum_tag_ty); | 1086 | try sema.addDeclaredHereNote(msg, enum_tag_ty); |
| 1087 | break :msg msg; | 1087 | break :msg msg; |
| ... | @@ -1153,7 +1153,7 @@ fn resolvePackedUnionLayout( | ... | @@ -1153,7 +1153,7 @@ fn resolvePackedUnionLayout( |
| 1153 | try sema.ensureLayoutResolved(field_ty, field_ty_src, .field); | 1153 | try sema.ensureLayoutResolved(field_ty, field_ty_src, .field); |
| 1154 | if (field_ty.zigTypeTag(zcu) == .@"opaque") { | 1154 | if (field_ty.zigTypeTag(zcu) == .@"opaque") { |
| 1155 | return sema.failWithOwnedErrorMsg(block, msg: { | 1155 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 1156 | const msg = try sema.errMsg(field_ty_src, "cannot directly embed opaque type '{f}' in union", .{field_ty.fmt(pt)}); | 1156 | const msg = try sema.errMsg(field_ty_src, "cannot directly embed opaque type '{f}' in union", .{field_ty.fmt(zcu)}); |
| 1157 | errdefer msg.destroy(gpa); | 1157 | errdefer msg.destroy(gpa); |
| 1158 | try sema.errNote(field_ty_src, msg, "opaque types have unknown size", .{}); | 1158 | try sema.errNote(field_ty_src, msg, "opaque types have unknown size", .{}); |
| 1159 | try sema.addDeclaredHereNote(msg, field_ty); | 1159 | try sema.addDeclaredHereNote(msg, field_ty); |
| ... | @@ -1161,7 +1161,7 @@ fn resolvePackedUnionLayout( | ... | @@ -1161,7 +1161,7 @@ fn resolvePackedUnionLayout( |
| 1161 | }); | 1161 | }); |
| 1162 | } | 1162 | } |
| 1163 | if (field_ty.unpackable(zcu)) |reason| return sema.failWithOwnedErrorMsg(block, msg: { | 1163 | if (field_ty.unpackable(zcu)) |reason| return sema.failWithOwnedErrorMsg(block, msg: { |
| 1164 | const msg = try sema.errMsg(field_ty_src, "packed unions cannot contain fields of type '{f}'", .{field_ty.fmt(pt)}); | 1164 | const msg = try sema.errMsg(field_ty_src, "packed unions cannot contain fields of type '{f}'", .{field_ty.fmt(zcu)}); |
| 1165 | errdefer msg.destroy(gpa); | 1165 | errdefer msg.destroy(gpa); |
| 1166 | try sema.explainWhyTypeIsUnpackable(msg, field_ty_src, reason); | 1166 | try sema.explainWhyTypeIsUnpackable(msg, field_ty_src, reason); |
| 1167 | break :msg msg; | 1167 | break :msg msg; |
| ... | @@ -1199,7 +1199,7 @@ fn resolvePackedUnionLayout( | ... | @@ -1199,7 +1199,7 @@ fn resolvePackedUnionLayout( |
| 1199 | block, | 1199 | block, |
| 1200 | backing_int_ty_src, | 1200 | backing_int_ty_src, |
| 1201 | "expected backing integer type, found '{f}'", | 1201 | "expected backing integer type, found '{f}'", |
| 1202 | .{backing_ty.fmt(pt)}, | 1202 | .{backing_ty.fmt(zcu)}, |
| 1203 | ); | 1203 | ); |
| 1204 | const backing_int_bits = backing_ty.intInfo(zcu).bits; | 1204 | const backing_int_bits = backing_ty.intInfo(zcu).bits; |
| 1205 | for (union_obj.field_types.get(ip), 0..) |field_type_ip, field_idx| { | 1205 | for (union_obj.field_types.get(ip), 0..) |field_type_ip, field_idx| { |
| ... | @@ -1209,12 +1209,12 @@ fn resolvePackedUnionLayout( | ... | @@ -1209,12 +1209,12 @@ fn resolvePackedUnionLayout( |
| 1209 | const field_ty_src = block.src(.{ .container_field_type = @intCast(field_idx) }); | 1209 | const field_ty_src = block.src(.{ .container_field_type = @intCast(field_idx) }); |
| 1210 | const msg = try sema.errMsg(field_ty_src, "field bit width does not match backing integer", .{}); | 1210 | const msg = try sema.errMsg(field_ty_src, "field bit width does not match backing integer", .{}); |
| 1211 | errdefer msg.destroy(gpa); | 1211 | errdefer msg.destroy(gpa); |
| 1212 | try sema.errNote(field_ty_src, msg, "field type '{f}' has bit width '{d}'", .{ field_type.fmt(pt), field_bits }); | 1212 | try sema.errNote(field_ty_src, msg, "field type '{f}' has bit width '{d}'", .{ field_type.fmt(zcu), field_bits }); |
| 1213 | try sema.errNote( | 1213 | try sema.errNote( |
| 1214 | backing_int_ty_src, | 1214 | backing_int_ty_src, |
| 1215 | msg, | 1215 | msg, |
| 1216 | "backing integer '{f}' has bit width '{d}'", | 1216 | "backing integer '{f}' has bit width '{d}'", |
| 1217 | .{ backing_ty.fmt(pt), backing_int_bits }, | 1217 | .{ backing_ty.fmt(zcu), backing_int_bits }, |
| 1218 | ); | 1218 | ); |
| 1219 | try sema.errNote(field_ty_src, msg, "all fields in a packed union must have the same bit width", .{}); | 1219 | try sema.errNote(field_ty_src, msg, "all fields in a packed union must have the same bit width", .{}); |
| 1220 | break :msg msg; | 1220 | break :msg msg; |
| ... | @@ -1233,8 +1233,8 @@ fn resolvePackedUnionLayout( | ... | @@ -1233,8 +1233,8 @@ fn resolvePackedUnionLayout( |
| 1233 | const field_ty_src = block.src(.{ .container_field_type = @intCast(field_idx) }); | 1233 | const field_ty_src = block.src(.{ .container_field_type = @intCast(field_idx) }); |
| 1234 | const msg = try sema.errMsg(field_ty_src, "field bit width does not match earlier field", .{}); | 1234 | const msg = try sema.errMsg(field_ty_src, "field bit width does not match earlier field", .{}); |
| 1235 | errdefer msg.destroy(gpa); | 1235 | errdefer msg.destroy(gpa); |
| 1236 | try sema.errNote(field_ty_src, msg, "field type '{f}' has bit width '{d}'", .{ field_type.fmt(pt), field_bits }); | 1236 | try sema.errNote(field_ty_src, msg, "field type '{f}' has bit width '{d}'", .{ field_type.fmt(zcu), field_bits }); |
| 1237 | try sema.errNote(first_field_ty_src, msg, "other field type '{f}' has bit width '{d}'", .{ first_field_type.fmt(pt), first_field_bits }); | 1237 | try sema.errNote(first_field_ty_src, msg, "other field type '{f}' has bit width '{d}'", .{ first_field_type.fmt(zcu), first_field_bits }); |
| 1238 | try sema.errNote(field_ty_src, msg, "all fields in a packed union must have the same bit width", .{}); | 1238 | try sema.errNote(field_ty_src, msg, "all fields in a packed union must have the same bit width", .{}); |
| 1239 | break :msg msg; | 1239 | break :msg msg; |
| 1240 | }); | 1240 | }); |
| ... | @@ -1421,7 +1421,7 @@ pub fn resolveEnumLayout(sema: *Sema, enum_ty: Type) CompileError!void { | ... | @@ -1421,7 +1421,7 @@ pub fn resolveEnumLayout(sema: *Sema, enum_ty: Type) CompileError!void { |
| 1421 | &block, | 1421 | &block, |
| 1422 | block.src(.container_arg), | 1422 | block.src(.container_arg), |
| 1423 | "expected integer tag type, found '{f}'", | 1423 | "expected integer tag type, found '{f}'", |
| 1424 | .{int_tag_ty.fmt(pt)}, | 1424 | .{int_tag_ty.fmt(zcu)}, |
| 1425 | ), | 1425 | ), |
| 1426 | } | 1426 | } |
| 1427 | break :ty int_tag_ty; | 1427 | break :ty int_tag_ty; |
| ... | @@ -1532,7 +1532,7 @@ pub fn resolveEnumLayout(sema: *Sema, enum_ty: Type) CompileError!void { | ... | @@ -1532,7 +1532,7 @@ pub fn resolveEnumLayout(sema: *Sema, enum_ty: Type) CompileError!void { |
| 1532 | &block, | 1532 | &block, |
| 1533 | field_val_src, | 1533 | field_val_src, |
| 1534 | "enum tag value '{f}' too large for type '{f}'", | 1534 | "enum tag value '{f}' too large for type '{f}'", |
| 1535 | .{ result.val.fmtValueSema(pt, sema), int_tag_ty.fmt(pt) }, | 1535 | .{ result.val.fmtValueSema(sema), int_tag_ty.fmt(zcu) }, |
| 1536 | ); | 1536 | ); |
| 1537 | const val = result.val.toIntern(); | 1537 | const val = result.val.toIntern(); |
| 1538 | enum_obj.field_values.get(ip)[field_idx] = val; | 1538 | enum_obj.field_values.get(ip)[field_idx] = val; |
| ... | @@ -1542,7 +1542,7 @@ pub fn resolveEnumLayout(sema: *Sema, enum_ty: Type) CompileError!void { | ... | @@ -1542,7 +1542,7 @@ pub fn resolveEnumLayout(sema: *Sema, enum_ty: Type) CompileError!void { |
| 1542 | return sema.failWithOwnedErrorMsg(&block, msg: { | 1542 | return sema.failWithOwnedErrorMsg(&block, msg: { |
| 1543 | const prev_field_val_src = block.src(.{ .container_field_value = prev_field_index }); | 1543 | const prev_field_val_src = block.src(.{ .container_field_value = prev_field_index }); |
| 1544 | const msg = try sema.errMsg(field_val_src, "enum tag value '{f}' for field '{f}' already taken", .{ | 1544 | const msg = try sema.errMsg(field_val_src, "enum tag value '{f}' for field '{f}' already taken", .{ |
| 1545 | Value.fromInterned(field_val).fmtValueSema(pt, sema), | 1545 | Value.fromInterned(field_val).fmtValueSema(sema), |
| 1546 | enum_obj.field_names.get(ip)[field_idx].fmt(ip), | 1546 | enum_obj.field_names.get(ip)[field_idx].fmt(ip), |
| 1547 | }); | 1547 | }); |
| 1548 | errdefer msg.destroy(gpa); | 1548 | errdefer msg.destroy(gpa); |
src/Type.zig+144-162| ... | @@ -412,21 +412,14 @@ pub fn eql(a: Type, b: Type) bool { | ... | @@ -412,21 +412,14 @@ pub fn eql(a: Type, b: Type) bool { |
| 412 | 412 | ||
| 413 | pub const format = @compileError("do not format types directly; use either ty.fmtDebug() or ty.fmt()"); | 413 | pub const format = @compileError("do not format types directly; use either ty.fmtDebug() or ty.fmt()"); |
| 414 | 414 | ||
| 415 | pub const Formatter = std.fmt.Alt(Format, Format.default); | 415 | pub fn fmt(ty: Type, zcu: *Zcu) Formatter { |
| 416 | 416 | return .{ .ty = ty, .zcu = zcu }; | |
| 417 | pub fn fmt(ty: Type, pt: Zcu.PerThread) Formatter { | ||
| 418 | return .{ .data = .{ | ||
| 419 | .ty = ty, | ||
| 420 | .pt = pt, | ||
| 421 | } }; | ||
| 422 | } | 417 | } |
| 423 | 418 | pub const Formatter = struct { | |
| 424 | const Format = struct { | ||
| 425 | ty: Type, | 419 | ty: Type, |
| 426 | pt: Zcu.PerThread, | 420 | zcu: *Zcu, |
| 427 | 421 | pub fn format(f: Formatter, writer: *std.Io.Writer) std.Io.Writer.Error!void { | |
| 428 | fn default(f: Format, writer: *std.Io.Writer) std.Io.Writer.Error!void { | 422 | return print(f.ty, writer, f.zcu, null); |
| 429 | return print(f.ty, writer, f.pt, null); | ||
| 430 | } | 423 | } |
| 431 | }; | 424 | }; |
| 432 | 425 | ||
| ... | @@ -442,9 +435,9 @@ pub fn dump(start_type: Type, writer: *std.Io.Writer) std.Io.Writer.Error!void { | ... | @@ -442,9 +435,9 @@ pub fn dump(start_type: Type, writer: *std.Io.Writer) std.Io.Writer.Error!void { |
| 442 | 435 | ||
| 443 | /// Prints a name suitable for `@typeName`. | 436 | /// Prints a name suitable for `@typeName`. |
| 444 | /// TODO: take an `opt_sema` to pass to `fmtValue` when printing sentinels. | 437 | /// TODO: take an `opt_sema` to pass to `fmtValue` when printing sentinels. |
| 445 | pub fn print(ty: Type, writer: *std.Io.Writer, pt: Zcu.PerThread, ctx: ?*Comparison) std.Io.Writer.Error!void { | 438 | pub fn print(ty: Type, writer: *std.Io.Writer, zcu: *Zcu, ctx: ?*Comparison) std.Io.Writer.Error!void { |
| 446 | if (ctx) |c| { | 439 | if (ctx) |c| { |
| 447 | const should_dedupe = shouldDedupeType(ty, c, pt) catch |err| switch (err) { | 440 | const should_dedupe = shouldDedupeType(ty, c, zcu) catch |err| switch (err) { |
| 448 | error.OutOfMemory => return error.WriteFailed, | 441 | error.OutOfMemory => return error.WriteFailed, |
| 449 | }; | 442 | }; |
| 450 | switch (should_dedupe) { | 443 | switch (should_dedupe) { |
| ... | @@ -453,7 +446,6 @@ pub fn print(ty: Type, writer: *std.Io.Writer, pt: Zcu.PerThread, ctx: ?*Compari | ... | @@ -453,7 +446,6 @@ pub fn print(ty: Type, writer: *std.Io.Writer, pt: Zcu.PerThread, ctx: ?*Compari |
| 453 | } | 446 | } |
| 454 | } | 447 | } |
| 455 | 448 | ||
| 456 | const zcu = pt.zcu; | ||
| 457 | const ip = &zcu.intern_pool; | 449 | const ip = &zcu.intern_pool; |
| 458 | switch (ip.indexToKey(ty.toIntern())) { | 450 | switch (ip.indexToKey(ty.toIntern())) { |
| 459 | .undef => return writer.writeAll("@as(type, undefined)"), | 451 | .undef => return writer.writeAll("@as(type, undefined)"), |
| ... | @@ -469,8 +461,8 @@ pub fn print(ty: Type, writer: *std.Io.Writer, pt: Zcu.PerThread, ctx: ?*Compari | ... | @@ -469,8 +461,8 @@ pub fn print(ty: Type, writer: *std.Io.Writer, pt: Zcu.PerThread, ctx: ?*Compari |
| 469 | 461 | ||
| 470 | if (info.sentinel != .none) switch (info.flags.size) { | 462 | if (info.sentinel != .none) switch (info.flags.size) { |
| 471 | .one, .c => unreachable, | 463 | .one, .c => unreachable, |
| 472 | .many => try writer.print("[*:{f}]", .{Value.fromInterned(info.sentinel).fmtValue(pt)}), | 464 | .many => try writer.print("[*:{f}]", .{Value.fromInterned(info.sentinel).fmtValue(zcu)}), |
| 473 | .slice => try writer.print("[:{f}]", .{Value.fromInterned(info.sentinel).fmtValue(pt)}), | 465 | .slice => try writer.print("[:{f}]", .{Value.fromInterned(info.sentinel).fmtValue(zcu)}), |
| 474 | } else switch (info.flags.size) { | 466 | } else switch (info.flags.size) { |
| 475 | .one => try writer.writeAll("*"), | 467 | .one => try writer.writeAll("*"), |
| 476 | .many => try writer.writeAll("[*]"), | 468 | .many => try writer.writeAll("[*]"), |
| ... | @@ -485,7 +477,7 @@ pub fn print(ty: Type, writer: *std.Io.Writer, pt: Zcu.PerThread, ctx: ?*Compari | ... | @@ -485,7 +477,7 @@ pub fn print(ty: Type, writer: *std.Io.Writer, pt: Zcu.PerThread, ctx: ?*Compari |
| 485 | const alignment = if (info.flags.alignment != .none) | 477 | const alignment = if (info.flags.alignment != .none) |
| 486 | info.flags.alignment | 478 | info.flags.alignment |
| 487 | else | 479 | else |
| 488 | Type.fromInterned(info.child).abiAlignment(pt.zcu); | 480 | Type.fromInterned(info.child).abiAlignment(zcu); |
| 489 | try writer.print("align({d}", .{alignment.toByteUnits() orelse 0}); | 481 | try writer.print("align({d}", .{alignment.toByteUnits() orelse 0}); |
| 490 | 482 | ||
| 491 | if (info.packed_offset.bit_offset != 0 or info.packed_offset.host_size != 0) { | 483 | if (info.packed_offset.bit_offset != 0 or info.packed_offset.host_size != 0) { |
| ... | @@ -504,39 +496,39 @@ pub fn print(ty: Type, writer: *std.Io.Writer, pt: Zcu.PerThread, ctx: ?*Compari | ... | @@ -504,39 +496,39 @@ pub fn print(ty: Type, writer: *std.Io.Writer, pt: Zcu.PerThread, ctx: ?*Compari |
| 504 | if (info.flags.is_const) try writer.writeAll("const "); | 496 | if (info.flags.is_const) try writer.writeAll("const "); |
| 505 | if (info.flags.is_volatile) try writer.writeAll("volatile "); | 497 | if (info.flags.is_volatile) try writer.writeAll("volatile "); |
| 506 | 498 | ||
| 507 | try print(Type.fromInterned(info.child), writer, pt, ctx); | 499 | try print(Type.fromInterned(info.child), writer, zcu, ctx); |
| 508 | return; | 500 | return; |
| 509 | }, | 501 | }, |
| 510 | .array_type => |array_type| { | 502 | .array_type => |array_type| { |
| 511 | if (array_type.sentinel == .none) { | 503 | if (array_type.sentinel == .none) { |
| 512 | try writer.print("[{d}]", .{array_type.len}); | 504 | try writer.print("[{d}]", .{array_type.len}); |
| 513 | try print(Type.fromInterned(array_type.child), writer, pt, ctx); | 505 | try print(Type.fromInterned(array_type.child), writer, zcu, ctx); |
| 514 | } else { | 506 | } else { |
| 515 | try writer.print("[{d}:{f}]", .{ | 507 | try writer.print("[{d}:{f}]", .{ |
| 516 | array_type.len, | 508 | array_type.len, |
| 517 | Value.fromInterned(array_type.sentinel).fmtValue(pt), | 509 | Value.fromInterned(array_type.sentinel).fmtValue(zcu), |
| 518 | }); | 510 | }); |
| 519 | try print(Type.fromInterned(array_type.child), writer, pt, ctx); | 511 | try print(Type.fromInterned(array_type.child), writer, zcu, ctx); |
| 520 | } | 512 | } |
| 521 | return; | 513 | return; |
| 522 | }, | 514 | }, |
| 523 | .vector_type => |vector_type| { | 515 | .vector_type => |vector_type| { |
| 524 | try writer.print("@Vector({d}, ", .{vector_type.len}); | 516 | try writer.print("@Vector({d}, ", .{vector_type.len}); |
| 525 | try print(Type.fromInterned(vector_type.child), writer, pt, ctx); | 517 | try print(Type.fromInterned(vector_type.child), writer, zcu, ctx); |
| 526 | try writer.writeAll(")"); | 518 | try writer.writeAll(")"); |
| 527 | return; | 519 | return; |
| 528 | }, | 520 | }, |
| 529 | .opt_type => |child| { | 521 | .opt_type => |child| { |
| 530 | try writer.writeByte('?'); | 522 | try writer.writeByte('?'); |
| 531 | return print(Type.fromInterned(child), writer, pt, ctx); | 523 | return print(Type.fromInterned(child), writer, zcu, ctx); |
| 532 | }, | 524 | }, |
| 533 | .error_union_type => |error_union_type| { | 525 | .error_union_type => |error_union_type| { |
| 534 | try print(Type.fromInterned(error_union_type.error_set_type), writer, pt, ctx); | 526 | try print(Type.fromInterned(error_union_type.error_set_type), writer, zcu, ctx); |
| 535 | try writer.writeByte('!'); | 527 | try writer.writeByte('!'); |
| 536 | if (error_union_type.payload_type == .generic_poison_type) { | 528 | if (error_union_type.payload_type == .generic_poison_type) { |
| 537 | try writer.writeAll("anytype"); | 529 | try writer.writeAll("anytype"); |
| 538 | } else { | 530 | } else { |
| 539 | try print(Type.fromInterned(error_union_type.payload_type), writer, pt, ctx); | 531 | try print(Type.fromInterned(error_union_type.payload_type), writer, zcu, ctx); |
| 540 | } | 532 | } |
| 541 | return; | 533 | return; |
| 542 | }, | 534 | }, |
| ... | @@ -618,8 +610,8 @@ pub fn print(ty: Type, writer: *std.Io.Writer, pt: Zcu.PerThread, ctx: ?*Compari | ... | @@ -618,8 +610,8 @@ pub fn print(ty: Type, writer: *std.Io.Writer, pt: Zcu.PerThread, ctx: ?*Compari |
| 618 | for (tuple.types.get(ip), tuple.values.get(ip), 0..) |field_ty, val, i| { | 610 | for (tuple.types.get(ip), tuple.values.get(ip), 0..) |field_ty, val, i| { |
| 619 | try writer.writeAll(if (i == 0) " " else ", "); | 611 | try writer.writeAll(if (i == 0) " " else ", "); |
| 620 | if (val != .none) try writer.writeAll("comptime "); | 612 | if (val != .none) try writer.writeAll("comptime "); |
| 621 | try print(Type.fromInterned(field_ty), writer, pt, ctx); | 613 | try print(Type.fromInterned(field_ty), writer, zcu, ctx); |
| 622 | if (val != .none) try writer.print(" = {f}", .{Value.fromInterned(val).fmtValue(pt)}); | 614 | if (val != .none) try writer.print(" = {f}", .{Value.fromInterned(val).fmtValue(zcu)}); |
| 623 | } | 615 | } |
| 624 | try writer.writeAll(" }"); | 616 | try writer.writeAll(" }"); |
| 625 | }, | 617 | }, |
| ... | @@ -643,12 +635,12 @@ pub fn print(ty: Type, writer: *std.Io.Writer, pt: Zcu.PerThread, ctx: ?*Compari | ... | @@ -643,12 +635,12 @@ pub fn print(ty: Type, writer: *std.Io.Writer, pt: Zcu.PerThread, ctx: ?*Compari |
| 643 | .image => try writer.writeAll("@SpirvType(.image)"), | 635 | .image => try writer.writeAll("@SpirvType(.image)"), |
| 644 | .sampled_image => { | 636 | .sampled_image => { |
| 645 | try writer.writeAll("@SpirvType(.sampled_image, "); | 637 | try writer.writeAll("@SpirvType(.sampled_image, "); |
| 646 | try print(Type.fromInterned(info.ty), writer, pt, ctx); | 638 | try print(Type.fromInterned(info.ty), writer, zcu, ctx); |
| 647 | try writer.writeAll(")"); | 639 | try writer.writeAll(")"); |
| 648 | }, | 640 | }, |
| 649 | .runtime_array => { | 641 | .runtime_array => { |
| 650 | try writer.writeAll("@SpirvType(.runtime_array, "); | 642 | try writer.writeAll("@SpirvType(.runtime_array, "); |
| 651 | try print(Type.fromInterned(info.ty), writer, pt, ctx); | 643 | try print(Type.fromInterned(info.ty), writer, zcu, ctx); |
| 652 | try writer.writeAll(")"); | 644 | try writer.writeAll(")"); |
| 653 | }, | 645 | }, |
| 654 | } | 646 | } |
| ... | @@ -672,7 +664,7 @@ pub fn print(ty: Type, writer: *std.Io.Writer, pt: Zcu.PerThread, ctx: ?*Compari | ... | @@ -672,7 +664,7 @@ pub fn print(ty: Type, writer: *std.Io.Writer, pt: Zcu.PerThread, ctx: ?*Compari |
| 672 | if (param_ty == .generic_poison_type) { | 664 | if (param_ty == .generic_poison_type) { |
| 673 | try writer.writeAll("anytype"); | 665 | try writer.writeAll("anytype"); |
| 674 | } else { | 666 | } else { |
| 675 | try print(Type.fromInterned(param_ty), writer, pt, ctx); | 667 | try print(Type.fromInterned(param_ty), writer, zcu, ctx); |
| 676 | } | 668 | } |
| 677 | } | 669 | } |
| 678 | if (fn_info.is_var_args) { | 670 | if (fn_info.is_var_args) { |
| ... | @@ -699,13 +691,13 @@ pub fn print(ty: Type, writer: *std.Io.Writer, pt: Zcu.PerThread, ctx: ?*Compari | ... | @@ -699,13 +691,13 @@ pub fn print(ty: Type, writer: *std.Io.Writer, pt: Zcu.PerThread, ctx: ?*Compari |
| 699 | if (fn_info.return_type == .generic_poison_type) { | 691 | if (fn_info.return_type == .generic_poison_type) { |
| 700 | try writer.writeAll("anytype"); | 692 | try writer.writeAll("anytype"); |
| 701 | } else { | 693 | } else { |
| 702 | try print(Type.fromInterned(fn_info.return_type), writer, pt, ctx); | 694 | try print(Type.fromInterned(fn_info.return_type), writer, zcu, ctx); |
| 703 | } | 695 | } |
| 704 | }, | 696 | }, |
| 705 | .anyframe_type => |child| { | 697 | .anyframe_type => |child| { |
| 706 | if (child == .none) return writer.writeAll("anyframe"); | 698 | if (child == .none) return writer.writeAll("anyframe"); |
| 707 | try writer.writeAll("anyframe->"); | 699 | try writer.writeAll("anyframe->"); |
| 708 | return print(Type.fromInterned(child), writer, pt, ctx); | 700 | return print(Type.fromInterned(child), writer, zcu, ctx); |
| 709 | }, | 701 | }, |
| 710 | 702 | ||
| 711 | // values, not types | 703 | // values, not types |
| ... | @@ -2872,11 +2864,62 @@ pub fn fieldPtrType(ptr_ty: Type, field_index: u32, pt: Zcu.PerThread) Allocator | ... | @@ -2872,11 +2864,62 @@ pub fn fieldPtrType(ptr_ty: Type, field_index: u32, pt: Zcu.PerThread) Allocator |
| 2872 | const ptr_info = ip.indexToKey(ptr_ty.toIntern()).ptr_type; | 2864 | const ptr_info = ip.indexToKey(ptr_ty.toIntern()).ptr_type; |
| 2873 | assert(ptr_info.flags.size == .one or ptr_info.flags.size == .c); | 2865 | assert(ptr_info.flags.size == .one or ptr_info.flags.size == .c); |
| 2874 | const aggregate_ty: Type = .fromInterned(ptr_info.child); | 2866 | const aggregate_ty: Type = .fromInterned(ptr_info.child); |
| 2867 | |||
| 2868 | var field_ptr_info = ptr_info; | ||
| 2869 | |||
| 2870 | field_ptr_info.child = if (aggregate_ty.isSlice(zcu)) switch (field_index) { | ||
| 2871 | Value.slice_ptr_index => aggregate_ty.slicePtrFieldType(zcu).toIntern(), | ||
| 2872 | Value.slice_len_index => .usize_type, | ||
| 2873 | else => unreachable, | ||
| 2874 | } else aggregate_ty.fieldType(field_index, zcu).toIntern(); | ||
| 2875 | |||
| 2876 | field_ptr_info.flags.alignment = aggregate_ty.fieldPtrAlign(ptr_info.flags.alignment, field_index, zcu); | ||
| 2877 | |||
| 2878 | if (aggregate_ty.zigTypeTag(zcu) == .@"struct" and | ||
| 2879 | aggregate_ty.containerLayout(zcu) == .@"packed") | ||
| 2880 | { | ||
| 2881 | field_ptr_info.packed_offset = packed_offset: { | ||
| 2882 | comptime assert(Type.packed_struct_layout_version == 2); | ||
| 2883 | const bit_offset = zcu.structPackedFieldBitOffset( | ||
| 2884 | ip.loadStructType(aggregate_ty.toIntern()), | ||
| 2885 | field_index, | ||
| 2886 | ); | ||
| 2887 | break :packed_offset if (ptr_info.packed_offset.host_size != 0) .{ | ||
| 2888 | .host_size = ptr_info.packed_offset.host_size, | ||
| 2889 | .bit_offset = ptr_info.packed_offset.bit_offset + bit_offset, | ||
| 2890 | } else .{ | ||
| 2891 | .host_size = switch (zcu.comp.getZigBackend()) { | ||
| 2892 | else => @intCast((aggregate_ty.bitSize(zcu) + 7) / 8), | ||
| 2893 | .stage2_x86_64, .stage2_c => @intCast(aggregate_ty.abiSize(zcu)), | ||
| 2894 | }, | ||
| 2895 | .bit_offset = ptr_info.packed_offset.bit_offset + bit_offset, | ||
| 2896 | }; | ||
| 2897 | }; | ||
| 2898 | } | ||
| 2899 | |||
| 2900 | return pt.ptrType(field_ptr_info); | ||
| 2901 | } | ||
| 2902 | |||
| 2903 | pub fn fieldPtrAlign( | ||
| 2904 | aggregate_ty: Type, | ||
| 2905 | aggregate_ptr_align: Alignment, | ||
| 2906 | field_index: u32, | ||
| 2907 | zcu: *const Zcu, | ||
| 2908 | ) Alignment { | ||
| 2909 | const ip = &zcu.intern_pool; | ||
| 2910 | |||
| 2875 | aggregate_ty.assertHasLayout(zcu); | 2911 | aggregate_ty.assertHasLayout(zcu); |
| 2912 | |||
| 2913 | const aggregate_ty_align = aggregate_ty.abiAlignment(zcu); | ||
| 2914 | const aggregate_align: Alignment = switch (aggregate_ptr_align) { | ||
| 2915 | .none => aggregate_ty_align, | ||
| 2916 | else => |a| a, | ||
| 2917 | }; | ||
| 2918 | |||
| 2876 | // We only exit this `switch` for default-layout aggregates, where the field pointer alignment | 2919 | // We only exit this `switch` for default-layout aggregates, where the field pointer alignment |
| 2877 | // is a simple minimum of the aggregate pointer alignment and the field alignment. | 2920 | // is a simple minimum of the aggregate pointer alignment and the field alignment. |
| 2878 | // `field_align` is `.none` if there is no explicit alignment annotation. | 2921 | // `field_explicit_align` is `.none` if there is no explicit alignment annotation. |
| 2879 | const field_ty: Type, const field_align: Alignment = switch (aggregate_ty.zigTypeTag(zcu)) { | 2922 | const field_ty: Type, const field_explicit_align: Alignment = switch (aggregate_ty.zigTypeTag(zcu)) { |
| 2880 | .@"struct" => switch (aggregate_ty.containerLayout(zcu)) { | 2923 | .@"struct" => switch (aggregate_ty.containerLayout(zcu)) { |
| 2881 | .auto => field: { | 2924 | .auto => field: { |
| 2882 | if (aggregate_ty.isTuple(zcu)) { | 2925 | if (aggregate_ty.isTuple(zcu)) { |
| ... | @@ -2893,56 +2936,21 @@ pub fn fieldPtrType(ptr_ty: Type, field_index: u32, pt: Zcu.PerThread) Allocator | ... | @@ -2893,56 +2936,21 @@ pub fn fieldPtrType(ptr_ty: Type, field_index: u32, pt: Zcu.PerThread) Allocator |
| 2893 | // `extern struct { x: u32, y: u16 }`, the `y` field is 4-byte aligned. | 2936 | // `extern struct { x: u32, y: u16 }`, the `y` field is 4-byte aligned. |
| 2894 | const field_ty = aggregate_ty.fieldType(field_index, zcu); | 2937 | const field_ty = aggregate_ty.fieldType(field_index, zcu); |
| 2895 | const field_offset = aggregate_ty.structFieldOffset(field_index, zcu); | 2938 | const field_offset = aggregate_ty.structFieldOffset(field_index, zcu); |
| 2896 | const parent_align = switch (ptr_info.flags.alignment) { | 2939 | const field_align = aggregate_align.offset(field_offset); |
| 2897 | .none => aggregate_ty.abiAlignment(zcu), | 2940 | |
| 2898 | else => |a| a, | 2941 | if (aggregate_ptr_align == .none and |
| 2899 | }; | 2942 | aggregate_ty.explicitFieldAlignment(field_index, zcu) == .none and |
| 2900 | const actual_field_align = switch (field_offset) { | 2943 | field_align == field_ty.abiAlignment(zcu)) |
| 2901 | 0 => parent_align, | 2944 | { |
| 2902 | else => parent_align.minStrict(.fromLog2Units(@ctz(field_offset))), | 2945 | // There's no user-specified 'align' in sight, and the alignment from the |
| 2903 | }; | 2946 | // field offset matches the field type's natural alignment, so just use a |
| 2904 | const field_ptr_align: Alignment = a: { | 2947 | // default-aligned pointer. |
| 2905 | if (ptr_info.flags.alignment == .none and | 2948 | return .none; |
| 2906 | aggregate_ty.explicitFieldAlignment(field_index, zcu) == .none and | ||
| 2907 | actual_field_align == field_ty.abiAlignment(zcu)) | ||
| 2908 | { | ||
| 2909 | // There's no user-specified 'align' in sight, and the alignment from the | ||
| 2910 | // field offset matches the field type's natural alignment, so just use a | ||
| 2911 | // default-aligned pointer. | ||
| 2912 | break :a .none; | ||
| 2913 | } | ||
| 2914 | break :a actual_field_align; | ||
| 2915 | }; | ||
| 2916 | var field_ptr_info = ptr_info; | ||
| 2917 | field_ptr_info.child = field_ty.toIntern(); | ||
| 2918 | field_ptr_info.flags.alignment = field_ptr_align; | ||
| 2919 | return pt.ptrType(field_ptr_info); | ||
| 2920 | }, | ||
| 2921 | .@"packed" => { | ||
| 2922 | var field_ptr_info = ptr_info; | ||
| 2923 | if (field_ptr_info.flags.alignment == .none) { | ||
| 2924 | field_ptr_info.flags.alignment = aggregate_ty.abiAlignment(zcu); | ||
| 2925 | } | 2949 | } |
| 2926 | field_ptr_info.packed_offset = packed_offset: { | 2950 | |
| 2927 | comptime assert(Type.packed_struct_layout_version == 2); | 2951 | return field_align; |
| 2928 | const bit_offset = zcu.structPackedFieldBitOffset( | ||
| 2929 | ip.loadStructType(aggregate_ty.toIntern()), | ||
| 2930 | field_index, | ||
| 2931 | ); | ||
| 2932 | break :packed_offset if (ptr_info.packed_offset.host_size != 0) .{ | ||
| 2933 | .host_size = ptr_info.packed_offset.host_size, | ||
| 2934 | .bit_offset = ptr_info.packed_offset.bit_offset + bit_offset, | ||
| 2935 | } else .{ | ||
| 2936 | .host_size = switch (zcu.comp.getZigBackend()) { | ||
| 2937 | else => @intCast((aggregate_ty.bitSize(zcu) + 7) / 8), | ||
| 2938 | .stage2_x86_64, .stage2_c => @intCast(aggregate_ty.abiSize(zcu)), | ||
| 2939 | }, | ||
| 2940 | .bit_offset = ptr_info.packed_offset.bit_offset + bit_offset, | ||
| 2941 | }; | ||
| 2942 | }; | ||
| 2943 | field_ptr_info.child = aggregate_ty.fieldType(field_index, zcu).toIntern(); | ||
| 2944 | return pt.ptrType(field_ptr_info); | ||
| 2945 | }, | 2952 | }, |
| 2953 | .@"packed" => return aggregate_align, | ||
| 2946 | }, | 2954 | }, |
| 2947 | .@"union" => switch (aggregate_ty.containerLayout(zcu)) { | 2955 | .@"union" => switch (aggregate_ty.containerLayout(zcu)) { |
| 2948 | .auto => field: { | 2956 | .auto => field: { |
| ... | @@ -2952,30 +2960,14 @@ pub fn fieldPtrType(ptr_ty: Type, field_index: u32, pt: Zcu.PerThread) Allocator | ... | @@ -2952,30 +2960,14 @@ pub fn fieldPtrType(ptr_ty: Type, field_index: u32, pt: Zcu.PerThread) Allocator |
| 2952 | union_obj.field_aligns.getOrNone(ip, field_index), | 2960 | union_obj.field_aligns.getOrNone(ip, field_index), |
| 2953 | }; | 2961 | }; |
| 2954 | }, | 2962 | }, |
| 2955 | .@"extern" => { | 2963 | .@"extern", .@"packed" => { |
| 2956 | // The alignment always matches that of the union pointer. If the union pointer is | 2964 | // The alignment always matches that of the union pointer. If the union pointer is |
| 2957 | // default aligned (`.none`), we may need to explicitly align the result pointer. | 2965 | // default aligned (`.none`), we may need to explicitly align the result pointer. |
| 2958 | const field_ty = aggregate_ty.fieldType(field_index, zcu); | 2966 | const field_ty_align = aggregate_ty.fieldType(field_index, zcu).abiAlignment(zcu); |
| 2959 | var field_ptr_info = ptr_info; | 2967 | return switch (aggregate_ptr_align) { |
| 2960 | field_ptr_info.child = field_ty.toIntern(); | 2968 | .none => if (field_ty_align == aggregate_ty_align) .none else aggregate_ty_align, |
| 2961 | if (field_ptr_info.flags.alignment == .none and | 2969 | else => |a| a, |
| 2962 | Alignment.compareStrict(field_ty.abiAlignment(zcu), .neq, aggregate_ty.abiAlignment(zcu))) | 2970 | }; |
| 2963 | { | ||
| 2964 | field_ptr_info.flags.alignment = aggregate_ty.abiAlignment(zcu); | ||
| 2965 | } | ||
| 2966 | return pt.ptrType(field_ptr_info); | ||
| 2967 | }, | ||
| 2968 | .@"packed" => { | ||
| 2969 | const field_ty = aggregate_ty.fieldType(field_index, zcu); | ||
| 2970 | var field_ptr_info = ptr_info; | ||
| 2971 | if (field_ptr_info.flags.alignment == .none) { | ||
| 2972 | const resolved_align = aggregate_ty.abiAlignment(zcu); | ||
| 2973 | if (field_ty.abiAlignment(zcu) != resolved_align) { | ||
| 2974 | field_ptr_info.flags.alignment = resolved_align; | ||
| 2975 | } | ||
| 2976 | } | ||
| 2977 | field_ptr_info.child = aggregate_ty.fieldType(field_index, zcu).toIntern(); | ||
| 2978 | return pt.ptrType(field_ptr_info); | ||
| 2979 | }, | 2971 | }, |
| 2980 | }, | 2972 | }, |
| 2981 | .pointer => field: { | 2973 | .pointer => field: { |
| ... | @@ -2988,39 +2980,31 @@ pub fn fieldPtrType(ptr_ty: Type, field_index: u32, pt: Zcu.PerThread) Allocator | ... | @@ -2988,39 +2980,31 @@ pub fn fieldPtrType(ptr_ty: Type, field_index: u32, pt: Zcu.PerThread) Allocator |
| 2988 | }, | 2980 | }, |
| 2989 | else => unreachable, | 2981 | else => unreachable, |
| 2990 | }; | 2982 | }; |
| 2991 | const field_ptr_align: Alignment = a: { | 2983 | if (aggregate_ty.zigTypeTag(zcu) == .@"struct" and |
| 2992 | if (aggregate_ty.zigTypeTag(zcu) == .@"struct" and aggregate_ty.structFieldIsComptime(field_index, zcu)) { | 2984 | aggregate_ty.structFieldIsComptime(field_index, zcu)) |
| 2993 | // For `comptime` fields, just use exactly what was specified, or ABI alignment if nothing was specified. | 2985 | { |
| 2994 | break :a field_align; | 2986 | // For `comptime` fields, just use exactly what was specified, or ABI alignment if nothing was specified. |
| 2995 | } | 2987 | return field_explicit_align; |
| 2996 | const actual_field_align = switch (field_align) { | 2988 | } |
| 2997 | .none => switch (ip.indexToKey(aggregate_ty.toIntern())) { | 2989 | const field_align = switch (field_explicit_align) { |
| 2998 | .struct_type, .tuple_type, .union_type => field_ty.abiAlignment(zcu), | 2990 | .none => switch (ip.indexToKey(aggregate_ty.toIntern())) { |
| 2999 | .ptr_type => Type.usize.abiAlignment(zcu), | 2991 | .struct_type, .tuple_type, .union_type => field_ty.abiAlignment(zcu), |
| 3000 | else => unreachable, | 2992 | .ptr_type => Type.usize.abiAlignment(zcu), |
| 3001 | }, | 2993 | else => unreachable, |
| 3002 | else => |a| a, | 2994 | }, |
| 3003 | }; | 2995 | else => |a| a, |
| 3004 | const actual_aggregate_align = switch (ptr_info.flags.alignment) { | ||
| 3005 | .none => aggregate_ty.abiAlignment(zcu), | ||
| 3006 | else => |a| a, | ||
| 3007 | }; | ||
| 3008 | if (actual_aggregate_align.compareStrict(.lt, actual_field_align)) { | ||
| 3009 | // Underaligned aggregate; use that alignment. | ||
| 3010 | assert(ptr_info.flags.alignment != .none); | ||
| 3011 | break :a actual_aggregate_align; | ||
| 3012 | } | ||
| 3013 | if (field_align == .none and actual_field_align == field_ty.abiAlignment(zcu)) { | ||
| 3014 | // No explicit annotation on the field (nor an unusual default), and the aggregate | ||
| 3015 | // alignment is irrelevant to us, so return an un-annotated pointer. | ||
| 3016 | break :a .none; | ||
| 3017 | } | ||
| 3018 | break :a actual_field_align; | ||
| 3019 | }; | 2996 | }; |
| 3020 | var field_ptr_info = ptr_info; | 2997 | if (aggregate_align.compareStrict(.lt, field_align)) { |
| 3021 | field_ptr_info.flags.alignment = field_ptr_align; | 2998 | // Underaligned aggregate; use that alignment. |
| 3022 | field_ptr_info.child = field_ty.toIntern(); | 2999 | assert(aggregate_ptr_align == aggregate_align); |
| 3023 | return pt.ptrType(field_ptr_info); | 3000 | return aggregate_align; |
| 3001 | } | ||
| 3002 | if (field_explicit_align == .none and field_align == field_ty.abiAlignment(zcu)) { | ||
| 3003 | // No explicit annotation on the field (nor an unusual default), and the aggregate | ||
| 3004 | // alignment is irrelevant to us, so return an un-annotated pointer. | ||
| 3005 | return .none; | ||
| 3006 | } | ||
| 3007 | return field_align; | ||
| 3024 | } | 3008 | } |
| 3025 | 3009 | ||
| 3026 | pub fn containerTypeName(ty: Type, ip: *const InternPool) struct { | 3010 | pub fn containerTypeName(ty: Type, ip: *const InternPool) struct { |
| ... | @@ -3359,8 +3343,7 @@ pub fn assertHasLayout(ty: Type, zcu: *const Zcu) void { | ... | @@ -3359,8 +3343,7 @@ pub fn assertHasLayout(ty: Type, zcu: *const Zcu) void { |
| 3359 | } | 3343 | } |
| 3360 | 3344 | ||
| 3361 | /// Recursively walks the type and marks for each subtype how many times it has been seen | 3345 | /// Recursively walks the type and marks for each subtype how many times it has been seen |
| 3362 | fn collectSubtypes(ty: Type, pt: Zcu.PerThread, visited: *std.array_hash_map.Auto(Type, u16)) error{OutOfMemory}!void { | 3346 | fn collectSubtypes(ty: Type, zcu: *Zcu, visited: *std.array_hash_map.Auto(Type, u16)) error{OutOfMemory}!void { |
| 3363 | const zcu = pt.zcu; | ||
| 3364 | const ip = &zcu.intern_pool; | 3347 | const ip = &zcu.intern_pool; |
| 3365 | 3348 | ||
| 3366 | const gop = try visited.getOrPut(zcu.gpa, ty); | 3349 | const gop = try visited.getOrPut(zcu.gpa, ty); |
| ... | @@ -3371,34 +3354,34 @@ fn collectSubtypes(ty: Type, pt: Zcu.PerThread, visited: *std.array_hash_map.Aut | ... | @@ -3371,34 +3354,34 @@ fn collectSubtypes(ty: Type, pt: Zcu.PerThread, visited: *std.array_hash_map.Aut |
| 3371 | } | 3354 | } |
| 3372 | 3355 | ||
| 3373 | switch (ip.indexToKey(ty.toIntern())) { | 3356 | switch (ip.indexToKey(ty.toIntern())) { |
| 3374 | .ptr_type => try collectSubtypes(Type.fromInterned(ty.ptrInfo(zcu).child), pt, visited), | 3357 | .ptr_type => try collectSubtypes(Type.fromInterned(ty.ptrInfo(zcu).child), zcu, visited), |
| 3375 | .array_type => |array_type| try collectSubtypes(Type.fromInterned(array_type.child), pt, visited), | 3358 | .array_type => |array_type| try collectSubtypes(Type.fromInterned(array_type.child), zcu, visited), |
| 3376 | .vector_type => |vector_type| try collectSubtypes(Type.fromInterned(vector_type.child), pt, visited), | 3359 | .vector_type => |vector_type| try collectSubtypes(Type.fromInterned(vector_type.child), zcu, visited), |
| 3377 | .opt_type => |child| try collectSubtypes(Type.fromInterned(child), pt, visited), | 3360 | .opt_type => |child| try collectSubtypes(Type.fromInterned(child), zcu, visited), |
| 3378 | .error_union_type => |error_union_type| { | 3361 | .error_union_type => |error_union_type| { |
| 3379 | try collectSubtypes(Type.fromInterned(error_union_type.error_set_type), pt, visited); | 3362 | try collectSubtypes(Type.fromInterned(error_union_type.error_set_type), zcu, visited); |
| 3380 | if (error_union_type.payload_type != .generic_poison_type) { | 3363 | if (error_union_type.payload_type != .generic_poison_type) { |
| 3381 | try collectSubtypes(Type.fromInterned(error_union_type.payload_type), pt, visited); | 3364 | try collectSubtypes(Type.fromInterned(error_union_type.payload_type), zcu, visited); |
| 3382 | } | 3365 | } |
| 3383 | }, | 3366 | }, |
| 3384 | .tuple_type => |tuple| { | 3367 | .tuple_type => |tuple| { |
| 3385 | for (tuple.types.get(ip)) |field_ty| { | 3368 | for (tuple.types.get(ip)) |field_ty| { |
| 3386 | try collectSubtypes(Type.fromInterned(field_ty), pt, visited); | 3369 | try collectSubtypes(Type.fromInterned(field_ty), zcu, visited); |
| 3387 | } | 3370 | } |
| 3388 | }, | 3371 | }, |
| 3389 | .func_type => |fn_info| { | 3372 | .func_type => |fn_info| { |
| 3390 | const param_types = fn_info.param_types.get(&zcu.intern_pool); | 3373 | const param_types = fn_info.param_types.get(&zcu.intern_pool); |
| 3391 | for (param_types) |param_ty| { | 3374 | for (param_types) |param_ty| { |
| 3392 | if (param_ty != .generic_poison_type) { | 3375 | if (param_ty != .generic_poison_type) { |
| 3393 | try collectSubtypes(Type.fromInterned(param_ty), pt, visited); | 3376 | try collectSubtypes(Type.fromInterned(param_ty), zcu, visited); |
| 3394 | } | 3377 | } |
| 3395 | } | 3378 | } |
| 3396 | 3379 | ||
| 3397 | if (fn_info.return_type != .generic_poison_type) { | 3380 | if (fn_info.return_type != .generic_poison_type) { |
| 3398 | try collectSubtypes(Type.fromInterned(fn_info.return_type), pt, visited); | 3381 | try collectSubtypes(Type.fromInterned(fn_info.return_type), zcu, visited); |
| 3399 | } | 3382 | } |
| 3400 | }, | 3383 | }, |
| 3401 | .anyframe_type => |child| try collectSubtypes(Type.fromInterned(child), pt, visited), | 3384 | .anyframe_type => |child| try collectSubtypes(Type.fromInterned(child), zcu, visited), |
| 3402 | 3385 | ||
| 3403 | // leaf types | 3386 | // leaf types |
| 3404 | .undef, | 3387 | .undef, |
| ... | @@ -3435,7 +3418,7 @@ fn collectSubtypes(ty: Type, pt: Zcu.PerThread, visited: *std.array_hash_map.Aut | ... | @@ -3435,7 +3418,7 @@ fn collectSubtypes(ty: Type, pt: Zcu.PerThread, visited: *std.array_hash_map.Aut |
| 3435 | } | 3418 | } |
| 3436 | } | 3419 | } |
| 3437 | 3420 | ||
| 3438 | fn shouldDedupeType(ty: Type, ctx: *Comparison, pt: Zcu.PerThread) error{OutOfMemory}!Comparison.DedupeEntry { | 3421 | fn shouldDedupeType(ty: Type, ctx: *Comparison, zcu: *Zcu) error{OutOfMemory}!Comparison.DedupeEntry { |
| 3439 | if (ctx.type_occurrences.get(ty)) |occ| { | 3422 | if (ctx.type_occurrences.get(ty)) |occ| { |
| 3440 | if (ctx.type_dedupe_cache.get(ty)) |cached| { | 3423 | if (ctx.type_dedupe_cache.get(ty)) |cached| { |
| 3441 | return cached; | 3424 | return cached; |
| ... | @@ -3443,7 +3426,7 @@ fn shouldDedupeType(ty: Type, ctx: *Comparison, pt: Zcu.PerThread) error{OutOfMe | ... | @@ -3443,7 +3426,7 @@ fn shouldDedupeType(ty: Type, ctx: *Comparison, pt: Zcu.PerThread) error{OutOfMe |
| 3443 | 3426 | ||
| 3444 | var discarding: std.Io.Writer.Discarding = .init(&.{}); | 3427 | var discarding: std.Io.Writer.Discarding = .init(&.{}); |
| 3445 | 3428 | ||
| 3446 | print(ty, &discarding.writer, pt, null) catch | 3429 | print(ty, &discarding.writer, zcu, null) catch |
| 3447 | unreachable; // we are writing into a discarding writer, it should never fail | 3430 | unreachable; // we are writing into a discarding writer, it should never fail |
| 3448 | 3431 | ||
| 3449 | const type_len: i32 = @intCast(discarding.count); | 3432 | const type_len: i32 = @intCast(discarding.count); |
| ... | @@ -3460,7 +3443,7 @@ fn shouldDedupeType(ty: Type, ctx: *Comparison, pt: Zcu.PerThread) error{OutOfMe | ... | @@ -3460,7 +3443,7 @@ fn shouldDedupeType(ty: Type, ctx: *Comparison, pt: Zcu.PerThread) error{OutOfMe |
| 3460 | break :b .{ .dedupe = .{ .index = ctx.placeholder_index - 1 } }; | 3443 | break :b .{ .dedupe = .{ .index = ctx.placeholder_index - 1 } }; |
| 3461 | } else .dont_dedupe; | 3444 | } else .dont_dedupe; |
| 3462 | 3445 | ||
| 3463 | try ctx.type_dedupe_cache.put(pt.zcu.gpa, ty, entry); | 3446 | try ctx.type_dedupe_cache.put(zcu.comp.gpa, ty, entry); |
| 3464 | 3447 | ||
| 3465 | return entry; | 3448 | return entry; |
| 3466 | } else { | 3449 | } else { |
| ... | @@ -3491,38 +3474,37 @@ pub const Comparison = struct { | ... | @@ -3491,38 +3474,37 @@ pub const Comparison = struct { |
| 3491 | dedupe: Placeholder, | 3474 | dedupe: Placeholder, |
| 3492 | }; | 3475 | }; |
| 3493 | 3476 | ||
| 3494 | pub fn init(types: []const Type, pt: Zcu.PerThread) error{OutOfMemory}!Comparison { | 3477 | pub fn init(types: []const Type, zcu: *Zcu) error{OutOfMemory}!Comparison { |
| 3495 | var cmp: Comparison = .{ | 3478 | var cmp: Comparison = .{ |
| 3496 | .type_occurrences = .empty, | 3479 | .type_occurrences = .empty, |
| 3497 | .type_dedupe_cache = .empty, | 3480 | .type_dedupe_cache = .empty, |
| 3498 | .placeholder_index = 0, | 3481 | .placeholder_index = 0, |
| 3499 | }; | 3482 | }; |
| 3500 | 3483 | ||
| 3501 | errdefer cmp.deinit(pt); | 3484 | errdefer cmp.deinit(zcu.comp.gpa); |
| 3502 | 3485 | ||
| 3503 | for (types) |ty| { | 3486 | for (types) |ty| { |
| 3504 | try collectSubtypes(ty, pt, &cmp.type_occurrences); | 3487 | try collectSubtypes(ty, zcu, &cmp.type_occurrences); |
| 3505 | } | 3488 | } |
| 3506 | 3489 | ||
| 3507 | return cmp; | 3490 | return cmp; |
| 3508 | } | 3491 | } |
| 3509 | 3492 | ||
| 3510 | pub fn deinit(cmp: *Comparison, pt: Zcu.PerThread) void { | 3493 | pub fn deinit(cmp: *Comparison, gpa: Allocator) void { |
| 3511 | const gpa = pt.zcu.gpa; | ||
| 3512 | cmp.type_occurrences.deinit(gpa); | 3494 | cmp.type_occurrences.deinit(gpa); |
| 3513 | cmp.type_dedupe_cache.deinit(gpa); | 3495 | cmp.type_dedupe_cache.deinit(gpa); |
| 3514 | } | 3496 | } |
| 3515 | 3497 | ||
| 3516 | pub fn fmtType(ctx: *Comparison, ty: Type, pt: Zcu.PerThread) Comparison.Formatter { | 3498 | pub fn fmtType(ctx: *Comparison, ty: Type, zcu: *Zcu) Comparison.Formatter { |
| 3517 | return .{ .ty = ty, .ctx = ctx, .pt = pt }; | 3499 | return .{ .ty = ty, .ctx = ctx, .zcu = zcu }; |
| 3518 | } | 3500 | } |
| 3519 | pub const Formatter = struct { | 3501 | pub const Formatter = struct { |
| 3520 | ty: Type, | 3502 | ty: Type, |
| 3521 | ctx: *Comparison, | 3503 | ctx: *Comparison, |
| 3522 | pt: Zcu.PerThread, | 3504 | zcu: *Zcu, |
| 3523 | 3505 | ||
| 3524 | pub fn format(self: Comparison.Formatter, writer: anytype) error{WriteFailed}!void { | 3506 | pub fn format(self: Comparison.Formatter, writer: anytype) error{WriteFailed}!void { |
| 3525 | print(self.ty, writer, self.pt, self.ctx) catch return error.WriteFailed; | 3507 | print(self.ty, writer, self.zcu, self.ctx) catch return error.WriteFailed; |
| 3526 | } | 3508 | } |
| 3527 | }; | 3509 | }; |
| 3528 | }; | 3510 | }; |
src/Value.zig+326-201| ... | @@ -34,19 +34,19 @@ pub fn fmtDebug(val: Value) std.fmt.Alt(Value, dump) { | ... | @@ -34,19 +34,19 @@ pub fn fmtDebug(val: Value) std.fmt.Alt(Value, dump) { |
| 34 | return .{ .data = val }; | 34 | return .{ .data = val }; |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | pub fn fmtValue(val: Value, pt: Zcu.PerThread) std.fmt.Alt(print_value.FormatContext, print_value.format) { | 37 | pub fn fmtValue(val: Value, zcu: *Zcu) std.fmt.Alt(print_value.FormatContext, print_value.format) { |
| 38 | return .{ .data = .{ | 38 | return .{ .data = .{ |
| 39 | .val = val, | 39 | .val = val, |
| 40 | .pt = pt, | 40 | .zcu = zcu, |
| 41 | .opt_sema = null, | 41 | .opt_sema = null, |
| 42 | .depth = 3, | 42 | .depth = 3, |
| 43 | } }; | 43 | } }; |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | pub fn fmtValueSema(val: Value, pt: Zcu.PerThread, sema: *Sema) std.fmt.Alt(print_value.FormatContext, print_value.formatSema) { | 46 | pub fn fmtValueSema(val: Value, sema: *Sema) std.fmt.Alt(print_value.FormatContext, print_value.formatSema) { |
| 47 | return .{ .data = .{ | 47 | return .{ .data = .{ |
| 48 | .val = val, | 48 | .val = val, |
| 49 | .pt = pt, | 49 | .zcu = sema.pt.zcu, |
| 50 | .opt_sema = sema, | 50 | .opt_sema = sema, |
| 51 | .depth = 3, | 51 | .depth = 3, |
| 52 | } }; | 52 | } }; |
| ... | @@ -1890,167 +1890,233 @@ pub fn getOffsetPtr(ptr_val: Value, byte_off: u64, new_ty: Type, pt: Zcu.PerThre | ... | @@ -1890,167 +1890,233 @@ pub fn getOffsetPtr(ptr_val: Value, byte_off: u64, new_ty: Type, pt: Zcu.PerThre |
| 1890 | return Value.fromInterned(try pt.intern(.{ .ptr = ptr })); | 1890 | return Value.fromInterned(try pt.intern(.{ .ptr = ptr })); |
| 1891 | } | 1891 | } |
| 1892 | 1892 | ||
| 1893 | pub const PointerDeriveStep = union(enum) { | 1893 | pub const PointerDerivation = struct { |
| 1894 | int: struct { | 1894 | elem_ty: Type, |
| 1895 | addr: u64, | 1895 | /// TODO: investigate eliminating this field. We should *always* know the lengths of arrays |
| 1896 | ptr_ty: Type, | 1896 | /// which are pointed to, so `.one` should be the only possible case! |
| 1897 | }, | 1897 | size: Size, |
| 1898 | nav_ptr: InternPool.Nav.Index, | 1898 | @"align": InternPool.Alignment, |
| 1899 | uav_ptr: InternPool.Key.Ptr.BaseAddr.Uav, | 1899 | @"const": bool, |
| 1900 | comptime_alloc_ptr: struct { | 1900 | @"volatile": bool, |
| 1901 | idx: InternPool.ComptimeAllocIndex, | 1901 | @"allowzero": bool, |
| 1902 | val: Value, | 1902 | |
| 1903 | ptr_ty: Type, | 1903 | addr: union(enum) { |
| 1904 | }, | 1904 | int: u64, |
| 1905 | comptime_field_ptr: Value, | 1905 | nav: InternPool.Nav.Index, |
| 1906 | eu_payload_ptr: struct { | 1906 | uav: Value, |
| 1907 | parent: *PointerDeriveStep, | 1907 | comptime_field: Value, |
| 1908 | /// This type will never be cast: it is provided for convenience. | 1908 | comptime_alloc: struct { |
| 1909 | result_ptr_ty: Type, | 1909 | idx: InternPool.ComptimeAllocIndex, |
| 1910 | }, | 1910 | val: Value, |
| 1911 | opt_payload_ptr: struct { | 1911 | }, |
| 1912 | parent: *PointerDeriveStep, | 1912 | eu_payload: struct { parent: *PointerDerivation }, |
| 1913 | /// This type will never be cast: it is provided for convenience. | 1913 | opt_payload: struct { parent: *PointerDerivation }, |
| 1914 | result_ptr_ty: Type, | 1914 | field: struct { |
| 1915 | }, | 1915 | parent: *PointerDerivation, |
| 1916 | field_ptr: struct { | 1916 | field_index: u32, |
| 1917 | parent: *PointerDeriveStep, | 1917 | }, |
| 1918 | field_idx: u32, | 1918 | elem: struct { |
| 1919 | /// This type will never be cast: it is provided for convenience. | 1919 | parent: *PointerDerivation, |
| 1920 | result_ptr_ty: Type, | 1920 | elem_index: u64, |
| 1921 | }, | 1921 | }, |
| 1922 | elem_ptr: struct { | 1922 | offset_and_cast: struct { |
| 1923 | parent: *PointerDeriveStep, | 1923 | parent: *PointerDerivation, |
| 1924 | elem_idx: u64, | 1924 | byte_offset: u64, |
| 1925 | /// This type will never be cast: it is provided for convenience. | 1925 | }, |
| 1926 | result_ptr_ty: Type, | ||
| 1927 | }, | ||
| 1928 | offset_and_cast: struct { | ||
| 1929 | parent: *PointerDeriveStep, | ||
| 1930 | byte_offset: u64, | ||
| 1931 | new_ptr_ty: Type, | ||
| 1932 | }, | 1926 | }, |
| 1933 | 1927 | ||
| 1934 | pub fn ptrType(step: PointerDeriveStep, pt: Zcu.PerThread) !Type { | 1928 | pub const Size = enum { one, many }; |
| 1935 | return switch (step) { | 1929 | |
| 1936 | .int => |int| int.ptr_ty, | 1930 | pub fn fmtType(pd: PointerDerivation, zcu: *Zcu) FormatType { |
| 1937 | .nav_ptr => |nav| try pt.navPtrType(nav), | 1931 | return .{ .pd = pd, .zcu = zcu }; |
| 1938 | .uav_ptr => |uav| Type.fromInterned(uav.orig_ty), | ||
| 1939 | .comptime_alloc_ptr => |info| info.ptr_ty, | ||
| 1940 | .comptime_field_ptr => |val| try pt.singleConstPtrType(val.typeOf(pt.zcu)), | ||
| 1941 | .offset_and_cast => |oac| oac.new_ptr_ty, | ||
| 1942 | inline .eu_payload_ptr, .opt_payload_ptr, .field_ptr, .elem_ptr => |x| x.result_ptr_ty, | ||
| 1943 | }; | ||
| 1944 | } | 1932 | } |
| 1933 | pub const FormatType = struct { | ||
| 1934 | pd: PointerDerivation, | ||
| 1935 | zcu: *Zcu, | ||
| 1936 | pub fn format(ctx: FormatType, w: *Io.Writer) Io.Writer.Error!void { | ||
| 1937 | const pd = ctx.pd; | ||
| 1938 | switch (pd.size) { | ||
| 1939 | .one => try w.writeByte('*'), | ||
| 1940 | .many => try w.writeAll("[*]"), | ||
| 1941 | } | ||
| 1942 | if (pd.@"align".toByteUnits()) |align_bytes| { | ||
| 1943 | try w.print("align({d}) ", .{align_bytes}); | ||
| 1944 | } | ||
| 1945 | if (pd.@"const") try w.writeAll("const "); | ||
| 1946 | if (pd.@"volatile") try w.writeAll("volatile "); | ||
| 1947 | if (pd.@"allowzero") try w.writeAll("allowzero "); | ||
| 1948 | try pd.elem_ty.print(w, ctx.zcu, null); | ||
| 1949 | } | ||
| 1950 | }; | ||
| 1945 | }; | 1951 | }; |
| 1946 | 1952 | ||
| 1947 | /// Given a pointer value, get the sequence of steps to derive it, ideally by taking | 1953 | /// Given a pointer value, get the sequence of steps to derive it, ideally by taking |
| 1948 | /// only field and element pointers with no casts. This can be used by codegen backends | 1954 | /// only field and element pointers with no casts. This can be used by codegen backends |
| 1949 | /// which prefer field/elem accesses when lowering constant pointer values. | 1955 | /// which prefer field/elem accesses when lowering constant pointer values. |
| 1950 | /// It is also used by the Value printing logic for pointers. | 1956 | /// It is also used by the Value printing logic for pointers. |
| 1951 | pub fn pointerDerivation(ptr_val: Value, arena: Allocator, pt: Zcu.PerThread, opt_sema: ?*Sema) Allocator.Error!PointerDeriveStep { | 1957 | pub fn pointerDerivation(ptr_val: Value, arena: Allocator, zcu: *Zcu, opt_sema: ?*Sema) Allocator.Error!PointerDerivation { |
| 1952 | const zcu = pt.zcu; | ||
| 1953 | const ptr = zcu.intern_pool.indexToKey(ptr_val.toIntern()).ptr; | 1958 | const ptr = zcu.intern_pool.indexToKey(ptr_val.toIntern()).ptr; |
| 1954 | const base_derive: PointerDeriveStep = switch (ptr.base_addr) { | 1959 | const ptr_ty_info: InternPool.Key.PtrType = info: { |
| 1955 | .int => return .{ .int = .{ | 1960 | var info = Type.fromInterned(ptr.ty).ptrInfo(zcu); |
| 1956 | .addr = ptr.byte_offset, | 1961 | if (info.packed_offset.host_size != 0) { |
| 1957 | .ptr_ty = Type.fromInterned(ptr.ty), | 1962 | // TODO: this function *should* handle packed pointers by returning the derivation of |
| 1958 | } }, | 1963 | // the backing int pointer. However, until https://github.com/ziglang/zig/issues/24061 |
| 1959 | .nav => |nav| .{ .nav_ptr = nav }, | 1964 | // is implemented, we don't have access to the backing type. For now, fudge things a |
| 1965 | // little by pretending that this is a pointer to anyopaque. What could go wrong? | ||
| 1966 | info.child = .anyopaque_type; | ||
| 1967 | } | ||
| 1968 | break :info info; | ||
| 1969 | }; | ||
| 1970 | const ptr_size: PointerDerivation.Size = switch (ptr_ty_info.flags.size) { | ||
| 1971 | .one => .one, | ||
| 1972 | .many, .c => .many, | ||
| 1973 | .slice => unreachable, | ||
| 1974 | }; | ||
| 1975 | const base_derive: PointerDerivation = switch (ptr.base_addr) { | ||
| 1976 | .int => return .{ | ||
| 1977 | .elem_ty = .fromInterned(ptr_ty_info.child), | ||
| 1978 | .size = ptr_size, | ||
| 1979 | .@"align" = ptr_ty_info.flags.alignment, | ||
| 1980 | .@"const" = ptr_ty_info.flags.is_const, | ||
| 1981 | .@"volatile" = ptr_ty_info.flags.is_volatile, | ||
| 1982 | .@"allowzero" = ptr_ty_info.flags.is_allowzero, | ||
| 1983 | .addr = .{ .int = ptr.byte_offset }, | ||
| 1984 | }, | ||
| 1985 | .nav => |nav| base: { | ||
| 1986 | const resolved = zcu.intern_pool.getNav(nav).resolved.?; | ||
| 1987 | break :base .{ | ||
| 1988 | .elem_ty = .fromInterned(resolved.type), | ||
| 1989 | .size = .one, | ||
| 1990 | .@"align" = resolved.@"align", | ||
| 1991 | .@"const" = resolved.@"const", | ||
| 1992 | .@"volatile" = false, | ||
| 1993 | .@"allowzero" = false, | ||
| 1994 | .addr = .{ .nav = nav }, | ||
| 1995 | }; | ||
| 1996 | }, | ||
| 1960 | .uav => |uav| base: { | 1997 | .uav => |uav| base: { |
| 1961 | // A slight tweak: `orig_ty` here is sometimes not `const`, but it ought to be. | 1998 | const orig_ty_info = Type.fromInterned(uav.orig_ty).ptrInfo(zcu); |
| 1962 | // TODO: fix this in the sites interning anon decls! | 1999 | break :base .{ |
| 1963 | const const_ty = try pt.ptrType(info: { | 2000 | .elem_ty = .fromInterned(orig_ty_info.child), |
| 1964 | var info = Type.fromInterned(uav.orig_ty).ptrInfo(zcu); | 2001 | .size = .one, |
| 1965 | info.flags.is_const = true; | 2002 | .@"align" = orig_ty_info.flags.alignment, |
| 1966 | break :info info; | 2003 | // A slight tweak: `orig_ty` here is sometimes not `const`, but it ought to be. |
| 1967 | }); | 2004 | // TODO: fix this in the sites interning anon decls! |
| 1968 | break :base .{ .uav_ptr = .{ | 2005 | .@"const" = true, |
| 1969 | .val = uav.val, | 2006 | .@"volatile" = orig_ty_info.flags.is_volatile, |
| 1970 | .orig_ty = const_ty.toIntern(), | 2007 | .@"allowzero" = orig_ty_info.flags.is_allowzero, |
| 1971 | } }; | 2008 | |
| 2009 | .addr = .{ .uav = .fromInterned(uav.val) }, | ||
| 2010 | }; | ||
| 1972 | }, | 2011 | }, |
| 1973 | .comptime_alloc => |idx| base: { | 2012 | .comptime_alloc => |idx| base: { |
| 1974 | const sema = opt_sema.?; | 2013 | const sema = opt_sema.?; |
| 1975 | const alloc = sema.getComptimeAlloc(idx); | 2014 | const alloc = sema.getComptimeAlloc(idx); |
| 1976 | const val = try alloc.val.intern(pt, arena); | 2015 | const val = try alloc.val.intern(sema.pt, arena); |
| 1977 | const ty = val.typeOf(zcu); | 2016 | break :base .{ |
| 1978 | break :base .{ .comptime_alloc_ptr = .{ | 2017 | .elem_ty = val.typeOf(zcu), |
| 1979 | .idx = idx, | 2018 | .size = .one, |
| 1980 | .val = val, | 2019 | .@"align" = alloc.alignment, |
| 1981 | .ptr_ty = try pt.ptrType(.{ | 2020 | .@"const" = alloc.is_const, |
| 1982 | .child = ty.toIntern(), | 2021 | .@"volatile" = false, |
| 1983 | .flags = .{ | 2022 | .@"allowzero" = false, |
| 1984 | .alignment = alloc.alignment, | 2023 | .addr = .{ .comptime_alloc = .{ |
| 1985 | }, | 2024 | .idx = idx, |
| 1986 | }), | 2025 | .val = val, |
| 1987 | } }; | 2026 | } }, |
| 1988 | }, | 2027 | }; |
| 1989 | .comptime_field => |val| .{ .comptime_field_ptr = Value.fromInterned(val) }, | 2028 | }, |
| 2029 | .comptime_field => |val| .{ | ||
| 2030 | .elem_ty = Value.fromInterned(val).typeOf(zcu), | ||
| 2031 | .size = .one, | ||
| 2032 | .@"align" = .none, | ||
| 2033 | .@"const" = true, | ||
| 2034 | .@"volatile" = false, | ||
| 2035 | .@"allowzero" = false, | ||
| 2036 | .addr = .{ .comptime_field = .fromInterned(val) }, | ||
| 2037 | }, | ||
| 1990 | .eu_payload => |eu_ptr| base: { | 2038 | .eu_payload => |eu_ptr| base: { |
| 1991 | const base_ptr = Value.fromInterned(eu_ptr); | 2039 | const parent_step = try arena.create(PointerDerivation); |
| 1992 | const base_ptr_ty = base_ptr.typeOf(zcu); | 2040 | parent_step.* = try pointerDerivation(.fromInterned(eu_ptr), arena, zcu, opt_sema); |
| 1993 | const parent_step = try arena.create(PointerDeriveStep); | 2041 | break :base .{ |
| 1994 | parent_step.* = try pointerDerivation(.fromInterned(eu_ptr), arena, pt, opt_sema); | 2042 | .elem_ty = parent_step.elem_ty.errorUnionPayload(zcu), |
| 1995 | break :base .{ .eu_payload_ptr = .{ | 2043 | .size = .one, |
| 1996 | .parent = parent_step, | 2044 | .@"align" = parent_step.@"align", |
| 1997 | .result_ptr_ty = try pt.adjustPtrTypeChild(base_ptr_ty, base_ptr_ty.childType(zcu).errorUnionPayload(zcu)), | 2045 | .@"const" = parent_step.@"const", |
| 1998 | } }; | 2046 | .@"volatile" = parent_step.@"volatile", |
| 2047 | .@"allowzero" = parent_step.@"allowzero", | ||
| 2048 | .addr = .{ .eu_payload = .{ | ||
| 2049 | .parent = parent_step, | ||
| 2050 | } }, | ||
| 2051 | }; | ||
| 1999 | }, | 2052 | }, |
| 2000 | .opt_payload => |opt_ptr| base: { | 2053 | .opt_payload => |opt_ptr| base: { |
| 2001 | const base_ptr = Value.fromInterned(opt_ptr); | 2054 | const parent_step = try arena.create(PointerDerivation); |
| 2002 | const base_ptr_ty = base_ptr.typeOf(zcu); | 2055 | parent_step.* = try pointerDerivation(.fromInterned(opt_ptr), arena, zcu, opt_sema); |
| 2003 | const parent_step = try arena.create(PointerDeriveStep); | 2056 | break :base .{ |
| 2004 | parent_step.* = try pointerDerivation(.fromInterned(opt_ptr), arena, pt, opt_sema); | 2057 | .elem_ty = parent_step.elem_ty.optionalChild(zcu), |
| 2005 | break :base .{ .opt_payload_ptr = .{ | 2058 | .size = .one, |
| 2006 | .parent = parent_step, | 2059 | .@"align" = parent_step.@"align", |
| 2007 | .result_ptr_ty = try pt.adjustPtrTypeChild(base_ptr_ty, base_ptr_ty.childType(zcu).optionalChild(zcu)), | 2060 | .@"const" = parent_step.@"const", |
| 2008 | } }; | 2061 | .@"volatile" = parent_step.@"volatile", |
| 2062 | .@"allowzero" = parent_step.@"allowzero", | ||
| 2063 | .addr = .{ .opt_payload = .{ | ||
| 2064 | .parent = parent_step, | ||
| 2065 | } }, | ||
| 2066 | }; | ||
| 2009 | }, | 2067 | }, |
| 2010 | .field => |field| base: { | 2068 | .field => |field| base: { |
| 2011 | const base_ptr = Value.fromInterned(field.base); | 2069 | const parent_step = try arena.create(PointerDerivation); |
| 2012 | const base_ptr_ty = try pt.ptrType(info: { | 2070 | parent_step.* = try pointerDerivation(.fromInterned(field.base), arena, zcu, opt_sema); |
| 2013 | var info = base_ptr.typeOf(zcu).ptrInfo(zcu); | 2071 | break :base .{ |
| 2014 | info.flags.size = .one; | 2072 | .elem_ty = if (parent_step.elem_ty.isSlice(zcu)) switch (field.index) { |
| 2015 | break :info info; | 2073 | Value.slice_ptr_index => parent_step.elem_ty.slicePtrFieldType(zcu), |
| 2016 | }); | 2074 | Value.slice_len_index => .usize, |
| 2017 | const parent_step = try arena.create(PointerDeriveStep); | 2075 | else => unreachable, |
| 2018 | parent_step.* = try pointerDerivation(base_ptr, arena, pt, opt_sema); | 2076 | } else parent_step.elem_ty.fieldType(@intCast(field.index), zcu), |
| 2019 | break :base .{ .field_ptr = .{ | 2077 | .size = .one, |
| 2020 | .parent = parent_step, | 2078 | .@"align" = parent_step.elem_ty.fieldPtrAlign(parent_step.@"align", @intCast(field.index), zcu), |
| 2021 | .field_idx = @intCast(field.index), | 2079 | .@"const" = parent_step.@"const", |
| 2022 | .result_ptr_ty = try base_ptr_ty.fieldPtrType(@intCast(field.index), pt), | 2080 | .@"volatile" = parent_step.@"volatile", |
| 2023 | } }; | 2081 | .@"allowzero" = parent_step.@"allowzero", |
| 2082 | .addr = .{ .field = .{ | ||
| 2083 | .parent = parent_step, | ||
| 2084 | .field_index = @intCast(field.index), | ||
| 2085 | } }, | ||
| 2086 | }; | ||
| 2024 | }, | 2087 | }, |
| 2025 | .arr_elem => |arr_elem| base: { | 2088 | .arr_elem => |arr_elem| base: { |
| 2026 | const parent_step = try arena.create(PointerDeriveStep); | 2089 | const parent_step = try arena.create(PointerDerivation); |
| 2027 | parent_step.* = try pointerDerivation(.fromInterned(arr_elem.base), arena, pt, opt_sema); | 2090 | parent_step.* = try pointerDerivation(.fromInterned(arr_elem.base), arena, zcu, opt_sema); |
| 2028 | const parent_ptr_info = (try parent_step.ptrType(pt)).ptrInfo(zcu); | 2091 | break :base .{ |
| 2029 | const result_ptr_ty = try pt.ptrType(.{ | 2092 | .elem_ty = parent_step.elem_ty, |
| 2030 | .child = parent_ptr_info.child, | 2093 | .size = .many, |
| 2031 | .flags = flags: { | 2094 | .@"align" = switch (parent_step.@"align") { |
| 2032 | var flags = parent_ptr_info.flags; | 2095 | .none => .none, |
| 2033 | flags.size = .one; | 2096 | else => |a| a.minStrict(parent_step.elem_ty.abiAlignment(zcu)), |
| 2034 | if (flags.alignment != .none) flags.alignment = .minStrict( | ||
| 2035 | flags.alignment, | ||
| 2036 | Type.fromInterned(parent_ptr_info.child).abiAlignment(zcu), | ||
| 2037 | ); | ||
| 2038 | break :flags flags; | ||
| 2039 | }, | 2097 | }, |
| 2040 | }); | 2098 | .@"const" = parent_step.@"const", |
| 2041 | break :base .{ .elem_ptr = .{ | 2099 | .@"volatile" = parent_step.@"volatile", |
| 2042 | .parent = parent_step, | 2100 | .@"allowzero" = parent_step.@"allowzero", |
| 2043 | .elem_idx = arr_elem.index, | 2101 | .addr = .{ .elem = .{ |
| 2044 | .result_ptr_ty = result_ptr_ty, | 2102 | .parent = parent_step, |
| 2045 | } }; | 2103 | .elem_index = arr_elem.index, |
| 2104 | } }, | ||
| 2105 | }; | ||
| 2046 | }, | 2106 | }, |
| 2047 | }; | 2107 | }; |
| 2048 | 2108 | ||
| 2049 | if (ptr.byte_offset == 0 and ptr.ty == (try base_derive.ptrType(pt)).toIntern()) { | 2109 | if (ptr.byte_offset == 0 and |
| 2110 | ptr_ty_info.child == base_derive.elem_ty.toIntern() and | ||
| 2111 | ptr_size == base_derive.size and | ||
| 2112 | ptr_ty_info.flags.alignment == base_derive.@"align" and | ||
| 2113 | ptr_ty_info.flags.is_const == base_derive.@"const" and | ||
| 2114 | ptr_ty_info.flags.is_volatile == base_derive.@"volatile" and | ||
| 2115 | ptr_ty_info.flags.is_allowzero == base_derive.@"allowzero") | ||
| 2116 | { | ||
| 2050 | return base_derive; | 2117 | return base_derive; |
| 2051 | } | 2118 | } |
| 2052 | 2119 | ||
| 2053 | const ptr_ty_info = Type.fromInterned(ptr.ty).ptrInfo(zcu); | ||
| 2054 | const need_child: Type = .fromInterned(ptr_ty_info.child); | 2120 | const need_child: Type = .fromInterned(ptr_ty_info.child); |
| 2055 | if (need_child.comptimeOnly(zcu) or | 2121 | if (need_child.comptimeOnly(zcu) or |
| 2056 | need_child.zigTypeTag(zcu) == .@"opaque" or | 2122 | need_child.zigTypeTag(zcu) == .@"opaque" or |
| ... | @@ -2058,27 +2124,50 @@ pub fn pointerDerivation(ptr_val: Value, arena: Allocator, pt: Zcu.PerThread, op | ... | @@ -2058,27 +2124,50 @@ pub fn pointerDerivation(ptr_val: Value, arena: Allocator, pt: Zcu.PerThread, op |
| 2058 | { | 2124 | { |
| 2059 | // No refinement can happen - this pointer is presumably invalid. | 2125 | // No refinement can happen - this pointer is presumably invalid. |
| 2060 | // Just offset it. | 2126 | // Just offset it. |
| 2061 | const parent = try arena.create(PointerDeriveStep); | 2127 | const parent = try arena.create(PointerDerivation); |
| 2062 | parent.* = base_derive; | 2128 | parent.* = base_derive; |
| 2063 | return .{ .offset_and_cast = .{ | 2129 | return .{ |
| 2064 | .parent = parent, | 2130 | .elem_ty = .fromInterned(ptr_ty_info.child), |
| 2065 | .byte_offset = ptr.byte_offset, | 2131 | .size = ptr_size, |
| 2066 | .new_ptr_ty = Type.fromInterned(ptr.ty), | 2132 | .@"align" = ptr_ty_info.flags.alignment, |
| 2067 | } }; | 2133 | .@"const" = ptr_ty_info.flags.is_const, |
| 2134 | .@"volatile" = ptr_ty_info.flags.is_volatile, | ||
| 2135 | .@"allowzero" = ptr_ty_info.flags.is_allowzero, | ||
| 2136 | .addr = .{ .offset_and_cast = .{ | ||
| 2137 | .parent = parent, | ||
| 2138 | .byte_offset = ptr.byte_offset, | ||
| 2139 | } }, | ||
| 2140 | }; | ||
| 2068 | } | 2141 | } |
| 2069 | const need_bytes = need_child.abiSize(zcu); | 2142 | const need_bytes = need_child.abiSize(zcu); |
| 2070 | 2143 | ||
| 2071 | var cur_derive = base_derive; | 2144 | var cur_derive = base_derive; |
| 2072 | var cur_offset = ptr.byte_offset; | 2145 | var cur_offset = ptr.byte_offset; |
| 2073 | 2146 | ||
| 2147 | if (cur_derive.size == .many) { | ||
| 2148 | const parent = try arena.create(PointerDerivation); | ||
| 2149 | parent.* = cur_derive; | ||
| 2150 | cur_derive = .{ | ||
| 2151 | .elem_ty = parent.elem_ty, | ||
| 2152 | .size = .one, | ||
| 2153 | .@"align" = parent.@"align", | ||
| 2154 | .@"const" = parent.@"const", | ||
| 2155 | .@"volatile" = parent.@"volatile", | ||
| 2156 | .@"allowzero" = parent.@"allowzero", | ||
| 2157 | .addr = .{ .elem = .{ | ||
| 2158 | .parent = parent, | ||
| 2159 | .elem_index = 0, | ||
| 2160 | } }, | ||
| 2161 | }; | ||
| 2162 | } | ||
| 2163 | |||
| 2074 | // Refine through fields and array elements as much as possible. | 2164 | // Refine through fields and array elements as much as possible. |
| 2075 | 2165 | ||
| 2076 | if (need_bytes > 0) while (true) { | 2166 | if (need_bytes > 0) while (true) { |
| 2077 | const cur_ty = (try cur_derive.ptrType(pt)).childType(zcu); | 2167 | if (cur_derive.elem_ty.toIntern() == need_child.toIntern() and cur_offset == 0) { |
| 2078 | if (cur_ty.toIntern() == need_child.toIntern() and cur_offset == 0) { | ||
| 2079 | break; | 2168 | break; |
| 2080 | } | 2169 | } |
| 2081 | switch (cur_ty.zigTypeTag(zcu)) { | 2170 | switch (cur_derive.elem_ty.zigTypeTag(zcu)) { |
| 2082 | .noreturn, | 2171 | .noreturn, |
| 2083 | .type, | 2172 | .type, |
| 2084 | .comptime_int, | 2173 | .comptime_int, |
| ... | @@ -2105,71 +2194,105 @@ pub fn pointerDerivation(ptr_val: Value, arena: Allocator, pt: Zcu.PerThread, op | ... | @@ -2105,71 +2194,105 @@ pub fn pointerDerivation(ptr_val: Value, arena: Allocator, pt: Zcu.PerThread, op |
| 2105 | 2194 | ||
| 2106 | .optional => { | 2195 | .optional => { |
| 2107 | ptr_opt: { | 2196 | ptr_opt: { |
| 2108 | if (!cur_ty.isPtrLikeOptional(zcu)) break :ptr_opt; | 2197 | if (!cur_derive.elem_ty.isPtrLikeOptional(zcu)) break :ptr_opt; |
| 2109 | if (need_child.zigTypeTag(zcu) != .pointer) break :ptr_opt; | 2198 | if (need_child.zigTypeTag(zcu) != .pointer) break :ptr_opt; |
| 2110 | switch (need_child.ptrSize(zcu)) { | 2199 | switch (need_child.ptrSize(zcu)) { |
| 2111 | .one, .many => {}, | 2200 | .one, .many => {}, |
| 2112 | .slice, .c => break :ptr_opt, | 2201 | .slice, .c => break :ptr_opt, |
| 2113 | } | 2202 | } |
| 2114 | const parent = try arena.create(PointerDeriveStep); | 2203 | const parent = try arena.create(PointerDerivation); |
| 2115 | parent.* = cur_derive; | 2204 | parent.* = cur_derive; |
| 2116 | cur_derive = .{ .opt_payload_ptr = .{ | 2205 | cur_derive = .{ |
| 2117 | .parent = parent, | 2206 | .elem_ty = parent.elem_ty.optionalChild(zcu), |
| 2118 | .result_ptr_ty = try pt.adjustPtrTypeChild(try parent.ptrType(pt), cur_ty.optionalChild(zcu)), | 2207 | .size = .one, |
| 2119 | } }; | 2208 | .@"align" = parent.@"align", |
| 2209 | .@"const" = parent.@"const", | ||
| 2210 | .@"volatile" = parent.@"volatile", | ||
| 2211 | .@"allowzero" = parent.@"allowzero", | ||
| 2212 | .addr = .{ .opt_payload = .{ | ||
| 2213 | .parent = parent, | ||
| 2214 | } }, | ||
| 2215 | }; | ||
| 2120 | continue; | 2216 | continue; |
| 2121 | } | 2217 | } |
| 2122 | break; | 2218 | break; |
| 2123 | }, | 2219 | }, |
| 2124 | 2220 | ||
| 2125 | .array => { | 2221 | .array => { |
| 2126 | const elem_ty = cur_ty.childType(zcu); | 2222 | const elem_ty = cur_derive.elem_ty.childType(zcu); |
| 2127 | const elem_size = elem_ty.abiSize(zcu); | 2223 | const elem_size = elem_ty.abiSize(zcu); |
| 2128 | const start_idx = cur_offset / elem_size; | 2224 | const start_idx = cur_offset / elem_size; |
| 2129 | const end_idx = (cur_offset + need_bytes + elem_size - 1) / elem_size; | 2225 | const end_idx = (cur_offset + need_bytes + elem_size - 1) / elem_size; |
| 2226 | const start_off = start_idx * elem_size; | ||
| 2130 | if (end_idx == start_idx + 1 and ptr_ty_info.flags.size == .one) { | 2227 | if (end_idx == start_idx + 1 and ptr_ty_info.flags.size == .one) { |
| 2131 | const parent = try arena.create(PointerDeriveStep); | 2228 | const parent = try arena.create(PointerDerivation); |
| 2132 | parent.* = cur_derive; | 2229 | parent.* = cur_derive; |
| 2133 | cur_derive = .{ .elem_ptr = .{ | 2230 | cur_derive = .{ |
| 2134 | .parent = parent, | 2231 | .elem_ty = elem_ty, |
| 2135 | .elem_idx = start_idx, | 2232 | .size = .one, |
| 2136 | .result_ptr_ty = try pt.adjustPtrTypeChild(try parent.ptrType(pt), elem_ty), | 2233 | .@"align" = switch (parent.@"align") { |
| 2137 | } }; | 2234 | .none => .none, |
| 2138 | cur_offset -= start_idx * elem_size; | 2235 | else => |a| a.offset(start_off), |
| 2236 | }, | ||
| 2237 | .@"const" = parent.@"const", | ||
| 2238 | .@"volatile" = parent.@"volatile", | ||
| 2239 | .@"allowzero" = parent.@"allowzero", | ||
| 2240 | .addr = .{ .elem = .{ | ||
| 2241 | .parent = parent, | ||
| 2242 | .elem_index = start_idx, | ||
| 2243 | } }, | ||
| 2244 | }; | ||
| 2245 | cur_offset -= start_off; | ||
| 2139 | } else { | 2246 | } else { |
| 2140 | // Go into the first element if needed, but don't go any deeper. | 2247 | // Go into the first element if the byte offsets line up neatly, but don't try |
| 2141 | if (start_idx > 0) { | 2248 | // to go any deeper. |
| 2142 | const parent = try arena.create(PointerDeriveStep); | 2249 | if (start_idx > 0 and start_idx * elem_size == cur_offset) { |
| 2250 | const parent = try arena.create(PointerDerivation); | ||
| 2143 | parent.* = cur_derive; | 2251 | parent.* = cur_derive; |
| 2144 | cur_derive = .{ .elem_ptr = .{ | 2252 | cur_derive = .{ |
| 2145 | .parent = parent, | 2253 | .elem_ty = elem_ty, |
| 2146 | .elem_idx = start_idx, | 2254 | .size = .one, |
| 2147 | .result_ptr_ty = try pt.adjustPtrTypeChild(try parent.ptrType(pt), elem_ty), | 2255 | .@"align" = switch (parent.@"align") { |
| 2148 | } }; | 2256 | .none => .none, |
| 2149 | cur_offset -= start_idx * elem_size; | 2257 | else => |a| a.offset(start_off), |
| 2258 | }, | ||
| 2259 | .@"const" = parent.@"const", | ||
| 2260 | .@"volatile" = parent.@"volatile", | ||
| 2261 | .@"allowzero" = parent.@"allowzero", | ||
| 2262 | .addr = .{ .elem = .{ | ||
| 2263 | .parent = parent, | ||
| 2264 | .elem_index = start_idx, | ||
| 2265 | } }, | ||
| 2266 | }; | ||
| 2267 | cur_offset -= start_off; | ||
| 2150 | } | 2268 | } |
| 2151 | break; | 2269 | break; |
| 2152 | } | 2270 | } |
| 2153 | }, | 2271 | }, |
| 2154 | .@"struct" => switch (cur_ty.containerLayout(zcu)) { | 2272 | .@"struct" => switch (cur_derive.elem_ty.containerLayout(zcu)) { |
| 2155 | .auto, .@"packed" => break, | 2273 | .auto, .@"packed" => break, |
| 2156 | .@"extern" => for (0..cur_ty.structFieldCount(zcu)) |field_idx| { | 2274 | .@"extern" => for (0..cur_derive.elem_ty.structFieldCount(zcu)) |field_idx| { |
| 2157 | const field_ty = cur_ty.fieldType(field_idx, zcu); | 2275 | const field_ty = cur_derive.elem_ty.fieldType(field_idx, zcu); |
| 2158 | const start_off = cur_ty.structFieldOffset(field_idx, zcu); | 2276 | const start_off = cur_derive.elem_ty.structFieldOffset(field_idx, zcu); |
| 2159 | const end_off = start_off + field_ty.abiSize(zcu); | 2277 | const end_off = start_off + field_ty.abiSize(zcu); |
| 2160 | if (cur_offset >= start_off and cur_offset + need_bytes <= end_off) { | 2278 | if (cur_offset >= start_off and cur_offset + need_bytes <= end_off) { |
| 2161 | const base_ptr_ty = try pt.ptrType(info: { | 2279 | const parent = try arena.create(PointerDerivation); |
| 2162 | var info = (try cur_derive.ptrType(pt)).ptrInfo(zcu); | ||
| 2163 | info.flags.size = .one; | ||
| 2164 | break :info info; | ||
| 2165 | }); | ||
| 2166 | const parent = try arena.create(PointerDeriveStep); | ||
| 2167 | parent.* = cur_derive; | 2280 | parent.* = cur_derive; |
| 2168 | cur_derive = .{ .field_ptr = .{ | 2281 | cur_derive = .{ |
| 2169 | .parent = parent, | 2282 | .elem_ty = field_ty, |
| 2170 | .field_idx = @intCast(field_idx), | 2283 | .size = .one, |
| 2171 | .result_ptr_ty = try base_ptr_ty.fieldPtrType(@intCast(field_idx), pt), | 2284 | .@"align" = switch (parent.@"align") { |
| 2172 | } }; | 2285 | .none => .none, |
| 2286 | else => |a| a.offset(start_off), | ||
| 2287 | }, | ||
| 2288 | .@"const" = parent.@"const", | ||
| 2289 | .@"volatile" = parent.@"volatile", | ||
| 2290 | .@"allowzero" = parent.@"allowzero", | ||
| 2291 | .addr = .{ .field = .{ | ||
| 2292 | .parent = parent, | ||
| 2293 | .field_index = @intCast(field_idx), | ||
| 2294 | } }, | ||
| 2295 | }; | ||
| 2173 | cur_offset -= start_off; | 2296 | cur_offset -= start_off; |
| 2174 | break; | 2297 | break; |
| 2175 | } | 2298 | } |
| ... | @@ -2179,31 +2302,33 @@ pub fn pointerDerivation(ptr_val: Value, arena: Allocator, pt: Zcu.PerThread, op | ... | @@ -2179,31 +2302,33 @@ pub fn pointerDerivation(ptr_val: Value, arena: Allocator, pt: Zcu.PerThread, op |
| 2179 | }; | 2302 | }; |
| 2180 | 2303 | ||
| 2181 | if (cur_offset == 0) compatible: { | 2304 | if (cur_offset == 0) compatible: { |
| 2182 | const src_ptr_ty_info = (try cur_derive.ptrType(pt)).ptrInfo(zcu); | ||
| 2183 | // We allow silently doing some "coercible" pointer things. | 2305 | // We allow silently doing some "coercible" pointer things. |
| 2184 | // In particular, we only give up if cv qualifiers are *removed*. | 2306 | // In particular, we only give up if cv qualifiers are *removed*. |
| 2185 | if (src_ptr_ty_info.flags.is_const and !ptr_ty_info.flags.is_const) break :compatible; | 2307 | if (cur_derive.@"const" and !ptr_ty_info.flags.is_const) break :compatible; |
| 2186 | if (src_ptr_ty_info.flags.is_volatile and !ptr_ty_info.flags.is_volatile) break :compatible; | 2308 | if (cur_derive.@"volatile" and !ptr_ty_info.flags.is_volatile) break :compatible; |
| 2187 | if (src_ptr_ty_info.flags.is_allowzero and !ptr_ty_info.flags.is_allowzero) break :compatible; | 2309 | if (cur_derive.@"allowzero" and !ptr_ty_info.flags.is_allowzero) break :compatible; |
| 2188 | // Everything else has to match exactly. | 2310 | // Element type and alignment, however, have to match exactly. |
| 2189 | if (src_ptr_ty_info.child != ptr_ty_info.child) break :compatible; | 2311 | if (cur_derive.elem_ty.toIntern() != ptr_ty_info.child) break :compatible; |
| 2190 | if (src_ptr_ty_info.sentinel != ptr_ty_info.sentinel) break :compatible; | 2312 | if (cur_derive.size != ptr_size) break :compatible; |
| 2191 | if (src_ptr_ty_info.packed_offset != ptr_ty_info.packed_offset) break :compatible; | 2313 | if (cur_derive.@"align" != ptr_ty_info.flags.alignment) break :compatible; |
| 2192 | if (src_ptr_ty_info.flags.size != ptr_ty_info.flags.size) break :compatible; | ||
| 2193 | if (src_ptr_ty_info.flags.alignment != ptr_ty_info.flags.alignment) break :compatible; | ||
| 2194 | if (src_ptr_ty_info.flags.address_space != ptr_ty_info.flags.address_space) break :compatible; | ||
| 2195 | if (src_ptr_ty_info.flags.vector_index != ptr_ty_info.flags.vector_index) break :compatible; | ||
| 2196 | 2314 | ||
| 2197 | return cur_derive; | 2315 | return cur_derive; |
| 2198 | } | 2316 | } |
| 2199 | 2317 | ||
| 2200 | const parent = try arena.create(PointerDeriveStep); | 2318 | const parent = try arena.create(PointerDerivation); |
| 2201 | parent.* = cur_derive; | 2319 | parent.* = cur_derive; |
| 2202 | return .{ .offset_and_cast = .{ | 2320 | return .{ |
| 2203 | .parent = parent, | 2321 | .elem_ty = .fromInterned(ptr_ty_info.child), |
| 2204 | .byte_offset = cur_offset, | 2322 | .size = ptr_size, |
| 2205 | .new_ptr_ty = Type.fromInterned(ptr.ty), | 2323 | .@"align" = ptr_ty_info.flags.alignment, |
| 2206 | } }; | 2324 | .@"const" = ptr_ty_info.flags.is_const, |
| 2325 | .@"volatile" = ptr_ty_info.flags.is_volatile, | ||
| 2326 | .@"allowzero" = ptr_ty_info.flags.is_allowzero, | ||
| 2327 | .addr = .{ .offset_and_cast = .{ | ||
| 2328 | .parent = parent, | ||
| 2329 | .byte_offset = cur_offset, | ||
| 2330 | } }, | ||
| 2331 | }; | ||
| 2207 | } | 2332 | } |
| 2208 | 2333 | ||
| 2209 | const InterpretMode = enum { | 2334 | const InterpretMode = enum { |
src/Zcu/PerThread.zig+11-10| ... | @@ -138,6 +138,15 @@ pub fn update( | ... | @@ -138,6 +138,15 @@ pub fn update( |
| 138 | const gpa = comp.gpa; | 138 | const gpa = comp.gpa; |
| 139 | const io = comp.io; | 139 | const io = comp.io; |
| 140 | 140 | ||
| 141 | if (!zcu.backendSupportsFeature(.separate_thread)) { | ||
| 142 | // We may still be running the linker on a separate thread at the moment, but once prelink | ||
| 143 | // completes, we need that thread to exit so that we can process all ZCU link tasks on the | ||
| 144 | // main thread. We signal this condition by immediately closing the ZCU task queue. It's | ||
| 145 | // important that we do this before enqueueing *any* ZCU link tasks: otherwise those tasks | ||
| 146 | // will run on the linker thread which is meant to be for prelink only! | ||
| 147 | comp.link_queue.finishZcuQueue(comp); | ||
| 148 | } | ||
| 149 | |||
| 141 | { | 150 | { |
| 142 | const tracy_trace = traceNamed(@src(), "astgen"); | 151 | const tracy_trace = traceNamed(@src(), "astgen"); |
| 143 | defer tracy_trace.end(); | 152 | defer tracy_trace.end(); |
| ... | @@ -269,14 +278,6 @@ pub fn update( | ... | @@ -269,14 +278,6 @@ pub fn update( |
| 269 | 278 | ||
| 270 | try zcu.flushRetryableFailures(); | 279 | try zcu.flushRetryableFailures(); |
| 271 | 280 | ||
| 272 | if (!zcu.backendSupportsFeature(.separate_thread)) { | ||
| 273 | // Close the ZCU task queue. Prelink may still be running, but the closed | ||
| 274 | // queue will cause the linker task to exit once prelink finishes. The | ||
| 275 | // closed queue also communicates to `enqueueZcu` that it should wait for | ||
| 276 | // the linker task to finish and then run ZCU tasks serially. | ||
| 277 | comp.link_queue.finishZcuQueue(comp); | ||
| 278 | } | ||
| 279 | |||
| 280 | zcu.sema_prog_node = main_progress_node.start("Semantic Analysis", 0); | 281 | zcu.sema_prog_node = main_progress_node.start("Semantic Analysis", 0); |
| 281 | if (comp.bin_file != null) { | 282 | if (comp.bin_file != null) { |
| 282 | zcu.codegen_prog_node = main_progress_node.start("Code Generation", 0); | 283 | zcu.codegen_prog_node = main_progress_node.start("Code Generation", 0); |
| ... | @@ -3471,7 +3472,7 @@ fn analyzeFuncBodyInner( | ... | @@ -3471,7 +3472,7 @@ fn analyzeFuncBodyInner( |
| 3471 | &inner_block, | 3472 | &inner_block, |
| 3472 | inner_block.nodeOffset(.zero), | 3473 | inner_block.nodeOffset(.zero), |
| 3473 | "cannot resolve inferred error set of {s} function type '{f}'", | 3474 | "cannot resolve inferred error set of {s} function type '{f}'", |
| 3474 | .{ description, fn_ty.fmt(pt) }, | 3475 | .{ description, fn_ty.fmt(zcu) }, |
| 3475 | ); | 3476 | ); |
| 3476 | } | 3477 | } |
| 3477 | 3478 | ||
| ... | @@ -4587,6 +4588,6 @@ fn printVerboseAir( | ... | @@ -4587,6 +4588,6 @@ fn printVerboseAir( |
| 4587 | const zcu = pt.zcu; | 4588 | const zcu = pt.zcu; |
| 4588 | const ip = &zcu.intern_pool; | 4589 | const ip = &zcu.intern_pool; |
| 4589 | try w.print("# Begin Function AIR: {f}:\n", .{fqn.fmt(ip)}); | 4590 | try w.print("# Begin Function AIR: {f}:\n", .{fqn.fmt(ip)}); |
| 4590 | try air.write(w, pt, liveness); | 4591 | try air.write(w, zcu, liveness); |
| 4591 | try w.print("# End Function AIR: {f}\n\n", .{fqn.fmt(ip)}); | 4592 | try w.print("# End Function AIR: {f}\n\n", .{fqn.fmt(ip)}); |
| 4592 | } | 4593 | } |
src/codegen.zig+7-6| ... | @@ -255,7 +255,6 @@ pub fn generateLazySymbol( | ... | @@ -255,7 +255,6 @@ pub fn generateLazySymbol( |
| 255 | ) link.EmitError!void { | 255 | ) link.EmitError!void { |
| 256 | const tracy = trace(@src()); | 256 | const tracy = trace(@src()); |
| 257 | defer tracy.end(); | 257 | defer tracy.end(); |
| 258 | tracy.addTextFmt("{t}, {f}", .{ lazy_sym.kind, Type.fromInterned(lazy_sym.ty).fmt(pt) }); | ||
| 259 | 258 | ||
| 260 | const comp = bin_file.comp; | 259 | const comp = bin_file.comp; |
| 261 | const zcu = pt.zcu; | 260 | const zcu = pt.zcu; |
| ... | @@ -263,9 +262,11 @@ pub fn generateLazySymbol( | ... | @@ -263,9 +262,11 @@ pub fn generateLazySymbol( |
| 263 | const target = &comp.root_mod.resolved_target.result; | 262 | const target = &comp.root_mod.resolved_target.result; |
| 264 | const endian = target.cpu.arch.endian(); | 263 | const endian = target.cpu.arch.endian(); |
| 265 | 264 | ||
| 265 | tracy.addTextFmt("{t}, {f}", .{ lazy_sym.kind, Type.fromInterned(lazy_sym.ty).fmt(zcu) }); | ||
| 266 | |||
| 266 | log.debug("generateLazySymbol: kind = {s}, ty = {f}", .{ | 267 | log.debug("generateLazySymbol: kind = {s}, ty = {f}", .{ |
| 267 | @tagName(lazy_sym.kind), | 268 | @tagName(lazy_sym.kind), |
| 268 | Type.fromInterned(lazy_sym.ty).fmt(pt), | 269 | Type.fromInterned(lazy_sym.ty).fmt(zcu), |
| 269 | }); | 270 | }); |
| 270 | 271 | ||
| 271 | if (lazy_sym.kind == .code) { | 272 | if (lazy_sym.kind == .code) { |
| ... | @@ -303,7 +304,7 @@ pub fn generateLazySymbol( | ... | @@ -303,7 +304,7 @@ pub fn generateLazySymbol( |
| 303 | } | 304 | } |
| 304 | } else { | 305 | } else { |
| 305 | return zcu.codegenFailType(lazy_sym.ty, "TODO implement generateLazySymbol for {s} {f}", .{ | 306 | return zcu.codegenFailType(lazy_sym.ty, "TODO implement generateLazySymbol for {s} {f}", .{ |
| 306 | @tagName(lazy_sym.kind), Type.fromInterned(lazy_sym.ty).fmt(pt), | 307 | @tagName(lazy_sym.kind), Type.fromInterned(lazy_sym.ty).fmt(zcu), |
| 307 | }); | 308 | }); |
| 308 | } | 309 | } |
| 309 | } | 310 | } |
| ... | @@ -325,7 +326,7 @@ pub fn generateSymbol( | ... | @@ -325,7 +326,7 @@ pub fn generateSymbol( |
| 325 | const target = zcu.getTarget(); | 326 | const target = zcu.getTarget(); |
| 326 | const endian = target.cpu.arch.endian(); | 327 | const endian = target.cpu.arch.endian(); |
| 327 | 328 | ||
| 328 | log.debug("generateSymbol: val = {f}", .{val.fmtValue(pt)}); | 329 | log.debug("generateSymbol: val = {f}", .{val.fmtValue(zcu)}); |
| 329 | 330 | ||
| 330 | const abi_size = math.cast(usize, ty.abiSize(zcu)) orelse { | 331 | const abi_size = math.cast(usize, ty.abiSize(zcu)) orelse { |
| 331 | return zcu.comp.link_diags.fail("failed to generate symbol: type size overflow", .{}); | 332 | return zcu.comp.link_diags.fail("failed to generate symbol: type size overflow", .{}); |
| ... | @@ -733,7 +734,7 @@ fn lowerUavRef( | ... | @@ -733,7 +734,7 @@ fn lowerUavRef( |
| 733 | const uav_ty = Type.fromInterned(ip.typeOf(uav_val)); | 734 | const uav_ty = Type.fromInterned(ip.typeOf(uav_val)); |
| 734 | const is_fn_body = uav_ty.zigTypeTag(zcu) == .@"fn"; | 735 | const is_fn_body = uav_ty.zigTypeTag(zcu) == .@"fn"; |
| 735 | 736 | ||
| 736 | log.debug("lowerUavRef: ty = {f}", .{uav_ty.fmt(pt)}); | 737 | log.debug("lowerUavRef: ty = {f}", .{uav_ty.fmt(zcu)}); |
| 737 | 738 | ||
| 738 | if (!is_fn_body and !uav_ty.hasRuntimeBits(zcu)) { | 739 | if (!is_fn_body and !uav_ty.hasRuntimeBits(zcu)) { |
| 739 | try w.splatByteAll(0xaa, ptr_width_bytes); | 740 | try w.splatByteAll(0xaa, ptr_width_bytes); |
| ... | @@ -876,7 +877,7 @@ pub fn lowerValue(pt: Zcu.PerThread, val: Value, target: *const std.Target) Allo | ... | @@ -876,7 +877,7 @@ pub fn lowerValue(pt: Zcu.PerThread, val: Value, target: *const std.Target) Allo |
| 876 | const ip = &zcu.intern_pool; | 877 | const ip = &zcu.intern_pool; |
| 877 | const ty = val.typeOf(zcu); | 878 | const ty = val.typeOf(zcu); |
| 878 | 879 | ||
| 879 | log.debug("lowerValue(@as({f}, {f}))", .{ ty.fmt(pt), val.fmtValue(pt) }); | 880 | log.debug("lowerValue(@as({f}, {f}))", .{ ty.fmt(zcu), val.fmtValue(zcu) }); |
| 880 | 881 | ||
| 881 | if (val.isUndef(zcu)) return .undef; | 882 | if (val.isUndef(zcu)) return .undef; |
| 882 | 883 |
src/codegen/aarch64/Select.zig+3-3| ... | @@ -946,7 +946,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) codegen.Error!void | ... | @@ -946,7 +946,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) codegen.Error!void |
| 946 | isel: *Select, | 946 | isel: *Select, |
| 947 | inst: Air.Inst.Index, | 947 | inst: Air.Inst.Index, |
| 948 | pub fn format(fmt_air: @This(), writer: *std.Io.Writer) std.Io.Writer.Error!void { | 948 | pub fn format(fmt_air: @This(), writer: *std.Io.Writer) std.Io.Writer.Error!void { |
| 949 | fmt_air.isel.air.writeInst(writer, fmt_air.inst, fmt_air.isel.pt, null); | 949 | fmt_air.isel.air.writeInst(writer, fmt_air.inst, fmt_air.isel.pt.zcu, null); |
| 950 | } | 950 | } |
| 951 | } { | 951 | } { |
| 952 | return .{ .isel = it.isel, .inst = inst }; | 952 | return .{ .isel = it.isel, .inst = inst }; |
| ... | @@ -7974,11 +7974,11 @@ fn fmtLoopLive(isel: *Select, loop_inst: Air.Inst.Index) struct { | ... | @@ -7974,11 +7974,11 @@ fn fmtLoopLive(isel: *Select, loop_inst: Air.Inst.Index) struct { |
| 7974 | } | 7974 | } |
| 7975 | 7975 | ||
| 7976 | fn fmtType(isel: *Select, ty: ZigType) ZigType.Formatter { | 7976 | fn fmtType(isel: *Select, ty: ZigType) ZigType.Formatter { |
| 7977 | return ty.fmt(isel.pt); | 7977 | return ty.fmt(isel.pt.zcu); |
| 7978 | } | 7978 | } |
| 7979 | 7979 | ||
| 7980 | fn fmtConstant(isel: *Select, constant: Constant) @typeInfo(@TypeOf(Constant.fmtValue)).@"fn".return_type.? { | 7980 | fn fmtConstant(isel: *Select, constant: Constant) @typeInfo(@TypeOf(Constant.fmtValue)).@"fn".return_type.? { |
| 7981 | return constant.fmtValue(isel.pt); | 7981 | return constant.fmtValue(isel.pt.zcu); |
| 7982 | } | 7982 | } |
| 7983 | 7983 | ||
| 7984 | fn block( | 7984 | fn block( |
src/codegen/c.zig+112-90| ... | @@ -740,59 +740,57 @@ pub const DeclGen = struct { | ... | @@ -740,59 +740,57 @@ pub const DeclGen = struct { |
| 740 | fn renderUav( | 740 | fn renderUav( |
| 741 | dg: *DeclGen, | 741 | dg: *DeclGen, |
| 742 | w: *Writer, | 742 | w: *Writer, |
| 743 | uav: InternPool.Key.Ptr.BaseAddr.Uav, | 743 | uav_val: Value, |
| 744 | derivation: Value.PointerDerivation, | ||
| 744 | location: ValueRenderLocation, | 745 | location: ValueRenderLocation, |
| 745 | ) Error!void { | 746 | ) Error!void { |
| 746 | const pt = dg.pt; | 747 | const pt = dg.pt; |
| 747 | const zcu = pt.zcu; | 748 | const zcu = pt.zcu; |
| 748 | const ip = &zcu.intern_pool; | 749 | const ip = &zcu.intern_pool; |
| 749 | const uav_val = Value.fromInterned(uav.val); | ||
| 750 | const uav_ty = uav_val.typeOf(zcu); | 750 | const uav_ty = uav_val.typeOf(zcu); |
| 751 | 751 | ||
| 752 | // Render an undefined pointer if we have a pointer to a zero-bit or comptime type. | 752 | // Render an undefined pointer if we have a pointer to a zero-bit or comptime type. |
| 753 | const ptr_ty: Type = .fromInterned(uav.orig_ty); | 753 | if (!uav_ty.isRuntimeFnOrHasRuntimeBits(zcu)) { |
| 754 | if (ptr_ty.isPtrAtRuntime(zcu) and !uav_ty.isRuntimeFnOrHasRuntimeBits(zcu)) { | 754 | const target = zcu.getTarget(); |
| 755 | try w.writeByte('('); | 755 | const alignment = switch (derivation.@"align") { |
| 756 | try dg.renderOpvPointer(w, ptr_ty, location); | 756 | .none => derivation.elem_ty.abiAlignment(zcu), |
| 757 | return w.writeByte(')'); | 757 | else => |a| a, |
| 758 | }; | ||
| 759 | try w.writeAll("(("); | ||
| 760 | try dg.renderDerivedPointerType(w, derivation); | ||
| 761 | try w.print("){f})", .{fmtUnsignedIntLiteralSmall( | ||
| 762 | target, | ||
| 763 | .uintptr_t, | ||
| 764 | alignment.forward(undefPattern(u64) >> @intCast(64 - target.ptrBitWidth())), | ||
| 765 | location == .static_initializer, | ||
| 766 | 16, | ||
| 767 | .lower, | ||
| 768 | )}); | ||
| 769 | return; | ||
| 758 | } | 770 | } |
| 759 | 771 | ||
| 760 | switch (ip.indexToKey(uav.val)) { | 772 | switch (ip.indexToKey(uav_val.toIntern())) { |
| 761 | .func => unreachable, | 773 | .func => unreachable, |
| 762 | .@"extern" => unreachable, | 774 | .@"extern" => unreachable, |
| 763 | else => {}, | 775 | else => {}, |
| 764 | } | 776 | } |
| 765 | 777 | ||
| 766 | // We shouldn't cast C function pointers as this is UB (when you call | ||
| 767 | // them). The analysis until now should ensure that the C function | ||
| 768 | // pointers are compatible. If they are not, then there is a bug | ||
| 769 | // somewhere and we should let the C compiler tell us about it. | ||
| 770 | const elem_ty = ptr_ty.childType(zcu); | ||
| 771 | const need_cast = elem_ty.toIntern() != uav_ty.toIntern() and | ||
| 772 | elem_ty.zigTypeTag(zcu) != .@"fn" or uav_ty.zigTypeTag(zcu) != .@"fn"; | ||
| 773 | if (need_cast) { | ||
| 774 | try w.writeAll("(("); | ||
| 775 | try dg.renderType(w, ptr_ty); | ||
| 776 | try w.writeByte(')'); | ||
| 777 | } | ||
| 778 | try w.writeByte('&'); | 778 | try w.writeByte('&'); |
| 779 | try renderUavName(w, uav_val); | 779 | try renderUavName(w, uav_val); |
| 780 | if (need_cast) try w.writeByte(')'); | ||
| 781 | 780 | ||
| 782 | // Indicate that the anon decl should be rendered to the output so that | 781 | // Indicate that the anon decl should be rendered to the output so that |
| 783 | // our reference above is not undefined. | 782 | // our reference above is not undefined. |
| 784 | const ptr_type = ip.indexToKey(uav.orig_ty).ptr_type; | 783 | const gop = try dg.uavs.getOrPut(dg.gpa, uav_val.toIntern()); |
| 785 | const gop = try dg.uavs.getOrPut(dg.gpa, uav.val); | ||
| 786 | if (!gop.found_existing) gop.value_ptr.* = .none; | 784 | if (!gop.found_existing) gop.value_ptr.* = .none; |
| 787 | // If there is an explicit alignment, greater than the current one, use it. | 785 | // If there is an explicit alignment, greater than the current one, use it. |
| 788 | // Note that we intentionally start at `.none`, so `gop.value_ptr.*` is never | 786 | // Note that we intentionally start at `.none`, so `gop.value_ptr.*` is never |
| 789 | // underaligned, so we don't need to worry about the `.none` case here. | 787 | // underaligned, so we don't need to worry about the `.none` case here. |
| 790 | if (ptr_type.flags.alignment != .none) { | 788 | if (derivation.@"align" != .none) { |
| 791 | // Resolve the current alignment so we can choose the bigger one. | 789 | // Resolve the current alignment so we can choose the bigger one. |
| 792 | const cur_alignment: Alignment = if (gop.value_ptr.* == .none) abi: { | 790 | const cur_alignment: Alignment = if (gop.value_ptr.* == .none) abi: { |
| 793 | break :abi Type.fromInterned(ptr_type.child).abiAlignment(zcu); | 791 | break :abi uav_ty.abiAlignment(zcu); |
| 794 | } else gop.value_ptr.*; | 792 | } else gop.value_ptr.*; |
| 795 | gop.value_ptr.* = cur_alignment.maxStrict(ptr_type.flags.alignment); | 793 | gop.value_ptr.* = cur_alignment.maxStrict(derivation.@"align"); |
| 796 | } | 794 | } |
| 797 | } | 795 | } |
| 798 | 796 | ||
| ... | @@ -818,28 +816,14 @@ pub const DeclGen = struct { | ... | @@ -818,28 +816,14 @@ pub const DeclGen = struct { |
| 818 | 816 | ||
| 819 | // Render an undefined pointer if we have a pointer to a zero-bit or comptime type. | 817 | // Render an undefined pointer if we have a pointer to a zero-bit or comptime type. |
| 820 | const nav_ty: Type = .fromInterned(ip.getNav(owner_nav).resolved.?.type); | 818 | const nav_ty: Type = .fromInterned(ip.getNav(owner_nav).resolved.?.type); |
| 821 | const ptr_ty = try pt.navPtrType(owner_nav); | ||
| 822 | if (nav_ty.zigTypeTag(zcu) != .@"opaque" and !nav_ty.isRuntimeFnOrHasRuntimeBits(zcu)) { | 819 | if (nav_ty.zigTypeTag(zcu) != .@"opaque" and !nav_ty.isRuntimeFnOrHasRuntimeBits(zcu)) { |
| 823 | try w.writeByte('('); | 820 | try w.writeByte('('); |
| 824 | try dg.renderOpvPointer(w, ptr_ty, location); | 821 | try dg.renderOpvPointer(w, try pt.navPtrType(owner_nav), location); |
| 825 | return w.writeByte(')'); | 822 | return w.writeByte(')'); |
| 826 | } | 823 | } |
| 827 | 824 | ||
| 828 | // We shouldn't cast C function pointers as this is UB (when you call | ||
| 829 | // them). The analysis until now should ensure that the C function | ||
| 830 | // pointers are compatible. If they are not, then there is a bug | ||
| 831 | // somewhere and we should let the C compiler tell us about it. | ||
| 832 | const elem_ty = ptr_ty.childType(zcu); | ||
| 833 | const need_cast = elem_ty.toIntern() != nav_ty.toIntern() and | ||
| 834 | elem_ty.zigTypeTag(zcu) != .@"fn" or nav_ty.zigTypeTag(zcu) != .@"fn"; | ||
| 835 | if (need_cast) { | ||
| 836 | try w.writeAll("(("); | ||
| 837 | try dg.renderType(w, ptr_ty); | ||
| 838 | try w.writeByte(')'); | ||
| 839 | } | ||
| 840 | try w.writeByte('&'); | 825 | try w.writeByte('&'); |
| 841 | try renderNavName(w, owner_nav, ip); | 826 | try renderNavName(w, owner_nav, ip); |
| 842 | if (need_cast) try w.writeByte(')'); | ||
| 843 | } | 827 | } |
| 844 | 828 | ||
| 845 | fn renderOpvPointer( | 829 | fn renderOpvPointer( |
| ... | @@ -865,92 +849,108 @@ pub const DeclGen = struct { | ... | @@ -865,92 +849,108 @@ pub const DeclGen = struct { |
| 865 | fn renderPointer( | 849 | fn renderPointer( |
| 866 | dg: *DeclGen, | 850 | dg: *DeclGen, |
| 867 | w: *Writer, | 851 | w: *Writer, |
| 868 | derivation: Value.PointerDeriveStep, | 852 | derivation: Value.PointerDerivation, |
| 869 | location: ValueRenderLocation, | 853 | location: ValueRenderLocation, |
| 870 | ) Error!void { | 854 | ) Error!void { |
| 871 | const pt = dg.pt; | 855 | const pt = dg.pt; |
| 872 | const zcu = pt.zcu; | 856 | const zcu = pt.zcu; |
| 873 | switch (derivation) { | 857 | switch (derivation.addr) { |
| 874 | .comptime_alloc_ptr, .comptime_field_ptr => unreachable, | 858 | .comptime_alloc, .comptime_field => unreachable, |
| 875 | .int => |int| { | 859 | .int => |int| { |
| 876 | const addr_val = try pt.intValue(.usize, int.addr); | 860 | const addr_val = try pt.intValue(.usize, int); |
| 877 | try w.writeByte('('); | 861 | try w.writeByte('('); |
| 878 | try dg.renderType(w, int.ptr_ty); | 862 | try dg.renderDerivedPointerType(w, derivation); |
| 879 | try w.print("){f}", .{try dg.fmtIntLiteralHex(addr_val, .other)}); | 863 | try w.print("){f}", .{try dg.fmtIntLiteralHex(addr_val, .other)}); |
| 880 | }, | 864 | }, |
| 881 | 865 | ||
| 882 | .nav_ptr => |nav| try dg.renderNav(w, nav, location), | 866 | .nav => |nav| try dg.renderNav(w, nav, location), |
| 883 | .uav_ptr => |uav| try dg.renderUav(w, uav, location), | 867 | .uav => |val| try dg.renderUav(w, val, derivation, location), |
| 884 | 868 | ||
| 885 | inline .eu_payload_ptr, .opt_payload_ptr => |info| { | 869 | inline .eu_payload, .opt_payload => |info| { |
| 886 | try w.writeAll("&("); | 870 | try w.writeAll("&("); |
| 887 | try dg.renderPointer(w, info.parent.*, location); | 871 | try dg.renderPointer(w, info.parent.*, location); |
| 888 | try w.writeAll(")->payload"); | 872 | try w.writeAll(")->payload"); |
| 889 | }, | 873 | }, |
| 890 | 874 | ||
| 891 | .field_ptr => |field| { | 875 | .field => |derived| { |
| 892 | const parent_ptr_ty = try field.parent.ptrType(pt); | 876 | switch (fieldLocation(derived.parent.elem_ty, derivation.elem_ty, derived.field_index, zcu)) { |
| 893 | |||
| 894 | switch (fieldLocation(parent_ptr_ty, field.result_ptr_ty, field.field_idx, zcu)) { | ||
| 895 | .begin => { | 877 | .begin => { |
| 896 | try w.writeByte('('); | 878 | try w.writeByte('('); |
| 897 | try dg.renderType(w, field.result_ptr_ty); | 879 | try dg.renderDerivedPointerType(w, derivation); |
| 898 | try w.writeByte(')'); | 880 | try w.writeByte(')'); |
| 899 | try dg.renderPointer(w, field.parent.*, location); | 881 | try dg.renderPointer(w, derived.parent.*, location); |
| 900 | }, | 882 | }, |
| 901 | .field => |name| { | 883 | .field => |name| { |
| 902 | try w.writeAll("&("); | 884 | try w.writeAll("&("); |
| 903 | try dg.renderPointer(w, field.parent.*, location); | 885 | try dg.renderPointer(w, derived.parent.*, location); |
| 904 | try w.writeAll(")->"); | 886 | try w.writeAll(")->"); |
| 905 | try dg.writeCValue(w, name); | 887 | try dg.writeCValue(w, name); |
| 906 | }, | 888 | }, |
| 907 | .byte_offset => |byte_offset| { | 889 | .byte_offset => |byte_offset| { |
| 908 | try w.writeByte('('); | 890 | try w.writeByte('('); |
| 909 | try dg.renderType(w, field.result_ptr_ty); | 891 | try dg.renderDerivedPointerType(w, derivation); |
| 910 | try w.writeByte(')'); | 892 | try w.writeByte(')'); |
| 911 | const offset_val = try pt.intValue(.usize, byte_offset); | 893 | const offset_val = try pt.intValue(.usize, byte_offset); |
| 912 | try w.writeAll("((char *)"); | 894 | try w.writeAll("((char *)"); |
| 913 | try dg.renderPointer(w, field.parent.*, location); | 895 | try dg.renderPointer(w, derived.parent.*, location); |
| 914 | try w.print(" + {f})", .{try dg.fmtIntLiteralDec(offset_val, .other)}); | 896 | try w.print(" + {f})", .{try dg.fmtIntLiteralDec(offset_val, .other)}); |
| 915 | }, | 897 | }, |
| 916 | } | 898 | } |
| 917 | }, | 899 | }, |
| 918 | 900 | ||
| 919 | .elem_ptr => |elem| if (!(try elem.parent.ptrType(pt)).childType(zcu).hasRuntimeBits(zcu)) { | 901 | .elem => |derived| if (!derived.parent.elem_ty.hasRuntimeBits(zcu)) { |
| 920 | // Element type is zero-bit, so lowers to `void`. The index is irrelevant; just cast the pointer. | 902 | // Element type is zero-bit, so lowers to `void`. The index is irrelevant; just cast the pointer. |
| 921 | try w.writeByte('('); | 903 | try w.writeByte('('); |
| 922 | try dg.renderType(w, elem.result_ptr_ty); | 904 | try dg.renderDerivedPointerType(w, derivation); |
| 923 | try w.writeByte(')'); | 905 | try w.writeByte(')'); |
| 924 | try dg.renderPointer(w, elem.parent.*, location); | 906 | try dg.renderPointer(w, derived.parent.*, location); |
| 925 | } else { | 907 | } else { |
| 926 | const index_val = try pt.intValue(.usize, elem.elem_idx); | 908 | const index_val = try pt.intValue(.usize, derived.elem_index); |
| 927 | try w.writeByte('('); | 909 | try w.writeByte('('); |
| 928 | // We want to do pointer arithmetic on a pointer to the element type, but the parent | 910 | // We want to do pointer arithmetic on a pointer to the element type, but the parent |
| 929 | // might be a pointer-to-array, in which case we must cast it. | 911 | // is a pointer-to-array, so we need to cast first. |
| 930 | if (elem.result_ptr_ty.toIntern() != (try elem.parent.ptrType(pt)).toIntern()) { | 912 | try w.writeByte('('); |
| 931 | try w.writeByte('('); | 913 | try dg.renderDerivedPointerType(w, derivation); |
| 932 | try dg.renderType(w, elem.result_ptr_ty); | 914 | try w.writeByte(')'); |
| 933 | try w.writeByte(')'); | 915 | |
| 934 | } | 916 | try dg.renderPointer(w, derived.parent.*, location); |
| 935 | try dg.renderPointer(w, elem.parent.*, location); | ||
| 936 | try w.print(" + {f})", .{try dg.fmtIntLiteralDec(index_val, .other)}); | 917 | try w.print(" + {f})", .{try dg.fmtIntLiteralDec(index_val, .other)}); |
| 937 | }, | 918 | }, |
| 938 | 919 | ||
| 939 | .offset_and_cast => |oac| { | 920 | .offset_and_cast => |derived| { |
| 940 | try w.writeByte('('); | 921 | try w.writeByte('('); |
| 941 | try dg.renderType(w, oac.new_ptr_ty); | 922 | try dg.renderDerivedPointerType(w, derivation); |
| 942 | try w.writeByte(')'); | 923 | try w.writeByte(')'); |
| 943 | if (oac.byte_offset == 0) { | 924 | if (derived.byte_offset == 0) { |
| 944 | try dg.renderPointer(w, oac.parent.*, location); | 925 | try dg.renderPointer(w, derived.parent.*, location); |
| 945 | } else { | 926 | } else { |
| 946 | const offset_val = try pt.intValue(.usize, oac.byte_offset); | 927 | const offset_val = try pt.intValue(.usize, derived.byte_offset); |
| 947 | try w.writeAll("((char *)"); | 928 | try w.writeAll("((char *)"); |
| 948 | try dg.renderPointer(w, oac.parent.*, location); | 929 | try dg.renderPointer(w, derived.parent.*, location); |
| 949 | try w.print(" + {f})", .{try dg.fmtIntLiteralDec(offset_val, .other)}); | 930 | try w.print(" + {f})", .{try dg.fmtIntLiteralDec(offset_val, .other)}); |
| 950 | } | 931 | } |
| 951 | }, | 932 | }, |
| 952 | } | 933 | } |
| 953 | } | 934 | } |
| 935 | fn renderDerivedPointerType( | ||
| 936 | dg: *DeclGen, | ||
| 937 | w: *Writer, | ||
| 938 | derivation: Value.PointerDerivation, | ||
| 939 | ) Error!void { | ||
| 940 | return dg.renderType(w, try dg.pt.ptrType(.{ | ||
| 941 | .child = derivation.elem_ty.toIntern(), | ||
| 942 | .flags = .{ | ||
| 943 | .size = switch (derivation.size) { | ||
| 944 | .one => .one, | ||
| 945 | .many => .many, | ||
| 946 | }, | ||
| 947 | .alignment = derivation.@"align", | ||
| 948 | .is_const = derivation.@"const", | ||
| 949 | .is_volatile = derivation.@"volatile", | ||
| 950 | .is_allowzero = derivation.@"allowzero", | ||
| 951 | }, | ||
| 952 | })); | ||
| 953 | } | ||
| 954 | 954 | ||
| 955 | fn renderValueAsLvalue( | 955 | fn renderValueAsLvalue( |
| 956 | dg: *DeclGen, | 956 | dg: *DeclGen, |
| ... | @@ -1166,7 +1166,31 @@ pub const DeclGen = struct { | ... | @@ -1166,7 +1166,31 @@ pub const DeclGen = struct { |
| 1166 | try w.writeByte('}'); | 1166 | try w.writeByte('}'); |
| 1167 | }, | 1167 | }, |
| 1168 | .ptr => { | 1168 | .ptr => { |
| 1169 | const derivation = try val.pointerDerivation(dg.arena, pt, null); | 1169 | // TODO: `Value.pointerDerivation` ought to do this for us, but it doesn't receive |
| 1170 | // `pt`, so it actually *can't* until https://github.com/ziglang/zig/issues/24061 is | ||
| 1171 | // implemented. | ||
| 1172 | const non_packed_ptr: Value = non_packed_ptr: { | ||
| 1173 | const ptr_info = val.typeOf(zcu).ptrInfo(zcu); | ||
| 1174 | if (ptr_info.packed_offset.host_size == 0) { | ||
| 1175 | break :non_packed_ptr val; | ||
| 1176 | } | ||
| 1177 | const backing_ty: Type = switch (ptr_info.flags.vector_index) { | ||
| 1178 | _ => .fromInterned(ptr_info.child), | ||
| 1179 | .none => try pt.intType( | ||
| 1180 | .unsigned, | ||
| 1181 | @intCast(ptr_info.packed_offset.host_size * 8), | ||
| 1182 | ), | ||
| 1183 | }; | ||
| 1184 | const new_ptr_ty = try pt.ptrType(info: { | ||
| 1185 | var info = ptr_info; | ||
| 1186 | info.child = backing_ty.toIntern(); | ||
| 1187 | info.packed_offset = .{ .host_size = 0, .bit_offset = 0 }; | ||
| 1188 | info.flags.vector_index = .none; | ||
| 1189 | break :info info; | ||
| 1190 | }); | ||
| 1191 | break :non_packed_ptr try pt.getCoerced(val, new_ptr_ty); | ||
| 1192 | }; | ||
| 1193 | const derivation = try non_packed_ptr.pointerDerivation(dg.arena, zcu, null); | ||
| 1170 | try w.writeByte('('); | 1194 | try w.writeByte('('); |
| 1171 | try dg.renderPointer(w, derivation, location); | 1195 | try dg.renderPointer(w, derivation, location); |
| 1172 | try w.writeByte(')'); | 1196 | try w.writeByte(')'); |
| ... | @@ -5380,8 +5404,8 @@ fn airOptionalPayloadPtrSet(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -5380,8 +5404,8 @@ fn airOptionalPayloadPtrSet(f: *Function, inst: Air.Inst.Index) !CValue { |
| 5380 | } | 5404 | } |
| 5381 | 5405 | ||
| 5382 | fn fieldLocation( | 5406 | fn fieldLocation( |
| 5383 | container_ptr_ty: Type, | 5407 | container_ty: Type, |
| 5384 | field_ptr_ty: Type, | 5408 | field_ty: Type, |
| 5385 | field_index: u32, | 5409 | field_index: u32, |
| 5386 | zcu: *Zcu, | 5410 | zcu: *Zcu, |
| 5387 | ) union(enum) { | 5411 | ) union(enum) { |
| ... | @@ -5390,27 +5414,22 @@ fn fieldLocation( | ... | @@ -5390,27 +5414,22 @@ fn fieldLocation( |
| 5390 | byte_offset: u64, | 5414 | byte_offset: u64, |
| 5391 | } { | 5415 | } { |
| 5392 | const ip = &zcu.intern_pool; | 5416 | const ip = &zcu.intern_pool; |
| 5393 | const container_ty: Type = .fromInterned(ip.indexToKey(container_ptr_ty.toIntern()).ptr_type.child); | ||
| 5394 | switch (ip.indexToKey(container_ty.toIntern())) { | 5417 | switch (ip.indexToKey(container_ty.toIntern())) { |
| 5395 | .struct_type => { | 5418 | .struct_type => { |
| 5396 | const loaded_struct = ip.loadStructType(container_ty.toIntern()); | 5419 | const loaded_struct = ip.loadStructType(container_ty.toIntern()); |
| 5397 | return switch (loaded_struct.layout) { | 5420 | return switch (loaded_struct.layout) { |
| 5398 | .auto, .@"extern" => if (!container_ty.hasRuntimeBits(zcu)) | 5421 | .auto, .@"extern" => if (!container_ty.hasRuntimeBits(zcu)) |
| 5399 | .begin | 5422 | .begin |
| 5400 | else if (!field_ptr_ty.childType(zcu).hasRuntimeBits(zcu)) | 5423 | else if (!field_ty.hasRuntimeBits(zcu)) |
| 5401 | .{ .byte_offset = loaded_struct.field_offsets.get(ip)[field_index] } | 5424 | .{ .byte_offset = loaded_struct.field_offsets.get(ip)[field_index] } |
| 5402 | else | 5425 | else |
| 5403 | .{ .field = .{ .identifier = loaded_struct.field_names.get(ip)[field_index].toSlice(ip) } }, | 5426 | .{ .field = .{ .identifier = loaded_struct.field_names.get(ip)[field_index].toSlice(ip) } }, |
| 5404 | .@"packed" => if (field_ptr_ty.ptrInfo(zcu).packed_offset.host_size == 0) | 5427 | .@"packed" => .begin, |
| 5405 | .{ .byte_offset = @divExact(zcu.structPackedFieldBitOffset(loaded_struct, field_index) + | ||
| 5406 | container_ptr_ty.ptrInfo(zcu).packed_offset.bit_offset, 8) } | ||
| 5407 | else | ||
| 5408 | .begin, | ||
| 5409 | }; | 5428 | }; |
| 5410 | }, | 5429 | }, |
| 5411 | .tuple_type => return if (!container_ty.hasRuntimeBits(zcu)) | 5430 | .tuple_type => return if (!container_ty.hasRuntimeBits(zcu)) |
| 5412 | .begin | 5431 | .begin |
| 5413 | else if (!field_ptr_ty.childType(zcu).hasRuntimeBits(zcu)) | 5432 | else if (!field_ty.hasRuntimeBits(zcu)) |
| 5414 | .{ .byte_offset = container_ty.structFieldOffset(field_index, zcu) } | 5433 | .{ .byte_offset = container_ty.structFieldOffset(field_index, zcu) } |
| 5415 | else | 5434 | else |
| 5416 | .{ .field = .{ .field = field_index } }, | 5435 | .{ .field = .{ .field = field_index } }, |
| ... | @@ -5418,7 +5437,6 @@ fn fieldLocation( | ... | @@ -5418,7 +5437,6 @@ fn fieldLocation( |
| 5418 | const loaded_union = ip.loadUnionType(container_ty.toIntern()); | 5437 | const loaded_union = ip.loadUnionType(container_ty.toIntern()); |
| 5419 | switch (loaded_union.layout) { | 5438 | switch (loaded_union.layout) { |
| 5420 | .auto => { | 5439 | .auto => { |
| 5421 | const field_ty: Type = .fromInterned(loaded_union.field_types.get(ip)[field_index]); | ||
| 5422 | if (!field_ty.hasRuntimeBits(zcu)) { | 5440 | if (!field_ty.hasRuntimeBits(zcu)) { |
| 5423 | if (container_ty.unionHasAllZeroBitFieldTypes(zcu)) return .begin; | 5441 | if (container_ty.unionHasAllZeroBitFieldTypes(zcu)) return .begin; |
| 5424 | return .{ .field = .{ .identifier = "payload" } }; | 5442 | return .{ .field = .{ .identifier = "payload" } }; |
| ... | @@ -5427,7 +5445,6 @@ fn fieldLocation( | ... | @@ -5427,7 +5445,6 @@ fn fieldLocation( |
| 5427 | return .{ .field = .{ .payload_identifier = field_name.toSlice(ip) } }; | 5445 | return .{ .field = .{ .payload_identifier = field_name.toSlice(ip) } }; |
| 5428 | }, | 5446 | }, |
| 5429 | .@"extern" => { | 5447 | .@"extern" => { |
| 5430 | const field_ty: Type = .fromInterned(loaded_union.field_types.get(ip)[field_index]); | ||
| 5431 | if (!field_ty.hasRuntimeBits(zcu)) return .begin; | 5448 | if (!field_ty.hasRuntimeBits(zcu)) return .begin; |
| 5432 | const field_name = ip.loadEnumType(loaded_union.enum_tag_type).field_names.get(ip)[field_index]; | 5449 | const field_name = ip.loadEnumType(loaded_union.enum_tag_type).field_names.get(ip)[field_index]; |
| 5433 | return .{ .field = .{ .identifier = field_name.toSlice(ip) } }; | 5450 | return .{ .field = .{ .identifier = field_name.toSlice(ip) } }; |
| ... | @@ -5486,7 +5503,7 @@ fn airFieldParentPtr(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -5486,7 +5503,7 @@ fn airFieldParentPtr(f: *Function, inst: Air.Inst.Index) !CValue { |
| 5486 | try f.renderType(w, container_ptr_ty); | 5503 | try f.renderType(w, container_ptr_ty); |
| 5487 | try w.writeByte(')'); | 5504 | try w.writeByte(')'); |
| 5488 | 5505 | ||
| 5489 | switch (fieldLocation(container_ptr_ty, field_ptr_ty, extra.field_index, zcu)) { | 5506 | switch (fieldLocation(container_ty, field_ptr_ty.childType(zcu), extra.field_index, zcu)) { |
| 5490 | .begin => try f.writeCValue(w, field_ptr_val, .other), | 5507 | .begin => try f.writeCValue(w, field_ptr_val, .other), |
| 5491 | .field => |field| { | 5508 | .field => |field| { |
| 5492 | const u8_ptr_ty = try pt.adjustPtrTypeChild(field_ptr_ty, .u8); | 5509 | const u8_ptr_ty = try pt.adjustPtrTypeChild(field_ptr_ty, .u8); |
| ... | @@ -5537,7 +5554,12 @@ fn fieldPtr( | ... | @@ -5537,7 +5554,12 @@ fn fieldPtr( |
| 5537 | try f.renderType(w, field_ptr_ty); | 5554 | try f.renderType(w, field_ptr_ty); |
| 5538 | try w.writeByte(')'); | 5555 | try w.writeByte(')'); |
| 5539 | 5556 | ||
| 5540 | switch (fieldLocation(container_ptr_ty, field_ptr_ty, field_index, zcu)) { | 5557 | switch (fieldLocation( |
| 5558 | container_ptr_ty.childType(zcu), | ||
| 5559 | field_ptr_ty.childType(zcu), | ||
| 5560 | field_index, | ||
| 5561 | zcu, | ||
| 5562 | )) { | ||
| 5541 | .begin => try f.writeCValue(w, container_ptr_val, .other), | 5563 | .begin => try f.writeCValue(w, container_ptr_val, .other), |
| 5542 | .field => |field| { | 5564 | .field => |field| { |
| 5543 | try w.writeByte('&'); | 5565 | try w.writeByte('&'); |
src/codegen/c/type/render_defs.zig+4-4| ... | @@ -28,7 +28,7 @@ pub fn defineAligned( | ... | @@ -28,7 +28,7 @@ pub fn defineAligned( |
| 28 | }); | 28 | }); |
| 29 | if (!zcu.comp.config.root_strip) try w.print(" /* align({d}) {f} */", .{ | 29 | if (!zcu.comp.config.root_strip) try w.print(" /* align({d}) {f} */", .{ |
| 30 | alignment.toByteUnits().?, | 30 | alignment.toByteUnits().?, |
| 31 | ty.fmt(pt), | 31 | ty.fmt(zcu), |
| 32 | }); | 32 | }); |
| 33 | try w.writeByte('\n'); | 33 | try w.writeByte('\n'); |
| 34 | } | 34 | } |
| ... | @@ -113,7 +113,7 @@ pub fn errunionDefineComplete( | ... | @@ -113,7 +113,7 @@ pub fn errunionDefineComplete( |
| 113 | }); | 113 | }); |
| 114 | } | 114 | } |
| 115 | if (!zcu.comp.config.root_strip) try w.print(" /* anyerror!{f} */", .{ | 115 | if (!zcu.comp.config.root_strip) try w.print(" /* anyerror!{f} */", .{ |
| 116 | payload_ty.fmt(pt), | 116 | payload_ty.fmt(zcu), |
| 117 | }); | 117 | }); |
| 118 | try w.writeByte('\n'); | 118 | try w.writeByte('\n'); |
| 119 | } | 119 | } |
| ... | @@ -159,7 +159,7 @@ pub fn defineIncomplete(ty: Type, w: *Writer, pt: Zcu.PerThread) Writer.Error!vo | ... | @@ -159,7 +159,7 @@ pub fn defineIncomplete(ty: Type, w: *Writer, pt: Zcu.PerThread) Writer.Error!vo |
| 159 | name_cty.fmtTypeName(zcu), | 159 | name_cty.fmtTypeName(zcu), |
| 160 | }); | 160 | }); |
| 161 | if (!zcu.comp.config.root_strip) try w.print(" /* {f} */", .{ | 161 | if (!zcu.comp.config.root_strip) try w.print(" /* {f} */", .{ |
| 162 | ty.fmt(pt), | 162 | ty.fmt(zcu), |
| 163 | }); | 163 | }); |
| 164 | try w.writeByte('\n'); | 164 | try w.writeByte('\n'); |
| 165 | } | 165 | } |
| ... | @@ -337,7 +337,7 @@ pub fn defineComplete( | ... | @@ -337,7 +337,7 @@ pub fn defineComplete( |
| 337 | else => return, | 337 | else => return, |
| 338 | }; | 338 | }; |
| 339 | if (!zcu.comp.config.root_strip) try w.print(" /* {f} */", .{ | 339 | if (!zcu.comp.config.root_strip) try w.print(" /* {f} */", .{ |
| 340 | ty.fmt(pt), | 340 | ty.fmt(zcu), |
| 341 | }); | 341 | }); |
| 342 | try w.writeByte('\n'); | 342 | try w.writeByte('\n'); |
| 343 | if (check_cty) |cty| try writeStaticAssertTypeLayout(ty, cty, w, zcu); | 343 | if (check_cty) |cty| try writeStaticAssertTypeLayout(ty, cty, w, zcu); |
src/codegen/llvm.zig+4-3| ... | @@ -1354,6 +1354,7 @@ pub const Object = struct { | ... | @@ -1354,6 +1354,7 @@ pub const Object = struct { |
| 1354 | /// | 1354 | /// |
| 1355 | /// `val` is always a type because `o.type_pool` only contains types. | 1355 | /// `val` is always a type because `o.type_pool` only contains types. |
| 1356 | pub fn updateConstIncomplete(o: *Object, pt: Zcu.PerThread, index: link.ConstPool.Index, val: InternPool.Index) Allocator.Error!void { | 1356 | pub fn updateConstIncomplete(o: *Object, pt: Zcu.PerThread, index: link.ConstPool.Index, val: InternPool.Index) Allocator.Error!void { |
| 1357 | _ = pt; | ||
| 1357 | const zcu = o.zcu; | 1358 | const zcu = o.zcu; |
| 1358 | assert(zcu.intern_pool.typeOf(val) == .type_type); | 1359 | assert(zcu.intern_pool.typeOf(val) == .type_type); |
| 1359 | 1360 | ||
| ... | @@ -1367,7 +1368,7 @@ pub const Object = struct { | ... | @@ -1367,7 +1368,7 @@ pub const Object = struct { |
| 1367 | if (!o.builder.strip) { | 1368 | if (!o.builder.strip) { |
| 1368 | assert(val != .anyerror_type); | 1369 | assert(val != .anyerror_type); |
| 1369 | const fwd_ref = o.debug_types.items[@backingInt(index)]; | 1370 | const fwd_ref = o.debug_types.items[@backingInt(index)]; |
| 1370 | const name_str = try o.builder.metadataStringFmt("{f}", .{ty.fmt(pt)}); | 1371 | const name_str = try o.builder.metadataStringFmt("{f}", .{ty.fmt(zcu)}); |
| 1371 | // If `ty` is a function, use a dummy *function* type to prevent existing debug | 1372 | // If `ty` is a function, use a dummy *function* type to prevent existing debug |
| 1372 | // subprograms from becoming ill-formed. | 1373 | // subprograms from becoming ill-formed. |
| 1373 | const debug_incomplete_type = switch (ty.zigTypeTag(zcu)) { | 1374 | const debug_incomplete_type = switch (ty.zigTypeTag(zcu)) { |
| ... | @@ -1458,7 +1459,7 @@ pub const Object = struct { | ... | @@ -1458,7 +1459,7 @@ pub const Object = struct { |
| 1458 | const target = zcu.getTarget(); | 1459 | const target = zcu.getTarget(); |
| 1459 | const ip = &zcu.intern_pool; | 1460 | const ip = &zcu.intern_pool; |
| 1460 | 1461 | ||
| 1461 | const name = try o.builder.metadataStringFmt("{f}", .{ty.fmt(pt)}); | 1462 | const name = try o.builder.metadataStringFmt("{f}", .{ty.fmt(zcu)}); |
| 1462 | 1463 | ||
| 1463 | // lldb cannot handle non-byte-sized types, so in the logic below, bit sizes are padded up. | 1464 | // lldb cannot handle non-byte-sized types, so in the logic below, bit sizes are padded up. |
| 1464 | // For instance, `bool` is considered to be 8 bits, and `u60` is considered to be 64 bits. | 1465 | // For instance, `bool` is considered to be 8 bits, and `u60` is considered to be 64 bits. |
| ... | @@ -1967,7 +1968,7 @@ pub const Object = struct { | ... | @@ -1967,7 +1968,7 @@ pub const Object = struct { |
| 1967 | const debug_payload_type = try o.builder.debugUnionType( | 1968 | const debug_payload_type = try o.builder.debugUnionType( |
| 1968 | payload_name: { | 1969 | payload_name: { |
| 1969 | if (layout.tag_size == 0) break :payload_name name; | 1970 | if (layout.tag_size == 0) break :payload_name name; |
| 1970 | break :payload_name try o.builder.metadataStringFmt("{f}:Payload", .{ty.fmt(pt)}); | 1971 | break :payload_name try o.builder.metadataStringFmt("{f}:Payload", .{ty.fmt(zcu)}); |
| 1971 | }, | 1972 | }, |
| 1972 | file, | 1973 | file, |
| 1973 | scope, | 1974 | scope, |
src/codegen/loongarch/Select.zig+3-3| ... | @@ -3016,7 +3016,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) codegen.Error!void | ... | @@ -3016,7 +3016,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) codegen.Error!void |
| 3016 | isel: *Select, | 3016 | isel: *Select, |
| 3017 | inst: Air.Inst.Index, | 3017 | inst: Air.Inst.Index, |
| 3018 | pub fn format(fmt_air: @This(), writer: *std.Io.Writer) std.Io.Writer.Error!void { | 3018 | pub fn format(fmt_air: @This(), writer: *std.Io.Writer) std.Io.Writer.Error!void { |
| 3019 | fmt_air.isel.air.writeInst(writer, fmt_air.inst, fmt_air.isel.pt, null); | 3019 | fmt_air.isel.air.writeInst(writer, fmt_air.inst, fmt_air.isel.pt.zcu, null); |
| 3020 | } | 3020 | } |
| 3021 | } { | 3021 | } { |
| 3022 | return .{ .isel = it.isel, .inst = inst }; | 3022 | return .{ .isel = it.isel, .inst = inst }; |
| ... | @@ -5266,11 +5266,11 @@ fn fmtLoopLive(isel: *Select, loop_inst: Air.Inst.Index) struct { | ... | @@ -5266,11 +5266,11 @@ fn fmtLoopLive(isel: *Select, loop_inst: Air.Inst.Index) struct { |
| 5266 | } | 5266 | } |
| 5267 | 5267 | ||
| 5268 | fn fmtType(isel: *Select, ty: ZigType) ZigType.Formatter { | 5268 | fn fmtType(isel: *Select, ty: ZigType) ZigType.Formatter { |
| 5269 | return ty.fmt(isel.pt); | 5269 | return ty.fmt(isel.pt.zcu); |
| 5270 | } | 5270 | } |
| 5271 | 5271 | ||
| 5272 | fn fmtConstant(isel: *Select, constant: Constant) @typeInfo(@TypeOf(Constant.fmtValue)).@"fn".return_type.? { | 5272 | fn fmtConstant(isel: *Select, constant: Constant) @typeInfo(@TypeOf(Constant.fmtValue)).@"fn".return_type.? { |
| 5273 | return constant.fmtValue(isel.pt); | 5273 | return constant.fmtValue(isel.pt.zcu); |
| 5274 | } | 5274 | } |
| 5275 | 5275 | ||
| 5276 | fn fmtRegisterSet(regs: RegisterSet) struct { | 5276 | fn fmtRegisterSet(regs: RegisterSet) struct { |
src/codegen/riscv64/CodeGen.zig+18-18| ... | @@ -1291,7 +1291,7 @@ fn genLazy(func: *Func, lazy_sym: link.File.LazySymbol) InnerError!void { | ... | @@ -1291,7 +1291,7 @@ fn genLazy(func: *Func, lazy_sym: link.File.LazySymbol) InnerError!void { |
| 1291 | switch (Type.fromInterned(lazy_sym.ty).zigTypeTag(zcu)) { | 1291 | switch (Type.fromInterned(lazy_sym.ty).zigTypeTag(zcu)) { |
| 1292 | .@"enum" => { | 1292 | .@"enum" => { |
| 1293 | const enum_ty = Type.fromInterned(lazy_sym.ty); | 1293 | const enum_ty = Type.fromInterned(lazy_sym.ty); |
| 1294 | wip_mir_log.debug("{f}.@tagName:", .{enum_ty.fmt(pt)}); | 1294 | wip_mir_log.debug("{f}.@tagName:", .{enum_ty.fmt(zcu)}); |
| 1295 | 1295 | ||
| 1296 | const param_regs = abi.Registers.Integer.function_arg_regs; | 1296 | const param_regs = abi.Registers.Integer.function_arg_regs; |
| 1297 | const ret_reg = param_regs[0]; | 1297 | const ret_reg = param_regs[0]; |
| ... | @@ -1374,7 +1374,7 @@ fn genLazy(func: *Func, lazy_sym: link.File.LazySymbol) InnerError!void { | ... | @@ -1374,7 +1374,7 @@ fn genLazy(func: *Func, lazy_sym: link.File.LazySymbol) InnerError!void { |
| 1374 | }, | 1374 | }, |
| 1375 | else => return func.fail( | 1375 | else => return func.fail( |
| 1376 | "TODO implement {s} for {f}", | 1376 | "TODO implement {s} for {f}", |
| 1377 | .{ @tagName(lazy_sym.kind), Type.fromInterned(lazy_sym.ty).fmt(pt) }, | 1377 | .{ @tagName(lazy_sym.kind), Type.fromInterned(lazy_sym.ty).fmt(zcu) }, |
| 1378 | ), | 1378 | ), |
| 1379 | } | 1379 | } |
| 1380 | } | 1380 | } |
| ... | @@ -1911,7 +1911,7 @@ fn splitType(func: *Func, ty: Type) ![2]Type { | ... | @@ -1911,7 +1911,7 @@ fn splitType(func: *Func, ty: Type) ![2]Type { |
| 1911 | else => return func.fail("TODO: splitType class {}", .{class}), | 1911 | else => return func.fail("TODO: splitType class {}", .{class}), |
| 1912 | }; | 1912 | }; |
| 1913 | } else if (parts[0].abiSize(zcu) + parts[1].abiSize(zcu) == ty.abiSize(zcu)) return parts; | 1913 | } else if (parts[0].abiSize(zcu) + parts[1].abiSize(zcu) == ty.abiSize(zcu)) return parts; |
| 1914 | return func.fail("TODO implement splitType for {f}", .{ty.fmt(func.pt)}); | 1914 | return func.fail("TODO implement splitType for {f}", .{ty.fmt(zcu)}); |
| 1915 | } | 1915 | } |
| 1916 | 1916 | ||
| 1917 | /// Truncates the value in the register in place. | 1917 | /// Truncates the value in the register in place. |
| ... | @@ -2024,7 +2024,7 @@ fn allocMemPtr(func: *Func, inst: Air.Inst.Index) !FrameIndex { | ... | @@ -2024,7 +2024,7 @@ fn allocMemPtr(func: *Func, inst: Air.Inst.Index) !FrameIndex { |
| 2024 | const val_ty = ptr_ty.childType(zcu); | 2024 | const val_ty = ptr_ty.childType(zcu); |
| 2025 | return func.allocFrameIndex(FrameAlloc.init(.{ | 2025 | return func.allocFrameIndex(FrameAlloc.init(.{ |
| 2026 | .size = math.cast(u32, val_ty.abiSize(zcu)) orelse { | 2026 | .size = math.cast(u32, val_ty.abiSize(zcu)) orelse { |
| 2027 | return func.fail("type '{f}' too big to fit into stack frame", .{val_ty.fmt(pt)}); | 2027 | return func.fail("type '{f}' too big to fit into stack frame", .{val_ty.fmt(zcu)}); |
| 2028 | }, | 2028 | }, |
| 2029 | .alignment = ptr_ty.ptrAlignment(zcu).max(.@"1"), | 2029 | .alignment = ptr_ty.ptrAlignment(zcu).max(.@"1"), |
| 2030 | })); | 2030 | })); |
| ... | @@ -2164,7 +2164,7 @@ pub fn spillRegisters(func: *Func, comptime registers: []const Register) !void { | ... | @@ -2164,7 +2164,7 @@ pub fn spillRegisters(func: *Func, comptime registers: []const Register) !void { |
| 2164 | /// allocated. A second call to `copyToTmpRegister` may return the same register. | 2164 | /// allocated. A second call to `copyToTmpRegister` may return the same register. |
| 2165 | /// This can have a side effect of spilling instructions to the stack to free up a register. | 2165 | /// This can have a side effect of spilling instructions to the stack to free up a register. |
| 2166 | fn copyToTmpRegister(func: *Func, ty: Type, mcv: MCValue) !Register { | 2166 | fn copyToTmpRegister(func: *Func, ty: Type, mcv: MCValue) !Register { |
| 2167 | log.debug("copyToTmpRegister ty: {f}", .{ty.fmt(func.pt)}); | 2167 | log.debug("copyToTmpRegister ty: {f}", .{ty.fmt(func.pt.zcu)}); |
| 2168 | const reg = try func.register_manager.allocReg(null, func.regTempClassForType(ty)); | 2168 | const reg = try func.register_manager.allocReg(null, func.regTempClassForType(ty)); |
| 2169 | try func.genSetReg(ty, reg, mcv); | 2169 | try func.genSetReg(ty, reg, mcv); |
| 2170 | return reg; | 2170 | return reg; |
| ... | @@ -2249,7 +2249,7 @@ fn airIntCast(func: *Func, inst: Air.Inst.Index) !void { | ... | @@ -2249,7 +2249,7 @@ fn airIntCast(func: *Func, inst: Air.Inst.Index) !void { |
| 2249 | 2249 | ||
| 2250 | break :result dst_mcv; | 2250 | break :result dst_mcv; |
| 2251 | } orelse return func.fail("TODO: implement airIntCast from {f} to {f}", .{ | 2251 | } orelse return func.fail("TODO: implement airIntCast from {f} to {f}", .{ |
| 2252 | src_ty.fmt(pt), dst_ty.fmt(pt), | 2252 | src_ty.fmt(zcu), dst_ty.fmt(zcu), |
| 2253 | }); | 2253 | }); |
| 2254 | 2254 | ||
| 2255 | return func.finishAir(inst, result, .{ ty_op.operand, .none, .none }); | 2255 | return func.finishAir(inst, result, .{ ty_op.operand, .none, .none }); |
| ... | @@ -2636,7 +2636,7 @@ fn genBinOp( | ... | @@ -2636,7 +2636,7 @@ fn genBinOp( |
| 2636 | .add_sat, | 2636 | .add_sat, |
| 2637 | => { | 2637 | => { |
| 2638 | if (bit_size != 64 or !is_unsigned) | 2638 | if (bit_size != 64 or !is_unsigned) |
| 2639 | return func.fail("TODO: genBinOp ty: {f}", .{lhs_ty.fmt(pt)}); | 2639 | return func.fail("TODO: genBinOp ty: {f}", .{lhs_ty.fmt(zcu)}); |
| 2640 | 2640 | ||
| 2641 | const tmp_reg = try func.copyToTmpRegister(rhs_ty, .{ .register = rhs_reg }); | 2641 | const tmp_reg = try func.copyToTmpRegister(rhs_ty, .{ .register = rhs_reg }); |
| 2642 | const tmp_lock = func.register_manager.lockRegAssumeUnused(tmp_reg); | 2642 | const tmp_lock = func.register_manager.lockRegAssumeUnused(tmp_reg); |
| ... | @@ -4057,7 +4057,7 @@ fn airGetUnionTag(func: *Func, inst: Air.Inst.Index) !void { | ... | @@ -4057,7 +4057,7 @@ fn airGetUnionTag(func: *Func, inst: Air.Inst.Index) !void { |
| 4057 | } else { | 4057 | } else { |
| 4058 | return func.fail( | 4058 | return func.fail( |
| 4059 | "TODO implement get_union_tag for ABI larger than 8 bytes and operand {}, tag {f}", | 4059 | "TODO implement get_union_tag for ABI larger than 8 bytes and operand {}, tag {f}", |
| 4060 | .{ frame_mcv, tag_ty.fmt(pt) }, | 4060 | .{ frame_mcv, tag_ty.fmt(zcu) }, |
| 4061 | ); | 4061 | ); |
| 4062 | } | 4062 | } |
| 4063 | }, | 4063 | }, |
| ... | @@ -4177,7 +4177,7 @@ fn airAbs(func: *Func, inst: Air.Inst.Index) !void { | ... | @@ -4177,7 +4177,7 @@ fn airAbs(func: *Func, inst: Air.Inst.Index) !void { |
| 4177 | 4177 | ||
| 4178 | switch (scalar_ty.zigTypeTag(zcu)) { | 4178 | switch (scalar_ty.zigTypeTag(zcu)) { |
| 4179 | .int => if (ty.zigTypeTag(zcu) == .vector) { | 4179 | .int => if (ty.zigTypeTag(zcu) == .vector) { |
| 4180 | return func.fail("TODO implement airAbs for {f}", .{ty.fmt(pt)}); | 4180 | return func.fail("TODO implement airAbs for {f}", .{ty.fmt(zcu)}); |
| 4181 | } else { | 4181 | } else { |
| 4182 | const int_info = scalar_ty.intInfo(zcu); | 4182 | const int_info = scalar_ty.intInfo(zcu); |
| 4183 | const int_bits = int_info.bits; | 4183 | const int_bits = int_info.bits; |
| ... | @@ -4258,7 +4258,7 @@ fn airAbs(func: *Func, inst: Air.Inst.Index) !void { | ... | @@ -4258,7 +4258,7 @@ fn airAbs(func: *Func, inst: Air.Inst.Index) !void { |
| 4258 | 4258 | ||
| 4259 | break :result return_mcv; | 4259 | break :result return_mcv; |
| 4260 | }, | 4260 | }, |
| 4261 | else => return func.fail("TODO: implement airAbs {f}", .{scalar_ty.fmt(pt)}), | 4261 | else => return func.fail("TODO: implement airAbs {f}", .{scalar_ty.fmt(zcu)}), |
| 4262 | } | 4262 | } |
| 4263 | 4263 | ||
| 4264 | break :result .unreach; | 4264 | break :result .unreach; |
| ... | @@ -4322,7 +4322,7 @@ fn airByteSwap(func: *Func, inst: Air.Inst.Index) !void { | ... | @@ -4322,7 +4322,7 @@ fn airByteSwap(func: *Func, inst: Air.Inst.Index) !void { |
| 4322 | 4322 | ||
| 4323 | break :result dest_mcv; | 4323 | break :result dest_mcv; |
| 4324 | }, | 4324 | }, |
| 4325 | else => return func.fail("TODO: airByteSwap {f}", .{ty.fmt(pt)}), | 4325 | else => return func.fail("TODO: airByteSwap {f}", .{ty.fmt(zcu)}), |
| 4326 | } | 4326 | } |
| 4327 | }; | 4327 | }; |
| 4328 | return func.finishAir(inst, result, .{ ty_op.operand, .none, .none }); | 4328 | return func.finishAir(inst, result, .{ ty_op.operand, .none, .none }); |
| ... | @@ -4388,7 +4388,7 @@ fn airUnaryMath(func: *Func, inst: Air.Inst.Index, tag: Air.Inst.Tag) !void { | ... | @@ -4388,7 +4388,7 @@ fn airUnaryMath(func: *Func, inst: Air.Inst.Index, tag: Air.Inst.Tag) !void { |
| 4388 | else => return func.fail("TODO: airUnaryMath Float {s}", .{@tagName(tag)}), | 4388 | else => return func.fail("TODO: airUnaryMath Float {s}", .{@tagName(tag)}), |
| 4389 | } | 4389 | } |
| 4390 | }, | 4390 | }, |
| 4391 | else => return func.fail("TODO: airUnaryMath ty: {f}", .{ty.fmt(pt)}), | 4391 | else => return func.fail("TODO: airUnaryMath ty: {f}", .{ty.fmt(zcu)}), |
| 4392 | } | 4392 | } |
| 4393 | 4393 | ||
| 4394 | break :result MCValue{ .register = dst_reg }; | 4394 | break :result MCValue{ .register = dst_reg }; |
| ... | @@ -4488,7 +4488,7 @@ fn load(func: *Func, dst_mcv: MCValue, ptr_mcv: MCValue, ptr_ty: Type) InnerErro | ... | @@ -4488,7 +4488,7 @@ fn load(func: *Func, dst_mcv: MCValue, ptr_mcv: MCValue, ptr_ty: Type) InnerErro |
| 4488 | const zcu = pt.zcu; | 4488 | const zcu = pt.zcu; |
| 4489 | const dst_ty = ptr_ty.childType(zcu); | 4489 | const dst_ty = ptr_ty.childType(zcu); |
| 4490 | 4490 | ||
| 4491 | log.debug("loading {}:{f} into {}", .{ ptr_mcv, ptr_ty.fmt(pt), dst_mcv }); | 4491 | log.debug("loading {}:{f} into {}", .{ ptr_mcv, ptr_ty.fmt(zcu), dst_mcv }); |
| 4492 | 4492 | ||
| 4493 | switch (ptr_mcv) { | 4493 | switch (ptr_mcv) { |
| 4494 | .none, | 4494 | .none, |
| ... | @@ -4541,7 +4541,7 @@ fn airStore(func: *Func, inst: Air.Inst.Index, safety: bool) !void { | ... | @@ -4541,7 +4541,7 @@ fn airStore(func: *Func, inst: Air.Inst.Index, safety: bool) !void { |
| 4541 | fn store(func: *Func, ptr_mcv: MCValue, src_mcv: MCValue, ptr_ty: Type) !void { | 4541 | fn store(func: *Func, ptr_mcv: MCValue, src_mcv: MCValue, ptr_ty: Type) !void { |
| 4542 | const zcu = func.pt.zcu; | 4542 | const zcu = func.pt.zcu; |
| 4543 | const src_ty = ptr_ty.childType(zcu); | 4543 | const src_ty = ptr_ty.childType(zcu); |
| 4544 | log.debug("storing {}:{f} in {}:{f}", .{ src_mcv, src_ty.fmt(func.pt), ptr_mcv, ptr_ty.fmt(func.pt) }); | 4544 | log.debug("storing {}:{f} in {}:{f}", .{ src_mcv, src_ty.fmt(zcu), ptr_mcv, ptr_ty.fmt(zcu) }); |
| 4545 | 4545 | ||
| 4546 | switch (ptr_mcv) { | 4546 | switch (ptr_mcv) { |
| 4547 | .none => unreachable, | 4547 | .none => unreachable, |
| ... | @@ -7269,7 +7269,7 @@ fn airBitCast(func: *Func, inst: Air.Inst.Index) !void { | ... | @@ -7269,7 +7269,7 @@ fn airBitCast(func: *Func, inst: Air.Inst.Index) !void { |
| 7269 | const bit_size = dst_ty.bitSize(zcu); | 7269 | const bit_size = dst_ty.bitSize(zcu); |
| 7270 | if (abi_size * 8 <= bit_size) break :result dst_mcv; | 7270 | if (abi_size * 8 <= bit_size) break :result dst_mcv; |
| 7271 | 7271 | ||
| 7272 | return func.fail("TODO: airBitCast {f} to {f}", .{ src_ty.fmt(pt), dst_ty.fmt(pt) }); | 7272 | return func.fail("TODO: airBitCast {f} to {f}", .{ src_ty.fmt(zcu), dst_ty.fmt(zcu) }); |
| 7273 | }; | 7273 | }; |
| 7274 | return func.finishAir(inst, result, .{ ty_op.operand, .none, .none }); | 7274 | return func.finishAir(inst, result, .{ ty_op.operand, .none, .none }); |
| 7275 | } | 7275 | } |
| ... | @@ -8085,7 +8085,7 @@ fn airAggregateInit(func: *Func, inst: Air.Inst.Index) !void { | ... | @@ -8085,7 +8085,7 @@ fn airAggregateInit(func: *Func, inst: Air.Inst.Index) !void { |
| 8085 | ); | 8085 | ); |
| 8086 | break :result .{ .load_frame = .{ .index = frame_index } }; | 8086 | break :result .{ .load_frame = .{ .index = frame_index } }; |
| 8087 | }, | 8087 | }, |
| 8088 | else => return func.fail("TODO: airAggregate {f}", .{result_ty.fmt(pt)}), | 8088 | else => return func.fail("TODO: airAggregate {f}", .{result_ty.fmt(zcu)}), |
| 8089 | } | 8089 | } |
| 8090 | }; | 8090 | }; |
| 8091 | 8091 | ||
| ... | @@ -8279,7 +8279,7 @@ fn resolveCallingConventionValues( | ... | @@ -8279,7 +8279,7 @@ fn resolveCallingConventionValues( |
| 8279 | }; | 8279 | }; |
| 8280 | 8280 | ||
| 8281 | result.return_value = switch (ret_tracking_i) { | 8281 | result.return_value = switch (ret_tracking_i) { |
| 8282 | else => return func.fail("ty {f} took {} tracking return indices", .{ ret_ty.fmt(pt), ret_tracking_i }), | 8282 | else => return func.fail("ty {f} took {} tracking return indices", .{ ret_ty.fmt(zcu), ret_tracking_i }), |
| 8283 | 1 => ret_tracking[0], | 8283 | 1 => ret_tracking[0], |
| 8284 | 2 => InstTracking.init(.{ .register_pair = .{ | 8284 | 2 => InstTracking.init(.{ .register_pair = .{ |
| 8285 | ret_tracking[0].short.register, ret_tracking[1].short.register, | 8285 | ret_tracking[0].short.register, ret_tracking[1].short.register, |
| ... | @@ -8334,7 +8334,7 @@ fn resolveCallingConventionValues( | ... | @@ -8334,7 +8334,7 @@ fn resolveCallingConventionValues( |
| 8334 | else => return func.fail("TODO: C calling convention arg class {}", .{class}), | 8334 | else => return func.fail("TODO: C calling convention arg class {}", .{class}), |
| 8335 | } else { | 8335 | } else { |
| 8336 | arg.* = switch (arg_mcv_i) { | 8336 | arg.* = switch (arg_mcv_i) { |
| 8337 | else => return func.fail("ty {f} took {} tracking arg indices", .{ ty.fmt(pt), arg_mcv_i }), | 8337 | else => return func.fail("ty {f} took {} tracking arg indices", .{ ty.fmt(zcu), arg_mcv_i }), |
| 8338 | 1 => arg_mcv[0], | 8338 | 1 => arg_mcv[0], |
| 8339 | 2 => .{ .register_pair = .{ arg_mcv[0].register, arg_mcv[1].register } }, | 8339 | 2 => .{ .register_pair = .{ arg_mcv[0].register, arg_mcv[1].register } }, |
| 8340 | }; | 8340 | }; |
src/codegen/sparc64/CodeGen.zig+3-3| ... | @@ -985,7 +985,7 @@ fn airArg(self: *Self, inst: Air.Inst.Index) InnerError!void { | ... | @@ -985,7 +985,7 @@ fn airArg(self: *Self, inst: Air.Inst.Index) InnerError!void { |
| 985 | switch (self.args[arg_index]) { | 985 | switch (self.args[arg_index]) { |
| 986 | .stack_offset => |off| { | 986 | .stack_offset => |off| { |
| 987 | const abi_size = math.cast(u32, ty.abiSize(zcu)) orelse { | 987 | const abi_size = math.cast(u32, ty.abiSize(zcu)) orelse { |
| 988 | return self.fail("type '{f}' too big to fit into stack frame", .{ty.fmt(pt)}); | 988 | return self.fail("type '{f}' too big to fit into stack frame", .{ty.fmt(zcu)}); |
| 989 | }; | 989 | }; |
| 990 | const offset = off + abi_size; | 990 | const offset = off + abi_size; |
| 991 | break :blk .{ .stack_offset = offset }; | 991 | break :blk .{ .stack_offset = offset }; |
| ... | @@ -2722,7 +2722,7 @@ fn allocMemPtr(self: *Self, inst: Air.Inst.Index) !u32 { | ... | @@ -2722,7 +2722,7 @@ fn allocMemPtr(self: *Self, inst: Air.Inst.Index) !u32 { |
| 2722 | } | 2722 | } |
| 2723 | 2723 | ||
| 2724 | const abi_size = math.cast(u32, elem_ty.abiSize(zcu)) orelse { | 2724 | const abi_size = math.cast(u32, elem_ty.abiSize(zcu)) orelse { |
| 2725 | return self.fail("type '{f}' too big to fit into stack frame", .{elem_ty.fmt(pt)}); | 2725 | return self.fail("type '{f}' too big to fit into stack frame", .{elem_ty.fmt(zcu)}); |
| 2726 | }; | 2726 | }; |
| 2727 | // TODO swap this for inst.ty.ptrAlign | 2727 | // TODO swap this for inst.ty.ptrAlign |
| 2728 | const abi_align = elem_ty.abiAlignment(zcu); | 2728 | const abi_align = elem_ty.abiAlignment(zcu); |
| ... | @@ -2734,7 +2734,7 @@ fn allocRegOrMem(self: *Self, inst: Air.Inst.Index, reg_ok: bool) !MCValue { | ... | @@ -2734,7 +2734,7 @@ fn allocRegOrMem(self: *Self, inst: Air.Inst.Index, reg_ok: bool) !MCValue { |
| 2734 | const zcu = pt.zcu; | 2734 | const zcu = pt.zcu; |
| 2735 | const elem_ty = self.typeOfIndex(inst); | 2735 | const elem_ty = self.typeOfIndex(inst); |
| 2736 | const abi_size = math.cast(u32, elem_ty.abiSize(zcu)) orelse { | 2736 | const abi_size = math.cast(u32, elem_ty.abiSize(zcu)) orelse { |
| 2737 | return self.fail("type '{f}' too big to fit into stack frame", .{elem_ty.fmt(pt)}); | 2737 | return self.fail("type '{f}' too big to fit into stack frame", .{elem_ty.fmt(zcu)}); |
| 2738 | }; | 2738 | }; |
| 2739 | const abi_align = elem_ty.abiAlignment(zcu); | 2739 | const abi_align = elem_ty.abiAlignment(zcu); |
| 2740 | self.stack_align = self.stack_align.max(abi_align); | 2740 | self.stack_align = self.stack_align.max(abi_align); |
src/codegen/spirv/CodeGen.zig+157-121| ... | @@ -1297,8 +1297,8 @@ fn constant(cg: *CodeGen, ty: Type, val: Value, repr: Repr) Error!Id { | ... | @@ -1297,8 +1297,8 @@ fn constant(cg: *CodeGen, ty: Type, val: Value, repr: Repr) Error!Id { |
| 1297 | const ip = &zcu.intern_pool; | 1297 | const ip = &zcu.intern_pool; |
| 1298 | 1298 | ||
| 1299 | log.debug("lowering constant: ty = {f}, val = {f}, key = {s}", .{ | 1299 | log.debug("lowering constant: ty = {f}, val = {f}, key = {s}", .{ |
| 1300 | ty.fmt(pt), | 1300 | ty.fmt(zcu), |
| 1301 | val.fmtValue(pt), | 1301 | val.fmtValue(zcu), |
| 1302 | @tagName(ip.indexToKey(val.toIntern())), | 1302 | @tagName(ip.indexToKey(val.toIntern())), |
| 1303 | }); | 1303 | }); |
| 1304 | assert(!ty.isPtrAtRuntime(zcu)); | 1304 | assert(!ty.isPtrAtRuntime(zcu)); |
| ... | @@ -1640,7 +1640,6 @@ fn constant(cg: *CodeGen, ty: Type, val: Value, repr: Repr) Error!Id { | ... | @@ -1640,7 +1640,6 @@ fn constant(cg: *CodeGen, ty: Type, val: Value, repr: Repr) Error!Id { |
| 1640 | } | 1640 | } |
| 1641 | 1641 | ||
| 1642 | fn constantPtr(cg: *CodeGen, ptr_val: Value) !Id { | 1642 | fn constantPtr(cg: *CodeGen, ptr_val: Value) !Id { |
| 1643 | const pt = cg.pt; | ||
| 1644 | const zcu = cg.zcu; | 1643 | const zcu = cg.zcu; |
| 1645 | const gpa = cg.gpa; | 1644 | const gpa = cg.gpa; |
| 1646 | 1645 | ||
| ... | @@ -1653,32 +1652,64 @@ fn constantPtr(cg: *CodeGen, ptr_val: Value) !Id { | ... | @@ -1653,32 +1652,64 @@ fn constantPtr(cg: *CodeGen, ptr_val: Value) !Id { |
| 1653 | var arena = std.heap.ArenaAllocator.init(gpa); | 1652 | var arena = std.heap.ArenaAllocator.init(gpa); |
| 1654 | defer arena.deinit(); | 1653 | defer arena.deinit(); |
| 1655 | 1654 | ||
| 1656 | const derivation = try ptr_val.pointerDerivation(arena.allocator(), pt, null); | 1655 | // TODO: `Value.pointerDerivation` ought to do this for us, but it doesn't receive |
| 1657 | return cg.derivePtr(derivation); | 1656 | // `pt`, so it actually *can't* until https://github.com/ziglang/zig/issues/24061 is |
| 1657 | // implemented. | ||
| 1658 | const non_packed_ptr_val: Value = non_packed_ptr: { | ||
| 1659 | const ptr_info = ptr_val.typeOf(zcu).ptrInfo(zcu); | ||
| 1660 | if (ptr_info.packed_offset.host_size == 0) { | ||
| 1661 | break :non_packed_ptr ptr_val; | ||
| 1662 | } | ||
| 1663 | const backing_ty: Type = switch (ptr_info.flags.vector_index) { | ||
| 1664 | _ => try cg.pt.vectorType(.{ | ||
| 1665 | .child = ptr_info.child, | ||
| 1666 | .len = ptr_info.packed_offset.host_size, | ||
| 1667 | }), | ||
| 1668 | .none => try cg.pt.intType( | ||
| 1669 | .unsigned, | ||
| 1670 | @intCast(ptr_info.packed_offset.host_size * 8), | ||
| 1671 | ), | ||
| 1672 | }; | ||
| 1673 | const new_ptr_ty = try cg.pt.ptrType(info: { | ||
| 1674 | var info = ptr_info; | ||
| 1675 | info.child = backing_ty.toIntern(); | ||
| 1676 | info.packed_offset = .{ .host_size = 0, .bit_offset = 0 }; | ||
| 1677 | info.flags.vector_index = .none; | ||
| 1678 | break :info info; | ||
| 1679 | }); | ||
| 1680 | break :non_packed_ptr try cg.pt.getCoerced(ptr_val, new_ptr_ty); | ||
| 1681 | }; | ||
| 1682 | |||
| 1683 | const derivation = try non_packed_ptr_val.pointerDerivation(arena.allocator(), zcu, null); | ||
| 1684 | return cg.derivePtr(ptr_val.typeOf(zcu).ptrAddressSpace(zcu), derivation); | ||
| 1658 | } | 1685 | } |
| 1659 | 1686 | ||
| 1660 | fn derivePtr(cg: *CodeGen, derivation: Value.PointerDeriveStep) !Id { | 1687 | fn derivePtr(cg: *CodeGen, @"addrspace": std.lang.AddressSpace, derivation: Value.PointerDerivation) !Id { |
| 1661 | const gpa = cg.gpa; | 1688 | const gpa = cg.gpa; |
| 1662 | const pt = cg.pt; | ||
| 1663 | const zcu = cg.zcu; | 1689 | const zcu = cg.zcu; |
| 1664 | const target = zcu.getTarget(); | 1690 | const target = zcu.getTarget(); |
| 1665 | switch (derivation) { | 1691 | |
| 1666 | .comptime_alloc_ptr, .comptime_field_ptr => unreachable, | 1692 | const result_ty_id = try cg.ptrType( |
| 1693 | try cg.pointeeType(@"addrspace", derivation.elem_ty, false), | ||
| 1694 | cg.storageClass(@"addrspace"), | ||
| 1695 | ); | ||
| 1696 | |||
| 1697 | switch (derivation.addr) { | ||
| 1698 | .comptime_alloc, .comptime_field => unreachable, | ||
| 1667 | .int => |int| { | 1699 | .int => |int| { |
| 1668 | if (target.os.tag != .opencl) { | 1700 | if (target.os.tag != .opencl) { |
| 1669 | if (int.ptr_ty.ptrAddressSpace(zcu) != .physical_storage_buffer) { | 1701 | if (@"addrspace" != .physical_storage_buffer) { |
| 1670 | return cg.fail( | 1702 | return cg.fail( |
| 1671 | "cannot cast integer to pointer with address space '{s}'", | 1703 | "cannot cast integer to pointer with address space '{s}'", |
| 1672 | .{@tagName(int.ptr_ty.ptrAddressSpace(zcu))}, | 1704 | .{@tagName(@"addrspace")}, |
| 1673 | ); | 1705 | ); |
| 1674 | } | 1706 | } |
| 1675 | } | 1707 | } |
| 1676 | const result_ty_id = try cg.resolveType(int.ptr_ty, .direct); | ||
| 1677 | // TODO: This can probably be an OpSpecConstantOp Bitcast, but | 1708 | // TODO: This can probably be an OpSpecConstantOp Bitcast, but |
| 1678 | // that is not implemented by Mesa yet. Therefore, just generate it | 1709 | // that is not implemented by Mesa yet. Therefore, just generate it |
| 1679 | // as a runtime operation. | 1710 | // as a runtime operation. |
| 1680 | const result_ptr_id = cg.allocId(); | 1711 | const result_ptr_id = cg.allocId(); |
| 1681 | const value_id = try cg.constInt(.usize, int.addr); | 1712 | const value_id = try cg.constInt(.usize, int); |
| 1682 | try cg.body.emit(gpa, .OpConvertUToPtr, .{ | 1713 | try cg.body.emit(gpa, .OpConvertUToPtr, .{ |
| 1683 | .id_result_type = result_ty_id, | 1714 | .id_result_type = result_ty_id, |
| 1684 | .id_result = result_ptr_id, | 1715 | .id_result = result_ptr_id, |
| ... | @@ -1686,10 +1717,8 @@ fn derivePtr(cg: *CodeGen, derivation: Value.PointerDeriveStep) !Id { | ... | @@ -1686,10 +1717,8 @@ fn derivePtr(cg: *CodeGen, derivation: Value.PointerDeriveStep) !Id { |
| 1686 | }); | 1717 | }); |
| 1687 | return result_ptr_id; | 1718 | return result_ptr_id; |
| 1688 | }, | 1719 | }, |
| 1689 | .nav_ptr => |nav_index| { | 1720 | .nav => |nav_index| { |
| 1690 | const ip = &zcu.intern_pool; | 1721 | const ip = &zcu.intern_pool; |
| 1691 | const result_ptr_ty = try pt.navPtrType(nav_index); | ||
| 1692 | const ty_id = try cg.resolveType(result_ptr_ty, .direct); | ||
| 1693 | const nav = ip.getNav(nav_index); | 1722 | const nav = ip.getNav(nav_index); |
| 1694 | const nav_ty: Type = .fromInterned(nav.resolved.?.type); | 1723 | const nav_ty: Type = .fromInterned(nav.resolved.?.type); |
| 1695 | 1724 | ||
| ... | @@ -1698,10 +1727,10 @@ fn derivePtr(cg: *CodeGen, derivation: Value.PointerDeriveStep) !Id { | ... | @@ -1698,10 +1727,10 @@ fn derivePtr(cg: *CodeGen, derivation: Value.PointerDeriveStep) !Id { |
| 1698 | 1727 | ||
| 1699 | if (ip.isFunctionType(nav_ty.toIntern())) { | 1728 | if (ip.isFunctionType(nav_ty.toIntern())) { |
| 1700 | if (is_extern) return try cg.resolveExternFn(nav_index); | 1729 | if (is_extern) return try cg.resolveExternFn(nav_index); |
| 1701 | return try cg.constUndef(ty_id); | 1730 | return try cg.constUndef(result_ty_id); |
| 1702 | } | 1731 | } |
| 1703 | if (!nav_ty.hasRuntimeBits(zcu) and nav_ty.zigTypeTag(zcu) != .spirv) { | 1732 | if (!nav_ty.hasRuntimeBits(zcu) and nav_ty.zigTypeTag(zcu) != .spirv) { |
| 1704 | return cg.constUndef(ty_id); | 1733 | return cg.constUndef(result_ty_id); |
| 1705 | } | 1734 | } |
| 1706 | if (!is_extern) { | 1735 | if (!is_extern) { |
| 1707 | return cg.todo("pointer to constant '{f}'", .{nav.fqn.fmt(ip)}); | 1736 | return cg.todo("pointer to constant '{f}'", .{nav.fqn.fmt(ip)}); |
| ... | @@ -1718,7 +1747,7 @@ fn derivePtr(cg: *CodeGen, derivation: Value.PointerDeriveStep) !Id { | ... | @@ -1718,7 +1747,7 @@ fn derivePtr(cg: *CodeGen, derivation: Value.PointerDeriveStep) !Id { |
| 1718 | try cg.block_var_ids.put(gpa, var_id, {}); | 1747 | try cg.block_var_ids.put(gpa, var_id, {}); |
| 1719 | } | 1748 | } |
| 1720 | 1749 | ||
| 1721 | if (decl_ptr_ty_id == ty_id) return var_id; | 1750 | if (decl_ptr_ty_id == result_ty_id) return var_id; |
| 1722 | switch (target.os.tag) { | 1751 | switch (target.os.tag) { |
| 1723 | .vulkan, .opengl => return var_id, | 1752 | .vulkan, .opengl => return var_id, |
| 1724 | else => {}, | 1753 | else => {}, |
| ... | @@ -1726,63 +1755,63 @@ fn derivePtr(cg: *CodeGen, derivation: Value.PointerDeriveStep) !Id { | ... | @@ -1726,63 +1755,63 @@ fn derivePtr(cg: *CodeGen, derivation: Value.PointerDeriveStep) !Id { |
| 1726 | 1755 | ||
| 1727 | const casted_ptr_id = cg.allocId(); | 1756 | const casted_ptr_id = cg.allocId(); |
| 1728 | try cg.body.emit(gpa, .OpBitcast, .{ | 1757 | try cg.body.emit(gpa, .OpBitcast, .{ |
| 1729 | .id_result_type = ty_id, | 1758 | .id_result_type = result_ty_id, |
| 1730 | .id_result = casted_ptr_id, | 1759 | .id_result = casted_ptr_id, |
| 1731 | .operand = var_id, | 1760 | .operand = var_id, |
| 1732 | }); | 1761 | }); |
| 1733 | return casted_ptr_id; | 1762 | return casted_ptr_id; |
| 1734 | }, | 1763 | }, |
| 1735 | .uav_ptr => |uav| { | 1764 | .uav => |uav_val| { |
| 1736 | const ip = &zcu.intern_pool; | 1765 | const ip = &zcu.intern_pool; |
| 1737 | const result_ptr_ty: Type = .fromInterned(uav.orig_ty); | 1766 | const uav_ty = uav_val.typeOf(zcu); |
| 1738 | const ty_id = try cg.resolveType(result_ptr_ty, .direct); | ||
| 1739 | const uav_ty: Type = .fromInterned(ip.typeOf(uav.val)); | ||
| 1740 | 1767 | ||
| 1741 | switch (ip.indexToKey(uav.val)) { | 1768 | switch (ip.indexToKey(uav_val.toIntern())) { |
| 1742 | .func => unreachable, // TODO | 1769 | .func => unreachable, // TODO |
| 1743 | .@"extern" => assert(!ip.isFunctionType(uav_ty.toIntern())), | 1770 | .@"extern" => assert(!ip.isFunctionType(uav_ty.toIntern())), |
| 1744 | else => {}, | 1771 | else => {}, |
| 1745 | } | 1772 | } |
| 1746 | 1773 | ||
| 1747 | if (!uav_ty.hasRuntimeBits(zcu) and uav_ty.zigTypeTag(zcu) != .spirv) { | 1774 | if (!uav_ty.hasRuntimeBits(zcu) and uav_ty.zigTypeTag(zcu) != .spirv) { |
| 1748 | return cg.constUndef(ty_id); | 1775 | return cg.constUndef(result_ty_id); |
| 1749 | } | 1776 | } |
| 1750 | 1777 | ||
| 1751 | if (cg.storageClass(result_ptr_ty.ptrAddressSpace(zcu)) != .function) { | 1778 | if (cg.storageClass(@"addrspace") != .function) { |
| 1752 | return cg.todo("pointer to an anonymous constant of type '{f}'", .{uav_ty.fmt(pt)}); | 1779 | return cg.todo("pointer to an anonymous constant of type '{f}'", .{uav_ty.fmt(zcu)}); |
| 1753 | } | 1780 | } |
| 1754 | 1781 | ||
| 1755 | const uav_ty_id = try cg.resolveType(uav_ty, .indirect); | 1782 | const uav_ty_id = try cg.resolveType(uav_ty, .indirect); |
| 1756 | const ptr_id = try cg.alloc(uav_ty_id, null); | 1783 | const ptr_id = try cg.alloc(uav_ty_id, null); |
| 1757 | const val_id = try cg.constant(uav_ty, .fromInterned(uav.val), .indirect); | 1784 | const val_id = try cg.constant(uav_ty, uav_val, .indirect); |
| 1758 | try cg.body.emit(gpa, .OpStore, .{ .pointer = ptr_id, .object = val_id }); | 1785 | try cg.body.emit(gpa, .OpStore, .{ .pointer = ptr_id, .object = val_id }); |
| 1759 | return ptr_id; | 1786 | return ptr_id; |
| 1760 | }, | 1787 | }, |
| 1761 | .eu_payload_ptr => @panic("TODO"), | 1788 | .eu_payload => @panic("TODO"), |
| 1762 | .opt_payload_ptr => @panic("TODO"), | 1789 | .opt_payload => @panic("TODO"), |
| 1763 | .field_ptr => |field| { | 1790 | .field => |derived| return cg.structFieldPtr( |
| 1764 | const parent_ptr_id = try cg.derivePtr(field.parent.*); | 1791 | @"addrspace", |
| 1765 | const parent_ptr_ty = try field.parent.ptrType(pt); | 1792 | result_ty_id, |
| 1766 | return cg.structFieldPtr(field.result_ptr_ty, parent_ptr_ty, parent_ptr_id, field.field_idx); | 1793 | derivation.elem_ty, |
| 1767 | }, | 1794 | derived.parent.elem_ty, |
| 1768 | .elem_ptr => |elem| { | 1795 | try cg.derivePtr(@"addrspace", derived.parent.*), |
| 1769 | const parent_ptr_id = try cg.derivePtr(elem.parent.*); | 1796 | derived.field_index, |
| 1770 | const parent_ptr_ty = try elem.parent.ptrType(pt); | 1797 | ), |
| 1771 | const index_id = try cg.constInt(.usize, elem.elem_idx); | 1798 | .elem => |derived| return cg.ptrElemPtr( |
| 1772 | return cg.ptrElemPtr(parent_ptr_ty, parent_ptr_id, index_id); | 1799 | switch (derived.parent.size) { |
| 1773 | }, | 1800 | .one => .single_array_ptr, |
| 1774 | .offset_and_cast => |oac| { | 1801 | .many => .many_ptr, |
| 1775 | const parent_ptr_id = try cg.derivePtr(oac.parent.*); | 1802 | }, |
| 1776 | const parent_ptr_ty = try oac.parent.ptrType(pt); | 1803 | @"addrspace", |
| 1777 | 1804 | derived.parent.elem_ty, | |
| 1778 | if (oac.new_ptr_ty.ptrInfo(zcu).flags.vector_index != .none) { | 1805 | try cg.derivePtr(@"addrspace", derived.parent.*), |
| 1779 | return parent_ptr_id; | 1806 | try cg.constInt(.usize, derived.elem_index), |
| 1780 | } | 1807 | ), |
| 1808 | .offset_and_cast => |derived| { | ||
| 1809 | const parent_ptr_id = try cg.derivePtr(@"addrspace", derived.parent.*); | ||
| 1781 | 1810 | ||
| 1782 | if (oac.byte_offset == 0) { | 1811 | if (derived.byte_offset == 0) { |
| 1783 | var depth: u32 = 0; | 1812 | var depth: u32 = 0; |
| 1784 | var cur = parent_ptr_ty.childType(zcu); | 1813 | var cur = derived.parent.elem_ty; |
| 1785 | const dst_child = oac.new_ptr_ty.childType(zcu); | 1814 | const dst_child = derivation.elem_ty; |
| 1786 | while (cur.toIntern() != dst_child.toIntern()) { | 1815 | while (cur.toIntern() != dst_child.toIntern()) { |
| 1787 | switch (cur.zigTypeTag(zcu)) { | 1816 | switch (cur.zigTypeTag(zcu)) { |
| 1788 | .array => { | 1817 | .array => { |
| ... | @@ -1807,9 +1836,6 @@ fn derivePtr(cg: *CodeGen, derivation: Value.PointerDeriveStep) !Id { | ... | @@ -1807,9 +1836,6 @@ fn derivePtr(cg: *CodeGen, derivation: Value.PointerDeriveStep) !Id { |
| 1807 | } | 1836 | } |
| 1808 | if (cur.toIntern() == dst_child.toIntern()) { | 1837 | if (cur.toIntern() == dst_child.toIntern()) { |
| 1809 | if (depth != 0) { | 1838 | if (depth != 0) { |
| 1810 | const as = oac.new_ptr_ty.ptrAddressSpace(zcu); | ||
| 1811 | const child_ty_id = try cg.pointeeType(as, dst_child, false); | ||
| 1812 | const result_ty_id = try cg.ptrType(child_ty_id, cg.storageClass(as)); | ||
| 1813 | const scratch_top = cg.id_scratch.items.len; | 1839 | const scratch_top = cg.id_scratch.items.len; |
| 1814 | defer cg.id_scratch.shrinkRetainingCapacity(scratch_top); | 1840 | defer cg.id_scratch.shrinkRetainingCapacity(scratch_top); |
| 1815 | const zero = try cg.constInt(.u32, 0); | 1841 | const zero = try cg.constInt(.u32, 0); |
| ... | @@ -1820,7 +1846,6 @@ fn derivePtr(cg: *CodeGen, derivation: Value.PointerDeriveStep) !Id { | ... | @@ -1820,7 +1846,6 @@ fn derivePtr(cg: *CodeGen, derivation: Value.PointerDeriveStep) !Id { |
| 1820 | return parent_ptr_id; | 1846 | return parent_ptr_id; |
| 1821 | } | 1847 | } |
| 1822 | } | 1848 | } |
| 1823 | const result_ty_id = try cg.resolveType(oac.new_ptr_ty, .direct); | ||
| 1824 | if (target.os.tag == .opencl) { | 1849 | if (target.os.tag == .opencl) { |
| 1825 | const result_ptr_id = cg.allocId(); | 1850 | const result_ptr_id = cg.allocId(); |
| 1826 | try cg.body.emit(gpa, .OpBitcast, .{ | 1851 | try cg.body.emit(gpa, .OpBitcast, .{ |
| ... | @@ -1832,9 +1857,9 @@ fn derivePtr(cg: *CodeGen, derivation: Value.PointerDeriveStep) !Id { | ... | @@ -1832,9 +1857,9 @@ fn derivePtr(cg: *CodeGen, derivation: Value.PointerDeriveStep) !Id { |
| 1832 | } | 1857 | } |
| 1833 | } | 1858 | } |
| 1834 | 1859 | ||
| 1835 | return cg.fail("cannot cast pointer '{f}' to '{f}'", .{ | 1860 | return cg.fail("cannot cast pointer '*{f}' to '*{f}'", .{ |
| 1836 | parent_ptr_ty.fmt(pt), | 1861 | derived.parent.elem_ty.fmt(zcu), |
| 1837 | oac.new_ptr_ty.fmt(pt), | 1862 | derivation.elem_ty.fmt(zcu), |
| 1838 | }); | 1863 | }); |
| 1839 | }, | 1864 | }, |
| 1840 | } | 1865 | } |
| ... | @@ -1881,7 +1906,7 @@ fn resolveType(cg: *CodeGen, ty: Type, repr: Repr) Error!Id { | ... | @@ -1881,7 +1906,7 @@ fn resolveType(cg: *CodeGen, ty: Type, repr: Repr) Error!Id { |
| 1881 | const ip = &zcu.intern_pool; | 1906 | const ip = &zcu.intern_pool; |
| 1882 | const target = cg.zcu.getTarget(); | 1907 | const target = cg.zcu.getTarget(); |
| 1883 | 1908 | ||
| 1884 | log.debug("resolveType: ty = {f}", .{ty.fmt(pt)}); | 1909 | log.debug("resolveType: ty = {f}", .{ty.fmt(zcu)}); |
| 1885 | 1910 | ||
| 1886 | switch (ty.zigTypeTag(zcu)) { | 1911 | switch (ty.zigTypeTag(zcu)) { |
| 1887 | .noreturn => { | 1912 | .noreturn => { |
| ... | @@ -1919,7 +1944,7 @@ fn resolveType(cg: *CodeGen, ty: Type, repr: Repr) Error!Id { | ... | @@ -1919,7 +1944,7 @@ fn resolveType(cg: *CodeGen, ty: Type, repr: Repr) Error!Id { |
| 1919 | }; | 1944 | }; |
| 1920 | if (!supported) return cg.fail( | 1945 | if (!supported) return cg.fail( |
| 1921 | "'{f}' is not supported on the current SPIR-V feature set", | 1946 | "'{f}' is not supported on the current SPIR-V feature set", |
| 1922 | .{ty.fmt(cg.pt)}, | 1947 | .{ty.fmt(zcu)}, |
| 1923 | ); | 1948 | ); |
| 1924 | return try cg.floatType(bits); | 1949 | return try cg.floatType(bits); |
| 1925 | }, | 1950 | }, |
| ... | @@ -2047,7 +2072,7 @@ fn resolveType(cg: *CodeGen, ty: Type, repr: Repr) Error!Id { | ... | @@ -2047,7 +2072,7 @@ fn resolveType(cg: *CodeGen, ty: Type, repr: Repr) Error!Id { |
| 2047 | null, | 2072 | null, |
| 2048 | .none, | 2073 | .none, |
| 2049 | ); | 2074 | ); |
| 2050 | try cg.debugNameFmt(result_id, "{f}", .{ty.fmt(cg.pt)}); | 2075 | try cg.debugNameFmt(result_id, "{f}", .{ty.fmt(zcu)}); |
| 2051 | return result_id; | 2076 | return result_id; |
| 2052 | }, | 2077 | }, |
| 2053 | .struct_type => ip.loadStructType(ty.toIntern()), | 2078 | .struct_type => ip.loadStructType(ty.toIntern()), |
| ... | @@ -2080,7 +2105,7 @@ fn resolveType(cg: *CodeGen, ty: Type, repr: Repr) Error!Id { | ... | @@ -2080,7 +2105,7 @@ fn resolveType(cg: *CodeGen, ty: Type, repr: Repr) Error!Id { |
| 2080 | ty.toIntern(), | 2105 | ty.toIntern(), |
| 2081 | ); | 2106 | ); |
| 2082 | 2107 | ||
| 2083 | try cg.debugNameFmt(result_id, "{f}", .{ty.fmt(cg.pt)}); | 2108 | try cg.debugNameFmt(result_id, "{f}", .{ty.fmt(zcu)}); |
| 2084 | 2109 | ||
| 2085 | return result_id; | 2110 | return result_id; |
| 2086 | }, | 2111 | }, |
| ... | @@ -2134,7 +2159,7 @@ fn resolveType(cg: *CodeGen, ty: Type, repr: Repr) Error!Id { | ... | @@ -2134,7 +2159,7 @@ fn resolveType(cg: *CodeGen, ty: Type, repr: Repr) Error!Id { |
| 2134 | } | 2159 | } |
| 2135 | 2160 | ||
| 2136 | const result_id = try cg.structType(member_types[0..len], null, .none); | 2161 | const result_id = try cg.structType(member_types[0..len], null, .none); |
| 2137 | try cg.debugNameFmt(result_id, "{f}", .{ty.fmt(cg.pt)}); | 2162 | try cg.debugNameFmt(result_id, "{f}", .{ty.fmt(zcu)}); |
| 2138 | return result_id; | 2163 | return result_id; |
| 2139 | }, | 2164 | }, |
| 2140 | } | 2165 | } |
| ... | @@ -2169,7 +2194,7 @@ fn resolveType(cg: *CodeGen, ty: Type, repr: Repr) Error!Id { | ... | @@ -2169,7 +2194,7 @@ fn resolveType(cg: *CodeGen, ty: Type, repr: Repr) Error!Id { |
| 2169 | member_names[0..layout.total_fields], | 2194 | member_names[0..layout.total_fields], |
| 2170 | .none, | 2195 | .none, |
| 2171 | ); | 2196 | ); |
| 2172 | try cg.debugNameFmt(result_id, "{f}", .{ty.fmt(cg.pt)}); | 2197 | try cg.debugNameFmt(result_id, "{f}", .{ty.fmt(zcu)}); |
| 2173 | return result_id; | 2198 | return result_id; |
| 2174 | }, | 2199 | }, |
| 2175 | .error_set => { | 2200 | .error_set => { |
| ... | @@ -2206,7 +2231,7 @@ fn resolveType(cg: *CodeGen, ty: Type, repr: Repr) Error!Id { | ... | @@ -2206,7 +2231,7 @@ fn resolveType(cg: *CodeGen, ty: Type, repr: Repr) Error!Id { |
| 2206 | }, | 2231 | }, |
| 2207 | .@"opaque" => { | 2232 | .@"opaque" => { |
| 2208 | if (target.os.tag != .opencl) return cg.fail("cannot generate opaque type", .{}); | 2233 | if (target.os.tag != .opencl) return cg.fail("cannot generate opaque type", .{}); |
| 2209 | return try cg.opaqueType("{f}", .{ty.fmt(cg.pt)}); | 2234 | return try cg.opaqueType("{f}", .{ty.fmt(zcu)}); |
| 2210 | }, | 2235 | }, |
| 2211 | .spirv => { | 2236 | .spirv => { |
| 2212 | const spirv_type = ip.loadSpirvType(ty.toIntern()); | 2237 | const spirv_type = ip.loadSpirvType(ty.toIntern()); |
| ... | @@ -6455,21 +6480,28 @@ fn airSliceElemVal(cg: *CodeGen, inst: Air.Inst.Index) !?Id { | ... | @@ -6455,21 +6480,28 @@ fn airSliceElemVal(cg: *CodeGen, inst: Air.Inst.Index) !?Id { |
| 6455 | return try cg.load(slice_ty.childType(zcu), elem_ptr, .{ .is_volatile = slice_ty.isVolatilePtr(zcu) }); | 6480 | return try cg.load(slice_ty.childType(zcu), elem_ptr, .{ .is_volatile = slice_ty.isVolatilePtr(zcu) }); |
| 6456 | } | 6481 | } |
| 6457 | 6482 | ||
| 6458 | fn ptrElemPtr(cg: *CodeGen, ptr_ty: Type, ptr_id: Id, index_id: Id) !Id { | 6483 | fn ptrElemPtr( |
| 6459 | const zcu = cg.zcu; | 6484 | cg: *CodeGen, |
| 6485 | mode: enum { single_array_ptr, many_ptr }, | ||
| 6486 | @"addrspace": std.lang.AddressSpace, | ||
| 6487 | elem_ty: Type, | ||
| 6488 | ptr_id: Id, | ||
| 6489 | index_id: Id, | ||
| 6490 | ) !Id { | ||
| 6460 | // Construct new pointer type for the resulting pointer | 6491 | // Construct new pointer type for the resulting pointer |
| 6461 | const as = ptr_ty.ptrAddressSpace(zcu); | ||
| 6462 | const is_single_ptr = ptr_ty.isSinglePointer(zcu); | ||
| 6463 | const elem_is_block = cg.block_var_ids.contains(ptr_id); | 6492 | const elem_is_block = cg.block_var_ids.contains(ptr_id); |
| 6464 | const elem_ty_id = try cg.pointeeType(as, ptr_ty.indexableElem(zcu), elem_is_block); | 6493 | const elem_ty_id = try cg.pointeeType(@"addrspace", elem_ty, elem_is_block); |
| 6465 | const elem_ptr_ty_id = try cg.ptrType(elem_ty_id, cg.storageClass(as)); | 6494 | const elem_ptr_ty_id = try cg.ptrType(elem_ty_id, cg.storageClass(@"addrspace")); |
| 6466 | if (is_single_ptr) { | 6495 | switch (mode) { |
| 6467 | // Pointer-to-array. In this case, the resulting pointer is not of the same type | 6496 | .single_array_ptr => { |
| 6468 | // as the ptr_ty (we want a *T, not a *[N]T), and hence we need to use accessChain. | 6497 | // Pointer-to-array. In this case, the resulting pointer is not of the same type |
| 6469 | return cg.accessChainId(elem_ptr_ty_id, ptr_id, &.{index_id}); | 6498 | // as the ptr_ty (we want a *T, not a *[N]T), and hence we need to use accessChain. |
| 6470 | } else { | 6499 | return cg.accessChainId(elem_ptr_ty_id, ptr_id, &.{index_id}); |
| 6471 | // Resulting pointer type is the same as the ptr_ty, so use ptrAccessChain | 6500 | }, |
| 6472 | return cg.ptrAccessChain(elem_ptr_ty_id, ptr_id, index_id, &.{}); | 6501 | .many_ptr => { |
| 6502 | // Resulting pointer type is the same as the ptr_ty, so use ptrAccessChain | ||
| 6503 | return cg.ptrAccessChain(elem_ptr_ty_id, ptr_id, index_id, &.{}); | ||
| 6504 | }, | ||
| 6473 | } | 6505 | } |
| 6474 | } | 6506 | } |
| 6475 | 6507 | ||
| ... | @@ -6483,13 +6515,19 @@ fn airPtrElemPtr(cg: *CodeGen, inst: Air.Inst.Index) !?Id { | ... | @@ -6483,13 +6515,19 @@ fn airPtrElemPtr(cg: *CodeGen, inst: Air.Inst.Index) !?Id { |
| 6483 | const ty_pl = cg.air.instructions.items(.data)[@backingInt(inst)].ty_pl; | 6515 | const ty_pl = cg.air.instructions.items(.data)[@backingInt(inst)].ty_pl; |
| 6484 | const bin_op = cg.air.extraData(Air.Bin, ty_pl.payload).data; | 6516 | const bin_op = cg.air.extraData(Air.Bin, ty_pl.payload).data; |
| 6485 | const src_ptr_ty = cg.typeOf(bin_op.lhs); | 6517 | const src_ptr_ty = cg.typeOf(bin_op.lhs); |
| 6486 | const elem_ty = src_ptr_ty.childType(zcu); | 6518 | const elem_ty = src_ptr_ty.indexableElem(zcu); |
| 6487 | const ptr_id = try cg.resolve(bin_op.lhs); | 6519 | const ptr_id = try cg.resolve(bin_op.lhs); |
| 6488 | 6520 | ||
| 6489 | assert(elem_ty.hasRuntimeBits(zcu)); | 6521 | assert(elem_ty.hasRuntimeBits(zcu)); |
| 6490 | 6522 | ||
| 6491 | const index_id = try cg.resolve(bin_op.rhs); | 6523 | const index_id = try cg.resolve(bin_op.rhs); |
| 6492 | return try cg.ptrElemPtr(src_ptr_ty, ptr_id, index_id); | 6524 | return try cg.ptrElemPtr( |
| 6525 | if (src_ptr_ty.isSinglePointer(zcu)) .single_array_ptr else .many_ptr, | ||
| 6526 | src_ptr_ty.ptrAddressSpace(zcu), | ||
| 6527 | elem_ty, | ||
| 6528 | ptr_id, | ||
| 6529 | index_id, | ||
| 6530 | ); | ||
| 6493 | } | 6531 | } |
| 6494 | 6532 | ||
| 6495 | fn airArrayElemVal(cg: *CodeGen, inst: Air.Inst.Index) !?Id { | 6533 | fn airArrayElemVal(cg: *CodeGen, inst: Air.Inst.Index) !?Id { |
| ... | @@ -6551,7 +6589,13 @@ fn airPtrElemVal(cg: *CodeGen, inst: Air.Inst.Index) !?Id { | ... | @@ -6551,7 +6589,13 @@ fn airPtrElemVal(cg: *CodeGen, inst: Air.Inst.Index) !?Id { |
| 6551 | const elem_ty = cg.typeOfIndex(inst); | 6589 | const elem_ty = cg.typeOfIndex(inst); |
| 6552 | const ptr_id = try cg.resolve(bin_op.lhs); | 6590 | const ptr_id = try cg.resolve(bin_op.lhs); |
| 6553 | const index_id = try cg.resolve(bin_op.rhs); | 6591 | const index_id = try cg.resolve(bin_op.rhs); |
| 6554 | const elem_ptr_id = try cg.ptrElemPtr(ptr_ty, ptr_id, index_id); | 6592 | const elem_ptr_id = try cg.ptrElemPtr( |
| 6593 | if (ptr_ty.isSinglePointer(zcu)) .single_array_ptr else .many_ptr, | ||
| 6594 | ptr_ty.ptrAddressSpace(zcu), | ||
| 6595 | elem_ty, | ||
| 6596 | ptr_id, | ||
| 6597 | index_id, | ||
| 6598 | ); | ||
| 6555 | return try cg.load(elem_ty, elem_ptr_id, .{ .is_volatile = ptr_ty.isVolatilePtr(zcu) }); | 6599 | return try cg.load(elem_ty, elem_ptr_id, .{ .is_volatile = ptr_ty.isVolatilePtr(zcu) }); |
| 6556 | } | 6600 | } |
| 6557 | 6601 | ||
| ... | @@ -6845,66 +6889,44 @@ fn airFieldParentPtr(cg: *CodeGen, inst: Air.Inst.Index) !?Id { | ... | @@ -6845,66 +6889,44 @@ fn airFieldParentPtr(cg: *CodeGen, inst: Air.Inst.Index) !?Id { |
| 6845 | 6889 | ||
| 6846 | fn structFieldPtr( | 6890 | fn structFieldPtr( |
| 6847 | cg: *CodeGen, | 6891 | cg: *CodeGen, |
| 6848 | result_ptr_ty: Type, | 6892 | @"addrspace": std.lang.AddressSpace, |
| 6849 | object_ptr_ty: Type, | 6893 | result_ptr_ty_id: Id, |
| 6894 | field_ty: Type, | ||
| 6895 | object_ty: Type, | ||
| 6850 | object_ptr: Id, | 6896 | object_ptr: Id, |
| 6851 | field_index: u32, | 6897 | field_index: u32, |
| 6852 | ) !Id { | 6898 | ) !Id { |
| 6853 | const result_ty_id = try cg.resolveType(result_ptr_ty, .direct); | ||
| 6854 | |||
| 6855 | const zcu = cg.zcu; | 6899 | const zcu = cg.zcu; |
| 6856 | const object_ty = object_ptr_ty.childType(zcu); | ||
| 6857 | switch (object_ty.zigTypeTag(zcu)) { | 6900 | switch (object_ty.zigTypeTag(zcu)) { |
| 6858 | .pointer => { | 6901 | .pointer => { |
| 6859 | assert(object_ty.isSlice(zcu)); | 6902 | assert(object_ty.isSlice(zcu)); |
| 6860 | return cg.accessChain(result_ty_id, object_ptr, &.{field_index}); | 6903 | return cg.accessChain(result_ptr_ty_id, object_ptr, &.{field_index}); |
| 6861 | }, | 6904 | }, |
| 6862 | .@"struct" => switch (object_ty.containerLayout(zcu)) { | 6905 | .@"struct" => switch (object_ty.containerLayout(zcu)) { |
| 6863 | .@"packed" => { | 6906 | .@"packed" => unreachable, |
| 6864 | const byte_offset = codegen.fieldOffset(object_ptr_ty, result_ptr_ty, field_index, zcu); | ||
| 6865 | if (byte_offset == 0) return object_ptr; | ||
| 6866 | const usize_ty_id = try cg.resolveType(.usize, .direct); | ||
| 6867 | const base_int = cg.allocId(); | ||
| 6868 | try cg.body.emit(cg.gpa, .OpConvertPtrToU, .{ | ||
| 6869 | .id_result_type = usize_ty_id, | ||
| 6870 | .id_result = base_int, | ||
| 6871 | .pointer = object_ptr, | ||
| 6872 | }); | ||
| 6873 | const offset_id = try cg.constInt(.usize, byte_offset); | ||
| 6874 | const adjusted = try cg.buildBinary(.OpIAdd, .{ .ty = .usize, .value = .{ .singleton = base_int } }, .{ .ty = .usize, .value = .{ .singleton = offset_id } }); | ||
| 6875 | const adjusted_id = try adjusted.materialize(cg); | ||
| 6876 | const result_id = cg.allocId(); | ||
| 6877 | try cg.body.emit(cg.gpa, .OpConvertUToPtr, .{ | ||
| 6878 | .id_result_type = result_ty_id, | ||
| 6879 | .id_result = result_id, | ||
| 6880 | .integer_value = adjusted_id, | ||
| 6881 | }); | ||
| 6882 | return result_id; | ||
| 6883 | }, | ||
| 6884 | .auto, .@"extern" => { | 6907 | .auto, .@"extern" => { |
| 6885 | const member_index = cg.memberIndex(object_ty, field_index); | 6908 | const member_index = cg.memberIndex(object_ty, field_index); |
| 6886 | return try cg.accessChain(result_ty_id, object_ptr, &.{member_index}); | 6909 | return try cg.accessChain(result_ptr_ty_id, object_ptr, &.{member_index}); |
| 6887 | }, | 6910 | }, |
| 6888 | }, | 6911 | }, |
| 6889 | .@"union" => switch (object_ty.containerLayout(zcu)) { | 6912 | .@"union" => switch (object_ty.containerLayout(zcu)) { |
| 6890 | .@"packed" => return cg.todo("implement field access for packed unions", .{}), | 6913 | .@"packed" => unreachable, |
| 6891 | .auto => { | 6914 | .auto => { |
| 6892 | if (!result_ptr_ty.childType(zcu).hasRuntimeBits(zcu)) return try cg.constUndef(result_ty_id); | 6915 | if (!field_ty.hasRuntimeBits(zcu)) return try cg.constUndef(result_ptr_ty_id); |
| 6893 | return try cg.accessChain(result_ty_id, object_ptr, &.{field_index}); | 6916 | return try cg.accessChain(result_ptr_ty_id, object_ptr, &.{field_index}); |
| 6894 | }, | 6917 | }, |
| 6895 | .@"extern" => { | 6918 | .@"extern" => { |
| 6896 | const layout = cg.unionLayout(object_ty); | 6919 | const layout = cg.unionLayout(object_ty); |
| 6897 | if (!layout.has_payload) { | 6920 | if (!layout.has_payload) { |
| 6898 | // Asked to get a pointer to a zero-sized field. Just lower this | 6921 | // Asked to get a pointer to a zero-sized field. Just lower this |
| 6899 | // to undefined, there is no reason to make it be a valid pointer. | 6922 | // to undefined, there is no reason to make it be a valid pointer. |
| 6900 | return try cg.constUndef(result_ty_id); | 6923 | return try cg.constUndef(result_ptr_ty_id); |
| 6901 | } | 6924 | } |
| 6902 | 6925 | ||
| 6903 | const storage_class = cg.storageClass(object_ptr_ty.ptrAddressSpace(zcu)); | 6926 | const storage_class = cg.storageClass(@"addrspace"); |
| 6904 | const field_ty = result_ptr_ty.childType(zcu); | ||
| 6905 | if (field_ty.toIntern() == layout.payload_ty.toIntern()) { | 6927 | if (field_ty.toIntern() == layout.payload_ty.toIntern()) { |
| 6906 | if (object_ty.containerLayout(zcu) == .@"packed") return object_ptr; | 6928 | if (object_ty.containerLayout(zcu) == .@"packed") return object_ptr; |
| 6907 | return try cg.accessChain(result_ty_id, object_ptr, &.{layout.payload_index}); | 6929 | return try cg.accessChain(result_ptr_ty_id, object_ptr, &.{layout.payload_index}); |
| 6908 | } | 6930 | } |
| 6909 | 6931 | ||
| 6910 | switch (zcu.getTarget().os.tag) { | 6932 | switch (zcu.getTarget().os.tag) { |
| ... | @@ -6913,7 +6935,7 @@ fn structFieldPtr( | ... | @@ -6913,7 +6935,7 @@ fn structFieldPtr( |
| 6913 | // type is structurally identical to the payload type (dedup will | 6935 | // type is structurally identical to the payload type (dedup will |
| 6914 | // unify them) the access chain typed as the field type is valid. | 6936 | // unify them) the access chain typed as the field type is valid. |
| 6915 | if (object_ty.containerLayout(zcu) == .@"packed") return object_ptr; | 6937 | if (object_ty.containerLayout(zcu) == .@"packed") return object_ptr; |
| 6916 | return try cg.accessChain(result_ty_id, object_ptr, &.{layout.payload_index}); | 6938 | return try cg.accessChain(result_ptr_ty_id, object_ptr, &.{layout.payload_index}); |
| 6917 | }, | 6939 | }, |
| 6918 | else => {}, | 6940 | else => {}, |
| 6919 | } | 6941 | } |
| ... | @@ -6927,7 +6949,7 @@ fn structFieldPtr( | ... | @@ -6927,7 +6949,7 @@ fn structFieldPtr( |
| 6927 | 6949 | ||
| 6928 | const active_pl_ptr_id = cg.allocId(); | 6950 | const active_pl_ptr_id = cg.allocId(); |
| 6929 | try cg.body.emit(cg.gpa, .OpBitcast, .{ | 6951 | try cg.body.emit(cg.gpa, .OpBitcast, .{ |
| 6930 | .id_result_type = result_ty_id, | 6952 | .id_result_type = result_ptr_ty_id, |
| 6931 | .id_result = active_pl_ptr_id, | 6953 | .id_result = active_pl_ptr_id, |
| 6932 | .operand = pl_ptr_id, | 6954 | .operand = pl_ptr_id, |
| 6933 | }); | 6955 | }); |
| ... | @@ -6971,7 +6993,14 @@ fn airStructFieldPtr(cg: *CodeGen, inst: Air.Inst.Index) !?Id { | ... | @@ -6971,7 +6993,14 @@ fn airStructFieldPtr(cg: *CodeGen, inst: Air.Inst.Index) !?Id { |
| 6971 | const struct_ptr = try cg.resolve(struct_field.struct_operand); | 6993 | const struct_ptr = try cg.resolve(struct_field.struct_operand); |
| 6972 | const struct_ptr_ty = cg.typeOf(struct_field.struct_operand); | 6994 | const struct_ptr_ty = cg.typeOf(struct_field.struct_operand); |
| 6973 | const result_ptr_ty = cg.typeOfIndex(inst); | 6995 | const result_ptr_ty = cg.typeOfIndex(inst); |
| 6974 | return try cg.structFieldPtr(result_ptr_ty, struct_ptr_ty, struct_ptr, struct_field.field_index); | 6996 | return try cg.structFieldPtr( |
| 6997 | struct_ptr_ty.ptrAddressSpace(cg.zcu), | ||
| 6998 | try cg.resolveType(result_ptr_ty, .direct), | ||
| 6999 | result_ptr_ty.childType(cg.zcu), | ||
| 7000 | struct_ptr_ty.childType(cg.zcu), | ||
| 7001 | struct_ptr, | ||
| 7002 | struct_field.field_index, | ||
| 7003 | ); | ||
| 6975 | } | 7004 | } |
| 6976 | 7005 | ||
| 6977 | fn airStructFieldPtrIndex(cg: *CodeGen, inst: Air.Inst.Index, field_index: u32) !?Id { | 7006 | fn airStructFieldPtrIndex(cg: *CodeGen, inst: Air.Inst.Index, field_index: u32) !?Id { |
| ... | @@ -6979,7 +7008,14 @@ fn airStructFieldPtrIndex(cg: *CodeGen, inst: Air.Inst.Index, field_index: u32) | ... | @@ -6979,7 +7008,14 @@ fn airStructFieldPtrIndex(cg: *CodeGen, inst: Air.Inst.Index, field_index: u32) |
| 6979 | const struct_ptr = try cg.resolve(ty_op.operand); | 7008 | const struct_ptr = try cg.resolve(ty_op.operand); |
| 6980 | const struct_ptr_ty = cg.typeOf(ty_op.operand); | 7009 | const struct_ptr_ty = cg.typeOf(ty_op.operand); |
| 6981 | const result_ptr_ty = cg.typeOfIndex(inst); | 7010 | const result_ptr_ty = cg.typeOfIndex(inst); |
| 6982 | return try cg.structFieldPtr(result_ptr_ty, struct_ptr_ty, struct_ptr, field_index); | 7011 | return try cg.structFieldPtr( |
| 7012 | struct_ptr_ty.ptrAddressSpace(cg.zcu), | ||
| 7013 | try cg.resolveType(result_ptr_ty, .direct), | ||
| 7014 | result_ptr_ty.childType(cg.zcu), | ||
| 7015 | struct_ptr_ty.childType(cg.zcu), | ||
| 7016 | struct_ptr, | ||
| 7017 | field_index, | ||
| 7018 | ); | ||
| 6983 | } | 7019 | } |
| 6984 | 7020 | ||
| 6985 | fn alloc(cg: *CodeGen, ty_id: Id, initializer: ?Id) !Id { | 7021 | fn alloc(cg: *CodeGen, ty_id: Id, initializer: ?Id) !Id { |
src/codegen/wasm/CodeGen.zig+9-9| ... | @@ -1154,7 +1154,7 @@ fn allocStack(cg: *CodeGen, ty: Type) !WValue { | ... | @@ -1154,7 +1154,7 @@ fn allocStack(cg: *CodeGen, ty: Type) !WValue { |
| 1154 | 1154 | ||
| 1155 | const abi_size = std.math.cast(u32, ty.abiSize(zcu)) orelse { | 1155 | const abi_size = std.math.cast(u32, ty.abiSize(zcu)) orelse { |
| 1156 | return cg.fail("Type {f} with ABI size of {d} exceeds stack frame size", .{ | 1156 | return cg.fail("Type {f} with ABI size of {d} exceeds stack frame size", .{ |
| 1157 | ty.fmt(pt), ty.abiSize(zcu), | 1157 | ty.fmt(zcu), ty.abiSize(zcu), |
| 1158 | }); | 1158 | }); |
| 1159 | }; | 1159 | }; |
| 1160 | const abi_align = ty.abiAlignment(zcu); | 1160 | const abi_align = ty.abiAlignment(zcu); |
| ... | @@ -1195,7 +1195,7 @@ fn allocStackPtr(cg: *CodeGen, inst: Air.Inst.Index) !WValue { | ... | @@ -1195,7 +1195,7 @@ fn allocStackPtr(cg: *CodeGen, inst: Air.Inst.Index) !WValue { |
| 1195 | const abi_alignment = ptr_ty.ptrAlignment(zcu); | 1195 | const abi_alignment = ptr_ty.ptrAlignment(zcu); |
| 1196 | const abi_size = std.math.cast(u32, pointee_ty.abiSize(zcu)) orelse { | 1196 | const abi_size = std.math.cast(u32, pointee_ty.abiSize(zcu)) orelse { |
| 1197 | return cg.fail("Type {f} with ABI size of {d} exceeds stack frame size", .{ | 1197 | return cg.fail("Type {f} with ABI size of {d} exceeds stack frame size", .{ |
| 1198 | pointee_ty.fmt(pt), pointee_ty.abiSize(zcu), | 1198 | pointee_ty.fmt(zcu), pointee_ty.abiSize(zcu), |
| 1199 | }); | 1199 | }); |
| 1200 | }; | 1200 | }; |
| 1201 | cg.stack_alignment = cg.stack_alignment.max(abi_alignment); | 1201 | cg.stack_alignment = cg.stack_alignment.max(abi_alignment); |
| ... | @@ -2108,7 +2108,7 @@ fn airCall(cg: *CodeGen, inst: Air.Inst.Index, modifier: std.lang.CallModifier) | ... | @@ -2108,7 +2108,7 @@ fn airCall(cg: *CodeGen, inst: Air.Inst.Index, modifier: std.lang.CallModifier) |
| 2108 | if (!arg_ty.hasRuntimeBits(zcu)) continue; | 2108 | if (!arg_ty.hasRuntimeBits(zcu)) continue; |
| 2109 | 2109 | ||
| 2110 | const arg_size = std.math.cast(u32, arg_ty.abiSize(zcu)) orelse { | 2110 | const arg_size = std.math.cast(u32, arg_ty.abiSize(zcu)) orelse { |
| 2111 | return cg.fail("argument type {f} too large for wasm varargs buffer", .{arg_ty.fmt(pt)}); | 2111 | return cg.fail("argument type {f} too large for wasm varargs buffer", .{arg_ty.fmt(zcu)}); |
| 2112 | }; | 2112 | }; |
| 2113 | const arg_align = arg_ty.abiAlignment(zcu); | 2113 | const arg_align = arg_ty.abiAlignment(zcu); |
| 2114 | 2114 | ||
| ... | @@ -2128,7 +2128,7 @@ fn airCall(cg: *CodeGen, inst: Air.Inst.Index, modifier: std.lang.CallModifier) | ... | @@ -2128,7 +2128,7 @@ fn airCall(cg: *CodeGen, inst: Air.Inst.Index, modifier: std.lang.CallModifier) |
| 2128 | 2128 | ||
| 2129 | const arg_val = try cg.resolveInst(arg); | 2129 | const arg_val = try cg.resolveInst(arg); |
| 2130 | const arg_size = std.math.cast(u32, arg_ty.abiSize(zcu)) orelse { | 2130 | const arg_size = std.math.cast(u32, arg_ty.abiSize(zcu)) orelse { |
| 2131 | return cg.fail("argument type {f} too large for wasm varargs buffer", .{arg_ty.fmt(pt)}); | 2131 | return cg.fail("argument type {f} too large for wasm varargs buffer", .{arg_ty.fmt(zcu)}); |
| 2132 | }; | 2132 | }; |
| 2133 | const arg_align = arg_ty.abiAlignment(zcu); | 2133 | const arg_align = arg_ty.abiAlignment(zcu); |
| 2134 | 2134 | ||
| ... | @@ -5189,7 +5189,7 @@ fn lowerConstant(cg: *CodeGen, val: Value) InnerError!WValue { | ... | @@ -5189,7 +5189,7 @@ fn lowerConstant(cg: *CodeGen, val: Value) InnerError!WValue { |
| 5189 | return .{ .imm32 = @intFromBool(!val.isNull(zcu)) }; | 5189 | return .{ .imm32 = @intFromBool(!val.isNull(zcu)) }; |
| 5190 | }, | 5190 | }, |
| 5191 | .aggregate => switch (ip.indexToKey(ty.ip_index)) { | 5191 | .aggregate => switch (ip.indexToKey(ty.ip_index)) { |
| 5192 | .array_type => return cg.fail("Wasm TODO: LowerConstant for {f}", .{ty.fmt(pt)}), | 5192 | .array_type => return cg.fail("Wasm TODO: LowerConstant for {f}", .{ty.fmt(zcu)}), |
| 5193 | .vector_type => { | 5193 | .vector_type => { |
| 5194 | assert(determineSimdStoreStrategy(ty, zcu, cg.target) == .direct); | 5194 | assert(determineSimdStoreStrategy(ty, zcu, cg.target) == .direct); |
| 5195 | var buf: [16]u8 = undefined; | 5195 | var buf: [16]u8 = undefined; |
| ... | @@ -5883,7 +5883,7 @@ fn airAggFieldVal(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { | ... | @@ -5883,7 +5883,7 @@ fn airAggFieldVal(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 5883 | .@"packed" => unreachable, // legalize .expand_packed_agg_field_val | 5883 | .@"packed" => unreachable, // legalize .expand_packed_agg_field_val |
| 5884 | else => result: { | 5884 | else => result: { |
| 5885 | const offset = std.math.cast(u32, struct_ty.structFieldOffset(field_index, zcu)) orelse { | 5885 | const offset = std.math.cast(u32, struct_ty.structFieldOffset(field_index, zcu)) orelse { |
| 5886 | return cg.fail("Field type '{f}' too big to fit into stack frame", .{field_ty.fmt(pt)}); | 5886 | return cg.fail("Field type '{f}' too big to fit into stack frame", .{field_ty.fmt(zcu)}); |
| 5887 | }; | 5887 | }; |
| 5888 | if (isByRef(field_ty, zcu, cg.target)) { | 5888 | if (isByRef(field_ty, zcu, cg.target)) { |
| 5889 | break :result try cg.offsetPointer(operand, offset); | 5889 | break :result try cg.offsetPointer(operand, offset); |
| ... | @@ -6296,7 +6296,7 @@ fn isNull(cg: *CodeGen, operand: WValue, op_ty: Type, opcode: std.wasm.Opcode, o | ... | @@ -6296,7 +6296,7 @@ fn isNull(cg: *CodeGen, operand: WValue, op_ty: Type, opcode: std.wasm.Opcode, o |
| 6296 | // a pointer to the stack value | 6296 | // a pointer to the stack value |
| 6297 | if (payload_ty.hasRuntimeBits(zcu)) { | 6297 | if (payload_ty.hasRuntimeBits(zcu)) { |
| 6298 | const offset = std.math.cast(u32, payload_ty.abiSize(zcu)) orelse { | 6298 | const offset = std.math.cast(u32, payload_ty.abiSize(zcu)) orelse { |
| 6299 | return cg.fail("Optional type {f} too big to fit into stack frame", .{optional_ty.fmt(pt)}); | 6299 | return cg.fail("Optional type {f} too big to fit into stack frame", .{optional_ty.fmt(zcu)}); |
| 6300 | }; | 6300 | }; |
| 6301 | try cg.emitMemBase(operand); | 6301 | try cg.emitMemBase(operand); |
| 6302 | try cg.addMemArg(.i32_load8_u, .{ .offset = operand.memOffset() + offset, .alignment = .@"1" }); | 6302 | try cg.addMemArg(.i32_load8_u, .{ .offset = operand.memOffset() + offset, .alignment = .@"1" }); |
| ... | @@ -6381,7 +6381,7 @@ fn airOptionalPayloadPtrSet(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void | ... | @@ -6381,7 +6381,7 @@ fn airOptionalPayloadPtrSet(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void |
| 6381 | } | 6381 | } |
| 6382 | 6382 | ||
| 6383 | const offset = std.math.cast(u32, payload_ty.abiSize(zcu)) orelse { | 6383 | const offset = std.math.cast(u32, payload_ty.abiSize(zcu)) orelse { |
| 6384 | return cg.fail("Optional type {f} too big to fit into stack frame", .{opt_ty.fmt(pt)}); | 6384 | return cg.fail("Optional type {f} too big to fit into stack frame", .{opt_ty.fmt(zcu)}); |
| 6385 | }; | 6385 | }; |
| 6386 | 6386 | ||
| 6387 | try cg.emitMemBase(operand); | 6387 | try cg.emitMemBase(operand); |
| ... | @@ -6412,7 +6412,7 @@ fn airWrapOptional(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { | ... | @@ -6412,7 +6412,7 @@ fn airWrapOptional(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 6412 | break :result operand; | 6412 | break :result operand; |
| 6413 | } | 6413 | } |
| 6414 | const offset = std.math.cast(u32, payload_ty.abiSize(zcu)) orelse { | 6414 | const offset = std.math.cast(u32, payload_ty.abiSize(zcu)) orelse { |
| 6415 | return cg.fail("Optional type {f} too big to fit into stack frame", .{op_ty.fmt(pt)}); | 6415 | return cg.fail("Optional type {f} too big to fit into stack frame", .{op_ty.fmt(zcu)}); |
| 6416 | }; | 6416 | }; |
| 6417 | 6417 | ||
| 6418 | // Create optional type, set the non-null bit, and store the operand inside the optional type | 6418 | // Create optional type, set the non-null bit, and store the operand inside the optional type |
src/codegen/x86_64/CodeGen.zig+133-128| ... | @@ -1174,7 +1174,7 @@ const FormatAirData = struct { | ... | @@ -1174,7 +1174,7 @@ const FormatAirData = struct { |
| 1174 | inst: Air.Inst.Index, | 1174 | inst: Air.Inst.Index, |
| 1175 | }; | 1175 | }; |
| 1176 | fn formatAir(data: FormatAirData, w: *Writer) Writer.Error!void { | 1176 | fn formatAir(data: FormatAirData, w: *Writer) Writer.Error!void { |
| 1177 | data.self.air.writeInst(w, data.inst, data.self.pt, data.self.liveness); | 1177 | data.self.air.writeInst(w, data.inst, data.self.pt.zcu, data.self.liveness); |
| 1178 | } | 1178 | } |
| 1179 | fn fmtAir(self: *CodeGen, inst: Air.Inst.Index) std.fmt.Alt(FormatAirData, formatAir) { | 1179 | fn fmtAir(self: *CodeGen, inst: Air.Inst.Index) std.fmt.Alt(FormatAirData, formatAir) { |
| 1180 | return .{ .data = .{ .self = self, .inst = inst } }; | 1180 | return .{ .data = .{ .self = self, .inst = inst } }; |
| ... | @@ -1185,14 +1185,15 @@ const FormatWipMirData = struct { | ... | @@ -1185,14 +1185,15 @@ const FormatWipMirData = struct { |
| 1185 | inst: Mir.Inst.Index, | 1185 | inst: Mir.Inst.Index, |
| 1186 | }; | 1186 | }; |
| 1187 | fn formatWipMir(data: FormatWipMirData, w: *Writer) Writer.Error!void { | 1187 | fn formatWipMir(data: FormatWipMirData, w: *Writer) Writer.Error!void { |
| 1188 | const zcu = data.self.pt.zcu; | ||
| 1188 | var lower: Lower = .{ | 1189 | var lower: Lower = .{ |
| 1189 | .target = data.self.target, | 1190 | .target = data.self.target, |
| 1190 | .allocator = data.self.gpa, | 1191 | .allocator = data.self.gpa, |
| 1191 | .mir = data.self.getTmpMir(), | 1192 | .mir = data.self.getTmpMir(), |
| 1192 | .cc = .auto, | 1193 | .cc = .auto, |
| 1193 | .src_loc = switch (data.self.owner) { | 1194 | .src_loc = switch (data.self.owner) { |
| 1194 | .nav_index => |nav| data.self.pt.zcu.navSrcLoc(nav), | 1195 | .nav_index => |nav| zcu.navSrcLoc(nav), |
| 1195 | .lazy_sym => |lazy_sym| Type.fromInterned(lazy_sym.ty).srcLocOrNull(data.self.pt.zcu) orelse .unneeded, | 1196 | .lazy_sym => |lazy_sym| Type.fromInterned(lazy_sym.ty).srcLocOrNull(zcu) orelse .unneeded, |
| 1196 | }, | 1197 | }, |
| 1197 | }; | 1198 | }; |
| 1198 | var first = true; | 1199 | var first = true; |
| ... | @@ -1215,7 +1216,7 @@ fn formatWipMir(data: FormatWipMirData, w: *Writer) Writer.Error!void { | ... | @@ -1215,7 +1216,7 @@ fn formatWipMir(data: FormatWipMirData, w: *Writer) Writer.Error!void { |
| 1215 | first = false; | 1216 | first = false; |
| 1216 | } | 1217 | } |
| 1217 | if (first) { | 1218 | if (first) { |
| 1218 | const ip = &data.self.pt.zcu.intern_pool; | 1219 | const ip = &zcu.intern_pool; |
| 1219 | const mir_inst = lower.mir.instructions.get(data.inst); | 1220 | const mir_inst = lower.mir.instructions.get(data.inst); |
| 1220 | try w.print(" | .{s}", .{@tagName(mir_inst.ops)}); | 1221 | try w.print(" | .{s}", .{@tagName(mir_inst.ops)}); |
| 1221 | switch (mir_inst.ops) { | 1222 | switch (mir_inst.ops) { |
| ... | @@ -1264,7 +1265,7 @@ fn formatWipMir(data: FormatWipMirData, w: *Writer) Writer.Error!void { | ... | @@ -1264,7 +1265,7 @@ fn formatWipMir(data: FormatWipMirData, w: *Writer) Writer.Error!void { |
| 1264 | try w.print(" {f}", .{mem_op.fmt(.m)}); | 1265 | try w.print(" {f}", .{mem_op.fmt(.m)}); |
| 1265 | }, | 1266 | }, |
| 1266 | .pseudo_dbg_arg_val, .pseudo_dbg_var_val => try w.print(" {f}", .{ | 1267 | .pseudo_dbg_arg_val, .pseudo_dbg_var_val => try w.print(" {f}", .{ |
| 1267 | Value.fromInterned(mir_inst.data.ip_index).fmtValue(data.self.pt), | 1268 | Value.fromInterned(mir_inst.data.ip_index).fmtValue(zcu), |
| 1268 | }), | 1269 | }), |
| 1269 | } | 1270 | } |
| 1270 | } | 1271 | } |
| ... | @@ -4532,7 +4533,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -4532,7 +4533,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 4532 | } }) catch |err| switch (err) { | 4533 | } }) catch |err| switch (err) { |
| 4533 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | 4534 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ |
| 4534 | @tagName(air_tag), | 4535 | @tagName(air_tag), |
| 4535 | cg.typeOf(bin_op.lhs).fmt(pt), | 4536 | cg.typeOf(bin_op.lhs).fmt(zcu), |
| 4536 | ops[0].tracking(cg), | 4537 | ops[0].tracking(cg), |
| 4537 | ops[1].tracking(cg), | 4538 | ops[1].tracking(cg), |
| 4538 | }), | 4539 | }), |
| ... | @@ -4544,7 +4545,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -4544,7 +4545,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 4544 | .add_wrap => res[0].wrapInt(cg) catch |err| switch (err) { | 4545 | .add_wrap => res[0].wrapInt(cg) catch |err| switch (err) { |
| 4545 | error.SelectFailed => return cg.fail("failed to select {s} wrap {f} {f}", .{ | 4546 | error.SelectFailed => return cg.fail("failed to select {s} wrap {f} {f}", .{ |
| 4546 | @tagName(air_tag), | 4547 | @tagName(air_tag), |
| 4547 | cg.typeOf(bin_op.lhs).fmt(pt), | 4548 | cg.typeOf(bin_op.lhs).fmt(zcu), |
| 4548 | res[0].tracking(cg), | 4549 | res[0].tracking(cg), |
| 4549 | }), | 4550 | }), |
| 4550 | else => |e| return e, | 4551 | else => |e| return e, |
| ... | @@ -13109,7 +13110,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -13109,7 +13110,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 13109 | } }) catch |err| switch (err) { | 13110 | } }) catch |err| switch (err) { |
| 13110 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | 13111 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ |
| 13111 | @tagName(air_tag), | 13112 | @tagName(air_tag), |
| 13112 | cg.typeOf(bin_op.lhs).fmt(pt), | 13113 | cg.typeOf(bin_op.lhs).fmt(zcu), |
| 13113 | ops[0].tracking(cg), | 13114 | ops[0].tracking(cg), |
| 13114 | ops[1].tracking(cg), | 13115 | ops[1].tracking(cg), |
| 13115 | }), | 13116 | }), |
| ... | @@ -15283,7 +15284,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -15283,7 +15284,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 15283 | } }) catch |err| switch (err) { | 15284 | } }) catch |err| switch (err) { |
| 15284 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | 15285 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ |
| 15285 | @tagName(air_tag), | 15286 | @tagName(air_tag), |
| 15286 | cg.typeOf(bin_op.lhs).fmt(pt), | 15287 | cg.typeOf(bin_op.lhs).fmt(zcu), |
| 15287 | ops[0].tracking(cg), | 15288 | ops[0].tracking(cg), |
| 15288 | ops[1].tracking(cg), | 15289 | ops[1].tracking(cg), |
| 15289 | }), | 15290 | }), |
| ... | @@ -15295,7 +15296,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -15295,7 +15296,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 15295 | .sub_wrap => res[0].wrapInt(cg) catch |err| switch (err) { | 15296 | .sub_wrap => res[0].wrapInt(cg) catch |err| switch (err) { |
| 15296 | error.SelectFailed => return cg.fail("failed to select {s} wrap {f} {f}", .{ | 15297 | error.SelectFailed => return cg.fail("failed to select {s} wrap {f} {f}", .{ |
| 15297 | @tagName(air_tag), | 15298 | @tagName(air_tag), |
| 15298 | cg.typeOf(bin_op.lhs).fmt(pt), | 15299 | cg.typeOf(bin_op.lhs).fmt(zcu), |
| 15299 | res[0].tracking(cg), | 15300 | res[0].tracking(cg), |
| 15300 | }), | 15301 | }), |
| 15301 | else => |e| return e, | 15302 | else => |e| return e, |
| ... | @@ -22130,7 +22131,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -22130,7 +22131,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 22130 | } }) catch |err| switch (err) { | 22131 | } }) catch |err| switch (err) { |
| 22131 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | 22132 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ |
| 22132 | @tagName(air_tag), | 22133 | @tagName(air_tag), |
| 22133 | cg.typeOf(bin_op.lhs).fmt(pt), | 22134 | cg.typeOf(bin_op.lhs).fmt(zcu), |
| 22134 | ops[0].tracking(cg), | 22135 | ops[0].tracking(cg), |
| 22135 | ops[1].tracking(cg), | 22136 | ops[1].tracking(cg), |
| 22136 | }), | 22137 | }), |
| ... | @@ -25067,7 +25068,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -25067,7 +25068,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 25067 | } }) catch |err| switch (err) { | 25068 | } }) catch |err| switch (err) { |
| 25068 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | 25069 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ |
| 25069 | @tagName(air_tag), | 25070 | @tagName(air_tag), |
| 25070 | ty.fmt(pt), | 25071 | ty.fmt(zcu), |
| 25071 | ops[0].tracking(cg), | 25072 | ops[0].tracking(cg), |
| 25072 | ops[1].tracking(cg), | 25073 | ops[1].tracking(cg), |
| 25073 | }), | 25074 | }), |
| ... | @@ -26865,7 +26866,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -26865,7 +26866,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 26865 | } }) catch |err| switch (err) { | 26866 | } }) catch |err| switch (err) { |
| 26866 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | 26867 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ |
| 26867 | @tagName(air_tag), | 26868 | @tagName(air_tag), |
| 26868 | ty.fmt(pt), | 26869 | ty.fmt(zcu), |
| 26869 | ops[0].tracking(cg), | 26870 | ops[0].tracking(cg), |
| 26870 | ops[1].tracking(cg), | 26871 | ops[1].tracking(cg), |
| 26871 | }), | 26872 | }), |
| ... | @@ -26874,7 +26875,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -26874,7 +26875,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 26874 | res[0].wrapInt(cg) catch |err| switch (err) { | 26875 | res[0].wrapInt(cg) catch |err| switch (err) { |
| 26875 | error.SelectFailed => return cg.fail("failed to select {s} wrap {f} {f}", .{ | 26876 | error.SelectFailed => return cg.fail("failed to select {s} wrap {f} {f}", .{ |
| 26876 | @tagName(air_tag), | 26877 | @tagName(air_tag), |
| 26877 | cg.typeOf(bin_op.lhs).fmt(pt), | 26878 | cg.typeOf(bin_op.lhs).fmt(zcu), |
| 26878 | res[0].tracking(cg), | 26879 | res[0].tracking(cg), |
| 26879 | }), | 26880 | }), |
| 26880 | else => |e| return e, | 26881 | else => |e| return e, |
| ... | @@ -32090,7 +32091,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -32090,7 +32091,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 32090 | } }) catch |err| switch (err) { | 32091 | } }) catch |err| switch (err) { |
| 32091 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | 32092 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ |
| 32092 | @tagName(air_tag), | 32093 | @tagName(air_tag), |
| 32093 | cg.typeOf(bin_op.lhs).fmt(pt), | 32094 | cg.typeOf(bin_op.lhs).fmt(zcu), |
| 32094 | ops[0].tracking(cg), | 32095 | ops[0].tracking(cg), |
| 32095 | ops[1].tracking(cg), | 32096 | ops[1].tracking(cg), |
| 32096 | }), | 32097 | }), |
| ... | @@ -33328,7 +33329,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -33328,7 +33329,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 33328 | }) catch |err| switch (err) { | 33329 | }) catch |err| switch (err) { |
| 33329 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | 33330 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ |
| 33330 | @tagName(air_tag), | 33331 | @tagName(air_tag), |
| 33331 | ty.fmt(pt), | 33332 | ty.fmt(zcu), |
| 33332 | ops[0].tracking(cg), | 33333 | ops[0].tracking(cg), |
| 33333 | ops[1].tracking(cg), | 33334 | ops[1].tracking(cg), |
| 33334 | }), | 33335 | }), |
| ... | @@ -34785,7 +34786,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -34785,7 +34786,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 34785 | }) catch |err| switch (err) { | 34786 | }) catch |err| switch (err) { |
| 34786 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | 34787 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ |
| 34787 | @tagName(air_tag), | 34788 | @tagName(air_tag), |
| 34788 | ty.fmt(pt), | 34789 | ty.fmt(zcu), |
| 34789 | ops[0].tracking(cg), | 34790 | ops[0].tracking(cg), |
| 34790 | ops[1].tracking(cg), | 34791 | ops[1].tracking(cg), |
| 34791 | }), | 34792 | }), |
| ... | @@ -36346,7 +36347,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -36346,7 +36347,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 36346 | }) catch |err| switch (err) { | 36347 | }) catch |err| switch (err) { |
| 36347 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | 36348 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ |
| 36348 | @tagName(air_tag), | 36349 | @tagName(air_tag), |
| 36349 | cg.typeOf(bin_op.lhs).fmt(pt), | 36350 | cg.typeOf(bin_op.lhs).fmt(zcu), |
| 36350 | ops[0].tracking(cg), | 36351 | ops[0].tracking(cg), |
| 36351 | ops[1].tracking(cg), | 36352 | ops[1].tracking(cg), |
| 36352 | }), | 36353 | }), |
| ... | @@ -38038,7 +38039,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -38038,7 +38039,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 38038 | } })) catch |err| switch (err) { | 38039 | } })) catch |err| switch (err) { |
| 38039 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | 38040 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ |
| 38040 | @tagName(air_tag), | 38041 | @tagName(air_tag), |
| 38041 | ty.fmt(pt), | 38042 | ty.fmt(zcu), |
| 38042 | ops[0].tracking(cg), | 38043 | ops[0].tracking(cg), |
| 38043 | ops[1].tracking(cg), | 38044 | ops[1].tracking(cg), |
| 38044 | }), | 38045 | }), |
| ... | @@ -39820,7 +39821,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -39820,7 +39821,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 39820 | } }) catch |err| switch (err) { | 39821 | } }) catch |err| switch (err) { |
| 39821 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | 39822 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ |
| 39822 | @tagName(air_tag), | 39823 | @tagName(air_tag), |
| 39823 | cg.typeOf(bin_op.lhs).fmt(pt), | 39824 | cg.typeOf(bin_op.lhs).fmt(zcu), |
| 39824 | ops[0].tracking(cg), | 39825 | ops[0].tracking(cg), |
| 39825 | ops[1].tracking(cg), | 39826 | ops[1].tracking(cg), |
| 39826 | }), | 39827 | }), |
| ... | @@ -43333,7 +43334,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -43333,7 +43334,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 43333 | } }) catch |err| switch (err) { | 43334 | } }) catch |err| switch (err) { |
| 43334 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | 43335 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ |
| 43335 | @tagName(air_tag), | 43336 | @tagName(air_tag), |
| 43336 | cg.typeOf(bin_op.lhs).fmt(pt), | 43337 | cg.typeOf(bin_op.lhs).fmt(zcu), |
| 43337 | ops[0].tracking(cg), | 43338 | ops[0].tracking(cg), |
| 43338 | ops[1].tracking(cg), | 43339 | ops[1].tracking(cg), |
| 43339 | }), | 43340 | }), |
| ... | @@ -43447,7 +43448,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -43447,7 +43448,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 43447 | } }) catch |err| switch (err) { | 43448 | } }) catch |err| switch (err) { |
| 43448 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | 43449 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ |
| 43449 | @tagName(air_tag), | 43450 | @tagName(air_tag), |
| 43450 | cg.typeOf(bin_op.lhs).fmt(pt), | 43451 | cg.typeOf(bin_op.lhs).fmt(zcu), |
| 43451 | ops[0].tracking(cg), | 43452 | ops[0].tracking(cg), |
| 43452 | ops[1].tracking(cg), | 43453 | ops[1].tracking(cg), |
| 43453 | }), | 43454 | }), |
| ... | @@ -43576,7 +43577,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -43576,7 +43577,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 43576 | } }) catch |err| switch (err) { | 43577 | } }) catch |err| switch (err) { |
| 43577 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | 43578 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ |
| 43578 | @tagName(air_tag), | 43579 | @tagName(air_tag), |
| 43579 | cg.typeOf(bin_op.lhs).fmt(pt), | 43580 | cg.typeOf(bin_op.lhs).fmt(zcu), |
| 43580 | ops[0].tracking(cg), | 43581 | ops[0].tracking(cg), |
| 43581 | ops[1].tracking(cg), | 43582 | ops[1].tracking(cg), |
| 43582 | }), | 43583 | }), |
| ... | @@ -47885,7 +47886,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -47885,7 +47886,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 47885 | } }) catch |err| switch (err) { | 47886 | } }) catch |err| switch (err) { |
| 47886 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | 47887 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ |
| 47887 | @tagName(air_tag), | 47888 | @tagName(air_tag), |
| 47888 | cg.typeOf(bin_op.lhs).fmt(pt), | 47889 | cg.typeOf(bin_op.lhs).fmt(zcu), |
| 47889 | ops[0].tracking(cg), | 47890 | ops[0].tracking(cg), |
| 47890 | ops[1].tracking(cg), | 47891 | ops[1].tracking(cg), |
| 47891 | }), | 47892 | }), |
| ... | @@ -52188,7 +52189,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -52188,7 +52189,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 52188 | } }) catch |err| switch (err) { | 52189 | } }) catch |err| switch (err) { |
| 52189 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | 52190 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ |
| 52190 | @tagName(air_tag), | 52191 | @tagName(air_tag), |
| 52191 | cg.typeOf(bin_op.lhs).fmt(pt), | 52192 | cg.typeOf(bin_op.lhs).fmt(zcu), |
| 52192 | ops[0].tracking(cg), | 52193 | ops[0].tracking(cg), |
| 52193 | ops[1].tracking(cg), | 52194 | ops[1].tracking(cg), |
| 52194 | }), | 52195 | }), |
| ... | @@ -53037,7 +53038,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -53037,7 +53038,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 53037 | } }) catch |err| switch (err) { | 53038 | } }) catch |err| switch (err) { |
| 53038 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | 53039 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ |
| 53039 | @tagName(air_tag), | 53040 | @tagName(air_tag), |
| 53040 | ty_pl.ty.fmt(pt), | 53041 | ty_pl.ty.fmt(zcu), |
| 53041 | ops[0].tracking(cg), | 53042 | ops[0].tracking(cg), |
| 53042 | ops[1].tracking(cg), | 53043 | ops[1].tracking(cg), |
| 53043 | }), | 53044 | }), |
| ... | @@ -53942,7 +53943,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -53942,7 +53943,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 53942 | } }) catch |err| switch (err) { | 53943 | } }) catch |err| switch (err) { |
| 53943 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | 53944 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ |
| 53944 | @tagName(air_tag), | 53945 | @tagName(air_tag), |
| 53945 | ty_pl.ty.fmt(pt), | 53946 | ty_pl.ty.fmt(zcu), |
| 53946 | ops[0].tracking(cg), | 53947 | ops[0].tracking(cg), |
| 53947 | ops[1].tracking(cg), | 53948 | ops[1].tracking(cg), |
| 53948 | }), | 53949 | }), |
| ... | @@ -57539,7 +57540,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -57539,7 +57540,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 57539 | } }) catch |err| switch (err) { | 57540 | } }) catch |err| switch (err) { |
| 57540 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | 57541 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ |
| 57541 | @tagName(air_tag), | 57542 | @tagName(air_tag), |
| 57542 | ty_pl.ty.fmt(pt), | 57543 | ty_pl.ty.fmt(zcu), |
| 57543 | ops[0].tracking(cg), | 57544 | ops[0].tracking(cg), |
| 57544 | ops[1].tracking(cg), | 57545 | ops[1].tracking(cg), |
| 57545 | }), | 57546 | }), |
| ... | @@ -60884,7 +60885,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -60884,7 +60885,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 60884 | } }) catch |err| switch (err) { | 60885 | } }) catch |err| switch (err) { |
| 60885 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | 60886 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ |
| 60886 | @tagName(air_tag), | 60887 | @tagName(air_tag), |
| 60887 | ty_pl.ty.fmt(pt), | 60888 | ty_pl.ty.fmt(zcu), |
| 60888 | ops[0].tracking(cg), | 60889 | ops[0].tracking(cg), |
| 60889 | ops[1].tracking(cg), | 60890 | ops[1].tracking(cg), |
| 60890 | }), | 60891 | }), |
| ... | @@ -61279,7 +61280,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -61279,7 +61280,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 61279 | }) catch |err| switch (err) { | 61280 | }) catch |err| switch (err) { |
| 61280 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | 61281 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ |
| 61281 | @tagName(air_tag), | 61282 | @tagName(air_tag), |
| 61282 | cg.typeOf(bin_op.lhs).fmt(pt), | 61283 | cg.typeOf(bin_op.lhs).fmt(zcu), |
| 61283 | ops[0].tracking(cg), | 61284 | ops[0].tracking(cg), |
| 61284 | ops[1].tracking(cg), | 61285 | ops[1].tracking(cg), |
| 61285 | }), | 61286 | }), |
| ... | @@ -61842,8 +61843,8 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -61842,8 +61843,8 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 61842 | } }) catch |err| switch (err) { | 61843 | } }) catch |err| switch (err) { |
| 61843 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f} {f}", .{ | 61844 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f} {f}", .{ |
| 61844 | @tagName(air_tag), | 61845 | @tagName(air_tag), |
| 61845 | cg.typeOf(bin_op.lhs).fmt(pt), | 61846 | cg.typeOf(bin_op.lhs).fmt(zcu), |
| 61846 | cg.typeOf(bin_op.rhs).fmt(pt), | 61847 | cg.typeOf(bin_op.rhs).fmt(zcu), |
| 61847 | ops[0].tracking(cg), | 61848 | ops[0].tracking(cg), |
| 61848 | ops[1].tracking(cg), | 61849 | ops[1].tracking(cg), |
| 61849 | }), | 61850 | }), |
| ... | @@ -62204,8 +62205,8 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -62204,8 +62205,8 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 62204 | } }) catch |err| switch (err) { | 62205 | } }) catch |err| switch (err) { |
| 62205 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f} {f}", .{ | 62206 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f} {f}", .{ |
| 62206 | @tagName(air_tag), | 62207 | @tagName(air_tag), |
| 62207 | cg.typeOf(bin_op.lhs).fmt(pt), | 62208 | cg.typeOf(bin_op.lhs).fmt(zcu), |
| 62208 | cg.typeOf(bin_op.rhs).fmt(pt), | 62209 | cg.typeOf(bin_op.rhs).fmt(zcu), |
| 62209 | ops[0].tracking(cg), | 62210 | ops[0].tracking(cg), |
| 62210 | ops[1].tracking(cg), | 62211 | ops[1].tracking(cg), |
| 62211 | }), | 62212 | }), |
| ... | @@ -62216,7 +62217,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -62216,7 +62217,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 62216 | .shl => res[0].wrapInt(cg) catch |err| switch (err) { | 62217 | .shl => res[0].wrapInt(cg) catch |err| switch (err) { |
| 62217 | error.SelectFailed => return cg.fail("failed to select {s} wrap {f} {f}", .{ | 62218 | error.SelectFailed => return cg.fail("failed to select {s} wrap {f} {f}", .{ |
| 62218 | @tagName(air_tag), | 62219 | @tagName(air_tag), |
| 62219 | cg.typeOf(bin_op.lhs).fmt(pt), | 62220 | cg.typeOf(bin_op.lhs).fmt(zcu), |
| 62220 | res[0].tracking(cg), | 62221 | res[0].tracking(cg), |
| 62221 | }), | 62222 | }), |
| 62222 | else => |e| return e, | 62223 | else => |e| return e, |
| ... | @@ -62383,7 +62384,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -62383,7 +62384,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 62383 | } }) catch |err| switch (err) { | 62384 | } }) catch |err| switch (err) { |
| 62384 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ | 62385 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ |
| 62385 | @tagName(air_tag), | 62386 | @tagName(air_tag), |
| 62386 | cg.typeOf(bin_op.rhs).fmt(pt), | 62387 | cg.typeOf(bin_op.rhs).fmt(zcu), |
| 62387 | ops[1].tracking(cg), | 62388 | ops[1].tracking(cg), |
| 62388 | }), | 62389 | }), |
| 62389 | else => |e| return e, | 62390 | else => |e| return e, |
| ... | @@ -65640,7 +65641,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -65640,7 +65641,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 65640 | } }) catch |err| switch (err) { | 65641 | } }) catch |err| switch (err) { |
| 65641 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | 65642 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ |
| 65642 | @tagName(air_tag), | 65643 | @tagName(air_tag), |
| 65643 | lhs_ty.fmt(pt), | 65644 | lhs_ty.fmt(zcu), |
| 65644 | ops[0].tracking(cg), | 65645 | ops[0].tracking(cg), |
| 65645 | ops[1].tracking(cg), | 65646 | ops[1].tracking(cg), |
| 65646 | }), | 65647 | }), |
| ... | @@ -67425,7 +67426,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -67425,7 +67426,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 67425 | } }) catch |err| switch (err) { | 67426 | } }) catch |err| switch (err) { |
| 67426 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ | 67427 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ |
| 67427 | @tagName(air_tag), | 67428 | @tagName(air_tag), |
| 67428 | ty_op.ty.fmt(pt), | 67429 | ty_op.ty.fmt(zcu), |
| 67429 | ops[0].tracking(cg), | 67430 | ops[0].tracking(cg), |
| 67430 | }), | 67431 | }), |
| 67431 | else => |e| return e, | 67432 | else => |e| return e, |
| ... | @@ -70586,7 +70587,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -70586,7 +70587,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 70586 | } }) catch |err| switch (err) { | 70587 | } }) catch |err| switch (err) { |
| 70587 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ | 70588 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ |
| 70588 | @tagName(air_tag), | 70589 | @tagName(air_tag), |
| 70589 | cg.typeOf(ty_op.operand).fmt(pt), | 70590 | cg.typeOf(ty_op.operand).fmt(zcu), |
| 70590 | ops[0].tracking(cg), | 70591 | ops[0].tracking(cg), |
| 70591 | }), | 70592 | }), |
| 70592 | else => |e| return e, | 70593 | else => |e| return e, |
| ... | @@ -70983,7 +70984,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -70983,7 +70984,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 70983 | } }) catch |err| switch (err) { | 70984 | } }) catch |err| switch (err) { |
| 70984 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ | 70985 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ |
| 70985 | @tagName(air_tag), | 70986 | @tagName(air_tag), |
| 70986 | cg.typeOf(ty_op.operand).fmt(pt), | 70987 | cg.typeOf(ty_op.operand).fmt(zcu), |
| 70987 | ops[0].tracking(cg), | 70988 | ops[0].tracking(cg), |
| 70988 | }), | 70989 | }), |
| 70989 | else => |e| return e, | 70990 | else => |e| return e, |
| ... | @@ -71871,7 +71872,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -71871,7 +71872,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 71871 | } }) catch |err| switch (err) { | 71872 | } }) catch |err| switch (err) { |
| 71872 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ | 71873 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ |
| 71873 | @tagName(air_tag), | 71874 | @tagName(air_tag), |
| 71874 | cg.typeOf(ty_op.operand).fmt(pt), | 71875 | cg.typeOf(ty_op.operand).fmt(zcu), |
| 71875 | ops[0].tracking(cg), | 71876 | ops[0].tracking(cg), |
| 71876 | }), | 71877 | }), |
| 71877 | else => |e| return e, | 71878 | else => |e| return e, |
| ... | @@ -72520,7 +72521,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -72520,7 +72521,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 72520 | } }) catch |err| switch (err) { | 72521 | } }) catch |err| switch (err) { |
| 72521 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ | 72522 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ |
| 72522 | @tagName(air_tag), | 72523 | @tagName(air_tag), |
| 72523 | ty_op.ty.fmt(pt), | 72524 | ty_op.ty.fmt(zcu), |
| 72524 | ops[0].tracking(cg), | 72525 | ops[0].tracking(cg), |
| 72525 | }), | 72526 | }), |
| 72526 | else => |e| return e, | 72527 | else => |e| return e, |
| ... | @@ -75622,7 +75623,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -75622,7 +75623,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 75622 | } }) catch |err| switch (err) { | 75623 | } }) catch |err| switch (err) { |
| 75623 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ | 75624 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ |
| 75624 | @tagName(air_tag), | 75625 | @tagName(air_tag), |
| 75625 | ty_op.ty.fmt(pt), | 75626 | ty_op.ty.fmt(zcu), |
| 75626 | ops[0].tracking(cg), | 75627 | ops[0].tracking(cg), |
| 75627 | }), | 75628 | }), |
| 75628 | else => |e| return e, | 75629 | else => |e| return e, |
| ... | @@ -76684,7 +76685,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -76684,7 +76685,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 76684 | } }) catch |err| switch (err) { | 76685 | } }) catch |err| switch (err) { |
| 76685 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ | 76686 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ |
| 76686 | @tagName(air_tag), | 76687 | @tagName(air_tag), |
| 76687 | cg.typeOf(un_op).fmt(pt), | 76688 | cg.typeOf(un_op).fmt(zcu), |
| 76688 | ops[0].tracking(cg), | 76689 | ops[0].tracking(cg), |
| 76689 | }), | 76690 | }), |
| 76690 | else => |e| return e, | 76691 | else => |e| return e, |
| ... | @@ -77534,7 +77535,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -77534,7 +77535,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 77534 | }) catch |err| switch (err) { | 77535 | }) catch |err| switch (err) { |
| 77535 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ | 77536 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ |
| 77536 | @tagName(air_tag), | 77537 | @tagName(air_tag), |
| 77537 | cg.typeOf(un_op).fmt(pt), | 77538 | cg.typeOf(un_op).fmt(zcu), |
| 77538 | ops[0].tracking(cg), | 77539 | ops[0].tracking(cg), |
| 77539 | }), | 77540 | }), |
| 77540 | else => |e| return e, | 77541 | else => |e| return e, |
| ... | @@ -79085,7 +79086,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -79085,7 +79086,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 79085 | } }) catch |err| switch (err) { | 79086 | } }) catch |err| switch (err) { |
| 79086 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ | 79087 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ |
| 79087 | @tagName(air_tag), | 79088 | @tagName(air_tag), |
| 79088 | cg.typeOf(ty_op.operand).fmt(pt), | 79089 | cg.typeOf(ty_op.operand).fmt(zcu), |
| 79089 | ops[0].tracking(cg), | 79090 | ops[0].tracking(cg), |
| 79090 | }), | 79091 | }), |
| 79091 | else => |e| return e, | 79092 | else => |e| return e, |
| ... | @@ -80421,7 +80422,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -80421,7 +80422,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 80421 | }) catch |err| switch (err) { | 80422 | }) catch |err| switch (err) { |
| 80422 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ | 80423 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ |
| 80423 | @tagName(air_tag), | 80424 | @tagName(air_tag), |
| 80424 | cg.typeOf(un_op).fmt(pt), | 80425 | cg.typeOf(un_op).fmt(zcu), |
| 80425 | ops[0].tracking(cg), | 80426 | ops[0].tracking(cg), |
| 80426 | }), | 80427 | }), |
| 80427 | else => |e| return e, | 80428 | else => |e| return e, |
| ... | @@ -80961,7 +80962,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -80961,7 +80962,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 80961 | } }) catch |err| switch (err) { | 80962 | } }) catch |err| switch (err) { |
| 80962 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ | 80963 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ |
| 80963 | @tagName(air_tag), | 80964 | @tagName(air_tag), |
| 80964 | cg.typeOf(un_op).fmt(pt), | 80965 | cg.typeOf(un_op).fmt(zcu), |
| 80965 | ops[0].tracking(cg), | 80966 | ops[0].tracking(cg), |
| 80966 | }), | 80967 | }), |
| 80967 | else => |e| return e, | 80968 | else => |e| return e, |
| ... | @@ -81441,7 +81442,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -81441,7 +81442,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 81441 | }) catch |err| switch (err) { | 81442 | }) catch |err| switch (err) { |
| 81442 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | 81443 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ |
| 81443 | @tagName(air_tag), | 81444 | @tagName(air_tag), |
| 81444 | cg.typeOf(bin_op.lhs).fmt(pt), | 81445 | cg.typeOf(bin_op.lhs).fmt(zcu), |
| 81445 | ops[0].tracking(cg), | 81446 | ops[0].tracking(cg), |
| 81446 | ops[1].tracking(cg), | 81447 | ops[1].tracking(cg), |
| 81447 | }), | 81448 | }), |
| ... | @@ -82016,7 +82017,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -82016,7 +82017,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 82016 | for (&ops) |*op| op.wrapInt(cg) catch |err| switch (err) { | 82017 | for (&ops) |*op| op.wrapInt(cg) catch |err| switch (err) { |
| 82017 | error.SelectFailed => return cg.fail("failed to select {s} wrap {f} {f}", .{ | 82018 | error.SelectFailed => return cg.fail("failed to select {s} wrap {f} {f}", .{ |
| 82018 | @tagName(air_tag), | 82019 | @tagName(air_tag), |
| 82019 | ty.fmt(pt), | 82020 | ty.fmt(zcu), |
| 82020 | op.tracking(cg), | 82021 | op.tracking(cg), |
| 82021 | }), | 82022 | }), |
| 82022 | else => |e| return e, | 82023 | else => |e| return e, |
| ... | @@ -82028,7 +82029,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -82028,7 +82029,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 82028 | }) catch |err| switch (err) { | 82029 | }) catch |err| switch (err) { |
| 82029 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | 82030 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ |
| 82030 | @tagName(air_tag), | 82031 | @tagName(air_tag), |
| 82031 | ty.fmt(pt), | 82032 | ty.fmt(zcu), |
| 82032 | ops[0].tracking(cg), | 82033 | ops[0].tracking(cg), |
| 82033 | ops[1].tracking(cg), | 82034 | ops[1].tracking(cg), |
| 82034 | }), | 82035 | }), |
| ... | @@ -89107,7 +89108,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -89107,7 +89108,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 89107 | error.SelectFailed => return cg.fail("failed to select {s} {s} {f} {f} {f}", .{ | 89108 | error.SelectFailed => return cg.fail("failed to select {s} {s} {f} {f} {f}", .{ |
| 89108 | @tagName(air_tag), | 89109 | @tagName(air_tag), |
| 89109 | @tagName(vector_cmp.compareOperator()), | 89110 | @tagName(vector_cmp.compareOperator()), |
| 89110 | cg.typeOf(vector_cmp.lhs).fmt(pt), | 89111 | cg.typeOf(vector_cmp.lhs).fmt(zcu), |
| 89111 | ops[0].tracking(cg), | 89112 | ops[0].tracking(cg), |
| 89112 | ops[1].tracking(cg), | 89113 | ops[1].tracking(cg), |
| 89113 | }), | 89114 | }), |
| ... | @@ -91699,8 +91700,8 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -91699,8 +91700,8 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 91699 | } }) catch |err| switch (err) { | 91700 | } }) catch |err| switch (err) { |
| 91700 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | 91701 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ |
| 91701 | @tagName(air_tag), | 91702 | @tagName(air_tag), |
| 91702 | ty_op.ty.fmt(pt), | 91703 | ty_op.ty.fmt(zcu), |
| 91703 | cg.typeOf(ty_op.operand).fmt(pt), | 91704 | cg.typeOf(ty_op.operand).fmt(zcu), |
| 91704 | ops[0].tracking(cg), | 91705 | ops[0].tracking(cg), |
| 91705 | }), | 91706 | }), |
| 91706 | else => |e| return e, | 91707 | else => |e| return e, |
| ... | @@ -93374,8 +93375,8 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -93374,8 +93375,8 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 93374 | } }) catch |err| switch (err) { | 93375 | } }) catch |err| switch (err) { |
| 93375 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | 93376 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ |
| 93376 | @tagName(air_tag), | 93377 | @tagName(air_tag), |
| 93377 | ty_op.ty.fmt(pt), | 93378 | ty_op.ty.fmt(zcu), |
| 93378 | cg.typeOf(ty_op.operand).fmt(pt), | 93379 | cg.typeOf(ty_op.operand).fmt(zcu), |
| 93379 | ops[0].tracking(cg), | 93380 | ops[0].tracking(cg), |
| 93380 | }), | 93381 | }), |
| 93381 | else => |e| return e, | 93382 | else => |e| return e, |
| ... | @@ -98132,8 +98133,8 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -98132,8 +98133,8 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 98132 | } }) catch |err| switch (err) { | 98133 | } }) catch |err| switch (err) { |
| 98133 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | 98134 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ |
| 98134 | @tagName(air_tag), | 98135 | @tagName(air_tag), |
| 98135 | dst_ty.fmt(pt), | 98136 | dst_ty.fmt(zcu), |
| 98136 | src_ty.fmt(pt), | 98137 | src_ty.fmt(zcu), |
| 98137 | ops[0].tracking(cg), | 98138 | ops[0].tracking(cg), |
| 98138 | }), | 98139 | }), |
| 98139 | else => |e| return e, | 98140 | else => |e| return e, |
| ... | @@ -103798,8 +103799,8 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -103798,8 +103799,8 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 103798 | } }) catch |err| switch (err) { | 103799 | } }) catch |err| switch (err) { |
| 103799 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | 103800 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ |
| 103800 | @tagName(air_tag), | 103801 | @tagName(air_tag), |
| 103801 | ty_op.ty.fmt(pt), | 103802 | ty_op.ty.fmt(zcu), |
| 103802 | cg.typeOf(ty_op.operand).fmt(pt), | 103803 | cg.typeOf(ty_op.operand).fmt(zcu), |
| 103803 | ops[0].tracking(cg), | 103804 | ops[0].tracking(cg), |
| 103804 | }), | 103805 | }), |
| 103805 | else => |e| return e, | 103806 | else => |e| return e, |
| ... | @@ -115168,8 +115169,8 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -115168,8 +115169,8 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 115168 | } }) catch |err| switch (err) { | 115169 | } }) catch |err| switch (err) { |
| 115169 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | 115170 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ |
| 115170 | @tagName(air_tag), | 115171 | @tagName(air_tag), |
| 115171 | ty_op.ty.fmt(pt), | 115172 | ty_op.ty.fmt(zcu), |
| 115172 | cg.typeOf(ty_op.operand).fmt(pt), | 115173 | cg.typeOf(ty_op.operand).fmt(zcu), |
| 115173 | ops[0].tracking(cg), | 115174 | ops[0].tracking(cg), |
| 115174 | }), | 115175 | }), |
| 115175 | else => |e| return e, | 115176 | else => |e| return e, |
| ... | @@ -127059,8 +127060,8 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -127059,8 +127060,8 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 127059 | } }) catch |err| switch (err) { | 127060 | } }) catch |err| switch (err) { |
| 127060 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | 127061 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ |
| 127061 | @tagName(air_tag), | 127062 | @tagName(air_tag), |
| 127062 | ty_op.ty.fmt(pt), | 127063 | ty_op.ty.fmt(zcu), |
| 127063 | cg.typeOf(ty_op.operand).fmt(pt), | 127064 | cg.typeOf(ty_op.operand).fmt(zcu), |
| 127064 | ops[0].tracking(cg), | 127065 | ops[0].tracking(cg), |
| 127065 | }), | 127066 | }), |
| 127066 | else => |e| return e, | 127067 | else => |e| return e, |
| ... | @@ -161250,7 +161251,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -161250,7 +161251,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 161250 | error.SelectFailed => return cg.fail("failed to select {s}.{s} {f} {f}", .{ | 161251 | error.SelectFailed => return cg.fail("failed to select {s}.{s} {f} {f}", .{ |
| 161251 | @tagName(air_tag), | 161252 | @tagName(air_tag), |
| 161252 | @tagName(reduce.operation), | 161253 | @tagName(reduce.operation), |
| 161253 | cg.typeOf(reduce.operand).fmt(pt), | 161254 | cg.typeOf(reduce.operand).fmt(zcu), |
| 161254 | ops[0].tracking(cg), | 161255 | ops[0].tracking(cg), |
| 161255 | }), | 161256 | }), |
| 161256 | else => |e| return e, | 161257 | else => |e| return e, |
| ... | @@ -161261,7 +161262,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -161261,7 +161262,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 161261 | error.SelectFailed => return cg.fail("failed to select {s}.{s} wrap {f} {f}", .{ | 161262 | error.SelectFailed => return cg.fail("failed to select {s}.{s} wrap {f} {f}", .{ |
| 161262 | @tagName(air_tag), | 161263 | @tagName(air_tag), |
| 161263 | @tagName(reduce.operation), | 161264 | @tagName(reduce.operation), |
| 161264 | res_ty.fmt(pt), | 161265 | res_ty.fmt(zcu), |
| 161265 | res[0].tracking(cg), | 161266 | res[0].tracking(cg), |
| 161266 | }), | 161267 | }), |
| 161267 | else => |e| return e, | 161268 | else => |e| return e, |
| ... | @@ -168964,7 +168965,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -168964,7 +168965,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 168964 | error.SelectFailed => return cg.fail("failed to select {s}.{s} {f} {f}", .{ | 168965 | error.SelectFailed => return cg.fail("failed to select {s}.{s} {f} {f}", .{ |
| 168965 | @tagName(air_tag), | 168966 | @tagName(air_tag), |
| 168966 | @tagName(reduce.operation), | 168967 | @tagName(reduce.operation), |
| 168967 | cg.typeOf(reduce.operand).fmt(pt), | 168968 | cg.typeOf(reduce.operand).fmt(zcu), |
| 168968 | ops[0].tracking(cg), | 168969 | ops[0].tracking(cg), |
| 168969 | }), | 168970 | }), |
| 168970 | else => |e| return e, | 168971 | else => |e| return e, |
| ... | @@ -170804,7 +170805,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -170804,7 +170805,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 170804 | } }) catch |err| switch (err) { | 170805 | } }) catch |err| switch (err) { |
| 170805 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ | 170806 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ |
| 170806 | @tagName(air_tag), | 170807 | @tagName(air_tag), |
| 170807 | ty_op.ty.fmt(pt), | 170808 | ty_op.ty.fmt(zcu), |
| 170808 | ops[0].tracking(cg), | 170809 | ops[0].tracking(cg), |
| 170809 | }), | 170810 | }), |
| 170810 | else => |e| return e, | 170811 | else => |e| return e, |
| ... | @@ -170820,8 +170821,8 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -170820,8 +170821,8 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 170820 | ops[2] = ops[0].getByteLen(cg) catch |err| switch (err) { | 170821 | ops[2] = ops[0].getByteLen(cg) catch |err| switch (err) { |
| 170821 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f} {f}", .{ | 170822 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f} {f}", .{ |
| 170822 | @tagName(air_tag), | 170823 | @tagName(air_tag), |
| 170823 | cg.typeOf(bin_op.lhs).fmt(pt), | 170824 | cg.typeOf(bin_op.lhs).fmt(zcu), |
| 170824 | cg.typeOf(bin_op.rhs).fmt(pt), | 170825 | cg.typeOf(bin_op.rhs).fmt(zcu), |
| 170825 | ops[0].tracking(cg), | 170826 | ops[0].tracking(cg), |
| 170826 | ops[1].tracking(cg), | 170827 | ops[1].tracking(cg), |
| 170827 | }), | 170828 | }), |
| ... | @@ -170861,8 +170862,8 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -170861,8 +170862,8 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 170861 | }) catch |err| switch (err) { | 170862 | }) catch |err| switch (err) { |
| 170862 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f} {f} {f}", .{ | 170863 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f} {f} {f}", .{ |
| 170863 | @tagName(air_tag), | 170864 | @tagName(air_tag), |
| 170864 | cg.typeOf(bin_op.lhs).fmt(pt), | 170865 | cg.typeOf(bin_op.lhs).fmt(zcu), |
| 170865 | cg.typeOf(bin_op.rhs).fmt(pt), | 170866 | cg.typeOf(bin_op.rhs).fmt(zcu), |
| 170866 | ops[0].tracking(cg), | 170867 | ops[0].tracking(cg), |
| 170867 | ops[1].tracking(cg), | 170868 | ops[1].tracking(cg), |
| 170868 | ops[2].tracking(cg), | 170869 | ops[2].tracking(cg), |
| ... | @@ -171042,7 +171043,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -171042,7 +171043,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 171042 | } }) catch |err| switch (err) { | 171043 | } }) catch |err| switch (err) { |
| 171043 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ | 171044 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ |
| 171044 | @tagName(air_tag), | 171045 | @tagName(air_tag), |
| 171045 | cg.typeOf(un_op).fmt(pt), | 171046 | cg.typeOf(un_op).fmt(zcu), |
| 171046 | ops[0].tracking(cg), | 171047 | ops[0].tracking(cg), |
| 171047 | }), | 171048 | }), |
| 171048 | else => |e| return e, | 171049 | else => |e| return e, |
| ... | @@ -171208,7 +171209,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -171208,7 +171209,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 171208 | } }) catch |err| switch (err) { | 171209 | } }) catch |err| switch (err) { |
| 171209 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ | 171210 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ |
| 171210 | @tagName(air_tag), | 171211 | @tagName(air_tag), |
| 171211 | cg.typeOf(un_op).fmt(pt), | 171212 | cg.typeOf(un_op).fmt(zcu), |
| 171212 | ops[0].tracking(cg), | 171213 | ops[0].tracking(cg), |
| 171213 | }), | 171214 | }), |
| 171214 | else => |e| return e, | 171215 | else => |e| return e, |
| ... | @@ -171310,7 +171311,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -171310,7 +171311,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 171310 | } }) catch |err| switch (err) { | 171311 | } }) catch |err| switch (err) { |
| 171311 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ | 171312 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ |
| 171312 | @tagName(air_tag), | 171313 | @tagName(air_tag), |
| 171313 | cg.typeOf(un_op).fmt(pt), | 171314 | cg.typeOf(un_op).fmt(zcu), |
| 171314 | ops[0].tracking(cg), | 171315 | ops[0].tracking(cg), |
| 171315 | }), | 171316 | }), |
| 171316 | else => |e| return e, | 171317 | else => |e| return e, |
| ... | @@ -171408,7 +171409,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -171408,7 +171409,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 171408 | } }) catch |err| switch (err) { | 171409 | } }) catch |err| switch (err) { |
| 171409 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ | 171410 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ |
| 171410 | @tagName(air_tag), | 171411 | @tagName(air_tag), |
| 171411 | ty_op.ty.fmt(pt), | 171412 | ty_op.ty.fmt(zcu), |
| 171412 | ops[0].tracking(cg), | 171413 | ops[0].tracking(cg), |
| 171413 | }), | 171414 | }), |
| 171414 | else => |e| return e, | 171415 | else => |e| return e, |
| ... | @@ -171481,7 +171482,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -171481,7 +171482,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 171481 | }, | 171482 | }, |
| 171482 | else => return cg.fail("failed to select {s} {f}", .{ | 171483 | else => return cg.fail("failed to select {s} {f}", .{ |
| 171483 | @tagName(air_tag), | 171484 | @tagName(air_tag), |
| 171484 | agg_ty.fmt(pt), | 171485 | agg_ty.fmt(zcu), |
| 171485 | }), | 171486 | }), |
| 171486 | } | 171487 | } |
| 171487 | try res.finish(inst, &.{}, &.{}, cg); | 171488 | try res.finish(inst, &.{}, &.{}, cg); |
| ... | @@ -172927,7 +172928,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -172927,7 +172928,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 172927 | } }) catch |err| switch (err) { | 172928 | } }) catch |err| switch (err) { |
| 172928 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f} {f}", .{ | 172929 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f} {f}", .{ |
| 172929 | @tagName(air_tag), | 172930 | @tagName(air_tag), |
| 172930 | cg.typeOf(bin_op.lhs).fmt(pt), | 172931 | cg.typeOf(bin_op.lhs).fmt(zcu), |
| 172931 | ops[0].tracking(cg), | 172932 | ops[0].tracking(cg), |
| 172932 | ops[1].tracking(cg), | 172933 | ops[1].tracking(cg), |
| 172933 | ops[2].tracking(cg), | 172934 | ops[2].tracking(cg), |
| ... | @@ -173765,7 +173766,7 @@ fn genLazy(cg: *CodeGen, lazy_sym: link.File.LazySymbol) InnerError!void { | ... | @@ -173765,7 +173766,7 @@ fn genLazy(cg: *CodeGen, lazy_sym: link.File.LazySymbol) InnerError!void { |
| 173765 | switch (ip.indexToKey(lazy_sym.ty)) { | 173766 | switch (ip.indexToKey(lazy_sym.ty)) { |
| 173766 | .enum_type => { | 173767 | .enum_type => { |
| 173767 | const enum_ty: Type = .fromInterned(lazy_sym.ty); | 173768 | const enum_ty: Type = .fromInterned(lazy_sym.ty); |
| 173768 | wip_mir_log.debug("{f}.@tagName:", .{enum_ty.fmt(pt)}); | 173769 | wip_mir_log.debug("{f}.@tagName:", .{enum_ty.fmt(zcu)}); |
| 173769 | 173770 | ||
| 173770 | const ret_regs = abi.getCAbiIntReturnRegs(.auto)[0..2].*; | 173771 | const ret_regs = abi.getCAbiIntReturnRegs(.auto)[0..2].*; |
| 173771 | const ret_locks = cg.register_manager.lockRegsAssumeUnused(2, ret_regs); | 173772 | const ret_locks = cg.register_manager.lockRegsAssumeUnused(2, ret_regs); |
| ... | @@ -173826,7 +173827,7 @@ fn genLazy(cg: *CodeGen, lazy_sym: link.File.LazySymbol) InnerError!void { | ... | @@ -173826,7 +173827,7 @@ fn genLazy(cg: *CodeGen, lazy_sym: link.File.LazySymbol) InnerError!void { |
| 173826 | }, | 173827 | }, |
| 173827 | .error_set_type => |error_set_type| { | 173828 | .error_set_type => |error_set_type| { |
| 173828 | const err_ty: Type = .fromInterned(lazy_sym.ty); | 173829 | const err_ty: Type = .fromInterned(lazy_sym.ty); |
| 173829 | wip_mir_log.debug("{f}.@errorCast:", .{err_ty.fmt(pt)}); | 173830 | wip_mir_log.debug("{f}.@errorCast:", .{err_ty.fmt(zcu)}); |
| 173830 | 173831 | ||
| 173831 | const ret_reg = abi.getCAbiIntReturnRegs(.auto)[0]; | 173832 | const ret_reg = abi.getCAbiIntReturnRegs(.auto)[0]; |
| 173832 | const ret_lock = cg.register_manager.lockRegAssumeUnused(ret_reg); | 173833 | const ret_lock = cg.register_manager.lockRegAssumeUnused(ret_reg); |
| ... | @@ -173871,7 +173872,7 @@ fn genLazy(cg: *CodeGen, lazy_sym: link.File.LazySymbol) InnerError!void { | ... | @@ -173871,7 +173872,7 @@ fn genLazy(cg: *CodeGen, lazy_sym: link.File.LazySymbol) InnerError!void { |
| 173871 | }, | 173872 | }, |
| 173872 | else => return cg.fail( | 173873 | else => return cg.fail( |
| 173873 | "TODO implement {s} for {f}", | 173874 | "TODO implement {s} for {f}", |
| 173874 | .{ @tagName(lazy_sym.kind), Type.fromInterned(lazy_sym.ty).fmt(pt) }, | 173875 | .{ @tagName(lazy_sym.kind), Type.fromInterned(lazy_sym.ty).fmt(zcu) }, |
| 173875 | ), | 173876 | ), |
| 173876 | } | 173877 | } |
| 173877 | try cg.resetTemps(@fromBackingInt(@intCast(0))); | 173878 | try cg.resetTemps(@fromBackingInt(@intCast(0))); |
| ... | @@ -174080,7 +174081,7 @@ fn allocMemPtr(self: *CodeGen, inst: Air.Inst.Index) !FrameIndex { | ... | @@ -174080,7 +174081,7 @@ fn allocMemPtr(self: *CodeGen, inst: Air.Inst.Index) !FrameIndex { |
| 174080 | const val_ty = ptr_ty.childType(zcu); | 174081 | const val_ty = ptr_ty.childType(zcu); |
| 174081 | return self.allocFrameIndex(.init(.{ | 174082 | return self.allocFrameIndex(.init(.{ |
| 174082 | .size = std.math.cast(u32, val_ty.abiSize(zcu)) orelse { | 174083 | .size = std.math.cast(u32, val_ty.abiSize(zcu)) orelse { |
| 174083 | return self.fail("type '{f}' too big to fit into stack frame", .{val_ty.fmt(pt)}); | 174084 | return self.fail("type '{f}' too big to fit into stack frame", .{val_ty.fmt(zcu)}); |
| 174084 | }, | 174085 | }, |
| 174085 | .alignment = ptr_ty.ptrAlignment(zcu).max(.@"1"), | 174086 | .alignment = ptr_ty.ptrAlignment(zcu).max(.@"1"), |
| 174086 | })); | 174087 | })); |
| ... | @@ -174098,7 +174099,7 @@ fn allocRegOrMemAdvanced(self: *CodeGen, ty: Type, inst: ?Air.Inst.Index, reg_ok | ... | @@ -174098,7 +174099,7 @@ fn allocRegOrMemAdvanced(self: *CodeGen, ty: Type, inst: ?Air.Inst.Index, reg_ok |
| 174098 | const pt = self.pt; | 174099 | const pt = self.pt; |
| 174099 | const zcu = pt.zcu; | 174100 | const zcu = pt.zcu; |
| 174100 | const abi_size = std.math.cast(u32, ty.abiSize(zcu)) orelse { | 174101 | const abi_size = std.math.cast(u32, ty.abiSize(zcu)) orelse { |
| 174101 | return self.fail("type '{f}' too big to fit into stack frame", .{ty.fmt(pt)}); | 174102 | return self.fail("type '{f}' too big to fit into stack frame", .{ty.fmt(zcu)}); |
| 174102 | }; | 174103 | }; |
| 174103 | 174104 | ||
| 174104 | if (reg_ok) need_mem: { | 174105 | if (reg_ok) need_mem: { |
| ... | @@ -174592,9 +174593,9 @@ fn store( | ... | @@ -174592,9 +174593,9 @@ fn store( |
| 174592 | } | 174593 | } |
| 174593 | 174594 | ||
| 174594 | fn genUnOpMir(self: *CodeGen, mir_tag: Mir.Inst.FixedTag, dst_ty: Type, dst_mcv: MCValue) !void { | 174595 | fn genUnOpMir(self: *CodeGen, mir_tag: Mir.Inst.FixedTag, dst_ty: Type, dst_mcv: MCValue) !void { |
| 174595 | const pt = self.pt; | 174596 | const zcu = self.pt.zcu; |
| 174596 | const abi_size: u32 = @intCast(dst_ty.abiSize(pt.zcu)); | 174597 | const abi_size: u32 = @intCast(dst_ty.abiSize(zcu)); |
| 174597 | if (abi_size > 8) return self.fail("TODO implement {} for {f}", .{ mir_tag, dst_ty.fmt(pt) }); | 174598 | if (abi_size > 8) return self.fail("TODO implement {} for {f}", .{ mir_tag, dst_ty.fmt(zcu) }); |
| 174598 | switch (dst_mcv) { | 174599 | switch (dst_mcv) { |
| 174599 | .none, | 174600 | .none, |
| 174600 | .unreach, | 174601 | .unreach, |
| ... | @@ -176294,7 +176295,7 @@ fn genCall(cg: *CodeGen, info: union(enum) { | ... | @@ -176294,7 +176295,7 @@ fn genCall(cg: *CodeGen, info: union(enum) { |
| 176294 | } }); | 176295 | } }); |
| 176295 | dst.copyToMask(&src, cg) catch |err| switch (err) { | 176296 | dst.copyToMask(&src, cg) catch |err| switch (err) { |
| 176296 | error.SelectFailed => return cg.fail("failed to select arg {f} {f} {f}", .{ | 176297 | error.SelectFailed => return cg.fail("failed to select arg {f} {f} {f}", .{ |
| 176297 | arg_ty.fmt(pt), | 176298 | arg_ty.fmt(zcu), |
| 176298 | dst.tracking(cg), | 176299 | dst.tracking(cg), |
| 176299 | src.tracking(cg), | 176300 | src.tracking(cg), |
| 176300 | }), | 176301 | }), |
| ... | @@ -176515,7 +176516,7 @@ fn genCall(cg: *CodeGen, info: union(enum) { | ... | @@ -176515,7 +176516,7 @@ fn genCall(cg: *CodeGen, info: union(enum) { |
| 176515 | var dst = try cg.tempInit(arg_ty, dst_arg); | 176516 | var dst = try cg.tempInit(arg_ty, dst_arg); |
| 176516 | dst.copyToMask(&src, cg) catch |err| switch (err) { | 176517 | dst.copyToMask(&src, cg) catch |err| switch (err) { |
| 176517 | error.SelectFailed => return cg.fail("failed to select arg {f} {f} {f}", .{ | 176518 | error.SelectFailed => return cg.fail("failed to select arg {f} {f} {f}", .{ |
| 176518 | arg_ty.fmt(pt), | 176519 | arg_ty.fmt(zcu), |
| 176519 | dst.tracking(cg), | 176520 | dst.tracking(cg), |
| 176520 | src.tracking(cg), | 176521 | src.tracking(cg), |
| 176521 | }), | 176522 | }), |
| ... | @@ -176640,9 +176641,10 @@ fn genCall(cg: *CodeGen, info: union(enum) { | ... | @@ -176640,9 +176641,10 @@ fn genCall(cg: *CodeGen, info: union(enum) { |
| 176640 | } | 176641 | } |
| 176641 | 176642 | ||
| 176642 | fn airRet(cg: *CodeGen, inst: Air.Inst.Index, safety: bool) !void { | 176643 | fn airRet(cg: *CodeGen, inst: Air.Inst.Index, safety: bool) !void { |
| 176644 | const zcu = cg.pt.zcu; | ||
| 176643 | const un_op = cg.air.instructions.items(.data)[@backingInt(inst)].un_op; | 176645 | const un_op = cg.air.instructions.items(.data)[@backingInt(inst)].un_op; |
| 176644 | 176646 | ||
| 176645 | const ret_ty = cg.fn_type.fnReturnType(cg.pt.zcu); | 176647 | const ret_ty = cg.fn_type.fnReturnType(zcu); |
| 176646 | switch (cg.ret_mcv.short) { | 176648 | switch (cg.ret_mcv.short) { |
| 176647 | .none => {}, | 176649 | .none => {}, |
| 176648 | .register => |reg| { | 176650 | .register => |reg| { |
| ... | @@ -176660,7 +176662,7 @@ fn airRet(cg: *CodeGen, inst: Air.Inst.Index, safety: bool) !void { | ... | @@ -176660,7 +176662,7 @@ fn airRet(cg: *CodeGen, inst: Air.Inst.Index, safety: bool) !void { |
| 176660 | var dst = try cg.tempInit(ret_ty, cg.ret_mcv.short); | 176662 | var dst = try cg.tempInit(ret_ty, cg.ret_mcv.short); |
| 176661 | dst.copyToMask(&src, cg) catch |err| switch (err) { | 176663 | dst.copyToMask(&src, cg) catch |err| switch (err) { |
| 176662 | error.SelectFailed => return cg.fail("failed to select ret {f} {f} {f}", .{ | 176664 | error.SelectFailed => return cg.fail("failed to select ret {f} {f} {f}", .{ |
| 176663 | ret_ty.fmt(cg.pt), | 176665 | ret_ty.fmt(zcu), |
| 176664 | dst.tracking(cg), | 176666 | dst.tracking(cg), |
| 176665 | src.tracking(cg), | 176667 | src.tracking(cg), |
| 176666 | }), | 176668 | }), |
| ... | @@ -176706,6 +176708,7 @@ fn airRet(cg: *CodeGen, inst: Air.Inst.Index, safety: bool) !void { | ... | @@ -176706,6 +176708,7 @@ fn airRet(cg: *CodeGen, inst: Air.Inst.Index, safety: bool) !void { |
| 176706 | } | 176708 | } |
| 176707 | 176709 | ||
| 176708 | fn airRetLoad(cg: *CodeGen, inst: Air.Inst.Index) !void { | 176710 | fn airRetLoad(cg: *CodeGen, inst: Air.Inst.Index) !void { |
| 176711 | const zcu = cg.pt.zcu; | ||
| 176709 | const un_op = cg.air.instructions.items(.data)[@backingInt(inst)].un_op; | 176712 | const un_op = cg.air.instructions.items(.data)[@backingInt(inst)].un_op; |
| 176710 | switch (cg.ret_mcv.short) { | 176713 | switch (cg.ret_mcv.short) { |
| 176711 | .none => {}, | 176714 | .none => {}, |
| ... | @@ -176716,13 +176719,13 @@ fn airRetLoad(cg: *CodeGen, inst: Air.Inst.Index) !void { | ... | @@ -176716,13 +176719,13 @@ fn airRetLoad(cg: *CodeGen, inst: Air.Inst.Index) !void { |
| 176716 | => try cg.load(cg.ret_mcv.short, cg.typeOf(un_op), try cg.resolveInst(un_op)), | 176719 | => try cg.load(cg.ret_mcv.short, cg.typeOf(un_op), try cg.resolveInst(un_op)), |
| 176717 | .register_mask => { | 176720 | .register_mask => { |
| 176718 | var ptr = try cg.tempFromOperand(un_op, true); | 176721 | var ptr = try cg.tempFromOperand(un_op, true); |
| 176719 | const ret_ty = ptr.typeOf(cg).childType(cg.pt.zcu); | 176722 | const ret_ty = ptr.typeOf(cg).childType(zcu); |
| 176720 | var src = try ptr.load(ret_ty, .{}, cg); | 176723 | var src = try ptr.load(ret_ty, .{}, cg); |
| 176721 | try ptr.die(cg); | 176724 | try ptr.die(cg); |
| 176722 | var dst = try cg.tempInit(ret_ty, cg.ret_mcv.short); | 176725 | var dst = try cg.tempInit(ret_ty, cg.ret_mcv.short); |
| 176723 | dst.copyToMask(&src, cg) catch |err| switch (err) { | 176726 | dst.copyToMask(&src, cg) catch |err| switch (err) { |
| 176724 | error.SelectFailed => return cg.fail("failed to select ret_load {f} {f} {f}", .{ | 176727 | error.SelectFailed => return cg.fail("failed to select ret_load {f} {f} {f}", .{ |
| 176725 | ret_ty.fmt(cg.pt), | 176728 | ret_ty.fmt(zcu), |
| 176726 | dst.tracking(cg), | 176729 | dst.tracking(cg), |
| 176727 | src.tracking(cg), | 176730 | src.tracking(cg), |
| 176728 | }), | 176731 | }), |
| ... | @@ -176839,7 +176842,7 @@ fn genCondBrMir(self: *CodeGen, ty: Type, mcv: MCValue) !?Mir.Inst.Index { | ... | @@ -176839,7 +176842,7 @@ fn genCondBrMir(self: *CodeGen, ty: Type, mcv: MCValue) !?Mir.Inst.Index { |
| 176839 | return try self.asmJccReloc(.z, undefined); | 176842 | return try self.asmJccReloc(.z, undefined); |
| 176840 | }, | 176843 | }, |
| 176841 | else => return self.fail("TODO implement condbr when condition is {f} {s}", .{ | 176844 | else => return self.fail("TODO implement condbr when condition is {f} {s}", .{ |
| 176842 | ty.fmt(self.pt), @tagName(mcv), | 176845 | ty.fmt(self.pt.zcu), @tagName(mcv), |
| 176843 | }), | 176846 | }), |
| 176844 | } | 176847 | } |
| 176845 | } | 176848 | } |
| ... | @@ -178721,7 +178724,7 @@ fn moveStrategy(cg: *CodeGen, ty: Type, class: Register.Class, aligned: bool) !M | ... | @@ -178721,7 +178724,7 @@ fn moveStrategy(cg: *CodeGen, ty: Type, class: Register.Class, aligned: bool) !M |
| 178721 | }, | 178724 | }, |
| 178722 | .ip, .cr, .dr => {}, | 178725 | .ip, .cr, .dr => {}, |
| 178723 | } | 178726 | } |
| 178724 | return cg.fail("TODO moveStrategy for {f}", .{ty.fmt(pt)}); | 178727 | return cg.fail("TODO moveStrategy for {f}", .{ty.fmt(zcu)}); |
| 178725 | } | 178728 | } |
| 178726 | 178729 | ||
| 178727 | const CopyOptions = struct { | 178730 | const CopyOptions = struct { |
| ... | @@ -178729,7 +178732,7 @@ const CopyOptions = struct { | ... | @@ -178729,7 +178732,7 @@ const CopyOptions = struct { |
| 178729 | }; | 178732 | }; |
| 178730 | 178733 | ||
| 178731 | fn genCopy(self: *CodeGen, ty: Type, dst_mcv: MCValue, src_mcv: MCValue, opts: CopyOptions) InnerError!void { | 178734 | fn genCopy(self: *CodeGen, ty: Type, dst_mcv: MCValue, src_mcv: MCValue, opts: CopyOptions) InnerError!void { |
| 178732 | const pt = self.pt; | 178735 | const zcu = self.pt.zcu; |
| 178733 | 178736 | ||
| 178734 | const src_lock = if (src_mcv.getReg()) |reg| self.register_manager.lockReg(reg) else null; | 178737 | const src_lock = if (src_mcv.getReg()) |reg| self.register_manager.lockReg(reg) else null; |
| 178735 | defer if (src_lock) |lock| self.register_manager.unlockReg(lock); | 178738 | defer if (src_lock) |lock| self.register_manager.unlockReg(lock); |
| ... | @@ -178790,7 +178793,7 @@ fn genCopy(self: *CodeGen, ty: Type, dst_mcv: MCValue, src_mcv: MCValue, opts: C | ... | @@ -178790,7 +178793,7 @@ fn genCopy(self: *CodeGen, ty: Type, dst_mcv: MCValue, src_mcv: MCValue, opts: C |
| 178790 | .register => |src_reg| switch (dst_regs[0].class()) { | 178793 | .register => |src_reg| switch (dst_regs[0].class()) { |
| 178791 | .general_purpose => switch (src_reg.class()) { | 178794 | .general_purpose => switch (src_reg.class()) { |
| 178792 | else => unreachable, | 178795 | else => unreachable, |
| 178793 | .sse => if (ty.abiSize(pt.zcu) <= 16) { | 178796 | .sse => if (ty.abiSize(zcu) <= 16) { |
| 178794 | if (self.hasFeature(.avx)) { | 178797 | if (self.hasFeature(.avx)) { |
| 178795 | try self.asmRegisterRegister(.{ .v_q, .mov }, dst_regs[0].to64(), src_reg.to128()); | 178798 | try self.asmRegisterRegister(.{ .v_q, .mov }, dst_regs[0].to64(), src_reg.to128()); |
| 178796 | try self.asmRegisterRegisterImmediate(.{ .vp_q, .extr }, dst_regs[1].to64(), src_reg.to128(), .u(1)); | 178799 | try self.asmRegisterRegisterImmediate(.{ .vp_q, .extr }, dst_regs[1].to64(), src_reg.to128(), .u(1)); |
| ... | @@ -178865,7 +178868,7 @@ fn genCopy(self: *CodeGen, ty: Type, dst_mcv: MCValue, src_mcv: MCValue, opts: C | ... | @@ -178865,7 +178868,7 @@ fn genCopy(self: *CodeGen, ty: Type, dst_mcv: MCValue, src_mcv: MCValue, opts: C |
| 178865 | }, | 178868 | }, |
| 178866 | .air_ref => |src_ref| return self.genCopy(ty, dst_mcv, try self.resolveInst(src_ref), opts), | 178869 | .air_ref => |src_ref| return self.genCopy(ty, dst_mcv, try self.resolveInst(src_ref), opts), |
| 178867 | else => return self.fail("TODO implement genCopy for {s} of {f}", .{ | 178870 | else => return self.fail("TODO implement genCopy for {s} of {f}", .{ |
| 178868 | @tagName(src_mcv), ty.fmt(pt), | 178871 | @tagName(src_mcv), ty.fmt(zcu), |
| 178869 | }), | 178872 | }), |
| 178870 | }; | 178873 | }; |
| 178871 | defer if (src_info) |info| self.register_manager.unlockReg(info.addr_lock); | 178874 | defer if (src_info) |info| self.register_manager.unlockReg(info.addr_lock); |
| ... | @@ -179249,7 +179252,7 @@ fn genSetReg( | ... | @@ -179249,7 +179252,7 @@ fn genSetReg( |
| 179249 | 80 => null, | 179252 | 80 => null, |
| 179250 | else => unreachable, | 179253 | else => unreachable, |
| 179251 | }, | 179254 | }, |
| 179252 | }) orelse return cg.fail("TODO implement genSetReg for {f}", .{ty.fmt(pt)}), | 179255 | }) orelse return cg.fail("TODO implement genSetReg for {f}", .{ty.fmt(zcu)}), |
| 179253 | dst_alias, | 179256 | dst_alias, |
| 179254 | registerAlias(src_reg, @intCast(cg.unalignedSize(ty))), | 179257 | registerAlias(src_reg, @intCast(cg.unalignedSize(ty))), |
| 179255 | ), | 179258 | ), |
| ... | @@ -179360,7 +179363,7 @@ fn genSetReg( | ... | @@ -179360,7 +179363,7 @@ fn genSetReg( |
| 179360 | assert(!ty.optionalReprIsPayload(zcu)); | 179363 | assert(!ty.optionalReprIsPayload(zcu)); |
| 179361 | break :first_ty opt_child; | 179364 | break :first_ty opt_child; |
| 179362 | }, | 179365 | }, |
| 179363 | else => std.debug.panic("{s}: {f}\n", .{ @src().fn_name, ty.fmt(pt) }), | 179366 | else => std.debug.panic("{s}: {f}\n", .{ @src().fn_name, ty.fmt(zcu) }), |
| 179364 | }); | 179367 | }); |
| 179365 | const first_size: u31 = @intCast(first_ty.abiSize(zcu)); | 179368 | const first_size: u31 = @intCast(first_ty.abiSize(zcu)); |
| 179366 | const frame_size = std.math.ceilPowerOfTwoAssert(u32, abi_size); | 179369 | const frame_size = std.math.ceilPowerOfTwoAssert(u32, abi_size); |
| ... | @@ -179769,7 +179772,7 @@ fn genSetMem( | ... | @@ -179769,7 +179772,7 @@ fn genSetMem( |
| 179769 | ); | 179772 | ); |
| 179770 | }, | 179773 | }, |
| 179771 | else => return cg.fail("TODO implement genSetMem for {s} of {f}", .{ | 179774 | else => return cg.fail("TODO implement genSetMem for {s} of {f}", .{ |
| 179772 | @tagName(src_mcv), ty.fmt(pt), | 179775 | @tagName(src_mcv), ty.fmt(zcu), |
| 179773 | }), | 179776 | }), |
| 179774 | }, | 179777 | }, |
| 179775 | .register_offset => |reg_off| { | 179778 | .register_offset => |reg_off| { |
| ... | @@ -180329,7 +180332,7 @@ fn atomicOp( | ... | @@ -180329,7 +180332,7 @@ fn atomicOp( |
| 180329 | }, | 180332 | }, |
| 180330 | else => unreachable, | 180333 | else => unreachable, |
| 180331 | }) orelse return self.fail("TODO implement atomicOp of {s} for {f}", .{ | 180334 | }) orelse return self.fail("TODO implement atomicOp of {s} for {f}", .{ |
| 180332 | @tagName(op), val_ty.fmt(pt), | 180335 | @tagName(op), val_ty.fmt(zcu), |
| 180333 | }); | 180336 | }); |
| 180334 | try self.genSetReg(sse_reg, val_ty, .{ .register = .rax }, .{}); | 180337 | try self.genSetReg(sse_reg, val_ty, .{ .register = .rax }, .{}); |
| 180335 | switch (mir_tag[0]) { | 180338 | switch (mir_tag[0]) { |
| ... | @@ -180778,12 +180781,12 @@ fn airSelect(self: *CodeGen, inst: Air.Inst.Index) !void { | ... | @@ -180778,12 +180781,12 @@ fn airSelect(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 180778 | else | 180781 | else |
| 180779 | try self.copyToTmpRegister(pred_ty, pred_mcv) | 180782 | try self.copyToTmpRegister(pred_ty, pred_mcv) |
| 180780 | else | 180783 | else |
| 180781 | return self.fail("TODO implement airSelect for {f}", .{ty.fmt(pt)}), | 180784 | return self.fail("TODO implement airSelect for {f}", .{ty.fmt(zcu)}), |
| 180782 | else => unreachable, | 180785 | else => unreachable, |
| 180783 | }, | 180786 | }, |
| 180784 | .register_mask => |pred_reg_mask| { | 180787 | .register_mask => |pred_reg_mask| { |
| 180785 | if (pred_reg_mask.info.scalar.bitSize(self.target) != 8 * elem_abi_size) | 180788 | if (pred_reg_mask.info.scalar.bitSize(self.target) != 8 * elem_abi_size) |
| 180786 | return self.fail("TODO implement airSelect for {f}", .{ty.fmt(pt)}); | 180789 | return self.fail("TODO implement airSelect for {f}", .{ty.fmt(zcu)}); |
| 180787 | 180790 | ||
| 180788 | const mask_reg: Register = if (need_xmm0 and pred_reg_mask.reg.id() != comptime Register.xmm0.id()) mask_reg: { | 180791 | const mask_reg: Register = if (need_xmm0 and pred_reg_mask.reg.id() != comptime Register.xmm0.id()) mask_reg: { |
| 180789 | try self.register_manager.getKnownReg(.xmm0, null); | 180792 | try self.register_manager.getKnownReg(.xmm0, null); |
| ... | @@ -180857,7 +180860,7 @@ fn airSelect(self: *CodeGen, inst: Air.Inst.Index) !void { | ... | @@ -180857,7 +180860,7 @@ fn airSelect(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 180857 | else | 180860 | else |
| 180858 | null | 180861 | null |
| 180859 | else | 180862 | else |
| 180860 | null) orelse return self.fail("TODO implement airSelect for {f}", .{ty.fmt(pt)}); | 180863 | null) orelse return self.fail("TODO implement airSelect for {f}", .{ty.fmt(zcu)}); |
| 180861 | if (has_avx) { | 180864 | if (has_avx) { |
| 180862 | const rhs_alias = if (reuse_mcv.isRegister()) | 180865 | const rhs_alias = if (reuse_mcv.isRegister()) |
| 180863 | registerAlias(reuse_mcv.getReg().?, abi_size) | 180866 | registerAlias(reuse_mcv.getReg().?, abi_size) |
| ... | @@ -181010,7 +181013,7 @@ fn airSelect(self: *CodeGen, inst: Air.Inst.Index) !void { | ... | @@ -181010,7 +181013,7 @@ fn airSelect(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 181010 | else => unreachable, | 181013 | else => unreachable, |
| 181011 | }), | 181014 | }), |
| 181012 | ); | 181015 | ); |
| 181013 | } else return self.fail("TODO implement airSelect for {f}", .{ty.fmt(pt)}); | 181016 | } else return self.fail("TODO implement airSelect for {f}", .{ty.fmt(zcu)}); |
| 181014 | const elem_bits: u16 = @intCast(elem_abi_size * 8); | 181017 | const elem_bits: u16 = @intCast(elem_abi_size * 8); |
| 181015 | if (!pred_fits_in_elem) if (self.hasFeature(.ssse3)) { | 181018 | if (!pred_fits_in_elem) if (self.hasFeature(.ssse3)) { |
| 181016 | const mask_len = elem_abi_size * vec_len; | 181019 | const mask_len = elem_abi_size * vec_len; |
| ... | @@ -181039,7 +181042,7 @@ fn airSelect(self: *CodeGen, inst: Air.Inst.Index) !void { | ... | @@ -181039,7 +181042,7 @@ fn airSelect(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 181039 | mask_alias, | 181042 | mask_alias, |
| 181040 | mask_mem, | 181043 | mask_mem, |
| 181041 | ); | 181044 | ); |
| 181042 | } else return self.fail("TODO implement airSelect for {f}", .{ty.fmt(pt)}); | 181045 | } else return self.fail("TODO implement airSelect for {f}", .{ty.fmt(zcu)}); |
| 181043 | { | 181046 | { |
| 181044 | const mask_elem_ty = try pt.intType(.unsigned, elem_bits); | 181047 | const mask_elem_ty = try pt.intType(.unsigned, elem_bits); |
| 181045 | const mask_ty = try pt.vectorType(.{ .len = vec_len, .child = mask_elem_ty.toIntern() }); | 181048 | const mask_ty = try pt.vectorType(.{ .len = vec_len, .child = mask_elem_ty.toIntern() }); |
| ... | @@ -181159,7 +181162,7 @@ fn airSelect(self: *CodeGen, inst: Air.Inst.Index) !void { | ... | @@ -181159,7 +181162,7 @@ fn airSelect(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 181159 | else => null, | 181162 | else => null, |
| 181160 | }, | 181163 | }, |
| 181161 | }, | 181164 | }, |
| 181162 | }) orelse return self.fail("TODO implement airSelect for {f}", .{ty.fmt(pt)}); | 181165 | }) orelse return self.fail("TODO implement airSelect for {f}", .{ty.fmt(zcu)}); |
| 181163 | if (has_avx) { | 181166 | if (has_avx) { |
| 181164 | const rhs_alias = if (rhs_mcv.isRegister()) | 181167 | const rhs_alias = if (rhs_mcv.isRegister()) |
| 181165 | registerAlias(rhs_mcv.getReg().?, abi_size) | 181168 | registerAlias(rhs_mcv.getReg().?, abi_size) |
| ... | @@ -181466,7 +181469,7 @@ fn airVaArg(self: *CodeGen, inst: Air.Inst.Index) !void { | ... | @@ -181466,7 +181469,7 @@ fn airVaArg(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 181466 | assert(classes.len == 1); | 181469 | assert(classes.len == 1); |
| 181467 | unreachable; | 181470 | unreachable; |
| 181468 | }, | 181471 | }, |
| 181469 | else => return self.fail("TODO implement c_va_arg for {f} on SysV", .{promote_ty.fmt(pt)}), | 181472 | else => return self.fail("TODO implement c_va_arg for {f} on SysV", .{promote_ty.fmt(zcu)}), |
| 181470 | } | 181473 | } |
| 181471 | 181474 | ||
| 181472 | if (unused) break :result .unreach; | 181475 | if (unused) break :result .unreach; |
| ... | @@ -181512,7 +181515,7 @@ fn airVaArg(self: *CodeGen, inst: Air.Inst.Index) !void { | ... | @@ -181512,7 +181515,7 @@ fn airVaArg(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 181512 | try self.genCopy(.usize, next_arg_ptr, .{ .register = next_arg_ptr_reg }, .{}); | 181515 | try self.genCopy(.usize, next_arg_ptr, .{ .register = next_arg_ptr_reg }, .{}); |
| 181513 | }, | 181516 | }, |
| 181514 | .memory => unreachable, | 181517 | .memory => unreachable, |
| 181515 | else => return self.fail("TODO implement c_va_arg for {f} on Win64", .{promote_ty.fmt(pt)}), | 181518 | else => return self.fail("TODO implement c_va_arg for {f} on Win64", .{promote_ty.fmt(zcu)}), |
| 181516 | } | 181519 | } |
| 181517 | 181520 | ||
| 181518 | if (unused) break :result .unreach; | 181521 | if (unused) break :result .unreach; |
| ... | @@ -182299,7 +182302,7 @@ fn splitType(self: *CodeGen, comptime parts_len: usize, ty: Type) ![parts_len]Ty | ... | @@ -182299,7 +182302,7 @@ fn splitType(self: *CodeGen, comptime parts_len: usize, ty: Type) ![parts_len]Ty |
| 182299 | if (abi_size == parts_size) return parts; | 182302 | if (abi_size == parts_size) return parts; |
| 182300 | if (classes[classes.len - 1] == .float and abi_size > parts_size and abi_size <= parts_size + 4) return parts; | 182303 | if (classes[classes.len - 1] == .float and abi_size > parts_size and abi_size <= parts_size + 4) return parts; |
| 182301 | }; | 182304 | }; |
| 182302 | return self.fail("TODO implement splitType({d}, {f})", .{ parts_len, ty.fmt(pt) }); | 182305 | return self.fail("TODO implement splitType({d}, {f})", .{ parts_len, ty.fmt(zcu) }); |
| 182303 | } | 182306 | } |
| 182304 | 182307 | ||
| 182305 | /// Truncates the value in the register in place. | 182308 | /// Truncates the value in the register in place. |
| ... | @@ -183183,6 +183186,7 @@ const Temp = struct { | ... | @@ -183183,6 +183186,7 @@ const Temp = struct { |
| 183183 | } | 183186 | } |
| 183184 | 183187 | ||
| 183185 | fn store(ptr: *Temp, val: *Temp, opts: AccessOptions, cg: *CodeGen) InnerError!void { | 183188 | fn store(ptr: *Temp, val: *Temp, opts: AccessOptions, cg: *CodeGen) InnerError!void { |
| 183189 | const zcu = cg.pt.zcu; | ||
| 183186 | const val_ty = val.typeOf(cg); | 183190 | const val_ty = val.typeOf(cg); |
| 183187 | try ptr.toOffset(opts.disp, cg); | 183191 | try ptr.toOffset(opts.disp, cg); |
| 183188 | while (try ptr.toLea(cg)) {} | 183192 | while (try ptr.toLea(cg)) {} |
| ... | @@ -183194,7 +183198,7 @@ const Temp = struct { | ... | @@ -183194,7 +183198,7 @@ const Temp = struct { |
| 183194 | else => |mcv| std.debug.panic("{s}: {f}\n", .{ @src().fn_name, mcv }), | 183198 | else => |mcv| std.debug.panic("{s}: {f}\n", .{ @src().fn_name, mcv }), |
| 183195 | .undef => if (opts.safe) { | 183199 | .undef => if (opts.safe) { |
| 183196 | var pat = try cg.tempInit(.u8, .{ .immediate = 0xaa }); | 183200 | var pat = try cg.tempInit(.u8, .{ .immediate = 0xaa }); |
| 183197 | var len = try cg.tempInit(.usize, .{ .immediate = val_ty.abiSize(cg.pt.zcu) }); | 183201 | var len = try cg.tempInit(.usize, .{ .immediate = val_ty.abiSize(zcu) }); |
| 183198 | try ptr.memset(&pat, &len, cg); | 183202 | try ptr.memset(&pat, &len, cg); |
| 183199 | try pat.die(cg); | 183203 | try pat.die(cg); |
| 183200 | try len.die(cg); | 183204 | try len.die(cg); |
| ... | @@ -183248,12 +183252,12 @@ const Temp = struct { | ... | @@ -183248,12 +183252,12 @@ const Temp = struct { |
| 183248 | .register_offset => |val_reg_off| switch (val_reg_off.off) { | 183252 | .register_offset => |val_reg_off| switch (val_reg_off.off) { |
| 183249 | 0 => try ptr.storeRegs(val_ty, &.{registerAlias( | 183253 | 0 => try ptr.storeRegs(val_ty, &.{registerAlias( |
| 183250 | val_reg_off.reg, | 183254 | val_reg_off.reg, |
| 183251 | @intCast(val_ty.abiSize(cg.pt.zcu)), | 183255 | @intCast(val_ty.abiSize(zcu)), |
| 183252 | )}, cg), | 183256 | )}, cg), |
| 183253 | else => continue :val_to_gpr, | 183257 | else => continue :val_to_gpr, |
| 183254 | }, | 183258 | }, |
| 183255 | .register_overflow => |val_reg_ov| { | 183259 | .register_overflow => |val_reg_ov| { |
| 183256 | const ip = &cg.pt.zcu.intern_pool; | 183260 | const ip = &zcu.intern_pool; |
| 183257 | const first_ty: Type = .fromInterned(first_ty: switch (ip.indexToKey(val_ty.toIntern())) { | 183261 | const first_ty: Type = .fromInterned(first_ty: switch (ip.indexToKey(val_ty.toIntern())) { |
| 183258 | .tuple_type => |tuple_type| { | 183262 | .tuple_type => |tuple_type| { |
| 183259 | const tuple_field_types = tuple_type.types.get(ip); | 183263 | const tuple_field_types = tuple_type.types.get(ip); |
| ... | @@ -183261,12 +183265,12 @@ const Temp = struct { | ... | @@ -183261,12 +183265,12 @@ const Temp = struct { |
| 183261 | break :first_ty tuple_field_types[0]; | 183265 | break :first_ty tuple_field_types[0]; |
| 183262 | }, | 183266 | }, |
| 183263 | .opt_type => |opt_child| { | 183267 | .opt_type => |opt_child| { |
| 183264 | assert(!val_ty.optionalReprIsPayload(cg.pt.zcu)); | 183268 | assert(!val_ty.optionalReprIsPayload(zcu)); |
| 183265 | break :first_ty opt_child; | 183269 | break :first_ty opt_child; |
| 183266 | }, | 183270 | }, |
| 183267 | else => std.debug.panic("{s}: {f}\n", .{ @src().fn_name, val_ty.fmt(cg.pt) }), | 183271 | else => std.debug.panic("{s}: {f}\n", .{ @src().fn_name, val_ty.fmt(zcu) }), |
| 183268 | }); | 183272 | }); |
| 183269 | const first_size: u31 = @intCast(first_ty.abiSize(cg.pt.zcu)); | 183273 | const first_size: u31 = @intCast(first_ty.abiSize(zcu)); |
| 183270 | try ptr.storeRegs(first_ty, &.{registerAlias(val_reg_ov.reg, first_size)}, cg); | 183274 | try ptr.storeRegs(first_ty, &.{registerAlias(val_reg_ov.reg, first_size)}, cg); |
| 183271 | try ptr.toOffset(first_size, cg); | 183275 | try ptr.toOffset(first_size, cg); |
| 183272 | try cg.asmSetccMemory( | 183276 | try cg.asmSetccMemory( |
| ... | @@ -183277,7 +183281,7 @@ const Temp = struct { | ... | @@ -183277,7 +183281,7 @@ const Temp = struct { |
| 183277 | .lea_frame, .lea_nav, .lea_uav, .lea_lazy_sym => continue :val_to_gpr, | 183281 | .lea_frame, .lea_nav, .lea_uav, .lea_lazy_sym => continue :val_to_gpr, |
| 183278 | .memory, .indirect, .load_frame, .load_nav, .load_uav, .load_lazy_sym => { | 183282 | .memory, .indirect, .load_frame, .load_nav, .load_uav, .load_lazy_sym => { |
| 183279 | var val_ptr = try cg.tempInit(.usize, val_mcv.address()); | 183283 | var val_ptr = try cg.tempInit(.usize, val_mcv.address()); |
| 183280 | try ptr.memcpy(&val_ptr, val_ty.abiSize(cg.pt.zcu), cg); | 183284 | try ptr.memcpy(&val_ptr, val_ty.abiSize(zcu), cg); |
| 183281 | try val_ptr.die(cg); | 183285 | try val_ptr.die(cg); |
| 183282 | }, | 183286 | }, |
| 183283 | } | 183287 | } |
| ... | @@ -183325,6 +183329,7 @@ const Temp = struct { | ... | @@ -183325,6 +183329,7 @@ const Temp = struct { |
| 183325 | } | 183329 | } |
| 183326 | 183330 | ||
| 183327 | fn write(dst: *Temp, val: *Temp, opts: AccessOptions, cg: *CodeGen) InnerError!void { | 183331 | fn write(dst: *Temp, val: *Temp, opts: AccessOptions, cg: *CodeGen) InnerError!void { |
| 183332 | const zcu = cg.pt.zcu; | ||
| 183328 | const val_ty = val.typeOf(cg); | 183333 | const val_ty = val.typeOf(cg); |
| 183329 | while (try dst.toBase(false, cg)) {} | 183334 | while (try dst.toBase(false, cg)) {} |
| 183330 | val_to_gpr: while (true) : (while (try dst.toBase(false, cg) or | 183335 | val_to_gpr: while (true) : (while (try dst.toBase(false, cg) or |
| ... | @@ -183337,7 +183342,7 @@ const Temp = struct { | ... | @@ -183337,7 +183342,7 @@ const Temp = struct { |
| 183337 | .undef => if (opts.safe) { | 183342 | .undef => if (opts.safe) { |
| 183338 | var dst_ptr = try cg.tempInit(.usize, dst.tracking(cg).short.address().offset(opts.disp)); | 183343 | var dst_ptr = try cg.tempInit(.usize, dst.tracking(cg).short.address().offset(opts.disp)); |
| 183339 | var pat = try cg.tempInit(.u8, .{ .immediate = 0xaa }); | 183344 | var pat = try cg.tempInit(.u8, .{ .immediate = 0xaa }); |
| 183340 | var len = try cg.tempInit(.usize, .{ .immediate = val_ty.abiSize(cg.pt.zcu) }); | 183345 | var len = try cg.tempInit(.usize, .{ .immediate = val_ty.abiSize(zcu) }); |
| 183341 | try dst_ptr.memset(&pat, &len, cg); | 183346 | try dst_ptr.memset(&pat, &len, cg); |
| 183342 | try dst_ptr.die(cg); | 183347 | try dst_ptr.die(cg); |
| 183343 | try pat.die(cg); | 183348 | try pat.die(cg); |
| ... | @@ -183364,7 +183369,7 @@ const Temp = struct { | ... | @@ -183364,7 +183369,7 @@ const Temp = struct { |
| 183364 | ), | 183369 | ), |
| 183365 | .register => |val_reg| try dst.writeReg(opts.disp, val_ty, registerAlias( | 183370 | .register => |val_reg| try dst.writeReg(opts.disp, val_ty, registerAlias( |
| 183366 | val_reg, | 183371 | val_reg, |
| 183367 | @intCast(val_ty.abiSize(cg.pt.zcu)), | 183372 | @intCast(val_ty.abiSize(zcu)), |
| 183368 | ), cg), | 183373 | ), cg), |
| 183369 | inline .register_pair, | 183374 | inline .register_pair, |
| 183370 | .register_triple, | 183375 | .register_triple, |
| ... | @@ -183373,12 +183378,12 @@ const Temp = struct { | ... | @@ -183373,12 +183378,12 @@ const Temp = struct { |
| 183373 | .register_offset => |val_reg_off| switch (val_reg_off.off) { | 183378 | .register_offset => |val_reg_off| switch (val_reg_off.off) { |
| 183374 | 0 => try dst.writeReg(opts.disp, val_ty, registerAlias( | 183379 | 0 => try dst.writeReg(opts.disp, val_ty, registerAlias( |
| 183375 | val_reg_off.reg, | 183380 | val_reg_off.reg, |
| 183376 | @intCast(val_ty.abiSize(cg.pt.zcu)), | 183381 | @intCast(val_ty.abiSize(zcu)), |
| 183377 | ), cg), | 183382 | ), cg), |
| 183378 | else => continue :val_to_gpr, | 183383 | else => continue :val_to_gpr, |
| 183379 | }, | 183384 | }, |
| 183380 | .register_overflow => |val_reg_ov| { | 183385 | .register_overflow => |val_reg_ov| { |
| 183381 | const ip = &cg.pt.zcu.intern_pool; | 183386 | const ip = &zcu.intern_pool; |
| 183382 | const first_ty: Type = .fromInterned(first_ty: switch (ip.indexToKey(val_ty.toIntern())) { | 183387 | const first_ty: Type = .fromInterned(first_ty: switch (ip.indexToKey(val_ty.toIntern())) { |
| 183383 | .tuple_type => |tuple_type| { | 183388 | .tuple_type => |tuple_type| { |
| 183384 | const tuple_field_types = tuple_type.types.get(ip); | 183389 | const tuple_field_types = tuple_type.types.get(ip); |
| ... | @@ -183386,12 +183391,12 @@ const Temp = struct { | ... | @@ -183386,12 +183391,12 @@ const Temp = struct { |
| 183386 | break :first_ty tuple_field_types[0]; | 183391 | break :first_ty tuple_field_types[0]; |
| 183387 | }, | 183392 | }, |
| 183388 | .opt_type => |opt_child| { | 183393 | .opt_type => |opt_child| { |
| 183389 | assert(!val_ty.optionalReprIsPayload(cg.pt.zcu)); | 183394 | assert(!val_ty.optionalReprIsPayload(zcu)); |
| 183390 | break :first_ty opt_child; | 183395 | break :first_ty opt_child; |
| 183391 | }, | 183396 | }, |
| 183392 | else => std.debug.panic("{s}: {f}\n", .{ @src().fn_name, val_ty.fmt(cg.pt) }), | 183397 | else => std.debug.panic("{s}: {f}\n", .{ @src().fn_name, val_ty.fmt(zcu) }), |
| 183393 | }); | 183398 | }); |
| 183394 | const first_size: u31 = @intCast(first_ty.abiSize(cg.pt.zcu)); | 183399 | const first_size: u31 = @intCast(first_ty.abiSize(zcu)); |
| 183395 | try dst.writeReg(opts.disp, first_ty, registerAlias(val_reg_ov.reg, first_size), cg); | 183400 | try dst.writeReg(opts.disp, first_ty, registerAlias(val_reg_ov.reg, first_size), cg); |
| 183396 | try cg.asmSetccMemory( | 183401 | try cg.asmSetccMemory( |
| 183397 | val_reg_ov.eflags, | 183402 | val_reg_ov.eflags, |
| ... | @@ -183406,7 +183411,7 @@ const Temp = struct { | ... | @@ -183406,7 +183411,7 @@ const Temp = struct { |
| 183406 | var dst_ptr = | 183411 | var dst_ptr = |
| 183407 | try cg.tempInit(.usize, dst.tracking(cg).short.address().offset(opts.disp)); | 183412 | try cg.tempInit(.usize, dst.tracking(cg).short.address().offset(opts.disp)); |
| 183408 | var val_ptr = try cg.tempInit(.usize, val_mcv.address()); | 183413 | var val_ptr = try cg.tempInit(.usize, val_mcv.address()); |
| 183409 | try dst_ptr.memcpy(&val_ptr, val_ty.abiSize(cg.pt.zcu), cg); | 183414 | try dst_ptr.memcpy(&val_ptr, val_ty.abiSize(zcu), cg); |
| 183410 | try dst_ptr.die(cg); | 183415 | try dst_ptr.die(cg); |
| 183411 | try val_ptr.die(cg); | 183416 | try val_ptr.die(cg); |
| 183412 | }, | 183417 | }, |
| ... | @@ -183444,7 +183449,7 @@ const Temp = struct { | ... | @@ -183444,7 +183449,7 @@ const Temp = struct { |
| 183444 | assert(src_regs.len == @divCeil(int_info.bits, 64)); | 183449 | assert(src_regs.len == @divCeil(int_info.bits, 64)); |
| 183445 | break :part_ty .u64; | 183450 | break :part_ty .u64; |
| 183446 | } else part_ty: switch (ip.indexToKey(src_ty.toIntern())) { | 183451 | } else part_ty: switch (ip.indexToKey(src_ty.toIntern())) { |
| 183447 | else => std.debug.panic("{s}: {f}\n", .{ @src().fn_name, src_ty.fmt(cg.pt) }), | 183452 | else => std.debug.panic("{s}: {f}\n", .{ @src().fn_name, src_ty.fmt(zcu) }), |
| 183448 | .ptr_type => |ptr_info| { | 183453 | .ptr_type => |ptr_info| { |
| 183449 | assert(ptr_info.flags.size == .slice); | 183454 | assert(ptr_info.flags.size == .slice); |
| 183450 | assert(src_regs.len == 2); | 183455 | assert(src_regs.len == 2); |
| ... | @@ -183463,7 +183468,7 @@ const Temp = struct { | ... | @@ -183463,7 +183468,7 @@ const Temp = struct { |
| 183463 | }), | 183468 | }), |
| 183464 | }, | 183469 | }, |
| 183465 | .opt_type => |opt_child| switch (ip.indexToKey(opt_child)) { | 183470 | .opt_type => |opt_child| switch (ip.indexToKey(opt_child)) { |
| 183466 | else => std.debug.panic("{s}: {f}\n", .{ @src().fn_name, src_ty.fmt(cg.pt) }), | 183471 | else => std.debug.panic("{s}: {f}\n", .{ @src().fn_name, src_ty.fmt(zcu) }), |
| 183467 | .ptr_type => |ptr_info| { | 183472 | .ptr_type => |ptr_info| { |
| 183468 | assert(ptr_info.flags.size == .slice); | 183473 | assert(ptr_info.flags.size == .slice); |
| 183469 | assert(src_regs.len == 2); | 183474 | assert(src_regs.len == 2); |
| ... | @@ -189637,7 +189642,7 @@ fn resetTemps(cg: *CodeGen, from_index: Temp.Index) InnerError!void { | ... | @@ -189637,7 +189642,7 @@ fn resetTemps(cg: *CodeGen, from_index: Temp.Index) InnerError!void { |
| 189637 | any_valid = true; | 189642 | any_valid = true; |
| 189638 | tracking_log.err("failed to kill {f}: {f}", .{ | 189643 | tracking_log.err("failed to kill {f}: {f}", .{ |
| 189639 | temp.toIndex(), | 189644 | temp.toIndex(), |
| 189640 | cg.temp_type[temp_index].fmt(cg.pt), | 189645 | cg.temp_type[temp_index].fmt(cg.pt.zcu), |
| 189641 | }); | 189646 | }); |
| 189642 | } | 189647 | } |
| 189643 | cg.temp_type[temp_index] = undefined; | 189648 | cg.temp_type[temp_index] = undefined; |
src/crash_report.zig+7-8| ... | @@ -86,21 +86,20 @@ pub const CodegenFunc = if (enabled) struct { | ... | @@ -86,21 +86,20 @@ pub const CodegenFunc = if (enabled) struct { |
| 86 | 86 | ||
| 87 | pub const LinkerOp = if (enabled) struct { | 87 | pub const LinkerOp = if (enabled) struct { |
| 88 | lf: *link.File, | 88 | lf: *link.File, |
| 89 | tid: Zcu.PerThread.Id, | ||
| 90 | threadlocal var current: ?LinkerOp = null; | 89 | threadlocal var current: ?LinkerOp = null; |
| 91 | pub fn start(lf: *link.File, tid: Zcu.PerThread.Id) void { | 90 | pub fn start(lf: *link.File) void { |
| 92 | std.debug.assert(current == null); | 91 | std.debug.assert(current == null); |
| 93 | current = .{ .lf = lf, .tid = tid }; | 92 | current = .{ .lf = lf }; |
| 94 | } | 93 | } |
| 95 | pub fn stop(lf: *link.File, tid: Zcu.PerThread.Id) void { | 94 | pub fn stop(lf: *link.File) void { |
| 96 | std.debug.assert(current.?.lf == lf and current.?.tid == tid); | 95 | std.debug.assert(current.?.lf == lf); |
| 97 | current = null; | 96 | current = null; |
| 98 | } | 97 | } |
| 99 | } else struct { | 98 | } else struct { |
| 100 | const current: ?noreturn = null; | 99 | const current: ?noreturn = null; |
| 101 | // Dummy implementation | 100 | // Dummy implementation |
| 102 | pub fn start(_: *link.File, _: Zcu.PerThread.Id) void {} | 101 | pub fn start(_: *link.File) void {} |
| 103 | pub fn stop(_: *link.File, _: Zcu.PerThread.Id) void {} | 102 | pub fn stop(_: *link.File) void {} |
| 104 | }; | 103 | }; |
| 105 | 104 | ||
| 106 | fn dumpCrashContext() Io.Writer.Error!void { | 105 | fn dumpCrashContext() Io.Writer.Error!void { |
| ... | @@ -132,7 +131,7 @@ fn dumpCrashContext() Io.Writer.Error!void { | ... | @@ -132,7 +131,7 @@ fn dumpCrashContext() Io.Writer.Error!void { |
| 132 | try dumpCrashContextSema(anal, w, &S.crash_heap); | 131 | try dumpCrashContextSema(anal, w, &S.crash_heap); |
| 133 | } else if (LinkerOp.current) |linker_op| { | 132 | } else if (LinkerOp.current) |linker_op| { |
| 134 | try w.writeAll("Linker snapshot:\n"); | 133 | try w.writeAll("Linker snapshot:\n"); |
| 135 | switch (try linker_op.lf.dump(w, linker_op.tid)) { | 134 | switch (try linker_op.lf.dump(w)) { |
| 136 | .unimplemented => try w.writeAll("(backend does not support link snapshots)"), | 135 | .unimplemented => try w.writeAll("(backend does not support link snapshots)"), |
| 137 | .needs_extensions => try w.writeAll("(build with -Ddebug-extensions to dump linker state)"), | 136 | .needs_extensions => try w.writeAll("(build with -Ddebug-extensions to dump linker state)"), |
| 138 | .disabled => try w.writeAll("(run with --debug-link-snapshot to dump linker state)"), | 137 | .disabled => try w.writeAll("(run with --debug-link-snapshot to dump linker state)"), |
src/link.zig+10-10| ... | @@ -950,12 +950,12 @@ pub const File = struct { | ... | @@ -950,12 +950,12 @@ pub const File = struct { |
| 950 | } | 950 | } |
| 951 | } | 951 | } |
| 952 | 952 | ||
| 953 | pub fn idle(base: *File, tid: Zcu.PerThread.Id) Error!bool { | 953 | fn idle(base: *File) Error!bool { |
| 954 | switch (base.tag) { | 954 | switch (base.tag) { |
| 955 | else => return false, | 955 | else => return false, |
| 956 | inline .elf2, .coff, .macho2 => |tag| { | 956 | inline .elf2, .coff, .macho2 => |tag| { |
| 957 | dev.check(tag.devFeature()); | 957 | dev.check(tag.devFeature()); |
| 958 | return @as(*tag.Type(), @fieldParentPtr("base", base)).idle(tid); | 958 | return @as(*tag.Type(), @fieldParentPtr("base", base)).idle(); |
| 959 | }, | 959 | }, |
| 960 | } | 960 | } |
| 961 | } | 961 | } |
| ... | @@ -974,8 +974,8 @@ pub const File = struct { | ... | @@ -974,8 +974,8 @@ pub const File = struct { |
| 974 | /// Commit pending changes and write headers. Takes into account final output mode. | 974 | /// Commit pending changes and write headers. Takes into account final output mode. |
| 975 | /// `arena` has the lifetime of the call to `Compilation.update`. | 975 | /// `arena` has the lifetime of the call to `Compilation.update`. |
| 976 | pub fn flush(base: *File, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: std.Progress.Node) Error!void { | 976 | pub fn flush(base: *File, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: std.Progress.Node) Error!void { |
| 977 | crash_report.LinkerOp.start(base, tid); | 977 | crash_report.LinkerOp.start(base); |
| 978 | defer crash_report.LinkerOp.stop(base, tid); | 978 | defer crash_report.LinkerOp.stop(base); |
| 979 | 979 | ||
| 980 | const comp = base.comp; | 980 | const comp = base.comp; |
| 981 | const io = comp.io; | 981 | const io = comp.io; |
| ... | @@ -1026,8 +1026,8 @@ pub const File = struct { | ... | @@ -1026,8 +1026,8 @@ pub const File = struct { |
| 1026 | ) Error!void { | 1026 | ) Error!void { |
| 1027 | assert(pt.zcu.llvm_object == null); | 1027 | assert(pt.zcu.llvm_object == null); |
| 1028 | 1028 | ||
| 1029 | crash_report.LinkerOp.start(base, pt.tid); | 1029 | crash_report.LinkerOp.start(base); |
| 1030 | defer crash_report.LinkerOp.stop(base, pt.tid); | 1030 | defer crash_report.LinkerOp.stop(base); |
| 1031 | 1031 | ||
| 1032 | switch (base.tag) { | 1032 | switch (base.tag) { |
| 1033 | .lld => unreachable, | 1033 | .lld => unreachable, |
| ... | @@ -1115,7 +1115,7 @@ pub const File = struct { | ... | @@ -1115,7 +1115,7 @@ pub const File = struct { |
| 1115 | enabled, | 1115 | enabled, |
| 1116 | }; | 1116 | }; |
| 1117 | 1117 | ||
| 1118 | pub fn dump(base: *File, w: *Io.Writer, tid: Zcu.PerThread.Id) !DumpResult { | 1118 | pub fn dump(base: *File, w: *Io.Writer) !DumpResult { |
| 1119 | if (!build_options.enable_debug_extensions) return .not_built; | 1119 | if (!build_options.enable_debug_extensions) return .not_built; |
| 1120 | switch (base.tag) { | 1120 | switch (base.tag) { |
| 1121 | .elf, | 1121 | .elf, |
| ... | @@ -1129,7 +1129,7 @@ pub const File = struct { | ... | @@ -1129,7 +1129,7 @@ pub const File = struct { |
| 1129 | => return .unimplemented, | 1129 | => return .unimplemented, |
| 1130 | inline else => |tag| { | 1130 | inline else => |tag| { |
| 1131 | dev.check(tag.devFeature()); | 1131 | dev.check(tag.devFeature()); |
| 1132 | return @as(*tag.Type(), @fieldParentPtr("base", base)).dump(w, tid); | 1132 | return @as(*tag.Type(), @fieldParentPtr("base", base)).dump(w); |
| 1133 | }, | 1133 | }, |
| 1134 | } | 1134 | } |
| 1135 | } | 1135 | } |
| ... | @@ -1910,8 +1910,8 @@ pub fn doZcuTask(comp: *Compilation, tid: Zcu.PerThread.Id, task: ZcuTask) void | ... | @@ -1910,8 +1910,8 @@ pub fn doZcuTask(comp: *Compilation, tid: Zcu.PerThread.Id, task: ZcuTask) void |
| 1910 | } | 1910 | } |
| 1911 | } | 1911 | } |
| 1912 | } | 1912 | } |
| 1913 | pub fn doIdleTask(comp: *Compilation, tid: Zcu.PerThread.Id) Error!bool { | 1913 | pub fn doIdleTask(comp: *Compilation) Error!bool { |
| 1914 | return if (comp.bin_file) |lf| lf.idle(tid) else false; | 1914 | return if (comp.bin_file) |lf| lf.idle() else false; |
| 1915 | } | 1915 | } |
| 1916 | /// After the main pipeline is done, but before flush, the compilation may need to link one final | 1916 | /// After the main pipeline is done, but before flush, the compilation may need to link one final |
| 1917 | /// `Nav` into the binary: the `builtin.test_functions` value. Since the link thread isn't running | 1917 | /// `Nav` into the binary: the `builtin.test_functions` value. Since the link thread isn't running |
src/link/Coff.zig+33-51| ... | @@ -5766,7 +5766,7 @@ fn flushImplib( | ... | @@ -5766,7 +5766,7 @@ fn flushImplib( |
| 5766 | try file_writer.interface.flush(); | 5766 | try file_writer.interface.flush(); |
| 5767 | } | 5767 | } |
| 5768 | 5768 | ||
| 5769 | fn reportUndefs(coff: *Coff, tid: Zcu.PerThread.Id) !void { | 5769 | fn reportUndefs(coff: *Coff) !void { |
| 5770 | const comp = coff.base.comp; | 5770 | const comp = coff.base.comp; |
| 5771 | const gpa = comp.gpa; | 5771 | const gpa = comp.gpa; |
| 5772 | const max_notes = 4; | 5772 | const max_notes = 4; |
| ... | @@ -5887,14 +5887,8 @@ fn reportUndefs(coff: *Coff, tid: Zcu.PerThread.Id) !void { | ... | @@ -5887,14 +5887,8 @@ fn reportUndefs(coff: *Coff, tid: Zcu.PerThread.Id) !void { |
| 5887 | const ip = &comp.zcu.?.intern_pool; | 5887 | const ip = &comp.zcu.?.intern_pool; |
| 5888 | break :format ip.getNav(val.navIndex(coff)).fqn.fmt(ip); | 5888 | break :format ip.getNav(val.navIndex(coff)).fqn.fmt(ip); |
| 5889 | }, | 5889 | }, |
| 5890 | .uav => Value.fromInterned(val.uavValue(coff)).fmtValue(.{ | 5890 | .uav => Value.fromInterned(val.uavValue(coff)).fmtValue(coff.base.comp.zcu.?), |
| 5891 | .zcu = coff.base.comp.zcu.?, | 5891 | inline .lazy_code, .lazy_const_data => Type.fromInterned(val.lazySymbol(coff).ty).fmt(coff.base.comp.zcu.?), |
| 5892 | .tid = tid, | ||
| 5893 | }), | ||
| 5894 | inline .lazy_code, .lazy_const_data => Type.fromInterned(val.lazySymbol(coff).ty).fmt(.{ | ||
| 5895 | .zcu = coff.base.comp.zcu.?, | ||
| 5896 | .tid = tid, | ||
| 5897 | }), | ||
| 5898 | else => unreachable, | 5892 | else => unreachable, |
| 5899 | }, | 5893 | }, |
| 5900 | }); | 5894 | }); |
| ... | @@ -5922,13 +5916,14 @@ pub fn flush( | ... | @@ -5922,13 +5916,14 @@ pub fn flush( |
| 5922 | prog_node: std.Progress.Node, | 5916 | prog_node: std.Progress.Node, |
| 5923 | ) link.Error!void { | 5917 | ) link.Error!void { |
| 5924 | _ = arena; | 5918 | _ = arena; |
| 5919 | _ = tid; | ||
| 5925 | const sub_prog_node = prog_node.start("COFF Flush", 0); | 5920 | const sub_prog_node = prog_node.start("COFF Flush", 0); |
| 5926 | defer sub_prog_node.end(); | 5921 | defer sub_prog_node.end(); |
| 5927 | 5922 | ||
| 5928 | const comp = coff.base.comp; | 5923 | const comp = coff.base.comp; |
| 5929 | 5924 | ||
| 5930 | while (try coff.resolve(tid)) {} | 5925 | while (try coff.resolve()) {} |
| 5931 | while (try coff.idle(tid)) {} | 5926 | while (try coff.idle()) {} |
| 5932 | 5927 | ||
| 5933 | // This has to occur after all other flushMoved / flushResized have resolved, | 5928 | // This has to occur after all other flushMoved / flushResized have resolved, |
| 5934 | // but it will also generate one more set of resizes and moves. | 5929 | // but it will also generate one more set of resizes and moves. |
| ... | @@ -5948,10 +5943,10 @@ pub fn flush( | ... | @@ -5948,10 +5943,10 @@ pub fn flush( |
| 5948 | ), | 5943 | ), |
| 5949 | }; | 5944 | }; |
| 5950 | } | 5945 | } |
| 5951 | while (try coff.idle(tid)) {} | 5946 | while (try coff.idle()) {} |
| 5952 | 5947 | ||
| 5953 | if (coff.isImage()) | 5948 | if (coff.isImage()) |
| 5954 | try coff.reportUndefs(tid); | 5949 | try coff.reportUndefs(); |
| 5955 | 5950 | ||
| 5956 | if (comp.emit_implib) |implib_file| | 5951 | if (comp.emit_implib) |implib_file| |
| 5957 | coff.flushImplib(implib_file) catch |err| | 5952 | coff.flushImplib(implib_file) catch |err| |
| ... | @@ -5963,14 +5958,14 @@ pub fn flush( | ... | @@ -5963,14 +5958,14 @@ pub fn flush( |
| 5963 | }; | 5958 | }; |
| 5964 | 5959 | ||
| 5965 | if (coff.options.enable_link_snapshots) | 5960 | if (coff.options.enable_link_snapshots) |
| 5966 | coff.dumpStderr(tid) catch |err| | 5961 | coff.dumpStderr() catch |err| |
| 5967 | return comp.link_diags.fail("dumping link snapshot failed: {t}", .{err}); | 5962 | return comp.link_diags.fail("dumping link snapshot failed: {t}", .{err}); |
| 5968 | } | 5963 | } |
| 5969 | 5964 | ||
| 5970 | /// Runs a single "resolution" task. | 5965 | /// Runs a single "resolution" task. |
| 5971 | /// These are tasks that need to modify the node structure in some way. | 5966 | /// These are tasks that need to modify the node structure in some way. |
| 5972 | /// They must run in a defined order with respect to linker tasks. | 5967 | /// They must run in a defined order with respect to linker tasks. |
| 5973 | fn resolve(coff: *Coff, tid: Zcu.PerThread.Id) !bool { | 5968 | fn resolve(coff: *Coff) !bool { |
| 5974 | const comp = coff.base.comp; | 5969 | const comp = coff.base.comp; |
| 5975 | task: { | 5970 | task: { |
| 5976 | while (coff.section_merge_pending_index < coff.section_merges.count()) { | 5971 | while (coff.section_merge_pending_index < coff.section_merges.count()) { |
| ... | @@ -6046,7 +6041,6 @@ fn resolve(coff: *Coff, tid: Zcu.PerThread.Id) !bool { | ... | @@ -6046,7 +6041,6 @@ fn resolve(coff: *Coff, tid: Zcu.PerThread.Id) !bool { |
| 6046 | const si = coff.symbol_table.symbols.keys()[coff.symbol_table.pending_symbol_index]; | 6041 | const si = coff.symbol_table.symbols.keys()[coff.symbol_table.pending_symbol_index]; |
| 6047 | const sym = si.get(coff); | 6042 | const sym = si.get(coff); |
| 6048 | const sub_prog_node = coff.idleProgNode( | 6043 | const sub_prog_node = coff.idleProgNode( |
| 6049 | tid, | ||
| 6050 | coff.symbol_prog_node, | 6044 | coff.symbol_prog_node, |
| 6051 | if (sym.ni.unwrap()) |sym_ni| | 6045 | if (sym.ni.unwrap()) |sym_ni| |
| 6052 | coff.getNode(sym_ni) | 6046 | coff.getNode(sym_ni) |
| ... | @@ -6076,7 +6070,7 @@ fn resolve(coff: *Coff, tid: Zcu.PerThread.Id) !bool { | ... | @@ -6076,7 +6070,7 @@ fn resolve(coff: *Coff, tid: Zcu.PerThread.Id) !bool { |
| 6076 | return false; | 6070 | return false; |
| 6077 | } | 6071 | } |
| 6078 | 6072 | ||
| 6079 | pub fn idle(coff: *Coff, tid: Zcu.PerThread.Id) !bool { | 6073 | pub fn idle(coff: *Coff) !bool { |
| 6080 | // Idle tasks should not modify create / modify nodes, otherwise the output is not reproducible. | 6074 | // Idle tasks should not modify create / modify nodes, otherwise the output is not reproducible. |
| 6081 | coff.mf.nodes_lock.lock(); | 6075 | coff.mf.nodes_lock.lock(); |
| 6082 | defer coff.mf.nodes_lock.unlock(); | 6076 | defer coff.mf.nodes_lock.unlock(); |
| ... | @@ -6087,7 +6081,7 @@ pub fn idle(coff: *Coff, tid: Zcu.PerThread.Id) !bool { | ... | @@ -6087,7 +6081,7 @@ pub fn idle(coff: *Coff, tid: Zcu.PerThread.Id) !bool { |
| 6087 | if (coff.input_section_pending_index < coff.input_sections.items.len) { | 6081 | if (coff.input_section_pending_index < coff.input_sections.items.len) { |
| 6088 | const isi: Node.InputSection.Index = @fromBackingInt(@intCast(coff.input_section_pending_index)); | 6082 | const isi: Node.InputSection.Index = @fromBackingInt(@intCast(coff.input_section_pending_index)); |
| 6089 | coff.input_section_pending_index += 1; | 6083 | coff.input_section_pending_index += 1; |
| 6090 | const sub_prog_node = coff.idleProgNode(tid, coff.input_prog_node, coff.getNode(isi.symbol(coff).node(coff))); | 6084 | const sub_prog_node = coff.idleProgNode(coff.input_prog_node, coff.getNode(isi.symbol(coff).node(coff))); |
| 6091 | defer sub_prog_node.end(); | 6085 | defer sub_prog_node.end(); |
| 6092 | coff.flushInputSection(isi) catch |err| switch (err) { | 6086 | coff.flushInputSection(isi) catch |err| switch (err) { |
| 6093 | else => |e| { | 6087 | else => |e| { |
| ... | @@ -6112,7 +6106,7 @@ pub fn idle(coff: *Coff, tid: Zcu.PerThread.Id) !bool { | ... | @@ -6112,7 +6106,7 @@ pub fn idle(coff: *Coff, tid: Zcu.PerThread.Id) !bool { |
| 6112 | const clean_next_moved = ni.cleanNextMoved(&coff.mf); | 6106 | const clean_next_moved = ni.cleanNextMoved(&coff.mf); |
| 6113 | if (!clean_moved and !clean_resized and !clean_next_moved) continue; | 6107 | if (!clean_moved and !clean_resized and !clean_next_moved) continue; |
| 6114 | const sub_prog_node = | 6108 | const sub_prog_node = |
| 6115 | coff.idleProgNode(tid, coff.mf.update_prog_node, coff.getNode(ni)); | 6109 | coff.idleProgNode(coff.mf.update_prog_node, coff.getNode(ni)); |
| 6116 | defer sub_prog_node.end(); | 6110 | defer sub_prog_node.end(); |
| 6117 | if (clean_moved) try coff.flushMoved(ni); | 6111 | if (clean_moved) try coff.flushMoved(ni); |
| 6118 | if (clean_resized) try coff.flushResized(ni); | 6112 | if (clean_resized) try coff.flushResized(ni); |
| ... | @@ -6120,7 +6114,6 @@ pub fn idle(coff: *Coff, tid: Zcu.PerThread.Id) !bool { | ... | @@ -6120,7 +6114,6 @@ pub fn idle(coff: *Coff, tid: Zcu.PerThread.Id) !bool { |
| 6120 | } | 6114 | } |
| 6121 | while (coff.pending_members.pop()) |pending_mi| { | 6115 | while (coff.pending_members.pop()) |pending_mi| { |
| 6122 | const sub_prog_node = coff.idleProgNode( | 6116 | const sub_prog_node = coff.idleProgNode( |
| 6123 | tid, | ||
| 6124 | coff.symbol_prog_node, | 6117 | coff.symbol_prog_node, |
| 6125 | coff.getNode(pending_mi.key.get(coff).content_ni), | 6118 | coff.getNode(pending_mi.key.get(coff).content_ni), |
| 6126 | ); | 6119 | ); |
| ... | @@ -6131,7 +6124,6 @@ pub fn idle(coff: *Coff, tid: Zcu.PerThread.Id) !bool { | ... | @@ -6131,7 +6124,6 @@ pub fn idle(coff: *Coff, tid: Zcu.PerThread.Id) !bool { |
| 6131 | if (coff.exports_complete and coff.export_table.pending_sort) { | 6124 | if (coff.exports_complete and coff.export_table.pending_sort) { |
| 6132 | defer coff.export_table.pending_sort = false; | 6125 | defer coff.export_table.pending_sort = false; |
| 6133 | const sub_prog_node = coff.idleProgNode( | 6126 | const sub_prog_node = coff.idleProgNode( |
| 6134 | tid, | ||
| 6135 | coff.synth_prog_node, | 6127 | coff.synth_prog_node, |
| 6136 | coff.getNode(coff.export_table.ni), | 6128 | coff.getNode(coff.export_table.ni), |
| 6137 | ); | 6129 | ); |
| ... | @@ -6150,7 +6142,6 @@ pub fn idle(coff: *Coff, tid: Zcu.PerThread.Id) !bool { | ... | @@ -6150,7 +6142,6 @@ pub fn idle(coff: *Coff, tid: Zcu.PerThread.Id) !bool { |
| 6150 | 6142 | ||
| 6151 | fn idleProgNode( | 6143 | fn idleProgNode( |
| 6152 | coff: *Coff, | 6144 | coff: *Coff, |
| 6153 | tid: Zcu.PerThread.Id, | ||
| 6154 | prog_node: std.Progress.Node, | 6145 | prog_node: std.Progress.Node, |
| 6155 | node: Node, | 6146 | node: Node, |
| 6156 | ) std.Progress.Node { | 6147 | ) std.Progress.Node { |
| ... | @@ -6173,10 +6164,7 @@ fn idleProgNode( | ... | @@ -6173,10 +6164,7 @@ fn idleProgNode( |
| 6173 | break :name ip.getNav(nmi.navIndex(coff)).fqn.toSlice(ip); | 6164 | break :name ip.getNav(nmi.navIndex(coff)).fqn.toSlice(ip); |
| 6174 | }, | 6165 | }, |
| 6175 | .uav => |umi| std.mem.print(&name, "{f}", .{ | 6166 | .uav => |umi| std.mem.print(&name, "{f}", .{ |
| 6176 | Value.fromInterned(umi.uavValue(coff)).fmtValue(.{ | 6167 | Value.fromInterned(umi.uavValue(coff)).fmtValue(coff.base.comp.zcu.?), |
| 6177 | .zcu = coff.base.comp.zcu.?, | ||
| 6178 | .tid = tid, | ||
| 6179 | }), | ||
| 6180 | }) catch &name, | 6168 | }) catch &name, |
| 6181 | .archive_member => |mi| &mi.get(coff).headerPtr(coff).name, | 6169 | .archive_member => |mi| &mi.get(coff).headerPtr(coff).name, |
| 6182 | }, 0); | 6170 | }, 0); |
| ... | @@ -6185,7 +6173,7 @@ fn idleProgNode( | ... | @@ -6185,7 +6173,7 @@ fn idleProgNode( |
| 6185 | fn genPending(coff: *Coff, pt: Zcu.PerThread) Error!void { | 6173 | fn genPending(coff: *Coff, pt: Zcu.PerThread) Error!void { |
| 6186 | const comp = pt.zcu.comp; | 6174 | const comp = pt.zcu.comp; |
| 6187 | while (coff.pending_uavs.pop()) |pending_uav| { | 6175 | while (coff.pending_uavs.pop()) |pending_uav| { |
| 6188 | const sub_prog_node = coff.idleProgNode(pt.tid, coff.const_prog_node, .{ .uav = pending_uav.key }); | 6176 | const sub_prog_node = coff.idleProgNode(coff.const_prog_node, .{ .uav = pending_uav.key }); |
| 6189 | defer sub_prog_node.end(); | 6177 | defer sub_prog_node.end(); |
| 6190 | coff.genUav(pt, pending_uav.key, pending_uav.value.alignment) catch |err| switch (err) { | 6178 | coff.genUav(pt, pending_uav.key, pending_uav.value.alignment) catch |err| switch (err) { |
| 6191 | else => |e| return e, | 6179 | else => |e| return e, |
| ... | @@ -6845,7 +6833,7 @@ fn genLazy(coff: *Coff, pt: Zcu.PerThread, lmr: Node.LazyMapRef) !void { | ... | @@ -6845,7 +6833,7 @@ fn genLazy(coff: *Coff, pt: Zcu.PerThread, lmr: Node.LazyMapRef) !void { |
| 6845 | const sub_prog_node = coff.synth_prog_node.start( | 6833 | const sub_prog_node = coff.synth_prog_node.start( |
| 6846 | std.mem.print(&name, "lazy {s} for {f}", .{ | 6834 | std.mem.print(&name, "lazy {s} for {f}", .{ |
| 6847 | kind, | 6835 | kind, |
| 6848 | Type.fromInterned(lazy.ty).fmt(pt), | 6836 | Type.fromInterned(lazy.ty).fmt(coff.base.comp.zcu.?), |
| 6849 | }) catch &name, | 6837 | }) catch &name, |
| 6850 | 0, | 6838 | 0, |
| 6851 | ); | 6839 | ); |
| ... | @@ -7461,15 +7449,15 @@ fn updateExportInner( | ... | @@ -7461,15 +7449,15 @@ fn updateExportInner( |
| 7461 | switch (exp.exported) { | 7449 | switch (exp.exported) { |
| 7462 | .nav => |nav| log.debug("updateExports({f}) = {d}", .{ ip.getNav(nav).fqn.fmt(ip), exported_si }), | 7450 | .nav => |nav| log.debug("updateExports({f}) = {d}", .{ ip.getNav(nav).fqn.fmt(ip), exported_si }), |
| 7463 | .uav => |uav| log.debug("updateExports(@as({f}, {f})) = {d}", .{ | 7451 | .uav => |uav| log.debug("updateExports(@as({f}, {f})) = {d}", .{ |
| 7464 | Type.fromInterned(ip.typeOf(uav)).fmt(pt), | 7452 | Type.fromInterned(ip.typeOf(uav)).fmt(zcu), |
| 7465 | Value.fromInterned(uav).fmtValue(pt), | 7453 | Value.fromInterned(uav).fmtValue(zcu), |
| 7466 | exported_si, | 7454 | exported_si, |
| 7467 | }), | 7455 | }), |
| 7468 | } | 7456 | } |
| 7469 | 7457 | ||
| 7470 | try coff.genPending(pt); | 7458 | try coff.genPending(pt); |
| 7471 | while (try coff.resolve(pt.tid)) {} | 7459 | while (try coff.resolve()) {} |
| 7472 | while (try coff.idle(pt.tid)) {} | 7460 | while (try coff.idle()) {} |
| 7473 | 7461 | ||
| 7474 | const machine = coff.targetLoad(&coff.headerPtr().machine); | 7462 | const machine = coff.targetLoad(&coff.headerPtr().machine); |
| 7475 | const exported_ni = exported_si.node(coff); | 7463 | const exported_ni = exported_si.node(coff); |
| ... | @@ -7607,27 +7595,27 @@ fn updateExportInner( | ... | @@ -7607,27 +7595,27 @@ fn updateExportInner( |
| 7607 | } | 7595 | } |
| 7608 | } | 7596 | } |
| 7609 | 7597 | ||
| 7610 | fn dumpStderr(coff: *Coff, tid: Zcu.PerThread.Id) Io.File.Writer.Error!void { | 7598 | fn dumpStderr(coff: *Coff) Io.File.Writer.Error!void { |
| 7611 | const comp = coff.base.comp; | 7599 | const comp = coff.base.comp; |
| 7612 | const io = comp.io; | 7600 | const io = comp.io; |
| 7613 | var buffer: [512]u8 = undefined; | 7601 | var buffer: [512]u8 = undefined; |
| 7614 | const stderr = try io.lockStderr(&buffer, null); | 7602 | const stderr = try io.lockStderr(&buffer, null); |
| 7615 | defer io.unlockStderr(); | 7603 | defer io.unlockStderr(); |
| 7616 | const w = &stderr.file_writer.interface; | 7604 | const w = &stderr.file_writer.interface; |
| 7617 | _ = coff.dump(w, tid) catch |err| switch (err) { | 7605 | _ = coff.dump(w) catch |err| switch (err) { |
| 7618 | error.WriteFailed => return stderr.file_writer.err.?, | 7606 | error.WriteFailed => return stderr.file_writer.err.?, |
| 7619 | }; | 7607 | }; |
| 7620 | } | 7608 | } |
| 7621 | 7609 | ||
| 7622 | pub fn dump(coff: *Coff, w: *Io.Writer, tid: Zcu.PerThread.Id) Io.Writer.Error!link.File.DumpResult { | 7610 | pub fn dump(coff: *Coff, w: *Io.Writer) Io.Writer.Error!link.File.DumpResult { |
| 7623 | if (coff.options.enable_link_snapshots) { | 7611 | if (coff.options.enable_link_snapshots) { |
| 7624 | try coff.printNode(tid, w, .root, 0); | 7612 | try coff.printNode(w, .root, 0); |
| 7625 | try w.writeAll("Section table:\n"); | 7613 | try w.writeAll("Section table:\n"); |
| 7626 | for (coff.section_table.keys(), coff.section_table.values()) |name, sec| | 7614 | for (coff.section_table.keys(), coff.section_table.values()) |name, sec| |
| 7627 | try coff.printSection(w, name, sec.si); | 7615 | try coff.printSection(w, name, sec.si); |
| 7628 | try w.writeAll("Symbol table:\n"); | 7616 | try w.writeAll("Symbol table:\n"); |
| 7629 | for (1..coff.symbols.items.len) |si| | 7617 | for (1..coff.symbols.items.len) |si| |
| 7630 | try coff.printSymbol(w, tid, @fromBackingInt(@intCast(si))); | 7618 | try coff.printSymbol(w, @fromBackingInt(@intCast(si))); |
| 7631 | 7619 | ||
| 7632 | return .enabled; | 7620 | return .enabled; |
| 7633 | } | 7621 | } |
| ... | @@ -7648,7 +7636,6 @@ fn printSection(coff: *Coff, w: *Io.Writer, name: String, si: Symbol.Index) Io.W | ... | @@ -7648,7 +7636,6 @@ fn printSection(coff: *Coff, w: *Io.Writer, name: String, si: Symbol.Index) Io.W |
| 7648 | fn printSymbol( | 7636 | fn printSymbol( |
| 7649 | coff: *Coff, | 7637 | coff: *Coff, |
| 7650 | w: *Io.Writer, | 7638 | w: *Io.Writer, |
| 7651 | tid: Zcu.PerThread.Id, | ||
| 7652 | si: Symbol.Index, | 7639 | si: Symbol.Index, |
| 7653 | ) Io.Writer.Error!void { | 7640 | ) Io.Writer.Error!void { |
| 7654 | const sym = si.get(coff); | 7641 | const sym = si.get(coff); |
| ... | @@ -7687,7 +7674,7 @@ fn printSymbol( | ... | @@ -7687,7 +7674,7 @@ fn printSymbol( |
| 7687 | try w.print("G {f}\n", .{fmtGlobalName(coff, sym.gmi)}); | 7674 | try w.print("G {f}\n", .{fmtGlobalName(coff, sym.gmi)}); |
| 7688 | } else { | 7675 | } else { |
| 7689 | try w.writeAll("| "); | 7676 | try w.writeAll("| "); |
| 7690 | try coff.printNodeName(w, tid, coff.getNode(sym.ni.unwrap().?)); | 7677 | try coff.printNodeName(w, coff.getNode(sym.ni.unwrap().?)); |
| 7691 | if (sym.flags.extra_tag == .isli) | 7678 | if (sym.flags.extra_tag == .isli) |
| 7692 | try w.print(" | {s}", .{sym.extra.isli.name(coff).toSlice(coff)}); | 7679 | try w.print(" | {s}", .{sym.extra.isli.name(coff).toSlice(coff)}); |
| 7693 | try w.writeByte('\n'); | 7680 | try w.writeByte('\n'); |
| ... | @@ -7712,7 +7699,6 @@ fn globalNameEscape(data: FmtGlobalName, w: *std.Io.Writer) std.Io.Writer.Error! | ... | @@ -7712,7 +7699,6 @@ fn globalNameEscape(data: FmtGlobalName, w: *std.Io.Writer) std.Io.Writer.Error! |
| 7712 | fn printNodeName( | 7699 | fn printNodeName( |
| 7713 | coff: *Coff, | 7700 | coff: *Coff, |
| 7714 | w: *std.Io.Writer, | 7701 | w: *std.Io.Writer, |
| 7715 | tid: Zcu.PerThread.Id, | ||
| 7716 | node: Node, | 7702 | node: Node, |
| 7717 | ) Io.Writer.Error!void { | 7703 | ) Io.Writer.Error!void { |
| 7718 | switch (node) { | 7704 | switch (node) { |
| ... | @@ -7754,7 +7740,7 @@ fn printNodeName( | ... | @@ -7754,7 +7740,7 @@ fn printNodeName( |
| 7754 | const ip = &zcu.intern_pool; | 7740 | const ip = &zcu.intern_pool; |
| 7755 | const nav = ip.getNav(nmi.navIndex(coff)); | 7741 | const nav = ip.getNav(nmi.navIndex(coff)); |
| 7756 | try w.print("({f}, {f})", .{ | 7742 | try w.print("({f}, {f})", .{ |
| 7757 | Type.fromInterned(ip.typeOf(nav.resolved.?.value)).fmt(.{ .zcu = zcu, .tid = tid }), | 7743 | Type.fromInterned(ip.typeOf(nav.resolved.?.value)).fmt(zcu), |
| 7758 | nav.fqn.fmt(ip), | 7744 | nav.fqn.fmt(ip), |
| 7759 | }); | 7745 | }); |
| 7760 | }, | 7746 | }, |
| ... | @@ -7762,15 +7748,12 @@ fn printNodeName( | ... | @@ -7762,15 +7748,12 @@ fn printNodeName( |
| 7762 | const zcu = coff.base.comp.zcu.?; | 7748 | const zcu = coff.base.comp.zcu.?; |
| 7763 | const val: Value = .fromInterned(umi.uavValue(coff)); | 7749 | const val: Value = .fromInterned(umi.uavValue(coff)); |
| 7764 | try w.print("({f}, {f})", .{ | 7750 | try w.print("({f}, {f})", .{ |
| 7765 | val.typeOf(zcu).fmt(.{ .zcu = zcu, .tid = tid }), | 7751 | val.typeOf(zcu).fmt(zcu), |
| 7766 | val.fmtValue(.{ .zcu = zcu, .tid = tid }), | 7752 | val.fmtValue(zcu), |
| 7767 | }); | 7753 | }); |
| 7768 | }, | 7754 | }, |
| 7769 | inline .lazy_code, .lazy_const_data => |lmi| try w.print("({f})", .{ | 7755 | inline .lazy_code, .lazy_const_data => |lmi| try w.print("({f})", .{ |
| 7770 | Type.fromInterned(lmi.lazySymbol(coff).ty).fmt(.{ | 7756 | Type.fromInterned(lmi.lazySymbol(coff).ty).fmt(coff.base.comp.zcu.?), |
| 7771 | .zcu = coff.base.comp.zcu.?, | ||
| 7772 | .tid = tid, | ||
| 7773 | }), | ||
| 7774 | }), | 7757 | }), |
| 7775 | .builtin => |si| { | 7758 | .builtin => |si| { |
| 7776 | const sym = si.get(coff); | 7759 | const sym = si.get(coff); |
| ... | @@ -7779,9 +7762,8 @@ fn printNodeName( | ... | @@ -7779,9 +7762,8 @@ fn printNodeName( |
| 7779 | } | 7762 | } |
| 7780 | } | 7763 | } |
| 7781 | 7764 | ||
| 7782 | pub fn printNode( | 7765 | fn printNode( |
| 7783 | coff: *Coff, | 7766 | coff: *Coff, |
| 7784 | tid: Zcu.PerThread.Id, | ||
| 7785 | w: *Io.Writer, | 7767 | w: *Io.Writer, |
| 7786 | ni: MappedFile.Node.Index, | 7768 | ni: MappedFile.Node.Index, |
| 7787 | indent: usize, | 7769 | indent: usize, |
| ... | @@ -7789,7 +7771,7 @@ pub fn printNode( | ... | @@ -7789,7 +7771,7 @@ pub fn printNode( |
| 7789 | const node = coff.getNode(ni); | 7771 | const node = coff.getNode(ni); |
| 7790 | try w.splatByteAll(' ', indent); | 7772 | try w.splatByteAll(' ', indent); |
| 7791 | try w.writeAll(@tagName(node)); | 7773 | try w.writeAll(@tagName(node)); |
| 7792 | try coff.printNodeName(w, tid, node); | 7774 | try coff.printNodeName(w, node); |
| 7793 | { | 7775 | { |
| 7794 | const mf_node = &coff.mf.nodes.items[@backingInt(ni)]; | 7776 | const mf_node = &coff.mf.nodes.items[@backingInt(ni)]; |
| 7795 | const off, const size = mf_node.location().resolve(&coff.mf); | 7777 | const off, const size = mf_node.location().resolve(&coff.mf); |
| ... | @@ -7809,7 +7791,7 @@ pub fn printNode( | ... | @@ -7809,7 +7791,7 @@ pub fn printNode( |
| 7809 | // non-leaf, just print children | 7791 | // non-leaf, just print children |
| 7810 | var child_ni = first_ni; | 7792 | var child_ni = first_ni; |
| 7811 | while (true) { | 7793 | while (true) { |
| 7812 | try coff.printNode(tid, w, child_ni, indent + 1); | 7794 | try coff.printNode(w, child_ni, indent + 1); |
| 7813 | child_ni = child_ni.next(&coff.mf).unwrap() orelse break; | 7795 | child_ni = child_ni.next(&coff.mf).unwrap() orelse break; |
| 7814 | } | 7796 | } |
| 7815 | return; | 7797 | return; |
src/link/Dwarf.zig+24-23| ... | @@ -1036,7 +1036,7 @@ const Entry = struct { | ... | @@ -1036,7 +1036,7 @@ const Entry = struct { |
| 1036 | const val_unit, const val_entry = unit_and_entry; | 1036 | const val_unit, const val_entry = unit_and_entry; |
| 1037 | if (sec.getUnit(val_unit) == unit and unit.getEntry(val_entry) == entry) | 1037 | if (sec.getUnit(val_unit) == unit and unit.getEntry(val_entry) == entry) |
| 1038 | log.err("missing Value({f}({d}))", .{ | 1038 | log.err("missing Value({f}({d}))", .{ |
| 1039 | Value.fromInterned(val).fmtValue(.{ .tid = .main, .zcu = zcu }), | 1039 | Value.fromInterned(val).fmtValue(zcu), |
| 1040 | @backingInt(val), | 1040 | @backingInt(val), |
| 1041 | }); | 1041 | }); |
| 1042 | } | 1042 | } |
| ... | @@ -2120,9 +2120,10 @@ pub const WipNav = struct { | ... | @@ -2120,9 +2120,10 @@ pub const WipNav = struct { |
| 2120 | wip_nav: *WipNav, | 2120 | wip_nav: *WipNav, |
| 2121 | val: Value, | 2121 | val: Value, |
| 2122 | ) (UpdateError || Writer.Error)!void { | 2122 | ) (UpdateError || Writer.Error)!void { |
| 2123 | const ty = val.typeOf(wip_nav.pt.zcu); | 2123 | const zcu = wip_nav.pt.zcu; |
| 2124 | const ty = val.typeOf(zcu); | ||
| 2124 | const diw = &wip_nav.debug_info.writer; | 2125 | const diw = &wip_nav.debug_info.writer; |
| 2125 | const size = ty.abiSize(wip_nav.pt.zcu); | 2126 | const size = ty.abiSize(zcu); |
| 2126 | try diw.writeUleb128(size); | 2127 | try diw.writeUleb128(size); |
| 2127 | if (size == 0) return; | 2128 | if (size == 0) return; |
| 2128 | const old_end = diw.end; | 2129 | const old_end = diw.end; |
| ... | @@ -2135,7 +2136,7 @@ pub const WipNav = struct { | ... | @@ -2135,7 +2136,7 @@ pub const WipNav = struct { |
| 2135 | ); | 2136 | ); |
| 2136 | if (old_end + size != diw.end) { | 2137 | if (old_end + size != diw.end) { |
| 2137 | std.debug.print("{f} [{}]: {} != {}\n", .{ | 2138 | std.debug.print("{f} [{}]: {} != {}\n", .{ |
| 2138 | ty.fmt(wip_nav.pt), | 2139 | ty.fmt(zcu), |
| 2139 | ty.toIntern(), | 2140 | ty.toIntern(), |
| 2140 | size, | 2141 | size, |
| 2141 | diw.end - old_end, | 2142 | diw.end - old_end, |
| ... | @@ -3340,8 +3341,8 @@ fn updateConstIncompleteInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_inde | ... | @@ -3340,8 +3341,8 @@ fn updateConstIncompleteInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_inde |
| 3340 | switch (value_index) { | 3341 | switch (value_index) { |
| 3341 | .generic_poison_type => log.debug("updateValueIncomplete(anytype)", .{}), | 3342 | .generic_poison_type => log.debug("updateValueIncomplete(anytype)", .{}), |
| 3342 | else => log.debug("updateValueIncomplete(@as({f}, {f}))", .{ | 3343 | else => log.debug("updateValueIncomplete(@as({f}, {f}))", .{ |
| 3343 | val.typeOf(zcu).fmt(pt), | 3344 | val.typeOf(zcu).fmt(zcu), |
| 3344 | val.fmtValue(pt), | 3345 | val.fmtValue(zcu), |
| 3345 | }), | 3346 | }), |
| 3346 | } | 3347 | } |
| 3347 | 3348 | ||
| ... | @@ -3435,7 +3436,7 @@ fn updateConstIncompleteInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_inde | ... | @@ -3435,7 +3436,7 @@ fn updateConstIncompleteInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_inde |
| 3435 | else => |val_key| switch (val_key.typeOf()) { | 3436 | else => |val_key| switch (val_key.typeOf()) { |
| 3436 | .type_type => { | 3437 | .type_type => { |
| 3437 | try wip_nav.abbrevCode(.generated_empty_struct_type); | 3438 | try wip_nav.abbrevCode(.generated_empty_struct_type); |
| 3438 | try wip_nav.strpFmt("{f}", .{val.toType().fmt(pt)}); | 3439 | try wip_nav.strpFmt("{f}", .{val.toType().fmt(zcu)}); |
| 3439 | try wip_nav.debug_info.writer.writeByte(@intFromBool(true)); | 3440 | try wip_nav.debug_info.writer.writeByte(@intFromBool(true)); |
| 3440 | }, | 3441 | }, |
| 3441 | else => |ty| { | 3442 | else => |ty| { |
| ... | @@ -3509,8 +3510,8 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co | ... | @@ -3509,8 +3510,8 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co |
| 3509 | switch (value_index) { | 3510 | switch (value_index) { |
| 3510 | .generic_poison_type => log.debug("updateValue(anytype)", .{}), | 3511 | .generic_poison_type => log.debug("updateValue(anytype)", .{}), |
| 3511 | else => log.debug("updateValue(@as({f}, {f}))", .{ | 3512 | else => log.debug("updateValue(@as({f}, {f}))", .{ |
| 3512 | val.typeOf(zcu).fmt(pt), | 3513 | val.typeOf(zcu).fmt(zcu), |
| 3513 | val.fmtValue(pt), | 3514 | val.fmtValue(zcu), |
| 3514 | }), | 3515 | }), |
| 3515 | } | 3516 | } |
| 3516 | 3517 | ||
| ... | @@ -3551,7 +3552,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co | ... | @@ -3551,7 +3552,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co |
| 3551 | 3552 | ||
| 3552 | .int_type => |int_type| { | 3553 | .int_type => |int_type| { |
| 3553 | try wip_nav.abbrevCode(.numeric_type); | 3554 | try wip_nav.abbrevCode(.numeric_type); |
| 3554 | try wip_nav.strpFmt("{f}", .{val.toType().fmt(pt)}); | 3555 | try wip_nav.strpFmt("{f}", .{val.toType().fmt(zcu)}); |
| 3555 | try diw.writeByte(switch (int_type.signedness) { | 3556 | try diw.writeByte(switch (int_type.signedness) { |
| 3556 | inline .signed, .unsigned => |signedness| @field(DW.ATE, @tagName(signedness)), | 3557 | inline .signed, .unsigned => |signedness| @field(DW.ATE, @tagName(signedness)), |
| 3557 | }); | 3558 | }); |
| ... | @@ -3566,7 +3567,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co | ... | @@ -3566,7 +3567,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co |
| 3566 | .none => if (ptr_type.sentinel == .none) .ptr_type else .ptr_sentinel_type, | 3567 | .none => if (ptr_type.sentinel == .none) .ptr_type else .ptr_sentinel_type, |
| 3567 | else => if (ptr_type.sentinel == .none) .ptr_aligned_type else .ptr_aligned_sentinel_type, | 3568 | else => if (ptr_type.sentinel == .none) .ptr_aligned_type else .ptr_aligned_sentinel_type, |
| 3568 | }); | 3569 | }); |
| 3569 | try wip_nav.strpFmt("{f}", .{val.toType().fmt(pt)}); | 3570 | try wip_nav.strpFmt("{f}", .{val.toType().fmt(zcu)}); |
| 3570 | if (ptr_type.sentinel != .none) try wip_nav.blockValue(.fromInterned(ptr_type.sentinel)); | 3571 | if (ptr_type.sentinel != .none) try wip_nav.blockValue(.fromInterned(ptr_type.sentinel)); |
| 3571 | if (ptr_type.flags.alignment.toByteUnits()) |a| try diw.writeUleb128(a); | 3572 | if (ptr_type.flags.alignment.toByteUnits()) |a| try diw.writeUleb128(a); |
| 3572 | try diw.writeByte(@backingInt(ptr_type.flags.address_space)); | 3573 | try diw.writeByte(@backingInt(ptr_type.flags.address_space)); |
| ... | @@ -3592,7 +3593,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co | ... | @@ -3592,7 +3593,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co |
| 3592 | }, | 3593 | }, |
| 3593 | .slice => { | 3594 | .slice => { |
| 3594 | try wip_nav.abbrevCode(.generated_struct_type); | 3595 | try wip_nav.abbrevCode(.generated_struct_type); |
| 3595 | try wip_nav.strpFmt("{f}", .{val.toType().fmt(pt)}); | 3596 | try wip_nav.strpFmt("{f}", .{val.toType().fmt(zcu)}); |
| 3596 | try diw.writeUleb128(val.toType().abiSize(zcu)); | 3597 | try diw.writeUleb128(val.toType().abiSize(zcu)); |
| 3597 | try diw.writeUleb128(val.toType().abiAlignment(zcu).toByteUnits().?); | 3598 | try diw.writeUleb128(val.toType().abiAlignment(zcu).toByteUnits().?); |
| 3598 | try wip_nav.abbrevCode(.generated_field); | 3599 | try wip_nav.abbrevCode(.generated_field); |
| ... | @@ -3611,7 +3612,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co | ... | @@ -3611,7 +3612,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co |
| 3611 | .array_type => |array_type| { | 3612 | .array_type => |array_type| { |
| 3612 | const array_child_type: Type = .fromInterned(array_type.child); | 3613 | const array_child_type: Type = .fromInterned(array_type.child); |
| 3613 | try wip_nav.abbrevCode(if (array_type.sentinel == .none) .array_type else .array_sentinel_type); | 3614 | try wip_nav.abbrevCode(if (array_type.sentinel == .none) .array_type else .array_sentinel_type); |
| 3614 | try wip_nav.strpFmt("{f}", .{val.toType().fmt(pt)}); | 3615 | try wip_nav.strpFmt("{f}", .{val.toType().fmt(zcu)}); |
| 3615 | if (array_type.sentinel != .none) try wip_nav.blockValue(.fromInterned(array_type.sentinel)); | 3616 | if (array_type.sentinel != .none) try wip_nav.blockValue(.fromInterned(array_type.sentinel)); |
| 3616 | try wip_nav.refType(array_child_type); | 3617 | try wip_nav.refType(array_child_type); |
| 3617 | try wip_nav.abbrevCode(.array_len); | 3618 | try wip_nav.abbrevCode(.array_len); |
| ... | @@ -3621,7 +3622,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co | ... | @@ -3621,7 +3622,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co |
| 3621 | }, | 3622 | }, |
| 3622 | .vector_type => |vector_type| { | 3623 | .vector_type => |vector_type| { |
| 3623 | try wip_nav.abbrevCode(.vector_type); | 3624 | try wip_nav.abbrevCode(.vector_type); |
| 3624 | try wip_nav.strpFmt("{f}", .{val.toType().fmt(pt)}); | 3625 | try wip_nav.strpFmt("{f}", .{val.toType().fmt(zcu)}); |
| 3625 | try wip_nav.refType(.fromInterned(vector_type.child)); | 3626 | try wip_nav.refType(.fromInterned(vector_type.child)); |
| 3626 | try wip_nav.abbrevCode(.array_len); | 3627 | try wip_nav.abbrevCode(.array_len); |
| 3627 | try wip_nav.refType(.usize); | 3628 | try wip_nav.refType(.usize); |
| ... | @@ -3632,7 +3633,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co | ... | @@ -3632,7 +3633,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co |
| 3632 | const opt_child_type: Type = .fromInterned(opt_child_type_index); | 3633 | const opt_child_type: Type = .fromInterned(opt_child_type_index); |
| 3633 | const opt_repr = optRepr(opt_child_type, zcu); | 3634 | const opt_repr = optRepr(opt_child_type, zcu); |
| 3634 | try wip_nav.abbrevCode(.generated_union_type); | 3635 | try wip_nav.abbrevCode(.generated_union_type); |
| 3635 | try wip_nav.strpFmt("{f}", .{val.toType().fmt(pt)}); | 3636 | try wip_nav.strpFmt("{f}", .{val.toType().fmt(zcu)}); |
| 3636 | try diw.writeUleb128(val.toType().abiSize(zcu)); | 3637 | try diw.writeUleb128(val.toType().abiSize(zcu)); |
| 3637 | try diw.writeUleb128(val.toType().abiAlignment(zcu).toByteUnits().?); | 3638 | try diw.writeUleb128(val.toType().abiAlignment(zcu).toByteUnits().?); |
| 3638 | switch (opt_repr) { | 3639 | switch (opt_repr) { |
| ... | @@ -3713,7 +3714,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co | ... | @@ -3713,7 +3714,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co |
| 3713 | }; | 3714 | }; |
| 3714 | 3715 | ||
| 3715 | try wip_nav.abbrevCode(.generated_union_type); | 3716 | try wip_nav.abbrevCode(.generated_union_type); |
| 3716 | try wip_nav.strpFmt("{f}", .{val.toType().fmt(pt)}); | 3717 | try wip_nav.strpFmt("{f}", .{val.toType().fmt(zcu)}); |
| 3717 | if (error_union_type.error_set_type != .generic_poison_type and | 3718 | if (error_union_type.error_set_type != .generic_poison_type and |
| 3718 | error_union_type.payload_type != .generic_poison_type) | 3719 | error_union_type.payload_type != .generic_poison_type) |
| 3719 | { | 3720 | { |
| ... | @@ -3785,7 +3786,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co | ... | @@ -3785,7 +3786,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co |
| 3785 | .bool, | 3786 | .bool, |
| 3786 | => { | 3787 | => { |
| 3787 | try wip_nav.abbrevCode(.numeric_type); | 3788 | try wip_nav.abbrevCode(.numeric_type); |
| 3788 | try wip_nav.strpFmt("{f}", .{val.toType().fmt(pt)}); | 3789 | try wip_nav.strpFmt("{f}", .{val.toType().fmt(zcu)}); |
| 3789 | try diw.writeByte(if (value_index == .bool_type) | 3790 | try diw.writeByte(if (value_index == .bool_type) |
| 3790 | DW.ATE.boolean | 3791 | DW.ATE.boolean |
| 3791 | else if (val.toType().isRuntimeFloat()) | 3792 | else if (val.toType().isRuntimeFloat()) |
| ... | @@ -3815,18 +3816,18 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co | ... | @@ -3815,18 +3816,18 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co |
| 3815 | .enum_literal, | 3816 | .enum_literal, |
| 3816 | => { | 3817 | => { |
| 3817 | try wip_nav.abbrevCode(.void_type); | 3818 | try wip_nav.abbrevCode(.void_type); |
| 3818 | try wip_nav.strpFmt("{f}", .{val.toType().fmt(pt)}); | 3819 | try wip_nav.strpFmt("{f}", .{val.toType().fmt(zcu)}); |
| 3819 | }, | 3820 | }, |
| 3820 | .anyerror => unreachable, // already did early return above | 3821 | .anyerror => unreachable, // already did early return above |
| 3821 | .adhoc_inferred_error_set => unreachable, | 3822 | .adhoc_inferred_error_set => unreachable, |
| 3822 | }, | 3823 | }, |
| 3823 | .tuple_type => |tuple_type| if (tuple_type.types.len == 0) { | 3824 | .tuple_type => |tuple_type| if (tuple_type.types.len == 0) { |
| 3824 | try wip_nav.abbrevCode(.generated_empty_struct_type); | 3825 | try wip_nav.abbrevCode(.generated_empty_struct_type); |
| 3825 | try wip_nav.strpFmt("{f}", .{val.toType().fmt(pt)}); | 3826 | try wip_nav.strpFmt("{f}", .{val.toType().fmt(zcu)}); |
| 3826 | try diw.writeByte(@intFromBool(false)); | 3827 | try diw.writeByte(@intFromBool(false)); |
| 3827 | } else { | 3828 | } else { |
| 3828 | try wip_nav.abbrevCode(.generated_struct_type); | 3829 | try wip_nav.abbrevCode(.generated_struct_type); |
| 3829 | try wip_nav.strpFmt("{f}", .{val.toType().fmt(pt)}); | 3830 | try wip_nav.strpFmt("{f}", .{val.toType().fmt(zcu)}); |
| 3830 | try diw.writeUleb128(val.toType().abiSize(zcu)); | 3831 | try diw.writeUleb128(val.toType().abiSize(zcu)); |
| 3831 | try diw.writeUleb128(val.toType().abiAlignment(zcu).toByteUnits().?); | 3832 | try diw.writeUleb128(val.toType().abiAlignment(zcu).toByteUnits().?); |
| 3832 | var field_byte_offset: u64 = 0; | 3833 | var field_byte_offset: u64 = 0; |
| ... | @@ -4148,7 +4149,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co | ... | @@ -4148,7 +4149,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co |
| 4148 | .func_type => |func_type| { | 4149 | .func_type => |func_type| { |
| 4149 | const is_nullary = func_type.param_types.len == 0 and !func_type.is_var_args; | 4150 | const is_nullary = func_type.param_types.len == 0 and !func_type.is_var_args; |
| 4150 | try wip_nav.abbrevCode(if (is_nullary) .nullary_func_type else .func_type); | 4151 | try wip_nav.abbrevCode(if (is_nullary) .nullary_func_type else .func_type); |
| 4151 | try wip_nav.strpFmt("{f}", .{val.toType().fmt(pt)}); | 4152 | try wip_nav.strpFmt("{f}", .{val.toType().fmt(zcu)}); |
| 4152 | const cc: DW.CC = cc: { | 4153 | const cc: DW.CC = cc: { |
| 4153 | if (zcu.getTarget().cCallingConvention()) |cc| { | 4154 | if (zcu.getTarget().cCallingConvention()) |cc| { |
| 4154 | if (@as(std.lang.CallingConvention.Tag, cc) == func_type.cc) { | 4155 | if (@as(std.lang.CallingConvention.Tag, cc) == func_type.cc) { |
| ... | @@ -4231,7 +4232,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co | ... | @@ -4231,7 +4232,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co |
| 4231 | }, | 4232 | }, |
| 4232 | .error_set_type => |error_set_type| { | 4233 | .error_set_type => |error_set_type| { |
| 4233 | try wip_nav.abbrevCode(if (error_set_type.names.len == 0) .generated_empty_enum_type else .generated_enum_type); | 4234 | try wip_nav.abbrevCode(if (error_set_type.names.len == 0) .generated_empty_enum_type else .generated_enum_type); |
| 4234 | try wip_nav.strpFmt("{f}", .{val.toType().fmt(pt)}); | 4235 | try wip_nav.strpFmt("{f}", .{val.toType().fmt(zcu)}); |
| 4235 | try wip_nav.refType(.fromInterned(try pt.intern(.{ .int_type = .{ | 4236 | try wip_nav.refType(.fromInterned(try pt.intern(.{ .int_type = .{ |
| 4236 | .signedness = .unsigned, | 4237 | .signedness = .unsigned, |
| 4237 | .bits = zcu.errorSetBits(), | 4238 | .bits = zcu.errorSetBits(), |
| ... | @@ -4247,7 +4248,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co | ... | @@ -4247,7 +4248,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co |
| 4247 | }, | 4248 | }, |
| 4248 | .inferred_error_set_type => |func| { | 4249 | .inferred_error_set_type => |func| { |
| 4249 | try wip_nav.abbrevCode(.inferred_error_set_type); | 4250 | try wip_nav.abbrevCode(.inferred_error_set_type); |
| 4250 | try wip_nav.strpFmt("{f}", .{val.toType().fmt(pt)}); | 4251 | try wip_nav.strpFmt("{f}", .{val.toType().fmt(zcu)}); |
| 4251 | try wip_nav.refType(.fromInterned(switch (ip.funcIesResolvedUnordered(func)) { | 4252 | try wip_nav.refType(.fromInterned(switch (ip.funcIesResolvedUnordered(func)) { |
| 4252 | .none => .anyerror_type, | 4253 | .none => .anyerror_type, |
| 4253 | else => |ies| ies, | 4254 | else => |ies| ies, |
src/link/Dwarf2.zig+18-17| ... | @@ -2516,7 +2516,7 @@ pub fn updateConst( | ... | @@ -2516,7 +2516,7 @@ pub fn updateConst( |
| 2516 | ) link.Error!void { | 2516 | ) link.Error!void { |
| 2517 | switch (val) { | 2517 | switch (val) { |
| 2518 | .generic_poison_type => log.debug("updateConst(anytype)", .{}), | 2518 | .generic_poison_type => log.debug("updateConst(anytype)", .{}), |
| 2519 | else => log.debug("updateConst({f})", .{Value.fromInterned(val).fmtValue(pt)}), | 2519 | else => log.debug("updateConst({f})", .{Value.fromInterned(val).fmtValue(pt.zcu)}), |
| 2520 | } | 2520 | } |
| 2521 | dwarf.updateConstInner(pt, di_nw, val) catch |err| switch (err) { | 2521 | dwarf.updateConstInner(pt, di_nw, val) catch |err| switch (err) { |
| 2522 | else => |e| return e, | 2522 | else => |e| return e, |
| ... | @@ -2538,7 +2538,7 @@ fn updateConstInner( | ... | @@ -2538,7 +2538,7 @@ fn updateConstInner( |
| 2538 | try dwarf.abbrevCode(di_nw, .numeric_type); | 2538 | try dwarf.abbrevCode(di_nw, .numeric_type); |
| 2539 | var name_buf: [std.fmt.count("i{d}", .{std.math.maxInt(u16)})]u8 = undefined; | 2539 | var name_buf: [std.fmt.count("i{d}", .{std.math.maxInt(u16)})]u8 = undefined; |
| 2540 | try dwarf.strx(di_nw, std.mem.print(&name_buf, "{f}", .{ | 2540 | try dwarf.strx(di_nw, std.mem.print(&name_buf, "{f}", .{ |
| 2541 | ty.fmt(pt), | 2541 | ty.fmt(zcu), |
| 2542 | }) catch unreachable); | 2542 | }) catch unreachable); |
| 2543 | try di_w.writeByte(switch (int_type.signedness) { | 2543 | try di_w.writeByte(switch (int_type.signedness) { |
| 2544 | .signed => DW.ATE.signed, | 2544 | .signed => DW.ATE.signed, |
| ... | @@ -2550,7 +2550,7 @@ fn updateConstInner( | ... | @@ -2550,7 +2550,7 @@ fn updateConstInner( |
| 2550 | }, | 2550 | }, |
| 2551 | .ptr_type => |ptr_type| switch (ptr_type.flags.size) { | 2551 | .ptr_type => |ptr_type| switch (ptr_type.flags.size) { |
| 2552 | .one, .many, .c => { | 2552 | .one, .many, .c => { |
| 2553 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(@"const").fmt(pt)}); | 2553 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(@"const").fmt(zcu)}); |
| 2554 | defer zcu.gpa.free(name); | 2554 | defer zcu.gpa.free(name); |
| 2555 | try dwarf.abbrevCode(di_nw, switch (ptr_type.sentinel) { | 2555 | try dwarf.abbrevCode(di_nw, switch (ptr_type.sentinel) { |
| 2556 | .none => .ptr_type, | 2556 | .none => .ptr_type, |
| ... | @@ -2585,7 +2585,7 @@ fn updateConstInner( | ... | @@ -2585,7 +2585,7 @@ fn updateConstInner( |
| 2585 | }, | 2585 | }, |
| 2586 | .slice => { | 2586 | .slice => { |
| 2587 | const ty: Type = .fromInterned(@"const"); | 2587 | const ty: Type = .fromInterned(@"const"); |
| 2588 | const name = try zcu.gpa.print("{f}", .{ty.fmt(pt)}); | 2588 | const name = try zcu.gpa.print("{f}", .{ty.fmt(zcu)}); |
| 2589 | defer zcu.gpa.free(name); | 2589 | defer zcu.gpa.free(name); |
| 2590 | try dwarf.abbrevCode(di_nw, .generated_struct_type); | 2590 | try dwarf.abbrevCode(di_nw, .generated_struct_type); |
| 2591 | try dwarf.strx(di_nw, name); | 2591 | try dwarf.strx(di_nw, name); |
| ... | @@ -2605,7 +2605,7 @@ fn updateConstInner( | ... | @@ -2605,7 +2605,7 @@ fn updateConstInner( |
| 2605 | }, | 2605 | }, |
| 2606 | }, | 2606 | }, |
| 2607 | .array_type => |array_type| { | 2607 | .array_type => |array_type| { |
| 2608 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(@"const").fmt(pt)}); | 2608 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(@"const").fmt(zcu)}); |
| 2609 | defer zcu.gpa.free(name); | 2609 | defer zcu.gpa.free(name); |
| 2610 | try dwarf.abbrevCode( | 2610 | try dwarf.abbrevCode( |
| 2611 | di_nw, | 2611 | di_nw, |
| ... | @@ -2621,7 +2621,7 @@ fn updateConstInner( | ... | @@ -2621,7 +2621,7 @@ fn updateConstInner( |
| 2621 | try di_w.writeUleb128(@backingInt(AbbrevCode.null)); | 2621 | try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 2622 | }, | 2622 | }, |
| 2623 | .vector_type => |vector_type| { | 2623 | .vector_type => |vector_type| { |
| 2624 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(@"const").fmt(pt)}); | 2624 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(@"const").fmt(zcu)}); |
| 2625 | defer zcu.gpa.free(name); | 2625 | defer zcu.gpa.free(name); |
| 2626 | try dwarf.abbrevCode(di_nw, .vector_type); | 2626 | try dwarf.abbrevCode(di_nw, .vector_type); |
| 2627 | try dwarf.strx(di_nw, name); | 2627 | try dwarf.strx(di_nw, name); |
| ... | @@ -2635,7 +2635,7 @@ fn updateConstInner( | ... | @@ -2635,7 +2635,7 @@ fn updateConstInner( |
| 2635 | const opt_ty: Type = .fromInterned(@"const"); | 2635 | const opt_ty: Type = .fromInterned(@"const"); |
| 2636 | const opt_child_ty: Type = .fromInterned(opt_child_type_index); | 2636 | const opt_child_ty: Type = .fromInterned(opt_child_type_index); |
| 2637 | const opt_repr = optRepr(opt_child_ty, zcu); | 2637 | const opt_repr = optRepr(opt_child_ty, zcu); |
| 2638 | const name = try zcu.gpa.print("{f}", .{opt_ty.fmt(pt)}); | 2638 | const name = try zcu.gpa.print("{f}", .{opt_ty.fmt(zcu)}); |
| 2639 | defer zcu.gpa.free(name); | 2639 | defer zcu.gpa.free(name); |
| 2640 | try dwarf.abbrevCode(di_nw, .generated_union_type); | 2640 | try dwarf.abbrevCode(di_nw, .generated_union_type); |
| 2641 | try dwarf.strx(di_nw, name); | 2641 | try dwarf.strx(di_nw, name); |
| ... | @@ -2715,7 +2715,7 @@ fn updateConstInner( | ... | @@ -2715,7 +2715,7 @@ fn updateConstInner( |
| 2715 | codegen.errUnionPayloadOffset(eu_payload_ty, zcu), | 2715 | codegen.errUnionPayloadOffset(eu_payload_ty, zcu), |
| 2716 | }, | 2716 | }, |
| 2717 | }; | 2717 | }; |
| 2718 | const name = try zcu.gpa.print("{f}", .{eu_ty.fmt(pt)}); | 2718 | const name = try zcu.gpa.print("{f}", .{eu_ty.fmt(zcu)}); |
| 2719 | defer zcu.gpa.free(name); | 2719 | defer zcu.gpa.free(name); |
| 2720 | 2720 | ||
| 2721 | try dwarf.abbrevCode(di_nw, .generated_union_type); | 2721 | try dwarf.abbrevCode(di_nw, .generated_union_type); |
| ... | @@ -2819,7 +2819,7 @@ fn updateConstInner( | ... | @@ -2819,7 +2819,7 @@ fn updateConstInner( |
| 2819 | try dwarf.abbrevCode(di_nw, .void_type); | 2819 | try dwarf.abbrevCode(di_nw, .void_type); |
| 2820 | var name_buf: ["@TypeOf(undefined)".len]u8 = undefined; | 2820 | var name_buf: ["@TypeOf(undefined)".len]u8 = undefined; |
| 2821 | try dwarf.strx(di_nw, std.mem.print(&name_buf, "{f}", .{ | 2821 | try dwarf.strx(di_nw, std.mem.print(&name_buf, "{f}", .{ |
| 2822 | ty.fmt(pt), | 2822 | ty.fmt(zcu), |
| 2823 | }) catch unreachable); | 2823 | }) catch unreachable); |
| 2824 | }, | 2824 | }, |
| 2825 | .anyerror => { | 2825 | .anyerror => { |
| ... | @@ -2842,7 +2842,7 @@ fn updateConstInner( | ... | @@ -2842,7 +2842,7 @@ fn updateConstInner( |
| 2842 | }, | 2842 | }, |
| 2843 | .tuple_type => |tuple_type| { | 2843 | .tuple_type => |tuple_type| { |
| 2844 | const ty: Type = .fromInterned(@"const"); | 2844 | const ty: Type = .fromInterned(@"const"); |
| 2845 | const name = try zcu.gpa.print("{f}", .{ty.fmt(pt)}); | 2845 | const name = try zcu.gpa.print("{f}", .{ty.fmt(zcu)}); |
| 2846 | defer zcu.gpa.free(name); | 2846 | defer zcu.gpa.free(name); |
| 2847 | if (tuple_type.types.len == 0) { | 2847 | if (tuple_type.types.len == 0) { |
| 2848 | try dwarf.abbrevCode(di_nw, .generated_empty_struct_type); | 2848 | try dwarf.abbrevCode(di_nw, .generated_empty_struct_type); |
| ... | @@ -3255,7 +3255,7 @@ fn updateConstInner( | ... | @@ -3255,7 +3255,7 @@ fn updateConstInner( |
| 3255 | .spirv_type => unreachable, | 3255 | .spirv_type => unreachable, |
| 3256 | .func_type => |func_type| { | 3256 | .func_type => |func_type| { |
| 3257 | const is_empty = func_type.param_types.len == 0 and !func_type.is_var_args; | 3257 | const is_empty = func_type.param_types.len == 0 and !func_type.is_var_args; |
| 3258 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(@"const").fmt(pt)}); | 3258 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(@"const").fmt(zcu)}); |
| 3259 | defer zcu.gpa.free(name); | 3259 | defer zcu.gpa.free(name); |
| 3260 | try dwarf.abbrevCode(di_nw, if (is_empty) .empty_func_type else .func_type); | 3260 | try dwarf.abbrevCode(di_nw, if (is_empty) .empty_func_type else .func_type); |
| 3261 | try dwarf.strx(di_nw, name); | 3261 | try dwarf.strx(di_nw, name); |
| ... | @@ -3340,7 +3340,7 @@ fn updateConstInner( | ... | @@ -3340,7 +3340,7 @@ fn updateConstInner( |
| 3340 | if (!is_empty) try di_w.writeUleb128(@backingInt(AbbrevCode.null)); | 3340 | if (!is_empty) try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 3341 | }, | 3341 | }, |
| 3342 | .error_set_type => |error_set_type| { | 3342 | .error_set_type => |error_set_type| { |
| 3343 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(@"const").fmt(pt)}); | 3343 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(@"const").fmt(zcu)}); |
| 3344 | defer zcu.gpa.free(name); | 3344 | defer zcu.gpa.free(name); |
| 3345 | try dwarf.abbrevCode( | 3345 | try dwarf.abbrevCode( |
| 3346 | di_nw, | 3346 | di_nw, |
| ... | @@ -3358,7 +3358,7 @@ fn updateConstInner( | ... | @@ -3358,7 +3358,7 @@ fn updateConstInner( |
| 3358 | if (error_set_type.names.len > 0) try di_w.writeUleb128(@backingInt(AbbrevCode.null)); | 3358 | if (error_set_type.names.len > 0) try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 3359 | }, | 3359 | }, |
| 3360 | .inferred_error_set_type => |func| { | 3360 | .inferred_error_set_type => |func| { |
| 3361 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(@"const").fmt(pt)}); | 3361 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(@"const").fmt(zcu)}); |
| 3362 | defer zcu.gpa.free(name); | 3362 | defer zcu.gpa.free(name); |
| 3363 | try dwarf.abbrevCode(di_nw, .inferred_error_set_type); | 3363 | try dwarf.abbrevCode(di_nw, .inferred_error_set_type); |
| 3364 | try dwarf.strx(di_nw, name); | 3364 | try dwarf.strx(di_nw, name); |
| ... | @@ -3863,7 +3863,7 @@ pub fn updateConstIncomplete( | ... | @@ -3863,7 +3863,7 @@ pub fn updateConstIncomplete( |
| 3863 | di_nw: *link.MappedFile.Node.Writer, | 3863 | di_nw: *link.MappedFile.Node.Writer, |
| 3864 | val: InternPool.Index, | 3864 | val: InternPool.Index, |
| 3865 | ) link.Error!void { | 3865 | ) link.Error!void { |
| 3866 | log.debug("updateConstIncomplete({f})", .{Value.fromInterned(val).fmtValue(pt)}); | 3866 | log.debug("updateConstIncomplete({f})", .{Value.fromInterned(val).fmtValue(pt.zcu)}); |
| 3867 | dwarf.updateConstIncompleteInner(pt, di_nw, val) catch |err| switch (err) { | 3867 | dwarf.updateConstIncompleteInner(pt, di_nw, val) catch |err| switch (err) { |
| 3868 | else => |e| return e, | 3868 | else => |e| return e, |
| 3869 | error.WriteFailed => return dwarf.reportWriteError(di_nw), | 3869 | error.WriteFailed => return dwarf.reportWriteError(di_nw), |
| ... | @@ -4021,7 +4021,7 @@ fn updateConstIncompleteInner( | ... | @@ -4021,7 +4021,7 @@ fn updateConstIncompleteInner( |
| 4021 | }, | 4021 | }, |
| 4022 | else => |val_key| break :done switch (val_key.typeOf()) { | 4022 | else => |val_key| break :done switch (val_key.typeOf()) { |
| 4023 | .type_type => { | 4023 | .type_type => { |
| 4024 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(val).fmt(pt)}); | 4024 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(val).fmt(zcu)}); |
| 4025 | defer zcu.gpa.free(name); | 4025 | defer zcu.gpa.free(name); |
| 4026 | try dwarf.abbrevCode(di_nw, .generated_empty_struct_type); | 4026 | try dwarf.abbrevCode(di_nw, .generated_empty_struct_type); |
| 4027 | try dwarf.strx(di_nw, name); | 4027 | try dwarf.strx(di_nw, name); |
| ... | @@ -4140,11 +4140,12 @@ pub fn genDecl( | ... | @@ -4140,11 +4140,12 @@ pub fn genDecl( |
| 4140 | di_nw: *link.MappedFile.Node.Writer, | 4140 | di_nw: *link.MappedFile.Node.Writer, |
| 4141 | instance: Decl.Instance, | 4141 | instance: Decl.Instance, |
| 4142 | ) link.Error!void { | 4142 | ) link.Error!void { |
| 4143 | const zcu = pt.zcu; | ||
| 4143 | switch (instance) { | 4144 | switch (instance) { |
| 4144 | .none => unreachable, | 4145 | .none => unreachable, |
| 4145 | .@"const" => |@"const"| log.debug("genDecl({f})", .{Value.fromInterned(@"const").fmtValue(pt)}), | 4146 | .@"const" => |@"const"| log.debug("genDecl({f})", .{Value.fromInterned(@"const").fmtValue(zcu)}), |
| 4146 | .global => |global| log.debug("genDecl({f})", .{ | 4147 | .global => |global| log.debug("genDecl({f})", .{ |
| 4147 | pt.zcu.intern_pool.getNav(global).fqn.fmt(&pt.zcu.intern_pool), | 4148 | zcu.intern_pool.getNav(global).fqn.fmt(&zcu.intern_pool), |
| 4148 | }), | 4149 | }), |
| 4149 | } | 4150 | } |
| 4150 | dwarf.genDeclInner(pt, di_nw, instance) catch |err| switch (err) { | 4151 | dwarf.genDeclInner(pt, di_nw, instance) catch |err| switch (err) { |
src/link/Elf/ZigObject.zig+2-2| ... | @@ -1720,7 +1720,7 @@ fn updateLazySymbol( | ... | @@ -1720,7 +1720,7 @@ fn updateLazySymbol( |
| 1720 | const name_str_index = blk: { | 1720 | const name_str_index = blk: { |
| 1721 | const name = try std.fmt.allocPrint(gpa, "__lazy_{s}_{f}", .{ | 1721 | const name = try std.fmt.allocPrint(gpa, "__lazy_{s}_{f}", .{ |
| 1722 | @tagName(sym.kind), | 1722 | @tagName(sym.kind), |
| 1723 | Type.fromInterned(sym.ty).fmt(pt), | 1723 | Type.fromInterned(sym.ty).fmt(zcu), |
| 1724 | }); | 1724 | }); |
| 1725 | defer gpa.free(name); | 1725 | defer gpa.free(name); |
| 1726 | break :blk try self.strtab.insert(gpa, name); | 1726 | break :blk try self.strtab.insert(gpa, name); |
| ... | @@ -2349,7 +2349,7 @@ fn checkUavAllocated(pt: Zcu.PerThread, index: InternPool.Index, meta: AvMetadat | ... | @@ -2349,7 +2349,7 @@ fn checkUavAllocated(pt: Zcu.PerThread, index: InternPool.Index, meta: AvMetadat |
| 2349 | const uav = Value.fromInterned(index); | 2349 | const uav = Value.fromInterned(index); |
| 2350 | const ty = uav.typeOf(zcu); | 2350 | const ty = uav.typeOf(zcu); |
| 2351 | log.err("UAV {f}({d}) assigned symbol {d} but not allocated!", .{ | 2351 | log.err("UAV {f}({d}) assigned symbol {d} but not allocated!", .{ |
| 2352 | ty.fmt(pt), | 2352 | ty.fmt(zcu), |
| 2353 | index, | 2353 | index, |
| 2354 | meta.symbol_index, | 2354 | meta.symbol_index, |
| 2355 | }); | 2355 | }); |
src/link/Elf2.zig+38-44| ... | @@ -9726,8 +9726,9 @@ pub fn updateNav(elf: *Elf, pt: Zcu.PerThread, nav_index: InternPool.Nav.Index) | ... | @@ -9726,8 +9726,9 @@ pub fn updateNav(elf: *Elf, pt: Zcu.PerThread, nav_index: InternPool.Nav.Index) |
| 9726 | }; | 9726 | }; |
| 9727 | } | 9727 | } |
| 9728 | fn updateNavInner(elf: *Elf, pt: Zcu.PerThread, nav_index: InternPool.Nav.Index) Error!void { | 9728 | fn updateNavInner(elf: *Elf, pt: Zcu.PerThread, nav_index: InternPool.Nav.Index) Error!void { |
| 9729 | const zcu = pt.zcu; | 9729 | const comp = elf.base.comp; |
| 9730 | const gpa = zcu.gpa; | 9730 | const gpa = comp.gpa; |
| 9731 | const zcu = comp.zcu.?; | ||
| 9731 | const ip = &zcu.intern_pool; | 9732 | const ip = &zcu.intern_pool; |
| 9732 | 9733 | ||
| 9733 | const nav = ip.getNav(nav_index); | 9734 | const nav = ip.getNav(nav_index); |
| ... | @@ -9823,7 +9824,7 @@ pub fn updateContainerType( | ... | @@ -9823,7 +9824,7 @@ pub fn updateContainerType( |
| 9823 | ), | 9824 | ), |
| 9824 | }; | 9825 | }; |
| 9825 | } | 9826 | } |
| 9826 | pub fn updateContainerTypeInner( | 9827 | fn updateContainerTypeInner( |
| 9827 | elf: *Elf, | 9828 | elf: *Elf, |
| 9828 | pt: Zcu.PerThread, | 9829 | pt: Zcu.PerThread, |
| 9829 | ty: InternPool.Index, | 9830 | ty: InternPool.Index, |
| ... | @@ -10227,7 +10228,8 @@ pub fn flush( | ... | @@ -10227,7 +10228,8 @@ pub fn flush( |
| 10227 | tid: Zcu.PerThread.Id, | 10228 | tid: Zcu.PerThread.Id, |
| 10228 | prog_node: std.Progress.Node, | 10229 | prog_node: std.Progress.Node, |
| 10229 | ) link.Error!void { | 10230 | ) link.Error!void { |
| 10230 | elf.flushInner(arena, tid, prog_node) catch |err| switch (err) { | 10231 | _ = tid; |
| 10232 | elf.flushInner(arena, prog_node) catch |err| switch (err) { | ||
| 10231 | else => |e| return e, | 10233 | else => |e| return e, |
| 10232 | error.MappedFileIo => return elf.base.comp.link_diags.fail( | 10234 | error.MappedFileIo => return elf.base.comp.link_diags.fail( |
| 10233 | "failed to write output file: {t}", | 10235 | "failed to write output file: {t}", |
| ... | @@ -10238,7 +10240,6 @@ pub fn flush( | ... | @@ -10238,7 +10240,6 @@ pub fn flush( |
| 10238 | fn flushInner( | 10240 | fn flushInner( |
| 10239 | elf: *Elf, | 10241 | elf: *Elf, |
| 10240 | arena: std.mem.Allocator, | 10242 | arena: std.mem.Allocator, |
| 10241 | tid: Zcu.PerThread.Id, | ||
| 10242 | prog_node: std.Progress.Node, | 10243 | prog_node: std.Progress.Node, |
| 10243 | ) Error!void { | 10244 | ) Error!void { |
| 10244 | const comp = elf.base.comp; | 10245 | const comp = elf.base.comp; |
| ... | @@ -10266,7 +10267,7 @@ fn flushInner( | ... | @@ -10266,7 +10267,7 @@ fn flushInner( |
| 10266 | 10267 | ||
| 10267 | try elf.prepareDynamic(); | 10268 | try elf.prepareDynamic(); |
| 10268 | 10269 | ||
| 10269 | while (try elf.idle(tid)) {} | 10270 | while (try elf.idle()) {} |
| 10270 | 10271 | ||
| 10271 | assert(elf.input_pending_index == elf.inputs.items.len); | 10272 | assert(elf.input_pending_index == elf.inputs.items.len); |
| 10272 | assert(elf.input_section_pending_index == elf.input_sections.items.len); | 10273 | assert(elf.input_section_pending_index == elf.input_sections.items.len); |
| ... | @@ -10323,11 +10324,11 @@ fn flushInner( | ... | @@ -10323,11 +10324,11 @@ fn flushInner( |
| 10323 | try elf.mf.flush(); | 10324 | try elf.mf.flush(); |
| 10324 | 10325 | ||
| 10325 | if (elf.options.enable_link_snapshots) | 10326 | if (elf.options.enable_link_snapshots) |
| 10326 | elf.dumpStderr(tid) catch |err| | 10327 | elf.dumpStderr() catch |err| |
| 10327 | return diags.fail("dumping link snapshot failed: {t}", .{err}); | 10328 | return diags.fail("dumping link snapshot failed: {t}", .{err}); |
| 10328 | } | 10329 | } |
| 10329 | 10330 | ||
| 10330 | pub fn idle(elf: *Elf, tid: Zcu.PerThread.Id) link.Error!bool { | 10331 | pub fn idle(elf: *Elf) link.Error!bool { |
| 10331 | // This function is called non-deterministically, and so must not affect the layout of any nodes. | 10332 | // This function is called non-deterministically, and so must not affect the layout of any nodes. |
| 10332 | elf.mf.nodes_lock.lock(); | 10333 | elf.mf.nodes_lock.lock(); |
| 10333 | defer elf.mf.nodes_lock.unlock(); | 10334 | defer elf.mf.nodes_lock.unlock(); |
| ... | @@ -10343,7 +10344,7 @@ pub fn idle(elf: *Elf, tid: Zcu.PerThread.Id) link.Error!bool { | ... | @@ -10343,7 +10344,7 @@ pub fn idle(elf: *Elf, tid: Zcu.PerThread.Id) link.Error!bool { |
| 10343 | const ii: Node.InputIndex = @fromBackingInt(elf.input_pending_index); | 10344 | const ii: Node.InputIndex = @fromBackingInt(elf.input_pending_index); |
| 10344 | elf.input_pending_index += 1; | 10345 | elf.input_pending_index += 1; |
| 10345 | const idle_prog_node = | 10346 | const idle_prog_node = |
| 10346 | elf.startIdleProgress(tid, elf.input_prog_node, elf.getNode(ii.node(elf))); | 10347 | elf.startIdleProgress(elf.input_prog_node, elf.getNode(ii.node(elf))); |
| 10347 | defer idle_prog_node.end(); | 10348 | defer idle_prog_node.end(); |
| 10348 | elf.flushInput(ii) catch |err| switch (err) { | 10349 | elf.flushInput(ii) catch |err| switch (err) { |
| 10349 | else => |e| return e, | 10350 | else => |e| return e, |
| ... | @@ -10355,7 +10356,7 @@ pub fn idle(elf: *Elf, tid: Zcu.PerThread.Id) link.Error!bool { | ... | @@ -10355,7 +10356,7 @@ pub fn idle(elf: *Elf, tid: Zcu.PerThread.Id) link.Error!bool { |
| 10355 | const isi: InputSection.Index = @fromBackingInt(elf.input_section_pending_index); | 10356 | const isi: InputSection.Index = @fromBackingInt(elf.input_section_pending_index); |
| 10356 | elf.input_section_pending_index += 1; | 10357 | elf.input_section_pending_index += 1; |
| 10357 | const idle_prog_node = | 10358 | const idle_prog_node = |
| 10358 | elf.startIdleProgress(tid, elf.input_prog_node, elf.getNode(isi.node(elf))); | 10359 | elf.startIdleProgress(elf.input_prog_node, elf.getNode(isi.node(elf))); |
| 10359 | defer idle_prog_node.end(); | 10360 | defer idle_prog_node.end(); |
| 10360 | elf.flushInputSection(isi) catch |err| switch (err) { | 10361 | elf.flushInputSection(isi) catch |err| switch (err) { |
| 10361 | else => |e| return e, | 10362 | else => |e| return e, |
| ... | @@ -10465,7 +10466,7 @@ pub fn idle(elf: *Elf, tid: Zcu.PerThread.Id) link.Error!bool { | ... | @@ -10465,7 +10466,7 @@ pub fn idle(elf: *Elf, tid: Zcu.PerThread.Id) link.Error!bool { |
| 10465 | const clean_resized = ni.cleanResized(&elf.mf); | 10466 | const clean_resized = ni.cleanResized(&elf.mf); |
| 10466 | const clean_next_moved = ni.cleanNextMoved(&elf.mf); | 10467 | const clean_next_moved = ni.cleanNextMoved(&elf.mf); |
| 10467 | if (!clean_moved and !clean_resized and !clean_next_moved) continue; | 10468 | if (!clean_moved and !clean_resized and !clean_next_moved) continue; |
| 10468 | const idle_prog_node = elf.startIdleProgress(tid, elf.mf.update_prog_node, elf.getNode(ni)); | 10469 | const idle_prog_node = elf.startIdleProgress(elf.mf.update_prog_node, elf.getNode(ni)); |
| 10469 | defer idle_prog_node.end(); | 10470 | defer idle_prog_node.end(); |
| 10470 | if (clean_moved) try elf.flushMoved(ni); | 10471 | if (clean_moved) try elf.flushMoved(ni); |
| 10471 | if (clean_resized) try elf.flushResized(ni); | 10472 | if (clean_resized) try elf.flushResized(ni); |
| ... | @@ -10483,7 +10484,6 @@ pub fn idle(elf: *Elf, tid: Zcu.PerThread.Id) link.Error!bool { | ... | @@ -10483,7 +10484,6 @@ pub fn idle(elf: *Elf, tid: Zcu.PerThread.Id) link.Error!bool { |
| 10483 | 10484 | ||
| 10484 | fn startIdleProgress( | 10485 | fn startIdleProgress( |
| 10485 | elf: *Elf, | 10486 | elf: *Elf, |
| 10486 | tid: Zcu.PerThread.Id, | ||
| 10487 | prog_node: std.Progress.Node, | 10487 | prog_node: std.Progress.Node, |
| 10488 | node: Node, | 10488 | node: Node, |
| 10489 | ) std.Progress.Node { | 10489 | ) std.Progress.Node { |
| ... | @@ -10508,7 +10508,7 @@ fn startIdleProgress( | ... | @@ -10508,7 +10508,7 @@ fn startIdleProgress( |
| 10508 | break :name ip.getNav(nmi.nav(elf)).fqn.toSlice(ip); | 10508 | break :name ip.getNav(nmi.nav(elf)).fqn.toSlice(ip); |
| 10509 | }, | 10509 | }, |
| 10510 | .uav => |umi| std.mem.print(&name, "{f}", .{ | 10510 | .uav => |umi| std.mem.print(&name, "{f}", .{ |
| 10511 | Value.fromInterned(umi.uavValue(elf)).fmtValue(.{ .zcu = elf.base.comp.zcu.?, .tid = tid }), | 10511 | Value.fromInterned(umi.uavValue(elf)).fmtValue(elf.base.comp.zcu.?), |
| 10512 | }) catch &name, | 10512 | }) catch &name, |
| 10513 | .debug_shared => |ss| switch (ss) { | 10513 | .debug_shared => |ss| switch (ss) { |
| 10514 | .debug_abbrev => "debug info abbrevs", | 10514 | .debug_abbrev => "debug info abbrevs", |
| ... | @@ -10539,7 +10539,7 @@ fn startIdleProgress( | ... | @@ -10539,7 +10539,7 @@ fn startIdleProgress( |
| 10539 | .const_debug_info => |cpi| switch (cpi.val(&elf.dwarf.const_pool)) { | 10539 | .const_debug_info => |cpi| switch (cpi.val(&elf.dwarf.const_pool)) { |
| 10540 | .generic_poison_type => "anytype", | 10540 | .generic_poison_type => "anytype", |
| 10541 | else => |val| std.mem.print(&name, "debug info for {f}", .{ | 10541 | else => |val| std.mem.print(&name, "debug info for {f}", .{ |
| 10542 | Value.fromInterned(val).fmtValue(.{ .zcu = elf.base.comp.zcu.?, .tid = tid }), | 10542 | Value.fromInterned(val).fmtValue(elf.base.comp.zcu.?), |
| 10543 | }) catch &name, | 10543 | }) catch &name, |
| 10544 | }, | 10544 | }, |
| 10545 | .global_debug_info => |gi| { | 10545 | .global_debug_info => |gi| { |
| ... | @@ -10571,10 +10571,11 @@ fn startIdleProgress( | ... | @@ -10571,10 +10571,11 @@ fn startIdleProgress( |
| 10571 | } | 10571 | } |
| 10572 | 10572 | ||
| 10573 | fn genPending(elf: *Elf, pt: Zcu.PerThread) link.Error!void { | 10573 | fn genPending(elf: *Elf, pt: Zcu.PerThread) link.Error!void { |
| 10574 | const zcu = elf.base.comp.zcu.?; | ||
| 10574 | while (elf.pending_uavs.pop()) |umi| { | 10575 | while (elf.pending_uavs.pop()) |umi| { |
| 10575 | var prog_name_buf: [std.Progress.Node.max_name_len]u8 = undefined; | 10576 | var prog_name_buf: [std.Progress.Node.max_name_len]u8 = undefined; |
| 10576 | const prog_name = std.mem.print(&prog_name_buf, "{f}", .{ | 10577 | const prog_name = std.mem.print(&prog_name_buf, "{f}", .{ |
| 10577 | Value.fromInterned(umi.uavValue(elf)).fmtValue(pt), | 10578 | Value.fromInterned(umi.uavValue(elf)).fmtValue(zcu), |
| 10578 | }) catch &prog_name_buf; | 10579 | }) catch &prog_name_buf; |
| 10579 | const prog_node = elf.const_prog_node.start(prog_name, 0); | 10580 | const prog_node = elf.const_prog_node.start(prog_name, 0); |
| 10580 | defer prog_node.end(); | 10581 | defer prog_node.end(); |
| ... | @@ -10671,14 +10672,15 @@ fn genUav( | ... | @@ -10671,14 +10672,15 @@ fn genUav( |
| 10671 | } | 10672 | } |
| 10672 | 10673 | ||
| 10673 | fn genLazy(elf: *Elf, pt: Zcu.PerThread, lmr: Node.LazyMapRef) link.Error!void { | 10674 | fn genLazy(elf: *Elf, pt: Zcu.PerThread, lmr: Node.LazyMapRef) link.Error!void { |
| 10675 | const zcu = elf.base.comp.zcu.?; | ||
| 10674 | const lazy = lmr.lazySymbol(elf); | 10676 | const lazy = lmr.lazySymbol(elf); |
| 10675 | if (lazy.ty == .anyerror_type) return; | 10677 | if (lazy.ty == .anyerror_type) return; |
| 10676 | const lazy_ty: Type = .fromInterned(lazy.ty); | 10678 | const lazy_ty: Type = .fromInterned(lazy.ty); |
| 10677 | var prog_name_buf: [std.Progress.Node.max_name_len]u8 = undefined; | 10679 | var prog_name_buf: [std.Progress.Node.max_name_len]u8 = undefined; |
| 10678 | const prog_name: []const u8 = switch (lazy_ty.zigTypeTag(pt.zcu)) { | 10680 | const prog_name: []const u8 = switch (lazy_ty.zigTypeTag(zcu)) { |
| 10679 | .@"enum" => std.mem.print(&prog_name_buf, "@tagName({f})", .{lazy_ty.fmt(pt)}) catch &prog_name_buf, | 10681 | .@"enum" => std.mem.print(&prog_name_buf, "@tagName({f})", .{lazy_ty.fmt(zcu)}) catch &prog_name_buf, |
| 10680 | .error_set => switch (lmr.kind) { | 10682 | .error_set => switch (lmr.kind) { |
| 10681 | .code => std.mem.print(&prog_name_buf, "@errorCast({f})", .{lazy_ty.fmt(pt)}) catch &prog_name_buf, | 10683 | .code => std.mem.print(&prog_name_buf, "@errorCast({f})", .{lazy_ty.fmt(zcu)}) catch &prog_name_buf, |
| 10682 | .const_data => "@errorName(anyerror)", | 10684 | .const_data => "@errorName(anyerror)", |
| 10683 | }, | 10685 | }, |
| 10684 | else => unreachable, | 10686 | else => unreachable, |
| ... | @@ -12123,19 +12125,15 @@ pub fn updateExports( | ... | @@ -12123,19 +12125,15 @@ pub fn updateExports( |
| 12123 | export_indices: []const Zcu.Export.Index, | 12125 | export_indices: []const Zcu.Export.Index, |
| 12124 | ) link.Error!void { | 12126 | ) link.Error!void { |
| 12125 | for (export_indices) |export_index| { | 12127 | for (export_indices) |export_index| { |
| 12126 | elf.updateExportInner(pt, export_index) catch |err| switch (err) { | 12128 | elf.updateExportInner(export_index) catch |err| switch (err) { |
| 12127 | else => |e| return e, | 12129 | else => |e| return e, |
| 12128 | error.MappedFileIo => return elf.base.comp.link_diags.fail("failed to write output file: {t}", .{elf.mf.io_err.?}), | 12130 | error.MappedFileIo => return elf.base.comp.link_diags.fail("failed to write output file: {t}", .{elf.mf.io_err.?}), |
| 12129 | }; | 12131 | }; |
| 12130 | } | 12132 | } |
| 12131 | try elf.genPending(pt); | 12133 | try elf.genPending(pt); |
| 12132 | } | 12134 | } |
| 12133 | fn updateExportInner( | 12135 | fn updateExportInner(elf: *Elf, export_index: Zcu.Export.Index) Error!void { |
| 12134 | elf: *Elf, | 12136 | const zcu = elf.base.comp.zcu.?; |
| 12135 | pt: Zcu.PerThread, | ||
| 12136 | export_index: Zcu.Export.Index, | ||
| 12137 | ) Error!void { | ||
| 12138 | const zcu = pt.zcu; | ||
| 12139 | const ip = &zcu.intern_pool; | 12137 | const ip = &zcu.intern_pool; |
| 12140 | 12138 | ||
| 12141 | const @"export" = export_index.ptr(zcu); | 12139 | const @"export" = export_index.ptr(zcu); |
| ... | @@ -12143,8 +12141,8 @@ fn updateExportInner( | ... | @@ -12143,8 +12141,8 @@ fn updateExportInner( |
| 12143 | switch (@"export".exported) { | 12141 | switch (@"export".exported) { |
| 12144 | .nav => |nav| log.debug("updateExports({f})", .{ip.getNav(nav).fqn.fmt(ip)}), | 12142 | .nav => |nav| log.debug("updateExports({f})", .{ip.getNav(nav).fqn.fmt(ip)}), |
| 12145 | .uav => |uav| log.debug("updateExports(@as({f}, {f}))", .{ | 12143 | .uav => |uav| log.debug("updateExports(@as({f}, {f}))", .{ |
| 12146 | Type.fromInterned(ip.typeOf(uav)).fmt(pt), | 12144 | Type.fromInterned(ip.typeOf(uav)).fmt(zcu), |
| 12147 | Value.fromInterned(uav).fmtValue(pt), | 12145 | Value.fromInterned(uav).fmtValue(zcu), |
| 12148 | }), | 12146 | }), |
| 12149 | } | 12147 | } |
| 12150 | const exported_lsi: Symbol.LocalIndex = switch (@"export".exported) { | 12148 | const exported_lsi: Symbol.LocalIndex = switch (@"export".exported) { |
| ... | @@ -12210,21 +12208,21 @@ fn updateExportInner( | ... | @@ -12210,21 +12208,21 @@ fn updateExportInner( |
| 12210 | }; | 12208 | }; |
| 12211 | } | 12209 | } |
| 12212 | 12210 | ||
| 12213 | fn dumpStderr(elf: *Elf, tid: Zcu.PerThread.Id) Io.File.Writer.Error!void { | 12211 | fn dumpStderr(elf: *Elf) Io.File.Writer.Error!void { |
| 12214 | const comp = elf.base.comp; | 12212 | const comp = elf.base.comp; |
| 12215 | const io = comp.io; | 12213 | const io = comp.io; |
| 12216 | var buffer: [512]u8 = undefined; | 12214 | var buffer: [512]u8 = undefined; |
| 12217 | const stderr = try io.lockStderr(&buffer, null); | 12215 | const stderr = try io.lockStderr(&buffer, null); |
| 12218 | defer io.unlockStderr(); | 12216 | defer io.unlockStderr(); |
| 12219 | const w = &stderr.file_writer.interface; | 12217 | const w = &stderr.file_writer.interface; |
| 12220 | _ = elf.dump(w, tid) catch |err| switch (err) { | 12218 | _ = elf.dump(w) catch |err| switch (err) { |
| 12221 | error.WriteFailed => return stderr.file_writer.err.?, | 12219 | error.WriteFailed => return stderr.file_writer.err.?, |
| 12222 | }; | 12220 | }; |
| 12223 | } | 12221 | } |
| 12224 | 12222 | ||
| 12225 | pub fn dump(elf: *Elf, w: *Io.Writer, tid: Zcu.PerThread.Id) Io.Writer.Error!link.File.DumpResult { | 12223 | pub fn dump(elf: *Elf, w: *Io.Writer) Io.Writer.Error!link.File.DumpResult { |
| 12226 | if (elf.options.enable_link_snapshots) { | 12224 | if (elf.options.enable_link_snapshots) { |
| 12227 | try elf.printNode(tid, w, .root, 0); | 12225 | try elf.printNode(w, .root, 0); |
| 12228 | return .enabled; | 12226 | return .enabled; |
| 12229 | } | 12227 | } |
| 12230 | return .disabled; | 12228 | return .disabled; |
| ... | @@ -12232,7 +12230,6 @@ pub fn dump(elf: *Elf, w: *Io.Writer, tid: Zcu.PerThread.Id) Io.Writer.Error!lin | ... | @@ -12232,7 +12230,6 @@ pub fn dump(elf: *Elf, w: *Io.Writer, tid: Zcu.PerThread.Id) Io.Writer.Error!lin |
| 12232 | 12230 | ||
| 12233 | pub fn printNode( | 12231 | pub fn printNode( |
| 12234 | elf: *Elf, | 12232 | elf: *Elf, |
| 12235 | tid: Zcu.PerThread.Id, | ||
| 12236 | w: *Io.Writer, | 12233 | w: *Io.Writer, |
| 12237 | ni: MappedFile.Node.Index, | 12234 | ni: MappedFile.Node.Index, |
| 12238 | indent: usize, | 12235 | indent: usize, |
| ... | @@ -12277,7 +12274,7 @@ pub fn printNode( | ... | @@ -12277,7 +12274,7 @@ pub fn printNode( |
| 12277 | const ip = &zcu.intern_pool; | 12274 | const ip = &zcu.intern_pool; |
| 12278 | const nav = ip.getNav(nmi.nav(elf)); | 12275 | const nav = ip.getNav(nmi.nav(elf)); |
| 12279 | try w.print("({f}, {f})", .{ | 12276 | try w.print("({f}, {f})", .{ |
| 12280 | Type.fromInterned(nav.resolved.?.type).fmt(.{ .zcu = zcu, .tid = tid }), | 12277 | Type.fromInterned(nav.resolved.?.type).fmt(zcu), |
| 12281 | nav.fqn.fmt(ip), | 12278 | nav.fqn.fmt(ip), |
| 12282 | }); | 12279 | }); |
| 12283 | }, | 12280 | }, |
| ... | @@ -12285,15 +12282,12 @@ pub fn printNode( | ... | @@ -12285,15 +12282,12 @@ pub fn printNode( |
| 12285 | const zcu = elf.base.comp.zcu.?; | 12282 | const zcu = elf.base.comp.zcu.?; |
| 12286 | const val: Value = .fromInterned(umi.uavValue(elf)); | 12283 | const val: Value = .fromInterned(umi.uavValue(elf)); |
| 12287 | try w.print("({f}, {f})", .{ | 12284 | try w.print("({f}, {f})", .{ |
| 12288 | val.typeOf(zcu).fmt(.{ .zcu = zcu, .tid = tid }), | 12285 | val.typeOf(zcu).fmt(zcu), |
| 12289 | val.fmtValue(.{ .zcu = zcu, .tid = tid }), | 12286 | val.fmtValue(zcu), |
| 12290 | }); | 12287 | }); |
| 12291 | }, | 12288 | }, |
| 12292 | inline .lazy_code, .lazy_const_data => |lmi| try w.print("({f})", .{ | 12289 | inline .lazy_code, .lazy_const_data => |lmi| try w.print("({f})", .{ |
| 12293 | Type.fromInterned(lmi.lazySymbol(elf).ty).fmt(.{ | 12290 | Type.fromInterned(lmi.lazySymbol(elf).ty).fmt(elf.base.comp.zcu.?), |
| 12294 | .zcu = elf.base.comp.zcu.?, | ||
| 12295 | .tid = tid, | ||
| 12296 | }), | ||
| 12297 | }), | 12291 | }), |
| 12298 | .debug_shared => |ss| try w.print("({})", .{ss}), | 12292 | .debug_shared => |ss| try w.print("({})", .{ss}), |
| 12299 | .unit_frame, | 12293 | .unit_frame, |
| ... | @@ -12308,7 +12302,7 @@ pub fn printNode( | ... | @@ -12308,7 +12302,7 @@ pub fn printNode( |
| 12308 | .const_debug_info => |cpi| switch (cpi.val(&elf.dwarf.const_pool)) { | 12302 | .const_debug_info => |cpi| switch (cpi.val(&elf.dwarf.const_pool)) { |
| 12309 | .generic_poison_type => try w.writeAll("(anytype)"), | 12303 | .generic_poison_type => try w.writeAll("(anytype)"), |
| 12310 | else => |val| try w.print("({f})", .{ | 12304 | else => |val| try w.print("({f})", .{ |
| 12311 | Value.fromInterned(val).fmtValue(.{ .zcu = elf.base.comp.zcu.?, .tid = tid }), | 12305 | Value.fromInterned(val).fmtValue(elf.base.comp.zcu.?), |
| 12312 | }), | 12306 | }), |
| 12313 | }, | 12307 | }, |
| 12314 | .global_debug_info => |gi| { | 12308 | .global_debug_info => |gi| { |
| ... | @@ -12317,11 +12311,11 @@ pub fn printNode( | ... | @@ -12317,11 +12311,11 @@ pub fn printNode( |
| 12317 | const nav = ip.getNav(gi.nav(&elf.dwarf)); | 12311 | const nav = ip.getNav(gi.nav(&elf.dwarf)); |
| 12318 | try w.writeByte('('); | 12312 | try w.writeByte('('); |
| 12319 | if (nav.resolved) |resolved| try w.print("{f}, ", .{ | 12313 | if (nav.resolved) |resolved| try w.print("{f}, ", .{ |
| 12320 | Type.fromInterned(resolved.type).fmt(.{ .zcu = zcu, .tid = tid }), | 12314 | Type.fromInterned(resolved.type).fmt(zcu), |
| 12321 | }); | 12315 | }); |
| 12322 | try w.print("{f}", .{nav.fqn.fmt(ip)}); | 12316 | try w.print("{f}", .{nav.fqn.fmt(ip)}); |
| 12323 | if (nav.resolved) |resolved| try w.print(", {f}", .{ | 12317 | if (nav.resolved) |resolved| try w.print(", {f}", .{ |
| 12324 | Value.fromInterned(resolved.value).fmtValue(.{ .zcu = zcu, .tid = tid }), | 12318 | Value.fromInterned(resolved.value).fmtValue(zcu), |
| 12325 | }); | 12319 | }); |
| 12326 | try w.writeByte(')'); | 12320 | try w.writeByte(')'); |
| 12327 | }, | 12321 | }, |
| ... | @@ -12331,7 +12325,7 @@ pub fn printNode( | ... | @@ -12331,7 +12325,7 @@ pub fn printNode( |
| 12331 | const nav = ip.getNav(fi.nav(&elf.dwarf)); | 12325 | const nav = ip.getNav(fi.nav(&elf.dwarf)); |
| 12332 | try w.writeByte('('); | 12326 | try w.writeByte('('); |
| 12333 | if (nav.resolved) |resolved| try w.print("{f}, ", .{ | 12327 | if (nav.resolved) |resolved| try w.print("{f}, ", .{ |
| 12334 | Type.fromInterned(resolved.type).fmt(.{ .zcu = zcu, .tid = tid }), | 12328 | Type.fromInterned(resolved.type).fmt(zcu), |
| 12335 | }); | 12329 | }); |
| 12336 | try w.print("{f})", .{nav.fqn.fmt(ip)}); | 12330 | try w.print("{f})", .{nav.fqn.fmt(ip)}); |
| 12337 | }, | 12331 | }, |
| ... | @@ -12366,7 +12360,7 @@ pub fn printNode( | ... | @@ -12366,7 +12360,7 @@ pub fn printNode( |
| 12366 | // non-leaf, just print children | 12360 | // non-leaf, just print children |
| 12367 | var child_ni = first_ni; | 12361 | var child_ni = first_ni; |
| 12368 | while (true) { | 12362 | while (true) { |
| 12369 | try elf.printNode(tid, w, child_ni, indent + 1); | 12363 | try elf.printNode(w, child_ni, indent + 1); |
| 12370 | child_ni = child_ni.next(&elf.mf).unwrap() orelse break; | 12364 | child_ni = child_ni.next(&elf.mf).unwrap() orelse break; |
| 12371 | } | 12365 | } |
| 12372 | return; | 12366 | return; |
src/link/MachO/ZigObject.zig+1-1| ... | @@ -1330,7 +1330,7 @@ fn updateLazySymbol( | ... | @@ -1330,7 +1330,7 @@ fn updateLazySymbol( |
| 1330 | const name_str = blk: { | 1330 | const name_str = blk: { |
| 1331 | const name = try std.fmt.allocPrint(gpa, "__lazy_{s}_{f}", .{ | 1331 | const name = try std.fmt.allocPrint(gpa, "__lazy_{s}_{f}", .{ |
| 1332 | @tagName(lazy_sym.kind), | 1332 | @tagName(lazy_sym.kind), |
| 1333 | Type.fromInterned(lazy_sym.ty).fmt(pt), | 1333 | Type.fromInterned(lazy_sym.ty).fmt(zcu), |
| 1334 | }); | 1334 | }); |
| 1335 | defer gpa.free(name); | 1335 | defer gpa.free(name); |
| 1336 | break :blk try self.addString(gpa, name); | 1336 | break :blk try self.addString(gpa, name); |
src/link/MachO2.zig+9-11| ... | @@ -1100,10 +1100,11 @@ pub fn flush( | ... | @@ -1100,10 +1100,11 @@ pub fn flush( |
| 1100 | ) link.Error!void { | 1100 | ) link.Error!void { |
| 1101 | const diags = &macho.base.comp.link_diags; | 1101 | const diags = &macho.base.comp.link_diags; |
| 1102 | _ = arena; | 1102 | _ = arena; |
| 1103 | _ = tid; | ||
| 1103 | _ = prog_node; | 1104 | _ = prog_node; |
| 1104 | 1105 | ||
| 1105 | try macho.updateSegmentLoadAddresses(); | 1106 | try macho.updateSegmentLoadAddresses(); |
| 1106 | while (try macho.idle(tid)) {} | 1107 | while (try macho.idle()) {} |
| 1107 | 1108 | ||
| 1108 | if (macho.lc.entry_point) |entry_point_lc| { | 1109 | if (macho.lc.entry_point) |entry_point_lc| { |
| 1109 | // TODO: actually find the entry point. | 1110 | // TODO: actually find the entry point. |
| ... | @@ -1120,7 +1121,7 @@ pub fn flush( | ... | @@ -1120,7 +1121,7 @@ pub fn flush( |
| 1120 | }; | 1121 | }; |
| 1121 | 1122 | ||
| 1122 | if (macho.options.enable_link_snapshots) | 1123 | if (macho.options.enable_link_snapshots) |
| 1123 | macho.dumpStderr(tid) catch |err| | 1124 | macho.dumpStderr() catch |err| |
| 1124 | return diags.fail("dumping link snapshot failed: {t}", .{err}); | 1125 | return diags.fail("dumping link snapshot failed: {t}", .{err}); |
| 1125 | } | 1126 | } |
| 1126 | pub fn updateErrorData(macho: *MachO, pt: Zcu.PerThread) link.Error!void { | 1127 | pub fn updateErrorData(macho: *MachO, pt: Zcu.PerThread) link.Error!void { |
| ... | @@ -1128,9 +1129,7 @@ pub fn updateErrorData(macho: *MachO, pt: Zcu.PerThread) link.Error!void { | ... | @@ -1128,9 +1129,7 @@ pub fn updateErrorData(macho: *MachO, pt: Zcu.PerThread) link.Error!void { |
| 1128 | _ = pt; | 1129 | _ = pt; |
| 1129 | @panic("TODO"); | 1130 | @panic("TODO"); |
| 1130 | } | 1131 | } |
| 1131 | pub fn idle(macho: *MachO, tid: Zcu.PerThread.Id) link.Error!bool { | 1132 | pub fn idle(macho: *MachO) link.Error!bool { |
| 1132 | _ = tid; | ||
| 1133 | |||
| 1134 | macho.mf.nodes_lock.lock(); | 1133 | macho.mf.nodes_lock.lock(); |
| 1135 | defer macho.mf.nodes_lock.unlock(); | 1134 | defer macho.mf.nodes_lock.unlock(); |
| 1136 | 1135 | ||
| ... | @@ -1253,28 +1252,27 @@ pub fn updateExports( | ... | @@ -1253,28 +1252,27 @@ pub fn updateExports( |
| 1253 | @panic("TODO"); | 1252 | @panic("TODO"); |
| 1254 | } | 1253 | } |
| 1255 | 1254 | ||
| 1256 | fn dumpStderr(macho: *MachO, tid: Zcu.PerThread.Id) Io.File.Writer.Error!void { | 1255 | fn dumpStderr(macho: *MachO) Io.File.Writer.Error!void { |
| 1257 | const comp = macho.base.comp; | 1256 | const comp = macho.base.comp; |
| 1258 | const io = comp.io; | 1257 | const io = comp.io; |
| 1259 | var buffer: [512]u8 = undefined; | 1258 | var buffer: [512]u8 = undefined; |
| 1260 | const stderr = try io.lockStderr(&buffer, null); | 1259 | const stderr = try io.lockStderr(&buffer, null); |
| 1261 | defer io.unlockStderr(); | 1260 | defer io.unlockStderr(); |
| 1262 | const w = &stderr.file_writer.interface; | 1261 | const w = &stderr.file_writer.interface; |
| 1263 | _ = macho.dump(w, tid) catch |err| switch (err) { | 1262 | _ = macho.dump(w) catch |err| switch (err) { |
| 1264 | error.WriteFailed => return stderr.file_writer.err.?, | 1263 | error.WriteFailed => return stderr.file_writer.err.?, |
| 1265 | }; | 1264 | }; |
| 1266 | } | 1265 | } |
| 1267 | 1266 | ||
| 1268 | pub fn dump(macho: *MachO, w: *Io.Writer, tid: Zcu.PerThread.Id) !link.File.DumpResult { | 1267 | pub fn dump(macho: *MachO, w: *Io.Writer) !link.File.DumpResult { |
| 1269 | if (macho.options.enable_link_snapshots) { | 1268 | if (macho.options.enable_link_snapshots) { |
| 1270 | try macho.printNode(tid, w, .root, 0); | 1269 | try macho.printNode(w, .root, 0); |
| 1271 | return .enabled; | 1270 | return .enabled; |
| 1272 | } | 1271 | } |
| 1273 | return .disabled; | 1272 | return .disabled; |
| 1274 | } | 1273 | } |
| 1275 | fn printNode( | 1274 | fn printNode( |
| 1276 | macho: *const MachO, | 1275 | macho: *const MachO, |
| 1277 | tid: Zcu.PerThread.Id, | ||
| 1278 | w: *Io.Writer, | 1276 | w: *Io.Writer, |
| 1279 | ni: MappedFile.Node.Index, | 1277 | ni: MappedFile.Node.Index, |
| 1280 | indent: usize, | 1278 | indent: usize, |
| ... | @@ -1310,7 +1308,7 @@ fn printNode( | ... | @@ -1310,7 +1308,7 @@ fn printNode( |
| 1310 | // non-leaf, just print children | 1308 | // non-leaf, just print children |
| 1311 | var child_ni = first_ni; | 1309 | var child_ni = first_ni; |
| 1312 | while (true) { | 1310 | while (true) { |
| 1313 | try macho.printNode(tid, w, child_ni, indent + 1); | 1311 | try macho.printNode(w, child_ni, indent + 1); |
| 1314 | child_ni = child_ni.next(&macho.mf).unwrap() orelse break; | 1312 | child_ni = child_ni.next(&macho.mf).unwrap() orelse break; |
| 1315 | } | 1313 | } |
| 1316 | return; | 1314 | return; |
src/link/Queue.zig+33-30| ... | @@ -17,7 +17,7 @@ | ... | @@ -17,7 +17,7 @@ |
| 17 | /// set to `null` by the main thread after it is canceled. It is not otherwise modified; as such, it | 17 | /// set to `null` by the main thread after it is canceled. It is not otherwise modified; as such, it |
| 18 | /// may be checked non-atomically. If a task is being queued and this is `null`, tasks must be run | 18 | /// may be checked non-atomically. If a task is being queued and this is `null`, tasks must be run |
| 19 | /// eagerly. | 19 | /// eagerly. |
| 20 | future: ?std.Io.Future(void), | 20 | future: ?std.Io.Future(Io.Cancelable!void), |
| 21 | 21 | ||
| 22 | /// This is only used if `future == null` during prelink. In that case, it is used to ensure that | 22 | /// This is only used if `future == null` during prelink. In that case, it is used to ensure that |
| 23 | /// only one prelink task is run at a time. | 23 | /// only one prelink task is run at a time. |
| ... | @@ -42,15 +42,15 @@ pub const empty: Queue = .{ | ... | @@ -42,15 +42,15 @@ pub const empty: Queue = .{ |
| 42 | 42 | ||
| 43 | pub fn cancel(q: *Queue, io: Io) void { | 43 | pub fn cancel(q: *Queue, io: Io) void { |
| 44 | if (q.future) |*f| { | 44 | if (q.future) |*f| { |
| 45 | f.cancel(io); | 45 | defer q.future = null; |
| 46 | q.future = null; | 46 | f.cancel(io) catch {}; |
| 47 | } | 47 | } |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | pub fn wait(q: *Queue, io: Io) void { | 50 | pub fn wait(q: *Queue, io: Io) Io.Cancelable!void { |
| 51 | if (q.future) |*f| { | 51 | if (q.future) |*f| { |
| 52 | f.await(io); | 52 | defer q.future = null; |
| 53 | q.future = null; | 53 | try f.await(io); |
| 54 | } | 54 | } |
| 55 | } | 55 | } |
| 56 | 56 | ||
| ... | @@ -107,11 +107,13 @@ pub fn enqueueZcu( | ... | @@ -107,11 +107,13 @@ pub fn enqueueZcu( |
| 107 | } else |err| switch (err) { | 107 | } else |err| switch (err) { |
| 108 | error.Canceled => |e| return e, | 108 | error.Canceled => |e| return e, |
| 109 | error.Closed => { | 109 | error.Closed => { |
| 110 | // The linker is still processing prelink tasks. Wait for those | 110 | // This path is hit if the backend does not support `Zcu.Feature.separate_thread`. |
| 111 | // to finish, after which the linker task will exist, and ZCU | 111 | // In that case, the linker processes *prelink* tasks on a thread, but once prelink |
| 112 | // tasks will be run non-concurrently. This logic exists for | 112 | // completes we want to move processing to the main thread for all ZCU tasks. To |
| 113 | // backends which do not support `Zcu.Feature.separate_thread`. | 113 | // achieve this, `Compilation.update` immmediately closes the ZCU task queue at the |
| 114 | q.wait(io); | 114 | // start of the update, causing `runLinkTasks` to exit as soon as prelink completes. |
| 115 | // So here we just need to wait for that, then fall back to the single-threaded path. | ||
| 116 | try q.wait(io); | ||
| 115 | }, | 117 | }, |
| 116 | } | 118 | } |
| 117 | } | 119 | } |
| ... | @@ -148,7 +150,7 @@ pub fn finishZcuQueue(q: *Queue, comp: *Compilation) void { | ... | @@ -148,7 +150,7 @@ pub fn finishZcuQueue(q: *Queue, comp: *Compilation) void { |
| 148 | } | 150 | } |
| 149 | } | 151 | } |
| 150 | 152 | ||
| 151 | fn runLinkTasks(q: *Queue, comp: *Compilation) void { | 153 | fn runLinkTasks(q: *Queue, comp: *Compilation) Io.Cancelable!void { |
| 152 | const io = comp.io; | 154 | const io = comp.io; |
| 153 | const tid: Zcu.PerThread.Id = .acquire(io); | 155 | const tid: Zcu.PerThread.Id = .acquire(io); |
| 154 | defer tid.release(io); | 156 | defer tid.release(io); |
| ... | @@ -159,12 +161,19 @@ fn runLinkTasks(q: *Queue, comp: *Compilation) void { | ... | @@ -159,12 +161,19 @@ fn runLinkTasks(q: *Queue, comp: *Compilation) void { |
| 159 | var task_buf: [128]PrelinkTask = undefined; | 161 | var task_buf: [128]PrelinkTask = undefined; |
| 160 | const limit: usize = if (have_idle_tasks) 0 else 1; | 162 | const limit: usize = if (have_idle_tasks) 0 else 1; |
| 161 | const n = q.prelink_queue.get(io, &task_buf, limit) catch |err| switch (err) { | 163 | const n = q.prelink_queue.get(io, &task_buf, limit) catch |err| switch (err) { |
| 162 | error.Canceled => return, | 164 | error.Canceled => |e| return e, |
| 163 | error.Closed => break :prelink_tasks, | 165 | error.Closed => break :prelink_tasks, |
| 164 | }; | 166 | }; |
| 165 | if (n == 0) { | 167 | if (n == 0) { |
| 166 | assert(have_idle_tasks); | 168 | assert(have_idle_tasks); |
| 167 | have_idle_tasks = runIdleTask(comp, tid); | 169 | have_idle_tasks = link.doIdleTask(comp) catch |err| switch (err) { |
| 170 | error.Canceled => |e| return e, | ||
| 171 | error.AlreadyReported => false, | ||
| 172 | error.OutOfMemory => more_idle_tasks: { | ||
| 173 | comp.link_diags.setAllocFailure(); | ||
| 174 | break :more_idle_tasks false; | ||
| 175 | }, | ||
| 176 | }; | ||
| 168 | } else for (task_buf[0..n]) |task| { | 177 | } else for (task_buf[0..n]) |task| { |
| 169 | link.doPrelinkTask(comp, task); | 178 | link.doPrelinkTask(comp, task); |
| 170 | have_idle_tasks = true; | 179 | have_idle_tasks = true; |
| ... | @@ -181,8 +190,8 @@ fn runLinkTasks(q: *Queue, comp: *Compilation) void { | ... | @@ -181,8 +190,8 @@ fn runLinkTasks(q: *Queue, comp: *Compilation) void { |
| 181 | break :prelink; | 190 | break :prelink; |
| 182 | } | 191 | } |
| 183 | lf.prelink() catch |err| switch (err) { | 192 | lf.prelink() catch |err| switch (err) { |
| 193 | error.Canceled => |e| return e, | ||
| 184 | error.OutOfMemory => comp.link_diags.setAllocFailure(), | 194 | error.OutOfMemory => comp.link_diags.setAllocFailure(), |
| 185 | error.Canceled => @panic("TODO"), | ||
| 186 | error.AlreadyReported => {}, | 195 | error.AlreadyReported => {}, |
| 187 | }; | 196 | }; |
| 188 | } | 197 | } |
| ... | @@ -191,31 +200,25 @@ fn runLinkTasks(q: *Queue, comp: *Compilation) void { | ... | @@ -191,31 +200,25 @@ fn runLinkTasks(q: *Queue, comp: *Compilation) void { |
| 191 | var task_buf: [128]ZcuTask = undefined; | 200 | var task_buf: [128]ZcuTask = undefined; |
| 192 | const limit: usize = if (have_idle_tasks) 0 else 1; | 201 | const limit: usize = if (have_idle_tasks) 0 else 1; |
| 193 | const n = q.zcu_queue.get(io, &task_buf, limit) catch |err| switch (err) { | 202 | const n = q.zcu_queue.get(io, &task_buf, limit) catch |err| switch (err) { |
| 194 | error.Canceled => return, | 203 | error.Canceled => |e| return e, |
| 195 | error.Closed => break :zcu_tasks, | 204 | error.Closed => break :zcu_tasks, |
| 196 | }; | 205 | }; |
| 197 | if (n == 0) { | 206 | if (n == 0) { |
| 198 | assert(have_idle_tasks); | 207 | assert(have_idle_tasks); |
| 199 | have_idle_tasks = runIdleTask(comp, tid); | 208 | have_idle_tasks = link.doIdleTask(comp) catch |err| switch (err) { |
| 209 | error.Canceled => |e| return e, | ||
| 210 | error.AlreadyReported => false, | ||
| 211 | error.OutOfMemory => more_idle_tasks: { | ||
| 212 | comp.link_diags.setAllocFailure(); | ||
| 213 | break :more_idle_tasks false; | ||
| 214 | }, | ||
| 215 | }; | ||
| 200 | } else for (task_buf[0..n]) |task| { | 216 | } else for (task_buf[0..n]) |task| { |
| 201 | link.doZcuTask(comp, tid, task); | 217 | link.doZcuTask(comp, tid, task); |
| 202 | have_idle_tasks = true; | 218 | have_idle_tasks = true; |
| 203 | } | 219 | } |
| 204 | } | 220 | } |
| 205 | } | 221 | } |
| 206 | fn runIdleTask(comp: *Compilation, tid: Zcu.PerThread.Id) bool { | ||
| 207 | return link.doIdleTask(comp, tid) catch |err| switch (err) { | ||
| 208 | error.OutOfMemory => have_more: { | ||
| 209 | comp.link_diags.setAllocFailure(); | ||
| 210 | break :have_more false; | ||
| 211 | }, | ||
| 212 | error.AlreadyReported => false, | ||
| 213 | error.Canceled => { | ||
| 214 | comp.io.recancel(); | ||
| 215 | return false; | ||
| 216 | }, | ||
| 217 | }; | ||
| 218 | } | ||
| 219 | 222 | ||
| 220 | const std = @import("std"); | 223 | const std = @import("std"); |
| 221 | const assert = std.debug.assert; | 224 | const assert = std.debug.assert; |
src/print_value.zig+121-122| ... | @@ -10,28 +10,29 @@ const InternPool = @import("InternPool.zig"); | ... | @@ -10,28 +10,29 @@ const InternPool = @import("InternPool.zig"); |
| 10 | const Allocator = std.mem.Allocator; | 10 | const Allocator = std.mem.Allocator; |
| 11 | const Target = std.Target; | 11 | const Target = std.Target; |
| 12 | const Writer = std.Io.Writer; | 12 | const Writer = std.Io.Writer; |
| 13 | const assert = std.debug.assert; | ||
| 13 | 14 | ||
| 14 | const max_aggregate_items = 100; | 15 | const max_aggregate_items = 100; |
| 15 | const max_string_len = 256; | 16 | const max_string_len = 256; |
| 16 | 17 | ||
| 17 | pub const FormatContext = struct { | 18 | pub const FormatContext = struct { |
| 18 | val: Value, | 19 | val: Value, |
| 19 | pt: Zcu.PerThread, | 20 | zcu: *Zcu, |
| 20 | opt_sema: ?*Sema, | 21 | opt_sema: ?*Sema, |
| 21 | depth: u8, | 22 | depth: u8, |
| 22 | }; | 23 | }; |
| 23 | 24 | ||
| 24 | pub fn formatSema(ctx: FormatContext, writer: *Writer) Writer.Error!void { | 25 | pub fn formatSema(ctx: FormatContext, writer: *Writer) Writer.Error!void { |
| 25 | const sema = ctx.opt_sema.?; | 26 | const sema = ctx.opt_sema.?; |
| 26 | return print(ctx.val, writer, ctx.depth, ctx.pt, sema) catch |err| switch (err) { | 27 | return print(ctx.val, writer, ctx.depth, ctx.zcu, sema) catch |err| switch (err) { |
| 27 | error.OutOfMemory => @panic("OOM"), // We're not allowed to return this from a format function | 28 | error.OutOfMemory => @panic("OOM"), // We're not allowed to return this from a format function |
| 28 | error.WriteFailed => |e| return e, | 29 | error.WriteFailed => |e| return e, |
| 29 | }; | 30 | }; |
| 30 | } | 31 | } |
| 31 | 32 | ||
| 32 | pub fn format(ctx: FormatContext, writer: *Writer) Writer.Error!void { | 33 | pub fn format(ctx: FormatContext, writer: *Writer) Writer.Error!void { |
| 33 | std.debug.assert(ctx.opt_sema == null); | 34 | assert(ctx.opt_sema == null); |
| 34 | return print(ctx.val, writer, ctx.depth, ctx.pt, null) catch |err| switch (err) { | 35 | return print(ctx.val, writer, ctx.depth, ctx.zcu, null) catch |err| switch (err) { |
| 35 | error.OutOfMemory => @panic("OOM"), // We're not allowed to return this from a format function | 36 | error.OutOfMemory => @panic("OOM"), // We're not allowed to return this from a format function |
| 36 | error.WriteFailed => |e| return e, | 37 | error.WriteFailed => |e| return e, |
| 37 | }; | 38 | }; |
| ... | @@ -41,10 +42,9 @@ pub fn print( | ... | @@ -41,10 +42,9 @@ pub fn print( |
| 41 | val: Value, | 42 | val: Value, |
| 42 | writer: *Writer, | 43 | writer: *Writer, |
| 43 | level: u8, | 44 | level: u8, |
| 44 | pt: Zcu.PerThread, | 45 | zcu: *Zcu, |
| 45 | opt_sema: ?*Sema, | 46 | opt_sema: ?*Sema, |
| 46 | ) (Writer.Error || Allocator.Error)!void { | 47 | ) (Writer.Error || Allocator.Error)!void { |
| 47 | const zcu = pt.zcu; | ||
| 48 | const ip = &zcu.intern_pool; | 48 | const ip = &zcu.intern_pool; |
| 49 | switch (ip.indexToKey(val.toIntern())) { | 49 | switch (ip.indexToKey(val.toIntern())) { |
| 50 | .int_type, | 50 | .int_type, |
| ... | @@ -64,7 +64,7 @@ pub fn print( | ... | @@ -64,7 +64,7 @@ pub fn print( |
| 64 | .func_type, | 64 | .func_type, |
| 65 | .error_set_type, | 65 | .error_set_type, |
| 66 | .inferred_error_set_type, | 66 | .inferred_error_set_type, |
| 67 | => try Type.print(val.toType(), writer, pt, null), | 67 | => try Type.print(val.toType(), writer, zcu, null), |
| 68 | .undef => try writer.writeAll("undefined"), | 68 | .undef => try writer.writeAll("undefined"), |
| 69 | .simple_value => |simple_value| switch (simple_value) { | 69 | .simple_value => |simple_value| switch (simple_value) { |
| 70 | .void => try writer.writeAll("{}"), | 70 | .void => try writer.writeAll("{}"), |
| ... | @@ -88,7 +88,7 @@ pub fn print( | ... | @@ -88,7 +88,7 @@ pub fn print( |
| 88 | .err_name => |err_name| try writer.print("error.{f}", .{ | 88 | .err_name => |err_name| try writer.print("error.{f}", .{ |
| 89 | err_name.fmt(ip), | 89 | err_name.fmt(ip), |
| 90 | }), | 90 | }), |
| 91 | .payload => |payload| try print(Value.fromInterned(payload), writer, level, pt, opt_sema), | 91 | .payload => |payload| try print(Value.fromInterned(payload), writer, level, zcu, opt_sema), |
| 92 | }, | 92 | }, |
| 93 | .enum_literal => |enum_literal| try writer.print(".{f}", .{ | 93 | .enum_literal => |enum_literal| try writer.print(".{f}", .{ |
| 94 | enum_literal.fmt(ip), | 94 | enum_literal.fmt(ip), |
| ... | @@ -101,7 +101,7 @@ pub fn print( | ... | @@ -101,7 +101,7 @@ pub fn print( |
| 101 | } | 101 | } |
| 102 | try writer.writeAll("@fromBackingInt("); | 102 | try writer.writeAll("@fromBackingInt("); |
| 103 | if (level == 0) return writer.writeAll("...)"); | 103 | if (level == 0) return writer.writeAll("...)"); |
| 104 | try print(.fromInterned(enum_tag.int), writer, level - 1, pt, opt_sema); | 104 | try print(.fromInterned(enum_tag.int), writer, level - 1, zcu, opt_sema); |
| 105 | try writer.writeAll(")"); | 105 | try writer.writeAll(")"); |
| 106 | }, | 106 | }, |
| 107 | .float => |float| switch (float.storage) { | 107 | .float => |float| switch (float.storage) { |
| ... | @@ -112,7 +112,7 @@ pub fn print( | ... | @@ -112,7 +112,7 @@ pub fn print( |
| 112 | if (slice.len == .zero_usize) { | 112 | if (slice.len == .zero_usize) { |
| 113 | return writer.writeAll("&.{}"); | 113 | return writer.writeAll("&.{}"); |
| 114 | } | 114 | } |
| 115 | try print(.fromInterned(slice.ptr), writer, level, pt, opt_sema); | 115 | try print(.fromInterned(slice.ptr), writer, level, zcu, opt_sema); |
| 116 | } else { | 116 | } else { |
| 117 | const print_contents = switch (ip.getBackingAddrTag(slice.ptr).?) { | 117 | const print_contents = switch (ip.getBackingAddrTag(slice.ptr).?) { |
| 118 | .field, .arr_elem, .eu_payload, .opt_payload => unreachable, | 118 | .field, .arr_elem, .eu_payload, .opt_payload => unreachable, |
| ... | @@ -123,13 +123,13 @@ pub fn print( | ... | @@ -123,13 +123,13 @@ pub fn print( |
| 123 | // TODO: eventually we want to load the slice as an array with `sema`, but that's | 123 | // TODO: eventually we want to load the slice as an array with `sema`, but that's |
| 124 | // currently not possible without e.g. triggering compile errors. | 124 | // currently not possible without e.g. triggering compile errors. |
| 125 | } | 125 | } |
| 126 | try printPtr(Value.fromInterned(slice.ptr), null, writer, level, pt, opt_sema); | 126 | try printPtr(Value.fromInterned(slice.ptr), null, writer, level, zcu, opt_sema); |
| 127 | } | 127 | } |
| 128 | try writer.writeAll("[0.."); | 128 | try writer.writeAll("[0.."); |
| 129 | if (level == 0) { | 129 | if (level == 0) { |
| 130 | try writer.writeAll("(...)"); | 130 | try writer.writeAll("(...)"); |
| 131 | } else { | 131 | } else { |
| 132 | try print(Value.fromInterned(slice.len), writer, level - 1, pt, opt_sema); | 132 | try print(Value.fromInterned(slice.len), writer, level - 1, zcu, opt_sema); |
| 133 | } | 133 | } |
| 134 | try writer.writeAll("]"); | 134 | try writer.writeAll("]"); |
| 135 | }, | 135 | }, |
| ... | @@ -143,28 +143,28 @@ pub fn print( | ... | @@ -143,28 +143,28 @@ pub fn print( |
| 143 | // TODO: eventually we want to load the pointer with `sema`, but that's | 143 | // TODO: eventually we want to load the pointer with `sema`, but that's |
| 144 | // currently not possible without e.g. triggering compile errors. | 144 | // currently not possible without e.g. triggering compile errors. |
| 145 | } | 145 | } |
| 146 | try printPtr(val, .rvalue, writer, level, pt, opt_sema); | 146 | try printPtr(val, .rvalue, writer, level, zcu, opt_sema); |
| 147 | }, | 147 | }, |
| 148 | .opt => |opt| switch (opt.val) { | 148 | .opt => |opt| switch (opt.val) { |
| 149 | .none => try writer.writeAll("null"), | 149 | .none => try writer.writeAll("null"), |
| 150 | else => |payload| try print(Value.fromInterned(payload), writer, level, pt, opt_sema), | 150 | else => |payload| try print(Value.fromInterned(payload), writer, level, zcu, opt_sema), |
| 151 | }, | 151 | }, |
| 152 | .aggregate => |aggregate| try printAggregate(val, aggregate, false, writer, level, pt, opt_sema), | 152 | .aggregate => |aggregate| try printAggregate(val, aggregate, false, writer, level, zcu, opt_sema), |
| 153 | .un => |un| { | 153 | .un => |un| { |
| 154 | if (level == 0) { | 154 | if (level == 0) { |
| 155 | try writer.writeAll(".{ ... }"); | 155 | try writer.writeAll(".{ ... }"); |
| 156 | return; | 156 | return; |
| 157 | } | 157 | } |
| 158 | if (un.tag == .none) { | 158 | if (un.tag == .none) { |
| 159 | const backing_ty = try val.typeOf(zcu).externUnionBackingType(pt); | 159 | const backing_val: Value = .fromInterned(un.val); |
| 160 | try writer.print("@bitCast(@as({f}, ", .{backing_ty.fmt(pt)}); | 160 | try writer.print("@bitCast(@as({f}, ", .{backing_val.typeOf(zcu).fmt(zcu)}); |
| 161 | try print(Value.fromInterned(un.val), writer, level - 1, pt, opt_sema); | 161 | try print(backing_val, writer, level - 1, zcu, opt_sema); |
| 162 | try writer.writeAll("))"); | 162 | try writer.writeAll("))"); |
| 163 | } else { | 163 | } else { |
| 164 | try writer.writeAll(".{ "); | 164 | try writer.writeAll(".{ "); |
| 165 | try print(Value.fromInterned(un.tag), writer, level - 1, pt, opt_sema); | 165 | try print(Value.fromInterned(un.tag), writer, level - 1, zcu, opt_sema); |
| 166 | try writer.writeAll(" = "); | 166 | try writer.writeAll(" = "); |
| 167 | try print(Value.fromInterned(un.val), writer, level - 1, pt, opt_sema); | 167 | try print(Value.fromInterned(un.val), writer, level - 1, zcu, opt_sema); |
| 168 | try writer.writeAll(" }"); | 168 | try writer.writeAll(" }"); |
| 169 | } | 169 | } |
| 170 | }, | 170 | }, |
| ... | @@ -173,35 +173,17 @@ pub fn print( | ... | @@ -173,35 +173,17 @@ pub fn print( |
| 173 | return writer.writeAll(".{ ... }"); | 173 | return writer.writeAll(".{ ... }"); |
| 174 | } | 174 | } |
| 175 | const ty: Type = .fromInterned(bitpack.ty); | 175 | const ty: Type = .fromInterned(bitpack.ty); |
| 176 | switch (ty.zigTypeTag(zcu)) { | 176 | switch (ty.backingIntMode(zcu)) { |
| 177 | .@"struct" => { | 177 | .auto => { |
| 178 | if (ty.structFieldCount(zcu) == 0) { | 178 | try writer.print("@bitCast(@as({f}, ", .{ty.backingIntType(zcu).fmt(zcu)}); |
| 179 | return writer.writeAll(".{}"); | 179 | try print(.fromInterned(bitpack.backing_int_val), writer, level - 1, zcu, opt_sema); |
| 180 | } | 180 | try writer.writeAll("))"); |
| 181 | try writer.writeAll(".{ "); | ||
| 182 | const max_len = @min(ty.structFieldCount(zcu), max_aggregate_items); | ||
| 183 | for (0..max_len) |i| { | ||
| 184 | if (i != 0) try writer.writeAll(", "); | ||
| 185 | const field_name = ty.structFieldName(@intCast(i), zcu).unwrap().?; | ||
| 186 | try writer.print(".{f} = ", .{field_name.fmt(ip)}); | ||
| 187 | try print(try val.fieldValue(pt, i), writer, level - 1, pt, opt_sema); | ||
| 188 | } | ||
| 189 | try writer.writeAll(" }"); | ||
| 190 | return; | ||
| 191 | }, | 181 | }, |
| 192 | .@"union" => switch (ty.backingIntMode(zcu)) { | 182 | .explicit => { |
| 193 | .auto => { | 183 | try writer.writeAll("@fromBackingInt("); |
| 194 | try writer.print("@bitCast(@as({f}, ", .{ty.backingIntType(zcu).fmt(pt)}); | 184 | try print(.fromInterned(bitpack.backing_int_val), writer, level - 1, zcu, opt_sema); |
| 195 | try print(.fromInterned(bitpack.backing_int_val), writer, level - 1, pt, opt_sema); | 185 | try writer.writeAll(")"); |
| 196 | try writer.writeAll("))"); | ||
| 197 | }, | ||
| 198 | .explicit => { | ||
| 199 | try writer.writeAll("@fromBackingInt("); | ||
| 200 | try print(.fromInterned(bitpack.backing_int_val), writer, level - 1, pt, opt_sema); | ||
| 201 | try writer.writeAll(")"); | ||
| 202 | }, | ||
| 203 | }, | 186 | }, |
| 204 | else => unreachable, | ||
| 205 | } | 187 | } |
| 206 | }, | 188 | }, |
| 207 | .memoized_call => unreachable, | 189 | .memoized_call => unreachable, |
| ... | @@ -214,14 +196,13 @@ fn printAggregate( | ... | @@ -214,14 +196,13 @@ fn printAggregate( |
| 214 | is_ref: bool, | 196 | is_ref: bool, |
| 215 | writer: *Writer, | 197 | writer: *Writer, |
| 216 | level: u8, | 198 | level: u8, |
| 217 | pt: Zcu.PerThread, | 199 | zcu: *Zcu, |
| 218 | opt_sema: ?*Sema, | 200 | opt_sema: ?*Sema, |
| 219 | ) (Writer.Error || Allocator.Error)!void { | 201 | ) (Writer.Error || Allocator.Error)!void { |
| 220 | if (level == 0) { | 202 | if (level == 0) { |
| 221 | if (is_ref) try writer.writeByte('&'); | 203 | if (is_ref) try writer.writeByte('&'); |
| 222 | return writer.writeAll(".{ ... }"); | 204 | return writer.writeAll(".{ ... }"); |
| 223 | } | 205 | } |
| 224 | const zcu = pt.zcu; | ||
| 225 | const ip = &zcu.intern_pool; | 206 | const ip = &zcu.intern_pool; |
| 226 | const ty = Type.fromInterned(aggregate.ty); | 207 | const ty = Type.fromInterned(aggregate.ty); |
| 227 | switch (ty.zigTypeTag(zcu)) { | 208 | switch (ty.zigTypeTag(zcu)) { |
| ... | @@ -236,7 +217,7 @@ fn printAggregate( | ... | @@ -236,7 +217,7 @@ fn printAggregate( |
| 236 | if (i != 0) try writer.writeAll(", "); | 217 | if (i != 0) try writer.writeAll(", "); |
| 237 | const field_name = ty.structFieldName(@intCast(i), zcu).unwrap().?; | 218 | const field_name = ty.structFieldName(@intCast(i), zcu).unwrap().?; |
| 238 | try writer.print(".{f} = ", .{field_name.fmt(ip)}); | 219 | try writer.print(".{f} = ", .{field_name.fmt(ip)}); |
| 239 | try print(try val.fieldValue(pt, i), writer, level - 1, pt, opt_sema); | 220 | try printFieldValue(val, i, writer, level - 1, zcu, opt_sema); |
| 240 | } | 221 | } |
| 241 | try writer.writeAll(" }"); | 222 | try writer.writeAll(" }"); |
| 242 | return; | 223 | return; |
| ... | @@ -285,7 +266,7 @@ fn printAggregate( | ... | @@ -285,7 +266,7 @@ fn printAggregate( |
| 285 | 0 => try writer.writeAll(".{}"), | 266 | 0 => try writer.writeAll(".{}"), |
| 286 | 1 => { | 267 | 1 => { |
| 287 | try writer.writeAll(".{"); | 268 | try writer.writeAll(".{"); |
| 288 | try print(try val.fieldValue(pt, 0), writer, level - 1, pt, opt_sema); | 269 | try printFieldValue(val, 0, writer, level - 1, zcu, opt_sema); |
| 289 | try writer.writeByte('}'); | 270 | try writer.writeByte('}'); |
| 290 | }, | 271 | }, |
| 291 | else => { | 272 | else => { |
| ... | @@ -293,7 +274,7 @@ fn printAggregate( | ... | @@ -293,7 +274,7 @@ fn printAggregate( |
| 293 | const max_len = @min(len, max_aggregate_items); | 274 | const max_len = @min(len, max_aggregate_items); |
| 294 | for (0..max_len) |i| { | 275 | for (0..max_len) |i| { |
| 295 | if (i != 0) try writer.writeAll(", "); | 276 | if (i != 0) try writer.writeAll(", "); |
| 296 | try print(try val.fieldValue(pt, i), writer, level - 1, pt, opt_sema); | 277 | try printFieldValue(val, i, writer, level - 1, zcu, opt_sema); |
| 297 | } | 278 | } |
| 298 | if (len > max_aggregate_items) { | 279 | if (len > max_aggregate_items) { |
| 299 | try writer.writeAll(", ..."); | 280 | try writer.writeAll(", ..."); |
| ... | @@ -303,16 +284,40 @@ fn printAggregate( | ... | @@ -303,16 +284,40 @@ fn printAggregate( |
| 303 | } | 284 | } |
| 304 | } | 285 | } |
| 305 | 286 | ||
| 287 | /// We cannot use `aggregate_val.fieldValue(...)` here because for some representations of aggregate | ||
| 288 | /// values the individual field values may not yet be in the `InternPool`. So, this function is the | ||
| 289 | /// equivalent of doing `print(try aggregate_val.fieldValue(...))`, which understands the optimized | ||
| 290 | /// value representations so does not need to intern new values. | ||
| 291 | fn printFieldValue( | ||
| 292 | aggregate_val: Value, | ||
| 293 | field_index: usize, | ||
| 294 | writer: *Writer, | ||
| 295 | level: u8, | ||
| 296 | zcu: *Zcu, | ||
| 297 | opt_sema: ?*Sema, | ||
| 298 | ) (Writer.Error || Allocator.Error)!void { | ||
| 299 | const ip = &zcu.intern_pool; | ||
| 300 | switch (ip.indexToKey(aggregate_val.toIntern())) { | ||
| 301 | .undef => try writer.writeAll("undefined"), | ||
| 302 | .aggregate => |aggregate| switch (aggregate.storage) { | ||
| 303 | .bytes => |bytes| try writer.print("{d}", .{bytes.at(field_index, ip)}), | ||
| 304 | .elems => |elems| try print(.fromInterned(elems[field_index]), writer, level, zcu, opt_sema), | ||
| 305 | .repeated_elem => |elem| try print(.fromInterned(elem), writer, level, zcu, opt_sema), | ||
| 306 | }, | ||
| 307 | else => unreachable, | ||
| 308 | } | ||
| 309 | } | ||
| 310 | |||
| 306 | fn printPtr( | 311 | fn printPtr( |
| 307 | ptr_val: Value, | 312 | ptr_val: Value, |
| 308 | /// Whether to print `derivation` as an lvalue or rvalue. If `null`, the more concise option is chosen. | 313 | /// Whether to print `derivation` as an lvalue or rvalue. If `null`, the more concise option is chosen. |
| 309 | want_kind: ?PrintPtrKind, | 314 | want_kind: ?PrintPtrKind, |
| 310 | writer: *Writer, | 315 | writer: *Writer, |
| 311 | level: u8, | 316 | level: u8, |
| 312 | pt: Zcu.PerThread, | 317 | zcu: *Zcu, |
| 313 | opt_sema: ?*Sema, | 318 | opt_sema: ?*Sema, |
| 314 | ) (Writer.Error || Allocator.Error)!void { | 319 | ) (Writer.Error || Allocator.Error)!void { |
| 315 | const ptr = switch (pt.zcu.intern_pool.indexToKey(ptr_val.toIntern())) { | 320 | const ptr = switch (zcu.intern_pool.indexToKey(ptr_val.toIntern())) { |
| 316 | .undef => return writer.writeAll("undefined"), | 321 | .undef => return writer.writeAll("undefined"), |
| 317 | .ptr => |ptr| ptr, | 322 | .ptr => |ptr| ptr, |
| 318 | else => unreachable, | 323 | else => unreachable, |
| ... | @@ -320,25 +325,25 @@ fn printPtr( | ... | @@ -320,25 +325,25 @@ fn printPtr( |
| 320 | 325 | ||
| 321 | if (ptr.base_addr == .uav) { | 326 | if (ptr.base_addr == .uav) { |
| 322 | // If the value is an aggregate, we can potentially print it more nicely. | 327 | // If the value is an aggregate, we can potentially print it more nicely. |
| 323 | switch (pt.zcu.intern_pool.indexToKey(ptr.base_addr.uav.val)) { | 328 | switch (zcu.intern_pool.indexToKey(ptr.base_addr.uav.val)) { |
| 324 | .aggregate => |agg| return printAggregate( | 329 | .aggregate => |agg| return printAggregate( |
| 325 | Value.fromInterned(ptr.base_addr.uav.val), | 330 | Value.fromInterned(ptr.base_addr.uav.val), |
| 326 | agg, | 331 | agg, |
| 327 | true, | 332 | true, |
| 328 | writer, | 333 | writer, |
| 329 | level, | 334 | level, |
| 330 | pt, | 335 | zcu, |
| 331 | opt_sema, | 336 | opt_sema, |
| 332 | ), | 337 | ), |
| 333 | else => {}, | 338 | else => {}, |
| 334 | } | 339 | } |
| 335 | } | 340 | } |
| 336 | 341 | ||
| 337 | var arena = std.heap.ArenaAllocator.init(pt.zcu.gpa); | 342 | var arena = std.heap.ArenaAllocator.init(zcu.gpa); |
| 338 | defer arena.deinit(); | 343 | defer arena.deinit(); |
| 339 | const derivation = try ptr_val.pointerDerivation(arena.allocator(), pt, opt_sema); | 344 | const derivation = try ptr_val.pointerDerivation(arena.allocator(), zcu, opt_sema); |
| 340 | 345 | ||
| 341 | _ = try printPtrDerivation(derivation, writer, pt, want_kind, .{ .print_val = .{ | 346 | _ = try printPtrDerivation(derivation, writer, zcu, want_kind, .{ .print_val = .{ |
| 342 | .level = level, | 347 | .level = level, |
| 343 | .opt_sema = opt_sema, | 348 | .opt_sema = opt_sema, |
| 344 | } }, 20); | 349 | } }, 20); |
| ... | @@ -349,9 +354,9 @@ const PrintPtrKind = enum { lvalue, rvalue }; | ... | @@ -349,9 +354,9 @@ const PrintPtrKind = enum { lvalue, rvalue }; |
| 349 | /// Print the pointer defined by `derivation` as an lvalue or an rvalue. | 354 | /// Print the pointer defined by `derivation` as an lvalue or an rvalue. |
| 350 | /// Returns the root derivation, which may be ignored. | 355 | /// Returns the root derivation, which may be ignored. |
| 351 | pub fn printPtrDerivation( | 356 | pub fn printPtrDerivation( |
| 352 | derivation: Value.PointerDeriveStep, | 357 | derivation: Value.PointerDerivation, |
| 353 | writer: *Writer, | 358 | writer: *Writer, |
| 354 | pt: Zcu.PerThread, | 359 | zcu: *Zcu, |
| 355 | /// Whether to print `derivation` as an lvalue or rvalue. If `null`, the more concise option is chosen. | 360 | /// Whether to print `derivation` as an lvalue or rvalue. If `null`, the more concise option is chosen. |
| 356 | /// If this is `.rvalue`, the result may look like `&foo`, so it's not necessarily valid to treat it as | 361 | /// If this is `.rvalue`, the result may look like `&foo`, so it's not necessarily valid to treat it as |
| 357 | /// an atom -- e.g. `&foo.*` is distinct from `(&foo).*`. | 362 | /// an atom -- e.g. `&foo.*` is distinct from `(&foo).*`. |
| ... | @@ -368,33 +373,36 @@ pub fn printPtrDerivation( | ... | @@ -368,33 +373,36 @@ pub fn printPtrDerivation( |
| 368 | /// The maximum recursion depth. We can never recurse infinitely here, but the depth can be arbitrary, | 373 | /// The maximum recursion depth. We can never recurse infinitely here, but the depth can be arbitrary, |
| 369 | /// so at this depth we just write "..." to prevent stack overflow. | 374 | /// so at this depth we just write "..." to prevent stack overflow. |
| 370 | ptr_depth: u8, | 375 | ptr_depth: u8, |
| 371 | ) !Value.PointerDeriveStep { | 376 | ) !Value.PointerDerivation { |
| 372 | const zcu = pt.zcu; | ||
| 373 | const ip = &zcu.intern_pool; | 377 | const ip = &zcu.intern_pool; |
| 374 | 378 | ||
| 375 | if (ptr_depth == 0) { | 379 | if (ptr_depth == 0) { |
| 376 | const root_step = root: switch (derivation) { | 380 | var root_step = derivation; |
| 377 | inline .eu_payload_ptr, | 381 | while (true) { |
| 378 | .opt_payload_ptr, | 382 | switch (derivation.addr) { |
| 379 | .field_ptr, | 383 | inline .eu_payload, |
| 380 | .elem_ptr, | 384 | .opt_payload, |
| 381 | .offset_and_cast, | 385 | .field, |
| 382 | => |step| continue :root step.parent.*, | 386 | .elem, |
| 383 | else => |step| break :root step, | 387 | .offset_and_cast, |
| 384 | }; | 388 | => |derived| root_step = derived.parent.*, |
| 389 | |||
| 390 | .int, .nav, .uav, .comptime_alloc, .comptime_field => break, | ||
| 391 | } | ||
| 392 | } | ||
| 385 | try writer.writeAll("..."); | 393 | try writer.writeAll("..."); |
| 386 | return root_step; | 394 | return root_step; |
| 387 | } | 395 | } |
| 388 | 396 | ||
| 389 | const result_kind: PrintPtrKind = switch (derivation) { | 397 | const result_kind: PrintPtrKind = switch (derivation.addr) { |
| 390 | .nav_ptr, | 398 | .nav, |
| 391 | .uav_ptr, | 399 | .uav, |
| 392 | .comptime_alloc_ptr, | 400 | .comptime_alloc, |
| 393 | .comptime_field_ptr, | 401 | .comptime_field, |
| 394 | .eu_payload_ptr, | 402 | .eu_payload, |
| 395 | .opt_payload_ptr, | 403 | .opt_payload, |
| 396 | .field_ptr, | 404 | .field, |
| 397 | .elem_ptr, | 405 | .elem, |
| 398 | => .lvalue, | 406 | => .lvalue, |
| 399 | 407 | ||
| 400 | .offset_and_cast, | 408 | .offset_and_cast, |
| ... | @@ -409,33 +417,33 @@ pub fn printPtrDerivation( | ... | @@ -409,33 +417,33 @@ pub fn printPtrDerivation( |
| 409 | } | 417 | } |
| 410 | 418 | ||
| 411 | // null if `derivation` is the root. | 419 | // null if `derivation` is the root. |
| 412 | const root_or_null: ?Value.PointerDeriveStep = switch (derivation) { | 420 | const root_or_null: ?Value.PointerDerivation = switch (derivation.addr) { |
| 413 | .eu_payload_ptr => |info| root: { | 421 | .eu_payload => |info| root: { |
| 414 | try writer.writeByte('('); | 422 | try writer.writeByte('('); |
| 415 | const root = try printPtrDerivation(info.parent.*, writer, pt, .lvalue, root_strat, ptr_depth - 1); | 423 | const root = try printPtrDerivation(info.parent.*, writer, zcu, .lvalue, root_strat, ptr_depth - 1); |
| 416 | try writer.writeAll(" catch unreachable)"); | 424 | try writer.writeAll(" catch unreachable)"); |
| 417 | break :root root; | 425 | break :root root; |
| 418 | }, | 426 | }, |
| 419 | .opt_payload_ptr => |info| root: { | 427 | .opt_payload => |info| root: { |
| 420 | const root = try printPtrDerivation(info.parent.*, writer, pt, .lvalue, root_strat, ptr_depth - 1); | 428 | const root = try printPtrDerivation(info.parent.*, writer, zcu, .lvalue, root_strat, ptr_depth - 1); |
| 421 | try writer.writeAll(".?"); | 429 | try writer.writeAll(".?"); |
| 422 | break :root root; | 430 | break :root root; |
| 423 | }, | 431 | }, |
| 424 | .field_ptr => |field| root: { | 432 | .field => |derived| root: { |
| 425 | const root = try printPtrDerivation(field.parent.*, writer, pt, null, root_strat, ptr_depth - 1); | 433 | const root = try printPtrDerivation(derived.parent.*, writer, zcu, null, root_strat, ptr_depth - 1); |
| 426 | const agg_ty = (try field.parent.ptrType(pt)).childType(zcu); | 434 | const agg_ty = derived.parent.elem_ty; |
| 427 | switch (agg_ty.zigTypeTag(zcu)) { | 435 | switch (agg_ty.zigTypeTag(zcu)) { |
| 428 | .@"struct" => if (agg_ty.structFieldName(field.field_idx, zcu).unwrap()) |field_name| { | 436 | .@"struct" => if (agg_ty.structFieldName(derived.field_index, zcu).unwrap()) |field_name| { |
| 429 | try writer.print(".{f}", .{field_name.fmt(ip)}); | 437 | try writer.print(".{f}", .{field_name.fmt(ip)}); |
| 430 | } else { | 438 | } else { |
| 431 | try writer.print("[{d}]", .{field.field_idx}); | 439 | try writer.print("[{d}]", .{derived.field_index}); |
| 432 | }, | 440 | }, |
| 433 | .@"union" => { | 441 | .@"union" => { |
| 434 | const tag_ty = agg_ty.unionTagTypeHypothetical(zcu); | 442 | const tag_ty = agg_ty.unionTagTypeHypothetical(zcu); |
| 435 | const field_name = tag_ty.enumFieldName(field.field_idx, zcu); | 443 | const field_name = tag_ty.enumFieldName(derived.field_index, zcu); |
| 436 | try writer.print(".{f}", .{field_name.fmt(ip)}); | 444 | try writer.print(".{f}", .{field_name.fmt(ip)}); |
| 437 | }, | 445 | }, |
| 438 | .pointer => switch (field.field_idx) { | 446 | .pointer => switch (derived.field_index) { |
| 439 | Value.slice_ptr_index => try writer.writeAll(".ptr"), | 447 | Value.slice_ptr_index => try writer.writeAll(".ptr"), |
| 440 | Value.slice_len_index => try writer.writeAll(".len"), | 448 | Value.slice_len_index => try writer.writeAll(".len"), |
| 441 | else => unreachable, | 449 | else => unreachable, |
| ... | @@ -444,58 +452,49 @@ pub fn printPtrDerivation( | ... | @@ -444,58 +452,49 @@ pub fn printPtrDerivation( |
| 444 | } | 452 | } |
| 445 | break :root root; | 453 | break :root root; |
| 446 | }, | 454 | }, |
| 447 | .elem_ptr => |elem| root: { | 455 | .elem => |derived| root: { |
| 448 | const root = try printPtrDerivation(elem.parent.*, writer, pt, null, root_strat, ptr_depth - 1); | 456 | const root = try printPtrDerivation(derived.parent.*, writer, zcu, null, root_strat, ptr_depth - 1); |
| 449 | try writer.print("[{d}]", .{elem.elem_idx}); | 457 | try writer.print("[{d}]", .{derived.elem_index}); |
| 450 | break :root root; | 458 | break :root root; |
| 451 | }, | 459 | }, |
| 452 | 460 | ||
| 453 | .offset_and_cast => |oac| if (oac.byte_offset == 0) root: { | 461 | .offset_and_cast => |derived| if (derived.byte_offset == 0) root: { |
| 454 | try writer.print("@as({f}, @ptrCast(", .{oac.new_ptr_ty.fmt(pt)}); | 462 | try writer.print("@as({f}, @ptrCast(", .{derivation.fmtType(zcu)}); |
| 455 | const root = try printPtrDerivation(oac.parent.*, writer, pt, .rvalue, root_strat, ptr_depth - 1); | 463 | const root = try printPtrDerivation(derived.parent.*, writer, zcu, .rvalue, root_strat, ptr_depth - 1); |
| 456 | try writer.writeAll("))"); | 464 | try writer.writeAll("))"); |
| 457 | break :root root; | 465 | break :root root; |
| 458 | } else root: { | 466 | } else root: { |
| 459 | try writer.print("@as({f}, @ptrFromInt(@intFromPtr(", .{oac.new_ptr_ty.fmt(pt)}); | 467 | try writer.print("@as({f}, @ptrFromInt(@intFromPtr(", .{derivation.fmtType(zcu)}); |
| 460 | const root = try printPtrDerivation(oac.parent.*, writer, pt, .rvalue, root_strat, ptr_depth - 1); | 468 | const root = try printPtrDerivation(derived.parent.*, writer, zcu, .rvalue, root_strat, ptr_depth - 1); |
| 461 | try writer.print(") + {d}))", .{oac.byte_offset}); | 469 | try writer.print(") + {d}))", .{derived.byte_offset}); |
| 462 | break :root root; | 470 | break :root root; |
| 463 | }, | 471 | }, |
| 464 | 472 | ||
| 465 | .int, .nav_ptr, .uav_ptr, .comptime_alloc_ptr, .comptime_field_ptr => null, | 473 | .int, .nav, .uav, .comptime_alloc, .comptime_field => null, |
| 466 | }; | 474 | }; |
| 467 | 475 | ||
| 468 | if (root_or_null == null) switch (root_strat) { | 476 | if (root_or_null == null) switch (root_strat) { |
| 469 | .str => |x| try writer.writeAll(x), | 477 | .str => |x| try writer.writeAll(x), |
| 470 | .print_val => |x| switch (derivation) { | 478 | .print_val => |x| switch (derivation.addr) { |
| 471 | .int => |int| try writer.print("@as({f}, @ptrFromInt(0x{x}))", .{ int.ptr_ty.fmt(pt), int.addr }), | 479 | .int => |int| { |
| 472 | .nav_ptr => |nav| try writer.print("{f}", .{ip.getNav(nav).fqn.fmt(ip)}), | 480 | try writer.print("@as({f}, @ptrFromInt(0x{x}))", .{ derivation.fmtType(zcu), int }); |
| 473 | .uav_ptr => |uav| { | ||
| 474 | const ty = Value.fromInterned(uav.val).typeOf(zcu); | ||
| 475 | try writer.print("@as({f}, ", .{ty.fmt(pt)}); | ||
| 476 | if (x.level == 0) { | ||
| 477 | try writer.writeAll("..."); | ||
| 478 | } else { | ||
| 479 | try print(Value.fromInterned(uav.val), writer, x.level - 1, pt, x.opt_sema); | ||
| 480 | } | ||
| 481 | try writer.writeByte(')'); | ||
| 482 | }, | 481 | }, |
| 483 | .comptime_alloc_ptr => |info| { | 482 | .nav => |nav| try writer.print("{f}", .{ip.getNav(nav).fqn.fmt(ip)}), |
| 484 | try writer.print("@as({f}, ", .{info.val.typeOf(zcu).fmt(pt)}); | 483 | .uav, .comptime_field => |val| { |
| 484 | try writer.print("@as({f}, ", .{derivation.elem_ty.fmt(zcu)}); | ||
| 485 | if (x.level == 0) { | 485 | if (x.level == 0) { |
| 486 | try writer.writeAll("..."); | 486 | try writer.writeAll("..."); |
| 487 | } else { | 487 | } else { |
| 488 | try print(info.val, writer, x.level - 1, pt, x.opt_sema); | 488 | try print(val, writer, x.level - 1, zcu, x.opt_sema); |
| 489 | } | 489 | } |
| 490 | try writer.writeByte(')'); | 490 | try writer.writeByte(')'); |
| 491 | }, | 491 | }, |
| 492 | .comptime_field_ptr => |val| { | 492 | .comptime_alloc => |info| { |
| 493 | const ty = val.typeOf(zcu); | 493 | try writer.print("@as({f}, ", .{derivation.elem_ty.fmt(zcu)}); |
| 494 | try writer.print("@as({f}, ", .{ty.fmt(pt)}); | ||
| 495 | if (x.level == 0) { | 494 | if (x.level == 0) { |
| 496 | try writer.writeAll("..."); | 495 | try writer.writeAll("..."); |
| 497 | } else { | 496 | } else { |
| 498 | try print(val, writer, x.level - 1, pt, x.opt_sema); | 497 | try print(info.val, writer, x.level - 1, zcu, x.opt_sema); |
| 499 | } | 498 | } |
| 500 | try writer.writeByte(')'); | 499 | try writer.writeByte(')'); |
| 501 | }, | 500 | }, |