← 📝 Intermediate Code Generation
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.

  1. 1i = 1
  2. 2j = 1
  3. 3t1 = 10 * i
  4. 4t2 = t1 + j
  5. 5a[t2] = 0
  6. 6j = j + 1
  7. 7if j <= 10 goto 3
  8. 8i = i + 1
  9. 9if i <= 10 goto 2
  10. 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.