[Openmcl-devel] Porting the OpenMCL Compiler
jamesjb at jamesjb.com
Wed Jul 6 08:07:24 UTC 2005
I've been spending a fair bit of time studying the OpenMCL internals
and I now think I'm dangerous enough to consider a port to ARM
(probably Linux first, then hopefully Windows CE).
Obviously this is a huge task and I certainly don't expect to get very
far anytime soon, but hopefully I can learn a lot from the process
I'm planning to start out implementing kernel subprimitives and the
LAP assembler, but I'd like to get some advice on register usage,
since the ARM has far fewer registers than PowerPC.
Basically, there are 16 GPRs, r0-r15, except r15 is the PC, r14 is the
link register, and r13 is typically the control stack pointer. So,
apart from any tricks to be done with reusing lr for other purposes
(although I'd think that, being a GPR, it could fulfill the same
purpose as the LOC-PC register on PPC?), we are left with 13 GPRs.
I don't know if there are any guidelines about how many registers are
necessary for it to be worth paritioning into boxed and unboxed. If
this isn't enough then obviously life gets more complicated...
I wrote a little Lisp program to loop over all the fbound symbols in
the OpenMCL image and disassemble them to a file, then grepped the
output (hopefully correctly) to count register usage. Here are the
Based on this (and some possibly incorrect common sense), here's what
I've got so far:
r0 imm0 unboxed temp reg
r1 imm1 unboxed temp reg
r2 temp0 boxed temp reg
r3 temp1 boxed temp reg
r4 save0 boxed caller-save reg
r5 save1 boxed caller-save reg
r6 arg_y second to last argument
r7 arg_z last argument
r8 nargs number of function arguments
r9 allocptr heap free pointer
r10 fn current function object
r11 rcontext thread context register
r12 vsp value stack pointer
r13 sp control stack pointer
r14 lr link register
r15 pc program counter
This is assuming the temp stack pointer could be put in memory
somewhere, perhaps in the tcr? Also, this doesn't seem like very many
immediate registers, but according to the register counts for PowerPC,
maybe this isn't so bad?
I'm not sure what to use for NFN or FNAME either, hmm.
Also, I'm curious why OpenMCL uses registers for the last arguments
instead of the first, is there a sneaky reason why this is so?
More information about the Openmcl-devel