aboutsummaryrefslogtreecommitdiff
path: root/src/type.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-10-03 11:13:40 -0700
committerGitHub <noreply@github.com>2023-10-03 11:13:40 -0700
commit5c3393dc2efc836b0ec23e3c2c5ad3da4f8d6a59 (patch)
tree6cce7dc2cb662d5b85d75d77cca12a84f46fa63c /src/type.zig
parent77338947617f5aed0bfe50ca4975d284736a5d90 (diff)
parent405705cb76914072b9a91ac29f7cf0bf67b255f4 (diff)
downloadzig-5c3393dc2efc836b0ec23e3c2c5ad3da4f8d6a59.tar.gz
zig-5c3393dc2efc836b0ec23e3c2c5ad3da4f8d6a59.zip
Merge pull request #17375 from xxxbxxx/packed-struct
codegen: fix field offsets in packed structs
Diffstat (limited to 'src/type.zig')
-rw-r--r--src/type.zig20
1 files changed, 0 insertions, 20 deletions
diff --git a/src/type.zig b/src/type.zig
index 79be8b4c5b..78514fe3d5 100644
--- a/src/type.zig
+++ b/src/type.zig
@@ -3028,26 +3028,6 @@ pub const Type = struct {
};
}
- pub fn packedStructFieldBitOffset(ty: Type, field_index: usize, mod: *Module) u32 {
- const ip = &mod.intern_pool;
- const struct_type = ip.indexToKey(ty.toIntern()).struct_type;
- assert(struct_type.layout == .Packed);
- comptime assert(Type.packed_struct_layout_version == 2);
-
- var running_bits: u32 = 0;
- for (struct_type.field_types.get(ip), 0..) |field_ty, i| {
- if (i == field_index) break;
- if (!field_ty.toType().hasRuntimeBits(mod)) continue;
- const field_bits: u32 = @intCast(field_ty.toType().bitSize(mod));
- running_bits += field_bits;
- }
- return running_bits;
- }
-
- pub fn packedStructFieldByteOffset(ty: Type, field_index: usize, mod: *Module) u32 {
- return packedStructFieldBitOffset(ty, field_index, mod) / 8;
- }
-
pub const FieldOffset = struct {
field: usize,
offset: u64,