Initial import of Khronos LLVM-SPIRV from github

URL: https://github.com/KhronosGroup/SPIRV-LLVM.git
Upstream branch khronos/spirv-3.8
Upstream commit c24897cf4f7b6e38448175219e15429dd2e7b53c
19954 files changed
tree: 67590d968ee34b877145e836972d66332e80703a
  1. autoconf/
  2. bindings/
  3. cmake/
  4. docs/
  5. examples/
  6. include/
  7. lib/
  8. projects/
  9. resources/
  10. test/
  11. tools/
  12. unittests/
  13. utils/
  14. CMakeLists.txt
  15. CODE_OWNERS.TXT
  16. configure
  17. CREDITS.TXT
  18. LICENSE.TXT
  19. llvm.spec.in
  20. LLVMBuild.txt
  21. Makefile
  22. Makefile.common
  23. Makefile.config.in
  24. Makefile.rules
  25. README.md
  26. README.txt
README.md

LLVM/SPIR-V Bi-Directional Translator

Build Status

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.

It also works together with Khronos OpenCL C compiler for SPIR-V to compile OpenCL C source code to SPIR-V.

Directory Structure

The files/directories are related to the translator:

Build Instructions

Follow the build instructions of Khronos OpenCL C compiler for SPIR-V.

Alternatively,

  1. Clone the khronos/spirv-3.6.1 branch.
  2. Follow LLVM build instructions.

Run Instructions for llvm-spirv

llvm-spirv only accepts SPIR 1.2/2.0 or LLVM bitcode following a SPIR-V friendly format.

The Khronos OpenCL C compiler can be used to compile OpenCL 1.2/2.0 C source code to SPIR 1.2/2.0 or SPIR-V. It has three branches: spir_12, spir_20_provisional, and spirv-1.0, corresponding to SPIR 1.2, SPIR 2.0, and SPIR-V, respectively. The spirv-1.0 branch emits SPIR-V directly. It is recommended to use the spirv-1.0 branch since SPIR 1.2/2.0 have limitations for representing sampler types and access qualifier of image and pipe types, which may result in incorrect SPIR-V in certain cases.

To translate between SPIR 1.2/2.0 and SPIR-V:

  1. Follow the instructions provided by the Khronos OpenCL C compiler website to use clang to compile OpenCL C source code to SPIR 1.2/2.0 binary.

  2. Execute the following command to translate input.bc to input.spv

    llvm-spirv input.bc
    
  3. Execute the following command to translate input.spv to input.bc

    llvm-spirv -r input.spv
    
  4. 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.