Introduce and use code_to_optab and optab_to_code functions
Removes all the direct uses of op->code so that we can change the representation of "optab". The code_to_optab change is simply for uniformity (and better type checking). * optabs.h (struct optab_d): Rename code member to code_. (struct convert_optab_h): Likewise. (code_to_optab_): Rename from code_to_optab. (code_to_optab, optab_to_code): New. * dojump.c (do_compare_rtx_and_jump): Use code_to_optab. * ifcvt.c (noce_emit_move_insn): Likewise. * optabs.c (simplify_expand_binop): Use optab_to_code. (expand_simple_binop, shift_optab_p, commutative_optab_p): Likewise. (avoid_expensive_constant, expand_binop_directly): Likewise. (expand_binop, expand_simple_unop, expand_unop_direct): Likewise. (expand_unop, prepare_float_lib_cmp, expand_fixed_convert): Likewise. (have_insn_for, debug_optab_libfuncs): Likewise. (init_optab, init_optabv, init_convert_optab): Update for optab member name change. From-SVN: r189818
This commit is contained in:
parent
723cd7abc6
commit
19b5fafb92
|
@ -1,5 +1,20 @@
|
||||||
2012-07-24 Richard Henderson <rth@redhat.com>
|
2012-07-24 Richard Henderson <rth@redhat.com>
|
||||||
|
|
||||||
|
* optabs.h (struct optab_d): Rename code member to code_.
|
||||||
|
(struct convert_optab_h): Likewise.
|
||||||
|
(code_to_optab_): Rename from code_to_optab.
|
||||||
|
(code_to_optab, optab_to_code): New.
|
||||||
|
* dojump.c (do_compare_rtx_and_jump): Use code_to_optab.
|
||||||
|
* ifcvt.c (noce_emit_move_insn): Likewise.
|
||||||
|
* optabs.c (simplify_expand_binop): Use optab_to_code.
|
||||||
|
(expand_simple_binop, shift_optab_p, commutative_optab_p): Likewise.
|
||||||
|
(avoid_expensive_constant, expand_binop_directly): Likewise.
|
||||||
|
(expand_binop, expand_simple_unop, expand_unop_direct): Likewise.
|
||||||
|
(expand_unop, prepare_float_lib_cmp, expand_fixed_convert): Likewise.
|
||||||
|
(have_insn_for, debug_optab_libfuncs): Likewise.
|
||||||
|
(init_optab, init_optabv, init_convert_optab): Update for optab
|
||||||
|
member name change.
|
||||||
|
|
||||||
* libfuncs.h: Include optabs.h.
|
* libfuncs.h: Include optabs.h.
|
||||||
* dwarf2out.c, lto-streamer.in.c: Don't include libfuncs.h.
|
* dwarf2out.c, lto-streamer.in.c: Don't include libfuncs.h.
|
||||||
* Makefile.in (LIBFUNCS_H): Add OPTABS_H.
|
* Makefile.in (LIBFUNCS_H): Add OPTABS_H.
|
||||||
|
|
|
@ -1037,7 +1037,7 @@ do_compare_rtx_and_jump (rtx op0, rtx op1, enum rtx_code code, int unsignedp,
|
||||||
we can jump on other conditions... */
|
we can jump on other conditions... */
|
||||||
&& (have_insn_for (COMPARE, mode)
|
&& (have_insn_for (COMPARE, mode)
|
||||||
/* ... or if there is no libcall for it. */
|
/* ... or if there is no libcall for it. */
|
||||||
|| code_to_optab[code] == unknown_optab))
|
|| code_to_optab (code) == unknown_optab))
|
||||||
{
|
{
|
||||||
enum rtx_code first_code;
|
enum rtx_code first_code;
|
||||||
bool and_them = split_comparison (code, mode, &first_code, &code);
|
bool and_them = split_comparison (code, mode, &first_code, &code);
|
||||||
|
|
|
@ -902,7 +902,7 @@ noce_emit_move_insn (rtx x, rtx y)
|
||||||
switch (GET_RTX_CLASS (GET_CODE (y)))
|
switch (GET_RTX_CLASS (GET_CODE (y)))
|
||||||
{
|
{
|
||||||
case RTX_UNARY:
|
case RTX_UNARY:
|
||||||
ot = code_to_optab[GET_CODE (y)];
|
ot = code_to_optab (GET_CODE (y));
|
||||||
if (ot)
|
if (ot)
|
||||||
{
|
{
|
||||||
start_sequence ();
|
start_sequence ();
|
||||||
|
@ -919,7 +919,7 @@ noce_emit_move_insn (rtx x, rtx y)
|
||||||
|
|
||||||
case RTX_BIN_ARITH:
|
case RTX_BIN_ARITH:
|
||||||
case RTX_COMM_ARITH:
|
case RTX_COMM_ARITH:
|
||||||
ot = code_to_optab[GET_CODE (y)];
|
ot = code_to_optab (GET_CODE (y));
|
||||||
if (ot)
|
if (ot)
|
||||||
{
|
{
|
||||||
start_sequence ();
|
start_sequence ();
|
||||||
|
|
64
gcc/optabs.c
64
gcc/optabs.c
|
@ -55,7 +55,7 @@ struct target_libfuncs *this_target_libfuncs = &default_target_libfuncs;
|
||||||
(this_target_libfuncs->x_libfunc_hash)
|
(this_target_libfuncs->x_libfunc_hash)
|
||||||
|
|
||||||
/* Contains the optab used for each rtx code. */
|
/* Contains the optab used for each rtx code. */
|
||||||
optab code_to_optab[NUM_RTX_CODE + 1];
|
optab code_to_optab_[NUM_RTX_CODE + 1];
|
||||||
|
|
||||||
static void prepare_float_lib_cmp (rtx, rtx, enum rtx_code, rtx *,
|
static void prepare_float_lib_cmp (rtx, rtx, enum rtx_code, rtx *,
|
||||||
enum machine_mode *);
|
enum machine_mode *);
|
||||||
|
@ -678,8 +678,8 @@ simplify_expand_binop (enum machine_mode mode, optab binoptab,
|
||||||
{
|
{
|
||||||
if (CONSTANT_P (op0) && CONSTANT_P (op1))
|
if (CONSTANT_P (op0) && CONSTANT_P (op1))
|
||||||
{
|
{
|
||||||
rtx x = simplify_binary_operation (binoptab->code, mode, op0, op1);
|
rtx x = simplify_binary_operation (optab_to_code (binoptab),
|
||||||
|
mode, op0, op1);
|
||||||
if (x)
|
if (x)
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
@ -1266,7 +1266,7 @@ expand_simple_binop (enum machine_mode mode, enum rtx_code code, rtx op0,
|
||||||
rtx op1, rtx target, int unsignedp,
|
rtx op1, rtx target, int unsignedp,
|
||||||
enum optab_methods methods)
|
enum optab_methods methods)
|
||||||
{
|
{
|
||||||
optab binop = code_to_optab[(int) code];
|
optab binop = code_to_optab (code);
|
||||||
gcc_assert (binop);
|
gcc_assert (binop);
|
||||||
|
|
||||||
return expand_binop (mode, binop, op0, op1, target, unsignedp, methods);
|
return expand_binop (mode, binop, op0, op1, target, unsignedp, methods);
|
||||||
|
@ -1300,7 +1300,7 @@ swap_commutative_operands_with_target (rtx target, rtx op0, rtx op1)
|
||||||
static bool
|
static bool
|
||||||
shift_optab_p (optab binoptab)
|
shift_optab_p (optab binoptab)
|
||||||
{
|
{
|
||||||
switch (binoptab->code)
|
switch (optab_to_code (binoptab))
|
||||||
{
|
{
|
||||||
case ASHIFT:
|
case ASHIFT:
|
||||||
case SS_ASHIFT:
|
case SS_ASHIFT:
|
||||||
|
@ -1321,7 +1321,7 @@ shift_optab_p (optab binoptab)
|
||||||
static bool
|
static bool
|
||||||
commutative_optab_p (optab binoptab)
|
commutative_optab_p (optab binoptab)
|
||||||
{
|
{
|
||||||
return (GET_RTX_CLASS (binoptab->code) == RTX_COMM_ARITH
|
return (GET_RTX_CLASS (optab_to_code (binoptab)) == RTX_COMM_ARITH
|
||||||
|| binoptab == smul_widen_optab
|
|| binoptab == smul_widen_optab
|
||||||
|| binoptab == umul_widen_optab
|
|| binoptab == umul_widen_optab
|
||||||
|| binoptab == smul_highpart_optab
|
|| binoptab == smul_highpart_optab
|
||||||
|
@ -1342,7 +1342,8 @@ avoid_expensive_constant (enum machine_mode mode, optab binoptab,
|
||||||
if (mode != VOIDmode
|
if (mode != VOIDmode
|
||||||
&& optimize
|
&& optimize
|
||||||
&& CONSTANT_P (x)
|
&& CONSTANT_P (x)
|
||||||
&& rtx_cost (x, binoptab->code, opn, speed) > set_src_cost (x, speed))
|
&& (rtx_cost (x, optab_to_code (binoptab), opn, speed)
|
||||||
|
> set_src_cost (x, speed)))
|
||||||
{
|
{
|
||||||
if (CONST_INT_P (x))
|
if (CONST_INT_P (x))
|
||||||
{
|
{
|
||||||
|
@ -1458,7 +1459,7 @@ expand_binop_directly (enum machine_mode mode, optab binoptab,
|
||||||
REG_EQUAL note to it. If we can't because TEMP conflicts with an
|
REG_EQUAL note to it. If we can't because TEMP conflicts with an
|
||||||
operand, call expand_binop again, this time without a target. */
|
operand, call expand_binop again, this time without a target. */
|
||||||
if (INSN_P (pat) && NEXT_INSN (pat) != NULL_RTX
|
if (INSN_P (pat) && NEXT_INSN (pat) != NULL_RTX
|
||||||
&& ! add_equal_note (pat, ops[0].value, binoptab->code,
|
&& ! add_equal_note (pat, ops[0].value, optab_to_code (binoptab),
|
||||||
ops[1].value, ops[2].value))
|
ops[1].value, ops[2].value))
|
||||||
{
|
{
|
||||||
delete_insns_since (last);
|
delete_insns_since (last);
|
||||||
|
@ -2029,8 +2030,8 @@ expand_binop (enum machine_mode mode, optab binoptab, rtx op0, rtx op1,
|
||||||
rtx temp = emit_move_insn (target, xtarget);
|
rtx temp = emit_move_insn (target, xtarget);
|
||||||
|
|
||||||
set_dst_reg_note (temp, REG_EQUAL,
|
set_dst_reg_note (temp, REG_EQUAL,
|
||||||
gen_rtx_fmt_ee (binoptab->code, mode,
|
gen_rtx_fmt_ee (optab_to_code (binoptab),
|
||||||
copy_rtx (xop0),
|
mode, copy_rtx (xop0),
|
||||||
copy_rtx (xop1)),
|
copy_rtx (xop1)),
|
||||||
target);
|
target);
|
||||||
}
|
}
|
||||||
|
@ -2128,7 +2129,8 @@ expand_binop (enum machine_mode mode, optab binoptab, rtx op0, rtx op1,
|
||||||
|
|
||||||
target = gen_reg_rtx (mode);
|
target = gen_reg_rtx (mode);
|
||||||
emit_libcall_block_1 (insns, target, value,
|
emit_libcall_block_1 (insns, target, value,
|
||||||
gen_rtx_fmt_ee (binoptab->code, mode, op0, op1),
|
gen_rtx_fmt_ee (optab_to_code (binoptab),
|
||||||
|
mode, op0, op1),
|
||||||
trapv_binoptab_p (binoptab));
|
trapv_binoptab_p (binoptab));
|
||||||
|
|
||||||
return target;
|
return target;
|
||||||
|
@ -2481,7 +2483,7 @@ rtx
|
||||||
expand_simple_unop (enum machine_mode mode, enum rtx_code code, rtx op0,
|
expand_simple_unop (enum machine_mode mode, enum rtx_code code, rtx op0,
|
||||||
rtx target, int unsignedp)
|
rtx target, int unsignedp)
|
||||||
{
|
{
|
||||||
optab unop = code_to_optab[(int) code];
|
optab unop = code_to_optab (code);
|
||||||
gcc_assert (unop);
|
gcc_assert (unop);
|
||||||
|
|
||||||
return expand_unop (mode, unop, op0, target, unsignedp);
|
return expand_unop (mode, unop, op0, target, unsignedp);
|
||||||
|
@ -2971,7 +2973,7 @@ expand_unop_direct (enum machine_mode mode, optab unoptab, rtx op0, rtx target,
|
||||||
if (pat)
|
if (pat)
|
||||||
{
|
{
|
||||||
if (INSN_P (pat) && NEXT_INSN (pat) != NULL_RTX
|
if (INSN_P (pat) && NEXT_INSN (pat) != NULL_RTX
|
||||||
&& ! add_equal_note (pat, ops[0].value, unoptab->code,
|
&& ! add_equal_note (pat, ops[0].value, optab_to_code (unoptab),
|
||||||
ops[1].value, NULL_RTX))
|
ops[1].value, NULL_RTX))
|
||||||
{
|
{
|
||||||
delete_insns_since (last);
|
delete_insns_since (last);
|
||||||
|
@ -3170,7 +3172,7 @@ expand_unop (enum machine_mode mode, optab unoptab, rtx op0, rtx target,
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unoptab->code == NEG)
|
if (optab_to_code (unoptab) == NEG)
|
||||||
{
|
{
|
||||||
/* Try negating floating point values by flipping the sign bit. */
|
/* Try negating floating point values by flipping the sign bit. */
|
||||||
if (SCALAR_FLOAT_MODE_P (mode))
|
if (SCALAR_FLOAT_MODE_P (mode))
|
||||||
|
@ -3246,7 +3248,7 @@ expand_unop (enum machine_mode mode, optab unoptab, rtx op0, rtx target,
|
||||||
end_sequence ();
|
end_sequence ();
|
||||||
|
|
||||||
target = gen_reg_rtx (outmode);
|
target = gen_reg_rtx (outmode);
|
||||||
eq_value = gen_rtx_fmt_e (unoptab->code, mode, op0);
|
eq_value = gen_rtx_fmt_e (optab_to_code (unoptab), mode, op0);
|
||||||
if (GET_MODE_SIZE (outmode) < GET_MODE_SIZE (mode))
|
if (GET_MODE_SIZE (outmode) < GET_MODE_SIZE (mode))
|
||||||
eq_value = simplify_gen_unary (TRUNCATE, outmode, eq_value, mode);
|
eq_value = simplify_gen_unary (TRUNCATE, outmode, eq_value, mode);
|
||||||
else if (GET_MODE_SIZE (outmode) > GET_MODE_SIZE (mode))
|
else if (GET_MODE_SIZE (outmode) > GET_MODE_SIZE (mode))
|
||||||
|
@ -3326,7 +3328,7 @@ expand_unop (enum machine_mode mode, optab unoptab, rtx op0, rtx target,
|
||||||
|
|
||||||
/* One final attempt at implementing negation via subtraction,
|
/* One final attempt at implementing negation via subtraction,
|
||||||
this time allowing widening of the operand. */
|
this time allowing widening of the operand. */
|
||||||
if (unoptab->code == NEG && !HONOR_SIGNED_ZEROS (mode))
|
if (optab_to_code (unoptab) == NEG && !HONOR_SIGNED_ZEROS (mode))
|
||||||
{
|
{
|
||||||
rtx temp;
|
rtx temp;
|
||||||
temp = expand_binop (mode,
|
temp = expand_binop (mode,
|
||||||
|
@ -4325,12 +4327,12 @@ prepare_float_lib_cmp (rtx x, rtx y, enum rtx_code comparison,
|
||||||
mode != VOIDmode;
|
mode != VOIDmode;
|
||||||
mode = GET_MODE_WIDER_MODE (mode))
|
mode = GET_MODE_WIDER_MODE (mode))
|
||||||
{
|
{
|
||||||
if (code_to_optab[comparison]
|
if (code_to_optab (comparison)
|
||||||
&& (libfunc = optab_libfunc (code_to_optab[comparison], mode)))
|
&& (libfunc = optab_libfunc (code_to_optab (comparison), mode)))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (code_to_optab[swapped]
|
if (code_to_optab (swapped)
|
||||||
&& (libfunc = optab_libfunc (code_to_optab[swapped], mode)))
|
&& (libfunc = optab_libfunc (code_to_optab (swapped), mode)))
|
||||||
{
|
{
|
||||||
rtx tmp;
|
rtx tmp;
|
||||||
tmp = x; x = y; y = tmp;
|
tmp = x; x = y; y = tmp;
|
||||||
|
@ -4338,8 +4340,8 @@ prepare_float_lib_cmp (rtx x, rtx y, enum rtx_code comparison,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code_to_optab[reversed]
|
if (code_to_optab (reversed)
|
||||||
&& (libfunc = optab_libfunc (code_to_optab[reversed], mode)))
|
&& (libfunc = optab_libfunc (code_to_optab (reversed), mode)))
|
||||||
{
|
{
|
||||||
comparison = reversed;
|
comparison = reversed;
|
||||||
reversed_p = true;
|
reversed_p = true;
|
||||||
|
@ -5355,7 +5357,7 @@ expand_fixed_convert (rtx to, rtx from, int uintp, int satp)
|
||||||
end_sequence ();
|
end_sequence ();
|
||||||
|
|
||||||
emit_libcall_block (insns, to, value,
|
emit_libcall_block (insns, to, value,
|
||||||
gen_rtx_fmt_e (tab->code, to_mode, from));
|
gen_rtx_fmt_e (optab_to_code (tab), to_mode, from));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Generate code to convert FROM to fixed point and store in TO. FROM
|
/* Generate code to convert FROM to fixed point and store in TO. FROM
|
||||||
|
@ -5408,8 +5410,8 @@ expand_sfix_optab (rtx to, rtx from, convert_optab tab)
|
||||||
int
|
int
|
||||||
have_insn_for (enum rtx_code code, enum machine_mode mode)
|
have_insn_for (enum rtx_code code, enum machine_mode mode)
|
||||||
{
|
{
|
||||||
return (code_to_optab[(int) code] != 0
|
return (code_to_optab (code)
|
||||||
&& (optab_handler (code_to_optab[(int) code], mode)
|
&& (optab_handler (code_to_optab (code), mode)
|
||||||
!= CODE_FOR_nothing));
|
!= CODE_FOR_nothing));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5427,8 +5429,8 @@ init_insn_codes (void)
|
||||||
static inline void
|
static inline void
|
||||||
init_optab (optab op, enum rtx_code code)
|
init_optab (optab op, enum rtx_code code)
|
||||||
{
|
{
|
||||||
op->code = code;
|
op->code_ = code;
|
||||||
code_to_optab[(int) code] = op;
|
code_to_optab_[(int) code] = op;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Same, but fill in its code as CODE, and do _not_ write it into
|
/* Same, but fill in its code as CODE, and do _not_ write it into
|
||||||
|
@ -5436,14 +5438,14 @@ init_optab (optab op, enum rtx_code code)
|
||||||
static inline void
|
static inline void
|
||||||
init_optabv (optab op, enum rtx_code code)
|
init_optabv (optab op, enum rtx_code code)
|
||||||
{
|
{
|
||||||
op->code = code;
|
op->code_ = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Conversion optabs never go in the code_to_optab table. */
|
/* Conversion optabs never go in the code_to_optab table. */
|
||||||
static void
|
static void
|
||||||
init_convert_optab (convert_optab op, enum rtx_code code)
|
init_convert_optab (convert_optab op, enum rtx_code code)
|
||||||
{
|
{
|
||||||
op->code = code;
|
op->code_ = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the libfunc fields of an entire group of entries in some
|
/* Initialize the libfunc fields of an entire group of entries in some
|
||||||
|
@ -6701,7 +6703,7 @@ debug_optab_libfuncs (void)
|
||||||
{
|
{
|
||||||
gcc_assert (GET_CODE (l) == SYMBOL_REF);
|
gcc_assert (GET_CODE (l) == SYMBOL_REF);
|
||||||
fprintf (stderr, "%s\t%s:\t%s\n",
|
fprintf (stderr, "%s\t%s:\t%s\n",
|
||||||
GET_RTX_NAME (o->code),
|
GET_RTX_NAME (optab_to_code (o)),
|
||||||
GET_MODE_NAME (j),
|
GET_MODE_NAME (j),
|
||||||
XSTR (l, 0));
|
XSTR (l, 0));
|
||||||
}
|
}
|
||||||
|
@ -6722,7 +6724,7 @@ debug_optab_libfuncs (void)
|
||||||
{
|
{
|
||||||
gcc_assert (GET_CODE (l) == SYMBOL_REF);
|
gcc_assert (GET_CODE (l) == SYMBOL_REF);
|
||||||
fprintf (stderr, "%s\t%s\t%s:\t%s\n",
|
fprintf (stderr, "%s\t%s\t%s:\t%s\n",
|
||||||
GET_RTX_NAME (o->code),
|
GET_RTX_NAME (optab_to_code (o)),
|
||||||
GET_MODE_NAME (j),
|
GET_MODE_NAME (j),
|
||||||
GET_MODE_NAME (k),
|
GET_MODE_NAME (k),
|
||||||
XSTR (l, 0));
|
XSTR (l, 0));
|
||||||
|
|
14
gcc/optabs.h
14
gcc/optabs.h
|
@ -50,7 +50,7 @@ struct widening_optab_handlers
|
||||||
|
|
||||||
struct optab_d
|
struct optab_d
|
||||||
{
|
{
|
||||||
enum rtx_code code;
|
enum rtx_code code_;
|
||||||
char libcall_suffix;
|
char libcall_suffix;
|
||||||
const char *libcall_basename;
|
const char *libcall_basename;
|
||||||
void (*libcall_gen)(struct optab_d *, const char *name, char suffix,
|
void (*libcall_gen)(struct optab_d *, const char *name, char suffix,
|
||||||
|
@ -65,7 +65,7 @@ typedef struct optab_d * optab;
|
||||||
is the source mode. */
|
is the source mode. */
|
||||||
struct convert_optab_d
|
struct convert_optab_d
|
||||||
{
|
{
|
||||||
enum rtx_code code;
|
enum rtx_code code_;
|
||||||
const char *libcall_basename;
|
const char *libcall_basename;
|
||||||
void (*libcall_gen)(struct convert_optab_d *, const char *name,
|
void (*libcall_gen)(struct convert_optab_d *, const char *name,
|
||||||
enum machine_mode,
|
enum machine_mode,
|
||||||
|
@ -671,7 +671,15 @@ enum convert_optab_index
|
||||||
#define vcondu_optab (&convert_optab_table[(int) COI_vcondu])
|
#define vcondu_optab (&convert_optab_table[(int) COI_vcondu])
|
||||||
|
|
||||||
/* Contains the optab used for each rtx code. */
|
/* Contains the optab used for each rtx code. */
|
||||||
extern optab code_to_optab[NUM_RTX_CODE + 1];
|
extern optab code_to_optab_[NUM_RTX_CODE + 1];
|
||||||
|
|
||||||
|
static inline optab
|
||||||
|
code_to_optab (enum rtx_code code)
|
||||||
|
{
|
||||||
|
return code_to_optab_[code];
|
||||||
|
}
|
||||||
|
|
||||||
|
#define optab_to_code(op) ((op)->code_)
|
||||||
|
|
||||||
|
|
||||||
typedef rtx (*rtxfun) (rtx);
|
typedef rtx (*rtxfun) (rtx);
|
||||||
|
|
Loading…
Reference in New Issue