Puzzle about macro MIPS_PROLOGUE_TEMP_REGNUM

2010-06-04 Thread Amker.Cheng
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?
in my application, I have to save DFmode fpu regs through gpr regs,
that is $3,$4 in this case,
just like :
mfc1  $3,  $fpr
sw $3,  addr
mfc1  $4,  $fpr+1
sw $4,  addr+4

apparently this would crush the argument in $4.

Here is question,
why don't use $8 for MIPS_PROLOGUE_TEMP_REGNUM like EPILOGUE_TEMP?
Or have I done something wrong?

So, any clarification? Thanks in advance.
-- 
Best Regards.


Re: Puzzle about macro MIPS_PROLOGUE_TEMP_REGNUM

2010-06-04 Thread Ian Lance Taylor
"Amker.Cheng"  writes:

>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?
> in my application, I have to save DFmode fpu regs through gpr regs,
> that is $3,$4 in this case,
> just like :
> mfc1  $3,  $fpr
> sw $3,  addr
> mfc1  $4,  $fpr+1
> sw $4,  addr+4
>
> apparently this would crush the argument in $4.

Why not use $3 in all cases?  Why switch to $4?

> why don't use $8 for MIPS_PROLOGUE_TEMP_REGNUM like EPILOGUE_TEMP?

$8 can hold an argument value.  I think $13 would be a possibility,
but I don't see anything wrong with $3.

Ian


Re: Puzzle about macro MIPS_PROLOGUE_TEMP_REGNUM

2010-06-04 Thread Richard Sandiford
"Amker.Cheng"  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


Re: Puzzle about macro MIPS_PROLOGUE_TEMP_REGNUM

2010-06-06 Thread Amker.Cheng
>
> 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
Thank all of you for explanation.

> 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.
Seems $2 is used for gp load in MIPS16 defined by MIPS16_PIC_TEMP_REGNUM,
which should not conflict with MIPS_PROLOGUE_TEMP_REGNUM either.

Mips target uses mips_split_doubleword_move in mips_save_reg
 to implement double float reg saving.
Seems I have to provide a special pattern using exactly
the only (MIPS_PROLOGUE_TEMP_REGNUM) register,
rather than paired registers starting from it.

But, more patterns might result in consuming more memory, time.
Since my application is some kinda very unique(o32 abi and no MIPS16),
maybe I could use some paired temporary register in this purpose,
like $8-$15, $24-$25.

Thanks.
-- 
Best Regards.