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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [arch/] [ppc/] [math-emu/] [double.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
 * Definitions for IEEE Double Precision
3
 */
4
 
5
#if _FP_W_TYPE_SIZE < 32
6
#error "Here's a nickel kid.  Go buy yourself a real computer."
7
#endif
8
 
9
#if _FP_W_TYPE_SIZE < 64
10
#define _FP_FRACTBITS_D         (2 * _FP_W_TYPE_SIZE)
11
#else
12
#define _FP_FRACTBITS_D         _FP_W_TYPE_SIZE
13
#endif
14
 
15
#define _FP_FRACBITS_D          53
16
#define _FP_FRACXBITS_D         (_FP_FRACTBITS_D - _FP_FRACBITS_D)
17
#define _FP_WFRACBITS_D         (_FP_WORKBITS + _FP_FRACBITS_D)
18
#define _FP_WFRACXBITS_D        (_FP_FRACTBITS_D - _FP_WFRACBITS_D)
19
#define _FP_EXPBITS_D           11
20
#define _FP_EXPBIAS_D           1023
21
#define _FP_EXPMAX_D            2047
22
 
23
#define _FP_QNANBIT_D           \
24
        ((_FP_W_TYPE)1 << ((_FP_FRACBITS_D-2) % _FP_W_TYPE_SIZE))
25
#define _FP_IMPLBIT_D           \
26
        ((_FP_W_TYPE)1 << ((_FP_FRACBITS_D-1) % _FP_W_TYPE_SIZE))
27
#define _FP_OVERFLOW_D          \
28
        ((_FP_W_TYPE)1 << (_FP_WFRACBITS_D % _FP_W_TYPE_SIZE))
29
 
30
#if _FP_W_TYPE_SIZE < 64
31
 
32
union _FP_UNION_D
33
{
34
  double flt;
35
  struct {
36
#if __BYTE_ORDER == __BIG_ENDIAN
37
    unsigned sign  : 1;
38
    unsigned exp   : _FP_EXPBITS_D;
39
    unsigned frac1 : _FP_FRACBITS_D - (_FP_IMPLBIT_D != 0) - _FP_W_TYPE_SIZE;
40
    unsigned frac0 : _FP_W_TYPE_SIZE;
41
#else
42
    unsigned frac0 : _FP_W_TYPE_SIZE;
43
    unsigned frac1 : _FP_FRACBITS_D - (_FP_IMPLBIT_D != 0) - _FP_W_TYPE_SIZE;
44
    unsigned exp   : _FP_EXPBITS_D;
45
    unsigned sign  : 1;
46
#endif
47
  } bits __attribute__((packed));
48
};
49
 
50
#define FP_DECL_D(X)            _FP_DECL(2,X)
51
#define FP_UNPACK_RAW_D(X,val)  _FP_UNPACK_RAW_2(D,X,val)
52
#define FP_PACK_RAW_D(val,X)    _FP_PACK_RAW_2(D,val,X)
53
 
54
#define FP_UNPACK_D(X,val)              \
55
  do {                                  \
56
    _FP_UNPACK_RAW_2(D,X,val);          \
57
    _FP_UNPACK_CANONICAL(D,2,X);        \
58
  } while (0)
59
 
60
#define FP_PACK_D(val,X)                \
61
  do {                                  \
62
    _FP_PACK_CANONICAL(D,2,X);          \
63
    _FP_PACK_RAW_2(D,val,X);            \
64
  } while (0)
65
 
66
#define FP_NEG_D(R,X)           _FP_NEG(D,2,R,X)
67
#define FP_ADD_D(R,X,Y)         _FP_ADD(D,2,R,X,Y)
68
#define FP_SUB_D(R,X,Y)         _FP_SUB(D,2,R,X,Y)
69
#define FP_MUL_D(R,X,Y)         _FP_MUL(D,2,R,X,Y)
70
#define FP_DIV_D(R,X,Y)         _FP_DIV(D,2,R,X,Y)
71
#define FP_SQRT_D(R,X)          _FP_SQRT(D,2,R,X)
72
 
73
#define FP_CMP_D(r,X,Y,un)      _FP_CMP(D,2,r,X,Y,un)
74
#define FP_CMP_EQ_D(r,X,Y)      _FP_CMP_EQ(D,2,r,X,Y)
75
 
76
#define FP_TO_INT_D(r,X,rsz,rsg)  _FP_TO_INT(D,2,r,X,rsz,rsg)
77
#define FP_FROM_INT_D(X,r,rs,rt)  _FP_FROM_INT(D,2,X,r,rs,rt)
78
 
79
#else
80
 
81
union _FP_UNION_D
82
{
83
  double flt;
84
  struct {
85
#if __BYTE_ORDER == __BIG_ENDIAN
86
    unsigned sign : 1;
87
    unsigned exp  : _FP_EXPBITS_D;
88
    unsigned long frac : _FP_FRACBITS_D - (_FP_IMPLBIT_D != 0);
89
#else
90
    unsigned long frac : _FP_FRACBITS_D - (_FP_IMPLBIT_D != 0);
91
    unsigned exp  : _FP_EXPBITS_D;
92
    unsigned sign : 1;
93
#endif
94
  } bits __attribute__((packed));
95
};
96
 
97
#define FP_DECL_D(X)            _FP_DECL(1,X)
98
#define FP_UNPACK_RAW_D(X,val)  _FP_UNPACK_RAW_1(D,X,val)
99
#define FP_PACK_RAW_D(val,X)    _FP_PACK_RAW_1(D,val,X)
100
 
101
#define FP_UNPACK_D(X,val)              \
102
  do {                                  \
103
    _FP_UNPACK_RAW_1(D,X,val);          \
104
    _FP_UNPACK_CANONICAL(D,1,X);        \
105
  } while (0)
106
 
107
#define FP_PACK_D(val,X)                \
108
  do {                                  \
109
    _FP_PACK_CANONICAL(D,1,X);          \
110
    _FP_PACK_RAW_1(D,val,X);            \
111
  } while (0)
112
 
113
#define FP_NEG_D(R,X)           _FP_NEG(D,1,R,X)
114
#define FP_ADD_D(R,X,Y)         _FP_ADD(D,1,R,X,Y)
115
#define FP_SUB_D(R,X,Y)         _FP_SUB(D,1,R,X,Y)
116
#define FP_MUL_D(R,X,Y)         _FP_MUL(D,1,R,X,Y)
117
#define FP_DIV_D(R,X,Y)         _FP_DIV(D,1,R,X,Y)
118
#define FP_SQRT_D(R,X)          _FP_SQRT(D,1,R,X)
119
 
120
/* The implementation of _FP_MUL_D and _FP_DIV_D should be chosen by
121
   the target machine.  */
122
 
123
#define FP_CMP_D(r,X,Y,un)      _FP_CMP(D,1,r,X,Y,un)
124
#define FP_CMP_EQ_D(r,X,Y)      _FP_CMP_EQ(D,1,r,X,Y)
125
 
126
#define FP_TO_INT_D(r,X,rsz,rsg)  _FP_TO_INT(D,1,r,X,rsz,rsg)
127
#define FP_FROM_INT_D(X,r,rs,rt)  _FP_FROM_INT(D,1,X,r,rs,rt)
128
 
129
#endif /* W_TYPE_SIZE < 64 */

powered by: WebSVN 2.1.0

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