Skip to content

Commit 3fb8684

Browse files
authored
Merge pull request #24661 from alichraghi/spv4
spirv: refactor and remove deduplication ISel
2 parents 5998a8c + cd4b03c commit 3fb8684

File tree

17 files changed

+8302
-12059
lines changed

17 files changed

+8302
-12059
lines changed

CMakeLists.txt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -553,11 +553,6 @@ set(ZIG_STAGE2_SOURCES
553553
src/codegen/c/Type.zig
554554
src/codegen/llvm.zig
555555
src/codegen/llvm/bindings.zig
556-
src/codegen/spirv.zig
557-
src/codegen/spirv/Assembler.zig
558-
src/codegen/spirv/Module.zig
559-
src/codegen/spirv/Section.zig
560-
src/codegen/spirv/spec.zig
561556
src/crash_report.zig
562557
src/dev.zig
563558
src/libs/freebsd.zig
@@ -620,11 +615,6 @@ set(ZIG_STAGE2_SOURCES
620615
src/link/Plan9.zig
621616
src/link/Plan9/aout.zig
622617
src/link/Queue.zig
623-
src/link/SpirV.zig
624-
src/link/SpirV/BinaryModule.zig
625-
src/link/SpirV/deduplicate.zig
626-
src/link/SpirV/lower_invocation_globals.zig
627-
src/link/SpirV/prune_unused.zig
628618
src/link/StringTable.zig
629619
src/link/Wasm.zig
630620
src/link/Wasm/Archive.zig

lib/std/Build/Watch.zig

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,13 @@ const Os = switch (builtin.os.tag) {
177177
const gop = try w.dir_table.getOrPut(gpa, path);
178178
if (!gop.found_existing) {
179179
var mount_id: MountId = undefined;
180-
const dir_handle = try Os.getDirHandle(gpa, path, &mount_id);
180+
const dir_handle = Os.getDirHandle(gpa, path, &mount_id) catch |err| switch (err) {
181+
error.FileNotFound => {
182+
std.debug.assert(w.dir_table.swapRemove(path));
183+
continue;
184+
},
185+
else => return err,
186+
};
181187
const fan_fd = blk: {
182188
const fd_gop = try w.os.poll_fds.getOrPut(gpa, mount_id);
183189
if (!fd_gop.found_existing) {

src/Zcu.zig

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3651,9 +3651,8 @@ pub fn errorSetBits(zcu: *const Zcu) u16 {
36513651

36523652
if (zcu.error_limit == 0) return 0;
36533653
if (target.cpu.arch.isSpirV()) {
3654-
if (!target.cpu.has(.spirv, .storage_push_constant16)) {
3655-
return 32;
3656-
}
3654+
// As expected by https://github.com/Snektron/zig-spirv-test-executor
3655+
if (zcu.comp.config.is_test) return 32;
36573656
}
36583657

36593658
return @as(u16, std.math.log2_int(ErrorInt, zcu.error_limit)) + 1;

src/Zcu/PerThread.zig

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4459,13 +4459,10 @@ fn runCodegenInner(pt: Zcu.PerThread, func_index: InternPool.Index, air: *Air) e
44594459

44604460
const lf = comp.bin_file orelse return error.NoLinkFile;
44614461

4462-
// TODO: self-hosted codegen should always have a type of MIR; codegen should produce that MIR,
4463-
// and the linker should consume it. However, our SPIR-V backend is currently tightly coupled
4464-
// with our SPIR-V linker, so needs to work more like the LLVM backend. This should be fixed to
4465-
// unblock threaded codegen for SPIR-V.
4462+
// Just like LLVM, the SPIR-V backend can't multi-threaded due to SPIR-V design limitations.
44664463
if (lf.cast(.spirv)) |spirv_file| {
44674464
assert(pt.tid == .main); // SPIR-V has a lot of shared state
4468-
spirv_file.object.updateFunc(pt, func_index, air, &liveness) catch |err| {
4465+
spirv_file.updateFunc(pt, func_index, air, &liveness) catch |err| {
44694466
switch (err) {
44704467
error.OutOfMemory => comp.link_diags.setAllocFailure(),
44714468
}

src/codegen.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fn importBackend(comptime backend: std.builtin.CompilerBackend) type {
5757
.stage2_powerpc => unreachable,
5858
.stage2_riscv64 => @import("arch/riscv64/CodeGen.zig"),
5959
.stage2_sparc64 => @import("arch/sparc64/CodeGen.zig"),
60-
.stage2_spirv => @import("codegen/spirv.zig"),
60+
.stage2_spirv => @import("codegen/spirv/CodeGen.zig"),
6161
.stage2_wasm => @import("arch/wasm/CodeGen.zig"),
6262
.stage2_x86, .stage2_x86_64 => @import("arch/x86_64/CodeGen.zig"),
6363
_ => unreachable,

0 commit comments

Comments
 (0)