| ... | @@ -435,7 +435,7 @@ const InstTracking = struct { | ... | @@ -435,7 +435,7 @@ const InstTracking = struct { |
| 435 | fn trackSpill(inst_tracking: *InstTracking, function: *Func, inst: Air.Inst.Index) !void { | 435 | fn trackSpill(inst_tracking: *InstTracking, function: *Func, inst: Air.Inst.Index) !void { |
| 436 | try function.freeValue(inst_tracking.short); | 436 | try function.freeValue(inst_tracking.short); |
| 437 | inst_tracking.reuseFrame(); | 437 | inst_tracking.reuseFrame(); |
| 438 | tracking_log.debug("%{d} => {} (spilled)", .{ inst, inst_tracking.* }); | 438 | tracking_log.debug("%{d} => {f} (spilled)", .{ inst, inst_tracking.* }); |
| 439 | } | 439 | } |
| 440 | | 440 | |
| 441 | fn verifyMaterialize(inst_tracking: InstTracking, target: InstTracking) void { | 441 | fn verifyMaterialize(inst_tracking: InstTracking, target: InstTracking) void { |
| ... | @@ -1015,7 +1015,7 @@ const FormatTrackingData = struct { | ... | @@ -1015,7 +1015,7 @@ const FormatTrackingData = struct { |
| 1015 | }; | 1015 | }; |
| 1016 | fn formatTracking(data: FormatTrackingData, writer: *std.io.Writer) std.io.Writer.Error!void { | 1016 | fn formatTracking(data: FormatTrackingData, writer: *std.io.Writer) std.io.Writer.Error!void { |
| 1017 | var it = data.func.inst_tracking.iterator(); | 1017 | var it = data.func.inst_tracking.iterator(); |
| 1018 | while (it.next()) |entry| try writer.print("\n%{d} = {}", .{ entry.key_ptr.*, entry.value_ptr.* }); | 1018 | while (it.next()) |entry| try writer.print("\n%{d} = {f}", .{ entry.key_ptr.*, entry.value_ptr.* }); |
| 1019 | } | 1019 | } |
| 1020 | fn fmtTracking(func: *Func) std.fmt.Formatter(FormatTrackingData, formatTracking) { | 1020 | fn fmtTracking(func: *Func) std.fmt.Formatter(FormatTrackingData, formatTracking) { |
| 1021 | return .{ .data = .{ .func = func } }; | 1021 | return .{ .data = .{ .func = func } }; |
| ... | @@ -1033,7 +1033,7 @@ fn addInst(func: *Func, inst: Mir.Inst) error{OutOfMemory}!Mir.Inst.Index { | ... | @@ -1033,7 +1033,7 @@ fn addInst(func: *Func, inst: Mir.Inst) error{OutOfMemory}!Mir.Inst.Index { |
| 1033 | .pseudo_dbg_epilogue_begin, | 1033 | .pseudo_dbg_epilogue_begin, |
| 1034 | .pseudo_dead, | 1034 | .pseudo_dead, |
| 1035 | => false, | 1035 | => false, |
| 1036 | }) wip_mir_log.debug("{}", .{func.fmtWipMir(result_index)}); | 1036 | }) wip_mir_log.debug("{f}", .{func.fmtWipMir(result_index)}); |
| 1037 | return result_index; | 1037 | return result_index; |
| 1038 | } | 1038 | } |
| 1039 | | 1039 | |
| ... | @@ -1287,7 +1287,7 @@ fn genLazy(func: *Func, lazy_sym: link.File.LazySymbol) InnerError!void { | ... | @@ -1287,7 +1287,7 @@ fn genLazy(func: *Func, lazy_sym: link.File.LazySymbol) InnerError!void { |
| 1287 | switch (Type.fromInterned(lazy_sym.ty).zigTypeTag(zcu)) { | 1287 | switch (Type.fromInterned(lazy_sym.ty).zigTypeTag(zcu)) { |
| 1288 | .@"enum" => { | 1288 | .@"enum" => { |
| 1289 | const enum_ty = Type.fromInterned(lazy_sym.ty); | 1289 | const enum_ty = Type.fromInterned(lazy_sym.ty); |
| 1290 | wip_mir_log.debug("{}.@tagName:", .{enum_ty.fmt(pt)}); | 1290 | wip_mir_log.debug("{f}.@tagName:", .{enum_ty.fmt(pt)}); |
| 1291 | | 1291 | |
| 1292 | const param_regs = abi.Registers.Integer.function_arg_regs; | 1292 | const param_regs = abi.Registers.Integer.function_arg_regs; |
| 1293 | const ret_reg = param_regs[0]; | 1293 | const ret_reg = param_regs[0]; |
| ... | @@ -1369,7 +1369,7 @@ fn genLazy(func: *Func, lazy_sym: link.File.LazySymbol) InnerError!void { | ... | @@ -1369,7 +1369,7 @@ fn genLazy(func: *Func, lazy_sym: link.File.LazySymbol) InnerError!void { |
| 1369 | }); | 1369 | }); |
| 1370 | }, | 1370 | }, |
| 1371 | else => return func.fail( | 1371 | else => return func.fail( |
| 1372 | "TODO implement {s} for {}", | 1372 | "TODO implement {s} for {f}", |
| 1373 | .{ @tagName(lazy_sym.kind), Type.fromInterned(lazy_sym.ty).fmt(pt) }, | 1373 | .{ @tagName(lazy_sym.kind), Type.fromInterned(lazy_sym.ty).fmt(pt) }, |
| 1374 | ), | 1374 | ), |
| 1375 | } | 1375 | } |
| ... | @@ -1383,8 +1383,8 @@ fn genBody(func: *Func, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -1383,8 +1383,8 @@ fn genBody(func: *Func, body: []const Air.Inst.Index) InnerError!void { |
| 1383 | | 1383 | |
| 1384 | for (body) |inst| { | 1384 | for (body) |inst| { |
| 1385 | if (func.liveness.isUnused(inst) and !func.air.mustLower(inst, ip)) continue; | 1385 | if (func.liveness.isUnused(inst) and !func.air.mustLower(inst, ip)) continue; |
| 1386 | wip_mir_log.debug("{}", .{func.fmtAir(inst)}); | 1386 | wip_mir_log.debug("{f}", .{func.fmtAir(inst)}); |
| 1387 | verbose_tracking_log.debug("{}", .{func.fmtTracking()}); | 1387 | verbose_tracking_log.debug("{f}", .{func.fmtTracking()}); |
| 1388 | | 1388 | |
| 1389 | const old_air_bookkeeping = func.air_bookkeeping; | 1389 | const old_air_bookkeeping = func.air_bookkeeping; |
| 1390 | try func.ensureProcessDeathCapacity(Air.Liveness.bpi); | 1390 | try func.ensureProcessDeathCapacity(Air.Liveness.bpi); |
| ... | @@ -1674,7 +1674,7 @@ fn genBody(func: *Func, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -1674,7 +1674,7 @@ fn genBody(func: *Func, body: []const Air.Inst.Index) InnerError!void { |
| 1674 | } | 1674 | } |
| 1675 | } | 1675 | } |
| 1676 | } | 1676 | } |
| 1677 | verbose_tracking_log.debug("{}", .{func.fmtTracking()}); | 1677 | verbose_tracking_log.debug("{f}", .{func.fmtTracking()}); |
| 1678 | } | 1678 | } |
| 1679 | | 1679 | |
| 1680 | fn getValue(func: *Func, value: MCValue, inst: ?Air.Inst.Index) !void { | 1680 | fn getValue(func: *Func, value: MCValue, inst: ?Air.Inst.Index) !void { |
| ... | @@ -1891,7 +1891,7 @@ fn splitType(func: *Func, ty: Type) ![2]Type { | ... | @@ -1891,7 +1891,7 @@ fn splitType(func: *Func, ty: Type) ![2]Type { |
| 1891 | else => return func.fail("TODO: splitType class {}", .{class}), | 1891 | else => return func.fail("TODO: splitType class {}", .{class}), |
| 1892 | }; | 1892 | }; |
| 1893 | } else if (parts[0].abiSize(zcu) + parts[1].abiSize(zcu) == ty.abiSize(zcu)) return parts; | 1893 | } else if (parts[0].abiSize(zcu) + parts[1].abiSize(zcu) == ty.abiSize(zcu)) return parts; |
| 1894 | return func.fail("TODO implement splitType for {}", .{ty.fmt(func.pt)}); | 1894 | return func.fail("TODO implement splitType for {f}", .{ty.fmt(func.pt)}); |
| 1895 | } | 1895 | } |
| 1896 | | 1896 | |
| 1897 | /// Truncates the value in the register in place. | 1897 | /// Truncates the value in the register in place. |
| ... | @@ -2004,7 +2004,7 @@ fn allocMemPtr(func: *Func, inst: Air.Inst.Index) !FrameIndex { | ... | @@ -2004,7 +2004,7 @@ fn allocMemPtr(func: *Func, inst: Air.Inst.Index) !FrameIndex { |
| 2004 | const val_ty = ptr_ty.childType(zcu); | 2004 | const val_ty = ptr_ty.childType(zcu); |
| 2005 | return func.allocFrameIndex(FrameAlloc.init(.{ | 2005 | return func.allocFrameIndex(FrameAlloc.init(.{ |
| 2006 | .size = math.cast(u32, val_ty.abiSize(zcu)) orelse { | 2006 | .size = math.cast(u32, val_ty.abiSize(zcu)) orelse { |
| 2007 | return func.fail("type '{}' too big to fit into stack frame", .{val_ty.fmt(pt)}); | 2007 | return func.fail("type '{f}' too big to fit into stack frame", .{val_ty.fmt(pt)}); |
| 2008 | }, | 2008 | }, |
| 2009 | .alignment = ptr_ty.ptrAlignment(zcu).max(.@"1"), | 2009 | .alignment = ptr_ty.ptrAlignment(zcu).max(.@"1"), |
| 2010 | })); | 2010 | })); |
| ... | @@ -2144,7 +2144,7 @@ pub fn spillRegisters(func: *Func, comptime registers: []const Register) !void { | ... | @@ -2144,7 +2144,7 @@ pub fn spillRegisters(func: *Func, comptime registers: []const Register) !void { |
| 2144 | /// allocated. A second call to `copyToTmpRegister` may return the same register. | 2144 | /// allocated. A second call to `copyToTmpRegister` may return the same register. |
| 2145 | /// This can have a side effect of spilling instructions to the stack to free up a register. | 2145 | /// This can have a side effect of spilling instructions to the stack to free up a register. |
| 2146 | fn copyToTmpRegister(func: *Func, ty: Type, mcv: MCValue) !Register { | 2146 | fn copyToTmpRegister(func: *Func, ty: Type, mcv: MCValue) !Register { |
| 2147 | log.debug("copyToTmpRegister ty: {}", .{ty.fmt(func.pt)}); | 2147 | log.debug("copyToTmpRegister ty: {f}", .{ty.fmt(func.pt)}); |
| 2148 | const reg = try func.register_manager.allocReg(null, func.regTempClassForType(ty)); | 2148 | const reg = try func.register_manager.allocReg(null, func.regTempClassForType(ty)); |
| 2149 | try func.genSetReg(ty, reg, mcv); | 2149 | try func.genSetReg(ty, reg, mcv); |
| 2150 | return reg; | 2150 | return reg; |
| ... | @@ -2229,7 +2229,7 @@ fn airIntCast(func: *Func, inst: Air.Inst.Index) !void { | ... | @@ -2229,7 +2229,7 @@ fn airIntCast(func: *Func, inst: Air.Inst.Index) !void { |
| 2229 | break :result null; // TODO | 2229 | break :result null; // TODO |
| 2230 | | 2230 | |
| 2231 | break :result dst_mcv; | 2231 | break :result dst_mcv; |
| 2232 | } orelse return func.fail("TODO: implement airIntCast from {} to {}", .{ | 2232 | } orelse return func.fail("TODO: implement airIntCast from {f} to {f}", .{ |
| 2233 | src_ty.fmt(pt), dst_ty.fmt(pt), | 2233 | src_ty.fmt(pt), dst_ty.fmt(pt), |
| 2234 | }); | 2234 | }); |
| 2235 | | 2235 | |
| ... | @@ -2617,7 +2617,7 @@ fn genBinOp( | ... | @@ -2617,7 +2617,7 @@ fn genBinOp( |
| 2617 | .add_sat, | 2617 | .add_sat, |
| 2618 | => { | 2618 | => { |
| 2619 | if (bit_size != 64 or !is_unsigned) | 2619 | if (bit_size != 64 or !is_unsigned) |
| 2620 | return func.fail("TODO: genBinOp ty: {}", .{lhs_ty.fmt(pt)}); | 2620 | return func.fail("TODO: genBinOp ty: {f}", .{lhs_ty.fmt(pt)}); |
| 2621 | | 2621 | |
| 2622 | const tmp_reg = try func.copyToTmpRegister(rhs_ty, .{ .register = rhs_reg }); | 2622 | const tmp_reg = try func.copyToTmpRegister(rhs_ty, .{ .register = rhs_reg }); |
| 2623 | const tmp_lock = func.register_manager.lockRegAssumeUnused(tmp_reg); | 2623 | const tmp_lock = func.register_manager.lockRegAssumeUnused(tmp_reg); |
| ... | @@ -4049,7 +4049,7 @@ fn airGetUnionTag(func: *Func, inst: Air.Inst.Index) !void { | ... | @@ -4049,7 +4049,7 @@ fn airGetUnionTag(func: *Func, inst: Air.Inst.Index) !void { |
| 4049 | ); | 4049 | ); |
| 4050 | } else { | 4050 | } else { |
| 4051 | return func.fail( | 4051 | return func.fail( |
| 4052 | "TODO implement get_union_tag for ABI larger than 8 bytes and operand {}, tag {}", | 4052 | "TODO implement get_union_tag for ABI larger than 8 bytes and operand {}, tag {f}", |
| 4053 | .{ frame_mcv, tag_ty.fmt(pt) }, | 4053 | .{ frame_mcv, tag_ty.fmt(pt) }, |
| 4054 | ); | 4054 | ); |
| 4055 | } | 4055 | } |
| ... | @@ -4170,7 +4170,7 @@ fn airAbs(func: *Func, inst: Air.Inst.Index) !void { | ... | @@ -4170,7 +4170,7 @@ fn airAbs(func: *Func, inst: Air.Inst.Index) !void { |
| 4170 | | 4170 | |
| 4171 | switch (scalar_ty.zigTypeTag(zcu)) { | 4171 | switch (scalar_ty.zigTypeTag(zcu)) { |
| 4172 | .int => if (ty.zigTypeTag(zcu) == .vector) { | 4172 | .int => if (ty.zigTypeTag(zcu) == .vector) { |
| 4173 | return func.fail("TODO implement airAbs for {}", .{ty.fmt(pt)}); | 4173 | return func.fail("TODO implement airAbs for {f}", .{ty.fmt(pt)}); |
| 4174 | } else { | 4174 | } else { |
| 4175 | const int_info = scalar_ty.intInfo(zcu); | 4175 | const int_info = scalar_ty.intInfo(zcu); |
| 4176 | const int_bits = int_info.bits; | 4176 | const int_bits = int_info.bits; |
| ... | @@ -4251,7 +4251,7 @@ fn airAbs(func: *Func, inst: Air.Inst.Index) !void { | ... | @@ -4251,7 +4251,7 @@ fn airAbs(func: *Func, inst: Air.Inst.Index) !void { |
| 4251 | | 4251 | |
| 4252 | break :result return_mcv; | 4252 | break :result return_mcv; |
| 4253 | }, | 4253 | }, |
| 4254 | else => return func.fail("TODO: implement airAbs {}", .{scalar_ty.fmt(pt)}), | 4254 | else => return func.fail("TODO: implement airAbs {f}", .{scalar_ty.fmt(pt)}), |
| 4255 | } | 4255 | } |
| 4256 | | 4256 | |
| 4257 | break :result .unreach; | 4257 | break :result .unreach; |
| ... | @@ -4315,7 +4315,7 @@ fn airByteSwap(func: *Func, inst: Air.Inst.Index) !void { | ... | @@ -4315,7 +4315,7 @@ fn airByteSwap(func: *Func, inst: Air.Inst.Index) !void { |
| 4315 | | 4315 | |
| 4316 | break :result dest_mcv; | 4316 | break :result dest_mcv; |
| 4317 | }, | 4317 | }, |
| 4318 | else => return func.fail("TODO: airByteSwap {}", .{ty.fmt(pt)}), | 4318 | else => return func.fail("TODO: airByteSwap {f}", .{ty.fmt(pt)}), |
| 4319 | } | 4319 | } |
| 4320 | }; | 4320 | }; |
| 4321 | return func.finishAir(inst, result, .{ ty_op.operand, .none, .none }); | 4321 | return func.finishAir(inst, result, .{ ty_op.operand, .none, .none }); |
| ... | @@ -4381,7 +4381,7 @@ fn airUnaryMath(func: *Func, inst: Air.Inst.Index, tag: Air.Inst.Tag) !void { | ... | @@ -4381,7 +4381,7 @@ fn airUnaryMath(func: *Func, inst: Air.Inst.Index, tag: Air.Inst.Tag) !void { |
| 4381 | else => return func.fail("TODO: airUnaryMath Float {s}", .{@tagName(tag)}), | 4381 | else => return func.fail("TODO: airUnaryMath Float {s}", .{@tagName(tag)}), |
| 4382 | } | 4382 | } |
| 4383 | }, | 4383 | }, |
| 4384 | else => return func.fail("TODO: airUnaryMath ty: {}", .{ty.fmt(pt)}), | 4384 | else => return func.fail("TODO: airUnaryMath ty: {f}", .{ty.fmt(pt)}), |
| 4385 | } | 4385 | } |
| 4386 | | 4386 | |
| 4387 | break :result MCValue{ .register = dst_reg }; | 4387 | break :result MCValue{ .register = dst_reg }; |
| ... | @@ -4481,7 +4481,7 @@ fn load(func: *Func, dst_mcv: MCValue, ptr_mcv: MCValue, ptr_ty: Type) InnerErro | ... | @@ -4481,7 +4481,7 @@ fn load(func: *Func, dst_mcv: MCValue, ptr_mcv: MCValue, ptr_ty: Type) InnerErro |
| 4481 | const zcu = pt.zcu; | 4481 | const zcu = pt.zcu; |
| 4482 | const dst_ty = ptr_ty.childType(zcu); | 4482 | const dst_ty = ptr_ty.childType(zcu); |
| 4483 | | 4483 | |
| 4484 | log.debug("loading {}:{} into {}", .{ ptr_mcv, ptr_ty.fmt(pt), dst_mcv }); | 4484 | log.debug("loading {}:{f} into {}", .{ ptr_mcv, ptr_ty.fmt(pt), dst_mcv }); |
| 4485 | | 4485 | |
| 4486 | switch (ptr_mcv) { | 4486 | switch (ptr_mcv) { |
| 4487 | .none, | 4487 | .none, |
| ... | @@ -4534,7 +4534,7 @@ fn airStore(func: *Func, inst: Air.Inst.Index, safety: bool) !void { | ... | @@ -4534,7 +4534,7 @@ fn airStore(func: *Func, inst: Air.Inst.Index, safety: bool) !void { |
| 4534 | fn store(func: *Func, ptr_mcv: MCValue, src_mcv: MCValue, ptr_ty: Type) !void { | 4534 | fn store(func: *Func, ptr_mcv: MCValue, src_mcv: MCValue, ptr_ty: Type) !void { |
| 4535 | const zcu = func.pt.zcu; | 4535 | const zcu = func.pt.zcu; |
| 4536 | const src_ty = ptr_ty.childType(zcu); | 4536 | const src_ty = ptr_ty.childType(zcu); |
| 4537 | log.debug("storing {}:{} in {}:{}", .{ src_mcv, src_ty.fmt(func.pt), ptr_mcv, ptr_ty.fmt(func.pt) }); | 4537 | log.debug("storing {}:{f} in {}:{f}", .{ src_mcv, src_ty.fmt(func.pt), ptr_mcv, ptr_ty.fmt(func.pt) }); |
| 4538 | | 4538 | |
| 4539 | switch (ptr_mcv) { | 4539 | switch (ptr_mcv) { |
| 4540 | .none => unreachable, | 4540 | .none => unreachable, |
| ... | @@ -7289,7 +7289,7 @@ fn airBitCast(func: *Func, inst: Air.Inst.Index) !void { | ... | @@ -7289,7 +7289,7 @@ fn airBitCast(func: *Func, inst: Air.Inst.Index) !void { |
| 7289 | const bit_size = dst_ty.bitSize(zcu); | 7289 | const bit_size = dst_ty.bitSize(zcu); |
| 7290 | if (abi_size * 8 <= bit_size) break :result dst_mcv; | 7290 | if (abi_size * 8 <= bit_size) break :result dst_mcv; |
| 7291 | | 7291 | |
| 7292 | return func.fail("TODO: airBitCast {} to {}", .{ src_ty.fmt(pt), dst_ty.fmt(pt) }); | 7292 | return func.fail("TODO: airBitCast {f} to {f}", .{ src_ty.fmt(pt), dst_ty.fmt(pt) }); |
| 7293 | }; | 7293 | }; |
| 7294 | return func.finishAir(inst, result, .{ ty_op.operand, .none, .none }); | 7294 | return func.finishAir(inst, result, .{ ty_op.operand, .none, .none }); |
| 7295 | } | 7295 | } |
| ... | @@ -8105,7 +8105,7 @@ fn airAggregateInit(func: *Func, inst: Air.Inst.Index) !void { | ... | @@ -8105,7 +8105,7 @@ fn airAggregateInit(func: *Func, inst: Air.Inst.Index) !void { |
| 8105 | ); | 8105 | ); |
| 8106 | break :result .{ .load_frame = .{ .index = frame_index } }; | 8106 | break :result .{ .load_frame = .{ .index = frame_index } }; |
| 8107 | }, | 8107 | }, |
| 8108 | else => return func.fail("TODO: airAggregate {}", .{result_ty.fmt(pt)}), | 8108 | else => return func.fail("TODO: airAggregate {f}", .{result_ty.fmt(pt)}), |
| 8109 | } | 8109 | } |
| 8110 | }; | 8110 | }; |
| 8111 | | 8111 | |
| ... | @@ -8306,7 +8306,7 @@ fn resolveCallingConventionValues( | ... | @@ -8306,7 +8306,7 @@ fn resolveCallingConventionValues( |
| 8306 | }; | 8306 | }; |
| 8307 | | 8307 | |
| 8308 | result.return_value = switch (ret_tracking_i) { | 8308 | result.return_value = switch (ret_tracking_i) { |
| 8309 | else => return func.fail("ty {} took {} tracking return indices", .{ ret_ty.fmt(pt), ret_tracking_i }), | 8309 | else => return func.fail("ty {f} took {} tracking return indices", .{ ret_ty.fmt(pt), ret_tracking_i }), |
| 8310 | 1 => ret_tracking[0], | 8310 | 1 => ret_tracking[0], |
| 8311 | 2 => InstTracking.init(.{ .register_pair = .{ | 8311 | 2 => InstTracking.init(.{ .register_pair = .{ |
| 8312 | ret_tracking[0].short.register, ret_tracking[1].short.register, | 8312 | ret_tracking[0].short.register, ret_tracking[1].short.register, |
| ... | @@ -8361,7 +8361,7 @@ fn resolveCallingConventionValues( | ... | @@ -8361,7 +8361,7 @@ fn resolveCallingConventionValues( |
| 8361 | else => return func.fail("TODO: C calling convention arg class {}", .{class}), | 8361 | else => return func.fail("TODO: C calling convention arg class {}", .{class}), |
| 8362 | } else { | 8362 | } else { |
| 8363 | arg.* = switch (arg_mcv_i) { | 8363 | arg.* = switch (arg_mcv_i) { |
| 8364 | else => return func.fail("ty {} took {} tracking arg indices", .{ ty.fmt(pt), arg_mcv_i }), | 8364 | else => return func.fail("ty {f} took {} tracking arg indices", .{ ty.fmt(pt), arg_mcv_i }), |
| 8365 | 1 => arg_mcv[0], | 8365 | 1 => arg_mcv[0], |
| 8366 | 2 => .{ .register_pair = .{ arg_mcv[0].register, arg_mcv[1].register } }, | 8366 | 2 => .{ .register_pair = .{ arg_mcv[0].register, arg_mcv[1].register } }, |
| 8367 | }; | 8367 | }; |