+2014-08-25 David Malcolm <dmalcolm@redhat.com>
+
+ * rtl.h (rtx_jump_table_data::get_labels): New method.
+ * cfgbuild.c (make_edges): Replace hand-coded lookup of labels
+ with use of the new rtx_jump_table_data::get_labels method.
+ (purge_dead_tablejump_edges): Strengthen param "table" from rtx
+ to rtx_jump_table_data *. Simplify by using get_labels method.
+ * cfgrtl.c (delete_insn): Replace use of JUMP_TABLE_DATA_P with
+ a dyn_cast, introducing local "table", using it to replace
+ label-lookup logic with a get_labels method call.
+ (patch_jump_insn): Simplify using get_labels method.
+ * dwarf2cfi.c (create_trace_edges): Likewise.
+ * rtlanal.c (label_is_jump_target_p): Likewise.
+
2014-08-25 David Malcolm <dmalcolm@redhat.com>
* rtl.h (unshare_all_rtl_again): Strengthen param "insn" from rtx
/* Recognize a tablejump and do the right thing. */
else if (tablejump_p (insn, NULL, &table))
{
- rtvec vec;
+ rtvec vec = table->get_labels ();
int j;
- if (GET_CODE (PATTERN (table)) == ADDR_VEC)
- vec = XVEC (PATTERN (table), 0);
- else
- vec = XVEC (PATTERN (table), 1);
-
for (j = GET_NUM_ELEM (vec) - 1; j >= 0; --j)
make_label_edge (edge_cache, bb,
XEXP (RTVEC_ELT (vec, j), 0), 0);
}
static void
-purge_dead_tablejump_edges (basic_block bb, rtx table)
+purge_dead_tablejump_edges (basic_block bb, rtx_jump_table_data *table)
{
rtx_insn *insn = BB_END (bb);
rtx tmp;
edge_iterator ei;
edge e;
- if (GET_CODE (PATTERN (table)) == ADDR_VEC)
- vec = XVEC (PATTERN (table), 0);
- else
- vec = XVEC (PATTERN (table), 1);
+ vec = table->get_labels ();
for (j = GET_NUM_ELEM (vec) - 1; j >= 0; --j)
mark_tablejump_edge (XEXP (RTVEC_ELT (vec, j), 0));
remove_note (insn, note);
}
- if (JUMP_TABLE_DATA_P (insn))
+ if (rtx_jump_table_data *table = dyn_cast <rtx_jump_table_data *> (insn))
{
- rtx pat = PATTERN (insn);
- int diff_vec_p = GET_CODE (PATTERN (insn)) == ADDR_DIFF_VEC;
- int len = XVECLEN (pat, diff_vec_p);
+ rtvec vec = table->get_labels ();
+ int len = GET_NUM_ELEM (vec);
int i;
for (i = 0; i < len; i++)
{
- rtx label = XEXP (XVECEXP (pat, diff_vec_p, i), 0);
+ rtx label = XEXP (RTVEC_ELT (vec, i), 0);
/* When deleting code in bulk (e.g. removing many unreachable
blocks) we can delete a label that's a target of the vector
if (new_bb == EXIT_BLOCK_PTR_FOR_FN (cfun))
return false;
- if (GET_CODE (PATTERN (table)) == ADDR_VEC)
- vec = XVEC (PATTERN (table), 0);
- else
- vec = XVEC (PATTERN (table), 1);
+ vec = table->get_labels ();
for (j = GET_NUM_ELEM (vec) - 1; j >= 0; --j)
if (XEXP (RTVEC_ELT (vec, j), 0) == old_label)
if (tablejump_p (insn, NULL, &table))
{
- rtvec vec;
-
- tmp = PATTERN (table);
- vec = XVEC (tmp, GET_CODE (tmp) == ADDR_DIFF_VEC);
+ rtvec vec = table->get_labels ();
n = GET_NUM_ELEM (vec);
for (i = 0; i < n; ++i)
This is an instance of:
DEF_RTL_EXPR(JUMP_TABLE_DATA, "jump_table_data", "uuBe0000", RTX_INSN)
from rtl.def. */
+
+public:
+
+ /* This can be either:
+
+ (a) a table of absolute jumps, in which case PATTERN (this) is an
+ ADDR_VEC with arg 0 a vector of labels, or
+
+ (b) a table of relative jumps (e.g. for -fPIC), in which case
+ PATTERN (this) is an ADDR_DIFF_VEC, with arg 0 a LABEL_REF and
+ arg 1 the vector of labels.
+
+ This method gets the underlying vec. */
+
+ inline rtvec get_labels () const;
};
class GTY(()) rtx_barrier : public rtx_insn
-1 means this instruction has not been recognized yet. */
#define INSN_CODE(INSN) XINT (INSN, 5)
+inline rtvec rtx_jump_table_data::get_labels () const
+{
+ rtx pat = PATTERN (this);
+ if (GET_CODE (pat) == ADDR_VEC)
+ return XVEC (pat, 0);
+ else
+ return XVEC (pat, 1); /* presumably an ADDR_DIFF_VEC */
+}
+
#define RTX_FRAME_RELATED_P(RTX) \
(RTL_FLAG_CHECK6 ("RTX_FRAME_RELATED_P", (RTX), DEBUG_INSN, INSN, \
CALL_INSN, JUMP_INSN, BARRIER, SET)->frame_related)
if (tablejump_p (jump_insn, NULL, &table))
{
- rtvec vec = XVEC (PATTERN (table),
- GET_CODE (PATTERN (table)) == ADDR_DIFF_VEC);
+ rtvec vec = table->get_labels ();
int i, veclen = GET_NUM_ELEM (vec);
for (i = 0; i < veclen; ++i)