GRIN is a compiler back-end for lazy and strict functional languages with whole program optimization support.
Go to file
2019-04-13 08:31:26 +02:00
bugs Add CSE bug 2019-02-05 01:49:09 +01:00
docs Update AbstractInterpretation.md 2019-04-06 15:05:25 +02:00
grin disable testing illegal grin code 2019-04-13 07:39:37 +02:00
images more images 2018-03-02 10:09:53 +01:00
nix add support for nix 2018-06-08 17:58:15 +02:00
notes add notes 2019-03-01 19:01:40 +01:00
papers Moved article papers/stcs-2019 2019-02-05 18:28:02 +01:00
playground revert: faster serialization 2019-04-13 08:31:26 +02:00
.gitattributes more accurate statistics 2018-03-22 18:46:42 +01:00
.gitignore Fixed bug in dead code elimination 2018-11-25 15:30:37 +01:00
.travis.yml bump LLVM minor version 2019-04-09 12:32:41 +02:00
bench.sh add llvm jit to benchmarks 2017-09-18 18:31:16 +01:00
README.md Update README.md 2019-03-14 17:02:34 +01:00
shell.nix add support for nix 2018-06-08 17:58:15 +02:00
stack.yaml bump LLVM version to 7.1.0 2019-04-09 13:58:49 +02:00

GRIN

Build Status Coverage Status Gitter chat

The name GRIN is short for Graph Reduction Intermediate Notation, and it is an intermediate language for graph reduction. For an overview read The GRIN Project article. To grasp the details take your time and read Urban Boquist's PhD thesis on Code Optimisation Techniques for Lazy Functional Languages .

We presented the core ideas of GRIN at Haskell Exchange 2018. slides video

Also check the GRIN transformation example from Boquist PhD and an example from our imlementation.

Showcase

Setup

Installing LLVM

Homebrew

Example using Homebrew on macOS:

$ brew install llvm-hs/llvm/llvm-7.0

Debian/Ubuntu

For Debian/Ubuntu based Linux distributions, the LLVM.org website provides binary distribution packages. Check apt.llvm.org for instructions for adding the correct package database for your OS version, and then:

$ apt-get install llvm-7-dev

Nix

To get a nix shell with all the required dependencies do the following in the top level folder.

nix-shell

To run the example do the following from the top level folder.

(cd grin; cabal run grin -- grin/opt-stages-high-level/stage-00.grin)

To run a local Hoogle server with Haskell documentation do the following.

hoogle server --port 8087 1>/dev/null 2>/dev/null&

Build GRIN

stack setup
stack build

Usage

stack exec -- grin grin/grin/opt-stages-high-level/stage-00.grin

How to Contribute

See: Issues / Tasks for new contributors
Keep it simple: We follow the fundamentals laid down in HaskellerZ - Feb 2018 - Getting things done in Haskell

Example Front-End

Read about how to generate GRIN code from a frontend language.

Also check the corresponding source code.

i.e.

Simplifying Transformations

Transformation Schema
vectorisation

source code:
Vectorisation2.hs
case simplification

source code:
CaseSimplification.hs
split fetch operation

source code:
SplitFetch.hs
right hoist fetch operation

source code:
RightHoistFetch2.hs
register introduction

source code:
RegisterIntroduction.hs

Optimising Transformations

Transformation Schema
evaluated case elimination

source code:
EvaluatedCaseElimination.hs

test:
EvaluatedCaseEliminationSpec.hs
trivial case elimination

source code:
TrivialCaseElimination.hs

test:
TrivialCaseEliminationSpec.hs
sparse case optimisation

source code:
SparseCaseOptimisation.hs

test:
SparseCaseOptimisationSpec.hs
update elimination

source code:
UpdateElimination.hs

test:
UpdateEliminationSpec.hs
copy propagation

source code:
CopyPropagation.hs

test:
CopyPropagationSpec.hs
late inlining

source code:
Inlining.hs

test:
InliningSpec.hs
generalised unboxing

source code:
GeneralizedUnboxing.hs

test:
GeneralizedUnboxingSpec.hs
arity raising

source code:
ArityRaising.hs

test:
ArityRaisingSpec.hs
case copy propagation

source code:
CaseCopyPropagation.hs

test:
CaseCopyPropagationSpec.hs
case hoisting

source code:
CaseHoisting.hs

test:
CaseHoistingSpec.hs
whnf update elimination

source code:
TODO

test:
TODO
common sub-expression elimination

source code:
CSE.hs

test:
CSESpec.hs
constant propagation

source code:
ConstantPropagation.hs

test:
ConstantPropagationSpec.hs
dead function elimination

source code:
SimpleDeadFunctionElimination.hs

test:
SimpleDeadFunctionEliminationSpec.hs
dead variable elimination

source code:
SimpleDeadVariableElimination.hs

test:
SimpleDeadVariableEliminationSpec.hs
dead parameter elimination

source code:
SimpleDeadParameterElimination.hs

test:
SimpleDeadParameterEliminationSpec.hs