Commit 483b9fd0 by Alexandre Oliva Committed by Alexandre Oliva

fp-bit.h (MAX_USI_INT, MAX_SI_INT): Don't assume unsigned is wide enough.

* config/fp-bit.h (MAX_USI_INT, MAX_SI_INT): Don't assume
unsigned is wide enough.
(BITS_PER_SI): New.
* config/fp-bit.c (_fpmul_parts): Don't assume 32-bits SI.
(si_to_float): Likewise.
(float_to_si, float_to_usi): Use BITS_PER_SI.

From-SVN: r39407
parent 567a2f0e
2001-02-02 Alexandre Oliva <aoliva@redhat.com>
* config/fp-bit.h (MAX_USI_INT, MAX_SI_INT): Don't assume
unsigned is wide enough.
(BITS_PER_SI): New.
* config/fp-bit.c (_fpmul_parts): Don't assume 32-bits SI.
(si_to_float): Likewise.
(float_to_si, float_to_usi): Use BITS_PER_SI.
2001-02-01 Jeffrey Oldham <oldham@codesourcery.com> 2001-02-01 Jeffrey Oldham <oldham@codesourcery.com>
* dwarf2out.c: Added explanation of abbreviations. * dwarf2out.c: Added explanation of abbreviations.
......
...@@ -624,8 +624,8 @@ _fpmul_parts ( fp_number_type * a, ...@@ -624,8 +624,8 @@ _fpmul_parts ( fp_number_type * a,
return b; return b;
} }
/* Calculate the mantissa by multiplying both 64bit numbers to get a /* Calculate the mantissa by multiplying both numbers to get a
128 bit number */ twice-as-wide number. */
{ {
#if defined(NO_DI_MODE) #if defined(NO_DI_MODE)
{ {
...@@ -654,22 +654,22 @@ _fpmul_parts ( fp_number_type * a, ...@@ -654,22 +654,22 @@ _fpmul_parts ( fp_number_type * a,
} }
} }
#elif defined(FLOAT) #elif defined(FLOAT)
/* Multiplying two USIs to get a UDI, we're safe. */
{ {
/* Multiplying two 32 bit numbers to get a 64 bit number on UDItype answer = (UDItype)a->fraction.ll * (UDItype)b->fraction.ll;
a machine with DI, so we're safe */
DItype answer = (DItype)(a->fraction.ll) * (DItype)(b->fraction.ll); high = answer >> BITS_PER_SI;
high = answer >> 32;
low = answer; low = answer;
} }
#else #else
/* Doing a 64*64 to 128 */ /* fractype is DImode, but we need the result to be twice as wide.
{ Assuming a widening multiply from DImode to TImode is not
USItype nl = a->fraction.ll & 0xffffffff; available, build one by hand. */
USItype nh = a->fraction.ll >> 32; {
USItype ml = b->fraction.ll & 0xffffffff; USItype nl = a->fraction.ll;
USItype mh = b->fraction.ll >>32; USItype nh = a->fraction.ll >> BITS_PER_SI;
USItype ml = b->fraction.ll;
USItype mh = b->fraction.ll >> BITS_PER_SI;
UDItype pp_ll = (UDItype) ml * nl; UDItype pp_ll = (UDItype) ml * nl;
UDItype pp_hl = (UDItype) mh * nl; UDItype pp_hl = (UDItype) mh * nl;
UDItype pp_lh = (UDItype) ml * nh; UDItype pp_lh = (UDItype) ml * nh;
...@@ -678,12 +678,12 @@ _fpmul_parts ( fp_number_type * a, ...@@ -678,12 +678,12 @@ _fpmul_parts ( fp_number_type * a,
UDItype res0 = 0; UDItype res0 = 0;
UDItype ps_hh__ = pp_hl + pp_lh; UDItype ps_hh__ = pp_hl + pp_lh;
if (ps_hh__ < pp_hl) if (ps_hh__ < pp_hl)
res2 += 0x100000000LL; res2 += (UDItype)1 << BITS_PER_SI;
pp_hl = (ps_hh__ << 32) & 0xffffffff00000000LL; pp_hl = (UDItype)(USItype)ps_hh__ << BITS_PER_SI;
res0 = pp_ll + pp_hl; res0 = pp_ll + pp_hl;
if (res0 < pp_ll) if (res0 < pp_ll)
res2++; res2++;
res2 += ((ps_hh__ >> 32) & 0xffffffffL) + pp_hh; res2 += (ps_hh__ >> BITS_PER_SI) + pp_hh;
high = res2; high = res2;
low = res0; low = res0;
} }
...@@ -1151,9 +1151,9 @@ si_to_float (SItype arg_a) ...@@ -1151,9 +1151,9 @@ si_to_float (SItype arg_a)
{ {
/* Special case for minint, since there is no +ve integer /* Special case for minint, since there is no +ve integer
representation for it */ representation for it */
if (arg_a == (SItype) 0x80000000) if (arg_a == (- MAX_SI_INT - 1))
{ {
return -2147483648.0; return (FLO_type)(- MAX_SI_INT - 1);
} }
in.fraction.ll = (-arg_a); in.fraction.ll = (-arg_a);
} }
...@@ -1223,7 +1223,7 @@ float_to_si (FLO_type arg_a) ...@@ -1223,7 +1223,7 @@ float_to_si (FLO_type arg_a)
/* it is a number, but a small one */ /* it is a number, but a small one */
if (a.normal_exp < 0) if (a.normal_exp < 0)
return 0; return 0;
if (a.normal_exp > 4 * BITS_PER_UNIT - 2) if (a.normal_exp > BITS_PER_SI - 2)
return a.sign ? (-MAX_SI_INT)-1 : MAX_SI_INT; return a.sign ? (-MAX_SI_INT)-1 : MAX_SI_INT;
tmp = a.fraction.ll >> ((FRACBITS + NGARDS) - a.normal_exp); tmp = a.fraction.ll >> ((FRACBITS + NGARDS) - a.normal_exp);
return a.sign ? (-tmp) : (tmp); return a.sign ? (-tmp) : (tmp);
...@@ -1260,7 +1260,7 @@ float_to_usi (FLO_type arg_a) ...@@ -1260,7 +1260,7 @@ float_to_usi (FLO_type arg_a)
/* it is a number, but a small one */ /* it is a number, but a small one */
if (a.normal_exp < 0) if (a.normal_exp < 0)
return 0; return 0;
if (a.normal_exp > 4 * BITS_PER_UNIT - 1) if (a.normal_exp > BITS_PER_SI - 1)
return MAX_USI_INT; return MAX_USI_INT;
else if (a.normal_exp > (FRACBITS + NGARDS)) else if (a.normal_exp > (FRACBITS + NGARDS))
return a.fraction.ll << (a.normal_exp - (FRACBITS + NGARDS)); return a.fraction.ll << (a.normal_exp - (FRACBITS + NGARDS));
......
...@@ -103,9 +103,9 @@ typedef unsigned int UHItype __attribute__ ((mode (HI))); ...@@ -103,9 +103,9 @@ typedef unsigned int UHItype __attribute__ ((mode (HI)));
typedef unsigned int USItype __attribute__ ((mode (SI))); typedef unsigned int USItype __attribute__ ((mode (SI)));
typedef unsigned int UDItype __attribute__ ((mode (DI))); typedef unsigned int UDItype __attribute__ ((mode (DI)));
#define MAX_SI_INT ((SItype) ((unsigned) (~0)>>1)) #define MAX_USI_INT (~(USItype)0)
#define MAX_USI_INT ((USItype) ~0) #define MAX_SI_INT ((SItype) (MAX_USI_INT >> 1))
#define BITS_PER_SI (4 * BITS_PER_UNIT)
#ifdef FLOAT_ONLY #ifdef FLOAT_ONLY
#define NO_DI_MODE #define NO_DI_MODE
......
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