-/* Type of computer arithmetic.
- Only one of DEC, IBM, IEEE, C4X, or UNK should get defined.
-
- `IEEE', when REAL_WORDS_BIG_ENDIAN is non-zero, refers generically
- to big-endian IEEE floating-point data structure. This definition
- should work in SFmode `float' type and DFmode `double' type on
- virtually all big-endian IEEE machines. If LONG_DOUBLE_TYPE_SIZE
- has been defined to be 96, then IEEE also invokes the particular
- XFmode (`long double' type) data structure used by the Motorola
- 680x0 series processors.
-
- `IEEE', when REAL_WORDS_BIG_ENDIAN is zero, refers generally to
- little-endian IEEE machines. In this case, if LONG_DOUBLE_TYPE_SIZE
- has been defined to be 96, then IEEE also invokes the particular
- XFmode `long double' data structure used by the Intel 80x86 series
- processors.
-
- `DEC' refers specifically to the Digital Equipment Corp PDP-11
- and VAX floating point data structure. This model currently
- supports no type wider than DFmode.
-
- `IBM' refers specifically to the IBM System/370 and compatible
- floating point data structure. This model currently supports
- no type wider than DFmode. The IBM conversions were contributed by
- frank@atom.ansto.gov.au (Frank Crawford).
-
- `C4X' refers specifically to the floating point format used on
- Texas Instruments TMS320C3x and TMS320C4x digital signal
- processors. This supports QFmode (32-bit float, double) and HFmode
- (40-bit long double) where BITS_PER_BYTE is 32. Unlike IEEE
- floats, C4x floats are not rounded to be even. The C4x conversions
- were contributed by m.hayes@elec.canterbury.ac.nz (Michael Hayes) and
- Haj.Ten.Brugge@net.HCC.nl (Herman ten Brugge).
-
- If LONG_DOUBLE_TYPE_SIZE = 64 (the default, unless tm.h defines it)
- then `long double' and `double' are both implemented, but they
- both mean DFmode. In this case, the software floating-point
- support available here is activated by writing
- #define REAL_ARITHMETIC
- in tm.h.
-
- The case LONG_DOUBLE_TYPE_SIZE = 128 activates TFmode support
- and may deactivate XFmode since `long double' is used to refer
- to both modes. Defining INTEL_EXTENDED_IEEE_FORMAT at the same
- time enables 80387-style 80-bit floats in a 128-bit padded
- image, as seen on IA-64.
-
- The macros FLOAT_WORDS_BIG_ENDIAN, HOST_FLOAT_WORDS_BIG_ENDIAN,
- contributed by Richard Earnshaw <Richard.Earnshaw@cl.cam.ac.uk>,
- separate the floating point unit's endian-ness from that of
- the integer addressing. This permits one to define a big-endian
- FPU on a little-endian machine (e.g., ARM). An extension to
- BYTES_BIG_ENDIAN may be required for some machines in the future.
- These optional macros may be defined in tm.h. In real.h, they
- default to WORDS_BIG_ENDIAN, etc., so there is no need to define
- them for any normal host or target machine on which the floats
- and the integers have the same endian-ness. */
-
-
-/* The following converts gcc macros into the ones used by this file. */
-
-/* REAL_ARITHMETIC defined means that macros in real.h are
- defined to call emulator functions. */
-#ifdef REAL_ARITHMETIC
-
-#if TARGET_FLOAT_FORMAT == VAX_FLOAT_FORMAT
-/* PDP-11, Pro350, VAX: */
-#define DEC 1
-#else /* it's not VAX */
-#if TARGET_FLOAT_FORMAT == IBM_FLOAT_FORMAT
-/* IBM System/370 style */
-#define IBM 1
-#else /* it's also not an IBM */
-#if TARGET_FLOAT_FORMAT == C4X_FLOAT_FORMAT
-/* TMS320C3x/C4x style */
-#define C4X 1
-#else /* it's also not a C4X */
-#if TARGET_FLOAT_FORMAT == IEEE_FLOAT_FORMAT
-#define IEEE
-#else /* it's not IEEE either */
-/* UNKnown arithmetic. We don't support this and can't go on. */
-unknown arithmetic type
-#define UNK 1
-#endif /* not IEEE */
-#endif /* not C4X */
-#endif /* not IBM */
-#endif /* not VAX */
-
-#define REAL_WORDS_BIG_ENDIAN FLOAT_WORDS_BIG_ENDIAN
-
-#else
-/* REAL_ARITHMETIC not defined means that the *host's* data
- structure will be used. It may differ by endian-ness from the
- target machine's structure and will get its ends swapped
- accordingly (but not here). Probably only the decimal <-> binary
- functions in this file will actually be used in this case. */
-
-#if HOST_FLOAT_FORMAT == VAX_FLOAT_FORMAT
-#define DEC 1
-#else /* it's not VAX */
-#if HOST_FLOAT_FORMAT == IBM_FLOAT_FORMAT
-/* IBM System/370 style */
-#define IBM 1
-#else /* it's also not an IBM */
-#if HOST_FLOAT_FORMAT == IEEE_FLOAT_FORMAT
-#define IEEE
-#else /* it's not IEEE either */
-unknown arithmetic type
-#define UNK 1
-#endif /* not IEEE */
-#endif /* not IBM */
-#endif /* not VAX */
-
-#define REAL_WORDS_BIG_ENDIAN HOST_FLOAT_WORDS_BIG_ENDIAN
-
-#endif /* REAL_ARITHMETIC not defined */
-
-/* Define INFINITY for support of infinity.
- Define NANS for support of Not-a-Number's (NaN's). */
-#if !defined(DEC) && !defined(IBM) && !defined(C4X)
-#define INFINITY
-#define NANS
-#endif
-
-/* Support of NaNs requires support of infinity. */
-#ifdef NANS
-#ifndef INFINITY
-#define INFINITY
-#endif
-#endif
-\f
-/* Find a host integer type that is at least 16 bits wide,
- and another type at least twice whatever that size is. */
-
-#if HOST_BITS_PER_CHAR >= 16
-#define EMUSHORT char
-#define EMUSHORT_SIZE HOST_BITS_PER_CHAR
-#define EMULONG_SIZE (2 * HOST_BITS_PER_CHAR)
-#else
-#if HOST_BITS_PER_SHORT >= 16
-#define EMUSHORT short
-#define EMUSHORT_SIZE HOST_BITS_PER_SHORT
-#define EMULONG_SIZE (2 * HOST_BITS_PER_SHORT)
-#else
-#if HOST_BITS_PER_INT >= 16
-#define EMUSHORT int
-#define EMUSHORT_SIZE HOST_BITS_PER_INT
-#define EMULONG_SIZE (2 * HOST_BITS_PER_INT)
-#else
-#if HOST_BITS_PER_LONG >= 16
-#define EMUSHORT long
-#define EMUSHORT_SIZE HOST_BITS_PER_LONG
-#define EMULONG_SIZE (2 * HOST_BITS_PER_LONG)
-#else
-/* You will have to modify this program to have a smaller unit size. */
-#define EMU_NON_COMPILE
-#endif
-#endif
-#endif
-#endif
-
-#if HOST_BITS_PER_SHORT >= EMULONG_SIZE
-#define EMULONG short
-#else
-#if HOST_BITS_PER_INT >= EMULONG_SIZE
-#define EMULONG int
-#else
-#if HOST_BITS_PER_LONG >= EMULONG_SIZE
-#define EMULONG long
-#else
-#if HOST_BITS_PER_LONGLONG >= EMULONG_SIZE
-#define EMULONG long long int
-#else
-/* You will have to modify this program to have a smaller unit size. */
-#define EMU_NON_COMPILE
-#endif
-#endif
-#endif
-#endif
-
-
-/* The host interface doesn't work if no 16-bit size exists. */
-#if EMUSHORT_SIZE != 16
-#define EMU_NON_COMPILE
-#endif
-
-/* OK to continue compilation. */
-#ifndef EMU_NON_COMPILE
-
-/* Construct macros to translate between REAL_VALUE_TYPE and e type.
- In GET_REAL and PUT_REAL, r and e are pointers.
- A REAL_VALUE_TYPE is guaranteed to occupy contiguous locations
- in memory, with no holes. */
-
-#if MAX_LONG_DOUBLE_TYPE_SIZE == 96 || \
- (defined(INTEL_EXTENDED_IEEE_FORMAT) && MAX_LONG_DOUBLE_TYPE_SIZE == 128)
-/* Number of 16 bit words in external e type format */
-# define NE 6
-# define MAXDECEXP 4932
-# define MINDECEXP -4956
-# define GET_REAL(r,e) memcpy ((char *)(e), (char *)(r), 2*NE)
-# define PUT_REAL(e,r) \
- do { \
- memcpy ((char *)(r), (char *)(e), 2*NE); \
- if (2*NE < sizeof(*r)) \
- memset ((char *)(r) + 2*NE, 0, sizeof(*r) - 2*NE); \
- } while (0)
-# else /* no XFmode */
-# if MAX_LONG_DOUBLE_TYPE_SIZE == 128
-# define NE 10
-# define MAXDECEXP 4932
-# define MINDECEXP -4977
-# define GET_REAL(r,e) memcpy ((char *)(e), (char *)(r), 2*NE)
-# define PUT_REAL(e,r) \
- do { \
- memcpy ((char *)(r), (char *)(e), 2*NE); \
- if (2*NE < sizeof(*r)) \
- memset ((char *)(r) + 2*NE, 0, sizeof(*r) - 2*NE); \
- } while (0)
-#else
-#define NE 6
-#define MAXDECEXP 4932
-#define MINDECEXP -4956
-#ifdef REAL_ARITHMETIC
-/* Emulator uses target format internally
- but host stores it in host endian-ness. */
-
-#define GET_REAL(r,e) \
-do { \
- if (HOST_FLOAT_WORDS_BIG_ENDIAN == REAL_WORDS_BIG_ENDIAN) \
- e53toe ((unsigned EMUSHORT *) (r), (e)); \
- else \
- { \
- unsigned EMUSHORT w[4]; \
- memcpy (&w[3], ((EMUSHORT *) r), sizeof (EMUSHORT)); \
- memcpy (&w[2], ((EMUSHORT *) r) + 1, sizeof (EMUSHORT)); \
- memcpy (&w[1], ((EMUSHORT *) r) + 2, sizeof (EMUSHORT)); \
- memcpy (&w[0], ((EMUSHORT *) r) + 3, sizeof (EMUSHORT)); \
- e53toe (w, (e)); \
- } \
- } while (0)
-
-#define PUT_REAL(e,r) \
-do { \
- if (HOST_FLOAT_WORDS_BIG_ENDIAN == REAL_WORDS_BIG_ENDIAN) \
- etoe53 ((e), (unsigned EMUSHORT *) (r)); \
- else \
- { \
- unsigned EMUSHORT w[4]; \
- etoe53 ((e), w); \
- memcpy (((EMUSHORT *) r), &w[3], sizeof (EMUSHORT)); \
- memcpy (((EMUSHORT *) r) + 1, &w[2], sizeof (EMUSHORT)); \
- memcpy (((EMUSHORT *) r) + 2, &w[1], sizeof (EMUSHORT)); \
- memcpy (((EMUSHORT *) r) + 3, &w[0], sizeof (EMUSHORT)); \
- } \
- } while (0)
-
-#else /* not REAL_ARITHMETIC */
-
-/* emulator uses host format */
-#define GET_REAL(r,e) e53toe ((unsigned EMUSHORT *) (r), (e))
-#define PUT_REAL(e,r) etoe53 ((e), (unsigned EMUSHORT *) (r))
-
-#endif /* not REAL_ARITHMETIC */
-#endif /* not TFmode */
-#endif /* not XFmode */
-
-
-/* Number of 16 bit words in internal format */
-#define NI (NE+3)
-
-/* Array offset to exponent */
-#define E 1
-
-/* Array offset to high guard word */
-#define M 2
-
-/* Number of bits of precision */
-#define NBITS ((NI-4)*16)
-
-/* Maximum number of decimal digits in ASCII conversion
- * = NBITS*log10(2)
- */
-#define NDEC (NBITS*8/27)
-
-/* The exponent of 1.0 */
-#define EXONE (0x3fff)
-
-#if defined(HOST_EBCDIC)
-/* bit 8 is significant in EBCDIC */
-#define CHARMASK 0xff
-#else
-#define CHARMASK 0x7f
-#endif
-
-extern int extra_warnings;
-extern unsigned EMUSHORT ezero[], ehalf[], eone[], etwo[];
-extern unsigned EMUSHORT elog2[], esqrt2[];
-
-static void endian PARAMS ((unsigned EMUSHORT *, long *,
- enum machine_mode));
-static void eclear PARAMS ((unsigned EMUSHORT *));
-static void emov PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *));
-#if 0
-static void eabs PARAMS ((unsigned EMUSHORT *));
-#endif
-static void eneg PARAMS ((unsigned EMUSHORT *));
-static int eisneg PARAMS ((unsigned EMUSHORT *));
-static int eisinf PARAMS ((unsigned EMUSHORT *));
-static int eisnan PARAMS ((unsigned EMUSHORT *));
-static void einfin PARAMS ((unsigned EMUSHORT *));
-#ifdef NANS
-static void enan PARAMS ((unsigned EMUSHORT *, int));
-static void einan PARAMS ((unsigned EMUSHORT *));
-static int eiisnan PARAMS ((unsigned EMUSHORT *));
-static int eiisneg PARAMS ((unsigned EMUSHORT *));
-static void make_nan PARAMS ((unsigned EMUSHORT *, int, enum machine_mode));
-#endif
-static void emovi PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *));
-static void emovo PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *));
-static void ecleaz PARAMS ((unsigned EMUSHORT *));
-static void ecleazs PARAMS ((unsigned EMUSHORT *));
-static void emovz PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *));
-#if 0
-static void eiinfin PARAMS ((unsigned EMUSHORT *));
-#endif
-#ifdef INFINITY
-static int eiisinf PARAMS ((unsigned EMUSHORT *));
-#endif
-static int ecmpm PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *));
-static void eshdn1 PARAMS ((unsigned EMUSHORT *));
-static void eshup1 PARAMS ((unsigned EMUSHORT *));
-static void eshdn8 PARAMS ((unsigned EMUSHORT *));
-static void eshup8 PARAMS ((unsigned EMUSHORT *));
-static void eshup6 PARAMS ((unsigned EMUSHORT *));
-static void eshdn6 PARAMS ((unsigned EMUSHORT *));
-static void eaddm PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *));\f
-static void esubm PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *));
-static void m16m PARAMS ((unsigned int, unsigned short *,
- unsigned short *));
-static int edivm PARAMS ((unsigned short *, unsigned short *));
-static int emulm PARAMS ((unsigned short *, unsigned short *));
-static void emdnorm PARAMS ((unsigned EMUSHORT *, int, int, EMULONG, int));
-static void esub PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *,
- unsigned EMUSHORT *));
-static void eadd PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *,
- unsigned EMUSHORT *));
-static void eadd1 PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *,
- unsigned EMUSHORT *));
-static void ediv PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *,
- unsigned EMUSHORT *));
-static void emul PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *,
- unsigned EMUSHORT *));
-static void e53toe PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *));
-static void e64toe PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *));
-static void e113toe PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *));
-static void e24toe PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *));
-static void etoe113 PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *));
-static void toe113 PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *));
-static void etoe64 PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *));
-static void toe64 PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *));
-static void etoe53 PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *));
-static void toe53 PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *));
-static void etoe24 PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *));
-static void toe24 PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *));
-static int ecmp PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *));
-#if 0
-static void eround PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *));
-#endif
-static void ltoe PARAMS ((HOST_WIDE_INT *, unsigned EMUSHORT *));
-static void ultoe PARAMS ((unsigned HOST_WIDE_INT *, unsigned EMUSHORT *));
-static void eifrac PARAMS ((unsigned EMUSHORT *, HOST_WIDE_INT *,
- unsigned EMUSHORT *));
-static void euifrac PARAMS ((unsigned EMUSHORT *, unsigned HOST_WIDE_INT *,
- unsigned EMUSHORT *));
-static int eshift PARAMS ((unsigned EMUSHORT *, int));
-static int enormlz PARAMS ((unsigned EMUSHORT *));
-#if 0
-static void e24toasc PARAMS ((unsigned EMUSHORT *, char *, int));
-static void e53toasc PARAMS ((unsigned EMUSHORT *, char *, int));
-static void e64toasc PARAMS ((unsigned EMUSHORT *, char *, int));
-static void e113toasc PARAMS ((unsigned EMUSHORT *, char *, int));
-#endif /* 0 */
-static void etoasc PARAMS ((unsigned EMUSHORT *, char *, int));
-static void asctoe24 PARAMS ((const char *, unsigned EMUSHORT *));
-static void asctoe53 PARAMS ((const char *, unsigned EMUSHORT *));
-static void asctoe64 PARAMS ((const char *, unsigned EMUSHORT *));
-static void asctoe113 PARAMS ((const char *, unsigned EMUSHORT *));
-static void asctoe PARAMS ((const char *, unsigned EMUSHORT *));
-static void asctoeg PARAMS ((const char *, unsigned EMUSHORT *, int));
-static void efloor PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *));
-#if 0
-static void efrexp PARAMS ((unsigned EMUSHORT *, int *,
- unsigned EMUSHORT *));
-#endif
-static void eldexp PARAMS ((unsigned EMUSHORT *, int, unsigned EMUSHORT *));
-#if 0
-static void eremain PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *,
- unsigned EMUSHORT *));
-#endif
-static void eiremain PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *));
-static void mtherr PARAMS ((const char *, int));
-#ifdef DEC
-static void dectoe PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *));
-static void etodec PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *));
-static void todec PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *));
-#endif
-#ifdef IBM
-static void ibmtoe PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *,
- enum machine_mode));
-static void etoibm PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *,
- enum machine_mode));
-static void toibm PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *,
- enum machine_mode));
-#endif
-#ifdef C4X
-static void c4xtoe PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *,
- enum machine_mode));
-static void etoc4x PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *,
- enum machine_mode));
-static void toc4x PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *,
- enum machine_mode));
-#endif
-#if 0
-static void uditoe PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *));
-static void ditoe PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *));
-static void etoudi PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *));
-static void etodi PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *));
-static void esqrt PARAMS ((unsigned EMUSHORT *, unsigned EMUSHORT *));
-#endif
-\f
-/* Copy 32-bit numbers obtained from array containing 16-bit numbers,
- swapping ends if required, into output array of longs. The
- result is normally passed to fprintf by the ASM_OUTPUT_ macros. */