Changeset 94178 in vbox
- Timestamp:
- Mar 11, 2022 4:09:47 PM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 150434
- Location:
- trunk/src/VBox/VMM/VMMAll
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/IEMAllAImpl.asm
r94176 r94178 1489 1489 ; Makes ASSUMPTIONS about A0, A1, A2 and A3 assignments. 1490 1490 ; 1491 ; @note the _intel and _amd variants are implemented in C. 1492 ; 1491 1493 %macro IEMIMPL_SHIFT_DBL_OP 3 1492 1494 BEGINCODE 1493 BEGINPROC_FASTCALL iemAImpl_ %+ %1 %+ _u16_intel, 161494 BEGINPROC_FASTCALL iemAImpl_ %+ %1 %+ _u16_amd, 161495 1495 BEGINPROC_FASTCALL iemAImpl_ %+ %1 %+ _u16, 16 1496 1496 PROLOGUE_4_ARGS … … 1508 1508 ENDPROC iemAImpl_ %+ %1 %+ _u16 1509 1509 1510 BEGINPROC_FASTCALL iemAImpl_ %+ %1 %+ _u32_intel, 161511 BEGINPROC_FASTCALL iemAImpl_ %+ %1 %+ _u32_amd, 161512 1510 BEGINPROC_FASTCALL iemAImpl_ %+ %1 %+ _u32, 16 1513 1511 PROLOGUE_4_ARGS … … 1526 1524 1527 1525 %ifdef RT_ARCH_AMD64 1528 BEGINPROC_FASTCALL iemAImpl_ %+ %1 %+ _u64_intel, 201529 BEGINPROC_FASTCALL iemAImpl_ %+ %1 %+ _u64_amd, 201530 1526 BEGINPROC_FASTCALL iemAImpl_ %+ %1 %+ _u64, 20 1531 1527 PROLOGUE_4_ARGS -
trunk/src/VBox/VMM/VMMAll/IEMAllAImplC.cpp
r94176 r94178 2546 2546 # endif 2547 2547 2548 #endif /* !defined(RT_ARCH_AMD64) || defined(IEM_WITHOUT_ASSEMBLY) */ 2549 2548 2550 2549 2551 /* … … 2557 2559 * - ZF, SF and PF are calculated according to the result by both vendors. 2558 2560 */ 2559 #define EMIT_SHLD(a_cBitsWidth ) \2560 IEM_DECL_IMPL_DEF(void, iemAImpl_shld_u ## a_cBitsWidth,(uint ## a_cBitsWidth ## _t *puDst, \2561 uint ## a_cBitsWidth ## _t uSrc, uint8_t cShift,uint32_t *pfEFlags)) \2561 #define EMIT_SHLD(a_cBitsWidth, a_uType, a_Suffix, a_fIntelFlags) \ 2562 IEM_DECL_IMPL_DEF(void, RT_CONCAT3(iemAImpl_shld_u,a_cBitsWidth,a_Suffix),(a_uType *puDst, a_uType uSrc, uint8_t cShift, \ 2563 uint32_t *pfEFlags)) \ 2562 2564 { \ 2563 2565 /** @todo this ain't right for 16-bit. Apparently it should use 0x1f instead \ … … 2566 2568 if (cShift) \ 2567 2569 { \ 2568 uint ## a_cBitsWidth ## _tconst uDst = *puDst; \2569 uint ## a_cBitsWidth ## _tuResult = uDst << cShift; \2570 a_uType const uDst = *puDst; \ 2571 a_uType uResult = uDst << cShift; \ 2570 2572 uResult |= uSrc >> (a_cBitsWidth - cShift); \ 2571 2573 *puDst = uResult; \ 2572 2574 \ 2575 /* CALC EFLAGS: */ \ 2573 2576 uint32_t fEfl = *pfEFlags & ~X86_EFL_STATUS_BITS; \ 2574 AssertCompile(X86_EFL_CF_BIT == 0); \ 2575 fEfl |= X86_EFL_GET_OF_ ## a_cBitsWidth(uDst ^ (uDst << 1)); /* Set according to the first shift. */ \ 2576 fEfl |= (uDst >> (a_cBitsWidth - cShift)) & X86_EFL_CF; /* CF = last bit shifted out */ \ 2577 fEfl |= g_afParity[uResult & 0xff]; \ 2578 fEfl |= X86_EFL_CALC_SF(uResult, a_cBitsWidth); \ 2579 fEfl |= X86_EFL_CALC_ZF(uResult); \ 2580 *pfEFlags = fEfl; \ 2581 } \ 2582 }\ 2583 \ 2584 IEM_DECL_IMPL_DEF(void, iemAImpl_shld_u ## a_cBitsWidth ## _intel,(uint ## a_cBitsWidth ## _t *puDst, \ 2585 uint ## a_cBitsWidth ## _t uSrc, uint8_t cShift, \ 2586 uint32_t *pfEFlags)) \ 2587 { \ 2588 iemAImpl_shld_u ## a_cBitsWidth(puDst, uSrc, cShift, pfEFlags); \ 2589 } \ 2590 \ 2591 IEM_DECL_IMPL_DEF(void, iemAImpl_shld_u ## a_cBitsWidth ## _amd,(uint ## a_cBitsWidth ## _t *puDst, \ 2592 uint ## a_cBitsWidth ## _t uSrc, uint8_t cShift, \ 2593 uint32_t *pfEFlags)) \ 2594 { \ 2595 cShift &= a_cBitsWidth - 1; \ 2596 if (cShift) \ 2597 { \ 2598 uint ## a_cBitsWidth ## _t const uDst = *puDst; \ 2599 uint ## a_cBitsWidth ## _t uResult = uDst << cShift; \ 2600 uResult |= uSrc >> (a_cBitsWidth - cShift); \ 2601 *puDst = uResult; \ 2602 \ 2603 uint32_t fEfl = *pfEFlags & ~X86_EFL_STATUS_BITS; \ 2604 fEfl |= X86_EFL_GET_OF_ ## a_cBitsWidth((uDst << (cShift - 1)) ^ uResult); /* Set according to last shift. */ \ 2605 fEfl |= X86_EFL_AF; \ 2577 if (a_fIntelFlags) \ 2578 /* Intel 6700K & 10980XE: Set according to the first shift. AF always cleared. */ \ 2579 fEfl |= X86_EFL_GET_OF_ ## a_cBitsWidth(uDst ^ (uDst << 1)); \ 2580 else \ 2581 { /* AMD 3990X: Set according to last shift. AF always set. */ \ 2582 fEfl |= X86_EFL_GET_OF_ ## a_cBitsWidth((uDst << (cShift - 1)) ^ uResult); \ 2583 fEfl |= X86_EFL_AF; \ 2584 } \ 2606 2585 AssertCompile(X86_EFL_CF_BIT == 0); \ 2607 2586 fEfl |= (uDst >> (a_cBitsWidth - cShift)) & X86_EFL_CF; /* CF = last bit shifted out */ \ … … 2612 2591 } \ 2613 2592 } 2614 2615 EMIT_SHLD(64) 2616 # if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY) 2617 EMIT_SHLD(32) 2618 EMIT_SHLD(16) 2619 # endif 2593 #if !defined(RT_ARCH_AMD64) || defined(IEM_WITHOUT_ASSEMBLY) 2594 EMIT_SHLD(64, uint64_t, RT_NOTHING, 1) 2595 #endif /* !defined(RT_ARCH_AMD64) || defined(IEM_WITHOUT_ASSEMBLY) */ 2596 EMIT_SHLD(64, uint64_t, _intel, 1) 2597 EMIT_SHLD(64, uint64_t, _amd, 0) 2598 #if (!defined(RT_ARCH_X86) && !defined(RT_ARCH_AMD64)) || defined(IEM_WITHOUT_ASSEMBLY) 2599 EMIT_SHLD(32, uint32_t, RT_NOTHING, 1) 2600 #endif 2601 EMIT_SHLD(32, uint32_t, _intel, 1) 2602 EMIT_SHLD(32, uint32_t, _amd, 0) 2603 #if (!defined(RT_ARCH_X86) && !defined(RT_ARCH_AMD64)) || defined(IEM_WITHOUT_ASSEMBLY) 2604 EMIT_SHLD(16, uint16_t, RT_NOTHING, 1) 2605 #endif 2606 EMIT_SHLD(16, uint16_t, _intel, 1) 2607 EMIT_SHLD(16, uint16_t, _amd, 0) 2620 2608 2621 2609 … … 2631 2619 * - ZF, SF and PF are calculated according to the result by both vendors. 2632 2620 */ 2633 #define EMIT_SHRD(a_cBitsWidth) \ 2634 IEM_DECL_IMPL_DEF(void, iemAImpl_shrd_u ## a_cBitsWidth,(uint ## a_cBitsWidth ## _t *puDst, \ 2635 uint ## a_cBitsWidth ## _t uSrc, uint8_t cShift, uint32_t *pfEFlags)) \ 2621 #define EMIT_SHRD(a_cBitsWidth, a_uType, a_Suffix, a_fIntelFlags) \ 2622 IEM_DECL_IMPL_DEF(void, RT_CONCAT3(iemAImpl_shrd_u,a_cBitsWidth,a_Suffix),(a_uType *puDst, a_uType uSrc, uint8_t cShift, uint32_t *pfEFlags)) \ 2636 2623 { \ 2637 2624 /** @todo this is wrong for 16-bit, where it should be 0x1f not 0xf and \ … … 2640 2627 if (cShift) \ 2641 2628 { \ 2642 uint ## a_cBitsWidth ## _tconst uDst = *puDst; \2643 uint ## a_cBitsWidth ## _tuResult = uDst >> cShift; \2629 a_uType const uDst = *puDst; \ 2630 a_uType uResult = uDst >> cShift; \ 2644 2631 uResult |= uSrc << (a_cBitsWidth - cShift); \ 2645 2632 *puDst = uResult; \ 2646 2633 \ 2647 2634 uint32_t fEfl = *pfEFlags & ~X86_EFL_STATUS_BITS; \ 2648 fEfl |= X86_EFL_GET_OF_ ## a_cBitsWidth(uDst ^ (uSrc << (a_cBitsWidth - 1))); \ 2635 if (a_fIntelFlags) \ 2636 /* Intel 6700K & 10980XE: Set according to the first shift. AF always cleared. */ \ 2637 fEfl |= X86_EFL_GET_OF_ ## a_cBitsWidth(uDst ^ (uSrc << (a_cBitsWidth - 1))); \ 2638 else \ 2639 { /* AMD 3990X: Set according to last shift. AF always set. */ \ 2640 if (cShift > 1) /* Set according to last shift. */ \ 2641 fEfl |= X86_EFL_GET_OF_ ## a_cBitsWidth((uSrc << (a_cBitsWidth - cShift + 1)) ^ uResult); \ 2642 else \ 2643 fEfl |= X86_EFL_GET_OF_ ## a_cBitsWidth(uDst ^ uResult); \ 2644 fEfl |= X86_EFL_AF; \ 2645 } \ 2649 2646 AssertCompile(X86_EFL_CF_BIT == 0); \ 2650 2647 fEfl |= (uDst >> (cShift - 1)) & X86_EFL_CF; \ … … 2654 2651 *pfEFlags = fEfl; \ 2655 2652 } \ 2656 } \ 2657 \ 2658 IEM_DECL_IMPL_DEF(void, iemAImpl_shrd_u ## a_cBitsWidth ## _intel,(uint ## a_cBitsWidth ## _t *puDst, \ 2659 uint ## a_cBitsWidth ## _t uSrc, uint8_t cShift, \ 2660 uint32_t *pfEFlags)) \ 2661 { \ 2662 iemAImpl_shrd_u ## a_cBitsWidth(puDst, uSrc, cShift, pfEFlags); \ 2663 } \ 2664 \ 2665 IEM_DECL_IMPL_DEF(void, iemAImpl_shrd_u ## a_cBitsWidth ## _amd,(uint ## a_cBitsWidth ## _t *puDst, \ 2666 uint ## a_cBitsWidth ## _t uSrc, uint8_t cShift, \ 2667 uint32_t *pfEFlags)) \ 2668 { \ 2669 cShift &= a_cBitsWidth - 1; \ 2670 if (cShift) \ 2671 { \ 2672 uint ## a_cBitsWidth ## _t const uDst = *puDst; \ 2673 uint ## a_cBitsWidth ## _t uResult = uDst >> cShift; \ 2674 uResult |= uSrc << (a_cBitsWidth - cShift); \ 2675 *puDst = uResult; \ 2676 \ 2677 uint32_t fEfl = *pfEFlags & ~X86_EFL_STATUS_BITS; \ 2678 if (cShift > 1) /* Set according to last shift. */ \ 2679 fEfl |= X86_EFL_GET_OF_ ## a_cBitsWidth((uSrc << (a_cBitsWidth - cShift + 1)) ^ uResult); \ 2680 else \ 2681 fEfl |= X86_EFL_GET_OF_ ## a_cBitsWidth(uDst ^ uResult); \ 2682 fEfl |= X86_EFL_AF; \ 2683 AssertCompile(X86_EFL_CF_BIT == 0); \ 2684 fEfl |= (uDst >> (cShift - 1)) & X86_EFL_CF; \ 2685 fEfl |= X86_EFL_CALC_SF(uResult, a_cBitsWidth); \ 2686 fEfl |= X86_EFL_CALC_ZF(uResult); \ 2687 fEfl |= g_afParity[uResult & 0xff]; \ 2688 *pfEFlags = fEfl; \ 2689 } \ 2690 } 2691 EMIT_SHRD(64) 2692 # if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY) 2693 EMIT_SHRD(32) 2694 EMIT_SHRD(16) 2695 # endif 2696 2653 } 2654 #if !defined(RT_ARCH_AMD64) || defined(IEM_WITHOUT_ASSEMBLY) 2655 EMIT_SHRD(64, uint64_t, RT_NOTHING, 1) 2656 #endif /* !defined(RT_ARCH_AMD64) || defined(IEM_WITHOUT_ASSEMBLY) */ 2657 EMIT_SHRD(64, uint64_t, _intel, 1) 2658 EMIT_SHRD(64, uint64_t, _amd, 0) 2659 #if (!defined(RT_ARCH_X86) && !defined(RT_ARCH_AMD64)) || defined(IEM_WITHOUT_ASSEMBLY) 2660 EMIT_SHRD(32, uint32_t, RT_NOTHING, 1) 2661 #endif 2662 EMIT_SHRD(32, uint32_t, _intel, 1) 2663 EMIT_SHRD(32, uint32_t, _amd, 0) 2664 #if (!defined(RT_ARCH_X86) && !defined(RT_ARCH_AMD64)) || defined(IEM_WITHOUT_ASSEMBLY) 2665 EMIT_SHRD(16, uint16_t, RT_NOTHING, 1) 2666 #endif 2667 EMIT_SHRD(16, uint16_t, _intel, 1) 2668 EMIT_SHRD(16, uint16_t, _amd, 0) 2669 2670 2671 #if !defined(RT_ARCH_AMD64) || defined(IEM_WITHOUT_ASSEMBLY) 2697 2672 2698 2673 # if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
Note:
See TracChangeset
for help on using the changeset viewer.