| ... | @@ -593,7 +593,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -593,7 +593,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void { |
| 593 | .store => try self.airStore(inst), | 593 | .store => try self.airStore(inst), |
| 594 | .struct_field_ptr=> @panic("TODO try self.airStructFieldPtr(inst)"), | 594 | .struct_field_ptr=> @panic("TODO try self.airStructFieldPtr(inst)"), |
| 595 | .struct_field_val=> try self.airStructFieldVal(inst), | 595 | .struct_field_val=> try self.airStructFieldVal(inst), |
| 596 | .array_to_slice => @panic("TODO try self.airArrayToSlice(inst)"), | 596 | .array_to_slice => try self.airArrayToSlice(inst), |
| 597 | .int_to_float => @panic("TODO try self.airIntToFloat(inst)"), | 597 | .int_to_float => @panic("TODO try self.airIntToFloat(inst)"), |
| 598 | .float_to_int => @panic("TODO try self.airFloatToInt(inst)"), | 598 | .float_to_int => @panic("TODO try self.airFloatToInt(inst)"), |
| 599 | .cmpxchg_strong => @panic("TODO try self.airCmpxchg(inst)"), | 599 | .cmpxchg_strong => @panic("TODO try self.airCmpxchg(inst)"), |
| ... | @@ -783,6 +783,25 @@ fn airAlloc(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -783,6 +783,25 @@ fn airAlloc(self: *Self, inst: Air.Inst.Index) !void { |
| 783 | return self.finishAir(inst, .{ .ptr_stack_offset = stack_offset }, .{ .none, .none, .none }); | 783 | return self.finishAir(inst, .{ .ptr_stack_offset = stack_offset }, .{ .none, .none, .none }); |
| 784 | } | 784 | } |
| 785 | | 785 | |
| | 786 | fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void { |
| | 787 | const ty_op = self.air.instructions.items(.data)[inst].ty_op; |
| | 788 | const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: { |
| | 789 | const ptr_ty = self.air.typeOf(ty_op.operand); |
| | 790 | const ptr = try self.resolveInst(ty_op.operand); |
| | 791 | const array_ty = ptr_ty.childType(); |
| | 792 | const array_len = @intCast(u32, array_ty.arrayLen()); |
| | 793 | |
| | 794 | const ptr_bits = self.target.cpu.arch.ptrBitWidth(); |
| | 795 | const ptr_bytes = @divExact(ptr_bits, 8); |
| | 796 | |
| | 797 | const stack_offset = try self.allocMem(inst, ptr_bytes * 2, ptr_bytes * 2); |
| | 798 | try self.genSetStack(ptr_ty, stack_offset, ptr); |
| | 799 | try self.genSetStack(Type.initTag(.usize), stack_offset - ptr_bytes, .{ .immediate = array_len }); |
| | 800 | break :result MCValue{ .stack_offset = stack_offset }; |
| | 801 | }; |
| | 802 | return self.finishAir(inst, result, .{ ty_op.operand, .none, .none }); |
| | 803 | } |
| | 804 | |
| 786 | fn airAsm(self: *Self, inst: Air.Inst.Index) !void { | 805 | fn airAsm(self: *Self, inst: Air.Inst.Index) !void { |
| 787 | const ty_pl = self.air.instructions.items(.data)[inst].ty_pl; | 806 | const ty_pl = self.air.instructions.items(.data)[inst].ty_pl; |
| 788 | const extra = self.air.extraData(Air.Asm, ty_pl.payload); | 807 | const extra = self.air.extraData(Air.Asm, ty_pl.payload); |