diff mbox

wide-int, dfp

Message ID 055DB476-DAE0-464B-BCC6-E5372629B74C@comcast.net
State New
Headers show

Commit Message

Mike Stump Nov. 23, 2013, 7:21 p.m. UTC
Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch.    This patch covers the decimal floating point code.

Ok?
* dfp.c: Include wide-int.h.
	(decimal_real_to_integer2): Use wide-int interfaces and rename to
	decimal_real_to_integer.
	* dfp.h
	(decimal_real_to_integer2): Return a wide_int and rename to
	decimal_real_to_integer.

Comments

Ben Elliston Nov. 23, 2013, 10:56 p.m. UTC | #1
On Sat, Nov 23, 2013 at 11:21:10AM -0800, Mike Stump wrote:

> 	* dfp.c: Include wide-int.h.
> 	(decimal_real_to_integer2): Use wide-int interfaces and rename to
> 	decimal_real_to_integer.
> 	* dfp.h
> 	(decimal_real_to_integer2): Return a wide_int and rename to
> 	decimal_real_to_integer.

OK.

Thanks,
Ben
diff mbox

Patch

diff --git a/gcc/dfp.c b/gcc/dfp.c
index d15ee8f..265b707 100644
--- a/gcc/dfp.c
+++ b/gcc/dfp.c
@@ -24,6 +24,7 @@  along with GCC; see the file COPYING3.  If not see
 #include "tree.h"
 #include "tm_p.h"
 #include "dfp.h"
+#include "wide-int.h"
 
 /* The order of the following headers is important for making sure
    decNumber structure is large enough to hold decimal128 digits.  */
@@ -604,11 +605,11 @@  decimal_real_to_integer (const REAL_VALUE_TYPE *r)
   return real_to_integer (&to);
 }
 
-/* Likewise, but to an integer pair, HI+LOW.  */
+/* Likewise, but returns a wide_int with PRECISION.  *FAIL is set if the
+   value does not fit.  */
 
-void
-decimal_real_to_integer2 (HOST_WIDE_INT *plow, HOST_WIDE_INT *phigh,
-			  const REAL_VALUE_TYPE *r)
+wide_int
+decimal_real_to_integer (const REAL_VALUE_TYPE *r, bool *fail, int precision)
 {
   decContext set;
   decNumber dn, dn2, dn3;
@@ -628,7 +629,7 @@  decimal_real_to_integer2 (HOST_WIDE_INT *plow, HOST_WIDE_INT *phigh,
      function.  */
   decNumberToString (&dn, string);
   real_from_string (&to, string);
-  real_to_integer2 (plow, phigh, &to);
+  return real_to_integer (&to, fail, precision);
 }
 
 /* Perform the decimal floating point operation described by CODE.
diff --git a/gcc/dfp.h b/gcc/dfp.h
index 3b9bb8d..2f0da9b 100644
--- a/gcc/dfp.h
+++ b/gcc/dfp.h
@@ -38,7 +38,7 @@  void decimal_real_convert (REAL_VALUE_TYPE *, enum machine_mode, const REAL_VALU
 void decimal_real_to_decimal (char *, const REAL_VALUE_TYPE *, size_t, size_t, int);
 void decimal_do_fix_trunc (REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *);
 void decimal_real_maxval (REAL_VALUE_TYPE *, int, enum machine_mode);
-void decimal_real_to_integer2 (HOST_WIDE_INT *, HOST_WIDE_INT *, const REAL_VALUE_TYPE *);
+wide_int decimal_real_to_integer (const REAL_VALUE_TYPE *, bool *, int);
 HOST_WIDE_INT decimal_real_to_integer (const REAL_VALUE_TYPE *);
 
 #ifdef TREE_CODE