On Tue, Aug 7, 2012 at 2:35 AM, Lawrence Crowl <cr...@google.com> wrote: > Convert double_int from a struct with function into a class with > operators and methods. > > This patch adds the methods and operators. In general functions of > the form "double_int_whatever" become member functions "whatever" or, > when possible, operators. > > Every attempt has been made to preserve the existing algorithms, even > at the expense of some optimization opportunities. Some examples: > > The ext operation takes a value and returns a value. However, that > return value is usually assigned to the original variable. An > operation that modified a variable would be more efficient.
That's not always the case though and I think the interface should be consistent with existing behavior to avoid errors creeping in during the transition. > In some cases, an outer sign-specific function calls an inner > function with the sign as a parameter, which then decides which > implementation to do. Decisions should not be artificially > introduced, and the implementation of each case should be exposed as > a separate routine. > > The existing operations are implemented in terms of the new > operations, which necessarily adds a layer between the new code and > the existing users. Once all files have migrated, this layer will > be removed. > > There are several existing operations implemented in terms of even > older legacy operations. This extra layer has not been removed. > > On occasion though, parameterized functions are often called > with a constant argments. To support static statement of intent, > and potentially faster code in the future, there are several new > unparameterized member functions. Some examples: > > Four routines now encode both 'arithmetic or logical' and 'right or > left' shift as part of the funciton name. > > Four routines now encode both 'signed or unsigned' and 'less than or > greater than' as part of the function name. For most parts overloads that take an (unsigned) HOST_WIDE_INT argument would be nice, as well as the ability to say dbl + 1. > -typedef struct > +typedef struct double_int > { > +public: > + /* Normally, we would define constructors to create instances. > + Two things prevent us from doing so. > + First, defining a constructor makes the class non-POD in C++03, > + and we certainly want double_int to be a POD. > + Second, the GCC conding conventions prefer explicit conversion, > + and explicit conversion operators are not available until C++11. */ > + > + static double_int make (unsigned HOST_WIDE_INT cst); > + static double_int make (HOST_WIDE_INT cst); > + static double_int make (unsigned int cst); > + static double_int make (int cst); Did we somehow decide to not allow constructors? It's odd to convert to C++ and end up with static member functions resembling them ... Also I believe the conversion above introduces possible migration errors. Think of a previous HOST_WIDE_INT a; double_int d = uhwi_to_double_int (a); if you write that now as HOST_WIDE_INT a; double_int d = double_int::make (a); you get the effect of shwi_to_double_int. Oops. So as an intermediate I'd like you _not_ to introduce the make () overloads. Btw, if HOST_WIDE_INT == int the above won't even compile. Richard. > + /* No copy assignment operator or destructor to keep the type a POD. */ > + > + /* There are some special value-creation static member functions. */ > + > + static double_int mask (unsigned prec); > + static double_int max_value (unsigned int prec, bool uns); > + static double_int min_value (unsigned int prec, bool uns); > + > + /* The following functions are mutating operations. */ > + > + double_int &operator ++(); // prefix > + double_int &operator --(); // prefix > + double_int &operator *= (double_int); > + double_int &operator += (double_int); > + double_int &operator -= (double_int); > + > + /* The following functions are non-mutating operations. */ > + > + /* 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. */ > + > + int trailing_zeros () const; > + int popcount () const; > + > + /* Arithmetic query operations. */ > + > + bool multiple_of (double_int, bool, double_int *) const; > + > + /* Arithmetic operation functions. */ > + > + double_int set_bit (unsigned) const; > + double_int mul_with_sign (double_int, bool, int *) const; > + > + double_int operator * (double_int b) const; > + double_int operator + (double_int b) const; > + double_int operator - (double_int b) const; > + double_int operator - () const; > + double_int operator ~ () const; > + double_int operator & (double_int b) const; > + double_int operator | (double_int b) const; > + double_int operator ^ (double_int b) const; > + double_int and_not (double_int b) const; > + > + double_int lshift (HOST_WIDE_INT count, unsigned int prec, bool arith) > const; > + double_int rshift (HOST_WIDE_INT count, unsigned int prec, bool arith) > const; > + double_int alshift (HOST_WIDE_INT count, unsigned int prec) const; > + double_int arshift (HOST_WIDE_INT count, unsigned int prec) const; > + double_int llshift (HOST_WIDE_INT count, unsigned int prec) const; > + double_int lrshift (HOST_WIDE_INT count, unsigned int prec) const; > + double_int lrotate (HOST_WIDE_INT count, unsigned int prec) const; > + double_int rrotate (HOST_WIDE_INT count, unsigned int prec) const; > + > + /* You must ensure that double_int::ext is called on the operands > + of the following operations, if the precision of the numbers > + is less than HOST_BITS_PER_DOUBLE_INT bits. */ > + double_int div (double_int, bool, unsigned) const; > + double_int sdiv (double_int, unsigned) const; > + double_int udiv (double_int, unsigned) const; > + double_int mod (double_int, bool, unsigned) const; > + double_int smod (double_int, unsigned) const; > + double_int umod (double_int, unsigned) const; > + double_int divmod (double_int, bool, unsigned, double_int *) const; > + double_int sdivmod (double_int, unsigned, double_int *) const; > + double_int udivmod (double_int, unsigned, double_int *) const; > + > + /* Precision control functions. */ > + > + double_int ext (unsigned prec, bool uns) const; > + double_int zext (unsigned prec) const; > + double_int sext (unsigned prec) const; > + > + /* Comparative functions. */ > + > + bool is_zero () const; > + bool is_one () const; > + bool is_minus_one () const; > + bool is_negative () const; > + > + int cmp (double_int b, bool uns) const; > + int ucmp (double_int b) const; > + int scmp (double_int b) const; > + > + bool ult (double_int b) const; > + bool ugt (double_int b) const; > + bool slt (double_int b) const; > + bool sgt (double_int b) const; > + > + double_int max (double_int b, bool uns); > + double_int smax (double_int b); > + double_int umax (double_int b); > + > + double_int min (double_int b, bool uns); > + double_int smin (double_int b); > + double_int umin (double_int b); > + > + bool operator == (double_int cst2) const; > + bool operator != (double_int cst2) const; > + > + /* Please migrate away from using these member variables publically. */ > + > unsigned HOST_WIDE_INT low; > HOST_WIDE_INT high; > + > } double_int; > > #define HOST_BITS_PER_DOUBLE_INT (2 * HOST_BITS_PER_WIDE_INT) > @@ -63,66 +187,160 @@ typedef struct > /* Constructs double_int from integer CST. The bits over the precision of > HOST_WIDE_INT are filled with the sign bit. */ > > -static inline double_int > -shwi_to_double_int (HOST_WIDE_INT cst) > +inline > +double_int double_int::make (HOST_WIDE_INT cst) > { > double_int r; > - > r.low = (unsigned HOST_WIDE_INT) cst; > r.high = cst < 0 ? -1 : 0; > - > return r; > } > > +inline > +double_int double_int::make (int cst) > +{ > + return double_int::make (static_cast <HOST_WIDE_INT> (cst)); > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > +static inline double_int > +shwi_to_double_int (HOST_WIDE_INT cst) > +{ > + return double_int::make (cst); > +} > + > /* Some useful constants. */ > +/* FIXME(crowl): Maybe remove after converting callers? > + The problem is that a named constant would not be as optimizable, > + while the functional syntax is more verbose. */ > > -#define double_int_minus_one (shwi_to_double_int (-1)) > -#define double_int_zero (shwi_to_double_int (0)) > -#define double_int_one (shwi_to_double_int (1)) > -#define double_int_two (shwi_to_double_int (2)) > -#define double_int_ten (shwi_to_double_int (10)) > +#define double_int_minus_one (double_int::make (-1)) > +#define double_int_zero (double_int::make (0)) > +#define double_int_one (double_int::make (1)) > +#define double_int_two (double_int::make (2)) > +#define double_int_ten (double_int::make (10)) > > /* Constructs double_int from unsigned integer CST. The bits over the > precision of HOST_WIDE_INT are filled with zeros. */ > > -static inline double_int > -uhwi_to_double_int (unsigned HOST_WIDE_INT cst) > +inline > +double_int double_int::make (unsigned HOST_WIDE_INT cst) > { > double_int r; > - > r.low = cst; > r.high = 0; > - > return r; > } > > +inline > +double_int double_int::make (unsigned int cst) > +{ > + return double_int::make (static_cast <unsigned HOST_WIDE_INT> (cst)); > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > +static inline double_int > +uhwi_to_double_int (unsigned HOST_WIDE_INT cst) > +{ > + return double_int::make (cst); > +} > + > +inline double_int & > +double_int::operator ++ () > +{ > + *this + double_int_one; > + return *this; > +} > + > +inline double_int & > +double_int::operator -- () > +{ > + *this - double_int_one; > + return *this; > +} > + > +inline double_int & > +double_int::operator *= (double_int b) > +{ > + *this = *this * b; > + return *this; > +} > + > +inline double_int & > +double_int::operator += (double_int b) > +{ > + *this = *this + b; > + return *this; > +} > + > +inline double_int & > +double_int::operator -= (double_int b) > +{ > + *this = *this - b; > + return *this; > +} > + > /* Returns value of CST as a signed number. CST must satisfy > - double_int_fits_in_shwi_p. */ > + double_int::fits_signed. */ > + > +inline HOST_WIDE_INT > +double_int::to_signed () const > +{ > + return (HOST_WIDE_INT) low; > +} > > +/* FIXME(crowl): Remove after converting callers. */ > static inline HOST_WIDE_INT > double_int_to_shwi (double_int cst) > { > - return (HOST_WIDE_INT) cst.low; > + return cst.to_signed (); > } > > /* Returns value of CST as an unsigned number. CST must satisfy > - double_int_fits_in_uhwi_p. */ > + double_int::fits_unsigned. */ > + > +inline unsigned HOST_WIDE_INT > +double_int::to_unsigned () const > +{ > + return low; > +} > > +/* FIXME(crowl): Remove after converting callers. */ > static inline unsigned HOST_WIDE_INT > double_int_to_uhwi (double_int cst) > { > - return cst.low; > + return cst.to_unsigned (); > } > > -bool double_int_fits_in_hwi_p (double_int, bool); > -bool double_int_fits_in_shwi_p (double_int); > - > /* Returns true if CST fits in unsigned HOST_WIDE_INT. */ > > +inline bool > +double_int::fits_unsigned () const > +{ > + return high == 0; > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > static inline bool > double_int_fits_in_uhwi_p (double_int cst) > { > - return cst.high == 0; > + return cst.fits_unsigned (); > +} > + > +/* Returns true if CST fits in signed HOST_WIDE_INT. */ > + > +/* FIXME(crowl): Remove after converting callers. */ > +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, > @@ -130,88 +348,258 @@ double_int_fits_in_uhwi_p (double_int cs > you are representing numbers with precision less than > HOST_BITS_PER_DOUBLE_INT bits. */ > > -double_int double_int_mul (double_int, double_int); > -double_int double_int_mul_with_sign (double_int, double_int, bool, int *); > -double_int double_int_add (double_int, double_int); > -double_int double_int_sub (double_int, double_int); > -double_int double_int_neg (double_int); > +/* FIXME(crowl): Remove after converting callers. */ > +inline double_int > +double_int_mul (double_int a, double_int b) > +{ > + return a * b; > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > +inline double_int > +double_int_mul_with_sign (double_int a, double_int b, > + bool unsigned_p, int *overflow) > +{ > + return a.mul_with_sign (b, unsigned_p, overflow); > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > +inline double_int > +double_int_add (double_int a, double_int b) > +{ > + return a + b; > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > +inline double_int > +double_int_sub (double_int a, double_int b) > +{ > + return a - b; > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > +inline double_int > +double_int_neg (double_int a) > +{ > + return -a; > +} > > /* You must ensure that double_int_ext is called on the operands > of the following operations, if the precision of the numbers > is less than HOST_BITS_PER_DOUBLE_INT bits. */ > -double_int double_int_div (double_int, double_int, bool, unsigned); > -double_int double_int_sdiv (double_int, double_int, unsigned); > -double_int double_int_udiv (double_int, double_int, unsigned); > -double_int double_int_mod (double_int, double_int, bool, unsigned); > -double_int double_int_smod (double_int, double_int, unsigned); > -double_int double_int_umod (double_int, double_int, unsigned); > -double_int double_int_divmod (double_int, double_int, bool, unsigned, > double_int *); > -double_int double_int_sdivmod (double_int, double_int, unsigned, double_int > *); > -double_int double_int_udivmod (double_int, double_int, unsigned, double_int > *); > > -bool double_int_multiple_of (double_int, double_int, bool, double_int *); > +/* FIXME(crowl): Remove after converting callers. */ > +inline double_int > +double_int_div (double_int a, double_int b, bool uns, unsigned code) > +{ > + return a.div (b, uns, code); > +} > > -double_int double_int_setbit (double_int, unsigned); > -int double_int_ctz (double_int); > +/* FIXME(crowl): Remove after converting callers. */ > +inline double_int > +double_int_sdiv (double_int a, double_int b, unsigned code) > +{ > + return a.sdiv (b, code); > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > +inline double_int > +double_int_udiv (double_int a, double_int b, unsigned code) > +{ > + return a.udiv (b, code); > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > +inline double_int > +double_int_mod (double_int a, double_int b, bool uns, unsigned code) > +{ > + return a.mod (b, uns, code); > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > +inline double_int > +double_int_smod (double_int a, double_int b, unsigned code) > +{ > + return a.smod (b, code); > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > +inline double_int > +double_int_umod (double_int a, double_int b, unsigned code) > +{ > + return a.umod (b, code); > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > +inline double_int > +double_int_divmod (double_int a, double_int b, bool uns, > + unsigned code, double_int *mod) > +{ > + return a.divmod (b, uns, code, mod); > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > +inline double_int > +double_int_sdivmod (double_int a, double_int b, unsigned code, double_int > *mod) > +{ > + return a.sdivmod (b, code, mod); > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > +inline double_int > +double_int_udivmod (double_int a, double_int b, unsigned code, double_int > *mod) > +{ > + return a.udivmod (b, code, mod); > +} > + > +/***/ > + > +/* FIXME(crowl): Remove after converting callers. */ > +inline bool > +double_int_multiple_of (double_int product, double_int factor, > + bool unsigned_p, double_int *multiple) > +{ > + return product.multiple_of (factor, unsigned_p, multiple); > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > +inline double_int > +double_int_setbit (double_int a, unsigned bitpos) > +{ > + return a.set_bit (bitpos); > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > +inline int > +double_int_ctz (double_int a) > +{ > + return a.trailing_zeros (); > +} > > /* Logical operations. */ > > /* Returns ~A. */ > > +inline double_int > +double_int::operator ~ () const > +{ > + double_int result; > + result.low = ~low; > + result.high = ~high; > + return result; > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > static inline double_int > double_int_not (double_int a) > { > - a.low = ~a.low; > - a.high = ~a.high; > - return a; > + return ~a; > } > > /* Returns A | B. */ > > +inline double_int > +double_int::operator | (double_int b) const > +{ > + double_int result; > + result.low = low | b.low; > + result.high = high | b.high; > + return result; > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > static inline double_int > double_int_ior (double_int a, double_int b) > { > - a.low |= b.low; > - a.high |= b.high; > - return a; > + return a | b; > } > > /* Returns A & B. */ > > +inline double_int > +double_int::operator & (double_int b) const > +{ > + double_int result; > + result.low = low & b.low; > + result.high = high & b.high; > + return result; > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > static inline double_int > double_int_and (double_int a, double_int b) > { > - a.low &= b.low; > - a.high &= b.high; > - return a; > + return a & b; > } > > /* Returns A & ~B. */ > > +inline double_int > +double_int::and_not (double_int b) const > +{ > + double_int result; > + result.low = low & ~b.low; > + result.high = high & ~b.high; > + return result; > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > static inline double_int > double_int_and_not (double_int a, double_int b) > { > - a.low &= ~b.low; > - a.high &= ~b.high; > - return a; > + return a.and_not (b); > } > > /* Returns A ^ B. */ > > +inline double_int > +double_int::operator ^ (double_int b) const > +{ > + double_int result; > + result.low = low ^ b.low; > + result.high = high ^ b.high; > + return result; > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > static inline double_int > double_int_xor (double_int a, double_int b) > { > - a.low ^= b.low; > - a.high ^= b.high; > - return a; > + return a ^ b; > } > > > /* Shift operations. */ > -double_int double_int_lshift (double_int, HOST_WIDE_INT, unsigned int, bool); > -double_int double_int_rshift (double_int, HOST_WIDE_INT, unsigned int, bool); > -double_int double_int_lrotate (double_int, HOST_WIDE_INT, unsigned int); > -double_int double_int_rrotate (double_int, HOST_WIDE_INT, unsigned int); > + > +/* FIXME(crowl): Remove after converting callers. */ > +inline double_int > +double_int_lshift (double_int a, HOST_WIDE_INT count, unsigned int prec, > + bool arith) > +{ > + return a.lshift (count, prec, arith); > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > +inline double_int > +double_int_rshift (double_int a, HOST_WIDE_INT count, unsigned int prec, > + bool arith) > +{ > + return a.rshift (count, prec, arith); > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > +inline double_int > +double_int_lrotate (double_int a, HOST_WIDE_INT count, unsigned int prec) > +{ > + return a.lrotate (count, prec); > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > +inline double_int > +double_int_rrotate (double_int a, HOST_WIDE_INT count, unsigned int prec) > +{ > + return a.rrotate (count, prec); > +} > > /* Returns true if CST is negative. Of course, CST is considered to > be signed. */ > @@ -222,29 +610,115 @@ double_int_negative_p (double_int cst) > return cst.high < 0; > } > > -int double_int_cmp (double_int, double_int, bool); > -int double_int_scmp (double_int, double_int); > -int double_int_ucmp (double_int, double_int); > +/* FIXME(crowl): Remove after converting callers. */ > +inline int > +double_int_cmp (double_int a, double_int b, bool uns) > +{ > + return a.cmp (b, uns); > +} > > -double_int double_int_max (double_int, double_int, bool); > -double_int double_int_smax (double_int, double_int); > -double_int double_int_umax (double_int, double_int); > +/* FIXME(crowl): Remove after converting callers. */ > +inline int > +double_int_scmp (double_int a, double_int b) > +{ > + return a.scmp (b); > +} > > -double_int double_int_min (double_int, double_int, bool); > -double_int double_int_smin (double_int, double_int); > -double_int double_int_umin (double_int, double_int); > +/* FIXME(crowl): Remove after converting callers. */ > +inline int > +double_int_ucmp (double_int a, double_int b) > +{ > + return a.ucmp (b); > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > +inline double_int > +double_int_max (double_int a, double_int b, bool uns) > +{ > + return a.max (b, uns); > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > +inline double_int > +double_int_smax (double_int a, double_int b) > +{ > + return a.smax (b); > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > +inline double_int > +double_int_umax (double_int a, double_int b) > +{ > + return a.umax (b); > +} > + > + > +/* FIXME(crowl): Remove after converting callers. */ > +inline double_int > +double_int_min (double_int a, double_int b, bool uns) > +{ > + return a.min (b, uns); > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > +inline double_int > +double_int_smin (double_int a, double_int b) > +{ > + return a.smin (b); > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > +inline double_int > +double_int_umin (double_int a, double_int b) > +{ > + return a.umin (b); > +} > > void dump_double_int (FILE *, double_int, bool); > > /* Zero and sign extension of numbers in smaller precisions. */ > > -double_int double_int_ext (double_int, unsigned, bool); > -double_int double_int_sext (double_int, unsigned); > -double_int double_int_zext (double_int, unsigned); > -double_int double_int_mask (unsigned); > +/* FIXME(crowl): Remove after converting callers. */ > +inline double_int > +double_int_ext (double_int a, unsigned prec, bool uns) > +{ > + return a.ext (prec, uns); > +} > > -double_int double_int_max_value (unsigned int, bool); > -double_int double_int_min_value (unsigned int, bool); > +/* FIXME(crowl): Remove after converting callers. */ > +inline double_int > +double_int_sext (double_int a, unsigned prec) > +{ > + return a.sext (prec); > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > +inline double_int > +double_int_zext (double_int a, unsigned prec) > +{ > + return a.zext (prec); > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > +inline double_int > +double_int_mask (unsigned prec) > +{ > + return double_int::mask (prec); > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > +inline double_int > +double_int_max_value (unsigned int prec, bool uns) > +{ > + return double_int::max_value (prec, uns); > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > +inline double_int > +double_int_min_value (unsigned int prec, bool uns) > +{ > + return double_int::min_value (prec, uns); > +} > > #define ALL_ONES (~((unsigned HOST_WIDE_INT) 0)) > > @@ -254,64 +728,122 @@ double_int double_int_min_value (unsigne > > /* Returns true if CST is zero. */ > > +inline bool > +double_int::is_zero () const > +{ > + return low == 0 && high == 0; > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > static inline bool > double_int_zero_p (double_int cst) > { > - return cst.low == 0 && cst.high == 0; > + return cst.is_zero (); > } > > /* Returns true if CST is one. */ > > +inline bool > +double_int::is_one () const > +{ > + return low == 1 && high == 0; > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > static inline bool > double_int_one_p (double_int cst) > { > - return cst.low == 1 && cst.high == 0; > + return cst.is_one (); > } > > /* Returns true if CST is minus one. */ > > +inline bool > +double_int::is_minus_one () const > +{ > + return low == ALL_ONES && high == -1; > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > static inline bool > double_int_minus_one_p (double_int cst) > { > - return (cst.low == ALL_ONES && cst.high == -1); > + return cst.is_minus_one (); > +} > + > +/* Returns true if CST is negative. */ > + > +inline bool > +double_int::is_negative () const > +{ > + return high < 0; > } > > /* Returns true if CST1 == CST2. */ > > +inline bool > +double_int::operator == (double_int cst2) const > +{ > + return low == cst2.low && high == cst2.high; > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > static inline bool > double_int_equal_p (double_int cst1, double_int cst2) > { > - return cst1.low == cst2.low && cst1.high == cst2.high; > + return cst1 == cst2; > +} > + > +/* Returns true if CST1 != CST2. */ > + > +inline bool > +double_int::operator != (double_int cst2) const > +{ > + return low != cst2.low || high != cst2.high; > } > > /* Return number of set bits of CST. */ > > +inline int > +double_int::popcount () const > +{ > + return popcount_hwi (high) + popcount_hwi (low); > +} > + > +/* FIXME(crowl): Remove after converting callers. */ > static inline int > double_int_popcount (double_int cst) > { > - return popcount_hwi (cst.high) + popcount_hwi (cst.low); > + return cst.popcount (); > } > > > /* Legacy interface with decomposed high/low parts. */ > > +/* FIXME(crowl): Remove after converting callers. */ > extern int add_double_with_sign (unsigned HOST_WIDE_INT, HOST_WIDE_INT, > unsigned HOST_WIDE_INT, HOST_WIDE_INT, > unsigned HOST_WIDE_INT *, HOST_WIDE_INT *, > bool); > +/* FIXME(crowl): Remove after converting callers. */ > #define add_double(l1,h1,l2,h2,lv,hv) \ > add_double_with_sign (l1, h1, l2, h2, lv, hv, false) > +/* FIXME(crowl): Remove after converting callers. */ > extern int neg_double (unsigned HOST_WIDE_INT, HOST_WIDE_INT, > unsigned HOST_WIDE_INT *, HOST_WIDE_INT *); > +/* FIXME(crowl): Remove after converting callers. */ > extern int mul_double_with_sign (unsigned HOST_WIDE_INT, HOST_WIDE_INT, > unsigned HOST_WIDE_INT, HOST_WIDE_INT, > unsigned HOST_WIDE_INT *, HOST_WIDE_INT *, > bool); > +/* FIXME(crowl): Remove after converting callers. */ > #define mul_double(l1,h1,l2,h2,lv,hv) \ > mul_double_with_sign (l1, h1, l2, h2, lv, hv, false) > +/* FIXME(crowl): Remove after converting callers. */ > extern void lshift_double (unsigned HOST_WIDE_INT, HOST_WIDE_INT, > HOST_WIDE_INT, unsigned int, > unsigned HOST_WIDE_INT *, HOST_WIDE_INT *, bool); > +/* FIXME(crowl): Remove after converting callers. */ > extern int div_and_round_double (unsigned, int, unsigned HOST_WIDE_INT, > HOST_WIDE_INT, unsigned HOST_WIDE_INT, > HOST_WIDE_INT, unsigned HOST_WIDE_INT *, > Index: gcc/fixed-value.c > =================================================================== > --- gcc/fixed-value.c (revision 190186) > +++ gcc/fixed-value.c (working copy) > @@ -111,13 +111,11 @@ fixed_from_string (FIXED_VALUE_TYPE *f, > /* From the spec, we need to evaluate 1 to the maximal value. */ > f->data.low = -1; > f->data.high = -1; > - f->data = double_int_ext (f->data, > - GET_MODE_FBIT (f->mode) > - + GET_MODE_IBIT (f->mode), 1); > + f->data = f->data.zext (GET_MODE_FBIT (f->mode) > + + GET_MODE_IBIT (f->mode)); > } > else > - f->data = double_int_ext (f->data, > - SIGNED_FIXED_POINT_MODE_P (f->mode) > + f->data = f->data.ext (SIGNED_FIXED_POINT_MODE_P (f->mode) > + GET_MODE_FBIT (f->mode) > + GET_MODE_IBIT (f->mode), > UNSIGNED_FIXED_POINT_MODE_P (f->mode)); > @@ -159,8 +157,8 @@ fixed_saturate1 (enum machine_mode mode, > double_int max; > max.low = -1; > max.high = -1; > - max = double_int_ext (max, i_f_bits, 1); > - if (double_int_cmp (a, max, 1) == 1) > + max = max.zext (i_f_bits); > + if (a.ugt (max)) > { > if (sat_p) > *f = max; > @@ -173,21 +171,19 @@ fixed_saturate1 (enum machine_mode mode, > double_int max, min; > max.high = -1; > max.low = -1; > - max = double_int_ext (max, i_f_bits, 1); > + max = max.zext (i_f_bits); > min.high = 0; > min.low = 1; > - lshift_double (min.low, min.high, i_f_bits, > - HOST_BITS_PER_DOUBLE_INT, > - &min.low, &min.high, 1); > - min = double_int_ext (min, 1 + i_f_bits, 0); > - if (double_int_cmp (a, max, 0) == 1) > + min = min.alshift (i_f_bits, HOST_BITS_PER_DOUBLE_INT); > + min = min.sext (1 + i_f_bits); > + if (a.sgt (max)) > { > if (sat_p) > *f = max; > else > overflow_p = true; > } > - else if (double_int_cmp (a, min, 0) == -1) > + else if (a.slt (min)) > { > if (sat_p) > *f = min; > @@ -221,10 +217,10 @@ fixed_saturate2 (enum machine_mode mode, > max_r.low = 0; > max_s.high = -1; > max_s.low = -1; > - max_s = double_int_ext (max_s, i_f_bits, 1); > - if (double_int_cmp (a_high, max_r, 1) == 1 > - || (double_int_equal_p (a_high, max_r) && > - double_int_cmp (a_low, max_s, 1) == 1)) > + max_s = max_s.zext (i_f_bits); > + if (a_high.ugt (max_r) > + || (a_high == max_r && > + a_low.ugt (max_s))) > { > if (sat_p) > *f = max_s; > @@ -239,27 +235,25 @@ fixed_saturate2 (enum machine_mode mode, > max_r.low = 0; > max_s.high = -1; > max_s.low = -1; > - max_s = double_int_ext (max_s, i_f_bits, 1); > + max_s = max_s.zext (i_f_bits); > min_r.high = -1; > min_r.low = -1; > min_s.high = 0; > min_s.low = 1; > - lshift_double (min_s.low, min_s.high, i_f_bits, > - HOST_BITS_PER_DOUBLE_INT, > - &min_s.low, &min_s.high, 1); > - min_s = double_int_ext (min_s, 1 + i_f_bits, 0); > - if (double_int_cmp (a_high, max_r, 0) == 1 > - || (double_int_equal_p (a_high, max_r) && > - double_int_cmp (a_low, max_s, 1) == 1)) > + min_s = min_s.alshift (i_f_bits, HOST_BITS_PER_DOUBLE_INT); > + min_s = min_s.sext (1 + i_f_bits); > + if (a_high.sgt (max_r) > + || (a_high == max_r && > + a_low.ugt (max_s))) > { > if (sat_p) > *f = max_s; > else > overflow_p = true; > } > - else if (double_int_cmp (a_high, min_r, 0) == -1 > - || (double_int_equal_p (a_high, min_r) && > - double_int_cmp (a_low, min_s, 1) == -1)) > + else if (a_high.slt (min_r) > + || (a_high == min_r && > + a_low.ult (min_s))) > { > if (sat_p) > *f = min_s; > @@ -297,19 +291,19 @@ do_fixed_add (FIXED_VALUE_TYPE *f, const > /* This was a conditional expression but it triggered a bug in > Sun C 5.5. */ > if (subtract_p) > - temp = double_int_neg (b->data); > + temp = -b->data; > else > temp = b->data; > > unsigned_p = UNSIGNED_FIXED_POINT_MODE_P (a->mode); > i_f_bits = GET_MODE_IBIT (a->mode) + GET_MODE_FBIT (a->mode); > f->mode = a->mode; > - f->data = double_int_add (a->data, temp); > + f->data = a->data + temp; > if (unsigned_p) /* Unsigned type. */ > { > if (subtract_p) /* Unsigned subtraction. */ > { > - if (double_int_cmp (a->data, b->data, 1) == -1) > + if (a->data.ult (b->data)) > { > if (sat_p) > { > @@ -322,9 +316,9 @@ do_fixed_add (FIXED_VALUE_TYPE *f, const > } > else /* Unsigned addition. */ > { > - f->data = double_int_ext (f->data, i_f_bits, 1); > - if (double_int_cmp (f->data, a->data, 1) == -1 > - || double_int_cmp (f->data, b->data, 1) == -1) > + f->data = f->data.zext (i_f_bits); > + if (f->data.ult (a->data) > + || f->data.ult (b->data)) > { > if (sat_p) > { > @@ -353,22 +347,17 @@ do_fixed_add (FIXED_VALUE_TYPE *f, const > { > f->data.low = 1; > f->data.high = 0; > - lshift_double (f->data.low, f->data.high, i_f_bits, > - HOST_BITS_PER_DOUBLE_INT, > - &f->data.low, &f->data.high, 1); > + f->data = f->data.alshift (i_f_bits, HOST_BITS_PER_DOUBLE_INT); > if (get_fixed_sign_bit (a->data, i_f_bits) == 0) > { > - double_int one; > - one.low = 1; > - one.high = 0; > - f->data = double_int_sub (f->data, one); > + --f->data; > } > } > else > overflow_p = true; > } > } > - f->data = double_int_ext (f->data, (!unsigned_p) + i_f_bits, unsigned_p); > + f->data = f->data.ext ((!unsigned_p) + i_f_bits, unsigned_p); > return overflow_p; > } > > @@ -386,11 +375,10 @@ do_fixed_multiply (FIXED_VALUE_TYPE *f, > f->mode = a->mode; > if (GET_MODE_PRECISION (f->mode) <= HOST_BITS_PER_WIDE_INT) > { > - f->data = double_int_mul (a->data, b->data); > - lshift_double (f->data.low, f->data.high, > - (-GET_MODE_FBIT (f->mode)), > + f->data = a->data * b->data; > + f->data = f->data.lshift ((-GET_MODE_FBIT (f->mode)), > HOST_BITS_PER_DOUBLE_INT, > - &f->data.low, &f->data.high, !unsigned_p); > + !unsigned_p); > overflow_p = fixed_saturate1 (f->mode, f->data, &f->data, sat_p); > } > else > @@ -412,43 +400,43 @@ do_fixed_multiply (FIXED_VALUE_TYPE *f, > b_low.high = 0; > > /* Perform four multiplications. */ > - low_low = double_int_mul (a_low, b_low); > - low_high = double_int_mul (a_low, b_high); > - high_low = double_int_mul (a_high, b_low); > - high_high = double_int_mul (a_high, b_high); > + low_low = a_low * b_low; > + low_high = a_low * b_high; > + high_low = a_high * b_low; > + high_high = a_high * b_high; > > /* Accumulate four results to {r, s}. */ > temp1.high = high_low.low; > temp1.low = 0; > - s = double_int_add (low_low, temp1); > - if (double_int_cmp (s, low_low, 1) == -1 > - || double_int_cmp (s, temp1, 1) == -1) > + s = low_low + temp1; > + if (s.ult (low_low) > + || s.ult (temp1)) > carry ++; /* Carry */ > temp1.high = s.high; > temp1.low = s.low; > temp2.high = low_high.low; > temp2.low = 0; > - s = double_int_add (temp1, temp2); > - if (double_int_cmp (s, temp1, 1) == -1 > - || double_int_cmp (s, temp2, 1) == -1) > + s = temp1 + temp2; > + if (s.ult (temp1) > + || s.ult (temp2)) > carry ++; /* Carry */ > > temp1.low = high_low.high; > temp1.high = 0; > - r = double_int_add (high_high, temp1); > + r = high_high + temp1; > temp1.low = low_high.high; > temp1.high = 0; > - r = double_int_add (r, temp1); > + r += temp1; > temp1.low = carry; > temp1.high = 0; > - r = double_int_add (r, temp1); > + r += temp1; > > /* We need to subtract b from r, if a < 0. */ > if (!unsigned_p && a->data.high < 0) > - r = double_int_sub (r, b->data); > + r -= b->data; > /* We need to subtract a from r, if b < 0. */ > if (!unsigned_p && b->data.high < 0) > - r = double_int_sub (r, a->data); > + r -= a->data; > > /* Shift right the result by FBIT. */ > if (GET_MODE_FBIT (f->mode) == HOST_BITS_PER_DOUBLE_INT) > @@ -470,29 +458,23 @@ do_fixed_multiply (FIXED_VALUE_TYPE *f, > } > else > { > - lshift_double (s.low, s.high, > - (-GET_MODE_FBIT (f->mode)), > - HOST_BITS_PER_DOUBLE_INT, > - &s.low, &s.high, 0); > - lshift_double (r.low, r.high, > - (HOST_BITS_PER_DOUBLE_INT > + s = s.llshift ((-GET_MODE_FBIT (f->mode)), > HOST_BITS_PER_DOUBLE_INT); > + f->data = r.llshift ((HOST_BITS_PER_DOUBLE_INT > - GET_MODE_FBIT (f->mode)), > - HOST_BITS_PER_DOUBLE_INT, > - &f->data.low, &f->data.high, 0); > + HOST_BITS_PER_DOUBLE_INT); > f->data.low = f->data.low | s.low; > f->data.high = f->data.high | s.high; > s.low = f->data.low; > s.high = f->data.high; > - lshift_double (r.low, r.high, > - (-GET_MODE_FBIT (f->mode)), > + r = r.lshift ((-GET_MODE_FBIT (f->mode)), > HOST_BITS_PER_DOUBLE_INT, > - &r.low, &r.high, !unsigned_p); > + !unsigned_p); > } > > overflow_p = fixed_saturate2 (f->mode, r, s, &f->data, sat_p); > } > > - f->data = double_int_ext (f->data, (!unsigned_p) + i_f_bits, unsigned_p); > + f->data = f->data.ext ((!unsigned_p) + i_f_bits, unsigned_p); > return overflow_p; > } > > @@ -510,11 +492,10 @@ do_fixed_divide (FIXED_VALUE_TYPE *f, co > f->mode = a->mode; > if (GET_MODE_PRECISION (f->mode) <= HOST_BITS_PER_WIDE_INT) > { > - lshift_double (a->data.low, a->data.high, > - GET_MODE_FBIT (f->mode), > + f->data = a->data.lshift (GET_MODE_FBIT (f->mode), > HOST_BITS_PER_DOUBLE_INT, > - &f->data.low, &f->data.high, !unsigned_p); > - f->data = double_int_div (f->data, b->data, unsigned_p, > TRUNC_DIV_EXPR); > + !unsigned_p); > + f->data = f->data.div (b->data, unsigned_p, TRUNC_DIV_EXPR); > overflow_p = fixed_saturate1 (f->mode, f->data, &f->data, sat_p); > } > else > @@ -527,7 +508,7 @@ do_fixed_divide (FIXED_VALUE_TYPE *f, co > /* If a < 0, negate a. */ > if (!unsigned_p && a->data.high < 0) > { > - pos_a = double_int_neg (a->data); > + pos_a = -a->data; > num_of_neg ++; > } > else > @@ -536,7 +517,7 @@ do_fixed_divide (FIXED_VALUE_TYPE *f, co > /* If b < 0, negate b. */ > if (!unsigned_p && b->data.high < 0) > { > - pos_b = double_int_neg (b->data); > + pos_b = -b->data; > num_of_neg ++; > } > else > @@ -551,24 +532,15 @@ do_fixed_divide (FIXED_VALUE_TYPE *f, co > } > else > { > - lshift_double (pos_a.low, pos_a.high, > - GET_MODE_FBIT (f->mode), > - HOST_BITS_PER_DOUBLE_INT, > - &s.low, &s.high, 0); > - lshift_double (pos_a.low, pos_a.high, > - - (HOST_BITS_PER_DOUBLE_INT > + s = pos_a.llshift (GET_MODE_FBIT (f->mode), > HOST_BITS_PER_DOUBLE_INT); > + r = pos_a.llshift (- (HOST_BITS_PER_DOUBLE_INT > - GET_MODE_FBIT (f->mode)), > - HOST_BITS_PER_DOUBLE_INT, > - &r.low, &r.high, 0); > + HOST_BITS_PER_DOUBLE_INT); > } > > /* Divide r by pos_b to quo_r. The remainder is in mod. */ > - div_and_round_double (TRUNC_DIV_EXPR, 1, r.low, r.high, pos_b.low, > - pos_b.high, &quo_r.low, &quo_r.high, &mod.low, > - &mod.high); > - > - quo_s.high = 0; > - quo_s.low = 0; > + quo_r = r.divmod (pos_b, 1, TRUNC_DIV_EXPR, &mod); > + quo_s = double_int_zero; > > for (i = 0; i < HOST_BITS_PER_DOUBLE_INT; i++) > { > @@ -576,37 +548,34 @@ do_fixed_divide (FIXED_VALUE_TYPE *f, co > int leftmost_mod = (mod.high < 0); > > /* Shift left mod by 1 bit. */ > - lshift_double (mod.low, mod.high, 1, HOST_BITS_PER_DOUBLE_INT, > - &mod.low, &mod.high, 0); > + mod = mod.llshift (1, HOST_BITS_PER_DOUBLE_INT); > > /* Test the leftmost bit of s to add to mod. */ > if (s.high < 0) > mod.low += 1; > > /* Shift left quo_s by 1 bit. */ > - lshift_double (quo_s.low, quo_s.high, 1, HOST_BITS_PER_DOUBLE_INT, > - &quo_s.low, &quo_s.high, 0); > + quo_s = quo_s.llshift (1, HOST_BITS_PER_DOUBLE_INT); > > /* Try to calculate (mod - pos_b). */ > - temp = double_int_sub (mod, pos_b); > + temp = mod - pos_b; > > - if (leftmost_mod == 1 || double_int_cmp (mod, pos_b, 1) != -1) > + if (leftmost_mod == 1 || mod.ucmp (pos_b) != -1) > { > quo_s.low += 1; > mod = temp; > } > > /* Shift left s by 1 bit. */ > - lshift_double (s.low, s.high, 1, HOST_BITS_PER_DOUBLE_INT, > - &s.low, &s.high, 0); > + s = s.llshift (1, HOST_BITS_PER_DOUBLE_INT); > > } > > if (num_of_neg == 1) > { > - quo_s = double_int_neg (quo_s); > + quo_s = -quo_s; > if (quo_s.high == 0 && quo_s.low == 0) > - quo_r = double_int_neg (quo_r); > + quo_r = -quo_r; > else > { > quo_r.low = ~quo_r.low; > @@ -618,7 +587,7 @@ do_fixed_divide (FIXED_VALUE_TYPE *f, co > overflow_p = fixed_saturate2 (f->mode, quo_r, quo_s, &f->data, sat_p); > } > > - f->data = double_int_ext (f->data, (!unsigned_p) + i_f_bits, unsigned_p); > + f->data = f->data.ext ((!unsigned_p) + i_f_bits, unsigned_p); > return overflow_p; > } > > @@ -643,10 +612,9 @@ do_fixed_shift (FIXED_VALUE_TYPE *f, con > > if (GET_MODE_PRECISION (f->mode) <= HOST_BITS_PER_WIDE_INT || (!left_p)) > { > - lshift_double (a->data.low, a->data.high, > - left_p ? b->data.low : (-b->data.low), > + f->data = a->data.lshift (left_p ? b->data.low : (-b->data.low), > HOST_BITS_PER_DOUBLE_INT, > - &f->data.low, &f->data.high, !unsigned_p); > + !unsigned_p); > if (left_p) /* Only left shift saturates. */ > overflow_p = fixed_saturate1 (f->mode, f->data, &f->data, sat_p); > } > @@ -661,23 +629,20 @@ do_fixed_shift (FIXED_VALUE_TYPE *f, con > } > else > { > - lshift_double (a->data.low, a->data.high, > - b->data.low, > + temp_low = a->data.lshift (b->data.low, > HOST_BITS_PER_DOUBLE_INT, > - &temp_low.low, &temp_low.high, !unsigned_p); > + !unsigned_p); > /* Logical shift right to temp_high. */ > - lshift_double (a->data.low, a->data.high, > - b->data.low - HOST_BITS_PER_DOUBLE_INT, > - HOST_BITS_PER_DOUBLE_INT, > - &temp_high.low, &temp_high.high, 0); > + temp_high = a->data.llshift (b->data.low - HOST_BITS_PER_DOUBLE_INT, > + HOST_BITS_PER_DOUBLE_INT); > } > if (!unsigned_p && a->data.high < 0) /* Signed-extend temp_high. */ > - temp_high = double_int_ext (temp_high, b->data.low, unsigned_p); > + temp_high = temp_high.ext (b->data.low, unsigned_p); > f->data = temp_low; > overflow_p = fixed_saturate2 (f->mode, temp_high, temp_low, &f->data, > sat_p); > } > - f->data = double_int_ext (f->data, (!unsigned_p) + i_f_bits, unsigned_p); > + f->data = f->data.ext ((!unsigned_p) + i_f_bits, unsigned_p); > return overflow_p; > } > > @@ -692,8 +657,8 @@ do_fixed_neg (FIXED_VALUE_TYPE *f, const > bool unsigned_p = UNSIGNED_FIXED_POINT_MODE_P (a->mode); > int i_f_bits = GET_MODE_IBIT (a->mode) + GET_MODE_FBIT (a->mode); > f->mode = a->mode; > - f->data = double_int_neg (a->data); > - f->data = double_int_ext (f->data, (!unsigned_p) + i_f_bits, unsigned_p); > + f->data = -a->data; > + f->data = f->data.ext ((!unsigned_p) + i_f_bits, unsigned_p); > > if (unsigned_p) /* Unsigned type. */ > { > @@ -718,7 +683,7 @@ do_fixed_neg (FIXED_VALUE_TYPE *f, const > /* Saturate to the maximum by subtracting f->data by one. */ > f->data.low = -1; > f->data.high = -1; > - f->data = double_int_ext (f->data, i_f_bits, 1); > + f->data = f->data.zext (i_f_bits); > } > else > overflow_p = true; > @@ -789,25 +754,25 @@ fixed_compare (int icode, const FIXED_VA > switch (code) > { > case NE_EXPR: > - return !double_int_equal_p (op0->data, op1->data); > + return op0->data != op1->data; > > case EQ_EXPR: > - return double_int_equal_p (op0->data, op1->data); > + return op0->data == op1->data; > > case LT_EXPR: > - return double_int_cmp (op0->data, op1->data, > + return op0->data.cmp (op1->data, > UNSIGNED_FIXED_POINT_MODE_P (op0->mode)) == -1; > > case LE_EXPR: > - return double_int_cmp (op0->data, op1->data, > + return op0->data.cmp (op1->data, > UNSIGNED_FIXED_POINT_MODE_P (op0->mode)) != 1; > > case GT_EXPR: > - return double_int_cmp (op0->data, op1->data, > + return op0->data.cmp (op1->data, > UNSIGNED_FIXED_POINT_MODE_P (op0->mode)) == 1; > > case GE_EXPR: > - return double_int_cmp (op0->data, op1->data, > + return op0->data.cmp (op1->data, > UNSIGNED_FIXED_POINT_MODE_P (op0->mode)) != -1; > > default: > @@ -835,19 +800,15 @@ fixed_convert (FIXED_VALUE_TYPE *f, enum > /* Left shift a to temp_high, temp_low based on a->mode. */ > double_int temp_high, temp_low; > int amount = GET_MODE_FBIT (mode) - GET_MODE_FBIT (a->mode); > - lshift_double (a->data.low, a->data.high, > - amount, > + temp_low = a->data.lshift (amount, > HOST_BITS_PER_DOUBLE_INT, > - &temp_low.low, &temp_low.high, > SIGNED_FIXED_POINT_MODE_P (a->mode)); > /* Logical shift right to temp_high. */ > - lshift_double (a->data.low, a->data.high, > - amount - HOST_BITS_PER_DOUBLE_INT, > - HOST_BITS_PER_DOUBLE_INT, > - &temp_high.low, &temp_high.high, 0); > + temp_high = a->data.llshift (amount - HOST_BITS_PER_DOUBLE_INT, > + HOST_BITS_PER_DOUBLE_INT); > if (SIGNED_FIXED_POINT_MODE_P (a->mode) > && a->data.high < 0) /* Signed-extend temp_high. */ > - temp_high = double_int_ext (temp_high, amount, 0); > + temp_high = temp_high.sext (amount); > f->mode = mode; > f->data = temp_low; > if (SIGNED_FIXED_POINT_MODE_P (a->mode) == > @@ -885,10 +846,9 @@ fixed_convert (FIXED_VALUE_TYPE *f, enum > /* Set to maximum. */ > f->data.low = -1; /* Set to all ones. */ > f->data.high = -1; /* Set to all ones. */ > - f->data = double_int_ext (f->data, > - GET_MODE_FBIT (f->mode) > - + GET_MODE_IBIT (f->mode), > - 1); /* Clear the sign. */ > + f->data = f->data.zext (GET_MODE_FBIT (f->mode) > + + GET_MODE_IBIT (f->mode)); > + /* Clear the sign. */ > } > else > overflow_p = true; > @@ -903,10 +863,8 @@ fixed_convert (FIXED_VALUE_TYPE *f, enum > { > /* Right shift a to temp based on a->mode. */ > double_int temp; > - lshift_double (a->data.low, a->data.high, > - GET_MODE_FBIT (mode) - GET_MODE_FBIT (a->mode), > + temp = a->data.lshift (GET_MODE_FBIT (mode) - GET_MODE_FBIT (a->mode), > HOST_BITS_PER_DOUBLE_INT, > - &temp.low, &temp.high, > SIGNED_FIXED_POINT_MODE_P (a->mode)); > f->mode = mode; > f->data = temp; > @@ -944,10 +902,9 @@ fixed_convert (FIXED_VALUE_TYPE *f, enum > /* Set to maximum. */ > f->data.low = -1; /* Set to all ones. */ > f->data.high = -1; /* Set to all ones. */ > - f->data = double_int_ext (f->data, > - GET_MODE_FBIT (f->mode) > - + GET_MODE_IBIT (f->mode), > - 1); /* Clear the sign. */ > + f->data = f->data.zext (GET_MODE_FBIT (f->mode) > + + GET_MODE_IBIT (f->mode)); > + /* Clear the sign. */ > } > else > overflow_p = true; > @@ -959,8 +916,7 @@ fixed_convert (FIXED_VALUE_TYPE *f, enum > } > } > > - f->data = double_int_ext (f->data, > - SIGNED_FIXED_POINT_MODE_P (f->mode) > + f->data = f->data.ext (SIGNED_FIXED_POINT_MODE_P (f->mode) > + GET_MODE_FBIT (f->mode) > + GET_MODE_IBIT (f->mode), > UNSIGNED_FIXED_POINT_MODE_P (f->mode)); > @@ -988,19 +944,14 @@ fixed_convert_from_int (FIXED_VALUE_TYPE > } > else > { > - lshift_double (a.low, a.high, > - amount, > - HOST_BITS_PER_DOUBLE_INT, > - &temp_low.low, &temp_low.high, 0); > + temp_low = a.llshift (amount, HOST_BITS_PER_DOUBLE_INT); > > /* Logical shift right to temp_high. */ > - lshift_double (a.low, a.high, > - amount - HOST_BITS_PER_DOUBLE_INT, > - HOST_BITS_PER_DOUBLE_INT, > - &temp_high.low, &temp_high.high, 0); > + temp_high = a.llshift (amount - HOST_BITS_PER_DOUBLE_INT, > + HOST_BITS_PER_DOUBLE_INT); > } > if (!unsigned_p && a.high < 0) /* Signed-extend temp_high. */ > - temp_high = double_int_ext (temp_high, amount, 0); > + temp_high = temp_high.sext (amount); > > f->mode = mode; > f->data = temp_low; > @@ -1038,10 +989,9 @@ fixed_convert_from_int (FIXED_VALUE_TYPE > /* Set to maximum. */ > f->data.low = -1; /* Set to all ones. */ > f->data.high = -1; /* Set to all ones. */ > - f->data = double_int_ext (f->data, > - GET_MODE_FBIT (f->mode) > - + GET_MODE_IBIT (f->mode), > - 1); /* Clear the sign. */ > + f->data = f->data.zext (GET_MODE_FBIT (f->mode) > + + GET_MODE_IBIT (f->mode)); > + /* Clear the sign. */ > } > else > overflow_p = true; > @@ -1051,8 +1001,7 @@ fixed_convert_from_int (FIXED_VALUE_TYPE > &f->data, sat_p); > } > } > - f->data = double_int_ext (f->data, > - SIGNED_FIXED_POINT_MODE_P (f->mode) > + f->data = f->data.ext (SIGNED_FIXED_POINT_MODE_P (f->mode) > + GET_MODE_FBIT (f->mode) > + GET_MODE_IBIT (f->mode), > UNSIGNED_FIXED_POINT_MODE_P (f->mode)); > @@ -1093,10 +1042,8 @@ fixed_convert_from_real (FIXED_VALUE_TYP > { > f->data.low = 1; > f->data.high = 0; > - lshift_double (f->data.low, f->data.high, i_f_bits, > - HOST_BITS_PER_DOUBLE_INT, > - &f->data.low, &f->data.high, 1); > - f->data = double_int_ext (f->data, 1 + i_f_bits, 0); > + f->data = f->data.alshift (i_f_bits, HOST_BITS_PER_DOUBLE_INT); > + f->data = f->data.sext (1 + i_f_bits); > } > } > else > @@ -1108,12 +1055,12 @@ fixed_convert_from_real (FIXED_VALUE_TYP > { > f->data.low = -1; > f->data.high = -1; > - f->data = double_int_ext (f->data, i_f_bits, 1); > + f->data = f->data.zext (i_f_bits); > } > else > overflow_p = true; > } > - f->data = double_int_ext (f->data, (!unsigned_p) + i_f_bits, unsigned_p); > + f->data = f->data.ext ((!unsigned_p) + i_f_bits, unsigned_p); > return overflow_p; > } > > > -- > This patch is available for review at http://codereview.appspot.com/6443093