zig

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

commit 17dd2f0a853eebb99d7165a3ec90719fc7b023a2 (tree)
parent 8c83acd3d4e753c0fe52462068c2758ac3762095
Author: rpkak <rpkak@noreply.codeberg.org>
Date:   Sun, 15 Feb 2026 18:05:12 +0100

spirv: implement AIR tag struct_field_ptr

Diffstat:
Msrc/codegen/spirv/CodeGen.zig | 11+++++++++++
1 file changed, 11 insertions(+), 0 deletions(-)

diff --git a/src/codegen/spirv/CodeGen.zig b/src/codegen/spirv/CodeGen.zig @@ -2761,6 +2761,8 @@ fn genInst(cg: *CodeGen, inst: Air.Inst.Index) Error!void { .struct_field_val => try cg.airStructFieldVal(inst), .field_parent_ptr => try cg.airFieldParentPtr(inst), + .struct_field_ptr => try cg.airStructFieldPtr(inst), + .struct_field_ptr_index_0 => try cg.airStructFieldPtrIndex(inst, 0), .struct_field_ptr_index_1 => try cg.airStructFieldPtrIndex(inst, 1), .struct_field_ptr_index_2 => try cg.airStructFieldPtrIndex(inst, 2), @@ -4806,6 +4808,15 @@ fn structFieldPtr( } } +fn airStructFieldPtr(cg: *CodeGen, inst: Air.Inst.Index) !?Id { + const ty_pl = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; + const struct_field = cg.air.extraData(Air.StructField, ty_pl.payload).data; + const struct_ptr = try cg.resolve(struct_field.struct_operand); + const struct_ptr_ty = cg.typeOf(struct_field.struct_operand); + const result_ptr_ty = cg.typeOfIndex(inst); + return try cg.structFieldPtr(result_ptr_ty, struct_ptr_ty, struct_ptr, struct_field.field_index); +} + fn airStructFieldPtrIndex(cg: *CodeGen, inst: Air.Inst.Index, field_index: u32) !?Id { const ty_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; const struct_ptr = try cg.resolve(ty_op.operand);