VirtualBox

Ignore:
Timestamp:
Mar 26, 2024 10:07:26 AM (10 months ago)
Author:
vboxsync
Message:

VMM/IEM: Implement native emitters for IEM_MC_LOCAL_ASSIGN(), IEM_MC_AND_ARG_U16()/IEM_MC_AND_ARG_U32()/IEM_MC_AND_ARG_U64(), IEM_MC_SHL_LOCAL_S16()/IEM_MC_SHL_LOCAL_S32()/IEM_MC_SHL_LOCAL_S64(), IEM_MC_SAR_LOCAL_S16()/IEM_MC_SAR_LOCAL_S32()/IEM_MC_SAR_LOCAL_S64() and IEM_MC_ADD_LOCAL_S16_TO_EFF_ADDR()/IEM_MC_ADD_LOCAL_S32_TO_EFF_ADDR()/IEM_MC_ADD_LOCAL_S64_TO_EFF_ADDR() (enables recompilation of bt/btr/bts instructions), bugref:10371

File:
1 edited

Legend:

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

    r104033 r104056  
    56705670
    56715671/**
     5672 * Emits code for (signed) shifting a GPR a fixed number of bits to the right.
     5673 */
     5674DECL_FORCE_INLINE(uint32_t)
     5675iemNativeEmitArithShiftGprRightEx(PIEMNATIVEINSTR pCodeBuf, uint32_t off, uint8_t iGprDst, uint8_t cShift)
     5676{
     5677    Assert(cShift > 0 && cShift < 64);
     5678
     5679#if defined(RT_ARCH_AMD64)
     5680    /* sar dst, cShift */
     5681    pCodeBuf[off++] = iGprDst < 8 ? X86_OP_REX_W : X86_OP_REX_W | X86_OP_REX_B;
     5682    if (cShift != 1)
     5683    {
     5684        pCodeBuf[off++] = 0xc1;
     5685        pCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, 7, iGprDst & 7);
     5686        pCodeBuf[off++] = cShift;
     5687    }
     5688    else
     5689    {
     5690        pCodeBuf[off++] = 0xd1;
     5691        pCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, 7, iGprDst & 7);
     5692    }
     5693
     5694#elif defined(RT_ARCH_ARM64)
     5695    pCodeBuf[off++] = Armv8A64MkInstrAsrImm(iGprDst, iGprDst, cShift);
     5696
     5697#else
     5698# error "Port me"
     5699#endif
     5700    return off;
     5701}
     5702
     5703
     5704/**
     5705 * Emits code for (signed) shifting a GPR a fixed number of bits to the right.
     5706 */
     5707DECL_INLINE_THROW(uint32_t)
     5708iemNativeEmitArithShiftGprRight(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint8_t iGprDst, uint8_t cShift)
     5709{
     5710#if defined(RT_ARCH_AMD64)
     5711    off = iemNativeEmitArithShiftGprRightEx(iemNativeInstrBufEnsure(pReNative, off, 4), off, iGprDst, cShift);
     5712#elif defined(RT_ARCH_ARM64)
     5713    off = iemNativeEmitArithShiftGprRightEx(iemNativeInstrBufEnsure(pReNative, off, 1), off, iGprDst, cShift);
     5714#else
     5715# error "Port me"
     5716#endif
     5717    IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off);
     5718    return off;
     5719}
     5720
     5721
     5722/**
     5723 * Emits code for (signed) shifting a 32-bit GPR a fixed number of bits to the right.
     5724 */
     5725DECL_FORCE_INLINE(uint32_t)
     5726iemNativeEmitArithShiftGpr32RightEx(PIEMNATIVEINSTR pCodeBuf, uint32_t off, uint8_t iGprDst, uint8_t cShift)
     5727{
     5728    Assert(cShift > 0 && cShift < 64);
     5729
     5730#if defined(RT_ARCH_AMD64)
     5731    /* sar dst, cShift */
     5732    if (iGprDst >= 8)
     5733        pCodeBuf[off++] = X86_OP_REX_B;
     5734    if (cShift != 1)
     5735    {
     5736        pCodeBuf[off++] = 0xc1;
     5737        pCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, 7, iGprDst & 7);
     5738        pCodeBuf[off++] = cShift;
     5739    }
     5740    else
     5741    {
     5742        pCodeBuf[off++] = 0xd1;
     5743        pCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, 7, iGprDst & 7);
     5744    }
     5745
     5746#elif defined(RT_ARCH_ARM64)
     5747    pCodeBuf[off++] = Armv8A64MkInstrAsrImm(iGprDst, iGprDst, cShift, false /*f64Bit*/);
     5748
     5749#else
     5750# error "Port me"
     5751#endif
     5752    return off;
     5753}
     5754
     5755
     5756/**
     5757 * Emits code for (signed) shifting a GPR a fixed number of bits to the right.
     5758 */
     5759DECL_INLINE_THROW(uint32_t)
     5760iemNativeEmitArithShiftGpr32Right(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint8_t iGprDst, uint8_t cShift)
     5761{
     5762#if defined(RT_ARCH_AMD64)
     5763    off = iemNativeEmitArithShiftGpr32RightEx(iemNativeInstrBufEnsure(pReNative, off, 4), off, iGprDst, cShift);
     5764#elif defined(RT_ARCH_ARM64)
     5765    off = iemNativeEmitArithShiftGpr32RightEx(iemNativeInstrBufEnsure(pReNative, off, 1), off, iGprDst, cShift);
     5766#else
     5767# error "Port me"
     5768#endif
     5769    IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off);
     5770    return off;
     5771}
     5772
     5773
     5774/**
    56725775 * Emits code for rotating a GPR a fixed number of bits to the left.
    56735776 */
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