summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrevor Saunders <tbsaunde+gcc@tbsaunde.org>2015-10-21 21:05:02 +0000
committerTrevor Saunders <tbsaunde@gcc.gnu.org>2015-10-21 21:05:02 +0000
commite90bedf52c86a7b4e2e0a1f8a5a1450725cb95b6 (patch)
tree7e4247b26f99c762d570b1e1456c1d1e1167819e
parent0a798c16c13970d020bc5b93c1aceac9ec5dd7a1 (diff)
downloadgcc-e90bedf52c86a7b4e2e0a1f8a5a1450725cb95b6.tar.gz
unconditionally compile most of the delay slot code
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
-rw-r--r--gcc/ChangeLog21
-rw-r--r--gcc/cfgrtl.c4
-rw-r--r--gcc/final.c12
-rw-r--r--gcc/genattr-common.c8
-rw-r--r--gcc/genattr.c39
-rw-r--r--gcc/genattrtab.c16
-rw-r--r--gcc/opts.c2
-rw-r--r--gcc/reorg.c82
-rw-r--r--gcc/toplev.c4
9 files changed, 83 insertions, 105 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 20f72c51b96..cdeb703dbb7 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index ef73b49201b..d2fe1e07537 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -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 ();
diff --git a/gcc/final.c b/gcc/final.c
index b604c441f52..18faa63e26d 100644
--- a/gcc/final.c
+++ b/gcc/final.c
@@ -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
/* 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
diff --git a/gcc/genattr-common.c b/gcc/genattr-common.c
index 0ff8da984dd..a51f8ebf824 100644
--- a/gcc/genattr-common.c
+++ b/gcc/genattr-common.c
@@ -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))
diff --git a/gcc/genattr.c b/gcc/genattr.c
index d31f00733d9..e45f87cbeb2 100644
--- a/gcc/genattr.c
+++ b/gcc/genattr.c
@@ -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
diff --git a/gcc/genattrtab.c b/gcc/genattrtab.c
index 932b18b1237..8d1fa6c9bbf 100644
--- a/gcc/genattrtab.c
+++ b/gcc/genattrtab.c
@@ -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);
diff --git a/gcc/opts.c b/gcc/opts.c
index 89b3e793de6..a892c8880e8 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -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 },
diff --git a/gcc/reorg.c b/gcc/reorg.c
index c51e03cf366..47b938b46d0 100644
--- a/gcc/reorg.c
+++ b/gcc/reorg.c
@@ -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
-
/* 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]++;
}
-#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
/* 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 */
/* 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
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 6d740d42333..0083d816701 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -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)