authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-02-23 07:51:23+01:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-02-23 07:51:38+01:00
log800495afab7260d0a32786dd1f26eb5807b1f007
tree1fcbc2eaf04e3b42a530d3ce0d686a5919195bba
parent6abb432598c2d9b4395cc4d86d7d69663b4a0ad0

Builder: fix minor llvm ir syntax errors


1 files changed, 16 insertions(+), 4 deletions(-)

src/codegen/llvm/Builder.zig+16-4
...@@ -1790,6 +1790,18 @@ pub const Linkage = enum(u4) {...@@ -1790,6 +1790,18 @@ pub const Linkage = enum(u4) {
1790 ) @TypeOf(writer).Error!void {1790 ) @TypeOf(writer).Error!void {
1791 if (self != .external) try writer.print(" {s}", .{@tagName(self)});1791 if (self != .external) try writer.print(" {s}", .{@tagName(self)});
1792 }1792 }
1793
1794 fn formatOptional(
1795 data: ?Linkage,
1796 comptime _: []const u8,
1797 _: std.fmt.FormatOptions,
1798 writer: anytype,
1799 ) @TypeOf(writer).Error!void {
1800 if (data) |linkage| try writer.print(" {s}", .{@tagName(linkage)});
1801 }
1802 pub fn fmtOptional(self: ?Linkage) std.fmt.Formatter(formatOptional) {
1803 return .{ .data = self };
1804 }
1793};1805};
17941806
1795pub const Preemption = enum {1807pub const Preemption = enum {
...@@ -8073,10 +8085,9 @@ pub const Metadata = enum(u32) {...@@ -8073,10 +8085,9 @@ pub const Metadata = enum(u32) {
8073 try format(.{8085 try format(.{
8074 .formatter = data.formatter,8086 .formatter = data.formatter,
8075 .node = @unionInit(FormatData.Node, @tagName(tag)["local_".len..], node),8087 .node = @unionInit(FormatData.Node, @tagName(tag)["local_".len..], node),
8076 }, "", fmt_opts, writer);8088 }, "%", fmt_opts, writer);
8077 },8089 },
8078 .string => |node| try writer.print("{s}{}", .{8090 .string => |node| try writer.print((if (is_specialized) "" else "!") ++ "{}", .{
8079 if (is_specialized) "" else "!",
8080 node.fmt(builder),8091 node.fmt(builder),
8081 }),8092 }),
8082 inline .bool, .u32, .u64 => |node| try writer.print("{}", .{node}),8093 inline .bool, .u32, .u64 => |node| try writer.print("{}", .{node}),
...@@ -9276,7 +9287,8 @@ pub fn printUnbuffered(...@@ -9276,7 +9287,8 @@ pub fn printUnbuffered(
9276 \\9287 \\
9277 , .{9288 , .{
9278 variable.global.fmt(self),9289 variable.global.fmt(self),
9279 global.linkage,9290 Linkage.fmtOptional(if (global.linkage == .external and
9291 variable.init != .no_init) null else global.linkage),
9280 global.preemption,9292 global.preemption,
9281 global.visibility,9293 global.visibility,
9282 global.dll_storage_class,9294 global.dll_storage_class,