(decimal_)float_mode_for_size in real.h
authorRichard Sandiford <richard.sandiford@linaro.org>
Tue, 5 Sep 2017 19:57:09 +0000 (19:57 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Tue, 5 Sep 2017 19:57:09 +0000 (19:57 +0000)
This patch makes the binary float macros in real.h use
float_mode_for_size and adds a corresponding decimal_float_mode_for_size
for the decimal macros.

2017-09-05  Richard Sandiford  <richard.sandiford@linaro.org>

gcc/
* machmode.h (decimal_float_mode_for_size): New function.
* real.h (REAL_VALUE_TO_TARGET_LONG_DOUBLE): Use float_mode_for_size.
(REAL_VALUE_TO_TARGET_DOUBLE): Likewise.
(REAL_VALUE_TO_TARGET_SINGLE): Likewise.
(REAL_VALUE_TO_TARGET_DECIMAL128): Use decimal_float_mode_for_size.
(REAL_VALUE_TO_TARGET_DECIMAL64): Likewise.
(REAL_VALUE_TO_TARGET_DECIMAL32): Likewise.

From-SVN: r251727

gcc/ChangeLog
gcc/machmode.h
gcc/real.h

index 8105f3d..7fbade7 100644 (file)
@@ -1,5 +1,15 @@
 2017-09-05  Richard Sandiford  <richard.sandiford@linaro.org>
 
+       * machmode.h (decimal_float_mode_for_size): New function.
+       * real.h (REAL_VALUE_TO_TARGET_LONG_DOUBLE): Use float_mode_for_size.
+       (REAL_VALUE_TO_TARGET_DOUBLE): Likewise.
+       (REAL_VALUE_TO_TARGET_SINGLE): Likewise.
+       (REAL_VALUE_TO_TARGET_DECIMAL128): Use decimal_float_mode_for_size.
+       (REAL_VALUE_TO_TARGET_DECIMAL64): Likewise.
+       (REAL_VALUE_TO_TARGET_DECIMAL32): Likewise.
+
+2017-09-05  Richard Sandiford  <richard.sandiford@linaro.org>
+
        * builtins.c (expand_builtin_powi): Use int_mode_for_size.
        (get_builtin_sync_mode): Likewise.
        (expand_ifn_atomic_compare_exchange): Likewise.
index b331f07..d8344a9 100644 (file)
@@ -652,6 +652,15 @@ float_mode_for_size (unsigned int size)
   return dyn_cast <scalar_float_mode> (mode_for_size (size, MODE_FLOAT, 0));
 }
 
+/* Likewise for MODE_DECIMAL_FLOAT.  */
+
+inline opt_scalar_float_mode
+decimal_float_mode_for_size (unsigned int size)
+{
+  return dyn_cast <scalar_float_mode>
+    (mode_for_size (size, MODE_DECIMAL_FLOAT, 0));
+}
+
 /* Similar to mode_for_size, but find the smallest mode for a given width.  */
 
 extern machine_mode smallest_mode_for_size (unsigned int, enum mode_class);
index 95104b0..c034fd9 100644 (file)
@@ -383,27 +383,28 @@ extern const struct real_format arm_half_format;
 /* IN is a REAL_VALUE_TYPE.  OUT is an array of longs.  */
 #define REAL_VALUE_TO_TARGET_LONG_DOUBLE(IN, OUT)                      \
   real_to_target (OUT, &(IN),                                          \
-                 mode_for_size (LONG_DOUBLE_TYPE_SIZE, MODE_FLOAT, 0))
+                 float_mode_for_size (LONG_DOUBLE_TYPE_SIZE).require ())
 
 #define REAL_VALUE_TO_TARGET_DOUBLE(IN, OUT) \
-  real_to_target (OUT, &(IN), mode_for_size (64, MODE_FLOAT, 0))
+  real_to_target (OUT, &(IN), float_mode_for_size (64).require ())
 
 /* IN is a REAL_VALUE_TYPE.  OUT is a long.  */
 #define REAL_VALUE_TO_TARGET_SINGLE(IN, OUT) \
-  ((OUT) = real_to_target (NULL, &(IN), mode_for_size (32, MODE_FLOAT, 0)))
+  ((OUT) = real_to_target (NULL, &(IN), float_mode_for_size (32).require ()))
 
 /* Real values to IEEE 754 decimal floats.  */
 
 /* IN is a REAL_VALUE_TYPE.  OUT is an array of longs.  */
 #define REAL_VALUE_TO_TARGET_DECIMAL128(IN, OUT) \
-  real_to_target (OUT, &(IN), mode_for_size (128, MODE_DECIMAL_FLOAT, 0))
+  real_to_target (OUT, &(IN), decimal_float_mode_for_size (128).require ())
 
 #define REAL_VALUE_TO_TARGET_DECIMAL64(IN, OUT) \
-  real_to_target (OUT, &(IN), mode_for_size (64, MODE_DECIMAL_FLOAT, 0))
+  real_to_target (OUT, &(IN), decimal_float_mode_for_size (64).require ())
 
 /* IN is a REAL_VALUE_TYPE.  OUT is a long.  */
 #define REAL_VALUE_TO_TARGET_DECIMAL32(IN, OUT) \
-  ((OUT) = real_to_target (NULL, &(IN), mode_for_size (32, MODE_DECIMAL_FLOAT, 0)))
+  ((OUT) = real_to_target (NULL, &(IN), \
+                          decimal_float_mode_for_size (32).require ()))
 
 extern REAL_VALUE_TYPE real_value_truncate (format_helper, REAL_VALUE_TYPE);