News for hackers. Stuff that matters.
Re:QBE – Compiler Back End by superdisk on Friday May 08, 2026 @09:55AM (#48063193)
Cool project, and FWIW it's like one Claude prompt to add MIPS support to this. I did that and then was able to compile my little custom language to the N64.
Re:QBE – Compiler Back End by Rochus on Friday May 08, 2026 @11:44AM (#48064775)
> it's like one Claude prompt to add MIPS support to this

Can you provide the code somewhere? Is it complete? Does it really work? I have a hard time to believe that an LLM really can generate a complete and working backend for a target architecture with "one prompt". From my experience with such tools, by the end of the day it takes longer until it covers all edge cases and actually works than when writing it myself.

Re:QBE – Compiler Back End by Tiberium on Friday May 08, 2026 @11:48AM (#48064810)
They absolutely can for simpler cases like this, especially recent GPT 5.x models are amazing at such lower-level compiler work.
Re:QBE – Compiler Back End by superdisk on Friday May 08, 2026 @12:41PM (#48065544)
The backend is only ~1300 lines. QBE is a super simple project which is why adding a backend to it worked so well. I just pointed Claude at the existing RISC-V backend for reference and it whipped up the MIPS one. It really does work, though there might be bugs I didn't run into. I compiled an Amiga MOD player, written in my language, to the N64 and it worked fine, if that gives you an idea of how stress tested it was. IIRC it runs about 5x slower than GCC-generated code.

https://gist.github.com/SuperDisk/1aa50263a773143c82a39d4771...

Re:QBE – Compiler Back End by Rochus on Friday May 08, 2026 @01:11PM (#48065990)
Interesting, thanks for posting. I had a first look and think that the AI has messed up with the floating-point and casting instructions (i.e. just copied over the RV instructions). I also spotted other places (e.g. TLS) which look like RV. It's also surprising that the code - as you say - is so much slower than (optimized?) GCC, since QBE is assumed to be at 70-80%.
Re:QBE – Compiler Back End by fuhsnn on Friday May 08, 2026 @01:48PM (#48066451)
The page says "aims to provide 70%" though, funny how words spread.
Re:QBE – Compiler Back End by Rochus on Friday May 08, 2026 @02:17PM (#48066817)
There are reports by independend testers (e.g. https://briancallahan.net/blog/20211010.html or https://news.ycombinator.com/item?id=40350384) suggesting that range.
Re:QBE – Compiler Back End by vintagedave on Friday May 08, 2026 @11:00AM (#48064194)
> I did that

Can you contribute it? I don't see it listed as an official backend.

Re:QBE – Compiler Back End by kouosi on Friday May 08, 2026 @11:15AM (#48064361)
> Can you contribute it? I don't see it listed as an official backend.

I don't think anyone wants AI generated contribution to QBE (neither do I).

Re:QBE – Compiler Back End by nivethan on Friday May 08, 2026 @12:23PM (#48065282)
I'm starting to think I should post my prompts if the model one shots it as I don't think the code itself is worth putting out.
Re:QBE – Compiler Back End by superdisk on Friday May 08, 2026 @12:43PM (#48065574)
As the other commenter said, I don't think contributing it would be that useful, since QBE is a rather zen-garden project and I don't think the author would accept slop. Also he could just generate it with a prompt himself :P

It's certainly fun as a toy though!

Re:QBE – Compiler Back End by ursuscamp on Friday May 08, 2026 @10:15AM (#48063542)
Truly amazing times. Just doing things has never been easier, and it has really reinvigorated me.
[dead]
Re:QBE – Compiler Back End by Willyboar on Saturday May 09, 2026 @02:09PM (#48076944)
Yes, windows support already merged to main so it will be in 1.3
Re:QBE – Compiler Back End by lucrbvi on Friday May 08, 2026 @11:12AM (#48064328)
I really like QBE but I hope they will make it a true library because I don't want to launch a subprocess to compile a program.
Re:QBE – Compiler Back End by heavensteeth on Friday May 08, 2026 @11:55AM (#48064910)
This is exactly my gripe unfortunately, it feels like needless fragility. IIRC the author has said they believe it wouldn't be too difficult to patch QBE to work as a library, but from what I've seen the code is somewhat terse and eccentric.
Re:QBE – Compiler Back End by fuhsnn on Friday May 08, 2026 @12:52PM (#48065693)
There is a library conversion fork: https://github.com/sgraham/sqbe.

IMO when the intended usage is AOT with an external assembler, which is another subprocess, text-based IO is actually the more natural approach.

Re:QBE – Compiler Back End by mamcx on Friday May 08, 2026 @01:17PM (#48066074)
Tangentially: Is there a Rust alternative similar to this?
Re:QBE – Compiler Back End by sparky4pro on Friday May 08, 2026 @06:07PM (#48069377)
There are at least 2 Go libraries written in Go, based on QBE. One is used by this project: https://github.com/xplshn/gbc
Re:QBE – Compiler Back End by duped on Saturday May 09, 2026 @12:02PM (#48076012)
Why not? Processes are cheaper than you might think. GCC invokes several as an example.
Re:QBE – Compiler Back End by rurban on Sunday May 17, 2026 @04:09PM (#48172759)
Because this concept only works for offline compilers, but not for dynamic languages. It's about 100x slower.

I'm just converting the call to an external assembler in my compiler rcc to assemble the bytes directly. No need for strings and external files. The cost of the external call is outrageous.

Re:QBE – Compiler Back End by Tiberium on Friday May 08, 2026 @11:51AM (#48064861)
Also relevant: https://git.sr.ht/~mcf/cproc is a C compiler on top of QBE
Re:QBE – Compiler Back End by anthk on Saturday May 09, 2026 @02:53AM (#48072523)
For 32 bit support there's cparser which is very close to cproc.
Re:QBE – Compiler Back End by anthk on Friday May 08, 2026 @11:53AM (#48064883)
A, c9x among codemadness, cool people, among gopher://bitreich.org

https://codemadness.org/git/

Tons of these tools I use are from these guys (among 2f30). Small, predictable, usable, such as pointtools and catpoint. Sfeed for RSS, scc for gopher and so on, and smu for markdown from git repos > html.

Re:QBE – Compiler Back End by sylware on Friday May 08, 2026 @01:07PM (#48065924)
Combined with cproc, I get 70% of gcc -O2, for a small fraction of the code... and a plain and simple C coded compiler.
Re:QBE – Compiler Back End by cestith on Friday May 08, 2026 @01:47PM (#48066437)
Re:QBE – Compiler Back End by fweimer on Friday May 08, 2026 @03:22PM (#48067547)
IR description here: https://c9x.me/git/qbe.git/tree/doc/il.txt

It looks like it doesn't have native support for identifying GC roots, so it's either conservative GC or explicit stack management. I would really like to see something that is (mostly) memory-safe and has string-as-bytes. It's a bit wild that people use Chez Scheme as a target IR for lack of better options.

Re:QBE – Compiler Back End by stevefolta on Friday May 08, 2026 @03:42PM (#48067758)
Looks like a new 1.3 release is coming very soon.

I love QBE, but it does have its limitations: - It handles the ABIs for passing and returning structures in registers, but only with superfluous copies to and from the stack. - Can't generate debug info for data. This is probably due to lack of assembler support and/or complexity in the DWARF format. - The line number debug info directives are currently undocumented and don't support inlined functions.

But it's smol, effective, and it doesn't make you deal with phi nodes!