diff mbox

RFA: replace MD_REDIRECT_BRANCH with TARGET_CAN_FOLLOW_JUMP

Message ID 20130423091437.jztpvkle7co4wgoo-nzlynne@webmail.spamcop.net
State New
Headers show

Commit Message

Joern Rennecke April 23, 2013, 1:14 p.m. UTC
As discussed in the comments to PR38449, this patch replaces
MD_REDIRECT_BRANCH with TARGET_CAN_FOLLOW_JUMP

bootstrapped / regtested on i686-pc-linux-gnu

cross-built / regtested for i686-pc-linux-gnu X sh-elf

2013-04-22  Joern Rennecke <joern.rennecke@embecosm.com>

         * config/sh/sh-protos.h (sh_can_redirect_branch): Don't declare.
         * config/sh/sh.c (TARGET_CAN_FOLLOW_JUMP): Redefine.
         (sh_can_redirect_branch): Rename to ...
         (sh_can_follow_branch): ... this.  Constify argument types.
         * config/sh/sh.h (MD_CAN_REDIRECT_BRANCH): Don't define.
         * doc/tm.texi.in (MD_CAN_REDIRECT_BRANCH): Remove documentation.
         * reorg.c (steal_delay_list_from_target): Use targetm.can_follow_jump.
         * doc/tm.texi: Regenerate.

Comments

Kaz Kojima April 24, 2013, 12:22 p.m. UTC | #1
Joern Rennecke <joern.rennecke@embecosm.com> wrote:
> As discussed in the comments to PR38449, this patch replaces
> MD_REDIRECT_BRANCH with TARGET_CAN_FOLLOW_JUMP
> 
> bootstrapped / regtested on i686-pc-linux-gnu
> 
> cross-built / regtested for i686-pc-linux-gnu X sh-elf

FYI, I've tested the patch with the top level "make -k check" also on
sh4-unknown-linux-gnu with no new failures.  SH portion looks fine.

Regards,
	kaz
diff mbox

Patch

Index: config/sh/sh-protos.h
===================================================================
--- config/sh/sh-protos.h	(revision 198139)
+++ config/sh/sh-protos.h	(working copy)
@@ -150,7 +150,6 @@  extern void expand_sf_binop (rtx (*)(rtx
 extern void expand_df_unop (rtx (*)(rtx, rtx, rtx), rtx *);
 extern void expand_df_binop (rtx (*)(rtx, rtx, rtx, rtx), rtx *);
 extern int sh_insn_length_adjustment (rtx);
-extern bool sh_can_redirect_branch (rtx, rtx);
 extern void sh_expand_unop_v2sf (enum rtx_code, rtx, rtx);
 extern void sh_expand_binop_v2sf (enum rtx_code, rtx, rtx, rtx);
 extern bool sh_expand_t_scc (rtx *);
Index: config/sh/sh.c
===================================================================
--- config/sh/sh.c	(revision 198139)
+++ config/sh/sh.c	(working copy)
@@ -235,6 +235,7 @@  static int sh_variable_issue (FILE *, in
 static bool sh_function_ok_for_sibcall (tree, tree);
 
 static bool sh_cannot_modify_jumps_p (void);
+static bool sh_can_follow_branch (const_rtx, const_rtx);
 static reg_class_t sh_target_reg_class (void);
 static bool sh_optimize_target_register_callee_saved (bool);
 static bool sh_ms_bitfield_layout_p (const_tree);
@@ -462,6 +463,8 @@  #define TARGET_ASM_CAN_OUTPUT_MI_THUNK \
 
 #undef TARGET_CANNOT_MODIFY_JUMPS_P
 #define TARGET_CANNOT_MODIFY_JUMPS_P sh_cannot_modify_jumps_p
+#undef TARGET_CAN_FOLLOW_JUMP
+#define TARGET_CAN_FOLLOW_JUMP sh_can_follow_branch
 #undef TARGET_BRANCH_TARGET_REGISTER_CLASS
 #define TARGET_BRANCH_TARGET_REGISTER_CLASS sh_target_reg_class
 #undef TARGET_BRANCH_TARGET_REGISTER_CALLEE_SAVED
@@ -10655,8 +10658,8 @@  mark_constant_pool_use (rtx x)
 /* Return true if it's possible to redirect BRANCH1 to the destination
    of an unconditional jump BRANCH2.  We only want to do this if the
    resulting branch will have a short displacement.  */
-bool
-sh_can_redirect_branch (rtx branch1, rtx branch2)
+static bool
+sh_can_follow_branch (const_rtx branch1, const_rtx branch2)
 {
   if (flag_expensive_optimizations && simplejump_p (branch2))
     {
Index: config/sh/sh.h
===================================================================
--- config/sh/sh.h	(revision 198139)
+++ config/sh/sh.h	(working copy)
@@ -2257,9 +2257,6 @@  #define MODE_PRIORITY_TO_MODE(ENTITY, N)
 #define EMIT_MODE_SET(ENTITY, MODE, HARD_REGS_LIVE) \
   fpscr_set_from_mem ((MODE), (HARD_REGS_LIVE))
 
-#define MD_CAN_REDIRECT_BRANCH(INSN, SEQ) \
-  sh_can_redirect_branch ((INSN), (SEQ))
-
 #define DWARF_FRAME_RETURN_COLUMN \
   (TARGET_SH5 ? DWARF_FRAME_REGNUM (PR_MEDIA_REG) : DWARF_FRAME_REGNUM (PR_REG))
 
Index: doc/tm.texi
===================================================================
--- doc/tm.texi	(revision 198139)
+++ doc/tm.texi	(working copy)
@@ -10975,17 +10975,6 @@  @deftypefn {Target Hook} bool TARGET_LEG
 Take an instruction in @var{insn} and return @code{false} if the instruction is not appropriate as a combination of two or more instructions.  The default is to accept all instructions.
 @end deftypefn
 
-@defmac MD_CAN_REDIRECT_BRANCH (@var{branch1}, @var{branch2})
-
-Take a branch insn in @var{branch1} and another in @var{branch2}.
-Return true if redirecting @var{branch1} to the destination of
-@var{branch2} is possible.
-
-On some targets, branches may have a limited range.  Optimizing the
-filling of delay slots can result in branches being redirected, and this
-may in turn cause a branch offset to overflow.
-@end defmac
-
 @deftypefn {Target Hook} bool TARGET_CAN_FOLLOW_JUMP (const_rtx @var{follower}, const_rtx @var{followee})
 FOLLOWER and FOLLOWEE are JUMP_INSN instructions;  return true if FOLLOWER may be modified to follow FOLLOWEE;  false, if it can't.  For example, on some targets, certain kinds of branches can't be made to  follow through a hot/cold partitioning.
 @end deftypefn
Index: doc/tm.texi.in
===================================================================
--- doc/tm.texi.in	(revision 198139)
+++ doc/tm.texi.in	(working copy)
@@ -10817,17 +10817,6 @@  @hook TARGET_INVALID_WITHIN_DOLOOP
 
 @hook TARGET_LEGITIMATE_COMBINED_INSN
 
-@defmac MD_CAN_REDIRECT_BRANCH (@var{branch1}, @var{branch2})
-
-Take a branch insn in @var{branch1} and another in @var{branch2}.
-Return true if redirecting @var{branch1} to the destination of
-@var{branch2} is possible.
-
-On some targets, branches may have a limited range.  Optimizing the
-filling of delay slots can result in branches being redirected, and this
-may in turn cause a branch offset to overflow.
-@end defmac
-
 @hook TARGET_CAN_FOLLOW_JUMP
 
 @hook TARGET_COMMUTATIVE_P
Index: reorg.c
===================================================================
--- reorg.c	(revision 198139)
+++ reorg.c	(working copy)
@@ -1086,13 +1086,11 @@  steal_delay_list_from_target (rtx insn,
       || ! single_set (XVECEXP (seq, 0, 0)))
     return delay_list;
 
-#ifdef MD_CAN_REDIRECT_BRANCH
   /* On some targets, branches with delay slots can have a limited
      displacement.  Give the back end a chance to tell us we can't do
      this.  */
-  if (! MD_CAN_REDIRECT_BRANCH (insn, XVECEXP (seq, 0, 0)))
+  if (! targetm.can_follow_jump (insn, XVECEXP (seq, 0, 0)))
     return delay_list;
-#endif
 
   for (i = 1; i < XVECLEN (seq, 0); i++)
     {