authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-02-23 07:51:02+01:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-02-23 07:51:38+01:00
log6abb432598c2d9b4395cc4d86d7d69663b4a0ad0
treea0c43e1b5aaa9a864b94e8a7406cc07046209b86
parent43daed64fe8ce6e18571154adfea37ace2d84a34

Builder: implement opaque structs in bitcode


2 files changed, 24 insertions(+), 11 deletions(-)

src/codegen/llvm/Builder.zig+16-11
...@@ -13015,18 +13015,23 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -13015,18 +13015,23 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
13015 .string = extra.id.slice(self).?,13015 .string = extra.id.slice(self).?,
13016 });13016 });
1301713017
13018 const real_struct = self.type_items.items[@intFromEnum(extra.body)];13018 switch (extra.body) {
13019 const is_packed: bool = switch (real_struct.tag) {13019 .none => try type_block.writeAbbrev(ir.Type.Opaque{}),
13020 .structure => false,13020 else => {
13021 .packed_structure => true,13021 const real_struct = self.type_items.items[@intFromEnum(extra.body)];
13022 else => unreachable,13022 const is_packed: bool = switch (real_struct.tag) {
13023 };13023 .structure => false,
13024 .packed_structure => true,
13025 else => unreachable,
13026 };
1302413027
13025 var real_extra = self.typeExtraDataTrail(Type.Structure, real_struct.data);13028 var real_extra = self.typeExtraDataTrail(Type.Structure, real_struct.data);
13026 try type_block.writeAbbrev(ir.Type.StructNamed{13029 try type_block.writeAbbrev(ir.Type.StructNamed{
13027 .is_packed = is_packed,13030 .is_packed = is_packed,
13028 .types = real_extra.trail.next(real_extra.data.fields_len, Type, self),13031 .types = real_extra.trail.next(real_extra.data.fields_len, Type, self),
13029 });13032 });
13033 },
13034 }
13030 },13035 },
13031 .array,13036 .array,
13032 .small_array,13037 .small_array,
src/codegen/llvm/ir.zig+8
...@@ -188,6 +188,7 @@ pub const Type = struct {...@@ -188,6 +188,7 @@ pub const Type = struct {
188 pub const abbrevs = [_]type{188 pub const abbrevs = [_]type{
189 NumEntry,189 NumEntry,
190 Simple,190 Simple,
191 Opaque,
191 Integer,192 Integer,
192 StructAnon,193 StructAnon,
193 StructNamed,194 StructNamed,
...@@ -214,6 +215,13 @@ pub const Type = struct {...@@ -214,6 +215,13 @@ pub const Type = struct {
214 code: u5,215 code: u5,
215 };216 };
216217
218 pub const Opaque = struct {
219 pub const ops = [_]AbbrevOp{
220 .{ .literal = 6 },
221 .{ .literal = 0 },
222 };
223 };
224
217 pub const Integer = struct {225 pub const Integer = struct {
218 pub const ops = [_]AbbrevOp{226 pub const ops = [_]AbbrevOp{
219 .{ .literal = 7 },227 .{ .literal = 7 },