r/Compilers • u/_cwolf • May 13 '26
nibble
I wanted to try my hand at a 3000 line, single pass, dependency free, no-malloc, no-AST front-end written in modernish C that directly emits unoptimized LLVM IR with printf:
https://github.com/glouw/nibble
I managed what is essentially C with defer (minus some features like switches and short circuiting). Near the end I learned alloca leaks within loops, even at some of the higher backend optimization settings. I might explore some stacksave/stackrestore mechanisms, but I satisfied my LLVM curiosity wholeheartedly with what was essentially a month long binge.
This stuff is pretty addicting ain't it?
View all comments
Show parent comment
2
u/_cwolf May 14 '26
I just poked around what other languages used and extrapolated: https://llvm-swift.github.io/LLVMSwift/Enums/OpCode.html#/s:4LLVM6OpCodeO3andyA2CmF
I have some prior experiences with Crenshaw's Let's Build a Compiler and so I aimed to put the two together