VirtualBox

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

Last change on this file since 102735 was 102703, checked in by vboxsync, 11 months ago

VMM/IEM: Extended IEMTB_KEY_MASK to include the CPL so IEMTLBE_F_PT_NO_USER can be determined at compile time in the native recompiler. bugref:10371

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