diff --git a/lib/std/Build/Configuration.zig b/lib/std/Build/Configuration.zig index f22a856cff..17716d06d1 100644 --- a/lib/std/Build/Configuration.zig +++ b/lib/std/Build/Configuration.zig @@ -2619,7 +2619,7 @@ pub const Storage = enum { multi_list, flag_list, - /// The presence of the field is determined by a boolean within a packed + /// The presence of the field is determined by a boolean within a bitpack /// struct. pub fn FlagOptional( comptime flags_arg: @EnumLiteral(), diff --git a/lib/std/Io/Reader.zig b/lib/std/Io/Reader.zig index 99eaf655f5..a492eed387 100644 --- a/lib/std/Io/Reader.zig +++ b/lib/std/Io/Reader.zig @@ -1934,7 +1934,7 @@ test "takeDelimiterInclusive on an indirect reader when it rebases" { } } -test "takeStruct and peekStruct packed" { +test "takeStruct and peekStruct bitpack" { var r: Reader = .fixed(&.{ 0b11110000, 0b00110011 }); const S = bitpack struct(u16) { a: u2, b: u6, c: u7, d: u1 }; diff --git a/lib/std/mem.zig b/lib/std/mem.zig index f13c02ca11..6043bdd68f 100644 --- a/lib/std/mem.zig +++ b/lib/std/mem.zig @@ -2303,7 +2303,7 @@ pub fn byteSwapAligned( ptr.* = @bitCast(@byteSwap(@as(Int, @bitCast(ptr.*)))); } else { if (@"struct".layout != .@"extern") { - @compileError("byteSwapAligned expects a packed or extern struct"); + @compileError("byteSwapAligned expects a bitpack or extern struct"); } inline for (@"struct".field_types, @"struct".field_names, @"struct".field_attrs) |f_type, f_name, f_attr| { switch (@typeInfo(f_type)) { @@ -2327,7 +2327,7 @@ pub fn byteSwapAligned( ptr.* = @bitCast(@byteSwap(@as(Int, @bitCast(ptr.*)))); } else { if (@"union".layout != .@"extern") { - @compileError("byteSwapAligned expects a packed or extern union"); + @compileError("byteSwapAligned expects a bitpack or extern union"); } const first_size = @bitSizeOf(@"union".field_types[0]); diff --git a/lib/std/testing.zig b/lib/std/testing.zig index bd6c74aba7..5cccc1eefc 100644 --- a/lib/std/testing.zig +++ b/lib/std/testing.zig @@ -153,7 +153,7 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void { ); }, .auto => { - const Tag = @"union".tag_type orelse @compileError("byteSwapAllFields expects packed, extern, or tagged union"); + const Tag = @"union".tag_type orelse @compileError("byteSwapAllFields expects bitpack, extern, or tagged union"); try expectEqual(@as(Tag, expected), @as(Tag, actual)); switch (expected) { diff --git a/src/Air/Legalize.zig b/src/Air/Legalize.zig index e5fd5281fd..86cf1b4dcc 100644 --- a/src/Air/Legalize.zig +++ b/src/Air/Legalize.zig @@ -197,7 +197,7 @@ pub const Feature = enum { /// Currently assumes little endian and a specific integer layout where the lsb of every integer is the lsb of the /// first byte of memory until bit pointers know their backing type. expand_packed_store, - /// Replace `agg_field_val` of a packed field with a `bit_cast` to integer, `shr`, `trunc`, and `bit_cast` to field type. + /// Replace `agg_field_val` of a bitpack field with a `bit_cast` to integer, `shr`, `trunc`, and `bit_cast` to field type. expand_packed_agg_field_val, /// Replace `aggregate_init` of a bitpack struct with a sequence of `shl_exact`, `bit_cast`, `int_cast`, and `bit_or`. expand_packed_aggregate_init, diff --git a/src/InternPool.zig b/src/InternPool.zig index d65f583cb2..dab1badbb5 100644 --- a/src/InternPool.zig +++ b/src/InternPool.zig @@ -3321,7 +3321,7 @@ pub const LoadedStructType = struct { /// Iterates over non-comptime fields in the order they are laid out in memory at runtime. /// May or may not include zero-bit fields. - /// Asserts the struct is not packed. + /// Asserts the struct is not bitpack. pub fn iterateRuntimeOrder(s: *const LoadedStructType, ip: *const InternPool) RuntimeOrderIterator { switch (s.layout) { .auto => { @@ -3705,8 +3705,8 @@ pub fn loadUnionType(ip: *const InternPool, index: Index) LoadedUnionType { const item = unwrapped_index.getItem(ip); // Exiting this `switch` means this is a `bitpack union`. const backing_mode: BackingTypeMode = switch (item.tag) { - .type_union_packed_auto => .auto, - .type_union_packed_explicit => .explicit, + .type_union_bitpack_auto => .auto, + .type_union_bitpack_explicit => .explicit, .type_union => { const extra = extraDataTrail(extra_list, Tag.TypeUnion, item.data); var extra_index = extra.end; @@ -4249,8 +4249,8 @@ pub const Index = enum(u32) { type_struct_bitpack_auto_defaults: struct { data: *Tag.TypeStructPacked }, type_struct_bitpack_explicit_defaults: struct { data: *Tag.TypeStructPacked }, type_union: struct { data: *Tag.TypeUnion }, - type_union_packed_auto: struct { data: *Tag.TypeUnionPacked }, - type_union_packed_explicit: struct { data: *Tag.TypeUnionPacked }, + type_union_bitpack_auto: struct { data: *Tag.TypeUnionPacked }, + type_union_bitpack_explicit: struct { data: *Tag.TypeUnionPacked }, type_enum_auto: struct { data: *Tag.TypeEnum }, type_enum_explicit: struct { data: *Tag.TypeEnum }, type_enum_nonexhaustive: struct { data: *Tag.TypeEnum }, @@ -4862,10 +4862,10 @@ pub const Tag = enum(u8) { type_union, /// `bitpack union { ... }`. /// data is extra index of `TypeUnionPacked`. - type_union_packed_auto, + type_union_bitpack_auto, /// `bitpack union(T) { ... }`. /// data is extra index of `TypeUnionPacked`. - type_union_packed_explicit, + type_union_bitpack_explicit, /// An exhaustive enum type *without* an explicit integer tag type. The tag type is inferred. /// @@ -5271,8 +5271,8 @@ pub const Tag = enum(u8) { .@"trailing.field_aligns.?.len" = .@"(payload.fields_len + 3) & ~@as(u32, 3)", }, }, - .type_union_packed_auto = union_packed_encoding, - .type_union_packed_explicit = union_packed_encoding, + .type_union_bitpack_auto = union_packed_encoding, + .type_union_bitpack_explicit = union_packed_encoding, .type_enum_auto = .{ .summary = .@"{.payload.fqn%summary#\"}", .payload = TypeEnum, @@ -5566,7 +5566,7 @@ pub const Tag = enum(u8) { pub const Flags = bitpack struct(u32) { any_captures: enum(u2) { true, false, reified }, - /// `packed` layout is represented separately by `TypeStructPacked`. + /// `bitpack` layout is represented separately by `TypeStructPacked`. layout: enum(u1) { auto, @"extern" }, any_comptime_fields: bool, @@ -5656,7 +5656,7 @@ pub const Tag = enum(u8) { /// considered to have an explicitly specified integer tag type. enum_tag_mode: BackingTypeMode, - /// `packed` layout is represented separately by `TypeStructPacked`. + /// `bitpack` layout is represented separately by `TypeStructPacked`. layout: enum(u1) { auto, @"extern" }, any_field_aligns: bool, @@ -5759,7 +5759,7 @@ pub const Tag = enum(u8) { }; }; -/// Differentiates between user-provided and compiler-generated backing types for packed and tagged types. +/// Differentiates between user-provided and compiler-generated backing types for bitpack and tagged types. pub const BackingTypeMode = enum(u1) { /// The backing type was explicitly provided by the user. For instance: /// union(T) @@ -6590,7 +6590,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key { } }, }; } }, - .type_union_packed_auto, .type_union_packed_explicit => .{ .union_type = ns: { + .type_union_bitpack_auto, .type_union_bitpack_explicit => .{ .union_type = ns: { const extra_list = unwrapped_index.getExtra(ip); const extra = extraDataTrail(extra_list, Tag.TypeUnionPacked, data); break :ns switch (extra.data.bits.captures_len) { @@ -8195,7 +8195,7 @@ pub fn getReifiedStructType(ip: *InternPool, gpa: Allocator, io: Io, tid: Zcu.Pe any_comptime_fields: bool, any_field_defaults: bool, any_field_aligns: bool, - /// Explicitly specified backing int type. `.none` if not packed or if backing type is inferred. + /// Explicitly specified backing int type. `.none` if not bit-packed or if backing type is inferred. bitpack_backing_int_type: Index, }) Allocator.Error!WipContainerType.Result { var gop = try ip.getOrPutKey(gpa, io, tid, .{ .struct_type = .{ .reified = .{ @@ -8416,8 +8416,8 @@ pub fn getDeclaredUnionType( extra.appendNTimesAssumeCapacity(.{@backingInt(Index.none)}, ini.fields_len); // field_type items.appendAssumeCapacity(.{ .tag = switch (ini.bitpack_backing_mode) { - .auto => .type_union_packed_auto, - .explicit => .type_union_packed_explicit, + .auto => .type_union_bitpack_auto, + .explicit => .type_union_bitpack_explicit, }, .data = extra_index, }); @@ -8501,7 +8501,7 @@ pub fn getReifiedUnionType(ip: *InternPool, gpa: Allocator, io: Io, tid: Zcu.Per tag_usage: LoadedUnionType.TagUsage, /// Explicitly specified enum tag type. `.none` if `tag_usage != .tagged`. enum_tag_type: Index, - /// Explicitly specified backing int type. `.none` if not packed or if backing type is inferred. + /// Explicitly specified backing int type. `.none` if not bit-packed or if backing type is inferred. bitpack_backing_int_type: Index, }) Allocator.Error!WipContainerType.Result { var gop = try ip.getOrPutKey(gpa, io, tid, .{ .union_type = .{ .reified = .{ @@ -8546,8 +8546,8 @@ pub fn getReifiedUnionType(ip: *InternPool, gpa: Allocator, io: Io, tid: Zcu.Per extra.appendNTimesAssumeCapacity(.{@backingInt(Index.none)}, ini.fields_len); // field_type items.appendAssumeCapacity(.{ .tag = switch (ini.bitpack_backing_int_type) { - .none => .type_union_packed_auto, - else => .type_union_packed_explicit, + .none => .type_union_bitpack_auto, + else => .type_union_bitpack_explicit, }, .data = extra_index, }); @@ -10840,7 +10840,7 @@ fn dumpStatsFallible(ip: *const InternPool, arena: Allocator, w: *Io.Writer) (Al } break :b n * @sizeOf(u32); }, - .type_union_packed_auto, .type_union_packed_explicit => b: { + .type_union_bitpack_auto, .type_union_bitpack_explicit => b: { var n: usize = @typeInfo(Tag.TypeUnionPacked).@"struct".field_names.len; const extra = extraDataTrail(extra_list, Tag.TypeUnionPacked, data); switch (extra.data.bits.captures_len) { @@ -11025,8 +11025,8 @@ fn dumpAllFallible(ip: *const InternPool, w: *Io.Writer) Io.Writer.Error!void { .type_struct_bitpack_auto_defaults, .type_struct_bitpack_explicit_defaults, .type_union, - .type_union_packed_auto, - .type_union_packed_explicit, + .type_union_bitpack_auto, + .type_union_bitpack_explicit, .type_enum_auto, .type_enum_explicit, .type_enum_nonexhaustive, @@ -11753,8 +11753,8 @@ pub fn typeOf(ip: *const InternPool, index: Index) Index { .type_struct_bitpack_auto_defaults, .type_struct_bitpack_explicit_defaults, .type_union, - .type_union_packed_auto, - .type_union_packed_explicit, + .type_union_bitpack_auto, + .type_union_bitpack_explicit, .type_enum_auto, .type_enum_explicit, .type_enum_nonexhaustive, @@ -12107,8 +12107,8 @@ pub fn zigTypeTag(ip: *const InternPool, index: Index) std.lang.TypeId { .type_struct_bitpack_explicit_defaults, => .@"struct", .type_union, - .type_union_packed_auto, - .type_union_packed_explicit, + .type_union_bitpack_auto, + .type_union_bitpack_explicit, => .@"union", .type_enum_auto, .type_enum_explicit, @@ -12824,8 +12824,8 @@ pub fn resolveBitpackUnionLayout( const extra_items = local.shared.extra.view().items(.@"0"); const item = unwrapped_index.getItem(ip); switch (item.tag) { - .type_union_packed_auto, - .type_union_packed_explicit, + .type_union_bitpack_auto, + .type_union_bitpack_explicit, => {}, else => unreachable, } @@ -12902,8 +12902,8 @@ pub fn setWantTypeLayout(ip: *InternPool, io: Io, container_type: Index) bool { } }, - .type_union_packed_auto, - .type_union_packed_explicit, + .type_union_bitpack_auto, + .type_union_bitpack_explicit, => { const bits: *Tag.TypeUnionPacked.Bits = @ptrCast(&extra_items[ item.data + std.meta.fieldIndex(Tag.TypeUnionPacked, "bits").? diff --git a/src/Sema.zig b/src/Sema.zig index 34a0e18efc..ec9e02ea0a 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -20597,7 +20597,7 @@ fn zirReifyUnion( std.hash.autoHash(&hasher, layout); std.hash.autoHash(&hasher, arg_ty_val); - const explicit_tag_ty: ?Type, const explicit_packed_backing_type: ?Type = ty: { + const explicit_tag_ty: ?Type, const explicit_bitpack_backing_type: ?Type = ty: { const arg_ty = arg_ty_val.optionalValue(zcu) orelse break :ty .{ null, null }; switch (layout) { .@"extern" => return sema.fail(block, arg_ty_src, "extern union does not support enum tag type", .{}), @@ -20644,7 +20644,7 @@ fn zirReifyUnion( break :tag .none; }, .enum_tag_type = if (explicit_tag_ty) |ty| ty.toIntern() else .none, - .bitpack_backing_int_type = if (explicit_packed_backing_type) |ty| ty.toIntern() else .none, + .bitpack_backing_int_type = if (explicit_bitpack_backing_type) |ty| ty.toIntern() else .none, })) { .existing => |ty| { try sema.addTypeReferenceEntry(src, .fromInterned(ty)); diff --git a/src/Sema/reinterpret.zig b/src/Sema/reinterpret.zig index 107f8c8bc8..36b2710f29 100644 --- a/src/Sema/reinterpret.zig +++ b/src/Sema/reinterpret.zig @@ -3,7 +3,7 @@ //! a sequence of values in *packed* memory, and then unflatten through a combination of special //! cases (particularly for pointers and `undefined` values) and in-memory buffer reinterprets. //! -//! This is a little awkward on big-endian targets, as non-packed datastructures (e.g. `extern struct`) +//! This is a little awkward on big-endian targets, as non-bitpack datastructures (e.g. `extern struct`) //! have their fields reversed when represented as packed memory on such targets. /// If `host_bits` is `0`, attempts to convert the memory at offset diff --git a/src/Type.zig b/src/Type.zig index c937f5094a..e55a6f50ba 100644 --- a/src/Type.zig +++ b/src/Type.zig @@ -3050,7 +3050,7 @@ pub const UnpackableReason = union(enum) { other, }; -/// Returns `null` iff `ty` is allowed in packed types. +/// Returns `null` iff `ty` is allowed in bitpack types. pub fn unpackable(ty: Type, zcu: *const Zcu) ?UnpackableReason { return switch (ty.zigTypeTag(zcu)) { .void, diff --git a/src/Value.zig b/src/Value.zig index 473fe7f02b..294ce2c98c 100644 --- a/src/Value.zig +++ b/src/Value.zig @@ -385,7 +385,7 @@ pub fn writeToMemory(val: Value, zcu: *const Zcu, buffer: []u8) error{ /// Write a Value's contents to `buffer`. /// /// Both the start and the end of the provided buffer must be tight, since -/// big-endian packed memory layouts start at the end of the buffer. +/// big-endian bitpack memory layouts start at the end of the buffer. /// /// Supports arrays and vectors, for which the value is written in logical bit /// order, i.e. with the first element at bit offset 0. @@ -516,7 +516,7 @@ pub fn readIntFromMemory( /// Load a Value from the contents of `buffer`. /// /// Both the start and the end of the provided buffer must be tight, since -/// big-endian packed memory layouts start at the end of the buffer. +/// big-endian bitpack memory layouts start at the end of the buffer. /// /// Supports arrays and vectors, for which the value is read in logical bit /// order, i.e. with the first element at bit offset 0. diff --git a/src/codegen/c.zig b/src/codegen/c.zig index 9eba73e714..a448fd1ec1 100644 --- a/src/codegen/c.zig +++ b/src/codegen/c.zig @@ -3285,7 +3285,7 @@ fn airAlloc(f: *Function, inst: Air.Inst.Index) !CValue { .@"struct", .@"union" => switch (elem_ty.containerLayout(zcu)) { .@"bitpack" => { // For packed aggregates, we zero-initialize to try and work around a design flaw - // related to how `packed`, `undefined`, and RLS interact. See comment in `airStore` + // related to how `bitpack`, `undefined`, and RLS interact. See comment in `airStore` // for details. const w = &f.code.writer; try w.print("memset(&t{d}, 0x00, sizeof(", .{local.new_local}); @@ -3318,8 +3318,8 @@ fn airRetPtr(f: *Function, inst: Air.Inst.Index) !CValue { switch (elem_ty.zigTypeTag(zcu)) { .@"struct", .@"union" => switch (elem_ty.containerLayout(zcu)) { .@"bitpack" => { - // For packed aggregates, we zero-initialize to try and work around a design flaw - // related to how `packed`, `undefined`, and RLS interact. See comment in `airStore` + // For bit-packed aggregates, we zero-initialize to try and work around a design flaw + // related to how `bitpack`, `undefined`, and RLS interact. See comment in `airStore` // for details. const w = &f.code.writer; try w.print("memset(&t{d}, 0x00, sizeof(", .{local.new_local}); diff --git a/src/codegen/sparc64/bits.zig b/src/codegen/sparc64/bits.zig index 2a4a47230b..d6fd9fc4ed 100644 --- a/src/codegen/sparc64/bits.zig +++ b/src/codegen/sparc64/bits.zig @@ -163,7 +163,7 @@ pub const Instruction = union(enum) { // name them with letters since there's no official naming scheme. // TODO: need to rename the minor formats to a more descriptive name. - // I am using regular structs instead of packed ones to avoid + // I am using regular structs instead of bitpack ones to avoid // endianness-dependent behavior when constructing the actual // assembly instructions. // See also: https://github.com/ziglang/zig/issues/10113 diff --git a/src/codegen/spirv/CodeGen.zig b/src/codegen/spirv/CodeGen.zig index 9bb05a6dff..90f833ea6d 100644 --- a/src/codegen/spirv/CodeGen.zig +++ b/src/codegen/spirv/CodeGen.zig @@ -7726,7 +7726,7 @@ fn airAggFieldVal(cg: *CodeGen, inst: Air.Inst.Index) !?Id { const struct_ty = zcu.typeToBitpackStruct(object_ty).?; const struct_backing_int_bits = cg.backingIntBits(@intCast(object_ty.bitSize(zcu))).@"0"; const bit_offset = zcu.structPackedFieldBitOffset(struct_ty, field_index); - // We use the same int type the packed struct is backed by, because even though it would + // We use the same int type the bitpack struct is backed by, because even though it would // be valid SPIR-V to use an smaller type like u16, some implementations like PoCL will complain. const bit_offset_id = try cg.constInt(object_ty, bit_offset); const signedness = if (field_ty.isInt(zcu)) field_ty.intInfo(zcu).signedness else .unsigned; diff --git a/src/codegen/wasm/CodeGen.zig b/src/codegen/wasm/CodeGen.zig index b865074d99..bf3687800f 100644 --- a/src/codegen/wasm/CodeGen.zig +++ b/src/codegen/wasm/CodeGen.zig @@ -2580,7 +2580,7 @@ const IntType = struct { const @"u64": IntType = .{ .is_signed = false, .bits = 64 }; // Adapted from x86_64 backend - // Differ from Type.intInfo as it treats pointers/booleans/packed/enums/errors as integer + // Differ from Type.intInfo as it treats pointers/booleans/bitpack/enums/errors as integer fn fromType(cg: *CodeGen, ty: Type) IntType { const zcu = cg.zcu; const ip = &zcu.intern_pool;