unconditionally compile most of the delay slot code
authorTrevor Saunders <tbsaunde+gcc@tbsaunde.org>
Wed, 21 Oct 2015 21:05:02 +0000 (21:05 +0000)
committerTrevor Saunders <tbsaunde@gcc.gnu.org>
Wed, 21 Oct 2015 21:05:02 +0000 (21:05 +0000)
gcc/ChangeLog:

2015-10-21  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>

* cfgrtl.c (pass_free_cfg::execute): Adjust.
* final.c (dbr_sequence_length): Always define.
(shorten_branches): Adjust.
* genattr-common.c (main): Always define DELAY_SLOTS.
* genattr.c (main): Unconditionally declare functions and define
macros related to delay slots.
* genattrtab.c (write_eligible_delay): Adjust.
(main): Always write out delay slot functions.
* opts.c (default_options_table): Adjust.
* reorg.c (redirect_with_delay_slots_safe_p): Likewise.
(redirect_with_delay_list_safe_p): Likewise.
(fill_simple_delay_slots): Likewise.
(fill_slots_from_thread): Likewise.
(make_return_insns): Likewise.
(dbr_schedule): Likewise.
(rest_of_handle_delay_slots): Likewise.
(pass_delay_slots::gate): Likewise.
* toplev.c (process_options): Likewise.

From-SVN: r229145

gcc/ChangeLog
gcc/cfgrtl.c
gcc/final.c
gcc/genattr-common.c
gcc/genattr.c
gcc/genattrtab.c
gcc/opts.c
gcc/reorg.c
gcc/toplev.c

index 20f72c51b96c8141ee0bb76e791d912b9d8db2af..cdeb703dbb7fd75ef0c1d74813bb0fc520be8159 100644 (file)
@@ -1,3 +1,24 @@
+2015-10-21  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>
+
+       * cfgrtl.c (pass_free_cfg::execute): Adjust.
+       * final.c (dbr_sequence_length): Always define.
+       (shorten_branches): Adjust.
+       * genattr-common.c (main): Always define DELAY_SLOTS.
+       * genattr.c (main): Unconditionally declare functions and define
+       macros related to delay slots.
+       * genattrtab.c (write_eligible_delay): Adjust.
+       (main): Always write out delay slot functions.
+       * opts.c (default_options_table): Adjust.
+       * reorg.c (redirect_with_delay_slots_safe_p): Likewise.
+       (redirect_with_delay_list_safe_p): Likewise.
+       (fill_simple_delay_slots): Likewise.
+       (fill_slots_from_thread): Likewise.
+       (make_return_insns): Likewise.
+       (dbr_schedule): Likewise.
+       (rest_of_handle_delay_slots): Likewise.
+       (pass_delay_slots::gate): Likewise.
+       * toplev.c (process_options): Likewise.
+
 2015-10-21  Richard Henderson  <rth@redhat.com>
 
        * targhooks.c (default_addr_space_pointer_mode): Remove check
index ef73b49201b8334d3749296c50da4b7cf33bd4c4..d2fe1e07537c11523b9c71f829b1e45c65de198c 100644 (file)
@@ -483,15 +483,13 @@ public:
 unsigned int
 pass_free_cfg::execute (function *)
 {
-#ifdef DELAY_SLOTS
   /* The resource.c machinery uses DF but the CFG isn't guaranteed to be
      valid at that point so it would be too late to call df_analyze.  */
-  if (optimize > 0 && flag_delayed_branch)
+  if (DELAY_SLOTS && optimize > 0 && flag_delayed_branch)
     {
       df_note_add_problem ();
       df_analyze ();
     }
-#endif
 
   if (crtl->has_bb_partition)
     insert_section_boundary_note ();
index b604c441f52b1b48b60a1cb74eade57ea913edd6..18faa63e26d0afd689f9d1b7d2e095f04ab06fe9 100644 (file)
@@ -297,7 +297,6 @@ app_disable (void)
    delayed branch sequence (we don't count the insn needing the
    delay slot).   Zero if not in a delayed branch sequence.  */
 
-#ifdef DELAY_SLOTS
 int
 dbr_sequence_length (void)
 {
@@ -306,7 +305,6 @@ dbr_sequence_length (void)
   else
     return 0;
 }
-#endif
 \f
 /* The next two pages contain routines used to compute the length of an insn
    and to shorten branches.  */
@@ -1156,11 +1154,11 @@ shorten_branches (rtx_insn *first)
        {
          int i;
          int const_delay_slots;
-#ifdef DELAY_SLOTS
-         const_delay_slots = const_num_delay_slots (body_seq->insn (0));
-#else
-         const_delay_slots = 0;
-#endif
+         if (DELAY_SLOTS)
+           const_delay_slots = const_num_delay_slots (body_seq->insn (0));
+         else
+           const_delay_slots = 0;
+
          int (*inner_length_fun) (rtx_insn *)
            = const_delay_slots ? length_fun : insn_default_length;
          /* Inside a delay slot sequence, we do not do any branch shortening
index 0ff8da984dd7f7c030658877528cd22e3f138056..a51f8ebf824406537964bb10802bd8c06d04b7dc 100644 (file)
@@ -87,11 +87,7 @@ main (int argc, char **argv)
        break;
 
       case DEFINE_DELAY:
-       if (!have_delay)
-         {
-           printf ("#define DELAY_SLOTS\n");
-           have_delay = true;
-         }
+       have_delay = true;
        break;
 
       case DEFINE_INSN_RESERVATION:
@@ -105,6 +101,8 @@ main (int argc, char **argv)
       default:
        break;
       }
+
+           printf ("#define DELAY_SLOTS %d\n", have_delay);
   puts ("\n#endif /* GCC_INSN_ATTR_COMMON_H */");
 
   if (ferror (stdout) || fflush (stdout) || fclose (stdout))
index d31f00733d945d6cf6e0ff198875db75798a0450..e45f87cbeb26f26655e01b8d6cda48d0f03cf259 100644 (file)
@@ -140,9 +140,8 @@ find_tune_attr (rtx exp)
 int
 main (int argc, char **argv)
 {
-  int have_delay = 0;
-  int have_annul_true = 0;
-  int have_annul_false = 0;
+  bool have_annul_true = false;
+  bool have_annul_false = false;
   int num_insn_reservations = 0;
   int i;
 
@@ -172,29 +171,13 @@ main (int argc, char **argv)
          break;
 
        case DEFINE_DELAY:
-         if (! have_delay)
-           {
-             printf ("extern int num_delay_slots (rtx_insn *);\n");
-             printf ("extern int eligible_for_delay (rtx_insn *, int, rtx_insn *, int);\n\n");
-             printf ("extern int const_num_delay_slots (rtx_insn *);\n\n");
-             have_delay = 1;
-           }
-
          for (i = 0; i < XVECLEN (def, 1); i += 3)
            {
-             if (XVECEXP (def, 1, i + 1) && ! have_annul_true)
-               {
-                 printf ("#define ANNUL_IFTRUE_SLOTS\n");
-                 printf ("extern int eligible_for_annul_true (rtx_insn *, int, rtx_insn *, int);\n");
-                 have_annul_true = 1;
-               }
-
-             if (XVECEXP (def, 1, i + 2) && ! have_annul_false)
-               {
-                 printf ("#define ANNUL_IFFALSE_SLOTS\n");
-                 printf ("extern int eligible_for_annul_false (rtx_insn *, int, rtx_insn *, int);\n");
-                 have_annul_false = 1;
-               }
+             if (XVECEXP (def, 1, i + 1))
+               have_annul_true = true;
+
+             if (XVECEXP (def, 1, i + 2))
+               have_annul_false = true;
            }
          break;
 
@@ -208,6 +191,14 @@ main (int argc, char **argv)
        }
     }
 
+  printf ("extern int num_delay_slots (rtx_insn *);\n");
+  printf ("extern int eligible_for_delay (rtx_insn *, int, rtx_insn *, int);\n\n");
+  printf ("extern int const_num_delay_slots (rtx_insn *);\n\n");
+  printf ("#define ANNUL_IFTRUE_SLOTS %d\n", have_annul_true);
+  printf ("extern int eligible_for_annul_true (rtx_insn *, int, rtx_insn *, int);\n");
+  printf ("#define ANNUL_IFFALSE_SLOTS %d\n", have_annul_false);
+  printf ("extern int eligible_for_annul_false (rtx_insn *, int, rtx_insn *, int);\n");
+
   if (num_insn_reservations > 0)
     {
       bool has_tune_attr
index 932b18b12374aa876b9de29ed3a8f70a5cec4c0b..8d1fa6c9bbf09d2b5a171e239339039a10e48e1c 100644 (file)
@@ -4449,7 +4449,7 @@ write_eligible_delay (FILE *outf, const char *kind)
                 "                 rtx_insn *candidate_insn, int flags ATTRIBUTE_UNUSED)\n",
           kind);
   fprintf (outf, "{\n");
-  fprintf (outf, "  rtx_insn *insn;\n");
+  fprintf (outf, "  rtx_insn *insn ATTRIBUTE_UNUSED;\n");
   fprintf (outf, "\n");
   fprintf (outf, "  gcc_assert (slot < %d);\n", max_slots);
   fprintf (outf, "\n");
@@ -5240,8 +5240,7 @@ main (int argc, char **argv)
     }
 
   /* Expand DEFINE_DELAY information into new attribute.  */
-  if (num_delays)
-    expand_delays ();
+  expand_delays ();
 
   /* Make `insn_alternatives'.  */
   int num_insn_codes = get_num_insn_codes ();
@@ -5307,14 +5306,9 @@ main (int argc, char **argv)
   /* Write out delay eligibility information, if DEFINE_DELAY present.
      (The function to compute the number of delay slots will be written
      below.)  */
-  if (num_delays)
-    {
-      write_eligible_delay (attr_file, "delay");
-      if (have_annul_true)
-       write_eligible_delay (attr_file, "annul_true");
-      if (have_annul_false)
-       write_eligible_delay (attr_file, "annul_false");
-    }
+  write_eligible_delay (attr_file, "delay");
+  write_eligible_delay (attr_file, "annul_true");
+  write_eligible_delay (attr_file, "annul_false");
 
   /* Write out constant delay slot info.  */
   write_const_num_delay_slots (attr_file);
index 89b3e793de62cb3f372c1daf1c9560e6b96dd304..a892c8880e8f2db599115255abb9ad1d3c740733 100644 (file)
@@ -429,7 +429,7 @@ static const struct default_options default_options_table[] =
   {
     /* -O1 optimizations.  */
     { OPT_LEVELS_1_PLUS, OPT_fdefer_pop, NULL, 1 },
-#ifdef DELAY_SLOTS
+#if DELAY_SLOTS
     { OPT_LEVELS_1_PLUS, OPT_fdelayed_branch, NULL, 1 },
 #endif
     { OPT_LEVELS_1_PLUS, OPT_fguess_branch_probability, NULL, 1 },
index c51e03cf366effb8f5be3cb2a12ec9df25e55a53..47b938b46d05ae94b5a75fd4bcf2726bd84fd14a 100644 (file)
@@ -131,15 +131,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "target.h"
 #include "tree-pass.h"
 
-#ifdef DELAY_SLOTS
-
-#ifndef ANNUL_IFTRUE_SLOTS
-#define eligible_for_annul_true(INSN, SLOTS, TRIAL, FLAGS) 0
-#endif
-#ifndef ANNUL_IFFALSE_SLOTS
-#define eligible_for_annul_false(INSN, SLOTS, TRIAL, FLAGS) 0
-#endif
-
 \f
 /* First, some functions that were used before GCC got a control flow graph.
    These functions are now only used here in reorg.c, and have therefore
@@ -219,9 +210,6 @@ static void add_to_delay_list (rtx_insn *, vec<rtx_insn *> *);
 static rtx_insn *delete_from_delay_slot (rtx_insn *);
 static void delete_scheduled_jump (rtx_insn *);
 static void note_delay_statistics (int, int);
-#if defined(ANNUL_IFFALSE_SLOTS) || defined(ANNUL_IFTRUE_SLOTS)
-static void optimize_skip (rtx_jump_insn *, vec<rtx_insn *> *);
-#endif
 static int get_jump_flags (const rtx_insn *, rtx);
 static int mostly_true_jump (rtx);
 static rtx get_branch_condition (const rtx_insn *, rtx);
@@ -717,8 +705,6 @@ note_delay_statistics (int slots_filled, int index)
   num_filled_delays[index][slots_filled][reorg_pass_number]++;
 }
 \f
-#if defined(ANNUL_IFFALSE_SLOTS) || defined(ANNUL_IFTRUE_SLOTS)
-
 /* Optimize the following cases:
 
    1.  When a conditional branch skips over only one instruction,
@@ -818,7 +804,6 @@ optimize_skip (rtx_jump_insn *insn, vec<rtx_insn *> *delay_list)
       INSN_ANNULLED_BRANCH_P (insn) = 1;
     }
 }
-#endif
 \f
 /*  Encode and return branch direction and prediction information for
     INSN assuming it will jump to LABEL.
@@ -973,12 +958,12 @@ redirect_with_delay_slots_safe_p (rtx_insn *jump, rtx newlabel, rtx seq)
   flags = get_jump_flags (jump, newlabel);
   for (i = 1; i < pat->len (); i++)
     if (! (
-#ifdef ANNUL_IFFALSE_SLOTS
+#if ANNUL_IFFALSE_SLOTS
           (INSN_ANNULLED_BRANCH_P (jump)
            && INSN_FROM_TARGET_P (pat->insn (i)))
           ? eligible_for_annul_false (jump, i - 1, pat->insn (i), flags) :
 #endif
-#ifdef ANNUL_IFTRUE_SLOTS
+#if ANNUL_IFTRUE_SLOTS
           (INSN_ANNULLED_BRANCH_P (jump)
            && ! INSN_FROM_TARGET_P (XVECEXP (pat, 0, i)))
           ? eligible_for_annul_true (jump, i - 1, pat->insn (i), flags) :
@@ -1005,12 +990,12 @@ redirect_with_delay_list_safe_p (rtx_insn *jump, rtx newlabel,
   unsigned int i = 0;
   for (; i < delay_insns; i++)
     if (! (
-#ifdef ANNUL_IFFALSE_SLOTS
+#if ANNUL_IFFALSE_SLOTS
           (INSN_ANNULLED_BRANCH_P (jump)
            && INSN_FROM_TARGET_P (delay_list[i]))
           ? eligible_for_annul_false (jump, i, delay_list[i], flags) :
 #endif
-#ifdef ANNUL_IFTRUE_SLOTS
+#if ANNUL_IFTRUE_SLOTS
           (INSN_ANNULLED_BRANCH_P (jump)
            && ! INSN_FROM_TARGET_P (delay_list[i]))
           ? eligible_for_annul_true (jump, i, delay_list[i], flags) :
@@ -2096,8 +2081,8 @@ fill_simple_delay_slots (int non_jumps_p)
       /* If all needed slots haven't been filled, we come here.  */
 
       /* Try to optimize case of jumping around a single insn.  */
-#if defined(ANNUL_IFFALSE_SLOTS) || defined(ANNUL_IFTRUE_SLOTS)
-      if (slots_filled != slots_to_fill
+      if ((ANNUL_IFTRUE_SLOTS || ANNUL_IFFALSE_SLOTS)
+       && slots_filled != slots_to_fill
          && delay_list.is_empty ()
          && JUMP_P (insn)
          && (condjump_p (insn) || condjump_in_parallel_p (insn))
@@ -2107,7 +2092,6 @@ fill_simple_delay_slots (int non_jumps_p)
          if (!delay_list.is_empty ())
            slots_filled += 1;
        }
-#endif
 
       /* Try to get insns from beyond the insn needing the delay slot.
         These insns can neither set or reference resources set in insns being
@@ -2494,13 +2478,8 @@ fill_slots_from_thread (rtx_jump_insn *insn, rtx condition,
                goto winner;
            }
          else if (0
-#ifdef ANNUL_IFTRUE_SLOTS
-                  || ! thread_if_true
-#endif
-#ifdef ANNUL_IFFALSE_SLOTS
-                  || thread_if_true
-#endif
-                  )
+                  || (ANNUL_IFTRUE_SLOTS && ! thread_if_true)
+                  || (ANNUL_IFFALSE_SLOTS && thread_if_true))
            {
              old_trial = trial;
              trial = try_split (pat, trial, 0);
@@ -3611,13 +3590,13 @@ make_return_insns (rtx_insn *first)
        {
          for (i = 1; i < XVECLEN (pat, 0); i++)
            if (! (
-#ifdef ANNUL_IFFALSE_SLOTS
+#if ANNUL_IFFALSE_SLOTS
                   (INSN_ANNULLED_BRANCH_P (jump_insn)
                    && INSN_FROM_TARGET_P (pat->insn (i)))
                   ? eligible_for_annul_false (jump_insn, i - 1,
                                               pat->insn (i), flags) :
 #endif
-#ifdef ANNUL_IFTRUE_SLOTS
+#if ANNUL_IFTRUE_SLOTS
                   (INSN_ANNULLED_BRANCH_P (jump_insn)
                    && ! INSN_FROM_TARGET_P (pat->insn (i)))
                   ? eligible_for_annul_true (jump_insn, i - 1,
@@ -3852,21 +3831,24 @@ dbr_schedule (rtx_insn *first)
            }
        }
       fprintf (dump_file, "\n");
-#if defined (ANNUL_IFTRUE_SLOTS) || defined (ANNUL_IFFALSE_SLOTS)
-      fprintf (dump_file, ";; Reorg annuls: ");
-      need_comma = 0;
-      for (j = 0; j < MAX_DELAY_HISTOGRAM + 1; j++)
+
+      if (ANNUL_IFTRUE_SLOTS || ANNUL_IFFALSE_SLOTS)
        {
-         if (total_annul_slots[j])
+         fprintf (dump_file, ";; Reorg annuls: ");
+         need_comma = 0;
+         for (j = 0; j < MAX_DELAY_HISTOGRAM + 1; j++)
            {
-             if (need_comma)
-               fprintf (dump_file, ", ");
-             need_comma = 1;
-             fprintf (dump_file, "%d got %d delays", total_annul_slots[j], j);
+             if (total_annul_slots[j])
+               {
+                 if (need_comma)
+                   fprintf (dump_file, ", ");
+                 need_comma = 1;
+                 fprintf (dump_file, "%d got %d delays", total_annul_slots[j], j);
+               }
            }
+         fprintf (dump_file, "\n");
        }
-      fprintf (dump_file, "\n");
-#endif
+
       fprintf (dump_file, "\n");
     }
 
@@ -3880,15 +3862,14 @@ dbr_schedule (rtx_insn *first)
   free (uid_to_ruid);
   crtl->dbr_scheduled_p = true;
 }
-#endif /* DELAY_SLOTS */
 \f
 /* Run delay slot optimization.  */
 static unsigned int
 rest_of_handle_delay_slots (void)
 {
-#ifdef DELAY_SLOTS
-  dbr_schedule (get_insns ());
-#endif
+  if (DELAY_SLOTS)
+    dbr_schedule (get_insns ());
+
   return 0;
 }
 
@@ -3926,12 +3907,11 @@ public:
 bool
 pass_delay_slots::gate (function *)
 {
-#ifdef DELAY_SLOTS
   /* At -O0 dataflow info isn't updated after RA.  */
-  return optimize > 0 && flag_delayed_branch && !crtl->dbr_scheduled_p;
-#else
-  return 0;
-#endif
+  if (DELAY_SLOTS)
+    return optimize > 0 && flag_delayed_branch && !crtl->dbr_scheduled_p;
+
+  return false;
 }
 
 } // anon namespace
index 6d740d4233373479817fc0e21a38547215f5d56d..0083d81670159d8cc719ebd9b39d4a0e36ee1a48 100644 (file)
@@ -1317,10 +1317,8 @@ process_options (void)
   if (flag_schedule_insns || flag_schedule_insns_after_reload)
     warning (0, "instruction scheduling not supported on this target machine");
 #endif
-#ifndef DELAY_SLOTS
-  if (flag_delayed_branch)
+  if (!DELAY_SLOTS && flag_delayed_branch)
     warning (0, "this target machine does not have delayed branches");
-#endif
 
   user_label_prefix = USER_LABEL_PREFIX;
   if (flag_leading_underscore != -1)