// the find
rui314/9cc
A Small C Compiler
A small, hand-written C compiler targeting x86-64, written by rui314 as a teaching exercise in compiler construction. It's for developers who want to understand how a real compiler pipeline (parse -> semantic analysis -> IR -> register allocation -> codegen) works end to end, not for anyone who needs to actually compile C code today.
The staged architecture is unusually easy to follow for a compiler codebase — each phase (parse.c, sema.c, gen_ir.c, regalloc.c, gen_x86.c) is its own file with a clear single job, which makes it a good reference for learning how register allocation and IR lowering actually work in practice. The README explains the reasoning behind every unconventional choice (no free(), reading whole files into memory, hand-rolled recursive descent instead of lex/yacc) instead of just listing features, so you understand the tradeoffs rather than guessing at them. The IR has infinite virtual registers mapped down to real ones, which is the same technique production compilers use, just stripped down to something you can read in one sitting.
It's dead: last push was 2020 and the README itself tells you to go use chibicc instead, so cloning this over its successor is actively the wrong move for anyone except someone following the author's older blog series. Language coverage is intentionally incomplete — the author states outright it can't compile real-world C yet, so don't expect switch statements, structs, or much of the standard library to work reliably. x86-64-only codegen with no other backend, and the test suite (test.c plus two .inc files) is nowhere near enough to trust this with anything beyond toy programs.