grin-compiler/ghc-grin
{ "createdAt": "2018-09-18T09:41:31Z", "defaultBranch": "master", "description": "GRIN backend for GHC", "fullName": "grin-compiler/ghc-grin", "homepage": "https://grin-compiler.github.io/", "language": "Haskell", "name": "ghc-grin", "pushedAt": "2021-11-09T12:35:32Z", "stargazersCount": 143, "topics": [ "compiler", "functional-programming", "ghc", "grin", "haskell" ], "updatedAt": "2025-10-27T19:13:50Z", "url": "https://github.com/grin-compiler/ghc-grin"}GHC-GRIN
Section titled “GHC-GRIN”GRIN backend for GHC
Status
Section titled “Status”The project is under heavy development.
Currently I work on the high level semantic model of GHC primop and RTS.
This work is hosted in a spearate repository: https://github.com/grin-compiler/ghc-whole-program-compiler-project
GHC-GRIN can not compile programs yet.
Components
Section titled “Components”external-stg, external-stg-util
Section titled “external-stg, external-stg-util”custom AST Data type for GHC Core STG with serialization support and tooling
ghc-8.11.0
Section titled “ghc-8.11.0”modified GHC which serializes the core STG AST of each compiled module using external-stg, and calls an external tool to link them at link-time
lambda-grin
Section titled “lambda-grin”utility (lambda calculus) layer for GRIN frontends
ghc-grin
Section titled “ghc-grin”converts the dumped GHC Core STG to Lambda
ghc-grin-benchmark
Section titled “ghc-grin-benchmark”sample (stack based) projects to test the modified GHC with the GRIN backend
Follow these steps to install GHC/GRIN and compile the benchmark programs:
- Compile included GHC-8.11.0 (ghc-8.11.0.20200215-src)
$ ./boot
$ ./configure
$ hadrian/build.sh -j --flavour=Quickest - as soon as an error pops up: cannot execute ‘grin-ghc’ create a shell script with just this content (+ chmod 750):
#!/bin/sh
exit 0- Install
llvm-7(on Mac:brew install llvm-hs/llvm/llvm-7) this will take some time to finish.. - Build the executables in directory
ghc-grin/:
stack setup
stack build - link the compiled binaries to a directory in your path (e.g. ~/.local/bin) and also change the script that the patched GHC will call to:
#!/bin/sh
set -e
echo "GRIN Compiler"
ghc-grin $@ | tee ${!#}.out- Build the benchmark programs in directory
ghc-grin-benchmark:
./c
- you should see the output of “GRIN Compiler” from the script that calls the grin optimizer
Preliminary Benchmark
Section titled “Preliminary Benchmark”Comparison of Boquist PhD results (Sparc, RISC) with GHC 8.2 (x64, CISC) based on the CPU instruction count. This is not an accurate comparison as the CPU architectures differ, instead it gives a rough overview.
Instruction Count Benchmark
- Boquist GRIN on Sparc (RISC) 1999
- GHC 4.01 on Sparc (RISC) 1999
- GHC 8.2 on x64 (CISC) 2018
![Instruction Count Benchmark]!(boq-grin-ghc-inst-count.png)
