authorgravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2023-09-19 23:32:49+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-09-23 12:36:56-07:00
loga75300c8d8cfe21647db1d50f77a9a1ee8d62a0e
treed64829177c2bcecffd991d51a7f4cbbe4112dee8
parent8895025688b599a7082669234d40b26001bd9ed0

spirv: air slice


1 files changed, 17 insertions(+), 0 deletions(-)

src/codegen/spirv.zig+17
...@@ -1683,6 +1683,7 @@ pub const DeclGen = struct {...@@ -1683,6 +1683,7 @@ pub const DeclGen = struct {
1683 .not => try self.airNot(inst),1683 .not => try self.airNot(inst),
16841684
1685 .array_to_slice => try self.airArrayToSlice(inst),1685 .array_to_slice => try self.airArrayToSlice(inst),
1686 .slice => try self.airSlice(inst),
1686 .aggregate_init => try self.airAggregateInit(inst),1687 .aggregate_init => try self.airAggregateInit(inst),
16871688
1688 .slice_ptr => try self.airSliceField(inst, 0),1689 .slice_ptr => try self.airSliceField(inst, 0),
...@@ -2462,6 +2463,22 @@ pub const DeclGen = struct {...@@ -2462,6 +2463,22 @@ pub const DeclGen = struct {
2462 return try self.constructStruct(slice_ty_ref, &.{ elem_ptr_id, len_id });2463 return try self.constructStruct(slice_ty_ref, &.{ elem_ptr_id, len_id });
2463 }2464 }
24642465
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 fn airAggregateInit(self: *DeclGen, inst: Air.Inst.Index) !?IdRef {2482 fn airAggregateInit(self: *DeclGen, inst: Air.Inst.Index) !?IdRef {
2466 if (self.liveness.isUnused(inst)) return null;2483 if (self.liveness.isUnused(inst)) return null;
24672484