From: David Malcolm <dmalcolm@redhat.com>
To: gcc-patches@gcc.gnu.org
Cc: David Malcolm <dmalcolm@redhat.com>
Subject: [PATCH 07/10] Use rtx_insn for more scheduler things, plus CONST_CAST_RTX_INSN
Date: Fri, 05 Sep 2014 01:47:00 -0000 [thread overview]
Message-ID: <1409881927-61672-8-git-send-email-dmalcolm@redhat.com> (raw)
In-Reply-To: <1409881927-61672-1-git-send-email-dmalcolm@redhat.com>
gcc/
* 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.
---
gcc/sched-deps.c | 94 +++++++++++++++++++++++++++++---------------------------
gcc/sched-int.h | 7 +++--
gcc/system.h | 1 +
3 files changed, 53 insertions(+), 49 deletions(-)
diff --git a/gcc/sched-deps.c b/gcc/sched-deps.c
index 455ed19..cceff6d 100644
--- a/gcc/sched-deps.c
+++ b/gcc/sched-deps.c
@@ -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_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 enum DEPS_ADJUST_RESULT maybe_add_or_update_dep_1 (dep_t, bool,
@@ -528,7 +528,7 @@ deps_may_trap_p (const_rtx mem)
it is set to TRUE when the returned comparison should be reversed
to get the actual condition. */
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 src;
@@ -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
before using it. */
rtx
-sched_get_reverse_condition_uncached (const_rtx insn)
+sched_get_reverse_condition_uncached (const rtx_insn *insn)
{
bool rev;
rtx cond = sched_get_condition_with_rev_uncached (insn, &rev);
@@ -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
results are cached in INSN_CACHED_COND and INSN_REVERSE_COND. */
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;
@@ -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. */
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);
}
@@ -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
the conditions under which they are executed are mutually exclusive. */
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;
bool rev1 = false, rev2 = false;
@@ -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. */
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))
return false;
@@ -684,7 +684,7 @@ sched_insn_is_legitimate_for_speculation_p (const_rtx insn, ds_t ds)
if (SCHED_GROUP_P (insn))
return false;
- if (IS_SPECULATION_CHECK_P (CONST_CAST_RTX (insn)))
+ if (IS_SPECULATION_CHECK_P (CONST_CAST_RTX_INSN (insn)))
return false;
if (side_effects_p (PATTERN (insn)))
@@ -1970,7 +1970,6 @@ setup_insn_reg_uses (struct deps_desc *deps, rtx_insn *insn)
{
unsigned i;
reg_set_iterator rsi;
- rtx list;
struct reg_use_data *use, *use2, *next;
struct deps_reg *reg_last;
@@ -1991,9 +1990,9 @@ setup_insn_reg_uses (struct deps_desc *deps, rtx_insn *insn)
reg_last = &deps->reg_last[i];
/* 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;
use->next_regno_use = use2;
use2->next_regno_use = next;
@@ -2506,33 +2505,34 @@ sched_analyze_1 (struct deps_desc *deps, rtx x, rtx_insn *insn)
}
else
{
- rtx pending, pending_mem;
+ rtx_insn_list *pending;
+ rtx_expr_list *pending_mem;
pending = deps->pending_read_insns;
pending_mem = deps->pending_read_mems;
while (pending)
{
- if (anti_dependence (XEXP (pending_mem, 0), t)
- && ! sched_insns_conditions_mutex_p (insn, XEXP (pending, 0)))
- note_mem_dep (t, XEXP (pending_mem, 0), as_a <rtx_insn *> (XEXP (pending, 0)),
+ if (anti_dependence (pending_mem->element (), t)
+ && ! sched_insns_conditions_mutex_p (insn, pending->insn ()))
+ note_mem_dep (t, pending_mem->element (), pending->insn (),
DEP_ANTI);
- pending = XEXP (pending, 1);
- pending_mem = XEXP (pending_mem, 1);
+ pending = pending->next ();
+ pending_mem = pending_mem->next ();
}
pending = deps->pending_write_insns;
pending_mem = deps->pending_write_mems;
while (pending)
{
- if (output_dependence (XEXP (pending_mem, 0), t)
- && ! sched_insns_conditions_mutex_p (insn, XEXP (pending, 0)))
- note_mem_dep (t, XEXP (pending_mem, 0),
- as_a <rtx_insn *> (XEXP (pending, 0)),
+ if (output_dependence (pending_mem->element (), t)
+ && ! sched_insns_conditions_mutex_p (insn, pending->insn ()))
+ note_mem_dep (t, pending_mem->element (),
+ pending->insn (),
DEP_OUTPUT);
- pending = XEXP (pending, 1);
- pending_mem = XEXP (pending_mem, 1);
+ pending = pending->next ();
+ pending_mem = pending_mem-> next ();
}
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)
{
/* Reading memory. */
rtx u;
- rtx pending, pending_mem;
+ rtx_insn_list *pending;
+ rtx_expr_list *pending_mem;
rtx t = x;
if (sched_deps_info->use_cselib)
@@ -2657,31 +2658,31 @@ sched_analyze_2 (struct deps_desc *deps, rtx x, rtx_insn *insn)
pending_mem = deps->pending_read_mems;
while (pending)
{
- if (read_dependence (XEXP (pending_mem, 0), t)
+ if (read_dependence (pending_mem->element (), t)
&& ! sched_insns_conditions_mutex_p (insn,
- XEXP (pending, 0)))
- note_mem_dep (t, XEXP (pending_mem, 0),
- as_a <rtx_insn *> (XEXP (pending, 0)),
+ pending->insn ()))
+ note_mem_dep (t, pending_mem->element (),
+ pending->insn (),
DEP_ANTI);
- pending = XEXP (pending, 1);
- pending_mem = XEXP (pending_mem, 1);
+ pending = pending->next ();
+ pending_mem = pending_mem->next ();
}
pending = deps->pending_write_insns;
pending_mem = deps->pending_write_mems;
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,
- XEXP (pending, 0)))
- note_mem_dep (t, XEXP (pending_mem, 0),
- as_a <rtx_insn *> (XEXP (pending, 0)),
+ pending->insn ()))
+ note_mem_dep (t, pending_mem->element (),
+ pending->insn (),
sched_deps_info->generate_spec_deps
? BEGIN_DATA | DEP_TRUE : DEP_TRUE);
- pending = XEXP (pending, 1);
- pending_mem = XEXP (pending_mem, 1);
+ pending = pending->next ();
+ pending_mem = pending_mem->next ();
}
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)
reg_pending_barrier = MOVE_BARRIER;
else
{
- rtx pending, pending_mem;
+ rtx_insn_list *pending;
+ rtx_expr_list *pending_mem;
if (sched_deps_info->compute_jump_reg_dependencies)
{
@@ -3026,23 +3028,23 @@ sched_analyze_insn (struct deps_desc *deps, rtx x, rtx_insn *insn)
pending_mem = deps->pending_write_mems;
while (pending)
{
- if (! sched_insns_conditions_mutex_p (insn, XEXP (pending, 0)))
- add_dependence (insn, as_a <rtx_insn *> (XEXP (pending, 0)),
+ if (! sched_insns_conditions_mutex_p (insn, pending->insn ()))
+ add_dependence (insn, pending->insn (),
REG_DEP_OUTPUT);
- pending = XEXP (pending, 1);
- pending_mem = XEXP (pending_mem, 1);
+ pending = pending->next ();
+ pending_mem = pending_mem->next ();
}
pending = deps->pending_read_insns;
pending_mem = deps->pending_read_mems;
while (pending)
{
- if (MEM_VOLATILE_P (XEXP (pending_mem, 0))
- && ! sched_insns_conditions_mutex_p (insn, XEXP (pending, 0)))
- add_dependence (insn, as_a <rtx_insn *> (XEXP (pending, 0)),
+ if (MEM_VOLATILE_P (pending_mem->element ())
+ && ! sched_insns_conditions_mutex_p (insn, pending->insn ()))
+ add_dependence (insn, pending->insn (),
REG_DEP_OUTPUT);
- pending = XEXP (pending, 1);
- pending_mem = XEXP (pending_mem, 1);
+ pending = pending->next ();
+ pending_mem = pending_mem->next ();
}
add_dependence_list (insn, deps->last_pending_memory_flush, 1,
diff --git a/gcc/sched-int.h b/gcc/sched-int.h
index 76d4e96..dda394e 100644
--- a/gcc/sched-int.h
+++ b/gcc/sched-int.h
@@ -1291,9 +1291,10 @@ extern struct sched_deps_info_def *sched_deps_info;
/* Functions in sched-deps.c. */
-extern rtx sched_get_reverse_condition_uncached (const_rtx);
-extern bool sched_insns_conditions_mutex_p (const_rtx, const_rtx);
-extern bool sched_insn_is_legitimate_for_speculation_p (const_rtx, ds_t);
+extern rtx sched_get_reverse_condition_uncached (const rtx_insn *);
+extern bool sched_insns_conditions_mutex_p (const rtx_insn *,
+ 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 sched_analyze (struct deps_desc *, rtx_insn *, rtx_insn *);
extern void init_deps (struct deps_desc *, bool);
diff --git a/gcc/system.h b/gcc/system.h
index 3f2cfa1..a2c8f77 100644
--- a/gcc/system.h
+++ b/gcc/system.h
@@ -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_TREE(X) CONST_CAST (union tree_node *, (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_GIMPLE(X) CONST_CAST (struct gimple_statement_base *, (X))
--
1.8.5.3
next prev parent reply other threads:[~2014-09-05 1:47 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-05 1:47 [PATCH 00/10] More use of rtx subclasses David Malcolm
2014-09-05 1:47 ` [PATCH 09/10] Simplification within reorg.c David Malcolm
2014-09-05 2:32 ` Jeff Law
2014-09-05 1:47 ` [PATCH 10/10] Use rtx_insn for various jump-handling functions and predicates David Malcolm
2014-09-05 2:34 ` Jeff Law
2014-09-05 13:03 ` Richard Sandiford
2014-09-05 15:16 ` David Malcolm
2014-09-05 1:47 ` David Malcolm [this message]
2014-09-05 2:31 ` [PATCH 07/10] Use rtx_insn for more scheduler things, plus CONST_CAST_RTX_INSN Jeff Law
2014-09-05 1:47 ` [PATCH 03/10] for_each_eh_label callbacks take an rtx_code_label David Malcolm
2014-09-05 2:27 ` Jeff Law
2014-09-05 1:47 ` [PATCH 05/10] Convert set_block_for_insn from a macro to an inline function David Malcolm
2014-09-05 2:29 ` Jeff Law
2014-09-05 1:47 ` [PATCH 01/10] Use rtx_jump_table_data in jump.c:delete_related_insns David Malcolm
2014-09-05 2:23 ` Jeff Law
2014-09-05 1:47 ` [PATCH 06/10] Use rtx_insn more within peep2 David Malcolm
2014-09-05 2:29 ` Jeff Law
2014-09-05 1:47 ` [PATCH 04/10] Eliminate the checked cast from get_call_reg_set_usage David Malcolm
2014-09-05 2:28 ` Jeff Law
2014-09-05 1:47 ` [PATCH 02/10] Drop uncast_insn from param 1 of final_scan_insn David Malcolm
2014-09-05 2:25 ` Jeff Law
2014-09-05 1:47 ` [PATCH 08/10] Use rtx_insn_list within haifa-sched.c David Malcolm
2014-09-05 2:31 ` Jeff Law
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1409881927-61672-8-git-send-email-dmalcolm@redhat.com \
--to=dmalcolm@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).