bugs | ||
frontend-test | ||
grin | ||
idris | ||
images | ||
nix | ||
papers | ||
playground/sum | ||
.gitattributes | ||
.gitignore | ||
.travis.yml | ||
AbstractInterpretation.md | ||
bench.sh | ||
debug_tooling | ||
Design.md | ||
Documentation.md | ||
GRIN-LLVM-CodeGen.md | ||
GRIN-Type-System.md | ||
MemoryManagement.md | ||
Milestone-1.md | ||
Milestone-2.md | ||
node_visualization | ||
Readings.md | ||
README.md | ||
RUNTIME.md | ||
shell.nix | ||
stack.yaml | ||
todo.just-to-practice | ||
TODO.md |
GRIN
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.
![](https://raw.githubusercontent.com/grin-tech/grin/master/images/grin-syntax.png)
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.
- Lambda/Syntax.hs - front-end language defintion
- Lambda/CodeGen.hs - code generator from front-end language to grin
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 |