authorgravatar for rpkak@noreply.codeberg.orgrpkak <rpkak@noreply.codeberg.org> 2026-02-15 18:05:12+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-02-15 23:09:24+01:00
log17dd2f0a853eebb99d7165a3ec90719fc7b023a2
tree0dab7c267dda6ab6645e8f0746c375b14fed423b
parent8c83acd3d4e753c0fe52462068c2758ac3762095

spirv: implement AIR tag struct_field_ptr


1 files changed, 11 insertions(+), 0 deletions(-)

src/codegen/spirv/CodeGen.zig+11
...@@ -2761,6 +2761,8 @@ fn genInst(cg: *CodeGen, inst: Air.Inst.Index) Error!void {...@@ -2761,6 +2761,8 @@ fn genInst(cg: *CodeGen, inst: Air.Inst.Index) Error!void {
2761 .struct_field_val => try cg.airStructFieldVal(inst),2761 .struct_field_val => try cg.airStructFieldVal(inst),
2762 .field_parent_ptr => try cg.airFieldParentPtr(inst),2762 .field_parent_ptr => try cg.airFieldParentPtr(inst),
27632763
2764 .struct_field_ptr => try cg.airStructFieldPtr(inst),
2765
2764 .struct_field_ptr_index_0 => try cg.airStructFieldPtrIndex(inst, 0),2766 .struct_field_ptr_index_0 => try cg.airStructFieldPtrIndex(inst, 0),
2765 .struct_field_ptr_index_1 => try cg.airStructFieldPtrIndex(inst, 1),2767 .struct_field_ptr_index_1 => try cg.airStructFieldPtrIndex(inst, 1),
2766 .struct_field_ptr_index_2 => try cg.airStructFieldPtrIndex(inst, 2),2768 .struct_field_ptr_index_2 => try cg.airStructFieldPtrIndex(inst, 2),
...@@ -4806,6 +4808,15 @@ fn structFieldPtr(...@@ -4806,6 +4808,15 @@ fn structFieldPtr(
4806 }4808 }
4807}4809}
48084810
4811fn airStructFieldPtr(cg: *CodeGen, inst: Air.Inst.Index) !?Id {
4812 const ty_pl = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
4813 const struct_field = cg.air.extraData(Air.StructField, ty_pl.payload).data;
4814 const struct_ptr = try cg.resolve(struct_field.struct_operand);
4815 const struct_ptr_ty = cg.typeOf(struct_field.struct_operand);
4816 const result_ptr_ty = cg.typeOfIndex(inst);
4817 return try cg.structFieldPtr(result_ptr_ty, struct_ptr_ty, struct_ptr, struct_field.field_index);
4818}
4819
4809fn airStructFieldPtrIndex(cg: *CodeGen, inst: Air.Inst.Index, field_index: u32) !?Id {4820fn airStructFieldPtrIndex(cg: *CodeGen, inst: Air.Inst.Index, field_index: u32) !?Id {
4810 const ty_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;4821 const ty_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
4811 const struct_ptr = try cg.resolve(ty_op.operand);4822 const struct_ptr = try cg.resolve(ty_op.operand);