Changeset 102436 in vbox for trunk/src/VBox/VMM/include
- Timestamp:
- Dec 2, 2023 10:09:36 PM (17 months ago)
- svn:sync-xref-src-repo-rev:
- 160579
- Location:
- trunk/src/VBox/VMM/include
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/include/IEMN8veRecompiler.h
r102394 r102436 817 817 DECLHIDDEN(void) iemNativeRegFreeTmp(PIEMRECOMPILERSTATE pReNative, uint8_t idxHstReg) RT_NOEXCEPT; 818 818 DECLHIDDEN(void) iemNativeRegFreeTmpImm(PIEMRECOMPILERSTATE pReNative, uint8_t idxHstReg) RT_NOEXCEPT; 819 DECLHIDDEN(void) iemNativeRegFreeVar(PIEMRECOMPILERSTATE pReNative, uint8_t idxHstReg, bool fFlushShadows) RT_NOEXCEPT; 819 820 DECLHIDDEN(void) iemNativeRegFreeAndFlushMask(PIEMRECOMPILERSTATE pReNative, uint32_t fHstRegMask) RT_NOEXCEPT; 820 821 DECL_HIDDEN_THROW(uint32_t) iemNativeRegFlushPendingWrites(PIEMRECOMPILERSTATE pReNative, uint32_t off); 822 823 DECL_HIDDEN_THROW(uint8_t) iemNativeVarGetStackSlot(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar); 821 824 822 825 DECL_HIDDEN_THROW(uint32_t) iemNativeEmitLoadGprWithGstShadowReg(PIEMRECOMPILERSTATE pReNative, uint32_t off, -
trunk/src/VBox/VMM/include/IEMN8veRecompilerEmit.h
r102394 r102436 65 65 pbCodeBuf[off++] = RT_BYTE4(uInfo); 66 66 } 67 #elif RT_ARCH_ARM6467 #elif defined(RT_ARCH_ARM64) 68 68 /* nop */ 69 69 uint32_t *pu32CodeBuf = iemNativeInstrBufEnsure(pReNative, off, 1); … … 73 73 #else 74 74 # error "port me" 75 #endif 76 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 77 return off; 78 } 79 80 81 /** 82 * Emit a breakpoint instruction. 83 */ 84 DECL_INLINE_THROW(uint32_t) iemNativeEmitBrk(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint32_t uInfo) 85 { 86 #ifdef RT_ARCH_AMD64 87 uint8_t * const pbCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 1); 88 pbCodeBuf[off++] = 0xcc; 89 RT_NOREF(uInfo); 90 91 #elif defined(RT_ARCH_ARM64) 92 uint32_t * const pu32CodeBuf = iemNativeInstrBufEnsure(pReNative, off, 1); 93 pu32CodeBuf[off++] = Armv8A64MkInstrBrk(uInfo & UINT32_C(0xffff)); 94 95 #else 96 # error "error" 75 97 #endif 76 98 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); … … 97 119 pbCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, iGpr & 7, iGpr & 7); 98 120 99 #elif RT_ARCH_ARM64121 #elif defined(RT_ARCH_ARM64) 100 122 /* mov gpr, #0x0 */ 101 123 uint32_t *pu32CodeBuf = iemNativeInstrBufEnsure(pReNative, off, 1); … … 151 173 } 152 174 153 #elif RT_ARCH_ARM64175 #elif defined(RT_ARCH_ARM64) 154 176 uint32_t *pu32CodeBuf = iemNativeInstrBufEnsure(pReNative, off, 4); 155 177 … … 223 245 pbCodeBuf[off++] = RT_BYTE1(uImm8); 224 246 225 #elif RT_ARCH_ARM64247 #elif defined(RT_ARCH_ARM64) 226 248 /* movz gpr, imm16, lsl #0 */ 227 249 uint32_t * const pu32CodeBuf = iemNativeInstrBufEnsure(pReNative, off, 1); … … 258 280 return off; 259 281 } 260 #elif RT_ARCH_ARM64282 #elif defined(RT_ARCH_ARM64) 261 283 /** 262 284 * Common bit of iemNativeEmitLoadGprFromVCpuU64 and friends. … … 317 339 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 318 340 319 #elif RT_ARCH_ARM64341 #elif defined(RT_ARCH_ARM64) 320 342 off = iemNativeEmitGprByVCpuLdSt(pReNative, off, iGpr, offVCpu, kArmv8A64InstrLdStType_Ld_Dword, sizeof(uint64_t)); 321 343 … … 343 365 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 344 366 345 #elif RT_ARCH_ARM64367 #elif defined(RT_ARCH_ARM64) 346 368 off = iemNativeEmitGprByVCpuLdSt(pReNative, off, iGpr, offVCpu, kArmv8A64InstrLdStType_Ld_Word, sizeof(uint32_t)); 347 369 … … 370 392 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 371 393 372 #elif RT_ARCH_ARM64394 #elif defined(RT_ARCH_ARM64) 373 395 off = iemNativeEmitGprByVCpuLdSt(pReNative, off, iGpr, offVCpu, kArmv8A64InstrLdStType_Ld_Half, sizeof(uint16_t)); 374 396 … … 397 419 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 398 420 399 #elif RT_ARCH_ARM64421 #elif defined(RT_ARCH_ARM64) 400 422 off = iemNativeEmitGprByVCpuLdSt(pReNative, off, iGpr, offVCpu, kArmv8A64InstrLdStType_Ld_Byte, sizeof(uint8_t)); 401 423 … … 424 446 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 425 447 426 #elif RT_ARCH_ARM64448 #elif defined(RT_ARCH_ARM64) 427 449 off = iemNativeEmitGprByVCpuLdSt(pReNative, off, iGpr, offVCpu, kArmv8A64InstrLdStType_St_Dword, sizeof(uint64_t)); 428 450 … … 449 471 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 450 472 451 #elif RT_ARCH_ARM64473 #elif defined(RT_ARCH_ARM64) 452 474 off = iemNativeEmitGprByVCpuLdSt(pReNative, off, iGpr, offVCpu, kArmv8A64InstrLdStType_St_Word, sizeof(uint32_t)); 453 475 … … 475 497 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 476 498 477 #elif RT_ARCH_ARM64499 #elif defined(RT_ARCH_ARM64) 478 500 off = iemNativeEmitGprByVCpuLdSt(pReNative, off, iGpr, offVCpu, kArmv8A64InstrLdStType_St_Half, sizeof(uint16_t)); 479 501 … … 500 522 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 501 523 502 #elif RT_ARCH_ARM64524 #elif defined(RT_ARCH_ARM64) 503 525 off = iemNativeEmitGprByVCpuLdSt(pReNative, off, iGpr, offVCpu, kArmv8A64InstrLdStType_St_Byte, sizeof(uint8_t)); 504 526 … … 524 546 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 525 547 526 #elif RT_ARCH_ARM64548 #elif defined(RT_ARCH_ARM64) 527 549 /* Cannot use IEMNATIVE_REG_FIXED_TMP0 for the immediate as that's used by iemNativeEmitGprByVCpuLdSt. */ 528 550 uint8_t const idxRegImm = iemNativeRegAllocTmpImm(pReNative, &off, bImm); … … 599 621 pbCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, iGprDst & 7, iGprSrc & 7); 600 622 601 #elif RT_ARCH_ARM64623 #elif defined(RT_ARCH_ARM64) 602 624 /* mov dst, src; alias for: orr dst, xzr, src */ 603 625 uint32_t * const pu32CodeBuf = iemNativeInstrBufEnsure(pReNative, off, 1); … … 629 651 pbCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, iGprDst & 7, iGprSrc & 7); 630 652 631 #elif RT_ARCH_ARM64653 #elif defined(RT_ARCH_ARM64) 632 654 /* mov dst32, src32; alias for: orr dst32, wzr, src32 */ 633 655 uint32_t * const pu32CodeBuf = iemNativeInstrBufEnsure(pReNative, off, 1); … … 660 682 pbCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, iGprDst & 7, iGprSrc & 7); 661 683 662 #elif RT_ARCH_ARM64684 #elif defined(RT_ARCH_ARM64) 663 685 /* and gprdst, gprsrc, #0xffff */ 664 686 uint32_t * const pu32CodeBuf = iemNativeInstrBufEnsure(pReNative, off, 1); … … 699 721 pbCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, iGprDst & 7, iGprSrc & 7); 700 722 701 #elif RT_ARCH_ARM64723 #elif defined(RT_ARCH_ARM64) 702 724 /* and gprdst, gprsrc, #0xff */ 703 725 uint32_t * const pu32CodeBuf = iemNativeInstrBufEnsure(pReNative, off, 1); … … 744 766 pbCodeBuf[off++] = 8; 745 767 746 #elif RT_ARCH_ARM64768 #elif defined(RT_ARCH_ARM64) 747 769 /* ubfx gprdst, gprsrc, #8, #8 - gprdst = gprsrc[15:8] */ 748 770 uint32_t * const pu32CodeBuf = iemNativeInstrBufEnsure(pReNative, off, 1); … … 790 812 } 791 813 792 #elif RT_ARCH_ARM64814 #elif defined(RT_ARCH_ARM64) 793 815 if ((uint32_t)iAddend < 4096) 794 816 { … … 1151 1173 return off; 1152 1174 } 1153 #elif RT_ARCH_ARM641175 #elif defined(RT_ARCH_ARM64) 1154 1176 /** 1155 1177 * Common bit of iemNativeEmitLoadGprFromVCpuU64 and friends. … … 1202 1224 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 1203 1225 1204 #elif RT_ARCH_ARM641226 #elif defined(RT_ARCH_ARM64) 1205 1227 off = iemNativeEmitGprByGprLdSt(pReNative, off, iGprDst, iGprBase, offDisp, kArmv8A64InstrLdStType_Ld_Dword, sizeof(uint64_t)); 1206 1228 … … 1228 1250 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 1229 1251 1230 #elif RT_ARCH_ARM641252 #elif defined(RT_ARCH_ARM64) 1231 1253 off = iemNativeEmitGprByGprLdSt(pReNative, off, iGprDst, iGprBase, offDisp, kArmv8A64InstrLdStType_Ld_Word, sizeof(uint32_t)); 1232 1254 … … 1582 1604 #elif defined(RT_ARCH_ARM64) 1583 1605 uint32_t *pu32CodeBuf = iemNativeInstrBufEnsure(pReNative, off, 1); 1584 if ( fSetFlags)1606 if (!fSetFlags) 1585 1607 pu32CodeBuf[off++] = Armv8A64MkInstrAnd(iGprDst, iGprDst, iGprSrc, false /*f64Bit*/); 1586 1608 else … … 2674 2696 2675 2697 /** 2698 * Emits a test for any of the bits from @a fBits in the lower 8 bits of 2699 * @a iGprSrc, setting CPU flags accordingly. 2700 */ 2701 DECL_INLINE_THROW(uint32_t) 2702 iemNativeEmitTestAnyBitsInGpr8(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint8_t iGprSrc, uint8_t fBits) 2703 { 2704 Assert(fBits != 0); 2705 2706 #ifdef RT_ARCH_AMD64 2707 /* test Eb, imm8 */ 2708 uint8_t * const pbCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 4); 2709 if (iGprSrc >= 4) 2710 pbCodeBuf[off++] = iGprSrc >= 8 ? X86_OP_REX_B : X86_OP_REX; 2711 pbCodeBuf[off++] = 0xf6; 2712 pbCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, 0, iGprSrc & 7); 2713 pbCodeBuf[off++] = fBits; 2714 2715 #elif defined(RT_ARCH_ARM64) 2716 2717 /* ands xzr, src, [tmp|#imm] */ 2718 uint32_t uImmR = 0; 2719 uint32_t uImmNandS = 0; 2720 if (Armv8A64ConvertMask32ToImmRImmS(uImm, &uImmNandS, &uImmR)) 2721 { 2722 uint32_t *pu32CodeBuf = iemNativeInstrBufEnsure(pReNative, off, 1); 2723 pu32CodeBuf[off++] = Armv8A64MkInstrAndsImm(ARMV8_A64_REG_XZR, iGprDst, uImmNandS, uImmR, false /*f64Bit*/); 2724 } 2725 else 2726 { 2727 /* Use temporary register for the 64-bit immediate. */ 2728 uint8_t iTmpReg = iemNativeRegAllocTmpImm(pReNative, &off, uImm); 2729 uint32_t *pu32CodeBuf = iemNativeInstrBufEnsure(pReNative, off, 1); 2730 pu32CodeBuf[off++] = Armv8A64MkInstrAnds(ARMV8_A64_REG_XZR, iGprSrc, iTmpReg, false /*f64Bit*/); 2731 iemNativeRegFreeTmpImm(pReNative, iTmpReg); 2732 } 2733 2734 #else 2735 # error "Port me!" 2736 #endif 2737 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); 2738 return off; 2739 } 2740 2741 2742 /** 2676 2743 * Emits a jump to @a idxLabel on the condition _any_ of the bits in @a fBits 2677 2744 * are set in @a iGprSrc. … … 2838 2905 2839 2906 2907 /********************************************************************************************************************************* 2908 * Calls. * 2909 *********************************************************************************************************************************/ 2840 2910 2841 2911 /** … … 2866 2936 2867 2937 2938 /** 2939 * Emits code to load a stack variable into an argument GPR. 2940 * @throws VERR_IEM_VAR_NOT_INITIALIZED, VERR_IEM_VAR_UNEXPECTED_KIND 2941 */ 2942 DECL_FORCE_INLINE_THROW(uint32_t) 2943 iemNativeEmitLoadArgGregFromStackVar(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint8_t idxRegArg, uint8_t idxVar, 2944 int32_t offAddend = 0) 2945 { 2946 IEMNATIVE_ASSERT_VAR_IDX(pReNative, idxVar); 2947 AssertStmt(pReNative->Core.aVars[idxVar].enmKind == kIemNativeVarKind_Stack, 2948 IEMNATIVE_DO_LONGJMP(pReNative, VERR_IEM_VAR_UNEXPECTED_KIND)); 2949 2950 uint8_t const idxRegVar = pReNative->Core.aVars[idxVar].idxReg; 2951 if (idxRegVar < RT_ELEMENTS(pReNative->Core.aHstRegs)) 2952 { 2953 Assert(!(RT_BIT_32(idxRegVar) & IEMNATIVE_CALL_VOLATILE_GREG_MASK)); 2954 if (!offAddend) 2955 off = iemNativeEmitLoadGprFromGpr(pReNative, off, idxRegArg, idxRegVar); 2956 else 2957 off = iemNativeEmitLoadGprFromGprWithAddend(pReNative, off, idxRegArg, idxRegVar, offAddend); 2958 } 2959 else 2960 { 2961 uint8_t const idxStackSlot = pReNative->Core.aVars[idxVar].idxStackSlot; 2962 AssertStmt(idxStackSlot != UINT8_MAX, IEMNATIVE_DO_LONGJMP(pReNative, VERR_IEM_VAR_NOT_INITIALIZED)); 2963 off = iemNativeEmitLoadGprByBp(pReNative, off, idxRegArg, iemNativeStackCalcBpDisp(idxStackSlot)); 2964 if (offAddend) 2965 off = iemNativeEmitAddGprImm(pReNative, off, idxRegArg, offAddend); 2966 } 2967 return off; 2968 } 2969 2970 2971 /** 2972 * Emits code to load a stack or immediate variable value into an argument GPR, 2973 * optional with a addend. 2974 * @throws VERR_IEM_VAR_NOT_INITIALIZED, VERR_IEM_VAR_UNEXPECTED_KIND 2975 */ 2976 DECL_FORCE_INLINE_THROW(uint32_t) 2977 iemNativeEmitLoadArgGregFromImmOrStackVar(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint8_t idxRegArg, uint8_t idxVar, 2978 int32_t offAddend = 0) 2979 { 2980 IEMNATIVE_ASSERT_VAR_IDX(pReNative, idxVar); 2981 if (pReNative->Core.aVars[idxVar].enmKind == kIemNativeVarKind_Immediate) 2982 off = iemNativeEmitLoadGprImm64(pReNative, off, idxRegArg, pReNative->Core.aVars[idxVar].u.uValue + offAddend); 2983 else 2984 off = iemNativeEmitLoadArgGregFromStackVar(pReNative, off, idxRegArg, idxVar, offAddend); 2985 return off; 2986 } 2987 2988 2989 /** 2990 * Emits code to load the variable address into an argument GRP. 2991 * 2992 * This only works for uninitialized and stack variables. 2993 */ 2994 DECL_FORCE_INLINE_THROW(uint32_t) 2995 iemNativeEmitLoadArgGregWithVarAddr(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint8_t idxRegArg, uint8_t idxVar, 2996 bool fFlushShadows) 2997 { 2998 IEMNATIVE_ASSERT_VAR_IDX(pReNative, idxVar); 2999 AssertStmt( pReNative->Core.aVars[idxVar].enmKind == kIemNativeVarKind_Invalid 3000 || pReNative->Core.aVars[idxVar].enmKind == kIemNativeVarKind_Stack, 3001 IEMNATIVE_DO_LONGJMP(pReNative, VERR_IEM_VAR_UNEXPECTED_KIND)); 3002 3003 uint8_t const idxStackSlot = iemNativeVarGetStackSlot(pReNative, idxVar); 3004 int32_t const offBpDisp = iemNativeStackCalcBpDisp(idxStackSlot); 3005 3006 uint8_t const idxRegVar = pReNative->Core.aVars[idxVar].idxReg; 3007 if (idxRegVar < RT_ELEMENTS(pReNative->Core.aHstRegs)) 3008 { 3009 off = iemNativeEmitStoreGprByBp(pReNative, off, offBpDisp, idxRegVar); 3010 iemNativeRegFreeVar(pReNative, idxRegVar, fFlushShadows); 3011 Assert(pReNative->Core.aVars[idxVar].idxReg == UINT8_MAX); 3012 } 3013 Assert( pReNative->Core.aVars[idxVar].idxStackSlot != UINT8_MAX 3014 && pReNative->Core.aVars[idxVar].idxReg == UINT8_MAX); 3015 3016 return iemNativeEmitLeaGprByBp(pReNative, off, idxRegArg, offBpDisp); 3017 } 3018 3019 2868 3020 /** @} */ 2869 3021
Note:
See TracChangeset
for help on using the changeset viewer.