SPIN backend changes
Backend changes
The SRC M3 backend is based on gcc. In order to implement some of our
language changes, as well as to
support dynamic linking, we have had to modify the backend. The
changes are in the files gcc/m3.c and gcc/m3.def.
- VIEW
- In order to support VIEW, two new IR instructions
M3_CHECK_SIZE and M3_CHECK_ALIGN were added. These instructions
generate code that are used to perform the dynamic checks that
VIEW performs.
- ALIGNED FOR
- In order to support ALIGNED FOR, a new IR instruction
DECLARE_ALIGNED was added. It generates debugging info that
gdb must recognize.
PC Calling Convention
The PC has a particularly simple calling convention, with all
arguments passed on the stack. The same convention is used by the gcc
compiler on both the Linux and FreeBSD platforms. Here is the calling
sequence for a procedure of n arguments (e.g. foo(x1, x2, ..., xn)):
- Save any of the caller-saved registers (EAX, ECX, EDX) which are
live across the call.
- Push the argument values on the stack, beginning with xn and
working back to x1.
- Execute the CALL instruction.
- Add 4*n to ESP (the stack pointer), thus removing all argument
values from the stack.
The callee does the following:
- Save any callee-saved registers (EBX, ESI, EDI, EBP, ESP) which
are overwritten by the procedure. Typically ESP (the stack
pointer) is preserved by
adding and subtracting the same number of bytes rather than by
copying its value to another location.
- Do some work.
- Execute the RET instruction with no arguments. This leaves ESP
unchanged which is why the caller has to do step 4 itself.
Last changed July 22, 1996
whsieh@cs.washington.edu