Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

References

Foundational Compiler Textbooks

  • Compilers: Principles, Techniques, and Tools (The Dragon Book) - The definitive classic textbook by Aho, Lam, Sethi, and Ullman. Comprehensive treatment of lexical analysis, parsing, semantic analysis, and code generation with formal foundations. Updated in 2006 with modern optimization techniques and garbage collection coverage.

  • Engineering a Compiler (3rd Edition) - Keith Cooper and Linda Torczon’s practical engineering approach to compiler construction. Covers SSA forms, instruction scheduling, and graph-coloring register allocation.

  • Modern Compiler Implementation in C/Java/ML - Andrew Appel’s series providing detailed coverage of all compiler phases with working implementations. Available in three language editions. Excellent treatment of advanced topics including object-oriented and functional language compilation.

  • Introduction to Compilers and Language Design - Douglas Thain’s modern, accessible textbook offering a one-semester introduction. Enables building a simple compiler for a C-like language targeting X86 or ARM assembly with complete code examples.

Practical Hands-On Guides

  • Crafting Interpreters - Robert Nystrom’s exceptional hands-on guide building two complete interpreters from scratch. Free online. Covers parsing, semantic analysis, garbage collection, and optimization with beautiful hand-drawn illustrations.

  • Building an Optimizing Compiler - Robert Morgan’s advanced treatment of optimization techniques including data flow analysis, SSA form, and advanced optimization passes.

  • Writing a C Compiler: Build a Real Programming Language from Scratch - Nora Sandler’s book providing a clear path through compiler construction complexities. Progressive approach from simple programs to advanced features using pseudocode for any-language implementation.

  • Essentials of Compilation: An Incremental Approach in Python - Jeremy Siek’s unique incremental approach building a compiler progressively. Makes abstract concepts tangible through direct Python implementation, connecting language design decisions with compiler implementation.

  • Let’s Build a Compiler - Jack Crenshaw’s practically-oriented tutorial demystifying compiler internals. Step-by-step approach presenting up-to-date techniques with detailed implementation guidance.

Specialized Topics

  • Advanced Compiler Design and Implementation - Steven Muchnick’s comprehensive treatment of advanced compiler optimization techniques. Covers case studies of commercial compilers from Sun, IBM, DEC, and Intel. Introduces Informal Compiler Algorithm Notation (ICAN) for clear algorithm communication.

  • Parsing Techniques: A Practical Guide (2nd Edition) - Dick Grune and Ceriel Jacobs’ definitive 622-page treatment of parsing techniques. Free PDF available. Covers all parsing methods with clear explanations and practical applicability.

  • Types and Programming Languages - Benjamin Pierce’s definitive reference for understanding type systems. While not specifically a compiler book, it’s crucial for semantic analysis in compilers. Covers type checking, type inference, and advanced type system features.

  • Garbage Collection: Algorithms for Automatic Dynamic Memory Management - Richard Jones and Rafael Lins’ comprehensive survey of garbage collection algorithms. Covers all major collection strategies including mark-sweep, copying, generational, and concurrent collectors.

LLVM Infrastructure

  • Learn LLVM 17: A Beginner’s Guide - Kai Nacke and Amy Kwan’s hands-on guide to building and extending LLVM compilers. Covers frontend construction, backend development, IR generation and optimization, custom passes, and JIT compilation.

  • LLVM Tutorial: Kaleidoscope - Official step-by-step tutorial building a simple language frontend with LLVM. Covers lexing, parsing, AST construction, LLVM IR generation, JIT compilation, and optimization.

  • Clang Compiler Frontend - Ivan Murashko’s exploration of Clang internals with practical applications for static analysis and custom tooling. Covers AST operations, IDE integration, and performance optimization.

  • LLVM’s Analysis and Transform Passes - Documentation of LLVM’s optimization passes, useful for understanding what optimizations production compilers implement.

MLIR Infrastructure

  • MLIR Passes - Comprehensive documentation of MLIR’s transformation and analysis passes. Covers affine loop transformations, buffer optimizations, control flow simplifications, and dialect-specific passes for GPU, async, linalg, and other domains.

  • MLIR Tutorial - Step-by-step guide building a compiler for the Toy language using MLIR. Demonstrates how to define dialects, implement lowering passes, and leverage MLIR’s infrastructure for optimization.

  • MLIR Dialect Conversion - Guide to MLIR’s dialect conversion framework for progressive lowering between abstraction levels. Essential for understanding how to transform between different IR representations.

  • MLIR Pattern Rewriting - Documentation on MLIR’s declarative pattern rewriting infrastructure. Shows how to express transformations as patterns for maintainable optimization passes.

Cranelift Resources

Language-Specific Implementation

  • Compiling to Assembly from Scratch - Vladimir Keleshev’s modern approach using TypeScript subset targeting ARM assembly. Covers both baseline compiler and advanced extensions with complete source code.

  • Implementing Functional Languages: A Tutorial - Simon Peyton Jones and David Lester’s guide to implementing non-strict functional languages. Free PDF. Includes complete working prototypes using lazy graph reduction.

  • Write You a Haskell - My old tutorial on functional language implementation including parser, type inference, pattern matching, typeclasses, STG intermediate language, and native code generation.

  • Compiler Construction - Niklaus Wirth’s concise, practical guide. Step-by-step approach through each compiler design stage focusing on practical implementation.

Parsing Tools and Techniques

  • The Definitive ANTLR 4 Reference - Terence Parr’s essential guide to ANTLR parser generator with LL(*) parsing technology. Covers grammar construction, tree construction, and StringTemplate code generation.

  • ANTLR Mega Tutorial - Federico Tomassetti’s comprehensive tutorial covering ANTLR setup for multiple languages (JavaScript, Python, Java, C#), testing approaches, and advanced features.

  • LR Parsing Theory and Practice - Excellent blog post demystifying the differences between LL and LR parsing with practical examples.

Courses

  • CS 6120: Advanced Compilers: The Self-Guided Online Course - Cornell’s graduate-level compiler optimization course. Covers SSA form, dataflow analysis, loop optimizations, and modern optimization techniques with hands-on projects.

  • Stanford CS 143: Compilers - Introduction to compiler construction covering lexical analysis through code generation. Includes programming assignments building a compiler for a Java-like language.

  • IU P423/P523 Compilers - Jeremy Siek’s course using incremental approach with Racket. Materials available on GitHub.

  • KAIST CS420 Compiler Design - Modern treatment with Rust implementation. Course materials and assignments available on GitHub.

Online Resources and Tutorials

  • Basics of Compiler Design - Torben Mogensen’s free PDF textbook providing solid introduction to compiler construction fundamentals.

  • Compiler Design Tutorials - Collection of articles covering compiler topics from basic to advanced with code examples.

Research Papers and Academic Resources

Rust-Specific Compiler Resources

  • Rust Compiler Development Guide - The official guide to rustc internals. Essential reading for understanding how a production Rust compiler works.

  • Salsa - Framework for incremental computation used by rust-analyzer. Demonstrates modern techniques for responsive compiler frontends.

  • Make A Language - Series of blog posts walking through implementing a programming language in Rust, from lexing through type checking.

  • Introduction to LLVM in Rust - Rust implementation of the LLVM Kaleidoscope tutorial demonstrating LLVM bindings.

Code Generation Resources

  • Cranelift Code Generator - Production code generator written in Rust, designed for JIT and AOT compilation. Good example of modern compiler backend architecture.

  • Introduction to LLVM - Tutorial on using LLVM’s C++ API to generate code, covering the basics of LLVM IR and the programmatic interface.

  • Compiler Design in C - Allen Holub’s 924-page detailed coverage of real-world compiler implementation focusing on code generation.

Tools and Development Environments

  • Tree-sitter - Parser generator creating incremental parsers suitable for editor integration. Good example of modern parsing technology beyond traditional compiler construction.

  • ANTLR - Popular parser generator supporting multiple target languages. Extensive documentation and community resources.

  • Compiler Explorer - Online tool for exploring compiler output across different compilers and optimization levels. Invaluable for understanding code generation.

  • ANTLRWorks - GUI development environment for ANTLR grammars with visualization and debugging features.

Community and Support

  • r/Compilers - Active subreddit for compiler construction discussions, project showcases, and questions.

  • Compiler Jobs - Matthew Gaudet’s curated list of compiler engineering positions.

  • LLVM Discourse - Official LLVM community forum for discussions about LLVM, Clang, and related projects.

  • Rust Compiler Team - Information about contributing to the Rust compiler and joining the community.