VirtualBox

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

Last change on this file since 103826 was 103813, checked in by vboxsync, 10 months ago

VMM/IEM: Enable SIMD code again after latest amd64 fixes, bugref:10614

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