This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: i386-linux cross sh-elf breakage
- To: Richard Henderson <rth at cygnus dot com>
- Subject: Re: i386-linux cross sh-elf breakage
- From: Clinton Popetz <cpopetz at cygnus dot com>
- Date: Fri, 19 May 2000 16:26:32 -0500
- Cc: Toshiyasu Morita <tm at netcom dot com>, gcc-patches at gcc dot gnu dot org
- References: <200005152231.PAA01084@netcom.com> <20000516140146.A17877@cpopetz.com> <20000516175851.C7380@cygnus.com> <20000516212713.B4299@cpopetz.com> <20000518204943.B11020@cygnus.com>
On Thu, May 18, 2000 at 08:49:43PM -0700, Richard Henderson wrote:
> On Tue, May 16, 2000 at 09:27:13PM -0500, Clinton Popetz wrote:
> > #define MODE_USES_IN_EXIT_BLOCK gen_rtx_USE (VOIDmode, get_fpscr_rtx ())
> >
> > This is used by the other sh mode_switching code, to handle the special
> > case of needing to switch the FP mode back to the default mode for a
> > target ABI.
>
> This should have been handled with EPILOGUE_USES, I think.
Good point. I tweaked the mode switching code to deal with the exit block
while it's searching for mode changes, rather than inserting a USE beforehand.
This is orthogonal to the earlier toplev.c patch. Should I commit both if
c-torture for sh-elf passes?
-Clint
Fri May 19 15:23:47 CDT 2000 Clinton Popetz <cpopetz@cygnus.com>
* lcm.c (make_preds_opaque): Fix comment.
(optimize_mode_switching): Use MODE_AT_EXIT instead of
MODE_USES_IN_EXIT_BLOCK. Change leftover instance of
FP_MODE_NONE to no_mode.
* tm.texi (OPTIMIZE_MODE_SWITCHING): Refer to MODE_AT_EXIT.
(MODE_USES_IN_EXIT_BLOCK): Delete.
(MODE_AT_EXIT) Document.
* sh.h (MODE_USES_IN_EXIT_BLOCK): Delete.
(MODE_AT_EXIT): Define.
(MODE_NEEDED): Don't look for a USE.
(EPILOGUE_USES): Define.
Index: lcm.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/lcm.c,v
retrieving revision 1.15
diff -c -2 -p -r1.15 lcm.c
*** lcm.c 2000/05/17 21:01:07 1.15
--- lcm.c 2000/05/19 20:21:09
*************** static void make_preds_opaque PARAMS ((b
*** 851,855 ****
/* This function will allocate a new BBINFO structure, initialized
! with the FP_MODE, INSN, and basic block BB parameters. */
static struct seginfo *
--- 851,855 ----
/* This function will allocate a new BBINFO structure, initialized
! with the MODE, INSN, and basic block BB parameters. */
static struct seginfo *
*************** optimize_mode_switching (file)
*** 995,1021 ****
return 0;
- #ifdef MODE_USES_IN_EXIT_BLOCK
- /* For some ABIs a particular mode setting is required at function exit. */
-
- for (eg = EXIT_BLOCK_PTR->pred; eg; eg = eg->pred_next)
- {
- int bb = eg->src->index;
- rtx insn = BLOCK_END (bb);
- rtx use = MODE_USES_IN_EXIT_BLOCK;
-
- /* If the block ends with the use of the return value
- and / or a return, insert the new use(s) in front of them. */
- while ((GET_CODE (insn) == INSN && GET_CODE (PATTERN (insn)) == USE)
- || GET_CODE (insn) == JUMP_INSN)
- insn = PREV_INSN (insn);
-
- use = emit_insn_after (use, insn);
- if (insn == BLOCK_END (bb))
- BLOCK_END (bb) = use;
- else if (NEXT_INSN (use) == BLOCK_HEAD (bb))
- BLOCK_HEAD (bb) = NEXT_INSN (insn);
- }
- #endif /* MODE_USES_IN_EXIT_BLOCK */
-
/* Create the bitmap vectors. */
--- 995,998 ----
*************** optimize_mode_switching (file)
*** 1072,1075 ****
--- 1049,1073 ----
}
+ /* If this is the last block, and we must force a mode on exit,
+ make note of that. */
+ #ifdef MODE_AT_EXIT
+ if (bb == (n_basic_blocks - 1) && MODE_AT_EXIT (e) != no_mode
+ && last_mode != MODE_AT_EXIT (e))
+ {
+ rtx insn = BLOCK_END (bb);
+
+ /* Find the last insn before a USE and/or JUMP. */
+ while ((GET_CODE (insn) == INSN
+ && GET_CODE (PATTERN (insn)) == USE)
+ || GET_CODE (insn) == JUMP_INSN)
+ insn = PREV_INSN (insn);
+
+ last_mode = MODE_AT_EXIT (e);
+ add_seginfo (info + bb,
+ new_seginfo (last_mode, insn, bb, live_now));
+ RESET_BIT (transp[bb], j);
+ }
+ #endif
+
info[bb].computing = last_mode;
/* Check for blocks without ANY mode requirements. */
*************** optimize_mode_switching (file)
*** 1221,1225 ****
{
next = ptr->next;
! if (ptr->mode != FP_MODE_NONE)
{
rtx mode_set;
--- 1219,1223 ----
{
next = ptr->next;
! if (ptr->mode != no_mode)
{
rtx mode_set;
Index: tm.texi
===================================================================
RCS file: /cvs/gcc/egcs/gcc/tm.texi,v
retrieving revision 1.124
diff -c -2 -p -r1.124 tm.texi
*** tm.texi 2000/05/01 16:53:03 1.124
--- tm.texi 2000/05/19 20:21:16
*************** If you define this macro, you also have
*** 7275,7279 ****
@code{NUM_MODES_FOR_MODE_SWITCHING}, @code{MODE_NEEDED},
@code{MODE_PRIORITY_TO_MODE} and @code{EMIT_MODE_SET}.
! @code{MODE_AT_ENTRY} and @code{MODE_USES_IN_EXIT_BLOCK} are optional.
@findex NUM_MODES_FOR_MODE_SWITCHING
--- 7275,7279 ----
@code{NUM_MODES_FOR_MODE_SWITCHING}, @code{MODE_NEEDED},
@code{MODE_PRIORITY_TO_MODE} and @code{EMIT_MODE_SET}.
! @code{MODE_AT_ENTRY} and @code{MODE_AT_EXIT} are optional.
@findex NUM_MODES_FOR_MODE_SWITCHING
*************** represented as numbers 0 .. N - 1. N is
*** 7290,7302 ****
switch is needed / supplied.
- @findex MODE_USES_IN_EXIT_BLOCK
- @item MODE_USES_IN_EXIT_BLOCK
- If this macro is defined, it is called for each exit block when mode switching
- optimization is performed. Its return value should be the pattern of an insn,
- or a sequence of insns. It is emitted before the return insn / use insns at
- the end of the exit block.
-
- This is done before insns are examined for their need of any mode switching.
-
@findex MODE_NEEDED
@item MODE_NEEDED (@var{entity}, @var{insn})
--- 7290,7293 ----
*************** If this macro is defined, it is evaluate
*** 7312,7315 ****
--- 7303,7312 ----
mode switching. It should evaluate to an integer, which is a mode that
@var{entity} is assumed to be switched to at function entry.
+
+ @findex MODE_AT_EXIT
+ @item MODE_AT_EXIT (@var{entity})
+ If this macro is defined, it is evaluated for every @var{entity} that needs
+ mode switching. It should evaluate to an integer, which is a mode that
+ @var{entity} should have before function exit.
@findex MODE_PRIORITY_TO_MODE
Index: config/sh/sh.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/sh/sh.h,v
retrieving revision 1.61
diff -c -2 -p -r1.61 sh.h
*** sh.h 2000/04/12 20:10:19 1.61
--- sh.h 2000/05/19 20:21:18
*************** do { \
*** 2250,2261 ****
#define OPTIMIZE_MODE_SWITCHING(ENTITY) TARGET_SH4
! #define MODE_USES_IN_EXIT_BLOCK gen_rtx_USE (VOIDmode, get_fpscr_rtx ())
#define MODE_NEEDED(ENTITY, INSN) \
(recog_memoized (INSN) >= 0 \
? get_attr_fp_mode (INSN) \
- : (GET_CODE (PATTERN (INSN)) == USE \
- && rtx_equal_p (XEXP (PATTERN (INSN), 0), get_fpscr_rtx ())) \
- ? (TARGET_FPU_SINGLE ? FP_MODE_SINGLE : FP_MODE_DOUBLE) \
: FP_MODE_NONE)
--- 2250,2261 ----
#define OPTIMIZE_MODE_SWITCHING(ENTITY) TARGET_SH4
! #define MODE_AT_EXIT(ENTITY) \
! (TARGET_FPU_SINGLE ? FP_MODE_SINGLE : FP_MODE_DOUBLE)
+ #define EPILOGUE_USES(REGNO) (TARGET_SH4 && (REGNO) == FPSCR_REG)
+
#define MODE_NEEDED(ENTITY, INSN) \
(recog_memoized (INSN) >= 0 \
? get_attr_fp_mode (INSN) \
: FP_MODE_NONE)