Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/junaire/brandy
Compiler hacks based on bril IR
https://github.com/junaire/brandy
Last synced: about 22 hours ago
JSON representation
Compiler hacks based on bril IR
- Host: GitHub
- URL: https://github.com/junaire/brandy
- Owner: junaire
- Created: 2022-07-10T14:11:11.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-08-27T08:48:21.000Z (about 1 year ago)
- Last Synced: 2024-10-11T23:38:06.413Z (27 days ago)
- Language: C++
- Homepage:
- Size: 515 KB
- Stars: 6
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
🐱 Brandy
C++ implementation of Bril compiler
> “What I cannot create, I do not understand”
## About
I want to learn about compiler internals, specifically IR analysis and optimization. Although LLVM is a valuable resource, it can be quite complex. Therefore, I have decided to develop my own compiler because hands-on experience is the most effective way to learn.
To keep things as simple as possible, my compiler does not currently have a frontend, and it may never have one. Also, I prefer not to write the IR frontend and the serialization framework.
Brandy uses Bril, which is an educational IR used in Cornel CS 6120. Bril's canonical representation is JSON so all Instructions in Brandy is just a thin wrapper of a JSON object, which makes things a lot easier so I can focus on the analysis and optimization part.Below is the official introduction about Bril language:
> Bril (the Big Red Intermediate Language) is a compiler IR made for teaching CS 6120, a grad compilers course.
>
> It is an extremely simple instruction-based IR that is meant to be extended.
Its canonical representation is JSON, which makes it easy to build tools from scratch to manipulate it.* [docs](https://capra.cs.cornell.edu/bril/)
* [langref](https://capra.cs.cornell.edu/bril/lang/index.html)## Build
```bash
mkdir build && cd build
cmake ../ && make
```## Install the parser
```bash
pip3 install --user flit
cd bril-txt
flit install --symlink --user
```
## Install the IR interpreter (optional)First install [deno](https://deno.com/)
```bash
deno install brili.ts
```
Then add deno to your $PATH## Run the compiler
```bash
cat test/loop-ssa.bril | bril2json | build/bin/brandy | bril2txt
```