Commit 79052416 by Richard Sandiford Committed by Richard Sandiford

[67/77] Use scalar_mode in fixed-value.*

This patch makes the fixed-value.* routines use scalar_mode.
It would be possible to define special classes for these modes, as for
scalar_int_mode and scalar_float_mode, but at the moment nothing would
benefit from them.  In particular, there's no use case that would help
select between one class for all fixed-point modes versus one class for
fractional modes and one class for accumulator modes.

2017-08-30  Richard Sandiford  <richard.sandiford@linaro.org>
	    Alan Hayward  <alan.hayward@arm.com>
	    David Sherwood  <david.sherwood@arm.com>

gcc/
	* fixed-value.h (fixed_from_double_int): Take a scalar_mode
	rather than a machine_mode.
	(fixed_from_string): Likewise.
	(fixed_convert): Likewise.
	(fixed_convert_from_int): Likewise.
	(fixed_convert_from_real): Likewise.
	(real_convert_from_fixed): Likewise.
	* fixed-value.c (fixed_from_double_int): Likewise.
	(fixed_from_string): Likewise.
	(fixed_convert): Likewise.
	(fixed_convert_from_int): Likewise.
	(fixed_convert_from_real): Likewise.
	(real_convert_from_fixed): Likewise.
	* config/avr/avr.c (avr_out_round): Use as_a <scalar_mode>.

Co-Authored-By: Alan Hayward <alan.hayward@arm.com>
Co-Authored-By: David Sherwood <david.sherwood@arm.com>

From-SVN: r251518
parent db61b7f9
...@@ -2,6 +2,25 @@ ...@@ -2,6 +2,25 @@
Alan Hayward <alan.hayward@arm.com> Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com> David Sherwood <david.sherwood@arm.com>
* fixed-value.h (fixed_from_double_int): Take a scalar_mode
rather than a machine_mode.
(fixed_from_string): Likewise.
(fixed_convert): Likewise.
(fixed_convert_from_int): Likewise.
(fixed_convert_from_real): Likewise.
(real_convert_from_fixed): Likewise.
* fixed-value.c (fixed_from_double_int): Likewise.
(fixed_from_string): Likewise.
(fixed_convert): Likewise.
(fixed_convert_from_int): Likewise.
(fixed_convert_from_real): Likewise.
(real_convert_from_fixed): Likewise.
* config/avr/avr.c (avr_out_round): Use as_a <scalar_mode>.
2017-08-30 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
* emit-rtl.c (immed_double_const): Use is_a <scalar_mode> instead * emit-rtl.c (immed_double_const): Use is_a <scalar_mode> instead
of separate mode class checks. Do not allow vector modes here. of separate mode class checks. Do not allow vector modes here.
(immed_wide_int_const): Use as_a <scalar_mode>. (immed_wide_int_const): Use as_a <scalar_mode>.
......
...@@ -9176,7 +9176,7 @@ avr_out_fract (rtx_insn *insn, rtx operands[], bool intsigned, int *plen) ...@@ -9176,7 +9176,7 @@ avr_out_fract (rtx_insn *insn, rtx operands[], bool intsigned, int *plen)
const char* const char*
avr_out_round (rtx_insn *insn ATTRIBUTE_UNUSED, rtx *xop, int *plen) avr_out_round (rtx_insn *insn ATTRIBUTE_UNUSED, rtx *xop, int *plen)
{ {
machine_mode mode = GET_MODE (xop[0]); scalar_mode mode = as_a <scalar_mode> (GET_MODE (xop[0]));
scalar_int_mode imode = int_mode_for_mode (mode).require (); scalar_int_mode imode = int_mode_for_mode (mode).require ();
// The smallest fractional bit not cleared by the rounding is 2^(-RP). // The smallest fractional bit not cleared by the rounding is 2^(-RP).
int fbit = (int) GET_MODE_FBIT (mode); int fbit = (int) GET_MODE_FBIT (mode);
......
...@@ -86,7 +86,7 @@ check_real_for_fixed_mode (REAL_VALUE_TYPE *real_value, machine_mode mode) ...@@ -86,7 +86,7 @@ check_real_for_fixed_mode (REAL_VALUE_TYPE *real_value, machine_mode mode)
The bits in PAYLOAD are sign-extended/zero-extended according to MODE. */ The bits in PAYLOAD are sign-extended/zero-extended according to MODE. */
FIXED_VALUE_TYPE FIXED_VALUE_TYPE
fixed_from_double_int (double_int payload, machine_mode mode) fixed_from_double_int (double_int payload, scalar_mode mode)
{ {
FIXED_VALUE_TYPE value; FIXED_VALUE_TYPE value;
...@@ -108,7 +108,7 @@ fixed_from_double_int (double_int payload, machine_mode mode) ...@@ -108,7 +108,7 @@ fixed_from_double_int (double_int payload, machine_mode mode)
/* Initialize from a decimal or hexadecimal string. */ /* Initialize from a decimal or hexadecimal string. */
void void
fixed_from_string (FIXED_VALUE_TYPE *f, const char *str, machine_mode mode) fixed_from_string (FIXED_VALUE_TYPE *f, const char *str, scalar_mode mode)
{ {
REAL_VALUE_TYPE real_value, fixed_value, base_value; REAL_VALUE_TYPE real_value, fixed_value, base_value;
unsigned int fbit; unsigned int fbit;
...@@ -803,7 +803,7 @@ fixed_compare (int icode, const FIXED_VALUE_TYPE *op0, ...@@ -803,7 +803,7 @@ fixed_compare (int icode, const FIXED_VALUE_TYPE *op0,
Return true, if !SAT_P and overflow. */ Return true, if !SAT_P and overflow. */
bool bool
fixed_convert (FIXED_VALUE_TYPE *f, machine_mode mode, fixed_convert (FIXED_VALUE_TYPE *f, scalar_mode mode,
const FIXED_VALUE_TYPE *a, bool sat_p) const FIXED_VALUE_TYPE *a, bool sat_p)
{ {
bool overflow_p = false; bool overflow_p = false;
...@@ -947,7 +947,7 @@ fixed_convert (FIXED_VALUE_TYPE *f, machine_mode mode, ...@@ -947,7 +947,7 @@ fixed_convert (FIXED_VALUE_TYPE *f, machine_mode mode,
Return true, if !SAT_P and overflow. */ Return true, if !SAT_P and overflow. */
bool bool
fixed_convert_from_int (FIXED_VALUE_TYPE *f, machine_mode mode, fixed_convert_from_int (FIXED_VALUE_TYPE *f, scalar_mode mode,
double_int a, bool unsigned_p, bool sat_p) double_int a, bool unsigned_p, bool sat_p)
{ {
bool overflow_p = false; bool overflow_p = false;
...@@ -1031,7 +1031,7 @@ fixed_convert_from_int (FIXED_VALUE_TYPE *f, machine_mode mode, ...@@ -1031,7 +1031,7 @@ fixed_convert_from_int (FIXED_VALUE_TYPE *f, machine_mode mode,
Return true, if !SAT_P and overflow. */ Return true, if !SAT_P and overflow. */
bool bool
fixed_convert_from_real (FIXED_VALUE_TYPE *f, machine_mode mode, fixed_convert_from_real (FIXED_VALUE_TYPE *f, scalar_mode mode,
const REAL_VALUE_TYPE *a, bool sat_p) const REAL_VALUE_TYPE *a, bool sat_p)
{ {
bool overflow_p = false; bool overflow_p = false;
...@@ -1090,7 +1090,7 @@ fixed_convert_from_real (FIXED_VALUE_TYPE *f, machine_mode mode, ...@@ -1090,7 +1090,7 @@ fixed_convert_from_real (FIXED_VALUE_TYPE *f, machine_mode mode,
/* Convert to a new real mode from a fixed-point. */ /* Convert to a new real mode from a fixed-point. */
void void
real_convert_from_fixed (REAL_VALUE_TYPE *r, machine_mode mode, real_convert_from_fixed (REAL_VALUE_TYPE *r, scalar_mode mode,
const FIXED_VALUE_TYPE *f) const FIXED_VALUE_TYPE *f)
{ {
REAL_VALUE_TYPE base_value, fixed_value, real_value; REAL_VALUE_TYPE base_value, fixed_value, real_value;
......
...@@ -47,14 +47,13 @@ extern rtx const_fixed_from_fixed_value (FIXED_VALUE_TYPE, machine_mode); ...@@ -47,14 +47,13 @@ extern rtx const_fixed_from_fixed_value (FIXED_VALUE_TYPE, machine_mode);
/* Construct a FIXED_VALUE from a bit payload and machine mode MODE. /* Construct a FIXED_VALUE from a bit payload and machine mode MODE.
The bits in PAYLOAD are sign-extended/zero-extended according to MODE. */ The bits in PAYLOAD are sign-extended/zero-extended according to MODE. */
extern FIXED_VALUE_TYPE fixed_from_double_int (double_int, extern FIXED_VALUE_TYPE fixed_from_double_int (double_int, scalar_mode);
machine_mode);
/* Return a CONST_FIXED from a bit payload and machine mode MODE. /* Return a CONST_FIXED from a bit payload and machine mode MODE.
The bits in PAYLOAD are sign-extended/zero-extended according to MODE. */ The bits in PAYLOAD are sign-extended/zero-extended according to MODE. */
static inline rtx static inline rtx
const_fixed_from_double_int (double_int payload, const_fixed_from_double_int (double_int payload,
machine_mode mode) scalar_mode mode)
{ {
return return
const_fixed_from_fixed_value (fixed_from_double_int (payload, mode), const_fixed_from_fixed_value (fixed_from_double_int (payload, mode),
...@@ -63,25 +62,25 @@ const_fixed_from_double_int (double_int payload, ...@@ -63,25 +62,25 @@ const_fixed_from_double_int (double_int payload,
/* Initialize from a decimal or hexadecimal string. */ /* Initialize from a decimal or hexadecimal string. */
extern void fixed_from_string (FIXED_VALUE_TYPE *, const char *, extern void fixed_from_string (FIXED_VALUE_TYPE *, const char *,
machine_mode); scalar_mode);
/* In tree.c: wrap up a FIXED_VALUE_TYPE in a tree node. */ /* In tree.c: wrap up a FIXED_VALUE_TYPE in a tree node. */
extern tree build_fixed (tree, FIXED_VALUE_TYPE); extern tree build_fixed (tree, FIXED_VALUE_TYPE);
/* Extend or truncate to a new mode. */ /* Extend or truncate to a new mode. */
extern bool fixed_convert (FIXED_VALUE_TYPE *, machine_mode, extern bool fixed_convert (FIXED_VALUE_TYPE *, scalar_mode,
const FIXED_VALUE_TYPE *, bool); const FIXED_VALUE_TYPE *, bool);
/* Convert to a fixed-point mode from an integer. */ /* Convert to a fixed-point mode from an integer. */
extern bool fixed_convert_from_int (FIXED_VALUE_TYPE *, machine_mode, extern bool fixed_convert_from_int (FIXED_VALUE_TYPE *, scalar_mode,
double_int, bool, bool); double_int, bool, bool);
/* Convert to a fixed-point mode from a real. */ /* Convert to a fixed-point mode from a real. */
extern bool fixed_convert_from_real (FIXED_VALUE_TYPE *, machine_mode, extern bool fixed_convert_from_real (FIXED_VALUE_TYPE *, scalar_mode,
const REAL_VALUE_TYPE *, bool); const REAL_VALUE_TYPE *, bool);
/* Convert to a real mode from a fixed-point. */ /* Convert to a real mode from a fixed-point. */
extern void real_convert_from_fixed (REAL_VALUE_TYPE *, machine_mode, extern void real_convert_from_fixed (REAL_VALUE_TYPE *, scalar_mode,
const FIXED_VALUE_TYPE *); const FIXED_VALUE_TYPE *);
/* Compare two fixed-point objects for bitwise identity. */ /* Compare two fixed-point objects for bitwise identity. */
......
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