Compilers
Table of contents
Introduction
A compiler takes a program as input and produces an executable (e.g. assembly code code or bytecode).
A compiler generally has five phases:
- Lexical analysis
- Parsing
- Semantic analysis (e.g. types and scope rules)
- Optimization
- Code generation (translation)
These notes cover the five phases.
Many compilers are separated into a frontend and a backend. The frontend typically translates the source program into an IR (intermediate representation), the backend translates IR into target output languages. LLVM uses the frontend/backend concept to enable user-provided frontends to access the LLVM toolchain for optimization and codegen.