Changeset 104056 in vbox for trunk/src/VBox/VMM/include/IEMN8veRecompilerEmit.h
- Timestamp:
- Mar 26, 2024 10:07:26 AM (10 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/include/IEMN8veRecompilerEmit.h
r104033 r104056 5670 5670 5671 5671 /** 5672 * Emits code for (signed) shifting a GPR a fixed number of bits to the right. 5673 */ 5674 DECL_FORCE_INLINE(uint32_t) 5675 iemNativeEmitArithShiftGprRightEx(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 */ 5707 DECL_INLINE_THROW(uint32_t) 5708 iemNativeEmitArithShiftGprRight(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 */ 5725 DECL_FORCE_INLINE(uint32_t) 5726 iemNativeEmitArithShiftGpr32RightEx(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 */ 5759 DECL_INLINE_THROW(uint32_t) 5760 iemNativeEmitArithShiftGpr32Right(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 /** 5672 5775 * Emits code for rotating a GPR a fixed number of bits to the left. 5673 5776 */
Note:
See TracChangeset
for help on using the changeset viewer.