/* Instruction scheduling pass. Selective scheduler and pipeliner.
- Copyright (C) 2006-2014 Free Software Foundation, Inc.
+ Copyright (C) 2006-2016 Free Software Foundation, Inc.
This file is part of GCC.
#include "config.h"
#include "system.h"
#include "coretypes.h"
-#include "tm.h"
-#include "diagnostic-core.h"
+#include "backend.h"
+#include "cfghooks.h"
+#include "tree.h"
#include "rtl.h"
+#include "df.h"
#include "tm_p.h"
-#include "hard-reg-set.h"
-#include "regs.h"
-#include "function.h"
-#include "flags.h"
+#include "cfgrtl.h"
+#include "cfganal.h"
+#include "cfgbuild.h"
#include "insn-config.h"
#include "insn-attr.h"
-#include "except.h"
#include "recog.h"
#include "params.h"
#include "target.h"
#include "sched-int.h"
-#include "ggc.h"
-#include "tree.h"
-#include "vec.h"
-#include "langhooks.h"
-#include "rtlhooks-def.h"
#include "emit-rtl.h" /* FIXME: Can go away once crtl is moved to rtl.h. */
#ifdef INSN_SCHEDULING
+#include "regset.h"
+#include "cfgloop.h"
#include "sel-sched-ir.h"
/* We don't have to use it except for sel_print_insn. */
#include "sel-sched-dump.h"
sel_region_bb_info = vNULL;
/* A pool for allocating all lists. */
-alloc_pool sched_lists_pool;
+object_allocator<_list_node> sched_lists_pool ("sel-sched-lists");
/* This contains information about successors for compute_av_set. */
struct succs_info current_succs;
regset_pool.v[regset_pool.n++] = rs;
}
-#ifdef ENABLE_CHECKING
/* This is used as a qsort callback for sorting regset pool stacks.
X and XX are addresses of two regsets. They are never equal. */
static int
return -1;
gcc_unreachable ();
}
-#endif
-/* Free the regset pool possibly checking for memory leaks. */
+/* Free the regset pool possibly checking for memory leaks. */
void
free_regset_pool (void)
{
-#ifdef ENABLE_CHECKING
- {
- regset *v = regset_pool.v;
- int i = 0;
- int n = regset_pool.n;
+ if (flag_checking)
+ {
+ regset *v = regset_pool.v;
+ int i = 0;
+ int n = regset_pool.n;
- regset *vv = regset_pool.vv;
- int ii = 0;
- int nn = regset_pool.nn;
+ regset *vv = regset_pool.vv;
+ int ii = 0;
+ int nn = regset_pool.nn;
- int diff = 0;
+ int diff = 0;
- gcc_assert (n <= nn);
+ gcc_assert (n <= nn);
- /* Sort both vectors so it will be possible to compare them. */
- qsort (v, n, sizeof (*v), cmp_v_in_regset_pool);
- qsort (vv, nn, sizeof (*vv), cmp_v_in_regset_pool);
+ /* Sort both vectors so it will be possible to compare them. */
+ qsort (v, n, sizeof (*v), cmp_v_in_regset_pool);
+ qsort (vv, nn, sizeof (*vv), cmp_v_in_regset_pool);
- while (ii < nn)
- {
- if (v[i] == vv[ii])
- i++;
- else
- /* VV[II] was lost. */
- diff++;
+ while (ii < nn)
+ {
+ if (v[i] == vv[ii])
+ i++;
+ else
+ /* VV[II] was lost. */
+ diff++;
- ii++;
- }
+ ii++;
+ }
- gcc_assert (diff == regset_pool.diff);
- }
-#endif
+ gcc_assert (diff == regset_pool.diff);
+ }
/* If not true - we have a memory leak. */
gcc_assert (regset_pool.diff == 0);
sel_remove_insn (nop, false, full_tidying);
/* We'll recycle this nop. */
- INSN_DELETED_P (nop) = 0;
+ nop->set_undeleted ();
if (nop_pool.n == nop_pool.s)
nop_pool.v = XRESIZEVEC (rtx_insn *, nop_pool.v,
to support ia64 speculation. When changes are needed, new rtx X and new mode
NMODE are written, and the callback returns true. */
static int
-hash_with_unspec_callback (const_rtx x, enum machine_mode mode ATTRIBUTE_UNUSED,
- rtx *nx, enum machine_mode* nmode)
+hash_with_unspec_callback (const_rtx x, machine_mode mode ATTRIBUTE_UNUSED,
+ rtx *nx, machine_mode* nmode)
{
if (GET_CODE (x) == UNSPEC
&& targetm.sched.skip_rtx_p
/* The insn may come from the transformation cache, which may hold already
deleted insns, so mark it as not deleted. */
- INSN_DELETED_P (insn) = 0;
+ insn->set_undeleted ();
add_insn_after (insn, after, BLOCK_FOR_INSN (insn));
/* Extracts machine mode MODE and destination location DST_LOC
for given INSN. */
void
-get_dest_and_mode (rtx insn, rtx *dst_loc, enum machine_mode *mode)
+get_dest_and_mode (rtx insn, rtx *dst_loc, machine_mode *mode)
{
rtx pat = PATTERN (insn);
return sel_bb_head_p (insn) && sel_bb_end_p (insn);
}
-#ifdef ENABLE_CHECKING
/* Check that the region we're scheduling still has at most one
backedge. */
static void
gcc_assert (n <= 1);
}
}
-#endif
\f
/* Functions to work with control flow. */
sel_recompute_toporder ();
}
-#ifdef ENABLE_CHECKING
- verify_backedges ();
- verify_dominators (CDI_DOMINATORS);
-#endif
+ /* TODO: use separate flag for CFG checking. */
+ if (flag_checking)
+ {
+ verify_backedges ();
+ verify_dominators (CDI_DOMINATORS);
+ }
return changed;
}
free_av_set (bb);
}
-/* Exchange lv sets of TO and FROM. */
-static void
-exchange_lv_sets (basic_block to, basic_block from)
-{
- {
- regset to_lv_set = BB_LV_SET (to);
-
- BB_LV_SET (to) = BB_LV_SET (from);
- BB_LV_SET (from) = to_lv_set;
- }
-
- {
- bool to_lv_set_valid_p = BB_LV_SET_VALID_P (to);
-
- BB_LV_SET_VALID_P (to) = BB_LV_SET_VALID_P (from);
- BB_LV_SET_VALID_P (from) = to_lv_set_valid_p;
- }
-}
-
-
-/* Exchange av sets of TO and FROM. */
-static void
-exchange_av_sets (basic_block to, basic_block from)
-{
- {
- av_set_t to_av_set = BB_AV_SET (to);
-
- BB_AV_SET (to) = BB_AV_SET (from);
- BB_AV_SET (from) = to_av_set;
- }
-
- {
- int to_av_level = BB_AV_LEVEL (to);
-
- BB_AV_LEVEL (to) = BB_AV_LEVEL (from);
- BB_AV_LEVEL (from) = to_av_level;
- }
-}
-
/* Exchange data sets of TO and FROM. */
void
exchange_data_sets (basic_block to, basic_block from)
{
- exchange_lv_sets (to, from);
- exchange_av_sets (to, from);
+ /* Exchange lv sets of TO and FROM. */
+ std::swap (BB_LV_SET (from), BB_LV_SET (to));
+ std::swap (BB_LV_SET_VALID_P (from), BB_LV_SET_VALID_P (to));
+
+ /* Exchange av sets of TO and FROM. */
+ std::swap (BB_AV_SET (from), BB_AV_SET (to));
+ std::swap (BB_AV_LEVEL (from), BB_AV_LEVEL (to));
}
/* Copy data sets of FROM to TO. */
}
else
{
- insn_t note;
-
- note = bb_note (bb);
+ rtx_note *note = bb_note (bb);
head = next_nonnote_insn (note);
if (head && (BARRIER_P (head) || BLOCK_FOR_INSN (head) != bb))
static void
return_bb_to_pool (basic_block bb)
{
- rtx note = bb_note (bb);
+ rtx_note *note = bb_note (bb);
gcc_assert (NOTE_BASIC_BLOCK (note) == bb
&& bb->aux == NULL);
succs_info_pool.size = succs_size;
succs_info_pool.top = -1;
succs_info_pool.max_top = -1;
-
- sched_lists_pool = create_alloc_pool ("sel-sched-lists",
- sizeof (struct _list_node), 500);
}
/* Free the pools. */
{
int i;
- free_alloc_pool (sched_lists_pool);
+ sched_lists_pool.release ();
gcc_assert (succs_info_pool.top == -1);
for (i = 0; i <= succs_info_pool.max_top; i++)
{