- sign = r->sign << 31;
-
- switch (r->cl)
- {
- case rvc_zero:
- image = 0;
- break;
-
- case rvc_inf:
- case rvc_nan:
- image = 0x7fffffff | sign;
- break;
-
- case rvc_normal:
- sig = (r->sig[SIGSZ-1] >> (HOST_BITS_PER_LONG - 24)) & 0xffffff;
- exp = ((REAL_EXP (r) / 4) + 64) << 24;
- image = sign | exp | sig;
- break;
-
- default:
- gcc_unreachable ();
- }
-
- buf[0] = image;
-}
-
-static void
-decode_i370_single (const struct real_format *fmt ATTRIBUTE_UNUSED,
- REAL_VALUE_TYPE *r, const long *buf)
-{
- unsigned long sign, sig, image = buf[0];
- int exp;
-
- sign = (image >> 31) & 1;
- exp = (image >> 24) & 0x7f;
- sig = image & 0xffffff;
-
- memset (r, 0, sizeof (*r));
-
- if (exp || sig)
- {
- r->cl = rvc_normal;
- r->sign = sign;
- SET_REAL_EXP (r, (exp - 64) * 4);
- r->sig[SIGSZ-1] = sig << (HOST_BITS_PER_LONG - 24);
- normalize (r);
- }
-}
-
-static void
-encode_i370_double (const struct real_format *fmt ATTRIBUTE_UNUSED,
- long *buf, const REAL_VALUE_TYPE *r)
-{
- unsigned long sign, exp, image_hi, image_lo;
-
- sign = r->sign << 31;
-
- switch (r->cl)
- {
- case rvc_zero:
- image_hi = image_lo = 0;
- break;
-
- case rvc_inf:
- case rvc_nan:
- image_hi = 0x7fffffff | sign;
- image_lo = 0xffffffff;
- break;
-
- case rvc_normal:
- if (HOST_BITS_PER_LONG == 64)
- {
- image_hi = r->sig[SIGSZ-1];
- image_lo = (image_hi >> (64 - 56)) & 0xffffffff;
- image_hi = (image_hi >> (64 - 56 + 1) >> 31) & 0xffffff;
- }
- else
- {
- image_hi = r->sig[SIGSZ-1];
- image_lo = r->sig[SIGSZ-2];
- image_lo = (image_lo >> 8) | (image_hi << 24);
- image_hi >>= 8;
- }
-
- exp = ((REAL_EXP (r) / 4) + 64) << 24;
- image_hi |= sign | exp;
- break;
-
- default:
- gcc_unreachable ();
- }
-
- if (FLOAT_WORDS_BIG_ENDIAN)
- buf[0] = image_hi, buf[1] = image_lo;
- else
- buf[0] = image_lo, buf[1] = image_hi;
-}
-
-static void
-decode_i370_double (const struct real_format *fmt ATTRIBUTE_UNUSED,
- REAL_VALUE_TYPE *r, const long *buf)
-{
- unsigned long sign, image_hi, image_lo;
- int exp;
-
- if (FLOAT_WORDS_BIG_ENDIAN)
- image_hi = buf[0], image_lo = buf[1];
- else
- image_lo = buf[0], image_hi = buf[1];
-
- sign = (image_hi >> 31) & 1;
- exp = (image_hi >> 24) & 0x7f;
- image_hi &= 0xffffff;
- image_lo &= 0xffffffff;
-
- memset (r, 0, sizeof (*r));
-
- if (exp || image_hi || image_lo)
- {
- r->cl = rvc_normal;
- r->sign = sign;
- SET_REAL_EXP (r, (exp - 64) * 4 + (SIGNIFICAND_BITS - 56));
-
- if (HOST_BITS_PER_LONG == 32)
- {
- r->sig[0] = image_lo;
- r->sig[1] = image_hi;
- }
- else
- r->sig[0] = image_lo | (image_hi << 31 << 1);
-
- normalize (r);
- }
-}
-
-const struct real_format i370_single_format =
- {
- encode_i370_single,
- decode_i370_single,
- 16,
- 4,
- 6,
- 6,
- -64,
- 63,
- 31,
- 31,
- false,
- false,
- false, /* ??? The encoding does allow for "unnormals". */
- false, /* ??? The encoding does allow for "unnormals". */
- false
- };
-
-const struct real_format i370_double_format =
- {
- encode_i370_double,
- decode_i370_double,
- 16,
- 4,
- 14,
- 14,
- -64,
- 63,
- 63,
- 63,
- false,
- false,
- false, /* ??? The encoding does allow for "unnormals". */
- false, /* ??? The encoding does allow for "unnormals". */
- false
- };
-\f
-/* Encode real R into a single precision DFP value in BUF. */
-static void
-encode_decimal_single (const struct real_format *fmt ATTRIBUTE_UNUSED,
- long *buf ATTRIBUTE_UNUSED,
- const REAL_VALUE_TYPE *r ATTRIBUTE_UNUSED)
-{
- encode_decimal32 (fmt, buf, r);
-}
-
-/* Decode a single precision DFP value in BUF into a real R. */
-static void
-decode_decimal_single (const struct real_format *fmt ATTRIBUTE_UNUSED,
- REAL_VALUE_TYPE *r ATTRIBUTE_UNUSED,
- const long *buf ATTRIBUTE_UNUSED)
-{
- decode_decimal32 (fmt, r, buf);
-}