In this lecture we continue the previous lecture on memory managagement in which we study memory safety, automated memory management, and several garbage collection algorithms. See the previous lecture for the slides.
We extend the study of control-flow statements by looking at the translation of while loops. Loops do not need additional constructs in the intermediate language since the can be expressed using (conditional) jumps. But register allocation for loops requires the extension of liveness analysis to compute a fixpoint of the analysis results.
To express context-sensitive transformations, Stratego provides dynamic rewrite rules. We provide several examples that are useful in your compiler.
We then discuss code generation for functions, including: