diff options
| author | Robin Voetter <robin@voetter.nl> | 2022-12-11 13:39:29 +0100 |
|---|---|---|
| committer | Robin Voetter <robin@voetter.nl> | 2023-04-09 01:51:52 +0200 |
| commit | 12a3a8b100b7af4110cdc30de4def7d8f8d8c148 (patch) | |
| tree | a61daabe71dff5c0f898b9b4fb69e09fbc39c172 /src/codegen | |
| parent | e788dfa142f27717df1258009cadb61f314610dd (diff) | |
| download | zig-12a3a8b100b7af4110cdc30de4def7d8f8d8c148.tar.gz zig-12a3a8b100b7af4110cdc30de4def7d8f8d8c148.zip | |
spirv: slice constants
Implements lowering slice constants in the SPIR-V backend
Diffstat (limited to 'src/codegen')
| -rw-r--r-- | src/codegen/spirv.zig | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/codegen/spirv.zig b/src/codegen/spirv.zig index 7df4360c41..fb5cdbd126 100644 --- a/src/codegen/spirv.zig +++ b/src/codegen/spirv.zig @@ -586,7 +586,23 @@ pub const DeclGen = struct { try self.genDeclRef(decl_result_id, decl_index); try self.variable(.global, result_id, result_ty_ref, decl_result_id); }, - else => return self.todo("constant pointer of value type {s}", .{@tagName(val.tag())}), + .slice => { + const slice = val.castTag(.slice).?.data; + var buf: Type.SlicePtrFieldTypeBuffer = undefined; + + const ptr_id = self.spv.allocId(); + try self.genConstant(ptr_id, ty.slicePtrFieldType(&buf), slice.ptr, .indirect); + const len_id = self.spv.allocId(); + try self.genConstant(len_id, Type.usize, slice.len, .indirect); + + const constituents = [_]IdRef{ ptr_id, len_id }; + try section.emit(self.spv.gpa, .OpSpecConstantComposite, .{ + .id_result_type = result_ty_id, + .id_result = result_id, + .constituents = &constituents, + }); + }, + else => return self.todo("pointer of value type {s}", .{@tagName(val.tag())}), }, .Fn => switch (repr) { .direct => unreachable, |
