On Mon, Sep 10, 2007 at 12:22:11PM +0200, Tomas Svensson wrote:

> static bool
> legitimate_offset_address_p (enum machine_mode mode ATTRIBUTE_UNUSED, rtx 
> addr)
> {
>   rtx reg, offset;
> 
>   if (GET_CODE (addr) != PLUS)
>     return false;
> 
>   reg = XEXP (addr, 0);
>   offset = XEXP (addr, 1);
> 
>   if ((GET_CODE (reg) == REG && REG_OK_FOR_BASE_P (reg))
>       && legitimate_address_integer_p (offset, 0))
>     return true;
> 
>   return false;
> }

   I think Jim is right: The "GET_CODE (reg) == REG && REG_OK_FOR_BASE_P
(reg)" part doesn't do what you hope it does. You will have to pass down the
"strict" parameter all the way from legitimate_address_p(), use

REG_P (reg) && (!strict || REG_OK_FOR_BASE_P)

and additionally,

#ifdef REG_OK_STRICT
# define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
    { if (legitimate_address_p (MODE, X, true)) goto ADDR; }
#else
# define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
    { if (legitimate_address_p (MODE, X, false)) goto ADDR; }
#endif

but you'll have use the strict version of REG_OK_FOR_BASE_P(), normally by
defining REG_OK_STRICT before including machine.h.

   When your addresses are as simple as yours, all this is easier to do
directly in machine.h. The standard way is to define your helper macros
differently depending on REG_OK_STRICT:

#ifdef REG_OK_STRICT

#define REG_OK_FOR_BASE_P(x)         \
  (REGNO_OK_FOR_BASE_P (REGNO (x)))

#else /* !REG_OK_STRICT */

#define REG_OK_FOR_BASE_P(x)         \
  (!HARD_REGISTER_P (x) || REGNO_OK_FOR_BASE_P (REGNO (x)))

#endif

Then define GO_IF_LEGITIMATE_ADDRESS() using REG_OK_FOR_BASE_P().

   There's a little bit of trickery with the non-strict REG_OK_FOR_BASE_P()
macro. If you port has virtual hard regs used in addresses (e.g. a
non-existant argument pointer, which is later eliminated into the frame
pointer or the stack pointer), then you have to allow those also.

> static bool
> legitimate_address_integer_p (rtx addr, int offset ATTRIBUTE_UNUSED)
> {
>   return (GET_CODE (addr) == CONST_INT
>           && SMALL_INT (INTVAL (addr));
> }

GET_CODE (x) == REG             --> REG_P (x)
GET_CODE (x) == CONST_INT       --> CONST_INT_P (x)

-- 
Rask Ingemann Lambertsen

Reply via email to