This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] FOR_EACH_RTX construct to replace for_each_rtx
- From: Richard Henderson <rth at redhat dot com>
- To: Paolo Bonzini <paolo dot bonzini at lu dot unisi dot ch>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Mark Mitchell <mark at codesourcery dot com>
- Date: Wed, 19 Jan 2005 11:00:53 -0800
- Subject: Re: [PATCH] FOR_EACH_RTX construct to replace for_each_rtx
- References: <41EE99B0.9090806@lu.unisi.ch>
On Wed, Jan 19, 2005 at 06:32:32PM +0100, Paolo Bonzini wrote:
> - static rtx *btr_reference_found;
> -
> - /* A subroutine of btr_referenced_p, called through for_each_rtx.
> - PREG is a pointer to an rtx that is to be excluded from the
> - traversal. If we find a reference to a target register anywhere
> - else, return 1, and put a pointer to it into btr_reference_found. */
> - static int
> - find_btr_reference (rtx *px, void *preg)
> - {
> - rtx x;
> - int regno, i;
> -
> - if (px == preg)
> - return -1;
> - x = *px;
> - if (!REG_P (x))
> - return 0;
> - regno = REGNO (x);
> - for (i = hard_regno_nregs[regno][GET_MODE (x)] - 1; i >= 0; i--)
> - if (TEST_HARD_REG_BIT (all_btrs, regno+i))
> - {
> - btr_reference_found = px;
> - return 1;
> - }
> - return -1;
> - }
> -
> - /* Return nonzero if X references (sets or reads) any branch target register.
> - If EXCLUDEP is set, disregard any references within the rtx pointed to
> - by it. If returning nonzero, also set btr_reference_found as above. */
> - static int
> - btr_referenced_p (rtx x, rtx *excludep)
> - {
> - return for_each_rtx (&x, find_btr_reference, excludep);
> - }
...
> ! /* Find and return a use of a target register within an instruction INSN.
> ! If EXCLUDEP is set, disregard any references within the rtx pointed to
> ! by it. */
> static rtx *
> ! find_btr_use (rtx insn, rtx *excludep)
> {
> ! rtx_iter iter;
> ! rtx *loc;
> ! FOR_EACH_RTX (&insn, loc, iter)
> ! {
> ! rtx x;
> ! int regno, i;
> !
> ! if (loc == excludep)
> ! {
> ! rtx_iter_skip (&iter);
> ! continue;
> ! }
> !
> ! x = *loc;
> ! if (!REG_P (x))
> ! continue;
> ! regno = REGNO (x);
> ! for (i = hard_regno_nregs[regno][GET_MODE (x)] - 1; i >= 0; i--)
> ! if (TEST_HARD_REG_BIT (all_btrs, regno+i))
> ! return loc;
> ! }
> !
> ! return NULL;
> }
I don't like the fact that this isn't an exact drop-in replacement
of FOR_EACH_RTX. I very much feel that the first version of this
change to be installed should support *exactly* the same interface.
Nor should you have done any simultaneous renamings of functions.
r~