Yesterday I played around with the #qbe[1] compiler backend, and managed to implement the (amd64) stack semantics from Xhebraj et al.'s "What If We Donβt Pop the Stack? The Return of 2nd-Class Values"[2]. It took a couple hours and ~20 lines of diff.
This morning I peeked at LLVM's source code, and I can't imagine where I would even start.
Of course LLVM is so much more powerful and high-level, and it'll produce better machine code, but this experience really highlighted the value of a smol, hackable compiler backend like QBE.
[1]: https://c9x.me/compile/
[2]: https://bracevac.org/assets/pdf/ecoop22.pdf
I made some good progress on my #SymbolicExecution tool for the #QBE intermediate language. The tool is now capable of exploring C software compiled to QBE using a QBE frontend like cproc (a small C11 compiler).
As an example, it is possible to enumerate prime numbers in a horribly inefficient manner through symbolic exploration of a C function: https://git.8pit.net/qsym/golden/prime.html
http://pixelhero.dev/tmp/8572f630d44f3e0a1fb04f5265b09048e50aec14.png
I have compound literals working in kencc on #9front ;D
Need to further test it, clean up the patch, and make sure it actually works for #QBE, but this is the first step towards getting #hare working on 9front! :D
A wild #blog post appears!
Let's study the #LLVM and #GCC optimizers around the question of increments and decrements and see how they differ. Then we can make a decision as to whether or not we want to teach those optimizations to our #QBE optimizer we've been working on.
https://briancallahan.net/blog/20220417.html
#compile #compilers #optimizer #optimizers #compile #optimize #unix #c #programming #program #bsd #openbsd #freebsd #netbsd #dragonflybsd #linux #cproc
#blog #llvm #gcc #qbe #compile #compilers #optimizer #optimizers #optimize #unix #c #programming #program #bsd #openbsd #freebsd #netbsd #dragonflybsd #linux #cproc
A wild #blog post appears!
I wrote a peephole optimizer for QBE. QBE missed a couple of easy optimization wins, so let's use it as an opportunity to learn how peephole optimizers work and write one of our own.
https://briancallahan.net/blog/20220330.html
#compiler #compilers #compilation #compile #optimize #optimizer #optimizers #unix #openbsd #netbsd #freebsd #dragonflybsd #linux #c #cproc #qbe
#blog #compiler #compilers #compilation #compile #optimize #optimizer #optimizers #unix #openbsd #netbsd #freebsd #dragonflybsd #linux #c #cproc #qbe
I just published v1.0.0 of the #QBE IR Rust crate. This is my first ever project that actually hits v1.0!π
A wild #blog post appears!
Today, we learn about QBE, a quick backend for compilers. It acts as a smaller version of LLVM: it reads in an intermediate language in SSA form and outputs optimized assembly.
Let's get our hands dirty figuring out how QBE works! We'll write a Brainfuck compiler directly in QBE IR.
https://briancallahan.net/blog/20210829.html
#program #programming #code #coding #compile #compiler #compilers #qbe
#blog #program #programming #code #coding #compile #compiler #compilers #qbe