authorgravatar for liljaanton2001@gmail.comantlilja <liljaanton2001@gmail.com> 2023-08-26 18:34:14+02:00
committergravatar for liljaanton2001@gmail.comantlilja <liljaanton2001@gmail.com> 2024-02-21 16:24:59+01:00
log2801bf6400123b72ec1dcac7552a35c41bec365e
tree51350dca775211e3c214fb40c3b7f70b803a1764
parent9ccd7158b90ac773c0ab09bf5512f2d3d4ef87c2

LLVM Builder: Add strtab helper to String


1 files changed, 17 insertions(+), 0 deletions(-)

src/codegen/llvm/Builder.zig+17
......@@ -130,6 +130,11 @@ pub const String = enum(u32) {
130130 };
131131};
132132
133pub const StrtabString = struct {
134 offset: usize,
135 size: usize,
136};
137
133138pub const Type = enum(u32) {
134139 void,
135140 half,
......@@ -2159,6 +2164,18 @@ pub const Global = struct {
21592164 return builder.globals.keys()[@intFromEnum(self.unwrap(builder))];
21602165 }
21612166
2167 pub fn strtab(self: Index, builder: *const Builder) StrtabString {
2168 const name_index = self.name(builder).toIndex() orelse return .{
2169 .offset = 0,
2170 .size = 0,
2171 };
2172
2173 return .{
2174 .offset = builder.string_indices.items[name_index],
2175 .size = builder.string_indices.items[name_index + 1] - builder.string_indices.items[name_index] - 1,
2176 };
2177 }
2178
21622179 pub fn typeOf(self: Index, builder: *const Builder) Type {
21632180 return self.ptrConst(builder).type;
21642181 }