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]

help with address reload


I'm making nice progress on my i860 hacking: I seem to have big-endian
working, and I'm getting somewhere with improving code generation. 
However, I've run into a nasty problem cause by reload (prably by me not
defining some #define correctly).

I convert

(set (reg:SI xx) 
     (mem:SI (symbol_ref "sym")))

to

(set (reg:SI yy)
     (high:SI (symbol_ref "sym)))
(set (reg:SI xx)
     (mem:SI (lo_sum:SI (reg:SI yy) (symbol_ref "sym))))

during the define_expand of "movsi".  This usually works extreamly well,
with the first `set' being cse'd as appropriat.  The problem comes when
reload runs out of registers (?? guessing here) and winds up converting
the above sequence to

(set (reg:SI xx)
     (mem:SI (lo_sum:SI (high:SI (symbol_ref "sym))
                        (symbol_ref "sym))))

Which causes output_asm (?? somewhere in there, can't remember off hand
and I don't care) to segfault due to the mem operand being totally
invalid.

I've figured out that I may need to define LEGITIMIZE_RELOAD_ADDRESS,
which I did to:

#define LEGITIMIZE_RELOAD_ADDRESS(X,MODE,OPNUM,TYPE,IND_LEVELS,WIN)	\
{									\
  if (GET_CODE (X) == LO_SUM						\
      && GET_CODE (XEXP (X, 0)) == HIGH)				\
    {									\
      rtx orig_X = X;							\
      X = copy_rtx (X);							\
      push_reload (orig_X, NULL_RTX, &X, NULL_PTR,			\
		   GENERAL_REGS,					\
		   Pmode, VOIDmode, 0, 0, OPNUM, TYPE);			\
      goto WIN;								\
    }									\
}

I've also defined SECONDARY_INPUT_RELOAD_CLASS and
SECONDARY_OUTPUT_RELOAD_CLASS as:

#define 			\
  ((merged_LO_SUM_HIGH_address (X) ||					\
   ((CLASS) == FP_REGS && CONSTANT_P (X))) ? GENERAL_REGS : NO_REGS)

#define SECONDARY_OUTPUT_RELOAD_CLASS(CLASS,MODE,X)			\
  (merged_LO_SUM_HIGH_address (X) ? GENERAL_REGS : NO_REGS)

However, this gives me an abort (I've read the comment at the abort, so
I know I'm doing something wrong).

What I want to get is 

(set (reg:SI 31)
     (high:SI (symbol_ref "sym)))
(set (reg:SI xx)
     (mem:SI (lo_sum:SI (reg:SI 31) (symbol_ref "sym))))

(%r31 has been allocated as a scratch register in i860.h, probably just
of this sort of occasion).  The question is: how do I (correctly) get
reload to do this?  I take it that I should be able to without hacking
reload*.c.

Actually, shouldn't reload detect (lo_sum (high ...) ...) on it's own
and fix it by itself?

If my patches are needed, I'm very happy to send them in.


BTW, about 18 months ago, I sent in assignment forms to the FSF for my
work on GNU Pascal.  Are they still valid and can they apply to gcc in
general?  I don't think they have any email addresses on them, if they
do it will be billc@blackmagic.tait.co.nz which is no longer valid.  I
will have to sort out new employer forms, of course.

Bill
-- 
Leave others their otherness


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