diff options
| author | antlilja <liljaanton2001@gmail.com> | 2023-08-26 18:34:14 +0200 |
|---|---|---|
| committer | antlilja <liljaanton2001@gmail.com> | 2024-02-21 16:24:59 +0100 |
| commit | 2801bf6400123b72ec1dcac7552a35c41bec365e (patch) | |
| tree | 51350dca775211e3c214fb40c3b7f70b803a1764 /src/codegen/llvm | |
| parent | 9ccd7158b90ac773c0ab09bf5512f2d3d4ef87c2 (diff) | |
| download | zig-2801bf6400123b72ec1dcac7552a35c41bec365e.tar.gz zig-2801bf6400123b72ec1dcac7552a35c41bec365e.zip | |
LLVM Builder: Add strtab helper to String
Diffstat (limited to 'src/codegen/llvm')
| -rw-r--r-- | src/codegen/llvm/Builder.zig | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/codegen/llvm/Builder.zig b/src/codegen/llvm/Builder.zig index 20cc8dc5a2..2d9fe2c634 100644 --- a/src/codegen/llvm/Builder.zig +++ b/src/codegen/llvm/Builder.zig @@ -130,6 +130,11 @@ pub const String = enum(u32) { }; }; +pub const StrtabString = struct { + offset: usize, + size: usize, +}; + pub const Type = enum(u32) { void, half, @@ -2159,6 +2164,18 @@ pub const Global = struct { return builder.globals.keys()[@intFromEnum(self.unwrap(builder))]; } + pub fn strtab(self: Index, builder: *const Builder) StrtabString { + const name_index = self.name(builder).toIndex() orelse return .{ + .offset = 0, + .size = 0, + }; + + return .{ + .offset = builder.string_indices.items[name_index], + .size = builder.string_indices.items[name_index + 1] - builder.string_indices.items[name_index] - 1, + }; + } + pub fn typeOf(self: Index, builder: *const Builder) Type { return self.ptrConst(builder).type; } |
