* real.h (EXP_BITS): Make room for...
(struct real_value): ... added canonical bit.
(struct real_format): Added pnan.
(mips_single_format, mips_double_format, mips_extended_format,
mips_quad_format): New.
* real.c: Copy p to pnan in all formats.
(get_canonical_qnan, get_canonical_snan): Set canonical bit.
(real_nan): Use pnan to compute significand's shift.
(real_identical): Disregard significand in canonical
NaNs.
(real_hash): Likewise. Take signalling into account.
(encode_ieee_single, encode_ieee_double, encode_ieee_quad):
Disregard significand bits in canonical NaNs. Set all bits of
canonical NaN if !qnan_msb_set.
(encode_ibm_extended, decode_ibm_extended): Likewise. Use
qnan_msb_set to tell the base double format.
(ibm_extended_format): Use 53 as pnan.
(mips_single_format, mips_double_format, mips_extended_format,
mips_quad_format): Copied from the corresponding ieee/ibm
formats, with qnan_msb_set false.
* config/mips/iris6.h (MIPS_TFMODE_FORMAT): Use mips_extended_format.
* config/mips/linux64.h (MIPS_TFMODE_FORMAT): Use mips_quad_format.
* config/mips/mips.c (override_options): Use mips_single_format
and mips_double_format. Default TFmode to mips_quad_format.
* config/mips/t-linux64 (tp-bit.c): Define QUIET_NAN_NEGATED.
* config/mips/t-irix6: Likewise.
* config/mips/t-mips (fp-bit.c, dp-bit.c): Likewise.
* config/fp-bit.c (pack_d, unpack_d): Obey it.
From-SVN: r65146
+2003-04-01 Alexandre Oliva <aoliva@redhat.com>
+
+ * real.h (EXP_BITS): Make room for...
+ (struct real_value): ... added canonical bit.
+ (struct real_format): Added pnan.
+ (mips_single_format, mips_double_format, mips_extended_format,
+ mips_quad_format): New.
+ * real.c: Copy p to pnan in all formats.
+ (get_canonical_qnan, get_canonical_snan): Set canonical bit.
+ (real_nan): Use pnan to compute significand's shift.
+ (real_identical): Disregard significand in canonical
+ NaNs.
+ (real_hash): Likewise. Take signalling into account.
+ (encode_ieee_single, encode_ieee_double, encode_ieee_quad):
+ Disregard significand bits in canonical NaNs. Set all bits of
+ canonical NaN if !qnan_msb_set.
+ (encode_ibm_extended, decode_ibm_extended): Likewise. Use
+ qnan_msb_set to tell the base double format.
+ (ibm_extended_format): Use 53 as pnan.
+ (mips_single_format, mips_double_format, mips_extended_format,
+ mips_quad_format): Copied from the corresponding ieee/ibm
+ formats, with qnan_msb_set false.
+ * config/mips/iris6.h (MIPS_TFMODE_FORMAT): Use mips_extended_format.
+ * config/mips/linux64.h (MIPS_TFMODE_FORMAT): Use mips_quad_format.
+ * config/mips/mips.c (override_options): Use mips_single_format
+ and mips_double_format. Default TFmode to mips_quad_format.
+ * config/mips/t-linux64 (tp-bit.c): Define QUIET_NAN_NEGATED.
+ * config/mips/t-irix6: Likewise.
+ * config/mips/t-mips (fp-bit.c, dp-bit.c): Likewise.
+ * config/fp-bit.c (pack_d, unpack_d): Obey it.
+
2003-04-01 Geoffrey Keating <geoffk@apple.com>
* unwind-dw2-fde-darwin.c (DESTRUCTOR_MAY_BE_CALLED_LIVE): New.
exp = EXPMAX;
if (src->class == CLASS_QNAN || 1)
{
+#ifdef QUIET_NAN_NEGATED
+ fraction |= QUIET_NAN - 1;
+#else
fraction |= QUIET_NAN;
+#endif
}
}
else if (isinf (src))
else
{
/* Nonzero fraction, means nan */
+#ifdef QUIET_NAN_NEGATED
+ if ((fraction & QUIET_NAN) == 0)
+#else
if (fraction & QUIET_NAN)
+#endif
{
dst->class = CLASS_QNAN;
}
-_SYSTYPE_SVR4 -woff 131 \
%{mabi=32: -32}%{mabi=n32: -n32}%{mabi=64: -64}%{!mabi*: -n32}"
-#define MIPS_TFMODE_FORMAT ibm_extended_format
+#define MIPS_TFMODE_FORMAT mips_extended_format
for long double. There's no need to override this here, since
ieee_quad_format is the default, but let's put this here to make
sure nobody thinks we just forgot to set it to something else. */
-#define MIPS_TFMODE_FORMAT ieee_quad_format
+#define MIPS_TFMODE_FORMAT mips_quad_format
else
mips16 = 0;
+ real_format_for_mode[SFmode - QFmode] = &mips_single_format;
+ real_format_for_mode[DFmode - QFmode] = &mips_double_format;
#ifdef MIPS_TFMODE_FORMAT
real_format_for_mode[TFmode - QFmode] = &MIPS_TFMODE_FORMAT;
+#else
+ real_format_for_mode[TFmode - QFmode] = &mips_quad_format;
#endif
mips_print_operand_punct['?'] = 1;
echo '#ifdef __MIPSEL__' > tp-bit.c
echo '# define FLOAT_BIT_ORDER_MISMATCH' >> tp-bit.c
echo '#endif' >> tp-bit.c
+ echo '#define QUIET_NAN_NEGATED' >> dp-bit.c
echo '#if __LDBL_MANT_DIG__ == 106' >> tp-bit.c
echo '# define TFLOAT' >> tp-bit.c
cat $(srcdir)/config/fp-bit.c >> tp-bit.c
echo '# define FLOAT_BIT_ORDER_MISMATCH' >> tp-bit.c
echo '#endif' >> tp-bit.c
echo '#if __LDBL_MANT_DIG__ == 113' >> tp-bit.c
+ echo '#define QUIET_NAN_NEGATED' >> dp-bit.c
echo '# define TFLOAT' >> tp-bit.c
cat $(srcdir)/config/fp-bit.c >> tp-bit.c
echo '#endif' >> tp-bit.c
echo '#ifdef __MIPSEL__' > dp-bit.c
echo '#define FLOAT_BIT_ORDER_MISMATCH' >> dp-bit.c
echo '#endif' >> dp-bit.c
+ echo '#define QUIET_NAN_NEGATED' >> dp-bit.c
cat $(srcdir)/config/fp-bit.c >> dp-bit.c
fp-bit.c: $(srcdir)/config/fp-bit.c
echo '#ifdef __MIPSEL__' >> fp-bit.c
echo '#define FLOAT_BIT_ORDER_MISMATCH' >> fp-bit.c
echo '#endif' >> fp-bit.c
+ echo '#define QUIET_NAN_NEGATED' >> fp-bit.c
cat $(srcdir)/config/fp-bit.c >> fp-bit.c
memset (r, 0, sizeof (*r));
r->class = rvc_nan;
r->sign = sign;
+ r->canonical = 1;
}
static inline void
r->class = rvc_nan;
r->sign = sign;
r->signalling = 1;
+ r->canonical = 1;
}
static inline void
/* Compare two floating-point objects for bitwise identity. */
-extern bool
+bool
real_identical (a, b)
const REAL_VALUE_TYPE *a, *b;
{
case rvc_nan:
if (a->signalling != b->signalling)
return false;
+ /* The significand is ignored for canonical NaNs. */
+ if (a->canonical || b->canonical)
+ return a->canonical == b->canonical;
break;
default:
/* Shift the significand into place such that the bits
are in the most significant bits for the format. */
- lshift_significand (r, r, SIGNIFICAND_BITS - fmt->p);
+ lshift_significand (r, r, SIGNIFICAND_BITS - fmt->pnan);
/* Our MSB is always unset for NaNs. */
r->sig[SIGSZ-1] &= ~SIG_MSB;
{
case rvc_zero:
case rvc_inf:
- break;
+ return h;
case rvc_normal:
h |= r->exp << 3;
- /* FALLTHRU */
+ break;
case rvc_nan:
- if (sizeof(unsigned long) > sizeof(unsigned int))
- for (i = 0; i < SIGSZ; ++i)
- {
- unsigned long s = r->sig[i];
- h ^= s ^ (s >> (HOST_BITS_PER_LONG / 2));
- }
- else
- for (i = 0; i < SIGSZ; ++i)
- h ^= r->sig[i];
+ if (r->signalling)
+ h ^= (unsigned int)-1;
+ if (r->canonical)
+ return h;
break;
default:
abort ();
}
+ if (sizeof(unsigned long) > sizeof(unsigned int))
+ for (i = 0; i < SIGSZ; ++i)
+ {
+ unsigned long s = r->sig[i];
+ h ^= s ^ (s >> (HOST_BITS_PER_LONG / 2));
+ }
+ else
+ for (i = 0; i < SIGSZ; ++i)
+ h ^= r->sig[i];
+
return h;
}
\f
case rvc_nan:
if (fmt->has_nans)
{
+ if (r->canonical)
+ sig = 0;
if (r->signalling == fmt->qnan_msb_set)
sig &= ~(1 << 22);
else
sig |= 1 << 22;
- if (sig == 0)
+ /* We overload qnan_msb_set here: it's only clear for
+ mips_ieee_single, which wants all mantissa bits but the
+ quiet/signalling one set in canonical NaNs (at least
+ Quiet ones). */
+ if (r->canonical && !fmt->qnan_msb_set)
+ sig |= (1 << 22) - 1;
+ else if (sig == 0)
sig = 1 << 21;
image |= 255 << 23;
2,
1,
24,
+ 24,
-125,
128,
31,
true
};
+const struct real_format mips_single_format =
+ {
+ encode_ieee_single,
+ decode_ieee_single,
+ 2,
+ 1,
+ 24,
+ 24,
+ -125,
+ 128,
+ 31,
+ true,
+ true,
+ true,
+ true,
+ false
+ };
+
\f
/* IEEE double-precision format. */
case rvc_nan:
if (fmt->has_nans)
{
+ if (r->canonical)
+ sig_hi = sig_lo = 0;
if (r->signalling == fmt->qnan_msb_set)
sig_hi &= ~(1 << 19);
else
sig_hi |= 1 << 19;
- if (sig_hi == 0 && sig_lo == 0)
+ /* We overload qnan_msb_set here: it's only clear for
+ mips_ieee_single, which wants all mantissa bits but the
+ quiet/signalling one set in canonical NaNs (at least
+ Quiet ones). */
+ if (r->canonical && !fmt->qnan_msb_set)
+ {
+ sig_hi |= (1 << 19) - 1;
+ sig_lo = 0xffffffff;
+ }
+ else if (sig_hi == 0 && sig_lo == 0)
sig_hi = 1 << 18;
image_hi |= 2047 << 20;
2,
1,
53,
+ 53,
-1021,
1024,
63,
true
};
+const struct real_format mips_double_format =
+ {
+ encode_ieee_double,
+ decode_ieee_double,
+ 2,
+ 1,
+ 53,
+ 53,
+ -1021,
+ 1024,
+ 63,
+ true,
+ true,
+ true,
+ true,
+ false
+ };
+
\f
/* IEEE extended double precision format. This comes in three
flavours: Intel's as a 12 byte image, Intel's as a 16 byte image,
2,
1,
64,
+ 64,
-16382,
16384,
95,
2,
1,
64,
+ 64,
-16381,
16384,
79,
2,
1,
64,
+ 64,
-16381,
16384,
79,
static void
encode_ibm_extended (fmt, buf, r)
- const struct real_format *fmt ATTRIBUTE_UNUSED;
+ const struct real_format *fmt;
long *buf;
const REAL_VALUE_TYPE *r;
{
REAL_VALUE_TYPE u, v;
+ const struct real_format *base_fmt;
+
+ base_fmt = fmt->qnan_msb_set ? &ieee_double_format : &mips_double_format;
switch (r->class)
{
case rvc_inf:
case rvc_nan:
/* Both doubles set to Inf / NaN. */
- encode_ieee_double (&ieee_double_format, &buf[0], r);
+ encode_ieee_double (base_fmt, &buf[0], r);
buf[2] = buf[0];
buf[3] = buf[1];
return;
{
/* v = remainder containing additional 53 bits of significand. */
do_add (&v, r, &u, 1);
- round_for_format (&ieee_double_format, &v);
+ round_for_format (base_fmt, &v);
}
- round_for_format (&ieee_double_format, &u);
+ round_for_format (base_fmt, &u);
- encode_ieee_double (&ieee_double_format, &buf[0], &u);
- encode_ieee_double (&ieee_double_format, &buf[2], &v);
+ encode_ieee_double (base_fmt, &buf[0], &u);
+ encode_ieee_double (base_fmt, &buf[2], &v);
break;
default:
const long *buf;
{
REAL_VALUE_TYPE u, v;
+ const struct real_format *base_fmt;
- decode_ieee_double (&ieee_double_format, &u, &buf[0]);
+ base_fmt = fmt->qnan_msb_set ? &ieee_double_format : &mips_double_format;
+ decode_ieee_double (base_fmt, &u, &buf[0]);
if (u.class != rvc_zero && u.class != rvc_inf && u.class != rvc_nan)
{
- decode_ieee_double (&ieee_double_format, &v, &buf[2]);
+ decode_ieee_double (base_fmt, &v, &buf[2]);
do_add (r, &u, &v, 0);
}
else
2,
1,
53 + 53,
+ 53,
-1021 + 53,
1024,
-1,
true
};
+const struct real_format mips_extended_format =
+ {
+ encode_ibm_extended,
+ decode_ibm_extended,
+ 2,
+ 1,
+ 53 + 53,
+ 53,
+ -1021 + 53,
+ 1024,
+ -1,
+ true,
+ true,
+ true,
+ true,
+ false
+ };
+
\f
/* IEEE quad precision format. */
{
image3 |= 32767 << 16;
- if (HOST_BITS_PER_LONG == 32)
+ if (r->canonical)
+ {
+ /* Don't use bits from the significand. The
+ initialization above is right. */
+ }
+ else if (HOST_BITS_PER_LONG == 32)
{
image0 = u.sig[0];
image1 = u.sig[1];
image3 &= ~0x8000;
else
image3 |= 0x8000;
- if (((image3 & 0xffff) | image2 | image1 | image0) == 0)
+ /* We overload qnan_msb_set here: it's only clear for
+ mips_ieee_single, which wants all mantissa bits but the
+ quiet/signalling one set in canonical NaNs (at least
+ Quiet ones). */
+ if (r->canonical && !fmt->qnan_msb_set)
+ {
+ image3 |= 0x7fff;
+ image2 = image1 = image0 = 0xffffffff;
+ }
+ else if (((image3 & 0xffff) | image2 | image1 | image0) == 0)
image3 |= 0x4000;
}
else
2,
1,
113,
+ 113,
-16381,
16384,
127,
true,
true
};
+
+const struct real_format mips_quad_format =
+ {
+ encode_ieee_quad,
+ decode_ieee_quad,
+ 2,
+ 1,
+ 113,
+ 113,
+ -16381,
+ 16384,
+ 127,
+ true,
+ true,
+ true,
+ true,
+ false
+ };
\f
/* Descriptions of VAX floating point formats can be found beginning at
2,
1,
24,
+ 24,
-127,
127,
15,
2,
1,
56,
+ 56,
-127,
127,
15,
2,
1,
53,
+ 53,
-1023,
1023,
15,
16,
4,
6,
+ 6,
-64,
63,
31,
16,
4,
14,
+ 14,
-64,
63,
63,
2,
1,
24,
+ 24,
-126,
128,
-1,
2,
1,
32,
+ 32,
-126,
128,
-1,
2,
1,
SIGNIFICAND_BITS - 2,
+ SIGNIFICAND_BITS - 2,
-MAX_EXP,
MAX_EXP,
-1,
};
#define SIGNIFICAND_BITS (128 + HOST_BITS_PER_LONG)
-#define EXP_BITS (32 - 4)
+#define EXP_BITS (32 - 5)
#define MAX_EXP ((1 << (EXP_BITS - 1)) - 1)
#define SIGSZ (SIGNIFICAND_BITS / HOST_BITS_PER_LONG)
#define SIG_MSB ((unsigned long)1 << (HOST_BITS_PER_LONG - 1))
ENUM_BITFIELD (real_value_class) class : 2;
unsigned int sign : 1;
unsigned int signalling : 1;
+ unsigned int canonical : 1;
signed int exp : EXP_BITS;
unsigned long sig[SIGSZ];
};
/* Size of the significand in digits of radix B. */
int p;
+ /* Size of the significant of a NaN, in digits of radix B. */
+ int pnan;
+
/* The minimum negative integer, x, such that b**(x-1) is normalized. */
int emin;
/* Target formats defined in real.c. */
extern const struct real_format ieee_single_format;
+extern const struct real_format mips_single_format;
extern const struct real_format ieee_double_format;
+extern const struct real_format mips_double_format;
extern const struct real_format ieee_extended_motorola_format;
extern const struct real_format ieee_extended_intel_96_format;
extern const struct real_format ieee_extended_intel_128_format;
extern const struct real_format ibm_extended_format;
+extern const struct real_format mips_extended_format;
extern const struct real_format ieee_quad_format;
+extern const struct real_format mips_quad_format;
extern const struct real_format vax_f_format;
extern const struct real_format vax_d_format;
extern const struct real_format vax_g_format;