VirtualBox

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

Last change on this file since 36834 was 36829, checked in by vboxsync, 14 years ago

IEM: Some more instructions and tweaks.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 32.4 KB
Line 
1/* $Id: IEMInternal.h 36829 2011-04-24 13:45:25Z vboxsync $ */
2/** @file
3 * IEM - Internal header file.
4 */
5
6/*
7 * Copyright (C) 2011 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/stam.h>
22#include <VBox/vmm/cpum.h>
23#include <VBox/param.h>
24
25
26RT_C_DECLS_BEGIN
27
28
29/** @defgroup grp_iem_int Internals
30 * @ingroup grp_iem
31 * @internal
32 * @{
33 */
34
35
36/**
37 * Operand or addressing mode.
38 */
39typedef enum IEMMODE
40{
41 IEMMODE_16BIT = 0,
42 IEMMODE_32BIT,
43 IEMMODE_64BIT
44} IEMMODE;
45AssertCompileSize(IEMMODE, 4);
46
47/**
48 * Extended operand mode that includes a representation of 8-bit.
49 *
50 * This is used for packing down modes when invoking some C instruction
51 * implementations.
52 */
53typedef enum IEMMODEX
54{
55 IEMMODEX_16BIT = IEMMODE_16BIT,
56 IEMMODEX_32BIT = IEMMODE_32BIT,
57 IEMMODEX_64BIT = IEMMODE_64BIT,
58 IEMMODEX_8BIT
59} IEMMODEX;
60AssertCompileSize(IEMMODEX, 4);
61
62
63#ifdef IEM_VERIFICATION_MODE
64
65/**
66 * Verification event type.
67 */
68typedef enum IEMVERIFYEVENT
69{
70 IEMVERIFYEVENT_INVALID = 0,
71 IEMVERIFYEVENT_IOPORT_READ,
72 IEMVERIFYEVENT_IOPORT_WRITE,
73 IEMVERIFYEVENT_RAM_WRITE,
74 IEMVERIFYEVENT_RAM_READ
75} IEMVERIFYEVENT;
76
77/** Checks if the event type is a RAM read or write. */
78# define IEMVERIFYEVENT_IS_RAM(a_enmType) ((a_enmType) == IEMVERIFYEVENT_RAM_WRITE || (a_enmType) == IEMVERIFYEVENT_RAM_READ)
79
80/**
81 * Verification event record.
82 */
83typedef struct IEMVERIFYEVTREC
84{
85 /** Pointer to the next record in the list. */
86 struct IEMVERIFYEVTREC *pNext;
87 /** The event type. */
88 IEMVERIFYEVENT enmEvent;
89 /** The event data. */
90 union
91 {
92 /** IEMVERIFYEVENT_IOPORT_READ */
93 struct
94 {
95 RTIOPORT Port;
96 uint32_t cbValue;
97 } IOPortRead;
98
99 /** IEMVERIFYEVENT_IOPORT_WRITE */
100 struct
101 {
102 RTIOPORT Port;
103 uint32_t cbValue;
104 uint32_t u32Value;
105 } IOPortWrite;
106
107 /** IEMVERIFYEVENT_RAM_READ */
108 struct
109 {
110 RTGCPHYS GCPhys;
111 uint32_t cb;
112 } RamRead;
113
114 /** IEMVERIFYEVENT_RAM_WRITE */
115 struct
116 {
117 RTGCPHYS GCPhys;
118 uint32_t cb;
119 uint8_t ab[32];
120 } RamWrite;
121 } u;
122} IEMVERIFYEVTREC;
123/** Pointer to an IEM event verification records. */
124typedef IEMVERIFYEVTREC *PIEMVERIFYEVTREC;
125
126#endif /* IEM_VERIFICATION_MODE */
127
128
129/**
130 * The per-CPU IEM state.
131 */
132typedef struct IEMCPU
133{
134 /** Pointer to the CPU context - ring-3 contex. */
135 R3PTRTYPE(PCPUMCTX) pCtxR3;
136 /** Pointer to the CPU context - ring-0 contex. */
137 R0PTRTYPE(PCPUMCTX) pCtxR0;
138 /** Pointer to the CPU context - raw-mode contex. */
139 RCPTRTYPE(PCPUMCTX) pCtxRC;
140
141 /** Offset of the VMCPU structure relative to this structure (negative). */
142 int32_t offVMCpu;
143 /** Offset of the VM structure relative to this structure (negative). */
144 int32_t offVM;
145
146 /** Whether to bypass access handlers or not. */
147 bool fByPassHandlers;
148 /** Explicit alignment padding. */
149 bool afAlignment0[6];
150
151 /** The CPL. */
152 uint8_t uCpl;
153 /** The current CPU execution mode (CS). */
154 IEMMODE enmCpuMode;
155
156 /** @name Statistics
157 * @{ */
158 /** The number of instructions we've executed. */
159 uint32_t cInstructions;
160 /** The number of potential exits. */
161 uint32_t cPotentialExits;
162#ifdef IEM_VERIFICATION_MODE
163 /** The Number of I/O port reads that has been performed. */
164 uint32_t cIOReads;
165 /** The Number of I/O port writes that has been performed. */
166 uint32_t cIOWrites;
167 /** Hack for ignoring differences in undefined EFLAGS after MUL and DIV. */
168 bool fMulDivHack;
169 /** Hack for ignoring differences in OF after shifts greater than 1 bit.
170 * At least two intel CPUs this code is running on will set it different
171 * than what AMD and REM does. */
172 bool fShiftOfHack;
173 /** Set if no comparison to REM is currently performed.
174 * This is used to skip past really slow bits. */
175 bool fNoRem;
176 bool afAlignment1[5];
177 /** The physical address corresponding to abOpcodes[0]. */
178 RTGCPHYS GCPhysOpcodes;
179#endif
180 /** @} */
181
182 /** @name Decoder state.
183 * @{ */
184
185 /** The default addressing mode . */
186 IEMMODE enmDefAddrMode;
187 /** The effective addressing mode . */
188 IEMMODE enmEffAddrMode;
189 /** The default operand mode . */
190 IEMMODE enmDefOpSize;
191 /** The effective operand mode . */
192 IEMMODE enmEffOpSize;
193
194 /** The prefix mask (IEM_OP_PRF_XXX). */
195 uint32_t fPrefixes;
196 /** The extra REX ModR/M register field bit (REX.R << 3). */
197 uint8_t uRexReg;
198 /** The extra REX ModR/M r/m field, SIB base and opcode reg bit
199 * (REX.B << 3). */
200 uint8_t uRexB;
201 /** The extra REX SIB index field bit (REX.X << 3). */
202 uint8_t uRexIndex;
203 /** The effective segment register (X86_SREG_XXX). */
204 uint8_t iEffSeg;
205
206 /** The current offset into abOpcodes. */
207 uint8_t offOpcode;
208 /** The size of what has currently been fetched into abOpcodes. */
209 uint8_t cbOpcode;
210 /** The opcode bytes. */
211 uint8_t abOpcode[15];
212
213 /** @}*/
214
215 /** Alignment padding for aMemMappings. */
216 uint8_t abAlignment2[5];
217
218 /** The number of active guest memory mappings. */
219 uint8_t cActiveMappings;
220 /** The next unused mapping index. */
221 uint8_t iNextMapping;
222 /** Records for tracking guest memory mappings. */
223 struct
224 {
225 /** The address of the mapped bytes. */
226 void *pv;
227#if defined(IN_RC) && HC_ARCH_BITS == 64
228 uint32_t u32Alignment3; /**< Alignment padding. */
229#endif
230 /** The access flags (IEM_ACCESS_XXX).
231 * IEM_ACCESS_INVALID if the entry is unused. */
232 uint32_t fAccess;
233#if HC_ARCH_BITS == 64
234 uint32_t u32Alignment4; /**< Alignment padding. */
235#endif
236 } aMemMappings[3];
237
238 /** Bounce buffer info.
239 * This runs in parallel to aMemMappings. */
240 struct
241 {
242 /** The physical address of the first byte. */
243 RTGCPHYS GCPhysFirst;
244 /** The physical address of the second page. */
245 RTGCPHYS GCPhysSecond;
246 /** The number of bytes in the first page. */
247 uint16_t cbFirst;
248 /** The number of bytes in the second page. */
249 uint16_t cbSecond;
250 /** Whether it's unassigned memory. */
251 bool fUnassigned;
252 /** Explicit alignment padding. */
253 bool afAlignment5[3];
254 } aMemBbMappings[3];
255
256 /** Bounce buffer storage.
257 * This runs in parallel to aMemMappings and aMemBbMappings. */
258 struct
259 {
260 uint8_t ab[64];
261 } aBounceBuffers[3];
262
263#ifdef IEM_VERIFICATION_MODE
264 /** The event verification records for what IEM did (LIFO). */
265 R3PTRTYPE(PIEMVERIFYEVTREC) pIemEvtRecHead;
266 /** Insertion point for pIemEvtRecHead. */
267 R3PTRTYPE(PIEMVERIFYEVTREC *) ppIemEvtRecNext;
268 /** The event verification records for what the other party did (FIFO). */
269 R3PTRTYPE(PIEMVERIFYEVTREC) pOtherEvtRecHead;
270 /** Insertion point for pOtherEvtRecHead. */
271 R3PTRTYPE(PIEMVERIFYEVTREC *) ppOtherEvtRecNext;
272 /** List of free event records. */
273 R3PTRTYPE(PIEMVERIFYEVTREC) pFreeEvtRec;
274#endif
275} IEMCPU;
276/** Pointer to the per-CPU IEM state. */
277typedef IEMCPU *PIEMCPU;
278
279/** Converts a IEMCPU pointer to a VMCPU pointer.
280 * @returns VMCPU pointer.
281 * @param a_pIemCpu The IEM per CPU instance data.
282 */
283#define IEMCPU_TO_VMCPU(a_pIemCpu) ((PVMCPU)( (uintptr_t)(a_pIemCpu) + a_pIemCpu->offVMCpu ))
284
285/** Converts a IEMCPU pointer to a VM pointer.
286 * @returns VM pointer.
287 * @param a_pIemCpu The IEM per CPU instance data.
288 */
289#define IEMCPU_TO_VM(a_pIemCpu) ((PVM)( (uintptr_t)(a_pIemCpu) + a_pIemCpu->offVM ))
290
291/** @name IEM_ACCESS_XXX - Access details.
292 * @{ */
293#define IEM_ACCESS_INVALID UINT32_C(0x000000ff)
294#define IEM_ACCESS_TYPE_READ UINT32_C(0x00000001)
295#define IEM_ACCESS_TYPE_WRITE UINT32_C(0x00000002)
296#define IEM_ACCESS_TYPE_EXEC UINT32_C(0x00000004)
297#define IEM_ACCESS_TYPE_MASK UINT32_C(0x00000007)
298#define IEM_ACCESS_WHAT_CODE UINT32_C(0x00000010)
299#define IEM_ACCESS_WHAT_DATA UINT32_C(0x00000020)
300#define IEM_ACCESS_WHAT_STACK UINT32_C(0x00000030)
301#define IEM_ACCESS_WHAT_SYS UINT32_C(0x00000040)
302#define IEM_ACCESS_WHAT_MASK UINT32_C(0x00000070)
303/** Used in aMemMappings to indicate that the entry is bounce buffered. */
304#define IEM_ACCESS_BOUNCE_BUFFERED UINT32_C(0x00000100)
305/** Read+write data alias. */
306#define IEM_ACCESS_DATA_RW (IEM_ACCESS_TYPE_READ | IEM_ACCESS_TYPE_WRITE | IEM_ACCESS_WHAT_DATA)
307/** Write data alias. */
308#define IEM_ACCESS_DATA_W (IEM_ACCESS_TYPE_WRITE | IEM_ACCESS_WHAT_DATA)
309/** Read data alias. */
310#define IEM_ACCESS_DATA_R (IEM_ACCESS_TYPE_READ | IEM_ACCESS_WHAT_DATA)
311/** Instruction fetch alias. */
312#define IEM_ACCESS_INSTRUCTION (IEM_ACCESS_TYPE_EXEC | IEM_ACCESS_WHAT_CODE)
313/** Stack write alias. */
314#define IEM_ACCESS_STACK_W (IEM_ACCESS_TYPE_WRITE | IEM_ACCESS_WHAT_STACK)
315/** Stack read alias. */
316#define IEM_ACCESS_STACK_R (IEM_ACCESS_TYPE_READ | IEM_ACCESS_WHAT_STACK)
317/** @} */
318
319/** @name Prefix constants (IEMCPU::fPrefixes)
320 * @{ */
321#define IEM_OP_PRF_SEG_CS RT_BIT_32(0)
322#define IEM_OP_PRF_SEG_SS RT_BIT_32(1)
323#define IEM_OP_PRF_SEG_DS RT_BIT_32(2)
324#define IEM_OP_PRF_SEG_ES RT_BIT_32(3)
325#define IEM_OP_PRF_SEG_FS RT_BIT_32(4)
326#define IEM_OP_PRF_SEG_GS RT_BIT_32(5)
327#define IEM_OP_PRF_SEG_MASK UINT32_C(0x3f)
328
329#define IEM_OP_PRF_SIZE_OP RT_BIT_32(8)
330#define IEM_OP_PRF_SIZE_REX_W RT_BIT_32(9)
331#define IEM_OP_PRF_SIZE_ADDR RT_BIT_32(10)
332
333#define IEM_OP_PRF_LOCK RT_BIT_32(16)
334#define IEM_OP_PRF_REPNZ RT_BIT_32(17)
335#define IEM_OP_PRF_REPZ RT_BIT_32(18)
336
337#define IEM_OP_PRF_REX RT_BIT_32(24)
338#define IEM_OP_PRF_REX_R RT_BIT_32(25)
339#define IEM_OP_PRF_REX_B RT_BIT_32(26)
340#define IEM_OP_PRF_REX_X RT_BIT_32(27)
341/** @} */
342
343/**
344 * Tests if verification mode is enabled.
345 *
346 * This expands to @c false when IEM_VERIFICATION_MODE is not defined and
347 * should therefore cause the compiler to eliminate the verification branch
348 * of an if statement. */
349#ifdef IEM_VERIFICATION_MODE
350# define IEM_VERIFICATION_ENABLED(a_pIemCpu) ((a_pIemCpu)->fNoRem)
351#else
352# define IEM_VERIFICATION_ENABLED(a_pIemCpu) (false)
353#endif
354
355
356/** @def IEM_DECL_IMPL_TYPE
357 * For typedef'ing an instruction implementation function.
358 *
359 * @param a_RetType The return type.
360 * @param a_Name The name of the type.
361 * @param a_ArgList The argument list enclosed in parentheses.
362 */
363
364/** @def IEM_DECL_IMPL_DEF
365 * For defining an instruction implementation function.
366 *
367 * @param a_RetType The return type.
368 * @param a_Name The name of the type.
369 * @param a_ArgList The argument list enclosed in parentheses.
370 */
371
372#if defined(__GNUC__) && defined(RT_ARCH_X86)
373# define IEM_DECL_IMPL_TYPE(a_RetType, a_Name, a_ArgList) \
374 __attribute__((__fastcall__)) a_RetType (a_Name) a_ArgList
375# define IEM_DECL_IMPL_DEF(a_RetType, a_Name, a_ArgList) \
376 __attribute__((__fastcall__, __nothrow__)) a_RetType a_Name a_ArgList
377
378#elif defined(_MSC_VER) && defined(RT_ARCH_X86)
379# define IEM_DECL_IMPL_TYPE(a_RetType, a_Name, a_ArgList) \
380 a_RetType (__fastcall a_Name) a_ArgList
381# define IEM_DECL_IMPL_DEF(a_RetType, a_Name, a_ArgList) \
382 a_RetType __fastcall a_Name a_ArgList
383
384#else
385# define IEM_DECL_IMPL_TYPE(a_RetType, a_Name, a_ArgList) \
386 a_RetType (VBOXCALL a_Name) a_ArgList
387# define IEM_DECL_IMPL_DEF(a_RetType, a_Name, a_ArgList) \
388 a_RetType VBOXCALL a_Name a_ArgList
389
390#endif
391
392/** @name Arithmetic assignment operations on bytes (binary).
393 * @{ */
394typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINU8, (uint8_t *pu8Dst, uint8_t u8Src, uint32_t *pEFlags));
395typedef FNIEMAIMPLBINU8 *PFNIEMAIMPLBINU8;
396FNIEMAIMPLBINU8 iemAImpl_add_u8, iemAImpl_add_u8_locked;
397FNIEMAIMPLBINU8 iemAImpl_adc_u8, iemAImpl_adc_u8_locked;
398FNIEMAIMPLBINU8 iemAImpl_sub_u8, iemAImpl_sub_u8_locked;
399FNIEMAIMPLBINU8 iemAImpl_sbb_u8, iemAImpl_sbb_u8_locked;
400FNIEMAIMPLBINU8 iemAImpl_or_u8, iemAImpl_or_u8_locked;
401FNIEMAIMPLBINU8 iemAImpl_xor_u8, iemAImpl_xor_u8_locked;
402FNIEMAIMPLBINU8 iemAImpl_and_u8, iemAImpl_and_u8_locked;
403/** @} */
404
405/** @name Arithmetic assignment operations on words (binary).
406 * @{ */
407typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINU16, (uint16_t *pu16Dst, uint16_t u16Src, uint32_t *pEFlags));
408typedef FNIEMAIMPLBINU16 *PFNIEMAIMPLBINU16;
409FNIEMAIMPLBINU16 iemAImpl_add_u16, iemAImpl_add_u16_locked;
410FNIEMAIMPLBINU16 iemAImpl_adc_u16, iemAImpl_adc_u16_locked;
411FNIEMAIMPLBINU16 iemAImpl_sub_u16, iemAImpl_sub_u16_locked;
412FNIEMAIMPLBINU16 iemAImpl_sbb_u16, iemAImpl_sbb_u16_locked;
413FNIEMAIMPLBINU16 iemAImpl_or_u16, iemAImpl_or_u16_locked;
414FNIEMAIMPLBINU16 iemAImpl_xor_u16, iemAImpl_xor_u16_locked;
415FNIEMAIMPLBINU16 iemAImpl_and_u16, iemAImpl_and_u16_locked;
416/** @} */
417
418/** @name Arithmetic assignment operations on double words (binary).
419 * @{ */
420typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINU32, (uint32_t *pu32Dst, uint32_t u32Src, uint32_t *pEFlags));
421typedef FNIEMAIMPLBINU32 *PFNIEMAIMPLBINU32;
422FNIEMAIMPLBINU32 iemAImpl_add_u32, iemAImpl_add_u32_locked;
423FNIEMAIMPLBINU32 iemAImpl_adc_u32, iemAImpl_adc_u32_locked;
424FNIEMAIMPLBINU32 iemAImpl_sub_u32, iemAImpl_sub_u32_locked;
425FNIEMAIMPLBINU32 iemAImpl_sbb_u32, iemAImpl_sbb_u32_locked;
426FNIEMAIMPLBINU32 iemAImpl_or_u32, iemAImpl_or_u32_locked;
427FNIEMAIMPLBINU32 iemAImpl_xor_u32, iemAImpl_xor_u32_locked;
428FNIEMAIMPLBINU32 iemAImpl_and_u32, iemAImpl_and_u32_locked;
429/** @} */
430
431/** @name Arithmetic assignment operations on quad words (binary).
432 * @{ */
433typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINU64, (uint64_t *pu64Dst, uint64_t u64Src, uint32_t *pEFlags));
434typedef FNIEMAIMPLBINU64 *PFNIEMAIMPLBINU64;
435FNIEMAIMPLBINU64 iemAImpl_add_u64, iemAImpl_add_u64_locked;
436FNIEMAIMPLBINU64 iemAImpl_adc_u64, iemAImpl_adc_u64_locked;
437FNIEMAIMPLBINU64 iemAImpl_sub_u64, iemAImpl_sub_u64_locked;
438FNIEMAIMPLBINU64 iemAImpl_sbb_u64, iemAImpl_sbb_u64_locked;
439FNIEMAIMPLBINU64 iemAImpl_or_u64, iemAImpl_or_u64_locked;
440FNIEMAIMPLBINU64 iemAImpl_xor_u64, iemAImpl_xor_u64_locked;
441FNIEMAIMPLBINU64 iemAImpl_and_u64, iemAImpl_and_u64_locked;
442/** @} */
443
444/** @name Compare operations (thrown in with the binary ops).
445 * @{ */
446FNIEMAIMPLBINU8 iemAImpl_cmp_u8;
447FNIEMAIMPLBINU16 iemAImpl_cmp_u16;
448FNIEMAIMPLBINU32 iemAImpl_cmp_u32;
449FNIEMAIMPLBINU64 iemAImpl_cmp_u64;
450/** @} */
451
452/** @name Test operations (thrown in with the binary ops).
453 * @{ */
454FNIEMAIMPLBINU8 iemAImpl_test_u8;
455FNIEMAIMPLBINU16 iemAImpl_test_u16;
456FNIEMAIMPLBINU32 iemAImpl_test_u32;
457FNIEMAIMPLBINU64 iemAImpl_test_u64;
458/** @} */
459
460/** @name Exchange memory with register operations.
461 * @{ */
462IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u8, (uint8_t *pu8Mem, uint8_t *pu8Reg));
463IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u16,(uint16_t *pu16Mem, uint16_t *pu16Reg));
464IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u32,(uint32_t *pu32Mem, uint32_t *pu32Reg));
465IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u64,(uint64_t *pu64Mem, uint64_t *pu64Reg));
466/** @} */
467
468/** @name Signed multiplication operations (thrown in with the binary ops).
469 * @{ */
470FNIEMAIMPLBINU16 iemAImpl_imul_two_u16;
471FNIEMAIMPLBINU32 iemAImpl_imul_two_u32;
472FNIEMAIMPLBINU64 iemAImpl_imul_two_u64;
473/** @} */
474
475/** @name Arithmetic assignment operations on bytes (unary).
476 * @{ */
477typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLUNARYU8, (uint8_t *pu8Dst, uint32_t *pEFlags));
478typedef FNIEMAIMPLUNARYU8 *PFNIEMAIMPLUNARYU8;
479FNIEMAIMPLUNARYU8 iemAImpl_inc_u8, iemAImpl_inc_u8_locked;
480FNIEMAIMPLUNARYU8 iemAImpl_dec_u8, iemAImpl_dec_u8_locked;
481FNIEMAIMPLUNARYU8 iemAImpl_not_u8, iemAImpl_not_u8_locked;
482FNIEMAIMPLUNARYU8 iemAImpl_neg_u8, iemAImpl_neg_u8_locked;
483/** @} */
484
485/** @name Arithmetic assignment operations on words (unary).
486 * @{ */
487typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLUNARYU16, (uint16_t *pu16Dst, uint32_t *pEFlags));
488typedef FNIEMAIMPLUNARYU16 *PFNIEMAIMPLUNARYU16;
489FNIEMAIMPLUNARYU16 iemAImpl_inc_u16, iemAImpl_inc_u16_locked;
490FNIEMAIMPLUNARYU16 iemAImpl_dec_u16, iemAImpl_dec_u16_locked;
491FNIEMAIMPLUNARYU16 iemAImpl_not_u16, iemAImpl_not_u16_locked;
492FNIEMAIMPLUNARYU16 iemAImpl_neg_u16, iemAImpl_neg_u16_locked;
493/** @} */
494
495/** @name Arithmetic assignment operations on double words (unary).
496 * @{ */
497typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLUNARYU32, (uint32_t *pu32Dst, uint32_t *pEFlags));
498typedef FNIEMAIMPLUNARYU32 *PFNIEMAIMPLUNARYU32;
499FNIEMAIMPLUNARYU32 iemAImpl_inc_u32, iemAImpl_inc_u32_locked;
500FNIEMAIMPLUNARYU32 iemAImpl_dec_u32, iemAImpl_dec_u32_locked;
501FNIEMAIMPLUNARYU32 iemAImpl_not_u32, iemAImpl_not_u32_locked;
502FNIEMAIMPLUNARYU32 iemAImpl_neg_u32, iemAImpl_neg_u32_locked;
503/** @} */
504
505/** @name Arithmetic assignment operations on quad words (unary).
506 * @{ */
507typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLUNARYU64, (uint64_t *pu64Dst, uint32_t *pEFlags));
508typedef FNIEMAIMPLUNARYU64 *PFNIEMAIMPLUNARYU64;
509FNIEMAIMPLUNARYU64 iemAImpl_inc_u64, iemAImpl_inc_u64_locked;
510FNIEMAIMPLUNARYU64 iemAImpl_dec_u64, iemAImpl_dec_u64_locked;
511FNIEMAIMPLUNARYU64 iemAImpl_not_u64, iemAImpl_not_u64_locked;
512FNIEMAIMPLUNARYU64 iemAImpl_neg_u64, iemAImpl_neg_u64_locked;
513/** @} */
514
515
516/** @name Shift operations on bytes (Group 2).
517 * @{ */
518typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTU8,(uint8_t *pu8Dst, uint8_t cShift, uint32_t *pEFlags));
519typedef FNIEMAIMPLSHIFTU8 *PFNIEMAIMPLSHIFTU8;
520FNIEMAIMPLSHIFTU8 iemAImpl_rol_u8;
521FNIEMAIMPLSHIFTU8 iemAImpl_ror_u8;
522FNIEMAIMPLSHIFTU8 iemAImpl_rcl_u8;
523FNIEMAIMPLSHIFTU8 iemAImpl_rcr_u8;
524FNIEMAIMPLSHIFTU8 iemAImpl_shl_u8;
525FNIEMAIMPLSHIFTU8 iemAImpl_shr_u8;
526FNIEMAIMPLSHIFTU8 iemAImpl_sar_u8;
527/** @} */
528
529/** @name Shift operations on words (Group 2).
530 * @{ */
531typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTU16,(uint16_t *pu16Dst, uint8_t cShift, uint32_t *pEFlags));
532typedef FNIEMAIMPLSHIFTU16 *PFNIEMAIMPLSHIFTU16;
533FNIEMAIMPLSHIFTU16 iemAImpl_rol_u16;
534FNIEMAIMPLSHIFTU16 iemAImpl_ror_u16;
535FNIEMAIMPLSHIFTU16 iemAImpl_rcl_u16;
536FNIEMAIMPLSHIFTU16 iemAImpl_rcr_u16;
537FNIEMAIMPLSHIFTU16 iemAImpl_shl_u16;
538FNIEMAIMPLSHIFTU16 iemAImpl_shr_u16;
539FNIEMAIMPLSHIFTU16 iemAImpl_sar_u16;
540/** @} */
541
542/** @name Shift operations on double words (Group 2).
543 * @{ */
544typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTU32,(uint32_t *pu32Dst, uint8_t cShift, uint32_t *pEFlags));
545typedef FNIEMAIMPLSHIFTU32 *PFNIEMAIMPLSHIFTU32;
546FNIEMAIMPLSHIFTU32 iemAImpl_rol_u32;
547FNIEMAIMPLSHIFTU32 iemAImpl_ror_u32;
548FNIEMAIMPLSHIFTU32 iemAImpl_rcl_u32;
549FNIEMAIMPLSHIFTU32 iemAImpl_rcr_u32;
550FNIEMAIMPLSHIFTU32 iemAImpl_shl_u32;
551FNIEMAIMPLSHIFTU32 iemAImpl_shr_u32;
552FNIEMAIMPLSHIFTU32 iemAImpl_sar_u32;
553/** @} */
554
555/** @name Shift operations on words (Group 2).
556 * @{ */
557typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTU64,(uint64_t *pu64Dst, uint8_t cShift, uint32_t *pEFlags));
558typedef FNIEMAIMPLSHIFTU64 *PFNIEMAIMPLSHIFTU64;
559FNIEMAIMPLSHIFTU64 iemAImpl_rol_u64;
560FNIEMAIMPLSHIFTU64 iemAImpl_ror_u64;
561FNIEMAIMPLSHIFTU64 iemAImpl_rcl_u64;
562FNIEMAIMPLSHIFTU64 iemAImpl_rcr_u64;
563FNIEMAIMPLSHIFTU64 iemAImpl_shl_u64;
564FNIEMAIMPLSHIFTU64 iemAImpl_shr_u64;
565FNIEMAIMPLSHIFTU64 iemAImpl_sar_u64;
566/** @} */
567
568/** @name Multiplication and division operations.
569 * @{ */
570typedef IEM_DECL_IMPL_TYPE(int, FNIEMAIMPLMULDIVU8,(uint16_t *pu16AX, uint8_t u8FactorDivisor, uint32_t *pEFlags));
571typedef FNIEMAIMPLMULDIVU8 *PFNIEMAIMPLMULDIVU8;
572FNIEMAIMPLMULDIVU8 iemAImpl_mul_u8, iemAImpl_imul_u8;
573FNIEMAIMPLMULDIVU8 iemAImpl_div_u8, iemAImpl_idiv_u8;
574
575typedef IEM_DECL_IMPL_TYPE(int, FNIEMAIMPLMULDIVU16,(uint16_t *pu16AX, uint16_t *pu16DX, uint16_t u16FactorDivisor, uint32_t *pEFlags));
576typedef FNIEMAIMPLMULDIVU16 *PFNIEMAIMPLMULDIVU16;
577FNIEMAIMPLMULDIVU16 iemAImpl_mul_u16, iemAImpl_imul_u16;
578FNIEMAIMPLMULDIVU16 iemAImpl_div_u16, iemAImpl_idiv_u16;
579
580typedef IEM_DECL_IMPL_TYPE(int, FNIEMAIMPLMULDIVU32,(uint32_t *pu32EAX, uint32_t *pu32EDX, uint32_t u32FactorDivisor, uint32_t *pEFlags));
581typedef FNIEMAIMPLMULDIVU32 *PFNIEMAIMPLMULDIVU32;
582FNIEMAIMPLMULDIVU32 iemAImpl_mul_u32, iemAImpl_imul_u32;
583FNIEMAIMPLMULDIVU32 iemAImpl_div_u32, iemAImpl_idiv_u32;
584
585typedef IEM_DECL_IMPL_TYPE(int, FNIEMAIMPLMULDIVU64,(uint64_t *pu64RAX, uint64_t *pu64RDX, uint64_t u64FactorDivisor, uint32_t *pEFlags));
586typedef FNIEMAIMPLMULDIVU64 *PFNIEMAIMPLMULDIVU64;
587FNIEMAIMPLMULDIVU64 iemAImpl_mul_u64, iemAImpl_imul_u64;
588FNIEMAIMPLMULDIVU64 iemAImpl_div_u64, iemAImpl_idiv_u64;
589/** @} */
590
591
592/** @name C instruction implementations for anything slightly complicated.
593 * @{ */
594
595/**
596 * For typedef'ing or declaring a C instruction implementation function taking
597 * no extra arguments.
598 *
599 * @param a_Name The name of the type.
600 */
601# define IEM_CIMPL_DECL_TYPE_0(a_Name) \
602 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PIEMCPU pIemCpu, uint8_t cbInstr))
603/**
604 * For defining a C instruction implementation function taking no extra
605 * arguments.
606 *
607 * @param a_Name The name of the function
608 */
609# define IEM_CIMPL_DEF_0(a_Name) \
610 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PIEMCPU pIemCpu, uint8_t cbInstr))
611/**
612 * For calling a C instruction implementation function taking no extra
613 * arguments.
614 *
615 * This special call macro adds default arguments to the call and allow us to
616 * change these later.
617 *
618 * @param a_fn The name of the function.
619 */
620# define IEM_CIMPL_CALL_0(a_fn) a_fn(pIemCpu, cbInstr)
621
622/**
623 * For typedef'ing or declaring a C instruction implementation function taking
624 * one extra argument.
625 *
626 * @param a_Name The name of the type.
627 * @param a_Type0 The argument type.
628 * @param a_Arg0 The argument name.
629 */
630# define IEM_CIMPL_DECL_TYPE_1(a_Name, a_Type0, a_Arg0) \
631 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PIEMCPU pIemCpu, uint8_t cbInstr, a_Type0 a_Arg0))
632/**
633 * For defining a C instruction implementation function taking one extra
634 * argument.
635 *
636 * @param a_Name The name of the function
637 * @param a_Type0 The argument type.
638 * @param a_Arg0 The argument name.
639 */
640# define IEM_CIMPL_DEF_1(a_Name, a_Type0, a_Arg0) \
641 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PIEMCPU pIemCpu, uint8_t cbInstr, a_Type0 a_Arg0))
642/**
643 * For calling a C instruction implementation function taking one extra
644 * argument.
645 *
646 * This special call macro adds default arguments to the call and allow us to
647 * change these later.
648 *
649 * @param a_fn The name of the function.
650 * @param a0 The name of the 1st argument.
651 */
652# define IEM_CIMPL_CALL_1(a_fn, a0) a_fn(pIemCpu, cbInstr, (a0))
653
654/**
655 * For typedef'ing or declaring a C instruction implementation function taking
656 * two extra arguments.
657 *
658 * @param a_Name The name of the type.
659 * @param a_Type0 The type of the 1st argument
660 * @param a_Arg0 The name of the 1st argument.
661 * @param a_Type1 The type of the 2nd argument.
662 * @param a_Arg1 The name of the 2nd argument.
663 */
664# define IEM_CIMPL_DECL_TYPE_2(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1) \
665 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PIEMCPU pIemCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1))
666/**
667 * For defining a C instruction implementation function taking two extra
668 * arguments.
669 *
670 * @param a_Name The name of the function.
671 * @param a_Type0 The type of the 1st argument
672 * @param a_Arg0 The name of the 1st argument.
673 * @param a_Type1 The type of the 2nd argument.
674 * @param a_Arg1 The name of the 2nd argument.
675 */
676# define IEM_CIMPL_DEF_2(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1) \
677 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PIEMCPU pIemCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1))
678/**
679 * For calling a C instruction implementation function taking two extra
680 * arguments.
681 *
682 * This special call macro adds default arguments to the call and allow us to
683 * change these later.
684 *
685 * @param a_fn The name of the function.
686 * @param a0 The name of the 1st argument.
687 * @param a1 The name of the 2nd argument.
688 */
689# define IEM_CIMPL_CALL_2(a_fn, a0, a1) a_fn(pIemCpu, cbInstr, (a0), (a1))
690
691/**
692 * For typedef'ing or declaring a C instruction implementation function taking
693 * three extra arguments.
694 *
695 * @param a_Name The name of the type.
696 * @param a_Type0 The type of the 1st argument
697 * @param a_Arg0 The name of the 1st argument.
698 * @param a_Type1 The type of the 2nd argument.
699 * @param a_Arg1 The name of the 2nd argument.
700 * @param a_Type2 The type of the 3rd argument.
701 * @param a_Arg2 The name of the 3rd argument.
702 */
703# define IEM_CIMPL_DECL_TYPE_3(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2) \
704 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PIEMCPU pIemCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, a_Type2 a_Arg2))
705/**
706 * For defining a C instruction implementation function taking three extra
707 * arguments.
708 *
709 * @param a_Name The name of the function.
710 * @param a_Type0 The type of the 1st argument
711 * @param a_Arg0 The name of the 1st argument.
712 * @param a_Type1 The type of the 2nd argument.
713 * @param a_Arg1 The name of the 2nd argument.
714 * @param a_Type2 The type of the 3rd argument.
715 * @param a_Arg2 The name of the 3rd argument.
716 */
717# define IEM_CIMPL_DEF_3(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2) \
718 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PIEMCPU pIemCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, a_Type2 a_Arg2))
719/**
720 * For calling a C instruction implementation function taking three extra
721 * arguments.
722 *
723 * This special call macro adds default arguments to the call and allow us to
724 * change these later.
725 *
726 * @param a_fn The name of the function.
727 * @param a0 The name of the 1st argument.
728 * @param a1 The name of the 2nd argument.
729 * @param a2 The name of the 3rd argument.
730 */
731# define IEM_CIMPL_CALL_3(a_fn, a0, a1, a2) a_fn(pIemCpu, cbInstr, (a0), (a1), (a2))
732
733
734/**
735 * For typedef'ing or declaring a C instruction implementation function taking
736 * four extra arguments.
737 *
738 * @param a_Name The name of the type.
739 * @param a_Type0 The type of the 1st argument
740 * @param a_Arg0 The name of the 1st argument.
741 * @param a_Type1 The type of the 2nd argument.
742 * @param a_Arg1 The name of the 2nd argument.
743 * @param a_Type2 The type of the 3rd argument.
744 * @param a_Arg2 The name of the 3rd argument.
745 * @param a_Type3 The type of the 4th argument.
746 * @param a_Arg3 The name of the 4th argument.
747 */
748# define IEM_CIMPL_DECL_TYPE_4(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2, a_Type3, a_Arg3) \
749 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PIEMCPU pIemCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, a_Type2 a_Arg2, a_Type3 a_Arg3))
750/**
751 * For defining a C instruction implementation function taking four extra
752 * arguments.
753 *
754 * @param a_Name The name of the function.
755 * @param a_Type0 The type of the 1st argument
756 * @param a_Arg0 The name of the 1st argument.
757 * @param a_Type1 The type of the 2nd argument.
758 * @param a_Arg1 The name of the 2nd argument.
759 * @param a_Type2 The type of the 3rd argument.
760 * @param a_Arg2 The name of the 3rd argument.
761 * @param a_Type3 The type of the 4th argument.
762 * @param a_Arg3 The name of the 4th argument.
763 */
764# define IEM_CIMPL_DEF_4(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2, a_Type3, aArg3) \
765 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PIEMCPU pIemCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, a_Type2 a_Arg2, a_Type3 a_Arg3))
766/**
767 * For calling a C instruction implementation function taking four extra
768 * arguments.
769 *
770 * This special call macro adds default arguments to the call and allow us to
771 * change these later.
772 *
773 * @param a_fn The name of the function.
774 * @param a0 The name of the 1st argument.
775 * @param a1 The name of the 2nd argument.
776 * @param a2 The name of the 3rd argument.
777 * @param a3 The name of the 4th argument.
778 */
779# define IEM_CIMPL_CALL_4(a_fn, a0, a1, a2, a3) a_fn(pIemCpu, cbInstr, (a0), (a1), (a2), (a3))
780
781
782/**
783 * For typedef'ing or declaring a C instruction implementation function taking
784 * five extra arguments.
785 *
786 * @param a_Name The name of the type.
787 * @param a_Type0 The type of the 1st argument
788 * @param a_Arg0 The name of the 1st argument.
789 * @param a_Type1 The type of the 2nd argument.
790 * @param a_Arg1 The name of the 2nd argument.
791 * @param a_Type2 The type of the 3rd argument.
792 * @param a_Arg2 The name of the 3rd argument.
793 * @param a_Type3 The type of the 4th argument.
794 * @param a_Arg3 The name of the 4th argument.
795 * @param a_Type4 The type of the 5th argument.
796 * @param a_Arg4 The name of the 5th argument.
797 */
798# 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) \
799 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PIEMCPU pIemCpu, uint8_t cbInstr, \
800 a_Type0 a_Arg0, a_Type1 a_Arg1, a_Type2 a_Arg2, \
801 a_Type3 a_Arg3, a_Type4 a_Arg4))
802/**
803 * For defining a C instruction implementation function taking five extra
804 * arguments.
805 *
806 * @param a_Name The name of the function.
807 * @param a_Type0 The type of the 1st argument
808 * @param a_Arg0 The name of the 1st argument.
809 * @param a_Type1 The type of the 2nd argument.
810 * @param a_Arg1 The name of the 2nd argument.
811 * @param a_Type2 The type of the 3rd argument.
812 * @param a_Arg2 The name of the 3rd argument.
813 * @param a_Type3 The type of the 4th argument.
814 * @param a_Arg3 The name of the 4th argument.
815 * @param a_Type4 The type of the 5th argument.
816 * @param a_Arg4 The name of the 5th argument.
817 */
818# 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) \
819 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PIEMCPU pIemCpu, uint8_t cbInstr, \
820 a_Type0 a_Arg0, a_Type1 a_Arg1, a_Type2 a_Arg2, \
821 a_Type3 a_Arg3, a_Type4 a_Arg4))
822/**
823 * For calling a C instruction implementation function taking five extra
824 * arguments.
825 *
826 * This special call macro adds default arguments to the call and allow us to
827 * change these later.
828 *
829 * @param a_fn The name of the function.
830 * @param a0 The name of the 1st argument.
831 * @param a1 The name of the 2nd argument.
832 * @param a2 The name of the 3rd argument.
833 * @param a3 The name of the 4th argument.
834 * @param a4 The name of the 5th argument.
835 */
836# define IEM_CIMPL_CALL_5(a_fn, a0, a1, a2, a3, a4) a_fn(pIemCpu, cbInstr, (a0), (a1), (a2), (a3), (a4))
837
838/** @} */
839
840
841/** @} */
842
843RT_C_DECLS_END
844
845#endif
846
847
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