Commit f409457925
Changed files (11)
src
Air
arch
riscv64
x86_64
link
Sema
src/Air/Liveness.zig
@@ -1299,10 +1299,10 @@ fn analyzeOperands(
// This logic must synchronize with `will_die_immediately` in `AnalyzeBigOperands.init`.
const immediate_death = if (data.live_set.remove(inst)) blk: {
- log.debug("[{}] %{}: removed from live set", .{ pass, @intFromEnum(inst) });
+ log.debug("[{}] %{d}: removed from live set", .{ pass, @intFromEnum(inst) });
break :blk false;
} else blk: {
- log.debug("[{}] %{}: immediate death", .{ pass, @intFromEnum(inst) });
+ log.debug("[{}] %{d}: immediate death", .{ pass, @intFromEnum(inst) });
break :blk true;
};
@@ -1323,7 +1323,7 @@ fn analyzeOperands(
const mask = @as(Bpi, 1) << @as(OperandInt, @intCast(i));
if ((try data.live_set.fetchPut(gpa, operand, {})) == null) {
- log.debug("[{}] %{}: added %{} to live set (operand dies here)", .{ pass, @intFromEnum(inst), operand });
+ log.debug("[{}] %{f}: added %{d} to live set (operand dies here)", .{ pass, @intFromEnum(inst), operand });
tomb_bits |= mask;
}
}
@@ -1462,19 +1462,19 @@ fn analyzeInstBlock(
},
.main_analysis => {
- log.debug("[{}] %{}: block live set is {}", .{ pass, inst, fmtInstSet(&data.live_set) });
+ log.debug("[{}] %{f}: block live set is {f}", .{ pass, inst, fmtInstSet(&data.live_set) });
// We can move the live set because the body should have a noreturn
// instruction which overrides the set.
try data.block_scopes.put(gpa, inst, .{
.live_set = data.live_set.move(),
});
defer {
- log.debug("[{}] %{}: popped block scope", .{ pass, inst });
+ log.debug("[{}] %{f}: popped block scope", .{ pass, inst });
var scope = data.block_scopes.fetchRemove(inst).?.value;
scope.live_set.deinit(gpa);
}
- log.debug("[{}] %{}: pushed new block scope", .{ pass, inst });
+ log.debug("[{}] %{f}: pushed new block scope", .{ pass, inst });
try analyzeBody(a, pass, data, body);
// If the block is noreturn, block deaths not only aren't useful, they're impossible to
@@ -1501,7 +1501,7 @@ fn analyzeInstBlock(
}
assert(measured_num == num_deaths); // post-live-set should be a subset of pre-live-set
try a.special.put(gpa, inst, extra_index);
- log.debug("[{}] %{}: block deaths are {}", .{
+ log.debug("[{}] %{f}: block deaths are {f}", .{
pass,
inst,
fmtInstList(@ptrCast(a.extra.items[extra_index + 1 ..][0..num_deaths])),
@@ -1538,7 +1538,7 @@ fn writeLoopInfo(
const block_inst = key.*;
a.extra.appendAssumeCapacity(@intFromEnum(block_inst));
}
- log.debug("[{}] %{}: includes breaks to {}", .{ LivenessPass.loop_analysis, inst, fmtInstSet(&data.breaks) });
+ log.debug("[{}] %{f}: includes breaks to {f}", .{ LivenessPass.loop_analysis, inst, fmtInstSet(&data.breaks) });
// Now we put the live operands from the loop body in too
const num_live = data.live_set.count();
@@ -1550,7 +1550,7 @@ fn writeLoopInfo(
const alive = key.*;
a.extra.appendAssumeCapacity(@intFromEnum(alive));
}
- log.debug("[{}] %{}: maintain liveness of {}", .{ LivenessPass.loop_analysis, inst, fmtInstSet(&data.live_set) });
+ log.debug("[{}] %{f}: maintain liveness of {f}", .{ LivenessPass.loop_analysis, inst, fmtInstSet(&data.live_set) });
try a.special.put(gpa, inst, extra_index);
@@ -1591,7 +1591,7 @@ fn resolveLoopLiveSet(
try data.live_set.ensureUnusedCapacity(gpa, @intCast(loop_live.len));
for (loop_live) |alive| data.live_set.putAssumeCapacity(alive, {});
- log.debug("[{}] %{}: block live set is {}", .{ LivenessPass.main_analysis, inst, fmtInstSet(&data.live_set) });
+ log.debug("[{}] %{f}: block live set is {f}", .{ LivenessPass.main_analysis, inst, fmtInstSet(&data.live_set) });
for (breaks) |block_inst| {
// We might break to this block, so include every operand that the block needs alive
@@ -1604,7 +1604,7 @@ fn resolveLoopLiveSet(
}
}
- log.debug("[{}] %{}: loop live set is {}", .{ LivenessPass.main_analysis, inst, fmtInstSet(&data.live_set) });
+ log.debug("[{}] %{f}: loop live set is {f}", .{ LivenessPass.main_analysis, inst, fmtInstSet(&data.live_set) });
}
fn analyzeInstLoop(
@@ -1642,7 +1642,7 @@ fn analyzeInstLoop(
.live_set = data.live_set.move(),
});
defer {
- log.debug("[{}] %{}: popped loop block scop", .{ pass, inst });
+ log.debug("[{}] %{f}: popped loop block scop", .{ pass, inst });
var scope = data.block_scopes.fetchRemove(inst).?.value;
scope.live_set.deinit(gpa);
}
@@ -1743,13 +1743,13 @@ fn analyzeInstCondBr(
}
}
- log.debug("[{}] %{}: 'then' branch mirrored deaths are {}", .{ pass, inst, fmtInstList(then_mirrored_deaths.items) });
- log.debug("[{}] %{}: 'else' branch mirrored deaths are {}", .{ pass, inst, fmtInstList(else_mirrored_deaths.items) });
+ log.debug("[{}] %{f}: 'then' branch mirrored deaths are {f}", .{ pass, inst, fmtInstList(then_mirrored_deaths.items) });
+ log.debug("[{}] %{f}: 'else' branch mirrored deaths are {f}", .{ pass, inst, fmtInstList(else_mirrored_deaths.items) });
data.live_set.deinit(gpa);
data.live_set = then_live.move(); // Really the union of both live sets
- log.debug("[{}] %{}: new live set is {}", .{ pass, inst, fmtInstSet(&data.live_set) });
+ log.debug("[{}] %{f}: new live set is {f}", .{ pass, inst, fmtInstSet(&data.live_set) });
// Write the mirrored deaths to `extra`
const then_death_count = @as(u32, @intCast(then_mirrored_deaths.items.len));
@@ -1817,7 +1817,7 @@ fn analyzeInstSwitchBr(
});
}
defer if (is_dispatch_loop) {
- log.debug("[{}] %{}: popped loop block scop", .{ pass, inst });
+ log.debug("[{}] %{f}: popped loop block scop", .{ pass, inst });
var scope = data.block_scopes.fetchRemove(inst).?.value;
scope.live_set.deinit(gpa);
};
@@ -1875,13 +1875,13 @@ fn analyzeInstSwitchBr(
}
for (mirrored_deaths, 0..) |mirrored, i| {
- log.debug("[{}] %{}: case {} mirrored deaths are {}", .{ pass, inst, i, fmtInstList(mirrored.items) });
+ log.debug("[{}] %{f}: case {} mirrored deaths are {f}", .{ pass, inst, i, fmtInstList(mirrored.items) });
}
data.live_set.deinit(gpa);
data.live_set = all_alive.move();
- log.debug("[{}] %{}: new live set is {}", .{ pass, inst, fmtInstSet(&data.live_set) });
+ log.debug("[{}] %{f}: new live set is {f}", .{ pass, inst, fmtInstSet(&data.live_set) });
}
const else_death_count = @as(u32, @intCast(mirrored_deaths[ncases].items.len));
@@ -1980,7 +1980,7 @@ fn AnalyzeBigOperands(comptime pass: LivenessPass) type {
.main_analysis => {
if ((try big.data.live_set.fetchPut(gpa, operand, {})) == null) {
- log.debug("[{}] %{}: added %{} to live set (operand dies here)", .{ pass, big.inst, operand });
+ log.debug("[{}] %{f}: added %{f} to live set (operand dies here)", .{ pass, big.inst, operand });
big.extra_tombs[extra_byte] |= @as(u32, 1) << extra_bit;
}
},
@@ -2042,9 +2042,9 @@ const FmtInstSet = struct {
return;
}
var it = val.set.keyIterator();
- try w.print("%{}", .{it.next().?.*});
+ try w.print("%{f}", .{it.next().?.*});
while (it.next()) |key| {
- try w.print(" %{}", .{key.*});
+ try w.print(" %{f}", .{key.*});
}
}
};
@@ -2061,9 +2061,9 @@ const FmtInstList = struct {
try w.writeAll("[no instructions]");
return;
}
- try w.print("%{}", .{val.list[0]});
+ try w.print("%{f}", .{val.list[0]});
for (val.list[1..]) |inst| {
- try w.print(" %{}", .{inst});
+ try w.print(" %{f}", .{inst});
}
}
};
src/arch/riscv64/CodeGen.zig
@@ -499,14 +499,14 @@ const InstTracking = struct {
else => target.long,
} else target.long;
inst_tracking.short = target.short;
- tracking_log.debug("%{d} => {} (materialize)", .{ inst, inst_tracking.* });
+ tracking_log.debug("%{d} => {f} (materialize)", .{ inst, inst_tracking.* });
}
fn resurrect(inst_tracking: *InstTracking, inst: Air.Inst.Index, scope_generation: u32) void {
switch (inst_tracking.short) {
.dead => |die_generation| if (die_generation >= scope_generation) {
inst_tracking.reuseFrame();
- tracking_log.debug("%{d} => {} (resurrect)", .{ inst, inst_tracking.* });
+ tracking_log.debug("%{d} => {f} (resurrect)", .{ inst, inst_tracking.* });
},
else => {},
}
@@ -516,7 +516,7 @@ const InstTracking = struct {
if (inst_tracking.short == .dead) return;
try function.freeValue(inst_tracking.short);
inst_tracking.short = .{ .dead = function.scope_generation };
- tracking_log.debug("%{d} => {} (death)", .{ inst, inst_tracking.* });
+ tracking_log.debug("%{d} => {f} (death)", .{ inst, inst_tracking.* });
}
fn reuse(
@@ -527,15 +527,15 @@ const InstTracking = struct {
) void {
inst_tracking.short = .{ .dead = function.scope_generation };
if (new_inst) |inst|
- tracking_log.debug("%{d} => {} (reuse %{d})", .{ inst, inst_tracking.*, old_inst })
+ tracking_log.debug("%{d} => {f} (reuse %{d})", .{ inst, inst_tracking.*, old_inst })
else
- tracking_log.debug("tmp => {} (reuse %{d})", .{ inst_tracking.*, old_inst });
+ tracking_log.debug("tmp => {f} (reuse %{d})", .{ inst_tracking.*, old_inst });
}
fn liveOut(inst_tracking: *InstTracking, function: *Func, inst: Air.Inst.Index) void {
for (inst_tracking.getRegs()) |reg| {
if (function.register_manager.isRegFree(reg)) {
- tracking_log.debug("%{d} => {} (live-out)", .{ inst, inst_tracking.* });
+ tracking_log.debug("%{d} => {f} (live-out)", .{ inst, inst_tracking.* });
continue;
}
@@ -562,7 +562,7 @@ const InstTracking = struct {
// Perform side-effects of freeValue manually.
function.register_manager.freeReg(reg);
- tracking_log.debug("%{d} => {} (live-out %{d})", .{ inst, inst_tracking.*, tracked_inst });
+ tracking_log.debug("%{d} => {f} (live-out %{d})", .{ inst, inst_tracking.*, tracked_inst });
}
}
@@ -572,7 +572,7 @@ const InstTracking = struct {
_: std.fmt.FormatOptions,
writer: anytype,
) @TypeOf(writer).Error!void {
- if (!std.meta.eql(inst_tracking.long, inst_tracking.short)) try writer.print("|{}| ", .{inst_tracking.long});
+ if (!std.meta.eql(inst_tracking.long, inst_tracking.short)) try writer.print("|{f}| ", .{inst_tracking.long});
try writer.print("{}", .{inst_tracking.short});
}
};
@@ -802,7 +802,7 @@ pub fn generate(
function.mir_instructions.deinit(gpa);
}
- wip_mir_log.debug("{}:", .{fmtNav(func.owner_nav, ip)});
+ wip_mir_log.debug("{f}:", .{fmtNav(func.owner_nav, ip)});
try function.frame_allocs.resize(gpa, FrameIndex.named_count);
function.frame_allocs.set(
@@ -973,7 +973,7 @@ fn formatWipMir(data: FormatWipMirData, writer: *std.io.Writer) std.io.Writer.Er
else => |e| return e,
}).insts) |lowered_inst| {
if (!first) try writer.writeAll("\ndebug(wip_mir): ");
- try writer.print(" | {}", .{lowered_inst});
+ try writer.print(" | {f}", .{lowered_inst});
first = false;
}
}
@@ -1156,7 +1156,7 @@ fn gen(func: *Func) !void {
func.ret_mcv.long.address().offset(-func.ret_mcv.short.indirect.off),
);
func.ret_mcv.long = .{ .load_frame = .{ .index = frame_index } };
- tracking_log.debug("spill {} to {}", .{ func.ret_mcv.long, frame_index });
+ tracking_log.debug("spill {f} to {f}", .{ func.ret_mcv.long, frame_index });
},
else => unreachable,
}
@@ -1656,14 +1656,14 @@ fn genBody(func: *Func, body: []const Air.Inst.Index) InnerError!void {
if (std.debug.runtime_safety) {
if (func.air_bookkeeping < old_air_bookkeeping + 1) {
- std.debug.panic("in codegen.zig, handling of AIR instruction %{d} ('{}') did not do proper bookkeeping. Look for a missing call to finishAir.", .{ inst, air_tags[@intFromEnum(inst)] });
+ std.debug.panic("in codegen.zig, handling of AIR instruction %{d} ('{f}') did not do proper bookkeeping. Look for a missing call to finishAir.", .{ inst, air_tags[@intFromEnum(inst)] });
}
{ // check consistency of tracked registers
var it = func.register_manager.free_registers.iterator(.{ .kind = .unset });
while (it.next()) |index| {
const tracked_inst = func.register_manager.registers[index];
- tracking_log.debug("tracked inst: {}", .{tracked_inst});
+ tracking_log.debug("tracked inst: {f}", .{tracked_inst});
const tracking = func.getResolvedInstValue(tracked_inst);
for (tracking.getRegs()) |reg| {
if (RegisterManager.indexOfRegIntoTracked(reg).? == index) break;
@@ -1697,7 +1697,7 @@ fn freeValue(func: *Func, value: MCValue) !void {
fn feed(func: *Func, bt: *Air.Liveness.BigTomb, operand: Air.Inst.Ref) !void {
if (bt.feed()) if (operand.toIndex()) |inst| {
- log.debug("feed inst: %{}", .{inst});
+ log.debug("feed inst: %{f}", .{inst});
try func.processDeath(inst);
};
}
@@ -1726,7 +1726,7 @@ fn finishAirResult(func: *Func, inst: Air.Inst.Index, result: MCValue) void {
else => {},
}
- tracking_log.debug("%{d} => {} (birth)", .{ inst, result });
+ tracking_log.debug("%{d} => {f} (birth)", .{ inst, result });
func.inst_tracking.putAssumeCapacityNoClobber(inst, InstTracking.init(result));
// In some cases, an operand may be reused as the result.
// If that operand died and was a register, it was freed by
@@ -1827,7 +1827,7 @@ fn computeFrameLayout(func: *Func) !FrameLayout {
total_alloc_size + 64 + args_frame_size + spill_frame_size + call_frame_size,
@intCast(frame_align[@intFromEnum(FrameIndex.base_ptr)].toByteUnits().?),
);
- log.debug("frame size: {}", .{acc_frame_size});
+ log.debug("frame size: {f}", .{acc_frame_size});
// store the ra at total_size - 8, so it's the very first thing in the stack
// relative to the fp
@@ -1888,7 +1888,7 @@ fn splitType(func: *Func, ty: Type) ![2]Type {
},
else => unreachable,
},
- else => return func.fail("TODO: splitType class {}", .{class}),
+ else => return func.fail("TODO: splitType class {f}", .{class}),
};
} else if (parts[0].abiSize(zcu) + parts[1].abiSize(zcu) == ty.abiSize(zcu)) return parts;
return func.fail("TODO implement splitType for {f}", .{ty.fmt(func.pt)});
@@ -1992,7 +1992,7 @@ fn allocFrameIndex(func: *Func, alloc: FrameAlloc) !FrameIndex {
}
const frame_index: FrameIndex = @enumFromInt(func.frame_allocs.len);
try func.frame_allocs.append(func.gpa, alloc);
- log.debug("allocated frame {}", .{frame_index});
+ log.debug("allocated frame {f}", .{frame_index});
return frame_index;
}
src/arch/x86_64/CodeGen.zig
@@ -550,9 +550,9 @@ pub const MCValue = union(enum) {
@tagName(pl.reg),
}),
.indirect => |pl| try bw.print("[{s} + 0x{x}]", .{ @tagName(pl.reg), pl.off }),
- .indirect_load_frame => |pl| try bw.print("[[{} + 0x{x}]]", .{ pl.index, pl.off }),
- .load_frame => |pl| try bw.print("[{} + 0x{x}]", .{ pl.index, pl.off }),
- .lea_frame => |pl| try bw.print("{} + 0x{x}", .{ pl.index, pl.off }),
+ .indirect_load_frame => |pl| try bw.print("[[{f} + 0x{x}]]", .{ pl.index, pl.off }),
+ .load_frame => |pl| try bw.print("[{f} + 0x{x}]", .{ pl.index, pl.off }),
+ .lea_frame => |pl| try bw.print("{f} + 0x{x}", .{ pl.index, pl.off }),
.load_nav => |pl| try bw.print("[nav:{d}]", .{@intFromEnum(pl)}),
.lea_nav => |pl| try bw.print("nav:{d}", .{@intFromEnum(pl)}),
.load_uav => |pl| try bw.print("[uav:{d}]", .{@intFromEnum(pl.val)}),
@@ -561,10 +561,10 @@ pub const MCValue = union(enum) {
.lea_lazy_sym => |pl| try bw.print("lazy:{s}:{d}", .{ @tagName(pl.kind), @intFromEnum(pl.ty) }),
.load_extern_func => |pl| try bw.print("[extern:{d}]", .{@intFromEnum(pl)}),
.lea_extern_func => |pl| try bw.print("extern:{d}", .{@intFromEnum(pl)}),
- .elementwise_args => |pl| try bw.print("elementwise:{d}:[{} + 0x{x}]", .{
+ .elementwise_args => |pl| try bw.print("elementwise:{d}:[{f} + 0x{x}]", .{
pl.regs, pl.frame_index, pl.frame_off,
}),
- .reserved_frame => |pl| try bw.print("(dead:{})", .{pl}),
+ .reserved_frame => |pl| try bw.print("(dead:{f})", .{pl}),
.air_ref => |pl| try bw.print("(air:0x{x})", .{@intFromEnum(pl)}),
}
}
@@ -1195,7 +1195,7 @@ fn formatWipMir(data: FormatWipMirData, w: *Writer) Writer.Error!void {
};
try w.print(" {f}", .{mem_op.fmt(.m)});
},
- .pseudo_dbg_arg_val, .pseudo_dbg_var_val => try w.print(" {}", .{
+ .pseudo_dbg_arg_val, .pseudo_dbg_var_val => try w.print(" {f}", .{
Value.fromInterned(mir_inst.data.ip_index).fmtValue(data.self.pt),
}),
}
@@ -12887,7 +12887,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
.{ ._, ._nc, .j, .@"0b", ._, ._, ._ },
} },
} }) catch |err| switch (err) {
- error.SelectFailed => return cg.fail("failed to select {s} {} {} {}", .{
+ error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{
@tagName(air_tag),
cg.typeOf(bin_op.lhs).fmt(pt),
ops[0].tracking(cg),
@@ -21764,7 +21764,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
.{ ._, ._nc, .j, .@"0b", ._, ._, ._ },
} },
} }) catch |err| switch (err) {
- error.SelectFailed => return cg.fail("failed to select {s} {} {} {}", .{
+ error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{
@tagName(air_tag),
cg.typeOf(bin_op.lhs).fmt(pt),
ops[0].tracking(cg),
@@ -32482,7 +32482,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
.{ .@"0:", ._, .mov, .memad(.dst0q, .add_size, -8), .tmp3q, ._, ._ },
} },
} }) catch |err| switch (err) {
- error.SelectFailed => return cg.fail("failed to select {s} {} {} {}", .{
+ error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{
@tagName(air_tag),
cg.typeOf(bin_op.lhs).fmt(pt),
ops[0].tracking(cg),
@@ -59310,7 +59310,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
.{ ._, ._, .@"or", .tmp4q, .tmp5q, ._, ._ },
} },
} }) catch |err| switch (err) {
- error.SelectFailed => return cg.fail("failed to select {s} {} {} {}", .{
+ error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{
@tagName(air_tag),
ty_pl.ty.toType().fmt(pt),
ops[0].tracking(cg),
@@ -60809,7 +60809,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
.{ ._, ._, .@"or", .dst0d, .tmp0d, ._, ._ },
} },
} }) catch |err| switch (err) {
- error.SelectFailed => return cg.fail("failed to select {s} {} {}", .{
+ error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{
@tagName(air_tag),
cg.typeOf(bin_op.rhs).fmt(pt),
ops[1].tracking(cg),
@@ -64066,7 +64066,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
.{ .@"0:", ._, .mov, .memad(.dst0q, .add_size, -8), .tmp1q, ._, ._ },
} },
} }) catch |err| switch (err) {
- error.SelectFailed => return cg.fail("failed to select {s} {} {} {}", .{
+ error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f}", .{
@tagName(air_tag),
lhs_ty.fmt(pt),
ops[0].tracking(cg),
@@ -79428,7 +79428,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
.@"struct", .@"union" => {
assert(ty.containerLayout(zcu) == .@"packed");
for (&ops) |*op| op.wrapInt(cg) catch |err| switch (err) {
- error.SelectFailed => return cg.fail("failed to select {s} wrap {} {}", .{
+ error.SelectFailed => return cg.fail("failed to select {s} wrap {f} {f}", .{
@tagName(air_tag),
ty.fmt(pt),
op.tracking(cg),
@@ -86521,7 +86521,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
} },
}),
}) catch |err| switch (err) {
- error.SelectFailed => return cg.fail("failed to select {s} {s} {} {} {}", .{
+ error.SelectFailed => return cg.fail("failed to select {s} {s} {f} {f} {f}", .{
@tagName(air_tag),
@tagName(vector_cmp.compareOperator()),
cg.typeOf(vector_cmp.lhs).fmt(pt),
@@ -157186,7 +157186,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
} },
} },
}) catch |err| switch (err) {
- error.SelectFailed => return cg.fail("failed to select {s}.{s} {} {}", .{
+ error.SelectFailed => return cg.fail("failed to select {s}.{s} {f} {f}", .{
@tagName(air_tag),
@tagName(reduce.operation),
cg.typeOf(reduce.operand).fmt(pt),
@@ -157197,7 +157197,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
switch (reduce.operation) {
.And, .Or, .Xor, .Min, .Max => {},
.Add, .Mul => if (cg.intInfo(res_ty)) |_| res[0].wrapInt(cg) catch |err| switch (err) {
- error.SelectFailed => return cg.fail("failed to select {s}.{s} wrap {} {}", .{
+ error.SelectFailed => return cg.fail("failed to select {s}.{s} wrap {f} {f}", .{
@tagName(air_tag),
@tagName(reduce.operation),
res_ty.fmt(pt),
@@ -164480,7 +164480,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
} },
} },
}) catch |err| switch (err) {
- error.SelectFailed => return cg.fail("failed to select {s}.{s} {} {}", .{
+ error.SelectFailed => return cg.fail("failed to select {s}.{s} {f} {f}", .{
@tagName(air_tag),
@tagName(reduce.operation),
cg.typeOf(reduce.operand).fmt(pt),
@@ -166277,7 +166277,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
.{ ._, ._nz, .j, .@"0b", ._, ._, ._ },
} },
} }) catch |err| switch (err) {
- error.SelectFailed => return cg.fail("failed to select {s} {} {}", .{
+ error.SelectFailed => return cg.fail("failed to select {s} {f} {f}", .{
@tagName(air_tag),
ty_op.ty.toType().fmt(pt),
ops[0].tracking(cg),
@@ -166293,7 +166293,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
const bin_op = air_datas[@intFromEnum(inst)].bin_op;
var ops = try cg.tempsFromOperands(inst, .{ bin_op.lhs, bin_op.rhs }) ++ .{undefined};
ops[2] = ops[0].getByteLen(cg) catch |err| switch (err) {
- error.SelectFailed => return cg.fail("failed to select {s} {} {} {} {}", .{
+ error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f} {f}", .{
@tagName(air_tag),
cg.typeOf(bin_op.lhs).fmt(pt),
cg.typeOf(bin_op.rhs).fmt(pt),
@@ -166333,7 +166333,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
} },
}},
}) catch |err| switch (err) {
- error.SelectFailed => return cg.fail("failed to select {s} {} {} {} {} {}", .{
+ error.SelectFailed => return cg.fail("failed to select {s} {f} {f} {f} {f} {f}", .{
@tagName(air_tag),
cg.typeOf(bin_op.lhs).fmt(pt),
cg.typeOf(bin_op.rhs).fmt(pt),
@@ -181502,7 +181502,7 @@ fn genSetReg(
assert(!ty.optionalReprIsPayload(zcu));
break :first_ty opt_child;
},
- else => std.debug.panic("{s}: {}\n", .{ @src().fn_name, ty.fmt(pt) }),
+ else => std.debug.panic("{s}: {f}\n", .{ @src().fn_name, ty.fmt(pt) }),
});
const first_size: u31 = @intCast(first_ty.abiSize(zcu));
const frame_size = std.math.ceilPowerOfTwoAssert(u32, abi_size);
@@ -186930,7 +186930,7 @@ const Temp = struct {
assert(src_regs.len == std.math.divCeil(u16, int_info.bits, 64) catch unreachable);
break :part_ty .u64;
} else part_ty: switch (ip.indexToKey(src_ty.toIntern())) {
- else => std.debug.panic("{s}: {}\n", .{ @src().fn_name, src_ty.fmt(cg.pt) }),
+ else => std.debug.panic("{s}: {f}\n", .{ @src().fn_name, src_ty.fmt(cg.pt) }),
.ptr_type => |ptr_info| {
assert(ptr_info.flags.size == .slice);
assert(src_regs.len == 2);
@@ -186941,7 +186941,7 @@ const Temp = struct {
break :part_ty try cg.pt.intType(.unsigned, @as(u16, 8) * @min(src_abi_size, 8));
},
.opt_type => |opt_child| switch (ip.indexToKey(opt_child)) {
- else => std.debug.panic("{s}: {}\n", .{ @src().fn_name, src_ty.fmt(cg.pt) }),
+ else => std.debug.panic("{s}: {f}\n", .{ @src().fn_name, src_ty.fmt(cg.pt) }),
.ptr_type => |ptr_info| {
assert(ptr_info.flags.size == .slice);
assert(src_regs.len == 2);
src/arch/x86_64/encoder.zig
@@ -259,7 +259,7 @@ pub const Instruction = struct {
switch (sib.base) {
.none => any = false,
.reg => |reg| try w.print("{s}", .{@tagName(reg)}),
- .frame => |frame_index| try w.print("{}", .{frame_index}),
+ .frame => |frame_index| try w.print("{f}", .{frame_index}),
.table => try w.print("Table", .{}),
.rip_inst => |inst_index| try w.print("RipInst({d})", .{inst_index}),
.nav => |nav| try w.print("Nav({d})", .{@intFromEnum(nav)}),
src/link/MachO/relocatable.zig
@@ -202,7 +202,7 @@ pub fn flushStaticLib(macho_file: *MachO, comp: *Compilation, module_obj_path: ?
};
if (build_options.enable_logging) {
- state_log.debug("ar_symtab\n{}\n", .{ar_symtab.fmt(macho_file)});
+ state_log.debug("ar_symtab\n{f}\n", .{ar_symtab.fmt(macho_file)});
}
var buffer = std.ArrayList(u8).init(gpa);
src/link/Wasm/Object.zig
@@ -856,7 +856,7 @@ pub fn parse(
start_function = @enumFromInt(functions_start + index);
},
.element => {
- log.warn("unimplemented: element section in {} {?s}", .{ path, archive_member_name });
+ log.warn("unimplemented: element section in {f} {?s}", .{ path, archive_member_name });
pos = section_end;
},
.code => {
@@ -984,10 +984,10 @@ pub fn parse(
if (gop.value_ptr.type != fn_ty_index) {
var err = try diags.addErrorWithNotes(2);
try err.addMsg("symbol '{s}' mismatching function signatures", .{name.slice(wasm)});
- gop.value_ptr.source_location.addNote(&err, "imported as {} here", .{
+ gop.value_ptr.source_location.addNote(&err, "imported as {f} here", .{
gop.value_ptr.type.fmt(wasm),
});
- source_location.addNote(&err, "imported as {} here", .{fn_ty_index.fmt(wasm)});
+ source_location.addNote(&err, "imported as {f} here", .{fn_ty_index.fmt(wasm)});
continue;
}
if (gop.value_ptr.module_name != ptr.module_name.toOptional()) {
@@ -1155,11 +1155,11 @@ pub fn parse(
if (gop.value_ptr.type != ptr.type_index) {
var err = try diags.addErrorWithNotes(2);
try err.addMsg("function signature mismatch: {s}", .{name.slice(wasm)});
- gop.value_ptr.source_location.addNote(&err, "exported as {} here", .{
+ gop.value_ptr.source_location.addNote(&err, "exported as {f} here", .{
ptr.type_index.fmt(wasm),
});
const word = if (gop.value_ptr.resolution == .unresolved) "imported" else "exported";
- source_location.addNote(&err, "{s} as {} here", .{ word, gop.value_ptr.type.fmt(wasm) });
+ source_location.addNote(&err, "{s} as {f} here", .{ word, gop.value_ptr.type.fmt(wasm) });
continue;
}
if (gop.value_ptr.resolution == .unresolved or gop.value_ptr.flags.binding == .weak) {
@@ -1176,8 +1176,8 @@ pub fn parse(
}
var err = try diags.addErrorWithNotes(2);
try err.addMsg("symbol collision: {s}", .{name.slice(wasm)});
- gop.value_ptr.source_location.addNote(&err, "exported as {} here", .{ptr.type_index.fmt(wasm)});
- source_location.addNote(&err, "exported as {} here", .{gop.value_ptr.type.fmt(wasm)});
+ gop.value_ptr.source_location.addNote(&err, "exported as {f} here", .{ptr.type_index.fmt(wasm)});
+ source_location.addNote(&err, "exported as {f} here", .{gop.value_ptr.type.fmt(wasm)});
continue;
} else {
gop.value_ptr.* = .{
src/link/Coff.zig
@@ -2625,7 +2625,7 @@ fn logImportTables(coff: *const Coff) void {
log.debug("import tables:", .{});
for (coff.import_tables.keys(), 0..) |off, i| {
const itable = coff.import_tables.values()[i];
- log.debug("{}", .{itable.fmtDebug(.{
+ log.debug("{f}", .{itable.fmtDebug(.{
.coff = coff,
.index = i,
.name_off = off,
src/Sema/LowerZon.zig
@@ -338,7 +338,7 @@ fn failUnsupportedResultType(
const gpa = sema.gpa;
const pt = sema.pt;
return sema.failWithOwnedErrorMsg(self.block, msg: {
- const msg = try sema.errMsg(self.import_loc, "type '{}' is not available in ZON", .{ty.fmt(pt)});
+ const msg = try sema.errMsg(self.import_loc, "type '{f}' is not available in ZON", .{ty.fmt(pt)});
errdefer msg.destroy(gpa);
if (opt_note) |n| try sema.errNote(self.import_loc, msg, "{s}", .{n});
break :msg msg;
@@ -360,11 +360,7 @@ fn fail(
fn lowerExprKnownResTy(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) CompileError!InternPool.Index {
const pt = self.sema.pt;
return self.lowerExprKnownResTyInner(node, res_ty) catch |err| switch (err) {
- error.WrongType => return self.fail(
- node,
- "expected type '{}'",
- .{res_ty.fmt(pt)},
- ),
+ error.WrongType => return self.fail(node, "expected type '{f}'", .{res_ty.fmt(pt)}),
else => |e| return e,
};
}
@@ -428,7 +424,7 @@ fn lowerExprKnownResTyInner(
.frame,
.@"anyframe",
.void,
- => return self.fail(node, "type '{}' not available in ZON", .{res_ty.fmt(pt)}),
+ => return self.fail(node, "type '{f}' not available in ZON", .{res_ty.fmt(pt)}),
}
}
@@ -458,7 +454,7 @@ fn lowerInt(
// If lhs is unsigned and rhs is less than 0, we're out of bounds
if (lhs_info.signedness == .unsigned and rhs < 0) return self.fail(
node,
- "type '{}' cannot represent integer value '{}'",
+ "type '{f}' cannot represent integer value '{d}'",
.{ res_ty.fmt(self.sema.pt), rhs },
);
@@ -478,7 +474,7 @@ fn lowerInt(
if (rhs < min_int or rhs > max_int) {
return self.fail(
node,
- "type '{}' cannot represent integer value '{}'",
+ "type '{f}' cannot represent integer value '{d}'",
.{ res_ty.fmt(self.sema.pt), rhs },
);
}
@@ -496,7 +492,7 @@ fn lowerInt(
if (!val.fitsInTwosComp(int_info.signedness, int_info.bits)) {
return self.fail(
node,
- "type '{}' cannot represent integer value '{}'",
+ "type '{f}' cannot represent integer value '{f}'",
.{ res_ty.fmt(self.sema.pt), val },
);
}
@@ -517,7 +513,7 @@ fn lowerInt(
switch (big_int.setFloat(val, .trunc)) {
.inexact => return self.fail(
node,
- "fractional component prevents float value '{}' from coercion to type '{}'",
+ "fractional component prevents float value '{}' from coercion to type '{f}'",
.{ val, res_ty.fmt(self.sema.pt) },
),
.exact => {},
@@ -528,8 +524,8 @@ fn lowerInt(
if (!big_int.toConst().fitsInTwosComp(int_info.signedness, int_info.bits)) {
return self.fail(
node,
- "type '{}' cannot represent integer value '{}'",
- .{ val, res_ty.fmt(self.sema.pt) },
+ "type '{f}' cannot represent integer value '{}'",
+ .{ res_ty.fmt(self.sema.pt), val },
);
}
@@ -550,7 +546,7 @@ fn lowerInt(
if (val >= out_of_range) {
return self.fail(
node,
- "type '{}' cannot represent integer value '{}'",
+ "type '{f}' cannot represent integer value '{d}'",
.{ res_ty.fmt(self.sema.pt), val },
);
}
@@ -584,7 +580,7 @@ fn lowerFloat(
.pos_inf => b: {
if (res_ty.toIntern() == .comptime_float_type) return self.fail(
node,
- "expected type '{}'",
+ "expected type '{f}'",
.{res_ty.fmt(self.sema.pt)},
);
break :b try self.sema.pt.floatValue(res_ty, std.math.inf(f128));
@@ -592,7 +588,7 @@ fn lowerFloat(
.neg_inf => b: {
if (res_ty.toIntern() == .comptime_float_type) return self.fail(
node,
- "expected type '{}'",
+ "expected type '{f}'",
.{res_ty.fmt(self.sema.pt)},
);
break :b try self.sema.pt.floatValue(res_ty, -std.math.inf(f128));
@@ -600,7 +596,7 @@ fn lowerFloat(
.nan => b: {
if (res_ty.toIntern() == .comptime_float_type) return self.fail(
node,
- "expected type '{}'",
+ "expected type '{f}'",
.{res_ty.fmt(self.sema.pt)},
);
break :b try self.sema.pt.floatValue(res_ty, std.math.nan(f128));
@@ -795,7 +791,7 @@ fn lowerStruct(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool
const field_node = fields.vals.at(@intCast(i));
const name_index = struct_info.nameIndex(ip, field_name) orelse {
- return self.fail(field_node, "unexpected field '{}'", .{field_name.fmt(ip)});
+ return self.fail(field_node, "unexpected field '{f}'", .{field_name.fmt(ip)});
};
const field_type: Type = .fromInterned(struct_info.field_types.get(ip)[name_index]);
@@ -816,7 +812,7 @@ fn lowerStruct(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool
const field_names = struct_info.field_names.get(ip);
for (field_values, field_names) |*value, name| {
- if (value.* == .none) return self.fail(node, "missing field '{}'", .{name.fmt(ip)});
+ if (value.* == .none) return self.fail(node, "missing field '{f}'", .{name.fmt(ip)});
}
return self.sema.pt.intern(.{ .aggregate = .{
@@ -934,7 +930,7 @@ fn lowerUnion(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool.
.struct_literal => b: {
const fields: @FieldType(Zoir.Node, "struct_literal") = switch (node.get(self.file.zoir.?)) {
.struct_literal => |fields| fields,
- else => return self.fail(node, "expected type '{}'", .{res_ty.fmt(self.sema.pt)}),
+ else => return self.fail(node, "expected type '{f}'", .{res_ty.fmt(self.sema.pt)}),
};
if (fields.names.len != 1) {
return error.WrongType;
src/Air.zig
@@ -957,18 +957,14 @@ pub const Inst = struct {
return index.unwrap().target;
}
- pub fn format(
- index: Index,
- comptime _: []const u8,
- _: std.fmt.FormatOptions,
- writer: anytype,
- ) @TypeOf(writer).Error!void {
- try writer.writeByte('%');
+ pub fn format(index: Index, w: *std.io.Writer, comptime fmt: []const u8) std.io.Writer.Error!void {
+ comptime assert(fmt.len == 0);
+ try w.writeByte('%');
switch (index.unwrap()) {
.ref => {},
- .target => try writer.writeByte('t'),
+ .target => try w.writeByte('t'),
}
- try writer.print("{d}", .{@as(u31, @truncate(@intFromEnum(index)))});
+ try w.print("{d}", .{@as(u31, @truncate(@intFromEnum(index)))});
}
};
src/IncrementalDebugServer.zig
@@ -234,7 +234,7 @@ fn handleCommand(zcu: *Zcu, output: *std.ArrayListUnmanaged(u8), cmd_str: []cons
for (unit_info.deps.items, 0..) |dependee, i| {
try w.print("[{d}] ", .{i});
switch (dependee) {
- .src_hash, .namespace, .namespace_name, .zon_file, .embed_file => try w.print("{}", .{zcu.fmtDependee(dependee)}),
+ .src_hash, .namespace, .namespace_name, .zon_file, .embed_file => try w.print("{f}", .{zcu.fmtDependee(dependee)}),
.nav_val, .nav_ty => |nav| try w.print("{s} {d}", .{ @tagName(dependee), @intFromEnum(nav) }),
.interned => |ip_index| switch (ip.indexToKey(ip_index)) {
.struct_type, .union_type, .enum_type => try w.print("type {d}", .{@intFromEnum(ip_index)}),
src/register_manager.zig
@@ -149,7 +149,7 @@ pub fn RegisterManager(
/// Only the owner of the `RegisterLock` can unlock the
/// register later.
pub fn lockRegIndex(self: *Self, tracked_index: TrackedIndex) ?RegisterLock {
- log.debug("locking {}", .{regAtTrackedIndex(tracked_index)});
+ log.debug("locking {f}", .{regAtTrackedIndex(tracked_index)});
if (self.isRegIndexLocked(tracked_index)) {
log.debug(" register already locked", .{});
return null;
@@ -164,7 +164,7 @@ pub fn RegisterManager(
/// Like `lockReg` but asserts the register was unused always
/// returning a valid lock.
pub fn lockRegIndexAssumeUnused(self: *Self, tracked_index: TrackedIndex) RegisterLock {
- log.debug("locking asserting free {}", .{regAtTrackedIndex(tracked_index)});
+ log.debug("locking asserting free {f}", .{regAtTrackedIndex(tracked_index)});
assert(!self.isRegIndexLocked(tracked_index));
self.locked_registers.set(tracked_index);
return RegisterLock{ .tracked_index = tracked_index };
@@ -202,7 +202,7 @@ pub fn RegisterManager(
/// Requires `RegisterLock` to unlock a register.
/// Call `lockReg` to obtain the lock first.
pub fn unlockReg(self: *Self, lock: RegisterLock) void {
- log.debug("unlocking {}", .{regAtTrackedIndex(lock.tracked_index)});
+ log.debug("unlocking {f}", .{regAtTrackedIndex(lock.tracked_index)});
self.locked_registers.unset(lock.tracked_index);
}
@@ -238,7 +238,7 @@ pub fn RegisterManager(
if (i < count) return null;
for (regs, insts) |reg, inst| {
- log.debug("tryAllocReg {} for inst {?}", .{ reg, inst });
+ log.debug("tryAllocReg {f} for inst {f}", .{ reg, inst });
self.markRegAllocated(reg);
if (inst) |tracked_inst| {
@@ -317,7 +317,7 @@ pub fn RegisterManager(
tracked_index: TrackedIndex,
inst: ?Air.Inst.Index,
) AllocationError!void {
- log.debug("getReg {} for inst {?}", .{ regAtTrackedIndex(tracked_index), inst });
+ log.debug("getReg {f} for inst {f}", .{ regAtTrackedIndex(tracked_index), inst });
if (!self.isRegIndexFree(tracked_index)) {
// Move the instruction that was previously there to a
// stack allocation.
@@ -330,7 +330,7 @@ pub fn RegisterManager(
self.getRegIndexAssumeFree(tracked_index, inst);
}
pub fn getReg(self: *Self, reg: Register, inst: ?Air.Inst.Index) AllocationError!void {
- log.debug("getting reg: {}", .{reg});
+ log.debug("getting reg: {f}", .{reg});
return self.getRegIndex(indexOfRegIntoTracked(reg) orelse return, inst);
}
pub fn getKnownReg(
@@ -349,7 +349,7 @@ pub fn RegisterManager(
tracked_index: TrackedIndex,
inst: ?Air.Inst.Index,
) void {
- log.debug("getRegAssumeFree {} for inst {?}", .{ regAtTrackedIndex(tracked_index), inst });
+ log.debug("getRegAssumeFree {f} for inst {f}", .{ regAtTrackedIndex(tracked_index), inst });
self.markRegIndexAllocated(tracked_index);
assert(self.isRegIndexFree(tracked_index));
@@ -364,7 +364,7 @@ pub fn RegisterManager(
/// Marks the specified register as free
pub fn freeRegIndex(self: *Self, tracked_index: TrackedIndex) void {
- log.debug("freeing register {}", .{regAtTrackedIndex(tracked_index)});
+ log.debug("freeing register {f}", .{regAtTrackedIndex(tracked_index)});
self.registers[tracked_index] = undefined;
self.markRegIndexFree(tracked_index);
}