summaryrefslogtreecommitdiff
path: root/gcc/bb-reorder.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/bb-reorder.c')
-rw-r--r--gcc/bb-reorder.c105
1 files changed, 40 insertions, 65 deletions
diff --git a/gcc/bb-reorder.c b/gcc/bb-reorder.c
index c2a3be3255a..e443d59dacc 100644
--- a/gcc/bb-reorder.c
+++ b/gcc/bb-reorder.c
@@ -81,30 +81,17 @@
#include "config.h"
#include "system.h"
#include "coretypes.h"
-#include "tm.h"
-#include "hash-set.h"
-#include "machmode.h"
-#include "vec.h"
-#include "double-int.h"
-#include "input.h"
-#include "alias.h"
-#include "symtab.h"
-#include "wide-int.h"
-#include "inchash.h"
+#include "backend.h"
+#include "cfghooks.h"
#include "tree.h"
#include "rtl.h"
+#include "df.h"
+#include "alias.h"
#include "regs.h"
#include "flags.h"
#include "output.h"
#include "target.h"
-#include "hashtab.h"
-#include "hard-reg-set.h"
-#include "function.h"
#include "tm_p.h"
-#include "obstack.h"
-#include "statistics.h"
-#include "real.h"
-#include "fixed-value.h"
#include "insn-config.h"
#include "expmed.h"
#include "dojump.h"
@@ -119,20 +106,11 @@
#include "diagnostic-core.h"
#include "toplev.h" /* user_defined_section_attribute */
#include "tree-pass.h"
-#include "dominance.h"
-#include "cfg.h"
#include "cfgrtl.h"
#include "cfganal.h"
#include "cfgbuild.h"
#include "cfgcleanup.h"
-#include "predict.h"
-#include "basic-block.h"
-#include "df.h"
#include "bb-reorder.h"
-#include "hash-map.h"
-#include "is-a.h"
-#include "plugin-api.h"
-#include "ipa-ref.h"
#include "cgraph.h"
#include "except.h"
#include "fibonacci_heap.h"
@@ -142,15 +120,6 @@
the object file there will be an extra round. */
#define N_ROUNDS 5
-/* Stubs in case we don't have a return insn.
- We have to check at run time too, not only compile time. */
-
-#ifndef HAVE_return
-#define HAVE_return 0
-#define gen_return() NULL_RTX
-#endif
-
-
struct target_bb_reorder default_target_bb_reorder;
#if SWITCHABLE_TARGET
struct target_bb_reorder *this_target_bb_reorder = &default_target_bb_reorder;
@@ -1405,12 +1374,11 @@ copy_bb_p (const_basic_block bb, int code_may_grow)
int
get_uncond_jump_length (void)
{
- rtx_insn *label, *jump;
int length;
start_sequence ();
- label = emit_label (gen_label_rtx ());
- jump = emit_jump_insn (gen_jump (label));
+ rtx_code_label *label = emit_label (gen_label_rtx ());
+ rtx_insn *jump = emit_jump_insn (targetm.gen_jump (label));
length = get_attr_min_length (jump);
end_sequence ();
@@ -1426,8 +1394,7 @@ fix_up_crossing_landing_pad (eh_landing_pad old_lp, basic_block old_bb)
{
eh_landing_pad new_lp;
basic_block new_bb, last_bb, post_bb;
- rtx_insn *new_label, *jump;
- rtx post_label;
+ rtx_insn *jump;
unsigned new_partition;
edge_iterator ei;
edge e;
@@ -1439,14 +1406,14 @@ fix_up_crossing_landing_pad (eh_landing_pad old_lp, basic_block old_bb)
LABEL_PRESERVE_P (new_lp->landing_pad) = 1;
/* Put appropriate instructions in new bb. */
- new_label = emit_label (new_lp->landing_pad);
+ rtx_code_label *new_label = emit_label (new_lp->landing_pad);
expand_dw2_landing_pad_for_region (old_lp->region);
post_bb = BLOCK_FOR_INSN (old_lp->landing_pad);
post_bb = single_succ (post_bb);
- post_label = block_label (post_bb);
- jump = emit_jump_insn (gen_jump (post_label));
+ rtx_code_label *post_label = block_label (post_bb);
+ jump = emit_jump_insn (targetm.gen_jump (post_label));
JUMP_LABEL (jump) = post_label;
/* Create new basic block to be dest for lp. */
@@ -1745,9 +1712,11 @@ set_edge_can_fallthru_flag (void)
continue;
if (!any_condjump_p (BB_END (bb)))
continue;
- if (!invert_jump (BB_END (bb), JUMP_LABEL (BB_END (bb)), 0))
+
+ rtx_jump_insn *bb_end_jump = as_a <rtx_jump_insn *> (BB_END (bb));
+ if (!invert_jump (bb_end_jump, JUMP_LABEL (bb_end_jump), 0))
continue;
- invert_jump (BB_END (bb), JUMP_LABEL (BB_END (bb)), 0);
+ invert_jump (bb_end_jump, JUMP_LABEL (bb_end_jump), 0);
EDGE_SUCC (bb, 0)->flags |= EDGE_CAN_FALLTHRU;
EDGE_SUCC (bb, 1)->flags |= EDGE_CAN_FALLTHRU;
}
@@ -1766,14 +1735,13 @@ add_labels_and_missing_jumps (vec<edge> crossing_edges)
{
basic_block src = e->src;
basic_block dest = e->dest;
- rtx label;
- rtx_insn *new_jump;
+ rtx_jump_insn *new_jump;
if (dest == EXIT_BLOCK_PTR_FOR_FN (cfun))
continue;
/* Make sure dest has a label. */
- label = block_label (dest);
+ rtx_code_label *label = block_label (dest);
/* Nothing to do for non-fallthru edges. */
if (src == ENTRY_BLOCK_PTR_FOR_FN (cfun))
@@ -1791,7 +1759,7 @@ add_labels_and_missing_jumps (vec<edge> crossing_edges)
/* Make sure there's only one successor. */
gcc_assert (single_succ_p (src));
- new_jump = emit_jump_insn_after (gen_jump (label), BB_END (src));
+ new_jump = emit_jump_insn_after (targetm.gen_jump (label), BB_END (src));
BB_END (src) = new_jump;
JUMP_LABEL (new_jump) = label;
LABEL_NUSES (label) += 1;
@@ -1821,11 +1789,10 @@ fix_up_fall_thru_edges (void)
edge succ2;
edge fall_thru;
edge cond_jump = NULL;
- edge e;
bool cond_jump_crosses;
int invert_worked;
rtx_insn *old_jump;
- rtx fall_thru_label;
+ rtx_code_label *fall_thru_label;
FOR_EACH_BB_FN (cur_bb, cfun)
{
@@ -1902,17 +1869,21 @@ fix_up_fall_thru_edges (void)
fall_thru_label = block_label (fall_thru->dest);
- if (old_jump && JUMP_P (old_jump) && fall_thru_label)
- invert_worked = invert_jump (old_jump,
- fall_thru_label,0);
+ if (old_jump && fall_thru_label)
+ {
+ rtx_jump_insn *old_jump_insn =
+ dyn_cast <rtx_jump_insn *> (old_jump);
+ if (old_jump_insn)
+ invert_worked = invert_jump (old_jump_insn,
+ fall_thru_label, 0);
+ }
+
if (invert_worked)
{
fall_thru->flags &= ~EDGE_FALLTHRU;
cond_jump->flags |= EDGE_FALLTHRU;
update_br_prob_note (cur_bb);
- e = fall_thru;
- fall_thru = cond_jump;
- cond_jump = e;
+ std::swap (fall_thru, cond_jump);
cond_jump->flags |= EDGE_CROSSING;
fall_thru->flags &= ~EDGE_CROSSING;
}
@@ -2021,10 +1992,9 @@ fix_crossing_conditional_branches (void)
edge succ2;
edge crossing_edge;
edge new_edge;
- rtx_insn *old_jump;
rtx set_src;
rtx old_label = NULL_RTX;
- rtx new_label;
+ rtx_code_label *new_label;
FOR_EACH_BB_FN (cur_bb, cfun)
{
@@ -2049,7 +2019,7 @@ fix_crossing_conditional_branches (void)
if (crossing_edge)
{
- old_jump = BB_END (cur_bb);
+ rtx_insn *old_jump = BB_END (cur_bb);
/* Check to make sure the jump instruction is a
conditional jump. */
@@ -2072,6 +2042,9 @@ fix_crossing_conditional_branches (void)
if (set_src && (GET_CODE (set_src) == IF_THEN_ELSE))
{
+ rtx_jump_insn *old_jump_insn =
+ as_a <rtx_jump_insn *> (old_jump);
+
if (GET_CODE (XEXP (set_src, 1)) == PC)
old_label = XEXP (set_src, 2);
else if (GET_CODE (XEXP (set_src, 2)) == PC)
@@ -2088,7 +2061,8 @@ fix_crossing_conditional_branches (void)
else
{
basic_block last_bb;
- rtx_insn *new_jump;
+ rtx_code_label *old_jump_target;
+ rtx_jump_insn *new_jump;
/* Create new basic block to be dest for
conditional jump. */
@@ -2099,9 +2073,10 @@ fix_crossing_conditional_branches (void)
emit_label (new_label);
gcc_assert (GET_CODE (old_label) == LABEL_REF);
- old_label = JUMP_LABEL (old_jump);
- new_jump = emit_jump_insn (gen_jump (old_label));
- JUMP_LABEL (new_jump) = old_label;
+ old_jump_target = old_jump_insn->jump_target ();
+ new_jump = as_a <rtx_jump_insn *>
+ (emit_jump_insn (targetm.gen_jump (old_jump_target)));
+ new_jump->set_jump_target (old_jump_target);
last_bb = EXIT_BLOCK_PTR_FOR_FN (cfun)->prev_bb;
new_bb = create_basic_block (new_label, new_jump, last_bb);
@@ -2117,7 +2092,7 @@ fix_crossing_conditional_branches (void)
/* Make old jump branch to new bb. */
- redirect_jump (old_jump, new_label, 0);
+ redirect_jump (old_jump_insn, new_label, 0);
/* Remove crossing_edge as predecessor of 'dest'. */