"Amker.Cheng" <amker.ch...@gmail.com> writes:
> Hi :
>    I found the temp register used for saving registers when expanding
> prologue is defined by
> macro MIPS_PROLOGUE_TEMP_REGNUM on mips target, like:
>
> #define MIPS_PROLOGUE_TEMP_REGNUM \
>   (cfun->machine->interrupt_handler_p ? K0_REG_NUM : GP_REG_FIRST + 3)
>
> I don't understand why using registers starting from $3?

It's not "starting from $3".  It's $3 and nothing else ;-)  It's not
intended to be used as (MIPS_PROLOGUE_TEMP_REGNUM + N).

$3 was chosen because it's a MIPS16 register, and can therefore
be used for both MIPS16 and normal-mode code.  $2 used to be the
static chain register, which left $3 as the only free call-clobbered
MIPS16 register.  I changed the static chain register to $15 to avoid
a clash with the MIPS16 gp-load sequence:

    http://gcc.gnu.org/ml/gcc-patches/2008-08/msg00622.html

so $2 is probably free now too.

Richard

Reply via email to