1 /* Definitions of target machine for GNU compiler, for IBM S/390
2 Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
3 Contributed by Hartmut Penner (hpenner@de.ibm.com) and
4 Ulrich Weigand (uweigand@de.ibm.com).
6 This file is part of GNU CC.
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING. If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
24 #define EXPD(fp) (((fp.l.upper) >> 20) & 0x7FF)
26 #define SIGNBIT 0x80000000
27 #define SIGND(fp) ((fp.l.upper) & SIGNBIT)
28 #define MANTD_LL(fp) ((fp.ll & (HIDDEND_LL-1)) | HIDDEND_LL)
29 #define FRACD_LL(fp) (fp.ll & (HIDDEND_LL-1))
30 #define HIDDEND_LL ((UDItype_x)1 << 52)
32 typedef int DItype_x __attribute__ ((mode (DI)));
33 typedef unsigned int UDItype_x __attribute__ ((mode (DI)));
34 typedef int SItype_x __attribute__ ((mode (SI)));
35 typedef unsigned int USItype_x __attribute__ ((mode (SI)));
47 /* convert double to unsigned int */
49 __fixunsdfdi (double a1)
51 register union double_long dl1;
57 /* +/- 0, denormalized, negativ */
59 if (!EXPD (dl1) || SIGND(dl1))
62 exp = EXPD (dl1) - EXCESSD - 53;
71 if ((EXPD(dl1) == 0x7ff) && (FRACD_LL(dl1) != 0)) /* NaN */
74 /* Number big number & + inf */
77 return 0xFFFFFFFFFFFFFFFFULL;
82 /* shift down until exp < 12 or l = 0 */
90 #define __fixunsdfdi ___fixunsdfdi
95 #define EXPD(fp) (((fp.l.upper) >> 20) & 0x7FF)
97 #define SIGNBIT 0x80000000
98 #define SIGND(fp) ((fp.l.upper) & SIGNBIT)
99 #define MANTD_LL(fp) ((fp.ll & (HIDDEND_LL-1)) | HIDDEND_LL)
100 #define FRACD_LL(fp) (fp.ll & (HIDDEND_LL-1))
101 #define HIDDEND_LL ((UDItype_x)1 << 52)
103 typedef int DItype_x __attribute__ ((mode (DI)));
104 typedef unsigned int UDItype_x __attribute__ ((mode (DI)));
105 typedef int SItype_x __attribute__ ((mode (SI)));
106 typedef unsigned int USItype_x __attribute__ ((mode (SI)));
117 /* convert double to int */
119 __fixdfdi (double a1)
121 register union double_long dl1;
127 /* +/- 0, denormalized */
132 exp = EXPD (dl1) - EXCESSD - 53;
141 if ((EXPD(dl1) == 0x7ff) && (FRACD_LL(dl1) != 0)) /* NaN */
142 return 0x8000000000000000ULL;
144 /* Number big number & +/- inf */
147 l = (long long)1<<63;
155 /* shift down until exp < 12 or l = 0 */
161 return (SIGND (dl1) ? -l : l);
163 #define __fixdfdi ___fixdfdi
168 #define EXP(fp) (((fp.l) >> 23) & 0xFF)
170 #define SIGNBIT 0x80000000
171 #define SIGN(fp) ((fp.l) & SIGNBIT)
172 #define HIDDEN (1 << 23)
173 #define MANT(fp) (((fp.l) & 0x7FFFFF) | HIDDEN)
174 #define FRAC(fp) ((fp.l) & 0x7FFFFF)
176 typedef int DItype_x __attribute__ ((mode (DI)));
177 typedef unsigned int UDItype_x __attribute__ ((mode (DI)));
178 typedef int SItype_x __attribute__ ((mode (SI)));
179 typedef unsigned int USItype_x __attribute__ ((mode (SI)));
187 /* convert float to unsigned int */
189 __fixunssfdi (float a1)
191 register union float_long fl1;
193 register UDItype_x l;
197 /* +/- 0, denormalized, negativ */
199 if (!EXP (fl1) || SIGN(fl1))
202 exp = EXP (fl1) - EXCESS - 24;
211 if ((EXP(fl1) == 0xff) && (FRAC(fl1) != 0)) /* NaN */
214 /* Number big number & + inf */
217 return 0xFFFFFFFFFFFFFFFFULL;
229 #define __fixunssfdi ___fixunssfdi
234 #define EXP(fp) (((fp.l) >> 23) & 0xFF)
236 #define SIGNBIT 0x80000000
237 #define SIGN(fp) ((fp.l) & SIGNBIT)
238 #define HIDDEN (1 << 23)
239 #define MANT(fp) (((fp.l) & 0x7FFFFF) | HIDDEN)
240 #define FRAC(fp) ((fp.l) & 0x7FFFFF)
242 typedef int DItype_x __attribute__ ((mode (DI)));
243 typedef unsigned int UDItype_x __attribute__ ((mode (DI)));
244 typedef int SItype_x __attribute__ ((mode (SI)));
245 typedef unsigned int USItype_x __attribute__ ((mode (SI)));
253 /* convert double to int */
257 register union float_long fl1;
263 /* +/- 0, denormalized */
268 exp = EXP (fl1) - EXCESS - 24;
277 if ((EXP(fl1) == 0xff) && (FRAC(fl1) != 0)) /* NaN */
278 return 0x8000000000000000ULL;
280 /* Number big number & +/- inf */
283 l = (long long)1<<63;
296 return (SIGN (fl1) ? -l : l);
298 #define __fixsfdi ___fixsfdi