OSDN Git Service

5debf5ae44ab32a895f16cef9541312c36160d42
[pf3gnuchains/gcc-fork.git] / libgcc / config / i386 / 64 / sfp-machine.h
1 #define _FP_W_TYPE_SIZE         64
2
3 #define _FP_W_TYPE              unsigned long long
4 #define _FP_WS_TYPE             signed long long
5 #define _FP_I_TYPE              long long
6
7 typedef int TItype __attribute__ ((mode (TI)));
8 typedef unsigned int UTItype __attribute__ ((mode (TI)));
9
10 #define TI_BITS (__CHAR_BIT__ * (int)sizeof(TItype))
11
12 /* The type of the result of a floating point comparison.  This must
13    match `__libgcc_cmp_return__' in GCC for the target.  */
14 typedef int __gcc_CMPtype __attribute__ ((mode (__libgcc_cmp_return__)));
15 #define CMPtype __gcc_CMPtype
16
17 #define _FP_MUL_MEAT_Q(R,X,Y)                           \
18   _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
19
20 #define _FP_DIV_MEAT_Q(R,X,Y)   _FP_DIV_MEAT_2_udiv(Q,R,X,Y)
21
22 #define _FP_NANFRAC_S           _FP_QNANBIT_S
23 #define _FP_NANFRAC_D           _FP_QNANBIT_D
24 #define _FP_NANFRAC_E           _FP_QNANBIT_E, 0
25 #define _FP_NANFRAC_Q           _FP_QNANBIT_Q, 0
26 #define _FP_NANSIGN_S           1
27 #define _FP_NANSIGN_D           1
28 #define _FP_NANSIGN_E           1
29 #define _FP_NANSIGN_Q           1
30
31 #define _FP_KEEPNANFRACP 1
32
33 /* Here is something Intel misdesigned: the specs don't define
34    the case where we have two NaNs with same mantissas, but
35    different sign. Different operations pick up different NaNs.  */
36 #define _FP_CHOOSENAN(fs, wc, R, X, Y, OP)                      \
37   do {                                                          \
38     if (_FP_FRAC_GT_##wc(X, Y)                                  \
39         || (_FP_FRAC_EQ_##wc(X,Y) && (OP == '+' || OP == '*'))) \
40       {                                                         \
41         R##_s = X##_s;                                          \
42         _FP_FRAC_COPY_##wc(R,X);                                \
43       }                                                         \
44     else                                                        \
45       {                                                         \
46         R##_s = Y##_s;                                          \
47         _FP_FRAC_COPY_##wc(R,Y);                                \
48       }                                                         \
49     R##_c = FP_CLS_NAN;                                         \
50   } while (0)
51
52 #define FP_EX_INVALID           0x01
53 #define FP_EX_DENORM            0x02
54 #define FP_EX_DIVZERO           0x04
55 #define FP_EX_OVERFLOW          0x08
56 #define FP_EX_UNDERFLOW         0x10
57 #define FP_EX_INEXACT           0x20
58
59 struct fenv
60 {
61   unsigned short int __control_word;
62   unsigned short int __unused1;
63   unsigned short int __status_word;
64   unsigned short int __unused2;
65   unsigned short int __tags;
66   unsigned short int __unused3;
67   unsigned int __eip;
68   unsigned short int __cs_selector;
69   unsigned int __opcode:11;
70   unsigned int __unused4:5;
71   unsigned int __data_offset;
72   unsigned short int __data_selector;
73   unsigned short int __unused5;
74 };
75
76 #define FP_HANDLE_EXCEPTIONS                                            \
77   do {                                                                  \
78     if (_fex & FP_EX_INVALID)                                           \
79       {                                                                 \
80         float f = 0.0;                                                  \
81         __asm__ __volatile__ ("divss %0, %0 " : : "x" (f));             \
82       }                                                                 \
83     if (_fex & FP_EX_DIVZERO)                                           \
84       {                                                                 \
85         float f = 1.0, g = 0.0;                                         \
86         __asm__ __volatile__ ("divss %1, %0" : : "x" (f), "x" (g));     \
87       }                                                                 \
88     if (_fex & FP_EX_OVERFLOW)                                          \
89       {                                                                 \
90         struct fenv temp;                                               \
91         __asm__ __volatile__ ("fnstenv %0" : "=m" (temp));              \
92         temp.__status_word |= FP_EX_OVERFLOW;                           \
93         __asm__ __volatile__ ("fldenv %0" : : "m" (temp));              \
94         __asm__ __volatile__ ("fwait");                                 \
95       }                                                                 \
96     if (_fex & FP_EX_UNDERFLOW)                                         \
97       {                                                                 \
98         struct fenv temp;                                               \
99         __asm__ __volatile__ ("fnstenv %0" : "=m" (temp));              \
100         temp.__status_word |= FP_EX_UNDERFLOW;                          \
101         __asm__ __volatile__ ("fldenv %0" : : "m" (temp));              \
102         __asm__ __volatile__ ("fwait");                                 \
103       }                                                                 \
104     if (_fex & FP_EX_INEXACT)                                           \
105       {                                                                 \
106         struct fenv temp;                                               \
107         __asm__ __volatile__ ("fnstenv %0" : "=m" (temp));              \
108         temp.__status_word |= FP_EX_INEXACT;                            \
109         __asm__ __volatile__ ("fldenv %0" : : "m" (temp));              \
110         __asm__ __volatile__ ("fwait");                                 \
111       }                                                                 \
112   } while (0)
113
114 #define FP_RND_NEAREST          0
115 #define FP_RND_ZERO             0xc00
116 #define FP_RND_PINF             0x800
117 #define FP_RND_MINF             0x400
118
119 #define _FP_DECL_EX \
120   unsigned short _fcw __attribute__ ((unused)) = FP_RND_NEAREST
121
122 #define FP_INIT_ROUNDMODE                       \
123   do {                                          \
124     __asm__ ("fnstcw %0" : "=m" (_fcw));        \
125   } while (0)
126
127 #define FP_ROUNDMODE            (_fcw & 0xc00)
128
129 #define __LITTLE_ENDIAN 1234
130 #define __BIG_ENDIAN    4321
131
132 #define __BYTE_ORDER __LITTLE_ENDIAN
133
134 /* Define ALIASNAME as a strong alias for NAME.  */
135 #if defined __MACH__
136 /* Mach-O doesn't support aliasing.  If these functions ever return
137    anything but CMPtype we need to revisit this... */
138 #define strong_alias(name, aliasname) \
139   CMPtype aliasname (TFtype a, TFtype b) { return name(a, b); }
140 #else
141 # define strong_alias(name, aliasname) _strong_alias(name, aliasname)
142 # define _strong_alias(name, aliasname) \
143   extern __typeof (name) aliasname __attribute__ ((alias (#name)));
144 #endif