comparison libgcc/config/i386/64/sfp-machine.h @ 111:04ced10e8804

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