spirv: implement AIR tag struct_field_ptr

This commit is contained in:
rpkak 2026-02-15 18:05:12 +01:00 committed by Andrew Kelley
parent 8c83acd3d4
commit 17dd2f0a85

View file

@ -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);