VirtualBox

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

Last change on this file since 72670 was 72643, checked in by vboxsync, 7 years ago

VMM: Make SVM R0 code use CPUMCTX_EXTRN_xxx flags and cleanups. bugref:9193

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 80.7 KB
Line 
1/* $Id: IEMInternal.h 72643 2018-06-21 16:02:03Z vboxsync $ */
2/** @file
3 * IEM - Internal header file.
4 */
5
6/*
7 * Copyright (C) 2011-2017 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef ___IEMInternal_h
19#define ___IEMInternal_h
20
21#include <VBox/vmm/cpum.h>
22#include <VBox/vmm/iem.h>
23#include <VBox/vmm/stam.h>
24#include <VBox/param.h>
25
26#include <setjmp.h>
27
28
29RT_C_DECLS_BEGIN
30
31
32/** @defgroup grp_iem_int Internals
33 * @ingroup grp_iem
34 * @internal
35 * @{
36 */
37
38/** For expanding symbol in slickedit and other products tagging and
39 * crossreferencing IEM symbols. */
40#ifndef IEM_STATIC
41# define IEM_STATIC static
42#endif
43
44/** @def IEM_WITH_3DNOW
45 * Includes the 3DNow decoding. */
46#define IEM_WITH_3DNOW
47
48/** @def IEM_WITH_THREE_0F_38
49 * Includes the three byte opcode map for instrs starting with 0x0f 0x38. */
50#define IEM_WITH_THREE_0F_38
51
52/** @def IEM_WITH_THREE_0F_3A
53 * Includes the three byte opcode map for instrs starting with 0x0f 0x38. */
54#define IEM_WITH_THREE_0F_3A
55
56/** @def IEM_WITH_VEX
57 * Includes the VEX decoding. */
58#define IEM_WITH_VEX
59
60/** @def IEM_CFG_TARGET_CPU
61 * The minimum target CPU for the IEM emulation (IEMTARGETCPU_XXX value).
62 *
63 * By default we allow this to be configured by the user via the
64 * CPUM/GuestCpuName config string, but this comes at a slight cost during
65 * decoding. So, for applications of this code where there is no need to
66 * be dynamic wrt target CPU, just modify this define.
67 */
68#if !defined(IEM_CFG_TARGET_CPU) || defined(DOXYGEN_RUNNING)
69# define IEM_CFG_TARGET_CPU IEMTARGETCPU_DYNAMIC
70#endif
71
72
73//#define IEM_WITH_CODE_TLB// - work in progress
74
75
76#if !defined(IN_TSTVMSTRUCT) && !defined(DOXYGEN_RUNNING)
77/** Instruction statistics. */
78typedef struct IEMINSTRSTATS
79{
80# define IEM_DO_INSTR_STAT(a_Name, a_szDesc) uint32_t a_Name;
81# include "IEMInstructionStatisticsTmpl.h"
82# undef IEM_DO_INSTR_STAT
83} IEMINSTRSTATS;
84#else
85struct IEMINSTRSTATS;
86typedef struct IEMINSTRSTATS IEMINSTRSTATS;
87#endif
88/** Pointer to IEM instruction statistics. */
89typedef IEMINSTRSTATS *PIEMINSTRSTATS;
90
91/** Finish and move to types.h */
92typedef union
93{
94 uint32_t u32;
95} RTFLOAT32U;
96typedef RTFLOAT32U *PRTFLOAT32U;
97typedef RTFLOAT32U const *PCRTFLOAT32U;
98
99
100/**
101 * Extended operand mode that includes a representation of 8-bit.
102 *
103 * This is used for packing down modes when invoking some C instruction
104 * implementations.
105 */
106typedef enum IEMMODEX
107{
108 IEMMODEX_16BIT = IEMMODE_16BIT,
109 IEMMODEX_32BIT = IEMMODE_32BIT,
110 IEMMODEX_64BIT = IEMMODE_64BIT,
111 IEMMODEX_8BIT
112} IEMMODEX;
113AssertCompileSize(IEMMODEX, 4);
114
115
116/**
117 * Branch types.
118 */
119typedef enum IEMBRANCH
120{
121 IEMBRANCH_JUMP = 1,
122 IEMBRANCH_CALL,
123 IEMBRANCH_TRAP,
124 IEMBRANCH_SOFTWARE_INT,
125 IEMBRANCH_HARDWARE_INT
126} IEMBRANCH;
127AssertCompileSize(IEMBRANCH, 4);
128
129
130/**
131 * INT instruction types.
132 */
133typedef enum IEMINT
134{
135 /** INT n instruction (opcode 0xcd imm). */
136 IEMINT_INTN = 0,
137 /** Single byte INT3 instruction (opcode 0xcc). */
138 IEMINT_INT3 = IEM_XCPT_FLAGS_BP_INSTR,
139 /** Single byte INTO instruction (opcode 0xce). */
140 IEMINT_INTO = IEM_XCPT_FLAGS_OF_INSTR,
141 /** Single byte INT1 (ICEBP) instruction (opcode 0xf1). */
142 IEMINT_INT1 = IEM_XCPT_FLAGS_ICEBP_INSTR
143} IEMINT;
144AssertCompileSize(IEMINT, 4);
145
146
147/**
148 * A FPU result.
149 */
150typedef struct IEMFPURESULT
151{
152 /** The output value. */
153 RTFLOAT80U r80Result;
154 /** The output status. */
155 uint16_t FSW;
156} IEMFPURESULT;
157AssertCompileMemberOffset(IEMFPURESULT, FSW, 10);
158/** Pointer to a FPU result. */
159typedef IEMFPURESULT *PIEMFPURESULT;
160/** Pointer to a const FPU result. */
161typedef IEMFPURESULT const *PCIEMFPURESULT;
162
163
164/**
165 * A FPU result consisting of two output values and FSW.
166 */
167typedef struct IEMFPURESULTTWO
168{
169 /** The first output value. */
170 RTFLOAT80U r80Result1;
171 /** The output status. */
172 uint16_t FSW;
173 /** The second output value. */
174 RTFLOAT80U r80Result2;
175} IEMFPURESULTTWO;
176AssertCompileMemberOffset(IEMFPURESULTTWO, FSW, 10);
177AssertCompileMemberOffset(IEMFPURESULTTWO, r80Result2, 12);
178/** Pointer to a FPU result consisting of two output values and FSW. */
179typedef IEMFPURESULTTWO *PIEMFPURESULTTWO;
180/** Pointer to a const FPU result consisting of two output values and FSW. */
181typedef IEMFPURESULTTWO const *PCIEMFPURESULTTWO;
182
183
184/**
185 * IEM TLB entry.
186 *
187 * Lookup assembly:
188 * @code{.asm}
189 ; Calculate tag.
190 mov rax, [VA]
191 shl rax, 16
192 shr rax, 16 + X86_PAGE_SHIFT
193 or rax, [uTlbRevision]
194
195 ; Do indexing.
196 movzx ecx, al
197 lea rcx, [pTlbEntries + rcx]
198
199 ; Check tag.
200 cmp [rcx + IEMTLBENTRY.uTag], rax
201 jne .TlbMiss
202
203 ; Check access.
204 movsx rax, ACCESS_FLAGS | MAPPING_R3_NOT_VALID | 0xffffff00
205 and rax, [rcx + IEMTLBENTRY.fFlagsAndPhysRev]
206 cmp rax, [uTlbPhysRev]
207 jne .TlbMiss
208
209 ; Calc address and we're done.
210 mov eax, X86_PAGE_OFFSET_MASK
211 and eax, [VA]
212 or rax, [rcx + IEMTLBENTRY.pMappingR3]
213 %ifdef VBOX_WITH_STATISTICS
214 inc qword [cTlbHits]
215 %endif
216 jmp .Done
217
218 .TlbMiss:
219 mov r8d, ACCESS_FLAGS
220 mov rdx, [VA]
221 mov rcx, [pVCpu]
222 call iemTlbTypeMiss
223 .Done:
224
225 @endcode
226 *
227 */
228typedef struct IEMTLBENTRY
229{
230 /** The TLB entry tag.
231 * Bits 35 thru 0 are made up of the virtual address shifted right 12 bits.
232 * Bits 63 thru 36 are made up of the TLB revision (zero means invalid).
233 *
234 * The TLB lookup code uses the current TLB revision, which won't ever be zero,
235 * enabling an extremely cheap TLB invalidation most of the time. When the TLB
236 * revision wraps around though, the tags needs to be zeroed.
237 *
238 * @note Try use SHRD instruction? After seeing
239 * https://gmplib.org/~tege/x86-timing.pdf, maybe not.
240 */
241 uint64_t uTag;
242 /** Access flags and physical TLB revision.
243 *
244 * - Bit 0 - page tables - not executable (X86_PTE_PAE_NX).
245 * - Bit 1 - page tables - not writable (complemented X86_PTE_RW).
246 * - Bit 2 - page tables - not user (complemented X86_PTE_US).
247 * - Bit 3 - pgm phys/virt - not directly writable.
248 * - Bit 4 - pgm phys page - not directly readable.
249 * - Bit 5 - currently unused.
250 * - Bit 6 - page tables - not dirty (complemented X86_PTE_D).
251 * - Bit 7 - tlb entry - pMappingR3 member not valid.
252 * - Bits 63 thru 8 are used for the physical TLB revision number.
253 *
254 * We're using complemented bit meanings here because it makes it easy to check
255 * whether special action is required. For instance a user mode write access
256 * would do a "TEST fFlags, (X86_PTE_RW | X86_PTE_US | X86_PTE_D)" and a
257 * non-zero result would mean special handling needed because either it wasn't
258 * writable, or it wasn't user, or the page wasn't dirty. A user mode read
259 * access would do "TEST fFlags, X86_PTE_US"; and a kernel mode read wouldn't
260 * need to check any PTE flag.
261 */
262 uint64_t fFlagsAndPhysRev;
263 /** The guest physical page address. */
264 uint64_t GCPhys;
265 /** Pointer to the ring-3 mapping (possibly also valid in ring-0). */
266#ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
267 R3PTRTYPE(uint8_t *) pbMappingR3;
268#else
269 R3R0PTRTYPE(uint8_t *) pbMappingR3;
270#endif
271#if HC_ARCH_BITS == 32
272 uint32_t u32Padding1;
273#endif
274} IEMTLBENTRY;
275AssertCompileSize(IEMTLBENTRY, 32);
276/** Pointer to an IEM TLB entry. */
277typedef IEMTLBENTRY *PIEMTLBENTRY;
278
279/** @name IEMTLBE_F_XXX - TLB entry flags (IEMTLBENTRY::fFlagsAndPhysRev)
280 * @{ */
281#define IEMTLBE_F_PT_NO_EXEC RT_BIT_64(0) /**< Page tables: Not executable. */
282#define IEMTLBE_F_PT_NO_WRITE RT_BIT_64(1) /**< Page tables: Not writable. */
283#define IEMTLBE_F_PT_NO_USER RT_BIT_64(2) /**< Page tables: Not user accessible (supervisor only). */
284#define IEMTLBE_F_PG_NO_WRITE RT_BIT_64(3) /**< Phys page: Not writable (access handler, ROM, whatever). */
285#define IEMTLBE_F_PG_NO_READ RT_BIT_64(4) /**< Phys page: Not readable (MMIO / access handler, ROM) */
286#define IEMTLBE_F_PATCH_CODE RT_BIT_64(5) /**< Code TLB: Patch code (PATM). */
287#define IEMTLBE_F_PT_NO_DIRTY RT_BIT_64(6) /**< Page tables: Not dirty (needs to be made dirty on write). */
288#define IEMTLBE_F_NO_MAPPINGR3 RT_BIT_64(7) /**< TLB entry: The IEMTLBENTRY::pMappingR3 member is invalid. */
289#define IEMTLBE_F_PHYS_REV UINT64_C(0xffffffffffffff00) /**< Physical revision mask. */
290/** @} */
291
292
293/**
294 * An IEM TLB.
295 *
296 * We've got two of these, one for data and one for instructions.
297 */
298typedef struct IEMTLB
299{
300 /** The TLB entries.
301 * We've choosen 256 because that way we can obtain the result directly from a
302 * 8-bit register without an additional AND instruction. */
303 IEMTLBENTRY aEntries[256];
304 /** The TLB revision.
305 * This is actually only 28 bits wide (see IEMTLBENTRY::uTag) and is incremented
306 * by adding RT_BIT_64(36) to it. When it wraps around and becomes zero, all
307 * the tags in the TLB must be zeroed and the revision set to RT_BIT_64(36).
308 * (The revision zero indicates an invalid TLB entry.)
309 *
310 * The initial value is choosen to cause an early wraparound. */
311 uint64_t uTlbRevision;
312 /** The TLB physical address revision - shadow of PGM variable.
313 *
314 * This is actually only 56 bits wide (see IEMTLBENTRY::fFlagsAndPhysRev) and is
315 * incremented by adding RT_BIT_64(8). When it wraps around and becomes zero,
316 * a rendezvous is called and each CPU wipe the IEMTLBENTRY::pMappingR3 as well
317 * as IEMTLBENTRY::fFlagsAndPhysRev bits 63 thru 8, 4, and 3.
318 *
319 * The initial value is choosen to cause an early wraparound. */
320 uint64_t volatile uTlbPhysRev;
321
322 /* Statistics: */
323
324 /** TLB hits (VBOX_WITH_STATISTICS only). */
325 uint64_t cTlbHits;
326 /** TLB misses. */
327 uint32_t cTlbMisses;
328 /** Slow read path. */
329 uint32_t cTlbSlowReadPath;
330#if 0
331 /** TLB misses because of tag mismatch. */
332 uint32_t cTlbMissesTag;
333 /** TLB misses because of virtual access violation. */
334 uint32_t cTlbMissesVirtAccess;
335 /** TLB misses because of dirty bit. */
336 uint32_t cTlbMissesDirty;
337 /** TLB misses because of MMIO */
338 uint32_t cTlbMissesMmio;
339 /** TLB misses because of write access handlers. */
340 uint32_t cTlbMissesWriteHandler;
341 /** TLB misses because no r3(/r0) mapping. */
342 uint32_t cTlbMissesMapping;
343#endif
344 /** Alignment padding. */
345 uint32_t au32Padding[3+5];
346} IEMTLB;
347AssertCompileSizeAlignment(IEMTLB, 64);
348/** IEMTLB::uTlbRevision increment. */
349#define IEMTLB_REVISION_INCR RT_BIT_64(36)
350/** IEMTLB::uTlbPhysRev increment. */
351#define IEMTLB_PHYS_REV_INCR RT_BIT_64(8)
352
353
354/**
355 * The per-CPU IEM state.
356 */
357typedef struct IEMCPU
358{
359 /** Info status code that needs to be propagated to the IEM caller.
360 * This cannot be passed internally, as it would complicate all success
361 * checks within the interpreter making the code larger and almost impossible
362 * to get right. Instead, we'll store status codes to pass on here. Each
363 * source of these codes will perform appropriate sanity checks. */
364 int32_t rcPassUp; /* 0x00 */
365
366 /** The current CPU execution mode (CS). */
367 IEMMODE enmCpuMode; /* 0x04 */
368 /** The CPL. */
369 uint8_t uCpl; /* 0x05 */
370
371 /** Whether to bypass access handlers or not. */
372 bool fBypassHandlers; /* 0x06 */
373 /** Indicates that we're interpreting patch code - RC only! */
374 bool fInPatchCode; /* 0x07 */
375
376 /** @name Decoder state.
377 * @{ */
378#ifdef IEM_WITH_CODE_TLB
379 /** The offset of the next instruction byte. */
380 uint32_t offInstrNextByte; /* 0x08 */
381 /** The number of bytes available at pbInstrBuf for the current instruction.
382 * This takes the max opcode length into account so that doesn't need to be
383 * checked separately. */
384 uint32_t cbInstrBuf; /* 0x0c */
385 /** Pointer to the page containing RIP, user specified buffer or abOpcode.
386 * This can be NULL if the page isn't mappable for some reason, in which
387 * case we'll do fallback stuff.
388 *
389 * If we're executing an instruction from a user specified buffer,
390 * IEMExecOneWithPrefetchedByPC and friends, this is not necessarily a page
391 * aligned pointer but pointer to the user data.
392 *
393 * For instructions crossing pages, this will start on the first page and be
394 * advanced to the next page by the time we've decoded the instruction. This
395 * therefore precludes stuff like <tt>pbInstrBuf[offInstrNextByte + cbInstrBuf - cbCurInstr]</tt>
396 */
397 uint8_t const *pbInstrBuf; /* 0x10 */
398# if ARCH_BITS == 32
399 uint32_t uInstrBufHigh; /** The high dword of the host context pbInstrBuf member. */
400# endif
401 /** The program counter corresponding to pbInstrBuf.
402 * This is set to a non-canonical address when we need to invalidate it. */
403 uint64_t uInstrBufPc; /* 0x18 */
404 /** The number of bytes available at pbInstrBuf in total (for IEMExecLots).
405 * This takes the CS segment limit into account. */
406 uint16_t cbInstrBufTotal; /* 0x20 */
407 /** Offset into pbInstrBuf of the first byte of the current instruction.
408 * Can be negative to efficiently handle cross page instructions. */
409 int16_t offCurInstrStart; /* 0x22 */
410
411 /** The prefix mask (IEM_OP_PRF_XXX). */
412 uint32_t fPrefixes; /* 0x24 */
413 /** The extra REX ModR/M register field bit (REX.R << 3). */
414 uint8_t uRexReg; /* 0x28 */
415 /** The extra REX ModR/M r/m field, SIB base and opcode reg bit
416 * (REX.B << 3). */
417 uint8_t uRexB; /* 0x29 */
418 /** The extra REX SIB index field bit (REX.X << 3). */
419 uint8_t uRexIndex; /* 0x2a */
420
421 /** The effective segment register (X86_SREG_XXX). */
422 uint8_t iEffSeg; /* 0x2b */
423
424#else
425 /** The size of what has currently been fetched into abOpcode. */
426 uint8_t cbOpcode; /* 0x08 */
427 /** The current offset into abOpcode. */
428 uint8_t offOpcode; /* 0x09 */
429
430 /** The effective segment register (X86_SREG_XXX). */
431 uint8_t iEffSeg; /* 0x0a */
432
433 /** The extra REX ModR/M register field bit (REX.R << 3). */
434 uint8_t uRexReg; /* 0x0b */
435 /** The prefix mask (IEM_OP_PRF_XXX). */
436 uint32_t fPrefixes; /* 0x0c */
437 /** The extra REX ModR/M r/m field, SIB base and opcode reg bit
438 * (REX.B << 3). */
439 uint8_t uRexB; /* 0x10 */
440 /** The extra REX SIB index field bit (REX.X << 3). */
441 uint8_t uRexIndex; /* 0x11 */
442
443#endif
444
445 /** The effective operand mode. */
446 IEMMODE enmEffOpSize; /* 0x2c, 0x12 */
447 /** The default addressing mode. */
448 IEMMODE enmDefAddrMode; /* 0x2d, 0x13 */
449 /** The effective addressing mode. */
450 IEMMODE enmEffAddrMode; /* 0x2e, 0x14 */
451 /** The default operand mode. */
452 IEMMODE enmDefOpSize; /* 0x2f, 0x15 */
453
454 /** Prefix index (VEX.pp) for two byte and three byte tables. */
455 uint8_t idxPrefix; /* 0x30, 0x16 */
456 /** 3rd VEX/EVEX/XOP register.
457 * Please use IEM_GET_EFFECTIVE_VVVV to access. */
458 uint8_t uVex3rdReg; /* 0x31, 0x17 */
459 /** The VEX/EVEX/XOP length field. */
460 uint8_t uVexLength; /* 0x32, 0x18 */
461 /** Additional EVEX stuff. */
462 uint8_t fEvexStuff; /* 0x33, 0x19 */
463
464 /** The FPU opcode (FOP). */
465 uint16_t uFpuOpcode; /* 0x34, 0x1a */
466
467 /** Explicit alignment padding. */
468#ifdef IEM_WITH_CODE_TLB
469 uint8_t abAlignment2a[2]; /* 0x36 */
470#endif
471
472 /** The opcode bytes. */
473 uint8_t abOpcode[15]; /* 0x48, 0x1c */
474 /** Explicit alignment padding. */
475#ifdef IEM_WITH_CODE_TLB
476 uint8_t abAlignment2c[0x48 - 0x47]; /* 0x37 */
477#else
478 uint8_t abAlignment2c[0x48 - 0x2b]; /* 0x2b */
479#endif
480 /** @} */
481
482
483 /** The flags of the current exception / interrupt. */
484 uint32_t fCurXcpt; /* 0x48, 0x48 */
485 /** The current exception / interrupt. */
486 uint8_t uCurXcpt;
487 /** Exception / interrupt recursion depth. */
488 int8_t cXcptRecursions;
489
490 /** The number of active guest memory mappings. */
491 uint8_t cActiveMappings;
492 /** The next unused mapping index. */
493 uint8_t iNextMapping;
494 /** Records for tracking guest memory mappings. */
495 struct
496 {
497 /** The address of the mapped bytes. */
498 void *pv;
499#if defined(IN_RC) && HC_ARCH_BITS == 64
500 uint32_t u32Alignment3; /**< Alignment padding. */
501#endif
502 /** The access flags (IEM_ACCESS_XXX).
503 * IEM_ACCESS_INVALID if the entry is unused. */
504 uint32_t fAccess;
505#if HC_ARCH_BITS == 64
506 uint32_t u32Alignment4; /**< Alignment padding. */
507#endif
508 } aMemMappings[3];
509
510 /** Locking records for the mapped memory. */
511 union
512 {
513 PGMPAGEMAPLOCK Lock;
514 uint64_t au64Padding[2];
515 } aMemMappingLocks[3];
516
517 /** Bounce buffer info.
518 * This runs in parallel to aMemMappings. */
519 struct
520 {
521 /** The physical address of the first byte. */
522 RTGCPHYS GCPhysFirst;
523 /** The physical address of the second page. */
524 RTGCPHYS GCPhysSecond;
525 /** The number of bytes in the first page. */
526 uint16_t cbFirst;
527 /** The number of bytes in the second page. */
528 uint16_t cbSecond;
529 /** Whether it's unassigned memory. */
530 bool fUnassigned;
531 /** Explicit alignment padding. */
532 bool afAlignment5[3];
533 } aMemBbMappings[3];
534
535 /** Bounce buffer storage.
536 * This runs in parallel to aMemMappings and aMemBbMappings. */
537 struct
538 {
539 uint8_t ab[512];
540 } aBounceBuffers[3];
541
542
543 /** Pointer set jump buffer - ring-3 context. */
544 R3PTRTYPE(jmp_buf *) pJmpBufR3;
545 /** Pointer set jump buffer - ring-0 context. */
546 R0PTRTYPE(jmp_buf *) pJmpBufR0;
547 /** Pointer set jump buffer - raw-mode context. */
548 RCPTRTYPE(jmp_buf *) pJmpBufRC;
549
550 /** @todo Should move this near @a fCurXcpt later. */
551 /** The error code for the current exception / interrupt. */
552 uint32_t uCurXcptErr;
553 /** The CR2 for the current exception / interrupt. */
554 uint64_t uCurXcptCr2;
555
556 /** @name Statistics
557 * @{ */
558 /** The number of instructions we've executed. */
559 uint32_t cInstructions;
560 /** The number of potential exits. */
561 uint32_t cPotentialExits;
562 /** The number of bytes data or stack written (mostly for IEMExecOneEx).
563 * This may contain uncommitted writes. */
564 uint32_t cbWritten;
565 /** Counts the VERR_IEM_INSTR_NOT_IMPLEMENTED returns. */
566 uint32_t cRetInstrNotImplemented;
567 /** Counts the VERR_IEM_ASPECT_NOT_IMPLEMENTED returns. */
568 uint32_t cRetAspectNotImplemented;
569 /** Counts informational statuses returned (other than VINF_SUCCESS). */
570 uint32_t cRetInfStatuses;
571 /** Counts other error statuses returned. */
572 uint32_t cRetErrStatuses;
573 /** Number of times rcPassUp has been used. */
574 uint32_t cRetPassUpStatus;
575 /** Number of times RZ left with instruction commit pending for ring-3. */
576 uint32_t cPendingCommit;
577 /** Number of long jumps. */
578 uint32_t cLongJumps;
579 uint32_t uAlignment6; /**< Alignment padding. */
580 /** @} */
581
582 /** @name Target CPU information.
583 * @{ */
584#if IEM_CFG_TARGET_CPU == IEMTARGETCPU_DYNAMIC
585 /** The target CPU. */
586 uint32_t uTargetCpu;
587#else
588 uint32_t u32TargetCpuPadding;
589#endif
590 /** The CPU vendor. */
591 CPUMCPUVENDOR enmCpuVendor;
592 /** @} */
593
594 /** @name Host CPU information.
595 * @{ */
596 /** The CPU vendor. */
597 CPUMCPUVENDOR enmHostCpuVendor;
598 /** @} */
599
600 uint32_t au32Alignment8[HC_ARCH_BITS == 64 ? 4 + 8 : 4]; /**< Alignment padding. */
601
602 /** Data TLB.
603 * @remarks Must be 64-byte aligned. */
604 IEMTLB DataTlb;
605 /** Instruction TLB.
606 * @remarks Must be 64-byte aligned. */
607 IEMTLB CodeTlb;
608
609 /** Pointer to instruction statistics for raw-mode context (same as R0). */
610 RCPTRTYPE(PIEMINSTRSTATS) pStatsRC;
611 /** Alignment padding. */
612 RTRCPTR RCPtrPadding;
613 /** Pointer to instruction statistics for ring-0 context (same as RC). */
614 R0PTRTYPE(PIEMINSTRSTATS) pStatsR0;
615 /** Pointer to instruction statistics for non-ring-3 code. */
616 R3PTRTYPE(PIEMINSTRSTATS) pStatsCCR3;
617 /** Pointer to instruction statistics for ring-3 context. */
618 R3PTRTYPE(PIEMINSTRSTATS) pStatsR3;
619} IEMCPU;
620AssertCompileMemberOffset(IEMCPU, fCurXcpt, 0x48);
621AssertCompileMemberAlignment(IEMCPU, DataTlb, 64);
622AssertCompileMemberAlignment(IEMCPU, CodeTlb, 64);
623/** Pointer to the per-CPU IEM state. */
624typedef IEMCPU *PIEMCPU;
625/** Pointer to the const per-CPU IEM state. */
626typedef IEMCPU const *PCIEMCPU;
627
628
629/** @def IEM_GET_CTX
630 * Gets the guest CPU context for the calling EMT.
631 * @returns PCPUMCTX
632 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
633 */
634#define IEM_GET_CTX(a_pVCpu) (&(a_pVCpu)->cpum.GstCtx)
635
636/** @def IEM_CTX_ASSERT
637 * Asserts that the @a a_fExtrnMbz is present in the CPU context.
638 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
639 * @param a_fExtrnMbz The mask of CPUMCTX_EXTRN_XXX flags that must be zero.
640 */
641#define IEM_CTX_ASSERT(a_pVCpu, a_fExtrnMbz) AssertMsg(!((a_pVCpu)->cpum.GstCtx.fExtrn & (a_fExtrnMbz)), \
642 ("fExtrn=%#RX64 fExtrnMbz=%#RX64\n", (a_pVCpu)->cpum.GstCtx.fExtrn, \
643 (a_fExtrnMbz)))
644
645/** @def IEM_CTX_IMPORT_RET
646 * Makes sure the CPU context bits given by @a a_fExtrnImport are imported.
647 *
648 * Will call the keep to import the bits as needed.
649 *
650 * Returns on import failure.
651 *
652 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
653 * @param a_fExtrnImport The mask of CPUMCTX_EXTRN_XXX flags to import.
654 */
655#define IEM_CTX_IMPORT_RET(a_pVCpu, a_fExtrnImport) \
656 do { \
657 if (!((a_pVCpu)->cpum.GstCtx.fExtrn & (a_fExtrnImport))) \
658 { /* likely */ } \
659 else \
660 { \
661 int rcCtxImport = CPUMImportGuestStateOnDemand(a_pVCpu, a_fExtrnImport); \
662 AssertRCReturn(rcCtxImport, rcCtxImport); \
663 } \
664 } while (0)
665
666/** @def IEM_CTX_IMPORT_NORET
667 * Makes sure the CPU context bits given by @a a_fExtrnImport are imported.
668 *
669 * Will call the keep to import the bits as needed.
670 *
671 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
672 * @param a_fExtrnImport The mask of CPUMCTX_EXTRN_XXX flags to import.
673 */
674#define IEM_CTX_IMPORT_NORET(a_pVCpu, a_fExtrnImport) \
675 do { \
676 if (!((a_pVCpu)->cpum.GstCtx.fExtrn & (a_fExtrnImport))) \
677 { /* likely */ } \
678 else \
679 { \
680 int rcCtxImport = CPUMImportGuestStateOnDemand(a_pVCpu, a_fExtrnImport); \
681 AssertLogRelRC(rcCtxImport); \
682 } \
683 } while (0)
684
685/** @def IEM_CTX_IMPORT_JMP
686 * Makes sure the CPU context bits given by @a a_fExtrnImport are imported.
687 *
688 * Will call the keep to import the bits as needed.
689 *
690 * Jumps on import failure.
691 *
692 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
693 * @param a_fExtrnImport The mask of CPUMCTX_EXTRN_XXX flags to import.
694 */
695#define IEM_CTX_IMPORT_JMP(a_pVCpu, a_fExtrnImport) \
696 do { \
697 if (!((a_pVCpu)->cpum.GstCtx.fExtrn & (a_fExtrnImport))) \
698 { /* likely */ } \
699 else \
700 { \
701 int rcCtxImport = CPUMImportGuestStateOnDemand(a_pVCpu, a_fExtrnImport); \
702 AssertRCStmt(rcCtxImport, longjmp(*pVCpu->iem.s.CTX_SUFF(pJmpBuf), rcCtxImport)); \
703 } \
704 } while (0)
705
706
707
708/** Gets the current IEMTARGETCPU value.
709 * @returns IEMTARGETCPU value.
710 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
711 */
712#if IEM_CFG_TARGET_CPU != IEMTARGETCPU_DYNAMIC
713# define IEM_GET_TARGET_CPU(a_pVCpu) (IEM_CFG_TARGET_CPU)
714#else
715# define IEM_GET_TARGET_CPU(a_pVCpu) ((a_pVCpu)->iem.s.uTargetCpu)
716#endif
717
718/** @def Gets the instruction length. */
719#ifdef IEM_WITH_CODE_TLB
720# define IEM_GET_INSTR_LEN(a_pVCpu) ((a_pVCpu)->iem.s.offInstrNextByte - (uint32_t)(int32_t)(a_pVCpu)->iem.s.offCurInstrStart)
721#else
722# define IEM_GET_INSTR_LEN(a_pVCpu) ((a_pVCpu)->iem.s.offOpcode)
723#endif
724
725
726/** @name IEM_ACCESS_XXX - Access details.
727 * @{ */
728#define IEM_ACCESS_INVALID UINT32_C(0x000000ff)
729#define IEM_ACCESS_TYPE_READ UINT32_C(0x00000001)
730#define IEM_ACCESS_TYPE_WRITE UINT32_C(0x00000002)
731#define IEM_ACCESS_TYPE_EXEC UINT32_C(0x00000004)
732#define IEM_ACCESS_TYPE_MASK UINT32_C(0x00000007)
733#define IEM_ACCESS_WHAT_CODE UINT32_C(0x00000010)
734#define IEM_ACCESS_WHAT_DATA UINT32_C(0x00000020)
735#define IEM_ACCESS_WHAT_STACK UINT32_C(0x00000030)
736#define IEM_ACCESS_WHAT_SYS UINT32_C(0x00000040)
737#define IEM_ACCESS_WHAT_MASK UINT32_C(0x00000070)
738/** The writes are partial, so if initialize the bounce buffer with the
739 * orignal RAM content. */
740#define IEM_ACCESS_PARTIAL_WRITE UINT32_C(0x00000100)
741/** Used in aMemMappings to indicate that the entry is bounce buffered. */
742#define IEM_ACCESS_BOUNCE_BUFFERED UINT32_C(0x00000200)
743/** Bounce buffer with ring-3 write pending, first page. */
744#define IEM_ACCESS_PENDING_R3_WRITE_1ST UINT32_C(0x00000400)
745/** Bounce buffer with ring-3 write pending, second page. */
746#define IEM_ACCESS_PENDING_R3_WRITE_2ND UINT32_C(0x00000800)
747/** Valid bit mask. */
748#define IEM_ACCESS_VALID_MASK UINT32_C(0x00000fff)
749/** Read+write data alias. */
750#define IEM_ACCESS_DATA_RW (IEM_ACCESS_TYPE_READ | IEM_ACCESS_TYPE_WRITE | IEM_ACCESS_WHAT_DATA)
751/** Write data alias. */
752#define IEM_ACCESS_DATA_W (IEM_ACCESS_TYPE_WRITE | IEM_ACCESS_WHAT_DATA)
753/** Read data alias. */
754#define IEM_ACCESS_DATA_R (IEM_ACCESS_TYPE_READ | IEM_ACCESS_WHAT_DATA)
755/** Instruction fetch alias. */
756#define IEM_ACCESS_INSTRUCTION (IEM_ACCESS_TYPE_EXEC | IEM_ACCESS_WHAT_CODE)
757/** Stack write alias. */
758#define IEM_ACCESS_STACK_W (IEM_ACCESS_TYPE_WRITE | IEM_ACCESS_WHAT_STACK)
759/** Stack read alias. */
760#define IEM_ACCESS_STACK_R (IEM_ACCESS_TYPE_READ | IEM_ACCESS_WHAT_STACK)
761/** Stack read+write alias. */
762#define IEM_ACCESS_STACK_RW (IEM_ACCESS_TYPE_READ | IEM_ACCESS_TYPE_WRITE | IEM_ACCESS_WHAT_STACK)
763/** Read system table alias. */
764#define IEM_ACCESS_SYS_R (IEM_ACCESS_TYPE_READ | IEM_ACCESS_WHAT_SYS)
765/** Read+write system table alias. */
766#define IEM_ACCESS_SYS_RW (IEM_ACCESS_TYPE_READ | IEM_ACCESS_TYPE_WRITE | IEM_ACCESS_WHAT_SYS)
767/** @} */
768
769/** @name Prefix constants (IEMCPU::fPrefixes)
770 * @{ */
771#define IEM_OP_PRF_SEG_CS RT_BIT_32(0) /**< CS segment prefix (0x2e). */
772#define IEM_OP_PRF_SEG_SS RT_BIT_32(1) /**< SS segment prefix (0x36). */
773#define IEM_OP_PRF_SEG_DS RT_BIT_32(2) /**< DS segment prefix (0x3e). */
774#define IEM_OP_PRF_SEG_ES RT_BIT_32(3) /**< ES segment prefix (0x26). */
775#define IEM_OP_PRF_SEG_FS RT_BIT_32(4) /**< FS segment prefix (0x64). */
776#define IEM_OP_PRF_SEG_GS RT_BIT_32(5) /**< GS segment prefix (0x65). */
777#define IEM_OP_PRF_SEG_MASK UINT32_C(0x3f)
778
779#define IEM_OP_PRF_SIZE_OP RT_BIT_32(8) /**< Operand size prefix (0x66). */
780#define IEM_OP_PRF_SIZE_REX_W RT_BIT_32(9) /**< REX.W prefix (0x48-0x4f). */
781#define IEM_OP_PRF_SIZE_ADDR RT_BIT_32(10) /**< Address size prefix (0x67). */
782
783#define IEM_OP_PRF_LOCK RT_BIT_32(16) /**< Lock prefix (0xf0). */
784#define IEM_OP_PRF_REPNZ RT_BIT_32(17) /**< Repeat-not-zero prefix (0xf2). */
785#define IEM_OP_PRF_REPZ RT_BIT_32(18) /**< Repeat-if-zero prefix (0xf3). */
786
787#define IEM_OP_PRF_REX RT_BIT_32(24) /**< Any REX prefix (0x40-0x4f). */
788#define IEM_OP_PRF_REX_R RT_BIT_32(25) /**< REX.R prefix (0x44,0x45,0x46,0x47,0x4c,0x4d,0x4e,0x4f). */
789#define IEM_OP_PRF_REX_B RT_BIT_32(26) /**< REX.B prefix (0x41,0x43,0x45,0x47,0x49,0x4b,0x4d,0x4f). */
790#define IEM_OP_PRF_REX_X RT_BIT_32(27) /**< REX.X prefix (0x42,0x43,0x46,0x47,0x4a,0x4b,0x4e,0x4f). */
791/** Mask with all the REX prefix flags.
792 * This is generally for use when needing to undo the REX prefixes when they
793 * are followed legacy prefixes and therefore does not immediately preceed
794 * the first opcode byte.
795 * For testing whether any REX prefix is present, use IEM_OP_PRF_REX instead. */
796#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 )
797
798#define IEM_OP_PRF_VEX RT_BIT_32(28) /**< Indiciates VEX prefix. */
799#define IEM_OP_PRF_EVEX RT_BIT_32(29) /**< Indiciates EVEX prefix. */
800#define IEM_OP_PRF_XOP RT_BIT_32(30) /**< Indiciates XOP prefix. */
801/** @} */
802
803/** @name IEMOPFORM_XXX - Opcode forms
804 * @note These are ORed together with IEMOPHINT_XXX.
805 * @{ */
806/** ModR/M: reg, r/m */
807#define IEMOPFORM_RM 0
808/** ModR/M: reg, r/m (register) */
809#define IEMOPFORM_RM_REG (IEMOPFORM_RM | IEMOPFORM_MOD3)
810/** ModR/M: reg, r/m (memory) */
811#define IEMOPFORM_RM_MEM (IEMOPFORM_RM | IEMOPFORM_NOT_MOD3)
812/** ModR/M: r/m, reg */
813#define IEMOPFORM_MR 1
814/** ModR/M: r/m (register), reg */
815#define IEMOPFORM_MR_REG (IEMOPFORM_MR | IEMOPFORM_MOD3)
816/** ModR/M: r/m (memory), reg */
817#define IEMOPFORM_MR_MEM (IEMOPFORM_MR | IEMOPFORM_NOT_MOD3)
818/** ModR/M: r/m only */
819#define IEMOPFORM_M 2
820/** ModR/M: r/m only (register). */
821#define IEMOPFORM_M_REG (IEMOPFORM_M | IEMOPFORM_MOD3)
822/** ModR/M: r/m only (memory). */
823#define IEMOPFORM_M_MEM (IEMOPFORM_M | IEMOPFORM_NOT_MOD3)
824/** ModR/M: reg only */
825#define IEMOPFORM_R 3
826
827/** VEX+ModR/M: reg, r/m */
828#define IEMOPFORM_VEX_RM 4
829/** VEX+ModR/M: reg, r/m (register) */
830#define IEMOPFORM_VEX_RM_REG (IEMOPFORM_VEX_RM | IEMOPFORM_MOD3)
831/** VEX+ModR/M: reg, r/m (memory) */
832#define IEMOPFORM_VEX_RM_MEM (IEMOPFORM_VEX_RM | IEMOPFORM_NOT_MOD3)
833/** VEX+ModR/M: r/m, reg */
834#define IEMOPFORM_VEX_MR 5
835/** VEX+ModR/M: r/m (register), reg */
836#define IEMOPFORM_VEX_MR_REG (IEMOPFORM_VEX_MR | IEMOPFORM_MOD3)
837/** VEX+ModR/M: r/m (memory), reg */
838#define IEMOPFORM_VEX_MR_MEM (IEMOPFORM_VEX_MR | IEMOPFORM_NOT_MOD3)
839/** VEX+ModR/M: r/m only */
840#define IEMOPFORM_VEX_M 6
841/** VEX+ModR/M: r/m only (register). */
842#define IEMOPFORM_VEX_M_REG (IEMOPFORM_VEX_M | IEMOPFORM_MOD3)
843/** VEX+ModR/M: r/m only (memory). */
844#define IEMOPFORM_VEX_M_MEM (IEMOPFORM_VEX_M | IEMOPFORM_NOT_MOD3)
845/** VEX+ModR/M: reg only */
846#define IEMOPFORM_VEX_R 7
847/** VEX+ModR/M: reg, vvvv, r/m */
848#define IEMOPFORM_VEX_RVM 8
849/** VEX+ModR/M: reg, vvvv, r/m (register). */
850#define IEMOPFORM_VEX_RVM_REG (IEMOPFORM_VEX_RVM | IEMOPFORM_MOD3)
851/** VEX+ModR/M: reg, vvvv, r/m (memory). */
852#define IEMOPFORM_VEX_RVM_MEM (IEMOPFORM_VEX_RVM | IEMOPFORM_NOT_MOD3)
853/** VEX+ModR/M: r/m, vvvv, reg */
854#define IEMOPFORM_VEX_MVR 9
855/** VEX+ModR/M: r/m, vvvv, reg (register) */
856#define IEMOPFORM_VEX_MVR_REG (IEMOPFORM_VEX_MVR | IEMOPFORM_MOD3)
857/** VEX+ModR/M: r/m, vvvv, reg (memory) */
858#define IEMOPFORM_VEX_MVR_MEM (IEMOPFORM_VEX_MVR | IEMOPFORM_NOT_MOD3)
859
860/** Fixed register instruction, no R/M. */
861#define IEMOPFORM_FIXED 16
862
863/** The r/m is a register. */
864#define IEMOPFORM_MOD3 RT_BIT_32(8)
865/** The r/m is a memory access. */
866#define IEMOPFORM_NOT_MOD3 RT_BIT_32(9)
867/** @} */
868
869/** @name IEMOPHINT_XXX - Additional Opcode Hints
870 * @note These are ORed together with IEMOPFORM_XXX.
871 * @{ */
872/** Ignores the operand size prefix (66h). */
873#define IEMOPHINT_IGNORES_OZ_PFX RT_BIT_32(10)
874/** Ignores REX.W (aka WIG). */
875#define IEMOPHINT_IGNORES_REXW RT_BIT_32(11)
876/** Both the operand size prefixes (66h + REX.W) are ignored. */
877#define IEMOPHINT_IGNORES_OP_SIZES (IEMOPHINT_IGNORES_OZ_PFX | IEMOPHINT_IGNORES_REXW)
878/** Allowed with the lock prefix. */
879#define IEMOPHINT_LOCK_ALLOWED RT_BIT_32(11)
880/** The VEX.L value is ignored (aka LIG). */
881#define IEMOPHINT_VEX_L_IGNORED RT_BIT_32(12)
882/** The VEX.L value must be zero (i.e. 128-bit width only). */
883#define IEMOPHINT_VEX_L_ZERO RT_BIT_32(13)
884
885/** Hint to IEMAllInstructionPython.py that this macro should be skipped. */
886#define IEMOPHINT_SKIP_PYTHON RT_BIT_32(31)
887/** @} */
888
889/**
890 * Possible hardware task switch sources.
891 */
892typedef enum IEMTASKSWITCH
893{
894 /** Task switch caused by an interrupt/exception. */
895 IEMTASKSWITCH_INT_XCPT = 1,
896 /** Task switch caused by a far CALL. */
897 IEMTASKSWITCH_CALL,
898 /** Task switch caused by a far JMP. */
899 IEMTASKSWITCH_JUMP,
900 /** Task switch caused by an IRET. */
901 IEMTASKSWITCH_IRET
902} IEMTASKSWITCH;
903AssertCompileSize(IEMTASKSWITCH, 4);
904
905/**
906 * Possible CrX load (write) sources.
907 */
908typedef enum IEMACCESSCRX
909{
910 /** CrX access caused by 'mov crX' instruction. */
911 IEMACCESSCRX_MOV_CRX,
912 /** CrX (CR0) write caused by 'lmsw' instruction. */
913 IEMACCESSCRX_LMSW,
914 /** CrX (CR0) write caused by 'clts' instruction. */
915 IEMACCESSCRX_CLTS,
916 /** CrX (CR0) read caused by 'smsw' instruction. */
917 IEMACCESSCRX_SMSW
918} IEMACCESSCRX;
919
920
921/**
922 * Indicates to the verifier that the given flag set is undefined.
923 *
924 * Can be invoked again to add more flags.
925 *
926 * This is a NOOP if the verifier isn't compiled in.
927 *
928 * @note We're temporarily keeping this until code is converted to new
929 * disassembler style opcode handling.
930 */
931#define IEMOP_VERIFICATION_UNDEFINED_EFLAGS(a_fEfl) do { } while (0)
932
933
934/** @def IEM_DECL_IMPL_TYPE
935 * For typedef'ing an instruction implementation function.
936 *
937 * @param a_RetType The return type.
938 * @param a_Name The name of the type.
939 * @param a_ArgList The argument list enclosed in parentheses.
940 */
941
942/** @def IEM_DECL_IMPL_DEF
943 * For defining an instruction implementation function.
944 *
945 * @param a_RetType The return type.
946 * @param a_Name The name of the type.
947 * @param a_ArgList The argument list enclosed in parentheses.
948 */
949
950#if defined(__GNUC__) && defined(RT_ARCH_X86)
951# define IEM_DECL_IMPL_TYPE(a_RetType, a_Name, a_ArgList) \
952 __attribute__((__fastcall__)) a_RetType (a_Name) a_ArgList
953# define IEM_DECL_IMPL_DEF(a_RetType, a_Name, a_ArgList) \
954 __attribute__((__fastcall__, __nothrow__)) a_RetType a_Name a_ArgList
955
956#elif defined(_MSC_VER) && defined(RT_ARCH_X86)
957# define IEM_DECL_IMPL_TYPE(a_RetType, a_Name, a_ArgList) \
958 a_RetType (__fastcall a_Name) a_ArgList
959# define IEM_DECL_IMPL_DEF(a_RetType, a_Name, a_ArgList) \
960 a_RetType __fastcall a_Name a_ArgList
961
962#else
963# define IEM_DECL_IMPL_TYPE(a_RetType, a_Name, a_ArgList) \
964 a_RetType (VBOXCALL a_Name) a_ArgList
965# define IEM_DECL_IMPL_DEF(a_RetType, a_Name, a_ArgList) \
966 a_RetType VBOXCALL a_Name a_ArgList
967
968#endif
969
970/** @name Arithmetic assignment operations on bytes (binary).
971 * @{ */
972typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINU8, (uint8_t *pu8Dst, uint8_t u8Src, uint32_t *pEFlags));
973typedef FNIEMAIMPLBINU8 *PFNIEMAIMPLBINU8;
974FNIEMAIMPLBINU8 iemAImpl_add_u8, iemAImpl_add_u8_locked;
975FNIEMAIMPLBINU8 iemAImpl_adc_u8, iemAImpl_adc_u8_locked;
976FNIEMAIMPLBINU8 iemAImpl_sub_u8, iemAImpl_sub_u8_locked;
977FNIEMAIMPLBINU8 iemAImpl_sbb_u8, iemAImpl_sbb_u8_locked;
978FNIEMAIMPLBINU8 iemAImpl_or_u8, iemAImpl_or_u8_locked;
979FNIEMAIMPLBINU8 iemAImpl_xor_u8, iemAImpl_xor_u8_locked;
980FNIEMAIMPLBINU8 iemAImpl_and_u8, iemAImpl_and_u8_locked;
981/** @} */
982
983/** @name Arithmetic assignment operations on words (binary).
984 * @{ */
985typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINU16, (uint16_t *pu16Dst, uint16_t u16Src, uint32_t *pEFlags));
986typedef FNIEMAIMPLBINU16 *PFNIEMAIMPLBINU16;
987FNIEMAIMPLBINU16 iemAImpl_add_u16, iemAImpl_add_u16_locked;
988FNIEMAIMPLBINU16 iemAImpl_adc_u16, iemAImpl_adc_u16_locked;
989FNIEMAIMPLBINU16 iemAImpl_sub_u16, iemAImpl_sub_u16_locked;
990FNIEMAIMPLBINU16 iemAImpl_sbb_u16, iemAImpl_sbb_u16_locked;
991FNIEMAIMPLBINU16 iemAImpl_or_u16, iemAImpl_or_u16_locked;
992FNIEMAIMPLBINU16 iemAImpl_xor_u16, iemAImpl_xor_u16_locked;
993FNIEMAIMPLBINU16 iemAImpl_and_u16, iemAImpl_and_u16_locked;
994/** @} */
995
996/** @name Arithmetic assignment operations on double words (binary).
997 * @{ */
998typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINU32, (uint32_t *pu32Dst, uint32_t u32Src, uint32_t *pEFlags));
999typedef FNIEMAIMPLBINU32 *PFNIEMAIMPLBINU32;
1000FNIEMAIMPLBINU32 iemAImpl_add_u32, iemAImpl_add_u32_locked;
1001FNIEMAIMPLBINU32 iemAImpl_adc_u32, iemAImpl_adc_u32_locked;
1002FNIEMAIMPLBINU32 iemAImpl_sub_u32, iemAImpl_sub_u32_locked;
1003FNIEMAIMPLBINU32 iemAImpl_sbb_u32, iemAImpl_sbb_u32_locked;
1004FNIEMAIMPLBINU32 iemAImpl_or_u32, iemAImpl_or_u32_locked;
1005FNIEMAIMPLBINU32 iemAImpl_xor_u32, iemAImpl_xor_u32_locked;
1006FNIEMAIMPLBINU32 iemAImpl_and_u32, iemAImpl_and_u32_locked;
1007/** @} */
1008
1009/** @name Arithmetic assignment operations on quad words (binary).
1010 * @{ */
1011typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINU64, (uint64_t *pu64Dst, uint64_t u64Src, uint32_t *pEFlags));
1012typedef FNIEMAIMPLBINU64 *PFNIEMAIMPLBINU64;
1013FNIEMAIMPLBINU64 iemAImpl_add_u64, iemAImpl_add_u64_locked;
1014FNIEMAIMPLBINU64 iemAImpl_adc_u64, iemAImpl_adc_u64_locked;
1015FNIEMAIMPLBINU64 iemAImpl_sub_u64, iemAImpl_sub_u64_locked;
1016FNIEMAIMPLBINU64 iemAImpl_sbb_u64, iemAImpl_sbb_u64_locked;
1017FNIEMAIMPLBINU64 iemAImpl_or_u64, iemAImpl_or_u64_locked;
1018FNIEMAIMPLBINU64 iemAImpl_xor_u64, iemAImpl_xor_u64_locked;
1019FNIEMAIMPLBINU64 iemAImpl_and_u64, iemAImpl_and_u64_locked;
1020/** @} */
1021
1022/** @name Compare operations (thrown in with the binary ops).
1023 * @{ */
1024FNIEMAIMPLBINU8 iemAImpl_cmp_u8;
1025FNIEMAIMPLBINU16 iemAImpl_cmp_u16;
1026FNIEMAIMPLBINU32 iemAImpl_cmp_u32;
1027FNIEMAIMPLBINU64 iemAImpl_cmp_u64;
1028/** @} */
1029
1030/** @name Test operations (thrown in with the binary ops).
1031 * @{ */
1032FNIEMAIMPLBINU8 iemAImpl_test_u8;
1033FNIEMAIMPLBINU16 iemAImpl_test_u16;
1034FNIEMAIMPLBINU32 iemAImpl_test_u32;
1035FNIEMAIMPLBINU64 iemAImpl_test_u64;
1036/** @} */
1037
1038/** @name Bit operations operations (thrown in with the binary ops).
1039 * @{ */
1040FNIEMAIMPLBINU16 iemAImpl_bt_u16, iemAImpl_bt_u16_locked;
1041FNIEMAIMPLBINU32 iemAImpl_bt_u32, iemAImpl_bt_u32_locked;
1042FNIEMAIMPLBINU64 iemAImpl_bt_u64, iemAImpl_bt_u64_locked;
1043FNIEMAIMPLBINU16 iemAImpl_btc_u16, iemAImpl_btc_u16_locked;
1044FNIEMAIMPLBINU32 iemAImpl_btc_u32, iemAImpl_btc_u32_locked;
1045FNIEMAIMPLBINU64 iemAImpl_btc_u64, iemAImpl_btc_u64_locked;
1046FNIEMAIMPLBINU16 iemAImpl_btr_u16, iemAImpl_btr_u16_locked;
1047FNIEMAIMPLBINU32 iemAImpl_btr_u32, iemAImpl_btr_u32_locked;
1048FNIEMAIMPLBINU64 iemAImpl_btr_u64, iemAImpl_btr_u64_locked;
1049FNIEMAIMPLBINU16 iemAImpl_bts_u16, iemAImpl_bts_u16_locked;
1050FNIEMAIMPLBINU32 iemAImpl_bts_u32, iemAImpl_bts_u32_locked;
1051FNIEMAIMPLBINU64 iemAImpl_bts_u64, iemAImpl_bts_u64_locked;
1052/** @} */
1053
1054/** @name Exchange memory with register operations.
1055 * @{ */
1056IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u8, (uint8_t *pu8Mem, uint8_t *pu8Reg));
1057IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u16,(uint16_t *pu16Mem, uint16_t *pu16Reg));
1058IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u32,(uint32_t *pu32Mem, uint32_t *pu32Reg));
1059IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u64,(uint64_t *pu64Mem, uint64_t *pu64Reg));
1060/** @} */
1061
1062/** @name Exchange and add operations.
1063 * @{ */
1064IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u8, (uint8_t *pu8Dst, uint8_t *pu8Reg, uint32_t *pEFlags));
1065IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u16,(uint16_t *pu16Dst, uint16_t *pu16Reg, uint32_t *pEFlags));
1066IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u32,(uint32_t *pu32Dst, uint32_t *pu32Reg, uint32_t *pEFlags));
1067IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u64,(uint64_t *pu64Dst, uint64_t *pu64Reg, uint32_t *pEFlags));
1068IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u8_locked, (uint8_t *pu8Dst, uint8_t *pu8Reg, uint32_t *pEFlags));
1069IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u16_locked,(uint16_t *pu16Dst, uint16_t *pu16Reg, uint32_t *pEFlags));
1070IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u32_locked,(uint32_t *pu32Dst, uint32_t *pu32Reg, uint32_t *pEFlags));
1071IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u64_locked,(uint64_t *pu64Dst, uint64_t *pu64Reg, uint32_t *pEFlags));
1072/** @} */
1073
1074/** @name Compare and exchange.
1075 * @{ */
1076IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u8, (uint8_t *pu8Dst, uint8_t *puAl, uint8_t uSrcReg, uint32_t *pEFlags));
1077IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u8_locked, (uint8_t *pu8Dst, uint8_t *puAl, uint8_t uSrcReg, uint32_t *pEFlags));
1078IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u16, (uint16_t *pu16Dst, uint16_t *puAx, uint16_t uSrcReg, uint32_t *pEFlags));
1079IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u16_locked,(uint16_t *pu16Dst, uint16_t *puAx, uint16_t uSrcReg, uint32_t *pEFlags));
1080IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u32, (uint32_t *pu32Dst, uint32_t *puEax, uint32_t uSrcReg, uint32_t *pEFlags));
1081IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u32_locked,(uint32_t *pu32Dst, uint32_t *puEax, uint32_t uSrcReg, uint32_t *pEFlags));
1082#ifdef RT_ARCH_X86
1083IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u64, (uint64_t *pu64Dst, uint64_t *puRax, uint64_t *puSrcReg, uint32_t *pEFlags));
1084IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u64_locked,(uint64_t *pu64Dst, uint64_t *puRax, uint64_t *puSrcReg, uint32_t *pEFlags));
1085#else
1086IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u64, (uint64_t *pu64Dst, uint64_t *puRax, uint64_t uSrcReg, uint32_t *pEFlags));
1087IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u64_locked,(uint64_t *pu64Dst, uint64_t *puRax, uint64_t uSrcReg, uint32_t *pEFlags));
1088#endif
1089IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg8b,(uint64_t *pu64Dst, PRTUINT64U pu64EaxEdx, PRTUINT64U pu64EbxEcx,
1090 uint32_t *pEFlags));
1091IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg8b_locked,(uint64_t *pu64Dst, PRTUINT64U pu64EaxEdx, PRTUINT64U pu64EbxEcx,
1092 uint32_t *pEFlags));
1093IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg16b,(PRTUINT128U pu128Dst, PRTUINT128U pu128RaxRdx, PRTUINT128U pu128RbxRcx,
1094 uint32_t *pEFlags));
1095IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg16b_locked,(PRTUINT128U pu128Dst, PRTUINT128U pu128RaxRdx, PRTUINT128U pu128RbxRcx,
1096 uint32_t *pEFlags));
1097IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg16b_fallback,(PRTUINT128U pu128Dst, PRTUINT128U pu128RaxRdx,
1098 PRTUINT128U pu128RbxRcx, uint32_t *pEFlags));
1099/** @} */
1100
1101/** @name Memory ordering
1102 * @{ */
1103typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEMFENCE,(void));
1104typedef FNIEMAIMPLMEMFENCE *PFNIEMAIMPLMEMFENCE;
1105IEM_DECL_IMPL_DEF(void, iemAImpl_mfence,(void));
1106IEM_DECL_IMPL_DEF(void, iemAImpl_sfence,(void));
1107IEM_DECL_IMPL_DEF(void, iemAImpl_lfence,(void));
1108IEM_DECL_IMPL_DEF(void, iemAImpl_alt_mem_fence,(void));
1109/** @} */
1110
1111/** @name Double precision shifts
1112 * @{ */
1113typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTDBLU16,(uint16_t *pu16Dst, uint16_t u16Src, uint8_t cShift, uint32_t *pEFlags));
1114typedef FNIEMAIMPLSHIFTDBLU16 *PFNIEMAIMPLSHIFTDBLU16;
1115typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTDBLU32,(uint32_t *pu32Dst, uint32_t u32Src, uint8_t cShift, uint32_t *pEFlags));
1116typedef FNIEMAIMPLSHIFTDBLU32 *PFNIEMAIMPLSHIFTDBLU32;
1117typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTDBLU64,(uint64_t *pu64Dst, uint64_t u64Src, uint8_t cShift, uint32_t *pEFlags));
1118typedef FNIEMAIMPLSHIFTDBLU64 *PFNIEMAIMPLSHIFTDBLU64;
1119FNIEMAIMPLSHIFTDBLU16 iemAImpl_shld_u16;
1120FNIEMAIMPLSHIFTDBLU32 iemAImpl_shld_u32;
1121FNIEMAIMPLSHIFTDBLU64 iemAImpl_shld_u64;
1122FNIEMAIMPLSHIFTDBLU16 iemAImpl_shrd_u16;
1123FNIEMAIMPLSHIFTDBLU32 iemAImpl_shrd_u32;
1124FNIEMAIMPLSHIFTDBLU64 iemAImpl_shrd_u64;
1125/** @} */
1126
1127
1128/** @name Bit search operations (thrown in with the binary ops).
1129 * @{ */
1130FNIEMAIMPLBINU16 iemAImpl_bsf_u16;
1131FNIEMAIMPLBINU32 iemAImpl_bsf_u32;
1132FNIEMAIMPLBINU64 iemAImpl_bsf_u64;
1133FNIEMAIMPLBINU16 iemAImpl_bsr_u16;
1134FNIEMAIMPLBINU32 iemAImpl_bsr_u32;
1135FNIEMAIMPLBINU64 iemAImpl_bsr_u64;
1136/** @} */
1137
1138/** @name Signed multiplication operations (thrown in with the binary ops).
1139 * @{ */
1140FNIEMAIMPLBINU16 iemAImpl_imul_two_u16;
1141FNIEMAIMPLBINU32 iemAImpl_imul_two_u32;
1142FNIEMAIMPLBINU64 iemAImpl_imul_two_u64;
1143/** @} */
1144
1145/** @name Arithmetic assignment operations on bytes (unary).
1146 * @{ */
1147typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLUNARYU8, (uint8_t *pu8Dst, uint32_t *pEFlags));
1148typedef FNIEMAIMPLUNARYU8 *PFNIEMAIMPLUNARYU8;
1149FNIEMAIMPLUNARYU8 iemAImpl_inc_u8, iemAImpl_inc_u8_locked;
1150FNIEMAIMPLUNARYU8 iemAImpl_dec_u8, iemAImpl_dec_u8_locked;
1151FNIEMAIMPLUNARYU8 iemAImpl_not_u8, iemAImpl_not_u8_locked;
1152FNIEMAIMPLUNARYU8 iemAImpl_neg_u8, iemAImpl_neg_u8_locked;
1153/** @} */
1154
1155/** @name Arithmetic assignment operations on words (unary).
1156 * @{ */
1157typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLUNARYU16, (uint16_t *pu16Dst, uint32_t *pEFlags));
1158typedef FNIEMAIMPLUNARYU16 *PFNIEMAIMPLUNARYU16;
1159FNIEMAIMPLUNARYU16 iemAImpl_inc_u16, iemAImpl_inc_u16_locked;
1160FNIEMAIMPLUNARYU16 iemAImpl_dec_u16, iemAImpl_dec_u16_locked;
1161FNIEMAIMPLUNARYU16 iemAImpl_not_u16, iemAImpl_not_u16_locked;
1162FNIEMAIMPLUNARYU16 iemAImpl_neg_u16, iemAImpl_neg_u16_locked;
1163/** @} */
1164
1165/** @name Arithmetic assignment operations on double words (unary).
1166 * @{ */
1167typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLUNARYU32, (uint32_t *pu32Dst, uint32_t *pEFlags));
1168typedef FNIEMAIMPLUNARYU32 *PFNIEMAIMPLUNARYU32;
1169FNIEMAIMPLUNARYU32 iemAImpl_inc_u32, iemAImpl_inc_u32_locked;
1170FNIEMAIMPLUNARYU32 iemAImpl_dec_u32, iemAImpl_dec_u32_locked;
1171FNIEMAIMPLUNARYU32 iemAImpl_not_u32, iemAImpl_not_u32_locked;
1172FNIEMAIMPLUNARYU32 iemAImpl_neg_u32, iemAImpl_neg_u32_locked;
1173/** @} */
1174
1175/** @name Arithmetic assignment operations on quad words (unary).
1176 * @{ */
1177typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLUNARYU64, (uint64_t *pu64Dst, uint32_t *pEFlags));
1178typedef FNIEMAIMPLUNARYU64 *PFNIEMAIMPLUNARYU64;
1179FNIEMAIMPLUNARYU64 iemAImpl_inc_u64, iemAImpl_inc_u64_locked;
1180FNIEMAIMPLUNARYU64 iemAImpl_dec_u64, iemAImpl_dec_u64_locked;
1181FNIEMAIMPLUNARYU64 iemAImpl_not_u64, iemAImpl_not_u64_locked;
1182FNIEMAIMPLUNARYU64 iemAImpl_neg_u64, iemAImpl_neg_u64_locked;
1183/** @} */
1184
1185
1186/** @name Shift operations on bytes (Group 2).
1187 * @{ */
1188typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTU8,(uint8_t *pu8Dst, uint8_t cShift, uint32_t *pEFlags));
1189typedef FNIEMAIMPLSHIFTU8 *PFNIEMAIMPLSHIFTU8;
1190FNIEMAIMPLSHIFTU8 iemAImpl_rol_u8;
1191FNIEMAIMPLSHIFTU8 iemAImpl_ror_u8;
1192FNIEMAIMPLSHIFTU8 iemAImpl_rcl_u8;
1193FNIEMAIMPLSHIFTU8 iemAImpl_rcr_u8;
1194FNIEMAIMPLSHIFTU8 iemAImpl_shl_u8;
1195FNIEMAIMPLSHIFTU8 iemAImpl_shr_u8;
1196FNIEMAIMPLSHIFTU8 iemAImpl_sar_u8;
1197/** @} */
1198
1199/** @name Shift operations on words (Group 2).
1200 * @{ */
1201typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTU16,(uint16_t *pu16Dst, uint8_t cShift, uint32_t *pEFlags));
1202typedef FNIEMAIMPLSHIFTU16 *PFNIEMAIMPLSHIFTU16;
1203FNIEMAIMPLSHIFTU16 iemAImpl_rol_u16;
1204FNIEMAIMPLSHIFTU16 iemAImpl_ror_u16;
1205FNIEMAIMPLSHIFTU16 iemAImpl_rcl_u16;
1206FNIEMAIMPLSHIFTU16 iemAImpl_rcr_u16;
1207FNIEMAIMPLSHIFTU16 iemAImpl_shl_u16;
1208FNIEMAIMPLSHIFTU16 iemAImpl_shr_u16;
1209FNIEMAIMPLSHIFTU16 iemAImpl_sar_u16;
1210/** @} */
1211
1212/** @name Shift operations on double words (Group 2).
1213 * @{ */
1214typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTU32,(uint32_t *pu32Dst, uint8_t cShift, uint32_t *pEFlags));
1215typedef FNIEMAIMPLSHIFTU32 *PFNIEMAIMPLSHIFTU32;
1216FNIEMAIMPLSHIFTU32 iemAImpl_rol_u32;
1217FNIEMAIMPLSHIFTU32 iemAImpl_ror_u32;
1218FNIEMAIMPLSHIFTU32 iemAImpl_rcl_u32;
1219FNIEMAIMPLSHIFTU32 iemAImpl_rcr_u32;
1220FNIEMAIMPLSHIFTU32 iemAImpl_shl_u32;
1221FNIEMAIMPLSHIFTU32 iemAImpl_shr_u32;
1222FNIEMAIMPLSHIFTU32 iemAImpl_sar_u32;
1223/** @} */
1224
1225/** @name Shift operations on words (Group 2).
1226 * @{ */
1227typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTU64,(uint64_t *pu64Dst, uint8_t cShift, uint32_t *pEFlags));
1228typedef FNIEMAIMPLSHIFTU64 *PFNIEMAIMPLSHIFTU64;
1229FNIEMAIMPLSHIFTU64 iemAImpl_rol_u64;
1230FNIEMAIMPLSHIFTU64 iemAImpl_ror_u64;
1231FNIEMAIMPLSHIFTU64 iemAImpl_rcl_u64;
1232FNIEMAIMPLSHIFTU64 iemAImpl_rcr_u64;
1233FNIEMAIMPLSHIFTU64 iemAImpl_shl_u64;
1234FNIEMAIMPLSHIFTU64 iemAImpl_shr_u64;
1235FNIEMAIMPLSHIFTU64 iemAImpl_sar_u64;
1236/** @} */
1237
1238/** @name Multiplication and division operations.
1239 * @{ */
1240typedef IEM_DECL_IMPL_TYPE(int, FNIEMAIMPLMULDIVU8,(uint16_t *pu16AX, uint8_t u8FactorDivisor, uint32_t *pEFlags));
1241typedef FNIEMAIMPLMULDIVU8 *PFNIEMAIMPLMULDIVU8;
1242FNIEMAIMPLMULDIVU8 iemAImpl_mul_u8, iemAImpl_imul_u8;
1243FNIEMAIMPLMULDIVU8 iemAImpl_div_u8, iemAImpl_idiv_u8;
1244
1245typedef IEM_DECL_IMPL_TYPE(int, FNIEMAIMPLMULDIVU16,(uint16_t *pu16AX, uint16_t *pu16DX, uint16_t u16FactorDivisor, uint32_t *pEFlags));
1246typedef FNIEMAIMPLMULDIVU16 *PFNIEMAIMPLMULDIVU16;
1247FNIEMAIMPLMULDIVU16 iemAImpl_mul_u16, iemAImpl_imul_u16;
1248FNIEMAIMPLMULDIVU16 iemAImpl_div_u16, iemAImpl_idiv_u16;
1249
1250typedef IEM_DECL_IMPL_TYPE(int, FNIEMAIMPLMULDIVU32,(uint32_t *pu32EAX, uint32_t *pu32EDX, uint32_t u32FactorDivisor, uint32_t *pEFlags));
1251typedef FNIEMAIMPLMULDIVU32 *PFNIEMAIMPLMULDIVU32;
1252FNIEMAIMPLMULDIVU32 iemAImpl_mul_u32, iemAImpl_imul_u32;
1253FNIEMAIMPLMULDIVU32 iemAImpl_div_u32, iemAImpl_idiv_u32;
1254
1255typedef IEM_DECL_IMPL_TYPE(int, FNIEMAIMPLMULDIVU64,(uint64_t *pu64RAX, uint64_t *pu64RDX, uint64_t u64FactorDivisor, uint32_t *pEFlags));
1256typedef FNIEMAIMPLMULDIVU64 *PFNIEMAIMPLMULDIVU64;
1257FNIEMAIMPLMULDIVU64 iemAImpl_mul_u64, iemAImpl_imul_u64;
1258FNIEMAIMPLMULDIVU64 iemAImpl_div_u64, iemAImpl_idiv_u64;
1259/** @} */
1260
1261/** @name Byte Swap.
1262 * @{ */
1263IEM_DECL_IMPL_TYPE(void, iemAImpl_bswap_u16,(uint32_t *pu32Dst)); /* Yes, 32-bit register access. */
1264IEM_DECL_IMPL_TYPE(void, iemAImpl_bswap_u32,(uint32_t *pu32Dst));
1265IEM_DECL_IMPL_TYPE(void, iemAImpl_bswap_u64,(uint64_t *pu64Dst));
1266/** @} */
1267
1268/** @name Misc.
1269 * @{ */
1270FNIEMAIMPLBINU16 iemAImpl_arpl;
1271/** @} */
1272
1273
1274/** @name FPU operations taking a 32-bit float argument
1275 * @{ */
1276typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR32FSW,(PCX86FXSTATE pFpuState, uint16_t *pFSW,
1277 PCRTFLOAT80U pr80Val1, PCRTFLOAT32U pr32Val2));
1278typedef FNIEMAIMPLFPUR32FSW *PFNIEMAIMPLFPUR32FSW;
1279
1280typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR32,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
1281 PCRTFLOAT80U pr80Val1, PCRTFLOAT32U pr32Val2));
1282typedef FNIEMAIMPLFPUR32 *PFNIEMAIMPLFPUR32;
1283
1284FNIEMAIMPLFPUR32FSW iemAImpl_fcom_r80_by_r32;
1285FNIEMAIMPLFPUR32 iemAImpl_fadd_r80_by_r32;
1286FNIEMAIMPLFPUR32 iemAImpl_fmul_r80_by_r32;
1287FNIEMAIMPLFPUR32 iemAImpl_fsub_r80_by_r32;
1288FNIEMAIMPLFPUR32 iemAImpl_fsubr_r80_by_r32;
1289FNIEMAIMPLFPUR32 iemAImpl_fdiv_r80_by_r32;
1290FNIEMAIMPLFPUR32 iemAImpl_fdivr_r80_by_r32;
1291
1292IEM_DECL_IMPL_DEF(void, iemAImpl_fld_r32_to_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, PCRTFLOAT32U pr32Val));
1293IEM_DECL_IMPL_DEF(void, iemAImpl_fst_r80_to_r32,(PCX86FXSTATE pFpuState, uint16_t *pu16FSW,
1294 PRTFLOAT32U pr32Val, PCRTFLOAT80U pr80Val));
1295/** @} */
1296
1297/** @name FPU operations taking a 64-bit float argument
1298 * @{ */
1299typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR64,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
1300 PCRTFLOAT80U pr80Val1, PCRTFLOAT64U pr64Val2));
1301typedef FNIEMAIMPLFPUR64 *PFNIEMAIMPLFPUR64;
1302
1303FNIEMAIMPLFPUR64 iemAImpl_fadd_r80_by_r64;
1304FNIEMAIMPLFPUR64 iemAImpl_fmul_r80_by_r64;
1305FNIEMAIMPLFPUR64 iemAImpl_fsub_r80_by_r64;
1306FNIEMAIMPLFPUR64 iemAImpl_fsubr_r80_by_r64;
1307FNIEMAIMPLFPUR64 iemAImpl_fdiv_r80_by_r64;
1308FNIEMAIMPLFPUR64 iemAImpl_fdivr_r80_by_r64;
1309
1310IEM_DECL_IMPL_DEF(void, iemAImpl_fcom_r80_by_r64,(PCX86FXSTATE pFpuState, uint16_t *pFSW,
1311 PCRTFLOAT80U pr80Val1, PCRTFLOAT64U pr64Val2));
1312IEM_DECL_IMPL_DEF(void, iemAImpl_fld_r64_to_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, PCRTFLOAT64U pr64Val));
1313IEM_DECL_IMPL_DEF(void, iemAImpl_fst_r80_to_r64,(PCX86FXSTATE pFpuState, uint16_t *pu16FSW,
1314 PRTFLOAT64U pr32Val, PCRTFLOAT80U pr80Val));
1315/** @} */
1316
1317/** @name FPU operations taking a 80-bit float argument
1318 * @{ */
1319typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
1320 PCRTFLOAT80U pr80Val1, PCRTFLOAT80U pr80Val2));
1321typedef FNIEMAIMPLFPUR80 *PFNIEMAIMPLFPUR80;
1322FNIEMAIMPLFPUR80 iemAImpl_fadd_r80_by_r80;
1323FNIEMAIMPLFPUR80 iemAImpl_fmul_r80_by_r80;
1324FNIEMAIMPLFPUR80 iemAImpl_fsub_r80_by_r80;
1325FNIEMAIMPLFPUR80 iemAImpl_fsubr_r80_by_r80;
1326FNIEMAIMPLFPUR80 iemAImpl_fdiv_r80_by_r80;
1327FNIEMAIMPLFPUR80 iemAImpl_fdivr_r80_by_r80;
1328FNIEMAIMPLFPUR80 iemAImpl_fprem_r80_by_r80;
1329FNIEMAIMPLFPUR80 iemAImpl_fprem1_r80_by_r80;
1330FNIEMAIMPLFPUR80 iemAImpl_fscale_r80_by_r80;
1331
1332FNIEMAIMPLFPUR80 iemAImpl_fpatan_r80_by_r80;
1333FNIEMAIMPLFPUR80 iemAImpl_fyl2x_r80_by_r80;
1334FNIEMAIMPLFPUR80 iemAImpl_fyl2xp1_r80_by_r80;
1335
1336typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR80FSW,(PCX86FXSTATE pFpuState, uint16_t *pFSW,
1337 PCRTFLOAT80U pr80Val1, PCRTFLOAT80U pr80Val2));
1338typedef FNIEMAIMPLFPUR80FSW *PFNIEMAIMPLFPUR80FSW;
1339FNIEMAIMPLFPUR80FSW iemAImpl_fcom_r80_by_r80;
1340FNIEMAIMPLFPUR80FSW iemAImpl_fucom_r80_by_r80;
1341
1342typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLFPUR80EFL,(PCX86FXSTATE pFpuState, uint16_t *pu16Fsw,
1343 PCRTFLOAT80U pr80Val1, PCRTFLOAT80U pr80Val2));
1344typedef FNIEMAIMPLFPUR80EFL *PFNIEMAIMPLFPUR80EFL;
1345FNIEMAIMPLFPUR80EFL iemAImpl_fcomi_r80_by_r80;
1346FNIEMAIMPLFPUR80EFL iemAImpl_fucomi_r80_by_r80;
1347
1348typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR80UNARY,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, PCRTFLOAT80U pr80Val));
1349typedef FNIEMAIMPLFPUR80UNARY *PFNIEMAIMPLFPUR80UNARY;
1350FNIEMAIMPLFPUR80UNARY iemAImpl_fabs_r80;
1351FNIEMAIMPLFPUR80UNARY iemAImpl_fchs_r80;
1352FNIEMAIMPLFPUR80UNARY iemAImpl_f2xm1_r80;
1353FNIEMAIMPLFPUR80UNARY iemAImpl_fsqrt_r80;
1354FNIEMAIMPLFPUR80UNARY iemAImpl_frndint_r80;
1355FNIEMAIMPLFPUR80UNARY iemAImpl_fsin_r80;
1356FNIEMAIMPLFPUR80UNARY iemAImpl_fcos_r80;
1357
1358typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR80UNARYFSW,(PCX86FXSTATE pFpuState, uint16_t *pu16Fsw, PCRTFLOAT80U pr80Val));
1359typedef FNIEMAIMPLFPUR80UNARYFSW *PFNIEMAIMPLFPUR80UNARYFSW;
1360FNIEMAIMPLFPUR80UNARYFSW iemAImpl_ftst_r80;
1361FNIEMAIMPLFPUR80UNARYFSW iemAImpl_fxam_r80;
1362
1363typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR80LDCONST,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes));
1364typedef FNIEMAIMPLFPUR80LDCONST *PFNIEMAIMPLFPUR80LDCONST;
1365FNIEMAIMPLFPUR80LDCONST iemAImpl_fld1;
1366FNIEMAIMPLFPUR80LDCONST iemAImpl_fldl2t;
1367FNIEMAIMPLFPUR80LDCONST iemAImpl_fldl2e;
1368FNIEMAIMPLFPUR80LDCONST iemAImpl_fldpi;
1369FNIEMAIMPLFPUR80LDCONST iemAImpl_fldlg2;
1370FNIEMAIMPLFPUR80LDCONST iemAImpl_fldln2;
1371FNIEMAIMPLFPUR80LDCONST iemAImpl_fldz;
1372
1373typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR80UNARYTWO,(PCX86FXSTATE pFpuState, PIEMFPURESULTTWO pFpuResTwo,
1374 PCRTFLOAT80U pr80Val));
1375typedef FNIEMAIMPLFPUR80UNARYTWO *PFNIEMAIMPLFPUR80UNARYTWO;
1376FNIEMAIMPLFPUR80UNARYTWO iemAImpl_fptan_r80_r80;
1377FNIEMAIMPLFPUR80UNARYTWO iemAImpl_fxtract_r80_r80;
1378FNIEMAIMPLFPUR80UNARYTWO iemAImpl_fsincos_r80_r80;
1379
1380IEM_DECL_IMPL_DEF(void, iemAImpl_fld_r80_from_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, PCRTFLOAT80U pr80Val));
1381IEM_DECL_IMPL_DEF(void, iemAImpl_fst_r80_to_r80,(PCX86FXSTATE pFpuState, uint16_t *pu16FSW,
1382 PRTFLOAT80U pr80Dst, PCRTFLOAT80U pr80Src));
1383
1384/** @} */
1385
1386/** @name FPU operations taking a 16-bit signed integer argument
1387 * @{ */
1388typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUI16,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
1389 PCRTFLOAT80U pr80Val1, int16_t const *pi16Val2));
1390typedef FNIEMAIMPLFPUI16 *PFNIEMAIMPLFPUI16;
1391
1392FNIEMAIMPLFPUI16 iemAImpl_fiadd_r80_by_i16;
1393FNIEMAIMPLFPUI16 iemAImpl_fimul_r80_by_i16;
1394FNIEMAIMPLFPUI16 iemAImpl_fisub_r80_by_i16;
1395FNIEMAIMPLFPUI16 iemAImpl_fisubr_r80_by_i16;
1396FNIEMAIMPLFPUI16 iemAImpl_fidiv_r80_by_i16;
1397FNIEMAIMPLFPUI16 iemAImpl_fidivr_r80_by_i16;
1398
1399IEM_DECL_IMPL_DEF(void, iemAImpl_ficom_r80_by_i16,(PCX86FXSTATE pFpuState, uint16_t *pu16Fsw,
1400 PCRTFLOAT80U pr80Val1, int16_t const *pi16Val2));
1401
1402IEM_DECL_IMPL_DEF(void, iemAImpl_fild_i16_to_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, int16_t const *pi16Val));
1403IEM_DECL_IMPL_DEF(void, iemAImpl_fist_r80_to_i16,(PCX86FXSTATE pFpuState, uint16_t *pu16FSW,
1404 int16_t *pi16Val, PCRTFLOAT80U pr80Val));
1405IEM_DECL_IMPL_DEF(void, iemAImpl_fistt_r80_to_i16,(PCX86FXSTATE pFpuState, uint16_t *pu16FSW,
1406 int16_t *pi16Val, PCRTFLOAT80U pr80Val));
1407/** @} */
1408
1409/** @name FPU operations taking a 32-bit signed integer argument
1410 * @{ */
1411typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUI32,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
1412 PCRTFLOAT80U pr80Val1, int32_t const *pi32Val2));
1413typedef FNIEMAIMPLFPUI32 *PFNIEMAIMPLFPUI32;
1414
1415FNIEMAIMPLFPUI32 iemAImpl_fiadd_r80_by_i32;
1416FNIEMAIMPLFPUI32 iemAImpl_fimul_r80_by_i32;
1417FNIEMAIMPLFPUI32 iemAImpl_fisub_r80_by_i32;
1418FNIEMAIMPLFPUI32 iemAImpl_fisubr_r80_by_i32;
1419FNIEMAIMPLFPUI32 iemAImpl_fidiv_r80_by_i32;
1420FNIEMAIMPLFPUI32 iemAImpl_fidivr_r80_by_i32;
1421
1422IEM_DECL_IMPL_DEF(void, iemAImpl_ficom_r80_by_i32,(PCX86FXSTATE pFpuState, uint16_t *pu16Fsw,
1423 PCRTFLOAT80U pr80Val1, int32_t const *pi32Val2));
1424
1425IEM_DECL_IMPL_DEF(void, iemAImpl_fild_i32_to_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, int32_t const *pi32Val));
1426IEM_DECL_IMPL_DEF(void, iemAImpl_fist_r80_to_i32,(PCX86FXSTATE pFpuState, uint16_t *pu16FSW,
1427 int32_t *pi32Val, PCRTFLOAT80U pr80Val));
1428IEM_DECL_IMPL_DEF(void, iemAImpl_fistt_r80_to_i32,(PCX86FXSTATE pFpuState, uint16_t *pu16FSW,
1429 int32_t *pi32Val, PCRTFLOAT80U pr80Val));
1430/** @} */
1431
1432/** @name FPU operations taking a 64-bit signed integer argument
1433 * @{ */
1434typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUI64,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
1435 PCRTFLOAT80U pr80Val1, int64_t const *pi64Val2));
1436typedef FNIEMAIMPLFPUI64 *PFNIEMAIMPLFPUI64;
1437
1438FNIEMAIMPLFPUI64 iemAImpl_fiadd_r80_by_i64;
1439FNIEMAIMPLFPUI64 iemAImpl_fimul_r80_by_i64;
1440FNIEMAIMPLFPUI64 iemAImpl_fisub_r80_by_i64;
1441FNIEMAIMPLFPUI64 iemAImpl_fisubr_r80_by_i64;
1442FNIEMAIMPLFPUI64 iemAImpl_fidiv_r80_by_i64;
1443FNIEMAIMPLFPUI64 iemAImpl_fidivr_r80_by_i64;
1444
1445IEM_DECL_IMPL_DEF(void, iemAImpl_ficom_r80_by_i64,(PCX86FXSTATE pFpuState, uint16_t *pu16Fsw,
1446 PCRTFLOAT80U pr80Val1, int64_t const *pi64Val2));
1447
1448IEM_DECL_IMPL_DEF(void, iemAImpl_fild_i64_to_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, int64_t const *pi64Val));
1449IEM_DECL_IMPL_DEF(void, iemAImpl_fist_r80_to_i64,(PCX86FXSTATE pFpuState, uint16_t *pu16FSW,
1450 int64_t *pi64Val, PCRTFLOAT80U pr80Val));
1451IEM_DECL_IMPL_DEF(void, iemAImpl_fistt_r80_to_i64,(PCX86FXSTATE pFpuState, uint16_t *pu16FSW,
1452 int64_t *pi32Val, PCRTFLOAT80U pr80Val));
1453/** @} */
1454
1455
1456/** Temporary type representing a 256-bit vector register. */
1457typedef struct {uint64_t au64[4]; } IEMVMM256;
1458/** Temporary type pointing to a 256-bit vector register. */
1459typedef IEMVMM256 *PIEMVMM256;
1460/** Temporary type pointing to a const 256-bit vector register. */
1461typedef IEMVMM256 *PCIEMVMM256;
1462
1463
1464/** @name Media (SSE/MMX/AVX) operations: full1 + full2 -> full1.
1465 * @{ */
1466typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAF2U64,(PCX86FXSTATE pFpuState, uint64_t *pu64Dst, uint64_t const *pu64Src));
1467typedef FNIEMAIMPLMEDIAF2U64 *PFNIEMAIMPLMEDIAF2U64;
1468typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAF2U128,(PCX86FXSTATE pFpuState, PRTUINT128U pu128Dst, PCRTUINT128U pu128Src));
1469typedef FNIEMAIMPLMEDIAF2U128 *PFNIEMAIMPLMEDIAF2U128;
1470FNIEMAIMPLMEDIAF2U64 iemAImpl_pxor_u64, iemAImpl_pcmpeqb_u64, iemAImpl_pcmpeqw_u64, iemAImpl_pcmpeqd_u64;
1471FNIEMAIMPLMEDIAF2U128 iemAImpl_pxor_u128, iemAImpl_pcmpeqb_u128, iemAImpl_pcmpeqw_u128, iemAImpl_pcmpeqd_u128;
1472/** @} */
1473
1474/** @name Media (SSE/MMX/AVX) operations: lowhalf1 + lowhalf1 -> full1.
1475 * @{ */
1476typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAF1L1U64,(PCX86FXSTATE pFpuState, uint64_t *pu64Dst, uint32_t const *pu32Src));
1477typedef FNIEMAIMPLMEDIAF1L1U64 *PFNIEMAIMPLMEDIAF1L1U64;
1478typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAF1L1U128,(PCX86FXSTATE pFpuState, PRTUINT128U pu128Dst, uint64_t const *pu64Src));
1479typedef FNIEMAIMPLMEDIAF1L1U128 *PFNIEMAIMPLMEDIAF1L1U128;
1480FNIEMAIMPLMEDIAF1L1U64 iemAImpl_punpcklbw_u64, iemAImpl_punpcklwd_u64, iemAImpl_punpckldq_u64;
1481FNIEMAIMPLMEDIAF1L1U128 iemAImpl_punpcklbw_u128, iemAImpl_punpcklwd_u128, iemAImpl_punpckldq_u128, iemAImpl_punpcklqdq_u128;
1482/** @} */
1483
1484/** @name Media (SSE/MMX/AVX) operations: hihalf1 + hihalf2 -> full1.
1485 * @{ */
1486typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAF1H1U64,(PCX86FXSTATE pFpuState, uint64_t *pu64Dst, uint64_t const *pu64Src));
1487typedef FNIEMAIMPLMEDIAF2U64 *PFNIEMAIMPLMEDIAF1H1U64;
1488typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAF1H1U128,(PCX86FXSTATE pFpuState, PRTUINT128U pu128Dst, PCRTUINT128U pu128Src));
1489typedef FNIEMAIMPLMEDIAF2U128 *PFNIEMAIMPLMEDIAF1H1U128;
1490FNIEMAIMPLMEDIAF1H1U64 iemAImpl_punpckhbw_u64, iemAImpl_punpckhwd_u64, iemAImpl_punpckhdq_u64;
1491FNIEMAIMPLMEDIAF1H1U128 iemAImpl_punpckhbw_u128, iemAImpl_punpckhwd_u128, iemAImpl_punpckhdq_u128, iemAImpl_punpckhqdq_u128;
1492/** @} */
1493
1494/** @name Media (SSE/MMX/AVX) operation: Packed Shuffle Stuff (evil)
1495 * @{ */
1496typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAPSHUF,(PCX86FXSTATE pFpuState, PRTUINT128U pu128Dst,
1497 PCRTUINT128U pu128Src, uint8_t bEvil));
1498typedef FNIEMAIMPLMEDIAPSHUF *PFNIEMAIMPLMEDIAPSHUF;
1499FNIEMAIMPLMEDIAPSHUF iemAImpl_pshufhw, iemAImpl_pshuflw, iemAImpl_pshufd;
1500IEM_DECL_IMPL_DEF(void, iemAImpl_pshufw,(PCX86FXSTATE pFpuState, uint64_t *pu64Dst, uint64_t const *pu64Src, uint8_t bEvil));
1501/** @} */
1502
1503/** @name Media (SSE/MMX/AVX) operation: Move Byte Mask
1504 * @{ */
1505IEM_DECL_IMPL_DEF(void, iemAImpl_pmovmskb_u64,(PCX86FXSTATE pFpuState, uint64_t *pu64Dst, uint64_t const *pu64Src));
1506IEM_DECL_IMPL_DEF(void, iemAImpl_pmovmskb_u128,(PCX86FXSTATE pFpuState, uint64_t *pu64Dst, PCRTUINT128U pu128Src));
1507/** @} */
1508
1509/** @name Media (SSE/MMX/AVX) operation: Sort this later
1510 * @{ */
1511IEM_DECL_IMPL_DEF(void, iemAImpl_movsldup,(PCX86FXSTATE pFpuState, PRTUINT128U puDst, PCRTUINT128U puSrc));
1512IEM_DECL_IMPL_DEF(void, iemAImpl_movshdup,(PCX86FXSTATE pFpuState, PRTUINT128U puDst, PCRTUINT128U puSrc));
1513IEM_DECL_IMPL_DEF(void, iemAImpl_movddup,(PCX86FXSTATE pFpuState, PRTUINT128U puDst, uint64_t uSrc));
1514
1515IEM_DECL_IMPL_DEF(void, iemAImpl_vmovsldup_256_rr,(PX86XSAVEAREA pXState, uint8_t iYRegDst, uint8_t iYRegSrc));
1516IEM_DECL_IMPL_DEF(void, iemAImpl_vmovsldup_256_rm,(PX86XSAVEAREA pXState, uint8_t iYRegDst, PCRTUINT256U pSrc));
1517IEM_DECL_IMPL_DEF(void, iemAImpl_vmovddup_256_rr,(PX86XSAVEAREA pXState, uint8_t iYRegDst, uint8_t iYRegSrc));
1518IEM_DECL_IMPL_DEF(void, iemAImpl_vmovddup_256_rm,(PX86XSAVEAREA pXState, uint8_t iYRegDst, PCRTUINT256U pSrc));
1519
1520/** @} */
1521
1522
1523/** @name Function tables.
1524 * @{
1525 */
1526
1527/**
1528 * Function table for a binary operator providing implementation based on
1529 * operand size.
1530 */
1531typedef struct IEMOPBINSIZES
1532{
1533 PFNIEMAIMPLBINU8 pfnNormalU8, pfnLockedU8;
1534 PFNIEMAIMPLBINU16 pfnNormalU16, pfnLockedU16;
1535 PFNIEMAIMPLBINU32 pfnNormalU32, pfnLockedU32;
1536 PFNIEMAIMPLBINU64 pfnNormalU64, pfnLockedU64;
1537} IEMOPBINSIZES;
1538/** Pointer to a binary operator function table. */
1539typedef IEMOPBINSIZES const *PCIEMOPBINSIZES;
1540
1541
1542/**
1543 * Function table for a unary operator providing implementation based on
1544 * operand size.
1545 */
1546typedef struct IEMOPUNARYSIZES
1547{
1548 PFNIEMAIMPLUNARYU8 pfnNormalU8, pfnLockedU8;
1549 PFNIEMAIMPLUNARYU16 pfnNormalU16, pfnLockedU16;
1550 PFNIEMAIMPLUNARYU32 pfnNormalU32, pfnLockedU32;
1551 PFNIEMAIMPLUNARYU64 pfnNormalU64, pfnLockedU64;
1552} IEMOPUNARYSIZES;
1553/** Pointer to a unary operator function table. */
1554typedef IEMOPUNARYSIZES const *PCIEMOPUNARYSIZES;
1555
1556
1557/**
1558 * Function table for a shift operator providing implementation based on
1559 * operand size.
1560 */
1561typedef struct IEMOPSHIFTSIZES
1562{
1563 PFNIEMAIMPLSHIFTU8 pfnNormalU8;
1564 PFNIEMAIMPLSHIFTU16 pfnNormalU16;
1565 PFNIEMAIMPLSHIFTU32 pfnNormalU32;
1566 PFNIEMAIMPLSHIFTU64 pfnNormalU64;
1567} IEMOPSHIFTSIZES;
1568/** Pointer to a shift operator function table. */
1569typedef IEMOPSHIFTSIZES const *PCIEMOPSHIFTSIZES;
1570
1571
1572/**
1573 * Function table for a multiplication or division operation.
1574 */
1575typedef struct IEMOPMULDIVSIZES
1576{
1577 PFNIEMAIMPLMULDIVU8 pfnU8;
1578 PFNIEMAIMPLMULDIVU16 pfnU16;
1579 PFNIEMAIMPLMULDIVU32 pfnU32;
1580 PFNIEMAIMPLMULDIVU64 pfnU64;
1581} IEMOPMULDIVSIZES;
1582/** Pointer to a multiplication or division operation function table. */
1583typedef IEMOPMULDIVSIZES const *PCIEMOPMULDIVSIZES;
1584
1585
1586/**
1587 * Function table for a double precision shift operator providing implementation
1588 * based on operand size.
1589 */
1590typedef struct IEMOPSHIFTDBLSIZES
1591{
1592 PFNIEMAIMPLSHIFTDBLU16 pfnNormalU16;
1593 PFNIEMAIMPLSHIFTDBLU32 pfnNormalU32;
1594 PFNIEMAIMPLSHIFTDBLU64 pfnNormalU64;
1595} IEMOPSHIFTDBLSIZES;
1596/** Pointer to a double precision shift function table. */
1597typedef IEMOPSHIFTDBLSIZES const *PCIEMOPSHIFTDBLSIZES;
1598
1599
1600/**
1601 * Function table for media instruction taking two full sized media registers,
1602 * optionally the 2nd being a memory reference (only modifying the first op.)
1603 */
1604typedef struct IEMOPMEDIAF2
1605{
1606 PFNIEMAIMPLMEDIAF2U64 pfnU64;
1607 PFNIEMAIMPLMEDIAF2U128 pfnU128;
1608} IEMOPMEDIAF2;
1609/** Pointer to a media operation function table for full sized ops. */
1610typedef IEMOPMEDIAF2 const *PCIEMOPMEDIAF2;
1611
1612/**
1613 * Function table for media instruction taking taking one full and one lower
1614 * half media register.
1615 */
1616typedef struct IEMOPMEDIAF1L1
1617{
1618 PFNIEMAIMPLMEDIAF1L1U64 pfnU64;
1619 PFNIEMAIMPLMEDIAF1L1U128 pfnU128;
1620} IEMOPMEDIAF1L1;
1621/** Pointer to a media operation function table for lowhalf+lowhalf -> full. */
1622typedef IEMOPMEDIAF1L1 const *PCIEMOPMEDIAF1L1;
1623
1624/**
1625 * Function table for media instruction taking taking one full and one high half
1626 * media register.
1627 */
1628typedef struct IEMOPMEDIAF1H1
1629{
1630 PFNIEMAIMPLMEDIAF1H1U64 pfnU64;
1631 PFNIEMAIMPLMEDIAF1H1U128 pfnU128;
1632} IEMOPMEDIAF1H1;
1633/** Pointer to a media operation function table for hihalf+hihalf -> full. */
1634typedef IEMOPMEDIAF1H1 const *PCIEMOPMEDIAF1H1;
1635
1636
1637/** @} */
1638
1639
1640/** @name C instruction implementations for anything slightly complicated.
1641 * @{ */
1642
1643/**
1644 * For typedef'ing or declaring a C instruction implementation function taking
1645 * no extra arguments.
1646 *
1647 * @param a_Name The name of the type.
1648 */
1649# define IEM_CIMPL_DECL_TYPE_0(a_Name) \
1650 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PVMCPU pVCpu, uint8_t cbInstr))
1651/**
1652 * For defining a C instruction implementation function taking no extra
1653 * arguments.
1654 *
1655 * @param a_Name The name of the function
1656 */
1657# define IEM_CIMPL_DEF_0(a_Name) \
1658 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PVMCPU pVCpu, uint8_t cbInstr))
1659/**
1660 * For calling a C instruction implementation function taking no extra
1661 * arguments.
1662 *
1663 * This special call macro adds default arguments to the call and allow us to
1664 * change these later.
1665 *
1666 * @param a_fn The name of the function.
1667 */
1668# define IEM_CIMPL_CALL_0(a_fn) a_fn(pVCpu, cbInstr)
1669
1670/**
1671 * For typedef'ing or declaring a C instruction implementation function taking
1672 * one extra argument.
1673 *
1674 * @param a_Name The name of the type.
1675 * @param a_Type0 The argument type.
1676 * @param a_Arg0 The argument name.
1677 */
1678# define IEM_CIMPL_DECL_TYPE_1(a_Name, a_Type0, a_Arg0) \
1679 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PVMCPU pVCpu, uint8_t cbInstr, a_Type0 a_Arg0))
1680/**
1681 * For defining a C instruction implementation function taking one extra
1682 * argument.
1683 *
1684 * @param a_Name The name of the function
1685 * @param a_Type0 The argument type.
1686 * @param a_Arg0 The argument name.
1687 */
1688# define IEM_CIMPL_DEF_1(a_Name, a_Type0, a_Arg0) \
1689 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PVMCPU pVCpu, uint8_t cbInstr, a_Type0 a_Arg0))
1690/**
1691 * For calling a C instruction implementation function taking one extra
1692 * argument.
1693 *
1694 * This special call macro adds default arguments to the call and allow us to
1695 * change these later.
1696 *
1697 * @param a_fn The name of the function.
1698 * @param a0 The name of the 1st argument.
1699 */
1700# define IEM_CIMPL_CALL_1(a_fn, a0) a_fn(pVCpu, cbInstr, (a0))
1701
1702/**
1703 * For typedef'ing or declaring a C instruction implementation function taking
1704 * two extra arguments.
1705 *
1706 * @param a_Name The name of the type.
1707 * @param a_Type0 The type of the 1st argument
1708 * @param a_Arg0 The name of the 1st argument.
1709 * @param a_Type1 The type of the 2nd argument.
1710 * @param a_Arg1 The name of the 2nd argument.
1711 */
1712# define IEM_CIMPL_DECL_TYPE_2(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1) \
1713 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PVMCPU pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1))
1714/**
1715 * For defining a C instruction implementation function taking two extra
1716 * arguments.
1717 *
1718 * @param a_Name The name of the function.
1719 * @param a_Type0 The type of the 1st argument
1720 * @param a_Arg0 The name of the 1st argument.
1721 * @param a_Type1 The type of the 2nd argument.
1722 * @param a_Arg1 The name of the 2nd argument.
1723 */
1724# define IEM_CIMPL_DEF_2(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1) \
1725 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PVMCPU pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1))
1726/**
1727 * For calling a C instruction implementation function taking two extra
1728 * arguments.
1729 *
1730 * This special call macro adds default arguments to the call and allow us to
1731 * change these later.
1732 *
1733 * @param a_fn The name of the function.
1734 * @param a0 The name of the 1st argument.
1735 * @param a1 The name of the 2nd argument.
1736 */
1737# define IEM_CIMPL_CALL_2(a_fn, a0, a1) a_fn(pVCpu, cbInstr, (a0), (a1))
1738
1739/**
1740 * For typedef'ing or declaring a C instruction implementation function taking
1741 * three extra arguments.
1742 *
1743 * @param a_Name The name of the type.
1744 * @param a_Type0 The type of the 1st argument
1745 * @param a_Arg0 The name of the 1st argument.
1746 * @param a_Type1 The type of the 2nd argument.
1747 * @param a_Arg1 The name of the 2nd argument.
1748 * @param a_Type2 The type of the 3rd argument.
1749 * @param a_Arg2 The name of the 3rd argument.
1750 */
1751# define IEM_CIMPL_DECL_TYPE_3(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2) \
1752 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PVMCPU pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, a_Type2 a_Arg2))
1753/**
1754 * For defining a C instruction implementation function taking three extra
1755 * arguments.
1756 *
1757 * @param a_Name The name of the function.
1758 * @param a_Type0 The type of the 1st argument
1759 * @param a_Arg0 The name of the 1st argument.
1760 * @param a_Type1 The type of the 2nd argument.
1761 * @param a_Arg1 The name of the 2nd argument.
1762 * @param a_Type2 The type of the 3rd argument.
1763 * @param a_Arg2 The name of the 3rd argument.
1764 */
1765# define IEM_CIMPL_DEF_3(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2) \
1766 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PVMCPU pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, a_Type2 a_Arg2))
1767/**
1768 * For calling a C instruction implementation function taking three extra
1769 * arguments.
1770 *
1771 * This special call macro adds default arguments to the call and allow us to
1772 * change these later.
1773 *
1774 * @param a_fn The name of the function.
1775 * @param a0 The name of the 1st argument.
1776 * @param a1 The name of the 2nd argument.
1777 * @param a2 The name of the 3rd argument.
1778 */
1779# define IEM_CIMPL_CALL_3(a_fn, a0, a1, a2) a_fn(pVCpu, cbInstr, (a0), (a1), (a2))
1780
1781
1782/**
1783 * For typedef'ing or declaring a C instruction implementation function taking
1784 * four extra arguments.
1785 *
1786 * @param a_Name The name of the type.
1787 * @param a_Type0 The type of the 1st argument
1788 * @param a_Arg0 The name of the 1st argument.
1789 * @param a_Type1 The type of the 2nd argument.
1790 * @param a_Arg1 The name of the 2nd argument.
1791 * @param a_Type2 The type of the 3rd argument.
1792 * @param a_Arg2 The name of the 3rd argument.
1793 * @param a_Type3 The type of the 4th argument.
1794 * @param a_Arg3 The name of the 4th argument.
1795 */
1796# define IEM_CIMPL_DECL_TYPE_4(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2, a_Type3, a_Arg3) \
1797 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PVMCPU pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, a_Type2 a_Arg2, a_Type3 a_Arg3))
1798/**
1799 * For defining a C instruction implementation function taking four extra
1800 * arguments.
1801 *
1802 * @param a_Name The name of the function.
1803 * @param a_Type0 The type of the 1st argument
1804 * @param a_Arg0 The name of the 1st argument.
1805 * @param a_Type1 The type of the 2nd argument.
1806 * @param a_Arg1 The name of the 2nd argument.
1807 * @param a_Type2 The type of the 3rd argument.
1808 * @param a_Arg2 The name of the 3rd argument.
1809 * @param a_Type3 The type of the 4th argument.
1810 * @param a_Arg3 The name of the 4th argument.
1811 */
1812# define IEM_CIMPL_DEF_4(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2, a_Type3, a_Arg3) \
1813 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PVMCPU pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, \
1814 a_Type2 a_Arg2, a_Type3 a_Arg3))
1815/**
1816 * For calling a C instruction implementation function taking four extra
1817 * arguments.
1818 *
1819 * This special call macro adds default arguments to the call and allow us to
1820 * change these later.
1821 *
1822 * @param a_fn The name of the function.
1823 * @param a0 The name of the 1st argument.
1824 * @param a1 The name of the 2nd argument.
1825 * @param a2 The name of the 3rd argument.
1826 * @param a3 The name of the 4th argument.
1827 */
1828# define IEM_CIMPL_CALL_4(a_fn, a0, a1, a2, a3) a_fn(pVCpu, cbInstr, (a0), (a1), (a2), (a3))
1829
1830
1831/**
1832 * For typedef'ing or declaring a C instruction implementation function taking
1833 * five extra arguments.
1834 *
1835 * @param a_Name The name of the type.
1836 * @param a_Type0 The type of the 1st argument
1837 * @param a_Arg0 The name of the 1st argument.
1838 * @param a_Type1 The type of the 2nd argument.
1839 * @param a_Arg1 The name of the 2nd argument.
1840 * @param a_Type2 The type of the 3rd argument.
1841 * @param a_Arg2 The name of the 3rd argument.
1842 * @param a_Type3 The type of the 4th argument.
1843 * @param a_Arg3 The name of the 4th argument.
1844 * @param a_Type4 The type of the 5th argument.
1845 * @param a_Arg4 The name of the 5th argument.
1846 */
1847# 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) \
1848 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PVMCPU pVCpu, uint8_t cbInstr, \
1849 a_Type0 a_Arg0, a_Type1 a_Arg1, a_Type2 a_Arg2, \
1850 a_Type3 a_Arg3, a_Type4 a_Arg4))
1851/**
1852 * For defining a C instruction implementation function taking five extra
1853 * arguments.
1854 *
1855 * @param a_Name The name of the function.
1856 * @param a_Type0 The type of the 1st argument
1857 * @param a_Arg0 The name of the 1st argument.
1858 * @param a_Type1 The type of the 2nd argument.
1859 * @param a_Arg1 The name of the 2nd argument.
1860 * @param a_Type2 The type of the 3rd argument.
1861 * @param a_Arg2 The name of the 3rd argument.
1862 * @param a_Type3 The type of the 4th argument.
1863 * @param a_Arg3 The name of the 4th argument.
1864 * @param a_Type4 The type of the 5th argument.
1865 * @param a_Arg4 The name of the 5th argument.
1866 */
1867# 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) \
1868 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PVMCPU pVCpu, uint8_t cbInstr, \
1869 a_Type0 a_Arg0, a_Type1 a_Arg1, a_Type2 a_Arg2, \
1870 a_Type3 a_Arg3, a_Type4 a_Arg4))
1871/**
1872 * For calling a C instruction implementation function taking five extra
1873 * arguments.
1874 *
1875 * This special call macro adds default arguments to the call and allow us to
1876 * change these later.
1877 *
1878 * @param a_fn The name of the function.
1879 * @param a0 The name of the 1st argument.
1880 * @param a1 The name of the 2nd argument.
1881 * @param a2 The name of the 3rd argument.
1882 * @param a3 The name of the 4th argument.
1883 * @param a4 The name of the 5th argument.
1884 */
1885# define IEM_CIMPL_CALL_5(a_fn, a0, a1, a2, a3, a4) a_fn(pVCpu, cbInstr, (a0), (a1), (a2), (a3), (a4))
1886
1887/** @} */
1888
1889
1890/** @} */
1891
1892RT_C_DECLS_END
1893
1894#endif
1895
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