authorgravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2022-12-11 13:39:29+01:00
committergravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2023-04-09 01:51:52+02:00
log12a3a8b100b7af4110cdc30de4def7d8f8d8c148
treea61daabe71dff5c0f898b9b4fb69e09fbc39c172
parente788dfa142f27717df1258009cadb61f314610dd
signaturelock-open Commit is signed but in an unrecognized format.

spirv: slice constants

Implements lowering slice constants in the SPIR-V backend

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

src/codegen/spirv.zig+17-1
...@@ -586,7 +586,23 @@ pub const DeclGen = struct {...@@ -586,7 +586,23 @@ pub const DeclGen = struct {
586 try self.genDeclRef(decl_result_id, decl_index);586 try self.genDeclRef(decl_result_id, decl_index);
587 try self.variable(.global, result_id, result_ty_ref, decl_result_id);587 try self.variable(.global, result_id, result_ty_ref, decl_result_id);
588 },588 },
589 else => return self.todo("constant pointer of value type {s}", .{@tagName(val.tag())}),589 .slice => {
590 const slice = val.castTag(.slice).?.data;
591 var buf: Type.SlicePtrFieldTypeBuffer = undefined;
592
593 const ptr_id = self.spv.allocId();
594 try self.genConstant(ptr_id, ty.slicePtrFieldType(&buf), slice.ptr, .indirect);
595 const len_id = self.spv.allocId();
596 try self.genConstant(len_id, Type.usize, slice.len, .indirect);
597
598 const constituents = [_]IdRef{ ptr_id, len_id };
599 try section.emit(self.spv.gpa, .OpSpecConstantComposite, .{
600 .id_result_type = result_ty_id,
601 .id_result = result_id,
602 .constituents = &constituents,
603 });
604 },
605 else => return self.todo("pointer of value type {s}", .{@tagName(val.tag())}),
590 },606 },
591 .Fn => switch (repr) {607 .Fn => switch (repr) {
592 .direct => unreachable,608 .direct => unreachable,