| ... | @@ -9,7 +9,11 @@ units: []Unit, | ... | @@ -9,7 +9,11 @@ units: []Unit, |
| 9 | consts: std.ArrayList(Const), | 9 | consts: std.ArrayList(Const), |
| 10 | globals: std.array_hash_map.Auto(InternPool.Nav.Index, Global), | 10 | globals: std.array_hash_map.Auto(InternPool.Nav.Index, Global), |
| 11 | funcs: std.array_hash_map.Auto(InternPool.Nav.Index, Func), | 11 | funcs: std.array_hash_map.Auto(InternPool.Nav.Index, Func), |
| 12 | decls: std.array_hash_map.Auto(InternPool.TrackedInst.Index, MappedFile.Node.Index), | 12 | decls: std.array_hash_map.Auto(InternPool.TrackedInst.Index, Decl), |
| | 13 | pending_decl: ?struct { |
| | 14 | di: Decl.Index, |
| | 15 | instance_val: InternPool.Index, |
| | 16 | }, |
| 13 | | 17 | |
| 14 | debug_abbrev: Abbrev, | 18 | debug_abbrev: Abbrev, |
| 15 | frame: Frame, | 19 | frame: Frame, |
| ... | @@ -135,6 +139,22 @@ pub const Func = struct { | ... | @@ -135,6 +139,22 @@ pub const Func = struct { |
| 135 | }; | 139 | }; |
| 136 | }; | 140 | }; |
| 137 | | 141 | |
| | 142 | pub const Decl = struct { |
| | 143 | debug_info_ni: MappedFile.Node.Index.Optional, |
| | 144 | |
| | 145 | pub const Index = enum(u32) { |
| | 146 | _, |
| | 147 | |
| | 148 | pub fn srcInst(di: Decl.Index, dwarf: *Dwarf) InternPool.TrackedInst.Index { |
| | 149 | return dwarf.decls.keys()[@backingInt(di)]; |
| | 150 | } |
| | 151 | |
| | 152 | pub fn get(di: Decl.Index, dwarf: *Dwarf) *Decl { |
| | 153 | return &dwarf.decls.values()[@backingInt(di)]; |
| | 154 | } |
| | 155 | }; |
| | 156 | }; |
| | 157 | |
| 138 | pub const Frame = struct { | 158 | pub const Frame = struct { |
| 139 | header: Header, | 159 | header: Header, |
| 140 | | 160 | |
| ... | @@ -632,29 +652,33 @@ pub const WipNav = struct { | ... | @@ -632,29 +652,33 @@ pub const WipNav = struct { |
| 632 | } | 652 | } |
| 633 | fn startFuncDebugInfoInner(debug: *Debug) link.EmitError!void { | 653 | fn startFuncDebugInfoInner(debug: *Debug) link.EmitError!void { |
| 634 | const dwarf = debug.wip_nav.dwarf; | 654 | const dwarf = debug.wip_nav.dwarf; |
| 635 | const zcu = debug.pt.zcu; | 655 | const pt = debug.pt; |
| | 656 | const zcu = pt.zcu; |
| 636 | const ip = &zcu.intern_pool; | 657 | const ip = &zcu.intern_pool; |
| 637 | const func = zcu.funcInfo(debug.wip_nav.func); | 658 | const func = zcu.funcInfo(debug.wip_nav.func); |
| | 659 | const nav = ip.getNav(func.owner_nav); |
| 638 | const func_type = ip.indexToKey(func.ty).func_type; | 660 | const func_type = ip.indexToKey(func.ty).func_type; |
| 639 | const inst_info = ip.getNav(func.owner_nav).srcInst(ip).resolveFull(ip).?; | 661 | const inst_info = nav.srcInst(ip).resolveFull(ip).?; |
| 640 | const zf = zcu.fileByIndex(inst_info.file); | 662 | const zf = zcu.fileByIndex(inst_info.file); |
| 641 | const mod = zf.mod.?; | 663 | const target = &zf.mod.?.resolved_target.result; |
| 642 | const target = &mod.resolved_target.result; | | |
| 643 | const decl = zf.zir.?.getDeclaration(inst_info.inst); | 664 | const decl = zf.zir.?.getDeclaration(inst_info.inst); |
| 644 | const nav = ip.getNav(func.owner_nav); | 665 | const di_nw = &debug.info_writer; |
| 645 | const diw = &debug.info_writer.interface; | 666 | const diw = &di_nw.interface; |
| 646 | try diw.writeUleb128(try dwarf.refAbbrevCode(.decl_func)); | 667 | try diw.writeUleb128(try dwarf.refAbbrevCode(.decl_func)); |
| 647 | try debug.refType(.fromInterned(zcu.fileRootType(inst_info.file))); | 668 | try dwarf.refConst(pt, di_nw, .fromInterned(ip.namespacePtr(switch (func.generic_owner) { |
| | 669 | .none => nav, |
| | 670 | else => |generic_owner| ip.getNav(zcu.funcInfo(generic_owner).owner_nav), |
| | 671 | }.analysis.?.namespace).owner_type)); |
| 648 | try diw.writeInt(u32, decl.src_line + 1, dwarf.endian); | 672 | try diw.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| 649 | try diw.writeUleb128(decl.src_column + 1); | 673 | try diw.writeUleb128(decl.src_column + 1); |
| 650 | try diw.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); | 674 | try diw.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); |
| 651 | try debug.strp(nav.name.toSlice(ip)); | 675 | try dwarf.strp(&dwarf.debug_str, di_nw, nav.name.toSlice(ip)); |
| 652 | try debug.strp(switch (decl.linkage) { | 676 | try dwarf.strp(&dwarf.debug_str, di_nw, switch (decl.linkage) { |
| 653 | .normal => nav.fqn, | 677 | .normal => nav.fqn, |
| 654 | .@"extern", .@"export" => nav.name, | 678 | .@"extern", .@"export" => nav.name, |
| 655 | }.toSlice(ip)); | 679 | }.toSlice(ip)); |
| 656 | try debug.refType(.fromInterned(func_type.return_type)); | 680 | try dwarf.refConst(pt, di_nw, .fromInterned(func_type.return_type)); |
| 657 | try dwarf.symbolAddress(&debug.info_writer, debug.wip_nav.func_si, 0); | 681 | try dwarf.symbolAddress(di_nw, debug.wip_nav.func_si, 0); |
| 658 | debug.info_func_length_offset = diw.end; | 682 | debug.info_func_length_offset = diw.end; |
| 659 | try diw.writeInt(u32, undefined, dwarf.endian); | 683 | try diw.writeInt(u32, undefined, dwarf.endian); |
| 660 | try diw.writeUleb128( | 684 | try diw.writeUleb128( |
| ... | @@ -756,12 +780,14 @@ pub const WipNav = struct { | ... | @@ -756,12 +780,14 @@ pub const WipNav = struct { |
| 756 | loc: Loc, | 780 | loc: Loc, |
| 757 | ) link.EmitError!void { | 781 | ) link.EmitError!void { |
| 758 | assert(debug.wip_nav.func != .none); | 782 | assert(debug.wip_nav.func != .none); |
| 759 | try debug.abbrevCode(switch (tag) { | 783 | const dwarf = debug.wip_nav.dwarf; |
| | 784 | const di_nw = &debug.info_writer; |
| | 785 | try di_nw.interface.writeUleb128(try dwarf.refAbbrevCode(switch (tag) { |
| 760 | .arg => if (opt_name) |_| .arg else .unnamed_arg, | 786 | .arg => if (opt_name) |_| .arg else .unnamed_arg, |
| 761 | .local_var => if (opt_name) |_| .local_var else unreachable, | 787 | .local_var => if (opt_name) |_| .local_var else unreachable, |
| 762 | }); | 788 | })); |
| 763 | if (opt_name) |name| try debug.strp(name); | 789 | if (opt_name) |name| try dwarf.strp(&dwarf.debug_str, di_nw, name); |
| 764 | if (false) try debug.refType(ty); | 790 | try dwarf.refConst(debug.pt, di_nw, ty.toValue()); |
| 765 | try debug.infoExprLoc(loc); | 791 | try debug.infoExprLoc(loc); |
| 766 | debug.any_children = true; | 792 | debug.any_children = true; |
| 767 | } | 793 | } |
| ... | @@ -785,27 +811,38 @@ pub const WipNav = struct { | ... | @@ -785,27 +811,38 @@ pub const WipNav = struct { |
| 785 | val: Value, | 811 | val: Value, |
| 786 | ) link.EmitError!void { | 812 | ) link.EmitError!void { |
| 787 | assert(debug.wip_nav.func != .none); | 813 | assert(debug.wip_nav.func != .none); |
| | 814 | const dwarf = debug.wip_nav.dwarf; |
| | 815 | const pt = debug.pt; |
| 788 | const zcu = debug.pt.zcu; | 816 | const zcu = debug.pt.zcu; |
| 789 | const ty = val.typeOf(zcu); | 817 | const ty = val.typeOf(zcu); |
| 790 | const has_runtime_bits = ty.hasRuntimeBits(zcu); | 818 | const ty_class = ty.classify(zcu); |
| 791 | const has_comptime_state = ty.comptimeOnly(zcu); | 819 | const di_nw = &debug.info_writer; |
| 792 | try debug.abbrevCode(if (has_runtime_bits and has_comptime_state) switch (tag) { | 820 | try di_nw.interface.writeUleb128(try dwarf.refAbbrevCode(switch (tag) { |
| 793 | .comptime_arg => if (opt_name) |_| .comptime_arg_runtime_bits_comptime_state else .unnamed_comptime_arg_runtime_bits_comptime_state, | 821 | .comptime_arg => if (opt_name) |_| switch (ty_class) { |
| 794 | .local_const => if (opt_name) |_| .local_const_runtime_bits_comptime_state else unreachable, | 822 | .no_possible_value => unreachable, |
| 795 | } else if (has_comptime_state) switch (tag) { | 823 | .one_possible_value => .comptime_arg, |
| 796 | .comptime_arg => if (opt_name) |_| .comptime_arg_comptime_state else .unnamed_comptime_arg_comptime_state, | 824 | .runtime => .comptime_arg_fully_runtime, |
| 797 | .local_const => if (opt_name) |_| .local_const_comptime_state else unreachable, | 825 | .partially_comptime => .comptime_arg_partially_comptime, |
| 798 | } else if (has_runtime_bits) switch (tag) { | 826 | .fully_comptime => .comptime_arg_fully_comptime, |
| 799 | .comptime_arg => if (opt_name) |_| .comptime_arg_runtime_bits else .unnamed_comptime_arg_runtime_bits, | 827 | } else switch (ty_class) { |
| 800 | .local_const => if (opt_name) |_| .local_const_runtime_bits else unreachable, | 828 | .no_possible_value => unreachable, |
| 801 | } else switch (tag) { | 829 | .one_possible_value => .unnamed_comptime_arg, |
| 802 | .comptime_arg => if (opt_name) |_| .comptime_arg else .unnamed_comptime_arg, | 830 | .runtime => .unnamed_comptime_arg_fully_runtime, |
| 803 | .local_const => if (opt_name) |_| .local_const else unreachable, | 831 | .partially_comptime => .unnamed_comptime_arg_partially_comptime, |
| 804 | }); | 832 | .fully_comptime => .unnamed_comptime_arg_fully_comptime, |
| 805 | if (opt_name) |name| try debug.strp(name); | 833 | }, |
| 806 | if (false) try debug.refType(ty); | 834 | .local_const => if (opt_name) |_| switch (ty_class) { |
| 807 | if (has_runtime_bits) try debug.blockValue(val); | 835 | .no_possible_value => unreachable, |
| 808 | if (false and has_comptime_state) try debug.refValue(val); | 836 | .one_possible_value => .local_const, |
| | 837 | .runtime => .local_const_fully_runtime, |
| | 838 | .partially_comptime => .local_const_partially_comptime, |
| | 839 | .fully_comptime => .local_const_fully_comptime, |
| | 840 | } else unreachable, |
| | 841 | })); |
| | 842 | if (opt_name) |name| try dwarf.strp(&dwarf.debug_str, di_nw, name); |
| | 843 | try dwarf.refConst(pt, di_nw, ty.toValue()); |
| | 844 | if (ty_class.hasRuntimeBits()) try dwarf.blockConst(pt, di_nw, val); |
| | 845 | if (ty_class.comptimeOnly()) try dwarf.refConst(pt, di_nw, val); |
| 809 | debug.any_children = true; | 846 | debug.any_children = true; |
| 810 | } | 847 | } |
| 811 | | 848 | |
| ... | @@ -817,7 +854,7 @@ pub const WipNav = struct { | ... | @@ -817,7 +854,7 @@ pub const WipNav = struct { |
| 817 | } | 854 | } |
| 818 | fn genVarArgsDebugInfoInner(debug: *Debug) link.EmitError!void { | 855 | fn genVarArgsDebugInfoInner(debug: *Debug) link.EmitError!void { |
| 819 | assert(debug.wip_nav.func != .none); | 856 | assert(debug.wip_nav.func != .none); |
| 820 | try debug.abbrevCode(.is_var_args); | 857 | try debug.info_writer.interface.writeUleb128(try debug.wip_nav.dwarf.refAbbrevCode(.is_var_args)); |
| 821 | debug.any_children = true; | 858 | debug.any_children = true; |
| 822 | } | 859 | } |
| 823 | | 860 | |
| ... | @@ -927,11 +964,11 @@ pub const WipNav = struct { | ... | @@ -927,11 +964,11 @@ pub const WipNav = struct { |
| 927 | } | 964 | } |
| 928 | fn enterBlockInner(debug: *Debug, code_off: usize) link.EmitError!void { | 965 | fn enterBlockInner(debug: *Debug, code_off: usize) link.EmitError!void { |
| 929 | const dwarf = debug.wip_nav.dwarf; | 966 | const dwarf = debug.wip_nav.dwarf; |
| 930 | const diw = &debug.info_writer.interface; | | |
| 931 | const block = try debug.blocks.addOne(dwarf.lf.comp.gpa); | 967 | const block = try debug.blocks.addOne(dwarf.lf.comp.gpa); |
| 932 | | 968 | |
| | 969 | const diw = &debug.info_writer.interface; |
| 933 | block.abbrev_code = @intCast(diw.end); | 970 | block.abbrev_code = @intCast(diw.end); |
| 934 | try debug.abbrevCode(.block); | 971 | try diw.writeUleb128(try dwarf.refAbbrevCode(.block)); |
| 935 | block.low_pc_off = code_off; | 972 | block.low_pc_off = code_off; |
| 936 | try debug.infoAddrSym(debug.wip_nav.func_si, code_off); | 973 | try debug.infoAddrSym(debug.wip_nav.func_si, code_off); |
| 937 | block.high_pc = @intCast(diw.end); | 974 | block.high_pc = @intCast(diw.end); |
| ... | @@ -947,14 +984,14 @@ pub const WipNav = struct { | ... | @@ -947,14 +984,14 @@ pub const WipNav = struct { |
| 947 | } | 984 | } |
| 948 | fn leaveBlockInner(debug: *Debug, code_off: usize) link.EmitError!void { | 985 | fn leaveBlockInner(debug: *Debug, code_off: usize) link.EmitError!void { |
| 949 | const dwarf = debug.wip_nav.dwarf; | 986 | const dwarf = debug.wip_nav.dwarf; |
| 950 | const block_bytes = comptime uleb128Size(@backingInt(AbbrevCode.block)); | 987 | const block_size = comptime uleb128Size(@backingInt(AbbrevCode.block)); |
| 951 | const block = debug.blocks.pop().?; | 988 | const block = debug.blocks.pop().?; |
| 952 | if (debug.any_children) | 989 | if (debug.any_children) |
| 953 | try debug.info_writer.interface.writeUleb128(@backingInt(AbbrevCode.null)) | 990 | try debug.info_writer.interface.writeUleb128(@backingInt(AbbrevCode.null)) |
| 954 | else | 991 | else |
| 955 | std.leb.writeUnsignedFixed( | 992 | std.leb.writeUnsignedFixed( |
| 956 | block_bytes, | 993 | block_size, |
| 957 | debug.info_writer.interface.buffered()[block.abbrev_code..][0..block_bytes], | 994 | debug.info_writer.interface.buffered()[block.abbrev_code..][0..block_size], |
| 958 | @intCast(try dwarf.refAbbrevCode(.empty_block)), | 995 | @intCast(try dwarf.refAbbrevCode(.empty_block)), |
| 959 | ); | 996 | ); |
| 960 | std.mem.writeInt( | 997 | std.mem.writeInt( |
| ... | @@ -987,11 +1024,11 @@ pub const WipNav = struct { | ... | @@ -987,11 +1024,11 @@ pub const WipNav = struct { |
| 987 | ) link.EmitError!void { | 1024 | ) link.EmitError!void { |
| 988 | const dwarf = debug.wip_nav.dwarf; | 1025 | const dwarf = debug.wip_nav.dwarf; |
| 989 | const zcu = debug.pt.zcu; | 1026 | const zcu = debug.pt.zcu; |
| 990 | const diw = &debug.info_writer.interface; | | |
| 991 | const block = try debug.blocks.addOne(zcu.gpa); | 1027 | const block = try debug.blocks.addOne(zcu.gpa); |
| 992 | | 1028 | |
| | 1029 | const diw = &debug.info_writer.interface; |
| 993 | block.abbrev_code = @intCast(diw.end); | 1030 | block.abbrev_code = @intCast(diw.end); |
| 994 | try debug.abbrevCode(.inlined_func); | 1031 | try diw.writeUleb128(try dwarf.refAbbrevCode(.inlined_func)); |
| 995 | try debug.refFunc(func); | 1032 | try debug.refFunc(func); |
| 996 | try diw.writeUleb128((if (zcu.comp.config.incremental) | 1033 | try diw.writeUleb128((if (zcu.comp.config.incremental) |
| 997 | 0 | 1034 | 0 |
| ... | @@ -1019,15 +1056,15 @@ pub const WipNav = struct { | ... | @@ -1019,15 +1056,15 @@ pub const WipNav = struct { |
| 1019 | code_off: usize, | 1056 | code_off: usize, |
| 1020 | ) link.EmitError!void { | 1057 | ) link.EmitError!void { |
| 1021 | const dwarf = debug.wip_nav.dwarf; | 1058 | const dwarf = debug.wip_nav.dwarf; |
| 1022 | const inlined_func_bytes = comptime uleb128Size(@backingInt(AbbrevCode.inlined_func)); | 1059 | const inlined_func_size = comptime uleb128Size(@backingInt(AbbrevCode.inlined_func)); |
| 1023 | const block = debug.blocks.pop().?; | 1060 | const block = debug.blocks.pop().?; |
| 1024 | const diw = &debug.info_writer.interface; | 1061 | const diw = &debug.info_writer.interface; |
| 1025 | if (debug.any_children) | 1062 | if (debug.any_children) |
| 1026 | try diw.writeUleb128(@backingInt(AbbrevCode.null)) | 1063 | try diw.writeUleb128(@backingInt(AbbrevCode.null)) |
| 1027 | else | 1064 | else |
| 1028 | std.leb.writeUnsignedFixed( | 1065 | std.leb.writeUnsignedFixed( |
| 1029 | inlined_func_bytes, | 1066 | inlined_func_size, |
| 1030 | diw.buffered()[block.abbrev_code..][0..inlined_func_bytes], | 1067 | diw.buffered()[block.abbrev_code..][0..inlined_func_size], |
| 1031 | @intCast(try dwarf.refAbbrevCode(.empty_inlined_func)), | 1068 | @intCast(try dwarf.refAbbrevCode(.empty_inlined_func)), |
| 1032 | ); | 1069 | ); |
| 1033 | std.mem.writeInt( | 1070 | std.mem.writeInt( |
| ... | @@ -1091,24 +1128,6 @@ pub const WipNav = struct { | ... | @@ -1091,24 +1128,6 @@ pub const WipNav = struct { |
| 1091 | debug.wip_nav.func = func; | 1128 | debug.wip_nav.func = func; |
| 1092 | } | 1129 | } |
| 1093 | | 1130 | |
| 1094 | fn abbrevCode(debug: *Debug, abbrev_code: AbbrevCode) link.EmitError!void { | | |
| 1095 | try debug.info_writer.interface.writeUleb128( | | |
| 1096 | try debug.wip_nav.dwarf.refAbbrevCode(abbrev_code), | | |
| 1097 | ); | | |
| 1098 | } | | |
| 1099 | | | |
| 1100 | fn strp(debug: *Debug, str: []const u8) link.EmitError!void { | | |
| 1101 | const dwarf = debug.wip_nav.dwarf; | | |
| 1102 | try dwarf.strp(&dwarf.debug_str, &debug.info_writer, str); | | |
| 1103 | } | | |
| 1104 | | | |
| 1105 | fn strpFmt(debug: *Debug, comptime fmt: []const u8, args: anytype) link.EmitError!void { | | |
| 1106 | const gpa = debug.pt.zcu.gpa; | | |
| 1107 | const str = try gpa.print(fmt, args); | | |
| 1108 | defer gpa.free(str); | | |
| 1109 | try debug.strp(str); | | |
| 1110 | } | | |
| 1111 | | | |
| 1112 | fn infoExprLoc(debug: *Debug, loc: Loc) link.EmitError!void { | 1131 | fn infoExprLoc(debug: *Debug, loc: Loc) link.EmitError!void { |
| 1113 | var buf: [64]u8 = undefined; | 1132 | var buf: [64]u8 = undefined; |
| 1114 | var counter: ExprLocCounter = .init(debug.wip_nav.dwarf, &buf); | 1133 | var counter: ExprLocCounter = .init(debug.wip_nav.dwarf, &buf); |
| ... | @@ -1146,45 +1165,6 @@ pub const WipNav = struct { | ... | @@ -1146,45 +1165,6 @@ pub const WipNav = struct { |
| 1146 | 0, | 1165 | 0, |
| 1147 | ); | 1166 | ); |
| 1148 | } | 1167 | } |
| 1149 | | | |
| 1150 | fn refType(debug: *Debug, ty: Type) link.EmitError!void { | | |
| 1151 | return debug.refValue(ty.toValue()); | | |
| 1152 | } | | |
| 1153 | | | |
| 1154 | fn refValue(debug: *Debug, val: Value) link.EmitError!void { | | |
| 1155 | const dwarf = debug.wip_nav.dwarf; | | |
| 1156 | const cpi = try dwarf.getConst(debug.pt, val); | | |
| 1157 | try dwarf.sectionOffset( | | |
| 1158 | &debug.info_writer, | | |
| 1159 | Const.get(cpi, dwarf).debug_info_ni.unwrap().?, | | |
| 1160 | 0, | | |
| 1161 | ); | | |
| 1162 | } | | |
| 1163 | | | |
| 1164 | fn blockValue(debug: *Debug, val: Value) link.EmitError!void { | | |
| 1165 | const ty = val.typeOf(debug.pt.zcu); | | |
| 1166 | const diw = &debug.info_writer.interface; | | |
| 1167 | const size = ty.abiSize(debug.pt.zcu); | | |
| 1168 | try diw.writeUleb128(size); | | |
| 1169 | if (size == 0) return; | | |
| 1170 | const offset = diw.end; | | |
| 1171 | try codegen.generateSymbol( | | |
| 1172 | debug.wip_nav.dwarf.lf, | | |
| 1173 | debug.pt, | | |
| 1174 | val, | | |
| 1175 | diw, | | |
| 1176 | .{ .debug_output = .{ .dwarf2 = debug } }, | | |
| 1177 | ); | | |
| 1178 | if (offset + size != diw.end) { | | |
| 1179 | std.debug.print("{f} [{}]: {} != {}\n", .{ | | |
| 1180 | ty.fmt(debug.pt), | | |
| 1181 | ty.toIntern(), | | |
| 1182 | size, | | |
| 1183 | diw.end - offset, | | |
| 1184 | }); | | |
| 1185 | unreachable; | | |
| 1186 | } | | |
| 1187 | } | | |
| 1188 | }; | 1168 | }; |
| 1189 | | 1169 | |
| 1190 | pub fn deinit(wip_nav: *WipNav) void { | 1170 | pub fn deinit(wip_nav: *WipNav) void { |
| ... | @@ -1271,15 +1251,12 @@ pub const WipNav = struct { | ... | @@ -1271,15 +1251,12 @@ pub const WipNav = struct { |
| 1271 | | 1251 | |
| 1272 | const ExprLocCounter = struct { | 1252 | const ExprLocCounter = struct { |
| 1273 | dw: Writer.Discarding, | 1253 | dw: Writer.Discarding, |
| 1274 | section_offset_bytes: u32, | 1254 | section_offset_size: usize, |
| 1275 | address_size: AddressSize, | 1255 | address_size: AddressSize, |
| 1276 | fn init(dwarf: *Dwarf, buf: []u8) ExprLocCounter { | 1256 | fn init(dwarf: *Dwarf, buf: []u8) ExprLocCounter { |
| 1277 | return .{ | 1257 | return .{ |
| 1278 | .dw = .init(buf), | 1258 | .dw = .init(buf), |
| 1279 | .section_offset_bytes = switch (dwarf.format) { | 1259 | .section_offset_size = dwarf.sectionOffsetSize(), |
| 1280 | .@"32" => 4, | | |
| 1281 | .@"64" => 8, | | |
| 1282 | }, | | |
| 1283 | .address_size = dwarf.address_size, | 1260 | .address_size = dwarf.address_size, |
| 1284 | }; | 1261 | }; |
| 1285 | } | 1262 | } |
| ... | @@ -1293,7 +1270,7 @@ pub const WipNav = struct { | ... | @@ -1293,7 +1270,7 @@ pub const WipNav = struct { |
| 1293 | try counter.dw.writer.splatByteAll(undefined, @backingInt(counter.address_size)); | 1270 | try counter.dw.writer.splatByteAll(undefined, @backingInt(counter.address_size)); |
| 1294 | } | 1271 | } |
| 1295 | fn infoEntry(counter: *ExprLocCounter, _: MappedFile.Node.Index) Writer.Error!void { | 1272 | fn infoEntry(counter: *ExprLocCounter, _: MappedFile.Node.Index) Writer.Error!void { |
| 1296 | try counter.dw.writer.splatByteAll(undefined, counter.section_offset_bytes); | 1273 | try counter.dw.writer.splatByteAll(undefined, counter.section_offset_size); |
| 1297 | } | 1274 | } |
| 1298 | }; | 1275 | }; |
| 1299 | | 1276 | |
| ... | @@ -1363,6 +1340,7 @@ pub fn init(lf: *link.File, format: DW.Format) Dwarf { | ... | @@ -1363,6 +1340,7 @@ pub fn init(lf: *link.File, format: DW.Format) Dwarf { |
| 1363 | .globals = .empty, | 1340 | .globals = .empty, |
| 1364 | .funcs = .empty, | 1341 | .funcs = .empty, |
| 1365 | .decls = .empty, | 1342 | .decls = .empty, |
| | 1343 | .pending_decl = null, |
| 1366 | | 1344 | |
| 1367 | .debug_abbrev = .{ | 1345 | .debug_abbrev = .{ |
| 1368 | .ni = .none, | 1346 | .ni = .none, |
| ... | @@ -1486,9 +1464,7 @@ pub fn getUnit(dwarf: *Dwarf, mod: *Module) Unit.Index { | ... | @@ -1486,9 +1464,7 @@ pub fn getUnit(dwarf: *Dwarf, mod: *Module) Unit.Index { |
| 1486 | } | 1464 | } |
| 1487 | | 1465 | |
| 1488 | pub fn getConst(dwarf: *Dwarf, pt: Zcu.PerThread, val: Value) link.Error!link.ConstPool.Index { | 1466 | pub fn getConst(dwarf: *Dwarf, pt: Zcu.PerThread, val: Value) link.Error!link.ConstPool.Index { |
| 1489 | const zcu = pt.zcu; | 1467 | assert(val.typeOf(pt.zcu).comptimeOnly(pt.zcu)); |
| 1490 | const ty = val.typeOf(zcu); | | |
| 1491 | if (ty.toIntern() != .type_type) assert(ty.comptimeOnly(zcu)); | | |
| 1492 | return dwarf.const_pool.get(pt, .{ .elf2 = dwarf.lf.cast(.elf2).? }, val.toIntern()); | 1468 | return dwarf.const_pool.get(pt, .{ .elf2 = dwarf.lf.cast(.elf2).? }, val.toIntern()); |
| 1493 | } | 1469 | } |
| 1494 | | 1470 | |
| ... | @@ -1505,7 +1481,11 @@ pub fn getGlobal(dwarf: *Dwarf, nav: InternPool.Nav.Index) link.Error!Global.Ind | ... | @@ -1505,7 +1481,11 @@ pub fn getGlobal(dwarf: *Dwarf, nav: InternPool.Nav.Index) link.Error!Global.Ind |
| 1505 | assert(!mod.strip); | 1481 | assert(!mod.strip); |
| 1506 | const elf = dwarf.lf.cast(.elf2).?; | 1482 | const elf = dwarf.lf.cast(.elf2).?; |
| 1507 | try elf.nodes.ensureUnusedCapacity(gpa, 1); | 1483 | try elf.nodes.ensureUnusedCapacity(gpa, 1); |
| 1508 | try elf.dwarf_globals.ensureUnusedCapacity(gpa, 1); | 1484 | try elf.dwarf_globals.append(gpa, .{ |
| | 1485 | .debug_info_first_target_reloc = .none, |
| | 1486 | .debug_info_first_node_reloc = .none, |
| | 1487 | .debug_info_first_symbol_reloc = .none, |
| | 1488 | }); |
| 1509 | const unit = dwarf.getUnit(mod).get(dwarf); | 1489 | const unit = dwarf.getUnit(mod).get(dwarf); |
| 1510 | global_gop.value_ptr.debug_info_ni = .wrap(elf.addNodeAssumeCapacity( | 1490 | global_gop.value_ptr.debug_info_ni = .wrap(elf.addNodeAssumeCapacity( |
| 1511 | unit.debug_info_ni.unwrap().?.addFloatingChild(gpa, &elf.mf, .{ | 1491 | unit.debug_info_ni.unwrap().?.addFloatingChild(gpa, &elf.mf, .{ |
| ... | @@ -1518,11 +1498,6 @@ pub fn getGlobal(dwarf: *Dwarf, nav: InternPool.Nav.Index) link.Error!Global.Ind | ... | @@ -1518,11 +1498,6 @@ pub fn getGlobal(dwarf: *Dwarf, nav: InternPool.Nav.Index) link.Error!Global.Ind |
| 1518 | }, | 1498 | }, |
| 1519 | .{ .global_debug_info = gi }, | 1499 | .{ .global_debug_info = gi }, |
| 1520 | )); | 1500 | )); |
| 1521 | elf.dwarf_globals.addOneAssumeCapacity().* = .{ | | |
| 1522 | .debug_info_first_target_reloc = .none, | | |
| 1523 | .debug_info_first_node_reloc = .none, | | |
| 1524 | .debug_info_first_symbol_reloc = .none, | | |
| 1525 | }; | | |
| 1526 | return gi; | 1501 | return gi; |
| 1527 | } | 1502 | } |
| 1528 | pub fn getGlobalIfExists(dwarf: *Dwarf, nav: InternPool.Nav.Index) ?Global.Index { | 1503 | pub fn getGlobalIfExists(dwarf: *Dwarf, nav: InternPool.Nav.Index) ?Global.Index { |
| ... | @@ -1542,9 +1517,8 @@ pub fn getFunc(dwarf: *Dwarf, nav: InternPool.Nav.Index) link.Error!Func.Index { | ... | @@ -1542,9 +1517,8 @@ pub fn getFunc(dwarf: *Dwarf, nav: InternPool.Nav.Index) link.Error!Func.Index { |
| 1542 | if (func_gop.value_ptr.debug_info_ni != .none) return fi; | 1517 | if (func_gop.value_ptr.debug_info_ni != .none) return fi; |
| 1543 | const mod = comp.zcu.?.navFileScope(nav).mod.?; | 1518 | const mod = comp.zcu.?.navFileScope(nav).mod.?; |
| 1544 | const elf = dwarf.lf.cast(.elf2).?; | 1519 | const elf = dwarf.lf.cast(.elf2).?; |
| 1545 | try elf.dwarf_funcs.ensureUnusedCapacity(gpa, 1); | | |
| 1546 | try elf.nodes.ensureUnusedCapacity(gpa, 1); | 1520 | try elf.nodes.ensureUnusedCapacity(gpa, 1); |
| 1547 | elf.dwarf_funcs.addOneAssumeCapacity().* = .{ | 1521 | try elf.dwarf_funcs.append(gpa, .{ |
| 1548 | .frame_fde_first_symbol_reloc = .none, | 1522 | .frame_fde_first_symbol_reloc = .none, |
| 1549 | .frame_fde_first_node_reloc = .none, | 1523 | .frame_fde_first_node_reloc = .none, |
| 1550 | .debug_info_first_target_reloc = .none, | 1524 | .debug_info_first_target_reloc = .none, |
| ... | @@ -1552,7 +1526,7 @@ pub fn getFunc(dwarf: *Dwarf, nav: InternPool.Nav.Index) link.Error!Func.Index { | ... | @@ -1552,7 +1526,7 @@ pub fn getFunc(dwarf: *Dwarf, nav: InternPool.Nav.Index) link.Error!Func.Index { |
| 1552 | .debug_info_first_node_reloc = .none, | 1526 | .debug_info_first_node_reloc = .none, |
| 1553 | .debug_line_first_symbol_reloc = .none, | 1527 | .debug_line_first_symbol_reloc = .none, |
| 1554 | .debug_line_first_node_reloc = .none, | 1528 | .debug_line_first_node_reloc = .none, |
| 1555 | }; | 1529 | }); |
| 1556 | if (mod.strip) return fi; | 1530 | if (mod.strip) return fi; |
| 1557 | const unit = dwarf.getUnit(mod).get(dwarf); | 1531 | const unit = dwarf.getUnit(mod).get(dwarf); |
| 1558 | func_gop.value_ptr.debug_info_ni = .wrap(elf.addNodeAssumeCapacity( | 1532 | func_gop.value_ptr.debug_info_ni = .wrap(elf.addNodeAssumeCapacity( |
| ... | @@ -1572,6 +1546,86 @@ pub fn getFuncIfExists(dwarf: *Dwarf, nav: InternPool.Nav.Index) ?Func.Index { | ... | @@ -1572,6 +1546,86 @@ pub fn getFuncIfExists(dwarf: *Dwarf, nav: InternPool.Nav.Index) ?Func.Index { |
| 1572 | return @fromBackingInt(@intCast(dwarf.funcs.getIndex(nav) orelse return null)); | 1546 | return @fromBackingInt(@intCast(dwarf.funcs.getIndex(nav) orelse return null)); |
| 1573 | } | 1547 | } |
| 1574 | | 1548 | |
| | 1549 | pub fn getDeclInst(dwarf: *Dwarf, val: InternPool.Index) ?InternPool.TrackedInst.Index { |
| | 1550 | const ip = &dwarf.lf.comp.zcu.?.intern_pool; |
| | 1551 | switch (ip.indexToKey(val)) { |
| | 1552 | else => unreachable, |
| | 1553 | .struct_type => { |
| | 1554 | const loaded_struct = ip.loadStructType(val); |
| | 1555 | if (loaded_struct.captures.len == 0) return null; |
| | 1556 | return ip.getNav(loaded_struct.name_nav.unwrap() orelse |
| | 1557 | return loaded_struct.zir_index).srcInst(ip); |
| | 1558 | }, |
| | 1559 | .enum_type => { |
| | 1560 | const loaded_enum = ip.loadEnumType(val); |
| | 1561 | if (loaded_enum.captures.len == 0) return null; |
| | 1562 | return ip.getNav(loaded_enum.name_nav.unwrap() orelse |
| | 1563 | return loaded_enum.zir_index.unwrap().?).srcInst(ip); |
| | 1564 | }, |
| | 1565 | .union_type => { |
| | 1566 | const loaded_union = ip.loadUnionType(val); |
| | 1567 | if (loaded_union.captures.len == 0) return null; |
| | 1568 | return ip.getNav(loaded_union.name_nav.unwrap() orelse |
| | 1569 | return loaded_union.zir_index).srcInst(ip); |
| | 1570 | }, |
| | 1571 | .opaque_type => { |
| | 1572 | const loaded_opaque = ip.loadOpaqueType(val); |
| | 1573 | if (loaded_opaque.captures.len == 0) return null; |
| | 1574 | return ip.getNav(loaded_opaque.name_nav.unwrap() orelse |
| | 1575 | return loaded_opaque.zir_index).srcInst(ip); |
| | 1576 | }, |
| | 1577 | .func => |func| return ip.getNav(switch (func.generic_owner) { |
| | 1578 | .none => func.owner_nav, |
| | 1579 | else => |generic_owner| ip.indexToKey(generic_owner).func.owner_nav, |
| | 1580 | }).srcInst(ip), |
| | 1581 | } |
| | 1582 | } |
| | 1583 | pub fn getDecl( |
| | 1584 | dwarf: *Dwarf, |
| | 1585 | pt: Zcu.PerThread, |
| | 1586 | instance_val: InternPool.Index, |
| | 1587 | ) link.Error!MappedFile.Node.Index { |
| | 1588 | assert(dwarf.pending_decl == null); |
| | 1589 | const comp = dwarf.lf.comp; |
| | 1590 | const gpa = comp.gpa; |
| | 1591 | const zcu = pt.zcu; |
| | 1592 | const ip = &zcu.intern_pool; |
| | 1593 | const inst = dwarf.getDeclInst(instance_val) orelse { |
| | 1594 | const cpi = try dwarf.getConst(pt, .fromInterned(instance_val)); |
| | 1595 | return Const.get(cpi, dwarf).debug_info_ni.unwrap().?; |
| | 1596 | }; |
| | 1597 | const decl_gop = try dwarf.decls.getOrPut(gpa, inst); |
| | 1598 | if (!decl_gop.found_existing) decl_gop.value_ptr.* = .{ |
| | 1599 | .debug_info_ni = .none, |
| | 1600 | }; |
| | 1601 | const di: Decl.Index = @fromBackingInt(@intCast(decl_gop.index)); |
| | 1602 | if (decl_gop.value_ptr.debug_info_ni.unwrap()) |debug_info_ni| return debug_info_ni; |
| | 1603 | dwarf.pending_decl = .{ .di = di, .instance_val = instance_val }; |
| | 1604 | const elf = dwarf.lf.cast(.elf2).?; |
| | 1605 | try elf.nodes.ensureUnusedCapacity(gpa, 1); |
| | 1606 | try elf.dwarf_decls.putNoClobber(gpa, di, .{ |
| | 1607 | .debug_info_first_target_reloc = .none, |
| | 1608 | .debug_info_first_node_reloc = .none, |
| | 1609 | }); |
| | 1610 | const unit = dwarf.getUnit(zcu.fileByIndex(di.srcInst(dwarf).resolveFile(ip)).mod.?).get(dwarf); |
| | 1611 | const debug_info_ni = elf.addNodeAssumeCapacity( |
| | 1612 | unit.debug_info_ni.unwrap().?.addFloatingChild(gpa, &elf.mf, .{ |
| | 1613 | .enable_next_moved = true, |
| | 1614 | }) catch |err| switch (err) { |
| | 1615 | else => |e| return e, |
| | 1616 | error.MappedFileIo => return comp.link_diags.fail("failed to write output file: {t}", .{ |
| | 1617 | elf.mf.io_err.?, |
| | 1618 | }), |
| | 1619 | }, |
| | 1620 | .{ .decl_debug_info = di }, |
| | 1621 | ); |
| | 1622 | decl_gop.value_ptr.debug_info_ni = .wrap(debug_info_ni); |
| | 1623 | return debug_info_ni; |
| | 1624 | } |
| | 1625 | pub fn getDeclIfExists(dwarf: *Dwarf, inst: InternPool.TrackedInst.Index) ?Decl.Index { |
| | 1626 | return @fromBackingInt(@intCast(dwarf.decls.getIndex(inst) orelse return null)); |
| | 1627 | } |
| | 1628 | |
| 1575 | pub fn unitLengthSize(dwarf: *Dwarf) usize { | 1629 | pub fn unitLengthSize(dwarf: *Dwarf) usize { |
| 1576 | return switch (dwarf.format) { | 1630 | return switch (dwarf.format) { |
| 1577 | .@"32" => 4, | 1631 | .@"32" => 4, |
| ... | @@ -1976,33 +2030,33 @@ pub fn updateComptimeNav( | ... | @@ -1976,33 +2030,33 @@ pub fn updateComptimeNav( |
| 1976 | .unnamed_test, .@"test", .decltest => return, | 2030 | .unnamed_test, .@"test", .decltest => return, |
| 1977 | .@"comptime", .@"const", .@"var" => {}, | 2031 | .@"comptime", .@"const", .@"var" => {}, |
| 1978 | } | 2032 | } |
| 1979 | emit: switch (ip.indexToKey(nav_val.toIntern())) { | 2033 | done: switch (ip.indexToKey(nav_val.toIntern())) { |
| 1980 | .struct_type => { | 2034 | .struct_type => { |
| 1981 | const loaded_struct = ip.loadStructType(nav_val.toIntern()); | 2035 | const loaded_struct = ip.loadStructType(nav_val.toIntern()); |
| 1982 | if (nav_index.toOptional() == loaded_struct.name_nav) { | 2036 | if (nav_index.toOptional() == loaded_struct.name_nav) { |
| 1983 | _ = try dwarf.const_pool.get(pt, .{ .elf2 = dwarf.lf.cast(.elf2).? }, nav_val.toIntern()); | 2037 | _ = try dwarf.const_pool.get(pt, .{ .elf2 = dwarf.lf.cast(.elf2).? }, nav_val.toIntern()); |
| 1984 | break :emit; | 2038 | break :done; |
| 1985 | } | 2039 | } |
| 1986 | }, | 2040 | }, |
| 1987 | .enum_type => { | 2041 | .enum_type => { |
| 1988 | const loaded_enum = ip.loadEnumType(nav_val.toIntern()); | 2042 | const loaded_enum = ip.loadEnumType(nav_val.toIntern()); |
| 1989 | if (nav_index.toOptional() == loaded_enum.name_nav) { | 2043 | if (nav_index.toOptional() == loaded_enum.name_nav) { |
| 1990 | _ = try dwarf.const_pool.get(pt, .{ .elf2 = dwarf.lf.cast(.elf2).? }, nav_val.toIntern()); | 2044 | _ = try dwarf.const_pool.get(pt, .{ .elf2 = dwarf.lf.cast(.elf2).? }, nav_val.toIntern()); |
| 1991 | break :emit; | 2045 | break :done; |
| 1992 | } | 2046 | } |
| 1993 | }, | 2047 | }, |
| 1994 | .union_type => { | 2048 | .union_type => { |
| 1995 | const loaded_union = ip.loadUnionType(nav_val.toIntern()); | 2049 | const loaded_union = ip.loadUnionType(nav_val.toIntern()); |
| 1996 | if (nav_index.toOptional() == loaded_union.name_nav) { | 2050 | if (nav_index.toOptional() == loaded_union.name_nav) { |
| 1997 | _ = try dwarf.const_pool.get(pt, .{ .elf2 = dwarf.lf.cast(.elf2).? }, nav_val.toIntern()); | 2051 | _ = try dwarf.const_pool.get(pt, .{ .elf2 = dwarf.lf.cast(.elf2).? }, nav_val.toIntern()); |
| 1998 | break :emit; | 2052 | break :done; |
| 1999 | } | 2053 | } |
| 2000 | }, | 2054 | }, |
| 2001 | .opaque_type => { | 2055 | .opaque_type => { |
| 2002 | const loaded_opaque = ip.loadOpaqueType(nav_val.toIntern()); | 2056 | const loaded_opaque = ip.loadOpaqueType(nav_val.toIntern()); |
| 2003 | if (nav_index.toOptional() == loaded_opaque.name_nav) { | 2057 | if (nav_index.toOptional() == loaded_opaque.name_nav) { |
| 2004 | _ = try dwarf.const_pool.get(pt, .{ .elf2 = dwarf.lf.cast(.elf2).? }, nav_val.toIntern()); | 2058 | _ = try dwarf.const_pool.get(pt, .{ .elf2 = dwarf.lf.cast(.elf2).? }, nav_val.toIntern()); |
| 2005 | break :emit; | 2059 | break :done; |
| 2006 | } | 2060 | } |
| 2007 | }, | 2061 | }, |
| 2008 | .func => |func| if (func.owner_nav == nav_index and func.generic_owner == .none) { | 2062 | .func => |func| if (func.owner_nav == nav_index and func.generic_owner == .none) { |
| ... | @@ -2012,12 +2066,11 @@ pub fn updateComptimeNav( | ... | @@ -2012,12 +2066,11 @@ pub fn updateComptimeNav( |
| 2012 | var di_nw: MappedFile.Node.Writer = undefined; | 2066 | var di_nw: MappedFile.Node.Writer = undefined; |
| 2013 | f.debug_info_ni.unwrap().?.writer(zcu.gpa, &dwarf.lf.cast(.elf2).?.mf, &di_nw); | 2067 | f.debug_info_ni.unwrap().?.writer(zcu.gpa, &dwarf.lf.cast(.elf2).?.mf, &di_nw); |
| 2014 | defer di_nw.deinit(); | 2068 | defer di_nw.deinit(); |
| 2015 | const parent_cpi = try dwarf.getConst(pt, .fromInterned(zcu.fileRootType(inst_info.file))); | | |
| 2016 | dwarf.genDeclFuncGeneric( | 2069 | dwarf.genDeclFuncGeneric( |
| 2017 | pt, | 2070 | pt, |
| 2018 | &di_nw, | 2071 | &di_nw, |
| 2019 | zir, | 2072 | zir, |
| 2020 | parent_cpi, | 2073 | .fromInterned(ip.namespacePtr(nav.analysis.?.namespace).owner_type), |
| 2021 | &decl, | 2074 | &decl, |
| 2022 | &ip.indexToKey(func.ty).func_type, | 2075 | &ip.indexToKey(func.ty).func_type, |
| 2023 | nav.name.toSlice(ip), | 2076 | nav.name.toSlice(ip), |
| ... | @@ -2040,7 +2093,7 @@ fn genDeclFuncGeneric( | ... | @@ -2040,7 +2093,7 @@ fn genDeclFuncGeneric( |
| 2040 | pt: Zcu.PerThread, | 2093 | pt: Zcu.PerThread, |
| 2041 | di_nw: *MappedFile.Node.Writer, | 2094 | di_nw: *MappedFile.Node.Writer, |
| 2042 | zir: *const std.zig.Zir, | 2095 | zir: *const std.zig.Zir, |
| 2043 | parent_cpi: link.ConstPool.Index, | 2096 | parent_ty: Type, |
| 2044 | decl: *const std.zig.Zir.Inst.Declaration.Unwrapped, | 2097 | decl: *const std.zig.Zir.Inst.Declaration.Unwrapped, |
| 2045 | fn_ty: *const InternPool.Key.FuncType, | 2098 | fn_ty: *const InternPool.Key.FuncType, |
| 2046 | name: []const u8, | 2099 | name: []const u8, |
| ... | @@ -2048,7 +2101,7 @@ fn genDeclFuncGeneric( | ... | @@ -2048,7 +2101,7 @@ fn genDeclFuncGeneric( |
| 2048 | ) link.EmitError!void { | 2101 | ) link.EmitError!void { |
| 2049 | const diw = &di_nw.interface; | 2102 | const diw = &di_nw.interface; |
| 2050 | try diw.writeUleb128(try dwarf.refAbbrevCode(.decl_func_generic)); | 2103 | try diw.writeUleb128(try dwarf.refAbbrevCode(.decl_func_generic)); |
| 2051 | try dwarf.sectionOffset(di_nw, Const.get(parent_cpi, dwarf).debug_info_ni.unwrap().?, 0); | 2104 | try dwarf.refConst(pt, di_nw, parent_ty.toValue()); |
| 2052 | try diw.writeInt(u32, decl.src_line + 1, dwarf.endian); | 2105 | try diw.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| 2053 | try diw.writeUleb128(decl.src_column + 1); | 2106 | try diw.writeUleb128(decl.src_column + 1); |
| 2054 | try diw.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); | 2107 | try diw.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); |
| ... | @@ -2062,10 +2115,7 @@ fn genDeclFuncGeneric( | ... | @@ -2062,10 +2115,7 @@ fn genDeclFuncGeneric( |
| 2062 | try dwarf.strp(&dwarf.debug_str, di_nw, zir.nullTerminatedString(param_name)); | 2115 | try dwarf.strp(&dwarf.debug_str, di_nw, zir.nullTerminatedString(param_name)); |
| 2063 | }, | 2116 | }, |
| 2064 | } | 2117 | } |
| 2065 | try dwarf.sectionOffset(di_nw, Const.get(try dwarf.getConst( | 2118 | try dwarf.refConst(pt, di_nw, .fromInterned(fn_ty.param_types.get(&pt.zcu.intern_pool)[param_index])); |
| 2066 | pt, | | |
| 2067 | .fromInterned(fn_ty.param_types.get(&pt.zcu.intern_pool)[param_index]), | | |
| 2068 | ), dwarf).debug_info_ni.unwrap().?, 0); | | |
| 2069 | param_index += 1; | 2119 | param_index += 1; |
| 2070 | } | 2120 | } |
| 2071 | if (fn_ty.is_var_args) try diw.writeUleb128(try dwarf.refAbbrevCode(.is_var_args)); | 2121 | if (fn_ty.is_var_args) try diw.writeUleb128(try dwarf.refAbbrevCode(.is_var_args)); |
| ... | @@ -2079,16 +2129,14 @@ pub fn addConst( | ... | @@ -2079,16 +2129,14 @@ pub fn addConst( |
| 2079 | val: InternPool.Index, | 2129 | val: InternPool.Index, |
| 2080 | addConstNode: *const fn ( | 2130 | addConstNode: *const fn ( |
| 2081 | lf: *link.File, | 2131 | lf: *link.File, |
| 2082 | ui: Dwarf.Unit.Index, | 2132 | ui: Unit.Index, |
| 2083 | cpi: link.ConstPool.Index, | 2133 | cpi: link.ConstPool.Index, |
| 2084 | ) link.Error!MappedFile.Node.Index, | 2134 | ) link.Error!MappedFile.Node.Index, |
| 2085 | ) link.Error!void { | 2135 | ) link.Error!void { |
| 2086 | const comp = dwarf.lf.comp; | 2136 | const zcu = dwarf.lf.comp.zcu.?; |
| 2087 | const zcu = comp.zcu.?; | | |
| 2088 | const ip = &zcu.intern_pool; | 2137 | const ip = &zcu.intern_pool; |
| 2089 | | | |
| 2090 | assert(@backingInt(cpi) == dwarf.consts.items.len); | 2138 | assert(@backingInt(cpi) == dwarf.consts.items.len); |
| 2091 | try dwarf.consts.append(comp.gpa, .{ | 2139 | dwarf.consts.appendAssumeCapacity(.{ |
| 2092 | .debug_info_ni = debug_info_ni: switch (ip.indexToKey(val)) { | 2140 | .debug_info_ni = debug_info_ni: switch (ip.indexToKey(val)) { |
| 2093 | else => try addConstNode(dwarf.lf, dwarf.getUnit(zcu.root_mod), cpi), | 2141 | else => try addConstNode(dwarf.lf, dwarf.getUnit(zcu.root_mod), cpi), |
| 2094 | .func => |func| { | 2142 | .func => |func| { |
| ... | @@ -2144,112 +2192,73 @@ fn updateConstInner( | ... | @@ -2144,112 +2192,73 @@ fn updateConstInner( |
| 2144 | const diw = &di_nw.interface; | 2192 | const diw = &di_nw.interface; |
| 2145 | switch (ip.indexToKey(val)) { | 2193 | switch (ip.indexToKey(val)) { |
| 2146 | else => return, | 2194 | else => return, |
| 2147 | .struct_type => { | 2195 | .int_type => |int_type| { |
| 2148 | const loaded_struct = ip.loadStructType(val); | | |
| 2149 | const ty: Type = .fromInterned(val); | 2196 | const ty: Type = .fromInterned(val); |
| 2150 | const file = loaded_struct.zir_index.resolveFile(ip); | 2197 | try diw.writeUleb128(try dwarf.refAbbrevCode(.numeric_type)); |
| 2151 | switch (loaded_struct.layout) { | 2198 | var name_buf: [std.fmt.count("i{d}", .{std.math.maxInt(u16)})]u8 = undefined; |
| 2152 | .auto, .@"extern" => { | 2199 | try dwarf.strp(&dwarf.debug_str, di_nw, std.mem.print(&name_buf, "{f}", .{ty.fmt(pt)}) catch unreachable); |
| 2153 | const struct_is_file: bool = if (loaded_struct.zir_index.resolve(ip)) |inst| | 2200 | try diw.writeByte(switch (int_type.signedness) { |
| 2154 | inst == .main_struct_inst | 2201 | .signed => DW.ATE.signed, |
| 2155 | else | 2202 | .unsigned => DW.ATE.unsigned, |
| 2156 | false; | 2203 | }); |
| 2157 | if (loaded_struct.name_nav.unwrap()) |nav_index| { | 2204 | try diw.writeUleb128(int_type.bits); |
| 2158 | assert(!struct_is_file); | 2205 | try diw.writeUleb128(ty.abiSize(zcu)); |
| 2159 | const nav = ip.getNav(nav_index); | 2206 | try diw.writeUleb128(ty.abiAlignment(zcu).toByteUnits().?); |
| 2160 | const decl_inst = nav.srcInst(ip).resolve(ip).?; | 2207 | }, |
| 2161 | const decl = zcu.fileByIndex(file).zir.?.getDeclaration(decl_inst); | 2208 | .ptr_type => |ptr_type| switch (ptr_type.flags.size) { |
| 2162 | try diw.writeUleb128(try dwarf.refAbbrevCode( | 2209 | .one, .many, .c => { |
| 2163 | if (loaded_struct.field_types.len == 0) .decl_namespace_struct else .decl_struct, | 2210 | const ty: Type = .fromInterned(val); |
| 2164 | )); | 2211 | const ptr_child_ty: Type = .fromInterned(ptr_type.child); |
| 2165 | try dwarf.sectionOffset(di_nw, Const.get( | 2212 | try diw.writeUleb128(try dwarf.refAbbrevCode(switch (ptr_type.flags.alignment) { |
| 2166 | try dwarf.getConst(pt, .fromInterned(zcu.fileRootType(file))), | 2213 | .none => if (ptr_type.sentinel == .none) .ptr_type else .ptr_sentinel_type, |
| 2167 | dwarf, | 2214 | else => if (ptr_type.sentinel == .none) .ptr_aligned_type else .ptr_aligned_sentinel_type, |
| 2168 | ).debug_info_ni.unwrap().?, 0); | 2215 | })); |
| 2169 | try diw.writeInt(u32, decl.src_line + 1, dwarf.endian); | 2216 | { |
| 2170 | try diw.writeUleb128(decl.src_column + 1); | 2217 | const name = try zcu.gpa.print("{f}", .{ty.fmt(pt)}); |
| 2171 | try diw.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); | 2218 | defer zcu.gpa.free(name); |
| 2172 | try dwarf.strp(&dwarf.debug_str, di_nw, nav.name.toSlice(ip)); | 2219 | try dwarf.strp(&dwarf.debug_str, di_nw, name); |
| 2173 | } else { | 2220 | } |
| 2174 | const zfi = loaded_struct.zir_index.resolveFile(ip); | 2221 | if (ptr_type.sentinel != .none) try dwarf.blockConst(pt, di_nw, .fromInterned(ptr_type.sentinel)); |
| 2175 | const ui = dwarf.getUnit(zcu.fileByIndex(zfi).mod.?); | 2222 | if (ptr_type.flags.alignment.toByteUnits()) |a| try diw.writeUleb128(a); |
| 2176 | _, const fi = try ui.get(dwarf).getFile(zcu.gpa, ui, zfi); | 2223 | try diw.writeByte(@backingInt(ptr_type.flags.address_space)); |
| 2177 | try diw.writeUleb128(try dwarf.refAbbrevCode(switch (loaded_struct.field_types.len) { | 2224 | if (ptr_type.flags.is_const or ptr_type.flags.is_volatile) try dwarf.sectionOffset( |
| 2178 | 0 => if (struct_is_file) .empty_file else .empty_struct_type, | 2225 | di_nw, |
| 2179 | else => if (struct_is_file) .file else .struct_type, | 2226 | di_nw.ni, |
| 2180 | })); | 2227 | diw.end + dwarf.sectionOffsetSize(), |
| 2181 | try diw.writeUleb128(@backingInt(fi)); | 2228 | ); |
| 2182 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_struct.name.toSlice(ip)); | 2229 | if (ptr_type.flags.is_const) { |
| 2183 | } | 2230 | try diw.writeUleb128(try dwarf.refAbbrevCode(.is_const)); |
| 2184 | if (loaded_struct.field_types.len == 0) { | 2231 | if (ptr_type.flags.is_volatile) try dwarf.sectionOffset( |
| 2185 | if (!struct_is_file) try diw.writeByte(@intFromBool(false)); | 2232 | di_nw, |
| 2186 | } else { | 2233 | di_nw.ni, |
| 2187 | try diw.writeUleb128(ty.abiSize(zcu)); | 2234 | diw.end + dwarf.sectionOffsetSize(), |
| 2188 | try diw.writeUleb128(ty.abiAlignment(zcu).toByteUnits().?); | 2235 | ); |
| 2189 | for (0..loaded_struct.field_types.len) |field_index| { | 2236 | } |
| 2190 | const is_comptime = loaded_struct.field_is_comptime_bits.get(ip, field_index); | 2237 | if (ptr_type.flags.is_volatile) try diw.writeUleb128(try dwarf.refAbbrevCode(.is_volatile)); |
| 2191 | // TODO: we currently don't emit information about default values for | 2238 | try dwarf.refConst(pt, di_nw, ptr_child_ty.toValue()); |
| 2192 | // non-`comptime` fields, because these default values are resolved at a | 2239 | }, |
| 2193 | // separate time in the compiler frontend. To emit this information, the | 2240 | .slice => { |
| 2194 | // frontend needs to tell us when the default values are available: like | 2241 | const ty: Type = .fromInterned(val); |
| 2195 | // how `Zcu.PerThread.ensureTypeLayoutUpToDate` enqueues a link task to | 2242 | try diw.writeUleb128(try dwarf.refAbbrevCode(.generated_struct_type)); |
| 2196 | // indicate completion of the type's layout, a task should be enqueued | 2243 | { |
| 2197 | // by `Zcu.PerThread.ensureStructDefaultsUpToDate`, and upon receiving | 2244 | const name = try zcu.gpa.print("{f}", .{ty.fmt(pt)}); |
| 2198 | // it we should patch the correct default field values in. | 2245 | defer zcu.gpa.free(name); |
| 2199 | const field_init: InternPool.Index = if (is_comptime) loaded_struct.field_defaults.getOrNone(ip, field_index) else .none; | 2246 | try dwarf.strp(&dwarf.debug_str, di_nw, name); |
| 2200 | assert(!(is_comptime and field_init == .none)); | 2247 | } |
| 2201 | const field_type: Type = .fromInterned(loaded_struct.field_types.get(ip)[field_index]); | 2248 | try diw.writeUleb128(ty.abiSize(zcu)); |
| 2202 | const has_runtime_bits, const has_comptime_state = switch (field_init) { | 2249 | try diw.writeUleb128(ty.abiAlignment(zcu).toByteUnits().?); |
| 2203 | .none => .{ false, false }, | 2250 | try diw.writeUleb128(try dwarf.refAbbrevCode(.generated_field)); |
| 2204 | else => .{ | 2251 | try dwarf.strp(&dwarf.debug_str, di_nw, "ptr"); |
| 2205 | field_type.hasRuntimeBits(zcu), | 2252 | const ptr_field_ty = ty.slicePtrFieldType(zcu); |
| 2206 | field_type.comptimeOnly(zcu), | 2253 | try dwarf.refConst(pt, di_nw, ptr_field_ty.toValue()); |
| 2207 | }, | 2254 | try diw.writeUleb128(0); |
| 2208 | }; | 2255 | try diw.writeUleb128(try dwarf.refAbbrevCode(.generated_field)); |
| 2209 | try diw.writeUleb128(try dwarf.refAbbrevCode(if (is_comptime) | 2256 | try dwarf.strp(&dwarf.debug_str, di_nw, "len"); |
| 2210 | if (has_comptime_state) | 2257 | const len_field_ty: Type = .usize; |
| 2211 | .field_comptime_comptime_state | 2258 | try dwarf.refConst(pt, di_nw, len_field_ty.toValue()); |
| 2212 | else if (has_runtime_bits) | 2259 | try diw.writeUleb128(len_field_ty.abiAlignment(zcu).forward(ptr_field_ty.abiSize(zcu))); |
| 2213 | .field_comptime_runtime_bits | 2260 | try diw.writeUleb128(@backingInt(AbbrevCode.null)); |
| 2214 | else | 2261 | }, |
| 2215 | .field_comptime | | |
| 2216 | else if (field_init != .none) | | |
| 2217 | if (has_comptime_state) | | |
| 2218 | .field_default_comptime_state | | |
| 2219 | else if (has_runtime_bits) | | |
| 2220 | .field_default_runtime_bits | | |
| 2221 | else | | |
| 2222 | .field | | |
| 2223 | else | | |
| 2224 | .field)); | | |
| 2225 | try dwarf.strp( | | |
| 2226 | &dwarf.debug_str, | | |
| 2227 | di_nw, | | |
| 2228 | loaded_struct.field_names.get(ip)[field_index].toSlice(ip), | | |
| 2229 | ); | | |
| 2230 | try dwarf.sectionOffset(di_nw, Const.get( | | |
| 2231 | try dwarf.getConst(pt, field_type.toValue()), | | |
| 2232 | dwarf, | | |
| 2233 | ).debug_info_ni.unwrap().?, 0); | | |
| 2234 | if (!is_comptime) { | | |
| 2235 | try diw.writeUleb128(loaded_struct.field_offsets.get(ip)[field_index]); | | |
| 2236 | try diw.writeUleb128(loaded_struct.field_aligns.getOrNone(ip, field_index).toByteUnits() orelse | | |
| 2237 | field_type.abiAlignment(zcu).toByteUnits().?); | | |
| 2238 | } | | |
| 2239 | if (has_comptime_state) | | |
| 2240 | try dwarf.sectionOffset(di_nw, Const.get( | | |
| 2241 | try dwarf.getConst(pt, .fromInterned(field_init)), | | |
| 2242 | dwarf, | | |
| 2243 | ).debug_info_ni.unwrap().?, 0) | | |
| 2244 | else if (has_runtime_bits) | | |
| 2245 | //try wip_nav.blockValue(.fromInterned(field_init)); | | |
| 2246 | try diw.writeUleb128(0); | | |
| 2247 | } | | |
| 2248 | try diw.writeUleb128(@backingInt(AbbrevCode.null)); | | |
| 2249 | } | | |
| 2250 | }, | | |
| 2251 | .@"packed" => return, | | |
| 2252 | } | | |
| 2253 | }, | 2262 | }, |
| 2254 | .simple_type => |simple_type| switch (simple_type) { | 2263 | .simple_type => |simple_type| switch (simple_type) { |
| 2255 | .f16, | 2264 | .f16, |
| ... | @@ -2298,21 +2307,138 @@ fn updateConstInner( | ... | @@ -2298,21 +2307,138 @@ fn updateConstInner( |
| 2298 | .comptime_int, | 2307 | .comptime_int, |
| 2299 | .comptime_float, | 2308 | .comptime_float, |
| 2300 | .noreturn, | 2309 | .noreturn, |
| | 2310 | .null, |
| | 2311 | .undefined, |
| | 2312 | .enum_literal, |
| 2301 | => { | 2313 | => { |
| | 2314 | const ty: Type = .fromInterned(val); |
| 2302 | try diw.writeUleb128(try dwarf.refAbbrevCode(.void_type)); | 2315 | try diw.writeUleb128(try dwarf.refAbbrevCode(.void_type)); |
| 2303 | try dwarf.strp(&dwarf.debug_str, di_nw, @tagName(simple_type)); | 2316 | var name_buf: ["@TypeOf(undefined)".len]u8 = undefined; |
| 2304 | }, | 2317 | try dwarf.strp(&dwarf.debug_str, di_nw, std.mem.print(&name_buf, "{f}", .{ty.fmt(pt)}) catch unreachable); |
| 2305 | inline .null, .undefined => |tag| { | | |
| 2306 | try diw.writeUleb128(try dwarf.refAbbrevCode(.void_type)); | | |
| 2307 | try dwarf.strp(&dwarf.debug_str, di_nw, "@TypeOf(" ++ @tagName(tag) ++ ")"); | | |
| 2308 | }, | | |
| 2309 | .enum_literal => { | | |
| 2310 | try diw.writeUleb128(try dwarf.refAbbrevCode(.void_type)); | | |
| 2311 | try dwarf.strp(&dwarf.debug_str, di_nw, "@EnumLiteral()"); | | |
| 2312 | }, | 2318 | }, |
| 2313 | .anyerror => return, | 2319 | .anyerror => return, |
| 2314 | .adhoc_inferred_error_set => unreachable, | 2320 | .adhoc_inferred_error_set => unreachable, |
| 2315 | }, | 2321 | }, |
| | 2322 | .struct_type => { |
| | 2323 | const loaded_struct = ip.loadStructType(val); |
| | 2324 | const zfi = loaded_struct.zir_index.resolveFile(ip); |
| | 2325 | const zf = zcu.fileByIndex(zfi); |
| | 2326 | switch (loaded_struct.layout) { |
| | 2327 | .auto, .@"extern" => { |
| | 2328 | const struct_is_file = loaded_struct.zir_index.resolve(ip) == .main_struct_inst; |
| | 2329 | if (loaded_struct.name_nav.unwrap()) |name_ni| { |
| | 2330 | assert(!struct_is_file); |
| | 2331 | const name_nav = ip.getNav(name_ni); |
| | 2332 | const decl = zf.zir.?.getDeclaration(name_nav.srcInst(ip).resolve(ip).?); |
| | 2333 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( |
| | 2334 | name_nav.analysis.?.namespace, |
| | 2335 | ).owner_type); |
| | 2336 | try diw.writeUleb128(try dwarf.refAbbrevCode( |
| | 2337 | if (loaded_struct.field_types.len > 0) .decl_struct else .decl_namespace_struct, |
| | 2338 | )); |
| | 2339 | try dwarf.sectionOffset(di_nw, parent_ni, 0); |
| | 2340 | try diw.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| | 2341 | try diw.writeUleb128(decl.src_column + 1); |
| | 2342 | try diw.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); |
| | 2343 | try dwarf.strp(&dwarf.debug_str, di_nw, name_nav.name.toSlice(ip)); |
| | 2344 | } else { |
| | 2345 | const ui = dwarf.getUnit(zf.mod.?); |
| | 2346 | _, const fi = try ui.get(dwarf).getFile(zcu.gpa, ui, zfi); |
| | 2347 | try diw.writeUleb128(try dwarf.refAbbrevCode(switch (loaded_struct.field_types.len) { |
| | 2348 | 0 => if (struct_is_file) .empty_file else .empty_struct_type, |
| | 2349 | else => if (struct_is_file) .file else .struct_type, |
| | 2350 | })); |
| | 2351 | try diw.writeUleb128(@backingInt(fi)); |
| | 2352 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_struct.name.toSlice(ip)); |
| | 2353 | } |
| | 2354 | if (loaded_struct.field_types.len > 0) { |
| | 2355 | const ty: Type = .fromInterned(val); |
| | 2356 | try diw.writeUleb128(ty.abiSize(zcu)); |
| | 2357 | try diw.writeUleb128(ty.abiAlignment(zcu).toByteUnits().?); |
| | 2358 | for (0..loaded_struct.field_types.len) |field_index| { |
| | 2359 | const is_comptime = loaded_struct.field_is_comptime_bits.get(ip, field_index); |
| | 2360 | // TODO: we currently don't emit information about default values for |
| | 2361 | // non-`comptime` fields, because these default values are resolved at a |
| | 2362 | // separate time in the compiler frontend. To emit this information, the |
| | 2363 | // frontend needs to tell us when the default values are available: like |
| | 2364 | // how `Zcu.PerThread.ensureTypeLayoutUpToDate` enqueues a link task to |
| | 2365 | // indicate completion of the type's layout, a task should be enqueued |
| | 2366 | // by `Zcu.PerThread.ensureStructDefaultsUpToDate`, and upon receiving |
| | 2367 | // it we should patch the correct default field values in. |
| | 2368 | const field_default: InternPool.Index = |
| | 2369 | if (is_comptime) loaded_struct.field_defaults.getOrNone(ip, field_index) else .none; |
| | 2370 | assert(!(is_comptime and field_default == .none)); |
| | 2371 | const field_ty: Type = .fromInterned(loaded_struct.field_types.get(ip)[field_index]); |
| | 2372 | const field_default_class = switch (field_default) { |
| | 2373 | .none => .no_possible_value, |
| | 2374 | else => field_ty.classify(zcu), |
| | 2375 | }; |
| | 2376 | try diw.writeUleb128(try dwarf.refAbbrevCode(switch (field_default_class) { |
| | 2377 | .no_possible_value, .one_possible_value => if (is_comptime) .field_comptime else .field, |
| | 2378 | .runtime => if (is_comptime) .field_comptime_fully_runtime else .field_default_fully_runtime, |
| | 2379 | .partially_comptime => if (is_comptime) .field_comptime_partially_comptime else .field_default_partially_comptime, |
| | 2380 | .fully_comptime => if (is_comptime) .field_comptime_fully_comptime else .field_default_fully_comptime, |
| | 2381 | })); |
| | 2382 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_struct.field_names.get(ip)[field_index].toSlice(ip)); |
| | 2383 | try dwarf.refConst(pt, di_nw, field_ty.toValue()); |
| | 2384 | if (!is_comptime) { |
| | 2385 | try diw.writeUleb128(loaded_struct.field_offsets.get(ip)[field_index]); |
| | 2386 | try diw.writeUleb128(loaded_struct.field_aligns.getOrNone(ip, field_index).toByteUnits() orelse |
| | 2387 | field_ty.abiAlignment(zcu).toByteUnits().?); |
| | 2388 | } |
| | 2389 | if (field_default_class.hasRuntimeBits()) try dwarf.blockConst(pt, di_nw, .fromInterned(field_default)); |
| | 2390 | if (field_default_class.comptimeOnly()) try dwarf.refConst(pt, di_nw, .fromInterned(field_default)); |
| | 2391 | } |
| | 2392 | try diw.writeUleb128(@backingInt(AbbrevCode.null)); |
| | 2393 | } else try diw.writeByte(@intFromBool(false)); |
| | 2394 | }, |
| | 2395 | .@"packed" => return, |
| | 2396 | } |
| | 2397 | }, |
| | 2398 | .enum_type => { |
| | 2399 | const loaded_enum = ip.loadEnumType(val); |
| | 2400 | if (loaded_enum.zir_index.unwrap()) |zir_index| { |
| | 2401 | assert(loaded_enum.owner_union == .none); |
| | 2402 | const zfi = zir_index.resolveFile(ip); |
| | 2403 | const zf = zcu.fileByIndex(zfi); |
| | 2404 | if (loaded_enum.name_nav.unwrap()) |name_ni| { |
| | 2405 | const name_nav = ip.getNav(name_ni); |
| | 2406 | const decl = zf.zir.?.getDeclaration(name_nav.srcInst(ip).resolve(ip).?); |
| | 2407 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( |
| | 2408 | name_nav.analysis.?.namespace, |
| | 2409 | ).owner_type); |
| | 2410 | try diw.writeUleb128(try dwarf.refAbbrevCode( |
| | 2411 | if (loaded_enum.field_names.len > 0) .decl_enum else .decl_empty_enum, |
| | 2412 | )); |
| | 2413 | try dwarf.sectionOffset(di_nw, parent_ni, 0); |
| | 2414 | try diw.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| | 2415 | try diw.writeUleb128(decl.src_column + 1); |
| | 2416 | try diw.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); |
| | 2417 | try dwarf.strp(&dwarf.debug_str, di_nw, name_nav.name.toSlice(ip)); |
| | 2418 | } else { |
| | 2419 | const ui = dwarf.getUnit(zf.mod.?); |
| | 2420 | _, const fi = try ui.get(dwarf).getFile(zcu.gpa, ui, zfi); |
| | 2421 | try diw.writeUleb128(try dwarf.refAbbrevCode( |
| | 2422 | if (loaded_enum.field_names.len > 0) .enum_type else .empty_enum_type, |
| | 2423 | )); |
| | 2424 | try diw.writeUleb128(@backingInt(fi)); |
| | 2425 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_enum.name.toSlice(ip)); |
| | 2426 | } |
| | 2427 | } else { |
| | 2428 | assert(loaded_enum.owner_union != .none); |
| | 2429 | try diw.writeUleb128(try dwarf.refAbbrevCode( |
| | 2430 | if (loaded_enum.field_names.len == 0) .generated_empty_enum_type else .generated_enum_type, |
| | 2431 | )); |
| | 2432 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_enum.name.toSlice(ip)); |
| | 2433 | } |
| | 2434 | try dwarf.refConst(pt, di_nw, .fromInterned(loaded_enum.int_tag_type)); |
| | 2435 | for (0..loaded_enum.field_names.len) |field_index| { |
| | 2436 | try diw.writeUleb128(try dwarf.refAbbrevCode(.enum_field)); |
| | 2437 | try dwarf.enumConstValue(diw, loaded_enum, field_index); |
| | 2438 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_enum.field_names.get(ip)[field_index].toSlice(ip)); |
| | 2439 | } |
| | 2440 | if (loaded_enum.field_names.len > 0) try diw.writeUleb128(@backingInt(AbbrevCode.null)); |
| | 2441 | }, |
| 2316 | } | 2442 | } |
| 2317 | try dwarf.genDebugInfoPadding(diw, diw.unusedCapacityLen()); | 2443 | try dwarf.genDebugInfoPadding(diw, diw.unusedCapacityLen()); |
| 2318 | } | 2444 | } |
| ... | @@ -2339,45 +2465,90 @@ fn updateConstIncompleteInner( | ... | @@ -2339,45 +2465,90 @@ fn updateConstIncompleteInner( |
| 2339 | const ip = &zcu.intern_pool; | 2465 | const ip = &zcu.intern_pool; |
| 2340 | const diw = &di_nw.interface; | 2466 | const diw = &di_nw.interface; |
| 2341 | done: { | 2467 | done: { |
| 2342 | const zir_index, const name, const maybe_name_nav = container: switch (ip.indexToKey(val)) { | 2468 | const src_inst, const zf, const capture_names, const captures, const name, const maybe_name_nav, const namespace = container: switch (ip.indexToKey(val)) { |
| 2343 | .struct_type => { | 2469 | .struct_type => { |
| 2344 | const loaded_struct = ip.loadStructType(val); | 2470 | const loaded_struct = ip.loadStructType(val); |
| 2345 | if (loaded_struct.zir_index.resolveFull(ip)) |src_inst| switch (src_inst.inst) { | 2471 | const src_inst = loaded_struct.zir_index.resolveFull(ip) orelse { |
| | 2472 | try diw.writeUleb128(try dwarf.refAbbrevCode(.decl_lost)); |
| | 2473 | break :done; |
| | 2474 | }; |
| | 2475 | const zf = zcu.fileByIndex(src_inst.file); |
| | 2476 | switch (src_inst.inst) { |
| 2346 | .main_struct_inst => { | 2477 | .main_struct_inst => { |
| 2347 | const ui = dwarf.getUnit(zcu.fileByIndex(src_inst.file).mod.?); | 2478 | const ui = dwarf.getUnit(zf.mod.?); |
| 2348 | _, const fi = try ui.get(dwarf).getFile(zcu.gpa, ui, src_inst.file); | 2479 | _, const fi = try ui.get(dwarf).getFile(zcu.gpa, ui, src_inst.file); |
| 2349 | try diw.writeUleb128(try dwarf.refAbbrevCode(.empty_file)); | 2480 | try diw.writeUleb128(try dwarf.refAbbrevCode(.empty_file)); |
| 2350 | try diw.writeUleb128(@backingInt(fi)); | 2481 | try diw.writeUleb128(@backingInt(fi)); |
| 2351 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_struct.name.toSlice(ip)); | 2482 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_struct.name.toSlice(ip)); |
| | 2483 | try diw.writeByte(@intFromBool(true)); |
| 2352 | break :done; | 2484 | break :done; |
| 2353 | }, | 2485 | }, |
| 2354 | else => {}, | 2486 | else => break :container .{ |
| 2355 | }; | 2487 | src_inst, |
| 2356 | break :container .{ | 2488 | zf, |
| 2357 | loaded_struct.zir_index, | 2489 | zf.zir.?.getStructDecl(src_inst.inst).capture_names, |
| 2358 | loaded_struct.name, | 2490 | loaded_struct.captures, |
| 2359 | loaded_struct.name_nav, | 2491 | loaded_struct.name, |
| 2360 | }; | 2492 | loaded_struct.name_nav, |
| | 2493 | loaded_struct.namespace, |
| | 2494 | }, |
| | 2495 | } |
| 2361 | }, | 2496 | }, |
| 2362 | .union_type => { | 2497 | .union_type => { |
| 2363 | const loaded_union = ip.loadUnionType(val); | 2498 | const loaded_union = ip.loadUnionType(val); |
| 2364 | break :container .{ loaded_union.zir_index, loaded_union.name, loaded_union.name_nav }; | 2499 | const src_inst = loaded_union.zir_index.resolveFull(ip) orelse { |
| | 2500 | try diw.writeUleb128(try dwarf.refAbbrevCode(.decl_lost)); |
| | 2501 | break :done; |
| | 2502 | }; |
| | 2503 | const zf = zcu.fileByIndex(src_inst.file); |
| | 2504 | break :container .{ |
| | 2505 | src_inst, |
| | 2506 | zf, |
| | 2507 | zf.zir.?.getUnionDecl(src_inst.inst).capture_names, |
| | 2508 | loaded_union.captures, |
| | 2509 | loaded_union.name, |
| | 2510 | loaded_union.name_nav, |
| | 2511 | loaded_union.namespace, |
| | 2512 | }; |
| 2365 | }, | 2513 | }, |
| 2366 | .enum_type => { | 2514 | .enum_type => { |
| 2367 | const loaded_enum = ip.loadEnumType(val); | 2515 | const loaded_enum = ip.loadEnumType(val); |
| 2368 | if (loaded_enum.zir_index.unwrap()) |zir_index| | 2516 | const zir_index = loaded_enum.zir_index.unwrap() orelse { |
| 2369 | break :container .{ zir_index, loaded_enum.name, loaded_enum.name_nav }; | 2517 | try diw.writeUleb128(try dwarf.refAbbrevCode(.generated_empty_struct_type)); |
| 2370 | try diw.writeUleb128(try dwarf.refAbbrevCode(.generated_empty_struct_type)); | 2518 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_enum.name.toSlice(ip)); |
| 2371 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_enum.name.toSlice(ip)); | 2519 | try diw.writeByte(@intFromBool(true)); |
| 2372 | try diw.writeByte(@intFromBool(true)); | 2520 | break :done; |
| 2373 | break :done; | 2521 | }; |
| | 2522 | const src_inst = zir_index.resolveFull(ip) orelse { |
| | 2523 | try diw.writeUleb128(try dwarf.refAbbrevCode(.decl_lost)); |
| | 2524 | break :done; |
| | 2525 | }; |
| | 2526 | const zf = zcu.fileByIndex(src_inst.file); |
| | 2527 | break :container .{ |
| | 2528 | src_inst, |
| | 2529 | zf, |
| | 2530 | zf.zir.?.getEnumDecl(src_inst.inst).capture_names, |
| | 2531 | loaded_enum.captures, |
| | 2532 | loaded_enum.name, |
| | 2533 | loaded_enum.name_nav, |
| | 2534 | loaded_enum.namespace, |
| | 2535 | }; |
| 2374 | }, | 2536 | }, |
| 2375 | .opaque_type => { | 2537 | .opaque_type => { |
| 2376 | const loaded_opaque = ip.loadOpaqueType(val); | 2538 | const loaded_opaque = ip.loadOpaqueType(val); |
| | 2539 | const src_inst = loaded_opaque.zir_index.resolveFull(ip) orelse { |
| | 2540 | try diw.writeUleb128(try dwarf.refAbbrevCode(.decl_lost)); |
| | 2541 | break :done; |
| | 2542 | }; |
| | 2543 | const zf = zcu.fileByIndex(src_inst.file); |
| 2377 | break :container .{ | 2544 | break :container .{ |
| 2378 | loaded_opaque.zir_index, | 2545 | src_inst, |
| | 2546 | zf, |
| | 2547 | zf.zir.?.getOpaqueDecl(src_inst.inst).capture_names, |
| | 2548 | loaded_opaque.captures, |
| 2379 | loaded_opaque.name, | 2549 | loaded_opaque.name, |
| 2380 | loaded_opaque.name_nav, | 2550 | loaded_opaque.name_nav, |
| | 2551 | loaded_opaque.namespace, |
| 2381 | }; | 2552 | }; |
| 2382 | }, | 2553 | }, |
| 2383 | else => |val_key| break :done switch (val_key.typeOf()) { | 2554 | else => |val_key| break :done switch (val_key.typeOf()) { |
| ... | @@ -2389,37 +2560,133 @@ fn updateConstIncompleteInner( | ... | @@ -2389,37 +2560,133 @@ fn updateConstIncompleteInner( |
| 2389 | try diw.writeByte(@intFromBool(true)); | 2560 | try diw.writeByte(@intFromBool(true)); |
| 2390 | }, | 2561 | }, |
| 2391 | else => |ty| { | 2562 | else => |ty| { |
| 2392 | const ty_cpi = try dwarf.getConst(pt, Value.fromInterned(ty)); | | |
| 2393 | try diw.writeUleb128(try dwarf.refAbbrevCode(.undefined_comptime_value)); | 2563 | try diw.writeUleb128(try dwarf.refAbbrevCode(.undefined_comptime_value)); |
| 2394 | try dwarf.sectionOffset( | 2564 | try dwarf.refConst(pt, di_nw, .fromInterned(ty)); |
| 2395 | di_nw, | | |
| 2396 | Const.get(ty_cpi, dwarf).debug_info_ni.unwrap().?, | | |
| 2397 | 0, | | |
| 2398 | ); | | |
| 2399 | }, | 2565 | }, |
| 2400 | }, | 2566 | }, |
| 2401 | }; | 2567 | }; |
| 2402 | const src_inst = zir_index.resolveFull(ip) orelse { | 2568 | const capturing = for (captures.get(ip)) |capture| switch (capture.tag) { |
| 2403 | try diw.writeUleb128(try dwarf.refAbbrevCode(.decl_lost)); | 2569 | .@"comptime", .runtime => break true, |
| 2404 | break :done; | 2570 | .nav_val, .nav_ref => {}, |
| 2405 | }; | 2571 | } else false; |
| 2406 | if (maybe_name_nav.unwrap()) |name_nav| { | 2572 | const spec_di = if (false and capturing) try dwarf.getDecl(pt, val) else undefined; |
| 2407 | const name_src_inst = ip.getNav(name_nav).srcInst(ip).resolve(ip).?; | 2573 | _ = spec_di; |
| 2408 | const decl = zcu.fileByIndex(src_inst.file).zir.?.getDeclaration(name_src_inst); | 2574 | if (maybe_name_nav.unwrap()) |name_ni| { |
| 2409 | const parent_cpi = try dwarf.getConst(pt, .fromInterned(zcu.fileRootType(src_inst.file))); | 2575 | const name_nav = ip.getNav(name_ni); |
| 2410 | try diw.writeUleb128(try dwarf.refAbbrevCode(.decl_namespace_struct)); | 2576 | const name_src_inst = name_nav.srcInst(ip).resolve(ip).?; |
| 2411 | try dwarf.sectionOffset(di_nw, Const.get(parent_cpi, dwarf).debug_info_ni.unwrap().?, 0); | 2577 | const decl = zf.zir.?.getDeclaration(name_src_inst); |
| | 2578 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( |
| | 2579 | name_nav.analysis.?.namespace, |
| | 2580 | ).owner_type); |
| | 2581 | try diw.writeUleb128(try dwarf.refAbbrevCode( |
| | 2582 | if (capturing) .decl_capturing_namespace_struct else .decl_namespace_struct, |
| | 2583 | )); |
| | 2584 | try dwarf.sectionOffset(di_nw, parent_ni, 0); |
| 2412 | try diw.writeInt(u32, decl.src_line + 1, dwarf.endian); | 2585 | try diw.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| 2413 | try diw.writeUleb128(decl.src_column + 1); | 2586 | try diw.writeUleb128(decl.src_column + 1); |
| 2414 | try diw.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); | 2587 | try diw.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); |
| | 2588 | try dwarf.strp(&dwarf.debug_str, di_nw, name_nav.name.toSlice(ip)); |
| 2415 | } else { | 2589 | } else { |
| 2416 | const ui = dwarf.getUnit(zcu.fileByIndex(src_inst.file).mod.?); | 2590 | const ui = dwarf.getUnit(zf.mod.?); |
| 2417 | _, const fi = try ui.get(dwarf).getFile(zcu.gpa, ui, src_inst.file); | 2591 | _, const fi = try ui.get(dwarf).getFile(zcu.gpa, ui, src_inst.file); |
| 2418 | try diw.writeUleb128(try dwarf.refAbbrevCode(.empty_struct_type)); | 2592 | const parent_ni = if (false) try dwarf.getDecl(pt, ip.namespacePtr( |
| | 2593 | ip.namespacePtr(namespace).parent.unwrap().?, |
| | 2594 | ).owner_type); |
| | 2595 | _ = parent_ni; |
| | 2596 | try diw.writeUleb128(try dwarf.refAbbrevCode( |
| | 2597 | if (capturing) .capturing_empty_struct_type else .empty_struct_type, |
| | 2598 | )); |
| 2419 | try diw.writeUleb128(@backingInt(fi)); | 2599 | try diw.writeUleb128(@backingInt(fi)); |
| | 2600 | try dwarf.strp(&dwarf.debug_str, di_nw, name.toSlice(ip)); |
| 2420 | } | 2601 | } |
| 2421 | try dwarf.strp(&dwarf.debug_str, di_nw, name.toSlice(ip)); | | |
| 2422 | try diw.writeByte(@intFromBool(true)); | 2602 | try diw.writeByte(@intFromBool(true)); |
| | 2603 | if (capturing) { |
| | 2604 | for (capture_names, captures.get(ip)) |capture_name, capture| switch (capture.unwrap()) { |
| | 2605 | .@"comptime" => |capture_val| { |
| | 2606 | const ty: Type = .fromInterned(ip.typeOf(capture_val)); |
| | 2607 | const ty_class = ty.classify(zcu); |
| | 2608 | try diw.writeUleb128(try dwarf.refAbbrevCode(switch (ty_class) { |
| | 2609 | .no_possible_value => unreachable, |
| | 2610 | .one_possible_value => .comptime_capture, |
| | 2611 | .runtime => .comptime_capture_runtime, |
| | 2612 | .partially_comptime => .comptime_capture_partially_comptime, |
| | 2613 | .fully_comptime => .comptime_capture_fully_comptime, |
| | 2614 | })); |
| | 2615 | try dwarf.strp(&dwarf.debug_str, di_nw, zf.zir.?.nullTerminatedString(capture_name)); |
| | 2616 | try dwarf.refConst(pt, di_nw, ty.toValue()); |
| | 2617 | if (ty_class.hasRuntimeBits()) try dwarf.blockConst(pt, di_nw, .fromInterned(capture_val)); |
| | 2618 | if (ty_class.comptimeOnly()) try dwarf.refConst(pt, di_nw, .fromInterned(capture_val)); |
| | 2619 | }, |
| | 2620 | .runtime => |capture_ty| { |
| | 2621 | try diw.writeUleb128(try dwarf.refAbbrevCode(.runtime_capture)); |
| | 2622 | try dwarf.strp(&dwarf.debug_str, di_nw, zf.zir.?.nullTerminatedString(capture_name)); |
| | 2623 | try dwarf.refConst(pt, di_nw, .fromInterned(capture_ty)); |
| | 2624 | }, |
| | 2625 | .nav_val, .nav_ref => {}, |
| | 2626 | }; |
| | 2627 | try diw.writeByte(@backingInt(AbbrevCode.null)); |
| | 2628 | } |
| | 2629 | } |
| | 2630 | try dwarf.genDebugInfoPadding(diw, diw.unusedCapacityLen()); |
| | 2631 | } |
| | 2632 | |
| | 2633 | pub fn genDecl( |
| | 2634 | dwarf: *Dwarf, |
| | 2635 | pt: Zcu.PerThread, |
| | 2636 | di_nw: *MappedFile.Node.Writer, |
| | 2637 | instance_val: InternPool.Index, |
| | 2638 | ) link.Error!void { |
| | 2639 | dwarf.genDeclInner(pt, di_nw, instance_val) catch |err| switch (err) { |
| | 2640 | else => |e| return e, |
| | 2641 | error.WriteFailed => return dwarf.reportWriteError(di_nw), |
| | 2642 | }; |
| | 2643 | } |
| | 2644 | fn genDeclInner( |
| | 2645 | dwarf: *Dwarf, |
| | 2646 | pt: Zcu.PerThread, |
| | 2647 | di_nw: *MappedFile.Node.Writer, |
| | 2648 | instance_val: InternPool.Index, |
| | 2649 | ) link.EmitError!void { |
| | 2650 | const ip = &dwarf.lf.comp.zcu.?.intern_pool; |
| | 2651 | const diw = &di_nw.interface; |
| | 2652 | switch (ip.indexToKey(instance_val)) { |
| | 2653 | else => unreachable, |
| | 2654 | .struct_type => { |
| | 2655 | const loaded_struct = ip.loadStructType(instance_val); |
| | 2656 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( |
| | 2657 | ip.namespacePtr(loaded_struct.namespace).parent.unwrap().?, |
| | 2658 | ).owner_type); |
| | 2659 | try diw.writeUleb128(try dwarf.refAbbrevCode(.decl_specification_struct)); |
| | 2660 | try dwarf.sectionOffset(di_nw, parent_ni, 0); |
| | 2661 | try diw.writeInt(u32, 0, dwarf.endian); |
| | 2662 | try diw.writeUleb128(0); |
| | 2663 | try diw.writeByte(DW.ACCESS.public); |
| | 2664 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_struct.name.toSlice(ip)); |
| | 2665 | }, |
| | 2666 | .enum_type => { |
| | 2667 | const loaded_enum = ip.loadEnumType(instance_val); |
| | 2668 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( |
| | 2669 | ip.namespacePtr(loaded_enum.namespace).parent.unwrap().?, |
| | 2670 | ).owner_type); |
| | 2671 | try diw.writeUleb128(try dwarf.refAbbrevCode(.decl_specification_enum)); |
| | 2672 | try dwarf.sectionOffset(di_nw, parent_ni, 0); |
| | 2673 | try diw.writeInt(u32, 0, dwarf.endian); |
| | 2674 | try diw.writeUleb128(0); |
| | 2675 | try diw.writeByte(DW.ACCESS.public); |
| | 2676 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_enum.name.toSlice(ip)); |
| | 2677 | }, |
| | 2678 | .union_type => { |
| | 2679 | const loaded_union = ip.loadUnionType(instance_val); |
| | 2680 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( |
| | 2681 | ip.namespacePtr(loaded_union.namespace).parent.unwrap().?, |
| | 2682 | ).owner_type); |
| | 2683 | try diw.writeUleb128(try dwarf.refAbbrevCode(.decl_specification_union)); |
| | 2684 | try dwarf.sectionOffset(di_nw, parent_ni, 0); |
| | 2685 | try diw.writeInt(u32, 0, dwarf.endian); |
| | 2686 | try diw.writeUleb128(0); |
| | 2687 | try diw.writeByte(DW.ACCESS.public); |
| | 2688 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_union.name.toSlice(ip)); |
| | 2689 | }, |
| 2423 | } | 2690 | } |
| 2424 | try dwarf.genDebugInfoPadding(diw, diw.unusedCapacityLen()); | 2691 | try dwarf.genDebugInfoPadding(diw, diw.unusedCapacityLen()); |
| 2425 | } | 2692 | } |
| ... | @@ -2430,8 +2697,13 @@ pub fn updateLineNumber( | ... | @@ -2430,8 +2697,13 @@ pub fn updateLineNumber( |
| 2430 | inst: InternPool.TrackedInst.Index, | 2697 | inst: InternPool.TrackedInst.Index, |
| 2431 | line: u32, | 2698 | line: u32, |
| 2432 | ) void { | 2699 | ) void { |
| 2433 | const decl_ni = dwarf.decls.get(inst) orelse return; | 2700 | const di = dwarf.getDeclIfExists(inst) orelse return; |
| 2434 | std.mem.writeInt(u32, decl_ni.slice(mf)[AbbrevCode.decl_bytes..][0..4], line + 1, dwarf.endian); | 2701 | const decl_ni = di.get(dwarf).debug_info_ni.unwrap() orelse return; |
| | 2702 | std.mem.writeInt(u32, decl_ni.slice(mf)[AbbrevCode.decl_size..][0..4], line + 1, dwarf.endian); |
| | 2703 | } |
| | 2704 | |
| | 2705 | pub fn lostTracking(dwarf: *Dwarf, diw: *Writer) link.EmitError!void { |
| | 2706 | try diw.writeUleb128(try dwarf.refAbbrevCode(.decl_lost)); |
| 2435 | } | 2707 | } |
| 2436 | | 2708 | |
| 2437 | fn refAbbrevCodeIfExists( | 2709 | fn refAbbrevCodeIfExists( |
| ... | @@ -2442,7 +2714,7 @@ fn refAbbrevCodeIfExists( | ... | @@ -2442,7 +2714,7 @@ fn refAbbrevCodeIfExists( |
| 2442 | return if (dwarf.debug_abbrev.set.contains(abbrev_code)) @backingInt(abbrev_code) else null; | 2714 | return if (dwarf.debug_abbrev.set.contains(abbrev_code)) @backingInt(abbrev_code) else null; |
| 2443 | } | 2715 | } |
| 2444 | | 2716 | |
| 2445 | pub fn refAbbrevCode( | 2717 | fn refAbbrevCode( |
| 2446 | dwarf: *Dwarf, | 2718 | dwarf: *Dwarf, |
| 2447 | abbrev_code: AbbrevCode, | 2719 | abbrev_code: AbbrevCode, |
| 2448 | ) link.Error!@typeInfo(AbbrevCode).@"enum".tag_type { | 2720 | ) link.Error!@typeInfo(AbbrevCode).@"enum".tag_type { |
| ... | @@ -2517,6 +2789,75 @@ fn symbolAddress( | ... | @@ -2517,6 +2789,75 @@ fn symbolAddress( |
| 2517 | try elf.addReloc(@bitCast(nw.ni), offset, target_si, @bitCast(@as(u64, addend)), .absAddr(elf)); | 2789 | try elf.addReloc(@bitCast(nw.ni), offset, target_si, @bitCast(@as(u64, addend)), .absAddr(elf)); |
| 2518 | } | 2790 | } |
| 2519 | | 2791 | |
| | 2792 | fn blockConst(dwarf: *Dwarf, pt: Zcu.PerThread, nw: *MappedFile.Node.Writer, val: Value) link.EmitError!void { |
| | 2793 | const ty = val.typeOf(pt.zcu); |
| | 2794 | const size = ty.abiSize(pt.zcu); |
| | 2795 | try nw.interface.writeUleb128(size); |
| | 2796 | const start = nw.interface.end; |
| | 2797 | if (size > 0) try codegen.generateSymbol( |
| | 2798 | dwarf.lf, |
| | 2799 | pt, |
| | 2800 | val, |
| | 2801 | &nw.interface, |
| | 2802 | .{ .atom_index = @bitCast(nw.ni) }, |
| | 2803 | ); |
| | 2804 | assert(start + size == nw.interface.end); |
| | 2805 | } |
| | 2806 | |
| | 2807 | fn refConst(dwarf: *Dwarf, pt: Zcu.PerThread, nw: *MappedFile.Node.Writer, val: Value) link.EmitError!void { |
| | 2808 | try dwarf.sectionOffset(nw, Const.get(try dwarf.getConst(pt, val), dwarf).debug_info_ni.unwrap().?, 0); |
| | 2809 | } |
| | 2810 | |
| | 2811 | fn bigIntConstValue(dwarf: *Dwarf, diw: *Writer, ty: Type, big_int: std.math.big.int.Const) link.EmitError!void { |
| | 2812 | const zcu = dwarf.lf.comp.zcu.?; |
| | 2813 | const signedness = switch (ty.toIntern()) { |
| | 2814 | .comptime_int_type => .signed, |
| | 2815 | else => ty.intInfo(zcu).signedness, |
| | 2816 | }; |
| | 2817 | const bits = @max(1, big_int.bitCountTwosCompForSignedness(signedness)); |
| | 2818 | if (bits <= 64) { |
| | 2819 | try diw.writeUleb128(@as(u13, switch (signedness) { |
| | 2820 | .signed => DW.FORM.sdata, |
| | 2821 | .unsigned => DW.FORM.udata, |
| | 2822 | })); |
| | 2823 | var bit: usize = 0; |
| | 2824 | var carry: u1 = 1; |
| | 2825 | for (try diw.writableSlice(@divCeil(bits, 7))) |*byte| { |
| | 2826 | const limb_bits = @typeInfo(std.math.big.Limb).int.bits; |
| | 2827 | const limb_index = bit / limb_bits; |
| | 2828 | const limb_shift: std.math.Log2Int(std.math.big.Limb) = @intCast(bit % limb_bits); |
| | 2829 | const low_abs_part: u7 = @truncate(big_int.limbs[limb_index] >> limb_shift); |
| | 2830 | const abs_part = if (limb_shift > limb_bits - 7 and limb_index + 1 < big_int.limbs.len) abs_part: { |
| | 2831 | const high_abs_part: u7 = @truncate(big_int.limbs[limb_index + 1] << -%limb_shift); |
| | 2832 | break :abs_part high_abs_part | low_abs_part; |
| | 2833 | } else low_abs_part; |
| | 2834 | const twos_comp_part = if (big_int.positive) abs_part else twos_comp_part: { |
| | 2835 | const twos_comp_part, carry = @addWithOverflow(~abs_part, carry); |
| | 2836 | break :twos_comp_part twos_comp_part; |
| | 2837 | }; |
| | 2838 | bit += 7; |
| | 2839 | byte.* = @as(u8, if (bit < bits) 0x80 else 0x00) | twos_comp_part; |
| | 2840 | } |
| | 2841 | } else { |
| | 2842 | try diw.writeUleb128(DW.FORM.block); |
| | 2843 | const size = switch (ty.toIntern()) { |
| | 2844 | .comptime_int_type => @divCeil(bits, 8), |
| | 2845 | else => ty.abiSize(zcu), |
| | 2846 | }; |
| | 2847 | try diw.writeUleb128(size); |
| | 2848 | big_int.writeTwosComplement(try diw.writableSlice(@intCast(size)), dwarf.endian); |
| | 2849 | } |
| | 2850 | } |
| | 2851 | |
| | 2852 | fn enumConstValue(dwarf: *Dwarf, diw: *Writer, loaded_enum: InternPool.LoadedEnumType, field_index: usize) link.EmitError!void { |
| | 2853 | const zcu = dwarf.lf.comp.zcu.?; |
| | 2854 | var big_int_space: Value.BigIntSpace = undefined; |
| | 2855 | try dwarf.bigIntConstValue(diw, .fromInterned(loaded_enum.int_tag_type), if (loaded_enum.field_values.len > 0) |
| | 2856 | Value.fromInterned(loaded_enum.field_values.get(&zcu.intern_pool)[field_index]).toBigInt(&big_int_space, zcu) |
| | 2857 | else |
| | 2858 | std.math.big.int.Mutable.init(&big_int_space.limbs, field_index).toConst()); |
| | 2859 | } |
| | 2860 | |
| 2520 | fn strp(dwarf: *Dwarf, s: *Str, nw: *MappedFile.Node.Writer, str: []const u8) link.EmitError!void { | 2861 | fn strp(dwarf: *Dwarf, s: *Str, nw: *MappedFile.Node.Writer, str: []const u8) link.EmitError!void { |
| 2521 | const comp = dwarf.lf.comp; | 2862 | const comp = dwarf.lf.comp; |
| 2522 | const mf = &dwarf.lf.cast(.elf2).?.mf; | 2863 | const mf = &dwarf.lf.cast(.elf2).?.mf; |
| ... | @@ -2571,6 +2912,7 @@ pub const AbbrevCode = enum { | ... | @@ -2571,6 +2912,7 @@ pub const AbbrevCode = enum { |
| 2571 | decl_empty_enum, | 2912 | decl_empty_enum, |
| 2572 | decl_enum, | 2913 | decl_enum, |
| 2573 | decl_namespace_struct, | 2914 | decl_namespace_struct, |
| | 2915 | decl_capturing_namespace_struct, |
| 2574 | decl_struct, | 2916 | decl_struct, |
| 2575 | decl_packed_struct, | 2917 | decl_packed_struct, |
| 2576 | decl_union, | 2918 | decl_union, |
| ... | @@ -2587,6 +2929,7 @@ pub const AbbrevCode = enum { | ... | @@ -2587,6 +2929,7 @@ pub const AbbrevCode = enum { |
| 2587 | decl_extern_nullary_func, | 2929 | decl_extern_nullary_func, |
| 2588 | decl_extern_func, | 2930 | decl_extern_func, |
| 2589 | decl_specification_struct, | 2931 | decl_specification_struct, |
| | 2932 | decl_specification_enum, |
| 2590 | decl_specification_union, | 2933 | decl_specification_union, |
| 2591 | decl_specification_func, | 2934 | decl_specification_func, |
| 2592 | decl_instance_alias, | 2935 | decl_instance_alias, |
| ... | @@ -2619,11 +2962,13 @@ pub const AbbrevCode = enum { | ... | @@ -2619,11 +2962,13 @@ pub const AbbrevCode = enum { |
| 2619 | enum_field, | 2962 | enum_field, |
| 2620 | generated_field, | 2963 | generated_field, |
| 2621 | field, | 2964 | field, |
| 2622 | field_default_runtime_bits, | 2965 | field_default_fully_runtime, |
| 2623 | field_default_comptime_state, | 2966 | field_default_partially_comptime, |
| | 2967 | field_default_fully_comptime, |
| 2624 | field_comptime, | 2968 | field_comptime, |
| 2625 | field_comptime_runtime_bits, | 2969 | field_comptime_fully_runtime, |
| 2626 | field_comptime_comptime_state, | 2970 | field_comptime_partially_comptime, |
| | 2971 | field_comptime_fully_comptime, |
| 2627 | packed_field, | 2972 | packed_field, |
| 2628 | tagged_union, | 2973 | tagged_union, |
| 2629 | tagged_union_field, | 2974 | tagged_union_field, |
| ... | @@ -2655,6 +3000,7 @@ pub const AbbrevCode = enum { | ... | @@ -2655,6 +3000,7 @@ pub const AbbrevCode = enum { |
| 2655 | empty_enum_type, | 3000 | empty_enum_type, |
| 2656 | enum_type, | 3001 | enum_type, |
| 2657 | empty_struct_type, | 3002 | empty_struct_type, |
| | 3003 | capturing_empty_struct_type, |
| 2658 | struct_type, | 3004 | struct_type, |
| 2659 | empty_packed_struct_type, | 3005 | empty_packed_struct_type, |
| 2660 | packed_struct_type, | 3006 | packed_struct_type, |
| ... | @@ -2662,6 +3008,11 @@ pub const AbbrevCode = enum { | ... | @@ -2662,6 +3008,11 @@ pub const AbbrevCode = enum { |
| 2662 | union_type, | 3008 | union_type, |
| 2663 | empty_packed_union_type, | 3009 | empty_packed_union_type, |
| 2664 | packed_union_type, | 3010 | packed_union_type, |
| | 3011 | comptime_capture, |
| | 3012 | comptime_capture_runtime, |
| | 3013 | comptime_capture_partially_comptime, |
| | 3014 | comptime_capture_fully_comptime, |
| | 3015 | runtime_capture, |
| 2665 | builtin_extern_nullary_func, | 3016 | builtin_extern_nullary_func, |
| 2666 | builtin_extern_func, | 3017 | builtin_extern_func, |
| 2667 | builtin_extern_var, | 3018 | builtin_extern_var, |
| ... | @@ -2672,19 +3023,19 @@ pub const AbbrevCode = enum { | ... | @@ -2672,19 +3023,19 @@ pub const AbbrevCode = enum { |
| 2672 | arg, | 3023 | arg, |
| 2673 | unnamed_arg, | 3024 | unnamed_arg, |
| 2674 | comptime_arg, | 3025 | comptime_arg, |
| | 3026 | comptime_arg_fully_runtime, |
| | 3027 | comptime_arg_partially_comptime, |
| | 3028 | comptime_arg_fully_comptime, |
| 2675 | unnamed_comptime_arg, | 3029 | unnamed_comptime_arg, |
| 2676 | comptime_arg_runtime_bits, | 3030 | unnamed_comptime_arg_fully_runtime, |
| 2677 | unnamed_comptime_arg_runtime_bits, | 3031 | unnamed_comptime_arg_partially_comptime, |
| 2678 | comptime_arg_comptime_state, | 3032 | unnamed_comptime_arg_fully_comptime, |
| 2679 | unnamed_comptime_arg_comptime_state, | | |
| 2680 | comptime_arg_runtime_bits_comptime_state, | | |
| 2681 | unnamed_comptime_arg_runtime_bits_comptime_state, | | |
| 2682 | extern_param, | 3033 | extern_param, |
| 2683 | local_var, | 3034 | local_var, |
| 2684 | local_const, | 3035 | local_const, |
| 2685 | local_const_runtime_bits, | 3036 | local_const_fully_runtime, |
| 2686 | local_const_comptime_state, | 3037 | local_const_partially_comptime, |
| 2687 | local_const_runtime_bits_comptime_state, | 3038 | local_const_fully_comptime, |
| 2688 | undefined_comptime_value, | 3039 | undefined_comptime_value, |
| 2689 | comptime_value, | 3040 | comptime_value, |
| 2690 | location_comptime_value, | 3041 | location_comptime_value, |
| ... | @@ -2696,11 +3047,11 @@ pub const AbbrevCode = enum { | ... | @@ -2696,11 +3047,11 @@ pub const AbbrevCode = enum { |
| 2696 | comptime_value_elem_runtime_bits, | 3047 | comptime_value_elem_runtime_bits, |
| 2697 | comptime_value_elem_comptime_state, | 3048 | comptime_value_elem_comptime_state, |
| 2698 | | 3049 | |
| 2699 | const decl_bytes = uleb128Size(@backingInt(AbbrevCode.decl_instance_extern_func)); | 3050 | const decl_size = uleb128Size(@backingInt(AbbrevCode.decl_instance_extern_func)); |
| 2700 | comptime { | 3051 | comptime { |
| 2701 | assert(uleb128Size(@backingInt(AbbrevCode.pad_1)) == 1); | 3052 | assert(uleb128Size(@backingInt(AbbrevCode.pad_1)) == 1); |
| 2702 | assert(uleb128Size(@backingInt(AbbrevCode.pad_n)) == 1); | 3053 | assert(uleb128Size(@backingInt(AbbrevCode.pad_n)) == 1); |
| 2703 | assert(uleb128Size(@backingInt(AbbrevCode.decl_alias)) == decl_bytes); | 3054 | assert(uleb128Size(@backingInt(AbbrevCode.decl_alias)) == decl_size); |
| 2704 | } | 3055 | } |
| 2705 | | 3056 | |
| 2706 | const Attr = struct { | 3057 | const Attr = struct { |
| ... | @@ -2766,6 +3117,13 @@ pub const AbbrevCode = enum { | ... | @@ -2766,6 +3117,13 @@ pub const AbbrevCode = enum { |
| 2766 | .{ .declaration, .flag }, | 3117 | .{ .declaration, .flag }, |
| 2767 | }, | 3118 | }, |
| 2768 | }, | 3119 | }, |
| | 3120 | .decl_capturing_namespace_struct = .{ |
| | 3121 | .tag = .structure_type, |
| | 3122 | .children = true, |
| | 3123 | .attrs = decl_attrs ++ .{ |
| | 3124 | .{ .declaration, .flag }, |
| | 3125 | }, |
| | 3126 | }, |
| 2769 | .decl_struct = .{ | 3127 | .decl_struct = .{ |
| 2770 | .tag = .structure_type, | 3128 | .tag = .structure_type, |
| 2771 | .children = true, | 3129 | .children = true, |
| ... | @@ -2908,11 +3266,15 @@ pub const AbbrevCode = enum { | ... | @@ -2908,11 +3266,15 @@ pub const AbbrevCode = enum { |
| 2908 | }, | 3266 | }, |
| 2909 | }, | 3267 | }, |
| 2910 | .decl_specification_struct = .{ | 3268 | .decl_specification_struct = .{ |
| 2911 | .tag = .variable, | 3269 | .tag = .structure_type, |
| | 3270 | .attrs = decl_specification_attrs, |
| | 3271 | }, |
| | 3272 | .decl_specification_enum = .{ |
| | 3273 | .tag = .enumeration_type, |
| 2912 | .attrs = decl_specification_attrs, | 3274 | .attrs = decl_specification_attrs, |
| 2913 | }, | 3275 | }, |
| 2914 | .decl_specification_union = .{ | 3276 | .decl_specification_union = .{ |
| 2915 | .tag = .constant, | 3277 | .tag = .union_type, |
| 2916 | .attrs = decl_specification_attrs, | 3278 | .attrs = decl_specification_attrs, |
| 2917 | }, | 3279 | }, |
| 2918 | .decl_specification_func = .{ | 3280 | .decl_specification_func = .{ |
| ... | @@ -2940,6 +3302,7 @@ pub const AbbrevCode = enum { | ... | @@ -2940,6 +3302,7 @@ pub const AbbrevCode = enum { |
| 2940 | }, | 3302 | }, |
| 2941 | .decl_instance_namespace_struct = .{ | 3303 | .decl_instance_namespace_struct = .{ |
| 2942 | .tag = .structure_type, | 3304 | .tag = .structure_type, |
| | 3305 | .children = true, |
| 2943 | .attrs = decl_instance_attrs ++ .{ | 3306 | .attrs = decl_instance_attrs ++ .{ |
| 2944 | .{ .declaration, .flag }, | 3307 | .{ .declaration, .flag }, |
| 2945 | }, | 3308 | }, |
| ... | @@ -3118,6 +3481,7 @@ pub const AbbrevCode = enum { | ... | @@ -3118,6 +3481,7 @@ pub const AbbrevCode = enum { |
| 3118 | .attrs = &.{ | 3481 | .attrs = &.{ |
| 3119 | .{ .decl_file, .udata }, | 3482 | .{ .decl_file, .udata }, |
| 3120 | .{ .name, .strp }, | 3483 | .{ .name, .strp }, |
| | 3484 | .{ .declaration, .flag }, |
| 3121 | }, | 3485 | }, |
| 3122 | }, | 3486 | }, |
| 3123 | .file = .{ | 3487 | .file = .{ |
| ... | @@ -3161,7 +3525,17 @@ pub const AbbrevCode = enum { | ... | @@ -3161,7 +3525,17 @@ pub const AbbrevCode = enum { |
| 3161 | .{ .alignment, .udata }, | 3525 | .{ .alignment, .udata }, |
| 3162 | }, | 3526 | }, |
| 3163 | }, | 3527 | }, |
| 3164 | .field_default_runtime_bits = .{ | 3528 | .field_default_fully_runtime = .{ |
| | 3529 | .tag = .member, |
| | 3530 | .attrs = &.{ |
| | 3531 | .{ .name, .strp }, |
| | 3532 | .{ .type, .ref_addr }, |
| | 3533 | .{ .data_member_location, .udata }, |
| | 3534 | .{ .alignment, .udata }, |
| | 3535 | .{ .default_value, .block }, |
| | 3536 | }, |
| | 3537 | }, |
| | 3538 | .field_default_partially_comptime = .{ |
| 3165 | .tag = .member, | 3539 | .tag = .member, |
| 3166 | .attrs = &.{ | 3540 | .attrs = &.{ |
| 3167 | .{ .name, .strp }, | 3541 | .{ .name, .strp }, |
| ... | @@ -3169,9 +3543,10 @@ pub const AbbrevCode = enum { | ... | @@ -3169,9 +3543,10 @@ pub const AbbrevCode = enum { |
| 3169 | .{ .data_member_location, .udata }, | 3543 | .{ .data_member_location, .udata }, |
| 3170 | .{ .alignment, .udata }, | 3544 | .{ .alignment, .udata }, |
| 3171 | .{ .default_value, .block }, | 3545 | .{ .default_value, .block }, |
| | 3546 | .{ .ZIG_comptime_value, .ref_addr }, |
| 3172 | }, | 3547 | }, |
| 3173 | }, | 3548 | }, |
| 3174 | .field_default_comptime_state = .{ | 3549 | .field_default_fully_comptime = .{ |
| 3175 | .tag = .member, | 3550 | .tag = .member, |
| 3176 | .attrs = &.{ | 3551 | .attrs = &.{ |
| 3177 | .{ .name, .strp }, | 3552 | .{ .name, .strp }, |
| ... | @@ -3189,7 +3564,7 @@ pub const AbbrevCode = enum { | ... | @@ -3189,7 +3564,7 @@ pub const AbbrevCode = enum { |
| 3189 | .{ .type, .ref_addr }, | 3564 | .{ .type, .ref_addr }, |
| 3190 | }, | 3565 | }, |
| 3191 | }, | 3566 | }, |
| 3192 | .field_comptime_runtime_bits = .{ | 3567 | .field_comptime_fully_runtime = .{ |
| 3193 | .tag = .member, | 3568 | .tag = .member, |
| 3194 | .attrs = &.{ | 3569 | .attrs = &.{ |
| 3195 | .{ .const_expr, .flag_present }, | 3570 | .{ .const_expr, .flag_present }, |
| ... | @@ -3198,7 +3573,17 @@ pub const AbbrevCode = enum { | ... | @@ -3198,7 +3573,17 @@ pub const AbbrevCode = enum { |
| 3198 | .{ .const_value, .block }, | 3573 | .{ .const_value, .block }, |
| 3199 | }, | 3574 | }, |
| 3200 | }, | 3575 | }, |
| 3201 | .field_comptime_comptime_state = .{ | 3576 | .field_comptime_partially_comptime = .{ |
| | 3577 | .tag = .member, |
| | 3578 | .attrs = &.{ |
| | 3579 | .{ .const_expr, .flag_present }, |
| | 3580 | .{ .name, .strp }, |
| | 3581 | .{ .type, .ref_addr }, |
| | 3582 | .{ .const_value, .block }, |
| | 3583 | .{ .ZIG_comptime_value, .ref_addr }, |
| | 3584 | }, |
| | 3585 | }, |
| | 3586 | .field_comptime_fully_comptime = .{ |
| 3202 | .tag = .member, | 3587 | .tag = .member, |
| 3203 | .attrs = &.{ | 3588 | .attrs = &.{ |
| 3204 | .{ .const_expr, .flag_present }, | 3589 | .{ .const_expr, .flag_present }, |
| ... | @@ -3441,6 +3826,15 @@ pub const AbbrevCode = enum { | ... | @@ -3441,6 +3826,15 @@ pub const AbbrevCode = enum { |
| 3441 | .{ .declaration, .flag }, | 3826 | .{ .declaration, .flag }, |
| 3442 | }, | 3827 | }, |
| 3443 | }, | 3828 | }, |
| | 3829 | .capturing_empty_struct_type = .{ |
| | 3830 | .tag = .structure_type, |
| | 3831 | .children = true, |
| | 3832 | .attrs = &.{ |
| | 3833 | .{ .decl_file, .udata }, |
| | 3834 | .{ .name, .strp }, |
| | 3835 | .{ .declaration, .flag }, |
| | 3836 | }, |
| | 3837 | }, |
| 3444 | .struct_type = .{ | 3838 | .struct_type = .{ |
| 3445 | .tag = .structure_type, | 3839 | .tag = .structure_type, |
| 3446 | .children = true, | 3840 | .children = true, |
| ... | @@ -3504,6 +3898,45 @@ pub const AbbrevCode = enum { | ... | @@ -3504,6 +3898,45 @@ pub const AbbrevCode = enum { |
| 3504 | .{ .type, .ref_addr }, | 3898 | .{ .type, .ref_addr }, |
| 3505 | }, | 3899 | }, |
| 3506 | }, | 3900 | }, |
| | 3901 | .comptime_capture = .{ |
| | 3902 | .tag = .template_value_parameter, |
| | 3903 | .attrs = &.{ |
| | 3904 | .{ .name, .strp }, |
| | 3905 | .{ .type, .ref_addr }, |
| | 3906 | }, |
| | 3907 | }, |
| | 3908 | .comptime_capture_runtime = .{ |
| | 3909 | .tag = .template_value_parameter, |
| | 3910 | .attrs = &.{ |
| | 3911 | .{ .name, .strp }, |
| | 3912 | .{ .type, .ref_addr }, |
| | 3913 | .{ .const_value, .block }, |
| | 3914 | }, |
| | 3915 | }, |
| | 3916 | .comptime_capture_partially_comptime = .{ |
| | 3917 | .tag = .template_value_parameter, |
| | 3918 | .attrs = &.{ |
| | 3919 | .{ .name, .strp }, |
| | 3920 | .{ .type, .ref_addr }, |
| | 3921 | .{ .const_value, .block }, |
| | 3922 | .{ .ZIG_comptime_value, .ref_addr }, |
| | 3923 | }, |
| | 3924 | }, |
| | 3925 | .comptime_capture_fully_comptime = .{ |
| | 3926 | .tag = .template_value_parameter, |
| | 3927 | .attrs = &.{ |
| | 3928 | .{ .name, .strp }, |
| | 3929 | .{ .type, .ref_addr }, |
| | 3930 | .{ .ZIG_comptime_value, .ref_addr }, |
| | 3931 | }, |
| | 3932 | }, |
| | 3933 | .runtime_capture = .{ |
| | 3934 | .tag = .template_type_parameter, |
| | 3935 | .attrs = &.{ |
| | 3936 | .{ .name, .strp }, |
| | 3937 | .{ .type, .ref_addr }, |
| | 3938 | }, |
| | 3939 | }, |
| 3507 | .builtin_extern_nullary_func = .{ | 3940 | .builtin_extern_nullary_func = .{ |
| 3508 | .tag = .subprogram, | 3941 | .tag = .subprogram, |
| 3509 | .attrs = &.{ | 3942 | .attrs = &.{ |
| ... | @@ -3577,14 +4010,14 @@ pub const AbbrevCode = enum { | ... | @@ -3577,14 +4010,14 @@ pub const AbbrevCode = enum { |
| 3577 | .tag = .formal_parameter, | 4010 | .tag = .formal_parameter, |
| 3578 | .attrs = &.{ | 4011 | .attrs = &.{ |
| 3579 | .{ .name, .strp }, | 4012 | .{ .name, .strp }, |
| 3580 | //.{ .type, .ref_addr }, | 4013 | .{ .type, .ref_addr }, |
| 3581 | .{ .location, .exprloc }, | 4014 | .{ .location, .exprloc }, |
| 3582 | }, | 4015 | }, |
| 3583 | }, | 4016 | }, |
| 3584 | .unnamed_arg = .{ | 4017 | .unnamed_arg = .{ |
| 3585 | .tag = .formal_parameter, | 4018 | .tag = .formal_parameter, |
| 3586 | .attrs = &.{ | 4019 | .attrs = &.{ |
| 3587 | //.{ .type, .ref_addr }, | 4020 | .{ .type, .ref_addr }, |
| 3588 | .{ .location, .exprloc }, | 4021 | .{ .location, .exprloc }, |
| 3589 | }, | 4022 | }, |
| 3590 | }, | 4023 | }, |
| ... | @@ -3593,80 +4026,80 @@ pub const AbbrevCode = enum { | ... | @@ -3593,80 +4026,80 @@ pub const AbbrevCode = enum { |
| 3593 | .attrs = &.{ | 4026 | .attrs = &.{ |
| 3594 | .{ .const_expr, .flag_present }, | 4027 | .{ .const_expr, .flag_present }, |
| 3595 | .{ .name, .strp }, | 4028 | .{ .name, .strp }, |
| 3596 | //.{ .type, .ref_addr }, | 4029 | .{ .type, .ref_addr }, |
| 3597 | }, | 4030 | }, |
| 3598 | }, | 4031 | }, |
| 3599 | .unnamed_comptime_arg = .{ | 4032 | .comptime_arg_fully_runtime = .{ |
| 3600 | .tag = .formal_parameter, | 4033 | .tag = .formal_parameter, |
| 3601 | .attrs = &.{ | 4034 | .attrs = &.{ |
| 3602 | .{ .const_expr, .flag_present }, | 4035 | .{ .const_expr, .flag_present }, |
| 3603 | //.{ .type, .ref_addr }, | 4036 | .{ .name, .strp }, |
| | 4037 | .{ .type, .ref_addr }, |
| | 4038 | .{ .const_value, .block }, |
| 3604 | }, | 4039 | }, |
| 3605 | }, | 4040 | }, |
| 3606 | .comptime_arg_runtime_bits = .{ | 4041 | .comptime_arg_partially_comptime = .{ |
| 3607 | .tag = .formal_parameter, | 4042 | .tag = .formal_parameter, |
| 3608 | .attrs = &.{ | 4043 | .attrs = &.{ |
| 3609 | .{ .const_expr, .flag_present }, | 4044 | .{ .const_expr, .flag_present }, |
| 3610 | .{ .name, .strp }, | 4045 | .{ .name, .strp }, |
| 3611 | //.{ .type, .ref_addr }, | 4046 | .{ .type, .ref_addr }, |
| 3612 | .{ .const_value, .block }, | 4047 | .{ .const_value, .block }, |
| | 4048 | .{ .ZIG_comptime_value, .ref_addr }, |
| 3613 | }, | 4049 | }, |
| 3614 | }, | 4050 | }, |
| 3615 | .unnamed_comptime_arg_runtime_bits = .{ | 4051 | .comptime_arg_fully_comptime = .{ |
| 3616 | .tag = .formal_parameter, | 4052 | .tag = .formal_parameter, |
| 3617 | .attrs = &.{ | 4053 | .attrs = &.{ |
| 3618 | .{ .const_expr, .flag_present }, | 4054 | .{ .const_expr, .flag_present }, |
| 3619 | //.{ .type, .ref_addr }, | 4055 | .{ .name, .strp }, |
| 3620 | .{ .const_value, .block }, | 4056 | .{ .type, .ref_addr }, |
| | 4057 | .{ .ZIG_comptime_value, .ref_addr }, |
| 3621 | }, | 4058 | }, |
| 3622 | }, | 4059 | }, |
| 3623 | .comptime_arg_comptime_state = .{ | 4060 | .unnamed_comptime_arg = .{ |
| 3624 | .tag = .formal_parameter, | 4061 | .tag = .formal_parameter, |
| 3625 | .attrs = &.{ | 4062 | .attrs = &.{ |
| 3626 | .{ .const_expr, .flag_present }, | 4063 | .{ .const_expr, .flag_present }, |
| 3627 | .{ .name, .strp }, | 4064 | .{ .type, .ref_addr }, |
| 3628 | //.{ .type, .ref_addr }, | | |
| 3629 | //.{ .ZIG_comptime_value, .ref_addr }, | | |
| 3630 | }, | 4065 | }, |
| 3631 | }, | 4066 | }, |
| 3632 | .unnamed_comptime_arg_comptime_state = .{ | 4067 | .unnamed_comptime_arg_fully_runtime = .{ |
| 3633 | .tag = .formal_parameter, | 4068 | .tag = .formal_parameter, |
| 3634 | .attrs = &.{ | 4069 | .attrs = &.{ |
| 3635 | .{ .const_expr, .flag_present }, | 4070 | .{ .const_expr, .flag_present }, |
| 3636 | //.{ .type, .ref_addr }, | 4071 | .{ .type, .ref_addr }, |
| 3637 | //.{ .ZIG_comptime_value, .ref_addr }, | 4072 | .{ .const_value, .block }, |
| 3638 | }, | 4073 | }, |
| 3639 | }, | 4074 | }, |
| 3640 | .comptime_arg_runtime_bits_comptime_state = .{ | 4075 | .unnamed_comptime_arg_partially_comptime = .{ |
| 3641 | .tag = .formal_parameter, | 4076 | .tag = .formal_parameter, |
| 3642 | .attrs = &.{ | 4077 | .attrs = &.{ |
| 3643 | .{ .const_expr, .flag_present }, | 4078 | .{ .const_expr, .flag_present }, |
| 3644 | .{ .name, .strp }, | 4079 | .{ .type, .ref_addr }, |
| 3645 | //.{ .type, .ref_addr }, | | |
| 3646 | .{ .const_value, .block }, | 4080 | .{ .const_value, .block }, |
| 3647 | //.{ .ZIG_comptime_value, .ref_addr }, | 4081 | .{ .ZIG_comptime_value, .ref_addr }, |
| 3648 | }, | 4082 | }, |
| 3649 | }, | 4083 | }, |
| 3650 | .unnamed_comptime_arg_runtime_bits_comptime_state = .{ | 4084 | .unnamed_comptime_arg_fully_comptime = .{ |
| 3651 | .tag = .formal_parameter, | 4085 | .tag = .formal_parameter, |
| 3652 | .attrs = &.{ | 4086 | .attrs = &.{ |
| 3653 | .{ .const_expr, .flag_present }, | 4087 | .{ .const_expr, .flag_present }, |
| 3654 | //.{ .type, .ref_addr }, | 4088 | .{ .type, .ref_addr }, |
| 3655 | .{ .const_value, .block }, | 4089 | .{ .ZIG_comptime_value, .ref_addr }, |
| 3656 | //.{ .ZIG_comptime_value, .ref_addr }, | | |
| 3657 | }, | 4090 | }, |
| 3658 | }, | 4091 | }, |
| 3659 | .extern_param = .{ | 4092 | .extern_param = .{ |
| 3660 | .tag = .formal_parameter, | 4093 | .tag = .formal_parameter, |
| 3661 | .attrs = &.{ | 4094 | .attrs = &.{ |
| 3662 | //.{ .type, .ref_addr }, | 4095 | .{ .type, .ref_addr }, |
| 3663 | }, | 4096 | }, |
| 3664 | }, | 4097 | }, |
| 3665 | .local_var = .{ | 4098 | .local_var = .{ |
| 3666 | .tag = .variable, | 4099 | .tag = .variable, |
| 3667 | .attrs = &.{ | 4100 | .attrs = &.{ |
| 3668 | .{ .name, .strp }, | 4101 | .{ .name, .strp }, |
| 3669 | //.{ .type, .ref_addr }, | 4102 | .{ .type, .ref_addr }, |
| 3670 | .{ .location, .exprloc }, | 4103 | .{ .location, .exprloc }, |
| 3671 | }, | 4104 | }, |
| 3672 | }, | 4105 | }, |
| ... | @@ -3674,32 +4107,32 @@ pub const AbbrevCode = enum { | ... | @@ -3674,32 +4107,32 @@ pub const AbbrevCode = enum { |
| 3674 | .tag = .constant, | 4107 | .tag = .constant, |
| 3675 | .attrs = &.{ | 4108 | .attrs = &.{ |
| 3676 | .{ .name, .strp }, | 4109 | .{ .name, .strp }, |
| 3677 | //.{ .type, .ref_addr }, | 4110 | .{ .type, .ref_addr }, |
| 3678 | }, | 4111 | }, |
| 3679 | }, | 4112 | }, |
| 3680 | .local_const_runtime_bits = .{ | 4113 | .local_const_fully_runtime = .{ |
| 3681 | .tag = .constant, | 4114 | .tag = .constant, |
| 3682 | .attrs = &.{ | 4115 | .attrs = &.{ |
| 3683 | .{ .name, .strp }, | 4116 | .{ .name, .strp }, |
| 3684 | //.{ .type, .ref_addr }, | 4117 | .{ .type, .ref_addr }, |
| 3685 | .{ .const_value, .block }, | 4118 | .{ .const_value, .block }, |
| 3686 | }, | 4119 | }, |
| 3687 | }, | 4120 | }, |
| 3688 | .local_const_comptime_state = .{ | 4121 | .local_const_partially_comptime = .{ |
| 3689 | .tag = .constant, | 4122 | .tag = .constant, |
| 3690 | .attrs = &.{ | 4123 | .attrs = &.{ |
| 3691 | .{ .name, .strp }, | 4124 | .{ .name, .strp }, |
| 3692 | //.{ .type, .ref_addr }, | 4125 | .{ .type, .ref_addr }, |
| 3693 | //.{ .ZIG_comptime_value, .ref_addr }, | 4126 | .{ .const_value, .block }, |
| | 4127 | .{ .ZIG_comptime_value, .ref_addr }, |
| 3694 | }, | 4128 | }, |
| 3695 | }, | 4129 | }, |
| 3696 | .local_const_runtime_bits_comptime_state = .{ | 4130 | .local_const_fully_comptime = .{ |
| 3697 | .tag = .constant, | 4131 | .tag = .constant, |
| 3698 | .attrs = &.{ | 4132 | .attrs = &.{ |
| 3699 | .{ .name, .strp }, | 4133 | .{ .name, .strp }, |
| 3700 | //.{ .type, .ref_addr }, | 4134 | .{ .type, .ref_addr }, |
| 3701 | .{ .const_value, .block }, | 4135 | .{ .ZIG_comptime_value, .ref_addr }, |
| 3702 | //.{ .ZIG_comptime_value, .ref_addr }, | | |
| 3703 | }, | 4136 | }, |
| 3704 | }, | 4137 | }, |
| 3705 | .undefined_comptime_value = .{ | 4138 | .undefined_comptime_value = .{ |