Internals & Design

C type representation (c_type.h & c_type.c) is shared by the frontend and backend because the backend is responsible for ABI-specific lowering of calling conventions.

The C frontend is structured like so:

The backend (ir_*) uses an IR in Static Single Assignment (SSA) form. Instructions have a return type and up to two operands. Because of SSA form, temporaries are simply referenced by the instruction that provides their definition, so an explicit output operand is not required. The list of instructions is defined in ir_op.def. Each basic block in the control flow graph consists of 0 or more phi functions, followed by 0 or more instructions, terminated by a jump (unconditional/conditional branch, return, or trap).

The builder API (ir_builder.c) used by the frontend performs peephole optimizations on the fly, mainly constant folding.

Object file interface routines are in obj.[c/h] ELF implementation in o_elf.[c/h]. Support for other object formats like PE and Mach-O is planned. Debug information in the form of DWARF is also planned, but it is a sizeable undertaking.

The -d... compiler flag can be used to print the output of different stages of the backend for debugging.

The backend performs the following main passes:

[ ... ]

generated from doc/internals.md 2026-10-31