VirtualBox

Changeset 37675 in vbox for trunk/src/recompiler/fpu


Ignore:
Timestamp:
Jun 29, 2011 7:07:14 AM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
72535
Message:

rem: Synced with v0.12.5.

Location:
trunk/src/recompiler/fpu
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/recompiler/fpu/softfloat-native.c

    r36175 r37675  
    33#include "softfloat.h"
    44#include <math.h>
    5 #if defined(HOST_SOLARIS)
     5#if defined(CONFIG_SOLARIS)
    66#include <fenv.h>
    77#endif
     
    1010{
    1111    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 */
    1414    fpsetround(val);
    1515#elif defined(__arm__)
     
    2727#endif
    2828
    29 #if defined(HOST_BSD) || (defined(HOST_SOLARIS) && HOST_SOLARIS < 10)
     29#if defined(CONFIG_BSD) || \
     30    (defined(CONFIG_SOLARIS) && CONFIG_SOLARIS_VERSION < 10)
    3031#define lrint(d)                ((int32_t)rint(d))
    3132#define llrint(d)               ((int64_t)rint(d))
     
    4344#  define remainderl(fa, fb)   (remainder(fa, fb))
    4445# 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)
    4748extern long double rintl(long double);
    4849extern long double scalbnl(long double, int);
     
    359360| Software IEC/IEEE double-precision operations.
    360361*----------------------------------------------------------------------------*/
    361 #if defined(__sun__) && defined(HOST_SOLARIS) && HOST_SOLARIS < 10
     362#if defined(__sun__) && \
     363    (defined(CONFIG_SOLARIS) && CONFIG_SOLARIS_VERSION < 10)
    362364static inline float64 trunc(float64 x)
    363365{
  • trunk/src/recompiler/fpu/softfloat-native.h

    r36414 r37675  
    2020 *   are defined in <iso/math_c99.h> with a compiler directive
    2121 */
    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))) \
    2425    || (defined(__OpenBSD__) && (OpenBSD < 200811))
    2526/*
     
    6263#endif
    6364
    64 #if defined(__sun__) && !defined(NEED_LIBSUNMATH)
     65#if defined(__sun__) && !defined(CONFIG_NEEDS_LIBSUNMATH)
    6566
    6667#ifndef isnan
     
    112113| Software IEC/IEEE floating-point rounding mode.
    113114*----------------------------------------------------------------------------*/
    114 #if (defined(HOST_BSD) && !defined(__APPLE__)) || defined(HOST_SOLARIS)
     115#if (defined(CONFIG_BSD) && !defined(__APPLE__) && !defined(__GLIBC__)) \
     116    || defined(CONFIG_SOLARIS)
    115117#if defined(__OpenBSD__)
    116118#define FE_RM FP_RM
  • trunk/src/recompiler/fpu/softfloat.c

    r36170 r37675  
    24562456    return roundAndPackFloat32( aSign, aExp, zSig STATUS_VAR );
    24572457
     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*----------------------------------------------------------------------------*/
     2471static 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
     2479float32 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
     2511bits16 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);
    24582596}
    24592597
  • trunk/src/recompiler/fpu/softfloat.h

    r36175 r37675  
    3737#endif
    3838
    39 #if defined(HOST_SOLARIS) && defined(NEEDS_LIBSUNMATH)
     39#if defined(CONFIG_SOLARIS) && defined(CONFIG_NEEDS_LIBSUNMATH)
    4040#include <sunmath.h>
    4141#endif
     
    9595#else
    9696/* 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 */
    9898#define FLOATX80
    9999#endif
     
    155155#ifdef FLOAT128
    156156typedef struct {
    157 #ifdef WORDS_BIGENDIAN
     157#ifdef HOST_WORDS_BIGENDIAN
    158158    uint64_t high, low;
    159159#else
     
    250250float128 int64_to_float128( int64_t STATUS_PARAM );
    251251#endif
     252
     253/*----------------------------------------------------------------------------
     254| Software half-precision conversion routines.
     255*----------------------------------------------------------------------------*/
     256bits16 float32_to_float16( float32, flag STATUS_PARAM );
     257float32 float16_to_float32( bits16, flag STATUS_PARAM );
    252258
    253259/*----------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette