Changeset 94191 in vbox
- Timestamp:
- Mar 11, 2022 11:26:08 PM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 150447
- Location:
- trunk/src/VBox/VMM/VMMAll
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/IEMAllAImpl.asm
r94190 r94191 1445 1445 PROLOGUE_3_ARGS 1446 1446 IEM_MAYBE_LOAD_FLAGS A2, %2, %3 1447 %ifdef ASM_CALL64_GCC1447 %ifdef ASM_CALL64_GCC 1448 1448 mov cl, A1_8 1449 1449 %1 qword [A0], cl 1450 %else1450 %else 1451 1451 xchg A1, A0 1452 1452 %1 qword [A1], cl 1453 %endif1453 %endif 1454 1454 IEM_SAVE_FLAGS A2, %2, %3 1455 1455 EPILOGUE_3_ARGS -
trunk/src/VBox/VMM/VMMAll/IEMAllAImplC.cpp
r94190 r94191 2212 2212 * ROL 2213 2213 */ 2214 2215 #define EMIT_ROL(a_cBitsWidth, a_Suffix, a_fIntelFlags, a_fnHlp) \ 2216 IEM_DECL_IMPL_DEF(void, RT_CONCAT3(iemAImpl_rol_u,a_cBitsWidth,a_Suffix),(uint ## a_cBitsWidth ## _t *puDst, \ 2217 uint8_t cShift, uint32_t *pfEFlags)) \ 2214 #define EMIT_ROL(a_cBitsWidth, a_uType, a_Suffix, a_fIntelFlags, a_fnHlp) \ 2215 IEM_DECL_IMPL_DEF(void, RT_CONCAT3(iemAImpl_rol_u,a_cBitsWidth,a_Suffix),(a_uType *puDst, uint8_t cShift, uint32_t *pfEFlags)) \ 2218 2216 { \ 2219 cShift &= a_cBitsWidth -1; \2217 cShift &= a_cBitsWidth >= 32 ? a_cBitsWidth - 1 : 31; \ 2220 2218 if (cShift) \ 2221 2219 { \ 2222 uint ## a_cBitsWidth ## _t const uDst = *puDst; \ 2223 uint ## a_cBitsWidth ## _t const uResult = a_fnHlp(uDst, cShift); \ 2220 if (a_cBitsWidth < 32) \ 2221 cShift &= a_cBitsWidth - 1; \ 2222 a_uType const uDst = *puDst; \ 2223 a_uType const uResult = a_fnHlp(uDst, cShift); \ 2224 2224 *puDst = uResult; \ 2225 2225 \ … … 2240 2240 2241 2241 #if !defined(RT_ARCH_AMD64) || defined(IEM_WITHOUT_ASSEMBLY) 2242 EMIT_ROL(64, RT_NOTHING, 1, ASMRotateLeftU64)2243 #endif 2244 EMIT_ROL(64, _intel, 1, ASMRotateLeftU64)2245 EMIT_ROL(64, _amd, 0, ASMRotateLeftU64)2242 EMIT_ROL(64, uint64_t, RT_NOTHING, 1, ASMRotateLeftU64) 2243 #endif 2244 EMIT_ROL(64, uint64_t, _intel, 1, ASMRotateLeftU64) 2245 EMIT_ROL(64, uint64_t, _amd, 0, ASMRotateLeftU64) 2246 2246 2247 2247 #if (!defined(RT_ARCH_X86) && !defined(RT_ARCH_AMD64)) || defined(IEM_WITHOUT_ASSEMBLY) 2248 EMIT_ROL(32, RT_NOTHING, 1, ASMRotateLeftU32)2249 #endif 2250 EMIT_ROL(32, _intel, 1, ASMRotateLeftU32)2251 EMIT_ROL(32, _amd, 0, ASMRotateLeftU32)2248 EMIT_ROL(32, uint32_t, RT_NOTHING, 1, ASMRotateLeftU32) 2249 #endif 2250 EMIT_ROL(32, uint32_t, _intel, 1, ASMRotateLeftU32) 2251 EMIT_ROL(32, uint32_t, _amd, 0, ASMRotateLeftU32) 2252 2252 2253 2253 DECL_FORCE_INLINE(uint16_t) iemAImpl_rol_u16_hlp(uint16_t uValue, uint8_t cShift) … … 2256 2256 } 2257 2257 #if (!defined(RT_ARCH_X86) && !defined(RT_ARCH_AMD64)) || defined(IEM_WITHOUT_ASSEMBLY) 2258 EMIT_ROL(16, RT_NOTHING, 1, iemAImpl_rol_u16_hlp)2259 #endif 2260 EMIT_ROL(16, _intel, 1, iemAImpl_rol_u16_hlp)2261 EMIT_ROL(16, _amd, 0, iemAImpl_rol_u16_hlp)2258 EMIT_ROL(16, uint16_t, RT_NOTHING, 1, iemAImpl_rol_u16_hlp) 2259 #endif 2260 EMIT_ROL(16, uint16_t, _intel, 1, iemAImpl_rol_u16_hlp) 2261 EMIT_ROL(16, uint16_t, _amd, 0, iemAImpl_rol_u16_hlp) 2262 2262 2263 2263 DECL_FORCE_INLINE(uint8_t) iemAImpl_rol_u8_hlp(uint8_t uValue, uint8_t cShift) … … 2266 2266 } 2267 2267 #if (!defined(RT_ARCH_X86) && !defined(RT_ARCH_AMD64)) || defined(IEM_WITHOUT_ASSEMBLY) 2268 EMIT_ROL(8, RT_NOTHING, 1, iemAImpl_rol_u8_hlp)2269 #endif 2270 EMIT_ROL(8, _intel, 1, iemAImpl_rol_u8_hlp)2271 EMIT_ROL(8, _amd, 0, iemAImpl_rol_u8_hlp)2268 EMIT_ROL(8, uint8_t, RT_NOTHING, 1, iemAImpl_rol_u8_hlp) 2269 #endif 2270 EMIT_ROL(8, uint8_t, _intel, 1, iemAImpl_rol_u8_hlp) 2271 EMIT_ROL(8, uint8_t, _amd, 0, iemAImpl_rol_u8_hlp) 2272 2272 2273 2273 … … 2275 2275 * ROR 2276 2276 */ 2277 #define EMIT_ROR(a_cBitsWidth, a_Suffix, a_fIntelFlags, a_fnHlp) \ 2278 IEM_DECL_IMPL_DEF(void, RT_CONCAT3(iemAImpl_ror_u,a_cBitsWidth,a_Suffix),(uint ## a_cBitsWidth ## _t *puDst, \ 2279 uint8_t cShift, uint32_t *pfEFlags)) \ 2277 #define EMIT_ROR(a_cBitsWidth, a_uType, a_Suffix, a_fIntelFlags, a_fnHlp) \ 2278 IEM_DECL_IMPL_DEF(void, RT_CONCAT3(iemAImpl_ror_u,a_cBitsWidth,a_Suffix),(a_uType *puDst, uint8_t cShift, uint32_t *pfEFlags)) \ 2280 2279 { \ 2281 cShift &= a_cBitsWidth -1; \2280 cShift &= a_cBitsWidth >= 32 ? a_cBitsWidth - 1 : 31; \ 2282 2281 if (cShift) \ 2283 2282 { \ 2284 uint ## a_cBitsWidth ## _t const uDst = *puDst; \ 2285 uint ## a_cBitsWidth ## _t const uResult = a_fnHlp(uDst, cShift); \ 2283 if (a_cBitsWidth < 32) \ 2284 cShift &= a_cBitsWidth - 1; \ 2285 a_uType const uDst = *puDst; \ 2286 a_uType const uResult = a_fnHlp(uDst, cShift); \ 2286 2287 *puDst = uResult; \ 2287 2288 \ … … 2301 2302 2302 2303 #if !defined(RT_ARCH_AMD64) || defined(IEM_WITHOUT_ASSEMBLY) 2303 EMIT_ROR(64, RT_NOTHING, 1, ASMRotateRightU64)2304 #endif 2305 EMIT_ROR(64, _intel, 1, ASMRotateRightU64)2306 EMIT_ROR(64, _amd, 0, ASMRotateRightU64)2304 EMIT_ROR(64, uint64_t, RT_NOTHING, 1, ASMRotateRightU64) 2305 #endif 2306 EMIT_ROR(64, uint64_t, _intel, 1, ASMRotateRightU64) 2307 EMIT_ROR(64, uint64_t, _amd, 0, ASMRotateRightU64) 2307 2308 2308 2309 #if (!defined(RT_ARCH_X86) && !defined(RT_ARCH_AMD64)) || defined(IEM_WITHOUT_ASSEMBLY) 2309 EMIT_ROR(32, RT_NOTHING, 1, ASMRotateRightU32)2310 #endif 2311 EMIT_ROR(32, _intel, 1, ASMRotateRightU32)2312 EMIT_ROR(32, _amd, 0, ASMRotateRightU32)2310 EMIT_ROR(32, uint32_t, RT_NOTHING, 1, ASMRotateRightU32) 2311 #endif 2312 EMIT_ROR(32, uint32_t, _intel, 1, ASMRotateRightU32) 2313 EMIT_ROR(32, uint32_t, _amd, 0, ASMRotateRightU32) 2313 2314 2314 2315 DECL_FORCE_INLINE(uint16_t) iemAImpl_ror_u16_hlp(uint16_t uValue, uint8_t cShift) … … 2317 2318 } 2318 2319 #if (!defined(RT_ARCH_X86) && !defined(RT_ARCH_AMD64)) || defined(IEM_WITHOUT_ASSEMBLY) 2319 EMIT_ROR(16, RT_NOTHING, 1, iemAImpl_ror_u16_hlp)2320 #endif 2321 EMIT_ROR(16, _intel, 1, iemAImpl_ror_u16_hlp)2322 EMIT_ROR(16, _amd, 0, iemAImpl_ror_u16_hlp)2320 EMIT_ROR(16, uint16_t, RT_NOTHING, 1, iemAImpl_ror_u16_hlp) 2321 #endif 2322 EMIT_ROR(16, uint16_t, _intel, 1, iemAImpl_ror_u16_hlp) 2323 EMIT_ROR(16, uint16_t, _amd, 0, iemAImpl_ror_u16_hlp) 2323 2324 2324 2325 DECL_FORCE_INLINE(uint8_t) iemAImpl_ror_u8_hlp(uint8_t uValue, uint8_t cShift) … … 2327 2328 } 2328 2329 #if (!defined(RT_ARCH_X86) && !defined(RT_ARCH_AMD64)) || defined(IEM_WITHOUT_ASSEMBLY) 2329 EMIT_ROR(8, RT_NOTHING, 1, iemAImpl_ror_u8_hlp)2330 #endif 2331 EMIT_ROR(8, _intel, 1, iemAImpl_ror_u8_hlp)2332 EMIT_ROR(8, _amd, 0, iemAImpl_ror_u8_hlp)2330 EMIT_ROR(8, uint8_t, RT_NOTHING, 1, iemAImpl_ror_u8_hlp) 2331 #endif 2332 EMIT_ROR(8, uint8_t, _intel, 1, iemAImpl_ror_u8_hlp) 2333 EMIT_ROR(8, uint8_t, _amd, 0, iemAImpl_ror_u8_hlp) 2333 2334 2334 2335 … … 2336 2337 * RCL 2337 2338 */ 2338 #define EMIT_RCL(a_cBitsWidth, a_Suffix, a_fIntelFlags) \ 2339 IEM_DECL_IMPL_DEF(void, RT_CONCAT3(iemAImpl_rcl_u,a_cBitsWidth,a_Suffix),(uint ## a_cBitsWidth ## _t *puDst, \ 2340 uint8_t cShift, uint32_t *pfEFlags)) \ 2339 #define EMIT_RCL(a_cBitsWidth, a_uType, a_Suffix, a_fIntelFlags) \ 2340 IEM_DECL_IMPL_DEF(void, RT_CONCAT3(iemAImpl_rcl_u,a_cBitsWidth,a_Suffix),(a_uType *puDst, uint8_t cShift, uint32_t *pfEFlags)) \ 2341 2341 { \ 2342 cShift &= a_cBitsWidth -1; \2342 cShift &= a_cBitsWidth >= 32 ? a_cBitsWidth - 1 : 31; \ 2343 2343 if (cShift) \ 2344 2344 { \ 2345 uint ## a_cBitsWidth ## _t const uDst = *puDst; \ 2346 uint ## a_cBitsWidth ## _t uResult = uDst << cShift; \ 2345 if (a_cBitsWidth < 32) \ 2346 cShift %= a_cBitsWidth + 1; \ 2347 a_uType const uDst = *puDst; \ 2348 a_uType uResult = uDst << cShift; \ 2347 2349 if (cShift > 1) \ 2348 2350 uResult |= uDst >> (a_cBitsWidth + 1 - cShift); \ … … 2351 2353 uint32_t fEfl = *pfEFlags; \ 2352 2354 uint32_t fInCarry = fEfl & X86_EFL_CF; \ 2353 uResult |= ( uint ## a_cBitsWidth ## _t)fInCarry << (cShift - 1); \2355 uResult |= (a_uType)fInCarry << (cShift - 1); \ 2354 2356 \ 2355 2357 *puDst = uResult; \ … … 2357 2359 /* Calc EFLAGS. */ \ 2358 2360 fEfl &= ~(X86_EFL_CF | X86_EFL_OF); \ 2359 uint32_t const fOutCarry = (uDst >> (a_cBitsWidth - cShift)) & X86_EFL_CF; \ 2361 uint32_t const fOutCarry = a_cBitsWidth >= 32 || cShift \ 2362 ? (uDst >> (a_cBitsWidth - cShift)) & X86_EFL_CF : fInCarry; \ 2360 2363 fEfl |= fOutCarry; \ 2361 2364 if (!a_fIntelFlags) /* AMD 3990X: According to the last sub-shift: */ \ … … 2368 2371 2369 2372 #if !defined(RT_ARCH_AMD64) || defined(IEM_WITHOUT_ASSEMBLY) 2370 EMIT_RCL(64, RT_NOTHING, 1)2371 #endif 2372 EMIT_RCL(64, _intel, 1)2373 EMIT_RCL(64, _amd, 0)2373 EMIT_RCL(64, uint64_t, RT_NOTHING, 1) 2374 #endif 2375 EMIT_RCL(64, uint64_t, _intel, 1) 2376 EMIT_RCL(64, uint64_t, _amd, 0) 2374 2377 2375 2378 #if (!defined(RT_ARCH_X86) && !defined(RT_ARCH_AMD64)) || defined(IEM_WITHOUT_ASSEMBLY) 2376 EMIT_RCL(32, RT_NOTHING, 1)2377 #endif 2378 EMIT_RCL(32, _intel, 1)2379 EMIT_RCL(32, _amd, 0)2379 EMIT_RCL(32, uint32_t, RT_NOTHING, 1) 2380 #endif 2381 EMIT_RCL(32, uint32_t, _intel, 1) 2382 EMIT_RCL(32, uint32_t, _amd, 0) 2380 2383 2381 2384 #if (!defined(RT_ARCH_X86) && !defined(RT_ARCH_AMD64)) || defined(IEM_WITHOUT_ASSEMBLY) 2382 EMIT_RCL(16, RT_NOTHING, 1)2383 #endif 2384 EMIT_RCL(16, _intel, 1)2385 EMIT_RCL(16, _amd, 0)2385 EMIT_RCL(16, uint16_t, RT_NOTHING, 1) 2386 #endif 2387 EMIT_RCL(16, uint16_t, _intel, 1) 2388 EMIT_RCL(16, uint16_t, _amd, 0) 2386 2389 2387 2390 #if (!defined(RT_ARCH_X86) && !defined(RT_ARCH_AMD64)) || defined(IEM_WITHOUT_ASSEMBLY) 2388 EMIT_RCL(8, RT_NOTHING, 1)2389 #endif 2390 EMIT_RCL(8, _intel, 1)2391 EMIT_RCL(8, _amd, 0)2391 EMIT_RCL(8, uint8_t, RT_NOTHING, 1) 2392 #endif 2393 EMIT_RCL(8, uint8_t, _intel, 1) 2394 EMIT_RCL(8, uint8_t, _amd, 0) 2392 2395 2393 2396 … … 2395 2398 * RCR 2396 2399 */ 2397 #define EMIT_RCR(a_cBitsWidth, a_Suffix, a_fIntelFlags) \ 2398 IEM_DECL_IMPL_DEF(void, RT_CONCAT3(iemAImpl_rcr_u,a_cBitsWidth,a_Suffix),(uint ## a_cBitsWidth ##_t *puDst, \ 2399 uint8_t cShift, uint32_t *pfEFlags)) \ 2400 #define EMIT_RCR(a_cBitsWidth, a_uType, a_Suffix, a_fIntelFlags) \ 2401 IEM_DECL_IMPL_DEF(void, RT_CONCAT3(iemAImpl_rcr_u,a_cBitsWidth,a_Suffix),(a_uType *puDst, uint8_t cShift, uint32_t *pfEFlags)) \ 2400 2402 { \ 2401 cShift &= a_cBitsWidth -1; \2403 cShift &= a_cBitsWidth >= 32 ? a_cBitsWidth - 1 : 31; \ 2402 2404 if (cShift) \ 2403 2405 { \ 2404 uint ## a_cBitsWidth ## _t const uDst = *puDst; \ 2405 uint ## a_cBitsWidth ## _t uResult = uDst >> cShift; \ 2406 if (a_cBitsWidth < 32) \ 2407 cShift %= a_cBitsWidth + 1; \ 2408 a_uType const uDst = *puDst; \ 2409 a_uType uResult = uDst >> cShift; \ 2406 2410 if (cShift > 1) \ 2407 2411 uResult |= uDst << (a_cBitsWidth + 1 - cShift); \ … … 2410 2414 uint32_t fEfl = *pfEFlags; \ 2411 2415 uint32_t fInCarry = fEfl & X86_EFL_CF; \ 2412 uResult |= ( uint ## a_cBitsWidth ## _t)fInCarry << (a_cBitsWidth - cShift); \2416 uResult |= (a_uType)fInCarry << (a_cBitsWidth - cShift); \ 2413 2417 *puDst = uResult; \ 2414 2418 \ … … 2427 2431 2428 2432 #if !defined(RT_ARCH_AMD64) || defined(IEM_WITHOUT_ASSEMBLY) 2429 EMIT_RCR(64, RT_NOTHING, 1)2430 #endif 2431 EMIT_RCR(64, _intel, 1)2432 EMIT_RCR(64, _amd, 0)2433 EMIT_RCR(64, uint64_t, RT_NOTHING, 1) 2434 #endif 2435 EMIT_RCR(64, uint64_t, _intel, 1) 2436 EMIT_RCR(64, uint64_t, _amd, 0) 2433 2437 2434 2438 #if (!defined(RT_ARCH_X86) && !defined(RT_ARCH_AMD64)) || defined(IEM_WITHOUT_ASSEMBLY) 2435 EMIT_RCR(32, RT_NOTHING, 1)2436 #endif 2437 EMIT_RCR(32, _intel, 1)2438 EMIT_RCR(32, _amd, 0)2439 EMIT_RCR(32, uint32_t, RT_NOTHING, 1) 2440 #endif 2441 EMIT_RCR(32, uint32_t, _intel, 1) 2442 EMIT_RCR(32, uint32_t, _amd, 0) 2439 2443 2440 2444 #if (!defined(RT_ARCH_X86) && !defined(RT_ARCH_AMD64)) || defined(IEM_WITHOUT_ASSEMBLY) 2441 EMIT_RCR(16, RT_NOTHING, 1)2442 #endif 2443 EMIT_RCR(16, _intel, 1)2444 EMIT_RCR(16, _amd, 0)2445 EMIT_RCR(16, uint16_t, RT_NOTHING, 1) 2446 #endif 2447 EMIT_RCR(16, uint16_t, _intel, 1) 2448 EMIT_RCR(16, uint16_t, _amd, 0) 2445 2449 2446 2450 #if (!defined(RT_ARCH_X86) && !defined(RT_ARCH_AMD64)) || defined(IEM_WITHOUT_ASSEMBLY) 2447 EMIT_RCR(8, RT_NOTHING, 1)2448 #endif 2449 EMIT_RCR(8, _intel, 1)2450 EMIT_RCR(8, _amd, 0)2451 EMIT_RCR(8, uint8_t, RT_NOTHING, 1) 2452 #endif 2453 EMIT_RCR(8, uint8_t, _intel, 1) 2454 EMIT_RCR(8, uint8_t, _amd, 0) 2451 2455 2452 2456 … … 2454 2458 * SHL 2455 2459 */ 2456 #define EMIT_SHL(a_cBitsWidth, a_Suffix, a_fIntelFlags) \ 2457 IEM_DECL_IMPL_DEF(void, RT_CONCAT3(iemAImpl_shl_u,a_cBitsWidth,a_Suffix),(uint ## a_cBitsWidth ## _t *puDst, \ 2458 uint8_t cShift, uint32_t *pfEFlags)) \ 2460 #define EMIT_SHL(a_cBitsWidth, a_uType, a_Suffix, a_fIntelFlags) \ 2461 IEM_DECL_IMPL_DEF(void, RT_CONCAT3(iemAImpl_shl_u,a_cBitsWidth,a_Suffix),(a_uType *puDst, uint8_t cShift, uint32_t *pfEFlags)) \ 2459 2462 { \ 2460 cShift &= a_cBitsWidth -1; \2463 cShift &= a_cBitsWidth >= 32 ? a_cBitsWidth - 1 : 31; \ 2461 2464 if (cShift) \ 2462 2465 { \ 2463 uint ## a_cBitsWidth ##_tconst uDst = *puDst; \2464 uint ## a_cBitsWidth ##_tuResult = uDst << cShift; \2466 a_uType const uDst = *puDst; \ 2467 a_uType uResult = uDst << cShift; \ 2465 2468 *puDst = uResult; \ 2466 2469 \ … … 2484 2487 2485 2488 #if !defined(RT_ARCH_AMD64) || defined(IEM_WITHOUT_ASSEMBLY) 2486 EMIT_SHL(64, RT_NOTHING, 1)2487 #endif 2488 EMIT_SHL(64, _intel, 1)2489 EMIT_SHL(64, _amd, 0)2489 EMIT_SHL(64, uint64_t, RT_NOTHING, 1) 2490 #endif 2491 EMIT_SHL(64, uint64_t, _intel, 1) 2492 EMIT_SHL(64, uint64_t, _amd, 0) 2490 2493 2491 2494 #if (!defined(RT_ARCH_X86) && !defined(RT_ARCH_AMD64)) || defined(IEM_WITHOUT_ASSEMBLY) 2492 EMIT_SHL(32, RT_NOTHING, 1)2493 #endif 2494 EMIT_SHL(32, _intel, 1)2495 EMIT_SHL(32, _amd, 0)2495 EMIT_SHL(32, uint32_t, RT_NOTHING, 1) 2496 #endif 2497 EMIT_SHL(32, uint32_t, _intel, 1) 2498 EMIT_SHL(32, uint32_t, _amd, 0) 2496 2499 2497 2500 #if (!defined(RT_ARCH_X86) && !defined(RT_ARCH_AMD64)) || defined(IEM_WITHOUT_ASSEMBLY) 2498 EMIT_SHL(16, RT_NOTHING, 1)2499 #endif 2500 EMIT_SHL(16, _intel, 1)2501 EMIT_SHL(16, _amd, 0)2501 EMIT_SHL(16, uint16_t, RT_NOTHING, 1) 2502 #endif 2503 EMIT_SHL(16, uint16_t, _intel, 1) 2504 EMIT_SHL(16, uint16_t, _amd, 0) 2502 2505 2503 2506 #if (!defined(RT_ARCH_X86) && !defined(RT_ARCH_AMD64)) || defined(IEM_WITHOUT_ASSEMBLY) 2504 EMIT_SHL(8, RT_NOTHING, 1)2505 #endif 2506 EMIT_SHL(8, _intel, 1)2507 EMIT_SHL(8, _amd, 0)2507 EMIT_SHL(8, uint8_t, RT_NOTHING, 1) 2508 #endif 2509 EMIT_SHL(8, uint8_t, _intel, 1) 2510 EMIT_SHL(8, uint8_t, _amd, 0) 2508 2511 2509 2512 … … 2511 2514 * SHR 2512 2515 */ 2513 #define EMIT_SHR(a_cBitsWidth, a_Suffix, a_fIntelFlags) \ 2514 IEM_DECL_IMPL_DEF(void, RT_CONCAT3(iemAImpl_shr_u,a_cBitsWidth,a_Suffix),(uint ## a_cBitsWidth ## _t *puDst, \ 2515 uint8_t cShift, uint32_t *pfEFlags)) \ 2516 #define EMIT_SHR(a_cBitsWidth, a_uType, a_Suffix, a_fIntelFlags) \ 2517 IEM_DECL_IMPL_DEF(void, RT_CONCAT3(iemAImpl_shr_u,a_cBitsWidth,a_Suffix),(a_uType *puDst, uint8_t cShift, uint32_t *pfEFlags)) \ 2516 2518 { \ 2517 cShift &= a_cBitsWidth -1; \2519 cShift &= a_cBitsWidth >= 32 ? a_cBitsWidth - 1 : 31; \ 2518 2520 if (cShift) \ 2519 2521 { \ 2520 uint ## a_cBitsWidth ## _tconst uDst = *puDst; \2521 uint ## a_cBitsWidth ## _tuResult = uDst >> cShift; \2522 a_uType const uDst = *puDst; \ 2523 a_uType uResult = uDst >> cShift; \ 2522 2524 *puDst = uResult; \ 2523 2525 \ … … 2538 2540 2539 2541 #if !defined(RT_ARCH_AMD64) || defined(IEM_WITHOUT_ASSEMBLY) 2540 EMIT_SHR(64, RT_NOTHING, 1)2541 #endif 2542 EMIT_SHR(64, _intel, 1)2543 EMIT_SHR(64, _amd, 0)2542 EMIT_SHR(64, uint64_t, RT_NOTHING, 1) 2543 #endif 2544 EMIT_SHR(64, uint64_t, _intel, 1) 2545 EMIT_SHR(64, uint64_t, _amd, 0) 2544 2546 2545 2547 #if (!defined(RT_ARCH_X86) && !defined(RT_ARCH_AMD64)) || defined(IEM_WITHOUT_ASSEMBLY) 2546 EMIT_SHR(32, RT_NOTHING, 1)2547 #endif 2548 EMIT_SHR(32, _intel, 1)2549 EMIT_SHR(32, _amd, 0)2548 EMIT_SHR(32, uint32_t, RT_NOTHING, 1) 2549 #endif 2550 EMIT_SHR(32, uint32_t, _intel, 1) 2551 EMIT_SHR(32, uint32_t, _amd, 0) 2550 2552 2551 2553 #if (!defined(RT_ARCH_X86) && !defined(RT_ARCH_AMD64)) || defined(IEM_WITHOUT_ASSEMBLY) 2552 EMIT_SHR(16, RT_NOTHING, 1)2553 #endif 2554 EMIT_SHR(16, _intel, 1)2555 EMIT_SHR(16, _amd, 0)2554 EMIT_SHR(16, uint16_t, RT_NOTHING, 1) 2555 #endif 2556 EMIT_SHR(16, uint16_t, _intel, 1) 2557 EMIT_SHR(16, uint16_t, _amd, 0) 2556 2558 2557 2559 #if (!defined(RT_ARCH_X86) && !defined(RT_ARCH_AMD64)) || defined(IEM_WITHOUT_ASSEMBLY) 2558 EMIT_SHR(8, RT_NOTHING, 1)2559 #endif 2560 EMIT_SHR(8, _intel, 1)2561 EMIT_SHR(8, _amd, 0)2560 EMIT_SHR(8, uint8_t, RT_NOTHING, 1) 2561 #endif 2562 EMIT_SHR(8, uint8_t, _intel, 1) 2563 EMIT_SHR(8, uint8_t, _amd, 0) 2562 2564 2563 2565 … … 2565 2567 * SAR 2566 2568 */ 2567 #define EMIT_SAR(a_cBitsWidth, a_Suffix, a_fIntelFlags) \ 2568 IEM_DECL_IMPL_DEF(void, RT_CONCAT3(iemAImpl_sar_u,a_cBitsWidth,a_Suffix),(uint ## a_cBitsWidth ## _t *puDst, \ 2569 uint8_t cShift, uint32_t *pfEFlags)) \ 2569 #define EMIT_SAR(a_cBitsWidth, a_uType, a_iType, a_Suffix, a_fIntelFlags) \ 2570 IEM_DECL_IMPL_DEF(void, RT_CONCAT3(iemAImpl_sar_u,a_cBitsWidth,a_Suffix),(a_uType *puDst, uint8_t cShift, uint32_t *pfEFlags)) \ 2570 2571 { \ 2571 cShift &= a_cBitsWidth -1; \2572 cShift &= a_cBitsWidth >= 32 ? a_cBitsWidth - 1 : 31; \ 2572 2573 if (cShift) \ 2573 2574 { \ 2574 uint ## a_cBitsWidth ## _t const uDst =*puDst; \2575 uint ## a_cBitsWidth ## _t uResult = (int ## a_cBitsWidth ## _t)uDst >> cShift; \2575 a_iType const iDst = (a_iType)*puDst; \ 2576 a_uType uResult = iDst >> cShift; \ 2576 2577 *puDst = uResult; \ 2577 2578 \ … … 2580 2581 AssertCompile(X86_EFL_CF_BIT == 0); \ 2581 2582 uint32_t fEfl = *pfEFlags & ~X86_EFL_STATUS_BITS; \ 2582 fEfl |= ( uDst >> (cShift - 1)) & X86_EFL_CF; \2583 fEfl |= (iDst >> (cShift - 1)) & X86_EFL_CF; \ 2583 2584 fEfl |= X86_EFL_CALC_SF(uResult, a_cBitsWidth); \ 2584 2585 fEfl |= X86_EFL_CALC_ZF(uResult); \ … … 2591 2592 2592 2593 #if !defined(RT_ARCH_AMD64) || defined(IEM_WITHOUT_ASSEMBLY) 2593 EMIT_SAR(64, RT_NOTHING, 1)2594 #endif 2595 EMIT_SAR(64, _intel, 1)2596 EMIT_SAR(64, _amd, 0)2594 EMIT_SAR(64, uint64_t, int64_t, RT_NOTHING, 1) 2595 #endif 2596 EMIT_SAR(64, uint64_t, int64_t, _intel, 1) 2597 EMIT_SAR(64, uint64_t, int64_t, _amd, 0) 2597 2598 2598 2599 #if !defined(RT_ARCH_AMD64) || defined(IEM_WITHOUT_ASSEMBLY) 2599 EMIT_SAR(32, RT_NOTHING, 1)2600 #endif 2601 EMIT_SAR(32, _intel, 1)2602 EMIT_SAR(32, _amd, 0)2600 EMIT_SAR(32, uint32_t, int32_t, RT_NOTHING, 1) 2601 #endif 2602 EMIT_SAR(32, uint32_t, int32_t, _intel, 1) 2603 EMIT_SAR(32, uint32_t, int32_t, _amd, 0) 2603 2604 2604 2605 #if !defined(RT_ARCH_AMD64) || defined(IEM_WITHOUT_ASSEMBLY) 2605 EMIT_SAR(16, RT_NOTHING, 1)2606 #endif 2607 EMIT_SAR(16, _intel, 1)2608 EMIT_SAR(16, _amd, 0)2606 EMIT_SAR(16, uint16_t, int16_t, RT_NOTHING, 1) 2607 #endif 2608 EMIT_SAR(16, uint16_t, int16_t, _intel, 1) 2609 EMIT_SAR(16, uint16_t, int16_t, _amd, 0) 2609 2610 2610 2611 #if !defined(RT_ARCH_AMD64) || defined(IEM_WITHOUT_ASSEMBLY) 2611 EMIT_SAR(8, RT_NOTHING, 1)2612 #endif 2613 EMIT_SAR(8, _intel, 1)2614 EMIT_SAR(8, _amd, 0)2612 EMIT_SAR(8, uint8_t, int8_t, RT_NOTHING, 1) 2613 #endif 2614 EMIT_SAR(8, uint8_t, int8_t, _intel, 1) 2615 EMIT_SAR(8, uint8_t, int8_t, _amd, 0) 2615 2616 2616 2617
Note:
See TracChangeset
for help on using the changeset viewer.