[LLVMdev] another mips16 puzzle

reed kotler rkotler at mips.com
Thu Oct 11 17:01:17 PDT 2012


Usually we do all the accessing of stack variables via the SP register.

When the stack size is dynamic we need a frame pointer, FP.

There is a traditional FP register for MIPS, but FP is not a mips16 
register so in general it has little use for mips16 because you can't 
directly address it except in the move instruction when moving from/to 
mips16 to mips32 register.

There are several ways to deal with this situation.

One way is to just allocate a mips16 physical register to function as FP 
and use it for the whole duration of the function and copy SP into it at 
the beginning of the function. This is somewhat wasteful since we don't 
have so many mips 16 registers and there may be many paths through the 
function where we don't need to access stack data at all.

It would seem most logical to allocate FP for the duration of the 
function and have a virtual register which is an alias of FP that can 
take on various physical locations.

so at the beginning of the function.

mov vr, SP
mov FP, vr   ; you can't copy SP which is a mips32 register into another 
mips 32 register
                     ; directly; i.e. you have to go through a mips16 
register
....
then if you run out of registers and need that physical register 
allocated to vr, you can give it up and reload it from FP anytime you 
need it again.

I'm not sure if there is some simple way to do all of this in llvm.

There are some complications here because you won't be able to access 
stack locations without this vr so you have to be careful that it is not 
given up to easily because you will end up reloading it a lot.

tia.

Reed










More information about the llvm-dev mailing list