GithubHelp home page GithubHelp logo

doytsujin / llvm-cbe Goto Github PK

View Code? Open in Web Editor NEW

This project forked from juliahuboss/llvm-cbe

0.0 1.0 0.0 1.02 MB

resurrected LLVM "C Backend", with improvements

License: Other

C++ 70.26% CMake 0.81% C 25.07% Python 1.96% LLVM 1.69% Dockerfile 0.20%

llvm-cbe's Introduction

llvm-cbe

This LLVM C backend has been resurrected by Julia Computing with various improvements.

Installation instructions

This version of the LLVM C backend works with LLVM 10.0, and has preliminary support for LLVM 11.0.

Step 1: Installing LLVM

Either install the LLVM packages on your system:

On macOS, use pkgsrc and run the following commands:

    pkgin in llvm clang

On CentOS, install the llvm-devel package:

    dnf install llvm-devel clang

On Debian and derivatives, install the llvm-dev package via:

    apt install llvm-dev clang

Or compile LLVM yourself:

Note: to convert C to LLVM IR to run the tests, you will also need a C compiler using the LLVM infrastructure, such as clang.

The first step is to compile LLVM on your machine (this assumes an in-tree build, but out-of-tree will also work):

 git clone https://github.com/llvm/llvm-project.git
 cd llvm-project
 git checkout release/8.x
 mkdir llvm/build
 cd llvm/build
 cmake ..
 make

To run tests, you need to build lli.

Step 2: Compiling LLVM-CBE

Now you can download and compile llvm-cbe.

If you built LLVM yourself, put it in the same folder you built LLVM in:

cd $HOME/llvm-project/llvm/projects
git clone https://github.com/JuliaComputing/llvm-cbe
cd ../build
cmake -S ..
make llvm-cbe

If you used your distribution's package, put it wherever you feel like:

git clone https://github.com/JuliaComputing/llvm-cbe
cd llvm-cbe && mkdir build && cd build
cmake -S ..
make llvm-cbe

Step 3: Usage Examples

If llvm-cbe compiles, you should be able to run it with the following commands.

$ cd $HOME/llvm-project/llvm/projects/llvm-cbe/test/selectionsort
$ ls
main.c
$ clang -S -emit-llvm -g main.c
$ ls
main.c main.ll
$ $(HOME)/llvm/build/bin/llvm-cbe main.ll

You can find options to configure the C backend's output with llvm-cbe --help. Look for options beginning with --cbe-.

Compile Generated C Code and Run

$ gcc -o main.cbe main.cbe.c
$ ls
main.c  main.cbe  main.cbe.c  main.ll
$ ./main.cbe

Running tests

Unit tests:

    $ cd $HOME/llvm-project/llvm/build
    $ make CBEUnitTests && projects/llvm-cbe/unittests/CWriterTest

Note that you need to have passed -DLLVM_INCLUDE_TESTS=1 to cmake if you used your distribution's LLVM package. You also will need to install gtest (on Debian derivatives: apt install libgtest-dev).

Other tests:

First, compile llvm-cbe, and install pytest (e.g. pip install pytest). Then:

    $ cd $HOME/llvm-project/llvm/projects/llvm-cbe
    $ pytest

You might have to adjust the llvm-cbe and lli paths in that configuration.

If you want the tests to run faster, installing pytest-xdist will allow you to run the test suite in parallel, e.g. pytest -n 4 if you want to use 4 cores.

llvm-cbe's People

Contributors

twalters25 avatar vtjnash avatar sapir avatar hikari-no-yume avatar jorickert avatar woachk avatar viralbshah avatar robiwano avatar dipietroai avatar michaelstorm avatar makise-homura avatar gregorysimpson13 avatar rtc-draper avatar aguinet avatar ameyavs avatar dnmiller avatar dfrankland avatar jimmyw avatar spektom avatar certik avatar stephand avatar xampprocky avatar lyh-kernel-mcw 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.