1 /* Functions needed for soft-float on powerpc64-linux, copied from
2 libgcc2.c with macros expanded to force the use of specific types.
4 Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
5 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
7 This file is part of GCC.
9 GCC is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free
11 Software Foundation; either version 2, or (at your option) any later
14 In addition to the permissions in the GNU General Public License, the
15 Free Software Foundation gives you unlimited permission to link the
16 compiled version of this file into combinations with other programs,
17 and to distribute those combinations without any restriction coming
18 from the use of this file. (The General Public License restrictions
19 do apply in other respects; for example, they cover modification of
20 the file, and distribution when not linked into a combine
23 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
24 WARRANTY; without even the implied warranty of MERCHANTABILITY or
25 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
28 You should have received a copy of the GNU General Public License
29 along with GCC; see the file COPYING. If not, write to the Free
30 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
33 #if defined(__powerpc64__)
34 #include "config/fp-bit.h"
36 extern DItype
__fixtfdi (TFtype
);
37 extern DItype
__fixdfdi (DFtype
);
38 extern DItype
__fixsfdi (SFtype
);
39 extern USItype
__fixunsdfsi (DFtype
);
40 extern USItype
__fixunssfsi (SFtype
);
41 extern TFtype
__floatditf (DItype
);
42 extern DFtype
__floatdidf (DItype
);
43 extern SFtype
__floatdisf (DItype
);
44 extern DItype
__fixunstfdi (TFtype
);
46 static DItype
local_fixunssfdi (SFtype
);
47 static DItype
local_fixunsdfdi (DFtype
);
53 return - __fixunstfdi (-a
);
54 return __fixunstfdi (a
);
61 return - local_fixunsdfdi (-a
);
62 return local_fixunsdfdi (a
);
69 return - local_fixunssfdi (-a
);
70 return local_fixunssfdi (a
);
74 __fixunsdfsi (DFtype a
)
76 if (a
>= - (DFtype
) (- ((SItype
)(((USItype
)1 << ((4 * 8) - 1)) - 1)) - 1))
77 return (SItype
) (a
+ (- ((SItype
)(((USItype
)1 << ((4 * 8) - 1)) - 1)) - 1))
78 - (- ((SItype
)(((USItype
)1 << ((4 * 8) - 1)) - 1)) - 1);
83 __fixunssfsi (SFtype a
)
85 if (a
>= - (SFtype
) (- ((SItype
)(((USItype
)1 << ((4 * 8) - 1)) - 1)) - 1))
86 return (SItype
) (a
+ (- ((SItype
)(((USItype
)1 << ((4 * 8) - 1)) - 1)) - 1))
87 - (- ((SItype
)(((USItype
)1 << ((4 * 8) - 1)) - 1)) - 1);
92 __floatditf (DItype u
)
96 dh
= (SItype
) (u
>> (sizeof (SItype
) * 8));
97 dh
*= 2.0 * (((UDItype
) 1) << ((sizeof (SItype
) * 8) - 1));
98 dl
= (USItype
) (u
& ((((UDItype
) 1) << (sizeof (SItype
) * 8)) - 1));
100 return (TFtype
) dh
+ (TFtype
) dl
;
104 __floatdidf (DItype u
)
108 d
= (SItype
) (u
>> (sizeof (SItype
) * 8));
109 d
*= 2.0 * (((UDItype
) 1) << ((sizeof (SItype
) * 8) - 1));
110 d
+= (USItype
) (u
& ((((UDItype
) 1) << (sizeof (SItype
) * 8)) - 1));
116 __floatdisf (DItype u
)
120 if (53 < (sizeof (DItype
) * 8)
121 && 53 > ((sizeof (DItype
) * 8) - 53 + 24))
123 if (! (- ((DItype
) 1 << 53) < u
124 && u
< ((DItype
) 1 << 53)))
126 if ((UDItype
) u
& (((UDItype
) 1 << ((sizeof (DItype
) * 8) - 53)) - 1))
128 u
&= ~ (((UDItype
) 1 << ((sizeof (DItype
) * 8) - 53)) - 1);
129 u
|= ((UDItype
) 1 << ((sizeof (DItype
) * 8) - 53));
133 f
= (SItype
) (u
>> (sizeof (SItype
) * 8));
134 f
*= 2.0 * (((UDItype
) 1) << ((sizeof (SItype
) * 8) - 1));
135 f
+= (USItype
) (u
& ((((UDItype
) 1) << (sizeof (SItype
) * 8)) - 1));
141 __fixunstfdi (TFtype a
)
146 /* Compute high word of result, as a flonum. */
147 const TFtype b
= (a
/ (((UDItype
) 1) << (sizeof (SItype
) * 8)));
148 /* Convert that to fixed (but not to DItype!),
149 and shift it into the high word. */
150 UDItype v
= (USItype
) b
;
151 v
<<= (sizeof (SItype
) * 8);
152 /* Remove high part from the TFtype, leaving the low part as flonum. */
154 /* Convert that to fixed (but not to DItype!) and add it in.
155 Sometimes A comes out negative. This is significant, since
156 A has more bits than a long int does. */
164 /* This version is needed to prevent recursion; fixunsdfdi in libgcc
165 calls fixdfdi, which in turn calls calls fixunsdfdi. */
168 local_fixunsdfdi (DFtype a
)
172 hi
= a
/ (((UDItype
) 1) << (sizeof (SItype
) * 8));
173 lo
= (a
- ((DFtype
) hi
) * (((UDItype
) 1) << (sizeof (SItype
) * 8)));
174 return ((UDItype
) hi
<< (sizeof (SItype
) * 8)) | lo
;
177 /* This version is needed to prevent recursion; fixunssfdi in libgcc
178 calls fixsfdi, which in turn calls calls fixunssfdi. */
181 local_fixunssfdi (SFtype original_a
)
183 DFtype a
= original_a
;
186 hi
= a
/ (((UDItype
) 1) << (sizeof (SItype
) * 8));
187 lo
= (a
- ((DFtype
) hi
) * (((UDItype
) 1) << (sizeof (SItype
) * 8)));
188 return ((UDItype
) hi
<< (sizeof (SItype
) * 8)) | lo
;
191 #endif /* __powerpc64__ */