| ... | ... | @@ -222,6 +222,14 @@ const Branch = struct { |
| 222 | 222 | try writer.writeAll("}"); |
| 223 | 223 | } |
| 224 | 224 | |
| 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 | 233 | fn fmtDebug(self: @This()) std.fmt.Formatter(fmt) { |
| 226 | 234 | return .{ .data = .{ |
| 227 | 235 | .insts = self.inst_table.keys(), |
| ... | ... | @@ -823,7 +831,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void { |
| 823 | 831 | fn processDeath(self: *Self, inst: Air.Inst.Index) void { |
| 824 | 832 | const air_tags = self.air.instructions.items(.tag); |
| 825 | 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 | 835 | // When editing this function, note that the logic must synchronize with `reuseOperand`. |
| 828 | 836 | const prev_value = self.getResolvedInstValue(inst); |
| 829 | 837 | const branch = &self.branch_stack.items[self.branch_stack.items.len - 1]; |
| ... | ... | @@ -851,10 +859,8 @@ fn finishAirBookkeeping(self: *Self) void { |
| 851 | 859 | } |
| 852 | 860 | |
| 853 | 861 | fn 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 | 862 | var tomb_bits = self.liveness.getTombBits(inst); |
| 856 | 863 | for (operands) |op| { |
| 857 | | log.debug(" (processing {})", .{op}); |
| 858 | 864 | const dies = @truncate(u1, tomb_bits) != 0; |
| 859 | 865 | tomb_bits >>= 1; |
| 860 | 866 | if (!dies) continue; |
| ... | ... | @@ -865,7 +871,7 @@ fn finishAir(self: *Self, inst: Air.Inst.Index, result: MCValue, operands: [Live |
| 865 | 871 | } |
| 866 | 872 | const is_used = @truncate(u1, tomb_bits) == 0; |
| 867 | 873 | if (is_used) { |
| 868 | | log.debug(" (saving %{d} => {})", .{ inst, result }); |
| 874 | log.debug("%{d} => {}", .{ inst, result }); |
| 869 | 875 | const branch = &self.branch_stack.items[self.branch_stack.items.len - 1]; |
| 870 | 876 | branch.inst_table.putAssumeCapacityNoClobber(inst, result); |
| 871 | 877 | |
| ... | ... | @@ -4678,8 +4684,6 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void { |
| 4678 | 4684 | |
| 4679 | 4685 | const reloc = try self.genCondBrMir(cond_ty, cond); |
| 4680 | 4686 | |
| 4681 | | log.debug("airCondBr: %{d}", .{inst}); |
| 4682 | | |
| 4683 | 4687 | // If the condition dies here in this condbr instruction, process |
| 4684 | 4688 | // that death now instead of later as this has an effect on |
| 4685 | 4689 | // whether it needs to be spilled in the branches |
| ... | ... | @@ -4736,6 +4740,7 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void { |
| 4736 | 4740 | // that we can use all the code emitting abstractions. This is why at the bottom we |
| 4737 | 4741 | // assert that parent_branch.free_registers equals the saved_then_branch.free_registers |
| 4738 | 4742 | // rather than assigning it. |
| 4743 | log.debug("airCondBr: %{d}", .{inst}); |
| 4739 | 4744 | log.debug("Upper branches:", .{}); |
| 4740 | 4745 | for (self.branch_stack.items) |bs| { |
| 4741 | 4746 | log.debug("{}", .{bs.fmtDebug()}); |
| ... | ... | @@ -5119,8 +5124,6 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) !void { |
| 5119 | 5124 | ); |
| 5120 | 5125 | defer self.gpa.free(liveness.deaths); |
| 5121 | 5126 | |
| 5122 | | log.debug("airSwitch: %{d}", .{inst}); |
| 5123 | | |
| 5124 | 5127 | // If the condition dies here in this switch instruction, process |
| 5125 | 5128 | // that death now instead of later as this has an effect on |
| 5126 | 5129 | // whether it needs to be spilled in the branches |
| ... | ... | @@ -5207,6 +5210,7 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) !void { |
| 5207 | 5210 | |
| 5208 | 5211 | // Consolidate returned MCValues between prongs and else branch like we do |
| 5209 | 5212 | // in airCondBr. |
| 5213 | log.debug("airSwitch: %{d}", .{inst}); |
| 5210 | 5214 | log.debug("Upper branches:", .{}); |
| 5211 | 5215 | for (self.branch_stack.items) |bs| { |
| 5212 | 5216 | log.debug("{}", .{bs.fmtDebug()}); |