authorgravatar for seda18@rolmail.netDavid Senoner <seda18@rolmail.net> 2026-06-11 09:12:33+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-06-28 00:09:59+02:00
logb23a9579151b38e2b3539b9e4e8bbcd858cad2cb
tree64595ff8018ccfb4bad6b1e39f46d9d9daa9061f
parentefd6ded716a027f7d47fe5c38df17785c8e2a2e2

rename `struct_field_val` -> `agg_field_val`

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

15 files changed, 41 insertions(+), 42 deletions(-)

src/Air.zig+3-4
......@@ -688,8 +688,7 @@ pub const Inst = struct {
688688 struct_field_ptr_index_3,
689689 /// Given a byval struct or union and a field index, returns the field byval.
690690 /// Uses the `ty_pl` field, payload is `StructField`.
691 /// TODO rename to `agg_field_val`
692 struct_field_val,
691 agg_field_val,
693692 /// Given a pointer to a tagged union, set its tag to the provided value.
694693 /// Result type is always void.
695694 /// 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)
16841683 .block,
16851684 .dbg_inline_block,
16861685 .struct_field_ptr,
1687 .struct_field_val,
1686 .agg_field_val,
16881687 .slice_elem_ptr,
16891688 .ptr_elem_ptr,
16901689 .cmpxchg_weak,
......@@ -2079,7 +2078,7 @@ pub fn mustLower(air: Air, inst: Air.Inst.Index, ip: *const InternPool) bool {
20792078 .struct_field_ptr_index_1,
20802079 .struct_field_ptr_index_2,
20812080 .struct_field_ptr_index_3,
2082 .struct_field_val,
2081 .agg_field_val,
20832082 .get_union_tag,
20842083 .slice,
20852084 .slice_len,
src/Air/Legalize.zig+11-11
......@@ -181,8 +181,8 @@ pub const Feature = enum {
181181 /// Currently assumes little endian and a specific integer layout where the lsb of every integer is the lsb of the
182182 /// first byte of memory until bit pointers know their backing type.
183183 expand_packed_store,
184 /// Replace `struct_field_val` of a packed field with a `bit_cast` to integer, `shr`, `trunc`, and `bit_cast` to field type.
185 expand_packed_struct_field_val,
184 /// Replace `agg_field_val` of a packed field with a `bit_cast` to integer, `shr`, `trunc`, and `bit_cast` to field type.
185 expand_packed_agg_field_val,
186186 /// Replace `aggregate_init` of a packed struct with a sequence of `shl_exact`, `bit_cast`, `int_cast`, and `bit_or`.
187187 expand_packed_aggregate_init,
188188
......@@ -781,7 +781,7 @@ fn legalizeBody(l: *Legalize, body_start: usize, body_len: usize) Error!void {
781781 .struct_field_ptr_index_2,
782782 .struct_field_ptr_index_3,
783783 => {},
784 .struct_field_val => if (l.features.has(.expand_packed_struct_field_val)) {
784 .agg_field_val => if (l.features.has(.expand_packed_agg_field_val)) {
785785 const ty_pl = l.air_instructions.items(.data)[@intFromEnum(inst)].ty_pl;
786786 const extra = l.extraData(Air.StructField, ty_pl.payload).data;
787787 switch (l.typeOf(extra.struct_operand).containerLayout(zcu)) {
......@@ -1808,8 +1808,8 @@ fn scalarizeOverflowBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Error!
18081808 // %9 = legalize_vec_elem_val(orig_lhs, %8)
18091809 // %10 = legalize_vec_elem_val(orig_rhs, %8)
18101810 // %11 = ???_with_overflow(struct { Int, u1 }, %9, %10)
1811 // %12 = struct_field_val(%11, 0)
1812 // %13 = struct_field_val(%11, 1)
1811 // %12 = agg_field_val(%11, 0)
1812 // %13 = agg_field_val(%11, 1)
18131813 // %14 = legalize_vec_store_elem(%4, %8, %12)
18141814 // %15 = legalize_vec_store_elem(%4, %8, %13)
18151815 // %16 = cmp_eq(%8, <usize, N-1>)
......@@ -1861,7 +1861,7 @@ fn scalarizeOverflowBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Error!
18611861 } },
18621862 }).toRef();
18631863 const int_elem = loop.block.add(l, .{
1864 .tag = .struct_field_val,
1864 .tag = .agg_field_val,
18651865 .data = .{ .ty_pl = .{
18661866 .ty = .fromType(scalar_int_ty),
18671867 .payload = try l.addExtra(Air.StructField, .{
......@@ -1871,7 +1871,7 @@ fn scalarizeOverflowBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Error!
18711871 } },
18721872 }).toRef();
18731873 const overflow_elem = loop.block.add(l, .{
1874 .tag = .struct_field_val,
1874 .tag = .agg_field_val,
18751875 .data = .{ .ty_pl = .{
18761876 .ty = .u1_type,
18771877 .payload = try l.addExtra(Air.StructField, .{
......@@ -2343,14 +2343,14 @@ fn safeArithmeticBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index, overflow_
23432343 // The worst-case scenario is a vector operand:
23442344 //
23452345 // %1 = add_with_overflow(%x, %y)
2346 // %2 = struct_field_val(%1, .@"1")
2346 // %2 = agg_field_val(%1, .@"1")
23472347 // %3 = reduce(%2, .@"or")
23482348 // %4 = bit_cast(%3, @bool_type)
23492349 // %5 = cond_br(%4, {
23502350 // %6 = call(@panic.integerOverflow, [])
23512351 // %7 = unreach()
23522352 // }, {
2353 // %8 = struct_field_val(%1, .@"0")
2353 // %8 = agg_field_val(%1, .@"0")
23542354 // %9 = br(%z, %8)
23552355 // })
23562356 var inst_buf: [9]Air.Inst.Index = undefined;
......@@ -2369,7 +2369,7 @@ fn safeArithmeticBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index, overflow_
23692369 } },
23702370 });
23712371 const overflow_bits_inst = main_block.add(l, .{
2372 .tag = .struct_field_val,
2372 .tag = .agg_field_val,
23732373 .data = .{ .ty_pl = .{
23742374 .ty = Air.internedToRef(overflow_bits_ty.toIntern()),
23752375 .payload = try l.addExtra(Air.StructField, .{
......@@ -2393,7 +2393,7 @@ fn safeArithmeticBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index, overflow_
23932393 condbr.else_block = .init(condbr.then_block.stealRemainingCapacity());
23942394
23952395 const result_inst = condbr.else_block.add(l, .{
2396 .tag = .struct_field_val,
2396 .tag = .agg_field_val,
23972397 .data = .{ .ty_pl = .{
23982398 .ty = Air.internedToRef(operand_ty.toIntern()),
23992399 .payload = try l.addExtra(Air.StructField, .{
src/Air/Liveness.zig+1-1
......@@ -680,7 +680,7 @@ fn analyzeInst(
680680 const extra = a.air.extraData(Air.UnionInit, inst_datas[@intFromEnum(inst)].ty_pl.payload).data;
681681 return analyzeOperands(a, pass, data, inst, .{ extra.init, .none, .none });
682682 },
683 .struct_field_ptr, .struct_field_val, .spirv_runtime_array_len => {
683 .struct_field_ptr, .agg_field_val, .spirv_runtime_array_len => {
684684 const extra = a.air.extraData(Air.StructField, inst_datas[@intFromEnum(inst)].ty_pl.payload).data;
685685 return analyzeOperands(a, pass, data, inst, .{ extra.struct_operand, .none, .none });
686686 },
src/Air/Liveness/Verify.zig+1-1
......@@ -198,7 +198,7 @@ fn verifyBody(self: *Verify, body: []const Air.Inst.Index) Error!void {
198198 const extra = self.air.extraData(Air.UnionInit, ty_pl.payload).data;
199199 try self.verifyInstOperands(inst, .{ extra.init, .none, .none });
200200 },
201 .struct_field_ptr, .struct_field_val, .spirv_runtime_array_len => {
201 .struct_field_ptr, .agg_field_val, .spirv_runtime_array_len => {
202202 const ty_pl = data[@intFromEnum(inst)].ty_pl;
203203 const extra = self.air.extraData(Air.StructField, ty_pl.payload).data;
204204 try self.verifyInstOperands(inst, .{ extra.struct_operand, .none, .none });
src/Air/Verify.zig+1-1
......@@ -365,7 +365,7 @@ fn body(verify: *Verify, body_insts: []const Air.Inst.Index) Error!void {
365365 .struct_field_ptr_index_1,
366366 .struct_field_ptr_index_2,
367367 .struct_field_ptr_index_3,
368 .struct_field_val,
368 .agg_field_val,
369369 .set_union_tag,
370370 .get_union_tag,
371371 .slice,
src/Air/print.zig+1-1
......@@ -308,7 +308,7 @@ const Writer = struct {
308308 => try w.writeDbgVar(s, inst),
309309
310310 .struct_field_ptr => try w.writeStructField(s, inst),
311 .struct_field_val => try w.writeStructField(s, inst),
311 .agg_field_val => try w.writeStructField(s, inst),
312312 .spirv_runtime_array_len => try w.writeStructField(s, inst),
313313 .inferred_alloc => @panic("TODO"),
314314 .inferred_alloc_comptime => @panic("TODO"),
src/Sema.zig+1-1
......@@ -671,7 +671,7 @@ pub const Block = struct {
671671 field_ty: Type,
672672 ) !Air.Inst.Ref {
673673 return block.addInst(.{
674 .tag = .struct_field_val,
674 .tag = .agg_field_val,
675675 .data = .{ .ty_pl = .{
676676 .ty = Air.internedToRef(field_ty.toIntern()),
677677 .payload = try block.sema.addExtra(Air.StructField{
src/codegen/aarch64/Select.zig+2-2
......@@ -667,7 +667,7 @@ pub fn analyze(isel: *Select, air_body: []const Air.Inst.Index) !void {
667667 air_inst_index = air_body[air_body_index];
668668 continue :air_tag air_tags[@intFromEnum(air_inst_index)];
669669 },
670 .struct_field_ptr, .struct_field_val => {
670 .struct_field_ptr, .agg_field_val => {
671671 const ty_pl = air_data[@intFromEnum(air_inst_index)].ty_pl;
672672 const extra = isel.air.extraData(Air.StructField, ty_pl.payload).data;
673673
......@@ -5823,7 +5823,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory,
58235823 }
58245824 if (air.next()) |next_air_tag| continue :air_tag next_air_tag;
58255825 },
5826 .struct_field_val => {
5826 .agg_field_val => {
58275827 if (isel.live_values.fetchRemove(air.inst_index)) |field_vi| unused: {
58285828 defer field_vi.value.deref(isel);
58295829
src/codegen/c.zig+4-4
......@@ -36,7 +36,7 @@ pub fn legalizeFeatures(_: *const std.Target) ?*const Air.Legalize.Features {
3636
3737 .expand_packed_load = true,
3838 .expand_packed_store = true,
39 .expand_packed_struct_field_val = true,
39 .expand_packed_agg_field_val = true,
4040 .expand_packed_aggregate_init = true,
4141
4242 .scalarize_bit_cast_array = true,
......@@ -2823,7 +2823,7 @@ fn genBodyInner(f: *Function, body: []const Air.Inst.Index) Error!void {
28232823
28242824 .field_parent_ptr => try airFieldParentPtr(f, inst),
28252825
2826 .struct_field_val => try airStructFieldVal(f, inst),
2826 .agg_field_val => try airAggFieldVal(f, inst),
28272827 .slice_ptr => try airSliceField(f, inst, false, "ptr"),
28282828 .slice_len => try airSliceField(f, inst, false, "len"),
28292829
......@@ -5527,7 +5527,7 @@ fn fieldPtr(
55275527 return local;
55285528}
55295529
5530fn airStructFieldVal(f: *Function, inst: Air.Inst.Index) !CValue {
5530fn airAggFieldVal(f: *Function, inst: Air.Inst.Index) !CValue {
55315531 const pt = f.dg.pt;
55325532 const zcu = pt.zcu;
55335533 const ip = &zcu.intern_pool;
......@@ -5542,7 +5542,7 @@ fn airStructFieldVal(f: *Function, inst: Air.Inst.Index) !CValue {
55425542 const struct_ty = f.typeOf(extra.struct_operand);
55435543 const w = &f.code.writer;
55445544
5545 assert(struct_ty.containerLayout(zcu) != .@"packed"); // `Air.Legalize.Feature.expand_packed_struct_field_val` handles this case
5545 assert(struct_ty.containerLayout(zcu) != .@"packed"); // `Air.Legalize.Feature.expand_packed_agg_field_val` handles this case
55465546 const field_name: CValue = switch (ip.indexToKey(struct_ty.toIntern())) {
55475547 .struct_type => .{ .identifier = struct_ty.structFieldName(extra.field_index, zcu).unwrap().?.toSlice(ip) },
55485548 .union_type => name: {
src/codegen/llvm/FuncGen.zig+2-2
......@@ -539,7 +539,7 @@ fn genBody(self: *FuncGen, body: []const Air.Inst.Index, coverage_point: Air.Cov
539539 .atomic_store_seq_cst => try self.airAtomicStore(inst, .seq_cst),
540540
541541 .struct_field_ptr => try self.airStructFieldPtr(inst),
542 .struct_field_val => try self.airStructFieldVal(inst),
542 .agg_field_val => try self.airAggFieldVal(inst),
543543
544544 .struct_field_ptr_index_0 => try self.airStructFieldPtrIndex(inst, 0),
545545 .struct_field_ptr_index_1 => try self.airStructFieldPtrIndex(inst, 1),
......@@ -2323,7 +2323,7 @@ fn airStructFieldPtrIndex(
23232323 return self.fieldPtr(struct_ptr, struct_ptr_ty, field_index);
23242324}
23252325
2326fn airStructFieldVal(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value {
2326fn airAggFieldVal(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value {
23272327 const o = self.object;
23282328 const zcu = o.zcu;
23292329 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
src/codegen/riscv64/CodeGen.zig+3-3
......@@ -1519,7 +1519,7 @@ fn genBody(func: *Func, body: []const Air.Inst.Index) InnerError!void {
15191519 .store => try func.airStore(inst, false),
15201520 .store_safe => try func.airStore(inst, true),
15211521 .struct_field_ptr=> try func.airStructFieldPtr(inst),
1522 .struct_field_val=> try func.airStructFieldVal(inst),
1522 .agg_field_val => try func.airAggFieldVal(inst),
15231523 .float_from_int => try func.airFloatFromInt(inst),
15241524 .int_from_float => try func.airIntFromFloat(inst),
15251525 .cmpxchg_strong => try func.airCmpxchg(inst, .strong),
......@@ -4591,7 +4591,7 @@ fn structFieldPtr(func: *Func, inst: Air.Inst.Index, operand: Air.Inst.Ref, inde
45914591 return dst_mcv.offset(field_offset);
45924592}
45934593
4594fn airStructFieldVal(func: *Func, inst: Air.Inst.Index) !void {
4594fn airAggFieldVal(func: *Func, inst: Air.Inst.Index) !void {
45954595 const pt = func.pt;
45964596 const zcu = pt.zcu;
45974597
......@@ -4688,7 +4688,7 @@ fn airStructFieldVal(func: *Func, inst: Air.Inst.Index) !void {
46884688 break :result dst_mcv;
46894689 }
46904690
4691 return func.fail("TODO: airStructFieldVal load_frame field_off non multiple of 8", .{});
4691 return func.fail("TODO: airAggFieldVal load_frame field_off non multiple of 8", .{});
46924692 },
46934693 else => return func.fail("TODO: airStructField {s}", .{@tagName(src_mcv)}),
46944694 }
src/codegen/sparc64/CodeGen.zig+3-3
......@@ -576,7 +576,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
576576 .store => try self.airStore(inst, false),
577577 .store_safe => try self.airStore(inst, true),
578578 .struct_field_ptr=> try self.airStructFieldPtr(inst),
579 .struct_field_val=> try self.airStructFieldVal(inst),
579 .agg_field_val => try self.airAggFieldVal(inst),
580580 .array_to_slice => try self.airArrayToSlice(inst),
581581 .float_from_int => try self.airFloatFromInt(inst),
582582 .int_from_float => try self.airIntFromFloat(inst),
......@@ -2473,7 +2473,7 @@ fn airStructFieldPtrIndex(self: *Self, inst: Air.Inst.Index, index: u8) !void {
24732473 return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
24742474}
24752475
2476fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void {
2476fn airAggFieldVal(self: *Self, inst: Air.Inst.Index) !void {
24772477 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
24782478 const extra = self.air.extraData(Air.StructField, ty_pl.payload).data;
24792479 const operand = extra.struct_operand;
......@@ -2536,7 +2536,7 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void {
25362536 else => unreachable,
25372537 }
25382538 },
2539 else => return self.fail("TODO implement codegen struct_field_val for {}", .{mcv}),
2539 else => return self.fail("TODO implement codegen agg_field_val for {}", .{mcv}),
25402540 }
25412541 };
25422542
src/codegen/spirv/CodeGen.zig+2-2
......@@ -4222,7 +4222,7 @@ fn genInst(cg: *CodeGen, inst: Air.Inst.Index) Error!void {
42224222 .get_union_tag => try cg.airGetUnionTag(inst),
42234223 .union_init => try cg.airUnionInit(inst),
42244224
4225 .struct_field_val => try cg.airStructFieldVal(inst),
4225 .agg_field_val => try cg.airAggFieldVal(inst),
42264226 .field_parent_ptr => try cg.airFieldParentPtr(inst),
42274227
42284228 .struct_field_ptr => try cg.airStructFieldPtr(inst),
......@@ -6701,7 +6701,7 @@ fn airUnionInit(cg: *CodeGen, inst: Air.Inst.Index) !?Id {
67016701 return try cg.unionInit(ty, extra.field_index, payload);
67026702}
67036703
6704fn airStructFieldVal(cg: *CodeGen, inst: Air.Inst.Index) !?Id {
6704fn airAggFieldVal(cg: *CodeGen, inst: Air.Inst.Index) !?Id {
67056705 const pt = cg.pt;
67066706 const zcu = cg.zcu;
67076707 const ty_pl = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
src/codegen/wasm/CodeGen.zig+4-4
......@@ -41,7 +41,7 @@ pub fn legalizeFeatures(_: *const std.Target) *const Air.Legalize.Features {
4141
4242 .expand_packed_load,
4343 .expand_packed_store,
44 .expand_packed_struct_field_val,
44 .expand_packed_agg_field_val,
4545 .expand_packed_aggregate_init,
4646
4747 .scalarize_add,
......@@ -1809,7 +1809,7 @@ fn genInst(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
18091809 .struct_field_ptr_index_1 => cg.airStructFieldPtrIndex(inst, 1),
18101810 .struct_field_ptr_index_2 => cg.airStructFieldPtrIndex(inst, 2),
18111811 .struct_field_ptr_index_3 => cg.airStructFieldPtrIndex(inst, 3),
1812 .struct_field_val => cg.airStructFieldVal(inst),
1812 .agg_field_val => cg.airAggFieldVal(inst),
18131813 .field_parent_ptr => cg.airFieldParentPtr(inst),
18141814
18151815 .switch_br => cg.airSwitchBr(inst, false),
......@@ -5470,7 +5470,7 @@ fn structFieldPtr(
54705470 }
54715471}
54725472
5473fn airStructFieldVal(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5473fn airAggFieldVal(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
54745474 const pt = cg.pt;
54755475 const zcu = pt.zcu;
54765476 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 {
54835483 if (!field_ty.hasRuntimeBits(zcu)) return cg.finishAir(inst, .none, &.{struct_field.struct_operand});
54845484
54855485 const result: WValue = switch (struct_ty.containerLayout(zcu)) {
5486 .@"packed" => unreachable, // legalize .expand_packed_struct_field_val
5486 .@"packed" => unreachable, // legalize .expand_packed_agg_field_val
54875487 else => result: {
54885488 const offset = std.math.cast(u32, struct_ty.structFieldOffset(field_index, zcu)) orelse {
54895489 return cg.fail("Field type '{f}' too big to fit into stack frame", .{field_ty.fmt(pt)});
src/codegen/x86_64/CodeGen.zig+2-2
......@@ -72,7 +72,7 @@ pub fn legalizeFeatures(_: *const std.Target) *const Air.Legalize.Features {
7272
7373 .expand_packed_load,
7474 .expand_packed_store,
75 .expand_packed_struct_field_val,
75 .expand_packed_agg_field_val,
7676 .expand_packed_aggregate_init,
7777 });
7878}
......@@ -103965,7 +103965,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
103965103965 )), cg);
103966103966 try ops[0].finish(inst, &.{ty_op.operand}, &ops, cg);
103967103967 },
103968 .struct_field_val => {
103968 .agg_field_val => {
103969103969 const ty_pl = air_datas[@intFromEnum(inst)].ty_pl;
103970103970 const struct_field = cg.air.extraData(Air.StructField, ty_pl.payload).data;
103971103971 const agg_ty = cg.typeOf(struct_field.struct_operand);