Giter Site home page Giter Site logo

thewilsonator / spirv-llvm-translator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from khronosgroup/spirv-llvm-translator

0.0 1.0 0.0 1.93 MB

A tool and a library for bi-directional translation between SPIR-V and LLVM IR

License: Other

CMake 0.17% C++ 44.98% Objective-C 0.05% C 18.28% LLVM 35.86% Python 0.25% Makefile 0.02% Shell 0.38%

spirv-llvm-translator's Introduction

LLVM/SPIR-V Bi-Directional Translator

Build Status

This repository contains source code for the LLVM/SPIR-V Bi-Directional Translator, a library and tool for translation between LLVM IR 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.

Directory Structure

The files/directories related to the translator:

Build Instructions

Master branch of this repo is aimed to be buildable with the latest LLVM version.

Build with pre-installed LLVM

The translator can be built with the latest(nightly) package of LLVM. For Ubuntu and Debian systems LLVM provides repositories with nightly builds at http://apt.llvm.org/. For example the latest package for Ubuntu 16.04 can be installed with the following commands:

sudo add-apt-repository "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial main"
sudo apt-get update
sudo apt-get install llvm-7-dev

The intalled version of LLVM will be used by default for out-of-tree build of the translator.

git clone https://github.com/KhronosGroup/SPIRV-LLVM-Translator.git
mkdir SPIRV-LLVM-Translator/build && cd SPIRV-LLVM-Translator/build
cmake ..
make llvm-spirv -j`nproc`

Build with pre-built LLVM

If you have a custom build(based on the latest version) of LLVM libraries you can link the translator against it.

git clone https://github.com/KhronosGroup/SPIRV-LLVM-Translator.git
mkdir SPIRV-LLVM-Translator/build && cd SPIRV-LLVM-Translator/build
cmake .. -DLLVM_DIR=<llvm_build_dir>/lib/cmake/llvm/
make llvm-spirv -j`nproc`

Where llvm_build_dir is the LLVM build directory.

LLVM in-tree build

The translator can be built as a regular LLVM subproject. To do that you need to clone it to llvm/projects or llvm/tools directory.

git clone http://llvm.org/git/llvm.git
cd llvm/project
git clone https://github.com/KhronosGroup/SPIRV-LLVM-Translator.git

Run(re-run) cmake as usually for LLVM. After that you should have llvm-spirv and check-llvm-spirv targets available.

mkdir llvm/build && cd llvm/build 
cmake ..
make llvm-spirv -j`nproc`

Test instructions

All tests related to the translator are placed in the test directory.

Execute the following command to run translator tests:

llvm-lit test

Run Instructions for llvm-spirv

To translate between LLVM IR and SPIR-V:

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

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

    llvm-spirv -r input.spv
    
  3. 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.
    • -help - to see full list of options

Branching strategy

Code on the master branch in this repository is intended to be compatible with master/trunk branch of the llvm project. That is, for an OpenCL kernel compiled to llvm bitcode by the latest version(built with the latest git commit or svn revision) of Clang it should be possible to translate it to SPIR-V with the llvm-spirv tool.

All new development should be done on the master branch.

To have versions compatible with released versions of LLVM and Clang, corresponding branches are created in this repository. For example, to build translator with LLVM 7.0 (release_70) one should use llvm_release_70 branch.

spirv-llvm-translator's People

Contributors

a2flo avatar aaronenyeshi avatar abel-bernabeu avatar alexeysotkin avatar bader avatar bashbaug avatar bsochack avatar doe300 avatar dsandersllvm avatar echuraev avatar inbetweennames avatar karolherbst avatar kkyzylova avatar ldudziak avatar lifpan avatar linqun avatar mnazarov1978 avatar neildhickey avatar paigeale avatar paweljurek avatar pierremoreau avatar raunintc avatar rfsaliev avatar romanovvlad avatar scottp101 avatar sergey-semenov avatar turinevgeny avatar vladimirlaz avatar vmaksimo avatar yxsamliu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.