Annotation of sys/arch/hppa/spmath/dbl_float.h, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: dbl_float.h,v 1.11 2006/11/29 10:40:44 mickey Exp $ */
2: /*
3: (c) Copyright 1986 HEWLETT-PACKARD COMPANY
4: To anyone who acknowledges that this file is provided "AS IS"
5: without any express or implied warranty:
6: permission to use, copy, modify, and distribute this file
7: for any purpose is hereby granted without fee, provided that
8: the above copyright notice and this notice appears in all
9: copies, and that the name of Hewlett-Packard Company not be
10: used in advertising or publicity pertaining to distribution
11: of the software without specific, written prior permission.
12: Hewlett-Packard Company makes no representations about the
13: suitability of this software for any purpose.
14: */
15: /* @(#)dbl_float.h: Revision: 2.9.88.1 Date: 93/12/07 15:05:32 */
16:
17: /**************************************
18: * Declare double precision functions *
19: **************************************/
20:
21: /* 32-bit word grabing functions */
22: #define Dbl_firstword(value) Dallp1(value)
23: #define Dbl_secondword(value) Dallp2(value)
24: #define Dbl_thirdword(value) dummy_location
25: #define Dbl_fourthword(value) dummy_location
26:
27: #define Dbl_sign(object) Dsign(object)
28: #define Dbl_exponent(object) Dexponent(object)
29: #define Dbl_signexponent(object) Dsignexponent(object)
30: #define Dbl_mantissap1(object) Dmantissap1(object)
31: #define Dbl_mantissap2(object) Dmantissap2(object)
32: #define Dbl_exponentmantissap1(object) Dexponentmantissap1(object)
33: #define Dbl_allp1(object) Dallp1(object)
34: #define Dbl_allp2(object) Dallp2(object)
35:
36: /* dbl_and_signs ands the sign bits of each argument and puts the result
37: * into the first argument. dbl_or_signs ors those same sign bits */
38: #define Dbl_and_signs( src1dst, src2) \
39: Dallp1(src1dst) = (Dallp1(src2)|~(1<<31)) & Dallp1(src1dst)
40: #define Dbl_or_signs( src1dst, src2) \
41: Dallp1(src1dst) = (Dallp1(src2)&(1<<31)) | Dallp1(src1dst)
42:
43: /* The hidden bit is always the low bit of the exponent */
44: #define Dbl_clear_exponent_set_hidden(srcdst) Deposit_dexponent(srcdst,1)
45: #define Dbl_clear_signexponent_set_hidden(srcdst) \
46: Deposit_dsignexponent(srcdst,1)
47: #define Dbl_clear_sign(srcdst) Dallp1(srcdst) &= ~(1<<31)
48: #define Dbl_clear_signexponent(srcdst) \
49: Dallp1(srcdst) &= Dmantissap1((unsigned)-1)
50:
51: /* Exponent field for doubles has already been cleared and may be
52: * included in the shift. Here we need to generate two double width
53: * variable shifts. The insignificant bits can be ignored.
54: * MTSAR f(varamount)
55: * VSHD srcdst.high,srcdst.low => srcdst.low
56: * VSHD 0,srcdst.high => srcdst.high
57: * This is very difficult to model with C expressions since the shift amount
58: * could exceed 32. */
59: /* varamount must be less than 64 */
60: #define Dbl_rightshift(srcdstA, srcdstB, varamount) \
61: {if((varamount) >= 32) { \
62: Dallp2(srcdstB) = Dallp1(srcdstA) >> (varamount-32); \
63: Dallp1(srcdstA)=0; \
64: } \
65: else if(varamount > 0) { \
66: Variable_shift_double(Dallp1(srcdstA), Dallp2(srcdstB), \
67: (varamount), Dallp2(srcdstB)); \
68: Dallp1(srcdstA) >>= varamount; \
69: } }
70: /* varamount must be less than 64 */
71: #define Dbl_rightshift_exponentmantissa(srcdstA, srcdstB, varamount) \
72: {if((varamount) >= 32) { \
73: Dallp2(srcdstB) = Dexponentmantissap1(srcdstA) >> ((varamount)-32); \
74: Dallp1(srcdstA) &= (1<<31); /* clear exponentmantissa field */ \
75: } \
76: else if(varamount > 0) { \
77: Variable_shift_double(Dexponentmantissap1(srcdstA), Dallp2(srcdstB), \
78: (varamount), Dallp2(srcdstB)); \
79: Deposit_dexponentmantissap1(srcdstA, \
80: (Dexponentmantissap1(srcdstA)>>(varamount))); \
81: } }
82: /* varamount must be less than 64 */
83: #define Dbl_leftshift(srcdstA, srcdstB, varamount) \
84: {if((varamount) >= 32) { \
85: Dallp1(srcdstA) = Dallp2(srcdstB) << (varamount-32); \
86: Dallp2(srcdstB)=0; \
87: } \
88: else { \
89: if ((varamount) > 0) { \
90: Dallp1(srcdstA) = (Dallp1(srcdstA) << (varamount)) | \
91: (Dallp2(srcdstB) >> (32-(varamount))); \
92: Dallp2(srcdstB) <<= varamount; \
93: } \
94: } }
95: #define Dbl_leftshiftby1_withextent(lefta,leftb,right,resulta,resultb) \
96: Shiftdouble(Dallp1(lefta), Dallp2(leftb), 31, Dallp1(resulta)); \
97: Shiftdouble(Dallp2(leftb), Extall(right), 31, Dallp2(resultb))
98:
99: #define Dbl_rightshiftby1_withextent(leftb,right,dst) \
100: Extall(dst) = (Dallp2(leftb) << 31) | ((unsigned)Extall(right) >> 1) | \
101: Extlow(right)
102:
103: #define Dbl_arithrightshiftby1(srcdstA,srcdstB) \
104: Shiftdouble(Dallp1(srcdstA),Dallp2(srcdstB),1,Dallp2(srcdstB));\
105: Dallp1(srcdstA) = (int)Dallp1(srcdstA) >> 1
106:
107: /* Sign extend the sign bit with an integer destination */
108: #define Dbl_signextendedsign(value) Dsignedsign(value)
109:
110: #define Dbl_isone_hidden(dbl_value) (Is_dhidden(dbl_value)!=0)
111: /* Singles and doubles may include the sign and exponent fields. The
112: * hidden bit and the hidden overflow must be included. */
113: #define Dbl_increment(dbl_valueA,dbl_valueB) \
114: if( (Dallp2(dbl_valueB) += 1) == 0 ) Dallp1(dbl_valueA) += 1
115: #define Dbl_increment_mantissa(dbl_valueA,dbl_valueB) \
116: if( (Dmantissap2(dbl_valueB) += 1) == 0 ) \
117: Deposit_dmantissap1(dbl_valueA,dbl_valueA+1)
118: #define Dbl_decrement(dbl_valueA,dbl_valueB) \
119: if( Dallp2(dbl_valueB) == 0 ) Dallp1(dbl_valueA) -= 1; \
120: Dallp2(dbl_valueB) -= 1
121:
122: #define Dbl_isone_sign(dbl_value) (Is_dsign(dbl_value)!=0)
123: #define Dbl_isone_hiddenoverflow(dbl_value) (Is_dhiddenoverflow(dbl_value)!=0)
124: #define Dbl_isone_lowmantissap1(dbl_valueA) (Is_dlowp1(dbl_valueA)!=0)
125: #define Dbl_isone_lowmantissap2(dbl_valueB) (Is_dlowp2(dbl_valueB)!=0)
126: #define Dbl_isone_signaling(dbl_value) (Is_dsignaling(dbl_value)!=0)
127: #define Dbl_is_signalingnan(dbl_value) (Dsignalingnan(dbl_value)==0xfff)
128: #define Dbl_isnotzero(dbl_valueA,dbl_valueB) \
129: (Dallp1(dbl_valueA) || Dallp2(dbl_valueB))
130: #define Dbl_isnotzero_hiddenhigh7mantissa(dbl_value) \
131: (Dhiddenhigh7mantissa(dbl_value)!=0)
132: #define Dbl_isnotzero_exponent(dbl_value) (Dexponent(dbl_value)!=0)
133: #define Dbl_isnotzero_mantissa(dbl_valueA,dbl_valueB) \
134: (Dmantissap1(dbl_valueA) || Dmantissap2(dbl_valueB))
135: #define Dbl_isnotzero_mantissap1(dbl_valueA) (Dmantissap1(dbl_valueA)!=0)
136: #define Dbl_isnotzero_mantissap2(dbl_valueB) (Dmantissap2(dbl_valueB)!=0)
137: #define Dbl_isnotzero_exponentmantissa(dbl_valueA,dbl_valueB) \
138: (Dexponentmantissap1(dbl_valueA) || Dmantissap2(dbl_valueB))
139: #define Dbl_isnotzero_low4p2(dbl_value) (Dlow4p2(dbl_value)!=0)
140: #define Dbl_iszero(dbl_valueA,dbl_valueB) (Dallp1(dbl_valueA)==0 && \
141: Dallp2(dbl_valueB)==0)
142: #define Dbl_iszero_allp1(dbl_value) (Dallp1(dbl_value)==0)
143: #define Dbl_iszero_allp2(dbl_value) (Dallp2(dbl_value)==0)
144: #define Dbl_iszero_hidden(dbl_value) (Is_dhidden(dbl_value)==0)
145: #define Dbl_iszero_hiddenoverflow(dbl_value) (Is_dhiddenoverflow(dbl_value)==0)
146: #define Dbl_iszero_hiddenhigh3mantissa(dbl_value) \
147: (Dhiddenhigh3mantissa(dbl_value)==0)
148: #define Dbl_iszero_hiddenhigh7mantissa(dbl_value) \
149: (Dhiddenhigh7mantissa(dbl_value)==0)
150: #define Dbl_iszero_sign(dbl_value) (Is_dsign(dbl_value)==0)
151: #define Dbl_iszero_exponent(dbl_value) (Dexponent(dbl_value)==0)
152: #define Dbl_iszero_mantissa(dbl_valueA,dbl_valueB) \
153: (Dmantissap1(dbl_valueA)==0 && Dmantissap2(dbl_valueB)==0)
154: #define Dbl_iszero_exponentmantissa(dbl_valueA,dbl_valueB) \
155: (Dexponentmantissap1(dbl_valueA)==0 && Dmantissap2(dbl_valueB)==0)
156: #define Dbl_isinfinity_exponent(dbl_value) \
157: (Dexponent(dbl_value)==DBL_INFINITY_EXPONENT)
158: #define Dbl_isnotinfinity_exponent(dbl_value) \
159: (Dexponent(dbl_value)!=DBL_INFINITY_EXPONENT)
160: #define Dbl_isinfinity(dbl_valueA,dbl_valueB) \
161: (Dexponent(dbl_valueA)==DBL_INFINITY_EXPONENT && \
162: Dmantissap1(dbl_valueA)==0 && Dmantissap2(dbl_valueB)==0)
163: #define Dbl_isnan(dbl_valueA,dbl_valueB) \
164: (Dexponent(dbl_valueA)==DBL_INFINITY_EXPONENT && \
165: (Dmantissap1(dbl_valueA)!=0 || Dmantissap2(dbl_valueB)!=0))
166: #define Dbl_isnotnan(dbl_valueA,dbl_valueB) \
167: (Dexponent(dbl_valueA)!=DBL_INFINITY_EXPONENT || \
168: (Dmantissap1(dbl_valueA)==0 && Dmantissap2(dbl_valueB)==0))
169:
170: #define Dbl_islessthan(dbl_op1a,dbl_op1b,dbl_op2a,dbl_op2b) \
171: (Dallp1(dbl_op1a) < Dallp1(dbl_op2a) || \
172: (Dallp1(dbl_op1a) == Dallp1(dbl_op2a) && \
173: Dallp2(dbl_op1b) < Dallp2(dbl_op2b)))
174: #define Dbl_isgreaterthan(dbl_op1a,dbl_op1b,dbl_op2a,dbl_op2b) \
175: (Dallp1(dbl_op1a) > Dallp1(dbl_op2a) || \
176: (Dallp1(dbl_op1a) == Dallp1(dbl_op2a) && \
177: Dallp2(dbl_op1b) > Dallp2(dbl_op2b)))
178: #define Dbl_isnotlessthan(dbl_op1a,dbl_op1b,dbl_op2a,dbl_op2b) \
179: (Dallp1(dbl_op1a) > Dallp1(dbl_op2a) || \
180: (Dallp1(dbl_op1a) == Dallp1(dbl_op2a) && \
181: Dallp2(dbl_op1b) >= Dallp2(dbl_op2b)))
182: #define Dbl_isnotgreaterthan(dbl_op1a,dbl_op1b,dbl_op2a,dbl_op2b) \
183: (Dallp1(dbl_op1a) < Dallp1(dbl_op2a) || \
184: (Dallp1(dbl_op1a) == Dallp1(dbl_op2a) && \
185: Dallp2(dbl_op1b) <= Dallp2(dbl_op2b)))
186: #define Dbl_isequal(dbl_op1a,dbl_op1b,dbl_op2a,dbl_op2b) \
187: ((Dallp1(dbl_op1a) == Dallp1(dbl_op2a)) && \
188: (Dallp2(dbl_op1b) == Dallp2(dbl_op2b)))
189:
190: #define Dbl_leftshiftby8(dbl_valueA,dbl_valueB) \
191: Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),24,Dallp1(dbl_valueA)); \
192: Dallp2(dbl_valueB) <<= 8
193: #define Dbl_leftshiftby7(dbl_valueA,dbl_valueB) \
194: Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),25,Dallp1(dbl_valueA)); \
195: Dallp2(dbl_valueB) <<= 7
196: #define Dbl_leftshiftby4(dbl_valueA,dbl_valueB) \
197: Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),28,Dallp1(dbl_valueA)); \
198: Dallp2(dbl_valueB) <<= 4
199: #define Dbl_leftshiftby3(dbl_valueA,dbl_valueB) \
200: Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),29,Dallp1(dbl_valueA)); \
201: Dallp2(dbl_valueB) <<= 3
202: #define Dbl_leftshiftby2(dbl_valueA,dbl_valueB) \
203: Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),30,Dallp1(dbl_valueA)); \
204: Dallp2(dbl_valueB) <<= 2
205: #define Dbl_leftshiftby1(dbl_valueA,dbl_valueB) \
206: Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),31,Dallp1(dbl_valueA)); \
207: Dallp2(dbl_valueB) <<= 1
208:
209: #define Dbl_rightshiftby8(dbl_valueA,dbl_valueB) \
210: Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),8,Dallp2(dbl_valueB)); \
211: Dallp1(dbl_valueA) >>= 8
212: #define Dbl_rightshiftby4(dbl_valueA,dbl_valueB) \
213: Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),4,Dallp2(dbl_valueB)); \
214: Dallp1(dbl_valueA) >>= 4
215: #define Dbl_rightshiftby2(dbl_valueA,dbl_valueB) \
216: Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),2,Dallp2(dbl_valueB)); \
217: Dallp1(dbl_valueA) >>= 2
218: #define Dbl_rightshiftby1(dbl_valueA,dbl_valueB) \
219: Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),1,Dallp2(dbl_valueB)); \
220: Dallp1(dbl_valueA) >>= 1
221:
222: /* This magnitude comparison uses the signless first words and
223: * the regular part2 words. The comparison is graphically:
224: *
225: * 1st greater? -------------
226: * |
227: * 1st less?-----------------+---------
228: * | |
229: * 2nd greater or equal----->| |
230: * False True
231: */
232: #define Dbl_ismagnitudeless(leftB,rightB,signlessleft,signlessright) \
233: ((signlessleft <= signlessright) && \
234: ( (signlessleft < signlessright) || (Dallp2(leftB)<Dallp2(rightB)) ))
235:
236: #define Dbl_copytoint_exponentmantissap1(src,dest) \
237: dest = Dexponentmantissap1(src)
238:
239: /* A quiet NaN has the high mantissa bit clear and at least on other (in this
240: * case the adjacent bit) bit set. */
241: #define Dbl_set_quiet(dbl_value) Deposit_dhigh2mantissa(dbl_value,1)
242: #define Dbl_set_exponent(dbl_value, exp) Deposit_dexponent(dbl_value,exp)
243:
244: #define Dbl_set_mantissa(desta,destb,valuea,valueb) \
245: Deposit_dmantissap1(desta,valuea); \
246: Dmantissap2(destb) = Dmantissap2(valueb)
247: #define Dbl_set_mantissap1(desta,valuea) \
248: Deposit_dmantissap1(desta,valuea)
249: #define Dbl_set_mantissap2(destb,valueb) \
250: Dmantissap2(destb) = Dmantissap2(valueb)
251:
252: #define Dbl_set_exponentmantissa(desta,destb,valuea,valueb) \
253: Deposit_dexponentmantissap1(desta,valuea); \
254: Dmantissap2(destb) = Dmantissap2(valueb)
255: #define Dbl_set_exponentmantissap1(dest,value) \
256: Deposit_dexponentmantissap1(dest,value)
257:
258: #define Dbl_copyfromptr(src,desta,destb) \
259: Dallp1(desta) = src->wd0; \
260: Dallp2(destb) = src->wd1
261: #define Dbl_copytoptr(srca,srcb,dest) \
262: dest->wd0 = Dallp1(srca); \
263: dest->wd1 = Dallp2(srcb)
264:
265: /* An infinity is represented with the max exponent and a zero mantissa */
266: #define Dbl_setinfinity_exponent(dbl_value) \
267: Deposit_dexponent(dbl_value,DBL_INFINITY_EXPONENT)
268: #define Dbl_setinfinity_exponentmantissa(dbl_valueA,dbl_valueB) \
269: Deposit_dexponentmantissap1(dbl_valueA, \
270: (DBL_INFINITY_EXPONENT << (32-(1+DBL_EXP_LENGTH)))); \
271: Dmantissap2(dbl_valueB) = 0
272: #define Dbl_setinfinitypositive(dbl_valueA,dbl_valueB) \
273: Dallp1(dbl_valueA) \
274: = (DBL_INFINITY_EXPONENT << (32-(1+DBL_EXP_LENGTH))); \
275: Dmantissap2(dbl_valueB) = 0
276: #define Dbl_setinfinitynegative(dbl_valueA,dbl_valueB) \
277: Dallp1(dbl_valueA) = (1<<31) | \
278: (DBL_INFINITY_EXPONENT << (32-(1+DBL_EXP_LENGTH))); \
279: Dmantissap2(dbl_valueB) = 0
280: #define Dbl_setinfinity(dbl_valueA,dbl_valueB,sign) \
281: Dallp1(dbl_valueA) = (sign << 31) | \
282: (DBL_INFINITY_EXPONENT << (32-(1+DBL_EXP_LENGTH))); \
283: Dmantissap2(dbl_valueB) = 0
284:
285: #define Dbl_sethigh4bits(dbl_value, extsign) Deposit_dhigh4p1(dbl_value,extsign)
286: #define Dbl_set_sign(dbl_value,sign) Deposit_dsign(dbl_value,sign)
287: #define Dbl_invert_sign(dbl_value) Deposit_dsign(dbl_value,~Dsign(dbl_value))
288: #define Dbl_setone_sign(dbl_value) Deposit_dsign(dbl_value,1)
289: #define Dbl_setone_lowmantissap2(dbl_value) Deposit_dlowp2(dbl_value,1)
290: #define Dbl_setzero_sign(dbl_value) Dallp1(dbl_value) &= 0x7fffffff
291: #define Dbl_setzero_exponent(dbl_value) \
292: Dallp1(dbl_value) &= 0x800fffff
293: #define Dbl_setzero_mantissa(dbl_valueA,dbl_valueB) \
294: Dallp1(dbl_valueA) &= 0xfff00000; \
295: Dallp2(dbl_valueB) = 0
296: #define Dbl_setzero_mantissap1(dbl_value) Dallp1(dbl_value) &= 0xfff00000
297: #define Dbl_setzero_mantissap2(dbl_value) Dallp2(dbl_value) = 0
298: #define Dbl_setzero_exponentmantissa(dbl_valueA,dbl_valueB) \
299: Dallp1(dbl_valueA) &= 0x80000000; \
300: Dallp2(dbl_valueB) = 0
301: #define Dbl_setzero_exponentmantissap1(dbl_valueA) \
302: Dallp1(dbl_valueA) &= 0x80000000
303: #define Dbl_setzero(dbl_valueA,dbl_valueB) \
304: Dallp1(dbl_valueA) = 0; Dallp2(dbl_valueB) = 0
305: #define Dbl_setzerop1(dbl_value) Dallp1(dbl_value) = 0
306: #define Dbl_setzerop2(dbl_value) Dallp2(dbl_value) = 0
307: #define Dbl_setnegativezero(dbl_value) \
308: Dallp1(dbl_value) = 1 << 31; Dallp2(dbl_value) = 0
309: #define Dbl_setnegativezerop1(dbl_value) Dallp1(dbl_value) = 1 << 31
310:
311: /* Use the following macro for both overflow & underflow conditions */
312: #define ovfl -
313: #define unfl +
314: #define Dbl_setwrapped_exponent(dbl_value,exponent,op) \
315: Deposit_dexponent(dbl_value,(exponent op DBL_WRAP))
316:
317: #define Dbl_setlargestpositive(dbl_valueA,dbl_valueB) \
318: Dallp1(dbl_valueA) = ((DBL_EMAX+DBL_BIAS) << (32-(1+DBL_EXP_LENGTH))) \
319: | ((1<<(32-(1+DBL_EXP_LENGTH))) - 1 ); \
320: Dallp2(dbl_valueB) = 0xFFFFFFFF
321: #define Dbl_setlargestnegative(dbl_valueA,dbl_valueB) \
322: Dallp1(dbl_valueA) = ((DBL_EMAX+DBL_BIAS) << (32-(1+DBL_EXP_LENGTH))) \
323: | ((1<<(32-(1+DBL_EXP_LENGTH))) - 1 ) | (1<<31); \
324: Dallp2(dbl_valueB) = 0xFFFFFFFF
325: #define Dbl_setlargest_exponentmantissa(dbl_valueA,dbl_valueB) \
326: Deposit_dexponentmantissap1(dbl_valueA, \
327: (((DBL_EMAX+DBL_BIAS) << (32-(1+DBL_EXP_LENGTH))) \
328: | ((1<<(32-(1+DBL_EXP_LENGTH))) - 1 ))); \
329: Dallp2(dbl_valueB) = 0xFFFFFFFF
330:
331: #define Dbl_setnegativeinfinity(dbl_valueA,dbl_valueB) \
332: Dallp1(dbl_valueA) = ((1<<DBL_EXP_LENGTH) | DBL_INFINITY_EXPONENT) \
333: << (32-(1+DBL_EXP_LENGTH)) ; \
334: Dallp2(dbl_valueB) = 0
335: #define Dbl_setlargest(dbl_valueA,dbl_valueB,sign) \
336: Dallp1(dbl_valueA) = (sign << 31) | \
337: ((DBL_EMAX+DBL_BIAS) << (32-(1+DBL_EXP_LENGTH))) | \
338: ((1 << (32-(1+DBL_EXP_LENGTH))) - 1 ); \
339: Dallp2(dbl_valueB) = 0xFFFFFFFF
340:
341:
342: /* The high bit is always zero so arithmetic or logical shifts will work. */
343: #define Dbl_right_align(srcdstA,srcdstB,shift,extent) \
344: if( shift >= 32 ) \
345: { \
346: /* Big shift requires examining the portion shift off \
347: the end to properly set inexact. */ \
348: if(shift < 64) \
349: { \
350: if(shift > 32) \
351: { \
352: Variable_shift_double(Dallp1(srcdstA),Dallp2(srcdstB), \
353: shift-32, Extall(extent)); \
354: if(Dallp2(srcdstB) << (64 - (shift))) Ext_setone_low(extent); \
355: } \
356: else Extall(extent) = Dallp2(srcdstB); \
357: Dallp2(srcdstB) = Dallp1(srcdstA) >> (shift - 32); \
358: } \
359: else \
360: { \
361: Extall(extent) = Dallp1(srcdstA); \
362: if(Dallp2(srcdstB)) Ext_setone_low(extent); \
363: Dallp2(srcdstB) = 0; \
364: } \
365: Dallp1(srcdstA) = 0; \
366: } \
367: else \
368: { \
369: /* Small alignment is simpler. Extension is easily set. */ \
370: if (shift > 0) \
371: { \
372: Extall(extent) = Dallp2(srcdstB) << (32 - (shift)); \
373: Variable_shift_double(Dallp1(srcdstA),Dallp2(srcdstB),shift, \
374: Dallp2(srcdstB)); \
375: Dallp1(srcdstA) >>= shift; \
376: } \
377: else Extall(extent) = 0; \
378: }
379:
380: /*
381: * Here we need to shift the result right to correct for an overshift
382: * (due to the exponent becoming negative) during normalization.
383: */
384: #define Dbl_fix_overshift(srcdstA,srcdstB,shift,extent) \
385: Extall(extent) = Dallp2(srcdstB) << (32 - (shift)); \
386: Dallp2(srcdstB) = (Dallp1(srcdstA) << (32 - (shift))) | \
387: (Dallp2(srcdstB) >> (shift)); \
388: Dallp1(srcdstA) = Dallp1(srcdstA) >> shift
389:
390: #define Dbl_hiddenhigh3mantissa(dbl_value) Dhiddenhigh3mantissa(dbl_value)
391: #define Dbl_hidden(dbl_value) Dhidden(dbl_value)
392: #define Dbl_lowmantissap2(dbl_value) Dlowp2(dbl_value)
393:
394: /* The left argument is never smaller than the right argument */
395: #define Dbl_subtract(lefta,leftb,righta,rightb,resulta,resultb) \
396: if( Dallp2(rightb) > Dallp2(leftb) ) Dallp1(lefta)--; \
397: Dallp2(resultb) = Dallp2(leftb) - Dallp2(rightb); \
398: Dallp1(resulta) = Dallp1(lefta) - Dallp1(righta)
399:
400: /* Subtract right augmented with extension from left augmented with zeros and
401: * store into result and extension. */
402: #define Dbl_subtract_withextension(lefta,leftb,righta,rightb,extent,resulta,resultb) \
403: Dbl_subtract(lefta,leftb,righta,rightb,resulta,resultb); \
404: if( (Extall(extent) = 0-Extall(extent)) ) \
405: { \
406: if((Dallp2(resultb)--) == 0) Dallp1(resulta)--; \
407: }
408:
409: #define Dbl_addition(lefta,leftb,righta,rightb,resulta,resultb) \
410: /* If the sum of the low words is less than either source, then \
411: * an overflow into the next word occurred. */ \
412: Dallp1(resulta) = Dallp1(lefta) + Dallp1(righta); \
413: if((Dallp2(resultb) = Dallp2(leftb) + Dallp2(rightb)) < Dallp2(rightb)) \
414: Dallp1(resulta)++
415:
416: #define Dbl_xortointp1(left,right,result) \
417: result = Dallp1(left) XOR Dallp1(right)
418:
419: #define Dbl_xorfromintp1(left,right,result) \
420: Dallp1(result) = left XOR Dallp1(right)
421:
422: #define Dbl_swap_lower(left,right) \
423: Dallp2(left) = Dallp2(left) XOR Dallp2(right); \
424: Dallp2(right) = Dallp2(left) XOR Dallp2(right); \
425: Dallp2(left) = Dallp2(left) XOR Dallp2(right)
426:
427: /* Need to Initialize */
428: #define Dbl_makequietnan(desta,destb) \
429: Dallp1(desta) = ((DBL_EMAX+DBL_BIAS)+1)<< (32-(1+DBL_EXP_LENGTH)) \
430: | (1<<(32-(1+DBL_EXP_LENGTH+2))); \
431: Dallp2(destb) = 0
432: #define Dbl_makesignalingnan(desta,destb) \
433: Dallp1(desta) = ((DBL_EMAX+DBL_BIAS)+1)<< (32-(1+DBL_EXP_LENGTH)) \
434: | (1<<(32-(1+DBL_EXP_LENGTH+1))); \
435: Dallp2(destb) = 0
436:
437: #define Dbl_normalize(dbl_opndA,dbl_opndB,exponent) \
438: while(Dbl_iszero_hiddenhigh7mantissa(dbl_opndA)) { \
439: Dbl_leftshiftby8(dbl_opndA,dbl_opndB); \
440: exponent -= 8; \
441: } \
442: if(Dbl_iszero_hiddenhigh3mantissa(dbl_opndA)) { \
443: Dbl_leftshiftby4(dbl_opndA,dbl_opndB); \
444: exponent -= 4; \
445: } \
446: while(Dbl_iszero_hidden(dbl_opndA)) { \
447: Dbl_leftshiftby1(dbl_opndA,dbl_opndB); \
448: exponent -= 1; \
449: }
450:
451: #define Twoword_add(src1dstA,src1dstB,src2A,src2B) \
452: /* \
453: * want this macro to generate: \
454: * ADD src1dstB,src2B,src1dstB; \
455: * ADDC src1dstA,src2A,src1dstA; \
456: */ \
457: if ((src1dstB) + (src2B) < (src1dstB)) Dallp1(src1dstA)++; \
458: Dallp1(src1dstA) += (src2A); \
459: Dallp2(src1dstB) += (src2B)
460:
461: #define Twoword_subtract(src1dstA,src1dstB,src2A,src2B) \
462: /* \
463: * want this macro to generate: \
464: * SUB src1dstB,src2B,src1dstB; \
465: * SUBB src1dstA,src2A,src1dstA; \
466: */ \
467: if ((src1dstB) < (src2B)) Dallp1(src1dstA)--; \
468: Dallp1(src1dstA) -= (src2A); \
469: Dallp2(src1dstB) -= (src2B)
470:
471: #define Dbl_setoverflow(resultA,resultB) \
472: /* set result to infinity or largest number */ \
473: switch (Rounding_mode()) { \
474: case ROUNDPLUS: \
475: if (Dbl_isone_sign(resultA)) { \
476: Dbl_setlargestnegative(resultA,resultB); \
477: } \
478: else { \
479: Dbl_setinfinitypositive(resultA,resultB); \
480: } \
481: break; \
482: case ROUNDMINUS: \
483: if (Dbl_iszero_sign(resultA)) { \
484: Dbl_setlargestpositive(resultA,resultB); \
485: } \
486: else { \
487: Dbl_setinfinitynegative(resultA,resultB); \
488: } \
489: break; \
490: case ROUNDNEAREST: \
491: Dbl_setinfinity_exponentmantissa(resultA,resultB); \
492: break; \
493: case ROUNDZERO: \
494: Dbl_setlargest_exponentmantissa(resultA,resultB); \
495: }
496:
497: #define Dbl_denormalize(opndp1,opndp2,exponent,guard,sticky,inexact) \
498: Dbl_clear_signexponent_set_hidden(opndp1); \
499: if (exponent >= (1-DBL_P)) { \
500: if (exponent >= -31) { \
501: guard = (Dallp2(opndp2) >> (-(exponent))) & 1; \
502: if (exponent < 0) sticky |= Dallp2(opndp2) << (32+exponent); \
503: if (exponent > -31) { \
504: Variable_shift_double(opndp1,opndp2,1-exponent,opndp2); \
505: Dallp1(opndp1) >>= 1-exponent; \
506: } \
507: else { \
508: Dallp2(opndp2) = Dallp1(opndp1); \
509: Dbl_setzerop1(opndp1); \
510: } \
511: } \
512: else { \
513: guard = (Dallp1(opndp1) >> (-32-(exponent))) & 1; \
514: if (exponent == -32) sticky |= Dallp2(opndp2); \
515: else sticky |= (Dallp2(opndp2) | Dallp1(opndp1) << (64+(exponent))); \
516: Dallp2(opndp2) = Dallp1(opndp1) >> (-31-(exponent)); \
517: Dbl_setzerop1(opndp1); \
518: } \
519: inexact = guard | sticky; \
520: } \
521: else { \
522: guard = 0; \
523: sticky |= (Dallp1(opndp1) | Dallp2(opndp2)); \
524: Dbl_setzero(opndp1,opndp2); \
525: inexact = sticky; \
526: }
527:
528:
529: int dbl_fadd(dbl_floating_point *, dbl_floating_point *, dbl_floating_point *, unsigned int *);
530: int dbl_fcmp(dbl_floating_point *, dbl_floating_point *, unsigned int, unsigned int *);
531: int dbl_fdiv(dbl_floating_point *, dbl_floating_point *, dbl_floating_point *, unsigned int *);
532: int dbl_fmpy(dbl_floating_point *, dbl_floating_point *, dbl_floating_point *, unsigned int *);
533: int dbl_frem(dbl_floating_point *, dbl_floating_point *, dbl_floating_point *, unsigned int *);
534: int dbl_fsqrt(dbl_floating_point *, dbl_floating_point *, dbl_floating_point *, unsigned int *);
535: int dbl_fsub(dbl_floating_point *, dbl_floating_point *, dbl_floating_point *, unsigned int *);
536:
537: int sgl_to_dbl_fcnvff(sgl_floating_point *, sgl_floating_point *, dbl_floating_point *, unsigned int *);
538: int dbl_to_sgl_fcnvff(dbl_floating_point *, dbl_floating_point *, sgl_floating_point *, unsigned int *);
539:
540: int dbl_frnd(dbl_floating_point *, dbl_floating_point *, dbl_floating_point *, unsigned int *);
CVSweb