| ... | ... | @@ -2681,9 +2681,24 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void { |
| 2681 | 2681 | |
| 2682 | 2682 | fn airFieldParentPtr(self: *Self, inst: Air.Inst.Index) !void { |
| 2683 | 2683 | const ty_pl = self.air.instructions.items(.data)[inst].ty_pl; |
| 2684 | | const bin_op = self.air.extraData(Air.Bin, ty_pl.payload).data; |
| 2685 | | const result: MCValue = if (self.liveness.isUnused(inst)) .dead else return self.fail("TODO implement airFieldParentPtr", .{}); |
| 2686 | | return self.finishAir(inst, result, .{ bin_op.lhs, bin_op.rhs, .none }); |
| 2684 | const extra = self.air.extraData(Air.FieldParentPtr, ty_pl.payload).data; |
| 2685 | const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: { |
| 2686 | const field_ptr = try self.resolveInst(extra.field_ptr); |
| 2687 | const struct_ty = self.air.getRefType(ty_pl.ty).childType(); |
| 2688 | const struct_field_offset = @intCast(u32, struct_ty.structFieldOffset(extra.field_index, self.target.*)); |
| 2689 | switch (field_ptr) { |
| 2690 | .ptr_stack_offset => |off| { |
| 2691 | break :result MCValue{ .ptr_stack_offset = off + struct_field_offset }; |
| 2692 | }, |
| 2693 | else => { |
| 2694 | const lhs_bind: ReadArg.Bind = .{ .mcv = field_ptr }; |
| 2695 | const rhs_bind: ReadArg.Bind = .{ .mcv = .{ .immediate = struct_field_offset } }; |
| 2696 | |
| 2697 | break :result try self.addSub(.sub, lhs_bind, rhs_bind, Type.usize, Type.usize, null); |
| 2698 | }, |
| 2699 | } |
| 2700 | }; |
| 2701 | return self.finishAir(inst, result, .{ extra.field_ptr, .none, .none }); |
| 2687 | 2702 | } |
| 2688 | 2703 | |
| 2689 | 2704 | /// An argument to a Mir instruction which is read (and possibly also |