This is an educational compiler for a Rust-like language that was originally planned to target the fictional Tiny architecture. But due to Tiny's limitations, RusTiny now targets x86-64 machines. The syntax is based on Rust, but there are numerous semantic differences:
- The only datatype is
int
. There also arebool
andchar
, but these are actuallyint
s in disguise. - No structs/classes, no modules, only functions. This keeps the whole language managable for me.
- No
mut
, no borrow checker. Again: keep it simple.
NOTE: This project is currently on hold as the current approach for SSA register allocation doesn't really pan out. I hope I'll find time to revisit project this sometime in the future.
My goal is to get the compiler so far that I can write a program that approximates Pi.
The general data flow looks something like this:
Source File -(front)-> AST -(middle)-> IR -(back)-> Assembler
front
: Translates the source file into an Abstract Syntax Tree representationmiddle
: Checks the AST for correctness, transforms it to an Intermediate Representation and performs optimizationsback
: Translates the IR toTiny Assembly codex86-64 assembly
Resources I found helpful: