VirtualBox

Changeset 96333 in vbox


Ignore:
Timestamp:
Aug 19, 2022 11:37:07 AM (2 years ago)
Author:
vboxsync
Message:

VMM/IEM: Implement divps/divpd instructions, bugref:9898

Location:
trunk/src/VBox/VMM
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/IEMAllAImpl.asm

    r96331 r96333  
    45934593IEMIMPL_FP_F2 minps
    45944594IEMIMPL_FP_F2 minpd
     4595IEMIMPL_FP_F2 divps
     4596IEMIMPL_FP_F2 divpd
  • trunk/src/VBox/VMM/VMMAll/IEMAllAImplC.cpp

    r96331 r96333  
    453453extern const RTFLOAT80U  g_ar80One[];
    454454extern const RTFLOAT80U  g_r80Indefinite;
     455extern const RTFLOAT32U  g_ar32Infinity[];
     456extern const RTFLOAT64U  g_ar64Infinity[];
    455457extern const RTFLOAT80U  g_ar80Infinity[];
    456458extern const RTFLOAT128U g_r128Ln2;
     
    458460extern const RTUINT128U  g_u128Ln2MantissaIntel;
    459461extern const RTFLOAT128U g_ar128F2xm1HornerConsts[];
     462extern const RTFLOAT32U  g_ar32QNaN[];
     463extern const RTFLOAT64U  g_ar64QNaN[];
    460464
    461465/** Zero values (indexed by fSign). */
     
    472476
    473477/** Infinities (indexed by fSign). */
     478RTFLOAT32U const g_ar32Infinity[] = { RTFLOAT32U_INIT_INF(0), RTFLOAT32U_INIT_INF(1) };
     479RTFLOAT64U const g_ar64Infinity[] = { RTFLOAT64U_INIT_INF(0), RTFLOAT64U_INIT_INF(1) };
    474480RTFLOAT80U const g_ar80Infinity[] = { RTFLOAT80U_INIT_INF(0), RTFLOAT80U_INIT_INF(1) };
     481
     482/** Default QNaNs (indexed by fSign). */
     483RTFLOAT32U const g_ar32QNaN[] = { RTFLOAT32U_INIT_QNAN(0), RTFLOAT32U_INIT_QNAN(1) };
     484RTFLOAT64U const g_ar64QNaN[] = { RTFLOAT64U_INIT_QNAN(0), RTFLOAT64U_INIT_QNAN(1) };
     485
    475486
    476487#if 0
     
    1438414395}
    1438514396#endif
     14397
     14398
     14399/**
     14400 * DIVPS
     14401 */
     14402#ifdef IEM_WITHOUT_ASSEMBLY
     14403static uint32_t iemAImpl_divps_u128_worker(PRTFLOAT32U pr32Res, uint32_t fMxcsr, PCRTFLOAT32U pr32Val1, PCRTFLOAT32U pr32Val2)
     14404{
     14405    if (iemSseBinaryValIsNaNR32(pr32Res, pr32Val1, pr32Val2, &fMxcsr))
     14406        return fMxcsr;
     14407
     14408    RTFLOAT32U r32Src1, r32Src2;
     14409    iemSsePrepareValueR32(&r32Src1, fMxcsr, pr32Val1);
     14410    iemSsePrepareValueR32(&r32Src2, fMxcsr, pr32Val2);
     14411
     14412    if (RTFLOAT32U_IS_ZERO(&r32Src2))
     14413    {
     14414        if (   RTFLOAT32U_IS_ZERO(&r32Src1)
     14415            || RTFLOAT32U_IS_QUIET_NAN(&r32Src1))
     14416        {
     14417            *pr32Res = g_ar32QNaN[1];
     14418            return fMxcsr | X86_MXCSR_IE;
     14419        }
     14420        else if (RTFLOAT32U_IS_INF(&r32Src1))
     14421        {
     14422            *pr32Res = g_ar32Infinity[r32Src1.s.fSign != r32Src2.s.fSign];
     14423            return fMxcsr;
     14424        }
     14425        else
     14426        {
     14427            *pr32Res = g_ar32Infinity[r32Src1.s.fSign != r32Src2.s.fSign];
     14428            return fMxcsr | X86_MXCSR_ZE;
     14429        }
     14430    }
     14431
     14432    softfloat_state_t SoftState = IEM_SOFTFLOAT_STATE_INITIALIZER_FROM_MXCSR(fMxcsr);
     14433    float32_t r32Result = f32_div(iemFpSoftF32FromIprt(&r32Src1), iemFpSoftF32FromIprt(&r32Src2), &SoftState);
     14434    return iemSseSoftStateAndR32ToMxcsrAndIprtResult(&SoftState, r32Result, pr32Res, fMxcsr, &r32Src1, &r32Src2);
     14435}
     14436
     14437
     14438IEM_DECL_IMPL_DEF(void, iemAImpl_divps_u128,(PX86FXSTATE pFpuState, PIEMSSERESULT pResult, PCX86XMMREG puSrc1, PCX86XMMREG puSrc2))
     14439{
     14440    pResult->MXCSR |= iemAImpl_divps_u128_worker(&pResult->uResult.ar32[0], pFpuState->MXCSR, &puSrc1->ar32[0], &puSrc2->ar32[0]);
     14441    pResult->MXCSR |= iemAImpl_divps_u128_worker(&pResult->uResult.ar32[1], pFpuState->MXCSR, &puSrc1->ar32[1], &puSrc2->ar32[1]);
     14442    pResult->MXCSR |= iemAImpl_divps_u128_worker(&pResult->uResult.ar32[2], pFpuState->MXCSR, &puSrc1->ar32[2], &puSrc2->ar32[2]);
     14443    pResult->MXCSR |= iemAImpl_divps_u128_worker(&pResult->uResult.ar32[3], pFpuState->MXCSR, &puSrc1->ar32[3], &puSrc2->ar32[3]);
     14444}
     14445#endif
     14446
     14447
     14448/**
     14449 * DIVPD
     14450 */
     14451#ifdef IEM_WITHOUT_ASSEMBLY
     14452static uint32_t iemAImpl_divpd_u128_worker(PRTFLOAT64U pr64Res, uint32_t fMxcsr, PCRTFLOAT64U pr64Val1, PCRTFLOAT64U pr64Val2)
     14453{
     14454    if (iemSseBinaryValIsNaNR64(pr64Res, pr64Val1, pr64Val2, &fMxcsr))
     14455        return fMxcsr;
     14456
     14457    RTFLOAT64U r64Src1, r64Src2;
     14458    iemSsePrepareValueR64(&r64Src1, fMxcsr, pr64Val1);
     14459    iemSsePrepareValueR64(&r64Src2, fMxcsr, pr64Val2);
     14460
     14461    if (RTFLOAT64U_IS_ZERO(&r64Src2))
     14462    {
     14463        if (   RTFLOAT64U_IS_ZERO(&r64Src1)
     14464            || RTFLOAT64U_IS_QUIET_NAN(&r64Src1))
     14465        {
     14466            *pr64Res = g_ar64QNaN[1];
     14467            return fMxcsr | X86_MXCSR_IE;
     14468        }
     14469        else if (RTFLOAT64U_IS_INF(&r64Src1))
     14470        {
     14471            *pr64Res = g_ar64Infinity[r64Src1.s.fSign != r64Src2.s.fSign];
     14472            return fMxcsr;
     14473        }
     14474        else
     14475        {
     14476            *pr64Res = g_ar64Infinity[r64Src1.s.fSign != r64Src2.s.fSign];
     14477            return fMxcsr | X86_MXCSR_ZE;
     14478        }
     14479    }
     14480
     14481    softfloat_state_t SoftState = IEM_SOFTFLOAT_STATE_INITIALIZER_FROM_MXCSR(fMxcsr);
     14482    float64_t r64Result = f64_div(iemFpSoftF64FromIprt(&r64Src1), iemFpSoftF64FromIprt(&r64Src2), &SoftState);
     14483    return iemSseSoftStateAndR64ToMxcsrAndIprtResult(&SoftState, r64Result, pr64Res, fMxcsr, &r64Src1, &r64Src2);
     14484}
     14485
     14486
     14487IEM_DECL_IMPL_DEF(void, iemAImpl_divpd_u128,(PX86FXSTATE pFpuState, PIEMSSERESULT pResult, PCX86XMMREG puSrc1, PCX86XMMREG puSrc2))
     14488{
     14489    pResult->MXCSR |= iemAImpl_divpd_u128_worker(&pResult->uResult.ar64[0], pFpuState->MXCSR, &puSrc1->ar64[0], &puSrc2->ar64[0]);
     14490    pResult->MXCSR |= iemAImpl_divpd_u128_worker(&pResult->uResult.ar64[1], pFpuState->MXCSR, &puSrc1->ar64[1], &puSrc2->ar64[1]);
     14491}
     14492#endif
  • trunk/src/VBox/VMM/VMMAll/IEMAllInstructionsTwoByte0f.cpp.h

    r96331 r96333  
    40274027FNIEMOP_STUB(iemOp_minsd_Vsd_Wsd);
    40284028
     4029
    40294030/** Opcode      0x0f 0x5e - divps Vps, Wps */
    4030 FNIEMOP_STUB(iemOp_divps_Vps_Wps);
     4031FNIEMOP_DEF(iemOp_divps_Vps_Wps)
     4032{
     4033    IEMOP_MNEMONIC2(RM, DIVPS, divps, Vps, Wps, DISOPTYPE_HARMLESS, 0);
     4034    return FNIEMOP_CALL_1(iemOpCommonSseFp_FullFull_To_Full, iemAImpl_divps_u128);
     4035}
     4036
     4037
    40314038/** Opcode 0x66 0x0f 0x5e - divpd Vpd, Wpd */
    4032 FNIEMOP_STUB(iemOp_divpd_Vpd_Wpd);
     4039FNIEMOP_DEF(iemOp_divpd_Vpd_Wpd)
     4040{
     4041    IEMOP_MNEMONIC2(RM, DIVPD, divpd, Vpd, Wpd, DISOPTYPE_HARMLESS, 0);
     4042    return FNIEMOP_CALL_1(iemOpCommonSse2Fp_FullFull_To_Full, iemAImpl_divpd_u128);
     4043}
     4044
     4045
    40334046/** Opcode 0xf3 0x0f 0x5e - divss Vss, Wss */
    40344047FNIEMOP_STUB(iemOp_divss_Vss_Wss);
  • trunk/src/VBox/VMM/include/IEMInternal.h

    r96331 r96333  
    24242424FNIEMAIMPLFPSSEF2U128 iemAImpl_minps_u128;
    24252425FNIEMAIMPLFPSSEF2U128 iemAImpl_minpd_u128;
     2426FNIEMAIMPLFPSSEF2U128 iemAImpl_divps_u128;
     2427FNIEMAIMPLFPSSEF2U128 iemAImpl_divpd_u128;
    24262428
    24272429FNIEMAIMPLFPAVXF3U128 iemAImpl_vaddps_u128, iemAImpl_vaddps_u128_fallback;
     
    24332435FNIEMAIMPLFPAVXF3U128 iemAImpl_vminps_u128, iemAImpl_vminps_u128_fallback;
    24342436FNIEMAIMPLFPAVXF3U128 iemAImpl_vminpd_u128, iemAImpl_vminpd_u128_fallback;
     2437FNIEMAIMPLFPAVXF3U128 iemAImpl_vdivps_u128, iemAImpl_vdivps_u128_fallback;
     2438FNIEMAIMPLFPAVXF3U128 iemAImpl_vdivpd_u128, iemAImpl_vdivpd_u128_fallback;
    24352439
    24362440FNIEMAIMPLFPAVXF3U256 iemAImpl_vaddps_u256, iemAImpl_vaddps_u256_fallback;
     
    24422446FNIEMAIMPLFPAVXF3U256 iemAImpl_vminps_u256, iemAImpl_vminps_u256_fallback;
    24432447FNIEMAIMPLFPAVXF3U256 iemAImpl_vminpd_u256, iemAImpl_vminpd_u256_fallback;
     2448FNIEMAIMPLFPAVXF3U256 iemAImpl_vdivps_u256, iemAImpl_vdivps_u256_fallback;
     2449FNIEMAIMPLFPAVXF3U256 iemAImpl_vdivpd_u256, iemAImpl_vdivpd_u256_fallback;
    24442450/** @} */
    24452451
  • trunk/src/VBox/VMM/testcase/tstIEMCheckMc.cpp

    r96331 r96333  
    470470#define iemAImpl_minps_u128             NULL
    471471#define iemAImpl_minpd_u128             NULL
     472#define iemAImpl_divps_u128             NULL
     473#define iemAImpl_divpd_u128             NULL
    472474
    473475/** @}  */
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