aboutsummaryrefslogtreecommitdiff
path: root/src/InternPool.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-05-04 20:39:32 -0700
committerAndrew Kelley <andrew@ziglang.org>2023-06-10 20:42:28 -0700
commit773fabf3610629c8974b59ed6fbd27050b7e505b (patch)
tree483008e1e8536df478253558aa0c73b79d9edb45 /src/InternPool.zig
parent5e636643d2a36c777a607b65cfd1abbb1822ad1e (diff)
downloadzig-773fabf3610629c8974b59ed6fbd27050b7e505b.tar.gz
zig-773fabf3610629c8974b59ed6fbd27050b7e505b.zip
InternPool: add the missing pointer data
Diffstat (limited to 'src/InternPool.zig')
-rw-r--r--src/InternPool.zig21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/InternPool.zig b/src/InternPool.zig
index 295a694e2a..7328c74b4f 100644
--- a/src/InternPool.zig
+++ b/src/InternPool.zig
@@ -653,7 +653,6 @@ pub const Tag = enum(u8) {
/// data is payload to Vector.
type_vector,
/// A fully explicitly specified pointer type.
- /// TODO actually this is missing some stuff like bit_offset
/// data is payload to Pointer.
type_pointer,
/// An optional type.
@@ -793,6 +792,8 @@ pub const Pointer = struct {
child: Index,
sentinel: Index,
flags: Flags,
+ packed_offset: PackedOffset,
+ vector_index: VectorIndex,
pub const Flags = packed struct(u32) {
alignment: u16,
@@ -804,8 +805,14 @@ pub const Pointer = struct {
_: u7 = undefined,
};
+ pub const PackedOffset = packed struct(u32) {
+ host_size: u16,
+ bit_offset: u16,
+ };
+
pub const Size = std.builtin.Type.Pointer.Size;
pub const AddressSpace = std.builtin.AddressSpace;
+ pub const VectorIndex = Key.PtrType.VectorIndex;
};
/// Used for non-sentineled arrays that have length fitting in u32, as well as
@@ -914,6 +921,9 @@ pub fn indexToKey(ip: InternPool, index: Index) Key {
.is_volatile = ptr_info.flags.is_volatile,
.is_allowzero = ptr_info.flags.is_allowzero,
.address_space = ptr_info.flags.address_space,
+ .vector_index = ptr_info.vector_index,
+ .host_size = ptr_info.packed_offset.host_size,
+ .bit_offset = ptr_info.packed_offset.bit_offset,
} };
},
@@ -972,6 +982,11 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index {
.size = ptr_type.size,
.address_space = ptr_type.address_space,
},
+ .packed_offset = .{
+ .host_size = ptr_type.host_size,
+ .bit_offset = ptr_type.bit_offset,
+ },
+ .vector_index = ptr_type.vector_index,
}),
});
},
@@ -1126,6 +1141,8 @@ fn addExtraAssumeCapacity(ip: *InternPool, extra: anytype) u32 {
Index => @enumToInt(@field(extra, field.name)),
i32 => @bitCast(u32, @field(extra, field.name)),
Pointer.Flags => @bitCast(u32, @field(extra, field.name)),
+ Pointer.PackedOffset => @bitCast(u32, @field(extra, field.name)),
+ Pointer.VectorIndex => @enumToInt(@field(extra, field.name)),
else => @compileError("bad field type: " ++ @typeName(field.type)),
});
}
@@ -1180,6 +1197,8 @@ fn extraData(ip: InternPool, comptime T: type, index: usize) T {
Index => @intToEnum(Index, ip.extra.items[i]),
i32 => @bitCast(i32, ip.extra.items[i]),
Pointer.Flags => @bitCast(Pointer.Flags, ip.extra.items[i]),
+ Pointer.PackedOffset => @bitCast(Pointer.PackedOffset, ip.extra.items[i]),
+ Pointer.VectorIndex => @intToEnum(Pointer.VectorIndex, ip.extra.items[i]),
else => @compileError("bad field type: " ++ @typeName(field.type)),
};
i += 1;