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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libquadmath/] [quadmath-imp.h] - Blame information for rev 846

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

Line No. Rev Author Line
1 740 jeremybenn
/* GCC Quad-Precision Math Library
2
   Copyright (C) 2010, 2011 Free Software Foundation, Inc.
3
   Written by Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
4
 
5
This file is part of the libquadmath library.
6
Libquadmath is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Library General Public
8
License as published by the Free Software Foundation; either
9
version 2 of the License, or (at your option) any later version.
10
 
11
Libquadmath 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 GNU
14
Library General Public License for more details.
15
 
16
You should have received a copy of the GNU Library General Public
17
License along with libquadmath; see the file COPYING.LIB.  If
18
not, write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
19
Boston, MA 02110-1301, USA.  */
20
 
21
#ifndef QUADMATH_IMP_H
22
#define QUADMATH_IMP_H
23
 
24
#include <stdint.h>
25
#include <stdlib.h>
26
#include "quadmath.h"
27
#include "config.h"
28
 
29
 
30
/* Prototypes for internal functions.  */
31
extern int32_t __quadmath_rem_pio2q (__float128, __float128 *);
32
extern void __quadmath_kernel_sincosq (__float128, __float128, __float128 *,
33
                                       __float128 *, int);
34
extern __float128 __quadmath_kernel_sinq (__float128, __float128, int);
35
extern __float128 __quadmath_kernel_cosq (__float128, __float128);
36
 
37
 
38
 
39
/* Frankly, if you have __float128, you have 64-bit integers, right?  */
40
#ifndef UINT64_C
41
# error "No way!"
42
#endif
43
 
44
 
45
/* Main union type we use to manipulate the floating-point type.  */
46
typedef union
47
{
48
  __float128 value;
49
 
50
  struct
51
#ifdef __MINGW32__
52
  /* On mingw targets the ms-bitfields option is active by default.
53
     Therefore enforce gnu-bitfield style.  */
54
  __attribute__ ((gcc_struct))
55
#endif
56
  {
57
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
58
    unsigned negative:1;
59
    unsigned exponent:15;
60
    uint64_t mant_high:48;
61
    uint64_t mant_low:64;
62
#else
63
    uint64_t mant_low:64;
64
    uint64_t mant_high:48;
65
    unsigned exponent:15;
66
    unsigned negative:1;
67
#endif
68
  } ieee;
69
 
70
  struct
71
  {
72
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
73
    uint64_t high;
74
    uint64_t low;
75
#else
76
    uint64_t low;
77
    uint64_t high;
78
#endif
79
  } words64;
80
 
81
  struct
82
  {
83
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
84
    uint32_t w0;
85
    uint32_t w1;
86
    uint32_t w2;
87
    uint32_t w3;
88
#else
89
    uint32_t w3;
90
    uint32_t w2;
91
    uint32_t w1;
92
    uint32_t w0;
93
#endif
94
  } words32;
95
 
96
  struct
97
#ifdef __MINGW32__
98
  /* Make sure we are using gnu-style bitfield handling.  */
99
  __attribute__ ((gcc_struct))
100
#endif
101
  {
102
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
103
    unsigned negative:1;
104
    unsigned exponent:15;
105
    unsigned quiet_nan:1;
106
    uint64_t mant_high:47;
107
    uint64_t mant_low:64;
108
#else
109
    uint64_t mant_low:64;
110
    uint64_t mant_high:47;
111
    unsigned quiet_nan:1;
112
    unsigned exponent:15;
113
    unsigned negative:1;
114
#endif
115
  } nan;
116
 
117
} ieee854_float128;
118
 
119
 
120
/* Get two 64 bit ints from a long double.  */
121
#define GET_FLT128_WORDS64(ix0,ix1,d)  \
122
do {                                   \
123
  ieee854_float128 u;                  \
124
  u.value = (d);                       \
125
  (ix0) = u.words64.high;              \
126
  (ix1) = u.words64.low;               \
127
} while (0)
128
 
129
/* Set a long double from two 64 bit ints.  */
130
#define SET_FLT128_WORDS64(d,ix0,ix1)  \
131
do {                                   \
132
  ieee854_float128 u;                  \
133
  u.words64.high = (ix0);              \
134
  u.words64.low = (ix1);               \
135
  (d) = u.value;                       \
136
} while (0)
137
 
138
/* Get the more significant 64 bits of a long double mantissa.  */
139
#define GET_FLT128_MSW64(v,d)          \
140
do {                                   \
141
  ieee854_float128 u;                  \
142
  u.value = (d);                       \
143
  (v) = u.words64.high;                \
144
} while (0)
145
 
146
/* Set the more significant 64 bits of a long double mantissa from an int.  */
147
#define SET_FLT128_MSW64(d,v)          \
148
do {                                   \
149
  ieee854_float128 u;                  \
150
  u.value = (d);                       \
151
  u.words64.high = (v);                \
152
  (d) = u.value;                       \
153
} while (0)
154
 
155
/* Get the least significant 64 bits of a long double mantissa.  */
156
#define GET_FLT128_LSW64(v,d)          \
157
do {                                   \
158
  ieee854_float128 u;                  \
159
  u.value = (d);                       \
160
  (v) = u.words64.low;                 \
161
} while (0)
162
 
163
 
164
#define IEEE854_FLOAT128_BIAS 0x3fff
165
 
166
#define QUADFP_NAN              0
167
#define QUADFP_INFINITE         1
168
#define QUADFP_ZERO             2
169
#define QUADFP_SUBNORMAL        3
170
#define QUADFP_NORMAL           4
171
#define fpclassifyq(x) \
172
  __builtin_fpclassify (QUADFP_NAN, QUADFP_INFINITE, QUADFP_NORMAL, \
173
                        QUADFP_SUBNORMAL, QUADFP_ZERO, x)
174
 
175
#endif

powered by: WebSVN 2.1.0

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