VirtualBox

Changeset 104087 in vbox


Ignore:
Timestamp:
Mar 27, 2024 2:23:52 PM (13 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
162488
Message:

VMM/IEM: Implement native emitters for IEM_MC_STORE_XREG_U8() and IEM_MC_STORE_XREG_U16(), bugref:10614

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/IEMAllInstPython.py

    r104076 r104087  
    33543354    'IEM_MC_STORE_XREG_R64':                                     (McBlock.parseMcGeneric,           True,  True,  False, ),
    33553355    'IEM_MC_STORE_XREG_U128':                                    (McBlock.parseMcGeneric,           True,  True,  g_fNativeSimd),
    3356     'IEM_MC_STORE_XREG_U16':                                     (McBlock.parseMcGeneric,           True,  True,  False, ),
     3356    'IEM_MC_STORE_XREG_U16':                                     (McBlock.parseMcGeneric,           True,  True,  g_fNativeSimd),
    33573357    'IEM_MC_STORE_XREG_U32':                                     (McBlock.parseMcGeneric,           True,  True,  g_fNativeSimd),
    33583358    'IEM_MC_STORE_XREG_U32_U128':                                (McBlock.parseMcGeneric,           True,  True,  g_fNativeSimd),
     
    33603360    'IEM_MC_STORE_XREG_U64':                                     (McBlock.parseMcGeneric,           True,  True,  g_fNativeSimd),
    33613361    'IEM_MC_STORE_XREG_U64_ZX_U128':                             (McBlock.parseMcGeneric,           True,  True,  g_fNativeSimd),
    3362     'IEM_MC_STORE_XREG_U8':                                      (McBlock.parseMcGeneric,           True,  True,  False, ),
     3362    'IEM_MC_STORE_XREG_U8':                                      (McBlock.parseMcGeneric,           True,  True,  g_fNativeSimd),
    33633363    'IEM_MC_STORE_XREG_XMM':                                     (McBlock.parseMcGeneric,           True,  True,  g_fNativeSimd),
    33643364    'IEM_MC_STORE_XREG_XMM_U32':                                 (McBlock.parseMcGeneric,           True,  True,  False, ),
  • trunk/src/VBox/VMM/VMMAll/IEMAllN8veRecompFuncs.h

    r104084 r104087  
    77257725
    77267726#define IEM_MC_STORE_XREG_U64(a_iXReg, a_iQWord, a_u64Value) \
    7727     off = iemNativeEmitSimdStoreXregU64(pReNative, off, a_iXReg, a_u64Value, a_iQWord)
    7728 
    7729 /** Emits code for IEM_MC_STORE_XREG_U64. */
    7730 DECL_INLINE_THROW(uint32_t)
    7731 iemNativeEmitSimdStoreXregU64(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint8_t iXReg, uint8_t idxDstVar, uint8_t iQWord)
     7727    off = iemNativeEmitSimdStoreXregUxx(pReNative, off, a_iXReg, a_u64Value, sizeof(uint64_t), a_iQWord)
     7728
     7729#define IEM_MC_STORE_XREG_U32(a_iXReg, a_iDWord, a_u32Value) \
     7730    off = iemNativeEmitSimdStoreXregUxx(pReNative, off, a_iXReg, a_u32Value, sizeof(uint32_t), a_iDWord)
     7731
     7732#define IEM_MC_STORE_XREG_U16(a_iXReg, a_iWord, a_u32Value) \
     7733    off = iemNativeEmitSimdStoreXregUxx(pReNative, off, a_iXReg, a_u32Value, sizeof(uint16_t), a_iWord)
     7734
     7735#define IEM_MC_STORE_XREG_U8(a_iXReg, a_iByte, a_u32Value) \
     7736    off = iemNativeEmitSimdStoreXregUxx(pReNative, off, a_iXReg, a_u32Value, sizeof(uint8_t), a_iByte)
     7737
     7738/** Emits code for IEM_MC_STORE_XREG_U64/IEM_MC_STORE_XREG_U32/IEM_MC_STORE_XREG_U16/IEM_MC_STORE_XREG_U8. */
     7739DECL_INLINE_THROW(uint32_t)
     7740iemNativeEmitSimdStoreXregUxx(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint8_t iXReg, uint8_t idxDstVar, uint8_t cbLocal, uint8_t iElem)
    77327741{
    77337742    IEMNATIVE_ASSERT_VAR_IDX(pReNative, idxDstVar);
    7734     IEMNATIVE_ASSERT_VAR_SIZE(pReNative, idxDstVar, sizeof(uint64_t));
     7743    IEMNATIVE_ASSERT_VAR_SIZE(pReNative, idxDstVar, cbLocal);
     7744
     7745#ifdef VBOX_STRICT
     7746    switch (cbLocal)
     7747    {
     7748        case sizeof(uint64_t): Assert(iElem <  2); break;
     7749        case sizeof(uint32_t): Assert(iElem <  4); break;
     7750        case sizeof(uint16_t): Assert(iElem <  8); break;
     7751        case sizeof(uint8_t):  Assert(iElem < 16); break;
     7752        default: AssertFailed();
     7753    }
     7754#endif
    77357755
    77367756    uint8_t const idxSimdRegDst = iemNativeSimdRegAllocTmpForGuestSimdReg(pReNative, &off, IEMNATIVEGSTSIMDREG_SIMD(iXReg),
     
    77397759    uint8_t const idxVarReg = iemNativeVarRegisterAcquire(pReNative, idxDstVar, &off);
    77407760
    7741     off = iemNativeEmitSimdStoreGprToVecRegU64(pReNative, off, idxSimdRegDst, idxVarReg, iQWord);
    7742 
    7743     /* Free but don't flush the source register. */
    7744     iemNativeSimdRegFreeTmp(pReNative, idxSimdRegDst);
    7745     iemNativeVarRegisterRelease(pReNative, idxDstVar);
    7746 
    7747     return off;
    7748 }
    7749 
    7750 
    7751 #define IEM_MC_STORE_XREG_U32(a_iXReg, a_iDWord, a_u32Value) \
    7752     off = iemNativeEmitSimdStoreXregU32(pReNative, off, a_iXReg, a_u32Value, a_iDWord)
    7753 
    7754 /** Emits code for IEM_MC_STORE_XREG_U32. */
    7755 DECL_INLINE_THROW(uint32_t)
    7756 iemNativeEmitSimdStoreXregU32(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint8_t iXReg, uint8_t idxDstVar, uint8_t iDWord)
    7757 {
    7758     IEMNATIVE_ASSERT_VAR_IDX(pReNative, idxDstVar);
    7759     IEMNATIVE_ASSERT_VAR_SIZE(pReNative, idxDstVar, sizeof(uint32_t));
    7760 
    7761     uint8_t const idxSimdRegDst = iemNativeSimdRegAllocTmpForGuestSimdReg(pReNative, &off, IEMNATIVEGSTSIMDREG_SIMD(iXReg),
    7762                                                                           kIemNativeGstSimdRegLdStSz_Low128, kIemNativeGstRegUse_ForUpdate);
    7763 
    7764     uint8_t const idxVarReg = iemNativeVarRegisterAcquire(pReNative, idxDstVar, &off);
    7765 
    7766     off = iemNativeEmitSimdStoreGprToVecRegU32(pReNative, off, idxSimdRegDst, idxVarReg, iDWord);
     7761    switch (cbLocal)
     7762    {
     7763        case sizeof(uint64_t): off = iemNativeEmitSimdStoreGprToVecRegU64(pReNative, off, idxSimdRegDst, idxVarReg, iElem); break;
     7764        case sizeof(uint32_t): off = iemNativeEmitSimdStoreGprToVecRegU32(pReNative, off, idxSimdRegDst, idxVarReg, iElem); break;
     7765        case sizeof(uint16_t): off = iemNativeEmitSimdStoreGprToVecRegU16(pReNative, off, idxSimdRegDst, idxVarReg, iElem); break;
     7766        case sizeof(uint8_t):  off = iemNativeEmitSimdStoreGprToVecRegU8(pReNative, off, idxSimdRegDst, idxVarReg, iElem); break;
     7767        default: AssertFailed();
     7768    }
    77677769
    77687770    /* Free but don't flush the source register. */
  • trunk/src/VBox/VMM/include/IEMN8veRecompilerEmit.h

    r104058 r104087  
    86138613
    86148614/**
     8615 * Emits a vecdst[x] = gprsrc store, 16-bit.
     8616 */
     8617DECL_FORCE_INLINE(uint32_t)
     8618iemNativeEmitSimdStoreGprToVecRegU16Ex(PIEMNATIVEINSTR pCodeBuf, uint32_t off, uint8_t iVecRegDst, uint8_t iGprSrc, uint8_t iWord)
     8619{
     8620#ifdef RT_ARCH_AMD64
     8621    /* pinsrw vecsrc, gpr, #iWord. */
     8622    pCodeBuf[off++] = X86_OP_PRF_SIZE_OP;
     8623    if (iVecRegDst >= 8 || iGprSrc >= 8)
     8624        pCodeBuf[off++] =   (iVecRegDst < 8 ? 0 : X86_OP_REX_R)
     8625                          | (iGprSrc < 8 ? 0 : X86_OP_REX_B);
     8626    pCodeBuf[off++] = 0x0f;
     8627    pCodeBuf[off++] = 0xc4;
     8628    pCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, iVecRegDst & 7, iGprSrc & 7);
     8629    pCodeBuf[off++] = iWord;
     8630#elif defined(RT_ARCH_ARM64)
     8631    /* ins vecsrc[iWord], gpr */
     8632    pCodeBuf[off++] = Armv8A64MkVecInstrIns(iVecRegDst, iGprSrc, iWord, kArmv8InstrUmovInsSz_U16);
     8633#else
     8634# error "port me"
     8635#endif
     8636    return off;
     8637}
     8638
     8639
     8640/**
     8641 * Emits a vecdst[x] = gprsrc store, 16-bit.
     8642 */
     8643DECL_INLINE_THROW(uint32_t)
     8644iemNativeEmitSimdStoreGprToVecRegU16(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint8_t iVecRegDst, uint8_t iGprSrc, uint8_t iWord)
     8645{
     8646    Assert(iWord <= 15);
     8647
     8648#ifdef RT_ARCH_AMD64
     8649    off = iemNativeEmitSimdStoreGprToVecRegU16Ex(iemNativeInstrBufEnsure(pReNative, off, 6), off, iVecRegDst, iGprSrc, iWord);
     8650#elif defined(RT_ARCH_ARM64)
     8651    off = iemNativeEmitSimdStoreGprToVecRegU16Ex(iemNativeInstrBufEnsure(pReNative, off, 1), off, iVecRegDst, iGprSrc, iWord);
     8652#else
     8653# error "port me"
     8654#endif
     8655    IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off);
     8656    return off;
     8657}
     8658
     8659
     8660/**
     8661 * Emits a vecdst[x] = gprsrc store, 8-bit.
     8662 */
     8663DECL_FORCE_INLINE(uint32_t)
     8664iemNativeEmitSimdStoreGprToVecRegU8Ex(PIEMNATIVEINSTR pCodeBuf, uint32_t off, uint8_t iVecRegDst, uint8_t iGprSrc, uint8_t iByte)
     8665{
     8666#ifdef RT_ARCH_AMD64
     8667    /* pinsrb vecsrc, gpr, #iByte (ASSUMES SSE4.1). */
     8668    pCodeBuf[off++] = X86_OP_PRF_SIZE_OP;
     8669    if (iVecRegDst >= 8 || iGprSrc >= 8)
     8670        pCodeBuf[off++] =   (iVecRegDst < 8 ? 0 : X86_OP_REX_R)
     8671                          | (iGprSrc < 8 ? 0 : X86_OP_REX_B);
     8672    pCodeBuf[off++] = 0x0f;
     8673    pCodeBuf[off++] = 0x3a;
     8674    pCodeBuf[off++] = 0x20;
     8675    pCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, iVecRegDst & 7, iGprSrc & 7);
     8676    pCodeBuf[off++] = iByte;
     8677#elif defined(RT_ARCH_ARM64)
     8678    /* ins vecsrc[iByte], gpr */
     8679    pCodeBuf[off++] = Armv8A64MkVecInstrIns(iVecRegDst, iGprSrc, iByte, kArmv8InstrUmovInsSz_U8);
     8680#else
     8681# error "port me"
     8682#endif
     8683    return off;
     8684}
     8685
     8686
     8687/**
     8688 * Emits a vecdst[x] = gprsrc store, 8-bit.
     8689 */
     8690DECL_INLINE_THROW(uint32_t)
     8691iemNativeEmitSimdStoreGprToVecRegU8(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint8_t iVecRegDst, uint8_t iGprSrc, uint8_t iByte)
     8692{
     8693    Assert(iByte <= 15);
     8694
     8695#ifdef RT_ARCH_AMD64
     8696    off = iemNativeEmitSimdStoreGprToVecRegU8Ex(iemNativeInstrBufEnsure(pReNative, off, 7), off, iVecRegDst, iGprSrc, iByte);
     8697#elif defined(RT_ARCH_ARM64)
     8698    off = iemNativeEmitSimdStoreGprToVecRegU8Ex(iemNativeInstrBufEnsure(pReNative, off, 1), off, iVecRegDst, iGprSrc, iByte);
     8699#else
     8700# error "port me"
     8701#endif
     8702    IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off);
     8703    return off;
     8704}
     8705
     8706
     8707/**
    86158708 * Emits a vecdst.au32[iDWord] = 0 store.
    86168709 */
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