VirtualBox

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

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

VMM: bugref:9898 Fixed Python generator breakage with r162727 by implementing IEMOP_BODY macro instead of static helper function.

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