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 {...@@ -2224,7 +2224,7 @@ pub const Object = struct {
2224 else => try o.lowerDebugType(ty.childType(mod)),2224 else => try o.lowerDebugType(ty.childType(mod)),
2225 };2225 };
22262226
2227 const debug_vector_type = try o.builder.debugArrayType(2227 const debug_vector_type = try o.builder.debugVectorType(
2228 Builder.MetadataString.none, // Name2228 Builder.MetadataString.none, // Name
2229 Builder.Metadata.none, // File2229 Builder.Metadata.none, // File
2230 Builder.Metadata.none, // Scope2230 Builder.Metadata.none, // Scope
src/codegen/llvm/Builder.zig+54-1
...@@ -7608,6 +7608,7 @@ pub const Metadata = enum(u32) {...@@ -7608,6 +7608,7 @@ pub const Metadata = enum(u32) {
7608 composite_union_type,7608 composite_union_type,
7609 composite_enumeration_type,7609 composite_enumeration_type,
7610 composite_array_type,7610 composite_array_type,
7611 composite_vector_type,
7611 derived_pointer_type,7612 derived_pointer_type,
7612 derived_member_type,7613 derived_member_type,
7613 subroutine_type,7614 subroutine_type,
...@@ -11173,6 +11174,30 @@ pub fn debugArrayType(...@@ -11173,6 +11174,30 @@ pub fn debugArrayType(
11173 );11174 );
11174}11175}
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
11176pub fn debugPointerType(11201pub fn debugPointerType(
11177 self: *Builder,11202 self: *Builder,
11178 name: MetadataString,11203 name: MetadataString,
...@@ -11626,6 +11651,30 @@ fn debugArrayTypeAssumeCapacity(...@@ -11626,6 +11651,30 @@ fn debugArrayTypeAssumeCapacity(
11626 );11651 );
11627}11652}
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
11629fn debugCompositeTypeAssumeCapacity(11678fn debugCompositeTypeAssumeCapacity(
11630 self: *Builder,11679 self: *Builder,
11631 tag: Metadata.Tag,11680 tag: Metadata.Tag,
...@@ -13166,6 +13215,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -13166,6 +13215,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
13166 .composite_union_type,13215 .composite_union_type,
13167 .composite_enumeration_type,13216 .composite_enumeration_type,
13168 .composite_array_type,13217 .composite_array_type,
13218 .composite_vector_type,
13169 => |kind| {13219 => |kind| {
13170 const extra = self.metadataExtraData(Metadata.CompositeType, data);13220 const extra = self.metadataExtraData(Metadata.CompositeType, data);
1317113221
...@@ -13174,7 +13224,9 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -13174,7 +13224,9 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
13174 .composite_struct_type => std.dwarf.TAG.structure_type,13224 .composite_struct_type => std.dwarf.TAG.structure_type,
13175 .composite_union_type => std.dwarf.TAG.union_type,13225 .composite_union_type => std.dwarf.TAG.union_type,
13176 .composite_enumeration_type => std.dwarf.TAG.enumeration_type,13226 .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,
13178 else => unreachable,13230 else => unreachable,
13179 },13231 },
13180 .name = extra.name,13232 .name = extra.name,
...@@ -13184,6 +13236,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -13184,6 +13236,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
13184 .underlying_type = extra.underlying_type,13236 .underlying_type = extra.underlying_type,
13185 .size_in_bits = @as(u64, extra.size_in_bits_lo) | @as(u64, extra.size_in_bits_hi) << 32,13237 .size_in_bits = @as(u64, extra.size_in_bits_lo) | @as(u64, extra.size_in_bits_hi) << 32,
13186 .align_in_bits = @as(u64, extra.align_in_bits_lo) | @as(u64, extra.align_in_bits_hi) << 32,13238 .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,
13187 .elements = extra.fields_tuple,13240 .elements = extra.fields_tuple,
13188 }, metadata_adapter);13241 }, metadata_adapter);
13189 },13242 },
src/codegen/llvm/IR.zig+2-1
...@@ -767,7 +767,7 @@ pub const MetadataBlock = struct {...@@ -767,7 +767,7 @@ pub const MetadataBlock = struct {
767 .{ .vbr = 6 }, // size in bits767 .{ .vbr = 6 }, // size in bits
768 .{ .vbr = 6 }, // align in bits768 .{ .vbr = 6 }, // align in bits
769 .{ .literal = 0 }, // offset in bits769 .{ .literal = 0 }, // offset in bits
770 .{ .literal = 0 }, // flags770 .{ .fixed = 32 }, // flags
771 MetadataAbbrev, // elements771 MetadataAbbrev, // elements
772 .{ .literal = 0 }, // runtime lang772 .{ .literal = 0 }, // runtime lang
773 .{ .literal = 0 }, // vtable holder773 .{ .literal = 0 }, // vtable holder
...@@ -789,6 +789,7 @@ pub const MetadataBlock = struct {...@@ -789,6 +789,7 @@ pub const MetadataBlock = struct {
789 underlying_type: Builder.Metadata,789 underlying_type: Builder.Metadata,
790 size_in_bits: u64,790 size_in_bits: u64,
791 align_in_bits: u64,791 align_in_bits: u64,
792 flags: u32,
792 elements: Builder.Metadata,793 elements: Builder.Metadata,
793 };794 };
794795