Commit 86556d87 by Ben Elliston Committed by Ben Elliston

machmode.h (CLASS_HAS_WIDER_MODES_P): New macro.

	* machmode.h (CLASS_HAS_WIDER_MODES_P): New macro.
	* optabs.c (expand_binop): Use CLASS_HAS_WIDER_MODES_P, improve
	formatting.
	(expand_twoval_unop): Likewise.
	(widen_clz): Likewise.
	(expand_parity): Likewise.
	(expand_unop): Likewise.
	(emit_cmp_and_jmp_insn_1): Likewise.
	(prepare_float_lib_cmp): Likewise.

From-SVN: r107450
parent 94044657
2005-11-24 Ben Elliston <bje@au.ibm.com> 2005-11-24 Ben Elliston <bje@au.ibm.com>
* machmode.h (CLASS_HAS_WIDER_MODES_P): New macro.
* optabs.c (expand_binop): Use CLASS_HAS_WIDER_MODES_P, improve
formatting.
(expand_twoval_unop): Likewise.
(widen_clz): Likewise.
(expand_parity): Likewise.
(expand_unop): Likewise.
(emit_cmp_and_jmp_insn_1): Likewise.
(prepare_float_lib_cmp): Likewise.
2005-11-24 Ben Elliston <bje@au.ibm.com>
* optabs.c (prepare_cmp_insn): Use SCALAR_FLOAT_MODE_P. * optabs.c (prepare_cmp_insn): Use SCALAR_FLOAT_MODE_P.
Remove unused `class' variable. Remove unused `class' variable.
......
...@@ -76,6 +76,12 @@ extern const unsigned char mode_class[NUM_MACHINE_MODES]; ...@@ -76,6 +76,12 @@ extern const unsigned char mode_class[NUM_MACHINE_MODES];
#define SCALAR_FLOAT_MODE_P(MODE) \ #define SCALAR_FLOAT_MODE_P(MODE) \
(GET_MODE_CLASS (MODE) == MODE_FLOAT) (GET_MODE_CLASS (MODE) == MODE_FLOAT)
/* Nonzero if CLASS modes can be widened. */
#define CLASS_HAS_WIDER_MODES_P(CLASS) \
(CLASS == MODE_INT \
|| CLASS == MODE_FLOAT \
|| CLASS == MODE_COMPLEX_FLOAT)
/* Get the size in bytes and bits of an object of mode MODE. */ /* Get the size in bytes and bits of an object of mode MODE. */
extern CONST_MODE_SIZE unsigned char mode_size[NUM_MACHINE_MODES]; extern CONST_MODE_SIZE unsigned char mode_size[NUM_MACHINE_MODES];
......
...@@ -1192,7 +1192,8 @@ expand_binop (enum machine_mode mode, optab binoptab, rtx op0, rtx op1, ...@@ -1192,7 +1192,8 @@ expand_binop (enum machine_mode mode, optab binoptab, rtx op0, rtx op1,
/* If this is a multiply, see if we can do a widening operation that /* If this is a multiply, see if we can do a widening operation that
takes operands of this mode and makes a wider mode. */ takes operands of this mode and makes a wider mode. */
if (binoptab == smul_optab && GET_MODE_WIDER_MODE (mode) != VOIDmode if (binoptab == smul_optab
&& GET_MODE_WIDER_MODE (mode) != VOIDmode
&& (((unsignedp ? umul_widen_optab : smul_widen_optab) && (((unsignedp ? umul_widen_optab : smul_widen_optab)
->handlers[(int) GET_MODE_WIDER_MODE (mode)].insn_code) ->handlers[(int) GET_MODE_WIDER_MODE (mode)].insn_code)
!= CODE_FOR_nothing)) != CODE_FOR_nothing))
...@@ -1216,9 +1217,10 @@ expand_binop (enum machine_mode mode, optab binoptab, rtx op0, rtx op1, ...@@ -1216,9 +1217,10 @@ expand_binop (enum machine_mode mode, optab binoptab, rtx op0, rtx op1,
can open-code the operation. Check for a widening multiply at the can open-code the operation. Check for a widening multiply at the
wider mode as well. */ wider mode as well. */
if ((class == MODE_INT || class == MODE_FLOAT || class == MODE_COMPLEX_FLOAT) if (CLASS_HAS_WIDER_MODES_P (class)
&& methods != OPTAB_DIRECT && methods != OPTAB_LIB) && methods != OPTAB_DIRECT && methods != OPTAB_LIB)
for (wider_mode = GET_MODE_WIDER_MODE (mode); wider_mode != VOIDmode; for (wider_mode = GET_MODE_WIDER_MODE (mode);
wider_mode != VOIDmode;
wider_mode = GET_MODE_WIDER_MODE (wider_mode)) wider_mode = GET_MODE_WIDER_MODE (wider_mode))
{ {
if (binoptab->handlers[(int) wider_mode].insn_code != CODE_FOR_nothing if (binoptab->handlers[(int) wider_mode].insn_code != CODE_FOR_nothing
...@@ -1747,9 +1749,10 @@ expand_binop (enum machine_mode mode, optab binoptab, rtx op0, rtx op1, ...@@ -1747,9 +1749,10 @@ expand_binop (enum machine_mode mode, optab binoptab, rtx op0, rtx op1,
/* Look for a wider mode of the same class for which it appears we can do /* Look for a wider mode of the same class for which it appears we can do
the operation. */ the operation. */
if (class == MODE_INT || class == MODE_FLOAT || class == MODE_COMPLEX_FLOAT) if (CLASS_HAS_WIDER_MODES_P (class))
{ {
for (wider_mode = GET_MODE_WIDER_MODE (mode); wider_mode != VOIDmode; for (wider_mode = GET_MODE_WIDER_MODE (mode);
wider_mode != VOIDmode;
wider_mode = GET_MODE_WIDER_MODE (wider_mode)) wider_mode = GET_MODE_WIDER_MODE (wider_mode))
{ {
if ((binoptab->handlers[(int) wider_mode].insn_code if ((binoptab->handlers[(int) wider_mode].insn_code
...@@ -1921,9 +1924,10 @@ expand_twoval_unop (optab unoptab, rtx op0, rtx targ0, rtx targ1, ...@@ -1921,9 +1924,10 @@ expand_twoval_unop (optab unoptab, rtx op0, rtx targ0, rtx targ1,
/* It can't be done in this mode. Can we do it in a wider mode? */ /* It can't be done in this mode. Can we do it in a wider mode? */
if (class == MODE_INT || class == MODE_FLOAT || class == MODE_COMPLEX_FLOAT) if (CLASS_HAS_WIDER_MODES_P (class))
{ {
for (wider_mode = GET_MODE_WIDER_MODE (mode); wider_mode != VOIDmode; for (wider_mode = GET_MODE_WIDER_MODE (mode);
wider_mode != VOIDmode;
wider_mode = GET_MODE_WIDER_MODE (wider_mode)) wider_mode = GET_MODE_WIDER_MODE (wider_mode))
{ {
if (unoptab->handlers[(int) wider_mode].insn_code if (unoptab->handlers[(int) wider_mode].insn_code
...@@ -2043,9 +2047,10 @@ expand_twoval_binop (optab binoptab, rtx op0, rtx op1, rtx targ0, rtx targ1, ...@@ -2043,9 +2047,10 @@ expand_twoval_binop (optab binoptab, rtx op0, rtx op1, rtx targ0, rtx targ1,
/* It can't be done in this mode. Can we do it in a wider mode? */ /* It can't be done in this mode. Can we do it in a wider mode? */
if (class == MODE_INT || class == MODE_FLOAT || class == MODE_COMPLEX_FLOAT) if (CLASS_HAS_WIDER_MODES_P (class))
{ {
for (wider_mode = GET_MODE_WIDER_MODE (mode); wider_mode != VOIDmode; for (wider_mode = GET_MODE_WIDER_MODE (mode);
wider_mode != VOIDmode;
wider_mode = GET_MODE_WIDER_MODE (wider_mode)) wider_mode = GET_MODE_WIDER_MODE (wider_mode))
{ {
if (binoptab->handlers[(int) wider_mode].insn_code if (binoptab->handlers[(int) wider_mode].insn_code
...@@ -2142,10 +2147,11 @@ static rtx ...@@ -2142,10 +2147,11 @@ static rtx
widen_clz (enum machine_mode mode, rtx op0, rtx target) widen_clz (enum machine_mode mode, rtx op0, rtx target)
{ {
enum mode_class class = GET_MODE_CLASS (mode); enum mode_class class = GET_MODE_CLASS (mode);
if (class == MODE_INT || class == MODE_FLOAT || class == MODE_COMPLEX_FLOAT) if (CLASS_HAS_WIDER_MODES_P (class))
{ {
enum machine_mode wider_mode; enum machine_mode wider_mode;
for (wider_mode = GET_MODE_WIDER_MODE (mode); wider_mode != VOIDmode; for (wider_mode = GET_MODE_WIDER_MODE (mode);
wider_mode != VOIDmode;
wider_mode = GET_MODE_WIDER_MODE (wider_mode)) wider_mode = GET_MODE_WIDER_MODE (wider_mode))
{ {
if (clz_optab->handlers[(int) wider_mode].insn_code if (clz_optab->handlers[(int) wider_mode].insn_code
...@@ -2180,7 +2186,7 @@ static rtx ...@@ -2180,7 +2186,7 @@ static rtx
expand_parity (enum machine_mode mode, rtx op0, rtx target) expand_parity (enum machine_mode mode, rtx op0, rtx target)
{ {
enum mode_class class = GET_MODE_CLASS (mode); enum mode_class class = GET_MODE_CLASS (mode);
if (class == MODE_INT || class == MODE_FLOAT || class == MODE_COMPLEX_FLOAT) if (CLASS_HAS_WIDER_MODES_P (class))
{ {
enum machine_mode wider_mode; enum machine_mode wider_mode;
for (wider_mode = mode; wider_mode != VOIDmode; for (wider_mode = mode; wider_mode != VOIDmode;
...@@ -2412,8 +2418,9 @@ expand_unop (enum machine_mode mode, optab unoptab, rtx op0, rtx target, ...@@ -2412,8 +2418,9 @@ expand_unop (enum machine_mode mode, optab unoptab, rtx op0, rtx target,
goto try_libcall; goto try_libcall;
} }
if (class == MODE_INT || class == MODE_FLOAT || class == MODE_COMPLEX_FLOAT) if (CLASS_HAS_WIDER_MODES_P (class))
for (wider_mode = GET_MODE_WIDER_MODE (mode); wider_mode != VOIDmode; for (wider_mode = GET_MODE_WIDER_MODE (mode);
wider_mode != VOIDmode;
wider_mode = GET_MODE_WIDER_MODE (wider_mode)) wider_mode = GET_MODE_WIDER_MODE (wider_mode))
{ {
if (unoptab->handlers[(int) wider_mode].insn_code != CODE_FOR_nothing) if (unoptab->handlers[(int) wider_mode].insn_code != CODE_FOR_nothing)
...@@ -2551,9 +2558,10 @@ expand_unop (enum machine_mode mode, optab unoptab, rtx op0, rtx target, ...@@ -2551,9 +2558,10 @@ expand_unop (enum machine_mode mode, optab unoptab, rtx op0, rtx target,
/* It can't be done in this mode. Can we do it in a wider mode? */ /* It can't be done in this mode. Can we do it in a wider mode? */
if (class == MODE_INT || class == MODE_FLOAT || class == MODE_COMPLEX_FLOAT) if (CLASS_HAS_WIDER_MODES_P (class))
{ {
for (wider_mode = GET_MODE_WIDER_MODE (mode); wider_mode != VOIDmode; for (wider_mode = GET_MODE_WIDER_MODE (mode);
wider_mode != VOIDmode;
wider_mode = GET_MODE_WIDER_MODE (wider_mode)) wider_mode = GET_MODE_WIDER_MODE (wider_mode))
{ {
if ((unoptab->handlers[(int) wider_mode].insn_code if ((unoptab->handlers[(int) wider_mode].insn_code
...@@ -3633,8 +3641,7 @@ emit_cmp_and_jump_insn_1 (rtx x, rtx y, enum machine_mode mode, ...@@ -3633,8 +3641,7 @@ emit_cmp_and_jump_insn_1 (rtx x, rtx y, enum machine_mode mode,
return; return;
} }
if (class != MODE_INT && class != MODE_FLOAT if (!CLASS_HAS_WIDER_MODES_P (class))
&& class != MODE_COMPLEX_FLOAT)
break; break;
wider_mode = GET_MODE_WIDER_MODE (wider_mode); wider_mode = GET_MODE_WIDER_MODE (wider_mode);
...@@ -3720,7 +3727,9 @@ prepare_float_lib_cmp (rtx *px, rtx *py, enum rtx_code *pcomparison, ...@@ -3720,7 +3727,9 @@ prepare_float_lib_cmp (rtx *px, rtx *py, enum rtx_code *pcomparison,
rtx libfunc = 0; rtx libfunc = 0;
bool reversed_p = false; bool reversed_p = false;
for (mode = orig_mode; mode != VOIDmode; mode = GET_MODE_WIDER_MODE (mode)) for (mode = orig_mode;
mode != VOIDmode;
mode = GET_MODE_WIDER_MODE (mode))
{ {
if ((libfunc = code_to_optab[comparison]->handlers[mode].libfunc)) if ((libfunc = code_to_optab[comparison]->handlers[mode].libfunc))
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment