Skip to content

Commit 66493f1

Browse files
committed
spirv: super basic composite int support
1 parent 40b424c commit 66493f1

9 files changed

+119
-71
lines changed

src/Zcu.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3539,7 +3539,7 @@ pub fn errorSetBits(zcu: *const Zcu) u16 {
35393539
const target = zcu.getTarget();
35403540

35413541
if (zcu.error_limit == 0) return 0;
3542-
if (target.cpu.arch == .spirv64) {
3542+
if (target.cpu.arch.isSpirV()) {
35433543
if (!std.Target.spirv.featureSetHas(target.cpu.features, .storage_push_constant16)) {
35443544
return 32;
35453545
}

src/codegen/spirv.zig

Lines changed: 103 additions & 59 deletions
Large diffs are not rendered by default.

src/codegen/spirv/Module.zig

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,11 @@ pub fn finalize(self: *Module, a: Allocator) ![]Word {
369369
// Emit memory model
370370
const addressing_model: spec.AddressingModel = blk: {
371371
if (self.hasFeature(.shader)) {
372-
assert(self.target.cpu.arch == .spirv64);
373-
if (self.hasFeature(.physical_storage_buffer)) break :blk .PhysicalStorageBuffer64;
372+
if (self.hasFeature(.physical_storage_buffer)) {
373+
assert(self.target.cpu.arch == .spirv64);
374+
break :blk .PhysicalStorageBuffer64;
375+
}
376+
assert(self.target.cpu.arch == .spirv);
374377
break :blk .Logical;
375378
}
376379

src/target.zig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,8 @@ pub fn zigBackend(target: std.Target, use_llvm: bool) std.builtin.CompilerBacken
809809
.aarch64, .aarch64_be => .stage2_aarch64,
810810
.riscv64 => .stage2_riscv64,
811811
.sparc64 => .stage2_sparc64,
812-
.spirv64 => .stage2_spirv64,
812+
.spirv32 => if (target.os.tag == .opencl) .stage2_spirv64 else .other,
813+
.spirv, .spirv64 => .stage2_spirv64,
813814
else => .other,
814815
};
815816
}

test/cases/compile_errors/@import_zon_bad_type.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ export fn testMutablePointer() void {
117117
// tmp.zig:37:38: note: imported here
118118
// neg_inf.zon:1:1: error: expected type '?u8'
119119
// tmp.zig:57:28: note: imported here
120-
// neg_inf.zon:1:1: error: expected type 'tmp.testNonExhaustiveEnum__enum_492'
120+
// neg_inf.zon:1:1: error: expected type 'tmp.testNonExhaustiveEnum__enum_494'
121121
// tmp.zig:62:39: note: imported here
122-
// neg_inf.zon:1:1: error: expected type 'tmp.testUntaggedUnion__union_494'
122+
// neg_inf.zon:1:1: error: expected type 'tmp.testUntaggedUnion__union_496'
123123
// tmp.zig:67:44: note: imported here
124-
// neg_inf.zon:1:1: error: expected type 'tmp.testTaggedUnionVoid__union_497'
124+
// neg_inf.zon:1:1: error: expected type 'tmp.testTaggedUnionVoid__union_499'
125125
// tmp.zig:72:50: note: imported here

test/cases/compile_errors/anytype_param_requires_comptime.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ pub export fn entry() void {
1515
// error
1616
//
1717
// :7:25: error: unable to resolve comptime value
18-
// :7:25: note: initializer of comptime-only struct 'tmp.S.foo__anon_466.C' must be comptime-known
18+
// :7:25: note: initializer of comptime-only struct 'tmp.S.foo__anon_468.C' must be comptime-known
1919
// :4:16: note: struct requires comptime because of this field
2020
// :4:16: note: types are not available at runtime

test/cases/compile_errors/bogus_method_call_on_slice.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ pub export fn entry2() void {
1616
//
1717
// :3:6: error: no field or member function named 'copy' in '[]const u8'
1818
// :9:8: error: no field or member function named 'bar' in '@TypeOf(.{})'
19-
// :12:18: error: no field or member function named 'bar' in 'tmp.entry2__struct_470'
19+
// :12:18: error: no field or member function named 'bar' in 'tmp.entry2__struct_472'
2020
// :12:6: note: struct declared here

test/cases/compile_errors/coerce_anon_struct.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ export fn foo() void {
66

77
// error
88
//
9-
// :4:16: error: expected type 'tmp.T', found 'tmp.foo__struct_459'
9+
// :4:16: error: expected type 'tmp.T', found 'tmp.foo__struct_461'
1010
// :3:16: note: struct declared here
1111
// :1:11: note: struct declared here

test/cases/compile_errors/redundant_try.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ comptime {
4444
//
4545
// :5:23: error: expected error union type, found 'comptime_int'
4646
// :10:23: error: expected error union type, found '@TypeOf(.{})'
47-
// :15:23: error: expected error union type, found 'tmp.test2__struct_496'
47+
// :15:23: error: expected error union type, found 'tmp.test2__struct_498'
4848
// :15:23: note: struct declared here
49-
// :20:27: error: expected error union type, found 'tmp.test3__struct_498'
49+
// :20:27: error: expected error union type, found 'tmp.test3__struct_500'
5050
// :20:27: note: struct declared here
5151
// :25:23: error: expected error union type, found 'struct { comptime *const [5:0]u8 = "hello" }'
5252
// :31:13: error: expected error union type, found 'u32'

0 commit comments

Comments
 (0)