This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
scratch registers for peephole2
- To: gcc at gcc dot gnu dot org
- Subject: scratch registers for peephole2
- From: Richard Earnshaw <rearnsha at arm dot com>
- Date: Fri, 05 Jan 2001 19:56:52 +0000
- cc: rearnsha at arm dot com
- Organization: ARM Ltd.
- Reply-To: rearnsha at arm dot com
I've deleted the original mail, but I seem to recall that the AVR port was
having problems with scratch registers being used in peephole2 that were
not unsafe. Looking at the code in recog.c, it would appear that there is
potentially a similar problem on the ARM with the return register (which
is treated as a call-clobbered reg, but can contain real data).
Shouldn't there be a MD macro in that code that specifies that the
register is safe to use, something like
peep2_find_free_register:
/* Don't allocate fixed registers. */
if (fixed_regs[regno])
continue;
/* Make sure the register is of the right class. */
if (! TEST_HARD_REG_BIT (reg_class_contents[class], regno))
continue;
/* And can support the mode we need. */
if (! HARD_REGNO_MODE_OK (regno, mode))
continue;
/* And that we don't create an extra save/restore. */
if (! call_used_regs[regno] && ! regs_ever_live[regno])
continue;
/* And we don't clobber traceback for noreturn functions. */
if ((regno == FRAME_POINTER_REGNUM || regno ==
HARD_FRAME_POINTER_REGNUM)
&& (! reload_completed || frame_pointer_needed))
continue;
>>> /* The target may have further reasons for rejecting the register.
*/
>>> if (! REGNO_OK_FOR_PEEPHOLE2 (regno))
>>> continue;
I'd be inclined to make this macro unconditional, any port using peephole2
should define it (it can be 1 if all registers are safe).