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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [config/] [pa/] [quadlib.c] - Blame information for rev 820

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

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

powered by: WebSVN 2.1.0

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