+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>
* genmodes.c, mode-classes.def: New files.
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000000ff }, \
/* ALL_REGS: */ \
{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x01ffffff }, \
-}
+}
/* The same information, inverted:
Return the class number of the smallest class containing
|| TREE_CODE (VALTYPE) == OFFSET_TYPE)) \
? (TARGET_SHMEDIA ? DImode : SImode) : TYPE_MODE (VALTYPE)), \
BASE_RETURN_VALUE_REG (TYPE_MODE (VALTYPE)))
-
+
/* Define how to find the value returned by a library function
assuming the value has mode MODE. */
#define LIBCALL_VALUE(MODE) \
#define EXIT_IGNORE_STACK 1
-/*
+/*
On the SH, the trampoline looks like
2 0002 D202 mov.l l2,r2
1 0000 D301 mov.l l1,r3
#define any_register_operand register_operand
/* Define this macro if it is advisable to hold scalars in registers
- in a wider mode than that declared by the program. In such cases,
+ in a wider mode than that declared by the program. In such cases,
the value is constrained to be within the bounds of the declared
type, but kept valid in the wider mode. The signedness of the
extension may differ from that of the type.
? (TARGET_FMOVD ? FP_MODE_DOUBLE : FP_MODE_NONE) \
: 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) \
&& (REGNO) == FPSCR_REG)
? get_attr_fp_mode (INSN) \
: 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) \
((TARGET_FPU_SINGLE != 0) ^ (N) ? FP_MODE_SINGLE : FP_MODE_DOUBLE)
(UNSPECV_CONST8 6)
(UNSPECV_WINDOW_END 10)
(UNSPECV_CONST_END 11)
-])
+])
;; -------------------------------------------------------------------------
;; Attributes
;; ftrc_s fix_truncsfsi2_i4
;; dfdiv double precision floating point divide (or square root)
;; cwb ic_invalidate_line_i
-;; tls_load load TLS related address
+;; tls_load load TLS related address
;; arith_media SHmedia arithmetic, logical, and shift instructions
;; cbranch_media SHmedia conditional branch instructions
;; cmp_media SHmedia compare instructions
(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
; from the instruction it can be 2 bytes long. Something in the
; range -4090..4100 bytes can be 6 bytes long. All other conditional
;; delay slot scheduling from the target.
(define_insn "indirect_jump_scratch"
[(set (match_operand:SI 0 "register_operand" "=r")
- (unspec:SI [(match_operand 1 "const_int_operand" "")] UNSPEC_BBR))
+ (unspec:SI [(match_operand 1 "const_int_operand" "")] UNSPEC_BBR))
(set (pc) (unspec [(const_int 0)] UNSPEC_BBR))]
"TARGET_SH1"
""
(set (attr "fp_mode")
(if_then_else (eq_attr "fpu_single" "yes")
(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.
(set (attr "fp_mode")
(if_then_else (eq_attr "fpu_single" "yes")
(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"
[(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" ""))
(set (attr "fp_mode")
(if_then_else (eq_attr "fpu_single" "yes")
(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"
[(call (mem:SI (match_operand:SI 0 "arith_reg_operand" "r"))
(set (attr "fp_mode")
(if_then_else (eq_attr "fpu_single" "yes")
(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"
[(set (match_operand 0 "" "=rf")
(set (attr "fp_mode")
(if_then_else (eq_attr "fpu_single" "yes")
(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"
[(set (match_operand 0 "" "=rf")
(set (attr "fp_mode")
(if_then_else (eq_attr "fpu_single" "yes")
(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"
[(set (match_operand 0 "" "=rf")
[(set (reg:PSI FPSCR_REG)
(xor:PSI (reg:PSI FPSCR_REG) (const_int 1048576)))]
"TARGET_SH4"
- "fschg")
+ "fschg"
+ [(set_attr "fp_set" "unknown")])
(define_expand "addsf3"
[(set (match_operand:SF 0 "arith_reg_operand" "")
(const_int 4294967295))
(ashift:DI (match_operand:DI 2 "arith_reg_or_0_operand" "rZ")
(const_int 32))))]
-
+
"TARGET_SHMEDIA"
"mshflo.l %N1, %N2, %0"
[(set_attr "type" "arith_media")])
(const_int 32))
(and:DI (match_operand:DI 2 "arith_reg_or_0_operand" "rZ")
(const_int 4294967295))))]
-
+
"TARGET_SHMEDIA"
"mshflo.l %N2, %N1, %0"
[(set_attr "type" "arith_media")])
"rZ"))
(ashift:DI (match_operand:DI 2 "arith_reg_or_0_operand" "rZ")
(const_int 32))))]
-
+
"TARGET_SHMEDIA"
"mshflo.l %N1, %N2, %0"
[(set_attr "type" "arith_media")])
;; (vec_concat:V2SF (match_operand:SF 1 "register_operand" "rZ,0,f")
(vec_concat:V2SF (match_operand:SF 1 "register_operand" "rZ,f,f")
(match_operand:SF 2 "register_operand" "rZ,f,f")))]
-
+
"TARGET_SHMEDIA"
"@
mshflo.l %N1, %N2, %0
(ior:DI (ashift:DI (match_operand:DI 1 "arith_reg_or_0_operand" "rZ")
(const_int 32))
(zero_extend:DI (match_operand:SI 2 "extend_reg_or_0_operand" "rZ"))))]
-
+
"TARGET_SHMEDIA"
"mshflo.l %N2, %N1, %0"
[(set_attr "type" "arith_media")])
[(set_attr "type" "arith_media")])
;; The following description models the
-;; SH4 pipeline using the DFA based scheduler.
-;; The DFA based description is better way to model
+;; SH4 pipeline using the DFA based scheduler.
+;; The DFA based description is better way to model
;; a superscalar pipeline as compared to function unit
-;; reservation model.
-;; 1. The function unit based model is oriented to describe at most one
-;; unit reservation by each insn. It is difficult to model unit reservations in multiple
+;; reservation model.
+;; 1. The function unit based model is oriented to describe at most one
+;; unit reservation by each insn. It is difficult to model unit reservations in multiple
;; pipeline units by same insn. This can be done using DFA based description.
;; 2. The execution performance of DFA based scheduler does not depend on processor complexity.
-;; 3. Writing all unit reservations for an instruction class is more natural description
-;; of the pipeline and makes interface of the hazard recognizer simpler than the
+;; 3. Writing all unit reservations for an instruction class is more natural description
+;; of the pipeline and makes interface of the hazard recognizer simpler than the
;; old function unit based model.
;; 4. The DFA model is richer and is a part of greater overall framework of RCSP.
(define_automaton "inst_pipeline,fpu_pipe")
;; This unit is basically the decode unit of the processor.
-;; Since SH4 is a dual issue machine,it is as if there are two
+;; Since SH4 is a dual issue machine,it is as if there are two
;; units so that any insn can be processed by either one
;; of the decoding unit.
;; The address calculator used for branch instructions.
;; This will be reserved after "issue" of branch instructions
-;; and this is to make sure that no two branch instructions
-;; can be issued in parallel.
+;; and this is to make sure that no two branch instructions
+;; can be issued in parallel.
(define_cpu_unit "pcr_addrcalc" "inst_pipeline")
(define_reservation "fpu" "F1+F2")
-;; This is to highlight the fact that f1
+;; This is to highlight the fact that f1
;; cannot overlap with F1.
(exclusion_set "f1_1,f1_2" "F1")
(define_insn_reservation "nil" 0 (eq_attr "type" "nil") "nothing")
-;; Although reg moves have a latency of zero
+;; Although reg moves have a latency of zero
;; we need to highlight that they use D stage
;; for one cycle.
;; Latency: 1
;; Issue Rate: 1
-(define_insn_reservation "sh4_simple_arith" 1
+(define_insn_reservation "sh4_simple_arith" 1
(and (eq_attr "pipe_model" "sh4")
(eq_attr "insn_class" "ex_group"))
"issue,int")
;; Group: CO
;; Latency: 5
;; Issue Rate: 5
-;; this instruction can be executed in any of the pipelines
+;; this instruction can be executed in any of the pipelines
;; and blocks the pipeline for next 4 stages.
(define_insn_reservation "sh4_return_from_exp" 5
(and (eq_attr "pipe_model" "sh4")
(eq_attr "type" "cwb"))
"d_lock*2,(d_lock+memory)*3,issue+load_store+memory,memory*2")
-
+
;; LDS to PR,JSR
;; Group: CO
;; Latency: 3
;; scheduling. For the function call case, it's really best that we end with
;; something that models an rts.
-(define_insn_reservation "sh4_lds_to_pr" 3
+(define_insn_reservation "sh4_lds_to_pr" 3
(and (eq_attr "pipe_model" "sh4")
(eq_attr "type" "prset") )
"d_lock*2")
;; We could, of course, provide exact scheduling information for specific
;; sfuncs, if that should prove useful.
-(define_insn_reservation "sh4_call" 16
+(define_insn_reservation "sh4_call" 16
(and (eq_attr "pipe_model" "sh4")
(eq_attr "type" "call,sfunc"))
"d_lock*16")
-;; LDS.L to PR
+;; LDS.L to PR
;; Group: CO
;; Latency: 3
;; Issue Rate: 2
;; The SX unit is blocked for last 2 cycles.
-
+
(define_insn_reservation "ldsmem_to_pr" 3
(and (eq_attr "pipe_model" "sh4")
(eq_attr "type" "pload"))
;; Latency: 2
;; Issue Rate: 2
-(define_insn_reservation "sh4_prstore_mem" 2
+(define_insn_reservation "sh4_prstore_mem" 2
(and (eq_attr "pipe_model" "sh4")
(eq_attr "type" "pstore"))
"d_lock*2,nothing,memory")
;; Group: CO
;; Latency: 4
;; Issue Rate: 1
-;; F1 is blocked for last three cycles.
+;; F1 is blocked for last three cycles.
(define_insn_reservation "fpscr_load" 4
(and (eq_attr "pipe_model" "sh4")
(eq_attr "type" "dfp_conv"))
"issue,F01,F1+F2,F2")
-;; Double-precision floating-point (FADD,FMUL,FSUB)
+;; Double-precision floating-point (FADD,FMUL,FSUB)
;; Group: FE
;; Latency: (7,8)/9
;; Issue Rate: 1
(eq_attr "type" "dfp_arith"))
"issue,F01,F1+F2,fpu*4,F2")
-;; Double-precision FCMP (FCMP/EQ,FCMP/GT)
+;; Double-precision FCMP (FCMP/EQ,FCMP/GT)
;; Group: CO
;; Latency: 3/5
;; Issue Rate: 2
-(define_insn_reservation "fp_double_cmp" 3
+(define_insn_reservation "fp_double_cmp" 3
(and (eq_attr "pipe_model" "sh4")
(eq_attr "type" "dfp_cmp"))
"d_lock,(d_lock+F01),F1+F2,F2")
@end defmac
@defmac SYSROOT_SUFFIX_SPEC
-Define this macro to add a suffix to the target sysroot when GCC is
-configured with a sysroot. This will cause GCC to search for usr/lib,
-et al, within sysroot+suffix.
+Define this macro to add a suffix to the target sysroot when GCC is
+configured with a sysroot. This will cause GCC to search for usr/lib,
+et al, within sysroot+suffix.
@end defmac
@defmac SYSROOT_HEADERS_SUFFIX_SPEC
-Define this macro to add a headers_suffix to the target sysroot when
-GCC is configured with a sysroot. This will cause GCC to pass the
+Define this macro to add a headers_suffix to the target sysroot when
+GCC is configured with a sysroot. This will cause GCC to pass the
updated sysroot+headers_suffix to CPP@, causing it to search for
usr/include, et al, within sysroot+headers_suffix.
@end defmac
letters, amongst those accepted by @code{EXTRA_CONSTRAINT}, that should
be treated like memory constraints by the reload pass.
-It should return 1 if the operand type represented by the constraint
+It should return 1 if the operand type represented by the constraint
at the start of @var{str}, the first letter of which is the letter @var{c},
comprises a subset of all memory references including
-all those whose address is simply a base register. This allows the reload
-pass to reload an operand, if it does not directly correspond to the operand
+all those whose address is simply a base register. This allows the reload
+pass to reload an operand, if it does not directly correspond to the operand
type of @var{c}, by copying its address into a base register.
For example, on the S/390, some instructions do not accept arbitrary
@code{EXTRA_CONSTRAINT_STR}, that should
be treated like address constraints by the reload pass.
-It should return 1 if the operand type represented by the constraint
+It should return 1 if the operand type represented by the constraint
at the start of @var{str}, which starts with the letter @var{c}, comprises
a subset of all memory addresses including
-all those that consist of just a base register. This allows the reload
-pass to reload an operand, if it does not directly correspond to the operand
+all those that consist of just a base register. This allows the reload
+pass to reload an operand, if it does not directly correspond to the operand
type of @var{str}, by copying it into a base register.
Any constraint marked as @code{EXTRA_ADDRESS_CONSTRAINT} can only
-be used with the @code{address_operand} predicate. It is treated
+be used with the @code{address_operand} predicate. It is treated
analogously to the @samp{p} constraint.
@end defmac
@end defmac
@defmac DWARF_ALT_FRAME_RETURN_COLUMN
-A C expression whose value is an integer giving a DWARF 2 column
+A C expression whose value is an integer giving a DWARF 2 column
number that may be used as an alternate return column. This should
-be defined only if @code{DWARF_FRAME_RETURN_COLUMN} is set to a
+be defined only if @code{DWARF_FRAME_RETURN_COLUMN} is set to a
general register, but an alternate column needs to be used for
signal frames.
@end defmac
untouched by the epilogue, but could also be a stack slot.
Do not define this macro if the stack pointer is saved and restored
-by the regular prolog and epilog code in the call frame itself; in
-this case, the exception handling library routines will update the
-stack location to be restored in place. Otherwise, you must define
-this macro if you want to support call frame exception handling like
+by the regular prolog and epilog code in the call frame itself; in
+this case, the exception handling library routines will update the
+stack location to be restored in place. Otherwise, you must define
+this macro if you want to support call frame exception handling like
that provided by DWARF 2.
@end defmac
return address is stored. For targets that return by popping an
address off the stack, this might be a memory address just below
the @emph{target} call frame rather than inside the current call
-frame. If defined, @code{EH_RETURN_STACKADJ_RTX} will have already
-been assigned, so it may be used to calculate the location of the
+frame. If defined, @code{EH_RETURN_STACKADJ_RTX} will have already
+been assigned, so it may be used to calculate the location of the
target call frame.
Some targets have more complex requirements than storing to an
Given a dwarf register, this macro should return the internal unwind
column number to use instead.
-See the PowerPC's SPE target for an example.
+See the PowerPC's SPE target for an example.
@end defmac
@node Elimination
@findex gofast_maybe_init_libfuncs
@defmac US_SOFTWARE_GOFAST
Define this macro if your system C library uses the US Software GOFAST
-library to provide floating point emulation.
+library to provide floating point emulation.
In addition to defining this macro, your architecture must set
@code{TARGET_INIT_LIBFUNCS} to @code{gofast_maybe_init_libfuncs}, or
A C statement (sans semicolon) to output to the stdio stream
@var{stream} a directive telling the assembler to calculate the size of
the symbol @var{name} by subtracting its address from the current
-address.
+address.
If you define @code{SIZE_ASM_OP}, a default definition of this macro is
provided. The default assumes that the assembler recognizes a special
If you define this macro, you also have to define
@code{NUM_MODES_FOR_MODE_SWITCHING}, @code{MODE_NEEDED},
@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
@defmac NUM_MODES_FOR_MODE_SWITCHING
be switched into prior to the execution of @var{insn}.
@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
+mode switching. It should evaluate to an integer, which is a mode that
+@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 entry and exit.
+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
@defmac MODE_PRIORITY_TO_MODE (@var{entity}, @var{n})
@end deftypefn
@defmac POWI_MAX_MULTS
-If defined, this macro is interpreted as a signed integer C expression
+If defined, this macro is interpreted as a signed integer C expression
that specifies the maximum number of floating point multiplications
that should be emitted when expanding exponentiation by an integer
constant inline. When this value is defined, exponentiation requiring
system library's @code{pow}, @code{powf} or @code{powl} routines.
The default value places no upper bound on the multiplication count.
@end defmac
-
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
necessary mode switches. Return true if we did work. */
/* Create the list of segments within each basic block.
If NORMAL_MODE is defined, allow for two extra
blocks split from the entry and exit block. */
-#ifdef NORMAL_MODE
+#if defined (MODE_ENTRY) && defined (MODE_EXIT)
entry_exit_extra = 2;
#endif
bb_info[n_entities]
if (! n_entities)
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
exit block, so that we can note that there NORMAL_MODE is supplied /
add_seginfo (info + bb->index, ptr);
RESET_BIT (transp[bb->index], j);
}
-
+#ifdef MODE_AFTER
+ last_mode = MODE_AFTER (last_mode, insn);
+#endif
/* Update LIVE_NOW. */
for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
if (REG_NOTE_KIND (link) == REG_DEAD)
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)
{
info[bb->index].computing = mode;
if (pre_exit)
- info[pre_exit->index].seginfo->mode = mode;
+ info[pre_exit->index].seginfo->mode = MODE_EXIT (e);
}
}
#endif /* NORMAL_MODE */
if (need_commit)
commit_edge_insertions ();
-#ifdef NORMAL_MODE
+#if defined (MODE_ENTRY) && defined (MODE_EXIT)
cleanup_cfg (CLEANUP_NO_INSN_DEL);
#else
if (!need_commit && !emited)