This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Why doesn't -fomit-frame-pointer work(very well)?
>> 1) Bump FIRST_PSEUDO_REGISTER by two.
>> 2) define FRAME_POINTER_REGNUM and ARG_POINTER_REGNUM to be the
>> new pseudo-registers
>
>Actually, you can leave FRAME_POINTER_REGNUM == ARG_POINTER_REGNUM
>as you do currently.
Ok, I've got:
/* Base register for access to local variables of the function. */
#define HARD_FRAME_POINTER_REGNUM 14
/* Base register for access to local variables of the function. */
#ifndef SUPPORT_SUN_FPA
#define FRAME_POINTER_REGNUM 24
#else
#define FRAME_POINTER_REGNUM 56
#endif
#define REGISTER_NAMES \
{"%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6", "%d7", \
"%a0", "%a1", "%a2", "%a3", "%a4", "%a5", "%a6", "%sp", \
"%fp0", "%fp1", "%fp2", "%fp3", "%fp4", "%fp5", "%fp6", "%fp7", \
".fp" }
#define ELIMINABLE_REGS \
{{ ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
{ ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \
{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
{ FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}} \
#define CAN_ELIMINATE(FROM, TO) \
((TO) == STACK_POINTER_REGNUM ? ! frame_pointer_needed : 1)
#define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
(OFFSET) = 0 /* Total hack for now, fix later... */
1) I'll assume the above is correct.
2) Is there anything esle that has to be done?
I've tried:
/tmp/crap/bin/m68k-elf-gcc -fomit-frame-pointer -mcfv4e -O -S -o /tmp/z.s /tmp/z.c
On the code:
typedef __builtin_va_list __gnuc_va_list;
typedef __gnuc_va_list va_list;
extern void putzi(char c, char **p);
extern int _vformat (void (*putsub)(char c, char **p),
char **putbuf, const char *fmt, va_list argp);
int printf(const char *template, ...)
{
int retval;
va_list args;
__builtin_stdarg_start((args),template);
retval = _vformat(putzi, (char **)0, template, args);
__builtin_va_end(args);
return (retval);
}
And it produces:
printf:
link.w %a6,#0
pea 12(%a6)
move.l 8(%a6),-(%sp)
clr.l -(%sp)
pea putzi
jbsr _vformat
lea (16,%sp),%sp
unlk %a6
rts
Which didn't eliminate the frame pointer. I see from dumps that the
".fp" register(24) *is* eliminated in favor of "%a6"(14), and from gdb I see:
(gdb) c
Continuing.
Hardware watchpoint 18: *$4
Old value = 1
New value = 0
eliminate_regs_in_insn (insn=0x40023820, replace=0)
at /home/pbarada/work/cvs-wavemark/cross-linux-tools/gcc-304/gcc/reload1.c:3237
(gdb) p *ep
$5 = {from = 14, to = 15, initial_offset = 4, can_eliminate = 0,
can_eliminate_previous = 1, offset = 8, previous_offset = 4,
ref_outside_mem = 1, from_rtx = 0x4001c020, to_rtx = 0x4001c000}
(gdb) call debug_rtx(insn)
(insn 19 16 21 (set (mem/f:SI (pre_dec:SI (reg/f:SI 15 %sp)) 0)
(plus:SI (reg/f:SI 15 %sp)
(const_int 16 [0x10]))) 60 {pushasi} (nil)
(nil))
(gdb)
So it looks like it tried to eliminate the frame pointer and then
failed. I'm assuming that my defintion of INITIAL_ELIMINATION_OFFSET
needs to be correct for all of this to work(since ep->can_eliminate is
set to 0 since ep->previous_offset doesn't match ep->offset), right?
Thanks.
--
Peter Barada Peter.Barada@motorola.com
Wizard 781-852-2768 (direct)
WaveMark Solutions(wholly owned by Motorola) 781-270-0193 (fax)