mips16/mips64 frame ptr to stack ptr
Gavin Koch
gavin@cygnus.com
Tue Feb 17 09:43:00 GMT 1998
mips64 -mips16 is producing a lwu using an sp relative address mode,
which is not valid in mip16. The function mips_move_1word is using
lwu to do zero extension from SI to DI if the source is in memory
AND the frame pointer elimination code assumes it can arbitrarily
replace the frame pointer with the stack pointer which is not
true for this instruction mips16 mode.
The following patch prevents the elimination of the frame pointer
by the stack pointer when both TARGET_MIP16 and TARGET_64BIT.
It is an overly pesimistic way to solve this problem, but my attempts
to find a less pervasive solution have failed. My suggestion
is to install this patch, so that we at least get correct though
less optimal code, while/until we have a more optimal solution.
-gavin...
* mips/mips.h (CAN_ELIMINATE): Don't eliminate the frame
pointer for the stack pointer in MIPS16 and 64BIT.
Index: mips.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/mips/mips.h,v
retrieving revision 1.14
diff -c -r1.14 mips.h
*** mips.h 1998/01/14 20:57:49 1.14
--- mips.h 1998/02/17 17:05:22
***************
*** 2115,2130 ****
cases preventing register elimination are things that the compiler
already knows about.
! We can always eliminate to the frame pointer. We can eliminate to
! the stack pointer unless a frame pointer is needed. In mips16
! mode, we need a frame pointer for a large frame; otherwise, reload
! may be unable to compute the address of a local variable, since
! there is no way to add a large constant to the stack pointer
! without using a temporary register. */
#define CAN_ELIMINATE(FROM, TO) \
((TO) == HARD_FRAME_POINTER_REGNUM \
|| ((TO) == STACK_POINTER_REGNUM && ! frame_pointer_needed \
&& (! TARGET_MIPS16 \
|| compute_frame_size (get_frame_size ()) < 32768)))
--- 2115,2137 ----
cases preventing register elimination are things that the compiler
already knows about.
! When not in mips16 and mips64, we can always eliminate to the
! frame pointer. We can eliminate to the stack pointer unless
! a frame pointer is needed. In mips16 mode, we need a frame
! pointer for a large frame; otherwise, reload may be unable
! to compute the address of a local variable, since there is
! no way to add a large constant to the stack pointer
! without using a temporary register.
+ In mips16, for some instructions (eg lwu), we can't eliminate the
+ frame pointer for the stack pointer. These instructions are
+ only generated in TARGET_64BIT mode.
+ */
+
#define CAN_ELIMINATE(FROM, TO) \
((TO) == HARD_FRAME_POINTER_REGNUM \
|| ((TO) == STACK_POINTER_REGNUM && ! frame_pointer_needed \
+ && ! (TARGET_MIPS16 && TARGET_64BIT) \
&& (! TARGET_MIPS16 \
|| compute_frame_size (get_frame_size ()) < 32768)))
More information about the Gcc
mailing list