Commit a75300c8d8
Changed files (1)
src
codegen
src/codegen/spirv.zig
@@ -1683,6 +1683,7 @@ pub const DeclGen = struct {
.not => try self.airNot(inst),
.array_to_slice => try self.airArrayToSlice(inst),
+ .slice => try self.airSlice(inst),
.aggregate_init => try self.airAggregateInit(inst),
.slice_ptr => try self.airSliceField(inst, 0),
@@ -2462,6 +2463,22 @@ pub const DeclGen = struct {
return try self.constructStruct(slice_ty_ref, &.{ elem_ptr_id, len_id });
}
+ fn airSlice(self: *DeclGen, inst: Air.Inst.Index) !?IdRef {
+ if (self.liveness.isUnused(inst)) return null;
+
+ const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
+ const bin_op = self.air.extraData(Air.Bin, ty_pl.payload).data;
+ const ptr_id = try self.resolve(bin_op.lhs);
+ const len_id = try self.resolve(bin_op.rhs);
+ const slice_ty = self.typeOfIndex(inst);
+ const slice_ty_ref = try self.resolveType(slice_ty, .direct);
+
+ return try self.constructStruct(slice_ty_ref, &.{
+ ptr_id, // Note: Type should not need to be converted to direct.
+ len_id, // Note: Type should not need to be converted to direct.
+ });
+ }
+
fn airAggregateInit(self: *DeclGen, inst: Air.Inst.Index) !?IdRef {
if (self.liveness.isUnused(inst)) return null;