| ... | ... | @@ -4043,9 +4043,24 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void { |
| 4043 | 4043 | |
| 4044 | 4044 | fn airFieldParentPtr(self: *Self, inst: Air.Inst.Index) !void { |
| 4045 | 4045 | const ty_pl = self.air.instructions.items(.data)[inst].ty_pl; |
| 4046 | | const extra = self.air.extraData(Air.StructField, ty_pl.payload).data; |
| 4047 | | _ = extra; |
| 4048 | | return self.fail("TODO implement codegen airFieldParentPtr", .{}); |
| 4046 | const extra = self.air.extraData(Air.FieldParentPtr, ty_pl.payload).data; |
| 4047 | const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: { |
| 4048 | const field_ptr = try self.resolveInst(extra.field_ptr); |
| 4049 | const struct_ty = self.air.getRefType(ty_pl.ty).childType(); |
| 4050 | const struct_field_offset = @intCast(u32, struct_ty.structFieldOffset(extra.field_index, self.target.*)); |
| 4051 | switch (field_ptr) { |
| 4052 | .ptr_stack_offset => |off| { |
| 4053 | break :result MCValue{ .ptr_stack_offset = off + struct_field_offset }; |
| 4054 | }, |
| 4055 | else => { |
| 4056 | const lhs_bind: ReadArg.Bind = .{ .mcv = field_ptr }; |
| 4057 | const rhs_bind: ReadArg.Bind = .{ .mcv = .{ .immediate = struct_field_offset } }; |
| 4058 | |
| 4059 | break :result try self.addSub(.sub, lhs_bind, rhs_bind, Type.usize, Type.usize, null); |
| 4060 | }, |
| 4061 | } |
| 4062 | }; |
| 4063 | return self.finishAir(inst, result, .{ extra.field_ptr, .none, .none }); |
| 4049 | 4064 | } |
| 4050 | 4065 | |
| 4051 | 4066 | fn airArg(self: *Self, inst: Air.Inst.Index) !void { |