This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: MIPS ABI- Dead end functions


Shane Nay wrote:
> In the case that a function is dead end, i.e. has no references to 
> the gp, like calling another function, then the sequence-
> lui gp, 0xfc0 /* some number */
> addiu gp, gp, offestval
> addu gp, gp, fncaddr
> 
> I think is not required.  Like for instance-
> int mult(int x, int y) {
>         return x*y;
> }
> 
> creates-
> 00000000 <mult>:
>    0:   3c1c0000        lui     gp,0x0
>    4:   279c0000        addiu   gp,gp,0
>    8:   0399e021        addu    gp,gp,t9
>    c:   03e00008        jr      ra
>   10:   00851018        mult    v0,a0,a1
> 
> when it could just be-
>    0:   03e00008        jr      ra
>    4:   00851018        mult    v0,a0,a1
> 
> right?, or am I missing something?

That's right (SGI's cc does so).

> Normally gcc would pull out 
> unused register references in it's optimization passes (REG_DEAD), 
> but this stuff is being generated from macros in the assembler-
> 
>         .frame  $sp,0,$31               # vars= 0, regs= 0/0, args= 
> 0, extra= 0
>         .mask   0x00000000,0
>         .fmask  0x00000000,0
>         .set    noreorder
>         .cpload $25
>         .set    reorder
>         .set    noreorder
>         .set    nomacro
> 
> So..., how can this situation be handled cleanly?  The cleanest way I 
> can think of is to modify gcc so that it does not generate the 
> .cpload $25 sequence in the case that $gp is unused.  What do you 
> think?

Yes, that's the way to go. You may talk with Graeme Peterson about
it, his RFC for QNX PIC addresses this issue, too.


Thiemo


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]