| ... | @@ -10,10 +10,7 @@ consts: std.ArrayList(Const), | ... | @@ -10,10 +10,7 @@ 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, Decl), | 12 | decls: std.array_hash_map.Auto(InternPool.TrackedInst.Index, Decl), |
| 13 | pending_decl: ?struct { | 13 | pending_decl: struct { di: Decl.Index, instance_val: InternPool.Index }, |
| 14 | di: Decl.Index, | | |
| 15 | instance_val: InternPool.Index, | | |
| 16 | }, | | |
| 17 | | 14 | |
| 18 | debug_abbrev: Abbrev, | 15 | debug_abbrev: Abbrev, |
| 19 | frame: Frame, | 16 | frame: Frame, |
| ... | @@ -680,7 +677,7 @@ pub const WipNav = struct { | ... | @@ -680,7 +677,7 @@ pub const WipNav = struct { |
| 680 | const di_nw = &debug.info_writer; | 677 | const di_nw = &debug.info_writer; |
| 681 | const diw = &di_nw.interface; | 678 | const diw = &di_nw.interface; |
| 682 | try diw.writeUleb128(try dwarf.refAbbrevCode(.decl_func)); | 679 | try diw.writeUleb128(try dwarf.refAbbrevCode(.decl_func)); |
| 683 | try dwarf.refConst(pt, di_nw, .fromInterned(ip.namespacePtr(switch (func.generic_owner) { | 680 | try dwarf.refType(pt, di_nw, .fromInterned(ip.namespacePtr(switch (func.generic_owner) { |
| 684 | .none => nav, | 681 | .none => nav, |
| 685 | else => |generic_owner| ip.getNav(zcu.funcInfo(generic_owner).owner_nav), | 682 | else => |generic_owner| ip.getNav(zcu.funcInfo(generic_owner).owner_nav), |
| 686 | }.analysis.?.namespace).owner_type)); | 683 | }.analysis.?.namespace).owner_type)); |
| ... | @@ -692,7 +689,7 @@ pub const WipNav = struct { | ... | @@ -692,7 +689,7 @@ pub const WipNav = struct { |
| 692 | .normal => nav.fqn, | 689 | .normal => nav.fqn, |
| 693 | .@"extern", .@"export" => nav.name, | 690 | .@"extern", .@"export" => nav.name, |
| 694 | }.toSlice(ip)); | 691 | }.toSlice(ip)); |
| 695 | try dwarf.refConst(pt, di_nw, .fromInterned(func_type.return_type)); | 692 | try dwarf.refType(pt, di_nw, .fromInterned(func_type.return_type)); |
| 696 | try dwarf.addrSym(di_nw, debug.wip_nav.func_si, 0); | 693 | try dwarf.addrSym(di_nw, debug.wip_nav.func_si, 0); |
| 697 | debug.info_func_length_offset = diw.end; | 694 | debug.info_func_length_offset = diw.end; |
| 698 | try diw.writeInt(u32, undefined, dwarf.endian); | 695 | try diw.writeInt(u32, undefined, dwarf.endian); |
| ... | @@ -802,7 +799,7 @@ pub const WipNav = struct { | ... | @@ -802,7 +799,7 @@ pub const WipNav = struct { |
| 802 | .local_var => if (opt_name) |_| .local_var else unreachable, | 799 | .local_var => if (opt_name) |_| .local_var else unreachable, |
| 803 | })); | 800 | })); |
| 804 | if (opt_name) |name| try dwarf.strp(&dwarf.debug_str, di_nw, name); | 801 | if (opt_name) |name| try dwarf.strp(&dwarf.debug_str, di_nw, name); |
| 805 | try dwarf.refConst(debug.pt, di_nw, ty.toValue()); | 802 | try dwarf.refType(debug.pt, di_nw, ty); |
| 806 | try dwarf.exprLoc(&debug.info_writer, loc); | 803 | try dwarf.exprLoc(&debug.info_writer, loc); |
| 807 | debug.any_children = true; | 804 | debug.any_children = true; |
| 808 | } | 805 | } |
| ... | @@ -855,7 +852,7 @@ pub const WipNav = struct { | ... | @@ -855,7 +852,7 @@ pub const WipNav = struct { |
| 855 | } else unreachable, | 852 | } else unreachable, |
| 856 | })); | 853 | })); |
| 857 | if (opt_name) |name| try dwarf.strp(&dwarf.debug_str, di_nw, name); | 854 | if (opt_name) |name| try dwarf.strp(&dwarf.debug_str, di_nw, name); |
| 858 | try dwarf.refConst(pt, di_nw, ty.toValue()); | 855 | try dwarf.refType(pt, di_nw, ty); |
| 859 | if (ty_class.hasRuntimeBits()) try dwarf.blockConst(pt, di_nw, val); | 856 | if (ty_class.hasRuntimeBits()) try dwarf.blockConst(pt, di_nw, val); |
| 860 | if (ty_class.comptimeOnly()) try dwarf.refConst(pt, di_nw, val); | 857 | if (ty_class.comptimeOnly()) try dwarf.refConst(pt, di_nw, val); |
| 861 | debug.any_children = true; | 858 | debug.any_children = true; |
| ... | @@ -1251,7 +1248,7 @@ pub fn init(lf: *link.File, format: DW.Format) Dwarf { | ... | @@ -1251,7 +1248,7 @@ pub fn init(lf: *link.File, format: DW.Format) Dwarf { |
| 1251 | .globals = .empty, | 1248 | .globals = .empty, |
| 1252 | .funcs = .empty, | 1249 | .funcs = .empty, |
| 1253 | .decls = .empty, | 1250 | .decls = .empty, |
| 1254 | .pending_decl = null, | 1251 | .pending_decl = .{ .di = undefined, .instance_val = .none }, |
| 1255 | | 1252 | |
| 1256 | .debug_abbrev = .{ | 1253 | .debug_abbrev = .{ |
| 1257 | .ni = .none, | 1254 | .ni = .none, |
| ... | @@ -1457,33 +1454,42 @@ pub fn getFuncIfExists(dwarf: *Dwarf, nav: InternPool.Nav.Index) ?Func.Index { | ... | @@ -1457,33 +1454,42 @@ pub fn getFuncIfExists(dwarf: *Dwarf, nav: InternPool.Nav.Index) ?Func.Index { |
| 1457 | return @fromBackingInt(@intCast(dwarf.funcs.getIndex(nav) orelse return null)); | 1454 | return @fromBackingInt(@intCast(dwarf.funcs.getIndex(nav) orelse return null)); |
| 1458 | } | 1455 | } |
| 1459 | | 1456 | |
| 1460 | pub fn getDeclInst(dwarf: *Dwarf, val: InternPool.Index) ?InternPool.TrackedInst.Index { | 1457 | fn getDeclInst(dwarf: *Dwarf, val: InternPool.Index) ?InternPool.TrackedInst.Index { |
| 1461 | const ip = &dwarf.lf.comp.zcu.?.intern_pool; | 1458 | const ip = &dwarf.lf.comp.zcu.?.intern_pool; |
| 1462 | switch (ip.indexToKey(val)) { | 1459 | switch (ip.indexToKey(val)) { |
| 1463 | else => unreachable, | 1460 | else => unreachable, |
| 1464 | .struct_type => { | 1461 | .struct_type, .union_type, .enum_type, .opaque_type => |container, tag| switch (container) { |
| 1465 | const loaded_struct = ip.loadStructType(val); | 1462 | .declared => |declared| switch (declared.captures.owned.len) { |
| 1466 | if (loaded_struct.captures.len == 0) return null; | 1463 | 0 => return null, |
| 1467 | return ip.getNav(loaded_struct.name_nav.unwrap() orelse | 1464 | else => switch (tag) { |
| 1468 | return loaded_struct.zir_index).srcInst(ip); | 1465 | else => unreachable, |
| 1469 | }, | 1466 | .struct_type => { |
| 1470 | .enum_type => { | 1467 | const loaded_struct = ip.loadStructType(val); |
| 1471 | const loaded_enum = ip.loadEnumType(val); | 1468 | return ip.getNav(loaded_struct.name_nav.unwrap() orelse |
| 1472 | if (loaded_enum.captures.len == 0) return null; | 1469 | return loaded_struct.zir_index).srcInst(ip); |
| 1473 | return ip.getNav(loaded_enum.name_nav.unwrap() orelse | 1470 | }, |
| 1474 | return loaded_enum.zir_index.unwrap().?).srcInst(ip); | 1471 | .union_type => { |
| 1475 | }, | 1472 | const loaded_union = ip.loadUnionType(val); |
| 1476 | .union_type => { | 1473 | return ip.getNav(loaded_union.name_nav.unwrap() orelse |
| 1477 | const loaded_union = ip.loadUnionType(val); | 1474 | return loaded_union.zir_index).srcInst(ip); |
| 1478 | if (loaded_union.captures.len == 0) return null; | 1475 | }, |
| 1479 | return ip.getNav(loaded_union.name_nav.unwrap() orelse | 1476 | .enum_type => { |
| 1480 | return loaded_union.zir_index).srcInst(ip); | 1477 | const loaded_enum = ip.loadEnumType(val); |
| 1481 | }, | 1478 | return ip.getNav(loaded_enum.name_nav.unwrap() orelse |
| 1482 | .opaque_type => { | 1479 | return loaded_enum.zir_index.unwrap().?).srcInst(ip); |
| 1483 | const loaded_opaque = ip.loadOpaqueType(val); | 1480 | }, |
| 1484 | if (loaded_opaque.captures.len == 0) return null; | 1481 | .opaque_type => { |
| 1485 | return ip.getNav(loaded_opaque.name_nav.unwrap() orelse | 1482 | const loaded_opaque = ip.loadOpaqueType(val); |
| 1486 | return loaded_opaque.zir_index).srcInst(ip); | 1483 | return ip.getNav(loaded_opaque.name_nav.unwrap() orelse |
| | 1484 | return loaded_opaque.zir_index).srcInst(ip); |
| | 1485 | }, |
| | 1486 | }, |
| | 1487 | }, |
| | 1488 | .reified => |reified| { |
| | 1489 | assert(reified.zir_index.resolve(ip).? != .main_struct_inst); |
| | 1490 | return reified.zir_index; |
| | 1491 | }, |
| | 1492 | .generated_union_tag => unreachable, |
| 1487 | }, | 1493 | }, |
| 1488 | .func => |func| return ip.getNav(switch (func.generic_owner) { | 1494 | .func => |func| return ip.getNav(switch (func.generic_owner) { |
| 1489 | .none => func.owner_nav, | 1495 | .none => func.owner_nav, |
| ... | @@ -1496,7 +1502,7 @@ pub fn getDecl( | ... | @@ -1496,7 +1502,7 @@ pub fn getDecl( |
| 1496 | pt: Zcu.PerThread, | 1502 | pt: Zcu.PerThread, |
| 1497 | instance_val: InternPool.Index, | 1503 | instance_val: InternPool.Index, |
| 1498 | ) link.Error!MappedFile.Node.Index { | 1504 | ) link.Error!MappedFile.Node.Index { |
| 1499 | assert(dwarf.pending_decl == null); | 1505 | assert(dwarf.pending_decl.instance_val == .none); |
| 1500 | const comp = dwarf.lf.comp; | 1506 | const comp = dwarf.lf.comp; |
| 1501 | const gpa = comp.gpa; | 1507 | const gpa = comp.gpa; |
| 1502 | const zcu = pt.zcu; | 1508 | const zcu = pt.zcu; |
| ... | @@ -2003,13 +2009,15 @@ fn genDeclFuncGeneric( | ... | @@ -2003,13 +2009,15 @@ fn genDeclFuncGeneric( |
| 2003 | name: []const u8, | 2009 | name: []const u8, |
| 2004 | param_body: []const std.zig.Zir.Inst.Index, | 2010 | param_body: []const std.zig.Zir.Inst.Index, |
| 2005 | ) link.EmitError!void { | 2011 | ) link.EmitError!void { |
| | 2012 | const zcu = pt.zcu; |
| 2006 | const diw = &di_nw.interface; | 2013 | const diw = &di_nw.interface; |
| 2007 | try diw.writeUleb128(try dwarf.refAbbrevCode(.decl_func_generic)); | 2014 | try diw.writeUleb128(try dwarf.refAbbrevCode(.decl_func_generic)); |
| 2008 | try dwarf.refConst(pt, di_nw, parent_ty.toValue()); | 2015 | try dwarf.refType(pt, di_nw, parent_ty); |
| 2009 | try diw.writeInt(u32, decl.src_line + 1, dwarf.endian); | 2016 | try diw.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| 2010 | try diw.writeUleb128(decl.src_column + 1); | 2017 | try diw.writeUleb128(decl.src_column + 1); |
| 2011 | try diw.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); | 2018 | try diw.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); |
| 2012 | try dwarf.strp(&dwarf.debug_str, di_nw, name); | 2019 | try dwarf.strp(&dwarf.debug_str, di_nw, name); |
| | 2020 | try dwarf.refType(pt, di_nw, .fromInterned(fn_ty.return_type)); |
| 2013 | var param_index: u32 = 0; | 2021 | var param_index: u32 = 0; |
| 2014 | for (param_body) |param_inst| { | 2022 | for (param_body) |param_inst| { |
| 2015 | switch (zir.getParamName(param_inst) orelse break) { | 2023 | switch (zir.getParamName(param_inst) orelse break) { |
| ... | @@ -2019,7 +2027,7 @@ fn genDeclFuncGeneric( | ... | @@ -2019,7 +2027,7 @@ fn genDeclFuncGeneric( |
| 2019 | try dwarf.strp(&dwarf.debug_str, di_nw, zir.nullTerminatedString(param_name)); | 2027 | try dwarf.strp(&dwarf.debug_str, di_nw, zir.nullTerminatedString(param_name)); |
| 2020 | }, | 2028 | }, |
| 2021 | } | 2029 | } |
| 2022 | try dwarf.refConst(pt, di_nw, .fromInterned(fn_ty.param_types.get(&pt.zcu.intern_pool)[param_index])); | 2030 | try dwarf.refType(pt, di_nw, .fromInterned(fn_ty.param_types.get(&zcu.intern_pool)[param_index])); |
| 2023 | param_index += 1; | 2031 | param_index += 1; |
| 2024 | } | 2032 | } |
| 2025 | if (fn_ty.is_var_args) try diw.writeUleb128(try dwarf.refAbbrevCode(.is_var_args)); | 2033 | if (fn_ty.is_var_args) try diw.writeUleb128(try dwarf.refAbbrevCode(.is_var_args)); |
| ... | @@ -2095,7 +2103,6 @@ fn updateConstInner( | ... | @@ -2095,7 +2103,6 @@ fn updateConstInner( |
| 2095 | const ip = &zcu.intern_pool; | 2103 | const ip = &zcu.intern_pool; |
| 2096 | const diw = &di_nw.interface; | 2104 | const diw = &di_nw.interface; |
| 2097 | switch (ip.indexToKey(val)) { | 2105 | switch (ip.indexToKey(val)) { |
| 2098 | else => return, | | |
| 2099 | .int_type => |int_type| { | 2106 | .int_type => |int_type| { |
| 2100 | const ty: Type = .fromInterned(val); | 2107 | const ty: Type = .fromInterned(val); |
| 2101 | try diw.writeUleb128(try dwarf.refAbbrevCode(.numeric_type)); | 2108 | try diw.writeUleb128(try dwarf.refAbbrevCode(.numeric_type)); |
| ... | @@ -2111,17 +2118,13 @@ fn updateConstInner( | ... | @@ -2111,17 +2118,13 @@ fn updateConstInner( |
| 2111 | }, | 2118 | }, |
| 2112 | .ptr_type => |ptr_type| switch (ptr_type.flags.size) { | 2119 | .ptr_type => |ptr_type| switch (ptr_type.flags.size) { |
| 2113 | .one, .many, .c => { | 2120 | .one, .many, .c => { |
| 2114 | const ty: Type = .fromInterned(val); | 2121 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(val).fmt(pt)}); |
| 2115 | const ptr_child_ty: Type = .fromInterned(ptr_type.child); | 2122 | defer zcu.gpa.free(name); |
| 2116 | try diw.writeUleb128(try dwarf.refAbbrevCode(switch (ptr_type.flags.alignment) { | 2123 | try diw.writeUleb128(try dwarf.refAbbrevCode(switch (ptr_type.flags.alignment) { |
| 2117 | .none => if (ptr_type.sentinel == .none) .ptr_type else .ptr_sentinel_type, | 2124 | .none => if (ptr_type.sentinel == .none) .ptr_type else .ptr_sentinel_type, |
| 2118 | else => if (ptr_type.sentinel == .none) .ptr_aligned_type else .ptr_aligned_sentinel_type, | 2125 | else => if (ptr_type.sentinel == .none) .ptr_aligned_type else .ptr_aligned_sentinel_type, |
| 2119 | })); | 2126 | })); |
| 2120 | { | 2127 | try dwarf.strp(&dwarf.debug_str, di_nw, name); |
| 2121 | const name = try zcu.gpa.print("{f}", .{ty.fmt(pt)}); | | |
| 2122 | defer zcu.gpa.free(name); | | |
| 2123 | try dwarf.strp(&dwarf.debug_str, di_nw, name); | | |
| 2124 | } | | |
| 2125 | if (ptr_type.sentinel != .none) try dwarf.blockConst(pt, di_nw, .fromInterned(ptr_type.sentinel)); | 2128 | if (ptr_type.sentinel != .none) try dwarf.blockConst(pt, di_nw, .fromInterned(ptr_type.sentinel)); |
| 2126 | if (ptr_type.flags.alignment.toByteUnits()) |a| try diw.writeUleb128(a); | 2129 | if (ptr_type.flags.alignment.toByteUnits()) |a| try diw.writeUleb128(a); |
| 2127 | try diw.writeByte(@backingInt(ptr_type.flags.address_space)); | 2130 | try diw.writeByte(@backingInt(ptr_type.flags.address_space)); |
| ... | @@ -2139,31 +2142,181 @@ fn updateConstInner( | ... | @@ -2139,31 +2142,181 @@ fn updateConstInner( |
| 2139 | ); | 2142 | ); |
| 2140 | } | 2143 | } |
| 2141 | if (ptr_type.flags.is_volatile) try diw.writeUleb128(try dwarf.refAbbrevCode(.is_volatile)); | 2144 | if (ptr_type.flags.is_volatile) try diw.writeUleb128(try dwarf.refAbbrevCode(.is_volatile)); |
| 2142 | try dwarf.refConst(pt, di_nw, ptr_child_ty.toValue()); | 2145 | try dwarf.refType(pt, di_nw, .fromInterned(ptr_type.child)); |
| 2143 | }, | 2146 | }, |
| 2144 | .slice => { | 2147 | .slice => { |
| 2145 | const ty: Type = .fromInterned(val); | 2148 | const ty: Type = .fromInterned(val); |
| | 2149 | const name = try zcu.gpa.print("{f}", .{ty.fmt(pt)}); |
| | 2150 | defer zcu.gpa.free(name); |
| 2146 | try diw.writeUleb128(try dwarf.refAbbrevCode(.generated_struct_type)); | 2151 | try diw.writeUleb128(try dwarf.refAbbrevCode(.generated_struct_type)); |
| 2147 | { | 2152 | try dwarf.strp(&dwarf.debug_str, di_nw, name); |
| 2148 | const name = try zcu.gpa.print("{f}", .{ty.fmt(pt)}); | | |
| 2149 | defer zcu.gpa.free(name); | | |
| 2150 | try dwarf.strp(&dwarf.debug_str, di_nw, name); | | |
| 2151 | } | | |
| 2152 | try diw.writeUleb128(ty.abiSize(zcu)); | 2153 | try diw.writeUleb128(ty.abiSize(zcu)); |
| 2153 | try diw.writeUleb128(ty.abiAlignment(zcu).toByteUnits().?); | 2154 | try diw.writeUleb128(ty.abiAlignment(zcu).toByteUnits().?); |
| 2154 | try diw.writeUleb128(try dwarf.refAbbrevCode(.generated_field)); | 2155 | try diw.writeUleb128(try dwarf.refAbbrevCode(.generated_field)); |
| 2155 | try dwarf.strp(&dwarf.debug_str, di_nw, "ptr"); | 2156 | try dwarf.strp(&dwarf.debug_str, di_nw, "ptr"); |
| 2156 | const ptr_field_ty = ty.slicePtrFieldType(zcu); | 2157 | const ptr_field_ty = ty.slicePtrFieldType(zcu); |
| 2157 | try dwarf.refConst(pt, di_nw, ptr_field_ty.toValue()); | 2158 | try dwarf.refType(pt, di_nw, ptr_field_ty); |
| 2158 | try diw.writeUleb128(0); | 2159 | try diw.writeUleb128(0); |
| 2159 | try diw.writeUleb128(try dwarf.refAbbrevCode(.generated_field)); | 2160 | try diw.writeUleb128(try dwarf.refAbbrevCode(.generated_field)); |
| 2160 | try dwarf.strp(&dwarf.debug_str, di_nw, "len"); | 2161 | try dwarf.strp(&dwarf.debug_str, di_nw, "len"); |
| 2161 | const len_field_ty: Type = .usize; | 2162 | const len_field_ty: Type = .usize; |
| 2162 | try dwarf.refConst(pt, di_nw, len_field_ty.toValue()); | 2163 | try dwarf.refType(pt, di_nw, len_field_ty); |
| 2163 | try diw.writeUleb128(len_field_ty.abiAlignment(zcu).forward(ptr_field_ty.abiSize(zcu))); | 2164 | try diw.writeUleb128(len_field_ty.abiAlignment(zcu).forward(ptr_field_ty.abiSize(zcu))); |
| 2164 | try diw.writeUleb128(@backingInt(AbbrevCode.null)); | 2165 | try diw.writeUleb128(@backingInt(AbbrevCode.null)); |
| 2165 | }, | 2166 | }, |
| 2166 | }, | 2167 | }, |
| | 2168 | .array_type => |array_type| { |
| | 2169 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(val).fmt(pt)}); |
| | 2170 | defer zcu.gpa.free(name); |
| | 2171 | try diw.writeUleb128(try dwarf.refAbbrevCode( |
| | 2172 | if (array_type.sentinel == .none) .array_type else .array_sentinel_type, |
| | 2173 | )); |
| | 2174 | try dwarf.strp(&dwarf.debug_str, di_nw, name); |
| | 2175 | if (array_type.sentinel != .none) |
| | 2176 | try dwarf.blockConst(pt, di_nw, .fromInterned(array_type.sentinel)); |
| | 2177 | try dwarf.refType(pt, di_nw, .fromInterned(array_type.child)); |
| | 2178 | try diw.writeUleb128(try dwarf.refAbbrevCode(.array_len)); |
| | 2179 | try dwarf.refType(pt, di_nw, .usize); |
| | 2180 | try diw.writeUleb128(array_type.len); |
| | 2181 | try diw.writeUleb128(@backingInt(AbbrevCode.null)); |
| | 2182 | }, |
| | 2183 | .vector_type => |vector_type| { |
| | 2184 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(val).fmt(pt)}); |
| | 2185 | defer zcu.gpa.free(name); |
| | 2186 | try diw.writeUleb128(try dwarf.refAbbrevCode(.vector_type)); |
| | 2187 | try dwarf.strp(&dwarf.debug_str, di_nw, name); |
| | 2188 | try dwarf.refType(pt, di_nw, .fromInterned(vector_type.child)); |
| | 2189 | try diw.writeUleb128(try dwarf.refAbbrevCode(.array_len)); |
| | 2190 | try dwarf.refType(pt, di_nw, .usize); |
| | 2191 | try diw.writeUleb128(vector_type.len); |
| | 2192 | try diw.writeUleb128(@backingInt(AbbrevCode.null)); |
| | 2193 | }, |
| | 2194 | .opt_type => |opt_child_type_index| { |
| | 2195 | const opt_ty: Type = .fromInterned(val); |
| | 2196 | const opt_child_ty: Type = .fromInterned(opt_child_type_index); |
| | 2197 | const opt_repr = optRepr(opt_child_ty, zcu); |
| | 2198 | const name = try zcu.gpa.print("{f}", .{opt_ty.fmt(pt)}); |
| | 2199 | defer zcu.gpa.free(name); |
| | 2200 | try diw.writeUleb128(try dwarf.refAbbrevCode(.generated_union_type)); |
| | 2201 | try dwarf.strp(&dwarf.debug_str, di_nw, name); |
| | 2202 | try diw.writeUleb128(opt_ty.abiSize(zcu)); |
| | 2203 | try diw.writeUleb128(opt_ty.abiAlignment(zcu).toByteUnits().?); |
| | 2204 | switch (opt_repr) { |
| | 2205 | .opv_null => { |
| | 2206 | try diw.writeUleb128(try dwarf.refAbbrevCode(.generated_field)); |
| | 2207 | try dwarf.strp(&dwarf.debug_str, di_nw, "null"); |
| | 2208 | try dwarf.refType(pt, di_nw, .null); |
| | 2209 | try diw.writeUleb128(0); |
| | 2210 | }, |
| | 2211 | .unpacked, .error_set, .pointer => { |
| | 2212 | try diw.writeUleb128(try dwarf.refAbbrevCode(.tagged_union)); |
| | 2213 | try dwarf.secOffset(di_nw, di_nw.ni, diw.end + dwarf.secOffsetSize()); |
| | 2214 | { |
| | 2215 | try diw.writeUleb128(try dwarf.refAbbrevCode(.generated_field)); |
| | 2216 | try dwarf.strp(&dwarf.debug_str, di_nw, "has_value"); |
| | 2217 | switch (opt_repr) { |
| | 2218 | .opv_null => unreachable, |
| | 2219 | .unpacked => { |
| | 2220 | try dwarf.refType(pt, di_nw, .bool); |
| | 2221 | try diw.writeUleb128(if (opt_child_ty.hasRuntimeBits(zcu)) |
| | 2222 | opt_child_ty.abiSize(zcu) |
| | 2223 | else |
| | 2224 | 0); |
| | 2225 | }, |
| | 2226 | .error_set => { |
| | 2227 | try dwarf.refType(pt, di_nw, try pt.intType(.unsigned, zcu.errorSetBits())); |
| | 2228 | try diw.writeUleb128(0); |
| | 2229 | }, |
| | 2230 | .pointer => { |
| | 2231 | try dwarf.refType(pt, di_nw, .usize); |
| | 2232 | try diw.writeUleb128(0); |
| | 2233 | }, |
| | 2234 | } |
| | 2235 | |
| | 2236 | try diw.writeUleb128(try dwarf.refAbbrevCode(.tagged_union_field)); |
| | 2237 | try diw.writeUleb128(DW.FORM.data1); |
| | 2238 | try diw.writeByte(0); |
| | 2239 | { |
| | 2240 | try diw.writeUleb128(try dwarf.refAbbrevCode(.generated_field)); |
| | 2241 | try dwarf.strp(&dwarf.debug_str, di_nw, "null"); |
| | 2242 | try dwarf.refType(pt, di_nw, .null); |
| | 2243 | try diw.writeUleb128(0); |
| | 2244 | } |
| | 2245 | try diw.writeUleb128(@backingInt(AbbrevCode.null)); |
| | 2246 | |
| | 2247 | try diw.writeUleb128(try dwarf.refAbbrevCode(.tagged_union_default_field)); |
| | 2248 | { |
| | 2249 | try diw.writeUleb128(try dwarf.refAbbrevCode(.generated_field)); |
| | 2250 | try dwarf.strp(&dwarf.debug_str, di_nw, "?"); |
| | 2251 | try dwarf.refType(pt, di_nw, opt_child_ty); |
| | 2252 | try diw.writeUleb128(0); |
| | 2253 | } |
| | 2254 | try diw.writeUleb128(@backingInt(AbbrevCode.null)); |
| | 2255 | } |
| | 2256 | try diw.writeUleb128(@backingInt(AbbrevCode.null)); |
| | 2257 | }, |
| | 2258 | } |
| | 2259 | try diw.writeUleb128(@backingInt(AbbrevCode.null)); |
| | 2260 | }, |
| | 2261 | .anyframe_type => unreachable, |
| | 2262 | .error_union_type => |error_union_type| { |
| | 2263 | const eu_ty: Type = .fromInterned(val); |
| | 2264 | const eu_error_set_ty: Type = .fromInterned(error_union_type.error_set_type); |
| | 2265 | const eu_payload_ty: Type = .fromInterned(error_union_type.payload_type); |
| | 2266 | const eu_error_set_offset, const eu_payload_offset = switch (error_union_type.payload_type) { |
| | 2267 | .generic_poison_type => .{ 0, 0 }, |
| | 2268 | else => .{ |
| | 2269 | codegen.errUnionErrorOffset(eu_payload_ty, zcu), |
| | 2270 | codegen.errUnionPayloadOffset(eu_payload_ty, zcu), |
| | 2271 | }, |
| | 2272 | }; |
| | 2273 | const name = try zcu.gpa.print("{f}", .{eu_ty.fmt(pt)}); |
| | 2274 | defer zcu.gpa.free(name); |
| | 2275 | |
| | 2276 | try diw.writeUleb128(try dwarf.refAbbrevCode(.generated_union_type)); |
| | 2277 | try dwarf.strp(&dwarf.debug_str, di_nw, name); |
| | 2278 | if (error_union_type.error_set_type != .generic_poison_type and |
| | 2279 | error_union_type.payload_type != .generic_poison_type) |
| | 2280 | { |
| | 2281 | try diw.writeUleb128(eu_ty.abiSize(zcu)); |
| | 2282 | try diw.writeUleb128(eu_ty.abiAlignment(zcu).toByteUnits().?); |
| | 2283 | } else { |
| | 2284 | try diw.writeUleb128(0); |
| | 2285 | try diw.writeUleb128(1); |
| | 2286 | } |
| | 2287 | { |
| | 2288 | try diw.writeUleb128(try dwarf.refAbbrevCode(.tagged_union)); |
| | 2289 | try dwarf.secOffset(di_nw, di_nw.ni, diw.end + dwarf.secOffsetSize()); |
| | 2290 | { |
| | 2291 | try diw.writeUleb128(try dwarf.refAbbrevCode(.generated_field)); |
| | 2292 | try dwarf.strp(&dwarf.debug_str, di_nw, "is_error"); |
| | 2293 | try dwarf.refType(pt, di_nw, try pt.intType(.unsigned, zcu.errorSetBits())); |
| | 2294 | try diw.writeUleb128(eu_error_set_offset); |
| | 2295 | |
| | 2296 | try diw.writeUleb128(try dwarf.refAbbrevCode(.tagged_union_field)); |
| | 2297 | try diw.writeUleb128(DW.FORM.udata); |
| | 2298 | try diw.writeUleb128(0); |
| | 2299 | { |
| | 2300 | try diw.writeUleb128(try dwarf.refAbbrevCode(.generated_field)); |
| | 2301 | try dwarf.strp(&dwarf.debug_str, di_nw, "value"); |
| | 2302 | try dwarf.refType(pt, di_nw, eu_payload_ty); |
| | 2303 | try diw.writeUleb128(eu_payload_offset); |
| | 2304 | } |
| | 2305 | try diw.writeUleb128(@backingInt(AbbrevCode.null)); |
| | 2306 | |
| | 2307 | try diw.writeUleb128(try dwarf.refAbbrevCode(.tagged_union_default_field)); |
| | 2308 | { |
| | 2309 | try diw.writeUleb128(try dwarf.refAbbrevCode(.generated_field)); |
| | 2310 | try dwarf.strp(&dwarf.debug_str, di_nw, "error"); |
| | 2311 | try dwarf.refType(pt, di_nw, eu_error_set_ty); |
| | 2312 | try diw.writeUleb128(eu_error_set_offset); |
| | 2313 | } |
| | 2314 | try diw.writeUleb128(@backingInt(AbbrevCode.null)); |
| | 2315 | } |
| | 2316 | try diw.writeUleb128(@backingInt(AbbrevCode.null)); |
| | 2317 | } |
| | 2318 | try diw.writeUleb128(@backingInt(AbbrevCode.null)); |
| | 2319 | }, |
| 2167 | .simple_type => |simple_type| switch (simple_type) { | 2320 | .simple_type => |simple_type| switch (simple_type) { |
| 2168 | .f16, | 2321 | .f16, |
| 2169 | .f32, | 2322 | .f32, |
| ... | @@ -2220,25 +2373,315 @@ fn updateConstInner( | ... | @@ -2220,25 +2373,315 @@ fn updateConstInner( |
| 2220 | var name_buf: ["@TypeOf(undefined)".len]u8 = undefined; | 2373 | var name_buf: ["@TypeOf(undefined)".len]u8 = undefined; |
| 2221 | try dwarf.strp(&dwarf.debug_str, di_nw, std.mem.print(&name_buf, "{f}", .{ty.fmt(pt)}) catch unreachable); | 2374 | try dwarf.strp(&dwarf.debug_str, di_nw, std.mem.print(&name_buf, "{f}", .{ty.fmt(pt)}) catch unreachable); |
| 2222 | }, | 2375 | }, |
| 2223 | .anyerror => return, | 2376 | .anyerror => { |
| | 2377 | const global_error_set_names = ip.global_error_set.getNamesFromMainThread(); |
| | 2378 | try diw.writeUleb128(try dwarf.refAbbrevCode( |
| | 2379 | if (global_error_set_names.len > 0) .generated_enum_type else .generated_empty_enum_type, |
| | 2380 | )); |
| | 2381 | try dwarf.strp(&dwarf.debug_str, di_nw, "anyerror"); |
| | 2382 | try dwarf.refType(pt, di_nw, try pt.intType(.unsigned, zcu.errorSetBits())); |
| | 2383 | for (global_error_set_names, 1..) |name, value| { |
| | 2384 | try diw.writeUleb128(try dwarf.refAbbrevCode(.enum_field)); |
| | 2385 | try diw.writeUleb128(DW.FORM.udata); |
| | 2386 | try diw.writeUleb128(value); |
| | 2387 | try dwarf.strp(&dwarf.debug_str, di_nw, name.toSlice(ip)); |
| | 2388 | } |
| | 2389 | if (global_error_set_names.len > 0) try diw.writeUleb128(@backingInt(AbbrevCode.null)); |
| | 2390 | }, |
| 2224 | .adhoc_inferred_error_set => unreachable, | 2391 | .adhoc_inferred_error_set => unreachable, |
| 2225 | }, | 2392 | }, |
| | 2393 | .tuple_type => |tuple_type| { |
| | 2394 | const ty: Type = .fromInterned(val); |
| | 2395 | const name = try zcu.gpa.print("{f}", .{ty.fmt(pt)}); |
| | 2396 | defer zcu.gpa.free(name); |
| | 2397 | if (tuple_type.types.len == 0) { |
| | 2398 | try diw.writeUleb128(try dwarf.refAbbrevCode(.generated_empty_struct_type)); |
| | 2399 | try dwarf.strp(&dwarf.debug_str, di_nw, name); |
| | 2400 | try diw.writeByte(@intFromBool(false)); |
| | 2401 | } else { |
| | 2402 | try diw.writeUleb128(try dwarf.refAbbrevCode(.generated_struct_type)); |
| | 2403 | try dwarf.strp(&dwarf.debug_str, di_nw, name); |
| | 2404 | try diw.writeUleb128(ty.abiSize(zcu)); |
| | 2405 | try diw.writeUleb128(ty.abiAlignment(zcu).toByteUnits().?); |
| | 2406 | var field_byte_offset: u64 = 0; |
| | 2407 | for (0..tuple_type.types.len) |field_index| { |
| | 2408 | const comptime_value = tuple_type.values.get(ip)[field_index]; |
| | 2409 | const field_ty: Type = .fromInterned(tuple_type.types.get(ip)[field_index]); |
| | 2410 | const comptime_value_class = switch (comptime_value) { |
| | 2411 | .none => .no_possible_value, |
| | 2412 | else => field_ty.classify(zcu), |
| | 2413 | }; |
| | 2414 | try diw.writeUleb128(try dwarf.refAbbrevCode(switch (comptime_value) { |
| | 2415 | .none => .field, |
| | 2416 | else => switch (comptime_value_class) { |
| | 2417 | .no_possible_value, .one_possible_value => .field_comptime, |
| | 2418 | .runtime => .field_comptime_fully_runtime, |
| | 2419 | .partially_comptime => .field_comptime_partially_comptime, |
| | 2420 | .fully_comptime => .field_comptime_fully_comptime, |
| | 2421 | }, |
| | 2422 | })); |
| | 2423 | var field_name_buf: [std.fmt.count("{d}", .{std.math.maxInt(u32)})]u8 = undefined; |
| | 2424 | try dwarf.strp( |
| | 2425 | &dwarf.debug_str, |
| | 2426 | di_nw, |
| | 2427 | std.mem.print(&field_name_buf, "{d}", .{field_index}) catch unreachable, |
| | 2428 | ); |
| | 2429 | try dwarf.refType(pt, di_nw, field_ty); |
| | 2430 | if (comptime_value == .none) { |
| | 2431 | const field_align = field_ty.abiAlignment(zcu); |
| | 2432 | field_byte_offset = field_align.forward(field_byte_offset); |
| | 2433 | try diw.writeUleb128(field_byte_offset); |
| | 2434 | try diw.writeUleb128(field_ty.abiAlignment(zcu).toByteUnits().?); |
| | 2435 | field_byte_offset += field_ty.abiSize(zcu); |
| | 2436 | } |
| | 2437 | if (comptime_value_class.hasRuntimeBits()) |
| | 2438 | try dwarf.blockConst(pt, di_nw, .fromInterned(comptime_value)); |
| | 2439 | if (comptime_value_class.comptimeOnly()) |
| | 2440 | try dwarf.refConst(pt, di_nw, .fromInterned(comptime_value)); |
| | 2441 | } |
| | 2442 | try diw.writeUleb128(@backingInt(AbbrevCode.null)); |
| | 2443 | } |
| | 2444 | }, |
| 2226 | .struct_type => { | 2445 | .struct_type => { |
| 2227 | const loaded_struct = ip.loadStructType(val); | 2446 | const loaded_struct = ip.loadStructType(val); |
| 2228 | const zfi = loaded_struct.zir_index.resolveFile(ip); | 2447 | const zfi = loaded_struct.zir_index.resolveFile(ip); |
| 2229 | const zf = zcu.fileByIndex(zfi); | 2448 | const zf = zcu.fileByIndex(zfi); |
| | 2449 | const src_inst = loaded_struct.zir_index.resolve(ip); |
| | 2450 | if (src_inst == .main_struct_inst) { |
| | 2451 | assert(loaded_struct.captures.len == 0); |
| | 2452 | const ui = dwarf.getUnit(zf.mod.?); |
| | 2453 | _, const fi = try ui.get(dwarf).getFile(zcu.gpa, ui, zfi); |
| | 2454 | try diw.writeUleb128(try dwarf.refAbbrevCode(switch (loaded_struct.layout) { |
| | 2455 | .auto => if (loaded_struct.field_types.len > 0) .file else .empty_file, |
| | 2456 | .@"extern", .@"packed" => unreachable, |
| | 2457 | })); |
| | 2458 | try diw.writeUleb128(@backingInt(fi)); |
| | 2459 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_struct.name.toSlice(ip)); |
| | 2460 | } else if (loaded_struct.captures.len > 0 or loaded_struct.is_reified) { |
| | 2461 | try diw.writeUleb128(try dwarf.refAbbrevCode( |
| | 2462 | if (loaded_struct.captures.len > 0 or loaded_struct.field_types.len > 0) switch (loaded_struct.layout) { |
| | 2463 | .auto, .@"extern" => .decl_instance_struct, |
| | 2464 | .@"packed" => .decl_instance_packed_struct, |
| | 2465 | } else switch (loaded_struct.layout) { |
| | 2466 | .auto, .@"extern" => .decl_instance_empty_struct, |
| | 2467 | .@"packed" => .decl_instance_empty_packed_struct, |
| | 2468 | }, |
| | 2469 | )); |
| | 2470 | try dwarf.secOffset(di_nw, try dwarf.getDecl(pt, val), 0); |
| | 2471 | } else if (loaded_struct.name_nav.unwrap()) |name_ni| { |
| | 2472 | const name_nav = ip.getNav(name_ni); |
| | 2473 | const decl = zf.zir.?.getDeclaration(name_nav.srcInst(ip).resolve(ip).?); |
| | 2474 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( |
| | 2475 | name_nav.analysis.?.namespace, |
| | 2476 | ).owner_type); |
| | 2477 | try diw.writeUleb128(try dwarf.refAbbrevCode(switch (loaded_struct.layout) { |
| | 2478 | .auto, .@"extern" => if (loaded_struct.field_types.len > 0) .decl_struct else .decl_empty_struct, |
| | 2479 | .@"packed" => if (loaded_struct.field_types.len > 0) .decl_packed_struct else .decl_empty_packed_struct, |
| | 2480 | })); |
| | 2481 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| | 2482 | try diw.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| | 2483 | try diw.writeUleb128(decl.src_column + 1); |
| | 2484 | try diw.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); |
| | 2485 | try dwarf.strp(&dwarf.debug_str, di_nw, name_nav.name.toSlice(ip)); |
| | 2486 | } else { |
| | 2487 | const decl = zf.zir.?.getStructDecl(src_inst.?); |
| | 2488 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( |
| | 2489 | ip.namespacePtr(loaded_struct.namespace).parent.unwrap().?, |
| | 2490 | ).owner_type); |
| | 2491 | try diw.writeUleb128(try dwarf.refAbbrevCode(switch (loaded_struct.layout) { |
| | 2492 | .auto, .@"extern" => if (loaded_struct.field_types.len > 0) .type_decl_struct else .type_decl_empty_struct, |
| | 2493 | .@"packed" => if (loaded_struct.field_types.len > 0) .type_decl_packed_struct else .type_decl_empty_packed_struct, |
| | 2494 | })); |
| | 2495 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| | 2496 | try diw.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| | 2497 | try diw.writeUleb128(decl.src_column + 1); |
| | 2498 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_struct.name.toSlice(ip)); |
| | 2499 | } |
| 2230 | switch (loaded_struct.layout) { | 2500 | switch (loaded_struct.layout) { |
| 2231 | .auto, .@"extern" => { | 2501 | .auto, .@"extern" => { |
| 2232 | const struct_is_file = loaded_struct.zir_index.resolve(ip) == .main_struct_inst; | 2502 | const ty: Type = .fromInterned(val); |
| 2233 | if (loaded_struct.name_nav.unwrap()) |name_ni| { | 2503 | try diw.writeUleb128(ty.abiSize(zcu)); |
| 2234 | assert(!struct_is_file); | 2504 | try diw.writeUleb128(ty.abiAlignment(zcu).toByteUnits().?); |
| | 2505 | try dwarf.genCaptures(pt, di_nw, loaded_struct.captures); |
| | 2506 | for (0..loaded_struct.field_types.len) |field_index| { |
| | 2507 | const is_comptime = loaded_struct.field_is_comptime_bits.get(ip, field_index); |
| | 2508 | // TODO: we currently don't emit information about default values for |
| | 2509 | // non-`comptime` fields, because these default values are resolved at a |
| | 2510 | // separate time in the compiler frontend. To emit this information, the |
| | 2511 | // frontend needs to tell us when the default values are available: like |
| | 2512 | // how `Zcu.PerThread.ensureTypeLayoutUpToDate` enqueues a link task to |
| | 2513 | // indicate completion of the type's layout, a task should be enqueued |
| | 2514 | // by `Zcu.PerThread.ensureStructDefaultsUpToDate`, and upon receiving |
| | 2515 | // it we should patch the correct default field values in. |
| | 2516 | const field_default: InternPool.Index = |
| | 2517 | if (is_comptime) loaded_struct.field_defaults.getOrNone(ip, field_index) else .none; |
| | 2518 | assert(!(is_comptime and field_default == .none)); |
| | 2519 | const field_ty: Type = .fromInterned(loaded_struct.field_types.get(ip)[field_index]); |
| | 2520 | const field_default_class = switch (field_default) { |
| | 2521 | .none => .no_possible_value, |
| | 2522 | else => field_ty.classify(zcu), |
| | 2523 | }; |
| | 2524 | try diw.writeUleb128(try dwarf.refAbbrevCode(switch (field_default_class) { |
| | 2525 | .no_possible_value, .one_possible_value => if (is_comptime) .field_comptime else .field, |
| | 2526 | .runtime => if (is_comptime) .field_comptime_fully_runtime else .field_default_fully_runtime, |
| | 2527 | .partially_comptime => if (is_comptime) .field_comptime_partially_comptime else .field_default_partially_comptime, |
| | 2528 | .fully_comptime => if (is_comptime) .field_comptime_fully_comptime else .field_default_fully_comptime, |
| | 2529 | })); |
| | 2530 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_struct.field_names.get(ip)[field_index].toSlice(ip)); |
| | 2531 | try dwarf.refType(pt, di_nw, field_ty); |
| | 2532 | if (!is_comptime) { |
| | 2533 | try diw.writeUleb128(loaded_struct.field_offsets.get(ip)[field_index]); |
| | 2534 | try diw.writeUleb128(loaded_struct.field_aligns.getOrNone(ip, field_index).toByteUnits() orelse |
| | 2535 | field_ty.abiAlignment(zcu).toByteUnits().?); |
| | 2536 | } |
| | 2537 | if (field_default_class.hasRuntimeBits()) |
| | 2538 | try dwarf.blockConst(pt, di_nw, .fromInterned(field_default)); |
| | 2539 | if (field_default_class.comptimeOnly()) |
| | 2540 | try dwarf.refConst(pt, di_nw, .fromInterned(field_default)); |
| | 2541 | } |
| | 2542 | }, |
| | 2543 | .@"packed" => { |
| | 2544 | try dwarf.refType(pt, di_nw, .fromInterned(loaded_struct.packed_backing_int_type)); |
| | 2545 | try dwarf.genCaptures(pt, di_nw, loaded_struct.captures); |
| | 2546 | var field_bit_offset: u16 = 0; |
| | 2547 | for (0..loaded_struct.field_types.len) |field_index| { |
| | 2548 | try diw.writeUleb128(try dwarf.refAbbrevCode(.packed_field)); |
| | 2549 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_struct.field_names.get(ip)[field_index].toSlice(ip)); |
| | 2550 | const field_ty: Type = .fromInterned(loaded_struct.field_types.get(ip)[field_index]); |
| | 2551 | try dwarf.refType(pt, di_nw, field_ty); |
| | 2552 | try diw.writeUleb128(field_bit_offset); |
| | 2553 | field_bit_offset += @intCast(field_ty.bitSize(zcu)); |
| | 2554 | } |
| | 2555 | }, |
| | 2556 | } |
| | 2557 | if (loaded_struct.captures.len > 0 or loaded_struct.field_types.len > 0) |
| | 2558 | try diw.writeUleb128(@backingInt(AbbrevCode.null)); |
| | 2559 | }, |
| | 2560 | .union_type => { |
| | 2561 | const loaded_union = ip.loadUnionType(val); |
| | 2562 | const loaded_tag = ip.loadEnumType(loaded_union.enum_tag_type); |
| | 2563 | const zfi = loaded_union.zir_index.resolveFile(ip); |
| | 2564 | const zf = zcu.fileByIndex(zfi); |
| | 2565 | if (loaded_union.captures.len > 0 or loaded_union.is_reified) { |
| | 2566 | try diw.writeUleb128(try dwarf.refAbbrevCode( |
| | 2567 | if (loaded_union.captures.len > 0 or loaded_union.field_types.len > 0) switch (loaded_union.layout) { |
| | 2568 | .auto, .@"extern" => .decl_instance_union, |
| | 2569 | .@"packed" => .decl_instance_packed_union, |
| | 2570 | } else switch (loaded_union.layout) { |
| | 2571 | .auto, .@"extern" => .decl_instance_empty_union, |
| | 2572 | .@"packed" => .decl_instance_empty_packed_union, |
| | 2573 | }, |
| | 2574 | )); |
| | 2575 | try dwarf.secOffset(di_nw, try dwarf.getDecl(pt, val), 0); |
| | 2576 | } else if (loaded_union.name_nav.unwrap()) |name_ni| { |
| | 2577 | const name_nav = ip.getNav(name_ni); |
| | 2578 | const decl = zf.zir.?.getDeclaration(name_nav.srcInst(ip).resolve(ip).?); |
| | 2579 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( |
| | 2580 | name_nav.analysis.?.namespace, |
| | 2581 | ).owner_type); |
| | 2582 | try diw.writeUleb128(try dwarf.refAbbrevCode(switch (loaded_union.layout) { |
| | 2583 | .auto, .@"extern" => if (loaded_union.field_types.len > 0) .decl_union else .decl_empty_union, |
| | 2584 | .@"packed" => if (loaded_union.field_types.len > 0) .decl_packed_union else .decl_empty_packed_union, |
| | 2585 | })); |
| | 2586 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| | 2587 | try diw.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| | 2588 | try diw.writeUleb128(decl.src_column + 1); |
| | 2589 | try diw.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); |
| | 2590 | try dwarf.strp(&dwarf.debug_str, di_nw, name_nav.name.toSlice(ip)); |
| | 2591 | } else { |
| | 2592 | const decl = zf.zir.?.getUnionDecl(loaded_union.zir_index.resolve(ip).?); |
| | 2593 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( |
| | 2594 | ip.namespacePtr(loaded_union.namespace).parent.unwrap().?, |
| | 2595 | ).owner_type); |
| | 2596 | try diw.writeUleb128(try dwarf.refAbbrevCode(switch (loaded_union.layout) { |
| | 2597 | .auto, .@"extern" => if (loaded_union.field_types.len > 0) .type_decl_union else .type_decl_empty_union, |
| | 2598 | .@"packed" => if (loaded_union.field_types.len > 0) .type_decl_packed_union else .type_decl_empty_packed_union, |
| | 2599 | })); |
| | 2600 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| | 2601 | try diw.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| | 2602 | try diw.writeUleb128(decl.src_column + 1); |
| | 2603 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_union.name.toSlice(ip)); |
| | 2604 | } |
| | 2605 | switch (loaded_union.layout) { |
| | 2606 | .auto, .@"extern" => { |
| | 2607 | const union_layout = Type.getUnionLayout(loaded_union, zcu); |
| | 2608 | try diw.writeUleb128(union_layout.abi_size); |
| | 2609 | try diw.writeUleb128(union_layout.abi_align.toByteUnits().?); |
| | 2610 | try dwarf.genCaptures(pt, di_nw, loaded_union.captures); |
| | 2611 | if (loaded_union.has_runtime_tag) { |
| | 2612 | try diw.writeUleb128(try dwarf.refAbbrevCode(.tagged_union)); |
| | 2613 | try dwarf.secOffset(di_nw, di_nw.ni, diw.end + dwarf.secOffsetSize()); |
| | 2614 | { |
| | 2615 | try diw.writeUleb128(try dwarf.refAbbrevCode(.generated_field)); |
| | 2616 | try dwarf.strp(&dwarf.debug_str, di_nw, "tag"); |
| | 2617 | try dwarf.refType(pt, di_nw, .fromInterned(loaded_union.enum_tag_type)); |
| | 2618 | try diw.writeUleb128(union_layout.tagOffset()); |
| | 2619 | |
| | 2620 | for (0..loaded_union.field_types.len) |field_index| { |
| | 2621 | try diw.writeUleb128(try dwarf.refAbbrevCode(.tagged_union_field)); |
| | 2622 | try dwarf.enumConstValue(diw, loaded_tag, field_index); |
| | 2623 | { |
| | 2624 | try diw.writeUleb128(try dwarf.refAbbrevCode(.field)); |
| | 2625 | try dwarf.strp( |
| | 2626 | &dwarf.debug_str, |
| | 2627 | di_nw, |
| | 2628 | loaded_tag.field_names.get(ip)[field_index].toSlice(ip), |
| | 2629 | ); |
| | 2630 | const field_ty: Type = .fromInterned(loaded_union.field_types.get(ip)[field_index]); |
| | 2631 | try dwarf.refType(pt, di_nw, field_ty); |
| | 2632 | try diw.writeUleb128(union_layout.payloadOffset()); |
| | 2633 | try diw.writeUleb128(loaded_union.field_aligns.getOrNone(ip, field_index).toByteUnits() orelse |
| | 2634 | if (field_ty.isNoReturn(zcu)) 1 else field_ty.abiAlignment(zcu).toByteUnits().?); |
| | 2635 | } |
| | 2636 | try diw.writeUleb128(@backingInt(AbbrevCode.null)); |
| | 2637 | } |
| | 2638 | } |
| | 2639 | try diw.writeUleb128(@backingInt(AbbrevCode.null)); |
| | 2640 | } else for (0..loaded_union.field_types.len) |field_index| { |
| | 2641 | try diw.writeUleb128(try dwarf.refAbbrevCode(.field)); |
| | 2642 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_tag.field_names.get(ip)[field_index].toSlice(ip)); |
| | 2643 | const field_ty: Type = .fromInterned(loaded_union.field_types.get(ip)[field_index]); |
| | 2644 | try dwarf.refType(pt, di_nw, field_ty); |
| | 2645 | try diw.writeUleb128(0); |
| | 2646 | try diw.writeUleb128(loaded_union.field_aligns.getOrNone(ip, field_index).toByteUnits() orelse |
| | 2647 | if (field_ty.isNoReturn(zcu)) 1 else field_ty.abiAlignment(zcu).toByteUnits().?); |
| | 2648 | } |
| | 2649 | }, |
| | 2650 | .@"packed" => { |
| | 2651 | try dwarf.refType(pt, di_nw, .fromInterned(loaded_union.packed_backing_int_type)); |
| | 2652 | for (0..loaded_union.field_types.len) |field_index| { |
| | 2653 | try diw.writeUleb128(try dwarf.refAbbrevCode(.packed_field)); |
| | 2654 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_tag.field_names.get(ip)[field_index].toSlice(ip)); |
| | 2655 | try dwarf.refType(pt, di_nw, .fromInterned(loaded_union.field_types.get(ip)[field_index])); |
| | 2656 | try diw.writeUleb128(0); |
| | 2657 | } |
| | 2658 | }, |
| | 2659 | } |
| | 2660 | if (loaded_union.captures.len > 0 or loaded_union.field_types.len > 0) |
| | 2661 | try diw.writeUleb128(@backingInt(AbbrevCode.null)); |
| | 2662 | }, |
| | 2663 | .enum_type => { |
| | 2664 | const loaded_enum = ip.loadEnumType(val); |
| | 2665 | switch (loaded_enum.owner_union) { |
| | 2666 | .none => { |
| | 2667 | const zfi = loaded_enum.zir_index.unwrap().?.resolveFile(ip); |
| | 2668 | const zf = zcu.fileByIndex(zfi); |
| | 2669 | if (loaded_enum.captures.len > 0 or loaded_enum.is_reified) { |
| | 2670 | try diw.writeUleb128(try dwarf.refAbbrevCode( |
| | 2671 | if (loaded_enum.captures.len > 0 or loaded_enum.field_names.len > 0) |
| | 2672 | .decl_instance_enum |
| | 2673 | else |
| | 2674 | .decl_instance_empty_enum, |
| | 2675 | )); |
| | 2676 | try dwarf.secOffset(di_nw, try dwarf.getDecl(pt, val), 0); |
| | 2677 | } else if (loaded_enum.name_nav.unwrap()) |name_ni| { |
| 2235 | const name_nav = ip.getNav(name_ni); | 2678 | const name_nav = ip.getNav(name_ni); |
| 2236 | const decl = zf.zir.?.getDeclaration(name_nav.srcInst(ip).resolve(ip).?); | 2679 | const decl = zf.zir.?.getDeclaration(name_nav.srcInst(ip).resolve(ip).?); |
| 2237 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( | 2680 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( |
| 2238 | name_nav.analysis.?.namespace, | 2681 | name_nav.analysis.?.namespace, |
| 2239 | ).owner_type); | 2682 | ).owner_type); |
| 2240 | try diw.writeUleb128(try dwarf.refAbbrevCode( | 2683 | try diw.writeUleb128(try dwarf.refAbbrevCode( |
| 2241 | if (loaded_struct.field_types.len > 0) .decl_struct else .decl_namespace_struct, | 2684 | if (loaded_enum.field_names.len > 0) .decl_enum else .decl_empty_enum, |
| 2242 | )); | 2685 | )); |
| 2243 | try dwarf.secOffset(di_nw, parent_ni, 0); | 2686 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| 2244 | try diw.writeInt(u32, decl.src_line + 1, dwarf.endian); | 2687 | try diw.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| ... | @@ -2246,107 +2689,173 @@ fn updateConstInner( | ... | @@ -2246,107 +2689,173 @@ fn updateConstInner( |
| 2246 | try diw.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); | 2689 | try diw.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); |
| 2247 | try dwarf.strp(&dwarf.debug_str, di_nw, name_nav.name.toSlice(ip)); | 2690 | try dwarf.strp(&dwarf.debug_str, di_nw, name_nav.name.toSlice(ip)); |
| 2248 | } else { | 2691 | } else { |
| 2249 | const ui = dwarf.getUnit(zf.mod.?); | 2692 | const decl = zf.zir.?.getEnumDecl(loaded_enum.zir_index.unwrap().?.resolve(ip).?); |
| 2250 | _, const fi = try ui.get(dwarf).getFile(zcu.gpa, ui, zfi); | 2693 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( |
| 2251 | try diw.writeUleb128(try dwarf.refAbbrevCode(switch (loaded_struct.field_types.len) { | 2694 | ip.namespacePtr(loaded_enum.namespace).parent.unwrap().?, |
| 2252 | 0 => if (struct_is_file) .empty_file else .empty_struct_type, | 2695 | ).owner_type); |
| 2253 | else => if (struct_is_file) .file else .struct_type, | 2696 | try diw.writeUleb128(try dwarf.refAbbrevCode( |
| 2254 | })); | 2697 | if (loaded_enum.field_names.len > 0) .type_decl_enum else .type_decl_empty_enum, |
| 2255 | try diw.writeUleb128(@backingInt(fi)); | 2698 | )); |
| 2256 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_struct.fqn.toSlice(ip)); | 2699 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| | 2700 | try diw.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| | 2701 | try diw.writeUleb128(decl.src_column + 1); |
| | 2702 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_enum.name.toSlice(ip)); |
| 2257 | } | 2703 | } |
| 2258 | if (loaded_struct.field_types.len > 0) { | | |
| 2259 | const ty: Type = .fromInterned(val); | | |
| 2260 | try diw.writeUleb128(ty.abiSize(zcu)); | | |
| 2261 | try diw.writeUleb128(ty.abiAlignment(zcu).toByteUnits().?); | | |
| 2262 | for (0..loaded_struct.field_types.len) |field_index| { | | |
| 2263 | const is_comptime = loaded_struct.field_is_comptime_bits.get(ip, field_index); | | |
| 2264 | // TODO: we currently don't emit information about default values for | | |
| 2265 | // non-`comptime` fields, because these default values are resolved at a | | |
| 2266 | // separate time in the compiler frontend. To emit this information, the | | |
| 2267 | // frontend needs to tell us when the default values are available: like | | |
| 2268 | // how `Zcu.PerThread.ensureTypeLayoutUpToDate` enqueues a link task to | | |
| 2269 | // indicate completion of the type's layout, a task should be enqueued | | |
| 2270 | // by `Zcu.PerThread.ensureStructDefaultsUpToDate`, and upon receiving | | |
| 2271 | // it we should patch the correct default field values in. | | |
| 2272 | const field_default: InternPool.Index = | | |
| 2273 | if (is_comptime) loaded_struct.field_defaults.getOrNone(ip, field_index) else .none; | | |
| 2274 | assert(!(is_comptime and field_default == .none)); | | |
| 2275 | const field_ty: Type = .fromInterned(loaded_struct.field_types.get(ip)[field_index]); | | |
| 2276 | const field_default_class = switch (field_default) { | | |
| 2277 | .none => .no_possible_value, | | |
| 2278 | else => field_ty.classify(zcu), | | |
| 2279 | }; | | |
| 2280 | try diw.writeUleb128(try dwarf.refAbbrevCode(switch (field_default_class) { | | |
| 2281 | .no_possible_value, .one_possible_value => if (is_comptime) .field_comptime else .field, | | |
| 2282 | .runtime => if (is_comptime) .field_comptime_fully_runtime else .field_default_fully_runtime, | | |
| 2283 | .partially_comptime => if (is_comptime) .field_comptime_partially_comptime else .field_default_partially_comptime, | | |
| 2284 | .fully_comptime => if (is_comptime) .field_comptime_fully_comptime else .field_default_fully_comptime, | | |
| 2285 | })); | | |
| 2286 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_struct.field_names.get(ip)[field_index].toSlice(ip)); | | |
| 2287 | try dwarf.refConst(pt, di_nw, field_ty.toValue()); | | |
| 2288 | if (!is_comptime) { | | |
| 2289 | try diw.writeUleb128(loaded_struct.field_offsets.get(ip)[field_index]); | | |
| 2290 | try diw.writeUleb128(loaded_struct.field_aligns.getOrNone(ip, field_index).toByteUnits() orelse | | |
| 2291 | field_ty.abiAlignment(zcu).toByteUnits().?); | | |
| 2292 | } | | |
| 2293 | if (field_default_class.hasRuntimeBits()) try dwarf.blockConst(pt, di_nw, .fromInterned(field_default)); | | |
| 2294 | if (field_default_class.comptimeOnly()) try dwarf.refConst(pt, di_nw, .fromInterned(field_default)); | | |
| 2295 | } | | |
| 2296 | try diw.writeUleb128(@backingInt(AbbrevCode.null)); | | |
| 2297 | } else try diw.writeByte(@intFromBool(false)); | | |
| 2298 | }, | 2704 | }, |
| 2299 | .@"packed" => return, | 2705 | else => { |
| 2300 | } | | |
| 2301 | }, | | |
| 2302 | .enum_type => { | | |
| 2303 | const loaded_enum = ip.loadEnumType(val); | | |
| 2304 | if (loaded_enum.zir_index.unwrap()) |zir_index| { | | |
| 2305 | assert(loaded_enum.owner_union == .none); | | |
| 2306 | const zfi = zir_index.resolveFile(ip); | | |
| 2307 | const zf = zcu.fileByIndex(zfi); | | |
| 2308 | if (loaded_enum.name_nav.unwrap()) |name_ni| { | | |
| 2309 | const name_nav = ip.getNav(name_ni); | | |
| 2310 | const decl = zf.zir.?.getDeclaration(name_nav.srcInst(ip).resolve(ip).?); | | |
| 2311 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( | | |
| 2312 | name_nav.analysis.?.namespace, | | |
| 2313 | ).owner_type); | | |
| 2314 | try diw.writeUleb128(try dwarf.refAbbrevCode( | | |
| 2315 | if (loaded_enum.field_names.len > 0) .decl_enum else .decl_empty_enum, | | |
| 2316 | )); | | |
| 2317 | try dwarf.secOffset(di_nw, parent_ni, 0); | | |
| 2318 | try diw.writeInt(u32, decl.src_line + 1, dwarf.endian); | | |
| 2319 | try diw.writeUleb128(decl.src_column + 1); | | |
| 2320 | try diw.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); | | |
| 2321 | try dwarf.strp(&dwarf.debug_str, di_nw, name_nav.name.toSlice(ip)); | | |
| 2322 | } else { | | |
| 2323 | const ui = dwarf.getUnit(zf.mod.?); | | |
| 2324 | _, const fi = try ui.get(dwarf).getFile(zcu.gpa, ui, zfi); | | |
| 2325 | try diw.writeUleb128(try dwarf.refAbbrevCode( | 2706 | try diw.writeUleb128(try dwarf.refAbbrevCode( |
| 2326 | if (loaded_enum.field_names.len > 0) .enum_type else .empty_enum_type, | 2707 | if (loaded_enum.field_names.len > 0) .generated_enum_type else .generated_empty_enum_type, |
| 2327 | )); | 2708 | )); |
| 2328 | try diw.writeUleb128(@backingInt(fi)); | | |
| 2329 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_enum.fqn.toSlice(ip)); | 2709 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_enum.fqn.toSlice(ip)); |
| 2330 | } | 2710 | }, |
| 2331 | } else { | | |
| 2332 | assert(loaded_enum.owner_union != .none); | | |
| 2333 | try diw.writeUleb128(try dwarf.refAbbrevCode( | | |
| 2334 | if (loaded_enum.field_names.len == 0) .generated_empty_enum_type else .generated_enum_type, | | |
| 2335 | )); | | |
| 2336 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_enum.fqn.toSlice(ip)); | | |
| 2337 | } | 2711 | } |
| 2338 | try dwarf.refConst(pt, di_nw, .fromInterned(loaded_enum.int_tag_type)); | 2712 | try dwarf.refType(pt, di_nw, .fromInterned(loaded_enum.int_tag_type)); |
| 2339 | for (0..loaded_enum.field_names.len) |field_index| { | 2713 | for (0..loaded_enum.field_names.len) |field_index| { |
| 2340 | try diw.writeUleb128(try dwarf.refAbbrevCode(.enum_field)); | 2714 | try diw.writeUleb128(try dwarf.refAbbrevCode(.enum_field)); |
| 2341 | try dwarf.enumConstValue(diw, loaded_enum, field_index); | 2715 | try dwarf.enumConstValue(diw, loaded_enum, field_index); |
| 2342 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_enum.field_names.get(ip)[field_index].toSlice(ip)); | 2716 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_enum.field_names.get(ip)[field_index].toSlice(ip)); |
| 2343 | } | 2717 | } |
| 2344 | if (loaded_enum.field_names.len > 0) try diw.writeUleb128(@backingInt(AbbrevCode.null)); | 2718 | if (loaded_enum.captures.len > 0 or loaded_enum.field_names.len > 0) |
| | 2719 | try diw.writeUleb128(@backingInt(AbbrevCode.null)); |
| | 2720 | }, |
| | 2721 | // no defined size, so lowered the same as incomplete struct types |
| | 2722 | .opaque_type => return dwarf.updateConstIncompleteInner(pt, di_nw, val), |
| | 2723 | .spirv_type => unreachable, |
| | 2724 | .func_type => |func_type| { |
| | 2725 | const is_nullary = func_type.param_types.len == 0 and !func_type.is_var_args; |
| | 2726 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(val).fmt(pt)}); |
| | 2727 | defer zcu.gpa.free(name); |
| | 2728 | try diw.writeUleb128(try dwarf.refAbbrevCode( |
| | 2729 | if (is_nullary) .nullary_func_type else .func_type, |
| | 2730 | )); |
| | 2731 | try dwarf.strp(&dwarf.debug_str, di_nw, name); |
| | 2732 | const cc: DW.CC = cc: { |
| | 2733 | if (zcu.getTarget().cCallingConvention()) |cc| { |
| | 2734 | if (@as(std.lang.CallingConvention.Tag, cc) == func_type.cc) { |
| | 2735 | break :cc .normal; |
| | 2736 | } |
| | 2737 | } |
| | 2738 | // For better or worse, we try to match what Clang emits. |
| | 2739 | break :cc switch (func_type.cc) { |
| | 2740 | .@"inline" => .nocall, |
| | 2741 | .async, .auto, .naked => .normal, |
| | 2742 | .x86_64_sysv => .LLVM_X86_64SysV, |
| | 2743 | .x86_64_win => .LLVM_Win64, |
| | 2744 | .x86_64_regcall_v3_sysv => .LLVM_X86RegCall, |
| | 2745 | .x86_64_regcall_v4_win => .LLVM_X86RegCall, |
| | 2746 | .x86_64_vectorcall => .LLVM_vectorcall, |
| | 2747 | .x86_sysv, .x86_win, .x86_mingw => .normal, |
| | 2748 | .x86_64_preserve_none => .LLVM_PreserveNone, |
| | 2749 | .x86_stdcall => .BORLAND_stdcall, |
| | 2750 | .x86_fastcall => .BORLAND_msfastcall, |
| | 2751 | .x86_thiscall => .BORLAND_thiscall, |
| | 2752 | .x86_thiscall_mingw => .BORLAND_thiscall, |
| | 2753 | .x86_regcall_v3 => .LLVM_X86RegCall, |
| | 2754 | .x86_regcall_v4_win => .LLVM_X86RegCall, |
| | 2755 | .x86_vectorcall => .LLVM_vectorcall, |
| | 2756 | |
| | 2757 | .aarch64_aapcs => .normal, |
| | 2758 | .aarch64_aapcs_darwin => .normal, |
| | 2759 | .aarch64_aapcs_win => .normal, |
| | 2760 | .aarch64_vfabi => .LLVM_AAPCS, |
| | 2761 | .aarch64_vfabi_sve => .LLVM_AAPCS, |
| | 2762 | .aarch64_preserve_none => .LLVM_PreserveNone, |
| | 2763 | |
| | 2764 | .arm_aapcs => .LLVM_AAPCS, |
| | 2765 | .arm_aapcs_vfp => .LLVM_AAPCS_VFP, |
| | 2766 | |
| | 2767 | .riscv64_lp64_v, |
| | 2768 | .riscv32_ilp32_v, |
| | 2769 | => .LLVM_RISCVVectorCall, |
| | 2770 | |
| | 2771 | .m68k_rtd => .LLVM_M68kRTD, |
| | 2772 | |
| | 2773 | .sh_renesas => .GNU_renesas_sh, |
| | 2774 | |
| | 2775 | .amdgcn_kernel => .LLVM_OpenCLKernel, |
| | 2776 | .nvptx_kernel, |
| | 2777 | .spirv_kernel, |
| | 2778 | => .nocall, |
| | 2779 | |
| | 2780 | .x86_64_interrupt, |
| | 2781 | .x86_interrupt, |
| | 2782 | .arm_interrupt, |
| | 2783 | .mips64_interrupt, |
| | 2784 | .mips_interrupt, |
| | 2785 | .riscv64_interrupt, |
| | 2786 | .riscv32_interrupt, |
| | 2787 | .sh_interrupt, |
| | 2788 | .arc_interrupt, |
| | 2789 | .avr_builtin, |
| | 2790 | .avr_signal, |
| | 2791 | .avr_interrupt, |
| | 2792 | .csky_interrupt, |
| | 2793 | .m68k_interrupt, |
| | 2794 | .microblaze_interrupt, |
| | 2795 | .msp430_interrupt, |
| | 2796 | => .normal, |
| | 2797 | |
| | 2798 | else => .nocall, |
| | 2799 | }; |
| | 2800 | }; |
| | 2801 | try diw.writeByte(@backingInt(cc)); |
| | 2802 | try dwarf.refType(pt, di_nw, .fromInterned(func_type.return_type)); |
| | 2803 | if (!is_nullary) { |
| | 2804 | for (0..func_type.param_types.len) |param_index| { |
| | 2805 | try diw.writeUleb128(try dwarf.refAbbrevCode(.unnamed_param)); |
| | 2806 | try dwarf.refType(pt, di_nw, .fromInterned(func_type.param_types.get(ip)[param_index])); |
| | 2807 | } |
| | 2808 | if (func_type.is_var_args) try diw.writeUleb128(try dwarf.refAbbrevCode(.is_var_args)); |
| | 2809 | try diw.writeUleb128(@backingInt(AbbrevCode.null)); |
| | 2810 | } |
| | 2811 | }, |
| | 2812 | .error_set_type => |error_set_type| { |
| | 2813 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(val).fmt(pt)}); |
| | 2814 | defer zcu.gpa.free(name); |
| | 2815 | try diw.writeUleb128(try dwarf.refAbbrevCode( |
| | 2816 | if (error_set_type.names.len > 0) .generated_enum_type else .generated_empty_enum_type, |
| | 2817 | )); |
| | 2818 | try dwarf.strp(&dwarf.debug_str, di_nw, name); |
| | 2819 | try dwarf.refType(pt, di_nw, try pt.intType(.unsigned, zcu.errorSetBits())); |
| | 2820 | for (0..error_set_type.names.len) |field_index| { |
| | 2821 | const field_name = error_set_type.names.get(ip)[field_index]; |
| | 2822 | try diw.writeUleb128(try dwarf.refAbbrevCode(.enum_field)); |
| | 2823 | try diw.writeUleb128(DW.FORM.udata); |
| | 2824 | try diw.writeUleb128(ip.getErrorValueIfExists(field_name).?); |
| | 2825 | try dwarf.strp(&dwarf.debug_str, di_nw, field_name.toSlice(ip)); |
| | 2826 | } |
| | 2827 | if (error_set_type.names.len > 0) try diw.writeUleb128(@backingInt(AbbrevCode.null)); |
| | 2828 | }, |
| | 2829 | .inferred_error_set_type => |func| { |
| | 2830 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(val).fmt(pt)}); |
| | 2831 | defer zcu.gpa.free(name); |
| | 2832 | try diw.writeUleb128(try dwarf.refAbbrevCode(.inferred_error_set_type)); |
| | 2833 | try dwarf.strp(&dwarf.debug_str, di_nw, name); |
| | 2834 | try dwarf.refType(pt, di_nw, switch (ip.funcIesResolvedUnordered(func)) { |
| | 2835 | .none => .anyerror, |
| | 2836 | else => |ies| .fromInterned(ies), |
| | 2837 | }); |
| 2345 | }, | 2838 | }, |
| | 2839 | |
| | 2840 | else => return, |
| | 2841 | |
| | 2842 | .memoized_call => unreachable, // not a value |
| 2346 | } | 2843 | } |
| 2347 | try dwarf.genDebugInfoPadding(diw, diw.unusedCapacityLen()); | 2844 | try dwarf.genDebugInfoPadding(diw, diw.unusedCapacityLen()); |
| 2348 | } | 2845 | } |
| 2349 | | 2846 | |
| | 2847 | fn optRepr(opt_child_type: Type, zcu: *const Zcu) enum { unpacked, opv_null, error_set, pointer } { |
| | 2848 | if (opt_child_type.isNoReturn(zcu)) return .opv_null; |
| | 2849 | return switch (opt_child_type.toIntern()) { |
| | 2850 | .anyerror_type => .error_set, |
| | 2851 | else => switch (zcu.intern_pool.indexToKey(opt_child_type.toIntern())) { |
| | 2852 | else => .unpacked, |
| | 2853 | .error_set_type, .inferred_error_set_type => .error_set, |
| | 2854 | .ptr_type => |ptr_type| if (ptr_type.flags.is_allowzero) .unpacked else .pointer, |
| | 2855 | }, |
| | 2856 | }; |
| | 2857 | } |
| | 2858 | |
| 2350 | pub fn updateConstIncomplete( | 2859 | pub fn updateConstIncomplete( |
| 2351 | dwarf: *Dwarf, | 2860 | dwarf: *Dwarf, |
| 2352 | pt: Zcu.PerThread, | 2861 | pt: Zcu.PerThread, |
| ... | @@ -2369,7 +2878,7 @@ fn updateConstIncompleteInner( | ... | @@ -2369,7 +2878,7 @@ fn updateConstIncompleteInner( |
| 2369 | const ip = &zcu.intern_pool; | 2878 | const ip = &zcu.intern_pool; |
| 2370 | const diw = &di_nw.interface; | 2879 | const diw = &di_nw.interface; |
| 2371 | done: { | 2880 | done: { |
| 2372 | const src_inst, const zf, const capture_names, const captures, const fqn, const maybe_name_nav, const namespace = container: switch (ip.indexToKey(val)) { | 2881 | const kind: enum { @"struct", @"union", @"enum" }, const zf, const src_line, const src_column, const is_reified, const captures, const name, const maybe_name_nav, const namespace = container: switch (ip.indexToKey(val)) { |
| 2373 | .struct_type => { | 2882 | .struct_type => { |
| 2374 | const loaded_struct = ip.loadStructType(val); | 2883 | const loaded_struct = ip.loadStructType(val); |
| 2375 | const src_inst = loaded_struct.zir_index.resolveFull(ip) orelse { | 2884 | const src_inst = loaded_struct.zir_index.resolveFull(ip) orelse { |
| ... | @@ -2383,22 +2892,34 @@ fn updateConstIncompleteInner( | ... | @@ -2383,22 +2892,34 @@ fn updateConstIncompleteInner( |
| 2383 | _, const fi = try ui.get(dwarf).getFile(zcu.gpa, ui, src_inst.file); | 2892 | _, const fi = try ui.get(dwarf).getFile(zcu.gpa, ui, src_inst.file); |
| 2384 | try diw.writeUleb128(try dwarf.refAbbrevCode(.empty_file)); | 2893 | try diw.writeUleb128(try dwarf.refAbbrevCode(.empty_file)); |
| 2385 | try diw.writeUleb128(@backingInt(fi)); | 2894 | try diw.writeUleb128(@backingInt(fi)); |
| 2386 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_struct.fqn.toSlice(ip)); | 2895 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_struct.name.toSlice(ip)); |
| 2387 | try diw.writeByte(@intFromBool(true)); | 2896 | try diw.writeByte(@intFromBool(true)); |
| 2388 | break :done; | 2897 | break :done; |
| 2389 | }, | 2898 | }, |
| 2390 | else => break :container .{ | 2899 | else => { |
| 2391 | src_inst, | 2900 | const data = zf.zir.?.instructions.items(.data)[@backingInt(src_inst.inst)].extended; |
| 2392 | zf, | 2901 | const src_line, const src_column = src_loc: switch (data.opcode) { |
| 2393 | switch (zf.zir.?.instructions.items(.data)[@backingInt(src_inst.inst)].extended.opcode) { | | |
| 2394 | else => unreachable, | 2902 | else => unreachable, |
| 2395 | .struct_decl => zf.zir.?.getStructDecl(src_inst.inst).capture_names, | 2903 | .struct_decl => { |
| 2396 | .reify_struct => &.{}, | 2904 | const decl = zf.zir.?.getStructDecl(src_inst.inst); |
| 2397 | }, | 2905 | break :src_loc .{ decl.src_line, decl.src_column }; |
| 2398 | loaded_struct.captures, | 2906 | }, |
| 2399 | loaded_struct.fqn, | 2907 | .reify_struct => { |
| 2400 | loaded_struct.name_nav, | 2908 | const decl = zf.zir.?.extraData(std.zig.Zir.Inst.ReifyStruct, data.operand).data; |
| 2401 | loaded_struct.namespace, | 2909 | break :src_loc .{ decl.src_line, decl.src_column }; |
| | 2910 | }, |
| | 2911 | }; |
| | 2912 | break :container .{ |
| | 2913 | .@"struct", |
| | 2914 | zf, |
| | 2915 | src_line, |
| | 2916 | src_column, |
| | 2917 | loaded_struct.is_reified, |
| | 2918 | loaded_struct.captures, |
| | 2919 | loaded_struct.name, |
| | 2920 | loaded_struct.name_nav, |
| | 2921 | loaded_struct.namespace, |
| | 2922 | }; |
| 2402 | }, | 2923 | }, |
| 2403 | } | 2924 | } |
| 2404 | }, | 2925 | }, |
| ... | @@ -2409,16 +2930,26 @@ fn updateConstIncompleteInner( | ... | @@ -2409,16 +2930,26 @@ fn updateConstIncompleteInner( |
| 2409 | break :done; | 2930 | break :done; |
| 2410 | }; | 2931 | }; |
| 2411 | const zf = zcu.fileByIndex(src_inst.file); | 2932 | const zf = zcu.fileByIndex(src_inst.file); |
| | 2933 | const data = zf.zir.?.instructions.items(.data)[@backingInt(src_inst.inst)].extended; |
| | 2934 | const src_line, const src_column = src_loc: switch (data.opcode) { |
| | 2935 | else => unreachable, |
| | 2936 | .union_decl => { |
| | 2937 | const decl = zf.zir.?.getUnionDecl(src_inst.inst); |
| | 2938 | break :src_loc .{ decl.src_line, decl.src_column }; |
| | 2939 | }, |
| | 2940 | .reify_union => { |
| | 2941 | const decl = zf.zir.?.extraData(std.zig.Zir.Inst.ReifyUnion, data.operand).data; |
| | 2942 | break :src_loc .{ decl.src_line, decl.src_column }; |
| | 2943 | }, |
| | 2944 | }; |
| 2412 | break :container .{ | 2945 | break :container .{ |
| 2413 | src_inst, | 2946 | .@"union", |
| 2414 | zf, | 2947 | zf, |
| 2415 | switch (zf.zir.?.instructions.items(.data)[@backingInt(src_inst.inst)].extended.opcode) { | 2948 | src_line, |
| 2416 | else => unreachable, | 2949 | src_column, |
| 2417 | .union_decl => zf.zir.?.getUnionDecl(src_inst.inst).capture_names, | 2950 | loaded_union.is_reified, |
| 2418 | .reify_union => &.{}, | | |
| 2419 | }, | | |
| 2420 | loaded_union.captures, | 2951 | loaded_union.captures, |
| 2421 | loaded_union.fqn, | 2952 | loaded_union.name, |
| 2422 | loaded_union.name_nav, | 2953 | loaded_union.name_nav, |
| 2423 | loaded_union.namespace, | 2954 | loaded_union.namespace, |
| 2424 | }; | 2955 | }; |
| ... | @@ -2427,7 +2958,7 @@ fn updateConstIncompleteInner( | ... | @@ -2427,7 +2958,7 @@ fn updateConstIncompleteInner( |
| 2427 | const loaded_enum = ip.loadEnumType(val); | 2958 | const loaded_enum = ip.loadEnumType(val); |
| 2428 | const zir_index = loaded_enum.zir_index.unwrap() orelse { | 2959 | const zir_index = loaded_enum.zir_index.unwrap() orelse { |
| 2429 | try diw.writeUleb128(try dwarf.refAbbrevCode(.generated_empty_struct_type)); | 2960 | try diw.writeUleb128(try dwarf.refAbbrevCode(.generated_empty_struct_type)); |
| 2430 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_enum.fqn.toSlice(ip)); | 2961 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_enum.name.toSlice(ip)); |
| 2431 | try diw.writeByte(@intFromBool(true)); | 2962 | try diw.writeByte(@intFromBool(true)); |
| 2432 | break :done; | 2963 | break :done; |
| 2433 | }; | 2964 | }; |
| ... | @@ -2436,20 +2967,31 @@ fn updateConstIncompleteInner( | ... | @@ -2436,20 +2967,31 @@ fn updateConstIncompleteInner( |
| 2436 | break :done; | 2967 | break :done; |
| 2437 | }; | 2968 | }; |
| 2438 | const zf = zcu.fileByIndex(src_inst.file); | 2969 | const zf = zcu.fileByIndex(src_inst.file); |
| | 2970 | const data = zf.zir.?.instructions.items(.data)[@backingInt(src_inst.inst)].extended; |
| | 2971 | const src_line, const src_column = src_loc: switch (data.opcode) { |
| | 2972 | else => unreachable, |
| | 2973 | .enum_decl => { |
| | 2974 | const decl = zf.zir.?.getEnumDecl(src_inst.inst); |
| | 2975 | break :src_loc .{ decl.src_line, decl.src_column }; |
| | 2976 | }, |
| | 2977 | .reify_enum => { |
| | 2978 | const decl = zf.zir.?.extraData(std.zig.Zir.Inst.ReifyEnum, data.operand).data; |
| | 2979 | break :src_loc .{ decl.src_line, decl.src_column }; |
| | 2980 | }, |
| | 2981 | }; |
| 2439 | break :container .{ | 2982 | break :container .{ |
| 2440 | src_inst, | 2983 | .@"enum", |
| 2441 | zf, | 2984 | zf, |
| 2442 | switch (zf.zir.?.instructions.items(.data)[@backingInt(src_inst.inst)].extended.opcode) { | 2985 | src_line, |
| 2443 | else => unreachable, | 2986 | src_column, |
| 2444 | .enum_decl => zf.zir.?.getEnumDecl(src_inst.inst).capture_names, | 2987 | loaded_enum.is_reified, |
| 2445 | .reify_enum => &.{}, | | |
| 2446 | }, | | |
| 2447 | loaded_enum.captures, | 2988 | loaded_enum.captures, |
| 2448 | loaded_enum.fqn, | 2989 | loaded_enum.name, |
| 2449 | loaded_enum.name_nav, | 2990 | loaded_enum.name_nav, |
| 2450 | loaded_enum.namespace, | 2991 | loaded_enum.namespace, |
| 2451 | }; | 2992 | }; |
| 2452 | }, | 2993 | }, |
| | 2994 | // always complete, but forwarded from `updateConstInner` |
| 2453 | .opaque_type => { | 2995 | .opaque_type => { |
| 2454 | const loaded_opaque = ip.loadOpaqueType(val); | 2996 | const loaded_opaque = ip.loadOpaqueType(val); |
| 2455 | const src_inst = loaded_opaque.zir_index.resolveFull(ip) orelse { | 2997 | const src_inst = loaded_opaque.zir_index.resolveFull(ip) orelse { |
| ... | @@ -2457,12 +2999,15 @@ fn updateConstIncompleteInner( | ... | @@ -2457,12 +2999,15 @@ fn updateConstIncompleteInner( |
| 2457 | break :done; | 2999 | break :done; |
| 2458 | }; | 3000 | }; |
| 2459 | const zf = zcu.fileByIndex(src_inst.file); | 3001 | const zf = zcu.fileByIndex(src_inst.file); |
| | 3002 | const decl = zf.zir.?.getOpaqueDecl(src_inst.inst); |
| 2460 | break :container .{ | 3003 | break :container .{ |
| 2461 | src_inst, | 3004 | .@"struct", |
| 2462 | zf, | 3005 | zf, |
| 2463 | zf.zir.?.getOpaqueDecl(src_inst.inst).capture_names, | 3006 | decl.src_line, |
| | 3007 | decl.src_column, |
| | 3008 | false, |
| 2464 | loaded_opaque.captures, | 3009 | loaded_opaque.captures, |
| 2465 | loaded_opaque.fqn, | 3010 | loaded_opaque.name, |
| 2466 | loaded_opaque.name_nav, | 3011 | loaded_opaque.name_nav, |
| 2467 | loaded_opaque.namespace, | 3012 | loaded_opaque.namespace, |
| 2468 | }; | 3013 | }; |
| ... | @@ -2477,92 +3022,117 @@ fn updateConstIncompleteInner( | ... | @@ -2477,92 +3022,117 @@ fn updateConstIncompleteInner( |
| 2477 | }, | 3022 | }, |
| 2478 | else => |ty| { | 3023 | else => |ty| { |
| 2479 | try diw.writeUleb128(try dwarf.refAbbrevCode(.undefined_comptime_value)); | 3024 | try diw.writeUleb128(try dwarf.refAbbrevCode(.undefined_comptime_value)); |
| 2480 | try dwarf.refConst(pt, di_nw, .fromInterned(ty)); | 3025 | try dwarf.refType(pt, di_nw, .fromInterned(ty)); |
| 2481 | }, | 3026 | }, |
| 2482 | }, | 3027 | }, |
| 2483 | }; | 3028 | }; |
| 2484 | const spec_di = if (false and captures.len > 0) try dwarf.getDecl(pt, val) else undefined; | 3029 | if (captures.len > 0 or is_reified) { |
| 2485 | _ = spec_di; | 3030 | try diw.writeUleb128(try dwarf.refAbbrevCode(if (captures.len > 0) switch (kind) { |
| 2486 | if (maybe_name_nav.unwrap()) |name_ni| { | 3031 | .@"struct" => .decl_instance_incomplete_struct, |
| | 3032 | .@"union" => .decl_instance_incomplete_union, |
| | 3033 | .@"enum" => .decl_instance_incomplete_enum, |
| | 3034 | } else switch (kind) { |
| | 3035 | .@"struct" => .decl_instance_empty_incomplete_struct, |
| | 3036 | .@"union" => .decl_instance_empty_incomplete_union, |
| | 3037 | .@"enum" => .decl_instance_empty_incomplete_enum, |
| | 3038 | })); |
| | 3039 | try dwarf.secOffset(di_nw, try dwarf.getDecl(pt, val), 0); |
| | 3040 | } else if (maybe_name_nav.unwrap()) |name_ni| { |
| 2487 | const name_nav = ip.getNav(name_ni); | 3041 | const name_nav = ip.getNav(name_ni); |
| 2488 | const name_src_inst = name_nav.srcInst(ip).resolve(ip).?; | 3042 | const decl = zf.zir.?.getDeclaration(name_nav.srcInst(ip).resolve(ip).?); |
| 2489 | const decl = zf.zir.?.getDeclaration(name_src_inst); | | |
| 2490 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( | 3043 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( |
| 2491 | name_nav.analysis.?.namespace, | 3044 | name_nav.analysis.?.namespace, |
| 2492 | ).owner_type); | 3045 | ).owner_type); |
| 2493 | try diw.writeUleb128(try dwarf.refAbbrevCode( | 3046 | try diw.writeUleb128(try dwarf.refAbbrevCode(if (captures.len > 0) switch (kind) { |
| 2494 | if (captures.len > 0) .decl_capturing_namespace_struct else .decl_namespace_struct, | 3047 | .@"struct" => .decl_incomplete_struct, |
| 2495 | )); | 3048 | .@"union" => .decl_incomplete_union, |
| | 3049 | .@"enum" => .decl_incomplete_enum, |
| | 3050 | } else switch (kind) { |
| | 3051 | .@"struct" => .decl_empty_incomplete_struct, |
| | 3052 | .@"union" => .decl_empty_incomplete_union, |
| | 3053 | .@"enum" => .decl_empty_incomplete_enum, |
| | 3054 | })); |
| 2496 | try dwarf.secOffset(di_nw, parent_ni, 0); | 3055 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| 2497 | try diw.writeInt(u32, decl.src_line + 1, dwarf.endian); | 3056 | try diw.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| 2498 | try diw.writeUleb128(decl.src_column + 1); | 3057 | try diw.writeUleb128(decl.src_column + 1); |
| 2499 | try diw.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); | 3058 | try diw.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); |
| 2500 | try dwarf.strp(&dwarf.debug_str, di_nw, name_nav.name.toSlice(ip)); | 3059 | try dwarf.strp(&dwarf.debug_str, di_nw, name_nav.name.toSlice(ip)); |
| 2501 | } else { | 3060 | } else { |
| 2502 | const ui = dwarf.getUnit(zf.mod.?); | 3061 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( |
| 2503 | _, const fi = try ui.get(dwarf).getFile(zcu.gpa, ui, src_inst.file); | | |
| 2504 | const parent_ni = if (false) try dwarf.getDecl(pt, ip.namespacePtr( | | |
| 2505 | ip.namespacePtr(namespace).parent.unwrap().?, | 3062 | ip.namespacePtr(namespace).parent.unwrap().?, |
| 2506 | ).owner_type); | 3063 | ).owner_type); |
| 2507 | _ = parent_ni; | 3064 | try diw.writeUleb128(try dwarf.refAbbrevCode(if (captures.len > 0) switch (kind) { |
| 2508 | try diw.writeUleb128(try dwarf.refAbbrevCode( | 3065 | .@"struct" => .type_decl_incomplete_struct, |
| 2509 | if (captures.len > 0) .capturing_empty_struct_type else .empty_struct_type, | 3066 | .@"union" => .type_decl_incomplete_union, |
| 2510 | )); | 3067 | .@"enum" => .type_decl_incomplete_enum, |
| 2511 | try diw.writeUleb128(@backingInt(fi)); | 3068 | } else switch (kind) { |
| 2512 | try dwarf.strp(&dwarf.debug_str, di_nw, fqn.toSlice(ip)); | 3069 | .@"struct" => .type_decl_empty_incomplete_struct, |
| | 3070 | .@"union" => .type_decl_empty_incomplete_union, |
| | 3071 | .@"enum" => .type_decl_empty_incomplete_enum, |
| | 3072 | })); |
| | 3073 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| | 3074 | try diw.writeInt(u32, src_line + 1, dwarf.endian); |
| | 3075 | try diw.writeUleb128(src_column + 1); |
| | 3076 | try dwarf.strp(&dwarf.debug_str, di_nw, name.toSlice(ip)); |
| 2513 | } | 3077 | } |
| 2514 | try diw.writeByte(@intFromBool(true)); | 3078 | try dwarf.genCaptures(pt, di_nw, captures); |
| 2515 | for (capture_names, captures.get(ip)) |capture_name, capture| switch (capture.unwrap()) { | | |
| 2516 | .@"comptime" => |capture_val| { | | |
| 2517 | const ty: Type = .fromInterned(ip.typeOf(capture_val)); | | |
| 2518 | const ty_class = ty.classify(zcu); | | |
| 2519 | try diw.writeUleb128(try dwarf.refAbbrevCode(switch (ty_class) { | | |
| 2520 | .no_possible_value => unreachable, | | |
| 2521 | .one_possible_value => .comptime_capture, | | |
| 2522 | .runtime => .comptime_capture_runtime, | | |
| 2523 | .partially_comptime => .comptime_capture_partially_comptime, | | |
| 2524 | .fully_comptime => .comptime_capture_fully_comptime, | | |
| 2525 | })); | | |
| 2526 | try dwarf.strp(&dwarf.debug_str, di_nw, zf.zir.?.nullTerminatedString(capture_name)); | | |
| 2527 | try dwarf.refConst(pt, di_nw, ty.toValue()); | | |
| 2528 | if (ty_class.hasRuntimeBits()) try dwarf.blockConst(pt, di_nw, .fromInterned(capture_val)); | | |
| 2529 | if (ty_class.comptimeOnly()) try dwarf.refConst(pt, di_nw, .fromInterned(capture_val)); | | |
| 2530 | }, | | |
| 2531 | .runtime => |capture_ty| { | | |
| 2532 | try diw.writeUleb128(try dwarf.refAbbrevCode(.runtime_capture)); | | |
| 2533 | try dwarf.strp(&dwarf.debug_str, di_nw, zf.zir.?.nullTerminatedString(capture_name)); | | |
| 2534 | try dwarf.refConst(pt, di_nw, .fromInterned(capture_ty)); | | |
| 2535 | }, | | |
| 2536 | .nav_val => |capture_nav| { | | |
| 2537 | const gi = try dwarf.getGlobal(capture_nav); | | |
| 2538 | try diw.writeUleb128(try dwarf.refAbbrevCode(.nav_capture)); | | |
| 2539 | try dwarf.strp(&dwarf.debug_str, di_nw, zf.zir.?.nullTerminatedString(capture_name)); | | |
| 2540 | try dwarf.exprLoc(di_nw, .{ .implicit_pointer = .{ | | |
| 2541 | .node = gi.get(dwarf).debug_info_ni.unwrap().?, | | |
| 2542 | } }); | | |
| 2543 | }, | | |
| 2544 | .nav_ref => |capture_nav| { | | |
| 2545 | const gi = try dwarf.getGlobal(capture_nav); | | |
| 2546 | const capture_name_slice = try zcu.gpa.print("&{s}", .{zf.zir.?.nullTerminatedString(capture_name)}); | | |
| 2547 | defer zcu.gpa.free(capture_name_slice); | | |
| 2548 | try diw.writeUleb128(try dwarf.refAbbrevCode(.nav_capture)); | | |
| 2549 | try dwarf.strp(&dwarf.debug_str, di_nw, capture_name_slice); | | |
| 2550 | try dwarf.exprLoc(di_nw, .{ .stack_value = &.{ .implicit_pointer = .{ | | |
| 2551 | .node = gi.get(dwarf).debug_info_ni.unwrap().?, | | |
| 2552 | } } }); | | |
| 2553 | }, | | |
| 2554 | }; | | |
| 2555 | if (captures.len > 0) try diw.writeByte(@backingInt(AbbrevCode.null)); | 3079 | if (captures.len > 0) try diw.writeByte(@backingInt(AbbrevCode.null)); |
| 2556 | } | 3080 | } |
| 2557 | try dwarf.genDebugInfoPadding(diw, diw.unusedCapacityLen()); | 3081 | try dwarf.genDebugInfoPadding(diw, diw.unusedCapacityLen()); |
| 2558 | } | 3082 | } |
| 2559 | | 3083 | |
| | 3084 | fn genCaptures( |
| | 3085 | dwarf: *Dwarf, |
| | 3086 | pt: Zcu.PerThread, |
| | 3087 | di_nw: *MappedFile.Node.Writer, |
| | 3088 | captures: anytype, |
| | 3089 | ) link.EmitError!void { |
| | 3090 | const zcu = pt.zcu; |
| | 3091 | const ip = &zcu.intern_pool; |
| | 3092 | const diw = &di_nw.interface; |
| | 3093 | for (captures.get(ip)) |capture| switch (capture.unwrap()) { |
| | 3094 | .@"comptime" => |capture_val| { |
| | 3095 | const ty: Type = .fromInterned(ip.typeOf(capture_val)); |
| | 3096 | const ty_class = ty.classify(zcu); |
| | 3097 | try diw.writeUleb128(try dwarf.refAbbrevCode(switch (ty_class) { |
| | 3098 | .no_possible_value => unreachable, |
| | 3099 | .one_possible_value => .comptime_capture, |
| | 3100 | .runtime => .comptime_capture_runtime, |
| | 3101 | .partially_comptime => .comptime_capture_partially_comptime, |
| | 3102 | .fully_comptime => .comptime_capture_fully_comptime, |
| | 3103 | })); |
| | 3104 | try dwarf.refType(pt, di_nw, ty); |
| | 3105 | if (ty_class.hasRuntimeBits()) try dwarf.blockConst(pt, di_nw, .fromInterned(capture_val)); |
| | 3106 | if (ty_class.comptimeOnly()) try dwarf.refConst(pt, di_nw, .fromInterned(capture_val)); |
| | 3107 | }, |
| | 3108 | .runtime => |capture_ty| { |
| | 3109 | try diw.writeUleb128(try dwarf.refAbbrevCode(.runtime_capture)); |
| | 3110 | try dwarf.refType(pt, di_nw, .fromInterned(capture_ty)); |
| | 3111 | }, |
| | 3112 | .nav_val => |capture_nav| { |
| | 3113 | const gi = try dwarf.getGlobal(capture_nav); |
| | 3114 | try diw.writeUleb128(try dwarf.refAbbrevCode(.nav_capture)); |
| | 3115 | try dwarf.exprLoc(di_nw, .{ .implicit_pointer = .{ |
| | 3116 | .node = gi.get(dwarf).debug_info_ni.unwrap().?, |
| | 3117 | } }); |
| | 3118 | }, |
| | 3119 | .nav_ref => |capture_nav| { |
| | 3120 | const gi = try dwarf.getGlobal(capture_nav); |
| | 3121 | try diw.writeUleb128(try dwarf.refAbbrevCode(.nav_capture)); |
| | 3122 | try dwarf.exprLoc(di_nw, .{ .stack_value = &.{ .implicit_pointer = .{ |
| | 3123 | .node = gi.get(dwarf).debug_info_ni.unwrap().?, |
| | 3124 | } } }); |
| | 3125 | }, |
| | 3126 | }; |
| | 3127 | } |
| | 3128 | |
| 2560 | pub fn genDecl( | 3129 | pub fn genDecl( |
| 2561 | dwarf: *Dwarf, | 3130 | dwarf: *Dwarf, |
| 2562 | pt: Zcu.PerThread, | 3131 | pt: Zcu.PerThread, |
| 2563 | di_nw: *MappedFile.Node.Writer, | 3132 | di_nw: *MappedFile.Node.Writer, |
| 2564 | instance_val: InternPool.Index, | 3133 | instance_val: InternPool.Index, |
| 2565 | ) link.Error!void { | 3134 | ) link.Error!void { |
| | 3135 | log.debug("genDecl({f})", .{Value.fromInterned(instance_val).fmtValue(pt)}); |
| 2566 | dwarf.genDeclInner(pt, di_nw, instance_val) catch |err| switch (err) { | 3136 | dwarf.genDeclInner(pt, di_nw, instance_val) catch |err| switch (err) { |
| 2567 | else => |e| return e, | 3137 | else => |e| return e, |
| 2568 | error.WriteFailed => return dwarf.reportWriteError(di_nw), | 3138 | error.WriteFailed => return dwarf.reportWriteError(di_nw), |
| ... | @@ -2574,68 +3144,221 @@ fn genDeclInner( | ... | @@ -2574,68 +3144,221 @@ fn genDeclInner( |
| 2574 | di_nw: *MappedFile.Node.Writer, | 3144 | di_nw: *MappedFile.Node.Writer, |
| 2575 | instance_val: InternPool.Index, | 3145 | instance_val: InternPool.Index, |
| 2576 | ) link.EmitError!void { | 3146 | ) link.EmitError!void { |
| 2577 | const ip = &dwarf.lf.comp.zcu.?.intern_pool; | 3147 | const zcu = pt.zcu; |
| | 3148 | const ip = &zcu.intern_pool; |
| 2578 | const diw = &di_nw.interface; | 3149 | const diw = &di_nw.interface; |
| 2579 | switch (ip.indexToKey(instance_val)) { | 3150 | done: { |
| 2580 | else => unreachable, | 3151 | const kind: enum { @"struct", @"union", @"enum" }, const zf, const src_line, const src_column, const capture_names, const captures, const name, const maybe_name_nav, const namespace = container: switch (ip.indexToKey(instance_val)) { |
| 2581 | .struct_type => { | 3152 | else => unreachable, |
| 2582 | const loaded_struct = ip.loadStructType(instance_val); | 3153 | .struct_type => { |
| 2583 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( | 3154 | const loaded_struct = ip.loadStructType(instance_val); |
| 2584 | ip.namespacePtr(loaded_struct.namespace).parent.unwrap().?, | 3155 | const src_inst = loaded_struct.zir_index.resolveFull(ip) orelse { |
| 2585 | ).owner_type); | 3156 | try diw.writeUleb128(try dwarf.refAbbrevCode(.decl_lost)); |
| 2586 | try diw.writeUleb128(try dwarf.refAbbrevCode(.decl_specification_struct)); | 3157 | break :done; |
| 2587 | try dwarf.secOffset(di_nw, parent_ni, 0); | 3158 | }; |
| 2588 | try diw.writeInt(u32, 0, dwarf.endian); | 3159 | const zf = zcu.fileByIndex(src_inst.file); |
| 2589 | try diw.writeUleb128(0); | 3160 | const inst = zf.zir.?.instructions.get(@backingInt(src_inst.inst)); |
| 2590 | try diw.writeByte(DW.ACCESS.public); | 3161 | const src_line, const src_column, const capture_names = decl: switch (inst.tag) { |
| 2591 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_struct.fqn.toSlice(ip)); | 3162 | else => unreachable, |
| 2592 | }, | 3163 | .struct_init, .struct_init_ref => { |
| 2593 | .enum_type => { | 3164 | const decl = zf.zir.?.extraData(std.zig.Zir.Inst.StructInit, inst.data.pl_node.payload_index).data; |
| 2594 | const loaded_enum = ip.loadEnumType(instance_val); | 3165 | break :decl .{ decl.src_line, decl.src_column, &.{} }; |
| 2595 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( | 3166 | }, |
| 2596 | ip.namespacePtr(loaded_enum.namespace).parent.unwrap().?, | 3167 | .struct_init_anon => { |
| 2597 | ).owner_type); | 3168 | const decl = zf.zir.?.extraData(std.zig.Zir.Inst.StructInitAnon, inst.data.pl_node.payload_index).data; |
| 2598 | try diw.writeUleb128(try dwarf.refAbbrevCode(.decl_specification_enum)); | 3169 | break :decl .{ decl.src_line, decl.src_column, &.{} }; |
| 2599 | try dwarf.secOffset(di_nw, parent_ni, 0); | 3170 | }, |
| 2600 | try diw.writeInt(u32, 0, dwarf.endian); | 3171 | .extended => switch (inst.data.extended.opcode) { |
| 2601 | try diw.writeUleb128(0); | 3172 | else => unreachable, |
| 2602 | try diw.writeByte(DW.ACCESS.public); | 3173 | .struct_decl => { |
| 2603 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_enum.fqn.toSlice(ip)); | 3174 | const decl = zf.zir.?.getStructDecl(src_inst.inst); |
| 2604 | }, | 3175 | break :decl .{ decl.src_line, decl.src_column, decl.capture_names }; |
| 2605 | .union_type => { | 3176 | }, |
| 2606 | const loaded_union = ip.loadUnionType(instance_val); | 3177 | .reify_struct => { |
| 2607 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( | 3178 | const decl = zf.zir.?.extraData(std.zig.Zir.Inst.ReifyStruct, inst.data.extended.operand).data; |
| 2608 | ip.namespacePtr(loaded_union.namespace).parent.unwrap().?, | 3179 | break :decl .{ decl.src_line, decl.src_column, &.{} }; |
| 2609 | ).owner_type); | 3180 | }, |
| 2610 | try diw.writeUleb128(try dwarf.refAbbrevCode(.decl_specification_union)); | 3181 | }, |
| 2611 | try dwarf.secOffset(di_nw, parent_ni, 0); | 3182 | }; |
| 2612 | try diw.writeInt(u32, 0, dwarf.endian); | 3183 | break :container .{ |
| 2613 | try diw.writeUleb128(0); | 3184 | .@"struct", |
| 2614 | try diw.writeByte(DW.ACCESS.public); | 3185 | zf, |
| 2615 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_union.fqn.toSlice(ip)); | 3186 | src_line, |
| 2616 | }, | 3187 | src_column, |
| 2617 | } | 3188 | capture_names, |
| 2618 | try dwarf.genDebugInfoPadding(diw, diw.unusedCapacityLen()); | 3189 | loaded_struct.captures, |
| 2619 | } | 3190 | loaded_struct.name, |
| 2620 | | 3191 | loaded_struct.name_nav, |
| 2621 | pub fn updateLineNumber( | 3192 | loaded_struct.namespace, |
| 2622 | dwarf: *Dwarf, | 3193 | }; |
| 2623 | mf: *MappedFile, | 3194 | }, |
| 2624 | inst: InternPool.TrackedInst.Index, | 3195 | .union_type => { |
| 2625 | line: u32, | 3196 | const loaded_union = ip.loadUnionType(instance_val); |
| 2626 | ) void { | 3197 | const src_inst = loaded_union.zir_index.resolveFull(ip) orelse { |
| 2627 | const di = dwarf.getDeclIfExists(inst) orelse return; | 3198 | try diw.writeUleb128(try dwarf.refAbbrevCode(.decl_lost)); |
| 2628 | const decl_ni = di.get(dwarf).debug_info_ni.unwrap().?; | 3199 | break :done; |
| 2629 | std.mem.writeInt( | 3200 | }; |
| 2630 | u32, | 3201 | const zf = zcu.fileByIndex(src_inst.file); |
| 2631 | decl_ni.slice(mf)[AbbrevCode.decl_size..][0..4], | 3202 | const inst = zf.zir.?.instructions.get(@backingInt(src_inst.inst)); |
| 2632 | line + 1, | 3203 | const src_line, const src_column, const capture_names = decl: switch (inst.tag) { |
| 2633 | dwarf.endian, | 3204 | else => unreachable, |
| 2634 | ); | 3205 | .extended => switch (inst.data.extended.opcode) { |
| 2635 | } | 3206 | else => unreachable, |
| 2636 | | 3207 | .union_decl => { |
| 2637 | pub fn lostTracking(dwarf: *Dwarf, diw: *std.Io.Writer) link.EmitError!void { | 3208 | const decl = zf.zir.?.getUnionDecl(src_inst.inst); |
| 2638 | try diw.writeUleb128(try dwarf.refAbbrevCode(.decl_lost)); | 3209 | break :decl .{ decl.src_line, decl.src_column, decl.capture_names }; |
| | 3210 | }, |
| | 3211 | .reify_union => { |
| | 3212 | const decl = zf.zir.?.extraData(std.zig.Zir.Inst.ReifyUnion, inst.data.extended.operand).data; |
| | 3213 | break :decl .{ decl.src_line, decl.src_column, &.{} }; |
| | 3214 | }, |
| | 3215 | }, |
| | 3216 | }; |
| | 3217 | break :container .{ |
| | 3218 | .@"union", |
| | 3219 | zf, |
| | 3220 | src_line, |
| | 3221 | src_column, |
| | 3222 | capture_names, |
| | 3223 | loaded_union.captures, |
| | 3224 | loaded_union.name, |
| | 3225 | loaded_union.name_nav, |
| | 3226 | loaded_union.namespace, |
| | 3227 | }; |
| | 3228 | }, |
| | 3229 | .enum_type => { |
| | 3230 | const loaded_enum = ip.loadEnumType(instance_val); |
| | 3231 | const src_inst = loaded_enum.zir_index.unwrap().?.resolveFull(ip) orelse { |
| | 3232 | try diw.writeUleb128(try dwarf.refAbbrevCode(.decl_lost)); |
| | 3233 | break :done; |
| | 3234 | }; |
| | 3235 | const zf = zcu.fileByIndex(src_inst.file); |
| | 3236 | const inst = zf.zir.?.instructions.get(@backingInt(src_inst.inst)); |
| | 3237 | const src_line, const src_column, const capture_names = decl: switch (inst.tag) { |
| | 3238 | else => unreachable, |
| | 3239 | .extended => switch (inst.data.extended.opcode) { |
| | 3240 | else => unreachable, |
| | 3241 | .enum_decl => { |
| | 3242 | const decl = zf.zir.?.getEnumDecl(src_inst.inst); |
| | 3243 | break :decl .{ decl.src_line, decl.src_column, decl.capture_names }; |
| | 3244 | }, |
| | 3245 | .reify_enum => { |
| | 3246 | const decl = zf.zir.?.extraData(std.zig.Zir.Inst.ReifyEnum, inst.data.extended.operand).data; |
| | 3247 | break :decl .{ decl.src_line, decl.src_column, &.{} }; |
| | 3248 | }, |
| | 3249 | }, |
| | 3250 | }; |
| | 3251 | break :container .{ |
| | 3252 | .@"enum", |
| | 3253 | zf, |
| | 3254 | src_line, |
| | 3255 | src_column, |
| | 3256 | capture_names, |
| | 3257 | loaded_enum.captures, |
| | 3258 | loaded_enum.name, |
| | 3259 | loaded_enum.name_nav, |
| | 3260 | loaded_enum.namespace, |
| | 3261 | }; |
| | 3262 | }, |
| | 3263 | .opaque_type => { |
| | 3264 | const loaded_opaque = ip.loadOpaqueType(instance_val); |
| | 3265 | const src_inst = loaded_opaque.zir_index.resolveFull(ip) orelse { |
| | 3266 | try diw.writeUleb128(try dwarf.refAbbrevCode(.decl_lost)); |
| | 3267 | break :done; |
| | 3268 | }; |
| | 3269 | const zf = zcu.fileByIndex(src_inst.file); |
| | 3270 | const decl = zf.zir.?.getOpaqueDecl(src_inst.inst); |
| | 3271 | break :container .{ |
| | 3272 | .@"struct", |
| | 3273 | zf, |
| | 3274 | decl.src_line, |
| | 3275 | decl.src_column, |
| | 3276 | decl.capture_names, |
| | 3277 | loaded_opaque.captures, |
| | 3278 | loaded_opaque.name, |
| | 3279 | loaded_opaque.name_nav, |
| | 3280 | loaded_opaque.namespace, |
| | 3281 | }; |
| | 3282 | }, |
| | 3283 | }; |
| | 3284 | if (maybe_name_nav.unwrap()) |name_ni| { |
| | 3285 | const name_nav = ip.getNav(name_ni); |
| | 3286 | const decl = zf.zir.?.getDeclaration(name_nav.srcInst(ip).resolve(ip).?); |
| | 3287 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( |
| | 3288 | name_nav.analysis.?.namespace, |
| | 3289 | ).owner_type); |
| | 3290 | try diw.writeUleb128(try dwarf.refAbbrevCode(if (captures.len > 0) switch (kind) { |
| | 3291 | .@"struct" => .decl_specification_struct, |
| | 3292 | .@"union" => .decl_specification_union, |
| | 3293 | .@"enum" => .decl_specification_enum, |
| | 3294 | } else switch (kind) { |
| | 3295 | .@"struct" => .decl_specification_empty_struct, |
| | 3296 | .@"union" => .decl_specification_empty_union, |
| | 3297 | .@"enum" => .decl_specification_empty_enum, |
| | 3298 | })); |
| | 3299 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| | 3300 | try diw.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| | 3301 | try diw.writeUleb128(decl.src_column + 1); |
| | 3302 | try diw.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); |
| | 3303 | try dwarf.strp(&dwarf.debug_str, di_nw, name.toSlice(ip)); |
| | 3304 | } else { |
| | 3305 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( |
| | 3306 | ip.namespacePtr(namespace).parent.unwrap().?, |
| | 3307 | ).owner_type); |
| | 3308 | try diw.writeUleb128(try dwarf.refAbbrevCode(if (captures.len > 0) switch (kind) { |
| | 3309 | .@"struct" => .type_decl_specification_struct, |
| | 3310 | .@"union" => .type_decl_specification_union, |
| | 3311 | .@"enum" => .type_decl_specification_enum, |
| | 3312 | } else switch (kind) { |
| | 3313 | .@"struct" => .type_decl_specification_empty_struct, |
| | 3314 | .@"union" => .type_decl_specification_empty_union, |
| | 3315 | .@"enum" => .type_decl_specification_empty_enum, |
| | 3316 | })); |
| | 3317 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| | 3318 | try diw.writeInt(u32, src_line + 1, dwarf.endian); |
| | 3319 | try diw.writeUleb128(src_column + 1); |
| | 3320 | try dwarf.strp(&dwarf.debug_str, di_nw, name.toSlice(ip)); |
| | 3321 | } |
| | 3322 | for (capture_names, captures.get(ip)) |capture_name, capture| { |
| | 3323 | try diw.writeUleb128(try dwarf.refAbbrevCode(.capture_specification)); |
| | 3324 | switch (capture.unwrap()) { |
| | 3325 | .@"comptime", .runtime, .nav_val => try dwarf.strp( |
| | 3326 | &dwarf.debug_str, |
| | 3327 | di_nw, |
| | 3328 | zf.zir.?.nullTerminatedString(capture_name), |
| | 3329 | ), |
| | 3330 | .nav_ref => { |
| | 3331 | const capture_name_slice = try zcu.gpa.print("&{s}", .{ |
| | 3332 | zf.zir.?.nullTerminatedString(capture_name), |
| | 3333 | }); |
| | 3334 | defer zcu.gpa.free(capture_name_slice); |
| | 3335 | try dwarf.strp(&dwarf.debug_str, di_nw, capture_name_slice); |
| | 3336 | }, |
| | 3337 | } |
| | 3338 | } |
| | 3339 | if (captures.len > 0) try diw.writeUleb128(@backingInt(AbbrevCode.null)); |
| | 3340 | } |
| | 3341 | try dwarf.genDebugInfoPadding(diw, diw.unusedCapacityLen()); |
| | 3342 | } |
| | 3343 | |
| | 3344 | pub fn updateLineNumber( |
| | 3345 | dwarf: *Dwarf, |
| | 3346 | mf: *MappedFile, |
| | 3347 | inst: InternPool.TrackedInst.Index, |
| | 3348 | line: u32, |
| | 3349 | ) void { |
| | 3350 | const di = dwarf.getDeclIfExists(inst) orelse return; |
| | 3351 | const decl_ni = di.get(dwarf).debug_info_ni.unwrap().?; |
| | 3352 | std.mem.writeInt( |
| | 3353 | u32, |
| | 3354 | decl_ni.slice(mf)[AbbrevCode.decl_size..][0..4], |
| | 3355 | line + 1, |
| | 3356 | dwarf.endian, |
| | 3357 | ); |
| | 3358 | } |
| | 3359 | |
| | 3360 | pub fn lostTracking(dwarf: *Dwarf, diw: *std.Io.Writer) link.EmitError!void { |
| | 3361 | try diw.writeUleb128(try dwarf.refAbbrevCode(.decl_lost)); |
| 2639 | } | 3362 | } |
| 2640 | | 3363 | |
| 2641 | fn refAbbrevCodeIfExists( | 3364 | fn refAbbrevCodeIfExists( |
| ... | @@ -2746,6 +3469,14 @@ fn blockConst( | ... | @@ -2746,6 +3469,14 @@ fn blockConst( |
| 2746 | assert(start + size == nw.interface.end); | 3469 | assert(start + size == nw.interface.end); |
| 2747 | } | 3470 | } |
| 2748 | | 3471 | |
| | 3472 | fn refType( |
| | 3473 | dwarf: *Dwarf, |
| | 3474 | pt: Zcu.PerThread, |
| | 3475 | nw: *MappedFile.Node.Writer, |
| | 3476 | ty: Type, |
| | 3477 | ) link.EmitError!void { |
| | 3478 | return dwarf.refConst(pt, nw, ty.toValue()); |
| | 3479 | } |
| 2749 | fn refConst( | 3480 | fn refConst( |
| 2750 | dwarf: *Dwarf, | 3481 | dwarf: *Dwarf, |
| 2751 | pt: Zcu.PerThread, | 3482 | pt: Zcu.PerThread, |
| ... | @@ -2875,14 +3606,38 @@ pub const AbbrevCode = enum { | ... | @@ -2875,14 +3606,38 @@ pub const AbbrevCode = enum { |
| 2875 | // decl, specification, and instance codes are assumed to all have the same uleb128 size | 3606 | // decl, specification, and instance codes are assumed to all have the same uleb128 size |
| 2876 | decl_lost, | 3607 | decl_lost, |
| 2877 | decl_alias, | 3608 | decl_alias, |
| | 3609 | decl_empty_incomplete_enum, |
| | 3610 | decl_incomplete_enum, |
| 2878 | decl_empty_enum, | 3611 | decl_empty_enum, |
| 2879 | decl_enum, | 3612 | decl_enum, |
| 2880 | decl_namespace_struct, | 3613 | type_decl_empty_incomplete_enum, |
| 2881 | decl_capturing_namespace_struct, | 3614 | type_decl_incomplete_enum, |
| | 3615 | type_decl_empty_enum, |
| | 3616 | type_decl_enum, |
| | 3617 | decl_empty_incomplete_struct, |
| | 3618 | decl_incomplete_struct, |
| | 3619 | decl_empty_struct, |
| 2882 | decl_struct, | 3620 | decl_struct, |
| | 3621 | type_decl_empty_incomplete_struct, |
| | 3622 | type_decl_incomplete_struct, |
| | 3623 | type_decl_empty_struct, |
| | 3624 | type_decl_struct, |
| | 3625 | decl_empty_packed_struct, |
| 2883 | decl_packed_struct, | 3626 | decl_packed_struct, |
| | 3627 | type_decl_empty_packed_struct, |
| | 3628 | type_decl_packed_struct, |
| | 3629 | decl_empty_incomplete_union, |
| | 3630 | decl_incomplete_union, |
| | 3631 | decl_empty_union, |
| 2884 | decl_union, | 3632 | decl_union, |
| | 3633 | type_decl_empty_incomplete_union, |
| | 3634 | type_decl_incomplete_union, |
| | 3635 | type_decl_empty_union, |
| | 3636 | type_decl_union, |
| | 3637 | decl_empty_packed_union, |
| 2885 | decl_packed_union, | 3638 | decl_packed_union, |
| | 3639 | type_decl_empty_packed_union, |
| | 3640 | type_decl_packed_union, |
| 2886 | decl_var, | 3641 | decl_var, |
| 2887 | decl_const, | 3642 | decl_const, |
| 2888 | decl_const_runtime_bits, | 3643 | decl_const_runtime_bits, |
| ... | @@ -2894,17 +3649,35 @@ pub const AbbrevCode = enum { | ... | @@ -2894,17 +3649,35 @@ pub const AbbrevCode = enum { |
| 2894 | decl_func_generic, | 3649 | decl_func_generic, |
| 2895 | decl_extern_nullary_func, | 3650 | decl_extern_nullary_func, |
| 2896 | decl_extern_func, | 3651 | decl_extern_func, |
| | 3652 | decl_specification_empty_struct, |
| 2897 | decl_specification_struct, | 3653 | decl_specification_struct, |
| | 3654 | type_decl_specification_empty_struct, |
| | 3655 | type_decl_specification_struct, |
| | 3656 | decl_specification_empty_enum, |
| 2898 | decl_specification_enum, | 3657 | decl_specification_enum, |
| | 3658 | type_decl_specification_empty_enum, |
| | 3659 | type_decl_specification_enum, |
| | 3660 | decl_specification_empty_union, |
| 2899 | decl_specification_union, | 3661 | decl_specification_union, |
| | 3662 | type_decl_specification_empty_union, |
| | 3663 | type_decl_specification_union, |
| 2900 | decl_specification_func, | 3664 | decl_specification_func, |
| 2901 | decl_instance_alias, | 3665 | decl_instance_alias, |
| | 3666 | decl_instance_empty_incomplete_enum, |
| | 3667 | decl_instance_incomplete_enum, |
| 2902 | decl_instance_empty_enum, | 3668 | decl_instance_empty_enum, |
| 2903 | decl_instance_enum, | 3669 | decl_instance_enum, |
| 2904 | decl_instance_namespace_struct, | 3670 | decl_instance_empty_incomplete_struct, |
| | 3671 | decl_instance_incomplete_struct, |
| | 3672 | decl_instance_empty_struct, |
| 2905 | decl_instance_struct, | 3673 | decl_instance_struct, |
| | 3674 | decl_instance_empty_packed_struct, |
| 2906 | decl_instance_packed_struct, | 3675 | decl_instance_packed_struct, |
| | 3676 | decl_instance_empty_incomplete_union, |
| | 3677 | decl_instance_incomplete_union, |
| | 3678 | decl_instance_empty_union, |
| 2907 | decl_instance_union, | 3679 | decl_instance_union, |
| | 3680 | decl_instance_empty_packed_union, |
| 2908 | decl_instance_packed_union, | 3681 | decl_instance_packed_union, |
| 2909 | decl_instance_var, | 3682 | decl_instance_var, |
| 2910 | decl_instance_const, | 3683 | decl_instance_const, |
| ... | @@ -2963,17 +3736,7 @@ pub const AbbrevCode = enum { | ... | @@ -2963,17 +3736,7 @@ pub const AbbrevCode = enum { |
| 2963 | generated_empty_struct_type, | 3736 | generated_empty_struct_type, |
| 2964 | generated_struct_type, | 3737 | generated_struct_type, |
| 2965 | generated_union_type, | 3738 | generated_union_type, |
| 2966 | empty_enum_type, | 3739 | capture_specification, |
| 2967 | enum_type, | | |
| 2968 | empty_struct_type, | | |
| 2969 | capturing_empty_struct_type, | | |
| 2970 | struct_type, | | |
| 2971 | empty_packed_struct_type, | | |
| 2972 | packed_struct_type, | | |
| 2973 | empty_union_type, | | |
| 2974 | union_type, | | |
| 2975 | empty_packed_union_type, | | |
| 2976 | packed_union_type, | | |
| 2977 | comptime_capture, | 3740 | comptime_capture, |
| 2978 | comptime_capture_runtime, | 3741 | comptime_capture_runtime, |
| 2979 | comptime_capture_partially_comptime, | 3742 | comptime_capture_partially_comptime, |
| ... | @@ -3032,13 +3795,19 @@ pub const AbbrevCode = enum { | ... | @@ -3032,13 +3795,19 @@ pub const AbbrevCode = enum { |
| 3032 | .{ .accessibility, .data1 }, | 3795 | .{ .accessibility, .data1 }, |
| 3033 | .{ .name, .strp }, | 3796 | .{ .name, .strp }, |
| 3034 | }; | 3797 | }; |
| 3035 | | 3798 | const type_decl_attrs = &[_]Attr{ |
| | 3799 | .{ .ZIG_parent, .ref_addr }, |
| | 3800 | .{ .decl_line, .data4 }, |
| | 3801 | .{ .decl_column, .udata }, |
| | 3802 | .{ .name, .strp }, |
| | 3803 | }; |
| 3036 | const decl_specification_attrs = decl_attrs ++ &[_]Attr{ | 3804 | const decl_specification_attrs = decl_attrs ++ &[_]Attr{ |
| 3037 | .{ .declaration, .flag_present }, | 3805 | .{ .declaration, .flag_present }, |
| 3038 | }; | 3806 | }; |
| 3039 | | 3807 | const type_decl_specification_attrs = type_decl_attrs ++ &[_]Attr{ |
| | 3808 | .{ .declaration, .flag_present }, |
| | 3809 | }; |
| 3040 | const decl_instance_attrs = &[_]Attr{ | 3810 | const decl_instance_attrs = &[_]Attr{ |
| 3041 | .{ .ZIG_parent, .ref_addr }, | | |
| 3042 | .{ .specification, .ref_addr }, | 3811 | .{ .specification, .ref_addr }, |
| 3043 | }; | 3812 | }; |
| 3044 | | 3813 | |
| ... | @@ -3066,6 +3835,15 @@ pub const AbbrevCode = enum { | ... | @@ -3066,6 +3835,15 @@ pub const AbbrevCode = enum { |
| 3066 | .{ .import, .ref_addr }, | 3835 | .{ .import, .ref_addr }, |
| 3067 | }, | 3836 | }, |
| 3068 | }, | 3837 | }, |
| | 3838 | .decl_empty_incomplete_enum = .{ |
| | 3839 | .tag = .enumeration_type, |
| | 3840 | .attrs = decl_attrs, |
| | 3841 | }, |
| | 3842 | .decl_incomplete_enum = .{ |
| | 3843 | .tag = .enumeration_type, |
| | 3844 | .children = true, |
| | 3845 | .attrs = decl_attrs, |
| | 3846 | }, |
| 3069 | .decl_empty_enum = .{ | 3847 | .decl_empty_enum = .{ |
| 3070 | .tag = .enumeration_type, | 3848 | .tag = .enumeration_type, |
| 3071 | .attrs = decl_attrs ++ .{ | 3849 | .attrs = decl_attrs ++ .{ |
| ... | @@ -3079,17 +3857,42 @@ pub const AbbrevCode = enum { | ... | @@ -3079,17 +3857,42 @@ pub const AbbrevCode = enum { |
| 3079 | .{ .type, .ref_addr }, | 3857 | .{ .type, .ref_addr }, |
| 3080 | }, | 3858 | }, |
| 3081 | }, | 3859 | }, |
| 3082 | .decl_namespace_struct = .{ | 3860 | .type_decl_empty_incomplete_enum = .{ |
| 3083 | .tag = .structure_type, | 3861 | .tag = .enumeration_type, |
| 3084 | .attrs = decl_attrs ++ .{ | 3862 | .attrs = type_decl_attrs, |
| 3085 | .{ .declaration, .flag }, | 3863 | }, |
| | 3864 | .type_decl_incomplete_enum = .{ |
| | 3865 | .tag = .enumeration_type, |
| | 3866 | .children = true, |
| | 3867 | .attrs = type_decl_attrs, |
| | 3868 | }, |
| | 3869 | .type_decl_empty_enum = .{ |
| | 3870 | .tag = .enumeration_type, |
| | 3871 | .attrs = type_decl_attrs ++ .{ |
| | 3872 | .{ .type, .ref_addr }, |
| | 3873 | }, |
| | 3874 | }, |
| | 3875 | .type_decl_enum = .{ |
| | 3876 | .tag = .enumeration_type, |
| | 3877 | .children = true, |
| | 3878 | .attrs = type_decl_attrs ++ .{ |
| | 3879 | .{ .type, .ref_addr }, |
| 3086 | }, | 3880 | }, |
| 3087 | }, | 3881 | }, |
| 3088 | .decl_capturing_namespace_struct = .{ | 3882 | .decl_empty_incomplete_struct = .{ |
| | 3883 | .tag = .structure_type, |
| | 3884 | .attrs = decl_attrs, |
| | 3885 | }, |
| | 3886 | .decl_incomplete_struct = .{ |
| 3089 | .tag = .structure_type, | 3887 | .tag = .structure_type, |
| 3090 | .children = true, | 3888 | .children = true, |
| | 3889 | .attrs = decl_attrs, |
| | 3890 | }, |
| | 3891 | .decl_empty_struct = .{ |
| | 3892 | .tag = .structure_type, |
| 3091 | .attrs = decl_attrs ++ .{ | 3893 | .attrs = decl_attrs ++ .{ |
| 3092 | .{ .declaration, .flag }, | 3894 | .{ .byte_size, .udata }, |
| | 3895 | .{ .alignment, .udata }, |
| 3093 | }, | 3896 | }, |
| 3094 | }, | 3897 | }, |
| 3095 | .decl_struct = .{ | 3898 | .decl_struct = .{ |
| ... | @@ -3100,6 +3903,36 @@ pub const AbbrevCode = enum { | ... | @@ -3100,6 +3903,36 @@ pub const AbbrevCode = enum { |
| 3100 | .{ .alignment, .udata }, | 3903 | .{ .alignment, .udata }, |
| 3101 | }, | 3904 | }, |
| 3102 | }, | 3905 | }, |
| | 3906 | .type_decl_empty_incomplete_struct = .{ |
| | 3907 | .tag = .structure_type, |
| | 3908 | .attrs = type_decl_attrs, |
| | 3909 | }, |
| | 3910 | .type_decl_incomplete_struct = .{ |
| | 3911 | .tag = .structure_type, |
| | 3912 | .children = true, |
| | 3913 | .attrs = type_decl_attrs, |
| | 3914 | }, |
| | 3915 | .type_decl_empty_struct = .{ |
| | 3916 | .tag = .structure_type, |
| | 3917 | .attrs = type_decl_attrs ++ .{ |
| | 3918 | .{ .byte_size, .udata }, |
| | 3919 | .{ .alignment, .udata }, |
| | 3920 | }, |
| | 3921 | }, |
| | 3922 | .type_decl_struct = .{ |
| | 3923 | .tag = .structure_type, |
| | 3924 | .children = true, |
| | 3925 | .attrs = type_decl_attrs ++ .{ |
| | 3926 | .{ .byte_size, .udata }, |
| | 3927 | .{ .alignment, .udata }, |
| | 3928 | }, |
| | 3929 | }, |
| | 3930 | .decl_empty_packed_struct = .{ |
| | 3931 | .tag = .structure_type, |
| | 3932 | .attrs = decl_attrs ++ .{ |
| | 3933 | .{ .type, .ref_addr }, |
| | 3934 | }, |
| | 3935 | }, |
| 3103 | .decl_packed_struct = .{ | 3936 | .decl_packed_struct = .{ |
| 3104 | .tag = .structure_type, | 3937 | .tag = .structure_type, |
| 3105 | .children = true, | 3938 | .children = true, |
| ... | @@ -3107,6 +3940,35 @@ pub const AbbrevCode = enum { | ... | @@ -3107,6 +3940,35 @@ pub const AbbrevCode = enum { |
| 3107 | .{ .type, .ref_addr }, | 3940 | .{ .type, .ref_addr }, |
| 3108 | }, | 3941 | }, |
| 3109 | }, | 3942 | }, |
| | 3943 | .type_decl_empty_packed_struct = .{ |
| | 3944 | .tag = .structure_type, |
| | 3945 | .attrs = type_decl_attrs ++ .{ |
| | 3946 | .{ .type, .ref_addr }, |
| | 3947 | }, |
| | 3948 | }, |
| | 3949 | .type_decl_packed_struct = .{ |
| | 3950 | .tag = .structure_type, |
| | 3951 | .children = true, |
| | 3952 | .attrs = type_decl_attrs ++ .{ |
| | 3953 | .{ .type, .ref_addr }, |
| | 3954 | }, |
| | 3955 | }, |
| | 3956 | .decl_empty_incomplete_union = .{ |
| | 3957 | .tag = .union_type, |
| | 3958 | .attrs = decl_attrs, |
| | 3959 | }, |
| | 3960 | .decl_incomplete_union = .{ |
| | 3961 | .tag = .union_type, |
| | 3962 | .children = true, |
| | 3963 | .attrs = decl_attrs, |
| | 3964 | }, |
| | 3965 | .decl_empty_union = .{ |
| | 3966 | .tag = .union_type, |
| | 3967 | .attrs = decl_attrs ++ .{ |
| | 3968 | .{ .byte_size, .udata }, |
| | 3969 | .{ .alignment, .udata }, |
| | 3970 | }, |
| | 3971 | }, |
| 3110 | .decl_union = .{ | 3972 | .decl_union = .{ |
| 3111 | .tag = .union_type, | 3973 | .tag = .union_type, |
| 3112 | .children = true, | 3974 | .children = true, |
| ... | @@ -3115,6 +3977,36 @@ pub const AbbrevCode = enum { | ... | @@ -3115,6 +3977,36 @@ pub const AbbrevCode = enum { |
| 3115 | .{ .alignment, .udata }, | 3977 | .{ .alignment, .udata }, |
| 3116 | }, | 3978 | }, |
| 3117 | }, | 3979 | }, |
| | 3980 | .type_decl_empty_incomplete_union = .{ |
| | 3981 | .tag = .union_type, |
| | 3982 | .attrs = type_decl_attrs, |
| | 3983 | }, |
| | 3984 | .type_decl_incomplete_union = .{ |
| | 3985 | .tag = .union_type, |
| | 3986 | .children = true, |
| | 3987 | .attrs = type_decl_attrs, |
| | 3988 | }, |
| | 3989 | .type_decl_empty_union = .{ |
| | 3990 | .tag = .union_type, |
| | 3991 | .attrs = type_decl_attrs ++ .{ |
| | 3992 | .{ .byte_size, .udata }, |
| | 3993 | .{ .alignment, .udata }, |
| | 3994 | }, |
| | 3995 | }, |
| | 3996 | .type_decl_union = .{ |
| | 3997 | .tag = .union_type, |
| | 3998 | .children = true, |
| | 3999 | .attrs = type_decl_attrs ++ .{ |
| | 4000 | .{ .byte_size, .udata }, |
| | 4001 | .{ .alignment, .udata }, |
| | 4002 | }, |
| | 4003 | }, |
| | 4004 | .decl_empty_packed_union = .{ |
| | 4005 | .tag = .union_type, |
| | 4006 | .attrs = decl_attrs ++ .{ |
| | 4007 | .{ .type, .ref_addr }, |
| | 4008 | }, |
| | 4009 | }, |
| 3118 | .decl_packed_union = .{ | 4010 | .decl_packed_union = .{ |
| 3119 | .tag = .union_type, | 4011 | .tag = .union_type, |
| 3120 | .children = true, | 4012 | .children = true, |
| ... | @@ -3122,6 +4014,19 @@ pub const AbbrevCode = enum { | ... | @@ -3122,6 +4014,19 @@ pub const AbbrevCode = enum { |
| 3122 | .{ .type, .ref_addr }, | 4014 | .{ .type, .ref_addr }, |
| 3123 | }, | 4015 | }, |
| 3124 | }, | 4016 | }, |
| | 4017 | .type_decl_empty_packed_union = .{ |
| | 4018 | .tag = .union_type, |
| | 4019 | .attrs = type_decl_attrs ++ .{ |
| | 4020 | .{ .type, .ref_addr }, |
| | 4021 | }, |
| | 4022 | }, |
| | 4023 | .type_decl_packed_union = .{ |
| | 4024 | .tag = .union_type, |
| | 4025 | .children = true, |
| | 4026 | .attrs = type_decl_attrs ++ .{ |
| | 4027 | .{ .type, .ref_addr }, |
| | 4028 | }, |
| | 4029 | }, |
| 3125 | .decl_var = .{ | 4030 | .decl_var = .{ |
| 3126 | .tag = .variable, | 4031 | .tag = .variable, |
| 3127 | .attrs = decl_attrs ++ .{ | 4032 | .attrs = decl_attrs ++ .{ |
| ... | @@ -3200,16 +4105,15 @@ pub const AbbrevCode = enum { | ... | @@ -3200,16 +4105,15 @@ pub const AbbrevCode = enum { |
| 3200 | .decl_nullary_func_generic = .{ | 4105 | .decl_nullary_func_generic = .{ |
| 3201 | .tag = .subprogram, | 4106 | .tag = .subprogram, |
| 3202 | .attrs = decl_attrs ++ .{ | 4107 | .attrs = decl_attrs ++ .{ |
| 3203 | //.{ .type, .ref_addr }, | 4108 | .{ .type, .ref_addr }, |
| 3204 | //.{ .noreturn, .flag }, | 4109 | .{ .noreturn, .flag }, |
| 3205 | }, | 4110 | }, |
| 3206 | }, | 4111 | }, |
| 3207 | .decl_func_generic = .{ | 4112 | .decl_func_generic = .{ |
| 3208 | .tag = .subprogram, | 4113 | .tag = .subprogram, |
| 3209 | .children = true, | 4114 | .children = true, |
| 3210 | .attrs = decl_attrs ++ .{ | 4115 | .attrs = decl_attrs ++ .{ |
| 3211 | //.{ .type, .ref_addr }, | 4116 | .{ .type, .ref_addr }, |
| 3212 | //.{ .noreturn, .flag }, | | |
| 3213 | }, | 4117 | }, |
| 3214 | }, | 4118 | }, |
| 3215 | .decl_extern_nullary_func = .{ | 4119 | .decl_extern_nullary_func = .{ |
| ... | @@ -3233,18 +4137,60 @@ pub const AbbrevCode = enum { | ... | @@ -3233,18 +4137,60 @@ pub const AbbrevCode = enum { |
| 3233 | .{ .noreturn, .flag }, | 4137 | .{ .noreturn, .flag }, |
| 3234 | }, | 4138 | }, |
| 3235 | }, | 4139 | }, |
| | 4140 | .decl_specification_empty_struct = .{ |
| | 4141 | .tag = .structure_type, |
| | 4142 | .attrs = decl_specification_attrs, |
| | 4143 | }, |
| 3236 | .decl_specification_struct = .{ | 4144 | .decl_specification_struct = .{ |
| 3237 | .tag = .structure_type, | 4145 | .tag = .structure_type, |
| | 4146 | .children = true, |
| | 4147 | .attrs = decl_specification_attrs, |
| | 4148 | }, |
| | 4149 | .type_decl_specification_empty_struct = .{ |
| | 4150 | .tag = .structure_type, |
| | 4151 | .attrs = type_decl_specification_attrs, |
| | 4152 | }, |
| | 4153 | .type_decl_specification_struct = .{ |
| | 4154 | .tag = .structure_type, |
| | 4155 | .children = true, |
| | 4156 | .attrs = type_decl_specification_attrs, |
| | 4157 | }, |
| | 4158 | .decl_specification_empty_enum = .{ |
| | 4159 | .tag = .enumeration_type, |
| 3238 | .attrs = decl_specification_attrs, | 4160 | .attrs = decl_specification_attrs, |
| 3239 | }, | 4161 | }, |
| 3240 | .decl_specification_enum = .{ | 4162 | .decl_specification_enum = .{ |
| 3241 | .tag = .enumeration_type, | 4163 | .tag = .enumeration_type, |
| | 4164 | .children = true, |
| | 4165 | .attrs = decl_specification_attrs, |
| | 4166 | }, |
| | 4167 | .type_decl_specification_empty_enum = .{ |
| | 4168 | .tag = .enumeration_type, |
| | 4169 | .attrs = type_decl_specification_attrs, |
| | 4170 | }, |
| | 4171 | .type_decl_specification_enum = .{ |
| | 4172 | .tag = .enumeration_type, |
| | 4173 | .children = true, |
| | 4174 | .attrs = type_decl_specification_attrs, |
| | 4175 | }, |
| | 4176 | .decl_specification_empty_union = .{ |
| | 4177 | .tag = .union_type, |
| 3242 | .attrs = decl_specification_attrs, | 4178 | .attrs = decl_specification_attrs, |
| 3243 | }, | 4179 | }, |
| 3244 | .decl_specification_union = .{ | 4180 | .decl_specification_union = .{ |
| 3245 | .tag = .union_type, | 4181 | .tag = .union_type, |
| | 4182 | .children = true, |
| 3246 | .attrs = decl_specification_attrs, | 4183 | .attrs = decl_specification_attrs, |
| 3247 | }, | 4184 | }, |
| | 4185 | .type_decl_specification_empty_union = .{ |
| | 4186 | .tag = .union_type, |
| | 4187 | .attrs = type_decl_specification_attrs, |
| | 4188 | }, |
| | 4189 | .type_decl_specification_union = .{ |
| | 4190 | .tag = .union_type, |
| | 4191 | .children = true, |
| | 4192 | .attrs = type_decl_specification_attrs, |
| | 4193 | }, |
| 3248 | .decl_specification_func = .{ | 4194 | .decl_specification_func = .{ |
| 3249 | .tag = .subprogram, | 4195 | .tag = .subprogram, |
| 3250 | .attrs = decl_specification_attrs, | 4196 | .attrs = decl_specification_attrs, |
| ... | @@ -3255,6 +4201,15 @@ pub const AbbrevCode = enum { | ... | @@ -3255,6 +4201,15 @@ pub const AbbrevCode = enum { |
| 3255 | .{ .import, .ref_addr }, | 4201 | .{ .import, .ref_addr }, |
| 3256 | }, | 4202 | }, |
| 3257 | }, | 4203 | }, |
| | 4204 | .decl_instance_empty_incomplete_enum = .{ |
| | 4205 | .tag = .enumeration_type, |
| | 4206 | .attrs = decl_instance_attrs, |
| | 4207 | }, |
| | 4208 | .decl_instance_incomplete_enum = .{ |
| | 4209 | .tag = .enumeration_type, |
| | 4210 | .children = true, |
| | 4211 | .attrs = decl_instance_attrs, |
| | 4212 | }, |
| 3258 | .decl_instance_empty_enum = .{ | 4213 | .decl_instance_empty_enum = .{ |
| 3259 | .tag = .enumeration_type, | 4214 | .tag = .enumeration_type, |
| 3260 | .attrs = decl_instance_attrs ++ .{ | 4215 | .attrs = decl_instance_attrs ++ .{ |
| ... | @@ -3268,11 +4223,20 @@ pub const AbbrevCode = enum { | ... | @@ -3268,11 +4223,20 @@ pub const AbbrevCode = enum { |
| 3268 | .{ .type, .ref_addr }, | 4223 | .{ .type, .ref_addr }, |
| 3269 | }, | 4224 | }, |
| 3270 | }, | 4225 | }, |
| 3271 | .decl_instance_namespace_struct = .{ | 4226 | .decl_instance_empty_incomplete_struct = .{ |
| | 4227 | .tag = .structure_type, |
| | 4228 | .attrs = decl_instance_attrs, |
| | 4229 | }, |
| | 4230 | .decl_instance_incomplete_struct = .{ |
| 3272 | .tag = .structure_type, | 4231 | .tag = .structure_type, |
| 3273 | .children = true, | 4232 | .children = true, |
| | 4233 | .attrs = decl_instance_attrs, |
| | 4234 | }, |
| | 4235 | .decl_instance_empty_struct = .{ |
| | 4236 | .tag = .structure_type, |
| 3274 | .attrs = decl_instance_attrs ++ .{ | 4237 | .attrs = decl_instance_attrs ++ .{ |
| 3275 | .{ .declaration, .flag }, | 4238 | .{ .byte_size, .udata }, |
| | 4239 | .{ .alignment, .udata }, |
| 3276 | }, | 4240 | }, |
| 3277 | }, | 4241 | }, |
| 3278 | .decl_instance_struct = .{ | 4242 | .decl_instance_struct = .{ |
| ... | @@ -3283,6 +4247,12 @@ pub const AbbrevCode = enum { | ... | @@ -3283,6 +4247,12 @@ pub const AbbrevCode = enum { |
| 3283 | .{ .alignment, .udata }, | 4247 | .{ .alignment, .udata }, |
| 3284 | }, | 4248 | }, |
| 3285 | }, | 4249 | }, |
| | 4250 | .decl_instance_empty_packed_struct = .{ |
| | 4251 | .tag = .structure_type, |
| | 4252 | .attrs = decl_instance_attrs ++ .{ |
| | 4253 | .{ .type, .ref_addr }, |
| | 4254 | }, |
| | 4255 | }, |
| 3286 | .decl_instance_packed_struct = .{ | 4256 | .decl_instance_packed_struct = .{ |
| 3287 | .tag = .structure_type, | 4257 | .tag = .structure_type, |
| 3288 | .children = true, | 4258 | .children = true, |
| ... | @@ -3290,6 +4260,22 @@ pub const AbbrevCode = enum { | ... | @@ -3290,6 +4260,22 @@ pub const AbbrevCode = enum { |
| 3290 | .{ .type, .ref_addr }, | 4260 | .{ .type, .ref_addr }, |
| 3291 | }, | 4261 | }, |
| 3292 | }, | 4262 | }, |
| | 4263 | .decl_instance_empty_incomplete_union = .{ |
| | 4264 | .tag = .union_type, |
| | 4265 | .attrs = decl_instance_attrs, |
| | 4266 | }, |
| | 4267 | .decl_instance_incomplete_union = .{ |
| | 4268 | .tag = .union_type, |
| | 4269 | .children = true, |
| | 4270 | .attrs = decl_instance_attrs, |
| | 4271 | }, |
| | 4272 | .decl_instance_empty_union = .{ |
| | 4273 | .tag = .union_type, |
| | 4274 | .attrs = decl_instance_attrs ++ .{ |
| | 4275 | .{ .byte_size, .udata }, |
| | 4276 | .{ .alignment, .udata }, |
| | 4277 | }, |
| | 4278 | }, |
| 3293 | .decl_instance_union = .{ | 4279 | .decl_instance_union = .{ |
| 3294 | .tag = .union_type, | 4280 | .tag = .union_type, |
| 3295 | .children = true, | 4281 | .children = true, |
| ... | @@ -3298,6 +4284,12 @@ pub const AbbrevCode = enum { | ... | @@ -3298,6 +4284,12 @@ pub const AbbrevCode = enum { |
| 3298 | .{ .alignment, .udata }, | 4284 | .{ .alignment, .udata }, |
| 3299 | }, | 4285 | }, |
| 3300 | }, | 4286 | }, |
| | 4287 | .decl_instance_empty_packed_union = .{ |
| | 4288 | .tag = .union_type, |
| | 4289 | .attrs = decl_instance_attrs ++ .{ |
| | 4290 | .{ .type, .ref_addr }, |
| | 4291 | }, |
| | 4292 | }, |
| 3301 | .decl_instance_packed_union = .{ | 4293 | .decl_instance_packed_union = .{ |
| 3302 | .tag = .union_type, | 4294 | .tag = .union_type, |
| 3303 | .children = true, | 4295 | .children = true, |
| ... | @@ -3769,114 +4761,21 @@ pub const AbbrevCode = enum { | ... | @@ -3769,114 +4761,21 @@ pub const AbbrevCode = enum { |
| 3769 | .{ .alignment, .udata }, | 4761 | .{ .alignment, .udata }, |
| 3770 | }, | 4762 | }, |
| 3771 | }, | 4763 | }, |
| 3772 | .empty_enum_type = .{ | 4764 | .capture_specification = .{ |
| 3773 | .tag = .enumeration_type, | 4765 | .tag = .template_value_parameter, |
| 3774 | .attrs = &.{ | | |
| 3775 | .{ .decl_file, .udata }, | | |
| 3776 | .{ .name, .strp }, | | |
| 3777 | .{ .type, .ref_addr }, | | |
| 3778 | }, | | |
| 3779 | }, | | |
| 3780 | .enum_type = .{ | | |
| 3781 | .tag = .enumeration_type, | | |
| 3782 | .children = true, | | |
| 3783 | .attrs = &.{ | | |
| 3784 | .{ .decl_file, .udata }, | | |
| 3785 | .{ .name, .strp }, | | |
| 3786 | .{ .type, .ref_addr }, | | |
| 3787 | }, | | |
| 3788 | }, | | |
| 3789 | .empty_struct_type = .{ | | |
| 3790 | .tag = .structure_type, | | |
| 3791 | .attrs = &.{ | | |
| 3792 | .{ .decl_file, .udata }, | | |
| 3793 | .{ .name, .strp }, | | |
| 3794 | .{ .declaration, .flag }, | | |
| 3795 | }, | | |
| 3796 | }, | | |
| 3797 | .capturing_empty_struct_type = .{ | | |
| 3798 | .tag = .structure_type, | | |
| 3799 | .children = true, | | |
| 3800 | .attrs = &.{ | | |
| 3801 | .{ .decl_file, .udata }, | | |
| 3802 | .{ .name, .strp }, | | |
| 3803 | .{ .declaration, .flag }, | | |
| 3804 | }, | | |
| 3805 | }, | | |
| 3806 | .struct_type = .{ | | |
| 3807 | .tag = .structure_type, | | |
| 3808 | .children = true, | | |
| 3809 | .attrs = &.{ | | |
| 3810 | .{ .decl_file, .udata }, | | |
| 3811 | .{ .name, .strp }, | | |
| 3812 | .{ .byte_size, .udata }, | | |
| 3813 | .{ .alignment, .udata }, | | |
| 3814 | }, | | |
| 3815 | }, | | |
| 3816 | .empty_packed_struct_type = .{ | | |
| 3817 | .tag = .structure_type, | | |
| 3818 | .attrs = &.{ | | |
| 3819 | .{ .decl_file, .udata }, | | |
| 3820 | .{ .name, .strp }, | | |
| 3821 | .{ .type, .ref_addr }, | | |
| 3822 | }, | | |
| 3823 | }, | | |
| 3824 | .packed_struct_type = .{ | | |
| 3825 | .tag = .structure_type, | | |
| 3826 | .children = true, | | |
| 3827 | .attrs = &.{ | | |
| 3828 | .{ .decl_file, .udata }, | | |
| 3829 | .{ .name, .strp }, | | |
| 3830 | .{ .type, .ref_addr }, | | |
| 3831 | }, | | |
| 3832 | }, | | |
| 3833 | .empty_union_type = .{ | | |
| 3834 | .tag = .union_type, | | |
| 3835 | .attrs = &.{ | | |
| 3836 | .{ .decl_file, .udata }, | | |
| 3837 | .{ .name, .strp }, | | |
| 3838 | .{ .byte_size, .udata }, | | |
| 3839 | .{ .alignment, .udata }, | | |
| 3840 | }, | | |
| 3841 | }, | | |
| 3842 | .union_type = .{ | | |
| 3843 | .tag = .union_type, | | |
| 3844 | .children = true, | | |
| 3845 | .attrs = &.{ | | |
| 3846 | .{ .decl_file, .udata }, | | |
| 3847 | .{ .name, .strp }, | | |
| 3848 | .{ .byte_size, .udata }, | | |
| 3849 | .{ .alignment, .udata }, | | |
| 3850 | }, | | |
| 3851 | }, | | |
| 3852 | .empty_packed_union_type = .{ | | |
| 3853 | .tag = .union_type, | | |
| 3854 | .attrs = &.{ | | |
| 3855 | .{ .decl_file, .udata }, | | |
| 3856 | .{ .name, .strp }, | | |
| 3857 | .{ .type, .ref_addr }, | | |
| 3858 | }, | | |
| 3859 | }, | | |
| 3860 | .packed_union_type = .{ | | |
| 3861 | .tag = .union_type, | | |
| 3862 | .children = true, | | |
| 3863 | .attrs = &.{ | 4766 | .attrs = &.{ |
| 3864 | .{ .decl_file, .udata }, | | |
| 3865 | .{ .name, .strp }, | 4767 | .{ .name, .strp }, |
| 3866 | .{ .type, .ref_addr }, | | |
| 3867 | }, | 4768 | }, |
| 3868 | }, | 4769 | }, |
| 3869 | .comptime_capture = .{ | 4770 | .comptime_capture = .{ |
| 3870 | .tag = .template_value_parameter, | 4771 | .tag = .template_value_parameter, |
| 3871 | .attrs = &.{ | 4772 | .attrs = &.{ |
| 3872 | .{ .name, .strp }, | | |
| 3873 | .{ .type, .ref_addr }, | 4773 | .{ .type, .ref_addr }, |
| 3874 | }, | 4774 | }, |
| 3875 | }, | 4775 | }, |
| 3876 | .comptime_capture_runtime = .{ | 4776 | .comptime_capture_runtime = .{ |
| 3877 | .tag = .template_value_parameter, | 4777 | .tag = .template_value_parameter, |
| 3878 | .attrs = &.{ | 4778 | .attrs = &.{ |
| 3879 | .{ .name, .strp }, | | |
| 3880 | .{ .type, .ref_addr }, | 4779 | .{ .type, .ref_addr }, |
| 3881 | .{ .const_value, .block }, | 4780 | .{ .const_value, .block }, |
| 3882 | }, | 4781 | }, |
| ... | @@ -3884,7 +4783,6 @@ pub const AbbrevCode = enum { | ... | @@ -3884,7 +4783,6 @@ pub const AbbrevCode = enum { |
| 3884 | .comptime_capture_partially_comptime = .{ | 4783 | .comptime_capture_partially_comptime = .{ |
| 3885 | .tag = .template_value_parameter, | 4784 | .tag = .template_value_parameter, |
| 3886 | .attrs = &.{ | 4785 | .attrs = &.{ |
| 3887 | .{ .name, .strp }, | | |
| 3888 | .{ .type, .ref_addr }, | 4786 | .{ .type, .ref_addr }, |
| 3889 | .{ .const_value, .block }, | 4787 | .{ .const_value, .block }, |
| 3890 | .{ .ZIG_comptime_value, .ref_addr }, | 4788 | .{ .ZIG_comptime_value, .ref_addr }, |
| ... | @@ -3893,7 +4791,6 @@ pub const AbbrevCode = enum { | ... | @@ -3893,7 +4791,6 @@ pub const AbbrevCode = enum { |
| 3893 | .comptime_capture_fully_comptime = .{ | 4791 | .comptime_capture_fully_comptime = .{ |
| 3894 | .tag = .template_value_parameter, | 4792 | .tag = .template_value_parameter, |
| 3895 | .attrs = &.{ | 4793 | .attrs = &.{ |
| 3896 | .{ .name, .strp }, | | |
| 3897 | .{ .type, .ref_addr }, | 4794 | .{ .type, .ref_addr }, |
| 3898 | .{ .ZIG_comptime_value, .ref_addr }, | 4795 | .{ .ZIG_comptime_value, .ref_addr }, |
| 3899 | }, | 4796 | }, |
| ... | @@ -3901,14 +4798,12 @@ pub const AbbrevCode = enum { | ... | @@ -3901,14 +4798,12 @@ pub const AbbrevCode = enum { |
| 3901 | .runtime_capture = .{ | 4798 | .runtime_capture = .{ |
| 3902 | .tag = .template_type_parameter, | 4799 | .tag = .template_type_parameter, |
| 3903 | .attrs = &.{ | 4800 | .attrs = &.{ |
| 3904 | .{ .name, .strp }, | | |
| 3905 | .{ .type, .ref_addr }, | 4801 | .{ .type, .ref_addr }, |
| 3906 | }, | 4802 | }, |
| 3907 | }, | 4803 | }, |
| 3908 | .nav_capture = .{ | 4804 | .nav_capture = .{ |
| 3909 | .tag = .template_value_parameter, | 4805 | .tag = .template_value_parameter, |
| 3910 | .attrs = &.{ | 4806 | .attrs = &.{ |
| 3911 | .{ .name, .strp }, | | |
| 3912 | .{ .location, .exprloc }, | 4807 | .{ .location, .exprloc }, |
| 3913 | }, | 4808 | }, |
| 3914 | }, | 4809 | }, |