VirtualBox

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

Last change on this file since 104064 was 104064, checked in by vboxsync, 8 months ago

VMM/IEM: Made the IEMTB::cUsage value the native recompilation is done at configurable. bugref:10370

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