| ... | @@ -653,7 +653,6 @@ pub const Tag = enum(u8) { | ... | @@ -653,7 +653,6 @@ pub const Tag = enum(u8) { |
| 653 | /// data is payload to Vector. | 653 | /// data is payload to Vector. |
| 654 | type_vector, | 654 | type_vector, |
| 655 | /// A fully explicitly specified pointer type. | 655 | /// A fully explicitly specified pointer type. |
| 656 | /// TODO actually this is missing some stuff like bit_offset | | |
| 657 | /// data is payload to Pointer. | 656 | /// data is payload to Pointer. |
| 658 | type_pointer, | 657 | type_pointer, |
| 659 | /// An optional type. | 658 | /// An optional type. |
| ... | @@ -793,6 +792,8 @@ pub const Pointer = struct { | ... | @@ -793,6 +792,8 @@ pub const Pointer = struct { |
| 793 | child: Index, | 792 | child: Index, |
| 794 | sentinel: Index, | 793 | sentinel: Index, |
| 795 | flags: Flags, | 794 | flags: Flags, |
| | 795 | packed_offset: PackedOffset, |
| | 796 | vector_index: VectorIndex, |
| 796 | | 797 | |
| 797 | pub const Flags = packed struct(u32) { | 798 | pub const Flags = packed struct(u32) { |
| 798 | alignment: u16, | 799 | alignment: u16, |
| ... | @@ -804,8 +805,14 @@ pub const Pointer = struct { | ... | @@ -804,8 +805,14 @@ pub const Pointer = struct { |
| 804 | _: u7 = undefined, | 805 | _: u7 = undefined, |
| 805 | }; | 806 | }; |
| 806 | | 807 | |
| | 808 | pub const PackedOffset = packed struct(u32) { |
| | 809 | host_size: u16, |
| | 810 | bit_offset: u16, |
| | 811 | }; |
| | 812 | |
| 807 | pub const Size = std.builtin.Type.Pointer.Size; | 813 | pub const Size = std.builtin.Type.Pointer.Size; |
| 808 | pub const AddressSpace = std.builtin.AddressSpace; | 814 | pub const AddressSpace = std.builtin.AddressSpace; |
| | 815 | pub const VectorIndex = Key.PtrType.VectorIndex; |
| 809 | }; | 816 | }; |
| 810 | | 817 | |
| 811 | /// Used for non-sentineled arrays that have length fitting in u32, as well as | 818 | /// 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 { | ... | @@ -914,6 +921,9 @@ pub fn indexToKey(ip: InternPool, index: Index) Key { |
| 914 | .is_volatile = ptr_info.flags.is_volatile, | 921 | .is_volatile = ptr_info.flags.is_volatile, |
| 915 | .is_allowzero = ptr_info.flags.is_allowzero, | 922 | .is_allowzero = ptr_info.flags.is_allowzero, |
| 916 | .address_space = ptr_info.flags.address_space, | 923 | .address_space = ptr_info.flags.address_space, |
| | 924 | .vector_index = ptr_info.vector_index, |
| | 925 | .host_size = ptr_info.packed_offset.host_size, |
| | 926 | .bit_offset = ptr_info.packed_offset.bit_offset, |
| 917 | } }; | 927 | } }; |
| 918 | }, | 928 | }, |
| 919 | | 929 | |
| ... | @@ -972,6 +982,11 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index { | ... | @@ -972,6 +982,11 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index { |
| 972 | .size = ptr_type.size, | 982 | .size = ptr_type.size, |
| 973 | .address_space = ptr_type.address_space, | 983 | .address_space = ptr_type.address_space, |
| 974 | }, | 984 | }, |
| | 985 | .packed_offset = .{ |
| | 986 | .host_size = ptr_type.host_size, |
| | 987 | .bit_offset = ptr_type.bit_offset, |
| | 988 | }, |
| | 989 | .vector_index = ptr_type.vector_index, |
| 975 | }), | 990 | }), |
| 976 | }); | 991 | }); |
| 977 | }, | 992 | }, |
| ... | @@ -1126,6 +1141,8 @@ fn addExtraAssumeCapacity(ip: *InternPool, extra: anytype) u32 { | ... | @@ -1126,6 +1141,8 @@ fn addExtraAssumeCapacity(ip: *InternPool, extra: anytype) u32 { |
| 1126 | Index => @enumToInt(@field(extra, field.name)), | 1141 | Index => @enumToInt(@field(extra, field.name)), |
| 1127 | i32 => @bitCast(u32, @field(extra, field.name)), | 1142 | i32 => @bitCast(u32, @field(extra, field.name)), |
| 1128 | Pointer.Flags => @bitCast(u32, @field(extra, field.name)), | 1143 | Pointer.Flags => @bitCast(u32, @field(extra, field.name)), |
| | 1144 | Pointer.PackedOffset => @bitCast(u32, @field(extra, field.name)), |
| | 1145 | Pointer.VectorIndex => @enumToInt(@field(extra, field.name)), |
| 1129 | else => @compileError("bad field type: " ++ @typeName(field.type)), | 1146 | else => @compileError("bad field type: " ++ @typeName(field.type)), |
| 1130 | }); | 1147 | }); |
| 1131 | } | 1148 | } |
| ... | @@ -1180,6 +1197,8 @@ fn extraData(ip: InternPool, comptime T: type, index: usize) T { | ... | @@ -1180,6 +1197,8 @@ fn extraData(ip: InternPool, comptime T: type, index: usize) T { |
| 1180 | Index => @intToEnum(Index, ip.extra.items[i]), | 1197 | Index => @intToEnum(Index, ip.extra.items[i]), |
| 1181 | i32 => @bitCast(i32, ip.extra.items[i]), | 1198 | i32 => @bitCast(i32, ip.extra.items[i]), |
| 1182 | Pointer.Flags => @bitCast(Pointer.Flags, ip.extra.items[i]), | 1199 | Pointer.Flags => @bitCast(Pointer.Flags, ip.extra.items[i]), |
| | 1200 | Pointer.PackedOffset => @bitCast(Pointer.PackedOffset, ip.extra.items[i]), |
| | 1201 | Pointer.VectorIndex => @intToEnum(Pointer.VectorIndex, ip.extra.items[i]), |
| 1183 | else => @compileError("bad field type: " ++ @typeName(field.type)), | 1202 | else => @compileError("bad field type: " ++ @typeName(field.type)), |
| 1184 | }; | 1203 | }; |
| 1185 | i += 1; | 1204 | i += 1; |