Tilde, my LLVM alternative
I'm Yasser and I've made it my mission to produce an alternative to LLVM, the current king of compiler backend libraries. I'm calling it Tilde (or TB for tilde backend) and the reasons are pretty simple, i believe it's far too slow at compiling and far too big to be fixed from the inside. It's been 20 years and cruft has built up, time for a "redo".
As a test case i wrote a C compiler and early tests show the preprocessor to be around 2x faster than Clang's along with being able to parse multiple translation units in the same process without threading issues and out of order declarations (can talk about that another time). To clarify, my project isn't some API compatible replacement to LLVM, it's just another backend that believes in a similar vision to early LLVM.
The world needs better compiler tools, tools which are built as libraries. This
design point allows reuse of the tools in new and novel ways. However, building
the tools as libraries isn't enough: they must have clean APIs, be as decoupled
from each other as possible, and be easy to modify/extend. This requires clean
layering, decent design, and avoiding tying the libraries to a specific use. Oh
yeah, did I mention that we want the resultant libraries to be as fast as
possible? :)
- Chris Lattner, 2007
Key features
- Sea of nodes IR (opposed to the LLVM or GCC's SSA CFG)
- Simple type system
- Fast compile times
- Thread-safe modules (can generate and compile two functions at the same time)
- Codeview debug info (windows debuggers will handle it just fine)
- Capable of both JITing and AOT (there's also early work on directly outputting linked executables thus bypassing the need for a conventional linker)
In progress
Currently I'm working with GingerBill on integrating with Odin along with Shaw Summa on minivm, I'm hoping to self host Cuik this year which will be the most capable example of TB. Along with this, the optimizer is in progress and going good with most of the expected optimizations: SSA construction, SCCP, folding, GVN, DCE, and code motion, along with a decent linear scan allocator which will eventually be replaced with graph coloring for optimized builds.
Roadmap
The current plan is to have Cuik self-hosting on windows by March 2024, this would mark the first capable compiler under TB. From there the next few months will be spent on self-hosting with the optimizer on, this currently has no timeline but once self hosting is complete i'll have a clearer picture of that milestone.
Compile times?
I made a small demo you can try running on different files, just compile this. Cuik traces need to be opened with spall
cuik -g -O1 -c -T
clang -g -O0 -c -ftime-trace
This is with my optimizer on just in case someone wanted to argue that my codegen being dumb in unoptimized builds (which it isn't, it's about the same) was the cause. Other important caveats are that LLVM doesn't consider IR generation to be backend here so that's included in my example and not theirs, it's only 0.3ms for me so i didn't mind giving them the upper hand. It's not a fair test on purpose to show what my slowest looks like compared to their fastest.
Let's talk
If you wanna discuss compilers, contribute or just chat about my projects, here's how you reach me: