VirtualBox

Ignore:
Timestamp:
Mar 11, 2024 11:01:51 AM (11 months ago)
Author:
vboxsync
Message:

VMM/IEM: More amd64 fixes for SIMD enablement, bs3-cpu-instr-3 works now, bugref:10614

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/include/IEMN8veRecompilerEmit.h

    r103750 r103758  
    68286828 */
    68296829DECL_FORCE_INLINE_THROW(uint32_t)
    6830 iemNativeEmitSimdStoreVecRegToVCpuU128Ex(PIEMNATIVEINSTR pCodeBuf, uint32_t off, uint8_t iVecReg, uint32_t offVCpu)
     6830iemNativeEmitSimdStoreVecRegToVCpuLowU128Ex(PIEMNATIVEINSTR pCodeBuf, uint32_t off, uint8_t iVecReg, uint32_t offVCpu)
    68316831{
    68326832#ifdef RT_ARCH_AMD64
     
    68526852 */
    68536853DECL_INLINE_THROW(uint32_t)
    6854 iemNativeEmitSimdStoreVecRegToVCpuU128(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint8_t iVecReg, uint32_t offVCpu)
    6855 {
    6856 #ifdef RT_ARCH_AMD64
    6857     off = iemNativeEmitSimdStoreVecRegToVCpuU128Ex(iemNativeInstrBufEnsure(pReNative, off, 9), off, iVecReg, offVCpu);
    6858 #elif defined(RT_ARCH_ARM64)
    6859     off = iemNativeEmitSimdStoreVecRegToVCpuU128Ex(iemNativeInstrBufEnsure(pReNative, off, 1), off, iVecReg, offVCpu);
     6854iemNativeEmitSimdStoreVecRegToVCpuLowU128(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint8_t iVecReg, uint32_t offVCpu)
     6855{
     6856#ifdef RT_ARCH_AMD64
     6857    off = iemNativeEmitSimdStoreVecRegToVCpuLowU128Ex(iemNativeInstrBufEnsure(pReNative, off, 9), off, iVecReg, offVCpu);
     6858#elif defined(RT_ARCH_ARM64)
     6859    off = iemNativeEmitSimdStoreVecRegToVCpuLowU128Ex(iemNativeInstrBufEnsure(pReNative, off, 1), off, iVecReg, offVCpu);
     6860#else
     6861# error "port me"
     6862#endif
     6863    IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off);
     6864    return off;
     6865}
     6866
     6867
     6868/**
     6869 * Emits a high 128-bit vector register store to a VCpu value.
     6870 */
     6871DECL_FORCE_INLINE_THROW(uint32_t)
     6872iemNativeEmitSimdStoreVecRegToVCpuHighU128Ex(PIEMNATIVEINSTR pCodeBuf, uint32_t off, uint8_t iVecReg, uint32_t offVCpu)
     6873{
     6874#ifdef RT_ARCH_AMD64
     6875    /* vextracti128 mem128, reg128, 1 */ /* ASSUMES AVX2 support. */
     6876    pCodeBuf[off++] = X86_OP_VEX3;
     6877    if (iVecReg >= 8)
     6878        pCodeBuf[off++] = 0x63;
     6879    else
     6880        pCodeBuf[off++] = 0xe3;
     6881    pCodeBuf[off++] = 0x7d;
     6882    pCodeBuf[off++] = 0x39;
     6883    off = iemNativeEmitGprByVCpuDisp(pCodeBuf, off, iVecReg, offVCpu);
     6884    pCodeBuf[off++] = 0x01; /* Immediate */
     6885#elif defined(RT_ARCH_ARM64)
     6886    off = iemNativeEmitGprByVCpuLdStEx(pCodeBuf, off, iVecReg, offVCpu, kArmv8A64InstrLdStType_St_Vr_128, sizeof(RTUINT128U));
     6887#else
     6888# error "port me"
     6889#endif
     6890    return off;
     6891}
     6892
     6893
     6894/**
     6895 * Emits a high 128-bit vector register load of a VCpu value.
     6896 */
     6897DECL_INLINE_THROW(uint32_t)
     6898iemNativeEmitSimdStoreVecRegToVCpuHighU128(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint8_t iVecReg, uint32_t offVCpu)
     6899{
     6900#ifdef RT_ARCH_AMD64
     6901    off = iemNativeEmitSimdStoreVecRegToVCpuHighU128Ex(iemNativeInstrBufEnsure(pReNative, off, 10), off, iVecReg, offVCpu);
     6902#elif defined(RT_ARCH_ARM64)
     6903    /* ASSUMES that there are two adjacent 128-bit registers available for the 256-bit value. */
     6904    Assert(!(iVecReg & 0x1));
     6905    off = iemNativeEmitSimdStoreVecRegToVCpuHighU128Ex(iemNativeInstrBufEnsure(pReNative, off, 1), off, iVecReg + 1, offVCpu);
    68606906#else
    68616907# error "port me"
     
    68706916 */
    68716917DECL_FORCE_INLINE_THROW(uint32_t)
    6872 iemNativeEmitSimdLoadVecRegFromVCpuU128Ex(PIEMNATIVEINSTR pCodeBuf, uint32_t off, uint8_t iVecReg, uint32_t offVCpu)
     6918iemNativeEmitSimdLoadVecRegFromVCpuLowU128Ex(PIEMNATIVEINSTR pCodeBuf, uint32_t off, uint8_t iVecReg, uint32_t offVCpu)
    68736919{
    68746920#ifdef RT_ARCH_AMD64
     
    68946940 */
    68956941DECL_INLINE_THROW(uint32_t)
    6896 iemNativeEmitSimdLoadVecRegFromVCpuU128(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint8_t iVecReg, uint32_t offVCpu)
    6897 {
    6898 #ifdef RT_ARCH_AMD64
    6899     off = iemNativeEmitSimdLoadVecRegFromVCpuU128Ex(iemNativeInstrBufEnsure(pReNative, off, 9), off, iVecReg, offVCpu);
    6900 #elif defined(RT_ARCH_ARM64)
    6901     off = iemNativeEmitSimdLoadVecRegFromVCpuU128Ex(iemNativeInstrBufEnsure(pReNative, off, 1), off, iVecReg, offVCpu);
    6902 #else
    6903 # error "port me"
    6904 #endif
    6905     IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off);
    6906     return off;
    6907 }
    6908 
    6909 
    6910 #if 0 /* unused */
    6911 /**
    6912  * Emits a 256-bit vector register store to a VCpu value.
     6942iemNativeEmitSimdLoadVecRegFromVCpuLowU128(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint8_t iVecReg, uint32_t offVCpu)
     6943{
     6944#ifdef RT_ARCH_AMD64
     6945    off = iemNativeEmitSimdLoadVecRegFromVCpuLowU128Ex(iemNativeInstrBufEnsure(pReNative, off, 9), off, iVecReg, offVCpu);
     6946#elif defined(RT_ARCH_ARM64)
     6947    off = iemNativeEmitSimdLoadVecRegFromVCpuLowU128Ex(iemNativeInstrBufEnsure(pReNative, off, 1), off, iVecReg, offVCpu);
     6948#else
     6949# error "port me"
     6950#endif
     6951    IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off);
     6952    return off;
     6953}
     6954
     6955
     6956/**
     6957 * Emits a 128-bit vector register load of a VCpu value.
    69136958 */
    69146959DECL_FORCE_INLINE_THROW(uint32_t)
    6915 iemNativeEmitSimdStoreVecRegToVCpuU256(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint8_t iVecReg, uint32_t offVCpuLow, uint32_t offVCpuHigh)
    6916 {
    6917 #ifdef RT_ARCH_AMD64
    6918     AssertReleaseFailed();
     6960iemNativeEmitSimdLoadVecRegFromVCpuHighU128Ex(PIEMNATIVEINSTR pCodeBuf, uint32_t off, uint8_t iVecReg, uint32_t offVCpu)
     6961{
     6962#ifdef RT_ARCH_AMD64
     6963    /* vinserti128 ymm, ymm, mem128, 1. */ /* ASSUMES AVX2 support */
     6964    pCodeBuf[off++] = X86_OP_VEX3;
     6965    if (iVecReg >= 8)
     6966        pCodeBuf[off++] = 0x63;
     6967    else
     6968        pCodeBuf[off++] = 0xe3;
     6969    pCodeBuf[off++] = X86_OP_VEX3_BYTE3_MAKE(false, iVecReg, true, X86_OP_VEX3_BYTE3_P_066H);
     6970    pCodeBuf[off++] = 0x38;
     6971    off = iemNativeEmitGprByVCpuDisp(pCodeBuf, off, iVecReg, offVCpu);
     6972    pCodeBuf[off++] = 0x01; /* Immediate */
     6973#elif defined(RT_ARCH_ARM64)
     6974    off = iemNativeEmitGprByVCpuLdStEx(pCodeBuf, off, iVecReg, offVCpu, kArmv8A64InstrLdStType_Ld_Vr_128, sizeof(RTUINT128U));
     6975#else
     6976# error "port me"
     6977#endif
     6978    return off;
     6979}
     6980
     6981
     6982/**
     6983 * Emits a 128-bit vector register load of a VCpu value.
     6984 */
     6985DECL_INLINE_THROW(uint32_t)
     6986iemNativeEmitSimdLoadVecRegFromVCpuHighU128(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint8_t iVecReg, uint32_t offVCpu)
     6987{
     6988#ifdef RT_ARCH_AMD64
     6989    off = iemNativeEmitSimdLoadVecRegFromVCpuLowU128Ex(iemNativeInstrBufEnsure(pReNative, off, 10), off, iVecReg, offVCpu);
    69196990#elif defined(RT_ARCH_ARM64)
    69206991    /* ASSUMES that there are two adjacent 128-bit registers available for the 256-bit value. */
    69216992    Assert(!(iVecReg & 0x1));
    6922     off = iemNativeEmitSimdStoreVecRegToVCpuU128(pReNative, off, iVecReg,     offVCpuLow);
    6923     off = iemNativeEmitSimdStoreVecRegToVCpuU128(pReNative, off, iVecReg + 1, offVCpuHigh);
    6924 #else
    6925 # error "port me"
    6926 #endif
    6927     return off;
    6928 }
    6929 #endif
    6930 
    6931 
    6932 /**
    6933  * Emits a 256-bit vector register load of a VCpu value.
    6934  */
    6935 DECL_FORCE_INLINE_THROW(uint32_t)
    6936 iemNativeEmitSimdLoadVecRegFromVCpuU256(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint8_t iVecReg, uint32_t offVCpuLow, uint32_t offVCpuHigh)
    6937 {
    6938 #ifdef RT_ARCH_AMD64
    6939     AssertReleaseFailed();
    6940     RT_NOREF(pReNative, off, iVecReg, offVCpuLow, offVCpuHigh);
    6941 #elif defined(RT_ARCH_ARM64)
    6942     /* ASSUMES that there are two adjacent 128-bit registers available for the 256-bit value. */
    6943     Assert(!(iVecReg & 0x1));
    6944     off = iemNativeEmitSimdLoadVecRegFromVCpuU128(pReNative, off, iVecReg,     offVCpuLow);
    6945     off = iemNativeEmitSimdLoadVecRegFromVCpuU128(pReNative, off, iVecReg + 1, offVCpuHigh);
    6946 #else
    6947 # error "port me"
    6948 #endif
     6993    off = iemNativeEmitSimdLoadVecRegFromVCpuLowU128Ex(iemNativeInstrBufEnsure(pReNative, off, 1), off, iVecReg + 1, offVCpu);
     6994#else
     6995# error "port me"
     6996#endif
     6997    IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off);
    69496998    return off;
    69506999}
     
    70097058    if (iVecRegDst >= 8 && iVecRegSrc >= 8)
    70107059    {
    7011         pbCodeBuf[off++] = 0xc4;
     7060        pbCodeBuf[off++] = X86_OP_VEX3;
    70127061        pbCodeBuf[off++] = 0x41;
    70137062        pbCodeBuf[off++] = 0x7d;
     
    70177066    else
    70187067    {
    7019         pbCodeBuf[off++] = 0xc5;                                               /* Two byte VEX prefix */
     7068        pbCodeBuf[off++] = X86_OP_VEX2;
    70207069        pbCodeBuf[off++] = (iVecRegSrc >= 8 || iVecRegDst >= 8) ? 0x7d : 0xfd;
    70217070        pbCodeBuf[off++] = iVecRegSrc >= 8 ? 0x7f : 0x6f;
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