OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [config/] [pa/] [quadlib.c] - Blame information for rev 298

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 282 jeremybenn
/* Subroutines for long double support.
2
   Copyright (C) 2000, 2002, 2004, 2005, 2006, 2009 Free Software Foundation, Inc.
3
 
4
This file is part of GCC.
5
 
6
GCC is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 3, or (at your option)
9
any later version.
10
 
11
GCC is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
GNU General Public License for more details.
15
 
16
Under Section 7 of GPL version 3, you are granted additional
17
permissions described in the GCC Runtime Library Exception, version
18
3.1, as published by the Free Software Foundation.
19
 
20
You should have received a copy of the GNU General Public License and
21
a copy of the GCC Runtime Library Exception along with this program;
22
see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
23
<http://www.gnu.org/licenses/>.  */
24
 
25
/* HPUX TFmode compare requires a library call to _U_Qfcmp.  It takes
26
   a magic number as its third argument which indicates what to do.
27
   The return value is an integer to be compared against zero.  The
28
   comparison conditions are the same as those listed in Table 8-12
29
   of the PA-RISC 2.0 Architecture book for the fcmp instruction.  */
30
 
31
/* Raise FP_INVALID on SNaN as a side effect.  */
32
#define QCMP_INV 1
33
 
34
/* Comparison relations.  */
35
#define QCMP_UNORD 2
36
#define QCMP_EQ 4
37
#define QCMP_LT 8
38
#define QCMP_GT 16
39
 
40
int _U_Qfcmp (long double a, long double b, int);
41
long _U_Qfcnvfxt_quad_to_sgl (long double);
42
 
43
int _U_Qfeq (long double, long double);
44
int _U_Qfne (long double, long double);
45
int _U_Qfgt (long double, long double);
46
int _U_Qfge (long double, long double);
47
int _U_Qflt (long double, long double);
48
int _U_Qfle (long double, long double);
49
int _U_Qfltgt (long double, long double);
50
int _U_Qfunle (long double, long double);
51
int _U_Qfunlt (long double, long double);
52
int _U_Qfunge (long double, long double);
53
int _U_Qfungt (long double, long double);
54
int _U_Qfuneq (long double, long double);
55
int _U_Qfunord (long double, long double);
56
int _U_Qford (long double, long double);
57
 
58
int _U_Qfcomp (long double, long double);
59
 
60
long double _U_Qfneg (long double);
61
 
62
#ifdef __LP64__
63
int __U_Qfcnvfxt_quad_to_sgl (long double);
64
#endif
65
unsigned int _U_Qfcnvfxt_quad_to_usgl(long double);
66
long double _U_Qfcnvxf_usgl_to_quad (unsigned int);
67
unsigned long long _U_Qfcnvfxt_quad_to_udbl(long double);
68
long double _U_Qfcnvxf_udbl_to_quad (unsigned long long);
69
 
70
int
71
_U_Qfeq (long double a, long double b)
72
{
73
  return (_U_Qfcmp (a, b, QCMP_EQ) != 0);
74
}
75
 
76
int
77
_U_Qfne (long double a, long double b)
78
{
79
  return (_U_Qfcmp (a, b, QCMP_EQ) == 0);
80
}
81
 
82
int
83
_U_Qfgt (long double a, long double b)
84
{
85
  return (_U_Qfcmp (a, b, QCMP_INV | QCMP_GT) != 0);
86
}
87
 
88
int
89
_U_Qfge (long double a, long double b)
90
{
91
  return (_U_Qfcmp (a, b, QCMP_INV | QCMP_EQ | QCMP_GT) != 0);
92
}
93
 
94
int
95
_U_Qflt (long double a, long double b)
96
{
97
  return (_U_Qfcmp (a, b, QCMP_INV | QCMP_LT) != 0);
98
}
99
 
100
int
101
_U_Qfle (long double a, long double b)
102
{
103
  return (_U_Qfcmp (a, b, QCMP_INV | QCMP_EQ | QCMP_LT) != 0);
104
}
105
 
106
int
107
_U_Qfltgt (long double a, long double b)
108
{
109
  return (_U_Qfcmp (a, b, QCMP_INV | QCMP_LT | QCMP_GT) != 0);
110
}
111
 
112
int
113
_U_Qfunle (long double a, long double b)
114
{
115
  return (_U_Qfcmp (a, b, QCMP_INV | QCMP_UNORD | QCMP_EQ | QCMP_LT) != 0);
116
}
117
 
118
int
119
_U_Qfunlt (long double a, long double b)
120
{
121
  return (_U_Qfcmp (a, b, QCMP_INV | QCMP_UNORD | QCMP_LT) != 0);
122
}
123
 
124
int
125
_U_Qfunge (long double a, long double b)
126
{
127
  return (_U_Qfcmp (a, b, QCMP_INV | QCMP_UNORD | QCMP_EQ | QCMP_GT) != 0);
128
}
129
 
130
int
131
_U_Qfungt (long double a, long double b)
132
{
133
  return (_U_Qfcmp (a, b, QCMP_INV | QCMP_UNORD | QCMP_GT) != 0);
134
}
135
 
136
int
137
_U_Qfuneq (long double a, long double b)
138
{
139
  return (_U_Qfcmp (a, b, QCMP_INV | QCMP_UNORD | QCMP_EQ) != 0);
140
}
141
 
142
int
143
_U_Qfunord (long double a, long double b)
144
{
145
  return (_U_Qfcmp (a, b, QCMP_INV | QCMP_UNORD) != 0);
146
}
147
 
148
int
149
_U_Qford (long double a, long double b)
150
{
151
  return (_U_Qfcmp (a, b, QCMP_INV | QCMP_EQ | QCMP_LT | QCMP_GT) != 0);
152
}
153
 
154
int
155
_U_Qfcomp (long double a, long double b)
156
{
157
  if (_U_Qfcmp (a, b, QCMP_EQ) == 0)
158
    return 0;
159
 
160
  return (_U_Qfcmp (a, b, QCMP_UNORD | QCMP_EQ | QCMP_GT) != 0 ? 1 : -1);
161
}
162
 
163
 
164
/* Negate long double A.  */
165
long double
166
_U_Qfneg (long double a)
167
{
168
  union
169
   {
170
     long double ld;
171
     int i[4];
172
   } u;
173
 
174
  u.ld = a;
175
  u.i[0] ^= 0x80000000;
176
  return u.ld;
177
}
178
 
179
#ifdef __LP64__
180
/* This routine is only necessary for the PA64 port; for reasons unknown
181
   _U_Qfcnvfxt_quad_to_sgl returns the integer in the high 32bits of the
182
   return value.  Ugh.  */
183
int
184
__U_Qfcnvfxt_quad_to_sgl (long double a)
185
{
186
  return _U_Qfcnvfxt_quad_to_sgl (a) >> 32;
187
}
188
#endif
189
 
190
/* HP only has signed conversion in the C library, so need to synthesize
191
   unsigned versions.  */
192
unsigned int
193
_U_Qfcnvfxt_quad_to_usgl (long double a)
194
{
195
  extern long long _U_Qfcnvfxt_quad_to_dbl (long double a);
196
  return (unsigned int) _U_Qfcnvfxt_quad_to_dbl (a);
197
}
198
 
199
long double
200
_U_Qfcnvxf_usgl_to_quad (unsigned int a)
201
{
202
  extern long double _U_Qfcnvxf_dbl_to_quad (long long);
203
  return _U_Qfcnvxf_dbl_to_quad ((long long) a);
204
}
205
 
206
typedef union {
207
    unsigned long long u[2];
208
    long double d[1];
209
} quad_type;
210
 
211
unsigned long long
212
_U_Qfcnvfxt_quad_to_udbl (long double a)
213
{
214
  extern quad_type _U_Qfcnvfxt_quad_to_quad (long double a);
215
  quad_type u;
216
  u = _U_Qfcnvfxt_quad_to_quad(a);
217
  return u.u[1];
218
}
219
 
220
long double
221
_U_Qfcnvxf_udbl_to_quad (unsigned long long a)
222
{
223
  extern long double _U_Qfcnvxf_quad_to_quad (quad_type a);
224
  quad_type u;
225
  u.u[0] = 0;
226
  u.u[1] = a;
227
  return _U_Qfcnvxf_quad_to_quad (u);
228
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.