[PATCH 096/236] optabs.c: Use rtx_insn and rtx_code_label
David Malcolm
dmalcolm@redhat.com
Wed Aug 6 17:39:00 GMT 2014
gcc/
* optabs.c (expand_doubleword_shift): Strengthen local "insn" from
rtx to rtx_insn *.
(expand_binop): Likewise for locals "entry_last", "last", "insns"
(expand_twoval_unop): Likewise for locals entry_last", "last".
(expand_twoval_binop): Likewise.
(expand_twoval_binop_libfunc): Likewise for local "insns".
(widen_leading): Likewise for local "last".
(expand_doubleword_clz): Likewise for local "seq". Strengthen
locals "hi0_label", "after_label" from rtx to rtx_code_label *.
(widen_bswap): Strengthen local "last" from rtx to rtx_insn *.
(expand_parity): Likewise for locals "last" and "seq".
(expand_ffs): Likewise for local "seq". Strengthen local
"nonzero_label" from rtx to rtx_code_label *.
(expand_absneg_bit): Strengthen local "insns" from rtx to
rtx_insn *.
(expand_unop_direct): Likewise for local "last".
(expand_unop): Likewise for locals "last", "insns".
(expand_abs_nojump): Likewise for local "last".
(expand_abs): Strengthen local "op1" from rtx to rtx_code_label *.
(expand_one_cmpl_abs_nojump): Strengthen local "last" from rtx to
rtx_insn *.
(expand_copysign_absneg): Strengthen local "label" from rtx to
rtx_code_label *.
(expand_copysign_bit): Strengthen local "insns" from rtx to
rtx_insn *.
(struct no_conflict_data): Likewise for fields "first", "insn".
(emit_libcall_block_1): Likewise for param "insns" and locals
"next", "last", "insn".
(emit_libcall_block): For now, add a checked cast to rtx_insn *
on "insns" when invoking emit_libcall_block_1. Ultimately we
want to strengthen insns itself.
(prepare_cmp_insn): Strengthen local "last" from rtx to
rtx_insn *.
(emit_cmp_and_jump_insn_1): Likewise for local "insn".
(prepare_float_lib_cmp): Likewise for local "insns".
(emit_conditional_move): Likewise for local "last".
(emit_conditional_add): Likewise.
(have_sub2_insn): Likewise for local "seq".
(expand_float): Likewise for local "insns". Strengthen locals
"label", "neglabel" from rtx to rtx_code_label *.
(expand_fix): Likewise for locals "last", "insn", "insns" (to
rtx_insn *) and locals "lab1", "lab2" (to rtx_code_label *).
(expand_fixed_convert): Likewise for local "insns" (to
rtx_insn *).
(expand_sfix_optab): Likewise for local "last".
(expand_compare_and_swap_loop): Strengthen local "label" from rtx
to rtx_code_label *.
(maybe_emit_sync_lock_test_and_set): Strengthen local "last_insn"
from rtx to rtx_insn *.
(expand_atomic_fetch_op): Likewise for local "insn".
(maybe_legitimize_operand_same_code): Likewise for local "last".
(maybe_legitimize_operands): Likewise.
---
gcc/optabs.c | 134 ++++++++++++++++++++++++++++++++++-------------------------
1 file changed, 77 insertions(+), 57 deletions(-)
diff --git a/gcc/optabs.c b/gcc/optabs.c
index 24fc015..f098616 100644
--- a/gcc/optabs.c
+++ b/gcc/optabs.c
@@ -59,7 +59,7 @@ struct target_libfuncs *this_target_libfuncs = &default_target_libfuncs;
static void prepare_float_lib_cmp (rtx, rtx, enum rtx_code, rtx *,
enum machine_mode *);
static rtx expand_unop_direct (enum machine_mode, optab, rtx, rtx, int);
-static void emit_libcall_block_1 (rtx, rtx, rtx, rtx, bool);
+static void emit_libcall_block_1 (rtx_insn *, rtx, rtx, rtx, bool);
/* Debug facility for use in GDB. */
void debug_optab_libfuncs (void);
@@ -1102,7 +1102,7 @@ expand_doubleword_shift (enum machine_mode op1_mode, optab binoptab,
#ifdef HAVE_conditional_move
/* Try using conditional moves to generate straight-line code. */
{
- rtx start = get_last_insn ();
+ rtx_insn *start = get_last_insn ();
if (expand_doubleword_shift_condmove (op1_mode, binoptab,
cmp_code, cmp1, cmp2,
outof_input, into_input,
@@ -1540,8 +1540,8 @@ expand_binop (enum machine_mode mode, optab binoptab, rtx op0, rtx op1,
enum machine_mode wider_mode;
rtx libfunc;
rtx temp;
- rtx entry_last = get_last_insn ();
- rtx last;
+ rtx_insn *entry_last = get_last_insn ();
+ rtx_insn *last;
mclass = GET_MODE_CLASS (mode);
@@ -1737,7 +1737,7 @@ expand_binop (enum machine_mode mode, optab binoptab, rtx op0, rtx op1,
&& optab_handler (binoptab, word_mode) != CODE_FOR_nothing)
{
int i;
- rtx insns;
+ rtx_insn *insns;
/* If TARGET is the same as one of the operands, the REG_EQUAL note
won't be accurate, so use a new target. */
@@ -1806,7 +1806,7 @@ expand_binop (enum machine_mode mode, optab binoptab, rtx op0, rtx op1,
|| (shift_mask == BITS_PER_WORD - 1
&& double_shift_mask == BITS_PER_WORD * 2 - 1))
{
- rtx insns;
+ rtx_insn *insns;
rtx into_target, outof_target;
rtx into_input, outof_input;
int left_shift, outof_word;
@@ -1858,7 +1858,7 @@ expand_binop (enum machine_mode mode, optab binoptab, rtx op0, rtx op1,
&& optab_handler (ashl_optab, word_mode) != CODE_FOR_nothing
&& optab_handler (lshr_optab, word_mode) != CODE_FOR_nothing)
{
- rtx insns;
+ rtx_insn *insns;
rtx into_target, outof_target;
rtx into_input, outof_input;
rtx inter;
@@ -2143,7 +2143,7 @@ expand_binop (enum machine_mode mode, optab binoptab, rtx op0, rtx op1,
if (libfunc
&& (methods == OPTAB_LIB || methods == OPTAB_LIB_WIDEN))
{
- rtx insns;
+ rtx_insn *insns;
rtx op1x = op1;
enum machine_mode op1_mode = mode;
rtx value;
@@ -2331,8 +2331,8 @@ expand_twoval_unop (optab unoptab, rtx op0, rtx targ0, rtx targ1,
enum machine_mode mode = GET_MODE (targ0 ? targ0 : targ1);
enum mode_class mclass;
enum machine_mode wider_mode;
- rtx entry_last = get_last_insn ();
- rtx last;
+ rtx_insn *entry_last = get_last_insn ();
+ rtx_insn *last;
mclass = GET_MODE_CLASS (mode);
@@ -2405,8 +2405,8 @@ expand_twoval_binop (optab binoptab, rtx op0, rtx op1, rtx targ0, rtx targ1,
enum machine_mode mode = GET_MODE (targ0 ? targ0 : targ1);
enum mode_class mclass;
enum machine_mode wider_mode;
- rtx entry_last = get_last_insn ();
- rtx last;
+ rtx_insn *entry_last = get_last_insn ();
+ rtx_insn *last;
mclass = GET_MODE_CLASS (mode);
@@ -2487,7 +2487,7 @@ expand_twoval_binop_libfunc (optab binoptab, rtx op0, rtx op1,
enum machine_mode mode;
enum machine_mode libval_mode;
rtx libval;
- rtx insns;
+ rtx_insn *insns;
rtx libfunc;
/* Exactly one of TARG0 or TARG1 should be non-NULL. */
@@ -2553,7 +2553,8 @@ widen_leading (enum machine_mode mode, rtx op0, rtx target, optab unoptab)
{
if (optab_handler (unoptab, wider_mode) != CODE_FOR_nothing)
{
- rtx xop0, temp, last;
+ rtx xop0, temp;
+ rtx_insn *last;
last = get_last_insn ();
@@ -2588,9 +2589,10 @@ expand_doubleword_clz (enum machine_mode mode, rtx op0, rtx target)
rtx xop0 = force_reg (mode, op0);
rtx subhi = gen_highpart (word_mode, xop0);
rtx sublo = gen_lowpart (word_mode, xop0);
- rtx hi0_label = gen_label_rtx ();
- rtx after_label = gen_label_rtx ();
- rtx seq, temp, result;
+ rtx_code_label *hi0_label = gen_label_rtx ();
+ rtx_code_label *after_label = gen_label_rtx ();
+ rtx_insn *seq;
+ rtx temp, result;
/* If we were not given a target, use a word_mode register, not a
'mode' register. The result will fit, and nobody is expecting
@@ -2659,7 +2661,8 @@ widen_bswap (enum machine_mode mode, rtx op0, rtx target)
{
enum mode_class mclass = GET_MODE_CLASS (mode);
enum machine_mode wider_mode;
- rtx x, last;
+ rtx x;
+ rtx_insn *last;
if (!CLASS_HAS_WIDER_MODES_P (mclass))
return NULL_RTX;
@@ -2733,7 +2736,8 @@ expand_parity (enum machine_mode mode, rtx op0, rtx target)
{
if (optab_handler (popcount_optab, wider_mode) != CODE_FOR_nothing)
{
- rtx xop0, temp, last;
+ rtx xop0, temp;
+ rtx_insn *last;
last = get_last_insn ();
@@ -2770,7 +2774,8 @@ expand_parity (enum machine_mode mode, rtx op0, rtx target)
static rtx
expand_ctz (enum machine_mode mode, rtx op0, rtx target)
{
- rtx seq, temp;
+ rtx_insn *seq;
+ rtx temp;
if (optab_handler (clz_optab, mode) == CODE_FOR_nothing)
return 0;
@@ -2814,7 +2819,8 @@ expand_ffs (enum machine_mode mode, rtx op0, rtx target)
{
HOST_WIDE_INT val = 0;
bool defined_at_zero = false;
- rtx temp, seq;
+ rtx temp;
+ rtx_insn *seq;
if (optab_handler (ctz_optab, mode) != CODE_FOR_nothing)
{
@@ -2856,7 +2862,7 @@ expand_ffs (enum machine_mode mode, rtx op0, rtx target)
the operation sets condition codes that can be recycled for this.
(This is true on i386, for instance.) */
- rtx nonzero_label = gen_label_rtx ();
+ rtx_code_label *nonzero_label = gen_label_rtx ();
emit_cmp_and_jump_insns (op0, CONST0_RTX (mode), NE, 0,
mode, true, nonzero_label);
@@ -2913,7 +2919,8 @@ expand_absneg_bit (enum rtx_code code, enum machine_mode mode,
const struct real_format *fmt;
int bitpos, word, nwords, i;
enum machine_mode imode;
- rtx temp, insns;
+ rtx temp;
+ rtx_insn *insns;
/* The format has to have a simple sign bit. */
fmt = REAL_MODE_FORMAT (mode);
@@ -3010,7 +3017,7 @@ expand_unop_direct (enum machine_mode mode, optab unoptab, rtx op0, rtx target,
{
struct expand_operand ops[2];
enum insn_code icode = optab_handler (unoptab, mode);
- rtx last = get_last_insn ();
+ rtx_insn *last = get_last_insn ();
rtx pat;
create_output_operand (&ops[0], target, mode);
@@ -3095,7 +3102,8 @@ expand_unop (enum machine_mode mode, optab unoptab, rtx op0, rtx target,
be always more efficient than the other fallback methods. */
if (mode == HImode)
{
- rtx last, temp1, temp2;
+ rtx_insn *last;
+ rtx temp1, temp2;
if (optab_handler (rotl_optab, mode) != CODE_FOR_nothing)
{
@@ -3153,7 +3161,7 @@ expand_unop (enum machine_mode mode, optab unoptab, rtx op0, rtx target,
if (optab_handler (unoptab, wider_mode) != CODE_FOR_nothing)
{
rtx xop0 = op0;
- rtx last = get_last_insn ();
+ rtx_insn *last = get_last_insn ();
/* For certain operations, we need not actually extend
the narrow operand, as long as we will truncate the
@@ -3192,7 +3200,7 @@ expand_unop (enum machine_mode mode, optab unoptab, rtx op0, rtx target,
&& optab_handler (unoptab, word_mode) != CODE_FOR_nothing)
{
int i;
- rtx insns;
+ rtx_insn *insns;
if (target == 0 || target == op0 || !valid_multiword_target_p (target))
target = gen_reg_rtx (mode);
@@ -3270,7 +3278,7 @@ expand_unop (enum machine_mode mode, optab unoptab, rtx op0, rtx target,
libfunc = optab_libfunc (unoptab, mode);
if (libfunc)
{
- rtx insns;
+ rtx_insn *insns;
rtx value;
rtx eq_value;
enum machine_mode outmode = mode;
@@ -3317,7 +3325,7 @@ expand_unop (enum machine_mode mode, optab unoptab, rtx op0, rtx target,
|| optab_libfunc (unoptab, wider_mode))
{
rtx xop0 = op0;
- rtx last = get_last_insn ();
+ rtx_insn *last = get_last_insn ();
/* For certain operations, we need not actually extend
the narrow operand, as long as we will truncate the
@@ -3427,7 +3435,7 @@ expand_abs_nojump (enum machine_mode mode, rtx op0, rtx target,
if (optab_handler (smax_optab, mode) != CODE_FOR_nothing
&& !HONOR_SIGNED_ZEROS (mode))
{
- rtx last = get_last_insn ();
+ rtx_insn *last = get_last_insn ();
temp = expand_unop (mode, result_unsignedp ? neg_optab : negv_optab,
op0, NULL_RTX, 0);
@@ -3470,7 +3478,8 @@ rtx
expand_abs (enum machine_mode mode, rtx op0, rtx target,
int result_unsignedp, int safe)
{
- rtx temp, op1;
+ rtx temp;
+ rtx_code_label *op1;
if (GET_MODE_CLASS (mode) != MODE_INT
|| ! flag_trapv)
@@ -3531,7 +3540,7 @@ expand_one_cmpl_abs_nojump (enum machine_mode mode, rtx op0, rtx target)
/* If we have a MAX insn, we can do this as MAX (x, ~x). */
if (optab_handler (smax_optab, mode) != CODE_FOR_nothing)
{
- rtx last = get_last_insn ();
+ rtx_insn *last = get_last_insn ();
temp = expand_unop (mode, one_cmpl_optab, op0, NULL_RTX, 0);
if (temp != 0)
@@ -3576,7 +3585,8 @@ expand_copysign_absneg (enum machine_mode mode, rtx op0, rtx op1, rtx target,
{
enum machine_mode imode;
enum insn_code icode;
- rtx sign, label;
+ rtx sign;
+ rtx_code_label *label;
if (target == op1)
target = NULL_RTX;
@@ -3659,7 +3669,8 @@ expand_copysign_bit (enum machine_mode mode, rtx op0, rtx op1, rtx target,
{
enum machine_mode imode;
int word, nwords, i;
- rtx temp, insns;
+ rtx temp;
+ rtx_insn *insns;
if (GET_MODE_SIZE (mode) <= UNITS_PER_WORD)
{
@@ -3839,7 +3850,8 @@ emit_unop_insn (enum insn_code icode, rtx target, rtx op0, enum rtx_code code)
struct no_conflict_data
{
- rtx target, first, insn;
+ rtx target;
+ rtx_insn *first, *insn;
bool must_stay;
};
@@ -3891,11 +3903,11 @@ no_conflict_move_test (rtx dest, const_rtx set, void *p0)
note with an operand of EQUIV. */
static void
-emit_libcall_block_1 (rtx insns, rtx target, rtx result, rtx equiv,
+emit_libcall_block_1 (rtx_insn *insns, rtx target, rtx result, rtx equiv,
bool equiv_may_trap)
{
rtx final_dest = target;
- rtx next, last, insn;
+ rtx_insn *next, *last, *insn;
/* If this is a reg with REG_USERVAR_P set, then it could possibly turn
into a MEM later. Protect the libcall block from this change. */
@@ -3991,7 +4003,8 @@ emit_libcall_block_1 (rtx insns, rtx target, rtx result, rtx equiv,
void
emit_libcall_block (rtx insns, rtx target, rtx result, rtx equiv)
{
- emit_libcall_block_1 (insns, target, result, equiv, false);
+ emit_libcall_block_1 (as_a_nullable <rtx_insn *> (insns),
+ target, result, equiv, false);
}
/* Nonzero if we can perform a comparison of mode MODE straightforwardly.
@@ -4182,7 +4195,7 @@ prepare_cmp_insn (rtx x, rtx y, enum rtx_code comparison, rtx size,
if (icode != CODE_FOR_nothing
&& insn_operand_matches (icode, 0, test))
{
- rtx last = get_last_insn ();
+ rtx_insn *last = get_last_insn ();
rtx op0 = prepare_operand (icode, x, 1, mode, cmp_mode, unsignedp);
rtx op1 = prepare_operand (icode, y, 2, mode, cmp_mode, unsignedp);
if (op0 && op1
@@ -4294,7 +4307,7 @@ emit_cmp_and_jump_insn_1 (rtx test, enum machine_mode mode, rtx label, int prob)
enum machine_mode optab_mode;
enum mode_class mclass;
enum insn_code icode;
- rtx insn;
+ rtx_insn *insn;
mclass = GET_MODE_CLASS (mode);
optab_mode = (mclass == MODE_CC) ? CCmode : mode;
@@ -4375,7 +4388,8 @@ prepare_float_lib_cmp (rtx x, rtx y, enum rtx_code comparison,
enum machine_mode orig_mode = GET_MODE (x);
enum machine_mode mode, cmp_mode;
rtx true_rtx, false_rtx;
- rtx value, target, insns, equiv;
+ rtx value, target, equiv;
+ rtx_insn *insns;
rtx libfunc = 0;
bool reversed_p = false;
cmp_mode = targetm.libgcc_cmp_return_mode ();
@@ -4529,7 +4543,8 @@ emit_conditional_move (rtx target, enum rtx_code code, rtx op0, rtx op1,
enum machine_mode cmode, rtx op2, rtx op3,
enum machine_mode mode, int unsignedp)
{
- rtx tem, comparison, last;
+ rtx tem, comparison;
+ rtx_insn *last;
enum insn_code icode;
enum rtx_code reversed;
@@ -4650,7 +4665,8 @@ emit_conditional_add (rtx target, enum rtx_code code, rtx op0, rtx op1,
enum machine_mode cmode, rtx op2, rtx op3,
enum machine_mode mode, int unsignedp)
{
- rtx tem, comparison, last;
+ rtx tem, comparison;
+ rtx_insn *last;
enum insn_code icode;
/* If one operand is constant, make it the second one. Only do this
@@ -4868,7 +4884,7 @@ have_sub2_insn (rtx x, rtx y)
rtx
gen_move_insn (rtx x, rtx y)
{
- rtx seq;
+ rtx_insn *seq;
start_sequence ();
emit_move_insn_1 (x, y);
@@ -5074,7 +5090,7 @@ expand_float (rtx to, rtx from, int unsignedp)
then unconditionally adjust the result. */
if (unsignedp && can_do_signed)
{
- rtx label = gen_label_rtx ();
+ rtx_code_label *label = gen_label_rtx ();
rtx temp;
REAL_VALUE_TYPE offset;
@@ -5098,7 +5114,7 @@ expand_float (rtx to, rtx from, int unsignedp)
< GET_MODE_PRECISION (GET_MODE (from)))
{
rtx temp1;
- rtx neglabel = gen_label_rtx ();
+ rtx_code_label *neglabel = gen_label_rtx ();
/* Don't use TARGET if it isn't a register, is a hard register,
or is the wrong mode. */
@@ -5177,7 +5193,7 @@ expand_float (rtx to, rtx from, int unsignedp)
/* No hardware instruction available; call a library routine. */
{
rtx libfunc;
- rtx insns;
+ rtx_insn *insns;
rtx value;
convert_optab tab = unsignedp ? ufloat_optab : sfloat_optab;
@@ -5243,7 +5259,7 @@ expand_fix (rtx to, rtx from, int unsignedp)
if (icode != CODE_FOR_nothing)
{
- rtx last = get_last_insn ();
+ rtx_insn *last = get_last_insn ();
if (fmode != GET_MODE (from))
from = convert_to_mode (fmode, from, 0);
@@ -5301,7 +5317,9 @@ expand_fix (rtx to, rtx from, int unsignedp)
{
int bitsize;
REAL_VALUE_TYPE offset;
- rtx limit, lab1, lab2, insn;
+ rtx limit;
+ rtx_code_label *lab1, *lab2;
+ rtx_insn *insn;
bitsize = GET_MODE_PRECISION (GET_MODE (to));
real_2expN (&offset, bitsize - 1, fmode);
@@ -5365,7 +5383,7 @@ expand_fix (rtx to, rtx from, int unsignedp)
}
else
{
- rtx insns;
+ rtx_insn *insns;
rtx value;
rtx libfunc;
@@ -5407,7 +5425,8 @@ expand_fixed_convert (rtx to, rtx from, int uintp, int satp)
convert_optab tab;
enum rtx_code this_code;
enum insn_code code;
- rtx insns, value;
+ rtx_insn *insns;
+ rtx value;
rtx libfunc;
if (to_mode == from_mode)
@@ -5470,7 +5489,7 @@ expand_sfix_optab (rtx to, rtx from, convert_optab tab)
icode = convert_optab_handler (tab, imode, fmode);
if (icode != CODE_FOR_nothing)
{
- rtx last = get_last_insn ();
+ rtx_insn *last = get_last_insn ();
if (fmode != GET_MODE (from))
from = convert_to_mode (fmode, from, 0);
@@ -7082,7 +7101,8 @@ static bool
expand_compare_and_swap_loop (rtx mem, rtx old_reg, rtx new_reg, rtx seq)
{
enum machine_mode mode = GET_MODE (mem);
- rtx label, cmp_reg, success, oldval;
+ rtx_code_label *label;
+ rtx cmp_reg, success, oldval;
/* The loop we want to generate looks like
@@ -7162,7 +7182,7 @@ maybe_emit_sync_lock_test_and_set (rtx target, rtx mem, rtx val,
{
enum machine_mode mode = GET_MODE (mem);
enum insn_code icode;
- rtx last_insn = get_last_insn ();
+ rtx_insn *last_insn = get_last_insn ();
icode = optab_handler (sync_lock_test_and_set_optab, mode);
@@ -8073,7 +8093,7 @@ expand_atomic_fetch_op (rtx target, rtx mem, rtx val, enum rtx_code code,
/* If nothing else has succeeded, default to a compare and swap loop. */
if (can_compare_and_swap_p (mode, true))
{
- rtx insn;
+ rtx_insn *insn;
rtx t0 = gen_reg_rtx (mode), t1;
start_sequence ();
@@ -8166,7 +8186,7 @@ maybe_legitimize_operand_same_code (enum insn_code icode, unsigned int opno,
if (!(REG_P (addr) && REGNO (addr) > LAST_VIRTUAL_REGISTER)
&& !side_effects_p (addr))
{
- rtx last;
+ rtx_insn *last;
enum machine_mode mode;
last = get_last_insn ();
@@ -8280,7 +8300,7 @@ bool
maybe_legitimize_operands (enum insn_code icode, unsigned int opno,
unsigned int nops, struct expand_operand *ops)
{
- rtx last;
+ rtx_insn *last;
unsigned int i;
last = get_last_insn ();
--
1.8.5.3
More information about the Gcc-patches
mailing list