Changeset 37675 in vbox for trunk/src/recompiler/fpu
- Timestamp:
- Jun 29, 2011 7:07:14 AM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 72535
- Location:
- trunk/src/recompiler/fpu
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/recompiler/fpu/softfloat-native.c
r36175 r37675 3 3 #include "softfloat.h" 4 4 #include <math.h> 5 #if defined( HOST_SOLARIS)5 #if defined(CONFIG_SOLARIS) 6 6 #include <fenv.h> 7 7 #endif … … 10 10 { 11 11 STATUS(float_rounding_mode) = val; 12 #if defined(HOST_BSD) && !defined(__APPLE__) ||\13 (defined( HOST_SOLARIS) && (HOST_SOLARIS < 10 || HOST_SOLARIS== 11)) /* VBOX adds sol 11 */12 #if (defined(CONFIG_BSD) && !defined(__APPLE__) && !defined(__GLIBC__)) || \ 13 (defined(CONFIG_SOLARIS) && (CONFIG_SOLARIS_VERSION < 10 || CONFIG_SOLARIS_VERSION == 11)) /* VBOX adds sol 11 */ 14 14 fpsetround(val); 15 15 #elif defined(__arm__) … … 27 27 #endif 28 28 29 #if defined(HOST_BSD) || (defined(HOST_SOLARIS) && HOST_SOLARIS < 10) 29 #if defined(CONFIG_BSD) || \ 30 (defined(CONFIG_SOLARIS) && CONFIG_SOLARIS_VERSION < 10) 30 31 #define lrint(d) ((int32_t)rint(d)) 31 32 #define llrint(d) ((int64_t)rint(d)) … … 43 44 # define remainderl(fa, fb) (remainder(fa, fb)) 44 45 # endif /* VBOX && _BSD */ 45 46 #if !defined(__sparc__) && defined(HOST_SOLARIS) && HOST_SOLARIS < 10 46 #if !defined(__sparc__) && \ 47 (defined(CONFIG_SOLARIS) && CONFIG_SOLARIS_VERSION < 10) 47 48 extern long double rintl(long double); 48 49 extern long double scalbnl(long double, int); … … 359 360 | Software IEC/IEEE double-precision operations. 360 361 *----------------------------------------------------------------------------*/ 361 #if defined(__sun__) && defined(HOST_SOLARIS) && HOST_SOLARIS < 10 362 #if defined(__sun__) && \ 363 (defined(CONFIG_SOLARIS) && CONFIG_SOLARIS_VERSION < 10) 362 364 static inline float64 trunc(float64 x) 363 365 { -
trunk/src/recompiler/fpu/softfloat-native.h
r36414 r37675 20 20 * are defined in <iso/math_c99.h> with a compiler directive 21 21 */ 22 #if defined(HOST_SOLARIS) && (( HOST_SOLARIS <= 9 ) || ((HOST_SOLARIS >= 10) \ 23 && (__GNUC__ < 4))) \ 22 #if defined(CONFIG_SOLARIS) && \ 23 ((CONFIG_SOLARIS_VERSION <= 9 ) || \ 24 ((CONFIG_SOLARIS_VERSION >= 10) && (__GNUC__ < 4))) \ 24 25 || (defined(__OpenBSD__) && (OpenBSD < 200811)) 25 26 /* … … 62 63 #endif 63 64 64 #if defined(__sun__) && !defined( NEED_LIBSUNMATH)65 #if defined(__sun__) && !defined(CONFIG_NEEDS_LIBSUNMATH) 65 66 66 67 #ifndef isnan … … 112 113 | Software IEC/IEEE floating-point rounding mode. 113 114 *----------------------------------------------------------------------------*/ 114 #if (defined(HOST_BSD) && !defined(__APPLE__)) || defined(HOST_SOLARIS) 115 #if (defined(CONFIG_BSD) && !defined(__APPLE__) && !defined(__GLIBC__)) \ 116 || defined(CONFIG_SOLARIS) 115 117 #if defined(__OpenBSD__) 116 118 #define FE_RM FP_RM -
trunk/src/recompiler/fpu/softfloat.c
r36170 r37675 2456 2456 return roundAndPackFloat32( aSign, aExp, zSig STATUS_VAR ); 2457 2457 2458 } 2459 2460 2461 /*---------------------------------------------------------------------------- 2462 | Packs the sign `zSign', exponent `zExp', and significand `zSig' into a 2463 | half-precision floating-point value, returning the result. After being 2464 | shifted into the proper positions, the three fields are simply added 2465 | together to form the result. This means that any integer portion of `zSig' 2466 | will be added into the exponent. Since a properly normalized significand 2467 | will have an integer portion equal to 1, the `zExp' input should be 1 less 2468 | than the desired result exponent whenever `zSig' is a complete, normalized 2469 | significand. 2470 *----------------------------------------------------------------------------*/ 2471 static bits16 packFloat16(flag zSign, int16 zExp, bits16 zSig) 2472 { 2473 return (((bits32)zSign) << 15) + (((bits32)zExp) << 10) + zSig; 2474 } 2475 2476 /* Half precision floats come in two formats: standard IEEE and "ARM" format. 2477 The latter gains extra exponent range by omitting the NaN/Inf encodings. */ 2478 2479 float32 float16_to_float32( bits16 a, flag ieee STATUS_PARAM ) 2480 { 2481 flag aSign; 2482 int16 aExp; 2483 bits32 aSig; 2484 2485 aSign = a >> 15; 2486 aExp = (a >> 10) & 0x1f; 2487 aSig = a & 0x3ff; 2488 2489 if (aExp == 0x1f && ieee) { 2490 if (aSig) { 2491 /* Make sure correct exceptions are raised. */ 2492 float32ToCommonNaN(a STATUS_VAR); 2493 aSig |= 0x200; 2494 } 2495 return packFloat32(aSign, 0xff, aSig << 13); 2496 } 2497 if (aExp == 0) { 2498 int8 shiftCount; 2499 2500 if (aSig == 0) { 2501 return packFloat32(aSign, 0, 0); 2502 } 2503 2504 shiftCount = countLeadingZeros32( aSig ) - 21; 2505 aSig = aSig << shiftCount; 2506 aExp = -shiftCount; 2507 } 2508 return packFloat32( aSign, aExp + 0x70, aSig << 13); 2509 } 2510 2511 bits16 float32_to_float16( float32 a, flag ieee STATUS_PARAM) 2512 { 2513 flag aSign; 2514 int16 aExp; 2515 bits32 aSig; 2516 bits32 mask; 2517 bits32 increment; 2518 int8 roundingMode; 2519 2520 aSig = extractFloat32Frac( a ); 2521 aExp = extractFloat32Exp( a ); 2522 aSign = extractFloat32Sign( a ); 2523 if ( aExp == 0xFF ) { 2524 if (aSig) { 2525 /* Make sure correct exceptions are raised. */ 2526 float32ToCommonNaN(a STATUS_VAR); 2527 aSig |= 0x00400000; 2528 } 2529 return packFloat16(aSign, 0x1f, aSig >> 13); 2530 } 2531 if (aExp == 0 && aSign == 0) { 2532 return packFloat16(aSign, 0, 0); 2533 } 2534 /* Decimal point between bits 22 and 23. */ 2535 aSig |= 0x00800000; 2536 aExp -= 0x7f; 2537 if (aExp < -14) { 2538 mask = 0x007fffff; 2539 if (aExp < -24) { 2540 aExp = -25; 2541 } else { 2542 mask >>= 24 + aExp; 2543 } 2544 } else { 2545 mask = 0x00001fff; 2546 } 2547 if (aSig & mask) { 2548 float_raise( float_flag_underflow STATUS_VAR ); 2549 roundingMode = STATUS(float_rounding_mode); 2550 switch (roundingMode) { 2551 case float_round_nearest_even: 2552 increment = (mask + 1) >> 1; 2553 if ((aSig & mask) == increment) { 2554 increment = aSig & (increment << 1); 2555 } 2556 break; 2557 case float_round_up: 2558 increment = aSign ? 0 : mask; 2559 break; 2560 case float_round_down: 2561 increment = aSign ? mask : 0; 2562 break; 2563 default: /* round_to_zero */ 2564 increment = 0; 2565 break; 2566 } 2567 aSig += increment; 2568 if (aSig >= 0x01000000) { 2569 aSig >>= 1; 2570 aExp++; 2571 } 2572 } else if (aExp < -14 2573 && STATUS(float_detect_tininess) == float_tininess_before_rounding) { 2574 float_raise( float_flag_underflow STATUS_VAR); 2575 } 2576 2577 if (ieee) { 2578 if (aExp > 15) { 2579 float_raise( float_flag_overflow | float_flag_inexact STATUS_VAR); 2580 return packFloat16(aSign, 0x1f, 0); 2581 } 2582 } else { 2583 if (aExp > 16) { 2584 float_raise( float_flag_overflow | float_flag_inexact STATUS_VAR); 2585 return packFloat16(aSign, 0x1f, 0x3ff); 2586 } 2587 } 2588 if (aExp < -24) { 2589 return packFloat16(aSign, 0, 0); 2590 } 2591 if (aExp < -14) { 2592 aSig >>= -14 - aExp; 2593 aExp = -14; 2594 } 2595 return packFloat16(aSign, aExp + 14, aSig >> 13); 2458 2596 } 2459 2597 -
trunk/src/recompiler/fpu/softfloat.h
r36175 r37675 37 37 #endif 38 38 39 #if defined( HOST_SOLARIS) && defined(NEEDS_LIBSUNMATH)39 #if defined(CONFIG_SOLARIS) && defined(CONFIG_NEEDS_LIBSUNMATH) 40 40 #include <sunmath.h> 41 41 #endif … … 95 95 #else 96 96 /* native float support */ 97 #if (defined(__i386__) || defined(__x86_64__)) && (!defined( HOST_BSD) || defined(VBOX)) /** @todo VBOX: not correct on windows */97 #if (defined(__i386__) || defined(__x86_64__)) && (!defined(CONFIG_BSD) || defined(VBOX)) /** @todo VBOX: not correct on windows */ 98 98 #define FLOATX80 99 99 #endif … … 155 155 #ifdef FLOAT128 156 156 typedef struct { 157 #ifdef WORDS_BIGENDIAN157 #ifdef HOST_WORDS_BIGENDIAN 158 158 uint64_t high, low; 159 159 #else … … 250 250 float128 int64_to_float128( int64_t STATUS_PARAM ); 251 251 #endif 252 253 /*---------------------------------------------------------------------------- 254 | Software half-precision conversion routines. 255 *----------------------------------------------------------------------------*/ 256 bits16 float32_to_float16( float32, flag STATUS_PARAM ); 257 float32 float16_to_float32( bits16, flag STATUS_PARAM ); 252 258 253 259 /*----------------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.