Subtopic 4 of 5
8.4Basic blocks and the flow graph
Leaders: the first instruction, any jump target, any instruction after a jump. A basic block is a leader up to (not including) the next leader. Edges follow fall-through and jumps.
- 1i = 1
- 2j = 1
- 3t1 = 10 * i
- 4t2 = t1 + j
- 5a[t2] = 0
- 6j = j + 1
- 7if j <= 10 goto 3
- 8i = i + 1
- 9if i <= 10 goto 2
- 10x = 0
- Rule 1: the first instruction is a leader.
- Rule 2: the target of any jump is a leader.
- Rule 3: the instruction right after a jump is a leader.
- A basic block runs from one leader up to (not including) the next leader.
- Flow graph edges: fall-through to the next block (unless unconditional goto) and jump edges.
Previous year questions: Intermediate Code Generation (5)
PYQs are grouped by topic, so this is the full set for Intermediate Code Generation; try the ones that match this subtopic. Open all 5 on the topic page.