2 (** This module provides a translation of [RTL] programs to [ERTL] programs. *)
4 (** The work consists in expliciting the calling convention.
6 Function call instructions will be expanded so has to explicitely pass
7 arguments on dedicated physical registers, and then on specific places in
8 the stack if there are not enough registers.
10 We add a prologue at the beginning of each function that does the following
12 - Allocate enough space on the stack for the function to execute.
13 - Save the return address.
14 - Save callee-saved registers.
15 - Fetch parameters from physical registers and potentially from the stack.
17 Also, we add an epilogue which pretty much reverses the effects of the
19 - Save the return value in physical registers that can only be used for
21 - Restore callee-saved register.
22 - Restore the return address.
23 - Free the allocated space on the stack.
24 - Assign the return value to the physical return registers. *)
26 val translate : RTL.program -> ERTL.program