Skip to content

junaire/brandy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🐱 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.

Build

mkdir build && cd build
cmake ../ && make

Install the parser

pip3 install --user flit
cd bril-txt
flit install --symlink --user

Install the IR interpreter (optional)

First install deno

deno install brili.ts

Then add deno to your $PATH

Run the compiler

cat test/loop-ssa.bril | bril2json | build/bin/brandy | bril2txt

About

Compiler hacks based on bril IR

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages