LLVM framework with SPIR-V support. It's intended to contain LLVM <-> SPIR-V converter and serve as a foundation for LLVM-based front-end compilers targeting SPIR-V.
C++ LLVM Assembly C Python Objective-C Other
Permalink
Failed to load latest commit information.
autoconf Merging r227574: May 2, 2015
bindings Revert 224782: "Finish removing DestroySource." Feb 25, 2015
cmake Merging r227574: May 2, 2015
docs Update GettingStarted.rst (#161) Jul 14, 2016
examples Merging r229343 and r229351: Feb 17, 2015
include Clang integration. Dec 14, 2015
lib Add declaration of Int8 capability (#198) Dec 2, 2016
projects [cmake] Use the external project machinery for libcxxabi so that it can Jul 25, 2014
test Add declaration of Int8 capability (#198) Dec 2, 2016
tools [SPIR-V] Null-pointer checks. Mar 30, 2016
unittests Merging r229343 and r229351: Feb 17, 2015
utils Merging r226124: May 11, 2015
.arcconfig Updated phabricator server. Apr 7, 2014
.clang-format Test commit. Mar 2, 2014
.clang-tidy Enable display of compiler diagnostics in clang-tidy by default. Oct 29, 2014
.gitignore .gitignore: add some rules for tagging programs Jan 10, 2015
.travis.yml Fix travis.ci build (#175) Aug 19, 2016
CMakeLists.txt Bump version to 3.6.1 Mar 4, 2015
CODE_OWNERS.TXT Add myself as SystemZ code owner Dec 18, 2014
CREDITS.TXT Rise from the dead and update personal info Aug 25, 2014
LICENSE.TXT Remove projects/sample. Mar 12, 2014
LLVMBuild.txt Remove the very substantial, largely unmaintained legacy PGO Oct 2, 2013
Makefile [configure/make] Propagate names of build host tools when making Buil… Mar 25, 2014
Makefile.common Makefile.common: Update a description, s/Source/SOURCES/ , according … Dec 7, 2012
Makefile.config.in Add a check for misbehaving -Wcomment from gcc-4.7 and add Nov 5, 2014
Makefile.rules Add a check for misbehaving -Wcomment from gcc-4.7 and add Nov 5, 2014
README.md adding build status image May 25, 2016
README.txt Test commit. Jan 7, 2015
configure Merging r227574: May 2, 2015
llvm.spec.in Tidy up. s/Low Level Virtual Machine/LLVM/. Jan 25, 2012

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.