| author | |
| committer | |
| log | 6e49697ef576e86799c8365492082fdee9d216a9 |
| tree | 4d8a85516aff5399acf46ced92a7c055989e19b3 |
| parent | 792830d69cd335a49de97b617d3f668aa544b181 |
| signature |
The x86_64 backend now compiles and, with `-fstrip`, kinda works!6 files changed, 144 insertions(+), 145 deletions(-)
src/InternPool.zig+14| ... | @@ -4150,6 +4150,13 @@ pub const Index = enum(u32) { | ... | @@ -4150,6 +4150,13 @@ pub const Index = enum(u32) { |
| 4150 | const extra = ip.getLocalShared(slice.tid).extra.acquire(); | 4150 | const extra = ip.getLocalShared(slice.tid).extra.acquire(); |
| 4151 | return @ptrCast(extra.view().items(.@"0")[slice.start..][0..slice.len]); | 4151 | return @ptrCast(extra.view().items(.@"0")[slice.start..][0..slice.len]); |
| 4152 | } | 4152 | } |
| 4153 | |||
| 4154 | /// If `slice` is empty (`slice.len == 0`), returns `.none`. | ||
| 4155 | /// Otherwise, asserts that `index < slice.len`, and returns the value at `index`. | ||
| 4156 | pub fn getOrNone(slice: Slice, ip: *const InternPool, index: usize) Index { | ||
| 4157 | if (slice.len == 0) return .none; | ||
| 4158 | return slice.get(ip)[index]; | ||
| 4159 | } | ||
| 4153 | }; | 4160 | }; |
| 4154 | 4161 | ||
| 4155 | /// Used for a map of `Index` values to the index within a list of `Index` values. | 4162 | /// Used for a map of `Index` values to the index within a list of `Index` values. |
| ... | @@ -5981,6 +5988,13 @@ pub const Alignment = enum(u6) { | ... | @@ -5981,6 +5988,13 @@ pub const Alignment = enum(u6) { |
| 5981 | const bytes: []u8 = @ptrCast(extra.view().items(.@"0")[slice.start..]); | 5988 | const bytes: []u8 = @ptrCast(extra.view().items(.@"0")[slice.start..]); |
| 5982 | return @ptrCast(bytes[0..slice.len]); | 5989 | return @ptrCast(bytes[0..slice.len]); |
| 5983 | } | 5990 | } |
| 5991 | |||
| 5992 | /// If `slice` is empty (`slice.len == 0`), returns `.none`. | ||
| 5993 | /// Otherwise, asserts that `index < slice.len`, and returns the value at `index`. | ||
| 5994 | pub fn getOrNone(slice: Slice, ip: *const InternPool, index: usize) Alignment { | ||
| 5995 | if (slice.len == 0) return .none; | ||
| 5996 | return slice.get(ip)[index]; | ||
| 5997 | } | ||
| 5984 | }; | 5998 | }; |
| 5985 | 5999 | ||
| 5986 | pub fn toRelaxedCompareUnits(a: Alignment) u8 { | 6000 | pub fn toRelaxedCompareUnits(a: Alignment) u8 { |
src/Zcu/PerThread.zig+1| ... | @@ -4097,6 +4097,7 @@ pub fn getExtern(pt: Zcu.PerThread, key: InternPool.Key.Extern) Allocator.Error! | ... | @@ -4097,6 +4097,7 @@ pub fn getExtern(pt: Zcu.PerThread, key: InternPool.Key.Extern) Allocator.Error! |
| 4097 | } | 4097 | } |
| 4098 | 4098 | ||
| 4099 | // TODO: this shouldn't need a `PerThread`! Fix the signature of `Type.abiAlignment`. | 4099 | // TODO: this shouldn't need a `PerThread`! Fix the signature of `Type.abiAlignment`. |
| 4100 | // MLUGG TODO: that's done, move it! | ||
| 4100 | pub fn navAlignment(pt: Zcu.PerThread, nav_index: InternPool.Nav.Index) InternPool.Alignment { | 4101 | pub fn navAlignment(pt: Zcu.PerThread, nav_index: InternPool.Nav.Index) InternPool.Alignment { |
| 4101 | const zcu = pt.zcu; | 4102 | const zcu = pt.zcu; |
| 4102 | const ty: Type, const alignment = switch (zcu.intern_pool.getNav(nav_index).status) { | 4103 | const ty: Type, const alignment = switch (zcu.intern_pool.getNav(nav_index).status) { |
src/codegen.zig+37-55| ... | @@ -377,7 +377,7 @@ pub fn generateSymbol( | ... | @@ -377,7 +377,7 @@ pub fn generateSymbol( |
| 377 | .payload => 0, | 377 | .payload => 0, |
| 378 | }; | 378 | }; |
| 379 | 379 | ||
| 380 | if (!payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) { | 380 | if (!payload_ty.hasRuntimeBits(zcu)) { |
| 381 | try w.writeInt(u16, err_val, endian); | 381 | try w.writeInt(u16, err_val, endian); |
| 382 | return; | 382 | return; |
| 383 | } | 383 | } |
| ... | @@ -610,7 +610,7 @@ pub fn generateSymbol( | ... | @@ -610,7 +610,7 @@ pub fn generateSymbol( |
| 610 | .auto, .@"extern" => { | 610 | .auto, .@"extern" => { |
| 611 | const struct_begin = w.end; | 611 | const struct_begin = w.end; |
| 612 | const field_types = struct_type.field_types.get(ip); | 612 | const field_types = struct_type.field_types.get(ip); |
| 613 | const offsets = struct_type.offsets.get(ip); | 613 | const offsets = struct_type.field_offsets.get(ip); |
| 614 | 614 | ||
| 615 | var it = struct_type.iterateRuntimeOrder(ip); | 615 | var it = struct_type.iterateRuntimeOrder(ip); |
| 616 | while (it.next()) |field_index| { | 616 | while (it.next()) |field_index| { |
| ... | @@ -635,13 +635,11 @@ pub fn generateSymbol( | ... | @@ -635,13 +635,11 @@ pub fn generateSymbol( |
| 635 | try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(field_val), w, reloc_parent); | 635 | try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(field_val), w, reloc_parent); |
| 636 | } | 636 | } |
| 637 | 637 | ||
| 638 | const size = struct_type.sizeUnordered(ip); | 638 | assert(struct_type.alignment.check(struct_type.size)); |
| 639 | const alignment = struct_type.flagsUnordered(ip).alignment.toByteUnits().?; | ||
| 640 | 639 | ||
| 641 | const padding = math.cast( | 640 | const padding = math.cast(usize, struct_type.size - (w.end - struct_begin)) orelse { |
| 642 | usize, | 641 | return error.Overflow; |
| 643 | std.mem.alignForward(u64, size, @max(alignment, 1)) - (w.end - struct_begin), | 642 | }; |
| 644 | ) orelse return error.Overflow; | ||
| 645 | if (padding > 0) try w.splatByteAll(0, padding); | 643 | if (padding > 0) try w.splatByteAll(0, padding); |
| 646 | }, | 644 | }, |
| 647 | } | 645 | } |
| ... | @@ -1060,51 +1058,38 @@ pub fn lowerValue(pt: Zcu.PerThread, val: Value, target: *const std.Target) Allo | ... | @@ -1060,51 +1058,38 @@ pub fn lowerValue(pt: Zcu.PerThread, val: Value, target: *const std.Target) Allo |
| 1060 | 1058 | ||
| 1061 | switch (ty.zigTypeTag(zcu)) { | 1059 | switch (ty.zigTypeTag(zcu)) { |
| 1062 | .void => return .none, | 1060 | .void => return .none, |
| 1061 | .bool => return .{ .immediate = @intFromBool(val.toBool()) }, | ||
| 1063 | .pointer => switch (ty.ptrSize(zcu)) { | 1062 | .pointer => switch (ty.ptrSize(zcu)) { |
| 1064 | .slice => {}, | 1063 | .slice => {}, |
| 1065 | else => switch (val.toIntern()) { | 1064 | .one, .many, .c => { |
| 1066 | .null_value => { | 1065 | const elem_ty = ty.childType(zcu); |
| 1067 | return .{ .immediate = 0 }; | 1066 | const ptr = ip.indexToKey(val.toIntern()).ptr; |
| 1068 | }, | 1067 | if (ptr.base_addr == .int) return .{ .immediate = ptr.byte_offset }; |
| 1069 | else => switch (ip.indexToKey(val.toIntern())) { | 1068 | switch (ptr.base_addr) { |
| 1070 | .int => { | 1069 | .int => unreachable, // handled above |
| 1071 | return .{ .immediate = val.toUnsignedInt(zcu) }; | 1070 | |
| 1071 | .nav => |nav| if (elem_ty.isFnOrHasRuntimeBits(zcu)) { | ||
| 1072 | return .{ .lea_nav = nav }; | ||
| 1073 | } else { | ||
| 1074 | // Create the 0xaa bit pattern... | ||
| 1075 | const undef_ptr_bits: u64 = @intCast((@as(u66, 1) << @intCast(target.ptrBitWidth() + 1)) / 3); | ||
| 1076 | // ...but align the pointer | ||
| 1077 | const alignment = pt.navAlignment(nav); | ||
| 1078 | return .{ .immediate = alignment.forward(undef_ptr_bits) }; | ||
| 1072 | }, | 1079 | }, |
| 1073 | .ptr => |ptr| if (ptr.byte_offset == 0) switch (ptr.base_addr) { | ||
| 1074 | .nav => |nav| { | ||
| 1075 | if (!ty.isFnOrHasRuntimeBitsIgnoreComptime(zcu)) { | ||
| 1076 | const imm: u64 = switch (@divExact(target.ptrBitWidth(), 8)) { | ||
| 1077 | 1 => 0xaa, | ||
| 1078 | 2 => 0xaaaa, | ||
| 1079 | 4 => 0xaaaaaaaa, | ||
| 1080 | 8 => 0xaaaaaaaaaaaaaaaa, | ||
| 1081 | else => unreachable, | ||
| 1082 | }; | ||
| 1083 | return .{ .immediate = imm }; | ||
| 1084 | } | ||
| 1085 | |||
| 1086 | if (ty.castPtrToFn(zcu)) |fn_ty| { | ||
| 1087 | if (zcu.typeToFunc(fn_ty).?.is_generic) { | ||
| 1088 | return .{ .immediate = fn_ty.abiAlignment(zcu).toByteUnits().? }; | ||
| 1089 | } | ||
| 1090 | } else if (ty.zigTypeTag(zcu) == .pointer) { | ||
| 1091 | const elem_ty = ty.childType(zcu); | ||
| 1092 | if (!elem_ty.hasRuntimeBits(zcu)) { | ||
| 1093 | return .{ .immediate = elem_ty.abiAlignment(zcu).toByteUnits().? }; | ||
| 1094 | } | ||
| 1095 | } | ||
| 1096 | 1080 | ||
| 1097 | return .{ .lea_nav = nav }; | 1081 | .uav => |uav| if (elem_ty.isFnOrHasRuntimeBits(zcu)) { |
| 1098 | }, | 1082 | return .{ .lea_uav = uav }; |
| 1099 | .uav => |uav| if (Value.fromInterned(uav.val).typeOf(zcu).hasRuntimeBits(zcu)) | 1083 | } else { |
| 1100 | return .{ .lea_uav = uav } | 1084 | // Create the 0xaa bit pattern... |
| 1101 | else | 1085 | const undef_ptr_bits: u64 = @intCast((@as(u66, 1) << @intCast(target.ptrBitWidth() + 1)) / 3); |
| 1102 | return .{ .immediate = Type.fromInterned(uav.orig_ty).ptrAlignment(zcu) | 1086 | // ...but align the pointer |
| 1103 | .forward(@intCast((@as(u66, 1) << @intCast(target.ptrBitWidth() | 1)) / 3)) }, | 1087 | const alignment = Type.fromInterned(uav.orig_ty).ptrAlignment(zcu); |
| 1104 | else => {}, | 1088 | return .{ .immediate = alignment.forward(undef_ptr_bits) }; |
| 1105 | }, | 1089 | }, |
| 1090 | |||
| 1106 | else => {}, | 1091 | else => {}, |
| 1107 | }, | 1092 | } |
| 1108 | }, | 1093 | }, |
| 1109 | }, | 1094 | }, |
| 1110 | .int => { | 1095 | .int => { |
| ... | @@ -1117,9 +1102,6 @@ pub fn lowerValue(pt: Zcu.PerThread, val: Value, target: *const std.Target) Allo | ... | @@ -1117,9 +1102,6 @@ pub fn lowerValue(pt: Zcu.PerThread, val: Value, target: *const std.Target) Allo |
| 1117 | return .{ .immediate = unsigned }; | 1102 | return .{ .immediate = unsigned }; |
| 1118 | } | 1103 | } |
| 1119 | }, | 1104 | }, |
| 1120 | .bool => { | ||
| 1121 | return .{ .immediate = @intFromBool(val.toBool()) }; | ||
| 1122 | }, | ||
| 1123 | .optional => { | 1105 | .optional => { |
| 1124 | if (ty.isPtrLikeOptional(zcu)) { | 1106 | if (ty.isPtrLikeOptional(zcu)) { |
| 1125 | return lowerValue( | 1107 | return lowerValue( |
| ... | @@ -1147,7 +1129,7 @@ pub fn lowerValue(pt: Zcu.PerThread, val: Value, target: *const std.Target) Allo | ... | @@ -1147,7 +1129,7 @@ pub fn lowerValue(pt: Zcu.PerThread, val: Value, target: *const std.Target) Allo |
| 1147 | .error_union => { | 1129 | .error_union => { |
| 1148 | const err_type = ty.errorUnionSet(zcu); | 1130 | const err_type = ty.errorUnionSet(zcu); |
| 1149 | const payload_type = ty.errorUnionPayload(zcu); | 1131 | const payload_type = ty.errorUnionPayload(zcu); |
| 1150 | if (!payload_type.hasRuntimeBitsIgnoreComptime(zcu)) { | 1132 | if (!payload_type.hasRuntimeBits(zcu)) { |
| 1151 | // We use the error type directly as the type. | 1133 | // We use the error type directly as the type. |
| 1152 | const err_int_ty = try pt.errorIntType(); | 1134 | const err_int_ty = try pt.errorIntType(); |
| 1153 | switch (ip.indexToKey(val.toIntern()).error_union.val) { | 1135 | switch (ip.indexToKey(val.toIntern()).error_union.val) { |
| ... | @@ -1187,10 +1169,10 @@ pub fn lowerValue(pt: Zcu.PerThread, val: Value, target: *const std.Target) Allo | ... | @@ -1187,10 +1169,10 @@ pub fn lowerValue(pt: Zcu.PerThread, val: Value, target: *const std.Target) Allo |
| 1187 | } | 1169 | } |
| 1188 | 1170 | ||
| 1189 | pub fn errUnionPayloadOffset(payload_ty: Type, zcu: *Zcu) u64 { | 1171 | pub fn errUnionPayloadOffset(payload_ty: Type, zcu: *Zcu) u64 { |
| 1190 | if (!payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) return 0; | 1172 | if (!payload_ty.hasRuntimeBits(zcu)) return 0; |
| 1191 | const payload_align = payload_ty.abiAlignment(zcu); | 1173 | const payload_align = payload_ty.abiAlignment(zcu); |
| 1192 | const error_align = Type.anyerror.abiAlignment(zcu); | 1174 | const error_align = Type.anyerror.abiAlignment(zcu); |
| 1193 | if (payload_align.compare(.gte, error_align) or !payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) { | 1175 | if (payload_align.compare(.gte, error_align) or !payload_ty.hasRuntimeBits(zcu)) { |
| 1194 | return 0; | 1176 | return 0; |
| 1195 | } else { | 1177 | } else { |
| 1196 | return payload_align.forward(Type.anyerror.abiSize(zcu)); | 1178 | return payload_align.forward(Type.anyerror.abiSize(zcu)); |
| ... | @@ -1198,10 +1180,10 @@ pub fn errUnionPayloadOffset(payload_ty: Type, zcu: *Zcu) u64 { | ... | @@ -1198,10 +1180,10 @@ pub fn errUnionPayloadOffset(payload_ty: Type, zcu: *Zcu) u64 { |
| 1198 | } | 1180 | } |
| 1199 | 1181 | ||
| 1200 | pub fn errUnionErrorOffset(payload_ty: Type, zcu: *Zcu) u64 { | 1182 | pub fn errUnionErrorOffset(payload_ty: Type, zcu: *Zcu) u64 { |
| 1201 | if (!payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) return 0; | 1183 | if (!payload_ty.hasRuntimeBits(zcu)) return 0; |
| 1202 | const payload_align = payload_ty.abiAlignment(zcu); | 1184 | const payload_align = payload_ty.abiAlignment(zcu); |
| 1203 | const error_align = Type.anyerror.abiAlignment(zcu); | 1185 | const error_align = Type.anyerror.abiAlignment(zcu); |
| 1204 | if (payload_align.compare(.gte, error_align) and payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) { | 1186 | if (payload_align.compare(.gte, error_align) and payload_ty.hasRuntimeBits(zcu)) { |
| 1205 | return error_align.forward(payload_ty.abiSize(zcu)); | 1187 | return error_align.forward(payload_ty.abiSize(zcu)); |
| 1206 | } else { | 1188 | } else { |
| 1207 | return 0; | 1189 | return 0; |
src/codegen/x86_64/CodeGen.zig+32-30| ... | @@ -43261,7 +43261,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -43261,7 +43261,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 43261 | var ops = try cg.tempsFromOperands(inst, .{ bin_op.lhs, bin_op.rhs }); | 43261 | var ops = try cg.tempsFromOperands(inst, .{ bin_op.lhs, bin_op.rhs }); |
| 43262 | try ops[0].toSlicePtr(cg); | 43262 | try ops[0].toSlicePtr(cg); |
| 43263 | var res: [1]Temp = undefined; | 43263 | var res: [1]Temp = undefined; |
| 43264 | if (!hack_around_sema_opv_bugs or ty_pl.ty.toType().childType(zcu).hasRuntimeBitsIgnoreComptime(zcu)) cg.select(&res, &.{ty_pl.ty.toType()}, &ops, comptime &.{ .{ | 43264 | if (!hack_around_sema_opv_bugs or ty_pl.ty.toType().childType(zcu).hasRuntimeBits(zcu)) cg.select(&res, &.{ty_pl.ty.toType()}, &ops, comptime &.{ .{ |
| 43265 | .patterns = &.{ | 43265 | .patterns = &.{ |
| 43266 | .{ .src = .{ .to_gpr, .simm32, .none } }, | 43266 | .{ .src = .{ .to_gpr, .simm32, .none } }, |
| 43267 | }, | 43267 | }, |
| ... | @@ -43375,7 +43375,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -43375,7 +43375,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 43375 | var ops = try cg.tempsFromOperands(inst, .{ bin_op.lhs, bin_op.rhs }); | 43375 | var ops = try cg.tempsFromOperands(inst, .{ bin_op.lhs, bin_op.rhs }); |
| 43376 | try ops[0].toSlicePtr(cg); | 43376 | try ops[0].toSlicePtr(cg); |
| 43377 | var res: [1]Temp = undefined; | 43377 | var res: [1]Temp = undefined; |
| 43378 | if (!hack_around_sema_opv_bugs or ty_pl.ty.toType().childType(zcu).hasRuntimeBitsIgnoreComptime(zcu)) cg.select(&res, &.{ty_pl.ty.toType()}, &ops, comptime &.{ .{ | 43378 | if (!hack_around_sema_opv_bugs or ty_pl.ty.toType().childType(zcu).hasRuntimeBits(zcu)) cg.select(&res, &.{ty_pl.ty.toType()}, &ops, comptime &.{ .{ |
| 43379 | .patterns = &.{ | 43379 | .patterns = &.{ |
| 43380 | .{ .src = .{ .to_gpr, .simm32, .none } }, | 43380 | .{ .src = .{ .to_gpr, .simm32, .none } }, |
| 43381 | }, | 43381 | }, |
| ... | @@ -103699,7 +103699,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -103699,7 +103699,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 103699 | .optional_payload => { | 103699 | .optional_payload => { |
| 103700 | const ty_op = air_datas[@intFromEnum(inst)].ty_op; | 103700 | const ty_op = air_datas[@intFromEnum(inst)].ty_op; |
| 103701 | var ops = try cg.tempsFromOperands(inst, .{ty_op.operand}); | 103701 | var ops = try cg.tempsFromOperands(inst, .{ty_op.operand}); |
| 103702 | const pl = if (!hack_around_sema_opv_bugs or ty_op.ty.toType().hasRuntimeBitsIgnoreComptime(zcu)) | 103702 | const pl = if (!hack_around_sema_opv_bugs or ty_op.ty.toType().hasRuntimeBits(zcu)) |
| 103703 | try ops[0].read(ty_op.ty.toType(), .{}, cg) | 103703 | try ops[0].read(ty_op.ty.toType(), .{}, cg) |
| 103704 | else | 103704 | else |
| 103705 | try cg.tempInit(ty_op.ty.toType(), .none); | 103705 | try cg.tempInit(ty_op.ty.toType(), .none); |
| ... | @@ -103745,7 +103745,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -103745,7 +103745,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 103745 | const eu_pl_ty = ty_op.ty.toType(); | 103745 | const eu_pl_ty = ty_op.ty.toType(); |
| 103746 | const eu_pl_off: i32 = @intCast(codegen.errUnionPayloadOffset(eu_pl_ty, zcu)); | 103746 | const eu_pl_off: i32 = @intCast(codegen.errUnionPayloadOffset(eu_pl_ty, zcu)); |
| 103747 | var ops = try cg.tempsFromOperands(inst, .{ty_op.operand}); | 103747 | var ops = try cg.tempsFromOperands(inst, .{ty_op.operand}); |
| 103748 | const pl = if (!hack_around_sema_opv_bugs or eu_pl_ty.hasRuntimeBitsIgnoreComptime(zcu)) | 103748 | const pl = if (!hack_around_sema_opv_bugs or eu_pl_ty.hasRuntimeBits(zcu)) |
| 103749 | try ops[0].read(eu_pl_ty, .{ .disp = eu_pl_off }, cg) | 103749 | try ops[0].read(eu_pl_ty, .{ .disp = eu_pl_off }, cg) |
| 103750 | else | 103750 | else |
| 103751 | try cg.tempInit(eu_pl_ty, .none); | 103751 | try cg.tempInit(eu_pl_ty, .none); |
| ... | @@ -103864,7 +103864,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -103864,7 +103864,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 103864 | .@"packed" => unreachable, | 103864 | .@"packed" => unreachable, |
| 103865 | }; | 103865 | }; |
| 103866 | var ops = try cg.tempsFromOperands(inst, .{struct_field.struct_operand}); | 103866 | var ops = try cg.tempsFromOperands(inst, .{struct_field.struct_operand}); |
| 103867 | var res = if (!hack_around_sema_opv_bugs or field_ty.hasRuntimeBitsIgnoreComptime(zcu)) | 103867 | var res = if (!hack_around_sema_opv_bugs or field_ty.hasRuntimeBits(zcu)) |
| 103868 | try ops[0].read(field_ty, .{ .disp = field_off }, cg) | 103868 | try ops[0].read(field_ty, .{ .disp = field_off }, cg) |
| 103869 | else | 103869 | else |
| 103870 | try cg.tempInit(field_ty, .none); | 103870 | try cg.tempInit(field_ty, .none); |
| ... | @@ -104125,7 +104125,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -104125,7 +104125,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 104125 | var ops = try cg.tempsFromOperands(inst, .{ bin_op.lhs, bin_op.rhs }); | 104125 | var ops = try cg.tempsFromOperands(inst, .{ bin_op.lhs, bin_op.rhs }); |
| 104126 | try ops[0].toSlicePtr(cg); | 104126 | try ops[0].toSlicePtr(cg); |
| 104127 | var res: [1]Temp = undefined; | 104127 | var res: [1]Temp = undefined; |
| 104128 | if (!hack_around_sema_opv_bugs or res_ty.hasRuntimeBitsIgnoreComptime(zcu)) cg.select(&res, &.{res_ty}, &ops, comptime &.{ .{ | 104128 | if (!hack_around_sema_opv_bugs or res_ty.hasRuntimeBits(zcu)) cg.select(&res, &.{res_ty}, &ops, comptime &.{ .{ |
| 104129 | .dst_constraints = .{ .{ .int = .byte }, .any }, | 104129 | .dst_constraints = .{ .{ .int = .byte }, .any }, |
| 104130 | .patterns = &.{ | 104130 | .patterns = &.{ |
| 104131 | .{ .src = .{ .to_gpr, .simm32, .none } }, | 104131 | .{ .src = .{ .to_gpr, .simm32, .none } }, |
| ... | @@ -171422,10 +171422,10 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -171422,10 +171422,10 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 171422 | .auto, .@"extern" => { | 171422 | .auto, .@"extern" => { |
| 171423 | for (elems, 0..) |elem_ref, field_index| { | 171423 | for (elems, 0..) |elem_ref, field_index| { |
| 171424 | const elem_dies = bt.feed(); | 171424 | const elem_dies = bt.feed(); |
| 171425 | if (loaded_struct.fieldIsComptime(ip, field_index)) continue; | 171425 | if (loaded_struct.field_is_comptime_bits.get(ip, field_index)) continue; |
| 171426 | if (!hack_around_sema_opv_bugs or Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]).hasRuntimeBitsIgnoreComptime(zcu)) { | 171426 | if (!hack_around_sema_opv_bugs or Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]).hasRuntimeBits(zcu)) { |
| 171427 | var elem = try cg.tempFromOperand(elem_ref, elem_dies); | 171427 | var elem = try cg.tempFromOperand(elem_ref, elem_dies); |
| 171428 | try res.write(&elem, .{ .disp = @intCast(loaded_struct.offsets.get(ip)[field_index]) }, cg); | 171428 | try res.write(&elem, .{ .disp = @intCast(loaded_struct.field_offsets.get(ip)[field_index]) }, cg); |
| 171429 | try elem.die(cg); | 171429 | try elem.die(cg); |
| 171430 | try cg.resetTemps(reset_index); | 171430 | try cg.resetTemps(reset_index); |
| 171431 | } | 171431 | } |
| ... | @@ -171441,7 +171441,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -171441,7 +171441,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 171441 | const elem_dies = bt.feed(); | 171441 | const elem_dies = bt.feed(); |
| 171442 | if (tuple_type.values.get(ip)[field_index] != .none) continue; | 171442 | if (tuple_type.values.get(ip)[field_index] != .none) continue; |
| 171443 | const field_type = Type.fromInterned(tuple_type.types.get(ip)[field_index]); | 171443 | const field_type = Type.fromInterned(tuple_type.types.get(ip)[field_index]); |
| 171444 | if (!hack_around_sema_opv_bugs or field_type.hasRuntimeBitsIgnoreComptime(zcu)) { | 171444 | if (!hack_around_sema_opv_bugs or field_type.hasRuntimeBits(zcu)) { |
| 171445 | elem_disp = @intCast(field_type.abiAlignment(zcu).forward(elem_disp)); | 171445 | elem_disp = @intCast(field_type.abiAlignment(zcu).forward(elem_disp)); |
| 171446 | var elem = try cg.tempFromOperand(elem_ref, elem_dies); | 171446 | var elem = try cg.tempFromOperand(elem_ref, elem_dies); |
| 171447 | try res.write(&elem, .{ .disp = elem_disp }, cg); | 171447 | try res.write(&elem, .{ .disp = elem_disp }, cg); |
| ... | @@ -173756,7 +173756,7 @@ fn genLazy(cg: *CodeGen, lazy_sym: link.File.LazySymbol) InnerError!void { | ... | @@ -173756,7 +173756,7 @@ fn genLazy(cg: *CodeGen, lazy_sym: link.File.LazySymbol) InnerError!void { |
| 173756 | 173756 | ||
| 173757 | var data_off: i32 = 0; | 173757 | var data_off: i32 = 0; |
| 173758 | const reset_index = cg.next_temp_index; | 173758 | const reset_index = cg.next_temp_index; |
| 173759 | const tag_names = ip.loadEnumType(lazy_sym.ty).names; | 173759 | const tag_names = ip.loadEnumType(lazy_sym.ty).field_names; |
| 173760 | for (0..tag_names.len) |tag_index| { | 173760 | for (0..tag_names.len) |tag_index| { |
| 173761 | var enum_temp = try cg.tempInit(enum_ty, if (enum_ty.abiSize(zcu) <= @as(u4, switch (cg.target.cpu.arch) { | 173761 | var enum_temp = try cg.tempInit(enum_ty, if (enum_ty.abiSize(zcu) <= @as(u4, switch (cg.target.cpu.arch) { |
| 173762 | else => unreachable, | 173762 | else => unreachable, |
| ... | @@ -174334,7 +174334,7 @@ fn genUnwrapErrUnionPayloadMir( | ... | @@ -174334,7 +174334,7 @@ fn genUnwrapErrUnionPayloadMir( |
| 174334 | const payload_ty = err_union_ty.errorUnionPayload(zcu); | 174334 | const payload_ty = err_union_ty.errorUnionPayload(zcu); |
| 174335 | 174335 | ||
| 174336 | const result: MCValue = result: { | 174336 | const result: MCValue = result: { |
| 174337 | if (!payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) break :result .none; | 174337 | if (!payload_ty.hasRuntimeBits(zcu)) break :result .none; |
| 174338 | 174338 | ||
| 174339 | const payload_off: u31 = @intCast(codegen.errUnionPayloadOffset(payload_ty, zcu)); | 174339 | const payload_off: u31 = @intCast(codegen.errUnionPayloadOffset(payload_ty, zcu)); |
| 174340 | switch (err_union) { | 174340 | switch (err_union) { |
| ... | @@ -174450,7 +174450,7 @@ fn load(self: *CodeGen, dst_mcv: MCValue, ptr_ty: Type, ptr_mcv: MCValue) InnerE | ... | @@ -174450,7 +174450,7 @@ fn load(self: *CodeGen, dst_mcv: MCValue, ptr_ty: Type, ptr_mcv: MCValue) InnerE |
| 174450 | const pt = self.pt; | 174450 | const pt = self.pt; |
| 174451 | const zcu = pt.zcu; | 174451 | const zcu = pt.zcu; |
| 174452 | const dst_ty = ptr_ty.childType(zcu); | 174452 | const dst_ty = ptr_ty.childType(zcu); |
| 174453 | if (!dst_ty.hasRuntimeBitsIgnoreComptime(zcu)) return; | 174453 | if (!dst_ty.hasRuntimeBits(zcu)) return; |
| 174454 | switch (ptr_mcv) { | 174454 | switch (ptr_mcv) { |
| 174455 | .none, | 174455 | .none, |
| 174456 | .unreach, | 174456 | .unreach, |
| ... | @@ -174503,7 +174503,7 @@ fn store( | ... | @@ -174503,7 +174503,7 @@ fn store( |
| 174503 | const pt = self.pt; | 174503 | const pt = self.pt; |
| 174504 | const zcu = pt.zcu; | 174504 | const zcu = pt.zcu; |
| 174505 | const src_ty = ptr_ty.childType(zcu); | 174505 | const src_ty = ptr_ty.childType(zcu); |
| 174506 | if (!src_ty.hasRuntimeBitsIgnoreComptime(zcu)) return; | 174506 | if (!src_ty.hasRuntimeBits(zcu)) return; |
| 174507 | switch (ptr_mcv) { | 174507 | switch (ptr_mcv) { |
| 174508 | .none, | 174508 | .none, |
| 174509 | .unreach, | 174509 | .unreach, |
| ... | @@ -176615,7 +176615,7 @@ fn lowerSwitchBr( | ... | @@ -176615,7 +176615,7 @@ fn lowerSwitchBr( |
| 176615 | break :condition_index condition_index; | 176615 | break :condition_index condition_index; |
| 176616 | }; | 176616 | }; |
| 176617 | try cg.spillEflagsIfOccupied(); | 176617 | try cg.spillEflagsIfOccupied(); |
| 176618 | if (min.?.orderAgainstZero(zcu).compare(.neq)) try cg.genBinOpMir( | 176618 | if (Value.compareHetero(min.?, .neq, .zero_comptime_int, zcu)) try cg.genBinOpMir( |
| 176619 | .{ ._, .sub }, | 176619 | .{ ._, .sub }, |
| 176620 | condition_ty, | 176620 | condition_ty, |
| 176621 | condition_index, | 176621 | condition_index, |
| ... | @@ -176957,7 +176957,7 @@ fn airSwitchDispatch(self: *CodeGen, inst: Air.Inst.Index) !void { | ... | @@ -176957,7 +176957,7 @@ fn airSwitchDispatch(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 176957 | const unsigned_condition_ty = try self.pt.intType(.unsigned, self.intInfo(condition_ty).?.bits); | 176957 | const unsigned_condition_ty = try self.pt.intType(.unsigned, self.intInfo(condition_ty).?.bits); |
| 176958 | const condition_mcv = block_tracking.short; | 176958 | const condition_mcv = block_tracking.short; |
| 176959 | try self.spillEflagsIfOccupied(); | 176959 | try self.spillEflagsIfOccupied(); |
| 176960 | if (table.min.orderAgainstZero(self.pt.zcu).compare(.neq)) try self.genBinOpMir( | 176960 | if (Value.compareHetero(table.min, .neq, .zero_comptime_int, self.pt.zcu)) try self.genBinOpMir( |
| 176961 | .{ ._, .sub }, | 176961 | .{ ._, .sub }, |
| 176962 | condition_ty, | 176962 | condition_ty, |
| 176963 | condition_mcv, | 176963 | condition_mcv, |
| ... | @@ -177054,8 +177054,7 @@ fn airBr(self: *CodeGen, inst: Air.Inst.Index) !void { | ... | @@ -177054,8 +177054,7 @@ fn airBr(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 177054 | const br = self.air.instructions.items(.data)[@intFromEnum(inst)].br; | 177054 | const br = self.air.instructions.items(.data)[@intFromEnum(inst)].br; |
| 177055 | 177055 | ||
| 177056 | const block_ty = self.typeOfIndex(br.block_inst); | 177056 | const block_ty = self.typeOfIndex(br.block_inst); |
| 177057 | const block_unused = | 177057 | const block_unused = !block_ty.hasRuntimeBits(zcu) or self.liveness.isUnused(br.block_inst); |
| 177058 | !block_ty.hasRuntimeBitsIgnoreComptime(zcu) or self.liveness.isUnused(br.block_inst); | ||
| 177059 | const block_tracking = self.inst_tracking.getPtr(br.block_inst).?; | 177058 | const block_tracking = self.inst_tracking.getPtr(br.block_inst).?; |
| 177060 | const block_data = self.blocks.getPtr(br.block_inst).?; | 177059 | const block_data = self.blocks.getPtr(br.block_inst).?; |
| 177061 | const first_br = block_data.relocs.items.len == 0; | 177060 | const first_br = block_data.relocs.items.len == 0; |
| ... | @@ -180986,7 +180985,7 @@ fn resolveInst(self: *CodeGen, ref: Air.Inst.Ref) InnerError!MCValue { | ... | @@ -180986,7 +180985,7 @@ fn resolveInst(self: *CodeGen, ref: Air.Inst.Ref) InnerError!MCValue { |
| 180986 | const ty = self.typeOf(ref); | 180985 | const ty = self.typeOf(ref); |
| 180987 | 180986 | ||
| 180988 | // If the type has no codegen bits, no need to store it. | 180987 | // If the type has no codegen bits, no need to store it. |
| 180989 | if (!ty.hasRuntimeBitsIgnoreComptime(zcu)) return .none; | 180988 | if (!ty.hasRuntimeBits(zcu)) return .none; |
| 180990 | 180989 | ||
| 180991 | const mcv: MCValue = if (ref.toIndex()) |inst| mcv: { | 180990 | const mcv: MCValue = if (ref.toIndex()) |inst| mcv: { |
| 180992 | break :mcv self.inst_tracking.getPtr(inst).?.short; | 180991 | break :mcv self.inst_tracking.getPtr(inst).?.short; |
| ... | @@ -181105,7 +181104,7 @@ fn resolveCallingConventionValues( | ... | @@ -181105,7 +181104,7 @@ fn resolveCallingConventionValues( |
| 181105 | // Return values | 181104 | // Return values |
| 181106 | if (ret_ty.isNoReturn(zcu)) { | 181105 | if (ret_ty.isNoReturn(zcu)) { |
| 181107 | result.return_value = .init(.unreach); | 181106 | result.return_value = .init(.unreach); |
| 181108 | } else if (!ret_ty.hasRuntimeBitsIgnoreComptime(zcu)) { | 181107 | } else if (!ret_ty.hasRuntimeBits(zcu)) { |
| 181109 | // TODO: is this even possible for C calling convention? | 181108 | // TODO: is this even possible for C calling convention? |
| 181110 | result.return_value = .init(.none); | 181109 | result.return_value = .init(.none); |
| 181111 | } else { | 181110 | } else { |
| ... | @@ -181182,7 +181181,7 @@ fn resolveCallingConventionValues( | ... | @@ -181182,7 +181181,7 @@ fn resolveCallingConventionValues( |
| 181182 | 181181 | ||
| 181183 | // Input params | 181182 | // Input params |
| 181184 | params: for (param_types, result.args) |ty, *arg| { | 181183 | params: for (param_types, result.args) |ty, *arg| { |
| 181185 | assert(ty.hasRuntimeBitsIgnoreComptime(zcu)); | 181184 | assert(ty.hasRuntimeBits(zcu)); |
| 181186 | result.air_arg_count += 1; | 181185 | result.air_arg_count += 1; |
| 181187 | switch (cc) { | 181186 | switch (cc) { |
| 181188 | .x86_64_sysv => {}, | 181187 | .x86_64_sysv => {}, |
| ... | @@ -181327,7 +181326,7 @@ fn resolveCallingConventionValues( | ... | @@ -181327,7 +181326,7 @@ fn resolveCallingConventionValues( |
| 181327 | // Return values | 181326 | // Return values |
| 181328 | result.return_value = if (ret_ty.isNoReturn(zcu)) | 181327 | result.return_value = if (ret_ty.isNoReturn(zcu)) |
| 181329 | .init(.unreach) | 181328 | .init(.unreach) |
| 181330 | else if (!ret_ty.hasRuntimeBitsIgnoreComptime(zcu)) | 181329 | else if (!ret_ty.hasRuntimeBits(zcu)) |
| 181331 | .init(.none) | 181330 | .init(.none) |
| 181332 | else return_value: { | 181331 | else return_value: { |
| 181333 | const ret_gpr = abi.getCAbiIntReturnRegs(cc); | 181332 | const ret_gpr = abi.getCAbiIntReturnRegs(cc); |
| ... | @@ -181357,7 +181356,7 @@ fn resolveCallingConventionValues( | ... | @@ -181357,7 +181356,7 @@ fn resolveCallingConventionValues( |
| 181357 | 181356 | ||
| 181358 | // Input params | 181357 | // Input params |
| 181359 | for (param_types, result.args) |param_ty, *arg| { | 181358 | for (param_types, result.args) |param_ty, *arg| { |
| 181360 | if (!param_ty.hasRuntimeBitsIgnoreComptime(zcu)) { | 181359 | if (!param_ty.hasRuntimeBits(zcu)) { |
| 181361 | arg.* = .none; | 181360 | arg.* = .none; |
| 181362 | continue; | 181361 | continue; |
| 181363 | } | 181362 | } |
| ... | @@ -181721,7 +181720,7 @@ fn intInfo(cg: *CodeGen, ty: Type) ?std.builtin.Type.Int { | ... | @@ -181721,7 +181720,7 @@ fn intInfo(cg: *CodeGen, ty: Type) ?std.builtin.Type.Int { |
| 181721 | .one, .many, .c => .{ .signedness = .unsigned, .bits = cg.target.ptrBitWidth() }, | 181720 | .one, .many, .c => .{ .signedness = .unsigned, .bits = cg.target.ptrBitWidth() }, |
| 181722 | .slice => null, | 181721 | .slice => null, |
| 181723 | }, | 181722 | }, |
| 181724 | .opt_type => |opt_child| return if (!Type.fromInterned(opt_child).hasRuntimeBitsIgnoreComptime(zcu)) | 181723 | .opt_type => |opt_child| return if (!Type.fromInterned(opt_child).hasRuntimeBits(zcu)) |
| 181725 | .{ .signedness = .unsigned, .bits = 1 } | 181724 | .{ .signedness = .unsigned, .bits = 1 } |
| 181726 | else switch (ip.indexToKey(opt_child)) { | 181725 | else switch (ip.indexToKey(opt_child)) { |
| 181727 | .ptr_type => |ptr_type| switch (ptr_type.flags.size) { | 181726 | .ptr_type => |ptr_type| switch (ptr_type.flags.size) { |
| ... | @@ -181734,7 +181733,7 @@ fn intInfo(cg: *CodeGen, ty: Type) ?std.builtin.Type.Int { | ... | @@ -181734,7 +181733,7 @@ fn intInfo(cg: *CodeGen, ty: Type) ?std.builtin.Type.Int { |
| 181734 | else => null, | 181733 | else => null, |
| 181735 | }, | 181734 | }, |
| 181736 | .error_union_type => |error_union_type| return if (!Type.fromInterned(error_union_type.payload_type) | 181735 | .error_union_type => |error_union_type| return if (!Type.fromInterned(error_union_type.payload_type) |
| 181737 | .hasRuntimeBitsIgnoreComptime(zcu)) .{ .signedness = .unsigned, .bits = zcu.errorSetBits() } else null, | 181736 | .hasRuntimeBits(zcu)) .{ .signedness = .unsigned, .bits = zcu.errorSetBits() } else null, |
| 181738 | .simple_type => |simple_type| return switch (simple_type) { | 181737 | .simple_type => |simple_type| return switch (simple_type) { |
| 181739 | .bool => .{ .signedness = .unsigned, .bits = 1 }, | 181738 | .bool => .{ .signedness = .unsigned, .bits = 1 }, |
| 181740 | .anyerror => .{ .signedness = .unsigned, .bits = zcu.errorSetBits() }, | 181739 | .anyerror => .{ .signedness = .unsigned, .bits = zcu.errorSetBits() }, |
| ... | @@ -181767,14 +181766,17 @@ fn intInfo(cg: *CodeGen, ty: Type) ?std.builtin.Type.Int { | ... | @@ -181767,14 +181766,17 @@ fn intInfo(cg: *CodeGen, ty: Type) ?std.builtin.Type.Int { |
| 181767 | const loaded_struct = ip.loadStructType(ty_index); | 181766 | const loaded_struct = ip.loadStructType(ty_index); |
| 181768 | switch (loaded_struct.layout) { | 181767 | switch (loaded_struct.layout) { |
| 181769 | .auto, .@"extern" => return null, | 181768 | .auto, .@"extern" => return null, |
| 181770 | .@"packed" => ty_index = loaded_struct.backingIntTypeUnordered(ip), | 181769 | .@"packed" => ty_index = loaded_struct.packed_backing_int_type, |
| 181771 | } | 181770 | } |
| 181772 | }, | 181771 | }, |
| 181773 | .union_type => return switch (ip.loadUnionType(ty_index).flagsUnordered(ip).layout) { | 181772 | .union_type => { |
| 181774 | .auto, .@"extern" => null, | 181773 | const loaded_union = ip.loadUnionType(ty_index); |
| 181775 | .@"packed" => .{ .signedness = .unsigned, .bits = @intCast(ty.bitSize(zcu)) }, | 181774 | switch (loaded_union.layout) { |
| 181775 | .auto, .@"extern" => return null, | ||
| 181776 | .@"packed" => ty_index = loaded_union.packed_backing_int_type, | ||
| 181777 | } | ||
| 181776 | }, | 181778 | }, |
| 181777 | .enum_type => ty_index = ip.loadEnumType(ty_index).tag_ty, | 181779 | .enum_type => ty_index = ip.loadEnumType(ty_index).int_tag_type, |
| 181778 | .error_set_type, .inferred_error_set_type => return .{ .signedness = .unsigned, .bits = zcu.errorSetBits() }, | 181780 | .error_set_type, .inferred_error_set_type => return .{ .signedness = .unsigned, .bits = zcu.errorSetBits() }, |
| 181779 | else => return null, | 181781 | else => return null, |
| 181780 | }; | 181782 | }; |
src/codegen/x86_64/abi.zig+6-6| ... | @@ -339,7 +339,7 @@ fn classifySystemVStruct( | ... | @@ -339,7 +339,7 @@ fn classifySystemVStruct( |
| 339 | var field_it = loaded_struct.iterateRuntimeOrder(ip); | 339 | var field_it = loaded_struct.iterateRuntimeOrder(ip); |
| 340 | while (field_it.next()) |field_index| { | 340 | while (field_it.next()) |field_index| { |
| 341 | const field_ty = Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]); | 341 | const field_ty = Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]); |
| 342 | const field_align = loaded_struct.fieldAlign(ip, field_index); | 342 | const field_align = loaded_struct.field_aligns.getOrNone(ip, field_index); |
| 343 | byte_offset = std.mem.alignForward( | 343 | byte_offset = std.mem.alignForward( |
| 344 | u64, | 344 | u64, |
| 345 | byte_offset, | 345 | byte_offset, |
| ... | @@ -355,7 +355,7 @@ fn classifySystemVStruct( | ... | @@ -355,7 +355,7 @@ fn classifySystemVStruct( |
| 355 | .@"packed" => {}, | 355 | .@"packed" => {}, |
| 356 | } | 356 | } |
| 357 | } else if (zcu.typeToUnion(field_ty)) |field_loaded_union| { | 357 | } else if (zcu.typeToUnion(field_ty)) |field_loaded_union| { |
| 358 | switch (field_loaded_union.flagsUnordered(ip).layout) { | 358 | switch (field_loaded_union.layout) { |
| 359 | .auto => unreachable, | 359 | .auto => unreachable, |
| 360 | .@"extern" => { | 360 | .@"extern" => { |
| 361 | byte_offset = classifySystemVUnion(result, byte_offset, field_loaded_union, zcu, target); | 361 | byte_offset = classifySystemVUnion(result, byte_offset, field_loaded_union, zcu, target); |
| ... | @@ -369,11 +369,11 @@ fn classifySystemVStruct( | ... | @@ -369,11 +369,11 @@ fn classifySystemVStruct( |
| 369 | result_class.* = result_class.combineSystemV(field_class); | 369 | result_class.* = result_class.combineSystemV(field_class); |
| 370 | byte_offset += field_ty.abiSize(zcu); | 370 | byte_offset += field_ty.abiSize(zcu); |
| 371 | } | 371 | } |
| 372 | const final_byte_offset = starting_byte_offset + loaded_struct.sizeUnordered(ip); | 372 | const final_byte_offset = starting_byte_offset + loaded_struct.size; |
| 373 | std.debug.assert(final_byte_offset == std.mem.alignForward( | 373 | std.debug.assert(final_byte_offset == std.mem.alignForward( |
| 374 | u64, | 374 | u64, |
| 375 | byte_offset, | 375 | byte_offset, |
| 376 | loaded_struct.flagsUnordered(ip).alignment.toByteUnits().?, | 376 | loaded_struct.alignment.toByteUnits().?, |
| 377 | )); | 377 | )); |
| 378 | return final_byte_offset; | 378 | return final_byte_offset; |
| 379 | } | 379 | } |
| ... | @@ -398,7 +398,7 @@ fn classifySystemVUnion( | ... | @@ -398,7 +398,7 @@ fn classifySystemVUnion( |
| 398 | .@"packed" => {}, | 398 | .@"packed" => {}, |
| 399 | } | 399 | } |
| 400 | } else if (zcu.typeToUnion(field_ty)) |field_loaded_union| { | 400 | } else if (zcu.typeToUnion(field_ty)) |field_loaded_union| { |
| 401 | switch (field_loaded_union.flagsUnordered(ip).layout) { | 401 | switch (field_loaded_union.layout) { |
| 402 | .auto => unreachable, | 402 | .auto => unreachable, |
| 403 | .@"extern" => { | 403 | .@"extern" => { |
| 404 | _ = classifySystemVUnion(result, starting_byte_offset, field_loaded_union, zcu, target); | 404 | _ = classifySystemVUnion(result, starting_byte_offset, field_loaded_union, zcu, target); |
| ... | @@ -411,7 +411,7 @@ fn classifySystemVUnion( | ... | @@ -411,7 +411,7 @@ fn classifySystemVUnion( |
| 411 | for (result[@intCast(starting_byte_offset / 8)..][0..field_classes.len], field_classes) |*result_class, field_class| | 411 | for (result[@intCast(starting_byte_offset / 8)..][0..field_classes.len], field_classes) |*result_class, field_class| |
| 412 | result_class.* = result_class.combineSystemV(field_class); | 412 | result_class.* = result_class.combineSystemV(field_class); |
| 413 | } | 413 | } |
| 414 | return starting_byte_offset + loaded_union.sizeUnordered(ip); | 414 | return starting_byte_offset + loaded_union.size; |
| 415 | } | 415 | } |
| 416 | 416 | ||
| 417 | pub const zigcc = struct { | 417 | pub const zigcc = struct { |
src/link/Dwarf.zig+54-54| ... | @@ -2243,8 +2243,8 @@ pub const WipNav = struct { | ... | @@ -2243,8 +2243,8 @@ pub const WipNav = struct { |
| 2243 | const zcu = wip_nav.pt.zcu; | 2243 | const zcu = wip_nav.pt.zcu; |
| 2244 | const ip = &zcu.intern_pool; | 2244 | const ip = &zcu.intern_pool; |
| 2245 | var big_int_space: Value.BigIntSpace = undefined; | 2245 | var big_int_space: Value.BigIntSpace = undefined; |
| 2246 | try wip_nav.bigIntConstValue(abbrev_code, .fromInterned(loaded_enum.tag_ty), if (loaded_enum.values.len > 0) | 2246 | try wip_nav.bigIntConstValue(abbrev_code, .fromInterned(loaded_enum.int_tag_type), if (loaded_enum.field_values.len > 0) |
| 2247 | Value.fromInterned(loaded_enum.values.get(ip)[field_index]).toBigInt(&big_int_space, zcu) | 2247 | Value.fromInterned(loaded_enum.field_values.get(ip)[field_index]).toBigInt(&big_int_space, zcu) |
| 2248 | else | 2248 | else |
| 2249 | std.math.big.int.Mutable.init(&big_int_space.limbs, field_index).toConst()); | 2249 | std.math.big.int.Mutable.init(&big_int_space.limbs, field_index).toConst()); |
| 2250 | } | 2250 | } |
| ... | @@ -3164,8 +3164,8 @@ fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPoo | ... | @@ -3164,8 +3164,8 @@ fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPoo |
| 3164 | try diw.writeUleb128(nav_val.toType().abiSize(zcu)); | 3164 | try diw.writeUleb128(nav_val.toType().abiSize(zcu)); |
| 3165 | try diw.writeUleb128(nav_val.toType().abiAlignment(zcu).toByteUnits().?); | 3165 | try diw.writeUleb128(nav_val.toType().abiAlignment(zcu).toByteUnits().?); |
| 3166 | for (0..loaded_struct.field_types.len) |field_index| { | 3166 | for (0..loaded_struct.field_types.len) |field_index| { |
| 3167 | const is_comptime = loaded_struct.fieldIsComptime(ip, field_index); | 3167 | const is_comptime = loaded_struct.field_is_comptime_bits.get(ip, field_index); |
| 3168 | const field_init = loaded_struct.fieldInit(ip, field_index); | 3168 | const field_init = loaded_struct.field_defaults.getOrNone(ip, field_index); |
| 3169 | assert(!(is_comptime and field_init == .none)); | 3169 | assert(!(is_comptime and field_init == .none)); |
| 3170 | const field_type: Type = .fromInterned(loaded_struct.field_types.get(ip)[field_index]); | 3170 | const field_type: Type = .fromInterned(loaded_struct.field_types.get(ip)[field_index]); |
| 3171 | const has_runtime_bits, const has_comptime_state = switch (field_init) { | 3171 | const has_runtime_bits, const has_comptime_state = switch (field_init) { |
| ... | @@ -3191,11 +3191,11 @@ fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPoo | ... | @@ -3191,11 +3191,11 @@ fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPoo |
| 3191 | .struct_field | 3191 | .struct_field |
| 3192 | else | 3192 | else |
| 3193 | .struct_field); | 3193 | .struct_field); |
| 3194 | try wip_nav.strp(loaded_struct.fieldName(ip, field_index).toSlice(ip)); | 3194 | try wip_nav.strp(loaded_struct.field_names.get(ip)[field_index].toSlice(ip)); |
| 3195 | try wip_nav.refType(field_type); | 3195 | try wip_nav.refType(field_type); |
| 3196 | if (!is_comptime) { | 3196 | if (!is_comptime) { |
| 3197 | try diw.writeUleb128(loaded_struct.offsets.get(ip)[field_index]); | 3197 | try diw.writeUleb128(loaded_struct.field_offsets.get(ip)[field_index]); |
| 3198 | try diw.writeUleb128(loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse | 3198 | try diw.writeUleb128(loaded_struct.field_aligns.getOrNone(ip, field_index).toByteUnits() orelse |
| 3199 | field_type.abiAlignment(zcu).toByteUnits().?); | 3199 | field_type.abiAlignment(zcu).toByteUnits().?); |
| 3200 | } | 3200 | } |
| 3201 | if (has_comptime_state) | 3201 | if (has_comptime_state) |
| ... | @@ -3212,11 +3212,11 @@ fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPoo | ... | @@ -3212,11 +3212,11 @@ fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPoo |
| 3212 | .generic_decl = .generic_decl_const, | 3212 | .generic_decl = .generic_decl_const, |
| 3213 | .decl_instance = .decl_instance_packed_struct, | 3213 | .decl_instance = .decl_instance_packed_struct, |
| 3214 | }, &nav, inst_info.file, &decl); | 3214 | }, &nav, inst_info.file, &decl); |
| 3215 | try wip_nav.refType(.fromInterned(loaded_struct.backingIntTypeUnordered(ip))); | 3215 | try wip_nav.refType(.fromInterned(loaded_struct.packed_backing_int_type)); |
| 3216 | var field_bit_offset: u16 = 0; | 3216 | var field_bit_offset: u16 = 0; |
| 3217 | for (0..loaded_struct.field_types.len) |field_index| { | 3217 | for (0..loaded_struct.field_types.len) |field_index| { |
| 3218 | try wip_nav.abbrevCode(.packed_struct_field); | 3218 | try wip_nav.abbrevCode(.packed_struct_field); |
| 3219 | try wip_nav.strp(loaded_struct.fieldName(ip, field_index).toSlice(ip)); | 3219 | try wip_nav.strp(loaded_struct.field_names.get(ip)[field_index].toSlice(ip)); |
| 3220 | const field_type: Type = .fromInterned(loaded_struct.field_types.get(ip)[field_index]); | 3220 | const field_type: Type = .fromInterned(loaded_struct.field_types.get(ip)[field_index]); |
| 3221 | try wip_nav.refType(field_type); | 3221 | try wip_nav.refType(field_type); |
| 3222 | try diw.writeUleb128(field_bit_offset); | 3222 | try diw.writeUleb128(field_bit_offset); |
| ... | @@ -3246,7 +3246,7 @@ fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPoo | ... | @@ -3246,7 +3246,7 @@ fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPoo |
| 3246 | } | 3246 | } |
| 3247 | wip_nav.entry = nav_gop.value_ptr.*; | 3247 | wip_nav.entry = nav_gop.value_ptr.*; |
| 3248 | const diw = &wip_nav.debug_info.writer; | 3248 | const diw = &wip_nav.debug_info.writer; |
| 3249 | try wip_nav.declCommon(if (loaded_enum.names.len > 0) .{ | 3249 | try wip_nav.declCommon(if (loaded_enum.field_names.len > 0) .{ |
| 3250 | .decl = .decl_enum, | 3250 | .decl = .decl_enum, |
| 3251 | .generic_decl = .generic_decl_const, | 3251 | .generic_decl = .generic_decl_const, |
| 3252 | .decl_instance = .decl_instance_enum, | 3252 | .decl_instance = .decl_instance_enum, |
| ... | @@ -3255,16 +3255,16 @@ fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPoo | ... | @@ -3255,16 +3255,16 @@ fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPoo |
| 3255 | .generic_decl = .generic_decl_const, | 3255 | .generic_decl = .generic_decl_const, |
| 3256 | .decl_instance = .decl_instance_empty_enum, | 3256 | .decl_instance = .decl_instance_empty_enum, |
| 3257 | }, &nav, inst_info.file, &decl); | 3257 | }, &nav, inst_info.file, &decl); |
| 3258 | try wip_nav.refType(.fromInterned(loaded_enum.tag_ty)); | 3258 | try wip_nav.refType(.fromInterned(loaded_enum.int_tag_type)); |
| 3259 | for (0..loaded_enum.names.len) |field_index| { | 3259 | for (0..loaded_enum.field_names.len) |field_index| { |
| 3260 | try wip_nav.enumConstValue(loaded_enum, .{ | 3260 | try wip_nav.enumConstValue(loaded_enum, .{ |
| 3261 | .sdata = .signed_enum_field, | 3261 | .sdata = .signed_enum_field, |
| 3262 | .udata = .unsigned_enum_field, | 3262 | .udata = .unsigned_enum_field, |
| 3263 | .block = .big_enum_field, | 3263 | .block = .big_enum_field, |
| 3264 | }, field_index); | 3264 | }, field_index); |
| 3265 | try wip_nav.strp(loaded_enum.names.get(ip)[field_index].toSlice(ip)); | 3265 | try wip_nav.strp(loaded_enum.field_names.get(ip)[field_index].toSlice(ip)); |
| 3266 | } | 3266 | } |
| 3267 | if (loaded_enum.names.len > 0) try diw.writeUleb128(@intFromEnum(AbbrevCode.null)); | 3267 | if (loaded_enum.field_names.len > 0) try diw.writeUleb128(@intFromEnum(AbbrevCode.null)); |
| 3268 | break :tag .done; | 3268 | break :tag .done; |
| 3269 | }, | 3269 | }, |
| 3270 | .union_type => tag: { | 3270 | .union_type => tag: { |
| ... | @@ -3293,8 +3293,8 @@ fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPoo | ... | @@ -3293,8 +3293,8 @@ fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPoo |
| 3293 | const union_layout = Type.getUnionLayout(loaded_union, zcu); | 3293 | const union_layout = Type.getUnionLayout(loaded_union, zcu); |
| 3294 | try diw.writeUleb128(union_layout.abi_size); | 3294 | try diw.writeUleb128(union_layout.abi_size); |
| 3295 | try diw.writeUleb128(union_layout.abi_align.toByteUnits().?); | 3295 | try diw.writeUleb128(union_layout.abi_align.toByteUnits().?); |
| 3296 | const loaded_tag = loaded_union.loadTagType(ip); | 3296 | const loaded_tag = ip.loadEnumType(loaded_union.enum_tag_type); |
| 3297 | if (loaded_union.hasTag(ip)) { | 3297 | if (loaded_union.runtime_tag != .none) { |
| 3298 | try wip_nav.abbrevCode(.tagged_union); | 3298 | try wip_nav.abbrevCode(.tagged_union); |
| 3299 | try wip_nav.infoSectionOffset( | 3299 | try wip_nav.infoSectionOffset( |
| 3300 | .debug_info, | 3300 | .debug_info, |
| ... | @@ -3305,7 +3305,7 @@ fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPoo | ... | @@ -3305,7 +3305,7 @@ fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPoo |
| 3305 | { | 3305 | { |
| 3306 | try wip_nav.abbrevCode(.generated_field); | 3306 | try wip_nav.abbrevCode(.generated_field); |
| 3307 | try wip_nav.strp("tag"); | 3307 | try wip_nav.strp("tag"); |
| 3308 | try wip_nav.refType(.fromInterned(loaded_union.enum_tag_ty)); | 3308 | try wip_nav.refType(.fromInterned(loaded_union.enum_tag_type)); |
| 3309 | try diw.writeUleb128(union_layout.tagOffset()); | 3309 | try diw.writeUleb128(union_layout.tagOffset()); |
| 3310 | 3310 | ||
| 3311 | for (0..loaded_union.field_types.len) |field_index| { | 3311 | for (0..loaded_union.field_types.len) |field_index| { |
| ... | @@ -3316,11 +3316,11 @@ fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPoo | ... | @@ -3316,11 +3316,11 @@ fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPoo |
| 3316 | }, field_index); | 3316 | }, field_index); |
| 3317 | { | 3317 | { |
| 3318 | try wip_nav.abbrevCode(.struct_field); | 3318 | try wip_nav.abbrevCode(.struct_field); |
| 3319 | try wip_nav.strp(loaded_tag.names.get(ip)[field_index].toSlice(ip)); | 3319 | try wip_nav.strp(loaded_tag.field_names.get(ip)[field_index].toSlice(ip)); |
| 3320 | const field_type: Type = .fromInterned(loaded_union.field_types.get(ip)[field_index]); | 3320 | const field_type: Type = .fromInterned(loaded_union.field_types.get(ip)[field_index]); |
| 3321 | try wip_nav.refType(field_type); | 3321 | try wip_nav.refType(field_type); |
| 3322 | try diw.writeUleb128(union_layout.payloadOffset()); | 3322 | try diw.writeUleb128(union_layout.payloadOffset()); |
| 3323 | try diw.writeUleb128(loaded_union.fieldAlign(ip, field_index).toByteUnits() orelse | 3323 | try diw.writeUleb128(loaded_union.field_aligns.getOrNone(ip, field_index).toByteUnits() orelse |
| 3324 | if (field_type.isNoReturn(zcu)) 1 else field_type.abiAlignment(zcu).toByteUnits().?); | 3324 | if (field_type.isNoReturn(zcu)) 1 else field_type.abiAlignment(zcu).toByteUnits().?); |
| 3325 | } | 3325 | } |
| 3326 | try diw.writeUleb128(@intFromEnum(AbbrevCode.null)); | 3326 | try diw.writeUleb128(@intFromEnum(AbbrevCode.null)); |
| ... | @@ -3329,10 +3329,10 @@ fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPoo | ... | @@ -3329,10 +3329,10 @@ fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPoo |
| 3329 | try diw.writeUleb128(@intFromEnum(AbbrevCode.null)); | 3329 | try diw.writeUleb128(@intFromEnum(AbbrevCode.null)); |
| 3330 | } else for (0..loaded_union.field_types.len) |field_index| { | 3330 | } else for (0..loaded_union.field_types.len) |field_index| { |
| 3331 | try wip_nav.abbrevCode(.untagged_union_field); | 3331 | try wip_nav.abbrevCode(.untagged_union_field); |
| 3332 | try wip_nav.strp(loaded_tag.names.get(ip)[field_index].toSlice(ip)); | 3332 | try wip_nav.strp(loaded_tag.field_names.get(ip)[field_index].toSlice(ip)); |
| 3333 | const field_type: Type = .fromInterned(loaded_union.field_types.get(ip)[field_index]); | 3333 | const field_type: Type = .fromInterned(loaded_union.field_types.get(ip)[field_index]); |
| 3334 | try wip_nav.refType(field_type); | 3334 | try wip_nav.refType(field_type); |
| 3335 | try diw.writeUleb128(loaded_union.fieldAlign(ip, field_index).toByteUnits() orelse | 3335 | try diw.writeUleb128(loaded_union.field_aligns.getOrNone(ip, field_index).toByteUnits() orelse |
| 3336 | if (field_type.isNoReturn(zcu)) 1 else field_type.abiAlignment(zcu).toByteUnits().?); | 3336 | if (field_type.isNoReturn(zcu)) 1 else field_type.abiAlignment(zcu).toByteUnits().?); |
| 3337 | } | 3337 | } |
| 3338 | try diw.writeUleb128(@intFromEnum(AbbrevCode.null)); | 3338 | try diw.writeUleb128(@intFromEnum(AbbrevCode.null)); |
| ... | @@ -3877,18 +3877,18 @@ fn updateLazyType( | ... | @@ -3877,18 +3877,18 @@ fn updateLazyType( |
| 3877 | }, | 3877 | }, |
| 3878 | .enum_type => { | 3878 | .enum_type => { |
| 3879 | const loaded_enum = ip.loadEnumType(type_index); | 3879 | const loaded_enum = ip.loadEnumType(type_index); |
| 3880 | try wip_nav.abbrevCode(if (loaded_enum.names.len == 0) .generated_empty_enum_type else .generated_enum_type); | 3880 | try wip_nav.abbrevCode(if (loaded_enum.field_names.len == 0) .generated_empty_enum_type else .generated_enum_type); |
| 3881 | try wip_nav.strp(name); | 3881 | try wip_nav.strp(name); |
| 3882 | try wip_nav.refType(.fromInterned(loaded_enum.tag_ty)); | 3882 | try wip_nav.refType(.fromInterned(loaded_enum.int_tag_type)); |
| 3883 | for (0..loaded_enum.names.len) |field_index| { | 3883 | for (0..loaded_enum.field_names.len) |field_index| { |
| 3884 | try wip_nav.enumConstValue(loaded_enum, .{ | 3884 | try wip_nav.enumConstValue(loaded_enum, .{ |
| 3885 | .sdata = .signed_enum_field, | 3885 | .sdata = .signed_enum_field, |
| 3886 | .udata = .unsigned_enum_field, | 3886 | .udata = .unsigned_enum_field, |
| 3887 | .block = .big_enum_field, | 3887 | .block = .big_enum_field, |
| 3888 | }, field_index); | 3888 | }, field_index); |
| 3889 | try wip_nav.strp(loaded_enum.names.get(ip)[field_index].toSlice(ip)); | 3889 | try wip_nav.strp(loaded_enum.field_names.get(ip)[field_index].toSlice(ip)); |
| 3890 | } | 3890 | } |
| 3891 | if (loaded_enum.names.len > 0) try diw.writeUleb128(@intFromEnum(AbbrevCode.null)); | 3891 | if (loaded_enum.field_names.len > 0) try diw.writeUleb128(@intFromEnum(AbbrevCode.null)); |
| 3892 | }, | 3892 | }, |
| 3893 | .func_type => |func_type| { | 3893 | .func_type => |func_type| { |
| 3894 | const is_nullary = func_type.param_types.len == 0 and !func_type.is_var_args; | 3894 | const is_nullary = func_type.param_types.len == 0 and !func_type.is_var_args; |
| ... | @@ -4349,7 +4349,7 @@ fn updateLazyValue( | ... | @@ -4349,7 +4349,7 @@ fn updateLazyValue( |
| 4349 | const loaded_struct_type = ip.loadStructType(aggregate.ty); | 4349 | const loaded_struct_type = ip.loadStructType(aggregate.ty); |
| 4350 | assert(loaded_struct_type.layout == .auto); | 4350 | assert(loaded_struct_type.layout == .auto); |
| 4351 | for (0..loaded_struct_type.field_types.len) |field_index| { | 4351 | for (0..loaded_struct_type.field_types.len) |field_index| { |
| 4352 | if (loaded_struct_type.fieldIsComptime(ip, field_index)) continue; | 4352 | if (loaded_struct_type.field_is_comptime_bits.get(ip, field_index)) continue; |
| 4353 | const field_type: Type = .fromInterned(loaded_struct_type.field_types.get(ip)[field_index]); | 4353 | const field_type: Type = .fromInterned(loaded_struct_type.field_types.get(ip)[field_index]); |
| 4354 | const has_runtime_bits = field_type.hasRuntimeBits(zcu); | 4354 | const has_runtime_bits = field_type.hasRuntimeBits(zcu); |
| 4355 | const has_comptime_state = field_type.comptimeOnly(zcu) and try field_type.onePossibleValue(pt) == null; | 4355 | const has_comptime_state = field_type.comptimeOnly(zcu) and try field_type.onePossibleValue(pt) == null; |
| ... | @@ -4359,7 +4359,7 @@ fn updateLazyValue( | ... | @@ -4359,7 +4359,7 @@ fn updateLazyValue( |
| 4359 | .comptime_value_field_runtime_bits | 4359 | .comptime_value_field_runtime_bits |
| 4360 | else | 4360 | else |
| 4361 | continue); | 4361 | continue); |
| 4362 | try wip_nav.strp(loaded_struct_type.fieldName(ip, field_index).toSlice(ip)); | 4362 | try wip_nav.strp(loaded_struct_type.field_names.get(ip)[field_index].toSlice(ip)); |
| 4363 | const field_value: Value = .fromInterned(switch (aggregate.storage) { | 4363 | const field_value: Value = .fromInterned(switch (aggregate.storage) { |
| 4364 | .bytes => unreachable, | 4364 | .bytes => unreachable, |
| 4365 | .elems => |elems| elems[field_index], | 4365 | .elems => |elems| elems[field_index], |
| ... | @@ -4427,10 +4427,10 @@ fn updateLazyValue( | ... | @@ -4427,10 +4427,10 @@ fn updateLazyValue( |
| 4427 | try wip_nav.refType(.fromInterned(un.ty)); | 4427 | try wip_nav.refType(.fromInterned(un.ty)); |
| 4428 | field: { | 4428 | field: { |
| 4429 | const loaded_union_type = ip.loadUnionType(un.ty); | 4429 | const loaded_union_type = ip.loadUnionType(un.ty); |
| 4430 | assert(loaded_union_type.flagsUnordered(ip).layout == .auto); | 4430 | assert(loaded_union_type.layout == .auto); |
| 4431 | const field_index = zcu.unionTagFieldIndex(loaded_union_type, Value.fromInterned(un.tag)).?; | 4431 | const field_index = zcu.unionTagFieldIndex(loaded_union_type, Value.fromInterned(un.tag)).?; |
| 4432 | const field_ty: Type = .fromInterned(loaded_union_type.field_types.get(ip)[field_index]); | 4432 | const field_ty: Type = .fromInterned(loaded_union_type.field_types.get(ip)[field_index]); |
| 4433 | const field_name = loaded_union_type.loadTagType(ip).names.get(ip)[field_index]; | 4433 | const field_name = ip.loadEnumType(loaded_union_type.enum_tag_type).field_names.get(ip)[field_index]; |
| 4434 | const has_runtime_bits = field_ty.hasRuntimeBits(zcu); | 4434 | const has_runtime_bits = field_ty.hasRuntimeBits(zcu); |
| 4435 | const has_comptime_state = field_ty.comptimeOnly(zcu) and try field_ty.onePossibleValue(pt) == null; | 4435 | const has_comptime_state = field_ty.comptimeOnly(zcu) and try field_ty.onePossibleValue(pt) == null; |
| 4436 | try wip_nav.abbrevCode(if (has_comptime_state) | 4436 | try wip_nav.abbrevCode(if (has_comptime_state) |
| ... | @@ -4521,8 +4521,8 @@ fn updateContainerTypeWriterError( | ... | @@ -4521,8 +4521,8 @@ fn updateContainerTypeWriterError( |
| 4521 | try diw.writeUleb128(ty.abiSize(zcu)); | 4521 | try diw.writeUleb128(ty.abiSize(zcu)); |
| 4522 | try diw.writeUleb128(ty.abiAlignment(zcu).toByteUnits().?); | 4522 | try diw.writeUleb128(ty.abiAlignment(zcu).toByteUnits().?); |
| 4523 | for (0..loaded_struct.field_types.len) |field_index| { | 4523 | for (0..loaded_struct.field_types.len) |field_index| { |
| 4524 | const is_comptime = loaded_struct.fieldIsComptime(ip, field_index); | 4524 | const is_comptime = loaded_struct.field_is_comptime_bits.get(ip, field_index); |
| 4525 | const field_init = loaded_struct.fieldInit(ip, field_index); | 4525 | const field_init = loaded_struct.field_defaults.getOrNone(ip, field_index); |
| 4526 | assert(!(is_comptime and field_init == .none)); | 4526 | assert(!(is_comptime and field_init == .none)); |
| 4527 | const field_type: Type = .fromInterned(loaded_struct.field_types.get(ip)[field_index]); | 4527 | const field_type: Type = .fromInterned(loaded_struct.field_types.get(ip)[field_index]); |
| 4528 | const has_runtime_bits, const has_comptime_state = switch (field_init) { | 4528 | const has_runtime_bits, const has_comptime_state = switch (field_init) { |
| ... | @@ -4548,11 +4548,11 @@ fn updateContainerTypeWriterError( | ... | @@ -4548,11 +4548,11 @@ fn updateContainerTypeWriterError( |
| 4548 | .struct_field | 4548 | .struct_field |
| 4549 | else | 4549 | else |
| 4550 | .struct_field); | 4550 | .struct_field); |
| 4551 | try wip_nav.strp(loaded_struct.fieldName(ip, field_index).toSlice(ip)); | 4551 | try wip_nav.strp(loaded_struct.field_names.get(ip)[field_index].toSlice(ip)); |
| 4552 | try wip_nav.refType(field_type); | 4552 | try wip_nav.refType(field_type); |
| 4553 | if (!is_comptime) { | 4553 | if (!is_comptime) { |
| 4554 | try diw.writeUleb128(loaded_struct.offsets.get(ip)[field_index]); | 4554 | try diw.writeUleb128(loaded_struct.field_offsets.get(ip)[field_index]); |
| 4555 | try diw.writeUleb128(loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse | 4555 | try diw.writeUleb128(loaded_struct.field_aligns.getOrNone(ip, field_index).toByteUnits() orelse |
| 4556 | field_type.abiAlignment(zcu).toByteUnits().?); | 4556 | field_type.abiAlignment(zcu).toByteUnits().?); |
| 4557 | } | 4557 | } |
| 4558 | if (has_comptime_state) | 4558 | if (has_comptime_state) |
| ... | @@ -4628,8 +4628,8 @@ fn updateContainerTypeWriterError( | ... | @@ -4628,8 +4628,8 @@ fn updateContainerTypeWriterError( |
| 4628 | try diw.writeUleb128(ty.abiSize(zcu)); | 4628 | try diw.writeUleb128(ty.abiSize(zcu)); |
| 4629 | try diw.writeUleb128(ty.abiAlignment(zcu).toByteUnits().?); | 4629 | try diw.writeUleb128(ty.abiAlignment(zcu).toByteUnits().?); |
| 4630 | for (0..loaded_struct.field_types.len) |field_index| { | 4630 | for (0..loaded_struct.field_types.len) |field_index| { |
| 4631 | const is_comptime = loaded_struct.fieldIsComptime(ip, field_index); | 4631 | const is_comptime = loaded_struct.field_is_comptime_bits.get(ip, field_index); |
| 4632 | const field_init = loaded_struct.fieldInit(ip, field_index); | 4632 | const field_init = loaded_struct.field_defaults.getOrNone(ip, field_index); |
| 4633 | assert(!(is_comptime and field_init == .none)); | 4633 | assert(!(is_comptime and field_init == .none)); |
| 4634 | const field_type: Type = .fromInterned(loaded_struct.field_types.get(ip)[field_index]); | 4634 | const field_type: Type = .fromInterned(loaded_struct.field_types.get(ip)[field_index]); |
| 4635 | const has_runtime_bits, const has_comptime_state = switch (field_init) { | 4635 | const has_runtime_bits, const has_comptime_state = switch (field_init) { |
| ... | @@ -4655,11 +4655,11 @@ fn updateContainerTypeWriterError( | ... | @@ -4655,11 +4655,11 @@ fn updateContainerTypeWriterError( |
| 4655 | .struct_field | 4655 | .struct_field |
| 4656 | else | 4656 | else |
| 4657 | .struct_field); | 4657 | .struct_field); |
| 4658 | try wip_nav.strp(loaded_struct.fieldName(ip, field_index).toSlice(ip)); | 4658 | try wip_nav.strp(loaded_struct.field_names.get(ip)[field_index].toSlice(ip)); |
| 4659 | try wip_nav.refType(field_type); | 4659 | try wip_nav.refType(field_type); |
| 4660 | if (!is_comptime) { | 4660 | if (!is_comptime) { |
| 4661 | try diw.writeUleb128(loaded_struct.offsets.get(ip)[field_index]); | 4661 | try diw.writeUleb128(loaded_struct.field_offsets.get(ip)[field_index]); |
| 4662 | try diw.writeUleb128(loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse | 4662 | try diw.writeUleb128(loaded_struct.field_aligns.getOrNone(ip, field_index).toByteUnits() orelse |
| 4663 | field_type.abiAlignment(zcu).toByteUnits().?); | 4663 | field_type.abiAlignment(zcu).toByteUnits().?); |
| 4664 | } | 4664 | } |
| 4665 | if (has_comptime_state) | 4665 | if (has_comptime_state) |
| ... | @@ -4674,11 +4674,11 @@ fn updateContainerTypeWriterError( | ... | @@ -4674,11 +4674,11 @@ fn updateContainerTypeWriterError( |
| 4674 | try wip_nav.abbrevCode(if (loaded_struct.field_types.len > 0) .packed_struct_type else .empty_packed_struct_type); | 4674 | try wip_nav.abbrevCode(if (loaded_struct.field_types.len > 0) .packed_struct_type else .empty_packed_struct_type); |
| 4675 | try diw.writeUleb128(file_gop.index); | 4675 | try diw.writeUleb128(file_gop.index); |
| 4676 | try wip_nav.strp(name); | 4676 | try wip_nav.strp(name); |
| 4677 | try wip_nav.refType(.fromInterned(loaded_struct.backingIntTypeUnordered(ip))); | 4677 | try wip_nav.refType(.fromInterned(loaded_struct.packed_backing_int_type)); |
| 4678 | var field_bit_offset: u16 = 0; | 4678 | var field_bit_offset: u16 = 0; |
| 4679 | for (0..loaded_struct.field_types.len) |field_index| { | 4679 | for (0..loaded_struct.field_types.len) |field_index| { |
| 4680 | try wip_nav.abbrevCode(.packed_struct_field); | 4680 | try wip_nav.abbrevCode(.packed_struct_field); |
| 4681 | try wip_nav.strp(loaded_struct.fieldName(ip, field_index).toSlice(ip)); | 4681 | try wip_nav.strp(loaded_struct.field_names.get(ip)[field_index].toSlice(ip)); |
| 4682 | const field_type: Type = .fromInterned(loaded_struct.field_types.get(ip)[field_index]); | 4682 | const field_type: Type = .fromInterned(loaded_struct.field_types.get(ip)[field_index]); |
| 4683 | try wip_nav.refType(field_type); | 4683 | try wip_nav.refType(field_type); |
| 4684 | try diw.writeUleb128(field_bit_offset); | 4684 | try diw.writeUleb128(field_bit_offset); |
| ... | @@ -4690,19 +4690,19 @@ fn updateContainerTypeWriterError( | ... | @@ -4690,19 +4690,19 @@ fn updateContainerTypeWriterError( |
| 4690 | }, | 4690 | }, |
| 4691 | .enum_type => { | 4691 | .enum_type => { |
| 4692 | const loaded_enum = ip.loadEnumType(type_index); | 4692 | const loaded_enum = ip.loadEnumType(type_index); |
| 4693 | try wip_nav.abbrevCode(if (loaded_enum.names.len > 0) .enum_type else .empty_enum_type); | 4693 | try wip_nav.abbrevCode(if (loaded_enum.field_names.len > 0) .enum_type else .empty_enum_type); |
| 4694 | try diw.writeUleb128(file_gop.index); | 4694 | try diw.writeUleb128(file_gop.index); |
| 4695 | try wip_nav.strp(name); | 4695 | try wip_nav.strp(name); |
| 4696 | try wip_nav.refType(.fromInterned(loaded_enum.tag_ty)); | 4696 | try wip_nav.refType(.fromInterned(loaded_enum.int_tag_type)); |
| 4697 | for (0..loaded_enum.names.len) |field_index| { | 4697 | for (0..loaded_enum.field_names.len) |field_index| { |
| 4698 | try wip_nav.enumConstValue(loaded_enum, .{ | 4698 | try wip_nav.enumConstValue(loaded_enum, .{ |
| 4699 | .sdata = .signed_enum_field, | 4699 | .sdata = .signed_enum_field, |
| 4700 | .udata = .unsigned_enum_field, | 4700 | .udata = .unsigned_enum_field, |
| 4701 | .block = .big_enum_field, | 4701 | .block = .big_enum_field, |
| 4702 | }, field_index); | 4702 | }, field_index); |
| 4703 | try wip_nav.strp(loaded_enum.names.get(ip)[field_index].toSlice(ip)); | 4703 | try wip_nav.strp(loaded_enum.field_names.get(ip)[field_index].toSlice(ip)); |
| 4704 | } | 4704 | } |
| 4705 | if (loaded_enum.names.len > 0) try diw.writeUleb128(@intFromEnum(AbbrevCode.null)); | 4705 | if (loaded_enum.field_names.len > 0) try diw.writeUleb128(@intFromEnum(AbbrevCode.null)); |
| 4706 | }, | 4706 | }, |
| 4707 | .union_type => { | 4707 | .union_type => { |
| 4708 | const loaded_union = ip.loadUnionType(type_index); | 4708 | const loaded_union = ip.loadUnionType(type_index); |
| ... | @@ -4712,8 +4712,8 @@ fn updateContainerTypeWriterError( | ... | @@ -4712,8 +4712,8 @@ fn updateContainerTypeWriterError( |
| 4712 | const union_layout = Type.getUnionLayout(loaded_union, zcu); | 4712 | const union_layout = Type.getUnionLayout(loaded_union, zcu); |
| 4713 | try diw.writeUleb128(union_layout.abi_size); | 4713 | try diw.writeUleb128(union_layout.abi_size); |
| 4714 | try diw.writeUleb128(union_layout.abi_align.toByteUnits().?); | 4714 | try diw.writeUleb128(union_layout.abi_align.toByteUnits().?); |
| 4715 | const loaded_tag = loaded_union.loadTagType(ip); | 4715 | const loaded_tag = ip.loadEnumType(loaded_union.enum_tag_type); |
| 4716 | if (loaded_union.hasTag(ip)) { | 4716 | if (loaded_union.runtime_tag != .none) { |
| 4717 | try wip_nav.abbrevCode(.tagged_union); | 4717 | try wip_nav.abbrevCode(.tagged_union); |
| 4718 | try wip_nav.infoSectionOffset( | 4718 | try wip_nav.infoSectionOffset( |
| 4719 | .debug_info, | 4719 | .debug_info, |
| ... | @@ -4724,7 +4724,7 @@ fn updateContainerTypeWriterError( | ... | @@ -4724,7 +4724,7 @@ fn updateContainerTypeWriterError( |
| 4724 | { | 4724 | { |
| 4725 | try wip_nav.abbrevCode(.generated_field); | 4725 | try wip_nav.abbrevCode(.generated_field); |
| 4726 | try wip_nav.strp("tag"); | 4726 | try wip_nav.strp("tag"); |
| 4727 | try wip_nav.refType(.fromInterned(loaded_union.enum_tag_ty)); | 4727 | try wip_nav.refType(.fromInterned(loaded_union.enum_tag_type)); |
| 4728 | try diw.writeUleb128(union_layout.tagOffset()); | 4728 | try diw.writeUleb128(union_layout.tagOffset()); |
| 4729 | 4729 | ||
| 4730 | for (0..loaded_union.field_types.len) |field_index| { | 4730 | for (0..loaded_union.field_types.len) |field_index| { |
| ... | @@ -4735,11 +4735,11 @@ fn updateContainerTypeWriterError( | ... | @@ -4735,11 +4735,11 @@ fn updateContainerTypeWriterError( |
| 4735 | }, field_index); | 4735 | }, field_index); |
| 4736 | { | 4736 | { |
| 4737 | try wip_nav.abbrevCode(.struct_field); | 4737 | try wip_nav.abbrevCode(.struct_field); |
| 4738 | try wip_nav.strp(loaded_tag.names.get(ip)[field_index].toSlice(ip)); | 4738 | try wip_nav.strp(loaded_tag.field_names.get(ip)[field_index].toSlice(ip)); |
| 4739 | const field_type: Type = .fromInterned(loaded_union.field_types.get(ip)[field_index]); | 4739 | const field_type: Type = .fromInterned(loaded_union.field_types.get(ip)[field_index]); |
| 4740 | try wip_nav.refType(field_type); | 4740 | try wip_nav.refType(field_type); |
| 4741 | try diw.writeUleb128(union_layout.payloadOffset()); | 4741 | try diw.writeUleb128(union_layout.payloadOffset()); |
| 4742 | try diw.writeUleb128(loaded_union.fieldAlign(ip, field_index).toByteUnits() orelse | 4742 | try diw.writeUleb128(loaded_union.field_aligns.getOrNone(ip, field_index).toByteUnits() orelse |
| 4743 | if (field_type.isNoReturn(zcu)) 1 else field_type.abiAlignment(zcu).toByteUnits().?); | 4743 | if (field_type.isNoReturn(zcu)) 1 else field_type.abiAlignment(zcu).toByteUnits().?); |
| 4744 | } | 4744 | } |
| 4745 | try diw.writeUleb128(@intFromEnum(AbbrevCode.null)); | 4745 | try diw.writeUleb128(@intFromEnum(AbbrevCode.null)); |
| ... | @@ -4748,10 +4748,10 @@ fn updateContainerTypeWriterError( | ... | @@ -4748,10 +4748,10 @@ fn updateContainerTypeWriterError( |
| 4748 | try diw.writeUleb128(@intFromEnum(AbbrevCode.null)); | 4748 | try diw.writeUleb128(@intFromEnum(AbbrevCode.null)); |
| 4749 | } else for (0..loaded_union.field_types.len) |field_index| { | 4749 | } else for (0..loaded_union.field_types.len) |field_index| { |
| 4750 | try wip_nav.abbrevCode(.untagged_union_field); | 4750 | try wip_nav.abbrevCode(.untagged_union_field); |
| 4751 | try wip_nav.strp(loaded_tag.names.get(ip)[field_index].toSlice(ip)); | 4751 | try wip_nav.strp(loaded_tag.field_names.get(ip)[field_index].toSlice(ip)); |
| 4752 | const field_type: Type = .fromInterned(loaded_union.field_types.get(ip)[field_index]); | 4752 | const field_type: Type = .fromInterned(loaded_union.field_types.get(ip)[field_index]); |
| 4753 | try wip_nav.refType(field_type); | 4753 | try wip_nav.refType(field_type); |
| 4754 | try diw.writeUleb128(loaded_union.fieldAlign(ip, field_index).toByteUnits() orelse | 4754 | try diw.writeUleb128(loaded_union.field_aligns.getOrNone(ip, field_index).toByteUnits() orelse |
| 4755 | if (field_type.isNoReturn(zcu)) 1 else field_type.abiAlignment(zcu).toByteUnits().?); | 4755 | if (field_type.isNoReturn(zcu)) 1 else field_type.abiAlignment(zcu).toByteUnits().?); |
| 4756 | } | 4756 | } |
| 4757 | if (loaded_union.field_types.len > 0) try diw.writeUleb128(@intFromEnum(AbbrevCode.null)); | 4757 | if (loaded_union.field_types.len > 0) try diw.writeUleb128(@intFromEnum(AbbrevCode.null)); |