]>
Commit | Line | Data |
---|---|---|
2b24fc41 JJ |
1 | /* Functions needed for soft-float on powerpc64-linux, copied from |
2 | libgcc2.c with macros expanded to force the use of specific types. | |
3 | ||
4 | Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, | |
5 | 2000, 2001, 2002, 2003 Free Software Foundation, Inc. | |
6 | ||
7 | This file is part of GCC. | |
8 | ||
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 | |
12 | version. | |
13 | ||
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 | |
21 | executable.) | |
22 | ||
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 | |
26 | for more details. | |
27 | ||
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 | |
31 | 02111-1307, USA. */ | |
32 | ||
33 | #if defined(__powerpc64__) | |
65dbc870 | 34 | #include "config/fp-bit.h" |
2b24fc41 JJ |
35 | |
36 | extern DItype __fixdfdi (DFtype); | |
37 | extern DItype __fixsfdi (SFtype); | |
38 | extern USItype __fixunsdfsi (DFtype); | |
39 | extern USItype __fixunssfsi (SFtype); | |
40 | extern DFtype __floatdidf (DItype); | |
41 | extern SFtype __floatdisf (DItype); | |
42 | ||
43 | static DItype local_fixunssfdi (SFtype); | |
44 | static DItype local_fixunsdfdi (DFtype); | |
45 | ||
46 | DItype | |
47 | __fixdfdi (DFtype a) | |
48 | { | |
49 | if (a < 0) | |
50 | return - local_fixunsdfdi (-a); | |
51 | return local_fixunsdfdi (a); | |
52 | } | |
53 | ||
54 | DItype | |
55 | __fixsfdi (SFtype a) | |
56 | { | |
57 | if (a < 0) | |
58 | return - local_fixunssfdi (-a); | |
59 | return local_fixunssfdi (a); | |
60 | } | |
61 | ||
62 | USItype | |
63 | __fixunsdfsi (DFtype a) | |
64 | { | |
65 | if (a >= - (DFtype) (- ((SItype)(((USItype)1 << ((4 * 8) - 1)) - 1)) - 1)) | |
66 | return (SItype) (a + (- ((SItype)(((USItype)1 << ((4 * 8) - 1)) - 1)) - 1)) | |
67 | - (- ((SItype)(((USItype)1 << ((4 * 8) - 1)) - 1)) - 1); | |
68 | return (SItype) a; | |
69 | } | |
70 | ||
71 | USItype | |
72 | __fixunssfsi (SFtype a) | |
73 | { | |
74 | if (a >= - (SFtype) (- ((SItype)(((USItype)1 << ((4 * 8) - 1)) - 1)) - 1)) | |
75 | return (SItype) (a + (- ((SItype)(((USItype)1 << ((4 * 8) - 1)) - 1)) - 1)) | |
76 | - (- ((SItype)(((USItype)1 << ((4 * 8) - 1)) - 1)) - 1); | |
77 | return (SItype) a; | |
78 | } | |
79 | ||
80 | DFtype | |
81 | __floatdidf (DItype u) | |
82 | { | |
83 | DFtype d; | |
84 | ||
85 | d = (SItype) (u >> (sizeof (SItype) * 8)); | |
86 | d *= (((UDItype) 1) << ((sizeof (SItype) * 8) / 2)); | |
87 | d *= (((UDItype) 1) << ((sizeof (SItype) * 8) / 2)); | |
88 | d += (USItype) (u & ((((UDItype) 1) << (sizeof (SItype) * 8)) - 1)); | |
89 | ||
90 | return d; | |
91 | } | |
92 | ||
93 | SFtype | |
94 | __floatdisf (DItype u) | |
95 | { | |
96 | DFtype f; | |
97 | ||
98 | if (53 < (sizeof (DItype) * 8) | |
99 | && 53 > ((sizeof (DItype) * 8) - 53 + 24)) | |
100 | { | |
101 | if (! (- ((DItype) 1 << 53) < u | |
102 | && u < ((DItype) 1 << 53))) | |
103 | { | |
104 | if ((UDItype) u & (((UDItype) 1 << ((sizeof (DItype) * 8) - 53)) - 1)) | |
105 | { | |
106 | u &= ~ (((UDItype) 1 << ((sizeof (DItype) * 8) - 53)) - 1); | |
107 | u |= ((UDItype) 1 << ((sizeof (DItype) * 8) - 53)); | |
108 | } | |
109 | } | |
110 | } | |
111 | f = (SItype) (u >> (sizeof (SItype) * 8)); | |
112 | f *= (((UDItype) 1) << ((sizeof (SItype) * 8) / 2)); | |
113 | f *= (((UDItype) 1) << ((sizeof (SItype) * 8) / 2)); | |
114 | f += (USItype) (u & ((((UDItype) 1) << (sizeof (SItype) * 8)) - 1)); | |
115 | ||
116 | return (SFtype) f; | |
117 | } | |
118 | ||
119 | /* This version is needed to prevent recursion; fixunsdfdi in libgcc | |
120 | calls fixdfdi, which in turn calls calls fixunsdfdi. */ | |
121 | ||
122 | static DItype | |
123 | local_fixunsdfdi (DFtype a) | |
124 | { | |
125 | USItype hi, lo; | |
126 | ||
127 | hi = a / (((UDItype) 1) << (sizeof (SItype) * 8)); | |
128 | lo = (a - ((DFtype) hi) * (((UDItype) 1) << (sizeof (SItype) * 8))); | |
129 | return ((UDItype) hi << (sizeof (SItype) * 8)) | lo; | |
130 | } | |
131 | ||
132 | /* This version is needed to prevent recursion; fixunssfdi in libgcc | |
133 | calls fixsfdi, which in turn calls calls fixunssfdi. */ | |
134 | ||
135 | static DItype | |
136 | local_fixunssfdi (SFtype original_a) | |
137 | { | |
138 | DFtype a = original_a; | |
139 | USItype hi, lo; | |
140 | ||
141 | hi = a / (((UDItype) 1) << (sizeof (SItype) * 8)); | |
142 | lo = (a - ((DFtype) hi) * (((UDItype) 1) << (sizeof (SItype) * 8))); | |
143 | return ((UDItype) hi << (sizeof (SItype) * 8)) | lo; | |
144 | } | |
145 | ||
146 | #endif /* __powerpc64__ */ |