aboutsummaryrefslogtreecommitdiff
path: root/gcc/dojump.c
diff options
context:
space:
mode:
authorMikhail Maltsev <maltsevm@gmail.com>2015-05-20 19:39:42 +0000
committerMikhail Maltsev <miyuki@gcc.gnu.org>2015-05-20 19:39:42 +0000
commit1476d1bd020588ee81d1384354cf533c88849a3a (patch)
tree710f2e790c32c989e13feab254c623d98b5f103d /gcc/dojump.c
parentfd2ef1171407340dbb09935ab535debf40f56376 (diff)
downloadgcc-1476d1bd020588ee81d1384354cf533c88849a3a.zip
gcc-1476d1bd020588ee81d1384354cf533c88849a3a.tar.gz
gcc-1476d1bd020588ee81d1384354cf533c88849a3a.tar.bz2
Promote types of RTL expressions to more derived ones.
* bb-reorder.c (set_edge_can_fallthru_flag): Use rtx_jump_insn where feasible. (fix_up_fall_thru_edges): Likewise. (fix_crossing_conditional_branches): Likewise. Promote jump targets from to rtx_insn to rtx_code_label where feasible. * bt-load.c (move_btr_def): Remove as-a cast of the value returned by gen_move_insn (returned type changed to rtx_insn). * builtins.c (expand_errno_check): Fix arguments of do_compare_rtx_and_jump (now expects rtx_code_label). (expand_builtin_acc_on_device): Likewise. * cfgcleanup.c (try_simplify_condjump): Add cast when calling invert_jump (now exprects rtx_jump_insn). * cfgexpand.c (label_rtx_for_bb): Promote return type to rtx_code_label. (construct_init_block): Use rtx_code_label. * cfgrtl.c (block_label): Promote return type to rtx_code_label. (try_redirect_by_replacing_jump): Use cast to rtx_jump_insn when calling redirect_jump. (patch_jump_insn): Likewise. (redirect_branch_edge): Likewise. (force_nonfallthru_and_redirect): Likewise. (fixup_reorder_chain): Explicitly use rtx_jump_insn instead of rtx_insn when suitable. (rtl_lv_add_condition_to_bb): Update call of do_compare_rtx_and_jump. * cfgrtl.h: Promote return type of block_label to rtx_code_label. * config/bfin/bfin.c (hwloop_optimize): Fix call of emit_label_before. * config/i386/i386.c (ix86_emit_cmove): Explicitly use rtx_code_label to store the value retured by gen_label_rtx. * config/mips/mips.c (mips16_split_long_branches): Promote rtx_insn to rtx_jump_insn. * config/sh/sh.c (gen_far_branch): Likewise. Fix call of invert_jump. (split_branches): Fix calls of redirect_jump. * dojump.c (jumpifnot): Promote argument type from rtx to rtx_code_label. (jumpifnot_1): Likewise. (jumpif): Likewise. (jumpif_1): Likewise. (do_jump_1): Likewise. (do_jump): Likewise. Use rtx_code_label when feasible. (do_jump_by_parts_greater_rtx): Likewise. (do_jump_by_parts_zero_rtx): Likewise. (do_jump_by_parts_equality_rtx): Likewise. (do_compare_rtx_and_jump): Likewise. * dojump.h: Update function prototypes. * dse.c (emit_inc_dec_insn_before): Remove case (gen_move_insn now returns rtx_insn). * emit-rtl.c (emit_jump_insn_before_noloc): Promote return type to rtx_jump_insn. (emit_label_before): Likewise. (emit_jump_insn_after_noloc): Likewise. (emit_jump_insn_after_setloc): Likewise. (emit_jump_insn_after): Likewise (emit_jump_insn_before_setloc): Likewise. (emit_jump_insn_before): Likewise. (emit_label_before): Promote return type to rtx_code_label. (emit_label): Likewise. * except.c (sjlj_emit_dispatch_table): Use jump_target_rtx. * explow.c (emit_stack_save): Use gen_move_insn_uncast instead of gen_move_insn. (emit_stack_restore): Likewise. * expmed.c (emit_store_flag_force): Fix calls of do_compare_rtx_and_jump. (do_cmp_and_jump): Likewise. * expr.c (expand_expr_real_2): Likewise. Promote some local variables from rtx to rtx_code_label. (gen_move_insn_uncast): New function. * expr.h: Update return type of gen_move_insn (promote to rtx_insn). * function.c (convert_jumps_to_returns): Fix call of redirect_jump. * gcse.c (pre_insert_copy_insn): Use rtx_insn instead of rtx. * ifcvt.c (dead_or_predicable): Use rtx_jump_insn when calling invert_jump_1 and redirect_jump_1. * internal-fn.c (expand_arith_overflow_result_store): Fix call of do_compare_rtx_and_jump. (expand_addsub_overflow): Likewise. (expand_neg_overflow): Likewise. (expand_mul_overflow): Likewise. * ira.c (split_live_ranges_for_shrink_wrap): Use rtx_insn for return value of gen_move_insn. * jump.c (redirect_jump): Promote argument from rtx to rtx_jump_insn. * loop-doloop.c (add_test): Use rtx_code_label. (doloop_modify): Likewise. (doloop_optimize): Likewise. * loop-unroll.c (compare_and_jump_seq): Promote rtx to rtx_code_label. * lra-constraints.c (emit_spill_move): Remove cast of value returned by gen_move_insn. (inherit_reload_reg): Add cast when calling dump_insn_slim. (split_reg): Likewise. * modulo-sched.c (schedule_reg_moves): Remove cast of value returned by gen_move_insn. * optabs.c (expand_binop_directly): Remove casts of values returned by maybe_gen_insn. (expand_unop_direct): Likewise. (expand_abs): Likewise. (maybe_emit_unop_insn): Likewise. (maybe_gen_insn): Promote return type to rtx_insn. * optabs.h: Update prototype of maybe_gen_insn. * postreload-gcse.c (eliminate_partially_redundant_load): Remove redundant cast. * recog.c (struct peep2_insn_data): Promote type of insn field to rtx_insn. (peep2_reinit_state): Use NULL instead of NULL_RTX. (peep2_attempt): Remove casts of insn in peep2_insn_data. (peep2_fill_buffer): Promote argument from rtx to rtx_insn * recog.h (struct insn_gen_fn): Promote return types of function pointers and operator ().from rtx to rtx_insn. * reorg.c (fill_simple_delay_slots): Promote rtx_insn to rtx_jump_insn. (fill_eager_delay_slots): Likewise. (relax_delay_slots): Likewise. (make_return_insns): Likewise. (dbr_schedule): Likewise. (optimize_skips): Likewise. (reorg_redirect_jump): Likewise. (fill_slots_from_thread): Likewise. * reorg.h: Update prototypes. * resource.c (find_dead_or_set_registers): Use dyn_cast to rtx_jump_insn instead of check. Use it's jump_target method. * rtl.h (rtx_jump_insn::jump_label): Define new method. (rtx_jump_insn::jump_target): Define new method. (rtx_jump_insn::set_jump_target): Define new method. * rtlanal.c (tablejump_p): Promote type of one local variable. * sched-deps.c (sched_analyze_2): Promote rtx to rtx_insn_list. (sched_analyze_insn): Likewise. * sched-vis.c (print_insn_with_notes): Promote rtx to rtx_insn. (print_insn): Likewise. * stmt.c (label_rtx): Promote return type to rtx_insn. (force_label_rtx): Likewise. (jump_target_rtx): Define new function. (expand_label): Use it, get rid of one cast. (expand_naked_return): Promote rtx to rtx_code_label. (do_jump_if_equal): Fix do_compare_rtx_and_jump call. (expand_case): Use rtx_code_label instread of rtx where feasible. (expand_sjlj_dispatch_table): Likewise. (emit_case_nodes): Likewise. * stmt.h: Declare jump_target_rtx. Update prototypes. Fix comments. * store-motion.c (insert_store): Make use of new return type of gen_move_insn and remove a cast. (replace_store_insn): Likewise. From-SVN: r223454
Diffstat (limited to 'gcc/dojump.c')
-rw-r--r--gcc/dojump.c147
1 files changed, 80 insertions, 67 deletions
diff --git a/gcc/dojump.c b/gcc/dojump.c
index b564d64..e5ea589 100644
--- a/gcc/dojump.c
+++ b/gcc/dojump.c
@@ -61,10 +61,12 @@ along with GCC; see the file COPYING3. If not see
#include "tm_p.h"
static bool prefer_and_bit_test (machine_mode, int);
-static void do_jump_by_parts_greater (tree, tree, int, rtx, rtx, int);
-static void do_jump_by_parts_equality (tree, tree, rtx, rtx, int);
-static void do_compare_and_jump (tree, tree, enum rtx_code, enum rtx_code, rtx,
- rtx, int);
+static void do_jump_by_parts_greater (tree, tree, int,
+ rtx_code_label *, rtx_code_label *, int);
+static void do_jump_by_parts_equality (tree, tree, rtx_code_label *,
+ rtx_code_label *, int);
+static void do_compare_and_jump (tree, tree, enum rtx_code, enum rtx_code,
+ rtx_code_label *, rtx_code_label *, int);
/* Invert probability if there is any. -1 stands for unknown. */
@@ -146,34 +148,34 @@ restore_pending_stack_adjust (saved_pending_stack_adjust *save)
/* Expand conditional expressions. */
-/* Generate code to evaluate EXP and jump to LABEL if the value is zero.
- LABEL is an rtx of code CODE_LABEL, in this function and all the
- functions here. */
+/* Generate code to evaluate EXP and jump to LABEL if the value is zero. */
void
-jumpifnot (tree exp, rtx label, int prob)
+jumpifnot (tree exp, rtx_code_label *label, int prob)
{
- do_jump (exp, label, NULL_RTX, inv (prob));
+ do_jump (exp, label, NULL, inv (prob));
}
void
-jumpifnot_1 (enum tree_code code, tree op0, tree op1, rtx label, int prob)
+jumpifnot_1 (enum tree_code code, tree op0, tree op1, rtx_code_label *label,
+ int prob)
{
- do_jump_1 (code, op0, op1, label, NULL_RTX, inv (prob));
+ do_jump_1 (code, op0, op1, label, NULL, inv (prob));
}
/* Generate code to evaluate EXP and jump to LABEL if the value is nonzero. */
void
-jumpif (tree exp, rtx label, int prob)
+jumpif (tree exp, rtx_code_label *label, int prob)
{
- do_jump (exp, NULL_RTX, label, prob);
+ do_jump (exp, NULL, label, prob);
}
void
-jumpif_1 (enum tree_code code, tree op0, tree op1, rtx label, int prob)
+jumpif_1 (enum tree_code code, tree op0, tree op1,
+ rtx_code_label *label, int prob)
{
- do_jump_1 (code, op0, op1, NULL_RTX, label, prob);
+ do_jump_1 (code, op0, op1, NULL, label, prob);
}
/* Used internally by prefer_and_bit_test. */
@@ -225,7 +227,8 @@ prefer_and_bit_test (machine_mode mode, int bitnum)
void
do_jump_1 (enum tree_code code, tree op0, tree op1,
- rtx if_false_label, rtx if_true_label, int prob)
+ rtx_code_label *if_false_label, rtx_code_label *if_true_label,
+ int prob)
{
machine_mode mode;
rtx_code_label *drop_through_label = 0;
@@ -378,15 +381,15 @@ do_jump_1 (enum tree_code code, tree op0, tree op1,
op0_prob = inv (op0_false_prob);
op1_prob = inv (op1_false_prob);
}
- if (if_false_label == NULL_RTX)
+ if (if_false_label == NULL)
{
drop_through_label = gen_label_rtx ();
- do_jump (op0, drop_through_label, NULL_RTX, op0_prob);
- do_jump (op1, NULL_RTX, if_true_label, op1_prob);
+ do_jump (op0, drop_through_label, NULL, op0_prob);
+ do_jump (op1, NULL, if_true_label, op1_prob);
}
else
{
- do_jump (op0, if_false_label, NULL_RTX, op0_prob);
+ do_jump (op0, if_false_label, NULL, op0_prob);
do_jump (op1, if_false_label, if_true_label, op1_prob);
}
break;
@@ -405,18 +408,18 @@ do_jump_1 (enum tree_code code, tree op0, tree op1,
{
op0_prob = prob / 2;
op1_prob = GCOV_COMPUTE_SCALE ((prob / 2), inv (op0_prob));
- }
- if (if_true_label == NULL_RTX)
- {
- drop_through_label = gen_label_rtx ();
- do_jump (op0, NULL_RTX, drop_through_label, op0_prob);
- do_jump (op1, if_false_label, NULL_RTX, op1_prob);
- }
- else
- {
- do_jump (op0, NULL_RTX, if_true_label, op0_prob);
- do_jump (op1, if_false_label, if_true_label, op1_prob);
- }
+ }
+ if (if_true_label == NULL)
+ {
+ drop_through_label = gen_label_rtx ();
+ do_jump (op0, NULL, drop_through_label, op0_prob);
+ do_jump (op1, if_false_label, NULL, op1_prob);
+ }
+ else
+ {
+ do_jump (op0, NULL, if_true_label, op0_prob);
+ do_jump (op1, if_false_label, if_true_label, op1_prob);
+ }
break;
}
@@ -443,14 +446,15 @@ do_jump_1 (enum tree_code code, tree op0, tree op1,
PROB is probability of jump to if_true_label, or -1 if unknown. */
void
-do_jump (tree exp, rtx if_false_label, rtx if_true_label, int prob)
+do_jump (tree exp, rtx_code_label *if_false_label,
+ rtx_code_label *if_true_label, int prob)
{
enum tree_code code = TREE_CODE (exp);
rtx temp;
int i;
tree type;
machine_mode mode;
- rtx_code_label *drop_through_label = 0;
+ rtx_code_label *drop_through_label = NULL;
switch (code)
{
@@ -458,10 +462,13 @@ do_jump (tree exp, rtx if_false_label, rtx if_true_label, int prob)
break;
case INTEGER_CST:
- temp = integer_zerop (exp) ? if_false_label : if_true_label;
- if (temp)
- emit_jump (temp);
- break;
+ {
+ rtx_code_label *lab = integer_zerop (exp) ? if_false_label
+ : if_true_label;
+ if (lab)
+ emit_jump (lab);
+ break;
+ }
#if 0
/* This is not true with #pragma weak */
@@ -511,7 +518,7 @@ do_jump (tree exp, rtx if_false_label, rtx if_true_label, int prob)
}
do_pending_stack_adjust ();
- do_jump (TREE_OPERAND (exp, 0), label1, NULL_RTX, -1);
+ do_jump (TREE_OPERAND (exp, 0), label1, NULL, -1);
do_jump (TREE_OPERAND (exp, 1), if_false_label, if_true_label, prob);
emit_label (label1);
do_jump (TREE_OPERAND (exp, 2), if_false_label, if_true_label, prob);
@@ -555,7 +562,7 @@ do_jump (tree exp, rtx if_false_label, rtx if_true_label, int prob)
if (integer_onep (TREE_OPERAND (exp, 1)))
{
tree exp0 = TREE_OPERAND (exp, 0);
- rtx set_label, clr_label;
+ rtx_code_label *set_label, *clr_label;
int setclr_prob = prob;
/* Strip narrowing integral type conversions. */
@@ -684,11 +691,12 @@ do_jump (tree exp, rtx if_false_label, rtx if_true_label, int prob)
static void
do_jump_by_parts_greater_rtx (machine_mode mode, int unsignedp, rtx op0,
- rtx op1, rtx if_false_label, rtx if_true_label,
+ rtx op1, rtx_code_label *if_false_label,
+ rtx_code_label *if_true_label,
int prob)
{
int nwords = (GET_MODE_SIZE (mode) / UNITS_PER_WORD);
- rtx drop_through_label = 0;
+ rtx_code_label *drop_through_label = 0;
bool drop_through_if_true = false, drop_through_if_false = false;
enum rtx_code code = GT;
int i;
@@ -735,7 +743,7 @@ do_jump_by_parts_greater_rtx (machine_mode mode, int unsignedp, rtx op0,
/* All but high-order word must be compared as unsigned. */
do_compare_rtx_and_jump (op0_word, op1_word, code, (unsignedp || i > 0),
- word_mode, NULL_RTX, NULL_RTX, if_true_label,
+ word_mode, NULL_RTX, NULL, if_true_label,
prob);
/* Emit only one comparison for 0. Do not emit the last cond jump. */
@@ -744,7 +752,7 @@ do_jump_by_parts_greater_rtx (machine_mode mode, int unsignedp, rtx op0,
/* Consider lower words only if these are equal. */
do_compare_rtx_and_jump (op0_word, op1_word, NE, unsignedp, word_mode,
- NULL_RTX, NULL_RTX, if_false_label, inv (prob));
+ NULL_RTX, NULL, if_false_label, inv (prob));
}
if (!drop_through_if_false)
@@ -760,7 +768,8 @@ do_jump_by_parts_greater_rtx (machine_mode mode, int unsignedp, rtx op0,
static void
do_jump_by_parts_greater (tree treeop0, tree treeop1, int swap,
- rtx if_false_label, rtx if_true_label, int prob)
+ rtx_code_label *if_false_label,
+ rtx_code_label *if_true_label, int prob)
{
rtx op0 = expand_normal (swap ? treeop1 : treeop0);
rtx op1 = expand_normal (swap ? treeop0 : treeop1);
@@ -773,17 +782,18 @@ do_jump_by_parts_greater (tree treeop0, tree treeop1, int swap,
/* Jump according to whether OP0 is 0. We assume that OP0 has an integer
mode, MODE, that is too wide for the available compare insns. Either
- Either (but not both) of IF_TRUE_LABEL and IF_FALSE_LABEL may be NULL_RTX
+ Either (but not both) of IF_TRUE_LABEL and IF_FALSE_LABEL may be NULL
to indicate drop through. */
static void
do_jump_by_parts_zero_rtx (machine_mode mode, rtx op0,
- rtx if_false_label, rtx if_true_label, int prob)
+ rtx_code_label *if_false_label,
+ rtx_code_label *if_true_label, int prob)
{
int nwords = GET_MODE_SIZE (mode) / UNITS_PER_WORD;
rtx part;
int i;
- rtx drop_through_label = 0;
+ rtx_code_label *drop_through_label = NULL;
/* The fastest way of doing this comparison on almost any machine is to
"or" all the words and compare the result. If all have to be loaded
@@ -806,12 +816,12 @@ do_jump_by_parts_zero_rtx (machine_mode mode, rtx op0,
/* If we couldn't do the "or" simply, do this with a series of compares. */
if (! if_false_label)
- drop_through_label = if_false_label = gen_label_rtx ();
+ if_false_label = drop_through_label = gen_label_rtx ();
for (i = 0; i < nwords; i++)
do_compare_rtx_and_jump (operand_subword_force (op0, i, mode),
const0_rtx, EQ, 1, word_mode, NULL_RTX,
- if_false_label, NULL_RTX, prob);
+ if_false_label, NULL, prob);
if (if_true_label)
emit_jump (if_true_label);
@@ -827,10 +837,11 @@ do_jump_by_parts_zero_rtx (machine_mode mode, rtx op0,
static void
do_jump_by_parts_equality_rtx (machine_mode mode, rtx op0, rtx op1,
- rtx if_false_label, rtx if_true_label, int prob)
+ rtx_code_label *if_false_label,
+ rtx_code_label *if_true_label, int prob)
{
int nwords = (GET_MODE_SIZE (mode) / UNITS_PER_WORD);
- rtx drop_through_label = 0;
+ rtx_code_label *drop_through_label = NULL;
int i;
if (op1 == const0_rtx)
@@ -853,7 +864,7 @@ do_jump_by_parts_equality_rtx (machine_mode mode, rtx op0, rtx op1,
do_compare_rtx_and_jump (operand_subword_force (op0, i, mode),
operand_subword_force (op1, i, mode),
EQ, 0, word_mode, NULL_RTX,
- if_false_label, NULL_RTX, prob);
+ if_false_label, NULL, prob);
if (if_true_label)
emit_jump (if_true_label);
@@ -865,8 +876,9 @@ do_jump_by_parts_equality_rtx (machine_mode mode, rtx op0, rtx op1,
with one insn, test the comparison and jump to the appropriate label. */
static void
-do_jump_by_parts_equality (tree treeop0, tree treeop1, rtx if_false_label,
- rtx if_true_label, int prob)
+do_jump_by_parts_equality (tree treeop0, tree treeop1,
+ rtx_code_label *if_false_label,
+ rtx_code_label *if_true_label, int prob)
{
rtx op0 = expand_normal (treeop0);
rtx op1 = expand_normal (treeop1);
@@ -961,11 +973,12 @@ split_comparison (enum rtx_code code, machine_mode mode,
void
do_compare_rtx_and_jump (rtx op0, rtx op1, enum rtx_code code, int unsignedp,
- machine_mode mode, rtx size, rtx if_false_label,
- rtx if_true_label, int prob)
+ machine_mode mode, rtx size,
+ rtx_code_label *if_false_label,
+ rtx_code_label *if_true_label, int prob)
{
rtx tem;
- rtx dummy_label = NULL;
+ rtx_code_label *dummy_label = NULL;
/* Reverse the comparison if that is safe and we want to jump if it is
false. Also convert to the reverse comparison if the target can
@@ -1010,8 +1023,9 @@ do_compare_rtx_and_jump (rtx op0, rtx op1, enum rtx_code code, int unsignedp,
{
if (CONSTANT_P (tem))
{
- rtx label = (tem == const0_rtx || tem == CONST0_RTX (mode))
- ? if_false_label : if_true_label;
+ rtx_code_label *label = (tem == const0_rtx
+ || tem == CONST0_RTX (mode))
+ ? if_false_label : if_true_label;
if (label)
emit_jump (label);
return;
@@ -1127,7 +1141,7 @@ do_compare_rtx_and_jump (rtx op0, rtx op1, enum rtx_code code, int unsignedp,
first_prob = REG_BR_PROB_BASE - REG_BR_PROB_BASE / 100;
if (and_them)
{
- rtx dest_label;
+ rtx_code_label *dest_label;
/* If we only jump if true, just bypass the second jump. */
if (! if_false_label)
{
@@ -1138,13 +1152,11 @@ do_compare_rtx_and_jump (rtx op0, rtx op1, enum rtx_code code, int unsignedp,
else
dest_label = if_false_label;
do_compare_rtx_and_jump (op0, op1, first_code, unsignedp, mode,
- size, dest_label, NULL_RTX,
- first_prob);
+ size, dest_label, NULL, first_prob);
}
else
do_compare_rtx_and_jump (op0, op1, first_code, unsignedp, mode,
- size, NULL_RTX, if_true_label,
- first_prob);
+ size, NULL, if_true_label, first_prob);
}
}
@@ -1170,8 +1182,9 @@ do_compare_rtx_and_jump (rtx op0, rtx op1, enum rtx_code code, int unsignedp,
static void
do_compare_and_jump (tree treeop0, tree treeop1, enum rtx_code signed_code,
- enum rtx_code unsigned_code, rtx if_false_label,
- rtx if_true_label, int prob)
+ enum rtx_code unsigned_code,
+ rtx_code_label *if_false_label,
+ rtx_code_label *if_true_label, int prob)
{
rtx op0, op1;
tree type;