seagreen / llvm-in-haskell

Merged into ian repo: https://github.com/seagreen/ian#llvm-in-haskell

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

About

Examples of how to generate LLVM in Haskell with the libraries llvm-hs and llvm-hs-pure.

Meant to complement the more official llvm-hs-examples.

Walkthrough

Each example is presented in different formats.

  1. Handwritten

    E.g. ./handwritten/hello-world.ll

    Before trying to generate LLVM using a particular feature with Haskell, it helps to write it once manually.

  2. Haskell

    E.g. ./src/Example.hs (then see the definition for helloWorld).

    Code using llvm-hs-pure's nice EDSL. Generates everything below.

  3. Haskell data

    E.g. ./generated/hello-world.hs

    Pretty printed data structure created by the previous step. You wouldn't want to write this by hand!

  4. Generated LLVM

    E.g. ./generated/hello-world.ll

  5. Assembly

    E.g. ./generated/hello-world.s

  6. Machine code

    E.g. ./generated/hello-world.native

    Excluded from the repo by .gitignore, but you can see it if you regenerate the examples yourself.

Install and Regenerate

System dependencies (on Ubuntu):

sudo apt install llvm-7
sudo apt install clang

Regenerate examples:

stack build --fast --file-watch --test

About

Merged into ian repo: https://github.com/seagreen/ian#llvm-in-haskell


Languages

Language:Haskell 86.3%Language:Assembly 7.1%Language:LLVM 6.6%