VirtualBox

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

Last change on this file since 106424 was 106406, checked in by vboxsync, 7 months ago

VMM/IEM: Reduced the number of parameters for most iemNativeVarRegisterAcquire calls. bugref:10720

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

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette