Changeset 103740 in vbox
- Timestamp:
- Mar 9, 2024 1:42:20 AM (9 months ago)
- Location:
- trunk/src/VBox/VMM/VMMAll
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/IEMAllInstOneByte.cpp.h
r103739 r103740 1724 1724 { 1725 1725 IEMOP_MNEMONIC2(FIXED, SUB, sub, AL, Ib, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES); 1726 IEMOP_BODY_BINARY_AL_Ib(sub, 0);1726 IEMOP_BODY_BINARY_AL_Ib(sub, RT_ARCH_VAL_AMD64 | RT_ARCH_VAL_ARM64); 1727 1727 } 1728 1728 … … 1736 1736 { 1737 1737 IEMOP_MNEMONIC2(FIXED, SUB, sub, rAX, Iz, DISOPTYPE_HARMLESS, 0); 1738 IEMOP_BODY_BINARY_rAX_Iz_RW(sub, 0);1738 IEMOP_BODY_BINARY_rAX_Iz_RW(sub, RT_ARCH_VAL_AMD64 | RT_ARCH_VAL_ARM64); 1739 1739 } 1740 1740 … … 4440 4440 { 4441 4441 IEMOP_MNEMONIC(sub_Eb_Ib, "sub Eb,Ib"); 4442 IEMOP_BODY_BINARY_Eb_Ib_RW(sub, 0, 0);4442 IEMOP_BODY_BINARY_Eb_Ib_RW(sub, RT_ARCH_VAL_AMD64 | RT_ARCH_VAL_ARM64, 0); 4443 4443 } 4444 4444 … … 5013 5013 { 5014 5014 IEMOP_MNEMONIC(sub_Ev_Iz, "sub Ev,Iz"); 5015 IEMOP_BODY_BINARY_Ev_Iz_RW(sub, 0, 0);5015 IEMOP_BODY_BINARY_Ev_Iz_RW(sub, RT_ARCH_VAL_AMD64 | RT_ARCH_VAL_ARM64, 0); 5016 5016 } 5017 5017 -
trunk/src/VBox/VMM/VMMAll/target-x86/IEMAllN8veEmit-x86.h
r103739 r103740 732 732 else 733 733 { 734 uint8_t const idx TmpImmReg= iemNativeRegAllocTmpImm(pReNative, &off, uImmOp);734 uint8_t const idxRegTmpImm = iemNativeRegAllocTmpImm(pReNative, &off, uImmOp); 735 735 pCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 1); 736 pCodeBuf[off++] = Armv8A64MkInstrAddReg(idxRegDst, idxRegDst, idx TmpImmReg, cOpBits > 32 /*f64Bit*/, true /*fSetFlags*/);737 iemNativeRegFreeTmpImm(pReNative, idx TmpImmReg);736 pCodeBuf[off++] = Armv8A64MkInstrAddReg(idxRegDst, idxRegDst, idxRegTmpImm, cOpBits > 32 /*f64Bit*/, true /*fSetFlags*/); 737 iemNativeRegFreeTmpImm(pReNative, idxRegTmpImm); 738 738 } 739 739 } … … 742 742 /* Shift the operands up so we can perform a 32-bit operation and get all four flags. */ 743 743 uint32_t const cShift = 32 - cOpBits; 744 uint8_t const idx TmpImmReg= iemNativeRegAllocTmpImm(pReNative, &off, uImmOp << cShift);744 uint8_t const idxRegTmpImm = iemNativeRegAllocTmpImm(pReNative, &off, uImmOp << cShift); 745 745 pCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 2); 746 pCodeBuf[off++] = Armv8A64MkInstrAddReg(idxRegDst, idx TmpImmReg, idxRegDstIn, false /*f64Bit*/, true /*fSetFlags*/, cShift);746 pCodeBuf[off++] = Armv8A64MkInstrAddReg(idxRegDst, idxRegTmpImm, idxRegDstIn, false /*f64Bit*/, true /*fSetFlags*/, cShift); 747 747 pCodeBuf[off++] = Armv8A64MkInstrLsrImm(idxRegDst, idxRegDst, cShift, false /*f64Bit*/); 748 748 cOpBits = 32; 749 iemNativeRegFreeTmpImm(pReNative, idx TmpImmReg);749 iemNativeRegFreeTmpImm(pReNative, idxRegTmpImm); 750 750 } 751 751 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); … … 908 908 uint8_t idxVarDst, uint64_t uImmOp, uint8_t idxVarEfl, uint8_t cOpBits, uint8_t cImmBits) 909 909 { 910 RT_NOREF(pReNative, off, idxVarDst, uImmOp, idxVarEfl, cOpBits, cImmBits); 910 uint8_t const idxRegDst = iemNativeVarRegisterAcquire(pReNative, idxVarDst, &off, true /*fInitialized*/); 911 912 #ifdef RT_ARCH_AMD64 913 /* On AMD64 we just use the correctly sized SUB instruction to get the right EFLAGS.SF value. */ 914 PIEMNATIVEINSTR const pCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 8); 915 off = iemNativeEmitAmd64OneByteModRmInstrRIEx(pCodeBuf, off, 0x80, 0x83, 0x81, cOpBits, cImmBits, 5, idxRegDst, uImmOp); 916 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 917 918 iemNativeVarRegisterRelease(pReNative, idxVarDst); 919 920 off = iemNativeEmitEFlagsForArithmetic(pReNative, off, idxVarEfl, UINT8_MAX); 921 922 #elif defined(RT_ARCH_ARM64) 923 /* On ARM64 we'll need the two input operands as well as the result in order 924 to calculate the right flags, even if we use SUBS and translates NZCV into 925 OF, CF, ZF and SF. */ 926 uint8_t const idxRegDstIn = iemNativeRegAllocTmp(pReNative, &off); 927 PIEMNATIVEINSTR pCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 8); 928 off = iemNativeEmitLoadGprFromGprEx(pCodeBuf, off, idxRegDstIn, idxRegDst); 929 if (cOpBits >= 32) 930 { 931 if (uImmOp <= 0xfffU) 932 pCodeBuf[off++] = Armv8A64MkInstrSubUImm12(idxRegDst, idxRegDst, uImmOp, cOpBits > 32 /*f64Bit*/, true /*fSetFlags*/); 933 else if (uImmOp <= 0xfff000U && !(uImmOp & 0xfff)) 934 pCodeBuf[off++] = Armv8A64MkInstrSubUImm12(idxRegDst, idxRegDst, uImmOp, cOpBits > 32 /*f64Bit*/, true /*fSetFlags*/, 935 true /*fShift12*/); 936 else 937 { 938 uint8_t const idxRegTmpImm = iemNativeRegAllocTmpImm(pReNative, &off, uImmOp); 939 pCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 1); 940 pCodeBuf[off++] = Armv8A64MkInstrSubReg(idxRegDst, idxRegDst, idxRegTmpImm, cOpBits > 32 /*f64Bit*/, true /*fSetFlags*/); 941 iemNativeRegFreeTmpImm(pReNative, idxRegTmpImm); 942 } 943 } 944 else 945 { 946 /* Shift the operands up so we can perform a 32-bit operation and get all four flags. */ 947 uint32_t const cShift = 32 - cOpBits; 948 uint8_t const idxRegTmpImm = iemNativeRegAllocTmpImm(pReNative, &off, uImmOp); 949 pCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 4); 950 pCodeBuf[off++] = Armv8A64MkInstrLslImm(idxRegDstIn, idxRegDstIn, cShift, false /*f64Bit*/); 951 pCodeBuf[off++] = Armv8A64MkInstrSubReg(idxRegDst, idxRegDstIn, idxRegTmpImm, false /*f64Bit*/, true /*fSetFlags*/, cShift); 952 pCodeBuf[off++] = Armv8A64MkInstrLsrImm(idxRegDstIn, idxRegDstIn, cShift, false /*f64Bit*/); 953 pCodeBuf[off++] = Armv8A64MkInstrLsrImm(idxRegDst, idxRegDst, cShift, false /*f64Bit*/); 954 cOpBits = 32; 955 iemNativeRegFreeTmpImm(pReNative, idxRegTmpImm); 956 } 957 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 958 959 off = iemNativeEmitEFlagsForArithmetic(pReNative, off, idxVarEfl, UINT8_MAX, cOpBits, idxRegDst, 960 idxRegDstIn, UINT8_MAX, true /*fInvertCarry*/, uImmOp); 961 962 iemNativeRegFreeTmp(pReNative, idxRegDstIn); 963 iemNativeVarRegisterRelease(pReNative, idxVarDst); 964 RT_NOREF(cImmBits); 965 966 #else 967 # error "port me" 968 #endif 911 969 return off; 912 970 }
Note:
See TracChangeset
for help on using the changeset viewer.