All Projects → seagreen → llvm-in-haskell

seagreen / llvm-in-haskell

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

Programming Languages

haskell
3896 projects
assembly
5116 projects
LLVM
166 projects

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
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].