| ... | ... | @@ -1683,6 +1683,7 @@ pub const DeclGen = struct { |
| 1683 | 1683 | .not => try self.airNot(inst), |
| 1684 | 1684 | |
| 1685 | 1685 | .array_to_slice => try self.airArrayToSlice(inst), |
| 1686 | .slice => try self.airSlice(inst), |
| 1686 | 1687 | .aggregate_init => try self.airAggregateInit(inst), |
| 1687 | 1688 | |
| 1688 | 1689 | .slice_ptr => try self.airSliceField(inst, 0), |
| ... | ... | @@ -2462,6 +2463,22 @@ pub const DeclGen = struct { |
| 2462 | 2463 | return try self.constructStruct(slice_ty_ref, &.{ elem_ptr_id, len_id }); |
| 2463 | 2464 | } |
| 2464 | 2465 | |
| 2466 | fn airSlice(self: *DeclGen, inst: Air.Inst.Index) !?IdRef { |
| 2467 | if (self.liveness.isUnused(inst)) return null; |
| 2468 | |
| 2469 | const ty_pl = self.air.instructions.items(.data)[inst].ty_pl; |
| 2470 | const bin_op = self.air.extraData(Air.Bin, ty_pl.payload).data; |
| 2471 | const ptr_id = try self.resolve(bin_op.lhs); |
| 2472 | const len_id = try self.resolve(bin_op.rhs); |
| 2473 | const slice_ty = self.typeOfIndex(inst); |
| 2474 | const slice_ty_ref = try self.resolveType(slice_ty, .direct); |
| 2475 | |
| 2476 | return try self.constructStruct(slice_ty_ref, &.{ |
| 2477 | ptr_id, // Note: Type should not need to be converted to direct. |
| 2478 | len_id, // Note: Type should not need to be converted to direct. |
| 2479 | }); |
| 2480 | } |
| 2481 | |
| 2465 | 2482 | fn airAggregateInit(self: *DeclGen, inst: Air.Inst.Index) !?IdRef { |
| 2466 | 2483 | if (self.liveness.isUnused(inst)) return null; |
| 2467 | 2484 | |