diff options
author | Richard Sandiford <richard.sandiford@linaro.org> | 2017-08-30 11:08:44 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2017-08-30 11:08:44 +0000 |
commit | c94843d2422bdf77e2f86fad0329838f36773b43 (patch) | |
tree | 8b8124bc4e42d00aabe44407a57a8b8faa945a60 /gcc/optabs.c | |
parent | b77d1a175f94eb49f62a02c4a54fe617e1cd3363 (diff) | |
download | gcc-c94843d2422bdf77e2f86fad0329838f36773b43.zip gcc-c94843d2422bdf77e2f86fad0329838f36773b43.tar.gz gcc-c94843d2422bdf77e2f86fad0329838f36773b43.tar.bz2 |
[4/77] Add FOR_EACH iterators for modes
The new iterators are:
- FOR_EACH_MODE_IN_CLASS: iterate over all the modes in a mode class.
- FOR_EACH_MODE_FROM: iterate over all the modes in a class,
starting at a given mode.
- FOR_EACH_WIDER_MODE: iterate over all the modes in a class,
starting at the next widest mode after a given mode.
- FOR_EACH_2XWIDER_MODE: same, but considering only modes that
are two times wider than the previous mode.
- FOR_EACH_MODE_UNTIL: iterate over all the modes in a class until
a given mode is reached.
- FOR_EACH_MODE: iterate over all the modes in a class between
two given modes, inclusive of the first but not the second.
These help with the stronger type checking added by later patches,
since every new mode will be in the same class as the previous one.
2017-08-30 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
gcc/
* machmode.h (mode_traits): New structure.
(get_narrowest_mode): New function.
(mode_iterator::start): Likewise.
(mode_iterator::iterate_p): Likewise.
(mode_iterator::get_wider): Likewise.
(mode_iterator::get_known_wider): Likewise.
(mode_iterator::get_2xwider): Likewise.
(FOR_EACH_MODE_IN_CLASS): New mode iterator.
(FOR_EACH_MODE): Likewise.
(FOR_EACH_MODE_FROM): Likewise.
(FOR_EACH_MODE_UNTIL): Likewise.
(FOR_EACH_WIDER_MODE): Likewise.
(FOR_EACH_2XWIDER_MODE): Likewise.
* builtins.c (expand_builtin_strlen): Use new mode iterators.
* combine.c (simplify_comparison): Likewise
* config/i386/i386.c (type_natural_mode): Likewise.
* cse.c (cse_insn): Likewise.
* dse.c (find_shift_sequence): Likewise.
* emit-rtl.c (init_derived_machine_modes): Likewise.
(init_emit_once): Likewise.
* explow.c (hard_function_value): Likewise.
* expmed.c (extract_fixed_bit_field_1): Likewise.
(extract_bit_field_1): Likewise.
(expand_divmod): Likewise.
(emit_store_flag_1): Likewise.
* expr.c (init_expr_target): Likewise.
(convert_move): Likewise.
(alignment_for_piecewise_move): Likewise.
(widest_int_mode_for_size): Likewise.
(emit_block_move_via_movmem): Likewise.
(copy_blkmode_to_reg): Likewise.
(set_storage_via_setmem): Likewise.
(compress_float_constant): Likewise.
* omp-low.c (omp_clause_aligned_alignment): Likewise.
* optabs-query.c (get_best_extraction_insn): Likewise.
* optabs.c (expand_binop): Likewise.
(expand_twoval_unop): Likewise.
(expand_twoval_binop): Likewise.
(widen_leading): Likewise.
(widen_bswap): Likewise.
(expand_parity): Likewise.
(expand_unop): Likewise.
(prepare_cmp_insn): Likewise.
(prepare_float_lib_cmp): Likewise.
(expand_float): Likewise.
(expand_fix): Likewise.
(expand_sfix_optab): Likewise.
* postreload.c (move2add_use_add2_insn): Likewise.
* reg-stack.c (reg_to_stack): Likewise.
* reginfo.c (choose_hard_reg_mode): Likewise.
* rtlanal.c (init_num_sign_bit_copies_in_rep): Likewise.
* stor-layout.c (mode_for_size): Likewise.
(smallest_mode_for_size): Likewise.
(mode_for_vector): Likewise.
(finish_bitfield_representative): Likewise.
* tree-ssa-math-opts.c (target_supports_divmod_p): Likewise.
* tree-vect-generic.c (type_for_widest_vector_mode): Likewise.
* tree-vect-stmts.c (vectorizable_conversion): Likewise.
* var-tracking.c (prepare_call_arguments): Likewise.
gcc/ada/
* gcc-interface/misc.c (fp_prec_to_size): Use new mode iterators.
(fp_size_to_prec): Likewise.
gcc/c-family/
* c-common.c (c_common_fixed_point_type_for_size): Use new mode
iterators.
* c-cppbuiltin.c (c_cpp_builtins): Likewise.
Co-Authored-By: Alan Hayward <alan.hayward@arm.com>
Co-Authored-By: David Sherwood <david.sherwood@arm.com>
From-SVN: r251455
Diffstat (limited to 'gcc/optabs.c')
-rw-r--r-- | gcc/optabs.c | 74 |
1 files changed, 21 insertions, 53 deletions
diff --git a/gcc/optabs.c b/gcc/optabs.c index 71b74dd..ce419d3 100644 --- a/gcc/optabs.c +++ b/gcc/optabs.c @@ -1251,9 +1251,7 @@ expand_binop (machine_mode mode, optab binoptab, rtx op0, rtx op1, if (CLASS_HAS_WIDER_MODES_P (mclass) && methods != OPTAB_DIRECT && methods != OPTAB_LIB) - for (wider_mode = GET_MODE_WIDER_MODE (mode); - wider_mode != VOIDmode; - wider_mode = GET_MODE_WIDER_MODE (wider_mode)) + FOR_EACH_WIDER_MODE (wider_mode, mode) { if (optab_handler (binoptab, wider_mode) != CODE_FOR_nothing || (binoptab == smul_optab @@ -1794,9 +1792,7 @@ expand_binop (machine_mode mode, optab binoptab, rtx op0, rtx op1, if (CLASS_HAS_WIDER_MODES_P (mclass)) { - for (wider_mode = GET_MODE_WIDER_MODE (mode); - wider_mode != VOIDmode; - wider_mode = GET_MODE_WIDER_MODE (wider_mode)) + FOR_EACH_WIDER_MODE (wider_mode, mode) { if (find_widening_optab_handler (binoptab, wider_mode, mode, 1) != CODE_FOR_nothing @@ -1952,9 +1948,7 @@ expand_twoval_unop (optab unoptab, rtx op0, rtx targ0, rtx targ1, if (CLASS_HAS_WIDER_MODES_P (mclass)) { - for (wider_mode = GET_MODE_WIDER_MODE (mode); - wider_mode != VOIDmode; - wider_mode = GET_MODE_WIDER_MODE (wider_mode)) + FOR_EACH_WIDER_MODE (wider_mode, mode) { if (optab_handler (unoptab, wider_mode) != CODE_FOR_nothing) { @@ -2035,9 +2029,7 @@ expand_twoval_binop (optab binoptab, rtx op0, rtx op1, rtx targ0, rtx targ1, if (CLASS_HAS_WIDER_MODES_P (mclass)) { - for (wider_mode = GET_MODE_WIDER_MODE (mode); - wider_mode != VOIDmode; - wider_mode = GET_MODE_WIDER_MODE (wider_mode)) + FOR_EACH_WIDER_MODE (wider_mode, mode) { if (optab_handler (binoptab, wider_mode) != CODE_FOR_nothing) { @@ -2139,9 +2131,7 @@ widen_leading (machine_mode mode, rtx op0, rtx target, optab unoptab) if (CLASS_HAS_WIDER_MODES_P (mclass)) { machine_mode wider_mode; - for (wider_mode = GET_MODE_WIDER_MODE (mode); - wider_mode != VOIDmode; - wider_mode = GET_MODE_WIDER_MODE (wider_mode)) + FOR_EACH_WIDER_MODE (wider_mode, mode) { if (optab_handler (unoptab, wider_mode) != CODE_FOR_nothing) { @@ -2311,9 +2301,7 @@ widen_bswap (machine_mode mode, rtx op0, rtx target) if (!CLASS_HAS_WIDER_MODES_P (mclass)) return NULL_RTX; - for (wider_mode = GET_MODE_WIDER_MODE (mode); - wider_mode != VOIDmode; - wider_mode = GET_MODE_WIDER_MODE (wider_mode)) + FOR_EACH_WIDER_MODE (wider_mode, mode) if (optab_handler (bswap_optab, wider_mode) != CODE_FOR_nothing) goto found; return NULL_RTX; @@ -2375,8 +2363,7 @@ expand_parity (machine_mode mode, rtx op0, rtx target) if (CLASS_HAS_WIDER_MODES_P (mclass)) { machine_mode wider_mode; - for (wider_mode = mode; wider_mode != VOIDmode; - wider_mode = GET_MODE_WIDER_MODE (wider_mode)) + FOR_EACH_MODE_FROM (wider_mode, mode) { if (optab_handler (popcount_optab, wider_mode) != CODE_FOR_nothing) { @@ -2828,9 +2815,7 @@ expand_unop (machine_mode mode, optab unoptab, rtx op0, rtx target, } if (CLASS_HAS_WIDER_MODES_P (mclass)) - for (wider_mode = GET_MODE_WIDER_MODE (mode); - wider_mode != VOIDmode; - wider_mode = GET_MODE_WIDER_MODE (wider_mode)) + FOR_EACH_WIDER_MODE (wider_mode, mode) { if (optab_handler (unoptab, wider_mode) != CODE_FOR_nothing) { @@ -2997,9 +2982,7 @@ expand_unop (machine_mode mode, optab unoptab, rtx op0, rtx target, if (CLASS_HAS_WIDER_MODES_P (mclass)) { - for (wider_mode = GET_MODE_WIDER_MODE (mode); - wider_mode != VOIDmode; - wider_mode = GET_MODE_WIDER_MODE (wider_mode)) + FOR_EACH_WIDER_MODE (wider_mode, mode) { if (optab_handler (unoptab, wider_mode) != CODE_FOR_nothing || optab_libfunc (unoptab, wider_mode)) @@ -3800,9 +3783,7 @@ prepare_cmp_insn (rtx x, rtx y, enum rtx_code comparison, rtx size, /* Try to use a memory block compare insn - either cmpstr or cmpmem will do. */ - for (cmp_mode = GET_CLASS_NARROWEST_MODE (MODE_INT); - cmp_mode != VOIDmode; - cmp_mode = GET_MODE_WIDER_MODE (cmp_mode)) + FOR_EACH_MODE_IN_CLASS (cmp_mode, MODE_INT) { cmp_code = direct_optab_handler (cmpmem_optab, cmp_mode); if (cmp_code == CODE_FOR_nothing) @@ -3864,9 +3845,8 @@ prepare_cmp_insn (rtx x, rtx y, enum rtx_code comparison, rtx size, mclass = GET_MODE_CLASS (mode); test = gen_rtx_fmt_ee (comparison, VOIDmode, x, y); - cmp_mode = mode; - do - { + FOR_EACH_MODE_FROM (cmp_mode, mode) + { enum insn_code icode; icode = optab_handler (cbranch_optab, cmp_mode); if (icode != CODE_FOR_nothing @@ -3890,9 +3870,7 @@ prepare_cmp_insn (rtx x, rtx y, enum rtx_code comparison, rtx size, if (methods == OPTAB_DIRECT || !CLASS_HAS_WIDER_MODES_P (mclass)) break; - cmp_mode = GET_MODE_WIDER_MODE (cmp_mode); } - while (cmp_mode != VOIDmode); if (methods != OPTAB_LIB_WIDEN) goto fail; @@ -4075,9 +4053,7 @@ prepare_float_lib_cmp (rtx x, rtx y, enum rtx_code comparison, bool reversed_p = false; cmp_mode = targetm.libgcc_cmp_return_mode (); - for (mode = orig_mode; - mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_FROM (mode, orig_mode) { if (code_to_optab (comparison) && (libfunc = optab_libfunc (code_to_optab (comparison), mode))) @@ -4650,10 +4626,8 @@ expand_float (rtx to, rtx from, int unsignedp) wider mode. If the integer mode is wider than the mode of FROM, we can do the conversion signed even if the input is unsigned. */ - for (fmode = GET_MODE (to); fmode != VOIDmode; - fmode = GET_MODE_WIDER_MODE (fmode)) - for (imode = GET_MODE (from); imode != VOIDmode; - imode = GET_MODE_WIDER_MODE (imode)) + FOR_EACH_MODE_FROM (fmode, GET_MODE (to)) + FOR_EACH_MODE_FROM (imode, GET_MODE (from)) { int doing_unsigned = unsignedp; @@ -4700,8 +4674,7 @@ expand_float (rtx to, rtx from, int unsignedp) least as wide as the target. Using FMODE will avoid rounding woes with unsigned values greater than the signed maximum value. */ - for (fmode = GET_MODE (to); fmode != VOIDmode; - fmode = GET_MODE_WIDER_MODE (fmode)) + FOR_EACH_MODE_FROM (fmode, GET_MODE (to)) if (GET_MODE_PRECISION (GET_MODE (from)) < GET_MODE_BITSIZE (fmode) && can_float_p (fmode, GET_MODE (from), 0) != CODE_FOR_nothing) break; @@ -4848,10 +4821,8 @@ expand_fix (rtx to, rtx from, int unsignedp) this conversion. If the integer mode is wider than the mode of TO, we can do the conversion either signed or unsigned. */ - for (fmode = GET_MODE (from); fmode != VOIDmode; - fmode = GET_MODE_WIDER_MODE (fmode)) - for (imode = GET_MODE (to); imode != VOIDmode; - imode = GET_MODE_WIDER_MODE (imode)) + FOR_EACH_MODE_FROM (fmode, GET_MODE (from)) + FOR_EACH_MODE_FROM (imode, GET_MODE (to)) { int doing_unsigned = unsignedp; @@ -4911,8 +4882,7 @@ expand_fix (rtx to, rtx from, int unsignedp) simply clears out that bit. The rest is trivial. */ if (unsignedp && GET_MODE_PRECISION (GET_MODE (to)) <= HOST_BITS_PER_WIDE_INT) - for (fmode = GET_MODE (from); fmode != VOIDmode; - fmode = GET_MODE_WIDER_MODE (fmode)) + FOR_EACH_MODE_FROM (fmode, GET_MODE (from)) if (CODE_FOR_nothing != can_fix_p (GET_MODE (to), fmode, 0, &must_trunc) && (!DECIMAL_FLOAT_MODE_P (fmode) || GET_MODE_BITSIZE (fmode) > GET_MODE_PRECISION (GET_MODE (to)))) @@ -5113,10 +5083,8 @@ expand_sfix_optab (rtx to, rtx from, convert_optab tab) this conversion. If the integer mode is wider than the mode of TO, we can do the conversion either signed or unsigned. */ - for (fmode = GET_MODE (from); fmode != VOIDmode; - fmode = GET_MODE_WIDER_MODE (fmode)) - for (imode = GET_MODE (to); imode != VOIDmode; - imode = GET_MODE_WIDER_MODE (imode)) + FOR_EACH_MODE_FROM (fmode, GET_MODE (from)) + FOR_EACH_MODE_FROM (imode, GET_MODE (to)) { icode = convert_optab_handler (tab, imode, fmode); if (icode != CODE_FOR_nothing) |