| author | |
| committer | |
| log | 572517376a7695693c59a0ec4ec6cc5442003e3a |
| tree | 6b93537b4f022f84e3646598b9af6721258969bc |
| parent | 68c7fc5c595b4a48f95b3f2f8c4d0a6c3a388667 |
3 files changed, 26 insertions(+), 30 deletions(-)
src/codegen/spirv.zig+14-20| ... | ... | @@ -1474,10 +1474,7 @@ pub const DeclGen = struct { |
| 1474 | 1474 | try self.spv.addFunction(spv_decl_index, self.func); |
| 1475 | 1475 | |
| 1476 | 1476 | const fqn = ip.stringToSlice(try decl.getFullyQualifiedName(self.module)); |
| 1477 | try self.spv.sections.debug_names.emit(self.gpa, .OpName, .{ | |
| 1478 | .target = decl_id, | |
| 1479 | .name = fqn, | |
| 1480 | }); | |
| 1477 | try self.spv.debugName(decl_id, fqn); | |
| 1481 | 1478 | |
| 1482 | 1479 | // Temporarily generate a test kernel declaration if this is a test function. |
| 1483 | 1480 | if (self.module.test_functions.contains(self.decl_index)) { |
| ... | ... | @@ -1548,17 +1545,8 @@ pub const DeclGen = struct { |
| 1548 | 1545 | try self.spv.addFunction(spv_decl_index, self.func); |
| 1549 | 1546 | |
| 1550 | 1547 | const fqn = ip.stringToSlice(try decl.getFullyQualifiedName(self.module)); |
| 1551 | try self.spv.sections.debug_names.emit(self.gpa, .OpName, .{ | |
| 1552 | .target = decl_id, | |
| 1553 | .name = fqn, | |
| 1554 | }); | |
| 1555 | ||
| 1556 | const init_name = try std.fmt.allocPrint(self.gpa, "initializer of {s}", .{fqn}); | |
| 1557 | defer self.gpa.free(init_name); | |
| 1558 | try self.spv.sections.debug_names.emit(self.gpa, .OpName, .{ | |
| 1559 | .target = initializer_id, | |
| 1560 | .name = init_name, | |
| 1561 | }); | |
| 1548 | try self.spv.debugName(decl_id, fqn); | |
| 1549 | try self.spv.debugNameFmt(initializer_id, "initializer of {s}", .{fqn}); | |
| 1562 | 1550 | } |
| 1563 | 1551 | } |
| 1564 | 1552 | |
| ... | ... | @@ -1756,11 +1744,10 @@ pub const DeclGen = struct { |
| 1756 | 1744 | .switch_br => return self.airSwitchBr(inst), |
| 1757 | 1745 | .unreach, .trap => return self.airUnreach(), |
| 1758 | 1746 | |
| 1759 | .dbg_stmt => return self.airDbgStmt(inst), | |
| 1760 | .dbg_inline_begin => return self.airDbgInlineBegin(inst), | |
| 1761 | .dbg_inline_end => return self.airDbgInlineEnd(inst), | |
| 1762 | .dbg_var_ptr => return, | |
| 1763 | .dbg_var_val => return, | |
| 1747 | .dbg_stmt => return self.airDbgStmt(inst), | |
| 1748 | .dbg_inline_begin => return self.airDbgInlineBegin(inst), | |
| 1749 | .dbg_inline_end => return self.airDbgInlineEnd(inst), | |
| 1750 | .dbg_var_ptr, .dbg_var_val => return self.airDbgVar(inst), | |
| 1764 | 1751 | .dbg_block_begin => return, |
| 1765 | 1752 | .dbg_block_end => return, |
| 1766 | 1753 | |
| ... | ... | @@ -3566,6 +3553,13 @@ pub const DeclGen = struct { |
| 3566 | 3553 | _ = self.base_line_stack.pop(); |
| 3567 | 3554 | } |
| 3568 | 3555 | |
| 3556 | fn airDbgVar(self: *DeclGen, inst: Air.Inst.Index) !void { | |
| 3557 | const pl_op = self.air.instructions.items(.data)[inst].pl_op; | |
| 3558 | const target_id = try self.resolve(pl_op.operand); | |
| 3559 | const name = self.air.nullTerminatedString(pl_op.payload); | |
| 3560 | try self.spv.debugName(target_id, name); | |
| 3561 | } | |
| 3562 | ||
| 3569 | 3563 | fn airAssembly(self: *DeclGen, inst: Air.Inst.Index) !?IdRef { |
| 3570 | 3564 | const mod = self.module; |
| 3571 | 3565 | const ty_pl = self.air.instructions.items(.data)[inst].ty_pl; |
src/codegen/spirv/Cache.zig+6-6| ... | ... | @@ -462,11 +462,11 @@ fn emit( |
| 462 | 462 | switch (key) { |
| 463 | 463 | .void_type => { |
| 464 | 464 | try section.emit(spv.gpa, .OpTypeVoid, .{ .id_result = result_id }); |
| 465 | try spv.debugName(result_id, "void", .{}); | |
| 465 | try spv.debugName(result_id, "void"); | |
| 466 | 466 | }, |
| 467 | 467 | .bool_type => { |
| 468 | 468 | try section.emit(spv.gpa, .OpTypeBool, .{ .id_result = result_id }); |
| 469 | try spv.debugName(result_id, "bool", .{}); | |
| 469 | try spv.debugName(result_id, "bool"); | |
| 470 | 470 | }, |
| 471 | 471 | .int_type => |int| { |
| 472 | 472 | try section.emit(spv.gpa, .OpTypeInt, .{ |
| ... | ... | @@ -481,14 +481,14 @@ fn emit( |
| 481 | 481 | .unsigned => "u", |
| 482 | 482 | .signed => "i", |
| 483 | 483 | }; |
| 484 | try spv.debugName(result_id, "{s}{}", .{ ui, int.bits }); | |
| 484 | try spv.debugNameFmt(result_id, "{s}{}", .{ ui, int.bits }); | |
| 485 | 485 | }, |
| 486 | 486 | .float_type => |float| { |
| 487 | 487 | try section.emit(spv.gpa, .OpTypeFloat, .{ |
| 488 | 488 | .id_result = result_id, |
| 489 | 489 | .width = float.bits, |
| 490 | 490 | }); |
| 491 | try spv.debugName(result_id, "f{}", .{float.bits}); | |
| 491 | try spv.debugNameFmt(result_id, "f{}", .{float.bits}); | |
| 492 | 492 | }, |
| 493 | 493 | .vector_type => |vector| { |
| 494 | 494 | try section.emit(spv.gpa, .OpTypeVector, .{ |
| ... | ... | @@ -530,11 +530,11 @@ fn emit( |
| 530 | 530 | section.writeOperand(IdResult, self.resultId(member_type)); |
| 531 | 531 | } |
| 532 | 532 | if (self.getString(struct_type.name)) |name| { |
| 533 | try spv.debugName(result_id, "{s}", .{name}); | |
| 533 | try spv.debugName(result_id, name); | |
| 534 | 534 | } |
| 535 | 535 | for (struct_type.memberNames(), 0..) |member_name, i| { |
| 536 | 536 | if (self.getString(member_name)) |name| { |
| 537 | try spv.memberDebugName(result_id, @as(u32, @intCast(i)), "{s}", .{name}); | |
| 537 | try spv.memberDebugName(result_id, @as(u32, @intCast(i)), name); | |
| 538 | 538 | } |
| 539 | 539 | } |
| 540 | 540 | // TODO: Decorations? |
src/codegen/spirv/Module.zig+6-4| ... | ... | @@ -645,18 +645,20 @@ pub fn declareEntryPoint(self: *Module, decl_index: Decl.Index, name: []const u8 |
| 645 | 645 | }); |
| 646 | 646 | } |
| 647 | 647 | |
| 648 | pub fn debugName(self: *Module, target: IdResult, comptime fmt: []const u8, args: anytype) !void { | |
| 649 | const name = try std.fmt.allocPrint(self.gpa, fmt, args); | |
| 650 | defer self.gpa.free(name); | |
| 648 | pub fn debugName(self: *Module, target: IdResult, name: []const u8) !void { | |
| 651 | 649 | try self.sections.debug_names.emit(self.gpa, .OpName, .{ |
| 652 | 650 | .target = target, |
| 653 | 651 | .name = name, |
| 654 | 652 | }); |
| 655 | 653 | } |
| 656 | 654 | |
| 657 | pub fn memberDebugName(self: *Module, target: IdResult, member: u32, comptime fmt: []const u8, args: anytype) !void { | |
| 655 | pub fn debugNameFmt(self: *Module, target: IdResult, comptime fmt: []const u8, args: anytype) !void { | |
| 658 | 656 | const name = try std.fmt.allocPrint(self.gpa, fmt, args); |
| 659 | 657 | defer self.gpa.free(name); |
| 658 | try self.debugName(target, name); | |
| 659 | } | |
| 660 | ||
| 661 | pub fn memberDebugName(self: *Module, target: IdResult, member: u32, name: []const u8) !void { | |
| 660 | 662 | try self.sections.debug_names.emit(self.gpa, .OpMemberName, .{ |
| 661 | 663 | .type = target, |
| 662 | 664 | .member = member, |