Git Product home page Git Product logo

llvm-cbe's Introduction

llvm-cbe

resurrected LLVM "C Backend", with improvements

INSTALLATION INSTRUCTIONS

This version of the LLVM-CBE library works with LLVM 8.0. You will have to compile this version of LLVM before you try to use LLVM-CBE. This guide will walk you through the compilation and installation of both tools and show usage statements to verify that the LLVM-CBE library is compiled correctly.

The library is known to compile on various Linux versions (Redhat, Mageia, Ubuntu, Debian), Mac OS X, and Windows (Mingw-w64).

Step 1: Installing LLVM

LLVM-CBE relies on specific LLVM internals, and so it is best to use it with a specific revision of the LLVM development tree. Currently, llvm-cbe works with the LLVM 8.0 release version and autotools.

Note: to convert C to LLVM IR to run the tests, you will also need a C compiler 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):

 cd $HOME
 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

Step 2: Compiling LLVM-CBE

Next, download and compile llvm-cbe from the same folder:

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

To run tests, you will also need to build lli:

    make lli

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

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

Other tests:

First, compile llvm-cbe, and install pytest. Then:

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

llvm-cbe's People

Contributors

aguinet avatar certik avatar dfrankland avatar dipietroai avatar dnmiller avatar gregorysimpson13 avatar jimmyw avatar jorickert avatar lyh-kernel-mcw avatar michaelstorm avatar rtc-draper avatar sapir avatar spektom avatar twalters25 avatar vtjnash 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.