Commit dfe08bc4 by Trevor Saunders Committed by Trevor Saunders

make tablejump_p return the label as a rtx_insn *

gcc/ChangeLog:

2016-10-21  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>

	* cfgcleanup.c (merge_blocks_move_successor_nojumps): Adjust.
	(outgoing_edges_match): Likewise.
	(try_crossjump_to_edge): Likewise.
	* cfgrtl.c (try_redirect_by_replacing_jump): Likewise.
	(rtl_tidy_fallthru_edge): Likewise.
	* rtl.h (tablejump_p): Adjust prototype.
	* rtlanal.c (tablejump_p): Return the label as a rtx_insn *.

From-SVN: r241402
parent 04a121a7
2016-10-21 Trevor Saunders <tbsaunde+gcc@tbsaunde.org> 2016-10-21 Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
* cfgcleanup.c (merge_blocks_move_successor_nojumps): Adjust.
(outgoing_edges_match): Likewise.
(try_crossjump_to_edge): Likewise.
* cfgrtl.c (try_redirect_by_replacing_jump): Likewise.
(rtl_tidy_fallthru_edge): Likewise.
* rtl.h (tablejump_p): Adjust prototype.
* rtlanal.c (tablejump_p): Return the label as a rtx_insn *.
2016-10-21 Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
* rtl.h (label_ref_label): New function. * rtl.h (label_ref_label): New function.
(set_label_ref_label): New function. (set_label_ref_label): New function.
(LABEL_REF_LABEL): Delete. (LABEL_REF_LABEL): Delete.
......
...@@ -688,7 +688,7 @@ static void ...@@ -688,7 +688,7 @@ static void
merge_blocks_move_successor_nojumps (basic_block a, basic_block b) merge_blocks_move_successor_nojumps (basic_block a, basic_block b)
{ {
rtx_insn *barrier, *real_b_end; rtx_insn *barrier, *real_b_end;
rtx label; rtx_insn *label;
rtx_jump_table_data *table; rtx_jump_table_data *table;
/* If we are partitioning hot/cold basic blocks, we don't want to /* If we are partitioning hot/cold basic blocks, we don't want to
...@@ -709,7 +709,7 @@ merge_blocks_move_successor_nojumps (basic_block a, basic_block b) ...@@ -709,7 +709,7 @@ merge_blocks_move_successor_nojumps (basic_block a, basic_block b)
/* If there is a jump table following block B temporarily add the jump table /* If there is a jump table following block B temporarily add the jump table
to block B so that it will also be moved to the correct location. */ to block B so that it will also be moved to the correct location. */
if (tablejump_p (BB_END (b), &label, &table) if (tablejump_p (BB_END (b), &label, &table)
&& prev_active_insn (as_a<rtx_insn *> (label)) == BB_END (b)) && prev_active_insn (label) == BB_END (b))
{ {
BB_END (b) = table; BB_END (b) = table;
} }
...@@ -1697,7 +1697,7 @@ outgoing_edges_match (int mode, basic_block bb1, basic_block bb2) ...@@ -1697,7 +1697,7 @@ outgoing_edges_match (int mode, basic_block bb1, basic_block bb2)
/* Check whether there are tablejumps in the end of BB1 and BB2. /* Check whether there are tablejumps in the end of BB1 and BB2.
Return true if they are identical. */ Return true if they are identical. */
{ {
rtx label1, label2; rtx_insn *label1, *label2;
rtx_jump_table_data *table1, *table2; rtx_jump_table_data *table1, *table2;
if (tablejump_p (BB_END (bb1), &label1, &table1) if (tablejump_p (BB_END (bb1), &label1, &table1)
...@@ -1994,7 +1994,7 @@ try_crossjump_to_edge (int mode, edge e1, edge e2, ...@@ -1994,7 +1994,7 @@ try_crossjump_to_edge (int mode, edge e1, edge e2,
they have been already compared for equivalence in outgoing_edges_match () they have been already compared for equivalence in outgoing_edges_match ()
so replace the references to TABLE1 by references to TABLE2. */ so replace the references to TABLE1 by references to TABLE2. */
{ {
rtx label1, label2; rtx_insn *label1, *label2;
rtx_jump_table_data *table1, *table2; rtx_jump_table_data *table1, *table2;
if (tablejump_p (BB_END (osrc1), &label1, &table1) if (tablejump_p (BB_END (osrc1), &label1, &table1)
......
...@@ -1101,7 +1101,7 @@ try_redirect_by_replacing_jump (edge e, basic_block target, bool in_cfglayout) ...@@ -1101,7 +1101,7 @@ try_redirect_by_replacing_jump (edge e, basic_block target, bool in_cfglayout)
{ {
rtx_code_label *target_label = block_label (target); rtx_code_label *target_label = block_label (target);
rtx_insn *barrier; rtx_insn *barrier;
rtx label; rtx_insn *label;
rtx_jump_table_data *table; rtx_jump_table_data *table;
emit_jump_insn_after_noloc (targetm.gen_jump (target_label), insn); emit_jump_insn_after_noloc (targetm.gen_jump (target_label), insn);
...@@ -1773,7 +1773,7 @@ rtl_tidy_fallthru_edge (edge e) ...@@ -1773,7 +1773,7 @@ rtl_tidy_fallthru_edge (edge e)
&& (any_uncondjump_p (q) && (any_uncondjump_p (q)
|| single_succ_p (b))) || single_succ_p (b)))
{ {
rtx label; rtx_insn *label;
rtx_jump_table_data *table; rtx_jump_table_data *table;
if (tablejump_p (q, &label, &table)) if (tablejump_p (q, &label, &table))
...@@ -1786,8 +1786,7 @@ rtl_tidy_fallthru_edge (edge e) ...@@ -1786,8 +1786,7 @@ rtl_tidy_fallthru_edge (edge e)
PUT_CODE (label, NOTE); PUT_CODE (label, NOTE);
NOTE_KIND (label) = NOTE_INSN_DELETED_LABEL; NOTE_KIND (label) = NOTE_INSN_DELETED_LABEL;
NOTE_DELETED_LABEL_NAME (label) = name; NOTE_DELETED_LABEL_NAME (label) = name;
rtx_insn *lab = safe_as_a <rtx_insn *> (label); reorder_insns (label, label, PREV_INSN (q));
reorder_insns (lab, lab, PREV_INSN (q));
delete_insn (table); delete_insn (table);
} }
......
...@@ -3040,7 +3040,7 @@ extern rtx replace_rtx (rtx, rtx, rtx, bool = false); ...@@ -3040,7 +3040,7 @@ extern rtx replace_rtx (rtx, rtx, rtx, bool = false);
extern void replace_label (rtx *, rtx, rtx, bool); extern void replace_label (rtx *, rtx, rtx, bool);
extern void replace_label_in_insn (rtx_insn *, rtx, rtx, bool); extern void replace_label_in_insn (rtx_insn *, rtx, rtx, bool);
extern bool rtx_referenced_p (const_rtx, const_rtx); extern bool rtx_referenced_p (const_rtx, const_rtx);
extern bool tablejump_p (const rtx_insn *, rtx *, rtx_jump_table_data **); extern bool tablejump_p (const rtx_insn *, rtx_insn **, rtx_jump_table_data **);
extern int computed_jump_p (const rtx_insn *); extern int computed_jump_p (const rtx_insn *);
extern bool tls_referenced_p (const_rtx); extern bool tls_referenced_p (const_rtx);
......
...@@ -3103,26 +3103,26 @@ rtx_referenced_p (const_rtx x, const_rtx body) ...@@ -3103,26 +3103,26 @@ rtx_referenced_p (const_rtx x, const_rtx body)
*LABELP and the jump table to *TABLEP. LABELP and TABLEP may be NULL. */ *LABELP and the jump table to *TABLEP. LABELP and TABLEP may be NULL. */
bool bool
tablejump_p (const rtx_insn *insn, rtx *labelp, rtx_jump_table_data **tablep) tablejump_p (const rtx_insn *insn, rtx_insn **labelp,
rtx_jump_table_data **tablep)
{ {
rtx label;
rtx_insn *table;
if (!JUMP_P (insn)) if (!JUMP_P (insn))
return false; return false;
label = JUMP_LABEL (insn); rtx target = JUMP_LABEL (insn);
if (label != NULL_RTX && !ANY_RETURN_P (label) if (target == NULL_RTX || ANY_RETURN_P (target))
&& (table = NEXT_INSN (as_a <rtx_insn *> (label))) != NULL_RTX return false;
&& JUMP_TABLE_DATA_P (table))
{ rtx_insn *label = as_a<rtx_insn *> (target);
if (labelp) rtx_insn *table = next_insn (label);
*labelp = label; if (table == NULL_RTX || !JUMP_TABLE_DATA_P (table))
if (tablep) return false;
*tablep = as_a <rtx_jump_table_data *> (table);
return true; if (labelp)
} *labelp = label;
return false; if (tablep)
*tablep = as_a <rtx_jump_table_data *> (table);
return true;
} }
/* A subroutine of computed_jump_p, return 1 if X contains a REG or MEM or /* A subroutine of computed_jump_p, return 1 if X contains a REG or MEM or
......
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