authorgravatar for alichraghi@proton.meAli Chraghi <alichraghi@proton.me> 2025-02-19 00:06:10+03:30
committergravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2025-02-24 19:12:33+01:00
loga0eec9ce9e2f4ae40729949957bef98a2513fef7
treef17a4ac38256a6b0601a68439f562dc477c57989
parent1cc388d5263058f9e9eecc410eea825a9a58e143
signaturebadge-check Signed by SSH key SHA256:ZS52FNyUv2WUXvO4njmVaFVO46RHojFuOrxRc4LuKzg

spirv: replace some unreachables with compile errors


4 files changed, 76 insertions(+), 42 deletions(-)

lib/std/Target/spirv.zig+24-18
...@@ -17,6 +17,7 @@ pub const Feature = enum {...@@ -17,6 +17,7 @@ pub const Feature = enum {
17 float64,17 float64,
18 addresses,18 addresses,
19 matrix,19 matrix,
20 storage_push_constant16,
20 kernel,21 kernel,
21 generic_pointer,22 generic_pointer,
22 vector16,23 vector16,
...@@ -35,92 +36,97 @@ pub const all_features = blk: {...@@ -35,92 +36,97 @@ pub const all_features = blk: {
35 var result: [len]CpuFeature = undefined;36 var result: [len]CpuFeature = undefined;
36 result[@intFromEnum(Feature.v1_0)] = .{37 result[@intFromEnum(Feature.v1_0)] = .{
37 .llvm_name = null,38 .llvm_name = null,
38 .description = "SPIR-V version 1.0",39 .description = "Enable version 1.0",
39 .dependencies = featureSet(&[_]Feature{}),40 .dependencies = featureSet(&[_]Feature{}),
40 };41 };
41 result[@intFromEnum(Feature.v1_1)] = .{42 result[@intFromEnum(Feature.v1_1)] = .{
42 .llvm_name = null,43 .llvm_name = null,
43 .description = "SPIR-V version 1.1",44 .description = "Enable version 1.1",
44 .dependencies = featureSet(&[_]Feature{.v1_0}),45 .dependencies = featureSet(&[_]Feature{.v1_0}),
45 };46 };
46 result[@intFromEnum(Feature.v1_2)] = .{47 result[@intFromEnum(Feature.v1_2)] = .{
47 .llvm_name = null,48 .llvm_name = null,
48 .description = "SPIR-V version 1.2",49 .description = "Enable version 1.2",
49 .dependencies = featureSet(&[_]Feature{.v1_1}),50 .dependencies = featureSet(&[_]Feature{.v1_1}),
50 };51 };
51 result[@intFromEnum(Feature.v1_3)] = .{52 result[@intFromEnum(Feature.v1_3)] = .{
52 .llvm_name = null,53 .llvm_name = null,
53 .description = "SPIR-V version 1.3",54 .description = "Enable version 1.3",
54 .dependencies = featureSet(&[_]Feature{.v1_2}),55 .dependencies = featureSet(&[_]Feature{.v1_2}),
55 };56 };
56 result[@intFromEnum(Feature.v1_4)] = .{57 result[@intFromEnum(Feature.v1_4)] = .{
57 .llvm_name = null,58 .llvm_name = null,
58 .description = "SPIR-V version 1.4",59 .description = "Enable version 1.4",
59 .dependencies = featureSet(&[_]Feature{.v1_3}),60 .dependencies = featureSet(&[_]Feature{.v1_3}),
60 };61 };
61 result[@intFromEnum(Feature.v1_5)] = .{62 result[@intFromEnum(Feature.v1_5)] = .{
62 .llvm_name = null,63 .llvm_name = null,
63 .description = "SPIR-V version 1.5",64 .description = "Enable version 1.5",
64 .dependencies = featureSet(&[_]Feature{.v1_4}),65 .dependencies = featureSet(&[_]Feature{.v1_4}),
65 };66 };
66 result[@intFromEnum(Feature.v1_6)] = .{67 result[@intFromEnum(Feature.v1_6)] = .{
67 .llvm_name = null,68 .llvm_name = null,
68 .description = "SPIR-V version 1.6",69 .description = "Enable version 1.6",
69 .dependencies = featureSet(&[_]Feature{.v1_5}),70 .dependencies = featureSet(&[_]Feature{.v1_5}),
70 };71 };
71 result[@intFromEnum(Feature.int8)] = .{72 result[@intFromEnum(Feature.int8)] = .{
72 .llvm_name = null,73 .llvm_name = null,
73 .description = "Enable SPIR-V capability Int8",74 .description = "Enable Int8 capability",
74 .dependencies = featureSet(&[_]Feature{.v1_0}),75 .dependencies = featureSet(&[_]Feature{.v1_0}),
75 };76 };
76 result[@intFromEnum(Feature.int16)] = .{77 result[@intFromEnum(Feature.int16)] = .{
77 .llvm_name = null,78 .llvm_name = null,
78 .description = "Enable SPIR-V capability Int16",79 .description = "Enable Int16 capability",
79 .dependencies = featureSet(&[_]Feature{.v1_0}),80 .dependencies = featureSet(&[_]Feature{.v1_0}),
80 };81 };
81 result[@intFromEnum(Feature.int64)] = .{82 result[@intFromEnum(Feature.int64)] = .{
82 .llvm_name = null,83 .llvm_name = null,
83 .description = "Enable SPIR-V capability Int64",84 .description = "Enable Int64 capability",
84 .dependencies = featureSet(&[_]Feature{.v1_0}),85 .dependencies = featureSet(&[_]Feature{.v1_0}),
85 };86 };
86 result[@intFromEnum(Feature.float16)] = .{87 result[@intFromEnum(Feature.float16)] = .{
87 .llvm_name = null,88 .llvm_name = null,
88 .description = "Enable SPIR-V capability Float16",89 .description = "Enable Float16 capability",
89 .dependencies = featureSet(&[_]Feature{.v1_0}),90 .dependencies = featureSet(&[_]Feature{.v1_0}),
90 };91 };
91 result[@intFromEnum(Feature.float64)] = .{92 result[@intFromEnum(Feature.float64)] = .{
92 .llvm_name = null,93 .llvm_name = null,
93 .description = "Enable SPIR-V capability Float64",94 .description = "Enable Float64 capability",
94 .dependencies = featureSet(&[_]Feature{.v1_0}),95 .dependencies = featureSet(&[_]Feature{.v1_0}),
95 };96 };
96 result[@intFromEnum(Feature.addresses)] = .{97 result[@intFromEnum(Feature.addresses)] = .{
97 .llvm_name = null,98 .llvm_name = null,
98 .description = "Enable SPIR-V capability Addresses",99 .description = "Enable either the Addresses capability or, SPV_KHR_physical_storage_buffer extension and the PhysicalStorageBufferAddresses capability",
99 .dependencies = featureSet(&[_]Feature{.v1_0}),100 .dependencies = featureSet(&[_]Feature{.v1_0}),
100 };101 };
101 result[@intFromEnum(Feature.matrix)] = .{102 result[@intFromEnum(Feature.matrix)] = .{
102 .llvm_name = null,103 .llvm_name = null,
103 .description = "Enable SPIR-V capability Matrix",104 .description = "Enable Matrix capability",
104 .dependencies = featureSet(&[_]Feature{.v1_0}),105 .dependencies = featureSet(&[_]Feature{.v1_0}),
105 };106 };
107 result[@intFromEnum(Feature.storage_push_constant16)] = .{
108 .llvm_name = null,
109 .description = "Enable SPV_KHR_16bit_storage extension and the StoragePushConstant16 capability",
110 .dependencies = featureSet(&[_]Feature{.v1_3}),
111 };
106 result[@intFromEnum(Feature.kernel)] = .{112 result[@intFromEnum(Feature.kernel)] = .{
107 .llvm_name = null,113 .llvm_name = null,
108 .description = "Enable SPIR-V capability Kernel",114 .description = "Enable Kernel capability",
109 .dependencies = featureSet(&[_]Feature{.v1_0}),115 .dependencies = featureSet(&[_]Feature{.v1_0}),
110 };116 };
111 result[@intFromEnum(Feature.generic_pointer)] = .{117 result[@intFromEnum(Feature.generic_pointer)] = .{
112 .llvm_name = null,118 .llvm_name = null,
113 .description = "Enable SPIR-V capability GenericPointer",119 .description = "Enable GenericPointer capability",
114 .dependencies = featureSet(&[_]Feature{ .v1_0, .addresses }),120 .dependencies = featureSet(&[_]Feature{ .v1_0, .addresses }),
115 };121 };
116 result[@intFromEnum(Feature.vector16)] = .{122 result[@intFromEnum(Feature.vector16)] = .{
117 .llvm_name = null,123 .llvm_name = null,
118 .description = "Enable SPIR-V capability Vector16",124 .description = "Enable Vector16 capability",
119 .dependencies = featureSet(&[_]Feature{ .v1_0, .kernel }),125 .dependencies = featureSet(&[_]Feature{ .v1_0, .kernel }),
120 };126 };
121 result[@intFromEnum(Feature.shader)] = .{127 result[@intFromEnum(Feature.shader)] = .{
122 .llvm_name = null,128 .llvm_name = null,
123 .description = "Enable SPIR-V capability Shader",129 .description = "Enable Shader capability",
124 .dependencies = featureSet(&[_]Feature{ .v1_0, .matrix }),130 .dependencies = featureSet(&[_]Feature{ .v1_0, .matrix }),
125 };131 };
126 const ti = @typeInfo(Feature);132 const ti = @typeInfo(Feature);
src/Zcu.zig+8
...@@ -3463,7 +3463,15 @@ fn clearCachedResolvedReferences(zcu: *Zcu) void {...@@ -3463,7 +3463,15 @@ fn clearCachedResolvedReferences(zcu: *Zcu) void {
3463}3463}
34643464
3465pub fn errorSetBits(zcu: *const Zcu) u16 {3465pub fn errorSetBits(zcu: *const Zcu) u16 {
3466 const target = zcu.getTarget();
3467
3466 if (zcu.error_limit == 0) return 0;3468 if (zcu.error_limit == 0) return 0;
3469 if (target.cpu.arch == .spirv64) {
3470 if (!std.Target.spirv.featureSetHas(target.cpu.features, .storage_push_constant16)) {
3471 return 32;
3472 }
3473 }
3474
3467 return @as(u16, std.math.log2_int(ErrorInt, zcu.error_limit)) + 1;3475 return @as(u16, std.math.log2_int(ErrorInt, zcu.error_limit)) + 1;
3468}3476}
34693477
src/codegen/spirv.zig+34-22
...@@ -1018,7 +1018,7 @@ const NavGen = struct {...@@ -1018,7 +1018,7 @@ const NavGen = struct {
1018 const comp_ty_id = try self.resolveType(ty, .direct);1018 const comp_ty_id = try self.resolveType(ty, .direct);
1019 return try self.constructComposite(comp_ty_id, constituents.items);1019 return try self.constructComposite(comp_ty_id, constituents.items);
1020 },1020 },
1021 .tuple_type => unreachable, // TODO1021 .tuple_type => return self.todo("implement tuple types", .{}),
1022 else => unreachable,1022 else => unreachable,
1023 },1023 },
1024 .un => |un| {1024 .un => |un| {
...@@ -1255,6 +1255,7 @@ const NavGen = struct {...@@ -1255,6 +1255,7 @@ const NavGen = struct {
12551255
1256 fn ptrType(self: *NavGen, child_ty: Type, storage_class: StorageClass, child_repr: Repr) !IdRef {1256 fn ptrType(self: *NavGen, child_ty: Type, storage_class: StorageClass, child_repr: Repr) !IdRef {
1257 const zcu = self.pt.zcu;1257 const zcu = self.pt.zcu;
1258 const ip = &zcu.intern_pool;
1258 const key = .{ child_ty.toIntern(), storage_class, child_repr };1259 const key = .{ child_ty.toIntern(), storage_class, child_repr };
1259 const entry = try self.ptr_types.getOrPut(self.gpa, key);1260 const entry = try self.ptr_types.getOrPut(self.gpa, key);
1260 if (entry.found_existing) {1261 if (entry.found_existing) {
...@@ -1285,7 +1286,12 @@ const NavGen = struct {...@@ -1285,7 +1286,12 @@ const NavGen = struct {
1285 }1286 }
1286 }1287 }
12871288
1288 try self.spv.decorate(result_id, .{ .ArrayStride = .{ .array_stride = @intCast(child_ty.abiSize(zcu)) } });1289 switch (ip.indexToKey(child_ty.toIntern())) {
1290 .func_type, .opaque_type => {},
1291 else => {
1292 try self.spv.decorate(result_id, .{ .ArrayStride = .{ .array_stride = @intCast(child_ty.abiSize(zcu)) } });
1293 },
1294 }
1289 }1295 }
12901296
1291 try self.spv.sections.types_globals_constants.emit(self.spv.gpa, .OpTypePointer, .{1297 try self.spv.sections.types_globals_constants.emit(self.spv.gpa, .OpTypePointer, .{
...@@ -1704,7 +1710,10 @@ const NavGen = struct {...@@ -1704,7 +1710,10 @@ const NavGen = struct {
1704 return result_id;1710 return result_id;
1705 },1711 },
1706 .@"union" => return try self.resolveUnionType(ty),1712 .@"union" => return try self.resolveUnionType(ty),
1707 .error_set => return try self.resolveType(Type.u16, repr),1713 .error_set => {
1714 const err_int_ty = try pt.errorIntType();
1715 return try self.resolveType(err_int_ty, repr);
1716 },
1708 .error_union => {1717 .error_union => {
1709 const payload_ty = ty.errorUnionPayload(zcu);1718 const payload_ty = ty.errorUnionPayload(zcu);
1710 const error_ty_id = try self.resolveType(Type.anyerror, .indirect);1719 const error_ty_id = try self.resolveType(Type.anyerror, .indirect);
...@@ -2329,7 +2338,7 @@ const NavGen = struct {...@@ -2329,7 +2338,7 @@ const NavGen = struct {
2329 // NOTE: Vulkan's FMA instruction does *NOT* produce the right values!2338 // NOTE: Vulkan's FMA instruction does *NOT* produce the right values!
2330 // its precision guarantees do NOT match zigs and it does NOT match OpenCLs!2339 // its precision guarantees do NOT match zigs and it does NOT match OpenCLs!
2331 // it needs to be emulated!2340 // it needs to be emulated!
2332 .vulkan, .opengl => unreachable, // TODO: See above2341 .vulkan, .opengl => return self.todo("implement fma operation for {s} os", .{@tagName(target.os.tag)}),
2333 else => unreachable,2342 else => unreachable,
2334 };2343 };
23352344
...@@ -2529,12 +2538,12 @@ const NavGen = struct {...@@ -2529,12 +2538,12 @@ const NavGen = struct {
2529 .vulkan, .opengl => switch (op) {2538 .vulkan, .opengl => switch (op) {
2530 .i_abs => 5, // SAbs2539 .i_abs => 5, // SAbs
2531 .f_abs => 4, // FAbs2540 .f_abs => 4, // FAbs
2532 .clz => unreachable, // TODO
2533 .ctz => unreachable, // TODO
2534 .floor => 8, // Floor2541 .floor => 8, // Floor
2535 .ceil => 9, // Ceil2542 .ceil => 9, // Ceil
2536 .trunc => 3, // Trunc2543 .trunc => 3, // Trunc
2537 .round => 1, // Round2544 .round => 1, // Round
2545 .clz,
2546 .ctz,
2538 .sqrt,2547 .sqrt,
2539 .sin,2548 .sin,
2540 .cos,2549 .cos,
...@@ -2544,7 +2553,7 @@ const NavGen = struct {...@@ -2544,7 +2553,7 @@ const NavGen = struct {
2544 .log,2553 .log,
2545 .log2,2554 .log2,
2546 .log10,2555 .log10,
2547 => unreachable, // TODO2556 => return self.todo("implement unary operation '{s}' for {s} os", .{ @tagName(op), @tagName(target.os.tag) }),
2548 else => unreachable,2557 else => unreachable,
2549 },2558 },
2550 else => unreachable,2559 else => unreachable,
...@@ -2810,6 +2819,8 @@ const NavGen = struct {...@@ -2810,6 +2819,8 @@ const NavGen = struct {
2810 /// TODO is to also write out the error as a function call parameter, and to somehow fetch2819 /// TODO is to also write out the error as a function call parameter, and to somehow fetch
2811 /// the name of an error in the text executor.2820 /// the name of an error in the text executor.
2812 fn generateTestEntryPoint(self: *NavGen, name: []const u8, spv_test_decl_index: SpvModule.Decl.Index) !void {2821 fn generateTestEntryPoint(self: *NavGen, name: []const u8, spv_test_decl_index: SpvModule.Decl.Index) !void {
2822 const target = self.spv.target;
2823
2813 const anyerror_ty_id = try self.resolveType(Type.anyerror, .direct);2824 const anyerror_ty_id = try self.resolveType(Type.anyerror, .direct);
2814 const ptr_anyerror_ty = try self.pt.ptrType(.{2825 const ptr_anyerror_ty = try self.pt.ptrType(.{
2815 .child = Type.anyerror.toIntern(),2826 .child = Type.anyerror.toIntern(),
...@@ -2819,12 +2830,12 @@ const NavGen = struct {...@@ -2819,12 +2830,12 @@ const NavGen = struct {
28192830
2820 const spv_decl_index = try self.spv.allocDecl(.func);2831 const spv_decl_index = try self.spv.allocDecl(.func);
2821 const kernel_id = self.spv.declPtr(spv_decl_index).result_id;2832 const kernel_id = self.spv.declPtr(spv_decl_index).result_id;
2822 // for some reason we don't need to decorate the push constant here...
2823 try self.spv.declareDeclDeps(spv_decl_index, &.{spv_test_decl_index});
28242833
2825 const section = &self.spv.sections.functions;2834 var decl_deps = std.ArrayList(SpvModule.Decl.Index).init(self.gpa);
2835 defer decl_deps.deinit();
2836 try decl_deps.append(spv_test_decl_index);
28262837
2827 const target = self.spv.target;2838 const section = &self.spv.sections.functions;
28282839
2829 const p_error_id = self.spv.allocId();2840 const p_error_id = self.spv.allocId();
2830 switch (target.os.tag) {2841 switch (target.os.tag) {
...@@ -2904,6 +2915,7 @@ const NavGen = struct {...@@ -2904,6 +2915,7 @@ const NavGen = struct {
29042915
2905 const spv_err_decl_index = self.object.error_push_constant.?.push_constant_ptr;2916 const spv_err_decl_index = self.object.error_push_constant.?.push_constant_ptr;
2906 const push_constant_id = self.spv.declPtr(spv_err_decl_index).result_id;2917 const push_constant_id = self.spv.declPtr(spv_err_decl_index).result_id;
2918 try decl_deps.append(spv_err_decl_index);
29072919
2908 const zero_id = try self.constInt(Type.u32, 0);2920 const zero_id = try self.constInt(Type.u32, 0);
2909 // We cannot use OpInBoundsAccessChain to dereference cross-storage class, so we have to use2921 // We cannot use OpInBoundsAccessChain to dereference cross-storage class, so we have to use
...@@ -2953,6 +2965,7 @@ const NavGen = struct {...@@ -2953,6 +2965,7 @@ const NavGen = struct {
2953 else => unreachable,2965 else => unreachable,
2954 };2966 };
29552967
2968 try self.spv.declareDeclDeps(spv_decl_index, decl_deps.items);
2956 try self.spv.declareEntryPoint(spv_decl_index, test_name, execution_mode);2969 try self.spv.declareEntryPoint(spv_decl_index, test_name, execution_mode);
2957 }2970 }
29582971
...@@ -3372,6 +3385,7 @@ const NavGen = struct {...@@ -3372,6 +3385,7 @@ const NavGen = struct {
3372 .switch_br => return self.airSwitchBr(inst),3385 .switch_br => return self.airSwitchBr(inst),
3373 .unreach, .trap => return self.airUnreach(),3386 .unreach, .trap => return self.airUnreach(),
33743387
3388 .dbg_empty_stmt => return,
3375 .dbg_stmt => return self.airDbgStmt(inst),3389 .dbg_stmt => return self.airDbgStmt(inst),
3376 .dbg_inline_block => try self.airDbgInlineBlock(inst),3390 .dbg_inline_block => try self.airDbgInlineBlock(inst),
3377 .dbg_var_ptr, .dbg_var_val, .dbg_arg_inline => return self.airDbgVar(inst),3391 .dbg_var_ptr, .dbg_var_val, .dbg_arg_inline => return self.airDbgVar(inst),
...@@ -3651,6 +3665,7 @@ const NavGen = struct {...@@ -3651,6 +3665,7 @@ const NavGen = struct {
3651 }3665 }
36523666
3653 fn abs(self: *NavGen, result_ty: Type, value: Temporary) !Temporary {3667 fn abs(self: *NavGen, result_ty: Type, value: Temporary) !Temporary {
3668 const zcu = self.pt.zcu;
3654 const operand_info = self.arithmeticTypeInfo(value.ty);3669 const operand_info = self.arithmeticTypeInfo(value.ty);
36553670
3656 switch (operand_info.class) {3671 switch (operand_info.class) {
...@@ -3658,11 +3673,9 @@ const NavGen = struct {...@@ -3658,11 +3673,9 @@ const NavGen = struct {
3658 .integer, .strange_integer => {3673 .integer, .strange_integer => {
3659 const abs_value = try self.buildUnary(.i_abs, value);3674 const abs_value = try self.buildUnary(.i_abs, value);
36603675
3661 // TODO: We may need to bitcast the result to a uint3676 if (value.ty.intInfo(zcu).signedness == .signed and self.spv.hasFeature(.shader)) {
3662 // depending on the result type. Do that when3677 return self.todo("perform bitcast after @abs", .{});
3663 // bitCast is implemented for vectors.3678 }
3664 // This is only relevant for Vulkan
3665 assert(self.spv.hasFeature(.kernel)); // TODO
36663679
3667 return try self.normalize(abs_value, self.arithmeticTypeInfo(result_ty));3680 return try self.normalize(abs_value, self.arithmeticTypeInfo(result_ty));
3668 },3681 },
...@@ -3980,8 +3993,6 @@ const NavGen = struct {...@@ -3980,8 +3993,6 @@ const NavGen = struct {
3980 .float, .bool => unreachable,3993 .float, .bool => unreachable,
3981 }3994 }
39823995
3983 assert(self.spv.hasFeature(.kernel)); // TODO
3984
3985 const count = try self.buildUnary(op, operand);3996 const count = try self.buildUnary(op, operand);
39863997
3987 // Result of OpenCL ctz/clz returns operand.ty, and we want result_ty.3998 // Result of OpenCL ctz/clz returns operand.ty, and we want result_ty.
...@@ -4307,7 +4318,8 @@ const NavGen = struct {...@@ -4307,7 +4318,8 @@ const NavGen = struct {
4307 },4318 },
4308 .error_set => {4319 .error_set => {
4309 assert(!is_vector);4320 assert(!is_vector);
4310 return try self.cmp(op, lhs.pun(Type.u16), rhs.pun(Type.u16));4321 const err_int_ty = try pt.errorIntType();
4322 return try self.cmp(op, lhs.pun(err_int_ty), rhs.pun(err_int_ty));
4311 },4323 },
4312 .pointer => {4324 .pointer => {
4313 assert(!is_vector);4325 assert(!is_vector);
...@@ -4411,7 +4423,7 @@ const NavGen = struct {...@@ -4411,7 +4423,7 @@ const NavGen = struct {
4411 else => unreachable,4423 else => unreachable,
4412 };4424 };
4413 },4425 },
4414 else => unreachable,4426 else => |ty| return self.todo("implement cmp operation for '{s}' type", .{@tagName(ty)}),
4415 }4427 }
44164428
4417 const info = self.arithmeticTypeInfo(scalar_ty);4429 const info = self.arithmeticTypeInfo(scalar_ty);
...@@ -5233,13 +5245,13 @@ const NavGen = struct {...@@ -5233,13 +5245,13 @@ const NavGen = struct {
5233 return self.accessChain(result_ty_id, object_ptr, &.{field_index});5245 return self.accessChain(result_ty_id, object_ptr, &.{field_index});
5234 },5246 },
5235 .@"struct" => switch (object_ty.containerLayout(zcu)) {5247 .@"struct" => switch (object_ty.containerLayout(zcu)) {
5236 .@"packed" => unreachable, // TODO5248 .@"packed" => return self.todo("implement field access for packed structs", .{}),
5237 else => {5249 else => {
5238 return try self.accessChain(result_ty_id, object_ptr, &.{field_index});5250 return try self.accessChain(result_ty_id, object_ptr, &.{field_index});
5239 },5251 },
5240 },5252 },
5241 .@"union" => switch (object_ty.containerLayout(zcu)) {5253 .@"union" => switch (object_ty.containerLayout(zcu)) {
5242 .@"packed" => unreachable, // TODO5254 .@"packed" => return self.todo("implement field access for packed unions", .{}),
5243 else => {5255 else => {
5244 const layout = self.unionLayout(object_ty);5256 const layout = self.unionLayout(object_ty);
5245 if (!layout.has_payload) {5257 if (!layout.has_payload) {
src/codegen/spirv/Module.zig+10-2
...@@ -345,22 +345,30 @@ pub fn finalize(self: *Module, a: Allocator) ![]Word {...@@ -345,22 +345,30 @@ pub fn finalize(self: *Module, a: Allocator) ![]Word {
345 if (self.target.cpu.features.isEnabled(feature.index)) {345 if (self.target.cpu.features.isEnabled(feature.index)) {
346 const feature_tag: std.Target.spirv.Feature = @enumFromInt(feature.index);346 const feature_tag: std.Target.spirv.Feature = @enumFromInt(feature.index);
347 switch (feature_tag) {347 switch (feature_tag) {
348 // Versions
348 .v1_0, .v1_1, .v1_2, .v1_3, .v1_4, .v1_5, .v1_6 => {},349 .v1_0, .v1_1, .v1_2, .v1_3, .v1_4, .v1_5, .v1_6 => {},
350 // Features with no dependencies
349 .int8 => try self.addCapability(.Int8),351 .int8 => try self.addCapability(.Int8),
350 .int16 => try self.addCapability(.Int16),352 .int16 => try self.addCapability(.Int16),
351 .int64 => try self.addCapability(.Int64),353 .int64 => try self.addCapability(.Int64),
352 .float16 => try self.addCapability(.Float16),354 .float16 => try self.addCapability(.Float16),
353 .float64 => try self.addCapability(.Float64),355 .float64 => try self.addCapability(.Float64),
356 .matrix => try self.addCapability(.Matrix),
357 .storage_push_constant16 => {
358 try self.addExtension("SPV_KHR_16bit_storage");
359 try self.addCapability(.StoragePushConstant16);
360 },
354 .addresses => if (self.hasFeature(.shader)) {361 .addresses => if (self.hasFeature(.shader)) {
355 try self.addCapability(.PhysicalStorageBufferAddresses);
356 try self.addExtension("SPV_KHR_physical_storage_buffer");362 try self.addExtension("SPV_KHR_physical_storage_buffer");
363 try self.addCapability(.PhysicalStorageBufferAddresses);
357 } else {364 } else {
358 try self.addCapability(.Addresses);365 try self.addCapability(.Addresses);
359 },366 },
360 .matrix => try self.addCapability(.Matrix),367 // Kernel
361 .kernel => try self.addCapability(.Kernel),368 .kernel => try self.addCapability(.Kernel),
362 .generic_pointer => try self.addCapability(.GenericPointer),369 .generic_pointer => try self.addCapability(.GenericPointer),
363 .vector16 => try self.addCapability(.Vector16),370 .vector16 => try self.addCapability(.Vector16),
371 // Shader
364 .shader => try self.addCapability(.Shader),372 .shader => try self.addCapability(.Shader),
365 }373 }
366 }374 }