01Chapter 1: How a running program uses memoryThis chapter describes how a compiled program organizes memory while it runs. Later chapters build on it: activation records, scope, parameter passing, and the heap.4 min read
02Chapter 2: Activation records and the control stackThis chapter assumes you can read C-style functions and recursion, and that you know how a stack works. It covers what a compiler stores for each procedure call, how those records pile up on the control stack, and how to draw the stack for a recursive call. Later chapters cover the calling sequence 4 min read
03Chapter 3: Calling sequence and frame layoutThis chapter assumes you know what an activation record is and how the control stack grows and shrinks, as covered in the previous chapter. It also assumes basic C functions and recursion. Here you will see what each field of a frame holds and which steps the caller and callee perform at a call and 3 min read
04Chapter 4: Static and dynamic scope, access links and displayThis chapter assumes you know what an activation record is, how the control stack grows and shrinks on calls and returns, and what a nested procedure is. Those ideas come from the earlier chapters on activation records and frame layout.4 min read
05Chapter 5: Parameter passing: value, reference, copy-restore and nameThis chapter assumes you know what an activation record is and how the calling sequence stores arguments in it. It also assumes you can read C-style code. Here we ask what the callee receives for each parameter and how its changes reach the caller.4 min read
06Chapter 6: Heap allocation and garbage collection basicsThis chapter assumes you know the runtime layout from earlier chapters (code, static data, stack, heap) and can read basic C and Python. It covers how the heap hands out memory, how that memory is reclaimed, and the standard GATE comparisons between reclamation schemes.4 min read
07Chapter 7: Why compilers use intermediate codeThis chapter explains what intermediate code is and why a compiler builds it between parsing and machine code generation. It assumes you know parse trees and basic syntax-directed translation, and that you can read C-style code. Later chapters cover specific forms, such as syntax trees, DAGs and thr5 min read
08Chapter 8: Syntax trees and DAGsThis chapter assumes you can read parse trees, know what a syntax-directed definition is, and can follow three-address code at an introductory level. It covers how a compiler stores an expression as a tree, how a directed acyclic graph (DAG) removes repeated work from that tree, and how to count nod5 min read
09Chapter 9: Three-address codeThis chapter assumes you can read C-style expressions, know what a syntax tree is, and have seen syntax-directed translation at an introductory level. It covers the instruction forms of three-address code (TAC), how expressions are translated into it, and the mistakes that cost marks in GATE questio4 min read
10Chapter 10: Quadruples, triples and indirect triplesThis chapter assumes you can read three-address code (instructions with at most one operator and three addresses) and know what a syntax tree is. It also assumes basic C-style programming. Three-address code is an abstract idea. A compiler must store it in some data structure, and GATE questions oft4 min read
11Chapter 11: Translating control flow and boolean expressionsThis chapter assumes you know three-address code from the previous chapters. You should be able to read instructions such as t1 = a + b, goto L and if a < b goto L. You should also know what a syntax-directed definition is, with inherited and synthesized attributes.4 min read
12Chapter 12: BackpatchingThis chapter assumes you can read three-address code and know how a syntax-directed definition attaches attributes to grammar symbols. It also assumes you know the short-circuit translation of boolean expressions from the previous chapter, where B.true and B.false are labels passed down as inher3 min read
13Chapter 13: Basic blocks and control flow graphsThis chapter assumes you can read three-address code (covered in the earlier chapters on three-address code and its storage forms). You should also know what a graph is and what a jump target is. Every data flow analysis later in this tutorial runs on the structure built here, so GATE questions on r4 min read
14Chapter 14: Local and peephole optimizationThis chapter assumes you can split three-address code into basic blocks and read a simple DAG. Both were covered in earlier chapters. It also assumes you know what a live variable is, at the level of "its value may be read later".4 min read
15Chapter 15: Dominators and natural loopsThis chapter assumes you can draw a control flow graph (CFG) from basic blocks and that you know the iterative data flow method from the earlier chapters. Dominators are the tool compilers use to find loops in a CFG. Once the loops are found, optimizations such as loop-invariant code motion can be a4 min read
16Chapter 16: The data flow analysis frameworkThis chapter assumes you can split three-address code into basic blocks and draw a control flow graph (CFG). It also assumes you are comfortable with union, intersection and difference on sets. Later chapters apply the framework to reaching definitions, live variables and available expressions. Here5 min read
17Chapter 17: Reaching definitionsThis chapter assumes you know basic blocks, control flow graphs (CFGs) and the set operations union and difference. The next chapters build on this analysis: live variables, available expressions and the general iterative solver.3 min read
18Chapter 18: Live variable analysisThis chapter assumes you can split three-address code into basic blocks and draw a control flow graph (CFG). It also assumes you know the gen/kill, IN/OUT vocabulary from the data flow framework chapter, and basic set operations.4 min read
19Chapter 19: Available expressionsThis chapter assumes you can split three-address code into basic blocks, draw a control flow graph (CFG), and compute gen and kill sets for reaching definitions. It also assumes you are comfortable with set union, intersection and difference.3 min read
20Chapter 20: Iterating to a fixed pointThis chapter assumes you can build a control flow graph from three-address code. It also assumes you know the gen, kill, IN and OUT sets for reaching definitions, live variables and available expressions. You should be comfortable with union, intersection and set difference.4 min read
21Chapter 21: Optimizations that use data flow resultsThis chapter assumes you can build a control flow graph (CFG) from three-address code. It also assumes you know the gen/kill setup for reaching definitions, live variables and available expressions, and the iterative solver. Here we use their results. Each optimization below is only safe when a spec5 min read
22Chapter 22: Static single assignment formThis chapter assumes you can read three-address code, split it into basic blocks, and draw a control flow graph. It also assumes you know what reaching definitions are and what dominators are. Static single assignment form (SSA) is an intermediate representation. Each variable has exactly one assign4 min read
23Chapter 23: GATE problem patterns and solving strategiesThis chapter assumes you have read the earlier chapters on activation records, scope, parameter passing, three-address code, basic blocks, and the data flow framework. GATE compiler-design questions fall into a few repeating patterns. For each one, this chapter gives a first move and the usual trap.3 min read