VirtualBox

Changeset 104292 in vbox


Ignore:
Timestamp:
Apr 11, 2024 10:21:57 AM (8 months ago)
Author:
vboxsync
Message:

VMM/IEM: Implement native emitters for psrlw,psrld,psrlq, bugref:10652

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/armv8.h

    r104279 r104292  
    46134613
    46144614
     4615/** Armv8 USHR/USRA/URSRA/SSHR/SRSA/SSHR vector element size.    */
     4616typedef enum ARMV8INSTRUSHIFTSZ
     4617{
     4618    kArmv8InstrShiftSz_U8  = 16,  /**< Byte. */
     4619    kArmv8InstrShiftSz_U16 = 32,  /**< Halfword. */
     4620    kArmv8InstrShiftSz_U32 = 64,  /**< 32-bit. */
     4621    kArmv8InstrShiftSz_U64 = 128  /**< 64-bit. */
     4622} ARMV8INSTRUSHIFTSZ;
     4623
     4624/**
     4625 * A64: Encodes USHR/USRA/URSRA/SSHR/SRSA/SSHR (vector, register).
     4626 *
     4627 * @returns The encoded instruction.
     4628 * @param   iVecRegDst  The vector register to put the result into.
     4629 * @param   iVecRegSrc  The vector source register.
     4630 * @param   enmSz       Element size.
     4631 * @param   fUnsigned   Flag whether this a signed or unsigned shift,
     4632 * @param   fRound      Flag whether this is the rounding shift variant.
     4633 * @param   fAccum      Flag whether this is the accumulate shift variant.
     4634 * @param   f128Bit     Flag whether this operates on the full 128-bit (true, default) of the vector register
     4635 *                      or just the low 64-bit (false).
     4636 */
     4637DECL_FORCE_INLINE(uint32_t) Armv8A64MkVecInstrShrImm(uint32_t iVecRegDst, uint32_t iVecRegSrc, uint8_t cShift, ARMV8INSTRUSHIFTSZ enmSz,
     4638                                                     bool fUnsigned = true, bool fRound = false, bool fAccum = false, bool f128Bit = true)
     4639{
     4640    Assert(iVecRegDst < 32); Assert(iVecRegSrc < 32);
     4641    Assert(   cShift >= 1
     4642           && (   (enmSz == kArmv8InstrShiftSz_U8 &&  cShift <= 8)
     4643               || (enmSz == kArmv8InstrShiftSz_U16 && cShift <= 16)
     4644               || (enmSz == kArmv8InstrShiftSz_U32 && cShift <= 32)
     4645               || (enmSz == kArmv8InstrShiftSz_U64 && cShift <= 64)));
     4646
     4647    return UINT32_C(0xf000400)
     4648         | ((uint32_t)f128Bit << 30)
     4649         | ((uint32_t)fUnsigned << 29)
     4650         | (((uint32_t)enmSz - cShift) << 16)
     4651         | ((uint32_t)fRound << 13)
     4652         | ((uint32_t)fAccum << 12)
     4653         | (iVecRegSrc << 5)
     4654         | iVecRegDst;
     4655}
    46154656/** @} */
    46164657
  • trunk/src/VBox/VMM/VMMAll/IEMAllInstTwoByte0f.cpp.h

    r104288 r104292  
    65806580{
    65816581//    IEMOP_MNEMONIC2(RI, PSRLW, psrlw, Ux, Ib, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
    6582     SSE2_SHIFT_BODY_Imm(psrlw, bRm, 0);
     6582    SSE2_SHIFT_BODY_Imm(psrlw, bRm, RT_ARCH_VAL_AMD64 | RT_ARCH_VAL_ARM64);
    65836583}
    65846584
     
    66576657{
    66586658//    IEMOP_MNEMONIC2(RI, PSRLD, psrld, Ux, Ib, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
    6659     SSE2_SHIFT_BODY_Imm(psrld, bRm, 0);
     6659    SSE2_SHIFT_BODY_Imm(psrld, bRm, RT_ARCH_VAL_AMD64 | RT_ARCH_VAL_ARM64);
    66606660}
    66616661
     
    67326732{
    67336733//    IEMOP_MNEMONIC2(RI, PSRLQ, psrlq, Ux, Ib, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
    6734     SSE2_SHIFT_BODY_Imm(psrlq, bRm, 0);
     6734    SSE2_SHIFT_BODY_Imm(psrlq, bRm, RT_ARCH_VAL_AMD64 | RT_ARCH_VAL_ARM64);
    67356735}
    67366736
  • trunk/src/VBox/VMM/VMMAll/target-x86/IEMAllN8veEmit-x86.h

    r104279 r104292  
    20422042    return off;
    20432043}
     2044
     2045
     2046/**
     2047 * Common emitter for the shift right with immediate instructions.
     2048 */
     2049#ifdef RT_ARCH_AMD64
     2050# define IEMNATIVE_NATIVE_EMIT_SHIFT_RIGHT_IMM_U128(a_Instr, a_cShiftMax, a_ArmElemSz, a_bOpcX86) \
     2051    DECL_INLINE_THROW(uint32_t) \
     2052    RT_CONCAT3(iemNativeEmit_,a_Instr,_ri_u128)(PIEMRECOMPILERSTATE pReNative, uint32_t off, \
     2053                                                uint8_t const idxSimdGstRegDst, uint8_t const bImm) \
     2054    { \
     2055        if (bImm) \
     2056        { \
     2057            uint8_t const idxSimdRegDst = iemNativeSimdRegAllocTmpForGuestSimdReg(pReNative, &off, IEMNATIVEGSTSIMDREG_SIMD(idxSimdGstRegDst), \
     2058                                                                                  kIemNativeGstSimdRegLdStSz_Low128, kIemNativeGstRegUse_ForUpdate); \
     2059            PIEMNATIVEINSTR const pCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 5); \
     2060            pCodeBuf[off++] = X86_OP_PRF_SIZE_OP; \
     2061            if (idxSimdRegDst >= 8) \
     2062                pCodeBuf[off++] = X86_OP_REX_B; \
     2063            pCodeBuf[off++] = 0x0f; \
     2064            pCodeBuf[off++] = (a_bOpcX86); \
     2065            pCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, 2, idxSimdRegDst & 7); \
     2066            pCodeBuf[off++] = bImm; \
     2067            iemNativeSimdRegFreeTmp(pReNative, idxSimdRegDst); \
     2068            IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); \
     2069        } \
     2070        /* Immediate 0 is a nop. */ \
     2071        return off; \
     2072    }
     2073#elif defined(RT_ARCH_ARM64)
     2074# define IEMNATIVE_NATIVE_EMIT_SHIFT_RIGHT_IMM_U128(a_Instr, a_cShiftMax, a_ArmElemSz, a_bOpcX86) \
     2075    DECL_INLINE_THROW(uint32_t) \
     2076    RT_CONCAT3(iemNativeEmit_,a_Instr,_ri_u128)(PIEMRECOMPILERSTATE pReNative, uint32_t off, \
     2077                                                uint8_t const idxSimdGstRegDst, uint8_t const bImm) \
     2078    { \
     2079        if (bImm) \
     2080        { \
     2081            uint8_t const idxSimdRegDst = iemNativeSimdRegAllocTmpForGuestSimdReg(pReNative, &off, IEMNATIVEGSTSIMDREG_SIMD(idxSimdGstRegDst), \
     2082                                                                                  kIemNativeGstSimdRegLdStSz_Low128, kIemNativeGstRegUse_ForUpdate); \
     2083            PIEMNATIVEINSTR const pCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 1); \
     2084            pCodeBuf[off++] = Armv8A64MkVecInstrShrImm(idxSimdRegDst, idxSimdRegDst, RT_MIN(bImm, (a_cShiftMax)), (a_ArmElemSz)); \
     2085            iemNativeSimdRegFreeTmp(pReNative, idxSimdRegDst); \
     2086            IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); \
     2087        } \
     2088        /* Immediate 0 is a nop. */ \
     2089        return off; \
     2090    }
     2091#else
     2092# error "Port me"
     2093#endif
     2094
     2095IEMNATIVE_NATIVE_EMIT_SHIFT_RIGHT_IMM_U128(psrlw, 16, kArmv8InstrShiftSz_U16, 0x71);
     2096IEMNATIVE_NATIVE_EMIT_SHIFT_RIGHT_IMM_U128(psrld, 32, kArmv8InstrShiftSz_U32, 0x72);
     2097IEMNATIVE_NATIVE_EMIT_SHIFT_RIGHT_IMM_U128(psrlq, 64, kArmv8InstrShiftSz_U64, 0x73);
     2098
    20442099#endif
    20452100
  • trunk/src/VBox/VMM/include/IEMInternal.h

    r104281 r104292  
    20422042    /** Statistics per threaded function call.
    20432043     * Updated by both the threaded and native recompilers. */
    2044     uint32_t                acThreadedFuncStats[0x5100 /*20736*/];
     2044    uint32_t                acThreadedFuncStats[0x5120 /*20768*/];
    20452045# endif
    20462046#endif
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