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)):
  1. Save any of the caller-saved registers (EAX, ECX, EDX) which are live across the call.
  2. Push the argument values on the stack, beginning with xn and working back to x1.
  3. Execute the CALL instruction.
  4. Add 4*n to ESP (the stack pointer), thus removing all argument values from the stack.
The callee does the following:
  1. 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.
  2. Do some work.
  3. 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