> For the complete documentation index, see [llms.txt](https://isubasinghe.gitbook.io/isithas-wiki/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://isubasinghe.gitbook.io/isithas-wiki/computer_science/programming_language_theory/codegen.md).

# codegen

## Basic idea

The compiler back-end: lowering an intermediate representation to target machine instructions, allocating registers, scheduling, and emitting binary code.

## Key facts

* Common IRs: three-address code, SSA.
* Phases: instruction selection → scheduling → register allocation → emission.
* Register allocation reduces to graph colouring on the interference graph.
