1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25#ifndef __MATH_EMU_SINGLE_H__
26#define __MATH_EMU_SINGLE_H__
27
28#if _FP_W_TYPE_SIZE < 32
29#error "Here's a nickel kid. Go buy yourself a real computer."
30#endif
31
32#define _FP_FRACBITS_S 24
33#define _FP_FRACXBITS_S (_FP_W_TYPE_SIZE - _FP_FRACBITS_S)
34#define _FP_WFRACBITS_S (_FP_WORKBITS + _FP_FRACBITS_S)
35#define _FP_WFRACXBITS_S (_FP_W_TYPE_SIZE - _FP_WFRACBITS_S)
36#define _FP_EXPBITS_S 8
37#define _FP_EXPBIAS_S 127
38#define _FP_EXPMAX_S 255
39#define _FP_QNANBIT_S ((_FP_W_TYPE)1 << (_FP_FRACBITS_S-2))
40#define _FP_IMPLBIT_S ((_FP_W_TYPE)1 << (_FP_FRACBITS_S-1))
41#define _FP_OVERFLOW_S ((_FP_W_TYPE)1 << (_FP_WFRACBITS_S))
42
43
44
45
46union _FP_UNION_S
47{
48 float flt;
49 struct {
50#if __BYTE_ORDER == __BIG_ENDIAN
51 unsigned sign : 1;
52 unsigned exp : _FP_EXPBITS_S;
53 unsigned frac : _FP_FRACBITS_S - (_FP_IMPLBIT_S != 0);
54#else
55 unsigned frac : _FP_FRACBITS_S - (_FP_IMPLBIT_S != 0);
56 unsigned exp : _FP_EXPBITS_S;
57 unsigned sign : 1;
58#endif
59 } bits __attribute__((packed));
60};
61
62#define FP_DECL_S(X) _FP_DECL(1,X)
63#define FP_UNPACK_RAW_S(X,val) _FP_UNPACK_RAW_1(S,X,val)
64#define FP_UNPACK_RAW_SP(X,val) _FP_UNPACK_RAW_1_P(S,X,val)
65#define FP_PACK_RAW_S(val,X) _FP_PACK_RAW_1(S,val,X)
66#define FP_PACK_RAW_SP(val,X) \
67 do { \
68 if (!FP_INHIBIT_RESULTS) \
69 _FP_PACK_RAW_1_P(S,val,X); \
70 } while (0)
71
72#define FP_UNPACK_S(X,val) \
73 do { \
74 _FP_UNPACK_RAW_1(S,X,val); \
75 _FP_UNPACK_CANONICAL(S,1,X); \
76 } while (0)
77
78#define FP_UNPACK_SP(X,val) \
79 do { \
80 _FP_UNPACK_RAW_1_P(S,X,val); \
81 _FP_UNPACK_CANONICAL(S,1,X); \
82 } while (0)
83
84#define FP_PACK_S(val,X) \
85 do { \
86 _FP_PACK_CANONICAL(S,1,X); \
87 _FP_PACK_RAW_1(S,val,X); \
88 } while (0)
89
90#define FP_PACK_SP(val,X) \
91 do { \
92 _FP_PACK_CANONICAL(S,1,X); \
93 if (!FP_INHIBIT_RESULTS) \
94 _FP_PACK_RAW_1_P(S,val,X); \
95 } while (0)
96
97#define FP_ISSIGNAN_S(X) _FP_ISSIGNAN(S,1,X)
98#define FP_NEG_S(R,X) _FP_NEG(S,1,R,X)
99#define FP_ADD_S(R,X,Y) _FP_ADD(S,1,R,X,Y)
100#define FP_SUB_S(R,X,Y) _FP_SUB(S,1,R,X,Y)
101#define FP_MUL_S(R,X,Y) _FP_MUL(S,1,R,X,Y)
102#define FP_DIV_S(R,X,Y) _FP_DIV(S,1,R,X,Y)
103#define FP_SQRT_S(R,X) _FP_SQRT(S,1,R,X)
104#define _FP_SQRT_MEAT_S(R,S,T,X,Q) _FP_SQRT_MEAT_1(R,S,T,X,Q)
105
106#define FP_CMP_S(r,X,Y,un) _FP_CMP(S,1,r,X,Y,un)
107#define FP_CMP_EQ_S(r,X,Y) _FP_CMP_EQ(S,1,r,X,Y)
108
109#define FP_TO_INT_S(r,X,rsz,rsg) _FP_TO_INT(S,1,r,X,rsz,rsg)
110#define FP_TO_INT_ROUND_S(r,X,rsz,rsg) _FP_TO_INT_ROUND(S,1,r,X,rsz,rsg)
111#define FP_FROM_INT_S(X,r,rs,rt) _FP_FROM_INT(S,1,X,r,rs,rt)
112
113#define _FP_FRAC_HIGH_S(X) _FP_FRAC_HIGH_1(X)
114#define _FP_FRAC_HIGH_RAW_S(X) _FP_FRAC_HIGH_1(X)
115
116#endif
117