comparison libgcc/config/s390/32/_fixunssfdi.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents 77e2b8dfacca
children 84e7813d76e9
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 /* Definitions of target machine for GNU compiler, for IBM S/390 1 /* Definitions of target machine for GNU compiler, for IBM S/390
2 Copyright (C) 1999, 2000, 2001, 2007, 2008 and 2009 2 Copyright (C) 1999-2017 Free Software Foundation, Inc.
3 Free Software Foundation, Inc.
4 Contributed by Hartmut Penner (hpenner@de.ibm.com) and 3 Contributed by Hartmut Penner (hpenner@de.ibm.com) and
5 Ulrich Weigand (uweigand@de.ibm.com). 4 Ulrich Weigand (uweigand@de.ibm.com).
6 5
7 This file is part of GCC. 6 This file is part of GCC.
8 7
23 You should have received a copy of the GNU General Public License and 22 You should have received a copy of the GNU General Public License and
24 a copy of the GCC Runtime Library Exception along with this program; 23 a copy of the GCC Runtime Library Exception along with this program;
25 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 24 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
26 <http://www.gnu.org/licenses/>. */ 25 <http://www.gnu.org/licenses/>. */
27 26
28 #define EXP(fp) (((fp.l) >> 23) & 0xFF) 27 #ifndef __s390x__
29 #define EXCESS 126 28
29 #define EXPONENT_BIAS 127
30 #define MANTISSA_BITS 23
31 #define EXP(fp) (((fp.l) >> MANTISSA_BITS) & 0xFF)
30 #define SIGNBIT 0x80000000 32 #define SIGNBIT 0x80000000
31 #define SIGN(fp) ((fp.l) & SIGNBIT) 33 #define SIGN(fp) ((fp.l) & SIGNBIT)
32 #define HIDDEN (1 << 23) 34 #define HIDDEN (1 << MANTISSA_BITS)
33 #define MANT(fp) (((fp.l) & 0x7FFFFF) | HIDDEN) 35 #define MANT(fp) (((fp.l) & 0x7FFFFF) | HIDDEN)
34 #define FRAC(fp) ((fp.l) & 0x7FFFFF) 36 #define FRAC(fp) ((fp.l) & 0x7FFFFF)
35 37
36 typedef int DItype_x __attribute__ ((mode (DI))); 38 typedef int DItype_x __attribute__ ((mode (DI)));
37 typedef unsigned int UDItype_x __attribute__ ((mode (DI))); 39 typedef unsigned int UDItype_x __attribute__ ((mode (DI)));
42 { 44 {
43 float f; 45 float f;
44 USItype_x l; 46 USItype_x l;
45 }; 47 };
46 48
49 static __inline__ void
50 fexceptdiv (float d, float e)
51 {
52 __asm__ __volatile__ ("debr %0,%1" : : "f" (d), "f" (e) );
53 }
54
47 UDItype_x __fixunssfdi (float a1); 55 UDItype_x __fixunssfdi (float a1);
48 56
49 /* convert float to unsigned int */ 57 /* convert float to unsigned int */
50 UDItype_x 58 UDItype_x
51 __fixunssfdi (float a1) 59 __fixunssfdi (float a1)
54 register int exp; 62 register int exp;
55 register UDItype_x l; 63 register UDItype_x l;
56 64
57 fl1.f = a1; 65 fl1.f = a1;
58 66
59 /* +/- 0, denormalized, negative */ 67 /* +/- 0, denormalized */
60 68 if (!EXP (fl1))
61 if (!EXP (fl1) || SIGN(fl1))
62 return 0; 69 return 0;
63 70
64 exp = EXP (fl1) - EXCESS - 24; 71 /* Negative. */
72 if (SIGN (fl1))
73 {
74 /* Value is <= -1.0
75 C99 Annex F.4 requires an "invalid" exception to be thrown. */
76 if (EXP (fl1) >= EXPONENT_BIAS)
77 fexceptdiv (0.0, 0.0);
78 return 0;
79 }
80
81 exp = EXP (fl1) - EXPONENT_BIAS - MANTISSA_BITS;
65 82
66 /* number < 1 */ 83 /* number < 1 */
67
68 if (exp < -24) 84 if (exp < -24)
69 return 0; 85 return 0;
70 86
71 /* NaN */ 87 /* NaN */
72 88
73 if ((EXP(fl1) == 0xff) && (FRAC(fl1) != 0)) /* NaN */ 89 if ((EXP (fl1) == 0xff) && (FRAC (fl1) != 0)) /* NaN */
74 return 0x0ULL; 90 {
91 /* C99 Annex F.4 requires an "invalid" exception to be thrown. */
92 fexceptdiv (0.0, 0.0);
93 return 0x0ULL;
94 }
75 95
76 /* Number big number & + inf */ 96 /* Number big number & + inf */
77 97
78 if (exp >= 41) { 98 if (exp >= 41)
79 return 0xFFFFFFFFFFFFFFFFULL; 99 {
80 } 100 /* C99 Annex F.4 requires an "invalid" exception to be thrown. */
101 fexceptdiv (0.0, 0.0);
102 return 0xFFFFFFFFFFFFFFFFULL;
103 }
81 104
82 l = MANT(fl1); 105 l = MANT (fl1);
83 106
84 if (exp > 0) 107 if (exp > 0)
85 l <<= exp; 108 l <<= exp;
86 else 109 else
87 l >>= -exp; 110 l >>= -exp;
88 111
89 return l; 112 return l;
90 } 113 }
114 #endif /* !__s390x__ */