CS 4120: Introduction to Compilers
Fall 2011

Problem Set 4: Intermediate Code Generation

due: Friday, October 7, 11:59PM

changes: None so far.

  1. Using the IR and translation rules given in class, give the IR translation of the following Xi statement: q[i] = f(q[i])+q[i-1]
  2. Show how to translate the Xi short-circuit “or” operation, e1|e2, to IR. In particular, define Ce1|e2, t, f⟧. (Hint: look at the translation of &.)
  3. Suppose that Xi is extended with the “foreach” statement from PS3. Give a suitable syntax-directed translation rule or rules to describe intermediate code generation for this new statement form.