This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: REGNO_OK_FOR_BASE_P
- From: Ian Lance Taylor <iant at google dot com>
- To: Paul Koning <paul_koning at dell dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Mon, 25 Oct 2010 12:50:04 -0700
- Subject: Re: REGNO_OK_FOR_BASE_P
- References: <B3D02DFA-2CC9-4D57-BABE-1454961DAFE0@dell.com>
Paul Koning <paul_koning@dell.com> writes:
> Working on the pdp11 target, I ran into something odd.
>
> It defines REGNO_OK_FOR_BASE_P in a way that seems to match what gccint says one should do in the "strict" case -- but does so all the time. Specifically, it says:
>
> #define REGNO_OK_FOR_BASE_P(REGNO) \
> ((REGNO) < 8 || (unsigned) reg_renumber[REGNO] < 8)
>
> (8 because there are 8 general registers on the PDP11, all suitable as base.)
>
> It then defines another similarly named macro REG_OK_FOR_BASE_P which takes an rtx instead of a regno, for use in GO_IF_LEGITIMATE_ADDRESS. That second macro *does* come with a non-strict form which accepts all registers.
>
> Looking at gccint, that seemed wrong. As far as I can tell, REG_OK_FOR_BASE_P is not (or no longer) a standard macro so it's just a convenience macro inside the target. No problem there. But the strict REGNO_OK_FOR_BASE_P in non-strict settings seemed like an issue, so I changed it.
>
> The surprise it that it makes no difference. No change in code, no change in testsuite results. Why didn't it matter? Is the documentation wrong? Or is the existing definition somehow ok even for the non-strict case, in a way that isn't obvious?
I think the documentation is wrong. REGNO_OK_FOR_BASE_P is only
meaningful for hard registers. It doesn't make much sense to ask
whether a pseudo-register is OK to use as a base. The pseudo-register
can in principle be assigned to any hard register, so the answer is
always true.
In older releases GO_IF_LEGITIMATE_ADDRESS was often a macro written in
terms of REGNO_OK_FOR_BASE_P. Since GO_IF_LEGITIMATE_ADDRESS had to
change based on REG_OK_STRICT, it made sense to have REGNO_OK_FOR_BASE_P
change based on REG_OK_STRICT. But the generic part of gcc will not
check REGNO_OK_FOR_BASE_P for a pseudo register. And since current
targets should be using TARGET_LEGITIMATE_ADDRESS_P instead of
GO_IF_LEGITIMATE_ADDRESS, the issue of REGNO_OK_FOR_BASE_P is less
important. Probably the docs should be changed.
Ian