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


On Mon, 2002-11-11 at 07:38, Peter Barada wrote: 
> 
> You still need to reject indexed addressing mode, in
> GO_IF_LEGITIMATE_ADDRESS, but you also have to modify
> LEGITIMIZE_ADDRESS to re-write the indexed addressing mode into
> something that GO_IF_LEGITIMATE_ADDRESS *does* accept.
Yeah Thats what I thought, so from GO_IF_LEGITIMATE_ADDRESS, I removed
the part where it checked for the indexed addressing mode. But this did
not work so I cried for help. After your mail I got confident about what
I was doing and debugged it a little, and guess what... I had put my if
block for indexed mode the last in LEGITIMIZE_ADDRESS macro and the rtl
insn was satisfying condition for some other previous block also , so my
code wasnt getting executed :|. So I put it second in the macro now. And
the problem is solved:). Now it works, I haven't yet done much testing.

> 
> Your legitimize_address doesn't recognized all indexed address mode
> operands and force the the sum of the register and offest into a
> register.  The first clause will of your macro *does* re-write an

I think you missed that my clause is the last clause in the macro. Everything else was already there, sorry for not pointing it out with better clarity before.

> indexed addressing mode, but only where the offset is *larger* than
> +/-0x8000. You could try modifying the first clause to rewrite *any*
> indexed addressing:
> 
> #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.
> Which will take *any* indexed address mode and force it to become
> register indirect(I'm assuming that register indirect is valid for
> your target).  This change doesn't recognize register indirect plus
Again, I guess register indirect is LD RD, c(RA) <=> RD<-MEM(RA+c) right? (just so that I dont goof up in future :) )
> scaled index addressing modes though (equivalent to d8(Ax,Xi*S) in
> m68k/ColdFire speak). 
> 
> Hope this helps...
Yes it did! Thanx a lot!
Spundun

ps:My new macro loks like this.
/* Spundun: Added condition for indexedaddressing mode.
 * The second if block in the following macro.
 * (The one with else if (LEGITIMATE_INDEXED_ADDRESS_P (X)
 */
#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				\
    && (unsigned HOST_WIDE_INT) (INTVAL (XEXP (X, 1)) + 0x8000) >= 0x10000) \
    { HOST_WIDE_INT high_int, low_int;					\
      rtx sum;								\
      high_int = INTVAL (XEXP (X, 1)) & (~ (HOST_WIDE_INT) 0xffff);	\
      low_int = INTVAL (XEXP (X, 1)) & 0xffff;				\
      if (low_int & 0x8000)						\
	high_int += 0x10000, low_int |= ((HOST_WIDE_INT) -1) << 16;	\
      sum = force_operand (gen_rtx_PLUS (Pmode, XEXP (X, 0),		\
				    GEN_INT (high_int)), 0);		\
      (X) = gen_rtx_PLUS (Pmode, sum, GEN_INT (low_int));		\
      goto WIN;								\
    }									\
  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;                                        \
    }                                                  \
  else if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == REG	\
	   && GET_CODE (XEXP (X, 1)) != CONST_INT			\
	   && (TARGET_HARD_FLOAT || TARGET_POWERPC64 || (MODE) != DFmode) \
	   && (TARGET_POWERPC64 || (MODE) != DImode)			\
	   && (MODE) != TImode)						\
    {									\
      (X) = gen_rtx_PLUS (Pmode, XEXP (X, 0),				\
		     force_reg (Pmode, force_operand (XEXP (X, 1), 0))); \
      goto WIN;								\
    }									\
  else if (TARGET_ELF && TARGET_32BIT && TARGET_NO_TOC			\
	   && !flag_pic							\
	   && GET_CODE (X) != CONST_INT					\
	   && GET_CODE (X) != CONST_DOUBLE && CONSTANT_P (X)		\
	   && (TARGET_HARD_FLOAT || (MODE) != DFmode)			\
	   && (MODE) != DImode && (MODE) != TImode)			\
    {									\
      rtx reg = gen_reg_rtx (Pmode);					\
      emit_insn (gen_elf_high (reg, (X)));				\
      (X) = gen_rtx_LO_SUM (Pmode, reg, (X));				\
      if ((MODE) == SVmode)						\
	(X) = force_reg (Pmode, (X));					\
      goto WIN;								\
    }									\
  else if (GET_CODE (X) == PLUS && (MODE) == SVmode)			\
    {									\
      (X) = force_operand ((X), NULL_RTX);				\
      goto WIN;								\
    }									\
}





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