authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-09-02 20:49:37+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-09-07 22:42:56+02:00
log1d57b347e9aeddc2de33b1b77b331d36e4900425
treec4ffa0e8511a99767813e3174b9690f52d468e15
parentb9c31a8703fdd8297673aa65a1bdefd56cd13b77

x86_64: clean up logging


1 files changed, 12 insertions(+), 8 deletions(-)

src/arch/x86_64/CodeGen.zig+12-8
...@@ -222,6 +222,14 @@ const Branch = struct {...@@ -222,6 +222,14 @@ const Branch = struct {
222 try writer.writeAll("}");222 try writer.writeAll("}");
223 }223 }
224224
225 fn format(branch: Branch, comptime unused_format_string: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
226 _ = branch;
227 _ = unused_format_string;
228 _ = options;
229 _ = writer;
230 @compileError("do not format Branch directly; use ty.fmtDebug()");
231 }
232
225 fn fmtDebug(self: @This()) std.fmt.Formatter(fmt) {233 fn fmtDebug(self: @This()) std.fmt.Formatter(fmt) {
226 return .{ .data = .{234 return .{ .data = .{
227 .insts = self.inst_table.keys(),235 .insts = self.inst_table.keys(),
...@@ -823,7 +831,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {...@@ -823,7 +831,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
823fn processDeath(self: *Self, inst: Air.Inst.Index) void {831fn processDeath(self: *Self, inst: Air.Inst.Index) void {
824 const air_tags = self.air.instructions.items(.tag);832 const air_tags = self.air.instructions.items(.tag);
825 if (air_tags[inst] == .constant) return; // Constants are immortal.833 if (air_tags[inst] == .constant) return; // Constants are immortal.
826 log.debug(" (processing death of %{d})", .{inst});834 log.debug("%{d} => {}", .{ inst, MCValue.dead });
827 // When editing this function, note that the logic must synchronize with `reuseOperand`.835 // When editing this function, note that the logic must synchronize with `reuseOperand`.
828 const prev_value = self.getResolvedInstValue(inst);836 const prev_value = self.getResolvedInstValue(inst);
829 const branch = &self.branch_stack.items[self.branch_stack.items.len - 1];837 const branch = &self.branch_stack.items[self.branch_stack.items.len - 1];
...@@ -851,10 +859,8 @@ fn finishAirBookkeeping(self: *Self) void {...@@ -851,10 +859,8 @@ fn finishAirBookkeeping(self: *Self) void {
851}859}
852860
853fn finishAir(self: *Self, inst: Air.Inst.Index, result: MCValue, operands: [Liveness.bpi - 1]Air.Inst.Ref) void {861fn finishAir(self: *Self, inst: Air.Inst.Index, result: MCValue, operands: [Liveness.bpi - 1]Air.Inst.Ref) void {
854 log.debug("finishAir: %{d}, {}, {any}", .{ inst, result, operands });
855 var tomb_bits = self.liveness.getTombBits(inst);862 var tomb_bits = self.liveness.getTombBits(inst);
856 for (operands) |op| {863 for (operands) |op| {
857 log.debug(" (processing {})", .{op});
858 const dies = @truncate(u1, tomb_bits) != 0;864 const dies = @truncate(u1, tomb_bits) != 0;
859 tomb_bits >>= 1;865 tomb_bits >>= 1;
860 if (!dies) continue;866 if (!dies) continue;
...@@ -865,7 +871,7 @@ fn finishAir(self: *Self, inst: Air.Inst.Index, result: MCValue, operands: [Live...@@ -865,7 +871,7 @@ fn finishAir(self: *Self, inst: Air.Inst.Index, result: MCValue, operands: [Live
865 }871 }
866 const is_used = @truncate(u1, tomb_bits) == 0;872 const is_used = @truncate(u1, tomb_bits) == 0;
867 if (is_used) {873 if (is_used) {
868 log.debug(" (saving %{d} => {})", .{ inst, result });874 log.debug("%{d} => {}", .{ inst, result });
869 const branch = &self.branch_stack.items[self.branch_stack.items.len - 1];875 const branch = &self.branch_stack.items[self.branch_stack.items.len - 1];
870 branch.inst_table.putAssumeCapacityNoClobber(inst, result);876 branch.inst_table.putAssumeCapacityNoClobber(inst, result);
871877
...@@ -4678,8 +4684,6 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void {...@@ -4678,8 +4684,6 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void {
46784684
4679 const reloc = try self.genCondBrMir(cond_ty, cond);4685 const reloc = try self.genCondBrMir(cond_ty, cond);
46804686
4681 log.debug("airCondBr: %{d}", .{inst});
4682
4683 // If the condition dies here in this condbr instruction, process4687 // If the condition dies here in this condbr instruction, process
4684 // that death now instead of later as this has an effect on4688 // that death now instead of later as this has an effect on
4685 // whether it needs to be spilled in the branches4689 // whether it needs to be spilled in the branches
...@@ -4736,6 +4740,7 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void {...@@ -4736,6 +4740,7 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void {
4736 // that we can use all the code emitting abstractions. This is why at the bottom we4740 // that we can use all the code emitting abstractions. This is why at the bottom we
4737 // assert that parent_branch.free_registers equals the saved_then_branch.free_registers4741 // assert that parent_branch.free_registers equals the saved_then_branch.free_registers
4738 // rather than assigning it.4742 // rather than assigning it.
4743 log.debug("airCondBr: %{d}", .{inst});
4739 log.debug("Upper branches:", .{});4744 log.debug("Upper branches:", .{});
4740 for (self.branch_stack.items) |bs| {4745 for (self.branch_stack.items) |bs| {
4741 log.debug("{}", .{bs.fmtDebug()});4746 log.debug("{}", .{bs.fmtDebug()});
...@@ -5119,8 +5124,6 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) !void {...@@ -5119,8 +5124,6 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) !void {
5119 );5124 );
5120 defer self.gpa.free(liveness.deaths);5125 defer self.gpa.free(liveness.deaths);
51215126
5122 log.debug("airSwitch: %{d}", .{inst});
5123
5124 // If the condition dies here in this switch instruction, process5127 // If the condition dies here in this switch instruction, process
5125 // that death now instead of later as this has an effect on5128 // that death now instead of later as this has an effect on
5126 // whether it needs to be spilled in the branches5129 // whether it needs to be spilled in the branches
...@@ -5207,6 +5210,7 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) !void {...@@ -5207,6 +5210,7 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) !void {
52075210
5208 // Consolidate returned MCValues between prongs and else branch like we do5211 // Consolidate returned MCValues between prongs and else branch like we do
5209 // in airCondBr.5212 // in airCondBr.
5213 log.debug("airSwitch: %{d}", .{inst});
5210 log.debug("Upper branches:", .{});5214 log.debug("Upper branches:", .{});
5211 for (self.branch_stack.items) |bs| {5215 for (self.branch_stack.items) |bs| {
5212 log.debug("{}", .{bs.fmtDebug()});5216 log.debug("{}", .{bs.fmtDebug()});