VirtualBox

Changeset 105173 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Jul 7, 2024 1:04:51 PM (7 months ago)
Author:
vboxsync
Message:

VMM/IEM: Implement native emitter for packuswb, bugref:10652

Location:
trunk/src/VBox/VMM/VMMAll
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/IEMAllInstTwoByte0f.cpp.h

    r105172 r105173  
    58725872{
    58735873    IEMOP_MNEMONIC2(RM, PACKUSWB, packuswb, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
    5874     return FNIEMOP_CALL_1(iemOpCommonSse2Opt_FullFull_To_Full, iemAImpl_packuswb_u128);
     5874    SSE2_OPT_BODY_FullFull_To_Full(packuswb, iemAImpl_packuswb_u128, RT_ARCH_VAL_AMD64 | RT_ARCH_VAL_ARM64, RT_ARCH_VAL_AMD64 | RT_ARCH_VAL_ARM64);
    58755875}
    58765876
  • trunk/src/VBox/VMM/VMMAll/target-x86/IEMAllN8veEmit-x86.h

    r105172 r105173  
    23542354}
    23552355
     2356
     2357/**
     2358 * Common emitter for the PACKUSWB instructions - guest register / guest register variant.
     2359 */
     2360DECL_INLINE_THROW(uint32_t)
     2361iemNativeEmit_packuswb_rr_u128(PIEMRECOMPILERSTATE pReNative, uint32_t off,
     2362                               uint8_t const idxSimdGstRegDst, uint8_t const idxSimdGstRegSrc)
     2363{
     2364    uint8_t const idxSimdRegDst = iemNativeSimdRegAllocTmpForGuestSimdReg(pReNative, &off, IEMNATIVEGSTSIMDREG_SIMD(idxSimdGstRegDst),
     2365                                                                          kIemNativeGstSimdRegLdStSz_Low128, kIemNativeGstRegUse_ForUpdate);
     2366    uint8_t const idxSimdRegSrc = iemNativeSimdRegAllocTmpForGuestSimdReg(pReNative, &off, IEMNATIVEGSTSIMDREG_SIMD(idxSimdGstRegSrc),
     2367                                                                          kIemNativeGstSimdRegLdStSz_Low128, kIemNativeGstRegUse_ReadOnly);
     2368
     2369#ifdef RT_ARCH_AMD64
     2370    PIEMNATIVEINSTR const pCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 5);
     2371
     2372    /* packuswb xmm, xmm */
     2373    pCodeBuf[off++] = X86_OP_PRF_SIZE_OP;
     2374    if (idxSimdRegDst >= 8 || idxSimdRegSrc >= 8)
     2375        pCodeBuf[off++] =   (idxSimdRegSrc >= 8 ? X86_OP_REX_B : 0)
     2376                          | (idxSimdRegDst >= 8 ? X86_OP_REX_R : 0);
     2377    pCodeBuf[off++] = 0x0f;
     2378    pCodeBuf[off++] = 0x67;
     2379    pCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, idxSimdRegDst & 7, idxSimdRegSrc & 7);
     2380
     2381#elif defined(RT_ARCH_ARM64)
     2382    PIEMNATIVEINSTR const pCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 2);
     2383
     2384    pCodeBuf[off++] = Armv8A64MkVecInstrQxtn(kArmv8VecInstrQxtnOp_Sqxtun, false /*fUpper*/, idxSimdRegDst, idxSimdRegDst, kArmv8VecInstrArithSz_8);
     2385    pCodeBuf[off++] = Armv8A64MkVecInstrQxtn(kArmv8VecInstrQxtnOp_Sqxtun, true  /*fUpper*/, idxSimdRegDst, idxSimdRegSrc, kArmv8VecInstrArithSz_8);
     2386
     2387#else
     2388# error "port me"
     2389#endif
     2390
     2391    iemNativeSimdRegFreeTmp(pReNative, idxSimdRegDst);
     2392    iemNativeSimdRegFreeTmp(pReNative, idxSimdRegSrc);
     2393
     2394    IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off);
     2395    return off;
     2396}
     2397
     2398
     2399/**
     2400 * Common emitter for the PACKUSWB instructions - guest register / recompiler variable variant.
     2401 */
     2402DECL_INLINE_THROW(uint32_t)
     2403iemNativeEmit_packuswb_rv_u128(PIEMRECOMPILERSTATE pReNative, uint32_t off,
     2404                               uint8_t const idxSimdGstRegDst, uint8_t const idxVarSrc)
     2405{
     2406    IEMNATIVE_ASSERT_VAR_IDX(pReNative, idxVarSrc);
     2407    IEMNATIVE_ASSERT_VAR_SIZE(pReNative, idxVarSrc, sizeof(RTUINT128U));
     2408
     2409    uint8_t const idxSimdRegDst = iemNativeSimdRegAllocTmpForGuestSimdReg(pReNative, &off, IEMNATIVEGSTSIMDREG_SIMD(idxSimdGstRegDst),
     2410                                                                          kIemNativeGstSimdRegLdStSz_Low128, kIemNativeGstRegUse_ForUpdate);
     2411    uint8_t const idxSimdRegSrc = iemNativeVarSimdRegisterAcquire(pReNative, idxVarSrc, &off, true /*fInitialized*/);
     2412
     2413
     2414#ifdef RT_ARCH_AMD64
     2415    PIEMNATIVEINSTR const pCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 5);
     2416
     2417    /* packuswb xmm, xmm */
     2418    pCodeBuf[off++] = X86_OP_PRF_SIZE_OP;
     2419    if (idxSimdRegDst >= 8 || idxSimdRegSrc >= 8)
     2420        pCodeBuf[off++] =   (idxSimdRegSrc >= 8 ? X86_OP_REX_B : 0)
     2421                          | (idxSimdRegDst >= 8 ? X86_OP_REX_R : 0);
     2422    pCodeBuf[off++] = 0x0f;
     2423    pCodeBuf[off++] = 0x67;
     2424    pCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, idxSimdRegDst & 7, idxSimdRegSrc & 7);
     2425
     2426#elif defined(RT_ARCH_ARM64)
     2427    PIEMNATIVEINSTR const pCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 2);
     2428
     2429    pCodeBuf[off++] = Armv8A64MkVecInstrQxtn(kArmv8VecInstrQxtnOp_Sqxtun, false /*fUpper*/, idxSimdRegDst, idxSimdRegDst, kArmv8VecInstrArithSz_8);
     2430    pCodeBuf[off++] = Armv8A64MkVecInstrQxtn(kArmv8VecInstrQxtnOp_Sqxtun, true  /*fUpper*/, idxSimdRegDst, idxSimdRegSrc, kArmv8VecInstrArithSz_8);
     2431
     2432#else
     2433# error "port me"
     2434#endif
     2435
     2436    iemNativeSimdRegFreeTmp(pReNative, idxSimdRegDst);
     2437    iemNativeVarRegisterRelease(pReNative, idxVarSrc);
     2438
     2439    IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off);
     2440    return off;
     2441}
     2442
     2443
    23562444#endif /* IEMNATIVE_WITH_SIMD_REG_ALLOCATOR */
    23572445
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