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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46#include "float.h"
47#include "sgl_float.h"
48#include "dbl_float.h"
49#include "hppa.h"
50#include <linux/kernel.h>
51
52
53#undef Fpustatus_register
54#define Fpustatus_register Fpu_register[0]
55
56void
57sgl_denormalize(unsigned int *sgl_opnd, boolean *inexactflag, int rmode)
58{
59 unsigned int opnd;
60 int sign, exponent;
61 boolean guardbit = FALSE, stickybit, inexact;
62
63 opnd = *sgl_opnd;
64 stickybit = *inexactflag;
65 exponent = Sgl_exponent(opnd) - SGL_WRAP;
66 sign = Sgl_sign(opnd);
67 Sgl_denormalize(opnd,exponent,guardbit,stickybit,inexact);
68 if (inexact) {
69 switch (rmode) {
70 case ROUNDPLUS:
71 if (sign == 0) {
72 Sgl_increment(opnd);
73 }
74 break;
75 case ROUNDMINUS:
76 if (sign != 0) {
77 Sgl_increment(opnd);
78 }
79 break;
80 case ROUNDNEAREST:
81 if (guardbit && (stickybit ||
82 Sgl_isone_lowmantissa(opnd))) {
83 Sgl_increment(opnd);
84 }
85 break;
86 }
87 }
88 Sgl_set_sign(opnd,sign);
89 *sgl_opnd = opnd;
90 *inexactflag = inexact;
91 return;
92}
93
94void
95dbl_denormalize(unsigned int *dbl_opndp1,
96 unsigned int * dbl_opndp2,
97 boolean *inexactflag,
98 int rmode)
99{
100 unsigned int opndp1, opndp2;
101 int sign, exponent;
102 boolean guardbit = FALSE, stickybit, inexact;
103
104 opndp1 = *dbl_opndp1;
105 opndp2 = *dbl_opndp2;
106 stickybit = *inexactflag;
107 exponent = Dbl_exponent(opndp1) - DBL_WRAP;
108 sign = Dbl_sign(opndp1);
109 Dbl_denormalize(opndp1,opndp2,exponent,guardbit,stickybit,inexact);
110 if (inexact) {
111 switch (rmode) {
112 case ROUNDPLUS:
113 if (sign == 0) {
114 Dbl_increment(opndp1,opndp2);
115 }
116 break;
117 case ROUNDMINUS:
118 if (sign != 0) {
119 Dbl_increment(opndp1,opndp2);
120 }
121 break;
122 case ROUNDNEAREST:
123 if (guardbit && (stickybit ||
124 Dbl_isone_lowmantissap2(opndp2))) {
125 Dbl_increment(opndp1,opndp2);
126 }
127 break;
128 }
129 }
130 Dbl_set_sign(opndp1,sign);
131 *dbl_opndp1 = opndp1;
132 *dbl_opndp2 = opndp2;
133 *inexactflag = inexact;
134 return;
135}
136