diff options
| author | Robin Voetter <robin@voetter.nl> | 2023-09-19 23:32:49 +0200 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-09-23 12:36:56 -0700 |
| commit | a75300c8d8cfe21647db1d50f77a9a1ee8d62a0e (patch) | |
| tree | d64829177c2bcecffd991d51a7f4cbbe4112dee8 /src/codegen | |
| parent | 8895025688b599a7082669234d40b26001bd9ed0 (diff) | |
| download | zig-a75300c8d8cfe21647db1d50f77a9a1ee8d62a0e.tar.gz zig-a75300c8d8cfe21647db1d50f77a9a1ee8d62a0e.zip | |
spirv: air slice
Diffstat (limited to 'src/codegen')
| -rw-r--r-- | src/codegen/spirv.zig | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/codegen/spirv.zig b/src/codegen/spirv.zig index aa5b56f58a..496bd0150b 100644 --- a/src/codegen/spirv.zig +++ b/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; |
