On Wed, 15 Aug 2012, Richard Guenther wrote: > On Wed, Aug 15, 2012 at 12:31 PM, Jakub Jelinek <ja...@redhat.com> wrote: > > On Wed, Aug 15, 2012 at 12:28:58PM +0200, Richard Guenther wrote: > >> the function names make no sense - they should be talking about > >> host-wide-ints, because that is what they are about. Thus, > >> > >> /* Conversion functions. */ > >> > >> HOST_WIDE_INT to_signed_hwi () const; > >> unsigned HOST_WIDE_INT to_unsigned_hwi () const; > >> > >> /* Conversion query functions. */ > >> > >> bool fits_unsigned_hwi () const; > >> bool fits_signed_hwi () const; > >> bool fits_hwi (bool uns) const; > > > > Wouldn't uhwi and shwi be better? Both are already widely used within > > gcc... > > True, I'll change it that way.
Like so, testing in progress. Richard. 2012-08-15 Richard Guenther <rguent...@suse.de> * double-int.h (from_unsigned): Rename to ... (from_uhwi): ... this. (from_signed): Rename to ... (from_shwi): ... this. (to_signed): Rename to ... (to_shwi): ... this. (to_unsigned): Rename to ... (to_uhwi): ... this. (fits_unsigned): Rename to ... (fits_uhwi): ... this. (fits_signed): Rename to ... (fits_shwi): ... this. (fits): Rename to ... (fits_hwi): ... this. * double-int.c: Likewise. Index: gcc/double-int.c =================================================================== *** gcc/double-int.c (revision 190407) --- gcc/double-int.c (working copy) *************** double_int::sext (unsigned prec) const *** 716,722 **** /* Returns true if CST fits in signed HOST_WIDE_INT. */ bool ! double_int::fits_signed () const { const double_int &cst = *this; if (cst.high == 0) --- 716,722 ---- /* Returns true if CST fits in signed HOST_WIDE_INT. */ bool ! double_int::fits_shwi () const { const double_int &cst = *this; if (cst.high == 0) *************** double_int::fits_signed () const *** 731,742 **** unsigned HOST_WIDE_INT if UNS is true. */ bool ! double_int::fits (bool uns) const { if (uns) ! return this->fits_unsigned (); else ! return this->fits_signed (); } /* Returns A * B. */ --- 731,742 ---- unsigned HOST_WIDE_INT if UNS is true. */ bool ! double_int::fits_hwi (bool uns) const { if (uns) ! return this->fits_uhwi (); else ! return this->fits_shwi (); } /* Returns A * B. */ Index: gcc/double-int.h =================================================================== *** gcc/double-int.h (revision 190407) --- gcc/double-int.h (working copy) *************** public: *** 60,67 **** Second, the GCC conding conventions prefer explicit conversion, and explicit conversion operators are not available until C++11. */ ! static double_int from_unsigned (unsigned HOST_WIDE_INT cst); ! static double_int from_signed (HOST_WIDE_INT cst); /* No copy assignment operator or destructor to keep the type a POD. */ --- 60,67 ---- Second, the GCC conding conventions prefer explicit conversion, and explicit conversion operators are not available until C++11. */ ! static double_int from_uhwi (unsigned HOST_WIDE_INT cst); ! static double_int from_shwi (HOST_WIDE_INT cst); /* No copy assignment operator or destructor to keep the type a POD. */ *************** public: *** 83,96 **** /* Conversion functions. */ ! HOST_WIDE_INT to_signed () const; ! unsigned HOST_WIDE_INT to_unsigned () const; /* Conversion query functions. */ ! bool fits_unsigned () const; ! bool fits_signed () const; ! bool fits (bool uns) const; /* Attribute query functions. */ --- 83,96 ---- /* Conversion functions. */ ! HOST_WIDE_INT to_shwi () const; ! unsigned HOST_WIDE_INT to_uhwi () const; /* Conversion query functions. */ ! bool fits_uhwi () const; ! bool fits_shwi () const; ! bool fits_hwi (bool uns) const; /* Attribute query functions. */ *************** public: *** 186,192 **** HOST_WIDE_INT are filled with the sign bit. */ inline ! double_int double_int::from_signed (HOST_WIDE_INT cst) { double_int r; r.low = (unsigned HOST_WIDE_INT) cst; --- 186,192 ---- HOST_WIDE_INT are filled with the sign bit. */ inline ! double_int double_int::from_shwi (HOST_WIDE_INT cst) { double_int r; r.low = (unsigned HOST_WIDE_INT) cst; *************** double_int double_int::from_signed (HOST *** 198,204 **** static inline double_int shwi_to_double_int (HOST_WIDE_INT cst) { ! return double_int::from_signed (cst); } /* Some useful constants. */ --- 198,204 ---- static inline double_int shwi_to_double_int (HOST_WIDE_INT cst) { ! return double_int::from_shwi (cst); } /* Some useful constants. */ *************** shwi_to_double_int (HOST_WIDE_INT cst) *** 206,222 **** The problem is that a named constant would not be as optimizable, while the functional syntax is more verbose. */ ! #define double_int_minus_one (double_int::from_signed (-1)) ! #define double_int_zero (double_int::from_signed (0)) ! #define double_int_one (double_int::from_signed (1)) ! #define double_int_two (double_int::from_signed (2)) ! #define double_int_ten (double_int::from_signed (10)) /* Constructs double_int from unsigned integer CST. The bits over the precision of HOST_WIDE_INT are filled with zeros. */ inline ! double_int double_int::from_unsigned (unsigned HOST_WIDE_INT cst) { double_int r; r.low = cst; --- 206,222 ---- The problem is that a named constant would not be as optimizable, while the functional syntax is more verbose. */ ! #define double_int_minus_one (double_int::from_shwi (-1)) ! #define double_int_zero (double_int::from_shwi (0)) ! #define double_int_one (double_int::from_shwi (1)) ! #define double_int_two (double_int::from_shwi (2)) ! #define double_int_ten (double_int::from_shwi (10)) /* Constructs double_int from unsigned integer CST. The bits over the precision of HOST_WIDE_INT are filled with zeros. */ inline ! double_int double_int::from_uhwi (unsigned HOST_WIDE_INT cst) { double_int r; r.low = cst; *************** double_int double_int::from_unsigned (un *** 228,234 **** static inline double_int uhwi_to_double_int (unsigned HOST_WIDE_INT cst) { ! return double_int::from_unsigned (cst); } inline double_int & --- 228,234 ---- static inline double_int uhwi_to_double_int (unsigned HOST_WIDE_INT cst) { ! return double_int::from_uhwi (cst); } inline double_int & *************** double_int::operator -= (double_int b) *** 270,276 **** double_int::fits_signed. */ inline HOST_WIDE_INT ! double_int::to_signed () const { return (HOST_WIDE_INT) low; } --- 270,276 ---- double_int::fits_signed. */ inline HOST_WIDE_INT ! double_int::to_shwi () const { return (HOST_WIDE_INT) low; } *************** double_int::to_signed () const *** 279,292 **** static inline HOST_WIDE_INT double_int_to_shwi (double_int cst) { ! return cst.to_signed (); } /* Returns value of CST as an unsigned number. CST must satisfy double_int::fits_unsigned. */ inline unsigned HOST_WIDE_INT ! double_int::to_unsigned () const { return low; } --- 279,292 ---- static inline HOST_WIDE_INT double_int_to_shwi (double_int cst) { ! return cst.to_shwi (); } /* Returns value of CST as an unsigned number. CST must satisfy double_int::fits_unsigned. */ inline unsigned HOST_WIDE_INT ! double_int::to_uhwi () const { return low; } *************** double_int::to_unsigned () const *** 295,307 **** static inline unsigned HOST_WIDE_INT double_int_to_uhwi (double_int cst) { ! return cst.to_unsigned (); } /* Returns true if CST fits in unsigned HOST_WIDE_INT. */ inline bool ! double_int::fits_unsigned () const { return high == 0; } --- 295,307 ---- static inline unsigned HOST_WIDE_INT double_int_to_uhwi (double_int cst) { ! return cst.to_uhwi (); } /* Returns true if CST fits in unsigned HOST_WIDE_INT. */ inline bool ! double_int::fits_uhwi () const { return high == 0; } *************** double_int::fits_unsigned () const *** 310,316 **** static inline bool double_int_fits_in_uhwi_p (double_int cst) { ! return cst.fits_unsigned (); } /* Returns true if CST fits in signed HOST_WIDE_INT. */ --- 310,316 ---- static inline bool double_int_fits_in_uhwi_p (double_int cst) { ! return cst.fits_uhwi (); } /* Returns true if CST fits in signed HOST_WIDE_INT. */ *************** double_int_fits_in_uhwi_p (double_int cs *** 319,332 **** inline bool double_int_fits_in_shwi_p (double_int cst) { ! return cst.fits_signed (); } /* FIXME(crowl): Remove after converting callers. */ inline bool double_int_fits_in_hwi_p (double_int cst, bool uns) { ! return cst.fits (uns); } /* The following operations perform arithmetics modulo 2^precision, --- 319,332 ---- inline bool double_int_fits_in_shwi_p (double_int cst) { ! return cst.fits_shwi (); } /* FIXME(crowl): Remove after converting callers. */ inline bool double_int_fits_in_hwi_p (double_int cst, bool uns) { ! return cst.fits_hwi (uns); } /* The following operations perform arithmetics modulo 2^precision,