This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: rtl indexed addressing mode question
- From: Spundun <spundun at ISI dot EDU>
- To: Spundun Bhatt <spundun at ISI dot EDU>
- Cc: Mike Stump <mrs at apple dot com>, gcc at gcc dot gnu dot org
- Date: 08 Nov 2002 18:49:33 -0800
- Subject: Re: rtl indexed addressing mode question
- References: <2E3D7730-ED04-11D6-B06E-000393941EE6@apple.com> <3DCAEAAC.5000007@isi.edu>
Hi, I am trying to remove the indexed addressing mode from config files,
but cant get it right. First I tried to simply reject the mode in the
GO_IF_LEGITIMATE_ADDRESS macro as Mike suggested. But that didnt
work.then I tried to add conversion from indexed mode to simple
base/offset mode in the LEGITIMIZE_ADDRESS macro, but that didnt work
either. Heres is the macro, the last else if in it is what I added.but I
still get the unrecognizableinstruction error. (the patter is right
below the macro)
#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 (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; \
} \
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)); \
} \
}
The Pattern:
------------------------------------------------
stx_func_transitive.c: In function `main':
stx_func_transitive.c:242: Internal compiler error:
stx_func_transitive.c:242: internal error--unrecognizable insn:
(insn 73 72 76 (set (mem/s:SI (plus:SI (reg:SI 126)
(reg:SI 125)) 0)
(reg:SI 127)) -1 (nil)
(nil))
-----------------------------------------------
I will appreciate any help/suggestion regarding this.
Thanx
Spundun
On Thu, 2002-11-07 at 14:35, Spundun Bhatt wrote:
>
>
> Mike Stump wrote:
>
> > On Wednesday, October 30, 2002, at 05:26 PM, Spundun Bhatt wrote:
> >
> >> I am porting gcc to a new architecture. I am using rs6000 config
> >> files as template.
> >> My question is,
> >> my architecture doesnt support indexed addressing(ST R2,R3,R4) so I
> >> wanted to remove this mode from the config.
> >> I have located the GO_IF_LEGITIMATE_ADDRESS macro.. which in turn
> >> calls macro LEGITIMATE_INDEXED_ADDRESS .
> >> I am thinking of setting the later macro to 0 so it will not match
> >> the indexed addressing mode. Now I am wondering if the gcc will auto
> >> matically figureout that it has to add the 2 registers and then use
> >> the base+immediate offsetting mode.. or I have to modify some other
> >> macros too? Or if this is not the way.. then whats a good way of
> >> doing what I have to do?
> >
> >
> > Try it, see if it works! :-) I suspect that the compiler would
> > otherwise seem to just work, if you tried it.
>
> Thanx a lot for your reply
> But it didnt work :((
>
> The change I made is this.
> ------------------------------------------------------
> /*
> * Spundun: DIVA doesnot support indexed addressing mode.
> * hoping that this change will automatically fix the issues
> * TODO: Review Needed.
> */
> #define LEGITIMATE_INDEXED_ADDRESS_P(X) 0
> /*#define LEGITIMATE_INDEXED_ADDRESS_P(X) \
> (GET_CODE (X) == PLUS \
> && GET_CODE (XEXP (X, 0)) == REG \
> && GET_CODE (XEXP (X, 1)) == REG \
> && ((REG_OK_FOR_BASE_P (XEXP (X, 0)) \
> && REG_OK_FOR_INDEX_P (XEXP (X, 1))) \
> || (REG_OK_FOR_BASE_P (XEXP (X, 1)) \
> && REG_OK_FOR_INDEX_P (XEXP (X, 0)))))*/
>
> ------------------------------------------------------
> And I get this error
> ------------------------------------------------------
> rain:[Thu:07][11:52am] func_cornerturn> ~/gcc-cross/gcc-cross.current -S
> stx_func_transitive.c
> stx_func_transitive.c: In function `main':
> stx_func_transitive.c:242: Internal compiler error:
> stx_func_transitive.c:242: internal error--unrecognizable insn:
> (insn 73 72 76 (set (mem/s:SI (plus:SI (reg:SI 126)
> (reg:SI 125)) 0)
> (reg:SI 127)) -1 (nil)
> (nil))
> rain:[Thu:07][12:09pm] func_cornerturn>
> ------------------------------------------------------
>
> Should I try and play with the macro LEGITIMIZE_ADDRESS ? Or theres
> something else I have to change?
> Thanx
> Spundun