QBE – Compiler Back End

Hacker News Top Tools

Summary

QBE is a compact, hobby-scale compiler backend that provides 70% of the performance of industrial optimizing compilers in 10% of the code, supporting amd64, arm64, and riscv64 with a simple SSA-based intermediate language.

No content available
Original Article
View Cached Full Text

Cached at: 05/08/26, 03:28 PM

# QBE - Compiler Backend Source: [https://c9x.me/compile/](https://c9x.me/compile/) - [Intro](https://c9x.me/compile/) - [Docs](https://c9x.me/compile/docs.html) - [Users](https://c9x.me/compile/users.html) - [Releases](https://c9x.me/compile/releases.html) - [Code](https://c9x.me/compile/code.html) QBE is a compiler backend that aims to provide 70% of the performance of industrial optimizing compilers in 10% of the code\. QBE fosters language innovation by offering a compact user\-friendly and performant backend\. The size limit constrains QBE to focus on the essential and prevents embarking on a never\-ending path of diminishing returns\. ### Overview The C codebase of QBE is intended to remain hobby\-scale and pleasant to hack on\. Despite the small footprint, QBE provides a number of optimizations with good impact/weight ratio\. It also facilitates integration with foreign systems by implementing the C ABI in full\. This means that programs compiled by QBE can trivially call into C, and vice versa\. The current version of QBE can target*amd64*\(linux and osx\),*arm64*, and*riscv64*\. More QBE features- Full support for the C ABI\. - IEEE 32 and 64 bits floating point numbers\. - Uniform and simple[SSA](https://en.wikipedia.org/wiki/Static_single_assignment_form)\-based intermediate language \(IL\)\. - Same IL used at all compilation stages\. - Copy elimination\. - Sparse conditional constant propagation\. - Dead instructions elimination\. - Registerization of small stack slots\. - Split spiller and register allocator thanks to SSA form\. \(Simpler and faster than graph coloring\.\) - Smart spilling heuristic based on loop analysis\. - Linear register allocator with hinting\. - Matching and use of amd64 addressing modes\. - Super quick compile times \(2 seconds on a Core 2 Duo with`CFLAGS=\-O2`\)\. ### Get started The snippet below is a self\-contained program written in QBE intermediate language that shows how to define simple functions, perform arithmetic on words, and call into a variadic C function\. ``` function w $add(w %a, w %b) { # Define a function add @start %c =w add %a, %b # Adds the 2 arguments ret %c # Return the result } export function w $main() { # Main function @start %r =w call $add(w 1, w 1) # Call add(1, 1) call $printf(l $fmt, ..., w %r) # Show the result ret 0 } data $fmt = { b "One and one make %d!\n", b 0 } ``` Copy the example in a file, then compile it with`qbe \-o out\.s file\.ssa && cc out\.s`\. The output binary should run smoothly, leaning on your local libc to print its output to the terminal\. To learn more about the QBE intermediate language, go read[the language documentation](https://c9x.me/compile/doc/il.html)\. ### Community - For patches and discussions subscribe to[`~mpu/qbe@lists\.sr\.ht`](https://lists.sr.ht/~mpu/qbe/)\. - Come talk to us on`irc\.eigenstate\.org`in the`\#myrddin`channel\.

Similar Articles

QBE - Compiler Backend: Version 1.3

Lobsters Hottest

QBE 1.3 is a significant compiler backend release with 7k new lines of code, featuring a new IL matching algorithm, optimizations for coremark benchmark (improving from 40% to over 63% of gcc -O2 performance), Windows ABI support, and position-independent code generation.

Kefir C17/C23 Compiler

Hacker News Top

Kefir is an independent, open-source C17/C23 compiler developed by a single developer, targeting x86_64 with System-V ABI and supporting Linux and BSDs. It features an SSA-based optimization pipeline, DWARF5 debug info, bit-identical bootstrap, and has been validated against 100 real-world open-source projects.

QSOE: QNX-inspired OS with dual-kernel architecture

Hacker News Top

QSOE project v0.1 is released, providing a QNX-compatible operating system with two microkernel variants (custom Skimmer kernel and seL4-based), shared userspace, and support for SiFive Unmatched RISC-V hardware.