diff options
| author | mlugg <mlugg@mlugg.co.uk> | 2025-06-03 22:42:10 +0100 |
|---|---|---|
| committer | mlugg <mlugg@mlugg.co.uk> | 2025-06-12 13:55:40 +0100 |
| commit | 89ba8859704486d526a75434f18d5a25ff89d57b (patch) | |
| tree | da2ee8131619f320818ae99778d270c8589f17cb /src/Zcu/PerThread.zig | |
| parent | c0df70706695a67089d4e691d3d3a0f77b90298f (diff) | |
| download | zig-89ba8859704486d526a75434f18d5a25ff89d57b.tar.gz zig-89ba8859704486d526a75434f18d5a25ff89d57b.zip | |
spirv: make the backend compile again
Unfortunately, the self-hosted SPIR-V backend is quite tightly coupled
with the self-hosted SPIR-V linker through its `Object` concept (which
is much like `llvm.Object`). Reworking this would be too much work for
this branch. So, for now, I have introduced a special case (similar to
the LLVM backend's special case) to the codegen logic when using this
backend. We will want to delete this special case at some point, but it
need not block this work.
Diffstat (limited to 'src/Zcu/PerThread.zig')
| -rw-r--r-- | src/Zcu/PerThread.zig | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/Zcu/PerThread.zig b/src/Zcu/PerThread.zig index 6475649a68..ffc103310b 100644 --- a/src/Zcu/PerThread.zig +++ b/src/Zcu/PerThread.zig @@ -4461,6 +4461,22 @@ fn runCodegenInner(pt: Zcu.PerThread, func_index: InternPool.Index, air: *Air) e } const lf = comp.bin_file orelse return error.NoLinkFile; + + // TODO: self-hosted codegen should always have a type of MIR; codegen should produce that MIR, + // and the linker should consume it. However, our SPIR-V backend is currently tightly coupled + // with our SPIR-V linker, so needs to work more like the LLVM backend. This should be fixed to + // unblock threaded codegen for SPIR-V. + if (lf.cast(.spirv)) |spirv_file| { + assert(pt.tid == .main); // SPIR-V has a lot of shared state + spirv_file.object.updateFunc(pt, func_index, air, &liveness) catch |err| { + switch (err) { + error.OutOfMemory => comp.link_diags.setAllocFailure(), + } + return error.CodegenFail; + }; + return error.BackendDoesNotProduceMir; + } + return codegen.generateFunction(lf, pt, zcu.navSrcLoc(nav), func_index, air, &liveness) catch |err| switch (err) { error.OutOfMemory, error.CodegenFail, |
