In the LLAMA, parameters passed to a function and local variables
are accessed via the dup instruction on the stack.
For that reason, the stack position of parameters and variables
has to be known at compile time. This task is performed by the
compiler environment: it contains pairs
associating parameters and local variables with stack positions.
Let us consider the following LL function:
(defun f5 (x y) (+ x 5 y))
.proc f5/2 dup 2 % variable x push-constant 5 dup 3 % variable y ll-builtin + 3 return 2 .end
The arguments for the two dup instructions were determined with
the help of the environment. As shown in the following diagram,
the compiler has to simulate the effects of the instructions on the stack
in order to keep track of the parameter positions:
In the transformation rules given in section 6.2, these changes of the environment are not made explicit. Only if variables are added to the environment (as in defun and let), the environment extension is shown.