| ... | ... | @@ -1071,10 +1071,21 @@ fn airMax(self: *Self, inst: Air.Inst.Index) !void { |
| 1071 | 1071 | fn airSlice(self: *Self, inst: Air.Inst.Index) !void { |
| 1072 | 1072 | const ty_pl = self.air.instructions.items(.data)[inst].ty_pl; |
| 1073 | 1073 | const bin_op = self.air.extraData(Air.Bin, ty_pl.payload).data; |
| 1074 | | const result: MCValue = if (self.liveness.isUnused(inst)) |
| 1075 | | .dead |
| 1076 | | else |
| 1077 | | return self.fail("TODO implement slice for {}", .{self.target.cpu.arch}); |
| 1074 | |
| 1075 | if (self.liveness.isUnused(inst)) { |
| 1076 | return self.finishAir(inst, .dead, .{ bin_op.lhs, bin_op.rhs, .none }); |
| 1077 | } |
| 1078 | |
| 1079 | const ptr = try self.resolveInst(bin_op.lhs); |
| 1080 | const ptr_ty = self.air.typeOf(bin_op.lhs); |
| 1081 | const len = try self.resolveInst(bin_op.rhs); |
| 1082 | const len_ty = self.air.typeOf(bin_op.rhs); |
| 1083 | |
| 1084 | const stack_offset = @intCast(i32, try self.allocMem(inst, 16, 16)); |
| 1085 | try self.genSetStack(ptr_ty, stack_offset + 8, ptr); |
| 1086 | try self.genSetStack(len_ty, stack_offset, len); |
| 1087 | const result = MCValue{ .stack_offset = stack_offset }; |
| 1088 | |
| 1078 | 1089 | return self.finishAir(inst, result, .{ bin_op.lhs, bin_op.rhs, .none }); |
| 1079 | 1090 | } |
| 1080 | 1091 | |