[Openmcl-devel] Porting the OpenMCL Compiler
James Bielman
jamesjb at jamesjb.com
Wed Jul 6 01:07:24 PDT 2005
Hi,
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
either way.
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
results:
ARG_Z 132643
IMM0 50129
VSP 48012
ARG_Y 34665
FN 33836
SAVE0 32224
TEMP3 19587
SAVE1 18077
ALLOCPTR 11647
SAVE2 11001
TEMP4 9398
LOC-PC 9239
ARG_X 8769
NARGS 8744
SAVE3 7772
TEMP0 7249
TSP 5528
SAVE4 5155
TEMP2 4285
SAVE5 3717
SAVE7 3431
SP 2963
SAVE6 2747
IMM1 2436
ALLOCBASE 2045
IMM2 839
IMM3 517
TEMP1 446
RCONTEXT 293
IMM4 237
IMM5 13
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?
James
More information about the Openmcl-devel
mailing list