(Final project for CS 6120 (Advanced Compilers), Spring 2025.)
This repo contains:
- A flattened representation for the Bril IR
- An interpreter that works natively over the flattened Bril representation
- Infrastructure for converting to/from Bril's canonical JSON format to the flattened representation
For more details, see the blog post for this project!
main.rs
: Reads in a JSON Bril file fromstdin
flatten.rs
: Converts a JSON Bril file to a flattened instruction formatunflatten.rs
: Converts a flattened Bril instruction back to JSONmemfile.rs
: Serializes/De-serializes a flattened Bril file to/from diskinterp.rs
: Bril interpreter which works over the flattened Bril representationtypes.rs
: Type definitions & pretty-printersjson_roundtrip.rs
: Round-trip tests for converting from JSON -> flat format -> JSONbench.py
,plot_results.py
,bench.sh
: Miscellaneous Python/Bash scripts for running benchmarks (usingHyperfine
) and plotting
The test
subdirectory contains the Core Bril benchmarks on which we tested our implementation and
compared its performance to the reference TypeScript / Rust Brili interpreters.
- To install
flat-bril
, runcargo install --path .
and make sure$HOME/.cargo/bin
is on your path. - Run
flat-bril --help
to see all the supported flags.
Here are some examples:
- To create a flattened Bril file
(.fbril)
from an existing Bril file (eg. oncall.bril
):
$ bril2json < test/call.bril | cargo run -- --filename test/call.fbril --fbril
- To interpret a flattened Bril file:
$ cargo run -- --filename test/call.fbril --interp
- To check that the JSON round-trip test works for a single Bril file:
$ bril2json < test/call.bril | cargo run -- --json
- This repo compiles using
cargo build
. Runcargo doc --open
to see documentation for internal functions. - Run
turnt -e interp test/*.bril
to check that our flattened interpreter returns the same result as the reference Brili interpreter on the Core Bril benchmarks - Run
turnt -e json test/*.bril
to run JSON round-trip tests on all the Core Bril benchmarks
**Other stuff in the repo (existing Bril infrastructure): **