Subject: pcc port to pdp10.
To: None <port-pdp10@netbsd.org>
From: None <ragge@ludd.luth.se>
List: port-pdp10
Date: 02/11/2003 17:44:58
Some brief overview of some of the conventions I used for pcc. It differ
slightly from the gcc conventions in some areas. Please come up with
comments about this.

I have written it for a machine model where all text and pre-allocated
data are in the same section, but later allocated data can be anywhere.

Calling convention:
All parameters are passed on the stack, instead of some of them in
registers. This makes it much easier to debug. Also, 17 is used as
stack pointer and 16 as framepointer.

The stack frame looks like this for a function with 2 saved regs
and two automatics:

	!             !
	+-------------+
High	! auto var 2  ! < - sp points here
addr	+-------------+
	! auto var 1  !
	+-------------+
	! saved reg 1 !
	+-------------+
	! saved reg 1 !
	+-------------+
	!   old fp    ! < - fp points here
	+-------------+
	!   old pc    !
	+-------------+
	!    arg1     !
	+-------------+
Low	!    arg2     !
addr


The prologue for functions:

	push 17,16
	move 16,17
	< eventual save regs on stack >
	< eventual addi 17,val for automatics space on stack >


The epilogue:
	< restore of saved regs >
	move 17,16
	pop 17,16
	popj 17,


Register 1-7 is used as caller-saved variables (as in gcc) and 10-15 are
callee-saved regs. Register 0 is used as temporary scratch register.

Casting/type conventions:
I use 9/18/36/36/72 bits for char/short/int/long/long long types.
Char/short pointers are stored in the "version-271-microcode format".
It would be straightforward to convert it to use other byte pointer formats. 

Casts between char/short pointers and any other pointer are done as 
expected, but casting ints/longs have special rules: ints/longs are
assumed to containing a (9-bit) byte offset when casted to/from a
pointer. Exception here is if it is a constant that is casted, it will
_not_ be converted at all. Hence

	char *foo = (char *)0700000123456;

will not convert the value, but:

	int a; char *foo = (char *)a;

will put the rightmost two bits in bit 4-5 and right-shift the int value
two bits.


I haven't written any support for floating point yet. Actually, I 
haven't even tried any test programs on the compiler except for getting
the kernel to run :-)

-- Ragge