authorgravatar for liljaanton2001@gmail.comantlilja <liljaanton2001@gmail.com> 2024-02-21 23:33:25+01:00
committergravatar for liljaanton2001@gmail.comantlilja <liljaanton2001@gmail.com> 2024-02-21 23:33:25+01:00
log53f6071486a90661afc525019aa42037818ddac7
treee47dc6112657b7646c938db51f00c068bb7ba07f
parent5e9d0da43bd5dbda5a1d0e3d2d913efc6a071465

LLVM Builder: Emit debug vector types with DIVector flag


3 files changed, 57 insertions(+), 3 deletions(-)

src/codegen/llvm.zig+1-1
......@@ -2224,7 +2224,7 @@ pub const Object = struct {
22242224 else => try o.lowerDebugType(ty.childType(mod)),
22252225 };
22262226
2227 const debug_vector_type = try o.builder.debugArrayType(
2227 const debug_vector_type = try o.builder.debugVectorType(
22282228 Builder.MetadataString.none, // Name
22292229 Builder.Metadata.none, // File
22302230 Builder.Metadata.none, // Scope
src/codegen/llvm/Builder.zig+54-1
......@@ -7608,6 +7608,7 @@ pub const Metadata = enum(u32) {
76087608 composite_union_type,
76097609 composite_enumeration_type,
76107610 composite_array_type,
7611 composite_vector_type,
76117612 derived_pointer_type,
76127613 derived_member_type,
76137614 subroutine_type,
......@@ -11173,6 +11174,30 @@ pub fn debugArrayType(
1117311174 );
1117411175}
1117511176
11177pub fn debugVectorType(
11178 self: *Builder,
11179 name: MetadataString,
11180 file: Metadata,
11181 scope: Metadata,
11182 line: u32,
11183 underlying_type: Metadata,
11184 size_in_bits: u64,
11185 align_in_bits: u64,
11186 fields_tuple: Metadata,
11187) Allocator.Error!Metadata {
11188 try self.ensureUnusedMetadataCapacity(1, Metadata.CompositeType, 0);
11189 return self.debugVectorTypeAssumeCapacity(
11190 name,
11191 file,
11192 scope,
11193 line,
11194 underlying_type,
11195 size_in_bits,
11196 align_in_bits,
11197 fields_tuple,
11198 );
11199}
11200
1117611201pub fn debugPointerType(
1117711202 self: *Builder,
1117811203 name: MetadataString,
......@@ -11626,6 +11651,30 @@ fn debugArrayTypeAssumeCapacity(
1162611651 );
1162711652}
1162811653
11654fn debugVectorTypeAssumeCapacity(
11655 self: *Builder,
11656 name: MetadataString,
11657 file: Metadata,
11658 scope: Metadata,
11659 line: u32,
11660 underlying_type: Metadata,
11661 size_in_bits: u64,
11662 align_in_bits: u64,
11663 fields_tuple: Metadata,
11664) Metadata {
11665 return self.debugCompositeTypeAssumeCapacity(
11666 .composite_vector_type,
11667 name,
11668 file,
11669 scope,
11670 line,
11671 underlying_type,
11672 size_in_bits,
11673 align_in_bits,
11674 fields_tuple,
11675 );
11676}
11677
1162911678fn debugCompositeTypeAssumeCapacity(
1163011679 self: *Builder,
1163111680 tag: Metadata.Tag,
......@@ -13166,6 +13215,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1316613215 .composite_union_type,
1316713216 .composite_enumeration_type,
1316813217 .composite_array_type,
13218 .composite_vector_type,
1316913219 => |kind| {
1317013220 const extra = self.metadataExtraData(Metadata.CompositeType, data);
1317113221
......@@ -13174,7 +13224,9 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1317413224 .composite_struct_type => std.dwarf.TAG.structure_type,
1317513225 .composite_union_type => std.dwarf.TAG.union_type,
1317613226 .composite_enumeration_type => std.dwarf.TAG.enumeration_type,
13177 .composite_array_type => std.dwarf.TAG.array_type,
13227 .composite_array_type,
13228 .composite_vector_type,
13229 => std.dwarf.TAG.array_type,
1317813230 else => unreachable,
1317913231 },
1318013232 .name = extra.name,
......@@ -13184,6 +13236,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
1318413236 .underlying_type = extra.underlying_type,
1318513237 .size_in_bits = @as(u64, extra.size_in_bits_lo) | @as(u64, extra.size_in_bits_hi) << 32,
1318613238 .align_in_bits = @as(u64, extra.align_in_bits_lo) | @as(u64, extra.align_in_bits_hi) << 32,
13239 .flags = if (kind == .composite_vector_type) DIFlags.Vector else 0,
1318713240 .elements = extra.fields_tuple,
1318813241 }, metadata_adapter);
1318913242 },
src/codegen/llvm/IR.zig+2-1
......@@ -767,7 +767,7 @@ pub const MetadataBlock = struct {
767767 .{ .vbr = 6 }, // size in bits
768768 .{ .vbr = 6 }, // align in bits
769769 .{ .literal = 0 }, // offset in bits
770 .{ .literal = 0 }, // flags
770 .{ .fixed = 32 }, // flags
771771 MetadataAbbrev, // elements
772772 .{ .literal = 0 }, // runtime lang
773773 .{ .literal = 0 }, // vtable holder
......@@ -789,6 +789,7 @@ pub const MetadataBlock = struct {
789789 underlying_type: Builder.Metadata,
790790 size_in_bits: u64,
791791 align_in_bits: u64,
792 flags: u32,
792793 elements: Builder.Metadata,
793794 };
794795