VirtualBox

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

Last change on this file since 102856 was 102850, checked in by vboxsync, 11 months ago

VMM/IEM: Implemented the first of two code TLB lookups. bugref:10371

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 290.8 KB
Line 
1/* $Id: IEMInternal.h 102850 2024-01-12 00:47:47Z 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
1713 /** Statistics: Times TB execution was broken off before reaching the end. */
1714 STAMCOUNTER StatTbExecBreaks;
1715 /** Statistics: Times BltIn_CheckIrq breaks out of the TB. */
1716 STAMCOUNTER StatCheckIrqBreaks;
1717 /** Statistics: Times BltIn_CheckMode breaks out of the TB. */
1718 STAMCOUNTER StatCheckModeBreaks;
1719 /** Statistics: Times a post jump target check missed and had to find new TB. */
1720 STAMCOUNTER StatCheckBranchMisses;
1721 /** Statistics: Times a jump or page crossing required a TB with CS.LIM checking. */
1722 STAMCOUNTER StatCheckNeedCsLimChecking;
1723 /** Native TB statistics: Number of fully recompiled TBs. */
1724 STAMCOUNTER StatNativeFullyRecompiledTbs;
1725 /** Threaded TB statistics: Number of instructions per TB. */
1726 STAMPROFILE StatTbThreadedInstr;
1727 /** Threaded TB statistics: Number of calls per TB. */
1728 STAMPROFILE StatTbThreadedCalls;
1729 /** Native TB statistics: Native code size per TB. */
1730 STAMPROFILE StatTbNativeCode;
1731 /** Native TB statistics: Profiling native recompilation. */
1732 STAMPROFILE StatNativeRecompilation;
1733 /** Native TB statistics: Number of calls per TB that were recompiled properly. */
1734 STAMPROFILE StatNativeCallsRecompiled;
1735 /** Native TB statistics: Number of threaded calls per TB that weren't recompiled. */
1736 STAMPROFILE StatNativeCallsThreaded;
1737 /** Native recompiled execution: TLB hits for data fetches. */
1738 STAMCOUNTER StatNativeTlbHitsForFetch;
1739 /** Native recompiled execution: TLB hits for data stores. */
1740 STAMCOUNTER StatNativeTlbHitsForStore;
1741 /** Native recompiled execution: TLB hits for stack accesses. */
1742 STAMCOUNTER StatNativeTlbHitsForStack;
1743 /** Native recompiled execution: TLB hits for mapped accesses. */
1744 STAMCOUNTER StatNativeTlbHitsForMapped;
1745 /** Native recompiled execution: Code TLB misses for new page. */
1746 STAMCOUNTER StatNativeCodeTlbMissesNewPage;
1747 /** Native recompiled execution: Code TLB hits for new page. */
1748 STAMCOUNTER StatNativeCodeTlbHitsForNewPage;
1749 /** Native recompiled execution: Code TLB misses for new page with offset. */
1750 STAMCOUNTER StatNativeCodeTlbMissesNewPageWithOffset;
1751 /** Native recompiled execution: Code TLB hits for new page with offset. */
1752 STAMCOUNTER StatNativeCodeTlbHitsForNewPageWithOffset;
1753 uint64_t au64Padding[3];
1754 /** @} */
1755
1756 /** Data TLB.
1757 * @remarks Must be 64-byte aligned. */
1758 IEMTLB DataTlb;
1759 /** Instruction TLB.
1760 * @remarks Must be 64-byte aligned. */
1761 IEMTLB CodeTlb;
1762
1763 /** Exception statistics. */
1764 STAMCOUNTER aStatXcpts[32];
1765 /** Interrupt statistics. */
1766 uint32_t aStatInts[256];
1767
1768#if defined(VBOX_WITH_STATISTICS) && !defined(IN_TSTVMSTRUCT) && !defined(DOXYGEN_RUNNING)
1769 /** Instruction statistics for ring-0/raw-mode. */
1770 IEMINSTRSTATS StatsRZ;
1771 /** Instruction statistics for ring-3. */
1772 IEMINSTRSTATS StatsR3;
1773#endif
1774} IEMCPU;
1775AssertCompileMemberOffset(IEMCPU, cActiveMappings, 0x4f);
1776AssertCompileMemberAlignment(IEMCPU, aMemMappings, 16);
1777AssertCompileMemberAlignment(IEMCPU, aMemMappingLocks, 16);
1778AssertCompileMemberAlignment(IEMCPU, aBounceBuffers, 64);
1779AssertCompileMemberAlignment(IEMCPU, DataTlb, 64);
1780AssertCompileMemberAlignment(IEMCPU, CodeTlb, 64);
1781
1782/** Pointer to the per-CPU IEM state. */
1783typedef IEMCPU *PIEMCPU;
1784/** Pointer to the const per-CPU IEM state. */
1785typedef IEMCPU const *PCIEMCPU;
1786
1787
1788/** @def IEM_GET_CTX
1789 * Gets the guest CPU context for the calling EMT.
1790 * @returns PCPUMCTX
1791 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
1792 */
1793#define IEM_GET_CTX(a_pVCpu) (&(a_pVCpu)->cpum.GstCtx)
1794
1795/** @def IEM_CTX_ASSERT
1796 * Asserts that the @a a_fExtrnMbz is present in the CPU context.
1797 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
1798 * @param a_fExtrnMbz The mask of CPUMCTX_EXTRN_XXX flags that must be zero.
1799 */
1800#define IEM_CTX_ASSERT(a_pVCpu, a_fExtrnMbz) \
1801 AssertMsg(!((a_pVCpu)->cpum.GstCtx.fExtrn & (a_fExtrnMbz)), \
1802 ("fExtrn=%#RX64 & fExtrnMbz=%#RX64 -> %#RX64\n", \
1803 (a_pVCpu)->cpum.GstCtx.fExtrn, (a_fExtrnMbz), (a_pVCpu)->cpum.GstCtx.fExtrn & (a_fExtrnMbz) ))
1804
1805/** @def IEM_CTX_IMPORT_RET
1806 * Makes sure the CPU context bits given by @a a_fExtrnImport are imported.
1807 *
1808 * Will call the keep to import the bits as needed.
1809 *
1810 * Returns on import failure.
1811 *
1812 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
1813 * @param a_fExtrnImport The mask of CPUMCTX_EXTRN_XXX flags to import.
1814 */
1815#define IEM_CTX_IMPORT_RET(a_pVCpu, a_fExtrnImport) \
1816 do { \
1817 if (!((a_pVCpu)->cpum.GstCtx.fExtrn & (a_fExtrnImport))) \
1818 { /* likely */ } \
1819 else \
1820 { \
1821 int rcCtxImport = CPUMImportGuestStateOnDemand(a_pVCpu, a_fExtrnImport); \
1822 AssertRCReturn(rcCtxImport, rcCtxImport); \
1823 } \
1824 } while (0)
1825
1826/** @def IEM_CTX_IMPORT_NORET
1827 * Makes sure the CPU context bits given by @a a_fExtrnImport are imported.
1828 *
1829 * Will call the keep to import the bits as needed.
1830 *
1831 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
1832 * @param a_fExtrnImport The mask of CPUMCTX_EXTRN_XXX flags to import.
1833 */
1834#define IEM_CTX_IMPORT_NORET(a_pVCpu, a_fExtrnImport) \
1835 do { \
1836 if (!((a_pVCpu)->cpum.GstCtx.fExtrn & (a_fExtrnImport))) \
1837 { /* likely */ } \
1838 else \
1839 { \
1840 int rcCtxImport = CPUMImportGuestStateOnDemand(a_pVCpu, a_fExtrnImport); \
1841 AssertLogRelRC(rcCtxImport); \
1842 } \
1843 } while (0)
1844
1845/** @def IEM_CTX_IMPORT_JMP
1846 * Makes sure the CPU context bits given by @a a_fExtrnImport are imported.
1847 *
1848 * Will call the keep to import the bits as needed.
1849 *
1850 * Jumps on import failure.
1851 *
1852 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
1853 * @param a_fExtrnImport The mask of CPUMCTX_EXTRN_XXX flags to import.
1854 */
1855#define IEM_CTX_IMPORT_JMP(a_pVCpu, a_fExtrnImport) \
1856 do { \
1857 if (!((a_pVCpu)->cpum.GstCtx.fExtrn & (a_fExtrnImport))) \
1858 { /* likely */ } \
1859 else \
1860 { \
1861 int rcCtxImport = CPUMImportGuestStateOnDemand(a_pVCpu, a_fExtrnImport); \
1862 AssertRCStmt(rcCtxImport, IEM_DO_LONGJMP(pVCpu, rcCtxImport)); \
1863 } \
1864 } while (0)
1865
1866
1867
1868/** @def IEM_GET_TARGET_CPU
1869 * Gets the current IEMTARGETCPU value.
1870 * @returns IEMTARGETCPU value.
1871 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
1872 */
1873#if IEM_CFG_TARGET_CPU != IEMTARGETCPU_DYNAMIC
1874# define IEM_GET_TARGET_CPU(a_pVCpu) (IEM_CFG_TARGET_CPU)
1875#else
1876# define IEM_GET_TARGET_CPU(a_pVCpu) ((a_pVCpu)->iem.s.uTargetCpu)
1877#endif
1878
1879/** @def IEM_GET_INSTR_LEN
1880 * Gets the instruction length. */
1881#ifdef IEM_WITH_CODE_TLB
1882# define IEM_GET_INSTR_LEN(a_pVCpu) ((a_pVCpu)->iem.s.offInstrNextByte - (uint32_t)(int32_t)(a_pVCpu)->iem.s.offCurInstrStart)
1883#else
1884# define IEM_GET_INSTR_LEN(a_pVCpu) ((a_pVCpu)->iem.s.offOpcode)
1885#endif
1886
1887/** @def IEM_TRY_SETJMP
1888 * Wrapper around setjmp / try, hiding all the ugly differences.
1889 *
1890 * @note Use with extreme care as this is a fragile macro.
1891 * @param a_pVCpu The cross context virtual CPU structure of the calling EMT.
1892 * @param a_rcTarget The variable that should receive the status code in case
1893 * of a longjmp/throw.
1894 */
1895/** @def IEM_TRY_SETJMP_AGAIN
1896 * For when setjmp / try is used again in the same variable scope as a previous
1897 * IEM_TRY_SETJMP invocation.
1898 */
1899/** @def IEM_CATCH_LONGJMP_BEGIN
1900 * Start wrapper for catch / setjmp-else.
1901 *
1902 * This will set up a scope.
1903 *
1904 * @note Use with extreme care as this is a fragile macro.
1905 * @param a_pVCpu The cross context virtual CPU structure of the calling EMT.
1906 * @param a_rcTarget The variable that should receive the status code in case
1907 * of a longjmp/throw.
1908 */
1909/** @def IEM_CATCH_LONGJMP_END
1910 * End wrapper for catch / setjmp-else.
1911 *
1912 * This will close the scope set up by IEM_CATCH_LONGJMP_BEGIN and clean up the
1913 * state.
1914 *
1915 * @note Use with extreme care as this is a fragile macro.
1916 * @param a_pVCpu The cross context virtual CPU structure of the calling EMT.
1917 */
1918#if defined(IEM_WITH_SETJMP) || defined(DOXYGEN_RUNNING)
1919# ifdef IEM_WITH_THROW_CATCH
1920# define IEM_TRY_SETJMP(a_pVCpu, a_rcTarget) \
1921 a_rcTarget = VINF_SUCCESS; \
1922 try
1923# define IEM_TRY_SETJMP_AGAIN(a_pVCpu, a_rcTarget) \
1924 IEM_TRY_SETJMP(a_pVCpu, a_rcTarget)
1925# define IEM_CATCH_LONGJMP_BEGIN(a_pVCpu, a_rcTarget) \
1926 catch (int rcThrown) \
1927 { \
1928 a_rcTarget = rcThrown
1929# define IEM_CATCH_LONGJMP_END(a_pVCpu) \
1930 } \
1931 ((void)0)
1932# else /* !IEM_WITH_THROW_CATCH */
1933# define IEM_TRY_SETJMP(a_pVCpu, a_rcTarget) \
1934 jmp_buf JmpBuf; \
1935 jmp_buf * volatile pSavedJmpBuf = (a_pVCpu)->iem.s.CTX_SUFF(pJmpBuf); \
1936 (a_pVCpu)->iem.s.CTX_SUFF(pJmpBuf) = &JmpBuf; \
1937 if ((rcStrict = setjmp(JmpBuf)) == 0)
1938# define IEM_TRY_SETJMP_AGAIN(a_pVCpu, a_rcTarget) \
1939 pSavedJmpBuf = (a_pVCpu)->iem.s.CTX_SUFF(pJmpBuf); \
1940 (a_pVCpu)->iem.s.CTX_SUFF(pJmpBuf) = &JmpBuf; \
1941 if ((rcStrict = setjmp(JmpBuf)) == 0)
1942# define IEM_CATCH_LONGJMP_BEGIN(a_pVCpu, a_rcTarget) \
1943 else \
1944 { \
1945 ((void)0)
1946# define IEM_CATCH_LONGJMP_END(a_pVCpu) \
1947 } \
1948 (a_pVCpu)->iem.s.CTX_SUFF(pJmpBuf) = pSavedJmpBuf
1949# endif /* !IEM_WITH_THROW_CATCH */
1950#endif /* IEM_WITH_SETJMP */
1951
1952
1953/**
1954 * Shared per-VM IEM data.
1955 */
1956typedef struct IEM
1957{
1958 /** The VMX APIC-access page handler type. */
1959 PGMPHYSHANDLERTYPE hVmxApicAccessPage;
1960#ifndef VBOX_WITHOUT_CPUID_HOST_CALL
1961 /** Set if the CPUID host call functionality is enabled. */
1962 bool fCpuIdHostCall;
1963#endif
1964} IEM;
1965
1966
1967
1968/** @name IEM_ACCESS_XXX - Access details.
1969 * @{ */
1970#define IEM_ACCESS_INVALID UINT32_C(0x000000ff)
1971#define IEM_ACCESS_TYPE_READ UINT32_C(0x00000001)
1972#define IEM_ACCESS_TYPE_WRITE UINT32_C(0x00000002)
1973#define IEM_ACCESS_TYPE_EXEC UINT32_C(0x00000004)
1974#define IEM_ACCESS_TYPE_MASK UINT32_C(0x00000007)
1975#define IEM_ACCESS_WHAT_CODE UINT32_C(0x00000010)
1976#define IEM_ACCESS_WHAT_DATA UINT32_C(0x00000020)
1977#define IEM_ACCESS_WHAT_STACK UINT32_C(0x00000030)
1978#define IEM_ACCESS_WHAT_SYS UINT32_C(0x00000040)
1979#define IEM_ACCESS_WHAT_MASK UINT32_C(0x00000070)
1980/** The writes are partial, so if initialize the bounce buffer with the
1981 * orignal RAM content. */
1982#define IEM_ACCESS_PARTIAL_WRITE UINT32_C(0x00000100)
1983/** Used in aMemMappings to indicate that the entry is bounce buffered. */
1984#define IEM_ACCESS_BOUNCE_BUFFERED UINT32_C(0x00000200)
1985/** Bounce buffer with ring-3 write pending, first page. */
1986#define IEM_ACCESS_PENDING_R3_WRITE_1ST UINT32_C(0x00000400)
1987/** Bounce buffer with ring-3 write pending, second page. */
1988#define IEM_ACCESS_PENDING_R3_WRITE_2ND UINT32_C(0x00000800)
1989/** Not locked, accessed via the TLB. */
1990#define IEM_ACCESS_NOT_LOCKED UINT32_C(0x00001000)
1991/** Valid bit mask. */
1992#define IEM_ACCESS_VALID_MASK UINT32_C(0x00001fff)
1993/** Shift count for the TLB flags (upper word). */
1994#define IEM_ACCESS_SHIFT_TLB_FLAGS 16
1995
1996/** Read+write data alias. */
1997#define IEM_ACCESS_DATA_RW (IEM_ACCESS_TYPE_READ | IEM_ACCESS_TYPE_WRITE | IEM_ACCESS_WHAT_DATA)
1998/** Write data alias. */
1999#define IEM_ACCESS_DATA_W (IEM_ACCESS_TYPE_WRITE | IEM_ACCESS_WHAT_DATA)
2000/** Read data alias. */
2001#define IEM_ACCESS_DATA_R (IEM_ACCESS_TYPE_READ | IEM_ACCESS_WHAT_DATA)
2002/** Instruction fetch alias. */
2003#define IEM_ACCESS_INSTRUCTION (IEM_ACCESS_TYPE_EXEC | IEM_ACCESS_WHAT_CODE)
2004/** Stack write alias. */
2005#define IEM_ACCESS_STACK_W (IEM_ACCESS_TYPE_WRITE | IEM_ACCESS_WHAT_STACK)
2006/** Stack read alias. */
2007#define IEM_ACCESS_STACK_R (IEM_ACCESS_TYPE_READ | IEM_ACCESS_WHAT_STACK)
2008/** Stack read+write alias. */
2009#define IEM_ACCESS_STACK_RW (IEM_ACCESS_TYPE_READ | IEM_ACCESS_TYPE_WRITE | IEM_ACCESS_WHAT_STACK)
2010/** Read system table alias. */
2011#define IEM_ACCESS_SYS_R (IEM_ACCESS_TYPE_READ | IEM_ACCESS_WHAT_SYS)
2012/** Read+write system table alias. */
2013#define IEM_ACCESS_SYS_RW (IEM_ACCESS_TYPE_READ | IEM_ACCESS_TYPE_WRITE | IEM_ACCESS_WHAT_SYS)
2014/** @} */
2015
2016/** @name Prefix constants (IEMCPU::fPrefixes)
2017 * @{ */
2018#define IEM_OP_PRF_SEG_CS RT_BIT_32(0) /**< CS segment prefix (0x2e). */
2019#define IEM_OP_PRF_SEG_SS RT_BIT_32(1) /**< SS segment prefix (0x36). */
2020#define IEM_OP_PRF_SEG_DS RT_BIT_32(2) /**< DS segment prefix (0x3e). */
2021#define IEM_OP_PRF_SEG_ES RT_BIT_32(3) /**< ES segment prefix (0x26). */
2022#define IEM_OP_PRF_SEG_FS RT_BIT_32(4) /**< FS segment prefix (0x64). */
2023#define IEM_OP_PRF_SEG_GS RT_BIT_32(5) /**< GS segment prefix (0x65). */
2024#define IEM_OP_PRF_SEG_MASK UINT32_C(0x3f)
2025
2026#define IEM_OP_PRF_SIZE_OP RT_BIT_32(8) /**< Operand size prefix (0x66). */
2027#define IEM_OP_PRF_SIZE_REX_W RT_BIT_32(9) /**< REX.W prefix (0x48-0x4f). */
2028#define IEM_OP_PRF_SIZE_ADDR RT_BIT_32(10) /**< Address size prefix (0x67). */
2029
2030#define IEM_OP_PRF_LOCK RT_BIT_32(16) /**< Lock prefix (0xf0). */
2031#define IEM_OP_PRF_REPNZ RT_BIT_32(17) /**< Repeat-not-zero prefix (0xf2). */
2032#define IEM_OP_PRF_REPZ RT_BIT_32(18) /**< Repeat-if-zero prefix (0xf3). */
2033
2034#define IEM_OP_PRF_REX RT_BIT_32(24) /**< Any REX prefix (0x40-0x4f). */
2035#define IEM_OP_PRF_REX_R RT_BIT_32(25) /**< REX.R prefix (0x44,0x45,0x46,0x47,0x4c,0x4d,0x4e,0x4f). */
2036#define IEM_OP_PRF_REX_B RT_BIT_32(26) /**< REX.B prefix (0x41,0x43,0x45,0x47,0x49,0x4b,0x4d,0x4f). */
2037#define IEM_OP_PRF_REX_X RT_BIT_32(27) /**< REX.X prefix (0x42,0x43,0x46,0x47,0x4a,0x4b,0x4e,0x4f). */
2038/** Mask with all the REX prefix flags.
2039 * This is generally for use when needing to undo the REX prefixes when they
2040 * are followed legacy prefixes and therefore does not immediately preceed
2041 * the first opcode byte.
2042 * For testing whether any REX prefix is present, use IEM_OP_PRF_REX instead. */
2043#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 )
2044
2045#define IEM_OP_PRF_VEX RT_BIT_32(28) /**< Indiciates VEX prefix. */
2046#define IEM_OP_PRF_EVEX RT_BIT_32(29) /**< Indiciates EVEX prefix. */
2047#define IEM_OP_PRF_XOP RT_BIT_32(30) /**< Indiciates XOP prefix. */
2048/** @} */
2049
2050/** @name IEMOPFORM_XXX - Opcode forms
2051 * @note These are ORed together with IEMOPHINT_XXX.
2052 * @{ */
2053/** ModR/M: reg, r/m */
2054#define IEMOPFORM_RM 0
2055/** ModR/M: reg, r/m (register) */
2056#define IEMOPFORM_RM_REG (IEMOPFORM_RM | IEMOPFORM_MOD3)
2057/** ModR/M: reg, r/m (memory) */
2058#define IEMOPFORM_RM_MEM (IEMOPFORM_RM | IEMOPFORM_NOT_MOD3)
2059/** ModR/M: reg, r/m */
2060#define IEMOPFORM_RMI 1
2061/** ModR/M: reg, r/m (register) */
2062#define IEMOPFORM_RMI_REG (IEMOPFORM_RM | IEMOPFORM_MOD3)
2063/** ModR/M: reg, r/m (memory) */
2064#define IEMOPFORM_RMI_MEM (IEMOPFORM_RM | IEMOPFORM_NOT_MOD3)
2065/** ModR/M: r/m, reg */
2066#define IEMOPFORM_MR 2
2067/** ModR/M: r/m (register), reg */
2068#define IEMOPFORM_MR_REG (IEMOPFORM_MR | IEMOPFORM_MOD3)
2069/** ModR/M: r/m (memory), reg */
2070#define IEMOPFORM_MR_MEM (IEMOPFORM_MR | IEMOPFORM_NOT_MOD3)
2071/** ModR/M: r/m, reg */
2072#define IEMOPFORM_MRI 3
2073/** ModR/M: r/m (register), reg */
2074#define IEMOPFORM_MRI_REG (IEMOPFORM_MR | IEMOPFORM_MOD3)
2075/** ModR/M: r/m (memory), reg */
2076#define IEMOPFORM_MRI_MEM (IEMOPFORM_MR | IEMOPFORM_NOT_MOD3)
2077/** ModR/M: r/m only */
2078#define IEMOPFORM_M 4
2079/** ModR/M: r/m only (register). */
2080#define IEMOPFORM_M_REG (IEMOPFORM_M | IEMOPFORM_MOD3)
2081/** ModR/M: r/m only (memory). */
2082#define IEMOPFORM_M_MEM (IEMOPFORM_M | IEMOPFORM_NOT_MOD3)
2083/** ModR/M: reg only */
2084#define IEMOPFORM_R 5
2085
2086/** VEX+ModR/M: reg, r/m */
2087#define IEMOPFORM_VEX_RM 8
2088/** VEX+ModR/M: reg, r/m (register) */
2089#define IEMOPFORM_VEX_RM_REG (IEMOPFORM_VEX_RM | IEMOPFORM_MOD3)
2090/** VEX+ModR/M: reg, r/m (memory) */
2091#define IEMOPFORM_VEX_RM_MEM (IEMOPFORM_VEX_RM | IEMOPFORM_NOT_MOD3)
2092/** VEX+ModR/M: r/m, reg */
2093#define IEMOPFORM_VEX_MR 9
2094/** VEX+ModR/M: r/m (register), reg */
2095#define IEMOPFORM_VEX_MR_REG (IEMOPFORM_VEX_MR | IEMOPFORM_MOD3)
2096/** VEX+ModR/M: r/m (memory), reg */
2097#define IEMOPFORM_VEX_MR_MEM (IEMOPFORM_VEX_MR | IEMOPFORM_NOT_MOD3)
2098/** VEX+ModR/M: r/m only */
2099#define IEMOPFORM_VEX_M 10
2100/** VEX+ModR/M: r/m only (register). */
2101#define IEMOPFORM_VEX_M_REG (IEMOPFORM_VEX_M | IEMOPFORM_MOD3)
2102/** VEX+ModR/M: r/m only (memory). */
2103#define IEMOPFORM_VEX_M_MEM (IEMOPFORM_VEX_M | IEMOPFORM_NOT_MOD3)
2104/** VEX+ModR/M: reg only */
2105#define IEMOPFORM_VEX_R 11
2106/** VEX+ModR/M: reg, vvvv, r/m */
2107#define IEMOPFORM_VEX_RVM 12
2108/** VEX+ModR/M: reg, vvvv, r/m (register). */
2109#define IEMOPFORM_VEX_RVM_REG (IEMOPFORM_VEX_RVM | IEMOPFORM_MOD3)
2110/** VEX+ModR/M: reg, vvvv, r/m (memory). */
2111#define IEMOPFORM_VEX_RVM_MEM (IEMOPFORM_VEX_RVM | IEMOPFORM_NOT_MOD3)
2112/** VEX+ModR/M: reg, r/m, vvvv */
2113#define IEMOPFORM_VEX_RMV 13
2114/** VEX+ModR/M: reg, r/m, vvvv (register). */
2115#define IEMOPFORM_VEX_RMV_REG (IEMOPFORM_VEX_RMV | IEMOPFORM_MOD3)
2116/** VEX+ModR/M: reg, r/m, vvvv (memory). */
2117#define IEMOPFORM_VEX_RMV_MEM (IEMOPFORM_VEX_RMV | IEMOPFORM_NOT_MOD3)
2118/** VEX+ModR/M: reg, r/m, imm8 */
2119#define IEMOPFORM_VEX_RMI 14
2120/** VEX+ModR/M: reg, r/m, imm8 (register). */
2121#define IEMOPFORM_VEX_RMI_REG (IEMOPFORM_VEX_RMI | IEMOPFORM_MOD3)
2122/** VEX+ModR/M: reg, r/m, imm8 (memory). */
2123#define IEMOPFORM_VEX_RMI_MEM (IEMOPFORM_VEX_RMI | IEMOPFORM_NOT_MOD3)
2124/** VEX+ModR/M: r/m, vvvv, reg */
2125#define IEMOPFORM_VEX_MVR 15
2126/** VEX+ModR/M: r/m, vvvv, reg (register) */
2127#define IEMOPFORM_VEX_MVR_REG (IEMOPFORM_VEX_MVR | IEMOPFORM_MOD3)
2128/** VEX+ModR/M: r/m, vvvv, reg (memory) */
2129#define IEMOPFORM_VEX_MVR_MEM (IEMOPFORM_VEX_MVR | IEMOPFORM_NOT_MOD3)
2130/** VEX+ModR/M+/n: vvvv, r/m */
2131#define IEMOPFORM_VEX_VM 16
2132/** VEX+ModR/M+/n: vvvv, r/m (register) */
2133#define IEMOPFORM_VEX_VM_REG (IEMOPFORM_VEX_VM | IEMOPFORM_MOD3)
2134/** VEX+ModR/M+/n: vvvv, r/m (memory) */
2135#define IEMOPFORM_VEX_VM_MEM (IEMOPFORM_VEX_VM | IEMOPFORM_NOT_MOD3)
2136
2137/** Fixed register instruction, no R/M. */
2138#define IEMOPFORM_FIXED 32
2139
2140/** The r/m is a register. */
2141#define IEMOPFORM_MOD3 RT_BIT_32(8)
2142/** The r/m is a memory access. */
2143#define IEMOPFORM_NOT_MOD3 RT_BIT_32(9)
2144/** @} */
2145
2146/** @name IEMOPHINT_XXX - Additional Opcode Hints
2147 * @note These are ORed together with IEMOPFORM_XXX.
2148 * @{ */
2149/** Ignores the operand size prefix (66h). */
2150#define IEMOPHINT_IGNORES_OZ_PFX RT_BIT_32(10)
2151/** Ignores REX.W (aka WIG). */
2152#define IEMOPHINT_IGNORES_REXW RT_BIT_32(11)
2153/** Both the operand size prefixes (66h + REX.W) are ignored. */
2154#define IEMOPHINT_IGNORES_OP_SIZES (IEMOPHINT_IGNORES_OZ_PFX | IEMOPHINT_IGNORES_REXW)
2155/** Allowed with the lock prefix. */
2156#define IEMOPHINT_LOCK_ALLOWED RT_BIT_32(11)
2157/** The VEX.L value is ignored (aka LIG). */
2158#define IEMOPHINT_VEX_L_IGNORED RT_BIT_32(12)
2159/** The VEX.L value must be zero (i.e. 128-bit width only). */
2160#define IEMOPHINT_VEX_L_ZERO RT_BIT_32(13)
2161/** The VEX.V value must be zero. */
2162#define IEMOPHINT_VEX_V_ZERO RT_BIT_32(14)
2163
2164/** Hint to IEMAllInstructionPython.py that this macro should be skipped. */
2165#define IEMOPHINT_SKIP_PYTHON RT_BIT_32(31)
2166/** @} */
2167
2168/**
2169 * Possible hardware task switch sources.
2170 */
2171typedef enum IEMTASKSWITCH
2172{
2173 /** Task switch caused by an interrupt/exception. */
2174 IEMTASKSWITCH_INT_XCPT = 1,
2175 /** Task switch caused by a far CALL. */
2176 IEMTASKSWITCH_CALL,
2177 /** Task switch caused by a far JMP. */
2178 IEMTASKSWITCH_JUMP,
2179 /** Task switch caused by an IRET. */
2180 IEMTASKSWITCH_IRET
2181} IEMTASKSWITCH;
2182AssertCompileSize(IEMTASKSWITCH, 4);
2183
2184/**
2185 * Possible CrX load (write) sources.
2186 */
2187typedef enum IEMACCESSCRX
2188{
2189 /** CrX access caused by 'mov crX' instruction. */
2190 IEMACCESSCRX_MOV_CRX,
2191 /** CrX (CR0) write caused by 'lmsw' instruction. */
2192 IEMACCESSCRX_LMSW,
2193 /** CrX (CR0) write caused by 'clts' instruction. */
2194 IEMACCESSCRX_CLTS,
2195 /** CrX (CR0) read caused by 'smsw' instruction. */
2196 IEMACCESSCRX_SMSW
2197} IEMACCESSCRX;
2198
2199#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
2200/** @name IEM_SLAT_FAIL_XXX - Second-level address translation failure information.
2201 *
2202 * These flags provide further context to SLAT page-walk failures that could not be
2203 * determined by PGM (e.g, PGM is not privy to memory access permissions).
2204 *
2205 * @{
2206 */
2207/** Translating a nested-guest linear address failed accessing a nested-guest
2208 * physical address. */
2209# define IEM_SLAT_FAIL_LINEAR_TO_PHYS_ADDR RT_BIT_32(0)
2210/** Translating a nested-guest linear address failed accessing a
2211 * paging-structure entry or updating accessed/dirty bits. */
2212# define IEM_SLAT_FAIL_LINEAR_TO_PAGE_TABLE RT_BIT_32(1)
2213/** @} */
2214
2215DECLCALLBACK(FNPGMPHYSHANDLER) iemVmxApicAccessPageHandler;
2216# ifndef IN_RING3
2217DECLCALLBACK(FNPGMRZPHYSPFHANDLER) iemVmxApicAccessPagePfHandler;
2218# endif
2219#endif
2220
2221/**
2222 * Indicates to the verifier that the given flag set is undefined.
2223 *
2224 * Can be invoked again to add more flags.
2225 *
2226 * This is a NOOP if the verifier isn't compiled in.
2227 *
2228 * @note We're temporarily keeping this until code is converted to new
2229 * disassembler style opcode handling.
2230 */
2231#define IEMOP_VERIFICATION_UNDEFINED_EFLAGS(a_fEfl) do { } while (0)
2232
2233
2234/** @def IEM_DECL_IMPL_TYPE
2235 * For typedef'ing an instruction implementation function.
2236 *
2237 * @param a_RetType The return type.
2238 * @param a_Name The name of the type.
2239 * @param a_ArgList The argument list enclosed in parentheses.
2240 */
2241
2242/** @def IEM_DECL_IMPL_DEF
2243 * For defining an instruction implementation function.
2244 *
2245 * @param a_RetType The return type.
2246 * @param a_Name The name of the type.
2247 * @param a_ArgList The argument list enclosed in parentheses.
2248 */
2249
2250#if defined(__GNUC__) && defined(RT_ARCH_X86)
2251# define IEM_DECL_IMPL_TYPE(a_RetType, a_Name, a_ArgList) \
2252 __attribute__((__fastcall__)) a_RetType (a_Name) a_ArgList
2253# define IEM_DECL_IMPL_DEF(a_RetType, a_Name, a_ArgList) \
2254 __attribute__((__fastcall__, __nothrow__)) DECL_HIDDEN_ONLY(a_RetType) a_Name a_ArgList
2255# define IEM_DECL_IMPL_PROTO(a_RetType, a_Name, a_ArgList) \
2256 __attribute__((__fastcall__, __nothrow__)) DECL_HIDDEN_ONLY(a_RetType) a_Name a_ArgList
2257
2258#elif defined(_MSC_VER) && defined(RT_ARCH_X86)
2259# define IEM_DECL_IMPL_TYPE(a_RetType, a_Name, a_ArgList) \
2260 a_RetType (__fastcall a_Name) a_ArgList
2261# define IEM_DECL_IMPL_DEF(a_RetType, a_Name, a_ArgList) \
2262 a_RetType __fastcall a_Name a_ArgList RT_NOEXCEPT
2263# define IEM_DECL_IMPL_PROTO(a_RetType, a_Name, a_ArgList) \
2264 a_RetType __fastcall a_Name a_ArgList RT_NOEXCEPT
2265
2266#elif __cplusplus >= 201700 /* P0012R1 support */
2267# define IEM_DECL_IMPL_TYPE(a_RetType, a_Name, a_ArgList) \
2268 a_RetType (VBOXCALL a_Name) a_ArgList RT_NOEXCEPT
2269# define IEM_DECL_IMPL_DEF(a_RetType, a_Name, a_ArgList) \
2270 DECL_HIDDEN_ONLY(a_RetType) VBOXCALL a_Name a_ArgList RT_NOEXCEPT
2271# define IEM_DECL_IMPL_PROTO(a_RetType, a_Name, a_ArgList) \
2272 DECL_HIDDEN_ONLY(a_RetType) VBOXCALL a_Name a_ArgList RT_NOEXCEPT
2273
2274#else
2275# define IEM_DECL_IMPL_TYPE(a_RetType, a_Name, a_ArgList) \
2276 a_RetType (VBOXCALL a_Name) a_ArgList
2277# define IEM_DECL_IMPL_DEF(a_RetType, a_Name, a_ArgList) \
2278 DECL_HIDDEN_ONLY(a_RetType) VBOXCALL a_Name a_ArgList
2279# define IEM_DECL_IMPL_PROTO(a_RetType, a_Name, a_ArgList) \
2280 DECL_HIDDEN_ONLY(a_RetType) VBOXCALL a_Name a_ArgList
2281
2282#endif
2283
2284/** Defined in IEMAllAImplC.cpp but also used by IEMAllAImplA.asm. */
2285RT_C_DECLS_BEGIN
2286extern uint8_t const g_afParity[256];
2287RT_C_DECLS_END
2288
2289
2290/** @name Arithmetic assignment operations on bytes (binary).
2291 * @{ */
2292typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINU8, (uint8_t *pu8Dst, uint8_t u8Src, uint32_t *pEFlags));
2293typedef FNIEMAIMPLBINU8 *PFNIEMAIMPLBINU8;
2294FNIEMAIMPLBINU8 iemAImpl_add_u8, iemAImpl_add_u8_locked;
2295FNIEMAIMPLBINU8 iemAImpl_adc_u8, iemAImpl_adc_u8_locked;
2296FNIEMAIMPLBINU8 iemAImpl_sub_u8, iemAImpl_sub_u8_locked;
2297FNIEMAIMPLBINU8 iemAImpl_sbb_u8, iemAImpl_sbb_u8_locked;
2298FNIEMAIMPLBINU8 iemAImpl_or_u8, iemAImpl_or_u8_locked;
2299FNIEMAIMPLBINU8 iemAImpl_xor_u8, iemAImpl_xor_u8_locked;
2300FNIEMAIMPLBINU8 iemAImpl_and_u8, iemAImpl_and_u8_locked;
2301/** @} */
2302
2303/** @name Arithmetic assignment operations on words (binary).
2304 * @{ */
2305typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINU16, (uint16_t *pu16Dst, uint16_t u16Src, uint32_t *pEFlags));
2306typedef FNIEMAIMPLBINU16 *PFNIEMAIMPLBINU16;
2307FNIEMAIMPLBINU16 iemAImpl_add_u16, iemAImpl_add_u16_locked;
2308FNIEMAIMPLBINU16 iemAImpl_adc_u16, iemAImpl_adc_u16_locked;
2309FNIEMAIMPLBINU16 iemAImpl_sub_u16, iemAImpl_sub_u16_locked;
2310FNIEMAIMPLBINU16 iemAImpl_sbb_u16, iemAImpl_sbb_u16_locked;
2311FNIEMAIMPLBINU16 iemAImpl_or_u16, iemAImpl_or_u16_locked;
2312FNIEMAIMPLBINU16 iemAImpl_xor_u16, iemAImpl_xor_u16_locked;
2313FNIEMAIMPLBINU16 iemAImpl_and_u16, iemAImpl_and_u16_locked;
2314/** @} */
2315
2316/** @name Arithmetic assignment operations on double words (binary).
2317 * @{ */
2318typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINU32, (uint32_t *pu32Dst, uint32_t u32Src, uint32_t *pEFlags));
2319typedef FNIEMAIMPLBINU32 *PFNIEMAIMPLBINU32;
2320FNIEMAIMPLBINU32 iemAImpl_add_u32, iemAImpl_add_u32_locked;
2321FNIEMAIMPLBINU32 iemAImpl_adc_u32, iemAImpl_adc_u32_locked;
2322FNIEMAIMPLBINU32 iemAImpl_sub_u32, iemAImpl_sub_u32_locked;
2323FNIEMAIMPLBINU32 iemAImpl_sbb_u32, iemAImpl_sbb_u32_locked;
2324FNIEMAIMPLBINU32 iemAImpl_or_u32, iemAImpl_or_u32_locked;
2325FNIEMAIMPLBINU32 iemAImpl_xor_u32, iemAImpl_xor_u32_locked;
2326FNIEMAIMPLBINU32 iemAImpl_and_u32, iemAImpl_and_u32_locked;
2327FNIEMAIMPLBINU32 iemAImpl_blsi_u32, iemAImpl_blsi_u32_fallback;
2328FNIEMAIMPLBINU32 iemAImpl_blsr_u32, iemAImpl_blsr_u32_fallback;
2329FNIEMAIMPLBINU32 iemAImpl_blsmsk_u32, iemAImpl_blsmsk_u32_fallback;
2330/** @} */
2331
2332/** @name Arithmetic assignment operations on quad words (binary).
2333 * @{ */
2334typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINU64, (uint64_t *pu64Dst, uint64_t u64Src, uint32_t *pEFlags));
2335typedef FNIEMAIMPLBINU64 *PFNIEMAIMPLBINU64;
2336FNIEMAIMPLBINU64 iemAImpl_add_u64, iemAImpl_add_u64_locked;
2337FNIEMAIMPLBINU64 iemAImpl_adc_u64, iemAImpl_adc_u64_locked;
2338FNIEMAIMPLBINU64 iemAImpl_sub_u64, iemAImpl_sub_u64_locked;
2339FNIEMAIMPLBINU64 iemAImpl_sbb_u64, iemAImpl_sbb_u64_locked;
2340FNIEMAIMPLBINU64 iemAImpl_or_u64, iemAImpl_or_u64_locked;
2341FNIEMAIMPLBINU64 iemAImpl_xor_u64, iemAImpl_xor_u64_locked;
2342FNIEMAIMPLBINU64 iemAImpl_and_u64, iemAImpl_and_u64_locked;
2343FNIEMAIMPLBINU64 iemAImpl_blsi_u64, iemAImpl_blsi_u64_fallback;
2344FNIEMAIMPLBINU64 iemAImpl_blsr_u64, iemAImpl_blsr_u64_fallback;
2345FNIEMAIMPLBINU64 iemAImpl_blsmsk_u64, iemAImpl_blsmsk_u64_fallback;
2346/** @} */
2347
2348typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINROU8,(uint8_t const *pu8Dst, uint8_t u8Src, uint32_t *pEFlags));
2349typedef FNIEMAIMPLBINROU8 *PFNIEMAIMPLBINROU8;
2350typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINROU16,(uint16_t const *pu16Dst, uint16_t u16Src, uint32_t *pEFlags));
2351typedef FNIEMAIMPLBINROU16 *PFNIEMAIMPLBINROU16;
2352typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINROU32,(uint32_t const *pu32Dst, uint32_t u32Src, uint32_t *pEFlags));
2353typedef FNIEMAIMPLBINROU32 *PFNIEMAIMPLBINROU32;
2354typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINROU64,(uint64_t const *pu64Dst, uint64_t u64Src, uint32_t *pEFlags));
2355typedef FNIEMAIMPLBINROU64 *PFNIEMAIMPLBINROU64;
2356
2357/** @name Compare operations (thrown in with the binary ops).
2358 * @{ */
2359FNIEMAIMPLBINROU8 iemAImpl_cmp_u8;
2360FNIEMAIMPLBINROU16 iemAImpl_cmp_u16;
2361FNIEMAIMPLBINROU32 iemAImpl_cmp_u32;
2362FNIEMAIMPLBINROU64 iemAImpl_cmp_u64;
2363/** @} */
2364
2365/** @name Test operations (thrown in with the binary ops).
2366 * @{ */
2367FNIEMAIMPLBINROU8 iemAImpl_test_u8;
2368FNIEMAIMPLBINROU16 iemAImpl_test_u16;
2369FNIEMAIMPLBINROU32 iemAImpl_test_u32;
2370FNIEMAIMPLBINROU64 iemAImpl_test_u64;
2371/** @} */
2372
2373/** @name Bit operations operations (thrown in with the binary ops).
2374 * @{ */
2375FNIEMAIMPLBINROU16 iemAImpl_bt_u16;
2376FNIEMAIMPLBINROU32 iemAImpl_bt_u32;
2377FNIEMAIMPLBINROU64 iemAImpl_bt_u64;
2378FNIEMAIMPLBINU16 iemAImpl_btc_u16, iemAImpl_btc_u16_locked;
2379FNIEMAIMPLBINU32 iemAImpl_btc_u32, iemAImpl_btc_u32_locked;
2380FNIEMAIMPLBINU64 iemAImpl_btc_u64, iemAImpl_btc_u64_locked;
2381FNIEMAIMPLBINU16 iemAImpl_btr_u16, iemAImpl_btr_u16_locked;
2382FNIEMAIMPLBINU32 iemAImpl_btr_u32, iemAImpl_btr_u32_locked;
2383FNIEMAIMPLBINU64 iemAImpl_btr_u64, iemAImpl_btr_u64_locked;
2384FNIEMAIMPLBINU16 iemAImpl_bts_u16, iemAImpl_bts_u16_locked;
2385FNIEMAIMPLBINU32 iemAImpl_bts_u32, iemAImpl_bts_u32_locked;
2386FNIEMAIMPLBINU64 iemAImpl_bts_u64, iemAImpl_bts_u64_locked;
2387/** @} */
2388
2389/** @name Arithmetic three operand operations on double words (binary).
2390 * @{ */
2391typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINVEXU32, (uint32_t *pu32Dst, uint32_t u32Src1, uint32_t u32Src2, uint32_t *pEFlags));
2392typedef FNIEMAIMPLBINVEXU32 *PFNIEMAIMPLBINVEXU32;
2393FNIEMAIMPLBINVEXU32 iemAImpl_andn_u32, iemAImpl_andn_u32_fallback;
2394FNIEMAIMPLBINVEXU32 iemAImpl_bextr_u32, iemAImpl_bextr_u32_fallback;
2395FNIEMAIMPLBINVEXU32 iemAImpl_bzhi_u32, iemAImpl_bzhi_u32_fallback;
2396/** @} */
2397
2398/** @name Arithmetic three operand operations on quad words (binary).
2399 * @{ */
2400typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINVEXU64, (uint64_t *pu64Dst, uint64_t u64Src1, uint64_t u64Src2, uint32_t *pEFlags));
2401typedef FNIEMAIMPLBINVEXU64 *PFNIEMAIMPLBINVEXU64;
2402FNIEMAIMPLBINVEXU64 iemAImpl_andn_u64, iemAImpl_andn_u64_fallback;
2403FNIEMAIMPLBINVEXU64 iemAImpl_bextr_u64, iemAImpl_bextr_u64_fallback;
2404FNIEMAIMPLBINVEXU64 iemAImpl_bzhi_u64, iemAImpl_bzhi_u64_fallback;
2405/** @} */
2406
2407/** @name Arithmetic three operand operations on double words w/o EFLAGS (binary).
2408 * @{ */
2409typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINVEXU32NOEFL, (uint32_t *pu32Dst, uint32_t u32Src1, uint32_t u32Src2));
2410typedef FNIEMAIMPLBINVEXU32NOEFL *PFNIEMAIMPLBINVEXU32NOEFL;
2411FNIEMAIMPLBINVEXU32NOEFL iemAImpl_pdep_u32, iemAImpl_pdep_u32_fallback;
2412FNIEMAIMPLBINVEXU32NOEFL iemAImpl_pext_u32, iemAImpl_pext_u32_fallback;
2413FNIEMAIMPLBINVEXU32NOEFL iemAImpl_sarx_u32, iemAImpl_sarx_u32_fallback;
2414FNIEMAIMPLBINVEXU32NOEFL iemAImpl_shlx_u32, iemAImpl_shlx_u32_fallback;
2415FNIEMAIMPLBINVEXU32NOEFL iemAImpl_shrx_u32, iemAImpl_shrx_u32_fallback;
2416FNIEMAIMPLBINVEXU32NOEFL iemAImpl_rorx_u32;
2417/** @} */
2418
2419/** @name Arithmetic three operand operations on quad words w/o EFLAGS (binary).
2420 * @{ */
2421typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINVEXU64NOEFL, (uint64_t *pu64Dst, uint64_t u64Src1, uint64_t u64Src2));
2422typedef FNIEMAIMPLBINVEXU64NOEFL *PFNIEMAIMPLBINVEXU64NOEFL;
2423FNIEMAIMPLBINVEXU64NOEFL iemAImpl_pdep_u64, iemAImpl_pdep_u64_fallback;
2424FNIEMAIMPLBINVEXU64NOEFL iemAImpl_pext_u64, iemAImpl_pext_u64_fallback;
2425FNIEMAIMPLBINVEXU64NOEFL iemAImpl_sarx_u64, iemAImpl_sarx_u64_fallback;
2426FNIEMAIMPLBINVEXU64NOEFL iemAImpl_shlx_u64, iemAImpl_shlx_u64_fallback;
2427FNIEMAIMPLBINVEXU64NOEFL iemAImpl_shrx_u64, iemAImpl_shrx_u64_fallback;
2428FNIEMAIMPLBINVEXU64NOEFL iemAImpl_rorx_u64;
2429/** @} */
2430
2431/** @name MULX 32-bit and 64-bit.
2432 * @{ */
2433typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMULXVEXU32, (uint32_t *puDst1, uint32_t *puDst2, uint32_t uSrc1, uint32_t uSrc2));
2434typedef FNIEMAIMPLMULXVEXU32 *PFNIEMAIMPLMULXVEXU32;
2435FNIEMAIMPLMULXVEXU32 iemAImpl_mulx_u32, iemAImpl_mulx_u32_fallback;
2436
2437typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMULXVEXU64, (uint64_t *puDst1, uint64_t *puDst2, uint64_t uSrc1, uint64_t uSrc2));
2438typedef FNIEMAIMPLMULXVEXU64 *PFNIEMAIMPLMULXVEXU64;
2439FNIEMAIMPLMULXVEXU64 iemAImpl_mulx_u64, iemAImpl_mulx_u64_fallback;
2440/** @} */
2441
2442
2443/** @name Exchange memory with register operations.
2444 * @{ */
2445IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u8_locked, (uint8_t *pu8Mem, uint8_t *pu8Reg));
2446IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u16_locked,(uint16_t *pu16Mem, uint16_t *pu16Reg));
2447IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u32_locked,(uint32_t *pu32Mem, uint32_t *pu32Reg));
2448IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u64_locked,(uint64_t *pu64Mem, uint64_t *pu64Reg));
2449IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u8_unlocked, (uint8_t *pu8Mem, uint8_t *pu8Reg));
2450IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u16_unlocked,(uint16_t *pu16Mem, uint16_t *pu16Reg));
2451IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u32_unlocked,(uint32_t *pu32Mem, uint32_t *pu32Reg));
2452IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u64_unlocked,(uint64_t *pu64Mem, uint64_t *pu64Reg));
2453/** @} */
2454
2455/** @name Exchange and add operations.
2456 * @{ */
2457IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u8, (uint8_t *pu8Dst, uint8_t *pu8Reg, uint32_t *pEFlags));
2458IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u16,(uint16_t *pu16Dst, uint16_t *pu16Reg, uint32_t *pEFlags));
2459IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u32,(uint32_t *pu32Dst, uint32_t *pu32Reg, uint32_t *pEFlags));
2460IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u64,(uint64_t *pu64Dst, uint64_t *pu64Reg, uint32_t *pEFlags));
2461IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u8_locked, (uint8_t *pu8Dst, uint8_t *pu8Reg, uint32_t *pEFlags));
2462IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u16_locked,(uint16_t *pu16Dst, uint16_t *pu16Reg, uint32_t *pEFlags));
2463IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u32_locked,(uint32_t *pu32Dst, uint32_t *pu32Reg, uint32_t *pEFlags));
2464IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u64_locked,(uint64_t *pu64Dst, uint64_t *pu64Reg, uint32_t *pEFlags));
2465/** @} */
2466
2467/** @name Compare and exchange.
2468 * @{ */
2469IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u8, (uint8_t *pu8Dst, uint8_t *puAl, uint8_t uSrcReg, uint32_t *pEFlags));
2470IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u8_locked, (uint8_t *pu8Dst, uint8_t *puAl, uint8_t uSrcReg, uint32_t *pEFlags));
2471IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u16, (uint16_t *pu16Dst, uint16_t *puAx, uint16_t uSrcReg, uint32_t *pEFlags));
2472IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u16_locked,(uint16_t *pu16Dst, uint16_t *puAx, uint16_t uSrcReg, uint32_t *pEFlags));
2473IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u32, (uint32_t *pu32Dst, uint32_t *puEax, uint32_t uSrcReg, uint32_t *pEFlags));
2474IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u32_locked,(uint32_t *pu32Dst, uint32_t *puEax, uint32_t uSrcReg, uint32_t *pEFlags));
2475#if ARCH_BITS == 32
2476IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u64, (uint64_t *pu64Dst, uint64_t *puRax, uint64_t *puSrcReg, uint32_t *pEFlags));
2477IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u64_locked,(uint64_t *pu64Dst, uint64_t *puRax, uint64_t *puSrcReg, uint32_t *pEFlags));
2478#else
2479IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u64, (uint64_t *pu64Dst, uint64_t *puRax, uint64_t uSrcReg, uint32_t *pEFlags));
2480IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u64_locked,(uint64_t *pu64Dst, uint64_t *puRax, uint64_t uSrcReg, uint32_t *pEFlags));
2481#endif
2482IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg8b,(uint64_t *pu64Dst, PRTUINT64U pu64EaxEdx, PRTUINT64U pu64EbxEcx,
2483 uint32_t *pEFlags));
2484IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg8b_locked,(uint64_t *pu64Dst, PRTUINT64U pu64EaxEdx, PRTUINT64U pu64EbxEcx,
2485 uint32_t *pEFlags));
2486IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg16b,(PRTUINT128U pu128Dst, PRTUINT128U pu128RaxRdx, PRTUINT128U pu128RbxRcx,
2487 uint32_t *pEFlags));
2488IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg16b_locked,(PRTUINT128U pu128Dst, PRTUINT128U pu128RaxRdx, PRTUINT128U pu128RbxRcx,
2489 uint32_t *pEFlags));
2490#ifndef RT_ARCH_ARM64
2491IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg16b_fallback,(PRTUINT128U pu128Dst, PRTUINT128U pu128RaxRdx,
2492 PRTUINT128U pu128RbxRcx, uint32_t *pEFlags));
2493#endif
2494/** @} */
2495
2496/** @name Memory ordering
2497 * @{ */
2498typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEMFENCE,(void));
2499typedef FNIEMAIMPLMEMFENCE *PFNIEMAIMPLMEMFENCE;
2500IEM_DECL_IMPL_DEF(void, iemAImpl_mfence,(void));
2501IEM_DECL_IMPL_DEF(void, iemAImpl_sfence,(void));
2502IEM_DECL_IMPL_DEF(void, iemAImpl_lfence,(void));
2503#ifndef RT_ARCH_ARM64
2504IEM_DECL_IMPL_DEF(void, iemAImpl_alt_mem_fence,(void));
2505#endif
2506/** @} */
2507
2508/** @name Double precision shifts
2509 * @{ */
2510typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTDBLU16,(uint16_t *pu16Dst, uint16_t u16Src, uint8_t cShift, uint32_t *pEFlags));
2511typedef FNIEMAIMPLSHIFTDBLU16 *PFNIEMAIMPLSHIFTDBLU16;
2512typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTDBLU32,(uint32_t *pu32Dst, uint32_t u32Src, uint8_t cShift, uint32_t *pEFlags));
2513typedef FNIEMAIMPLSHIFTDBLU32 *PFNIEMAIMPLSHIFTDBLU32;
2514typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTDBLU64,(uint64_t *pu64Dst, uint64_t u64Src, uint8_t cShift, uint32_t *pEFlags));
2515typedef FNIEMAIMPLSHIFTDBLU64 *PFNIEMAIMPLSHIFTDBLU64;
2516FNIEMAIMPLSHIFTDBLU16 iemAImpl_shld_u16, iemAImpl_shld_u16_amd, iemAImpl_shld_u16_intel;
2517FNIEMAIMPLSHIFTDBLU32 iemAImpl_shld_u32, iemAImpl_shld_u32_amd, iemAImpl_shld_u32_intel;
2518FNIEMAIMPLSHIFTDBLU64 iemAImpl_shld_u64, iemAImpl_shld_u64_amd, iemAImpl_shld_u64_intel;
2519FNIEMAIMPLSHIFTDBLU16 iemAImpl_shrd_u16, iemAImpl_shrd_u16_amd, iemAImpl_shrd_u16_intel;
2520FNIEMAIMPLSHIFTDBLU32 iemAImpl_shrd_u32, iemAImpl_shrd_u32_amd, iemAImpl_shrd_u32_intel;
2521FNIEMAIMPLSHIFTDBLU64 iemAImpl_shrd_u64, iemAImpl_shrd_u64_amd, iemAImpl_shrd_u64_intel;
2522/** @} */
2523
2524
2525/** @name Bit search operations (thrown in with the binary ops).
2526 * @{ */
2527FNIEMAIMPLBINU16 iemAImpl_bsf_u16, iemAImpl_bsf_u16_amd, iemAImpl_bsf_u16_intel;
2528FNIEMAIMPLBINU32 iemAImpl_bsf_u32, iemAImpl_bsf_u32_amd, iemAImpl_bsf_u32_intel;
2529FNIEMAIMPLBINU64 iemAImpl_bsf_u64, iemAImpl_bsf_u64_amd, iemAImpl_bsf_u64_intel;
2530FNIEMAIMPLBINU16 iemAImpl_bsr_u16, iemAImpl_bsr_u16_amd, iemAImpl_bsr_u16_intel;
2531FNIEMAIMPLBINU32 iemAImpl_bsr_u32, iemAImpl_bsr_u32_amd, iemAImpl_bsr_u32_intel;
2532FNIEMAIMPLBINU64 iemAImpl_bsr_u64, iemAImpl_bsr_u64_amd, iemAImpl_bsr_u64_intel;
2533FNIEMAIMPLBINU16 iemAImpl_lzcnt_u16, iemAImpl_lzcnt_u16_amd, iemAImpl_lzcnt_u16_intel;
2534FNIEMAIMPLBINU32 iemAImpl_lzcnt_u32, iemAImpl_lzcnt_u32_amd, iemAImpl_lzcnt_u32_intel;
2535FNIEMAIMPLBINU64 iemAImpl_lzcnt_u64, iemAImpl_lzcnt_u64_amd, iemAImpl_lzcnt_u64_intel;
2536FNIEMAIMPLBINU16 iemAImpl_tzcnt_u16, iemAImpl_tzcnt_u16_amd, iemAImpl_tzcnt_u16_intel;
2537FNIEMAIMPLBINU32 iemAImpl_tzcnt_u32, iemAImpl_tzcnt_u32_amd, iemAImpl_tzcnt_u32_intel;
2538FNIEMAIMPLBINU64 iemAImpl_tzcnt_u64, iemAImpl_tzcnt_u64_amd, iemAImpl_tzcnt_u64_intel;
2539FNIEMAIMPLBINU16 iemAImpl_popcnt_u16, iemAImpl_popcnt_u16_fallback;
2540FNIEMAIMPLBINU32 iemAImpl_popcnt_u32, iemAImpl_popcnt_u32_fallback;
2541FNIEMAIMPLBINU64 iemAImpl_popcnt_u64, iemAImpl_popcnt_u64_fallback;
2542/** @} */
2543
2544/** @name Signed multiplication operations (thrown in with the binary ops).
2545 * @{ */
2546FNIEMAIMPLBINU16 iemAImpl_imul_two_u16, iemAImpl_imul_two_u16_amd, iemAImpl_imul_two_u16_intel;
2547FNIEMAIMPLBINU32 iemAImpl_imul_two_u32, iemAImpl_imul_two_u32_amd, iemAImpl_imul_two_u32_intel;
2548FNIEMAIMPLBINU64 iemAImpl_imul_two_u64, iemAImpl_imul_two_u64_amd, iemAImpl_imul_two_u64_intel;
2549/** @} */
2550
2551/** @name Arithmetic assignment operations on bytes (unary).
2552 * @{ */
2553typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLUNARYU8, (uint8_t *pu8Dst, uint32_t *pEFlags));
2554typedef FNIEMAIMPLUNARYU8 *PFNIEMAIMPLUNARYU8;
2555FNIEMAIMPLUNARYU8 iemAImpl_inc_u8, iemAImpl_inc_u8_locked;
2556FNIEMAIMPLUNARYU8 iemAImpl_dec_u8, iemAImpl_dec_u8_locked;
2557FNIEMAIMPLUNARYU8 iemAImpl_not_u8, iemAImpl_not_u8_locked;
2558FNIEMAIMPLUNARYU8 iemAImpl_neg_u8, iemAImpl_neg_u8_locked;
2559/** @} */
2560
2561/** @name Arithmetic assignment operations on words (unary).
2562 * @{ */
2563typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLUNARYU16, (uint16_t *pu16Dst, uint32_t *pEFlags));
2564typedef FNIEMAIMPLUNARYU16 *PFNIEMAIMPLUNARYU16;
2565FNIEMAIMPLUNARYU16 iemAImpl_inc_u16, iemAImpl_inc_u16_locked;
2566FNIEMAIMPLUNARYU16 iemAImpl_dec_u16, iemAImpl_dec_u16_locked;
2567FNIEMAIMPLUNARYU16 iemAImpl_not_u16, iemAImpl_not_u16_locked;
2568FNIEMAIMPLUNARYU16 iemAImpl_neg_u16, iemAImpl_neg_u16_locked;
2569/** @} */
2570
2571/** @name Arithmetic assignment operations on double words (unary).
2572 * @{ */
2573typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLUNARYU32, (uint32_t *pu32Dst, uint32_t *pEFlags));
2574typedef FNIEMAIMPLUNARYU32 *PFNIEMAIMPLUNARYU32;
2575FNIEMAIMPLUNARYU32 iemAImpl_inc_u32, iemAImpl_inc_u32_locked;
2576FNIEMAIMPLUNARYU32 iemAImpl_dec_u32, iemAImpl_dec_u32_locked;
2577FNIEMAIMPLUNARYU32 iemAImpl_not_u32, iemAImpl_not_u32_locked;
2578FNIEMAIMPLUNARYU32 iemAImpl_neg_u32, iemAImpl_neg_u32_locked;
2579/** @} */
2580
2581/** @name Arithmetic assignment operations on quad words (unary).
2582 * @{ */
2583typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLUNARYU64, (uint64_t *pu64Dst, uint32_t *pEFlags));
2584typedef FNIEMAIMPLUNARYU64 *PFNIEMAIMPLUNARYU64;
2585FNIEMAIMPLUNARYU64 iemAImpl_inc_u64, iemAImpl_inc_u64_locked;
2586FNIEMAIMPLUNARYU64 iemAImpl_dec_u64, iemAImpl_dec_u64_locked;
2587FNIEMAIMPLUNARYU64 iemAImpl_not_u64, iemAImpl_not_u64_locked;
2588FNIEMAIMPLUNARYU64 iemAImpl_neg_u64, iemAImpl_neg_u64_locked;
2589/** @} */
2590
2591
2592/** @name Shift operations on bytes (Group 2).
2593 * @{ */
2594typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTU8,(uint8_t *pu8Dst, uint8_t cShift, uint32_t *pEFlags));
2595typedef FNIEMAIMPLSHIFTU8 *PFNIEMAIMPLSHIFTU8;
2596FNIEMAIMPLSHIFTU8 iemAImpl_rol_u8, iemAImpl_rol_u8_amd, iemAImpl_rol_u8_intel;
2597FNIEMAIMPLSHIFTU8 iemAImpl_ror_u8, iemAImpl_ror_u8_amd, iemAImpl_ror_u8_intel;
2598FNIEMAIMPLSHIFTU8 iemAImpl_rcl_u8, iemAImpl_rcl_u8_amd, iemAImpl_rcl_u8_intel;
2599FNIEMAIMPLSHIFTU8 iemAImpl_rcr_u8, iemAImpl_rcr_u8_amd, iemAImpl_rcr_u8_intel;
2600FNIEMAIMPLSHIFTU8 iemAImpl_shl_u8, iemAImpl_shl_u8_amd, iemAImpl_shl_u8_intel;
2601FNIEMAIMPLSHIFTU8 iemAImpl_shr_u8, iemAImpl_shr_u8_amd, iemAImpl_shr_u8_intel;
2602FNIEMAIMPLSHIFTU8 iemAImpl_sar_u8, iemAImpl_sar_u8_amd, iemAImpl_sar_u8_intel;
2603/** @} */
2604
2605/** @name Shift operations on words (Group 2).
2606 * @{ */
2607typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTU16,(uint16_t *pu16Dst, uint8_t cShift, uint32_t *pEFlags));
2608typedef FNIEMAIMPLSHIFTU16 *PFNIEMAIMPLSHIFTU16;
2609FNIEMAIMPLSHIFTU16 iemAImpl_rol_u16, iemAImpl_rol_u16_amd, iemAImpl_rol_u16_intel;
2610FNIEMAIMPLSHIFTU16 iemAImpl_ror_u16, iemAImpl_ror_u16_amd, iemAImpl_ror_u16_intel;
2611FNIEMAIMPLSHIFTU16 iemAImpl_rcl_u16, iemAImpl_rcl_u16_amd, iemAImpl_rcl_u16_intel;
2612FNIEMAIMPLSHIFTU16 iemAImpl_rcr_u16, iemAImpl_rcr_u16_amd, iemAImpl_rcr_u16_intel;
2613FNIEMAIMPLSHIFTU16 iemAImpl_shl_u16, iemAImpl_shl_u16_amd, iemAImpl_shl_u16_intel;
2614FNIEMAIMPLSHIFTU16 iemAImpl_shr_u16, iemAImpl_shr_u16_amd, iemAImpl_shr_u16_intel;
2615FNIEMAIMPLSHIFTU16 iemAImpl_sar_u16, iemAImpl_sar_u16_amd, iemAImpl_sar_u16_intel;
2616/** @} */
2617
2618/** @name Shift operations on double words (Group 2).
2619 * @{ */
2620typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTU32,(uint32_t *pu32Dst, uint8_t cShift, uint32_t *pEFlags));
2621typedef FNIEMAIMPLSHIFTU32 *PFNIEMAIMPLSHIFTU32;
2622FNIEMAIMPLSHIFTU32 iemAImpl_rol_u32, iemAImpl_rol_u32_amd, iemAImpl_rol_u32_intel;
2623FNIEMAIMPLSHIFTU32 iemAImpl_ror_u32, iemAImpl_ror_u32_amd, iemAImpl_ror_u32_intel;
2624FNIEMAIMPLSHIFTU32 iemAImpl_rcl_u32, iemAImpl_rcl_u32_amd, iemAImpl_rcl_u32_intel;
2625FNIEMAIMPLSHIFTU32 iemAImpl_rcr_u32, iemAImpl_rcr_u32_amd, iemAImpl_rcr_u32_intel;
2626FNIEMAIMPLSHIFTU32 iemAImpl_shl_u32, iemAImpl_shl_u32_amd, iemAImpl_shl_u32_intel;
2627FNIEMAIMPLSHIFTU32 iemAImpl_shr_u32, iemAImpl_shr_u32_amd, iemAImpl_shr_u32_intel;
2628FNIEMAIMPLSHIFTU32 iemAImpl_sar_u32, iemAImpl_sar_u32_amd, iemAImpl_sar_u32_intel;
2629/** @} */
2630
2631/** @name Shift operations on words (Group 2).
2632 * @{ */
2633typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTU64,(uint64_t *pu64Dst, uint8_t cShift, uint32_t *pEFlags));
2634typedef FNIEMAIMPLSHIFTU64 *PFNIEMAIMPLSHIFTU64;
2635FNIEMAIMPLSHIFTU64 iemAImpl_rol_u64, iemAImpl_rol_u64_amd, iemAImpl_rol_u64_intel;
2636FNIEMAIMPLSHIFTU64 iemAImpl_ror_u64, iemAImpl_ror_u64_amd, iemAImpl_ror_u64_intel;
2637FNIEMAIMPLSHIFTU64 iemAImpl_rcl_u64, iemAImpl_rcl_u64_amd, iemAImpl_rcl_u64_intel;
2638FNIEMAIMPLSHIFTU64 iemAImpl_rcr_u64, iemAImpl_rcr_u64_amd, iemAImpl_rcr_u64_intel;
2639FNIEMAIMPLSHIFTU64 iemAImpl_shl_u64, iemAImpl_shl_u64_amd, iemAImpl_shl_u64_intel;
2640FNIEMAIMPLSHIFTU64 iemAImpl_shr_u64, iemAImpl_shr_u64_amd, iemAImpl_shr_u64_intel;
2641FNIEMAIMPLSHIFTU64 iemAImpl_sar_u64, iemAImpl_sar_u64_amd, iemAImpl_sar_u64_intel;
2642/** @} */
2643
2644/** @name Multiplication and division operations.
2645 * @{ */
2646typedef IEM_DECL_IMPL_TYPE(int, FNIEMAIMPLMULDIVU8,(uint16_t *pu16AX, uint8_t u8FactorDivisor, uint32_t *pEFlags));
2647typedef FNIEMAIMPLMULDIVU8 *PFNIEMAIMPLMULDIVU8;
2648FNIEMAIMPLMULDIVU8 iemAImpl_mul_u8, iemAImpl_mul_u8_amd, iemAImpl_mul_u8_intel;
2649FNIEMAIMPLMULDIVU8 iemAImpl_imul_u8, iemAImpl_imul_u8_amd, iemAImpl_imul_u8_intel;
2650FNIEMAIMPLMULDIVU8 iemAImpl_div_u8, iemAImpl_div_u8_amd, iemAImpl_div_u8_intel;
2651FNIEMAIMPLMULDIVU8 iemAImpl_idiv_u8, iemAImpl_idiv_u8_amd, iemAImpl_idiv_u8_intel;
2652
2653typedef IEM_DECL_IMPL_TYPE(int, FNIEMAIMPLMULDIVU16,(uint16_t *pu16AX, uint16_t *pu16DX, uint16_t u16FactorDivisor, uint32_t *pEFlags));
2654typedef FNIEMAIMPLMULDIVU16 *PFNIEMAIMPLMULDIVU16;
2655FNIEMAIMPLMULDIVU16 iemAImpl_mul_u16, iemAImpl_mul_u16_amd, iemAImpl_mul_u16_intel;
2656FNIEMAIMPLMULDIVU16 iemAImpl_imul_u16, iemAImpl_imul_u16_amd, iemAImpl_imul_u16_intel;
2657FNIEMAIMPLMULDIVU16 iemAImpl_div_u16, iemAImpl_div_u16_amd, iemAImpl_div_u16_intel;
2658FNIEMAIMPLMULDIVU16 iemAImpl_idiv_u16, iemAImpl_idiv_u16_amd, iemAImpl_idiv_u16_intel;
2659
2660typedef IEM_DECL_IMPL_TYPE(int, FNIEMAIMPLMULDIVU32,(uint32_t *pu32EAX, uint32_t *pu32EDX, uint32_t u32FactorDivisor, uint32_t *pEFlags));
2661typedef FNIEMAIMPLMULDIVU32 *PFNIEMAIMPLMULDIVU32;
2662FNIEMAIMPLMULDIVU32 iemAImpl_mul_u32, iemAImpl_mul_u32_amd, iemAImpl_mul_u32_intel;
2663FNIEMAIMPLMULDIVU32 iemAImpl_imul_u32, iemAImpl_imul_u32_amd, iemAImpl_imul_u32_intel;
2664FNIEMAIMPLMULDIVU32 iemAImpl_div_u32, iemAImpl_div_u32_amd, iemAImpl_div_u32_intel;
2665FNIEMAIMPLMULDIVU32 iemAImpl_idiv_u32, iemAImpl_idiv_u32_amd, iemAImpl_idiv_u32_intel;
2666
2667typedef IEM_DECL_IMPL_TYPE(int, FNIEMAIMPLMULDIVU64,(uint64_t *pu64RAX, uint64_t *pu64RDX, uint64_t u64FactorDivisor, uint32_t *pEFlags));
2668typedef FNIEMAIMPLMULDIVU64 *PFNIEMAIMPLMULDIVU64;
2669FNIEMAIMPLMULDIVU64 iemAImpl_mul_u64, iemAImpl_mul_u64_amd, iemAImpl_mul_u64_intel;
2670FNIEMAIMPLMULDIVU64 iemAImpl_imul_u64, iemAImpl_imul_u64_amd, iemAImpl_imul_u64_intel;
2671FNIEMAIMPLMULDIVU64 iemAImpl_div_u64, iemAImpl_div_u64_amd, iemAImpl_div_u64_intel;
2672FNIEMAIMPLMULDIVU64 iemAImpl_idiv_u64, iemAImpl_idiv_u64_amd, iemAImpl_idiv_u64_intel;
2673/** @} */
2674
2675/** @name Byte Swap.
2676 * @{ */
2677IEM_DECL_IMPL_TYPE(void, iemAImpl_bswap_u16,(uint32_t *pu32Dst)); /* Yes, 32-bit register access. */
2678IEM_DECL_IMPL_TYPE(void, iemAImpl_bswap_u32,(uint32_t *pu32Dst));
2679IEM_DECL_IMPL_TYPE(void, iemAImpl_bswap_u64,(uint64_t *pu64Dst));
2680/** @} */
2681
2682/** @name Misc.
2683 * @{ */
2684FNIEMAIMPLBINU16 iemAImpl_arpl;
2685/** @} */
2686
2687/** @name RDRAND and RDSEED
2688 * @{ */
2689typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLRDRANDSEEDU16,(uint16_t *puDst, uint32_t *pEFlags));
2690typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLRDRANDSEEDU32,(uint32_t *puDst, uint32_t *pEFlags));
2691typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLRDRANDSEEDU64,(uint64_t *puDst, uint32_t *pEFlags));
2692typedef FNIEMAIMPLRDRANDSEEDU16 *PFNIEMAIMPLRDRANDSEEDU16;
2693typedef FNIEMAIMPLRDRANDSEEDU32 *PFNIEMAIMPLRDRANDSEEDU32;
2694typedef FNIEMAIMPLRDRANDSEEDU64 *PFNIEMAIMPLRDRANDSEEDU64;
2695
2696FNIEMAIMPLRDRANDSEEDU16 iemAImpl_rdrand_u16, iemAImpl_rdrand_u16_fallback;
2697FNIEMAIMPLRDRANDSEEDU32 iemAImpl_rdrand_u32, iemAImpl_rdrand_u32_fallback;
2698FNIEMAIMPLRDRANDSEEDU64 iemAImpl_rdrand_u64, iemAImpl_rdrand_u64_fallback;
2699FNIEMAIMPLRDRANDSEEDU16 iemAImpl_rdseed_u16, iemAImpl_rdseed_u16_fallback;
2700FNIEMAIMPLRDRANDSEEDU32 iemAImpl_rdseed_u32, iemAImpl_rdseed_u32_fallback;
2701FNIEMAIMPLRDRANDSEEDU64 iemAImpl_rdseed_u64, iemAImpl_rdseed_u64_fallback;
2702/** @} */
2703
2704/** @name ADOX and ADCX
2705 * @{ */
2706typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLADXU32,(uint32_t *puDst, uint32_t *pfEFlags, uint32_t uSrc));
2707typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLADXU64,(uint64_t *puDst, uint32_t *pfEFlags, uint64_t uSrc));
2708typedef FNIEMAIMPLADXU32 *PFNIEMAIMPLADXU32;
2709typedef FNIEMAIMPLADXU64 *PFNIEMAIMPLADXU64;
2710
2711FNIEMAIMPLADXU32 iemAImpl_adcx_u32, iemAImpl_adcx_u32_fallback;
2712FNIEMAIMPLADXU64 iemAImpl_adcx_u64, iemAImpl_adcx_u64_fallback;
2713FNIEMAIMPLADXU32 iemAImpl_adox_u32, iemAImpl_adox_u32_fallback;
2714FNIEMAIMPLADXU64 iemAImpl_adox_u64, iemAImpl_adox_u64_fallback;
2715/** @} */
2716
2717/** @name FPU operations taking a 32-bit float argument
2718 * @{ */
2719typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR32FSW,(PCX86FXSTATE pFpuState, uint16_t *pFSW,
2720 PCRTFLOAT80U pr80Val1, PCRTFLOAT32U pr32Val2));
2721typedef FNIEMAIMPLFPUR32FSW *PFNIEMAIMPLFPUR32FSW;
2722
2723typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR32,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
2724 PCRTFLOAT80U pr80Val1, PCRTFLOAT32U pr32Val2));
2725typedef FNIEMAIMPLFPUR32 *PFNIEMAIMPLFPUR32;
2726
2727FNIEMAIMPLFPUR32FSW iemAImpl_fcom_r80_by_r32;
2728FNIEMAIMPLFPUR32 iemAImpl_fadd_r80_by_r32;
2729FNIEMAIMPLFPUR32 iemAImpl_fmul_r80_by_r32;
2730FNIEMAIMPLFPUR32 iemAImpl_fsub_r80_by_r32;
2731FNIEMAIMPLFPUR32 iemAImpl_fsubr_r80_by_r32;
2732FNIEMAIMPLFPUR32 iemAImpl_fdiv_r80_by_r32;
2733FNIEMAIMPLFPUR32 iemAImpl_fdivr_r80_by_r32;
2734
2735IEM_DECL_IMPL_DEF(void, iemAImpl_fld_r80_from_r32,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, PCRTFLOAT32U pr32Val));
2736IEM_DECL_IMPL_DEF(void, iemAImpl_fst_r80_to_r32,(PCX86FXSTATE pFpuState, uint16_t *pu16FSW,
2737 PRTFLOAT32U pr32Val, PCRTFLOAT80U pr80Val));
2738/** @} */
2739
2740/** @name FPU operations taking a 64-bit float argument
2741 * @{ */
2742typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR64FSW,(PCX86FXSTATE pFpuState, uint16_t *pFSW,
2743 PCRTFLOAT80U pr80Val1, PCRTFLOAT64U pr64Val2));
2744typedef FNIEMAIMPLFPUR64FSW *PFNIEMAIMPLFPUR64FSW;
2745
2746typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR64,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
2747 PCRTFLOAT80U pr80Val1, PCRTFLOAT64U pr64Val2));
2748typedef FNIEMAIMPLFPUR64 *PFNIEMAIMPLFPUR64;
2749
2750FNIEMAIMPLFPUR64FSW iemAImpl_fcom_r80_by_r64;
2751FNIEMAIMPLFPUR64 iemAImpl_fadd_r80_by_r64;
2752FNIEMAIMPLFPUR64 iemAImpl_fmul_r80_by_r64;
2753FNIEMAIMPLFPUR64 iemAImpl_fsub_r80_by_r64;
2754FNIEMAIMPLFPUR64 iemAImpl_fsubr_r80_by_r64;
2755FNIEMAIMPLFPUR64 iemAImpl_fdiv_r80_by_r64;
2756FNIEMAIMPLFPUR64 iemAImpl_fdivr_r80_by_r64;
2757
2758IEM_DECL_IMPL_DEF(void, iemAImpl_fld_r80_from_r64,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, PCRTFLOAT64U pr64Val));
2759IEM_DECL_IMPL_DEF(void, iemAImpl_fst_r80_to_r64,(PCX86FXSTATE pFpuState, uint16_t *pu16FSW,
2760 PRTFLOAT64U pr32Val, PCRTFLOAT80U pr80Val));
2761/** @} */
2762
2763/** @name FPU operations taking a 80-bit float argument
2764 * @{ */
2765typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
2766 PCRTFLOAT80U pr80Val1, PCRTFLOAT80U pr80Val2));
2767typedef FNIEMAIMPLFPUR80 *PFNIEMAIMPLFPUR80;
2768FNIEMAIMPLFPUR80 iemAImpl_fadd_r80_by_r80;
2769FNIEMAIMPLFPUR80 iemAImpl_fmul_r80_by_r80;
2770FNIEMAIMPLFPUR80 iemAImpl_fsub_r80_by_r80;
2771FNIEMAIMPLFPUR80 iemAImpl_fsubr_r80_by_r80;
2772FNIEMAIMPLFPUR80 iemAImpl_fdiv_r80_by_r80;
2773FNIEMAIMPLFPUR80 iemAImpl_fdivr_r80_by_r80;
2774FNIEMAIMPLFPUR80 iemAImpl_fprem_r80_by_r80;
2775FNIEMAIMPLFPUR80 iemAImpl_fprem1_r80_by_r80;
2776FNIEMAIMPLFPUR80 iemAImpl_fscale_r80_by_r80;
2777
2778FNIEMAIMPLFPUR80 iemAImpl_fpatan_r80_by_r80, iemAImpl_fpatan_r80_by_r80_amd, iemAImpl_fpatan_r80_by_r80_intel;
2779FNIEMAIMPLFPUR80 iemAImpl_fyl2x_r80_by_r80, iemAImpl_fyl2x_r80_by_r80_amd, iemAImpl_fyl2x_r80_by_r80_intel;
2780FNIEMAIMPLFPUR80 iemAImpl_fyl2xp1_r80_by_r80, iemAImpl_fyl2xp1_r80_by_r80_amd, iemAImpl_fyl2xp1_r80_by_r80_intel;
2781
2782typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR80FSW,(PCX86FXSTATE pFpuState, uint16_t *pFSW,
2783 PCRTFLOAT80U pr80Val1, PCRTFLOAT80U pr80Val2));
2784typedef FNIEMAIMPLFPUR80FSW *PFNIEMAIMPLFPUR80FSW;
2785FNIEMAIMPLFPUR80FSW iemAImpl_fcom_r80_by_r80;
2786FNIEMAIMPLFPUR80FSW iemAImpl_fucom_r80_by_r80;
2787
2788typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLFPUR80EFL,(PCX86FXSTATE pFpuState, uint16_t *pu16Fsw,
2789 PCRTFLOAT80U pr80Val1, PCRTFLOAT80U pr80Val2));
2790typedef FNIEMAIMPLFPUR80EFL *PFNIEMAIMPLFPUR80EFL;
2791FNIEMAIMPLFPUR80EFL iemAImpl_fcomi_r80_by_r80;
2792FNIEMAIMPLFPUR80EFL iemAImpl_fucomi_r80_by_r80;
2793
2794typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR80UNARY,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, PCRTFLOAT80U pr80Val));
2795typedef FNIEMAIMPLFPUR80UNARY *PFNIEMAIMPLFPUR80UNARY;
2796FNIEMAIMPLFPUR80UNARY iemAImpl_fabs_r80;
2797FNIEMAIMPLFPUR80UNARY iemAImpl_fchs_r80;
2798FNIEMAIMPLFPUR80UNARY iemAImpl_f2xm1_r80, iemAImpl_f2xm1_r80_amd, iemAImpl_f2xm1_r80_intel;
2799FNIEMAIMPLFPUR80UNARY iemAImpl_fsqrt_r80;
2800FNIEMAIMPLFPUR80UNARY iemAImpl_frndint_r80;
2801FNIEMAIMPLFPUR80UNARY iemAImpl_fsin_r80, iemAImpl_fsin_r80_amd, iemAImpl_fsin_r80_intel;
2802FNIEMAIMPLFPUR80UNARY iemAImpl_fcos_r80, iemAImpl_fcos_r80_amd, iemAImpl_fcos_r80_intel;
2803
2804typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR80UNARYFSW,(PCX86FXSTATE pFpuState, uint16_t *pu16Fsw, PCRTFLOAT80U pr80Val));
2805typedef FNIEMAIMPLFPUR80UNARYFSW *PFNIEMAIMPLFPUR80UNARYFSW;
2806FNIEMAIMPLFPUR80UNARYFSW iemAImpl_ftst_r80;
2807FNIEMAIMPLFPUR80UNARYFSW iemAImpl_fxam_r80;
2808
2809typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR80LDCONST,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes));
2810typedef FNIEMAIMPLFPUR80LDCONST *PFNIEMAIMPLFPUR80LDCONST;
2811FNIEMAIMPLFPUR80LDCONST iemAImpl_fld1;
2812FNIEMAIMPLFPUR80LDCONST iemAImpl_fldl2t;
2813FNIEMAIMPLFPUR80LDCONST iemAImpl_fldl2e;
2814FNIEMAIMPLFPUR80LDCONST iemAImpl_fldpi;
2815FNIEMAIMPLFPUR80LDCONST iemAImpl_fldlg2;
2816FNIEMAIMPLFPUR80LDCONST iemAImpl_fldln2;
2817FNIEMAIMPLFPUR80LDCONST iemAImpl_fldz;
2818
2819typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR80UNARYTWO,(PCX86FXSTATE pFpuState, PIEMFPURESULTTWO pFpuResTwo,
2820 PCRTFLOAT80U pr80Val));
2821typedef FNIEMAIMPLFPUR80UNARYTWO *PFNIEMAIMPLFPUR80UNARYTWO;
2822FNIEMAIMPLFPUR80UNARYTWO iemAImpl_fptan_r80_r80, iemAImpl_fptan_r80_r80_amd, iemAImpl_fptan_r80_r80_intel;
2823FNIEMAIMPLFPUR80UNARYTWO iemAImpl_fxtract_r80_r80;
2824FNIEMAIMPLFPUR80UNARYTWO iemAImpl_fsincos_r80_r80, iemAImpl_fsincos_r80_r80_amd, iemAImpl_fsincos_r80_r80_intel;
2825
2826IEM_DECL_IMPL_DEF(void, iemAImpl_fld_r80_from_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, PCRTFLOAT80U pr80Val));
2827IEM_DECL_IMPL_DEF(void, iemAImpl_fst_r80_to_r80,(PCX86FXSTATE pFpuState, uint16_t *pu16FSW,
2828 PRTFLOAT80U pr80Dst, PCRTFLOAT80U pr80Src));
2829
2830IEM_DECL_IMPL_DEF(void, iemAImpl_fld_r80_from_d80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, PCRTPBCD80U pd80Val));
2831IEM_DECL_IMPL_DEF(void, iemAImpl_fst_r80_to_d80,(PCX86FXSTATE pFpuState, uint16_t *pu16FSW,
2832 PRTPBCD80U pd80Dst, PCRTFLOAT80U pr80Src));
2833
2834/** @} */
2835
2836/** @name FPU operations taking a 16-bit signed integer argument
2837 * @{ */
2838typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUI16,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
2839 PCRTFLOAT80U pr80Val1, int16_t const *pi16Val2));
2840typedef FNIEMAIMPLFPUI16 *PFNIEMAIMPLFPUI16;
2841typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUSTR80TOI16,(PCX86FXSTATE pFpuState, uint16_t *pFpuRes,
2842 int16_t *pi16Dst, PCRTFLOAT80U pr80Src));
2843typedef FNIEMAIMPLFPUSTR80TOI16 *PFNIEMAIMPLFPUSTR80TOI16;
2844
2845FNIEMAIMPLFPUI16 iemAImpl_fiadd_r80_by_i16;
2846FNIEMAIMPLFPUI16 iemAImpl_fimul_r80_by_i16;
2847FNIEMAIMPLFPUI16 iemAImpl_fisub_r80_by_i16;
2848FNIEMAIMPLFPUI16 iemAImpl_fisubr_r80_by_i16;
2849FNIEMAIMPLFPUI16 iemAImpl_fidiv_r80_by_i16;
2850FNIEMAIMPLFPUI16 iemAImpl_fidivr_r80_by_i16;
2851
2852typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUI16FSW,(PCX86FXSTATE pFpuState, uint16_t *pFSW,
2853 PCRTFLOAT80U pr80Val1, int16_t const *pi16Val2));
2854typedef FNIEMAIMPLFPUI16FSW *PFNIEMAIMPLFPUI16FSW;
2855FNIEMAIMPLFPUI16FSW iemAImpl_ficom_r80_by_i16;
2856
2857IEM_DECL_IMPL_DEF(void, iemAImpl_fild_r80_from_i16,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, int16_t const *pi16Val));
2858FNIEMAIMPLFPUSTR80TOI16 iemAImpl_fist_r80_to_i16;
2859FNIEMAIMPLFPUSTR80TOI16 iemAImpl_fistt_r80_to_i16, iemAImpl_fistt_r80_to_i16_amd, iemAImpl_fistt_r80_to_i16_intel;
2860/** @} */
2861
2862/** @name FPU operations taking a 32-bit signed integer argument
2863 * @{ */
2864typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUI32,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
2865 PCRTFLOAT80U pr80Val1, int32_t const *pi32Val2));
2866typedef FNIEMAIMPLFPUI32 *PFNIEMAIMPLFPUI32;
2867typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUSTR80TOI32,(PCX86FXSTATE pFpuState, uint16_t *pFpuRes,
2868 int32_t *pi32Dst, PCRTFLOAT80U pr80Src));
2869typedef FNIEMAIMPLFPUSTR80TOI32 *PFNIEMAIMPLFPUSTR80TOI32;
2870
2871FNIEMAIMPLFPUI32 iemAImpl_fiadd_r80_by_i32;
2872FNIEMAIMPLFPUI32 iemAImpl_fimul_r80_by_i32;
2873FNIEMAIMPLFPUI32 iemAImpl_fisub_r80_by_i32;
2874FNIEMAIMPLFPUI32 iemAImpl_fisubr_r80_by_i32;
2875FNIEMAIMPLFPUI32 iemAImpl_fidiv_r80_by_i32;
2876FNIEMAIMPLFPUI32 iemAImpl_fidivr_r80_by_i32;
2877
2878typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUI32FSW,(PCX86FXSTATE pFpuState, uint16_t *pFSW,
2879 PCRTFLOAT80U pr80Val1, int32_t const *pi32Val2));
2880typedef FNIEMAIMPLFPUI32FSW *PFNIEMAIMPLFPUI32FSW;
2881FNIEMAIMPLFPUI32FSW iemAImpl_ficom_r80_by_i32;
2882
2883IEM_DECL_IMPL_DEF(void, iemAImpl_fild_r80_from_i32,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, int32_t const *pi32Val));
2884FNIEMAIMPLFPUSTR80TOI32 iemAImpl_fist_r80_to_i32;
2885FNIEMAIMPLFPUSTR80TOI32 iemAImpl_fistt_r80_to_i32;
2886/** @} */
2887
2888/** @name FPU operations taking a 64-bit signed integer argument
2889 * @{ */
2890typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUSTR80TOI64,(PCX86FXSTATE pFpuState, uint16_t *pFpuRes,
2891 int64_t *pi64Dst, PCRTFLOAT80U pr80Src));
2892typedef FNIEMAIMPLFPUSTR80TOI64 *PFNIEMAIMPLFPUSTR80TOI64;
2893
2894IEM_DECL_IMPL_DEF(void, iemAImpl_fild_r80_from_i64,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, int64_t const *pi64Val));
2895FNIEMAIMPLFPUSTR80TOI64 iemAImpl_fist_r80_to_i64;
2896FNIEMAIMPLFPUSTR80TOI64 iemAImpl_fistt_r80_to_i64;
2897/** @} */
2898
2899
2900/** Temporary type representing a 256-bit vector register. */
2901typedef struct { uint64_t au64[4]; } IEMVMM256;
2902/** Temporary type pointing to a 256-bit vector register. */
2903typedef IEMVMM256 *PIEMVMM256;
2904/** Temporary type pointing to a const 256-bit vector register. */
2905typedef IEMVMM256 *PCIEMVMM256;
2906
2907
2908/** @name Media (SSE/MMX/AVX) operations: full1 + full2 -> full1.
2909 * @{ */
2910typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAF2U64,(PCX86FXSTATE pFpuState, uint64_t *puDst, uint64_t const *puSrc));
2911typedef FNIEMAIMPLMEDIAF2U64 *PFNIEMAIMPLMEDIAF2U64;
2912typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAF2U128,(PCX86FXSTATE pFpuState, PRTUINT128U puDst, PCRTUINT128U puSrc));
2913typedef FNIEMAIMPLMEDIAF2U128 *PFNIEMAIMPLMEDIAF2U128;
2914typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAF3U128,(PX86XSAVEAREA pExtState, PRTUINT128U puDst, PCRTUINT128U puSrc1, PCRTUINT128U puSrc2));
2915typedef FNIEMAIMPLMEDIAF3U128 *PFNIEMAIMPLMEDIAF3U128;
2916typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAF3U256,(PX86XSAVEAREA pExtState, PRTUINT256U puDst, PCRTUINT256U puSrc1, PCRTUINT256U puSrc2));
2917typedef FNIEMAIMPLMEDIAF3U256 *PFNIEMAIMPLMEDIAF3U256;
2918typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAOPTF2U64,(uint64_t *puDst, uint64_t const *puSrc));
2919typedef FNIEMAIMPLMEDIAOPTF2U64 *PFNIEMAIMPLMEDIAOPTF2U64;
2920typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAOPTF2U128,(PRTUINT128U puDst, PCRTUINT128U puSrc));
2921typedef FNIEMAIMPLMEDIAOPTF2U128 *PFNIEMAIMPLMEDIAOPTF2U128;
2922typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAOPTF3U128,(PRTUINT128U puDst, PCRTUINT128U puSrc1, PCRTUINT128U puSrc2));
2923typedef FNIEMAIMPLMEDIAOPTF3U128 *PFNIEMAIMPLMEDIAOPTF3U128;
2924typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAOPTF3U256,(PRTUINT256U puDst, PCRTUINT256U puSrc1, PCRTUINT256U puSrc2));
2925typedef FNIEMAIMPLMEDIAOPTF3U256 *PFNIEMAIMPLMEDIAOPTF3U256;
2926typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAOPTF2U256,(PRTUINT256U puDst, PCRTUINT256U puSrc));
2927typedef FNIEMAIMPLMEDIAOPTF2U256 *PFNIEMAIMPLMEDIAOPTF2U256;
2928FNIEMAIMPLMEDIAF2U64 iemAImpl_pshufb_u64, iemAImpl_pshufb_u64_fallback;
2929FNIEMAIMPLMEDIAF2U64 iemAImpl_pand_u64, iemAImpl_pandn_u64, iemAImpl_por_u64, iemAImpl_pxor_u64;
2930FNIEMAIMPLMEDIAF2U64 iemAImpl_pcmpeqb_u64, iemAImpl_pcmpeqw_u64, iemAImpl_pcmpeqd_u64;
2931FNIEMAIMPLMEDIAF2U64 iemAImpl_pcmpgtb_u64, iemAImpl_pcmpgtw_u64, iemAImpl_pcmpgtd_u64;
2932FNIEMAIMPLMEDIAF2U64 iemAImpl_paddb_u64, iemAImpl_paddsb_u64, iemAImpl_paddusb_u64;
2933FNIEMAIMPLMEDIAF2U64 iemAImpl_paddw_u64, iemAImpl_paddsw_u64, iemAImpl_paddusw_u64;
2934FNIEMAIMPLMEDIAF2U64 iemAImpl_paddd_u64;
2935FNIEMAIMPLMEDIAF2U64 iemAImpl_paddq_u64;
2936FNIEMAIMPLMEDIAF2U64 iemAImpl_psubb_u64, iemAImpl_psubsb_u64, iemAImpl_psubusb_u64;
2937FNIEMAIMPLMEDIAF2U64 iemAImpl_psubw_u64, iemAImpl_psubsw_u64, iemAImpl_psubusw_u64;
2938FNIEMAIMPLMEDIAF2U64 iemAImpl_psubd_u64;
2939FNIEMAIMPLMEDIAF2U64 iemAImpl_psubq_u64;
2940FNIEMAIMPLMEDIAF2U64 iemAImpl_pmaddwd_u64;
2941FNIEMAIMPLMEDIAF2U64 iemAImpl_pmullw_u64, iemAImpl_pmulhw_u64;
2942FNIEMAIMPLMEDIAF2U64 iemAImpl_pminub_u64, iemAImpl_pmaxub_u64;
2943FNIEMAIMPLMEDIAF2U64 iemAImpl_pminsw_u64, iemAImpl_pmaxsw_u64;
2944FNIEMAIMPLMEDIAF2U64 iemAImpl_pabsb_u64, iemAImpl_pabsb_u64_fallback;
2945FNIEMAIMPLMEDIAF2U64 iemAImpl_pabsw_u64, iemAImpl_pabsw_u64_fallback;
2946FNIEMAIMPLMEDIAF2U64 iemAImpl_pabsd_u64, iemAImpl_pabsd_u64_fallback;
2947FNIEMAIMPLMEDIAF2U64 iemAImpl_psignb_u64, iemAImpl_psignb_u64_fallback;
2948FNIEMAIMPLMEDIAF2U64 iemAImpl_psignw_u64, iemAImpl_psignw_u64_fallback;
2949FNIEMAIMPLMEDIAF2U64 iemAImpl_psignd_u64, iemAImpl_psignd_u64_fallback;
2950FNIEMAIMPLMEDIAF2U64 iemAImpl_phaddw_u64, iemAImpl_phaddw_u64_fallback;
2951FNIEMAIMPLMEDIAF2U64 iemAImpl_phaddd_u64, iemAImpl_phaddd_u64_fallback;
2952FNIEMAIMPLMEDIAF2U64 iemAImpl_phsubw_u64, iemAImpl_phsubw_u64_fallback;
2953FNIEMAIMPLMEDIAF2U64 iemAImpl_phsubd_u64, iemAImpl_phsubd_u64_fallback;
2954FNIEMAIMPLMEDIAF2U64 iemAImpl_phaddsw_u64, iemAImpl_phaddsw_u64_fallback;
2955FNIEMAIMPLMEDIAF2U64 iemAImpl_phsubsw_u64, iemAImpl_phsubsw_u64_fallback;
2956FNIEMAIMPLMEDIAF2U64 iemAImpl_pmaddubsw_u64, iemAImpl_pmaddubsw_u64_fallback;
2957FNIEMAIMPLMEDIAF2U64 iemAImpl_pmulhrsw_u64, iemAImpl_pmulhrsw_u64_fallback;
2958FNIEMAIMPLMEDIAF2U64 iemAImpl_pmuludq_u64;
2959FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_psllw_u64, iemAImpl_psrlw_u64, iemAImpl_psraw_u64;
2960FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_pslld_u64, iemAImpl_psrld_u64, iemAImpl_psrad_u64;
2961FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_psllq_u64, iemAImpl_psrlq_u64;
2962FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_packsswb_u64, iemAImpl_packuswb_u64;
2963FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_packssdw_u64;
2964FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_pmulhuw_u64;
2965FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_pavgb_u64, iemAImpl_pavgw_u64;
2966FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_psadbw_u64;
2967
2968FNIEMAIMPLMEDIAF2U128 iemAImpl_pshufb_u128, iemAImpl_pshufb_u128_fallback;
2969FNIEMAIMPLMEDIAF2U128 iemAImpl_pand_u128, iemAImpl_pandn_u128, iemAImpl_por_u128, iemAImpl_pxor_u128;
2970FNIEMAIMPLMEDIAF2U128 iemAImpl_pcmpeqb_u128, iemAImpl_pcmpeqw_u128, iemAImpl_pcmpeqd_u128;
2971FNIEMAIMPLMEDIAF2U128 iemAImpl_pcmpeqq_u128, iemAImpl_pcmpeqq_u128_fallback;
2972FNIEMAIMPLMEDIAF2U128 iemAImpl_pcmpgtb_u128, iemAImpl_pcmpgtw_u128, iemAImpl_pcmpgtd_u128;
2973FNIEMAIMPLMEDIAF2U128 iemAImpl_pcmpgtq_u128, iemAImpl_pcmpgtq_u128_fallback;
2974FNIEMAIMPLMEDIAF2U128 iemAImpl_paddb_u128, iemAImpl_paddsb_u128, iemAImpl_paddusb_u128;
2975FNIEMAIMPLMEDIAF2U128 iemAImpl_paddw_u128, iemAImpl_paddsw_u128, iemAImpl_paddusw_u128;
2976FNIEMAIMPLMEDIAF2U128 iemAImpl_paddd_u128;
2977FNIEMAIMPLMEDIAF2U128 iemAImpl_paddq_u128;
2978FNIEMAIMPLMEDIAF2U128 iemAImpl_psubb_u128, iemAImpl_psubsb_u128, iemAImpl_psubusb_u128;
2979FNIEMAIMPLMEDIAF2U128 iemAImpl_psubw_u128, iemAImpl_psubsw_u128, iemAImpl_psubusw_u128;
2980FNIEMAIMPLMEDIAF2U128 iemAImpl_psubd_u128;
2981FNIEMAIMPLMEDIAF2U128 iemAImpl_psubq_u128;
2982FNIEMAIMPLMEDIAF2U128 iemAImpl_pmullw_u128, iemAImpl_pmullw_u128_fallback;
2983FNIEMAIMPLMEDIAF2U128 iemAImpl_pmulhw_u128;
2984FNIEMAIMPLMEDIAF2U128 iemAImpl_pmulld_u128, iemAImpl_pmulld_u128_fallback;
2985FNIEMAIMPLMEDIAF2U128 iemAImpl_pmaddwd_u128;
2986FNIEMAIMPLMEDIAF2U128 iemAImpl_pminub_u128;
2987FNIEMAIMPLMEDIAF2U128 iemAImpl_pminud_u128, iemAImpl_pminud_u128_fallback;
2988FNIEMAIMPLMEDIAF2U128 iemAImpl_pminuw_u128, iemAImpl_pminuw_u128_fallback;
2989FNIEMAIMPLMEDIAF2U128 iemAImpl_pminsb_u128, iemAImpl_pminsb_u128_fallback;
2990FNIEMAIMPLMEDIAF2U128 iemAImpl_pminsd_u128, iemAImpl_pminsd_u128_fallback;
2991FNIEMAIMPLMEDIAF2U128 iemAImpl_pminsw_u128, iemAImpl_pminsw_u128_fallback;
2992FNIEMAIMPLMEDIAF2U128 iemAImpl_pmaxub_u128;
2993FNIEMAIMPLMEDIAF2U128 iemAImpl_pmaxud_u128, iemAImpl_pmaxud_u128_fallback;
2994FNIEMAIMPLMEDIAF2U128 iemAImpl_pmaxuw_u128, iemAImpl_pmaxuw_u128_fallback;
2995FNIEMAIMPLMEDIAF2U128 iemAImpl_pmaxsb_u128, iemAImpl_pmaxsb_u128_fallback;
2996FNIEMAIMPLMEDIAF2U128 iemAImpl_pmaxsw_u128;
2997FNIEMAIMPLMEDIAF2U128 iemAImpl_pmaxsd_u128, iemAImpl_pmaxsd_u128_fallback;
2998FNIEMAIMPLMEDIAF2U128 iemAImpl_pabsb_u128, iemAImpl_pabsb_u128_fallback;
2999FNIEMAIMPLMEDIAF2U128 iemAImpl_pabsw_u128, iemAImpl_pabsw_u128_fallback;
3000FNIEMAIMPLMEDIAF2U128 iemAImpl_pabsd_u128, iemAImpl_pabsd_u128_fallback;
3001FNIEMAIMPLMEDIAF2U128 iemAImpl_psignb_u128, iemAImpl_psignb_u128_fallback;
3002FNIEMAIMPLMEDIAF2U128 iemAImpl_psignw_u128, iemAImpl_psignw_u128_fallback;
3003FNIEMAIMPLMEDIAF2U128 iemAImpl_psignd_u128, iemAImpl_psignd_u128_fallback;
3004FNIEMAIMPLMEDIAF2U128 iemAImpl_phaddw_u128, iemAImpl_phaddw_u128_fallback;
3005FNIEMAIMPLMEDIAF2U128 iemAImpl_phaddd_u128, iemAImpl_phaddd_u128_fallback;
3006FNIEMAIMPLMEDIAF2U128 iemAImpl_phsubw_u128, iemAImpl_phsubw_u128_fallback;
3007FNIEMAIMPLMEDIAF2U128 iemAImpl_phsubd_u128, iemAImpl_phsubd_u128_fallback;
3008FNIEMAIMPLMEDIAF2U128 iemAImpl_phaddsw_u128, iemAImpl_phaddsw_u128_fallback;
3009FNIEMAIMPLMEDIAF2U128 iemAImpl_phsubsw_u128, iemAImpl_phsubsw_u128_fallback;
3010FNIEMAIMPLMEDIAF2U128 iemAImpl_pmaddubsw_u128, iemAImpl_pmaddubsw_u128_fallback;
3011FNIEMAIMPLMEDIAF2U128 iemAImpl_pmulhrsw_u128, iemAImpl_pmulhrsw_u128_fallback;
3012FNIEMAIMPLMEDIAF2U128 iemAImpl_pmuludq_u128;
3013FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_packsswb_u128, iemAImpl_packuswb_u128;
3014FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_packssdw_u128, iemAImpl_packusdw_u128;
3015FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_psllw_u128, iemAImpl_psrlw_u128, iemAImpl_psraw_u128;
3016FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pslld_u128, iemAImpl_psrld_u128, iemAImpl_psrad_u128;
3017FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_psllq_u128, iemAImpl_psrlq_u128;
3018FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pmulhuw_u128;
3019FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pavgb_u128, iemAImpl_pavgw_u128;
3020FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_psadbw_u128;
3021FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pmuldq_u128, iemAImpl_pmuldq_u128_fallback;
3022FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_unpcklps_u128, iemAImpl_unpcklpd_u128;
3023FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_unpckhps_u128, iemAImpl_unpckhpd_u128;
3024FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_phminposuw_u128, iemAImpl_phminposuw_u128_fallback;
3025
3026FNIEMAIMPLMEDIAF3U128 iemAImpl_vpshufb_u128, iemAImpl_vpshufb_u128_fallback;
3027FNIEMAIMPLMEDIAF3U128 iemAImpl_vpand_u128, iemAImpl_vpand_u128_fallback;
3028FNIEMAIMPLMEDIAF3U128 iemAImpl_vpandn_u128, iemAImpl_vpandn_u128_fallback;
3029FNIEMAIMPLMEDIAF3U128 iemAImpl_vpor_u128, iemAImpl_vpor_u128_fallback;
3030FNIEMAIMPLMEDIAF3U128 iemAImpl_vpxor_u128, iemAImpl_vpxor_u128_fallback;
3031FNIEMAIMPLMEDIAF3U128 iemAImpl_vpcmpeqb_u128, iemAImpl_vpcmpeqb_u128_fallback;
3032FNIEMAIMPLMEDIAF3U128 iemAImpl_vpcmpeqw_u128, iemAImpl_vpcmpeqw_u128_fallback;
3033FNIEMAIMPLMEDIAF3U128 iemAImpl_vpcmpeqd_u128, iemAImpl_vpcmpeqd_u128_fallback;
3034FNIEMAIMPLMEDIAF3U128 iemAImpl_vpcmpeqq_u128, iemAImpl_vpcmpeqq_u128_fallback;
3035FNIEMAIMPLMEDIAF3U128 iemAImpl_vpcmpgtb_u128, iemAImpl_vpcmpgtb_u128_fallback;
3036FNIEMAIMPLMEDIAF3U128 iemAImpl_vpcmpgtw_u128, iemAImpl_vpcmpgtw_u128_fallback;
3037FNIEMAIMPLMEDIAF3U128 iemAImpl_vpcmpgtd_u128, iemAImpl_vpcmpgtd_u128_fallback;
3038FNIEMAIMPLMEDIAF3U128 iemAImpl_vpcmpgtq_u128, iemAImpl_vpcmpgtq_u128_fallback;
3039FNIEMAIMPLMEDIAF3U128 iemAImpl_vpaddb_u128, iemAImpl_vpaddb_u128_fallback;
3040FNIEMAIMPLMEDIAF3U128 iemAImpl_vpaddw_u128, iemAImpl_vpaddw_u128_fallback;
3041FNIEMAIMPLMEDIAF3U128 iemAImpl_vpaddd_u128, iemAImpl_vpaddd_u128_fallback;
3042FNIEMAIMPLMEDIAF3U128 iemAImpl_vpaddq_u128, iemAImpl_vpaddq_u128_fallback;
3043FNIEMAIMPLMEDIAF3U128 iemAImpl_vpsubb_u128, iemAImpl_vpsubb_u128_fallback;
3044FNIEMAIMPLMEDIAF3U128 iemAImpl_vpsubw_u128, iemAImpl_vpsubw_u128_fallback;
3045FNIEMAIMPLMEDIAF3U128 iemAImpl_vpsubd_u128, iemAImpl_vpsubd_u128_fallback;
3046FNIEMAIMPLMEDIAF3U128 iemAImpl_vpsubq_u128, iemAImpl_vpsubq_u128_fallback;
3047FNIEMAIMPLMEDIAF3U128 iemAImpl_vpminub_u128, iemAImpl_vpminub_u128_fallback;
3048FNIEMAIMPLMEDIAF3U128 iemAImpl_vpminuw_u128, iemAImpl_vpminuw_u128_fallback;
3049FNIEMAIMPLMEDIAF3U128 iemAImpl_vpminud_u128, iemAImpl_vpminud_u128_fallback;
3050FNIEMAIMPLMEDIAF3U128 iemAImpl_vpminsb_u128, iemAImpl_vpminsb_u128_fallback;
3051FNIEMAIMPLMEDIAF3U128 iemAImpl_vpminsw_u128, iemAImpl_vpminsw_u128_fallback;
3052FNIEMAIMPLMEDIAF3U128 iemAImpl_vpminsd_u128, iemAImpl_vpminsd_u128_fallback;
3053FNIEMAIMPLMEDIAF3U128 iemAImpl_vpmaxub_u128, iemAImpl_vpmaxub_u128_fallback;
3054FNIEMAIMPLMEDIAF3U128 iemAImpl_vpmaxuw_u128, iemAImpl_vpmaxuw_u128_fallback;
3055FNIEMAIMPLMEDIAF3U128 iemAImpl_vpmaxud_u128, iemAImpl_vpmaxud_u128_fallback;
3056FNIEMAIMPLMEDIAF3U128 iemAImpl_vpmaxsb_u128, iemAImpl_vpmaxsb_u128_fallback;
3057FNIEMAIMPLMEDIAF3U128 iemAImpl_vpmaxsw_u128, iemAImpl_vpmaxsw_u128_fallback;
3058FNIEMAIMPLMEDIAF3U128 iemAImpl_vpmaxsd_u128, iemAImpl_vpmaxsd_u128_fallback;
3059FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpacksswb_u128, iemAImpl_vpacksswb_u128_fallback;
3060FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpackssdw_u128, iemAImpl_vpackssdw_u128_fallback;
3061FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpackuswb_u128, iemAImpl_vpackuswb_u128_fallback;
3062FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpackusdw_u128, iemAImpl_vpackusdw_u128_fallback;
3063FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmullw_u128, iemAImpl_vpmullw_u128_fallback;
3064FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmulld_u128, iemAImpl_vpmulld_u128_fallback;
3065FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmulhw_u128, iemAImpl_vpmulhw_u128_fallback;
3066FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmulhuw_u128, iemAImpl_vpmulhuw_u128_fallback;
3067FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpavgb_u128, iemAImpl_vpavgb_u128_fallback;
3068FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpavgw_u128, iemAImpl_vpavgw_u128_fallback;
3069FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsignb_u128, iemAImpl_vpsignb_u128_fallback;
3070FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsignw_u128, iemAImpl_vpsignw_u128_fallback;
3071FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsignd_u128, iemAImpl_vpsignd_u128_fallback;
3072FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vphaddw_u128, iemAImpl_vphaddw_u128_fallback;
3073FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vphaddd_u128, iemAImpl_vphaddd_u128_fallback;
3074FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vphsubw_u128, iemAImpl_vphsubw_u128_fallback;
3075FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vphsubd_u128, iemAImpl_vphsubd_u128_fallback;
3076FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vphaddsw_u128, iemAImpl_vphaddsw_u128_fallback;
3077FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vphsubsw_u128, iemAImpl_vphsubsw_u128_fallback;
3078FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmaddubsw_u128, iemAImpl_vpmaddubsw_u128_fallback;
3079FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmulhrsw_u128, iemAImpl_vpmulhrsw_u128_fallback;
3080FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsadbw_u128, iemAImpl_vpsadbw_u128_fallback;
3081FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmuldq_u128, iemAImpl_vpmuldq_u128_fallback;
3082FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmuludq_u128, iemAImpl_vpmuludq_u128_fallback;
3083FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsubsb_u128, iemAImpl_vpsubsb_u128_fallback;
3084FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsubsw_u128, iemAImpl_vpsubsw_u128_fallback;
3085FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsubusb_u128, iemAImpl_vpsubusb_u128_fallback;
3086FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsubusw_u128, iemAImpl_vpsubusw_u128_fallback;
3087FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpaddusb_u128, iemAImpl_vpaddusb_u128_fallback;
3088FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpaddusw_u128, iemAImpl_vpaddusw_u128_fallback;
3089FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpaddsb_u128, iemAImpl_vpaddsb_u128_fallback;
3090FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpaddsw_u128, iemAImpl_vpaddsw_u128_fallback;
3091
3092FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_vpabsb_u128, iemAImpl_vpabsb_u128_fallback;
3093FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_vpabsw_u128, iemAImpl_vpabsd_u128_fallback;
3094FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_vpabsd_u128, iemAImpl_vpabsw_u128_fallback;
3095FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_vphminposuw_u128, iemAImpl_vphminposuw_u128_fallback;
3096
3097FNIEMAIMPLMEDIAF3U256 iemAImpl_vpshufb_u256, iemAImpl_vpshufb_u256_fallback;
3098FNIEMAIMPLMEDIAF3U256 iemAImpl_vpand_u256, iemAImpl_vpand_u256_fallback;
3099FNIEMAIMPLMEDIAF3U256 iemAImpl_vpandn_u256, iemAImpl_vpandn_u256_fallback;
3100FNIEMAIMPLMEDIAF3U256 iemAImpl_vpor_u256, iemAImpl_vpor_u256_fallback;
3101FNIEMAIMPLMEDIAF3U256 iemAImpl_vpxor_u256, iemAImpl_vpxor_u256_fallback;
3102FNIEMAIMPLMEDIAF3U256 iemAImpl_vpcmpeqb_u256, iemAImpl_vpcmpeqb_u256_fallback;
3103FNIEMAIMPLMEDIAF3U256 iemAImpl_vpcmpeqw_u256, iemAImpl_vpcmpeqw_u256_fallback;
3104FNIEMAIMPLMEDIAF3U256 iemAImpl_vpcmpeqd_u256, iemAImpl_vpcmpeqd_u256_fallback;
3105FNIEMAIMPLMEDIAF3U256 iemAImpl_vpcmpeqq_u256, iemAImpl_vpcmpeqq_u256_fallback;
3106FNIEMAIMPLMEDIAF3U256 iemAImpl_vpcmpgtb_u256, iemAImpl_vpcmpgtb_u256_fallback;
3107FNIEMAIMPLMEDIAF3U256 iemAImpl_vpcmpgtw_u256, iemAImpl_vpcmpgtw_u256_fallback;
3108FNIEMAIMPLMEDIAF3U256 iemAImpl_vpcmpgtd_u256, iemAImpl_vpcmpgtd_u256_fallback;
3109FNIEMAIMPLMEDIAF3U256 iemAImpl_vpcmpgtq_u256, iemAImpl_vpcmpgtq_u256_fallback;
3110FNIEMAIMPLMEDIAF3U256 iemAImpl_vpaddb_u256, iemAImpl_vpaddb_u256_fallback;
3111FNIEMAIMPLMEDIAF3U256 iemAImpl_vpaddw_u256, iemAImpl_vpaddw_u256_fallback;
3112FNIEMAIMPLMEDIAF3U256 iemAImpl_vpaddd_u256, iemAImpl_vpaddd_u256_fallback;
3113FNIEMAIMPLMEDIAF3U256 iemAImpl_vpaddq_u256, iemAImpl_vpaddq_u256_fallback;
3114FNIEMAIMPLMEDIAF3U256 iemAImpl_vpsubb_u256, iemAImpl_vpsubb_u256_fallback;
3115FNIEMAIMPLMEDIAF3U256 iemAImpl_vpsubw_u256, iemAImpl_vpsubw_u256_fallback;
3116FNIEMAIMPLMEDIAF3U256 iemAImpl_vpsubd_u256, iemAImpl_vpsubd_u256_fallback;
3117FNIEMAIMPLMEDIAF3U256 iemAImpl_vpsubq_u256, iemAImpl_vpsubq_u256_fallback;
3118FNIEMAIMPLMEDIAF3U256 iemAImpl_vpminub_u256, iemAImpl_vpminub_u256_fallback;
3119FNIEMAIMPLMEDIAF3U256 iemAImpl_vpminuw_u256, iemAImpl_vpminuw_u256_fallback;
3120FNIEMAIMPLMEDIAF3U256 iemAImpl_vpminud_u256, iemAImpl_vpminud_u256_fallback;
3121FNIEMAIMPLMEDIAF3U256 iemAImpl_vpminsb_u256, iemAImpl_vpminsb_u256_fallback;
3122FNIEMAIMPLMEDIAF3U256 iemAImpl_vpminsw_u256, iemAImpl_vpminsw_u256_fallback;
3123FNIEMAIMPLMEDIAF3U256 iemAImpl_vpminsd_u256, iemAImpl_vpminsd_u256_fallback;
3124FNIEMAIMPLMEDIAF3U256 iemAImpl_vpmaxub_u256, iemAImpl_vpmaxub_u256_fallback;
3125FNIEMAIMPLMEDIAF3U256 iemAImpl_vpmaxuw_u256, iemAImpl_vpmaxuw_u256_fallback;
3126FNIEMAIMPLMEDIAF3U256 iemAImpl_vpmaxud_u256, iemAImpl_vpmaxud_u256_fallback;
3127FNIEMAIMPLMEDIAF3U256 iemAImpl_vpmaxsb_u256, iemAImpl_vpmaxsb_u256_fallback;
3128FNIEMAIMPLMEDIAF3U256 iemAImpl_vpmaxsw_u256, iemAImpl_vpmaxsw_u256_fallback;
3129FNIEMAIMPLMEDIAF3U256 iemAImpl_vpmaxsd_u256, iemAImpl_vpmaxsd_u256_fallback;
3130FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpacksswb_u256, iemAImpl_vpacksswb_u256_fallback;
3131FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpackssdw_u256, iemAImpl_vpackssdw_u256_fallback;
3132FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpackuswb_u256, iemAImpl_vpackuswb_u256_fallback;
3133FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpackusdw_u256, iemAImpl_vpackusdw_u256_fallback;
3134FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmullw_u256, iemAImpl_vpmullw_u256_fallback;
3135FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmulld_u256, iemAImpl_vpmulld_u256_fallback;
3136FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmulhw_u256, iemAImpl_vpmulhw_u256_fallback;
3137FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmulhuw_u256, iemAImpl_vpmulhuw_u256_fallback;
3138FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpavgb_u256, iemAImpl_vpavgb_u256_fallback;
3139FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpavgw_u256, iemAImpl_vpavgw_u256_fallback;
3140FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsignb_u256, iemAImpl_vpsignb_u256_fallback;
3141FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsignw_u256, iemAImpl_vpsignw_u256_fallback;
3142FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsignd_u256, iemAImpl_vpsignd_u256_fallback;
3143FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vphaddw_u256, iemAImpl_vphaddw_u256_fallback;
3144FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vphaddd_u256, iemAImpl_vphaddd_u256_fallback;
3145FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vphsubw_u256, iemAImpl_vphsubw_u256_fallback;
3146FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vphsubd_u256, iemAImpl_vphsubd_u256_fallback;
3147FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vphaddsw_u256, iemAImpl_vphaddsw_u256_fallback;
3148FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vphsubsw_u256, iemAImpl_vphsubsw_u256_fallback;
3149FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmaddubsw_u256, iemAImpl_vpmaddubsw_u256_fallback;
3150FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmulhrsw_u256, iemAImpl_vpmulhrsw_u256_fallback;
3151FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsadbw_u256, iemAImpl_vpsadbw_u256_fallback;
3152FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmuldq_u256, iemAImpl_vpmuldq_u256_fallback;
3153FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmuludq_u256, iemAImpl_vpmuludq_u256_fallback;
3154FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsubsb_u256, iemAImpl_vpsubsb_u256_fallback;
3155FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsubsw_u256, iemAImpl_vpsubsw_u256_fallback;
3156FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsubusb_u256, iemAImpl_vpsubusb_u256_fallback;
3157FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsubusw_u256, iemAImpl_vpsubusw_u256_fallback;
3158FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpaddusb_u256, iemAImpl_vpaddusb_u256_fallback;
3159FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpaddusw_u256, iemAImpl_vpaddusw_u256_fallback;
3160FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpaddsb_u256, iemAImpl_vpaddsb_u256_fallback;
3161FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpaddsw_u256, iemAImpl_vpaddsw_u256_fallback;
3162
3163FNIEMAIMPLMEDIAOPTF2U256 iemAImpl_vpabsb_u256, iemAImpl_vpabsb_u256_fallback;
3164FNIEMAIMPLMEDIAOPTF2U256 iemAImpl_vpabsw_u256, iemAImpl_vpabsw_u256_fallback;
3165FNIEMAIMPLMEDIAOPTF2U256 iemAImpl_vpabsd_u256, iemAImpl_vpabsd_u256_fallback;
3166/** @} */
3167
3168/** @name Media (SSE/MMX/AVX) operations: lowhalf1 + lowhalf1 -> full1.
3169 * @{ */
3170FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_punpcklbw_u64, iemAImpl_punpcklwd_u64, iemAImpl_punpckldq_u64;
3171FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_punpcklbw_u128, iemAImpl_punpcklwd_u128, iemAImpl_punpckldq_u128, iemAImpl_punpcklqdq_u128;
3172FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpunpcklbw_u128, iemAImpl_vpunpcklbw_u128_fallback,
3173 iemAImpl_vpunpcklwd_u128, iemAImpl_vpunpcklwd_u128_fallback,
3174 iemAImpl_vpunpckldq_u128, iemAImpl_vpunpckldq_u128_fallback,
3175 iemAImpl_vpunpcklqdq_u128, iemAImpl_vpunpcklqdq_u128_fallback,
3176 iemAImpl_vunpcklps_u128, iemAImpl_vunpcklps_u128_fallback,
3177 iemAImpl_vunpcklpd_u128, iemAImpl_vunpcklpd_u128_fallback,
3178 iemAImpl_vunpckhps_u128, iemAImpl_vunpckhps_u128_fallback,
3179 iemAImpl_vunpckhpd_u128, iemAImpl_vunpckhpd_u128_fallback;
3180
3181FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpunpcklbw_u256, iemAImpl_vpunpcklbw_u256_fallback,
3182 iemAImpl_vpunpcklwd_u256, iemAImpl_vpunpcklwd_u256_fallback,
3183 iemAImpl_vpunpckldq_u256, iemAImpl_vpunpckldq_u256_fallback,
3184 iemAImpl_vpunpcklqdq_u256, iemAImpl_vpunpcklqdq_u256_fallback,
3185 iemAImpl_vunpcklps_u256, iemAImpl_vunpcklps_u256_fallback,
3186 iemAImpl_vunpcklpd_u256, iemAImpl_vunpcklpd_u256_fallback,
3187 iemAImpl_vunpckhps_u256, iemAImpl_vunpckhps_u256_fallback,
3188 iemAImpl_vunpckhpd_u256, iemAImpl_vunpckhpd_u256_fallback;
3189/** @} */
3190
3191/** @name Media (SSE/MMX/AVX) operations: hihalf1 + hihalf2 -> full1.
3192 * @{ */
3193FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_punpckhbw_u64, iemAImpl_punpckhwd_u64, iemAImpl_punpckhdq_u64;
3194FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_punpckhbw_u128, iemAImpl_punpckhwd_u128, iemAImpl_punpckhdq_u128, iemAImpl_punpckhqdq_u128;
3195FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpunpckhbw_u128, iemAImpl_vpunpckhbw_u128_fallback,
3196 iemAImpl_vpunpckhwd_u128, iemAImpl_vpunpckhwd_u128_fallback,
3197 iemAImpl_vpunpckhdq_u128, iemAImpl_vpunpckhdq_u128_fallback,
3198 iemAImpl_vpunpckhqdq_u128, iemAImpl_vpunpckhqdq_u128_fallback;
3199FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpunpckhbw_u256, iemAImpl_vpunpckhbw_u256_fallback,
3200 iemAImpl_vpunpckhwd_u256, iemAImpl_vpunpckhwd_u256_fallback,
3201 iemAImpl_vpunpckhdq_u256, iemAImpl_vpunpckhdq_u256_fallback,
3202 iemAImpl_vpunpckhqdq_u256, iemAImpl_vpunpckhqdq_u256_fallback;
3203/** @} */
3204
3205/** @name Media (SSE/MMX/AVX) operation: Packed Shuffle Stuff (evil)
3206 * @{ */
3207typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAPSHUFU128,(PRTUINT128U puDst, PCRTUINT128U puSrc, uint8_t bEvil));
3208typedef FNIEMAIMPLMEDIAPSHUFU128 *PFNIEMAIMPLMEDIAPSHUFU128;
3209typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAPSHUFU256,(PRTUINT256U puDst, PCRTUINT256U puSrc, uint8_t bEvil));
3210typedef FNIEMAIMPLMEDIAPSHUFU256 *PFNIEMAIMPLMEDIAPSHUFU256;
3211IEM_DECL_IMPL_DEF(void, iemAImpl_pshufw_u64,(uint64_t *puDst, uint64_t const *puSrc, uint8_t bEvil));
3212FNIEMAIMPLMEDIAPSHUFU128 iemAImpl_pshufhw_u128, iemAImpl_pshuflw_u128, iemAImpl_pshufd_u128;
3213#ifndef IEM_WITHOUT_ASSEMBLY
3214FNIEMAIMPLMEDIAPSHUFU256 iemAImpl_vpshufhw_u256, iemAImpl_vpshuflw_u256, iemAImpl_vpshufd_u256;
3215#endif
3216FNIEMAIMPLMEDIAPSHUFU256 iemAImpl_vpshufhw_u256_fallback, iemAImpl_vpshuflw_u256_fallback, iemAImpl_vpshufd_u256_fallback;
3217/** @} */
3218
3219/** @name Media (SSE/MMX/AVX) operation: Shift Immediate Stuff (evil)
3220 * @{ */
3221typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAPSHIFTU64,(uint64_t *puDst, uint8_t bShift));
3222typedef FNIEMAIMPLMEDIAPSHIFTU64 *PFNIEMAIMPLMEDIAPSHIFTU64;
3223typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAPSHIFTU128,(PRTUINT128U puDst, uint8_t bShift));
3224typedef FNIEMAIMPLMEDIAPSHIFTU128 *PFNIEMAIMPLMEDIAPSHIFTU128;
3225typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAPSHIFTU256,(PRTUINT256U puDst, uint8_t bShift));
3226typedef FNIEMAIMPLMEDIAPSHIFTU256 *PFNIEMAIMPLMEDIAPSHIFTU256;
3227FNIEMAIMPLMEDIAPSHIFTU64 iemAImpl_psllw_imm_u64, iemAImpl_pslld_imm_u64, iemAImpl_psllq_imm_u64;
3228FNIEMAIMPLMEDIAPSHIFTU64 iemAImpl_psrlw_imm_u64, iemAImpl_psrld_imm_u64, iemAImpl_psrlq_imm_u64;
3229FNIEMAIMPLMEDIAPSHIFTU64 iemAImpl_psraw_imm_u64, iemAImpl_psrad_imm_u64;
3230FNIEMAIMPLMEDIAPSHIFTU128 iemAImpl_psllw_imm_u128, iemAImpl_pslld_imm_u128, iemAImpl_psllq_imm_u128;
3231FNIEMAIMPLMEDIAPSHIFTU128 iemAImpl_psrlw_imm_u128, iemAImpl_psrld_imm_u128, iemAImpl_psrlq_imm_u128;
3232FNIEMAIMPLMEDIAPSHIFTU128 iemAImpl_psraw_imm_u128, iemAImpl_psrad_imm_u128;
3233FNIEMAIMPLMEDIAPSHIFTU128 iemAImpl_pslldq_imm_u128, iemAImpl_psrldq_imm_u128;
3234/** @} */
3235
3236/** @name Media (SSE/MMX/AVX) operation: Move Byte Mask
3237 * @{ */
3238IEM_DECL_IMPL_DEF(void, iemAImpl_pmovmskb_u64,(uint64_t *pu64Dst, uint64_t const *puSrc));
3239IEM_DECL_IMPL_DEF(void, iemAImpl_pmovmskb_u128,(uint64_t *pu64Dst, PCRTUINT128U puSrc));
3240#ifndef IEM_WITHOUT_ASSEMBLY
3241IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovmskb_u256,(uint64_t *pu64Dst, PCRTUINT256U puSrc));
3242#endif
3243IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovmskb_u256_fallback,(uint64_t *pu64Dst, PCRTUINT256U puSrc));
3244/** @} */
3245
3246/** @name Media (SSE/MMX/AVX) operations: Variable Blend Packed Bytes/R32/R64.
3247 * @{ */
3248typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBLENDU128,(PRTUINT128U puDst, PCRTUINT128U puSrc, PCRTUINT128U puMask));
3249typedef FNIEMAIMPLBLENDU128 *PFNIEMAIMPLBLENDU128;
3250typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLAVXBLENDU128,(PRTUINT128U puDst, PCRTUINT128U puSrc1, PCRTUINT128U puSrc2, PCRTUINT128U puMask));
3251typedef FNIEMAIMPLAVXBLENDU128 *PFNIEMAIMPLAVXBLENDU128;
3252typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLAVXBLENDU256,(PRTUINT256U puDst, PCRTUINT256U puSrc1, PCRTUINT256U puSrc2, PCRTUINT256U puMask));
3253typedef FNIEMAIMPLAVXBLENDU256 *PFNIEMAIMPLAVXBLENDU256;
3254
3255FNIEMAIMPLBLENDU128 iemAImpl_pblendvb_u128;
3256FNIEMAIMPLBLENDU128 iemAImpl_pblendvb_u128_fallback;
3257FNIEMAIMPLAVXBLENDU128 iemAImpl_vpblendvb_u128;
3258FNIEMAIMPLAVXBLENDU128 iemAImpl_vpblendvb_u128_fallback;
3259FNIEMAIMPLAVXBLENDU256 iemAImpl_vpblendvb_u256;
3260FNIEMAIMPLAVXBLENDU256 iemAImpl_vpblendvb_u256_fallback;
3261
3262FNIEMAIMPLBLENDU128 iemAImpl_blendvps_u128;
3263FNIEMAIMPLBLENDU128 iemAImpl_blendvps_u128_fallback;
3264FNIEMAIMPLAVXBLENDU128 iemAImpl_vblendvps_u128;
3265FNIEMAIMPLAVXBLENDU128 iemAImpl_vblendvps_u128_fallback;
3266FNIEMAIMPLAVXBLENDU256 iemAImpl_vblendvps_u256;
3267FNIEMAIMPLAVXBLENDU256 iemAImpl_vblendvps_u256_fallback;
3268
3269FNIEMAIMPLBLENDU128 iemAImpl_blendvpd_u128;
3270FNIEMAIMPLBLENDU128 iemAImpl_blendvpd_u128_fallback;
3271FNIEMAIMPLAVXBLENDU128 iemAImpl_vblendvpd_u128;
3272FNIEMAIMPLAVXBLENDU128 iemAImpl_vblendvpd_u128_fallback;
3273FNIEMAIMPLAVXBLENDU256 iemAImpl_vblendvpd_u256;
3274FNIEMAIMPLAVXBLENDU256 iemAImpl_vblendvpd_u256_fallback;
3275/** @} */
3276
3277
3278/** @name Media (SSE/MMX/AVX) operation: Sort this later
3279 * @{ */
3280IEM_DECL_IMPL_DEF(void, iemAImpl_vmovsldup_256_rr,(PX86XSAVEAREA pXState, uint8_t iYRegDst, uint8_t iYRegSrc));
3281IEM_DECL_IMPL_DEF(void, iemAImpl_vmovsldup_256_rm,(PX86XSAVEAREA pXState, uint8_t iYRegDst, PCRTUINT256U pSrc));
3282IEM_DECL_IMPL_DEF(void, iemAImpl_vmovshdup_256_rr,(PX86XSAVEAREA pXState, uint8_t iYRegDst, uint8_t iYRegSrc));
3283IEM_DECL_IMPL_DEF(void, iemAImpl_vmovshdup_256_rm,(PX86XSAVEAREA pXState, uint8_t iYRegDst, PCRTUINT256U pSrc));
3284IEM_DECL_IMPL_DEF(void, iemAImpl_vmovddup_256_rr,(PX86XSAVEAREA pXState, uint8_t iYRegDst, uint8_t iYRegSrc));
3285IEM_DECL_IMPL_DEF(void, iemAImpl_vmovddup_256_rm,(PX86XSAVEAREA pXState, uint8_t iYRegDst, PCRTUINT256U pSrc));
3286
3287IEM_DECL_IMPL_DEF(void, iemAImpl_pmovsxbw_u128,(PRTUINT128U puDst, uint64_t uSrc));
3288IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxbw_u128,(PRTUINT128U puDst, uint64_t uSrc));
3289IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxbw_u128_fallback,(PRTUINT128U puDst, uint64_t uSrc));
3290IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxbw_u256,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3291IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxbw_u256_fallback,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3292
3293IEM_DECL_IMPL_DEF(void, iemAImpl_pmovsxbd_u128,(PRTUINT128U puDst, uint32_t uSrc));
3294IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxbd_u128,(PRTUINT128U puDst, uint32_t uSrc));
3295IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxbd_u128_fallback,(PRTUINT128U puDst, uint32_t uSrc));
3296IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxbd_u256,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3297IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxbd_u256_fallback,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3298
3299IEM_DECL_IMPL_DEF(void, iemAImpl_pmovsxbq_u128,(PRTUINT128U puDst, uint16_t uSrc));
3300IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxbq_u128,(PRTUINT128U puDst, uint16_t uSrc));
3301IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxbq_u128_fallback,(PRTUINT128U puDst, uint16_t uSrc));
3302IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxbq_u256,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3303IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxbq_u256_fallback,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3304
3305IEM_DECL_IMPL_DEF(void, iemAImpl_pmovsxwd_u128,(PRTUINT128U puDst, uint64_t uSrc));
3306IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxwd_u128,(PRTUINT128U puDst, uint64_t uSrc));
3307IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxwd_u128_fallback,(PRTUINT128U puDst, uint64_t uSrc));
3308IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxwd_u256,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3309IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxwd_u256_fallback,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3310
3311IEM_DECL_IMPL_DEF(void, iemAImpl_pmovsxwq_u128,(PRTUINT128U puDst, uint32_t uSrc));
3312IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxwq_u128,(PRTUINT128U puDst, uint32_t uSrc));
3313IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxwq_u128_fallback,(PRTUINT128U puDst, uint32_t uSrc));
3314IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxwq_u256,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3315IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxwq_u256_fallback,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3316
3317IEM_DECL_IMPL_DEF(void, iemAImpl_pmovsxdq_u128,(PRTUINT128U puDst, uint64_t uSrc));
3318IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxdq_u128,(PRTUINT128U puDst, uint64_t uSrc));
3319IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxdq_u128_fallback,(PRTUINT128U puDst, uint64_t uSrc));
3320IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxdq_u256,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3321IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxdq_u256_fallback,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3322
3323IEM_DECL_IMPL_DEF(void, iemAImpl_pmovzxbw_u128,(PRTUINT128U puDst, uint64_t uSrc));
3324IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxbw_u128,(PRTUINT128U puDst, uint64_t uSrc));
3325IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxbw_u128_fallback,(PRTUINT128U puDst, uint64_t uSrc));
3326IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxbw_u256,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3327IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxbw_u256_fallback,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3328
3329IEM_DECL_IMPL_DEF(void, iemAImpl_pmovzxbd_u128,(PRTUINT128U puDst, uint32_t uSrc));
3330IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxbd_u128,(PRTUINT128U puDst, uint32_t uSrc));
3331IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxbd_u128_fallback,(PRTUINT128U puDst, uint32_t uSrc));
3332IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxbd_u256,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3333IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxbd_u256_fallback,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3334
3335IEM_DECL_IMPL_DEF(void, iemAImpl_pmovzxbq_u128,(PRTUINT128U puDst, uint16_t uSrc));
3336IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxbq_u128,(PRTUINT128U puDst, uint16_t uSrc));
3337IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxbq_u128_fallback,(PRTUINT128U puDst, uint16_t uSrc));
3338IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxbq_u256,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3339IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxbq_u256_fallback,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3340
3341IEM_DECL_IMPL_DEF(void, iemAImpl_pmovzxwd_u128,(PRTUINT128U puDst, uint64_t uSrc));
3342IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxwd_u128,(PRTUINT128U puDst, uint64_t uSrc));
3343IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxwd_u128_fallback,(PRTUINT128U puDst, uint64_t uSrc));
3344IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxwd_u256,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3345IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxwd_u256_fallback,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3346
3347IEM_DECL_IMPL_DEF(void, iemAImpl_pmovzxwq_u128,(PRTUINT128U puDst, uint32_t uSrc));
3348IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxwq_u128,(PRTUINT128U puDst, uint32_t uSrc));
3349IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxwq_u128_fallback,(PRTUINT128U puDst, uint32_t uSrc));
3350IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxwq_u256,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3351IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxwq_u256_fallback,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3352
3353IEM_DECL_IMPL_DEF(void, iemAImpl_pmovzxdq_u128,(PRTUINT128U puDst, uint64_t uSrc));
3354IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxdq_u128,(PRTUINT128U puDst, uint64_t uSrc));
3355IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxdq_u128_fallback,(PRTUINT128U puDst, uint64_t uSrc));
3356IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxdq_u256,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3357IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxdq_u256_fallback,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3358
3359IEM_DECL_IMPL_DEF(void, iemAImpl_shufpd_u128,(PRTUINT128U puDst, PCRTUINT128U puSrc, uint8_t bEvil));
3360IEM_DECL_IMPL_DEF(void, iemAImpl_vshufpd_u128,(PRTUINT128U puDst, PCRTUINT128U puSrc1, PCRTUINT128U puSrc2, uint8_t bEvil));
3361IEM_DECL_IMPL_DEF(void, iemAImpl_vshufpd_u128_fallback,(PRTUINT128U puDst, PCRTUINT128U puSrc1, PCRTUINT128U puSrc2, uint8_t bEvil));
3362IEM_DECL_IMPL_DEF(void, iemAImpl_vshufpd_u256,(PRTUINT256U puDst, PCRTUINT256U puSrc1, PCRTUINT256U puSrc2, uint8_t bEvil));
3363IEM_DECL_IMPL_DEF(void, iemAImpl_vshufpd_u256_fallback,(PRTUINT256U puDst, PCRTUINT256U puSrc1, PCRTUINT256U puSrc2, uint8_t bEvil));
3364
3365IEM_DECL_IMPL_DEF(void, iemAImpl_shufps_u128,(PRTUINT128U puDst, PCRTUINT128U puSrc, uint8_t bEvil));
3366IEM_DECL_IMPL_DEF(void, iemAImpl_vshufps_u128,(PRTUINT128U puDst, PCRTUINT128U puSrc1, PCRTUINT128U puSrc2, uint8_t bEvil));
3367IEM_DECL_IMPL_DEF(void, iemAImpl_vshufps_u128_fallback,(PRTUINT128U puDst, PCRTUINT128U puSrc1, PCRTUINT128U puSrc2, uint8_t bEvil));
3368IEM_DECL_IMPL_DEF(void, iemAImpl_vshufps_u256,(PRTUINT256U puDst, PCRTUINT256U puSrc1, PCRTUINT256U puSrc2, uint8_t bEvil));
3369IEM_DECL_IMPL_DEF(void, iemAImpl_vshufps_u256_fallback,(PRTUINT256U puDst, PCRTUINT256U puSrc1, PCRTUINT256U puSrc2, uint8_t bEvil));
3370
3371IEM_DECL_IMPL_DEF(void, iemAImpl_palignr_u64,(uint64_t *pu64Dst, uint64_t u64Src, uint8_t bEvil));
3372IEM_DECL_IMPL_DEF(void, iemAImpl_palignr_u64_fallback,(uint64_t *pu64Dst, uint64_t u64Src, uint8_t bEvil));
3373
3374IEM_DECL_IMPL_DEF(void, iemAImpl_pinsrw_u64,(uint64_t *pu64Dst, uint16_t u16Src, uint8_t bEvil));
3375IEM_DECL_IMPL_DEF(void, iemAImpl_pinsrw_u128,(PRTUINT128U puDst, uint16_t u16Src, uint8_t bEvil));
3376IEM_DECL_IMPL_DEF(void, iemAImpl_vpinsrw_u128,(PRTUINT128U puDst, PCRTUINT128U puSrc, uint16_t u16Src, uint8_t bEvil));
3377IEM_DECL_IMPL_DEF(void, iemAImpl_vpinsrw_u128_fallback,(PRTUINT128U puDst, PCRTUINT128U puSrc, uint16_t u16Src, uint8_t bEvil));
3378
3379IEM_DECL_IMPL_DEF(void, iemAImpl_pextrw_u64,(uint16_t *pu16Dst, uint64_t u64Src, uint8_t bEvil));
3380IEM_DECL_IMPL_DEF(void, iemAImpl_pextrw_u128,(uint16_t *pu16Dst, PCRTUINT128U puSrc, uint8_t bEvil));
3381IEM_DECL_IMPL_DEF(void, iemAImpl_vpextrw_u128,(uint16_t *pu16Dst, PCRTUINT128U puSrc, uint8_t bEvil));
3382IEM_DECL_IMPL_DEF(void, iemAImpl_vpextrw_u128_fallback,(uint16_t *pu16Dst, PCRTUINT128U puSrc, uint8_t bEvil));
3383
3384IEM_DECL_IMPL_DEF(void, iemAImpl_movmskps_u128,(uint8_t *pu8Dst, PCRTUINT128U puSrc));
3385IEM_DECL_IMPL_DEF(void, iemAImpl_vmovmskps_u128,(uint8_t *pu8Dst, PCRTUINT128U puSrc));
3386IEM_DECL_IMPL_DEF(void, iemAImpl_vmovmskps_u128_fallback,(uint8_t *pu8Dst, PCRTUINT128U puSrc));
3387IEM_DECL_IMPL_DEF(void, iemAImpl_vmovmskps_u256,(uint8_t *pu8Dst, PCRTUINT256U puSrc));
3388IEM_DECL_IMPL_DEF(void, iemAImpl_vmovmskps_u256_fallback,(uint8_t *pu8Dst, PCRTUINT256U puSrc));
3389
3390IEM_DECL_IMPL_DEF(void, iemAImpl_movmskpd_u128,(uint8_t *pu8Dst, PCRTUINT128U puSrc));
3391IEM_DECL_IMPL_DEF(void, iemAImpl_vmovmskpd_u128,(uint8_t *pu8Dst, PCRTUINT128U puSrc));
3392IEM_DECL_IMPL_DEF(void, iemAImpl_vmovmskpd_u128_fallback,(uint8_t *pu8Dst, PCRTUINT128U puSrc));
3393IEM_DECL_IMPL_DEF(void, iemAImpl_vmovmskpd_u256,(uint8_t *pu8Dst, PCRTUINT256U puSrc));
3394IEM_DECL_IMPL_DEF(void, iemAImpl_vmovmskpd_u256_fallback,(uint8_t *pu8Dst, PCRTUINT256U puSrc));
3395
3396
3397typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAOPTF2U128IMM8,(PRTUINT128U puDst, PCRTUINT128U puSrc, uint8_t bEvil));
3398typedef FNIEMAIMPLMEDIAOPTF2U128IMM8 *PFNIEMAIMPLMEDIAOPTF2U128IMM8;
3399typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAOPTF3U128IMM8,(PRTUINT128U puDst, PCRTUINT128U puSrc1, PCRTUINT128U puSrc2, uint8_t bEvil));
3400typedef FNIEMAIMPLMEDIAOPTF3U128IMM8 *PFNIEMAIMPLMEDIAOPTF3U128IMM8;
3401typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAOPTF3U256IMM8,(PRTUINT256U puDst, PCRTUINT256U puSrc1, PCRTUINT256U puSrc2, uint8_t bEvil));
3402typedef FNIEMAIMPLMEDIAOPTF3U256IMM8 *PFNIEMAIMPLMEDIAOPTF3U256IMM8;
3403
3404FNIEMAIMPLMEDIAOPTF2U128IMM8 iemAImpl_palignr_u128, iemAImpl_palignr_u128_fallback;
3405FNIEMAIMPLMEDIAOPTF2U128IMM8 iemAImpl_pblendw_u128, iemAImpl_pblendw_u128_fallback;
3406FNIEMAIMPLMEDIAOPTF2U128IMM8 iemAImpl_blendps_u128, iemAImpl_blendps_u128_fallback;
3407FNIEMAIMPLMEDIAOPTF2U128IMM8 iemAImpl_blendpd_u128, iemAImpl_blendpd_u128_fallback;
3408
3409FNIEMAIMPLMEDIAOPTF3U128IMM8 iemAImpl_vpalignr_u128, iemAImpl_vpalignr_u128_fallback;
3410FNIEMAIMPLMEDIAOPTF3U128IMM8 iemAImpl_vpblendw_u128, iemAImpl_vpblendw_u128_fallback;
3411FNIEMAIMPLMEDIAOPTF3U128IMM8 iemAImpl_vblendps_u128, iemAImpl_vblendps_u128_fallback;
3412FNIEMAIMPLMEDIAOPTF3U128IMM8 iemAImpl_vblendpd_u128, iemAImpl_vblendpd_u128_fallback;
3413
3414FNIEMAIMPLMEDIAOPTF3U256IMM8 iemAImpl_vpalignr_u256, iemAImpl_vpalignr_u256_fallback;
3415FNIEMAIMPLMEDIAOPTF3U256IMM8 iemAImpl_vpblendw_u256, iemAImpl_vpblendw_u256_fallback;
3416FNIEMAIMPLMEDIAOPTF3U256IMM8 iemAImpl_vblendps_u256, iemAImpl_vblendps_u256_fallback;
3417FNIEMAIMPLMEDIAOPTF3U256IMM8 iemAImpl_vblendpd_u256, iemAImpl_vblendpd_u256_fallback;
3418FNIEMAIMPLMEDIAOPTF3U256IMM8 iemAImpl_vperm2i128_u256, iemAImpl_vperm2i128_u256_fallback;
3419FNIEMAIMPLMEDIAOPTF3U256IMM8 iemAImpl_vperm2f128_u256, iemAImpl_vperm2f128_u256_fallback;
3420
3421FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_aesimc_u128, iemAImpl_aesimc_u128_fallback;
3422FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_aesenc_u128, iemAImpl_aesenc_u128_fallback;
3423FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_aesenclast_u128, iemAImpl_aesenclast_u128_fallback;
3424FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_aesdec_u128, iemAImpl_aesdec_u128_fallback;
3425FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_aesdeclast_u128, iemAImpl_aesdeclast_u128_fallback;
3426
3427FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_vaesimc_u128, iemAImpl_vaesimc_u128_fallback;
3428FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_vaesenc_u128, iemAImpl_vaesenc_u128_fallback;
3429FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_vaesenclast_u128, iemAImpl_vaesenclast_u128_fallback;
3430FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_vaesdec_u128, iemAImpl_vaesdec_u128_fallback;
3431FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_vaesdeclast_u128, iemAImpl_vaesdeclast_u128_fallback;
3432
3433FNIEMAIMPLMEDIAOPTF2U128IMM8 iemAImpl_aeskeygenassist_u128, iemAImpl_aeskeygenassist_u128_fallback;
3434
3435FNIEMAIMPLMEDIAOPTF3U128IMM8 iemAImpl_vaeskeygenassist_u128, iemAImpl_vaeskeygenassist_u128_fallback;
3436
3437FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_sha1nexte_u128, iemAImpl_sha1nexte_u128_fallback;
3438FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_sha1msg1_u128, iemAImpl_sha1msg1_u128_fallback;
3439FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_sha1msg2_u128, iemAImpl_sha1msg2_u128_fallback;
3440FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_sha256msg1_u128, iemAImpl_sha256msg1_u128_fallback;
3441FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_sha256msg2_u128, iemAImpl_sha256msg2_u128_fallback;
3442FNIEMAIMPLMEDIAOPTF2U128IMM8 iemAImpl_sha1rnds4_u128, iemAImpl_sha1rnds4_u128_fallback;
3443IEM_DECL_IMPL_DEF(void, iemAImpl_sha256rnds2_u128,(PRTUINT128U puDst, PCRTUINT128U puSrc, PCRTUINT128U puXmm0Constants));
3444IEM_DECL_IMPL_DEF(void, iemAImpl_sha256rnds2_u128_fallback,(PRTUINT128U puDst, PCRTUINT128U puSrc, PCRTUINT128U puXmm0Constants));
3445
3446typedef struct IEMPCMPISTRXSRC
3447{
3448 RTUINT128U uSrc1;
3449 RTUINT128U uSrc2;
3450} IEMPCMPISTRXSRC;
3451typedef IEMPCMPISTRXSRC *PIEMPCMPISTRXSRC;
3452typedef const IEMPCMPISTRXSRC *PCIEMPCMPISTRXSRC;
3453
3454typedef struct IEMPCMPESTRXSRC
3455{
3456 RTUINT128U uSrc1;
3457 RTUINT128U uSrc2;
3458 uint64_t u64Rax;
3459 uint64_t u64Rdx;
3460} IEMPCMPESTRXSRC;
3461typedef IEMPCMPESTRXSRC *PIEMPCMPESTRXSRC;
3462typedef const IEMPCMPESTRXSRC *PCIEMPCMPESTRXSRC;
3463
3464typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLPCMPISTRIU128IMM8,(uint32_t *pu32Ecx, uint32_t *pEFlags, PCIEMPCMPISTRXSRC pSrc, uint8_t bEvil));
3465typedef FNIEMAIMPLPCMPISTRIU128IMM8 *PFNIEMAIMPLPCMPISTRIU128IMM8;
3466typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLPCMPESTRIU128IMM8,(uint32_t *pu32Ecx, uint32_t *pEFlags, PCIEMPCMPESTRXSRC pSrc, uint8_t bEvil));
3467typedef FNIEMAIMPLPCMPESTRIU128IMM8 *PFNIEMAIMPLPCMPESTRIU128IMM8;
3468
3469typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLPCMPISTRMU128IMM8,(PRTUINT128U puDst, uint32_t *pEFlags, PCIEMPCMPISTRXSRC pSrc, uint8_t bEvil));
3470typedef FNIEMAIMPLPCMPISTRMU128IMM8 *PFNIEMAIMPLPCMPISTRMU128IMM8;
3471typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLPCMPESTRMU128IMM8,(PRTUINT128U puDst, uint32_t *pEFlags, PCIEMPCMPESTRXSRC pSrc, uint8_t bEvil));
3472typedef FNIEMAIMPLPCMPESTRMU128IMM8 *PFNIEMAIMPLPCMPESTRMU128IMM8;
3473
3474FNIEMAIMPLPCMPISTRIU128IMM8 iemAImpl_pcmpistri_u128, iemAImpl_pcmpistri_u128_fallback;
3475FNIEMAIMPLPCMPESTRIU128IMM8 iemAImpl_pcmpestri_u128, iemAImpl_pcmpestri_u128_fallback;
3476FNIEMAIMPLPCMPISTRMU128IMM8 iemAImpl_pcmpistrm_u128, iemAImpl_pcmpistrm_u128_fallback;
3477FNIEMAIMPLPCMPESTRMU128IMM8 iemAImpl_pcmpestrm_u128, iemAImpl_pcmpestrm_u128_fallback;
3478
3479FNIEMAIMPLMEDIAOPTF2U128IMM8 iemAImpl_pclmulqdq_u128, iemAImpl_pclmulqdq_u128_fallback;
3480FNIEMAIMPLMEDIAOPTF3U128IMM8 iemAImpl_vpclmulqdq_u128, iemAImpl_vpclmulqdq_u128_fallback;
3481
3482FNIEMAIMPLMEDIAOPTF2U128IMM8 iemAImpl_mpsadbw_u128, iemAImpl_mpsadbw_u128_fallback;
3483FNIEMAIMPLMEDIAOPTF3U128IMM8 iemAImpl_vmpsadbw_u128, iemAImpl_vmpsadbw_u128_fallback;
3484FNIEMAIMPLMEDIAOPTF3U256IMM8 iemAImpl_vmpsadbw_u256, iemAImpl_vmpsadbw_u256_fallback;
3485/** @} */
3486
3487/** @name Media Odds and Ends
3488 * @{ */
3489typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLCR32U8,(uint32_t *puDst, uint8_t uSrc));
3490typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLCR32U16,(uint32_t *puDst, uint16_t uSrc));
3491typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLCR32U32,(uint32_t *puDst, uint32_t uSrc));
3492typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLCR32U64,(uint32_t *puDst, uint64_t uSrc));
3493FNIEMAIMPLCR32U8 iemAImpl_crc32_u8, iemAImpl_crc32_u8_fallback;
3494FNIEMAIMPLCR32U16 iemAImpl_crc32_u16, iemAImpl_crc32_u16_fallback;
3495FNIEMAIMPLCR32U32 iemAImpl_crc32_u32, iemAImpl_crc32_u32_fallback;
3496FNIEMAIMPLCR32U64 iemAImpl_crc32_u64, iemAImpl_crc32_u64_fallback;
3497
3498typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLF2EFL128,(PCRTUINT128U puSrc1, PCRTUINT128U puSrc2, uint32_t *pEFlags));
3499typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLF2EFL256,(PCRTUINT256U puSrc1, PCRTUINT256U puSrc2, uint32_t *pEFlags));
3500FNIEMAIMPLF2EFL128 iemAImpl_ptest_u128;
3501FNIEMAIMPLF2EFL256 iemAImpl_vptest_u256, iemAImpl_vptest_u256_fallback;
3502
3503typedef 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. */
3504typedef FNIEMAIMPLSSEF2I32U64 *PFNIEMAIMPLSSEF2I32U64;
3505typedef 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. */
3506typedef FNIEMAIMPLSSEF2I64U64 *PFNIEMAIMPLSSEF2I64U64;
3507typedef 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. */
3508typedef FNIEMAIMPLSSEF2I32U32 *PFNIEMAIMPLSSEF2I32U32;
3509typedef 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. */
3510typedef FNIEMAIMPLSSEF2I64U32 *PFNIEMAIMPLSSEF2I64U32;
3511
3512FNIEMAIMPLSSEF2I32U64 iemAImpl_cvttsd2si_i32_r64;
3513FNIEMAIMPLSSEF2I32U64 iemAImpl_cvtsd2si_i32_r64;
3514
3515FNIEMAIMPLSSEF2I64U64 iemAImpl_cvttsd2si_i64_r64;
3516FNIEMAIMPLSSEF2I64U64 iemAImpl_cvtsd2si_i64_r64;
3517
3518FNIEMAIMPLSSEF2I32U32 iemAImpl_cvttss2si_i32_r32;
3519FNIEMAIMPLSSEF2I32U32 iemAImpl_cvtss2si_i32_r32;
3520
3521FNIEMAIMPLSSEF2I64U32 iemAImpl_cvttss2si_i64_r32;
3522FNIEMAIMPLSSEF2I64U32 iemAImpl_cvtss2si_i64_r32;
3523
3524typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSSEF2R32I32,(PCX86FXSTATE pFpuState, uint32_t *pfMxcsr, PRTFLOAT32U pr32Dst, const int32_t *pi32Src));
3525typedef FNIEMAIMPLSSEF2R32I32 *PFNIEMAIMPLSSEF2R32I32;
3526typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSSEF2R32I64,(PCX86FXSTATE pFpuState, uint32_t *pfMxcsr, PRTFLOAT32U pr32Dst, const int64_t *pi64Src));
3527typedef FNIEMAIMPLSSEF2R32I64 *PFNIEMAIMPLSSEF2R32I64;
3528
3529FNIEMAIMPLSSEF2R32I32 iemAImpl_cvtsi2ss_r32_i32;
3530FNIEMAIMPLSSEF2R32I64 iemAImpl_cvtsi2ss_r32_i64;
3531
3532typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSSEF2R64I32,(PCX86FXSTATE pFpuState, uint32_t *pfMxcsr, PRTFLOAT64U pr64Dst, const int32_t *pi32Src));
3533typedef FNIEMAIMPLSSEF2R64I32 *PFNIEMAIMPLSSEF2R64I32;
3534typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSSEF2R64I64,(PCX86FXSTATE pFpuState, uint32_t *pfMxcsr, PRTFLOAT64U pr64Dst, const int64_t *pi64Src));
3535typedef FNIEMAIMPLSSEF2R64I64 *PFNIEMAIMPLSSEF2R64I64;
3536
3537FNIEMAIMPLSSEF2R64I32 iemAImpl_cvtsi2sd_r64_i32;
3538FNIEMAIMPLSSEF2R64I64 iemAImpl_cvtsi2sd_r64_i64;
3539
3540
3541typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLF2EFLMXCSR128,(uint32_t *pfMxcsr, uint32_t *pfEFlags, PCX86XMMREG puSrc1, PCX86XMMREG puSrc2));
3542typedef FNIEMAIMPLF2EFLMXCSR128 *PFNIEMAIMPLF2EFLMXCSR128;
3543
3544FNIEMAIMPLF2EFLMXCSR128 iemAImpl_ucomiss_u128;
3545FNIEMAIMPLF2EFLMXCSR128 iemAImpl_vucomiss_u128, iemAImpl_vucomiss_u128_fallback;
3546
3547FNIEMAIMPLF2EFLMXCSR128 iemAImpl_ucomisd_u128;
3548FNIEMAIMPLF2EFLMXCSR128 iemAImpl_vucomisd_u128, iemAImpl_vucomisd_u128_fallback;
3549
3550FNIEMAIMPLF2EFLMXCSR128 iemAImpl_comiss_u128;
3551FNIEMAIMPLF2EFLMXCSR128 iemAImpl_vcomiss_u128, iemAImpl_vcomiss_u128_fallback;
3552
3553FNIEMAIMPLF2EFLMXCSR128 iemAImpl_comisd_u128;
3554FNIEMAIMPLF2EFLMXCSR128 iemAImpl_vcomisd_u128, iemAImpl_vcomisd_u128_fallback;
3555
3556
3557typedef struct IEMMEDIAF2XMMSRC
3558{
3559 X86XMMREG uSrc1;
3560 X86XMMREG uSrc2;
3561} IEMMEDIAF2XMMSRC;
3562typedef IEMMEDIAF2XMMSRC *PIEMMEDIAF2XMMSRC;
3563typedef const IEMMEDIAF2XMMSRC *PCIEMMEDIAF2XMMSRC;
3564
3565typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMXCSRF2XMMIMM8,(uint32_t *pfMxcsr, PX86XMMREG puDst, PCIEMMEDIAF2XMMSRC puSrc, uint8_t bEvil));
3566typedef FNIEMAIMPLMXCSRF2XMMIMM8 *PFNIEMAIMPLMXCSRF2XMMIMM8;
3567
3568FNIEMAIMPLMXCSRF2XMMIMM8 iemAImpl_cmpps_u128;
3569FNIEMAIMPLMXCSRF2XMMIMM8 iemAImpl_cmppd_u128;
3570FNIEMAIMPLMXCSRF2XMMIMM8 iemAImpl_cmpss_u128;
3571FNIEMAIMPLMXCSRF2XMMIMM8 iemAImpl_cmpsd_u128;
3572FNIEMAIMPLMXCSRF2XMMIMM8 iemAImpl_roundss_u128;
3573FNIEMAIMPLMXCSRF2XMMIMM8 iemAImpl_roundsd_u128;
3574
3575FNIEMAIMPLMXCSRF2XMMIMM8 iemAImpl_roundps_u128, iemAImpl_roundps_u128_fallback;
3576FNIEMAIMPLMXCSRF2XMMIMM8 iemAImpl_roundpd_u128, iemAImpl_roundpd_u128_fallback;
3577
3578FNIEMAIMPLMXCSRF2XMMIMM8 iemAImpl_dpps_u128, iemAImpl_dpps_u128_fallback;
3579FNIEMAIMPLMXCSRF2XMMIMM8 iemAImpl_dppd_u128, iemAImpl_dppd_u128_fallback;
3580
3581typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMXCSRU64U128,(uint32_t *pfMxcsr, uint64_t *pu64Dst, PCX86XMMREG pSrc));
3582typedef FNIEMAIMPLMXCSRU64U128 *PFNIEMAIMPLMXCSRU64U128;
3583
3584FNIEMAIMPLMXCSRU64U128 iemAImpl_cvtpd2pi_u128;
3585FNIEMAIMPLMXCSRU64U128 iemAImpl_cvttpd2pi_u128;
3586
3587typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMXCSRU128U64,(uint32_t *pfMxcsr, PX86XMMREG pDst, uint64_t u64Src));
3588typedef FNIEMAIMPLMXCSRU128U64 *PFNIEMAIMPLMXCSRU128U64;
3589
3590FNIEMAIMPLMXCSRU128U64 iemAImpl_cvtpi2ps_u128;
3591FNIEMAIMPLMXCSRU128U64 iemAImpl_cvtpi2pd_u128;
3592
3593typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMXCSRU64U64,(uint32_t *pfMxcsr, uint64_t *pu64Dst, uint64_t u64Src));
3594typedef FNIEMAIMPLMXCSRU64U64 *PFNIEMAIMPLMXCSRU64U64;
3595
3596FNIEMAIMPLMXCSRU64U64 iemAImpl_cvtps2pi_u128;
3597FNIEMAIMPLMXCSRU64U64 iemAImpl_cvttps2pi_u128;
3598
3599/** @} */
3600
3601
3602/** @name Function tables.
3603 * @{
3604 */
3605
3606/**
3607 * Function table for a binary operator providing implementation based on
3608 * operand size.
3609 */
3610typedef struct IEMOPBINSIZES
3611{
3612 PFNIEMAIMPLBINU8 pfnNormalU8, pfnLockedU8;
3613 PFNIEMAIMPLBINU16 pfnNormalU16, pfnLockedU16;
3614 PFNIEMAIMPLBINU32 pfnNormalU32, pfnLockedU32;
3615 PFNIEMAIMPLBINU64 pfnNormalU64, pfnLockedU64;
3616} IEMOPBINSIZES;
3617/** Pointer to a binary operator function table. */
3618typedef IEMOPBINSIZES const *PCIEMOPBINSIZES;
3619
3620
3621/**
3622 * Function table for a unary operator providing implementation based on
3623 * operand size.
3624 */
3625typedef struct IEMOPUNARYSIZES
3626{
3627 PFNIEMAIMPLUNARYU8 pfnNormalU8, pfnLockedU8;
3628 PFNIEMAIMPLUNARYU16 pfnNormalU16, pfnLockedU16;
3629 PFNIEMAIMPLUNARYU32 pfnNormalU32, pfnLockedU32;
3630 PFNIEMAIMPLUNARYU64 pfnNormalU64, pfnLockedU64;
3631} IEMOPUNARYSIZES;
3632/** Pointer to a unary operator function table. */
3633typedef IEMOPUNARYSIZES const *PCIEMOPUNARYSIZES;
3634
3635
3636/**
3637 * Function table for a shift operator providing implementation based on
3638 * operand size.
3639 */
3640typedef struct IEMOPSHIFTSIZES
3641{
3642 PFNIEMAIMPLSHIFTU8 pfnNormalU8;
3643 PFNIEMAIMPLSHIFTU16 pfnNormalU16;
3644 PFNIEMAIMPLSHIFTU32 pfnNormalU32;
3645 PFNIEMAIMPLSHIFTU64 pfnNormalU64;
3646} IEMOPSHIFTSIZES;
3647/** Pointer to a shift operator function table. */
3648typedef IEMOPSHIFTSIZES const *PCIEMOPSHIFTSIZES;
3649
3650
3651/**
3652 * Function table for a multiplication or division operation.
3653 */
3654typedef struct IEMOPMULDIVSIZES
3655{
3656 PFNIEMAIMPLMULDIVU8 pfnU8;
3657 PFNIEMAIMPLMULDIVU16 pfnU16;
3658 PFNIEMAIMPLMULDIVU32 pfnU32;
3659 PFNIEMAIMPLMULDIVU64 pfnU64;
3660} IEMOPMULDIVSIZES;
3661/** Pointer to a multiplication or division operation function table. */
3662typedef IEMOPMULDIVSIZES const *PCIEMOPMULDIVSIZES;
3663
3664
3665/**
3666 * Function table for a double precision shift operator providing implementation
3667 * based on operand size.
3668 */
3669typedef struct IEMOPSHIFTDBLSIZES
3670{
3671 PFNIEMAIMPLSHIFTDBLU16 pfnNormalU16;
3672 PFNIEMAIMPLSHIFTDBLU32 pfnNormalU32;
3673 PFNIEMAIMPLSHIFTDBLU64 pfnNormalU64;
3674} IEMOPSHIFTDBLSIZES;
3675/** Pointer to a double precision shift function table. */
3676typedef IEMOPSHIFTDBLSIZES const *PCIEMOPSHIFTDBLSIZES;
3677
3678
3679/**
3680 * Function table for media instruction taking two full sized media source
3681 * registers and one full sized destination register (AVX).
3682 */
3683typedef struct IEMOPMEDIAF3
3684{
3685 PFNIEMAIMPLMEDIAF3U128 pfnU128;
3686 PFNIEMAIMPLMEDIAF3U256 pfnU256;
3687} IEMOPMEDIAF3;
3688/** Pointer to a media operation function table for 3 full sized ops (AVX). */
3689typedef IEMOPMEDIAF3 const *PCIEMOPMEDIAF3;
3690
3691/** @def IEMOPMEDIAF3_INIT_VARS_EX
3692 * Declares a s_Host (x86 & amd64 only) and a s_Fallback variable with the
3693 * given functions as initializers. For use in AVX functions where a pair of
3694 * functions are only used once and the function table need not be public. */
3695#ifndef TST_IEM_CHECK_MC
3696# if (defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)) && !defined(IEM_WITHOUT_ASSEMBLY)
3697# define IEMOPMEDIAF3_INIT_VARS_EX(a_pfnHostU128, a_pfnHostU256, a_pfnFallbackU128, a_pfnFallbackU256) \
3698 static IEMOPMEDIAF3 const s_Host = { a_pfnHostU128, a_pfnHostU256 }; \
3699 static IEMOPMEDIAF3 const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
3700# else
3701# define IEMOPMEDIAF3_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) \
3702 static IEMOPMEDIAF3 const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
3703# endif
3704#else
3705# define IEMOPMEDIAF3_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) (void)0
3706#endif
3707/** @def IEMOPMEDIAF3_INIT_VARS
3708 * Generate AVX function tables for the @a a_InstrNm instruction.
3709 * @sa IEMOPMEDIAF3_INIT_VARS_EX */
3710#define IEMOPMEDIAF3_INIT_VARS(a_InstrNm) \
3711 IEMOPMEDIAF3_INIT_VARS_EX(RT_CONCAT3(iemAImpl_,a_InstrNm,_u128), RT_CONCAT3(iemAImpl_,a_InstrNm,_u256),\
3712 RT_CONCAT3(iemAImpl_,a_InstrNm,_u128_fallback), RT_CONCAT3(iemAImpl_,a_InstrNm,_u256_fallback))
3713
3714/**
3715 * Function table for media instruction taking two full sized media source
3716 * registers and one full sized destination register, but no additional state
3717 * (AVX).
3718 */
3719typedef struct IEMOPMEDIAOPTF3
3720{
3721 PFNIEMAIMPLMEDIAOPTF3U128 pfnU128;
3722 PFNIEMAIMPLMEDIAOPTF3U256 pfnU256;
3723} IEMOPMEDIAOPTF3;
3724/** Pointer to a media operation function table for 3 full sized ops (AVX). */
3725typedef IEMOPMEDIAOPTF3 const *PCIEMOPMEDIAOPTF3;
3726
3727/** @def IEMOPMEDIAOPTF3_INIT_VARS_EX
3728 * Declares a s_Host (x86 & amd64 only) and a s_Fallback variable with the
3729 * given functions as initializers. For use in AVX functions where a pair of
3730 * functions are only used once and the function table need not be public. */
3731#ifndef TST_IEM_CHECK_MC
3732# if (defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)) && !defined(IEM_WITHOUT_ASSEMBLY)
3733# define IEMOPMEDIAOPTF3_INIT_VARS_EX(a_pfnHostU128, a_pfnHostU256, a_pfnFallbackU128, a_pfnFallbackU256) \
3734 static IEMOPMEDIAOPTF3 const s_Host = { a_pfnHostU128, a_pfnHostU256 }; \
3735 static IEMOPMEDIAOPTF3 const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
3736# else
3737# define IEMOPMEDIAOPTF3_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) \
3738 static IEMOPMEDIAOPTF3 const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
3739# endif
3740#else
3741# define IEMOPMEDIAOPTF3_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) (void)0
3742#endif
3743/** @def IEMOPMEDIAOPTF3_INIT_VARS
3744 * Generate AVX function tables for the @a a_InstrNm instruction.
3745 * @sa IEMOPMEDIAOPTF3_INIT_VARS_EX */
3746#define IEMOPMEDIAOPTF3_INIT_VARS(a_InstrNm) \
3747 IEMOPMEDIAOPTF3_INIT_VARS_EX(RT_CONCAT3(iemAImpl_,a_InstrNm,_u128), RT_CONCAT3(iemAImpl_,a_InstrNm,_u256),\
3748 RT_CONCAT3(iemAImpl_,a_InstrNm,_u128_fallback), RT_CONCAT3(iemAImpl_,a_InstrNm,_u256_fallback))
3749
3750/**
3751 * Function table for media instruction taking one full sized media source
3752 * registers and one full sized destination register, but no additional state
3753 * (AVX).
3754 */
3755typedef struct IEMOPMEDIAOPTF2
3756{
3757 PFNIEMAIMPLMEDIAOPTF2U128 pfnU128;
3758 PFNIEMAIMPLMEDIAOPTF2U256 pfnU256;
3759} IEMOPMEDIAOPTF2;
3760/** Pointer to a media operation function table for 2 full sized ops (AVX). */
3761typedef IEMOPMEDIAOPTF2 const *PCIEMOPMEDIAOPTF2;
3762
3763/** @def IEMOPMEDIAOPTF2_INIT_VARS_EX
3764 * Declares a s_Host (x86 & amd64 only) and a s_Fallback variable with the
3765 * given functions as initializers. For use in AVX functions where a pair of
3766 * functions are only used once and the function table need not be public. */
3767#ifndef TST_IEM_CHECK_MC
3768# if (defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)) && !defined(IEM_WITHOUT_ASSEMBLY)
3769# define IEMOPMEDIAOPTF2_INIT_VARS_EX(a_pfnHostU128, a_pfnHostU256, a_pfnFallbackU128, a_pfnFallbackU256) \
3770 static IEMOPMEDIAOPTF2 const s_Host = { a_pfnHostU128, a_pfnHostU256 }; \
3771 static IEMOPMEDIAOPTF2 const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
3772# else
3773# define IEMOPMEDIAOPTF2_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) \
3774 static IEMOPMEDIAOPTF2 const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
3775# endif
3776#else
3777# define IEMOPMEDIAOPTF2_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) (void)0
3778#endif
3779/** @def IEMOPMEDIAOPTF2_INIT_VARS
3780 * Generate AVX function tables for the @a a_InstrNm instruction.
3781 * @sa IEMOPMEDIAOPTF2_INIT_VARS_EX */
3782#define IEMOPMEDIAOPTF2_INIT_VARS(a_InstrNm) \
3783 IEMOPMEDIAOPTF2_INIT_VARS_EX(RT_CONCAT3(iemAImpl_,a_InstrNm,_u128), RT_CONCAT3(iemAImpl_,a_InstrNm,_u256),\
3784 RT_CONCAT3(iemAImpl_,a_InstrNm,_u128_fallback), RT_CONCAT3(iemAImpl_,a_InstrNm,_u256_fallback))
3785
3786/**
3787 * Function table for media instruction taking two full sized media source
3788 * registers and one full sized destination register and an 8-bit immediate, but no additional state
3789 * (AVX).
3790 */
3791typedef struct IEMOPMEDIAOPTF3IMM8
3792{
3793 PFNIEMAIMPLMEDIAOPTF3U128IMM8 pfnU128;
3794 PFNIEMAIMPLMEDIAOPTF3U256IMM8 pfnU256;
3795} IEMOPMEDIAOPTF3IMM8;
3796/** Pointer to a media operation function table for 3 full sized ops (AVX). */
3797typedef IEMOPMEDIAOPTF3IMM8 const *PCIEMOPMEDIAOPTF3IMM8;
3798
3799/** @def IEMOPMEDIAOPTF3IMM8_INIT_VARS_EX
3800 * Declares a s_Host (x86 & amd64 only) and a s_Fallback variable with the
3801 * given functions as initializers. For use in AVX functions where a pair of
3802 * functions are only used once and the function table need not be public. */
3803#ifndef TST_IEM_CHECK_MC
3804# if (defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)) && !defined(IEM_WITHOUT_ASSEMBLY)
3805# define IEMOPMEDIAOPTF3IMM8_INIT_VARS_EX(a_pfnHostU128, a_pfnHostU256, a_pfnFallbackU128, a_pfnFallbackU256) \
3806 static IEMOPMEDIAOPTF3IMM8 const s_Host = { a_pfnHostU128, a_pfnHostU256 }; \
3807 static IEMOPMEDIAOPTF3IMM8 const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
3808# else
3809# define IEMOPMEDIAOPTF3IMM8_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) \
3810 static IEMOPMEDIAOPTF3IMM8 const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
3811# endif
3812#else
3813# define IEMOPMEDIAOPTF3IMM8_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) (void)0
3814#endif
3815/** @def IEMOPMEDIAOPTF3IMM8_INIT_VARS
3816 * Generate AVX function tables for the @a a_InstrNm instruction.
3817 * @sa IEMOPMEDIAOPTF3IMM8_INIT_VARS_EX */
3818#define IEMOPMEDIAOPTF3IMM8_INIT_VARS(a_InstrNm) \
3819 IEMOPMEDIAOPTF3IMM8_INIT_VARS_EX(RT_CONCAT3(iemAImpl_,a_InstrNm,_u128), RT_CONCAT3(iemAImpl_,a_InstrNm,_u256),\
3820 RT_CONCAT3(iemAImpl_,a_InstrNm,_u128_fallback), RT_CONCAT3(iemAImpl_,a_InstrNm,_u256_fallback))
3821/** @} */
3822
3823
3824/**
3825 * Function table for blend type instruction taking three full sized media source
3826 * registers and one full sized destination register, but no additional state
3827 * (AVX).
3828 */
3829typedef struct IEMOPBLENDOP
3830{
3831 PFNIEMAIMPLAVXBLENDU128 pfnU128;
3832 PFNIEMAIMPLAVXBLENDU256 pfnU256;
3833} IEMOPBLENDOP;
3834/** Pointer to a media operation function table for 4 full sized ops (AVX). */
3835typedef IEMOPBLENDOP const *PCIEMOPBLENDOP;
3836
3837/** @def IEMOPBLENDOP_INIT_VARS_EX
3838 * Declares a s_Host (x86 & amd64 only) and a s_Fallback variable with the
3839 * given functions as initializers. For use in AVX functions where a pair of
3840 * functions are only used once and the function table need not be public. */
3841#ifndef TST_IEM_CHECK_MC
3842# if (defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)) && !defined(IEM_WITHOUT_ASSEMBLY)
3843# define IEMOPBLENDOP_INIT_VARS_EX(a_pfnHostU128, a_pfnHostU256, a_pfnFallbackU128, a_pfnFallbackU256) \
3844 static IEMOPBLENDOP const s_Host = { a_pfnHostU128, a_pfnHostU256 }; \
3845 static IEMOPBLENDOP const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
3846# else
3847# define IEMOPBLENDOP_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) \
3848 static IEMOPBLENDOP const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
3849# endif
3850#else
3851# define IEMOPBLENDOP_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) (void)0
3852#endif
3853/** @def IEMOPBLENDOP_INIT_VARS
3854 * Generate AVX function tables for the @a a_InstrNm instruction.
3855 * @sa IEMOPBLENDOP_INIT_VARS_EX */
3856#define IEMOPBLENDOP_INIT_VARS(a_InstrNm) \
3857 IEMOPBLENDOP_INIT_VARS_EX(RT_CONCAT3(iemAImpl_,a_InstrNm,_u128), RT_CONCAT3(iemAImpl_,a_InstrNm,_u256),\
3858 RT_CONCAT3(iemAImpl_,a_InstrNm,_u128_fallback), RT_CONCAT3(iemAImpl_,a_InstrNm,_u256_fallback))
3859
3860
3861/** @name SSE/AVX single/double precision floating point operations.
3862 * @{ */
3863/**
3864 * A SSE result.
3865 */
3866typedef struct IEMSSERESULT
3867{
3868 /** The output value. */
3869 X86XMMREG uResult;
3870 /** The output status. */
3871 uint32_t MXCSR;
3872} IEMSSERESULT;
3873AssertCompileMemberOffset(IEMSSERESULT, MXCSR, 128 / 8);
3874/** Pointer to a SSE result. */
3875typedef IEMSSERESULT *PIEMSSERESULT;
3876/** Pointer to a const SSE result. */
3877typedef IEMSSERESULT const *PCIEMSSERESULT;
3878
3879
3880/**
3881 * A AVX128 result.
3882 */
3883typedef struct IEMAVX128RESULT
3884{
3885 /** The output value. */
3886 X86XMMREG uResult;
3887 /** The output status. */
3888 uint32_t MXCSR;
3889} IEMAVX128RESULT;
3890AssertCompileMemberOffset(IEMAVX128RESULT, MXCSR, 128 / 8);
3891/** Pointer to a AVX128 result. */
3892typedef IEMAVX128RESULT *PIEMAVX128RESULT;
3893/** Pointer to a const AVX128 result. */
3894typedef IEMAVX128RESULT const *PCIEMAVX128RESULT;
3895
3896
3897/**
3898 * A AVX256 result.
3899 */
3900typedef struct IEMAVX256RESULT
3901{
3902 /** The output value. */
3903 X86YMMREG uResult;
3904 /** The output status. */
3905 uint32_t MXCSR;
3906} IEMAVX256RESULT;
3907AssertCompileMemberOffset(IEMAVX256RESULT, MXCSR, 256 / 8);
3908/** Pointer to a AVX256 result. */
3909typedef IEMAVX256RESULT *PIEMAVX256RESULT;
3910/** Pointer to a const AVX256 result. */
3911typedef IEMAVX256RESULT const *PCIEMAVX256RESULT;
3912
3913
3914typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPSSEF2U128,(PX86FXSTATE pFpuState, PIEMSSERESULT pResult, PCX86XMMREG puSrc1, PCX86XMMREG puSrc2));
3915typedef FNIEMAIMPLFPSSEF2U128 *PFNIEMAIMPLFPSSEF2U128;
3916typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPSSEF2U128R32,(PX86FXSTATE pFpuState, PIEMSSERESULT pResult, PCX86XMMREG puSrc1, PCRTFLOAT32U pr32Src2));
3917typedef FNIEMAIMPLFPSSEF2U128R32 *PFNIEMAIMPLFPSSEF2U128R32;
3918typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPSSEF2U128R64,(PX86FXSTATE pFpuState, PIEMSSERESULT pResult, PCX86XMMREG puSrc1, PCRTFLOAT64U pr64Src2));
3919typedef FNIEMAIMPLFPSSEF2U128R64 *PFNIEMAIMPLFPSSEF2U128R64;
3920
3921typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPAVXF3U128,(PX86XSAVEAREA pExtState, PIEMAVX128RESULT pResult, PCX86XMMREG puSrc1, PCX86XMMREG puSrc2));
3922typedef FNIEMAIMPLFPAVXF3U128 *PFNIEMAIMPLFPAVXF3U128;
3923typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPAVXF3U128R32,(PX86XSAVEAREA pExtState, PIEMAVX128RESULT pResult, PCX86XMMREG puSrc1, PCRTFLOAT32U pr32Src2));
3924typedef FNIEMAIMPLFPAVXF3U128R32 *PFNIEMAIMPLFPAVXF3U128R32;
3925typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPAVXF3U128R64,(PX86XSAVEAREA pExtState, PIEMAVX128RESULT pResult, PCX86XMMREG puSrc1, PCRTFLOAT64U pr64Src2));
3926typedef FNIEMAIMPLFPAVXF3U128R64 *PFNIEMAIMPLFPAVXF3U128R64;
3927
3928typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPAVXF3U256,(PX86XSAVEAREA pExtState, PIEMAVX256RESULT pResult, PCX86YMMREG puSrc1, PCX86YMMREG puSrc2));
3929typedef FNIEMAIMPLFPAVXF3U256 *PFNIEMAIMPLFPAVXF3U256;
3930
3931FNIEMAIMPLFPSSEF2U128 iemAImpl_addps_u128;
3932FNIEMAIMPLFPSSEF2U128 iemAImpl_addpd_u128;
3933FNIEMAIMPLFPSSEF2U128 iemAImpl_mulps_u128;
3934FNIEMAIMPLFPSSEF2U128 iemAImpl_mulpd_u128;
3935FNIEMAIMPLFPSSEF2U128 iemAImpl_subps_u128;
3936FNIEMAIMPLFPSSEF2U128 iemAImpl_subpd_u128;
3937FNIEMAIMPLFPSSEF2U128 iemAImpl_minps_u128;
3938FNIEMAIMPLFPSSEF2U128 iemAImpl_minpd_u128;
3939FNIEMAIMPLFPSSEF2U128 iemAImpl_divps_u128;
3940FNIEMAIMPLFPSSEF2U128 iemAImpl_divpd_u128;
3941FNIEMAIMPLFPSSEF2U128 iemAImpl_maxps_u128;
3942FNIEMAIMPLFPSSEF2U128 iemAImpl_maxpd_u128;
3943FNIEMAIMPLFPSSEF2U128 iemAImpl_haddps_u128;
3944FNIEMAIMPLFPSSEF2U128 iemAImpl_haddpd_u128;
3945FNIEMAIMPLFPSSEF2U128 iemAImpl_hsubps_u128;
3946FNIEMAIMPLFPSSEF2U128 iemAImpl_hsubpd_u128;
3947FNIEMAIMPLFPSSEF2U128 iemAImpl_sqrtps_u128;
3948FNIEMAIMPLFPSSEF2U128 iemAImpl_rsqrtps_u128;
3949FNIEMAIMPLFPSSEF2U128 iemAImpl_sqrtpd_u128;
3950FNIEMAIMPLFPSSEF2U128 iemAImpl_rcpps_u128;
3951FNIEMAIMPLFPSSEF2U128 iemAImpl_addsubps_u128;
3952FNIEMAIMPLFPSSEF2U128 iemAImpl_addsubpd_u128;
3953FNIEMAIMPLFPSSEF2U128 iemAImpl_cvtpd2ps_u128;
3954FNIEMAIMPLFPSSEF2U128 iemAImpl_cvtps2pd_u128;
3955
3956FNIEMAIMPLFPSSEF2U128 iemAImpl_cvtdq2ps_u128;
3957FNIEMAIMPLFPSSEF2U128 iemAImpl_cvtps2dq_u128;
3958FNIEMAIMPLFPSSEF2U128 iemAImpl_cvttps2dq_u128;
3959FNIEMAIMPLFPSSEF2U128 iemAImpl_cvttpd2dq_u128;
3960FNIEMAIMPLFPSSEF2U128 iemAImpl_cvtdq2pd_u128;
3961FNIEMAIMPLFPSSEF2U128 iemAImpl_cvtpd2dq_u128;
3962
3963FNIEMAIMPLFPSSEF2U128R32 iemAImpl_addss_u128_r32;
3964FNIEMAIMPLFPSSEF2U128R64 iemAImpl_addsd_u128_r64;
3965FNIEMAIMPLFPSSEF2U128R32 iemAImpl_mulss_u128_r32;
3966FNIEMAIMPLFPSSEF2U128R64 iemAImpl_mulsd_u128_r64;
3967FNIEMAIMPLFPSSEF2U128R32 iemAImpl_subss_u128_r32;
3968FNIEMAIMPLFPSSEF2U128R64 iemAImpl_subsd_u128_r64;
3969FNIEMAIMPLFPSSEF2U128R32 iemAImpl_minss_u128_r32;
3970FNIEMAIMPLFPSSEF2U128R64 iemAImpl_minsd_u128_r64;
3971FNIEMAIMPLFPSSEF2U128R32 iemAImpl_divss_u128_r32;
3972FNIEMAIMPLFPSSEF2U128R64 iemAImpl_divsd_u128_r64;
3973FNIEMAIMPLFPSSEF2U128R32 iemAImpl_maxss_u128_r32;
3974FNIEMAIMPLFPSSEF2U128R64 iemAImpl_maxsd_u128_r64;
3975FNIEMAIMPLFPSSEF2U128R32 iemAImpl_cvtss2sd_u128_r32;
3976FNIEMAIMPLFPSSEF2U128R64 iemAImpl_cvtsd2ss_u128_r64;
3977FNIEMAIMPLFPSSEF2U128R32 iemAImpl_sqrtss_u128_r32;
3978FNIEMAIMPLFPSSEF2U128R64 iemAImpl_sqrtsd_u128_r64;
3979FNIEMAIMPLFPSSEF2U128R32 iemAImpl_rsqrtss_u128_r32;
3980FNIEMAIMPLFPSSEF2U128R32 iemAImpl_rcpss_u128_r32;
3981
3982FNIEMAIMPLFPAVXF3U128 iemAImpl_vaddps_u128, iemAImpl_vaddps_u128_fallback;
3983FNIEMAIMPLFPAVXF3U128 iemAImpl_vaddpd_u128, iemAImpl_vaddpd_u128_fallback;
3984FNIEMAIMPLFPAVXF3U128 iemAImpl_vmulps_u128, iemAImpl_vmulps_u128_fallback;
3985FNIEMAIMPLFPAVXF3U128 iemAImpl_vmulpd_u128, iemAImpl_vmulpd_u128_fallback;
3986FNIEMAIMPLFPAVXF3U128 iemAImpl_vsubps_u128, iemAImpl_vsubps_u128_fallback;
3987FNIEMAIMPLFPAVXF3U128 iemAImpl_vsubpd_u128, iemAImpl_vsubpd_u128_fallback;
3988FNIEMAIMPLFPAVXF3U128 iemAImpl_vminps_u128, iemAImpl_vminps_u128_fallback;
3989FNIEMAIMPLFPAVXF3U128 iemAImpl_vminpd_u128, iemAImpl_vminpd_u128_fallback;
3990FNIEMAIMPLFPAVXF3U128 iemAImpl_vdivps_u128, iemAImpl_vdivps_u128_fallback;
3991FNIEMAIMPLFPAVXF3U128 iemAImpl_vdivpd_u128, iemAImpl_vdivpd_u128_fallback;
3992FNIEMAIMPLFPAVXF3U128 iemAImpl_vmaxps_u128, iemAImpl_vmaxps_u128_fallback;
3993FNIEMAIMPLFPAVXF3U128 iemAImpl_vmaxpd_u128, iemAImpl_vmaxpd_u128_fallback;
3994FNIEMAIMPLFPAVXF3U128 iemAImpl_vhaddps_u128, iemAImpl_vhaddps_u128_fallback;
3995FNIEMAIMPLFPAVXF3U128 iemAImpl_vhaddpd_u128, iemAImpl_vhaddpd_u128_fallback;
3996FNIEMAIMPLFPAVXF3U128 iemAImpl_vhsubps_u128, iemAImpl_vhsubps_u128_fallback;
3997FNIEMAIMPLFPAVXF3U128 iemAImpl_vhsubpd_u128, iemAImpl_vhsubpd_u128_fallback;
3998FNIEMAIMPLFPAVXF3U128 iemAImpl_vsqrtps_u128, iemAImpl_vsqrtps_u128_fallback;
3999FNIEMAIMPLFPAVXF3U128 iemAImpl_vsqrtpd_u128, iemAImpl_vsqrtpd_u128_fallback;
4000FNIEMAIMPLFPAVXF3U128 iemAImpl_vaddsubps_u128, iemAImpl_vaddsubps_u128_fallback;
4001FNIEMAIMPLFPAVXF3U128 iemAImpl_vaddsubpd_u128, iemAImpl_vaddsubpd_u128_fallback;
4002FNIEMAIMPLFPAVXF3U128 iemAImpl_vcvtpd2ps_u128, iemAImpl_vcvtpd2ps_u128_fallback;
4003FNIEMAIMPLFPAVXF3U128 iemAImpl_vcvtps2pd_u128, iemAImpl_vcvtps2pd_u128_fallback;
4004
4005FNIEMAIMPLFPAVXF3U128R32 iemAImpl_vaddss_u128_r32, iemAImpl_vaddss_u128_r32_fallback;
4006FNIEMAIMPLFPAVXF3U128R64 iemAImpl_vaddsd_u128_r64, iemAImpl_vaddsd_u128_r64_fallback;
4007FNIEMAIMPLFPAVXF3U128R32 iemAImpl_vmulss_u128_r32, iemAImpl_vmulss_u128_r32_fallback;
4008FNIEMAIMPLFPAVXF3U128R64 iemAImpl_vmulsd_u128_r64, iemAImpl_vmulsd_u128_r64_fallback;
4009FNIEMAIMPLFPAVXF3U128R32 iemAImpl_vsubss_u128_r32, iemAImpl_vsubss_u128_r32_fallback;
4010FNIEMAIMPLFPAVXF3U128R64 iemAImpl_vsubsd_u128_r64, iemAImpl_vsubsd_u128_r64_fallback;
4011FNIEMAIMPLFPAVXF3U128R32 iemAImpl_vminss_u128_r32, iemAImpl_vminss_u128_r32_fallback;
4012FNIEMAIMPLFPAVXF3U128R64 iemAImpl_vminsd_u128_r64, iemAImpl_vminsd_u128_r64_fallback;
4013FNIEMAIMPLFPAVXF3U128R32 iemAImpl_vdivss_u128_r32, iemAImpl_vdivss_u128_r32_fallback;
4014FNIEMAIMPLFPAVXF3U128R64 iemAImpl_vdivsd_u128_r64, iemAImpl_vdivsd_u128_r64_fallback;
4015FNIEMAIMPLFPAVXF3U128R32 iemAImpl_vmaxss_u128_r32, iemAImpl_vmaxss_u128_r32_fallback;
4016FNIEMAIMPLFPAVXF3U128R64 iemAImpl_vmaxsd_u128_r64, iemAImpl_vmaxsd_u128_r64_fallback;
4017FNIEMAIMPLFPAVXF3U128R32 iemAImpl_vsqrtss_u128_r32, iemAImpl_vsqrtss_u128_r32_fallback;
4018FNIEMAIMPLFPAVXF3U128R64 iemAImpl_vsqrtsd_u128_r64, iemAImpl_vsqrtsd_u128_r64_fallback;
4019
4020FNIEMAIMPLFPAVXF3U256 iemAImpl_vaddps_u256, iemAImpl_vaddps_u256_fallback;
4021FNIEMAIMPLFPAVXF3U256 iemAImpl_vaddpd_u256, iemAImpl_vaddpd_u256_fallback;
4022FNIEMAIMPLFPAVXF3U256 iemAImpl_vmulps_u256, iemAImpl_vmulps_u256_fallback;
4023FNIEMAIMPLFPAVXF3U256 iemAImpl_vmulpd_u256, iemAImpl_vmulpd_u256_fallback;
4024FNIEMAIMPLFPAVXF3U256 iemAImpl_vsubps_u256, iemAImpl_vsubps_u256_fallback;
4025FNIEMAIMPLFPAVXF3U256 iemAImpl_vsubpd_u256, iemAImpl_vsubpd_u256_fallback;
4026FNIEMAIMPLFPAVXF3U256 iemAImpl_vminps_u256, iemAImpl_vminps_u256_fallback;
4027FNIEMAIMPLFPAVXF3U256 iemAImpl_vminpd_u256, iemAImpl_vminpd_u256_fallback;
4028FNIEMAIMPLFPAVXF3U256 iemAImpl_vdivps_u256, iemAImpl_vdivps_u256_fallback;
4029FNIEMAIMPLFPAVXF3U256 iemAImpl_vdivpd_u256, iemAImpl_vdivpd_u256_fallback;
4030FNIEMAIMPLFPAVXF3U256 iemAImpl_vmaxps_u256, iemAImpl_vmaxps_u256_fallback;
4031FNIEMAIMPLFPAVXF3U256 iemAImpl_vmaxpd_u256, iemAImpl_vmaxpd_u256_fallback;
4032FNIEMAIMPLFPAVXF3U256 iemAImpl_vhaddps_u256, iemAImpl_vhaddps_u256_fallback;
4033FNIEMAIMPLFPAVXF3U256 iemAImpl_vhaddpd_u256, iemAImpl_vhaddpd_u256_fallback;
4034FNIEMAIMPLFPAVXF3U256 iemAImpl_vhsubps_u256, iemAImpl_vhsubps_u256_fallback;
4035FNIEMAIMPLFPAVXF3U256 iemAImpl_vhsubpd_u256, iemAImpl_vhsubpd_u256_fallback;
4036FNIEMAIMPLFPAVXF3U256 iemAImpl_vhaddsubps_u256, iemAImpl_vhaddsubps_u256_fallback;
4037FNIEMAIMPLFPAVXF3U256 iemAImpl_vhaddsubpd_u256, iemAImpl_vhaddsubpd_u256_fallback;
4038FNIEMAIMPLFPAVXF3U256 iemAImpl_vcvtpd2ps_u256, iemAImpl_vcvtpd2ps_u256_fallback;
4039FNIEMAIMPLFPAVXF3U256 iemAImpl_vcvtps2pd_u256, iemAImpl_vcvtps2pd_u256_fallback;
4040/** @} */
4041
4042/** @name C instruction implementations for anything slightly complicated.
4043 * @{ */
4044
4045/**
4046 * For typedef'ing or declaring a C instruction implementation function taking
4047 * no extra arguments.
4048 *
4049 * @param a_Name The name of the type.
4050 */
4051# define IEM_CIMPL_DECL_TYPE_0(a_Name) \
4052 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr))
4053/**
4054 * For defining a C instruction implementation function taking no extra
4055 * arguments.
4056 *
4057 * @param a_Name The name of the function
4058 */
4059# define IEM_CIMPL_DEF_0(a_Name) \
4060 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr))
4061/**
4062 * Prototype version of IEM_CIMPL_DEF_0.
4063 */
4064# define IEM_CIMPL_PROTO_0(a_Name) \
4065 IEM_DECL_IMPL_PROTO(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr))
4066/**
4067 * For calling a C instruction implementation function taking no extra
4068 * arguments.
4069 *
4070 * This special call macro adds default arguments to the call and allow us to
4071 * change these later.
4072 *
4073 * @param a_fn The name of the function.
4074 */
4075# define IEM_CIMPL_CALL_0(a_fn) a_fn(pVCpu, cbInstr)
4076
4077/** Type for a C instruction implementation function taking no extra
4078 * arguments. */
4079typedef IEM_CIMPL_DECL_TYPE_0(FNIEMCIMPL0);
4080/** Function pointer type for a C instruction implementation function taking
4081 * no extra arguments. */
4082typedef FNIEMCIMPL0 *PFNIEMCIMPL0;
4083
4084/**
4085 * For typedef'ing or declaring a C instruction implementation function taking
4086 * one extra argument.
4087 *
4088 * @param a_Name The name of the type.
4089 * @param a_Type0 The argument type.
4090 * @param a_Arg0 The argument name.
4091 */
4092# define IEM_CIMPL_DECL_TYPE_1(a_Name, a_Type0, a_Arg0) \
4093 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0))
4094/**
4095 * For defining a C instruction implementation function taking one extra
4096 * argument.
4097 *
4098 * @param a_Name The name of the function
4099 * @param a_Type0 The argument type.
4100 * @param a_Arg0 The argument name.
4101 */
4102# define IEM_CIMPL_DEF_1(a_Name, a_Type0, a_Arg0) \
4103 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0))
4104/**
4105 * Prototype version of IEM_CIMPL_DEF_1.
4106 */
4107# define IEM_CIMPL_PROTO_1(a_Name, a_Type0, a_Arg0) \
4108 IEM_DECL_IMPL_PROTO(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0))
4109/**
4110 * For calling a C instruction implementation function taking one extra
4111 * argument.
4112 *
4113 * This special call macro adds default arguments to the call and allow us to
4114 * change these later.
4115 *
4116 * @param a_fn The name of the function.
4117 * @param a0 The name of the 1st argument.
4118 */
4119# define IEM_CIMPL_CALL_1(a_fn, a0) a_fn(pVCpu, cbInstr, (a0))
4120
4121/**
4122 * For typedef'ing or declaring a C instruction implementation function taking
4123 * two extra arguments.
4124 *
4125 * @param a_Name The name of the type.
4126 * @param a_Type0 The type of the 1st argument
4127 * @param a_Arg0 The name of the 1st argument.
4128 * @param a_Type1 The type of the 2nd argument.
4129 * @param a_Arg1 The name of the 2nd argument.
4130 */
4131# define IEM_CIMPL_DECL_TYPE_2(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1) \
4132 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1))
4133/**
4134 * For defining a C instruction implementation function taking two extra
4135 * arguments.
4136 *
4137 * @param a_Name The name of the function.
4138 * @param a_Type0 The type of the 1st argument
4139 * @param a_Arg0 The name of the 1st argument.
4140 * @param a_Type1 The type of the 2nd argument.
4141 * @param a_Arg1 The name of the 2nd argument.
4142 */
4143# define IEM_CIMPL_DEF_2(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1) \
4144 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1))
4145/**
4146 * Prototype version of IEM_CIMPL_DEF_2.
4147 */
4148# define IEM_CIMPL_PROTO_2(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1) \
4149 IEM_DECL_IMPL_PROTO(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1))
4150/**
4151 * For calling a C instruction implementation function taking two extra
4152 * arguments.
4153 *
4154 * This special call macro adds default arguments to the call and allow us to
4155 * change these later.
4156 *
4157 * @param a_fn The name of the function.
4158 * @param a0 The name of the 1st argument.
4159 * @param a1 The name of the 2nd argument.
4160 */
4161# define IEM_CIMPL_CALL_2(a_fn, a0, a1) a_fn(pVCpu, cbInstr, (a0), (a1))
4162
4163/**
4164 * For typedef'ing or declaring a C instruction implementation function taking
4165 * three extra arguments.
4166 *
4167 * @param a_Name The name of the type.
4168 * @param a_Type0 The type of the 1st argument
4169 * @param a_Arg0 The name of the 1st argument.
4170 * @param a_Type1 The type of the 2nd argument.
4171 * @param a_Arg1 The name of the 2nd argument.
4172 * @param a_Type2 The type of the 3rd argument.
4173 * @param a_Arg2 The name of the 3rd argument.
4174 */
4175# define IEM_CIMPL_DECL_TYPE_3(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2) \
4176 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, a_Type2 a_Arg2))
4177/**
4178 * For defining a C instruction implementation function taking three extra
4179 * arguments.
4180 *
4181 * @param a_Name The name of the function.
4182 * @param a_Type0 The type of the 1st argument
4183 * @param a_Arg0 The name of the 1st argument.
4184 * @param a_Type1 The type of the 2nd argument.
4185 * @param a_Arg1 The name of the 2nd argument.
4186 * @param a_Type2 The type of the 3rd argument.
4187 * @param a_Arg2 The name of the 3rd argument.
4188 */
4189# define IEM_CIMPL_DEF_3(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2) \
4190 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, a_Type2 a_Arg2))
4191/**
4192 * Prototype version of IEM_CIMPL_DEF_3.
4193 */
4194# define IEM_CIMPL_PROTO_3(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2) \
4195 IEM_DECL_IMPL_PROTO(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, a_Type2 a_Arg2))
4196/**
4197 * For calling a C instruction implementation function taking three extra
4198 * arguments.
4199 *
4200 * This special call macro adds default arguments to the call and allow us to
4201 * change these later.
4202 *
4203 * @param a_fn The name of the function.
4204 * @param a0 The name of the 1st argument.
4205 * @param a1 The name of the 2nd argument.
4206 * @param a2 The name of the 3rd argument.
4207 */
4208# define IEM_CIMPL_CALL_3(a_fn, a0, a1, a2) a_fn(pVCpu, cbInstr, (a0), (a1), (a2))
4209
4210
4211/**
4212 * For typedef'ing or declaring a C instruction implementation function taking
4213 * four extra arguments.
4214 *
4215 * @param a_Name The name of the type.
4216 * @param a_Type0 The type of the 1st argument
4217 * @param a_Arg0 The name of the 1st argument.
4218 * @param a_Type1 The type of the 2nd argument.
4219 * @param a_Arg1 The name of the 2nd argument.
4220 * @param a_Type2 The type of the 3rd argument.
4221 * @param a_Arg2 The name of the 3rd argument.
4222 * @param a_Type3 The type of the 4th argument.
4223 * @param a_Arg3 The name of the 4th argument.
4224 */
4225# define IEM_CIMPL_DECL_TYPE_4(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2, a_Type3, a_Arg3) \
4226 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))
4227/**
4228 * For defining a C instruction implementation function taking four extra
4229 * arguments.
4230 *
4231 * @param a_Name The name of the function.
4232 * @param a_Type0 The type of the 1st argument
4233 * @param a_Arg0 The name of the 1st argument.
4234 * @param a_Type1 The type of the 2nd argument.
4235 * @param a_Arg1 The name of the 2nd argument.
4236 * @param a_Type2 The type of the 3rd argument.
4237 * @param a_Arg2 The name of the 3rd argument.
4238 * @param a_Type3 The type of the 4th argument.
4239 * @param a_Arg3 The name of the 4th argument.
4240 */
4241# define IEM_CIMPL_DEF_4(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2, a_Type3, a_Arg3) \
4242 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, \
4243 a_Type2 a_Arg2, a_Type3 a_Arg3))
4244/**
4245 * Prototype version of IEM_CIMPL_DEF_4.
4246 */
4247# define IEM_CIMPL_PROTO_4(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2, a_Type3, a_Arg3) \
4248 IEM_DECL_IMPL_PROTO(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, \
4249 a_Type2 a_Arg2, a_Type3 a_Arg3))
4250/**
4251 * For calling a C instruction implementation function taking four extra
4252 * arguments.
4253 *
4254 * This special call macro adds default arguments to the call and allow us to
4255 * change these later.
4256 *
4257 * @param a_fn The name of the function.
4258 * @param a0 The name of the 1st argument.
4259 * @param a1 The name of the 2nd argument.
4260 * @param a2 The name of the 3rd argument.
4261 * @param a3 The name of the 4th argument.
4262 */
4263# define IEM_CIMPL_CALL_4(a_fn, a0, a1, a2, a3) a_fn(pVCpu, cbInstr, (a0), (a1), (a2), (a3))
4264
4265
4266/**
4267 * For typedef'ing or declaring a C instruction implementation function taking
4268 * five extra arguments.
4269 *
4270 * @param a_Name The name of the type.
4271 * @param a_Type0 The type of the 1st argument
4272 * @param a_Arg0 The name of the 1st argument.
4273 * @param a_Type1 The type of the 2nd argument.
4274 * @param a_Arg1 The name of the 2nd argument.
4275 * @param a_Type2 The type of the 3rd argument.
4276 * @param a_Arg2 The name of the 3rd argument.
4277 * @param a_Type3 The type of the 4th argument.
4278 * @param a_Arg3 The name of the 4th argument.
4279 * @param a_Type4 The type of the 5th argument.
4280 * @param a_Arg4 The name of the 5th argument.
4281 */
4282# 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) \
4283 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, \
4284 a_Type0 a_Arg0, a_Type1 a_Arg1, a_Type2 a_Arg2, \
4285 a_Type3 a_Arg3, a_Type4 a_Arg4))
4286/**
4287 * For defining a C instruction implementation function taking five extra
4288 * arguments.
4289 *
4290 * @param a_Name The name of the function.
4291 * @param a_Type0 The type of the 1st argument
4292 * @param a_Arg0 The name of the 1st argument.
4293 * @param a_Type1 The type of the 2nd argument.
4294 * @param a_Arg1 The name of the 2nd argument.
4295 * @param a_Type2 The type of the 3rd argument.
4296 * @param a_Arg2 The name of the 3rd argument.
4297 * @param a_Type3 The type of the 4th argument.
4298 * @param a_Arg3 The name of the 4th argument.
4299 * @param a_Type4 The type of the 5th argument.
4300 * @param a_Arg4 The name of the 5th argument.
4301 */
4302# 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) \
4303 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, \
4304 a_Type2 a_Arg2, a_Type3 a_Arg3, a_Type4 a_Arg4))
4305/**
4306 * Prototype version of IEM_CIMPL_DEF_5.
4307 */
4308# 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) \
4309 IEM_DECL_IMPL_PROTO(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, \
4310 a_Type2 a_Arg2, a_Type3 a_Arg3, a_Type4 a_Arg4))
4311/**
4312 * For calling a C instruction implementation function taking five extra
4313 * arguments.
4314 *
4315 * This special call macro adds default arguments to the call and allow us to
4316 * change these later.
4317 *
4318 * @param a_fn The name of the function.
4319 * @param a0 The name of the 1st argument.
4320 * @param a1 The name of the 2nd argument.
4321 * @param a2 The name of the 3rd argument.
4322 * @param a3 The name of the 4th argument.
4323 * @param a4 The name of the 5th argument.
4324 */
4325# define IEM_CIMPL_CALL_5(a_fn, a0, a1, a2, a3, a4) a_fn(pVCpu, cbInstr, (a0), (a1), (a2), (a3), (a4))
4326
4327/** @} */
4328
4329
4330/** @name Opcode Decoder Function Types.
4331 * @{ */
4332
4333/** @typedef PFNIEMOP
4334 * Pointer to an opcode decoder function.
4335 */
4336
4337/** @def FNIEMOP_DEF
4338 * Define an opcode decoder function.
4339 *
4340 * We're using macors for this so that adding and removing parameters as well as
4341 * tweaking compiler specific attributes becomes easier. See FNIEMOP_CALL
4342 *
4343 * @param a_Name The function name.
4344 */
4345
4346/** @typedef PFNIEMOPRM
4347 * Pointer to an opcode decoder function with RM byte.
4348 */
4349
4350/** @def FNIEMOPRM_DEF
4351 * Define an opcode decoder function with RM byte.
4352 *
4353 * We're using macors for this so that adding and removing parameters as well as
4354 * tweaking compiler specific attributes becomes easier. See FNIEMOP_CALL_1
4355 *
4356 * @param a_Name The function name.
4357 */
4358
4359#if defined(__GNUC__) && defined(RT_ARCH_X86)
4360typedef VBOXSTRICTRC (__attribute__((__fastcall__)) * PFNIEMOP)(PVMCPUCC pVCpu);
4361typedef VBOXSTRICTRC (__attribute__((__fastcall__)) * PFNIEMOPRM)(PVMCPUCC pVCpu, uint8_t bRm);
4362# define FNIEMOP_DEF(a_Name) \
4363 IEM_STATIC VBOXSTRICTRC __attribute__((__fastcall__, __nothrow__)) a_Name(PVMCPUCC pVCpu)
4364# define FNIEMOP_DEF_1(a_Name, a_Type0, a_Name0) \
4365 IEM_STATIC VBOXSTRICTRC __attribute__((__fastcall__, __nothrow__)) a_Name(PVMCPUCC pVCpu, a_Type0 a_Name0)
4366# define FNIEMOP_DEF_2(a_Name, a_Type0, a_Name0, a_Type1, a_Name1) \
4367 IEM_STATIC VBOXSTRICTRC __attribute__((__fastcall__, __nothrow__)) a_Name(PVMCPUCC pVCpu, a_Type0 a_Name0, a_Type1 a_Name1)
4368
4369#elif defined(_MSC_VER) && defined(RT_ARCH_X86)
4370typedef VBOXSTRICTRC (__fastcall * PFNIEMOP)(PVMCPUCC pVCpu);
4371typedef VBOXSTRICTRC (__fastcall * PFNIEMOPRM)(PVMCPUCC pVCpu, uint8_t bRm);
4372# define FNIEMOP_DEF(a_Name) \
4373 IEM_STATIC /*__declspec(naked)*/ VBOXSTRICTRC __fastcall a_Name(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP
4374# define FNIEMOP_DEF_1(a_Name, a_Type0, a_Name0) \
4375 IEM_STATIC /*__declspec(naked)*/ VBOXSTRICTRC __fastcall a_Name(PVMCPUCC pVCpu, a_Type0 a_Name0) IEM_NOEXCEPT_MAY_LONGJMP
4376# define FNIEMOP_DEF_2(a_Name, a_Type0, a_Name0, a_Type1, a_Name1) \
4377 IEM_STATIC /*__declspec(naked)*/ VBOXSTRICTRC __fastcall a_Name(PVMCPUCC pVCpu, a_Type0 a_Name0, a_Type1 a_Name1) IEM_NOEXCEPT_MAY_LONGJMP
4378
4379#elif defined(__GNUC__) && !defined(IEM_WITH_THROW_CATCH)
4380typedef VBOXSTRICTRC (* PFNIEMOP)(PVMCPUCC pVCpu);
4381typedef VBOXSTRICTRC (* PFNIEMOPRM)(PVMCPUCC pVCpu, uint8_t bRm);
4382# define FNIEMOP_DEF(a_Name) \
4383 IEM_STATIC VBOXSTRICTRC __attribute__((__nothrow__)) a_Name(PVMCPUCC pVCpu)
4384# define FNIEMOP_DEF_1(a_Name, a_Type0, a_Name0) \
4385 IEM_STATIC VBOXSTRICTRC __attribute__((__nothrow__)) a_Name(PVMCPUCC pVCpu, a_Type0 a_Name0)
4386# define FNIEMOP_DEF_2(a_Name, a_Type0, a_Name0, a_Type1, a_Name1) \
4387 IEM_STATIC VBOXSTRICTRC __attribute__((__nothrow__)) a_Name(PVMCPUCC pVCpu, a_Type0 a_Name0, a_Type1 a_Name1)
4388
4389#else
4390typedef VBOXSTRICTRC (* PFNIEMOP)(PVMCPUCC pVCpu);
4391typedef VBOXSTRICTRC (* PFNIEMOPRM)(PVMCPUCC pVCpu, uint8_t bRm);
4392# define FNIEMOP_DEF(a_Name) \
4393 IEM_STATIC VBOXSTRICTRC a_Name(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP
4394# define FNIEMOP_DEF_1(a_Name, a_Type0, a_Name0) \
4395 IEM_STATIC VBOXSTRICTRC a_Name(PVMCPUCC pVCpu, a_Type0 a_Name0) IEM_NOEXCEPT_MAY_LONGJMP
4396# define FNIEMOP_DEF_2(a_Name, a_Type0, a_Name0, a_Type1, a_Name1) \
4397 IEM_STATIC VBOXSTRICTRC a_Name(PVMCPUCC pVCpu, a_Type0 a_Name0, a_Type1 a_Name1) IEM_NOEXCEPT_MAY_LONGJMP
4398
4399#endif
4400#define FNIEMOPRM_DEF(a_Name) FNIEMOP_DEF_1(a_Name, uint8_t, bRm)
4401
4402/**
4403 * Call an opcode decoder function.
4404 *
4405 * We're using macors for this so that adding and removing parameters can be
4406 * done as we please. See FNIEMOP_DEF.
4407 */
4408#define FNIEMOP_CALL(a_pfn) (a_pfn)(pVCpu)
4409
4410/**
4411 * Call a common opcode decoder function taking one extra argument.
4412 *
4413 * We're using macors for this so that adding and removing parameters can be
4414 * done as we please. See FNIEMOP_DEF_1.
4415 */
4416#define FNIEMOP_CALL_1(a_pfn, a0) (a_pfn)(pVCpu, a0)
4417
4418/**
4419 * Call a common opcode decoder function taking one extra argument.
4420 *
4421 * We're using macors for this so that adding and removing parameters can be
4422 * done as we please. See FNIEMOP_DEF_1.
4423 */
4424#define FNIEMOP_CALL_2(a_pfn, a0, a1) (a_pfn)(pVCpu, a0, a1)
4425/** @} */
4426
4427
4428/** @name Misc Helpers
4429 * @{ */
4430
4431/** Used to shut up GCC warnings about variables that 'may be used uninitialized'
4432 * due to GCC lacking knowledge about the value range of a switch. */
4433#if RT_CPLUSPLUS_PREREQ(202000)
4434# define IEM_NOT_REACHED_DEFAULT_CASE_RET() default: [[unlikely]] AssertFailedReturn(VERR_IPE_NOT_REACHED_DEFAULT_CASE)
4435#else
4436# define IEM_NOT_REACHED_DEFAULT_CASE_RET() default: AssertFailedReturn(VERR_IPE_NOT_REACHED_DEFAULT_CASE)
4437#endif
4438
4439/** Variant of IEM_NOT_REACHED_DEFAULT_CASE_RET that returns a custom value. */
4440#if RT_CPLUSPLUS_PREREQ(202000)
4441# define IEM_NOT_REACHED_DEFAULT_CASE_RET2(a_RetValue) default: [[unlikely]] AssertFailedReturn(a_RetValue)
4442#else
4443# define IEM_NOT_REACHED_DEFAULT_CASE_RET2(a_RetValue) default: AssertFailedReturn(a_RetValue)
4444#endif
4445
4446/**
4447 * Returns IEM_RETURN_ASPECT_NOT_IMPLEMENTED, and in debug builds logs the
4448 * occation.
4449 */
4450#ifdef LOG_ENABLED
4451# define IEM_RETURN_ASPECT_NOT_IMPLEMENTED() \
4452 do { \
4453 /*Log*/ LogAlways(("%s: returning IEM_RETURN_ASPECT_NOT_IMPLEMENTED (line %d)\n", __FUNCTION__, __LINE__)); \
4454 return VERR_IEM_ASPECT_NOT_IMPLEMENTED; \
4455 } while (0)
4456#else
4457# define IEM_RETURN_ASPECT_NOT_IMPLEMENTED() \
4458 return VERR_IEM_ASPECT_NOT_IMPLEMENTED
4459#endif
4460
4461/**
4462 * Returns IEM_RETURN_ASPECT_NOT_IMPLEMENTED, and in debug builds logs the
4463 * occation using the supplied logger statement.
4464 *
4465 * @param a_LoggerArgs What to log on failure.
4466 */
4467#ifdef LOG_ENABLED
4468# define IEM_RETURN_ASPECT_NOT_IMPLEMENTED_LOG(a_LoggerArgs) \
4469 do { \
4470 LogAlways((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); LogAlways(a_LoggerArgs); \
4471 /*LogFunc(a_LoggerArgs);*/ \
4472 return VERR_IEM_ASPECT_NOT_IMPLEMENTED; \
4473 } while (0)
4474#else
4475# define IEM_RETURN_ASPECT_NOT_IMPLEMENTED_LOG(a_LoggerArgs) \
4476 return VERR_IEM_ASPECT_NOT_IMPLEMENTED
4477#endif
4478
4479/**
4480 * Gets the CPU mode (from fExec) as a IEMMODE value.
4481 *
4482 * @returns IEMMODE
4483 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
4484 */
4485#define IEM_GET_CPU_MODE(a_pVCpu) ((a_pVCpu)->iem.s.fExec & IEM_F_MODE_CPUMODE_MASK)
4486
4487/**
4488 * Check if we're currently executing in real or virtual 8086 mode.
4489 *
4490 * @returns @c true if it is, @c false if not.
4491 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
4492 */
4493#define IEM_IS_REAL_OR_V86_MODE(a_pVCpu) (( ((a_pVCpu)->iem.s.fExec ^ IEM_F_MODE_X86_PROT_MASK) \
4494 & (IEM_F_MODE_X86_V86_MASK | IEM_F_MODE_X86_PROT_MASK)) != 0)
4495
4496/**
4497 * Check if we're currently executing in virtual 8086 mode.
4498 *
4499 * @returns @c true if it is, @c false if not.
4500 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
4501 */
4502#define IEM_IS_V86_MODE(a_pVCpu) (((a_pVCpu)->iem.s.fExec & IEM_F_MODE_X86_V86_MASK) != 0)
4503
4504/**
4505 * Check if we're currently executing in long mode.
4506 *
4507 * @returns @c true if it is, @c false if not.
4508 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
4509 */
4510#define IEM_IS_LONG_MODE(a_pVCpu) (CPUMIsGuestInLongModeEx(IEM_GET_CTX(a_pVCpu)))
4511
4512/**
4513 * Check if we're currently executing in a 16-bit code segment.
4514 *
4515 * @returns @c true if it is, @c false if not.
4516 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
4517 */
4518#define IEM_IS_16BIT_CODE(a_pVCpu) (IEM_GET_CPU_MODE(a_pVCpu) == IEMMODE_16BIT)
4519
4520/**
4521 * Check if we're currently executing in a 32-bit code segment.
4522 *
4523 * @returns @c true if it is, @c false if not.
4524 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
4525 */
4526#define IEM_IS_32BIT_CODE(a_pVCpu) (IEM_GET_CPU_MODE(a_pVCpu) == IEMMODE_32BIT)
4527
4528/**
4529 * Check if we're currently executing in a 64-bit code segment.
4530 *
4531 * @returns @c true if it is, @c false if not.
4532 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
4533 */
4534#define IEM_IS_64BIT_CODE(a_pVCpu) (IEM_GET_CPU_MODE(a_pVCpu) == IEMMODE_64BIT)
4535
4536/**
4537 * Check if we're currently executing in real mode.
4538 *
4539 * @returns @c true if it is, @c false if not.
4540 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
4541 */
4542#define IEM_IS_REAL_MODE(a_pVCpu) (!((a_pVCpu)->iem.s.fExec & IEM_F_MODE_X86_PROT_MASK))
4543
4544/**
4545 * Gets the current protection level (CPL).
4546 *
4547 * @returns 0..3
4548 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
4549 */
4550#define IEM_GET_CPL(a_pVCpu) (((a_pVCpu)->iem.s.fExec >> IEM_F_X86_CPL_SHIFT) & IEM_F_X86_CPL_SMASK)
4551
4552/**
4553 * Sets the current protection level (CPL).
4554 *
4555 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
4556 */
4557#define IEM_SET_CPL(a_pVCpu, a_uCpl) \
4558 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)
4559
4560/**
4561 * Returns a (const) pointer to the CPUMFEATURES for the guest CPU.
4562 * @returns PCCPUMFEATURES
4563 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
4564 */
4565#define IEM_GET_GUEST_CPU_FEATURES(a_pVCpu) (&((a_pVCpu)->CTX_SUFF(pVM)->cpum.ro.GuestFeatures))
4566
4567/**
4568 * Returns a (const) pointer to the CPUMFEATURES for the host CPU.
4569 * @returns PCCPUMFEATURES
4570 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
4571 */
4572#define IEM_GET_HOST_CPU_FEATURES(a_pVCpu) (&g_CpumHostFeatures.s)
4573
4574/**
4575 * Evaluates to true if we're presenting an Intel CPU to the guest.
4576 */
4577#define IEM_IS_GUEST_CPU_INTEL(a_pVCpu) ( (a_pVCpu)->iem.s.enmCpuVendor == CPUMCPUVENDOR_INTEL )
4578
4579/**
4580 * Evaluates to true if we're presenting an AMD CPU to the guest.
4581 */
4582#define IEM_IS_GUEST_CPU_AMD(a_pVCpu) ( (a_pVCpu)->iem.s.enmCpuVendor == CPUMCPUVENDOR_AMD || (a_pVCpu)->iem.s.enmCpuVendor == CPUMCPUVENDOR_HYGON )
4583
4584/**
4585 * Check if the address is canonical.
4586 */
4587#define IEM_IS_CANONICAL(a_u64Addr) X86_IS_CANONICAL(a_u64Addr)
4588
4589/** Checks if the ModR/M byte is in register mode or not. */
4590#define IEM_IS_MODRM_REG_MODE(a_bRm) ( ((a_bRm) & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT) )
4591/** Checks if the ModR/M byte is in memory mode or not. */
4592#define IEM_IS_MODRM_MEM_MODE(a_bRm) ( ((a_bRm) & X86_MODRM_MOD_MASK) != (3 << X86_MODRM_MOD_SHIFT) )
4593
4594/**
4595 * Gets the register (reg) part of a ModR/M encoding, with REX.R added in.
4596 *
4597 * For use during decoding.
4598 */
4599#define IEM_GET_MODRM_REG(a_pVCpu, a_bRm) ( (((a_bRm) >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | (a_pVCpu)->iem.s.uRexReg )
4600/**
4601 * Gets the r/m part of a ModR/M encoding as a register index, with REX.B added in.
4602 *
4603 * For use during decoding.
4604 */
4605#define IEM_GET_MODRM_RM(a_pVCpu, a_bRm) ( ((a_bRm) & X86_MODRM_RM_MASK) | (a_pVCpu)->iem.s.uRexB )
4606
4607/**
4608 * Gets the register (reg) part of a ModR/M encoding, without REX.R.
4609 *
4610 * For use during decoding.
4611 */
4612#define IEM_GET_MODRM_REG_8(a_bRm) ( (((a_bRm) >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) )
4613/**
4614 * Gets the r/m part of a ModR/M encoding as a register index, without REX.B.
4615 *
4616 * For use during decoding.
4617 */
4618#define IEM_GET_MODRM_RM_8(a_bRm) ( ((a_bRm) & X86_MODRM_RM_MASK) )
4619
4620/**
4621 * Gets the register (reg) part of a ModR/M encoding as an extended 8-bit
4622 * register index, with REX.R added in.
4623 *
4624 * For use during decoding.
4625 *
4626 * @see iemGRegRefU8Ex, iemGRegFetchU8Ex, iemGRegStoreU8Ex
4627 */
4628#define IEM_GET_MODRM_REG_EX8(a_pVCpu, a_bRm) \
4629 ( (pVCpu->iem.s.fPrefixes & IEM_OP_PRF_REX) \
4630 || !((a_bRm) & (4 << X86_MODRM_REG_SHIFT)) /* IEM_GET_MODRM_REG(pVCpu, a_bRm) < 4 */ \
4631 ? IEM_GET_MODRM_REG(pVCpu, a_bRm) : (((a_bRm) >> X86_MODRM_REG_SHIFT) & 3) | 16)
4632/**
4633 * Gets the r/m part of a ModR/M encoding as an extended 8-bit register index,
4634 * with REX.B added in.
4635 *
4636 * For use during decoding.
4637 *
4638 * @see iemGRegRefU8Ex, iemGRegFetchU8Ex, iemGRegStoreU8Ex
4639 */
4640#define IEM_GET_MODRM_RM_EX8(a_pVCpu, a_bRm) \
4641 ( (pVCpu->iem.s.fPrefixes & IEM_OP_PRF_REX) \
4642 || !((a_bRm) & 4) /* IEM_GET_MODRM_RM(pVCpu, a_bRm) < 4 */ \
4643 ? IEM_GET_MODRM_RM(pVCpu, a_bRm) : ((a_bRm) & 3) | 16)
4644
4645/**
4646 * Combines the prefix REX and ModR/M byte for passing to
4647 * iemOpHlpCalcRmEffAddrThreadedAddr64().
4648 *
4649 * @returns The ModRM byte but with bit 3 set to REX.B and bit 4 to REX.X.
4650 * The two bits are part of the REG sub-field, which isn't needed in
4651 * iemOpHlpCalcRmEffAddrThreadedAddr64().
4652 *
4653 * For use during decoding/recompiling.
4654 */
4655#define IEM_GET_MODRM_EX(a_pVCpu, a_bRm) \
4656 ( ((a_bRm) & ~X86_MODRM_REG_MASK) \
4657 | (uint8_t)( (pVCpu->iem.s.fPrefixes & (IEM_OP_PRF_REX_B | IEM_OP_PRF_REX_X)) >> (26 - 3) ) )
4658AssertCompile(IEM_OP_PRF_REX_B == RT_BIT_32(26));
4659AssertCompile(IEM_OP_PRF_REX_X == RT_BIT_32(27));
4660
4661/**
4662 * Gets the effective VEX.VVVV value.
4663 *
4664 * The 4th bit is ignored if not 64-bit code.
4665 * @returns effective V-register value.
4666 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
4667 */
4668#define IEM_GET_EFFECTIVE_VVVV(a_pVCpu) \
4669 (IEM_IS_64BIT_CODE(a_pVCpu) ? (a_pVCpu)->iem.s.uVex3rdReg : (a_pVCpu)->iem.s.uVex3rdReg & 7)
4670
4671
4672/**
4673 * Checks if we're executing inside an AMD-V or VT-x guest.
4674 */
4675#if defined(VBOX_WITH_NESTED_HWVIRT_VMX) || defined(VBOX_WITH_NESTED_HWVIRT_SVM)
4676# define IEM_IS_IN_GUEST(a_pVCpu) RT_BOOL((a_pVCpu)->iem.s.fExec & IEM_F_X86_CTX_IN_GUEST)
4677#else
4678# define IEM_IS_IN_GUEST(a_pVCpu) false
4679#endif
4680
4681
4682#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
4683
4684/**
4685 * Check if the guest has entered VMX root operation.
4686 */
4687# define IEM_VMX_IS_ROOT_MODE(a_pVCpu) (CPUMIsGuestInVmxRootMode(IEM_GET_CTX(a_pVCpu)))
4688
4689/**
4690 * Check if the guest has entered VMX non-root operation.
4691 */
4692# 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)) \
4693 == (IEM_F_X86_CTX_VMX | IEM_F_X86_CTX_IN_GUEST) )
4694
4695/**
4696 * Check if the nested-guest has the given Pin-based VM-execution control set.
4697 */
4698# define IEM_VMX_IS_PINCTLS_SET(a_pVCpu, a_PinCtl) (CPUMIsGuestVmxPinCtlsSet(IEM_GET_CTX(a_pVCpu), (a_PinCtl)))
4699
4700/**
4701 * Check if the nested-guest has the given Processor-based VM-execution control set.
4702 */
4703# define IEM_VMX_IS_PROCCTLS_SET(a_pVCpu, a_ProcCtl) (CPUMIsGuestVmxProcCtlsSet(IEM_GET_CTX(a_pVCpu), (a_ProcCtl)))
4704
4705/**
4706 * Check if the nested-guest has the given Secondary Processor-based VM-execution
4707 * control set.
4708 */
4709# define IEM_VMX_IS_PROCCTLS2_SET(a_pVCpu, a_ProcCtl2) (CPUMIsGuestVmxProcCtls2Set(IEM_GET_CTX(a_pVCpu), (a_ProcCtl2)))
4710
4711/** Gets the guest-physical address of the shadows VMCS for the given VCPU. */
4712# define IEM_VMX_GET_SHADOW_VMCS(a_pVCpu) ((a_pVCpu)->cpum.GstCtx.hwvirt.vmx.GCPhysShadowVmcs)
4713
4714/** Whether a shadow VMCS is present for the given VCPU. */
4715# define IEM_VMX_HAS_SHADOW_VMCS(a_pVCpu) RT_BOOL(IEM_VMX_GET_SHADOW_VMCS(a_pVCpu) != NIL_RTGCPHYS)
4716
4717/** Gets the VMXON region pointer. */
4718# define IEM_VMX_GET_VMXON_PTR(a_pVCpu) ((a_pVCpu)->cpum.GstCtx.hwvirt.vmx.GCPhysVmxon)
4719
4720/** Gets the guest-physical address of the current VMCS for the given VCPU. */
4721# define IEM_VMX_GET_CURRENT_VMCS(a_pVCpu) ((a_pVCpu)->cpum.GstCtx.hwvirt.vmx.GCPhysVmcs)
4722
4723/** Whether a current VMCS is present for the given VCPU. */
4724# define IEM_VMX_HAS_CURRENT_VMCS(a_pVCpu) RT_BOOL(IEM_VMX_GET_CURRENT_VMCS(a_pVCpu) != NIL_RTGCPHYS)
4725
4726/** Assigns the guest-physical address of the current VMCS for the given VCPU. */
4727# define IEM_VMX_SET_CURRENT_VMCS(a_pVCpu, a_GCPhysVmcs) \
4728 do \
4729 { \
4730 Assert((a_GCPhysVmcs) != NIL_RTGCPHYS); \
4731 (a_pVCpu)->cpum.GstCtx.hwvirt.vmx.GCPhysVmcs = (a_GCPhysVmcs); \
4732 } while (0)
4733
4734/** Clears any current VMCS for the given VCPU. */
4735# define IEM_VMX_CLEAR_CURRENT_VMCS(a_pVCpu) \
4736 do \
4737 { \
4738 (a_pVCpu)->cpum.GstCtx.hwvirt.vmx.GCPhysVmcs = NIL_RTGCPHYS; \
4739 } while (0)
4740
4741/**
4742 * Invokes the VMX VM-exit handler for an instruction intercept.
4743 */
4744# define IEM_VMX_VMEXIT_INSTR_RET(a_pVCpu, a_uExitReason, a_cbInstr) \
4745 do { return iemVmxVmexitInstr((a_pVCpu), (a_uExitReason), (a_cbInstr)); } while (0)
4746
4747/**
4748 * Invokes the VMX VM-exit handler for an instruction intercept where the
4749 * instruction provides additional VM-exit information.
4750 */
4751# define IEM_VMX_VMEXIT_INSTR_NEEDS_INFO_RET(a_pVCpu, a_uExitReason, a_uInstrId, a_cbInstr) \
4752 do { return iemVmxVmexitInstrNeedsInfo((a_pVCpu), (a_uExitReason), (a_uInstrId), (a_cbInstr)); } while (0)
4753
4754/**
4755 * Invokes the VMX VM-exit handler for a task switch.
4756 */
4757# define IEM_VMX_VMEXIT_TASK_SWITCH_RET(a_pVCpu, a_enmTaskSwitch, a_SelNewTss, a_cbInstr) \
4758 do { return iemVmxVmexitTaskSwitch((a_pVCpu), (a_enmTaskSwitch), (a_SelNewTss), (a_cbInstr)); } while (0)
4759
4760/**
4761 * Invokes the VMX VM-exit handler for MWAIT.
4762 */
4763# define IEM_VMX_VMEXIT_MWAIT_RET(a_pVCpu, a_fMonitorArmed, a_cbInstr) \
4764 do { return iemVmxVmexitInstrMwait((a_pVCpu), (a_fMonitorArmed), (a_cbInstr)); } while (0)
4765
4766/**
4767 * Invokes the VMX VM-exit handler for EPT faults.
4768 */
4769# define IEM_VMX_VMEXIT_EPT_RET(a_pVCpu, a_pPtWalk, a_fAccess, a_fSlatFail, a_cbInstr) \
4770 do { return iemVmxVmexitEpt(a_pVCpu, a_pPtWalk, a_fAccess, a_fSlatFail, a_cbInstr); } while (0)
4771
4772/**
4773 * Invokes the VMX VM-exit handler.
4774 */
4775# define IEM_VMX_VMEXIT_TRIPLE_FAULT_RET(a_pVCpu, a_uExitReason, a_uExitQual) \
4776 do { return iemVmxVmexit((a_pVCpu), (a_uExitReason), (a_uExitQual)); } while (0)
4777
4778#else
4779# define IEM_VMX_IS_ROOT_MODE(a_pVCpu) (false)
4780# define IEM_VMX_IS_NON_ROOT_MODE(a_pVCpu) (false)
4781# define IEM_VMX_IS_PINCTLS_SET(a_pVCpu, a_cbInstr) (false)
4782# define IEM_VMX_IS_PROCCTLS_SET(a_pVCpu, a_cbInstr) (false)
4783# define IEM_VMX_IS_PROCCTLS2_SET(a_pVCpu, a_cbInstr) (false)
4784# define IEM_VMX_VMEXIT_INSTR_RET(a_pVCpu, a_uExitReason, a_cbInstr) do { return VERR_VMX_IPE_1; } while (0)
4785# define IEM_VMX_VMEXIT_INSTR_NEEDS_INFO_RET(a_pVCpu, a_uExitReason, a_uInstrId, a_cbInstr) do { return VERR_VMX_IPE_1; } while (0)
4786# define IEM_VMX_VMEXIT_TASK_SWITCH_RET(a_pVCpu, a_enmTaskSwitch, a_SelNewTss, a_cbInstr) do { return VERR_VMX_IPE_1; } while (0)
4787# define IEM_VMX_VMEXIT_MWAIT_RET(a_pVCpu, a_fMonitorArmed, a_cbInstr) do { return VERR_VMX_IPE_1; } while (0)
4788# define IEM_VMX_VMEXIT_EPT_RET(a_pVCpu, a_pPtWalk, a_fAccess, a_fSlatFail, a_cbInstr) do { return VERR_VMX_IPE_1; } while (0)
4789# define IEM_VMX_VMEXIT_TRIPLE_FAULT_RET(a_pVCpu, a_uExitReason, a_uExitQual) do { return VERR_VMX_IPE_1; } while (0)
4790
4791#endif
4792
4793#ifdef VBOX_WITH_NESTED_HWVIRT_SVM
4794/**
4795 * Checks if we're executing a guest using AMD-V.
4796 */
4797# define IEM_SVM_IS_IN_GUEST(a_pVCpu) ( (a_pVCpu->iem.s.fExec & (IEM_F_X86_CTX_SVM | IEM_F_X86_CTX_IN_GUEST)) \
4798 == (IEM_F_X86_CTX_SVM | IEM_F_X86_CTX_IN_GUEST))
4799/**
4800 * Check if an SVM control/instruction intercept is set.
4801 */
4802# define IEM_SVM_IS_CTRL_INTERCEPT_SET(a_pVCpu, a_Intercept) \
4803 (IEM_SVM_IS_IN_GUEST(a_pVCpu) && CPUMIsGuestSvmCtrlInterceptSet(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_Intercept)))
4804
4805/**
4806 * Check if an SVM read CRx intercept is set.
4807 */
4808# define IEM_SVM_IS_READ_CR_INTERCEPT_SET(a_pVCpu, a_uCr) \
4809 (IEM_SVM_IS_IN_GUEST(a_pVCpu) && CPUMIsGuestSvmReadCRxInterceptSet(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_uCr)))
4810
4811/**
4812 * Check if an SVM write CRx intercept is set.
4813 */
4814# define IEM_SVM_IS_WRITE_CR_INTERCEPT_SET(a_pVCpu, a_uCr) \
4815 (IEM_SVM_IS_IN_GUEST(a_pVCpu) && CPUMIsGuestSvmWriteCRxInterceptSet(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_uCr)))
4816
4817/**
4818 * Check if an SVM read DRx intercept is set.
4819 */
4820# define IEM_SVM_IS_READ_DR_INTERCEPT_SET(a_pVCpu, a_uDr) \
4821 (IEM_SVM_IS_IN_GUEST(a_pVCpu) && CPUMIsGuestSvmReadDRxInterceptSet(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_uDr)))
4822
4823/**
4824 * Check if an SVM write DRx intercept is set.
4825 */
4826# define IEM_SVM_IS_WRITE_DR_INTERCEPT_SET(a_pVCpu, a_uDr) \
4827 (IEM_SVM_IS_IN_GUEST(a_pVCpu) && CPUMIsGuestSvmWriteDRxInterceptSet(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_uDr)))
4828
4829/**
4830 * Check if an SVM exception intercept is set.
4831 */
4832# define IEM_SVM_IS_XCPT_INTERCEPT_SET(a_pVCpu, a_uVector) \
4833 (IEM_SVM_IS_IN_GUEST(a_pVCpu) && CPUMIsGuestSvmXcptInterceptSet(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_uVector)))
4834
4835/**
4836 * Invokes the SVM \#VMEXIT handler for the nested-guest.
4837 */
4838# define IEM_SVM_VMEXIT_RET(a_pVCpu, a_uExitCode, a_uExitInfo1, a_uExitInfo2) \
4839 do { return iemSvmVmexit((a_pVCpu), (a_uExitCode), (a_uExitInfo1), (a_uExitInfo2)); } while (0)
4840
4841/**
4842 * Invokes the 'MOV CRx' SVM \#VMEXIT handler after constructing the
4843 * corresponding decode assist information.
4844 */
4845# define IEM_SVM_CRX_VMEXIT_RET(a_pVCpu, a_uExitCode, a_enmAccessCrX, a_iGReg) \
4846 do \
4847 { \
4848 uint64_t uExitInfo1; \
4849 if ( IEM_GET_GUEST_CPU_FEATURES(a_pVCpu)->fSvmDecodeAssists \
4850 && (a_enmAccessCrX) == IEMACCESSCRX_MOV_CRX) \
4851 uExitInfo1 = SVM_EXIT1_MOV_CRX_MASK | ((a_iGReg) & 7); \
4852 else \
4853 uExitInfo1 = 0; \
4854 IEM_SVM_VMEXIT_RET(a_pVCpu, a_uExitCode, uExitInfo1, 0); \
4855 } while (0)
4856
4857/** Check and handles SVM nested-guest instruction intercept and updates
4858 * NRIP if needed.
4859 */
4860# define IEM_SVM_CHECK_INSTR_INTERCEPT(a_pVCpu, a_Intercept, a_uExitCode, a_uExitInfo1, a_uExitInfo2, a_cbInstr) \
4861 do \
4862 { \
4863 if (IEM_SVM_IS_CTRL_INTERCEPT_SET(a_pVCpu, a_Intercept)) \
4864 { \
4865 IEM_SVM_UPDATE_NRIP(a_pVCpu, a_cbInstr); \
4866 IEM_SVM_VMEXIT_RET(a_pVCpu, a_uExitCode, a_uExitInfo1, a_uExitInfo2); \
4867 } \
4868 } while (0)
4869
4870/** Checks and handles SVM nested-guest CR0 read intercept. */
4871# define IEM_SVM_CHECK_READ_CR0_INTERCEPT(a_pVCpu, a_uExitInfo1, a_uExitInfo2, a_cbInstr) \
4872 do \
4873 { \
4874 if (!IEM_SVM_IS_READ_CR_INTERCEPT_SET(a_pVCpu, 0)) \
4875 { /* probably likely */ } \
4876 else \
4877 { \
4878 IEM_SVM_UPDATE_NRIP(a_pVCpu, a_cbInstr); \
4879 IEM_SVM_VMEXIT_RET(a_pVCpu, SVM_EXIT_READ_CR0, a_uExitInfo1, a_uExitInfo2); \
4880 } \
4881 } while (0)
4882
4883/**
4884 * Updates the NextRIP (NRI) field in the nested-guest VMCB.
4885 */
4886# define IEM_SVM_UPDATE_NRIP(a_pVCpu, a_cbInstr) \
4887 do { \
4888 if (IEM_GET_GUEST_CPU_FEATURES(a_pVCpu)->fSvmNextRipSave) \
4889 CPUMGuestSvmUpdateNRip(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_cbInstr)); \
4890 } while (0)
4891
4892#else
4893# define IEM_SVM_IS_CTRL_INTERCEPT_SET(a_pVCpu, a_Intercept) (false)
4894# define IEM_SVM_IS_READ_CR_INTERCEPT_SET(a_pVCpu, a_uCr) (false)
4895# define IEM_SVM_IS_WRITE_CR_INTERCEPT_SET(a_pVCpu, a_uCr) (false)
4896# define IEM_SVM_IS_READ_DR_INTERCEPT_SET(a_pVCpu, a_uDr) (false)
4897# define IEM_SVM_IS_WRITE_DR_INTERCEPT_SET(a_pVCpu, a_uDr) (false)
4898# define IEM_SVM_IS_XCPT_INTERCEPT_SET(a_pVCpu, a_uVector) (false)
4899# define IEM_SVM_VMEXIT_RET(a_pVCpu, a_uExitCode, a_uExitInfo1, a_uExitInfo2) do { return VERR_SVM_IPE_1; } while (0)
4900# define IEM_SVM_CRX_VMEXIT_RET(a_pVCpu, a_uExitCode, a_enmAccessCrX, a_iGReg) do { return VERR_SVM_IPE_1; } while (0)
4901# define IEM_SVM_CHECK_INSTR_INTERCEPT(a_pVCpu, a_Intercept, a_uExitCode, \
4902 a_uExitInfo1, a_uExitInfo2, a_cbInstr) do { } while (0)
4903# define IEM_SVM_CHECK_READ_CR0_INTERCEPT(a_pVCpu, a_uExitInfo1, a_uExitInfo2, a_cbInstr) do { } while (0)
4904# define IEM_SVM_UPDATE_NRIP(a_pVCpu, a_cbInstr) do { } while (0)
4905
4906#endif
4907
4908/** @} */
4909
4910uint32_t iemCalcExecDbgFlagsSlow(PVMCPUCC pVCpu);
4911VBOXSTRICTRC iemExecInjectPendingTrap(PVMCPUCC pVCpu);
4912
4913
4914/**
4915 * Selector descriptor table entry as fetched by iemMemFetchSelDesc.
4916 */
4917typedef union IEMSELDESC
4918{
4919 /** The legacy view. */
4920 X86DESC Legacy;
4921 /** The long mode view. */
4922 X86DESC64 Long;
4923} IEMSELDESC;
4924/** Pointer to a selector descriptor table entry. */
4925typedef IEMSELDESC *PIEMSELDESC;
4926
4927/** @name Raising Exceptions.
4928 * @{ */
4929VBOXSTRICTRC iemTaskSwitch(PVMCPUCC pVCpu, IEMTASKSWITCH enmTaskSwitch, uint32_t uNextEip, uint32_t fFlags,
4930 uint16_t uErr, uint64_t uCr2, RTSEL SelTSS, PIEMSELDESC pNewDescTSS) RT_NOEXCEPT;
4931
4932VBOXSTRICTRC iemRaiseXcptOrInt(PVMCPUCC pVCpu, uint8_t cbInstr, uint8_t u8Vector, uint32_t fFlags,
4933 uint16_t uErr, uint64_t uCr2) RT_NOEXCEPT;
4934#ifdef IEM_WITH_SETJMP
4935DECL_NO_RETURN(void) iemRaiseXcptOrIntJmp(PVMCPUCC pVCpu, uint8_t cbInstr, uint8_t u8Vector,
4936 uint32_t fFlags, uint16_t uErr, uint64_t uCr2) IEM_NOEXCEPT_MAY_LONGJMP;
4937#endif
4938VBOXSTRICTRC iemRaiseDivideError(PVMCPUCC pVCpu) RT_NOEXCEPT;
4939VBOXSTRICTRC iemRaiseDebugException(PVMCPUCC pVCpu) RT_NOEXCEPT;
4940VBOXSTRICTRC iemRaiseBoundRangeExceeded(PVMCPUCC pVCpu) RT_NOEXCEPT;
4941VBOXSTRICTRC iemRaiseUndefinedOpcode(PVMCPUCC pVCpu) RT_NOEXCEPT;
4942VBOXSTRICTRC iemRaiseDeviceNotAvailable(PVMCPUCC pVCpu) RT_NOEXCEPT;
4943VBOXSTRICTRC iemRaiseTaskSwitchFaultWithErr(PVMCPUCC pVCpu, uint16_t uErr) RT_NOEXCEPT;
4944VBOXSTRICTRC iemRaiseTaskSwitchFaultCurrentTSS(PVMCPUCC pVCpu) RT_NOEXCEPT;
4945VBOXSTRICTRC iemRaiseTaskSwitchFault0(PVMCPUCC pVCpu) RT_NOEXCEPT;
4946VBOXSTRICTRC iemRaiseTaskSwitchFaultBySelector(PVMCPUCC pVCpu, uint16_t uSel) RT_NOEXCEPT;
4947/*VBOXSTRICTRC iemRaiseSelectorNotPresent(PVMCPUCC pVCpu, uint32_t iSegReg, uint32_t fAccess) RT_NOEXCEPT;*/
4948VBOXSTRICTRC iemRaiseSelectorNotPresentWithErr(PVMCPUCC pVCpu, uint16_t uErr) RT_NOEXCEPT;
4949VBOXSTRICTRC iemRaiseSelectorNotPresentBySelector(PVMCPUCC pVCpu, uint16_t uSel) RT_NOEXCEPT;
4950VBOXSTRICTRC iemRaiseStackSelectorNotPresentBySelector(PVMCPUCC pVCpu, uint16_t uSel) RT_NOEXCEPT;
4951VBOXSTRICTRC iemRaiseStackSelectorNotPresentWithErr(PVMCPUCC pVCpu, uint16_t uErr) RT_NOEXCEPT;
4952VBOXSTRICTRC iemRaiseGeneralProtectionFault(PVMCPUCC pVCpu, uint16_t uErr) RT_NOEXCEPT;
4953VBOXSTRICTRC iemRaiseGeneralProtectionFault0(PVMCPUCC pVCpu) RT_NOEXCEPT;
4954#ifdef IEM_WITH_SETJMP
4955DECL_NO_RETURN(void) iemRaiseGeneralProtectionFault0Jmp(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP;
4956#endif
4957VBOXSTRICTRC iemRaiseGeneralProtectionFaultBySelector(PVMCPUCC pVCpu, RTSEL Sel) RT_NOEXCEPT;
4958VBOXSTRICTRC iemRaiseNotCanonical(PVMCPUCC pVCpu) RT_NOEXCEPT;
4959VBOXSTRICTRC iemRaiseSelectorBounds(PVMCPUCC pVCpu, uint32_t iSegReg, uint32_t fAccess) RT_NOEXCEPT;
4960#ifdef IEM_WITH_SETJMP
4961DECL_NO_RETURN(void) iemRaiseSelectorBoundsJmp(PVMCPUCC pVCpu, uint32_t iSegReg, uint32_t fAccess) IEM_NOEXCEPT_MAY_LONGJMP;
4962#endif
4963VBOXSTRICTRC iemRaiseSelectorBoundsBySelector(PVMCPUCC pVCpu, RTSEL Sel) RT_NOEXCEPT;
4964#ifdef IEM_WITH_SETJMP
4965DECL_NO_RETURN(void) iemRaiseSelectorBoundsBySelectorJmp(PVMCPUCC pVCpu, RTSEL Sel) IEM_NOEXCEPT_MAY_LONGJMP;
4966#endif
4967VBOXSTRICTRC iemRaiseSelectorInvalidAccess(PVMCPUCC pVCpu, uint32_t iSegReg, uint32_t fAccess) RT_NOEXCEPT;
4968#ifdef IEM_WITH_SETJMP
4969DECL_NO_RETURN(void) iemRaiseSelectorInvalidAccessJmp(PVMCPUCC pVCpu, uint32_t iSegReg, uint32_t fAccess) IEM_NOEXCEPT_MAY_LONGJMP;
4970#endif
4971VBOXSTRICTRC iemRaisePageFault(PVMCPUCC pVCpu, RTGCPTR GCPtrWhere, uint32_t cbAccess, uint32_t fAccess, int rc) RT_NOEXCEPT;
4972#ifdef IEM_WITH_SETJMP
4973DECL_NO_RETURN(void) iemRaisePageFaultJmp(PVMCPUCC pVCpu, RTGCPTR GCPtrWhere, uint32_t cbAccess, uint32_t fAccess, int rc) IEM_NOEXCEPT_MAY_LONGJMP;
4974#endif
4975VBOXSTRICTRC iemRaiseMathFault(PVMCPUCC pVCpu) RT_NOEXCEPT;
4976VBOXSTRICTRC iemRaiseAlignmentCheckException(PVMCPUCC pVCpu) RT_NOEXCEPT;
4977#ifdef IEM_WITH_SETJMP
4978DECL_NO_RETURN(void) iemRaiseAlignmentCheckExceptionJmp(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP;
4979#endif
4980VBOXSTRICTRC iemRaiseSimdFpException(PVMCPUCC pVCpu) RT_NOEXCEPT;
4981
4982void iemLogSyscallProtModeInt(PVMCPUCC pVCpu, uint8_t u8Vector, uint8_t cbInstr);
4983
4984IEM_CIMPL_DEF_0(iemCImplRaiseDivideError);
4985IEM_CIMPL_DEF_0(iemCImplRaiseInvalidLockPrefix);
4986IEM_CIMPL_DEF_0(iemCImplRaiseInvalidOpcode);
4987
4988/**
4989 * Macro for calling iemCImplRaiseDivideError().
4990 *
4991 * This is for things that will _always_ decode to an \#DE, taking the
4992 * recompiler into consideration and everything.
4993 *
4994 * @return Strict VBox status code.
4995 */
4996#define IEMOP_RAISE_DIVIDE_ERROR_RET() IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_XCPT, 0, iemCImplRaiseDivideError)
4997
4998/**
4999 * Macro for calling iemCImplRaiseInvalidLockPrefix().
5000 *
5001 * This is for things that will _always_ decode to an \#UD, taking the
5002 * recompiler into consideration and everything.
5003 *
5004 * @return Strict VBox status code.
5005 */
5006#define IEMOP_RAISE_INVALID_LOCK_PREFIX_RET() IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_XCPT, 0, iemCImplRaiseInvalidLockPrefix)
5007
5008/**
5009 * Macro for calling iemCImplRaiseInvalidOpcode() for decode/static \#UDs.
5010 *
5011 * This is for things that will _always_ decode to an \#UD, taking the
5012 * recompiler into consideration and everything.
5013 *
5014 * @return Strict VBox status code.
5015 */
5016#define IEMOP_RAISE_INVALID_OPCODE_RET() IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_XCPT, 0, iemCImplRaiseInvalidOpcode)
5017
5018/**
5019 * Macro for calling iemCImplRaiseInvalidOpcode() for runtime-style \#UDs.
5020 *
5021 * Using this macro means you've got _buggy_ _code_ and are doing things that
5022 * belongs exclusively in IEMAllCImpl.cpp during decoding.
5023 *
5024 * @return Strict VBox status code.
5025 * @see IEMOP_RAISE_INVALID_OPCODE_RET
5026 */
5027#define IEMOP_RAISE_INVALID_OPCODE_RUNTIME_RET() IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_XCPT, 0, iemCImplRaiseInvalidOpcode)
5028
5029/** @} */
5030
5031/** @name Register Access.
5032 * @{ */
5033VBOXSTRICTRC iemRegRipRelativeJumpS8AndFinishClearingRF(PVMCPUCC pVCpu, uint8_t cbInstr, int8_t offNextInstr,
5034 IEMMODE enmEffOpSize) RT_NOEXCEPT;
5035VBOXSTRICTRC iemRegRipRelativeJumpS16AndFinishClearingRF(PVMCPUCC pVCpu, uint8_t cbInstr, int16_t offNextInstr) RT_NOEXCEPT;
5036VBOXSTRICTRC iemRegRipRelativeJumpS32AndFinishClearingRF(PVMCPUCC pVCpu, uint8_t cbInstr, int32_t offNextInstr,
5037 IEMMODE enmEffOpSize) RT_NOEXCEPT;
5038/** @} */
5039
5040/** @name FPU access and helpers.
5041 * @{ */
5042void iemFpuPushResult(PVMCPUCC pVCpu, PIEMFPURESULT pResult, uint16_t uFpuOpcode) RT_NOEXCEPT;
5043void iemFpuPushResultWithMemOp(PVMCPUCC pVCpu, PIEMFPURESULT pResult, uint8_t iEffSeg, RTGCPTR GCPtrEff, uint16_t uFpuOpcode) RT_NOEXCEPT;
5044void iemFpuPushResultTwo(PVMCPUCC pVCpu, PIEMFPURESULTTWO pResult, uint16_t uFpuOpcode) RT_NOEXCEPT;
5045void iemFpuStoreResult(PVMCPUCC pVCpu, PIEMFPURESULT pResult, uint8_t iStReg, uint16_t uFpuOpcode) RT_NOEXCEPT;
5046void iemFpuStoreResultThenPop(PVMCPUCC pVCpu, PIEMFPURESULT pResult, uint8_t iStReg, uint16_t uFpuOpcode) RT_NOEXCEPT;
5047void iemFpuStoreResultWithMemOp(PVMCPUCC pVCpu, PIEMFPURESULT pResult, uint8_t iStReg,
5048 uint8_t iEffSeg, RTGCPTR GCPtrEff, uint16_t uFpuOpcode) RT_NOEXCEPT;
5049void iemFpuStoreResultWithMemOpThenPop(PVMCPUCC pVCpu, PIEMFPURESULT pResult, uint8_t iStReg,
5050 uint8_t iEffSeg, RTGCPTR GCPtrEff, uint16_t uFpuOpcode) RT_NOEXCEPT;
5051void iemFpuUpdateOpcodeAndIp(PVMCPUCC pVCpu, uint16_t uFpuOpcode) RT_NOEXCEPT;
5052void iemFpuUpdateFSW(PVMCPUCC pVCpu, uint16_t u16FSW, uint16_t uFpuOpcode) RT_NOEXCEPT;
5053void iemFpuUpdateFSWThenPop(PVMCPUCC pVCpu, uint16_t u16FSW, uint16_t uFpuOpcode) RT_NOEXCEPT;
5054void iemFpuUpdateFSWWithMemOp(PVMCPUCC pVCpu, uint16_t u16FSW, uint8_t iEffSeg, RTGCPTR GCPtrEff, uint16_t uFpuOpcode) RT_NOEXCEPT;
5055void iemFpuUpdateFSWThenPopPop(PVMCPUCC pVCpu, uint16_t u16FSW, uint16_t uFpuOpcode) RT_NOEXCEPT;
5056void iemFpuUpdateFSWWithMemOpThenPop(PVMCPUCC pVCpu, uint16_t u16FSW, uint8_t iEffSeg, RTGCPTR GCPtrEff, uint16_t uFpuOpcode) RT_NOEXCEPT;
5057void iemFpuStackUnderflow(PVMCPUCC pVCpu, uint8_t iStReg, uint16_t uFpuOpcode) RT_NOEXCEPT;
5058void iemFpuStackUnderflowWithMemOp(PVMCPUCC pVCpu, uint8_t iStReg, uint8_t iEffSeg, RTGCPTR GCPtrEff, uint16_t uFpuOpcode) RT_NOEXCEPT;
5059void iemFpuStackUnderflowThenPop(PVMCPUCC pVCpu, uint8_t iStReg, uint16_t uFpuOpcode) RT_NOEXCEPT;
5060void iemFpuStackUnderflowWithMemOpThenPop(PVMCPUCC pVCpu, uint8_t iStReg, uint8_t iEffSeg, RTGCPTR GCPtrEff, uint16_t uFpuOpcode) RT_NOEXCEPT;
5061void iemFpuStackUnderflowThenPopPop(PVMCPUCC pVCpu, uint16_t uFpuOpcode) RT_NOEXCEPT;
5062void iemFpuStackPushUnderflow(PVMCPUCC pVCpu, uint16_t uFpuOpcode) RT_NOEXCEPT;
5063void iemFpuStackPushUnderflowTwo(PVMCPUCC pVCpu, uint16_t uFpuOpcode) RT_NOEXCEPT;
5064void iemFpuStackPushOverflow(PVMCPUCC pVCpu, uint16_t uFpuOpcode) RT_NOEXCEPT;
5065void iemFpuStackPushOverflowWithMemOp(PVMCPUCC pVCpu, uint8_t iEffSeg, RTGCPTR GCPtrEff, uint16_t uFpuOpcode) RT_NOEXCEPT;
5066/** @} */
5067
5068/** @name SSE+AVX SIMD access and helpers.
5069 * @{ */
5070void iemSseStoreResult(PVMCPUCC pVCpu, PCIEMSSERESULT pResult, uint8_t iXmmReg) RT_NOEXCEPT;
5071void iemSseUpdateMxcsr(PVMCPUCC pVCpu, uint32_t fMxcsr) RT_NOEXCEPT;
5072/** @} */
5073
5074/** @name Memory access.
5075 * @{ */
5076
5077/** Report a \#GP instead of \#AC and do not restrict to ring-3 */
5078#define IEM_MEMMAP_F_ALIGN_GP RT_BIT_32(16)
5079/** SSE access that should report a \#GP instead of \#AC, unless MXCSR.MM=1
5080 * when it works like normal \#AC. Always used with IEM_MEMMAP_F_ALIGN_GP. */
5081#define IEM_MEMMAP_F_ALIGN_SSE RT_BIT_32(17)
5082/** If \#AC is applicable, raise it. Always used with IEM_MEMMAP_F_ALIGN_GP.
5083 * Users include FXSAVE & FXRSTOR. */
5084#define IEM_MEMMAP_F_ALIGN_GP_OR_AC RT_BIT_32(18)
5085
5086VBOXSTRICTRC iemMemMap(PVMCPUCC pVCpu, void **ppvMem, uint8_t *pbUnmapInfo, size_t cbMem, uint8_t iSegReg, RTGCPTR GCPtrMem,
5087 uint32_t fAccess, uint32_t uAlignCtl) RT_NOEXCEPT;
5088VBOXSTRICTRC iemMemCommitAndUnmap(PVMCPUCC pVCpu, uint8_t bUnmapInfo) RT_NOEXCEPT;
5089#ifndef IN_RING3
5090VBOXSTRICTRC iemMemCommitAndUnmapPostponeTroubleToR3(PVMCPUCC pVCpu, uint8_t bUnmapInfo) RT_NOEXCEPT;
5091#endif
5092void iemMemRollbackAndUnmap(PVMCPUCC pVCpu, uint8_t bUnmapInfo) RT_NOEXCEPT;
5093void iemMemRollback(PVMCPUCC pVCpu) RT_NOEXCEPT;
5094VBOXSTRICTRC iemMemApplySegment(PVMCPUCC pVCpu, uint32_t fAccess, uint8_t iSegReg, size_t cbMem, PRTGCPTR pGCPtrMem) RT_NOEXCEPT;
5095VBOXSTRICTRC iemMemMarkSelDescAccessed(PVMCPUCC pVCpu, uint16_t uSel) RT_NOEXCEPT;
5096VBOXSTRICTRC iemMemPageTranslateAndCheckAccess(PVMCPUCC pVCpu, RTGCPTR GCPtrMem, uint32_t cbAccess, uint32_t fAccess, PRTGCPHYS pGCPhysMem) RT_NOEXCEPT;
5097
5098void iemOpcodeFlushLight(PVMCPUCC pVCpu, uint8_t cbInstr);
5099void iemOpcodeFlushHeavy(PVMCPUCC pVCpu, uint8_t cbInstr);
5100#ifdef IEM_WITH_CODE_TLB
5101void iemOpcodeFetchBytesJmp(PVMCPUCC pVCpu, size_t cbDst, void *pvDst) IEM_NOEXCEPT_MAY_LONGJMP;
5102#else
5103VBOXSTRICTRC iemOpcodeFetchMoreBytes(PVMCPUCC pVCpu, size_t cbMin) RT_NOEXCEPT;
5104#endif
5105#ifdef IEM_WITH_SETJMP
5106uint8_t iemOpcodeGetNextU8SlowJmp(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP;
5107uint16_t iemOpcodeGetNextU16SlowJmp(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP;
5108uint32_t iemOpcodeGetNextU32SlowJmp(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP;
5109uint64_t iemOpcodeGetNextU64SlowJmp(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP;
5110#else
5111VBOXSTRICTRC iemOpcodeGetNextU8Slow(PVMCPUCC pVCpu, uint8_t *pb) RT_NOEXCEPT;
5112VBOXSTRICTRC iemOpcodeGetNextS8SxU16Slow(PVMCPUCC pVCpu, uint16_t *pu16) RT_NOEXCEPT;
5113VBOXSTRICTRC iemOpcodeGetNextS8SxU32Slow(PVMCPUCC pVCpu, uint32_t *pu32) RT_NOEXCEPT;
5114VBOXSTRICTRC iemOpcodeGetNextS8SxU64Slow(PVMCPUCC pVCpu, uint64_t *pu64) RT_NOEXCEPT;
5115VBOXSTRICTRC iemOpcodeGetNextU16Slow(PVMCPUCC pVCpu, uint16_t *pu16) RT_NOEXCEPT;
5116VBOXSTRICTRC iemOpcodeGetNextU16ZxU32Slow(PVMCPUCC pVCpu, uint32_t *pu32) RT_NOEXCEPT;
5117VBOXSTRICTRC iemOpcodeGetNextU16ZxU64Slow(PVMCPUCC pVCpu, uint64_t *pu64) RT_NOEXCEPT;
5118VBOXSTRICTRC iemOpcodeGetNextU32Slow(PVMCPUCC pVCpu, uint32_t *pu32) RT_NOEXCEPT;
5119VBOXSTRICTRC iemOpcodeGetNextU32ZxU64Slow(PVMCPUCC pVCpu, uint64_t *pu64) RT_NOEXCEPT;
5120VBOXSTRICTRC iemOpcodeGetNextS32SxU64Slow(PVMCPUCC pVCpu, uint64_t *pu64) RT_NOEXCEPT;
5121VBOXSTRICTRC iemOpcodeGetNextU64Slow(PVMCPUCC pVCpu, uint64_t *pu64) RT_NOEXCEPT;
5122#endif
5123
5124VBOXSTRICTRC iemMemFetchDataU8(PVMCPUCC pVCpu, uint8_t *pu8Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
5125VBOXSTRICTRC iemMemFetchDataU16(PVMCPUCC pVCpu, uint16_t *pu16Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
5126VBOXSTRICTRC iemMemFetchDataU32(PVMCPUCC pVCpu, uint32_t *pu32Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
5127VBOXSTRICTRC iemMemFetchDataU32_ZX_U64(PVMCPUCC pVCpu, uint64_t *pu64Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
5128VBOXSTRICTRC iemMemFetchDataU64(PVMCPUCC pVCpu, uint64_t *pu64Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
5129VBOXSTRICTRC iemMemFetchDataU64AlignedU128(PVMCPUCC pVCpu, uint64_t *pu64Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
5130VBOXSTRICTRC iemMemFetchDataR80(PVMCPUCC pVCpu, PRTFLOAT80U pr80Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
5131VBOXSTRICTRC iemMemFetchDataD80(PVMCPUCC pVCpu, PRTPBCD80U pd80Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
5132VBOXSTRICTRC iemMemFetchDataU128(PVMCPUCC pVCpu, PRTUINT128U pu128Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
5133VBOXSTRICTRC iemMemFetchDataU128AlignedSse(PVMCPUCC pVCpu, PRTUINT128U pu128Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
5134VBOXSTRICTRC iemMemFetchDataU256(PVMCPUCC pVCpu, PRTUINT256U pu256Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
5135VBOXSTRICTRC iemMemFetchDataU256AlignedSse(PVMCPUCC pVCpu, PRTUINT256U pu256Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
5136VBOXSTRICTRC iemMemFetchDataXdtr(PVMCPUCC pVCpu, uint16_t *pcbLimit, PRTGCPTR pGCPtrBase, uint8_t iSegReg,
5137 RTGCPTR GCPtrMem, IEMMODE enmOpSize) RT_NOEXCEPT;
5138#ifdef IEM_WITH_SETJMP
5139uint8_t iemMemFetchDataU8SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5140uint16_t iemMemFetchDataU16SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5141uint32_t iemMemFetchDataU32SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5142uint32_t iemMemFlatFetchDataU32SafeJmp(PVMCPUCC pVCpu, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5143uint64_t iemMemFetchDataU64SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5144uint64_t iemMemFetchDataU64AlignedU128SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5145void iemMemFetchDataR80SafeJmp(PVMCPUCC pVCpu, PRTFLOAT80U pr80Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5146void iemMemFetchDataD80SafeJmp(PVMCPUCC pVCpu, PRTPBCD80U pd80Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5147void iemMemFetchDataU128SafeJmp(PVMCPUCC pVCpu, PRTUINT128U pu128Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5148void iemMemFetchDataU128AlignedSseSafeJmp(PVMCPUCC pVCpu, PRTUINT128U pu128Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5149void iemMemFetchDataU256SafeJmp(PVMCPUCC pVCpu, PRTUINT256U pu256Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5150void iemMemFetchDataU256AlignedSseSafeJmp(PVMCPUCC pVCpu, PRTUINT256U pu256Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5151# if 0 /* these are inlined now */
5152uint8_t iemMemFetchDataU8Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5153uint16_t iemMemFetchDataU16Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5154uint32_t iemMemFetchDataU32Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5155uint32_t iemMemFlatFetchDataU32Jmp(PVMCPUCC pVCpu, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5156uint64_t iemMemFetchDataU64Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5157uint64_t iemMemFetchDataU64AlignedU128Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5158void iemMemFetchDataR80Jmp(PVMCPUCC pVCpu, PRTFLOAT80U pr80Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5159void iemMemFetchDataD80Jmp(PVMCPUCC pVCpu, PRTPBCD80U pd80Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5160void iemMemFetchDataU128Jmp(PVMCPUCC pVCpu, PRTUINT128U pu128Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5161# endif
5162void iemMemFetchDataU128AlignedSseJmp(PVMCPUCC pVCpu, PRTUINT128U pu128Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5163void iemMemFetchDataU256Jmp(PVMCPUCC pVCpu, PRTUINT256U pu256Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5164void iemMemFetchDataU256AlignedSseJmp(PVMCPUCC pVCpu, PRTUINT256U pu256Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5165#endif
5166
5167VBOXSTRICTRC iemMemFetchSysU8(PVMCPUCC pVCpu, uint8_t *pu8Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
5168VBOXSTRICTRC iemMemFetchSysU16(PVMCPUCC pVCpu, uint16_t *pu16Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
5169VBOXSTRICTRC iemMemFetchSysU32(PVMCPUCC pVCpu, uint32_t *pu32Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
5170VBOXSTRICTRC iemMemFetchSysU64(PVMCPUCC pVCpu, uint64_t *pu64Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
5171VBOXSTRICTRC iemMemFetchSelDesc(PVMCPUCC pVCpu, PIEMSELDESC pDesc, uint16_t uSel, uint8_t uXcpt) RT_NOEXCEPT;
5172
5173VBOXSTRICTRC iemMemStoreDataU8(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint8_t u8Value) RT_NOEXCEPT;
5174VBOXSTRICTRC iemMemStoreDataU16(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint16_t u16Value) RT_NOEXCEPT;
5175VBOXSTRICTRC iemMemStoreDataU32(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint32_t u32Value) RT_NOEXCEPT;
5176VBOXSTRICTRC iemMemStoreDataU64(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint64_t u64Value) RT_NOEXCEPT;
5177VBOXSTRICTRC iemMemStoreDataU128(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, RTUINT128U u128Value) RT_NOEXCEPT;
5178VBOXSTRICTRC iemMemStoreDataU128AlignedSse(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, RTUINT128U u128Value) RT_NOEXCEPT;
5179VBOXSTRICTRC iemMemStoreDataU256(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTUINT256U pu256Value) RT_NOEXCEPT;
5180VBOXSTRICTRC iemMemStoreDataU256AlignedAvx(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTUINT256U pu256Value) RT_NOEXCEPT;
5181VBOXSTRICTRC iemMemStoreDataXdtr(PVMCPUCC pVCpu, uint16_t cbLimit, RTGCPTR GCPtrBase, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
5182#ifdef IEM_WITH_SETJMP
5183void iemMemStoreDataU8SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint8_t u8Value) IEM_NOEXCEPT_MAY_LONGJMP;
5184void iemMemStoreDataU16SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint16_t u16Value) IEM_NOEXCEPT_MAY_LONGJMP;
5185void iemMemStoreDataU32SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint32_t u32Value) IEM_NOEXCEPT_MAY_LONGJMP;
5186void iemMemStoreDataU64SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint64_t u64Value) IEM_NOEXCEPT_MAY_LONGJMP;
5187void iemMemStoreDataU128SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTUINT128U u128Value) IEM_NOEXCEPT_MAY_LONGJMP;
5188void iemMemStoreDataU128AlignedSseSafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, RTUINT128U u128Value) IEM_NOEXCEPT_MAY_LONGJMP;
5189void iemMemStoreDataU256SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTUINT256U pu256Value) IEM_NOEXCEPT_MAY_LONGJMP;
5190void iemMemStoreDataU256AlignedAvxSafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTUINT256U pu256Value) IEM_NOEXCEPT_MAY_LONGJMP;
5191void iemMemStoreDataR80SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTFLOAT80U pr80Value) IEM_NOEXCEPT_MAY_LONGJMP;
5192void iemMemStoreDataD80SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTPBCD80U pd80Value) IEM_NOEXCEPT_MAY_LONGJMP;
5193#if 0
5194void iemMemStoreDataU8Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint8_t u8Value) IEM_NOEXCEPT_MAY_LONGJMP;
5195void iemMemStoreDataU16Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint16_t u16Value) IEM_NOEXCEPT_MAY_LONGJMP;
5196void iemMemStoreDataU32Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint32_t u32Value) IEM_NOEXCEPT_MAY_LONGJMP;
5197void iemMemStoreDataU64Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint64_t u64Value) IEM_NOEXCEPT_MAY_LONGJMP;
5198void iemMemStoreDataU128Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, RTUINT128U u128Value) IEM_NOEXCEPT_MAY_LONGJMP;
5199#endif
5200void iemMemStoreDataU128AlignedSseJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, RTUINT128U u128Value) IEM_NOEXCEPT_MAY_LONGJMP;
5201void iemMemStoreDataU256Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTUINT256U pu256Value) IEM_NOEXCEPT_MAY_LONGJMP;
5202void iemMemStoreDataU256AlignedAvxJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTUINT256U pu256Value) IEM_NOEXCEPT_MAY_LONGJMP;
5203#endif
5204
5205#ifdef IEM_WITH_SETJMP
5206uint8_t *iemMemMapDataU8RwSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5207uint8_t *iemMemMapDataU8WoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5208uint8_t const *iemMemMapDataU8RoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5209uint16_t *iemMemMapDataU16RwSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5210uint16_t *iemMemMapDataU16WoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5211uint16_t const *iemMemMapDataU16RoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5212uint32_t *iemMemMapDataU32RwSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5213uint32_t *iemMemMapDataU32WoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5214uint32_t const *iemMemMapDataU32RoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5215uint64_t *iemMemMapDataU64RwSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5216uint64_t *iemMemMapDataU64WoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5217uint64_t const *iemMemMapDataU64RoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5218PRTFLOAT80U iemMemMapDataR80RwSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5219PRTFLOAT80U iemMemMapDataR80WoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5220PCRTFLOAT80U iemMemMapDataR80RoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5221PRTPBCD80U iemMemMapDataD80RwSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5222PRTPBCD80U iemMemMapDataD80WoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5223PCRTPBCD80U iemMemMapDataD80RoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5224PRTUINT128U iemMemMapDataU128RwSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5225PRTUINT128U iemMemMapDataU128WoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5226PCRTUINT128U iemMemMapDataU128RoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5227
5228void iemMemCommitAndUnmapJmp(PVMCPUCC pVCpu, uint8_t bUnmapInfo) IEM_NOEXCEPT_MAY_LONGJMP;
5229void iemMemCommitAndUnmapRwSafeJmp(PVMCPUCC pVCpu, uint8_t bUnmapInfo) IEM_NOEXCEPT_MAY_LONGJMP;
5230void iemMemCommitAndUnmapWoSafeJmp(PVMCPUCC pVCpu, uint8_t bUnmapInfo) IEM_NOEXCEPT_MAY_LONGJMP;
5231void iemMemCommitAndUnmapRoSafeJmp(PVMCPUCC pVCpu, uint8_t bUnmapInfo) IEM_NOEXCEPT_MAY_LONGJMP;
5232void iemMemRollbackAndUnmapWoSafe(PVMCPUCC pVCpu, uint8_t bUnmapInfo) RT_NOEXCEPT;
5233#endif
5234
5235VBOXSTRICTRC iemMemStackPushBeginSpecial(PVMCPUCC pVCpu, size_t cbMem, uint32_t cbAlign,
5236 void **ppvMem, uint8_t *pbUnmapInfo, uint64_t *puNewRsp) RT_NOEXCEPT;
5237VBOXSTRICTRC iemMemStackPushCommitSpecial(PVMCPUCC pVCpu, uint8_t bUnmapInfo, uint64_t uNewRsp) RT_NOEXCEPT;
5238VBOXSTRICTRC iemMemStackPushU16(PVMCPUCC pVCpu, uint16_t u16Value) RT_NOEXCEPT;
5239VBOXSTRICTRC iemMemStackPushU32(PVMCPUCC pVCpu, uint32_t u32Value) RT_NOEXCEPT;
5240VBOXSTRICTRC iemMemStackPushU64(PVMCPUCC pVCpu, uint64_t u64Value) RT_NOEXCEPT;
5241VBOXSTRICTRC iemMemStackPushU16Ex(PVMCPUCC pVCpu, uint16_t u16Value, PRTUINT64U pTmpRsp) RT_NOEXCEPT;
5242VBOXSTRICTRC iemMemStackPushU32Ex(PVMCPUCC pVCpu, uint32_t u32Value, PRTUINT64U pTmpRsp) RT_NOEXCEPT;
5243VBOXSTRICTRC iemMemStackPushU64Ex(PVMCPUCC pVCpu, uint64_t u64Value, PRTUINT64U pTmpRsp) RT_NOEXCEPT;
5244VBOXSTRICTRC iemMemStackPushU32SReg(PVMCPUCC pVCpu, uint32_t u32Value) RT_NOEXCEPT;
5245VBOXSTRICTRC iemMemStackPopBeginSpecial(PVMCPUCC pVCpu, size_t cbMem, uint32_t cbAlign,
5246 void const **ppvMem, uint8_t *pbUnmapInfo, uint64_t *puNewRsp) RT_NOEXCEPT;
5247VBOXSTRICTRC iemMemStackPopContinueSpecial(PVMCPUCC pVCpu, size_t off, size_t cbMem,
5248 void const **ppvMem, uint8_t *pbUnmapInfo, uint64_t uCurNewRsp) RT_NOEXCEPT;
5249VBOXSTRICTRC iemMemStackPopDoneSpecial(PVMCPUCC pVCpu, uint8_t bUnmapInfo) RT_NOEXCEPT;
5250VBOXSTRICTRC iemMemStackPopU16(PVMCPUCC pVCpu, uint16_t *pu16Value) RT_NOEXCEPT;
5251VBOXSTRICTRC iemMemStackPopU32(PVMCPUCC pVCpu, uint32_t *pu32Value) RT_NOEXCEPT;
5252VBOXSTRICTRC iemMemStackPopU64(PVMCPUCC pVCpu, uint64_t *pu64Value) RT_NOEXCEPT;
5253VBOXSTRICTRC iemMemStackPopU16Ex(PVMCPUCC pVCpu, uint16_t *pu16Value, PRTUINT64U pTmpRsp) RT_NOEXCEPT;
5254VBOXSTRICTRC iemMemStackPopU32Ex(PVMCPUCC pVCpu, uint32_t *pu32Value, PRTUINT64U pTmpRsp) RT_NOEXCEPT;
5255VBOXSTRICTRC iemMemStackPopU64Ex(PVMCPUCC pVCpu, uint64_t *pu64Value, PRTUINT64U pTmpRsp) RT_NOEXCEPT;
5256
5257#ifdef IEM_WITH_SETJMP
5258void iemMemStackPushU16SafeJmp(PVMCPUCC pVCpu, uint16_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
5259void iemMemStackPushU32SafeJmp(PVMCPUCC pVCpu, uint32_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
5260void iemMemStackPushU32SRegSafeJmp(PVMCPUCC pVCpu, uint32_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
5261void iemMemStackPushU64SafeJmp(PVMCPUCC pVCpu, uint64_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
5262void iemMemStackPopGRegU16SafeJmp(PVMCPUCC pVCpu, uint8_t iGReg) IEM_NOEXCEPT_MAY_LONGJMP;
5263void iemMemStackPopGRegU32SafeJmp(PVMCPUCC pVCpu, uint8_t iGReg) IEM_NOEXCEPT_MAY_LONGJMP;
5264void iemMemStackPopGRegU64SafeJmp(PVMCPUCC pVCpu, uint8_t iGReg) IEM_NOEXCEPT_MAY_LONGJMP;
5265
5266void iemMemFlat32StackPushU16SafeJmp(PVMCPUCC pVCpu, uint16_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
5267void iemMemFlat32StackPushU32SafeJmp(PVMCPUCC pVCpu, uint32_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
5268void iemMemFlat32StackPushU32SRegSafeJmp(PVMCPUCC pVCpu, uint32_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
5269void iemMemFlat32StackPopGRegU16SafeJmp(PVMCPUCC pVCpu, uint8_t iGReg) IEM_NOEXCEPT_MAY_LONGJMP;
5270void iemMemFlat32StackPopGRegU32SafeJmp(PVMCPUCC pVCpu, uint8_t iGReg) IEM_NOEXCEPT_MAY_LONGJMP;
5271
5272void iemMemFlat64StackPushU16SafeJmp(PVMCPUCC pVCpu, uint16_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
5273void iemMemFlat64StackPushU64SafeJmp(PVMCPUCC pVCpu, uint64_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
5274void iemMemFlat64StackPopGRegU16SafeJmp(PVMCPUCC pVCpu, uint8_t iGReg) IEM_NOEXCEPT_MAY_LONGJMP;
5275void iemMemFlat64StackPopGRegU64SafeJmp(PVMCPUCC pVCpu, uint8_t iGReg) IEM_NOEXCEPT_MAY_LONGJMP;
5276
5277void iemMemStoreStackU16SafeJmp(PVMCPUCC pVCpu, RTGCPTR GCPtrMem, uint16_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
5278void iemMemStoreStackU32SafeJmp(PVMCPUCC pVCpu, RTGCPTR GCPtrMem, uint32_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
5279void iemMemStoreStackU32SRegSafeJmp(PVMCPUCC pVCpu, RTGCPTR GCPtrMem, uint32_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
5280void iemMemStoreStackU64SafeJmp(PVMCPUCC pVCpu, RTGCPTR GCPtrMem, uint64_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
5281
5282uint16_t iemMemFetchStackU16SafeJmp(PVMCPUCC pVCpu, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5283uint32_t iemMemFetchStackU32SafeJmp(PVMCPUCC pVCpu, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5284uint64_t iemMemFetchStackU64SafeJmp(PVMCPUCC pVCpu, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5285
5286#endif
5287
5288/** @} */
5289
5290/** @name IEMAllCImpl.cpp
5291 * @note sed -e '/IEM_CIMPL_DEF_/!d' -e 's/IEM_CIMPL_DEF_/IEM_CIMPL_PROTO_/' -e 's/$/;/'
5292 * @{ */
5293IEM_CIMPL_PROTO_2(iemCImpl_pop_mem16, uint16_t, iEffSeg, RTGCPTR, GCPtrEffDst);
5294IEM_CIMPL_PROTO_2(iemCImpl_pop_mem32, uint16_t, iEffSeg, RTGCPTR, GCPtrEffDst);
5295IEM_CIMPL_PROTO_2(iemCImpl_pop_mem64, uint16_t, iEffSeg, RTGCPTR, GCPtrEffDst);
5296IEM_CIMPL_PROTO_0(iemCImpl_popa_16);
5297IEM_CIMPL_PROTO_0(iemCImpl_popa_32);
5298IEM_CIMPL_PROTO_0(iemCImpl_pusha_16);
5299IEM_CIMPL_PROTO_0(iemCImpl_pusha_32);
5300IEM_CIMPL_PROTO_1(iemCImpl_pushf, IEMMODE, enmEffOpSize);
5301IEM_CIMPL_PROTO_1(iemCImpl_popf, IEMMODE, enmEffOpSize);
5302IEM_CIMPL_PROTO_1(iemCImpl_call_16, uint16_t, uNewPC);
5303IEM_CIMPL_PROTO_1(iemCImpl_call_rel_16, int16_t, offDisp);
5304IEM_CIMPL_PROTO_1(iemCImpl_call_32, uint32_t, uNewPC);
5305IEM_CIMPL_PROTO_1(iemCImpl_call_rel_32, int32_t, offDisp);
5306IEM_CIMPL_PROTO_1(iemCImpl_call_64, uint64_t, uNewPC);
5307IEM_CIMPL_PROTO_1(iemCImpl_call_rel_64, int64_t, offDisp);
5308IEM_CIMPL_PROTO_3(iemCImpl_FarJmp, uint16_t, uSel, uint64_t, offSeg, IEMMODE, enmEffOpSize);
5309IEM_CIMPL_PROTO_3(iemCImpl_callf, uint16_t, uSel, uint64_t, offSeg, IEMMODE, enmEffOpSize);
5310typedef IEM_CIMPL_DECL_TYPE_3(FNIEMCIMPLFARBRANCH, uint16_t, uSel, uint64_t, offSeg, IEMMODE, enmEffOpSize);
5311typedef FNIEMCIMPLFARBRANCH *PFNIEMCIMPLFARBRANCH;
5312IEM_CIMPL_PROTO_2(iemCImpl_retf, IEMMODE, enmEffOpSize, uint16_t, cbPop);
5313IEM_CIMPL_PROTO_0(iemCImpl_retn_16);
5314IEM_CIMPL_PROTO_0(iemCImpl_retn_32);
5315IEM_CIMPL_PROTO_0(iemCImpl_retn_64);
5316IEM_CIMPL_PROTO_1(iemCImpl_retn_iw_16, uint16_t, cbPop);
5317IEM_CIMPL_PROTO_1(iemCImpl_retn_iw_32, uint16_t, cbPop);
5318IEM_CIMPL_PROTO_1(iemCImpl_retn_iw_64, uint16_t, cbPop);
5319IEM_CIMPL_PROTO_3(iemCImpl_enter, IEMMODE, enmEffOpSize, uint16_t, cbFrame, uint8_t, cParameters);
5320IEM_CIMPL_PROTO_1(iemCImpl_leave, IEMMODE, enmEffOpSize);
5321IEM_CIMPL_PROTO_2(iemCImpl_int, uint8_t, u8Int, IEMINT, enmInt);
5322IEM_CIMPL_PROTO_1(iemCImpl_iret_real_v8086, IEMMODE, enmEffOpSize);
5323IEM_CIMPL_PROTO_4(iemCImpl_iret_prot_v8086, uint32_t, uNewEip, uint16_t, uNewCs, uint32_t, uNewFlags, uint64_t, uNewRsp);
5324IEM_CIMPL_PROTO_1(iemCImpl_iret_prot_NestedTask, IEMMODE, enmEffOpSize);
5325IEM_CIMPL_PROTO_1(iemCImpl_iret_prot, IEMMODE, enmEffOpSize);
5326IEM_CIMPL_PROTO_1(iemCImpl_iret_64bit, IEMMODE, enmEffOpSize);
5327IEM_CIMPL_PROTO_1(iemCImpl_iret, IEMMODE, enmEffOpSize);
5328IEM_CIMPL_PROTO_0(iemCImpl_loadall286);
5329IEM_CIMPL_PROTO_0(iemCImpl_syscall);
5330IEM_CIMPL_PROTO_1(iemCImpl_sysret, IEMMODE, enmEffOpSize);
5331IEM_CIMPL_PROTO_0(iemCImpl_sysenter);
5332IEM_CIMPL_PROTO_1(iemCImpl_sysexit, IEMMODE, enmEffOpSize);
5333IEM_CIMPL_PROTO_2(iemCImpl_LoadSReg, uint8_t, iSegReg, uint16_t, uSel);
5334IEM_CIMPL_PROTO_2(iemCImpl_load_SReg, uint8_t, iSegReg, uint16_t, uSel);
5335IEM_CIMPL_PROTO_2(iemCImpl_pop_Sreg, uint8_t, iSegReg, IEMMODE, enmEffOpSize);
5336IEM_CIMPL_PROTO_5(iemCImpl_load_SReg_Greg, uint16_t, uSel, uint64_t, offSeg, uint8_t, iSegReg, uint8_t, iGReg, IEMMODE, enmEffOpSize);
5337IEM_CIMPL_PROTO_2(iemCImpl_VerX, uint16_t, uSel, bool, fWrite);
5338IEM_CIMPL_PROTO_3(iemCImpl_LarLsl_u64, uint64_t *, pu64Dst, uint16_t, uSel, bool, fIsLar);
5339IEM_CIMPL_PROTO_3(iemCImpl_LarLsl_u16, uint16_t *, pu16Dst, uint16_t, uSel, bool, fIsLar);
5340IEM_CIMPL_PROTO_3(iemCImpl_lgdt, uint8_t, iEffSeg, RTGCPTR, GCPtrEffSrc, IEMMODE, enmEffOpSize);
5341IEM_CIMPL_PROTO_2(iemCImpl_sgdt, uint8_t, iEffSeg, RTGCPTR, GCPtrEffDst);
5342IEM_CIMPL_PROTO_3(iemCImpl_lidt, uint8_t, iEffSeg, RTGCPTR, GCPtrEffSrc, IEMMODE, enmEffOpSize);
5343IEM_CIMPL_PROTO_2(iemCImpl_sidt, uint8_t, iEffSeg, RTGCPTR, GCPtrEffDst);
5344IEM_CIMPL_PROTO_1(iemCImpl_lldt, uint16_t, uNewLdt);
5345IEM_CIMPL_PROTO_2(iemCImpl_sldt_reg, uint8_t, iGReg, uint8_t, enmEffOpSize);
5346IEM_CIMPL_PROTO_2(iemCImpl_sldt_mem, uint8_t, iEffSeg, RTGCPTR, GCPtrEffDst);
5347IEM_CIMPL_PROTO_1(iemCImpl_ltr, uint16_t, uNewTr);
5348IEM_CIMPL_PROTO_2(iemCImpl_str_reg, uint8_t, iGReg, uint8_t, enmEffOpSize);
5349IEM_CIMPL_PROTO_2(iemCImpl_str_mem, uint8_t, iEffSeg, RTGCPTR, GCPtrEffDst);
5350IEM_CIMPL_PROTO_2(iemCImpl_mov_Rd_Cd, uint8_t, iGReg, uint8_t, iCrReg);
5351IEM_CIMPL_PROTO_2(iemCImpl_smsw_reg, uint8_t, iGReg, uint8_t, enmEffOpSize);
5352IEM_CIMPL_PROTO_2(iemCImpl_smsw_mem, uint8_t, iEffSeg, RTGCPTR, GCPtrEffDst);
5353IEM_CIMPL_PROTO_4(iemCImpl_load_CrX, uint8_t, iCrReg, uint64_t, uNewCrX, IEMACCESSCRX, enmAccessCrX, uint8_t, iGReg);
5354IEM_CIMPL_PROTO_2(iemCImpl_mov_Cd_Rd, uint8_t, iCrReg, uint8_t, iGReg);
5355IEM_CIMPL_PROTO_2(iemCImpl_lmsw, uint16_t, u16NewMsw, RTGCPTR, GCPtrEffDst);
5356IEM_CIMPL_PROTO_0(iemCImpl_clts);
5357IEM_CIMPL_PROTO_2(iemCImpl_mov_Rd_Dd, uint8_t, iGReg, uint8_t, iDrReg);
5358IEM_CIMPL_PROTO_2(iemCImpl_mov_Dd_Rd, uint8_t, iDrReg, uint8_t, iGReg);
5359IEM_CIMPL_PROTO_2(iemCImpl_mov_Rd_Td, uint8_t, iGReg, uint8_t, iTrReg);
5360IEM_CIMPL_PROTO_2(iemCImpl_mov_Td_Rd, uint8_t, iTrReg, uint8_t, iGReg);
5361IEM_CIMPL_PROTO_1(iemCImpl_invlpg, RTGCPTR, GCPtrPage);
5362IEM_CIMPL_PROTO_3(iemCImpl_invpcid, uint8_t, iEffSeg, RTGCPTR, GCPtrInvpcidDesc, uint64_t, uInvpcidType);
5363IEM_CIMPL_PROTO_0(iemCImpl_invd);
5364IEM_CIMPL_PROTO_0(iemCImpl_wbinvd);
5365IEM_CIMPL_PROTO_0(iemCImpl_rsm);
5366IEM_CIMPL_PROTO_0(iemCImpl_rdtsc);
5367IEM_CIMPL_PROTO_0(iemCImpl_rdtscp);
5368IEM_CIMPL_PROTO_0(iemCImpl_rdpmc);
5369IEM_CIMPL_PROTO_0(iemCImpl_rdmsr);
5370IEM_CIMPL_PROTO_0(iemCImpl_wrmsr);
5371IEM_CIMPL_PROTO_3(iemCImpl_in, uint16_t, u16Port, uint8_t, cbReg, uint8_t, bImmAndEffAddrMode);
5372IEM_CIMPL_PROTO_2(iemCImpl_in_eAX_DX, uint8_t, cbReg, IEMMODE, enmEffAddrMode);
5373IEM_CIMPL_PROTO_3(iemCImpl_out, uint16_t, u16Port, uint8_t, cbReg, uint8_t, bImmAndEffAddrMode);
5374IEM_CIMPL_PROTO_2(iemCImpl_out_DX_eAX, uint8_t, cbReg, IEMMODE, enmEffAddrMode);
5375IEM_CIMPL_PROTO_0(iemCImpl_cli);
5376IEM_CIMPL_PROTO_0(iemCImpl_sti);
5377IEM_CIMPL_PROTO_0(iemCImpl_hlt);
5378IEM_CIMPL_PROTO_1(iemCImpl_monitor, uint8_t, iEffSeg);
5379IEM_CIMPL_PROTO_0(iemCImpl_mwait);
5380IEM_CIMPL_PROTO_0(iemCImpl_swapgs);
5381IEM_CIMPL_PROTO_0(iemCImpl_cpuid);
5382IEM_CIMPL_PROTO_1(iemCImpl_aad, uint8_t, bImm);
5383IEM_CIMPL_PROTO_1(iemCImpl_aam, uint8_t, bImm);
5384IEM_CIMPL_PROTO_0(iemCImpl_daa);
5385IEM_CIMPL_PROTO_0(iemCImpl_das);
5386IEM_CIMPL_PROTO_0(iemCImpl_aaa);
5387IEM_CIMPL_PROTO_0(iemCImpl_aas);
5388IEM_CIMPL_PROTO_3(iemCImpl_bound_16, int16_t, idxArray, int16_t, idxLowerBound, int16_t, idxUpperBound);
5389IEM_CIMPL_PROTO_3(iemCImpl_bound_32, int32_t, idxArray, int32_t, idxLowerBound, int32_t, idxUpperBound);
5390IEM_CIMPL_PROTO_0(iemCImpl_xgetbv);
5391IEM_CIMPL_PROTO_0(iemCImpl_xsetbv);
5392IEM_CIMPL_PROTO_5(iemCImpl_cmpxchg16b_fallback_rendezvous, PRTUINT128U, pu128Dst, PRTUINT128U, pu128RaxRdx,
5393 PRTUINT128U, pu128RbxRcx, uint32_t *, pEFlags, uint8_t, bUnmapInfo);
5394IEM_CIMPL_PROTO_2(iemCImpl_clflush_clflushopt, uint8_t, iEffSeg, RTGCPTR, GCPtrEff);
5395IEM_CIMPL_PROTO_1(iemCImpl_finit, bool, fCheckXcpts);
5396IEM_CIMPL_PROTO_3(iemCImpl_fxsave, uint8_t, iEffSeg, RTGCPTR, GCPtrEff, IEMMODE, enmEffOpSize);
5397IEM_CIMPL_PROTO_3(iemCImpl_fxrstor, uint8_t, iEffSeg, RTGCPTR, GCPtrEff, IEMMODE, enmEffOpSize);
5398IEM_CIMPL_PROTO_3(iemCImpl_xsave, uint8_t, iEffSeg, RTGCPTR, GCPtrEff, IEMMODE, enmEffOpSize);
5399IEM_CIMPL_PROTO_3(iemCImpl_xrstor, uint8_t, iEffSeg, RTGCPTR, GCPtrEff, IEMMODE, enmEffOpSize);
5400IEM_CIMPL_PROTO_2(iemCImpl_stmxcsr, uint8_t, iEffSeg, RTGCPTR, GCPtrEff);
5401IEM_CIMPL_PROTO_2(iemCImpl_vstmxcsr, uint8_t, iEffSeg, RTGCPTR, GCPtrEff);
5402IEM_CIMPL_PROTO_2(iemCImpl_ldmxcsr, uint8_t, iEffSeg, RTGCPTR, GCPtrEff);
5403IEM_CIMPL_PROTO_3(iemCImpl_fnstenv, IEMMODE, enmEffOpSize, uint8_t, iEffSeg, RTGCPTR, GCPtrEffDst);
5404IEM_CIMPL_PROTO_3(iemCImpl_fnsave, IEMMODE, enmEffOpSize, uint8_t, iEffSeg, RTGCPTR, GCPtrEffDst);
5405IEM_CIMPL_PROTO_3(iemCImpl_fldenv, IEMMODE, enmEffOpSize, uint8_t, iEffSeg, RTGCPTR, GCPtrEffSrc);
5406IEM_CIMPL_PROTO_3(iemCImpl_frstor, IEMMODE, enmEffOpSize, uint8_t, iEffSeg, RTGCPTR, GCPtrEffSrc);
5407IEM_CIMPL_PROTO_1(iemCImpl_fldcw, uint16_t, u16Fcw);
5408IEM_CIMPL_PROTO_2(iemCImpl_fxch_underflow, uint8_t, iStReg, uint16_t, uFpuOpcode);
5409IEM_CIMPL_PROTO_3(iemCImpl_fcomi_fucomi, uint8_t, iStReg, bool, fUCmp, uint32_t, uPopAndFpuOpcode);
5410IEM_CIMPL_PROTO_2(iemCImpl_rdseed, uint8_t, iReg, IEMMODE, enmEffOpSize);
5411IEM_CIMPL_PROTO_2(iemCImpl_rdrand, uint8_t, iReg, IEMMODE, enmEffOpSize);
5412/** @} */
5413
5414/** @name IEMAllCImplStrInstr.cpp.h
5415 * @note sed -e '/IEM_CIMPL_DEF_/!d' -e 's/IEM_CIMPL_DEF_/IEM_CIMPL_PROTO_/' -e 's/$/;/' -e 's/RT_CONCAT4(//' \
5416 * -e 's/,ADDR_SIZE)/64/g' -e 's/,OP_SIZE,/64/g' -e 's/,OP_rAX,/rax/g' IEMAllCImplStrInstr.cpp.h
5417 * @{ */
5418IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op8_addr16, uint8_t, iEffSeg);
5419IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op8_addr16, uint8_t, iEffSeg);
5420IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_al_m16);
5421IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_al_m16);
5422IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op8_addr16, uint8_t, iEffSeg);
5423IEM_CIMPL_PROTO_0(iemCImpl_stos_al_m16);
5424IEM_CIMPL_PROTO_1(iemCImpl_lods_al_m16, int8_t, iEffSeg);
5425IEM_CIMPL_PROTO_1(iemCImpl_ins_op8_addr16, bool, fIoChecked);
5426IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op8_addr16, bool, fIoChecked);
5427IEM_CIMPL_PROTO_2(iemCImpl_outs_op8_addr16, uint8_t, iEffSeg, bool, fIoChecked);
5428IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op8_addr16, uint8_t, iEffSeg, bool, fIoChecked);
5429
5430IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op16_addr16, uint8_t, iEffSeg);
5431IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op16_addr16, uint8_t, iEffSeg);
5432IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_ax_m16);
5433IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_ax_m16);
5434IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op16_addr16, uint8_t, iEffSeg);
5435IEM_CIMPL_PROTO_0(iemCImpl_stos_ax_m16);
5436IEM_CIMPL_PROTO_1(iemCImpl_lods_ax_m16, int8_t, iEffSeg);
5437IEM_CIMPL_PROTO_1(iemCImpl_ins_op16_addr16, bool, fIoChecked);
5438IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op16_addr16, bool, fIoChecked);
5439IEM_CIMPL_PROTO_2(iemCImpl_outs_op16_addr16, uint8_t, iEffSeg, bool, fIoChecked);
5440IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op16_addr16, uint8_t, iEffSeg, bool, fIoChecked);
5441
5442IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op32_addr16, uint8_t, iEffSeg);
5443IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op32_addr16, uint8_t, iEffSeg);
5444IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_eax_m16);
5445IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_eax_m16);
5446IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op32_addr16, uint8_t, iEffSeg);
5447IEM_CIMPL_PROTO_0(iemCImpl_stos_eax_m16);
5448IEM_CIMPL_PROTO_1(iemCImpl_lods_eax_m16, int8_t, iEffSeg);
5449IEM_CIMPL_PROTO_1(iemCImpl_ins_op32_addr16, bool, fIoChecked);
5450IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op32_addr16, bool, fIoChecked);
5451IEM_CIMPL_PROTO_2(iemCImpl_outs_op32_addr16, uint8_t, iEffSeg, bool, fIoChecked);
5452IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op32_addr16, uint8_t, iEffSeg, bool, fIoChecked);
5453
5454
5455IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op8_addr32, uint8_t, iEffSeg);
5456IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op8_addr32, uint8_t, iEffSeg);
5457IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_al_m32);
5458IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_al_m32);
5459IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op8_addr32, uint8_t, iEffSeg);
5460IEM_CIMPL_PROTO_0(iemCImpl_stos_al_m32);
5461IEM_CIMPL_PROTO_1(iemCImpl_lods_al_m32, int8_t, iEffSeg);
5462IEM_CIMPL_PROTO_1(iemCImpl_ins_op8_addr32, bool, fIoChecked);
5463IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op8_addr32, bool, fIoChecked);
5464IEM_CIMPL_PROTO_2(iemCImpl_outs_op8_addr32, uint8_t, iEffSeg, bool, fIoChecked);
5465IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op8_addr32, uint8_t, iEffSeg, bool, fIoChecked);
5466
5467IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op16_addr32, uint8_t, iEffSeg);
5468IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op16_addr32, uint8_t, iEffSeg);
5469IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_ax_m32);
5470IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_ax_m32);
5471IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op16_addr32, uint8_t, iEffSeg);
5472IEM_CIMPL_PROTO_0(iemCImpl_stos_ax_m32);
5473IEM_CIMPL_PROTO_1(iemCImpl_lods_ax_m32, int8_t, iEffSeg);
5474IEM_CIMPL_PROTO_1(iemCImpl_ins_op16_addr32, bool, fIoChecked);
5475IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op16_addr32, bool, fIoChecked);
5476IEM_CIMPL_PROTO_2(iemCImpl_outs_op16_addr32, uint8_t, iEffSeg, bool, fIoChecked);
5477IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op16_addr32, uint8_t, iEffSeg, bool, fIoChecked);
5478
5479IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op32_addr32, uint8_t, iEffSeg);
5480IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op32_addr32, uint8_t, iEffSeg);
5481IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_eax_m32);
5482IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_eax_m32);
5483IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op32_addr32, uint8_t, iEffSeg);
5484IEM_CIMPL_PROTO_0(iemCImpl_stos_eax_m32);
5485IEM_CIMPL_PROTO_1(iemCImpl_lods_eax_m32, int8_t, iEffSeg);
5486IEM_CIMPL_PROTO_1(iemCImpl_ins_op32_addr32, bool, fIoChecked);
5487IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op32_addr32, bool, fIoChecked);
5488IEM_CIMPL_PROTO_2(iemCImpl_outs_op32_addr32, uint8_t, iEffSeg, bool, fIoChecked);
5489IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op32_addr32, uint8_t, iEffSeg, bool, fIoChecked);
5490
5491IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op64_addr32, uint8_t, iEffSeg);
5492IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op64_addr32, uint8_t, iEffSeg);
5493IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_rax_m32);
5494IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_rax_m32);
5495IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op64_addr32, uint8_t, iEffSeg);
5496IEM_CIMPL_PROTO_0(iemCImpl_stos_rax_m32);
5497IEM_CIMPL_PROTO_1(iemCImpl_lods_rax_m32, int8_t, iEffSeg);
5498IEM_CIMPL_PROTO_1(iemCImpl_ins_op64_addr32, bool, fIoChecked);
5499IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op64_addr32, bool, fIoChecked);
5500IEM_CIMPL_PROTO_2(iemCImpl_outs_op64_addr32, uint8_t, iEffSeg, bool, fIoChecked);
5501IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op64_addr32, uint8_t, iEffSeg, bool, fIoChecked);
5502
5503
5504IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op8_addr64, uint8_t, iEffSeg);
5505IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op8_addr64, uint8_t, iEffSeg);
5506IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_al_m64);
5507IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_al_m64);
5508IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op8_addr64, uint8_t, iEffSeg);
5509IEM_CIMPL_PROTO_0(iemCImpl_stos_al_m64);
5510IEM_CIMPL_PROTO_1(iemCImpl_lods_al_m64, int8_t, iEffSeg);
5511IEM_CIMPL_PROTO_1(iemCImpl_ins_op8_addr64, bool, fIoChecked);
5512IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op8_addr64, bool, fIoChecked);
5513IEM_CIMPL_PROTO_2(iemCImpl_outs_op8_addr64, uint8_t, iEffSeg, bool, fIoChecked);
5514IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op8_addr64, uint8_t, iEffSeg, bool, fIoChecked);
5515
5516IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op16_addr64, uint8_t, iEffSeg);
5517IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op16_addr64, uint8_t, iEffSeg);
5518IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_ax_m64);
5519IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_ax_m64);
5520IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op16_addr64, uint8_t, iEffSeg);
5521IEM_CIMPL_PROTO_0(iemCImpl_stos_ax_m64);
5522IEM_CIMPL_PROTO_1(iemCImpl_lods_ax_m64, int8_t, iEffSeg);
5523IEM_CIMPL_PROTO_1(iemCImpl_ins_op16_addr64, bool, fIoChecked);
5524IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op16_addr64, bool, fIoChecked);
5525IEM_CIMPL_PROTO_2(iemCImpl_outs_op16_addr64, uint8_t, iEffSeg, bool, fIoChecked);
5526IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op16_addr64, uint8_t, iEffSeg, bool, fIoChecked);
5527
5528IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op32_addr64, uint8_t, iEffSeg);
5529IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op32_addr64, uint8_t, iEffSeg);
5530IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_eax_m64);
5531IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_eax_m64);
5532IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op32_addr64, uint8_t, iEffSeg);
5533IEM_CIMPL_PROTO_0(iemCImpl_stos_eax_m64);
5534IEM_CIMPL_PROTO_1(iemCImpl_lods_eax_m64, int8_t, iEffSeg);
5535IEM_CIMPL_PROTO_1(iemCImpl_ins_op32_addr64, bool, fIoChecked);
5536IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op32_addr64, bool, fIoChecked);
5537IEM_CIMPL_PROTO_2(iemCImpl_outs_op32_addr64, uint8_t, iEffSeg, bool, fIoChecked);
5538IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op32_addr64, uint8_t, iEffSeg, bool, fIoChecked);
5539
5540IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op64_addr64, uint8_t, iEffSeg);
5541IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op64_addr64, uint8_t, iEffSeg);
5542IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_rax_m64);
5543IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_rax_m64);
5544IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op64_addr64, uint8_t, iEffSeg);
5545IEM_CIMPL_PROTO_0(iemCImpl_stos_rax_m64);
5546IEM_CIMPL_PROTO_1(iemCImpl_lods_rax_m64, int8_t, iEffSeg);
5547IEM_CIMPL_PROTO_1(iemCImpl_ins_op64_addr64, bool, fIoChecked);
5548IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op64_addr64, bool, fIoChecked);
5549IEM_CIMPL_PROTO_2(iemCImpl_outs_op64_addr64, uint8_t, iEffSeg, bool, fIoChecked);
5550IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op64_addr64, uint8_t, iEffSeg, bool, fIoChecked);
5551/** @} */
5552
5553#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
5554VBOXSTRICTRC iemVmxVmexit(PVMCPUCC pVCpu, uint32_t uExitReason, uint64_t u64ExitQual) RT_NOEXCEPT;
5555VBOXSTRICTRC iemVmxVmexitInstr(PVMCPUCC pVCpu, uint32_t uExitReason, uint8_t cbInstr) RT_NOEXCEPT;
5556VBOXSTRICTRC iemVmxVmexitInstrNeedsInfo(PVMCPUCC pVCpu, uint32_t uExitReason, VMXINSTRID uInstrId, uint8_t cbInstr) RT_NOEXCEPT;
5557VBOXSTRICTRC iemVmxVmexitTaskSwitch(PVMCPUCC pVCpu, IEMTASKSWITCH enmTaskSwitch, RTSEL SelNewTss, uint8_t cbInstr) RT_NOEXCEPT;
5558VBOXSTRICTRC iemVmxVmexitEvent(PVMCPUCC pVCpu, uint8_t uVector, uint32_t fFlags, uint32_t uErrCode, uint64_t uCr2, uint8_t cbInstr) RT_NOEXCEPT;
5559VBOXSTRICTRC iemVmxVmexitEventDoubleFault(PVMCPUCC pVCpu) RT_NOEXCEPT;
5560VBOXSTRICTRC iemVmxVmexitEpt(PVMCPUCC pVCpu, PPGMPTWALK pWalk, uint32_t fAccess, uint32_t fSlatFail, uint8_t cbInstr) RT_NOEXCEPT;
5561VBOXSTRICTRC iemVmxVmexitPreemptTimer(PVMCPUCC pVCpu) RT_NOEXCEPT;
5562VBOXSTRICTRC iemVmxVmexitInstrMwait(PVMCPUCC pVCpu, bool fMonitorHwArmed, uint8_t cbInstr) RT_NOEXCEPT;
5563VBOXSTRICTRC iemVmxVmexitInstrIo(PVMCPUCC pVCpu, VMXINSTRID uInstrId, uint16_t u16Port,
5564 bool fImm, uint8_t cbAccess, uint8_t cbInstr) RT_NOEXCEPT;
5565VBOXSTRICTRC iemVmxVmexitInstrStrIo(PVMCPUCC pVCpu, VMXINSTRID uInstrId, uint16_t u16Port, uint8_t cbAccess,
5566 bool fRep, VMXEXITINSTRINFO ExitInstrInfo, uint8_t cbInstr) RT_NOEXCEPT;
5567VBOXSTRICTRC iemVmxVmexitInstrMovDrX(PVMCPUCC pVCpu, VMXINSTRID uInstrId, uint8_t iDrReg, uint8_t iGReg, uint8_t cbInstr) RT_NOEXCEPT;
5568VBOXSTRICTRC iemVmxVmexitInstrMovToCr8(PVMCPUCC pVCpu, uint8_t iGReg, uint8_t cbInstr) RT_NOEXCEPT;
5569VBOXSTRICTRC iemVmxVmexitInstrMovFromCr8(PVMCPUCC pVCpu, uint8_t iGReg, uint8_t cbInstr) RT_NOEXCEPT;
5570VBOXSTRICTRC iemVmxVmexitInstrMovToCr3(PVMCPUCC pVCpu, uint64_t uNewCr3, uint8_t iGReg, uint8_t cbInstr) RT_NOEXCEPT;
5571VBOXSTRICTRC iemVmxVmexitInstrMovFromCr3(PVMCPUCC pVCpu, uint8_t iGReg, uint8_t cbInstr) RT_NOEXCEPT;
5572VBOXSTRICTRC iemVmxVmexitInstrMovToCr0Cr4(PVMCPUCC pVCpu, uint8_t iCrReg, uint64_t *puNewCrX, uint8_t iGReg, uint8_t cbInstr) RT_NOEXCEPT;
5573VBOXSTRICTRC iemVmxVmexitInstrClts(PVMCPUCC pVCpu, uint8_t cbInstr) RT_NOEXCEPT;
5574VBOXSTRICTRC iemVmxVmexitInstrLmsw(PVMCPUCC pVCpu, uint32_t uGuestCr0, uint16_t *pu16NewMsw,
5575 RTGCPTR GCPtrEffDst, uint8_t cbInstr) RT_NOEXCEPT;
5576VBOXSTRICTRC iemVmxVmexitInstrInvlpg(PVMCPUCC pVCpu, RTGCPTR GCPtrPage, uint8_t cbInstr) RT_NOEXCEPT;
5577VBOXSTRICTRC iemVmxApicWriteEmulation(PVMCPUCC pVCpu) RT_NOEXCEPT;
5578VBOXSTRICTRC iemVmxVirtApicAccessUnused(PVMCPUCC pVCpu, PRTGCPHYS pGCPhysAccess, size_t cbAccess, uint32_t fAccess) RT_NOEXCEPT;
5579uint32_t iemVmxVirtApicReadRaw32(PVMCPUCC pVCpu, uint16_t offReg) RT_NOEXCEPT;
5580void iemVmxVirtApicWriteRaw32(PVMCPUCC pVCpu, uint16_t offReg, uint32_t uReg) RT_NOEXCEPT;
5581VBOXSTRICTRC iemVmxInvvpid(PVMCPUCC pVCpu, uint8_t cbInstr, uint8_t iEffSeg, RTGCPTR GCPtrInvvpidDesc,
5582 uint64_t u64InvvpidType, PCVMXVEXITINFO pExitInfo) RT_NOEXCEPT;
5583bool iemVmxIsRdmsrWrmsrInterceptSet(PCVMCPU pVCpu, uint32_t uExitReason, uint32_t idMsr) RT_NOEXCEPT;
5584IEM_CIMPL_PROTO_0(iemCImpl_vmxoff);
5585IEM_CIMPL_PROTO_2(iemCImpl_vmxon, uint8_t, iEffSeg, RTGCPTR, GCPtrVmxon);
5586IEM_CIMPL_PROTO_0(iemCImpl_vmlaunch);
5587IEM_CIMPL_PROTO_0(iemCImpl_vmresume);
5588IEM_CIMPL_PROTO_2(iemCImpl_vmptrld, uint8_t, iEffSeg, RTGCPTR, GCPtrVmcs);
5589IEM_CIMPL_PROTO_2(iemCImpl_vmptrst, uint8_t, iEffSeg, RTGCPTR, GCPtrVmcs);
5590IEM_CIMPL_PROTO_2(iemCImpl_vmclear, uint8_t, iEffSeg, RTGCPTR, GCPtrVmcs);
5591IEM_CIMPL_PROTO_2(iemCImpl_vmwrite_reg, uint64_t, u64Val, uint64_t, u64VmcsField);
5592IEM_CIMPL_PROTO_3(iemCImpl_vmwrite_mem, uint8_t, iEffSeg, RTGCPTR, GCPtrVal, uint32_t, u64VmcsField);
5593IEM_CIMPL_PROTO_2(iemCImpl_vmread_reg64, uint64_t *, pu64Dst, uint64_t, u64VmcsField);
5594IEM_CIMPL_PROTO_2(iemCImpl_vmread_reg32, uint64_t *, pu32Dst, uint32_t, u32VmcsField);
5595IEM_CIMPL_PROTO_3(iemCImpl_vmread_mem_reg64, uint8_t, iEffSeg, RTGCPTR, GCPtrDst, uint32_t, u64VmcsField);
5596IEM_CIMPL_PROTO_3(iemCImpl_vmread_mem_reg32, uint8_t, iEffSeg, RTGCPTR, GCPtrDst, uint32_t, u32VmcsField);
5597IEM_CIMPL_PROTO_3(iemCImpl_invvpid, uint8_t, iEffSeg, RTGCPTR, GCPtrInvvpidDesc, uint64_t, uInvvpidType);
5598IEM_CIMPL_PROTO_3(iemCImpl_invept, uint8_t, iEffSeg, RTGCPTR, GCPtrInveptDesc, uint64_t, uInveptType);
5599IEM_CIMPL_PROTO_0(iemCImpl_vmx_pause);
5600#endif
5601
5602#ifdef VBOX_WITH_NESTED_HWVIRT_SVM
5603VBOXSTRICTRC iemSvmVmexit(PVMCPUCC pVCpu, uint64_t uExitCode, uint64_t uExitInfo1, uint64_t uExitInfo2) RT_NOEXCEPT;
5604VBOXSTRICTRC iemHandleSvmEventIntercept(PVMCPUCC pVCpu, uint8_t cbInstr, uint8_t u8Vector, uint32_t fFlags, uint32_t uErr, uint64_t uCr2) RT_NOEXCEPT;
5605VBOXSTRICTRC iemSvmHandleIOIntercept(PVMCPUCC pVCpu, uint16_t u16Port, SVMIOIOTYPE enmIoType, uint8_t cbReg,
5606 uint8_t cAddrSizeBits, uint8_t iEffSeg, bool fRep, bool fStrIo, uint8_t cbInstr) RT_NOEXCEPT;
5607VBOXSTRICTRC iemSvmHandleMsrIntercept(PVMCPUCC pVCpu, uint32_t idMsr, bool fWrite, uint8_t cbInstr) RT_NOEXCEPT;
5608IEM_CIMPL_PROTO_0(iemCImpl_vmrun);
5609IEM_CIMPL_PROTO_0(iemCImpl_vmload);
5610IEM_CIMPL_PROTO_0(iemCImpl_vmsave);
5611IEM_CIMPL_PROTO_0(iemCImpl_clgi);
5612IEM_CIMPL_PROTO_0(iemCImpl_stgi);
5613IEM_CIMPL_PROTO_0(iemCImpl_invlpga);
5614IEM_CIMPL_PROTO_0(iemCImpl_skinit);
5615IEM_CIMPL_PROTO_0(iemCImpl_svm_pause);
5616#endif
5617
5618IEM_CIMPL_PROTO_0(iemCImpl_vmcall); /* vmx */
5619IEM_CIMPL_PROTO_0(iemCImpl_vmmcall); /* svm */
5620IEM_CIMPL_PROTO_1(iemCImpl_Hypercall, uint16_t, uDisOpcode); /* both */
5621
5622extern const PFNIEMOP g_apfnIemInterpretOnlyOneByteMap[256];
5623extern const PFNIEMOP g_apfnIemInterpretOnlyTwoByteMap[1024];
5624extern const PFNIEMOP g_apfnIemInterpretOnlyThreeByte0f3a[1024];
5625extern const PFNIEMOP g_apfnIemInterpretOnlyThreeByte0f38[1024];
5626extern const PFNIEMOP g_apfnIemInterpretOnlyVecMap1[1024];
5627extern const PFNIEMOP g_apfnIemInterpretOnlyVecMap2[1024];
5628extern const PFNIEMOP g_apfnIemInterpretOnlyVecMap3[1024];
5629
5630/*
5631 * Recompiler related stuff.
5632 */
5633extern const PFNIEMOP g_apfnIemThreadedRecompilerOneByteMap[256];
5634extern const PFNIEMOP g_apfnIemThreadedRecompilerTwoByteMap[1024];
5635extern const PFNIEMOP g_apfnIemThreadedRecompilerThreeByte0f3a[1024];
5636extern const PFNIEMOP g_apfnIemThreadedRecompilerThreeByte0f38[1024];
5637extern const PFNIEMOP g_apfnIemThreadedRecompilerVecMap1[1024];
5638extern const PFNIEMOP g_apfnIemThreadedRecompilerVecMap2[1024];
5639extern const PFNIEMOP g_apfnIemThreadedRecompilerVecMap3[1024];
5640
5641DECLCALLBACK(int) iemTbInit(PVMCC pVM, uint32_t cInitialTbs, uint32_t cMaxTbs,
5642 uint64_t cbInitialExec, uint64_t cbMaxExec, uint32_t cbChunkExec);
5643void iemThreadedTbObsolete(PVMCPUCC pVCpu, PIEMTB pTb, bool fSafeToFree);
5644void iemTbAllocatorProcessDelayedFrees(PVMCPUCC pVCpu, PIEMTBALLOCATOR pTbAllocator);
5645void iemTbAllocatorFreeupNativeSpace(PVMCPUCC pVCpu, uint32_t cNeededInstrs);
5646
5647
5648/** @todo FNIEMTHREADEDFUNC and friends may need more work... */
5649#if defined(__GNUC__) && !defined(IEM_WITH_THROW_CATCH)
5650typedef VBOXSTRICTRC /*__attribute__((__nothrow__))*/ FNIEMTHREADEDFUNC(PVMCPU pVCpu, uint64_t uParam0, uint64_t uParam1, uint64_t uParam2);
5651typedef FNIEMTHREADEDFUNC *PFNIEMTHREADEDFUNC;
5652# define IEM_DECL_IEMTHREADEDFUNC_DEF(a_Name) \
5653 VBOXSTRICTRC __attribute__((__nothrow__)) a_Name(PVMCPU pVCpu, uint64_t uParam0, uint64_t uParam1, uint64_t uParam2)
5654# define IEM_DECL_IEMTHREADEDFUNC_PROTO(a_Name) \
5655 VBOXSTRICTRC __attribute__((__nothrow__)) a_Name(PVMCPU pVCpu, uint64_t uParam0, uint64_t uParam1, uint64_t uParam2)
5656
5657#else
5658typedef VBOXSTRICTRC (FNIEMTHREADEDFUNC)(PVMCPU pVCpu, uint64_t uParam0, uint64_t uParam1, uint64_t uParam2);
5659typedef FNIEMTHREADEDFUNC *PFNIEMTHREADEDFUNC;
5660# define IEM_DECL_IEMTHREADEDFUNC_DEF(a_Name) \
5661 VBOXSTRICTRC a_Name(PVMCPU pVCpu, uint64_t uParam0, uint64_t uParam1, uint64_t uParam2) IEM_NOEXCEPT_MAY_LONGJMP
5662# define IEM_DECL_IEMTHREADEDFUNC_PROTO(a_Name) \
5663 VBOXSTRICTRC a_Name(PVMCPU pVCpu, uint64_t uParam0, uint64_t uParam1, uint64_t uParam2) IEM_NOEXCEPT_MAY_LONGJMP
5664#endif
5665
5666
5667IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_Nop);
5668IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_LogCpuState);
5669
5670IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_DeferToCImpl0);
5671
5672IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckIrq);
5673IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckMode);
5674IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckHwInstrBps);
5675IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckCsLim);
5676
5677IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckCsLimAndOpcodes);
5678IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckOpcodes);
5679IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckOpcodesConsiderCsLim);
5680
5681/* Branching: */
5682IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckCsLimAndPcAndOpcodes);
5683IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckPcAndOpcodes);
5684IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckPcAndOpcodesConsiderCsLim);
5685
5686IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckCsLimAndOpcodesLoadingTlb);
5687IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckOpcodesLoadingTlb);
5688IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckOpcodesLoadingTlbConsiderCsLim);
5689
5690/* Natural page crossing: */
5691IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckCsLimAndOpcodesAcrossPageLoadingTlb);
5692IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckOpcodesAcrossPageLoadingTlb);
5693IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckOpcodesAcrossPageLoadingTlbConsiderCsLim);
5694
5695IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckCsLimAndOpcodesOnNextPageLoadingTlb);
5696IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckOpcodesOnNextPageLoadingTlb);
5697IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckOpcodesOnNextPageLoadingTlbConsiderCsLim);
5698
5699IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckCsLimAndOpcodesOnNewPageLoadingTlb);
5700IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckOpcodesOnNewPageLoadingTlb);
5701IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckOpcodesOnNewPageLoadingTlbConsiderCsLim);
5702
5703bool iemThreadedCompileEmitIrqCheckBefore(PVMCPUCC pVCpu, PIEMTB pTb);
5704bool iemThreadedCompileBeginEmitCallsComplications(PVMCPUCC pVCpu, PIEMTB pTb);
5705
5706/* Native recompiler public bits: */
5707DECLHIDDEN(PIEMTB) iemNativeRecompile(PVMCPUCC pVCpu, PIEMTB pTb) RT_NOEXCEPT;
5708DECLHIDDEN(void) iemNativeDisassembleTb(PCIEMTB pTb, PCDBGFINFOHLP pHlp) RT_NOEXCEPT;
5709int iemExecMemAllocatorInit(PVMCPU pVCpu, uint64_t cbMax, uint64_t cbInitial, uint32_t cbChunk);
5710void iemExecMemAllocatorFree(PVMCPU pVCpu, void *pv, size_t cb);
5711
5712
5713/** @} */
5714
5715RT_C_DECLS_END
5716
5717#endif /* !VMM_INCLUDED_SRC_include_IEMInternal_h */
5718
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