In this lecture we study further code generation techniques.
We first study functions in ChocoPy and the operational semantics rules that define their meaning. Then we look at activation records, what motivates their existence, and how they are used to implement function calls. We reconstruct the RISC-V calling convention described in the ChocoPy language implementation guide, looking in detail at the implementation of an example caller and callee.
In the second part of the lecture, we study dynamic rewrite rules in Stratego, which can be used to define context-sensitive transformations. We look at examples for keeping track of stack offsets, and mapping variables to their offsets. See the paper by Bravenboer et al. (2006) for more information about dynamic rules.
In the third part of the lecture, we take a broader look at mechanics for code generation, the properties we would like compilers to adhere to, and to what extend existing mechanisms support the verification of those properties out of the box.
We only briefly touch on these topics. See the references for further information.