MIPS ABI- Dead end functions
Shane Nay
shane@minirl.com
Tue Jul 30 06:08:00 GMT 2002
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? 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?
Thanks,
Shane Nay.
More information about the Binutils
mailing list