VirtualBox

source: vbox/trunk/src/VBox/VMM/include/IEMInternal.h@ 105690

Last change on this file since 105690 was 105673, checked in by vboxsync, 9 months ago

VMM/IEM,TM: Do full-TB looping. Redid timer polling in the recompiler. Rewrote the Blt_CheckIrq code, eliminating a conditional. Fixed some TLB related assertions. Moved some IEMCPU members around in hope of better cache-locality. bugref:10656

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 357.8 KB
Line 
1/* $Id: IEMInternal.h 105673 2024-08-14 13:57:57Z vboxsync $ */
2/** @file
3 * IEM - Internal header file.
4 */
5
6/*
7 * Copyright (C) 2011-2024 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.215389.xyz.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef VMM_INCLUDED_SRC_include_IEMInternal_h
29#define VMM_INCLUDED_SRC_include_IEMInternal_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34#ifndef RT_IN_ASSEMBLER
35# include <VBox/vmm/cpum.h>
36# include <VBox/vmm/iem.h>
37# include <VBox/vmm/pgm.h>
38# include <VBox/vmm/stam.h>
39# include <VBox/param.h>
40
41# include <iprt/setjmp-without-sigmask.h>
42# include <iprt/list.h>
43#endif /* !RT_IN_ASSEMBLER */
44
45
46RT_C_DECLS_BEGIN
47
48
49/** @defgroup grp_iem_int Internals
50 * @ingroup grp_iem
51 * @internal
52 * @{
53 */
54
55/* Make doxygen happy w/o overcomplicating the #if checks. */
56#ifdef DOXYGEN_RUNNING
57# define IEM_WITH_THROW_CATCH
58# define VBOX_WITH_IEM_NATIVE_RECOMPILER_LONGJMP
59#endif
60
61/** For expanding symbol in slickedit and other products tagging and
62 * crossreferencing IEM symbols. */
63#ifndef IEM_STATIC
64# define IEM_STATIC static
65#endif
66
67/** @def IEM_WITH_SETJMP
68 * Enables alternative status code handling using setjmps.
69 *
70 * This adds a bit of expense via the setjmp() call since it saves all the
71 * non-volatile registers. However, it eliminates return code checks and allows
72 * for more optimal return value passing (return regs instead of stack buffer).
73 */
74#if defined(DOXYGEN_RUNNING) || defined(RT_OS_WINDOWS) || 1
75# define IEM_WITH_SETJMP
76#endif
77
78/** @def IEM_WITH_THROW_CATCH
79 * Enables using C++ throw/catch as an alternative to setjmp/longjmp in user
80 * mode code when IEM_WITH_SETJMP is in effect.
81 *
82 * With GCC 11.3.1 and code TLB on linux, using throw/catch instead of
83 * setjmp/long resulted in bs2-test-1 running 3.00% faster and all but on test
84 * result value improving by more than 1%. (Best out of three.)
85 *
86 * With Visual C++ 2019 and code TLB on windows, using throw/catch instead of
87 * setjmp/long resulted in bs2-test-1 running 3.68% faster and all but some of
88 * the MMIO and CPUID tests ran noticeably faster. Variation is greater than on
89 * Linux, but it should be quite a bit faster for normal code.
90 */
91#if defined(__cplusplus) && defined(IEM_WITH_SETJMP) && defined(IN_RING3) && (defined(__GNUC__) || defined(_MSC_VER)) /* ASM-NOINC-START */
92# define IEM_WITH_THROW_CATCH
93#endif /*ASM-NOINC-END*/
94
95/** @def IEM_WITH_INTRA_TB_JUMPS
96 * Enables loop-jumps within a TB (currently only to the first call).
97 */
98#if defined(DOXYGEN_RUNNING) || 1
99# define IEM_WITH_INTRA_TB_JUMPS
100#endif
101
102/** @def IEMNATIVE_WITH_DELAYED_PC_UPDATING
103 * Enables the delayed PC updating optimization (see @bugref{10373}).
104 */
105#if defined(DOXYGEN_RUNNING) || 1
106# define IEMNATIVE_WITH_DELAYED_PC_UPDATING
107#endif
108
109/** Enables the SIMD register allocator @bugref{10614}. */
110#if defined(DOXYGEN_RUNNING) || 1
111# define IEMNATIVE_WITH_SIMD_REG_ALLOCATOR
112#endif
113/** Enables access to even callee saved registers. */
114//# define IEMNATIVE_WITH_SIMD_REG_ACCESS_ALL_REGISTERS
115
116#if defined(DOXYGEN_RUNNING) || 1
117/** @def IEMNATIVE_WITH_DELAYED_REGISTER_WRITEBACK
118 * Delay the writeback or dirty registers as long as possible. */
119# define IEMNATIVE_WITH_DELAYED_REGISTER_WRITEBACK
120#endif
121
122/** @def IEM_WITH_TLB_STATISTICS
123 * Enables all TLB statistics. */
124#if defined(VBOX_WITH_STATISTICS) || defined(DOXYGEN_RUNNING)
125# define IEM_WITH_TLB_STATISTICS
126#endif
127
128/** @def IEMNATIVE_WITH_SIMD_FP_NATIVE_EMITTERS
129 * Enable this to use native emitters for certain SIMD FP operations. */
130#if 1 || defined(DOXYGEN_RUNNING)
131# define IEMNATIVE_WITH_SIMD_FP_NATIVE_EMITTERS
132#endif
133
134/** @def VBOX_WITH_IEM_NATIVE_RECOMPILER_LONGJMP
135 * Enables a quicker alternative to throw/longjmp for IEM_DO_LONGJMP when
136 * executing native translation blocks.
137 *
138 * This exploits the fact that we save all non-volatile registers in the TB
139 * prologue and thus just need to do the same as the TB epilogue to get the
140 * effect of a longjmp/throw. Since MSC marks XMM6 thru XMM15 as
141 * non-volatile (and does something even more crazy for ARM), this probably
142 * won't work reliably on Windows. */
143#ifdef RT_ARCH_ARM64
144# ifndef RT_OS_WINDOWS
145# define VBOX_WITH_IEM_NATIVE_RECOMPILER_LONGJMP
146# endif
147#endif
148/* ASM-NOINC-START */
149#ifdef VBOX_WITH_IEM_NATIVE_RECOMPILER_LONGJMP
150# if !defined(IN_RING3) \
151 || !defined(VBOX_WITH_IEM_RECOMPILER) \
152 || !defined(VBOX_WITH_IEM_NATIVE_RECOMPILER)
153# undef VBOX_WITH_IEM_NATIVE_RECOMPILER_LONGJMP
154# elif defined(RT_OS_WINDOWS)
155# pragma message("VBOX_WITH_IEM_NATIVE_RECOMPILER_LONGJMP is not safe to use on windows")
156# endif
157#endif
158
159
160/** @def IEM_DO_LONGJMP
161 *
162 * Wrapper around longjmp / throw.
163 *
164 * @param a_pVCpu The CPU handle.
165 * @param a_rc The status code jump back with / throw.
166 */
167#if defined(IEM_WITH_SETJMP) || defined(DOXYGEN_RUNNING)
168# ifdef IEM_WITH_THROW_CATCH
169# ifdef VBOX_WITH_IEM_NATIVE_RECOMPILER_LONGJMP
170# define IEM_DO_LONGJMP(a_pVCpu, a_rc) do { \
171 if ((a_pVCpu)->iem.s.pvTbFramePointerR3) \
172 iemNativeTbLongJmp((a_pVCpu)->iem.s.pvTbFramePointerR3, (a_rc)); \
173 throw int(a_rc); \
174 } while (0)
175# else
176# define IEM_DO_LONGJMP(a_pVCpu, a_rc) throw int(a_rc)
177# endif
178# else
179# define IEM_DO_LONGJMP(a_pVCpu, a_rc) longjmp(*(a_pVCpu)->iem.s.CTX_SUFF(pJmpBuf), (a_rc))
180# endif
181#endif
182
183/** For use with IEM function that may do a longjmp (when enabled).
184 *
185 * Visual C++ has trouble longjmp'ing from/over functions with the noexcept
186 * attribute. So, we indicate that function that may be part of a longjmp may
187 * throw "exceptions" and that the compiler should definitely not generate and
188 * std::terminate calling unwind code.
189 *
190 * Here is one example of this ending in std::terminate:
191 * @code{.txt}
19200 00000041`cadfda10 00007ffc`5d5a1f9f ucrtbase!abort+0x4e
19301 00000041`cadfda40 00007ffc`57af229a ucrtbase!terminate+0x1f
19402 00000041`cadfda70 00007ffb`eec91030 VCRUNTIME140!__std_terminate+0xa [d:\agent\_work\1\s\src\vctools\crt\vcruntime\src\eh\ehhelpers.cpp @ 192]
19503 00000041`cadfdaa0 00007ffb`eec92c6d VCRUNTIME140_1!_CallSettingFrame+0x20 [d:\agent\_work\1\s\src\vctools\crt\vcruntime\src\eh\amd64\handlers.asm @ 50]
19604 00000041`cadfdad0 00007ffb`eec93ae5 VCRUNTIME140_1!__FrameHandler4::FrameUnwindToState+0x241 [d:\agent\_work\1\s\src\vctools\crt\vcruntime\src\eh\frame.cpp @ 1085]
19705 00000041`cadfdc00 00007ffb`eec92258 VCRUNTIME140_1!__FrameHandler4::FrameUnwindToEmptyState+0x2d [d:\agent\_work\1\s\src\vctools\crt\vcruntime\src\eh\risctrnsctrl.cpp @ 218]
19806 00000041`cadfdc30 00007ffb`eec940e9 VCRUNTIME140_1!__InternalCxxFrameHandler<__FrameHandler4>+0x194 [d:\agent\_work\1\s\src\vctools\crt\vcruntime\src\eh\frame.cpp @ 304]
19907 00000041`cadfdcd0 00007ffc`5f9f249f VCRUNTIME140_1!__CxxFrameHandler4+0xa9 [d:\agent\_work\1\s\src\vctools\crt\vcruntime\src\eh\risctrnsctrl.cpp @ 290]
20008 00000041`cadfdd40 00007ffc`5f980939 ntdll!RtlpExecuteHandlerForUnwind+0xf
20109 00000041`cadfdd70 00007ffc`5f9a0edd ntdll!RtlUnwindEx+0x339
2020a 00000041`cadfe490 00007ffc`57aff976 ntdll!RtlUnwind+0xcd
2030b 00000041`cadfea00 00007ffb`e1b5de01 VCRUNTIME140!__longjmp_internal+0xe6 [d:\agent\_work\1\s\src\vctools\crt\vcruntime\src\eh\amd64\longjmp.asm @ 140]
2040c (Inline Function) --------`-------- VBoxVMM!iemOpcodeGetNextU8SlowJmp+0x95 [L:\vbox-intern\src\VBox\VMM\VMMAll\IEMAll.cpp @ 1155]
2050d 00000041`cadfea50 00007ffb`e1b60f6b VBoxVMM!iemOpcodeGetNextU8Jmp+0xc1 [L:\vbox-intern\src\VBox\VMM\include\IEMInline.h @ 402]
2060e 00000041`cadfea90 00007ffb`e1cc6201 VBoxVMM!IEMExecForExits+0xdb [L:\vbox-intern\src\VBox\VMM\VMMAll\IEMAll.cpp @ 10185]
2070f 00000041`cadfec70 00007ffb`e1d0df8d VBoxVMM!EMHistoryExec+0x4f1 [L:\vbox-intern\src\VBox\VMM\VMMAll\EMAll.cpp @ 452]
20810 00000041`cadfed60 00007ffb`e1d0d4c0 VBoxVMM!nemR3WinHandleExitCpuId+0x79d [L:\vbox-intern\src\VBox\VMM\VMMAll\NEMAllNativeTemplate-win.cpp.h @ 1829] @encode
209 @endcode
210 *
211 * @see https://developercommunity.visualstudio.com/t/fragile-behavior-of-longjmp-called-from-noexcept-f/1532859
212 */
213#if defined(IEM_WITH_SETJMP) && (defined(_MSC_VER) || defined(IEM_WITH_THROW_CATCH))
214# define IEM_NOEXCEPT_MAY_LONGJMP RT_NOEXCEPT_EX(false)
215#else
216# define IEM_NOEXCEPT_MAY_LONGJMP RT_NOEXCEPT
217#endif
218/* ASM-NOINC-END */
219
220#define IEM_IMPLEMENTS_TASKSWITCH
221
222/** @def IEM_WITH_3DNOW
223 * Includes the 3DNow decoding. */
224#if !defined(IEM_WITH_3DNOW) || defined(DOXYGEN_RUNNING) /* For doxygen, set in Config.kmk. */
225# ifndef IEM_WITHOUT_3DNOW
226# define IEM_WITH_3DNOW
227# endif
228#endif
229
230/** @def IEM_WITH_THREE_0F_38
231 * Includes the three byte opcode map for instrs starting with 0x0f 0x38. */
232#if !defined(IEM_WITH_THREE_0F_38) || defined(DOXYGEN_RUNNING) /* For doxygen, set in Config.kmk. */
233# ifndef IEM_WITHOUT_THREE_0F_38
234# define IEM_WITH_THREE_0F_38
235# endif
236#endif
237
238/** @def IEM_WITH_THREE_0F_3A
239 * Includes the three byte opcode map for instrs starting with 0x0f 0x38. */
240#if !defined(IEM_WITH_THREE_0F_3A) || defined(DOXYGEN_RUNNING) /* For doxygen, set in Config.kmk. */
241# ifndef IEM_WITHOUT_THREE_0F_3A
242# define IEM_WITH_THREE_0F_3A
243# endif
244#endif
245
246/** @def IEM_WITH_VEX
247 * Includes the VEX decoding. */
248#if !defined(IEM_WITH_VEX) || defined(DOXYGEN_RUNNING) /* For doxygen, set in Config.kmk. */
249# ifndef IEM_WITHOUT_VEX
250# define IEM_WITH_VEX
251# endif
252#endif
253
254/** @def IEM_CFG_TARGET_CPU
255 * The minimum target CPU for the IEM emulation (IEMTARGETCPU_XXX value).
256 *
257 * By default we allow this to be configured by the user via the
258 * CPUM/GuestCpuName config string, but this comes at a slight cost during
259 * decoding. So, for applications of this code where there is no need to
260 * be dynamic wrt target CPU, just modify this define.
261 */
262#if !defined(IEM_CFG_TARGET_CPU) || defined(DOXYGEN_RUNNING)
263# define IEM_CFG_TARGET_CPU IEMTARGETCPU_DYNAMIC
264#endif
265
266//#define IEM_WITH_CODE_TLB // - work in progress
267//#define IEM_WITH_DATA_TLB // - work in progress
268
269
270/** @def IEM_USE_UNALIGNED_DATA_ACCESS
271 * Use unaligned accesses instead of elaborate byte assembly. */
272#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86) || defined(DOXYGEN_RUNNING) /*ASM-NOINC*/
273# define IEM_USE_UNALIGNED_DATA_ACCESS
274#endif /*ASM-NOINC*/
275
276//#define IEM_LOG_MEMORY_WRITES
277
278
279
280#ifndef RT_IN_ASSEMBLER /* ASM-NOINC-START - the rest of the file */
281
282# if !defined(IEM_WITHOUT_INSTRUCTION_STATS) && !defined(DOXYGEN_RUNNING)
283/** Instruction statistics. */
284typedef struct IEMINSTRSTATS
285{
286# define IEM_DO_INSTR_STAT(a_Name, a_szDesc) uint32_t a_Name;
287# include "IEMInstructionStatisticsTmpl.h"
288# undef IEM_DO_INSTR_STAT
289} IEMINSTRSTATS;
290#else
291struct IEMINSTRSTATS;
292typedef struct IEMINSTRSTATS IEMINSTRSTATS;
293#endif
294/** Pointer to IEM instruction statistics. */
295typedef IEMINSTRSTATS *PIEMINSTRSTATS;
296
297
298/** @name IEMTARGETCPU_EFL_BEHAVIOR_XXX - IEMCPU::aidxTargetCpuEflFlavour
299 * @{ */
300#define IEMTARGETCPU_EFL_BEHAVIOR_NATIVE 0 /**< Native x86 EFLAGS result; Intel EFLAGS when on non-x86 hosts. */
301#define IEMTARGETCPU_EFL_BEHAVIOR_INTEL 1 /**< Intel EFLAGS result. */
302#define IEMTARGETCPU_EFL_BEHAVIOR_AMD 2 /**< AMD EFLAGS result */
303#define IEMTARGETCPU_EFL_BEHAVIOR_RESERVED 3 /**< Reserved/dummy entry slot that's the same as 0. */
304#define IEMTARGETCPU_EFL_BEHAVIOR_MASK 3 /**< For masking the index before use. */
305/** Selects the right variant from a_aArray.
306 * pVCpu is implicit in the caller context. */
307#define IEMTARGETCPU_EFL_BEHAVIOR_SELECT(a_aArray) \
308 (a_aArray[pVCpu->iem.s.aidxTargetCpuEflFlavour[1] & IEMTARGETCPU_EFL_BEHAVIOR_MASK])
309/** Variation of IEMTARGETCPU_EFL_BEHAVIOR_SELECT for when no native worker can
310 * be used because the host CPU does not support the operation. */
311#define IEMTARGETCPU_EFL_BEHAVIOR_SELECT_NON_NATIVE(a_aArray) \
312 (a_aArray[pVCpu->iem.s.aidxTargetCpuEflFlavour[0] & IEMTARGETCPU_EFL_BEHAVIOR_MASK])
313/** Variation of IEMTARGETCPU_EFL_BEHAVIOR_SELECT for a two dimentional
314 * array paralleling IEMCPU::aidxTargetCpuEflFlavour and a single bit index
315 * into the two.
316 * @sa IEM_SELECT_NATIVE_OR_FALLBACK */
317#if defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)
318# define IEMTARGETCPU_EFL_BEHAVIOR_SELECT_EX(a_aaArray, a_fNative) \
319 (a_aaArray[a_fNative][pVCpu->iem.s.aidxTargetCpuEflFlavour[a_fNative] & IEMTARGETCPU_EFL_BEHAVIOR_MASK])
320#else
321# define IEMTARGETCPU_EFL_BEHAVIOR_SELECT_EX(a_aaArray, a_fNative) \
322 (a_aaArray[0][pVCpu->iem.s.aidxTargetCpuEflFlavour[0] & IEMTARGETCPU_EFL_BEHAVIOR_MASK])
323#endif
324/** @} */
325
326/**
327 * Picks @a a_pfnNative or @a a_pfnFallback according to the host CPU feature
328 * indicator given by @a a_fCpumFeatureMember (CPUMFEATURES member).
329 *
330 * On non-x86 hosts, this will shortcut to the fallback w/o checking the
331 * indicator.
332 *
333 * @sa IEMTARGETCPU_EFL_BEHAVIOR_SELECT_EX
334 */
335#if (defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)) && !defined(IEM_WITHOUT_ASSEMBLY)
336# define IEM_SELECT_HOST_OR_FALLBACK(a_fCpumFeatureMember, a_pfnNative, a_pfnFallback) \
337 (g_CpumHostFeatures.s.a_fCpumFeatureMember ? a_pfnNative : a_pfnFallback)
338#else
339# define IEM_SELECT_HOST_OR_FALLBACK(a_fCpumFeatureMember, a_pfnNative, a_pfnFallback) (a_pfnFallback)
340#endif
341
342
343/**
344 * Branch types.
345 */
346typedef enum IEMBRANCH
347{
348 IEMBRANCH_JUMP = 1,
349 IEMBRANCH_CALL,
350 IEMBRANCH_TRAP,
351 IEMBRANCH_SOFTWARE_INT,
352 IEMBRANCH_HARDWARE_INT
353} IEMBRANCH;
354AssertCompileSize(IEMBRANCH, 4);
355
356
357/**
358 * INT instruction types.
359 */
360typedef enum IEMINT
361{
362 /** INT n instruction (opcode 0xcd imm). */
363 IEMINT_INTN = 0,
364 /** Single byte INT3 instruction (opcode 0xcc). */
365 IEMINT_INT3 = IEM_XCPT_FLAGS_BP_INSTR,
366 /** Single byte INTO instruction (opcode 0xce). */
367 IEMINT_INTO = IEM_XCPT_FLAGS_OF_INSTR,
368 /** Single byte INT1 (ICEBP) instruction (opcode 0xf1). */
369 IEMINT_INT1 = IEM_XCPT_FLAGS_ICEBP_INSTR
370} IEMINT;
371AssertCompileSize(IEMINT, 4);
372
373
374/**
375 * A FPU result.
376 */
377typedef struct IEMFPURESULT
378{
379 /** The output value. */
380 RTFLOAT80U r80Result;
381 /** The output status. */
382 uint16_t FSW;
383} IEMFPURESULT;
384AssertCompileMemberOffset(IEMFPURESULT, FSW, 10);
385/** Pointer to a FPU result. */
386typedef IEMFPURESULT *PIEMFPURESULT;
387/** Pointer to a const FPU result. */
388typedef IEMFPURESULT const *PCIEMFPURESULT;
389
390
391/**
392 * A FPU result consisting of two output values and FSW.
393 */
394typedef struct IEMFPURESULTTWO
395{
396 /** The first output value. */
397 RTFLOAT80U r80Result1;
398 /** The output status. */
399 uint16_t FSW;
400 /** The second output value. */
401 RTFLOAT80U r80Result2;
402} IEMFPURESULTTWO;
403AssertCompileMemberOffset(IEMFPURESULTTWO, FSW, 10);
404AssertCompileMemberOffset(IEMFPURESULTTWO, r80Result2, 12);
405/** Pointer to a FPU result consisting of two output values and FSW. */
406typedef IEMFPURESULTTWO *PIEMFPURESULTTWO;
407/** Pointer to a const FPU result consisting of two output values and FSW. */
408typedef IEMFPURESULTTWO const *PCIEMFPURESULTTWO;
409
410
411/**
412 * IEM TLB entry.
413 *
414 * Lookup assembly:
415 * @code{.asm}
416 ; Calculate tag.
417 mov rax, [VA]
418 shl rax, 16
419 shr rax, 16 + X86_PAGE_SHIFT
420 or rax, [uTlbRevision]
421
422 ; Do indexing.
423 movzx ecx, al
424 lea rcx, [pTlbEntries + rcx]
425
426 ; Check tag.
427 cmp [rcx + IEMTLBENTRY.uTag], rax
428 jne .TlbMiss
429
430 ; Check access.
431 mov rax, ACCESS_FLAGS | MAPPING_R3_NOT_VALID | 0xffffff00
432 and rax, [rcx + IEMTLBENTRY.fFlagsAndPhysRev]
433 cmp rax, [uTlbPhysRev]
434 jne .TlbMiss
435
436 ; Calc address and we're done.
437 mov eax, X86_PAGE_OFFSET_MASK
438 and eax, [VA]
439 or rax, [rcx + IEMTLBENTRY.pMappingR3]
440 %ifdef VBOX_WITH_STATISTICS
441 inc qword [cTlbHits]
442 %endif
443 jmp .Done
444
445 .TlbMiss:
446 mov r8d, ACCESS_FLAGS
447 mov rdx, [VA]
448 mov rcx, [pVCpu]
449 call iemTlbTypeMiss
450 .Done:
451
452 @endcode
453 *
454 */
455typedef struct IEMTLBENTRY
456{
457 /** The TLB entry tag.
458 * Bits 35 thru 0 are made up of the virtual address shifted right 12 bits, this
459 * is ASSUMING a virtual address width of 48 bits.
460 *
461 * Bits 63 thru 36 are made up of the TLB revision (zero means invalid).
462 *
463 * The TLB lookup code uses the current TLB revision, which won't ever be zero,
464 * enabling an extremely cheap TLB invalidation most of the time. When the TLB
465 * revision wraps around though, the tags needs to be zeroed.
466 *
467 * @note Try use SHRD instruction? After seeing
468 * https://gmplib.org/~tege/x86-timing.pdf, maybe not.
469 *
470 * @todo This will need to be reorganized for 57-bit wide virtual address and
471 * PCID (currently 12 bits) and ASID (currently 6 bits) support. We'll
472 * have to move the TLB entry versioning entirely to the
473 * fFlagsAndPhysRev member then, 57 bit wide VAs means we'll only have
474 * 19 bits left (64 - 57 + 12 = 19) and they'll almost entire be
475 * consumed by PCID and ASID (12 + 6 = 18).
476 */
477 uint64_t uTag;
478 /** Access flags and physical TLB revision.
479 *
480 * - Bit 0 - page tables - not executable (X86_PTE_PAE_NX).
481 * - Bit 1 - page tables - not writable (complemented X86_PTE_RW).
482 * - Bit 2 - page tables - not user (complemented X86_PTE_US).
483 * - Bit 3 - pgm phys/virt - not directly writable.
484 * - Bit 4 - pgm phys page - not directly readable.
485 * - Bit 5 - page tables - not accessed (complemented X86_PTE_A).
486 * - Bit 6 - page tables - not dirty (complemented X86_PTE_D).
487 * - Bit 7 - tlb entry - pMappingR3 member not valid.
488 * - Bits 63 thru 8 are used for the physical TLB revision number.
489 *
490 * We're using complemented bit meanings here because it makes it easy to check
491 * whether special action is required. For instance a user mode write access
492 * would do a "TEST fFlags, (X86_PTE_RW | X86_PTE_US | X86_PTE_D)" and a
493 * non-zero result would mean special handling needed because either it wasn't
494 * writable, or it wasn't user, or the page wasn't dirty. A user mode read
495 * access would do "TEST fFlags, X86_PTE_US"; and a kernel mode read wouldn't
496 * need to check any PTE flag.
497 */
498 uint64_t fFlagsAndPhysRev;
499 /** The guest physical page address. */
500 uint64_t GCPhys;
501 /** Pointer to the ring-3 mapping. */
502 R3PTRTYPE(uint8_t *) pbMappingR3;
503#if HC_ARCH_BITS == 32
504 uint32_t u32Padding1;
505#endif
506} IEMTLBENTRY;
507AssertCompileSize(IEMTLBENTRY, 32);
508/** Pointer to an IEM TLB entry. */
509typedef IEMTLBENTRY *PIEMTLBENTRY;
510/** Pointer to a const IEM TLB entry. */
511typedef IEMTLBENTRY const *PCIEMTLBENTRY;
512
513/** @name IEMTLBE_F_XXX - TLB entry flags (IEMTLBENTRY::fFlagsAndPhysRev)
514 * @{ */
515#define IEMTLBE_F_PT_NO_EXEC RT_BIT_64(0) /**< Page tables: Not executable. */
516#define IEMTLBE_F_PT_NO_WRITE RT_BIT_64(1) /**< Page tables: Not writable. */
517#define IEMTLBE_F_PT_NO_USER RT_BIT_64(2) /**< Page tables: Not user accessible (supervisor only). */
518#define IEMTLBE_F_PG_NO_WRITE RT_BIT_64(3) /**< Phys page: Not writable (access handler, ROM, whatever). */
519#define IEMTLBE_F_PG_NO_READ RT_BIT_64(4) /**< Phys page: Not readable (MMIO / access handler, ROM) */
520#define IEMTLBE_F_PT_NO_ACCESSED RT_BIT_64(5) /**< Phys tables: Not accessed (need to be marked accessed). */
521#define IEMTLBE_F_PT_NO_DIRTY RT_BIT_64(6) /**< Page tables: Not dirty (needs to be made dirty on write). */
522#define IEMTLBE_F_PT_LARGE_PAGE RT_BIT_64(7) /**< Page tables: Large 2 or 4 MiB page (for flushing). */
523#define IEMTLBE_F_NO_MAPPINGR3 RT_BIT_64(8) /**< TLB entry: The IEMTLBENTRY::pMappingR3 member is invalid. */
524#define IEMTLBE_F_PG_UNASSIGNED RT_BIT_64(9) /**< Phys page: Unassigned memory (not RAM, ROM, MMIO2 or MMIO). */
525#define IEMTLBE_F_PG_CODE_PAGE RT_BIT_64(10) /**< Phys page: Code page. */
526#define IEMTLBE_F_PHYS_REV UINT64_C(0xfffffffffffff800) /**< Physical revision mask. @sa IEMTLB_PHYS_REV_INCR */
527/** @} */
528AssertCompile(PGMIEMGCPHYS2PTR_F_NO_WRITE == IEMTLBE_F_PG_NO_WRITE);
529AssertCompile(PGMIEMGCPHYS2PTR_F_NO_READ == IEMTLBE_F_PG_NO_READ);
530AssertCompile(PGMIEMGCPHYS2PTR_F_NO_MAPPINGR3 == IEMTLBE_F_NO_MAPPINGR3);
531AssertCompile(PGMIEMGCPHYS2PTR_F_UNASSIGNED == IEMTLBE_F_PG_UNASSIGNED);
532AssertCompile(PGMIEMGCPHYS2PTR_F_CODE_PAGE == IEMTLBE_F_PG_CODE_PAGE);
533AssertCompile(PGM_WALKINFO_BIG_PAGE == IEMTLBE_F_PT_LARGE_PAGE);
534/** The bits set by PGMPhysIemGCPhys2PtrNoLock. */
535#define IEMTLBE_GCPHYS2PTR_MASK ( PGMIEMGCPHYS2PTR_F_NO_WRITE \
536 | PGMIEMGCPHYS2PTR_F_NO_READ \
537 | PGMIEMGCPHYS2PTR_F_NO_MAPPINGR3 \
538 | PGMIEMGCPHYS2PTR_F_UNASSIGNED \
539 | PGMIEMGCPHYS2PTR_F_CODE_PAGE \
540 | IEMTLBE_F_PHYS_REV )
541
542
543/** The TLB size (power of two).
544 * We initially chose 256 because that way we can obtain the result directly
545 * from a 8-bit register without an additional AND instruction.
546 * See also @bugref{10687}. */
547#if defined(RT_ARCH_AMD64)
548# define IEMTLB_ENTRY_COUNT 256
549# define IEMTLB_ENTRY_COUNT_AS_POWER_OF_TWO 8
550#else
551# define IEMTLB_ENTRY_COUNT 8192
552# define IEMTLB_ENTRY_COUNT_AS_POWER_OF_TWO 13
553#endif
554AssertCompile(RT_BIT_32(IEMTLB_ENTRY_COUNT_AS_POWER_OF_TWO) == IEMTLB_ENTRY_COUNT);
555
556/** TLB slot format spec (assumes uint32_t or unsigned value). */
557#if IEMTLB_ENTRY_COUNT <= 0x100 / 2
558# define IEMTLB_SLOT_FMT "%02x"
559#elif IEMTLB_ENTRY_COUNT <= 0x1000 / 2
560# define IEMTLB_SLOT_FMT "%03x"
561#elif IEMTLB_ENTRY_COUNT <= 0x10000 / 2
562# define IEMTLB_SLOT_FMT "%04x"
563#else
564# define IEMTLB_SLOT_FMT "%05x"
565#endif
566
567/** Enable the large page bitmap TLB optimization.
568 *
569 * The idea here is to avoid scanning the full 32 KB (2MB pages, 2*512 TLB
570 * entries) or 64 KB (4MB pages, 2*1024 TLB entries) worth of TLB entries during
571 * invlpg when large pages are used, and instead just scan 128 or 256 bytes of
572 * the bmLargePage bitmap to determin which TLB entires that might be containing
573 * large pages and actually require checking.
574 *
575 * There is a good posibility of false positives since we currently don't clear
576 * the bitmap when flushing the TLB, but it should help reduce the workload when
577 * the large pages aren't fully loaded into the TLB in their entirity...
578 */
579#define IEMTLB_WITH_LARGE_PAGE_BITMAP
580
581/**
582 * An IEM TLB.
583 *
584 * We've got two of these, one for data and one for instructions.
585 */
586typedef struct IEMTLB
587{
588 /** The non-global TLB revision.
589 * This is actually only 28 bits wide (see IEMTLBENTRY::uTag) and is incremented
590 * by adding RT_BIT_64(36) to it. When it wraps around and becomes zero, all
591 * the tags in the TLB must be zeroed and the revision set to RT_BIT_64(36).
592 * (The revision zero indicates an invalid TLB entry.)
593 *
594 * The initial value is choosen to cause an early wraparound. */
595 uint64_t uTlbRevision;
596 /** The TLB physical address revision - shadow of PGM variable.
597 *
598 * This is actually only 56 bits wide (see IEMTLBENTRY::fFlagsAndPhysRev) and is
599 * incremented by adding RT_BIT_64(8). When it wraps around and becomes zero,
600 * a rendezvous is called and each CPU wipe the IEMTLBENTRY::pMappingR3 as well
601 * as IEMTLBENTRY::fFlagsAndPhysRev bits 63 thru 8, 4, and 3.
602 *
603 * The initial value is choosen to cause an early wraparound.
604 *
605 * @note This is placed between the two TLB revisions because we
606 * load it in pair with one or the other on arm64. */
607 uint64_t volatile uTlbPhysRev;
608 /** The global TLB revision.
609 * Same as uTlbRevision, but only increased for global flushes. */
610 uint64_t uTlbRevisionGlobal;
611
612 /** Large page tag range.
613 *
614 * This is used to avoid scanning a large page's worth of TLB entries for each
615 * INVLPG instruction, and only to do so iff we've loaded any and when the
616 * address is in this range. This is kept up to date when we loading new TLB
617 * entries.
618 */
619 struct LARGEPAGERANGE
620 {
621 /** The lowest large page address tag, UINT64_MAX if none. */
622 uint64_t uFirstTag;
623 /** The highest large page address tag (with offset mask part set), 0 if none. */
624 uint64_t uLastTag;
625 }
626 /** Large page range for non-global pages. */
627 NonGlobalLargePageRange,
628 /** Large page range for global pages. */
629 GlobalLargePageRange;
630 /** Number of non-global entries for large pages loaded since last TLB flush. */
631 uint32_t cTlbNonGlobalLargePageCurLoads;
632 /** Number of global entries for large pages loaded since last TLB flush. */
633 uint32_t cTlbGlobalLargePageCurLoads;
634
635 /* Statistics: */
636
637 /** TLB hits in IEMAll.cpp code (IEM_WITH_TLB_STATISTICS only; both).
638 * @note For the data TLB this is only used in iemMemMap and and for direct (i.e.
639 * not via safe read/write path) calls to iemMemMapJmp. */
640 uint64_t cTlbCoreHits;
641 /** Safe read/write TLB hits in iemMemMapJmp (IEM_WITH_TLB_STATISTICS
642 * only; data tlb only). */
643 uint64_t cTlbSafeHits;
644 /** TLB hits in IEMAllMemRWTmplInline.cpp.h (data + IEM_WITH_TLB_STATISTICS only). */
645 uint64_t cTlbInlineCodeHits;
646
647 /** TLB misses in IEMAll.cpp code (both).
648 * @note For the data TLB this is only used in iemMemMap and for direct (i.e.
649 * not via safe read/write path) calls to iemMemMapJmp. So,
650 * for the data TLB this more like 'other misses', while for the code
651 * TLB is all misses. */
652 uint64_t cTlbCoreMisses;
653 /** Subset of cTlbCoreMisses that results in PTE.G=1 loads (odd entries). */
654 uint64_t cTlbCoreGlobalLoads;
655 /** Safe read/write TLB misses in iemMemMapJmp (so data only). */
656 uint64_t cTlbSafeMisses;
657 /** Subset of cTlbSafeMisses that results in PTE.G=1 loads (odd entries). */
658 uint64_t cTlbSafeGlobalLoads;
659 /** Safe read path taken (data only). */
660 uint64_t cTlbSafeReadPath;
661 /** Safe write path taken (data only). */
662 uint64_t cTlbSafeWritePath;
663
664 /** @name Details for native code TLB misses.
665 * @note These counts are included in the above counters (cTlbSafeReadPath,
666 * cTlbSafeWritePath, cTlbInlineCodeHits).
667 * @{ */
668 /** TLB misses in native code due to tag mismatch. */
669 STAMCOUNTER cTlbNativeMissTag;
670 /** TLB misses in native code due to flags or physical revision mismatch. */
671 STAMCOUNTER cTlbNativeMissFlagsAndPhysRev;
672 /** TLB misses in native code due to misaligned access. */
673 STAMCOUNTER cTlbNativeMissAlignment;
674 /** TLB misses in native code due to cross page access. */
675 uint32_t cTlbNativeMissCrossPage;
676 /** TLB misses in native code due to non-canonical address. */
677 uint32_t cTlbNativeMissNonCanonical;
678 /** @} */
679
680 /** Slow read path (code only). */
681 uint32_t cTlbSlowCodeReadPath;
682
683 /** Regular TLB flush count. */
684 uint32_t cTlsFlushes;
685 /** Global TLB flush count. */
686 uint32_t cTlsGlobalFlushes;
687 /** Revision rollovers. */
688 uint32_t cTlbRevisionRollovers;
689 /** Physical revision flushes. */
690 uint32_t cTlbPhysRevFlushes;
691 /** Physical revision rollovers. */
692 uint32_t cTlbPhysRevRollovers;
693
694 /** Number of INVLPG (and similar) operations. */
695 uint32_t cTlbInvlPg;
696 /** Subset of cTlbInvlPg that involved non-global large pages. */
697 uint32_t cTlbInvlPgLargeNonGlobal;
698 /** Subset of cTlbInvlPg that involved global large pages. */
699 uint32_t cTlbInvlPgLargeGlobal;
700
701 uint32_t au32Padding[13];
702
703 /** The TLB entries.
704 * Even entries are for PTE.G=0 and uses uTlbRevision.
705 * Odd entries are for PTE.G=1 and uses uTlbRevisionGlobal. */
706 IEMTLBENTRY aEntries[IEMTLB_ENTRY_COUNT * 2];
707#ifdef IEMTLB_WITH_LARGE_PAGE_BITMAP
708 /** Bitmap tracking TLB entries for large pages.
709 * This duplicates IEMTLBE_F_PT_LARGE_PAGE for each TLB entry. */
710 uint64_t bmLargePage[IEMTLB_ENTRY_COUNT * 2 / 64];
711#endif
712} IEMTLB;
713AssertCompileSizeAlignment(IEMTLB, 64);
714#ifdef IEMTLB_WITH_LARGE_PAGE_BITMAP
715AssertCompile(IEMTLB_ENTRY_COUNT >= 32 /* bmLargePage ASSUMPTION */);
716#endif
717/** The width (in bits) of the address portion of the TLB tag. */
718#define IEMTLB_TAG_ADDR_WIDTH 36
719/** IEMTLB::uTlbRevision increment. */
720#define IEMTLB_REVISION_INCR RT_BIT_64(IEMTLB_TAG_ADDR_WIDTH)
721/** IEMTLB::uTlbRevision mask. */
722#define IEMTLB_REVISION_MASK (~(RT_BIT_64(IEMTLB_TAG_ADDR_WIDTH) - 1))
723
724/** IEMTLB::uTlbPhysRev increment.
725 * @sa IEMTLBE_F_PHYS_REV */
726#define IEMTLB_PHYS_REV_INCR RT_BIT_64(11)
727AssertCompile(IEMTLBE_F_PHYS_REV == ~(IEMTLB_PHYS_REV_INCR - 1U));
728
729/**
730 * Calculates the TLB tag for a virtual address but without TLB revision.
731 * @returns Tag value for indexing and comparing with IEMTLB::uTag.
732 * @param a_GCPtr The virtual address. Must be RTGCPTR or same size or
733 * the clearing of the top 16 bits won't work (if 32-bit
734 * we'll end up with mostly zeros).
735 */
736#define IEMTLB_CALC_TAG_NO_REV(a_GCPtr) ( (((a_GCPtr) << 16) >> (GUEST_PAGE_SHIFT + 16)) )
737/**
738 * Converts a TLB tag value into a even TLB index.
739 * @returns Index into IEMTLB::aEntries.
740 * @param a_uTag Value returned by IEMTLB_CALC_TAG.
741 */
742#if IEMTLB_ENTRY_COUNT == 256
743# define IEMTLB_TAG_TO_EVEN_INDEX(a_uTag) ( (uint8_t)(a_uTag) * 2U )
744#else
745# define IEMTLB_TAG_TO_EVEN_INDEX(a_uTag) ( ((a_uTag) & (IEMTLB_ENTRY_COUNT - 1U)) * 2U )
746AssertCompile(RT_IS_POWER_OF_TWO(IEMTLB_ENTRY_COUNT));
747#endif
748/**
749 * Converts a TLB tag value into an even TLB index.
750 * @returns Pointer into IEMTLB::aEntries corresponding to .
751 * @param a_pTlb The TLB.
752 * @param a_uTag Value returned by IEMTLB_CALC_TAG or
753 * IEMTLB_CALC_TAG_NO_REV.
754 */
755#define IEMTLB_TAG_TO_EVEN_ENTRY(a_pTlb, a_uTag) ( &(a_pTlb)->aEntries[IEMTLB_TAG_TO_EVEN_INDEX(a_uTag)] )
756
757/** Converts a GC address to an even TLB index. */
758#define IEMTLB_ADDR_TO_EVEN_INDEX(a_GCPtr) IEMTLB_TAG_TO_EVEN_INDEX(IEMTLB_CALC_TAG_NO_REV(a_GCPtr))
759
760
761/** @def IEM_WITH_TLB_TRACE
762 * Enables the TLB tracing.
763 * Adjust buffer size in IEMR3Init. */
764#if defined(DOXYGEN_RUNNING) || 0
765# define IEM_WITH_TLB_TRACE
766#endif
767
768#ifdef IEM_WITH_TLB_TRACE
769
770/** TLB trace entry types. */
771typedef enum : uint8_t
772{
773 kIemTlbTraceType_Invalid,
774 kIemTlbTraceType_InvlPg,
775 kIemTlbTraceType_EvictSlot,
776 kIemTlbTraceType_LargeEvictSlot,
777 kIemTlbTraceType_LargeScan,
778 kIemTlbTraceType_Flush,
779 kIemTlbTraceType_FlushGlobal,
780 kIemTlbTraceType_Load,
781 kIemTlbTraceType_LoadGlobal,
782 kIemTlbTraceType_Load_Cr0,
783 kIemTlbTraceType_Load_Cr3,
784 kIemTlbTraceType_Load_Cr4,
785 kIemTlbTraceType_Load_Efer,
786 kIemTlbTraceType_Irq,
787 kIemTlbTraceType_Xcpt,
788 kIemTlbTraceType_IRet,
789 kIemTlbTraceType_Tb_Compile,
790 kIemTlbTraceType_Tb_Exec_Threaded,
791 kIemTlbTraceType_Tb_Exec_Native,
792 kIemTlbTraceType_User0,
793 kIemTlbTraceType_User1,
794 kIemTlbTraceType_User2,
795 kIemTlbTraceType_User3,
796} IEMTLBTRACETYPE;
797
798/** TLB trace entry. */
799typedef struct IEMTLBTRACEENTRY
800{
801 /** The flattened RIP for the event. */
802 uint64_t rip;
803 /** The event type. */
804 IEMTLBTRACETYPE enmType;
805 /** Byte parameter - typically used as 'bool fDataTlb'. */
806 uint8_t bParam;
807 /** 16-bit parameter value. */
808 uint16_t u16Param;
809 /** 32-bit parameter value. */
810 uint32_t u32Param;
811 /** 64-bit parameter value. */
812 uint64_t u64Param;
813 /** 64-bit parameter value. */
814 uint64_t u64Param2;
815} IEMTLBTRACEENTRY;
816AssertCompileSize(IEMTLBTRACEENTRY, 32);
817/** Pointer to a TLB trace entry. */
818typedef IEMTLBTRACEENTRY *PIEMTLBTRACEENTRY;
819/** Pointer to a const TLB trace entry. */
820typedef IEMTLBTRACEENTRY const *PCIEMTLBTRACEENTRY;
821#endif /* !IEM_WITH_TLB_TRACE */
822
823#if defined(IEM_WITH_TLB_TRACE) && defined(IN_RING3)
824# define IEMTLBTRACE_INVLPG(a_pVCpu, a_GCPtr) \
825 iemTlbTrace(a_pVCpu, kIemTlbTraceType_InvlPg, a_GCPtr)
826# define IEMTLBTRACE_EVICT_SLOT(a_pVCpu, a_GCPtrTag, a_GCPhys, a_idxSlot, a_fDataTlb) \
827 iemTlbTrace(a_pVCpu, kIemTlbTraceType_EvictSlot, a_GCPtrTag, a_GCPhys, a_fDataTlb, a_idxSlot)
828# define IEMTLBTRACE_LARGE_EVICT_SLOT(a_pVCpu, a_GCPtrTag, a_GCPhys, a_idxSlot, a_fDataTlb) \
829 iemTlbTrace(a_pVCpu, kIemTlbTraceType_LargeEvictSlot, a_GCPtrTag, a_GCPhys, a_fDataTlb, a_idxSlot)
830# define IEMTLBTRACE_LARGE_SCAN(a_pVCpu, a_fGlobal, a_fNonGlobal, a_fDataTlb) \
831 iemTlbTrace(a_pVCpu, kIemTlbTraceType_LargeScan, 0, 0, a_fDataTlb, (uint8_t)a_fGlobal | ((uint8_t)a_fNonGlobal << 1))
832# define IEMTLBTRACE_FLUSH(a_pVCpu, a_uRev, a_fDataTlb) \
833 iemTlbTrace(a_pVCpu, kIemTlbTraceType_Flush, a_uRev, 0, a_fDataTlb)
834# define IEMTLBTRACE_FLUSH_GLOBAL(a_pVCpu, a_uRev, a_uGRev, a_fDataTlb) \
835 iemTlbTrace(a_pVCpu, kIemTlbTraceType_FlushGlobal, a_uRev, a_uGRev, a_fDataTlb)
836# define IEMTLBTRACE_LOAD(a_pVCpu, a_GCPtr, a_GCPhys, a_fTlb, a_fDataTlb) \
837 iemTlbTrace(a_pVCpu, kIemTlbTraceType_Load, a_GCPtr, a_GCPhys, a_fDataTlb, a_fTlb)
838# define IEMTLBTRACE_LOAD_GLOBAL(a_pVCpu, a_GCPtr, a_GCPhys, a_fTlb, a_fDataTlb) \
839 iemTlbTrace(a_pVCpu, kIemTlbTraceType_LoadGlobal, a_GCPtr, a_GCPhys, a_fDataTlb, a_fTlb)
840#else
841# define IEMTLBTRACE_INVLPG(a_pVCpu, a_GCPtr) do { } while (0)
842# define IEMTLBTRACE_EVICT_SLOT(a_pVCpu, a_GCPtrTag, a_GCPhys, a_idxSlot, a_fDataTlb) do { } while (0)
843# define IEMTLBTRACE_LARGE_EVICT_SLOT(a_pVCpu, a_GCPtrTag, a_GCPhys, a_idxSlot, a_fDataTlb) do { } while (0)
844# define IEMTLBTRACE_LARGE_SCAN(a_pVCpu, a_fGlobal, a_fNonGlobal, a_fDataTlb) do { } while (0)
845# define IEMTLBTRACE_FLUSH(a_pVCpu, a_uRev, a_fDataTlb) do { } while (0)
846# define IEMTLBTRACE_FLUSH_GLOBAL(a_pVCpu, a_uRev, a_uGRev, a_fDataTlb) do { } while (0)
847# define IEMTLBTRACE_LOAD(a_pVCpu, a_GCPtr, a_GCPhys, a_fTlb, a_fDataTlb) do { } while (0)
848# define IEMTLBTRACE_LOAD_GLOBAL(a_pVCpu, a_GCPtr, a_GCPhys, a_fTlb, a_fDataTlb) do { } while (0)
849#endif
850
851#if defined(IEM_WITH_TLB_TRACE) && defined(IN_RING3) && 1
852# define IEMTLBTRACE_LOAD_CR0(a_pVCpu, a_uNew, a_uOld) iemTlbTrace(a_pVCpu, kIemTlbTraceType_Load_Cr0, a_uNew, a_uOld)
853# define IEMTLBTRACE_LOAD_CR3(a_pVCpu, a_uNew, a_uOld) iemTlbTrace(a_pVCpu, kIemTlbTraceType_Load_Cr3, a_uNew, a_uOld)
854# define IEMTLBTRACE_LOAD_CR4(a_pVCpu, a_uNew, a_uOld) iemTlbTrace(a_pVCpu, kIemTlbTraceType_Load_Cr4, a_uNew, a_uOld)
855# define IEMTLBTRACE_LOAD_EFER(a_pVCpu, a_uNew, a_uOld) iemTlbTrace(a_pVCpu, kIemTlbTraceType_Load_Efer, a_uNew, a_uOld)
856#else
857# define IEMTLBTRACE_LOAD_CR0(a_pVCpu, a_uNew, a_uOld) do { } while (0)
858# define IEMTLBTRACE_LOAD_CR3(a_pVCpu, a_uNew, a_uOld) do { } while (0)
859# define IEMTLBTRACE_LOAD_CR4(a_pVCpu, a_uNew, a_uOld) do { } while (0)
860# define IEMTLBTRACE_LOAD_EFER(a_pVCpu, a_uNew, a_uOld) do { } while (0)
861#endif
862
863#if defined(IEM_WITH_TLB_TRACE) && defined(IN_RING3) && 1
864# define IEMTLBTRACE_IRQ(a_pVCpu, a_uVector, a_fFlags, a_fEFlags) \
865 iemTlbTrace(a_pVCpu, kIemTlbTraceType_Irq, a_fEFlags, 0, a_uVector, a_fFlags)
866# define IEMTLBTRACE_XCPT(a_pVCpu, a_uVector, a_uErr, a_uCr2, a_fFlags) \
867 iemTlbTrace(a_pVCpu, kIemTlbTraceType_Xcpt, a_uErr, a_uCr2, a_uVector, a_fFlags)
868# define IEMTLBTRACE_IRET(a_pVCpu, a_uRetCs, a_uRetRip, a_fEFlags) \
869 iemTlbTrace(a_pVCpu, kIemTlbTraceType_IRet, a_uRetRip, a_fEFlags, 0, a_uRetCs)
870#else
871# define IEMTLBTRACE_IRQ(a_pVCpu, a_uVector, a_fFlags, a_fEFlags) do { } while (0)
872# define IEMTLBTRACE_XCPT(a_pVCpu, a_uVector, a_uErr, a_uCr2, a_fFlags) do { } while (0)
873# define IEMTLBTRACE_IRET(a_pVCpu, a_uRetCs, a_uRetRip, a_fEFlags) do { } while (0)
874#endif
875
876#if defined(IEM_WITH_TLB_TRACE) && defined(IN_RING3) && 1
877# define IEMTLBTRACE_TB_COMPILE(a_pVCpu, a_GCPhysPc) \
878 iemTlbTrace(a_pVCpu, kIemTlbTraceType_Tb_Compile, a_GCPhysPc)
879# define IEMTLBTRACE_TB_EXEC_THRD(a_pVCpu, a_pTb) \
880 iemTlbTrace(a_pVCpu, kIemTlbTraceType_Tb_Exec_Threaded, (a_pTb)->GCPhysPc, (uintptr_t)a_pTb, 0, (a_pTb)->cUsed)
881# define IEMTLBTRACE_TB_EXEC_N8VE(a_pVCpu, a_pTb) \
882 iemTlbTrace(a_pVCpu, kIemTlbTraceType_Tb_Exec_Native, (a_pTb)->GCPhysPc, (uintptr_t)a_pTb, 0, (a_pTb)->cUsed)
883#else
884# define IEMTLBTRACE_TB_COMPILE(a_pVCpu, a_GCPhysPc) do { } while (0)
885# define IEMTLBTRACE_TB_EXEC_THRD(a_pVCpu, a_pTb) do { } while (0)
886# define IEMTLBTRACE_TB_EXEC_N8VE(a_pVCpu, a_pTb) do { } while (0)
887#endif
888
889#if defined(IEM_WITH_TLB_TRACE) && defined(IN_RING3) && 1
890# define IEMTLBTRACE_USER0(a_pVCpu, a_u64Param1, a_u64Param2, a_u32Param, a_bParam) \
891 iemTlbTrace(a_pVCpu, kIemTlbTraceType_User0, a_u64Param1, a_u64Param2, a_bParam, a_u32Param)
892# define IEMTLBTRACE_USER1(a_pVCpu, a_u64Param1, a_u64Param2, a_u32Param, a_bParam) \
893 iemTlbTrace(a_pVCpu, kIemTlbTraceType_User1, a_u64Param1, a_u64Param2, a_bParam, a_u32Param)
894# define IEMTLBTRACE_USER2(a_pVCpu, a_u64Param1, a_u64Param2, a_u32Param, a_bParam) \
895 iemTlbTrace(a_pVCpu, kIemTlbTraceType_User2, a_u64Param1, a_u64Param2, a_bParam, a_u32Param)
896# define IEMTLBTRACE_USER3(a_pVCpu, a_u64Param1, a_u64Param2, a_u32Param, a_bParam) \
897 iemTlbTrace(a_pVCpu, kIemTlbTraceType_User3, a_u64Param1, a_u64Param2, a_bParam, a_u32Param)
898#else
899# define IEMTLBTRACE_USER0(a_pVCpu, a_u64Param1, a_u64Param2, a_u32Param, a_bParam) do { } while (0)
900# define IEMTLBTRACE_USER1(a_pVCpu, a_u64Param1, a_u64Param2, a_u32Param, a_bParam) do { } while (0)
901# define IEMTLBTRACE_USER2(a_pVCpu, a_u64Param1, a_u64Param2, a_u32Param, a_bParam) do { } while (0)
902# define IEMTLBTRACE_USER3(a_pVCpu, a_u64Param1, a_u64Param2, a_u32Param, a_bParam) do { } while (0)
903#endif
904
905
906/** @name IEM_MC_F_XXX - MC block flags/clues.
907 * @todo Merge with IEM_CIMPL_F_XXX
908 * @{ */
909#define IEM_MC_F_ONLY_8086 RT_BIT_32(0)
910#define IEM_MC_F_MIN_186 RT_BIT_32(1)
911#define IEM_MC_F_MIN_286 RT_BIT_32(2)
912#define IEM_MC_F_NOT_286_OR_OLDER IEM_MC_F_MIN_386
913#define IEM_MC_F_MIN_386 RT_BIT_32(3)
914#define IEM_MC_F_MIN_486 RT_BIT_32(4)
915#define IEM_MC_F_MIN_PENTIUM RT_BIT_32(5)
916#define IEM_MC_F_MIN_PENTIUM_II IEM_MC_F_MIN_PENTIUM
917#define IEM_MC_F_MIN_CORE IEM_MC_F_MIN_PENTIUM
918#define IEM_MC_F_64BIT RT_BIT_32(6)
919#define IEM_MC_F_NOT_64BIT RT_BIT_32(7)
920/** This is set by IEMAllN8vePython.py to indicate a variation without the
921 * flags-clearing-and-checking, when there is also a variation with that.
922 * @note Do not use this manully, it's only for python and for testing in
923 * the native recompiler! */
924#define IEM_MC_F_WITHOUT_FLAGS RT_BIT_32(8)
925/** @} */
926
927/** @name IEM_CIMPL_F_XXX - State change clues for CIMPL calls.
928 *
929 * These clues are mainly for the recompiler, so that it can emit correct code.
930 *
931 * They are processed by the python script and which also automatically
932 * calculates flags for MC blocks based on the statements, extending the use of
933 * these flags to describe MC block behavior to the recompiler core. The python
934 * script pass the flags to the IEM_MC2_END_EMIT_CALLS macro, but mainly for
935 * error checking purposes. The script emits the necessary fEndTb = true and
936 * similar statements as this reduces compile time a tiny bit.
937 *
938 * @{ */
939/** Flag set if direct branch, clear if absolute or indirect. */
940#define IEM_CIMPL_F_BRANCH_DIRECT RT_BIT_32(0)
941/** Flag set if indirect branch, clear if direct or relative.
942 * This is also used for all system control transfers (SYSCALL, SYSRET, INT, ++)
943 * as well as for return instructions (RET, IRET, RETF). */
944#define IEM_CIMPL_F_BRANCH_INDIRECT RT_BIT_32(1)
945/** Flag set if relative branch, clear if absolute or indirect. */
946#define IEM_CIMPL_F_BRANCH_RELATIVE RT_BIT_32(2)
947/** Flag set if conditional branch, clear if unconditional. */
948#define IEM_CIMPL_F_BRANCH_CONDITIONAL RT_BIT_32(3)
949/** Flag set if it's a far branch (changes CS). */
950#define IEM_CIMPL_F_BRANCH_FAR RT_BIT_32(4)
951/** Convenience: Testing any kind of branch. */
952#define IEM_CIMPL_F_BRANCH_ANY (IEM_CIMPL_F_BRANCH_DIRECT | IEM_CIMPL_F_BRANCH_INDIRECT | IEM_CIMPL_F_BRANCH_RELATIVE)
953
954/** Execution flags may change (IEMCPU::fExec). */
955#define IEM_CIMPL_F_MODE RT_BIT_32(5)
956/** May change significant portions of RFLAGS. */
957#define IEM_CIMPL_F_RFLAGS RT_BIT_32(6)
958/** May change the status bits (X86_EFL_STATUS_BITS) in RFLAGS. */
959#define IEM_CIMPL_F_STATUS_FLAGS RT_BIT_32(7)
960/** May trigger interrupt shadowing. */
961#define IEM_CIMPL_F_INHIBIT_SHADOW RT_BIT_32(8)
962/** May enable interrupts, so recheck IRQ immediately afterwards executing
963 * the instruction. */
964#define IEM_CIMPL_F_CHECK_IRQ_AFTER RT_BIT_32(9)
965/** May disable interrupts, so recheck IRQ immediately before executing the
966 * instruction. */
967#define IEM_CIMPL_F_CHECK_IRQ_BEFORE RT_BIT_32(10)
968/** Convenience: Check for IRQ both before and after an instruction. */
969#define IEM_CIMPL_F_CHECK_IRQ_BEFORE_AND_AFTER (IEM_CIMPL_F_CHECK_IRQ_BEFORE | IEM_CIMPL_F_CHECK_IRQ_AFTER)
970/** May trigger a VM exit (treated like IEM_CIMPL_F_MODE atm). */
971#define IEM_CIMPL_F_VMEXIT RT_BIT_32(11)
972/** May modify FPU state.
973 * @todo Not sure if this is useful yet. */
974#define IEM_CIMPL_F_FPU RT_BIT_32(12)
975/** REP prefixed instruction which may yield before updating PC.
976 * @todo Not sure if this is useful, REP functions now return non-zero
977 * status if they don't update the PC. */
978#define IEM_CIMPL_F_REP RT_BIT_32(13)
979/** I/O instruction.
980 * @todo Not sure if this is useful yet. */
981#define IEM_CIMPL_F_IO RT_BIT_32(14)
982/** Force end of TB after the instruction. */
983#define IEM_CIMPL_F_END_TB RT_BIT_32(15)
984/** Flag set if a branch may also modify the stack (push/pop return address). */
985#define IEM_CIMPL_F_BRANCH_STACK RT_BIT_32(16)
986/** Flag set if a branch may also modify the stack (push/pop return address)
987 * and switch it (load/restore SS:RSP). */
988#define IEM_CIMPL_F_BRANCH_STACK_FAR RT_BIT_32(17)
989/** Convenience: Raise exception (technically unnecessary, since it shouldn't return VINF_SUCCESS). */
990#define IEM_CIMPL_F_XCPT \
991 (IEM_CIMPL_F_BRANCH_INDIRECT | IEM_CIMPL_F_BRANCH_FAR | IEM_CIMPL_F_BRANCH_STACK_FAR \
992 | IEM_CIMPL_F_MODE | IEM_CIMPL_F_RFLAGS | IEM_CIMPL_F_VMEXIT)
993
994/** The block calls a C-implementation instruction function with two implicit arguments.
995 * Mutually exclusive with IEM_CIMPL_F_CALLS_AIMPL and
996 * IEM_CIMPL_F_CALLS_AIMPL_WITH_FXSTATE.
997 * @note The python scripts will add this if missing. */
998#define IEM_CIMPL_F_CALLS_CIMPL RT_BIT_32(18)
999/** The block calls an ASM-implementation instruction function.
1000 * Mutually exclusive with IEM_CIMPL_F_CALLS_CIMPL and
1001 * IEM_CIMPL_F_CALLS_AIMPL_WITH_FXSTATE.
1002 * @note The python scripts will add this if missing. */
1003#define IEM_CIMPL_F_CALLS_AIMPL RT_BIT_32(19)
1004/** The block calls an ASM-implementation instruction function with an implicit
1005 * X86FXSTATE pointer argument.
1006 * Mutually exclusive with IEM_CIMPL_F_CALLS_CIMPL, IEM_CIMPL_F_CALLS_AIMPL and
1007 * IEM_CIMPL_F_CALLS_AIMPL_WITH_XSTATE.
1008 * @note The python scripts will add this if missing. */
1009#define IEM_CIMPL_F_CALLS_AIMPL_WITH_FXSTATE RT_BIT_32(20)
1010/** The block calls an ASM-implementation instruction function with an implicit
1011 * X86XSAVEAREA pointer argument.
1012 * Mutually exclusive with IEM_CIMPL_F_CALLS_CIMPL, IEM_CIMPL_F_CALLS_AIMPL and
1013 * IEM_CIMPL_F_CALLS_AIMPL_WITH_FXSTATE.
1014 * @note No different from IEM_CIMPL_F_CALLS_AIMPL_WITH_FXSTATE, so same value.
1015 * @note The python scripts will add this if missing. */
1016#define IEM_CIMPL_F_CALLS_AIMPL_WITH_XSTATE IEM_CIMPL_F_CALLS_AIMPL_WITH_FXSTATE
1017/** @} */
1018
1019
1020/** @name IEM_F_XXX - Execution mode flags (IEMCPU::fExec, IEMTB::fFlags).
1021 *
1022 * These flags are set when entering IEM and adjusted as code is executed, such
1023 * that they will always contain the current values as instructions are
1024 * finished.
1025 *
1026 * In recompiled execution mode, (most of) these flags are included in the
1027 * translation block selection key and stored in IEMTB::fFlags alongside the
1028 * IEMTB_F_XXX flags. The latter flags uses bits 31 thru 24, which are all zero
1029 * in IEMCPU::fExec.
1030 *
1031 * @{ */
1032/** Mode: The block target mode mask. */
1033#define IEM_F_MODE_MASK UINT32_C(0x0000001f)
1034/** Mode: The IEMMODE part of the IEMTB_F_MODE_MASK value. */
1035#define IEM_F_MODE_CPUMODE_MASK UINT32_C(0x00000003)
1036/** X86 Mode: Bit used to indicating pre-386 CPU in 16-bit mode (for eliminating
1037 * conditional in EIP/IP updating), and flat wide open CS, SS, DS, and ES in
1038 * 32-bit mode (for simplifying most memory accesses). */
1039#define IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK UINT32_C(0x00000004)
1040/** X86 Mode: Bit indicating protected mode, real mode (or SMM) when not set. */
1041#define IEM_F_MODE_X86_PROT_MASK UINT32_C(0x00000008)
1042/** X86 Mode: Bit used to indicate virtual 8086 mode (only 16-bit). */
1043#define IEM_F_MODE_X86_V86_MASK UINT32_C(0x00000010)
1044
1045/** X86 Mode: 16-bit on 386 or later. */
1046#define IEM_F_MODE_X86_16BIT UINT32_C(0x00000000)
1047/** X86 Mode: 80286, 80186 and 8086/88 targetting blocks (EIP update opt). */
1048#define IEM_F_MODE_X86_16BIT_PRE_386 UINT32_C(0x00000004)
1049/** X86 Mode: 16-bit protected mode on 386 or later. */
1050#define IEM_F_MODE_X86_16BIT_PROT UINT32_C(0x00000008)
1051/** X86 Mode: 16-bit protected mode on 386 or later. */
1052#define IEM_F_MODE_X86_16BIT_PROT_PRE_386 UINT32_C(0x0000000c)
1053/** X86 Mode: 16-bit virtual 8086 protected mode (on 386 or later). */
1054#define IEM_F_MODE_X86_16BIT_PROT_V86 UINT32_C(0x00000018)
1055
1056/** X86 Mode: 32-bit on 386 or later. */
1057#define IEM_F_MODE_X86_32BIT UINT32_C(0x00000001)
1058/** X86 Mode: 32-bit mode with wide open flat CS, SS, DS and ES. */
1059#define IEM_F_MODE_X86_32BIT_FLAT UINT32_C(0x00000005)
1060/** X86 Mode: 32-bit protected mode. */
1061#define IEM_F_MODE_X86_32BIT_PROT UINT32_C(0x00000009)
1062/** X86 Mode: 32-bit protected mode with wide open flat CS, SS, DS and ES. */
1063#define IEM_F_MODE_X86_32BIT_PROT_FLAT UINT32_C(0x0000000d)
1064
1065/** X86 Mode: 64-bit (includes protected, but not the flat bit). */
1066#define IEM_F_MODE_X86_64BIT UINT32_C(0x0000000a)
1067
1068/** X86 Mode: Checks if @a a_fExec represent a FLAT mode. */
1069#define IEM_F_MODE_X86_IS_FLAT(a_fExec) ( ((a_fExec) & IEM_F_MODE_MASK) == IEM_F_MODE_X86_64BIT \
1070 || ((a_fExec) & IEM_F_MODE_MASK) == IEM_F_MODE_X86_32BIT_PROT_FLAT \
1071 || ((a_fExec) & IEM_F_MODE_MASK) == IEM_F_MODE_X86_32BIT_FLAT)
1072
1073/** Bypass access handlers when set. */
1074#define IEM_F_BYPASS_HANDLERS UINT32_C(0x00010000)
1075/** Have pending hardware instruction breakpoints. */
1076#define IEM_F_PENDING_BRK_INSTR UINT32_C(0x00020000)
1077/** Have pending hardware data breakpoints. */
1078#define IEM_F_PENDING_BRK_DATA UINT32_C(0x00040000)
1079
1080/** X86: Have pending hardware I/O breakpoints. */
1081#define IEM_F_PENDING_BRK_X86_IO UINT32_C(0x00000400)
1082/** X86: Disregard the lock prefix (implied or not) when set. */
1083#define IEM_F_X86_DISREGARD_LOCK UINT32_C(0x00000800)
1084
1085/** Pending breakpoint mask (what iemCalcExecDbgFlags works out). */
1086#define IEM_F_PENDING_BRK_MASK (IEM_F_PENDING_BRK_INSTR | IEM_F_PENDING_BRK_DATA | IEM_F_PENDING_BRK_X86_IO)
1087
1088/** Caller configurable options. */
1089#define IEM_F_USER_OPTS (IEM_F_BYPASS_HANDLERS | IEM_F_X86_DISREGARD_LOCK)
1090
1091/** X86: The current protection level (CPL) shift factor. */
1092#define IEM_F_X86_CPL_SHIFT 8
1093/** X86: The current protection level (CPL) mask. */
1094#define IEM_F_X86_CPL_MASK UINT32_C(0x00000300)
1095/** X86: The current protection level (CPL) shifted mask. */
1096#define IEM_F_X86_CPL_SMASK UINT32_C(0x00000003)
1097
1098/** X86: Alignment checks enabled (CR0.AM=1 & EFLAGS.AC=1). */
1099#define IEM_F_X86_AC UINT32_C(0x00080000)
1100
1101/** X86 execution context.
1102 * The IEM_F_X86_CTX_XXX values are individual flags that can be combined (with
1103 * the exception of IEM_F_X86_CTX_NORMAL). This allows running VMs from SMM
1104 * mode. */
1105#define IEM_F_X86_CTX_MASK UINT32_C(0x0000f000)
1106/** X86 context: Plain regular execution context. */
1107#define IEM_F_X86_CTX_NORMAL UINT32_C(0x00000000)
1108/** X86 context: VT-x enabled. */
1109#define IEM_F_X86_CTX_VMX UINT32_C(0x00001000)
1110/** X86 context: AMD-V enabled. */
1111#define IEM_F_X86_CTX_SVM UINT32_C(0x00002000)
1112/** X86 context: In AMD-V or VT-x guest mode. */
1113#define IEM_F_X86_CTX_IN_GUEST UINT32_C(0x00004000)
1114/** X86 context: System management mode (SMM). */
1115#define IEM_F_X86_CTX_SMM UINT32_C(0x00008000)
1116
1117/** @todo Add TF+RF+INHIBIT indicator(s), so we can eliminate the conditional in
1118 * iemRegFinishClearingRF() most for most situations (CPUMCTX_DBG_HIT_DRX_MASK
1119 * and CPUMCTX_DBG_DBGF_MASK are covered by the IEM_F_PENDING_BRK_XXX bits
1120 * alread). */
1121
1122/** @todo Add TF+RF+INHIBIT indicator(s), so we can eliminate the conditional in
1123 * iemRegFinishClearingRF() most for most situations
1124 * (CPUMCTX_DBG_HIT_DRX_MASK and CPUMCTX_DBG_DBGF_MASK are covered by
1125 * the IEM_F_PENDING_BRK_XXX bits alread). */
1126
1127/** @} */
1128
1129
1130/** @name IEMTB_F_XXX - Translation block flags (IEMTB::fFlags).
1131 *
1132 * Extends the IEM_F_XXX flags (subject to IEMTB_F_IEM_F_MASK) to make up the
1133 * translation block flags. The combined flag mask (subject to
1134 * IEMTB_F_KEY_MASK) is used as part of the lookup key for translation blocks.
1135 *
1136 * @{ */
1137/** Mask of IEM_F_XXX flags included in IEMTB_F_XXX. */
1138#define IEMTB_F_IEM_F_MASK UINT32_C(0x00ffffff)
1139
1140/** Type: The block type mask. */
1141#define IEMTB_F_TYPE_MASK UINT32_C(0x03000000)
1142/** Type: Purly threaded recompiler (via tables). */
1143#define IEMTB_F_TYPE_THREADED UINT32_C(0x01000000)
1144/** Type: Native recompilation. */
1145#define IEMTB_F_TYPE_NATIVE UINT32_C(0x02000000)
1146
1147/** Set when we're starting the block in an "interrupt shadow".
1148 * We don't need to distingish between the two types of this mask, thus the one.
1149 * @see CPUMCTX_INHIBIT_SHADOW, CPUMIsInInterruptShadow() */
1150#define IEMTB_F_INHIBIT_SHADOW UINT32_C(0x04000000)
1151/** Set when we're currently inhibiting NMIs
1152 * @see CPUMCTX_INHIBIT_NMI, CPUMAreInterruptsInhibitedByNmi() */
1153#define IEMTB_F_INHIBIT_NMI UINT32_C(0x08000000)
1154
1155/** Checks that EIP/IP is wihin CS.LIM before each instruction. Used when
1156 * we're close the limit before starting a TB, as determined by
1157 * iemGetTbFlagsForCurrentPc(). */
1158#define IEMTB_F_CS_LIM_CHECKS UINT32_C(0x10000000)
1159
1160/** Mask of the IEMTB_F_XXX flags that are part of the TB lookup key.
1161 *
1162 * @note We skip all of IEM_F_X86_CTX_MASK, with the exception of SMM (which we
1163 * don't implement), because we don't currently generate any context
1164 * specific code - that's all handled in CIMPL functions.
1165 *
1166 * For the threaded recompiler we don't generate any CPL specific code
1167 * either, but the native recompiler does for memory access (saves getting
1168 * the CPL from fExec and turning it into IEMTLBE_F_PT_NO_USER).
1169 * Since most OSes will not share code between rings, this shouldn't
1170 * have any real effect on TB/memory/recompiling load.
1171 */
1172#define IEMTB_F_KEY_MASK ((UINT32_MAX & ~(IEM_F_X86_CTX_MASK | IEMTB_F_TYPE_MASK)) | IEM_F_X86_CTX_SMM)
1173/** @} */
1174
1175AssertCompile( (IEM_F_MODE_X86_16BIT & IEM_F_MODE_CPUMODE_MASK) == IEMMODE_16BIT);
1176AssertCompile(!(IEM_F_MODE_X86_16BIT & IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK));
1177AssertCompile(!(IEM_F_MODE_X86_16BIT & IEM_F_MODE_X86_PROT_MASK));
1178AssertCompile(!(IEM_F_MODE_X86_16BIT & IEM_F_MODE_X86_V86_MASK));
1179AssertCompile( (IEM_F_MODE_X86_16BIT_PRE_386 & IEM_F_MODE_CPUMODE_MASK) == IEMMODE_16BIT);
1180AssertCompile( IEM_F_MODE_X86_16BIT_PRE_386 & IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK);
1181AssertCompile(!(IEM_F_MODE_X86_16BIT_PRE_386 & IEM_F_MODE_X86_PROT_MASK));
1182AssertCompile(!(IEM_F_MODE_X86_16BIT_PRE_386 & IEM_F_MODE_X86_V86_MASK));
1183AssertCompile( (IEM_F_MODE_X86_16BIT_PROT & IEM_F_MODE_CPUMODE_MASK) == IEMMODE_16BIT);
1184AssertCompile(!(IEM_F_MODE_X86_16BIT_PROT & IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK));
1185AssertCompile( IEM_F_MODE_X86_16BIT_PROT & IEM_F_MODE_X86_PROT_MASK);
1186AssertCompile(!(IEM_F_MODE_X86_16BIT_PROT & IEM_F_MODE_X86_V86_MASK));
1187AssertCompile( (IEM_F_MODE_X86_16BIT_PROT_PRE_386 & IEM_F_MODE_CPUMODE_MASK) == IEMMODE_16BIT);
1188AssertCompile( IEM_F_MODE_X86_16BIT_PROT_PRE_386 & IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK);
1189AssertCompile( IEM_F_MODE_X86_16BIT_PROT_PRE_386 & IEM_F_MODE_X86_PROT_MASK);
1190AssertCompile(!(IEM_F_MODE_X86_16BIT_PROT_PRE_386 & IEM_F_MODE_X86_V86_MASK));
1191AssertCompile( IEM_F_MODE_X86_16BIT_PROT_V86 & IEM_F_MODE_X86_PROT_MASK);
1192AssertCompile(!(IEM_F_MODE_X86_16BIT_PROT_V86 & IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK));
1193AssertCompile( IEM_F_MODE_X86_16BIT_PROT_V86 & IEM_F_MODE_X86_V86_MASK);
1194
1195AssertCompile( (IEM_F_MODE_X86_32BIT & IEM_F_MODE_CPUMODE_MASK) == IEMMODE_32BIT);
1196AssertCompile(!(IEM_F_MODE_X86_32BIT & IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK));
1197AssertCompile(!(IEM_F_MODE_X86_32BIT & IEM_F_MODE_X86_PROT_MASK));
1198AssertCompile( (IEM_F_MODE_X86_32BIT_FLAT & IEM_F_MODE_CPUMODE_MASK) == IEMMODE_32BIT);
1199AssertCompile( IEM_F_MODE_X86_32BIT_FLAT & IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK);
1200AssertCompile(!(IEM_F_MODE_X86_32BIT_FLAT & IEM_F_MODE_X86_PROT_MASK));
1201AssertCompile( (IEM_F_MODE_X86_32BIT_PROT & IEM_F_MODE_CPUMODE_MASK) == IEMMODE_32BIT);
1202AssertCompile(!(IEM_F_MODE_X86_32BIT_PROT & IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK));
1203AssertCompile( IEM_F_MODE_X86_32BIT_PROT & IEM_F_MODE_X86_PROT_MASK);
1204AssertCompile( (IEM_F_MODE_X86_32BIT_PROT_FLAT & IEM_F_MODE_CPUMODE_MASK) == IEMMODE_32BIT);
1205AssertCompile( IEM_F_MODE_X86_32BIT_PROT_FLAT & IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK);
1206AssertCompile( IEM_F_MODE_X86_32BIT_PROT_FLAT & IEM_F_MODE_X86_PROT_MASK);
1207
1208AssertCompile( (IEM_F_MODE_X86_64BIT & IEM_F_MODE_CPUMODE_MASK) == IEMMODE_64BIT);
1209AssertCompile( IEM_F_MODE_X86_64BIT & IEM_F_MODE_X86_PROT_MASK);
1210AssertCompile(!(IEM_F_MODE_X86_64BIT & IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK));
1211
1212/** Native instruction type for use with the native code generator.
1213 * This is a byte (uint8_t) for x86 and amd64 and uint32_t for the other(s). */
1214#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
1215typedef uint8_t IEMNATIVEINSTR;
1216#else
1217typedef uint32_t IEMNATIVEINSTR;
1218#endif
1219/** Pointer to a native instruction unit. */
1220typedef IEMNATIVEINSTR *PIEMNATIVEINSTR;
1221/** Pointer to a const native instruction unit. */
1222typedef IEMNATIVEINSTR const *PCIEMNATIVEINSTR;
1223
1224/**
1225 * A call for the threaded call table.
1226 */
1227typedef struct IEMTHRDEDCALLENTRY
1228{
1229 /** The function to call (IEMTHREADEDFUNCS). */
1230 uint16_t enmFunction;
1231
1232 /** Instruction number in the TB (for statistics). */
1233 uint8_t idxInstr;
1234 /** The opcode length. */
1235 uint8_t cbOpcode;
1236 /** Offset into IEMTB::pabOpcodes. */
1237 uint16_t offOpcode;
1238
1239 /** TB lookup table index (7 bits) and large size (1 bits).
1240 *
1241 * The default size is 1 entry, but for indirect calls and returns we set the
1242 * top bit and allocate 4 (IEM_TB_LOOKUP_TAB_LARGE_SIZE) entries. The large
1243 * tables uses RIP for selecting the entry to use, as it is assumed a hash table
1244 * lookup isn't that slow compared to sequentially trying out 4 TBs.
1245 *
1246 * By default lookup table entry 0 for a TB is reserved as a fallback for
1247 * calltable entries w/o explicit entreis, so this member will be non-zero if
1248 * there is a lookup entry associated with this call.
1249 *
1250 * @sa IEM_TB_LOOKUP_TAB_GET_SIZE, IEM_TB_LOOKUP_TAB_GET_IDX
1251 */
1252 uint8_t uTbLookup;
1253
1254 /** Flags - IEMTHREADEDCALLENTRY_F_XXX. */
1255 uint8_t fFlags;
1256
1257 /** Generic parameters. */
1258 uint64_t auParams[3];
1259} IEMTHRDEDCALLENTRY;
1260AssertCompileSize(IEMTHRDEDCALLENTRY, sizeof(uint64_t) * 4);
1261/** Pointer to a threaded call entry. */
1262typedef struct IEMTHRDEDCALLENTRY *PIEMTHRDEDCALLENTRY;
1263/** Pointer to a const threaded call entry. */
1264typedef IEMTHRDEDCALLENTRY const *PCIEMTHRDEDCALLENTRY;
1265
1266/** The number of TB lookup table entries for a large allocation
1267 * (IEMTHRDEDCALLENTRY::uTbLookup bit 7 set). */
1268#define IEM_TB_LOOKUP_TAB_LARGE_SIZE 4
1269/** Get the lookup table size from IEMTHRDEDCALLENTRY::uTbLookup. */
1270#define IEM_TB_LOOKUP_TAB_GET_SIZE(a_uTbLookup) (!((a_uTbLookup) & 0x80) ? 1 : IEM_TB_LOOKUP_TAB_LARGE_SIZE)
1271/** Get the first lookup table index from IEMTHRDEDCALLENTRY::uTbLookup. */
1272#define IEM_TB_LOOKUP_TAB_GET_IDX(a_uTbLookup) ((a_uTbLookup) & 0x7f)
1273/** Get the lookup table index from IEMTHRDEDCALLENTRY::uTbLookup and RIP. */
1274#define IEM_TB_LOOKUP_TAB_GET_IDX_WITH_RIP(a_uTbLookup, a_Rip) \
1275 (!((a_uTbLookup) & 0x80) ? (a_uTbLookup) & 0x7f : ((a_uTbLookup) & 0x7f) + ((a_Rip) & (IEM_TB_LOOKUP_TAB_LARGE_SIZE - 1)) )
1276
1277/** Make a IEMTHRDEDCALLENTRY::uTbLookup value. */
1278#define IEM_TB_LOOKUP_TAB_MAKE(a_idxTable, a_fLarge) ((a_idxTable) | ((a_fLarge) ? 0x80 : 0))
1279
1280
1281/** The call entry is a jump target. */
1282#define IEMTHREADEDCALLENTRY_F_JUMP_TARGET UINT8_C(0x01)
1283
1284
1285/**
1286 * Native IEM TB 'function' typedef.
1287 *
1288 * This will throw/longjmp on occation.
1289 *
1290 * @note AMD64 doesn't have that many non-volatile registers and does sport
1291 * 32-bit address displacments, so we don't need pCtx.
1292 *
1293 * On ARM64 pCtx allows us to directly address the whole register
1294 * context without requiring a separate indexing register holding the
1295 * offset. This saves an instruction loading the offset for each guest
1296 * CPU context access, at the cost of a non-volatile register.
1297 * Fortunately, ARM64 has quite a lot more registers.
1298 */
1299typedef
1300#ifdef RT_ARCH_AMD64
1301int FNIEMTBNATIVE(PVMCPUCC pVCpu)
1302#else
1303int FNIEMTBNATIVE(PVMCPUCC pVCpu, PCPUMCTX pCtx)
1304#endif
1305#if RT_CPLUSPLUS_PREREQ(201700)
1306 IEM_NOEXCEPT_MAY_LONGJMP
1307#endif
1308 ;
1309/** Pointer to a native IEM TB entry point function.
1310 * This will throw/longjmp on occation. */
1311typedef FNIEMTBNATIVE *PFNIEMTBNATIVE;
1312
1313
1314/**
1315 * Translation block debug info entry type.
1316 */
1317typedef enum IEMTBDBGENTRYTYPE
1318{
1319 kIemTbDbgEntryType_Invalid = 0,
1320 /** The entry is for marking a native code position.
1321 * Entries following this all apply to this position. */
1322 kIemTbDbgEntryType_NativeOffset,
1323 /** The entry is for a new guest instruction. */
1324 kIemTbDbgEntryType_GuestInstruction,
1325 /** Marks the start of a threaded call. */
1326 kIemTbDbgEntryType_ThreadedCall,
1327 /** Marks the location of a label. */
1328 kIemTbDbgEntryType_Label,
1329 /** Info about a host register shadowing a guest register. */
1330 kIemTbDbgEntryType_GuestRegShadowing,
1331#ifdef IEMNATIVE_WITH_SIMD_REG_ALLOCATOR
1332 /** Info about a host SIMD register shadowing a guest SIMD register. */
1333 kIemTbDbgEntryType_GuestSimdRegShadowing,
1334#endif
1335#ifdef IEMNATIVE_WITH_DELAYED_PC_UPDATING
1336 /** Info about a delayed RIP update. */
1337 kIemTbDbgEntryType_DelayedPcUpdate,
1338#endif
1339#if defined(IEMNATIVE_WITH_DELAYED_REGISTER_WRITEBACK) || defined(IEMNATIVE_WITH_SIMD_REG_ALLOCATOR)
1340 /** Info about a shadowed guest register becoming dirty. */
1341 kIemTbDbgEntryType_GuestRegDirty,
1342 /** Info about register writeback/flush oepration. */
1343 kIemTbDbgEntryType_GuestRegWriteback,
1344#endif
1345 kIemTbDbgEntryType_End
1346} IEMTBDBGENTRYTYPE;
1347
1348/**
1349 * Translation block debug info entry.
1350 */
1351typedef union IEMTBDBGENTRY
1352{
1353 /** Plain 32-bit view. */
1354 uint32_t u;
1355
1356 /** Generic view for getting at the type field. */
1357 struct
1358 {
1359 /** IEMTBDBGENTRYTYPE */
1360 uint32_t uType : 4;
1361 uint32_t uTypeSpecific : 28;
1362 } Gen;
1363
1364 struct
1365 {
1366 /** kIemTbDbgEntryType_ThreadedCall1. */
1367 uint32_t uType : 4;
1368 /** Native code offset. */
1369 uint32_t offNative : 28;
1370 } NativeOffset;
1371
1372 struct
1373 {
1374 /** kIemTbDbgEntryType_GuestInstruction. */
1375 uint32_t uType : 4;
1376 uint32_t uUnused : 4;
1377 /** The IEM_F_XXX flags. */
1378 uint32_t fExec : 24;
1379 } GuestInstruction;
1380
1381 struct
1382 {
1383 /* kIemTbDbgEntryType_ThreadedCall. */
1384 uint32_t uType : 4;
1385 /** Set if the call was recompiled to native code, clear if just calling
1386 * threaded function. */
1387 uint32_t fRecompiled : 1;
1388 uint32_t uUnused : 11;
1389 /** The threaded call number (IEMTHREADEDFUNCS). */
1390 uint32_t enmCall : 16;
1391 } ThreadedCall;
1392
1393 struct
1394 {
1395 /* kIemTbDbgEntryType_Label. */
1396 uint32_t uType : 4;
1397 uint32_t uUnused : 4;
1398 /** The label type (IEMNATIVELABELTYPE). */
1399 uint32_t enmLabel : 8;
1400 /** The label data. */
1401 uint32_t uData : 16;
1402 } Label;
1403
1404 struct
1405 {
1406 /* kIemTbDbgEntryType_GuestRegShadowing. */
1407 uint32_t uType : 4;
1408 uint32_t uUnused : 4;
1409 /** The guest register being shadowed (IEMNATIVEGSTREG). */
1410 uint32_t idxGstReg : 8;
1411 /** The host new register number, UINT8_MAX if dropped. */
1412 uint32_t idxHstReg : 8;
1413 /** The previous host register number, UINT8_MAX if new. */
1414 uint32_t idxHstRegPrev : 8;
1415 } GuestRegShadowing;
1416
1417#ifdef IEMNATIVE_WITH_SIMD_REG_ALLOCATOR
1418 struct
1419 {
1420 /* kIemTbDbgEntryType_GuestSimdRegShadowing. */
1421 uint32_t uType : 4;
1422 uint32_t uUnused : 4;
1423 /** The guest register being shadowed (IEMNATIVEGSTSIMDREG). */
1424 uint32_t idxGstSimdReg : 8;
1425 /** The host new register number, UINT8_MAX if dropped. */
1426 uint32_t idxHstSimdReg : 8;
1427 /** The previous host register number, UINT8_MAX if new. */
1428 uint32_t idxHstSimdRegPrev : 8;
1429 } GuestSimdRegShadowing;
1430#endif
1431
1432#ifdef IEMNATIVE_WITH_DELAYED_PC_UPDATING
1433 struct
1434 {
1435 /* kIemTbDbgEntryType_DelayedPcUpdate. */
1436 uint32_t uType : 4;
1437 /* The instruction offset added to the program counter. */
1438 uint32_t offPc : 14;
1439 /** Number of instructions skipped. */
1440 uint32_t cInstrSkipped : 14;
1441 } DelayedPcUpdate;
1442#endif
1443
1444#if defined(IEMNATIVE_WITH_DELAYED_REGISTER_WRITEBACK) || defined(IEMNATIVE_WITH_SIMD_REG_ALLOCATOR)
1445 struct
1446 {
1447 /* kIemTbDbgEntryType_GuestRegDirty. */
1448 uint32_t uType : 4;
1449 uint32_t uUnused : 11;
1450 /** Flag whether this is about a SIMD (true) or general (false) register. */
1451 uint32_t fSimdReg : 1;
1452 /** The guest register index being marked as dirty. */
1453 uint32_t idxGstReg : 8;
1454 /** The host register number this register is shadowed in .*/
1455 uint32_t idxHstReg : 8;
1456 } GuestRegDirty;
1457
1458 struct
1459 {
1460 /* kIemTbDbgEntryType_GuestRegWriteback. */
1461 uint32_t uType : 4;
1462 /** Flag whether this is about a SIMD (true) or general (false) register flush. */
1463 uint32_t fSimdReg : 1;
1464 /** The mask shift. */
1465 uint32_t cShift : 2;
1466 /** The guest register mask being written back. */
1467 uint32_t fGstReg : 25;
1468 } GuestRegWriteback;
1469#endif
1470
1471} IEMTBDBGENTRY;
1472AssertCompileSize(IEMTBDBGENTRY, sizeof(uint32_t));
1473/** Pointer to a debug info entry. */
1474typedef IEMTBDBGENTRY *PIEMTBDBGENTRY;
1475/** Pointer to a const debug info entry. */
1476typedef IEMTBDBGENTRY const *PCIEMTBDBGENTRY;
1477
1478/**
1479 * Translation block debug info.
1480 */
1481typedef struct IEMTBDBG
1482{
1483 /** Number of entries in aEntries. */
1484 uint32_t cEntries;
1485 /** The offset of the last kIemTbDbgEntryType_NativeOffset record. */
1486 uint32_t offNativeLast;
1487 /** Debug info entries. */
1488 RT_FLEXIBLE_ARRAY_EXTENSION
1489 IEMTBDBGENTRY aEntries[RT_FLEXIBLE_ARRAY];
1490} IEMTBDBG;
1491/** Pointer to TB debug info. */
1492typedef IEMTBDBG *PIEMTBDBG;
1493/** Pointer to const TB debug info. */
1494typedef IEMTBDBG const *PCIEMTBDBG;
1495
1496
1497/**
1498 * Translation block.
1499 *
1500 * The current plan is to just keep TBs and associated lookup hash table private
1501 * to each VCpu as that simplifies TB removal greatly (no races) and generally
1502 * avoids using expensive atomic primitives for updating lists and stuff.
1503 */
1504#pragma pack(2) /* to prevent the Thrd structure from being padded unnecessarily */
1505typedef struct IEMTB
1506{
1507 /** Next block with the same hash table entry. */
1508 struct IEMTB *pNext;
1509 /** Usage counter. */
1510 uint32_t cUsed;
1511 /** The IEMCPU::msRecompilerPollNow last time it was used. */
1512 uint32_t msLastUsed;
1513
1514 /** @name What uniquely identifies the block.
1515 * @{ */
1516 RTGCPHYS GCPhysPc;
1517 /** IEMTB_F_XXX (i.e. IEM_F_XXX ++). */
1518 uint32_t fFlags;
1519 union
1520 {
1521 struct
1522 {
1523 /**< Relevant CS X86DESCATTR_XXX bits. */
1524 uint16_t fAttr;
1525 } x86;
1526 };
1527 /** @} */
1528
1529 /** Number of opcode ranges. */
1530 uint8_t cRanges;
1531 /** Statistics: Number of instructions in the block. */
1532 uint8_t cInstructions;
1533
1534 /** Type specific info. */
1535 union
1536 {
1537 struct
1538 {
1539 /** The call sequence table. */
1540 PIEMTHRDEDCALLENTRY paCalls;
1541 /** Number of calls in paCalls. */
1542 uint16_t cCalls;
1543 /** Number of calls allocated. */
1544 uint16_t cAllocated;
1545 } Thrd;
1546 struct
1547 {
1548 /** The native instructions (PFNIEMTBNATIVE). */
1549 PIEMNATIVEINSTR paInstructions;
1550 /** Number of instructions pointed to by paInstructions. */
1551 uint32_t cInstructions;
1552 } Native;
1553 /** Generic view for zeroing when freeing. */
1554 struct
1555 {
1556 uintptr_t uPtr;
1557 uint32_t uData;
1558 } Gen;
1559 };
1560
1561 /** The allocation chunk this TB belongs to. */
1562 uint8_t idxAllocChunk;
1563 /** The number of entries in the lookup table.
1564 * Because we're out of space, the TB lookup table is located before the
1565 * opcodes pointed to by pabOpcodes. */
1566 uint8_t cTbLookupEntries;
1567
1568 /** Number of bytes of opcodes stored in pabOpcodes.
1569 * @todo this field isn't really needed, aRanges keeps the actual info. */
1570 uint16_t cbOpcodes;
1571 /** Pointer to the opcode bytes this block was recompiled from.
1572 * This also points to the TB lookup table, which starts cTbLookupEntries
1573 * entries before the opcodes (we don't have room atm for another point). */
1574 uint8_t *pabOpcodes;
1575
1576 /** Debug info if enabled.
1577 * This is only generated by the native recompiler. */
1578 PIEMTBDBG pDbgInfo;
1579
1580 /* --- 64 byte cache line end --- */
1581
1582 /** Opcode ranges.
1583 *
1584 * The opcode checkers and maybe TLB loading functions will use this to figure
1585 * out what to do. The parameter will specify an entry and the opcode offset to
1586 * start at and the minimum number of bytes to verify (instruction length).
1587 *
1588 * When VT-x and AMD-V looks up the opcode bytes for an exitting instruction,
1589 * they'll first translate RIP (+ cbInstr - 1) to a physical address using the
1590 * code TLB (must have a valid entry for that address) and scan the ranges to
1591 * locate the corresponding opcodes. Probably.
1592 */
1593 struct IEMTBOPCODERANGE
1594 {
1595 /** Offset within pabOpcodes. */
1596 uint16_t offOpcodes;
1597 /** Number of bytes. */
1598 uint16_t cbOpcodes;
1599 /** The page offset. */
1600 RT_GCC_EXTENSION
1601 uint16_t offPhysPage : 12;
1602 /** Unused bits. */
1603 RT_GCC_EXTENSION
1604 uint16_t u2Unused : 2;
1605 /** Index into GCPhysPc + aGCPhysPages for the physical page address. */
1606 RT_GCC_EXTENSION
1607 uint16_t idxPhysPage : 2;
1608 } aRanges[8];
1609
1610 /** Physical pages that this TB covers.
1611 * The GCPhysPc w/o page offset is element zero, so starting here with 1. */
1612 RTGCPHYS aGCPhysPages[2];
1613} IEMTB;
1614#pragma pack()
1615AssertCompileMemberAlignment(IEMTB, GCPhysPc, sizeof(RTGCPHYS));
1616AssertCompileMemberAlignment(IEMTB, Thrd, sizeof(void *));
1617AssertCompileMemberAlignment(IEMTB, pabOpcodes, sizeof(void *));
1618AssertCompileMemberAlignment(IEMTB, pDbgInfo, sizeof(void *));
1619AssertCompileMemberAlignment(IEMTB, aGCPhysPages, sizeof(RTGCPHYS));
1620AssertCompileMemberOffset(IEMTB, aRanges, 64);
1621AssertCompileMemberSize(IEMTB, aRanges[0], 6);
1622#if 1
1623AssertCompileSize(IEMTB, 128);
1624# define IEMTB_SIZE_IS_POWER_OF_TWO /**< The IEMTB size is a power of two. */
1625#else
1626AssertCompileSize(IEMTB, 168);
1627# undef IEMTB_SIZE_IS_POWER_OF_TWO
1628#endif
1629
1630/** Pointer to a translation block. */
1631typedef IEMTB *PIEMTB;
1632/** Pointer to a const translation block. */
1633typedef IEMTB const *PCIEMTB;
1634
1635/** Gets address of the given TB lookup table entry. */
1636#define IEMTB_GET_TB_LOOKUP_TAB_ENTRY(a_pTb, a_idx) \
1637 ((PIEMTB *)&(a_pTb)->pabOpcodes[-(int)((a_pTb)->cTbLookupEntries - (a_idx)) * sizeof(PIEMTB)])
1638
1639/**
1640 * Gets the physical address for a TB opcode range.
1641 */
1642DECL_FORCE_INLINE(RTGCPHYS) iemTbGetRangePhysPageAddr(PCIEMTB pTb, uint8_t idxRange)
1643{
1644 Assert(idxRange < RT_MIN(pTb->cRanges, RT_ELEMENTS(pTb->aRanges)));
1645 uint8_t const idxPage = pTb->aRanges[idxRange].idxPhysPage;
1646 Assert(idxPage <= RT_ELEMENTS(pTb->aGCPhysPages));
1647 if (idxPage == 0)
1648 return pTb->GCPhysPc & ~(RTGCPHYS)GUEST_PAGE_OFFSET_MASK;
1649 Assert(!(pTb->aGCPhysPages[idxPage - 1] & GUEST_PAGE_OFFSET_MASK));
1650 return pTb->aGCPhysPages[idxPage - 1];
1651}
1652
1653
1654/**
1655 * A chunk of memory in the TB allocator.
1656 */
1657typedef struct IEMTBCHUNK
1658{
1659 /** Pointer to the translation blocks in this chunk. */
1660 PIEMTB paTbs;
1661#ifdef IN_RING0
1662 /** Allocation handle. */
1663 RTR0MEMOBJ hMemObj;
1664#endif
1665} IEMTBCHUNK;
1666
1667/**
1668 * A per-CPU translation block allocator.
1669 *
1670 * Because of how the IEMTBCACHE uses the lower 6 bits of the TB address to keep
1671 * the length of the collision list, and of course also for cache line alignment
1672 * reasons, the TBs must be allocated with at least 64-byte alignment.
1673 * Memory is there therefore allocated using one of the page aligned allocators.
1674 *
1675 *
1676 * To avoid wasting too much memory, it is allocated piecemeal as needed,
1677 * in chunks (IEMTBCHUNK) of 2 MiB or more. The TB has an 8-bit chunk index
1678 * that enables us to quickly calculate the allocation bitmap position when
1679 * freeing the translation block.
1680 */
1681typedef struct IEMTBALLOCATOR
1682{
1683 /** Magic value (IEMTBALLOCATOR_MAGIC). */
1684 uint32_t uMagic;
1685
1686#ifdef IEMTB_SIZE_IS_POWER_OF_TWO
1687 /** Mask corresponding to cTbsPerChunk - 1. */
1688 uint32_t fChunkMask;
1689 /** Shift count corresponding to cTbsPerChunk. */
1690 uint8_t cChunkShift;
1691#else
1692 uint32_t uUnused;
1693 uint8_t bUnused;
1694#endif
1695 /** Number of chunks we're allowed to allocate. */
1696 uint8_t cMaxChunks;
1697 /** Number of chunks currently populated. */
1698 uint16_t cAllocatedChunks;
1699 /** Number of translation blocks per chunk. */
1700 uint32_t cTbsPerChunk;
1701 /** Chunk size. */
1702 uint32_t cbPerChunk;
1703
1704 /** The maximum number of TBs. */
1705 uint32_t cMaxTbs;
1706 /** Total number of TBs in the populated chunks.
1707 * (cAllocatedChunks * cTbsPerChunk) */
1708 uint32_t cTotalTbs;
1709 /** The current number of TBs in use.
1710 * The number of free TBs: cAllocatedTbs - cInUseTbs; */
1711 uint32_t cInUseTbs;
1712 /** Statistics: Number of the cInUseTbs that are native ones. */
1713 uint32_t cNativeTbs;
1714 /** Statistics: Number of the cInUseTbs that are threaded ones. */
1715 uint32_t cThreadedTbs;
1716
1717 /** Where to start pruning TBs from when we're out.
1718 * See iemTbAllocatorAllocSlow for details. */
1719 uint32_t iPruneFrom;
1720 /** Where to start pruning native TBs from when we're out of executable memory.
1721 * See iemTbAllocatorFreeupNativeSpace for details. */
1722 uint32_t iPruneNativeFrom;
1723 uint64_t u64Padding;
1724
1725 /** Statistics: Number of TB allocation calls. */
1726 STAMCOUNTER StatAllocs;
1727 /** Statistics: Number of TB free calls. */
1728 STAMCOUNTER StatFrees;
1729 /** Statistics: Time spend pruning. */
1730 STAMPROFILE StatPrune;
1731 /** Statistics: Time spend pruning native TBs. */
1732 STAMPROFILE StatPruneNative;
1733
1734 /** The delayed free list (see iemTbAlloctorScheduleForFree). */
1735 PIEMTB pDelayedFreeHead;
1736 /* Head of the list of free TBs. */
1737 PIEMTB pTbsFreeHead;
1738
1739 /** Allocation chunks. */
1740 IEMTBCHUNK aChunks[256];
1741} IEMTBALLOCATOR;
1742/** Pointer to a TB allocator. */
1743typedef struct IEMTBALLOCATOR *PIEMTBALLOCATOR;
1744
1745/** Magic value for the TB allocator (Emmet Harley Cohen). */
1746#define IEMTBALLOCATOR_MAGIC UINT32_C(0x19900525)
1747
1748
1749/**
1750 * A per-CPU translation block cache (hash table).
1751 *
1752 * The hash table is allocated once during IEM initialization and size double
1753 * the max TB count, rounded up to the nearest power of two (so we can use and
1754 * AND mask rather than a rest division when hashing).
1755 */
1756typedef struct IEMTBCACHE
1757{
1758 /** Magic value (IEMTBCACHE_MAGIC). */
1759 uint32_t uMagic;
1760 /** Size of the hash table. This is a power of two. */
1761 uint32_t cHash;
1762 /** The mask corresponding to cHash. */
1763 uint32_t uHashMask;
1764 uint32_t uPadding;
1765
1766 /** @name Statistics
1767 * @{ */
1768 /** Number of collisions ever. */
1769 STAMCOUNTER cCollisions;
1770
1771 /** Statistics: Number of TB lookup misses. */
1772 STAMCOUNTER cLookupMisses;
1773 /** Statistics: Number of TB lookup hits via hash table (debug only). */
1774 STAMCOUNTER cLookupHits;
1775 /** Statistics: Number of TB lookup hits via TB associated lookup table (debug only). */
1776 STAMCOUNTER cLookupHitsViaTbLookupTable;
1777 STAMCOUNTER auPadding2[2];
1778 /** Statistics: Collision list length pruning. */
1779 STAMPROFILE StatPrune;
1780 /** @} */
1781
1782 /** The hash table itself.
1783 * @note The lower 6 bits of the pointer is used for keeping the collision
1784 * list length, so we can take action when it grows too long.
1785 * This works because TBs are allocated using a 64 byte (or
1786 * higher) alignment from page aligned chunks of memory, so the lower
1787 * 6 bits of the address will always be zero.
1788 * See IEMTBCACHE_PTR_COUNT_MASK, IEMTBCACHE_PTR_MAKE and friends.
1789 */
1790 RT_FLEXIBLE_ARRAY_EXTENSION
1791 PIEMTB apHash[RT_FLEXIBLE_ARRAY];
1792} IEMTBCACHE;
1793/** Pointer to a per-CPU translation block cahce. */
1794typedef IEMTBCACHE *PIEMTBCACHE;
1795
1796/** Magic value for IEMTBCACHE (Johnny O'Neal). */
1797#define IEMTBCACHE_MAGIC UINT32_C(0x19561010)
1798
1799/** The collision count mask for IEMTBCACHE::apHash entries. */
1800#define IEMTBCACHE_PTR_COUNT_MASK ((uintptr_t)0x3f)
1801/** The max collision count for IEMTBCACHE::apHash entries before pruning. */
1802#define IEMTBCACHE_PTR_MAX_COUNT ((uintptr_t)0x30)
1803/** Combine a TB pointer and a collision list length into a value for an
1804 * IEMTBCACHE::apHash entry. */
1805#define IEMTBCACHE_PTR_MAKE(a_pTb, a_cCount) (PIEMTB)((uintptr_t)(a_pTb) | (a_cCount))
1806/** Combine a TB pointer and a collision list length into a value for an
1807 * IEMTBCACHE::apHash entry. */
1808#define IEMTBCACHE_PTR_GET_TB(a_pHashEntry) (PIEMTB)((uintptr_t)(a_pHashEntry) & ~IEMTBCACHE_PTR_COUNT_MASK)
1809/** Combine a TB pointer and a collision list length into a value for an
1810 * IEMTBCACHE::apHash entry. */
1811#define IEMTBCACHE_PTR_GET_COUNT(a_pHashEntry) ((uintptr_t)(a_pHashEntry) & IEMTBCACHE_PTR_COUNT_MASK)
1812
1813/**
1814 * Calculates the hash table slot for a TB from physical PC address and TB flags.
1815 */
1816#define IEMTBCACHE_HASH(a_paCache, a_fTbFlags, a_GCPhysPc) \
1817 IEMTBCACHE_HASH_NO_KEY_MASK(a_paCache, (a_fTbFlags) & IEMTB_F_KEY_MASK, a_GCPhysPc)
1818
1819/**
1820 * Calculates the hash table slot for a TB from physical PC address and TB
1821 * flags, ASSUMING the caller has applied IEMTB_F_KEY_MASK to @a a_fTbFlags.
1822 */
1823#define IEMTBCACHE_HASH_NO_KEY_MASK(a_paCache, a_fTbFlags, a_GCPhysPc) \
1824 (((uint32_t)(a_GCPhysPc) ^ (a_fTbFlags)) & (a_paCache)->uHashMask)
1825
1826
1827/** @name IEMBRANCHED_F_XXX - Branched indicator (IEMCPU::fTbBranched).
1828 *
1829 * These flags parallels the main IEM_CIMPL_F_BRANCH_XXX flags.
1830 *
1831 * @{ */
1832/** Value if no branching happened recently. */
1833#define IEMBRANCHED_F_NO UINT8_C(0x00)
1834/** Flag set if direct branch, clear if absolute or indirect. */
1835#define IEMBRANCHED_F_DIRECT UINT8_C(0x01)
1836/** Flag set if indirect branch, clear if direct or relative. */
1837#define IEMBRANCHED_F_INDIRECT UINT8_C(0x02)
1838/** Flag set if relative branch, clear if absolute or indirect. */
1839#define IEMBRANCHED_F_RELATIVE UINT8_C(0x04)
1840/** Flag set if conditional branch, clear if unconditional. */
1841#define IEMBRANCHED_F_CONDITIONAL UINT8_C(0x08)
1842/** Flag set if it's a far branch. */
1843#define IEMBRANCHED_F_FAR UINT8_C(0x10)
1844/** Flag set if the stack pointer is modified. */
1845#define IEMBRANCHED_F_STACK UINT8_C(0x20)
1846/** Flag set if the stack pointer and (maybe) the stack segment are modified. */
1847#define IEMBRANCHED_F_STACK_FAR UINT8_C(0x40)
1848/** Flag set (by IEM_MC_REL_JMP_XXX) if it's a zero bytes relative jump. */
1849#define IEMBRANCHED_F_ZERO UINT8_C(0x80)
1850/** @} */
1851
1852
1853/**
1854 * The per-CPU IEM state.
1855 */
1856typedef struct IEMCPU
1857{
1858 /** Info status code that needs to be propagated to the IEM caller.
1859 * This cannot be passed internally, as it would complicate all success
1860 * checks within the interpreter making the code larger and almost impossible
1861 * to get right. Instead, we'll store status codes to pass on here. Each
1862 * source of these codes will perform appropriate sanity checks. */
1863 int32_t rcPassUp; /* 0x00 */
1864 /** Execution flag, IEM_F_XXX. */
1865 uint32_t fExec; /* 0x04 */
1866
1867 /** @name Decoder state.
1868 * @{ */
1869#ifdef IEM_WITH_CODE_TLB
1870 /** The offset of the next instruction byte. */
1871 uint32_t offInstrNextByte; /* 0x08 */
1872 /** The number of bytes available at pbInstrBuf for the current instruction.
1873 * This takes the max opcode length into account so that doesn't need to be
1874 * checked separately. */
1875 uint32_t cbInstrBuf; /* 0x0c */
1876 /** Pointer to the page containing RIP, user specified buffer or abOpcode.
1877 * This can be NULL if the page isn't mappable for some reason, in which
1878 * case we'll do fallback stuff.
1879 *
1880 * If we're executing an instruction from a user specified buffer,
1881 * IEMExecOneWithPrefetchedByPC and friends, this is not necessarily a page
1882 * aligned pointer but pointer to the user data.
1883 *
1884 * For instructions crossing pages, this will start on the first page and be
1885 * advanced to the next page by the time we've decoded the instruction. This
1886 * therefore precludes stuff like <tt>pbInstrBuf[offInstrNextByte + cbInstrBuf - cbCurInstr]</tt>
1887 */
1888 uint8_t const *pbInstrBuf; /* 0x10 */
1889# if ARCH_BITS == 32
1890 uint32_t uInstrBufHigh; /** The high dword of the host context pbInstrBuf member. */
1891# endif
1892 /** The program counter corresponding to pbInstrBuf.
1893 * This is set to a non-canonical address when we need to invalidate it. */
1894 uint64_t uInstrBufPc; /* 0x18 */
1895 /** The guest physical address corresponding to pbInstrBuf. */
1896 RTGCPHYS GCPhysInstrBuf; /* 0x20 */
1897 /** The number of bytes available at pbInstrBuf in total (for IEMExecLots).
1898 * This takes the CS segment limit into account.
1899 * @note Set to zero when the code TLB is flushed to trigger TLB reload. */
1900 uint16_t cbInstrBufTotal; /* 0x28 */
1901 /** Offset into pbInstrBuf of the first byte of the current instruction.
1902 * Can be negative to efficiently handle cross page instructions. */
1903 int16_t offCurInstrStart; /* 0x2a */
1904
1905# ifndef IEM_WITH_OPAQUE_DECODER_STATE
1906 /** The prefix mask (IEM_OP_PRF_XXX). */
1907 uint32_t fPrefixes; /* 0x2c */
1908 /** The extra REX ModR/M register field bit (REX.R << 3). */
1909 uint8_t uRexReg; /* 0x30 */
1910 /** The extra REX ModR/M r/m field, SIB base and opcode reg bit
1911 * (REX.B << 3). */
1912 uint8_t uRexB; /* 0x31 */
1913 /** The extra REX SIB index field bit (REX.X << 3). */
1914 uint8_t uRexIndex; /* 0x32 */
1915
1916 /** The effective segment register (X86_SREG_XXX). */
1917 uint8_t iEffSeg; /* 0x33 */
1918
1919 /** The offset of the ModR/M byte relative to the start of the instruction. */
1920 uint8_t offModRm; /* 0x34 */
1921
1922# ifdef IEM_WITH_CODE_TLB_AND_OPCODE_BUF
1923 /** The current offset into abOpcode. */
1924 uint8_t offOpcode; /* 0x35 */
1925# else
1926 uint8_t bUnused; /* 0x35 */
1927# endif
1928# else /* IEM_WITH_OPAQUE_DECODER_STATE */
1929 uint8_t abOpaqueDecoderPart1[0x36 - 0x2c];
1930# endif /* IEM_WITH_OPAQUE_DECODER_STATE */
1931
1932#else /* !IEM_WITH_CODE_TLB */
1933# ifndef IEM_WITH_OPAQUE_DECODER_STATE
1934 /** The size of what has currently been fetched into abOpcode. */
1935 uint8_t cbOpcode; /* 0x08 */
1936 /** The current offset into abOpcode. */
1937 uint8_t offOpcode; /* 0x09 */
1938 /** The offset of the ModR/M byte relative to the start of the instruction. */
1939 uint8_t offModRm; /* 0x0a */
1940
1941 /** The effective segment register (X86_SREG_XXX). */
1942 uint8_t iEffSeg; /* 0x0b */
1943
1944 /** The prefix mask (IEM_OP_PRF_XXX). */
1945 uint32_t fPrefixes; /* 0x0c */
1946 /** The extra REX ModR/M register field bit (REX.R << 3). */
1947 uint8_t uRexReg; /* 0x10 */
1948 /** The extra REX ModR/M r/m field, SIB base and opcode reg bit
1949 * (REX.B << 3). */
1950 uint8_t uRexB; /* 0x11 */
1951 /** The extra REX SIB index field bit (REX.X << 3). */
1952 uint8_t uRexIndex; /* 0x12 */
1953
1954# else /* IEM_WITH_OPAQUE_DECODER_STATE */
1955 uint8_t abOpaqueDecoderPart1[0x13 - 0x08];
1956# endif /* IEM_WITH_OPAQUE_DECODER_STATE */
1957#endif /* !IEM_WITH_CODE_TLB */
1958
1959#ifndef IEM_WITH_OPAQUE_DECODER_STATE
1960 /** The effective operand mode. */
1961 IEMMODE enmEffOpSize; /* 0x36, 0x13 */
1962 /** The default addressing mode. */
1963 IEMMODE enmDefAddrMode; /* 0x37, 0x14 */
1964 /** The effective addressing mode. */
1965 IEMMODE enmEffAddrMode; /* 0x38, 0x15 */
1966 /** The default operand mode. */
1967 IEMMODE enmDefOpSize; /* 0x39, 0x16 */
1968
1969 /** Prefix index (VEX.pp) for two byte and three byte tables. */
1970 uint8_t idxPrefix; /* 0x3a, 0x17 */
1971 /** 3rd VEX/EVEX/XOP register.
1972 * Please use IEM_GET_EFFECTIVE_VVVV to access. */
1973 uint8_t uVex3rdReg; /* 0x3b, 0x18 */
1974 /** The VEX/EVEX/XOP length field. */
1975 uint8_t uVexLength; /* 0x3c, 0x19 */
1976 /** Additional EVEX stuff. */
1977 uint8_t fEvexStuff; /* 0x3d, 0x1a */
1978
1979# ifndef IEM_WITH_CODE_TLB
1980 /** Explicit alignment padding. */
1981 uint8_t abAlignment2a[1]; /* 0x1b */
1982# endif
1983 /** The FPU opcode (FOP). */
1984 uint16_t uFpuOpcode; /* 0x3e, 0x1c */
1985# ifndef IEM_WITH_CODE_TLB
1986 /** Explicit alignment padding. */
1987 uint8_t abAlignment2b[2]; /* 0x1e */
1988# endif
1989
1990 /** The opcode bytes. */
1991 uint8_t abOpcode[15]; /* 0x40, 0x20 */
1992 /** Explicit alignment padding. */
1993# ifdef IEM_WITH_CODE_TLB
1994 //uint8_t abAlignment2c[0x4f - 0x4f]; /* 0x4f */
1995# else
1996 uint8_t abAlignment2c[0x4f - 0x2f]; /* 0x2f */
1997# endif
1998
1999#else /* IEM_WITH_OPAQUE_DECODER_STATE */
2000# ifdef IEM_WITH_CODE_TLB
2001 uint8_t abOpaqueDecoderPart2[0x4f - 0x36];
2002# else
2003 uint8_t abOpaqueDecoderPart2[0x4f - 0x13];
2004# endif
2005#endif /* IEM_WITH_OPAQUE_DECODER_STATE */
2006 /** @} */
2007
2008
2009 /** The number of active guest memory mappings. */
2010 uint8_t cActiveMappings; /* 0x4f, 0x4f */
2011
2012 /** Records for tracking guest memory mappings. */
2013 struct
2014 {
2015 /** The address of the mapped bytes. */
2016 R3R0PTRTYPE(void *) pv;
2017 /** The access flags (IEM_ACCESS_XXX).
2018 * IEM_ACCESS_INVALID if the entry is unused. */
2019 uint32_t fAccess;
2020#if HC_ARCH_BITS == 64
2021 uint32_t u32Alignment4; /**< Alignment padding. */
2022#endif
2023 } aMemMappings[3]; /* 0x50 LB 0x30 */
2024
2025 /** Locking records for the mapped memory. */
2026 union
2027 {
2028 PGMPAGEMAPLOCK Lock;
2029 uint64_t au64Padding[2];
2030 } aMemMappingLocks[3]; /* 0x80 LB 0x30 */
2031
2032 /** Bounce buffer info.
2033 * This runs in parallel to aMemMappings. */
2034 struct
2035 {
2036 /** The physical address of the first byte. */
2037 RTGCPHYS GCPhysFirst;
2038 /** The physical address of the second page. */
2039 RTGCPHYS GCPhysSecond;
2040 /** The number of bytes in the first page. */
2041 uint16_t cbFirst;
2042 /** The number of bytes in the second page. */
2043 uint16_t cbSecond;
2044 /** Whether it's unassigned memory. */
2045 bool fUnassigned;
2046 /** Explicit alignment padding. */
2047 bool afAlignment5[3];
2048 } aMemBbMappings[3]; /* 0xb0 LB 0x48 */
2049
2050 /** The flags of the current exception / interrupt. */
2051 uint32_t fCurXcpt; /* 0xf8 */
2052 /** The current exception / interrupt. */
2053 uint8_t uCurXcpt; /* 0xfc */
2054 /** Exception / interrupt recursion depth. */
2055 int8_t cXcptRecursions; /* 0xfb */
2056
2057 /** The next unused mapping index.
2058 * @todo try find room for this up with cActiveMappings. */
2059 uint8_t iNextMapping; /* 0xfd */
2060 uint8_t abAlignment7[1];
2061
2062 /** Bounce buffer storage.
2063 * This runs in parallel to aMemMappings and aMemBbMappings. */
2064 struct
2065 {
2066 uint8_t ab[512];
2067 } aBounceBuffers[3]; /* 0x100 LB 0x600 */
2068
2069
2070 /** Pointer set jump buffer - ring-3 context. */
2071 R3PTRTYPE(jmp_buf *) pJmpBufR3;
2072 /** Pointer set jump buffer - ring-0 context. */
2073 R0PTRTYPE(jmp_buf *) pJmpBufR0;
2074
2075 /** @todo Should move this near @a fCurXcpt later. */
2076 /** The CR2 for the current exception / interrupt. */
2077 uint64_t uCurXcptCr2;
2078 /** The error code for the current exception / interrupt. */
2079 uint32_t uCurXcptErr;
2080
2081 /** @name Statistics
2082 * @{ */
2083 /** The number of instructions we've executed. */
2084 uint32_t cInstructions;
2085 /** The number of potential exits. */
2086 uint32_t cPotentialExits;
2087 /** The number of bytes data or stack written (mostly for IEMExecOneEx).
2088 * This may contain uncommitted writes. */
2089 uint32_t cbWritten;
2090 /** Counts the VERR_IEM_INSTR_NOT_IMPLEMENTED returns. */
2091 uint32_t cRetInstrNotImplemented;
2092 /** Counts the VERR_IEM_ASPECT_NOT_IMPLEMENTED returns. */
2093 uint32_t cRetAspectNotImplemented;
2094 /** Counts informational statuses returned (other than VINF_SUCCESS). */
2095 uint32_t cRetInfStatuses;
2096 /** Counts other error statuses returned. */
2097 uint32_t cRetErrStatuses;
2098 /** Number of times rcPassUp has been used. */
2099 uint32_t cRetPassUpStatus;
2100 /** Number of times RZ left with instruction commit pending for ring-3. */
2101 uint32_t cPendingCommit;
2102 /** Number of misaligned (host sense) atomic instruction accesses. */
2103 uint32_t cMisalignedAtomics;
2104 /** Number of long jumps. */
2105 uint32_t cLongJumps;
2106 /** @} */
2107
2108 /** @name Target CPU information.
2109 * @{ */
2110#if IEM_CFG_TARGET_CPU == IEMTARGETCPU_DYNAMIC
2111 /** The target CPU. */
2112 uint8_t uTargetCpu;
2113#else
2114 uint8_t bTargetCpuPadding;
2115#endif
2116 /** For selecting assembly works matching the target CPU EFLAGS behaviour, see
2117 * IEMTARGETCPU_EFL_BEHAVIOR_XXX for values, with the 1st entry for when no
2118 * native host support and the 2nd for when there is.
2119 *
2120 * The two values are typically indexed by a g_CpumHostFeatures bit.
2121 *
2122 * This is for instance used for the BSF & BSR instructions where AMD and
2123 * Intel CPUs produce different EFLAGS. */
2124 uint8_t aidxTargetCpuEflFlavour[2];
2125
2126 /** The CPU vendor. */
2127 CPUMCPUVENDOR enmCpuVendor;
2128 /** @} */
2129
2130 /** @name Host CPU information.
2131 * @{ */
2132 /** The CPU vendor. */
2133 CPUMCPUVENDOR enmHostCpuVendor;
2134 /** @} */
2135
2136 /** Counts RDMSR \#GP(0) LogRel(). */
2137 uint8_t cLogRelRdMsr;
2138 /** Counts WRMSR \#GP(0) LogRel(). */
2139 uint8_t cLogRelWrMsr;
2140 /** Alignment padding. */
2141 uint8_t abAlignment9[42];
2142
2143
2144 /** @name Recompiled Exection
2145 * @{ */
2146 /** Pointer to the current translation block.
2147 * This can either be one being executed or one being compiled. */
2148 R3PTRTYPE(PIEMTB) pCurTbR3;
2149#ifdef VBOX_WITH_IEM_NATIVE_RECOMPILER_LONGJMP
2150 /** Frame pointer for the last native TB to execute. */
2151 R3PTRTYPE(void *) pvTbFramePointerR3;
2152#else
2153 R3PTRTYPE(void *) pvUnusedR3;
2154#endif
2155#ifdef IEMNATIVE_WITH_SIMD_FP_NATIVE_EMITTERS
2156 /** The saved host floating point control register (MXCSR on x86, FPCR on arm64)
2157 * needing restore when the TB finished, IEMNATIVE_SIMD_FP_CTRL_REG_NOT_MODIFIED indicates the TB
2158 * didn't modify it so we don't need to restore it. */
2159# ifdef RT_ARCH_AMD64
2160 uint32_t uRegFpCtrl;
2161 /** Temporary copy of MXCSR for stmxcsr/ldmxcsr (so we don't have to fiddle with stack pointers). */
2162 uint32_t uRegMxcsrTmp;
2163# elif defined(RT_ARCH_ARM64)
2164 uint64_t uRegFpCtrl;
2165# else
2166# error "Port me"
2167# endif
2168#else
2169 uint64_t u64Unused;
2170#endif
2171 /** Pointer to the ring-3 TB cache for this EMT. */
2172 R3PTRTYPE(PIEMTBCACHE) pTbCacheR3;
2173 /** Pointer to the ring-3 TB lookup entry.
2174 * This either points to pTbLookupEntryDummyR3 or an actually lookuptable
2175 * entry, thus it can always safely be used w/o NULL checking. */
2176 R3PTRTYPE(PIEMTB *) ppTbLookupEntryR3;
2177#if 0 /* unused */
2178 /** The PC (RIP) at the start of pCurTbR3/pCurTbR0.
2179 * The TBs are based on physical addresses, so this is needed to correleated
2180 * RIP to opcode bytes stored in the TB (AMD-V / VT-x). */
2181 uint64_t uCurTbStartPc;
2182#endif
2183
2184 /** Number of threaded TBs executed. */
2185 uint64_t cTbExecThreaded;
2186 /** Number of native TBs executed. */
2187 uint64_t cTbExecNative;
2188
2189 /** The number of IRQ/FF checks till the next timer poll call. */
2190 uint32_t cIrqChecksTillNextPoll;
2191 /** The virtual sync time at the last timer poll call in milliseconds. */
2192 uint32_t msRecompilerPollNow;
2193 /** The virtual sync time at the last timer poll call in nanoseconds. */
2194 uint64_t nsRecompilerPollNow;
2195 /** The previous cIrqChecksTillNextPoll value. */
2196 uint32_t cIrqChecksTillNextPollPrev;
2197 /** The ideal nanosecond interval between two timer polls.
2198 * @todo make this adaptive? */
2199 uint32_t cNsIdealPollInterval;
2200
2201 /** The current instruction number in a native TB.
2202 * This is set by code that may trigger an unexpected TB exit (throw/longjmp)
2203 * and will be picked up by the TB execution loop. Only used when
2204 * IEMNATIVE_WITH_INSTRUCTION_COUNTING is defined. */
2205 uint8_t idxTbCurInstr;
2206 /** @} */
2207
2208 /** @name Recompilation
2209 * @{ */
2210 /** Whether we need to check the opcode bytes for the current instruction.
2211 * This is set by a previous instruction if it modified memory or similar. */
2212 bool fTbCheckOpcodes;
2213 /** Indicates whether and how we just branched - IEMBRANCHED_F_XXX. */
2214 uint8_t fTbBranched;
2215 /** Set when GCPhysInstrBuf is updated because of a page crossing. */
2216 bool fTbCrossedPage;
2217 /** Whether to end the current TB. */
2218 bool fEndTb;
2219 /** Indicates that the current instruction is an STI. This is set by the
2220 * iemCImpl_sti code and subsequently cleared by the recompiler. */
2221 bool fTbCurInstrIsSti;
2222 /** Spaced reserved for recompiler data / alignment. */
2223 bool afRecompilerStuff1[1];
2224 /** Number of instructions before we need emit an IRQ check call again.
2225 * This helps making sure we don't execute too long w/o checking for
2226 * interrupts and immediately following instructions that may enable
2227 * interrupts (e.g. POPF, IRET, STI). With STI an additional hack is
2228 * required to make sure we check following the next instruction as well, see
2229 * fTbCurInstrIsSti. */
2230 uint8_t cInstrTillIrqCheck;
2231 /** The index of the last CheckIrq call during threaded recompilation. */
2232 uint16_t idxLastCheckIrqCallNo;
2233 /** The size of the IEMTB::pabOpcodes allocation in pThrdCompileTbR3. */
2234 uint16_t cbOpcodesAllocated;
2235 /** The IEMTB::cUsed value when to attempt native recompilation of a TB. */
2236 uint32_t uTbNativeRecompileAtUsedCount;
2237 /** The IEM_CIMPL_F_XXX mask for the current instruction. */
2238 uint32_t fTbCurInstr;
2239 /** The IEM_CIMPL_F_XXX mask for the previous instruction. */
2240 uint32_t fTbPrevInstr;
2241 /** Strict: Tracking skipped EFLAGS calculations. Any bits set here are
2242 * currently not up to date in EFLAGS. */
2243 uint32_t fSkippingEFlags;
2244 /** Spaced reserved for recompiler data / alignment. */
2245 uint32_t u32RecompilerStuff2;
2246#if 0 /* unused */
2247 /** Previous GCPhysInstrBuf value - only valid if fTbCrossedPage is set. */
2248 RTGCPHYS GCPhysInstrBufPrev;
2249#endif
2250
2251 /** Fixed TB used for threaded recompilation.
2252 * This is allocated once with maxed-out sizes and re-used afterwards. */
2253 R3PTRTYPE(PIEMTB) pThrdCompileTbR3;
2254 /** Pointer to the ring-3 TB allocator for this EMT. */
2255 R3PTRTYPE(PIEMTBALLOCATOR) pTbAllocatorR3;
2256 /** Pointer to the ring-3 executable memory allocator for this EMT. */
2257 R3PTRTYPE(struct IEMEXECMEMALLOCATOR *) pExecMemAllocatorR3;
2258 /** Pointer to the native recompiler state for ring-3. */
2259 R3PTRTYPE(struct IEMRECOMPILERSTATE *) pNativeRecompilerStateR3;
2260 /** Dummy entry for ppTbLookupEntryR3. */
2261 R3PTRTYPE(PIEMTB) pTbLookupEntryDummyR3;
2262 /** @} */
2263
2264 /** Dummy TLB entry used for accesses to pages with databreakpoints. */
2265 IEMTLBENTRY DataBreakpointTlbe;
2266
2267 /** Threaded TB statistics: Times TB execution was broken off before reaching the end. */
2268 STAMCOUNTER StatTbThreadedExecBreaks;
2269 /** Statistics: Times BltIn_CheckIrq breaks out of the TB. */
2270 STAMCOUNTER StatCheckIrqBreaks;
2271 /** Statistics: Times BltIn_CheckTimers breaks direct linking TBs. */
2272 STAMCOUNTER StatCheckTimersBreaks;
2273 /** Statistics: Times BltIn_CheckMode breaks out of the TB. */
2274 STAMCOUNTER StatCheckModeBreaks;
2275 /** Threaded TB statistics: Times execution break on call with lookup entries. */
2276 STAMCOUNTER StatTbThreadedExecBreaksWithLookup;
2277 /** Threaded TB statistics: Times execution break on call without lookup entries. */
2278 STAMCOUNTER StatTbThreadedExecBreaksWithoutLookup;
2279 /** Statistics: Times a post jump target check missed and had to find new TB. */
2280 STAMCOUNTER StatCheckBranchMisses;
2281 /** Statistics: Times a jump or page crossing required a TB with CS.LIM checking. */
2282 STAMCOUNTER StatCheckNeedCsLimChecking;
2283 /** Statistics: Times a loop was detected within a TB. */
2284 STAMCOUNTER StatTbLoopInTbDetected;
2285 /** Statistics: Times a loop back to the start of the TB was detected. */
2286 STAMCOUNTER StatTbLoopFullTbDetected;
2287 /** Exec memory allocator statistics: Number of times allocaintg executable memory failed. */
2288 STAMCOUNTER StatNativeExecMemInstrBufAllocFailed;
2289 /** Native TB statistics: Number of fully recompiled TBs. */
2290 STAMCOUNTER StatNativeFullyRecompiledTbs;
2291 /** TB statistics: Number of instructions per TB. */
2292 STAMPROFILE StatTbInstr;
2293 /** TB statistics: Number of TB lookup table entries per TB. */
2294 STAMPROFILE StatTbLookupEntries;
2295 /** Threaded TB statistics: Number of calls per TB. */
2296 STAMPROFILE StatTbThreadedCalls;
2297 /** Native TB statistics: Native code size per TB. */
2298 STAMPROFILE StatTbNativeCode;
2299 /** Native TB statistics: Profiling native recompilation. */
2300 STAMPROFILE StatNativeRecompilation;
2301 /** Native TB statistics: Number of calls per TB that were recompiled properly. */
2302 STAMPROFILE StatNativeCallsRecompiled;
2303 /** Native TB statistics: Number of threaded calls per TB that weren't recompiled. */
2304 STAMPROFILE StatNativeCallsThreaded;
2305 /** Native recompiled execution: TLB hits for data fetches. */
2306 STAMCOUNTER StatNativeTlbHitsForFetch;
2307 /** Native recompiled execution: TLB hits for data stores. */
2308 STAMCOUNTER StatNativeTlbHitsForStore;
2309 /** Native recompiled execution: TLB hits for stack accesses. */
2310 STAMCOUNTER StatNativeTlbHitsForStack;
2311 /** Native recompiled execution: TLB hits for mapped accesses. */
2312 STAMCOUNTER StatNativeTlbHitsForMapped;
2313 /** Native recompiled execution: Code TLB misses for new page. */
2314 STAMCOUNTER StatNativeCodeTlbMissesNewPage;
2315 /** Native recompiled execution: Code TLB hits for new page. */
2316 STAMCOUNTER StatNativeCodeTlbHitsForNewPage;
2317 /** Native recompiled execution: Code TLB misses for new page with offset. */
2318 STAMCOUNTER StatNativeCodeTlbMissesNewPageWithOffset;
2319 /** Native recompiled execution: Code TLB hits for new page with offset. */
2320 STAMCOUNTER StatNativeCodeTlbHitsForNewPageWithOffset;
2321
2322 /** Native recompiler: Number of calls to iemNativeRegAllocFindFree. */
2323 STAMCOUNTER StatNativeRegFindFree;
2324 /** Native recompiler: Number of times iemNativeRegAllocFindFree needed
2325 * to free a variable. */
2326 STAMCOUNTER StatNativeRegFindFreeVar;
2327 /** Native recompiler: Number of times iemNativeRegAllocFindFree did
2328 * not need to free any variables. */
2329 STAMCOUNTER StatNativeRegFindFreeNoVar;
2330 /** Native recompiler: Liveness info freed shadowed guest registers in
2331 * iemNativeRegAllocFindFree. */
2332 STAMCOUNTER StatNativeRegFindFreeLivenessUnshadowed;
2333 /** Native recompiler: Liveness info helped with the allocation in
2334 * iemNativeRegAllocFindFree. */
2335 STAMCOUNTER StatNativeRegFindFreeLivenessHelped;
2336
2337 /** Native recompiler: Number of times status flags calc has been skipped. */
2338 STAMCOUNTER StatNativeEflSkippedArithmetic;
2339 /** Native recompiler: Number of times status flags calc has been skipped. */
2340 STAMCOUNTER StatNativeEflSkippedLogical;
2341
2342 /** Native recompiler: Number of opportunities to skip EFLAGS.CF updating. */
2343 STAMCOUNTER StatNativeLivenessEflCfSkippable;
2344 /** Native recompiler: Number of opportunities to skip EFLAGS.PF updating. */
2345 STAMCOUNTER StatNativeLivenessEflPfSkippable;
2346 /** Native recompiler: Number of opportunities to skip EFLAGS.AF updating. */
2347 STAMCOUNTER StatNativeLivenessEflAfSkippable;
2348 /** Native recompiler: Number of opportunities to skip EFLAGS.ZF updating. */
2349 STAMCOUNTER StatNativeLivenessEflZfSkippable;
2350 /** Native recompiler: Number of opportunities to skip EFLAGS.SF updating. */
2351 STAMCOUNTER StatNativeLivenessEflSfSkippable;
2352 /** Native recompiler: Number of opportunities to skip EFLAGS.OF updating. */
2353 STAMCOUNTER StatNativeLivenessEflOfSkippable;
2354 /** Native recompiler: Number of required EFLAGS.CF updates. */
2355 STAMCOUNTER StatNativeLivenessEflCfRequired;
2356 /** Native recompiler: Number of required EFLAGS.PF updates. */
2357 STAMCOUNTER StatNativeLivenessEflPfRequired;
2358 /** Native recompiler: Number of required EFLAGS.AF updates. */
2359 STAMCOUNTER StatNativeLivenessEflAfRequired;
2360 /** Native recompiler: Number of required EFLAGS.ZF updates. */
2361 STAMCOUNTER StatNativeLivenessEflZfRequired;
2362 /** Native recompiler: Number of required EFLAGS.SF updates. */
2363 STAMCOUNTER StatNativeLivenessEflSfRequired;
2364 /** Native recompiler: Number of required EFLAGS.OF updates. */
2365 STAMCOUNTER StatNativeLivenessEflOfRequired;
2366 /** Native recompiler: Number of potentially delayable EFLAGS.CF updates. */
2367 STAMCOUNTER StatNativeLivenessEflCfDelayable;
2368 /** Native recompiler: Number of potentially delayable EFLAGS.PF updates. */
2369 STAMCOUNTER StatNativeLivenessEflPfDelayable;
2370 /** Native recompiler: Number of potentially delayable EFLAGS.AF updates. */
2371 STAMCOUNTER StatNativeLivenessEflAfDelayable;
2372 /** Native recompiler: Number of potentially delayable EFLAGS.ZF updates. */
2373 STAMCOUNTER StatNativeLivenessEflZfDelayable;
2374 /** Native recompiler: Number of potentially delayable EFLAGS.SF updates. */
2375 STAMCOUNTER StatNativeLivenessEflSfDelayable;
2376 /** Native recompiler: Number of potentially delayable EFLAGS.OF updates. */
2377 STAMCOUNTER StatNativeLivenessEflOfDelayable;
2378
2379 /** Native recompiler: Number of potential PC updates in total. */
2380 STAMCOUNTER StatNativePcUpdateTotal;
2381 /** Native recompiler: Number of PC updates which could be delayed. */
2382 STAMCOUNTER StatNativePcUpdateDelayed;
2383
2384//#ifdef IEMNATIVE_WITH_SIMD_REG_ALLOCATOR
2385 /** Native recompiler: Number of calls to iemNativeSimdRegAllocFindFree. */
2386 STAMCOUNTER StatNativeSimdRegFindFree;
2387 /** Native recompiler: Number of times iemNativeSimdRegAllocFindFree needed
2388 * to free a variable. */
2389 STAMCOUNTER StatNativeSimdRegFindFreeVar;
2390 /** Native recompiler: Number of times iemNativeSimdRegAllocFindFree did
2391 * not need to free any variables. */
2392 STAMCOUNTER StatNativeSimdRegFindFreeNoVar;
2393 /** Native recompiler: Liveness info freed shadowed guest registers in
2394 * iemNativeSimdRegAllocFindFree. */
2395 STAMCOUNTER StatNativeSimdRegFindFreeLivenessUnshadowed;
2396 /** Native recompiler: Liveness info helped with the allocation in
2397 * iemNativeSimdRegAllocFindFree. */
2398 STAMCOUNTER StatNativeSimdRegFindFreeLivenessHelped;
2399
2400 /** Native recompiler: Number of potential IEM_MC_MAYBE_RAISE_DEVICE_NOT_AVAILABLE() checks. */
2401 STAMCOUNTER StatNativeMaybeDeviceNotAvailXcptCheckPotential;
2402 /** Native recompiler: Number of potential IEM_MC_MAYBE_RAISE_WAIT_DEVICE_NOT_AVAILABLE() checks. */
2403 STAMCOUNTER StatNativeMaybeWaitDeviceNotAvailXcptCheckPotential;
2404 /** Native recompiler: Number of potential IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT() checks. */
2405 STAMCOUNTER StatNativeMaybeSseXcptCheckPotential;
2406 /** Native recompiler: Number of potential IEM_MC_MAYBE_RAISE_AVX_RELATED_XCPT() checks. */
2407 STAMCOUNTER StatNativeMaybeAvxXcptCheckPotential;
2408
2409 /** Native recompiler: Number of IEM_MC_MAYBE_RAISE_DEVICE_NOT_AVAILABLE() checks omitted. */
2410 STAMCOUNTER StatNativeMaybeDeviceNotAvailXcptCheckOmitted;
2411 /** Native recompiler: Number of IEM_MC_MAYBE_RAISE_WAIT_DEVICE_NOT_AVAILABLE() checks omitted. */
2412 STAMCOUNTER StatNativeMaybeWaitDeviceNotAvailXcptCheckOmitted;
2413 /** Native recompiler: Number of IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT() checks omitted. */
2414 STAMCOUNTER StatNativeMaybeSseXcptCheckOmitted;
2415 /** Native recompiler: Number of IEM_MC_MAYBE_RAISE_AVX_RELATED_XCPT() checks omitted. */
2416 STAMCOUNTER StatNativeMaybeAvxXcptCheckOmitted;
2417//#endif
2418
2419 /** Native recompiler: The TB finished executing completely without jumping to a an exit label.
2420 * Not availabe in release builds. */
2421 STAMCOUNTER StatNativeTbFinished;
2422 /** Native recompiler: The TB finished executing jumping to the ReturnBreak label. */
2423 STAMCOUNTER StatNativeTbExitReturnBreak;
2424 /** Native recompiler: The TB finished executing jumping to the ReturnBreakFF label. */
2425 STAMCOUNTER StatNativeTbExitReturnBreakFF;
2426 /** Native recompiler: The TB finished executing jumping to the ReturnWithFlags label. */
2427 STAMCOUNTER StatNativeTbExitReturnWithFlags;
2428 /** Native recompiler: The TB finished executing with other non-zero status. */
2429 STAMCOUNTER StatNativeTbExitReturnOtherStatus;
2430 /** Native recompiler: The TB finished executing via throw / long jump. */
2431 STAMCOUNTER StatNativeTbExitLongJump;
2432 /** Native recompiler: The TB finished executing jumping to the ReturnBreak
2433 * label, but directly jumped to the next TB, scenario \#1 w/o IRQ checks. */
2434 STAMCOUNTER StatNativeTbExitDirectLinking1NoIrq;
2435 /** Native recompiler: The TB finished executing jumping to the ReturnBreak
2436 * label, but directly jumped to the next TB, scenario \#1 with IRQ checks. */
2437 STAMCOUNTER StatNativeTbExitDirectLinking1Irq;
2438 /** Native recompiler: The TB finished executing jumping to the ReturnBreak
2439 * label, but directly jumped to the next TB, scenario \#1 w/o IRQ checks. */
2440 STAMCOUNTER StatNativeTbExitDirectLinking2NoIrq;
2441 /** Native recompiler: The TB finished executing jumping to the ReturnBreak
2442 * label, but directly jumped to the next TB, scenario \#2 with IRQ checks. */
2443 STAMCOUNTER StatNativeTbExitDirectLinking2Irq;
2444
2445 /** Native recompiler: The TB finished executing jumping to the RaiseDe label. */
2446 STAMCOUNTER StatNativeTbExitRaiseDe;
2447 /** Native recompiler: The TB finished executing jumping to the RaiseUd label. */
2448 STAMCOUNTER StatNativeTbExitRaiseUd;
2449 /** Native recompiler: The TB finished executing jumping to the RaiseSseRelated label. */
2450 STAMCOUNTER StatNativeTbExitRaiseSseRelated;
2451 /** Native recompiler: The TB finished executing jumping to the RaiseAvxRelated label. */
2452 STAMCOUNTER StatNativeTbExitRaiseAvxRelated;
2453 /** Native recompiler: The TB finished executing jumping to the RaiseSseAvxFpRelated label. */
2454 STAMCOUNTER StatNativeTbExitRaiseSseAvxFpRelated;
2455 /** Native recompiler: The TB finished executing jumping to the RaiseNm label. */
2456 STAMCOUNTER StatNativeTbExitRaiseNm;
2457 /** Native recompiler: The TB finished executing jumping to the RaiseGp0 label. */
2458 STAMCOUNTER StatNativeTbExitRaiseGp0;
2459 /** Native recompiler: The TB finished executing jumping to the RaiseMf label. */
2460 STAMCOUNTER StatNativeTbExitRaiseMf;
2461 /** Native recompiler: The TB finished executing jumping to the RaiseXf label. */
2462 STAMCOUNTER StatNativeTbExitRaiseXf;
2463 /** Native recompiler: The TB finished executing jumping to the ObsoleteTb label. */
2464 STAMCOUNTER StatNativeTbExitObsoleteTb;
2465
2466 /** Native recompiler: Number of full TB loops (jumps from end to start). */
2467 STAMCOUNTER StatNativeTbExitLoopFullTb;
2468
2469 /** Native recompiler: Failure situations with direct linking scenario \#1.
2470 * Counter with StatNativeTbExitReturnBreak. Not in release builds.
2471 * @{ */
2472 STAMCOUNTER StatNativeTbExitDirectLinking1NoTb;
2473 STAMCOUNTER StatNativeTbExitDirectLinking1MismatchGCPhysPc;
2474 STAMCOUNTER StatNativeTbExitDirectLinking1MismatchFlags;
2475 STAMCOUNTER StatNativeTbExitDirectLinking1PendingIrq;
2476 /** @} */
2477
2478 /** Native recompiler: Failure situations with direct linking scenario \#2.
2479 * Counter with StatNativeTbExitReturnBreak. Not in release builds.
2480 * @{ */
2481 STAMCOUNTER StatNativeTbExitDirectLinking2NoTb;
2482 STAMCOUNTER StatNativeTbExitDirectLinking2MismatchGCPhysPc;
2483 STAMCOUNTER StatNativeTbExitDirectLinking2MismatchFlags;
2484 STAMCOUNTER StatNativeTbExitDirectLinking2PendingIrq;
2485 /** @} */
2486
2487 /** iemMemMap and iemMemMapJmp statistics.
2488 * @{ */
2489 STAMCOUNTER StatMemMapJmp;
2490 STAMCOUNTER StatMemMapNoJmp;
2491 STAMCOUNTER StatMemBounceBufferCrossPage;
2492 STAMCOUNTER StatMemBounceBufferMapPhys;
2493 /** @} */
2494
2495#ifdef IEM_WITH_TLB_TRACE
2496 uint64_t au64Padding[6];
2497#else
2498 //uint64_t au64Padding[1];
2499#endif
2500
2501#ifdef IEM_WITH_TLB_TRACE
2502 /** The end (next) trace entry. */
2503 uint32_t idxTlbTraceEntry;
2504 /** Number of trace entries allocated expressed as a power of two. */
2505 uint32_t cTlbTraceEntriesShift;
2506 /** The trace entries. */
2507 PIEMTLBTRACEENTRY paTlbTraceEntries;
2508#endif
2509
2510 /** Data TLB.
2511 * @remarks Must be 64-byte aligned. */
2512 IEMTLB DataTlb;
2513 /** Instruction TLB.
2514 * @remarks Must be 64-byte aligned. */
2515 IEMTLB CodeTlb;
2516
2517 /** Exception statistics. */
2518 STAMCOUNTER aStatXcpts[32];
2519 /** Interrupt statistics. */
2520 uint32_t aStatInts[256];
2521
2522#if defined(VBOX_WITH_STATISTICS) && !defined(DOXYGEN_RUNNING) && !defined(IEM_WITHOUT_INSTRUCTION_STATS)
2523 /** Instruction statistics for ring-0/raw-mode. */
2524 IEMINSTRSTATS StatsRZ;
2525 /** Instruction statistics for ring-3. */
2526 IEMINSTRSTATS StatsR3;
2527# ifdef VBOX_WITH_IEM_RECOMPILER
2528 /** Statistics per threaded function call.
2529 * Updated by both the threaded and native recompilers. */
2530 uint32_t acThreadedFuncStats[0x6000 /*24576*/];
2531# endif
2532#endif
2533} IEMCPU;
2534AssertCompileMemberOffset(IEMCPU, cActiveMappings, 0x4f);
2535AssertCompileMemberAlignment(IEMCPU, aMemMappings, 16);
2536AssertCompileMemberAlignment(IEMCPU, aMemMappingLocks, 16);
2537AssertCompileMemberAlignment(IEMCPU, aBounceBuffers, 64);
2538AssertCompileMemberAlignment(IEMCPU, pCurTbR3, 64);
2539AssertCompileMemberAlignment(IEMCPU, DataTlb, 64);
2540AssertCompileMemberAlignment(IEMCPU, CodeTlb, 64);
2541
2542/** Pointer to the per-CPU IEM state. */
2543typedef IEMCPU *PIEMCPU;
2544/** Pointer to the const per-CPU IEM state. */
2545typedef IEMCPU const *PCIEMCPU;
2546
2547/** @def IEMNATIVE_SIMD_FP_CTRL_REG_NOT_MODIFIED
2548 * Value indicating the TB didn't modified the floating point control register.
2549 * @note Neither FPCR nor MXCSR accept this as a valid value (MXCSR is not fully populated,
2550 * FPCR has the upper 32-bit reserved), so this is safe. */
2551#if defined(IEMNATIVE_WITH_SIMD_FP_NATIVE_EMITTERS) || defined(DOXYGEN_RUNNING)
2552# ifdef RT_ARCH_AMD64
2553# define IEMNATIVE_SIMD_FP_CTRL_REG_NOT_MODIFIED UINT32_MAX
2554# elif defined(RT_ARCH_ARM64)
2555# define IEMNATIVE_SIMD_FP_CTRL_REG_NOT_MODIFIED UINT64_MAX
2556# else
2557# error "Port me"
2558# endif
2559#endif
2560
2561/** @def IEM_GET_CTX
2562 * Gets the guest CPU context for the calling EMT.
2563 * @returns PCPUMCTX
2564 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
2565 */
2566#define IEM_GET_CTX(a_pVCpu) (&(a_pVCpu)->cpum.GstCtx)
2567
2568/** @def IEM_CTX_ASSERT
2569 * Asserts that the @a a_fExtrnMbz is present in the CPU context.
2570 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
2571 * @param a_fExtrnMbz The mask of CPUMCTX_EXTRN_XXX flags that must be zero.
2572 */
2573#define IEM_CTX_ASSERT(a_pVCpu, a_fExtrnMbz) \
2574 AssertMsg(!((a_pVCpu)->cpum.GstCtx.fExtrn & (a_fExtrnMbz)), \
2575 ("fExtrn=%#RX64 & fExtrnMbz=%#RX64 -> %#RX64\n", \
2576 (a_pVCpu)->cpum.GstCtx.fExtrn, (a_fExtrnMbz), (a_pVCpu)->cpum.GstCtx.fExtrn & (a_fExtrnMbz) ))
2577
2578/** @def IEM_CTX_IMPORT_RET
2579 * Makes sure the CPU context bits given by @a a_fExtrnImport are imported.
2580 *
2581 * Will call the keep to import the bits as needed.
2582 *
2583 * Returns on import failure.
2584 *
2585 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
2586 * @param a_fExtrnImport The mask of CPUMCTX_EXTRN_XXX flags to import.
2587 */
2588#define IEM_CTX_IMPORT_RET(a_pVCpu, a_fExtrnImport) \
2589 do { \
2590 if (!((a_pVCpu)->cpum.GstCtx.fExtrn & (a_fExtrnImport))) \
2591 { /* likely */ } \
2592 else \
2593 { \
2594 int rcCtxImport = CPUMImportGuestStateOnDemand(a_pVCpu, a_fExtrnImport); \
2595 AssertRCReturn(rcCtxImport, rcCtxImport); \
2596 } \
2597 } while (0)
2598
2599/** @def IEM_CTX_IMPORT_NORET
2600 * Makes sure the CPU context bits given by @a a_fExtrnImport are imported.
2601 *
2602 * Will call the keep to import the bits as needed.
2603 *
2604 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
2605 * @param a_fExtrnImport The mask of CPUMCTX_EXTRN_XXX flags to import.
2606 */
2607#define IEM_CTX_IMPORT_NORET(a_pVCpu, a_fExtrnImport) \
2608 do { \
2609 if (!((a_pVCpu)->cpum.GstCtx.fExtrn & (a_fExtrnImport))) \
2610 { /* likely */ } \
2611 else \
2612 { \
2613 int rcCtxImport = CPUMImportGuestStateOnDemand(a_pVCpu, a_fExtrnImport); \
2614 AssertLogRelRC(rcCtxImport); \
2615 } \
2616 } while (0)
2617
2618/** @def IEM_CTX_IMPORT_JMP
2619 * Makes sure the CPU context bits given by @a a_fExtrnImport are imported.
2620 *
2621 * Will call the keep to import the bits as needed.
2622 *
2623 * Jumps on import failure.
2624 *
2625 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
2626 * @param a_fExtrnImport The mask of CPUMCTX_EXTRN_XXX flags to import.
2627 */
2628#define IEM_CTX_IMPORT_JMP(a_pVCpu, a_fExtrnImport) \
2629 do { \
2630 if (!((a_pVCpu)->cpum.GstCtx.fExtrn & (a_fExtrnImport))) \
2631 { /* likely */ } \
2632 else \
2633 { \
2634 int rcCtxImport = CPUMImportGuestStateOnDemand(a_pVCpu, a_fExtrnImport); \
2635 AssertRCStmt(rcCtxImport, IEM_DO_LONGJMP(pVCpu, rcCtxImport)); \
2636 } \
2637 } while (0)
2638
2639
2640
2641/** @def IEM_GET_TARGET_CPU
2642 * Gets the current IEMTARGETCPU value.
2643 * @returns IEMTARGETCPU value.
2644 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
2645 */
2646#if IEM_CFG_TARGET_CPU != IEMTARGETCPU_DYNAMIC
2647# define IEM_GET_TARGET_CPU(a_pVCpu) (IEM_CFG_TARGET_CPU)
2648#else
2649# define IEM_GET_TARGET_CPU(a_pVCpu) ((a_pVCpu)->iem.s.uTargetCpu)
2650#endif
2651
2652/** @def IEM_GET_INSTR_LEN
2653 * Gets the instruction length. */
2654#ifdef IEM_WITH_CODE_TLB
2655# define IEM_GET_INSTR_LEN(a_pVCpu) ((a_pVCpu)->iem.s.offInstrNextByte - (uint32_t)(int32_t)(a_pVCpu)->iem.s.offCurInstrStart)
2656#else
2657# define IEM_GET_INSTR_LEN(a_pVCpu) ((a_pVCpu)->iem.s.offOpcode)
2658#endif
2659
2660/** @def IEM_TRY_SETJMP
2661 * Wrapper around setjmp / try, hiding all the ugly differences.
2662 *
2663 * @note Use with extreme care as this is a fragile macro.
2664 * @param a_pVCpu The cross context virtual CPU structure of the calling EMT.
2665 * @param a_rcTarget The variable that should receive the status code in case
2666 * of a longjmp/throw.
2667 */
2668/** @def IEM_TRY_SETJMP_AGAIN
2669 * For when setjmp / try is used again in the same variable scope as a previous
2670 * IEM_TRY_SETJMP invocation.
2671 */
2672/** @def IEM_CATCH_LONGJMP_BEGIN
2673 * Start wrapper for catch / setjmp-else.
2674 *
2675 * This will set up a scope.
2676 *
2677 * @note Use with extreme care as this is a fragile macro.
2678 * @param a_pVCpu The cross context virtual CPU structure of the calling EMT.
2679 * @param a_rcTarget The variable that should receive the status code in case
2680 * of a longjmp/throw.
2681 */
2682/** @def IEM_CATCH_LONGJMP_END
2683 * End wrapper for catch / setjmp-else.
2684 *
2685 * This will close the scope set up by IEM_CATCH_LONGJMP_BEGIN and clean up the
2686 * state.
2687 *
2688 * @note Use with extreme care as this is a fragile macro.
2689 * @param a_pVCpu The cross context virtual CPU structure of the calling EMT.
2690 */
2691#if defined(IEM_WITH_SETJMP) || defined(DOXYGEN_RUNNING)
2692# ifdef IEM_WITH_THROW_CATCH
2693# define IEM_TRY_SETJMP(a_pVCpu, a_rcTarget) \
2694 a_rcTarget = VINF_SUCCESS; \
2695 try
2696# define IEM_TRY_SETJMP_AGAIN(a_pVCpu, a_rcTarget) \
2697 IEM_TRY_SETJMP(a_pVCpu, a_rcTarget)
2698# define IEM_CATCH_LONGJMP_BEGIN(a_pVCpu, a_rcTarget) \
2699 catch (int rcThrown) \
2700 { \
2701 a_rcTarget = rcThrown
2702# define IEM_CATCH_LONGJMP_END(a_pVCpu) \
2703 } \
2704 ((void)0)
2705# else /* !IEM_WITH_THROW_CATCH */
2706# define IEM_TRY_SETJMP(a_pVCpu, a_rcTarget) \
2707 jmp_buf JmpBuf; \
2708 jmp_buf * volatile pSavedJmpBuf = (a_pVCpu)->iem.s.CTX_SUFF(pJmpBuf); \
2709 (a_pVCpu)->iem.s.CTX_SUFF(pJmpBuf) = &JmpBuf; \
2710 if ((rcStrict = setjmp(JmpBuf)) == 0)
2711# define IEM_TRY_SETJMP_AGAIN(a_pVCpu, a_rcTarget) \
2712 pSavedJmpBuf = (a_pVCpu)->iem.s.CTX_SUFF(pJmpBuf); \
2713 (a_pVCpu)->iem.s.CTX_SUFF(pJmpBuf) = &JmpBuf; \
2714 if ((rcStrict = setjmp(JmpBuf)) == 0)
2715# define IEM_CATCH_LONGJMP_BEGIN(a_pVCpu, a_rcTarget) \
2716 else \
2717 { \
2718 ((void)0)
2719# define IEM_CATCH_LONGJMP_END(a_pVCpu) \
2720 } \
2721 (a_pVCpu)->iem.s.CTX_SUFF(pJmpBuf) = pSavedJmpBuf
2722# endif /* !IEM_WITH_THROW_CATCH */
2723#endif /* IEM_WITH_SETJMP */
2724
2725
2726/**
2727 * Shared per-VM IEM data.
2728 */
2729typedef struct IEM
2730{
2731 /** The VMX APIC-access page handler type. */
2732 PGMPHYSHANDLERTYPE hVmxApicAccessPage;
2733#ifndef VBOX_WITHOUT_CPUID_HOST_CALL
2734 /** Set if the CPUID host call functionality is enabled. */
2735 bool fCpuIdHostCall;
2736#endif
2737} IEM;
2738
2739
2740
2741/** @name IEM_ACCESS_XXX - Access details.
2742 * @{ */
2743#define IEM_ACCESS_INVALID UINT32_C(0x000000ff)
2744#define IEM_ACCESS_TYPE_READ UINT32_C(0x00000001)
2745#define IEM_ACCESS_TYPE_WRITE UINT32_C(0x00000002)
2746#define IEM_ACCESS_TYPE_EXEC UINT32_C(0x00000004)
2747#define IEM_ACCESS_TYPE_MASK UINT32_C(0x00000007)
2748#define IEM_ACCESS_WHAT_CODE UINT32_C(0x00000010)
2749#define IEM_ACCESS_WHAT_DATA UINT32_C(0x00000020)
2750#define IEM_ACCESS_WHAT_STACK UINT32_C(0x00000030)
2751#define IEM_ACCESS_WHAT_SYS UINT32_C(0x00000040)
2752#define IEM_ACCESS_WHAT_MASK UINT32_C(0x00000070)
2753/** The writes are partial, so if initialize the bounce buffer with the
2754 * orignal RAM content. */
2755#define IEM_ACCESS_PARTIAL_WRITE UINT32_C(0x00000100)
2756/** Used in aMemMappings to indicate that the entry is bounce buffered. */
2757#define IEM_ACCESS_BOUNCE_BUFFERED UINT32_C(0x00000200)
2758/** Bounce buffer with ring-3 write pending, first page. */
2759#define IEM_ACCESS_PENDING_R3_WRITE_1ST UINT32_C(0x00000400)
2760/** Bounce buffer with ring-3 write pending, second page. */
2761#define IEM_ACCESS_PENDING_R3_WRITE_2ND UINT32_C(0x00000800)
2762/** Not locked, accessed via the TLB. */
2763#define IEM_ACCESS_NOT_LOCKED UINT32_C(0x00001000)
2764/** Atomic access.
2765 * This enables special alignment checks and the VINF_EM_EMULATE_SPLIT_LOCK
2766 * fallback for misaligned stuff. See @bugref{10547}. */
2767#define IEM_ACCESS_ATOMIC UINT32_C(0x00002000)
2768/** Valid bit mask. */
2769#define IEM_ACCESS_VALID_MASK UINT32_C(0x00003fff)
2770/** Shift count for the TLB flags (upper word). */
2771#define IEM_ACCESS_SHIFT_TLB_FLAGS 16
2772
2773/** Atomic read+write data alias. */
2774#define IEM_ACCESS_DATA_ATOMIC (IEM_ACCESS_TYPE_READ | IEM_ACCESS_TYPE_WRITE | IEM_ACCESS_WHAT_DATA | IEM_ACCESS_ATOMIC)
2775/** Read+write data alias. */
2776#define IEM_ACCESS_DATA_RW (IEM_ACCESS_TYPE_READ | IEM_ACCESS_TYPE_WRITE | IEM_ACCESS_WHAT_DATA)
2777/** Write data alias. */
2778#define IEM_ACCESS_DATA_W (IEM_ACCESS_TYPE_WRITE | IEM_ACCESS_WHAT_DATA)
2779/** Read data alias. */
2780#define IEM_ACCESS_DATA_R (IEM_ACCESS_TYPE_READ | IEM_ACCESS_WHAT_DATA)
2781/** Instruction fetch alias. */
2782#define IEM_ACCESS_INSTRUCTION (IEM_ACCESS_TYPE_EXEC | IEM_ACCESS_WHAT_CODE)
2783/** Stack write alias. */
2784#define IEM_ACCESS_STACK_W (IEM_ACCESS_TYPE_WRITE | IEM_ACCESS_WHAT_STACK)
2785/** Stack read alias. */
2786#define IEM_ACCESS_STACK_R (IEM_ACCESS_TYPE_READ | IEM_ACCESS_WHAT_STACK)
2787/** Stack read+write alias. */
2788#define IEM_ACCESS_STACK_RW (IEM_ACCESS_TYPE_READ | IEM_ACCESS_TYPE_WRITE | IEM_ACCESS_WHAT_STACK)
2789/** Read system table alias. */
2790#define IEM_ACCESS_SYS_R (IEM_ACCESS_TYPE_READ | IEM_ACCESS_WHAT_SYS)
2791/** Read+write system table alias. */
2792#define IEM_ACCESS_SYS_RW (IEM_ACCESS_TYPE_READ | IEM_ACCESS_TYPE_WRITE | IEM_ACCESS_WHAT_SYS)
2793/** @} */
2794
2795/** @name Prefix constants (IEMCPU::fPrefixes)
2796 * @{ */
2797#define IEM_OP_PRF_SEG_CS RT_BIT_32(0) /**< CS segment prefix (0x2e). */
2798#define IEM_OP_PRF_SEG_SS RT_BIT_32(1) /**< SS segment prefix (0x36). */
2799#define IEM_OP_PRF_SEG_DS RT_BIT_32(2) /**< DS segment prefix (0x3e). */
2800#define IEM_OP_PRF_SEG_ES RT_BIT_32(3) /**< ES segment prefix (0x26). */
2801#define IEM_OP_PRF_SEG_FS RT_BIT_32(4) /**< FS segment prefix (0x64). */
2802#define IEM_OP_PRF_SEG_GS RT_BIT_32(5) /**< GS segment prefix (0x65). */
2803#define IEM_OP_PRF_SEG_MASK UINT32_C(0x3f)
2804
2805#define IEM_OP_PRF_SIZE_OP RT_BIT_32(8) /**< Operand size prefix (0x66). */
2806#define IEM_OP_PRF_SIZE_REX_W RT_BIT_32(9) /**< REX.W prefix (0x48-0x4f). */
2807#define IEM_OP_PRF_SIZE_ADDR RT_BIT_32(10) /**< Address size prefix (0x67). */
2808
2809#define IEM_OP_PRF_LOCK RT_BIT_32(16) /**< Lock prefix (0xf0). */
2810#define IEM_OP_PRF_REPNZ RT_BIT_32(17) /**< Repeat-not-zero prefix (0xf2). */
2811#define IEM_OP_PRF_REPZ RT_BIT_32(18) /**< Repeat-if-zero prefix (0xf3). */
2812
2813#define IEM_OP_PRF_REX RT_BIT_32(24) /**< Any REX prefix (0x40-0x4f). */
2814#define IEM_OP_PRF_REX_B RT_BIT_32(25) /**< REX.B prefix (0x41,0x43,0x45,0x47,0x49,0x4b,0x4d,0x4f). */
2815#define IEM_OP_PRF_REX_X RT_BIT_32(26) /**< REX.X prefix (0x42,0x43,0x46,0x47,0x4a,0x4b,0x4e,0x4f). */
2816#define IEM_OP_PRF_REX_R RT_BIT_32(27) /**< REX.R prefix (0x44,0x45,0x46,0x47,0x4c,0x4d,0x4e,0x4f). */
2817/** Mask with all the REX prefix flags.
2818 * This is generally for use when needing to undo the REX prefixes when they
2819 * are followed legacy prefixes and therefore does not immediately preceed
2820 * the first opcode byte.
2821 * For testing whether any REX prefix is present, use IEM_OP_PRF_REX instead. */
2822#define IEM_OP_PRF_REX_MASK (IEM_OP_PRF_REX | IEM_OP_PRF_REX_R | IEM_OP_PRF_REX_B | IEM_OP_PRF_REX_X | IEM_OP_PRF_SIZE_REX_W )
2823
2824#define IEM_OP_PRF_VEX RT_BIT_32(28) /**< Indiciates VEX prefix. */
2825#define IEM_OP_PRF_EVEX RT_BIT_32(29) /**< Indiciates EVEX prefix. */
2826#define IEM_OP_PRF_XOP RT_BIT_32(30) /**< Indiciates XOP prefix. */
2827/** @} */
2828
2829/** @name IEMOPFORM_XXX - Opcode forms
2830 * @note These are ORed together with IEMOPHINT_XXX.
2831 * @{ */
2832/** ModR/M: reg, r/m */
2833#define IEMOPFORM_RM 0
2834/** ModR/M: reg, r/m (register) */
2835#define IEMOPFORM_RM_REG (IEMOPFORM_RM | IEMOPFORM_MOD3)
2836/** ModR/M: reg, r/m (memory) */
2837#define IEMOPFORM_RM_MEM (IEMOPFORM_RM | IEMOPFORM_NOT_MOD3)
2838/** ModR/M: reg, r/m, imm */
2839#define IEMOPFORM_RMI 1
2840/** ModR/M: reg, r/m (register), imm */
2841#define IEMOPFORM_RMI_REG (IEMOPFORM_RMI | IEMOPFORM_MOD3)
2842/** ModR/M: reg, r/m (memory), imm */
2843#define IEMOPFORM_RMI_MEM (IEMOPFORM_RMI | IEMOPFORM_NOT_MOD3)
2844/** ModR/M: reg, r/m, xmm0 */
2845#define IEMOPFORM_RM0 2
2846/** ModR/M: reg, r/m (register), xmm0 */
2847#define IEMOPFORM_RM0_REG (IEMOPFORM_RM0 | IEMOPFORM_MOD3)
2848/** ModR/M: reg, r/m (memory), xmm0 */
2849#define IEMOPFORM_RM0_MEM (IEMOPFORM_RM0 | IEMOPFORM_NOT_MOD3)
2850/** ModR/M: r/m, reg */
2851#define IEMOPFORM_MR 3
2852/** ModR/M: r/m (register), reg */
2853#define IEMOPFORM_MR_REG (IEMOPFORM_MR | IEMOPFORM_MOD3)
2854/** ModR/M: r/m (memory), reg */
2855#define IEMOPFORM_MR_MEM (IEMOPFORM_MR | IEMOPFORM_NOT_MOD3)
2856/** ModR/M: r/m, reg, imm */
2857#define IEMOPFORM_MRI 4
2858/** ModR/M: r/m (register), reg, imm */
2859#define IEMOPFORM_MRI_REG (IEMOPFORM_MRI | IEMOPFORM_MOD3)
2860/** ModR/M: r/m (memory), reg, imm */
2861#define IEMOPFORM_MRI_MEM (IEMOPFORM_MRI | IEMOPFORM_NOT_MOD3)
2862/** ModR/M: r/m only */
2863#define IEMOPFORM_M 5
2864/** ModR/M: r/m only (register). */
2865#define IEMOPFORM_M_REG (IEMOPFORM_M | IEMOPFORM_MOD3)
2866/** ModR/M: r/m only (memory). */
2867#define IEMOPFORM_M_MEM (IEMOPFORM_M | IEMOPFORM_NOT_MOD3)
2868/** ModR/M: r/m, imm */
2869#define IEMOPFORM_MI 6
2870/** ModR/M: r/m (register), imm */
2871#define IEMOPFORM_MI_REG (IEMOPFORM_MI | IEMOPFORM_MOD3)
2872/** ModR/M: r/m (memory), imm */
2873#define IEMOPFORM_MI_MEM (IEMOPFORM_MI | IEMOPFORM_NOT_MOD3)
2874/** ModR/M: r/m, 1 (shift and rotate instructions) */
2875#define IEMOPFORM_M1 7
2876/** ModR/M: r/m (register), 1. */
2877#define IEMOPFORM_M1_REG (IEMOPFORM_M1 | IEMOPFORM_MOD3)
2878/** ModR/M: r/m (memory), 1. */
2879#define IEMOPFORM_M1_MEM (IEMOPFORM_M1 | IEMOPFORM_NOT_MOD3)
2880/** ModR/M: r/m, CL (shift and rotate instructions)
2881 * @todo This should just've been a generic fixed register. But the python
2882 * code doesn't needs more convincing. */
2883#define IEMOPFORM_M_CL 8
2884/** ModR/M: r/m (register), CL. */
2885#define IEMOPFORM_M_CL_REG (IEMOPFORM_M_CL | IEMOPFORM_MOD3)
2886/** ModR/M: r/m (memory), CL. */
2887#define IEMOPFORM_M_CL_MEM (IEMOPFORM_M_CL | IEMOPFORM_NOT_MOD3)
2888/** ModR/M: reg only */
2889#define IEMOPFORM_R 9
2890
2891/** VEX+ModR/M: reg, r/m */
2892#define IEMOPFORM_VEX_RM 16
2893/** VEX+ModR/M: reg, r/m (register) */
2894#define IEMOPFORM_VEX_RM_REG (IEMOPFORM_VEX_RM | IEMOPFORM_MOD3)
2895/** VEX+ModR/M: reg, r/m (memory) */
2896#define IEMOPFORM_VEX_RM_MEM (IEMOPFORM_VEX_RM | IEMOPFORM_NOT_MOD3)
2897/** VEX+ModR/M: r/m, reg */
2898#define IEMOPFORM_VEX_MR 17
2899/** VEX+ModR/M: r/m (register), reg */
2900#define IEMOPFORM_VEX_MR_REG (IEMOPFORM_VEX_MR | IEMOPFORM_MOD3)
2901/** VEX+ModR/M: r/m (memory), reg */
2902#define IEMOPFORM_VEX_MR_MEM (IEMOPFORM_VEX_MR | IEMOPFORM_NOT_MOD3)
2903/** VEX+ModR/M: r/m, reg, imm8 */
2904#define IEMOPFORM_VEX_MRI 18
2905/** VEX+ModR/M: r/m (register), reg, imm8 */
2906#define IEMOPFORM_VEX_MRI_REG (IEMOPFORM_VEX_MRI | IEMOPFORM_MOD3)
2907/** VEX+ModR/M: r/m (memory), reg, imm8 */
2908#define IEMOPFORM_VEX_MRI_MEM (IEMOPFORM_VEX_MRI | IEMOPFORM_NOT_MOD3)
2909/** VEX+ModR/M: r/m only */
2910#define IEMOPFORM_VEX_M 19
2911/** VEX+ModR/M: r/m only (register). */
2912#define IEMOPFORM_VEX_M_REG (IEMOPFORM_VEX_M | IEMOPFORM_MOD3)
2913/** VEX+ModR/M: r/m only (memory). */
2914#define IEMOPFORM_VEX_M_MEM (IEMOPFORM_VEX_M | IEMOPFORM_NOT_MOD3)
2915/** VEX+ModR/M: reg only */
2916#define IEMOPFORM_VEX_R 20
2917/** VEX+ModR/M: reg, vvvv, r/m */
2918#define IEMOPFORM_VEX_RVM 21
2919/** VEX+ModR/M: reg, vvvv, r/m (register). */
2920#define IEMOPFORM_VEX_RVM_REG (IEMOPFORM_VEX_RVM | IEMOPFORM_MOD3)
2921/** VEX+ModR/M: reg, vvvv, r/m (memory). */
2922#define IEMOPFORM_VEX_RVM_MEM (IEMOPFORM_VEX_RVM | IEMOPFORM_NOT_MOD3)
2923/** VEX+ModR/M: reg, vvvv, r/m, imm */
2924#define IEMOPFORM_VEX_RVMI 22
2925/** VEX+ModR/M: reg, vvvv, r/m (register), imm. */
2926#define IEMOPFORM_VEX_RVMI_REG (IEMOPFORM_VEX_RVMI | IEMOPFORM_MOD3)
2927/** VEX+ModR/M: reg, vvvv, r/m (memory), imm. */
2928#define IEMOPFORM_VEX_RVMI_MEM (IEMOPFORM_VEX_RVMI | IEMOPFORM_NOT_MOD3)
2929/** VEX+ModR/M: reg, vvvv, r/m, imm(reg) */
2930#define IEMOPFORM_VEX_RVMR 23
2931/** VEX+ModR/M: reg, vvvv, r/m (register), imm(reg). */
2932#define IEMOPFORM_VEX_RVMR_REG (IEMOPFORM_VEX_RVMI | IEMOPFORM_MOD3)
2933/** VEX+ModR/M: reg, vvvv, r/m (memory), imm(reg). */
2934#define IEMOPFORM_VEX_RVMR_MEM (IEMOPFORM_VEX_RVMI | IEMOPFORM_NOT_MOD3)
2935/** VEX+ModR/M: reg, r/m, vvvv */
2936#define IEMOPFORM_VEX_RMV 24
2937/** VEX+ModR/M: reg, r/m, vvvv (register). */
2938#define IEMOPFORM_VEX_RMV_REG (IEMOPFORM_VEX_RMV | IEMOPFORM_MOD3)
2939/** VEX+ModR/M: reg, r/m, vvvv (memory). */
2940#define IEMOPFORM_VEX_RMV_MEM (IEMOPFORM_VEX_RMV | IEMOPFORM_NOT_MOD3)
2941/** VEX+ModR/M: reg, r/m, imm8 */
2942#define IEMOPFORM_VEX_RMI 25
2943/** VEX+ModR/M: reg, r/m, imm8 (register). */
2944#define IEMOPFORM_VEX_RMI_REG (IEMOPFORM_VEX_RMI | IEMOPFORM_MOD3)
2945/** VEX+ModR/M: reg, r/m, imm8 (memory). */
2946#define IEMOPFORM_VEX_RMI_MEM (IEMOPFORM_VEX_RMI | IEMOPFORM_NOT_MOD3)
2947/** VEX+ModR/M: r/m, vvvv, reg */
2948#define IEMOPFORM_VEX_MVR 26
2949/** VEX+ModR/M: r/m, vvvv, reg (register) */
2950#define IEMOPFORM_VEX_MVR_REG (IEMOPFORM_VEX_MVR | IEMOPFORM_MOD3)
2951/** VEX+ModR/M: r/m, vvvv, reg (memory) */
2952#define IEMOPFORM_VEX_MVR_MEM (IEMOPFORM_VEX_MVR | IEMOPFORM_NOT_MOD3)
2953/** VEX+ModR/M+/n: vvvv, r/m */
2954#define IEMOPFORM_VEX_VM 27
2955/** VEX+ModR/M+/n: vvvv, r/m (register) */
2956#define IEMOPFORM_VEX_VM_REG (IEMOPFORM_VEX_VM | IEMOPFORM_MOD3)
2957/** VEX+ModR/M+/n: vvvv, r/m (memory) */
2958#define IEMOPFORM_VEX_VM_MEM (IEMOPFORM_VEX_VM | IEMOPFORM_NOT_MOD3)
2959/** VEX+ModR/M+/n: vvvv, r/m, imm8 */
2960#define IEMOPFORM_VEX_VMI 28
2961/** VEX+ModR/M+/n: vvvv, r/m, imm8 (register) */
2962#define IEMOPFORM_VEX_VMI_REG (IEMOPFORM_VEX_VMI | IEMOPFORM_MOD3)
2963/** VEX+ModR/M+/n: vvvv, r/m, imm8 (memory) */
2964#define IEMOPFORM_VEX_VMI_MEM (IEMOPFORM_VEX_VMI | IEMOPFORM_NOT_MOD3)
2965
2966/** Fixed register instruction, no R/M. */
2967#define IEMOPFORM_FIXED 32
2968
2969/** The r/m is a register. */
2970#define IEMOPFORM_MOD3 RT_BIT_32(8)
2971/** The r/m is a memory access. */
2972#define IEMOPFORM_NOT_MOD3 RT_BIT_32(9)
2973/** @} */
2974
2975/** @name IEMOPHINT_XXX - Additional Opcode Hints
2976 * @note These are ORed together with IEMOPFORM_XXX.
2977 * @{ */
2978/** Ignores the operand size prefix (66h). */
2979#define IEMOPHINT_IGNORES_OZ_PFX RT_BIT_32(10)
2980/** Ignores REX.W (aka WIG). */
2981#define IEMOPHINT_IGNORES_REXW RT_BIT_32(11)
2982/** Both the operand size prefixes (66h + REX.W) are ignored. */
2983#define IEMOPHINT_IGNORES_OP_SIZES (IEMOPHINT_IGNORES_OZ_PFX | IEMOPHINT_IGNORES_REXW)
2984/** Allowed with the lock prefix. */
2985#define IEMOPHINT_LOCK_ALLOWED RT_BIT_32(11)
2986/** The VEX.L value is ignored (aka LIG). */
2987#define IEMOPHINT_VEX_L_IGNORED RT_BIT_32(12)
2988/** The VEX.L value must be zero (i.e. 128-bit width only). */
2989#define IEMOPHINT_VEX_L_ZERO RT_BIT_32(13)
2990/** The VEX.L value must be one (i.e. 256-bit width only). */
2991#define IEMOPHINT_VEX_L_ONE RT_BIT_32(14)
2992/** The VEX.V value must be zero. */
2993#define IEMOPHINT_VEX_V_ZERO RT_BIT_32(15)
2994/** The REX.W/VEX.V value must be zero. */
2995#define IEMOPHINT_REX_W_ZERO RT_BIT_32(16)
2996#define IEMOPHINT_VEX_W_ZERO IEMOPHINT_REX_W_ZERO
2997/** The REX.W/VEX.V value must be one. */
2998#define IEMOPHINT_REX_W_ONE RT_BIT_32(17)
2999#define IEMOPHINT_VEX_W_ONE IEMOPHINT_REX_W_ONE
3000
3001/** Hint to IEMAllInstructionPython.py that this macro should be skipped. */
3002#define IEMOPHINT_SKIP_PYTHON RT_BIT_32(31)
3003/** @} */
3004
3005/**
3006 * Possible hardware task switch sources.
3007 */
3008typedef enum IEMTASKSWITCH
3009{
3010 /** Task switch caused by an interrupt/exception. */
3011 IEMTASKSWITCH_INT_XCPT = 1,
3012 /** Task switch caused by a far CALL. */
3013 IEMTASKSWITCH_CALL,
3014 /** Task switch caused by a far JMP. */
3015 IEMTASKSWITCH_JUMP,
3016 /** Task switch caused by an IRET. */
3017 IEMTASKSWITCH_IRET
3018} IEMTASKSWITCH;
3019AssertCompileSize(IEMTASKSWITCH, 4);
3020
3021/**
3022 * Possible CrX load (write) sources.
3023 */
3024typedef enum IEMACCESSCRX
3025{
3026 /** CrX access caused by 'mov crX' instruction. */
3027 IEMACCESSCRX_MOV_CRX,
3028 /** CrX (CR0) write caused by 'lmsw' instruction. */
3029 IEMACCESSCRX_LMSW,
3030 /** CrX (CR0) write caused by 'clts' instruction. */
3031 IEMACCESSCRX_CLTS,
3032 /** CrX (CR0) read caused by 'smsw' instruction. */
3033 IEMACCESSCRX_SMSW
3034} IEMACCESSCRX;
3035
3036#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
3037/** @name IEM_SLAT_FAIL_XXX - Second-level address translation failure information.
3038 *
3039 * These flags provide further context to SLAT page-walk failures that could not be
3040 * determined by PGM (e.g, PGM is not privy to memory access permissions).
3041 *
3042 * @{
3043 */
3044/** Translating a nested-guest linear address failed accessing a nested-guest
3045 * physical address. */
3046# define IEM_SLAT_FAIL_LINEAR_TO_PHYS_ADDR RT_BIT_32(0)
3047/** Translating a nested-guest linear address failed accessing a
3048 * paging-structure entry or updating accessed/dirty bits. */
3049# define IEM_SLAT_FAIL_LINEAR_TO_PAGE_TABLE RT_BIT_32(1)
3050/** @} */
3051
3052DECLCALLBACK(FNPGMPHYSHANDLER) iemVmxApicAccessPageHandler;
3053# ifndef IN_RING3
3054DECLCALLBACK(FNPGMRZPHYSPFHANDLER) iemVmxApicAccessPagePfHandler;
3055# endif
3056#endif
3057
3058/**
3059 * Indicates to the verifier that the given flag set is undefined.
3060 *
3061 * Can be invoked again to add more flags.
3062 *
3063 * This is a NOOP if the verifier isn't compiled in.
3064 *
3065 * @note We're temporarily keeping this until code is converted to new
3066 * disassembler style opcode handling.
3067 */
3068#define IEMOP_VERIFICATION_UNDEFINED_EFLAGS(a_fEfl) do { } while (0)
3069
3070
3071/** @def IEM_DECL_IMPL_TYPE
3072 * For typedef'ing an instruction implementation function.
3073 *
3074 * @param a_RetType The return type.
3075 * @param a_Name The name of the type.
3076 * @param a_ArgList The argument list enclosed in parentheses.
3077 */
3078
3079/** @def IEM_DECL_IMPL_DEF
3080 * For defining an instruction implementation function.
3081 *
3082 * @param a_RetType The return type.
3083 * @param a_Name The name of the type.
3084 * @param a_ArgList The argument list enclosed in parentheses.
3085 */
3086
3087#if defined(__GNUC__) && defined(RT_ARCH_X86)
3088# define IEM_DECL_IMPL_TYPE(a_RetType, a_Name, a_ArgList) \
3089 __attribute__((__fastcall__)) a_RetType (a_Name) a_ArgList
3090# define IEM_DECL_IMPL_DEF(a_RetType, a_Name, a_ArgList) \
3091 __attribute__((__fastcall__, __nothrow__)) DECL_HIDDEN_ONLY(a_RetType) a_Name a_ArgList
3092# define IEM_DECL_IMPL_PROTO(a_RetType, a_Name, a_ArgList) \
3093 __attribute__((__fastcall__, __nothrow__)) DECL_HIDDEN_ONLY(a_RetType) a_Name a_ArgList
3094
3095#elif defined(_MSC_VER) && defined(RT_ARCH_X86)
3096# define IEM_DECL_IMPL_TYPE(a_RetType, a_Name, a_ArgList) \
3097 a_RetType (__fastcall a_Name) a_ArgList
3098# define IEM_DECL_IMPL_DEF(a_RetType, a_Name, a_ArgList) \
3099 a_RetType __fastcall a_Name a_ArgList RT_NOEXCEPT
3100# define IEM_DECL_IMPL_PROTO(a_RetType, a_Name, a_ArgList) \
3101 a_RetType __fastcall a_Name a_ArgList RT_NOEXCEPT
3102
3103#elif __cplusplus >= 201700 /* P0012R1 support */
3104# define IEM_DECL_IMPL_TYPE(a_RetType, a_Name, a_ArgList) \
3105 a_RetType (VBOXCALL a_Name) a_ArgList RT_NOEXCEPT
3106# define IEM_DECL_IMPL_DEF(a_RetType, a_Name, a_ArgList) \
3107 DECL_HIDDEN_ONLY(a_RetType) VBOXCALL a_Name a_ArgList RT_NOEXCEPT
3108# define IEM_DECL_IMPL_PROTO(a_RetType, a_Name, a_ArgList) \
3109 DECL_HIDDEN_ONLY(a_RetType) VBOXCALL a_Name a_ArgList RT_NOEXCEPT
3110
3111#else
3112# define IEM_DECL_IMPL_TYPE(a_RetType, a_Name, a_ArgList) \
3113 a_RetType (VBOXCALL a_Name) a_ArgList
3114# define IEM_DECL_IMPL_DEF(a_RetType, a_Name, a_ArgList) \
3115 DECL_HIDDEN_ONLY(a_RetType) VBOXCALL a_Name a_ArgList
3116# define IEM_DECL_IMPL_PROTO(a_RetType, a_Name, a_ArgList) \
3117 DECL_HIDDEN_ONLY(a_RetType) VBOXCALL a_Name a_ArgList
3118
3119#endif
3120
3121/** Defined in IEMAllAImplC.cpp but also used by IEMAllAImplA.asm. */
3122RT_C_DECLS_BEGIN
3123extern uint8_t const g_afParity[256];
3124RT_C_DECLS_END
3125
3126
3127/** @name Arithmetic assignment operations on bytes (binary).
3128 * @{ */
3129typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLBINU8, (uint32_t fEFlagsIn, uint8_t *pu8Dst, uint8_t u8Src));
3130typedef FNIEMAIMPLBINU8 *PFNIEMAIMPLBINU8;
3131FNIEMAIMPLBINU8 iemAImpl_add_u8, iemAImpl_add_u8_locked;
3132FNIEMAIMPLBINU8 iemAImpl_adc_u8, iemAImpl_adc_u8_locked;
3133FNIEMAIMPLBINU8 iemAImpl_sub_u8, iemAImpl_sub_u8_locked;
3134FNIEMAIMPLBINU8 iemAImpl_sbb_u8, iemAImpl_sbb_u8_locked;
3135FNIEMAIMPLBINU8 iemAImpl_or_u8, iemAImpl_or_u8_locked;
3136FNIEMAIMPLBINU8 iemAImpl_xor_u8, iemAImpl_xor_u8_locked;
3137FNIEMAIMPLBINU8 iemAImpl_and_u8, iemAImpl_and_u8_locked;
3138/** @} */
3139
3140/** @name Arithmetic assignment operations on words (binary).
3141 * @{ */
3142typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLBINU16, (uint32_t fEFlagsIn, uint16_t *pu16Dst, uint16_t u16Src));
3143typedef FNIEMAIMPLBINU16 *PFNIEMAIMPLBINU16;
3144FNIEMAIMPLBINU16 iemAImpl_add_u16, iemAImpl_add_u16_locked;
3145FNIEMAIMPLBINU16 iemAImpl_adc_u16, iemAImpl_adc_u16_locked;
3146FNIEMAIMPLBINU16 iemAImpl_sub_u16, iemAImpl_sub_u16_locked;
3147FNIEMAIMPLBINU16 iemAImpl_sbb_u16, iemAImpl_sbb_u16_locked;
3148FNIEMAIMPLBINU16 iemAImpl_or_u16, iemAImpl_or_u16_locked;
3149FNIEMAIMPLBINU16 iemAImpl_xor_u16, iemAImpl_xor_u16_locked;
3150FNIEMAIMPLBINU16 iemAImpl_and_u16, iemAImpl_and_u16_locked;
3151/** @} */
3152
3153
3154/** @name Arithmetic assignment operations on double words (binary).
3155 * @{ */
3156typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLBINU32, (uint32_t fEFlagsIn, uint32_t *pu32Dst, uint32_t u32Src));
3157typedef FNIEMAIMPLBINU32 *PFNIEMAIMPLBINU32;
3158FNIEMAIMPLBINU32 iemAImpl_add_u32, iemAImpl_add_u32_locked;
3159FNIEMAIMPLBINU32 iemAImpl_adc_u32, iemAImpl_adc_u32_locked;
3160FNIEMAIMPLBINU32 iemAImpl_sub_u32, iemAImpl_sub_u32_locked;
3161FNIEMAIMPLBINU32 iemAImpl_sbb_u32, iemAImpl_sbb_u32_locked;
3162FNIEMAIMPLBINU32 iemAImpl_or_u32, iemAImpl_or_u32_locked;
3163FNIEMAIMPLBINU32 iemAImpl_xor_u32, iemAImpl_xor_u32_locked;
3164FNIEMAIMPLBINU32 iemAImpl_and_u32, iemAImpl_and_u32_locked;
3165FNIEMAIMPLBINU32 iemAImpl_blsi_u32, iemAImpl_blsi_u32_fallback;
3166FNIEMAIMPLBINU32 iemAImpl_blsr_u32, iemAImpl_blsr_u32_fallback;
3167FNIEMAIMPLBINU32 iemAImpl_blsmsk_u32, iemAImpl_blsmsk_u32_fallback;
3168/** @} */
3169
3170/** @name Arithmetic assignment operations on quad words (binary).
3171 * @{ */
3172typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLBINU64, (uint32_t fEFlagsIn, uint64_t *pu64Dst, uint64_t u64Src));
3173typedef FNIEMAIMPLBINU64 *PFNIEMAIMPLBINU64;
3174FNIEMAIMPLBINU64 iemAImpl_add_u64, iemAImpl_add_u64_locked;
3175FNIEMAIMPLBINU64 iemAImpl_adc_u64, iemAImpl_adc_u64_locked;
3176FNIEMAIMPLBINU64 iemAImpl_sub_u64, iemAImpl_sub_u64_locked;
3177FNIEMAIMPLBINU64 iemAImpl_sbb_u64, iemAImpl_sbb_u64_locked;
3178FNIEMAIMPLBINU64 iemAImpl_or_u64, iemAImpl_or_u64_locked;
3179FNIEMAIMPLBINU64 iemAImpl_xor_u64, iemAImpl_xor_u64_locked;
3180FNIEMAIMPLBINU64 iemAImpl_and_u64, iemAImpl_and_u64_locked;
3181FNIEMAIMPLBINU64 iemAImpl_blsi_u64, iemAImpl_blsi_u64_fallback;
3182FNIEMAIMPLBINU64 iemAImpl_blsr_u64, iemAImpl_blsr_u64_fallback;
3183FNIEMAIMPLBINU64 iemAImpl_blsmsk_u64, iemAImpl_blsmsk_u64_fallback;
3184/** @} */
3185
3186typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLBINROU8, (uint32_t fEFlagsIn, uint8_t const *pu8Dst, uint8_t u8Src));
3187typedef FNIEMAIMPLBINROU8 *PFNIEMAIMPLBINROU8;
3188typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLBINROU16,(uint32_t fEFlagsIn, uint16_t const *pu16Dst, uint16_t u16Src));
3189typedef FNIEMAIMPLBINROU16 *PFNIEMAIMPLBINROU16;
3190typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLBINROU32,(uint32_t fEFlagsIn, uint32_t const *pu32Dst, uint32_t u32Src));
3191typedef FNIEMAIMPLBINROU32 *PFNIEMAIMPLBINROU32;
3192typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLBINROU64,(uint32_t fEFlagsIn, uint64_t const *pu64Dst, uint64_t u64Src));
3193typedef FNIEMAIMPLBINROU64 *PFNIEMAIMPLBINROU64;
3194
3195/** @name Compare operations (thrown in with the binary ops).
3196 * @{ */
3197FNIEMAIMPLBINROU8 iemAImpl_cmp_u8;
3198FNIEMAIMPLBINROU16 iemAImpl_cmp_u16;
3199FNIEMAIMPLBINROU32 iemAImpl_cmp_u32;
3200FNIEMAIMPLBINROU64 iemAImpl_cmp_u64;
3201/** @} */
3202
3203/** @name Test operations (thrown in with the binary ops).
3204 * @{ */
3205FNIEMAIMPLBINROU8 iemAImpl_test_u8;
3206FNIEMAIMPLBINROU16 iemAImpl_test_u16;
3207FNIEMAIMPLBINROU32 iemAImpl_test_u32;
3208FNIEMAIMPLBINROU64 iemAImpl_test_u64;
3209/** @} */
3210
3211/** @name Bit operations operations (thrown in with the binary ops).
3212 * @{ */
3213FNIEMAIMPLBINROU16 iemAImpl_bt_u16;
3214FNIEMAIMPLBINROU32 iemAImpl_bt_u32;
3215FNIEMAIMPLBINROU64 iemAImpl_bt_u64;
3216FNIEMAIMPLBINU16 iemAImpl_btc_u16, iemAImpl_btc_u16_locked;
3217FNIEMAIMPLBINU32 iemAImpl_btc_u32, iemAImpl_btc_u32_locked;
3218FNIEMAIMPLBINU64 iemAImpl_btc_u64, iemAImpl_btc_u64_locked;
3219FNIEMAIMPLBINU16 iemAImpl_btr_u16, iemAImpl_btr_u16_locked;
3220FNIEMAIMPLBINU32 iemAImpl_btr_u32, iemAImpl_btr_u32_locked;
3221FNIEMAIMPLBINU64 iemAImpl_btr_u64, iemAImpl_btr_u64_locked;
3222FNIEMAIMPLBINU16 iemAImpl_bts_u16, iemAImpl_bts_u16_locked;
3223FNIEMAIMPLBINU32 iemAImpl_bts_u32, iemAImpl_bts_u32_locked;
3224FNIEMAIMPLBINU64 iemAImpl_bts_u64, iemAImpl_bts_u64_locked;
3225/** @} */
3226
3227/** @name Arithmetic three operand operations on double words (binary).
3228 * @{ */
3229typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINVEXU32, (uint32_t *pu32Dst, uint32_t u32Src1, uint32_t u32Src2, uint32_t *pEFlags));
3230typedef FNIEMAIMPLBINVEXU32 *PFNIEMAIMPLBINVEXU32;
3231FNIEMAIMPLBINVEXU32 iemAImpl_andn_u32, iemAImpl_andn_u32_fallback;
3232FNIEMAIMPLBINVEXU32 iemAImpl_bextr_u32, iemAImpl_bextr_u32_fallback;
3233FNIEMAIMPLBINVEXU32 iemAImpl_bzhi_u32, iemAImpl_bzhi_u32_fallback;
3234/** @} */
3235
3236/** @name Arithmetic three operand operations on quad words (binary).
3237 * @{ */
3238typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINVEXU64, (uint64_t *pu64Dst, uint64_t u64Src1, uint64_t u64Src2, uint32_t *pEFlags));
3239typedef FNIEMAIMPLBINVEXU64 *PFNIEMAIMPLBINVEXU64;
3240FNIEMAIMPLBINVEXU64 iemAImpl_andn_u64, iemAImpl_andn_u64_fallback;
3241FNIEMAIMPLBINVEXU64 iemAImpl_bextr_u64, iemAImpl_bextr_u64_fallback;
3242FNIEMAIMPLBINVEXU64 iemAImpl_bzhi_u64, iemAImpl_bzhi_u64_fallback;
3243/** @} */
3244
3245/** @name Arithmetic three operand operations on double words w/o EFLAGS (binary).
3246 * @{ */
3247typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINVEXU32NOEFL, (uint32_t *pu32Dst, uint32_t u32Src1, uint32_t u32Src2));
3248typedef FNIEMAIMPLBINVEXU32NOEFL *PFNIEMAIMPLBINVEXU32NOEFL;
3249FNIEMAIMPLBINVEXU32NOEFL iemAImpl_pdep_u32, iemAImpl_pdep_u32_fallback;
3250FNIEMAIMPLBINVEXU32NOEFL iemAImpl_pext_u32, iemAImpl_pext_u32_fallback;
3251FNIEMAIMPLBINVEXU32NOEFL iemAImpl_sarx_u32, iemAImpl_sarx_u32_fallback;
3252FNIEMAIMPLBINVEXU32NOEFL iemAImpl_shlx_u32, iemAImpl_shlx_u32_fallback;
3253FNIEMAIMPLBINVEXU32NOEFL iemAImpl_shrx_u32, iemAImpl_shrx_u32_fallback;
3254FNIEMAIMPLBINVEXU32NOEFL iemAImpl_rorx_u32;
3255/** @} */
3256
3257/** @name Arithmetic three operand operations on quad words w/o EFLAGS (binary).
3258 * @{ */
3259typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINVEXU64NOEFL, (uint64_t *pu64Dst, uint64_t u64Src1, uint64_t u64Src2));
3260typedef FNIEMAIMPLBINVEXU64NOEFL *PFNIEMAIMPLBINVEXU64NOEFL;
3261FNIEMAIMPLBINVEXU64NOEFL iemAImpl_pdep_u64, iemAImpl_pdep_u64_fallback;
3262FNIEMAIMPLBINVEXU64NOEFL iemAImpl_pext_u64, iemAImpl_pext_u64_fallback;
3263FNIEMAIMPLBINVEXU64NOEFL iemAImpl_sarx_u64, iemAImpl_sarx_u64_fallback;
3264FNIEMAIMPLBINVEXU64NOEFL iemAImpl_shlx_u64, iemAImpl_shlx_u64_fallback;
3265FNIEMAIMPLBINVEXU64NOEFL iemAImpl_shrx_u64, iemAImpl_shrx_u64_fallback;
3266FNIEMAIMPLBINVEXU64NOEFL iemAImpl_rorx_u64;
3267/** @} */
3268
3269/** @name MULX 32-bit and 64-bit.
3270 * @{ */
3271typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMULXVEXU32, (uint32_t *puDst1, uint32_t *puDst2, uint32_t uSrc1, uint32_t uSrc2));
3272typedef FNIEMAIMPLMULXVEXU32 *PFNIEMAIMPLMULXVEXU32;
3273FNIEMAIMPLMULXVEXU32 iemAImpl_mulx_u32, iemAImpl_mulx_u32_fallback;
3274
3275typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMULXVEXU64, (uint64_t *puDst1, uint64_t *puDst2, uint64_t uSrc1, uint64_t uSrc2));
3276typedef FNIEMAIMPLMULXVEXU64 *PFNIEMAIMPLMULXVEXU64;
3277FNIEMAIMPLMULXVEXU64 iemAImpl_mulx_u64, iemAImpl_mulx_u64_fallback;
3278/** @} */
3279
3280
3281/** @name Exchange memory with register operations.
3282 * @{ */
3283IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u8_locked, (uint8_t *pu8Mem, uint8_t *pu8Reg));
3284IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u16_locked,(uint16_t *pu16Mem, uint16_t *pu16Reg));
3285IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u32_locked,(uint32_t *pu32Mem, uint32_t *pu32Reg));
3286IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u64_locked,(uint64_t *pu64Mem, uint64_t *pu64Reg));
3287IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u8_unlocked, (uint8_t *pu8Mem, uint8_t *pu8Reg));
3288IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u16_unlocked,(uint16_t *pu16Mem, uint16_t *pu16Reg));
3289IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u32_unlocked,(uint32_t *pu32Mem, uint32_t *pu32Reg));
3290IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u64_unlocked,(uint64_t *pu64Mem, uint64_t *pu64Reg));
3291/** @} */
3292
3293/** @name Exchange and add operations.
3294 * @{ */
3295IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u8, (uint8_t *pu8Dst, uint8_t *pu8Reg, uint32_t *pEFlags));
3296IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u16,(uint16_t *pu16Dst, uint16_t *pu16Reg, uint32_t *pEFlags));
3297IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u32,(uint32_t *pu32Dst, uint32_t *pu32Reg, uint32_t *pEFlags));
3298IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u64,(uint64_t *pu64Dst, uint64_t *pu64Reg, uint32_t *pEFlags));
3299IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u8_locked, (uint8_t *pu8Dst, uint8_t *pu8Reg, uint32_t *pEFlags));
3300IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u16_locked,(uint16_t *pu16Dst, uint16_t *pu16Reg, uint32_t *pEFlags));
3301IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u32_locked,(uint32_t *pu32Dst, uint32_t *pu32Reg, uint32_t *pEFlags));
3302IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u64_locked,(uint64_t *pu64Dst, uint64_t *pu64Reg, uint32_t *pEFlags));
3303/** @} */
3304
3305/** @name Compare and exchange.
3306 * @{ */
3307IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u8, (uint8_t *pu8Dst, uint8_t *puAl, uint8_t uSrcReg, uint32_t *pEFlags));
3308IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u8_locked, (uint8_t *pu8Dst, uint8_t *puAl, uint8_t uSrcReg, uint32_t *pEFlags));
3309IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u16, (uint16_t *pu16Dst, uint16_t *puAx, uint16_t uSrcReg, uint32_t *pEFlags));
3310IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u16_locked,(uint16_t *pu16Dst, uint16_t *puAx, uint16_t uSrcReg, uint32_t *pEFlags));
3311IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u32, (uint32_t *pu32Dst, uint32_t *puEax, uint32_t uSrcReg, uint32_t *pEFlags));
3312IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u32_locked,(uint32_t *pu32Dst, uint32_t *puEax, uint32_t uSrcReg, uint32_t *pEFlags));
3313#if ARCH_BITS == 32
3314IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u64, (uint64_t *pu64Dst, uint64_t *puRax, uint64_t *puSrcReg, uint32_t *pEFlags));
3315IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u64_locked,(uint64_t *pu64Dst, uint64_t *puRax, uint64_t *puSrcReg, uint32_t *pEFlags));
3316#else
3317IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u64, (uint64_t *pu64Dst, uint64_t *puRax, uint64_t uSrcReg, uint32_t *pEFlags));
3318IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u64_locked,(uint64_t *pu64Dst, uint64_t *puRax, uint64_t uSrcReg, uint32_t *pEFlags));
3319#endif
3320IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg8b,(uint64_t *pu64Dst, PRTUINT64U pu64EaxEdx, PRTUINT64U pu64EbxEcx,
3321 uint32_t *pEFlags));
3322IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg8b_locked,(uint64_t *pu64Dst, PRTUINT64U pu64EaxEdx, PRTUINT64U pu64EbxEcx,
3323 uint32_t *pEFlags));
3324IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg16b,(PRTUINT128U pu128Dst, PRTUINT128U pu128RaxRdx, PRTUINT128U pu128RbxRcx,
3325 uint32_t *pEFlags));
3326IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg16b_locked,(PRTUINT128U pu128Dst, PRTUINT128U pu128RaxRdx, PRTUINT128U pu128RbxRcx,
3327 uint32_t *pEFlags));
3328#ifndef RT_ARCH_ARM64
3329IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg16b_fallback,(PRTUINT128U pu128Dst, PRTUINT128U pu128RaxRdx,
3330 PRTUINT128U pu128RbxRcx, uint32_t *pEFlags));
3331#endif
3332/** @} */
3333
3334/** @name Memory ordering
3335 * @{ */
3336typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEMFENCE,(void));
3337typedef FNIEMAIMPLMEMFENCE *PFNIEMAIMPLMEMFENCE;
3338IEM_DECL_IMPL_DEF(void, iemAImpl_mfence,(void));
3339IEM_DECL_IMPL_DEF(void, iemAImpl_sfence,(void));
3340IEM_DECL_IMPL_DEF(void, iemAImpl_lfence,(void));
3341#ifndef RT_ARCH_ARM64
3342IEM_DECL_IMPL_DEF(void, iemAImpl_alt_mem_fence,(void));
3343#endif
3344/** @} */
3345
3346/** @name Double precision shifts
3347 * @{ */
3348typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTDBLU16,(uint16_t *pu16Dst, uint16_t u16Src, uint8_t cShift, uint32_t *pEFlags));
3349typedef FNIEMAIMPLSHIFTDBLU16 *PFNIEMAIMPLSHIFTDBLU16;
3350typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTDBLU32,(uint32_t *pu32Dst, uint32_t u32Src, uint8_t cShift, uint32_t *pEFlags));
3351typedef FNIEMAIMPLSHIFTDBLU32 *PFNIEMAIMPLSHIFTDBLU32;
3352typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTDBLU64,(uint64_t *pu64Dst, uint64_t u64Src, uint8_t cShift, uint32_t *pEFlags));
3353typedef FNIEMAIMPLSHIFTDBLU64 *PFNIEMAIMPLSHIFTDBLU64;
3354FNIEMAIMPLSHIFTDBLU16 iemAImpl_shld_u16, iemAImpl_shld_u16_amd, iemAImpl_shld_u16_intel;
3355FNIEMAIMPLSHIFTDBLU32 iemAImpl_shld_u32, iemAImpl_shld_u32_amd, iemAImpl_shld_u32_intel;
3356FNIEMAIMPLSHIFTDBLU64 iemAImpl_shld_u64, iemAImpl_shld_u64_amd, iemAImpl_shld_u64_intel;
3357FNIEMAIMPLSHIFTDBLU16 iemAImpl_shrd_u16, iemAImpl_shrd_u16_amd, iemAImpl_shrd_u16_intel;
3358FNIEMAIMPLSHIFTDBLU32 iemAImpl_shrd_u32, iemAImpl_shrd_u32_amd, iemAImpl_shrd_u32_intel;
3359FNIEMAIMPLSHIFTDBLU64 iemAImpl_shrd_u64, iemAImpl_shrd_u64_amd, iemAImpl_shrd_u64_intel;
3360/** @} */
3361
3362
3363/** @name Bit search operations (thrown in with the binary ops).
3364 * @{ */
3365FNIEMAIMPLBINU16 iemAImpl_bsf_u16, iemAImpl_bsf_u16_amd, iemAImpl_bsf_u16_intel;
3366FNIEMAIMPLBINU32 iemAImpl_bsf_u32, iemAImpl_bsf_u32_amd, iemAImpl_bsf_u32_intel;
3367FNIEMAIMPLBINU64 iemAImpl_bsf_u64, iemAImpl_bsf_u64_amd, iemAImpl_bsf_u64_intel;
3368FNIEMAIMPLBINU16 iemAImpl_bsr_u16, iemAImpl_bsr_u16_amd, iemAImpl_bsr_u16_intel;
3369FNIEMAIMPLBINU32 iemAImpl_bsr_u32, iemAImpl_bsr_u32_amd, iemAImpl_bsr_u32_intel;
3370FNIEMAIMPLBINU64 iemAImpl_bsr_u64, iemAImpl_bsr_u64_amd, iemAImpl_bsr_u64_intel;
3371FNIEMAIMPLBINU16 iemAImpl_lzcnt_u16, iemAImpl_lzcnt_u16_amd, iemAImpl_lzcnt_u16_intel;
3372FNIEMAIMPLBINU32 iemAImpl_lzcnt_u32, iemAImpl_lzcnt_u32_amd, iemAImpl_lzcnt_u32_intel;
3373FNIEMAIMPLBINU64 iemAImpl_lzcnt_u64, iemAImpl_lzcnt_u64_amd, iemAImpl_lzcnt_u64_intel;
3374FNIEMAIMPLBINU16 iemAImpl_tzcnt_u16, iemAImpl_tzcnt_u16_amd, iemAImpl_tzcnt_u16_intel;
3375FNIEMAIMPLBINU32 iemAImpl_tzcnt_u32, iemAImpl_tzcnt_u32_amd, iemAImpl_tzcnt_u32_intel;
3376FNIEMAIMPLBINU64 iemAImpl_tzcnt_u64, iemAImpl_tzcnt_u64_amd, iemAImpl_tzcnt_u64_intel;
3377FNIEMAIMPLBINU16 iemAImpl_popcnt_u16, iemAImpl_popcnt_u16_fallback;
3378FNIEMAIMPLBINU32 iemAImpl_popcnt_u32, iemAImpl_popcnt_u32_fallback;
3379FNIEMAIMPLBINU64 iemAImpl_popcnt_u64, iemAImpl_popcnt_u64_fallback;
3380/** @} */
3381
3382/** @name Signed multiplication operations (thrown in with the binary ops).
3383 * @{ */
3384FNIEMAIMPLBINU16 iemAImpl_imul_two_u16, iemAImpl_imul_two_u16_amd, iemAImpl_imul_two_u16_intel;
3385FNIEMAIMPLBINU32 iemAImpl_imul_two_u32, iemAImpl_imul_two_u32_amd, iemAImpl_imul_two_u32_intel;
3386FNIEMAIMPLBINU64 iemAImpl_imul_two_u64, iemAImpl_imul_two_u64_amd, iemAImpl_imul_two_u64_intel;
3387/** @} */
3388
3389/** @name Arithmetic assignment operations on bytes (unary).
3390 * @{ */
3391typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLUNARYU8, (uint8_t *pu8Dst, uint32_t *pEFlags));
3392typedef FNIEMAIMPLUNARYU8 *PFNIEMAIMPLUNARYU8;
3393FNIEMAIMPLUNARYU8 iemAImpl_inc_u8, iemAImpl_inc_u8_locked;
3394FNIEMAIMPLUNARYU8 iemAImpl_dec_u8, iemAImpl_dec_u8_locked;
3395FNIEMAIMPLUNARYU8 iemAImpl_not_u8, iemAImpl_not_u8_locked;
3396FNIEMAIMPLUNARYU8 iemAImpl_neg_u8, iemAImpl_neg_u8_locked;
3397/** @} */
3398
3399/** @name Arithmetic assignment operations on words (unary).
3400 * @{ */
3401typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLUNARYU16, (uint16_t *pu16Dst, uint32_t *pEFlags));
3402typedef FNIEMAIMPLUNARYU16 *PFNIEMAIMPLUNARYU16;
3403FNIEMAIMPLUNARYU16 iemAImpl_inc_u16, iemAImpl_inc_u16_locked;
3404FNIEMAIMPLUNARYU16 iemAImpl_dec_u16, iemAImpl_dec_u16_locked;
3405FNIEMAIMPLUNARYU16 iemAImpl_not_u16, iemAImpl_not_u16_locked;
3406FNIEMAIMPLUNARYU16 iemAImpl_neg_u16, iemAImpl_neg_u16_locked;
3407/** @} */
3408
3409/** @name Arithmetic assignment operations on double words (unary).
3410 * @{ */
3411typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLUNARYU32, (uint32_t *pu32Dst, uint32_t *pEFlags));
3412typedef FNIEMAIMPLUNARYU32 *PFNIEMAIMPLUNARYU32;
3413FNIEMAIMPLUNARYU32 iemAImpl_inc_u32, iemAImpl_inc_u32_locked;
3414FNIEMAIMPLUNARYU32 iemAImpl_dec_u32, iemAImpl_dec_u32_locked;
3415FNIEMAIMPLUNARYU32 iemAImpl_not_u32, iemAImpl_not_u32_locked;
3416FNIEMAIMPLUNARYU32 iemAImpl_neg_u32, iemAImpl_neg_u32_locked;
3417/** @} */
3418
3419/** @name Arithmetic assignment operations on quad words (unary).
3420 * @{ */
3421typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLUNARYU64, (uint64_t *pu64Dst, uint32_t *pEFlags));
3422typedef FNIEMAIMPLUNARYU64 *PFNIEMAIMPLUNARYU64;
3423FNIEMAIMPLUNARYU64 iemAImpl_inc_u64, iemAImpl_inc_u64_locked;
3424FNIEMAIMPLUNARYU64 iemAImpl_dec_u64, iemAImpl_dec_u64_locked;
3425FNIEMAIMPLUNARYU64 iemAImpl_not_u64, iemAImpl_not_u64_locked;
3426FNIEMAIMPLUNARYU64 iemAImpl_neg_u64, iemAImpl_neg_u64_locked;
3427/** @} */
3428
3429
3430/** @name Shift operations on bytes (Group 2).
3431 * @{ */
3432typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLSHIFTU8,(uint32_t fEFlagsIn, uint8_t *pu8Dst, uint8_t cShift));
3433typedef FNIEMAIMPLSHIFTU8 *PFNIEMAIMPLSHIFTU8;
3434FNIEMAIMPLSHIFTU8 iemAImpl_rol_u8, iemAImpl_rol_u8_amd, iemAImpl_rol_u8_intel;
3435FNIEMAIMPLSHIFTU8 iemAImpl_ror_u8, iemAImpl_ror_u8_amd, iemAImpl_ror_u8_intel;
3436FNIEMAIMPLSHIFTU8 iemAImpl_rcl_u8, iemAImpl_rcl_u8_amd, iemAImpl_rcl_u8_intel;
3437FNIEMAIMPLSHIFTU8 iemAImpl_rcr_u8, iemAImpl_rcr_u8_amd, iemAImpl_rcr_u8_intel;
3438FNIEMAIMPLSHIFTU8 iemAImpl_shl_u8, iemAImpl_shl_u8_amd, iemAImpl_shl_u8_intel;
3439FNIEMAIMPLSHIFTU8 iemAImpl_shr_u8, iemAImpl_shr_u8_amd, iemAImpl_shr_u8_intel;
3440FNIEMAIMPLSHIFTU8 iemAImpl_sar_u8, iemAImpl_sar_u8_amd, iemAImpl_sar_u8_intel;
3441/** @} */
3442
3443/** @name Shift operations on words (Group 2).
3444 * @{ */
3445typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLSHIFTU16,(uint32_t fEFlagsIn, uint16_t *pu16Dst, uint8_t cShift));
3446typedef FNIEMAIMPLSHIFTU16 *PFNIEMAIMPLSHIFTU16;
3447FNIEMAIMPLSHIFTU16 iemAImpl_rol_u16, iemAImpl_rol_u16_amd, iemAImpl_rol_u16_intel;
3448FNIEMAIMPLSHIFTU16 iemAImpl_ror_u16, iemAImpl_ror_u16_amd, iemAImpl_ror_u16_intel;
3449FNIEMAIMPLSHIFTU16 iemAImpl_rcl_u16, iemAImpl_rcl_u16_amd, iemAImpl_rcl_u16_intel;
3450FNIEMAIMPLSHIFTU16 iemAImpl_rcr_u16, iemAImpl_rcr_u16_amd, iemAImpl_rcr_u16_intel;
3451FNIEMAIMPLSHIFTU16 iemAImpl_shl_u16, iemAImpl_shl_u16_amd, iemAImpl_shl_u16_intel;
3452FNIEMAIMPLSHIFTU16 iemAImpl_shr_u16, iemAImpl_shr_u16_amd, iemAImpl_shr_u16_intel;
3453FNIEMAIMPLSHIFTU16 iemAImpl_sar_u16, iemAImpl_sar_u16_amd, iemAImpl_sar_u16_intel;
3454/** @} */
3455
3456/** @name Shift operations on double words (Group 2).
3457 * @{ */
3458typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLSHIFTU32,(uint32_t fEFlagsIn, uint32_t *pu32Dst, uint8_t cShift));
3459typedef FNIEMAIMPLSHIFTU32 *PFNIEMAIMPLSHIFTU32;
3460FNIEMAIMPLSHIFTU32 iemAImpl_rol_u32, iemAImpl_rol_u32_amd, iemAImpl_rol_u32_intel;
3461FNIEMAIMPLSHIFTU32 iemAImpl_ror_u32, iemAImpl_ror_u32_amd, iemAImpl_ror_u32_intel;
3462FNIEMAIMPLSHIFTU32 iemAImpl_rcl_u32, iemAImpl_rcl_u32_amd, iemAImpl_rcl_u32_intel;
3463FNIEMAIMPLSHIFTU32 iemAImpl_rcr_u32, iemAImpl_rcr_u32_amd, iemAImpl_rcr_u32_intel;
3464FNIEMAIMPLSHIFTU32 iemAImpl_shl_u32, iemAImpl_shl_u32_amd, iemAImpl_shl_u32_intel;
3465FNIEMAIMPLSHIFTU32 iemAImpl_shr_u32, iemAImpl_shr_u32_amd, iemAImpl_shr_u32_intel;
3466FNIEMAIMPLSHIFTU32 iemAImpl_sar_u32, iemAImpl_sar_u32_amd, iemAImpl_sar_u32_intel;
3467/** @} */
3468
3469/** @name Shift operations on words (Group 2).
3470 * @{ */
3471typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLSHIFTU64,(uint32_t fEFlagsIn, uint64_t *pu64Dst, uint8_t cShift));
3472typedef FNIEMAIMPLSHIFTU64 *PFNIEMAIMPLSHIFTU64;
3473FNIEMAIMPLSHIFTU64 iemAImpl_rol_u64, iemAImpl_rol_u64_amd, iemAImpl_rol_u64_intel;
3474FNIEMAIMPLSHIFTU64 iemAImpl_ror_u64, iemAImpl_ror_u64_amd, iemAImpl_ror_u64_intel;
3475FNIEMAIMPLSHIFTU64 iemAImpl_rcl_u64, iemAImpl_rcl_u64_amd, iemAImpl_rcl_u64_intel;
3476FNIEMAIMPLSHIFTU64 iemAImpl_rcr_u64, iemAImpl_rcr_u64_amd, iemAImpl_rcr_u64_intel;
3477FNIEMAIMPLSHIFTU64 iemAImpl_shl_u64, iemAImpl_shl_u64_amd, iemAImpl_shl_u64_intel;
3478FNIEMAIMPLSHIFTU64 iemAImpl_shr_u64, iemAImpl_shr_u64_amd, iemAImpl_shr_u64_intel;
3479FNIEMAIMPLSHIFTU64 iemAImpl_sar_u64, iemAImpl_sar_u64_amd, iemAImpl_sar_u64_intel;
3480/** @} */
3481
3482/** @name Multiplication and division operations.
3483 * @{ */
3484typedef IEM_DECL_IMPL_TYPE(int, FNIEMAIMPLMULDIVU8,(uint16_t *pu16AX, uint8_t u8FactorDivisor, uint32_t *pEFlags));
3485typedef FNIEMAIMPLMULDIVU8 *PFNIEMAIMPLMULDIVU8;
3486FNIEMAIMPLMULDIVU8 iemAImpl_mul_u8, iemAImpl_mul_u8_amd, iemAImpl_mul_u8_intel;
3487FNIEMAIMPLMULDIVU8 iemAImpl_imul_u8, iemAImpl_imul_u8_amd, iemAImpl_imul_u8_intel;
3488FNIEMAIMPLMULDIVU8 iemAImpl_div_u8, iemAImpl_div_u8_amd, iemAImpl_div_u8_intel;
3489FNIEMAIMPLMULDIVU8 iemAImpl_idiv_u8, iemAImpl_idiv_u8_amd, iemAImpl_idiv_u8_intel;
3490
3491typedef IEM_DECL_IMPL_TYPE(int, FNIEMAIMPLMULDIVU16,(uint16_t *pu16AX, uint16_t *pu16DX, uint16_t u16FactorDivisor, uint32_t *pEFlags));
3492typedef FNIEMAIMPLMULDIVU16 *PFNIEMAIMPLMULDIVU16;
3493FNIEMAIMPLMULDIVU16 iemAImpl_mul_u16, iemAImpl_mul_u16_amd, iemAImpl_mul_u16_intel;
3494FNIEMAIMPLMULDIVU16 iemAImpl_imul_u16, iemAImpl_imul_u16_amd, iemAImpl_imul_u16_intel;
3495FNIEMAIMPLMULDIVU16 iemAImpl_div_u16, iemAImpl_div_u16_amd, iemAImpl_div_u16_intel;
3496FNIEMAIMPLMULDIVU16 iemAImpl_idiv_u16, iemAImpl_idiv_u16_amd, iemAImpl_idiv_u16_intel;
3497
3498typedef IEM_DECL_IMPL_TYPE(int, FNIEMAIMPLMULDIVU32,(uint32_t *pu32EAX, uint32_t *pu32EDX, uint32_t u32FactorDivisor, uint32_t *pEFlags));
3499typedef FNIEMAIMPLMULDIVU32 *PFNIEMAIMPLMULDIVU32;
3500FNIEMAIMPLMULDIVU32 iemAImpl_mul_u32, iemAImpl_mul_u32_amd, iemAImpl_mul_u32_intel;
3501FNIEMAIMPLMULDIVU32 iemAImpl_imul_u32, iemAImpl_imul_u32_amd, iemAImpl_imul_u32_intel;
3502FNIEMAIMPLMULDIVU32 iemAImpl_div_u32, iemAImpl_div_u32_amd, iemAImpl_div_u32_intel;
3503FNIEMAIMPLMULDIVU32 iemAImpl_idiv_u32, iemAImpl_idiv_u32_amd, iemAImpl_idiv_u32_intel;
3504
3505typedef IEM_DECL_IMPL_TYPE(int, FNIEMAIMPLMULDIVU64,(uint64_t *pu64RAX, uint64_t *pu64RDX, uint64_t u64FactorDivisor, uint32_t *pEFlags));
3506typedef FNIEMAIMPLMULDIVU64 *PFNIEMAIMPLMULDIVU64;
3507FNIEMAIMPLMULDIVU64 iemAImpl_mul_u64, iemAImpl_mul_u64_amd, iemAImpl_mul_u64_intel;
3508FNIEMAIMPLMULDIVU64 iemAImpl_imul_u64, iemAImpl_imul_u64_amd, iemAImpl_imul_u64_intel;
3509FNIEMAIMPLMULDIVU64 iemAImpl_div_u64, iemAImpl_div_u64_amd, iemAImpl_div_u64_intel;
3510FNIEMAIMPLMULDIVU64 iemAImpl_idiv_u64, iemAImpl_idiv_u64_amd, iemAImpl_idiv_u64_intel;
3511/** @} */
3512
3513/** @name Byte Swap.
3514 * @{ */
3515IEM_DECL_IMPL_TYPE(void, iemAImpl_bswap_u16,(uint32_t *pu32Dst)); /* Yes, 32-bit register access. */
3516IEM_DECL_IMPL_TYPE(void, iemAImpl_bswap_u32,(uint32_t *pu32Dst));
3517IEM_DECL_IMPL_TYPE(void, iemAImpl_bswap_u64,(uint64_t *pu64Dst));
3518/** @} */
3519
3520/** @name Misc.
3521 * @{ */
3522FNIEMAIMPLBINU16 iemAImpl_arpl;
3523/** @} */
3524
3525/** @name RDRAND and RDSEED
3526 * @{ */
3527typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLRDRANDSEEDU16,(uint16_t *puDst, uint32_t *pEFlags));
3528typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLRDRANDSEEDU32,(uint32_t *puDst, uint32_t *pEFlags));
3529typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLRDRANDSEEDU64,(uint64_t *puDst, uint32_t *pEFlags));
3530typedef FNIEMAIMPLRDRANDSEEDU16 *PFNIEMAIMPLRDRANDSEEDU16;
3531typedef FNIEMAIMPLRDRANDSEEDU32 *PFNIEMAIMPLRDRANDSEEDU32;
3532typedef FNIEMAIMPLRDRANDSEEDU64 *PFNIEMAIMPLRDRANDSEEDU64;
3533
3534FNIEMAIMPLRDRANDSEEDU16 iemAImpl_rdrand_u16, iemAImpl_rdrand_u16_fallback;
3535FNIEMAIMPLRDRANDSEEDU32 iemAImpl_rdrand_u32, iemAImpl_rdrand_u32_fallback;
3536FNIEMAIMPLRDRANDSEEDU64 iemAImpl_rdrand_u64, iemAImpl_rdrand_u64_fallback;
3537FNIEMAIMPLRDRANDSEEDU16 iemAImpl_rdseed_u16, iemAImpl_rdseed_u16_fallback;
3538FNIEMAIMPLRDRANDSEEDU32 iemAImpl_rdseed_u32, iemAImpl_rdseed_u32_fallback;
3539FNIEMAIMPLRDRANDSEEDU64 iemAImpl_rdseed_u64, iemAImpl_rdseed_u64_fallback;
3540/** @} */
3541
3542/** @name ADOX and ADCX
3543 * @{ */
3544FNIEMAIMPLBINU32 iemAImpl_adcx_u32, iemAImpl_adcx_u32_fallback;
3545FNIEMAIMPLBINU64 iemAImpl_adcx_u64, iemAImpl_adcx_u64_fallback;
3546FNIEMAIMPLBINU32 iemAImpl_adox_u32, iemAImpl_adox_u32_fallback;
3547FNIEMAIMPLBINU64 iemAImpl_adox_u64, iemAImpl_adox_u64_fallback;
3548/** @} */
3549
3550/** @name FPU operations taking a 32-bit float argument
3551 * @{ */
3552typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR32FSW,(PCX86FXSTATE pFpuState, uint16_t *pFSW,
3553 PCRTFLOAT80U pr80Val1, PCRTFLOAT32U pr32Val2));
3554typedef FNIEMAIMPLFPUR32FSW *PFNIEMAIMPLFPUR32FSW;
3555
3556typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR32,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
3557 PCRTFLOAT80U pr80Val1, PCRTFLOAT32U pr32Val2));
3558typedef FNIEMAIMPLFPUR32 *PFNIEMAIMPLFPUR32;
3559
3560FNIEMAIMPLFPUR32FSW iemAImpl_fcom_r80_by_r32;
3561FNIEMAIMPLFPUR32 iemAImpl_fadd_r80_by_r32;
3562FNIEMAIMPLFPUR32 iemAImpl_fmul_r80_by_r32;
3563FNIEMAIMPLFPUR32 iemAImpl_fsub_r80_by_r32;
3564FNIEMAIMPLFPUR32 iemAImpl_fsubr_r80_by_r32;
3565FNIEMAIMPLFPUR32 iemAImpl_fdiv_r80_by_r32;
3566FNIEMAIMPLFPUR32 iemAImpl_fdivr_r80_by_r32;
3567
3568IEM_DECL_IMPL_DEF(void, iemAImpl_fld_r80_from_r32,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, PCRTFLOAT32U pr32Val));
3569IEM_DECL_IMPL_DEF(void, iemAImpl_fst_r80_to_r32,(PCX86FXSTATE pFpuState, uint16_t *pu16FSW,
3570 PRTFLOAT32U pr32Val, PCRTFLOAT80U pr80Val));
3571/** @} */
3572
3573/** @name FPU operations taking a 64-bit float argument
3574 * @{ */
3575typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR64FSW,(PCX86FXSTATE pFpuState, uint16_t *pFSW,
3576 PCRTFLOAT80U pr80Val1, PCRTFLOAT64U pr64Val2));
3577typedef FNIEMAIMPLFPUR64FSW *PFNIEMAIMPLFPUR64FSW;
3578
3579typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR64,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
3580 PCRTFLOAT80U pr80Val1, PCRTFLOAT64U pr64Val2));
3581typedef FNIEMAIMPLFPUR64 *PFNIEMAIMPLFPUR64;
3582
3583FNIEMAIMPLFPUR64FSW iemAImpl_fcom_r80_by_r64;
3584FNIEMAIMPLFPUR64 iemAImpl_fadd_r80_by_r64;
3585FNIEMAIMPLFPUR64 iemAImpl_fmul_r80_by_r64;
3586FNIEMAIMPLFPUR64 iemAImpl_fsub_r80_by_r64;
3587FNIEMAIMPLFPUR64 iemAImpl_fsubr_r80_by_r64;
3588FNIEMAIMPLFPUR64 iemAImpl_fdiv_r80_by_r64;
3589FNIEMAIMPLFPUR64 iemAImpl_fdivr_r80_by_r64;
3590
3591IEM_DECL_IMPL_DEF(void, iemAImpl_fld_r80_from_r64,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, PCRTFLOAT64U pr64Val));
3592IEM_DECL_IMPL_DEF(void, iemAImpl_fst_r80_to_r64,(PCX86FXSTATE pFpuState, uint16_t *pu16FSW,
3593 PRTFLOAT64U pr32Val, PCRTFLOAT80U pr80Val));
3594/** @} */
3595
3596/** @name FPU operations taking a 80-bit float argument
3597 * @{ */
3598typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
3599 PCRTFLOAT80U pr80Val1, PCRTFLOAT80U pr80Val2));
3600typedef FNIEMAIMPLFPUR80 *PFNIEMAIMPLFPUR80;
3601FNIEMAIMPLFPUR80 iemAImpl_fadd_r80_by_r80;
3602FNIEMAIMPLFPUR80 iemAImpl_fmul_r80_by_r80;
3603FNIEMAIMPLFPUR80 iemAImpl_fsub_r80_by_r80;
3604FNIEMAIMPLFPUR80 iemAImpl_fsubr_r80_by_r80;
3605FNIEMAIMPLFPUR80 iemAImpl_fdiv_r80_by_r80;
3606FNIEMAIMPLFPUR80 iemAImpl_fdivr_r80_by_r80;
3607FNIEMAIMPLFPUR80 iemAImpl_fprem_r80_by_r80;
3608FNIEMAIMPLFPUR80 iemAImpl_fprem1_r80_by_r80;
3609FNIEMAIMPLFPUR80 iemAImpl_fscale_r80_by_r80;
3610
3611FNIEMAIMPLFPUR80 iemAImpl_fpatan_r80_by_r80, iemAImpl_fpatan_r80_by_r80_amd, iemAImpl_fpatan_r80_by_r80_intel;
3612FNIEMAIMPLFPUR80 iemAImpl_fyl2x_r80_by_r80, iemAImpl_fyl2x_r80_by_r80_amd, iemAImpl_fyl2x_r80_by_r80_intel;
3613FNIEMAIMPLFPUR80 iemAImpl_fyl2xp1_r80_by_r80, iemAImpl_fyl2xp1_r80_by_r80_amd, iemAImpl_fyl2xp1_r80_by_r80_intel;
3614
3615typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR80FSW,(PCX86FXSTATE pFpuState, uint16_t *pFSW,
3616 PCRTFLOAT80U pr80Val1, PCRTFLOAT80U pr80Val2));
3617typedef FNIEMAIMPLFPUR80FSW *PFNIEMAIMPLFPUR80FSW;
3618FNIEMAIMPLFPUR80FSW iemAImpl_fcom_r80_by_r80;
3619FNIEMAIMPLFPUR80FSW iemAImpl_fucom_r80_by_r80;
3620
3621typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLFPUR80EFL,(PCX86FXSTATE pFpuState, uint16_t *pu16Fsw,
3622 PCRTFLOAT80U pr80Val1, PCRTFLOAT80U pr80Val2));
3623typedef FNIEMAIMPLFPUR80EFL *PFNIEMAIMPLFPUR80EFL;
3624FNIEMAIMPLFPUR80EFL iemAImpl_fcomi_r80_by_r80;
3625FNIEMAIMPLFPUR80EFL iemAImpl_fucomi_r80_by_r80;
3626
3627typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR80UNARY,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, PCRTFLOAT80U pr80Val));
3628typedef FNIEMAIMPLFPUR80UNARY *PFNIEMAIMPLFPUR80UNARY;
3629FNIEMAIMPLFPUR80UNARY iemAImpl_fabs_r80;
3630FNIEMAIMPLFPUR80UNARY iemAImpl_fchs_r80;
3631FNIEMAIMPLFPUR80UNARY iemAImpl_f2xm1_r80, iemAImpl_f2xm1_r80_amd, iemAImpl_f2xm1_r80_intel;
3632FNIEMAIMPLFPUR80UNARY iemAImpl_fsqrt_r80;
3633FNIEMAIMPLFPUR80UNARY iemAImpl_frndint_r80;
3634FNIEMAIMPLFPUR80UNARY iemAImpl_fsin_r80, iemAImpl_fsin_r80_amd, iemAImpl_fsin_r80_intel;
3635FNIEMAIMPLFPUR80UNARY iemAImpl_fcos_r80, iemAImpl_fcos_r80_amd, iemAImpl_fcos_r80_intel;
3636
3637typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR80UNARYFSW,(PCX86FXSTATE pFpuState, uint16_t *pu16Fsw, PCRTFLOAT80U pr80Val));
3638typedef FNIEMAIMPLFPUR80UNARYFSW *PFNIEMAIMPLFPUR80UNARYFSW;
3639FNIEMAIMPLFPUR80UNARYFSW iemAImpl_ftst_r80;
3640FNIEMAIMPLFPUR80UNARYFSW iemAImpl_fxam_r80;
3641
3642typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR80LDCONST,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes));
3643typedef FNIEMAIMPLFPUR80LDCONST *PFNIEMAIMPLFPUR80LDCONST;
3644FNIEMAIMPLFPUR80LDCONST iemAImpl_fld1;
3645FNIEMAIMPLFPUR80LDCONST iemAImpl_fldl2t;
3646FNIEMAIMPLFPUR80LDCONST iemAImpl_fldl2e;
3647FNIEMAIMPLFPUR80LDCONST iemAImpl_fldpi;
3648FNIEMAIMPLFPUR80LDCONST iemAImpl_fldlg2;
3649FNIEMAIMPLFPUR80LDCONST iemAImpl_fldln2;
3650FNIEMAIMPLFPUR80LDCONST iemAImpl_fldz;
3651
3652typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR80UNARYTWO,(PCX86FXSTATE pFpuState, PIEMFPURESULTTWO pFpuResTwo,
3653 PCRTFLOAT80U pr80Val));
3654typedef FNIEMAIMPLFPUR80UNARYTWO *PFNIEMAIMPLFPUR80UNARYTWO;
3655FNIEMAIMPLFPUR80UNARYTWO iemAImpl_fptan_r80_r80, iemAImpl_fptan_r80_r80_amd, iemAImpl_fptan_r80_r80_intel;
3656FNIEMAIMPLFPUR80UNARYTWO iemAImpl_fxtract_r80_r80;
3657FNIEMAIMPLFPUR80UNARYTWO iemAImpl_fsincos_r80_r80, iemAImpl_fsincos_r80_r80_amd, iemAImpl_fsincos_r80_r80_intel;
3658
3659IEM_DECL_IMPL_DEF(void, iemAImpl_fld_r80_from_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, PCRTFLOAT80U pr80Val));
3660IEM_DECL_IMPL_DEF(void, iemAImpl_fst_r80_to_r80,(PCX86FXSTATE pFpuState, uint16_t *pu16FSW,
3661 PRTFLOAT80U pr80Dst, PCRTFLOAT80U pr80Src));
3662
3663IEM_DECL_IMPL_DEF(void, iemAImpl_fld_r80_from_d80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, PCRTPBCD80U pd80Val));
3664IEM_DECL_IMPL_DEF(void, iemAImpl_fst_r80_to_d80,(PCX86FXSTATE pFpuState, uint16_t *pu16FSW,
3665 PRTPBCD80U pd80Dst, PCRTFLOAT80U pr80Src));
3666
3667/** @} */
3668
3669/** @name FPU operations taking a 16-bit signed integer argument
3670 * @{ */
3671typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUI16,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
3672 PCRTFLOAT80U pr80Val1, int16_t const *pi16Val2));
3673typedef FNIEMAIMPLFPUI16 *PFNIEMAIMPLFPUI16;
3674typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUSTR80TOI16,(PCX86FXSTATE pFpuState, uint16_t *pFpuRes,
3675 int16_t *pi16Dst, PCRTFLOAT80U pr80Src));
3676typedef FNIEMAIMPLFPUSTR80TOI16 *PFNIEMAIMPLFPUSTR80TOI16;
3677
3678FNIEMAIMPLFPUI16 iemAImpl_fiadd_r80_by_i16;
3679FNIEMAIMPLFPUI16 iemAImpl_fimul_r80_by_i16;
3680FNIEMAIMPLFPUI16 iemAImpl_fisub_r80_by_i16;
3681FNIEMAIMPLFPUI16 iemAImpl_fisubr_r80_by_i16;
3682FNIEMAIMPLFPUI16 iemAImpl_fidiv_r80_by_i16;
3683FNIEMAIMPLFPUI16 iemAImpl_fidivr_r80_by_i16;
3684
3685typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUI16FSW,(PCX86FXSTATE pFpuState, uint16_t *pFSW,
3686 PCRTFLOAT80U pr80Val1, int16_t const *pi16Val2));
3687typedef FNIEMAIMPLFPUI16FSW *PFNIEMAIMPLFPUI16FSW;
3688FNIEMAIMPLFPUI16FSW iemAImpl_ficom_r80_by_i16;
3689
3690IEM_DECL_IMPL_DEF(void, iemAImpl_fild_r80_from_i16,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, int16_t const *pi16Val));
3691FNIEMAIMPLFPUSTR80TOI16 iemAImpl_fist_r80_to_i16;
3692FNIEMAIMPLFPUSTR80TOI16 iemAImpl_fistt_r80_to_i16, iemAImpl_fistt_r80_to_i16_amd, iemAImpl_fistt_r80_to_i16_intel;
3693/** @} */
3694
3695/** @name FPU operations taking a 32-bit signed integer argument
3696 * @{ */
3697typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUI32,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
3698 PCRTFLOAT80U pr80Val1, int32_t const *pi32Val2));
3699typedef FNIEMAIMPLFPUI32 *PFNIEMAIMPLFPUI32;
3700typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUSTR80TOI32,(PCX86FXSTATE pFpuState, uint16_t *pFpuRes,
3701 int32_t *pi32Dst, PCRTFLOAT80U pr80Src));
3702typedef FNIEMAIMPLFPUSTR80TOI32 *PFNIEMAIMPLFPUSTR80TOI32;
3703
3704FNIEMAIMPLFPUI32 iemAImpl_fiadd_r80_by_i32;
3705FNIEMAIMPLFPUI32 iemAImpl_fimul_r80_by_i32;
3706FNIEMAIMPLFPUI32 iemAImpl_fisub_r80_by_i32;
3707FNIEMAIMPLFPUI32 iemAImpl_fisubr_r80_by_i32;
3708FNIEMAIMPLFPUI32 iemAImpl_fidiv_r80_by_i32;
3709FNIEMAIMPLFPUI32 iemAImpl_fidivr_r80_by_i32;
3710
3711typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUI32FSW,(PCX86FXSTATE pFpuState, uint16_t *pFSW,
3712 PCRTFLOAT80U pr80Val1, int32_t const *pi32Val2));
3713typedef FNIEMAIMPLFPUI32FSW *PFNIEMAIMPLFPUI32FSW;
3714FNIEMAIMPLFPUI32FSW iemAImpl_ficom_r80_by_i32;
3715
3716IEM_DECL_IMPL_DEF(void, iemAImpl_fild_r80_from_i32,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, int32_t const *pi32Val));
3717FNIEMAIMPLFPUSTR80TOI32 iemAImpl_fist_r80_to_i32;
3718FNIEMAIMPLFPUSTR80TOI32 iemAImpl_fistt_r80_to_i32;
3719/** @} */
3720
3721/** @name FPU operations taking a 64-bit signed integer argument
3722 * @{ */
3723typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUSTR80TOI64,(PCX86FXSTATE pFpuState, uint16_t *pFpuRes,
3724 int64_t *pi64Dst, PCRTFLOAT80U pr80Src));
3725typedef FNIEMAIMPLFPUSTR80TOI64 *PFNIEMAIMPLFPUSTR80TOI64;
3726
3727IEM_DECL_IMPL_DEF(void, iemAImpl_fild_r80_from_i64,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, int64_t const *pi64Val));
3728FNIEMAIMPLFPUSTR80TOI64 iemAImpl_fist_r80_to_i64;
3729FNIEMAIMPLFPUSTR80TOI64 iemAImpl_fistt_r80_to_i64;
3730/** @} */
3731
3732
3733/** Temporary type representing a 256-bit vector register. */
3734typedef struct { uint64_t au64[4]; } IEMVMM256;
3735/** Temporary type pointing to a 256-bit vector register. */
3736typedef IEMVMM256 *PIEMVMM256;
3737/** Temporary type pointing to a const 256-bit vector register. */
3738typedef IEMVMM256 *PCIEMVMM256;
3739
3740
3741/** @name Media (SSE/MMX/AVX) operations: full1 + full2 -> full1.
3742 * @{ */
3743typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAF2U64,(PCX86FXSTATE pFpuState, uint64_t *puDst, uint64_t const *puSrc));
3744typedef FNIEMAIMPLMEDIAF2U64 *PFNIEMAIMPLMEDIAF2U64;
3745typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLMEDIAF2U128,(uint32_t uMxCsrIn, PX86XMMREG puDst, PCX86XMMREG puSrc));
3746typedef FNIEMAIMPLMEDIAF2U128 *PFNIEMAIMPLMEDIAF2U128;
3747typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLMEDIAF2U256,(uint32_t uMxCsrIn, PX86YMMREG puDst, PCX86YMMREG puSrc));
3748typedef FNIEMAIMPLMEDIAF2U256 *PFNIEMAIMPLMEDIAF2U256;
3749typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLMEDIAF3U128,(uint32_t uMxCsrIn, PX86XMMREG puDst, PCX86XMMREG puSrc1, PCX86XMMREG puSrc2));
3750typedef FNIEMAIMPLMEDIAF3U128 *PFNIEMAIMPLMEDIAF3U128;
3751typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLMEDIAF3U256,(uint32_t uMxCsrIn, PX86YMMREG puDst, PCX86YMMREG puSrc1, PCX86YMMREG puSrc2));
3752typedef FNIEMAIMPLMEDIAF3U256 *PFNIEMAIMPLMEDIAF3U256;
3753typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAOPTF2U64,(uint64_t *puDst, uint64_t const *puSrc));
3754typedef FNIEMAIMPLMEDIAOPTF2U64 *PFNIEMAIMPLMEDIAOPTF2U64;
3755typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAOPTF2U128,(PRTUINT128U puDst, PCRTUINT128U puSrc));
3756typedef FNIEMAIMPLMEDIAOPTF2U128 *PFNIEMAIMPLMEDIAOPTF2U128;
3757typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAOPTF3U128,(PRTUINT128U puDst, PCRTUINT128U puSrc1, PCRTUINT128U puSrc2));
3758typedef FNIEMAIMPLMEDIAOPTF3U128 *PFNIEMAIMPLMEDIAOPTF3U128;
3759typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAOPTF3U256,(PRTUINT256U puDst, PCRTUINT256U puSrc1, PCRTUINT256U puSrc2));
3760typedef FNIEMAIMPLMEDIAOPTF3U256 *PFNIEMAIMPLMEDIAOPTF3U256;
3761typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAOPTF2U256,(PRTUINT256U puDst, PCRTUINT256U puSrc));
3762typedef FNIEMAIMPLMEDIAOPTF2U256 *PFNIEMAIMPLMEDIAOPTF2U256;
3763FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_pshufb_u64, iemAImpl_pshufb_u64_fallback;
3764FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_pand_u64, iemAImpl_pandn_u64, iemAImpl_por_u64, iemAImpl_pxor_u64;
3765FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_pcmpeqb_u64, iemAImpl_pcmpeqw_u64, iemAImpl_pcmpeqd_u64;
3766FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_pcmpgtb_u64, iemAImpl_pcmpgtw_u64, iemAImpl_pcmpgtd_u64;
3767FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_paddb_u64, iemAImpl_paddsb_u64, iemAImpl_paddusb_u64;
3768FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_paddw_u64, iemAImpl_paddsw_u64, iemAImpl_paddusw_u64;
3769FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_paddd_u64;
3770FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_paddq_u64;
3771FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_psubb_u64, iemAImpl_psubsb_u64, iemAImpl_psubusb_u64;
3772FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_psubw_u64, iemAImpl_psubsw_u64, iemAImpl_psubusw_u64;
3773FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_psubd_u64;
3774FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_psubq_u64;
3775FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_pmaddwd_u64, iemAImpl_pmaddwd_u64_fallback;
3776FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_pmullw_u64, iemAImpl_pmulhw_u64;
3777FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_pminub_u64, iemAImpl_pmaxub_u64;
3778FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_pminsw_u64, iemAImpl_pmaxsw_u64;
3779FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_pabsb_u64, iemAImpl_pabsb_u64_fallback;
3780FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_pabsw_u64, iemAImpl_pabsw_u64_fallback;
3781FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_pabsd_u64, iemAImpl_pabsd_u64_fallback;
3782FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_psignb_u64, iemAImpl_psignb_u64_fallback;
3783FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_psignw_u64, iemAImpl_psignw_u64_fallback;
3784FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_psignd_u64, iemAImpl_psignd_u64_fallback;
3785FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_phaddw_u64, iemAImpl_phaddw_u64_fallback;
3786FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_phaddd_u64, iemAImpl_phaddd_u64_fallback;
3787FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_phsubw_u64, iemAImpl_phsubw_u64_fallback;
3788FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_phsubd_u64, iemAImpl_phsubd_u64_fallback;
3789FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_phaddsw_u64, iemAImpl_phaddsw_u64_fallback;
3790FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_phsubsw_u64, iemAImpl_phsubsw_u64_fallback;
3791FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_pmaddubsw_u64, iemAImpl_pmaddubsw_u64_fallback;
3792FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_pmulhrsw_u64, iemAImpl_pmulhrsw_u64_fallback;
3793FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_pmuludq_u64;
3794FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_psllw_u64, iemAImpl_psrlw_u64, iemAImpl_psraw_u64;
3795FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_pslld_u64, iemAImpl_psrld_u64, iemAImpl_psrad_u64;
3796FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_psllq_u64, iemAImpl_psrlq_u64;
3797FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_packsswb_u64, iemAImpl_packuswb_u64;
3798FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_packssdw_u64;
3799FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_pmulhuw_u64;
3800FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_pavgb_u64, iemAImpl_pavgw_u64;
3801FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_psadbw_u64;
3802
3803FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pshufb_u128, iemAImpl_pshufb_u128_fallback;
3804FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pand_u128, iemAImpl_pandn_u128, iemAImpl_por_u128, iemAImpl_pxor_u128;
3805FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pcmpeqb_u128, iemAImpl_pcmpeqw_u128, iemAImpl_pcmpeqd_u128;
3806FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pcmpeqq_u128, iemAImpl_pcmpeqq_u128_fallback;
3807FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pcmpgtb_u128, iemAImpl_pcmpgtw_u128, iemAImpl_pcmpgtd_u128;
3808FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pcmpgtq_u128, iemAImpl_pcmpgtq_u128_fallback;
3809FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_paddb_u128, iemAImpl_paddsb_u128, iemAImpl_paddusb_u128;
3810FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_paddw_u128, iemAImpl_paddsw_u128, iemAImpl_paddusw_u128;
3811FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_paddd_u128;
3812FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_paddq_u128;
3813FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_psubb_u128, iemAImpl_psubsb_u128, iemAImpl_psubusb_u128;
3814FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_psubw_u128, iemAImpl_psubsw_u128, iemAImpl_psubusw_u128;
3815FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_psubd_u128;
3816FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_psubq_u128;
3817FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pmullw_u128, iemAImpl_pmullw_u128_fallback;
3818FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pmulhw_u128;
3819FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pmulld_u128, iemAImpl_pmulld_u128_fallback;
3820FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pmaddwd_u128, iemAImpl_pmaddwd_u128_fallback;
3821FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pminub_u128;
3822FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pminud_u128, iemAImpl_pminud_u128_fallback;
3823FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pminuw_u128, iemAImpl_pminuw_u128_fallback;
3824FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pminsb_u128, iemAImpl_pminsb_u128_fallback;
3825FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pminsd_u128, iemAImpl_pminsd_u128_fallback;
3826FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pminsw_u128, iemAImpl_pminsw_u128_fallback;
3827FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pmaxub_u128;
3828FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pmaxud_u128, iemAImpl_pmaxud_u128_fallback;
3829FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pmaxuw_u128, iemAImpl_pmaxuw_u128_fallback;
3830FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pmaxsb_u128, iemAImpl_pmaxsb_u128_fallback;
3831FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pmaxsw_u128;
3832FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pmaxsd_u128, iemAImpl_pmaxsd_u128_fallback;
3833FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pabsb_u128, iemAImpl_pabsb_u128_fallback;
3834FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pabsw_u128, iemAImpl_pabsw_u128_fallback;
3835FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pabsd_u128, iemAImpl_pabsd_u128_fallback;
3836FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_psignb_u128, iemAImpl_psignb_u128_fallback;
3837FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_psignw_u128, iemAImpl_psignw_u128_fallback;
3838FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_psignd_u128, iemAImpl_psignd_u128_fallback;
3839FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_phaddw_u128, iemAImpl_phaddw_u128_fallback;
3840FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_phaddd_u128, iemAImpl_phaddd_u128_fallback;
3841FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_phsubw_u128, iemAImpl_phsubw_u128_fallback;
3842FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_phsubd_u128, iemAImpl_phsubd_u128_fallback;
3843FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_phaddsw_u128, iemAImpl_phaddsw_u128_fallback;
3844FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_phsubsw_u128, iemAImpl_phsubsw_u128_fallback;
3845FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pmaddubsw_u128, iemAImpl_pmaddubsw_u128_fallback;
3846FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pmulhrsw_u128, iemAImpl_pmulhrsw_u128_fallback;
3847FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pmuludq_u128;
3848FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pmaddwd_u128, iemAImpl_pmaddwd_u128_fallback;
3849FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_packsswb_u128, iemAImpl_packuswb_u128;
3850FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_packssdw_u128, iemAImpl_packusdw_u128;
3851FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_psllw_u128, iemAImpl_psrlw_u128, iemAImpl_psraw_u128;
3852FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pslld_u128, iemAImpl_psrld_u128, iemAImpl_psrad_u128;
3853FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_psllq_u128, iemAImpl_psrlq_u128;
3854FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pmulhuw_u128;
3855FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pavgb_u128, iemAImpl_pavgw_u128;
3856FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_psadbw_u128;
3857FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pmuldq_u128, iemAImpl_pmuldq_u128_fallback;
3858FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_unpcklps_u128, iemAImpl_unpcklpd_u128;
3859FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_unpckhps_u128, iemAImpl_unpckhpd_u128;
3860FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_phminposuw_u128, iemAImpl_phminposuw_u128_fallback;
3861
3862FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpshufb_u128, iemAImpl_vpshufb_u128_fallback;
3863FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpand_u128, iemAImpl_vpand_u128_fallback;
3864FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpandn_u128, iemAImpl_vpandn_u128_fallback;
3865FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpor_u128, iemAImpl_vpor_u128_fallback;
3866FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpxor_u128, iemAImpl_vpxor_u128_fallback;
3867FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpcmpeqb_u128, iemAImpl_vpcmpeqb_u128_fallback;
3868FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpcmpeqw_u128, iemAImpl_vpcmpeqw_u128_fallback;
3869FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpcmpeqd_u128, iemAImpl_vpcmpeqd_u128_fallback;
3870FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpcmpeqq_u128, iemAImpl_vpcmpeqq_u128_fallback;
3871FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpcmpgtb_u128, iemAImpl_vpcmpgtb_u128_fallback;
3872FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpcmpgtw_u128, iemAImpl_vpcmpgtw_u128_fallback;
3873FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpcmpgtd_u128, iemAImpl_vpcmpgtd_u128_fallback;
3874FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpcmpgtq_u128, iemAImpl_vpcmpgtq_u128_fallback;
3875FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpaddb_u128, iemAImpl_vpaddb_u128_fallback;
3876FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpaddw_u128, iemAImpl_vpaddw_u128_fallback;
3877FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpaddd_u128, iemAImpl_vpaddd_u128_fallback;
3878FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpaddq_u128, iemAImpl_vpaddq_u128_fallback;
3879FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsubb_u128, iemAImpl_vpsubb_u128_fallback;
3880FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsubw_u128, iemAImpl_vpsubw_u128_fallback;
3881FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsubd_u128, iemAImpl_vpsubd_u128_fallback;
3882FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsubq_u128, iemAImpl_vpsubq_u128_fallback;
3883FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpminub_u128, iemAImpl_vpminub_u128_fallback;
3884FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpminuw_u128, iemAImpl_vpminuw_u128_fallback;
3885FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpminud_u128, iemAImpl_vpminud_u128_fallback;
3886FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpminsb_u128, iemAImpl_vpminsb_u128_fallback;
3887FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpminsw_u128, iemAImpl_vpminsw_u128_fallback;
3888FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpminsd_u128, iemAImpl_vpminsd_u128_fallback;
3889FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmaxub_u128, iemAImpl_vpmaxub_u128_fallback;
3890FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmaxuw_u128, iemAImpl_vpmaxuw_u128_fallback;
3891FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmaxud_u128, iemAImpl_vpmaxud_u128_fallback;
3892FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmaxsb_u128, iemAImpl_vpmaxsb_u128_fallback;
3893FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmaxsw_u128, iemAImpl_vpmaxsw_u128_fallback;
3894FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmaxsd_u128, iemAImpl_vpmaxsd_u128_fallback;
3895FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpacksswb_u128, iemAImpl_vpacksswb_u128_fallback;
3896FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpackssdw_u128, iemAImpl_vpackssdw_u128_fallback;
3897FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpackuswb_u128, iemAImpl_vpackuswb_u128_fallback;
3898FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpackusdw_u128, iemAImpl_vpackusdw_u128_fallback;
3899FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmullw_u128, iemAImpl_vpmullw_u128_fallback;
3900FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmulld_u128, iemAImpl_vpmulld_u128_fallback;
3901FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmulhw_u128, iemAImpl_vpmulhw_u128_fallback;
3902FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmulhuw_u128, iemAImpl_vpmulhuw_u128_fallback;
3903FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpavgb_u128, iemAImpl_vpavgb_u128_fallback;
3904FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpavgw_u128, iemAImpl_vpavgw_u128_fallback;
3905FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsignb_u128, iemAImpl_vpsignb_u128_fallback;
3906FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsignw_u128, iemAImpl_vpsignw_u128_fallback;
3907FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsignd_u128, iemAImpl_vpsignd_u128_fallback;
3908FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vphaddw_u128, iemAImpl_vphaddw_u128_fallback;
3909FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vphaddd_u128, iemAImpl_vphaddd_u128_fallback;
3910FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vphsubw_u128, iemAImpl_vphsubw_u128_fallback;
3911FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vphsubd_u128, iemAImpl_vphsubd_u128_fallback;
3912FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vphaddsw_u128, iemAImpl_vphaddsw_u128_fallback;
3913FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vphsubsw_u128, iemAImpl_vphsubsw_u128_fallback;
3914FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmaddubsw_u128, iemAImpl_vpmaddubsw_u128_fallback;
3915FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmulhrsw_u128, iemAImpl_vpmulhrsw_u128_fallback;
3916FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsadbw_u128, iemAImpl_vpsadbw_u128_fallback;
3917FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmuldq_u128, iemAImpl_vpmuldq_u128_fallback;
3918FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmuludq_u128, iemAImpl_vpmuludq_u128_fallback;
3919FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsubsb_u128, iemAImpl_vpsubsb_u128_fallback;
3920FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsubsw_u128, iemAImpl_vpsubsw_u128_fallback;
3921FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsubusb_u128, iemAImpl_vpsubusb_u128_fallback;
3922FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsubusw_u128, iemAImpl_vpsubusw_u128_fallback;
3923FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpaddusb_u128, iemAImpl_vpaddusb_u128_fallback;
3924FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpaddusw_u128, iemAImpl_vpaddusw_u128_fallback;
3925FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpaddsb_u128, iemAImpl_vpaddsb_u128_fallback;
3926FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpaddsw_u128, iemAImpl_vpaddsw_u128_fallback;
3927FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsllw_u128, iemAImpl_vpsllw_u128_fallback;
3928FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpslld_u128, iemAImpl_vpslld_u128_fallback;
3929FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsllq_u128, iemAImpl_vpsllq_u128_fallback;
3930FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsraw_u128, iemAImpl_vpsraw_u128_fallback;
3931FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsrad_u128, iemAImpl_vpsrad_u128_fallback;
3932FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsrlw_u128, iemAImpl_vpsrlw_u128_fallback;
3933FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsrld_u128, iemAImpl_vpsrld_u128_fallback;
3934FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsrlq_u128, iemAImpl_vpsrlq_u128_fallback;
3935FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmaddwd_u128, iemAImpl_vpmaddwd_u128_fallback;
3936
3937FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_vpabsb_u128, iemAImpl_vpabsb_u128_fallback;
3938FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_vpabsw_u128, iemAImpl_vpabsd_u128_fallback;
3939FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_vpabsd_u128, iemAImpl_vpabsw_u128_fallback;
3940FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_vphminposuw_u128, iemAImpl_vphminposuw_u128_fallback;
3941
3942FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpshufb_u256, iemAImpl_vpshufb_u256_fallback;
3943FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpand_u256, iemAImpl_vpand_u256_fallback;
3944FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpandn_u256, iemAImpl_vpandn_u256_fallback;
3945FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpor_u256, iemAImpl_vpor_u256_fallback;
3946FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpxor_u256, iemAImpl_vpxor_u256_fallback;
3947FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpcmpeqb_u256, iemAImpl_vpcmpeqb_u256_fallback;
3948FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpcmpeqw_u256, iemAImpl_vpcmpeqw_u256_fallback;
3949FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpcmpeqd_u256, iemAImpl_vpcmpeqd_u256_fallback;
3950FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpcmpeqq_u256, iemAImpl_vpcmpeqq_u256_fallback;
3951FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpcmpgtb_u256, iemAImpl_vpcmpgtb_u256_fallback;
3952FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpcmpgtw_u256, iemAImpl_vpcmpgtw_u256_fallback;
3953FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpcmpgtd_u256, iemAImpl_vpcmpgtd_u256_fallback;
3954FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpcmpgtq_u256, iemAImpl_vpcmpgtq_u256_fallback;
3955FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpaddb_u256, iemAImpl_vpaddb_u256_fallback;
3956FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpaddw_u256, iemAImpl_vpaddw_u256_fallback;
3957FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpaddd_u256, iemAImpl_vpaddd_u256_fallback;
3958FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpaddq_u256, iemAImpl_vpaddq_u256_fallback;
3959FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsubb_u256, iemAImpl_vpsubb_u256_fallback;
3960FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsubw_u256, iemAImpl_vpsubw_u256_fallback;
3961FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsubd_u256, iemAImpl_vpsubd_u256_fallback;
3962FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsubq_u256, iemAImpl_vpsubq_u256_fallback;
3963FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpminub_u256, iemAImpl_vpminub_u256_fallback;
3964FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpminuw_u256, iemAImpl_vpminuw_u256_fallback;
3965FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpminud_u256, iemAImpl_vpminud_u256_fallback;
3966FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpminsb_u256, iemAImpl_vpminsb_u256_fallback;
3967FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpminsw_u256, iemAImpl_vpminsw_u256_fallback;
3968FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpminsd_u256, iemAImpl_vpminsd_u256_fallback;
3969FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmaxub_u256, iemAImpl_vpmaxub_u256_fallback;
3970FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmaxuw_u256, iemAImpl_vpmaxuw_u256_fallback;
3971FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmaxud_u256, iemAImpl_vpmaxud_u256_fallback;
3972FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmaxsb_u256, iemAImpl_vpmaxsb_u256_fallback;
3973FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmaxsw_u256, iemAImpl_vpmaxsw_u256_fallback;
3974FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmaxsd_u256, iemAImpl_vpmaxsd_u256_fallback;
3975FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpacksswb_u256, iemAImpl_vpacksswb_u256_fallback;
3976FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpackssdw_u256, iemAImpl_vpackssdw_u256_fallback;
3977FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpackuswb_u256, iemAImpl_vpackuswb_u256_fallback;
3978FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpackusdw_u256, iemAImpl_vpackusdw_u256_fallback;
3979FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmullw_u256, iemAImpl_vpmullw_u256_fallback;
3980FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmulld_u256, iemAImpl_vpmulld_u256_fallback;
3981FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmulhw_u256, iemAImpl_vpmulhw_u256_fallback;
3982FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmulhuw_u256, iemAImpl_vpmulhuw_u256_fallback;
3983FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpavgb_u256, iemAImpl_vpavgb_u256_fallback;
3984FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpavgw_u256, iemAImpl_vpavgw_u256_fallback;
3985FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsignb_u256, iemAImpl_vpsignb_u256_fallback;
3986FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsignw_u256, iemAImpl_vpsignw_u256_fallback;
3987FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsignd_u256, iemAImpl_vpsignd_u256_fallback;
3988FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vphaddw_u256, iemAImpl_vphaddw_u256_fallback;
3989FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vphaddd_u256, iemAImpl_vphaddd_u256_fallback;
3990FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vphsubw_u256, iemAImpl_vphsubw_u256_fallback;
3991FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vphsubd_u256, iemAImpl_vphsubd_u256_fallback;
3992FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vphaddsw_u256, iemAImpl_vphaddsw_u256_fallback;
3993FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vphsubsw_u256, iemAImpl_vphsubsw_u256_fallback;
3994FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmaddubsw_u256, iemAImpl_vpmaddubsw_u256_fallback;
3995FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmulhrsw_u256, iemAImpl_vpmulhrsw_u256_fallback;
3996FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsadbw_u256, iemAImpl_vpsadbw_u256_fallback;
3997FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmuldq_u256, iemAImpl_vpmuldq_u256_fallback;
3998FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmuludq_u256, iemAImpl_vpmuludq_u256_fallback;
3999FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsubsb_u256, iemAImpl_vpsubsb_u256_fallback;
4000FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsubsw_u256, iemAImpl_vpsubsw_u256_fallback;
4001FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsubusb_u256, iemAImpl_vpsubusb_u256_fallback;
4002FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsubusw_u256, iemAImpl_vpsubusw_u256_fallback;
4003FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpaddusb_u256, iemAImpl_vpaddusb_u256_fallback;
4004FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpaddusw_u256, iemAImpl_vpaddusw_u256_fallback;
4005FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpaddsb_u256, iemAImpl_vpaddsb_u256_fallback;
4006FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpaddsw_u256, iemAImpl_vpaddsw_u256_fallback;
4007FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsllw_u256, iemAImpl_vpsllw_u256_fallback;
4008FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpslld_u256, iemAImpl_vpslld_u256_fallback;
4009FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsllq_u256, iemAImpl_vpsllq_u256_fallback;
4010FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsraw_u256, iemAImpl_vpsraw_u256_fallback;
4011FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsrad_u256, iemAImpl_vpsrad_u256_fallback;
4012FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsrlw_u256, iemAImpl_vpsrlw_u256_fallback;
4013FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsrld_u256, iemAImpl_vpsrld_u256_fallback;
4014FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsrlq_u256, iemAImpl_vpsrlq_u256_fallback;
4015FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmaddwd_u256, iemAImpl_vpmaddwd_u256_fallback;
4016FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpermps_u256, iemAImpl_vpermps_u256_fallback;
4017FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpermd_u256, iemAImpl_vpermd_u256_fallback;
4018
4019FNIEMAIMPLMEDIAOPTF2U256 iemAImpl_vpabsb_u256, iemAImpl_vpabsb_u256_fallback;
4020FNIEMAIMPLMEDIAOPTF2U256 iemAImpl_vpabsw_u256, iemAImpl_vpabsw_u256_fallback;
4021FNIEMAIMPLMEDIAOPTF2U256 iemAImpl_vpabsd_u256, iemAImpl_vpabsd_u256_fallback;
4022/** @} */
4023
4024/** @name Media (SSE/MMX/AVX) operations: lowhalf1 + lowhalf1 -> full1.
4025 * @{ */
4026FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_punpcklbw_u64, iemAImpl_punpcklwd_u64, iemAImpl_punpckldq_u64;
4027FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_punpcklbw_u128, iemAImpl_punpcklwd_u128, iemAImpl_punpckldq_u128, iemAImpl_punpcklqdq_u128;
4028FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpunpcklbw_u128, iemAImpl_vpunpcklbw_u128_fallback,
4029 iemAImpl_vpunpcklwd_u128, iemAImpl_vpunpcklwd_u128_fallback,
4030 iemAImpl_vpunpckldq_u128, iemAImpl_vpunpckldq_u128_fallback,
4031 iemAImpl_vpunpcklqdq_u128, iemAImpl_vpunpcklqdq_u128_fallback,
4032 iemAImpl_vunpcklps_u128, iemAImpl_vunpcklps_u128_fallback,
4033 iemAImpl_vunpcklpd_u128, iemAImpl_vunpcklpd_u128_fallback,
4034 iemAImpl_vunpckhps_u128, iemAImpl_vunpckhps_u128_fallback,
4035 iemAImpl_vunpckhpd_u128, iemAImpl_vunpckhpd_u128_fallback;
4036
4037FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpunpcklbw_u256, iemAImpl_vpunpcklbw_u256_fallback,
4038 iemAImpl_vpunpcklwd_u256, iemAImpl_vpunpcklwd_u256_fallback,
4039 iemAImpl_vpunpckldq_u256, iemAImpl_vpunpckldq_u256_fallback,
4040 iemAImpl_vpunpcklqdq_u256, iemAImpl_vpunpcklqdq_u256_fallback,
4041 iemAImpl_vunpcklps_u256, iemAImpl_vunpcklps_u256_fallback,
4042 iemAImpl_vunpcklpd_u256, iemAImpl_vunpcklpd_u256_fallback,
4043 iemAImpl_vunpckhps_u256, iemAImpl_vunpckhps_u256_fallback,
4044 iemAImpl_vunpckhpd_u256, iemAImpl_vunpckhpd_u256_fallback;
4045/** @} */
4046
4047/** @name Media (SSE/MMX/AVX) operations: hihalf1 + hihalf2 -> full1.
4048 * @{ */
4049FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_punpckhbw_u64, iemAImpl_punpckhwd_u64, iemAImpl_punpckhdq_u64;
4050FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_punpckhbw_u128, iemAImpl_punpckhwd_u128, iemAImpl_punpckhdq_u128, iemAImpl_punpckhqdq_u128;
4051FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpunpckhbw_u128, iemAImpl_vpunpckhbw_u128_fallback,
4052 iemAImpl_vpunpckhwd_u128, iemAImpl_vpunpckhwd_u128_fallback,
4053 iemAImpl_vpunpckhdq_u128, iemAImpl_vpunpckhdq_u128_fallback,
4054 iemAImpl_vpunpckhqdq_u128, iemAImpl_vpunpckhqdq_u128_fallback;
4055FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpunpckhbw_u256, iemAImpl_vpunpckhbw_u256_fallback,
4056 iemAImpl_vpunpckhwd_u256, iemAImpl_vpunpckhwd_u256_fallback,
4057 iemAImpl_vpunpckhdq_u256, iemAImpl_vpunpckhdq_u256_fallback,
4058 iemAImpl_vpunpckhqdq_u256, iemAImpl_vpunpckhqdq_u256_fallback;
4059/** @} */
4060
4061/** @name Media (SSE/MMX/AVX) operation: Packed Shuffle Stuff (evil)
4062 * @{ */
4063typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAPSHUFU128,(PRTUINT128U puDst, PCRTUINT128U puSrc, uint8_t bEvil));
4064typedef FNIEMAIMPLMEDIAPSHUFU128 *PFNIEMAIMPLMEDIAPSHUFU128;
4065typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAPSHUFU256,(PRTUINT256U puDst, PCRTUINT256U puSrc, uint8_t bEvil));
4066typedef FNIEMAIMPLMEDIAPSHUFU256 *PFNIEMAIMPLMEDIAPSHUFU256;
4067IEM_DECL_IMPL_DEF(void, iemAImpl_pshufw_u64,(uint64_t *puDst, uint64_t const *puSrc, uint8_t bEvil));
4068FNIEMAIMPLMEDIAPSHUFU128 iemAImpl_pshufhw_u128, iemAImpl_pshuflw_u128, iemAImpl_pshufd_u128;
4069#ifndef IEM_WITHOUT_ASSEMBLY
4070FNIEMAIMPLMEDIAPSHUFU256 iemAImpl_vpshufhw_u256, iemAImpl_vpshuflw_u256, iemAImpl_vpshufd_u256;
4071#endif
4072FNIEMAIMPLMEDIAPSHUFU256 iemAImpl_vpshufhw_u256_fallback, iemAImpl_vpshuflw_u256_fallback, iemAImpl_vpshufd_u256_fallback;
4073/** @} */
4074
4075/** @name Media (SSE/MMX/AVX) operation: Shift Immediate Stuff (evil)
4076 * @{ */
4077typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAPSHIFTU64,(uint64_t *puDst, uint8_t bShift));
4078typedef FNIEMAIMPLMEDIAPSHIFTU64 *PFNIEMAIMPLMEDIAPSHIFTU64;
4079typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAPSHIFTU128,(PRTUINT128U puDst, uint8_t bShift));
4080typedef FNIEMAIMPLMEDIAPSHIFTU128 *PFNIEMAIMPLMEDIAPSHIFTU128;
4081typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAPSHIFTU256,(PRTUINT256U puDst, uint8_t bShift));
4082typedef FNIEMAIMPLMEDIAPSHIFTU256 *PFNIEMAIMPLMEDIAPSHIFTU256;
4083FNIEMAIMPLMEDIAPSHIFTU64 iemAImpl_psllw_imm_u64, iemAImpl_pslld_imm_u64, iemAImpl_psllq_imm_u64;
4084FNIEMAIMPLMEDIAPSHIFTU64 iemAImpl_psrlw_imm_u64, iemAImpl_psrld_imm_u64, iemAImpl_psrlq_imm_u64;
4085FNIEMAIMPLMEDIAPSHIFTU64 iemAImpl_psraw_imm_u64, iemAImpl_psrad_imm_u64;
4086FNIEMAIMPLMEDIAPSHIFTU128 iemAImpl_psllw_imm_u128, iemAImpl_pslld_imm_u128, iemAImpl_psllq_imm_u128;
4087FNIEMAIMPLMEDIAPSHIFTU128 iemAImpl_psrlw_imm_u128, iemAImpl_psrld_imm_u128, iemAImpl_psrlq_imm_u128;
4088FNIEMAIMPLMEDIAPSHIFTU128 iemAImpl_psraw_imm_u128, iemAImpl_psrad_imm_u128;
4089FNIEMAIMPLMEDIAPSHIFTU128 iemAImpl_pslldq_imm_u128, iemAImpl_psrldq_imm_u128;
4090/** @} */
4091
4092/** @name Media (SSE/MMX/AVX) operation: Move Byte Mask
4093 * @{ */
4094IEM_DECL_IMPL_DEF(void, iemAImpl_maskmovq_u64,(uint64_t *puMem, uint64_t const *puSrc, uint64_t const *puMsk));
4095IEM_DECL_IMPL_DEF(void, iemAImpl_maskmovdqu_u128,(PRTUINT128U puMem, PCRTUINT128U puSrc, PCRTUINT128U puMsk));
4096IEM_DECL_IMPL_DEF(void, iemAImpl_pmovmskb_u64,(uint64_t *pu64Dst, uint64_t const *puSrc));
4097IEM_DECL_IMPL_DEF(void, iemAImpl_pmovmskb_u128,(uint64_t *pu64Dst, PCRTUINT128U puSrc));
4098#ifndef IEM_WITHOUT_ASSEMBLY
4099IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovmskb_u256,(uint64_t *pu64Dst, PCRTUINT256U puSrc));
4100#endif
4101IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovmskb_u256_fallback,(uint64_t *pu64Dst, PCRTUINT256U puSrc));
4102/** @} */
4103
4104/** @name Media (SSE/MMX/AVX) operations: Variable Blend Packed Bytes/R32/R64.
4105 * @{ */
4106typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBLENDU128,(PRTUINT128U puDst, PCRTUINT128U puSrc, PCRTUINT128U puMask));
4107typedef FNIEMAIMPLBLENDU128 *PFNIEMAIMPLBLENDU128;
4108typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLAVXBLENDU128,(PRTUINT128U puDst, PCRTUINT128U puSrc1, PCRTUINT128U puSrc2, PCRTUINT128U puMask));
4109typedef FNIEMAIMPLAVXBLENDU128 *PFNIEMAIMPLAVXBLENDU128;
4110typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLAVXBLENDU256,(PRTUINT256U puDst, PCRTUINT256U puSrc1, PCRTUINT256U puSrc2, PCRTUINT256U puMask));
4111typedef FNIEMAIMPLAVXBLENDU256 *PFNIEMAIMPLAVXBLENDU256;
4112
4113FNIEMAIMPLBLENDU128 iemAImpl_pblendvb_u128;
4114FNIEMAIMPLBLENDU128 iemAImpl_pblendvb_u128_fallback;
4115FNIEMAIMPLAVXBLENDU128 iemAImpl_vpblendvb_u128;
4116FNIEMAIMPLAVXBLENDU128 iemAImpl_vpblendvb_u128_fallback;
4117FNIEMAIMPLAVXBLENDU256 iemAImpl_vpblendvb_u256;
4118FNIEMAIMPLAVXBLENDU256 iemAImpl_vpblendvb_u256_fallback;
4119
4120FNIEMAIMPLBLENDU128 iemAImpl_blendvps_u128;
4121FNIEMAIMPLBLENDU128 iemAImpl_blendvps_u128_fallback;
4122FNIEMAIMPLAVXBLENDU128 iemAImpl_vblendvps_u128;
4123FNIEMAIMPLAVXBLENDU128 iemAImpl_vblendvps_u128_fallback;
4124FNIEMAIMPLAVXBLENDU256 iemAImpl_vblendvps_u256;
4125FNIEMAIMPLAVXBLENDU256 iemAImpl_vblendvps_u256_fallback;
4126
4127FNIEMAIMPLBLENDU128 iemAImpl_blendvpd_u128;
4128FNIEMAIMPLBLENDU128 iemAImpl_blendvpd_u128_fallback;
4129FNIEMAIMPLAVXBLENDU128 iemAImpl_vblendvpd_u128;
4130FNIEMAIMPLAVXBLENDU128 iemAImpl_vblendvpd_u128_fallback;
4131FNIEMAIMPLAVXBLENDU256 iemAImpl_vblendvpd_u256;
4132FNIEMAIMPLAVXBLENDU256 iemAImpl_vblendvpd_u256_fallback;
4133/** @} */
4134
4135
4136/** @name Media (SSE/MMX/AVX) operation: Sort this later
4137 * @{ */
4138IEM_DECL_IMPL_DEF(void, iemAImpl_pmovsxbw_u128,(PRTUINT128U puDst, uint64_t uSrc));
4139IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxbw_u128,(PRTUINT128U puDst, uint64_t uSrc));
4140IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxbw_u128_fallback,(PRTUINT128U puDst, uint64_t uSrc));
4141IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxbw_u256,(PRTUINT256U puDst, PCRTUINT128U puSrc));
4142IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxbw_u256_fallback,(PRTUINT256U puDst, PCRTUINT128U puSrc));
4143
4144IEM_DECL_IMPL_DEF(void, iemAImpl_pmovsxbd_u128,(PRTUINT128U puDst, uint32_t uSrc));
4145IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxbd_u128,(PRTUINT128U puDst, uint32_t uSrc));
4146IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxbd_u128_fallback,(PRTUINT128U puDst, uint32_t uSrc));
4147IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxbd_u256,(PRTUINT256U puDst, PCRTUINT128U puSrc));
4148IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxbd_u256_fallback,(PRTUINT256U puDst, PCRTUINT128U puSrc));
4149
4150IEM_DECL_IMPL_DEF(void, iemAImpl_pmovsxbq_u128,(PRTUINT128U puDst, uint16_t uSrc));
4151IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxbq_u128,(PRTUINT128U puDst, uint16_t uSrc));
4152IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxbq_u128_fallback,(PRTUINT128U puDst, uint16_t uSrc));
4153IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxbq_u256,(PRTUINT256U puDst, PCRTUINT128U puSrc));
4154IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxbq_u256_fallback,(PRTUINT256U puDst, PCRTUINT128U puSrc));
4155
4156IEM_DECL_IMPL_DEF(void, iemAImpl_pmovsxwd_u128,(PRTUINT128U puDst, uint64_t uSrc));
4157IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxwd_u128,(PRTUINT128U puDst, uint64_t uSrc));
4158IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxwd_u128_fallback,(PRTUINT128U puDst, uint64_t uSrc));
4159IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxwd_u256,(PRTUINT256U puDst, PCRTUINT128U puSrc));
4160IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxwd_u256_fallback,(PRTUINT256U puDst, PCRTUINT128U puSrc));
4161
4162IEM_DECL_IMPL_DEF(void, iemAImpl_pmovsxwq_u128,(PRTUINT128U puDst, uint32_t uSrc));
4163IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxwq_u128,(PRTUINT128U puDst, uint32_t uSrc));
4164IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxwq_u128_fallback,(PRTUINT128U puDst, uint32_t uSrc));
4165IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxwq_u256,(PRTUINT256U puDst, PCRTUINT128U puSrc));
4166IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxwq_u256_fallback,(PRTUINT256U puDst, PCRTUINT128U puSrc));
4167
4168IEM_DECL_IMPL_DEF(void, iemAImpl_pmovsxdq_u128,(PRTUINT128U puDst, uint64_t uSrc));
4169IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxdq_u128,(PRTUINT128U puDst, uint64_t uSrc));
4170IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxdq_u128_fallback,(PRTUINT128U puDst, uint64_t uSrc));
4171IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxdq_u256,(PRTUINT256U puDst, PCRTUINT128U puSrc));
4172IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxdq_u256_fallback,(PRTUINT256U puDst, PCRTUINT128U puSrc));
4173
4174IEM_DECL_IMPL_DEF(void, iemAImpl_pmovzxbw_u128,(PRTUINT128U puDst, uint64_t uSrc));
4175IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxbw_u128,(PRTUINT128U puDst, uint64_t uSrc));
4176IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxbw_u128_fallback,(PRTUINT128U puDst, uint64_t uSrc));
4177IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxbw_u256,(PRTUINT256U puDst, PCRTUINT128U puSrc));
4178IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxbw_u256_fallback,(PRTUINT256U puDst, PCRTUINT128U puSrc));
4179
4180IEM_DECL_IMPL_DEF(void, iemAImpl_pmovzxbd_u128,(PRTUINT128U puDst, uint32_t uSrc));
4181IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxbd_u128,(PRTUINT128U puDst, uint32_t uSrc));
4182IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxbd_u128_fallback,(PRTUINT128U puDst, uint32_t uSrc));
4183IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxbd_u256,(PRTUINT256U puDst, PCRTUINT128U puSrc));
4184IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxbd_u256_fallback,(PRTUINT256U puDst, PCRTUINT128U puSrc));
4185
4186IEM_DECL_IMPL_DEF(void, iemAImpl_pmovzxbq_u128,(PRTUINT128U puDst, uint16_t uSrc));
4187IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxbq_u128,(PRTUINT128U puDst, uint16_t uSrc));
4188IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxbq_u128_fallback,(PRTUINT128U puDst, uint16_t uSrc));
4189IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxbq_u256,(PRTUINT256U puDst, PCRTUINT128U puSrc));
4190IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxbq_u256_fallback,(PRTUINT256U puDst, PCRTUINT128U puSrc));
4191
4192IEM_DECL_IMPL_DEF(void, iemAImpl_pmovzxwd_u128,(PRTUINT128U puDst, uint64_t uSrc));
4193IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxwd_u128,(PRTUINT128U puDst, uint64_t uSrc));
4194IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxwd_u128_fallback,(PRTUINT128U puDst, uint64_t uSrc));
4195IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxwd_u256,(PRTUINT256U puDst, PCRTUINT128U puSrc));
4196IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxwd_u256_fallback,(PRTUINT256U puDst, PCRTUINT128U puSrc));
4197
4198IEM_DECL_IMPL_DEF(void, iemAImpl_pmovzxwq_u128,(PRTUINT128U puDst, uint32_t uSrc));
4199IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxwq_u128,(PRTUINT128U puDst, uint32_t uSrc));
4200IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxwq_u128_fallback,(PRTUINT128U puDst, uint32_t uSrc));
4201IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxwq_u256,(PRTUINT256U puDst, PCRTUINT128U puSrc));
4202IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxwq_u256_fallback,(PRTUINT256U puDst, PCRTUINT128U puSrc));
4203
4204IEM_DECL_IMPL_DEF(void, iemAImpl_pmovzxdq_u128,(PRTUINT128U puDst, uint64_t uSrc));
4205IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxdq_u128,(PRTUINT128U puDst, uint64_t uSrc));
4206IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxdq_u128_fallback,(PRTUINT128U puDst, uint64_t uSrc));
4207IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxdq_u256,(PRTUINT256U puDst, PCRTUINT128U puSrc));
4208IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxdq_u256_fallback,(PRTUINT256U puDst, PCRTUINT128U puSrc));
4209
4210IEM_DECL_IMPL_DEF(void, iemAImpl_shufpd_u128,(PRTUINT128U puDst, PCRTUINT128U puSrc, uint8_t bEvil));
4211IEM_DECL_IMPL_DEF(void, iemAImpl_vshufpd_u128,(PRTUINT128U puDst, PCRTUINT128U puSrc1, PCRTUINT128U puSrc2, uint8_t bEvil));
4212IEM_DECL_IMPL_DEF(void, iemAImpl_vshufpd_u128_fallback,(PRTUINT128U puDst, PCRTUINT128U puSrc1, PCRTUINT128U puSrc2, uint8_t bEvil));
4213IEM_DECL_IMPL_DEF(void, iemAImpl_vshufpd_u256,(PRTUINT256U puDst, PCRTUINT256U puSrc1, PCRTUINT256U puSrc2, uint8_t bEvil));
4214IEM_DECL_IMPL_DEF(void, iemAImpl_vshufpd_u256_fallback,(PRTUINT256U puDst, PCRTUINT256U puSrc1, PCRTUINT256U puSrc2, uint8_t bEvil));
4215
4216IEM_DECL_IMPL_DEF(void, iemAImpl_shufps_u128,(PRTUINT128U puDst, PCRTUINT128U puSrc, uint8_t bEvil));
4217IEM_DECL_IMPL_DEF(void, iemAImpl_vshufps_u128,(PRTUINT128U puDst, PCRTUINT128U puSrc1, PCRTUINT128U puSrc2, uint8_t bEvil));
4218IEM_DECL_IMPL_DEF(void, iemAImpl_vshufps_u128_fallback,(PRTUINT128U puDst, PCRTUINT128U puSrc1, PCRTUINT128U puSrc2, uint8_t bEvil));
4219IEM_DECL_IMPL_DEF(void, iemAImpl_vshufps_u256,(PRTUINT256U puDst, PCRTUINT256U puSrc1, PCRTUINT256U puSrc2, uint8_t bEvil));
4220IEM_DECL_IMPL_DEF(void, iemAImpl_vshufps_u256_fallback,(PRTUINT256U puDst, PCRTUINT256U puSrc1, PCRTUINT256U puSrc2, uint8_t bEvil));
4221
4222IEM_DECL_IMPL_DEF(void, iemAImpl_palignr_u64,(uint64_t *pu64Dst, uint64_t u64Src, uint8_t bEvil));
4223IEM_DECL_IMPL_DEF(void, iemAImpl_palignr_u64_fallback,(uint64_t *pu64Dst, uint64_t u64Src, uint8_t bEvil));
4224
4225IEM_DECL_IMPL_DEF(void, iemAImpl_movmskps_u128,(uint8_t *pu8Dst, PCRTUINT128U puSrc));
4226IEM_DECL_IMPL_DEF(void, iemAImpl_vmovmskps_u128,(uint8_t *pu8Dst, PCRTUINT128U puSrc));
4227IEM_DECL_IMPL_DEF(void, iemAImpl_vmovmskps_u128_fallback,(uint8_t *pu8Dst, PCRTUINT128U puSrc));
4228IEM_DECL_IMPL_DEF(void, iemAImpl_vmovmskps_u256,(uint8_t *pu8Dst, PCRTUINT256U puSrc));
4229IEM_DECL_IMPL_DEF(void, iemAImpl_vmovmskps_u256_fallback,(uint8_t *pu8Dst, PCRTUINT256U puSrc));
4230
4231IEM_DECL_IMPL_DEF(void, iemAImpl_movmskpd_u128,(uint8_t *pu8Dst, PCRTUINT128U puSrc));
4232IEM_DECL_IMPL_DEF(void, iemAImpl_vmovmskpd_u128,(uint8_t *pu8Dst, PCRTUINT128U puSrc));
4233IEM_DECL_IMPL_DEF(void, iemAImpl_vmovmskpd_u128_fallback,(uint8_t *pu8Dst, PCRTUINT128U puSrc));
4234IEM_DECL_IMPL_DEF(void, iemAImpl_vmovmskpd_u256,(uint8_t *pu8Dst, PCRTUINT256U puSrc));
4235IEM_DECL_IMPL_DEF(void, iemAImpl_vmovmskpd_u256_fallback,(uint8_t *pu8Dst, PCRTUINT256U puSrc));
4236
4237
4238typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAOPTF2U128IMM8,(PRTUINT128U puDst, PCRTUINT128U puSrc, uint8_t bEvil));
4239typedef FNIEMAIMPLMEDIAOPTF2U128IMM8 *PFNIEMAIMPLMEDIAOPTF2U128IMM8;
4240typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAOPTF2U256IMM8,(PRTUINT256U puDst, PCRTUINT256U puSrc, uint8_t bEvil));
4241typedef FNIEMAIMPLMEDIAOPTF2U256IMM8 *PFNIEMAIMPLMEDIAOPTF2U256IMM8;
4242typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAOPTF3U128IMM8,(PRTUINT128U puDst, PCRTUINT128U puSrc1, PCRTUINT128U puSrc2, uint8_t bEvil));
4243typedef FNIEMAIMPLMEDIAOPTF3U128IMM8 *PFNIEMAIMPLMEDIAOPTF3U128IMM8;
4244typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAOPTF3U256IMM8,(PRTUINT256U puDst, PCRTUINT256U puSrc1, PCRTUINT256U puSrc2, uint8_t bEvil));
4245typedef FNIEMAIMPLMEDIAOPTF3U256IMM8 *PFNIEMAIMPLMEDIAOPTF3U256IMM8;
4246
4247FNIEMAIMPLMEDIAOPTF2U128IMM8 iemAImpl_palignr_u128, iemAImpl_palignr_u128_fallback;
4248FNIEMAIMPLMEDIAOPTF2U128IMM8 iemAImpl_pblendw_u128, iemAImpl_pblendw_u128_fallback;
4249FNIEMAIMPLMEDIAOPTF2U128IMM8 iemAImpl_blendps_u128, iemAImpl_blendps_u128_fallback;
4250FNIEMAIMPLMEDIAOPTF2U128IMM8 iemAImpl_blendpd_u128, iemAImpl_blendpd_u128_fallback;
4251
4252FNIEMAIMPLMEDIAOPTF3U128IMM8 iemAImpl_vpalignr_u128, iemAImpl_vpalignr_u128_fallback;
4253FNIEMAIMPLMEDIAOPTF3U128IMM8 iemAImpl_vpblendw_u128, iemAImpl_vpblendw_u128_fallback;
4254FNIEMAIMPLMEDIAOPTF3U128IMM8 iemAImpl_vpblendd_u128, iemAImpl_vpblendd_u128_fallback;
4255FNIEMAIMPLMEDIAOPTF3U128IMM8 iemAImpl_vblendps_u128, iemAImpl_vblendps_u128_fallback;
4256FNIEMAIMPLMEDIAOPTF3U128IMM8 iemAImpl_vblendpd_u128, iemAImpl_vblendpd_u128_fallback;
4257
4258FNIEMAIMPLMEDIAOPTF3U256IMM8 iemAImpl_vpalignr_u256, iemAImpl_vpalignr_u256_fallback;
4259FNIEMAIMPLMEDIAOPTF3U256IMM8 iemAImpl_vpblendw_u256, iemAImpl_vpblendw_u256_fallback;
4260FNIEMAIMPLMEDIAOPTF3U256IMM8 iemAImpl_vpblendd_u256, iemAImpl_vpblendd_u256_fallback;
4261FNIEMAIMPLMEDIAOPTF3U256IMM8 iemAImpl_vblendps_u256, iemAImpl_vblendps_u256_fallback;
4262FNIEMAIMPLMEDIAOPTF3U256IMM8 iemAImpl_vblendpd_u256, iemAImpl_vblendpd_u256_fallback;
4263FNIEMAIMPLMEDIAOPTF3U256IMM8 iemAImpl_vperm2i128_u256, iemAImpl_vperm2i128_u256_fallback;
4264FNIEMAIMPLMEDIAOPTF3U256IMM8 iemAImpl_vperm2f128_u256, iemAImpl_vperm2f128_u256_fallback;
4265
4266FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_aesimc_u128, iemAImpl_aesimc_u128_fallback;
4267FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_aesenc_u128, iemAImpl_aesenc_u128_fallback;
4268FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_aesenclast_u128, iemAImpl_aesenclast_u128_fallback;
4269FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_aesdec_u128, iemAImpl_aesdec_u128_fallback;
4270FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_aesdeclast_u128, iemAImpl_aesdeclast_u128_fallback;
4271
4272FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_vaesimc_u128, iemAImpl_vaesimc_u128_fallback;
4273FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vaesenc_u128, iemAImpl_vaesenc_u128_fallback;
4274FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vaesenclast_u128, iemAImpl_vaesenclast_u128_fallback;
4275FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vaesdec_u128, iemAImpl_vaesdec_u128_fallback;
4276FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vaesdeclast_u128, iemAImpl_vaesdeclast_u128_fallback;
4277
4278FNIEMAIMPLMEDIAOPTF2U128IMM8 iemAImpl_aeskeygenassist_u128, iemAImpl_aeskeygenassist_u128_fallback;
4279
4280FNIEMAIMPLMEDIAOPTF2U128IMM8 iemAImpl_vaeskeygenassist_u128, iemAImpl_vaeskeygenassist_u128_fallback;
4281
4282FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_sha1nexte_u128, iemAImpl_sha1nexte_u128_fallback;
4283FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_sha1msg1_u128, iemAImpl_sha1msg1_u128_fallback;
4284FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_sha1msg2_u128, iemAImpl_sha1msg2_u128_fallback;
4285FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_sha256msg1_u128, iemAImpl_sha256msg1_u128_fallback;
4286FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_sha256msg2_u128, iemAImpl_sha256msg2_u128_fallback;
4287FNIEMAIMPLMEDIAOPTF2U128IMM8 iemAImpl_sha1rnds4_u128, iemAImpl_sha1rnds4_u128_fallback;
4288IEM_DECL_IMPL_DEF(void, iemAImpl_sha256rnds2_u128,(PRTUINT128U puDst, PCRTUINT128U puSrc, PCRTUINT128U puXmm0Constants));
4289IEM_DECL_IMPL_DEF(void, iemAImpl_sha256rnds2_u128_fallback,(PRTUINT128U puDst, PCRTUINT128U puSrc, PCRTUINT128U puXmm0Constants));
4290
4291FNIEMAIMPLMEDIAOPTF2U256IMM8 iemAImpl_vpermq_u256, iemAImpl_vpermq_u256_fallback;
4292FNIEMAIMPLMEDIAOPTF2U256IMM8 iemAImpl_vpermpd_u256, iemAImpl_vpermpd_u256_fallback;
4293
4294typedef struct IEMPCMPISTRXSRC
4295{
4296 RTUINT128U uSrc1;
4297 RTUINT128U uSrc2;
4298} IEMPCMPISTRXSRC;
4299typedef IEMPCMPISTRXSRC *PIEMPCMPISTRXSRC;
4300typedef const IEMPCMPISTRXSRC *PCIEMPCMPISTRXSRC;
4301
4302typedef struct IEMPCMPESTRXSRC
4303{
4304 RTUINT128U uSrc1;
4305 RTUINT128U uSrc2;
4306 uint64_t u64Rax;
4307 uint64_t u64Rdx;
4308} IEMPCMPESTRXSRC;
4309typedef IEMPCMPESTRXSRC *PIEMPCMPESTRXSRC;
4310typedef const IEMPCMPESTRXSRC *PCIEMPCMPESTRXSRC;
4311
4312typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLPCMPISTRIU128IMM8,(uint32_t *pEFlags, PCRTUINT128U pSrc1, PCRTUINT128U pSrc2, uint8_t bEvil));
4313typedef FNIEMAIMPLPCMPISTRIU128IMM8 *PFNIEMAIMPLPCMPISTRIU128IMM8;
4314typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLPCMPESTRIU128IMM8,(uint32_t *pu32Ecx, uint32_t *pEFlags, PCIEMPCMPESTRXSRC pSrc, uint8_t bEvil));
4315typedef FNIEMAIMPLPCMPESTRIU128IMM8 *PFNIEMAIMPLPCMPESTRIU128IMM8;
4316
4317typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLPCMPISTRMU128IMM8,(PRTUINT128U puDst, uint32_t *pEFlags, PCIEMPCMPISTRXSRC pSrc, uint8_t bEvil));
4318typedef FNIEMAIMPLPCMPISTRMU128IMM8 *PFNIEMAIMPLPCMPISTRMU128IMM8;
4319typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLPCMPESTRMU128IMM8,(PRTUINT128U puDst, uint32_t *pEFlags, PCIEMPCMPESTRXSRC pSrc, uint8_t bEvil));
4320typedef FNIEMAIMPLPCMPESTRMU128IMM8 *PFNIEMAIMPLPCMPESTRMU128IMM8;
4321
4322FNIEMAIMPLPCMPISTRIU128IMM8 iemAImpl_pcmpistri_u128, iemAImpl_pcmpistri_u128_fallback;
4323FNIEMAIMPLPCMPESTRIU128IMM8 iemAImpl_pcmpestri_u128, iemAImpl_pcmpestri_u128_fallback;
4324FNIEMAIMPLPCMPISTRMU128IMM8 iemAImpl_pcmpistrm_u128, iemAImpl_pcmpistrm_u128_fallback;
4325FNIEMAIMPLPCMPESTRMU128IMM8 iemAImpl_pcmpestrm_u128, iemAImpl_pcmpestrm_u128_fallback;
4326FNIEMAIMPLPCMPISTRIU128IMM8 iemAImpl_vpcmpistri_u128, iemAImpl_vpcmpistri_u128_fallback;
4327FNIEMAIMPLPCMPESTRIU128IMM8 iemAImpl_vpcmpestri_u128, iemAImpl_vpcmpestri_u128_fallback;
4328FNIEMAIMPLPCMPISTRMU128IMM8 iemAImpl_vpcmpistrm_u128, iemAImpl_vpcmpistrm_u128_fallback;
4329FNIEMAIMPLPCMPESTRMU128IMM8 iemAImpl_vpcmpestrm_u128, iemAImpl_vpcmpestrm_u128_fallback;
4330
4331
4332FNIEMAIMPLMEDIAOPTF2U128IMM8 iemAImpl_pclmulqdq_u128, iemAImpl_pclmulqdq_u128_fallback;
4333FNIEMAIMPLMEDIAOPTF3U128IMM8 iemAImpl_vpclmulqdq_u128, iemAImpl_vpclmulqdq_u128_fallback;
4334
4335FNIEMAIMPLMEDIAOPTF2U128IMM8 iemAImpl_mpsadbw_u128, iemAImpl_mpsadbw_u128_fallback;
4336FNIEMAIMPLMEDIAOPTF3U128IMM8 iemAImpl_vmpsadbw_u128, iemAImpl_vmpsadbw_u128_fallback;
4337FNIEMAIMPLMEDIAOPTF3U256IMM8 iemAImpl_vmpsadbw_u256, iemAImpl_vmpsadbw_u256_fallback;
4338
4339FNIEMAIMPLMEDIAPSHUFU128 iemAImpl_vpsllw_imm_u128, iemAImpl_vpsllw_imm_u128_fallback;
4340FNIEMAIMPLMEDIAPSHUFU256 iemAImpl_vpsllw_imm_u256, iemAImpl_vpsllw_imm_u256_fallback;
4341FNIEMAIMPLMEDIAPSHUFU128 iemAImpl_vpslld_imm_u128, iemAImpl_vpslld_imm_u128_fallback;
4342FNIEMAIMPLMEDIAPSHUFU256 iemAImpl_vpslld_imm_u256, iemAImpl_vpslld_imm_u256_fallback;
4343FNIEMAIMPLMEDIAPSHUFU128 iemAImpl_vpsllq_imm_u128, iemAImpl_vpsllq_imm_u128_fallback;
4344FNIEMAIMPLMEDIAPSHUFU256 iemAImpl_vpsllq_imm_u256, iemAImpl_vpsllq_imm_u256_fallback;
4345IEM_DECL_IMPL_DEF(void, iemAImpl_vpslldq_imm_u128,(PRTUINT128U puDst, PCRTUINT128U puSrc, uint8_t uShift));
4346IEM_DECL_IMPL_DEF(void, iemAImpl_vpslldq_imm_u128_fallback,(PRTUINT128U puDst, PCRTUINT128U puSrc, uint8_t uShift));
4347IEM_DECL_IMPL_DEF(void, iemAImpl_vpslldq_imm_u256,(PRTUINT256U puDst, PCRTUINT256U puSrc, uint8_t uShift));
4348IEM_DECL_IMPL_DEF(void, iemAImpl_vpslldq_imm_u256_fallback,(PRTUINT256U puDst, PCRTUINT256U puSrc, uint8_t uShift));
4349
4350FNIEMAIMPLMEDIAPSHUFU128 iemAImpl_vpsraw_imm_u128, iemAImpl_vpsraw_imm_u128_fallback;
4351FNIEMAIMPLMEDIAPSHUFU256 iemAImpl_vpsraw_imm_u256, iemAImpl_vpsraw_imm_u256_fallback;
4352FNIEMAIMPLMEDIAPSHUFU128 iemAImpl_vpsrad_imm_u128, iemAImpl_vpsrad_imm_u128_fallback;
4353FNIEMAIMPLMEDIAPSHUFU256 iemAImpl_vpsrad_imm_u256, iemAImpl_vpsrad_imm_u256_fallback;
4354
4355FNIEMAIMPLMEDIAPSHUFU128 iemAImpl_vpsrlw_imm_u128, iemAImpl_vpsrlw_imm_u128_fallback;
4356FNIEMAIMPLMEDIAPSHUFU256 iemAImpl_vpsrlw_imm_u256, iemAImpl_vpsrlw_imm_u256_fallback;
4357FNIEMAIMPLMEDIAPSHUFU128 iemAImpl_vpsrld_imm_u128, iemAImpl_vpsrld_imm_u128_fallback;
4358FNIEMAIMPLMEDIAPSHUFU256 iemAImpl_vpsrld_imm_u256, iemAImpl_vpsrld_imm_u256_fallback;
4359FNIEMAIMPLMEDIAPSHUFU128 iemAImpl_vpsrlq_imm_u128, iemAImpl_vpsrlq_imm_u128_fallback;
4360FNIEMAIMPLMEDIAPSHUFU256 iemAImpl_vpsrlq_imm_u256, iemAImpl_vpsrlq_imm_u256_fallback;
4361IEM_DECL_IMPL_DEF(void, iemAImpl_vpsrldq_imm_u128,(PRTUINT128U puDst, PCRTUINT128U puSrc, uint8_t uShift));
4362IEM_DECL_IMPL_DEF(void, iemAImpl_vpsrldq_imm_u128_fallback,(PRTUINT128U puDst, PCRTUINT128U puSrc, uint8_t uShift));
4363IEM_DECL_IMPL_DEF(void, iemAImpl_vpsrldq_imm_u256,(PRTUINT256U puDst, PCRTUINT256U puSrc, uint8_t uShift));
4364IEM_DECL_IMPL_DEF(void, iemAImpl_vpsrldq_imm_u256_fallback,(PRTUINT256U puDst, PCRTUINT256U puSrc, uint8_t uShift));
4365
4366FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpermilps_u128, iemAImpl_vpermilps_u128_fallback;
4367FNIEMAIMPLMEDIAOPTF2U128IMM8 iemAImpl_vpermilps_imm_u128, iemAImpl_vpermilps_imm_u128_fallback;
4368FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpermilps_u256, iemAImpl_vpermilps_u256_fallback;
4369FNIEMAIMPLMEDIAOPTF2U256IMM8 iemAImpl_vpermilps_imm_u256, iemAImpl_vpermilps_imm_u256_fallback;
4370
4371FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpermilpd_u128, iemAImpl_vpermilpd_u128_fallback;
4372FNIEMAIMPLMEDIAOPTF2U128IMM8 iemAImpl_vpermilpd_imm_u128, iemAImpl_vpermilpd_imm_u128_fallback;
4373FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpermilpd_u256, iemAImpl_vpermilpd_u256_fallback;
4374FNIEMAIMPLMEDIAOPTF2U256IMM8 iemAImpl_vpermilpd_imm_u256, iemAImpl_vpermilpd_imm_u256_fallback;
4375
4376FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsllvd_u128, iemAImpl_vpsllvd_u128_fallback;
4377FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsllvd_u256, iemAImpl_vpsllvd_u256_fallback;
4378FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsllvq_u128, iemAImpl_vpsllvq_u128_fallback;
4379FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsllvq_u256, iemAImpl_vpsllvq_u256_fallback;
4380FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsravd_u128, iemAImpl_vpsravd_u128_fallback;
4381FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsravd_u256, iemAImpl_vpsravd_u256_fallback;
4382FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsrlvd_u128, iemAImpl_vpsrlvd_u128_fallback;
4383FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsrlvd_u256, iemAImpl_vpsrlvd_u256_fallback;
4384FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsrlvq_u128, iemAImpl_vpsrlvq_u128_fallback;
4385FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsrlvq_u256, iemAImpl_vpsrlvq_u256_fallback;
4386/** @} */
4387
4388/** @name Media Odds and Ends
4389 * @{ */
4390typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLCR32U8,(uint32_t *puDst, uint8_t uSrc));
4391typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLCR32U16,(uint32_t *puDst, uint16_t uSrc));
4392typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLCR32U32,(uint32_t *puDst, uint32_t uSrc));
4393typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLCR32U64,(uint32_t *puDst, uint64_t uSrc));
4394FNIEMAIMPLCR32U8 iemAImpl_crc32_u8, iemAImpl_crc32_u8_fallback;
4395FNIEMAIMPLCR32U16 iemAImpl_crc32_u16, iemAImpl_crc32_u16_fallback;
4396FNIEMAIMPLCR32U32 iemAImpl_crc32_u32, iemAImpl_crc32_u32_fallback;
4397FNIEMAIMPLCR32U64 iemAImpl_crc32_u64, iemAImpl_crc32_u64_fallback;
4398
4399typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLF2EFL128,(PCRTUINT128U puSrc1, PCRTUINT128U puSrc2, uint32_t *pEFlags));
4400typedef FNIEMAIMPLF2EFL128 *PFNIEMAIMPLF2EFL128;
4401typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLF2EFL256,(PCRTUINT256U puSrc1, PCRTUINT256U puSrc2, uint32_t *pEFlags));
4402typedef FNIEMAIMPLF2EFL256 *PFNIEMAIMPLF2EFL256;
4403FNIEMAIMPLF2EFL128 iemAImpl_ptest_u128;
4404FNIEMAIMPLF2EFL256 iemAImpl_vptest_u256, iemAImpl_vptest_u256_fallback;
4405FNIEMAIMPLF2EFL128 iemAImpl_vtestps_u128, iemAImpl_vtestps_u128_fallback;
4406FNIEMAIMPLF2EFL256 iemAImpl_vtestps_u256, iemAImpl_vtestps_u256_fallback;
4407FNIEMAIMPLF2EFL128 iemAImpl_vtestpd_u128, iemAImpl_vtestpd_u128_fallback;
4408FNIEMAIMPLF2EFL256 iemAImpl_vtestpd_u256, iemAImpl_vtestpd_u256_fallback;
4409
4410typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLSSEF2I32U64,(uint32_t uMxCsrIn, int32_t *pi32Dst, const uint64_t *pu64Src)); /* pu64Src is a double precision floating point. */
4411typedef FNIEMAIMPLSSEF2I32U64 *PFNIEMAIMPLSSEF2I32U64;
4412typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLSSEF2I64U64,(uint32_t uMxCsrIn, int64_t *pi64Dst, const uint64_t *pu64Src)); /* pu64Src is a double precision floating point. */
4413typedef FNIEMAIMPLSSEF2I64U64 *PFNIEMAIMPLSSEF2I64U64;
4414typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLSSEF2I32U32,(uint32_t uMxCsrIn, int32_t *pi32Dst, const uint32_t *pu32Src)); /* pu32Src is a single precision floating point. */
4415typedef FNIEMAIMPLSSEF2I32U32 *PFNIEMAIMPLSSEF2I32U32;
4416typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLSSEF2I64U32,(uint32_t uMxCsrIn, int64_t *pi64Dst, const uint32_t *pu32Src)); /* pu32Src is a single precision floating point. */
4417typedef FNIEMAIMPLSSEF2I64U32 *PFNIEMAIMPLSSEF2I64U32;
4418typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLSSEF2I32R32,(uint32_t uMxCsrIn, int32_t *pi32Dst, PCRTFLOAT32U pr32Src));
4419typedef FNIEMAIMPLSSEF2I32R32 *PFNIEMAIMPLSSEF2I32R32;
4420typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLSSEF2I64R32,(uint32_t uMxCsrIn, int64_t *pi64Dst, PCRTFLOAT32U pr32Src));
4421typedef FNIEMAIMPLSSEF2I64R32 *PFNIEMAIMPLSSEF2I64R32;
4422typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLSSEF2I32R64,(uint32_t uMxCsrIn, int32_t *pi32Dst, PCRTFLOAT64U pr64Src));
4423typedef FNIEMAIMPLSSEF2I32R64 *PFNIEMAIMPLSSEF2I32R64;
4424typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLSSEF2I64R64,(uint32_t uMxCsrIn, int64_t *pi64Dst, PCRTFLOAT64U pr64Src));
4425typedef FNIEMAIMPLSSEF2I64R64 *PFNIEMAIMPLSSEF2I64R64;
4426
4427FNIEMAIMPLSSEF2I32U64 iemAImpl_cvttsd2si_i32_r64;
4428FNIEMAIMPLSSEF2I32U64 iemAImpl_cvtsd2si_i32_r64;
4429
4430FNIEMAIMPLSSEF2I64U64 iemAImpl_cvttsd2si_i64_r64;
4431FNIEMAIMPLSSEF2I64U64 iemAImpl_cvtsd2si_i64_r64;
4432
4433FNIEMAIMPLSSEF2I32U32 iemAImpl_cvttss2si_i32_r32;
4434FNIEMAIMPLSSEF2I32U32 iemAImpl_cvtss2si_i32_r32;
4435
4436FNIEMAIMPLSSEF2I64U32 iemAImpl_cvttss2si_i64_r32;
4437FNIEMAIMPLSSEF2I64U32 iemAImpl_cvtss2si_i64_r32;
4438
4439FNIEMAIMPLSSEF2I32R32 iemAImpl_vcvttss2si_i32_r32, iemAImpl_vcvttss2si_i32_r32_fallback;
4440FNIEMAIMPLSSEF2I64R32 iemAImpl_vcvttss2si_i64_r32, iemAImpl_vcvttss2si_i64_r32_fallback;
4441FNIEMAIMPLSSEF2I32R32 iemAImpl_vcvtss2si_i32_r32, iemAImpl_vcvtss2si_i32_r32_fallback;
4442FNIEMAIMPLSSEF2I64R32 iemAImpl_vcvtss2si_i64_r32, iemAImpl_vcvtss2si_i64_r32_fallback;
4443
4444FNIEMAIMPLSSEF2I32R64 iemAImpl_vcvttss2si_i32_r64, iemAImpl_vcvttss2si_i32_r64_fallback;
4445FNIEMAIMPLSSEF2I64R64 iemAImpl_vcvttss2si_i64_r64, iemAImpl_vcvttss2si_i64_r64_fallback;
4446FNIEMAIMPLSSEF2I32R64 iemAImpl_vcvtss2si_i32_r64, iemAImpl_vcvtss2si_i32_r64_fallback;
4447FNIEMAIMPLSSEF2I64R64 iemAImpl_vcvtss2si_i64_r64, iemAImpl_vcvtss2si_i64_r64_fallback;
4448
4449FNIEMAIMPLSSEF2I32R32 iemAImpl_vcvttsd2si_i32_r32, iemAImpl_vcvttsd2si_i32_r32_fallback;
4450FNIEMAIMPLSSEF2I64R32 iemAImpl_vcvttsd2si_i64_r32, iemAImpl_vcvttsd2si_i64_r32_fallback;
4451FNIEMAIMPLSSEF2I32R32 iemAImpl_vcvtsd2si_i32_r32, iemAImpl_vcvtsd2si_i32_r32_fallback;
4452FNIEMAIMPLSSEF2I64R32 iemAImpl_vcvtsd2si_i64_r32, iemAImpl_vcvtsd2si_i64_r32_fallback;
4453
4454FNIEMAIMPLSSEF2I32R64 iemAImpl_vcvttsd2si_i32_r64, iemAImpl_vcvttsd2si_i32_r64_fallback;
4455FNIEMAIMPLSSEF2I64R64 iemAImpl_vcvttsd2si_i64_r64, iemAImpl_vcvttsd2si_i64_r64_fallback;
4456FNIEMAIMPLSSEF2I32R64 iemAImpl_vcvtsd2si_i32_r64, iemAImpl_vcvtsd2si_i32_r64_fallback;
4457FNIEMAIMPLSSEF2I64R64 iemAImpl_vcvtsd2si_i64_r64, iemAImpl_vcvtsd2si_i64_r64_fallback;
4458
4459typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLSSEF2R32I32,(uint32_t uMxCsrIn, PRTFLOAT32U pr32Dst, const int32_t *pi32Src));
4460typedef FNIEMAIMPLSSEF2R32I32 *PFNIEMAIMPLSSEF2R32I32;
4461typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLSSEF2R32I64,(uint32_t uMxCsrIn, PRTFLOAT32U pr32Dst, const int64_t *pi64Src));
4462typedef FNIEMAIMPLSSEF2R32I64 *PFNIEMAIMPLSSEF2R32I64;
4463
4464FNIEMAIMPLSSEF2R32I32 iemAImpl_cvtsi2ss_r32_i32;
4465FNIEMAIMPLSSEF2R32I64 iemAImpl_cvtsi2ss_r32_i64;
4466
4467typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLAVXF3XMMI32,(uint32_t uMxCsrIn, PX86XMMREG puDst, PCX86XMMREG puSrc, const int32_t *pi32Src));
4468typedef FNIEMAIMPLAVXF3XMMI32 *PFNIEMAIMPLAVXF3XMMI32;
4469typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLAVXF3XMMI64,(uint32_t uMxCsrIn, PX86XMMREG puDst, PCX86XMMREG puSrc, const int64_t *pi64Src));
4470typedef FNIEMAIMPLAVXF3XMMI64 *PFNIEMAIMPLAVXF3XMMI64;
4471
4472FNIEMAIMPLAVXF3XMMI32 iemAImpl_vcvtsi2ss_u128_i32, iemAImpl_vcvtsi2ss_u128_i32_fallback;
4473FNIEMAIMPLAVXF3XMMI64 iemAImpl_vcvtsi2ss_u128_i64, iemAImpl_vcvtsi2ss_u128_i64_fallback;
4474
4475
4476typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLSSEF2R64I32,(uint32_t uMxCsrIn, PRTFLOAT64U pr64Dst, const int32_t *pi32Src));
4477typedef FNIEMAIMPLSSEF2R64I32 *PFNIEMAIMPLSSEF2R64I32;
4478typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLSSEF2R64I64,(uint32_t uMxCsrIn, PRTFLOAT64U pr64Dst, const int64_t *pi64Src));
4479typedef FNIEMAIMPLSSEF2R64I64 *PFNIEMAIMPLSSEF2R64I64;
4480
4481FNIEMAIMPLSSEF2R64I32 iemAImpl_cvtsi2sd_r64_i32;
4482FNIEMAIMPLSSEF2R64I64 iemAImpl_cvtsi2sd_r64_i64;
4483
4484FNIEMAIMPLAVXF3XMMI32 iemAImpl_vcvtsi2sd_u128_i32, iemAImpl_vcvtsi2sd_u128_i32_fallback;
4485FNIEMAIMPLAVXF3XMMI64 iemAImpl_vcvtsi2sd_u128_i64, iemAImpl_vcvtsi2sd_u128_i64_fallback;
4486
4487IEM_DECL_IMPL_DEF(uint32_t, iemAImpl_vcvtps2pd_u128_u64,(uint32_t uMxCsrIn, PX86XMMREG puDst, const uint64_t *pu64Src)); /* Actually two single precision floating point values. */
4488IEM_DECL_IMPL_DEF(uint32_t, iemAImpl_vcvtps2pd_u128_u64_fallback,(uint32_t uMxCsrIn, PX86XMMREG puDst, const uint64_t *pu64Src)); /* Actually two single precision floating point values. */
4489IEM_DECL_IMPL_DEF(uint32_t, iemAImpl_vcvtps2pd_u256_u128,(uint32_t uMxCsrIn, PX86YMMREG puDst, PCX86XMMREG puSrc));
4490IEM_DECL_IMPL_DEF(uint32_t, iemAImpl_vcvtps2pd_u256_u128_fallback,(uint32_t uMxCsrIn, PX86YMMREG puDst, PCX86XMMREG puSrc));
4491
4492
4493IEM_DECL_IMPL_DEF(uint32_t, iemAImpl_vcvtdq2pd_u128_u64,(uint32_t uMxCsrIn, PX86XMMREG puDst, const uint64_t *pu64Src)); /* Actually two single precision floating point values. */
4494IEM_DECL_IMPL_DEF(uint32_t, iemAImpl_vcvtdq2pd_u128_u64_fallback,(uint32_t uMxCsrIn, PX86XMMREG puDst, const uint64_t *pu64Src)); /* Actually two single precision floating point values. */
4495IEM_DECL_IMPL_DEF(uint32_t, iemAImpl_vcvtdq2pd_u256_u128,(uint32_t uMxCsrIn, PX86YMMREG puDst, PCX86XMMREG puSrc));
4496IEM_DECL_IMPL_DEF(uint32_t, iemAImpl_vcvtdq2pd_u256_u128_fallback,(uint32_t uMxCsrIn, PX86YMMREG puDst, PCX86XMMREG puSrc));
4497
4498
4499typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLF2EFLMXCSRR32R32,(uint32_t uMxCsrIn, uint32_t *pfEFlags, RTFLOAT32U uSrc1, RTFLOAT32U uSrc2));
4500typedef FNIEMAIMPLF2EFLMXCSRR32R32 *PFNIEMAIMPLF2EFLMXCSRR32R32;
4501
4502typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLF2EFLMXCSRR64R64,(uint32_t uMxCsrIn, uint32_t *pfEFlags, RTFLOAT64U uSrc1, RTFLOAT64U uSrc2));
4503typedef FNIEMAIMPLF2EFLMXCSRR64R64 *PFNIEMAIMPLF2EFLMXCSRR64R64;
4504
4505FNIEMAIMPLF2EFLMXCSRR32R32 iemAImpl_ucomiss_u128;
4506FNIEMAIMPLF2EFLMXCSRR32R32 iemAImpl_vucomiss_u128, iemAImpl_vucomiss_u128_fallback;
4507
4508FNIEMAIMPLF2EFLMXCSRR64R64 iemAImpl_ucomisd_u128;
4509FNIEMAIMPLF2EFLMXCSRR64R64 iemAImpl_vucomisd_u128, iemAImpl_vucomisd_u128_fallback;
4510
4511FNIEMAIMPLF2EFLMXCSRR32R32 iemAImpl_comiss_u128;
4512FNIEMAIMPLF2EFLMXCSRR32R32 iemAImpl_vcomiss_u128, iemAImpl_vcomiss_u128_fallback;
4513
4514FNIEMAIMPLF2EFLMXCSRR64R64 iemAImpl_comisd_u128;
4515FNIEMAIMPLF2EFLMXCSRR64R64 iemAImpl_vcomisd_u128, iemAImpl_vcomisd_u128_fallback;
4516
4517
4518typedef struct IEMMEDIAF2XMMSRC
4519{
4520 X86XMMREG uSrc1;
4521 X86XMMREG uSrc2;
4522} IEMMEDIAF2XMMSRC;
4523typedef IEMMEDIAF2XMMSRC *PIEMMEDIAF2XMMSRC;
4524typedef const IEMMEDIAF2XMMSRC *PCIEMMEDIAF2XMMSRC;
4525
4526
4527typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLMEDIAF3XMMIMM8,(uint32_t uMxCsrIn, PX86XMMREG puDst, PCIEMMEDIAF2XMMSRC puSrc, uint8_t bEvil));
4528typedef FNIEMAIMPLMEDIAF3XMMIMM8 *PFNIEMAIMPLMEDIAF3XMMIMM8;
4529
4530
4531typedef struct IEMMEDIAF2YMMSRC
4532{
4533 X86YMMREG uSrc1;
4534 X86YMMREG uSrc2;
4535} IEMMEDIAF2YMMSRC;
4536typedef IEMMEDIAF2YMMSRC *PIEMMEDIAF2YMMSRC;
4537typedef const IEMMEDIAF2YMMSRC *PCIEMMEDIAF2YMMSRC;
4538
4539
4540typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLMEDIAF3YMMIMM8,(uint32_t uMxCsrIn, PX86YMMREG puDst, PCIEMMEDIAF2YMMSRC puSrc, uint8_t bEvil));
4541typedef FNIEMAIMPLMEDIAF3YMMIMM8 *PFNIEMAIMPLMEDIAF3YMMIMM8;
4542
4543
4544FNIEMAIMPLMEDIAF3XMMIMM8 iemAImpl_cmpps_u128;
4545FNIEMAIMPLMEDIAF3XMMIMM8 iemAImpl_cmppd_u128;
4546FNIEMAIMPLMEDIAF3XMMIMM8 iemAImpl_cmpss_u128;
4547FNIEMAIMPLMEDIAF3XMMIMM8 iemAImpl_cmpsd_u128;
4548
4549FNIEMAIMPLMEDIAF3XMMIMM8 iemAImpl_vcmpps_u128, iemAImpl_vcmpps_u128_fallback;
4550FNIEMAIMPLMEDIAF3XMMIMM8 iemAImpl_vcmppd_u128, iemAImpl_vcmppd_u128_fallback;
4551FNIEMAIMPLMEDIAF3XMMIMM8 iemAImpl_vcmpss_u128, iemAImpl_vcmpss_u128_fallback;
4552FNIEMAIMPLMEDIAF3XMMIMM8 iemAImpl_vcmpsd_u128, iemAImpl_vcmpsd_u128_fallback;
4553
4554FNIEMAIMPLMEDIAF3YMMIMM8 iemAImpl_vcmpps_u256, iemAImpl_vcmpps_u256_fallback;
4555FNIEMAIMPLMEDIAF3YMMIMM8 iemAImpl_vcmppd_u256, iemAImpl_vcmppd_u256_fallback;
4556
4557FNIEMAIMPLMEDIAF3XMMIMM8 iemAImpl_roundss_u128;
4558FNIEMAIMPLMEDIAF3XMMIMM8 iemAImpl_roundsd_u128;
4559
4560FNIEMAIMPLMEDIAF3XMMIMM8 iemAImpl_dpps_u128, iemAImpl_dpps_u128_fallback;
4561FNIEMAIMPLMEDIAF3XMMIMM8 iemAImpl_dppd_u128, iemAImpl_dppd_u128_fallback;
4562
4563
4564typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLMEDIAF2U128IMM8,(uint32_t uMxCsrIn, PX86XMMREG puDst, PCX86XMMREG puSrc, uint8_t bEvil));
4565typedef FNIEMAIMPLMEDIAF2U128IMM8 *PFNIEMAIMPLMEDIAF2U128IMM8;
4566
4567
4568typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLMEDIAF2U256IMM8,(uint32_t uMxCsrIn, PX86YMMREG puDst, PCX86YMMREG puSrc, uint8_t bEvil));
4569typedef FNIEMAIMPLMEDIAF2U256IMM8 *PFNIEMAIMPLMEDIAF2U256IMM8;
4570
4571
4572FNIEMAIMPLMEDIAF2U128IMM8 iemAImpl_roundps_u128, iemAImpl_roundps_u128_fallback;
4573FNIEMAIMPLMEDIAF2U128IMM8 iemAImpl_roundpd_u128, iemAImpl_roundpd_u128_fallback;
4574
4575FNIEMAIMPLMEDIAF2U128IMM8 iemAImpl_vroundps_u128, iemAImpl_vroundps_u128_fallback;
4576FNIEMAIMPLMEDIAF2U128IMM8 iemAImpl_vroundpd_u128, iemAImpl_vroundpd_u128_fallback;
4577
4578FNIEMAIMPLMEDIAF2U256IMM8 iemAImpl_vroundps_u256, iemAImpl_vroundps_u256_fallback;
4579FNIEMAIMPLMEDIAF2U256IMM8 iemAImpl_vroundpd_u256, iemAImpl_vroundpd_u256_fallback;
4580
4581FNIEMAIMPLMEDIAF3XMMIMM8 iemAImpl_vroundss_u128, iemAImpl_vroundss_u128_fallback;
4582FNIEMAIMPLMEDIAF3XMMIMM8 iemAImpl_vroundsd_u128, iemAImpl_vroundsd_u128_fallback;
4583
4584FNIEMAIMPLMEDIAF3XMMIMM8 iemAImpl_vdpps_u128, iemAImpl_vdpps_u128_fallback;
4585FNIEMAIMPLMEDIAF3XMMIMM8 iemAImpl_vdppd_u128, iemAImpl_vdppd_u128_fallback;
4586
4587FNIEMAIMPLMEDIAF3YMMIMM8 iemAImpl_vdpps_u256, iemAImpl_vdpps_u256_fallback;
4588
4589
4590typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLMXCSRU64U128,(uint32_t fMxCsrIn, uint64_t *pu64Dst, PCX86XMMREG pSrc));
4591typedef FNIEMAIMPLMXCSRU64U128 *PFNIEMAIMPLMXCSRU64U128;
4592
4593FNIEMAIMPLMXCSRU64U128 iemAImpl_cvtpd2pi_u128;
4594FNIEMAIMPLMXCSRU64U128 iemAImpl_cvttpd2pi_u128;
4595
4596typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLMXCSRU128U64,(uint32_t fMxCsrIn, PX86XMMREG pDst, uint64_t u64Src));
4597typedef FNIEMAIMPLMXCSRU128U64 *PFNIEMAIMPLMXCSRU128U64;
4598
4599FNIEMAIMPLMXCSRU128U64 iemAImpl_cvtpi2ps_u128;
4600FNIEMAIMPLMXCSRU128U64 iemAImpl_cvtpi2pd_u128;
4601
4602typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLMXCSRU64U64,(uint32_t fMxCsrIn, uint64_t *pu64Dst, uint64_t u64Src));
4603typedef FNIEMAIMPLMXCSRU64U64 *PFNIEMAIMPLMXCSRU64U64;
4604
4605FNIEMAIMPLMXCSRU64U64 iemAImpl_cvtps2pi_u128;
4606FNIEMAIMPLMXCSRU64U64 iemAImpl_cvttps2pi_u128;
4607
4608/** @} */
4609
4610
4611/** @name Function tables.
4612 * @{
4613 */
4614
4615/**
4616 * Function table for a binary operator providing implementation based on
4617 * operand size.
4618 */
4619typedef struct IEMOPBINSIZES
4620{
4621 PFNIEMAIMPLBINU8 pfnNormalU8, pfnLockedU8;
4622 PFNIEMAIMPLBINU16 pfnNormalU16, pfnLockedU16;
4623 PFNIEMAIMPLBINU32 pfnNormalU32, pfnLockedU32;
4624 PFNIEMAIMPLBINU64 pfnNormalU64, pfnLockedU64;
4625} IEMOPBINSIZES;
4626/** Pointer to a binary operator function table. */
4627typedef IEMOPBINSIZES const *PCIEMOPBINSIZES;
4628
4629
4630/**
4631 * Function table for a unary operator providing implementation based on
4632 * operand size.
4633 */
4634typedef struct IEMOPUNARYSIZES
4635{
4636 PFNIEMAIMPLUNARYU8 pfnNormalU8, pfnLockedU8;
4637 PFNIEMAIMPLUNARYU16 pfnNormalU16, pfnLockedU16;
4638 PFNIEMAIMPLUNARYU32 pfnNormalU32, pfnLockedU32;
4639 PFNIEMAIMPLUNARYU64 pfnNormalU64, pfnLockedU64;
4640} IEMOPUNARYSIZES;
4641/** Pointer to a unary operator function table. */
4642typedef IEMOPUNARYSIZES const *PCIEMOPUNARYSIZES;
4643
4644
4645/**
4646 * Function table for a shift operator providing implementation based on
4647 * operand size.
4648 */
4649typedef struct IEMOPSHIFTSIZES
4650{
4651 PFNIEMAIMPLSHIFTU8 pfnNormalU8;
4652 PFNIEMAIMPLSHIFTU16 pfnNormalU16;
4653 PFNIEMAIMPLSHIFTU32 pfnNormalU32;
4654 PFNIEMAIMPLSHIFTU64 pfnNormalU64;
4655} IEMOPSHIFTSIZES;
4656/** Pointer to a shift operator function table. */
4657typedef IEMOPSHIFTSIZES const *PCIEMOPSHIFTSIZES;
4658
4659
4660/**
4661 * Function table for a multiplication or division operation.
4662 */
4663typedef struct IEMOPMULDIVSIZES
4664{
4665 PFNIEMAIMPLMULDIVU8 pfnU8;
4666 PFNIEMAIMPLMULDIVU16 pfnU16;
4667 PFNIEMAIMPLMULDIVU32 pfnU32;
4668 PFNIEMAIMPLMULDIVU64 pfnU64;
4669} IEMOPMULDIVSIZES;
4670/** Pointer to a multiplication or division operation function table. */
4671typedef IEMOPMULDIVSIZES const *PCIEMOPMULDIVSIZES;
4672
4673
4674/**
4675 * Function table for a double precision shift operator providing implementation
4676 * based on operand size.
4677 */
4678typedef struct IEMOPSHIFTDBLSIZES
4679{
4680 PFNIEMAIMPLSHIFTDBLU16 pfnNormalU16;
4681 PFNIEMAIMPLSHIFTDBLU32 pfnNormalU32;
4682 PFNIEMAIMPLSHIFTDBLU64 pfnNormalU64;
4683} IEMOPSHIFTDBLSIZES;
4684/** Pointer to a double precision shift function table. */
4685typedef IEMOPSHIFTDBLSIZES const *PCIEMOPSHIFTDBLSIZES;
4686
4687
4688/**
4689 * Function table for media instruction taking two full sized media source
4690 * registers and one full sized destination register (AVX).
4691 */
4692typedef struct IEMOPMEDIAF3
4693{
4694 PFNIEMAIMPLMEDIAF3U128 pfnU128;
4695 PFNIEMAIMPLMEDIAF3U256 pfnU256;
4696} IEMOPMEDIAF3;
4697/** Pointer to a media operation function table for 3 full sized ops (AVX). */
4698typedef IEMOPMEDIAF3 const *PCIEMOPMEDIAF3;
4699
4700/** @def IEMOPMEDIAF3_INIT_VARS_EX
4701 * Declares a s_Host (x86 & amd64 only) and a s_Fallback variable with the
4702 * given functions as initializers. For use in AVX functions where a pair of
4703 * functions are only used once and the function table need not be public. */
4704#ifndef TST_IEM_CHECK_MC
4705# if (defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)) && !defined(IEM_WITHOUT_ASSEMBLY)
4706# define IEMOPMEDIAF3_INIT_VARS_EX(a_pfnHostU128, a_pfnHostU256, a_pfnFallbackU128, a_pfnFallbackU256) \
4707 static IEMOPMEDIAF3 const s_Host = { a_pfnHostU128, a_pfnHostU256 }; \
4708 static IEMOPMEDIAF3 const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
4709# else
4710# define IEMOPMEDIAF3_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) \
4711 static IEMOPMEDIAF3 const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
4712# endif
4713#else
4714# define IEMOPMEDIAF3_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) (void)0
4715#endif
4716/** @def IEMOPMEDIAF3_INIT_VARS
4717 * Generate AVX function tables for the @a a_InstrNm instruction.
4718 * @sa IEMOPMEDIAF3_INIT_VARS_EX */
4719#define IEMOPMEDIAF3_INIT_VARS(a_InstrNm) \
4720 IEMOPMEDIAF3_INIT_VARS_EX(RT_CONCAT3(iemAImpl_,a_InstrNm,_u128), RT_CONCAT3(iemAImpl_,a_InstrNm,_u256),\
4721 RT_CONCAT3(iemAImpl_,a_InstrNm,_u128_fallback), RT_CONCAT3(iemAImpl_,a_InstrNm,_u256_fallback))
4722
4723
4724/**
4725 * Function table for media instruction taking one full sized media source
4726 * registers and one full sized destination register (AVX).
4727 */
4728typedef struct IEMOPMEDIAF2
4729{
4730 PFNIEMAIMPLMEDIAF2U128 pfnU128;
4731 PFNIEMAIMPLMEDIAF2U256 pfnU256;
4732} IEMOPMEDIAF2;
4733/** Pointer to a media operation function table for 2 full sized ops (AVX). */
4734typedef IEMOPMEDIAF2 const *PCIEMOPMEDIAF2;
4735
4736/** @def IEMOPMEDIAF2_INIT_VARS_EX
4737 * Declares a s_Host (x86 & amd64 only) and a s_Fallback variable with the
4738 * given functions as initializers. For use in AVX functions where a pair of
4739 * functions are only used once and the function table need not be public. */
4740#ifndef TST_IEM_CHECK_MC
4741# if (defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)) && !defined(IEM_WITHOUT_ASSEMBLY)
4742# define IEMOPMEDIAF2_INIT_VARS_EX(a_pfnHostU128, a_pfnHostU256, a_pfnFallbackU128, a_pfnFallbackU256) \
4743 static IEMOPMEDIAF2 const s_Host = { a_pfnHostU128, a_pfnHostU256 }; \
4744 static IEMOPMEDIAF2 const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
4745# else
4746# define IEMOPMEDIAF2_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) \
4747 static IEMOPMEDIAF2 const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
4748# endif
4749#else
4750# define IEMOPMEDIAF2_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) (void)0
4751#endif
4752/** @def IEMOPMEDIAF2_INIT_VARS
4753 * Generate AVX function tables for the @a a_InstrNm instruction.
4754 * @sa IEMOPMEDIAF2_INIT_VARS_EX */
4755#define IEMOPMEDIAF2_INIT_VARS(a_InstrNm) \
4756 IEMOPMEDIAF2_INIT_VARS_EX(RT_CONCAT3(iemAImpl_,a_InstrNm,_u128), RT_CONCAT3(iemAImpl_,a_InstrNm,_u256),\
4757 RT_CONCAT3(iemAImpl_,a_InstrNm,_u128_fallback), RT_CONCAT3(iemAImpl_,a_InstrNm,_u256_fallback))
4758
4759
4760/**
4761 * Function table for media instruction taking two full sized media source
4762 * registers and one full sized destination register, but no additional state
4763 * (AVX).
4764 */
4765typedef struct IEMOPMEDIAOPTF3
4766{
4767 PFNIEMAIMPLMEDIAOPTF3U128 pfnU128;
4768 PFNIEMAIMPLMEDIAOPTF3U256 pfnU256;
4769} IEMOPMEDIAOPTF3;
4770/** Pointer to a media operation function table for 3 full sized ops (AVX). */
4771typedef IEMOPMEDIAOPTF3 const *PCIEMOPMEDIAOPTF3;
4772
4773/** @def IEMOPMEDIAOPTF3_INIT_VARS_EX
4774 * Declares a s_Host (x86 & amd64 only) and a s_Fallback variable with the
4775 * given functions as initializers. For use in AVX functions where a pair of
4776 * functions are only used once and the function table need not be public. */
4777#ifndef TST_IEM_CHECK_MC
4778# if (defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)) && !defined(IEM_WITHOUT_ASSEMBLY)
4779# define IEMOPMEDIAOPTF3_INIT_VARS_EX(a_pfnHostU128, a_pfnHostU256, a_pfnFallbackU128, a_pfnFallbackU256) \
4780 static IEMOPMEDIAOPTF3 const s_Host = { a_pfnHostU128, a_pfnHostU256 }; \
4781 static IEMOPMEDIAOPTF3 const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
4782# else
4783# define IEMOPMEDIAOPTF3_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) \
4784 static IEMOPMEDIAOPTF3 const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
4785# endif
4786#else
4787# define IEMOPMEDIAOPTF3_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) (void)0
4788#endif
4789/** @def IEMOPMEDIAOPTF3_INIT_VARS
4790 * Generate AVX function tables for the @a a_InstrNm instruction.
4791 * @sa IEMOPMEDIAOPTF3_INIT_VARS_EX */
4792#define IEMOPMEDIAOPTF3_INIT_VARS(a_InstrNm) \
4793 IEMOPMEDIAOPTF3_INIT_VARS_EX(RT_CONCAT3(iemAImpl_,a_InstrNm,_u128), RT_CONCAT3(iemAImpl_,a_InstrNm,_u256),\
4794 RT_CONCAT3(iemAImpl_,a_InstrNm,_u128_fallback), RT_CONCAT3(iemAImpl_,a_InstrNm,_u256_fallback))
4795
4796/**
4797 * Function table for media instruction taking one full sized media source
4798 * registers and one full sized destination register, but no additional state
4799 * (AVX).
4800 */
4801typedef struct IEMOPMEDIAOPTF2
4802{
4803 PFNIEMAIMPLMEDIAOPTF2U128 pfnU128;
4804 PFNIEMAIMPLMEDIAOPTF2U256 pfnU256;
4805} IEMOPMEDIAOPTF2;
4806/** Pointer to a media operation function table for 2 full sized ops (AVX). */
4807typedef IEMOPMEDIAOPTF2 const *PCIEMOPMEDIAOPTF2;
4808
4809/** @def IEMOPMEDIAOPTF2_INIT_VARS_EX
4810 * Declares a s_Host (x86 & amd64 only) and a s_Fallback variable with the
4811 * given functions as initializers. For use in AVX functions where a pair of
4812 * functions are only used once and the function table need not be public. */
4813#ifndef TST_IEM_CHECK_MC
4814# if (defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)) && !defined(IEM_WITHOUT_ASSEMBLY)
4815# define IEMOPMEDIAOPTF2_INIT_VARS_EX(a_pfnHostU128, a_pfnHostU256, a_pfnFallbackU128, a_pfnFallbackU256) \
4816 static IEMOPMEDIAOPTF2 const s_Host = { a_pfnHostU128, a_pfnHostU256 }; \
4817 static IEMOPMEDIAOPTF2 const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
4818# else
4819# define IEMOPMEDIAOPTF2_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) \
4820 static IEMOPMEDIAOPTF2 const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
4821# endif
4822#else
4823# define IEMOPMEDIAOPTF2_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) (void)0
4824#endif
4825/** @def IEMOPMEDIAOPTF2_INIT_VARS
4826 * Generate AVX function tables for the @a a_InstrNm instruction.
4827 * @sa IEMOPMEDIAOPTF2_INIT_VARS_EX */
4828#define IEMOPMEDIAOPTF2_INIT_VARS(a_InstrNm) \
4829 IEMOPMEDIAOPTF2_INIT_VARS_EX(RT_CONCAT3(iemAImpl_,a_InstrNm,_u128), RT_CONCAT3(iemAImpl_,a_InstrNm,_u256),\
4830 RT_CONCAT3(iemAImpl_,a_InstrNm,_u128_fallback), RT_CONCAT3(iemAImpl_,a_InstrNm,_u256_fallback))
4831
4832
4833/**
4834 * Function table for media instruction taking one full sized media source
4835 * register and one full sized destination register and an 8-bit immediate (AVX).
4836 */
4837typedef struct IEMOPMEDIAF2IMM8
4838{
4839 PFNIEMAIMPLMEDIAF2U128IMM8 pfnU128;
4840 PFNIEMAIMPLMEDIAF2U256IMM8 pfnU256;
4841} IEMOPMEDIAF2IMM8;
4842/** Pointer to a media operation function table for 2 full sized ops (AVX). */
4843typedef IEMOPMEDIAF2IMM8 const *PCIEMOPMEDIAF2IMM8;
4844
4845/** @def IEMOPMEDIAF2IMM8_INIT_VARS_EX
4846 * Declares a s_Host (x86 & amd64 only) and a s_Fallback variable with the
4847 * given functions as initializers. For use in AVX functions where a pair of
4848 * functions are only used once and the function table need not be public. */
4849#ifndef TST_IEM_CHECK_MC
4850# if (defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)) && !defined(IEM_WITHOUT_ASSEMBLY)
4851# define IEMOPMEDIAF2IMM8_INIT_VARS_EX(a_pfnHostU128, a_pfnHostU256, a_pfnFallbackU128, a_pfnFallbackU256) \
4852 static IEMOPMEDIAF2IMM8 const s_Host = { a_pfnHostU128, a_pfnHostU256 }; \
4853 static IEMOPMEDIAF2IMM8 const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
4854# else
4855# define IEMOPMEDIAF2IMM8_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) \
4856 static IEMOPMEDIAF2IMM8 const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
4857# endif
4858#else
4859# define IEMOPMEDIAF2IMM8_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) (void)0
4860#endif
4861/** @def IEMOPMEDIAF2IMM8_INIT_VARS
4862 * Generate AVX function tables for the @a a_InstrNm instruction.
4863 * @sa IEMOPMEDIAF2IMM8_INIT_VARS_EX */
4864#define IEMOPMEDIAF2IMM8_INIT_VARS(a_InstrNm) \
4865 IEMOPMEDIAF2IMM8_INIT_VARS_EX(RT_CONCAT3(iemAImpl_,a_InstrNm,_u128), RT_CONCAT3(iemAImpl_,a_InstrNm,_u256),\
4866 RT_CONCAT3(iemAImpl_,a_InstrNm,_u128_fallback), RT_CONCAT3(iemAImpl_,a_InstrNm,_u256_fallback))
4867
4868
4869/**
4870 * Function table for media instruction taking one full sized media source
4871 * register and one full sized destination register and an 8-bit immediate, but no additional state
4872 * (AVX).
4873 */
4874typedef struct IEMOPMEDIAOPTF2IMM8
4875{
4876 PFNIEMAIMPLMEDIAOPTF2U128IMM8 pfnU128;
4877 PFNIEMAIMPLMEDIAOPTF2U256IMM8 pfnU256;
4878} IEMOPMEDIAOPTF2IMM8;
4879/** Pointer to a media operation function table for 2 full sized ops (AVX). */
4880typedef IEMOPMEDIAOPTF2IMM8 const *PCIEMOPMEDIAOPTF2IMM8;
4881
4882/** @def IEMOPMEDIAOPTF2IMM8_INIT_VARS_EX
4883 * Declares a s_Host (x86 & amd64 only) and a s_Fallback variable with the
4884 * given functions as initializers. For use in AVX functions where a pair of
4885 * functions are only used once and the function table need not be public. */
4886#ifndef TST_IEM_CHECK_MC
4887# if (defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)) && !defined(IEM_WITHOUT_ASSEMBLY)
4888# define IEMOPMEDIAOPTF2IMM8_INIT_VARS_EX(a_pfnHostU128, a_pfnHostU256, a_pfnFallbackU128, a_pfnFallbackU256) \
4889 static IEMOPMEDIAOPTF2IMM8 const s_Host = { a_pfnHostU128, a_pfnHostU256 }; \
4890 static IEMOPMEDIAOPTF2IMM8 const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
4891# else
4892# define IEMOPMEDIAOPTF2IMM8_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) \
4893 static IEMOPMEDIAOPTF2IMM8 const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
4894# endif
4895#else
4896# define IEMOPMEDIAOPTF2IMM8_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) (void)0
4897#endif
4898/** @def IEMOPMEDIAOPTF2IMM8_INIT_VARS
4899 * Generate AVX function tables for the @a a_InstrNm instruction.
4900 * @sa IEMOPMEDIAOPTF2IMM8_INIT_VARS_EX */
4901#define IEMOPMEDIAOPTF2IMM8_INIT_VARS(a_InstrNm) \
4902 IEMOPMEDIAOPTF2IMM8_INIT_VARS_EX(RT_CONCAT3(iemAImpl_,a_InstrNm,_imm_u128), RT_CONCAT3(iemAImpl_,a_InstrNm,_imm_u256),\
4903 RT_CONCAT3(iemAImpl_,a_InstrNm,_imm_u128_fallback), RT_CONCAT3(iemAImpl_,a_InstrNm,_imm_u256_fallback))
4904
4905/**
4906 * Function table for media instruction taking two full sized media source
4907 * registers and one full sized destination register and an 8-bit immediate, but no additional state
4908 * (AVX).
4909 */
4910typedef struct IEMOPMEDIAOPTF3IMM8
4911{
4912 PFNIEMAIMPLMEDIAOPTF3U128IMM8 pfnU128;
4913 PFNIEMAIMPLMEDIAOPTF3U256IMM8 pfnU256;
4914} IEMOPMEDIAOPTF3IMM8;
4915/** Pointer to a media operation function table for 3 full sized ops (AVX). */
4916typedef IEMOPMEDIAOPTF3IMM8 const *PCIEMOPMEDIAOPTF3IMM8;
4917
4918/** @def IEMOPMEDIAOPTF3IMM8_INIT_VARS_EX
4919 * Declares a s_Host (x86 & amd64 only) and a s_Fallback variable with the
4920 * given functions as initializers. For use in AVX functions where a pair of
4921 * functions are only used once and the function table need not be public. */
4922#ifndef TST_IEM_CHECK_MC
4923# if (defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)) && !defined(IEM_WITHOUT_ASSEMBLY)
4924# define IEMOPMEDIAOPTF3IMM8_INIT_VARS_EX(a_pfnHostU128, a_pfnHostU256, a_pfnFallbackU128, a_pfnFallbackU256) \
4925 static IEMOPMEDIAOPTF3IMM8 const s_Host = { a_pfnHostU128, a_pfnHostU256 }; \
4926 static IEMOPMEDIAOPTF3IMM8 const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
4927# else
4928# define IEMOPMEDIAOPTF3IMM8_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) \
4929 static IEMOPMEDIAOPTF3IMM8 const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
4930# endif
4931#else
4932# define IEMOPMEDIAOPTF3IMM8_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) (void)0
4933#endif
4934/** @def IEMOPMEDIAOPTF3IMM8_INIT_VARS
4935 * Generate AVX function tables for the @a a_InstrNm instruction.
4936 * @sa IEMOPMEDIAOPTF3IMM8_INIT_VARS_EX */
4937#define IEMOPMEDIAOPTF3IMM8_INIT_VARS(a_InstrNm) \
4938 IEMOPMEDIAOPTF3IMM8_INIT_VARS_EX(RT_CONCAT3(iemAImpl_,a_InstrNm,_u128), RT_CONCAT3(iemAImpl_,a_InstrNm,_u256),\
4939 RT_CONCAT3(iemAImpl_,a_InstrNm,_u128_fallback), RT_CONCAT3(iemAImpl_,a_InstrNm,_u256_fallback))
4940/** @} */
4941
4942
4943/**
4944 * Function table for blend type instruction taking three full sized media source
4945 * registers and one full sized destination register, but no additional state
4946 * (AVX).
4947 */
4948typedef struct IEMOPBLENDOP
4949{
4950 PFNIEMAIMPLAVXBLENDU128 pfnU128;
4951 PFNIEMAIMPLAVXBLENDU256 pfnU256;
4952} IEMOPBLENDOP;
4953/** Pointer to a media operation function table for 4 full sized ops (AVX). */
4954typedef IEMOPBLENDOP const *PCIEMOPBLENDOP;
4955
4956/** @def IEMOPBLENDOP_INIT_VARS_EX
4957 * Declares a s_Host (x86 & amd64 only) and a s_Fallback variable with the
4958 * given functions as initializers. For use in AVX functions where a pair of
4959 * functions are only used once and the function table need not be public. */
4960#ifndef TST_IEM_CHECK_MC
4961# if (defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)) && !defined(IEM_WITHOUT_ASSEMBLY)
4962# define IEMOPBLENDOP_INIT_VARS_EX(a_pfnHostU128, a_pfnHostU256, a_pfnFallbackU128, a_pfnFallbackU256) \
4963 static IEMOPBLENDOP const s_Host = { a_pfnHostU128, a_pfnHostU256 }; \
4964 static IEMOPBLENDOP const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
4965# else
4966# define IEMOPBLENDOP_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) \
4967 static IEMOPBLENDOP const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
4968# endif
4969#else
4970# define IEMOPBLENDOP_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) (void)0
4971#endif
4972/** @def IEMOPBLENDOP_INIT_VARS
4973 * Generate AVX function tables for the @a a_InstrNm instruction.
4974 * @sa IEMOPBLENDOP_INIT_VARS_EX */
4975#define IEMOPBLENDOP_INIT_VARS(a_InstrNm) \
4976 IEMOPBLENDOP_INIT_VARS_EX(RT_CONCAT3(iemAImpl_,a_InstrNm,_u128), RT_CONCAT3(iemAImpl_,a_InstrNm,_u256),\
4977 RT_CONCAT3(iemAImpl_,a_InstrNm,_u128_fallback), RT_CONCAT3(iemAImpl_,a_InstrNm,_u256_fallback))
4978
4979
4980/** @name SSE/AVX single/double precision floating point operations.
4981 * @{ */
4982typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLFPSSEF2U128,(uint32_t uMxCsrIn, PX86XMMREG pResult, PCX86XMMREG puSrc1, PCX86XMMREG puSrc2));
4983typedef FNIEMAIMPLFPSSEF2U128 *PFNIEMAIMPLFPSSEF2U128;
4984typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLFPSSEF2U128R32,(uint32_t uMxCsrIn, PX86XMMREG Result, PCX86XMMREG puSrc1, PCRTFLOAT32U pr32Src2));
4985typedef FNIEMAIMPLFPSSEF2U128R32 *PFNIEMAIMPLFPSSEF2U128R32;
4986typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLFPSSEF2U128R64,(uint32_t uMxCsrIn, PX86XMMREG pResult, PCX86XMMREG puSrc1, PCRTFLOAT64U pr64Src2));
4987typedef FNIEMAIMPLFPSSEF2U128R64 *PFNIEMAIMPLFPSSEF2U128R64;
4988
4989typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLFPAVXF3U128,(uint32_t uMxCsrIn, PX86XMMREG pResult, PCX86XMMREG puSrc1, PCX86XMMREG puSrc2));
4990typedef FNIEMAIMPLFPAVXF3U128 *PFNIEMAIMPLFPAVXF3U128;
4991typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLFPAVXF3U128R32,(uint32_t uMxCsrIn, PX86XMMREG pResult, PCX86XMMREG puSrc1, PCRTFLOAT32U pr32Src2));
4992typedef FNIEMAIMPLFPAVXF3U128R32 *PFNIEMAIMPLFPAVXF3U128R32;
4993typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLFPAVXF3U128R64,(uint32_t uMxCsrIn, PX86XMMREG pResult, PCX86XMMREG puSrc1, PCRTFLOAT64U pr64Src2));
4994typedef FNIEMAIMPLFPAVXF3U128R64 *PFNIEMAIMPLFPAVXF3U128R64;
4995
4996typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLFPAVXF3U256,(uint32_t uMxCsrIn, PX86YMMREG pResult, PCX86YMMREG puSrc1, PCX86YMMREG puSrc2));
4997typedef FNIEMAIMPLFPAVXF3U256 *PFNIEMAIMPLFPAVXF3U256;
4998
4999FNIEMAIMPLFPSSEF2U128 iemAImpl_addps_u128;
5000FNIEMAIMPLFPSSEF2U128 iemAImpl_addpd_u128;
5001FNIEMAIMPLFPSSEF2U128 iemAImpl_mulps_u128;
5002FNIEMAIMPLFPSSEF2U128 iemAImpl_mulpd_u128;
5003FNIEMAIMPLFPSSEF2U128 iemAImpl_subps_u128;
5004FNIEMAIMPLFPSSEF2U128 iemAImpl_subpd_u128;
5005FNIEMAIMPLFPSSEF2U128 iemAImpl_minps_u128;
5006FNIEMAIMPLFPSSEF2U128 iemAImpl_minpd_u128;
5007FNIEMAIMPLFPSSEF2U128 iemAImpl_divps_u128;
5008FNIEMAIMPLFPSSEF2U128 iemAImpl_divpd_u128;
5009FNIEMAIMPLFPSSEF2U128 iemAImpl_maxps_u128;
5010FNIEMAIMPLFPSSEF2U128 iemAImpl_maxpd_u128;
5011FNIEMAIMPLFPSSEF2U128 iemAImpl_haddps_u128;
5012FNIEMAIMPLFPSSEF2U128 iemAImpl_haddpd_u128;
5013FNIEMAIMPLFPSSEF2U128 iemAImpl_hsubps_u128;
5014FNIEMAIMPLFPSSEF2U128 iemAImpl_hsubpd_u128;
5015FNIEMAIMPLFPSSEF2U128 iemAImpl_sqrtps_u128;
5016FNIEMAIMPLFPSSEF2U128 iemAImpl_rsqrtps_u128;
5017FNIEMAIMPLFPSSEF2U128 iemAImpl_sqrtpd_u128;
5018FNIEMAIMPLFPSSEF2U128 iemAImpl_rcpps_u128;
5019FNIEMAIMPLFPSSEF2U128 iemAImpl_addsubps_u128;
5020FNIEMAIMPLFPSSEF2U128 iemAImpl_addsubpd_u128;
5021
5022FNIEMAIMPLFPSSEF2U128 iemAImpl_cvtpd2ps_u128;
5023IEM_DECL_IMPL_PROTO(uint32_t, iemAImpl_cvtps2pd_u128,(uint32_t uMxCsrIn, PX86XMMREG pResult, uint64_t const *pu64Src));
5024
5025FNIEMAIMPLFPSSEF2U128 iemAImpl_cvtdq2ps_u128;
5026FNIEMAIMPLFPSSEF2U128 iemAImpl_cvtps2dq_u128;
5027FNIEMAIMPLFPSSEF2U128 iemAImpl_cvttps2dq_u128;
5028FNIEMAIMPLFPSSEF2U128 iemAImpl_cvttpd2dq_u128;
5029FNIEMAIMPLFPSSEF2U128 iemAImpl_cvtdq2pd_u128;
5030FNIEMAIMPLFPSSEF2U128 iemAImpl_cvtpd2dq_u128;
5031
5032FNIEMAIMPLFPSSEF2U128R32 iemAImpl_addss_u128_r32;
5033FNIEMAIMPLFPSSEF2U128R64 iemAImpl_addsd_u128_r64;
5034FNIEMAIMPLFPSSEF2U128R32 iemAImpl_mulss_u128_r32;
5035FNIEMAIMPLFPSSEF2U128R64 iemAImpl_mulsd_u128_r64;
5036FNIEMAIMPLFPSSEF2U128R32 iemAImpl_subss_u128_r32;
5037FNIEMAIMPLFPSSEF2U128R64 iemAImpl_subsd_u128_r64;
5038FNIEMAIMPLFPSSEF2U128R32 iemAImpl_minss_u128_r32;
5039FNIEMAIMPLFPSSEF2U128R64 iemAImpl_minsd_u128_r64;
5040FNIEMAIMPLFPSSEF2U128R32 iemAImpl_divss_u128_r32;
5041FNIEMAIMPLFPSSEF2U128R64 iemAImpl_divsd_u128_r64;
5042FNIEMAIMPLFPSSEF2U128R32 iemAImpl_maxss_u128_r32;
5043FNIEMAIMPLFPSSEF2U128R64 iemAImpl_maxsd_u128_r64;
5044FNIEMAIMPLFPSSEF2U128R32 iemAImpl_cvtss2sd_u128_r32;
5045FNIEMAIMPLFPSSEF2U128R64 iemAImpl_cvtsd2ss_u128_r64;
5046FNIEMAIMPLFPSSEF2U128R32 iemAImpl_sqrtss_u128_r32;
5047FNIEMAIMPLFPSSEF2U128R64 iemAImpl_sqrtsd_u128_r64;
5048FNIEMAIMPLFPSSEF2U128R32 iemAImpl_rsqrtss_u128_r32;
5049FNIEMAIMPLFPSSEF2U128R32 iemAImpl_rcpss_u128_r32;
5050
5051FNIEMAIMPLMEDIAF3U128 iemAImpl_vaddps_u128, iemAImpl_vaddps_u128_fallback;
5052FNIEMAIMPLMEDIAF3U128 iemAImpl_vaddpd_u128, iemAImpl_vaddpd_u128_fallback;
5053FNIEMAIMPLMEDIAF3U128 iemAImpl_vmulps_u128, iemAImpl_vmulps_u128_fallback;
5054FNIEMAIMPLMEDIAF3U128 iemAImpl_vmulpd_u128, iemAImpl_vmulpd_u128_fallback;
5055FNIEMAIMPLMEDIAF3U128 iemAImpl_vsubps_u128, iemAImpl_vsubps_u128_fallback;
5056FNIEMAIMPLMEDIAF3U128 iemAImpl_vsubpd_u128, iemAImpl_vsubpd_u128_fallback;
5057FNIEMAIMPLMEDIAF3U128 iemAImpl_vminps_u128, iemAImpl_vminps_u128_fallback;
5058FNIEMAIMPLMEDIAF3U128 iemAImpl_vminpd_u128, iemAImpl_vminpd_u128_fallback;
5059FNIEMAIMPLMEDIAF3U128 iemAImpl_vdivps_u128, iemAImpl_vdivps_u128_fallback;
5060FNIEMAIMPLMEDIAF3U128 iemAImpl_vdivpd_u128, iemAImpl_vdivpd_u128_fallback;
5061FNIEMAIMPLMEDIAF3U128 iemAImpl_vmaxps_u128, iemAImpl_vmaxps_u128_fallback;
5062FNIEMAIMPLMEDIAF3U128 iemAImpl_vmaxpd_u128, iemAImpl_vmaxpd_u128_fallback;
5063FNIEMAIMPLMEDIAF3U128 iemAImpl_vhaddps_u128, iemAImpl_vhaddps_u128_fallback;
5064FNIEMAIMPLMEDIAF3U128 iemAImpl_vhaddpd_u128, iemAImpl_vhaddpd_u128_fallback;
5065FNIEMAIMPLMEDIAF3U128 iemAImpl_vhsubps_u128, iemAImpl_vhsubps_u128_fallback;
5066FNIEMAIMPLMEDIAF3U128 iemAImpl_vhsubpd_u128, iemAImpl_vhsubpd_u128_fallback;
5067FNIEMAIMPLMEDIAF2U128 iemAImpl_vsqrtps_u128, iemAImpl_vsqrtps_u128_fallback;
5068FNIEMAIMPLMEDIAF2U128 iemAImpl_vsqrtpd_u128, iemAImpl_vsqrtpd_u128_fallback;
5069FNIEMAIMPLMEDIAF2U128 iemAImpl_vrsqrtps_u128, iemAImpl_vrsqrtps_u128_fallback;
5070FNIEMAIMPLMEDIAF2U128 iemAImpl_vrcpps_u128, iemAImpl_vrcpps_u128_fallback;
5071FNIEMAIMPLMEDIAF3U128 iemAImpl_vaddsubps_u128, iemAImpl_vaddsubps_u128_fallback;
5072FNIEMAIMPLMEDIAF3U128 iemAImpl_vaddsubpd_u128, iemAImpl_vaddsubpd_u128_fallback;
5073FNIEMAIMPLMEDIAF2U128 iemAImpl_vcvtdq2ps_u128, iemAImpl_vcvtdq2ps_u128_fallback;
5074FNIEMAIMPLMEDIAF2U128 iemAImpl_vcvtps2dq_u128, iemAImpl_vcvtps2dq_u128_fallback;
5075FNIEMAIMPLMEDIAF2U128 iemAImpl_vcvttps2dq_u128, iemAImpl_vcvttps2dq_u128_fallback;
5076IEM_DECL_IMPL_PROTO(uint32_t, iemAImpl_vcvtpd2ps_u128_u128,(uint32_t uMxCsrIn, PX86XMMREG puDst, PCX86XMMREG puSrc));
5077IEM_DECL_IMPL_PROTO(uint32_t, iemAImpl_vcvtpd2ps_u128_u128_fallback,(uint32_t uMxCsrIn, PX86XMMREG puDst, PCX86XMMREG puSrc));
5078IEM_DECL_IMPL_PROTO(uint32_t, iemAImpl_vcvttpd2dq_u128_u128,(uint32_t uMxCsrIn, PX86XMMREG puDst, PCX86XMMREG puSrc));
5079IEM_DECL_IMPL_PROTO(uint32_t, iemAImpl_vcvttpd2dq_u128_u128_fallback,(uint32_t uMxCsrIn, PX86XMMREG puDst, PCX86XMMREG puSrc));
5080IEM_DECL_IMPL_PROTO(uint32_t, iemAImpl_vcvtpd2dq_u128_u128,(uint32_t uMxCsrIn, PX86XMMREG puDst, PCX86XMMREG puSrc));
5081IEM_DECL_IMPL_PROTO(uint32_t, iemAImpl_vcvtpd2dq_u128_u128_fallback,(uint32_t uMxCsrIn, PX86XMMREG puDst, PCX86XMMREG puSrc));
5082
5083
5084FNIEMAIMPLFPAVXF3U128R32 iemAImpl_vaddss_u128_r32, iemAImpl_vaddss_u128_r32_fallback;
5085FNIEMAIMPLFPAVXF3U128R64 iemAImpl_vaddsd_u128_r64, iemAImpl_vaddsd_u128_r64_fallback;
5086FNIEMAIMPLFPAVXF3U128R32 iemAImpl_vmulss_u128_r32, iemAImpl_vmulss_u128_r32_fallback;
5087FNIEMAIMPLFPAVXF3U128R64 iemAImpl_vmulsd_u128_r64, iemAImpl_vmulsd_u128_r64_fallback;
5088FNIEMAIMPLFPAVXF3U128R32 iemAImpl_vsubss_u128_r32, iemAImpl_vsubss_u128_r32_fallback;
5089FNIEMAIMPLFPAVXF3U128R64 iemAImpl_vsubsd_u128_r64, iemAImpl_vsubsd_u128_r64_fallback;
5090FNIEMAIMPLFPAVXF3U128R32 iemAImpl_vminss_u128_r32, iemAImpl_vminss_u128_r32_fallback;
5091FNIEMAIMPLFPAVXF3U128R64 iemAImpl_vminsd_u128_r64, iemAImpl_vminsd_u128_r64_fallback;
5092FNIEMAIMPLFPAVXF3U128R32 iemAImpl_vdivss_u128_r32, iemAImpl_vdivss_u128_r32_fallback;
5093FNIEMAIMPLFPAVXF3U128R64 iemAImpl_vdivsd_u128_r64, iemAImpl_vdivsd_u128_r64_fallback;
5094FNIEMAIMPLFPAVXF3U128R32 iemAImpl_vmaxss_u128_r32, iemAImpl_vmaxss_u128_r32_fallback;
5095FNIEMAIMPLFPAVXF3U128R64 iemAImpl_vmaxsd_u128_r64, iemAImpl_vmaxsd_u128_r64_fallback;
5096FNIEMAIMPLFPAVXF3U128R32 iemAImpl_vsqrtss_u128_r32, iemAImpl_vsqrtss_u128_r32_fallback;
5097FNIEMAIMPLFPAVXF3U128R64 iemAImpl_vsqrtsd_u128_r64, iemAImpl_vsqrtsd_u128_r64_fallback;
5098FNIEMAIMPLFPAVXF3U128R32 iemAImpl_vrsqrtss_u128_r32, iemAImpl_vrsqrtss_u128_r32_fallback;
5099FNIEMAIMPLFPAVXF3U128R32 iemAImpl_vrcpss_u128_r32, iemAImpl_vrcpss_u128_r32_fallback;
5100FNIEMAIMPLFPAVXF3U128R32 iemAImpl_vcvtss2sd_u128_r32, iemAImpl_vcvtss2sd_u128_r32_fallback;
5101FNIEMAIMPLFPAVXF3U128R64 iemAImpl_vcvtsd2ss_u128_r64, iemAImpl_vcvtsd2ss_u128_r64_fallback;
5102
5103
5104FNIEMAIMPLFPAVXF3U256 iemAImpl_vaddps_u256, iemAImpl_vaddps_u256_fallback;
5105FNIEMAIMPLFPAVXF3U256 iemAImpl_vaddpd_u256, iemAImpl_vaddpd_u256_fallback;
5106FNIEMAIMPLFPAVXF3U256 iemAImpl_vmulps_u256, iemAImpl_vmulps_u256_fallback;
5107FNIEMAIMPLFPAVXF3U256 iemAImpl_vmulpd_u256, iemAImpl_vmulpd_u256_fallback;
5108FNIEMAIMPLFPAVXF3U256 iemAImpl_vsubps_u256, iemAImpl_vsubps_u256_fallback;
5109FNIEMAIMPLFPAVXF3U256 iemAImpl_vsubpd_u256, iemAImpl_vsubpd_u256_fallback;
5110FNIEMAIMPLFPAVXF3U256 iemAImpl_vminps_u256, iemAImpl_vminps_u256_fallback;
5111FNIEMAIMPLFPAVXF3U256 iemAImpl_vminpd_u256, iemAImpl_vminpd_u256_fallback;
5112FNIEMAIMPLFPAVXF3U256 iemAImpl_vdivps_u256, iemAImpl_vdivps_u256_fallback;
5113FNIEMAIMPLFPAVXF3U256 iemAImpl_vdivpd_u256, iemAImpl_vdivpd_u256_fallback;
5114FNIEMAIMPLFPAVXF3U256 iemAImpl_vmaxps_u256, iemAImpl_vmaxps_u256_fallback;
5115FNIEMAIMPLFPAVXF3U256 iemAImpl_vmaxpd_u256, iemAImpl_vmaxpd_u256_fallback;
5116FNIEMAIMPLFPAVXF3U256 iemAImpl_vhaddps_u256, iemAImpl_vhaddps_u256_fallback;
5117FNIEMAIMPLFPAVXF3U256 iemAImpl_vhaddpd_u256, iemAImpl_vhaddpd_u256_fallback;
5118FNIEMAIMPLFPAVXF3U256 iemAImpl_vhsubps_u256, iemAImpl_vhsubps_u256_fallback;
5119FNIEMAIMPLFPAVXF3U256 iemAImpl_vhsubpd_u256, iemAImpl_vhsubpd_u256_fallback;
5120FNIEMAIMPLMEDIAF3U256 iemAImpl_vaddsubps_u256, iemAImpl_vaddsubps_u256_fallback;
5121FNIEMAIMPLMEDIAF3U256 iemAImpl_vaddsubpd_u256, iemAImpl_vaddsubpd_u256_fallback;
5122FNIEMAIMPLMEDIAF2U256 iemAImpl_vsqrtps_u256, iemAImpl_vsqrtps_u256_fallback;
5123FNIEMAIMPLMEDIAF2U256 iemAImpl_vsqrtpd_u256, iemAImpl_vsqrtpd_u256_fallback;
5124FNIEMAIMPLMEDIAF2U256 iemAImpl_vrsqrtps_u256, iemAImpl_vrsqrtps_u256_fallback;
5125FNIEMAIMPLMEDIAF2U256 iemAImpl_vrcpps_u256, iemAImpl_vrcpps_u256_fallback;
5126FNIEMAIMPLMEDIAF2U256 iemAImpl_vcvtdq2ps_u256, iemAImpl_vcvtdq2ps_u256_fallback;
5127FNIEMAIMPLMEDIAF2U256 iemAImpl_vcvtps2dq_u256, iemAImpl_vcvtps2dq_u256_fallback;
5128FNIEMAIMPLMEDIAF2U256 iemAImpl_vcvttps2dq_u256, iemAImpl_vcvttps2dq_u256_fallback;
5129IEM_DECL_IMPL_PROTO(uint32_t, iemAImpl_vcvtpd2ps_u128_u256,(uint32_t uMxCsrIn, PX86XMMREG puDst, PCX86YMMREG puSrc));
5130IEM_DECL_IMPL_PROTO(uint32_t, iemAImpl_vcvtpd2ps_u128_u256_fallback,(uint32_t uMxCsrIn, PX86XMMREG puDst, PCX86YMMREG puSrc));
5131IEM_DECL_IMPL_PROTO(uint32_t, iemAImpl_vcvttpd2dq_u128_u256,(uint32_t uMxCsrIn, PX86XMMREG puDst, PCX86YMMREG puSrc));
5132IEM_DECL_IMPL_PROTO(uint32_t, iemAImpl_vcvttpd2dq_u128_u256_fallback,(uint32_t uMxCsrIn, PX86XMMREG puDst, PCX86YMMREG puSrc));
5133IEM_DECL_IMPL_PROTO(uint32_t, iemAImpl_vcvtpd2dq_u128_u256,(uint32_t uMxCsrIn, PX86XMMREG puDst, PCX86YMMREG puSrc));
5134IEM_DECL_IMPL_PROTO(uint32_t, iemAImpl_vcvtpd2dq_u128_u256_fallback,(uint32_t uMxCsrIn, PX86XMMREG puDst, PCX86YMMREG puSrc));
5135/** @} */
5136
5137/** @name C instruction implementations for anything slightly complicated.
5138 * @{ */
5139
5140/**
5141 * For typedef'ing or declaring a C instruction implementation function taking
5142 * no extra arguments.
5143 *
5144 * @param a_Name The name of the type.
5145 */
5146# define IEM_CIMPL_DECL_TYPE_0(a_Name) \
5147 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr))
5148/**
5149 * For defining a C instruction implementation function taking no extra
5150 * arguments.
5151 *
5152 * @param a_Name The name of the function
5153 */
5154# define IEM_CIMPL_DEF_0(a_Name) \
5155 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr))
5156/**
5157 * Prototype version of IEM_CIMPL_DEF_0.
5158 */
5159# define IEM_CIMPL_PROTO_0(a_Name) \
5160 IEM_DECL_IMPL_PROTO(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr))
5161/**
5162 * For calling a C instruction implementation function taking no extra
5163 * arguments.
5164 *
5165 * This special call macro adds default arguments to the call and allow us to
5166 * change these later.
5167 *
5168 * @param a_fn The name of the function.
5169 */
5170# define IEM_CIMPL_CALL_0(a_fn) a_fn(pVCpu, cbInstr)
5171
5172/** Type for a C instruction implementation function taking no extra
5173 * arguments. */
5174typedef IEM_CIMPL_DECL_TYPE_0(FNIEMCIMPL0);
5175/** Function pointer type for a C instruction implementation function taking
5176 * no extra arguments. */
5177typedef FNIEMCIMPL0 *PFNIEMCIMPL0;
5178
5179/**
5180 * For typedef'ing or declaring a C instruction implementation function taking
5181 * one extra argument.
5182 *
5183 * @param a_Name The name of the type.
5184 * @param a_Type0 The argument type.
5185 * @param a_Arg0 The argument name.
5186 */
5187# define IEM_CIMPL_DECL_TYPE_1(a_Name, a_Type0, a_Arg0) \
5188 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0))
5189/**
5190 * For defining a C instruction implementation function taking one extra
5191 * argument.
5192 *
5193 * @param a_Name The name of the function
5194 * @param a_Type0 The argument type.
5195 * @param a_Arg0 The argument name.
5196 */
5197# define IEM_CIMPL_DEF_1(a_Name, a_Type0, a_Arg0) \
5198 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0))
5199/**
5200 * Prototype version of IEM_CIMPL_DEF_1.
5201 */
5202# define IEM_CIMPL_PROTO_1(a_Name, a_Type0, a_Arg0) \
5203 IEM_DECL_IMPL_PROTO(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0))
5204/**
5205 * For calling a C instruction implementation function taking one extra
5206 * argument.
5207 *
5208 * This special call macro adds default arguments to the call and allow us to
5209 * change these later.
5210 *
5211 * @param a_fn The name of the function.
5212 * @param a0 The name of the 1st argument.
5213 */
5214# define IEM_CIMPL_CALL_1(a_fn, a0) a_fn(pVCpu, cbInstr, (a0))
5215
5216/**
5217 * For typedef'ing or declaring a C instruction implementation function taking
5218 * two extra arguments.
5219 *
5220 * @param a_Name The name of the type.
5221 * @param a_Type0 The type of the 1st argument
5222 * @param a_Arg0 The name of the 1st argument.
5223 * @param a_Type1 The type of the 2nd argument.
5224 * @param a_Arg1 The name of the 2nd argument.
5225 */
5226# define IEM_CIMPL_DECL_TYPE_2(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1) \
5227 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1))
5228/**
5229 * For defining a C instruction implementation function taking two extra
5230 * arguments.
5231 *
5232 * @param a_Name The name of the function.
5233 * @param a_Type0 The type of the 1st argument
5234 * @param a_Arg0 The name of the 1st argument.
5235 * @param a_Type1 The type of the 2nd argument.
5236 * @param a_Arg1 The name of the 2nd argument.
5237 */
5238# define IEM_CIMPL_DEF_2(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1) \
5239 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1))
5240/**
5241 * Prototype version of IEM_CIMPL_DEF_2.
5242 */
5243# define IEM_CIMPL_PROTO_2(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1) \
5244 IEM_DECL_IMPL_PROTO(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1))
5245/**
5246 * For calling a C instruction implementation function taking two extra
5247 * arguments.
5248 *
5249 * This special call macro adds default arguments to the call and allow us to
5250 * change these later.
5251 *
5252 * @param a_fn The name of the function.
5253 * @param a0 The name of the 1st argument.
5254 * @param a1 The name of the 2nd argument.
5255 */
5256# define IEM_CIMPL_CALL_2(a_fn, a0, a1) a_fn(pVCpu, cbInstr, (a0), (a1))
5257
5258/**
5259 * For typedef'ing or declaring a C instruction implementation function taking
5260 * three extra arguments.
5261 *
5262 * @param a_Name The name of the type.
5263 * @param a_Type0 The type of the 1st argument
5264 * @param a_Arg0 The name of the 1st argument.
5265 * @param a_Type1 The type of the 2nd argument.
5266 * @param a_Arg1 The name of the 2nd argument.
5267 * @param a_Type2 The type of the 3rd argument.
5268 * @param a_Arg2 The name of the 3rd argument.
5269 */
5270# define IEM_CIMPL_DECL_TYPE_3(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2) \
5271 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, a_Type2 a_Arg2))
5272/**
5273 * For defining a C instruction implementation function taking three extra
5274 * arguments.
5275 *
5276 * @param a_Name The name of the function.
5277 * @param a_Type0 The type of the 1st argument
5278 * @param a_Arg0 The name of the 1st argument.
5279 * @param a_Type1 The type of the 2nd argument.
5280 * @param a_Arg1 The name of the 2nd argument.
5281 * @param a_Type2 The type of the 3rd argument.
5282 * @param a_Arg2 The name of the 3rd argument.
5283 */
5284# define IEM_CIMPL_DEF_3(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2) \
5285 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, a_Type2 a_Arg2))
5286/**
5287 * Prototype version of IEM_CIMPL_DEF_3.
5288 */
5289# define IEM_CIMPL_PROTO_3(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2) \
5290 IEM_DECL_IMPL_PROTO(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, a_Type2 a_Arg2))
5291/**
5292 * For calling a C instruction implementation function taking three extra
5293 * arguments.
5294 *
5295 * This special call macro adds default arguments to the call and allow us to
5296 * change these later.
5297 *
5298 * @param a_fn The name of the function.
5299 * @param a0 The name of the 1st argument.
5300 * @param a1 The name of the 2nd argument.
5301 * @param a2 The name of the 3rd argument.
5302 */
5303# define IEM_CIMPL_CALL_3(a_fn, a0, a1, a2) a_fn(pVCpu, cbInstr, (a0), (a1), (a2))
5304
5305
5306/**
5307 * For typedef'ing or declaring a C instruction implementation function taking
5308 * four extra arguments.
5309 *
5310 * @param a_Name The name of the type.
5311 * @param a_Type0 The type of the 1st argument
5312 * @param a_Arg0 The name of the 1st argument.
5313 * @param a_Type1 The type of the 2nd argument.
5314 * @param a_Arg1 The name of the 2nd argument.
5315 * @param a_Type2 The type of the 3rd argument.
5316 * @param a_Arg2 The name of the 3rd argument.
5317 * @param a_Type3 The type of the 4th argument.
5318 * @param a_Arg3 The name of the 4th argument.
5319 */
5320# define IEM_CIMPL_DECL_TYPE_4(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2, a_Type3, a_Arg3) \
5321 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, a_Type2 a_Arg2, a_Type3 a_Arg3))
5322/**
5323 * For defining a C instruction implementation function taking four extra
5324 * arguments.
5325 *
5326 * @param a_Name The name of the function.
5327 * @param a_Type0 The type of the 1st argument
5328 * @param a_Arg0 The name of the 1st argument.
5329 * @param a_Type1 The type of the 2nd argument.
5330 * @param a_Arg1 The name of the 2nd argument.
5331 * @param a_Type2 The type of the 3rd argument.
5332 * @param a_Arg2 The name of the 3rd argument.
5333 * @param a_Type3 The type of the 4th argument.
5334 * @param a_Arg3 The name of the 4th argument.
5335 */
5336# define IEM_CIMPL_DEF_4(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2, a_Type3, a_Arg3) \
5337 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, \
5338 a_Type2 a_Arg2, a_Type3 a_Arg3))
5339/**
5340 * Prototype version of IEM_CIMPL_DEF_4.
5341 */
5342# define IEM_CIMPL_PROTO_4(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2, a_Type3, a_Arg3) \
5343 IEM_DECL_IMPL_PROTO(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, \
5344 a_Type2 a_Arg2, a_Type3 a_Arg3))
5345/**
5346 * For calling a C instruction implementation function taking four extra
5347 * arguments.
5348 *
5349 * This special call macro adds default arguments to the call and allow us to
5350 * change these later.
5351 *
5352 * @param a_fn The name of the function.
5353 * @param a0 The name of the 1st argument.
5354 * @param a1 The name of the 2nd argument.
5355 * @param a2 The name of the 3rd argument.
5356 * @param a3 The name of the 4th argument.
5357 */
5358# define IEM_CIMPL_CALL_4(a_fn, a0, a1, a2, a3) a_fn(pVCpu, cbInstr, (a0), (a1), (a2), (a3))
5359
5360
5361/**
5362 * For typedef'ing or declaring a C instruction implementation function taking
5363 * five extra arguments.
5364 *
5365 * @param a_Name The name of the type.
5366 * @param a_Type0 The type of the 1st argument
5367 * @param a_Arg0 The name of the 1st argument.
5368 * @param a_Type1 The type of the 2nd argument.
5369 * @param a_Arg1 The name of the 2nd argument.
5370 * @param a_Type2 The type of the 3rd argument.
5371 * @param a_Arg2 The name of the 3rd argument.
5372 * @param a_Type3 The type of the 4th argument.
5373 * @param a_Arg3 The name of the 4th argument.
5374 * @param a_Type4 The type of the 5th argument.
5375 * @param a_Arg4 The name of the 5th argument.
5376 */
5377# define IEM_CIMPL_DECL_TYPE_5(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2, a_Type3, a_Arg3, a_Type4, a_Arg4) \
5378 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, \
5379 a_Type0 a_Arg0, a_Type1 a_Arg1, a_Type2 a_Arg2, \
5380 a_Type3 a_Arg3, a_Type4 a_Arg4))
5381/**
5382 * For defining a C instruction implementation function taking five extra
5383 * arguments.
5384 *
5385 * @param a_Name The name of the function.
5386 * @param a_Type0 The type of the 1st argument
5387 * @param a_Arg0 The name of the 1st argument.
5388 * @param a_Type1 The type of the 2nd argument.
5389 * @param a_Arg1 The name of the 2nd argument.
5390 * @param a_Type2 The type of the 3rd argument.
5391 * @param a_Arg2 The name of the 3rd argument.
5392 * @param a_Type3 The type of the 4th argument.
5393 * @param a_Arg3 The name of the 4th argument.
5394 * @param a_Type4 The type of the 5th argument.
5395 * @param a_Arg4 The name of the 5th argument.
5396 */
5397# define IEM_CIMPL_DEF_5(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2, a_Type3, a_Arg3, a_Type4, a_Arg4) \
5398 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, \
5399 a_Type2 a_Arg2, a_Type3 a_Arg3, a_Type4 a_Arg4))
5400/**
5401 * Prototype version of IEM_CIMPL_DEF_5.
5402 */
5403# define IEM_CIMPL_PROTO_5(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2, a_Type3, a_Arg3, a_Type4, a_Arg4) \
5404 IEM_DECL_IMPL_PROTO(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, \
5405 a_Type2 a_Arg2, a_Type3 a_Arg3, a_Type4 a_Arg4))
5406/**
5407 * For calling a C instruction implementation function taking five extra
5408 * arguments.
5409 *
5410 * This special call macro adds default arguments to the call and allow us to
5411 * change these later.
5412 *
5413 * @param a_fn The name of the function.
5414 * @param a0 The name of the 1st argument.
5415 * @param a1 The name of the 2nd argument.
5416 * @param a2 The name of the 3rd argument.
5417 * @param a3 The name of the 4th argument.
5418 * @param a4 The name of the 5th argument.
5419 */
5420# define IEM_CIMPL_CALL_5(a_fn, a0, a1, a2, a3, a4) a_fn(pVCpu, cbInstr, (a0), (a1), (a2), (a3), (a4))
5421
5422/** @} */
5423
5424
5425/** @name Opcode Decoder Function Types.
5426 * @{ */
5427
5428/** @typedef PFNIEMOP
5429 * Pointer to an opcode decoder function.
5430 */
5431
5432/** @def FNIEMOP_DEF
5433 * Define an opcode decoder function.
5434 *
5435 * We're using macors for this so that adding and removing parameters as well as
5436 * tweaking compiler specific attributes becomes easier. See FNIEMOP_CALL
5437 *
5438 * @param a_Name The function name.
5439 */
5440
5441/** @typedef PFNIEMOPRM
5442 * Pointer to an opcode decoder function with RM byte.
5443 */
5444
5445/** @def FNIEMOPRM_DEF
5446 * Define an opcode decoder function with RM byte.
5447 *
5448 * We're using macors for this so that adding and removing parameters as well as
5449 * tweaking compiler specific attributes becomes easier. See FNIEMOP_CALL_1
5450 *
5451 * @param a_Name The function name.
5452 */
5453
5454#if defined(__GNUC__) && defined(RT_ARCH_X86)
5455typedef VBOXSTRICTRC (__attribute__((__fastcall__)) * PFNIEMOP)(PVMCPUCC pVCpu);
5456typedef VBOXSTRICTRC (__attribute__((__fastcall__)) * PFNIEMOPRM)(PVMCPUCC pVCpu, uint8_t bRm);
5457# define FNIEMOP_DEF(a_Name) \
5458 IEM_STATIC VBOXSTRICTRC __attribute__((__fastcall__, __nothrow__)) a_Name(PVMCPUCC pVCpu)
5459# define FNIEMOP_DEF_1(a_Name, a_Type0, a_Name0) \
5460 IEM_STATIC VBOXSTRICTRC __attribute__((__fastcall__, __nothrow__)) a_Name(PVMCPUCC pVCpu, a_Type0 a_Name0)
5461# define FNIEMOP_DEF_2(a_Name, a_Type0, a_Name0, a_Type1, a_Name1) \
5462 IEM_STATIC VBOXSTRICTRC __attribute__((__fastcall__, __nothrow__)) a_Name(PVMCPUCC pVCpu, a_Type0 a_Name0, a_Type1 a_Name1)
5463
5464#elif defined(_MSC_VER) && defined(RT_ARCH_X86)
5465typedef VBOXSTRICTRC (__fastcall * PFNIEMOP)(PVMCPUCC pVCpu);
5466typedef VBOXSTRICTRC (__fastcall * PFNIEMOPRM)(PVMCPUCC pVCpu, uint8_t bRm);
5467# define FNIEMOP_DEF(a_Name) \
5468 IEM_STATIC /*__declspec(naked)*/ VBOXSTRICTRC __fastcall a_Name(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP
5469# define FNIEMOP_DEF_1(a_Name, a_Type0, a_Name0) \
5470 IEM_STATIC /*__declspec(naked)*/ VBOXSTRICTRC __fastcall a_Name(PVMCPUCC pVCpu, a_Type0 a_Name0) IEM_NOEXCEPT_MAY_LONGJMP
5471# define FNIEMOP_DEF_2(a_Name, a_Type0, a_Name0, a_Type1, a_Name1) \
5472 IEM_STATIC /*__declspec(naked)*/ VBOXSTRICTRC __fastcall a_Name(PVMCPUCC pVCpu, a_Type0 a_Name0, a_Type1 a_Name1) IEM_NOEXCEPT_MAY_LONGJMP
5473
5474#elif defined(__GNUC__) && !defined(IEM_WITH_THROW_CATCH)
5475typedef VBOXSTRICTRC (* PFNIEMOP)(PVMCPUCC pVCpu);
5476typedef VBOXSTRICTRC (* PFNIEMOPRM)(PVMCPUCC pVCpu, uint8_t bRm);
5477# define FNIEMOP_DEF(a_Name) \
5478 IEM_STATIC VBOXSTRICTRC __attribute__((__nothrow__)) a_Name(PVMCPUCC pVCpu)
5479# define FNIEMOP_DEF_1(a_Name, a_Type0, a_Name0) \
5480 IEM_STATIC VBOXSTRICTRC __attribute__((__nothrow__)) a_Name(PVMCPUCC pVCpu, a_Type0 a_Name0)
5481# define FNIEMOP_DEF_2(a_Name, a_Type0, a_Name0, a_Type1, a_Name1) \
5482 IEM_STATIC VBOXSTRICTRC __attribute__((__nothrow__)) a_Name(PVMCPUCC pVCpu, a_Type0 a_Name0, a_Type1 a_Name1)
5483
5484#else
5485typedef VBOXSTRICTRC (* PFNIEMOP)(PVMCPUCC pVCpu);
5486typedef VBOXSTRICTRC (* PFNIEMOPRM)(PVMCPUCC pVCpu, uint8_t bRm);
5487# define FNIEMOP_DEF(a_Name) \
5488 IEM_STATIC VBOXSTRICTRC a_Name(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP
5489# define FNIEMOP_DEF_1(a_Name, a_Type0, a_Name0) \
5490 IEM_STATIC VBOXSTRICTRC a_Name(PVMCPUCC pVCpu, a_Type0 a_Name0) IEM_NOEXCEPT_MAY_LONGJMP
5491# define FNIEMOP_DEF_2(a_Name, a_Type0, a_Name0, a_Type1, a_Name1) \
5492 IEM_STATIC VBOXSTRICTRC a_Name(PVMCPUCC pVCpu, a_Type0 a_Name0, a_Type1 a_Name1) IEM_NOEXCEPT_MAY_LONGJMP
5493
5494#endif
5495#define FNIEMOPRM_DEF(a_Name) FNIEMOP_DEF_1(a_Name, uint8_t, bRm)
5496
5497/**
5498 * Call an opcode decoder function.
5499 *
5500 * We're using macors for this so that adding and removing parameters can be
5501 * done as we please. See FNIEMOP_DEF.
5502 */
5503#define FNIEMOP_CALL(a_pfn) (a_pfn)(pVCpu)
5504
5505/**
5506 * Call a common opcode decoder function taking one extra argument.
5507 *
5508 * We're using macors for this so that adding and removing parameters can be
5509 * done as we please. See FNIEMOP_DEF_1.
5510 */
5511#define FNIEMOP_CALL_1(a_pfn, a0) (a_pfn)(pVCpu, a0)
5512
5513/**
5514 * Call a common opcode decoder function taking one extra argument.
5515 *
5516 * We're using macors for this so that adding and removing parameters can be
5517 * done as we please. See FNIEMOP_DEF_1.
5518 */
5519#define FNIEMOP_CALL_2(a_pfn, a0, a1) (a_pfn)(pVCpu, a0, a1)
5520/** @} */
5521
5522
5523/** @name Misc Helpers
5524 * @{ */
5525
5526/** Used to shut up GCC warnings about variables that 'may be used uninitialized'
5527 * due to GCC lacking knowledge about the value range of a switch. */
5528#if RT_CPLUSPLUS_PREREQ(202000)
5529# define IEM_NOT_REACHED_DEFAULT_CASE_RET() default: [[unlikely]] AssertFailedReturn(VERR_IPE_NOT_REACHED_DEFAULT_CASE)
5530#else
5531# define IEM_NOT_REACHED_DEFAULT_CASE_RET() default: AssertFailedReturn(VERR_IPE_NOT_REACHED_DEFAULT_CASE)
5532#endif
5533
5534/** Variant of IEM_NOT_REACHED_DEFAULT_CASE_RET that returns a custom value. */
5535#if RT_CPLUSPLUS_PREREQ(202000)
5536# define IEM_NOT_REACHED_DEFAULT_CASE_RET2(a_RetValue) default: [[unlikely]] AssertFailedReturn(a_RetValue)
5537#else
5538# define IEM_NOT_REACHED_DEFAULT_CASE_RET2(a_RetValue) default: AssertFailedReturn(a_RetValue)
5539#endif
5540
5541/**
5542 * Returns IEM_RETURN_ASPECT_NOT_IMPLEMENTED, and in debug builds logs the
5543 * occation.
5544 */
5545#ifdef LOG_ENABLED
5546# define IEM_RETURN_ASPECT_NOT_IMPLEMENTED() \
5547 do { \
5548 /*Log*/ LogAlways(("%s: returning IEM_RETURN_ASPECT_NOT_IMPLEMENTED (line %d)\n", __FUNCTION__, __LINE__)); \
5549 return VERR_IEM_ASPECT_NOT_IMPLEMENTED; \
5550 } while (0)
5551#else
5552# define IEM_RETURN_ASPECT_NOT_IMPLEMENTED() \
5553 return VERR_IEM_ASPECT_NOT_IMPLEMENTED
5554#endif
5555
5556/**
5557 * Returns IEM_RETURN_ASPECT_NOT_IMPLEMENTED, and in debug builds logs the
5558 * occation using the supplied logger statement.
5559 *
5560 * @param a_LoggerArgs What to log on failure.
5561 */
5562#ifdef LOG_ENABLED
5563# define IEM_RETURN_ASPECT_NOT_IMPLEMENTED_LOG(a_LoggerArgs) \
5564 do { \
5565 LogAlways((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); LogAlways(a_LoggerArgs); \
5566 /*LogFunc(a_LoggerArgs);*/ \
5567 return VERR_IEM_ASPECT_NOT_IMPLEMENTED; \
5568 } while (0)
5569#else
5570# define IEM_RETURN_ASPECT_NOT_IMPLEMENTED_LOG(a_LoggerArgs) \
5571 return VERR_IEM_ASPECT_NOT_IMPLEMENTED
5572#endif
5573
5574/**
5575 * Gets the CPU mode (from fExec) as a IEMMODE value.
5576 *
5577 * @returns IEMMODE
5578 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
5579 */
5580#define IEM_GET_CPU_MODE(a_pVCpu) ((a_pVCpu)->iem.s.fExec & IEM_F_MODE_CPUMODE_MASK)
5581
5582/**
5583 * Check if we're currently executing in real or virtual 8086 mode.
5584 *
5585 * @returns @c true if it is, @c false if not.
5586 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
5587 */
5588#define IEM_IS_REAL_OR_V86_MODE(a_pVCpu) (( ((a_pVCpu)->iem.s.fExec ^ IEM_F_MODE_X86_PROT_MASK) \
5589 & (IEM_F_MODE_X86_V86_MASK | IEM_F_MODE_X86_PROT_MASK)) != 0)
5590
5591/**
5592 * Check if we're currently executing in virtual 8086 mode.
5593 *
5594 * @returns @c true if it is, @c false if not.
5595 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
5596 */
5597#define IEM_IS_V86_MODE(a_pVCpu) (((a_pVCpu)->iem.s.fExec & IEM_F_MODE_X86_V86_MASK) != 0)
5598
5599/**
5600 * Check if we're currently executing in long mode.
5601 *
5602 * @returns @c true if it is, @c false if not.
5603 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
5604 */
5605#define IEM_IS_LONG_MODE(a_pVCpu) (CPUMIsGuestInLongModeEx(IEM_GET_CTX(a_pVCpu)))
5606
5607/**
5608 * Check if we're currently executing in a 16-bit code segment.
5609 *
5610 * @returns @c true if it is, @c false if not.
5611 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
5612 */
5613#define IEM_IS_16BIT_CODE(a_pVCpu) (IEM_GET_CPU_MODE(a_pVCpu) == IEMMODE_16BIT)
5614
5615/**
5616 * Check if we're currently executing in a 32-bit code segment.
5617 *
5618 * @returns @c true if it is, @c false if not.
5619 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
5620 */
5621#define IEM_IS_32BIT_CODE(a_pVCpu) (IEM_GET_CPU_MODE(a_pVCpu) == IEMMODE_32BIT)
5622
5623/**
5624 * Check if we're currently executing in a 64-bit code segment.
5625 *
5626 * @returns @c true if it is, @c false if not.
5627 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
5628 */
5629#define IEM_IS_64BIT_CODE(a_pVCpu) (IEM_GET_CPU_MODE(a_pVCpu) == IEMMODE_64BIT)
5630
5631/**
5632 * Check if we're currently executing in real mode.
5633 *
5634 * @returns @c true if it is, @c false if not.
5635 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
5636 */
5637#define IEM_IS_REAL_MODE(a_pVCpu) (!((a_pVCpu)->iem.s.fExec & IEM_F_MODE_X86_PROT_MASK))
5638
5639/**
5640 * Gets the current protection level (CPL).
5641 *
5642 * @returns 0..3
5643 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
5644 */
5645#define IEM_GET_CPL(a_pVCpu) (((a_pVCpu)->iem.s.fExec >> IEM_F_X86_CPL_SHIFT) & IEM_F_X86_CPL_SMASK)
5646
5647/**
5648 * Sets the current protection level (CPL).
5649 *
5650 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
5651 */
5652#define IEM_SET_CPL(a_pVCpu, a_uCpl) \
5653 do { (a_pVCpu)->iem.s.fExec = ((a_pVCpu)->iem.s.fExec & ~IEM_F_X86_CPL_MASK) | ((a_uCpl) << IEM_F_X86_CPL_SHIFT); } while (0)
5654
5655/**
5656 * Returns a (const) pointer to the CPUMFEATURES for the guest CPU.
5657 * @returns PCCPUMFEATURES
5658 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
5659 */
5660#define IEM_GET_GUEST_CPU_FEATURES(a_pVCpu) (&((a_pVCpu)->CTX_SUFF(pVM)->cpum.ro.GuestFeatures))
5661
5662/**
5663 * Returns a (const) pointer to the CPUMFEATURES for the host CPU.
5664 * @returns PCCPUMFEATURES
5665 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
5666 */
5667#define IEM_GET_HOST_CPU_FEATURES(a_pVCpu) (&g_CpumHostFeatures.s)
5668
5669/**
5670 * Evaluates to true if we're presenting an Intel CPU to the guest.
5671 */
5672#define IEM_IS_GUEST_CPU_INTEL(a_pVCpu) ( (a_pVCpu)->iem.s.enmCpuVendor == CPUMCPUVENDOR_INTEL )
5673
5674/**
5675 * Evaluates to true if we're presenting an AMD CPU to the guest.
5676 */
5677#define IEM_IS_GUEST_CPU_AMD(a_pVCpu) ( (a_pVCpu)->iem.s.enmCpuVendor == CPUMCPUVENDOR_AMD || (a_pVCpu)->iem.s.enmCpuVendor == CPUMCPUVENDOR_HYGON )
5678
5679/**
5680 * Check if the address is canonical.
5681 */
5682#define IEM_IS_CANONICAL(a_u64Addr) X86_IS_CANONICAL(a_u64Addr)
5683
5684/** Checks if the ModR/M byte is in register mode or not. */
5685#define IEM_IS_MODRM_REG_MODE(a_bRm) ( ((a_bRm) & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT) )
5686/** Checks if the ModR/M byte is in memory mode or not. */
5687#define IEM_IS_MODRM_MEM_MODE(a_bRm) ( ((a_bRm) & X86_MODRM_MOD_MASK) != (3 << X86_MODRM_MOD_SHIFT) )
5688
5689/**
5690 * Gets the register (reg) part of a ModR/M encoding, with REX.R added in.
5691 *
5692 * For use during decoding.
5693 */
5694#define IEM_GET_MODRM_REG(a_pVCpu, a_bRm) ( (((a_bRm) >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | (a_pVCpu)->iem.s.uRexReg )
5695/**
5696 * Gets the r/m part of a ModR/M encoding as a register index, with REX.B added in.
5697 *
5698 * For use during decoding.
5699 */
5700#define IEM_GET_MODRM_RM(a_pVCpu, a_bRm) ( ((a_bRm) & X86_MODRM_RM_MASK) | (a_pVCpu)->iem.s.uRexB )
5701
5702/**
5703 * Gets the register (reg) part of a ModR/M encoding, without REX.R.
5704 *
5705 * For use during decoding.
5706 */
5707#define IEM_GET_MODRM_REG_8(a_bRm) ( (((a_bRm) >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) )
5708/**
5709 * Gets the r/m part of a ModR/M encoding as a register index, without REX.B.
5710 *
5711 * For use during decoding.
5712 */
5713#define IEM_GET_MODRM_RM_8(a_bRm) ( ((a_bRm) & X86_MODRM_RM_MASK) )
5714
5715/**
5716 * Gets the register (reg) part of a ModR/M encoding as an extended 8-bit
5717 * register index, with REX.R added in.
5718 *
5719 * For use during decoding.
5720 *
5721 * @see iemGRegRefU8Ex, iemGRegFetchU8Ex, iemGRegStoreU8Ex
5722 */
5723#define IEM_GET_MODRM_REG_EX8(a_pVCpu, a_bRm) \
5724 ( (pVCpu->iem.s.fPrefixes & IEM_OP_PRF_REX) \
5725 || !((a_bRm) & (4 << X86_MODRM_REG_SHIFT)) /* IEM_GET_MODRM_REG(pVCpu, a_bRm) < 4 */ \
5726 ? IEM_GET_MODRM_REG(pVCpu, a_bRm) : (((a_bRm) >> X86_MODRM_REG_SHIFT) & 3) | 16)
5727/**
5728 * Gets the r/m part of a ModR/M encoding as an extended 8-bit register index,
5729 * with REX.B added in.
5730 *
5731 * For use during decoding.
5732 *
5733 * @see iemGRegRefU8Ex, iemGRegFetchU8Ex, iemGRegStoreU8Ex
5734 */
5735#define IEM_GET_MODRM_RM_EX8(a_pVCpu, a_bRm) \
5736 ( (pVCpu->iem.s.fPrefixes & IEM_OP_PRF_REX) \
5737 || !((a_bRm) & 4) /* IEM_GET_MODRM_RM(pVCpu, a_bRm) < 4 */ \
5738 ? IEM_GET_MODRM_RM(pVCpu, a_bRm) : ((a_bRm) & 3) | 16)
5739
5740/**
5741 * Combines the prefix REX and ModR/M byte for passing to
5742 * iemOpHlpCalcRmEffAddrThreadedAddr64().
5743 *
5744 * @returns The ModRM byte but with bit 3 set to REX.B and bit 4 to REX.X.
5745 * The two bits are part of the REG sub-field, which isn't needed in
5746 * iemOpHlpCalcRmEffAddrThreadedAddr64().
5747 *
5748 * For use during decoding/recompiling.
5749 */
5750#define IEM_GET_MODRM_EX(a_pVCpu, a_bRm) \
5751 ( ((a_bRm) & ~X86_MODRM_REG_MASK) \
5752 | (uint8_t)( (pVCpu->iem.s.fPrefixes & (IEM_OP_PRF_REX_B | IEM_OP_PRF_REX_X)) >> (25 - 3) ) )
5753AssertCompile(IEM_OP_PRF_REX_B == RT_BIT_32(25));
5754AssertCompile(IEM_OP_PRF_REX_X == RT_BIT_32(26));
5755
5756/**
5757 * Gets the effective VEX.VVVV value.
5758 *
5759 * The 4th bit is ignored if not 64-bit code.
5760 * @returns effective V-register value.
5761 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
5762 */
5763#define IEM_GET_EFFECTIVE_VVVV(a_pVCpu) \
5764 (IEM_IS_64BIT_CODE(a_pVCpu) ? (a_pVCpu)->iem.s.uVex3rdReg : (a_pVCpu)->iem.s.uVex3rdReg & 7)
5765
5766
5767/**
5768 * Gets the register (reg) part of a the special 4th register byte used by
5769 * vblendvps and vblendvpd.
5770 *
5771 * For use during decoding.
5772 */
5773#define IEM_GET_IMM8_REG(a_pVCpu, a_bRegImm8) \
5774 (IEM_IS_64BIT_CODE(a_pVCpu) ? (a_bRegImm8) >> 4 : ((a_bRegImm8) >> 4) & 7)
5775
5776
5777/**
5778 * Checks if we're executing inside an AMD-V or VT-x guest.
5779 */
5780#if defined(VBOX_WITH_NESTED_HWVIRT_VMX) || defined(VBOX_WITH_NESTED_HWVIRT_SVM)
5781# define IEM_IS_IN_GUEST(a_pVCpu) RT_BOOL((a_pVCpu)->iem.s.fExec & IEM_F_X86_CTX_IN_GUEST)
5782#else
5783# define IEM_IS_IN_GUEST(a_pVCpu) false
5784#endif
5785
5786
5787#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
5788
5789/**
5790 * Check if the guest has entered VMX root operation.
5791 */
5792# define IEM_VMX_IS_ROOT_MODE(a_pVCpu) (CPUMIsGuestInVmxRootMode(IEM_GET_CTX(a_pVCpu)))
5793
5794/**
5795 * Check if the guest has entered VMX non-root operation.
5796 */
5797# define IEM_VMX_IS_NON_ROOT_MODE(a_pVCpu) ( ((a_pVCpu)->iem.s.fExec & (IEM_F_X86_CTX_VMX | IEM_F_X86_CTX_IN_GUEST)) \
5798 == (IEM_F_X86_CTX_VMX | IEM_F_X86_CTX_IN_GUEST) )
5799
5800/**
5801 * Check if the nested-guest has the given Pin-based VM-execution control set.
5802 */
5803# define IEM_VMX_IS_PINCTLS_SET(a_pVCpu, a_PinCtl) (CPUMIsGuestVmxPinCtlsSet(IEM_GET_CTX(a_pVCpu), (a_PinCtl)))
5804
5805/**
5806 * Check if the nested-guest has the given Processor-based VM-execution control set.
5807 */
5808# define IEM_VMX_IS_PROCCTLS_SET(a_pVCpu, a_ProcCtl) (CPUMIsGuestVmxProcCtlsSet(IEM_GET_CTX(a_pVCpu), (a_ProcCtl)))
5809
5810/**
5811 * Check if the nested-guest has the given Secondary Processor-based VM-execution
5812 * control set.
5813 */
5814# define IEM_VMX_IS_PROCCTLS2_SET(a_pVCpu, a_ProcCtl2) (CPUMIsGuestVmxProcCtls2Set(IEM_GET_CTX(a_pVCpu), (a_ProcCtl2)))
5815
5816/** Gets the guest-physical address of the shadows VMCS for the given VCPU. */
5817# define IEM_VMX_GET_SHADOW_VMCS(a_pVCpu) ((a_pVCpu)->cpum.GstCtx.hwvirt.vmx.GCPhysShadowVmcs)
5818
5819/** Whether a shadow VMCS is present for the given VCPU. */
5820# define IEM_VMX_HAS_SHADOW_VMCS(a_pVCpu) RT_BOOL(IEM_VMX_GET_SHADOW_VMCS(a_pVCpu) != NIL_RTGCPHYS)
5821
5822/** Gets the VMXON region pointer. */
5823# define IEM_VMX_GET_VMXON_PTR(a_pVCpu) ((a_pVCpu)->cpum.GstCtx.hwvirt.vmx.GCPhysVmxon)
5824
5825/** Gets the guest-physical address of the current VMCS for the given VCPU. */
5826# define IEM_VMX_GET_CURRENT_VMCS(a_pVCpu) ((a_pVCpu)->cpum.GstCtx.hwvirt.vmx.GCPhysVmcs)
5827
5828/** Whether a current VMCS is present for the given VCPU. */
5829# define IEM_VMX_HAS_CURRENT_VMCS(a_pVCpu) RT_BOOL(IEM_VMX_GET_CURRENT_VMCS(a_pVCpu) != NIL_RTGCPHYS)
5830
5831/** Assigns the guest-physical address of the current VMCS for the given VCPU. */
5832# define IEM_VMX_SET_CURRENT_VMCS(a_pVCpu, a_GCPhysVmcs) \
5833 do \
5834 { \
5835 Assert((a_GCPhysVmcs) != NIL_RTGCPHYS); \
5836 (a_pVCpu)->cpum.GstCtx.hwvirt.vmx.GCPhysVmcs = (a_GCPhysVmcs); \
5837 } while (0)
5838
5839/** Clears any current VMCS for the given VCPU. */
5840# define IEM_VMX_CLEAR_CURRENT_VMCS(a_pVCpu) \
5841 do \
5842 { \
5843 (a_pVCpu)->cpum.GstCtx.hwvirt.vmx.GCPhysVmcs = NIL_RTGCPHYS; \
5844 } while (0)
5845
5846/**
5847 * Invokes the VMX VM-exit handler for an instruction intercept.
5848 */
5849# define IEM_VMX_VMEXIT_INSTR_RET(a_pVCpu, a_uExitReason, a_cbInstr) \
5850 do { return iemVmxVmexitInstr((a_pVCpu), (a_uExitReason), (a_cbInstr)); } while (0)
5851
5852/**
5853 * Invokes the VMX VM-exit handler for an instruction intercept where the
5854 * instruction provides additional VM-exit information.
5855 */
5856# define IEM_VMX_VMEXIT_INSTR_NEEDS_INFO_RET(a_pVCpu, a_uExitReason, a_uInstrId, a_cbInstr) \
5857 do { return iemVmxVmexitInstrNeedsInfo((a_pVCpu), (a_uExitReason), (a_uInstrId), (a_cbInstr)); } while (0)
5858
5859/**
5860 * Invokes the VMX VM-exit handler for a task switch.
5861 */
5862# define IEM_VMX_VMEXIT_TASK_SWITCH_RET(a_pVCpu, a_enmTaskSwitch, a_SelNewTss, a_cbInstr) \
5863 do { return iemVmxVmexitTaskSwitch((a_pVCpu), (a_enmTaskSwitch), (a_SelNewTss), (a_cbInstr)); } while (0)
5864
5865/**
5866 * Invokes the VMX VM-exit handler for MWAIT.
5867 */
5868# define IEM_VMX_VMEXIT_MWAIT_RET(a_pVCpu, a_fMonitorArmed, a_cbInstr) \
5869 do { return iemVmxVmexitInstrMwait((a_pVCpu), (a_fMonitorArmed), (a_cbInstr)); } while (0)
5870
5871/**
5872 * Invokes the VMX VM-exit handler for EPT faults.
5873 */
5874# define IEM_VMX_VMEXIT_EPT_RET(a_pVCpu, a_pPtWalk, a_fAccess, a_fSlatFail, a_cbInstr) \
5875 do { return iemVmxVmexitEpt(a_pVCpu, a_pPtWalk, a_fAccess, a_fSlatFail, a_cbInstr); } while (0)
5876
5877/**
5878 * Invokes the VMX VM-exit handler.
5879 */
5880# define IEM_VMX_VMEXIT_TRIPLE_FAULT_RET(a_pVCpu, a_uExitReason, a_uExitQual) \
5881 do { return iemVmxVmexit((a_pVCpu), (a_uExitReason), (a_uExitQual)); } while (0)
5882
5883#else
5884# define IEM_VMX_IS_ROOT_MODE(a_pVCpu) (false)
5885# define IEM_VMX_IS_NON_ROOT_MODE(a_pVCpu) (false)
5886# define IEM_VMX_IS_PINCTLS_SET(a_pVCpu, a_cbInstr) (false)
5887# define IEM_VMX_IS_PROCCTLS_SET(a_pVCpu, a_cbInstr) (false)
5888# define IEM_VMX_IS_PROCCTLS2_SET(a_pVCpu, a_cbInstr) (false)
5889# define IEM_VMX_VMEXIT_INSTR_RET(a_pVCpu, a_uExitReason, a_cbInstr) do { return VERR_VMX_IPE_1; } while (0)
5890# define IEM_VMX_VMEXIT_INSTR_NEEDS_INFO_RET(a_pVCpu, a_uExitReason, a_uInstrId, a_cbInstr) do { return VERR_VMX_IPE_1; } while (0)
5891# define IEM_VMX_VMEXIT_TASK_SWITCH_RET(a_pVCpu, a_enmTaskSwitch, a_SelNewTss, a_cbInstr) do { return VERR_VMX_IPE_1; } while (0)
5892# define IEM_VMX_VMEXIT_MWAIT_RET(a_pVCpu, a_fMonitorArmed, a_cbInstr) do { return VERR_VMX_IPE_1; } while (0)
5893# define IEM_VMX_VMEXIT_EPT_RET(a_pVCpu, a_pPtWalk, a_fAccess, a_fSlatFail, a_cbInstr) do { return VERR_VMX_IPE_1; } while (0)
5894# define IEM_VMX_VMEXIT_TRIPLE_FAULT_RET(a_pVCpu, a_uExitReason, a_uExitQual) do { return VERR_VMX_IPE_1; } while (0)
5895
5896#endif
5897
5898#ifdef VBOX_WITH_NESTED_HWVIRT_SVM
5899/**
5900 * Checks if we're executing a guest using AMD-V.
5901 */
5902# define IEM_SVM_IS_IN_GUEST(a_pVCpu) ( (a_pVCpu->iem.s.fExec & (IEM_F_X86_CTX_SVM | IEM_F_X86_CTX_IN_GUEST)) \
5903 == (IEM_F_X86_CTX_SVM | IEM_F_X86_CTX_IN_GUEST))
5904/**
5905 * Check if an SVM control/instruction intercept is set.
5906 */
5907# define IEM_SVM_IS_CTRL_INTERCEPT_SET(a_pVCpu, a_Intercept) \
5908 (IEM_SVM_IS_IN_GUEST(a_pVCpu) && CPUMIsGuestSvmCtrlInterceptSet(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_Intercept)))
5909
5910/**
5911 * Check if an SVM read CRx intercept is set.
5912 */
5913# define IEM_SVM_IS_READ_CR_INTERCEPT_SET(a_pVCpu, a_uCr) \
5914 (IEM_SVM_IS_IN_GUEST(a_pVCpu) && CPUMIsGuestSvmReadCRxInterceptSet(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_uCr)))
5915
5916/**
5917 * Check if an SVM write CRx intercept is set.
5918 */
5919# define IEM_SVM_IS_WRITE_CR_INTERCEPT_SET(a_pVCpu, a_uCr) \
5920 (IEM_SVM_IS_IN_GUEST(a_pVCpu) && CPUMIsGuestSvmWriteCRxInterceptSet(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_uCr)))
5921
5922/**
5923 * Check if an SVM read DRx intercept is set.
5924 */
5925# define IEM_SVM_IS_READ_DR_INTERCEPT_SET(a_pVCpu, a_uDr) \
5926 (IEM_SVM_IS_IN_GUEST(a_pVCpu) && CPUMIsGuestSvmReadDRxInterceptSet(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_uDr)))
5927
5928/**
5929 * Check if an SVM write DRx intercept is set.
5930 */
5931# define IEM_SVM_IS_WRITE_DR_INTERCEPT_SET(a_pVCpu, a_uDr) \
5932 (IEM_SVM_IS_IN_GUEST(a_pVCpu) && CPUMIsGuestSvmWriteDRxInterceptSet(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_uDr)))
5933
5934/**
5935 * Check if an SVM exception intercept is set.
5936 */
5937# define IEM_SVM_IS_XCPT_INTERCEPT_SET(a_pVCpu, a_uVector) \
5938 (IEM_SVM_IS_IN_GUEST(a_pVCpu) && CPUMIsGuestSvmXcptInterceptSet(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_uVector)))
5939
5940/**
5941 * Invokes the SVM \#VMEXIT handler for the nested-guest.
5942 */
5943# define IEM_SVM_VMEXIT_RET(a_pVCpu, a_uExitCode, a_uExitInfo1, a_uExitInfo2) \
5944 do { return iemSvmVmexit((a_pVCpu), (a_uExitCode), (a_uExitInfo1), (a_uExitInfo2)); } while (0)
5945
5946/**
5947 * Invokes the 'MOV CRx' SVM \#VMEXIT handler after constructing the
5948 * corresponding decode assist information.
5949 */
5950# define IEM_SVM_CRX_VMEXIT_RET(a_pVCpu, a_uExitCode, a_enmAccessCrX, a_iGReg) \
5951 do \
5952 { \
5953 uint64_t uExitInfo1; \
5954 if ( IEM_GET_GUEST_CPU_FEATURES(a_pVCpu)->fSvmDecodeAssists \
5955 && (a_enmAccessCrX) == IEMACCESSCRX_MOV_CRX) \
5956 uExitInfo1 = SVM_EXIT1_MOV_CRX_MASK | ((a_iGReg) & 7); \
5957 else \
5958 uExitInfo1 = 0; \
5959 IEM_SVM_VMEXIT_RET(a_pVCpu, a_uExitCode, uExitInfo1, 0); \
5960 } while (0)
5961
5962/** Check and handles SVM nested-guest instruction intercept and updates
5963 * NRIP if needed.
5964 */
5965# define IEM_SVM_CHECK_INSTR_INTERCEPT(a_pVCpu, a_Intercept, a_uExitCode, a_uExitInfo1, a_uExitInfo2, a_cbInstr) \
5966 do \
5967 { \
5968 if (IEM_SVM_IS_CTRL_INTERCEPT_SET(a_pVCpu, a_Intercept)) \
5969 { \
5970 IEM_SVM_UPDATE_NRIP(a_pVCpu, a_cbInstr); \
5971 IEM_SVM_VMEXIT_RET(a_pVCpu, a_uExitCode, a_uExitInfo1, a_uExitInfo2); \
5972 } \
5973 } while (0)
5974
5975/** Checks and handles SVM nested-guest CR0 read intercept. */
5976# define IEM_SVM_CHECK_READ_CR0_INTERCEPT(a_pVCpu, a_uExitInfo1, a_uExitInfo2, a_cbInstr) \
5977 do \
5978 { \
5979 if (!IEM_SVM_IS_READ_CR_INTERCEPT_SET(a_pVCpu, 0)) \
5980 { /* probably likely */ } \
5981 else \
5982 { \
5983 IEM_SVM_UPDATE_NRIP(a_pVCpu, a_cbInstr); \
5984 IEM_SVM_VMEXIT_RET(a_pVCpu, SVM_EXIT_READ_CR0, a_uExitInfo1, a_uExitInfo2); \
5985 } \
5986 } while (0)
5987
5988/**
5989 * Updates the NextRIP (NRI) field in the nested-guest VMCB.
5990 */
5991# define IEM_SVM_UPDATE_NRIP(a_pVCpu, a_cbInstr) \
5992 do { \
5993 if (IEM_GET_GUEST_CPU_FEATURES(a_pVCpu)->fSvmNextRipSave) \
5994 CPUMGuestSvmUpdateNRip(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_cbInstr)); \
5995 } while (0)
5996
5997#else
5998# define IEM_SVM_IS_CTRL_INTERCEPT_SET(a_pVCpu, a_Intercept) (false)
5999# define IEM_SVM_IS_READ_CR_INTERCEPT_SET(a_pVCpu, a_uCr) (false)
6000# define IEM_SVM_IS_WRITE_CR_INTERCEPT_SET(a_pVCpu, a_uCr) (false)
6001# define IEM_SVM_IS_READ_DR_INTERCEPT_SET(a_pVCpu, a_uDr) (false)
6002# define IEM_SVM_IS_WRITE_DR_INTERCEPT_SET(a_pVCpu, a_uDr) (false)
6003# define IEM_SVM_IS_XCPT_INTERCEPT_SET(a_pVCpu, a_uVector) (false)
6004# define IEM_SVM_VMEXIT_RET(a_pVCpu, a_uExitCode, a_uExitInfo1, a_uExitInfo2) do { return VERR_SVM_IPE_1; } while (0)
6005# define IEM_SVM_CRX_VMEXIT_RET(a_pVCpu, a_uExitCode, a_enmAccessCrX, a_iGReg) do { return VERR_SVM_IPE_1; } while (0)
6006# define IEM_SVM_CHECK_INSTR_INTERCEPT(a_pVCpu, a_Intercept, a_uExitCode, \
6007 a_uExitInfo1, a_uExitInfo2, a_cbInstr) do { } while (0)
6008# define IEM_SVM_CHECK_READ_CR0_INTERCEPT(a_pVCpu, a_uExitInfo1, a_uExitInfo2, a_cbInstr) do { } while (0)
6009# define IEM_SVM_UPDATE_NRIP(a_pVCpu, a_cbInstr) do { } while (0)
6010
6011#endif
6012
6013/** @} */
6014
6015uint32_t iemCalcExecDbgFlagsSlow(PVMCPUCC pVCpu);
6016VBOXSTRICTRC iemExecInjectPendingTrap(PVMCPUCC pVCpu);
6017
6018
6019/**
6020 * Selector descriptor table entry as fetched by iemMemFetchSelDesc.
6021 */
6022typedef union IEMSELDESC
6023{
6024 /** The legacy view. */
6025 X86DESC Legacy;
6026 /** The long mode view. */
6027 X86DESC64 Long;
6028} IEMSELDESC;
6029/** Pointer to a selector descriptor table entry. */
6030typedef IEMSELDESC *PIEMSELDESC;
6031
6032/** @name Raising Exceptions.
6033 * @{ */
6034VBOXSTRICTRC iemTaskSwitch(PVMCPUCC pVCpu, IEMTASKSWITCH enmTaskSwitch, uint32_t uNextEip, uint32_t fFlags,
6035 uint16_t uErr, uint64_t uCr2, RTSEL SelTSS, PIEMSELDESC pNewDescTSS) RT_NOEXCEPT;
6036
6037VBOXSTRICTRC iemRaiseXcptOrInt(PVMCPUCC pVCpu, uint8_t cbInstr, uint8_t u8Vector, uint32_t fFlags,
6038 uint16_t uErr, uint64_t uCr2) RT_NOEXCEPT;
6039#ifdef IEM_WITH_SETJMP
6040DECL_NO_RETURN(void) iemRaiseXcptOrIntJmp(PVMCPUCC pVCpu, uint8_t cbInstr, uint8_t u8Vector,
6041 uint32_t fFlags, uint16_t uErr, uint64_t uCr2) IEM_NOEXCEPT_MAY_LONGJMP;
6042#endif
6043VBOXSTRICTRC iemRaiseDivideError(PVMCPUCC pVCpu) RT_NOEXCEPT;
6044#ifdef IEM_WITH_SETJMP
6045DECL_NO_RETURN(void) iemRaiseDivideErrorJmp(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP;
6046#endif
6047VBOXSTRICTRC iemRaiseDebugException(PVMCPUCC pVCpu) RT_NOEXCEPT;
6048VBOXSTRICTRC iemRaiseBoundRangeExceeded(PVMCPUCC pVCpu) RT_NOEXCEPT;
6049VBOXSTRICTRC iemRaiseUndefinedOpcode(PVMCPUCC pVCpu) RT_NOEXCEPT;
6050#ifdef IEM_WITH_SETJMP
6051DECL_NO_RETURN(void) iemRaiseUndefinedOpcodeJmp(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP;
6052#endif
6053VBOXSTRICTRC iemRaiseDeviceNotAvailable(PVMCPUCC pVCpu) RT_NOEXCEPT;
6054#ifdef IEM_WITH_SETJMP
6055DECL_NO_RETURN(void) iemRaiseDeviceNotAvailableJmp(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP;
6056#endif
6057VBOXSTRICTRC iemRaiseTaskSwitchFaultWithErr(PVMCPUCC pVCpu, uint16_t uErr) RT_NOEXCEPT;
6058VBOXSTRICTRC iemRaiseTaskSwitchFaultCurrentTSS(PVMCPUCC pVCpu) RT_NOEXCEPT;
6059VBOXSTRICTRC iemRaiseTaskSwitchFault0(PVMCPUCC pVCpu) RT_NOEXCEPT;
6060VBOXSTRICTRC iemRaiseTaskSwitchFaultBySelector(PVMCPUCC pVCpu, uint16_t uSel) RT_NOEXCEPT;
6061/*VBOXSTRICTRC iemRaiseSelectorNotPresent(PVMCPUCC pVCpu, uint32_t iSegReg, uint32_t fAccess) RT_NOEXCEPT;*/
6062VBOXSTRICTRC iemRaiseSelectorNotPresentWithErr(PVMCPUCC pVCpu, uint16_t uErr) RT_NOEXCEPT;
6063VBOXSTRICTRC iemRaiseSelectorNotPresentBySelector(PVMCPUCC pVCpu, uint16_t uSel) RT_NOEXCEPT;
6064VBOXSTRICTRC iemRaiseStackSelectorNotPresentBySelector(PVMCPUCC pVCpu, uint16_t uSel) RT_NOEXCEPT;
6065VBOXSTRICTRC iemRaiseStackSelectorNotPresentWithErr(PVMCPUCC pVCpu, uint16_t uErr) RT_NOEXCEPT;
6066VBOXSTRICTRC iemRaiseGeneralProtectionFault(PVMCPUCC pVCpu, uint16_t uErr) RT_NOEXCEPT;
6067VBOXSTRICTRC iemRaiseGeneralProtectionFault0(PVMCPUCC pVCpu) RT_NOEXCEPT;
6068#ifdef IEM_WITH_SETJMP
6069DECL_NO_RETURN(void) iemRaiseGeneralProtectionFault0Jmp(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP;
6070#endif
6071VBOXSTRICTRC iemRaiseGeneralProtectionFaultBySelector(PVMCPUCC pVCpu, RTSEL Sel) RT_NOEXCEPT;
6072VBOXSTRICTRC iemRaiseNotCanonical(PVMCPUCC pVCpu) RT_NOEXCEPT;
6073VBOXSTRICTRC iemRaiseSelectorBounds(PVMCPUCC pVCpu, uint32_t iSegReg, uint32_t fAccess) RT_NOEXCEPT;
6074#ifdef IEM_WITH_SETJMP
6075DECL_NO_RETURN(void) iemRaiseSelectorBoundsJmp(PVMCPUCC pVCpu, uint32_t iSegReg, uint32_t fAccess) IEM_NOEXCEPT_MAY_LONGJMP;
6076#endif
6077VBOXSTRICTRC iemRaiseSelectorBoundsBySelector(PVMCPUCC pVCpu, RTSEL Sel) RT_NOEXCEPT;
6078#ifdef IEM_WITH_SETJMP
6079DECL_NO_RETURN(void) iemRaiseSelectorBoundsBySelectorJmp(PVMCPUCC pVCpu, RTSEL Sel) IEM_NOEXCEPT_MAY_LONGJMP;
6080#endif
6081VBOXSTRICTRC iemRaiseSelectorInvalidAccess(PVMCPUCC pVCpu, uint32_t iSegReg, uint32_t fAccess) RT_NOEXCEPT;
6082#ifdef IEM_WITH_SETJMP
6083DECL_NO_RETURN(void) iemRaiseSelectorInvalidAccessJmp(PVMCPUCC pVCpu, uint32_t iSegReg, uint32_t fAccess) IEM_NOEXCEPT_MAY_LONGJMP;
6084#endif
6085VBOXSTRICTRC iemRaisePageFault(PVMCPUCC pVCpu, RTGCPTR GCPtrWhere, uint32_t cbAccess, uint32_t fAccess, int rc) RT_NOEXCEPT;
6086#ifdef IEM_WITH_SETJMP
6087DECL_NO_RETURN(void) iemRaisePageFaultJmp(PVMCPUCC pVCpu, RTGCPTR GCPtrWhere, uint32_t cbAccess, uint32_t fAccess, int rc) IEM_NOEXCEPT_MAY_LONGJMP;
6088#endif
6089VBOXSTRICTRC iemRaiseMathFault(PVMCPUCC pVCpu) RT_NOEXCEPT;
6090#ifdef IEM_WITH_SETJMP
6091DECL_NO_RETURN(void) iemRaiseMathFaultJmp(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP;
6092#endif
6093VBOXSTRICTRC iemRaiseAlignmentCheckException(PVMCPUCC pVCpu) RT_NOEXCEPT;
6094#ifdef IEM_WITH_SETJMP
6095DECL_NO_RETURN(void) iemRaiseAlignmentCheckExceptionJmp(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP;
6096#endif
6097VBOXSTRICTRC iemRaiseSimdFpException(PVMCPUCC pVCpu) RT_NOEXCEPT;
6098#ifdef IEM_WITH_SETJMP
6099DECL_NO_RETURN(void) iemRaiseSimdFpExceptionJmp(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP;
6100#endif
6101
6102void iemLogSyscallRealModeInt(PVMCPUCC pVCpu, uint8_t u8Vector, uint8_t cbInstr);
6103void iemLogSyscallProtModeInt(PVMCPUCC pVCpu, uint8_t u8Vector, uint8_t cbInstr);
6104
6105IEM_CIMPL_DEF_0(iemCImplRaiseDivideError);
6106IEM_CIMPL_DEF_0(iemCImplRaiseInvalidLockPrefix);
6107IEM_CIMPL_DEF_0(iemCImplRaiseInvalidOpcode);
6108
6109/**
6110 * Macro for calling iemCImplRaiseDivideError().
6111 *
6112 * This is for things that will _always_ decode to an \#DE, taking the
6113 * recompiler into consideration and everything.
6114 *
6115 * @return Strict VBox status code.
6116 */
6117#define IEMOP_RAISE_DIVIDE_ERROR_RET() IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_XCPT, 0, iemCImplRaiseDivideError)
6118
6119/**
6120 * Macro for calling iemCImplRaiseInvalidLockPrefix().
6121 *
6122 * This is for things that will _always_ decode to an \#UD, taking the
6123 * recompiler into consideration and everything.
6124 *
6125 * @return Strict VBox status code.
6126 */
6127#define IEMOP_RAISE_INVALID_LOCK_PREFIX_RET() IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_XCPT, 0, iemCImplRaiseInvalidLockPrefix)
6128
6129/**
6130 * Macro for calling iemCImplRaiseInvalidOpcode() for decode/static \#UDs.
6131 *
6132 * This is for things that will _always_ decode to an \#UD, taking the
6133 * recompiler into consideration and everything.
6134 *
6135 * @return Strict VBox status code.
6136 */
6137#define IEMOP_RAISE_INVALID_OPCODE_RET() IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_XCPT, 0, iemCImplRaiseInvalidOpcode)
6138
6139/**
6140 * Macro for calling iemCImplRaiseInvalidOpcode() for runtime-style \#UDs.
6141 *
6142 * Using this macro means you've got _buggy_ _code_ and are doing things that
6143 * belongs exclusively in IEMAllCImpl.cpp during decoding.
6144 *
6145 * @return Strict VBox status code.
6146 * @see IEMOP_RAISE_INVALID_OPCODE_RET
6147 */
6148#define IEMOP_RAISE_INVALID_OPCODE_RUNTIME_RET() IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_XCPT, 0, iemCImplRaiseInvalidOpcode)
6149
6150/** @} */
6151
6152/** @name Register Access.
6153 * @{ */
6154VBOXSTRICTRC iemRegRipRelativeJumpS8AndFinishClearingRF(PVMCPUCC pVCpu, uint8_t cbInstr, int8_t offNextInstr,
6155 IEMMODE enmEffOpSize) RT_NOEXCEPT;
6156VBOXSTRICTRC iemRegRipRelativeJumpS16AndFinishClearingRF(PVMCPUCC pVCpu, uint8_t cbInstr, int16_t offNextInstr) RT_NOEXCEPT;
6157VBOXSTRICTRC iemRegRipRelativeJumpS32AndFinishClearingRF(PVMCPUCC pVCpu, uint8_t cbInstr, int32_t offNextInstr,
6158 IEMMODE enmEffOpSize) RT_NOEXCEPT;
6159/** @} */
6160
6161/** @name FPU access and helpers.
6162 * @{ */
6163void iemFpuPushResult(PVMCPUCC pVCpu, PIEMFPURESULT pResult, uint16_t uFpuOpcode) RT_NOEXCEPT;
6164void iemFpuPushResultWithMemOp(PVMCPUCC pVCpu, PIEMFPURESULT pResult, uint8_t iEffSeg, RTGCPTR GCPtrEff, uint16_t uFpuOpcode) RT_NOEXCEPT;
6165void iemFpuPushResultTwo(PVMCPUCC pVCpu, PIEMFPURESULTTWO pResult, uint16_t uFpuOpcode) RT_NOEXCEPT;
6166void iemFpuStoreResult(PVMCPUCC pVCpu, PIEMFPURESULT pResult, uint8_t iStReg, uint16_t uFpuOpcode) RT_NOEXCEPT;
6167void iemFpuStoreResultThenPop(PVMCPUCC pVCpu, PIEMFPURESULT pResult, uint8_t iStReg, uint16_t uFpuOpcode) RT_NOEXCEPT;
6168void iemFpuStoreResultWithMemOp(PVMCPUCC pVCpu, PIEMFPURESULT pResult, uint8_t iStReg,
6169 uint8_t iEffSeg, RTGCPTR GCPtrEff, uint16_t uFpuOpcode) RT_NOEXCEPT;
6170void iemFpuStoreResultWithMemOpThenPop(PVMCPUCC pVCpu, PIEMFPURESULT pResult, uint8_t iStReg,
6171 uint8_t iEffSeg, RTGCPTR GCPtrEff, uint16_t uFpuOpcode) RT_NOEXCEPT;
6172void iemFpuUpdateOpcodeAndIp(PVMCPUCC pVCpu, uint16_t uFpuOpcode) RT_NOEXCEPT;
6173void iemFpuUpdateFSW(PVMCPUCC pVCpu, uint16_t u16FSW, uint16_t uFpuOpcode) RT_NOEXCEPT;
6174void iemFpuUpdateFSWThenPop(PVMCPUCC pVCpu, uint16_t u16FSW, uint16_t uFpuOpcode) RT_NOEXCEPT;
6175void iemFpuUpdateFSWWithMemOp(PVMCPUCC pVCpu, uint16_t u16FSW, uint8_t iEffSeg, RTGCPTR GCPtrEff, uint16_t uFpuOpcode) RT_NOEXCEPT;
6176void iemFpuUpdateFSWThenPopPop(PVMCPUCC pVCpu, uint16_t u16FSW, uint16_t uFpuOpcode) RT_NOEXCEPT;
6177void iemFpuUpdateFSWWithMemOpThenPop(PVMCPUCC pVCpu, uint16_t u16FSW, uint8_t iEffSeg, RTGCPTR GCPtrEff, uint16_t uFpuOpcode) RT_NOEXCEPT;
6178void iemFpuStackUnderflow(PVMCPUCC pVCpu, uint8_t iStReg, uint16_t uFpuOpcode) RT_NOEXCEPT;
6179void iemFpuStackUnderflowWithMemOp(PVMCPUCC pVCpu, uint8_t iStReg, uint8_t iEffSeg, RTGCPTR GCPtrEff, uint16_t uFpuOpcode) RT_NOEXCEPT;
6180void iemFpuStackUnderflowThenPop(PVMCPUCC pVCpu, uint8_t iStReg, uint16_t uFpuOpcode) RT_NOEXCEPT;
6181void iemFpuStackUnderflowWithMemOpThenPop(PVMCPUCC pVCpu, uint8_t iStReg, uint8_t iEffSeg, RTGCPTR GCPtrEff, uint16_t uFpuOpcode) RT_NOEXCEPT;
6182void iemFpuStackUnderflowThenPopPop(PVMCPUCC pVCpu, uint16_t uFpuOpcode) RT_NOEXCEPT;
6183void iemFpuStackPushUnderflow(PVMCPUCC pVCpu, uint16_t uFpuOpcode) RT_NOEXCEPT;
6184void iemFpuStackPushUnderflowTwo(PVMCPUCC pVCpu, uint16_t uFpuOpcode) RT_NOEXCEPT;
6185void iemFpuStackPushOverflow(PVMCPUCC pVCpu, uint16_t uFpuOpcode) RT_NOEXCEPT;
6186void iemFpuStackPushOverflowWithMemOp(PVMCPUCC pVCpu, uint8_t iEffSeg, RTGCPTR GCPtrEff, uint16_t uFpuOpcode) RT_NOEXCEPT;
6187/** @} */
6188
6189/** @name SSE+AVX SIMD access and helpers.
6190 * @{ */
6191void iemSseUpdateMxcsr(PVMCPUCC pVCpu, uint32_t fMxcsr) RT_NOEXCEPT;
6192/** @} */
6193
6194/** @name Memory access.
6195 * @{ */
6196
6197/** Report a \#GP instead of \#AC and do not restrict to ring-3 */
6198#define IEM_MEMMAP_F_ALIGN_GP RT_BIT_32(16)
6199/** SSE access that should report a \#GP instead of \#AC, unless MXCSR.MM=1
6200 * when it works like normal \#AC. Always used with IEM_MEMMAP_F_ALIGN_GP. */
6201#define IEM_MEMMAP_F_ALIGN_SSE RT_BIT_32(17)
6202/** If \#AC is applicable, raise it. Always used with IEM_MEMMAP_F_ALIGN_GP.
6203 * Users include FXSAVE & FXRSTOR. */
6204#define IEM_MEMMAP_F_ALIGN_GP_OR_AC RT_BIT_32(18)
6205
6206VBOXSTRICTRC iemMemMap(PVMCPUCC pVCpu, void **ppvMem, uint8_t *pbUnmapInfo, size_t cbMem, uint8_t iSegReg, RTGCPTR GCPtrMem,
6207 uint32_t fAccess, uint32_t uAlignCtl) RT_NOEXCEPT;
6208VBOXSTRICTRC iemMemCommitAndUnmap(PVMCPUCC pVCpu, uint8_t bUnmapInfo) RT_NOEXCEPT;
6209#ifndef IN_RING3
6210VBOXSTRICTRC iemMemCommitAndUnmapPostponeTroubleToR3(PVMCPUCC pVCpu, uint8_t bUnmapInfo) RT_NOEXCEPT;
6211#endif
6212void iemMemRollbackAndUnmap(PVMCPUCC pVCpu, uint8_t bUnmapInfo) RT_NOEXCEPT;
6213void iemMemRollback(PVMCPUCC pVCpu) RT_NOEXCEPT;
6214VBOXSTRICTRC iemMemApplySegment(PVMCPUCC pVCpu, uint32_t fAccess, uint8_t iSegReg, size_t cbMem, PRTGCPTR pGCPtrMem) RT_NOEXCEPT;
6215VBOXSTRICTRC iemMemMarkSelDescAccessed(PVMCPUCC pVCpu, uint16_t uSel) RT_NOEXCEPT;
6216VBOXSTRICTRC iemMemPageTranslateAndCheckAccess(PVMCPUCC pVCpu, RTGCPTR GCPtrMem, uint32_t cbAccess, uint32_t fAccess, PRTGCPHYS pGCPhysMem) RT_NOEXCEPT;
6217
6218void iemOpcodeFlushLight(PVMCPUCC pVCpu, uint8_t cbInstr);
6219void iemOpcodeFlushHeavy(PVMCPUCC pVCpu, uint8_t cbInstr);
6220#ifdef IEM_WITH_CODE_TLB
6221void iemOpcodeFetchBytesJmp(PVMCPUCC pVCpu, size_t cbDst, void *pvDst) IEM_NOEXCEPT_MAY_LONGJMP;
6222#else
6223VBOXSTRICTRC iemOpcodeFetchMoreBytes(PVMCPUCC pVCpu, size_t cbMin) RT_NOEXCEPT;
6224#endif
6225#ifdef IEM_WITH_SETJMP
6226uint8_t iemOpcodeGetNextU8SlowJmp(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP;
6227uint16_t iemOpcodeGetNextU16SlowJmp(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP;
6228uint32_t iemOpcodeGetNextU32SlowJmp(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP;
6229uint64_t iemOpcodeGetNextU64SlowJmp(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP;
6230#else
6231VBOXSTRICTRC iemOpcodeGetNextU8Slow(PVMCPUCC pVCpu, uint8_t *pb) RT_NOEXCEPT;
6232VBOXSTRICTRC iemOpcodeGetNextS8SxU16Slow(PVMCPUCC pVCpu, uint16_t *pu16) RT_NOEXCEPT;
6233VBOXSTRICTRC iemOpcodeGetNextS8SxU32Slow(PVMCPUCC pVCpu, uint32_t *pu32) RT_NOEXCEPT;
6234VBOXSTRICTRC iemOpcodeGetNextS8SxU64Slow(PVMCPUCC pVCpu, uint64_t *pu64) RT_NOEXCEPT;
6235VBOXSTRICTRC iemOpcodeGetNextU16Slow(PVMCPUCC pVCpu, uint16_t *pu16) RT_NOEXCEPT;
6236VBOXSTRICTRC iemOpcodeGetNextU16ZxU32Slow(PVMCPUCC pVCpu, uint32_t *pu32) RT_NOEXCEPT;
6237VBOXSTRICTRC iemOpcodeGetNextU16ZxU64Slow(PVMCPUCC pVCpu, uint64_t *pu64) RT_NOEXCEPT;
6238VBOXSTRICTRC iemOpcodeGetNextU32Slow(PVMCPUCC pVCpu, uint32_t *pu32) RT_NOEXCEPT;
6239VBOXSTRICTRC iemOpcodeGetNextU32ZxU64Slow(PVMCPUCC pVCpu, uint64_t *pu64) RT_NOEXCEPT;
6240VBOXSTRICTRC iemOpcodeGetNextS32SxU64Slow(PVMCPUCC pVCpu, uint64_t *pu64) RT_NOEXCEPT;
6241VBOXSTRICTRC iemOpcodeGetNextU64Slow(PVMCPUCC pVCpu, uint64_t *pu64) RT_NOEXCEPT;
6242#endif
6243
6244VBOXSTRICTRC iemMemFetchDataU8(PVMCPUCC pVCpu, uint8_t *pu8Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
6245VBOXSTRICTRC iemMemFetchDataU16(PVMCPUCC pVCpu, uint16_t *pu16Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
6246VBOXSTRICTRC iemMemFetchDataU32(PVMCPUCC pVCpu, uint32_t *pu32Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
6247VBOXSTRICTRC iemMemFetchDataU32NoAc(PVMCPUCC pVCpu, uint32_t *pu32Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
6248VBOXSTRICTRC iemMemFetchDataU32_ZX_U64(PVMCPUCC pVCpu, uint64_t *pu64Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
6249VBOXSTRICTRC iemMemFetchDataU64(PVMCPUCC pVCpu, uint64_t *pu64Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
6250VBOXSTRICTRC iemMemFetchDataU64NoAc(PVMCPUCC pVCpu, uint64_t *pu64Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
6251VBOXSTRICTRC iemMemFetchDataU64AlignedU128(PVMCPUCC pVCpu, uint64_t *pu64Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
6252VBOXSTRICTRC iemMemFetchDataR80(PVMCPUCC pVCpu, PRTFLOAT80U pr80Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
6253VBOXSTRICTRC iemMemFetchDataD80(PVMCPUCC pVCpu, PRTPBCD80U pd80Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
6254VBOXSTRICTRC iemMemFetchDataU128(PVMCPUCC pVCpu, PRTUINT128U pu128Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
6255VBOXSTRICTRC iemMemFetchDataU128NoAc(PVMCPUCC pVCpu, PRTUINT128U pu128Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
6256VBOXSTRICTRC iemMemFetchDataU128AlignedSse(PVMCPUCC pVCpu, PRTUINT128U pu128Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
6257VBOXSTRICTRC iemMemFetchDataU256(PVMCPUCC pVCpu, PRTUINT256U pu256Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
6258VBOXSTRICTRC iemMemFetchDataU256NoAc(PVMCPUCC pVCpu, PRTUINT256U pu256Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
6259VBOXSTRICTRC iemMemFetchDataU256AlignedAvx(PVMCPUCC pVCpu, PRTUINT256U pu256Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
6260VBOXSTRICTRC iemMemFetchDataXdtr(PVMCPUCC pVCpu, uint16_t *pcbLimit, PRTGCPTR pGCPtrBase, uint8_t iSegReg,
6261 RTGCPTR GCPtrMem, IEMMODE enmOpSize) RT_NOEXCEPT;
6262#ifdef IEM_WITH_SETJMP
6263uint8_t iemMemFetchDataU8SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6264uint16_t iemMemFetchDataU16SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6265uint32_t iemMemFetchDataU32SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6266uint32_t iemMemFetchDataU32NoAcSafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6267uint32_t iemMemFlatFetchDataU32SafeJmp(PVMCPUCC pVCpu, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6268uint64_t iemMemFetchDataU64SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6269uint64_t iemMemFetchDataU64NoAcSafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6270uint64_t iemMemFetchDataU64AlignedU128SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6271void iemMemFetchDataR80SafeJmp(PVMCPUCC pVCpu, PRTFLOAT80U pr80Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6272void iemMemFetchDataD80SafeJmp(PVMCPUCC pVCpu, PRTPBCD80U pd80Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6273void iemMemFetchDataU128SafeJmp(PVMCPUCC pVCpu, PRTUINT128U pu128Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6274void iemMemFetchDataU128NoAcSafeJmp(PVMCPUCC pVCpu, PRTUINT128U pu128Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6275void iemMemFetchDataU128AlignedSseSafeJmp(PVMCPUCC pVCpu, PRTUINT128U pu128Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6276void iemMemFetchDataU256SafeJmp(PVMCPUCC pVCpu, PRTUINT256U pu256Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6277void iemMemFetchDataU256NoAcSafeJmp(PVMCPUCC pVCpu, PRTUINT256U pu256Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6278void iemMemFetchDataU256AlignedAvxSafeJmp(PVMCPUCC pVCpu, PRTUINT256U pu256Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6279# if 0 /* these are inlined now */
6280uint8_t iemMemFetchDataU8Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6281uint16_t iemMemFetchDataU16Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6282uint32_t iemMemFetchDataU32Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6283uint32_t iemMemFlatFetchDataU32Jmp(PVMCPUCC pVCpu, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6284uint64_t iemMemFetchDataU64Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6285uint64_t iemMemFetchDataU64AlignedU128Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6286void iemMemFetchDataR80Jmp(PVMCPUCC pVCpu, PRTFLOAT80U pr80Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6287void iemMemFetchDataD80Jmp(PVMCPUCC pVCpu, PRTPBCD80U pd80Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6288void iemMemFetchDataU128Jmp(PVMCPUCC pVCpu, PRTUINT128U pu128Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6289void iemMemFetchDataU128NoAcJmp(PVMCPUCC pVCpu, PRTUINT128U pu128Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6290void iemMemFetchDataU128AlignedSseJmp(PVMCPUCC pVCpu, PRTUINT128U pu128Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6291void iemMemFetchDataU256NoAcJmp(PVMCPUCC pVCpu, PRTUINT256U pu256Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6292void iemMemFetchDataU256AlignedAvxJmp(PVMCPUCC pVCpu, PRTUINT256U pu256Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6293# endif
6294void iemMemFetchDataU256Jmp(PVMCPUCC pVCpu, PRTUINT256U pu256Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6295#endif
6296
6297VBOXSTRICTRC iemMemFetchSysU8(PVMCPUCC pVCpu, uint8_t *pu8Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
6298VBOXSTRICTRC iemMemFetchSysU16(PVMCPUCC pVCpu, uint16_t *pu16Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
6299VBOXSTRICTRC iemMemFetchSysU32(PVMCPUCC pVCpu, uint32_t *pu32Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
6300VBOXSTRICTRC iemMemFetchSysU64(PVMCPUCC pVCpu, uint64_t *pu64Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
6301VBOXSTRICTRC iemMemFetchSelDesc(PVMCPUCC pVCpu, PIEMSELDESC pDesc, uint16_t uSel, uint8_t uXcpt) RT_NOEXCEPT;
6302
6303VBOXSTRICTRC iemMemStoreDataU8(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint8_t u8Value) RT_NOEXCEPT;
6304VBOXSTRICTRC iemMemStoreDataU16(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint16_t u16Value) RT_NOEXCEPT;
6305VBOXSTRICTRC iemMemStoreDataU32(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint32_t u32Value) RT_NOEXCEPT;
6306VBOXSTRICTRC iemMemStoreDataU64(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint64_t u64Value) RT_NOEXCEPT;
6307VBOXSTRICTRC iemMemStoreDataU128(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, RTUINT128U u128Value) RT_NOEXCEPT;
6308VBOXSTRICTRC iemMemStoreDataU128NoAc(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, RTUINT128U u128Value) RT_NOEXCEPT;
6309VBOXSTRICTRC iemMemStoreDataU128AlignedSse(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, RTUINT128U u128Value) RT_NOEXCEPT;
6310VBOXSTRICTRC iemMemStoreDataU256(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTUINT256U pu256Value) RT_NOEXCEPT;
6311VBOXSTRICTRC iemMemStoreDataU256NoAc(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTUINT256U pu256Value) RT_NOEXCEPT;
6312VBOXSTRICTRC iemMemStoreDataU256AlignedAvx(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTUINT256U pu256Value) RT_NOEXCEPT;
6313VBOXSTRICTRC iemMemStoreDataXdtr(PVMCPUCC pVCpu, uint16_t cbLimit, RTGCPTR GCPtrBase, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
6314#ifdef IEM_WITH_SETJMP
6315void iemMemStoreDataU8SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint8_t u8Value) IEM_NOEXCEPT_MAY_LONGJMP;
6316void iemMemStoreDataU16SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint16_t u16Value) IEM_NOEXCEPT_MAY_LONGJMP;
6317void iemMemStoreDataU32SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint32_t u32Value) IEM_NOEXCEPT_MAY_LONGJMP;
6318void iemMemStoreDataU64SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint64_t u64Value) IEM_NOEXCEPT_MAY_LONGJMP;
6319void iemMemStoreDataU128SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTUINT128U u128Value) IEM_NOEXCEPT_MAY_LONGJMP;
6320void iemMemStoreDataU128NoAcSafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTUINT128U pu128Value) IEM_NOEXCEPT_MAY_LONGJMP;
6321void iemMemStoreDataU128AlignedSseSafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTUINT128U pu128Value) IEM_NOEXCEPT_MAY_LONGJMP;
6322void iemMemStoreDataU256SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTUINT256U pu256Value) IEM_NOEXCEPT_MAY_LONGJMP;
6323void iemMemStoreDataU256NoAcSafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTUINT256U pu256Value) IEM_NOEXCEPT_MAY_LONGJMP;
6324void iemMemStoreDataU256AlignedAvxSafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTUINT256U pu256Value) IEM_NOEXCEPT_MAY_LONGJMP;
6325void iemMemStoreDataR80SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTFLOAT80U pr80Value) IEM_NOEXCEPT_MAY_LONGJMP;
6326void iemMemStoreDataD80SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTPBCD80U pd80Value) IEM_NOEXCEPT_MAY_LONGJMP;
6327#if 0
6328void iemMemStoreDataU8Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint8_t u8Value) IEM_NOEXCEPT_MAY_LONGJMP;
6329void iemMemStoreDataU16Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint16_t u16Value) IEM_NOEXCEPT_MAY_LONGJMP;
6330void iemMemStoreDataU32Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint32_t u32Value) IEM_NOEXCEPT_MAY_LONGJMP;
6331void iemMemStoreDataU64Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint64_t u64Value) IEM_NOEXCEPT_MAY_LONGJMP;
6332void iemMemStoreDataU128Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, RTUINT128U u128Value) IEM_NOEXCEPT_MAY_LONGJMP;
6333void iemMemStoreDataNoAcU128Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, RTUINT128U u128Value) IEM_NOEXCEPT_MAY_LONGJMP;
6334void iemMemStoreDataU256NoAcJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTUINT256U pu256Value) IEM_NOEXCEPT_MAY_LONGJMP;
6335void iemMemStoreDataU256AlignedAvxJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTUINT256U pu256Value) IEM_NOEXCEPT_MAY_LONGJMP;
6336#endif
6337void iemMemStoreDataU128AlignedSseJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, RTUINT128U u128Value) IEM_NOEXCEPT_MAY_LONGJMP;
6338void iemMemStoreDataU256Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTUINT256U pu256Value) IEM_NOEXCEPT_MAY_LONGJMP;
6339#endif
6340
6341#ifdef IEM_WITH_SETJMP
6342uint8_t *iemMemMapDataU8RwSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6343uint8_t *iemMemMapDataU8AtSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6344uint8_t *iemMemMapDataU8WoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6345uint8_t const *iemMemMapDataU8RoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6346uint16_t *iemMemMapDataU16RwSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6347uint16_t *iemMemMapDataU16AtSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6348uint16_t *iemMemMapDataU16WoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6349uint16_t const *iemMemMapDataU16RoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6350uint32_t *iemMemMapDataU32RwSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6351uint32_t *iemMemMapDataU32AtSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6352uint32_t *iemMemMapDataU32WoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6353uint32_t const *iemMemMapDataU32RoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6354uint64_t *iemMemMapDataU64RwSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6355uint64_t *iemMemMapDataU64AtSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6356uint64_t *iemMemMapDataU64WoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6357uint64_t const *iemMemMapDataU64RoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6358PRTFLOAT80U iemMemMapDataR80RwSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6359PRTFLOAT80U iemMemMapDataR80WoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6360PCRTFLOAT80U iemMemMapDataR80RoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6361PRTPBCD80U iemMemMapDataD80RwSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6362PRTPBCD80U iemMemMapDataD80WoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6363PCRTPBCD80U iemMemMapDataD80RoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6364PRTUINT128U iemMemMapDataU128RwSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6365PRTUINT128U iemMemMapDataU128AtSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6366PRTUINT128U iemMemMapDataU128WoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6367PCRTUINT128U iemMemMapDataU128RoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6368
6369void iemMemCommitAndUnmapJmp(PVMCPUCC pVCpu, uint8_t bUnmapInfo) IEM_NOEXCEPT_MAY_LONGJMP;
6370void iemMemCommitAndUnmapRwSafeJmp(PVMCPUCC pVCpu, uint8_t bUnmapInfo) IEM_NOEXCEPT_MAY_LONGJMP;
6371void iemMemCommitAndUnmapAtSafeJmp(PVMCPUCC pVCpu, uint8_t bUnmapInfo) IEM_NOEXCEPT_MAY_LONGJMP;
6372void iemMemCommitAndUnmapWoSafeJmp(PVMCPUCC pVCpu, uint8_t bUnmapInfo) IEM_NOEXCEPT_MAY_LONGJMP;
6373void iemMemCommitAndUnmapRoSafeJmp(PVMCPUCC pVCpu, uint8_t bUnmapInfo) IEM_NOEXCEPT_MAY_LONGJMP;
6374void iemMemRollbackAndUnmapWoSafe(PVMCPUCC pVCpu, uint8_t bUnmapInfo) RT_NOEXCEPT;
6375#endif
6376
6377VBOXSTRICTRC iemMemStackPushBeginSpecial(PVMCPUCC pVCpu, size_t cbMem, uint32_t cbAlign,
6378 void **ppvMem, uint8_t *pbUnmapInfo, uint64_t *puNewRsp) RT_NOEXCEPT;
6379VBOXSTRICTRC iemMemStackPushCommitSpecial(PVMCPUCC pVCpu, uint8_t bUnmapInfo, uint64_t uNewRsp) RT_NOEXCEPT;
6380VBOXSTRICTRC iemMemStackPushU16(PVMCPUCC pVCpu, uint16_t u16Value) RT_NOEXCEPT;
6381VBOXSTRICTRC iemMemStackPushU32(PVMCPUCC pVCpu, uint32_t u32Value) RT_NOEXCEPT;
6382VBOXSTRICTRC iemMemStackPushU64(PVMCPUCC pVCpu, uint64_t u64Value) RT_NOEXCEPT;
6383VBOXSTRICTRC iemMemStackPushU16Ex(PVMCPUCC pVCpu, uint16_t u16Value, PRTUINT64U pTmpRsp) RT_NOEXCEPT;
6384VBOXSTRICTRC iemMemStackPushU32Ex(PVMCPUCC pVCpu, uint32_t u32Value, PRTUINT64U pTmpRsp) RT_NOEXCEPT;
6385VBOXSTRICTRC iemMemStackPushU64Ex(PVMCPUCC pVCpu, uint64_t u64Value, PRTUINT64U pTmpRsp) RT_NOEXCEPT;
6386VBOXSTRICTRC iemMemStackPushU32SReg(PVMCPUCC pVCpu, uint32_t u32Value) RT_NOEXCEPT;
6387VBOXSTRICTRC iemMemStackPopBeginSpecial(PVMCPUCC pVCpu, size_t cbMem, uint32_t cbAlign,
6388 void const **ppvMem, uint8_t *pbUnmapInfo, uint64_t *puNewRsp) RT_NOEXCEPT;
6389VBOXSTRICTRC iemMemStackPopContinueSpecial(PVMCPUCC pVCpu, size_t off, size_t cbMem,
6390 void const **ppvMem, uint8_t *pbUnmapInfo, uint64_t uCurNewRsp) RT_NOEXCEPT;
6391VBOXSTRICTRC iemMemStackPopDoneSpecial(PVMCPUCC pVCpu, uint8_t bUnmapInfo) RT_NOEXCEPT;
6392VBOXSTRICTRC iemMemStackPopU16(PVMCPUCC pVCpu, uint16_t *pu16Value) RT_NOEXCEPT;
6393VBOXSTRICTRC iemMemStackPopU32(PVMCPUCC pVCpu, uint32_t *pu32Value) RT_NOEXCEPT;
6394VBOXSTRICTRC iemMemStackPopU64(PVMCPUCC pVCpu, uint64_t *pu64Value) RT_NOEXCEPT;
6395VBOXSTRICTRC iemMemStackPopU16Ex(PVMCPUCC pVCpu, uint16_t *pu16Value, PRTUINT64U pTmpRsp) RT_NOEXCEPT;
6396VBOXSTRICTRC iemMemStackPopU32Ex(PVMCPUCC pVCpu, uint32_t *pu32Value, PRTUINT64U pTmpRsp) RT_NOEXCEPT;
6397VBOXSTRICTRC iemMemStackPopU64Ex(PVMCPUCC pVCpu, uint64_t *pu64Value, PRTUINT64U pTmpRsp) RT_NOEXCEPT;
6398
6399#ifdef IEM_WITH_SETJMP
6400void iemMemStackPushU16SafeJmp(PVMCPUCC pVCpu, uint16_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
6401void iemMemStackPushU32SafeJmp(PVMCPUCC pVCpu, uint32_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
6402void iemMemStackPushU32SRegSafeJmp(PVMCPUCC pVCpu, uint32_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
6403void iemMemStackPushU64SafeJmp(PVMCPUCC pVCpu, uint64_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
6404void iemMemStackPopGRegU16SafeJmp(PVMCPUCC pVCpu, uint8_t iGReg) IEM_NOEXCEPT_MAY_LONGJMP;
6405void iemMemStackPopGRegU32SafeJmp(PVMCPUCC pVCpu, uint8_t iGReg) IEM_NOEXCEPT_MAY_LONGJMP;
6406void iemMemStackPopGRegU64SafeJmp(PVMCPUCC pVCpu, uint8_t iGReg) IEM_NOEXCEPT_MAY_LONGJMP;
6407
6408void iemMemFlat32StackPushU16SafeJmp(PVMCPUCC pVCpu, uint16_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
6409void iemMemFlat32StackPushU32SafeJmp(PVMCPUCC pVCpu, uint32_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
6410void iemMemFlat32StackPushU32SRegSafeJmp(PVMCPUCC pVCpu, uint32_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
6411void iemMemFlat32StackPopGRegU16SafeJmp(PVMCPUCC pVCpu, uint8_t iGReg) IEM_NOEXCEPT_MAY_LONGJMP;
6412void iemMemFlat32StackPopGRegU32SafeJmp(PVMCPUCC pVCpu, uint8_t iGReg) IEM_NOEXCEPT_MAY_LONGJMP;
6413
6414void iemMemFlat64StackPushU16SafeJmp(PVMCPUCC pVCpu, uint16_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
6415void iemMemFlat64StackPushU64SafeJmp(PVMCPUCC pVCpu, uint64_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
6416void iemMemFlat64StackPopGRegU16SafeJmp(PVMCPUCC pVCpu, uint8_t iGReg) IEM_NOEXCEPT_MAY_LONGJMP;
6417void iemMemFlat64StackPopGRegU64SafeJmp(PVMCPUCC pVCpu, uint8_t iGReg) IEM_NOEXCEPT_MAY_LONGJMP;
6418
6419void iemMemStoreStackU16SafeJmp(PVMCPUCC pVCpu, RTGCPTR GCPtrMem, uint16_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
6420void iemMemStoreStackU32SafeJmp(PVMCPUCC pVCpu, RTGCPTR GCPtrMem, uint32_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
6421void iemMemStoreStackU32SRegSafeJmp(PVMCPUCC pVCpu, RTGCPTR GCPtrMem, uint32_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
6422void iemMemStoreStackU64SafeJmp(PVMCPUCC pVCpu, RTGCPTR GCPtrMem, uint64_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
6423
6424uint16_t iemMemFetchStackU16SafeJmp(PVMCPUCC pVCpu, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6425uint32_t iemMemFetchStackU32SafeJmp(PVMCPUCC pVCpu, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6426uint64_t iemMemFetchStackU64SafeJmp(PVMCPUCC pVCpu, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
6427
6428#endif
6429
6430/** @} */
6431
6432/** @name IEMAllCImpl.cpp
6433 * @note sed -e '/IEM_CIMPL_DEF_/!d' -e 's/IEM_CIMPL_DEF_/IEM_CIMPL_PROTO_/' -e 's/$/;/'
6434 * @{ */
6435IEM_CIMPL_PROTO_2(iemCImpl_pop_mem16, uint16_t, iEffSeg, RTGCPTR, GCPtrEffDst);
6436IEM_CIMPL_PROTO_2(iemCImpl_pop_mem32, uint16_t, iEffSeg, RTGCPTR, GCPtrEffDst);
6437IEM_CIMPL_PROTO_2(iemCImpl_pop_mem64, uint16_t, iEffSeg, RTGCPTR, GCPtrEffDst);
6438IEM_CIMPL_PROTO_0(iemCImpl_popa_16);
6439IEM_CIMPL_PROTO_0(iemCImpl_popa_32);
6440IEM_CIMPL_PROTO_0(iemCImpl_pusha_16);
6441IEM_CIMPL_PROTO_0(iemCImpl_pusha_32);
6442IEM_CIMPL_PROTO_1(iemCImpl_pushf, IEMMODE, enmEffOpSize);
6443IEM_CIMPL_PROTO_1(iemCImpl_popf, IEMMODE, enmEffOpSize);
6444IEM_CIMPL_PROTO_3(iemCImpl_FarJmp, uint16_t, uSel, uint64_t, offSeg, IEMMODE, enmEffOpSize);
6445IEM_CIMPL_PROTO_3(iemCImpl_callf, uint16_t, uSel, uint64_t, offSeg, IEMMODE, enmEffOpSize);
6446typedef IEM_CIMPL_DECL_TYPE_3(FNIEMCIMPLFARBRANCH, uint16_t, uSel, uint64_t, offSeg, IEMMODE, enmEffOpSize);
6447typedef FNIEMCIMPLFARBRANCH *PFNIEMCIMPLFARBRANCH;
6448IEM_CIMPL_PROTO_2(iemCImpl_retf, IEMMODE, enmEffOpSize, uint16_t, cbPop);
6449IEM_CIMPL_PROTO_3(iemCImpl_enter, IEMMODE, enmEffOpSize, uint16_t, cbFrame, uint8_t, cParameters);
6450IEM_CIMPL_PROTO_1(iemCImpl_leave, IEMMODE, enmEffOpSize);
6451IEM_CIMPL_PROTO_2(iemCImpl_int, uint8_t, u8Int, IEMINT, enmInt);
6452IEM_CIMPL_PROTO_1(iemCImpl_iret_real_v8086, IEMMODE, enmEffOpSize);
6453IEM_CIMPL_PROTO_4(iemCImpl_iret_prot_v8086, uint32_t, uNewEip, uint16_t, uNewCs, uint32_t, uNewFlags, uint64_t, uNewRsp);
6454IEM_CIMPL_PROTO_1(iemCImpl_iret_prot_NestedTask, IEMMODE, enmEffOpSize);
6455IEM_CIMPL_PROTO_1(iemCImpl_iret_prot, IEMMODE, enmEffOpSize);
6456IEM_CIMPL_PROTO_1(iemCImpl_iret_64bit, IEMMODE, enmEffOpSize);
6457IEM_CIMPL_PROTO_1(iemCImpl_iret, IEMMODE, enmEffOpSize);
6458IEM_CIMPL_PROTO_0(iemCImpl_loadall286);
6459IEM_CIMPL_PROTO_0(iemCImpl_syscall);
6460IEM_CIMPL_PROTO_1(iemCImpl_sysret, IEMMODE, enmEffOpSize);
6461IEM_CIMPL_PROTO_0(iemCImpl_sysenter);
6462IEM_CIMPL_PROTO_1(iemCImpl_sysexit, IEMMODE, enmEffOpSize);
6463IEM_CIMPL_PROTO_2(iemCImpl_LoadSReg, uint8_t, iSegReg, uint16_t, uSel);
6464IEM_CIMPL_PROTO_2(iemCImpl_load_SReg, uint8_t, iSegReg, uint16_t, uSel);
6465IEM_CIMPL_PROTO_2(iemCImpl_pop_Sreg, uint8_t, iSegReg, IEMMODE, enmEffOpSize);
6466IEM_CIMPL_PROTO_5(iemCImpl_load_SReg_Greg, uint16_t, uSel, uint64_t, offSeg, uint8_t, iSegReg, uint8_t, iGReg, IEMMODE, enmEffOpSize);
6467IEM_CIMPL_PROTO_2(iemCImpl_VerX, uint16_t, uSel, bool, fWrite);
6468IEM_CIMPL_PROTO_3(iemCImpl_LarLsl_u64, uint64_t *, pu64Dst, uint16_t, uSel, bool, fIsLar);
6469IEM_CIMPL_PROTO_3(iemCImpl_LarLsl_u16, uint16_t *, pu16Dst, uint16_t, uSel, bool, fIsLar);
6470IEM_CIMPL_PROTO_3(iemCImpl_lgdt, uint8_t, iEffSeg, RTGCPTR, GCPtrEffSrc, IEMMODE, enmEffOpSize);
6471IEM_CIMPL_PROTO_2(iemCImpl_sgdt, uint8_t, iEffSeg, RTGCPTR, GCPtrEffDst);
6472IEM_CIMPL_PROTO_3(iemCImpl_lidt, uint8_t, iEffSeg, RTGCPTR, GCPtrEffSrc, IEMMODE, enmEffOpSize);
6473IEM_CIMPL_PROTO_2(iemCImpl_sidt, uint8_t, iEffSeg, RTGCPTR, GCPtrEffDst);
6474IEM_CIMPL_PROTO_1(iemCImpl_lldt, uint16_t, uNewLdt);
6475IEM_CIMPL_PROTO_2(iemCImpl_sldt_reg, uint8_t, iGReg, uint8_t, enmEffOpSize);
6476IEM_CIMPL_PROTO_2(iemCImpl_sldt_mem, uint8_t, iEffSeg, RTGCPTR, GCPtrEffDst);
6477IEM_CIMPL_PROTO_1(iemCImpl_ltr, uint16_t, uNewTr);
6478IEM_CIMPL_PROTO_2(iemCImpl_str_reg, uint8_t, iGReg, uint8_t, enmEffOpSize);
6479IEM_CIMPL_PROTO_2(iemCImpl_str_mem, uint8_t, iEffSeg, RTGCPTR, GCPtrEffDst);
6480IEM_CIMPL_PROTO_2(iemCImpl_mov_Rd_Cd, uint8_t, iGReg, uint8_t, iCrReg);
6481IEM_CIMPL_PROTO_2(iemCImpl_smsw_reg, uint8_t, iGReg, uint8_t, enmEffOpSize);
6482IEM_CIMPL_PROTO_2(iemCImpl_smsw_mem, uint8_t, iEffSeg, RTGCPTR, GCPtrEffDst);
6483IEM_CIMPL_PROTO_4(iemCImpl_load_CrX, uint8_t, iCrReg, uint64_t, uNewCrX, IEMACCESSCRX, enmAccessCrX, uint8_t, iGReg);
6484IEM_CIMPL_PROTO_2(iemCImpl_mov_Cd_Rd, uint8_t, iCrReg, uint8_t, iGReg);
6485IEM_CIMPL_PROTO_2(iemCImpl_lmsw, uint16_t, u16NewMsw, RTGCPTR, GCPtrEffDst);
6486IEM_CIMPL_PROTO_0(iemCImpl_clts);
6487IEM_CIMPL_PROTO_2(iemCImpl_mov_Rd_Dd, uint8_t, iGReg, uint8_t, iDrReg);
6488IEM_CIMPL_PROTO_2(iemCImpl_mov_Dd_Rd, uint8_t, iDrReg, uint8_t, iGReg);
6489IEM_CIMPL_PROTO_2(iemCImpl_mov_Rd_Td, uint8_t, iGReg, uint8_t, iTrReg);
6490IEM_CIMPL_PROTO_2(iemCImpl_mov_Td_Rd, uint8_t, iTrReg, uint8_t, iGReg);
6491IEM_CIMPL_PROTO_1(iemCImpl_invlpg, RTGCPTR, GCPtrPage);
6492IEM_CIMPL_PROTO_3(iemCImpl_invpcid, uint8_t, iEffSeg, RTGCPTR, GCPtrInvpcidDesc, uint64_t, uInvpcidType);
6493IEM_CIMPL_PROTO_0(iemCImpl_invd);
6494IEM_CIMPL_PROTO_0(iemCImpl_wbinvd);
6495IEM_CIMPL_PROTO_0(iemCImpl_rsm);
6496IEM_CIMPL_PROTO_0(iemCImpl_rdtsc);
6497IEM_CIMPL_PROTO_0(iemCImpl_rdtscp);
6498IEM_CIMPL_PROTO_0(iemCImpl_rdpmc);
6499IEM_CIMPL_PROTO_0(iemCImpl_rdmsr);
6500IEM_CIMPL_PROTO_0(iemCImpl_wrmsr);
6501IEM_CIMPL_PROTO_3(iemCImpl_in, uint16_t, u16Port, uint8_t, cbReg, uint8_t, bImmAndEffAddrMode);
6502IEM_CIMPL_PROTO_2(iemCImpl_in_eAX_DX, uint8_t, cbReg, IEMMODE, enmEffAddrMode);
6503IEM_CIMPL_PROTO_3(iemCImpl_out, uint16_t, u16Port, uint8_t, cbReg, uint8_t, bImmAndEffAddrMode);
6504IEM_CIMPL_PROTO_2(iemCImpl_out_DX_eAX, uint8_t, cbReg, IEMMODE, enmEffAddrMode);
6505IEM_CIMPL_PROTO_0(iemCImpl_cli);
6506IEM_CIMPL_PROTO_0(iemCImpl_sti);
6507IEM_CIMPL_PROTO_0(iemCImpl_hlt);
6508IEM_CIMPL_PROTO_1(iemCImpl_monitor, uint8_t, iEffSeg);
6509IEM_CIMPL_PROTO_0(iemCImpl_mwait);
6510IEM_CIMPL_PROTO_0(iemCImpl_swapgs);
6511IEM_CIMPL_PROTO_0(iemCImpl_cpuid);
6512IEM_CIMPL_PROTO_1(iemCImpl_aad, uint8_t, bImm);
6513IEM_CIMPL_PROTO_1(iemCImpl_aam, uint8_t, bImm);
6514IEM_CIMPL_PROTO_0(iemCImpl_daa);
6515IEM_CIMPL_PROTO_0(iemCImpl_das);
6516IEM_CIMPL_PROTO_0(iemCImpl_aaa);
6517IEM_CIMPL_PROTO_0(iemCImpl_aas);
6518IEM_CIMPL_PROTO_3(iemCImpl_bound_16, int16_t, idxArray, int16_t, idxLowerBound, int16_t, idxUpperBound);
6519IEM_CIMPL_PROTO_3(iemCImpl_bound_32, int32_t, idxArray, int32_t, idxLowerBound, int32_t, idxUpperBound);
6520IEM_CIMPL_PROTO_0(iemCImpl_xgetbv);
6521IEM_CIMPL_PROTO_0(iemCImpl_xsetbv);
6522IEM_CIMPL_PROTO_5(iemCImpl_cmpxchg16b_fallback_rendezvous, PRTUINT128U, pu128Dst, PRTUINT128U, pu128RaxRdx,
6523 PRTUINT128U, pu128RbxRcx, uint32_t *, pEFlags, uint8_t, bUnmapInfo);
6524IEM_CIMPL_PROTO_2(iemCImpl_clflush_clflushopt, uint8_t, iEffSeg, RTGCPTR, GCPtrEff);
6525IEM_CIMPL_PROTO_1(iemCImpl_finit, bool, fCheckXcpts);
6526IEM_CIMPL_PROTO_3(iemCImpl_fxsave, uint8_t, iEffSeg, RTGCPTR, GCPtrEff, IEMMODE, enmEffOpSize);
6527IEM_CIMPL_PROTO_3(iemCImpl_fxrstor, uint8_t, iEffSeg, RTGCPTR, GCPtrEff, IEMMODE, enmEffOpSize);
6528IEM_CIMPL_PROTO_3(iemCImpl_xsave, uint8_t, iEffSeg, RTGCPTR, GCPtrEff, IEMMODE, enmEffOpSize);
6529IEM_CIMPL_PROTO_3(iemCImpl_xrstor, uint8_t, iEffSeg, RTGCPTR, GCPtrEff, IEMMODE, enmEffOpSize);
6530IEM_CIMPL_PROTO_2(iemCImpl_stmxcsr, uint8_t, iEffSeg, RTGCPTR, GCPtrEff);
6531IEM_CIMPL_PROTO_2(iemCImpl_vstmxcsr, uint8_t, iEffSeg, RTGCPTR, GCPtrEff);
6532IEM_CIMPL_PROTO_2(iemCImpl_ldmxcsr, uint8_t, iEffSeg, RTGCPTR, GCPtrEff);
6533IEM_CIMPL_PROTO_2(iemCImpl_vldmxcsr, uint8_t, iEffSeg, RTGCPTR, GCPtrEff);
6534IEM_CIMPL_PROTO_3(iemCImpl_fnstenv, IEMMODE, enmEffOpSize, uint8_t, iEffSeg, RTGCPTR, GCPtrEffDst);
6535IEM_CIMPL_PROTO_3(iemCImpl_fnsave, IEMMODE, enmEffOpSize, uint8_t, iEffSeg, RTGCPTR, GCPtrEffDst);
6536IEM_CIMPL_PROTO_3(iemCImpl_fldenv, IEMMODE, enmEffOpSize, uint8_t, iEffSeg, RTGCPTR, GCPtrEffSrc);
6537IEM_CIMPL_PROTO_3(iemCImpl_frstor, IEMMODE, enmEffOpSize, uint8_t, iEffSeg, RTGCPTR, GCPtrEffSrc);
6538IEM_CIMPL_PROTO_1(iemCImpl_fldcw, uint16_t, u16Fcw);
6539IEM_CIMPL_PROTO_2(iemCImpl_fxch_underflow, uint8_t, iStReg, uint16_t, uFpuOpcode);
6540IEM_CIMPL_PROTO_3(iemCImpl_fcomi_fucomi, uint8_t, iStReg, bool, fUCmp, uint32_t, uPopAndFpuOpcode);
6541IEM_CIMPL_PROTO_2(iemCImpl_rdseed, uint8_t, iReg, IEMMODE, enmEffOpSize);
6542IEM_CIMPL_PROTO_2(iemCImpl_rdrand, uint8_t, iReg, IEMMODE, enmEffOpSize);
6543IEM_CIMPL_PROTO_4(iemCImpl_vmaskmovps_load_u128, uint8_t, iXRegDst, uint8_t, iXRegMsk, uint8_t, iEffSeg, RTGCPTR, GCPtrEffSrc);
6544IEM_CIMPL_PROTO_4(iemCImpl_vmaskmovps_load_u256, uint8_t, iYRegDst, uint8_t, iYRegMsk, uint8_t, iEffSeg, RTGCPTR, GCPtrEffSrc);
6545IEM_CIMPL_PROTO_4(iemCImpl_vmaskmovps_store_u128, uint8_t, iEffSeg, RTGCPTR, GCPtrEffDst, uint8_t, iXRegMsk, uint8_t, iXRegSrc);
6546IEM_CIMPL_PROTO_4(iemCImpl_vmaskmovps_store_u256, uint8_t, iEffSeg, RTGCPTR, GCPtrEffDst, uint8_t, iYRegMsk, uint8_t, iYRegSrc);
6547IEM_CIMPL_PROTO_4(iemCImpl_vpmaskmovd_load_u128, uint8_t, iXRegDst, uint8_t, iXRegMsk, uint8_t, iEffSeg, RTGCPTR, GCPtrEffSrc);
6548IEM_CIMPL_PROTO_4(iemCImpl_vpmaskmovd_load_u256, uint8_t, iYRegDst, uint8_t, iYRegMsk, uint8_t, iEffSeg, RTGCPTR, GCPtrEffSrc);
6549IEM_CIMPL_PROTO_4(iemCImpl_vpmaskmovd_store_u128, uint8_t, iEffSeg, RTGCPTR, GCPtrEffDst, uint8_t, iXRegMsk, uint8_t, iXRegSrc);
6550IEM_CIMPL_PROTO_4(iemCImpl_vpmaskmovd_store_u256, uint8_t, iEffSeg, RTGCPTR, GCPtrEffDst, uint8_t, iYRegMsk, uint8_t, iYRegSrc);
6551IEM_CIMPL_PROTO_4(iemCImpl_vmaskmovpd_load_u128, uint8_t, iXRegDst, uint8_t, iXRegMsk, uint8_t, iEffSeg, RTGCPTR, GCPtrEffSrc);
6552IEM_CIMPL_PROTO_4(iemCImpl_vmaskmovpd_load_u256, uint8_t, iYRegDst, uint8_t, iYRegMsk, uint8_t, iEffSeg, RTGCPTR, GCPtrEffSrc);
6553IEM_CIMPL_PROTO_4(iemCImpl_vmaskmovpd_store_u128, uint8_t, iEffSeg, RTGCPTR, GCPtrEffDst, uint8_t, iXRegMsk, uint8_t, iXRegSrc);
6554IEM_CIMPL_PROTO_4(iemCImpl_vmaskmovpd_store_u256, uint8_t, iEffSeg, RTGCPTR, GCPtrEffDst, uint8_t, iYRegMsk, uint8_t, iYRegSrc);
6555IEM_CIMPL_PROTO_4(iemCImpl_vpmaskmovq_load_u128, uint8_t, iXRegDst, uint8_t, iXRegMsk, uint8_t, iEffSeg, RTGCPTR, GCPtrEffSrc);
6556IEM_CIMPL_PROTO_4(iemCImpl_vpmaskmovq_load_u256, uint8_t, iYRegDst, uint8_t, iYRegMsk, uint8_t, iEffSeg, RTGCPTR, GCPtrEffSrc);
6557IEM_CIMPL_PROTO_4(iemCImpl_vpmaskmovq_store_u128, uint8_t, iEffSeg, RTGCPTR, GCPtrEffDst, uint8_t, iXRegMsk, uint8_t, iXRegSrc);
6558IEM_CIMPL_PROTO_4(iemCImpl_vpmaskmovq_store_u256, uint8_t, iEffSeg, RTGCPTR, GCPtrEffDst, uint8_t, iYRegMsk, uint8_t, iYRegSrc);
6559IEM_CIMPL_PROTO_2(iemCImpl_vpgather_worker_xx, uint32_t, u32PackedArgs, uint32_t, u32Disp);
6560
6561/** @} */
6562
6563/** @name IEMAllCImplStrInstr.cpp.h
6564 * @note sed -e '/IEM_CIMPL_DEF_/!d' -e 's/IEM_CIMPL_DEF_/IEM_CIMPL_PROTO_/' -e 's/$/;/' -e 's/RT_CONCAT4(//' \
6565 * -e 's/,ADDR_SIZE)/64/g' -e 's/,OP_SIZE,/64/g' -e 's/,OP_rAX,/rax/g' IEMAllCImplStrInstr.cpp.h
6566 * @{ */
6567IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op8_addr16, uint8_t, iEffSeg);
6568IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op8_addr16, uint8_t, iEffSeg);
6569IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_al_m16);
6570IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_al_m16);
6571IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op8_addr16, uint8_t, iEffSeg);
6572IEM_CIMPL_PROTO_0(iemCImpl_stos_al_m16);
6573IEM_CIMPL_PROTO_1(iemCImpl_lods_al_m16, int8_t, iEffSeg);
6574IEM_CIMPL_PROTO_1(iemCImpl_ins_op8_addr16, bool, fIoChecked);
6575IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op8_addr16, bool, fIoChecked);
6576IEM_CIMPL_PROTO_2(iemCImpl_outs_op8_addr16, uint8_t, iEffSeg, bool, fIoChecked);
6577IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op8_addr16, uint8_t, iEffSeg, bool, fIoChecked);
6578
6579IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op16_addr16, uint8_t, iEffSeg);
6580IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op16_addr16, uint8_t, iEffSeg);
6581IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_ax_m16);
6582IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_ax_m16);
6583IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op16_addr16, uint8_t, iEffSeg);
6584IEM_CIMPL_PROTO_0(iemCImpl_stos_ax_m16);
6585IEM_CIMPL_PROTO_1(iemCImpl_lods_ax_m16, int8_t, iEffSeg);
6586IEM_CIMPL_PROTO_1(iemCImpl_ins_op16_addr16, bool, fIoChecked);
6587IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op16_addr16, bool, fIoChecked);
6588IEM_CIMPL_PROTO_2(iemCImpl_outs_op16_addr16, uint8_t, iEffSeg, bool, fIoChecked);
6589IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op16_addr16, uint8_t, iEffSeg, bool, fIoChecked);
6590
6591IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op32_addr16, uint8_t, iEffSeg);
6592IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op32_addr16, uint8_t, iEffSeg);
6593IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_eax_m16);
6594IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_eax_m16);
6595IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op32_addr16, uint8_t, iEffSeg);
6596IEM_CIMPL_PROTO_0(iemCImpl_stos_eax_m16);
6597IEM_CIMPL_PROTO_1(iemCImpl_lods_eax_m16, int8_t, iEffSeg);
6598IEM_CIMPL_PROTO_1(iemCImpl_ins_op32_addr16, bool, fIoChecked);
6599IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op32_addr16, bool, fIoChecked);
6600IEM_CIMPL_PROTO_2(iemCImpl_outs_op32_addr16, uint8_t, iEffSeg, bool, fIoChecked);
6601IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op32_addr16, uint8_t, iEffSeg, bool, fIoChecked);
6602
6603
6604IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op8_addr32, uint8_t, iEffSeg);
6605IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op8_addr32, uint8_t, iEffSeg);
6606IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_al_m32);
6607IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_al_m32);
6608IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op8_addr32, uint8_t, iEffSeg);
6609IEM_CIMPL_PROTO_0(iemCImpl_stos_al_m32);
6610IEM_CIMPL_PROTO_1(iemCImpl_lods_al_m32, int8_t, iEffSeg);
6611IEM_CIMPL_PROTO_1(iemCImpl_ins_op8_addr32, bool, fIoChecked);
6612IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op8_addr32, bool, fIoChecked);
6613IEM_CIMPL_PROTO_2(iemCImpl_outs_op8_addr32, uint8_t, iEffSeg, bool, fIoChecked);
6614IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op8_addr32, uint8_t, iEffSeg, bool, fIoChecked);
6615
6616IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op16_addr32, uint8_t, iEffSeg);
6617IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op16_addr32, uint8_t, iEffSeg);
6618IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_ax_m32);
6619IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_ax_m32);
6620IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op16_addr32, uint8_t, iEffSeg);
6621IEM_CIMPL_PROTO_0(iemCImpl_stos_ax_m32);
6622IEM_CIMPL_PROTO_1(iemCImpl_lods_ax_m32, int8_t, iEffSeg);
6623IEM_CIMPL_PROTO_1(iemCImpl_ins_op16_addr32, bool, fIoChecked);
6624IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op16_addr32, bool, fIoChecked);
6625IEM_CIMPL_PROTO_2(iemCImpl_outs_op16_addr32, uint8_t, iEffSeg, bool, fIoChecked);
6626IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op16_addr32, uint8_t, iEffSeg, bool, fIoChecked);
6627
6628IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op32_addr32, uint8_t, iEffSeg);
6629IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op32_addr32, uint8_t, iEffSeg);
6630IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_eax_m32);
6631IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_eax_m32);
6632IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op32_addr32, uint8_t, iEffSeg);
6633IEM_CIMPL_PROTO_0(iemCImpl_stos_eax_m32);
6634IEM_CIMPL_PROTO_1(iemCImpl_lods_eax_m32, int8_t, iEffSeg);
6635IEM_CIMPL_PROTO_1(iemCImpl_ins_op32_addr32, bool, fIoChecked);
6636IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op32_addr32, bool, fIoChecked);
6637IEM_CIMPL_PROTO_2(iemCImpl_outs_op32_addr32, uint8_t, iEffSeg, bool, fIoChecked);
6638IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op32_addr32, uint8_t, iEffSeg, bool, fIoChecked);
6639
6640IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op64_addr32, uint8_t, iEffSeg);
6641IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op64_addr32, uint8_t, iEffSeg);
6642IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_rax_m32);
6643IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_rax_m32);
6644IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op64_addr32, uint8_t, iEffSeg);
6645IEM_CIMPL_PROTO_0(iemCImpl_stos_rax_m32);
6646IEM_CIMPL_PROTO_1(iemCImpl_lods_rax_m32, int8_t, iEffSeg);
6647IEM_CIMPL_PROTO_1(iemCImpl_ins_op64_addr32, bool, fIoChecked);
6648IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op64_addr32, bool, fIoChecked);
6649IEM_CIMPL_PROTO_2(iemCImpl_outs_op64_addr32, uint8_t, iEffSeg, bool, fIoChecked);
6650IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op64_addr32, uint8_t, iEffSeg, bool, fIoChecked);
6651
6652
6653IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op8_addr64, uint8_t, iEffSeg);
6654IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op8_addr64, uint8_t, iEffSeg);
6655IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_al_m64);
6656IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_al_m64);
6657IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op8_addr64, uint8_t, iEffSeg);
6658IEM_CIMPL_PROTO_0(iemCImpl_stos_al_m64);
6659IEM_CIMPL_PROTO_1(iemCImpl_lods_al_m64, int8_t, iEffSeg);
6660IEM_CIMPL_PROTO_1(iemCImpl_ins_op8_addr64, bool, fIoChecked);
6661IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op8_addr64, bool, fIoChecked);
6662IEM_CIMPL_PROTO_2(iemCImpl_outs_op8_addr64, uint8_t, iEffSeg, bool, fIoChecked);
6663IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op8_addr64, uint8_t, iEffSeg, bool, fIoChecked);
6664
6665IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op16_addr64, uint8_t, iEffSeg);
6666IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op16_addr64, uint8_t, iEffSeg);
6667IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_ax_m64);
6668IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_ax_m64);
6669IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op16_addr64, uint8_t, iEffSeg);
6670IEM_CIMPL_PROTO_0(iemCImpl_stos_ax_m64);
6671IEM_CIMPL_PROTO_1(iemCImpl_lods_ax_m64, int8_t, iEffSeg);
6672IEM_CIMPL_PROTO_1(iemCImpl_ins_op16_addr64, bool, fIoChecked);
6673IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op16_addr64, bool, fIoChecked);
6674IEM_CIMPL_PROTO_2(iemCImpl_outs_op16_addr64, uint8_t, iEffSeg, bool, fIoChecked);
6675IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op16_addr64, uint8_t, iEffSeg, bool, fIoChecked);
6676
6677IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op32_addr64, uint8_t, iEffSeg);
6678IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op32_addr64, uint8_t, iEffSeg);
6679IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_eax_m64);
6680IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_eax_m64);
6681IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op32_addr64, uint8_t, iEffSeg);
6682IEM_CIMPL_PROTO_0(iemCImpl_stos_eax_m64);
6683IEM_CIMPL_PROTO_1(iemCImpl_lods_eax_m64, int8_t, iEffSeg);
6684IEM_CIMPL_PROTO_1(iemCImpl_ins_op32_addr64, bool, fIoChecked);
6685IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op32_addr64, bool, fIoChecked);
6686IEM_CIMPL_PROTO_2(iemCImpl_outs_op32_addr64, uint8_t, iEffSeg, bool, fIoChecked);
6687IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op32_addr64, uint8_t, iEffSeg, bool, fIoChecked);
6688
6689IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op64_addr64, uint8_t, iEffSeg);
6690IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op64_addr64, uint8_t, iEffSeg);
6691IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_rax_m64);
6692IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_rax_m64);
6693IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op64_addr64, uint8_t, iEffSeg);
6694IEM_CIMPL_PROTO_0(iemCImpl_stos_rax_m64);
6695IEM_CIMPL_PROTO_1(iemCImpl_lods_rax_m64, int8_t, iEffSeg);
6696IEM_CIMPL_PROTO_1(iemCImpl_ins_op64_addr64, bool, fIoChecked);
6697IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op64_addr64, bool, fIoChecked);
6698IEM_CIMPL_PROTO_2(iemCImpl_outs_op64_addr64, uint8_t, iEffSeg, bool, fIoChecked);
6699IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op64_addr64, uint8_t, iEffSeg, bool, fIoChecked);
6700/** @} */
6701
6702#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
6703VBOXSTRICTRC iemVmxVmexit(PVMCPUCC pVCpu, uint32_t uExitReason, uint64_t u64ExitQual) RT_NOEXCEPT;
6704VBOXSTRICTRC iemVmxVmexitInstr(PVMCPUCC pVCpu, uint32_t uExitReason, uint8_t cbInstr) RT_NOEXCEPT;
6705VBOXSTRICTRC iemVmxVmexitInstrNeedsInfo(PVMCPUCC pVCpu, uint32_t uExitReason, VMXINSTRID uInstrId, uint8_t cbInstr) RT_NOEXCEPT;
6706VBOXSTRICTRC iemVmxVmexitTaskSwitch(PVMCPUCC pVCpu, IEMTASKSWITCH enmTaskSwitch, RTSEL SelNewTss, uint8_t cbInstr) RT_NOEXCEPT;
6707VBOXSTRICTRC iemVmxVmexitEvent(PVMCPUCC pVCpu, uint8_t uVector, uint32_t fFlags, uint32_t uErrCode, uint64_t uCr2, uint8_t cbInstr) RT_NOEXCEPT;
6708VBOXSTRICTRC iemVmxVmexitEventDoubleFault(PVMCPUCC pVCpu) RT_NOEXCEPT;
6709VBOXSTRICTRC iemVmxVmexitEpt(PVMCPUCC pVCpu, PPGMPTWALKFAST pWalk, uint32_t fAccess, uint32_t fSlatFail, uint8_t cbInstr) RT_NOEXCEPT;
6710VBOXSTRICTRC iemVmxVmexitPreemptTimer(PVMCPUCC pVCpu) RT_NOEXCEPT;
6711VBOXSTRICTRC iemVmxVmexitInstrMwait(PVMCPUCC pVCpu, bool fMonitorHwArmed, uint8_t cbInstr) RT_NOEXCEPT;
6712VBOXSTRICTRC iemVmxVmexitInstrIo(PVMCPUCC pVCpu, VMXINSTRID uInstrId, uint16_t u16Port,
6713 bool fImm, uint8_t cbAccess, uint8_t cbInstr) RT_NOEXCEPT;
6714VBOXSTRICTRC iemVmxVmexitInstrStrIo(PVMCPUCC pVCpu, VMXINSTRID uInstrId, uint16_t u16Port, uint8_t cbAccess,
6715 bool fRep, VMXEXITINSTRINFO ExitInstrInfo, uint8_t cbInstr) RT_NOEXCEPT;
6716VBOXSTRICTRC iemVmxVmexitInstrMovDrX(PVMCPUCC pVCpu, VMXINSTRID uInstrId, uint8_t iDrReg, uint8_t iGReg, uint8_t cbInstr) RT_NOEXCEPT;
6717VBOXSTRICTRC iemVmxVmexitInstrMovToCr8(PVMCPUCC pVCpu, uint8_t iGReg, uint8_t cbInstr) RT_NOEXCEPT;
6718VBOXSTRICTRC iemVmxVmexitInstrMovFromCr8(PVMCPUCC pVCpu, uint8_t iGReg, uint8_t cbInstr) RT_NOEXCEPT;
6719VBOXSTRICTRC iemVmxVmexitInstrMovToCr3(PVMCPUCC pVCpu, uint64_t uNewCr3, uint8_t iGReg, uint8_t cbInstr) RT_NOEXCEPT;
6720VBOXSTRICTRC iemVmxVmexitInstrMovFromCr3(PVMCPUCC pVCpu, uint8_t iGReg, uint8_t cbInstr) RT_NOEXCEPT;
6721VBOXSTRICTRC iemVmxVmexitInstrMovToCr0Cr4(PVMCPUCC pVCpu, uint8_t iCrReg, uint64_t *puNewCrX, uint8_t iGReg, uint8_t cbInstr) RT_NOEXCEPT;
6722VBOXSTRICTRC iemVmxVmexitInstrClts(PVMCPUCC pVCpu, uint8_t cbInstr) RT_NOEXCEPT;
6723VBOXSTRICTRC iemVmxVmexitInstrLmsw(PVMCPUCC pVCpu, uint32_t uGuestCr0, uint16_t *pu16NewMsw,
6724 RTGCPTR GCPtrEffDst, uint8_t cbInstr) RT_NOEXCEPT;
6725VBOXSTRICTRC iemVmxVmexitInstrInvlpg(PVMCPUCC pVCpu, RTGCPTR GCPtrPage, uint8_t cbInstr) RT_NOEXCEPT;
6726VBOXSTRICTRC iemVmxApicWriteEmulation(PVMCPUCC pVCpu) RT_NOEXCEPT;
6727VBOXSTRICTRC iemVmxVirtApicAccessUnused(PVMCPUCC pVCpu, PRTGCPHYS pGCPhysAccess, size_t cbAccess, uint32_t fAccess) RT_NOEXCEPT;
6728uint32_t iemVmxVirtApicReadRaw32(PVMCPUCC pVCpu, uint16_t offReg) RT_NOEXCEPT;
6729void iemVmxVirtApicWriteRaw32(PVMCPUCC pVCpu, uint16_t offReg, uint32_t uReg) RT_NOEXCEPT;
6730VBOXSTRICTRC iemVmxInvvpid(PVMCPUCC pVCpu, uint8_t cbInstr, uint8_t iEffSeg, RTGCPTR GCPtrInvvpidDesc,
6731 uint64_t u64InvvpidType, PCVMXVEXITINFO pExitInfo) RT_NOEXCEPT;
6732bool iemVmxIsRdmsrWrmsrInterceptSet(PCVMCPU pVCpu, uint32_t uExitReason, uint32_t idMsr) RT_NOEXCEPT;
6733IEM_CIMPL_PROTO_0(iemCImpl_vmxoff);
6734IEM_CIMPL_PROTO_2(iemCImpl_vmxon, uint8_t, iEffSeg, RTGCPTR, GCPtrVmxon);
6735IEM_CIMPL_PROTO_0(iemCImpl_vmlaunch);
6736IEM_CIMPL_PROTO_0(iemCImpl_vmresume);
6737IEM_CIMPL_PROTO_2(iemCImpl_vmptrld, uint8_t, iEffSeg, RTGCPTR, GCPtrVmcs);
6738IEM_CIMPL_PROTO_2(iemCImpl_vmptrst, uint8_t, iEffSeg, RTGCPTR, GCPtrVmcs);
6739IEM_CIMPL_PROTO_2(iemCImpl_vmclear, uint8_t, iEffSeg, RTGCPTR, GCPtrVmcs);
6740IEM_CIMPL_PROTO_2(iemCImpl_vmwrite_reg, uint64_t, u64Val, uint64_t, u64VmcsField);
6741IEM_CIMPL_PROTO_3(iemCImpl_vmwrite_mem, uint8_t, iEffSeg, RTGCPTR, GCPtrVal, uint32_t, u64VmcsField);
6742IEM_CIMPL_PROTO_2(iemCImpl_vmread_reg64, uint64_t *, pu64Dst, uint64_t, u64VmcsField);
6743IEM_CIMPL_PROTO_2(iemCImpl_vmread_reg32, uint64_t *, pu32Dst, uint32_t, u32VmcsField);
6744IEM_CIMPL_PROTO_3(iemCImpl_vmread_mem_reg64, uint8_t, iEffSeg, RTGCPTR, GCPtrDst, uint32_t, u64VmcsField);
6745IEM_CIMPL_PROTO_3(iemCImpl_vmread_mem_reg32, uint8_t, iEffSeg, RTGCPTR, GCPtrDst, uint32_t, u32VmcsField);
6746IEM_CIMPL_PROTO_3(iemCImpl_invvpid, uint8_t, iEffSeg, RTGCPTR, GCPtrInvvpidDesc, uint64_t, uInvvpidType);
6747IEM_CIMPL_PROTO_3(iemCImpl_invept, uint8_t, iEffSeg, RTGCPTR, GCPtrInveptDesc, uint64_t, uInveptType);
6748IEM_CIMPL_PROTO_0(iemCImpl_vmx_pause);
6749#endif
6750
6751#ifdef VBOX_WITH_NESTED_HWVIRT_SVM
6752VBOXSTRICTRC iemSvmVmexit(PVMCPUCC pVCpu, uint64_t uExitCode, uint64_t uExitInfo1, uint64_t uExitInfo2) RT_NOEXCEPT;
6753VBOXSTRICTRC iemHandleSvmEventIntercept(PVMCPUCC pVCpu, uint8_t cbInstr, uint8_t u8Vector, uint32_t fFlags, uint32_t uErr, uint64_t uCr2) RT_NOEXCEPT;
6754VBOXSTRICTRC iemSvmHandleIOIntercept(PVMCPUCC pVCpu, uint16_t u16Port, SVMIOIOTYPE enmIoType, uint8_t cbReg,
6755 uint8_t cAddrSizeBits, uint8_t iEffSeg, bool fRep, bool fStrIo, uint8_t cbInstr) RT_NOEXCEPT;
6756VBOXSTRICTRC iemSvmHandleMsrIntercept(PVMCPUCC pVCpu, uint32_t idMsr, bool fWrite, uint8_t cbInstr) RT_NOEXCEPT;
6757IEM_CIMPL_PROTO_0(iemCImpl_vmrun);
6758IEM_CIMPL_PROTO_0(iemCImpl_vmload);
6759IEM_CIMPL_PROTO_0(iemCImpl_vmsave);
6760IEM_CIMPL_PROTO_0(iemCImpl_clgi);
6761IEM_CIMPL_PROTO_0(iemCImpl_stgi);
6762IEM_CIMPL_PROTO_0(iemCImpl_invlpga);
6763IEM_CIMPL_PROTO_0(iemCImpl_skinit);
6764IEM_CIMPL_PROTO_0(iemCImpl_svm_pause);
6765#endif
6766
6767IEM_CIMPL_PROTO_0(iemCImpl_vmcall); /* vmx */
6768IEM_CIMPL_PROTO_0(iemCImpl_vmmcall); /* svm */
6769IEM_CIMPL_PROTO_1(iemCImpl_Hypercall, uint16_t, uDisOpcode); /* both */
6770
6771extern const PFNIEMOP g_apfnIemInterpretOnlyOneByteMap[256];
6772extern const PFNIEMOP g_apfnIemInterpretOnlyTwoByteMap[1024];
6773extern const PFNIEMOP g_apfnIemInterpretOnlyThreeByte0f3a[1024];
6774extern const PFNIEMOP g_apfnIemInterpretOnlyThreeByte0f38[1024];
6775extern const PFNIEMOP g_apfnIemInterpretOnlyVecMap1[1024];
6776extern const PFNIEMOP g_apfnIemInterpretOnlyVecMap2[1024];
6777extern const PFNIEMOP g_apfnIemInterpretOnlyVecMap3[1024];
6778
6779/*
6780 * Recompiler related stuff.
6781 */
6782extern const PFNIEMOP g_apfnIemThreadedRecompilerOneByteMap[256];
6783extern const PFNIEMOP g_apfnIemThreadedRecompilerTwoByteMap[1024];
6784extern const PFNIEMOP g_apfnIemThreadedRecompilerThreeByte0f3a[1024];
6785extern const PFNIEMOP g_apfnIemThreadedRecompilerThreeByte0f38[1024];
6786extern const PFNIEMOP g_apfnIemThreadedRecompilerVecMap1[1024];
6787extern const PFNIEMOP g_apfnIemThreadedRecompilerVecMap2[1024];
6788extern const PFNIEMOP g_apfnIemThreadedRecompilerVecMap3[1024];
6789
6790DECLHIDDEN(int) iemPollTimers(PVMCC pVM, PVMCPUCC pVCpu) RT_NOEXCEPT;
6791
6792DECLCALLBACK(int) iemTbInit(PVMCC pVM, uint32_t cInitialTbs, uint32_t cMaxTbs,
6793 uint64_t cbInitialExec, uint64_t cbMaxExec, uint32_t cbChunkExec);
6794void iemThreadedTbObsolete(PVMCPUCC pVCpu, PIEMTB pTb, bool fSafeToFree);
6795DECLHIDDEN(void) iemTbAllocatorFree(PVMCPUCC pVCpu, PIEMTB pTb);
6796void iemTbAllocatorProcessDelayedFrees(PVMCPUCC pVCpu, PIEMTBALLOCATOR pTbAllocator);
6797void iemTbAllocatorFreeupNativeSpace(PVMCPUCC pVCpu, uint32_t cNeededInstrs);
6798DECLHIDDEN(const char *) iemTbFlagsToString(uint32_t fFlags, char *pszBuf, size_t cbBuf) RT_NOEXCEPT;
6799DECLHIDDEN(void) iemThreadedDisassembleTb(PCIEMTB pTb, PCDBGFINFOHLP pHlp) RT_NOEXCEPT;
6800
6801
6802/** @todo FNIEMTHREADEDFUNC and friends may need more work... */
6803#if defined(__GNUC__) && !defined(IEM_WITH_THROW_CATCH)
6804typedef VBOXSTRICTRC /*__attribute__((__nothrow__))*/ FNIEMTHREADEDFUNC(PVMCPU pVCpu, uint64_t uParam0, uint64_t uParam1, uint64_t uParam2);
6805typedef FNIEMTHREADEDFUNC *PFNIEMTHREADEDFUNC;
6806# define IEM_DECL_IEMTHREADEDFUNC_DEF(a_Name) \
6807 VBOXSTRICTRC __attribute__((__nothrow__)) a_Name(PVMCPU pVCpu, uint64_t uParam0, uint64_t uParam1, uint64_t uParam2)
6808# define IEM_DECL_IEMTHREADEDFUNC_PROTO(a_Name) \
6809 VBOXSTRICTRC __attribute__((__nothrow__)) a_Name(PVMCPU pVCpu, uint64_t uParam0, uint64_t uParam1, uint64_t uParam2)
6810
6811#else
6812typedef VBOXSTRICTRC (FNIEMTHREADEDFUNC)(PVMCPU pVCpu, uint64_t uParam0, uint64_t uParam1, uint64_t uParam2);
6813typedef FNIEMTHREADEDFUNC *PFNIEMTHREADEDFUNC;
6814# define IEM_DECL_IEMTHREADEDFUNC_DEF(a_Name) \
6815 VBOXSTRICTRC a_Name(PVMCPU pVCpu, uint64_t uParam0, uint64_t uParam1, uint64_t uParam2) IEM_NOEXCEPT_MAY_LONGJMP
6816# define IEM_DECL_IEMTHREADEDFUNC_PROTO(a_Name) \
6817 VBOXSTRICTRC a_Name(PVMCPU pVCpu, uint64_t uParam0, uint64_t uParam1, uint64_t uParam2) IEM_NOEXCEPT_MAY_LONGJMP
6818#endif
6819
6820
6821IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_Nop);
6822IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_LogCpuState);
6823
6824IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_DeferToCImpl0);
6825
6826IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckIrq);
6827IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckTimers);
6828IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckTimersAndIrq);
6829IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckMode);
6830IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckHwInstrBps);
6831IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckCsLim);
6832
6833IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckCsLimAndOpcodes);
6834IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckOpcodes);
6835IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckOpcodesConsiderCsLim);
6836
6837/* Branching: */
6838IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckCsLimAndPcAndOpcodes);
6839IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckPcAndOpcodes);
6840IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckPcAndOpcodesConsiderCsLim);
6841
6842IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckCsLimAndOpcodesLoadingTlb);
6843IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckOpcodesLoadingTlb);
6844IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckOpcodesLoadingTlbConsiderCsLim);
6845
6846/* Natural page crossing: */
6847IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckCsLimAndOpcodesAcrossPageLoadingTlb);
6848IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckOpcodesAcrossPageLoadingTlb);
6849IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckOpcodesAcrossPageLoadingTlbConsiderCsLim);
6850
6851IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckCsLimAndOpcodesOnNextPageLoadingTlb);
6852IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckOpcodesOnNextPageLoadingTlb);
6853IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckOpcodesOnNextPageLoadingTlbConsiderCsLim);
6854
6855IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckCsLimAndOpcodesOnNewPageLoadingTlb);
6856IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckOpcodesOnNewPageLoadingTlb);
6857IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckOpcodesOnNewPageLoadingTlbConsiderCsLim);
6858
6859IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_Jump);
6860
6861bool iemThreadedCompileEmitIrqCheckBefore(PVMCPUCC pVCpu, PIEMTB pTb);
6862bool iemThreadedCompileBeginEmitCallsComplications(PVMCPUCC pVCpu, PIEMTB pTb);
6863
6864/* Native recompiler public bits: */
6865
6866DECLHIDDEN(PIEMTB) iemNativeRecompile(PVMCPUCC pVCpu, PIEMTB pTb) RT_NOEXCEPT;
6867DECLHIDDEN(void) iemNativeDisassembleTb(PVMCPU pVCpu, PCIEMTB pTb, PCDBGFINFOHLP pHlp) RT_NOEXCEPT;
6868int iemExecMemAllocatorInit(PVMCPU pVCpu, uint64_t cbMax, uint64_t cbInitial, uint32_t cbChunk) RT_NOEXCEPT;
6869DECLHIDDEN(PIEMNATIVEINSTR) iemExecMemAllocatorAlloc(PVMCPU pVCpu, uint32_t cbReq, PIEMTB pTb, PIEMNATIVEINSTR *ppaExec,
6870 struct IEMNATIVEPERCHUNKCTX const **ppChunkCtx) RT_NOEXCEPT;
6871DECLHIDDEN(PIEMNATIVEINSTR) iemExecMemAllocatorAllocFromChunk(PVMCPU pVCpu, uint32_t idxChunk, uint32_t cbReq,
6872 PIEMNATIVEINSTR *ppaExec);
6873DECLHIDDEN(void) iemExecMemAllocatorReadyForUse(PVMCPUCC pVCpu, void *pv, size_t cb) RT_NOEXCEPT;
6874void iemExecMemAllocatorFree(PVMCPU pVCpu, void *pv, size_t cb) RT_NOEXCEPT;
6875DECLASM(DECL_NO_RETURN(void)) iemNativeTbLongJmp(void *pvFramePointer, int rc) RT_NOEXCEPT;
6876DECLHIDDEN(struct IEMNATIVEPERCHUNKCTX const *) iemExecMemGetTbChunkCtx(PVMCPU pVCpu, PCIEMTB pTb);
6877DECLHIDDEN(struct IEMNATIVEPERCHUNKCTX const *) iemNativeRecompileAttachExecMemChunkCtx(PVMCPU pVCpu, uint32_t idxChunk);
6878
6879/** Packed 32-bit argument for iemCImpl_vpgather_worker_xx. */
6880typedef union IEMGATHERARGS
6881{
6882 /** Integer view. */
6883 uint32_t u;
6884 /** Bitfield view. */
6885 struct
6886 {
6887 uint32_t iYRegDst : 4; /**< 0 - XMM or YMM register number (destination) */
6888 uint32_t iYRegIdc : 4; /**< 4 - XMM or YMM register number (indices) */
6889 uint32_t iYRegMsk : 4; /**< 8 - XMM or YMM register number (mask) */
6890 uint32_t iGRegBase : 4; /**< 12 - general register number (base ptr) */
6891 uint32_t iScale : 2; /**< 16 - scale factor (1/2/4/8) */
6892 uint32_t enmEffOpSize : 2; /**< 18 - operand size (16/32/64/--) */
6893 uint32_t enmEffAddrMode : 2; /**< 20 - addressing mode (16/32/64/--) */
6894 uint32_t iEffSeg : 3; /**< 22 - effective segment (ES/CS/SS/DS/FS/GS) */
6895 uint32_t fVex256 : 1; /**< 25 - overall instruction width (128/256 bits) */
6896 uint32_t fIdxQword : 1; /**< 26 - individual index width (4/8 bytes) */
6897 uint32_t fValQword : 1; /**< 27 - individual value width (4/8 bytes) */
6898 } s;
6899} IEMGATHERARGS;
6900AssertCompileSize(IEMGATHERARGS, sizeof(uint32_t));
6901
6902#endif /* !RT_IN_ASSEMBLER - ASM-NOINC-END */
6903
6904
6905/** @} */
6906
6907RT_C_DECLS_END
6908
6909/* ASM-INC: %include "IEMInternalStruct.mac" */
6910
6911#endif /* !VMM_INCLUDED_SRC_include_IEMInternal_h */
6912
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette