VirtualBox

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

Last change on this file since 105447 was 105447, checked in by vboxsync, 4 months ago

VMM/IEM: Reverted accidental 16384 TLB size back to 8192 in r164097. bugref:10727

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

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