LLVM Community,
We are writing to propose promotion of the SPIR-V backend from its current experimental to an official status within the LLVM project. Over the past three years, the SPIR-V backend has seen significant advancements in functionality, stability, and community support and has become an important piece of software for multiple downstream projects.
Overview of SPIR-V and SPIR-V backend
SPIR-V is an intermediate representation defined by the Khronos Group. It serves as a cross-vendor unifying IR for programming heterogeneous accelerators such as GPUs, FPGAs, NPUs, and also CPUs. SPIR-V is integral to a rich ecosystem of high-level languages and APIs, including OpenCL, Vulkan, SYCL, GLSL, and HLSL, and works as a portable binary format for their compilers and drivers.
Current Status and Prospects
The SPIR-V backend has been deeply transformed and matured since its initial introduction as an experimental target in March 2021. We have incorporated feedback from the initial RFC and Phabricator comments, refined alignment with the general GlobalISel workflow, and introduced numerous customer-requested features, including SPIR-V extensions, builtins, and LLVM intrinsics. By improving the backend architecture and aligning it with GlobalISel requirements, we have enhanced the correctness of Machine IR between passes.
We have presented our solutions to these challenges at the LLVM Developers’ Meetings in 2022 and 2024. Contributors from multiple organizations, including AMD, Google, Intel, and Microsoft actively participate in the development and maintenance of the project.
The SPIR-V backend is built to serve both compute kernel and graphics shader developers equally. We collaborate closely with the Khronos OpenCL, SPIR, and Vulkan working groups to ensure that the backend aligns with the needs of the broader development community. Recently, Khronos Group acknowledged these efforts in its RFP, stating the following: “…due to ongoing developments and contributions from various SPIR-V vendors, the backend is anticipated to fully supplant the translator”.
When it comes to compute kernel support, the backend has achieved OpenCL 3.0 conformance. Over the past year, we also reached a ~99% SYCL CTS pass rate across all optimization levels and are nearing full SYCL conformance. With 31 SPIR-V extensions already implemented and more planned in the near future, the backend stands as a robust alternative to the Khronos SPIR-V LLVM Translator. Intel intends to leverage the SPIR-V backend in SYCL/DPC++ compiler and its XPU backend for Triton compilation flows.
There is ongoing work to support Vulkan and HLSL in the SPIR-V backend. Recently the community has also learned that Microsoft is going to adopt SPIR-V in DirectX 12. Their HLSL team already plays a vital role in the SPIR-V backend development.
The project also now facilitates integration and offers better compatibility with external tools and libraries previously relying on Khronos SPIR-V LLVM Translator to produce SPIR-V from LLVM IR.
Requirements for Official Targets
The SPIR-V backend satisfies the criteria specified for official targets in the LLVM Developer Policy:
- Maintainers: The backend is actively maintained by a team of dedicated contributors from multiple organizations.
- Active Community: Current development is discussed bi-weekly by LLVM SPIR-V Backend Working Group (open to the public).
- Code Compliance: The backend’s code conforms to LLVM’s coding standards and policies. There are no contentious issues affecting standard CodeGen flow.
- Documentation: SPIR-V spec and comprehensive documentation are available.
- Stability Period: The backend has been stable in-tree for more than two years now.
- Testing and Buildbots: Extensive test coverage with many small tests has been established. The backend passes the check-all build target, and a public GitHub Action validating SPIR-V was added to ensure correctness of new patches.
We have defined internal QA requirements and established processes to ensure rigorous testing and validation of the generated code, focusing on the backend’s stability and correctness. This effort included significantly enhancing test coverage with over 500 new LIT tests, integrating machine verifier and Khronos SPIR-V validation tooling as a standard practice for new test cases, run through GitHub Actions on each pull request. We also run regular working group meetings.
Future Work and Ongoing Efforts
Looking ahead, there are ideas to develop a SPIR-V consumer within LLVM, potentially sharing code with the backend. This initiative could benefit projects like SYCL/DPC++, providing a more integrated and efficient workflow. We are also working on porting additional tests from the Khronos SPIR-V LLVM Translator.
We encourage community contributions to support more SPIR-V extensions, address any remaining corner cases, or report any issues!
Request for Comments
Promoting the SPIR-V backend to an official target will significantly benefit the LLVM project and its users. We welcome any feedback from the community regarding this proposal.
CC: @VyacheslavLevytskyy, @Keenuts, @chouinard, @rengolin, @MaskRay, @jdoerfert, @nikic, @kuhar, @arsenm, @beanz, @bogner, @s-perron, @MrSidims, @AlexVlx, @efriedma-quic