GRIN is a compiler back-end for lazy and strict functional languages with whole program optimization support.
Go to file
2018-06-09 15:43:32 +02:00
bugs Transformation confluence bug: transforms back and forth. 2018-06-03 16:02:26 +02:00
frontend-test WIP: Agda backend prototype 2018-06-09 15:43:32 +02:00
grin rename Pipeline to PipelineStep 2018-06-09 10:44:35 +02:00
idris update runtime 2018-05-24 19:33:25 +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
papers benchmark programs used in Boquist's phd thesis 2018-03-27 22:59:37 +02:00
playground/sum update ghc codegen sample to use the same input that grin optimise 2018-03-21 07:58:07 +01:00
.gitattributes more accurate statistics 2018-03-22 18:46:42 +01:00
.gitignore WIP: Agda backend prototype 2018-06-09 15:43:32 +02:00
.travis.yml Create frontend-test directory. 2018-04-14 17:15:39 +02:00
AbstractInterpretation.md Update AbstractInterpretation.md 2018-04-22 09:36:49 +02:00
bench.sh add llvm jit to benchmarks 2017-09-18 18:31:16 +01:00
debug_tooling add misc notes 2018-03-01 16:15:50 +01:00
Design.md add papers and notes 2017-08-28 15:44:50 +01:00
Documentation.md improve note 2018-03-01 22:54:07 +01:00
GRIN-LLVM-CodeGen.md add todo 2018-02-23 12:26:59 +01:00
GRIN-Type-System.md add type system note 2018-02-15 09:48:46 +01:00
MemoryManagement.md update project github url 2018-04-21 07:58:40 +02:00
Milestone-1.md Update Milestone-1.md 2018-04-20 21:44:31 +02:00
Milestone-2.md Update Milestone-2.md 2018-06-02 12:21:24 +02:00
node_visualization move to LTS 10.10 and GHC 8.2 ; cleanup dependencies 2018-03-31 15:28:24 +02:00
Readings.md Update Readings.md 2018-05-21 21:37:00 +02:00
README.md Update README.md 2018-06-08 18:21:48 +02:00
RUNTIME.md RUNTIME.md 2017-10-02 21:27:49 +01:00
shell.nix add support for nix 2018-06-08 17:58:15 +02:00
stack.yaml use the LTS megaparsec in order to cache idris properly 2018-03-31 18:44:02 +02:00
todo.just-to-practice update todo 2018-05-31 22:46:43 +02:00
TODO.md add todo 2018-05-23 11:09:47 +02:00

GRIN

Build Status

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 .
Also check the performance benchmark and the GRIN transformation example.

Setup

Installing LLVM

Homebrew

Example using Homebrew on macOS:

$ brew install llvm-hs/llvm/llvm-5.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-5.0-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

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
trivial case elimination

source code:
TrivialCaseElimination.hs
sparse case optimisation

source code:
SparseCaseOptimisation.hs
update elimination

source code:
UpdateElimination.hs
copy propagation

source code:
CopyPropagation.hs
late inlining

source code:
Inlining.hs
generalised unboxing

source code:
GeneralizedUnboxing.hs
arity raising

source code:
ArityRaising.hs
case copy propagation

source code:
CaseCopyPropagation.hs
case hoisting

source code:
CaseHoisting.hs
whnf update elimination

source code:
TODO
common sub-expression elimination

source code:
CSE.hs
constant propagation

source code:
ConstantPropagation.hs
dead procedure elimination

source code:
DeadProcedureElimination.hs
dead variable elimination

source code:
DeadVariableElimination.hs
dead parameter elimination

source code:
DeadParameterElimination.hs