dbl_float.h (36084B)
1/* SPDX-License-Identifier: GPL-2.0-or-later */ 2/* 3 * Linux/PA-RISC Project (http://www.parisc-linux.org/) 4 * 5 * Floating-point emulation code 6 * Copyright (C) 2001 Hewlett-Packard (Paul Bame) <bame@debian.org> 7 */ 8#ifdef __NO_PA_HDRS 9 PA header file -- do not include this header file for non-PA builds. 10#endif 11 12/* 32-bit word grabbing functions */ 13#define Dbl_firstword(value) Dallp1(value) 14#define Dbl_secondword(value) Dallp2(value) 15#define Dbl_thirdword(value) dummy_location 16#define Dbl_fourthword(value) dummy_location 17 18#define Dbl_sign(object) Dsign(object) 19#define Dbl_exponent(object) Dexponent(object) 20#define Dbl_signexponent(object) Dsignexponent(object) 21#define Dbl_mantissap1(object) Dmantissap1(object) 22#define Dbl_mantissap2(object) Dmantissap2(object) 23#define Dbl_exponentmantissap1(object) Dexponentmantissap1(object) 24#define Dbl_allp1(object) Dallp1(object) 25#define Dbl_allp2(object) Dallp2(object) 26 27/* dbl_and_signs ANDs the sign bits of each argument and puts the result 28 * into the first argument. dbl_or_signs ors those same sign bits */ 29#define Dbl_and_signs( src1dst, src2) \ 30 Dallp1(src1dst) = (Dallp1(src2)|~((unsigned int)1<<31)) & Dallp1(src1dst) 31#define Dbl_or_signs( src1dst, src2) \ 32 Dallp1(src1dst) = (Dallp1(src2)&((unsigned int)1<<31)) | Dallp1(src1dst) 33 34/* The hidden bit is always the low bit of the exponent */ 35#define Dbl_clear_exponent_set_hidden(srcdst) Deposit_dexponent(srcdst,1) 36#define Dbl_clear_signexponent_set_hidden(srcdst) \ 37 Deposit_dsignexponent(srcdst,1) 38#define Dbl_clear_sign(srcdst) Dallp1(srcdst) &= ~((unsigned int)1<<31) 39#define Dbl_clear_signexponent(srcdst) \ 40 Dallp1(srcdst) &= Dmantissap1((unsigned int)-1) 41 42/* Exponent field for doubles has already been cleared and may be 43 * included in the shift. Here we need to generate two double width 44 * variable shifts. The insignificant bits can be ignored. 45 * MTSAR f(varamount) 46 * VSHD srcdst.high,srcdst.low => srcdst.low 47 * VSHD 0,srcdst.high => srcdst.high 48 * This is very difficult to model with C expressions since the shift amount 49 * could exceed 32. */ 50/* varamount must be less than 64 */ 51#define Dbl_rightshift(srcdstA, srcdstB, varamount) \ 52 {if((varamount) >= 32) { \ 53 Dallp2(srcdstB) = Dallp1(srcdstA) >> (varamount-32); \ 54 Dallp1(srcdstA)=0; \ 55 } \ 56 else if(varamount > 0) { \ 57 Variable_shift_double(Dallp1(srcdstA), Dallp2(srcdstB), \ 58 (varamount), Dallp2(srcdstB)); \ 59 Dallp1(srcdstA) >>= varamount; \ 60 } } 61/* varamount must be less than 64 */ 62#define Dbl_rightshift_exponentmantissa(srcdstA, srcdstB, varamount) \ 63 {if((varamount) >= 32) { \ 64 Dallp2(srcdstB) = Dexponentmantissap1(srcdstA) >> (varamount-32); \ 65 Dallp1(srcdstA) &= ((unsigned int)1<<31); /* clear expmant field */ \ 66 } \ 67 else if(varamount > 0) { \ 68 Variable_shift_double(Dexponentmantissap1(srcdstA), Dallp2(srcdstB), \ 69 (varamount), Dallp2(srcdstB)); \ 70 Deposit_dexponentmantissap1(srcdstA, \ 71 (Dexponentmantissap1(srcdstA)>>varamount)); \ 72 } } 73/* varamount must be less than 64 */ 74#define Dbl_leftshift(srcdstA, srcdstB, varamount) \ 75 {if((varamount) >= 32) { \ 76 Dallp1(srcdstA) = Dallp2(srcdstB) << (varamount-32); \ 77 Dallp2(srcdstB)=0; \ 78 } \ 79 else { \ 80 if ((varamount) > 0) { \ 81 Dallp1(srcdstA) = (Dallp1(srcdstA) << (varamount)) | \ 82 (Dallp2(srcdstB) >> (32-(varamount))); \ 83 Dallp2(srcdstB) <<= varamount; \ 84 } \ 85 } } 86#define Dbl_leftshiftby1_withextent(lefta,leftb,right,resulta,resultb) \ 87 Shiftdouble(Dallp1(lefta), Dallp2(leftb), 31, Dallp1(resulta)); \ 88 Shiftdouble(Dallp2(leftb), Extall(right), 31, Dallp2(resultb)) 89 90#define Dbl_rightshiftby1_withextent(leftb,right,dst) \ 91 Extall(dst) = (Dallp2(leftb) << 31) | ((unsigned int)Extall(right) >> 1) | \ 92 Extlow(right) 93 94#define Dbl_arithrightshiftby1(srcdstA,srcdstB) \ 95 Shiftdouble(Dallp1(srcdstA),Dallp2(srcdstB),1,Dallp2(srcdstB));\ 96 Dallp1(srcdstA) = (int)Dallp1(srcdstA) >> 1 97 98/* Sign extend the sign bit with an integer destination */ 99#define Dbl_signextendedsign(value) Dsignedsign(value) 100 101#define Dbl_isone_hidden(dbl_value) (Is_dhidden(dbl_value)!=0) 102/* Singles and doubles may include the sign and exponent fields. The 103 * hidden bit and the hidden overflow must be included. */ 104#define Dbl_increment(dbl_valueA,dbl_valueB) \ 105 if( (Dallp2(dbl_valueB) += 1) == 0 ) Dallp1(dbl_valueA) += 1 106#define Dbl_increment_mantissa(dbl_valueA,dbl_valueB) \ 107 if( (Dmantissap2(dbl_valueB) += 1) == 0 ) \ 108 Deposit_dmantissap1(dbl_valueA,dbl_valueA+1) 109#define Dbl_decrement(dbl_valueA,dbl_valueB) \ 110 if( Dallp2(dbl_valueB) == 0 ) Dallp1(dbl_valueA) -= 1; \ 111 Dallp2(dbl_valueB) -= 1 112 113#define Dbl_isone_sign(dbl_value) (Is_dsign(dbl_value)!=0) 114#define Dbl_isone_hiddenoverflow(dbl_value) (Is_dhiddenoverflow(dbl_value)!=0) 115#define Dbl_isone_lowmantissap1(dbl_valueA) (Is_dlowp1(dbl_valueA)!=0) 116#define Dbl_isone_lowmantissap2(dbl_valueB) (Is_dlowp2(dbl_valueB)!=0) 117#define Dbl_isone_signaling(dbl_value) (Is_dsignaling(dbl_value)!=0) 118#define Dbl_is_signalingnan(dbl_value) (Dsignalingnan(dbl_value)==0xfff) 119#define Dbl_isnotzero(dbl_valueA,dbl_valueB) \ 120 (Dallp1(dbl_valueA) || Dallp2(dbl_valueB)) 121#define Dbl_isnotzero_hiddenhigh7mantissa(dbl_value) \ 122 (Dhiddenhigh7mantissa(dbl_value)!=0) 123#define Dbl_isnotzero_exponent(dbl_value) (Dexponent(dbl_value)!=0) 124#define Dbl_isnotzero_mantissa(dbl_valueA,dbl_valueB) \ 125 (Dmantissap1(dbl_valueA) || Dmantissap2(dbl_valueB)) 126#define Dbl_isnotzero_mantissap1(dbl_valueA) (Dmantissap1(dbl_valueA)!=0) 127#define Dbl_isnotzero_mantissap2(dbl_valueB) (Dmantissap2(dbl_valueB)!=0) 128#define Dbl_isnotzero_exponentmantissa(dbl_valueA,dbl_valueB) \ 129 (Dexponentmantissap1(dbl_valueA) || Dmantissap2(dbl_valueB)) 130#define Dbl_isnotzero_low4p2(dbl_value) (Dlow4p2(dbl_value)!=0) 131#define Dbl_iszero(dbl_valueA,dbl_valueB) (Dallp1(dbl_valueA)==0 && \ 132 Dallp2(dbl_valueB)==0) 133#define Dbl_iszero_allp1(dbl_value) (Dallp1(dbl_value)==0) 134#define Dbl_iszero_allp2(dbl_value) (Dallp2(dbl_value)==0) 135#define Dbl_iszero_hidden(dbl_value) (Is_dhidden(dbl_value)==0) 136#define Dbl_iszero_hiddenoverflow(dbl_value) (Is_dhiddenoverflow(dbl_value)==0) 137#define Dbl_iszero_hiddenhigh3mantissa(dbl_value) \ 138 (Dhiddenhigh3mantissa(dbl_value)==0) 139#define Dbl_iszero_hiddenhigh7mantissa(dbl_value) \ 140 (Dhiddenhigh7mantissa(dbl_value)==0) 141#define Dbl_iszero_sign(dbl_value) (Is_dsign(dbl_value)==0) 142#define Dbl_iszero_exponent(dbl_value) (Dexponent(dbl_value)==0) 143#define Dbl_iszero_mantissa(dbl_valueA,dbl_valueB) \ 144 (Dmantissap1(dbl_valueA)==0 && Dmantissap2(dbl_valueB)==0) 145#define Dbl_iszero_exponentmantissa(dbl_valueA,dbl_valueB) \ 146 (Dexponentmantissap1(dbl_valueA)==0 && Dmantissap2(dbl_valueB)==0) 147#define Dbl_isinfinity_exponent(dbl_value) \ 148 (Dexponent(dbl_value)==DBL_INFINITY_EXPONENT) 149#define Dbl_isnotinfinity_exponent(dbl_value) \ 150 (Dexponent(dbl_value)!=DBL_INFINITY_EXPONENT) 151#define Dbl_isinfinity(dbl_valueA,dbl_valueB) \ 152 (Dexponent(dbl_valueA)==DBL_INFINITY_EXPONENT && \ 153 Dmantissap1(dbl_valueA)==0 && Dmantissap2(dbl_valueB)==0) 154#define Dbl_isnan(dbl_valueA,dbl_valueB) \ 155 (Dexponent(dbl_valueA)==DBL_INFINITY_EXPONENT && \ 156 (Dmantissap1(dbl_valueA)!=0 || Dmantissap2(dbl_valueB)!=0)) 157#define Dbl_isnotnan(dbl_valueA,dbl_valueB) \ 158 (Dexponent(dbl_valueA)!=DBL_INFINITY_EXPONENT || \ 159 (Dmantissap1(dbl_valueA)==0 && Dmantissap2(dbl_valueB)==0)) 160 161#define Dbl_islessthan(dbl_op1a,dbl_op1b,dbl_op2a,dbl_op2b) \ 162 (Dallp1(dbl_op1a) < Dallp1(dbl_op2a) || \ 163 (Dallp1(dbl_op1a) == Dallp1(dbl_op2a) && \ 164 Dallp2(dbl_op1b) < Dallp2(dbl_op2b))) 165#define Dbl_isgreaterthan(dbl_op1a,dbl_op1b,dbl_op2a,dbl_op2b) \ 166 (Dallp1(dbl_op1a) > Dallp1(dbl_op2a) || \ 167 (Dallp1(dbl_op1a) == Dallp1(dbl_op2a) && \ 168 Dallp2(dbl_op1b) > Dallp2(dbl_op2b))) 169#define Dbl_isnotlessthan(dbl_op1a,dbl_op1b,dbl_op2a,dbl_op2b) \ 170 (Dallp1(dbl_op1a) > Dallp1(dbl_op2a) || \ 171 (Dallp1(dbl_op1a) == Dallp1(dbl_op2a) && \ 172 Dallp2(dbl_op1b) >= Dallp2(dbl_op2b))) 173#define Dbl_isnotgreaterthan(dbl_op1a,dbl_op1b,dbl_op2a,dbl_op2b) \ 174 (Dallp1(dbl_op1a) < Dallp1(dbl_op2a) || \ 175 (Dallp1(dbl_op1a) == Dallp1(dbl_op2a) && \ 176 Dallp2(dbl_op1b) <= Dallp2(dbl_op2b))) 177#define Dbl_isequal(dbl_op1a,dbl_op1b,dbl_op2a,dbl_op2b) \ 178 ((Dallp1(dbl_op1a) == Dallp1(dbl_op2a)) && \ 179 (Dallp2(dbl_op1b) == Dallp2(dbl_op2b))) 180 181#define Dbl_leftshiftby8(dbl_valueA,dbl_valueB) \ 182 Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),24,Dallp1(dbl_valueA)); \ 183 Dallp2(dbl_valueB) <<= 8 184#define Dbl_leftshiftby7(dbl_valueA,dbl_valueB) \ 185 Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),25,Dallp1(dbl_valueA)); \ 186 Dallp2(dbl_valueB) <<= 7 187#define Dbl_leftshiftby4(dbl_valueA,dbl_valueB) \ 188 Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),28,Dallp1(dbl_valueA)); \ 189 Dallp2(dbl_valueB) <<= 4 190#define Dbl_leftshiftby3(dbl_valueA,dbl_valueB) \ 191 Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),29,Dallp1(dbl_valueA)); \ 192 Dallp2(dbl_valueB) <<= 3 193#define Dbl_leftshiftby2(dbl_valueA,dbl_valueB) \ 194 Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),30,Dallp1(dbl_valueA)); \ 195 Dallp2(dbl_valueB) <<= 2 196#define Dbl_leftshiftby1(dbl_valueA,dbl_valueB) \ 197 Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),31,Dallp1(dbl_valueA)); \ 198 Dallp2(dbl_valueB) <<= 1 199 200#define Dbl_rightshiftby8(dbl_valueA,dbl_valueB) \ 201 Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),8,Dallp2(dbl_valueB)); \ 202 Dallp1(dbl_valueA) >>= 8 203#define Dbl_rightshiftby4(dbl_valueA,dbl_valueB) \ 204 Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),4,Dallp2(dbl_valueB)); \ 205 Dallp1(dbl_valueA) >>= 4 206#define Dbl_rightshiftby2(dbl_valueA,dbl_valueB) \ 207 Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),2,Dallp2(dbl_valueB)); \ 208 Dallp1(dbl_valueA) >>= 2 209#define Dbl_rightshiftby1(dbl_valueA,dbl_valueB) \ 210 Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),1,Dallp2(dbl_valueB)); \ 211 Dallp1(dbl_valueA) >>= 1 212 213/* This magnitude comparison uses the signless first words and 214 * the regular part2 words. The comparison is graphically: 215 * 216 * 1st greater? ------------- 217 * | 218 * 1st less?-----------------+--------- 219 * | | 220 * 2nd greater or equal----->| | 221 * False True 222 */ 223#define Dbl_ismagnitudeless(leftB,rightB,signlessleft,signlessright) \ 224 ((signlessleft <= signlessright) && \ 225 ( (signlessleft < signlessright) || (Dallp2(leftB)<Dallp2(rightB)) )) 226 227#define Dbl_copytoint_exponentmantissap1(src,dest) \ 228 dest = Dexponentmantissap1(src) 229 230/* A quiet NaN has the high mantissa bit clear and at least on other (in this 231 * case the adjacent bit) bit set. */ 232#define Dbl_set_quiet(dbl_value) Deposit_dhigh2mantissa(dbl_value,1) 233#define Dbl_set_exponent(dbl_value, exp) Deposit_dexponent(dbl_value,exp) 234 235#define Dbl_set_mantissa(desta,destb,valuea,valueb) \ 236 Deposit_dmantissap1(desta,valuea); \ 237 Dmantissap2(destb) = Dmantissap2(valueb) 238#define Dbl_set_mantissap1(desta,valuea) \ 239 Deposit_dmantissap1(desta,valuea) 240#define Dbl_set_mantissap2(destb,valueb) \ 241 Dmantissap2(destb) = Dmantissap2(valueb) 242 243#define Dbl_set_exponentmantissa(desta,destb,valuea,valueb) \ 244 Deposit_dexponentmantissap1(desta,valuea); \ 245 Dmantissap2(destb) = Dmantissap2(valueb) 246#define Dbl_set_exponentmantissap1(dest,value) \ 247 Deposit_dexponentmantissap1(dest,value) 248 249#define Dbl_copyfromptr(src,desta,destb) \ 250 Dallp1(desta) = src->wd0; \ 251 Dallp2(destb) = src->wd1 252#define Dbl_copytoptr(srca,srcb,dest) \ 253 dest->wd0 = Dallp1(srca); \ 254 dest->wd1 = Dallp2(srcb) 255 256/* An infinity is represented with the max exponent and a zero mantissa */ 257#define Dbl_setinfinity_exponent(dbl_value) \ 258 Deposit_dexponent(dbl_value,DBL_INFINITY_EXPONENT) 259#define Dbl_setinfinity_exponentmantissa(dbl_valueA,dbl_valueB) \ 260 Deposit_dexponentmantissap1(dbl_valueA, \ 261 (DBL_INFINITY_EXPONENT << (32-(1+DBL_EXP_LENGTH)))); \ 262 Dmantissap2(dbl_valueB) = 0 263#define Dbl_setinfinitypositive(dbl_valueA,dbl_valueB) \ 264 Dallp1(dbl_valueA) \ 265 = (DBL_INFINITY_EXPONENT << (32-(1+DBL_EXP_LENGTH))); \ 266 Dmantissap2(dbl_valueB) = 0 267#define Dbl_setinfinitynegative(dbl_valueA,dbl_valueB) \ 268 Dallp1(dbl_valueA) = ((unsigned int)1<<31) | \ 269 (DBL_INFINITY_EXPONENT << (32-(1+DBL_EXP_LENGTH))); \ 270 Dmantissap2(dbl_valueB) = 0 271#define Dbl_setinfinity(dbl_valueA,dbl_valueB,sign) \ 272 Dallp1(dbl_valueA) = ((unsigned int)sign << 31) | \ 273 (DBL_INFINITY_EXPONENT << (32-(1+DBL_EXP_LENGTH))); \ 274 Dmantissap2(dbl_valueB) = 0 275 276#define Dbl_sethigh4bits(dbl_value, extsign) Deposit_dhigh4p1(dbl_value,extsign) 277#define Dbl_set_sign(dbl_value,sign) Deposit_dsign(dbl_value,sign) 278#define Dbl_invert_sign(dbl_value) Deposit_dsign(dbl_value,~Dsign(dbl_value)) 279#define Dbl_setone_sign(dbl_value) Deposit_dsign(dbl_value,1) 280#define Dbl_setone_lowmantissap2(dbl_value) Deposit_dlowp2(dbl_value,1) 281#define Dbl_setzero_sign(dbl_value) Dallp1(dbl_value) &= 0x7fffffff 282#define Dbl_setzero_exponent(dbl_value) \ 283 Dallp1(dbl_value) &= 0x800fffff 284#define Dbl_setzero_mantissa(dbl_valueA,dbl_valueB) \ 285 Dallp1(dbl_valueA) &= 0xfff00000; \ 286 Dallp2(dbl_valueB) = 0 287#define Dbl_setzero_mantissap1(dbl_value) Dallp1(dbl_value) &= 0xfff00000 288#define Dbl_setzero_mantissap2(dbl_value) Dallp2(dbl_value) = 0 289#define Dbl_setzero_exponentmantissa(dbl_valueA,dbl_valueB) \ 290 Dallp1(dbl_valueA) &= 0x80000000; \ 291 Dallp2(dbl_valueB) = 0 292#define Dbl_setzero_exponentmantissap1(dbl_valueA) \ 293 Dallp1(dbl_valueA) &= 0x80000000 294#define Dbl_setzero(dbl_valueA,dbl_valueB) \ 295 Dallp1(dbl_valueA) = 0; Dallp2(dbl_valueB) = 0 296#define Dbl_setzerop1(dbl_value) Dallp1(dbl_value) = 0 297#define Dbl_setzerop2(dbl_value) Dallp2(dbl_value) = 0 298#define Dbl_setnegativezero(dbl_value) \ 299 Dallp1(dbl_value) = (unsigned int)1 << 31; Dallp2(dbl_value) = 0 300#define Dbl_setnegativezerop1(dbl_value) Dallp1(dbl_value) = (unsigned int)1<<31 301 302/* Use the following macro for both overflow & underflow conditions */ 303#define ovfl - 304#define unfl + 305#define Dbl_setwrapped_exponent(dbl_value,exponent,op) \ 306 Deposit_dexponent(dbl_value,(exponent op DBL_WRAP)) 307 308#define Dbl_setlargestpositive(dbl_valueA,dbl_valueB) \ 309 Dallp1(dbl_valueA) = ((DBL_EMAX+DBL_BIAS) << (32-(1+DBL_EXP_LENGTH))) \ 310 | ((1<<(32-(1+DBL_EXP_LENGTH))) - 1 ); \ 311 Dallp2(dbl_valueB) = 0xFFFFFFFF 312#define Dbl_setlargestnegative(dbl_valueA,dbl_valueB) \ 313 Dallp1(dbl_valueA) = ((DBL_EMAX+DBL_BIAS) << (32-(1+DBL_EXP_LENGTH))) \ 314 | ((1<<(32-(1+DBL_EXP_LENGTH))) - 1 ) \ 315 | ((unsigned int)1<<31); \ 316 Dallp2(dbl_valueB) = 0xFFFFFFFF 317#define Dbl_setlargest_exponentmantissa(dbl_valueA,dbl_valueB) \ 318 Deposit_dexponentmantissap1(dbl_valueA, \ 319 (((DBL_EMAX+DBL_BIAS) << (32-(1+DBL_EXP_LENGTH))) \ 320 | ((1<<(32-(1+DBL_EXP_LENGTH))) - 1 ))); \ 321 Dallp2(dbl_valueB) = 0xFFFFFFFF 322 323#define Dbl_setnegativeinfinity(dbl_valueA,dbl_valueB) \ 324 Dallp1(dbl_valueA) = ((1<<DBL_EXP_LENGTH) | DBL_INFINITY_EXPONENT) \ 325 << (32-(1+DBL_EXP_LENGTH)) ; \ 326 Dallp2(dbl_valueB) = 0 327#define Dbl_setlargest(dbl_valueA,dbl_valueB,sign) \ 328 Dallp1(dbl_valueA) = ((unsigned int)sign << 31) | \ 329 ((DBL_EMAX+DBL_BIAS) << (32-(1+DBL_EXP_LENGTH))) | \ 330 ((1 << (32-(1+DBL_EXP_LENGTH))) - 1 ); \ 331 Dallp2(dbl_valueB) = 0xFFFFFFFF 332 333 334/* The high bit is always zero so arithmetic or logical shifts will work. */ 335#define Dbl_right_align(srcdstA,srcdstB,shift,extent) \ 336 if( shift >= 32 ) \ 337 { \ 338 /* Big shift requires examining the portion shift off \ 339 the end to properly set inexact. */ \ 340 if(shift < 64) \ 341 { \ 342 if(shift > 32) \ 343 { \ 344 Variable_shift_double(Dallp1(srcdstA),Dallp2(srcdstB), \ 345 shift-32, Extall(extent)); \ 346 if(Dallp2(srcdstB) << 64 - (shift)) Ext_setone_low(extent); \ 347 } \ 348 else Extall(extent) = Dallp2(srcdstB); \ 349 Dallp2(srcdstB) = Dallp1(srcdstA) >> (shift - 32); \ 350 } \ 351 else \ 352 { \ 353 Extall(extent) = Dallp1(srcdstA); \ 354 if(Dallp2(srcdstB)) Ext_setone_low(extent); \ 355 Dallp2(srcdstB) = 0; \ 356 } \ 357 Dallp1(srcdstA) = 0; \ 358 } \ 359 else \ 360 { \ 361 /* Small alignment is simpler. Extension is easily set. */ \ 362 if (shift > 0) \ 363 { \ 364 Extall(extent) = Dallp2(srcdstB) << 32 - (shift); \ 365 Variable_shift_double(Dallp1(srcdstA),Dallp2(srcdstB),shift, \ 366 Dallp2(srcdstB)); \ 367 Dallp1(srcdstA) >>= shift; \ 368 } \ 369 else Extall(extent) = 0; \ 370 } 371 372/* 373 * Here we need to shift the result right to correct for an overshift 374 * (due to the exponent becoming negative) during normalization. 375 */ 376#define Dbl_fix_overshift(srcdstA,srcdstB,shift,extent) \ 377 Extall(extent) = Dallp2(srcdstB) << 32 - (shift); \ 378 Dallp2(srcdstB) = (Dallp1(srcdstA) << 32 - (shift)) | \ 379 (Dallp2(srcdstB) >> (shift)); \ 380 Dallp1(srcdstA) = Dallp1(srcdstA) >> shift 381 382#define Dbl_hiddenhigh3mantissa(dbl_value) Dhiddenhigh3mantissa(dbl_value) 383#define Dbl_hidden(dbl_value) Dhidden(dbl_value) 384#define Dbl_lowmantissap2(dbl_value) Dlowp2(dbl_value) 385 386/* The left argument is never smaller than the right argument */ 387#define Dbl_subtract(lefta,leftb,righta,rightb,resulta,resultb) \ 388 if( Dallp2(rightb) > Dallp2(leftb) ) Dallp1(lefta)--; \ 389 Dallp2(resultb) = Dallp2(leftb) - Dallp2(rightb); \ 390 Dallp1(resulta) = Dallp1(lefta) - Dallp1(righta) 391 392/* Subtract right augmented with extension from left augmented with zeros and 393 * store into result and extension. */ 394#define Dbl_subtract_withextension(lefta,leftb,righta,rightb,extent,resulta,resultb) \ 395 Dbl_subtract(lefta,leftb,righta,rightb,resulta,resultb); \ 396 if( (Extall(extent) = 0-Extall(extent)) ) \ 397 { \ 398 if((Dallp2(resultb)--) == 0) Dallp1(resulta)--; \ 399 } 400 401#define Dbl_addition(lefta,leftb,righta,rightb,resulta,resultb) \ 402 /* If the sum of the low words is less than either source, then \ 403 * an overflow into the next word occurred. */ \ 404 Dallp1(resulta) = Dallp1(lefta) + Dallp1(righta); \ 405 if((Dallp2(resultb) = Dallp2(leftb) + Dallp2(rightb)) < Dallp2(rightb)) \ 406 Dallp1(resulta)++ 407 408#define Dbl_xortointp1(left,right,result) \ 409 result = Dallp1(left) XOR Dallp1(right) 410 411#define Dbl_xorfromintp1(left,right,result) \ 412 Dallp1(result) = left XOR Dallp1(right) 413 414#define Dbl_swap_lower(left,right) \ 415 Dallp2(left) = Dallp2(left) XOR Dallp2(right); \ 416 Dallp2(right) = Dallp2(left) XOR Dallp2(right); \ 417 Dallp2(left) = Dallp2(left) XOR Dallp2(right) 418 419/* Need to Initialize */ 420#define Dbl_makequietnan(desta,destb) \ 421 Dallp1(desta) = ((DBL_EMAX+DBL_BIAS)+1)<< (32-(1+DBL_EXP_LENGTH)) \ 422 | (1<<(32-(1+DBL_EXP_LENGTH+2))); \ 423 Dallp2(destb) = 0 424#define Dbl_makesignalingnan(desta,destb) \ 425 Dallp1(desta) = ((DBL_EMAX+DBL_BIAS)+1)<< (32-(1+DBL_EXP_LENGTH)) \ 426 | (1<<(32-(1+DBL_EXP_LENGTH+1))); \ 427 Dallp2(destb) = 0 428 429#define Dbl_normalize(dbl_opndA,dbl_opndB,exponent) \ 430 while(Dbl_iszero_hiddenhigh7mantissa(dbl_opndA)) { \ 431 Dbl_leftshiftby8(dbl_opndA,dbl_opndB); \ 432 exponent -= 8; \ 433 } \ 434 if(Dbl_iszero_hiddenhigh3mantissa(dbl_opndA)) { \ 435 Dbl_leftshiftby4(dbl_opndA,dbl_opndB); \ 436 exponent -= 4; \ 437 } \ 438 while(Dbl_iszero_hidden(dbl_opndA)) { \ 439 Dbl_leftshiftby1(dbl_opndA,dbl_opndB); \ 440 exponent -= 1; \ 441 } 442 443#define Twoword_add(src1dstA,src1dstB,src2A,src2B) \ 444 /* \ 445 * want this macro to generate: \ 446 * ADD src1dstB,src2B,src1dstB; \ 447 * ADDC src1dstA,src2A,src1dstA; \ 448 */ \ 449 if ((src1dstB) + (src2B) < (src1dstB)) Dallp1(src1dstA)++; \ 450 Dallp1(src1dstA) += (src2A); \ 451 Dallp2(src1dstB) += (src2B) 452 453#define Twoword_subtract(src1dstA,src1dstB,src2A,src2B) \ 454 /* \ 455 * want this macro to generate: \ 456 * SUB src1dstB,src2B,src1dstB; \ 457 * SUBB src1dstA,src2A,src1dstA; \ 458 */ \ 459 if ((src1dstB) < (src2B)) Dallp1(src1dstA)--; \ 460 Dallp1(src1dstA) -= (src2A); \ 461 Dallp2(src1dstB) -= (src2B) 462 463#define Dbl_setoverflow(resultA,resultB) \ 464 /* set result to infinity or largest number */ \ 465 switch (Rounding_mode()) { \ 466 case ROUNDPLUS: \ 467 if (Dbl_isone_sign(resultA)) { \ 468 Dbl_setlargestnegative(resultA,resultB); \ 469 } \ 470 else { \ 471 Dbl_setinfinitypositive(resultA,resultB); \ 472 } \ 473 break; \ 474 case ROUNDMINUS: \ 475 if (Dbl_iszero_sign(resultA)) { \ 476 Dbl_setlargestpositive(resultA,resultB); \ 477 } \ 478 else { \ 479 Dbl_setinfinitynegative(resultA,resultB); \ 480 } \ 481 break; \ 482 case ROUNDNEAREST: \ 483 Dbl_setinfinity_exponentmantissa(resultA,resultB); \ 484 break; \ 485 case ROUNDZERO: \ 486 Dbl_setlargest_exponentmantissa(resultA,resultB); \ 487 } 488 489#define Dbl_denormalize(opndp1,opndp2,exponent,guard,sticky,inexact) \ 490 Dbl_clear_signexponent_set_hidden(opndp1); \ 491 if (exponent >= (1-DBL_P)) { \ 492 if (exponent >= -31) { \ 493 guard = (Dallp2(opndp2) >> -exponent) & 1; \ 494 if (exponent < 0) sticky |= Dallp2(opndp2) << (32+exponent); \ 495 if (exponent > -31) { \ 496 Variable_shift_double(opndp1,opndp2,1-exponent,opndp2); \ 497 Dallp1(opndp1) >>= 1-exponent; \ 498 } \ 499 else { \ 500 Dallp2(opndp2) = Dallp1(opndp1); \ 501 Dbl_setzerop1(opndp1); \ 502 } \ 503 } \ 504 else { \ 505 guard = (Dallp1(opndp1) >> -32-exponent) & 1; \ 506 if (exponent == -32) sticky |= Dallp2(opndp2); \ 507 else sticky |= (Dallp2(opndp2) | Dallp1(opndp1) << 64+exponent); \ 508 Dallp2(opndp2) = Dallp1(opndp1) >> -31-exponent; \ 509 Dbl_setzerop1(opndp1); \ 510 } \ 511 inexact = guard | sticky; \ 512 } \ 513 else { \ 514 guard = 0; \ 515 sticky |= (Dallp1(opndp1) | Dallp2(opndp2)); \ 516 Dbl_setzero(opndp1,opndp2); \ 517 inexact = sticky; \ 518 } 519 520/* 521 * The fused multiply add instructions requires a double extended format, 522 * with 106 bits of mantissa. 523 */ 524#define DBLEXT_THRESHOLD 106 525 526#define Dblext_setzero(valA,valB,valC,valD) \ 527 Dextallp1(valA) = 0; Dextallp2(valB) = 0; \ 528 Dextallp3(valC) = 0; Dextallp4(valD) = 0 529 530 531#define Dblext_isnotzero_mantissap3(valC) (Dextallp3(valC)!=0) 532#define Dblext_isnotzero_mantissap4(valD) (Dextallp3(valD)!=0) 533#define Dblext_isone_lowp2(val) (Dextlowp2(val)!=0) 534#define Dblext_isone_highp3(val) (Dexthighp3(val)!=0) 535#define Dblext_isnotzero_low31p3(val) (Dextlow31p3(val)!=0) 536#define Dblext_iszero(valA,valB,valC,valD) (Dextallp1(valA)==0 && \ 537 Dextallp2(valB)==0 && Dextallp3(valC)==0 && Dextallp4(valD)==0) 538 539#define Dblext_copy(srca,srcb,srcc,srcd,desta,destb,destc,destd) \ 540 Dextallp1(desta) = Dextallp4(srca); \ 541 Dextallp2(destb) = Dextallp4(srcb); \ 542 Dextallp3(destc) = Dextallp4(srcc); \ 543 Dextallp4(destd) = Dextallp4(srcd) 544 545#define Dblext_swap_lower(leftp2,leftp3,leftp4,rightp2,rightp3,rightp4) \ 546 Dextallp2(leftp2) = Dextallp2(leftp2) XOR Dextallp2(rightp2); \ 547 Dextallp2(rightp2) = Dextallp2(leftp2) XOR Dextallp2(rightp2); \ 548 Dextallp2(leftp2) = Dextallp2(leftp2) XOR Dextallp2(rightp2); \ 549 Dextallp3(leftp3) = Dextallp3(leftp3) XOR Dextallp3(rightp3); \ 550 Dextallp3(rightp3) = Dextallp3(leftp3) XOR Dextallp3(rightp3); \ 551 Dextallp3(leftp3) = Dextallp3(leftp3) XOR Dextallp3(rightp3); \ 552 Dextallp4(leftp4) = Dextallp4(leftp4) XOR Dextallp4(rightp4); \ 553 Dextallp4(rightp4) = Dextallp4(leftp4) XOR Dextallp4(rightp4); \ 554 Dextallp4(leftp4) = Dextallp4(leftp4) XOR Dextallp4(rightp4) 555 556#define Dblext_setone_lowmantissap4(dbl_value) Deposit_dextlowp4(dbl_value,1) 557 558/* The high bit is always zero so arithmetic or logical shifts will work. */ 559#define Dblext_right_align(srcdstA,srcdstB,srcdstC,srcdstD,shift) \ 560 {int shiftamt, sticky; \ 561 shiftamt = shift % 32; \ 562 sticky = 0; \ 563 switch (shift/32) { \ 564 case 0: if (shiftamt > 0) { \ 565 sticky = Dextallp4(srcdstD) << 32 - (shiftamt); \ 566 Variable_shift_double(Dextallp3(srcdstC), \ 567 Dextallp4(srcdstD),shiftamt,Dextallp4(srcdstD)); \ 568 Variable_shift_double(Dextallp2(srcdstB), \ 569 Dextallp3(srcdstC),shiftamt,Dextallp3(srcdstC)); \ 570 Variable_shift_double(Dextallp1(srcdstA), \ 571 Dextallp2(srcdstB),shiftamt,Dextallp2(srcdstB)); \ 572 Dextallp1(srcdstA) >>= shiftamt; \ 573 } \ 574 break; \ 575 case 1: if (shiftamt > 0) { \ 576 sticky = (Dextallp3(srcdstC) << 31 - shiftamt) | \ 577 Dextallp4(srcdstD); \ 578 Variable_shift_double(Dextallp2(srcdstB), \ 579 Dextallp3(srcdstC),shiftamt,Dextallp4(srcdstD)); \ 580 Variable_shift_double(Dextallp1(srcdstA), \ 581 Dextallp2(srcdstB),shiftamt,Dextallp3(srcdstC)); \ 582 } \ 583 else { \ 584 sticky = Dextallp4(srcdstD); \ 585 Dextallp4(srcdstD) = Dextallp3(srcdstC); \ 586 Dextallp3(srcdstC) = Dextallp2(srcdstB); \ 587 } \ 588 Dextallp2(srcdstB) = Dextallp1(srcdstA) >> shiftamt; \ 589 Dextallp1(srcdstA) = 0; \ 590 break; \ 591 case 2: if (shiftamt > 0) { \ 592 sticky = (Dextallp2(srcdstB) << 31 - shiftamt) | \ 593 Dextallp3(srcdstC) | Dextallp4(srcdstD); \ 594 Variable_shift_double(Dextallp1(srcdstA), \ 595 Dextallp2(srcdstB),shiftamt,Dextallp4(srcdstD)); \ 596 } \ 597 else { \ 598 sticky = Dextallp3(srcdstC) | Dextallp4(srcdstD); \ 599 Dextallp4(srcdstD) = Dextallp2(srcdstB); \ 600 } \ 601 Dextallp3(srcdstC) = Dextallp1(srcdstA) >> shiftamt; \ 602 Dextallp1(srcdstA) = Dextallp2(srcdstB) = 0; \ 603 break; \ 604 case 3: if (shiftamt > 0) { \ 605 sticky = (Dextallp1(srcdstA) << 31 - shiftamt) | \ 606 Dextallp2(srcdstB) | Dextallp3(srcdstC) | \ 607 Dextallp4(srcdstD); \ 608 } \ 609 else { \ 610 sticky = Dextallp2(srcdstB) | Dextallp3(srcdstC) | \ 611 Dextallp4(srcdstD); \ 612 } \ 613 Dextallp4(srcdstD) = Dextallp1(srcdstA) >> shiftamt; \ 614 Dextallp1(srcdstA) = Dextallp2(srcdstB) = 0; \ 615 Dextallp3(srcdstC) = 0; \ 616 break; \ 617 } \ 618 if (sticky) Dblext_setone_lowmantissap4(srcdstD); \ 619 } 620 621/* The left argument is never smaller than the right argument */ 622#define Dblext_subtract(lefta,leftb,leftc,leftd,righta,rightb,rightc,rightd,resulta,resultb,resultc,resultd) \ 623 if( Dextallp4(rightd) > Dextallp4(leftd) ) \ 624 if( (Dextallp3(leftc)--) == 0) \ 625 if( (Dextallp2(leftb)--) == 0) Dextallp1(lefta)--; \ 626 Dextallp4(resultd) = Dextallp4(leftd) - Dextallp4(rightd); \ 627 if( Dextallp3(rightc) > Dextallp3(leftc) ) \ 628 if( (Dextallp2(leftb)--) == 0) Dextallp1(lefta)--; \ 629 Dextallp3(resultc) = Dextallp3(leftc) - Dextallp3(rightc); \ 630 if( Dextallp2(rightb) > Dextallp2(leftb) ) Dextallp1(lefta)--; \ 631 Dextallp2(resultb) = Dextallp2(leftb) - Dextallp2(rightb); \ 632 Dextallp1(resulta) = Dextallp1(lefta) - Dextallp1(righta) 633 634#define Dblext_addition(lefta,leftb,leftc,leftd,righta,rightb,rightc,rightd,resulta,resultb,resultc,resultd) \ 635 /* If the sum of the low words is less than either source, then \ 636 * an overflow into the next word occurred. */ \ 637 if ((Dextallp4(resultd) = Dextallp4(leftd)+Dextallp4(rightd)) < \ 638 Dextallp4(rightd)) \ 639 if((Dextallp3(resultc) = Dextallp3(leftc)+Dextallp3(rightc)+1) <= \ 640 Dextallp3(rightc)) \ 641 if((Dextallp2(resultb) = Dextallp2(leftb)+Dextallp2(rightb)+1) \ 642 <= Dextallp2(rightb)) \ 643 Dextallp1(resulta) = Dextallp1(lefta)+Dextallp1(righta)+1; \ 644 else Dextallp1(resulta) = Dextallp1(lefta)+Dextallp1(righta); \ 645 else \ 646 if ((Dextallp2(resultb) = Dextallp2(leftb)+Dextallp2(rightb)) < \ 647 Dextallp2(rightb)) \ 648 Dextallp1(resulta) = Dextallp1(lefta)+Dextallp1(righta)+1; \ 649 else Dextallp1(resulta) = Dextallp1(lefta)+Dextallp1(righta); \ 650 else \ 651 if ((Dextallp3(resultc) = Dextallp3(leftc)+Dextallp3(rightc)) < \ 652 Dextallp3(rightc)) \ 653 if ((Dextallp2(resultb) = Dextallp2(leftb)+Dextallp2(rightb)+1) \ 654 <= Dextallp2(rightb)) \ 655 Dextallp1(resulta) = Dextallp1(lefta)+Dextallp1(righta)+1; \ 656 else Dextallp1(resulta) = Dextallp1(lefta)+Dextallp1(righta); \ 657 else \ 658 if ((Dextallp2(resultb) = Dextallp2(leftb)+Dextallp2(rightb)) < \ 659 Dextallp2(rightb)) \ 660 Dextallp1(resulta) = Dextallp1(lefta)+Dextallp1(righta)+1; \ 661 else Dextallp1(resulta) = Dextallp1(lefta)+Dextallp1(righta) 662 663 664#define Dblext_arithrightshiftby1(srcdstA,srcdstB,srcdstC,srcdstD) \ 665 Shiftdouble(Dextallp3(srcdstC),Dextallp4(srcdstD),1,Dextallp4(srcdstD)); \ 666 Shiftdouble(Dextallp2(srcdstB),Dextallp3(srcdstC),1,Dextallp3(srcdstC)); \ 667 Shiftdouble(Dextallp1(srcdstA),Dextallp2(srcdstB),1,Dextallp2(srcdstB)); \ 668 Dextallp1(srcdstA) = (int)Dextallp1(srcdstA) >> 1 669 670#define Dblext_leftshiftby8(valA,valB,valC,valD) \ 671 Shiftdouble(Dextallp1(valA),Dextallp2(valB),24,Dextallp1(valA)); \ 672 Shiftdouble(Dextallp2(valB),Dextallp3(valC),24,Dextallp2(valB)); \ 673 Shiftdouble(Dextallp3(valC),Dextallp4(valD),24,Dextallp3(valC)); \ 674 Dextallp4(valD) <<= 8 675#define Dblext_leftshiftby4(valA,valB,valC,valD) \ 676 Shiftdouble(Dextallp1(valA),Dextallp2(valB),28,Dextallp1(valA)); \ 677 Shiftdouble(Dextallp2(valB),Dextallp3(valC),28,Dextallp2(valB)); \ 678 Shiftdouble(Dextallp3(valC),Dextallp4(valD),28,Dextallp3(valC)); \ 679 Dextallp4(valD) <<= 4 680#define Dblext_leftshiftby3(valA,valB,valC,valD) \ 681 Shiftdouble(Dextallp1(valA),Dextallp2(valB),29,Dextallp1(valA)); \ 682 Shiftdouble(Dextallp2(valB),Dextallp3(valC),29,Dextallp2(valB)); \ 683 Shiftdouble(Dextallp3(valC),Dextallp4(valD),29,Dextallp3(valC)); \ 684 Dextallp4(valD) <<= 3 685#define Dblext_leftshiftby2(valA,valB,valC,valD) \ 686 Shiftdouble(Dextallp1(valA),Dextallp2(valB),30,Dextallp1(valA)); \ 687 Shiftdouble(Dextallp2(valB),Dextallp3(valC),30,Dextallp2(valB)); \ 688 Shiftdouble(Dextallp3(valC),Dextallp4(valD),30,Dextallp3(valC)); \ 689 Dextallp4(valD) <<= 2 690#define Dblext_leftshiftby1(valA,valB,valC,valD) \ 691 Shiftdouble(Dextallp1(valA),Dextallp2(valB),31,Dextallp1(valA)); \ 692 Shiftdouble(Dextallp2(valB),Dextallp3(valC),31,Dextallp2(valB)); \ 693 Shiftdouble(Dextallp3(valC),Dextallp4(valD),31,Dextallp3(valC)); \ 694 Dextallp4(valD) <<= 1 695 696#define Dblext_rightshiftby4(valueA,valueB,valueC,valueD) \ 697 Shiftdouble(Dextallp3(valueC),Dextallp4(valueD),4,Dextallp4(valueD)); \ 698 Shiftdouble(Dextallp2(valueB),Dextallp3(valueC),4,Dextallp3(valueC)); \ 699 Shiftdouble(Dextallp1(valueA),Dextallp2(valueB),4,Dextallp2(valueB)); \ 700 Dextallp1(valueA) >>= 4 701#define Dblext_rightshiftby1(valueA,valueB,valueC,valueD) \ 702 Shiftdouble(Dextallp3(valueC),Dextallp4(valueD),1,Dextallp4(valueD)); \ 703 Shiftdouble(Dextallp2(valueB),Dextallp3(valueC),1,Dextallp3(valueC)); \ 704 Shiftdouble(Dextallp1(valueA),Dextallp2(valueB),1,Dextallp2(valueB)); \ 705 Dextallp1(valueA) >>= 1 706 707#define Dblext_xortointp1(left,right,result) Dbl_xortointp1(left,right,result) 708 709#define Dblext_xorfromintp1(left,right,result) \ 710 Dbl_xorfromintp1(left,right,result) 711 712#define Dblext_copytoint_exponentmantissap1(src,dest) \ 713 Dbl_copytoint_exponentmantissap1(src,dest) 714 715#define Dblext_ismagnitudeless(leftB,rightB,signlessleft,signlessright) \ 716 Dbl_ismagnitudeless(leftB,rightB,signlessleft,signlessright) 717 718#define Dbl_copyto_dblext(src1,src2,dest1,dest2,dest3,dest4) \ 719 Dextallp1(dest1) = Dallp1(src1); Dextallp2(dest2) = Dallp2(src2); \ 720 Dextallp3(dest3) = 0; Dextallp4(dest4) = 0 721 722#define Dblext_set_sign(dbl_value,sign) Dbl_set_sign(dbl_value,sign) 723#define Dblext_clear_signexponent_set_hidden(srcdst) \ 724 Dbl_clear_signexponent_set_hidden(srcdst) 725#define Dblext_clear_signexponent(srcdst) Dbl_clear_signexponent(srcdst) 726#define Dblext_clear_sign(srcdst) Dbl_clear_sign(srcdst) 727#define Dblext_isone_hidden(dbl_value) Dbl_isone_hidden(dbl_value) 728 729/* 730 * The Fourword_add() macro assumes that integers are 4 bytes in size. 731 * It will break if this is not the case. 732 */ 733 734#define Fourword_add(src1dstA,src1dstB,src1dstC,src1dstD,src2A,src2B,src2C,src2D) \ 735 /* \ 736 * want this macro to generate: \ 737 * ADD src1dstD,src2D,src1dstD; \ 738 * ADDC src1dstC,src2C,src1dstC; \ 739 * ADDC src1dstB,src2B,src1dstB; \ 740 * ADDC src1dstA,src2A,src1dstA; \ 741 */ \ 742 if ((unsigned int)(src1dstD += (src2D)) < (unsigned int)(src2D)) { \ 743 if ((unsigned int)(src1dstC += (src2C) + 1) <= \ 744 (unsigned int)(src2C)) { \ 745 if ((unsigned int)(src1dstB += (src2B) + 1) <= \ 746 (unsigned int)(src2B)) src1dstA++; \ 747 } \ 748 else if ((unsigned int)(src1dstB += (src2B)) < \ 749 (unsigned int)(src2B)) src1dstA++; \ 750 } \ 751 else { \ 752 if ((unsigned int)(src1dstC += (src2C)) < \ 753 (unsigned int)(src2C)) { \ 754 if ((unsigned int)(src1dstB += (src2B) + 1) <= \ 755 (unsigned int)(src2B)) src1dstA++; \ 756 } \ 757 else if ((unsigned int)(src1dstB += (src2B)) < \ 758 (unsigned int)(src2B)) src1dstA++; \ 759 } \ 760 src1dstA += (src2A) 761 762#define Dblext_denormalize(opndp1,opndp2,opndp3,opndp4,exponent,is_tiny) \ 763 {int shiftamt, sticky; \ 764 is_tiny = TRUE; \ 765 if (exponent == 0 && (Dextallp3(opndp3) || Dextallp4(opndp4))) { \ 766 switch (Rounding_mode()) { \ 767 case ROUNDPLUS: \ 768 if (Dbl_iszero_sign(opndp1)) { \ 769 Dbl_increment(opndp1,opndp2); \ 770 if (Dbl_isone_hiddenoverflow(opndp1)) \ 771 is_tiny = FALSE; \ 772 Dbl_decrement(opndp1,opndp2); \ 773 } \ 774 break; \ 775 case ROUNDMINUS: \ 776 if (Dbl_isone_sign(opndp1)) { \ 777 Dbl_increment(opndp1,opndp2); \ 778 if (Dbl_isone_hiddenoverflow(opndp1)) \ 779 is_tiny = FALSE; \ 780 Dbl_decrement(opndp1,opndp2); \ 781 } \ 782 break; \ 783 case ROUNDNEAREST: \ 784 if (Dblext_isone_highp3(opndp3) && \ 785 (Dblext_isone_lowp2(opndp2) || \ 786 Dblext_isnotzero_low31p3(opndp3))) { \ 787 Dbl_increment(opndp1,opndp2); \ 788 if (Dbl_isone_hiddenoverflow(opndp1)) \ 789 is_tiny = FALSE; \ 790 Dbl_decrement(opndp1,opndp2); \ 791 } \ 792 break; \ 793 } \ 794 } \ 795 Dblext_clear_signexponent_set_hidden(opndp1); \ 796 if (exponent >= (1-QUAD_P)) { \ 797 shiftamt = (1-exponent) % 32; \ 798 switch((1-exponent)/32) { \ 799 case 0: sticky = Dextallp4(opndp4) << 32-(shiftamt); \ 800 Variableshiftdouble(opndp3,opndp4,shiftamt,opndp4); \ 801 Variableshiftdouble(opndp2,opndp3,shiftamt,opndp3); \ 802 Variableshiftdouble(opndp1,opndp2,shiftamt,opndp2); \ 803 Dextallp1(opndp1) >>= shiftamt; \ 804 break; \ 805 case 1: sticky = (Dextallp3(opndp3) << 32-(shiftamt)) | \ 806 Dextallp4(opndp4); \ 807 Variableshiftdouble(opndp2,opndp3,shiftamt,opndp4); \ 808 Variableshiftdouble(opndp1,opndp2,shiftamt,opndp3); \ 809 Dextallp2(opndp2) = Dextallp1(opndp1) >> shiftamt; \ 810 Dextallp1(opndp1) = 0; \ 811 break; \ 812 case 2: sticky = (Dextallp2(opndp2) << 32-(shiftamt)) | \ 813 Dextallp3(opndp3) | Dextallp4(opndp4); \ 814 Variableshiftdouble(opndp1,opndp2,shiftamt,opndp4); \ 815 Dextallp3(opndp3) = Dextallp1(opndp1) >> shiftamt; \ 816 Dextallp1(opndp1) = Dextallp2(opndp2) = 0; \ 817 break; \ 818 case 3: sticky = (Dextallp1(opndp1) << 32-(shiftamt)) | \ 819 Dextallp2(opndp2) | Dextallp3(opndp3) | \ 820 Dextallp4(opndp4); \ 821 Dextallp4(opndp4) = Dextallp1(opndp1) >> shiftamt; \ 822 Dextallp1(opndp1) = Dextallp2(opndp2) = 0; \ 823 Dextallp3(opndp3) = 0; \ 824 break; \ 825 } \ 826 } \ 827 else { \ 828 sticky = Dextallp1(opndp1) | Dextallp2(opndp2) | \ 829 Dextallp3(opndp3) | Dextallp4(opndp4); \ 830 Dblext_setzero(opndp1,opndp2,opndp3,opndp4); \ 831 } \ 832 if (sticky) Dblext_setone_lowmantissap4(opndp4); \ 833 exponent = 0; \ 834 }