VirtualBox

Ignore:
Timestamp:
Apr 10, 2024 1:52:25 PM (10 months ago)
Author:
vboxsync
Message:

VMM/IEM: Implement a native emitter for the pxor,xorps,xorpd instructions, bugref:10652

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/target-x86/IEMAllN8veEmit-x86.h

    r104099 r104278  
    18721872
    18731873
     1874
     1875#ifdef IEMNATIVE_WITH_SIMD_REG_ALLOCATOR
     1876/*********************************************************************************************************************************
     1877*   SIMD emitters.                                                                                                               *
     1878*********************************************************************************************************************************/
     1879
     1880/**
     1881 * Common emitter for the PXOR, XORPS, XORPD instructions - guest register / guest register variant.
     1882 */
     1883DECL_INLINE_THROW(uint32_t)
     1884iemNativeEmit_pxor_rr_u128(PIEMRECOMPILERSTATE pReNative, uint32_t off,
     1885                           uint8_t const idxSimdGstRegDst, uint8_t const idxSimdGstRegSrc)
     1886{
     1887    uint8_t const idxSimdRegDst = iemNativeSimdRegAllocTmpForGuestSimdReg(pReNative, &off, IEMNATIVEGSTSIMDREG_SIMD(idxSimdGstRegDst),
     1888                                                                          kIemNativeGstSimdRegLdStSz_Low128, kIemNativeGstRegUse_ForUpdate);
     1889    uint8_t const idxSimdRegSrc = iemNativeSimdRegAllocTmpForGuestSimdReg(pReNative, &off, IEMNATIVEGSTSIMDREG_SIMD(idxSimdGstRegSrc),
     1890                                                                          kIemNativeGstSimdRegLdStSz_Low128, kIemNativeGstRegUse_ReadOnly);
     1891
     1892#ifdef RT_ARCH_AMD64
     1893    PIEMNATIVEINSTR const pCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 5);
     1894
     1895    /* pxor xmm, xmm */
     1896    pCodeBuf[off++] = X86_OP_PRF_SIZE_OP;
     1897    if (idxSimdRegDst >= 8 || idxSimdRegSrc >= 8)
     1898        pCodeBuf[off++] =   (idxSimdRegSrc >= 8 ? X86_OP_REX_B : 0)
     1899                          | (idxSimdRegDst >= 8 ? X86_OP_REX_R : 0);
     1900    pCodeBuf[off++] = 0x0f;
     1901    pCodeBuf[off++] = 0xef;
     1902    pCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, idxSimdRegDst & 7, idxSimdRegSrc & 7);
     1903
     1904#elif defined(RT_ARCH_ARM64)
     1905    PIEMNATIVEINSTR const pCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 1);
     1906
     1907    pCodeBuf[off++] = Armv8A64MkVecInstrEor(idxSimdRegDst, idxSimdRegDst, idxSimdRegSrc);
     1908#else
     1909# error "port me"
     1910#endif
     1911
     1912    iemNativeSimdRegFreeTmp(pReNative, idxSimdRegDst);
     1913    iemNativeSimdRegFreeTmp(pReNative, idxSimdRegSrc);
     1914
     1915    IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off);
     1916    return off;
     1917}
     1918
     1919
     1920/**
     1921 * Common emitter for the PXOR, XORPS, XORPD instructions - guest register / recompiler variable variant.
     1922 */
     1923DECL_INLINE_THROW(uint32_t)
     1924iemNativeEmit_pxor_rv_u128(PIEMRECOMPILERSTATE pReNative, uint32_t off,
     1925                           uint8_t const idxSimdGstRegDst, uint8_t const idxVarSrc)
     1926{
     1927    IEMNATIVE_ASSERT_VAR_IDX(pReNative, idxVarSrc);
     1928    IEMNATIVE_ASSERT_VAR_SIZE(pReNative, idxVarSrc, sizeof(RTUINT128U));
     1929
     1930    uint8_t const idxSimdRegDst = iemNativeSimdRegAllocTmpForGuestSimdReg(pReNative, &off, IEMNATIVEGSTSIMDREG_SIMD(idxSimdGstRegDst),
     1931                                                                          kIemNativeGstSimdRegLdStSz_Low128, kIemNativeGstRegUse_ForUpdate);
     1932    uint8_t const idxSimdRegSrc = iemNativeVarSimdRegisterAcquire(pReNative, idxVarSrc, &off, true /*fInitialized*/);
     1933
     1934
     1935#ifdef RT_ARCH_AMD64
     1936    PIEMNATIVEINSTR const pCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 5);
     1937
     1938    /* pxor xmm, xmm */
     1939    pCodeBuf[off++] = X86_OP_PRF_SIZE_OP;
     1940    if (idxSimdRegDst >= 8 || idxSimdRegSrc >= 8)
     1941        pCodeBuf[off++] =   (idxSimdRegSrc >= 8 ? X86_OP_REX_B : 0)
     1942                          | (idxSimdRegDst >= 8 ? X86_OP_REX_R : 0);
     1943    pCodeBuf[off++] = 0x0f;
     1944    pCodeBuf[off++] = 0xef;
     1945    pCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, idxSimdRegDst & 7, idxSimdRegSrc & 7);
     1946
     1947#elif defined(RT_ARCH_ARM64)
     1948    PIEMNATIVEINSTR const pCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 1);
     1949
     1950    pCodeBuf[off++] = Armv8A64MkVecInstrEor(idxSimdRegDst, idxSimdRegDst, idxSimdRegSrc);
     1951#else
     1952# error "port me"
     1953#endif
     1954
     1955    iemNativeSimdRegFreeTmp(pReNative, idxSimdRegDst);
     1956    iemNativeVarRegisterRelease(pReNative, idxVarSrc);
     1957
     1958    IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off);
     1959    return off;
     1960}
     1961#endif
     1962
    18741963#endif /* !VMM_INCLUDED_SRC_VMMAll_target_x86_IEMAllN8veEmit_x86_h */
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