This textbook describes all phases of a modern compiler - lexical analysis, parsing, abstract syntax, semantic actions, intermediate representations, instruction selection via tree matching, dataflow analysis, graph-coloring register allocation, andruntime systems. It includes good coverage of current techniques in code generation and register allocation, as well as functional and object-oriented languages, that is missing from most books. The most accepted and successful techniques are described, rather than a catalog of every possible variant. Descriptions of the interfaces between modules of a compiler are illustrated with actual C header files. A feature of the book is a designed compiler implementation project in C, including front-end and ´high-tech´ back-end phases, so that students can build a complete working compiler in one semester.