#include "fibheap.h"
#include "target.h"
#include "function.h"
+#include "tm_p.h"
#include "obstack.h"
#include "expr.h"
#include "regs.h"
the .o 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 runtime too, not only compiletime. */
+
+#ifndef HAVE_return
+#define HAVE_return 0
+#define gen_return() NULL_RTX
+#endif
+
+
/* Branch thresholds in thousandths (per mille) of the REG_BR_PROB_BASE. */
static int branch_threshold[N_ROUNDS] = {400, 200, 100, 0, 0};
{
basic_block new_bb;
- new_bb = cfg_layout_duplicate_bb (old_bb, e);
+ new_bb = duplicate_block (old_bb, e);
if (e->dest != new_bb)
abort ();
if (e->dest->rbi->visited)
last_trace = -1;
/* If we are partitioning hot/cold basic blocks, mark the cold
- traces as already connnected, to remove them from consideration
+ traces as already connected, to remove them from consideration
for connection to the hot traces. After the hot traces have all
been connected (determined by "unconnected_hot_trace_count"), we
will go back and connect the cold traces. */
}
FREE (connected);
+ FREE (cold_traces);
}
/* Return true when BB can and should be copied. CODE_MAY_GROW is true
return false;
if (!bb->pred || !bb->pred->pred_next)
return false;
- if (!cfg_layout_can_duplicate_bb_p (bb))
+ if (!can_duplicate_block_p (bb))
return false;
/* Avoid duplicating blocks which have many successors (PR/13430). */
for (cur_insn = BB_HEAD (bb); cur_insn != NEXT_INSN (BB_END (bb));
cur_insn = NEXT_INSN (cur_insn))
- if (GET_CODE (cur_insn) != NOTE
- && GET_CODE (cur_insn) != CODE_LABEL)
+ if (!NOTE_P (cur_insn)
+ && !LABEL_P (cur_insn))
{
insert_insn = cur_insn;
break;
/* If any destination of a crossing edge does not have a label, add label;
Convert any fall-through crossing edges (for blocks that do not contain
- a jump) to unconditional jumps. */
+ a jump) to unconditional jumps. */
static void
add_labels_and_missing_jumps (edge *crossing_edges, int n_crossing_edges)
if (src && (src != ENTRY_BLOCK_PTR))
{
- if (GET_CODE (BB_END (src)) != JUMP_INSN)
+ if (!JUMP_P (BB_END (src)))
/* bb just falls through. */
{
/* make sure there's only one successor */
edge succ1;
edge succ2;
edge fall_thru;
- edge cond_jump;
+ edge cond_jump = NULL;
edge e;
bool cond_jump_crosses;
int invert_worked;
&& cur_bb->rbi->next == cond_jump->dest)
{
/* Find label in fall_thru block. We've already added
- any missing labels, so there must be one. */
+ any missing labels, so there must be one. */
fall_thru_label = block_label (fall_thru->dest);
/* Check each predecessor to see if it has a label, and contains
only one executable instruction, which is an unconditional jump.
- If so, we can use it. */
+ If so, we can use it. */
- if (GET_CODE (BB_HEAD (src)) == CODE_LABEL)
+ if (LABEL_P (BB_HEAD (src)))
for (insn = BB_HEAD (src);
!INSN_P (insn) && insn != NEXT_INSN (BB_END (src));
insn = NEXT_INSN (insn))
{
if (INSN_P (insn)
&& insn == BB_END (src)
- && GET_CODE (insn) == JUMP_INSN
+ && JUMP_P (insn)
&& !any_condjump_p (insn))
{
source_bb = src;
(old_label),
BB_END (new_bb));
}
-#ifdef HAVE_return
- else if (GET_CODE (old_label) == RETURN)
+ else if (HAVE_return
+ && GET_CODE (old_label) == RETURN)
new_jump = emit_jump_insn_after (gen_return (),
BB_END (new_bb));
-#endif
else
abort ();
/* Check to see if bb ends in a crossing (unconditional) jump. At
this point, no crossing jumps should be conditional. */
- if (GET_CODE (last_insn) == JUMP_INSN
+ if (JUMP_P (last_insn)
&& succ->crossing_edge)
{
rtx label2, table;
reference of label, as target for jump. */
label = JUMP_LABEL (last_insn);
- label_addr = gen_rtx_LABEL_REF (VOIDmode, label);
+ label_addr = gen_rtx_LABEL_REF (Pmode, label);
LABEL_NUSES (label) += 1;
/* Get a register to use for the indirect jump. */
cur_insn = NEXT_INSN (cur_insn))
{
BLOCK_FOR_INSN (cur_insn) = cur_bb;
- if (GET_CODE (cur_insn) == JUMP_INSN)
+ if (JUMP_P (cur_insn))
jump_insn = cur_insn;
}
FOR_EACH_BB (bb)
for (e = bb->succ; e; e = e->succ_next)
if (e->crossing_edge
- && GET_CODE (BB_END (e->src)) == JUMP_INSN)
+ && JUMP_P (BB_END (e->src)))
REG_NOTES (BB_END (e->src)) = gen_rtx_EXPR_LIST (REG_CROSSING_JUMP,
NULL_RTX,
REG_NOTES (BB_END
add_reg_crossing_jump_notes ();
}
-/* Reorder basic blocks. The main entry point to this file. */
+/* Reorder basic blocks. The main entry point to this file. FLAGS is
+ the set of flags to pass to cfg_layout_initialize(). */
void
-reorder_basic_blocks (void)
+reorder_basic_blocks (unsigned int flags)
{
int n_traces;
int i;
timevar_push (TV_REORDER_BLOCKS);
- cfg_layout_initialize ();
+ cfg_layout_initialize (flags);
set_edge_can_fallthru_flag ();
mark_dfs_back_edges ();
crossing_edges = xcalloc (max_edges, sizeof (edge));
- cfg_layout_initialize ();
+ cfg_layout_initialize (0);
FOR_EACH_BB (cur_bb)
if (cur_bb->index >= 0