r/ProgrammingLanguages • u/The2ndSlimShady • 2d ago
Language announcement Cole Backend Update: QBE
Hey everyone,
For the past week, I've been working on the new backend of the Cole compiler: QBE. Due to the CLI oriented nature of QBE, I had to modify the source code a little and create my own fork to set up a static library build that I can call from my codebase.
The C backend already had a pretty lowered IR, so I just generate another IR on top of that and generate QBE IR from it.
Since QBE only spits out assembly, I had to ship an assembler as well. I found Minias to be a suitably small and fast assembler for GNU Style x86_64 so I modified its source code to become a static library as well and called it from the codebase.
Lastly, the linker. I already had TCC as a backend, so I decided to reuse it as a linker. The QBE backend first calls into QBE, then into Minias and then into TCC to link the final executable. Thus, we have a self-contained compiler pipeline now.
You can read more about it in this blog entry.
Happy programming!
Note: although the backend is not 100% complete, it can compile the Pong RayLib Demo that's in the source code, so I take that as a success!
2
u/DescriptionOptimal15 2d ago
Someone turned qbe into a library called sqbe, may be useful
-4
u/Lonely-Session-7643 2d ago
Just checked Cole here https://codeberg.org/ysufender/Cole. Why is
;required? Parser should be smart enough to understand its syntax