VirtualBox

Changeset 94568 in vbox


Ignore:
Timestamp:
Apr 12, 2022 9:38:06 AM (3 years ago)
Author:
vboxsync
Message:

VMM/IEM: C implementation of fxtract helper. bugref:9898

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/IEMAllAImplC.cpp

    r94567 r94568  
    450450extern const RTFLOAT80U  g_ar80One[];
    451451extern const RTFLOAT80U  g_r80Indefinite;
     452extern const RTFLOAT80U  g_r80Infinity;
    452453extern const RTFLOAT128U g_r128Ln2;
    453454extern const RTUINT128U  g_u128Ln2Mantissa;
     
    464465/** Indefinite (negative). */
    465466RTFLOAT80U const g_r80Indefinite = RTFLOAT80U_INIT_INDEFINITE(1);
     467
     468/** Infinities (indexed by fSign). */
     469RTFLOAT80U const g_ar80Infinity[] = { RTFLOAT80U_INIT_INF(0), RTFLOAT80U_INIT_INF(1) };
    466470
    467471#if 0
     
    56385642IEM_DECL_IMPL_DEF(void, iemAImpl_fxtract_r80_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULTTWO pFpuResTwo, PCRTFLOAT80U pr80Val))
    56395643{
    5640     RT_NOREF(pFpuState, pFpuResTwo, pr80Val);
    5641     AssertReleaseFailed();
     5644    uint16_t const fFcw = pFpuState->FCW;
     5645    uint16_t fFsw       = (pFpuState->FSW & (X86_FSW_C0 | X86_FSW_C2 | X86_FSW_C3)) | (6 << X86_FSW_TOP_SHIFT);
     5646
     5647    if (RTFLOAT80U_IS_NORMAL(pr80Val))
     5648    {
     5649        softfloat_state_t Ignored = SOFTFLOAT_STATE_INIT_DEFAULTS();
     5650        iemFpuSoftF80ToIprt(&pFpuResTwo->r80Result1, i32_to_extF80((int32_t)pr80Val->s.uExponent - RTFLOAT80U_EXP_BIAS, &Ignored));
     5651
     5652        pFpuResTwo->r80Result2.s.fSign     = pr80Val->s.fSign;
     5653        pFpuResTwo->r80Result2.s.uExponent = RTFLOAT80U_EXP_BIAS;
     5654        pFpuResTwo->r80Result2.s.uMantissa = pr80Val->s.uMantissa;
     5655    }
     5656    else if (RTFLOAT80U_IS_ZERO(pr80Val))
     5657    {
     5658        fFsw |= X86_FSW_ZE;
     5659        if (fFcw & X86_FCW_ZM)
     5660        {
     5661            pFpuResTwo->r80Result1 = g_ar80Infinity[1];
     5662            pFpuResTwo->r80Result2 = *pr80Val;
     5663        }
     5664        else
     5665        {
     5666            pFpuResTwo->r80Result2 = *pr80Val;
     5667            fFsw = X86_FSW_ES | X86_FSW_B | (fFsw & ~X86_FSW_TOP_MASK) | (7 << X86_FSW_TOP_SHIFT);
     5668        }
     5669    }
     5670    else if (RTFLOAT80U_IS_DENORMAL_OR_PSEUDO_DENORMAL(pr80Val))
     5671    {
     5672        fFsw |= X86_FSW_DE;
     5673        if (fFcw & X86_FCW_DM)
     5674        {
     5675            pFpuResTwo->r80Result2.s.fSign     = pr80Val->s.fSign;
     5676            pFpuResTwo->r80Result2.s.uExponent = RTFLOAT80U_EXP_BIAS;
     5677            pFpuResTwo->r80Result2.s.uMantissa = pr80Val->s.uMantissa;
     5678            int32_t iExponent = -16382;
     5679            while (!(pFpuResTwo->r80Result2.s.uMantissa & RT_BIT_64(63)))
     5680            {
     5681                pFpuResTwo->r80Result2.s.uMantissa <<= 1;
     5682                iExponent--;
     5683            }
     5684
     5685            softfloat_state_t Ignored = SOFTFLOAT_STATE_INIT_DEFAULTS();
     5686            iemFpuSoftF80ToIprt(&pFpuResTwo->r80Result1, i32_to_extF80(iExponent, &Ignored));
     5687        }
     5688        else
     5689        {
     5690            pFpuResTwo->r80Result2 = *pr80Val;
     5691            fFsw = X86_FSW_ES | X86_FSW_B | (fFsw & ~X86_FSW_TOP_MASK) | (7 << X86_FSW_TOP_SHIFT);
     5692        }
     5693    }
     5694    else if (   RTFLOAT80U_IS_QUIET_NAN(pr80Val)
     5695             || RTFLOAT80U_IS_INDEFINITE(pr80Val))
     5696    {
     5697        pFpuResTwo->r80Result1 = *pr80Val;
     5698        pFpuResTwo->r80Result2 = *pr80Val;
     5699    }
     5700    else if (RTFLOAT80U_IS_INF(pr80Val))
     5701    {
     5702        pFpuResTwo->r80Result1 = g_ar80Infinity[0];
     5703        pFpuResTwo->r80Result2 = *pr80Val;
     5704    }
     5705    else
     5706    {
     5707        if (fFcw & X86_FCW_IM)
     5708        {
     5709            if (!RTFLOAT80U_IS_SIGNALLING_NAN(pr80Val))
     5710                pFpuResTwo->r80Result1 = g_r80Indefinite;
     5711            else
     5712            {
     5713                pFpuResTwo->r80Result1 = *pr80Val;
     5714                pFpuResTwo->r80Result1.s.uMantissa |= RT_BIT_64(62); /* make it quiet */
     5715            }
     5716            pFpuResTwo->r80Result2 = pFpuResTwo->r80Result1;
     5717        }
     5718        else
     5719        {
     5720            pFpuResTwo->r80Result2 = *pr80Val;
     5721            fFsw = X86_FSW_ES | X86_FSW_B | (fFsw & ~X86_FSW_TOP_MASK) | (7 << X86_FSW_TOP_SHIFT);
     5722        }
     5723        fFsw |= X86_FSW_IE;
     5724    }
     5725    pFpuResTwo->FSW = fFsw;
    56425726}
    56435727
Note: See TracChangeset for help on using the changeset viewer.

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