VirtualBox

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

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

VMM/IEM: Optimize kIemTbDbgEntryType_NativeOffset emitting, caching the previous offset instead of searching backwards for it. bugref:10370

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