This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: rtl indexed addressing mode question


>> #define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN)                      \
>> { if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == REG      \
>>     && GET_CODE (XEXP (X, 1)) == CONST_INT                       \
>>     {                                                            \
>>       (X) = force_operand (gen_rtx_PLUS (Pmode, XEXP (X, 0),     \
>>                                     XEXP (X, 1)), 0);            \
>>       goto WIN;                                                  \
>>     }                                                            \
>> 
>This wont match indexed mode right? because the second operand is
>const int. Are we both using the jargon in the same meaning? To me
>indexed addressing mode is something like LD RD,RB(RA) where
>RD<-MEM(RA+RB) is done. 

This change matches base-offset addressing (where the first operand is
a register, and the second is some *constant*), but nor your 'indexed'
addressing MEM(RA+RB)).  To make it match *any* indexed
addressing(where the first operand is a register and the second can be
a register, constant, scaled register, etc), you shuld remove the test
for the constant int:  

>> #define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN)                      \
>> { if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == REG)     \
>>     {                                                            \
>>       (X) = force_operand (gen_rtx_PLUS (Pmode, XEXP (X, 0),     \
>>                                     XEXP (X, 1)), 0);            \
>>       goto WIN;                                                  \
>>     }                                                            \

So this matches any operand that is the addition of a register and
anything.  Note that register indirect (register offset addressing
where the offset is *zero*) is not handled by this clause, and is
assumed to be valid for your architecture.

>ps:My new macro loks like this.
>  else if (LEGITIMATE_INDEXED_ADDRESS_P (X))           \
>    {                                                  \
>      rtx reg = gen_reg_rtx (Pmode);                   \
>      emit_insn (gen_addsi3 (reg, force_operand(XEXP (X,0), 0), \
>                 force_operand(XEXP (X,1),0)));        \
>      (X) = gen_rtx_PLUS (Pmode, reg, GEN_INT (0));    \
>      goto WIN;                                        \
>    }                                                  \

This doesn't look quite right.

If given:

   (mem:QI (plus:SI (reg:SI 50) (reg:SI 51)) 0)

Youd clause will convert it into:

   (set (reg:SI 52) (plus:SI (reg:SI 50) (reg:SI 51)))
   (mem:QI (plus:SI (reg:SI 50) (const_int 0)) 0)

where the addition of zero will get optimized away by the optimizer.
Rather than go through all the extra work, Try the suggested version
above and see what happens...

Hope this helps...

-- 
Peter Barada                                   Peter.Barada@motorola.com
Wizard                                         781-852-2768 (direct)
WaveMark Solutions(wholly owned by Motorola)   781-270-0193 (fax)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]