zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit b23a9579151b38e2b3539b9e4e8bbcd858cad2cb (tree)
parent efd6ded716a027f7d47fe5c38df17785c8e2a2e2
Author: David Senoner <seda18@rolmail.net>
Date:   Thu, 11 Jun 2026 09:12:33 +0200

rename `struct_field_val` -> `agg_field_val`

Also rename corresponding `airStructFieldVal` functions ->
`airAggFieldVal`

Diffstat:
Msrc/Air.zig | 7+++----
Msrc/Air/Legalize.zig | 22+++++++++++-----------
Msrc/Air/Liveness.zig | 2+-
Msrc/Air/Liveness/Verify.zig | 2+-
Msrc/Air/Verify.zig | 2+-
Msrc/Air/print.zig | 2+-
Msrc/Sema.zig | 2+-
Msrc/codegen/aarch64/Select.zig | 4++--
Msrc/codegen/c.zig | 8++++----
Msrc/codegen/llvm/FuncGen.zig | 4++--
Msrc/codegen/riscv64/CodeGen.zig | 6+++---
Msrc/codegen/sparc64/CodeGen.zig | 6+++---
Msrc/codegen/spirv/CodeGen.zig | 4++--
Msrc/codegen/wasm/CodeGen.zig | 8++++----
Msrc/codegen/x86_64/CodeGen.zig | 4++--
15 files changed, 41 insertions(+), 42 deletions(-)

diff --git a/src/Air.zig b/src/Air.zig @@ -688,8 +688,7 @@ pub const Inst = struct { struct_field_ptr_index_3, /// Given a byval struct or union and a field index, returns the field byval. /// Uses the `ty_pl` field, payload is `StructField`. - /// TODO rename to `agg_field_val` - struct_field_val, + agg_field_val, /// Given a pointer to a tagged union, set its tag to the provided value. /// Result type is always void. /// Uses the `bin_op` field. LHS is union pointer, RHS is new tag value. @@ -1684,7 +1683,7 @@ pub fn typeOfIndex(air: *const Air, inst: Air.Inst.Index, ip: *const InternPool) .block, .dbg_inline_block, .struct_field_ptr, - .struct_field_val, + .agg_field_val, .slice_elem_ptr, .ptr_elem_ptr, .cmpxchg_weak, @@ -2079,7 +2078,7 @@ pub fn mustLower(air: Air, inst: Air.Inst.Index, ip: *const InternPool) bool { .struct_field_ptr_index_1, .struct_field_ptr_index_2, .struct_field_ptr_index_3, - .struct_field_val, + .agg_field_val, .get_union_tag, .slice, .slice_len, diff --git a/src/Air/Legalize.zig b/src/Air/Legalize.zig @@ -181,8 +181,8 @@ 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 `struct_field_val` of a packed field with a `bit_cast` to integer, `shr`, `trunc`, and `bit_cast` to field type. - expand_packed_struct_field_val, + /// Replace `agg_field_val` of a packed 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 packed struct with a sequence of `shl_exact`, `bit_cast`, `int_cast`, and `bit_or`. expand_packed_aggregate_init, @@ -781,7 +781,7 @@ fn legalizeBody(l: *Legalize, body_start: usize, body_len: usize) Error!void { .struct_field_ptr_index_2, .struct_field_ptr_index_3, => {}, - .struct_field_val => if (l.features.has(.expand_packed_struct_field_val)) { + .agg_field_val => if (l.features.has(.expand_packed_agg_field_val)) { const ty_pl = l.air_instructions.items(.data)[@intFromEnum(inst)].ty_pl; const extra = l.extraData(Air.StructField, ty_pl.payload).data; switch (l.typeOf(extra.struct_operand).containerLayout(zcu)) { @@ -1808,8 +1808,8 @@ fn scalarizeOverflowBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Error! // %9 = legalize_vec_elem_val(orig_lhs, %8) // %10 = legalize_vec_elem_val(orig_rhs, %8) // %11 = ???_with_overflow(struct { Int, u1 }, %9, %10) - // %12 = struct_field_val(%11, 0) - // %13 = struct_field_val(%11, 1) + // %12 = agg_field_val(%11, 0) + // %13 = agg_field_val(%11, 1) // %14 = legalize_vec_store_elem(%4, %8, %12) // %15 = legalize_vec_store_elem(%4, %8, %13) // %16 = cmp_eq(%8, <usize, N-1>) @@ -1861,7 +1861,7 @@ fn scalarizeOverflowBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Error! } }, }).toRef(); const int_elem = loop.block.add(l, .{ - .tag = .struct_field_val, + .tag = .agg_field_val, .data = .{ .ty_pl = .{ .ty = .fromType(scalar_int_ty), .payload = try l.addExtra(Air.StructField, .{ @@ -1871,7 +1871,7 @@ fn scalarizeOverflowBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Error! } }, }).toRef(); const overflow_elem = loop.block.add(l, .{ - .tag = .struct_field_val, + .tag = .agg_field_val, .data = .{ .ty_pl = .{ .ty = .u1_type, .payload = try l.addExtra(Air.StructField, .{ @@ -2343,14 +2343,14 @@ fn safeArithmeticBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index, overflow_ // The worst-case scenario is a vector operand: // // %1 = add_with_overflow(%x, %y) - // %2 = struct_field_val(%1, .@"1") + // %2 = agg_field_val(%1, .@"1") // %3 = reduce(%2, .@"or") // %4 = bit_cast(%3, @bool_type) // %5 = cond_br(%4, { // %6 = call(@panic.integerOverflow, []) // %7 = unreach() // }, { - // %8 = struct_field_val(%1, .@"0") + // %8 = agg_field_val(%1, .@"0") // %9 = br(%z, %8) // }) var inst_buf: [9]Air.Inst.Index = undefined; @@ -2369,7 +2369,7 @@ fn safeArithmeticBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index, overflow_ } }, }); const overflow_bits_inst = main_block.add(l, .{ - .tag = .struct_field_val, + .tag = .agg_field_val, .data = .{ .ty_pl = .{ .ty = Air.internedToRef(overflow_bits_ty.toIntern()), .payload = try l.addExtra(Air.StructField, .{ @@ -2393,7 +2393,7 @@ fn safeArithmeticBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index, overflow_ condbr.else_block = .init(condbr.then_block.stealRemainingCapacity()); const result_inst = condbr.else_block.add(l, .{ - .tag = .struct_field_val, + .tag = .agg_field_val, .data = .{ .ty_pl = .{ .ty = Air.internedToRef(operand_ty.toIntern()), .payload = try l.addExtra(Air.StructField, .{ diff --git a/src/Air/Liveness.zig b/src/Air/Liveness.zig @@ -680,7 +680,7 @@ fn analyzeInst( const extra = a.air.extraData(Air.UnionInit, inst_datas[@intFromEnum(inst)].ty_pl.payload).data; return analyzeOperands(a, pass, data, inst, .{ extra.init, .none, .none }); }, - .struct_field_ptr, .struct_field_val, .spirv_runtime_array_len => { + .struct_field_ptr, .agg_field_val, .spirv_runtime_array_len => { const extra = a.air.extraData(Air.StructField, inst_datas[@intFromEnum(inst)].ty_pl.payload).data; return analyzeOperands(a, pass, data, inst, .{ extra.struct_operand, .none, .none }); }, diff --git a/src/Air/Liveness/Verify.zig b/src/Air/Liveness/Verify.zig @@ -198,7 +198,7 @@ fn verifyBody(self: *Verify, body: []const Air.Inst.Index) Error!void { const extra = self.air.extraData(Air.UnionInit, ty_pl.payload).data; try self.verifyInstOperands(inst, .{ extra.init, .none, .none }); }, - .struct_field_ptr, .struct_field_val, .spirv_runtime_array_len => { + .struct_field_ptr, .agg_field_val, .spirv_runtime_array_len => { const ty_pl = data[@intFromEnum(inst)].ty_pl; const extra = self.air.extraData(Air.StructField, ty_pl.payload).data; try self.verifyInstOperands(inst, .{ extra.struct_operand, .none, .none }); diff --git a/src/Air/Verify.zig b/src/Air/Verify.zig @@ -365,7 +365,7 @@ fn body(verify: *Verify, body_insts: []const Air.Inst.Index) Error!void { .struct_field_ptr_index_1, .struct_field_ptr_index_2, .struct_field_ptr_index_3, - .struct_field_val, + .agg_field_val, .set_union_tag, .get_union_tag, .slice, diff --git a/src/Air/print.zig b/src/Air/print.zig @@ -308,7 +308,7 @@ const Writer = struct { => try w.writeDbgVar(s, inst), .struct_field_ptr => try w.writeStructField(s, inst), - .struct_field_val => try w.writeStructField(s, inst), + .agg_field_val => try w.writeStructField(s, inst), .spirv_runtime_array_len => try w.writeStructField(s, inst), .inferred_alloc => @panic("TODO"), .inferred_alloc_comptime => @panic("TODO"), diff --git a/src/Sema.zig b/src/Sema.zig @@ -671,7 +671,7 @@ pub const Block = struct { field_ty: Type, ) !Air.Inst.Ref { return block.addInst(.{ - .tag = .struct_field_val, + .tag = .agg_field_val, .data = .{ .ty_pl = .{ .ty = Air.internedToRef(field_ty.toIntern()), .payload = try block.sema.addExtra(Air.StructField{ diff --git a/src/codegen/aarch64/Select.zig b/src/codegen/aarch64/Select.zig @@ -667,7 +667,7 @@ pub fn analyze(isel: *Select, air_body: []const Air.Inst.Index) !void { air_inst_index = air_body[air_body_index]; continue :air_tag air_tags[@intFromEnum(air_inst_index)]; }, - .struct_field_ptr, .struct_field_val => { + .struct_field_ptr, .agg_field_val => { const ty_pl = air_data[@intFromEnum(air_inst_index)].ty_pl; const extra = isel.air.extraData(Air.StructField, ty_pl.payload).data; @@ -5823,7 +5823,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, } if (air.next()) |next_air_tag| continue :air_tag next_air_tag; }, - .struct_field_val => { + .agg_field_val => { if (isel.live_values.fetchRemove(air.inst_index)) |field_vi| unused: { defer field_vi.value.deref(isel); diff --git a/src/codegen/c.zig b/src/codegen/c.zig @@ -36,7 +36,7 @@ pub fn legalizeFeatures(_: *const std.Target) ?*const Air.Legalize.Features { .expand_packed_load = true, .expand_packed_store = true, - .expand_packed_struct_field_val = true, + .expand_packed_agg_field_val = true, .expand_packed_aggregate_init = true, .scalarize_bit_cast_array = true, @@ -2823,7 +2823,7 @@ fn genBodyInner(f: *Function, body: []const Air.Inst.Index) Error!void { .field_parent_ptr => try airFieldParentPtr(f, inst), - .struct_field_val => try airStructFieldVal(f, inst), + .agg_field_val => try airAggFieldVal(f, inst), .slice_ptr => try airSliceField(f, inst, false, "ptr"), .slice_len => try airSliceField(f, inst, false, "len"), @@ -5527,7 +5527,7 @@ fn fieldPtr( return local; } -fn airStructFieldVal(f: *Function, inst: Air.Inst.Index) !CValue { +fn airAggFieldVal(f: *Function, inst: Air.Inst.Index) !CValue { const pt = f.dg.pt; const zcu = pt.zcu; const ip = &zcu.intern_pool; @@ -5542,7 +5542,7 @@ fn airStructFieldVal(f: *Function, inst: Air.Inst.Index) !CValue { const struct_ty = f.typeOf(extra.struct_operand); const w = &f.code.writer; - assert(struct_ty.containerLayout(zcu) != .@"packed"); // `Air.Legalize.Feature.expand_packed_struct_field_val` handles this case + assert(struct_ty.containerLayout(zcu) != .@"packed"); // `Air.Legalize.Feature.expand_packed_agg_field_val` handles this case const field_name: CValue = switch (ip.indexToKey(struct_ty.toIntern())) { .struct_type => .{ .identifier = struct_ty.structFieldName(extra.field_index, zcu).unwrap().?.toSlice(ip) }, .union_type => name: { diff --git a/src/codegen/llvm/FuncGen.zig b/src/codegen/llvm/FuncGen.zig @@ -539,7 +539,7 @@ fn genBody(self: *FuncGen, body: []const Air.Inst.Index, coverage_point: Air.Cov .atomic_store_seq_cst => try self.airAtomicStore(inst, .seq_cst), .struct_field_ptr => try self.airStructFieldPtr(inst), - .struct_field_val => try self.airStructFieldVal(inst), + .agg_field_val => try self.airAggFieldVal(inst), .struct_field_ptr_index_0 => try self.airStructFieldPtrIndex(inst, 0), .struct_field_ptr_index_1 => try self.airStructFieldPtrIndex(inst, 1), @@ -2323,7 +2323,7 @@ fn airStructFieldPtrIndex( return self.fieldPtr(struct_ptr, struct_ptr_ty, field_index); } -fn airStructFieldVal(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value { +fn airAggFieldVal(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value { const o = self.object; const zcu = o.zcu; const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; diff --git a/src/codegen/riscv64/CodeGen.zig b/src/codegen/riscv64/CodeGen.zig @@ -1519,7 +1519,7 @@ fn genBody(func: *Func, body: []const Air.Inst.Index) InnerError!void { .store => try func.airStore(inst, false), .store_safe => try func.airStore(inst, true), .struct_field_ptr=> try func.airStructFieldPtr(inst), - .struct_field_val=> try func.airStructFieldVal(inst), + .agg_field_val => try func.airAggFieldVal(inst), .float_from_int => try func.airFloatFromInt(inst), .int_from_float => try func.airIntFromFloat(inst), .cmpxchg_strong => try func.airCmpxchg(inst, .strong), @@ -4591,7 +4591,7 @@ fn structFieldPtr(func: *Func, inst: Air.Inst.Index, operand: Air.Inst.Ref, inde return dst_mcv.offset(field_offset); } -fn airStructFieldVal(func: *Func, inst: Air.Inst.Index) !void { +fn airAggFieldVal(func: *Func, inst: Air.Inst.Index) !void { const pt = func.pt; const zcu = pt.zcu; @@ -4688,7 +4688,7 @@ fn airStructFieldVal(func: *Func, inst: Air.Inst.Index) !void { break :result dst_mcv; } - return func.fail("TODO: airStructFieldVal load_frame field_off non multiple of 8", .{}); + return func.fail("TODO: airAggFieldVal load_frame field_off non multiple of 8", .{}); }, else => return func.fail("TODO: airStructField {s}", .{@tagName(src_mcv)}), } diff --git a/src/codegen/sparc64/CodeGen.zig b/src/codegen/sparc64/CodeGen.zig @@ -576,7 +576,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void { .store => try self.airStore(inst, false), .store_safe => try self.airStore(inst, true), .struct_field_ptr=> try self.airStructFieldPtr(inst), - .struct_field_val=> try self.airStructFieldVal(inst), + .agg_field_val => try self.airAggFieldVal(inst), .array_to_slice => try self.airArrayToSlice(inst), .float_from_int => try self.airFloatFromInt(inst), .int_from_float => try self.airIntFromFloat(inst), @@ -2473,7 +2473,7 @@ fn airStructFieldPtrIndex(self: *Self, inst: Air.Inst.Index, index: u8) !void { return self.finishAir(inst, result, .{ ty_op.operand, .none, .none }); } -fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void { +fn airAggFieldVal(self: *Self, inst: Air.Inst.Index) !void { const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; const extra = self.air.extraData(Air.StructField, ty_pl.payload).data; const operand = extra.struct_operand; @@ -2536,7 +2536,7 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void { else => unreachable, } }, - else => return self.fail("TODO implement codegen struct_field_val for {}", .{mcv}), + else => return self.fail("TODO implement codegen agg_field_val for {}", .{mcv}), } }; diff --git a/src/codegen/spirv/CodeGen.zig b/src/codegen/spirv/CodeGen.zig @@ -4222,7 +4222,7 @@ fn genInst(cg: *CodeGen, inst: Air.Inst.Index) Error!void { .get_union_tag => try cg.airGetUnionTag(inst), .union_init => try cg.airUnionInit(inst), - .struct_field_val => try cg.airStructFieldVal(inst), + .agg_field_val => try cg.airAggFieldVal(inst), .field_parent_ptr => try cg.airFieldParentPtr(inst), .struct_field_ptr => try cg.airStructFieldPtr(inst), @@ -6701,7 +6701,7 @@ fn airUnionInit(cg: *CodeGen, inst: Air.Inst.Index) !?Id { return try cg.unionInit(ty, extra.field_index, payload); } -fn airStructFieldVal(cg: *CodeGen, inst: Air.Inst.Index) !?Id { +fn airAggFieldVal(cg: *CodeGen, inst: Air.Inst.Index) !?Id { const pt = cg.pt; const zcu = cg.zcu; const ty_pl = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; diff --git a/src/codegen/wasm/CodeGen.zig b/src/codegen/wasm/CodeGen.zig @@ -41,7 +41,7 @@ pub fn legalizeFeatures(_: *const std.Target) *const Air.Legalize.Features { .expand_packed_load, .expand_packed_store, - .expand_packed_struct_field_val, + .expand_packed_agg_field_val, .expand_packed_aggregate_init, .scalarize_add, @@ -1809,7 +1809,7 @@ fn genInst(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { .struct_field_ptr_index_1 => cg.airStructFieldPtrIndex(inst, 1), .struct_field_ptr_index_2 => cg.airStructFieldPtrIndex(inst, 2), .struct_field_ptr_index_3 => cg.airStructFieldPtrIndex(inst, 3), - .struct_field_val => cg.airStructFieldVal(inst), + .agg_field_val => cg.airAggFieldVal(inst), .field_parent_ptr => cg.airFieldParentPtr(inst), .switch_br => cg.airSwitchBr(inst, false), @@ -5470,7 +5470,7 @@ fn structFieldPtr( } } -fn airStructFieldVal(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { +fn airAggFieldVal(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { const pt = cg.pt; const zcu = pt.zcu; const ty_pl = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; @@ -5483,7 +5483,7 @@ fn airStructFieldVal(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { if (!field_ty.hasRuntimeBits(zcu)) return cg.finishAir(inst, .none, &.{struct_field.struct_operand}); const result: WValue = switch (struct_ty.containerLayout(zcu)) { - .@"packed" => unreachable, // legalize .expand_packed_struct_field_val + .@"packed" => unreachable, // legalize .expand_packed_agg_field_val else => result: { const offset = std.math.cast(u32, struct_ty.structFieldOffset(field_index, zcu)) orelse { return cg.fail("Field type '{f}' too big to fit into stack frame", .{field_ty.fmt(pt)}); diff --git a/src/codegen/x86_64/CodeGen.zig b/src/codegen/x86_64/CodeGen.zig @@ -72,7 +72,7 @@ pub fn legalizeFeatures(_: *const std.Target) *const Air.Legalize.Features { .expand_packed_load, .expand_packed_store, - .expand_packed_struct_field_val, + .expand_packed_agg_field_val, .expand_packed_aggregate_init, }); } @@ -103965,7 +103965,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { )), cg); try ops[0].finish(inst, &.{ty_op.operand}, &ops, cg); }, - .struct_field_val => { + .agg_field_val => { const ty_pl = air_datas[@intFromEnum(inst)].ty_pl; const struct_field = cg.air.extraData(Air.StructField, ty_pl.payload).data; const agg_ty = cg.typeOf(struct_field.struct_operand);