A flow chart shows the stages of the compiler, including one new step in the assembly generation stage.
1. The lexer turns program.c into a token list.
2. The parser turns the token list into an abstract syntax tree.
3. Semantic analysis turns the AST into a transformed AST. It has three steps:
a. Identifier resolution
b. Type checking
c. Loop Labeling
4. TACKY Generation turns the transformed AST into TACKY.
5. Optimization turns TACKY into optimized TACKY. It has four steps:
a. Constant Folding
b. Unreachable Code Elimination
c. Copy Propagation
d. Dead Store Elimination
An arrow leads from each step to the next. Another arrow leads from dead store elimination back to constant folding.
6. Assembly generation turns optimized TACKY into assembly. ...
Get Writing a C Compiler now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.