Commit a3be187d by David Malcolm Committed by David Malcolm

resource.c: Use rtx_sequence

gcc/
2014-08-27  David Malcolm  <dmalcolm@redhat.com>

	* resource.c (mark_referenced_resources): Strengthen local
	"sequence" from rtx to rtx_sequence *, adding a checked cast, and
	using methods of rtx_sequence to clarify the code.
	(find_dead_or_set_registers): Within the switch statement, convert
	a GET_CODE check to a dyn_cast, introducing local "seq".  Within
	the JUMP_P handling, introduce another local "seq", adding a
	checked cast to rtx_sequence *.  In both cases, use methods of
	rtx_sequence to clarify the code.
	(mark_set_resources): Within SEQUENCE case, introduce local "seq"
	via a checked cast, and use methods of rtx_sequence to simplify
	the code.

From-SVN: r214598
parent 9e3090e1
2014-08-27 David Malcolm <dmalcolm@redhat.com> 2014-08-27 David Malcolm <dmalcolm@redhat.com>
* resource.c (mark_referenced_resources): Strengthen local
"sequence" from rtx to rtx_sequence *, adding a checked cast, and
using methods of rtx_sequence to clarify the code.
(find_dead_or_set_registers): Within the switch statement, convert
a GET_CODE check to a dyn_cast, introducing local "seq". Within
the JUMP_P handling, introduce another local "seq", adding a
checked cast to rtx_sequence *. In both cases, use methods of
rtx_sequence to clarify the code.
(mark_set_resources): Within SEQUENCE case, introduce local "seq"
via a checked cast, and use methods of rtx_sequence to simplify
the code.
2014-08-27 David Malcolm <dmalcolm@redhat.com>
* reorg.c (redundant_insn): In two places in the function, replace * reorg.c (redundant_insn): In two places in the function, replace
a check of GET_CODE with a dyn_cast, introducing local "seq", and a check of GET_CODE with a dyn_cast, introducing local "seq", and
usings methods of rtx_sequence to clarify the code. usings methods of rtx_sequence to clarify the code.
......
...@@ -309,15 +309,15 @@ mark_referenced_resources (rtx x, struct resources *res, ...@@ -309,15 +309,15 @@ mark_referenced_resources (rtx x, struct resources *res,
into the delay slot of this CALL. If so, the USE's for them into the delay slot of this CALL. If so, the USE's for them
don't count and should be skipped. */ don't count and should be skipped. */
rtx_insn *insn = PREV_INSN (x); rtx_insn *insn = PREV_INSN (x);
rtx sequence = 0; rtx_sequence *sequence = 0;
int seq_size = 0; int seq_size = 0;
int i; int i;
/* If we are part of a delay slot sequence, point at the SEQUENCE. */ /* If we are part of a delay slot sequence, point at the SEQUENCE. */
if (NEXT_INSN (insn) != x) if (NEXT_INSN (insn) != x)
{ {
sequence = PATTERN (NEXT_INSN (insn)); sequence = as_a <rtx_sequence *> (PATTERN (NEXT_INSN (insn)));
seq_size = XVECLEN (sequence, 0); seq_size = sequence->len ();
gcc_assert (GET_CODE (sequence) == SEQUENCE); gcc_assert (GET_CODE (sequence) == SEQUENCE);
} }
...@@ -356,7 +356,7 @@ mark_referenced_resources (rtx x, struct resources *res, ...@@ -356,7 +356,7 @@ mark_referenced_resources (rtx x, struct resources *res,
{ {
for (i = 1; i < seq_size; i++) for (i = 1; i < seq_size; i++)
{ {
rtx slot_pat = PATTERN (XVECEXP (sequence, 0, i)); rtx slot_pat = PATTERN (sequence->element (i));
if (GET_CODE (slot_pat) == SET if (GET_CODE (slot_pat) == SET
&& rtx_equal_p (SET_DEST (slot_pat), && rtx_equal_p (SET_DEST (slot_pat),
XEXP (XEXP (link, 0), 0))) XEXP (XEXP (link, 0), 0)))
...@@ -473,13 +473,14 @@ find_dead_or_set_registers (rtx target, struct resources *res, ...@@ -473,13 +473,14 @@ find_dead_or_set_registers (rtx target, struct resources *res,
} }
else if (GET_CODE (PATTERN (insn)) == CLOBBER) else if (GET_CODE (PATTERN (insn)) == CLOBBER)
continue; continue;
else if (GET_CODE (PATTERN (insn)) == SEQUENCE) else if (rtx_sequence *seq =
dyn_cast <rtx_sequence *> (PATTERN (insn)))
{ {
/* An unconditional jump can be used to fill the delay slot /* An unconditional jump can be used to fill the delay slot
of a call, so search for a JUMP_INSN in any position. */ of a call, so search for a JUMP_INSN in any position. */
for (i = 0; i < XVECLEN (PATTERN (insn), 0); i++) for (i = 0; i < seq->len (); i++)
{ {
this_jump_insn = XVECEXP (PATTERN (insn), 0, i); this_jump_insn = seq->element (i);
if (JUMP_P (this_jump_insn)) if (JUMP_P (this_jump_insn))
break; break;
} }
...@@ -536,17 +537,18 @@ find_dead_or_set_registers (rtx target, struct resources *res, ...@@ -536,17 +537,18 @@ find_dead_or_set_registers (rtx target, struct resources *res,
if (GET_CODE (PATTERN (insn)) == SEQUENCE if (GET_CODE (PATTERN (insn)) == SEQUENCE
&& INSN_ANNULLED_BRANCH_P (this_jump_insn)) && INSN_ANNULLED_BRANCH_P (this_jump_insn))
{ {
for (i = 1; i < XVECLEN (PATTERN (insn), 0); i++) rtx_sequence *seq = as_a <rtx_sequence *> (PATTERN (insn));
INSN_FROM_TARGET_P (XVECEXP (PATTERN (insn), 0, i)) for (i = 1; i < seq->len (); i++)
= ! INSN_FROM_TARGET_P (XVECEXP (PATTERN (insn), 0, i)); INSN_FROM_TARGET_P (seq->element (i))
= ! INSN_FROM_TARGET_P (seq->element (i));
target_set = set; target_set = set;
mark_set_resources (insn, &target_set, 0, mark_set_resources (insn, &target_set, 0,
MARK_SRC_DEST_CALL); MARK_SRC_DEST_CALL);
for (i = 1; i < XVECLEN (PATTERN (insn), 0); i++) for (i = 1; i < seq->len (); i++)
INSN_FROM_TARGET_P (XVECEXP (PATTERN (insn), 0, i)) INSN_FROM_TARGET_P (seq->element (i))
= ! INSN_FROM_TARGET_P (XVECEXP (PATTERN (insn), 0, i)); = ! INSN_FROM_TARGET_P (seq->element (i));
mark_set_resources (insn, &set, 0, MARK_SRC_DEST_CALL); mark_set_resources (insn, &set, 0, MARK_SRC_DEST_CALL);
} }
...@@ -712,13 +714,14 @@ mark_set_resources (rtx x, struct resources *res, int in_dest, ...@@ -712,13 +714,14 @@ mark_set_resources (rtx x, struct resources *res, int in_dest,
case SEQUENCE: case SEQUENCE:
{ {
rtx control = XVECEXP (x, 0, 0); rtx_sequence *seq = as_a <rtx_sequence *> (x);
rtx control = seq->element (0);
bool annul_p = JUMP_P (control) && INSN_ANNULLED_BRANCH_P (control); bool annul_p = JUMP_P (control) && INSN_ANNULLED_BRANCH_P (control);
mark_set_resources (control, res, 0, mark_type); mark_set_resources (control, res, 0, mark_type);
for (i = XVECLEN (x, 0) - 1; i >= 0; --i) for (i = seq->len () - 1; i >= 0; --i)
{ {
rtx elt = XVECEXP (x, 0, i); rtx elt = seq->element (i);
if (!annul_p && INSN_FROM_TARGET_P (elt)) if (!annul_p && INSN_FROM_TARGET_P (elt))
mark_set_resources (elt, res, 0, mark_type); mark_set_resources (elt, res, 0, mark_type);
} }
......
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