1 | /* $Id: IEMMc.h 96789 2022-09-19 13:04:06Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * IEM - Interpreted Execution Manager - IEM_MC_XXX.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2011-2022 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef VMM_INCLUDED_SRC_include_IEMMc_h
|
---|
29 | #define VMM_INCLUDED_SRC_include_IEMMc_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 |
|
---|
35 | /** @name "Microcode" macros.
|
---|
36 | *
|
---|
37 | * The idea is that we should be able to use the same code to interpret
|
---|
38 | * instructions as well as recompiler instructions. Thus this obfuscation.
|
---|
39 | *
|
---|
40 | * @{
|
---|
41 | */
|
---|
42 | #define IEM_MC_BEGIN(a_cArgs, a_cLocals) {
|
---|
43 | #define IEM_MC_END() }
|
---|
44 | #define IEM_MC_PAUSE() do {} while (0)
|
---|
45 | #define IEM_MC_CONTINUE() do {} while (0)
|
---|
46 |
|
---|
47 | /** Internal macro. */
|
---|
48 | #define IEM_MC_RETURN_ON_FAILURE(a_Expr) \
|
---|
49 | do \
|
---|
50 | { \
|
---|
51 | VBOXSTRICTRC rcStrict2 = a_Expr; \
|
---|
52 | if (rcStrict2 != VINF_SUCCESS) \
|
---|
53 | return rcStrict2; \
|
---|
54 | } while (0)
|
---|
55 |
|
---|
56 |
|
---|
57 | #define IEM_MC_ADVANCE_RIP() iemRegUpdateRipAndClearRF(pVCpu)
|
---|
58 | #define IEM_MC_REL_JMP_S8(a_i8) IEM_MC_RETURN_ON_FAILURE(iemRegRipRelativeJumpS8(pVCpu, a_i8))
|
---|
59 | #define IEM_MC_REL_JMP_S16(a_i16) IEM_MC_RETURN_ON_FAILURE(iemRegRipRelativeJumpS16(pVCpu, a_i16))
|
---|
60 | #define IEM_MC_REL_JMP_S32(a_i32) IEM_MC_RETURN_ON_FAILURE(iemRegRipRelativeJumpS32(pVCpu, a_i32))
|
---|
61 | #define IEM_MC_SET_RIP_U16(a_u16NewIP) IEM_MC_RETURN_ON_FAILURE(iemRegRipJump((pVCpu), (a_u16NewIP)))
|
---|
62 | #define IEM_MC_SET_RIP_U32(a_u32NewIP) IEM_MC_RETURN_ON_FAILURE(iemRegRipJump((pVCpu), (a_u32NewIP)))
|
---|
63 | #define IEM_MC_SET_RIP_U64(a_u64NewIP) IEM_MC_RETURN_ON_FAILURE(iemRegRipJump((pVCpu), (a_u64NewIP)))
|
---|
64 | #define IEM_MC_RAISE_DIVIDE_ERROR() return iemRaiseDivideError(pVCpu)
|
---|
65 | #define IEM_MC_MAYBE_RAISE_DEVICE_NOT_AVAILABLE() \
|
---|
66 | do { \
|
---|
67 | if (pVCpu->cpum.GstCtx.cr0 & (X86_CR0_EM | X86_CR0_TS)) \
|
---|
68 | return iemRaiseDeviceNotAvailable(pVCpu); \
|
---|
69 | } while (0)
|
---|
70 | #define IEM_MC_MAYBE_RAISE_WAIT_DEVICE_NOT_AVAILABLE() \
|
---|
71 | do { \
|
---|
72 | if ((pVCpu->cpum.GstCtx.cr0 & (X86_CR0_MP | X86_CR0_TS)) == (X86_CR0_MP | X86_CR0_TS)) \
|
---|
73 | return iemRaiseDeviceNotAvailable(pVCpu); \
|
---|
74 | } while (0)
|
---|
75 | #define IEM_MC_MAYBE_RAISE_FPU_XCPT() \
|
---|
76 | do { \
|
---|
77 | if (pVCpu->cpum.GstCtx.XState.x87.FSW & X86_FSW_ES) \
|
---|
78 | return iemRaiseMathFault(pVCpu); \
|
---|
79 | } while (0)
|
---|
80 | #define IEM_MC_MAYBE_RAISE_AVX2_RELATED_XCPT() \
|
---|
81 | do { \
|
---|
82 | if ( (pVCpu->cpum.GstCtx.aXcr[0] & (XSAVE_C_YMM | XSAVE_C_SSE)) != (XSAVE_C_YMM | XSAVE_C_SSE) \
|
---|
83 | || !(pVCpu->cpum.GstCtx.cr4 & X86_CR4_OSXSAVE) \
|
---|
84 | || !IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fAvx2) \
|
---|
85 | return iemRaiseUndefinedOpcode(pVCpu); \
|
---|
86 | if (pVCpu->cpum.GstCtx.cr0 & X86_CR0_TS) \
|
---|
87 | return iemRaiseDeviceNotAvailable(pVCpu); \
|
---|
88 | } while (0)
|
---|
89 | #define IEM_MC_MAYBE_RAISE_AVX_RELATED_XCPT() \
|
---|
90 | do { \
|
---|
91 | if ( (pVCpu->cpum.GstCtx.aXcr[0] & (XSAVE_C_YMM | XSAVE_C_SSE)) != (XSAVE_C_YMM | XSAVE_C_SSE) \
|
---|
92 | || !(pVCpu->cpum.GstCtx.cr4 & X86_CR4_OSXSAVE) \
|
---|
93 | || !IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fAvx) \
|
---|
94 | return iemRaiseUndefinedOpcode(pVCpu); \
|
---|
95 | if (pVCpu->cpum.GstCtx.cr0 & X86_CR0_TS) \
|
---|
96 | return iemRaiseDeviceNotAvailable(pVCpu); \
|
---|
97 | } while (0)
|
---|
98 | #define IEM_MC_MAYBE_RAISE_SSE42_RELATED_XCPT() \
|
---|
99 | do { \
|
---|
100 | if ( (pVCpu->cpum.GstCtx.cr0 & X86_CR0_EM) \
|
---|
101 | || !(pVCpu->cpum.GstCtx.cr4 & X86_CR4_OSFXSR) \
|
---|
102 | || !IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fSse42) \
|
---|
103 | return iemRaiseUndefinedOpcode(pVCpu); \
|
---|
104 | if (pVCpu->cpum.GstCtx.cr0 & X86_CR0_TS) \
|
---|
105 | return iemRaiseDeviceNotAvailable(pVCpu); \
|
---|
106 | } while (0)
|
---|
107 | #define IEM_MC_MAYBE_RAISE_SSE41_RELATED_XCPT() \
|
---|
108 | do { \
|
---|
109 | if ( (pVCpu->cpum.GstCtx.cr0 & X86_CR0_EM) \
|
---|
110 | || !(pVCpu->cpum.GstCtx.cr4 & X86_CR4_OSFXSR) \
|
---|
111 | || !IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fSse41) \
|
---|
112 | return iemRaiseUndefinedOpcode(pVCpu); \
|
---|
113 | if (pVCpu->cpum.GstCtx.cr0 & X86_CR0_TS) \
|
---|
114 | return iemRaiseDeviceNotAvailable(pVCpu); \
|
---|
115 | } while (0)
|
---|
116 | #define IEM_MC_MAYBE_RAISE_SSSE3_RELATED_XCPT() \
|
---|
117 | do { \
|
---|
118 | if ( (pVCpu->cpum.GstCtx.cr0 & X86_CR0_EM) \
|
---|
119 | || !(pVCpu->cpum.GstCtx.cr4 & X86_CR4_OSFXSR) \
|
---|
120 | || !IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fSsse3) \
|
---|
121 | return iemRaiseUndefinedOpcode(pVCpu); \
|
---|
122 | if (pVCpu->cpum.GstCtx.cr0 & X86_CR0_TS) \
|
---|
123 | return iemRaiseDeviceNotAvailable(pVCpu); \
|
---|
124 | } while (0)
|
---|
125 | #define IEM_MC_MAYBE_RAISE_SSE3_RELATED_XCPT() \
|
---|
126 | do { \
|
---|
127 | if ( (pVCpu->cpum.GstCtx.cr0 & X86_CR0_EM) \
|
---|
128 | || !(pVCpu->cpum.GstCtx.cr4 & X86_CR4_OSFXSR) \
|
---|
129 | || !IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fSse3) \
|
---|
130 | return iemRaiseUndefinedOpcode(pVCpu); \
|
---|
131 | if (pVCpu->cpum.GstCtx.cr0 & X86_CR0_TS) \
|
---|
132 | return iemRaiseDeviceNotAvailable(pVCpu); \
|
---|
133 | } while (0)
|
---|
134 | #define IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT() \
|
---|
135 | do { \
|
---|
136 | if ( (pVCpu->cpum.GstCtx.cr0 & X86_CR0_EM) \
|
---|
137 | || !(pVCpu->cpum.GstCtx.cr4 & X86_CR4_OSFXSR) \
|
---|
138 | || !IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fSse2) \
|
---|
139 | return iemRaiseUndefinedOpcode(pVCpu); \
|
---|
140 | if (pVCpu->cpum.GstCtx.cr0 & X86_CR0_TS) \
|
---|
141 | return iemRaiseDeviceNotAvailable(pVCpu); \
|
---|
142 | } while (0)
|
---|
143 | #define IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT() \
|
---|
144 | do { \
|
---|
145 | if ( (pVCpu->cpum.GstCtx.cr0 & X86_CR0_EM) \
|
---|
146 | || !(pVCpu->cpum.GstCtx.cr4 & X86_CR4_OSFXSR) \
|
---|
147 | || !IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fSse) \
|
---|
148 | return iemRaiseUndefinedOpcode(pVCpu); \
|
---|
149 | if (pVCpu->cpum.GstCtx.cr0 & X86_CR0_TS) \
|
---|
150 | return iemRaiseDeviceNotAvailable(pVCpu); \
|
---|
151 | } while (0)
|
---|
152 | #define IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT() \
|
---|
153 | do { \
|
---|
154 | if ( (pVCpu->cpum.GstCtx.cr0 & X86_CR0_EM) \
|
---|
155 | || !IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fMmx) \
|
---|
156 | return iemRaiseUndefinedOpcode(pVCpu); \
|
---|
157 | if (pVCpu->cpum.GstCtx.cr0 & X86_CR0_TS) \
|
---|
158 | return iemRaiseDeviceNotAvailable(pVCpu); \
|
---|
159 | if (pVCpu->cpum.GstCtx.XState.x87.FSW & X86_FSW_ES) \
|
---|
160 | return iemRaiseMathFault(pVCpu); \
|
---|
161 | } while (0)
|
---|
162 | #define IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT_EX(a_fSupported) \
|
---|
163 | do { \
|
---|
164 | if ( (pVCpu->cpum.GstCtx.cr0 & X86_CR0_EM) \
|
---|
165 | || !(a_fSupported)) \
|
---|
166 | return iemRaiseUndefinedOpcode(pVCpu); \
|
---|
167 | if (pVCpu->cpum.GstCtx.cr0 & X86_CR0_TS) \
|
---|
168 | return iemRaiseDeviceNotAvailable(pVCpu); \
|
---|
169 | if (pVCpu->cpum.GstCtx.XState.x87.FSW & X86_FSW_ES) \
|
---|
170 | return iemRaiseMathFault(pVCpu); \
|
---|
171 | } while (0)
|
---|
172 | #define IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT_CHECK_SSE_OR_MMXEXT() \
|
---|
173 | do { \
|
---|
174 | if ( (pVCpu->cpum.GstCtx.cr0 & X86_CR0_EM) \
|
---|
175 | || ( !IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fSse \
|
---|
176 | && !IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fAmdMmxExts) ) \
|
---|
177 | return iemRaiseUndefinedOpcode(pVCpu); \
|
---|
178 | if (pVCpu->cpum.GstCtx.cr0 & X86_CR0_TS) \
|
---|
179 | return iemRaiseDeviceNotAvailable(pVCpu); \
|
---|
180 | if (pVCpu->cpum.GstCtx.XState.x87.FSW & X86_FSW_ES) \
|
---|
181 | return iemRaiseMathFault(pVCpu); \
|
---|
182 | } while (0)
|
---|
183 | #define IEM_MC_RAISE_GP0_IF_CPL_NOT_ZERO() \
|
---|
184 | do { \
|
---|
185 | if (pVCpu->iem.s.uCpl != 0) \
|
---|
186 | return iemRaiseGeneralProtectionFault0(pVCpu); \
|
---|
187 | } while (0)
|
---|
188 | #define IEM_MC_RAISE_GP0_IF_EFF_ADDR_UNALIGNED(a_EffAddr, a_cbAlign) \
|
---|
189 | do { \
|
---|
190 | if (!((a_EffAddr) & ((a_cbAlign) - 1))) { /* likely */ } \
|
---|
191 | else return iemRaiseGeneralProtectionFault0(pVCpu); \
|
---|
192 | } while (0)
|
---|
193 | #define IEM_MC_MAYBE_RAISE_FSGSBASE_XCPT() \
|
---|
194 | do { \
|
---|
195 | if ( pVCpu->iem.s.enmCpuMode != IEMMODE_64BIT \
|
---|
196 | || !IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fFsGsBase \
|
---|
197 | || !(pVCpu->cpum.GstCtx.cr4 & X86_CR4_FSGSBASE)) \
|
---|
198 | return iemRaiseUndefinedOpcode(pVCpu); \
|
---|
199 | } while (0)
|
---|
200 | #define IEM_MC_MAYBE_RAISE_NON_CANONICAL_ADDR_GP0(a_u64Addr) \
|
---|
201 | do { \
|
---|
202 | if (!IEM_IS_CANONICAL(a_u64Addr)) \
|
---|
203 | return iemRaiseGeneralProtectionFault0(pVCpu); \
|
---|
204 | } while (0)
|
---|
205 | #define IEM_MC_MAYBE_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT() \
|
---|
206 | do { \
|
---|
207 | if (( ~((pVCpu->cpum.GstCtx.XState.x87.MXCSR & X86_MXCSR_XCPT_MASK) >> X86_MXCSR_XCPT_MASK_SHIFT) \
|
---|
208 | & (pVCpu->cpum.GstCtx.XState.x87.MXCSR & X86_MXCSR_XCPT_FLAGS)) != 0) \
|
---|
209 | { \
|
---|
210 | if (pVCpu->cpum.GstCtx.cr4 & X86_CR4_OSXMMEEXCPT)\
|
---|
211 | return iemRaiseSimdFpException(pVCpu); \
|
---|
212 | else \
|
---|
213 | return iemRaiseUndefinedOpcode(pVCpu); \
|
---|
214 | } \
|
---|
215 | } while (0)
|
---|
216 | #define IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT() \
|
---|
217 | do { \
|
---|
218 | if (pVCpu->cpum.GstCtx.cr4 & X86_CR4_OSXMMEEXCPT)\
|
---|
219 | return iemRaiseSimdFpException(pVCpu); \
|
---|
220 | else \
|
---|
221 | return iemRaiseUndefinedOpcode(pVCpu); \
|
---|
222 | } while (0)
|
---|
223 | #define IEM_MC_MAYBE_RAISE_PCLMUL_RELATED_XCPT() \
|
---|
224 | do { \
|
---|
225 | if ( (pVCpu->cpum.GstCtx.cr0 & X86_CR0_EM) \
|
---|
226 | || !(pVCpu->cpum.GstCtx.cr4 & X86_CR4_OSFXSR) \
|
---|
227 | || !IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fPclMul) \
|
---|
228 | return iemRaiseUndefinedOpcode(pVCpu); \
|
---|
229 | if (pVCpu->cpum.GstCtx.cr0 & X86_CR0_TS) \
|
---|
230 | return iemRaiseDeviceNotAvailable(pVCpu); \
|
---|
231 | } while (0)
|
---|
232 |
|
---|
233 |
|
---|
234 | #define IEM_MC_LOCAL(a_Type, a_Name) a_Type a_Name
|
---|
235 | #define IEM_MC_LOCAL_CONST(a_Type, a_Name, a_Value) a_Type const a_Name = (a_Value)
|
---|
236 | #define IEM_MC_REF_LOCAL(a_pRefArg, a_Local) (a_pRefArg) = &(a_Local)
|
---|
237 | #define IEM_MC_ARG(a_Type, a_Name, a_iArg) a_Type a_Name
|
---|
238 | #define IEM_MC_ARG_CONST(a_Type, a_Name, a_Value, a_iArg) a_Type const a_Name = (a_Value)
|
---|
239 | #define IEM_MC_ARG_LOCAL_REF(a_Type, a_Name, a_Local, a_iArg) a_Type const a_Name = &(a_Local)
|
---|
240 | #define IEM_MC_ARG_LOCAL_EFLAGS(a_pName, a_Name, a_iArg) \
|
---|
241 | uint32_t a_Name; \
|
---|
242 | uint32_t *a_pName = &a_Name
|
---|
243 | #define IEM_MC_COMMIT_EFLAGS(a_EFlags) \
|
---|
244 | do { pVCpu->cpum.GstCtx.eflags.u = (a_EFlags); Assert(pVCpu->cpum.GstCtx.eflags.u & X86_EFL_1); } while (0)
|
---|
245 |
|
---|
246 | #define IEM_MC_ASSIGN(a_VarOrArg, a_CVariableOrConst) (a_VarOrArg) = (a_CVariableOrConst)
|
---|
247 | #define IEM_MC_ASSIGN_TO_SMALLER IEM_MC_ASSIGN
|
---|
248 |
|
---|
249 | #define IEM_MC_FETCH_GREG_U8(a_u8Dst, a_iGReg) (a_u8Dst) = iemGRegFetchU8(pVCpu, (a_iGReg))
|
---|
250 | #define IEM_MC_FETCH_GREG_U8_ZX_U16(a_u16Dst, a_iGReg) (a_u16Dst) = iemGRegFetchU8(pVCpu, (a_iGReg))
|
---|
251 | #define IEM_MC_FETCH_GREG_U8_ZX_U32(a_u32Dst, a_iGReg) (a_u32Dst) = iemGRegFetchU8(pVCpu, (a_iGReg))
|
---|
252 | #define IEM_MC_FETCH_GREG_U8_ZX_U64(a_u64Dst, a_iGReg) (a_u64Dst) = iemGRegFetchU8(pVCpu, (a_iGReg))
|
---|
253 | #define IEM_MC_FETCH_GREG_U8_SX_U16(a_u16Dst, a_iGReg) (a_u16Dst) = (int8_t)iemGRegFetchU8(pVCpu, (a_iGReg))
|
---|
254 | #define IEM_MC_FETCH_GREG_U8_SX_U32(a_u32Dst, a_iGReg) (a_u32Dst) = (int8_t)iemGRegFetchU8(pVCpu, (a_iGReg))
|
---|
255 | #define IEM_MC_FETCH_GREG_U8_SX_U64(a_u64Dst, a_iGReg) (a_u64Dst) = (int8_t)iemGRegFetchU8(pVCpu, (a_iGReg))
|
---|
256 | #define IEM_MC_FETCH_GREG_U16(a_u16Dst, a_iGReg) (a_u16Dst) = iemGRegFetchU16(pVCpu, (a_iGReg))
|
---|
257 | #define IEM_MC_FETCH_GREG_U16_ZX_U32(a_u32Dst, a_iGReg) (a_u32Dst) = iemGRegFetchU16(pVCpu, (a_iGReg))
|
---|
258 | #define IEM_MC_FETCH_GREG_U16_ZX_U64(a_u64Dst, a_iGReg) (a_u64Dst) = iemGRegFetchU16(pVCpu, (a_iGReg))
|
---|
259 | #define IEM_MC_FETCH_GREG_U16_SX_U32(a_u32Dst, a_iGReg) (a_u32Dst) = (int16_t)iemGRegFetchU16(pVCpu, (a_iGReg))
|
---|
260 | #define IEM_MC_FETCH_GREG_U16_SX_U64(a_u64Dst, a_iGReg) (a_u64Dst) = (int16_t)iemGRegFetchU16(pVCpu, (a_iGReg))
|
---|
261 | #define IEM_MC_FETCH_GREG_U32(a_u32Dst, a_iGReg) (a_u32Dst) = iemGRegFetchU32(pVCpu, (a_iGReg))
|
---|
262 | #define IEM_MC_FETCH_GREG_U32_ZX_U64(a_u64Dst, a_iGReg) (a_u64Dst) = iemGRegFetchU32(pVCpu, (a_iGReg))
|
---|
263 | #define IEM_MC_FETCH_GREG_U32_SX_U64(a_u64Dst, a_iGReg) (a_u64Dst) = (int32_t)iemGRegFetchU32(pVCpu, (a_iGReg))
|
---|
264 | #define IEM_MC_FETCH_GREG_U64(a_u64Dst, a_iGReg) (a_u64Dst) = iemGRegFetchU64(pVCpu, (a_iGReg))
|
---|
265 | #define IEM_MC_FETCH_GREG_U64_ZX_U64 IEM_MC_FETCH_GREG_U64
|
---|
266 | #define IEM_MC_FETCH_SREG_U16(a_u16Dst, a_iSReg) do { \
|
---|
267 | IEM_CTX_IMPORT_NORET(pVCpu, CPUMCTX_EXTRN_SREG_FROM_IDX(a_iSReg)); \
|
---|
268 | (a_u16Dst) = iemSRegFetchU16(pVCpu, (a_iSReg)); \
|
---|
269 | } while (0)
|
---|
270 | #define IEM_MC_FETCH_SREG_ZX_U32(a_u32Dst, a_iSReg) do { \
|
---|
271 | IEM_CTX_IMPORT_NORET(pVCpu, CPUMCTX_EXTRN_SREG_FROM_IDX(a_iSReg)); \
|
---|
272 | (a_u32Dst) = iemSRegFetchU16(pVCpu, (a_iSReg)); \
|
---|
273 | } while (0)
|
---|
274 | #define IEM_MC_FETCH_SREG_ZX_U64(a_u64Dst, a_iSReg) do { \
|
---|
275 | IEM_CTX_IMPORT_NORET(pVCpu, CPUMCTX_EXTRN_SREG_FROM_IDX(a_iSReg)); \
|
---|
276 | (a_u64Dst) = iemSRegFetchU16(pVCpu, (a_iSReg)); \
|
---|
277 | } while (0)
|
---|
278 | /** @todo IEM_MC_FETCH_SREG_BASE_U64 & IEM_MC_FETCH_SREG_BASE_U32 probably aren't worth it... */
|
---|
279 | #define IEM_MC_FETCH_SREG_BASE_U64(a_u64Dst, a_iSReg) do { \
|
---|
280 | IEM_CTX_IMPORT_NORET(pVCpu, CPUMCTX_EXTRN_SREG_FROM_IDX(a_iSReg)); \
|
---|
281 | (a_u64Dst) = iemSRegBaseFetchU64(pVCpu, (a_iSReg)); \
|
---|
282 | } while (0)
|
---|
283 | #define IEM_MC_FETCH_SREG_BASE_U32(a_u32Dst, a_iSReg) do { \
|
---|
284 | IEM_CTX_IMPORT_NORET(pVCpu, CPUMCTX_EXTRN_SREG_FROM_IDX(a_iSReg)); \
|
---|
285 | (a_u32Dst) = iemSRegBaseFetchU64(pVCpu, (a_iSReg)); \
|
---|
286 | } while (0)
|
---|
287 | /** @note Not for IOPL or IF testing or modification. */
|
---|
288 | #define IEM_MC_FETCH_EFLAGS(a_EFlags) (a_EFlags) = pVCpu->cpum.GstCtx.eflags.u
|
---|
289 | #define IEM_MC_FETCH_EFLAGS_U8(a_EFlags) (a_EFlags) = (uint8_t)pVCpu->cpum.GstCtx.eflags.u
|
---|
290 | #define IEM_MC_FETCH_FSW(a_u16Fsw) (a_u16Fsw) = pVCpu->cpum.GstCtx.XState.x87.FSW
|
---|
291 | #define IEM_MC_FETCH_FCW(a_u16Fcw) (a_u16Fcw) = pVCpu->cpum.GstCtx.XState.x87.FCW
|
---|
292 |
|
---|
293 | #define IEM_MC_STORE_GREG_U8(a_iGReg, a_u8Value) *iemGRegRefU8( pVCpu, (a_iGReg)) = (a_u8Value)
|
---|
294 | #define IEM_MC_STORE_GREG_U16(a_iGReg, a_u16Value) *iemGRegRefU16(pVCpu, (a_iGReg)) = (a_u16Value)
|
---|
295 | #define IEM_MC_STORE_GREG_U32(a_iGReg, a_u32Value) *iemGRegRefU64(pVCpu, (a_iGReg)) = (uint32_t)(a_u32Value) /* clear high bits. */
|
---|
296 | #define IEM_MC_STORE_GREG_I32(a_iGReg, a_i32Value) *iemGRegRefI64(pVCpu, (a_iGReg)) = (int64_t)(a_i32Value) /* Sign extension. */
|
---|
297 | #define IEM_MC_STORE_GREG_U64(a_iGReg, a_u64Value) *iemGRegRefU64(pVCpu, (a_iGReg)) = (a_u64Value)
|
---|
298 | #define IEM_MC_STORE_GREG_I64(a_iGReg, a_i64Value) *iemGRegRefI64(pVCpu, (a_iGReg)) = (a_i64Value)
|
---|
299 | #define IEM_MC_STORE_GREG_U8_CONST IEM_MC_STORE_GREG_U8
|
---|
300 | #define IEM_MC_STORE_GREG_U16_CONST IEM_MC_STORE_GREG_U16
|
---|
301 | #define IEM_MC_STORE_GREG_U32_CONST IEM_MC_STORE_GREG_U32
|
---|
302 | #define IEM_MC_STORE_GREG_U64_CONST IEM_MC_STORE_GREG_U64
|
---|
303 | #define IEM_MC_CLEAR_HIGH_GREG_U64(a_iGReg) *iemGRegRefU64(pVCpu, (a_iGReg)) &= UINT32_MAX
|
---|
304 | #define IEM_MC_CLEAR_HIGH_GREG_U64_BY_REF(a_pu32Dst) do { (a_pu32Dst)[1] = 0; } while (0)
|
---|
305 | /** @todo IEM_MC_STORE_SREG_BASE_U64 & IEM_MC_STORE_SREG_BASE_U32 aren't worth it... */
|
---|
306 | #define IEM_MC_STORE_SREG_BASE_U64(a_iSReg, a_u64Value) do { \
|
---|
307 | IEM_CTX_IMPORT_NORET(pVCpu, CPUMCTX_EXTRN_SREG_FROM_IDX(a_iSReg)); \
|
---|
308 | *iemSRegBaseRefU64(pVCpu, (a_iSReg)) = (a_u64Value); \
|
---|
309 | } while (0)
|
---|
310 | #define IEM_MC_STORE_SREG_BASE_U32(a_iSReg, a_u32Value) do { \
|
---|
311 | IEM_CTX_IMPORT_NORET(pVCpu, CPUMCTX_EXTRN_SREG_FROM_IDX(a_iSReg)); \
|
---|
312 | *iemSRegBaseRefU64(pVCpu, (a_iSReg)) = (uint32_t)(a_u32Value); /* clear high bits. */ \
|
---|
313 | } while (0)
|
---|
314 | #define IEM_MC_STORE_FPUREG_R80_SRC_REF(a_iSt, a_pr80Src) \
|
---|
315 | do { pVCpu->cpum.GstCtx.XState.x87.aRegs[a_iSt].r80 = *(a_pr80Src); } while (0)
|
---|
316 |
|
---|
317 |
|
---|
318 | #define IEM_MC_REF_GREG_U8(a_pu8Dst, a_iGReg) (a_pu8Dst) = iemGRegRefU8( pVCpu, (a_iGReg))
|
---|
319 | #define IEM_MC_REF_GREG_U16(a_pu16Dst, a_iGReg) (a_pu16Dst) = iemGRegRefU16(pVCpu, (a_iGReg))
|
---|
320 | /** @todo User of IEM_MC_REF_GREG_U32 needs to clear the high bits on commit.
|
---|
321 | * Use IEM_MC_CLEAR_HIGH_GREG_U64_BY_REF! */
|
---|
322 | #define IEM_MC_REF_GREG_U32(a_pu32Dst, a_iGReg) (a_pu32Dst) = iemGRegRefU32(pVCpu, (a_iGReg))
|
---|
323 | #define IEM_MC_REF_GREG_I32(a_pi32Dst, a_iGReg) (a_pi32Dst) = (int32_t *)iemGRegRefU32(pVCpu, (a_iGReg))
|
---|
324 | #define IEM_MC_REF_GREG_I32_CONST(a_pi32Dst, a_iGReg) (a_pi32Dst) = (int32_t const *)iemGRegRefU32(pVCpu, (a_iGReg))
|
---|
325 | #define IEM_MC_REF_GREG_U64(a_pu64Dst, a_iGReg) (a_pu64Dst) = iemGRegRefU64(pVCpu, (a_iGReg))
|
---|
326 | #define IEM_MC_REF_GREG_I64(a_pi64Dst, a_iGReg) (a_pi64Dst) = (int64_t *)iemGRegRefU64(pVCpu, (a_iGReg))
|
---|
327 | #define IEM_MC_REF_GREG_I64_CONST(a_pi64Dst, a_iGReg) (a_pi64Dst) = (int64_t const *)iemGRegRefU64(pVCpu, (a_iGReg))
|
---|
328 | /** @note Not for IOPL or IF testing or modification. */
|
---|
329 | #define IEM_MC_REF_EFLAGS(a_pEFlags) (a_pEFlags) = &pVCpu->cpum.GstCtx.eflags.u
|
---|
330 | #define IEM_MC_REF_MXCSR(a_pfMxcsr) (a_pfMxcsr) = &pVCpu->cpum.GstCtx.XState.x87.MXCSR
|
---|
331 |
|
---|
332 | #define IEM_MC_ADD_GREG_U8(a_iGReg, a_u8Value) *iemGRegRefU8( pVCpu, (a_iGReg)) += (a_u8Value)
|
---|
333 | #define IEM_MC_ADD_GREG_U16(a_iGReg, a_u16Value) *iemGRegRefU16(pVCpu, (a_iGReg)) += (a_u16Value)
|
---|
334 | #define IEM_MC_ADD_GREG_U32(a_iGReg, a_u32Value) \
|
---|
335 | do { \
|
---|
336 | uint32_t *pu32Reg = iemGRegRefU32(pVCpu, (a_iGReg)); \
|
---|
337 | *pu32Reg += (a_u32Value); \
|
---|
338 | pu32Reg[1] = 0; /* implicitly clear the high bit. */ \
|
---|
339 | } while (0)
|
---|
340 | #define IEM_MC_ADD_GREG_U64(a_iGReg, a_u64Value) *iemGRegRefU64(pVCpu, (a_iGReg)) += (a_u64Value)
|
---|
341 |
|
---|
342 | #define IEM_MC_SUB_GREG_U8(a_iGReg, a_u8Value) *iemGRegRefU8( pVCpu, (a_iGReg)) -= (a_u8Value)
|
---|
343 | #define IEM_MC_SUB_GREG_U16(a_iGReg, a_u16Value) *iemGRegRefU16(pVCpu, (a_iGReg)) -= (a_u16Value)
|
---|
344 | #define IEM_MC_SUB_GREG_U32(a_iGReg, a_u32Value) \
|
---|
345 | do { \
|
---|
346 | uint32_t *pu32Reg = iemGRegRefU32(pVCpu, (a_iGReg)); \
|
---|
347 | *pu32Reg -= (a_u32Value); \
|
---|
348 | pu32Reg[1] = 0; /* implicitly clear the high bit. */ \
|
---|
349 | } while (0)
|
---|
350 | #define IEM_MC_SUB_GREG_U64(a_iGReg, a_u64Value) *iemGRegRefU64(pVCpu, (a_iGReg)) -= (a_u64Value)
|
---|
351 | #define IEM_MC_SUB_LOCAL_U16(a_u16Value, a_u16Const) do { (a_u16Value) -= a_u16Const; } while (0)
|
---|
352 |
|
---|
353 | #define IEM_MC_ADD_GREG_U8_TO_LOCAL(a_u8Value, a_iGReg) do { (a_u8Value) += iemGRegFetchU8( pVCpu, (a_iGReg)); } while (0)
|
---|
354 | #define IEM_MC_ADD_GREG_U16_TO_LOCAL(a_u16Value, a_iGReg) do { (a_u16Value) += iemGRegFetchU16(pVCpu, (a_iGReg)); } while (0)
|
---|
355 | #define IEM_MC_ADD_GREG_U32_TO_LOCAL(a_u32Value, a_iGReg) do { (a_u32Value) += iemGRegFetchU32(pVCpu, (a_iGReg)); } while (0)
|
---|
356 | #define IEM_MC_ADD_GREG_U64_TO_LOCAL(a_u64Value, a_iGReg) do { (a_u64Value) += iemGRegFetchU64(pVCpu, (a_iGReg)); } while (0)
|
---|
357 | #define IEM_MC_ADD_LOCAL_S16_TO_EFF_ADDR(a_EffAddr, a_i16) do { (a_EffAddr) += (a_i16); } while (0)
|
---|
358 | #define IEM_MC_ADD_LOCAL_S32_TO_EFF_ADDR(a_EffAddr, a_i32) do { (a_EffAddr) += (a_i32); } while (0)
|
---|
359 | #define IEM_MC_ADD_LOCAL_S64_TO_EFF_ADDR(a_EffAddr, a_i64) do { (a_EffAddr) += (a_i64); } while (0)
|
---|
360 |
|
---|
361 | #define IEM_MC_AND_LOCAL_U8(a_u8Local, a_u8Mask) do { (a_u8Local) &= (a_u8Mask); } while (0)
|
---|
362 | #define IEM_MC_AND_LOCAL_U16(a_u16Local, a_u16Mask) do { (a_u16Local) &= (a_u16Mask); } while (0)
|
---|
363 | #define IEM_MC_AND_LOCAL_U32(a_u32Local, a_u32Mask) do { (a_u32Local) &= (a_u32Mask); } while (0)
|
---|
364 | #define IEM_MC_AND_LOCAL_U64(a_u64Local, a_u64Mask) do { (a_u64Local) &= (a_u64Mask); } while (0)
|
---|
365 |
|
---|
366 | #define IEM_MC_AND_ARG_U16(a_u16Arg, a_u16Mask) do { (a_u16Arg) &= (a_u16Mask); } while (0)
|
---|
367 | #define IEM_MC_AND_ARG_U32(a_u32Arg, a_u32Mask) do { (a_u32Arg) &= (a_u32Mask); } while (0)
|
---|
368 | #define IEM_MC_AND_ARG_U64(a_u64Arg, a_u64Mask) do { (a_u64Arg) &= (a_u64Mask); } while (0)
|
---|
369 |
|
---|
370 | #define IEM_MC_OR_LOCAL_U8(a_u8Local, a_u8Mask) do { (a_u8Local) |= (a_u8Mask); } while (0)
|
---|
371 | #define IEM_MC_OR_LOCAL_U16(a_u16Local, a_u16Mask) do { (a_u16Local) |= (a_u16Mask); } while (0)
|
---|
372 | #define IEM_MC_OR_LOCAL_U32(a_u32Local, a_u32Mask) do { (a_u32Local) |= (a_u32Mask); } while (0)
|
---|
373 |
|
---|
374 | #define IEM_MC_SAR_LOCAL_S16(a_i16Local, a_cShift) do { (a_i16Local) >>= (a_cShift); } while (0)
|
---|
375 | #define IEM_MC_SAR_LOCAL_S32(a_i32Local, a_cShift) do { (a_i32Local) >>= (a_cShift); } while (0)
|
---|
376 | #define IEM_MC_SAR_LOCAL_S64(a_i64Local, a_cShift) do { (a_i64Local) >>= (a_cShift); } while (0)
|
---|
377 |
|
---|
378 | #define IEM_MC_SHL_LOCAL_S16(a_i16Local, a_cShift) do { (a_i16Local) <<= (a_cShift); } while (0)
|
---|
379 | #define IEM_MC_SHL_LOCAL_S32(a_i32Local, a_cShift) do { (a_i32Local) <<= (a_cShift); } while (0)
|
---|
380 | #define IEM_MC_SHL_LOCAL_S64(a_i64Local, a_cShift) do { (a_i64Local) <<= (a_cShift); } while (0)
|
---|
381 |
|
---|
382 | #define IEM_MC_AND_2LOCS_U32(a_u32Local, a_u32Mask) do { (a_u32Local) &= (a_u32Mask); } while (0)
|
---|
383 |
|
---|
384 | #define IEM_MC_OR_2LOCS_U32(a_u32Local, a_u32Mask) do { (a_u32Local) |= (a_u32Mask); } while (0)
|
---|
385 |
|
---|
386 | #define IEM_MC_AND_GREG_U8(a_iGReg, a_u8Value) *iemGRegRefU8( pVCpu, (a_iGReg)) &= (a_u8Value)
|
---|
387 | #define IEM_MC_AND_GREG_U16(a_iGReg, a_u16Value) *iemGRegRefU16(pVCpu, (a_iGReg)) &= (a_u16Value)
|
---|
388 | #define IEM_MC_AND_GREG_U32(a_iGReg, a_u32Value) \
|
---|
389 | do { \
|
---|
390 | uint32_t *pu32Reg = iemGRegRefU32(pVCpu, (a_iGReg)); \
|
---|
391 | *pu32Reg &= (a_u32Value); \
|
---|
392 | pu32Reg[1] = 0; /* implicitly clear the high bit. */ \
|
---|
393 | } while (0)
|
---|
394 | #define IEM_MC_AND_GREG_U64(a_iGReg, a_u64Value) *iemGRegRefU64(pVCpu, (a_iGReg)) &= (a_u64Value)
|
---|
395 |
|
---|
396 | #define IEM_MC_OR_GREG_U8(a_iGReg, a_u8Value) *iemGRegRefU8( pVCpu, (a_iGReg)) |= (a_u8Value)
|
---|
397 | #define IEM_MC_OR_GREG_U16(a_iGReg, a_u16Value) *iemGRegRefU16(pVCpu, (a_iGReg)) |= (a_u16Value)
|
---|
398 | #define IEM_MC_OR_GREG_U32(a_iGReg, a_u32Value) \
|
---|
399 | do { \
|
---|
400 | uint32_t *pu32Reg = iemGRegRefU32(pVCpu, (a_iGReg)); \
|
---|
401 | *pu32Reg |= (a_u32Value); \
|
---|
402 | pu32Reg[1] = 0; /* implicitly clear the high bit. */ \
|
---|
403 | } while (0)
|
---|
404 | #define IEM_MC_OR_GREG_U64(a_iGReg, a_u64Value) *iemGRegRefU64(pVCpu, (a_iGReg)) |= (a_u64Value)
|
---|
405 |
|
---|
406 |
|
---|
407 | /** @note Not for IOPL or IF modification. */
|
---|
408 | #define IEM_MC_SET_EFL_BIT(a_fBit) do { pVCpu->cpum.GstCtx.eflags.u |= (a_fBit); } while (0)
|
---|
409 | /** @note Not for IOPL or IF modification. */
|
---|
410 | #define IEM_MC_CLEAR_EFL_BIT(a_fBit) do { pVCpu->cpum.GstCtx.eflags.u &= ~(a_fBit); } while (0)
|
---|
411 | /** @note Not for IOPL or IF modification. */
|
---|
412 | #define IEM_MC_FLIP_EFL_BIT(a_fBit) do { pVCpu->cpum.GstCtx.eflags.u ^= (a_fBit); } while (0)
|
---|
413 |
|
---|
414 | #define IEM_MC_CLEAR_FSW_EX() do { pVCpu->cpum.GstCtx.XState.x87.FSW &= X86_FSW_C_MASK | X86_FSW_TOP_MASK; } while (0)
|
---|
415 |
|
---|
416 | /** Switches the FPU state to MMX mode (FSW.TOS=0, FTW=0) if necessary. */
|
---|
417 | #define IEM_MC_FPU_TO_MMX_MODE() do { \
|
---|
418 | pVCpu->cpum.GstCtx.XState.x87.FSW &= ~X86_FSW_TOP_MASK; \
|
---|
419 | pVCpu->cpum.GstCtx.XState.x87.FTW = 0xff; \
|
---|
420 | } while (0)
|
---|
421 |
|
---|
422 | /** Switches the FPU state from MMX mode (FTW=0xffff). */
|
---|
423 | #define IEM_MC_FPU_FROM_MMX_MODE() do { \
|
---|
424 | pVCpu->cpum.GstCtx.XState.x87.FTW = 0; \
|
---|
425 | } while (0)
|
---|
426 |
|
---|
427 | #define IEM_MC_FETCH_MREG_U64(a_u64Value, a_iMReg) \
|
---|
428 | do { (a_u64Value) = pVCpu->cpum.GstCtx.XState.x87.aRegs[(a_iMReg)].mmx; } while (0)
|
---|
429 | #define IEM_MC_FETCH_MREG_U32(a_u32Value, a_iMReg) \
|
---|
430 | do { (a_u32Value) = pVCpu->cpum.GstCtx.XState.x87.aRegs[(a_iMReg)].au32[0]; } while (0)
|
---|
431 | #define IEM_MC_STORE_MREG_U64(a_iMReg, a_u64Value) do { \
|
---|
432 | pVCpu->cpum.GstCtx.XState.x87.aRegs[(a_iMReg)].mmx = (a_u64Value); \
|
---|
433 | pVCpu->cpum.GstCtx.XState.x87.aRegs[(a_iMReg)].au32[2] = 0xffff; \
|
---|
434 | } while (0)
|
---|
435 | #define IEM_MC_STORE_MREG_U32_ZX_U64(a_iMReg, a_u32Value) do { \
|
---|
436 | pVCpu->cpum.GstCtx.XState.x87.aRegs[(a_iMReg)].mmx = (uint32_t)(a_u32Value); \
|
---|
437 | pVCpu->cpum.GstCtx.XState.x87.aRegs[(a_iMReg)].au32[2] = 0xffff; \
|
---|
438 | } while (0)
|
---|
439 | #define IEM_MC_REF_MREG_U64(a_pu64Dst, a_iMReg) /** @todo need to set high word to 0xffff on commit (see IEM_MC_STORE_MREG_U64) */ \
|
---|
440 | (a_pu64Dst) = (&pVCpu->cpum.GstCtx.XState.x87.aRegs[(a_iMReg)].mmx)
|
---|
441 | #define IEM_MC_REF_MREG_U64_CONST(a_pu64Dst, a_iMReg) \
|
---|
442 | (a_pu64Dst) = ((uint64_t const *)&pVCpu->cpum.GstCtx.XState.x87.aRegs[(a_iMReg)].mmx)
|
---|
443 | #define IEM_MC_REF_MREG_U32_CONST(a_pu32Dst, a_iMReg) \
|
---|
444 | (a_pu32Dst) = ((uint32_t const *)&pVCpu->cpum.GstCtx.XState.x87.aRegs[(a_iMReg)].mmx)
|
---|
445 | #define IEM_MC_MODIFIED_MREG(a_iMReg) \
|
---|
446 | do { pVCpu->cpum.GstCtx.XState.x87.aRegs[(a_iMReg)].au32[2] = 0xffff; } while (0)
|
---|
447 | #define IEM_MC_MODIFIED_MREG_BY_REF(a_pu64Dst) \
|
---|
448 | do { ((uint32_t *)(a_pu64Dst))[2] = 0xffff; } while (0)
|
---|
449 |
|
---|
450 | #define IEM_MC_FETCH_XREG_U128(a_u128Value, a_iXReg) \
|
---|
451 | do { (a_u128Value).au64[0] = pVCpu->cpum.GstCtx.XState.x87.aXMM[(a_iXReg)].au64[0]; \
|
---|
452 | (a_u128Value).au64[1] = pVCpu->cpum.GstCtx.XState.x87.aXMM[(a_iXReg)].au64[1]; \
|
---|
453 | } while (0)
|
---|
454 | #define IEM_MC_FETCH_XREG_XMM(a_XmmValue, a_iXReg) \
|
---|
455 | do { (a_XmmValue).au64[0] = pVCpu->cpum.GstCtx.XState.x87.aXMM[(a_iXReg)].au64[0]; \
|
---|
456 | (a_XmmValue).au64[1] = pVCpu->cpum.GstCtx.XState.x87.aXMM[(a_iXReg)].au64[1]; \
|
---|
457 | } while (0)
|
---|
458 | #define IEM_MC_FETCH_XREG_U64(a_u64Value, a_iXReg) \
|
---|
459 | do { (a_u64Value) = pVCpu->cpum.GstCtx.XState.x87.aXMM[(a_iXReg)].au64[0]; } while (0)
|
---|
460 | #define IEM_MC_FETCH_XREG_U32(a_u32Value, a_iXReg) \
|
---|
461 | do { (a_u32Value) = pVCpu->cpum.GstCtx.XState.x87.aXMM[(a_iXReg)].au32[0]; } while (0)
|
---|
462 | #define IEM_MC_FETCH_XREG_HI_U64(a_u64Value, a_iXReg) \
|
---|
463 | do { (a_u64Value) = pVCpu->cpum.GstCtx.XState.x87.aXMM[(a_iXReg)].au64[1]; } while (0)
|
---|
464 | #define IEM_MC_STORE_XREG_U128(a_iXReg, a_u128Value) \
|
---|
465 | do { pVCpu->cpum.GstCtx.XState.x87.aXMM[(a_iXReg)].au64[0] = (a_u128Value).au64[0]; \
|
---|
466 | pVCpu->cpum.GstCtx.XState.x87.aXMM[(a_iXReg)].au64[1] = (a_u128Value).au64[1]; \
|
---|
467 | } while (0)
|
---|
468 | #define IEM_MC_STORE_XREG_XMM(a_iXReg, a_XmmValue) \
|
---|
469 | do { pVCpu->cpum.GstCtx.XState.x87.aXMM[(a_iXReg)].au64[0] = (a_XmmValue).au64[0]; \
|
---|
470 | pVCpu->cpum.GstCtx.XState.x87.aXMM[(a_iXReg)].au64[1] = (a_XmmValue).au64[1]; \
|
---|
471 | } while (0)
|
---|
472 | #define IEM_MC_STORE_XREG_XMM_U32(a_iXReg, a_iDword, a_XmmValue) \
|
---|
473 | do { pVCpu->cpum.GstCtx.XState.x87.aXMM[(a_iXReg)].au32[(a_iDword)] = (a_XmmValue).au32[(a_iDword)]; } while (0)
|
---|
474 | #define IEM_MC_STORE_XREG_XMM_U64(a_iXReg, a_iQword, a_XmmValue) \
|
---|
475 | do { pVCpu->cpum.GstCtx.XState.x87.aXMM[(a_iXReg)].au64[(a_iQword)] = (a_XmmValue).au64[(a_iQword)]; } while (0)
|
---|
476 | #define IEM_MC_STORE_XREG_U64(a_iXReg, a_u64Value) \
|
---|
477 | do { pVCpu->cpum.GstCtx.XState.x87.aXMM[(a_iXReg)].au64[0] = (a_u64Value); } while (0)
|
---|
478 | #define IEM_MC_STORE_XREG_U64_ZX_U128(a_iXReg, a_u64Value) \
|
---|
479 | do { pVCpu->cpum.GstCtx.XState.x87.aXMM[(a_iXReg)].au64[0] = (a_u64Value); \
|
---|
480 | pVCpu->cpum.GstCtx.XState.x87.aXMM[(a_iXReg)].au64[1] = 0; \
|
---|
481 | } while (0)
|
---|
482 | #define IEM_MC_STORE_XREG_U32(a_iXReg, a_u32Value) \
|
---|
483 | do { pVCpu->cpum.GstCtx.XState.x87.aXMM[(a_iXReg)].au32[0] = (a_u32Value); } while (0)
|
---|
484 | #define IEM_MC_STORE_XREG_R32(a_iXReg, a_r32Value) \
|
---|
485 | do { pVCpu->cpum.GstCtx.XState.x87.aXMM[(a_iXReg)].ar32[0] = (a_r32Value); } while (0)
|
---|
486 | #define IEM_MC_STORE_XREG_R64(a_iXReg, a_r64Value) \
|
---|
487 | do { pVCpu->cpum.GstCtx.XState.x87.aXMM[(a_iXReg)].ar64[0] = (a_r64Value); } while (0)
|
---|
488 | #define IEM_MC_STORE_XREG_U32_ZX_U128(a_iXReg, a_u32Value) \
|
---|
489 | do { pVCpu->cpum.GstCtx.XState.x87.aXMM[(a_iXReg)].au64[0] = (uint32_t)(a_u32Value); \
|
---|
490 | pVCpu->cpum.GstCtx.XState.x87.aXMM[(a_iXReg)].au64[1] = 0; \
|
---|
491 | } while (0)
|
---|
492 | #define IEM_MC_STORE_XREG_HI_U64(a_iXReg, a_u64Value) \
|
---|
493 | do { pVCpu->cpum.GstCtx.XState.x87.aXMM[(a_iXReg)].au64[1] = (a_u64Value); } while (0)
|
---|
494 | #define IEM_MC_REF_XREG_U128(a_pu128Dst, a_iXReg) \
|
---|
495 | (a_pu128Dst) = (&pVCpu->cpum.GstCtx.XState.x87.aXMM[(a_iXReg)].uXmm)
|
---|
496 | #define IEM_MC_REF_XREG_U128_CONST(a_pu128Dst, a_iXReg) \
|
---|
497 | (a_pu128Dst) = ((PCRTUINT128U)&pVCpu->cpum.GstCtx.XState.x87.aXMM[(a_iXReg)].uXmm)
|
---|
498 | #define IEM_MC_REF_XREG_XMM_CONST(a_pXmmDst, a_iXReg) \
|
---|
499 | (a_pXmmDst) = (&pVCpu->cpum.GstCtx.XState.x87.aXMM[(a_iXReg)])
|
---|
500 | #define IEM_MC_REF_XREG_U32_CONST(a_pu32Dst, a_iXReg) \
|
---|
501 | (a_pu32Dst) = ((uint32_t const *)&pVCpu->cpum.GstCtx.XState.x87.aXMM[(a_iXReg)].au32[0])
|
---|
502 | #define IEM_MC_REF_XREG_U64_CONST(a_pu64Dst, a_iXReg) \
|
---|
503 | (a_pu64Dst) = ((uint64_t const *)&pVCpu->cpum.GstCtx.XState.x87.aXMM[(a_iXReg)].au64[0])
|
---|
504 | #define IEM_MC_REF_XREG_R32_CONST(a_pr32Dst, a_iXReg) \
|
---|
505 | (a_pr32Dst) = ((RTFLOAT32U const *)&pVCpu->cpum.GstCtx.XState.x87.aXMM[(a_iXReg)].ar32[0])
|
---|
506 | #define IEM_MC_REF_XREG_R64_CONST(a_pr64Dst, a_iXReg) \
|
---|
507 | (a_pr64Dst) = ((RTFLOAT64U const *)&pVCpu->cpum.GstCtx.XState.x87.aXMM[(a_iXReg)].ar64[0])
|
---|
508 | #define IEM_MC_COPY_XREG_U128(a_iXRegDst, a_iXRegSrc) \
|
---|
509 | do { pVCpu->cpum.GstCtx.XState.x87.aXMM[(a_iXRegDst)].au64[0] \
|
---|
510 | = pVCpu->cpum.GstCtx.XState.x87.aXMM[(a_iXRegSrc)].au64[0]; \
|
---|
511 | pVCpu->cpum.GstCtx.XState.x87.aXMM[(a_iXRegDst)].au64[1] \
|
---|
512 | = pVCpu->cpum.GstCtx.XState.x87.aXMM[(a_iXRegSrc)].au64[1]; \
|
---|
513 | } while (0)
|
---|
514 |
|
---|
515 | #define IEM_MC_FETCH_YREG_U32(a_u32Dst, a_iYRegSrc) \
|
---|
516 | do { uintptr_t const iYRegSrcTmp = (a_iYRegSrc); \
|
---|
517 | (a_u32Dst) = pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegSrcTmp].au32[0]; \
|
---|
518 | } while (0)
|
---|
519 | #define IEM_MC_FETCH_YREG_U64(a_u64Dst, a_iYRegSrc) \
|
---|
520 | do { uintptr_t const iYRegSrcTmp = (a_iYRegSrc); \
|
---|
521 | (a_u64Dst) = pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegSrcTmp].au64[0]; \
|
---|
522 | } while (0)
|
---|
523 | #define IEM_MC_FETCH_YREG_2ND_U64(a_u64Dst, a_iYRegSrc) \
|
---|
524 | do { uintptr_t const iYRegSrcTmp = (a_iYRegSrc); \
|
---|
525 | (a_u64Dst) = pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegSrcTmp].au64[1]; \
|
---|
526 | } while (0)
|
---|
527 | #define IEM_MC_FETCH_YREG_U128(a_u128Dst, a_iYRegSrc) \
|
---|
528 | do { uintptr_t const iYRegSrcTmp = (a_iYRegSrc); \
|
---|
529 | (a_u128Dst).au64[0] = pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegSrcTmp].au64[0]; \
|
---|
530 | (a_u128Dst).au64[1] = pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegSrcTmp].au64[1]; \
|
---|
531 | } while (0)
|
---|
532 | #define IEM_MC_FETCH_YREG_U256(a_u256Dst, a_iYRegSrc) \
|
---|
533 | do { uintptr_t const iYRegSrcTmp = (a_iYRegSrc); \
|
---|
534 | (a_u256Dst).au64[0] = pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegSrcTmp].au64[0]; \
|
---|
535 | (a_u256Dst).au64[1] = pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegSrcTmp].au64[1]; \
|
---|
536 | (a_u256Dst).au64[2] = pVCpu->cpum.GstCtx.XState.u.YmmHi.aYmmHi[iYRegSrcTmp].au64[0]; \
|
---|
537 | (a_u256Dst).au64[3] = pVCpu->cpum.GstCtx.XState.u.YmmHi.aYmmHi[iYRegSrcTmp].au64[1]; \
|
---|
538 | } while (0)
|
---|
539 |
|
---|
540 | #define IEM_MC_INT_CLEAR_ZMM_256_UP(a_iXRegDst) do { /* For AVX512 and AVX1024 support. */ } while (0)
|
---|
541 | #define IEM_MC_STORE_YREG_U32_ZX_VLMAX(a_iYRegDst, a_u32Src) \
|
---|
542 | do { uintptr_t const iYRegDstTmp = (a_iYRegDst); \
|
---|
543 | pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegDstTmp].au32[0] = (a_u32Src); \
|
---|
544 | pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegDstTmp].au32[1] = 0; \
|
---|
545 | pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegDstTmp].au64[1] = 0; \
|
---|
546 | pVCpu->cpum.GstCtx.XState.u.YmmHi.aYmmHi[iYRegDstTmp].au64[0] = 0; \
|
---|
547 | pVCpu->cpum.GstCtx.XState.u.YmmHi.aYmmHi[iYRegDstTmp].au64[1] = 0; \
|
---|
548 | IEM_MC_INT_CLEAR_ZMM_256_UP(iYRegDstTmp); \
|
---|
549 | } while (0)
|
---|
550 | #define IEM_MC_STORE_YREG_U64_ZX_VLMAX(a_iYRegDst, a_u64Src) \
|
---|
551 | do { uintptr_t const iYRegDstTmp = (a_iYRegDst); \
|
---|
552 | pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegDstTmp].au64[0] = (a_u64Src); \
|
---|
553 | pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegDstTmp].au64[1] = 0; \
|
---|
554 | pVCpu->cpum.GstCtx.XState.u.YmmHi.aYmmHi[iYRegDstTmp].au64[0] = 0; \
|
---|
555 | pVCpu->cpum.GstCtx.XState.u.YmmHi.aYmmHi[iYRegDstTmp].au64[1] = 0; \
|
---|
556 | IEM_MC_INT_CLEAR_ZMM_256_UP(iYRegDstTmp); \
|
---|
557 | } while (0)
|
---|
558 | #define IEM_MC_STORE_YREG_U128_ZX_VLMAX(a_iYRegDst, a_u128Src) \
|
---|
559 | do { uintptr_t const iYRegDstTmp = (a_iYRegDst); \
|
---|
560 | pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegDstTmp].au64[0] = (a_u128Src).au64[0]; \
|
---|
561 | pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegDstTmp].au64[1] = (a_u128Src).au64[1]; \
|
---|
562 | pVCpu->cpum.GstCtx.XState.u.YmmHi.aYmmHi[iYRegDstTmp].au64[0] = 0; \
|
---|
563 | pVCpu->cpum.GstCtx.XState.u.YmmHi.aYmmHi[iYRegDstTmp].au64[1] = 0; \
|
---|
564 | IEM_MC_INT_CLEAR_ZMM_256_UP(iYRegDstTmp); \
|
---|
565 | } while (0)
|
---|
566 | #define IEM_MC_STORE_YREG_U256_ZX_VLMAX(a_iYRegDst, a_u256Src) \
|
---|
567 | do { uintptr_t const iYRegDstTmp = (a_iYRegDst); \
|
---|
568 | pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegDstTmp].au64[0] = (a_u256Src).au64[0]; \
|
---|
569 | pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegDstTmp].au64[1] = (a_u256Src).au64[1]; \
|
---|
570 | pVCpu->cpum.GstCtx.XState.u.YmmHi.aYmmHi[iYRegDstTmp].au64[0] = (a_u256Src).au64[2]; \
|
---|
571 | pVCpu->cpum.GstCtx.XState.u.YmmHi.aYmmHi[iYRegDstTmp].au64[1] = (a_u256Src).au64[3]; \
|
---|
572 | IEM_MC_INT_CLEAR_ZMM_256_UP(iYRegDstTmp); \
|
---|
573 | } while (0)
|
---|
574 |
|
---|
575 | #define IEM_MC_REF_YREG_U128(a_pu128Dst, a_iYReg) \
|
---|
576 | (a_pu128Dst) = (&pVCpu->cpum.GstCtx.XState.x87.aYMM[(a_iYReg)].uXmm)
|
---|
577 | #define IEM_MC_REF_YREG_U128_CONST(a_pu128Dst, a_iYReg) \
|
---|
578 | (a_pu128Dst) = ((PCRTUINT128U)&pVCpu->cpum.GstCtx.XState.x87.aYMM[(a_iYReg)].uXmm)
|
---|
579 | #define IEM_MC_REF_YREG_U64_CONST(a_pu64Dst, a_iYReg) \
|
---|
580 | (a_pu64Dst) = ((uint64_t const *)&pVCpu->cpum.GstCtx.XState.x87.aYMM[(a_iYReg)].au64[0])
|
---|
581 | #define IEM_MC_CLEAR_YREG_128_UP(a_iYReg) \
|
---|
582 | do { uintptr_t const iYRegTmp = (a_iYReg); \
|
---|
583 | pVCpu->cpum.GstCtx.XState.u.YmmHi.aYmmHi[iYRegTmp].au64[0] = 0; \
|
---|
584 | pVCpu->cpum.GstCtx.XState.u.YmmHi.aYmmHi[iYRegTmp].au64[1] = 0; \
|
---|
585 | IEM_MC_INT_CLEAR_ZMM_256_UP(iYRegTmp); \
|
---|
586 | } while (0)
|
---|
587 |
|
---|
588 | #define IEM_MC_COPY_YREG_U256_ZX_VLMAX(a_iYRegDst, a_iYRegSrc) \
|
---|
589 | do { uintptr_t const iYRegDstTmp = (a_iYRegDst); \
|
---|
590 | uintptr_t const iYRegSrcTmp = (a_iYRegSrc); \
|
---|
591 | pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegDstTmp].au64[0] = pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegSrcTmp].au64[0]; \
|
---|
592 | pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegDstTmp].au64[1] = pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegSrcTmp].au64[1]; \
|
---|
593 | pVCpu->cpum.GstCtx.XState.u.YmmHi.aYmmHi[iYRegDstTmp].au64[0] = pVCpu->cpum.GstCtx.XState.u.YmmHi.aYmmHi[iYRegSrcTmp].au64[0]; \
|
---|
594 | pVCpu->cpum.GstCtx.XState.u.YmmHi.aYmmHi[iYRegDstTmp].au64[1] = pVCpu->cpum.GstCtx.XState.u.YmmHi.aYmmHi[iYRegSrcTmp].au64[1]; \
|
---|
595 | IEM_MC_INT_CLEAR_ZMM_256_UP(iYRegDstTmp); \
|
---|
596 | } while (0)
|
---|
597 | #define IEM_MC_COPY_YREG_U128_ZX_VLMAX(a_iYRegDst, a_iYRegSrc) \
|
---|
598 | do { uintptr_t const iYRegDstTmp = (a_iYRegDst); \
|
---|
599 | uintptr_t const iYRegSrcTmp = (a_iYRegSrc); \
|
---|
600 | pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegDstTmp].au64[0] = pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegSrcTmp].au64[0]; \
|
---|
601 | pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegDstTmp].au64[1] = pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegSrcTmp].au64[1]; \
|
---|
602 | pVCpu->cpum.GstCtx.XState.u.YmmHi.aYmmHi[iYRegDstTmp].au64[0] = 0; \
|
---|
603 | pVCpu->cpum.GstCtx.XState.u.YmmHi.aYmmHi[iYRegDstTmp].au64[1] = 0; \
|
---|
604 | IEM_MC_INT_CLEAR_ZMM_256_UP(iYRegDstTmp); \
|
---|
605 | } while (0)
|
---|
606 | #define IEM_MC_COPY_YREG_U64_ZX_VLMAX(a_iYRegDst, a_iYRegSrc) \
|
---|
607 | do { uintptr_t const iYRegDstTmp = (a_iYRegDst); \
|
---|
608 | uintptr_t const iYRegSrcTmp = (a_iYRegSrc); \
|
---|
609 | pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegDstTmp].au64[0] = pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegSrcTmp].au64[0]; \
|
---|
610 | pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegDstTmp].au64[1] = 0; \
|
---|
611 | pVCpu->cpum.GstCtx.XState.u.YmmHi.aYmmHi[iYRegDstTmp].au64[0] = 0; \
|
---|
612 | pVCpu->cpum.GstCtx.XState.u.YmmHi.aYmmHi[iYRegDstTmp].au64[1] = 0; \
|
---|
613 | IEM_MC_INT_CLEAR_ZMM_256_UP(iYRegDstTmp); \
|
---|
614 | } while (0)
|
---|
615 |
|
---|
616 | #define IEM_MC_MERGE_YREG_U32_U96_ZX_VLMAX(a_iYRegDst, a_iYRegSrc32, a_iYRegSrcHx) \
|
---|
617 | do { uintptr_t const iYRegDstTmp = (a_iYRegDst); \
|
---|
618 | uintptr_t const iYRegSrc32Tmp = (a_iYRegSrc32); \
|
---|
619 | uintptr_t const iYRegSrcHxTmp = (a_iYRegSrcHx); \
|
---|
620 | pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegDstTmp].au32[0] = pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegSrc32Tmp].au32[0]; \
|
---|
621 | pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegDstTmp].au32[1] = pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegSrcHxTmp].au32[1]; \
|
---|
622 | pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegDstTmp].au64[1] = pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegSrcHxTmp].au64[1]; \
|
---|
623 | pVCpu->cpum.GstCtx.XState.u.YmmHi.aYmmHi[iYRegDstTmp].au64[0] = 0; \
|
---|
624 | pVCpu->cpum.GstCtx.XState.u.YmmHi.aYmmHi[iYRegDstTmp].au64[1] = 0; \
|
---|
625 | IEM_MC_INT_CLEAR_ZMM_256_UP(iYRegDstTmp); \
|
---|
626 | } while (0)
|
---|
627 | #define IEM_MC_MERGE_YREG_U64_U64_ZX_VLMAX(a_iYRegDst, a_iYRegSrc64, a_iYRegSrcHx) \
|
---|
628 | do { uintptr_t const iYRegDstTmp = (a_iYRegDst); \
|
---|
629 | uintptr_t const iYRegSrc64Tmp = (a_iYRegSrc64); \
|
---|
630 | uintptr_t const iYRegSrcHxTmp = (a_iYRegSrcHx); \
|
---|
631 | pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegDstTmp].au64[0] = pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegSrc64Tmp].au64[0]; \
|
---|
632 | pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegDstTmp].au64[1] = pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegSrcHxTmp].au64[1]; \
|
---|
633 | pVCpu->cpum.GstCtx.XState.u.YmmHi.aYmmHi[iYRegDstTmp].au64[0] = 0; \
|
---|
634 | pVCpu->cpum.GstCtx.XState.u.YmmHi.aYmmHi[iYRegDstTmp].au64[1] = 0; \
|
---|
635 | IEM_MC_INT_CLEAR_ZMM_256_UP(iYRegDstTmp); \
|
---|
636 | } while (0)
|
---|
637 | #define IEM_MC_MERGE_YREG_U64LO_U64LO_ZX_VLMAX(a_iYRegDst, a_iYRegSrc64, a_iYRegSrcHx) /* for vmovhlps */ \
|
---|
638 | do { uintptr_t const iYRegDstTmp = (a_iYRegDst); \
|
---|
639 | uintptr_t const iYRegSrc64Tmp = (a_iYRegSrc64); \
|
---|
640 | uintptr_t const iYRegSrcHxTmp = (a_iYRegSrcHx); \
|
---|
641 | pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegDstTmp].au64[0] = pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegSrc64Tmp].au64[0]; \
|
---|
642 | pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegDstTmp].au64[1] = pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegSrcHxTmp].au64[0]; \
|
---|
643 | pVCpu->cpum.GstCtx.XState.u.YmmHi.aYmmHi[iYRegDstTmp].au64[0] = 0; \
|
---|
644 | pVCpu->cpum.GstCtx.XState.u.YmmHi.aYmmHi[iYRegDstTmp].au64[1] = 0; \
|
---|
645 | IEM_MC_INT_CLEAR_ZMM_256_UP(iYRegDstTmp); \
|
---|
646 | } while (0)
|
---|
647 | #define IEM_MC_MERGE_YREG_U64HI_U64HI_ZX_VLMAX(a_iYRegDst, a_iYRegSrc64, a_iYRegSrcHx) /* for vmovhlps */ \
|
---|
648 | do { uintptr_t const iYRegDstTmp = (a_iYRegDst); \
|
---|
649 | uintptr_t const iYRegSrc64Tmp = (a_iYRegSrc64); \
|
---|
650 | uintptr_t const iYRegSrcHxTmp = (a_iYRegSrcHx); \
|
---|
651 | pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegDstTmp].au64[0] = pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegSrc64Tmp].au64[1]; \
|
---|
652 | pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegDstTmp].au64[1] = pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegSrcHxTmp].au64[1]; \
|
---|
653 | pVCpu->cpum.GstCtx.XState.u.YmmHi.aYmmHi[iYRegDstTmp].au64[0] = 0; \
|
---|
654 | pVCpu->cpum.GstCtx.XState.u.YmmHi.aYmmHi[iYRegDstTmp].au64[1] = 0; \
|
---|
655 | IEM_MC_INT_CLEAR_ZMM_256_UP(iYRegDstTmp); \
|
---|
656 | } while (0)
|
---|
657 | #define IEM_MC_MERGE_YREG_U64LO_U64LOCAL_ZX_VLMAX(a_iYRegDst, a_iYRegSrcHx, a_u64Local) \
|
---|
658 | do { uintptr_t const iYRegDstTmp = (a_iYRegDst); \
|
---|
659 | uintptr_t const iYRegSrcHxTmp = (a_iYRegSrcHx); \
|
---|
660 | pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegDstTmp].au64[0] = pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegSrcHxTmp].au64[0]; \
|
---|
661 | pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegDstTmp].au64[1] = (a_u64Local); \
|
---|
662 | pVCpu->cpum.GstCtx.XState.u.YmmHi.aYmmHi[iYRegDstTmp].au64[0] = 0; \
|
---|
663 | pVCpu->cpum.GstCtx.XState.u.YmmHi.aYmmHi[iYRegDstTmp].au64[1] = 0; \
|
---|
664 | IEM_MC_INT_CLEAR_ZMM_256_UP(iYRegDstTmp); \
|
---|
665 | } while (0)
|
---|
666 | #define IEM_MC_MERGE_YREG_U64LOCAL_U64HI_ZX_VLMAX(a_iYRegDst, a_u64Local, a_iYRegSrcHx) \
|
---|
667 | do { uintptr_t const iYRegDstTmp = (a_iYRegDst); \
|
---|
668 | uintptr_t const iYRegSrcHxTmp = (a_iYRegSrcHx); \
|
---|
669 | pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegDstTmp].au64[0] = (a_u64Local); \
|
---|
670 | pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegDstTmp].au64[1] = pVCpu->cpum.GstCtx.XState.x87.aXMM[iYRegSrcHxTmp].au64[1]; \
|
---|
671 | pVCpu->cpum.GstCtx.XState.u.YmmHi.aYmmHi[iYRegDstTmp].au64[0] = 0; \
|
---|
672 | pVCpu->cpum.GstCtx.XState.u.YmmHi.aYmmHi[iYRegDstTmp].au64[1] = 0; \
|
---|
673 | IEM_MC_INT_CLEAR_ZMM_256_UP(iYRegDstTmp); \
|
---|
674 | } while (0)
|
---|
675 |
|
---|
676 | #ifndef IEM_WITH_SETJMP
|
---|
677 | # define IEM_MC_FETCH_MEM_U8(a_u8Dst, a_iSeg, a_GCPtrMem) \
|
---|
678 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU8(pVCpu, &(a_u8Dst), (a_iSeg), (a_GCPtrMem)))
|
---|
679 | # define IEM_MC_FETCH_MEM16_U8(a_u8Dst, a_iSeg, a_GCPtrMem16) \
|
---|
680 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU8(pVCpu, &(a_u8Dst), (a_iSeg), (a_GCPtrMem16)))
|
---|
681 | # define IEM_MC_FETCH_MEM32_U8(a_u8Dst, a_iSeg, a_GCPtrMem32) \
|
---|
682 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU8(pVCpu, &(a_u8Dst), (a_iSeg), (a_GCPtrMem32)))
|
---|
683 | #else
|
---|
684 | # define IEM_MC_FETCH_MEM_U8(a_u8Dst, a_iSeg, a_GCPtrMem) \
|
---|
685 | ((a_u8Dst) = iemMemFetchDataU8Jmp(pVCpu, (a_iSeg), (a_GCPtrMem)))
|
---|
686 | # define IEM_MC_FETCH_MEM16_U8(a_u8Dst, a_iSeg, a_GCPtrMem16) \
|
---|
687 | ((a_u8Dst) = iemMemFetchDataU8Jmp(pVCpu, (a_iSeg), (a_GCPtrMem16)))
|
---|
688 | # define IEM_MC_FETCH_MEM32_U8(a_u8Dst, a_iSeg, a_GCPtrMem32) \
|
---|
689 | ((a_u8Dst) = iemMemFetchDataU8Jmp(pVCpu, (a_iSeg), (a_GCPtrMem32)))
|
---|
690 | #endif
|
---|
691 |
|
---|
692 | #ifndef IEM_WITH_SETJMP
|
---|
693 | # define IEM_MC_FETCH_MEM_U16(a_u16Dst, a_iSeg, a_GCPtrMem) \
|
---|
694 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU16(pVCpu, &(a_u16Dst), (a_iSeg), (a_GCPtrMem)))
|
---|
695 | # define IEM_MC_FETCH_MEM_U16_DISP(a_u16Dst, a_iSeg, a_GCPtrMem, a_offDisp) \
|
---|
696 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU16(pVCpu, &(a_u16Dst), (a_iSeg), (a_GCPtrMem) + (a_offDisp)))
|
---|
697 | # define IEM_MC_FETCH_MEM_I16(a_i16Dst, a_iSeg, a_GCPtrMem) \
|
---|
698 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU16(pVCpu, (uint16_t *)&(a_i16Dst), (a_iSeg), (a_GCPtrMem)))
|
---|
699 | #else
|
---|
700 | # define IEM_MC_FETCH_MEM_U16(a_u16Dst, a_iSeg, a_GCPtrMem) \
|
---|
701 | ((a_u16Dst) = iemMemFetchDataU16Jmp(pVCpu, (a_iSeg), (a_GCPtrMem)))
|
---|
702 | # define IEM_MC_FETCH_MEM_U16_DISP(a_u16Dst, a_iSeg, a_GCPtrMem, a_offDisp) \
|
---|
703 | ((a_u16Dst) = iemMemFetchDataU16Jmp(pVCpu, (a_iSeg), (a_GCPtrMem) + (a_offDisp)))
|
---|
704 | # define IEM_MC_FETCH_MEM_I16(a_i16Dst, a_iSeg, a_GCPtrMem) \
|
---|
705 | ((a_i16Dst) = (int16_t)iemMemFetchDataU16Jmp(pVCpu, (a_iSeg), (a_GCPtrMem)))
|
---|
706 | #endif
|
---|
707 |
|
---|
708 | #ifndef IEM_WITH_SETJMP
|
---|
709 | # define IEM_MC_FETCH_MEM_U32(a_u32Dst, a_iSeg, a_GCPtrMem) \
|
---|
710 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU32(pVCpu, &(a_u32Dst), (a_iSeg), (a_GCPtrMem)))
|
---|
711 | # define IEM_MC_FETCH_MEM_U32_DISP(a_u32Dst, a_iSeg, a_GCPtrMem, a_offDisp) \
|
---|
712 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU32(pVCpu, &(a_u32Dst), (a_iSeg), (a_GCPtrMem) + (a_offDisp)))
|
---|
713 | # define IEM_MC_FETCH_MEM_I32(a_i32Dst, a_iSeg, a_GCPtrMem) \
|
---|
714 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU32(pVCpu, (uint32_t *)&(a_i32Dst), (a_iSeg), (a_GCPtrMem)))
|
---|
715 | #else
|
---|
716 | # define IEM_MC_FETCH_MEM_U32(a_u32Dst, a_iSeg, a_GCPtrMem) \
|
---|
717 | ((a_u32Dst) = iemMemFetchDataU32Jmp(pVCpu, (a_iSeg), (a_GCPtrMem)))
|
---|
718 | # define IEM_MC_FETCH_MEM_U32_DISP(a_u32Dst, a_iSeg, a_GCPtrMem, a_offDisp) \
|
---|
719 | ((a_u32Dst) = iemMemFetchDataU32Jmp(pVCpu, (a_iSeg), (a_GCPtrMem) + (a_offDisp)))
|
---|
720 | # define IEM_MC_FETCH_MEM_I32(a_i32Dst, a_iSeg, a_GCPtrMem) \
|
---|
721 | ((a_i32Dst) = (int32_t)iemMemFetchDataU32Jmp(pVCpu, (a_iSeg), (a_GCPtrMem)))
|
---|
722 | #endif
|
---|
723 |
|
---|
724 | #ifdef SOME_UNUSED_FUNCTION
|
---|
725 | # define IEM_MC_FETCH_MEM_S32_SX_U64(a_u64Dst, a_iSeg, a_GCPtrMem) \
|
---|
726 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataS32SxU64(pVCpu, &(a_u64Dst), (a_iSeg), (a_GCPtrMem)))
|
---|
727 | #endif
|
---|
728 |
|
---|
729 | #ifndef IEM_WITH_SETJMP
|
---|
730 | # define IEM_MC_FETCH_MEM_U64(a_u64Dst, a_iSeg, a_GCPtrMem) \
|
---|
731 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU64(pVCpu, &(a_u64Dst), (a_iSeg), (a_GCPtrMem)))
|
---|
732 | # define IEM_MC_FETCH_MEM_U64_DISP(a_u64Dst, a_iSeg, a_GCPtrMem, a_offDisp) \
|
---|
733 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU64(pVCpu, &(a_u64Dst), (a_iSeg), (a_GCPtrMem) + (a_offDisp)))
|
---|
734 | # define IEM_MC_FETCH_MEM_U64_ALIGN_U128(a_u64Dst, a_iSeg, a_GCPtrMem) \
|
---|
735 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU64AlignedU128(pVCpu, &(a_u64Dst), (a_iSeg), (a_GCPtrMem)))
|
---|
736 | # define IEM_MC_FETCH_MEM_I64(a_i64Dst, a_iSeg, a_GCPtrMem) \
|
---|
737 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU64(pVCpu, (uint64_t *)&(a_i64Dst), (a_iSeg), (a_GCPtrMem)))
|
---|
738 | #else
|
---|
739 | # define IEM_MC_FETCH_MEM_U64(a_u64Dst, a_iSeg, a_GCPtrMem) \
|
---|
740 | ((a_u64Dst) = iemMemFetchDataU64Jmp(pVCpu, (a_iSeg), (a_GCPtrMem)))
|
---|
741 | # define IEM_MC_FETCH_MEM_U64_DISP(a_u64Dst, a_iSeg, a_GCPtrMem, a_offDisp) \
|
---|
742 | ((a_u64Dst) = iemMemFetchDataU64Jmp(pVCpu, (a_iSeg), (a_GCPtrMem) + (a_offDisp)))
|
---|
743 | # define IEM_MC_FETCH_MEM_U64_ALIGN_U128(a_u64Dst, a_iSeg, a_GCPtrMem) \
|
---|
744 | ((a_u64Dst) = iemMemFetchDataU64AlignedU128Jmp(pVCpu, (a_iSeg), (a_GCPtrMem)))
|
---|
745 | # define IEM_MC_FETCH_MEM_I64(a_i64Dst, a_iSeg, a_GCPtrMem) \
|
---|
746 | ((a_i64Dst) = (int64_t)iemMemFetchDataU64Jmp(pVCpu, (a_iSeg), (a_GCPtrMem)))
|
---|
747 | #endif
|
---|
748 |
|
---|
749 | #ifndef IEM_WITH_SETJMP
|
---|
750 | # define IEM_MC_FETCH_MEM_R32(a_r32Dst, a_iSeg, a_GCPtrMem) \
|
---|
751 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU32(pVCpu, &(a_r32Dst).u, (a_iSeg), (a_GCPtrMem)))
|
---|
752 | # define IEM_MC_FETCH_MEM_R64(a_r64Dst, a_iSeg, a_GCPtrMem) \
|
---|
753 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU64(pVCpu, &(a_r64Dst).u, (a_iSeg), (a_GCPtrMem)))
|
---|
754 | # define IEM_MC_FETCH_MEM_R80(a_r80Dst, a_iSeg, a_GCPtrMem) \
|
---|
755 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataR80(pVCpu, &(a_r80Dst), (a_iSeg), (a_GCPtrMem)))
|
---|
756 | # define IEM_MC_FETCH_MEM_D80(a_d80Dst, a_iSeg, a_GCPtrMem) \
|
---|
757 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataD80(pVCpu, &(a_d80Dst), (a_iSeg), (a_GCPtrMem)))
|
---|
758 | #else
|
---|
759 | # define IEM_MC_FETCH_MEM_R32(a_r32Dst, a_iSeg, a_GCPtrMem) \
|
---|
760 | ((a_r32Dst).u = iemMemFetchDataU32Jmp(pVCpu, (a_iSeg), (a_GCPtrMem)))
|
---|
761 | # define IEM_MC_FETCH_MEM_R64(a_r64Dst, a_iSeg, a_GCPtrMem) \
|
---|
762 | ((a_r64Dst).u = iemMemFetchDataU64Jmp(pVCpu, (a_iSeg), (a_GCPtrMem)))
|
---|
763 | # define IEM_MC_FETCH_MEM_R80(a_r80Dst, a_iSeg, a_GCPtrMem) \
|
---|
764 | iemMemFetchDataR80Jmp(pVCpu, &(a_r80Dst), (a_iSeg), (a_GCPtrMem))
|
---|
765 | # define IEM_MC_FETCH_MEM_D80(a_d80Dst, a_iSeg, a_GCPtrMem) \
|
---|
766 | iemMemFetchDataD80Jmp(pVCpu, &(a_d80Dst), (a_iSeg), (a_GCPtrMem))
|
---|
767 | #endif
|
---|
768 |
|
---|
769 | #ifndef IEM_WITH_SETJMP
|
---|
770 | # define IEM_MC_FETCH_MEM_U128(a_u128Dst, a_iSeg, a_GCPtrMem) \
|
---|
771 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU128(pVCpu, &(a_u128Dst), (a_iSeg), (a_GCPtrMem)))
|
---|
772 | # define IEM_MC_FETCH_MEM_U128_NO_AC(a_u128Dst, a_iSeg, a_GCPtrMem) \
|
---|
773 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU128(pVCpu, &(a_u128Dst), (a_iSeg), (a_GCPtrMem)))
|
---|
774 | # define IEM_MC_FETCH_MEM_U128_ALIGN_SSE(a_u128Dst, a_iSeg, a_GCPtrMem) \
|
---|
775 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU128AlignedSse(pVCpu, &(a_u128Dst), (a_iSeg), (a_GCPtrMem)))
|
---|
776 |
|
---|
777 | # define IEM_MC_FETCH_MEM_XMM(a_XmmDst, a_iSeg, a_GCPtrMem) \
|
---|
778 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU128(pVCpu, &(a_XmmDst).uXmm, (a_iSeg), (a_GCPtrMem)))
|
---|
779 | # define IEM_MC_FETCH_MEM_XMM_NO_AC(a_XmmDst, a_iSeg, a_GCPtrMem) \
|
---|
780 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU128(pVCpu, &(a_XmmDst).uXmm, (a_iSeg), (a_GCPtrMem)))
|
---|
781 | # define IEM_MC_FETCH_MEM_XMM_ALIGN_SSE(a_XmmDst, a_iSeg, a_GCPtrMem) \
|
---|
782 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU128AlignedSse(pVCpu, &(a_XmmDst).uXmm, (a_iSeg), (a_GCPtrMem)))
|
---|
783 | # define IEM_MC_FETCH_MEM_XMM_U32(a_XmmDst, a_iDWord, a_iSeg, a_GCPtrMem) \
|
---|
784 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU32(pVCpu, &(a_XmmDst).au32[(a_iDWord)], (a_iSeg), (a_GCPtrMem)))
|
---|
785 | # define IEM_MC_FETCH_MEM_XMM_U64(a_XmmDst, a_iQWord, a_iSeg, a_GCPtrMem) \
|
---|
786 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU64(pVCpu, &(a_XmmDst).au64[(a_iQWord)], (a_iSeg), (a_GCPtrMem)))
|
---|
787 | #else
|
---|
788 | # define IEM_MC_FETCH_MEM_U128(a_u128Dst, a_iSeg, a_GCPtrMem) \
|
---|
789 | iemMemFetchDataU128Jmp(pVCpu, &(a_u128Dst), (a_iSeg), (a_GCPtrMem))
|
---|
790 | # define IEM_MC_FETCH_MEM_U128_NO_AC(a_u128Dst, a_iSeg, a_GCPtrMem) \
|
---|
791 | iemMemFetchDataU128Jmp(pVCpu, &(a_u128Dst), (a_iSeg), (a_GCPtrMem))
|
---|
792 | # define IEM_MC_FETCH_MEM_U128_ALIGN_SSE(a_u128Dst, a_iSeg, a_GCPtrMem) \
|
---|
793 | iemMemFetchDataU128AlignedSseJmp(pVCpu, &(a_u128Dst), (a_iSeg), (a_GCPtrMem))
|
---|
794 |
|
---|
795 | # define IEM_MC_FETCH_MEM_XMM(a_XmmDst, a_iSeg, a_GCPtrMem) \
|
---|
796 | iemMemFetchDataU128Jmp(pVCpu, &(a_XmmDst).uXmm, (a_iSeg), (a_GCPtrMem))
|
---|
797 | # define IEM_MC_FETCH_MEM_XMM_NO_AC(a_XmmDst, a_iSeg, a_GCPtrMem) \
|
---|
798 | iemMemFetchDataU128Jmp(pVCpu, &(a_XmmDst).uXmm, (a_iSeg), (a_GCPtrMem))
|
---|
799 | # define IEM_MC_FETCH_MEM_XMM_ALIGN_SSE(a_XmmDst, a_iSeg, a_GCPtrMem) \
|
---|
800 | iemMemFetchDataU128AlignedSseJmp(pVCpu, &(a_XmmDst).uXmm, (a_iSeg), (a_GCPtrMem))
|
---|
801 | # define IEM_MC_FETCH_MEM_XMM_U32(a_XmmDst, a_iDWord, a_iSeg, a_GCPtrMem) \
|
---|
802 | (a_XmmDst).au32[(a_iDWord)] = iemMemFetchDataU32Jmp(pVCpu, (a_iSeg), (a_GCPtrMem))
|
---|
803 | # define IEM_MC_FETCH_MEM_XMM_U64(a_XmmDst, a_iQWord, a_iSeg, a_GCPtrMem) \
|
---|
804 | (a_XmmDst).au64[(a_iQWord)] = iemMemFetchDataU64Jmp(pVCpu, (a_iSeg), (a_GCPtrMem))
|
---|
805 | #endif
|
---|
806 |
|
---|
807 | #ifndef IEM_WITH_SETJMP
|
---|
808 | # define IEM_MC_FETCH_MEM_U256(a_u256Dst, a_iSeg, a_GCPtrMem) \
|
---|
809 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU256(pVCpu, &(a_u256Dst), (a_iSeg), (a_GCPtrMem)))
|
---|
810 | # define IEM_MC_FETCH_MEM_U256_NO_AC(a_u256Dst, a_iSeg, a_GCPtrMem) \
|
---|
811 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU256(pVCpu, &(a_u256Dst), (a_iSeg), (a_GCPtrMem)))
|
---|
812 | # define IEM_MC_FETCH_MEM_U256_ALIGN_AVX(a_u256Dst, a_iSeg, a_GCPtrMem) \
|
---|
813 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU256AlignedSse(pVCpu, &(a_u256Dst), (a_iSeg), (a_GCPtrMem)))
|
---|
814 |
|
---|
815 | # define IEM_MC_FETCH_MEM_YMM(a_YmmDst, a_iSeg, a_GCPtrMem) \
|
---|
816 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU256(pVCpu, &(a_YmmDst).ymm, (a_iSeg), (a_GCPtrMem)))
|
---|
817 | # define IEM_MC_FETCH_MEM_YMM_NO_AC(a_YmmDst, a_iSeg, a_GCPtrMem) \
|
---|
818 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU256(pVCpu, &(a_YmmDst).ymm, (a_iSeg), (a_GCPtrMem)))
|
---|
819 | # define IEM_MC_FETCH_MEM_YMM_ALIGN_AVX(a_YmmDst, a_iSeg, a_GCPtrMem) \
|
---|
820 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU256AlignedSse(pVCpu, &(a_YmmDst).ymm, (a_iSeg), (a_GCPtrMem)))
|
---|
821 | #else
|
---|
822 | # define IEM_MC_FETCH_MEM_U256(a_u256Dst, a_iSeg, a_GCPtrMem) \
|
---|
823 | iemMemFetchDataU256Jmp(pVCpu, &(a_u256Dst), (a_iSeg), (a_GCPtrMem))
|
---|
824 | # define IEM_MC_FETCH_MEM_U256_NO_AC(a_u256Dst, a_iSeg, a_GCPtrMem) \
|
---|
825 | iemMemFetchDataU256Jmp(pVCpu, &(a_u256Dst), (a_iSeg), (a_GCPtrMem))
|
---|
826 | # define IEM_MC_FETCH_MEM_U256_ALIGN_AVX(a_u256Dst, a_iSeg, a_GCPtrMem) \
|
---|
827 | iemMemFetchDataU256AlignedSseJmp(pVCpu, &(a_u256Dst), (a_iSeg), (a_GCPtrMem))
|
---|
828 |
|
---|
829 | # define IEM_MC_FETCH_MEM_YMM(a_YmmDst, a_iSeg, a_GCPtrMem) \
|
---|
830 | iemMemFetchDataU256Jmp(pVCpu, &(a_YmmDst).ymm, (a_iSeg), (a_GCPtrMem))
|
---|
831 | # define IEM_MC_FETCH_MEM_YMM_NO_AC(a_YmmDst, a_iSeg, a_GCPtrMem) \
|
---|
832 | iemMemFetchDataU256Jmp(pVCpu, &(a_YmmDst).ymm, (a_iSeg), (a_GCPtrMem))
|
---|
833 | # define IEM_MC_FETCH_MEM_YMM_ALIGN_AVX(a_YmmDst, a_iSeg, a_GCPtrMem) \
|
---|
834 | iemMemFetchDataU256AlignedSseJmp(pVCpu, &(a_YmmDst).ymm, (a_iSeg), (a_GCPtrMem))
|
---|
835 | #endif
|
---|
836 |
|
---|
837 |
|
---|
838 |
|
---|
839 | #ifndef IEM_WITH_SETJMP
|
---|
840 | # define IEM_MC_FETCH_MEM_U8_ZX_U16(a_u16Dst, a_iSeg, a_GCPtrMem) \
|
---|
841 | do { \
|
---|
842 | uint8_t u8Tmp; \
|
---|
843 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU8(pVCpu, &u8Tmp, (a_iSeg), (a_GCPtrMem))); \
|
---|
844 | (a_u16Dst) = u8Tmp; \
|
---|
845 | } while (0)
|
---|
846 | # define IEM_MC_FETCH_MEM_U8_ZX_U32(a_u32Dst, a_iSeg, a_GCPtrMem) \
|
---|
847 | do { \
|
---|
848 | uint8_t u8Tmp; \
|
---|
849 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU8(pVCpu, &u8Tmp, (a_iSeg), (a_GCPtrMem))); \
|
---|
850 | (a_u32Dst) = u8Tmp; \
|
---|
851 | } while (0)
|
---|
852 | # define IEM_MC_FETCH_MEM_U8_ZX_U64(a_u64Dst, a_iSeg, a_GCPtrMem) \
|
---|
853 | do { \
|
---|
854 | uint8_t u8Tmp; \
|
---|
855 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU8(pVCpu, &u8Tmp, (a_iSeg), (a_GCPtrMem))); \
|
---|
856 | (a_u64Dst) = u8Tmp; \
|
---|
857 | } while (0)
|
---|
858 | # define IEM_MC_FETCH_MEM_U16_ZX_U32(a_u32Dst, a_iSeg, a_GCPtrMem) \
|
---|
859 | do { \
|
---|
860 | uint16_t u16Tmp; \
|
---|
861 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU16(pVCpu, &u16Tmp, (a_iSeg), (a_GCPtrMem))); \
|
---|
862 | (a_u32Dst) = u16Tmp; \
|
---|
863 | } while (0)
|
---|
864 | # define IEM_MC_FETCH_MEM_U16_ZX_U64(a_u64Dst, a_iSeg, a_GCPtrMem) \
|
---|
865 | do { \
|
---|
866 | uint16_t u16Tmp; \
|
---|
867 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU16(pVCpu, &u16Tmp, (a_iSeg), (a_GCPtrMem))); \
|
---|
868 | (a_u64Dst) = u16Tmp; \
|
---|
869 | } while (0)
|
---|
870 | # define IEM_MC_FETCH_MEM_U32_ZX_U64(a_u64Dst, a_iSeg, a_GCPtrMem) \
|
---|
871 | do { \
|
---|
872 | uint32_t u32Tmp; \
|
---|
873 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU32(pVCpu, &u32Tmp, (a_iSeg), (a_GCPtrMem))); \
|
---|
874 | (a_u64Dst) = u32Tmp; \
|
---|
875 | } while (0)
|
---|
876 | #else /* IEM_WITH_SETJMP */
|
---|
877 | # define IEM_MC_FETCH_MEM_U8_ZX_U16(a_u16Dst, a_iSeg, a_GCPtrMem) \
|
---|
878 | ((a_u16Dst) = iemMemFetchDataU8Jmp(pVCpu, (a_iSeg), (a_GCPtrMem)))
|
---|
879 | # define IEM_MC_FETCH_MEM_U8_ZX_U32(a_u32Dst, a_iSeg, a_GCPtrMem) \
|
---|
880 | ((a_u32Dst) = iemMemFetchDataU8Jmp(pVCpu, (a_iSeg), (a_GCPtrMem)))
|
---|
881 | # define IEM_MC_FETCH_MEM_U8_ZX_U64(a_u64Dst, a_iSeg, a_GCPtrMem) \
|
---|
882 | ((a_u64Dst) = iemMemFetchDataU8Jmp(pVCpu, (a_iSeg), (a_GCPtrMem)))
|
---|
883 | # define IEM_MC_FETCH_MEM_U16_ZX_U32(a_u32Dst, a_iSeg, a_GCPtrMem) \
|
---|
884 | ((a_u32Dst) = iemMemFetchDataU16Jmp(pVCpu, (a_iSeg), (a_GCPtrMem)))
|
---|
885 | # define IEM_MC_FETCH_MEM_U16_ZX_U64(a_u64Dst, a_iSeg, a_GCPtrMem) \
|
---|
886 | ((a_u64Dst) = iemMemFetchDataU16Jmp(pVCpu, (a_iSeg), (a_GCPtrMem)))
|
---|
887 | # define IEM_MC_FETCH_MEM_U32_ZX_U64(a_u64Dst, a_iSeg, a_GCPtrMem) \
|
---|
888 | ((a_u64Dst) = iemMemFetchDataU32Jmp(pVCpu, (a_iSeg), (a_GCPtrMem)))
|
---|
889 | #endif /* IEM_WITH_SETJMP */
|
---|
890 |
|
---|
891 | #ifndef IEM_WITH_SETJMP
|
---|
892 | # define IEM_MC_FETCH_MEM_U8_SX_U16(a_u16Dst, a_iSeg, a_GCPtrMem) \
|
---|
893 | do { \
|
---|
894 | uint8_t u8Tmp; \
|
---|
895 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU8(pVCpu, &u8Tmp, (a_iSeg), (a_GCPtrMem))); \
|
---|
896 | (a_u16Dst) = (int8_t)u8Tmp; \
|
---|
897 | } while (0)
|
---|
898 | # define IEM_MC_FETCH_MEM_U8_SX_U32(a_u32Dst, a_iSeg, a_GCPtrMem) \
|
---|
899 | do { \
|
---|
900 | uint8_t u8Tmp; \
|
---|
901 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU8(pVCpu, &u8Tmp, (a_iSeg), (a_GCPtrMem))); \
|
---|
902 | (a_u32Dst) = (int8_t)u8Tmp; \
|
---|
903 | } while (0)
|
---|
904 | # define IEM_MC_FETCH_MEM_U8_SX_U64(a_u64Dst, a_iSeg, a_GCPtrMem) \
|
---|
905 | do { \
|
---|
906 | uint8_t u8Tmp; \
|
---|
907 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU8(pVCpu, &u8Tmp, (a_iSeg), (a_GCPtrMem))); \
|
---|
908 | (a_u64Dst) = (int8_t)u8Tmp; \
|
---|
909 | } while (0)
|
---|
910 | # define IEM_MC_FETCH_MEM_U16_SX_U32(a_u32Dst, a_iSeg, a_GCPtrMem) \
|
---|
911 | do { \
|
---|
912 | uint16_t u16Tmp; \
|
---|
913 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU16(pVCpu, &u16Tmp, (a_iSeg), (a_GCPtrMem))); \
|
---|
914 | (a_u32Dst) = (int16_t)u16Tmp; \
|
---|
915 | } while (0)
|
---|
916 | # define IEM_MC_FETCH_MEM_U16_SX_U64(a_u64Dst, a_iSeg, a_GCPtrMem) \
|
---|
917 | do { \
|
---|
918 | uint16_t u16Tmp; \
|
---|
919 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU16(pVCpu, &u16Tmp, (a_iSeg), (a_GCPtrMem))); \
|
---|
920 | (a_u64Dst) = (int16_t)u16Tmp; \
|
---|
921 | } while (0)
|
---|
922 | # define IEM_MC_FETCH_MEM_U32_SX_U64(a_u64Dst, a_iSeg, a_GCPtrMem) \
|
---|
923 | do { \
|
---|
924 | uint32_t u32Tmp; \
|
---|
925 | IEM_MC_RETURN_ON_FAILURE(iemMemFetchDataU32(pVCpu, &u32Tmp, (a_iSeg), (a_GCPtrMem))); \
|
---|
926 | (a_u64Dst) = (int32_t)u32Tmp; \
|
---|
927 | } while (0)
|
---|
928 | #else /* IEM_WITH_SETJMP */
|
---|
929 | # define IEM_MC_FETCH_MEM_U8_SX_U16(a_u16Dst, a_iSeg, a_GCPtrMem) \
|
---|
930 | ((a_u16Dst) = (int8_t)iemMemFetchDataU8Jmp(pVCpu, (a_iSeg), (a_GCPtrMem)))
|
---|
931 | # define IEM_MC_FETCH_MEM_U8_SX_U32(a_u32Dst, a_iSeg, a_GCPtrMem) \
|
---|
932 | ((a_u32Dst) = (int8_t)iemMemFetchDataU8Jmp(pVCpu, (a_iSeg), (a_GCPtrMem)))
|
---|
933 | # define IEM_MC_FETCH_MEM_U8_SX_U64(a_u64Dst, a_iSeg, a_GCPtrMem) \
|
---|
934 | ((a_u64Dst) = (int8_t)iemMemFetchDataU8Jmp(pVCpu, (a_iSeg), (a_GCPtrMem)))
|
---|
935 | # define IEM_MC_FETCH_MEM_U16_SX_U32(a_u32Dst, a_iSeg, a_GCPtrMem) \
|
---|
936 | ((a_u32Dst) = (int16_t)iemMemFetchDataU16Jmp(pVCpu, (a_iSeg), (a_GCPtrMem)))
|
---|
937 | # define IEM_MC_FETCH_MEM_U16_SX_U64(a_u64Dst, a_iSeg, a_GCPtrMem) \
|
---|
938 | ((a_u64Dst) = (int16_t)iemMemFetchDataU16Jmp(pVCpu, (a_iSeg), (a_GCPtrMem)))
|
---|
939 | # define IEM_MC_FETCH_MEM_U32_SX_U64(a_u64Dst, a_iSeg, a_GCPtrMem) \
|
---|
940 | ((a_u64Dst) = (int32_t)iemMemFetchDataU32Jmp(pVCpu, (a_iSeg), (a_GCPtrMem)))
|
---|
941 | #endif /* IEM_WITH_SETJMP */
|
---|
942 |
|
---|
943 | #ifndef IEM_WITH_SETJMP
|
---|
944 | # define IEM_MC_STORE_MEM_U8(a_iSeg, a_GCPtrMem, a_u8Value) \
|
---|
945 | IEM_MC_RETURN_ON_FAILURE(iemMemStoreDataU8(pVCpu, (a_iSeg), (a_GCPtrMem), (a_u8Value)))
|
---|
946 | # define IEM_MC_STORE_MEM_U16(a_iSeg, a_GCPtrMem, a_u16Value) \
|
---|
947 | IEM_MC_RETURN_ON_FAILURE(iemMemStoreDataU16(pVCpu, (a_iSeg), (a_GCPtrMem), (a_u16Value)))
|
---|
948 | # define IEM_MC_STORE_MEM_U32(a_iSeg, a_GCPtrMem, a_u32Value) \
|
---|
949 | IEM_MC_RETURN_ON_FAILURE(iemMemStoreDataU32(pVCpu, (a_iSeg), (a_GCPtrMem), (a_u32Value)))
|
---|
950 | # define IEM_MC_STORE_MEM_U64(a_iSeg, a_GCPtrMem, a_u64Value) \
|
---|
951 | IEM_MC_RETURN_ON_FAILURE(iemMemStoreDataU64(pVCpu, (a_iSeg), (a_GCPtrMem), (a_u64Value)))
|
---|
952 | #else
|
---|
953 | # define IEM_MC_STORE_MEM_U8(a_iSeg, a_GCPtrMem, a_u8Value) \
|
---|
954 | iemMemStoreDataU8Jmp(pVCpu, (a_iSeg), (a_GCPtrMem), (a_u8Value))
|
---|
955 | # define IEM_MC_STORE_MEM_U16(a_iSeg, a_GCPtrMem, a_u16Value) \
|
---|
956 | iemMemStoreDataU16Jmp(pVCpu, (a_iSeg), (a_GCPtrMem), (a_u16Value))
|
---|
957 | # define IEM_MC_STORE_MEM_U32(a_iSeg, a_GCPtrMem, a_u32Value) \
|
---|
958 | iemMemStoreDataU32Jmp(pVCpu, (a_iSeg), (a_GCPtrMem), (a_u32Value))
|
---|
959 | # define IEM_MC_STORE_MEM_U64(a_iSeg, a_GCPtrMem, a_u64Value) \
|
---|
960 | iemMemStoreDataU64Jmp(pVCpu, (a_iSeg), (a_GCPtrMem), (a_u64Value))
|
---|
961 | #endif
|
---|
962 |
|
---|
963 | #ifndef IEM_WITH_SETJMP
|
---|
964 | # define IEM_MC_STORE_MEM_U8_CONST(a_iSeg, a_GCPtrMem, a_u8C) \
|
---|
965 | IEM_MC_RETURN_ON_FAILURE(iemMemStoreDataU8(pVCpu, (a_iSeg), (a_GCPtrMem), (a_u8C)))
|
---|
966 | # define IEM_MC_STORE_MEM_U16_CONST(a_iSeg, a_GCPtrMem, a_u16C) \
|
---|
967 | IEM_MC_RETURN_ON_FAILURE(iemMemStoreDataU16(pVCpu, (a_iSeg), (a_GCPtrMem), (a_u16C)))
|
---|
968 | # define IEM_MC_STORE_MEM_U32_CONST(a_iSeg, a_GCPtrMem, a_u32C) \
|
---|
969 | IEM_MC_RETURN_ON_FAILURE(iemMemStoreDataU32(pVCpu, (a_iSeg), (a_GCPtrMem), (a_u32C)))
|
---|
970 | # define IEM_MC_STORE_MEM_U64_CONST(a_iSeg, a_GCPtrMem, a_u64C) \
|
---|
971 | IEM_MC_RETURN_ON_FAILURE(iemMemStoreDataU64(pVCpu, (a_iSeg), (a_GCPtrMem), (a_u64C)))
|
---|
972 | #else
|
---|
973 | # define IEM_MC_STORE_MEM_U8_CONST(a_iSeg, a_GCPtrMem, a_u8C) \
|
---|
974 | iemMemStoreDataU8Jmp(pVCpu, (a_iSeg), (a_GCPtrMem), (a_u8C))
|
---|
975 | # define IEM_MC_STORE_MEM_U16_CONST(a_iSeg, a_GCPtrMem, a_u16C) \
|
---|
976 | iemMemStoreDataU16Jmp(pVCpu, (a_iSeg), (a_GCPtrMem), (a_u16C))
|
---|
977 | # define IEM_MC_STORE_MEM_U32_CONST(a_iSeg, a_GCPtrMem, a_u32C) \
|
---|
978 | iemMemStoreDataU32Jmp(pVCpu, (a_iSeg), (a_GCPtrMem), (a_u32C))
|
---|
979 | # define IEM_MC_STORE_MEM_U64_CONST(a_iSeg, a_GCPtrMem, a_u64C) \
|
---|
980 | iemMemStoreDataU64Jmp(pVCpu, (a_iSeg), (a_GCPtrMem), (a_u64C))
|
---|
981 | #endif
|
---|
982 |
|
---|
983 | #define IEM_MC_STORE_MEM_I8_CONST_BY_REF( a_pi8Dst, a_i8C) *(a_pi8Dst) = (a_i8C)
|
---|
984 | #define IEM_MC_STORE_MEM_I16_CONST_BY_REF(a_pi16Dst, a_i16C) *(a_pi16Dst) = (a_i16C)
|
---|
985 | #define IEM_MC_STORE_MEM_I32_CONST_BY_REF(a_pi32Dst, a_i32C) *(a_pi32Dst) = (a_i32C)
|
---|
986 | #define IEM_MC_STORE_MEM_I64_CONST_BY_REF(a_pi64Dst, a_i64C) *(a_pi64Dst) = (a_i64C)
|
---|
987 | #define IEM_MC_STORE_MEM_NEG_QNAN_R32_BY_REF(a_pr32Dst) (a_pr32Dst)->u = UINT32_C(0xffc00000)
|
---|
988 | #define IEM_MC_STORE_MEM_NEG_QNAN_R64_BY_REF(a_pr64Dst) (a_pr64Dst)->u = UINT64_C(0xfff8000000000000)
|
---|
989 | #define IEM_MC_STORE_MEM_NEG_QNAN_R80_BY_REF(a_pr80Dst) \
|
---|
990 | do { \
|
---|
991 | (a_pr80Dst)->au64[0] = UINT64_C(0xc000000000000000); \
|
---|
992 | (a_pr80Dst)->au16[4] = UINT16_C(0xffff); \
|
---|
993 | } while (0)
|
---|
994 | #define IEM_MC_STORE_MEM_INDEF_D80_BY_REF(a_pd80Dst) \
|
---|
995 | do { \
|
---|
996 | (a_pd80Dst)->au64[0] = UINT64_C(0xc000000000000000); \
|
---|
997 | (a_pd80Dst)->au16[4] = UINT16_C(0xffff); \
|
---|
998 | } while (0)
|
---|
999 |
|
---|
1000 | #ifndef IEM_WITH_SETJMP
|
---|
1001 | # define IEM_MC_STORE_MEM_U128(a_iSeg, a_GCPtrMem, a_u128Value) \
|
---|
1002 | IEM_MC_RETURN_ON_FAILURE(iemMemStoreDataU128(pVCpu, (a_iSeg), (a_GCPtrMem), (a_u128Value)))
|
---|
1003 | # define IEM_MC_STORE_MEM_U128_ALIGN_SSE(a_iSeg, a_GCPtrMem, a_u128Value) \
|
---|
1004 | IEM_MC_RETURN_ON_FAILURE(iemMemStoreDataU128AlignedSse(pVCpu, (a_iSeg), (a_GCPtrMem), (a_u128Value)))
|
---|
1005 | #else
|
---|
1006 | # define IEM_MC_STORE_MEM_U128(a_iSeg, a_GCPtrMem, a_u128Value) \
|
---|
1007 | iemMemStoreDataU128Jmp(pVCpu, (a_iSeg), (a_GCPtrMem), (a_u128Value))
|
---|
1008 | # define IEM_MC_STORE_MEM_U128_ALIGN_SSE(a_iSeg, a_GCPtrMem, a_u128Value) \
|
---|
1009 | iemMemStoreDataU128AlignedSseJmp(pVCpu, (a_iSeg), (a_GCPtrMem), (a_u128Value))
|
---|
1010 | #endif
|
---|
1011 |
|
---|
1012 | #ifndef IEM_WITH_SETJMP
|
---|
1013 | # define IEM_MC_STORE_MEM_U256(a_iSeg, a_GCPtrMem, a_u256Value) \
|
---|
1014 | IEM_MC_RETURN_ON_FAILURE(iemMemStoreDataU256(pVCpu, (a_iSeg), (a_GCPtrMem), &(a_u256Value)))
|
---|
1015 | # define IEM_MC_STORE_MEM_U256_ALIGN_AVX(a_iSeg, a_GCPtrMem, a_u256Value) \
|
---|
1016 | IEM_MC_RETURN_ON_FAILURE(iemMemStoreDataU256AlignedAvx(pVCpu, (a_iSeg), (a_GCPtrMem), &(a_u256Value)))
|
---|
1017 | #else
|
---|
1018 | # define IEM_MC_STORE_MEM_U256(a_iSeg, a_GCPtrMem, a_u256Value) \
|
---|
1019 | iemMemStoreDataU256Jmp(pVCpu, (a_iSeg), (a_GCPtrMem), &(a_u256Value))
|
---|
1020 | # define IEM_MC_STORE_MEM_U256_ALIGN_AVX(a_iSeg, a_GCPtrMem, a_u256Value) \
|
---|
1021 | iemMemStoreDataU256AlignedAvxJmp(pVCpu, (a_iSeg), (a_GCPtrMem), &(a_u256Value))
|
---|
1022 | #endif
|
---|
1023 |
|
---|
1024 |
|
---|
1025 | #define IEM_MC_PUSH_U16(a_u16Value) \
|
---|
1026 | IEM_MC_RETURN_ON_FAILURE(iemMemStackPushU16(pVCpu, (a_u16Value)))
|
---|
1027 | #define IEM_MC_PUSH_U32(a_u32Value) \
|
---|
1028 | IEM_MC_RETURN_ON_FAILURE(iemMemStackPushU32(pVCpu, (a_u32Value)))
|
---|
1029 | #define IEM_MC_PUSH_U32_SREG(a_u32Value) \
|
---|
1030 | IEM_MC_RETURN_ON_FAILURE(iemMemStackPushU32SReg(pVCpu, (a_u32Value)))
|
---|
1031 | #define IEM_MC_PUSH_U64(a_u64Value) \
|
---|
1032 | IEM_MC_RETURN_ON_FAILURE(iemMemStackPushU64(pVCpu, (a_u64Value)))
|
---|
1033 |
|
---|
1034 | #define IEM_MC_POP_U16(a_pu16Value) \
|
---|
1035 | IEM_MC_RETURN_ON_FAILURE(iemMemStackPopU16(pVCpu, (a_pu16Value)))
|
---|
1036 | #define IEM_MC_POP_U32(a_pu32Value) \
|
---|
1037 | IEM_MC_RETURN_ON_FAILURE(iemMemStackPopU32(pVCpu, (a_pu32Value)))
|
---|
1038 | #define IEM_MC_POP_U64(a_pu64Value) \
|
---|
1039 | IEM_MC_RETURN_ON_FAILURE(iemMemStackPopU64(pVCpu, (a_pu64Value)))
|
---|
1040 |
|
---|
1041 | /** Maps guest memory for direct or bounce buffered access.
|
---|
1042 | * The purpose is to pass it to an operand implementation, thus the a_iArg.
|
---|
1043 | * @remarks May return.
|
---|
1044 | */
|
---|
1045 | #define IEM_MC_MEM_MAP(a_pMem, a_fAccess, a_iSeg, a_GCPtrMem, a_iArg) \
|
---|
1046 | IEM_MC_RETURN_ON_FAILURE(iemMemMap(pVCpu, (void **)&(a_pMem), sizeof(*(a_pMem)), (a_iSeg), \
|
---|
1047 | (a_GCPtrMem), (a_fAccess), sizeof(*(a_pMem)) - 1))
|
---|
1048 |
|
---|
1049 | /** Maps guest memory for direct or bounce buffered access.
|
---|
1050 | * The purpose is to pass it to an operand implementation, thus the a_iArg.
|
---|
1051 | * @remarks May return.
|
---|
1052 | */
|
---|
1053 | #define IEM_MC_MEM_MAP_EX(a_pvMem, a_fAccess, a_cbMem, a_iSeg, a_GCPtrMem, a_cbAlign, a_iArg) \
|
---|
1054 | IEM_MC_RETURN_ON_FAILURE(iemMemMap(pVCpu, (void **)&(a_pvMem), (a_cbMem), (a_iSeg), \
|
---|
1055 | (a_GCPtrMem), (a_fAccess), (a_cbAlign)))
|
---|
1056 |
|
---|
1057 | /** Commits the memory and unmaps the guest memory.
|
---|
1058 | * @remarks May return.
|
---|
1059 | */
|
---|
1060 | #define IEM_MC_MEM_COMMIT_AND_UNMAP(a_pvMem, a_fAccess) \
|
---|
1061 | IEM_MC_RETURN_ON_FAILURE(iemMemCommitAndUnmap(pVCpu, (a_pvMem), (a_fAccess)))
|
---|
1062 |
|
---|
1063 | /** Commits the memory and unmaps the guest memory unless the FPU status word
|
---|
1064 | * indicates (@a a_u16FSW) and FPU control word indicates a pending exception
|
---|
1065 | * that would cause FLD not to store.
|
---|
1066 | *
|
---|
1067 | * The current understanding is that \#O, \#U, \#IA and \#IS will prevent a
|
---|
1068 | * store, while \#P will not.
|
---|
1069 | *
|
---|
1070 | * @remarks May in theory return - for now.
|
---|
1071 | */
|
---|
1072 | #define IEM_MC_MEM_COMMIT_AND_UNMAP_FOR_FPU_STORE(a_pvMem, a_fAccess, a_u16FSW) \
|
---|
1073 | do { \
|
---|
1074 | if ( !(a_u16FSW & X86_FSW_ES) \
|
---|
1075 | || !( (a_u16FSW & (X86_FSW_UE | X86_FSW_OE | X86_FSW_IE)) \
|
---|
1076 | & ~(pVCpu->cpum.GstCtx.XState.x87.FCW & X86_FCW_MASK_ALL) ) ) \
|
---|
1077 | IEM_MC_RETURN_ON_FAILURE(iemMemCommitAndUnmap(pVCpu, (a_pvMem), (a_fAccess))); \
|
---|
1078 | } while (0)
|
---|
1079 |
|
---|
1080 | /** Calculate efficient address from R/M. */
|
---|
1081 | #ifndef IEM_WITH_SETJMP
|
---|
1082 | # define IEM_MC_CALC_RM_EFF_ADDR(a_GCPtrEff, bRm, cbImm) \
|
---|
1083 | IEM_MC_RETURN_ON_FAILURE(iemOpHlpCalcRmEffAddr(pVCpu, (bRm), (cbImm), &(a_GCPtrEff)))
|
---|
1084 | #else
|
---|
1085 | # define IEM_MC_CALC_RM_EFF_ADDR(a_GCPtrEff, bRm, cbImm) \
|
---|
1086 | ((a_GCPtrEff) = iemOpHlpCalcRmEffAddrJmp(pVCpu, (bRm), (cbImm)))
|
---|
1087 | #endif
|
---|
1088 |
|
---|
1089 | #define IEM_MC_CALL_VOID_AIMPL_0(a_pfn) (a_pfn)()
|
---|
1090 | #define IEM_MC_CALL_VOID_AIMPL_1(a_pfn, a0) (a_pfn)((a0))
|
---|
1091 | #define IEM_MC_CALL_VOID_AIMPL_2(a_pfn, a0, a1) (a_pfn)((a0), (a1))
|
---|
1092 | #define IEM_MC_CALL_VOID_AIMPL_3(a_pfn, a0, a1, a2) (a_pfn)((a0), (a1), (a2))
|
---|
1093 | #define IEM_MC_CALL_VOID_AIMPL_4(a_pfn, a0, a1, a2, a3) (a_pfn)((a0), (a1), (a2), (a3))
|
---|
1094 | #define IEM_MC_CALL_AIMPL_3(a_rc, a_pfn, a0, a1, a2) (a_rc) = (a_pfn)((a0), (a1), (a2))
|
---|
1095 | #define IEM_MC_CALL_AIMPL_4(a_rc, a_pfn, a0, a1, a2, a3) (a_rc) = (a_pfn)((a0), (a1), (a2), (a3))
|
---|
1096 |
|
---|
1097 | /**
|
---|
1098 | * Defers the rest of the instruction emulation to a C implementation routine
|
---|
1099 | * and returns, only taking the standard parameters.
|
---|
1100 | *
|
---|
1101 | * @param a_pfnCImpl The pointer to the C routine.
|
---|
1102 | * @sa IEM_DECL_IMPL_C_TYPE_0 and IEM_CIMPL_DEF_0.
|
---|
1103 | */
|
---|
1104 | #define IEM_MC_CALL_CIMPL_0(a_pfnCImpl) return (a_pfnCImpl)(pVCpu, IEM_GET_INSTR_LEN(pVCpu))
|
---|
1105 |
|
---|
1106 | /**
|
---|
1107 | * Defers the rest of instruction emulation to a C implementation routine and
|
---|
1108 | * returns, taking one argument in addition to the standard ones.
|
---|
1109 | *
|
---|
1110 | * @param a_pfnCImpl The pointer to the C routine.
|
---|
1111 | * @param a0 The argument.
|
---|
1112 | */
|
---|
1113 | #define IEM_MC_CALL_CIMPL_1(a_pfnCImpl, a0) return (a_pfnCImpl)(pVCpu, IEM_GET_INSTR_LEN(pVCpu), a0)
|
---|
1114 |
|
---|
1115 | /**
|
---|
1116 | * Defers the rest of the instruction emulation to a C implementation routine
|
---|
1117 | * and returns, taking two arguments in addition to the standard ones.
|
---|
1118 | *
|
---|
1119 | * @param a_pfnCImpl The pointer to the C routine.
|
---|
1120 | * @param a0 The first extra argument.
|
---|
1121 | * @param a1 The second extra argument.
|
---|
1122 | */
|
---|
1123 | #define IEM_MC_CALL_CIMPL_2(a_pfnCImpl, a0, a1) return (a_pfnCImpl)(pVCpu, IEM_GET_INSTR_LEN(pVCpu), a0, a1)
|
---|
1124 |
|
---|
1125 | /**
|
---|
1126 | * Defers the rest of the instruction emulation to a C implementation routine
|
---|
1127 | * and returns, taking three arguments in addition to the standard ones.
|
---|
1128 | *
|
---|
1129 | * @param a_pfnCImpl The pointer to the C routine.
|
---|
1130 | * @param a0 The first extra argument.
|
---|
1131 | * @param a1 The second extra argument.
|
---|
1132 | * @param a2 The third extra argument.
|
---|
1133 | */
|
---|
1134 | #define IEM_MC_CALL_CIMPL_3(a_pfnCImpl, a0, a1, a2) return (a_pfnCImpl)(pVCpu, IEM_GET_INSTR_LEN(pVCpu), a0, a1, a2)
|
---|
1135 |
|
---|
1136 | /**
|
---|
1137 | * Defers the rest of the instruction emulation to a C implementation routine
|
---|
1138 | * and returns, taking four arguments in addition to the standard ones.
|
---|
1139 | *
|
---|
1140 | * @param a_pfnCImpl The pointer to the C routine.
|
---|
1141 | * @param a0 The first extra argument.
|
---|
1142 | * @param a1 The second extra argument.
|
---|
1143 | * @param a2 The third extra argument.
|
---|
1144 | * @param a3 The fourth extra argument.
|
---|
1145 | */
|
---|
1146 | #define IEM_MC_CALL_CIMPL_4(a_pfnCImpl, a0, a1, a2, a3) return (a_pfnCImpl)(pVCpu, IEM_GET_INSTR_LEN(pVCpu), a0, a1, a2, a3)
|
---|
1147 |
|
---|
1148 | /**
|
---|
1149 | * Defers the rest of the instruction emulation to a C implementation routine
|
---|
1150 | * and returns, taking two arguments in addition to the standard ones.
|
---|
1151 | *
|
---|
1152 | * @param a_pfnCImpl The pointer to the C routine.
|
---|
1153 | * @param a0 The first extra argument.
|
---|
1154 | * @param a1 The second extra argument.
|
---|
1155 | * @param a2 The third extra argument.
|
---|
1156 | * @param a3 The fourth extra argument.
|
---|
1157 | * @param a4 The fifth extra argument.
|
---|
1158 | */
|
---|
1159 | #define IEM_MC_CALL_CIMPL_5(a_pfnCImpl, a0, a1, a2, a3, a4) return (a_pfnCImpl)(pVCpu, IEM_GET_INSTR_LEN(pVCpu), a0, a1, a2, a3, a4)
|
---|
1160 |
|
---|
1161 | /**
|
---|
1162 | * Defers the entire instruction emulation to a C implementation routine and
|
---|
1163 | * returns, only taking the standard parameters.
|
---|
1164 | *
|
---|
1165 | * This shall be used without any IEM_MC_BEGIN or IEM_END macro surrounding it.
|
---|
1166 | *
|
---|
1167 | * @param a_pfnCImpl The pointer to the C routine.
|
---|
1168 | * @sa IEM_DECL_IMPL_C_TYPE_0 and IEM_CIMPL_DEF_0.
|
---|
1169 | */
|
---|
1170 | #define IEM_MC_DEFER_TO_CIMPL_0(a_pfnCImpl) (a_pfnCImpl)(pVCpu, IEM_GET_INSTR_LEN(pVCpu))
|
---|
1171 |
|
---|
1172 | /**
|
---|
1173 | * Defers the entire instruction emulation to a C implementation routine and
|
---|
1174 | * returns, taking one argument in addition to the standard ones.
|
---|
1175 | *
|
---|
1176 | * This shall be used without any IEM_MC_BEGIN or IEM_END macro surrounding it.
|
---|
1177 | *
|
---|
1178 | * @param a_pfnCImpl The pointer to the C routine.
|
---|
1179 | * @param a0 The argument.
|
---|
1180 | */
|
---|
1181 | #define IEM_MC_DEFER_TO_CIMPL_1(a_pfnCImpl, a0) (a_pfnCImpl)(pVCpu, IEM_GET_INSTR_LEN(pVCpu), a0)
|
---|
1182 |
|
---|
1183 | /**
|
---|
1184 | * Defers the entire instruction emulation to a C implementation routine and
|
---|
1185 | * returns, taking two arguments in addition to the standard ones.
|
---|
1186 | *
|
---|
1187 | * This shall be used without any IEM_MC_BEGIN or IEM_END macro surrounding it.
|
---|
1188 | *
|
---|
1189 | * @param a_pfnCImpl The pointer to the C routine.
|
---|
1190 | * @param a0 The first extra argument.
|
---|
1191 | * @param a1 The second extra argument.
|
---|
1192 | */
|
---|
1193 | #define IEM_MC_DEFER_TO_CIMPL_2(a_pfnCImpl, a0, a1) (a_pfnCImpl)(pVCpu, IEM_GET_INSTR_LEN(pVCpu), a0, a1)
|
---|
1194 |
|
---|
1195 | /**
|
---|
1196 | * Defers the entire instruction emulation to a C implementation routine and
|
---|
1197 | * returns, taking three arguments in addition to the standard ones.
|
---|
1198 | *
|
---|
1199 | * This shall be used without any IEM_MC_BEGIN or IEM_END macro surrounding it.
|
---|
1200 | *
|
---|
1201 | * @param a_pfnCImpl The pointer to the C routine.
|
---|
1202 | * @param a0 The first extra argument.
|
---|
1203 | * @param a1 The second extra argument.
|
---|
1204 | * @param a2 The third extra argument.
|
---|
1205 | */
|
---|
1206 | #define IEM_MC_DEFER_TO_CIMPL_3(a_pfnCImpl, a0, a1, a2) (a_pfnCImpl)(pVCpu, IEM_GET_INSTR_LEN(pVCpu), a0, a1, a2)
|
---|
1207 |
|
---|
1208 | /**
|
---|
1209 | * Calls a FPU assembly implementation taking one visible argument.
|
---|
1210 | *
|
---|
1211 | * @param a_pfnAImpl Pointer to the assembly FPU routine.
|
---|
1212 | * @param a0 The first extra argument.
|
---|
1213 | */
|
---|
1214 | #define IEM_MC_CALL_FPU_AIMPL_1(a_pfnAImpl, a0) \
|
---|
1215 | do { \
|
---|
1216 | a_pfnAImpl(&pVCpu->cpum.GstCtx.XState.x87, (a0)); \
|
---|
1217 | } while (0)
|
---|
1218 |
|
---|
1219 | /**
|
---|
1220 | * Calls a FPU assembly implementation taking two visible arguments.
|
---|
1221 | *
|
---|
1222 | * @param a_pfnAImpl Pointer to the assembly FPU routine.
|
---|
1223 | * @param a0 The first extra argument.
|
---|
1224 | * @param a1 The second extra argument.
|
---|
1225 | */
|
---|
1226 | #define IEM_MC_CALL_FPU_AIMPL_2(a_pfnAImpl, a0, a1) \
|
---|
1227 | do { \
|
---|
1228 | a_pfnAImpl(&pVCpu->cpum.GstCtx.XState.x87, (a0), (a1)); \
|
---|
1229 | } while (0)
|
---|
1230 |
|
---|
1231 | /**
|
---|
1232 | * Calls a FPU assembly implementation taking three visible arguments.
|
---|
1233 | *
|
---|
1234 | * @param a_pfnAImpl Pointer to the assembly FPU routine.
|
---|
1235 | * @param a0 The first extra argument.
|
---|
1236 | * @param a1 The second extra argument.
|
---|
1237 | * @param a2 The third extra argument.
|
---|
1238 | */
|
---|
1239 | #define IEM_MC_CALL_FPU_AIMPL_3(a_pfnAImpl, a0, a1, a2) \
|
---|
1240 | do { \
|
---|
1241 | a_pfnAImpl(&pVCpu->cpum.GstCtx.XState.x87, (a0), (a1), (a2)); \
|
---|
1242 | } while (0)
|
---|
1243 |
|
---|
1244 | #define IEM_MC_SET_FPU_RESULT(a_FpuData, a_FSW, a_pr80Value) \
|
---|
1245 | do { \
|
---|
1246 | (a_FpuData).FSW = (a_FSW); \
|
---|
1247 | (a_FpuData).r80Result = *(a_pr80Value); \
|
---|
1248 | } while (0)
|
---|
1249 |
|
---|
1250 | /** Pushes FPU result onto the stack. */
|
---|
1251 | #define IEM_MC_PUSH_FPU_RESULT(a_FpuData) \
|
---|
1252 | iemFpuPushResult(pVCpu, &a_FpuData)
|
---|
1253 | /** Pushes FPU result onto the stack and sets the FPUDP. */
|
---|
1254 | #define IEM_MC_PUSH_FPU_RESULT_MEM_OP(a_FpuData, a_iEffSeg, a_GCPtrEff) \
|
---|
1255 | iemFpuPushResultWithMemOp(pVCpu, &a_FpuData, a_iEffSeg, a_GCPtrEff)
|
---|
1256 |
|
---|
1257 | /** Replaces ST0 with value one and pushes value 2 onto the FPU stack. */
|
---|
1258 | #define IEM_MC_PUSH_FPU_RESULT_TWO(a_FpuDataTwo) \
|
---|
1259 | iemFpuPushResultTwo(pVCpu, &a_FpuDataTwo)
|
---|
1260 |
|
---|
1261 | /** Stores FPU result in a stack register. */
|
---|
1262 | #define IEM_MC_STORE_FPU_RESULT(a_FpuData, a_iStReg) \
|
---|
1263 | iemFpuStoreResult(pVCpu, &a_FpuData, a_iStReg)
|
---|
1264 | /** Stores FPU result in a stack register and pops the stack. */
|
---|
1265 | #define IEM_MC_STORE_FPU_RESULT_THEN_POP(a_FpuData, a_iStReg) \
|
---|
1266 | iemFpuStoreResultThenPop(pVCpu, &a_FpuData, a_iStReg)
|
---|
1267 | /** Stores FPU result in a stack register and sets the FPUDP. */
|
---|
1268 | #define IEM_MC_STORE_FPU_RESULT_MEM_OP(a_FpuData, a_iStReg, a_iEffSeg, a_GCPtrEff) \
|
---|
1269 | iemFpuStoreResultWithMemOp(pVCpu, &a_FpuData, a_iStReg, a_iEffSeg, a_GCPtrEff)
|
---|
1270 | /** Stores FPU result in a stack register, sets the FPUDP, and pops the
|
---|
1271 | * stack. */
|
---|
1272 | #define IEM_MC_STORE_FPU_RESULT_WITH_MEM_OP_THEN_POP(a_FpuData, a_iStReg, a_iEffSeg, a_GCPtrEff) \
|
---|
1273 | iemFpuStoreResultWithMemOpThenPop(pVCpu, &a_FpuData, a_iStReg, a_iEffSeg, a_GCPtrEff)
|
---|
1274 |
|
---|
1275 | /** Only update the FOP, FPUIP, and FPUCS. (For FNOP.) */
|
---|
1276 | #define IEM_MC_UPDATE_FPU_OPCODE_IP() \
|
---|
1277 | iemFpuUpdateOpcodeAndIp(pVCpu)
|
---|
1278 | /** Free a stack register (for FFREE and FFREEP). */
|
---|
1279 | #define IEM_MC_FPU_STACK_FREE(a_iStReg) \
|
---|
1280 | iemFpuStackFree(pVCpu, a_iStReg)
|
---|
1281 | /** Increment the FPU stack pointer. */
|
---|
1282 | #define IEM_MC_FPU_STACK_INC_TOP() \
|
---|
1283 | iemFpuStackIncTop(pVCpu)
|
---|
1284 | /** Decrement the FPU stack pointer. */
|
---|
1285 | #define IEM_MC_FPU_STACK_DEC_TOP() \
|
---|
1286 | iemFpuStackDecTop(pVCpu)
|
---|
1287 |
|
---|
1288 | /** Updates the FSW, FOP, FPUIP, and FPUCS. */
|
---|
1289 | #define IEM_MC_UPDATE_FSW(a_u16FSW) \
|
---|
1290 | iemFpuUpdateFSW(pVCpu, a_u16FSW)
|
---|
1291 | /** Updates the FSW with a constant value as well as FOP, FPUIP, and FPUCS. */
|
---|
1292 | #define IEM_MC_UPDATE_FSW_CONST(a_u16FSW) \
|
---|
1293 | iemFpuUpdateFSW(pVCpu, a_u16FSW)
|
---|
1294 | /** Updates the FSW, FOP, FPUIP, FPUCS, FPUDP, and FPUDS. */
|
---|
1295 | #define IEM_MC_UPDATE_FSW_WITH_MEM_OP(a_u16FSW, a_iEffSeg, a_GCPtrEff) \
|
---|
1296 | iemFpuUpdateFSWWithMemOp(pVCpu, a_u16FSW, a_iEffSeg, a_GCPtrEff)
|
---|
1297 | /** Updates the FSW, FOP, FPUIP, and FPUCS, and then pops the stack. */
|
---|
1298 | #define IEM_MC_UPDATE_FSW_THEN_POP(a_u16FSW) \
|
---|
1299 | iemFpuUpdateFSWThenPop(pVCpu, a_u16FSW)
|
---|
1300 | /** Updates the FSW, FOP, FPUIP, FPUCS, FPUDP and FPUDS, and then pops the
|
---|
1301 | * stack. */
|
---|
1302 | #define IEM_MC_UPDATE_FSW_WITH_MEM_OP_THEN_POP(a_u16FSW, a_iEffSeg, a_GCPtrEff) \
|
---|
1303 | iemFpuUpdateFSWWithMemOpThenPop(pVCpu, a_u16FSW, a_iEffSeg, a_GCPtrEff)
|
---|
1304 | /** Updates the FSW, FOP, FPUIP, and FPUCS, and then pops the stack twice. */
|
---|
1305 | #define IEM_MC_UPDATE_FSW_THEN_POP_POP(a_u16FSW) \
|
---|
1306 | iemFpuUpdateFSWThenPopPop(pVCpu, a_u16FSW)
|
---|
1307 |
|
---|
1308 | /** Raises a FPU stack underflow exception. Sets FPUIP, FPUCS and FOP. */
|
---|
1309 | #define IEM_MC_FPU_STACK_UNDERFLOW(a_iStDst) \
|
---|
1310 | iemFpuStackUnderflow(pVCpu, a_iStDst)
|
---|
1311 | /** Raises a FPU stack underflow exception. Sets FPUIP, FPUCS and FOP. Pops
|
---|
1312 | * stack. */
|
---|
1313 | #define IEM_MC_FPU_STACK_UNDERFLOW_THEN_POP(a_iStDst) \
|
---|
1314 | iemFpuStackUnderflowThenPop(pVCpu, a_iStDst)
|
---|
1315 | /** Raises a FPU stack underflow exception. Sets FPUIP, FPUCS, FOP, FPUDP and
|
---|
1316 | * FPUDS. */
|
---|
1317 | #define IEM_MC_FPU_STACK_UNDERFLOW_MEM_OP(a_iStDst, a_iEffSeg, a_GCPtrEff) \
|
---|
1318 | iemFpuStackUnderflowWithMemOp(pVCpu, a_iStDst, a_iEffSeg, a_GCPtrEff)
|
---|
1319 | /** Raises a FPU stack underflow exception. Sets FPUIP, FPUCS, FOP, FPUDP and
|
---|
1320 | * FPUDS. Pops stack. */
|
---|
1321 | #define IEM_MC_FPU_STACK_UNDERFLOW_MEM_OP_THEN_POP(a_iStDst, a_iEffSeg, a_GCPtrEff) \
|
---|
1322 | iemFpuStackUnderflowWithMemOpThenPop(pVCpu, a_iStDst, a_iEffSeg, a_GCPtrEff)
|
---|
1323 | /** Raises a FPU stack underflow exception. Sets FPUIP, FPUCS and FOP. Pops
|
---|
1324 | * stack twice. */
|
---|
1325 | #define IEM_MC_FPU_STACK_UNDERFLOW_THEN_POP_POP() \
|
---|
1326 | iemFpuStackUnderflowThenPopPop(pVCpu)
|
---|
1327 | /** Raises a FPU stack underflow exception for an instruction pushing a result
|
---|
1328 | * value onto the stack. Sets FPUIP, FPUCS and FOP. */
|
---|
1329 | #define IEM_MC_FPU_STACK_PUSH_UNDERFLOW() \
|
---|
1330 | iemFpuStackPushUnderflow(pVCpu)
|
---|
1331 | /** Raises a FPU stack underflow exception for an instruction pushing a result
|
---|
1332 | * value onto the stack and replacing ST0. Sets FPUIP, FPUCS and FOP. */
|
---|
1333 | #define IEM_MC_FPU_STACK_PUSH_UNDERFLOW_TWO() \
|
---|
1334 | iemFpuStackPushUnderflowTwo(pVCpu)
|
---|
1335 |
|
---|
1336 | /** Raises a FPU stack overflow exception as part of a push attempt. Sets
|
---|
1337 | * FPUIP, FPUCS and FOP. */
|
---|
1338 | #define IEM_MC_FPU_STACK_PUSH_OVERFLOW() \
|
---|
1339 | iemFpuStackPushOverflow(pVCpu)
|
---|
1340 | /** Raises a FPU stack overflow exception as part of a push attempt. Sets
|
---|
1341 | * FPUIP, FPUCS, FOP, FPUDP and FPUDS. */
|
---|
1342 | #define IEM_MC_FPU_STACK_PUSH_OVERFLOW_MEM_OP(a_iEffSeg, a_GCPtrEff) \
|
---|
1343 | iemFpuStackPushOverflowWithMemOp(pVCpu, a_iEffSeg, a_GCPtrEff)
|
---|
1344 | /** Prepares for using the FPU state.
|
---|
1345 | * Ensures that we can use the host FPU in the current context (RC+R0.
|
---|
1346 | * Ensures the guest FPU state in the CPUMCTX is up to date. */
|
---|
1347 | #define IEM_MC_PREPARE_FPU_USAGE() iemFpuPrepareUsage(pVCpu)
|
---|
1348 | /** Actualizes the guest FPU state so it can be accessed read-only fashion. */
|
---|
1349 | #define IEM_MC_ACTUALIZE_FPU_STATE_FOR_READ() iemFpuActualizeStateForRead(pVCpu)
|
---|
1350 | /** Actualizes the guest FPU state so it can be accessed and modified. */
|
---|
1351 | #define IEM_MC_ACTUALIZE_FPU_STATE_FOR_CHANGE() iemFpuActualizeStateForChange(pVCpu)
|
---|
1352 |
|
---|
1353 | /** Stores SSE SIMD result updating MXCSR. */
|
---|
1354 | #define IEM_MC_STORE_SSE_RESULT(a_SseData, a_iXmmReg) \
|
---|
1355 | iemSseStoreResult(pVCpu, &a_SseData, a_iXmmReg)
|
---|
1356 | /** Updates MXCSR. */
|
---|
1357 | #define IEM_MC_SSE_UPDATE_MXCSR(a_fMxcsr) \
|
---|
1358 | iemSseUpdateMxcsr(pVCpu, a_fMxcsr)
|
---|
1359 |
|
---|
1360 | /** Prepares for using the SSE state.
|
---|
1361 | * Ensures that we can use the host SSE/FPU in the current context (RC+R0.
|
---|
1362 | * Ensures the guest SSE state in the CPUMCTX is up to date. */
|
---|
1363 | #define IEM_MC_PREPARE_SSE_USAGE() iemFpuPrepareUsageSse(pVCpu)
|
---|
1364 | /** Actualizes the guest XMM0..15 and MXCSR register state for read-only access. */
|
---|
1365 | #define IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ() iemFpuActualizeSseStateForRead(pVCpu)
|
---|
1366 | /** Actualizes the guest XMM0..15 and MXCSR register state for read-write access. */
|
---|
1367 | #define IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE() iemFpuActualizeSseStateForChange(pVCpu)
|
---|
1368 |
|
---|
1369 | /** Prepares for using the AVX state.
|
---|
1370 | * Ensures that we can use the host AVX/FPU in the current context (RC+R0.
|
---|
1371 | * Ensures the guest AVX state in the CPUMCTX is up to date.
|
---|
1372 | * @note This will include the AVX512 state too when support for it is added
|
---|
1373 | * due to the zero extending feature of VEX instruction. */
|
---|
1374 | #define IEM_MC_PREPARE_AVX_USAGE() iemFpuPrepareUsageAvx(pVCpu)
|
---|
1375 | /** Actualizes the guest XMM0..15 and MXCSR register state for read-only access. */
|
---|
1376 | #define IEM_MC_ACTUALIZE_AVX_STATE_FOR_READ() iemFpuActualizeAvxStateForRead(pVCpu)
|
---|
1377 | /** Actualizes the guest YMM0..15 and MXCSR register state for read-write access. */
|
---|
1378 | #define IEM_MC_ACTUALIZE_AVX_STATE_FOR_CHANGE() iemFpuActualizeAvxStateForChange(pVCpu)
|
---|
1379 |
|
---|
1380 | /**
|
---|
1381 | * Calls a MMX assembly implementation taking two visible arguments.
|
---|
1382 | *
|
---|
1383 | * @param a_pfnAImpl Pointer to the assembly MMX routine.
|
---|
1384 | * @param a0 The first extra argument.
|
---|
1385 | * @param a1 The second extra argument.
|
---|
1386 | */
|
---|
1387 | #define IEM_MC_CALL_MMX_AIMPL_2(a_pfnAImpl, a0, a1) \
|
---|
1388 | do { \
|
---|
1389 | IEM_MC_PREPARE_FPU_USAGE(); \
|
---|
1390 | a_pfnAImpl(&pVCpu->cpum.GstCtx.XState.x87, (a0), (a1)); \
|
---|
1391 | } while (0)
|
---|
1392 |
|
---|
1393 | /**
|
---|
1394 | * Calls a MMX assembly implementation taking three visible arguments.
|
---|
1395 | *
|
---|
1396 | * @param a_pfnAImpl Pointer to the assembly MMX routine.
|
---|
1397 | * @param a0 The first extra argument.
|
---|
1398 | * @param a1 The second extra argument.
|
---|
1399 | * @param a2 The third extra argument.
|
---|
1400 | */
|
---|
1401 | #define IEM_MC_CALL_MMX_AIMPL_3(a_pfnAImpl, a0, a1, a2) \
|
---|
1402 | do { \
|
---|
1403 | IEM_MC_PREPARE_FPU_USAGE(); \
|
---|
1404 | a_pfnAImpl(&pVCpu->cpum.GstCtx.XState.x87, (a0), (a1), (a2)); \
|
---|
1405 | } while (0)
|
---|
1406 |
|
---|
1407 |
|
---|
1408 | /**
|
---|
1409 | * Calls a SSE assembly implementation taking two visible arguments.
|
---|
1410 | *
|
---|
1411 | * @param a_pfnAImpl Pointer to the assembly SSE routine.
|
---|
1412 | * @param a0 The first extra argument.
|
---|
1413 | * @param a1 The second extra argument.
|
---|
1414 | */
|
---|
1415 | #define IEM_MC_CALL_SSE_AIMPL_2(a_pfnAImpl, a0, a1) \
|
---|
1416 | do { \
|
---|
1417 | IEM_MC_PREPARE_SSE_USAGE(); \
|
---|
1418 | a_pfnAImpl(&pVCpu->cpum.GstCtx.XState.x87, (a0), (a1)); \
|
---|
1419 | } while (0)
|
---|
1420 |
|
---|
1421 | /**
|
---|
1422 | * Calls a SSE assembly implementation taking three visible arguments.
|
---|
1423 | *
|
---|
1424 | * @param a_pfnAImpl Pointer to the assembly SSE routine.
|
---|
1425 | * @param a0 The first extra argument.
|
---|
1426 | * @param a1 The second extra argument.
|
---|
1427 | * @param a2 The third extra argument.
|
---|
1428 | */
|
---|
1429 | #define IEM_MC_CALL_SSE_AIMPL_3(a_pfnAImpl, a0, a1, a2) \
|
---|
1430 | do { \
|
---|
1431 | IEM_MC_PREPARE_SSE_USAGE(); \
|
---|
1432 | a_pfnAImpl(&pVCpu->cpum.GstCtx.XState.x87, (a0), (a1), (a2)); \
|
---|
1433 | } while (0)
|
---|
1434 |
|
---|
1435 |
|
---|
1436 | /** Declares implicit arguments for IEM_MC_CALL_AVX_AIMPL_2,
|
---|
1437 | * IEM_MC_CALL_AVX_AIMPL_3, IEM_MC_CALL_AVX_AIMPL_4, ... */
|
---|
1438 | #define IEM_MC_IMPLICIT_AVX_AIMPL_ARGS() \
|
---|
1439 | IEM_MC_ARG_CONST(PX86XSAVEAREA, pXState, &pVCpu->cpum.GstCtx.XState, 0)
|
---|
1440 |
|
---|
1441 | /**
|
---|
1442 | * Calls a AVX assembly implementation taking two visible arguments.
|
---|
1443 | *
|
---|
1444 | * There is one implicit zero'th argument, a pointer to the extended state.
|
---|
1445 | *
|
---|
1446 | * @param a_pfnAImpl Pointer to the assembly AVX routine.
|
---|
1447 | * @param a1 The first extra argument.
|
---|
1448 | * @param a2 The second extra argument.
|
---|
1449 | */
|
---|
1450 | #define IEM_MC_CALL_AVX_AIMPL_2(a_pfnAImpl, a1, a2) \
|
---|
1451 | do { \
|
---|
1452 | IEM_MC_PREPARE_AVX_USAGE(); \
|
---|
1453 | a_pfnAImpl(pXState, (a1), (a2)); \
|
---|
1454 | } while (0)
|
---|
1455 |
|
---|
1456 | /**
|
---|
1457 | * Calls a AVX assembly implementation taking three visible arguments.
|
---|
1458 | *
|
---|
1459 | * There is one implicit zero'th argument, a pointer to the extended state.
|
---|
1460 | *
|
---|
1461 | * @param a_pfnAImpl Pointer to the assembly AVX routine.
|
---|
1462 | * @param a1 The first extra argument.
|
---|
1463 | * @param a2 The second extra argument.
|
---|
1464 | * @param a3 The third extra argument.
|
---|
1465 | */
|
---|
1466 | #define IEM_MC_CALL_AVX_AIMPL_3(a_pfnAImpl, a1, a2, a3) \
|
---|
1467 | do { \
|
---|
1468 | IEM_MC_PREPARE_AVX_USAGE(); \
|
---|
1469 | a_pfnAImpl(pXState, (a1), (a2), (a3)); \
|
---|
1470 | } while (0)
|
---|
1471 |
|
---|
1472 | /** @note Not for IOPL or IF testing. */
|
---|
1473 | #define IEM_MC_IF_EFL_BIT_SET(a_fBit) if (pVCpu->cpum.GstCtx.eflags.u & (a_fBit)) {
|
---|
1474 | /** @note Not for IOPL or IF testing. */
|
---|
1475 | #define IEM_MC_IF_EFL_BIT_NOT_SET(a_fBit) if (!(pVCpu->cpum.GstCtx.eflags.u & (a_fBit))) {
|
---|
1476 | /** @note Not for IOPL or IF testing. */
|
---|
1477 | #define IEM_MC_IF_EFL_ANY_BITS_SET(a_fBits) if (pVCpu->cpum.GstCtx.eflags.u & (a_fBits)) {
|
---|
1478 | /** @note Not for IOPL or IF testing. */
|
---|
1479 | #define IEM_MC_IF_EFL_NO_BITS_SET(a_fBits) if (!(pVCpu->cpum.GstCtx.eflags.u & (a_fBits))) {
|
---|
1480 | /** @note Not for IOPL or IF testing. */
|
---|
1481 | #define IEM_MC_IF_EFL_BITS_NE(a_fBit1, a_fBit2) \
|
---|
1482 | if ( !!(pVCpu->cpum.GstCtx.eflags.u & (a_fBit1)) \
|
---|
1483 | != !!(pVCpu->cpum.GstCtx.eflags.u & (a_fBit2)) ) {
|
---|
1484 | /** @note Not for IOPL or IF testing. */
|
---|
1485 | #define IEM_MC_IF_EFL_BITS_EQ(a_fBit1, a_fBit2) \
|
---|
1486 | if ( !!(pVCpu->cpum.GstCtx.eflags.u & (a_fBit1)) \
|
---|
1487 | == !!(pVCpu->cpum.GstCtx.eflags.u & (a_fBit2)) ) {
|
---|
1488 | /** @note Not for IOPL or IF testing. */
|
---|
1489 | #define IEM_MC_IF_EFL_BIT_SET_OR_BITS_NE(a_fBit, a_fBit1, a_fBit2) \
|
---|
1490 | if ( (pVCpu->cpum.GstCtx.eflags.u & (a_fBit)) \
|
---|
1491 | || !!(pVCpu->cpum.GstCtx.eflags.u & (a_fBit1)) \
|
---|
1492 | != !!(pVCpu->cpum.GstCtx.eflags.u & (a_fBit2)) ) {
|
---|
1493 | /** @note Not for IOPL or IF testing. */
|
---|
1494 | #define IEM_MC_IF_EFL_BIT_NOT_SET_AND_BITS_EQ(a_fBit, a_fBit1, a_fBit2) \
|
---|
1495 | if ( !(pVCpu->cpum.GstCtx.eflags.u & (a_fBit)) \
|
---|
1496 | && !!(pVCpu->cpum.GstCtx.eflags.u & (a_fBit1)) \
|
---|
1497 | == !!(pVCpu->cpum.GstCtx.eflags.u & (a_fBit2)) ) {
|
---|
1498 | #define IEM_MC_IF_CX_IS_NZ() if (pVCpu->cpum.GstCtx.cx != 0) {
|
---|
1499 | #define IEM_MC_IF_ECX_IS_NZ() if (pVCpu->cpum.GstCtx.ecx != 0) {
|
---|
1500 | #define IEM_MC_IF_RCX_IS_NZ() if (pVCpu->cpum.GstCtx.rcx != 0) {
|
---|
1501 | /** @note Not for IOPL or IF testing. */
|
---|
1502 | #define IEM_MC_IF_CX_IS_NZ_AND_EFL_BIT_SET(a_fBit) \
|
---|
1503 | if ( pVCpu->cpum.GstCtx.cx != 0 \
|
---|
1504 | && (pVCpu->cpum.GstCtx.eflags.u & a_fBit)) {
|
---|
1505 | /** @note Not for IOPL or IF testing. */
|
---|
1506 | #define IEM_MC_IF_ECX_IS_NZ_AND_EFL_BIT_SET(a_fBit) \
|
---|
1507 | if ( pVCpu->cpum.GstCtx.ecx != 0 \
|
---|
1508 | && (pVCpu->cpum.GstCtx.eflags.u & a_fBit)) {
|
---|
1509 | /** @note Not for IOPL or IF testing. */
|
---|
1510 | #define IEM_MC_IF_RCX_IS_NZ_AND_EFL_BIT_SET(a_fBit) \
|
---|
1511 | if ( pVCpu->cpum.GstCtx.rcx != 0 \
|
---|
1512 | && (pVCpu->cpum.GstCtx.eflags.u & a_fBit)) {
|
---|
1513 | /** @note Not for IOPL or IF testing. */
|
---|
1514 | #define IEM_MC_IF_CX_IS_NZ_AND_EFL_BIT_NOT_SET(a_fBit) \
|
---|
1515 | if ( pVCpu->cpum.GstCtx.cx != 0 \
|
---|
1516 | && !(pVCpu->cpum.GstCtx.eflags.u & a_fBit)) {
|
---|
1517 | /** @note Not for IOPL or IF testing. */
|
---|
1518 | #define IEM_MC_IF_ECX_IS_NZ_AND_EFL_BIT_NOT_SET(a_fBit) \
|
---|
1519 | if ( pVCpu->cpum.GstCtx.ecx != 0 \
|
---|
1520 | && !(pVCpu->cpum.GstCtx.eflags.u & a_fBit)) {
|
---|
1521 | /** @note Not for IOPL or IF testing. */
|
---|
1522 | #define IEM_MC_IF_RCX_IS_NZ_AND_EFL_BIT_NOT_SET(a_fBit) \
|
---|
1523 | if ( pVCpu->cpum.GstCtx.rcx != 0 \
|
---|
1524 | && !(pVCpu->cpum.GstCtx.eflags.u & a_fBit)) {
|
---|
1525 | #define IEM_MC_IF_LOCAL_IS_Z(a_Local) if ((a_Local) == 0) {
|
---|
1526 | #define IEM_MC_IF_GREG_BIT_SET(a_iGReg, a_iBitNo) if (iemGRegFetchU64(pVCpu, (a_iGReg)) & RT_BIT_64(a_iBitNo)) {
|
---|
1527 |
|
---|
1528 | #define IEM_MC_REF_FPUREG(a_pr80Dst, a_iSt) \
|
---|
1529 | do { (a_pr80Dst) = &pVCpu->cpum.GstCtx.XState.x87.aRegs[X86_FSW_TOP_GET_ST(pVCpu->cpum.GstCtx.XState.x87.FSW, a_iSt)].r80; } while (0)
|
---|
1530 | #define IEM_MC_IF_FPUREG_IS_EMPTY(a_iSt) \
|
---|
1531 | if (iemFpuStRegNotEmpty(pVCpu, (a_iSt)) != VINF_SUCCESS) {
|
---|
1532 | #define IEM_MC_IF_FPUREG_NOT_EMPTY(a_iSt) \
|
---|
1533 | if (iemFpuStRegNotEmpty(pVCpu, (a_iSt)) == VINF_SUCCESS) {
|
---|
1534 | #define IEM_MC_IF_FPUREG_IS_EMPTY(a_iSt) \
|
---|
1535 | if (iemFpuStRegNotEmpty(pVCpu, (a_iSt)) != VINF_SUCCESS) {
|
---|
1536 | #define IEM_MC_IF_FPUREG_NOT_EMPTY_REF_R80(a_pr80Dst, a_iSt) \
|
---|
1537 | if (iemFpuStRegNotEmptyRef(pVCpu, (a_iSt), &(a_pr80Dst)) == VINF_SUCCESS) {
|
---|
1538 | #define IEM_MC_IF_TWO_FPUREGS_NOT_EMPTY_REF_R80(a_pr80Dst0, a_iSt0, a_pr80Dst1, a_iSt1) \
|
---|
1539 | if (iemFpu2StRegsNotEmptyRef(pVCpu, (a_iSt0), &(a_pr80Dst0), (a_iSt1), &(a_pr80Dst1)) == VINF_SUCCESS) {
|
---|
1540 | #define IEM_MC_IF_TWO_FPUREGS_NOT_EMPTY_REF_R80_FIRST(a_pr80Dst0, a_iSt0, a_iSt1) \
|
---|
1541 | if (iemFpu2StRegsNotEmptyRefFirst(pVCpu, (a_iSt0), &(a_pr80Dst0), (a_iSt1)) == VINF_SUCCESS) {
|
---|
1542 | #define IEM_MC_IF_FCW_IM() \
|
---|
1543 | if (pVCpu->cpum.GstCtx.XState.x87.FCW & X86_FCW_IM) {
|
---|
1544 | #define IEM_MC_IF_MXCSR_XCPT_PENDING() \
|
---|
1545 | if (( ~((pVCpu->cpum.GstCtx.XState.x87.MXCSR & X86_MXCSR_XCPT_MASK) >> X86_MXCSR_XCPT_MASK_SHIFT) \
|
---|
1546 | & (pVCpu->cpum.GstCtx.XState.x87.MXCSR & X86_MXCSR_XCPT_FLAGS)) != 0) {
|
---|
1547 |
|
---|
1548 | #define IEM_MC_ELSE() } else {
|
---|
1549 | #define IEM_MC_ENDIF() } do {} while (0)
|
---|
1550 |
|
---|
1551 | /** @} */
|
---|
1552 |
|
---|
1553 | #endif /* !VMM_INCLUDED_SRC_include_IEMMc_h */
|
---|
1554 |
|
---|