Skip to content

Commit 2739a15

Browse files
committed
Builder: fix inconsequential llvm ir flag syntax
1 parent a903943 commit 2739a15

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

src/codegen/llvm/Builder.zig

+20-9
Original file line numberDiff line numberDiff line change
@@ -7804,10 +7804,10 @@ pub const Metadata = enum(u32) {
78047804
pub const Subprogram = struct {
78057805
pub const Options = struct {
78067806
di_flags: DIFlags,
7807-
sp_flags: SPFlags,
7807+
sp_flags: DISPFlags,
78087808
};
78097809

7810-
pub const SPFlags = packed struct(u32) {
7810+
pub const DISPFlags = packed struct(u32) {
78117811
Virtuality: enum(u2) { Zero, Virtual, PureVirtual } = .Zero,
78127812
LocalToUnit: bool = false,
78137813
Definition: bool = false,
@@ -7822,21 +7822,21 @@ pub const Metadata = enum(u32) {
78227822
Unused: u20 = 0,
78237823

78247824
pub fn format(
7825-
self: SPFlags,
7825+
self: DISPFlags,
78267826
comptime _: []const u8,
78277827
_: std.fmt.FormatOptions,
78287828
writer: anytype,
78297829
) @TypeOf(writer).Error!void {
78307830
var need_pipe = false;
7831-
inline for (@typeInfo(SPFlags).Struct.fields) |field| {
7831+
inline for (@typeInfo(DISPFlags).Struct.fields) |field| {
78327832
switch (@typeInfo(field.type)) {
78337833
.Bool => if (@field(self, field.name)) {
78347834
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});
78367836
},
78377837
.Enum => if (@field(self, field.name) != .Zero) {
78387838
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))});
78407840
},
78417841
.Int => assert(@field(self, field.name) == 0),
78427842
else => @compileError("bad field type: " ++ field.name ++ ": " ++
@@ -8023,6 +8023,8 @@ pub const Metadata = enum(u32) {
80238023
bool: bool,
80248024
u32: u32,
80258025
u64: u64,
8026+
di_flags: DIFlags,
8027+
sp_flags: Subprogram.DISPFlags,
80268028
raw: []const u8,
80278029

80288030
const ValueData = struct {
@@ -8094,7 +8096,12 @@ pub const Metadata = enum(u32) {
80948096
.string => |node| try writer.print((if (is_specialized) "" else "!") ++ "{}", .{
80958097
node.fmt(builder),
80968098
}),
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}),
80988105
.raw => |node| try writer.writeAll(node),
80998106
}
81008107
}
@@ -8126,7 +8133,11 @@ pub const Metadata = enum(u32) {
81268133
},
81278134
.EnumLiteral => .{ .raw = @tagName(some) },
81288135
.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+
},
81308141
.Int, .ComptimeInt => .{ .u64 = some },
81318142
.Pointer => .{ .raw = some },
81328143
else => @compileError("unknown type to format: " ++ @typeName(Node)),
@@ -9943,7 +9954,7 @@ pub fn printUnbuffered(
99439954
.virtualIndex = null,
99449955
.thisAdjustment = null,
99459956
.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(
99479958
@intFromEnum(kind) - @intFromEnum(Metadata.Tag.subprogram),
99489959
))) << 2)),
99499960
.unit = extra.compile_unit,

src/codegen/llvm/ir.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ pub const MetadataBlock = struct {
743743
line: u32,
744744
ty: Builder.Metadata,
745745
scope_line: u32,
746-
sp_flags: Builder.Metadata.Subprogram.SPFlags,
746+
sp_flags: Builder.Metadata.Subprogram.DISPFlags,
747747
flags: Builder.Metadata.DIFlags,
748748
compile_unit: Builder.Metadata,
749749
};

0 commit comments

Comments
 (0)