authorgravatar for alichraghi@proton.meAli Chraghi <alichraghi@proton.me> 2026-06-17 01:54:10+03:30
committergravatar for alichraghi@noreply.codeberg.orgAli Cheraghi <alichraghi@noreply.codeberg.org> 2026-06-18 13:38:58+02:00
log65e74dfbda3e50ba09a2b59061ccb90a7dd68e9f
tree60faead2672c05bc933745300d323086937e7346
parent508cbec69455d82c0e9bb5ae47f064ab33460469

@extern: add flat decoration


24 files changed, 133 insertions(+), 19 deletions(-)

lib/std/lang.zig+2-1
......@@ -1173,11 +1173,12 @@ pub const ExternOptions = struct {
11731173
11741174 pub const Decoration = union(enum) {
11751175 location: u32,
1176 flat: u32,
11761177 descriptor: Descriptor,
11771178
11781179 pub const Descriptor = struct {
1179 binding: u32,
11801180 set: u32,
1181 binding: u32,
11811182 };
11821183 };
11831184
src/InternPool.zig+4-4
......@@ -5406,16 +5406,15 @@ pub const Tag = enum(u8) {
54065406 _: u23 = 0,
54075407
54085408 pub const Source = enum(u1) { builtin, syntax };
5409 pub const DecorationType = enum(u2) { none, location, descriptor };
5409 pub const DecorationType = enum(u2) { none, location, descriptor, flat };
54105410 };
54115411
54125412 pub fn decoration(self: Extern) ?std.lang.ExternOptions.Decoration {
54135413 return switch (self.flags.decoration_type) {
54145414 .none => null,
5415 .location => std.lang.ExternOptions.Decoration{
5416 .location = self.location_or_descriptor_set,
5417 },
5415 .location => std.lang.ExternOptions.Decoration{ .location = self.location_or_descriptor_set },
54185416 .descriptor => std.lang.ExternOptions.Decoration{ .descriptor = .{ .set = self.location_or_descriptor_set, .binding = self.descriptor_binding } },
5417 .flat => std.lang.ExternOptions.Decoration{ .flat = self.location_or_descriptor_set },
54195418 };
54205419 }
54215420 };
......@@ -9199,6 +9198,7 @@ pub fn getExtern(
91999198 }) catch unreachable; // capacity asserted above
92009199 const decoration_type, const location_or_descriptor_set, const descriptor_binding = if (key.decoration) |decoration| switch (decoration) {
92019200 .location => |location| .{ Tag.Extern.Flags.DecorationType.location, location, undefined },
9201 .flat => |location| .{ Tag.Extern.Flags.DecorationType.flat, location, undefined },
92029202 .descriptor => |descriptor| .{ Tag.Extern.Flags.DecorationType.descriptor, descriptor.set, descriptor.binding },
92039203 } else .{ Tag.Extern.Flags.DecorationType.none, undefined, undefined };
92049204 const extra_index = addExtraAssumeCapacity(extra, Tag.Extern{
src/Sema.zig+7
......@@ -25021,6 +25021,13 @@ fn zirBuiltinExtern(
2502125021 .pcrel => if (options.visibility == .default) return sema.fail(block, options_src, "cannot require a pc-relative relocation to a symbol with default visibility", .{}),
2502225022 }
2502325023
25024 if (options.decoration) |decoration| switch (decoration) {
25025 .flat => if (ptr_info.flags.address_space != .input) {
25026 return sema.fail(block, options_src, "'flat' decoration requires 'input' address space", .{});
25027 },
25028 .location, .descriptor => {},
25029 };
25030
2502425031 // TODO: error for threadlocal functions, non-const functions, etc
2502525032
2502625033 const extern_val = try pt.getExtern(.{
src/codegen/spirv/Assembler.zig+9
......@@ -393,6 +393,15 @@ fn processGenericInstruction(ass: *Assembler) !?AsmValue {
393393 const actual_word_count = section.instructions.items.len - first_word;
394394 section.instructions.items[first_word] |= @as(u32, @as(u16, @intCast(actual_word_count))) << 16 | @intFromEnum(ass.inst.opcode);
395395
396 switch (ass.inst.opcode) {
397 .OpKill,
398 .OpReturn,
399 .OpReturnValue,
400 .OpUnreachable,
401 => ass.cg.block_terminated = true,
402 else => {},
403 }
404
396405 if (maybe_result_id) |result| return .{ .value = result };
397406 return null;
398407}
src/codegen/spirv/CodeGen.zig+30-10
......@@ -118,6 +118,10 @@ block_stack: std.ArrayList(*Block) = .empty,
118118block_results: std.AutoHashMapUnmanaged(Air.Inst.Index, Id) = .empty,
119119base_line: u32,
120120block_label: Id = .none,
121/// Whether the current block has been terminated by a terminator
122/// instruction (e.g. OpKill from inline assembly). When true, no further
123/// branch instructions should be emitted for the current block.
124block_terminated: bool = false,
121125next_arg_index: u32 = 0,
122126args: std.ArrayList(Id) = .empty,
123127virtual_allocas: std.AutoHashMapUnmanaged(Id, ?Id) = .empty,
......@@ -428,10 +432,13 @@ pub fn genNav(cg: *CodeGen, do_codegen: bool) Error!void {
428432 if (ty.zigTypeTag(zcu) == .@"struct" and storage_class != .physical_storage_buffer) {
429433 try cg.module.decorate(ty_id, .block);
430434 }
431 try cg.module.decorate(ptr_ty_id, .{
432 .array_stride = .{ .array_stride = @intCast(ty.abiSize(zcu)) },
433 });
434 try cg.decorateLayout(ty, ty_id);
435
436 if (ty.hasRuntimeBits(zcu)) {
437 try cg.module.decorate(ptr_ty_id, .{
438 .array_stride = .{ .array_stride = @intCast(ty.abiSize(zcu)) },
439 });
440 try cg.decorateLayout(ty, ty_id);
441 }
435442 },
436443 else => {},
437444 }
......@@ -445,6 +452,10 @@ pub fn genNav(cg: *CodeGen, do_codegen: bool) Error!void {
445452 .location = .{ .location = location },
446453 });
447454 },
455 .flat => |location| {
456 try cg.module.decorate(result_id, .{ .location = .{ .location = location } });
457 try cg.module.decorate(result_id, .flat);
458 },
448459 .descriptor => |descriptor| {
449460 if (storage_class != .storage_buffer and storage_class != .uniform and storage_class != .uniform_constant) {
450461 return cg.fail("storage class must be one of (storage_buffer, uniform, uniform_constant) but is {s}", .{@tagName(storage_class)});
......@@ -770,6 +781,7 @@ fn addFunctionDep(cg: *CodeGen, decl_index: Module.Decl.Index, storage_class: St
770781fn beginSpvBlock(cg: *CodeGen, label: Id) !void {
771782 try cg.body.emit(cg.module.gpa, .OpLabel, .{ .id_result = label });
772783 cg.block_label = label;
784 cg.block_terminated = false;
773785}
774786
775787/// Return the amount of bits in the largest supported integer type. This is either 32 (always supported), or 64 (if
......@@ -2038,10 +2050,12 @@ fn resolveType(cg: *CodeGen, ty: Type, repr: Repr) Error!Id {
20382050 const elem_ty: Type = .fromInterned(spirv_type.ty);
20392051 const elem_ty_id = try cg.resolveType(elem_ty, .indirect);
20402052 const result_id = try cg.module.runtimeArrayType(ip_index, elem_ty_id);
2041 try cg.module.decorate(
2042 result_id,
2043 .{ .array_stride = .{ .array_stride = @intCast(elem_ty.abiSize(zcu)) } },
2044 );
2053
2054 if (elem_ty.hasRuntimeBits(zcu)) {
2055 try cg.module.decorate(result_id, .{ .array_stride = .{
2056 .array_stride = @intCast(elem_ty.abiSize(zcu)),
2057 } });
2058 }
20452059 return result_id;
20462060 },
20472061 }
......@@ -6564,6 +6578,8 @@ fn structuredNextBlock(cg: *CodeGen, incoming: []const Block.Incoming) !Id {
65646578/// terminating a body, there should be no instructions after it.
65656579/// This function should only be called with structured control flow generation.
65666580fn structuredBreak(cg: *CodeGen, target_block: Id) !void {
6581 if (cg.block_terminated) return;
6582
65676583 const gpa = cg.module.gpa;
65686584 const sblock = cg.block_stack.getLast().?;
65696585 const merge_block = switch (sblock.*) {
......@@ -6833,7 +6849,9 @@ fn airCondBr(cg: *CodeGen, inst: Air.Inst.Index) !void {
68336849 .next_block = then_next,
68346850 };
68356851
6836 try cg.body.emit(gpa, .OpBranch, .{ .target_label = merge_label });
6852 if (!cg.block_terminated) {
6853 try cg.body.emit(gpa, .OpBranch, .{ .target_label = merge_label });
6854 }
68376855
68386856 try cg.beginSpvBlock(else_label);
68396857 const else_next = try cg.genStructuredBody(.selection, else_body);
......@@ -6842,7 +6860,9 @@ fn airCondBr(cg: *CodeGen, inst: Air.Inst.Index) !void {
68426860 .next_block = else_next,
68436861 };
68446862
6845 try cg.body.emit(gpa, .OpBranch, .{ .target_label = merge_label });
6863 if (!cg.block_terminated) {
6864 try cg.body.emit(gpa, .OpBranch, .{ .target_label = merge_label });
6865 }
68466866
68476867 try cg.beginSpvBlock(merge_label);
68486868 const next_block = try cg.structuredNextBlock(&.{ then_incoming, else_incoming });
test/behavior/basic.zig+4
......@@ -302,6 +302,8 @@ test "compile time global reinterpret" {
302302}
303303
304304test "cast undefined" {
305 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
306
305307 const array: [100]u8 = undefined;
306308 const slice = @as([]const u8, &array);
307309 testCastUndefined(slice);
......@@ -372,6 +374,7 @@ test "call function pointer in struct" {
372374 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
373375 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
374376 try expect(mem.eql(u8, f3(true), "a"));
377 try expect(mem.eql(u8, f3(false), "b"));
375378}
376379
377380fn f3(x: bool) []const u8 {
......@@ -412,6 +415,7 @@ test "call result of if else expression" {
412415 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
413416
414417 try expect(mem.eql(u8, f2(true), "a"));
418 try expect(mem.eql(u8, f2(false), "b"));
415419}
416420fn f2(x: bool) []const u8 {
417421 return (if (x) &fA else &fB)();
test/behavior/bitcast.zig+3
......@@ -35,6 +35,8 @@ test "@bitCast iX -> uX exotic integers" {
3535 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
3636 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
3737 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
38 if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
39
3840 const bit_values = [_]usize{ 1, 48, 27, 512, 493, 293, 125, 204, 112 };
3941
4042 inline for (bit_values) |bits| {
......@@ -77,6 +79,7 @@ test "bitcast uX to bytes" {
7779 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
7880 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
7981 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
82 if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
8083
8184 const bit_values = [_]usize{ 1, 48, 27, 512, 493, 293, 125, 204, 112 };
8285 inline for (bit_values) |bits| {
test/behavior/cast.zig+13
......@@ -103,6 +103,10 @@ test "comptime_int @floatFromInt" {
103103}
104104
105105test "@floatFromInt" {
106 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
107 if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
108 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
109
106110 const S = struct {
107111 fn doTheTest() !void {
108112 try testIntToFloat(-2);
......@@ -128,9 +132,13 @@ fn testIntFromFloat(comptime F: type, f: F, comptime I: type, i: I) !void {
128132
129133test "@intFromFloat > 128 bits" {
130134 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
135 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
131136 if (builtin.zig_backend == .stage2_llvm) return error.SkipZigTest;
137 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
132138
139 try testIntFromFloat(f16, 1024, u140, 1024);
133140 try testIntFromFloat(f16, -1024, i140, -1024);
141
134142 try testIntFromFloat(f32, 1 << 24, u140, 1 << 24);
135143 try testIntFromFloat(f32, -1 << 24, i140, -1 << 24);
136144
......@@ -152,10 +160,13 @@ test "@floatFromInt > 128 bits" {
152160 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
153161 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
154162 if (builtin.zig_backend == .stage2_llvm) return error.SkipZigTest;
163 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
155164
156165 try testFloatFromInt(u140, 1024, f16, 1024);
166 try testFloatFromInt(i140, -1024, f16, -1024);
157167
158168 try testFloatFromInt(u140, 1 << 24, f32, 1 << 24);
169 try testFloatFromInt(i140, -1 << 24, f32, -1 << 24);
159170
160171 try testFloatFromInt(u200, 1 << 53, f64, 1 << 53);
161172 try testFloatFromInt(i200, -1 << 53, f64, -1 << 53);
......@@ -416,9 +427,11 @@ test "implicit cast from *[N]T to [*c]T" {
416427 var y: [*c]u16 = &x;
417428
418429 try expect(std.mem.eql(u16, x[0..4], y[0..4]));
430 x[0] = 8;
419431 y[3] = 6;
420432 try expect(std.mem.eql(u16, x[0..4], y[0..4]));
421433}
434
422435test "*usize to *void" {
423436 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
424437
test/behavior/cast_int.zig+4
......@@ -8,6 +8,8 @@ const minInt = std.math.minInt;
88test "@intCast i32 to u7" {
99 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
1010 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
11 if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
12
1113 var x: u128 = maxInt(u128);
1214 var y: i32 = 120;
1315 _ = .{ &x, &y };
......@@ -143,6 +145,7 @@ test "@intCast <= 64 bits" {
143145 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
144146 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
145147 try testIntCast(i32, minInt(i32), i64, minInt(i32));
148 try testIntCast(i32, maxInt(i32), i64, maxInt(i32));
146149 try testIntCast(u32, maxInt(u32), u64, maxInt(u32));
147150 try testIntCast(u32, maxInt(i32), i64, maxInt(i32));
148151 try testIntCast(u32, maxInt(u32), i64, maxInt(u32));
......@@ -169,6 +172,7 @@ test "@intCast > 128 bits" {
169172 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
170173
171174 try testIntCast(u8, 123, u140, 123);
175 try testIntCast(u64, 1 << 63, u140, 1 << 63);
172176 try testIntCast(u127, maxInt(u127), u140, maxInt(u127));
173177 try testIntCast(i8, -42, i140, -42);
174178 try testIntCast(i64, minInt(i64), i140, minInt(i64));
test/behavior/enum.zig+6
......@@ -932,6 +932,7 @@ test "constant enum initialization with differing sizes" {
932932 if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
933933 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
934934 try test3_1(test3_foo);
935 try test3_2(test3_bar);
935936}
936937const Test3Foo = union(enum) {
937938 One: void,
......@@ -972,7 +973,9 @@ test "@tagName" {
972973 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
973974 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
974975 if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
976 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
975977
978 try expect(mem.eql(u8, testEnumTagNameBare(BareNumber.Three), "Three"));
976979 comptime assert(mem.eql(u8, testEnumTagNameBare(BareNumber.Three), "Three"));
977980}
978981
......@@ -987,7 +990,9 @@ test "@tagName non-exhaustive enum" {
987990 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
988991 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
989992 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
993 if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
990994
995 try expect(mem.eql(u8, testEnumTagNameBare(NonExhaustive.B), "B"));
991996 comptime assert(mem.eql(u8, testEnumTagNameBare(NonExhaustive.B), "B"));
992997}
993998const NonExhaustive = enum(u8) { A, B, _ };
......@@ -1029,6 +1034,7 @@ test "@tagName on enum literals" {
10291034 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
10301035
10311036 try expect(mem.eql(u8, @tagName(.FooBar), "FooBar"));
1037 comptime assert(mem.eql(u8, @tagName(.FooBar), "FooBar"));
10321038}
10331039
10341040test "tag name with signed enum values" {
test/behavior/error.zig+10
......@@ -145,11 +145,17 @@ test "implicit cast to optional to error union to return result loc" {
145145}
146146
147147test "fn returning empty error set can be passed as fn returning any error" {
148 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
149
150 entry();
151 comptime entry();
148152}
149153
150154test "fn returning empty error set can be passed as fn returning any error - pointer" {
151155 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
156
152157 entryPtr();
158 comptime entryPtr();
153159}
154160fn entry() void {
155161 foo2(bar2);
......@@ -362,8 +368,10 @@ test "error: Infer error set from literals" {
362368 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
363369
364370 _ = nullLiteral("n") catch |err| handleErrors(err);
371 _ = floatLiteral("n") catch |err| handleErrors(err);
365372 _ = intLiteral("n") catch |err| handleErrors(err);
366373 _ = comptime nullLiteral("n") catch |err| handleErrors(err);
374 _ = comptime floatLiteral("n") catch |err| handleErrors(err);
367375 _ = comptime intLiteral("n") catch |err| handleErrors(err);
368376}
369377
......@@ -689,6 +697,7 @@ test "coerce error set to the current inferred error set" {
689697test "error union payload is properly aligned" {
690698 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
691699 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
700 if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
692701
693702 const S = struct {
694703 a: u128,
......@@ -746,6 +755,7 @@ test "pointer to error union payload" {
746755 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
747756 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
748757 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
758 if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
749759
750760 var err_union: anyerror!u8 = 15;
751761
test/behavior/eval.zig-1
......@@ -1181,7 +1181,6 @@ test "lazy sizeof is resolved in division" {
11811181}
11821182
11831183test "lazy sizeof union tag size in compare" {
1184
11851184 const A = union(enum) {
11861185 a: void,
11871186 b: void,
test/behavior/floatop.zig+8
......@@ -134,6 +134,8 @@ test "cmp f32" {
134134}
135135
136136test "cmp f64" {
137 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
138
137139 try testCmp(f64);
138140 try comptime testCmp(f64);
139141}
......@@ -142,7 +144,9 @@ test "cmp f128" {
142144 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
143145 if (builtin.zig_backend == .stage2_c and builtin.cpu.arch.isArm()) return error.SkipZigTest;
144146 if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
147 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
145148
149 try testCmp(f128);
146150 try comptime testCmp(f128);
147151}
148152
......@@ -150,7 +154,10 @@ test "cmp f80/c_longdouble" {
150154 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
151155 if (builtin.zig_backend == .stage2_c and builtin.cpu.arch.isArm()) return error.SkipZigTest;
152156 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
157 if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
153158
159 try testCmp(f80);
160 try comptime testCmp(f80);
154161 try testCmp(c_longdouble);
155162 try comptime testCmp(c_longdouble);
156163}
......@@ -225,6 +232,7 @@ test "vector cmp f32" {
225232 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
226233 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
227234 if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
235 if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch.isArm()) return error.SkipZigTest;
228236 if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch.isPowerPC64()) return error.SkipZigTest;
229237 if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch == .hexagon) return error.SkipZigTest;
230238
test/behavior/fn.zig+6
......@@ -292,6 +292,9 @@ fn voidFun(a: i32, b: void, c: i32, d: void) !void {
292292
293293test "call function with empty string" {
294294 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
295 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
296
297 acceptsString("");
295298}
296299
297300fn acceptsString(foo: []u8) void {
......@@ -302,7 +305,9 @@ test "function pointers" {
302305 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
303306 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
304307 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
308
305309 const fns = [_]*const @TypeOf(fn1){
310 &fn1,
306311 &fn2,
307312 &fn3,
308313 &fn4,
......@@ -440,6 +445,7 @@ test "method call with optional and error union first param" {
440445 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
441446
442447 const S = struct {
448 x: i32 = 1234,
443449
444450 fn opt(s: ?@This()) !void {
445451 try expect(s.?.x == 1234);
test/behavior/math.zig+1-1
......@@ -574,6 +574,7 @@ test "large integer division" {
574574 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
575575 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest;
576576 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
577 if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
577578
578579 {
579580 var numerator: u256 = 99999999999999999997315645440;
......@@ -654,7 +655,6 @@ fn testSignedWrappingEval(x: i32) !void {
654655}
655656
656657test "signed negation wrapping" {
657
658658 try testSignedNegationWrappingEval(minInt(i16));
659659 try comptime testSignedNegationWrappingEval(minInt(i16));
660660}
test/behavior/maximum_minimum.zig+1
......@@ -350,6 +350,7 @@ test "@min/@max with runtime signed and unsigned integers of same size" {
350350
351351test "@min/@max with runtime vectors of signed and unsigned integers of same size" {
352352 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
353 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
353354 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
354355 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
355356 if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
test/behavior/memcpy.zig-1
......@@ -168,7 +168,6 @@ test "@memcpy with sentinel" {
168168}
169169
170170test "@memcpy no sentinel source into sentinel destination" {
171
172171 const S = struct {
173172 fn doTheTest() void {
174173 const src: []const u8 = &.{ 1, 2, 3 };
test/behavior/muladd.zig+3
......@@ -34,6 +34,7 @@ test "@mulAdd f16" {
3434 if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
3535
3636 try comptime testMulAdd16();
37 try testMulAdd16();
3738}
3839
3940fn testMulAdd16() !void {
......@@ -48,7 +49,9 @@ test "@mulAdd f80" {
4849 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
4950 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
5051 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
52 if (builtin.zig_backend == .stage2_c and builtin.cpu.arch.isArm()) return error.SkipZigTest;
5153 if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
54
5255 try comptime testMulAdd80();
5356 try testMulAdd80();
5457}
test/behavior/optional.zig+1
......@@ -522,6 +522,7 @@ test "alignment of wrapping an optional payload" {
522522 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
523523 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
524524 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
525 if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
525526
526527 const S = struct {
527528 const I = extern struct { x: i128 };
test/behavior/packed-struct.zig+3
......@@ -227,6 +227,8 @@ test "nested packed structs" {
227227test "regular in irregular packed struct" {
228228 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
229229 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
230 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
231
230232 const Irregular = packed struct {
231233 bar: Regular = Regular{},
232234 _: u24 = 0,
......@@ -247,6 +249,7 @@ test "nested packed struct unaligned" {
247249 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
248250 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
249251 const S1 = packed struct {
252 a: u4,
250253 b: u4,
251254 c: u8,
252255 };
test/behavior/struct.zig+3
......@@ -446,6 +446,7 @@ test "runtime struct initialization of bitfield" {
446446 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
447447 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
448448 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
449 if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
449450
450451 const s1 = Nibbles{
451452 .x = x1,
......@@ -503,6 +504,7 @@ test "implicit cast packed struct field to const ptr" {
503504 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
504505 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
505506 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
507 if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; // TODO
506508
507509 const LevelUpMove = packed struct {
508510 move_id: u9,
......@@ -536,6 +538,7 @@ test "packed struct with non-ABI-aligned field" {
536538 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
537539 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
538540 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
541 if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
539542
540543 const S = packed struct {
541544 x: u9,
test/behavior/vector.zig+2
......@@ -415,6 +415,7 @@ test "vector @splat" {
415415
416416test "load vector elements via comptime index" {
417417 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
418 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
418419 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
419420
420421 const S = struct {
......@@ -617,6 +618,7 @@ test "vector division operators" {
617618test "vector bitwise not operator" {
618619 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
619620 if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
621 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
620622 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
621623 if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
622624
test/behavior/while.zig-1
......@@ -38,7 +38,6 @@ fn staticWhileLoop2() i32 {
3838}
3939
4040test "while with continue expression" {
41
4241 var sum: i32 = 0;
4342 {
4443 var i: i32 = 0;
test/cases/compile_errors/extern_spirv_decoration_validation.zig created+13
......@@ -0,0 +1,13 @@
1const x = @extern(*addrspace(.output) u32, .{
2 .name = "x",
3 .decoration = .{ .flat = 0 },
4});
5comptime {
6 _ = x;
7}
8
9// error
10// backend=selfhosted
11// target=spirv64-vulkan
12//
13// :1:45: error: 'flat' decoration requires 'input' address space