-
Notifications
You must be signed in to change notification settings - Fork 60
Home
The khronos/spirv-3.6.1 branch of this repository contains source code for the LLVM/SPIR-V Bi-Directional Translator, a library for translating between LLVM and SPIR-V.
The LLVM/SPIR-V Bi-Directional Translator is open source software. You may freely distribute it under the terms of the license agreement found in LICENSE.txt.
Currently it accepts LLVM bitcodes compatible with SPIR 1.2/2.0 standards, and SPIR-V friendly format.
The files/directories are related to the translator:
- include/Support/SPIRV.h - header file
- lib/SPIRV - library for SPIR-V in-memory representation, decoder/encoder and LLVM/SPIR-V translator
- tools/llvm-spirv - command line utility for translating between LLVM bitcode and SPIR-V binary
- Clone the khronos/spirv-3.6.1 branch.
- Follow LLVM build instructions.
llvm-spirv only accepts SPIR 1.2/2.0 or LLVM bitcode following a SPIR-V friendly format.
The Open Source SPIR producer can be used to compile OpenCL 1.2/2.0 C source code to SPIR 1.2/2.0.
To translate between SPIR 1.2/2.0 and SPIR-V:
-
Follow the instructions provided by the open source SPIR producer website to use clang to compile OpenCL C source code to SPIR 1.2/2.0 binary.
-
Execute the following command to translate input.bc to input.spv
llvm-spirv input.bc
-
Execute the following command to translate input.spv to input.bc
llvm-spirv -r input.spv
-
Other options accepted by llvm-spirv
- -o file_name - to specify output name
- -spirv-debug - output debugging information
- -spirv-text - read/write SPIR-V in an internal textual format for debugging purpose. The textual format is not defined by SPIR-V spec.