| author | |
| committer | |
| log | 941bc3719382a4f6245ad42175d911964f1bc9a4 |
| tree | f17c7a8b9afb241b7de4f43973bea882cb06bf2d |
| parent | 49be02e6d75acd996d9b2a573714552ba081ea13 |
29 files changed, 699 insertions(+), 1137 deletions(-)
lib/compiler/aro/aro/Diagnostics.zig+3-3| ... | ... | @@ -542,15 +542,15 @@ const MsgWriter = struct { |
| 542 | 542 | } |
| 543 | 543 | |
| 544 | 544 | pub fn print(m: *MsgWriter, comptime fmt: []const u8, args: anytype) void { |
| 545 | m.w.writer().print(fmt, args) catch {}; | |
| 545 | m.w.interface.print(fmt, args) catch {}; | |
| 546 | 546 | } |
| 547 | 547 | |
| 548 | 548 | fn write(m: *MsgWriter, msg: []const u8) void { |
| 549 | m.w.writer().writeAll(msg) catch {}; | |
| 549 | m.w.interface.writeAll(msg) catch {}; | |
| 550 | 550 | } |
| 551 | 551 | |
| 552 | 552 | fn setColor(m: *MsgWriter, color: std.io.tty.Color) void { |
| 553 | m.config.setColor(m.w.writer(), color) catch {}; | |
| 553 | m.config.setColor(m.w.interface, color) catch {}; | |
| 554 | 554 | } |
| 555 | 555 | |
| 556 | 556 | fn location(m: *MsgWriter, path: []const u8, line: u32, col: u32) void { |
src/Compilation.zig+2-4| ... | ... | @@ -6012,9 +6012,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32 |
| 6012 | 6012 | |
| 6013 | 6013 | // In .rc files, a " within a quoted string is escaped as "" |
| 6014 | 6014 | const fmtRcEscape = struct { |
| 6015 | fn formatRcEscape(bytes: []const u8, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void { | |
| 6016 | _ = fmt; | |
| 6017 | _ = options; | |
| 6015 | fn formatRcEscape(bytes: []const u8, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 6018 | 6016 | for (bytes) |byte| switch (byte) { |
| 6019 | 6017 | '"' => try writer.writeAll("\"\""), |
| 6020 | 6018 | '\\' => try writer.writeAll("\\\\"), |
| ... | ... | @@ -6022,7 +6020,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32 |
| 6022 | 6020 | }; |
| 6023 | 6021 | } |
| 6024 | 6022 | |
| 6025 | pub fn fmtRcEscape(bytes: []const u8) std.fmt.Formatter(formatRcEscape) { | |
| 6023 | pub fn fmtRcEscape(bytes: []const u8) std.fmt.Formatter([]const u8, formatRcEscape) { | |
| 6026 | 6024 | return .{ .data = bytes }; |
| 6027 | 6025 | } |
| 6028 | 6026 | }.fmtRcEscape; |
src/Type.zig+10-25| ... | ... | @@ -121,15 +121,14 @@ pub fn eql(a: Type, b: Type, zcu: *const Zcu) bool { |
| 121 | 121 | return a.toIntern() == b.toIntern(); |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | pub fn format(ty: Type, comptime unused_fmt_string: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void { | |
| 124 | pub fn format(ty: Type, writer: *std.io.Writer, comptime unused_fmt_string: []const u8) !void { | |
| 125 | 125 | _ = ty; |
| 126 | 126 | _ = unused_fmt_string; |
| 127 | _ = options; | |
| 128 | 127 | _ = writer; |
| 129 | 128 | @compileError("do not format types directly; use either ty.fmtDebug() or ty.fmt()"); |
| 130 | 129 | } |
| 131 | 130 | |
| 132 | pub const Formatter = std.fmt.Formatter(format2); | |
| 131 | pub const Formatter = std.fmt.Formatter(Format, Format.default); | |
| 133 | 132 | |
| 134 | 133 | pub fn fmt(ty: Type, pt: Zcu.PerThread) Formatter { |
| 135 | 134 | return .{ .data = .{ |
| ... | ... | @@ -138,42 +137,28 @@ pub fn fmt(ty: Type, pt: Zcu.PerThread) Formatter { |
| 138 | 137 | } }; |
| 139 | 138 | } |
| 140 | 139 | |
| 141 | const FormatContext = struct { | |
| 140 | const Format = struct { | |
| 142 | 141 | ty: Type, |
| 143 | 142 | pt: Zcu.PerThread, |
| 144 | }; | |
| 145 | 143 | |
| 146 | fn format2( | |
| 147 | ctx: FormatContext, | |
| 148 | comptime unused_format_string: []const u8, | |
| 149 | options: std.fmt.FormatOptions, | |
| 150 | writer: anytype, | |
| 151 | ) !void { | |
| 152 | comptime assert(unused_format_string.len == 0); | |
| 153 | _ = options; | |
| 154 | return print(ctx.ty, writer, ctx.pt); | |
| 155 | } | |
| 144 | fn default(f: Format, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 145 | return print(f.ty, writer, f.pt); | |
| 146 | } | |
| 147 | }; | |
| 156 | 148 | |
| 157 | pub fn fmtDebug(ty: Type) std.fmt.Formatter(dump) { | |
| 149 | pub fn fmtDebug(ty: Type) std.fmt.Formatter(Type, dump) { | |
| 158 | 150 | return .{ .data = ty }; |
| 159 | 151 | } |
| 160 | 152 | |
| 161 | 153 | /// This is a debug function. In order to print types in a meaningful way |
| 162 | 154 | /// we also need access to the module. |
| 163 | pub fn dump( | |
| 164 | start_type: Type, | |
| 165 | comptime unused_format_string: []const u8, | |
| 166 | options: std.fmt.FormatOptions, | |
| 167 | writer: anytype, | |
| 168 | ) @TypeOf(writer).Error!void { | |
| 169 | _ = options; | |
| 170 | comptime assert(unused_format_string.len == 0); | |
| 155 | pub fn dump(start_type: Type, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 171 | 156 | return writer.print("{any}", .{start_type.ip_index}); |
| 172 | 157 | } |
| 173 | 158 | |
| 174 | 159 | /// Prints a name suitable for `@typeName`. |
| 175 | 160 | /// TODO: take an `opt_sema` to pass to `fmtValue` when printing sentinels. |
| 176 | pub fn print(ty: Type, writer: anytype, pt: Zcu.PerThread) @TypeOf(writer).Error!void { | |
| 161 | pub fn print(ty: Type, writer: *std.io.Writer, pt: Zcu.PerThread) std.io.Writer.Error!void { | |
| 177 | 162 | const zcu = pt.zcu; |
| 178 | 163 | const ip = &zcu.intern_pool; |
| 179 | 164 | switch (ip.indexToKey(ty.toIntern())) { |
src/Value.zig+8-15| ... | ... | @@ -15,31 +15,24 @@ const Value = @This(); |
| 15 | 15 | |
| 16 | 16 | ip_index: InternPool.Index, |
| 17 | 17 | |
| 18 | pub fn format(val: Value, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void { | |
| 18 | pub fn format(val: Value, writer: *std.io.Writer, comptime fmt: []const u8) !void { | |
| 19 | 19 | _ = val; |
| 20 | _ = fmt; | |
| 21 | _ = options; | |
| 22 | 20 | _ = writer; |
| 21 | _ = fmt; | |
| 23 | 22 | @compileError("do not use format values directly; use either fmtDebug or fmtValue"); |
| 24 | 23 | } |
| 25 | 24 | |
| 26 | 25 | /// This is a debug function. In order to print values in a meaningful way |
| 27 | 26 | /// we also need access to the type. |
| 28 | pub fn dump( | |
| 29 | start_val: Value, | |
| 30 | comptime fmt: []const u8, | |
| 31 | _: std.fmt.FormatOptions, | |
| 32 | out_stream: anytype, | |
| 33 | ) !void { | |
| 34 | comptime assert(fmt.len == 0); | |
| 35 | try out_stream.print("(interned: {})", .{start_val.toIntern()}); | |
| 27 | pub fn dump(start_val: Value, w: std.io.Writer) std.io.Writer.Error!void { | |
| 28 | try w.print("(interned: {})", .{start_val.toIntern()}); | |
| 36 | 29 | } |
| 37 | 30 | |
| 38 | pub fn fmtDebug(val: Value) std.fmt.Formatter(dump) { | |
| 31 | pub fn fmtDebug(val: Value) std.fmt.Formatter(Value, dump) { | |
| 39 | 32 | return .{ .data = val }; |
| 40 | 33 | } |
| 41 | 34 | |
| 42 | pub fn fmtValue(val: Value, pt: Zcu.PerThread) std.fmt.Formatter(print_value.format) { | |
| 35 | pub fn fmtValue(val: Value, pt: Zcu.PerThread) std.fmt.Formatter(print_value.FormatContext, print_value.format) { | |
| 43 | 36 | return .{ .data = .{ |
| 44 | 37 | .val = val, |
| 45 | 38 | .pt = pt, |
| ... | ... | @@ -48,7 +41,7 @@ pub fn fmtValue(val: Value, pt: Zcu.PerThread) std.fmt.Formatter(print_value.for |
| 48 | 41 | } }; |
| 49 | 42 | } |
| 50 | 43 | |
| 51 | pub fn fmtValueSema(val: Value, pt: Zcu.PerThread, sema: *Sema) std.fmt.Formatter(print_value.formatSema) { | |
| 44 | pub fn fmtValueSema(val: Value, pt: Zcu.PerThread, sema: *Sema) std.fmt.Formatter(print_value.FormatContext, print_value.formatSema) { | |
| 52 | 45 | return .{ .data = .{ |
| 53 | 46 | .val = val, |
| 54 | 47 | .pt = pt, |
| ... | ... | @@ -57,7 +50,7 @@ pub fn fmtValueSema(val: Value, pt: Zcu.PerThread, sema: *Sema) std.fmt.Formatte |
| 57 | 50 | } }; |
| 58 | 51 | } |
| 59 | 52 | |
| 60 | pub fn fmtValueSemaFull(ctx: print_value.FormatContext) std.fmt.Formatter(print_value.formatSema) { | |
| 53 | pub fn fmtValueSemaFull(ctx: print_value.FormatContext) std.fmt.Formatter(print_value.FormatContext, print_value.formatSema) { | |
| 61 | 54 | return .{ .data = ctx }; |
| 62 | 55 | } |
| 63 | 56 |
src/arch/riscv64/CodeGen.zig+16-32| ... | ... | @@ -937,12 +937,7 @@ const FormatWipMirData = struct { |
| 937 | 937 | func: *Func, |
| 938 | 938 | inst: Mir.Inst.Index, |
| 939 | 939 | }; |
| 940 | fn formatWipMir( | |
| 941 | data: FormatWipMirData, | |
| 942 | comptime _: []const u8, | |
| 943 | _: std.fmt.FormatOptions, | |
| 944 | writer: anytype, | |
| 945 | ) @TypeOf(writer).Error!void { | |
| 940 | fn formatWipMir(data: FormatWipMirData, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 946 | 941 | const pt = data.func.pt; |
| 947 | 942 | const comp = pt.zcu.comp; |
| 948 | 943 | var lower: Lower = .{ |
| ... | ... | @@ -982,7 +977,7 @@ fn formatWipMir( |
| 982 | 977 | first = false; |
| 983 | 978 | } |
| 984 | 979 | } |
| 985 | fn fmtWipMir(func: *Func, inst: Mir.Inst.Index) std.fmt.Formatter(formatWipMir) { | |
| 980 | fn fmtWipMir(func: *Func, inst: Mir.Inst.Index) std.fmt.Formatter(FormatWipMirData, formatWipMir) { | |
| 986 | 981 | return .{ .data = .{ .func = func, .inst = inst } }; |
| 987 | 982 | } |
| 988 | 983 | |
| ... | ... | @@ -990,15 +985,10 @@ const FormatNavData = struct { |
| 990 | 985 | ip: *const InternPool, |
| 991 | 986 | nav_index: InternPool.Nav.Index, |
| 992 | 987 | }; |
| 993 | fn formatNav( | |
| 994 | data: FormatNavData, | |
| 995 | comptime _: []const u8, | |
| 996 | _: std.fmt.FormatOptions, | |
| 997 | writer: anytype, | |
| 998 | ) @TypeOf(writer).Error!void { | |
| 999 | try writer.print("{}", .{data.ip.getNav(data.nav_index).fqn.fmt(data.ip)}); | |
| 1000 | } | |
| 1001 | fn fmtNav(nav_index: InternPool.Nav.Index, ip: *const InternPool) std.fmt.Formatter(formatNav) { | |
| 988 | fn formatNav(data: FormatNavData, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 989 | try writer.print("{f}", .{data.ip.getNav(data.nav_index).fqn.fmt(data.ip)}); | |
| 990 | } | |
| 991 | fn fmtNav(nav_index: InternPool.Nav.Index, ip: *const InternPool) std.fmt.Formatter(FormatNavData, formatNav) { | |
| 1002 | 992 | return .{ .data = .{ |
| 1003 | 993 | .ip = ip, |
| 1004 | 994 | .nav_index = nav_index, |
| ... | ... | @@ -1009,31 +999,25 @@ const FormatAirData = struct { |
| 1009 | 999 | func: *Func, |
| 1010 | 1000 | inst: Air.Inst.Index, |
| 1011 | 1001 | }; |
| 1012 | fn formatAir( | |
| 1013 | data: FormatAirData, | |
| 1014 | comptime _: []const u8, | |
| 1015 | _: std.fmt.FormatOptions, | |
| 1016 | writer: anytype, | |
| 1017 | ) @TypeOf(writer).Error!void { | |
| 1018 | data.func.air.dumpInst(data.inst, data.func.pt, data.func.liveness); | |
| 1019 | } | |
| 1020 | fn fmtAir(func: *Func, inst: Air.Inst.Index) std.fmt.Formatter(formatAir) { | |
| 1002 | fn formatAir(data: FormatAirData, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 1003 | // Not acceptable implementation because it ignores `writer`: | |
| 1004 | //data.func.air.dumpInst(data.inst, data.func.pt, data.func.liveness); | |
| 1005 | _ = data; | |
| 1006 | _ = writer; | |
| 1007 | @panic("unimplemented"); | |
| 1008 | } | |
| 1009 | fn fmtAir(func: *Func, inst: Air.Inst.Index) std.fmt.Formatter(FormatAirData, formatAir) { | |
| 1021 | 1010 | return .{ .data = .{ .func = func, .inst = inst } }; |
| 1022 | 1011 | } |
| 1023 | 1012 | |
| 1024 | 1013 | const FormatTrackingData = struct { |
| 1025 | 1014 | func: *Func, |
| 1026 | 1015 | }; |
| 1027 | fn formatTracking( | |
| 1028 | data: FormatTrackingData, | |
| 1029 | comptime _: []const u8, | |
| 1030 | _: std.fmt.FormatOptions, | |
| 1031 | writer: anytype, | |
| 1032 | ) @TypeOf(writer).Error!void { | |
| 1016 | fn formatTracking(data: FormatTrackingData, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 1033 | 1017 | var it = data.func.inst_tracking.iterator(); |
| 1034 | 1018 | while (it.next()) |entry| try writer.print("\n%{d} = {}", .{ entry.key_ptr.*, entry.value_ptr.* }); |
| 1035 | 1019 | } |
| 1036 | fn fmtTracking(func: *Func) std.fmt.Formatter(formatTracking) { | |
| 1020 | fn fmtTracking(func: *Func) std.fmt.Formatter(FormatTrackingData, formatTracking) { | |
| 1037 | 1021 | return .{ .data = .{ .func = func } }; |
| 1038 | 1022 | } |
| 1039 | 1023 |
src/arch/x86_64/CodeGen.zig+208-233| ... | ... | @@ -6,6 +6,7 @@ const log = std.log.scoped(.codegen); |
| 6 | 6 | const tracking_log = std.log.scoped(.tracking); |
| 7 | 7 | const verbose_tracking_log = std.log.scoped(.verbose_tracking); |
| 8 | 8 | const wip_mir_log = std.log.scoped(.wip_mir); |
| 9 | const Writer = std.io.Writer; | |
| 9 | 10 | |
| 10 | 11 | const Air = @import("../../Air.zig"); |
| 11 | 12 | const Allocator = std.mem.Allocator; |
| ... | ... | @@ -524,52 +525,47 @@ pub const MCValue = union(enum) { |
| 524 | 525 | }; |
| 525 | 526 | } |
| 526 | 527 | |
| 527 | pub fn format( | |
| 528 | mcv: MCValue, | |
| 529 | comptime _: []const u8, | |
| 530 | _: std.fmt.FormatOptions, | |
| 531 | writer: anytype, | |
| 532 | ) @TypeOf(writer).Error!void { | |
| 528 | pub fn format(mcv: MCValue, bw: *Writer, comptime _: []const u8) Writer.Error!void { | |
| 533 | 529 | switch (mcv) { |
| 534 | .none, .unreach, .dead, .undef => try writer.print("({s})", .{@tagName(mcv)}), | |
| 535 | .immediate => |pl| try writer.print("0x{x}", .{pl}), | |
| 536 | .memory => |pl| try writer.print("[ds:0x{x}]", .{pl}), | |
| 537 | inline .eflags, .register => |pl| try writer.print("{s}", .{@tagName(pl)}), | |
| 538 | .register_pair => |pl| try writer.print("{s}:{s}", .{ @tagName(pl[1]), @tagName(pl[0]) }), | |
| 539 | .register_triple => |pl| try writer.print("{s}:{s}:{s}", .{ | |
| 530 | .none, .unreach, .dead, .undef => try bw.print("({s})", .{@tagName(mcv)}), | |
| 531 | .immediate => |pl| try bw.print("0x{x}", .{pl}), | |
| 532 | .memory => |pl| try bw.print("[ds:0x{x}]", .{pl}), | |
| 533 | inline .eflags, .register => |pl| try bw.print("{s}", .{@tagName(pl)}), | |
| 534 | .register_pair => |pl| try bw.print("{s}:{s}", .{ @tagName(pl[1]), @tagName(pl[0]) }), | |
| 535 | .register_triple => |pl| try bw.print("{s}:{s}:{s}", .{ | |
| 540 | 536 | @tagName(pl[2]), @tagName(pl[1]), @tagName(pl[0]), |
| 541 | 537 | }), |
| 542 | .register_quadruple => |pl| try writer.print("{s}:{s}:{s}:{s}", .{ | |
| 538 | .register_quadruple => |pl| try bw.print("{s}:{s}:{s}:{s}", .{ | |
| 543 | 539 | @tagName(pl[3]), @tagName(pl[2]), @tagName(pl[1]), @tagName(pl[0]), |
| 544 | 540 | }), |
| 545 | .register_offset => |pl| try writer.print("{s} + 0x{x}", .{ @tagName(pl.reg), pl.off }), | |
| 546 | .register_overflow => |pl| try writer.print("{s}:{s}", .{ | |
| 541 | .register_offset => |pl| try bw.print("{s} + 0x{x}", .{ @tagName(pl.reg), pl.off }), | |
| 542 | .register_overflow => |pl| try bw.print("{s}:{s}", .{ | |
| 547 | 543 | @tagName(pl.eflags), |
| 548 | 544 | @tagName(pl.reg), |
| 549 | 545 | }), |
| 550 | .register_mask => |pl| try writer.print("mask({s},{}):{c}{s}", .{ | |
| 546 | .register_mask => |pl| try bw.print("mask({s},{f}):{c}{s}", .{ | |
| 551 | 547 | @tagName(pl.info.kind), |
| 552 | 548 | pl.info.scalar, |
| 553 | 549 | @as(u8, if (pl.info.inverted) '!' else ' '), |
| 554 | 550 | @tagName(pl.reg), |
| 555 | 551 | }), |
| 556 | .indirect => |pl| try writer.print("[{s} + 0x{x}]", .{ @tagName(pl.reg), pl.off }), | |
| 557 | .indirect_load_frame => |pl| try writer.print("[[{} + 0x{x}]]", .{ pl.index, pl.off }), | |
| 558 | .load_frame => |pl| try writer.print("[{} + 0x{x}]", .{ pl.index, pl.off }), | |
| 559 | .lea_frame => |pl| try writer.print("{} + 0x{x}", .{ pl.index, pl.off }), | |
| 560 | .load_nav => |pl| try writer.print("[nav:{d}]", .{@intFromEnum(pl)}), | |
| 561 | .lea_nav => |pl| try writer.print("nav:{d}", .{@intFromEnum(pl)}), | |
| 562 | .load_uav => |pl| try writer.print("[uav:{d}]", .{@intFromEnum(pl.val)}), | |
| 563 | .lea_uav => |pl| try writer.print("uav:{d}", .{@intFromEnum(pl.val)}), | |
| 564 | .load_lazy_sym => |pl| try writer.print("[lazy:{s}:{d}]", .{ @tagName(pl.kind), @intFromEnum(pl.ty) }), | |
| 565 | .lea_lazy_sym => |pl| try writer.print("lazy:{s}:{d}", .{ @tagName(pl.kind), @intFromEnum(pl.ty) }), | |
| 566 | .load_extern_func => |pl| try writer.print("[extern:{d}]", .{@intFromEnum(pl)}), | |
| 567 | .lea_extern_func => |pl| try writer.print("extern:{d}", .{@intFromEnum(pl)}), | |
| 568 | .elementwise_args => |pl| try writer.print("elementwise:{d}:[{} + 0x{x}]", .{ | |
| 552 | .indirect => |pl| try bw.print("[{s} + 0x{x}]", .{ @tagName(pl.reg), pl.off }), | |
| 553 | .indirect_load_frame => |pl| try bw.print("[[{} + 0x{x}]]", .{ pl.index, pl.off }), | |
| 554 | .load_frame => |pl| try bw.print("[{} + 0x{x}]", .{ pl.index, pl.off }), | |
| 555 | .lea_frame => |pl| try bw.print("{} + 0x{x}", .{ pl.index, pl.off }), | |
| 556 | .load_nav => |pl| try bw.print("[nav:{d}]", .{@intFromEnum(pl)}), | |
| 557 | .lea_nav => |pl| try bw.print("nav:{d}", .{@intFromEnum(pl)}), | |
| 558 | .load_uav => |pl| try bw.print("[uav:{d}]", .{@intFromEnum(pl.val)}), | |
| 559 | .lea_uav => |pl| try bw.print("uav:{d}", .{@intFromEnum(pl.val)}), | |
| 560 | .load_lazy_sym => |pl| try bw.print("[lazy:{s}:{d}]", .{ @tagName(pl.kind), @intFromEnum(pl.ty) }), | |
| 561 | .lea_lazy_sym => |pl| try bw.print("lazy:{s}:{d}", .{ @tagName(pl.kind), @intFromEnum(pl.ty) }), | |
| 562 | .load_extern_func => |pl| try bw.print("[extern:{d}]", .{@intFromEnum(pl)}), | |
| 563 | .lea_extern_func => |pl| try bw.print("extern:{d}", .{@intFromEnum(pl)}), | |
| 564 | .elementwise_args => |pl| try bw.print("elementwise:{d}:[{} + 0x{x}]", .{ | |
| 569 | 565 | pl.regs, pl.frame_index, pl.frame_off, |
| 570 | 566 | }), |
| 571 | .reserved_frame => |pl| try writer.print("(dead:{})", .{pl}), | |
| 572 | .air_ref => |pl| try writer.print("(air:0x{x})", .{@intFromEnum(pl)}), | |
| 567 | .reserved_frame => |pl| try bw.print("(dead:{})", .{pl}), | |
| 568 | .air_ref => |pl| try bw.print("(air:0x{x})", .{@intFromEnum(pl)}), | |
| 573 | 569 | } |
| 574 | 570 | } |
| 575 | 571 | }; |
| ... | ... | @@ -639,7 +635,7 @@ const InstTracking = struct { |
| 639 | 635 | .reserved_frame => |index| self.long = .{ .load_frame = .{ .index = index } }, |
| 640 | 636 | else => unreachable, |
| 641 | 637 | } |
| 642 | tracking_log.debug("spill {} from {} to {}", .{ inst, self.short, self.long }); | |
| 638 | tracking_log.debug("spill {f} from {f} to {f}", .{ inst, self.short, self.long }); | |
| 643 | 639 | try cg.genCopy(cg.typeOfIndex(inst), self.long, self.short, .{}); |
| 644 | 640 | for (self.short.getRegs()) |reg| if (reg.isClass(.x87)) try cg.asmRegister(.{ .f_, .free }, reg); |
| 645 | 641 | } |
| ... | ... | @@ -672,7 +668,7 @@ const InstTracking = struct { |
| 672 | 668 | else => {}, // TODO process stack allocation death |
| 673 | 669 | } |
| 674 | 670 | self.reuseFrame(); |
| 675 | tracking_log.debug("{} => {} (spilled)", .{ inst, self.* }); | |
| 671 | tracking_log.debug("{f} => {f} (spilled)", .{ inst, self.* }); | |
| 676 | 672 | } |
| 677 | 673 | |
| 678 | 674 | fn verifyMaterialize(self: InstTracking, target: InstTracking) void { |
| ... | ... | @@ -749,7 +745,7 @@ const InstTracking = struct { |
| 749 | 745 | else => target.long, |
| 750 | 746 | } else target.long; |
| 751 | 747 | self.short = target.short; |
| 752 | tracking_log.debug("{} => {} (materialize)", .{ inst, self.* }); | |
| 748 | tracking_log.debug("{f} => {f} (materialize)", .{ inst, self.* }); | |
| 753 | 749 | } |
| 754 | 750 | |
| 755 | 751 | fn resurrect(self: *InstTracking, function: *CodeGen, inst: Air.Inst.Index, scope_generation: u32) !void { |
| ... | ... | @@ -757,7 +753,7 @@ const InstTracking = struct { |
| 757 | 753 | .dead => |die_generation| if (die_generation >= scope_generation) { |
| 758 | 754 | self.reuseFrame(); |
| 759 | 755 | try function.getValue(self.short, inst); |
| 760 | tracking_log.debug("{} => {} (resurrect)", .{ inst, self.* }); | |
| 756 | tracking_log.debug("{f} => {f} (resurrect)", .{ inst, self.* }); | |
| 761 | 757 | }, |
| 762 | 758 | else => {}, |
| 763 | 759 | } |
| ... | ... | @@ -768,7 +764,7 @@ const InstTracking = struct { |
| 768 | 764 | try function.freeValue(self.short, opts); |
| 769 | 765 | if (self.long == .none) self.long = self.short; |
| 770 | 766 | self.short = .{ .dead = function.scope_generation }; |
| 771 | tracking_log.debug("{} => {} (death)", .{ inst, self.* }); | |
| 767 | tracking_log.debug("{f} => {f} (death)", .{ inst, self.* }); | |
| 772 | 768 | } |
| 773 | 769 | |
| 774 | 770 | fn reuse( |
| ... | ... | @@ -778,13 +774,13 @@ const InstTracking = struct { |
| 778 | 774 | old_inst: Air.Inst.Index, |
| 779 | 775 | ) void { |
| 780 | 776 | self.short = .{ .dead = function.scope_generation }; |
| 781 | tracking_log.debug("{?} => {} (reuse {})", .{ new_inst, self.*, old_inst }); | |
| 777 | tracking_log.debug("{?f} => {f} (reuse {f})", .{ new_inst, self.*, old_inst }); | |
| 782 | 778 | } |
| 783 | 779 | |
| 784 | 780 | fn liveOut(self: *InstTracking, function: *CodeGen, inst: Air.Inst.Index) void { |
| 785 | 781 | for (self.getRegs()) |reg| { |
| 786 | 782 | if (function.register_manager.isRegFree(reg)) { |
| 787 | tracking_log.debug("{} => {} (live-out)", .{ inst, self.* }); | |
| 783 | tracking_log.debug("{f} => {f} (live-out)", .{ inst, self.* }); | |
| 788 | 784 | continue; |
| 789 | 785 | } |
| 790 | 786 | |
| ... | ... | @@ -812,18 +808,13 @@ const InstTracking = struct { |
| 812 | 808 | // Perform side-effects of freeValue manually. |
| 813 | 809 | function.register_manager.freeReg(reg); |
| 814 | 810 | |
| 815 | tracking_log.debug("{} => {} (live-out {})", .{ inst, self.*, tracked_inst }); | |
| 811 | tracking_log.debug("{f} => {f} (live-out {f})", .{ inst, self.*, tracked_inst }); | |
| 816 | 812 | } |
| 817 | 813 | } |
| 818 | 814 | |
| 819 | pub fn format( | |
| 820 | tracking: InstTracking, | |
| 821 | comptime _: []const u8, | |
| 822 | _: std.fmt.FormatOptions, | |
| 823 | writer: anytype, | |
| 824 | ) @TypeOf(writer).Error!void { | |
| 825 | if (!std.meta.eql(tracking.long, tracking.short)) try writer.print("|{}| ", .{tracking.long}); | |
| 826 | try writer.print("{}", .{tracking.short}); | |
| 815 | pub fn format(tracking: InstTracking, bw: *Writer, comptime _: []const u8) Writer.Error!void { | |
| 816 | if (!std.meta.eql(tracking.long, tracking.short)) try bw.print("|{f}| ", .{tracking.long}); | |
| 817 | try bw.print("{f}", .{tracking.short}); | |
| 827 | 818 | } |
| 828 | 819 | }; |
| 829 | 820 | |
| ... | ... | @@ -939,7 +930,7 @@ pub fn generate( |
| 939 | 930 | function.inst_tracking.putAssumeCapacityNoClobber(temp.toIndex(), .init(.none)); |
| 940 | 931 | } |
| 941 | 932 | |
| 942 | wip_mir_log.debug("{}:", .{fmtNav(func.owner_nav, ip)}); | |
| 933 | wip_mir_log.debug("{f}:", .{fmtNav(func.owner_nav, ip)}); | |
| 943 | 934 | |
| 944 | 935 | try function.frame_allocs.resize(gpa, FrameIndex.named_count); |
| 945 | 936 | function.frame_allocs.set( |
| ... | ... | @@ -1097,15 +1088,10 @@ const FormatNavData = struct { |
| 1097 | 1088 | ip: *const InternPool, |
| 1098 | 1089 | nav_index: InternPool.Nav.Index, |
| 1099 | 1090 | }; |
| 1100 | fn formatNav( | |
| 1101 | data: FormatNavData, | |
| 1102 | comptime _: []const u8, | |
| 1103 | _: std.fmt.FormatOptions, | |
| 1104 | writer: anytype, | |
| 1105 | ) @TypeOf(writer).Error!void { | |
| 1106 | try writer.print("{}", .{data.ip.getNav(data.nav_index).fqn.fmt(data.ip)}); | |
| 1091 | fn formatNav(data: FormatNavData, w: *Writer) Writer.Error!void { | |
| 1092 | try w.print("{f}", .{data.ip.getNav(data.nav_index).fqn.fmt(data.ip)}); | |
| 1107 | 1093 | } |
| 1108 | fn fmtNav(nav_index: InternPool.Nav.Index, ip: *const InternPool) std.fmt.Formatter(formatNav) { | |
| 1094 | fn fmtNav(nav_index: InternPool.Nav.Index, ip: *const InternPool) std.fmt.Formatter(FormatNavData, formatNav) { | |
| 1109 | 1095 | return .{ .data = .{ |
| 1110 | 1096 | .ip = ip, |
| 1111 | 1097 | .nav_index = nav_index, |
| ... | ... | @@ -1116,15 +1102,14 @@ const FormatAirData = struct { |
| 1116 | 1102 | self: *CodeGen, |
| 1117 | 1103 | inst: Air.Inst.Index, |
| 1118 | 1104 | }; |
| 1119 | fn formatAir( | |
| 1120 | data: FormatAirData, | |
| 1121 | comptime _: []const u8, | |
| 1122 | _: std.fmt.FormatOptions, | |
| 1123 | writer: anytype, | |
| 1124 | ) @TypeOf(writer).Error!void { | |
| 1125 | data.self.air.dumpInst(data.inst, data.self.pt, data.self.liveness); | |
| 1105 | fn formatAir(data: FormatAirData, w: *std.io.Writer) Writer.Error!void { | |
| 1106 | // not acceptable implementation because it ignores `w`: | |
| 1107 | //data.self.air.dumpInst(data.inst, data.self.pt, data.self.liveness); | |
| 1108 | _ = data; | |
| 1109 | _ = w; | |
| 1110 | @panic("TODO: unimplemented"); | |
| 1126 | 1111 | } |
| 1127 | fn fmtAir(self: *CodeGen, inst: Air.Inst.Index) std.fmt.Formatter(formatAir) { | |
| 1112 | fn fmtAir(self: *CodeGen, inst: Air.Inst.Index) std.fmt.Formatter(FormatAirData, formatAir) { | |
| 1128 | 1113 | return .{ .data = .{ .self = self, .inst = inst } }; |
| 1129 | 1114 | } |
| 1130 | 1115 | |
| ... | ... | @@ -1132,12 +1117,7 @@ const FormatWipMirData = struct { |
| 1132 | 1117 | self: *CodeGen, |
| 1133 | 1118 | inst: Mir.Inst.Index, |
| 1134 | 1119 | }; |
| 1135 | fn formatWipMir( | |
| 1136 | data: FormatWipMirData, | |
| 1137 | comptime _: []const u8, | |
| 1138 | _: std.fmt.FormatOptions, | |
| 1139 | writer: anytype, | |
| 1140 | ) @TypeOf(writer).Error!void { | |
| 1120 | fn formatWipMir(data: FormatWipMirData, w: *Writer) Writer.Error!void { | |
| 1141 | 1121 | var lower: Lower = .{ |
| 1142 | 1122 | .target = data.self.target, |
| 1143 | 1123 | .allocator = data.self.gpa, |
| ... | ... | @@ -1152,11 +1132,11 @@ fn formatWipMir( |
| 1152 | 1132 | lower.err_msg.?.deinit(data.self.gpa); |
| 1153 | 1133 | lower.err_msg = null; |
| 1154 | 1134 | } |
| 1155 | try writer.writeAll(lower.err_msg.?.msg); | |
| 1135 | try w.writeAll(lower.err_msg.?.msg); | |
| 1156 | 1136 | return; |
| 1157 | 1137 | }, |
| 1158 | 1138 | error.OutOfMemory, error.InvalidInstruction, error.CannotEncode => |e| { |
| 1159 | try writer.writeAll(switch (e) { | |
| 1139 | try w.writeAll(switch (e) { | |
| 1160 | 1140 | error.OutOfMemory => "Out of memory", |
| 1161 | 1141 | error.InvalidInstruction => "CodeGen failed to find a viable instruction.", |
| 1162 | 1142 | error.CannotEncode => "CodeGen failed to encode the instruction.", |
| ... | ... | @@ -1165,14 +1145,14 @@ fn formatWipMir( |
| 1165 | 1145 | }, |
| 1166 | 1146 | else => |e| return e, |
| 1167 | 1147 | }).insts) |lowered_inst| { |
| 1168 | if (!first) try writer.writeAll("\ndebug(wip_mir): "); | |
| 1169 | try writer.print(" | {}", .{lowered_inst}); | |
| 1148 | if (!first) try w.writeAll("\ndebug(wip_mir): "); | |
| 1149 | try w.print(" | {f}", .{lowered_inst}); | |
| 1170 | 1150 | first = false; |
| 1171 | 1151 | } |
| 1172 | 1152 | if (first) { |
| 1173 | 1153 | const ip = &data.self.pt.zcu.intern_pool; |
| 1174 | 1154 | const mir_inst = lower.mir.instructions.get(data.inst); |
| 1175 | try writer.print(" | .{s}", .{@tagName(mir_inst.ops)}); | |
| 1155 | try w.print(" | .{s}", .{@tagName(mir_inst.ops)}); | |
| 1176 | 1156 | switch (mir_inst.ops) { |
| 1177 | 1157 | else => unreachable, |
| 1178 | 1158 | .pseudo_dbg_prologue_end_none, |
| ... | ... | @@ -1184,20 +1164,20 @@ fn formatWipMir( |
| 1184 | 1164 | .pseudo_dbg_var_none, |
| 1185 | 1165 | .pseudo_dead_none, |
| 1186 | 1166 | => {}, |
| 1187 | .pseudo_dbg_line_stmt_line_column, .pseudo_dbg_line_line_column => try writer.print( | |
| 1167 | .pseudo_dbg_line_stmt_line_column, .pseudo_dbg_line_line_column => try w.print( | |
| 1188 | 1168 | " {[line]d}, {[column]d}", |
| 1189 | 1169 | mir_inst.data.line_column, |
| 1190 | 1170 | ), |
| 1191 | .pseudo_dbg_enter_inline_func, .pseudo_dbg_leave_inline_func => try writer.print(" {}", .{ | |
| 1171 | .pseudo_dbg_enter_inline_func, .pseudo_dbg_leave_inline_func => try w.print(" {f}", .{ | |
| 1192 | 1172 | ip.getNav(ip.indexToKey(mir_inst.data.ip_index).func.owner_nav).name.fmt(ip), |
| 1193 | 1173 | }), |
| 1194 | .pseudo_dbg_arg_i_s, .pseudo_dbg_var_i_s => try writer.print(" {d}", .{ | |
| 1174 | .pseudo_dbg_arg_i_s, .pseudo_dbg_var_i_s => try w.print(" {d}", .{ | |
| 1195 | 1175 | @as(i32, @bitCast(mir_inst.data.i.i)), |
| 1196 | 1176 | }), |
| 1197 | .pseudo_dbg_arg_i_u, .pseudo_dbg_var_i_u => try writer.print(" {d}", .{ | |
| 1177 | .pseudo_dbg_arg_i_u, .pseudo_dbg_var_i_u => try w.print(" {d}", .{ | |
| 1198 | 1178 | mir_inst.data.i.i, |
| 1199 | 1179 | }), |
| 1200 | .pseudo_dbg_arg_i_64, .pseudo_dbg_var_i_64 => try writer.print(" {d}", .{ | |
| 1180 | .pseudo_dbg_arg_i_64, .pseudo_dbg_var_i_64 => try w.print(" {d}", .{ | |
| 1201 | 1181 | mir_inst.data.i64, |
| 1202 | 1182 | }), |
| 1203 | 1183 | .pseudo_dbg_arg_ro, .pseudo_dbg_var_ro => { |
| ... | ... | @@ -1205,44 +1185,39 @@ fn formatWipMir( |
| 1205 | 1185 | .base = .{ .reg = mir_inst.data.ro.reg }, |
| 1206 | 1186 | .disp = mir_inst.data.ro.off, |
| 1207 | 1187 | }) }; |
| 1208 | try writer.print(" {}", .{mem_op.fmt(.m)}); | |
| 1188 | try w.print(" {f}", .{mem_op.fmt(.m)}); | |
| 1209 | 1189 | }, |
| 1210 | 1190 | .pseudo_dbg_arg_fa, .pseudo_dbg_var_fa => { |
| 1211 | 1191 | const mem_op: encoder.Instruction.Operand = .{ .mem = .initSib(.qword, .{ |
| 1212 | 1192 | .base = .{ .frame = mir_inst.data.fa.index }, |
| 1213 | 1193 | .disp = mir_inst.data.fa.off, |
| 1214 | 1194 | }) }; |
| 1215 | try writer.print(" {}", .{mem_op.fmt(.m)}); | |
| 1195 | try w.print(" {f}", .{mem_op.fmt(.m)}); | |
| 1216 | 1196 | }, |
| 1217 | 1197 | .pseudo_dbg_arg_m, .pseudo_dbg_var_m => { |
| 1218 | 1198 | const mem_op: encoder.Instruction.Operand = .{ |
| 1219 | 1199 | .mem = lower.mir.extraData(Mir.Memory, mir_inst.data.x.payload).data.decode(), |
| 1220 | 1200 | }; |
| 1221 | try writer.print(" {}", .{mem_op.fmt(.m)}); | |
| 1201 | try w.print(" {f}", .{mem_op.fmt(.m)}); | |
| 1222 | 1202 | }, |
| 1223 | .pseudo_dbg_arg_val, .pseudo_dbg_var_val => try writer.print(" {}", .{ | |
| 1203 | .pseudo_dbg_arg_val, .pseudo_dbg_var_val => try w.print(" {}", .{ | |
| 1224 | 1204 | Value.fromInterned(mir_inst.data.ip_index).fmtValue(data.self.pt), |
| 1225 | 1205 | }), |
| 1226 | 1206 | } |
| 1227 | 1207 | } |
| 1228 | 1208 | } |
| 1229 | fn fmtWipMir(self: *CodeGen, inst: Mir.Inst.Index) std.fmt.Formatter(formatWipMir) { | |
| 1209 | fn fmtWipMir(self: *CodeGen, inst: Mir.Inst.Index) std.fmt.Formatter(FormatWipMirData, formatWipMir) { | |
| 1230 | 1210 | return .{ .data = .{ .self = self, .inst = inst } }; |
| 1231 | 1211 | } |
| 1232 | 1212 | |
| 1233 | 1213 | const FormatTrackingData = struct { |
| 1234 | 1214 | self: *CodeGen, |
| 1235 | 1215 | }; |
| 1236 | fn formatTracking( | |
| 1237 | data: FormatTrackingData, | |
| 1238 | comptime _: []const u8, | |
| 1239 | _: std.fmt.FormatOptions, | |
| 1240 | writer: anytype, | |
| 1241 | ) @TypeOf(writer).Error!void { | |
| 1216 | fn formatTracking(data: FormatTrackingData, w: *Writer) Writer.Error!void { | |
| 1242 | 1217 | var it = data.self.inst_tracking.iterator(); |
| 1243 | while (it.next()) |entry| try writer.print("\n{} = {}", .{ entry.key_ptr.*, entry.value_ptr.* }); | |
| 1218 | while (it.next()) |entry| try w.print("\n{f} = {f}", .{ entry.key_ptr.*, entry.value_ptr.* }); | |
| 1244 | 1219 | } |
| 1245 | fn fmtTracking(self: *CodeGen) std.fmt.Formatter(formatTracking) { | |
| 1220 | fn fmtTracking(self: *CodeGen) std.fmt.Formatter(FormatTrackingData, formatTracking) { | |
| 1246 | 1221 | return .{ .data = .{ .self = self } }; |
| 1247 | 1222 | } |
| 1248 | 1223 | |
| ... | ... | @@ -1251,7 +1226,7 @@ fn addInst(self: *CodeGen, inst: Mir.Inst) error{OutOfMemory}!Mir.Inst.Index { |
| 1251 | 1226 | try self.mir_instructions.ensureUnusedCapacity(gpa, 1); |
| 1252 | 1227 | const result_index: Mir.Inst.Index = @intCast(self.mir_instructions.len); |
| 1253 | 1228 | self.mir_instructions.appendAssumeCapacity(inst); |
| 1254 | if (inst.ops != .pseudo_dead_none) wip_mir_log.debug("{}", .{self.fmtWipMir(result_index)}); | |
| 1229 | if (inst.ops != .pseudo_dead_none) wip_mir_log.debug("{f}", .{self.fmtWipMir(result_index)}); | |
| 1255 | 1230 | return result_index; |
| 1256 | 1231 | } |
| 1257 | 1232 | |
| ... | ... | @@ -2056,7 +2031,7 @@ fn gen( |
| 2056 | 2031 | .{}, |
| 2057 | 2032 | ); |
| 2058 | 2033 | self.ret_mcv.long = .{ .load_frame = .{ .index = frame_index } }; |
| 2059 | tracking_log.debug("spill {} to {}", .{ self.ret_mcv.long, frame_index }); | |
| 2034 | tracking_log.debug("spill {f} to {f}", .{ self.ret_mcv.long, frame_index }); | |
| 2060 | 2035 | }, |
| 2061 | 2036 | else => unreachable, |
| 2062 | 2037 | } |
| ... | ... | @@ -2334,8 +2309,8 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 2334 | 2309 | |
| 2335 | 2310 | for (body) |inst| { |
| 2336 | 2311 | if (cg.liveness.isUnused(inst) and !cg.air.mustLower(inst, ip)) continue; |
| 2337 | wip_mir_log.debug("{}", .{cg.fmtAir(inst)}); | |
| 2338 | verbose_tracking_log.debug("{}", .{cg.fmtTracking()}); | |
| 2312 | wip_mir_log.debug("{f}", .{cg.fmtAir(inst)}); | |
| 2313 | verbose_tracking_log.debug("{f}", .{cg.fmtTracking()}); | |
| 2339 | 2314 | |
| 2340 | 2315 | cg.reused_operands = .initEmpty(); |
| 2341 | 2316 | try cg.inst_tracking.ensureUnusedCapacity(cg.gpa, 1); |
| ... | ... | @@ -4339,7 +4314,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 4339 | 4314 | .{ ._, ._nc, .j, .@"0b", ._, ._, ._ }, |
| 4340 | 4315 | } }, |
| 4341 | 4316 | } }) catch |err| switch (err) { |
| 4342 | error.SelectFailed => return cg.fail("failed to select {s} {} {} {}", .{ | |
| 4317 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | |
| 4343 | 4318 | @tagName(air_tag), |
| 4344 | 4319 | cg.typeOf(bin_op.lhs).fmt(pt), |
| 4345 | 4320 | ops[0].tracking(cg), |
| ... | ... | @@ -4351,7 +4326,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 4351 | 4326 | else => unreachable, |
| 4352 | 4327 | .add, .add_optimized => {}, |
| 4353 | 4328 | .add_wrap => res[0].wrapInt(cg) catch |err| switch (err) { |
| 4354 | error.SelectFailed => return cg.fail("failed to select {s} wrap {} {}", .{ | |
| 4329 | error.SelectFailed => return cg.fail("failed to select {s} wrap {f} {f}", .{ | |
| 4355 | 4330 | @tagName(air_tag), |
| 4356 | 4331 | cg.typeOf(bin_op.lhs).fmt(pt), |
| 4357 | 4332 | res[0].tracking(cg), |
| ... | ... | @@ -14947,7 +14922,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 14947 | 14922 | .{ ._, ._nc, .j, .@"0b", ._, ._, ._ }, |
| 14948 | 14923 | } }, |
| 14949 | 14924 | } }) catch |err| switch (err) { |
| 14950 | error.SelectFailed => return cg.fail("failed to select {s} {} {} {}", .{ | |
| 14925 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | |
| 14951 | 14926 | @tagName(air_tag), |
| 14952 | 14927 | cg.typeOf(bin_op.lhs).fmt(pt), |
| 14953 | 14928 | ops[0].tracking(cg), |
| ... | ... | @@ -14959,7 +14934,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 14959 | 14934 | else => unreachable, |
| 14960 | 14935 | .sub, .sub_optimized => {}, |
| 14961 | 14936 | .sub_wrap => res[0].wrapInt(cg) catch |err| switch (err) { |
| 14962 | error.SelectFailed => return cg.fail("failed to select {s} wrap {} {}", .{ | |
| 14937 | error.SelectFailed => return cg.fail("failed to select {s} wrap {f} {f}", .{ | |
| 14963 | 14938 | @tagName(air_tag), |
| 14964 | 14939 | cg.typeOf(bin_op.lhs).fmt(pt), |
| 14965 | 14940 | res[0].tracking(cg), |
| ... | ... | @@ -24587,7 +24562,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 24587 | 24562 | .{ ._, ._nc, .j, .@"0b", ._, ._, ._ }, |
| 24588 | 24563 | } }, |
| 24589 | 24564 | } }) catch |err| switch (err) { |
| 24590 | error.SelectFailed => return cg.fail("failed to select {s} {} {} {}", .{ | |
| 24565 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | |
| 24591 | 24566 | @tagName(air_tag), |
| 24592 | 24567 | ty.fmt(pt), |
| 24593 | 24568 | ops[0].tracking(cg), |
| ... | ... | @@ -27287,7 +27262,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 27287 | 27262 | .{ ._, ._nc, .j, .@"0b", ._, ._, ._ }, |
| 27288 | 27263 | } }, |
| 27289 | 27264 | } }) catch |err| switch (err) { |
| 27290 | error.SelectFailed => return cg.fail("failed to select {s} {} {} {}", .{ | |
| 27265 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | |
| 27291 | 27266 | @tagName(air_tag), |
| 27292 | 27267 | ty.fmt(pt), |
| 27293 | 27268 | ops[0].tracking(cg), |
| ... | ... | @@ -27296,7 +27271,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 27296 | 27271 | else => |e| return e, |
| 27297 | 27272 | }; |
| 27298 | 27273 | res[0].wrapInt(cg) catch |err| switch (err) { |
| 27299 | error.SelectFailed => return cg.fail("failed to select {s} wrap {} {}", .{ | |
| 27274 | error.SelectFailed => return cg.fail("failed to select {s} wrap {f} {f}", .{ | |
| 27300 | 27275 | @tagName(air_tag), |
| 27301 | 27276 | cg.typeOf(bin_op.lhs).fmt(pt), |
| 27302 | 27277 | res[0].tracking(cg), |
| ... | ... | @@ -33606,7 +33581,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 33606 | 33581 | assert(air_tag == .div_exact); |
| 33607 | 33582 | res[0] = ops[0].divTruncInts(&ops[1], cg) catch |err| break :err err; |
| 33608 | 33583 | }) catch |err| switch (err) { |
| 33609 | error.SelectFailed => return cg.fail("failed to select {s} {} {} {}", .{ | |
| 33584 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | |
| 33610 | 33585 | @tagName(air_tag), |
| 33611 | 33586 | ty.fmt(pt), |
| 33612 | 33587 | ops[0].tracking(cg), |
| ... | ... | @@ -34837,7 +34812,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 34837 | 34812 | } }) else err: { |
| 34838 | 34813 | res[0] = ops[0].divTruncInts(&ops[1], cg) catch |err| break :err err; |
| 34839 | 34814 | }) catch |err| switch (err) { |
| 34840 | error.SelectFailed => return cg.fail("failed to select {s} {} {} {}", .{ | |
| 34815 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | |
| 34841 | 34816 | @tagName(air_tag), |
| 34842 | 34817 | ty.fmt(pt), |
| 34843 | 34818 | ops[0].tracking(cg), |
| ... | ... | @@ -36148,7 +36123,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 36148 | 36123 | } }, |
| 36149 | 36124 | } }, |
| 36150 | 36125 | }) catch |err| switch (err) { |
| 36151 | error.SelectFailed => return cg.fail("failed to select {s} {} {} {}", .{ | |
| 36126 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | |
| 36152 | 36127 | @tagName(air_tag), |
| 36153 | 36128 | cg.typeOf(bin_op.lhs).fmt(pt), |
| 36154 | 36129 | ops[0].tracking(cg), |
| ... | ... | @@ -37614,7 +37589,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 37614 | 37589 | .{ ._, ._nc, .j, .@"0b", ._, ._, ._ }, |
| 37615 | 37590 | } }, |
| 37616 | 37591 | } })) catch |err| switch (err) { |
| 37617 | error.SelectFailed => return cg.fail("failed to select {s} {} {} {}", .{ | |
| 37592 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | |
| 37618 | 37593 | @tagName(air_tag), |
| 37619 | 37594 | ty.fmt(pt), |
| 37620 | 37595 | ops[0].tracking(cg), |
| ... | ... | @@ -39248,7 +39223,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 39248 | 39223 | .{ ._, ._nc, .j, .@"0b", ._, ._, ._ }, |
| 39249 | 39224 | } }, |
| 39250 | 39225 | } }) catch |err| switch (err) { |
| 39251 | error.SelectFailed => return cg.fail("failed to select {s} {} {} {}", .{ | |
| 39226 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | |
| 39252 | 39227 | @tagName(air_tag), |
| 39253 | 39228 | cg.typeOf(bin_op.lhs).fmt(pt), |
| 39254 | 39229 | ops[0].tracking(cg), |
| ... | ... | @@ -42077,7 +42052,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 42077 | 42052 | .{ ._, ._nc, .j, .@"0b", ._, ._, ._ }, |
| 42078 | 42053 | } }, |
| 42079 | 42054 | } }) catch |err| switch (err) { |
| 42080 | error.SelectFailed => return cg.fail("failed to select {s} {} {} {}", .{ | |
| 42055 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | |
| 42081 | 42056 | @tagName(air_tag), |
| 42082 | 42057 | cg.typeOf(bin_op.lhs).fmt(pt), |
| 42083 | 42058 | ops[0].tracking(cg), |
| ... | ... | @@ -42191,7 +42166,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 42191 | 42166 | .{ ._, ._, .lea, .dst0p, .leai(.src0, .dst0), ._, ._ }, |
| 42192 | 42167 | } }, |
| 42193 | 42168 | } }) catch |err| switch (err) { |
| 42194 | error.SelectFailed => return cg.fail("failed to select {s} {} {} {}", .{ | |
| 42169 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | |
| 42195 | 42170 | @tagName(air_tag), |
| 42196 | 42171 | cg.typeOf(bin_op.lhs).fmt(pt), |
| 42197 | 42172 | ops[0].tracking(cg), |
| ... | ... | @@ -42320,7 +42295,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 42320 | 42295 | .{ ._, ._, .lea, .dst0p, .leai(.src0, .dst0), ._, ._ }, |
| 42321 | 42296 | } }, |
| 42322 | 42297 | } }) catch |err| switch (err) { |
| 42323 | error.SelectFailed => return cg.fail("failed to select {s} {} {} {}", .{ | |
| 42298 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | |
| 42324 | 42299 | @tagName(air_tag), |
| 42325 | 42300 | cg.typeOf(bin_op.lhs).fmt(pt), |
| 42326 | 42301 | ops[0].tracking(cg), |
| ... | ... | @@ -46485,7 +46460,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 46485 | 46460 | .{ ._, ._nc, .j, .@"0b", ._, ._, ._ }, |
| 46486 | 46461 | } }, |
| 46487 | 46462 | } }) catch |err| switch (err) { |
| 46488 | error.SelectFailed => return cg.fail("failed to select {s} {} {} {}", .{ | |
| 46463 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | |
| 46489 | 46464 | @tagName(air_tag), |
| 46490 | 46465 | cg.typeOf(bin_op.lhs).fmt(pt), |
| 46491 | 46466 | ops[0].tracking(cg), |
| ... | ... | @@ -50644,7 +50619,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 50644 | 50619 | .{ ._, ._nc, .j, .@"0b", ._, ._, ._ }, |
| 50645 | 50620 | } }, |
| 50646 | 50621 | } }) catch |err| switch (err) { |
| 50647 | error.SelectFailed => return cg.fail("failed to select {s} {} {} {}", .{ | |
| 50622 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | |
| 50648 | 50623 | @tagName(air_tag), |
| 50649 | 50624 | cg.typeOf(bin_op.lhs).fmt(pt), |
| 50650 | 50625 | ops[0].tracking(cg), |
| ... | ... | @@ -51493,7 +51468,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 51493 | 51468 | .{ ._, ._, .mov, .memad(.dst0q, .add_src0_size, -8), .tmp0q, ._, ._ }, |
| 51494 | 51469 | } }, |
| 51495 | 51470 | } }) catch |err| switch (err) { |
| 51496 | error.SelectFailed => return cg.fail("failed to select {s} {} {} {}", .{ | |
| 51471 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | |
| 51497 | 51472 | @tagName(air_tag), |
| 51498 | 51473 | ty_pl.ty.toType().fmt(pt), |
| 51499 | 51474 | ops[0].tracking(cg), |
| ... | ... | @@ -52398,7 +52373,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 52398 | 52373 | .{ ._, ._, .mov, .memad(.dst0q, .add_src0_size, -8), .tmp0q, ._, ._ }, |
| 52399 | 52374 | } }, |
| 52400 | 52375 | } }) catch |err| switch (err) { |
| 52401 | error.SelectFailed => return cg.fail("failed to select {s} {} {} {}", .{ | |
| 52376 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | |
| 52402 | 52377 | @tagName(air_tag), |
| 52403 | 52378 | ty_pl.ty.toType().fmt(pt), |
| 52404 | 52379 | ops[0].tracking(cg), |
| ... | ... | @@ -55995,7 +55970,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 55995 | 55970 | .{ ._, ._, .@"or", .tmp2q, .tmp1q, ._, ._ }, |
| 55996 | 55971 | } }, |
| 55997 | 55972 | } }) catch |err| switch (err) { |
| 55998 | error.SelectFailed => return cg.fail("failed to select {s} {} {} {}", .{ | |
| 55973 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | |
| 55999 | 55974 | @tagName(air_tag), |
| 56000 | 55975 | ty_pl.ty.toType().fmt(pt), |
| 56001 | 55976 | ops[0].tracking(cg), |
| ... | ... | @@ -59735,7 +59710,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 59735 | 59710 | } }, |
| 59736 | 59711 | } }, |
| 59737 | 59712 | }) catch |err| switch (err) { |
| 59738 | error.SelectFailed => return cg.fail("failed to select {s} {} {} {}", .{ | |
| 59713 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | |
| 59739 | 59714 | @tagName(air_tag), |
| 59740 | 59715 | cg.typeOf(bin_op.lhs).fmt(pt), |
| 59741 | 59716 | ops[0].tracking(cg), |
| ... | ... | @@ -60298,7 +60273,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 60298 | 60273 | .{ ._, ._nz, .j, .@"0b", ._, ._, ._ }, |
| 60299 | 60274 | } }, |
| 60300 | 60275 | } }) catch |err| switch (err) { |
| 60301 | error.SelectFailed => return cg.fail("failed to select {s} {} {} {} {}", .{ | |
| 60276 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f} {f}", .{ | |
| 60302 | 60277 | @tagName(air_tag), |
| 60303 | 60278 | cg.typeOf(bin_op.lhs).fmt(pt), |
| 60304 | 60279 | cg.typeOf(bin_op.rhs).fmt(pt), |
| ... | ... | @@ -60660,7 +60635,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 60660 | 60635 | .{ ._, ._ns, .j, .@"0b", ._, ._, ._ }, |
| 60661 | 60636 | } }, |
| 60662 | 60637 | } }) catch |err| switch (err) { |
| 60663 | error.SelectFailed => return cg.fail("failed to select {s} {} {} {} {}", .{ | |
| 60638 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f} {f}", .{ | |
| 60664 | 60639 | @tagName(air_tag), |
| 60665 | 60640 | cg.typeOf(bin_op.lhs).fmt(pt), |
| 60666 | 60641 | cg.typeOf(bin_op.rhs).fmt(pt), |
| ... | ... | @@ -60672,7 +60647,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 60672 | 60647 | switch (air_tag) { |
| 60673 | 60648 | else => unreachable, |
| 60674 | 60649 | .shl => res[0].wrapInt(cg) catch |err| switch (err) { |
| 60675 | error.SelectFailed => return cg.fail("failed to select {s} wrap {} {}", .{ | |
| 60650 | error.SelectFailed => return cg.fail("failed to select {s} wrap {f} {f}", .{ | |
| 60676 | 60651 | @tagName(air_tag), |
| 60677 | 60652 | cg.typeOf(bin_op.lhs).fmt(pt), |
| 60678 | 60653 | res[0].tracking(cg), |
| ... | ... | @@ -65329,7 +65304,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 65329 | 65304 | .{ ._, ._b, .j, .@"0b", ._, ._, ._ }, |
| 65330 | 65305 | } }, |
| 65331 | 65306 | } }) catch |err| switch (err) { |
| 65332 | error.SelectFailed => return cg.fail("failed to select {s} {} {}", .{ | |
| 65307 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ | |
| 65333 | 65308 | @tagName(air_tag), |
| 65334 | 65309 | ty_op.ty.toType().fmt(pt), |
| 65335 | 65310 | ops[0].tracking(cg), |
| ... | ... | @@ -68483,7 +68458,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 68483 | 68458 | .{ ._, ._nc, .j, .@"0b", ._, ._, ._ }, |
| 68484 | 68459 | } }, |
| 68485 | 68460 | } }) catch |err| switch (err) { |
| 68486 | error.SelectFailed => return cg.fail("failed to select {s} {} {}", .{ | |
| 68461 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ | |
| 68487 | 68462 | @tagName(air_tag), |
| 68488 | 68463 | cg.typeOf(ty_op.operand).fmt(pt), |
| 68489 | 68464 | ops[0].tracking(cg), |
| ... | ... | @@ -68880,7 +68855,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 68880 | 68855 | .{ .@"0:", ._, .lea, .dst0d, .leasia(.dst0, .@"8", .tmp0, .add_8_src0_size), ._, ._ }, |
| 68881 | 68856 | } }, |
| 68882 | 68857 | } }) catch |err| switch (err) { |
| 68883 | error.SelectFailed => return cg.fail("failed to select {s} {} {}", .{ | |
| 68858 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ | |
| 68884 | 68859 | @tagName(air_tag), |
| 68885 | 68860 | cg.typeOf(ty_op.operand).fmt(pt), |
| 68886 | 68861 | ops[0].tracking(cg), |
| ... | ... | @@ -69768,7 +69743,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 69768 | 69743 | .{ ._, ._ae, .j, .@"0b", ._, ._, ._ }, |
| 69769 | 69744 | } }, |
| 69770 | 69745 | } }) catch |err| switch (err) { |
| 69771 | error.SelectFailed => return cg.fail("failed to select {s} {} {}", .{ | |
| 69746 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ | |
| 69772 | 69747 | @tagName(air_tag), |
| 69773 | 69748 | cg.typeOf(ty_op.operand).fmt(pt), |
| 69774 | 69749 | ops[0].tracking(cg), |
| ... | ... | @@ -70417,7 +70392,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 70417 | 70392 | .{ ._, ._ae, .j, .@"0b", ._, ._, ._ }, |
| 70418 | 70393 | } }, |
| 70419 | 70394 | } }) catch |err| switch (err) { |
| 70420 | error.SelectFailed => return cg.fail("failed to select {s} {} {}", .{ | |
| 70395 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ | |
| 70421 | 70396 | @tagName(air_tag), |
| 70422 | 70397 | ty_op.ty.toType().fmt(pt), |
| 70423 | 70398 | ops[0].tracking(cg), |
| ... | ... | @@ -73519,7 +73494,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 73519 | 73494 | .{ ._, ._ae, .j, .@"0b", ._, ._, ._ }, |
| 73520 | 73495 | } }, |
| 73521 | 73496 | } }) catch |err| switch (err) { |
| 73522 | error.SelectFailed => return cg.fail("failed to select {s} {} {}", .{ | |
| 73497 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ | |
| 73523 | 73498 | @tagName(air_tag), |
| 73524 | 73499 | ty_op.ty.toType().fmt(pt), |
| 73525 | 73500 | ops[0].tracking(cg), |
| ... | ... | @@ -74457,7 +74432,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 74457 | 74432 | .{ ._, ._nc, .j, .@"0b", ._, ._, ._ }, |
| 74458 | 74433 | } }, |
| 74459 | 74434 | } }) catch |err| switch (err) { |
| 74460 | error.SelectFailed => return cg.fail("failed to select {s} {} {}", .{ | |
| 74435 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ | |
| 74461 | 74436 | @tagName(air_tag), |
| 74462 | 74437 | cg.typeOf(un_op).fmt(pt), |
| 74463 | 74438 | ops[0].tracking(cg), |
| ... | ... | @@ -75183,7 +75158,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 75183 | 75158 | } }, |
| 75184 | 75159 | } }, |
| 75185 | 75160 | }) catch |err| switch (err) { |
| 75186 | error.SelectFailed => return cg.fail("failed to select {s} {} {}", .{ | |
| 75161 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ | |
| 75187 | 75162 | @tagName(air_tag), |
| 75188 | 75163 | cg.typeOf(un_op).fmt(pt), |
| 75189 | 75164 | ops[0].tracking(cg), |
| ... | ... | @@ -76734,7 +76709,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 76734 | 76709 | .{ ._, ._nc, .j, .@"0b", ._, ._, ._ }, |
| 76735 | 76710 | } }, |
| 76736 | 76711 | } }) catch |err| switch (err) { |
| 76737 | error.SelectFailed => return cg.fail("failed to select {s} {} {}", .{ | |
| 76712 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ | |
| 76738 | 76713 | @tagName(air_tag), |
| 76739 | 76714 | cg.typeOf(ty_op.operand).fmt(pt), |
| 76740 | 76715 | ops[0].tracking(cg), |
| ... | ... | @@ -77926,7 +77901,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 77926 | 77901 | } }, |
| 77927 | 77902 | } }, |
| 77928 | 77903 | }) catch |err| switch (err) { |
| 77929 | error.SelectFailed => return cg.fail("failed to select {s} {} {}", .{ | |
| 77904 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ | |
| 77930 | 77905 | @tagName(air_tag), |
| 77931 | 77906 | cg.typeOf(un_op).fmt(pt), |
| 77932 | 77907 | ops[0].tracking(cg), |
| ... | ... | @@ -78466,7 +78441,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 78466 | 78441 | .{ ._, ._nc, .j, .@"0b", ._, ._, ._ }, |
| 78467 | 78442 | } }, |
| 78468 | 78443 | } }) catch |err| switch (err) { |
| 78469 | error.SelectFailed => return cg.fail("failed to select {s} {} {}", .{ | |
| 78444 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ | |
| 78470 | 78445 | @tagName(air_tag), |
| 78471 | 78446 | cg.typeOf(un_op).fmt(pt), |
| 78472 | 78447 | ops[0].tracking(cg), |
| ... | ... | @@ -78913,7 +78888,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 78913 | 78888 | } else err: { |
| 78914 | 78889 | res[0] = ops[0].cmpInts(cmp_op, &ops[1], cg) catch |err| break :err err; |
| 78915 | 78890 | }) catch |err| switch (err) { |
| 78916 | error.SelectFailed => return cg.fail("failed to select {s} {} {} {}", .{ | |
| 78891 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | |
| 78917 | 78892 | @tagName(air_tag), |
| 78918 | 78893 | cg.typeOf(bin_op.lhs).fmt(pt), |
| 78919 | 78894 | ops[0].tracking(cg), |
| ... | ... | @@ -79470,7 +79445,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 79470 | 79445 | res[0] = ops[0].cmpInts(cmp_op, &ops[1], cg) catch |err| break :err err; |
| 79471 | 79446 | }, |
| 79472 | 79447 | }) catch |err| switch (err) { |
| 79473 | error.SelectFailed => return cg.fail("failed to select {s} {} {} {}", .{ | |
| 79448 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | |
| 79474 | 79449 | @tagName(air_tag), |
| 79475 | 79450 | ty.fmt(pt), |
| 79476 | 79451 | ops[0].tracking(cg), |
| ... | ... | @@ -88546,7 +88521,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 88546 | 88521 | .{ ._, ._ae, .j, .@"0b", ._, ._, ._ }, |
| 88547 | 88522 | } }, |
| 88548 | 88523 | } }) catch |err| switch (err) { |
| 88549 | error.SelectFailed => return cg.fail("failed to select {s} {} {} {}", .{ | |
| 88524 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | |
| 88550 | 88525 | @tagName(air_tag), |
| 88551 | 88526 | ty_op.ty.toType().fmt(pt), |
| 88552 | 88527 | cg.typeOf(ty_op.operand).fmt(pt), |
| ... | ... | @@ -90221,7 +90196,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 90221 | 90196 | .{ ._, ._ae, .j, .@"0b", ._, ._, ._ }, |
| 90222 | 90197 | } }, |
| 90223 | 90198 | } }) catch |err| switch (err) { |
| 90224 | error.SelectFailed => return cg.fail("failed to select {s} {} {} {}", .{ | |
| 90199 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | |
| 90225 | 90200 | @tagName(air_tag), |
| 90226 | 90201 | ty_op.ty.toType().fmt(pt), |
| 90227 | 90202 | cg.typeOf(ty_op.operand).fmt(pt), |
| ... | ... | @@ -94899,7 +94874,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 94899 | 94874 | .{ ._, ._nz, .j, .@"0b", ._, ._, ._ }, |
| 94900 | 94875 | } }, |
| 94901 | 94876 | } }) catch |err| switch (err) { |
| 94902 | error.SelectFailed => return cg.fail("failed to select {s} {} {} {}", .{ | |
| 94877 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | |
| 94903 | 94878 | @tagName(air_tag), |
| 94904 | 94879 | dst_ty.fmt(pt), |
| 94905 | 94880 | src_ty.fmt(pt), |
| ... | ... | @@ -100565,7 +100540,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 100565 | 100540 | .{ ._, ._nz, .j, .@"0b", ._, ._, ._ }, |
| 100566 | 100541 | } }, |
| 100567 | 100542 | } }) catch |err| switch (err) { |
| 100568 | error.SelectFailed => return cg.fail("failed to select {s} {} {} {}", .{ | |
| 100543 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | |
| 100569 | 100544 | @tagName(air_tag), |
| 100570 | 100545 | ty_op.ty.toType().fmt(pt), |
| 100571 | 100546 | cg.typeOf(ty_op.operand).fmt(pt), |
| ... | ... | @@ -111427,7 +111402,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 111427 | 111402 | .{ ._, ._ae, .j, .@"0b", ._, ._, ._ }, |
| 111428 | 111403 | } }, |
| 111429 | 111404 | } }) catch |err| switch (err) { |
| 111430 | error.SelectFailed => return cg.fail("failed to select {s} {} {} {}", .{ | |
| 111405 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | |
| 111431 | 111406 | @tagName(air_tag), |
| 111432 | 111407 | ty_op.ty.toType().fmt(pt), |
| 111433 | 111408 | cg.typeOf(ty_op.operand).fmt(pt), |
| ... | ... | @@ -123446,7 +123421,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 123446 | 123421 | .{ ._, ._ae, .j, .@"0b", ._, ._, ._ }, |
| 123447 | 123422 | } }, |
| 123448 | 123423 | } }) catch |err| switch (err) { |
| 123449 | error.SelectFailed => return cg.fail("failed to select {s} {} {} {}", .{ | |
| 123424 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{ | |
| 123450 | 123425 | @tagName(air_tag), |
| 123451 | 123426 | ty_op.ty.toType().fmt(pt), |
| 123452 | 123427 | cg.typeOf(ty_op.operand).fmt(pt), |
| ... | ... | @@ -166464,7 +166439,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 166464 | 166439 | .{ ._, ._, .@"test", .src0p, .src0p, ._, ._ }, |
| 166465 | 166440 | } }, |
| 166466 | 166441 | } }) catch |err| switch (err) { |
| 166467 | error.SelectFailed => return cg.fail("failed to select {s} {} {}", .{ | |
| 166442 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ | |
| 166468 | 166443 | @tagName(air_tag), |
| 166469 | 166444 | cg.typeOf(un_op).fmt(pt), |
| 166470 | 166445 | ops[0].tracking(cg), |
| ... | ... | @@ -166552,7 +166527,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 166552 | 166527 | .{ ._, ._, .call, .tmp0d, ._, ._, ._ }, |
| 166553 | 166528 | } }, |
| 166554 | 166529 | } }) catch |err| switch (err) { |
| 166555 | error.SelectFailed => return cg.fail("failed to select {s} {} {}", .{ | |
| 166530 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ | |
| 166556 | 166531 | @tagName(air_tag), |
| 166557 | 166532 | cg.typeOf(un_op).fmt(pt), |
| 166558 | 166533 | ops[0].tracking(cg), |
| ... | ... | @@ -166654,7 +166629,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 166654 | 166629 | .{ ._, ._, .lea, .dst1d, .leai(.dst1, .tmp1), ._, ._ }, |
| 166655 | 166630 | } }, |
| 166656 | 166631 | } }) catch |err| switch (err) { |
| 166657 | error.SelectFailed => return cg.fail("failed to select {s} {} {}", .{ | |
| 166632 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ | |
| 166658 | 166633 | @tagName(air_tag), |
| 166659 | 166634 | cg.typeOf(un_op).fmt(pt), |
| 166660 | 166635 | ops[0].tracking(cg), |
| ... | ... | @@ -166752,7 +166727,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 166752 | 166727 | .{ ._, ._, .@"test", .src0d, .src0d, ._, ._ }, |
| 166753 | 166728 | } }, |
| 166754 | 166729 | } }) catch |err| switch (err) { |
| 166755 | error.SelectFailed => return cg.fail("failed to select {s} {} {}", .{ | |
| 166730 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{ | |
| 166756 | 166731 | @tagName(air_tag), |
| 166757 | 166732 | ty_op.ty.toType().fmt(pt), |
| 166758 | 166733 | ops[0].tracking(cg), |
| ... | ... | @@ -166804,7 +166779,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 166804 | 166779 | } |
| 166805 | 166780 | } |
| 166806 | 166781 | }, |
| 166807 | .@"packed" => return cg.fail("failed to select {s} {}", .{ | |
| 166782 | .@"packed" => return cg.fail("failed to select {s} {f}", .{ | |
| 166808 | 166783 | @tagName(air_tag), |
| 166809 | 166784 | agg_ty.fmt(pt), |
| 166810 | 166785 | }), |
| ... | ... | @@ -166825,7 +166800,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 166825 | 166800 | elem_disp += @intCast(field_type.abiSize(zcu)); |
| 166826 | 166801 | } |
| 166827 | 166802 | }, |
| 166828 | else => return cg.fail("failed to select {s} {}", .{ | |
| 166803 | else => return cg.fail("failed to select {s} {f}", .{ | |
| 166829 | 166804 | @tagName(air_tag), |
| 166830 | 166805 | agg_ty.fmt(pt), |
| 166831 | 166806 | }), |
| ... | ... | @@ -168123,7 +168098,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 168123 | 168098 | .{ ._, ._ae, .j, .@"0b", ._, ._, ._ }, |
| 168124 | 168099 | } }, |
| 168125 | 168100 | } }) catch |err| switch (err) { |
| 168126 | error.SelectFailed => return cg.fail("failed to select {s} {} {} {} {}", .{ | |
| 168101 | error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f} {f}", .{ | |
| 168127 | 168102 | @tagName(air_tag), |
| 168128 | 168103 | cg.typeOf(bin_op.lhs).fmt(pt), |
| 168129 | 168104 | ops[0].tracking(cg), |
| ... | ... | @@ -168223,7 +168198,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 168223 | 168198 | .{ ._, ._, .cmp, .src0d, .lea(.tmp1d), ._, ._ }, |
| 168224 | 168199 | } }, |
| 168225 | 168200 | } }) catch |err| switch (err) { |
| 168226 | error.SelectFailed => return cg.fail("failed to select {s} {}", .{ | |
| 168201 | error.SelectFailed => return cg.fail("failed to select {s} {f}", .{ | |
| 168227 | 168202 | @tagName(air_tag), |
| 168228 | 168203 | ops[0].tracking(cg), |
| 168229 | 168204 | }), |
| ... | ... | @@ -168242,12 +168217,12 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 168242 | 168217 | .ref => { |
| 168243 | 168218 | const result = try cg.allocRegOrMem(err_ret_trace_index, true); |
| 168244 | 168219 | try cg.genCopy(.usize, result, ops[0].tracking(cg).short, .{}); |
| 168245 | tracking_log.debug("{} => {} (birth)", .{ err_ret_trace_index, result }); | |
| 168220 | tracking_log.debug("{f} => {f} (birth)", .{ err_ret_trace_index, result }); | |
| 168246 | 168221 | cg.inst_tracking.putAssumeCapacityNoClobber(err_ret_trace_index, .init(result)); |
| 168247 | 168222 | }, |
| 168248 | 168223 | .temp => |temp_index| { |
| 168249 | 168224 | const temp_tracking = temp_index.tracking(cg); |
| 168250 | tracking_log.debug("{} => {} (birth)", .{ err_ret_trace_index, temp_tracking.short }); | |
| 168225 | tracking_log.debug("{f} => {f} (birth)", .{ err_ret_trace_index, temp_tracking.short }); | |
| 168251 | 168226 | cg.inst_tracking.putAssumeCapacityNoClobber(err_ret_trace_index, temp_tracking.*); |
| 168252 | 168227 | assert(cg.reuseTemp(err_ret_trace_index, temp_index.toIndex(), temp_tracking)); |
| 168253 | 168228 | }, |
| ... | ... | @@ -168917,7 +168892,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 168917 | 168892 | try cg.resetTemps(@enumFromInt(0)); |
| 168918 | 168893 | cg.checkInvariantsAfterAirInst(); |
| 168919 | 168894 | } |
| 168920 | verbose_tracking_log.debug("{}", .{cg.fmtTracking()}); | |
| 168895 | verbose_tracking_log.debug("{f}", .{cg.fmtTracking()}); | |
| 168921 | 168896 | } |
| 168922 | 168897 | |
| 168923 | 168898 | fn genLazy(cg: *CodeGen, lazy_sym: link.File.LazySymbol) InnerError!void { |
| ... | ... | @@ -168927,7 +168902,7 @@ fn genLazy(cg: *CodeGen, lazy_sym: link.File.LazySymbol) InnerError!void { |
| 168927 | 168902 | switch (ip.indexToKey(lazy_sym.ty)) { |
| 168928 | 168903 | .enum_type => { |
| 168929 | 168904 | const enum_ty: Type = .fromInterned(lazy_sym.ty); |
| 168930 | wip_mir_log.debug("{}.@tagName:", .{enum_ty.fmt(pt)}); | |
| 168905 | wip_mir_log.debug("{f}.@tagName:", .{enum_ty.fmt(pt)}); | |
| 168931 | 168906 | |
| 168932 | 168907 | const param_regs = abi.getCAbiIntParamRegs(.auto); |
| 168933 | 168908 | const param_locks = cg.register_manager.lockRegsAssumeUnused(2, param_regs[0..2].*); |
| ... | ... | @@ -168976,7 +168951,7 @@ fn genLazy(cg: *CodeGen, lazy_sym: link.File.LazySymbol) InnerError!void { |
| 168976 | 168951 | }, |
| 168977 | 168952 | .error_set_type => |error_set_type| { |
| 168978 | 168953 | const err_ty: Type = .fromInterned(lazy_sym.ty); |
| 168979 | wip_mir_log.debug("{}.@errorCast:", .{err_ty.fmt(pt)}); | |
| 168954 | wip_mir_log.debug("{f}.@errorCast:", .{err_ty.fmt(pt)}); | |
| 168980 | 168955 | |
| 168981 | 168956 | const param_regs = abi.getCAbiIntParamRegs(.auto); |
| 168982 | 168957 | const param_locks = cg.register_manager.lockRegsAssumeUnused(2, param_regs[0..2].*); |
| ... | ... | @@ -169016,7 +168991,7 @@ fn genLazy(cg: *CodeGen, lazy_sym: link.File.LazySymbol) InnerError!void { |
| 169016 | 168991 | try cg.asmOpOnly(.{ ._, .ret }); |
| 169017 | 168992 | }, |
| 169018 | 168993 | else => return cg.fail( |
| 169019 | "TODO implement {s} for {}", | |
| 168994 | "TODO implement {s} for {f}", | |
| 169020 | 168995 | .{ @tagName(lazy_sym.kind), Type.fromInterned(lazy_sym.ty).fmt(pt) }, |
| 169021 | 168996 | ), |
| 169022 | 168997 | } |
| ... | ... | @@ -169076,7 +169051,7 @@ fn finishAirResult(self: *CodeGen, inst: Air.Inst.Index, result: MCValue) void { |
| 169076 | 169051 | .none, .dead, .unreach => {}, |
| 169077 | 169052 | else => unreachable, // Why didn't the result die? |
| 169078 | 169053 | } else { |
| 169079 | tracking_log.debug("{} => {} (birth)", .{ inst, result }); | |
| 169054 | tracking_log.debug("{f} => {f} (birth)", .{ inst, result }); | |
| 169080 | 169055 | self.inst_tracking.putAssumeCapacityNoClobber(inst, .init(result)); |
| 169081 | 169056 | // In some cases, an operand may be reused as the result. |
| 169082 | 169057 | // If that operand died and was a register, it was freed by |
| ... | ... | @@ -169226,7 +169201,7 @@ fn allocMemPtr(self: *CodeGen, inst: Air.Inst.Index) !FrameIndex { |
| 169226 | 169201 | const val_ty = ptr_ty.childType(zcu); |
| 169227 | 169202 | return self.allocFrameIndex(.init(.{ |
| 169228 | 169203 | .size = std.math.cast(u32, val_ty.abiSize(zcu)) orelse { |
| 169229 | return self.fail("type '{}' too big to fit into stack frame", .{val_ty.fmt(pt)}); | |
| 169204 | return self.fail("type '{f}' too big to fit into stack frame", .{val_ty.fmt(pt)}); | |
| 169230 | 169205 | }, |
| 169231 | 169206 | .alignment = ptr_ty.ptrAlignment(zcu).max(.@"1"), |
| 169232 | 169207 | })); |
| ... | ... | @@ -169244,7 +169219,7 @@ fn allocRegOrMemAdvanced(self: *CodeGen, ty: Type, inst: ?Air.Inst.Index, reg_ok |
| 169244 | 169219 | const pt = self.pt; |
| 169245 | 169220 | const zcu = pt.zcu; |
| 169246 | 169221 | const abi_size = std.math.cast(u32, ty.abiSize(zcu)) orelse { |
| 169247 | return self.fail("type '{}' too big to fit into stack frame", .{ty.fmt(pt)}); | |
| 169222 | return self.fail("type '{f}' too big to fit into stack frame", .{ty.fmt(pt)}); | |
| 169248 | 169223 | }; |
| 169249 | 169224 | |
| 169250 | 169225 | if (reg_ok) need_mem: { |
| ... | ... | @@ -169749,7 +169724,7 @@ fn airFpext(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 169749 | 169724 | ); |
| 169750 | 169725 | } |
| 169751 | 169726 | break :result dst_mcv; |
| 169752 | } orelse return self.fail("TODO implement airFpext from {} to {}", .{ | |
| 169727 | } orelse return self.fail("TODO implement airFpext from {f} to {f}", .{ | |
| 169753 | 169728 | src_ty.fmt(pt), dst_ty.fmt(pt), |
| 169754 | 169729 | }); |
| 169755 | 169730 | return self.finishAir(inst, result, .{ ty_op.operand, .none, .none }); |
| ... | ... | @@ -170004,7 +169979,7 @@ fn airIntCast(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 170004 | 169979 | ); |
| 170005 | 169980 | |
| 170006 | 169981 | break :result dst_mcv; |
| 170007 | }) orelse return self.fail("TODO implement airIntCast from {} to {}", .{ | |
| 169982 | }) orelse return self.fail("TODO implement airIntCast from {f} to {f}", .{ | |
| 170008 | 169983 | src_ty.fmt(pt), dst_ty.fmt(pt), |
| 170009 | 169984 | }); |
| 170010 | 169985 | return self.finishAir(inst, result, .{ ty_op.operand, .none, .none }); |
| ... | ... | @@ -170076,7 +170051,7 @@ fn airTrunc(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 170076 | 170051 | else => null, |
| 170077 | 170052 | }, |
| 170078 | 170053 | else => null, |
| 170079 | }) orelse return self.fail("TODO implement airTrunc for {}", .{dst_ty.fmt(pt)}); | |
| 170054 | }) orelse return self.fail("TODO implement airTrunc for {f}", .{dst_ty.fmt(pt)}); | |
| 170080 | 170055 | |
| 170081 | 170056 | const dst_info = dst_elem_ty.intInfo(zcu); |
| 170082 | 170057 | const src_info = src_elem_ty.intInfo(zcu); |
| ... | ... | @@ -170497,7 +170472,7 @@ fn airAddSat(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 170497 | 170472 | const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op; |
| 170498 | 170473 | const ty = self.typeOf(bin_op.lhs); |
| 170499 | 170474 | if (ty.zigTypeTag(zcu) == .vector or ty.abiSize(zcu) > 8) return self.fail( |
| 170500 | "TODO implement airAddSat for {}", | |
| 170475 | "TODO implement airAddSat for {f}", | |
| 170501 | 170476 | .{ty.fmt(pt)}, |
| 170502 | 170477 | ); |
| 170503 | 170478 | |
| ... | ... | @@ -170575,7 +170550,7 @@ fn airSubSat(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 170575 | 170550 | const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op; |
| 170576 | 170551 | const ty = self.typeOf(bin_op.lhs); |
| 170577 | 170552 | if (ty.zigTypeTag(zcu) == .vector or ty.abiSize(zcu) > 8) return self.fail( |
| 170578 | "TODO implement airSubSat for {}", | |
| 170553 | "TODO implement airSubSat for {f}", | |
| 170579 | 170554 | .{ty.fmt(pt)}, |
| 170580 | 170555 | ); |
| 170581 | 170556 | |
| ... | ... | @@ -170726,7 +170701,7 @@ fn airMulSat(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 170726 | 170701 | } |
| 170727 | 170702 | |
| 170728 | 170703 | if (ty.zigTypeTag(zcu) == .vector or ty.abiSize(zcu) > 8) return self.fail( |
| 170729 | "TODO implement airMulSat for {}", | |
| 170704 | "TODO implement airMulSat for {f}", | |
| 170730 | 170705 | .{ty.fmt(pt)}, |
| 170731 | 170706 | ); |
| 170732 | 170707 | |
| ... | ... | @@ -171020,7 +170995,7 @@ fn airMulWithOverflow(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 171020 | 170995 | const tuple_ty = self.typeOfIndex(inst); |
| 171021 | 170996 | const dst_ty = self.typeOf(bin_op.lhs); |
| 171022 | 170997 | const result: MCValue = switch (dst_ty.zigTypeTag(zcu)) { |
| 171023 | .vector => return self.fail("TODO implement airMulWithOverflow for {}", .{dst_ty.fmt(pt)}), | |
| 170998 | .vector => return self.fail("TODO implement airMulWithOverflow for {f}", .{dst_ty.fmt(pt)}), | |
| 171024 | 170999 | .int => result: { |
| 171025 | 171000 | const dst_info = dst_ty.intInfo(zcu); |
| 171026 | 171001 | if (dst_info.bits > 128 and dst_info.signedness == .unsigned) { |
| ... | ... | @@ -171373,7 +171348,7 @@ fn airMulWithOverflow(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 171373 | 171348 | else => { |
| 171374 | 171349 | // For now, this is the only supported multiply that doesn't fit in a register. |
| 171375 | 171350 | if (dst_info.bits > 128 or src_bits != 64) |
| 171376 | return self.fail("TODO implement airWithOverflow from {} to {}", .{ | |
| 171351 | return self.fail("TODO implement airWithOverflow from {f} to {f}", .{ | |
| 171377 | 171352 | src_ty.fmt(pt), dst_ty.fmt(pt), |
| 171378 | 171353 | }); |
| 171379 | 171354 | |
| ... | ... | @@ -171774,7 +171749,7 @@ fn airShlShrBinOp(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 171774 | 171749 | }, |
| 171775 | 171750 | else => {}, |
| 171776 | 171751 | } |
| 171777 | return self.fail("TODO implement airShlShrBinOp for {}", .{lhs_ty.fmt(pt)}); | |
| 171752 | return self.fail("TODO implement airShlShrBinOp for {f}", .{lhs_ty.fmt(pt)}); | |
| 171778 | 171753 | }; |
| 171779 | 171754 | return self.finishAir(inst, result, .{ bin_op.lhs, bin_op.rhs, .none }); |
| 171780 | 171755 | } |
| ... | ... | @@ -172034,7 +172009,7 @@ fn airUnwrapErrUnionErr(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 172034 | 172009 | .index = frame_addr.index, |
| 172035 | 172010 | .off = frame_addr.off + @as(i32, @intCast(err_off)), |
| 172036 | 172011 | } }, |
| 172037 | else => return self.fail("TODO implement unwrap_err_err for {}", .{operand}), | |
| 172012 | else => return self.fail("TODO implement unwrap_err_err for {f}", .{operand}), | |
| 172038 | 172013 | } |
| 172039 | 172014 | }; |
| 172040 | 172015 | return self.finishAir(inst, result, .{ ty_op.operand, .none, .none }); |
| ... | ... | @@ -172196,7 +172171,7 @@ fn genUnwrapErrUnionPayloadMir( |
| 172196 | 172171 | else |
| 172197 | 172172 | .{ .register = try self.copyToTmpRegister(payload_ty, result_mcv) }; |
| 172198 | 172173 | }, |
| 172199 | else => return self.fail("TODO implement genUnwrapErrUnionPayloadMir for {}", .{err_union}), | |
| 172174 | else => return self.fail("TODO implement genUnwrapErrUnionPayloadMir for {f}", .{err_union}), | |
| 172200 | 172175 | } |
| 172201 | 172176 | }; |
| 172202 | 172177 | |
| ... | ... | @@ -172362,7 +172337,7 @@ fn airSliceLen(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 172362 | 172337 | .index = frame_addr.index, |
| 172363 | 172338 | .off = frame_addr.off + 8, |
| 172364 | 172339 | } }, |
| 172365 | else => return self.fail("TODO implement slice_len for {}", .{src_mcv}), | |
| 172340 | else => return self.fail("TODO implement slice_len for {f}", .{src_mcv}), | |
| 172366 | 172341 | }; |
| 172367 | 172342 | if (self.reuseOperand(inst, ty_op.operand, 0, src_mcv)) { |
| 172368 | 172343 | switch (src_mcv) { |
| ... | ... | @@ -172645,7 +172620,7 @@ fn airArrayElemVal(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 172645 | 172620 | }.to64(), |
| 172646 | 172621 | ), |
| 172647 | 172622 | }, |
| 172648 | else => return self.fail("TODO airArrayElemVal for {s} of {}", .{ | |
| 172623 | else => return self.fail("TODO airArrayElemVal for {s} of {f}", .{ | |
| 172649 | 172624 | @tagName(array_mat_mcv), array_ty.fmt(pt), |
| 172650 | 172625 | }), |
| 172651 | 172626 | } |
| ... | ... | @@ -172688,7 +172663,7 @@ fn airArrayElemVal(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 172688 | 172663 | .load_extern_func, |
| 172689 | 172664 | .lea_extern_func, |
| 172690 | 172665 | => try self.genSetReg(addr_reg, .usize, array_mcv.address(), .{}), |
| 172691 | else => return self.fail("TODO airArrayElemVal_val for {s} of {}", .{ | |
| 172666 | else => return self.fail("TODO airArrayElemVal_val for {s} of {f}", .{ | |
| 172692 | 172667 | @tagName(array_mcv), array_ty.fmt(pt), |
| 172693 | 172668 | }), |
| 172694 | 172669 | } |
| ... | ... | @@ -172881,7 +172856,7 @@ fn airGetUnionTag(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 172881 | 172856 | } |
| 172882 | 172857 | |
| 172883 | 172858 | return self.fail( |
| 172884 | "TODO implement get_union_tag for ABI larger than 8 bytes and operand {}", | |
| 172859 | "TODO implement get_union_tag for ABI larger than 8 bytes and operand {f}", | |
| 172885 | 172860 | .{operand}, |
| 172886 | 172861 | ); |
| 172887 | 172862 | }, |
| ... | ... | @@ -172893,7 +172868,7 @@ fn airGetUnionTag(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 172893 | 172868 | .register = registerAlias(result.register, @intCast(layout.tag_size)), |
| 172894 | 172869 | }; |
| 172895 | 172870 | }, |
| 172896 | else => return self.fail("TODO implement get_union_tag for {}", .{operand}), | |
| 172871 | else => return self.fail("TODO implement get_union_tag for {f}", .{operand}), | |
| 172897 | 172872 | } |
| 172898 | 172873 | }; |
| 172899 | 172874 | |
| ... | ... | @@ -172909,7 +172884,7 @@ fn airClz(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 172909 | 172884 | |
| 172910 | 172885 | const dst_ty = self.typeOfIndex(inst); |
| 172911 | 172886 | const src_ty = self.typeOf(ty_op.operand); |
| 172912 | if (src_ty.zigTypeTag(zcu) == .vector) return self.fail("TODO implement airClz for {}", .{ | |
| 172887 | if (src_ty.zigTypeTag(zcu) == .vector) return self.fail("TODO implement airClz for {f}", .{ | |
| 172913 | 172888 | src_ty.fmt(pt), |
| 172914 | 172889 | }); |
| 172915 | 172890 | |
| ... | ... | @@ -173105,7 +173080,7 @@ fn airCtz(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 173105 | 173080 | |
| 173106 | 173081 | const dst_ty = self.typeOfIndex(inst); |
| 173107 | 173082 | const src_ty = self.typeOf(ty_op.operand); |
| 173108 | if (src_ty.zigTypeTag(zcu) == .vector) return self.fail("TODO implement airCtz for {}", .{ | |
| 173083 | if (src_ty.zigTypeTag(zcu) == .vector) return self.fail("TODO implement airCtz for {f}", .{ | |
| 173109 | 173084 | src_ty.fmt(pt), |
| 173110 | 173085 | }); |
| 173111 | 173086 | |
| ... | ... | @@ -173277,7 +173252,7 @@ fn airPopCount(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 173277 | 173252 | const src_ty = self.typeOf(ty_op.operand); |
| 173278 | 173253 | const src_abi_size: u32 = @intCast(src_ty.abiSize(zcu)); |
| 173279 | 173254 | if (src_ty.zigTypeTag(zcu) == .vector or src_abi_size > 16) |
| 173280 | return self.fail("TODO implement airPopCount for {}", .{src_ty.fmt(pt)}); | |
| 173255 | return self.fail("TODO implement airPopCount for {f}", .{src_ty.fmt(pt)}); | |
| 173281 | 173256 | const src_mcv = try self.resolveInst(ty_op.operand); |
| 173282 | 173257 | |
| 173283 | 173258 | const mat_src_mcv = switch (src_mcv) { |
| ... | ... | @@ -173430,7 +173405,7 @@ fn genByteSwap( |
| 173430 | 173405 | const has_movbe = self.hasFeature(.movbe); |
| 173431 | 173406 | |
| 173432 | 173407 | if (src_ty.zigTypeTag(zcu) == .vector) return self.fail( |
| 173433 | "TODO implement genByteSwap for {}", | |
| 173408 | "TODO implement genByteSwap for {f}", | |
| 173434 | 173409 | .{src_ty.fmt(pt)}, |
| 173435 | 173410 | ); |
| 173436 | 173411 | |
| ... | ... | @@ -173739,7 +173714,7 @@ fn floatSign(self: *CodeGen, inst: Air.Inst.Index, tag: Air.Inst.Tag, operand: A |
| 173739 | 173714 | const result = result: { |
| 173740 | 173715 | const scalar_bits = ty.scalarType(zcu).floatBits(self.target); |
| 173741 | 173716 | if (scalar_bits == 80) { |
| 173742 | if (ty.zigTypeTag(zcu) != .float) return self.fail("TODO implement floatSign for {}", .{ | |
| 173717 | if (ty.zigTypeTag(zcu) != .float) return self.fail("TODO implement floatSign for {f}", .{ | |
| 173743 | 173718 | ty.fmt(pt), |
| 173744 | 173719 | }); |
| 173745 | 173720 | |
| ... | ... | @@ -173763,7 +173738,7 @@ fn floatSign(self: *CodeGen, inst: Air.Inst.Index, tag: Air.Inst.Tag, operand: A |
| 173763 | 173738 | const abi_size: u32 = switch (ty.abiSize(zcu)) { |
| 173764 | 173739 | 1...16 => 16, |
| 173765 | 173740 | 17...32 => 32, |
| 173766 | else => return self.fail("TODO implement floatSign for {}", .{ | |
| 173741 | else => return self.fail("TODO implement floatSign for {f}", .{ | |
| 173767 | 173742 | ty.fmt(pt), |
| 173768 | 173743 | }), |
| 173769 | 173744 | }; |
| ... | ... | @@ -173822,7 +173797,7 @@ fn floatSign(self: *CodeGen, inst: Air.Inst.Index, tag: Air.Inst.Tag, operand: A |
| 173822 | 173797 | .abs => .{ .v_pd, .@"and" }, |
| 173823 | 173798 | else => unreachable, |
| 173824 | 173799 | }, |
| 173825 | 80 => return self.fail("TODO implement floatSign for {}", .{ty.fmt(pt)}), | |
| 173800 | 80 => return self.fail("TODO implement floatSign for {f}", .{ty.fmt(pt)}), | |
| 173826 | 173801 | else => unreachable, |
| 173827 | 173802 | }, |
| 173828 | 173803 | registerAlias(dst_reg, abi_size), |
| ... | ... | @@ -173848,7 +173823,7 @@ fn floatSign(self: *CodeGen, inst: Air.Inst.Index, tag: Air.Inst.Tag, operand: A |
| 173848 | 173823 | .abs => .{ ._pd, .@"and" }, |
| 173849 | 173824 | else => unreachable, |
| 173850 | 173825 | }, |
| 173851 | 80 => return self.fail("TODO implement floatSign for {}", .{ty.fmt(pt)}), | |
| 173826 | 80 => return self.fail("TODO implement floatSign for {f}", .{ty.fmt(pt)}), | |
| 173852 | 173827 | else => unreachable, |
| 173853 | 173828 | }, |
| 173854 | 173829 | registerAlias(dst_reg, abi_size), |
| ... | ... | @@ -173928,7 +173903,7 @@ fn genRoundLibcall(self: *CodeGen, ty: Type, src_mcv: MCValue, mode: bits.RoundM |
| 173928 | 173903 | if (self.getRoundTag(ty)) |_| return .none; |
| 173929 | 173904 | |
| 173930 | 173905 | if (ty.zigTypeTag(zcu) != .float) |
| 173931 | return self.fail("TODO implement genRound for {}", .{ty.fmt(pt)}); | |
| 173906 | return self.fail("TODO implement genRound for {f}", .{ty.fmt(pt)}); | |
| 173932 | 173907 | |
| 173933 | 173908 | var sym_buf: ["__trunc?".len]u8 = undefined; |
| 173934 | 173909 | return try self.genCall(.{ .extern_func = .{ |
| ... | ... | @@ -174164,7 +174139,7 @@ fn airAbs(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 174164 | 174139 | }, |
| 174165 | 174140 | .float => return self.floatSign(inst, .abs, ty_op.operand, ty), |
| 174166 | 174141 | }, |
| 174167 | }) orelse return self.fail("TODO implement airAbs for {}", .{ty.fmt(pt)}); | |
| 174142 | }) orelse return self.fail("TODO implement airAbs for {f}", .{ty.fmt(pt)}); | |
| 174168 | 174143 | |
| 174169 | 174144 | const abi_size: u32 = @intCast(ty.abiSize(zcu)); |
| 174170 | 174145 | const src_mcv = try self.resolveInst(ty_op.operand); |
| ... | ... | @@ -174323,7 +174298,7 @@ fn airSqrt(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 174323 | 174298 | else => unreachable, |
| 174324 | 174299 | }, |
| 174325 | 174300 | else => unreachable, |
| 174326 | }) orelse return self.fail("TODO implement airSqrt for {}", .{ty.fmt(pt)}); | |
| 174301 | }) orelse return self.fail("TODO implement airSqrt for {f}", .{ty.fmt(pt)}); | |
| 174327 | 174302 | switch (mir_tag[0]) { |
| 174328 | 174303 | .v_ss, .v_sd => if (src_mcv.isBase()) try self.asmRegisterRegisterMemory( |
| 174329 | 174304 | mir_tag, |
| ... | ... | @@ -174481,7 +174456,7 @@ fn packedLoad(self: *CodeGen, dst_mcv: MCValue, ptr_ty: Type, ptr_mcv: MCValue) |
| 174481 | 174456 | return; |
| 174482 | 174457 | } |
| 174483 | 174458 | |
| 174484 | if (val_abi_size > 8) return self.fail("TODO implement packed load of {}", .{val_ty.fmt(pt)}); | |
| 174459 | if (val_abi_size > 8) return self.fail("TODO implement packed load of {f}", .{val_ty.fmt(pt)}); | |
| 174485 | 174460 | |
| 174486 | 174461 | const limb_abi_size: u31 = @min(val_abi_size, 8); |
| 174487 | 174462 | const limb_abi_bits = limb_abi_size * 8; |
| ... | ... | @@ -174753,7 +174728,7 @@ fn packedStore(self: *CodeGen, ptr_ty: Type, ptr_mcv: MCValue, src_mcv: MCValue) |
| 174753 | 174728 | limb_mem, |
| 174754 | 174729 | registerAlias(tmp_reg, limb_abi_size), |
| 174755 | 174730 | ); |
| 174756 | } else return self.fail("TODO: implement packed store of {}", .{src_ty.fmt(pt)}); | |
| 174731 | } else return self.fail("TODO: implement packed store of {f}", .{src_ty.fmt(pt)}); | |
| 174757 | 174732 | } |
| 174758 | 174733 | } |
| 174759 | 174734 | |
| ... | ... | @@ -174856,7 +174831,7 @@ fn genUnOp(self: *CodeGen, maybe_inst: ?Air.Inst.Index, tag: Air.Inst.Tag, src_a |
| 174856 | 174831 | const zcu = pt.zcu; |
| 174857 | 174832 | const src_ty = self.typeOf(src_air); |
| 174858 | 174833 | if (src_ty.zigTypeTag(zcu) == .vector) |
| 174859 | return self.fail("TODO implement genUnOp for {}", .{src_ty.fmt(pt)}); | |
| 174834 | return self.fail("TODO implement genUnOp for {f}", .{src_ty.fmt(pt)}); | |
| 174860 | 174835 | |
| 174861 | 174836 | var src_mcv = try self.resolveInst(src_air); |
| 174862 | 174837 | switch (src_mcv) { |
| ... | ... | @@ -174943,7 +174918,7 @@ fn genUnOp(self: *CodeGen, maybe_inst: ?Air.Inst.Index, tag: Air.Inst.Tag, src_a |
| 174943 | 174918 | fn genUnOpMir(self: *CodeGen, mir_tag: Mir.Inst.FixedTag, dst_ty: Type, dst_mcv: MCValue) !void { |
| 174944 | 174919 | const pt = self.pt; |
| 174945 | 174920 | const abi_size: u32 = @intCast(dst_ty.abiSize(pt.zcu)); |
| 174946 | if (abi_size > 8) return self.fail("TODO implement {} for {}", .{ mir_tag, dst_ty.fmt(pt) }); | |
| 174921 | if (abi_size > 8) return self.fail("TODO implement {} for {f}", .{ mir_tag, dst_ty.fmt(pt) }); | |
| 174947 | 174922 | switch (dst_mcv) { |
| 174948 | 174923 | .none, |
| 174949 | 174924 | .unreach, |
| ... | ... | @@ -175672,7 +175647,7 @@ fn genBinOp( |
| 175672 | 175647 | }, |
| 175673 | 175648 | floatLibcAbiSuffix(lhs_ty), |
| 175674 | 175649 | }), |
| 175675 | else => return self.fail("TODO implement genBinOp for {s} {}", .{ | |
| 175650 | else => return self.fail("TODO implement genBinOp for {s} {f}", .{ | |
| 175676 | 175651 | @tagName(air_tag), lhs_ty.fmt(pt), |
| 175677 | 175652 | }), |
| 175678 | 175653 | } catch unreachable; |
| ... | ... | @@ -175785,7 +175760,7 @@ fn genBinOp( |
| 175785 | 175760 | ); |
| 175786 | 175761 | break :adjusted .{ .register = dst_reg }; |
| 175787 | 175762 | }, |
| 175788 | 80, 128 => return self.fail("TODO implement genBinOp for {s} of {}", .{ | |
| 175763 | 80, 128 => return self.fail("TODO implement genBinOp for {s} of {f}", .{ | |
| 175789 | 175764 | @tagName(air_tag), lhs_ty.fmt(pt), |
| 175790 | 175765 | }), |
| 175791 | 175766 | else => unreachable, |
| ... | ... | @@ -175819,7 +175794,7 @@ fn genBinOp( |
| 175819 | 175794 | if (sse_op and ((lhs_ty.scalarType(zcu).isRuntimeFloat() and |
| 175820 | 175795 | lhs_ty.scalarType(zcu).floatBits(self.target) == 80) or |
| 175821 | 175796 | lhs_ty.abiSize(zcu) > self.vectorSize(.float))) |
| 175822 | return self.fail("TODO implement genBinOp for {s} {}", .{ @tagName(air_tag), lhs_ty.fmt(pt) }); | |
| 175797 | return self.fail("TODO implement genBinOp for {s} {f}", .{ @tagName(air_tag), lhs_ty.fmt(pt) }); | |
| 175823 | 175798 | |
| 175824 | 175799 | const maybe_mask_reg = switch (air_tag) { |
| 175825 | 175800 | else => null, |
| ... | ... | @@ -176199,7 +176174,7 @@ fn genBinOp( |
| 176199 | 176174 | } |
| 176200 | 176175 | }, |
| 176201 | 176176 | |
| 176202 | else => return self.fail("TODO implement genBinOp for {s} {}", .{ | |
| 176177 | else => return self.fail("TODO implement genBinOp for {s} {f}", .{ | |
| 176203 | 176178 | @tagName(air_tag), lhs_ty.fmt(pt), |
| 176204 | 176179 | }), |
| 176205 | 176180 | } |
| ... | ... | @@ -176953,7 +176928,7 @@ fn genBinOp( |
| 176953 | 176928 | else => unreachable, |
| 176954 | 176929 | }, |
| 176955 | 176930 | }, |
| 176956 | }) orelse return self.fail("TODO implement genBinOp for {s} {}", .{ | |
| 176931 | }) orelse return self.fail("TODO implement genBinOp for {s} {f}", .{ | |
| 176957 | 176932 | @tagName(air_tag), lhs_ty.fmt(pt), |
| 176958 | 176933 | }); |
| 176959 | 176934 | |
| ... | ... | @@ -177086,7 +177061,7 @@ fn genBinOp( |
| 177086 | 177061 | else => unreachable, |
| 177087 | 177062 | }, |
| 177088 | 177063 | else => unreachable, |
| 177089 | }) orelse return self.fail("TODO implement genBinOp for {s} {}", .{ | |
| 177064 | }) orelse return self.fail("TODO implement genBinOp for {s} {f}", .{ | |
| 177090 | 177065 | @tagName(air_tag), lhs_ty.fmt(pt), |
| 177091 | 177066 | }), |
| 177092 | 177067 | mask_reg, |
| ... | ... | @@ -177118,7 +177093,7 @@ fn genBinOp( |
| 177118 | 177093 | else => unreachable, |
| 177119 | 177094 | }, |
| 177120 | 177095 | else => unreachable, |
| 177121 | }) orelse return self.fail("TODO implement genBinOp for {s} {}", .{ | |
| 177096 | }) orelse return self.fail("TODO implement genBinOp for {s} {f}", .{ | |
| 177122 | 177097 | @tagName(air_tag), lhs_ty.fmt(pt), |
| 177123 | 177098 | }), |
| 177124 | 177099 | dst_reg, |
| ... | ... | @@ -177154,7 +177129,7 @@ fn genBinOp( |
| 177154 | 177129 | else => unreachable, |
| 177155 | 177130 | }, |
| 177156 | 177131 | else => unreachable, |
| 177157 | }) orelse return self.fail("TODO implement genBinOp for {s} {}", .{ | |
| 177132 | }) orelse return self.fail("TODO implement genBinOp for {s} {f}", .{ | |
| 177158 | 177133 | @tagName(air_tag), lhs_ty.fmt(pt), |
| 177159 | 177134 | }), |
| 177160 | 177135 | mask_reg, |
| ... | ... | @@ -177185,7 +177160,7 @@ fn genBinOp( |
| 177185 | 177160 | else => unreachable, |
| 177186 | 177161 | }, |
| 177187 | 177162 | else => unreachable, |
| 177188 | }) orelse return self.fail("TODO implement genBinOp for {s} {}", .{ | |
| 177163 | }) orelse return self.fail("TODO implement genBinOp for {s} {f}", .{ | |
| 177189 | 177164 | @tagName(air_tag), lhs_ty.fmt(pt), |
| 177190 | 177165 | }), |
| 177191 | 177166 | dst_reg, |
| ... | ... | @@ -177215,7 +177190,7 @@ fn genBinOp( |
| 177215 | 177190 | else => unreachable, |
| 177216 | 177191 | }, |
| 177217 | 177192 | else => unreachable, |
| 177218 | }) orelse return self.fail("TODO implement genBinOp for {s} {}", .{ | |
| 177193 | }) orelse return self.fail("TODO implement genBinOp for {s} {f}", .{ | |
| 177219 | 177194 | @tagName(air_tag), lhs_ty.fmt(pt), |
| 177220 | 177195 | }); |
| 177221 | 177196 | try self.asmRegisterRegister(.{ mir_fixes, .@"and" }, dst_reg, mask_reg); |
| ... | ... | @@ -178022,7 +177997,7 @@ fn airArg(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 178022 | 177997 | |
| 178023 | 177998 | break :result dst_mcv; |
| 178024 | 177999 | }, |
| 178025 | else => return self.fail("TODO implement arg for {}", .{src_mcv}), | |
| 178000 | else => return self.fail("TODO implement arg for {f}", .{src_mcv}), | |
| 178026 | 178001 | } |
| 178027 | 178002 | }; |
| 178028 | 178003 | return self.finishAir(inst, result, .{ .none, .none, .none }); |
| ... | ... | @@ -179079,7 +179054,7 @@ fn genCondBrMir(self: *CodeGen, ty: Type, mcv: MCValue) !Mir.Inst.Index { |
| 179079 | 179054 | const reg = try self.copyToTmpRegister(ty, mcv); |
| 179080 | 179055 | return self.genCondBrMir(ty, .{ .register = reg }); |
| 179081 | 179056 | } |
| 179082 | return self.fail("TODO implement condbr when condition is {} with abi larger than 8 bytes", .{mcv}); | |
| 179057 | return self.fail("TODO implement condbr when condition is {f} with abi larger than 8 bytes", .{mcv}); | |
| 179083 | 179058 | }, |
| 179084 | 179059 | else => return self.fail("TODO implement condbr when condition is {s}", .{@tagName(mcv)}), |
| 179085 | 179060 | } |
| ... | ... | @@ -179166,7 +179141,7 @@ fn isErr(self: *CodeGen, maybe_inst: ?Air.Inst.Index, eu_ty: Type, eu_mcv: MCVal |
| 179166 | 179141 | } }, |
| 179167 | 179142 | .{ .immediate = 0 }, |
| 179168 | 179143 | ), |
| 179169 | else => return self.fail("TODO implement isErr for {}", .{eu_mcv}), | |
| 179144 | else => return self.fail("TODO implement isErr for {f}", .{eu_mcv}), | |
| 179170 | 179145 | } |
| 179171 | 179146 | |
| 179172 | 179147 | if (maybe_inst) |inst| self.eflags_inst = inst; |
| ... | ... | @@ -180916,7 +180891,7 @@ fn moveStrategy(cg: *CodeGen, ty: Type, class: Register.Class, aligned: bool) !M |
| 180916 | 180891 | }, |
| 180917 | 180892 | .ip, .cr, .dr => {}, |
| 180918 | 180893 | } |
| 180919 | return cg.fail("TODO moveStrategy for {}", .{ty.fmt(pt)}); | |
| 180894 | return cg.fail("TODO moveStrategy for {f}", .{ty.fmt(pt)}); | |
| 180920 | 180895 | } |
| 180921 | 180896 | |
| 180922 | 180897 | const CopyOptions = struct { |
| ... | ... | @@ -181048,7 +181023,7 @@ fn genCopy(self: *CodeGen, ty: Type, dst_mcv: MCValue, src_mcv: MCValue, opts: C |
| 181048 | 181023 | break :src_info .{ .addr_reg = src_addr_reg, .addr_lock = src_addr_lock }; |
| 181049 | 181024 | }, |
| 181050 | 181025 | .air_ref => |src_ref| return self.genCopy(ty, dst_mcv, try self.resolveInst(src_ref), opts), |
| 181051 | else => return self.fail("TODO implement genCopy for {s} of {}", .{ | |
| 181026 | else => return self.fail("TODO implement genCopy for {s} of {f}", .{ | |
| 181052 | 181027 | @tagName(src_mcv), ty.fmt(pt), |
| 181053 | 181028 | }), |
| 181054 | 181029 | }; |
| ... | ... | @@ -181424,7 +181399,7 @@ fn genSetReg( |
| 181424 | 181399 | 80 => null, |
| 181425 | 181400 | else => unreachable, |
| 181426 | 181401 | }, |
| 181427 | }) orelse return self.fail("TODO implement genSetReg for {}", .{ty.fmt(pt)}), | |
| 181402 | }) orelse return self.fail("TODO implement genSetReg for {f}", .{ty.fmt(pt)}), | |
| 181428 | 181403 | dst_alias, |
| 181429 | 181404 | registerAlias(src_reg, abi_size), |
| 181430 | 181405 | ), |
| ... | ... | @@ -181854,7 +181829,7 @@ fn genSetMem( |
| 181854 | 181829 | opts, |
| 181855 | 181830 | ); |
| 181856 | 181831 | }, |
| 181857 | else => return self.fail("TODO implement genSetMem for {s} of {}", .{ | |
| 181832 | else => return self.fail("TODO implement genSetMem for {s} of {f}", .{ | |
| 181858 | 181833 | @tagName(src_mcv), ty.fmt(pt), |
| 181859 | 181834 | }), |
| 181860 | 181835 | }, |
| ... | ... | @@ -182167,7 +182142,7 @@ fn airFloatFromInt(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 182167 | 182142 | 32, 64 => src_size > 8, |
| 182168 | 182143 | else => unreachable, |
| 182169 | 182144 | }) { |
| 182170 | if (src_bits > 128) return self.fail("TODO implement airFloatFromInt from {} to {}", .{ | |
| 182145 | if (src_bits > 128) return self.fail("TODO implement airFloatFromInt from {f} to {f}", .{ | |
| 182171 | 182146 | src_ty.fmt(pt), dst_ty.fmt(pt), |
| 182172 | 182147 | }); |
| 182173 | 182148 | |
| ... | ... | @@ -182209,7 +182184,7 @@ fn airFloatFromInt(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 182209 | 182184 | else => unreachable, |
| 182210 | 182185 | }, |
| 182211 | 182186 | else => null, |
| 182212 | }) orelse return self.fail("TODO implement airFloatFromInt from {} to {}", .{ | |
| 182187 | }) orelse return self.fail("TODO implement airFloatFromInt from {f} to {f}", .{ | |
| 182213 | 182188 | src_ty.fmt(pt), dst_ty.fmt(pt), |
| 182214 | 182189 | }); |
| 182215 | 182190 | const dst_alias = dst_reg.to128(); |
| ... | ... | @@ -182247,7 +182222,7 @@ fn airIntFromFloat(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 182247 | 182222 | 32, 64 => dst_size > 8, |
| 182248 | 182223 | else => unreachable, |
| 182249 | 182224 | }) { |
| 182250 | if (dst_bits > 128) return self.fail("TODO implement airIntFromFloat from {} to {}", .{ | |
| 182225 | if (dst_bits > 128) return self.fail("TODO implement airIntFromFloat from {f} to {f}", .{ | |
| 182251 | 182226 | src_ty.fmt(pt), dst_ty.fmt(pt), |
| 182252 | 182227 | }); |
| 182253 | 182228 | |
| ... | ... | @@ -182531,7 +182506,7 @@ fn atomicOp( |
| 182531 | 182506 | else => null, |
| 182532 | 182507 | }, |
| 182533 | 182508 | else => unreachable, |
| 182534 | }) orelse return self.fail("TODO implement atomicOp of {s} for {}", .{ | |
| 182509 | }) orelse return self.fail("TODO implement atomicOp of {s} for {f}", .{ | |
| 182535 | 182510 | @tagName(op), val_ty.fmt(pt), |
| 182536 | 182511 | }); |
| 182537 | 182512 | try self.genSetReg(sse_reg, val_ty, .{ .register = .rax }, .{}); |
| ... | ... | @@ -183286,7 +183261,7 @@ fn airSplat(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 183286 | 183261 | else => unreachable, |
| 183287 | 183262 | }, |
| 183288 | 183263 | } |
| 183289 | return self.fail("TODO implement airSplat for {}", .{vector_ty.fmt(pt)}); | |
| 183264 | return self.fail("TODO implement airSplat for {f}", .{vector_ty.fmt(pt)}); | |
| 183290 | 183265 | }; |
| 183291 | 183266 | return self.finishAir(inst, result, .{ ty_op.operand, .none, .none }); |
| 183292 | 183267 | } |
| ... | ... | @@ -183322,12 +183297,12 @@ fn airSelect(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 183322 | 183297 | else |
| 183323 | 183298 | try self.copyToTmpRegister(pred_ty, pred_mcv) |
| 183324 | 183299 | else |
| 183325 | return self.fail("TODO implement airSelect for {}", .{ty.fmt(pt)}), | |
| 183300 | return self.fail("TODO implement airSelect for {f}", .{ty.fmt(pt)}), | |
| 183326 | 183301 | else => unreachable, |
| 183327 | 183302 | }, |
| 183328 | 183303 | .register_mask => |pred_reg_mask| { |
| 183329 | 183304 | if (pred_reg_mask.info.scalar.bitSize(self.target) != 8 * elem_abi_size) |
| 183330 | return self.fail("TODO implement airSelect for {}", .{ty.fmt(pt)}); | |
| 183305 | return self.fail("TODO implement airSelect for {f}", .{ty.fmt(pt)}); | |
| 183331 | 183306 | |
| 183332 | 183307 | const mask_reg: Register = if (need_xmm0 and pred_reg_mask.reg.id() != comptime Register.xmm0.id()) mask_reg: { |
| 183333 | 183308 | try self.register_manager.getKnownReg(.xmm0, null); |
| ... | ... | @@ -183401,7 +183376,7 @@ fn airSelect(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 183401 | 183376 | else |
| 183402 | 183377 | null |
| 183403 | 183378 | else |
| 183404 | null) orelse return self.fail("TODO implement airSelect for {}", .{ty.fmt(pt)}); | |
| 183379 | null) orelse return self.fail("TODO implement airSelect for {f}", .{ty.fmt(pt)}); | |
| 183405 | 183380 | if (has_avx) { |
| 183406 | 183381 | const rhs_alias = if (reuse_mcv.isRegister()) |
| 183407 | 183382 | registerAlias(reuse_mcv.getReg().?, abi_size) |
| ... | ... | @@ -183554,7 +183529,7 @@ fn airSelect(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 183554 | 183529 | else => unreachable, |
| 183555 | 183530 | }), |
| 183556 | 183531 | ); |
| 183557 | } else return self.fail("TODO implement airSelect for {}", .{ty.fmt(pt)}); | |
| 183532 | } else return self.fail("TODO implement airSelect for {f}", .{ty.fmt(pt)}); | |
| 183558 | 183533 | const elem_bits: u16 = @intCast(elem_abi_size * 8); |
| 183559 | 183534 | if (!pred_fits_in_elem) if (self.hasFeature(.ssse3)) { |
| 183560 | 183535 | const mask_len = elem_abi_size * vec_len; |
| ... | ... | @@ -183583,7 +183558,7 @@ fn airSelect(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 183583 | 183558 | mask_alias, |
| 183584 | 183559 | mask_mem, |
| 183585 | 183560 | ); |
| 183586 | } else return self.fail("TODO implement airSelect for {}", .{ty.fmt(pt)}); | |
| 183561 | } else return self.fail("TODO implement airSelect for {f}", .{ty.fmt(pt)}); | |
| 183587 | 183562 | { |
| 183588 | 183563 | const mask_elem_ty = try pt.intType(.unsigned, elem_bits); |
| 183589 | 183564 | const mask_ty = try pt.vectorType(.{ .len = vec_len, .child = mask_elem_ty.toIntern() }); |
| ... | ... | @@ -183706,7 +183681,7 @@ fn airSelect(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 183706 | 183681 | else => null, |
| 183707 | 183682 | }, |
| 183708 | 183683 | }, |
| 183709 | }) orelse return self.fail("TODO implement airSelect for {}", .{ty.fmt(pt)}); | |
| 183684 | }) orelse return self.fail("TODO implement airSelect for {f}", .{ty.fmt(pt)}); | |
| 183710 | 183685 | if (has_avx) { |
| 183711 | 183686 | const rhs_alias = if (rhs_mcv.isRegister()) |
| 183712 | 183687 | registerAlias(rhs_mcv.getReg().?, abi_size) |
| ... | ... | @@ -184551,7 +184526,7 @@ fn airShuffle(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 184551 | 184526 | } |
| 184552 | 184527 | |
| 184553 | 184528 | break :result null; |
| 184554 | }) orelse return self.fail("TODO implement airShuffle from {} and {} to {} with {}", .{ | |
| 184529 | }) orelse return self.fail("TODO implement airShuffle from {f} and {f} to {f} with {f}", .{ | |
| 184555 | 184530 | lhs_ty.fmt(pt), |
| 184556 | 184531 | rhs_ty.fmt(pt), |
| 184557 | 184532 | dst_ty.fmt(pt), |
| ... | ... | @@ -184800,7 +184775,7 @@ fn airMulAdd(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 184800 | 184775 | 32, 64 => !self.hasFeature(.fma), |
| 184801 | 184776 | else => unreachable, |
| 184802 | 184777 | }) { |
| 184803 | if (ty.zigTypeTag(zcu) != .float) return self.fail("TODO implement airMulAdd for {}", .{ | |
| 184778 | if (ty.zigTypeTag(zcu) != .float) return self.fail("TODO implement airMulAdd for {f}", .{ | |
| 184804 | 184779 | ty.fmt(pt), |
| 184805 | 184780 | }); |
| 184806 | 184781 | |
| ... | ... | @@ -184930,7 +184905,7 @@ fn airMulAdd(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 184930 | 184905 | else => unreachable, |
| 184931 | 184906 | } |
| 184932 | 184907 | else |
| 184933 | unreachable) orelse return self.fail("TODO implement airMulAdd for {}", .{ty.fmt(pt)}); | |
| 184908 | unreachable) orelse return self.fail("TODO implement airMulAdd for {f}", .{ty.fmt(pt)}); | |
| 184934 | 184909 | |
| 184935 | 184910 | var mops: [3]MCValue = undefined; |
| 184936 | 184911 | for (order, mcvs) |mop_index, mcv| mops[mop_index - 1] = mcv; |
| ... | ... | @@ -185130,7 +185105,7 @@ fn airVaArg(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 185130 | 185105 | assert(classes.len == 1); |
| 185131 | 185106 | unreachable; |
| 185132 | 185107 | }, |
| 185133 | else => return self.fail("TODO implement c_va_arg for {} on SysV", .{promote_ty.fmt(pt)}), | |
| 185108 | else => return self.fail("TODO implement c_va_arg for {f} on SysV", .{promote_ty.fmt(pt)}), | |
| 185134 | 185109 | } |
| 185135 | 185110 | |
| 185136 | 185111 | if (unused) break :result .unreach; |
| ... | ... | @@ -185779,7 +185754,7 @@ fn splitType(self: *CodeGen, comptime parts_len: usize, ty: Type) ![parts_len]Ty |
| 185779 | 185754 | for (parts) |part| part_sizes += part.abiSize(zcu); |
| 185780 | 185755 | if (part_sizes == ty.abiSize(zcu)) return parts; |
| 185781 | 185756 | }; |
| 185782 | return self.fail("TODO implement splitType({d}, {})", .{ parts_len, ty.fmt(pt) }); | |
| 185757 | return self.fail("TODO implement splitType({d}, {f})", .{ parts_len, ty.fmt(pt) }); | |
| 185783 | 185758 | } |
| 185784 | 185759 | |
| 185785 | 185760 | /// Truncates the value in the register in place. |
| ... | ... | @@ -186153,7 +186128,7 @@ const Temp = struct { |
| 186153 | 186128 | cg.next_temp_index = @enumFromInt(@intFromEnum(new_temp_index) + 1); |
| 186154 | 186129 | const mcv = temp.tracking(cg).short; |
| 186155 | 186130 | switch (mcv) { |
| 186156 | else => std.debug.panic("{s}: {}\n", .{ @src().fn_name, mcv }), | |
| 186131 | else => std.debug.panic("{s}: {f}\n", .{ @src().fn_name, mcv }), | |
| 186157 | 186132 | .register => |reg| { |
| 186158 | 186133 | const new_reg = try cg.register_manager.allocReg(new_temp_index.toIndex(), abi.RegisterClass.gp); |
| 186159 | 186134 | new_temp_index.tracking(cg).* = .init(.{ .register = new_reg }); |
| ... | ... | @@ -186227,7 +186202,7 @@ const Temp = struct { |
| 186227 | 186202 | const new_temp_index = cg.next_temp_index; |
| 186228 | 186203 | cg.temp_type[@intFromEnum(new_temp_index)] = limb_ty; |
| 186229 | 186204 | switch (temp.tracking(cg).short) { |
| 186230 | else => |mcv| std.debug.panic("{s}: {}\n", .{ @src().fn_name, mcv }), | |
| 186205 | else => |mcv| std.debug.panic("{s}: {f}\n", .{ @src().fn_name, mcv }), | |
| 186231 | 186206 | .immediate => |imm| { |
| 186232 | 186207 | assert(limb_index == 0); |
| 186233 | 186208 | new_temp_index.tracking(cg).* = .init(.{ .immediate = imm }); |
| ... | ... | @@ -186568,7 +186543,7 @@ const Temp = struct { |
| 186568 | 186543 | }, |
| 186569 | 186544 | else => {}, |
| 186570 | 186545 | } |
| 186571 | std.debug.panic("{s}: {} {}\n", .{ @src().fn_name, temp_tracking, overflow_temp_tracking }); | |
| 186546 | std.debug.panic("{s}: {f} {f}\n", .{ @src().fn_name, temp_tracking, overflow_temp_tracking }); | |
| 186572 | 186547 | } |
| 186573 | 186548 | |
| 186574 | 186549 | fn asMask(temp: Temp, info: MaskInfo, cg: *CodeGen) void { |
| ... | ... | @@ -186658,7 +186633,7 @@ const Temp = struct { |
| 186658 | 186633 | while (try ptr.toLea(cg)) {} |
| 186659 | 186634 | const val_mcv = val.tracking(cg).short; |
| 186660 | 186635 | switch (val_mcv) { |
| 186661 | else => |mcv| std.debug.panic("{s}: {}\n", .{ @src().fn_name, mcv }), | |
| 186636 | else => |mcv| std.debug.panic("{s}: {f}\n", .{ @src().fn_name, mcv }), | |
| 186662 | 186637 | .register => |val_reg| try ptr.loadReg(val_ty, registerAlias( |
| 186663 | 186638 | val_reg, |
| 186664 | 186639 | @intCast(val_ty.abiSize(cg.pt.zcu)), |
| ... | ... | @@ -186698,7 +186673,7 @@ const Temp = struct { |
| 186698 | 186673 | {}) { |
| 186699 | 186674 | const val_mcv = val.tracking(cg).short; |
| 186700 | 186675 | switch (val_mcv) { |
| 186701 | else => |mcv| std.debug.panic("{s}: {}\n", .{ @src().fn_name, mcv }), | |
| 186676 | else => |mcv| std.debug.panic("{s}: {f}\n", .{ @src().fn_name, mcv }), | |
| 186702 | 186677 | .undef => if (opts.safe) { |
| 186703 | 186678 | var pat = try cg.tempInit(.u8, .{ .immediate = 0xaa }); |
| 186704 | 186679 | var len = try cg.tempInit(.usize, .{ .immediate = val_ty.abiSize(cg.pt.zcu) }); |
| ... | ... | @@ -186772,7 +186747,7 @@ const Temp = struct { |
| 186772 | 186747 | assert(!val_ty.optionalReprIsPayload(cg.pt.zcu)); |
| 186773 | 186748 | break :first_ty opt_child; |
| 186774 | 186749 | }, |
| 186775 | else => std.debug.panic("{s}: {}\n", .{ @src().fn_name, val_ty.fmt(cg.pt) }), | |
| 186750 | else => std.debug.panic("{s}: {f}\n", .{ @src().fn_name, val_ty.fmt(cg.pt) }), | |
| 186776 | 186751 | }); |
| 186777 | 186752 | const first_size: u31 = @intCast(first_ty.abiSize(cg.pt.zcu)); |
| 186778 | 186753 | try ptr.storeRegs(first_ty, &.{registerAlias(val_reg_ov.reg, first_size)}, cg); |
| ... | ... | @@ -186804,7 +186779,7 @@ const Temp = struct { |
| 186804 | 186779 | |
| 186805 | 186780 | fn readTo(src: *Temp, val_ty: Type, val_mcv: MCValue, opts: AccessOptions, cg: *CodeGen) InnerError!void { |
| 186806 | 186781 | switch (val_mcv) { |
| 186807 | else => |mcv| std.debug.panic("{s}: {}\n", .{ @src().fn_name, mcv }), | |
| 186782 | else => |mcv| std.debug.panic("{s}: {f}\n", .{ @src().fn_name, mcv }), | |
| 186808 | 186783 | .register => |val_reg| try src.readReg(opts.disp, val_ty, registerAlias( |
| 186809 | 186784 | val_reg, |
| 186810 | 186785 | @intCast(cg.unalignedSize(val_ty)), |
| ... | ... | @@ -186844,7 +186819,7 @@ const Temp = struct { |
| 186844 | 186819 | {}) { |
| 186845 | 186820 | const val_mcv = val.tracking(cg).short; |
| 186846 | 186821 | switch (val_mcv) { |
| 186847 | else => |mcv| std.debug.panic("{s}: {}\n", .{ @src().fn_name, mcv }), | |
| 186822 | else => |mcv| std.debug.panic("{s}: {f}\n", .{ @src().fn_name, mcv }), | |
| 186848 | 186823 | .none => {}, |
| 186849 | 186824 | .undef => if (opts.safe) { |
| 186850 | 186825 | var dst_ptr = try cg.tempInit(.usize, dst.tracking(cg).short.address().offset(opts.disp)); |
| ... | ... | @@ -186905,7 +186880,7 @@ const Temp = struct { |
| 186905 | 186880 | assert(!val_ty.optionalReprIsPayload(cg.pt.zcu)); |
| 186906 | 186881 | break :first_ty opt_child; |
| 186907 | 186882 | }, |
| 186908 | else => std.debug.panic("{s}: {}\n", .{ @src().fn_name, val_ty.fmt(cg.pt) }), | |
| 186883 | else => std.debug.panic("{s}: {f}\n", .{ @src().fn_name, val_ty.fmt(cg.pt) }), | |
| 186909 | 186884 | }); |
| 186910 | 186885 | const first_size: u31 = @intCast(first_ty.abiSize(cg.pt.zcu)); |
| 186911 | 186886 | try dst.writeReg(opts.disp, first_ty, registerAlias(val_reg_ov.reg, first_size), cg); |
| ... | ... | @@ -191677,12 +191652,12 @@ const Temp = struct { |
| 191677 | 191652 | break :result result; |
| 191678 | 191653 | }, |
| 191679 | 191654 | }; |
| 191680 | tracking_log.debug("{} => {} (birth)", .{ inst, result }); | |
| 191655 | tracking_log.debug("{f} => {f} (birth)", .{ inst, result }); | |
| 191681 | 191656 | cg.inst_tracking.putAssumeCapacityNoClobber(inst, .init(result)); |
| 191682 | 191657 | }, |
| 191683 | 191658 | .temp => |temp_index| { |
| 191684 | 191659 | const temp_tracking = temp_index.tracking(cg); |
| 191685 | tracking_log.debug("{} => {} (birth)", .{ inst, temp_tracking.short }); | |
| 191660 | tracking_log.debug("{f} => {f} (birth)", .{ inst, temp_tracking.short }); | |
| 191686 | 191661 | cg.inst_tracking.putAssumeCapacityNoClobber(inst, .init(temp_tracking.short)); |
| 191687 | 191662 | assert(cg.reuseTemp(inst, temp_index.toIndex(), temp_tracking)); |
| 191688 | 191663 | }, |
| ... | ... | @@ -191757,7 +191732,7 @@ fn resetTemps(cg: *CodeGen, from_index: Temp.Index) InnerError!void { |
| 191757 | 191732 | const temp: Temp.Index = @enumFromInt(temp_index); |
| 191758 | 191733 | if (temp.isValid(cg)) { |
| 191759 | 191734 | any_valid = true; |
| 191760 | tracking_log.err("failed to kill {}: {}", .{ | |
| 191735 | tracking_log.err("failed to kill {f}: {f}", .{ | |
| 191761 | 191736 | temp.toIndex(), |
| 191762 | 191737 | cg.temp_type[temp_index].fmt(cg.pt), |
| 191763 | 191738 | }); |
src/codegen/c.zig+62-56| ... | ... | @@ -340,13 +340,15 @@ fn isReservedIdent(ident: []const u8) bool { |
| 340 | 340 | } else return reserved_idents.has(ident); |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | fn formatIdent( | |
| 344 | ident: []const u8, | |
| 345 | comptime fmt_str: []const u8, | |
| 346 | _: std.fmt.FormatOptions, | |
| 347 | writer: anytype, | |
| 348 | ) @TypeOf(writer).Error!void { | |
| 349 | const solo = fmt_str.len != 0 and fmt_str[0] == ' '; // space means solo; not part of a bigger ident. | |
| 343 | fn formatIdentSolo(ident: []const u8, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 344 | return formatIdentOptions(ident, writer, true); | |
| 345 | } | |
| 346 | ||
| 347 | fn formatIdentUnsolo(ident: []const u8, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 348 | return formatIdentOptions(ident, writer, false); | |
| 349 | } | |
| 350 | ||
| 351 | fn formatIdentOptions(ident: []const u8, writer: *std.io.Writer, solo: bool) std.io.Writer.Error!void { | |
| 350 | 352 | if (solo and isReservedIdent(ident)) { |
| 351 | 353 | try writer.writeAll("zig_e_"); |
| 352 | 354 | } |
| ... | ... | @@ -363,30 +365,36 @@ fn formatIdent( |
| 363 | 365 | } |
| 364 | 366 | } |
| 365 | 367 | } |
| 366 | pub fn fmtIdent(ident: []const u8) std.fmt.Formatter(formatIdent) { | |
| 368 | ||
| 369 | pub fn fmtIdentSolo(ident: []const u8) std.fmt.Formatter([]const u8, formatIdentSolo) { | |
| 370 | return .{ .data = ident }; | |
| 371 | } | |
| 372 | ||
| 373 | pub fn fmtIdentUnsolo(ident: []const u8) std.fmt.Formatter([]const u8, formatIdentUnsolo) { | |
| 367 | 374 | return .{ .data = ident }; |
| 368 | 375 | } |
| 369 | 376 | |
| 370 | 377 | const CTypePoolStringFormatData = struct { |
| 371 | 378 | ctype_pool_string: CType.Pool.String, |
| 372 | 379 | ctype_pool: *const CType.Pool, |
| 380 | solo: bool, | |
| 373 | 381 | }; |
| 374 | fn formatCTypePoolString( | |
| 375 | data: CTypePoolStringFormatData, | |
| 376 | comptime fmt_str: []const u8, | |
| 377 | fmt_opts: std.fmt.FormatOptions, | |
| 378 | writer: anytype, | |
| 379 | ) @TypeOf(writer).Error!void { | |
| 382 | fn formatCTypePoolString(data: CTypePoolStringFormatData, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 380 | 383 | if (data.ctype_pool_string.toSlice(data.ctype_pool)) |slice| |
| 381 | try formatIdent(slice, fmt_str, fmt_opts, writer) | |
| 384 | try formatIdentOptions(slice, writer, data.solo) | |
| 382 | 385 | else |
| 383 | 386 | try writer.print("{}", .{data.ctype_pool_string.fmt(data.ctype_pool)}); |
| 384 | 387 | } |
| 385 | 388 | pub fn fmtCTypePoolString( |
| 386 | 389 | ctype_pool_string: CType.Pool.String, |
| 387 | 390 | ctype_pool: *const CType.Pool, |
| 388 | ) std.fmt.Formatter(formatCTypePoolString) { | |
| 389 | return .{ .data = .{ .ctype_pool_string = ctype_pool_string, .ctype_pool = ctype_pool } }; | |
| 391 | solo: bool, | |
| 392 | ) std.fmt.Formatter(CTypePoolStringFormatData, formatCTypePoolString) { | |
| 393 | return .{ .data = .{ | |
| 394 | .ctype_pool_string = ctype_pool_string, | |
| 395 | .ctype_pool = ctype_pool, | |
| 396 | .solo = solo, | |
| 397 | } }; | |
| 390 | 398 | } |
| 391 | 399 | |
| 392 | 400 | // Returns true if `formatIdent` would make any edits to ident. |
| ... | ... | @@ -596,7 +604,7 @@ pub const Function = struct { |
| 596 | 604 | return f.object.dg.renderIntCast(w, dest_ty, .{ .c_value = .{ .f = f, .value = src, .v = v } }, src_ty, location); |
| 597 | 605 | } |
| 598 | 606 | |
| 599 | fn fmtIntLiteral(f: *Function, val: Value) !std.fmt.Formatter(formatIntLiteral) { | |
| 607 | fn fmtIntLiteral(f: *Function, val: Value) !std.fmt.Formatter(FormatIntLiteralContext, formatIntLiteral) { | |
| 600 | 608 | return f.object.dg.fmtIntLiteral(val, .Other); |
| 601 | 609 | } |
| 602 | 610 | |
| ... | ... | @@ -614,16 +622,16 @@ pub const Function = struct { |
| 614 | 622 | gop.value_ptr.* = .{ |
| 615 | 623 | .fn_name = switch (key) { |
| 616 | 624 | .tag_name, |
| 617 | => |enum_ty| try ctype_pool.fmt(gpa, "zig_{s}_{}__{d}", .{ | |
| 625 | => |enum_ty| try ctype_pool.fmt(gpa, "zig_{s}_{f}__{d}", .{ | |
| 618 | 626 | @tagName(key), |
| 619 | fmtIdent(ip.loadEnumType(enum_ty).name.toSlice(ip)), | |
| 627 | fmtIdentUnsolo(ip.loadEnumType(enum_ty).name.toSlice(ip)), | |
| 620 | 628 | @intFromEnum(enum_ty), |
| 621 | 629 | }), |
| 622 | 630 | .never_tail, |
| 623 | 631 | .never_inline, |
| 624 | 632 | => |owner_nav| try ctype_pool.fmt(gpa, "zig_{s}_{}__{d}", .{ |
| 625 | 633 | @tagName(key), |
| 626 | fmtIdent(ip.getNav(owner_nav).name.toSlice(ip)), | |
| 634 | fmtIdentUnsolo(ip.getNav(owner_nav).name.toSlice(ip)), | |
| 627 | 635 | @intFromEnum(owner_nav), |
| 628 | 636 | }), |
| 629 | 637 | }, |
| ... | ... | @@ -965,7 +973,7 @@ pub const DeclGen = struct { |
| 965 | 973 | |
| 966 | 974 | fn renderErrorName(dg: *DeclGen, writer: anytype, err_name: InternPool.NullTerminatedString) !void { |
| 967 | 975 | const ip = &dg.pt.zcu.intern_pool; |
| 968 | try writer.print("zig_error_{}", .{fmtIdent(err_name.toSlice(ip))}); | |
| 976 | try writer.print("zig_error_{}", .{fmtIdentUnsolo(err_name.toSlice(ip))}); | |
| 969 | 977 | } |
| 970 | 978 | |
| 971 | 979 | fn renderValue( |
| ... | ... | @@ -1551,7 +1559,7 @@ pub const DeclGen = struct { |
| 1551 | 1559 | .payload => { |
| 1552 | 1560 | try writer.writeByte('{'); |
| 1553 | 1561 | if (field_ty.hasRuntimeBits(zcu)) { |
| 1554 | try writer.print(" .{ } = ", .{fmtIdent(field_name.toSlice(ip))}); | |
| 1562 | try writer.print(" .{ } = ", .{fmtIdentSolo(field_name.toSlice(ip))}); | |
| 1555 | 1563 | try dg.renderValue( |
| 1556 | 1564 | writer, |
| 1557 | 1565 | Value.fromInterned(un.val), |
| ... | ... | @@ -1888,7 +1896,7 @@ pub const DeclGen = struct { |
| 1888 | 1896 | kind: CType.Kind, |
| 1889 | 1897 | name: union(enum) { |
| 1890 | 1898 | nav: InternPool.Nav.Index, |
| 1891 | fmt_ctype_pool_string: std.fmt.Formatter(formatCTypePoolString), | |
| 1899 | fmt_ctype_pool_string: std.fmt.Formatter(CTypePoolStringFormatData, formatCTypePoolString), | |
| 1892 | 1900 | @"export": struct { |
| 1893 | 1901 | main_name: InternPool.NullTerminatedString, |
| 1894 | 1902 | extern_name: InternPool.NullTerminatedString, |
| ... | ... | @@ -1933,7 +1941,7 @@ pub const DeclGen = struct { |
| 1933 | 1941 | switch (name) { |
| 1934 | 1942 | .nav => |nav| try dg.renderNavName(w, nav), |
| 1935 | 1943 | .fmt_ctype_pool_string => |fmt| try w.print("{ }", .{fmt}), |
| 1936 | .@"export" => |@"export"| try w.print("{ }", .{fmtIdent(@"export".extern_name.toSlice(ip))}), | |
| 1944 | .@"export" => |@"export"| try w.print("{ }", .{fmtIdentSolo(@"export".extern_name.toSlice(ip))}), | |
| 1937 | 1945 | } |
| 1938 | 1946 | |
| 1939 | 1947 | try renderTypeSuffix( |
| ... | ... | @@ -1961,13 +1969,13 @@ pub const DeclGen = struct { |
| 1961 | 1969 | const is_export = @"export".extern_name != @"export".main_name; |
| 1962 | 1970 | if (is_mangled and is_export) { |
| 1963 | 1971 | try w.print(" zig_mangled_export({ }, {s}, {s})", .{ |
| 1964 | fmtIdent(extern_name), | |
| 1972 | fmtIdentSolo(extern_name), | |
| 1965 | 1973 | fmtStringLiteral(extern_name, null), |
| 1966 | 1974 | fmtStringLiteral(@"export".main_name.toSlice(ip), null), |
| 1967 | 1975 | }); |
| 1968 | 1976 | } else if (is_mangled) { |
| 1969 | 1977 | try w.print(" zig_mangled({ }, {s})", .{ |
| 1970 | fmtIdent(extern_name), fmtStringLiteral(extern_name, null), | |
| 1978 | fmtIdentSolo(extern_name), fmtStringLiteral(extern_name, null), | |
| 1971 | 1979 | }); |
| 1972 | 1980 | } else if (is_export) { |
| 1973 | 1981 | try w.print(" zig_export({s}, {s})", .{ |
| ... | ... | @@ -2198,7 +2206,7 @@ pub const DeclGen = struct { |
| 2198 | 2206 | .new_local, .local => |i| try w.print("t{d}", .{i}), |
| 2199 | 2207 | .constant => |uav| try renderUavName(w, uav), |
| 2200 | 2208 | .nav => |nav| try dg.renderNavName(w, nav), |
| 2201 | .identifier => |ident| try w.print("{ }", .{fmtIdent(ident)}), | |
| 2209 | .identifier => |ident| try w.print("{ }", .{fmtIdentSolo(ident)}), | |
| 2202 | 2210 | else => unreachable, |
| 2203 | 2211 | } |
| 2204 | 2212 | } |
| ... | ... | @@ -2215,13 +2223,13 @@ pub const DeclGen = struct { |
| 2215 | 2223 | try dg.renderNavName(w, nav); |
| 2216 | 2224 | }, |
| 2217 | 2225 | .undef => |ty| try dg.renderUndefValue(w, ty, .Other), |
| 2218 | .identifier => |ident| try w.print("{ }", .{fmtIdent(ident)}), | |
| 2226 | .identifier => |ident| try w.print("{ }", .{fmtIdentSolo(ident)}), | |
| 2219 | 2227 | .payload_identifier => |ident| try w.print("{ }.{ }", .{ |
| 2220 | fmtIdent("payload"), | |
| 2221 | fmtIdent(ident), | |
| 2228 | fmtIdentSolo("payload"), | |
| 2229 | fmtIdentSolo(ident), | |
| 2222 | 2230 | }), |
| 2223 | .ctype_pool_string => |string| try w.print("{ }", .{ | |
| 2224 | fmtCTypePoolString(string, &dg.ctype_pool), | |
| 2231 | .ctype_pool_string => |string| try w.print("{f}", .{ | |
| 2232 | fmtCTypePoolString(string, &dg.ctype_pool, true), | |
| 2225 | 2233 | }), |
| 2226 | 2234 | } |
| 2227 | 2235 | } |
| ... | ... | @@ -2245,10 +2253,10 @@ pub const DeclGen = struct { |
| 2245 | 2253 | }, |
| 2246 | 2254 | .nav_ref => |nav| try dg.renderNavName(w, nav), |
| 2247 | 2255 | .undef => unreachable, |
| 2248 | .identifier => |ident| try w.print("(*{ })", .{fmtIdent(ident)}), | |
| 2256 | .identifier => |ident| try w.print("(*{ })", .{fmtIdentSolo(ident)}), | |
| 2249 | 2257 | .payload_identifier => |ident| try w.print("(*{ }.{ })", .{ |
| 2250 | fmtIdent("payload"), | |
| 2251 | fmtIdent(ident), | |
| 2258 | fmtIdentSolo("payload"), | |
| 2259 | fmtIdentSolo(ident), | |
| 2252 | 2260 | }), |
| 2253 | 2261 | } |
| 2254 | 2262 | } |
| ... | ... | @@ -2334,14 +2342,14 @@ pub const DeclGen = struct { |
| 2334 | 2342 | const nav = ip.getNav(nav_index); |
| 2335 | 2343 | if (nav.getExtern(ip)) |@"extern"| { |
| 2336 | 2344 | try writer.print("{ }", .{ |
| 2337 | fmtIdent(ip.getNav(@"extern".owner_nav).name.toSlice(ip)), | |
| 2345 | fmtIdentSolo(ip.getNav(@"extern".owner_nav).name.toSlice(ip)), | |
| 2338 | 2346 | }); |
| 2339 | 2347 | } else { |
| 2340 | 2348 | // MSVC has a limit of 4095 character token length limit, and fmtIdent can (worst case), |
| 2341 | 2349 | // expand to 3x the length of its input, but let's cut it off at a much shorter limit. |
| 2342 | 2350 | const fqn_slice = ip.getNav(nav_index).fqn.toSlice(ip); |
| 2343 | 2351 | try writer.print("{}__{d}", .{ |
| 2344 | fmtIdent(fqn_slice[0..@min(fqn_slice.len, 100)]), | |
| 2352 | fmtIdentUnsolo(fqn_slice[0..@min(fqn_slice.len, 100)]), | |
| 2345 | 2353 | @intFromEnum(nav_index), |
| 2346 | 2354 | }); |
| 2347 | 2355 | } |
| ... | ... | @@ -2452,7 +2460,7 @@ fn renderFwdDeclTypeName( |
| 2452 | 2460 | switch (fwd_decl.name) { |
| 2453 | 2461 | .anon => try w.print("anon__lazy_{d}", .{@intFromEnum(ctype.index)}), |
| 2454 | 2462 | .index => |index| try w.print("{}__{d}", .{ |
| 2455 | fmtIdent(Type.fromInterned(index).containerTypeName(ip).toSlice(&zcu.intern_pool)), | |
| 2463 | fmtIdentUnsolo(Type.fromInterned(index).containerTypeName(ip).toSlice(&zcu.intern_pool)), | |
| 2456 | 2464 | @intFromEnum(index), |
| 2457 | 2465 | }), |
| 2458 | 2466 | } |
| ... | ... | @@ -2666,7 +2674,7 @@ fn renderFields( |
| 2666 | 2674 | .suffix, |
| 2667 | 2675 | .{}, |
| 2668 | 2676 | ); |
| 2669 | try writer.print("{}{ }", .{ trailing, fmtCTypePoolString(field_info.name, ctype_pool) }); | |
| 2677 | try writer.print("{}{f}", .{ trailing, fmtCTypePoolString(field_info.name, ctype_pool, true) }); | |
| 2670 | 2678 | try renderTypeSuffix(.flush, ctype_pool, zcu, writer, field_info.ctype, .suffix, .{}); |
| 2671 | 2679 | try writer.writeAll(";\n"); |
| 2672 | 2680 | } |
| ... | ... | @@ -2841,7 +2849,7 @@ pub fn genErrDecls(o: *Object) !void { |
| 2841 | 2849 | const name = name_nts.toSlice(ip); |
| 2842 | 2850 | if (val > 1) try writer.writeAll(", "); |
| 2843 | 2851 | try writer.print("{{" ++ name_prefix ++ "{}, {}}}", .{ |
| 2844 | fmtIdent(name), | |
| 2852 | fmtIdentUnsolo(name), | |
| 2845 | 2853 | try o.dg.fmtIntLiteral(try pt.intValue(.usize, name.len), .StaticInitializer), |
| 2846 | 2854 | }); |
| 2847 | 2855 | } |
| ... | ... | @@ -2891,7 +2899,7 @@ pub fn genLazyFn(o: *Object, lazy_ctype_pool: *const CType.Pool, lazy_fn: LazyFn |
| 2891 | 2899 | try w.writeAll(";\n return ("); |
| 2892 | 2900 | try o.dg.renderType(w, name_slice_ty); |
| 2893 | 2901 | try w.print("){{{}, {}}};\n", .{ |
| 2894 | fmtIdent("name"), | |
| 2902 | fmtIdentUnsolo("name"), | |
| 2895 | 2903 | try o.dg.fmtIntLiteral(try pt.intValue(.usize, tag_name_len), .Other), |
| 2896 | 2904 | }); |
| 2897 | 2905 | |
| ... | ... | @@ -3204,7 +3212,7 @@ pub fn genExports(dg: *DeclGen, exported: Zcu.Exported, export_indices: []const |
| 3204 | 3212 | .uav => |uav| try DeclGen.renderUavName(fwd, Value.fromInterned(uav)), |
| 3205 | 3213 | } |
| 3206 | 3214 | try fwd.writeByte(' '); |
| 3207 | try fwd.print("{ }", .{fmtIdent(main_name.toSlice(ip))}); | |
| 3215 | try fwd.print("{ }", .{fmtIdentSolo(main_name.toSlice(ip))}); | |
| 3208 | 3216 | try fwd.writeByte('\n'); |
| 3209 | 3217 | |
| 3210 | 3218 | const exported_val = exported.getValue(zcu); |
| ... | ... | @@ -3250,13 +3258,13 @@ pub fn genExports(dg: *DeclGen, exported: Zcu.Exported, export_indices: []const |
| 3250 | 3258 | ); |
| 3251 | 3259 | if (is_mangled and is_export) { |
| 3252 | 3260 | try fwd.print(" zig_mangled_export({ }, {s}, {s})", .{ |
| 3253 | fmtIdent(extern_name), | |
| 3261 | fmtIdentSolo(extern_name), | |
| 3254 | 3262 | fmtStringLiteral(extern_name, null), |
| 3255 | 3263 | fmtStringLiteral(main_name.toSlice(ip), null), |
| 3256 | 3264 | }); |
| 3257 | 3265 | } else if (is_mangled) { |
| 3258 | 3266 | try fwd.print(" zig_mangled({ }, {s})", .{ |
| 3259 | fmtIdent(extern_name), fmtStringLiteral(extern_name, null), | |
| 3267 | fmtIdentSolo(extern_name), fmtStringLiteral(extern_name, null), | |
| 3260 | 3268 | }); |
| 3261 | 3269 | } else if (is_export) { |
| 3262 | 3270 | try fwd.print(" zig_export({s}, {s})", .{ |
| ... | ... | @@ -4538,7 +4546,7 @@ fn airCmpLtErrorsLen(f: *Function, inst: Air.Inst.Index) !CValue { |
| 4538 | 4546 | try f.writeCValue(writer, local, .Other); |
| 4539 | 4547 | try writer.writeAll(" = "); |
| 4540 | 4548 | try f.writeCValue(writer, operand, .Other); |
| 4541 | try writer.print(" < sizeof({ }) / sizeof(*{0 });\n", .{fmtIdent("zig_errorName")}); | |
| 4549 | try writer.print(" < sizeof({ }) / sizeof(*{0 });\n", .{fmtIdentSolo("zig_errorName")}); | |
| 4542 | 4550 | return local; |
| 4543 | 4551 | } |
| 4544 | 4552 | |
| ... | ... | @@ -8202,10 +8210,9 @@ fn stringLiteral( |
| 8202 | 8210 | const FormatStringContext = struct { str: []const u8, sentinel: ?u8 }; |
| 8203 | 8211 | fn formatStringLiteral( |
| 8204 | 8212 | data: FormatStringContext, |
| 8205 | comptime fmt: []const u8, | |
| 8206 | _: std.fmt.FormatOptions, | |
| 8207 | writer: anytype, | |
| 8208 | ) @TypeOf(writer).Error!void { | |
| 8213 | writer: *std.io.Writer, | |
| 8214 | comptime fmt: []const u8, // TODO move this state to FormatStringContext | |
| 8215 | ) std.io.Writer.Error!void { | |
| 8209 | 8216 | if (fmt.len != 1 or fmt[0] != 's') @compileError("Invalid fmt: " ++ fmt); |
| 8210 | 8217 | |
| 8211 | 8218 | var literal = stringLiteral(writer, data.str.len + @intFromBool(data.sentinel != null)); |
| ... | ... | @@ -8215,7 +8222,7 @@ fn formatStringLiteral( |
| 8215 | 8222 | try literal.end(); |
| 8216 | 8223 | } |
| 8217 | 8224 | |
| 8218 | fn fmtStringLiteral(str: []const u8, sentinel: ?u8) std.fmt.Formatter(formatStringLiteral) { | |
| 8225 | fn fmtStringLiteral(str: []const u8, sentinel: ?u8) std.fmt.Formatter(FormatStringContext, formatStringLiteral) { | |
| 8219 | 8226 | return .{ .data = .{ .str = str, .sentinel = sentinel } }; |
| 8220 | 8227 | } |
| 8221 | 8228 | |
| ... | ... | @@ -8234,10 +8241,9 @@ const FormatIntLiteralContext = struct { |
| 8234 | 8241 | }; |
| 8235 | 8242 | fn formatIntLiteral( |
| 8236 | 8243 | data: FormatIntLiteralContext, |
| 8237 | comptime fmt: []const u8, | |
| 8238 | options: std.fmt.FormatOptions, | |
| 8239 | writer: anytype, | |
| 8240 | ) @TypeOf(writer).Error!void { | |
| 8244 | writer: *std.io.Writer, | |
| 8245 | comptime fmt: []const u8, // TODO move this state to FormatIntLiteralContext | |
| 8246 | ) std.io.Writer.Error!void { | |
| 8241 | 8247 | const pt = data.dg.pt; |
| 8242 | 8248 | const zcu = pt.zcu; |
| 8243 | 8249 | const target = &data.dg.mod.resolved_target.result; |
| ... | ... | @@ -8406,7 +8412,7 @@ fn formatIntLiteral( |
| 8406 | 8412 | .kind = data.kind, |
| 8407 | 8413 | .ctype = c_limb_ctype, |
| 8408 | 8414 | .val = try pt.intValue_big(.comptime_int, c_limb_mut.toConst()), |
| 8409 | }, fmt, options, writer); | |
| 8415 | }, fmt, writer); | |
| 8410 | 8416 | } |
| 8411 | 8417 | } |
| 8412 | 8418 | try data.ctype.renderLiteralSuffix(writer, ctype_pool); |
src/codegen/c/Type.zig+2-8| ... | ... | @@ -938,19 +938,13 @@ pub const Pool = struct { |
| 938 | 938 | index: String.Index, |
| 939 | 939 | |
| 940 | 940 | const FormatData = struct { string: String, pool: *const Pool }; |
| 941 | fn format( | |
| 942 | data: FormatData, | |
| 943 | comptime fmt_str: []const u8, | |
| 944 | _: std.fmt.FormatOptions, | |
| 945 | writer: anytype, | |
| 946 | ) @TypeOf(writer).Error!void { | |
| 947 | if (fmt_str.len > 0) @compileError("invalid format string '" ++ fmt_str ++ "'"); | |
| 941 | fn format(data: FormatData, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 948 | 942 | if (data.string.toSlice(data.pool)) |slice| |
| 949 | 943 | try writer.writeAll(slice) |
| 950 | 944 | else |
| 951 | 945 | try writer.print("f{d}", .{@intFromEnum(data.string.index)}); |
| 952 | 946 | } |
| 953 | pub fn fmt(str: String, pool: *const Pool) std.fmt.Formatter(format) { | |
| 947 | pub fn fmt(str: String, pool: *const Pool) std.fmt.Formatter(FormatData, format) { | |
| 954 | 948 | return .{ .data = .{ .string = str, .pool = pool } }; |
| 955 | 949 | } |
| 956 | 950 |
src/link/Coff.zig+14-29| ... | ... | @@ -3061,40 +3061,25 @@ const ImportTable = struct { |
| 3061 | 3061 | return base_vaddr + index * @sizeOf(u64); |
| 3062 | 3062 | } |
| 3063 | 3063 | |
| 3064 | const FormatContext = struct { | |
| 3064 | const Format = struct { | |
| 3065 | 3065 | itab: ImportTable, |
| 3066 | 3066 | ctx: Context, |
| 3067 | }; | |
| 3068 | 3067 | |
| 3069 | fn format(itab: ImportTable, comptime unused_format_string: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void { | |
| 3070 | _ = itab; | |
| 3071 | _ = unused_format_string; | |
| 3072 | _ = options; | |
| 3073 | _ = writer; | |
| 3074 | @compileError("do not format ImportTable directly; use itab.fmtDebug()"); | |
| 3075 | } | |
| 3076 | ||
| 3077 | fn format2( | |
| 3078 | fmt_ctx: FormatContext, | |
| 3079 | comptime unused_format_string: []const u8, | |
| 3080 | options: fmt.FormatOptions, | |
| 3081 | writer: anytype, | |
| 3082 | ) @TypeOf(writer).Error!void { | |
| 3083 | _ = options; | |
| 3084 | comptime assert(unused_format_string.len == 0); | |
| 3085 | const lib_name = fmt_ctx.ctx.coff.temp_strtab.getAssumeExists(fmt_ctx.ctx.name_off); | |
| 3086 | const base_vaddr = getBaseAddress(fmt_ctx.ctx); | |
| 3087 | try writer.print("IAT({s}.dll) @{x}:", .{ lib_name, base_vaddr }); | |
| 3088 | for (fmt_ctx.itab.entries.items, 0..) |entry, i| { | |
| 3089 | try writer.print("\n {d}@{?x} => {s}", .{ | |
| 3090 | i, | |
| 3091 | fmt_ctx.itab.getImportAddress(entry, fmt_ctx.ctx), | |
| 3092 | fmt_ctx.ctx.coff.getSymbolName(entry), | |
| 3093 | }); | |
| 3068 | fn default(f: Format, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 3069 | const lib_name = f.ctx.coff.temp_strtab.getAssumeExists(f.ctx.name_off); | |
| 3070 | const base_vaddr = getBaseAddress(f.ctx); | |
| 3071 | try writer.print("IAT({s}.dll) @{x}:", .{ lib_name, base_vaddr }); | |
| 3072 | for (f.itab.entries.items, 0..) |entry, i| { | |
| 3073 | try writer.print("\n {d}@{?x} => {s}", .{ | |
| 3074 | i, | |
| 3075 | f.itab.getImportAddress(entry, f.ctx), | |
| 3076 | f.ctx.coff.getSymbolName(entry), | |
| 3077 | }); | |
| 3078 | } | |
| 3094 | 3079 | } |
| 3095 | } | |
| 3080 | }; | |
| 3096 | 3081 | |
| 3097 | fn fmtDebug(itab: ImportTable, ctx: Context) fmt.Formatter(format2) { | |
| 3082 | fn fmtDebug(itab: ImportTable, ctx: Context) fmt.Formatter(Format, Format.default) { | |
| 3098 | 3083 | return .{ .data = .{ .itab = itab, .ctx = ctx } }; |
| 3099 | 3084 | } |
| 3100 | 3085 |
src/link/Elf.zig+10-39| ... | ... | @@ -3860,26 +3860,19 @@ pub fn failFile( |
| 3860 | 3860 | return error.LinkFailure; |
| 3861 | 3861 | } |
| 3862 | 3862 | |
| 3863 | const FormatShdrCtx = struct { | |
| 3863 | const FormatShdr = struct { | |
| 3864 | 3864 | elf_file: *Elf, |
| 3865 | 3865 | shdr: elf.Elf64_Shdr, |
| 3866 | 3866 | }; |
| 3867 | 3867 | |
| 3868 | fn fmtShdr(self: *Elf, shdr: elf.Elf64_Shdr) std.fmt.Formatter(formatShdr) { | |
| 3868 | fn fmtShdr(self: *Elf, shdr: elf.Elf64_Shdr) std.fmt.Formatter(FormatShdr, formatShdr) { | |
| 3869 | 3869 | return .{ .data = .{ |
| 3870 | 3870 | .shdr = shdr, |
| 3871 | 3871 | .elf_file = self, |
| 3872 | 3872 | } }; |
| 3873 | 3873 | } |
| 3874 | 3874 | |
| 3875 | fn formatShdr( | |
| 3876 | ctx: FormatShdrCtx, | |
| 3877 | comptime unused_fmt_string: []const u8, | |
| 3878 | options: std.fmt.FormatOptions, | |
| 3879 | writer: anytype, | |
| 3880 | ) !void { | |
| 3881 | _ = options; | |
| 3882 | _ = unused_fmt_string; | |
| 3875 | fn formatShdr(ctx: FormatShdr, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 3883 | 3876 | const shdr = ctx.shdr; |
| 3884 | 3877 | try writer.print("{s} : @{x} ({x}) : align({x}) : size({x}) : entsize({x}) : flags({})", .{ |
| 3885 | 3878 | ctx.elf_file.getShString(shdr.sh_name), shdr.sh_offset, |
| ... | ... | @@ -3889,18 +3882,11 @@ fn formatShdr( |
| 3889 | 3882 | }); |
| 3890 | 3883 | } |
| 3891 | 3884 | |
| 3892 | pub fn fmtShdrFlags(sh_flags: u64) std.fmt.Formatter(formatShdrFlags) { | |
| 3885 | pub fn fmtShdrFlags(sh_flags: u64) std.fmt.Formatter(u64, formatShdrFlags) { | |
| 3893 | 3886 | return .{ .data = sh_flags }; |
| 3894 | 3887 | } |
| 3895 | 3888 | |
| 3896 | fn formatShdrFlags( | |
| 3897 | sh_flags: u64, | |
| 3898 | comptime unused_fmt_string: []const u8, | |
| 3899 | options: std.fmt.FormatOptions, | |
| 3900 | writer: anytype, | |
| 3901 | ) !void { | |
| 3902 | _ = unused_fmt_string; | |
| 3903 | _ = options; | |
| 3889 | fn formatShdrFlags(sh_flags: u64, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 3904 | 3890 | if (elf.SHF_WRITE & sh_flags != 0) { |
| 3905 | 3891 | try writer.writeAll("W"); |
| 3906 | 3892 | } |
| ... | ... | @@ -3945,26 +3931,19 @@ fn formatShdrFlags( |
| 3945 | 3931 | } |
| 3946 | 3932 | } |
| 3947 | 3933 | |
| 3948 | const FormatPhdrCtx = struct { | |
| 3934 | const FormatPhdr = struct { | |
| 3949 | 3935 | elf_file: *Elf, |
| 3950 | 3936 | phdr: elf.Elf64_Phdr, |
| 3951 | 3937 | }; |
| 3952 | 3938 | |
| 3953 | fn fmtPhdr(self: *Elf, phdr: elf.Elf64_Phdr) std.fmt.Formatter(formatPhdr) { | |
| 3939 | fn fmtPhdr(self: *Elf, phdr: elf.Elf64_Phdr) std.fmt.Formatter(FormatPhdr, formatPhdr) { | |
| 3954 | 3940 | return .{ .data = .{ |
| 3955 | 3941 | .phdr = phdr, |
| 3956 | 3942 | .elf_file = self, |
| 3957 | 3943 | } }; |
| 3958 | 3944 | } |
| 3959 | 3945 | |
| 3960 | fn formatPhdr( | |
| 3961 | ctx: FormatPhdrCtx, | |
| 3962 | comptime unused_fmt_string: []const u8, | |
| 3963 | options: std.fmt.FormatOptions, | |
| 3964 | writer: anytype, | |
| 3965 | ) !void { | |
| 3966 | _ = options; | |
| 3967 | _ = unused_fmt_string; | |
| 3946 | fn formatPhdr(ctx: FormatPhdr, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 3968 | 3947 | const phdr = ctx.phdr; |
| 3969 | 3948 | const write = phdr.p_flags & elf.PF_W != 0; |
| 3970 | 3949 | const read = phdr.p_flags & elf.PF_R != 0; |
| ... | ... | @@ -3991,19 +3970,11 @@ fn formatPhdr( |
| 3991 | 3970 | }); |
| 3992 | 3971 | } |
| 3993 | 3972 | |
| 3994 | pub fn dumpState(self: *Elf) std.fmt.Formatter(fmtDumpState) { | |
| 3973 | pub fn dumpState(self: *Elf) std.fmt.Formatter(*Elf, fmtDumpState) { | |
| 3995 | 3974 | return .{ .data = self }; |
| 3996 | 3975 | } |
| 3997 | 3976 | |
| 3998 | fn fmtDumpState( | |
| 3999 | self: *Elf, | |
| 4000 | comptime unused_fmt_string: []const u8, | |
| 4001 | options: std.fmt.FormatOptions, | |
| 4002 | writer: anytype, | |
| 4003 | ) !void { | |
| 4004 | _ = unused_fmt_string; | |
| 4005 | _ = options; | |
| 4006 | ||
| 3977 | fn fmtDumpState(self: *Elf, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 4007 | 3978 | const shared_objects = self.shared_objects.values(); |
| 4008 | 3979 | |
| 4009 | 3980 | if (self.zigObjectPtr()) |zig_object| { |
src/link/Elf/Archive.zig+12-19| ... | ... | @@ -214,35 +214,28 @@ pub const ArSymtab = struct { |
| 214 | 214 | @compileError("do not format ar symtab directly; use fmt instead"); |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | const FormatContext = struct { | |
| 217 | const Format = struct { | |
| 218 | 218 | ar: ArSymtab, |
| 219 | 219 | elf_file: *Elf, |
| 220 | ||
| 221 | fn default(f: Format, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 222 | const ar = f.ar; | |
| 223 | const elf_file = f.elf_file; | |
| 224 | for (ar.symtab.items, 0..) |entry, i| { | |
| 225 | const name = ar.strtab.getAssumeExists(entry.off); | |
| 226 | const file = elf_file.file(entry.file_index).?; | |
| 227 | try writer.print(" {d}: {s} in file({d})({})\n", .{ i, name, entry.file_index, file.fmtPath() }); | |
| 228 | } | |
| 229 | } | |
| 220 | 230 | }; |
| 221 | 231 | |
| 222 | pub fn fmt(ar: ArSymtab, elf_file: *Elf) std.fmt.Formatter(format2) { | |
| 232 | pub fn fmt(ar: ArSymtab, elf_file: *Elf) std.fmt.Formatter(Format, Format.default) { | |
| 223 | 233 | return .{ .data = .{ |
| 224 | 234 | .ar = ar, |
| 225 | 235 | .elf_file = elf_file, |
| 226 | 236 | } }; |
| 227 | 237 | } |
| 228 | 238 | |
| 229 | fn format2( | |
| 230 | ctx: FormatContext, | |
| 231 | comptime unused_fmt_string: []const u8, | |
| 232 | options: std.fmt.FormatOptions, | |
| 233 | writer: anytype, | |
| 234 | ) !void { | |
| 235 | _ = unused_fmt_string; | |
| 236 | _ = options; | |
| 237 | const ar = ctx.ar; | |
| 238 | const elf_file = ctx.elf_file; | |
| 239 | for (ar.symtab.items, 0..) |entry, i| { | |
| 240 | const name = ar.strtab.getAssumeExists(entry.off); | |
| 241 | const file = elf_file.file(entry.file_index).?; | |
| 242 | try writer.print(" {d}: {s} in file({d})({})\n", .{ i, name, entry.file_index, file.fmtPath() }); | |
| 243 | } | |
| 244 | } | |
| 245 | ||
| 246 | 239 | const Entry = struct { |
| 247 | 240 | /// Offset into the string table. |
| 248 | 241 | off: u32, |
src/link/Elf/Atom.zig+28-48| ... | ... | @@ -904,65 +904,45 @@ pub fn setExtra(atom: Atom, extras: Extra, elf_file: *Elf) void { |
| 904 | 904 | atom.file(elf_file).?.setAtomExtra(atom.extra_index, extras); |
| 905 | 905 | } |
| 906 | 906 | |
| 907 | pub fn format( | |
| 908 | atom: Atom, | |
| 909 | comptime unused_fmt_string: []const u8, | |
| 910 | options: std.fmt.FormatOptions, | |
| 911 | writer: anytype, | |
| 912 | ) !void { | |
| 913 | _ = atom; | |
| 914 | _ = unused_fmt_string; | |
| 915 | _ = options; | |
| 916 | _ = writer; | |
| 917 | @compileError("do not format Atom directly"); | |
| 918 | } | |
| 919 | ||
| 920 | pub fn fmt(atom: Atom, elf_file: *Elf) std.fmt.Formatter(format2) { | |
| 907 | pub fn fmt(atom: Atom, elf_file: *Elf) std.fmt.Formatter(Format, Format.default) { | |
| 921 | 908 | return .{ .data = .{ |
| 922 | 909 | .atom = atom, |
| 923 | 910 | .elf_file = elf_file, |
| 924 | 911 | } }; |
| 925 | 912 | } |
| 926 | 913 | |
| 927 | const FormatContext = struct { | |
| 914 | const Format = struct { | |
| 928 | 915 | atom: Atom, |
| 929 | 916 | elf_file: *Elf, |
| 930 | }; | |
| 931 | 917 | |
| 932 | fn format2( | |
| 933 | ctx: FormatContext, | |
| 934 | comptime unused_fmt_string: []const u8, | |
| 935 | options: std.fmt.FormatOptions, | |
| 936 | writer: anytype, | |
| 937 | ) !void { | |
| 938 | _ = options; | |
| 939 | _ = unused_fmt_string; | |
| 940 | const atom = ctx.atom; | |
| 941 | const elf_file = ctx.elf_file; | |
| 942 | try writer.print("atom({d}) : {s} : @{x} : shdr({d}) : align({x}) : size({x}) : prev({}) : next({})", .{ | |
| 943 | atom.atom_index, atom.name(elf_file), atom.address(elf_file), | |
| 944 | atom.output_section_index, atom.alignment.toByteUnits() orelse 0, atom.size, | |
| 945 | atom.prev_atom_ref, atom.next_atom_ref, | |
| 946 | }); | |
| 947 | if (atom.file(elf_file)) |atom_file| switch (atom_file) { | |
| 948 | .object => |object| { | |
| 949 | if (atom.fdes(object).len > 0) { | |
| 950 | try writer.writeAll(" : fdes{ "); | |
| 951 | const extras = atom.extra(elf_file); | |
| 952 | for (atom.fdes(object), extras.fde_start..) |fde, i| { | |
| 953 | try writer.print("{d}", .{i}); | |
| 954 | if (!fde.alive) try writer.writeAll("([*])"); | |
| 955 | if (i - extras.fde_start < extras.fde_count - 1) try writer.writeAll(", "); | |
| 918 | fn default(f: Format, w: *std.io.Writer) std.io.Writer.Error!void { | |
| 919 | const atom = f.atom; | |
| 920 | const elf_file = f.elf_file; | |
| 921 | try w.print("atom({d}) : {s} : @{x} : shdr({d}) : align({x}) : size({x}) : prev({}) : next({})", .{ | |
| 922 | atom.atom_index, atom.name(elf_file), atom.address(elf_file), | |
| 923 | atom.output_section_index, atom.alignment.toByteUnits() orelse 0, atom.size, | |
| 924 | atom.prev_atom_ref, atom.next_atom_ref, | |
| 925 | }); | |
| 926 | if (atom.file(elf_file)) |atom_file| switch (atom_file) { | |
| 927 | .object => |object| { | |
| 928 | if (atom.fdes(object).len > 0) { | |
| 929 | try w.writeAll(" : fdes{ "); | |
| 930 | const extras = atom.extra(elf_file); | |
| 931 | for (atom.fdes(object), extras.fde_start..) |fde, i| { | |
| 932 | try w.print("{d}", .{i}); | |
| 933 | if (!fde.alive) try w.writeAll("([*])"); | |
| 934 | if (i - extras.fde_start < extras.fde_count - 1) try w.writeAll(", "); | |
| 935 | } | |
| 936 | try w.writeAll(" }"); | |
| 956 | 937 | } |
| 957 | try writer.writeAll(" }"); | |
| 958 | } | |
| 959 | }, | |
| 960 | else => {}, | |
| 961 | }; | |
| 962 | if (!atom.alive) { | |
| 963 | try writer.writeAll(" : [*]"); | |
| 938 | }, | |
| 939 | else => {}, | |
| 940 | }; | |
| 941 | if (!atom.alive) { | |
| 942 | try w.writeAll(" : [*]"); | |
| 943 | } | |
| 964 | 944 | } |
| 965 | } | |
| 945 | }; | |
| 966 | 946 | |
| 967 | 947 | pub const Index = u32; |
| 968 | 948 |
src/link/Elf/AtomList.zig+19-36| ... | ... | @@ -167,46 +167,29 @@ pub fn lastAtom(list: AtomList, elf_file: *Elf) *Atom { |
| 167 | 167 | return elf_file.atom(list.atoms.keys()[list.atoms.keys().len - 1]).?; |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | pub fn format( | |
| 171 | list: AtomList, | |
| 172 | comptime unused_fmt_string: []const u8, | |
| 173 | options: std.fmt.FormatOptions, | |
| 174 | writer: anytype, | |
| 175 | ) !void { | |
| 176 | _ = list; | |
| 177 | _ = unused_fmt_string; | |
| 178 | _ = options; | |
| 179 | _ = writer; | |
| 180 | @compileError("do not format AtomList directly"); | |
| 181 | } | |
| 182 | ||
| 183 | const FormatCtx = struct { AtomList, *Elf }; | |
| 170 | const Format = struct { | |
| 171 | atom_list: AtomList, | |
| 172 | elf_file: *Elf, | |
| 173 | ||
| 174 | fn default(f: Format, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 175 | const list, const elf_file = f; | |
| 176 | try writer.print("list : @{x} : shdr({d}) : align({x}) : size({x})", .{ | |
| 177 | list.address(elf_file), list.output_section_index, | |
| 178 | list.alignment.toByteUnits() orelse 0, list.size, | |
| 179 | }); | |
| 180 | try writer.writeAll(" : atoms{ "); | |
| 181 | for (list.atoms.keys(), 0..) |ref, i| { | |
| 182 | try writer.print("{}", .{ref}); | |
| 183 | if (i < list.atoms.keys().len - 1) try writer.writeAll(", "); | |
| 184 | } | |
| 185 | try writer.writeAll(" }"); | |
| 186 | } | |
| 187 | }; | |
| 184 | 188 | |
| 185 | pub fn fmt(list: AtomList, elf_file: *Elf) std.fmt.Formatter(format2) { | |
| 189 | pub fn fmt(list: AtomList, elf_file: *Elf) std.fmt.Formatter(Format, Format.default) { | |
| 186 | 190 | return .{ .data = .{ list, elf_file } }; |
| 187 | 191 | } |
| 188 | 192 | |
| 189 | fn format2( | |
| 190 | ctx: FormatCtx, | |
| 191 | comptime unused_fmt_string: []const u8, | |
| 192 | options: std.fmt.FormatOptions, | |
| 193 | writer: anytype, | |
| 194 | ) !void { | |
| 195 | _ = unused_fmt_string; | |
| 196 | _ = options; | |
| 197 | const list, const elf_file = ctx; | |
| 198 | try writer.print("list : @{x} : shdr({d}) : align({x}) : size({x})", .{ | |
| 199 | list.address(elf_file), list.output_section_index, | |
| 200 | list.alignment.toByteUnits() orelse 0, list.size, | |
| 201 | }); | |
| 202 | try writer.writeAll(" : atoms{ "); | |
| 203 | for (list.atoms.keys(), 0..) |ref, i| { | |
| 204 | try writer.print("{}", .{ref}); | |
| 205 | if (i < list.atoms.keys().len - 1) try writer.writeAll(", "); | |
| 206 | } | |
| 207 | try writer.writeAll(" }"); | |
| 208 | } | |
| 209 | ||
| 210 | 193 | const assert = std.debug.assert; |
| 211 | 194 | const elf = std.elf; |
| 212 | 195 | const log = std.log.scoped(.link); |
src/link/Elf/LinkerDefined.zig+14-21| ... | ... | @@ -437,38 +437,31 @@ pub fn setSymbolExtra(self: *LinkerDefined, index: u32, extra: Symbol.Extra) voi |
| 437 | 437 | } |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | pub fn fmtSymtab(self: *LinkerDefined, elf_file: *Elf) std.fmt.Formatter(formatSymtab) { | |
| 440 | pub fn fmtSymtab(self: *LinkerDefined, elf_file: *Elf) std.fmt.Formatter(Format, Format.symtab) { | |
| 441 | 441 | return .{ .data = .{ |
| 442 | 442 | .self = self, |
| 443 | 443 | .elf_file = elf_file, |
| 444 | 444 | } }; |
| 445 | 445 | } |
| 446 | 446 | |
| 447 | const FormatContext = struct { | |
| 447 | const Format = struct { | |
| 448 | 448 | self: *LinkerDefined, |
| 449 | 449 | elf_file: *Elf, |
| 450 | }; | |
| 451 | 450 | |
| 452 | fn formatSymtab( | |
| 453 | ctx: FormatContext, | |
| 454 | comptime unused_fmt_string: []const u8, | |
| 455 | options: std.fmt.FormatOptions, | |
| 456 | writer: anytype, | |
| 457 | ) !void { | |
| 458 | _ = unused_fmt_string; | |
| 459 | _ = options; | |
| 460 | const self = ctx.self; | |
| 461 | const elf_file = ctx.elf_file; | |
| 462 | try writer.writeAll(" globals\n"); | |
| 463 | for (self.symbols.items, 0..) |sym, i| { | |
| 464 | const ref = self.resolveSymbol(@intCast(i), elf_file); | |
| 465 | if (elf_file.symbol(ref)) |ref_sym| { | |
| 466 | try writer.print(" {}\n", .{ref_sym.fmt(elf_file)}); | |
| 467 | } else { | |
| 468 | try writer.print(" {s} : unclaimed\n", .{sym.name(elf_file)}); | |
| 451 | fn symtab(ctx: Format, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 452 | const self = ctx.self; | |
| 453 | const elf_file = ctx.elf_file; | |
| 454 | try writer.writeAll(" globals\n"); | |
| 455 | for (self.symbols.items, 0..) |sym, i| { | |
| 456 | const ref = self.resolveSymbol(@intCast(i), elf_file); | |
| 457 | if (elf_file.symbol(ref)) |ref_sym| { | |
| 458 | try writer.print(" {f}\n", .{ref_sym.fmt(elf_file)}); | |
| 459 | } else { | |
| 460 | try writer.print(" {s} : unclaimed\n", .{sym.name(elf_file)}); | |
| 461 | } | |
| 469 | 462 | } |
| 470 | 463 | } |
| 471 | } | |
| 464 | }; | |
| 472 | 465 | |
| 473 | 466 | const assert = std.debug.assert; |
| 474 | 467 | const elf = std.elf; |
src/link/Elf/Merge.zig+31-71| ... | ... | @@ -157,54 +157,34 @@ pub const Section = struct { |
| 157 | 157 | } |
| 158 | 158 | }; |
| 159 | 159 | |
| 160 | pub fn format( | |
| 161 | msec: Section, | |
| 162 | comptime unused_fmt_string: []const u8, | |
| 163 | options: std.fmt.FormatOptions, | |
| 164 | writer: anytype, | |
| 165 | ) !void { | |
| 166 | _ = msec; | |
| 167 | _ = unused_fmt_string; | |
| 168 | _ = options; | |
| 169 | _ = writer; | |
| 170 | @compileError("do not format directly"); | |
| 171 | } | |
| 172 | ||
| 173 | pub fn fmt(msec: Section, elf_file: *Elf) std.fmt.Formatter(format2) { | |
| 160 | pub fn fmt(msec: Section, elf_file: *Elf) std.fmt.Formatter(Format, Format.default) { | |
| 174 | 161 | return .{ .data = .{ |
| 175 | 162 | .msec = msec, |
| 176 | 163 | .elf_file = elf_file, |
| 177 | 164 | } }; |
| 178 | 165 | } |
| 179 | 166 | |
| 180 | const FormatContext = struct { | |
| 167 | const Format = struct { | |
| 181 | 168 | msec: Section, |
| 182 | 169 | elf_file: *Elf, |
| 183 | }; | |
| 184 | 170 | |
| 185 | pub fn format2( | |
| 186 | ctx: FormatContext, | |
| 187 | comptime unused_fmt_string: []const u8, | |
| 188 | options: std.fmt.FormatOptions, | |
| 189 | writer: anytype, | |
| 190 | ) !void { | |
| 191 | _ = options; | |
| 192 | _ = unused_fmt_string; | |
| 193 | const msec = ctx.msec; | |
| 194 | const elf_file = ctx.elf_file; | |
| 195 | try writer.print("{s} : @{x} : size({x}) : align({x}) : entsize({x}) : type({x}) : flags({x})\n", .{ | |
| 196 | msec.name(elf_file), | |
| 197 | msec.address(elf_file), | |
| 198 | msec.size, | |
| 199 | msec.alignment.toByteUnits() orelse 0, | |
| 200 | msec.entsize, | |
| 201 | msec.type, | |
| 202 | msec.flags, | |
| 203 | }); | |
| 204 | for (msec.subsections.items) |msub| { | |
| 205 | try writer.print(" {}\n", .{msub.fmt(elf_file)}); | |
| 171 | pub fn default(f: Format, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 172 | const msec = f.msec; | |
| 173 | const elf_file = f.elf_file; | |
| 174 | try writer.print("{s} : @{x} : size({x}) : align({x}) : entsize({x}) : type({x}) : flags({x})\n", .{ | |
| 175 | msec.name(elf_file), | |
| 176 | msec.address(elf_file), | |
| 177 | msec.size, | |
| 178 | msec.alignment.toByteUnits() orelse 0, | |
| 179 | msec.entsize, | |
| 180 | msec.type, | |
| 181 | msec.flags, | |
| 182 | }); | |
| 183 | for (msec.subsections.items) |msub| { | |
| 184 | try writer.print(" {f}\n", .{msub.fmt(elf_file)}); | |
| 185 | } | |
| 206 | 186 | } |
| 207 | } | |
| 187 | }; | |
| 208 | 188 | |
| 209 | 189 | pub const Index = u32; |
| 210 | 190 | }; |
| ... | ... | @@ -231,48 +211,28 @@ pub const Subsection = struct { |
| 231 | 211 | return msec.bytes.items[msub.string_index..][0..msub.size]; |
| 232 | 212 | } |
| 233 | 213 | |
| 234 | pub fn format( | |
| 235 | msub: Subsection, | |
| 236 | comptime unused_fmt_string: []const u8, | |
| 237 | options: std.fmt.FormatOptions, | |
| 238 | writer: anytype, | |
| 239 | ) !void { | |
| 240 | _ = msub; | |
| 241 | _ = unused_fmt_string; | |
| 242 | _ = options; | |
| 243 | _ = writer; | |
| 244 | @compileError("do not format directly"); | |
| 245 | } | |
| 246 | ||
| 247 | pub fn fmt(msub: Subsection, elf_file: *Elf) std.fmt.Formatter(format2) { | |
| 214 | pub fn fmt(msub: Subsection, elf_file: *Elf) std.fmt.Formatter(Format, Format.default) { | |
| 248 | 215 | return .{ .data = .{ |
| 249 | 216 | .msub = msub, |
| 250 | 217 | .elf_file = elf_file, |
| 251 | 218 | } }; |
| 252 | 219 | } |
| 253 | 220 | |
| 254 | const FormatContext = struct { | |
| 221 | const Format = struct { | |
| 255 | 222 | msub: Subsection, |
| 256 | 223 | elf_file: *Elf, |
| 257 | }; | |
| 258 | 224 | |
| 259 | pub fn format2( | |
| 260 | ctx: FormatContext, | |
| 261 | comptime unused_fmt_string: []const u8, | |
| 262 | options: std.fmt.FormatOptions, | |
| 263 | writer: anytype, | |
| 264 | ) !void { | |
| 265 | _ = options; | |
| 266 | _ = unused_fmt_string; | |
| 267 | const msub = ctx.msub; | |
| 268 | const elf_file = ctx.elf_file; | |
| 269 | try writer.print("@{x} : align({x}) : size({x})", .{ | |
| 270 | msub.address(elf_file), | |
| 271 | msub.alignment, | |
| 272 | msub.size, | |
| 273 | }); | |
| 274 | if (!msub.alive) try writer.writeAll(" : [*]"); | |
| 275 | } | |
| 225 | pub fn default(ctx: Format, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 226 | const msub = ctx.msub; | |
| 227 | const elf_file = ctx.elf_file; | |
| 228 | try writer.print("@{x} : align({x}) : size({x})", .{ | |
| 229 | msub.address(elf_file), | |
| 230 | msub.alignment, | |
| 231 | msub.size, | |
| 232 | }); | |
| 233 | if (!msub.alive) try writer.writeAll(" : [*]"); | |
| 234 | } | |
| 235 | }; | |
| 276 | 236 | |
| 277 | 237 | pub const Index = u32; |
| 278 | 238 | }; |
src/link/Elf/Object.zig+66-121| ... | ... | @@ -1432,167 +1432,112 @@ pub fn group(self: *Object, index: Elf.Group.Index) *Elf.Group { |
| 1432 | 1432 | return &self.groups.items[index]; |
| 1433 | 1433 | } |
| 1434 | 1434 | |
| 1435 | pub fn format( | |
| 1436 | self: *Object, | |
| 1437 | comptime unused_fmt_string: []const u8, | |
| 1438 | options: std.fmt.FormatOptions, | |
| 1439 | writer: anytype, | |
| 1440 | ) !void { | |
| 1441 | _ = self; | |
| 1442 | _ = unused_fmt_string; | |
| 1443 | _ = options; | |
| 1444 | _ = writer; | |
| 1445 | @compileError("do not format objects directly"); | |
| 1446 | } | |
| 1447 | ||
| 1448 | pub fn fmtSymtab(self: *Object, elf_file: *Elf) std.fmt.Formatter(formatSymtab) { | |
| 1435 | pub fn fmtSymtab(self: *Object, elf_file: *Elf) std.fmt.Formatter(Format, Format.symtab) { | |
| 1449 | 1436 | return .{ .data = .{ |
| 1450 | 1437 | .object = self, |
| 1451 | 1438 | .elf_file = elf_file, |
| 1452 | 1439 | } }; |
| 1453 | 1440 | } |
| 1454 | 1441 | |
| 1455 | const FormatContext = struct { | |
| 1442 | const Format = struct { | |
| 1456 | 1443 | object: *Object, |
| 1457 | 1444 | elf_file: *Elf, |
| 1458 | }; | |
| 1459 | 1445 | |
| 1460 | fn formatSymtab( | |
| 1461 | ctx: FormatContext, | |
| 1462 | comptime unused_fmt_string: []const u8, | |
| 1463 | options: std.fmt.FormatOptions, | |
| 1464 | writer: anytype, | |
| 1465 | ) !void { | |
| 1466 | _ = unused_fmt_string; | |
| 1467 | _ = options; | |
| 1468 | const object = ctx.object; | |
| 1469 | const elf_file = ctx.elf_file; | |
| 1470 | try writer.writeAll(" locals\n"); | |
| 1471 | for (object.locals()) |sym| { | |
| 1472 | try writer.print(" {}\n", .{sym.fmt(elf_file)}); | |
| 1446 | fn symtab(f: Format, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 1447 | const object = f.object; | |
| 1448 | const elf_file = f.elf_file; | |
| 1449 | try writer.writeAll(" locals\n"); | |
| 1450 | for (object.locals()) |sym| { | |
| 1451 | try writer.print(" {}\n", .{sym.fmt(elf_file)}); | |
| 1452 | } | |
| 1453 | try writer.writeAll(" globals\n"); | |
| 1454 | for (object.globals(), 0..) |sym, i| { | |
| 1455 | const first_global = object.first_global.?; | |
| 1456 | const ref = object.resolveSymbol(@intCast(i + first_global), elf_file); | |
| 1457 | if (elf_file.symbol(ref)) |ref_sym| { | |
| 1458 | try writer.print(" {}\n", .{ref_sym.fmt(elf_file)}); | |
| 1459 | } else { | |
| 1460 | try writer.print(" {s} : unclaimed\n", .{sym.name(elf_file)}); | |
| 1461 | } | |
| 1462 | } | |
| 1473 | 1463 | } |
| 1474 | try writer.writeAll(" globals\n"); | |
| 1475 | for (object.globals(), 0..) |sym, i| { | |
| 1476 | const first_global = object.first_global.?; | |
| 1477 | const ref = object.resolveSymbol(@intCast(i + first_global), elf_file); | |
| 1478 | if (elf_file.symbol(ref)) |ref_sym| { | |
| 1479 | try writer.print(" {}\n", .{ref_sym.fmt(elf_file)}); | |
| 1480 | } else { | |
| 1481 | try writer.print(" {s} : unclaimed\n", .{sym.name(elf_file)}); | |
| 1464 | ||
| 1465 | fn atoms(f: Format, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 1466 | const object = f.object; | |
| 1467 | try writer.writeAll(" atoms\n"); | |
| 1468 | for (object.atoms_indexes.items) |atom_index| { | |
| 1469 | const atom_ptr = object.atom(atom_index) orelse continue; | |
| 1470 | try writer.print(" {}\n", .{atom_ptr.fmt(f.elf_file)}); | |
| 1471 | } | |
| 1472 | } | |
| 1473 | ||
| 1474 | fn cies(f: Format, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 1475 | const object = f.object; | |
| 1476 | try writer.writeAll(" cies\n"); | |
| 1477 | for (object.cies.items, 0..) |cie, i| { | |
| 1478 | try writer.print(" cie({d}) : {}\n", .{ i, cie.fmt(f.elf_file) }); | |
| 1482 | 1479 | } |
| 1483 | 1480 | } |
| 1484 | } | |
| 1485 | 1481 | |
| 1486 | pub fn fmtAtoms(self: *Object, elf_file: *Elf) std.fmt.Formatter(formatAtoms) { | |
| 1482 | fn fdes(f: Format, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 1483 | const object = f.object; | |
| 1484 | try writer.writeAll(" fdes\n"); | |
| 1485 | for (object.fdes.items, 0..) |fde, i| { | |
| 1486 | try writer.print(" fde({d}) : {}\n", .{ i, fde.fmt(f.elf_file) }); | |
| 1487 | } | |
| 1488 | } | |
| 1489 | ||
| 1490 | fn groups(f: Format, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 1491 | const object = f.object; | |
| 1492 | const elf_file = f.elf_file; | |
| 1493 | try writer.writeAll(" groups\n"); | |
| 1494 | for (object.groups.items, 0..) |g, g_index| { | |
| 1495 | try writer.print(" {s}({d})", .{ if (g.is_comdat) "COMDAT" else "GROUP", g_index }); | |
| 1496 | if (!g.alive) try writer.writeAll(" : [*]"); | |
| 1497 | try writer.writeByte('\n'); | |
| 1498 | const g_members = g.members(elf_file); | |
| 1499 | for (g_members) |shndx| { | |
| 1500 | const atom_index = object.atoms_indexes.items[shndx]; | |
| 1501 | const atom_ptr = object.atom(atom_index) orelse continue; | |
| 1502 | try writer.print(" atom({d}) : {s}\n", .{ atom_index, atom_ptr.name(elf_file) }); | |
| 1503 | } | |
| 1504 | } | |
| 1505 | } | |
| 1506 | }; | |
| 1507 | ||
| 1508 | pub fn fmtAtoms(self: *Object, elf_file: *Elf) std.fmt.Formatter(Format, Format.atoms) { | |
| 1487 | 1509 | return .{ .data = .{ |
| 1488 | 1510 | .object = self, |
| 1489 | 1511 | .elf_file = elf_file, |
| 1490 | 1512 | } }; |
| 1491 | 1513 | } |
| 1492 | 1514 | |
| 1493 | fn formatAtoms( | |
| 1494 | ctx: FormatContext, | |
| 1495 | comptime unused_fmt_string: []const u8, | |
| 1496 | options: std.fmt.FormatOptions, | |
| 1497 | writer: anytype, | |
| 1498 | ) !void { | |
| 1499 | _ = unused_fmt_string; | |
| 1500 | _ = options; | |
| 1501 | const object = ctx.object; | |
| 1502 | try writer.writeAll(" atoms\n"); | |
| 1503 | for (object.atoms_indexes.items) |atom_index| { | |
| 1504 | const atom_ptr = object.atom(atom_index) orelse continue; | |
| 1505 | try writer.print(" {}\n", .{atom_ptr.fmt(ctx.elf_file)}); | |
| 1506 | } | |
| 1507 | } | |
| 1508 | ||
| 1509 | pub fn fmtCies(self: *Object, elf_file: *Elf) std.fmt.Formatter(formatCies) { | |
| 1515 | pub fn fmtCies(self: *Object, elf_file: *Elf) std.fmt.Formatter(Format, Format.cies) { | |
| 1510 | 1516 | return .{ .data = .{ |
| 1511 | 1517 | .object = self, |
| 1512 | 1518 | .elf_file = elf_file, |
| 1513 | 1519 | } }; |
| 1514 | 1520 | } |
| 1515 | 1521 | |
| 1516 | fn formatCies( | |
| 1517 | ctx: FormatContext, | |
| 1518 | comptime unused_fmt_string: []const u8, | |
| 1519 | options: std.fmt.FormatOptions, | |
| 1520 | writer: anytype, | |
| 1521 | ) !void { | |
| 1522 | _ = unused_fmt_string; | |
| 1523 | _ = options; | |
| 1524 | const object = ctx.object; | |
| 1525 | try writer.writeAll(" cies\n"); | |
| 1526 | for (object.cies.items, 0..) |cie, i| { | |
| 1527 | try writer.print(" cie({d}) : {}\n", .{ i, cie.fmt(ctx.elf_file) }); | |
| 1528 | } | |
| 1529 | } | |
| 1530 | ||
| 1531 | pub fn fmtFdes(self: *Object, elf_file: *Elf) std.fmt.Formatter(formatFdes) { | |
| 1522 | pub fn fmtFdes(self: *Object, elf_file: *Elf) std.fmt.Formatter(Format, Format.fdes) { | |
| 1532 | 1523 | return .{ .data = .{ |
| 1533 | 1524 | .object = self, |
| 1534 | 1525 | .elf_file = elf_file, |
| 1535 | 1526 | } }; |
| 1536 | 1527 | } |
| 1537 | 1528 | |
| 1538 | fn formatFdes( | |
| 1539 | ctx: FormatContext, | |
| 1540 | comptime unused_fmt_string: []const u8, | |
| 1541 | options: std.fmt.FormatOptions, | |
| 1542 | writer: anytype, | |
| 1543 | ) !void { | |
| 1544 | _ = unused_fmt_string; | |
| 1545 | _ = options; | |
| 1546 | const object = ctx.object; | |
| 1547 | try writer.writeAll(" fdes\n"); | |
| 1548 | for (object.fdes.items, 0..) |fde, i| { | |
| 1549 | try writer.print(" fde({d}) : {}\n", .{ i, fde.fmt(ctx.elf_file) }); | |
| 1550 | } | |
| 1551 | } | |
| 1552 | ||
| 1553 | pub fn fmtGroups(self: *Object, elf_file: *Elf) std.fmt.Formatter(formatGroups) { | |
| 1529 | pub fn fmtGroups(self: *Object, elf_file: *Elf) std.fmt.Formatter(Format, Format.groups) { | |
| 1554 | 1530 | return .{ .data = .{ |
| 1555 | 1531 | .object = self, |
| 1556 | 1532 | .elf_file = elf_file, |
| 1557 | 1533 | } }; |
| 1558 | 1534 | } |
| 1559 | 1535 | |
| 1560 | fn formatGroups( | |
| 1561 | ctx: FormatContext, | |
| 1562 | comptime unused_fmt_string: []const u8, | |
| 1563 | options: std.fmt.FormatOptions, | |
| 1564 | writer: anytype, | |
| 1565 | ) !void { | |
| 1566 | _ = unused_fmt_string; | |
| 1567 | _ = options; | |
| 1568 | const object = ctx.object; | |
| 1569 | const elf_file = ctx.elf_file; | |
| 1570 | try writer.writeAll(" groups\n"); | |
| 1571 | for (object.groups.items, 0..) |g, g_index| { | |
| 1572 | try writer.print(" {s}({d})", .{ if (g.is_comdat) "COMDAT" else "GROUP", g_index }); | |
| 1573 | if (!g.alive) try writer.writeAll(" : [*]"); | |
| 1574 | try writer.writeByte('\n'); | |
| 1575 | const g_members = g.members(elf_file); | |
| 1576 | for (g_members) |shndx| { | |
| 1577 | const atom_index = object.atoms_indexes.items[shndx]; | |
| 1578 | const atom_ptr = object.atom(atom_index) orelse continue; | |
| 1579 | try writer.print(" atom({d}) : {s}\n", .{ atom_index, atom_ptr.name(elf_file) }); | |
| 1580 | } | |
| 1581 | } | |
| 1582 | } | |
| 1583 | ||
| 1584 | pub fn fmtPath(self: Object) std.fmt.Formatter(formatPath) { | |
| 1536 | pub fn fmtPath(self: Object) std.fmt.Formatter(Object, formatPath) { | |
| 1585 | 1537 | return .{ .data = self }; |
| 1586 | 1538 | } |
| 1587 | 1539 | |
| 1588 | fn formatPath( | |
| 1589 | object: Object, | |
| 1590 | comptime unused_fmt_string: []const u8, | |
| 1591 | options: std.fmt.FormatOptions, | |
| 1592 | writer: anytype, | |
| 1593 | ) !void { | |
| 1594 | _ = unused_fmt_string; | |
| 1595 | _ = options; | |
| 1540 | fn formatPath(object: Object, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 1596 | 1541 | if (object.archive) |ar| { |
| 1597 | 1542 | try writer.print("{}({})", .{ ar.path, object.path }); |
| 1598 | 1543 | } else { |
src/link/Elf/SharedObject.zig+5-25| ... | ... | @@ -509,41 +509,21 @@ pub fn setSymbolExtra(self: *SharedObject, index: u32, extra: Symbol.Extra) void |
| 509 | 509 | } |
| 510 | 510 | } |
| 511 | 511 | |
| 512 | pub fn format( | |
| 513 | self: SharedObject, | |
| 514 | comptime unused_fmt_string: []const u8, | |
| 515 | options: std.fmt.FormatOptions, | |
| 516 | writer: anytype, | |
| 517 | ) !void { | |
| 518 | _ = self; | |
| 519 | _ = unused_fmt_string; | |
| 520 | _ = options; | |
| 521 | _ = writer; | |
| 522 | @compileError("unreachable"); | |
| 523 | } | |
| 524 | ||
| 525 | pub fn fmtSymtab(self: SharedObject, elf_file: *Elf) std.fmt.Formatter(formatSymtab) { | |
| 512 | pub fn fmtSymtab(self: SharedObject, elf_file: *Elf) std.fmt.Formatter(Format, Format.symtab) { | |
| 526 | 513 | return .{ .data = .{ |
| 527 | 514 | .shared = self, |
| 528 | 515 | .elf_file = elf_file, |
| 529 | 516 | } }; |
| 530 | 517 | } |
| 531 | 518 | |
| 532 | const FormatContext = struct { | |
| 519 | const Format = struct { | |
| 533 | 520 | shared: SharedObject, |
| 534 | 521 | elf_file: *Elf, |
| 535 | 522 | }; |
| 536 | 523 | |
| 537 | fn formatSymtab( | |
| 538 | ctx: FormatContext, | |
| 539 | comptime unused_fmt_string: []const u8, | |
| 540 | options: std.fmt.FormatOptions, | |
| 541 | writer: anytype, | |
| 542 | ) !void { | |
| 543 | _ = unused_fmt_string; | |
| 544 | _ = options; | |
| 545 | const shared = ctx.shared; | |
| 546 | const elf_file = ctx.elf_file; | |
| 524 | fn formatSymtab(f: Format, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 525 | const shared = f.shared; | |
| 526 | const elf_file = f.elf_file; | |
| 547 | 527 | try writer.writeAll(" globals\n"); |
| 548 | 528 | for (shared.symbols.items, 0..) |sym, i| { |
| 549 | 529 | const ref = shared.resolveSymbol(@intCast(i), elf_file); |
src/link/Elf/Symbol.zig+50-77| ... | ... | @@ -316,99 +316,72 @@ pub fn setOutputSym(symbol: Symbol, elf_file: *Elf, out: *elf.Elf64_Sym) void { |
| 316 | 316 | out.st_size = esym.st_size; |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | pub fn format( | |
| 320 | symbol: Symbol, | |
| 321 | comptime unused_fmt_string: []const u8, | |
| 322 | options: std.fmt.FormatOptions, | |
| 323 | writer: anytype, | |
| 324 | ) !void { | |
| 325 | _ = symbol; | |
| 326 | _ = unused_fmt_string; | |
| 327 | _ = options; | |
| 328 | _ = writer; | |
| 329 | @compileError("do not format Symbol directly"); | |
| 330 | } | |
| 331 | ||
| 332 | const FormatContext = struct { | |
| 319 | const Format = struct { | |
| 333 | 320 | symbol: Symbol, |
| 334 | 321 | elf_file: *Elf, |
| 322 | ||
| 323 | fn name(f: Format, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 324 | const elf_file = f.elf_file; | |
| 325 | const symbol = f.symbol; | |
| 326 | try writer.writeAll(symbol.name(elf_file)); | |
| 327 | switch (symbol.version_index.VERSION) { | |
| 328 | @intFromEnum(elf.VER_NDX.LOCAL), @intFromEnum(elf.VER_NDX.GLOBAL) => {}, | |
| 329 | else => { | |
| 330 | const file_ptr = symbol.file(elf_file).?; | |
| 331 | assert(file_ptr == .shared_object); | |
| 332 | const shared_object = file_ptr.shared_object; | |
| 333 | try writer.print("@{s}", .{shared_object.versionString(symbol.version_index)}); | |
| 334 | }, | |
| 335 | } | |
| 336 | } | |
| 337 | ||
| 338 | fn default(f: Format, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 339 | const symbol = f.symbol; | |
| 340 | const elf_file = f.elf_file; | |
| 341 | try writer.print("%{d} : {s} : @{x}", .{ | |
| 342 | symbol.esym_index, | |
| 343 | symbol.fmtName(elf_file), | |
| 344 | symbol.address(.{ .plt = false, .trampoline = false }, elf_file), | |
| 345 | }); | |
| 346 | if (symbol.file(elf_file)) |file_ptr| { | |
| 347 | if (symbol.isAbs(elf_file)) { | |
| 348 | if (symbol.elfSym(elf_file).st_shndx == elf.SHN_UNDEF) { | |
| 349 | try writer.writeAll(" : undef"); | |
| 350 | } else { | |
| 351 | try writer.writeAll(" : absolute"); | |
| 352 | } | |
| 353 | } else if (symbol.outputShndx(elf_file)) |shndx| { | |
| 354 | try writer.print(" : shdr({d})", .{shndx}); | |
| 355 | } | |
| 356 | if (symbol.atom(elf_file)) |atom_ptr| { | |
| 357 | try writer.print(" : atom({d})", .{atom_ptr.atom_index}); | |
| 358 | } | |
| 359 | var buf: [2]u8 = .{'_'} ** 2; | |
| 360 | if (symbol.flags.@"export") buf[0] = 'E'; | |
| 361 | if (symbol.flags.import) buf[1] = 'I'; | |
| 362 | try writer.print(" : {s}", .{&buf}); | |
| 363 | if (symbol.flags.weak) try writer.writeAll(" : weak"); | |
| 364 | switch (file_ptr) { | |
| 365 | inline else => |x| try writer.print(" : {s}({d})", .{ @tagName(file_ptr), x.index }), | |
| 366 | } | |
| 367 | } else try writer.writeAll(" : unresolved"); | |
| 368 | } | |
| 335 | 369 | }; |
| 336 | 370 | |
| 337 | pub fn fmtName(symbol: Symbol, elf_file: *Elf) std.fmt.Formatter(formatName) { | |
| 371 | pub fn fmtName(symbol: Symbol, elf_file: *Elf) std.fmt.Formatter(Format, Format.name) { | |
| 338 | 372 | return .{ .data = .{ |
| 339 | 373 | .symbol = symbol, |
| 340 | 374 | .elf_file = elf_file, |
| 341 | 375 | } }; |
| 342 | 376 | } |
| 343 | 377 | |
| 344 | fn formatName( | |
| 345 | ctx: FormatContext, | |
| 346 | comptime unused_fmt_string: []const u8, | |
| 347 | options: std.fmt.FormatOptions, | |
| 348 | writer: anytype, | |
| 349 | ) !void { | |
| 350 | _ = options; | |
| 351 | _ = unused_fmt_string; | |
| 352 | const elf_file = ctx.elf_file; | |
| 353 | const symbol = ctx.symbol; | |
| 354 | try writer.writeAll(symbol.name(elf_file)); | |
| 355 | switch (symbol.version_index.VERSION) { | |
| 356 | @intFromEnum(elf.VER_NDX.LOCAL), @intFromEnum(elf.VER_NDX.GLOBAL) => {}, | |
| 357 | else => { | |
| 358 | const file_ptr = symbol.file(elf_file).?; | |
| 359 | assert(file_ptr == .shared_object); | |
| 360 | const shared_object = file_ptr.shared_object; | |
| 361 | try writer.print("@{s}", .{shared_object.versionString(symbol.version_index)}); | |
| 362 | }, | |
| 363 | } | |
| 364 | } | |
| 365 | ||
| 366 | pub fn fmt(symbol: Symbol, elf_file: *Elf) std.fmt.Formatter(format2) { | |
| 378 | pub fn fmt(symbol: Symbol, elf_file: *Elf) std.fmt.Formatter(Format, Format.default) { | |
| 367 | 379 | return .{ .data = .{ |
| 368 | 380 | .symbol = symbol, |
| 369 | 381 | .elf_file = elf_file, |
| 370 | 382 | } }; |
| 371 | 383 | } |
| 372 | 384 | |
| 373 | fn format2( | |
| 374 | ctx: FormatContext, | |
| 375 | comptime unused_fmt_string: []const u8, | |
| 376 | options: std.fmt.FormatOptions, | |
| 377 | writer: anytype, | |
| 378 | ) !void { | |
| 379 | _ = options; | |
| 380 | _ = unused_fmt_string; | |
| 381 | const symbol = ctx.symbol; | |
| 382 | const elf_file = ctx.elf_file; | |
| 383 | try writer.print("%{d} : {s} : @{x}", .{ | |
| 384 | symbol.esym_index, | |
| 385 | symbol.fmtName(elf_file), | |
| 386 | symbol.address(.{ .plt = false, .trampoline = false }, elf_file), | |
| 387 | }); | |
| 388 | if (symbol.file(elf_file)) |file_ptr| { | |
| 389 | if (symbol.isAbs(elf_file)) { | |
| 390 | if (symbol.elfSym(elf_file).st_shndx == elf.SHN_UNDEF) { | |
| 391 | try writer.writeAll(" : undef"); | |
| 392 | } else { | |
| 393 | try writer.writeAll(" : absolute"); | |
| 394 | } | |
| 395 | } else if (symbol.outputShndx(elf_file)) |shndx| { | |
| 396 | try writer.print(" : shdr({d})", .{shndx}); | |
| 397 | } | |
| 398 | if (symbol.atom(elf_file)) |atom_ptr| { | |
| 399 | try writer.print(" : atom({d})", .{atom_ptr.atom_index}); | |
| 400 | } | |
| 401 | var buf: [2]u8 = .{'_'} ** 2; | |
| 402 | if (symbol.flags.@"export") buf[0] = 'E'; | |
| 403 | if (symbol.flags.import) buf[1] = 'I'; | |
| 404 | try writer.print(" : {s}", .{&buf}); | |
| 405 | if (symbol.flags.weak) try writer.writeAll(" : weak"); | |
| 406 | switch (file_ptr) { | |
| 407 | inline else => |x| try writer.print(" : {s}({d})", .{ @tagName(file_ptr), x.index }), | |
| 408 | } | |
| 409 | } else try writer.writeAll(" : unresolved"); | |
| 410 | } | |
| 411 | ||
| 412 | 385 | pub const Flags = packed struct { |
| 413 | 386 | /// Whether the symbol is imported at runtime. |
| 414 | 387 | import: bool = false, |
src/link/Elf/Thunk.zig+11-31| ... | ... | @@ -65,47 +65,27 @@ fn trampolineSize(cpu_arch: std.Target.Cpu.Arch) usize { |
| 65 | 65 | }; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | pub fn format( | |
| 69 | thunk: Thunk, | |
| 70 | comptime unused_fmt_string: []const u8, | |
| 71 | options: std.fmt.FormatOptions, | |
| 72 | writer: anytype, | |
| 73 | ) !void { | |
| 74 | _ = thunk; | |
| 75 | _ = unused_fmt_string; | |
| 76 | _ = options; | |
| 77 | _ = writer; | |
| 78 | @compileError("do not format Thunk directly"); | |
| 79 | } | |
| 80 | ||
| 81 | pub fn fmt(thunk: Thunk, elf_file: *Elf) std.fmt.Formatter(format2) { | |
| 68 | pub fn fmt(thunk: Thunk, elf_file: *Elf) std.fmt.Formatter(Format, Format.default) { | |
| 82 | 69 | return .{ .data = .{ |
| 83 | 70 | .thunk = thunk, |
| 84 | 71 | .elf_file = elf_file, |
| 85 | 72 | } }; |
| 86 | 73 | } |
| 87 | 74 | |
| 88 | const FormatContext = struct { | |
| 75 | const Format = struct { | |
| 89 | 76 | thunk: Thunk, |
| 90 | 77 | elf_file: *Elf, |
| 91 | }; | |
| 92 | 78 | |
| 93 | fn format2( | |
| 94 | ctx: FormatContext, | |
| 95 | comptime unused_fmt_string: []const u8, | |
| 96 | options: std.fmt.FormatOptions, | |
| 97 | writer: anytype, | |
| 98 | ) !void { | |
| 99 | _ = options; | |
| 100 | _ = unused_fmt_string; | |
| 101 | const thunk = ctx.thunk; | |
| 102 | const elf_file = ctx.elf_file; | |
| 103 | try writer.print("@{x} : size({x})\n", .{ thunk.value, thunk.size(elf_file) }); | |
| 104 | for (thunk.symbols.keys()) |ref| { | |
| 105 | const sym = elf_file.symbol(ref).?; | |
| 106 | try writer.print(" {} : {s} : @{x}\n", .{ ref, sym.name(elf_file), sym.value }); | |
| 79 | fn default(f: Format, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 80 | const thunk = f.thunk; | |
| 81 | const elf_file = f.elf_file; | |
| 82 | try writer.print("@{x} : size({x})\n", .{ thunk.value, thunk.size(elf_file) }); | |
| 83 | for (thunk.symbols.keys()) |ref| { | |
| 84 | const sym = elf_file.symbol(ref).?; | |
| 85 | try writer.print(" {} : {s} : @{x}\n", .{ ref, sym.name(elf_file), sym.value }); | |
| 86 | } | |
| 107 | 87 | } |
| 108 | } | |
| 88 | }; | |
| 109 | 89 | |
| 110 | 90 | pub const Index = u32; |
| 111 | 91 |
src/link/Elf/ZigObject.zig+28-42| ... | ... | @@ -2195,60 +2195,46 @@ pub fn setSymbolExtra(self: *ZigObject, index: u32, extra: Symbol.Extra) void { |
| 2195 | 2195 | } |
| 2196 | 2196 | } |
| 2197 | 2197 | |
| 2198 | pub fn fmtSymtab(self: *ZigObject, elf_file: *Elf) std.fmt.Formatter(formatSymtab) { | |
| 2199 | return .{ .data = .{ | |
| 2200 | .self = self, | |
| 2201 | .elf_file = elf_file, | |
| 2202 | } }; | |
| 2203 | } | |
| 2204 | ||
| 2205 | const FormatContext = struct { | |
| 2198 | const Format = struct { | |
| 2206 | 2199 | self: *ZigObject, |
| 2207 | 2200 | elf_file: *Elf, |
| 2208 | }; | |
| 2209 | 2201 | |
| 2210 | fn formatSymtab( | |
| 2211 | ctx: FormatContext, | |
| 2212 | comptime unused_fmt_string: []const u8, | |
| 2213 | options: std.fmt.FormatOptions, | |
| 2214 | writer: anytype, | |
| 2215 | ) !void { | |
| 2216 | _ = unused_fmt_string; | |
| 2217 | _ = options; | |
| 2218 | const self = ctx.self; | |
| 2219 | const elf_file = ctx.elf_file; | |
| 2220 | try writer.writeAll(" locals\n"); | |
| 2221 | for (self.local_symbols.items) |index| { | |
| 2222 | const local = self.symbols.items[index]; | |
| 2223 | try writer.print(" {}\n", .{local.fmt(elf_file)}); | |
| 2202 | fn symtab(f: Format, writer: *std.io.Writer.Error) std.io.Writer.Error!void { | |
| 2203 | const self = f.self; | |
| 2204 | const elf_file = f.elf_file; | |
| 2205 | try writer.writeAll(" locals\n"); | |
| 2206 | for (self.local_symbols.items) |index| { | |
| 2207 | const local = self.symbols.items[index]; | |
| 2208 | try writer.print(" {f}\n", .{local.fmt(elf_file)}); | |
| 2209 | } | |
| 2210 | try writer.writeAll(" globals\n"); | |
| 2211 | for (f.self.global_symbols.items) |index| { | |
| 2212 | const global = self.symbols.items[index]; | |
| 2213 | try writer.print(" {f}\n", .{global.fmt(elf_file)}); | |
| 2214 | } | |
| 2224 | 2215 | } |
| 2225 | try writer.writeAll(" globals\n"); | |
| 2226 | for (ctx.self.global_symbols.items) |index| { | |
| 2227 | const global = self.symbols.items[index]; | |
| 2228 | try writer.print(" {}\n", .{global.fmt(elf_file)}); | |
| 2216 | ||
| 2217 | fn atoms(f: Format, writer: *std.io.Writer.Error) std.io.Writer.Error!void { | |
| 2218 | try writer.writeAll(" atoms\n"); | |
| 2219 | for (f.self.atoms_indexes.items) |atom_index| { | |
| 2220 | const atom_ptr = f.self.atom(atom_index) orelse continue; | |
| 2221 | try writer.print(" {f}\n", .{atom_ptr.fmt(f.elf_file)}); | |
| 2222 | } | |
| 2229 | 2223 | } |
| 2230 | } | |
| 2224 | }; | |
| 2231 | 2225 | |
| 2232 | pub fn fmtAtoms(self: *ZigObject, elf_file: *Elf) std.fmt.Formatter(formatAtoms) { | |
| 2226 | pub fn fmtSymtab(self: *ZigObject, elf_file: *Elf) std.fmt.Formatter(Format, Format.symtab) { | |
| 2233 | 2227 | return .{ .data = .{ |
| 2234 | 2228 | .self = self, |
| 2235 | 2229 | .elf_file = elf_file, |
| 2236 | 2230 | } }; |
| 2237 | 2231 | } |
| 2238 | 2232 | |
| 2239 | fn formatAtoms( | |
| 2240 | ctx: FormatContext, | |
| 2241 | comptime unused_fmt_string: []const u8, | |
| 2242 | options: std.fmt.FormatOptions, | |
| 2243 | writer: anytype, | |
| 2244 | ) !void { | |
| 2245 | _ = unused_fmt_string; | |
| 2246 | _ = options; | |
| 2247 | try writer.writeAll(" atoms\n"); | |
| 2248 | for (ctx.self.atoms_indexes.items) |atom_index| { | |
| 2249 | const atom_ptr = ctx.self.atom(atom_index) orelse continue; | |
| 2250 | try writer.print(" {}\n", .{atom_ptr.fmt(ctx.elf_file)}); | |
| 2251 | } | |
| 2233 | pub fn fmtAtoms(self: *ZigObject, elf_file: *Elf) std.fmt.Formatter(Format, Format.atoms) { | |
| 2234 | return .{ .data = .{ | |
| 2235 | .self = self, | |
| 2236 | .elf_file = elf_file, | |
| 2237 | } }; | |
| 2252 | 2238 | } |
| 2253 | 2239 | |
| 2254 | 2240 | const ElfSym = struct { |
src/link/Elf/eh_frame.zig+30-70| ... | ... | @@ -47,52 +47,32 @@ pub const Fde = struct { |
| 47 | 47 | return object.relocs.items[fde.rel_index..][0..fde.rel_num]; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | pub fn format( | |
| 51 | fde: Fde, | |
| 52 | comptime unused_fmt_string: []const u8, | |
| 53 | options: std.fmt.FormatOptions, | |
| 54 | writer: anytype, | |
| 55 | ) !void { | |
| 56 | _ = fde; | |
| 57 | _ = unused_fmt_string; | |
| 58 | _ = options; | |
| 59 | _ = writer; | |
| 60 | @compileError("do not format FDEs directly"); | |
| 61 | } | |
| 62 | ||
| 63 | pub fn fmt(fde: Fde, elf_file: *Elf) std.fmt.Formatter(format2) { | |
| 50 | pub fn fmt(fde: Fde, elf_file: *Elf) std.fmt.Formatter(Format, Format.default) { | |
| 64 | 51 | return .{ .data = .{ |
| 65 | 52 | .fde = fde, |
| 66 | 53 | .elf_file = elf_file, |
| 67 | 54 | } }; |
| 68 | 55 | } |
| 69 | 56 | |
| 70 | const FdeFormatContext = struct { | |
| 57 | const Format = struct { | |
| 71 | 58 | fde: Fde, |
| 72 | 59 | elf_file: *Elf, |
| 73 | }; | |
| 74 | 60 | |
| 75 | fn format2( | |
| 76 | ctx: FdeFormatContext, | |
| 77 | comptime unused_fmt_string: []const u8, | |
| 78 | options: std.fmt.FormatOptions, | |
| 79 | writer: anytype, | |
| 80 | ) !void { | |
| 81 | _ = unused_fmt_string; | |
| 82 | _ = options; | |
| 83 | const fde = ctx.fde; | |
| 84 | const elf_file = ctx.elf_file; | |
| 85 | const base_addr = fde.address(elf_file); | |
| 86 | const object = elf_file.file(fde.file_index).?.object; | |
| 87 | const atom_name = fde.atom(object).name(elf_file); | |
| 88 | try writer.print("@{x} : size({x}) : cie({d}) : {s}", .{ | |
| 89 | base_addr + fde.out_offset, | |
| 90 | fde.calcSize(), | |
| 91 | fde.cie_index, | |
| 92 | atom_name, | |
| 93 | }); | |
| 94 | if (!fde.alive) try writer.writeAll(" : [*]"); | |
| 95 | } | |
| 61 | fn default(f: Format, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 62 | const fde = f.fde; | |
| 63 | const elf_file = f.elf_file; | |
| 64 | const base_addr = fde.address(elf_file); | |
| 65 | const object = elf_file.file(fde.file_index).?.object; | |
| 66 | const atom_name = fde.atom(object).name(elf_file); | |
| 67 | try writer.print("@{x} : size({x}) : cie({d}) : {s}", .{ | |
| 68 | base_addr + fde.out_offset, | |
| 69 | fde.calcSize(), | |
| 70 | fde.cie_index, | |
| 71 | atom_name, | |
| 72 | }); | |
| 73 | if (!fde.alive) try writer.writeAll(" : [*]"); | |
| 74 | } | |
| 75 | }; | |
| 96 | 76 | }; |
| 97 | 77 | |
| 98 | 78 | pub const Cie = struct { |
| ... | ... | @@ -150,48 +130,28 @@ pub const Cie = struct { |
| 150 | 130 | return true; |
| 151 | 131 | } |
| 152 | 132 | |
| 153 | pub fn format( | |
| 154 | cie: Cie, | |
| 155 | comptime unused_fmt_string: []const u8, | |
| 156 | options: std.fmt.FormatOptions, | |
| 157 | writer: anytype, | |
| 158 | ) !void { | |
| 159 | _ = cie; | |
| 160 | _ = unused_fmt_string; | |
| 161 | _ = options; | |
| 162 | _ = writer; | |
| 163 | @compileError("do not format CIEs directly"); | |
| 164 | } | |
| 165 | ||
| 166 | pub fn fmt(cie: Cie, elf_file: *Elf) std.fmt.Formatter(format2) { | |
| 133 | pub fn fmt(cie: Cie, elf_file: *Elf) std.fmt.Formatter(Format, Format.default) { | |
| 167 | 134 | return .{ .data = .{ |
| 168 | 135 | .cie = cie, |
| 169 | 136 | .elf_file = elf_file, |
| 170 | 137 | } }; |
| 171 | 138 | } |
| 172 | 139 | |
| 173 | const CieFormatContext = struct { | |
| 140 | const Format = struct { | |
| 174 | 141 | cie: Cie, |
| 175 | 142 | elf_file: *Elf, |
| 176 | }; | |
| 177 | 143 | |
| 178 | fn format2( | |
| 179 | ctx: CieFormatContext, | |
| 180 | comptime unused_fmt_string: []const u8, | |
| 181 | options: std.fmt.FormatOptions, | |
| 182 | writer: anytype, | |
| 183 | ) !void { | |
| 184 | _ = unused_fmt_string; | |
| 185 | _ = options; | |
| 186 | const cie = ctx.cie; | |
| 187 | const elf_file = ctx.elf_file; | |
| 188 | const base_addr = cie.address(elf_file); | |
| 189 | try writer.print("@{x} : size({x})", .{ | |
| 190 | base_addr + cie.out_offset, | |
| 191 | cie.calcSize(), | |
| 192 | }); | |
| 193 | if (!cie.alive) try writer.writeAll(" : [*]"); | |
| 194 | } | |
| 144 | fn format2(f: Format, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 145 | const cie = f.cie; | |
| 146 | const elf_file = f.elf_file; | |
| 147 | const base_addr = cie.address(elf_file); | |
| 148 | try writer.print("@{x} : size({x})", .{ | |
| 149 | base_addr + cie.out_offset, | |
| 150 | cie.calcSize(), | |
| 151 | }); | |
| 152 | if (!cie.alive) try writer.writeAll(" : [*]"); | |
| 153 | } | |
| 154 | }; | |
| 195 | 155 | }; |
| 196 | 156 | |
| 197 | 157 | pub const Iterator = struct { |
src/link/Elf/file.zig+4-11| ... | ... | @@ -10,23 +10,16 @@ pub const File = union(enum) { |
| 10 | 10 | }; |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | pub fn fmtPath(file: File) std.fmt.Formatter(formatPath) { | |
| 13 | pub fn fmtPath(file: File) std.fmt.Formatter(File, formatPath) { | |
| 14 | 14 | return .{ .data = file }; |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | fn formatPath( | |
| 18 | file: File, | |
| 19 | comptime unused_fmt_string: []const u8, | |
| 20 | options: std.fmt.FormatOptions, | |
| 21 | writer: anytype, | |
| 22 | ) !void { | |
| 23 | _ = unused_fmt_string; | |
| 24 | _ = options; | |
| 17 | fn formatPath(file: File, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 25 | 18 | switch (file) { |
| 26 | 19 | .zig_object => |zo| try writer.writeAll(zo.basename), |
| 27 | 20 | .linker_defined => try writer.writeAll("(linker defined)"), |
| 28 | .object => |x| try writer.print("{}", .{x.fmtPath()}), | |
| 29 | .shared_object => |x| try writer.print("{}", .{@as(Path, x.path)}), | |
| 21 | .object => |x| try writer.print("{f}", .{x.fmtPath()}), | |
| 22 | .shared_object => |x| try writer.print("{f}", .{@as(Path, x.path)}), | |
| 30 | 23 | } |
| 31 | 24 | } |
| 32 | 25 |
src/link/Elf/relocation.zig+2-9| ... | ... | @@ -141,21 +141,14 @@ const FormatRelocTypeCtx = struct { |
| 141 | 141 | cpu_arch: std.Target.Cpu.Arch, |
| 142 | 142 | }; |
| 143 | 143 | |
| 144 | pub fn fmtRelocType(r_type: u32, cpu_arch: std.Target.Cpu.Arch) std.fmt.Formatter(formatRelocType) { | |
| 144 | pub fn fmtRelocType(r_type: u32, cpu_arch: std.Target.Cpu.Arch) std.fmt.Formatter(FormatRelocTypeCtx, formatRelocType) { | |
| 145 | 145 | return .{ .data = .{ |
| 146 | 146 | .r_type = r_type, |
| 147 | 147 | .cpu_arch = cpu_arch, |
| 148 | 148 | } }; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | fn formatRelocType( | |
| 152 | ctx: FormatRelocTypeCtx, | |
| 153 | comptime unused_fmt_string: []const u8, | |
| 154 | options: std.fmt.FormatOptions, | |
| 155 | writer: anytype, | |
| 156 | ) !void { | |
| 157 | _ = unused_fmt_string; | |
| 158 | _ = options; | |
| 151 | fn formatRelocType(ctx: FormatRelocTypeCtx, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 159 | 152 | const r_type = ctx.r_type; |
| 160 | 153 | switch (ctx.cpu_arch) { |
| 161 | 154 | .x86_64 => try writer.print("R_X86_64_{s}", .{@tagName(@as(elf.R_X86_64, @enumFromInt(r_type)))}), |
src/link/Elf/synthetic_sections.zig+36-50| ... | ... | @@ -606,37 +606,30 @@ pub const GotSection = struct { |
| 606 | 606 | } |
| 607 | 607 | } |
| 608 | 608 | |
| 609 | const FormatCtx = struct { | |
| 609 | const Format = struct { | |
| 610 | 610 | got: GotSection, |
| 611 | 611 | elf_file: *Elf, |
| 612 | ||
| 613 | pub fn default(f: Format, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 614 | const got = f.got; | |
| 615 | const elf_file = f.elf_file; | |
| 616 | try writer.writeAll("GOT\n"); | |
| 617 | for (got.entries.items) |entry| { | |
| 618 | const symbol = elf_file.symbol(entry.ref).?; | |
| 619 | try writer.print(" {d}@0x{x} => {}@0x{x} ({s})\n", .{ | |
| 620 | entry.cell_index, | |
| 621 | entry.address(elf_file), | |
| 622 | entry.ref, | |
| 623 | symbol.address(.{}, elf_file), | |
| 624 | symbol.name(elf_file), | |
| 625 | }); | |
| 626 | } | |
| 627 | } | |
| 612 | 628 | }; |
| 613 | 629 | |
| 614 | pub fn fmt(got: GotSection, elf_file: *Elf) std.fmt.Formatter(format2) { | |
| 630 | pub fn fmt(got: GotSection, elf_file: *Elf) std.fmt.Formatter(Format, Format.default) { | |
| 615 | 631 | return .{ .data = .{ .got = got, .elf_file = elf_file } }; |
| 616 | 632 | } |
| 617 | ||
| 618 | pub fn format2( | |
| 619 | ctx: FormatCtx, | |
| 620 | comptime unused_fmt_string: []const u8, | |
| 621 | options: std.fmt.FormatOptions, | |
| 622 | writer: anytype, | |
| 623 | ) !void { | |
| 624 | _ = options; | |
| 625 | _ = unused_fmt_string; | |
| 626 | const got = ctx.got; | |
| 627 | const elf_file = ctx.elf_file; | |
| 628 | try writer.writeAll("GOT\n"); | |
| 629 | for (got.entries.items) |entry| { | |
| 630 | const symbol = elf_file.symbol(entry.ref).?; | |
| 631 | try writer.print(" {d}@0x{x} => {}@0x{x} ({s})\n", .{ | |
| 632 | entry.cell_index, | |
| 633 | entry.address(elf_file), | |
| 634 | entry.ref, | |
| 635 | symbol.address(.{}, elf_file), | |
| 636 | symbol.name(elf_file), | |
| 637 | }); | |
| 638 | } | |
| 639 | } | |
| 640 | 633 | }; |
| 641 | 634 | |
| 642 | 635 | pub const PltSection = struct { |
| ... | ... | @@ -749,38 +742,31 @@ pub const PltSection = struct { |
| 749 | 742 | } |
| 750 | 743 | } |
| 751 | 744 | |
| 752 | const FormatCtx = struct { | |
| 745 | const Format = struct { | |
| 753 | 746 | plt: PltSection, |
| 754 | 747 | elf_file: *Elf, |
| 748 | ||
| 749 | pub fn default(f: Format, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 750 | const plt = f.plt; | |
| 751 | const elf_file = f.elf_file; | |
| 752 | try writer.writeAll("PLT\n"); | |
| 753 | for (plt.symbols.items, 0..) |ref, i| { | |
| 754 | const symbol = elf_file.symbol(ref).?; | |
| 755 | try writer.print(" {d}@0x{x} => {}@0x{x} ({s})\n", .{ | |
| 756 | i, | |
| 757 | symbol.pltAddress(elf_file), | |
| 758 | ref, | |
| 759 | symbol.address(.{}, elf_file), | |
| 760 | symbol.name(elf_file), | |
| 761 | }); | |
| 762 | } | |
| 763 | } | |
| 755 | 764 | }; |
| 756 | 765 | |
| 757 | pub fn fmt(plt: PltSection, elf_file: *Elf) std.fmt.Formatter(format2) { | |
| 766 | pub fn fmt(plt: PltSection, elf_file: *Elf) std.fmt.Formatter(Format, Format.default) { | |
| 758 | 767 | return .{ .data = .{ .plt = plt, .elf_file = elf_file } }; |
| 759 | 768 | } |
| 760 | 769 | |
| 761 | pub fn format2( | |
| 762 | ctx: FormatCtx, | |
| 763 | comptime unused_fmt_string: []const u8, | |
| 764 | options: std.fmt.FormatOptions, | |
| 765 | writer: anytype, | |
| 766 | ) !void { | |
| 767 | _ = options; | |
| 768 | _ = unused_fmt_string; | |
| 769 | const plt = ctx.plt; | |
| 770 | const elf_file = ctx.elf_file; | |
| 771 | try writer.writeAll("PLT\n"); | |
| 772 | for (plt.symbols.items, 0..) |ref, i| { | |
| 773 | const symbol = elf_file.symbol(ref).?; | |
| 774 | try writer.print(" {d}@0x{x} => {}@0x{x} ({s})\n", .{ | |
| 775 | i, | |
| 776 | symbol.pltAddress(elf_file), | |
| 777 | ref, | |
| 778 | symbol.address(.{}, elf_file), | |
| 779 | symbol.name(elf_file), | |
| 780 | }); | |
| 781 | } | |
| 782 | } | |
| 783 | ||
| 784 | 770 | const x86_64 = struct { |
| 785 | 771 | fn write(plt: PltSection, elf_file: *Elf, writer: anytype) !void { |
| 786 | 772 | const shdrs = elf_file.sections.items(.shdr); |
src/link/Lld.zig+2-2| ... | ... | @@ -1649,7 +1649,7 @@ fn spawnLld( |
| 1649 | 1649 | child.stderr_behavior = .Pipe; |
| 1650 | 1650 | |
| 1651 | 1651 | child.spawn() catch |err| break :term err; |
| 1652 | stderr = try child.stderr.?.reader().readAllAlloc(comp.gpa, std.math.maxInt(usize)); | |
| 1652 | stderr = try child.stderr.?.deprecatedReader().readAllAlloc(comp.gpa, std.math.maxInt(usize)); | |
| 1653 | 1653 | break :term child.wait(); |
| 1654 | 1654 | }) catch |first_err| term: { |
| 1655 | 1655 | const err = switch (first_err) { |
| ... | ... | @@ -1697,7 +1697,7 @@ fn spawnLld( |
| 1697 | 1697 | rsp_child.stderr_behavior = .Pipe; |
| 1698 | 1698 | |
| 1699 | 1699 | rsp_child.spawn() catch |err| break :err err; |
| 1700 | stderr = try rsp_child.stderr.?.reader().readAllAlloc(comp.gpa, std.math.maxInt(usize)); | |
| 1700 | stderr = try rsp_child.stderr.?.deprecatedReader().readAllAlloc(comp.gpa, std.math.maxInt(usize)); | |
| 1701 | 1701 | break :term rsp_child.wait() catch |err| break :err err; |
| 1702 | 1702 | } |
| 1703 | 1703 | }, |
src/link/MachO/Object.zig+2-2| ... | ... | @@ -2552,7 +2552,7 @@ const Format = struct { |
| 2552 | 2552 | } |
| 2553 | 2553 | } |
| 2554 | 2554 | |
| 2555 | fn formatSymtab(f: Format, w: *Writer) Writer.Error!void { | |
| 2555 | fn symtab(f: Format, w: *Writer) Writer.Error!void { | |
| 2556 | 2556 | const object = f.object; |
| 2557 | 2557 | const macho_file = f.macho_file; |
| 2558 | 2558 | try w.writeAll(" symbols\n"); |
| ... | ... | @@ -2695,7 +2695,7 @@ const StabFile = struct { |
| 2695 | 2695 | }; |
| 2696 | 2696 | |
| 2697 | 2697 | pub fn fmt(stab: Stab, object: Object) std.fmt.Formatter(Stab.Format, Stab.Format.default) { |
| 2698 | return .{ .data = .{ stab, object } }; | |
| 2698 | return .{ .data = .{ .stab = stab, .object = object } }; | |
| 2699 | 2699 | } |
| 2700 | 2700 | }; |
| 2701 | 2701 | }; |
src/link/MachO/Relocation.zig+1-1| ... | ... | @@ -71,7 +71,7 @@ pub fn lessThan(ctx: void, lhs: Relocation, rhs: Relocation) bool { |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | pub fn fmtPretty(rel: Relocation, cpu_arch: std.Target.Cpu.Arch) std.fmt.Formatter(Format, Format.pretty) { |
| 74 | return .{ .data = .{ rel, cpu_arch } }; | |
| 74 | return .{ .data = .{ .relocation = rel, .arch = cpu_arch } }; | |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | const Format = struct { |
src/link/MachO/eh_frame.zig+14-34| ... | ... | @@ -211,49 +211,29 @@ pub const Fde = struct { |
| 211 | 211 | return fde.getObject(macho_file).getAtom(fde.lsda); |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | pub fn format( | |
| 215 | fde: Fde, | |
| 216 | comptime unused_fmt_string: []const u8, | |
| 217 | options: std.fmt.FormatOptions, | |
| 218 | writer: anytype, | |
| 219 | ) !void { | |
| 220 | _ = fde; | |
| 221 | _ = unused_fmt_string; | |
| 222 | _ = options; | |
| 223 | _ = writer; | |
| 224 | @compileError("do not format FDEs directly"); | |
| 225 | } | |
| 226 | ||
| 227 | pub fn fmt(fde: Fde, macho_file: *MachO) std.fmt.Formatter(format2) { | |
| 214 | pub fn fmt(fde: Fde, macho_file: *MachO) std.fmt.Formatter(Format, Format.default) { | |
| 228 | 215 | return .{ .data = .{ |
| 229 | 216 | .fde = fde, |
| 230 | 217 | .macho_file = macho_file, |
| 231 | 218 | } }; |
| 232 | 219 | } |
| 233 | 220 | |
| 234 | const FormatContext = struct { | |
| 221 | const Format = struct { | |
| 235 | 222 | fde: Fde, |
| 236 | 223 | macho_file: *MachO, |
| 237 | }; | |
| 238 | 224 | |
| 239 | fn format2( | |
| 240 | ctx: FormatContext, | |
| 241 | comptime unused_fmt_string: []const u8, | |
| 242 | options: std.fmt.FormatOptions, | |
| 243 | writer: anytype, | |
| 244 | ) !void { | |
| 245 | _ = unused_fmt_string; | |
| 246 | _ = options; | |
| 247 | const fde = ctx.fde; | |
| 248 | const macho_file = ctx.macho_file; | |
| 249 | try writer.print("@{x} : size({x}) : cie({d}) : {s}", .{ | |
| 250 | fde.offset, | |
| 251 | fde.getSize(), | |
| 252 | fde.cie, | |
| 253 | fde.getAtom(macho_file).getName(macho_file), | |
| 254 | }); | |
| 255 | if (!fde.alive) try writer.writeAll(" : [*]"); | |
| 256 | } | |
| 225 | fn default(f: Format, writer: *Writer) Writer.Error!void { | |
| 226 | const fde = f.fde; | |
| 227 | const macho_file = f.macho_file; | |
| 228 | try writer.print("@{x} : size({x}) : cie({d}) : {s}", .{ | |
| 229 | fde.offset, | |
| 230 | fde.getSize(), | |
| 231 | fde.cie, | |
| 232 | fde.getAtom(macho_file).getName(macho_file), | |
| 233 | }); | |
| 234 | if (!fde.alive) try writer.writeAll(" : [*]"); | |
| 235 | } | |
| 236 | }; | |
| 257 | 237 | |
| 258 | 238 | pub const Index = u32; |
| 259 | 239 | }; |
src/print_value.zig+9-23| ... | ... | @@ -20,15 +20,8 @@ pub const FormatContext = struct { |
| 20 | 20 | depth: u8, |
| 21 | 21 | }; |
| 22 | 22 | |
| 23 | pub fn formatSema( | |
| 24 | ctx: FormatContext, | |
| 25 | comptime fmt: []const u8, | |
| 26 | options: std.fmt.FormatOptions, | |
| 27 | writer: anytype, | |
| 28 | ) !void { | |
| 29 | _ = options; | |
| 23 | pub fn formatSema(ctx: FormatContext, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 30 | 24 | const sema = ctx.opt_sema.?; |
| 31 | comptime std.debug.assert(fmt.len == 0); | |
| 32 | 25 | return print(ctx.val, writer, ctx.depth, ctx.pt, sema) catch |err| switch (err) { |
| 33 | 26 | error.OutOfMemory => @panic("OOM"), // We're not allowed to return this from a format function |
| 34 | 27 | error.ComptimeBreak, error.ComptimeReturn => unreachable, |
| ... | ... | @@ -37,15 +30,8 @@ pub fn formatSema( |
| 37 | 30 | }; |
| 38 | 31 | } |
| 39 | 32 | |
| 40 | pub fn format( | |
| 41 | ctx: FormatContext, | |
| 42 | comptime fmt: []const u8, | |
| 43 | options: std.fmt.FormatOptions, | |
| 44 | writer: anytype, | |
| 45 | ) !void { | |
| 46 | _ = options; | |
| 33 | pub fn format(ctx: FormatContext, writer: *std.io.Writer) std.io.Writer.Error!void { | |
| 47 | 34 | std.debug.assert(ctx.opt_sema == null); |
| 48 | comptime std.debug.assert(fmt.len == 0); | |
| 49 | 35 | return print(ctx.val, writer, ctx.depth, ctx.pt, null) catch |err| switch (err) { |
| 50 | 36 | error.OutOfMemory => @panic("OOM"), // We're not allowed to return this from a format function |
| 51 | 37 | error.ComptimeBreak, error.ComptimeReturn, error.AnalysisFail => unreachable, |
| ... | ... | @@ -55,11 +41,11 @@ pub fn format( |
| 55 | 41 | |
| 56 | 42 | pub fn print( |
| 57 | 43 | val: Value, |
| 58 | writer: anytype, | |
| 44 | writer: *std.io.Writer, | |
| 59 | 45 | level: u8, |
| 60 | 46 | pt: Zcu.PerThread, |
| 61 | 47 | opt_sema: ?*Sema, |
| 62 | ) (@TypeOf(writer).Error || Zcu.CompileError)!void { | |
| 48 | ) (std.io.Writer.Error || Zcu.CompileError)!void { | |
| 63 | 49 | const zcu = pt.zcu; |
| 64 | 50 | const ip = &zcu.intern_pool; |
| 65 | 51 | switch (ip.indexToKey(val.toIntern())) { |
| ... | ... | @@ -197,11 +183,11 @@ fn printAggregate( |
| 197 | 183 | val: Value, |
| 198 | 184 | aggregate: InternPool.Key.Aggregate, |
| 199 | 185 | is_ref: bool, |
| 200 | writer: anytype, | |
| 186 | writer: *std.io.Writer, | |
| 201 | 187 | level: u8, |
| 202 | 188 | pt: Zcu.PerThread, |
| 203 | 189 | opt_sema: ?*Sema, |
| 204 | ) (@TypeOf(writer).Error || Zcu.CompileError)!void { | |
| 190 | ) (std.io.Writer.Error || Zcu.CompileError)!void { | |
| 205 | 191 | if (level == 0) { |
| 206 | 192 | if (is_ref) try writer.writeByte('&'); |
| 207 | 193 | return writer.writeAll(".{ ... }"); |
| ... | ... | @@ -283,11 +269,11 @@ fn printPtr( |
| 283 | 269 | ptr_val: Value, |
| 284 | 270 | /// Whether to print `derivation` as an lvalue or rvalue. If `null`, the more concise option is chosen. |
| 285 | 271 | want_kind: ?PrintPtrKind, |
| 286 | writer: anytype, | |
| 272 | writer: *std.io.Writer, | |
| 287 | 273 | level: u8, |
| 288 | 274 | pt: Zcu.PerThread, |
| 289 | 275 | opt_sema: ?*Sema, |
| 290 | ) (@TypeOf(writer).Error || Zcu.CompileError)!void { | |
| 276 | ) (std.io.Writer.Error || Zcu.CompileError)!void { | |
| 291 | 277 | const ptr = switch (pt.zcu.intern_pool.indexToKey(ptr_val.toIntern())) { |
| 292 | 278 | .undef => return writer.writeAll("undefined"), |
| 293 | 279 | .ptr => |ptr| ptr, |
| ... | ... | @@ -329,7 +315,7 @@ const PrintPtrKind = enum { lvalue, rvalue }; |
| 329 | 315 | /// Returns the root derivation, which may be ignored. |
| 330 | 316 | pub fn printPtrDerivation( |
| 331 | 317 | derivation: Value.PointerDeriveStep, |
| 332 | writer: anytype, | |
| 318 | writer: *std.io.Writer, | |
| 333 | 319 | pt: Zcu.PerThread, |
| 334 | 320 | /// Whether to print `derivation` as an lvalue or rvalue. If `null`, the more concise option is chosen. |
| 335 | 321 | /// If this is `.rvalue`, the result may look like `&foo`, so it's not necessarily valid to treat it as |