Changeset aa59fa0 in mainline for softfloat/generic
- Timestamp:
- 2006-03-16T00:32:41Z (20 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 585819d
- Parents:
- 69cdeec
- Location:
- softfloat/generic
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
softfloat/generic/add.c
r69cdeec raa59fa0 36 36 { 37 37 int expdiff; 38 __u32exp1, exp2,frac1, frac2;38 uint32_t exp1, exp2,frac1, frac2; 39 39 40 40 expdiff = a.parts.exp - b.parts.exp; … … 144 144 { 145 145 int expdiff; 146 __u32exp1, exp2;147 __u64frac1, frac2;146 uint32_t exp1, exp2; 147 uint64_t frac1, frac2; 148 148 149 149 expdiff = ((int )a.parts.exp) - b.parts.exp; -
softfloat/generic/common.c
r69cdeec raa59fa0 57 57 * @return valied float64 58 58 */ 59 float64 finishFloat64( __s32 cexp, __u64cfrac, char sign)59 float64 finishFloat64(int32_t cexp, uint64_t cfrac, char sign) 60 60 { 61 61 float64 result; … … 109 109 } 110 110 111 result.parts.exp = ( __u32)cexp;111 result.parts.exp = (uint32_t)cexp; 112 112 113 113 result.parts.fraction = ((cfrac >>(64 - FLOAT64_FRACTION_SIZE - 2 ) ) & (~FLOAT64_HIDDEN_BIT_MASK)); … … 119 119 * @param i 120 120 */ 121 int countZeroes64( __u64i)121 int countZeroes64(uint64_t i) 122 122 { 123 123 int j; … … 134 134 * @param i 135 135 */ 136 int countZeroes32( __u32i)136 int countZeroes32(uint32_t i) 137 137 { 138 138 int j; … … 149 149 * @param i 150 150 */ 151 int countZeroes8( __u8i)151 int countZeroes8(uint8_t i) 152 152 { 153 153 return zeroTable[i]; … … 158 158 * @param fraction part with hidden bit shifted to 30. bit 159 159 */ 160 void roundFloat32( __s32 *exp, __u32*fraction)160 void roundFloat32(int32_t *exp, uint32_t *fraction) 161 161 { 162 162 /* rounding - if first bit after fraction is set then round up */ … … 183 183 * @param fraction part with hidden bit shifted to 62. bit 184 184 */ 185 void roundFloat64( __s32 *exp, __u64*fraction)185 void roundFloat64(int32_t *exp, uint64_t *fraction) 186 186 { 187 187 /* rounding - if first bit after fraction is set then round up */ -
softfloat/generic/conversion.c
r69cdeec raa59fa0 35 35 { 36 36 float64 result; 37 __u64frac;37 uint64_t frac; 38 38 39 39 result.parts.sign = a.parts.sign; … … 74 74 { 75 75 float32 result; 76 __s32exp;77 __u64frac;76 int32_t exp; 77 uint64_t frac; 78 78 79 79 result.parts.sign = a.parts.sign; … … 84 84 85 85 if (isFloat64SigNaN(a)) { 86 result.parts.fraction = 0x 800000; /* set first bit of fraction nonzero */86 result.parts.fraction = 0x400000; /* set first bit of fraction nonzero */ 87 87 return result; 88 88 } … … 145 145 * @return unsigned integer 146 146 */ 147 static __u32_float32_to_uint32_helper(float32 a)148 { 149 __u32frac;147 static uint32_t _float32_to_uint32_helper(float32 a) 148 { 149 uint32_t frac; 150 150 151 151 if (a.parts.exp < FLOAT32_BIAS) { … … 173 173 * - now its the biggest or the smallest int 174 174 */ 175 __u32float32_to_uint32(float32 a)175 uint32_t float32_to_uint32(float32 a) 176 176 { 177 177 if (isFloat32NaN(a)) { … … 193 193 * - now its the biggest or the smallest int 194 194 */ 195 __s32float32_to_int32(float32 a)195 int32_t float32_to_int32(float32 a) 196 196 { 197 197 if (isFloat32NaN(a)) { … … 213 213 * @return unsigned integer 214 214 */ 215 static __u64_float64_to_uint64_helper(float64 a)216 { 217 __u64frac;215 static uint64_t _float64_to_uint64_helper(float64 a) 216 { 217 uint64_t frac; 218 218 219 219 if (a.parts.exp < FLOAT64_BIAS) { … … 241 241 * - now its the biggest or the smallest int 242 242 */ 243 __u64float64_to_uint64(float64 a)243 uint64_t float64_to_uint64(float64 a) 244 244 { 245 245 if (isFloat64NaN(a)) { … … 261 261 * - now its the biggest or the smallest int 262 262 */ 263 __s64float64_to_int64(float64 a)263 int64_t float64_to_int64(float64 a) 264 264 { 265 265 if (isFloat64NaN(a)) { … … 284 284 * @return unsigned integer 285 285 */ 286 static __u64_float32_to_uint64_helper(float32 a)287 { 288 __u64frac;286 static uint64_t _float32_to_uint64_helper(float32 a) 287 { 288 uint64_t frac; 289 289 290 290 if (a.parts.exp < FLOAT32_BIAS) { … … 312 312 * - now its the biggest or the smallest int 313 313 */ 314 __u64float32_to_uint64(float32 a)314 uint64_t float32_to_uint64(float32 a) 315 315 { 316 316 if (isFloat32NaN(a)) { … … 332 332 * - now its the biggest or the smallest int 333 333 */ 334 __s64float32_to_int64(float32 a)334 int64_t float32_to_int64(float32 a) 335 335 { 336 336 if (isFloat32NaN(a)) { … … 352 352 * - now its the biggest or the smallest int 353 353 */ 354 __u32float64_to_uint32(float64 a)354 uint32_t float64_to_uint32(float64 a) 355 355 { 356 356 if (isFloat64NaN(a)) { … … 365 365 } 366 366 367 return ( __u32)_float64_to_uint64_helper(a);367 return (uint32_t)_float64_to_uint64_helper(a); 368 368 } 369 369 … … 372 372 * - now its the biggest or the smallest int 373 373 */ 374 __s32float64_to_int32(float64 a)374 int32_t float64_to_int32(float64 a) 375 375 { 376 376 if (isFloat64NaN(a)) { … … 384 384 return MAX_INT32; 385 385 } 386 return ( __s32)_float64_to_uint64_helper(a);386 return (int32_t)_float64_to_uint64_helper(a); 387 387 } 388 388 … … 391 391 * 392 392 */ 393 float32 uint32_to_float32( __u32i)393 float32 uint32_to_float32(uint32_t i) 394 394 { 395 395 int counter; 396 __s32exp;396 int32_t exp; 397 397 float32 result; 398 398 … … 423 423 } 424 424 425 float32 int32_to_float32( __s32i)425 float32 int32_to_float32(int32_t i) 426 426 { 427 427 float32 result; 428 428 429 429 if (i < 0) { 430 result = uint32_to_float32(( __u32)(-i));431 } else { 432 result = uint32_to_float32(( __u32)i);430 result = uint32_to_float32((uint32_t)(-i)); 431 } else { 432 result = uint32_to_float32((uint32_t)i); 433 433 } 434 434 … … 439 439 440 440 441 float32 uint64_to_float32( __u64i)441 float32 uint64_to_float32(uint64_t i) 442 442 { 443 443 int counter; 444 __s32 exp; 444 int32_t exp; 445 int32_t j; 445 446 float32 result; 446 447 … … 463 464 i >>= 1 + 32 - counter; 464 465 } 465 466 roundFloat32(&exp, &i); 467 468 result.parts.fraction = i >> 7; 466 467 j = (uint32_t)i; 468 roundFloat32(&exp, &j); 469 470 result.parts.fraction = j >> 7; 469 471 result.parts.exp = exp; 470 472 return result; 471 473 } 472 474 473 float32 int64_to_float32( __s64i)475 float32 int64_to_float32(int64_t i) 474 476 { 475 477 float32 result; 476 478 477 479 if (i < 0) { 478 result = uint64_to_float32(( __u64)(-i));479 } else { 480 result = uint64_to_float32(( __u64)i);480 result = uint64_to_float32((uint64_t)(-i)); 481 } else { 482 result = uint64_to_float32((uint64_t)i); 481 483 } 482 484 … … 490 492 * 491 493 */ 492 float64 uint32_to_float64( __u32i)494 float64 uint32_to_float64(uint32_t i) 493 495 { 494 496 int counter; 495 __s32exp;497 int32_t exp; 496 498 float64 result; 497 __u64frac;499 uint64_t frac; 498 500 499 501 result.parts.sign = 0; … … 520 522 } 521 523 522 float64 int32_to_float64( __s32i)524 float64 int32_to_float64(int32_t i) 523 525 { 524 526 float64 result; 525 527 526 528 if (i < 0) { 527 result = uint32_to_float64(( __u32)(-i));528 } else { 529 result = uint32_to_float64(( __u32)i);529 result = uint32_to_float64((uint32_t)(-i)); 530 } else { 531 result = uint32_to_float64((uint32_t)i); 530 532 } 531 533 … … 536 538 537 539 538 float64 uint64_to_float64( __u64i)540 float64 uint64_to_float64(uint64_t i) 539 541 { 540 542 int counter; 541 __s32exp;543 int32_t exp; 542 544 float64 result; 543 545 … … 567 569 } 568 570 569 float64 int64_to_float64( __s64i)571 float64 int64_to_float64(int64_t i) 570 572 { 571 573 float64 result; 572 574 573 575 if (i < 0) { 574 result = uint64_to_float64(( __u64)(-i));575 } else { 576 result = uint64_to_float64(( __u64)i);576 result = uint64_to_float64((uint64_t)(-i)); 577 } else { 578 result = uint64_to_float64((uint64_t)i); 577 579 } 578 580 -
softfloat/generic/div.c
r69cdeec raa59fa0 38 38 { 39 39 float32 result; 40 __s32aexp, bexp, cexp;41 __u64afrac, bfrac, cfrac;40 int32_t aexp, bexp, cexp; 41 uint64_t afrac, bfrac, cfrac; 42 42 43 43 result.parts.sign = a.parts.sign ^ b.parts.sign; … … 181 181 182 182 } else { 183 result.parts.exp = ( __u32)cexp;183 result.parts.exp = (uint32_t)cexp; 184 184 } 185 185 … … 192 192 { 193 193 float64 result; 194 __s64aexp, bexp, cexp;195 __u64afrac, bfrac, cfrac;196 __u64remlo, remhi;194 int64_t aexp, bexp, cexp; 195 uint64_t afrac, bfrac, cfrac; 196 uint64_t remlo, remhi; 197 197 198 198 result.parts.sign = a.parts.sign ^ b.parts.sign; … … 307 307 remlo = - remlo; 308 308 309 while (( __s64) remhi < 0) {309 while ((int64_t) remhi < 0) { 310 310 cfrac--; 311 311 remlo += bfrac; … … 321 321 } 322 322 323 __u64 divFloat64estim(__u64 a, __u64b)323 uint64_t divFloat64estim(uint64_t a, uint64_t b) 324 324 { 325 __u64bhi;326 __u64remhi, remlo;327 __u64result;325 uint64_t bhi; 326 uint64_t remhi, remlo; 327 uint64_t result; 328 328 329 329 if ( b <= a ) { … … 339 339 340 340 b <<= 32; 341 while ( ( __s64) remhi < 0 ) {341 while ( (int64_t) remhi < 0 ) { 342 342 result -= 0x1ll << 32; 343 343 remlo += b; -
softfloat/generic/mul.c
r69cdeec raa59fa0 38 38 { 39 39 float32 result; 40 __u64frac1, frac2;41 __s32exp;40 uint64_t frac1, frac2; 41 int32_t exp; 42 42 43 43 result.parts.sign = a.parts.sign ^ b.parts.sign; … … 174 174 { 175 175 float64 result; 176 __u64frac1, frac2;177 __s32exp;176 uint64_t frac1, frac2; 177 int32_t exp; 178 178 179 179 result.parts.sign = a.parts.sign ^ b.parts.sign; … … 258 258 * @param hi higher part of result 259 259 */ 260 void mul64integers( __u64 a,__u64 b, __u64 *lo, __u64*hi)260 void mul64integers(uint64_t a,uint64_t b, uint64_t *lo, uint64_t *hi) 261 261 { 262 __u64low, high, middle1, middle2;263 __u32alow, blow;262 uint64_t low, high, middle1, middle2; 263 uint32_t alow, blow; 264 264 265 265 alow = a & 0xFFFFFFFF; … … 269 269 b >>= 32; 270 270 271 low = (( __u64)alow) * blow;271 low = ((uint64_t)alow) * blow; 272 272 middle1 = a * blow; 273 273 middle2 = alow * b; … … 275 275 276 276 middle1 += middle2; 277 high += ((( __u64)(middle1 < middle2)) << 32) + (middle1 >> 32);277 high += (((uint64_t)(middle1 < middle2)) << 32) + (middle1 >> 32); 278 278 middle1 <<= 32; 279 279 low += middle1; -
softfloat/generic/softfloat.c
r69cdeec raa59fa0 39 39 #include<other.h> 40 40 41 #include<arch.h>42 #include<types.h>43 41 #include<functions.h> 44 42 … … 485 483 } 486 484 487 float __mulsc3(float a, float b, float c, float d)488 {489 /* TODO: */490 }491 492 float __divsc3(float a, float b, float c, float d)493 {494 /* TODO: */495 }496 -
softfloat/generic/sub.c
r69cdeec raa59fa0 36 36 { 37 37 int expdiff; 38 __u32exp1, exp2, frac1, frac2;38 uint32_t exp1, exp2, frac1, frac2; 39 39 float32 result; 40 40 … … 147 147 { 148 148 int expdiff; 149 __u32exp1, exp2;150 __u64frac1, frac2;149 uint32_t exp1, exp2; 150 uint64_t frac1, frac2; 151 151 float64 result; 152 152
Note:
See TracChangeset
for help on using the changeset viewer.
