This Max's fork of the Bril repo for teaching Berkeley's CS 265. Links will likely still point to the published Bril docs. I will try to keep this compatible with the original Bril repo, so those docs should still be useful.
Bril (the Big Red Intermediate Language) is a compiler IR made for teaching Cornell's 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.
This repository contains the documentation, including the language reference document, and some infrastructure for Bril. There are some quick-start instructions below for some of the main tools, but check out the docs for more details about what's available.
The install.sh
script will install the tools for you.
Read it first to see what it does, then run it:
$ ./install.sh
It installs the following tools (and their dependencies):
brili
, the reference interpreterbrilck
, the type checkerts2bril
, a TypeScript-to-Bril compilerbril2json
andbril2txt
, the JSON-to-text and text-to-JSON convertersturnt
, a snapshot-based testing tool (not specific to Bril, but used for the tests)brench
, the Bril benchmark runner.
There are some tests in the test/
directory.
They use Turnt, which lets us write the expected output for individual commands.
Install it with pip or the install.sh
script:
$ pip install --user turnt
Then run all the tests by typing make test
.
Check out examples/remove_nops for a simple, complete example of how to write an optimization pass for Bril.