authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-02-23 21:12:45+01:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-02-23 21:12:57+01:00
loga8708dbf3bf0500e63d12a29239978e9596809ee
treec5294919bd0921ca0856436f71d0b782c92bdc52
parent2c67a1ecd2d6680631e13c8a7bc56915d633eb29

Builder: fix inconsequential llvm ir flag syntax


2 files changed, 21 insertions(+), 10 deletions(-)

src/codegen/llvm/Builder.zig+20-9
...@@ -7804,10 +7804,10 @@ pub const Metadata = enum(u32) {...@@ -7804,10 +7804,10 @@ pub const Metadata = enum(u32) {
7804 pub const Subprogram = struct {7804 pub const Subprogram = struct {
7805 pub const Options = struct {7805 pub const Options = struct {
7806 di_flags: DIFlags,7806 di_flags: DIFlags,
7807 sp_flags: SPFlags,7807 sp_flags: DISPFlags,
7808 };7808 };
78097809
7810 pub const SPFlags = packed struct(u32) {7810 pub const DISPFlags = packed struct(u32) {
7811 Virtuality: enum(u2) { Zero, Virtual, PureVirtual } = .Zero,7811 Virtuality: enum(u2) { Zero, Virtual, PureVirtual } = .Zero,
7812 LocalToUnit: bool = false,7812 LocalToUnit: bool = false,
7813 Definition: bool = false,7813 Definition: bool = false,
...@@ -7822,21 +7822,21 @@ pub const Metadata = enum(u32) {...@@ -7822,21 +7822,21 @@ pub const Metadata = enum(u32) {
7822 Unused: u20 = 0,7822 Unused: u20 = 0,
78237823
7824 pub fn format(7824 pub fn format(
7825 self: SPFlags,7825 self: DISPFlags,
7826 comptime _: []const u8,7826 comptime _: []const u8,
7827 _: std.fmt.FormatOptions,7827 _: std.fmt.FormatOptions,
7828 writer: anytype,7828 writer: anytype,
7829 ) @TypeOf(writer).Error!void {7829 ) @TypeOf(writer).Error!void {
7830 var need_pipe = false;7830 var need_pipe = false;
7831 inline for (@typeInfo(SPFlags).Struct.fields) |field| {7831 inline for (@typeInfo(DISPFlags).Struct.fields) |field| {
7832 switch (@typeInfo(field.type)) {7832 switch (@typeInfo(field.type)) {
7833 .Bool => if (@field(self, field.name)) {7833 .Bool => if (@field(self, field.name)) {
7834 if (need_pipe) try writer.writeAll(" | ") else need_pipe = true;7834 if (need_pipe) try writer.writeAll(" | ") else need_pipe = true;
7835 try writer.print("SPFlag{s}", .{field.name});7835 try writer.print("DISPFlag{s}", .{field.name});
7836 },7836 },
7837 .Enum => if (@field(self, field.name) != .Zero) {7837 .Enum => if (@field(self, field.name) != .Zero) {
7838 if (need_pipe) try writer.writeAll(" | ") else need_pipe = true;7838 if (need_pipe) try writer.writeAll(" | ") else need_pipe = true;
7839 try writer.print("SPFlag{s}", .{@tagName(@field(self, field.name))});7839 try writer.print("DISPFlag{s}", .{@tagName(@field(self, field.name))});
7840 },7840 },
7841 .Int => assert(@field(self, field.name) == 0),7841 .Int => assert(@field(self, field.name) == 0),
7842 else => @compileError("bad field type: " ++ field.name ++ ": " ++7842 else => @compileError("bad field type: " ++ field.name ++ ": " ++
...@@ -8023,6 +8023,8 @@ pub const Metadata = enum(u32) {...@@ -8023,6 +8023,8 @@ pub const Metadata = enum(u32) {
8023 bool: bool,8023 bool: bool,
8024 u32: u32,8024 u32: u32,
8025 u64: u64,8025 u64: u64,
8026 di_flags: DIFlags,
8027 sp_flags: Subprogram.DISPFlags,
8026 raw: []const u8,8028 raw: []const u8,
80278029
8028 const ValueData = struct {8030 const ValueData = struct {
...@@ -8094,7 +8096,12 @@ pub const Metadata = enum(u32) {...@@ -8094,7 +8096,12 @@ pub const Metadata = enum(u32) {
8094 .string => |node| try writer.print((if (is_specialized) "" else "!") ++ "{}", .{8096 .string => |node| try writer.print((if (is_specialized) "" else "!") ++ "{}", .{
8095 node.fmt(builder),8097 node.fmt(builder),
8096 }),8098 }),
8097 inline .bool, .u32, .u64 => |node| try writer.print("{}", .{node}),8099 inline .bool,
8100 .u32,
8101 .u64,
8102 .di_flags,
8103 .sp_flags,
8104 => |node| try writer.print("{}", .{node}),
8098 .raw => |node| try writer.writeAll(node),8105 .raw => |node| try writer.writeAll(node),
8099 }8106 }
8100 }8107 }
...@@ -8126,7 +8133,11 @@ pub const Metadata = enum(u32) {...@@ -8126,7 +8133,11 @@ pub const Metadata = enum(u32) {
8126 },8133 },
8127 .EnumLiteral => .{ .raw = @tagName(some) },8134 .EnumLiteral => .{ .raw = @tagName(some) },
8128 .Bool => .{ .bool = some },8135 .Bool => .{ .bool = some },
8129 .Struct => .{ .u32 = @bitCast(some) },8136 .Struct => switch (Some) {
8137 DIFlags => .{ .di_flags = some },
8138 Subprogram.DISPFlags => .{ .sp_flags = some },
8139 else => @compileError("unknown type to format: " ++ @typeName(Node)),
8140 },
8130 .Int, .ComptimeInt => .{ .u64 = some },8141 .Int, .ComptimeInt => .{ .u64 = some },
8131 .Pointer => .{ .raw = some },8142 .Pointer => .{ .raw = some },
8132 else => @compileError("unknown type to format: " ++ @typeName(Node)),8143 else => @compileError("unknown type to format: " ++ @typeName(Node)),
...@@ -9943,7 +9954,7 @@ pub fn printUnbuffered(...@@ -9943,7 +9954,7 @@ pub fn printUnbuffered(
9943 .virtualIndex = null,9954 .virtualIndex = null,
9944 .thisAdjustment = null,9955 .thisAdjustment = null,
9945 .flags = extra.di_flags,9956 .flags = extra.di_flags,
9946 .spFlags = @as(Metadata.Subprogram.SPFlags, @bitCast(@as(u32, @as(u3, @intCast(9957 .spFlags = @as(Metadata.Subprogram.DISPFlags, @bitCast(@as(u32, @as(u3, @intCast(
9947 @intFromEnum(kind) - @intFromEnum(Metadata.Tag.subprogram),9958 @intFromEnum(kind) - @intFromEnum(Metadata.Tag.subprogram),
9948 ))) << 2)),9959 ))) << 2)),
9949 .unit = extra.compile_unit,9960 .unit = extra.compile_unit,
src/codegen/llvm/ir.zig+1-1
...@@ -743,7 +743,7 @@ pub const MetadataBlock = struct {...@@ -743,7 +743,7 @@ pub const MetadataBlock = struct {
743 line: u32,743 line: u32,
744 ty: Builder.Metadata,744 ty: Builder.Metadata,
745 scope_line: u32,745 scope_line: u32,
746 sp_flags: Builder.Metadata.Subprogram.SPFlags,746 sp_flags: Builder.Metadata.Subprogram.DISPFlags,
747 flags: Builder.Metadata.DIFlags,747 flags: Builder.Metadata.DIFlags,
748 compile_unit: Builder.Metadata,748 compile_unit: Builder.Metadata,
749 };749 };