From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22010 invoked by alias); 17 Jun 2008 22:14:23 -0000 Received: (qmail 21987 invoked by uid 22791); 17 Jun 2008 22:14:22 -0000 X-Spam-Check-By: sourceware.org Received: from contrabass.post.ru (HELO contrabass.post.ru) (85.21.78.5) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 17 Jun 2008 22:14:03 +0000 Received: from corbina.ru (mail.post.ru [195.14.50.16]) by contrabass.post.ru (Postfix) with ESMTP id 487457210B; Wed, 18 Jun 2008 02:13:59 +0400 (MSD) Received: from [10.193.100.241] (account aesok@post.ru HELO Vista.corbina.ru) by corbina.ru (CommuniGate Pro SMTP 5.1.14) with ESMTPA id 714122405; Wed, 18 Jun 2008 02:13:59 +0400 Date: Tue, 17 Jun 2008 22:26:00 -0000 From: Anatoly Sokolov X-Mailer: The Bat! (v4.0.14) Professional Message-ID: <113229086.20080618021412@post.ru> To: gcc-patches@gcc.gnu.org CC: rth@redhat.com, aesok@post.ru, chertykov@gmail.com Subject: Add more restriction in 'peep2_find_free_register' MIME-Version: 1.0 Content-Type: text/plain; charset=windows-1251 Content-Transfer-Encoding: quoted-printable Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2008-06/txt/msg01112.txt.bz2 Hello. This patch add two more check in 'peep2_find_free_register' function, which find free hard registers for use as scratch registers in peephole2. * It is not allowed to use register that are being declared as global, as scratch register. * For an interrupt function it is safety to use only call-used registers which are saved in prologue. In 'rename_registers' optimization pass this check is done in HARD_REGNO_RENAME_OK macro. This patch add HARD_REGNO_SCRATCH_OK macro for 'peephole2' pass. The HARD_REGNO_SCRATCH_OK macro sould be difined for target which use interru= pt and 'match_scratch' in peephole2 (avr, m68k). For example for avr target: avr.h: #define HARD_REGNO_SCRATCH_OK(REGNO) avr_hard_regno_scrath_ok (REGNO) avr.c: int avr_hard_regno_scrath_ok (unsigned int regno) { /* Interrupt functions can only use registers that have already been saved by the prologue, even if they would normally be call-clobbered. */ if ((cfun->machine->is_interrupt || cfun->machine->is_signal) && !df_regs_ever_live_p (regno)) return 0; return 1; } 2008-06-17 Anatoly Sokolov * recog.c (peep2_find_free_register): Add check for global regs.=20 Add target specific check. Index: gcc/doc/tm.texi =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- gcc/doc/tm.texi (revision 136872) +++ gcc/doc/tm.texi (working copy) @@ -2242,6 +2242,16 @@ allocation. @end defmac =20 +@defmac HARD_REGNO_SCRATCH_OK (@var{regno}) +A C expression that is nonzero if it is OK to use a hard register=20 +@var{regno} as scratch reg in peephole2. + +One common use of this macro is to prevent using of a register that=20 +is not saved by a prologue in an interrupt handler. + +The default is always nonzero. +@end defmac + @defmac AVOID_CCMODE_COPIES Define this macro if the compiler should avoid copies to/from @code{CCmode} registers. You should only define this macro if support for copying to/fr= om Index: gcc/recog.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- gcc/recog.c (revision 136872) +++ gcc/recog.c (working copy) @@ -2898,6 +2898,9 @@ /* Don't allocate fixed registers. */ if (fixed_regs[regno]) continue; + /* Don't allocate global registers. */ + if (global_regs[regno]) + continue; /* Make sure the register is of the right class. */ if (! TEST_HARD_REG_BIT (reg_class_contents[cl], regno)) continue; @@ -2907,6 +2910,10 @@ /* And that we don't create an extra save/restore. */ if (! call_used_regs[regno] && ! df_regs_ever_live_p (regno)) continue; +#ifdef HARD_REGNO_SCRATCH_OK + if (! HARD_REGNO_SCRATCH_OK(regno)) + continue; +#endif /* And we don't clobber traceback for noreturn functions. */ if ((regno =3D=3D FRAME_POINTER_REGNUM || regno =3D=3D HARD_FRAME_PO= INTER_REGNUM) && (! reload_completed || frame_pointer_needed)) Anatoly.