Commit c838c402 by David Malcolm Committed by David Malcolm

Use rtx_insn for more scheduler things, plus CONST_CAST_RTX_INSN

gcc/ChangeLog:
2014-09-05  David Malcolm  <dmalcolm@redhat.com>

	* sched-deps.c (sched_get_condition_with_rev_uncached): Strengthen
	param "insn" from const_rtx to const rtx_insn *.
	(sched_get_reverse_condition_uncached): Likewise.
	(sched_get_condition_with_rev): Likewise.
	(sched_has_condition_p): Likewise.
	(sched_insns_conditions_mutex_p): Likewise for both params.
	(sched_insn_is_legitimate_for_speculation_p): Likewise for param
	"insn"; convert use of CONST_CAST_RTX to CONST_CAST_RTX_INSN.
	(setup_insn_reg_uses): Move local "list" to be more tightly
	scoped, strengthening it from an rtx to an rtx_insn_list *.  Use
	its methods for clarity and type-safety.
	(sched_analyze_1): Strengthen local "pending" from rtx to
	rtx_insn_list *, and local "pending_mem" from rtx to
	rtx_expr_list *.  Use methods of each for clarity and type-safety.
	(sched_analyze_2): Likewise.
	(sched_analyze_insn): Likewise.

	* sched-int.h (sched_get_reverse_condition_uncached): Strengthen
	param from const_rtx to const rtx_insn *.
	(sched_insns_conditions_mutex_p): Likewise for both params.
	(sched_insn_is_legitimate_for_speculation_p): Likewise for first
	param.

	* system.h (CONST_CAST_RTX_INSN): New macro.

From-SVN: r214967
parent 1c9b6043
2014-09-05 David Malcolm <dmalcolm@redhat.com> 2014-09-05 David Malcolm <dmalcolm@redhat.com>
* sched-deps.c (sched_get_condition_with_rev_uncached): Strengthen
param "insn" from const_rtx to const rtx_insn *.
(sched_get_reverse_condition_uncached): Likewise.
(sched_get_condition_with_rev): Likewise.
(sched_has_condition_p): Likewise.
(sched_insns_conditions_mutex_p): Likewise for both params.
(sched_insn_is_legitimate_for_speculation_p): Likewise for param
"insn"; conver use of CONST_CAST_RTX to CONST_CAST_RTX_INSN.
(setup_insn_reg_uses): Move local "list" to be more tightly
scoped, strengthening it from an rtx to an rtx_insn_list *. Use
its methods for clarity and type-safety.
(sched_analyze_1): Strengthen local "pending" from rtx to
rtx_insn_list *, and local "pending_mem" from rtx to
rtx_expr_list *. Use methods of each for clarity and type-safety.
(sched_analyze_2): Likewise.
(sched_analyze_insn): Likewise.
* sched-int.h (sched_get_reverse_condition_uncached): Strengthen
param from const_rtx to const rtx_insn *.
(sched_insns_conditions_mutex_p): Likewise for both params.
(sched_insn_is_legitimate_for_speculation_p): Likewise for first
param.
* system.h (CONST_CAST_RTX_INSN): New macro.
2014-09-05 David Malcolm <dmalcolm@redhat.com>
* recog.c (peep2_attempt): Strengthen return type from rtx to * recog.c (peep2_attempt): Strengthen return type from rtx to
rtx_insn *. rtx_insn *.
(peep2_update_life): Likewise for params "last", "prev", removing (peep2_update_life): Likewise for params "last", "prev", removing
...@@ -496,7 +496,7 @@ static void sched_analyze_1 (struct deps_desc *, rtx, rtx_insn *); ...@@ -496,7 +496,7 @@ static void sched_analyze_1 (struct deps_desc *, rtx, rtx_insn *);
static void sched_analyze_2 (struct deps_desc *, rtx, rtx_insn *); static void sched_analyze_2 (struct deps_desc *, rtx, rtx_insn *);
static void sched_analyze_insn (struct deps_desc *, rtx, rtx_insn *); static void sched_analyze_insn (struct deps_desc *, rtx, rtx_insn *);
static bool sched_has_condition_p (const_rtx); static bool sched_has_condition_p (const rtx_insn *);
static int conditions_mutex_p (const_rtx, const_rtx, bool, bool); static int conditions_mutex_p (const_rtx, const_rtx, bool, bool);
static enum DEPS_ADJUST_RESULT maybe_add_or_update_dep_1 (dep_t, bool, static enum DEPS_ADJUST_RESULT maybe_add_or_update_dep_1 (dep_t, bool,
...@@ -528,7 +528,7 @@ deps_may_trap_p (const_rtx mem) ...@@ -528,7 +528,7 @@ deps_may_trap_p (const_rtx mem)
it is set to TRUE when the returned comparison should be reversed it is set to TRUE when the returned comparison should be reversed
to get the actual condition. */ to get the actual condition. */
static rtx static rtx
sched_get_condition_with_rev_uncached (const_rtx insn, bool *rev) sched_get_condition_with_rev_uncached (const rtx_insn *insn, bool *rev)
{ {
rtx pat = PATTERN (insn); rtx pat = PATTERN (insn);
rtx src; rtx src;
...@@ -567,7 +567,7 @@ sched_get_condition_with_rev_uncached (const_rtx insn, bool *rev) ...@@ -567,7 +567,7 @@ sched_get_condition_with_rev_uncached (const_rtx insn, bool *rev)
find such a condition. The caller should make a copy of the condition find such a condition. The caller should make a copy of the condition
before using it. */ before using it. */
rtx rtx
sched_get_reverse_condition_uncached (const_rtx insn) sched_get_reverse_condition_uncached (const rtx_insn *insn)
{ {
bool rev; bool rev;
rtx cond = sched_get_condition_with_rev_uncached (insn, &rev); rtx cond = sched_get_condition_with_rev_uncached (insn, &rev);
...@@ -587,7 +587,7 @@ sched_get_reverse_condition_uncached (const_rtx insn) ...@@ -587,7 +587,7 @@ sched_get_reverse_condition_uncached (const_rtx insn)
We only do actual work the first time we come here for an insn; the We only do actual work the first time we come here for an insn; the
results are cached in INSN_CACHED_COND and INSN_REVERSE_COND. */ results are cached in INSN_CACHED_COND and INSN_REVERSE_COND. */
static rtx static rtx
sched_get_condition_with_rev (const_rtx insn, bool *rev) sched_get_condition_with_rev (const rtx_insn *insn, bool *rev)
{ {
bool tmp; bool tmp;
...@@ -620,7 +620,7 @@ sched_get_condition_with_rev (const_rtx insn, bool *rev) ...@@ -620,7 +620,7 @@ sched_get_condition_with_rev (const_rtx insn, bool *rev)
/* True when we can find a condition under which INSN is executed. */ /* True when we can find a condition under which INSN is executed. */
static bool static bool
sched_has_condition_p (const_rtx insn) sched_has_condition_p (const rtx_insn *insn)
{ {
return !! sched_get_condition_with_rev (insn, NULL); return !! sched_get_condition_with_rev (insn, NULL);
} }
...@@ -646,7 +646,7 @@ conditions_mutex_p (const_rtx cond1, const_rtx cond2, bool rev1, bool rev2) ...@@ -646,7 +646,7 @@ conditions_mutex_p (const_rtx cond1, const_rtx cond2, bool rev1, bool rev2)
/* Return true if insn1 and insn2 can never depend on one another because /* Return true if insn1 and insn2 can never depend on one another because
the conditions under which they are executed are mutually exclusive. */ the conditions under which they are executed are mutually exclusive. */
bool bool
sched_insns_conditions_mutex_p (const_rtx insn1, const_rtx insn2) sched_insns_conditions_mutex_p (const rtx_insn *insn1, const rtx_insn *insn2)
{ {
rtx cond1, cond2; rtx cond1, cond2;
bool rev1 = false, rev2 = false; bool rev1 = false, rev2 = false;
...@@ -673,7 +673,7 @@ sched_insns_conditions_mutex_p (const_rtx insn1, const_rtx insn2) ...@@ -673,7 +673,7 @@ sched_insns_conditions_mutex_p (const_rtx insn1, const_rtx insn2)
/* Return true if INSN can potentially be speculated with type DS. */ /* Return true if INSN can potentially be speculated with type DS. */
bool bool
sched_insn_is_legitimate_for_speculation_p (const_rtx insn, ds_t ds) sched_insn_is_legitimate_for_speculation_p (const rtx_insn *insn, ds_t ds)
{ {
if (HAS_INTERNAL_DEP (insn)) if (HAS_INTERNAL_DEP (insn))
return false; return false;
...@@ -684,7 +684,7 @@ sched_insn_is_legitimate_for_speculation_p (const_rtx insn, ds_t ds) ...@@ -684,7 +684,7 @@ sched_insn_is_legitimate_for_speculation_p (const_rtx insn, ds_t ds)
if (SCHED_GROUP_P (insn)) if (SCHED_GROUP_P (insn))
return false; return false;
if (IS_SPECULATION_CHECK_P (CONST_CAST_RTX (insn))) if (IS_SPECULATION_CHECK_P (CONST_CAST_RTX_INSN (insn)))
return false; return false;
if (side_effects_p (PATTERN (insn))) if (side_effects_p (PATTERN (insn)))
...@@ -1970,7 +1970,6 @@ setup_insn_reg_uses (struct deps_desc *deps, rtx_insn *insn) ...@@ -1970,7 +1970,6 @@ setup_insn_reg_uses (struct deps_desc *deps, rtx_insn *insn)
{ {
unsigned i; unsigned i;
reg_set_iterator rsi; reg_set_iterator rsi;
rtx list;
struct reg_use_data *use, *use2, *next; struct reg_use_data *use, *use2, *next;
struct deps_reg *reg_last; struct deps_reg *reg_last;
...@@ -1991,9 +1990,9 @@ setup_insn_reg_uses (struct deps_desc *deps, rtx_insn *insn) ...@@ -1991,9 +1990,9 @@ setup_insn_reg_uses (struct deps_desc *deps, rtx_insn *insn)
reg_last = &deps->reg_last[i]; reg_last = &deps->reg_last[i];
/* Create the cycle list of uses. */ /* Create the cycle list of uses. */
for (list = reg_last->uses; list; list = XEXP (list, 1)) for (rtx_insn_list *list = reg_last->uses; list; list = list->next ())
{ {
use2 = create_insn_reg_use (i, as_a <rtx_insn *> (XEXP (list, 0))); use2 = create_insn_reg_use (i, list->insn ());
next = use->next_regno_use; next = use->next_regno_use;
use->next_regno_use = use2; use->next_regno_use = use2;
use2->next_regno_use = next; use2->next_regno_use = next;
...@@ -2506,33 +2505,34 @@ sched_analyze_1 (struct deps_desc *deps, rtx x, rtx_insn *insn) ...@@ -2506,33 +2505,34 @@ sched_analyze_1 (struct deps_desc *deps, rtx x, rtx_insn *insn)
} }
else else
{ {
rtx pending, pending_mem; rtx_insn_list *pending;
rtx_expr_list *pending_mem;
pending = deps->pending_read_insns; pending = deps->pending_read_insns;
pending_mem = deps->pending_read_mems; pending_mem = deps->pending_read_mems;
while (pending) while (pending)
{ {
if (anti_dependence (XEXP (pending_mem, 0), t) if (anti_dependence (pending_mem->element (), t)
&& ! sched_insns_conditions_mutex_p (insn, XEXP (pending, 0))) && ! sched_insns_conditions_mutex_p (insn, pending->insn ()))
note_mem_dep (t, XEXP (pending_mem, 0), as_a <rtx_insn *> (XEXP (pending, 0)), note_mem_dep (t, pending_mem->element (), pending->insn (),
DEP_ANTI); DEP_ANTI);
pending = XEXP (pending, 1); pending = pending->next ();
pending_mem = XEXP (pending_mem, 1); pending_mem = pending_mem->next ();
} }
pending = deps->pending_write_insns; pending = deps->pending_write_insns;
pending_mem = deps->pending_write_mems; pending_mem = deps->pending_write_mems;
while (pending) while (pending)
{ {
if (output_dependence (XEXP (pending_mem, 0), t) if (output_dependence (pending_mem->element (), t)
&& ! sched_insns_conditions_mutex_p (insn, XEXP (pending, 0))) && ! sched_insns_conditions_mutex_p (insn, pending->insn ()))
note_mem_dep (t, XEXP (pending_mem, 0), note_mem_dep (t, pending_mem->element (),
as_a <rtx_insn *> (XEXP (pending, 0)), pending->insn (),
DEP_OUTPUT); DEP_OUTPUT);
pending = XEXP (pending, 1); pending = pending->next ();
pending_mem = XEXP (pending_mem, 1); pending_mem = pending_mem-> next ();
} }
add_dependence_list (insn, deps->last_pending_memory_flush, 1, add_dependence_list (insn, deps->last_pending_memory_flush, 1,
...@@ -2635,7 +2635,8 @@ sched_analyze_2 (struct deps_desc *deps, rtx x, rtx_insn *insn) ...@@ -2635,7 +2635,8 @@ sched_analyze_2 (struct deps_desc *deps, rtx x, rtx_insn *insn)
{ {
/* Reading memory. */ /* Reading memory. */
rtx u; rtx u;
rtx pending, pending_mem; rtx_insn_list *pending;
rtx_expr_list *pending_mem;
rtx t = x; rtx t = x;
if (sched_deps_info->use_cselib) if (sched_deps_info->use_cselib)
...@@ -2657,31 +2658,31 @@ sched_analyze_2 (struct deps_desc *deps, rtx x, rtx_insn *insn) ...@@ -2657,31 +2658,31 @@ sched_analyze_2 (struct deps_desc *deps, rtx x, rtx_insn *insn)
pending_mem = deps->pending_read_mems; pending_mem = deps->pending_read_mems;
while (pending) while (pending)
{ {
if (read_dependence (XEXP (pending_mem, 0), t) if (read_dependence (pending_mem->element (), t)
&& ! sched_insns_conditions_mutex_p (insn, && ! sched_insns_conditions_mutex_p (insn,
XEXP (pending, 0))) pending->insn ()))
note_mem_dep (t, XEXP (pending_mem, 0), note_mem_dep (t, pending_mem->element (),
as_a <rtx_insn *> (XEXP (pending, 0)), pending->insn (),
DEP_ANTI); DEP_ANTI);
pending = XEXP (pending, 1); pending = pending->next ();
pending_mem = XEXP (pending_mem, 1); pending_mem = pending_mem->next ();
} }
pending = deps->pending_write_insns; pending = deps->pending_write_insns;
pending_mem = deps->pending_write_mems; pending_mem = deps->pending_write_mems;
while (pending) while (pending)
{ {
if (true_dependence (XEXP (pending_mem, 0), VOIDmode, t) if (true_dependence (pending_mem->element (), VOIDmode, t)
&& ! sched_insns_conditions_mutex_p (insn, && ! sched_insns_conditions_mutex_p (insn,
XEXP (pending, 0))) pending->insn ()))
note_mem_dep (t, XEXP (pending_mem, 0), note_mem_dep (t, pending_mem->element (),
as_a <rtx_insn *> (XEXP (pending, 0)), pending->insn (),
sched_deps_info->generate_spec_deps sched_deps_info->generate_spec_deps
? BEGIN_DATA | DEP_TRUE : DEP_TRUE); ? BEGIN_DATA | DEP_TRUE : DEP_TRUE);
pending = XEXP (pending, 1); pending = pending->next ();
pending_mem = XEXP (pending_mem, 1); pending_mem = pending_mem->next ();
} }
for (u = deps->last_pending_memory_flush; u; u = XEXP (u, 1)) for (u = deps->last_pending_memory_flush; u; u = XEXP (u, 1))
...@@ -2998,7 +2999,8 @@ sched_analyze_insn (struct deps_desc *deps, rtx x, rtx_insn *insn) ...@@ -2998,7 +2999,8 @@ sched_analyze_insn (struct deps_desc *deps, rtx x, rtx_insn *insn)
reg_pending_barrier = MOVE_BARRIER; reg_pending_barrier = MOVE_BARRIER;
else else
{ {
rtx pending, pending_mem; rtx_insn_list *pending;
rtx_expr_list *pending_mem;
if (sched_deps_info->compute_jump_reg_dependencies) if (sched_deps_info->compute_jump_reg_dependencies)
{ {
...@@ -3026,23 +3028,23 @@ sched_analyze_insn (struct deps_desc *deps, rtx x, rtx_insn *insn) ...@@ -3026,23 +3028,23 @@ sched_analyze_insn (struct deps_desc *deps, rtx x, rtx_insn *insn)
pending_mem = deps->pending_write_mems; pending_mem = deps->pending_write_mems;
while (pending) while (pending)
{ {
if (! sched_insns_conditions_mutex_p (insn, XEXP (pending, 0))) if (! sched_insns_conditions_mutex_p (insn, pending->insn ()))
add_dependence (insn, as_a <rtx_insn *> (XEXP (pending, 0)), add_dependence (insn, pending->insn (),
REG_DEP_OUTPUT); REG_DEP_OUTPUT);
pending = XEXP (pending, 1); pending = pending->next ();
pending_mem = XEXP (pending_mem, 1); pending_mem = pending_mem->next ();
} }
pending = deps->pending_read_insns; pending = deps->pending_read_insns;
pending_mem = deps->pending_read_mems; pending_mem = deps->pending_read_mems;
while (pending) while (pending)
{ {
if (MEM_VOLATILE_P (XEXP (pending_mem, 0)) if (MEM_VOLATILE_P (pending_mem->element ())
&& ! sched_insns_conditions_mutex_p (insn, XEXP (pending, 0))) && ! sched_insns_conditions_mutex_p (insn, pending->insn ()))
add_dependence (insn, as_a <rtx_insn *> (XEXP (pending, 0)), add_dependence (insn, pending->insn (),
REG_DEP_OUTPUT); REG_DEP_OUTPUT);
pending = XEXP (pending, 1); pending = pending->next ();
pending_mem = XEXP (pending_mem, 1); pending_mem = pending_mem->next ();
} }
add_dependence_list (insn, deps->last_pending_memory_flush, 1, add_dependence_list (insn, deps->last_pending_memory_flush, 1,
......
...@@ -1291,9 +1291,10 @@ extern struct sched_deps_info_def *sched_deps_info; ...@@ -1291,9 +1291,10 @@ extern struct sched_deps_info_def *sched_deps_info;
/* Functions in sched-deps.c. */ /* Functions in sched-deps.c. */
extern rtx sched_get_reverse_condition_uncached (const_rtx); extern rtx sched_get_reverse_condition_uncached (const rtx_insn *);
extern bool sched_insns_conditions_mutex_p (const_rtx, const_rtx); extern bool sched_insns_conditions_mutex_p (const rtx_insn *,
extern bool sched_insn_is_legitimate_for_speculation_p (const_rtx, ds_t); const rtx_insn *);
extern bool sched_insn_is_legitimate_for_speculation_p (const rtx_insn *, ds_t);
extern void add_dependence (rtx_insn *, rtx_insn *, enum reg_note); extern void add_dependence (rtx_insn *, rtx_insn *, enum reg_note);
extern void sched_analyze (struct deps_desc *, rtx_insn *, rtx_insn *); extern void sched_analyze (struct deps_desc *, rtx_insn *, rtx_insn *);
extern void init_deps (struct deps_desc *, bool); extern void init_deps (struct deps_desc *, bool);
......
...@@ -1034,6 +1034,7 @@ helper_const_non_const_cast (const char *p) ...@@ -1034,6 +1034,7 @@ helper_const_non_const_cast (const char *p)
#define CONST_CAST(TYPE,X) CONST_CAST2 (TYPE, const TYPE, (X)) #define CONST_CAST(TYPE,X) CONST_CAST2 (TYPE, const TYPE, (X))
#define CONST_CAST_TREE(X) CONST_CAST (union tree_node *, (X)) #define CONST_CAST_TREE(X) CONST_CAST (union tree_node *, (X))
#define CONST_CAST_RTX(X) CONST_CAST (struct rtx_def *, (X)) #define CONST_CAST_RTX(X) CONST_CAST (struct rtx_def *, (X))
#define CONST_CAST_RTX_INSN(X) CONST_CAST (struct rtx_insn *, (X))
#define CONST_CAST_BB(X) CONST_CAST (struct basic_block_def *, (X)) #define CONST_CAST_BB(X) CONST_CAST (struct basic_block_def *, (X))
#define CONST_CAST_GIMPLE(X) CONST_CAST (struct gimple_statement_base *, (X)) #define CONST_CAST_GIMPLE(X) CONST_CAST (struct gimple_statement_base *, (X))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment