| ... | @@ -517,7 +517,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -517,7 +517,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void { |
| 517 | .shl_sat => @panic("TODO try self.airShlSat(inst)"), | 517 | .shl_sat => @panic("TODO try self.airShlSat(inst)"), |
| 518 | .min => @panic("TODO try self.airMin(inst)"), | 518 | .min => @panic("TODO try self.airMin(inst)"), |
| 519 | .max => @panic("TODO try self.airMax(inst)"), | 519 | .max => @panic("TODO try self.airMax(inst)"), |
| 520 | .slice => @panic("TODO try self.airSlice(inst)"), | 520 | .slice => try self.airSlice(inst), |
| 521 | | 521 | |
| 522 | .sqrt, | 522 | .sqrt, |
| 523 | .sin, | 523 | .sin, |
| ... | @@ -1647,6 +1647,26 @@ fn airRetPtr(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -1647,6 +1647,26 @@ fn airRetPtr(self: *Self, inst: Air.Inst.Index) !void { |
| 1647 | return self.finishAir(inst, .{ .ptr_stack_offset = stack_offset }, .{ .none, .none, .none }); | 1647 | return self.finishAir(inst, .{ .ptr_stack_offset = stack_offset }, .{ .none, .none, .none }); |
| 1648 | } | 1648 | } |
| 1649 | | 1649 | |
| | 1650 | fn airSlice(self: *Self, inst: Air.Inst.Index) !void { |
| | 1651 | const ty_pl = self.air.instructions.items(.data)[inst].ty_pl; |
| | 1652 | const bin_op = self.air.extraData(Air.Bin, ty_pl.payload).data; |
| | 1653 | const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: { |
| | 1654 | const ptr = try self.resolveInst(bin_op.lhs); |
| | 1655 | const ptr_ty = self.air.typeOf(bin_op.lhs); |
| | 1656 | const len = try self.resolveInst(bin_op.rhs); |
| | 1657 | const len_ty = self.air.typeOf(bin_op.rhs); |
| | 1658 | |
| | 1659 | const ptr_bits = self.target.cpu.arch.ptrBitWidth(); |
| | 1660 | const ptr_bytes = @divExact(ptr_bits, 8); |
| | 1661 | |
| | 1662 | const stack_offset = try self.allocMem(inst, ptr_bytes * 2, ptr_bytes * 2); |
| | 1663 | try self.genSetStack(ptr_ty, stack_offset, ptr); |
| | 1664 | try self.genSetStack(len_ty, stack_offset - ptr_bytes, len); |
| | 1665 | break :result MCValue{ .stack_offset = stack_offset }; |
| | 1666 | }; |
| | 1667 | return self.finishAir(inst, result, .{ bin_op.lhs, bin_op.rhs, .none }); |
| | 1668 | } |
| | 1669 | |
| 1650 | fn airSliceElemVal(self: *Self, inst: Air.Inst.Index) !void { | 1670 | fn airSliceElemVal(self: *Self, inst: Air.Inst.Index) !void { |
| 1651 | const is_volatile = false; // TODO | 1671 | const is_volatile = false; // TODO |
| 1652 | const bin_op = self.air.instructions.items(.data)[inst].bin_op; | 1672 | const bin_op = self.air.instructions.items(.data)[inst].bin_op; |