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 9 #ifdef __NO_PA_HDRS 10 PA header file -- do not include this header file for non-PA builds. 11 #endif 12 13 /* 32-bit word grabbing functions */ 14 #define Sgl_firstword(value) Sall(value) 15 #define Sgl_secondword(value) dummy_location 16 #define Sgl_thirdword(value) dummy_location 17 #define Sgl_fourthword(value) dummy_location 18 19 #define Sgl_sign(object) Ssign(object) 20 #define Sgl_exponent(object) Sexponent(object) 21 #define Sgl_signexponent(object) Ssignexponent(object) 22 #define Sgl_mantissa(object) Smantissa(object) 23 #define Sgl_exponentmantissa(object) Sexponentmantissa(object) 24 #define Sgl_all(object) Sall(object) 25 26 /* sgl_and_signs ANDs the sign bits of each argument and puts the result 27 * into the first argument. sgl_or_signs ors those same sign bits */ 28 #define Sgl_and_signs( src1dst, src2) \ 29 Sall(src1dst) = (Sall(src2)|~((unsigned int)1<<31)) & Sall(src1dst) 30 #define Sgl_or_signs( src1dst, src2) \ 31 Sall(src1dst) = (Sall(src2)&((unsigned int)1<<31)) | Sall(src1dst) 32 33 /* The hidden bit is always the low bit of the exponent */ 34 #define Sgl_clear_exponent_set_hidden(srcdst) Deposit_sexponent(srcdst,1) 35 #define Sgl_clear_signexponent_set_hidden(srcdst) \ 36 Deposit_ssignexponent(srcdst,1) 37 #define Sgl_clear_sign(srcdst) Sall(srcdst) &= ~((unsigned int)1<<31) 38 #define Sgl_clear_signexponent(srcdst) Sall(srcdst) &= 0x007fffff 39 40 /* varamount must be less than 32 for the next three functions */ 41 #define Sgl_rightshift(srcdst, varamount) \ 42 Sall(srcdst) >>= varamount 43 #define Sgl_leftshift(srcdst, varamount) \ 44 Sall(srcdst) <<= varamount 45 #define Sgl_rightshift_exponentmantissa(srcdst, varamount) \ 46 Sall(srcdst) = \ 47 (Sexponentmantissa(srcdst) >> varamount) | \ 48 (Sall(srcdst) & ((unsigned int)1<<31)) 49 50 #define Sgl_leftshiftby1_withextent(left,right,result) \ 51 Shiftdouble(Sall(left),Extall(right),31,Sall(result)) 52 53 #define Sgl_rightshiftby1_withextent(left,right,dst) \ 54 Shiftdouble(Sall(left),Extall(right),1,Extall(right)) 55 #define Sgl_arithrightshiftby1(srcdst) \ 56 Sall(srcdst) = (int)Sall(srcdst) >> 1 57 58 /* Sign extend the sign bit with an integer destination */ 59 #define Sgl_signextendedsign(value) Ssignedsign(value) 60 61 #define Sgl_isone_hidden(sgl_value) (Shidden(sgl_value)) 62 #define Sgl_increment(sgl_value) Sall(sgl_value) += 1 63 #define Sgl_increment_mantissa(sgl_value) \ 64 Deposit_smantissa(sgl_value,sgl_value+1) 65 #define Sgl_decrement(sgl_value) Sall(sgl_value) -= 1 66 67 #define Sgl_isone_sign(sgl_value) (Is_ssign(sgl_value)!=0) 68 #define Sgl_isone_hiddenoverflow(sgl_value) \ 69 (Is_shiddenoverflow(sgl_value)!=0) 70 #define Sgl_isone_lowmantissa(sgl_value) (Is_slow(sgl_value)!=0) 71 #define Sgl_isone_signaling(sgl_value) (Is_ssignaling(sgl_value)!=0) 72 #define Sgl_is_signalingnan(sgl_value) (Ssignalingnan(sgl_value)==0x1ff) 73 #define Sgl_isnotzero(sgl_value) (Sall(sgl_value)!=0) 74 #define Sgl_isnotzero_hiddenhigh7mantissa(sgl_value) \ 75 (Shiddenhigh7mantissa(sgl_value)!=0) 76 #define Sgl_isnotzero_low4(sgl_value) (Slow4(sgl_value)!=0) 77 #define Sgl_isnotzero_exponent(sgl_value) (Sexponent(sgl_value)!=0) 78 #define Sgl_isnotzero_mantissa(sgl_value) (Smantissa(sgl_value)!=0) 79 #define Sgl_isnotzero_exponentmantissa(sgl_value) \ 80 (Sexponentmantissa(sgl_value)!=0) 81 #define Sgl_iszero(sgl_value) (Sall(sgl_value)==0) 82 #define Sgl_iszero_signaling(sgl_value) (Is_ssignaling(sgl_value)==0) 83 #define Sgl_iszero_hidden(sgl_value) (Is_shidden(sgl_value)==0) 84 #define Sgl_iszero_hiddenoverflow(sgl_value) \ 85 (Is_shiddenoverflow(sgl_value)==0) 86 #define Sgl_iszero_hiddenhigh3mantissa(sgl_value) \ 87 (Shiddenhigh3mantissa(sgl_value)==0) 88 #define Sgl_iszero_hiddenhigh7mantissa(sgl_value) \ 89 (Shiddenhigh7mantissa(sgl_value)==0) 90 #define Sgl_iszero_sign(sgl_value) (Is_ssign(sgl_value)==0) 91 #define Sgl_iszero_exponent(sgl_value) (Sexponent(sgl_value)==0) 92 #define Sgl_iszero_mantissa(sgl_value) (Smantissa(sgl_value)==0) 93 #define Sgl_iszero_exponentmantissa(sgl_value) \ 94 (Sexponentmantissa(sgl_value)==0) 95 #define Sgl_isinfinity_exponent(sgl_value) \ 96 (Sgl_exponent(sgl_value)==SGL_INFINITY_EXPONENT) 97 #define Sgl_isnotinfinity_exponent(sgl_value) \ 98 (Sgl_exponent(sgl_value)!=SGL_INFINITY_EXPONENT) 99 #define Sgl_isinfinity(sgl_value) \ 100 (Sgl_exponent(sgl_value)==SGL_INFINITY_EXPONENT && \ 101 Sgl_mantissa(sgl_value)==0) 102 #define Sgl_isnan(sgl_value) \ 103 (Sgl_exponent(sgl_value)==SGL_INFINITY_EXPONENT && \ 104 Sgl_mantissa(sgl_value)!=0) 105 #define Sgl_isnotnan(sgl_value) \ 106 (Sgl_exponent(sgl_value)!=SGL_INFINITY_EXPONENT || \ 107 Sgl_mantissa(sgl_value)==0) 108 #define Sgl_islessthan(sgl_op1,sgl_op2) \ 109 (Sall(sgl_op1) < Sall(sgl_op2)) 110 #define Sgl_isgreaterthan(sgl_op1,sgl_op2) \ 111 (Sall(sgl_op1) > Sall(sgl_op2)) 112 #define Sgl_isnotlessthan(sgl_op1,sgl_op2) \ 113 (Sall(sgl_op1) >= Sall(sgl_op2)) 114 #define Sgl_isequal(sgl_op1,sgl_op2) \ 115 (Sall(sgl_op1) == Sall(sgl_op2)) 116 117 #define Sgl_leftshiftby8(sgl_value) \ 118 Sall(sgl_value) <<= 8 119 #define Sgl_leftshiftby4(sgl_value) \ 120 Sall(sgl_value) <<= 4 121 #define Sgl_leftshiftby3(sgl_value) \ 122 Sall(sgl_value) <<= 3 123 #define Sgl_leftshiftby2(sgl_value) \ 124 Sall(sgl_value) <<= 2 125 #define Sgl_leftshiftby1(sgl_value) \ 126 Sall(sgl_value) <<= 1 127 #define Sgl_rightshiftby1(sgl_value) \ 128 Sall(sgl_value) >>= 1 129 #define Sgl_rightshiftby4(sgl_value) \ 130 Sall(sgl_value) >>= 4 131 #define Sgl_rightshiftby8(sgl_value) \ 132 Sall(sgl_value) >>= 8 133 134 #define Sgl_ismagnitudeless(signlessleft,signlessright) \ 135 /* unsigned int signlessleft, signlessright; */ \ 136 (signlessleft < signlessright) 137 138 139 #define Sgl_copytoint_exponentmantissa(source,dest) \ 140 dest = Sexponentmantissa(source) 141 142 /* A quiet NaN has the high mantissa bit clear and at least on other (in this 143 * case the adjacent bit) bit set. */ 144 #define Sgl_set_quiet(sgl_value) Deposit_shigh2mantissa(sgl_value,1) 145 #define Sgl_set_exponent(sgl_value,exp) Deposit_sexponent(sgl_value,exp) 146 147 #define Sgl_set_mantissa(dest,value) Deposit_smantissa(dest,value) 148 #define Sgl_set_exponentmantissa(dest,value) \ 149 Deposit_sexponentmantissa(dest,value) 150 151 /* An infinity is represented with the max exponent and a zero mantissa */ 152 #define Sgl_setinfinity_exponent(sgl_value) \ 153 Deposit_sexponent(sgl_value,SGL_INFINITY_EXPONENT) 154 #define Sgl_setinfinity_exponentmantissa(sgl_value) \ 155 Deposit_sexponentmantissa(sgl_value, \ 156 (SGL_INFINITY_EXPONENT << (32-(1+SGL_EXP_LENGTH)))) 157 #define Sgl_setinfinitypositive(sgl_value) \ 158 Sall(sgl_value) = (SGL_INFINITY_EXPONENT << (32-(1+SGL_EXP_LENGTH))) 159 #define Sgl_setinfinitynegative(sgl_value) \ 160 Sall(sgl_value) = (SGL_INFINITY_EXPONENT << (32-(1+SGL_EXP_LENGTH))) \ 161 | ((unsigned int)1<<31) 162 #define Sgl_setinfinity(sgl_value,sign) \ 163 Sall(sgl_value) = (SGL_INFINITY_EXPONENT << (32-(1+SGL_EXP_LENGTH))) | \ 164 ((unsigned int)sign << 31) 165 #define Sgl_sethigh4bits(sgl_value, extsign) \ 166 Deposit_shigh4(sgl_value,extsign) 167 #define Sgl_set_sign(sgl_value,sign) Deposit_ssign(sgl_value,sign) 168 #define Sgl_invert_sign(sgl_value) \ 169 Deposit_ssign(sgl_value,~Ssign(sgl_value)) 170 #define Sgl_setone_sign(sgl_value) Deposit_ssign(sgl_value,1) 171 #define Sgl_setone_lowmantissa(sgl_value) Deposit_slow(sgl_value,1) 172 #define Sgl_setzero_sign(sgl_value) Sall(sgl_value) &= 0x7fffffff 173 #define Sgl_setzero_exponent(sgl_value) Sall(sgl_value) &= 0x807fffff 174 #define Sgl_setzero_mantissa(sgl_value) Sall(sgl_value) &= 0xff800000 175 #define Sgl_setzero_exponentmantissa(sgl_value) Sall(sgl_value) &= 0x80000000 176 #define Sgl_setzero(sgl_value) Sall(sgl_value) = 0 177 #define Sgl_setnegativezero(sgl_value) Sall(sgl_value) = (unsigned int)1 << 31 178 179 /* Use following macro for both overflow & underflow conditions */ 180 #define ovfl - 181 #define unfl + 182 #define Sgl_setwrapped_exponent(sgl_value,exponent,op) \ 183 Deposit_sexponent(sgl_value,(exponent op SGL_WRAP)) 184 185 #define Sgl_setlargestpositive(sgl_value) \ 186 Sall(sgl_value) = ((SGL_EMAX+SGL_BIAS) << (32-(1+SGL_EXP_LENGTH))) \ 187 | ((1<<(32-(1+SGL_EXP_LENGTH))) - 1 ) 188 #define Sgl_setlargestnegative(sgl_value) \ 189 Sall(sgl_value) = ((SGL_EMAX+SGL_BIAS) << (32-(1+SGL_EXP_LENGTH))) \ 190 | ((1<<(32-(1+SGL_EXP_LENGTH))) - 1 ) \ 191 | ((unsigned int)1<<31) 192 193 #define Sgl_setnegativeinfinity(sgl_value) \ 194 Sall(sgl_value) = \ 195 ((1<<SGL_EXP_LENGTH) | SGL_INFINITY_EXPONENT) << (32-(1+SGL_EXP_LENGTH)) 196 #define Sgl_setlargest(sgl_value,sign) \ 197 Sall(sgl_value) = (unsigned int)sign << 31 | \ 198 (((SGL_EMAX+SGL_BIAS) << (32-(1+SGL_EXP_LENGTH))) \ 199 | ((1 << (32-(1+SGL_EXP_LENGTH))) - 1 )) 200 #define Sgl_setlargest_exponentmantissa(sgl_value) \ 201 Sall(sgl_value) = Sall(sgl_value) & ((unsigned int)1<<31) | \ 202 (((SGL_EMAX+SGL_BIAS) << (32-(1+SGL_EXP_LENGTH))) \ 203 | ((1 << (32-(1+SGL_EXP_LENGTH))) - 1 )) 204 205 /* The high bit is always zero so arithmetic or logical shifts will work. */ 206 #define Sgl_right_align(srcdst,shift,extent) \ 207 /* sgl_floating_point srcdst; int shift; extension extent */ \ 208 if (shift < 32) { \ 209 Extall(extent) = Sall(srcdst) << (32-(shift)); \ 210 Sall(srcdst) >>= shift; \ 211 } \ 212 else { \ 213 Extall(extent) = Sall(srcdst); \ 214 Sall(srcdst) = 0; \ 215 } 216 #define Sgl_hiddenhigh3mantissa(sgl_value) Shiddenhigh3mantissa(sgl_value) 217 #define Sgl_hidden(sgl_value) Shidden(sgl_value) 218 #define Sgl_lowmantissa(sgl_value) Slow(sgl_value) 219 220 /* The left argument is never smaller than the right argument */ 221 #define Sgl_subtract(sgl_left,sgl_right,sgl_result) \ 222 Sall(sgl_result) = Sall(sgl_left) - Sall(sgl_right) 223 224 /* Subtract right augmented with extension from left augmented with zeros and 225 * store into result and extension. */ 226 #define Sgl_subtract_withextension(left,right,extent,result) \ 227 /* sgl_floating_point left,right,result; extension extent */ \ 228 Sgl_subtract(left,right,result); \ 229 if((Extall(extent) = 0-Extall(extent))) \ 230 Sall(result) = Sall(result)-1 231 232 #define Sgl_addition(sgl_left,sgl_right,sgl_result) \ 233 Sall(sgl_result) = Sall(sgl_left) + Sall(sgl_right) 234 235 #define Sgl_xortointp1(left,right,result) \ 236 result = Sall(left) XOR Sall(right); 237 238 #define Sgl_xorfromintp1(left,right,result) \ 239 Sall(result) = left XOR Sall(right) 240 241 /* Need to Initialize */ 242 #define Sgl_makequietnan(dest) \ 243 Sall(dest) = ((SGL_EMAX+SGL_BIAS)+1)<< (32-(1+SGL_EXP_LENGTH)) \ 244 | (1<<(32-(1+SGL_EXP_LENGTH+2))) 245 #define Sgl_makesignalingnan(dest) \ 246 Sall(dest) = ((SGL_EMAX+SGL_BIAS)+1)<< (32-(1+SGL_EXP_LENGTH)) \ 247 | (1<<(32-(1+SGL_EXP_LENGTH+1))) 248 249 #define Sgl_normalize(sgl_opnd,exponent) \ 250 while(Sgl_iszero_hiddenhigh7mantissa(sgl_opnd)) { \ 251 Sgl_leftshiftby8(sgl_opnd); \ 252 exponent -= 8; \ 253 } \ 254 if(Sgl_iszero_hiddenhigh3mantissa(sgl_opnd)) { \ 255 Sgl_leftshiftby4(sgl_opnd); \ 256 exponent -= 4; \ 257 } \ 258 while(Sgl_iszero_hidden(sgl_opnd)) { \ 259 Sgl_leftshiftby1(sgl_opnd); \ 260 exponent -= 1; \ 261 } 262 263 #define Sgl_setoverflow(sgl_opnd) \ 264 /* set result to infinity or largest number */ \ 265 switch (Rounding_mode()) { \ 266 case ROUNDPLUS: \ 267 if (Sgl_isone_sign(sgl_opnd)) { \ 268 Sgl_setlargestnegative(sgl_opnd); \ 269 } \ 270 else { \ 271 Sgl_setinfinitypositive(sgl_opnd); \ 272 } \ 273 break; \ 274 case ROUNDMINUS: \ 275 if (Sgl_iszero_sign(sgl_opnd)) { \ 276 Sgl_setlargestpositive(sgl_opnd); \ 277 } \ 278 else { \ 279 Sgl_setinfinitynegative(sgl_opnd); \ 280 } \ 281 break; \ 282 case ROUNDNEAREST: \ 283 Sgl_setinfinity_exponentmantissa(sgl_opnd); \ 284 break; \ 285 case ROUNDZERO: \ 286 Sgl_setlargest_exponentmantissa(sgl_opnd); \ 287 } 288 289 #define Sgl_denormalize(opnd,exponent,guard,sticky,inexact) \ 290 Sgl_clear_signexponent_set_hidden(opnd); \ 291 if (exponent >= (1 - SGL_P)) { \ 292 guard = (Sall(opnd) >> -exponent) & 1; \ 293 if (exponent < 0) sticky |= Sall(opnd) << (32+exponent); \ 294 inexact = guard | sticky; \ 295 Sall(opnd) >>= (1-exponent); \ 296 } \ 297 else { \ 298 guard = 0; \ 299 sticky |= Sall(opnd); \ 300 inexact = sticky; \ 301 Sgl_setzero(opnd); \ 302 } 303 304 /* 305 * The fused multiply add instructions requires a single extended format, 306 * with 48 bits of mantissa. 307 */ 308 #define SGLEXT_THRESHOLD 48 309 310 #define Sglext_setzero(valA,valB) \ 311 Sextallp1(valA) = 0; Sextallp2(valB) = 0 312 313 #define Sglext_isnotzero_mantissap2(valB) (Sextallp2(valB)!=0) 314 #define Sglext_isone_lowp1(val) (Sextlowp1(val)!=0) 315 #define Sglext_isone_highp2(val) (Sexthighp2(val)!=0) 316 #define Sglext_isnotzero_low31p2(val) (Sextlow31p2(val)!=0) 317 #define Sglext_iszero(valA,valB) (Sextallp1(valA)==0 && Sextallp2(valB)==0) 318 319 #define Sgl_copytoptr(src,destptr) *destptr = src 320 #define Sgl_copyfromptr(srcptr,dest) dest = *srcptr 321 #define Sglext_copy(srca,srcb,desta,destb) \ 322 Sextallp1(desta) = Sextallp1(srca); \ 323 Sextallp2(destb) = Sextallp2(srcb) 324 #define Sgl_copyto_sglext(src1,dest1,dest2) \ 325 Sextallp1(dest1) = Sall(src1); Sextallp2(dest2) = 0 326 327 #define Sglext_swap_lower(leftp2,rightp2) \ 328 Sextallp2(leftp2) = Sextallp2(leftp2) XOR Sextallp2(rightp2); \ 329 Sextallp2(rightp2) = Sextallp2(leftp2) XOR Sextallp2(rightp2); \ 330 Sextallp2(leftp2) = Sextallp2(leftp2) XOR Sextallp2(rightp2) 331 332 #define Sglext_setone_lowmantissap2(value) Deposit_dlowp2(value,1) 333 334 /* The high bit is always zero so arithmetic or logical shifts will work. */ 335 #define Sglext_right_align(srcdstA,srcdstB,shift) \ 336 {int shiftamt, sticky; \ 337 shiftamt = shift % 32; \ 338 sticky = 0; \ 339 switch (shift/32) { \ 340 case 0: if (shiftamt > 0) { \ 341 sticky = Sextallp2(srcdstB) << 32 - (shiftamt); \ 342 Variable_shift_double(Sextallp1(srcdstA), \ 343 Sextallp2(srcdstB),shiftamt,Sextallp2(srcdstB)); \ 344 Sextallp1(srcdstA) >>= shiftamt; \ 345 } \ 346 break; \ 347 case 1: if (shiftamt > 0) { \ 348 sticky = (Sextallp1(srcdstA) << 32 - (shiftamt)) | \ 349 Sextallp2(srcdstB); \ 350 } \ 351 else { \ 352 sticky = Sextallp2(srcdstB); \ 353 } \ 354 Sextallp2(srcdstB) = Sextallp1(srcdstA) >> shiftamt; \ 355 Sextallp1(srcdstA) = 0; \ 356 break; \ 357 } \ 358 if (sticky) Sglext_setone_lowmantissap2(srcdstB); \ 359 } 360 361 /* The left argument is never smaller than the right argument */ 362 #define Sglext_subtract(lefta,leftb,righta,rightb,resulta,resultb) \ 363 if( Sextallp2(rightb) > Sextallp2(leftb) ) Sextallp1(lefta)--; \ 364 Sextallp2(resultb) = Sextallp2(leftb) - Sextallp2(rightb); \ 365 Sextallp1(resulta) = Sextallp1(lefta) - Sextallp1(righta) 366 367 #define Sglext_addition(lefta,leftb,righta,rightb,resulta,resultb) \ 368 /* If the sum of the low words is less than either source, then \ 369 * an overflow into the next word occurred. */ \ 370 if ((Sextallp2(resultb) = Sextallp2(leftb)+Sextallp2(rightb)) < \ 371 Sextallp2(rightb)) \ 372 Sextallp1(resulta) = Sextallp1(lefta)+Sextallp1(righta)+1; \ 373 else Sextallp1(resulta) = Sextallp1(lefta)+Sextallp1(righta) 374 375 376 #define Sglext_arithrightshiftby1(srcdstA,srcdstB) \ 377 Shiftdouble(Sextallp1(srcdstA),Sextallp2(srcdstB),1,Sextallp2(srcdstB)); \ 378 Sextallp1(srcdstA) = (int)Sextallp1(srcdstA) >> 1 379 380 #define Sglext_leftshiftby8(valA,valB) \ 381 Shiftdouble(Sextallp1(valA),Sextallp2(valB),24,Sextallp1(valA)); \ 382 Sextallp2(valB) <<= 8 383 #define Sglext_leftshiftby4(valA,valB) \ 384 Shiftdouble(Sextallp1(valA),Sextallp2(valB),28,Sextallp1(valA)); \ 385 Sextallp2(valB) <<= 4 386 #define Sglext_leftshiftby3(valA,valB) \ 387 Shiftdouble(Sextallp1(valA),Sextallp2(valB),29,Sextallp1(valA)); \ 388 Sextallp2(valB) <<= 3 389 #define Sglext_leftshiftby2(valA,valB) \ 390 Shiftdouble(Sextallp1(valA),Sextallp2(valB),30,Sextallp1(valA)); \ 391 Sextallp2(valB) <<= 2 392 #define Sglext_leftshiftby1(valA,valB) \ 393 Shiftdouble(Sextallp1(valA),Sextallp2(valB),31,Sextallp1(valA)); \ 394 Sextallp2(valB) <<= 1 395 396 #define Sglext_rightshiftby4(valueA,valueB) \ 397 Shiftdouble(Sextallp1(valueA),Sextallp2(valueB),4,Sextallp2(valueB)); \ 398 Sextallp1(valueA) >>= 4 399 #define Sglext_rightshiftby3(valueA,valueB) \ 400 Shiftdouble(Sextallp1(valueA),Sextallp2(valueB),3,Sextallp2(valueB)); \ 401 Sextallp1(valueA) >>= 3 402 #define Sglext_rightshiftby1(valueA,valueB) \ 403 Shiftdouble(Sextallp1(valueA),Sextallp2(valueB),1,Sextallp2(valueB)); \ 404 Sextallp1(valueA) >>= 1 405 406 #define Sglext_xortointp1(left,right,result) Sgl_xortointp1(left,right,result) 407 #define Sglext_xorfromintp1(left,right,result) \ 408 Sgl_xorfromintp1(left,right,result) 409 #define Sglext_copytoint_exponentmantissa(src,dest) \ 410 Sgl_copytoint_exponentmantissa(src,dest) 411 #define Sglext_ismagnitudeless(signlessleft,signlessright) \ 412 Sgl_ismagnitudeless(signlessleft,signlessright) 413 414 #define Sglext_set_sign(dbl_value,sign) Sgl_set_sign(dbl_value,sign) 415 #define Sglext_clear_signexponent_set_hidden(srcdst) \ 416 Sgl_clear_signexponent_set_hidden(srcdst) 417 #define Sglext_clear_signexponent(srcdst) Sgl_clear_signexponent(srcdst) 418 #define Sglext_clear_sign(srcdst) Sgl_clear_sign(srcdst) 419 #define Sglext_isone_hidden(dbl_value) Sgl_isone_hidden(dbl_value) 420 421 #define Sglext_denormalize(opndp1,opndp2,exponent,is_tiny) \ 422 {int sticky; \ 423 is_tiny = TRUE; \ 424 if (exponent == 0 && Sextallp2(opndp2)) { \ 425 switch (Rounding_mode()) { \ 426 case ROUNDPLUS: \ 427 if (Sgl_iszero_sign(opndp1)) \ 428 if (Sgl_isone_hiddenoverflow(opndp1 + 1)) \ 429 is_tiny = FALSE; \ 430 break; \ 431 case ROUNDMINUS: \ 432 if (Sgl_isone_sign(opndp1)) { \ 433 if (Sgl_isone_hiddenoverflow(opndp1 + 1)) \ 434 is_tiny = FALSE; \ 435 } \ 436 break; \ 437 case ROUNDNEAREST: \ 438 if (Sglext_isone_highp2(opndp2) && \ 439 (Sglext_isone_lowp1(opndp1) || \ 440 Sglext_isnotzero_low31p2(opndp2))) \ 441 if (Sgl_isone_hiddenoverflow(opndp1 + 1)) \ 442 is_tiny = FALSE; \ 443 break; \ 444 } \ 445 } \ 446 Sglext_clear_signexponent_set_hidden(opndp1); \ 447 if (exponent >= (1-DBL_P)) { \ 448 if (exponent >= -31) { \ 449 if (exponent > -31) { \ 450 sticky = Sextallp2(opndp2) << 31+exponent; \ 451 Variable_shift_double(opndp1,opndp2,1-exponent,opndp2); \ 452 Sextallp1(opndp1) >>= 1-exponent; \ 453 } \ 454 else { \ 455 sticky = Sextallp2(opndp2); \ 456 Sextallp2(opndp2) = Sextallp1(opndp1); \ 457 Sextallp1(opndp1) = 0; \ 458 } \ 459 } \ 460 else { \ 461 sticky = (Sextallp1(opndp1) << 31+exponent) | \ 462 Sextallp2(opndp2); \ 463 Sextallp2(opndp2) = Sextallp1(opndp1) >> -31-exponent; \ 464 Sextallp1(opndp1) = 0; \ 465 } \ 466 } \ 467 else { \ 468 sticky = Sextallp1(opndp1) | Sextallp2(opndp2); \ 469 Sglext_setzero(opndp1,opndp2); \ 470 } \ 471 if (sticky) Sglext_setone_lowmantissap2(opndp2); \ 472 exponent = 0; \ 473 } 474
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.