Commit 73774972 by Eric Christopher Committed by Eric Christopher

lcm.c (optimize_mode_switching): Change NORMAL_MODE to MODE_ENTRY and MODE_EXIT.

2003-10-10  Eric Christopher  <echristo@redhat.com>

        * lcm.c (optimize_mode_switching): Change NORMAL_MODE
        to MODE_ENTRY and MODE_EXIT. Add MODE_AFTER for insns
        that set mode.
        * config/sh/sh.h (MODE_ENTRY): New macro.
        (MODE_EXIT): Ditto.
        (MODE_AFTER): Ditto.
        * config/sh/sh.md: Change for MODE_AFTER. Add
        fp_set attribute.
        * doc/tm.texi: Document MODE_AFTER, MODE_ENTRY, and MODE_EXIT.

From-SVN: r72315
parent 8d61e55e
2003-10-10 Eric Christopher <echristo@redhat.com>
* lcm.c (optimize_mode_switching): Change NORMAL_MODE
to MODE_ENTRY and MODE_EXIT. Add MODE_AFTER for insns
that set mode.
* config/sh/sh.h (MODE_ENTRY): New macro.
(MODE_EXIT): Ditto.
(MODE_AFTER): Ditto.
* config/sh/sh.md: Change for MODE_AFTER. Add
fp_set attribute.
* doc/tm.texi: Document MODE_AFTER, MODE_ENTRY, and MODE_EXIT.
2003-10-10 Zack Weinberg <zack@codesourcery.com> 2003-10-10 Zack Weinberg <zack@codesourcery.com>
* genmodes.c, mode-classes.def: New files. * genmodes.c, mode-classes.def: New files.
......
...@@ -3234,6 +3234,11 @@ extern int rtx_equal_function_value_matters; ...@@ -3234,6 +3234,11 @@ extern int rtx_equal_function_value_matters;
? (TARGET_FMOVD ? FP_MODE_DOUBLE : FP_MODE_NONE) \ ? (TARGET_FMOVD ? FP_MODE_DOUBLE : FP_MODE_NONE) \
: ACTUAL_NORMAL_MODE (ENTITY)) : ACTUAL_NORMAL_MODE (ENTITY))
#define MODE_ENTRY(ENTITY) NORMAL_MODE (ENTITY)
#define MODE_EXIT(ENTITY) \
(sh_cfun_attr_renesas_p () ? FP_MODE_NONE : NORMAL_MODE (ENTITY))
#define EPILOGUE_USES(REGNO) ((TARGET_SH2E || TARGET_SH4) \ #define EPILOGUE_USES(REGNO) ((TARGET_SH2E || TARGET_SH4) \
&& (REGNO) == FPSCR_REG) && (REGNO) == FPSCR_REG)
...@@ -3242,6 +3247,12 @@ extern int rtx_equal_function_value_matters; ...@@ -3242,6 +3247,12 @@ extern int rtx_equal_function_value_matters;
? get_attr_fp_mode (INSN) \ ? get_attr_fp_mode (INSN) \
: FP_MODE_NONE) : FP_MODE_NONE)
#define MODE_AFTER(MODE, INSN) \
(recog_memoized (INSN) >= 0 \
&& get_attr_fp_set (INSN) != FP_SET_NONE \
? get_attr_fp_set (INSN) \
: (MODE))
#define MODE_PRIORITY_TO_MODE(ENTITY, N) \ #define MODE_PRIORITY_TO_MODE(ENTITY, N) \
((TARGET_FPU_SINGLE != 0) ^ (N) ? FP_MODE_SINGLE : FP_MODE_DOUBLE) ((TARGET_FPU_SINGLE != 0) ^ (N) ? FP_MODE_SINGLE : FP_MODE_DOUBLE)
......
...@@ -280,6 +280,14 @@ ...@@ -280,6 +280,14 @@
(define_attr "fp_mode" "single,double,none" (const_string "none")) (define_attr "fp_mode" "single,double,none" (const_string "none"))
;; Indicate if the fpu mode is set by this instruction
;; "unknown" must have the value as "none" in fp_mode, and means
;; that the instruction/abi has left the processor in an unknown
;; state.
;; "none" means that nothing has changed and no mode is set.
;; This attribute is only used for the Renesas ABI.
(define_attr "fp_set" "single,double,unknown,none" (const_string "none"))
; If a conditional branch destination is within -252..258 bytes away ; If a conditional branch destination is within -252..258 bytes away
; from the instruction it can be 2 bytes long. Something in the ; from the instruction it can be 2 bytes long. Something in the
; range -4090..4100 bytes can be 6 bytes long. All other conditional ; range -4090..4100 bytes can be 6 bytes long. All other conditional
...@@ -5562,7 +5570,8 @@ ...@@ -5562,7 +5570,8 @@
(set (attr "fp_mode") (set (attr "fp_mode")
(if_then_else (eq_attr "fpu_single" "yes") (if_then_else (eq_attr "fpu_single" "yes")
(const_string "single") (const_string "double"))) (const_string "single") (const_string "double")))
(set_attr "needs_delay_slot" "yes")]) (set_attr "needs_delay_slot" "yes")
(set_attr "fp_set" "unknown")])
;; This is a pc-rel call, using bsrf, for use with PIC. ;; This is a pc-rel call, using bsrf, for use with PIC.
...@@ -5579,7 +5588,8 @@ ...@@ -5579,7 +5588,8 @@
(set (attr "fp_mode") (set (attr "fp_mode")
(if_then_else (eq_attr "fpu_single" "yes") (if_then_else (eq_attr "fpu_single" "yes")
(const_string "single") (const_string "double"))) (const_string "single") (const_string "double")))
(set_attr "needs_delay_slot" "yes")]) (set_attr "needs_delay_slot" "yes")
(set_attr "fp_set" "unknown")])
(define_insn_and_split "call_pcrel" (define_insn_and_split "call_pcrel"
[(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "")) [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" ""))
...@@ -5607,7 +5617,8 @@ ...@@ -5607,7 +5617,8 @@
(set (attr "fp_mode") (set (attr "fp_mode")
(if_then_else (eq_attr "fpu_single" "yes") (if_then_else (eq_attr "fpu_single" "yes")
(const_string "single") (const_string "double"))) (const_string "single") (const_string "double")))
(set_attr "needs_delay_slot" "yes")]) (set_attr "needs_delay_slot" "yes")
(set_attr "fp_set" "unknown")])
(define_insn "call_compact" (define_insn "call_compact"
[(call (mem:SI (match_operand:SI 0 "arith_reg_operand" "r")) [(call (mem:SI (match_operand:SI 0 "arith_reg_operand" "r"))
...@@ -5662,7 +5673,8 @@ ...@@ -5662,7 +5673,8 @@
(set (attr "fp_mode") (set (attr "fp_mode")
(if_then_else (eq_attr "fpu_single" "yes") (if_then_else (eq_attr "fpu_single" "yes")
(const_string "single") (const_string "double"))) (const_string "single") (const_string "double")))
(set_attr "needs_delay_slot" "yes")]) (set_attr "needs_delay_slot" "yes")
(set_attr "fp_set" "unknown")])
(define_insn "call_valuei_pcrel" (define_insn "call_valuei_pcrel"
[(set (match_operand 0 "" "=rf") [(set (match_operand 0 "" "=rf")
...@@ -5678,7 +5690,8 @@ ...@@ -5678,7 +5690,8 @@
(set (attr "fp_mode") (set (attr "fp_mode")
(if_then_else (eq_attr "fpu_single" "yes") (if_then_else (eq_attr "fpu_single" "yes")
(const_string "single") (const_string "double"))) (const_string "single") (const_string "double")))
(set_attr "needs_delay_slot" "yes")]) (set_attr "needs_delay_slot" "yes")
(set_attr "fp_set" "unknown")])
(define_insn_and_split "call_value_pcrel" (define_insn_and_split "call_value_pcrel"
[(set (match_operand 0 "" "=rf") [(set (match_operand 0 "" "=rf")
...@@ -5708,7 +5721,8 @@ ...@@ -5708,7 +5721,8 @@
(set (attr "fp_mode") (set (attr "fp_mode")
(if_then_else (eq_attr "fpu_single" "yes") (if_then_else (eq_attr "fpu_single" "yes")
(const_string "single") (const_string "double"))) (const_string "single") (const_string "double")))
(set_attr "needs_delay_slot" "yes")]) (set_attr "needs_delay_slot" "yes")
(set_attr "fp_set" "unknown")])
(define_insn "call_value_compact" (define_insn "call_value_compact"
[(set (match_operand 0 "" "=rf") [(set (match_operand 0 "" "=rf")
...@@ -8169,7 +8183,8 @@ mov.l\\t1f,r0\\n\\ ...@@ -8169,7 +8183,8 @@ mov.l\\t1f,r0\\n\\
[(set (reg:PSI FPSCR_REG) [(set (reg:PSI FPSCR_REG)
(xor:PSI (reg:PSI FPSCR_REG) (const_int 1048576)))] (xor:PSI (reg:PSI FPSCR_REG) (const_int 1048576)))]
"TARGET_SH4" "TARGET_SH4"
"fschg") "fschg"
[(set_attr "fp_set" "unknown")])
(define_expand "addsf3" (define_expand "addsf3"
[(set (match_operand:SF 0 "arith_reg_operand" "") [(set (match_operand:SF 0 "arith_reg_operand" "")
......
...@@ -8226,7 +8226,8 @@ return nonzero for any @var{entity} that needs mode-switching. ...@@ -8226,7 +8226,8 @@ return nonzero for any @var{entity} that needs mode-switching.
If you define this macro, you also have to define If you define this macro, you also have to define
@code{NUM_MODES_FOR_MODE_SWITCHING}, @code{MODE_NEEDED}, @code{NUM_MODES_FOR_MODE_SWITCHING}, @code{MODE_NEEDED},
@code{MODE_PRIORITY_TO_MODE} and @code{EMIT_MODE_SET}. @code{MODE_PRIORITY_TO_MODE} and @code{EMIT_MODE_SET}.
@code{NORMAL_MODE} is optional. @code{MODE_AFTER}, @code{MODE_ENTRY}, and @code{MODE_EXIT}
are optional.
@end defmac @end defmac
@defmac NUM_MODES_FOR_MODE_SWITCHING @defmac NUM_MODES_FOR_MODE_SWITCHING
...@@ -8250,10 +8251,24 @@ return an integer value not larger than the corresponding element in ...@@ -8250,10 +8251,24 @@ return an integer value not larger than the corresponding element in
be switched into prior to the execution of @var{insn}. be switched into prior to the execution of @var{insn}.
@end defmac @end defmac
@defmac NORMAL_MODE (@var{entity}) @defmac MODE_AFTER (@var{mode}, @var{insn})
If this macro is defined, it is evaluated for every @var{insn} during
mode switching. It determines the mode that an insn results in (if
different from the incoming mode).
@end defmac
@defmac MODE_ENTRY (@var{entity})
If this macro is defined, it is evaluated for every @var{entity} that needs 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 mode switching. It should evaluate to an integer, which is a mode that
@var{entity} is assumed to be switched to at function entry and exit. @var{entity} is assumed to be switched to at function entry. If @code{MODE_ENTRY}
is defined then @code{MODE_EXIT} must be defined.
@end defmac
@defmac MODE_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} is assumed to be switched to at function exit. If @code{MODE_EXIT}
is defined then @code{MODE_ENTRY} must be defined.
@end defmac @end defmac
@defmac MODE_PRIORITY_TO_MODE (@var{entity}, @var{n}) @defmac MODE_PRIORITY_TO_MODE (@var{entity}, @var{n})
...@@ -9160,4 +9175,3 @@ more than this number of multiplications is implemented by calling the ...@@ -9160,4 +9175,3 @@ more than this number of multiplications is implemented by calling the
system library's @code{pow}, @code{powf} or @code{powl} routines. system library's @code{pow}, @code{powf} or @code{powl} routines.
The default value places no upper bound on the multiplication count. The default value places no upper bound on the multiplication count.
@end defmac @end defmac
...@@ -958,6 +958,12 @@ reg_becomes_live (rtx reg, rtx setter ATTRIBUTE_UNUSED, void *live) ...@@ -958,6 +958,12 @@ reg_becomes_live (rtx reg, rtx setter ATTRIBUTE_UNUSED, void *live)
SET_HARD_REG_BIT (* (HARD_REG_SET *) live, regno + nregs); SET_HARD_REG_BIT (* (HARD_REG_SET *) live, regno + nregs);
} }
/* Make sure if MODE_ENTRY is defined the MODE_EXIT is defined
and vice versa. */
#if defined (MODE_ENTRY) != defined (MODE_EXIT)
#error "Both MODE_ENTRY and MODE_EXIT must be defined"
#endif
/* Find all insns that need a particular mode setting, and insert the /* Find all insns that need a particular mode setting, and insert the
necessary mode switches. Return true if we did work. */ necessary mode switches. Return true if we did work. */
...@@ -990,7 +996,7 @@ optimize_mode_switching (FILE *file) ...@@ -990,7 +996,7 @@ optimize_mode_switching (FILE *file)
/* Create the list of segments within each basic block. /* Create the list of segments within each basic block.
If NORMAL_MODE is defined, allow for two extra If NORMAL_MODE is defined, allow for two extra
blocks split from the entry and exit block. */ blocks split from the entry and exit block. */
#ifdef NORMAL_MODE #if defined (MODE_ENTRY) && defined (MODE_EXIT)
entry_exit_extra = 2; entry_exit_extra = 2;
#endif #endif
bb_info[n_entities] bb_info[n_entities]
...@@ -1003,7 +1009,7 @@ optimize_mode_switching (FILE *file) ...@@ -1003,7 +1009,7 @@ optimize_mode_switching (FILE *file)
if (! n_entities) if (! n_entities)
return 0; return 0;
#ifdef NORMAL_MODE #if defined (MODE_ENTRY) && defined (MODE_EXIT)
{ {
/* Split the edge from the entry block and the fallthrough edge to the /* Split the edge from the entry block and the fallthrough edge to the
exit block, so that we can note that there NORMAL_MODE is supplied / exit block, so that we can note that there NORMAL_MODE is supplied /
...@@ -1068,7 +1074,9 @@ optimize_mode_switching (FILE *file) ...@@ -1068,7 +1074,9 @@ optimize_mode_switching (FILE *file)
add_seginfo (info + bb->index, ptr); add_seginfo (info + bb->index, ptr);
RESET_BIT (transp[bb->index], j); RESET_BIT (transp[bb->index], j);
} }
#ifdef MODE_AFTER
last_mode = MODE_AFTER (last_mode, insn);
#endif
/* Update LIVE_NOW. */ /* Update LIVE_NOW. */
for (link = REG_NOTES (insn); link; link = XEXP (link, 1)) for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
if (REG_NOTE_KIND (link) == REG_DEAD) if (REG_NOTE_KIND (link) == REG_DEAD)
...@@ -1089,9 +1097,9 @@ optimize_mode_switching (FILE *file) ...@@ -1089,9 +1097,9 @@ optimize_mode_switching (FILE *file)
add_seginfo (info + bb->index, ptr); add_seginfo (info + bb->index, ptr);
} }
} }
#ifdef NORMAL_MODE #if defined (MODE_ENTRY) && defined (MODE_EXIT)
{ {
int mode = NORMAL_MODE (e); int mode = MODE_ENTRY (e);
if (mode != no_mode) if (mode != no_mode)
{ {
...@@ -1109,7 +1117,7 @@ optimize_mode_switching (FILE *file) ...@@ -1109,7 +1117,7 @@ optimize_mode_switching (FILE *file)
info[bb->index].computing = mode; info[bb->index].computing = mode;
if (pre_exit) if (pre_exit)
info[pre_exit->index].seginfo->mode = mode; info[pre_exit->index].seginfo->mode = MODE_EXIT (e);
} }
} }
#endif /* NORMAL_MODE */ #endif /* NORMAL_MODE */
...@@ -1285,7 +1293,7 @@ optimize_mode_switching (FILE *file) ...@@ -1285,7 +1293,7 @@ optimize_mode_switching (FILE *file)
if (need_commit) if (need_commit)
commit_edge_insertions (); commit_edge_insertions ();
#ifdef NORMAL_MODE #if defined (MODE_ENTRY) && defined (MODE_EXIT)
cleanup_cfg (CLEANUP_NO_INSN_DEL); cleanup_cfg (CLEANUP_NO_INSN_DEL);
#else #else
if (!need_commit && !emited) if (!need_commit && !emited)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment