Lexical analysis, parsing, syntax-directed translation, runtime environments, intermediate code generation, local optimization, data flow analysis, constant propagation, liveness analysis, common subexpression elimination.
First phase of compiler: converts source code to tokens.
Syntactic analysis: check grammar and build parse tree.
Attach semantic actions to grammar rules to produce output (e.g., intermediate code).
Memory organization: stack for function calls, heap for dynamic allocation.
Three-address code (TAC), quadruples, triples, abstract syntax trees.
Optimizations within a basic block: constant folding, algebraic simplification, copy propagation.
Global analysis: reaching definitions, live variables, available expressions.
Replace variable with constant value if known.
Determine which variables are live at each program point (used before next write).
Replace duplicate expression evaluations with single computation.