Hi all,

I am doing a port of a 32bit target in GCC 4.4.0. I have written the
macro legitimize_reload_address which does something similar to what
the target pa does. i.e

   For the PA, transform:

        memory(X + <large int>)

   into:

        if (<large int> & mask) >= 16
          Y = (<large int> & ~mask) + mask + 1  Round up.
        else
          Y = (<large int> & ~mask)             Round down.
        Z = X + Y
        memory (Z + (<large int> - Y));


The input for the macro is

(plus:SI (reg/f:SI 23 r7)
                (const_int 65536 [0x10000]))

and the target support only 15bit signed offset so in
legitimize_reload_address i have

     mask = 0x3fff;
     offset = INTVAL (XEXP ((addr), 1));

      /* Choose rounding direction.  Round up if we are >= halfway.  */
      if ((offset & mask) >= ((mask + 1) / 2))
        newoffset = (offset & ~mask) + mask + 1;
      else
        newoffset = offset & ~mask;

      /* Ensure that long displacements are aligned.  */
      newoffset &= ~(GET_MODE_SIZE (mode) - 1);

      if (newoffset)
        {
          temp = gen_rtx_PLUS (Pmode, XEXP (addr, 0),
                               GEN_INT (newoffset));
          addr = gen_rtx_PLUS (Pmode, temp, GEN_INT (offset - newoffset));
          push_reload (XEXP (addr, 0), 0, &XEXP (addr, 0), 0,
                       BASE_REG_CLASS, Pmode, VOIDmode, 0, 0,
                       opnum, type);
          return addr;
        }


The macro is defined like this:

#define LEGITIMIZE_RELOAD_ADDRESS(X,MODE,OPNUM,TYPE,IND_L,WIN)         \
do {                       \
  rtx new_x = legitimize_reload_address (X, MODE, OPNUM, TYPE, IND_L); \
  if (new_x)               \
    {                      \
      X = new_x;           \
      goto WIN;            \
    }                      \
} while (0)

I issue that i am facing is that if i return null_rtx without doing
any processing the complier works propely. But if
legitimize_reload_address gets executed and jumbs to the label WIN
iget ICE.

ice1.c:5: error: unrecognizable insn:
(insn 45 44 20 2 ice1.c:5 (set (mem/c:SI (plus:SI (reg:SI 16 r0)
                (const_int 65536 [0x10000])) [4 S4 A32])
        (reg:SI 2 d2)) -1 (nil))


Is there something wrong with my legitimize_relaod_address?

Thanks for your time.
Regards,
shafi

Reply via email to