authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-04-05 05:12:13+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-04-05 05:12:13+02:00
loge73257dec2d997e9d573419178695992790a9525
treeffebad814a53dfcad5facdc035f01f9956dd8982
parentad7a028228eabffd19b2d831bebe87c67723347c

lib/std: BitSet,EnumSet: replace initEmpty/initFull with decl literals (#31469)

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31469 Reviewed-by: Andrew Kelley <andrew@ziglang.org> Co-authored-by: nektro <hello@nektro.net> Co-committed-by: nektro <hello@nektro.net>

18 files changed, 76 insertions(+), 66 deletions(-)

lib/compiler/aro/backend/Ir/x86/Renderer.zig+3-3
...@@ -21,17 +21,17 @@ const RegisterManager = zig.RegisterManager(Renderer, Register, Ir.Ref, abi.allo...@@ -21,17 +21,17 @@ const RegisterManager = zig.RegisterManager(Renderer, Register, Ir.Ref, abi.allo
21const RegisterBitSet = RegisterManager.RegisterBitSet;21const RegisterBitSet = RegisterManager.RegisterBitSet;
22const RegisterClass = struct {22const RegisterClass = struct {
23 const gp: RegisterBitSet = blk: {23 const gp: RegisterBitSet = blk: {
24 var set = RegisterBitSet.initEmpty();24 var set = RegisterBitSet.empty;
25 for (abi.allocatable_regs, 0..) |reg, index| if (reg.class() == .general_purpose) set.set(index);25 for (abi.allocatable_regs, 0..) |reg, index| if (reg.class() == .general_purpose) set.set(index);
26 break :blk set;26 break :blk set;
27 };27 };
28 const x87: RegisterBitSet = blk: {28 const x87: RegisterBitSet = blk: {
29 var set = RegisterBitSet.initEmpty();29 var set = RegisterBitSet.empty;
30 for (abi.allocatable_regs, 0..) |reg, index| if (reg.class() == .x87) set.set(index);30 for (abi.allocatable_regs, 0..) |reg, index| if (reg.class() == .x87) set.set(index);
31 break :blk set;31 break :blk set;
32 };32 };
33 const sse: RegisterBitSet = blk: {33 const sse: RegisterBitSet = blk: {
34 var set = RegisterBitSet.initEmpty();34 var set = RegisterBitSet.empty;
35 for (abi.allocatable_regs, 0..) |reg, index| if (reg.class() == .sse) set.set(index);35 for (abi.allocatable_regs, 0..) |reg, index| if (reg.class() == .sse) set.set(index);
36 break :blk set;36 break :blk set;
37 };37 };
lib/compiler/resinator/compile.zig+2-2
...@@ -2746,7 +2746,7 @@ pub const Compiler = struct {...@@ -2746,7 +2746,7 @@ pub const Compiler = struct {
2746 // 1. Any permutation that does not have PRELOAD in it just uses the2746 // 1. Any permutation that does not have PRELOAD in it just uses the
2747 // default flags.2747 // default flags.
2748 const initial_flags = flags.*;2748 const initial_flags = flags.*;
2749 var flags_set = std.enums.EnumSet(rc.CommonResourceAttributes).initEmpty();2749 var flags_set = std.enums.EnumSet(rc.CommonResourceAttributes).empty;
2750 for (tokens) |token| {2750 for (tokens) |token| {
2751 const attribute = rc.CommonResourceAttributes.map.get(token.slice(source)).?;2751 const attribute = rc.CommonResourceAttributes.map.get(token.slice(source)).?;
2752 flags_set.insert(attribute);2752 flags_set.insert(attribute);
...@@ -2769,7 +2769,7 @@ pub const Compiler = struct {...@@ -2769,7 +2769,7 @@ pub const Compiler = struct {
2769 // 3. If none of DISCARDABLE, SHARED, or PURE is specified, then PRELOAD2769 // 3. If none of DISCARDABLE, SHARED, or PURE is specified, then PRELOAD
2770 // implies `flags &= ~SHARED` and LOADONCALL implies `flags |= SHARED`2770 // implies `flags &= ~SHARED` and LOADONCALL implies `flags |= SHARED`
2771 const shared_set = comptime blk: {2771 const shared_set = comptime blk: {
2772 var set = std.enums.EnumSet(rc.CommonResourceAttributes).initEmpty();2772 var set = std.enums.EnumSet(rc.CommonResourceAttributes).empty;
2773 set.insert(.discardable);2773 set.insert(.discardable);
2774 set.insert(.shared);2774 set.insert(.shared);
2775 set.insert(.pure);2775 set.insert(.pure);
lib/std/Io/Kqueue.zig+2-2
...@@ -186,7 +186,7 @@ pub fn init(k: *Kqueue, gpa: Allocator, options: InitOptions) !void {...@@ -186,7 +186,7 @@ pub fn init(k: *Kqueue, gpa: Allocator, options: InitOptions) !void {
186 .awaiter = null,186 .awaiter = null,
187 .queue_next = null,187 .queue_next = null,
188 .cancel_thread = null,188 .cancel_thread = null,
189 .awaiting_completions = .initEmpty(),189 .awaiting_completions = .empty,
190 };190 };
191 const main_thread = &k.threads.allocated[0];191 const main_thread = &k.threads.allocated[0];
192 Thread.self = main_thread;192 Thread.self = main_thread;
...@@ -713,7 +713,7 @@ fn concurrent(...@@ -713,7 +713,7 @@ fn concurrent(
713 .awaiter = null,713 .awaiter = null,
714 .queue_next = null,714 .queue_next = null,
715 .cancel_thread = null,715 .cancel_thread = null,
716 .awaiting_completions = .initEmpty(),716 .awaiting_completions = .empty,
717 };717 };
718 closure.* = .{718 closure.* = .{
719 .kqueue = k,719 .kqueue = k,
lib/std/bit_set.zig+22-6
...@@ -68,16 +68,24 @@ pub fn IntegerBitSet(comptime size: u16) type {...@@ -68,16 +68,24 @@ pub fn IntegerBitSet(comptime size: u16) type {
68 /// The bit mask, as a single integer68 /// The bit mask, as a single integer
69 mask: MaskInt,69 mask: MaskInt,
7070
71 /// Deprecated: use `.empty`.
71 /// Creates a bit set with no elements present.72 /// Creates a bit set with no elements present.
72 pub fn initEmpty() Self {73 pub fn initEmpty() Self {
73 return .{ .mask = 0 };74 return .{ .mask = 0 };
74 }75 }
7576
77 /// Deprecated: use `.full`.
76 /// Creates a bit set with all elements present.78 /// Creates a bit set with all elements present.
77 pub fn initFull() Self {79 pub fn initFull() Self {
78 return .{ .mask = ~@as(MaskInt, 0) };80 return .{ .mask = ~@as(MaskInt, 0) };
79 }81 }
8082
83 /// A bit set with no elements present.
84 pub const empty: Self = .{ .mask = 0 };
85
86 /// A bit set with all elements present.
87 pub const full: Self = .{ .mask = ~@as(MaskInt, 0) };
88
81 /// Returns the number of bits in this bit set89 /// Returns the number of bits in this bit set
82 pub inline fn capacity(self: Self) usize {90 pub inline fn capacity(self: Self) usize {
83 _ = self;91 _ = self;
...@@ -387,11 +395,13 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {...@@ -387,11 +395,13 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {
387 /// Padding bits at the end are undefined.395 /// Padding bits at the end are undefined.
388 masks: [num_masks]MaskInt,396 masks: [num_masks]MaskInt,
389397
398 /// Deprecated: use `.empty`.
390 /// Creates a bit set with no elements present.399 /// Creates a bit set with no elements present.
391 pub fn initEmpty() Self {400 pub fn initEmpty() Self {
392 return .{ .masks = [_]MaskInt{0} ** num_masks };401 return .{ .masks = [_]MaskInt{0} ** num_masks };
393 }402 }
394403
404 /// Deprecated: use `.full`.
395 /// Creates a bit set with all elements present.405 /// Creates a bit set with all elements present.
396 pub fn initFull() Self {406 pub fn initFull() Self {
397 if (num_masks == 0) {407 if (num_masks == 0) {
...@@ -401,6 +411,12 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {...@@ -401,6 +411,12 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {
401 }411 }
402 }412 }
403413
414 /// A bit set with no elements present.
415 pub const empty: Self = .{ .masks = @splat(0) };
416
417 /// A bit set with all elements present.
418 pub const full: Self = .{ .masks = if (num_masks == 0) .{} else ([_]MaskInt{~@as(MaskInt, 0)} ** (num_masks - 1) ++ [_]MaskInt{last_item_mask}) };
419
404 /// Returns the number of bits in this bit set420 /// Returns the number of bits in this bit set
405 pub inline fn capacity(self: Self) usize {421 pub inline fn capacity(self: Self) usize {
406 _ = self;422 _ = self;
...@@ -1633,17 +1649,17 @@ fn fillOdd(set: anytype, len: usize) void {...@@ -1633,17 +1649,17 @@ fn fillOdd(set: anytype, len: usize) void {
1633}1649}
16341650
1635fn testPureBitSet(comptime Set: type) !void {1651fn testPureBitSet(comptime Set: type) !void {
1636 const empty = Set.initEmpty();1652 const empty = Set.empty;
1637 const full = Set.initFull();1653 const full = Set.full;
16381654
1639 const even = even: {1655 const even = even: {
1640 var bit_set = Set.initEmpty();1656 var bit_set = Set.empty;
1641 fillEven(&bit_set, Set.bit_length);1657 fillEven(&bit_set, Set.bit_length);
1642 break :even bit_set;1658 break :even bit_set;
1643 };1659 };
16441660
1645 const odd = odd: {1661 const odd = odd: {
1646 var bit_set = Set.initEmpty();1662 var bit_set = Set.empty;
1647 fillOdd(&bit_set, Set.bit_length);1663 fillOdd(&bit_set, Set.bit_length);
1648 break :odd bit_set;1664 break :odd bit_set;
1649 };1665 };
...@@ -1686,8 +1702,8 @@ fn testPureBitSet(comptime Set: type) !void {...@@ -1686,8 +1702,8 @@ fn testPureBitSet(comptime Set: type) !void {
1686}1702}
16871703
1688fn testStaticBitSet(comptime Set: type) !void {1704fn testStaticBitSet(comptime Set: type) !void {
1689 var a = Set.initEmpty();1705 var a = Set.empty;
1690 var b = Set.initFull();1706 var b = Set.full;
1691 try testing.expectEqual(@as(usize, 0), a.count());1707 try testing.expectEqual(@as(usize, 0), a.count());
1692 try testing.expectEqual(@as(usize, Set.bit_length), b.count());1708 try testing.expectEqual(@as(usize, Set.bit_length), b.count());
16931709
lib/std/crypto/codecs/base64_hex_ct.zig+2-2
...@@ -93,7 +93,7 @@ pub const hex = struct {...@@ -93,7 +93,7 @@ pub const hex = struct {
93 /// The decoder will skip any characters that are in the ignore list.93 /// The decoder will skip any characters that are in the ignore list.
94 /// The ignore list must not contain any valid hexadecimal characters.94 /// The ignore list must not contain any valid hexadecimal characters.
95 pub fn decoderWithIgnore(ignore_chars: []const u8) error{InvalidCharacter}!DecoderWithIgnore {95 pub fn decoderWithIgnore(ignore_chars: []const u8) error{InvalidCharacter}!DecoderWithIgnore {
96 var ignored_chars = StaticBitSet(256).initEmpty();96 var ignored_chars = StaticBitSet(256).empty;
97 for (ignore_chars) |c| {97 for (ignore_chars) |c| {
98 switch (c) {98 switch (c) {
99 '0'...'9', 'a'...'f', 'A'...'F' => return error.InvalidCharacter,99 '0'...'9', 'a'...'f', 'A'...'F' => return error.InvalidCharacter,
...@@ -269,7 +269,7 @@ pub const base64 = struct {...@@ -269,7 +269,7 @@ pub const base64 = struct {
269269
270 /// Creates a new decoder that ignores certain characters.270 /// Creates a new decoder that ignores certain characters.
271 pub fn decoderWithIgnore(ignore_chars: []const u8) error{InvalidCharacter}!DecoderWithIgnore {271 pub fn decoderWithIgnore(ignore_chars: []const u8) error{InvalidCharacter}!DecoderWithIgnore {
272 var ignored_chars = StaticBitSet(256).initEmpty();272 var ignored_chars = StaticBitSet(256).empty;
273 for (ignore_chars) |c| {273 for (ignore_chars) |c| {
274 switch (c) {274 switch (c) {
275 'A'...'Z', 'a'...'z', '0'...'9' => return error.InvalidCharacter,275 'A'...'Z', 'a'...'z', '0'...'9' => return error.InvalidCharacter,
lib/std/enums.zig+19-25
...@@ -252,7 +252,7 @@ pub fn EnumSet(comptime E: type) type {...@@ -252,7 +252,7 @@ pub fn EnumSet(comptime E: type) type {
252 /// The maximum number of items in this set.252 /// The maximum number of items in this set.
253 pub const len = Indexer.count;253 pub const len = Indexer.count;
254254
255 bits: BitSet = BitSet.initEmpty(),255 bits: BitSet = .empty,
256256
257 /// Initializes the set using a struct of bools257 /// Initializes the set using a struct of bools
258 pub fn init(init_values: EnumFieldStruct(E, bool, false)) Self {258 pub fn init(init_values: EnumFieldStruct(E, bool, false)) Self {
...@@ -278,19 +278,15 @@ pub fn EnumSet(comptime E: type) type {...@@ -278,19 +278,15 @@ pub fn EnumSet(comptime E: type) type {
278 return result;278 return result;
279 }279 }
280280
281 /// Returns a set containing no keys.281 /// A set containing no keys.
282 pub fn initEmpty() Self {282 pub const empty: Self = .{ .bits = .empty };
283 return .{ .bits = BitSet.initEmpty() };
284 }
285283
286 /// Returns a set containing all possible keys.284 /// A set containing all possible keys.
287 pub fn initFull() Self {285 pub const full: Self = .{ .bits = .full };
288 return .{ .bits = BitSet.initFull() };
289 }
290286
291 /// Returns a set containing multiple keys.287 /// Returns a set containing multiple keys.
292 pub fn initMany(keys: []const Key) Self {288 pub fn initMany(keys: []const Key) Self {
293 var set = initEmpty();289 var set: Self = .empty;
294 for (keys) |key| set.insert(key);290 for (keys) |key| set.insert(key);
295 return set;291 return set;
296 }292 }
...@@ -440,7 +436,7 @@ pub fn EnumMap(comptime E: type, comptime V: type) type {...@@ -440,7 +436,7 @@ pub fn EnumMap(comptime E: type, comptime V: type) type {
440 const BitSet = std.StaticBitSet(Indexer.count);436 const BitSet = std.StaticBitSet(Indexer.count);
441437
442 /// Bits determining whether items are in the map438 /// Bits determining whether items are in the map
443 bits: BitSet = BitSet.initEmpty(),439 bits: BitSet = .empty,
444 /// Values of items in the map. If the associated440 /// Values of items in the map. If the associated
445 /// bit is zero, the value is undefined.441 /// bit is zero, the value is undefined.
446 values: [Indexer.count]Value = undefined,442 values: [Indexer.count]Value = undefined,
...@@ -475,7 +471,7 @@ pub fn EnumMap(comptime E: type, comptime V: type) type {...@@ -475,7 +471,7 @@ pub fn EnumMap(comptime E: type, comptime V: type) type {
475 /// Consider using EnumArray instead if the map will remain full.471 /// Consider using EnumArray instead if the map will remain full.
476 pub fn initFull(value: Value) Self {472 pub fn initFull(value: Value) Self {
477 var result: Self = .{473 var result: Self = .{
478 .bits = Self.BitSet.initFull(),474 .bits = .full,
479 .values = undefined,475 .values = undefined,
480 };476 };
481 @memset(&result.values, value);477 @memset(&result.values, value);
...@@ -493,7 +489,7 @@ pub fn EnumMap(comptime E: type, comptime V: type) type {...@@ -493,7 +489,7 @@ pub fn EnumMap(comptime E: type, comptime V: type) type {
493 pub fn initFullWithDefault(comptime default: ?Value, init_values: EnumFieldStruct(E, Value, default)) Self {489 pub fn initFullWithDefault(comptime default: ?Value, init_values: EnumFieldStruct(E, Value, default)) Self {
494 @setEvalBranchQuota(2 * @typeInfo(E).@"enum".fields.len);490 @setEvalBranchQuota(2 * @typeInfo(E).@"enum".fields.len);
495 var result: Self = .{491 var result: Self = .{
496 .bits = Self.BitSet.initFull(),492 .bits = .full,
497 .values = undefined,493 .values = undefined,
498 };494 };
499 inline for (0..Self.len) |i| {495 inline for (0..Self.len) |i| {
...@@ -687,16 +683,14 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {...@@ -687,16 +683,14 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {
687 return self;683 return self;
688 }684 }
689685
690 /// Initializes the multiset with a count of zero.686 /// A multiset with a count of zero.
691 pub fn initEmpty() Self {687 pub const empty: Self = .initWithCount(0);
692 return initWithCount(0);
693 }
694688
695 /// Initializes the multiset with all keys at the689 /// Initializes the multiset with all keys at the
696 /// same count.690 /// same count.
697 pub fn initWithCount(comptime c: CountSize) Self {691 pub fn initWithCount(comptime c: CountSize) Self {
698 return .{692 return .{
699 .counts = EnumArray(E, CountSize).initDefault(c, .{}),693 .counts = .initDefault(c, .{}),
700 };694 };
701 }695 }
702696
...@@ -855,7 +849,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {...@@ -855,7 +849,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {
855test EnumMultiset {849test EnumMultiset {
856 const Ball = enum { red, green, blue };850 const Ball = enum { red, green, blue };
857851
858 const empty = EnumMultiset(Ball).initEmpty();852 const empty = EnumMultiset(Ball).empty;
859 const r0_g1_b2 = EnumMultiset(Ball).init(.{853 const r0_g1_b2 = EnumMultiset(Ball).init(.{
860 .red = 0,854 .red = 0,
861 .green = 1,855 .green = 1,
...@@ -1162,8 +1156,8 @@ pub fn EnumArray(comptime E: type, comptime V: type) type {...@@ -1162,8 +1156,8 @@ pub fn EnumArray(comptime E: type, comptime V: type) type {
1162test "pure EnumSet fns" {1156test "pure EnumSet fns" {
1163 const Suit = enum { spades, hearts, clubs, diamonds };1157 const Suit = enum { spades, hearts, clubs, diamonds };
11641158
1165 const empty = EnumSet(Suit).initEmpty();1159 const empty = EnumSet(Suit).empty;
1166 const full = EnumSet(Suit).initFull();1160 const full = EnumSet(Suit).full;
1167 const black = EnumSet(Suit).initMany(&[_]Suit{ .spades, .clubs });1161 const black = EnumSet(Suit).initMany(&[_]Suit{ .spades, .clubs });
1168 const red = EnumSet(Suit).initMany(&[_]Suit{ .hearts, .diamonds });1162 const red = EnumSet(Suit).initMany(&[_]Suit{ .hearts, .diamonds });
11691163
...@@ -1224,8 +1218,8 @@ test "pure EnumSet fns" {...@@ -1224,8 +1218,8 @@ test "pure EnumSet fns" {
12241218
1225test "EnumSet empty" {1219test "EnumSet empty" {
1226 const E = enum {};1220 const E = enum {};
1227 const empty = EnumSet(E).initEmpty();1221 const empty = EnumSet(E).empty;
1228 const full = EnumSet(E).initFull();1222 const full = EnumSet(E).full;
12291223
1230 try std.testing.expect(empty.eql(full));1224 try std.testing.expect(empty.eql(full));
1231 try std.testing.expect(empty.complement().eql(full));1225 try std.testing.expect(empty.complement().eql(full));
...@@ -1236,13 +1230,13 @@ test "EnumSet empty" {...@@ -1236,13 +1230,13 @@ test "EnumSet empty" {
1236test "EnumSet const iterator" {1230test "EnumSet const iterator" {
1237 const Direction = enum { up, down, left, right };1231 const Direction = enum { up, down, left, right };
1238 const diag_move = init: {1232 const diag_move = init: {
1239 var move = EnumSet(Direction).initEmpty();1233 var move = EnumSet(Direction).empty;
1240 move.insert(.right);1234 move.insert(.right);
1241 move.insert(.up);1235 move.insert(.up);
1242 break :init move;1236 break :init move;
1243 };1237 };
12441238
1245 var result = EnumSet(Direction).initEmpty();1239 var result = EnumSet(Direction).empty;
1246 var it = diag_move.iterator();1240 var it = diag_move.iterator();
1247 while (it.next()) |dir| {1241 while (it.next()) |dir| {
1248 result.insert(dir);1242 result.insert(dir);
src/Air/Legalize.zig+3-3
...@@ -15,7 +15,7 @@ features: if (switch (dev.env) {...@@ -15,7 +15,7 @@ features: if (switch (dev.env) {
15 }15 }
16 /// `inline` to propagate comptime-known result.16 /// `inline` to propagate comptime-known result.
17 inline fn hasAny(_: @This(), comptime features: []const Feature) bool {17 inline fn hasAny(_: @This(), comptime features: []const Feature) bool {
18 return comptime !bootstrap_features.intersectWith(.initMany(features)).eql(.initEmpty());18 return comptime !bootstrap_features.intersectWith(.initMany(features)).eql(.empty);
19 }19 }
20} else struct {20} else struct {
21 features: *const Features,21 features: *const Features,
...@@ -28,7 +28,7 @@ features: if (switch (dev.env) {...@@ -28,7 +28,7 @@ features: if (switch (dev.env) {
28 return rt.features.contains(feature);28 return rt.features.contains(feature);
29 }29 }
30 fn hasAny(rt: @This(), comptime features: []const Feature) bool {30 fn hasAny(rt: @This(), comptime features: []const Feature) bool {
31 return !rt.features.intersectWith(comptime .initMany(features)).eql(comptime .initEmpty());31 return !rt.features.intersectWith(comptime .initMany(features)).eql(.empty);
32 }32 }
33},33},
3434
...@@ -276,7 +276,7 @@ pub const Features = std.enums.EnumSet(Feature);...@@ -276,7 +276,7 @@ pub const Features = std.enums.EnumSet(Feature);
276pub const Error = std.mem.Allocator.Error;276pub const Error = std.mem.Allocator.Error;
277277
278pub fn legalize(air: *Air, pt: Zcu.PerThread, features: *const Features) Error!void {278pub fn legalize(air: *Air, pt: Zcu.PerThread, features: *const Features) Error!void {
279 assert(!features.eql(comptime .initEmpty())); // backend asked to run legalize, but no features were enabled279 assert(!features.eql(.empty)); // backend asked to run legalize, but no features were enabled
280 var l: Legalize = .{280 var l: Legalize = .{
281 .pt = pt,281 .pt = pt,
282 .air_instructions = air.instructions.toMultiArrayList(),282 .air_instructions = air.instructions.toMultiArrayList(),
src/codegen/aarch64.zig+1-1
...@@ -46,7 +46,7 @@ pub fn generate(...@@ -46,7 +46,7 @@ pub fn generate(
46 .dom_len = 0,46 .dom_len = 0,
47 .dom = .empty,47 .dom = .empty,
4848
49 .saved_registers = comptime .initEmpty(),49 .saved_registers = .empty,
50 .instructions = .empty,50 .instructions = .empty,
51 .literals = .empty,51 .literals = .empty,
52 .nav_relocs = .empty,52 .nav_relocs = .empty,
src/codegen/aarch64/Assemble.zig+1-1
...@@ -129,7 +129,7 @@ const matchers = matchers: {...@@ -129,7 +129,7 @@ const matchers = matchers: {
129 break :Symbols @Struct(.auto, null, &field_names, &field_types, &@splat(.{}));129 break :Symbols @Struct(.auto, null, &field_names, &field_types, &@splat(.{}));
130 } = undefined;130 } = undefined;
131 const Symbol = std.meta.FieldEnum(@TypeOf(instruction.symbols));131 const Symbol = std.meta.FieldEnum(@TypeOf(instruction.symbols));
132 comptime var unused_symbols: std.enums.EnumSet(Symbol) = .initFull();132 comptime var unused_symbols: std.enums.EnumSet(Symbol) = .full;
133 comptime var pattern_as: Assemble = .{ .source = instruction.pattern, .operands = undefined };133 comptime var pattern_as: Assemble = .{ .source = instruction.pattern, .operands = undefined };
134 inline while (true) {134 inline while (true) {
135 comptime var ct_token_buf: [token_buf_len]u8 = undefined;135 comptime var ct_token_buf: [token_buf_len]u8 = undefined;
src/codegen/riscv64/CodeGen.zig+1-1
...@@ -1386,7 +1386,7 @@ fn genBody(func: *Func, body: []const Air.Inst.Index) InnerError!void {...@@ -1386,7 +1386,7 @@ fn genBody(func: *Func, body: []const Air.Inst.Index) InnerError!void {
1386 const old_air_bookkeeping = func.air_bookkeeping;1386 const old_air_bookkeeping = func.air_bookkeeping;
1387 try func.ensureProcessDeathCapacity(Air.Liveness.bpi);1387 try func.ensureProcessDeathCapacity(Air.Liveness.bpi);
13881388
1389 func.reused_operands = @TypeOf(func.reused_operands).initEmpty();1389 func.reused_operands = @TypeOf(func.reused_operands).empty;
1390 try func.inst_tracking.ensureUnusedCapacity(func.gpa, 1);1390 try func.inst_tracking.ensureUnusedCapacity(func.gpa, 1);
1391 const tag = air_tags[@intFromEnum(inst)];1391 const tag = air_tags[@intFromEnum(inst)];
1392 switch (tag) {1392 switch (tag) {
src/codegen/riscv64/Mir.zig+1-1
...@@ -189,7 +189,7 @@ pub const LoadSymbolPayload = struct {...@@ -189,7 +189,7 @@ pub const LoadSymbolPayload = struct {
189189
190/// Used in conjunction with payload to transfer a list of used registers in a compact manner.190/// Used in conjunction with payload to transfer a list of used registers in a compact manner.
191pub const RegisterList = struct {191pub const RegisterList = struct {
192 bitset: BitSet = BitSet.initEmpty(),192 bitset: BitSet = .empty,
193193
194 const BitSet = IntegerBitSet(32);194 const BitSet = IntegerBitSet(32);
195 const Self = @This();195 const Self = @This();
src/codegen/riscv64/abi.zig+1-1
...@@ -344,7 +344,7 @@ pub const Registers = struct {...@@ -344,7 +344,7 @@ pub const Registers = struct {
344};344};
345345
346fn initRegBitSet(start: usize, length: usize) RegisterBitSet {346fn initRegBitSet(start: usize, length: usize) RegisterBitSet {
347 var set = RegisterBitSet.initEmpty();347 var set = RegisterBitSet.empty;
348 set.setRangeValue(.{348 set.setRangeValue(.{
349 .start = start,349 .start = start,
350 .end = start + length,350 .end = start + length,
src/codegen/sparc64/CodeGen.zig+1-1
...@@ -476,7 +476,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {...@@ -476,7 +476,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
476 const old_air_bookkeeping = self.air_bookkeeping;476 const old_air_bookkeeping = self.air_bookkeeping;
477 try self.ensureProcessDeathCapacity(Air.Liveness.bpi);477 try self.ensureProcessDeathCapacity(Air.Liveness.bpi);
478478
479 self.reused_operands = @TypeOf(self.reused_operands).initEmpty();479 self.reused_operands = @TypeOf(self.reused_operands).empty;
480 switch (air_tags[@intFromEnum(inst)]) {480 switch (air_tags[@intFromEnum(inst)]) {
481 // zig fmt: off481 // zig fmt: off
482482
src/codegen/sparc64/abi.zig+1-1
...@@ -49,7 +49,7 @@ pub const RegisterManager = RegisterManagerFn(@import("CodeGen.zig"), Register,...@@ -49,7 +49,7 @@ pub const RegisterManager = RegisterManagerFn(@import("CodeGen.zig"), Register,
49const RegisterBitSet = RegisterManager.RegisterBitSet;49const RegisterBitSet = RegisterManager.RegisterBitSet;
50pub const RegisterClass = struct {50pub const RegisterClass = struct {
51 pub const gp: RegisterBitSet = blk: {51 pub const gp: RegisterBitSet = blk: {
52 var set = RegisterBitSet.initEmpty();52 var set = RegisterBitSet.empty;
53 set.setRangeValue(.{53 set.setRangeValue(.{
54 .start = 0,54 .start = 0,
55 .end = allocatable_regs.len,55 .end = allocatable_regs.len,
src/codegen/x86_64/CodeGen.zig+4-4
...@@ -2298,7 +2298,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {...@@ -2298,7 +2298,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
2298 wip_mir_log.debug("{f}", .{cg.fmtAir(inst)});2298 wip_mir_log.debug("{f}", .{cg.fmtAir(inst)});
2299 verbose_tracking_log.debug("{f}", .{cg.fmtTracking()});2299 verbose_tracking_log.debug("{f}", .{cg.fmtTracking()});
23002300
2301 cg.reused_operands = .initEmpty();2301 cg.reused_operands = .empty;
2302 try cg.inst_tracking.ensureUnusedCapacity(cg.gpa, 1);2302 try cg.inst_tracking.ensureUnusedCapacity(cg.gpa, 1);
2303 switch (air_tags[@intFromEnum(inst)]) {2303 switch (air_tags[@intFromEnum(inst)]) {
2304 .select => try cg.airSelect(inst),2304 .select => try cg.airSelect(inst),
...@@ -177417,7 +177417,7 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {...@@ -177417,7 +177417,7 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {
177417 used: bool,177417 used: bool,
177418 fn init(size: ?Memory.Size) @This() {177418 fn init(size: ?Memory.Size) @This() {
177419 return .{177419 return .{
177420 .op_has_size = if (size) |_| .initFull() else .initEmpty(),177420 .op_has_size = if (size) |_| .full else .empty,
177421 .size = size orelse .none,177421 .size = size orelse .none,
177422 .used = false,177422 .used = false,
177423 };177423 };
...@@ -178351,9 +178351,9 @@ fn genCopy(self: *CodeGen, ty: Type, dst_mcv: MCValue, src_mcv: MCValue, opts: C...@@ -178351,9 +178351,9 @@ fn genCopy(self: *CodeGen, ty: Type, dst_mcv: MCValue, src_mcv: MCValue, opts: C
178351 else => unreachable,178351 else => unreachable,
178352 },178352 },
178353 dst_tag => |src_regs| {178353 dst_tag => |src_regs| {
178354 var remaining: std.StaticBitSet(dst_regs.len) = .initFull();178354 var remaining: std.StaticBitSet(dst_regs.len) = .full;
178355 var hazard_regs = src_regs;178355 var hazard_regs = src_regs;
178356 while (!remaining.eql(.initEmpty())) {178356 while (!remaining.eql(.empty)) {
178357 var remaining_it = remaining.iterator(.{});178357 var remaining_it = remaining.iterator(.{});
178358 next: while (remaining_it.next()) |index| {178358 next: while (remaining_it.next()) |index| {
178359 const dst_reg = dst_regs[index];178359 const dst_reg = dst_regs[index];
src/codegen/x86_64/Mir.zig+1-1
...@@ -1780,7 +1780,7 @@ pub const RegisterList = struct {...@@ -1780,7 +1780,7 @@ pub const RegisterList = struct {
1780 const BitSet = std.bit_set.IntegerBitSet(32);1780 const BitSet = std.bit_set.IntegerBitSet(32);
1781 const Self = @This();1781 const Self = @This();
17821782
1783 pub const empty: RegisterList = .{ .bitset = .initEmpty() };1783 pub const empty: RegisterList = .{ .bitset = .empty };
17841784
1785 fn getIndexForReg(registers: []const Register, reg: Register) BitSet.MaskInt {1785 fn getIndexForReg(registers: []const Register, reg: Register) BitSet.MaskInt {
1786 for (registers, 0..) |cpreg, i| {1786 for (registers, 0..) |cpreg, i| {
src/codegen/x86_64/abi.zig+4-4
...@@ -575,22 +575,22 @@ pub const RegisterManager = RegisterManagerFn(@import("CodeGen.zig"), Register,...@@ -575,22 +575,22 @@ pub const RegisterManager = RegisterManagerFn(@import("CodeGen.zig"), Register,
575const RegisterBitSet = RegisterManager.RegisterBitSet;575const RegisterBitSet = RegisterManager.RegisterBitSet;
576pub const RegisterClass = struct {576pub const RegisterClass = struct {
577 pub const gp: RegisterBitSet = blk: {577 pub const gp: RegisterBitSet = blk: {
578 var set = RegisterBitSet.initEmpty();578 var set = RegisterBitSet.empty;
579 for (allocatable_regs, 0..) |reg, index| if (reg.isClass(.general_purpose)) set.set(index);579 for (allocatable_regs, 0..) |reg, index| if (reg.isClass(.general_purpose)) set.set(index);
580 break :blk set;580 break :blk set;
581 };581 };
582 pub const gphi: RegisterBitSet = blk: {582 pub const gphi: RegisterBitSet = blk: {
583 var set = RegisterBitSet.initEmpty();583 var set = RegisterBitSet.empty;
584 for (allocatable_regs, 0..) |reg, index| if (reg.isClass(.gphi)) set.set(index);584 for (allocatable_regs, 0..) |reg, index| if (reg.isClass(.gphi)) set.set(index);
585 break :blk set;585 break :blk set;
586 };586 };
587 pub const x87: RegisterBitSet = blk: {587 pub const x87: RegisterBitSet = blk: {
588 var set = RegisterBitSet.initEmpty();588 var set = RegisterBitSet.empty;
589 for (allocatable_regs, 0..) |reg, index| if (reg.isClass(.x87)) set.set(index);589 for (allocatable_regs, 0..) |reg, index| if (reg.isClass(.x87)) set.set(index);
590 break :blk set;590 break :blk set;
591 };591 };
592 pub const sse: RegisterBitSet = blk: {592 pub const sse: RegisterBitSet = blk: {
593 var set = RegisterBitSet.initEmpty();593 var set = RegisterBitSet.empty;
594 for (allocatable_regs, 0..) |reg, index| if (reg.isClass(.sse)) set.set(index);594 for (allocatable_regs, 0..) |reg, index| if (reg.isClass(.sse)) set.set(index);
595 break :blk set;595 break :blk set;
596 };596 };
src/register_manager.zig+7-7
...@@ -34,12 +34,12 @@ pub fn RegisterManager(...@@ -34,12 +34,12 @@ pub fn RegisterManager(
34 registers: TrackedRegisters = undefined,34 registers: TrackedRegisters = undefined,
35 /// Tracks which registers are free (in which case the35 /// Tracks which registers are free (in which case the
36 /// corresponding bit is set to 1)36 /// corresponding bit is set to 1)
37 free_registers: RegisterBitSet = .initFull(),37 free_registers: RegisterBitSet = .full,
38 /// Tracks all registers allocated in the course of this38 /// Tracks all registers allocated in the course of this
39 /// function39 /// function
40 allocated_registers: RegisterBitSet = .initEmpty(),40 allocated_registers: RegisterBitSet = .empty,
41 /// Tracks registers which are locked from being allocated41 /// Tracks registers which are locked from being allocated
42 locked_registers: RegisterBitSet = .initEmpty(),42 locked_registers: RegisterBitSet = .empty,
4343
44 const Self = @This();44 const Self = @This();
4545
...@@ -393,7 +393,7 @@ const MockRegister1 = enum(u2) {...@@ -393,7 +393,7 @@ const MockRegister1 = enum(u2) {
393 );393 );
394394
395 const gp = blk: {395 const gp = blk: {
396 var set: RM.RegisterBitSet = .initEmpty();396 var set: RM.RegisterBitSet = .empty;
397 set.setRangeValue(.{397 set.setRangeValue(.{
398 .start = 0,398 .start = 0,
399 .end = allocatable_registers.len,399 .end = allocatable_registers.len,
...@@ -421,7 +421,7 @@ const MockRegister2 = enum(u2) {...@@ -421,7 +421,7 @@ const MockRegister2 = enum(u2) {
421 );421 );
422422
423 const gp = blk: {423 const gp = blk: {
424 var set: RM.RegisterBitSet = .initEmpty();424 var set: RM.RegisterBitSet = .empty;
425 set.setRangeValue(.{425 set.setRangeValue(.{
426 .start = 0,426 .start = 0,
427 .end = allocatable_registers.len,427 .end = allocatable_registers.len,
...@@ -462,7 +462,7 @@ const MockRegister3 = enum(u3) {...@@ -462,7 +462,7 @@ const MockRegister3 = enum(u3) {
462 );462 );
463463
464 const gp = blk: {464 const gp = blk: {
465 var set: RM.RegisterBitSet = .initEmpty();465 var set: RM.RegisterBitSet = .empty;
466 set.setRangeValue(.{466 set.setRangeValue(.{
467 .start = 0,467 .start = 0,
468 .end = gp_regs.len,468 .end = gp_regs.len,
...@@ -470,7 +470,7 @@ const MockRegister3 = enum(u3) {...@@ -470,7 +470,7 @@ const MockRegister3 = enum(u3) {
470 break :blk set;470 break :blk set;
471 };471 };
472 const ext = blk: {472 const ext = blk: {
473 var set: RM.RegisterBitSet = .initEmpty();473 var set: RM.RegisterBitSet = .empty;
474 set.setRangeValue(.{474 set.setRangeValue(.{
475 .start = gp_regs.len,475 .start = gp_regs.len,
476 .end = allocatable_registers.len,476 .end = allocatable_registers.len,