VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMAll/IEMAllInstTwoByte0f.cpp.h@ 102719

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

VMM/IEM: Corrected missing clobbering of kIemNativeGstReg_SegAttrib*. bugref:10371

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 523.8 KB
Line 
1/* $Id: IEMAllInstTwoByte0f.cpp.h 102719 2023-12-28 00:27:07Z vboxsync $ */
2/** @file
3 * IEM - Instruction Decoding and Emulation.
4 *
5 * @remarks IEMAllInstVexMap1.cpp.h is a VEX mirror of this file.
6 * Any update here is likely needed in that file too.
7 */
8
9/*
10 * Copyright (C) 2011-2023 Oracle and/or its affiliates.
11 *
12 * This file is part of VirtualBox base platform packages, as
13 * available from https://www.virtualbox.org.
14 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation, in version 3 of the
18 * License.
19 *
20 * This program is distributed in the hope that it will be useful, but
21 * WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 * General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, see <https://www.gnu.org/licenses>.
27 *
28 * SPDX-License-Identifier: GPL-3.0-only
29 */
30
31
32/** @name Two byte opcodes (first byte 0x0f).
33 *
34 * @{
35 */
36
37
38/**
39 * Common worker for MMX instructions on the form:
40 * pxxx mm1, mm2/mem64
41 */
42FNIEMOP_DEF_1(iemOpCommonMmx_FullFull_To_Full, PFNIEMAIMPLMEDIAF2U64, pfnU64)
43{
44 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
45 if (IEM_IS_MODRM_REG_MODE(bRm))
46 {
47 /*
48 * MMX, MMX.
49 */
50 /** @todo testcase: REX.B / REX.R and MMX register indexing. Ignored? */
51 /** @todo testcase: REX.B / REX.R and segment register indexing. Ignored? */
52 IEM_MC_BEGIN(2, 0, IEM_MC_F_NOT_286_OR_OLDER, 0);
53 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fMmx);
54 IEM_MC_ARG(uint64_t *, pDst, 0);
55 IEM_MC_ARG(uint64_t const *, pSrc, 1);
56 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
57 IEM_MC_PREPARE_FPU_USAGE();
58 IEM_MC_FPU_TO_MMX_MODE();
59
60 IEM_MC_REF_MREG_U64(pDst, IEM_GET_MODRM_REG_8(bRm));
61 IEM_MC_REF_MREG_U64_CONST(pSrc, IEM_GET_MODRM_RM_8(bRm));
62 IEM_MC_CALL_MMX_AIMPL_2(pfnU64, pDst, pSrc);
63 IEM_MC_MODIFIED_MREG_BY_REF(pDst);
64
65 IEM_MC_ADVANCE_RIP_AND_FINISH();
66 IEM_MC_END();
67 }
68 else
69 {
70 /*
71 * MMX, [mem64].
72 */
73 IEM_MC_BEGIN(2, 2, IEM_MC_F_NOT_286_OR_OLDER, 0);
74 IEM_MC_ARG(uint64_t *, pDst, 0);
75 IEM_MC_LOCAL(uint64_t, uSrc);
76 IEM_MC_ARG_LOCAL_REF(uint64_t const *, pSrc, uSrc, 1);
77 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
78
79 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
80 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fMmx);
81 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
82 IEM_MC_FETCH_MEM_U64(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
83
84 IEM_MC_PREPARE_FPU_USAGE();
85 IEM_MC_FPU_TO_MMX_MODE();
86
87 IEM_MC_REF_MREG_U64(pDst, IEM_GET_MODRM_REG_8(bRm));
88 IEM_MC_CALL_MMX_AIMPL_2(pfnU64, pDst, pSrc);
89 IEM_MC_MODIFIED_MREG_BY_REF(pDst);
90
91 IEM_MC_ADVANCE_RIP_AND_FINISH();
92 IEM_MC_END();
93 }
94}
95
96
97/**
98 * Common worker for MMX instructions on the form:
99 * pxxx mm1, mm2/mem64
100 *
101 * Unlike iemOpCommonMmx_FullFull_To_Full, the @a pfnU64 worker function takes
102 * no FXSAVE state, just the operands.
103 */
104FNIEMOP_DEF_1(iemOpCommonMmxOpt_FullFull_To_Full, PFNIEMAIMPLMEDIAOPTF2U64, pfnU64)
105{
106 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
107 if (IEM_IS_MODRM_REG_MODE(bRm))
108 {
109 /*
110 * MMX, MMX.
111 */
112 /** @todo testcase: REX.B / REX.R and MMX register indexing. Ignored? */
113 /** @todo testcase: REX.B / REX.R and segment register indexing. Ignored? */
114 IEM_MC_BEGIN(2, 0, IEM_MC_F_NOT_286_OR_OLDER, 0);
115 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fMmx);
116 IEM_MC_ARG(uint64_t *, pDst, 0);
117 IEM_MC_ARG(uint64_t const *, pSrc, 1);
118 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
119 IEM_MC_PREPARE_FPU_USAGE();
120 IEM_MC_FPU_TO_MMX_MODE();
121
122 IEM_MC_REF_MREG_U64(pDst, IEM_GET_MODRM_REG_8(bRm));
123 IEM_MC_REF_MREG_U64_CONST(pSrc, IEM_GET_MODRM_RM_8(bRm));
124 IEM_MC_CALL_VOID_AIMPL_2(pfnU64, pDst, pSrc);
125 IEM_MC_MODIFIED_MREG_BY_REF(pDst);
126
127 IEM_MC_ADVANCE_RIP_AND_FINISH();
128 IEM_MC_END();
129 }
130 else
131 {
132 /*
133 * MMX, [mem64].
134 */
135 IEM_MC_BEGIN(2, 2, IEM_MC_F_NOT_286_OR_OLDER, 0);
136 IEM_MC_ARG(uint64_t *, pDst, 0);
137 IEM_MC_LOCAL(uint64_t, uSrc);
138 IEM_MC_ARG_LOCAL_REF(uint64_t const *, pSrc, uSrc, 1);
139 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
140
141 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
142 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fMmx);
143 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
144 IEM_MC_FETCH_MEM_U64(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
145
146 IEM_MC_PREPARE_FPU_USAGE();
147 IEM_MC_FPU_TO_MMX_MODE();
148
149 IEM_MC_REF_MREG_U64(pDst, IEM_GET_MODRM_REG_8(bRm));
150 IEM_MC_CALL_VOID_AIMPL_2(pfnU64, pDst, pSrc);
151 IEM_MC_MODIFIED_MREG_BY_REF(pDst);
152
153 IEM_MC_ADVANCE_RIP_AND_FINISH();
154 IEM_MC_END();
155 }
156}
157
158
159/**
160 * Common worker for MMX instructions on the form:
161 * pxxx mm1, mm2/mem64
162 * for instructions introduced with SSE.
163 */
164FNIEMOP_DEF_1(iemOpCommonMmxSse_FullFull_To_Full, PFNIEMAIMPLMEDIAF2U64, pfnU64)
165{
166 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
167 if (IEM_IS_MODRM_REG_MODE(bRm))
168 {
169 /*
170 * MMX, MMX.
171 */
172 /** @todo testcase: REX.B / REX.R and MMX register indexing. Ignored? */
173 /** @todo testcase: REX.B / REX.R and segment register indexing. Ignored? */
174 IEM_MC_BEGIN(2, 0, IEM_MC_F_NOT_286_OR_OLDER, 0);
175 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX_2_OR(fSse, fAmdMmxExts);
176 IEM_MC_ARG(uint64_t *, pDst, 0);
177 IEM_MC_ARG(uint64_t const *, pSrc, 1);
178 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
179 IEM_MC_PREPARE_FPU_USAGE();
180 IEM_MC_FPU_TO_MMX_MODE();
181
182 IEM_MC_REF_MREG_U64(pDst, IEM_GET_MODRM_REG_8(bRm));
183 IEM_MC_REF_MREG_U64_CONST(pSrc, IEM_GET_MODRM_RM_8(bRm));
184 IEM_MC_CALL_MMX_AIMPL_2(pfnU64, pDst, pSrc);
185 IEM_MC_MODIFIED_MREG_BY_REF(pDst);
186
187 IEM_MC_ADVANCE_RIP_AND_FINISH();
188 IEM_MC_END();
189 }
190 else
191 {
192 /*
193 * MMX, [mem64].
194 */
195 IEM_MC_BEGIN(2, 2, IEM_MC_F_NOT_286_OR_OLDER, 0);
196 IEM_MC_ARG(uint64_t *, pDst, 0);
197 IEM_MC_LOCAL(uint64_t, uSrc);
198 IEM_MC_ARG_LOCAL_REF(uint64_t const *, pSrc, uSrc, 1);
199 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
200
201 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
202 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX_2_OR(fSse, fAmdMmxExts);
203 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
204 IEM_MC_FETCH_MEM_U64(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
205
206 IEM_MC_PREPARE_FPU_USAGE();
207 IEM_MC_FPU_TO_MMX_MODE();
208
209 IEM_MC_REF_MREG_U64(pDst, IEM_GET_MODRM_REG_8(bRm));
210 IEM_MC_CALL_MMX_AIMPL_2(pfnU64, pDst, pSrc);
211 IEM_MC_MODIFIED_MREG_BY_REF(pDst);
212
213 IEM_MC_ADVANCE_RIP_AND_FINISH();
214 IEM_MC_END();
215 }
216}
217
218
219/**
220 * Common worker for MMX instructions on the form:
221 * pxxx mm1, mm2/mem64
222 * for instructions introduced with SSE.
223 *
224 * Unlike iemOpCommonMmxSse_FullFull_To_Full, the @a pfnU64 worker function takes
225 * no FXSAVE state, just the operands.
226 */
227FNIEMOP_DEF_1(iemOpCommonMmxSseOpt_FullFull_To_Full, PFNIEMAIMPLMEDIAOPTF2U64, pfnU64)
228{
229 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
230 if (IEM_IS_MODRM_REG_MODE(bRm))
231 {
232 /*
233 * MMX, MMX.
234 */
235 /** @todo testcase: REX.B / REX.R and MMX register indexing. Ignored? */
236 /** @todo testcase: REX.B / REX.R and segment register indexing. Ignored? */
237 IEM_MC_BEGIN(2, 0, IEM_MC_F_NOT_286_OR_OLDER, 0);
238 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX_2_OR(fSse, fAmdMmxExts);
239 IEM_MC_ARG(uint64_t *, pDst, 0);
240 IEM_MC_ARG(uint64_t const *, pSrc, 1);
241 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
242 IEM_MC_PREPARE_FPU_USAGE();
243 IEM_MC_FPU_TO_MMX_MODE();
244
245 IEM_MC_REF_MREG_U64(pDst, IEM_GET_MODRM_REG_8(bRm));
246 IEM_MC_REF_MREG_U64_CONST(pSrc, IEM_GET_MODRM_RM_8(bRm));
247 IEM_MC_CALL_VOID_AIMPL_2(pfnU64, pDst, pSrc);
248 IEM_MC_MODIFIED_MREG_BY_REF(pDst);
249
250 IEM_MC_ADVANCE_RIP_AND_FINISH();
251 IEM_MC_END();
252 }
253 else
254 {
255 /*
256 * MMX, [mem64].
257 */
258 IEM_MC_BEGIN(2, 2, IEM_MC_F_NOT_286_OR_OLDER, 0);
259 IEM_MC_ARG(uint64_t *, pDst, 0);
260 IEM_MC_LOCAL(uint64_t, uSrc);
261 IEM_MC_ARG_LOCAL_REF(uint64_t const *, pSrc, uSrc, 1);
262 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
263
264 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
265 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX_2_OR(fSse, fAmdMmxExts);
266 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
267 IEM_MC_FETCH_MEM_U64(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
268
269 IEM_MC_PREPARE_FPU_USAGE();
270 IEM_MC_FPU_TO_MMX_MODE();
271
272 IEM_MC_REF_MREG_U64(pDst, IEM_GET_MODRM_REG_8(bRm));
273 IEM_MC_CALL_VOID_AIMPL_2(pfnU64, pDst, pSrc);
274 IEM_MC_MODIFIED_MREG_BY_REF(pDst);
275
276 IEM_MC_ADVANCE_RIP_AND_FINISH();
277 IEM_MC_END();
278 }
279}
280
281
282/**
283 * Common worker for MMX instructions on the form:
284 * pxxx mm1, mm2/mem64
285 * that was introduced with SSE2.
286 */
287FNIEMOP_DEF_1(iemOpCommonMmx_FullFull_To_Full_Sse2, PFNIEMAIMPLMEDIAF2U64, pfnU64)
288{
289 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
290 if (IEM_IS_MODRM_REG_MODE(bRm))
291 {
292 /*
293 * MMX, MMX.
294 */
295 /** @todo testcase: REX.B / REX.R and MMX register indexing. Ignored? */
296 /** @todo testcase: REX.B / REX.R and segment register indexing. Ignored? */
297 IEM_MC_BEGIN(2, 0, IEM_MC_F_NOT_286_OR_OLDER, 0);
298 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
299 IEM_MC_ARG(uint64_t *, pDst, 0);
300 IEM_MC_ARG(uint64_t const *, pSrc, 1);
301 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
302 IEM_MC_PREPARE_FPU_USAGE();
303 IEM_MC_FPU_TO_MMX_MODE();
304
305 IEM_MC_REF_MREG_U64(pDst, IEM_GET_MODRM_REG_8(bRm));
306 IEM_MC_REF_MREG_U64_CONST(pSrc, IEM_GET_MODRM_RM_8(bRm));
307 IEM_MC_CALL_MMX_AIMPL_2(pfnU64, pDst, pSrc);
308 IEM_MC_MODIFIED_MREG_BY_REF(pDst);
309
310 IEM_MC_ADVANCE_RIP_AND_FINISH();
311 IEM_MC_END();
312 }
313 else
314 {
315 /*
316 * MMX, [mem64].
317 */
318 IEM_MC_BEGIN(2, 2, IEM_MC_F_NOT_286_OR_OLDER, 0);
319 IEM_MC_ARG(uint64_t *, pDst, 0);
320 IEM_MC_LOCAL(uint64_t, uSrc);
321 IEM_MC_ARG_LOCAL_REF(uint64_t const *, pSrc, uSrc, 1);
322 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
323
324 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
325 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
326 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
327 IEM_MC_FETCH_MEM_U64(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
328
329 IEM_MC_PREPARE_FPU_USAGE();
330 IEM_MC_FPU_TO_MMX_MODE();
331
332 IEM_MC_REF_MREG_U64(pDst, IEM_GET_MODRM_REG_8(bRm));
333 IEM_MC_CALL_MMX_AIMPL_2(pfnU64, pDst, pSrc);
334 IEM_MC_MODIFIED_MREG_BY_REF(pDst);
335
336 IEM_MC_ADVANCE_RIP_AND_FINISH();
337 IEM_MC_END();
338 }
339}
340
341
342/**
343 * Common worker for SSE instructions of the form:
344 * pxxx xmm1, xmm2/mem128
345 *
346 * Proper alignment of the 128-bit operand is enforced.
347 * SSE cpuid checks. No SIMD FP exceptions.
348 *
349 * @sa iemOpCommonSse2_FullFull_To_Full
350 */
351FNIEMOP_DEF_1(iemOpCommonSse_FullFull_To_Full, PFNIEMAIMPLMEDIAF2U128, pfnU128)
352{
353 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
354 if (IEM_IS_MODRM_REG_MODE(bRm))
355 {
356 /*
357 * XMM, XMM.
358 */
359 IEM_MC_BEGIN(2, 0, IEM_MC_F_NOT_286_OR_OLDER, 0);
360 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
361 IEM_MC_ARG(PRTUINT128U, pDst, 0);
362 IEM_MC_ARG(PCRTUINT128U, pSrc, 1);
363 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
364 IEM_MC_PREPARE_SSE_USAGE();
365 IEM_MC_REF_XREG_U128(pDst, IEM_GET_MODRM_REG(pVCpu, bRm));
366 IEM_MC_REF_XREG_U128_CONST(pSrc, IEM_GET_MODRM_RM(pVCpu, bRm));
367 IEM_MC_CALL_SSE_AIMPL_2(pfnU128, pDst, pSrc);
368 IEM_MC_ADVANCE_RIP_AND_FINISH();
369 IEM_MC_END();
370 }
371 else
372 {
373 /*
374 * XMM, [mem128].
375 */
376 IEM_MC_BEGIN(2, 2, IEM_MC_F_NOT_286_OR_OLDER, 0);
377 IEM_MC_ARG(PRTUINT128U, pDst, 0);
378 IEM_MC_LOCAL(RTUINT128U, uSrc);
379 IEM_MC_ARG_LOCAL_REF(PCRTUINT128U, pSrc, uSrc, 1);
380 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
381
382 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
383 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
384 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
385 IEM_MC_FETCH_MEM_U128_ALIGN_SSE(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
386
387 IEM_MC_PREPARE_SSE_USAGE();
388 IEM_MC_REF_XREG_U128(pDst, IEM_GET_MODRM_REG(pVCpu, bRm));
389 IEM_MC_CALL_SSE_AIMPL_2(pfnU128, pDst, pSrc);
390
391 IEM_MC_ADVANCE_RIP_AND_FINISH();
392 IEM_MC_END();
393 }
394}
395
396
397/**
398 * Common worker for SSE2 instructions on the forms:
399 * pxxx xmm1, xmm2/mem128
400 *
401 * Proper alignment of the 128-bit operand is enforced.
402 * Exceptions type 4. SSE2 cpuid checks.
403 *
404 * @sa iemOpCommonSse41_FullFull_To_Full, iemOpCommonSse2_FullFull_To_Full
405 */
406FNIEMOP_DEF_1(iemOpCommonSse2_FullFull_To_Full, PFNIEMAIMPLMEDIAF2U128, pfnU128)
407{
408 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
409 if (IEM_IS_MODRM_REG_MODE(bRm))
410 {
411 /*
412 * XMM, XMM.
413 */
414 IEM_MC_BEGIN(2, 0, IEM_MC_F_NOT_286_OR_OLDER, 0);
415 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
416 IEM_MC_ARG(PRTUINT128U, pDst, 0);
417 IEM_MC_ARG(PCRTUINT128U, pSrc, 1);
418 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
419 IEM_MC_PREPARE_SSE_USAGE();
420 IEM_MC_REF_XREG_U128(pDst, IEM_GET_MODRM_REG(pVCpu, bRm));
421 IEM_MC_REF_XREG_U128_CONST(pSrc, IEM_GET_MODRM_RM(pVCpu, bRm));
422 IEM_MC_CALL_SSE_AIMPL_2(pfnU128, pDst, pSrc);
423 IEM_MC_ADVANCE_RIP_AND_FINISH();
424 IEM_MC_END();
425 }
426 else
427 {
428 /*
429 * XMM, [mem128].
430 */
431 IEM_MC_BEGIN(2, 2, IEM_MC_F_NOT_286_OR_OLDER, 0);
432 IEM_MC_ARG(PRTUINT128U, pDst, 0);
433 IEM_MC_LOCAL(RTUINT128U, uSrc);
434 IEM_MC_ARG_LOCAL_REF(PCRTUINT128U, pSrc, uSrc, 1);
435 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
436
437 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
438 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
439 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
440 IEM_MC_FETCH_MEM_U128_ALIGN_SSE(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
441
442 IEM_MC_PREPARE_SSE_USAGE();
443 IEM_MC_REF_XREG_U128(pDst, IEM_GET_MODRM_REG(pVCpu, bRm));
444 IEM_MC_CALL_SSE_AIMPL_2(pfnU128, pDst, pSrc);
445
446 IEM_MC_ADVANCE_RIP_AND_FINISH();
447 IEM_MC_END();
448 }
449}
450
451
452/**
453 * Common worker for SSE2 instructions on the forms:
454 * pxxx xmm1, xmm2/mem128
455 *
456 * Proper alignment of the 128-bit operand is enforced.
457 * Exceptions type 4. SSE2 cpuid checks.
458 *
459 * Unlike iemOpCommonSse2_FullFull_To_Full, the @a pfnU128 worker function takes
460 * no FXSAVE state, just the operands.
461 *
462 * @sa iemOpCommonSse41_FullFull_To_Full, iemOpCommonSse2_FullFull_To_Full
463 */
464FNIEMOP_DEF_1(iemOpCommonSse2Opt_FullFull_To_Full, PFNIEMAIMPLMEDIAOPTF2U128, pfnU128)
465{
466 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
467 if (IEM_IS_MODRM_REG_MODE(bRm))
468 {
469 /*
470 * XMM, XMM.
471 */
472 IEM_MC_BEGIN(2, 0, IEM_MC_F_NOT_286_OR_OLDER, 0);
473 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
474 IEM_MC_ARG(PRTUINT128U, pDst, 0);
475 IEM_MC_ARG(PCRTUINT128U, pSrc, 1);
476 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
477 IEM_MC_PREPARE_SSE_USAGE();
478 IEM_MC_REF_XREG_U128(pDst, IEM_GET_MODRM_REG(pVCpu, bRm));
479 IEM_MC_REF_XREG_U128_CONST(pSrc, IEM_GET_MODRM_RM(pVCpu, bRm));
480 IEM_MC_CALL_VOID_AIMPL_2(pfnU128, pDst, pSrc);
481 IEM_MC_ADVANCE_RIP_AND_FINISH();
482 IEM_MC_END();
483 }
484 else
485 {
486 /*
487 * XMM, [mem128].
488 */
489 IEM_MC_BEGIN(2, 2, IEM_MC_F_NOT_286_OR_OLDER, 0);
490 IEM_MC_ARG(PRTUINT128U, pDst, 0);
491 IEM_MC_LOCAL(RTUINT128U, uSrc);
492 IEM_MC_ARG_LOCAL_REF(PCRTUINT128U, pSrc, uSrc, 1);
493 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
494
495 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
496 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
497 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
498 IEM_MC_FETCH_MEM_U128_ALIGN_SSE(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
499
500 IEM_MC_PREPARE_SSE_USAGE();
501 IEM_MC_REF_XREG_U128(pDst, IEM_GET_MODRM_REG(pVCpu, bRm));
502 IEM_MC_CALL_VOID_AIMPL_2(pfnU128, pDst, pSrc);
503
504 IEM_MC_ADVANCE_RIP_AND_FINISH();
505 IEM_MC_END();
506 }
507}
508
509
510/**
511 * Common worker for MMX instructions on the forms:
512 * pxxxx mm1, mm2/mem32
513 *
514 * The 2nd operand is the first half of a register, which in the memory case
515 * means a 32-bit memory access.
516 */
517FNIEMOP_DEF_1(iemOpCommonMmx_LowLow_To_Full, PFNIEMAIMPLMEDIAOPTF2U64, pfnU64)
518{
519 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
520 if (IEM_IS_MODRM_REG_MODE(bRm))
521 {
522 /*
523 * MMX, MMX.
524 */
525 IEM_MC_BEGIN(2, 0, IEM_MC_F_NOT_286_OR_OLDER, 0);
526 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fMmx);
527 IEM_MC_ARG(uint64_t *, puDst, 0);
528 IEM_MC_ARG(uint64_t const *, puSrc, 1);
529 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
530 IEM_MC_PREPARE_FPU_USAGE();
531 IEM_MC_FPU_TO_MMX_MODE();
532
533 IEM_MC_REF_MREG_U64(puDst, IEM_GET_MODRM_REG_8(bRm));
534 IEM_MC_REF_MREG_U64_CONST(puSrc, IEM_GET_MODRM_RM_8(bRm));
535 IEM_MC_CALL_VOID_AIMPL_2(pfnU64, puDst, puSrc);
536 IEM_MC_MODIFIED_MREG_BY_REF(puDst);
537
538 IEM_MC_ADVANCE_RIP_AND_FINISH();
539 IEM_MC_END();
540 }
541 else
542 {
543 /*
544 * MMX, [mem32].
545 */
546 IEM_MC_BEGIN(2, 2, IEM_MC_F_NOT_286_OR_OLDER, 0);
547 IEM_MC_ARG(uint64_t *, puDst, 0);
548 IEM_MC_LOCAL(uint64_t, uSrc);
549 IEM_MC_ARG_LOCAL_REF(uint64_t const *, puSrc, uSrc, 1);
550 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
551
552 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
553 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fMmx);
554 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
555 IEM_MC_FETCH_MEM_U32_ZX_U64(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
556
557 IEM_MC_PREPARE_FPU_USAGE();
558 IEM_MC_FPU_TO_MMX_MODE();
559
560 IEM_MC_REF_MREG_U64(puDst, IEM_GET_MODRM_REG_8(bRm));
561 IEM_MC_CALL_VOID_AIMPL_2(pfnU64, puDst, puSrc);
562 IEM_MC_MODIFIED_MREG_BY_REF(puDst);
563
564 IEM_MC_ADVANCE_RIP_AND_FINISH();
565 IEM_MC_END();
566 }
567}
568
569
570/**
571 * Common worker for SSE instructions on the forms:
572 * pxxxx xmm1, xmm2/mem128
573 *
574 * The 2nd operand is the first half of a register, which in the memory case
575 * 128-bit aligned 64-bit or 128-bit memory accessed for SSE.
576 *
577 * Exceptions type 4.
578 */
579FNIEMOP_DEF_1(iemOpCommonSse_LowLow_To_Full, PFNIEMAIMPLMEDIAOPTF2U128, pfnU128)
580{
581 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
582 if (IEM_IS_MODRM_REG_MODE(bRm))
583 {
584 /*
585 * XMM, XMM.
586 */
587 IEM_MC_BEGIN(2, 0, IEM_MC_F_NOT_286_OR_OLDER, 0);
588 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
589 IEM_MC_ARG(PRTUINT128U, puDst, 0);
590 IEM_MC_ARG(PCRTUINT128U, puSrc, 1);
591 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
592 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
593 IEM_MC_REF_XREG_U128(puDst, IEM_GET_MODRM_REG(pVCpu, bRm));
594 IEM_MC_REF_XREG_U128_CONST(puSrc, IEM_GET_MODRM_RM(pVCpu, bRm));
595 IEM_MC_CALL_VOID_AIMPL_2(pfnU128, puDst, puSrc);
596 IEM_MC_ADVANCE_RIP_AND_FINISH();
597 IEM_MC_END();
598 }
599 else
600 {
601 /*
602 * XMM, [mem128].
603 */
604 IEM_MC_BEGIN(2, 2, IEM_MC_F_NOT_286_OR_OLDER, 0);
605 IEM_MC_ARG(PRTUINT128U, puDst, 0);
606 IEM_MC_LOCAL(RTUINT128U, uSrc);
607 IEM_MC_ARG_LOCAL_REF(PCRTUINT128U, puSrc, uSrc, 1);
608 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
609
610 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
611 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
612 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
613 /** @todo Most CPUs probably only read the low qword. We read everything to
614 * make sure we apply segmentation and alignment checks correctly.
615 * When we have time, it would be interesting to explore what real
616 * CPUs actually does and whether it will do a TLB load for the high
617 * part or skip any associated \#PF. Ditto for segmentation \#GPs. */
618 IEM_MC_FETCH_MEM_U128_ALIGN_SSE(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
619
620 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
621 IEM_MC_REF_XREG_U128(puDst, IEM_GET_MODRM_REG(pVCpu, bRm));
622 IEM_MC_CALL_VOID_AIMPL_2(pfnU128, puDst, puSrc);
623
624 IEM_MC_ADVANCE_RIP_AND_FINISH();
625 IEM_MC_END();
626 }
627}
628
629
630/**
631 * Common worker for SSE2 instructions on the forms:
632 * pxxxx xmm1, xmm2/mem128
633 *
634 * The 2nd operand is the first half of a register, which in the memory case
635 * 128-bit aligned 64-bit or 128-bit memory accessed for SSE.
636 *
637 * Exceptions type 4.
638 */
639FNIEMOP_DEF_1(iemOpCommonSse2_LowLow_To_Full, PFNIEMAIMPLMEDIAOPTF2U128, pfnU128)
640{
641 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
642 if (IEM_IS_MODRM_REG_MODE(bRm))
643 {
644 /*
645 * XMM, XMM.
646 */
647 IEM_MC_BEGIN(2, 0, IEM_MC_F_NOT_286_OR_OLDER, 0);
648 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
649 IEM_MC_ARG(PRTUINT128U, puDst, 0);
650 IEM_MC_ARG(PCRTUINT128U, puSrc, 1);
651 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
652 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
653 IEM_MC_REF_XREG_U128(puDst, IEM_GET_MODRM_REG(pVCpu, bRm));
654 IEM_MC_REF_XREG_U128_CONST(puSrc, IEM_GET_MODRM_RM(pVCpu, bRm));
655 IEM_MC_CALL_VOID_AIMPL_2(pfnU128, puDst, puSrc);
656 IEM_MC_ADVANCE_RIP_AND_FINISH();
657 IEM_MC_END();
658 }
659 else
660 {
661 /*
662 * XMM, [mem128].
663 */
664 IEM_MC_BEGIN(2, 2, IEM_MC_F_NOT_286_OR_OLDER, 0);
665 IEM_MC_ARG(PRTUINT128U, puDst, 0);
666 IEM_MC_LOCAL(RTUINT128U, uSrc);
667 IEM_MC_ARG_LOCAL_REF(PCRTUINT128U, puSrc, uSrc, 1);
668 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
669
670 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
671 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
672 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
673 /** @todo Most CPUs probably only read the low qword. We read everything to
674 * make sure we apply segmentation and alignment checks correctly.
675 * When we have time, it would be interesting to explore what real
676 * CPUs actually does and whether it will do a TLB load for the high
677 * part or skip any associated \#PF. Ditto for segmentation \#GPs. */
678 IEM_MC_FETCH_MEM_U128_ALIGN_SSE(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
679
680 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
681 IEM_MC_REF_XREG_U128(puDst, IEM_GET_MODRM_REG(pVCpu, bRm));
682 IEM_MC_CALL_VOID_AIMPL_2(pfnU128, puDst, puSrc);
683
684 IEM_MC_ADVANCE_RIP_AND_FINISH();
685 IEM_MC_END();
686 }
687}
688
689
690/**
691 * Common worker for MMX instructions on the form:
692 * pxxxx mm1, mm2/mem64
693 *
694 * The 2nd operand is the second half of a register, which in the memory case
695 * means a 64-bit memory access for MMX.
696 */
697FNIEMOP_DEF_1(iemOpCommonMmx_HighHigh_To_Full, PFNIEMAIMPLMEDIAOPTF2U64, pfnU64)
698{
699 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
700 if (IEM_IS_MODRM_REG_MODE(bRm))
701 {
702 /*
703 * MMX, MMX.
704 */
705 /** @todo testcase: REX.B / REX.R and MMX register indexing. Ignored? */
706 /** @todo testcase: REX.B / REX.R and segment register indexing. Ignored? */
707 IEM_MC_BEGIN(2, 0, IEM_MC_F_NOT_286_OR_OLDER, 0);
708 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fMmx);
709 IEM_MC_ARG(uint64_t *, puDst, 0);
710 IEM_MC_ARG(uint64_t const *, puSrc, 1);
711 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
712 IEM_MC_PREPARE_FPU_USAGE();
713 IEM_MC_FPU_TO_MMX_MODE();
714
715 IEM_MC_REF_MREG_U64(puDst, IEM_GET_MODRM_REG_8(bRm));
716 IEM_MC_REF_MREG_U64_CONST(puSrc, IEM_GET_MODRM_RM_8(bRm));
717 IEM_MC_CALL_VOID_AIMPL_2(pfnU64, puDst, puSrc);
718 IEM_MC_MODIFIED_MREG_BY_REF(puDst);
719
720 IEM_MC_ADVANCE_RIP_AND_FINISH();
721 IEM_MC_END();
722 }
723 else
724 {
725 /*
726 * MMX, [mem64].
727 */
728 IEM_MC_BEGIN(2, 2, IEM_MC_F_NOT_286_OR_OLDER, 0);
729 IEM_MC_ARG(uint64_t *, puDst, 0);
730 IEM_MC_LOCAL(uint64_t, uSrc);
731 IEM_MC_ARG_LOCAL_REF(uint64_t const *, puSrc, uSrc, 1);
732 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
733
734 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
735 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fMmx);
736 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
737 IEM_MC_FETCH_MEM_U64(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc); /* intel docs this to be full 64-bit read */
738
739 IEM_MC_PREPARE_FPU_USAGE();
740 IEM_MC_FPU_TO_MMX_MODE();
741
742 IEM_MC_REF_MREG_U64(puDst, IEM_GET_MODRM_REG_8(bRm));
743 IEM_MC_CALL_VOID_AIMPL_2(pfnU64, puDst, puSrc);
744 IEM_MC_MODIFIED_MREG_BY_REF(puDst);
745
746 IEM_MC_ADVANCE_RIP_AND_FINISH();
747 IEM_MC_END();
748 }
749}
750
751
752/**
753 * Common worker for SSE instructions on the form:
754 * pxxxx xmm1, xmm2/mem128
755 *
756 * The 2nd operand is the second half of a register, which for SSE a 128-bit
757 * aligned access where it may read the full 128 bits or only the upper 64 bits.
758 *
759 * Exceptions type 4.
760 */
761FNIEMOP_DEF_1(iemOpCommonSse_HighHigh_To_Full, PFNIEMAIMPLMEDIAOPTF2U128, pfnU128)
762{
763 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
764 if (IEM_IS_MODRM_REG_MODE(bRm))
765 {
766 /*
767 * XMM, XMM.
768 */
769 IEM_MC_BEGIN(2, 0, IEM_MC_F_NOT_286_OR_OLDER, 0);
770 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
771 IEM_MC_ARG(PRTUINT128U, puDst, 0);
772 IEM_MC_ARG(PCRTUINT128U, puSrc, 1);
773 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
774 IEM_MC_PREPARE_SSE_USAGE();
775 IEM_MC_REF_XREG_U128(puDst, IEM_GET_MODRM_REG(pVCpu, bRm));
776 IEM_MC_REF_XREG_U128_CONST(puSrc, IEM_GET_MODRM_RM(pVCpu, bRm));
777 IEM_MC_CALL_VOID_AIMPL_2(pfnU128, puDst, puSrc);
778 IEM_MC_ADVANCE_RIP_AND_FINISH();
779 IEM_MC_END();
780 }
781 else
782 {
783 /*
784 * XMM, [mem128].
785 */
786 IEM_MC_BEGIN(2, 2, IEM_MC_F_NOT_286_OR_OLDER, 0);
787 IEM_MC_ARG(PRTUINT128U, puDst, 0);
788 IEM_MC_LOCAL(RTUINT128U, uSrc);
789 IEM_MC_ARG_LOCAL_REF(PCRTUINT128U, puSrc, uSrc, 1);
790 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
791
792 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
793 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
794 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
795 /** @todo Most CPUs probably only read the high qword. We read everything to
796 * make sure we apply segmentation and alignment checks correctly.
797 * When we have time, it would be interesting to explore what real
798 * CPUs actually does and whether it will do a TLB load for the lower
799 * part or skip any associated \#PF. */
800 IEM_MC_FETCH_MEM_U128_ALIGN_SSE(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
801
802 IEM_MC_PREPARE_SSE_USAGE();
803 IEM_MC_REF_XREG_U128(puDst, IEM_GET_MODRM_REG(pVCpu, bRm));
804 IEM_MC_CALL_VOID_AIMPL_2(pfnU128, puDst, puSrc);
805
806 IEM_MC_ADVANCE_RIP_AND_FINISH();
807 IEM_MC_END();
808 }
809}
810
811
812/**
813 * Common worker for SSE instructions on the forms:
814 * pxxs xmm1, xmm2/mem128
815 *
816 * Proper alignment of the 128-bit operand is enforced.
817 * Exceptions type 2. SSE cpuid checks.
818 *
819 * @sa iemOpCommonSse41_FullFull_To_Full, iemOpCommonSse2_FullFull_To_Full
820 */
821FNIEMOP_DEF_1(iemOpCommonSseFp_FullFull_To_Full, PFNIEMAIMPLFPSSEF2U128, pfnU128)
822{
823 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
824 if (IEM_IS_MODRM_REG_MODE(bRm))
825 {
826 /*
827 * XMM128, XMM128.
828 */
829 IEM_MC_BEGIN(3, 1, IEM_MC_F_NOT_286_OR_OLDER, 0);
830 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
831 IEM_MC_LOCAL(IEMSSERESULT, SseRes);
832 IEM_MC_ARG_LOCAL_REF(PIEMSSERESULT, pSseRes, SseRes, 0);
833 IEM_MC_ARG(PCX86XMMREG, pSrc1, 1);
834 IEM_MC_ARG(PCX86XMMREG, pSrc2, 2);
835 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
836 IEM_MC_PREPARE_SSE_USAGE();
837 IEM_MC_REF_XREG_XMM_CONST(pSrc1, IEM_GET_MODRM_REG(pVCpu, bRm));
838 IEM_MC_REF_XREG_XMM_CONST(pSrc2, IEM_GET_MODRM_RM(pVCpu, bRm));
839 IEM_MC_CALL_SSE_AIMPL_3(pfnU128, pSseRes, pSrc1, pSrc2);
840 IEM_MC_STORE_SSE_RESULT(SseRes, IEM_GET_MODRM_REG(pVCpu, bRm));
841 IEM_MC_MAYBE_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
842
843 IEM_MC_ADVANCE_RIP_AND_FINISH();
844 IEM_MC_END();
845 }
846 else
847 {
848 /*
849 * XMM128, [mem128].
850 */
851 IEM_MC_BEGIN(3, 2, IEM_MC_F_NOT_286_OR_OLDER, 0);
852 IEM_MC_LOCAL(IEMSSERESULT, SseRes);
853 IEM_MC_LOCAL(X86XMMREG, uSrc2);
854 IEM_MC_ARG_LOCAL_REF(PIEMSSERESULT, pSseRes, SseRes, 0);
855 IEM_MC_ARG(PCX86XMMREG, pSrc1, 1);
856 IEM_MC_ARG_LOCAL_REF(PCX86XMMREG, pSrc2, uSrc2, 2);
857 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
858
859 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
860 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
861 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
862 IEM_MC_FETCH_MEM_XMM_ALIGN_SSE(uSrc2, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
863
864 IEM_MC_PREPARE_SSE_USAGE();
865 IEM_MC_REF_XREG_XMM_CONST(pSrc1, IEM_GET_MODRM_REG(pVCpu, bRm));
866 IEM_MC_CALL_SSE_AIMPL_3(pfnU128, pSseRes, pSrc1, pSrc2);
867 IEM_MC_STORE_SSE_RESULT(SseRes, IEM_GET_MODRM_REG(pVCpu, bRm));
868 IEM_MC_MAYBE_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
869
870 IEM_MC_ADVANCE_RIP_AND_FINISH();
871 IEM_MC_END();
872 }
873}
874
875
876/**
877 * Common worker for SSE instructions on the forms:
878 * pxxs xmm1, xmm2/mem32
879 *
880 * Proper alignment of the 128-bit operand is enforced.
881 * Exceptions type 2. SSE cpuid checks.
882 *
883 * @sa iemOpCommonSse41_FullFull_To_Full, iemOpCommonSse2_FullFull_To_Full
884 */
885FNIEMOP_DEF_1(iemOpCommonSseFp_FullR32_To_Full, PFNIEMAIMPLFPSSEF2U128R32, pfnU128_R32)
886{
887 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
888 if (IEM_IS_MODRM_REG_MODE(bRm))
889 {
890 /*
891 * XMM128, XMM32.
892 */
893 IEM_MC_BEGIN(3, 1, IEM_MC_F_NOT_286_OR_OLDER, 0);
894 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
895 IEM_MC_LOCAL(IEMSSERESULT, SseRes);
896 IEM_MC_ARG_LOCAL_REF(PIEMSSERESULT, pSseRes, SseRes, 0);
897 IEM_MC_ARG(PCX86XMMREG, pSrc1, 1);
898 IEM_MC_ARG(PCRTFLOAT32U, pSrc2, 2);
899 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
900 IEM_MC_PREPARE_SSE_USAGE();
901 IEM_MC_REF_XREG_XMM_CONST(pSrc1, IEM_GET_MODRM_REG(pVCpu, bRm));
902 IEM_MC_REF_XREG_R32_CONST(pSrc2, IEM_GET_MODRM_RM(pVCpu, bRm));
903 IEM_MC_CALL_SSE_AIMPL_3(pfnU128_R32, pSseRes, pSrc1, pSrc2);
904 IEM_MC_STORE_SSE_RESULT(SseRes, IEM_GET_MODRM_REG(pVCpu, bRm));
905 IEM_MC_MAYBE_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
906
907 IEM_MC_ADVANCE_RIP_AND_FINISH();
908 IEM_MC_END();
909 }
910 else
911 {
912 /*
913 * XMM128, [mem32].
914 */
915 IEM_MC_BEGIN(3, 2, IEM_MC_F_NOT_286_OR_OLDER, 0);
916 IEM_MC_LOCAL(IEMSSERESULT, SseRes);
917 IEM_MC_LOCAL(RTFLOAT32U, r32Src2);
918 IEM_MC_ARG_LOCAL_REF(PIEMSSERESULT, pSseRes, SseRes, 0);
919 IEM_MC_ARG(PCX86XMMREG, pSrc1, 1);
920 IEM_MC_ARG_LOCAL_REF(PCRTFLOAT32U, pr32Src2, r32Src2, 2);
921 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
922
923 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
924 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
925 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
926 IEM_MC_FETCH_MEM_R32(r32Src2, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
927
928 IEM_MC_PREPARE_SSE_USAGE();
929 IEM_MC_REF_XREG_XMM_CONST(pSrc1, IEM_GET_MODRM_REG(pVCpu, bRm));
930 IEM_MC_CALL_SSE_AIMPL_3(pfnU128_R32, pSseRes, pSrc1, pr32Src2);
931 IEM_MC_STORE_SSE_RESULT(SseRes, IEM_GET_MODRM_REG(pVCpu, bRm));
932 IEM_MC_MAYBE_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
933
934 IEM_MC_ADVANCE_RIP_AND_FINISH();
935 IEM_MC_END();
936 }
937}
938
939
940/**
941 * Common worker for SSE2 instructions on the forms:
942 * pxxd xmm1, xmm2/mem128
943 *
944 * Proper alignment of the 128-bit operand is enforced.
945 * Exceptions type 2. SSE cpuid checks.
946 *
947 * @sa iemOpCommonSseFp_FullFull_To_Full
948 */
949FNIEMOP_DEF_1(iemOpCommonSse2Fp_FullFull_To_Full, PFNIEMAIMPLFPSSEF2U128, pfnU128)
950{
951 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
952 if (IEM_IS_MODRM_REG_MODE(bRm))
953 {
954 /*
955 * XMM128, XMM128.
956 */
957 IEM_MC_BEGIN(3, 1, IEM_MC_F_NOT_286_OR_OLDER, 0);
958 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
959 IEM_MC_LOCAL(IEMSSERESULT, SseRes);
960 IEM_MC_ARG_LOCAL_REF(PIEMSSERESULT, pSseRes, SseRes, 0);
961 IEM_MC_ARG(PCX86XMMREG, pSrc1, 1);
962 IEM_MC_ARG(PCX86XMMREG, pSrc2, 2);
963 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
964 IEM_MC_PREPARE_SSE_USAGE();
965 IEM_MC_REF_XREG_XMM_CONST(pSrc1, IEM_GET_MODRM_REG(pVCpu, bRm));
966 IEM_MC_REF_XREG_XMM_CONST(pSrc2, IEM_GET_MODRM_RM(pVCpu, bRm));
967 IEM_MC_CALL_SSE_AIMPL_3(pfnU128, pSseRes, pSrc1, pSrc2);
968 IEM_MC_STORE_SSE_RESULT(SseRes, IEM_GET_MODRM_REG(pVCpu, bRm));
969 IEM_MC_MAYBE_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
970
971 IEM_MC_ADVANCE_RIP_AND_FINISH();
972 IEM_MC_END();
973 }
974 else
975 {
976 /*
977 * XMM128, [mem128].
978 */
979 IEM_MC_BEGIN(3, 2, IEM_MC_F_NOT_286_OR_OLDER, 0);
980 IEM_MC_LOCAL(IEMSSERESULT, SseRes);
981 IEM_MC_LOCAL(X86XMMREG, uSrc2);
982 IEM_MC_ARG_LOCAL_REF(PIEMSSERESULT, pSseRes, SseRes, 0);
983 IEM_MC_ARG(PCX86XMMREG, pSrc1, 1);
984 IEM_MC_ARG_LOCAL_REF(PCX86XMMREG, pSrc2, uSrc2, 2);
985 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
986
987 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
988 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
989 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
990 IEM_MC_FETCH_MEM_XMM_ALIGN_SSE(uSrc2, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
991
992 IEM_MC_PREPARE_SSE_USAGE();
993 IEM_MC_REF_XREG_XMM_CONST(pSrc1, IEM_GET_MODRM_REG(pVCpu, bRm));
994 IEM_MC_CALL_SSE_AIMPL_3(pfnU128, pSseRes, pSrc1, pSrc2);
995 IEM_MC_STORE_SSE_RESULT(SseRes, IEM_GET_MODRM_REG(pVCpu, bRm));
996 IEM_MC_MAYBE_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
997
998 IEM_MC_ADVANCE_RIP_AND_FINISH();
999 IEM_MC_END();
1000 }
1001}
1002
1003
1004/**
1005 * Common worker for SSE2 instructions on the forms:
1006 * pxxs xmm1, xmm2/mem64
1007 *
1008 * Proper alignment of the 128-bit operand is enforced.
1009 * Exceptions type 2. SSE2 cpuid checks.
1010 *
1011 * @sa iemOpCommonSse41_FullFull_To_Full, iemOpCommonSse2_FullFull_To_Full
1012 */
1013FNIEMOP_DEF_1(iemOpCommonSse2Fp_FullR64_To_Full, PFNIEMAIMPLFPSSEF2U128R64, pfnU128_R64)
1014{
1015 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
1016 if (IEM_IS_MODRM_REG_MODE(bRm))
1017 {
1018 /*
1019 * XMM, XMM.
1020 */
1021 IEM_MC_BEGIN(3, 1, IEM_MC_F_NOT_286_OR_OLDER, 0);
1022 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
1023 IEM_MC_LOCAL(IEMSSERESULT, SseRes);
1024 IEM_MC_ARG_LOCAL_REF(PIEMSSERESULT, pSseRes, SseRes, 0);
1025 IEM_MC_ARG(PCX86XMMREG, pSrc1, 1);
1026 IEM_MC_ARG(PCRTFLOAT64U, pSrc2, 2);
1027 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
1028 IEM_MC_PREPARE_SSE_USAGE();
1029 IEM_MC_REF_XREG_XMM_CONST(pSrc1, IEM_GET_MODRM_REG(pVCpu, bRm));
1030 IEM_MC_REF_XREG_R64_CONST(pSrc2, IEM_GET_MODRM_RM(pVCpu, bRm));
1031 IEM_MC_CALL_SSE_AIMPL_3(pfnU128_R64, pSseRes, pSrc1, pSrc2);
1032 IEM_MC_STORE_SSE_RESULT(SseRes, IEM_GET_MODRM_REG(pVCpu, bRm));
1033 IEM_MC_MAYBE_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
1034
1035 IEM_MC_ADVANCE_RIP_AND_FINISH();
1036 IEM_MC_END();
1037 }
1038 else
1039 {
1040 /*
1041 * XMM, [mem64].
1042 */
1043 IEM_MC_BEGIN(3, 2, IEM_MC_F_NOT_286_OR_OLDER, 0);
1044 IEM_MC_LOCAL(IEMSSERESULT, SseRes);
1045 IEM_MC_LOCAL(RTFLOAT64U, r64Src2);
1046 IEM_MC_ARG_LOCAL_REF(PIEMSSERESULT, pSseRes, SseRes, 0);
1047 IEM_MC_ARG(PCX86XMMREG, pSrc1, 1);
1048 IEM_MC_ARG_LOCAL_REF(PCRTFLOAT64U, pr64Src2, r64Src2, 2);
1049 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
1050
1051 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
1052 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
1053 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
1054 IEM_MC_FETCH_MEM_R64(r64Src2, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
1055
1056 IEM_MC_PREPARE_SSE_USAGE();
1057 IEM_MC_REF_XREG_XMM_CONST(pSrc1, IEM_GET_MODRM_REG(pVCpu, bRm));
1058 IEM_MC_CALL_SSE_AIMPL_3(pfnU128_R64, pSseRes, pSrc1, pr64Src2);
1059 IEM_MC_STORE_SSE_RESULT(SseRes, IEM_GET_MODRM_REG(pVCpu, bRm));
1060 IEM_MC_MAYBE_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
1061
1062 IEM_MC_ADVANCE_RIP_AND_FINISH();
1063 IEM_MC_END();
1064 }
1065}
1066
1067
1068/**
1069 * Common worker for SSE2 instructions on the form:
1070 * pxxxx xmm1, xmm2/mem128
1071 *
1072 * The 2nd operand is the second half of a register, which for SSE a 128-bit
1073 * aligned access where it may read the full 128 bits or only the upper 64 bits.
1074 *
1075 * Exceptions type 4.
1076 */
1077FNIEMOP_DEF_1(iemOpCommonSse2_HighHigh_To_Full, PFNIEMAIMPLMEDIAOPTF2U128, pfnU128)
1078{
1079 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
1080 if (IEM_IS_MODRM_REG_MODE(bRm))
1081 {
1082 /*
1083 * XMM, XMM.
1084 */
1085 IEM_MC_BEGIN(2, 0, IEM_MC_F_NOT_286_OR_OLDER, 0);
1086 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
1087 IEM_MC_ARG(PRTUINT128U, puDst, 0);
1088 IEM_MC_ARG(PCRTUINT128U, puSrc, 1);
1089 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
1090 IEM_MC_PREPARE_SSE_USAGE();
1091 IEM_MC_REF_XREG_U128(puDst, IEM_GET_MODRM_REG(pVCpu, bRm));
1092 IEM_MC_REF_XREG_U128_CONST(puSrc, IEM_GET_MODRM_RM(pVCpu, bRm));
1093 IEM_MC_CALL_VOID_AIMPL_2(pfnU128, puDst, puSrc);
1094 IEM_MC_ADVANCE_RIP_AND_FINISH();
1095 IEM_MC_END();
1096 }
1097 else
1098 {
1099 /*
1100 * XMM, [mem128].
1101 */
1102 IEM_MC_BEGIN(2, 2, IEM_MC_F_NOT_286_OR_OLDER, 0);
1103 IEM_MC_ARG(PRTUINT128U, puDst, 0);
1104 IEM_MC_LOCAL(RTUINT128U, uSrc);
1105 IEM_MC_ARG_LOCAL_REF(PCRTUINT128U, puSrc, uSrc, 1);
1106 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
1107
1108 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
1109 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
1110 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
1111 /** @todo Most CPUs probably only read the high qword. We read everything to
1112 * make sure we apply segmentation and alignment checks correctly.
1113 * When we have time, it would be interesting to explore what real
1114 * CPUs actually does and whether it will do a TLB load for the lower
1115 * part or skip any associated \#PF. */
1116 IEM_MC_FETCH_MEM_U128_ALIGN_SSE(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
1117
1118 IEM_MC_PREPARE_SSE_USAGE();
1119 IEM_MC_REF_XREG_U128(puDst, IEM_GET_MODRM_REG(pVCpu, bRm));
1120 IEM_MC_CALL_VOID_AIMPL_2(pfnU128, puDst, puSrc);
1121
1122 IEM_MC_ADVANCE_RIP_AND_FINISH();
1123 IEM_MC_END();
1124 }
1125}
1126
1127
1128/**
1129 * Common worker for SSE3 instructions on the forms:
1130 * hxxx xmm1, xmm2/mem128
1131 *
1132 * Proper alignment of the 128-bit operand is enforced.
1133 * Exceptions type 2. SSE3 cpuid checks.
1134 *
1135 * @sa iemOpCommonSse41_FullFull_To_Full, iemOpCommonSse2_FullFull_To_Full
1136 */
1137FNIEMOP_DEF_1(iemOpCommonSse3Fp_FullFull_To_Full, PFNIEMAIMPLFPSSEF2U128, pfnU128)
1138{
1139 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
1140 if (IEM_IS_MODRM_REG_MODE(bRm))
1141 {
1142 /*
1143 * XMM, XMM.
1144 */
1145 IEM_MC_BEGIN(3, 1, IEM_MC_F_NOT_286_OR_OLDER, 0);
1146 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse3);
1147 IEM_MC_LOCAL(IEMSSERESULT, SseRes);
1148 IEM_MC_ARG_LOCAL_REF(PIEMSSERESULT, pSseRes, SseRes, 0);
1149 IEM_MC_ARG(PCX86XMMREG, pSrc1, 1);
1150 IEM_MC_ARG(PCX86XMMREG, pSrc2, 2);
1151 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
1152 IEM_MC_PREPARE_SSE_USAGE();
1153 IEM_MC_REF_XREG_XMM_CONST(pSrc1, IEM_GET_MODRM_REG(pVCpu, bRm));
1154 IEM_MC_REF_XREG_XMM_CONST(pSrc2, IEM_GET_MODRM_RM(pVCpu, bRm));
1155 IEM_MC_CALL_SSE_AIMPL_3(pfnU128, pSseRes, pSrc1, pSrc2);
1156 IEM_MC_STORE_SSE_RESULT(SseRes, IEM_GET_MODRM_REG(pVCpu, bRm));
1157 IEM_MC_MAYBE_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
1158
1159 IEM_MC_ADVANCE_RIP_AND_FINISH();
1160 IEM_MC_END();
1161 }
1162 else
1163 {
1164 /*
1165 * XMM, [mem128].
1166 */
1167 IEM_MC_BEGIN(3, 2, IEM_MC_F_NOT_286_OR_OLDER, 0);
1168 IEM_MC_LOCAL(IEMSSERESULT, SseRes);
1169 IEM_MC_LOCAL(X86XMMREG, uSrc2);
1170 IEM_MC_ARG_LOCAL_REF(PIEMSSERESULT, pSseRes, SseRes, 0);
1171 IEM_MC_ARG(PCX86XMMREG, pSrc1, 1);
1172 IEM_MC_ARG_LOCAL_REF(PCX86XMMREG, pSrc2, uSrc2, 2);
1173 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
1174
1175 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
1176 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse3);
1177 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
1178 IEM_MC_FETCH_MEM_XMM_ALIGN_SSE(uSrc2, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
1179
1180 IEM_MC_PREPARE_SSE_USAGE();
1181 IEM_MC_REF_XREG_XMM_CONST(pSrc1, IEM_GET_MODRM_REG(pVCpu, bRm));
1182 IEM_MC_CALL_SSE_AIMPL_3(pfnU128, pSseRes, pSrc1, pSrc2);
1183 IEM_MC_STORE_SSE_RESULT(SseRes, IEM_GET_MODRM_REG(pVCpu, bRm));
1184 IEM_MC_MAYBE_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
1185
1186 IEM_MC_ADVANCE_RIP_AND_FINISH();
1187 IEM_MC_END();
1188 }
1189}
1190
1191
1192/** Opcode 0x0f 0x00 /0. */
1193FNIEMOPRM_DEF(iemOp_Grp6_sldt)
1194{
1195 IEMOP_MNEMONIC(sldt, "sldt Rv/Mw");
1196 IEMOP_HLP_MIN_286();
1197 IEMOP_HLP_NO_REAL_OR_V86_MODE();
1198
1199 if (IEM_IS_MODRM_REG_MODE(bRm))
1200 {
1201 IEMOP_HLP_DECODED_NL_1(OP_SLDT, IEMOPFORM_M_REG, OP_PARM_Ew, DISOPTYPE_DANGEROUS | DISOPTYPE_PRIVILEGED_NOTRAP);
1202 IEM_MC_DEFER_TO_CIMPL_2_RET(IEM_CIMPL_F_VMEXIT, RT_BIT_64(kIemNativeGstReg_GprFirst + IEM_GET_MODRM_RM(pVCpu, bRm)),
1203 iemCImpl_sldt_reg, IEM_GET_MODRM_RM(pVCpu, bRm), pVCpu->iem.s.enmEffOpSize);
1204 }
1205
1206 /* Ignore operand size here, memory refs are always 16-bit. */
1207 IEM_MC_BEGIN(2, 0, IEM_MC_F_MIN_286, 0);
1208 IEM_MC_ARG(RTGCPTR, GCPtrEffDst, 1);
1209 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
1210 IEMOP_HLP_DECODED_NL_1(OP_SLDT, IEMOPFORM_M_MEM, OP_PARM_Ew, DISOPTYPE_DANGEROUS | DISOPTYPE_PRIVILEGED_NOTRAP);
1211 IEM_MC_ARG_CONST(uint8_t, iEffSeg, /*=*/ pVCpu->iem.s.iEffSeg, 0);
1212 IEM_MC_CALL_CIMPL_2(IEM_CIMPL_F_VMEXIT, 0, iemCImpl_sldt_mem, iEffSeg, GCPtrEffDst);
1213 IEM_MC_END();
1214}
1215
1216
1217/** Opcode 0x0f 0x00 /1. */
1218FNIEMOPRM_DEF(iemOp_Grp6_str)
1219{
1220 IEMOP_MNEMONIC(str, "str Rv/Mw");
1221 IEMOP_HLP_MIN_286();
1222 IEMOP_HLP_NO_REAL_OR_V86_MODE();
1223
1224
1225 if (IEM_IS_MODRM_REG_MODE(bRm))
1226 {
1227 IEMOP_HLP_DECODED_NL_1(OP_STR, IEMOPFORM_M_REG, OP_PARM_Ew, DISOPTYPE_DANGEROUS | DISOPTYPE_PRIVILEGED_NOTRAP);
1228 IEM_MC_DEFER_TO_CIMPL_2_RET(IEM_CIMPL_F_VMEXIT, RT_BIT_64(kIemNativeGstReg_GprFirst + IEM_GET_MODRM_RM(pVCpu, bRm)),
1229 iemCImpl_str_reg, IEM_GET_MODRM_RM(pVCpu, bRm), pVCpu->iem.s.enmEffOpSize);
1230 }
1231
1232 /* Ignore operand size here, memory refs are always 16-bit. */
1233 IEM_MC_BEGIN(2, 0, IEM_MC_F_MIN_286, 0);
1234 IEM_MC_ARG(RTGCPTR, GCPtrEffDst, 1);
1235 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
1236 IEMOP_HLP_DECODED_NL_1(OP_STR, IEMOPFORM_M_MEM, OP_PARM_Ew, DISOPTYPE_DANGEROUS | DISOPTYPE_PRIVILEGED_NOTRAP);
1237 IEM_MC_ARG_CONST(uint8_t, iEffSeg, /*=*/ pVCpu->iem.s.iEffSeg, 0);
1238 IEM_MC_CALL_CIMPL_2(IEM_CIMPL_F_VMEXIT, 0, iemCImpl_str_mem, iEffSeg, GCPtrEffDst);
1239 IEM_MC_END();
1240}
1241
1242
1243/** Opcode 0x0f 0x00 /2. */
1244FNIEMOPRM_DEF(iemOp_Grp6_lldt)
1245{
1246 IEMOP_MNEMONIC(lldt, "lldt Ew");
1247 IEMOP_HLP_MIN_286();
1248 IEMOP_HLP_NO_REAL_OR_V86_MODE();
1249
1250 if (IEM_IS_MODRM_REG_MODE(bRm))
1251 {
1252 IEM_MC_BEGIN(1, 0, IEM_MC_F_MIN_286, 0);
1253 IEMOP_HLP_DECODED_NL_1(OP_LLDT, IEMOPFORM_M_REG, OP_PARM_Ew, DISOPTYPE_DANGEROUS);
1254 IEM_MC_ARG(uint16_t, u16Sel, 0);
1255 IEM_MC_FETCH_GREG_U16(u16Sel, IEM_GET_MODRM_RM(pVCpu, bRm));
1256 IEM_MC_CALL_CIMPL_1(IEM_CIMPL_F_VMEXIT, 0, iemCImpl_lldt, u16Sel);
1257 IEM_MC_END();
1258 }
1259 else
1260 {
1261 IEM_MC_BEGIN(1, 1, IEM_MC_F_MIN_286, 0);
1262 IEM_MC_ARG(uint16_t, u16Sel, 0);
1263 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
1264 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
1265 IEMOP_HLP_DECODED_NL_1(OP_LLDT, IEMOPFORM_M_MEM, OP_PARM_Ew, DISOPTYPE_DANGEROUS);
1266 IEM_MC_RAISE_GP0_IF_CPL_NOT_ZERO(); /** @todo test order */
1267 IEM_MC_FETCH_MEM_U16(u16Sel, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
1268 IEM_MC_CALL_CIMPL_1(IEM_CIMPL_F_VMEXIT, 0, iemCImpl_lldt, u16Sel);
1269 IEM_MC_END();
1270 }
1271}
1272
1273
1274/** Opcode 0x0f 0x00 /3. */
1275FNIEMOPRM_DEF(iemOp_Grp6_ltr)
1276{
1277 IEMOP_MNEMONIC(ltr, "ltr Ew");
1278 IEMOP_HLP_MIN_286();
1279 IEMOP_HLP_NO_REAL_OR_V86_MODE();
1280
1281 if (IEM_IS_MODRM_REG_MODE(bRm))
1282 {
1283 IEM_MC_BEGIN(1, 0, IEM_MC_F_MIN_286, 0);
1284 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1285 IEM_MC_ARG(uint16_t, u16Sel, 0);
1286 IEM_MC_FETCH_GREG_U16(u16Sel, IEM_GET_MODRM_RM(pVCpu, bRm));
1287 IEM_MC_CALL_CIMPL_1(IEM_CIMPL_F_VMEXIT, 0, iemCImpl_ltr, u16Sel);
1288 IEM_MC_END();
1289 }
1290 else
1291 {
1292 IEM_MC_BEGIN(1, 1, IEM_MC_F_MIN_286, 0);
1293 IEM_MC_ARG(uint16_t, u16Sel, 0);
1294 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
1295 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
1296 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1297 IEM_MC_RAISE_GP0_IF_CPL_NOT_ZERO(); /** @todo test order */
1298 IEM_MC_FETCH_MEM_U16(u16Sel, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
1299 IEM_MC_CALL_CIMPL_1(IEM_CIMPL_F_VMEXIT, 0, iemCImpl_ltr, u16Sel);
1300 IEM_MC_END();
1301 }
1302}
1303
1304
1305/** Opcode 0x0f 0x00 /3. */
1306FNIEMOP_DEF_2(iemOpCommonGrp6VerX, uint8_t, bRm, bool, fWrite)
1307{
1308 IEMOP_HLP_MIN_286();
1309 IEMOP_HLP_NO_REAL_OR_V86_MODE();
1310
1311 if (IEM_IS_MODRM_REG_MODE(bRm))
1312 {
1313 IEM_MC_BEGIN(2, 0, IEM_MC_F_MIN_286, 0);
1314 IEMOP_HLP_DECODED_NL_1(fWrite ? OP_VERW : OP_VERR, IEMOPFORM_M_MEM, OP_PARM_Ew, DISOPTYPE_DANGEROUS | DISOPTYPE_PRIVILEGED_NOTRAP);
1315 IEM_MC_ARG(uint16_t, u16Sel, 0);
1316 IEM_MC_ARG_CONST(bool, fWriteArg, fWrite, 1);
1317 IEM_MC_FETCH_GREG_U16(u16Sel, IEM_GET_MODRM_RM(pVCpu, bRm));
1318 IEM_MC_CALL_CIMPL_2(IEM_CIMPL_F_STATUS_FLAGS, 0, iemCImpl_VerX, u16Sel, fWriteArg);
1319 IEM_MC_END();
1320 }
1321 else
1322 {
1323 IEM_MC_BEGIN(2, 1, IEM_MC_F_MIN_286, 0);
1324 IEM_MC_ARG(uint16_t, u16Sel, 0);
1325 IEM_MC_ARG_CONST(bool, fWriteArg, fWrite, 1);
1326 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
1327 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
1328 IEMOP_HLP_DECODED_NL_1(fWrite ? OP_VERW : OP_VERR, IEMOPFORM_M_MEM, OP_PARM_Ew, DISOPTYPE_DANGEROUS | DISOPTYPE_PRIVILEGED_NOTRAP);
1329 IEM_MC_FETCH_MEM_U16(u16Sel, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
1330 IEM_MC_CALL_CIMPL_2(IEM_CIMPL_F_STATUS_FLAGS, 0, iemCImpl_VerX, u16Sel, fWriteArg);
1331 IEM_MC_END();
1332 }
1333}
1334
1335
1336/** Opcode 0x0f 0x00 /4. */
1337FNIEMOPRM_DEF(iemOp_Grp6_verr)
1338{
1339 IEMOP_MNEMONIC(verr, "verr Ew");
1340 return FNIEMOP_CALL_2(iemOpCommonGrp6VerX, bRm, false);
1341}
1342
1343
1344/** Opcode 0x0f 0x00 /5. */
1345FNIEMOPRM_DEF(iemOp_Grp6_verw)
1346{
1347 IEMOP_MNEMONIC(verw, "verw Ew");
1348 return FNIEMOP_CALL_2(iemOpCommonGrp6VerX, bRm, true);
1349}
1350
1351
1352/**
1353 * Group 6 jump table.
1354 */
1355IEM_STATIC const PFNIEMOPRM g_apfnGroup6[8] =
1356{
1357 iemOp_Grp6_sldt,
1358 iemOp_Grp6_str,
1359 iemOp_Grp6_lldt,
1360 iemOp_Grp6_ltr,
1361 iemOp_Grp6_verr,
1362 iemOp_Grp6_verw,
1363 iemOp_InvalidWithRM,
1364 iemOp_InvalidWithRM
1365};
1366
1367/** Opcode 0x0f 0x00. */
1368FNIEMOP_DEF(iemOp_Grp6)
1369{
1370 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
1371 return FNIEMOP_CALL_1(g_apfnGroup6[IEM_GET_MODRM_REG_8(bRm)], bRm);
1372}
1373
1374
1375/** Opcode 0x0f 0x01 /0. */
1376FNIEMOP_DEF_1(iemOp_Grp7_sgdt, uint8_t, bRm)
1377{
1378 IEMOP_MNEMONIC(sgdt, "sgdt Ms");
1379 IEMOP_HLP_MIN_286();
1380 IEMOP_HLP_64BIT_OP_SIZE();
1381 IEM_MC_BEGIN(2, 1, IEM_MC_F_MIN_286, 0);
1382 IEM_MC_ARG(RTGCPTR, GCPtrEffSrc, 1);
1383 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
1384 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1385 IEM_MC_ARG_CONST(uint8_t, iEffSeg, /*=*/ pVCpu->iem.s.iEffSeg, 0);
1386 IEM_MC_CALL_CIMPL_2(IEM_CIMPL_F_VMEXIT, 0, iemCImpl_sgdt, iEffSeg, GCPtrEffSrc);
1387 IEM_MC_END();
1388}
1389
1390
1391/** Opcode 0x0f 0x01 /0. */
1392FNIEMOP_DEF(iemOp_Grp7_vmcall)
1393{
1394 IEMOP_MNEMONIC(vmcall, "vmcall");
1395 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); /** @todo check prefix effect on the VMX instructions. ASSUMING no lock for now. */
1396
1397 /* Note! We do not check any CPUMFEATURES::fSvm here as we (GIM) generally
1398 want all hypercalls regardless of instruction used, and if a
1399 hypercall isn't handled by GIM or HMSvm will raise an #UD.
1400 (NEM/win makes ASSUMPTIONS about this behavior.) */
1401 IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_RFLAGS | IEM_CIMPL_F_VMEXIT | IEM_CIMPL_F_END_TB, 0, iemCImpl_vmcall);
1402}
1403
1404
1405/** Opcode 0x0f 0x01 /0. */
1406#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
1407FNIEMOP_DEF(iemOp_Grp7_vmlaunch)
1408{
1409 IEMOP_MNEMONIC(vmlaunch, "vmlaunch");
1410 IEMOP_HLP_IN_VMX_OPERATION("vmlaunch", kVmxVDiag_Vmentry);
1411 IEMOP_HLP_VMX_INSTR("vmlaunch", kVmxVDiag_Vmentry);
1412 IEMOP_HLP_DONE_DECODING();
1413 IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_BRANCH_INDIRECT | IEM_CIMPL_F_BRANCH_FAR
1414 | IEM_CIMPL_F_MODE | IEM_CIMPL_F_RFLAGS | IEM_CIMPL_F_VMEXIT | IEM_CIMPL_F_END_TB, 0,
1415 iemCImpl_vmlaunch);
1416}
1417#else
1418FNIEMOP_DEF(iemOp_Grp7_vmlaunch)
1419{
1420 IEMOP_BITCH_ABOUT_STUB();
1421 IEMOP_RAISE_INVALID_OPCODE_RET();
1422}
1423#endif
1424
1425
1426/** Opcode 0x0f 0x01 /0. */
1427#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
1428FNIEMOP_DEF(iemOp_Grp7_vmresume)
1429{
1430 IEMOP_MNEMONIC(vmresume, "vmresume");
1431 IEMOP_HLP_IN_VMX_OPERATION("vmresume", kVmxVDiag_Vmentry);
1432 IEMOP_HLP_VMX_INSTR("vmresume", kVmxVDiag_Vmentry);
1433 IEMOP_HLP_DONE_DECODING();
1434 IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_BRANCH_INDIRECT | IEM_CIMPL_F_BRANCH_FAR
1435 | IEM_CIMPL_F_MODE | IEM_CIMPL_F_RFLAGS | IEM_CIMPL_F_VMEXIT | IEM_CIMPL_F_END_TB, 0,
1436 iemCImpl_vmresume);
1437}
1438#else
1439FNIEMOP_DEF(iemOp_Grp7_vmresume)
1440{
1441 IEMOP_BITCH_ABOUT_STUB();
1442 IEMOP_RAISE_INVALID_OPCODE_RET();
1443}
1444#endif
1445
1446
1447/** Opcode 0x0f 0x01 /0. */
1448#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
1449FNIEMOP_DEF(iemOp_Grp7_vmxoff)
1450{
1451 IEMOP_MNEMONIC(vmxoff, "vmxoff");
1452 IEMOP_HLP_IN_VMX_OPERATION("vmxoff", kVmxVDiag_Vmxoff);
1453 IEMOP_HLP_VMX_INSTR("vmxoff", kVmxVDiag_Vmxoff);
1454 IEMOP_HLP_DONE_DECODING();
1455 IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_VMEXIT, 0, iemCImpl_vmxoff);
1456}
1457#else
1458FNIEMOP_DEF(iemOp_Grp7_vmxoff)
1459{
1460 IEMOP_BITCH_ABOUT_STUB();
1461 IEMOP_RAISE_INVALID_OPCODE_RET();
1462}
1463#endif
1464
1465
1466/** Opcode 0x0f 0x01 /1. */
1467FNIEMOP_DEF_1(iemOp_Grp7_sidt, uint8_t, bRm)
1468{
1469 IEMOP_MNEMONIC(sidt, "sidt Ms");
1470 IEMOP_HLP_MIN_286();
1471 IEMOP_HLP_64BIT_OP_SIZE();
1472 IEM_MC_BEGIN(2, 1, IEM_MC_F_MIN_286, 0);
1473 IEM_MC_ARG(RTGCPTR, GCPtrEffSrc, 1);
1474 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
1475 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1476 IEM_MC_ARG_CONST(uint8_t, iEffSeg, /*=*/ pVCpu->iem.s.iEffSeg, 0);
1477 IEM_MC_CALL_CIMPL_2(IEM_CIMPL_F_VMEXIT, 0, iemCImpl_sidt, iEffSeg, GCPtrEffSrc);
1478 IEM_MC_END();
1479}
1480
1481
1482/** Opcode 0x0f 0x01 /1. */
1483FNIEMOP_DEF(iemOp_Grp7_monitor)
1484{
1485 IEMOP_MNEMONIC(monitor, "monitor");
1486 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); /** @todo Verify that monitor is allergic to lock prefixes. */
1487 IEM_MC_DEFER_TO_CIMPL_1_RET(IEM_CIMPL_F_VMEXIT, 0, iemCImpl_monitor, pVCpu->iem.s.iEffSeg);
1488}
1489
1490
1491/** Opcode 0x0f 0x01 /1. */
1492FNIEMOP_DEF(iemOp_Grp7_mwait)
1493{
1494 IEMOP_MNEMONIC(mwait, "mwait"); /** @todo Verify that mwait is allergic to lock prefixes. */
1495 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1496 IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_END_TB | IEM_CIMPL_F_VMEXIT, 0, iemCImpl_mwait);
1497}
1498
1499
1500/** Opcode 0x0f 0x01 /2. */
1501FNIEMOP_DEF_1(iemOp_Grp7_lgdt, uint8_t, bRm)
1502{
1503 IEMOP_MNEMONIC(lgdt, "lgdt");
1504 IEMOP_HLP_64BIT_OP_SIZE();
1505 IEM_MC_BEGIN(3, 1, 0, 0);
1506 IEM_MC_ARG(RTGCPTR, GCPtrEffSrc, 1);
1507 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
1508 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1509 IEM_MC_ARG_CONST(uint8_t, iEffSeg, /*=*/ pVCpu->iem.s.iEffSeg, 0);
1510 IEM_MC_ARG_CONST(IEMMODE, enmEffOpSizeArg,/*=*/pVCpu->iem.s.enmEffOpSize, 2);
1511 IEM_MC_CALL_CIMPL_3(IEM_CIMPL_F_VMEXIT, 0, iemCImpl_lgdt, iEffSeg, GCPtrEffSrc, enmEffOpSizeArg);
1512 IEM_MC_END();
1513}
1514
1515
1516/** Opcode 0x0f 0x01 0xd0. */
1517FNIEMOP_DEF(iemOp_Grp7_xgetbv)
1518{
1519 IEMOP_MNEMONIC(xgetbv, "xgetbv");
1520 if (IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fXSaveRstor)
1521 {
1522 /** @todo r=ramshankar: We should use
1523 * IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX and
1524 * IEMOP_HLP_DONE_DECODING_NO_SIZE_OP_REPZ_OR_REPNZ_PREFIXES here. */
1525/** @todo testcase: test prefixes and exceptions. currently not checking for the
1526 * OPSIZE one ... */
1527 IEMOP_HLP_DONE_DECODING_NO_LOCK_REPZ_OR_REPNZ_PREFIXES();
1528 IEM_MC_DEFER_TO_CIMPL_0_RET(0,
1529 RT_BIT_64(kIemNativeGstReg_GprFirst + X86_GREG_xAX)
1530 | RT_BIT_64(kIemNativeGstReg_GprFirst + X86_GREG_xDX),
1531 iemCImpl_xgetbv);
1532 }
1533 IEMOP_RAISE_INVALID_OPCODE_RET();
1534}
1535
1536
1537/** Opcode 0x0f 0x01 0xd1. */
1538FNIEMOP_DEF(iemOp_Grp7_xsetbv)
1539{
1540 IEMOP_MNEMONIC(xsetbv, "xsetbv");
1541 if (IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fXSaveRstor)
1542 {
1543 /** @todo r=ramshankar: We should use
1544 * IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX and
1545 * IEMOP_HLP_DONE_DECODING_NO_SIZE_OP_REPZ_OR_REPNZ_PREFIXES here. */
1546/** @todo testcase: test prefixes and exceptions. currently not checking for the
1547 * OPSIZE one ... */
1548 IEMOP_HLP_DONE_DECODING_NO_LOCK_REPZ_OR_REPNZ_PREFIXES();
1549 IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_VMEXIT, 0, iemCImpl_xsetbv);
1550 }
1551 IEMOP_RAISE_INVALID_OPCODE_RET();
1552}
1553
1554
1555/** Opcode 0x0f 0x01 /3. */
1556FNIEMOP_DEF_1(iemOp_Grp7_lidt, uint8_t, bRm)
1557{
1558 IEMOP_MNEMONIC(lidt, "lidt");
1559 IEMMODE enmEffOpSize = IEM_IS_64BIT_CODE(pVCpu) ? IEMMODE_64BIT : pVCpu->iem.s.enmEffOpSize;
1560 IEM_MC_BEGIN(3, 1, 0, 0);
1561 IEM_MC_ARG(RTGCPTR, GCPtrEffSrc, 1);
1562 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
1563 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1564 IEM_MC_ARG_CONST(uint8_t, iEffSeg, /*=*/ pVCpu->iem.s.iEffSeg, 0);
1565 IEM_MC_ARG_CONST(IEMMODE, enmEffOpSizeArg, /*=*/ enmEffOpSize, 2);
1566 IEM_MC_CALL_CIMPL_3(IEM_CIMPL_F_VMEXIT, 0, iemCImpl_lidt, iEffSeg, GCPtrEffSrc, enmEffOpSizeArg);
1567 IEM_MC_END();
1568}
1569
1570
1571/** Opcode 0x0f 0x01 0xd8. */
1572#ifdef VBOX_WITH_NESTED_HWVIRT_SVM
1573FNIEMOP_DEF(iemOp_Grp7_Amd_vmrun)
1574{
1575 IEMOP_MNEMONIC(vmrun, "vmrun");
1576 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); /** @todo check prefix effect on the SVM instructions. ASSUMING no lock for now. */
1577 IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_BRANCH_INDIRECT | IEM_CIMPL_F_BRANCH_FAR
1578 | IEM_CIMPL_F_MODE | IEM_CIMPL_F_RFLAGS | IEM_CIMPL_F_VMEXIT | IEM_CIMPL_F_END_TB, 0,
1579 iemCImpl_vmrun);
1580}
1581#else
1582FNIEMOP_UD_STUB(iemOp_Grp7_Amd_vmrun);
1583#endif
1584
1585/** Opcode 0x0f 0x01 0xd9. */
1586FNIEMOP_DEF(iemOp_Grp7_Amd_vmmcall)
1587{
1588 IEMOP_MNEMONIC(vmmcall, "vmmcall");
1589 /** @todo r=bird: Table A-8 on page 524 in vol 3 has VMGEXIT for this
1590 * opcode sequence when F3 or F2 is used as prefix. So, the assumtion
1591 * here cannot be right... */
1592 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); /** @todo check prefix effect on the SVM instructions. ASSUMING no lock for now. */
1593
1594 /* Note! We do not check any CPUMFEATURES::fSvm here as we (GIM) generally
1595 want all hypercalls regardless of instruction used, and if a
1596 hypercall isn't handled by GIM or HMSvm will raise an #UD.
1597 (NEM/win makes ASSUMPTIONS about this behavior.) */
1598 IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_VMEXIT | IEM_CIMPL_F_END_TB, 0, iemCImpl_vmmcall);
1599}
1600
1601/** Opcode 0x0f 0x01 0xda. */
1602#ifdef VBOX_WITH_NESTED_HWVIRT_SVM
1603FNIEMOP_DEF(iemOp_Grp7_Amd_vmload)
1604{
1605 IEMOP_MNEMONIC(vmload, "vmload");
1606 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); /** @todo check prefix effect on the SVM instructions. ASSUMING no lock for now. */
1607 IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_VMEXIT, 0, iemCImpl_vmload);
1608}
1609#else
1610FNIEMOP_UD_STUB(iemOp_Grp7_Amd_vmload);
1611#endif
1612
1613
1614/** Opcode 0x0f 0x01 0xdb. */
1615#ifdef VBOX_WITH_NESTED_HWVIRT_SVM
1616FNIEMOP_DEF(iemOp_Grp7_Amd_vmsave)
1617{
1618 IEMOP_MNEMONIC(vmsave, "vmsave");
1619 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); /** @todo check prefix effect on the SVM instructions. ASSUMING no lock for now. */
1620 IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_VMEXIT, 0, iemCImpl_vmsave);
1621}
1622#else
1623FNIEMOP_UD_STUB(iemOp_Grp7_Amd_vmsave);
1624#endif
1625
1626
1627/** Opcode 0x0f 0x01 0xdc. */
1628#ifdef VBOX_WITH_NESTED_HWVIRT_SVM
1629FNIEMOP_DEF(iemOp_Grp7_Amd_stgi)
1630{
1631 IEMOP_MNEMONIC(stgi, "stgi");
1632 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); /** @todo check prefix effect on the SVM instructions. ASSUMING no lock for now. */
1633 IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_VMEXIT, 0, iemCImpl_stgi);
1634}
1635#else
1636FNIEMOP_UD_STUB(iemOp_Grp7_Amd_stgi);
1637#endif
1638
1639
1640/** Opcode 0x0f 0x01 0xdd. */
1641#ifdef VBOX_WITH_NESTED_HWVIRT_SVM
1642FNIEMOP_DEF(iemOp_Grp7_Amd_clgi)
1643{
1644 IEMOP_MNEMONIC(clgi, "clgi");
1645 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); /** @todo check prefix effect on the SVM instructions. ASSUMING no lock for now. */
1646 IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_VMEXIT, 0, iemCImpl_clgi);
1647}
1648#else
1649FNIEMOP_UD_STUB(iemOp_Grp7_Amd_clgi);
1650#endif
1651
1652
1653/** Opcode 0x0f 0x01 0xdf. */
1654#ifdef VBOX_WITH_NESTED_HWVIRT_SVM
1655FNIEMOP_DEF(iemOp_Grp7_Amd_invlpga)
1656{
1657 IEMOP_MNEMONIC(invlpga, "invlpga");
1658 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); /** @todo check prefix effect on the SVM instructions. ASSUMING no lock for now. */
1659 IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_VMEXIT, 0, iemCImpl_invlpga);
1660}
1661#else
1662FNIEMOP_UD_STUB(iemOp_Grp7_Amd_invlpga);
1663#endif
1664
1665
1666/** Opcode 0x0f 0x01 0xde. */
1667#ifdef VBOX_WITH_NESTED_HWVIRT_SVM
1668FNIEMOP_DEF(iemOp_Grp7_Amd_skinit)
1669{
1670 IEMOP_MNEMONIC(skinit, "skinit");
1671 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); /** @todo check prefix effect on the SVM instructions. ASSUMING no lock for now. */
1672 IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_VMEXIT, 0, iemCImpl_skinit);
1673}
1674#else
1675FNIEMOP_UD_STUB(iemOp_Grp7_Amd_skinit);
1676#endif
1677
1678
1679/** Opcode 0x0f 0x01 /4. */
1680FNIEMOP_DEF_1(iemOp_Grp7_smsw, uint8_t, bRm)
1681{
1682 IEMOP_MNEMONIC(smsw, "smsw");
1683 IEMOP_HLP_MIN_286();
1684 if (IEM_IS_MODRM_REG_MODE(bRm))
1685 {
1686 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1687 IEM_MC_DEFER_TO_CIMPL_2_RET(IEM_CIMPL_F_VMEXIT, RT_BIT_64(kIemNativeGstReg_GprFirst + IEM_GET_MODRM_RM(pVCpu, bRm)),
1688 iemCImpl_smsw_reg, IEM_GET_MODRM_RM(pVCpu, bRm), pVCpu->iem.s.enmEffOpSize);
1689 }
1690
1691 /* Ignore operand size here, memory refs are always 16-bit. */
1692 IEM_MC_BEGIN(2, 0, IEM_MC_F_MIN_286, 0);
1693 IEM_MC_ARG(RTGCPTR, GCPtrEffDst, 1);
1694 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
1695 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1696 IEM_MC_ARG_CONST(uint8_t, iEffSeg, /*=*/ pVCpu->iem.s.iEffSeg, 0);
1697 IEM_MC_CALL_CIMPL_2(IEM_CIMPL_F_VMEXIT, 0, iemCImpl_smsw_mem, iEffSeg, GCPtrEffDst);
1698 IEM_MC_END();
1699}
1700
1701
1702/** Opcode 0x0f 0x01 /6. */
1703FNIEMOP_DEF_1(iemOp_Grp7_lmsw, uint8_t, bRm)
1704{
1705 /* The operand size is effectively ignored, all is 16-bit and only the
1706 lower 3-bits are used. */
1707 IEMOP_MNEMONIC(lmsw, "lmsw");
1708 IEMOP_HLP_MIN_286();
1709 if (IEM_IS_MODRM_REG_MODE(bRm))
1710 {
1711 IEM_MC_BEGIN(2, 0, IEM_MC_F_MIN_286, 0);
1712 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1713 IEM_MC_ARG(uint16_t, u16Tmp, 0);
1714 IEM_MC_ARG_CONST(RTGCPTR, GCPtrEffDst, NIL_RTGCPTR, 1);
1715 IEM_MC_FETCH_GREG_U16(u16Tmp, IEM_GET_MODRM_RM(pVCpu, bRm));
1716 IEM_MC_CALL_CIMPL_2(IEM_CIMPL_F_MODE | IEM_CIMPL_F_VMEXIT, 0, iemCImpl_lmsw, u16Tmp, GCPtrEffDst);
1717 IEM_MC_END();
1718 }
1719 else
1720 {
1721 IEM_MC_BEGIN(2, 0, IEM_MC_F_MIN_286, 0);
1722 IEM_MC_ARG(uint16_t, u16Tmp, 0);
1723 IEM_MC_ARG(RTGCPTR, GCPtrEffDst, 1);
1724 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
1725 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1726 IEM_MC_FETCH_MEM_U16(u16Tmp, pVCpu->iem.s.iEffSeg, GCPtrEffDst);
1727 IEM_MC_CALL_CIMPL_2(IEM_CIMPL_F_MODE | IEM_CIMPL_F_VMEXIT, 0, iemCImpl_lmsw, u16Tmp, GCPtrEffDst);
1728 IEM_MC_END();
1729 }
1730}
1731
1732
1733/** Opcode 0x0f 0x01 /7. */
1734FNIEMOP_DEF_1(iemOp_Grp7_invlpg, uint8_t, bRm)
1735{
1736 IEMOP_MNEMONIC(invlpg, "invlpg");
1737 IEMOP_HLP_MIN_486();
1738 IEM_MC_BEGIN(1, 1, IEM_MC_F_MIN_386, 0);
1739 IEM_MC_ARG(RTGCPTR, GCPtrEffDst, 0);
1740 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
1741 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1742 IEM_MC_CALL_CIMPL_1(IEM_CIMPL_F_VMEXIT, 0, iemCImpl_invlpg, GCPtrEffDst);
1743 IEM_MC_END();
1744}
1745
1746
1747/** Opcode 0x0f 0x01 0xf8. */
1748FNIEMOP_DEF(iemOp_Grp7_swapgs)
1749{
1750 IEMOP_MNEMONIC(swapgs, "swapgs");
1751 IEMOP_HLP_ONLY_64BIT();
1752 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1753 IEM_MC_DEFER_TO_CIMPL_0_RET(0, RT_BIT_64(kIemNativeGstReg_SegBaseFirst + X86_SREG_GS), iemCImpl_swapgs);
1754}
1755
1756
1757/** Opcode 0x0f 0x01 0xf9. */
1758FNIEMOP_DEF(iemOp_Grp7_rdtscp)
1759{
1760 IEMOP_MNEMONIC(rdtscp, "rdtscp");
1761 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1762 IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_VMEXIT,
1763 RT_BIT_64(kIemNativeGstReg_GprFirst + X86_GREG_xAX)
1764 | RT_BIT_64(kIemNativeGstReg_GprFirst + X86_GREG_xDX)
1765 | RT_BIT_64(kIemNativeGstReg_GprFirst + X86_GREG_xCX),
1766 iemCImpl_rdtscp);
1767}
1768
1769
1770/**
1771 * Group 7 jump table, memory variant.
1772 */
1773IEM_STATIC const PFNIEMOPRM g_apfnGroup7Mem[8] =
1774{
1775 iemOp_Grp7_sgdt,
1776 iemOp_Grp7_sidt,
1777 iemOp_Grp7_lgdt,
1778 iemOp_Grp7_lidt,
1779 iemOp_Grp7_smsw,
1780 iemOp_InvalidWithRM,
1781 iemOp_Grp7_lmsw,
1782 iemOp_Grp7_invlpg
1783};
1784
1785
1786/** Opcode 0x0f 0x01. */
1787FNIEMOP_DEF(iemOp_Grp7)
1788{
1789 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
1790 if (IEM_IS_MODRM_MEM_MODE(bRm))
1791 return FNIEMOP_CALL_1(g_apfnGroup7Mem[IEM_GET_MODRM_REG_8(bRm)], bRm);
1792
1793 switch (IEM_GET_MODRM_REG_8(bRm))
1794 {
1795 case 0:
1796 switch (IEM_GET_MODRM_RM_8(bRm))
1797 {
1798 case 1: return FNIEMOP_CALL(iemOp_Grp7_vmcall);
1799 case 2: return FNIEMOP_CALL(iemOp_Grp7_vmlaunch);
1800 case 3: return FNIEMOP_CALL(iemOp_Grp7_vmresume);
1801 case 4: return FNIEMOP_CALL(iemOp_Grp7_vmxoff);
1802 }
1803 IEMOP_RAISE_INVALID_OPCODE_RET();
1804
1805 case 1:
1806 switch (IEM_GET_MODRM_RM_8(bRm))
1807 {
1808 case 0: return FNIEMOP_CALL(iemOp_Grp7_monitor);
1809 case 1: return FNIEMOP_CALL(iemOp_Grp7_mwait);
1810 }
1811 IEMOP_RAISE_INVALID_OPCODE_RET();
1812
1813 case 2:
1814 switch (IEM_GET_MODRM_RM_8(bRm))
1815 {
1816 case 0: return FNIEMOP_CALL(iemOp_Grp7_xgetbv);
1817 case 1: return FNIEMOP_CALL(iemOp_Grp7_xsetbv);
1818 }
1819 IEMOP_RAISE_INVALID_OPCODE_RET();
1820
1821 case 3:
1822 switch (IEM_GET_MODRM_RM_8(bRm))
1823 {
1824 case 0: return FNIEMOP_CALL(iemOp_Grp7_Amd_vmrun);
1825 case 1: return FNIEMOP_CALL(iemOp_Grp7_Amd_vmmcall);
1826 case 2: return FNIEMOP_CALL(iemOp_Grp7_Amd_vmload);
1827 case 3: return FNIEMOP_CALL(iemOp_Grp7_Amd_vmsave);
1828 case 4: return FNIEMOP_CALL(iemOp_Grp7_Amd_stgi);
1829 case 5: return FNIEMOP_CALL(iemOp_Grp7_Amd_clgi);
1830 case 6: return FNIEMOP_CALL(iemOp_Grp7_Amd_skinit);
1831 case 7: return FNIEMOP_CALL(iemOp_Grp7_Amd_invlpga);
1832 IEM_NOT_REACHED_DEFAULT_CASE_RET();
1833 }
1834
1835 case 4:
1836 return FNIEMOP_CALL_1(iemOp_Grp7_smsw, bRm);
1837
1838 case 5:
1839 IEMOP_RAISE_INVALID_OPCODE_RET();
1840
1841 case 6:
1842 return FNIEMOP_CALL_1(iemOp_Grp7_lmsw, bRm);
1843
1844 case 7:
1845 switch (IEM_GET_MODRM_RM_8(bRm))
1846 {
1847 case 0: return FNIEMOP_CALL(iemOp_Grp7_swapgs);
1848 case 1: return FNIEMOP_CALL(iemOp_Grp7_rdtscp);
1849 }
1850 IEMOP_RAISE_INVALID_OPCODE_RET();
1851
1852 IEM_NOT_REACHED_DEFAULT_CASE_RET();
1853 }
1854}
1855
1856/** Opcode 0x0f 0x00 /3. */
1857FNIEMOP_DEF_1(iemOpCommonLarLsl_Gv_Ew, bool, fIsLar)
1858{
1859 IEMOP_HLP_NO_REAL_OR_V86_MODE();
1860 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
1861
1862 if (IEM_IS_MODRM_REG_MODE(bRm))
1863 {
1864 switch (pVCpu->iem.s.enmEffOpSize)
1865 {
1866 case IEMMODE_16BIT:
1867 IEM_MC_BEGIN(3, 0, 0, 0);
1868 IEMOP_HLP_DECODED_NL_2(fIsLar ? OP_LAR : OP_LSL, IEMOPFORM_RM_REG, OP_PARM_Gv, OP_PARM_Ew, DISOPTYPE_DANGEROUS | DISOPTYPE_PRIVILEGED_NOTRAP);
1869 IEM_MC_ARG(uint16_t *, pu16Dst, 0);
1870 IEM_MC_ARG(uint16_t, u16Sel, 1);
1871 IEM_MC_ARG_CONST(bool, fIsLarArg, fIsLar, 2);
1872
1873 IEM_MC_FETCH_GREG_U16(u16Sel, IEM_GET_MODRM_RM(pVCpu, bRm));
1874 IEM_MC_REF_GREG_U16(pu16Dst, IEM_GET_MODRM_REG(pVCpu, bRm));
1875 IEM_MC_CALL_CIMPL_3(IEM_CIMPL_F_STATUS_FLAGS, RT_BIT_64(kIemNativeGstReg_GprFirst + IEM_GET_MODRM_REG(pVCpu, bRm)),
1876 iemCImpl_LarLsl_u16, pu16Dst, u16Sel, fIsLarArg);
1877
1878 IEM_MC_END();
1879 break;
1880
1881 case IEMMODE_32BIT:
1882 case IEMMODE_64BIT:
1883 IEM_MC_BEGIN(3, 0, IEM_MC_F_MIN_386, 0);
1884 IEMOP_HLP_DECODED_NL_2(fIsLar ? OP_LAR : OP_LSL, IEMOPFORM_RM_REG, OP_PARM_Gv, OP_PARM_Ew, DISOPTYPE_DANGEROUS | DISOPTYPE_PRIVILEGED_NOTRAP);
1885 IEM_MC_ARG(uint64_t *, pu64Dst, 0);
1886 IEM_MC_ARG(uint16_t, u16Sel, 1);
1887 IEM_MC_ARG_CONST(bool, fIsLarArg, fIsLar, 2);
1888
1889 IEM_MC_FETCH_GREG_U16(u16Sel, IEM_GET_MODRM_RM(pVCpu, bRm));
1890 IEM_MC_REF_GREG_U64(pu64Dst, IEM_GET_MODRM_REG(pVCpu, bRm));
1891 IEM_MC_CALL_CIMPL_3(IEM_CIMPL_F_STATUS_FLAGS, RT_BIT_64(kIemNativeGstReg_GprFirst + IEM_GET_MODRM_REG(pVCpu, bRm)),
1892 iemCImpl_LarLsl_u64, pu64Dst, u16Sel, fIsLarArg);
1893
1894 IEM_MC_END();
1895 break;
1896
1897 IEM_NOT_REACHED_DEFAULT_CASE_RET();
1898 }
1899 }
1900 else
1901 {
1902 switch (pVCpu->iem.s.enmEffOpSize)
1903 {
1904 case IEMMODE_16BIT:
1905 IEM_MC_BEGIN(3, 1, 0, 0);
1906 IEM_MC_ARG(uint16_t *, pu16Dst, 0);
1907 IEM_MC_ARG(uint16_t, u16Sel, 1);
1908 IEM_MC_ARG_CONST(bool, fIsLarArg, fIsLar, 2);
1909 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
1910
1911 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
1912 IEMOP_HLP_DECODED_NL_2(fIsLar ? OP_LAR : OP_LSL, IEMOPFORM_RM_MEM, OP_PARM_Gv, OP_PARM_Ew, DISOPTYPE_DANGEROUS | DISOPTYPE_PRIVILEGED_NOTRAP);
1913
1914 IEM_MC_FETCH_MEM_U16(u16Sel, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
1915 IEM_MC_REF_GREG_U16(pu16Dst, IEM_GET_MODRM_REG(pVCpu, bRm));
1916 IEM_MC_CALL_CIMPL_3(IEM_CIMPL_F_STATUS_FLAGS, RT_BIT_64(kIemNativeGstReg_GprFirst + IEM_GET_MODRM_REG(pVCpu, bRm)),
1917 iemCImpl_LarLsl_u16, pu16Dst, u16Sel, fIsLarArg);
1918
1919 IEM_MC_END();
1920 break;
1921
1922 case IEMMODE_32BIT:
1923 case IEMMODE_64BIT:
1924 IEM_MC_BEGIN(3, 1, IEM_MC_F_MIN_386, 0);
1925 IEM_MC_ARG(uint64_t *, pu64Dst, 0);
1926 IEM_MC_ARG(uint16_t, u16Sel, 1);
1927 IEM_MC_ARG_CONST(bool, fIsLarArg, fIsLar, 2);
1928 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
1929
1930 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
1931 IEMOP_HLP_DECODED_NL_2(fIsLar ? OP_LAR : OP_LSL, IEMOPFORM_RM_MEM, OP_PARM_Gv, OP_PARM_Ew, DISOPTYPE_DANGEROUS | DISOPTYPE_PRIVILEGED_NOTRAP);
1932/** @todo testcase: make sure it's a 16-bit read. */
1933
1934 IEM_MC_FETCH_MEM_U16(u16Sel, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
1935 IEM_MC_REF_GREG_U64(pu64Dst, IEM_GET_MODRM_REG(pVCpu, bRm));
1936 IEM_MC_CALL_CIMPL_3(IEM_CIMPL_F_STATUS_FLAGS, RT_BIT_64(kIemNativeGstReg_GprFirst + IEM_GET_MODRM_REG(pVCpu, bRm)),
1937 iemCImpl_LarLsl_u64, pu64Dst, u16Sel, fIsLarArg);
1938
1939 IEM_MC_END();
1940 break;
1941
1942 IEM_NOT_REACHED_DEFAULT_CASE_RET();
1943 }
1944 }
1945}
1946
1947
1948
1949/** Opcode 0x0f 0x02. */
1950FNIEMOP_DEF(iemOp_lar_Gv_Ew)
1951{
1952 IEMOP_MNEMONIC(lar, "lar Gv,Ew");
1953 return FNIEMOP_CALL_1(iemOpCommonLarLsl_Gv_Ew, true);
1954}
1955
1956
1957/** Opcode 0x0f 0x03. */
1958FNIEMOP_DEF(iemOp_lsl_Gv_Ew)
1959{
1960 IEMOP_MNEMONIC(lsl, "lsl Gv,Ew");
1961 return FNIEMOP_CALL_1(iemOpCommonLarLsl_Gv_Ew, false);
1962}
1963
1964
1965/** Opcode 0x0f 0x05. */
1966FNIEMOP_DEF(iemOp_syscall)
1967{
1968 IEMOP_MNEMONIC(syscall, "syscall"); /** @todo 286 LOADALL */
1969 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1970 IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_BRANCH_INDIRECT | IEM_CIMPL_F_BRANCH_FAR | IEM_CIMPL_F_BRANCH_STACK_FAR
1971 | IEM_CIMPL_F_MODE | IEM_CIMPL_F_RFLAGS | IEM_CIMPL_F_END_TB, 0,
1972 iemCImpl_syscall);
1973}
1974
1975
1976/** Opcode 0x0f 0x06. */
1977FNIEMOP_DEF(iemOp_clts)
1978{
1979 IEMOP_MNEMONIC(clts, "clts");
1980 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1981 IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_VMEXIT, 0, iemCImpl_clts);
1982}
1983
1984
1985/** Opcode 0x0f 0x07. */
1986FNIEMOP_DEF(iemOp_sysret)
1987{
1988 IEMOP_MNEMONIC(sysret, "sysret"); /** @todo 386 LOADALL */
1989 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1990 IEM_MC_DEFER_TO_CIMPL_1_RET(IEM_CIMPL_F_BRANCH_INDIRECT | IEM_CIMPL_F_BRANCH_FAR | IEM_CIMPL_F_BRANCH_STACK_FAR
1991 | IEM_CIMPL_F_MODE | IEM_CIMPL_F_RFLAGS | IEM_CIMPL_F_END_TB, 0,
1992 iemCImpl_sysret, pVCpu->iem.s.enmEffOpSize);
1993}
1994
1995
1996/** Opcode 0x0f 0x08. */
1997FNIEMOP_DEF(iemOp_invd)
1998{
1999 IEMOP_MNEMONIC0(FIXED, INVD, invd, DISOPTYPE_PRIVILEGED, 0);
2000 IEMOP_HLP_MIN_486();
2001 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
2002 IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_VMEXIT, 0, iemCImpl_invd);
2003}
2004
2005
2006/** Opcode 0x0f 0x09. */
2007FNIEMOP_DEF(iemOp_wbinvd)
2008{
2009 IEMOP_MNEMONIC0(FIXED, WBINVD, wbinvd, DISOPTYPE_PRIVILEGED, 0);
2010 IEMOP_HLP_MIN_486();
2011 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
2012 IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_VMEXIT, 0, iemCImpl_wbinvd);
2013}
2014
2015
2016/** Opcode 0x0f 0x0b. */
2017FNIEMOP_DEF(iemOp_ud2)
2018{
2019 IEMOP_MNEMONIC(ud2, "ud2");
2020 IEMOP_RAISE_INVALID_OPCODE_RET();
2021}
2022
2023/** Opcode 0x0f 0x0d. */
2024FNIEMOP_DEF(iemOp_nop_Ev_GrpP)
2025{
2026 /* AMD prefetch group, Intel implements this as NOP Ev (and so do we). */
2027 if (!IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fLongMode && !IEM_GET_GUEST_CPU_FEATURES(pVCpu)->f3DNowPrefetch)
2028 {
2029 IEMOP_MNEMONIC(GrpPNotSupported, "GrpP");
2030 IEMOP_RAISE_INVALID_OPCODE_RET();
2031 }
2032
2033 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
2034 if (IEM_IS_MODRM_REG_MODE(bRm))
2035 {
2036 IEMOP_MNEMONIC(GrpPInvalid, "GrpP");
2037 IEMOP_RAISE_INVALID_OPCODE_RET();
2038 }
2039
2040 switch (IEM_GET_MODRM_REG_8(bRm))
2041 {
2042 case 2: /* Aliased to /0 for the time being. */
2043 case 4: /* Aliased to /0 for the time being. */
2044 case 5: /* Aliased to /0 for the time being. */
2045 case 6: /* Aliased to /0 for the time being. */
2046 case 7: /* Aliased to /0 for the time being. */
2047 case 0: IEMOP_MNEMONIC(prefetch, "prefetch"); break;
2048 case 1: IEMOP_MNEMONIC(prefetchw_1, "prefetchw"); break;
2049 case 3: IEMOP_MNEMONIC(prefetchw_3, "prefetchw"); break;
2050 IEM_NOT_REACHED_DEFAULT_CASE_RET();
2051 }
2052
2053 IEM_MC_BEGIN(0, 1, 0, 0);
2054 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
2055 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
2056 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
2057 /* Currently a NOP. */
2058 NOREF(GCPtrEffSrc);
2059 IEM_MC_ADVANCE_RIP_AND_FINISH();
2060 IEM_MC_END();
2061}
2062
2063
2064/** Opcode 0x0f 0x0e. */
2065FNIEMOP_DEF(iemOp_femms)
2066{
2067 IEMOP_MNEMONIC(femms, "femms");
2068
2069 IEM_MC_BEGIN(0, 0, 0, 0);
2070 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
2071 IEM_MC_MAYBE_RAISE_DEVICE_NOT_AVAILABLE();
2072 IEM_MC_MAYBE_RAISE_FPU_XCPT();
2073 IEM_MC_ACTUALIZE_FPU_STATE_FOR_CHANGE();
2074 IEM_MC_FPU_FROM_MMX_MODE();
2075 IEM_MC_ADVANCE_RIP_AND_FINISH();
2076 IEM_MC_END();
2077}
2078
2079
2080/** Opcode 0x0f 0x0f. */
2081FNIEMOP_DEF(iemOp_3Dnow)
2082{
2083 if (!IEM_GET_GUEST_CPU_FEATURES(pVCpu)->f3DNow)
2084 {
2085 IEMOP_MNEMONIC(Inv3Dnow, "3Dnow");
2086 IEMOP_RAISE_INVALID_OPCODE_RET();
2087 }
2088
2089#ifdef IEM_WITH_3DNOW
2090 /* This is pretty sparse, use switch instead of table. */
2091 uint8_t b; IEM_OPCODE_GET_NEXT_U8(&b);
2092 return FNIEMOP_CALL_1(iemOp_3DNowDispatcher, b);
2093#else
2094 IEMOP_BITCH_ABOUT_STUB();
2095 return VERR_IEM_INSTR_NOT_IMPLEMENTED;
2096#endif
2097}
2098
2099
2100/**
2101 * @opcode 0x10
2102 * @oppfx none
2103 * @opcpuid sse
2104 * @opgroup og_sse_simdfp_datamove
2105 * @opxcpttype 4UA
2106 * @optest op1=1 op2=2 -> op1=2
2107 * @optest op1=0 op2=-22 -> op1=-22
2108 */
2109FNIEMOP_DEF(iemOp_movups_Vps_Wps)
2110{
2111 IEMOP_MNEMONIC2(RM, MOVUPS, movups, Vps_WO, Wps, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
2112 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
2113 if (IEM_IS_MODRM_REG_MODE(bRm))
2114 {
2115 /*
2116 * XMM128, XMM128.
2117 */
2118 IEM_MC_BEGIN(0, 0, 0, 0);
2119 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
2120 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
2121 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
2122 IEM_MC_COPY_XREG_U128(IEM_GET_MODRM_REG(pVCpu, bRm),
2123 IEM_GET_MODRM_RM(pVCpu, bRm));
2124 IEM_MC_ADVANCE_RIP_AND_FINISH();
2125 IEM_MC_END();
2126 }
2127 else
2128 {
2129 /*
2130 * XMM128, [mem128].
2131 */
2132 IEM_MC_BEGIN(0, 2, 0, 0);
2133 IEM_MC_LOCAL(RTUINT128U, uSrc); /** @todo optimize this one day... */
2134 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
2135
2136 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
2137 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
2138 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
2139 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
2140
2141 IEM_MC_FETCH_MEM_U128(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
2142 IEM_MC_STORE_XREG_U128(IEM_GET_MODRM_REG(pVCpu, bRm), uSrc);
2143
2144 IEM_MC_ADVANCE_RIP_AND_FINISH();
2145 IEM_MC_END();
2146 }
2147
2148}
2149
2150
2151/**
2152 * @opcode 0x10
2153 * @oppfx 0x66
2154 * @opcpuid sse2
2155 * @opgroup og_sse2_pcksclr_datamove
2156 * @opxcpttype 4UA
2157 * @optest op1=1 op2=2 -> op1=2
2158 * @optest op1=0 op2=-42 -> op1=-42
2159 */
2160FNIEMOP_DEF(iemOp_movupd_Vpd_Wpd)
2161{
2162 IEMOP_MNEMONIC2(RM, MOVUPD, movupd, Vpd_WO, Wpd, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
2163 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
2164 if (IEM_IS_MODRM_REG_MODE(bRm))
2165 {
2166 /*
2167 * XMM128, XMM128.
2168 */
2169 IEM_MC_BEGIN(0, 0, 0, 0);
2170 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
2171 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
2172 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
2173 IEM_MC_COPY_XREG_U128(IEM_GET_MODRM_REG(pVCpu, bRm),
2174 IEM_GET_MODRM_RM(pVCpu, bRm));
2175 IEM_MC_ADVANCE_RIP_AND_FINISH();
2176 IEM_MC_END();
2177 }
2178 else
2179 {
2180 /*
2181 * XMM128, [mem128].
2182 */
2183 IEM_MC_BEGIN(0, 2, 0, 0);
2184 IEM_MC_LOCAL(RTUINT128U, uSrc); /** @todo optimize this one day... */
2185 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
2186
2187 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
2188 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
2189 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
2190 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
2191
2192 IEM_MC_FETCH_MEM_U128(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
2193 IEM_MC_STORE_XREG_U128(IEM_GET_MODRM_REG(pVCpu, bRm), uSrc);
2194
2195 IEM_MC_ADVANCE_RIP_AND_FINISH();
2196 IEM_MC_END();
2197 }
2198}
2199
2200
2201/**
2202 * @opcode 0x10
2203 * @oppfx 0xf3
2204 * @opcpuid sse
2205 * @opgroup og_sse_simdfp_datamove
2206 * @opxcpttype 5
2207 * @optest op1=1 op2=2 -> op1=2
2208 * @optest op1=0 op2=-22 -> op1=-22
2209 */
2210FNIEMOP_DEF(iemOp_movss_Vss_Wss)
2211{
2212 IEMOP_MNEMONIC2(RM, MOVSS, movss, VssZx_WO, Wss, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
2213 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
2214 if (IEM_IS_MODRM_REG_MODE(bRm))
2215 {
2216 /*
2217 * XMM32, XMM32.
2218 */
2219 IEM_MC_BEGIN(0, 1, 0, 0);
2220 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
2221 IEM_MC_LOCAL(uint32_t, uSrc);
2222
2223 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
2224 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
2225 IEM_MC_FETCH_XREG_U32(uSrc, IEM_GET_MODRM_RM(pVCpu, bRm), 0 /*a_iDword*/ );
2226 IEM_MC_STORE_XREG_U32(IEM_GET_MODRM_REG(pVCpu, bRm), 0 /*a_iDword*/, uSrc);
2227
2228 IEM_MC_ADVANCE_RIP_AND_FINISH();
2229 IEM_MC_END();
2230 }
2231 else
2232 {
2233 /*
2234 * XMM128, [mem32].
2235 */
2236 IEM_MC_BEGIN(0, 2, 0, 0);
2237 IEM_MC_LOCAL(uint32_t, uSrc);
2238 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
2239
2240 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
2241 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
2242 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
2243 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
2244
2245 IEM_MC_FETCH_MEM_U32(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
2246 IEM_MC_STORE_XREG_U32_ZX_U128(IEM_GET_MODRM_REG(pVCpu, bRm), uSrc);
2247
2248 IEM_MC_ADVANCE_RIP_AND_FINISH();
2249 IEM_MC_END();
2250 }
2251}
2252
2253
2254/**
2255 * @opcode 0x10
2256 * @oppfx 0xf2
2257 * @opcpuid sse2
2258 * @opgroup og_sse2_pcksclr_datamove
2259 * @opxcpttype 5
2260 * @optest op1=1 op2=2 -> op1=2
2261 * @optest op1=0 op2=-42 -> op1=-42
2262 */
2263FNIEMOP_DEF(iemOp_movsd_Vsd_Wsd)
2264{
2265 IEMOP_MNEMONIC2(RM, MOVSD, movsd, VsdZx_WO, Wsd, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
2266 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
2267 if (IEM_IS_MODRM_REG_MODE(bRm))
2268 {
2269 /*
2270 * XMM64, XMM64.
2271 */
2272 IEM_MC_BEGIN(0, 1, 0, 0);
2273 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
2274 IEM_MC_LOCAL(uint64_t, uSrc);
2275
2276 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
2277 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
2278 IEM_MC_FETCH_XREG_U64(uSrc, IEM_GET_MODRM_RM(pVCpu, bRm), 0 /* a_iQword*/);
2279 IEM_MC_STORE_XREG_U64(IEM_GET_MODRM_REG(pVCpu, bRm), 0 /* a_iQword*/, uSrc);
2280
2281 IEM_MC_ADVANCE_RIP_AND_FINISH();
2282 IEM_MC_END();
2283 }
2284 else
2285 {
2286 /*
2287 * XMM128, [mem64].
2288 */
2289 IEM_MC_BEGIN(0, 2, 0, 0);
2290 IEM_MC_LOCAL(uint64_t, uSrc);
2291 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
2292
2293 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
2294 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
2295 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
2296 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
2297
2298 IEM_MC_FETCH_MEM_U64(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
2299 IEM_MC_STORE_XREG_U64_ZX_U128(IEM_GET_MODRM_REG(pVCpu, bRm), uSrc);
2300
2301 IEM_MC_ADVANCE_RIP_AND_FINISH();
2302 IEM_MC_END();
2303 }
2304}
2305
2306
2307/**
2308 * @opcode 0x11
2309 * @oppfx none
2310 * @opcpuid sse
2311 * @opgroup og_sse_simdfp_datamove
2312 * @opxcpttype 4UA
2313 * @optest op1=1 op2=2 -> op1=2
2314 * @optest op1=0 op2=-42 -> op1=-42
2315 */
2316FNIEMOP_DEF(iemOp_movups_Wps_Vps)
2317{
2318 IEMOP_MNEMONIC2(MR, MOVUPS, movups, Wps_WO, Vps, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
2319 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
2320 if (IEM_IS_MODRM_REG_MODE(bRm))
2321 {
2322 /*
2323 * XMM128, XMM128.
2324 */
2325 IEM_MC_BEGIN(0, 0, 0, 0);
2326 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
2327 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
2328 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
2329 IEM_MC_COPY_XREG_U128(IEM_GET_MODRM_RM(pVCpu, bRm),
2330 IEM_GET_MODRM_REG(pVCpu, bRm));
2331 IEM_MC_ADVANCE_RIP_AND_FINISH();
2332 IEM_MC_END();
2333 }
2334 else
2335 {
2336 /*
2337 * [mem128], XMM128.
2338 */
2339 IEM_MC_BEGIN(0, 2, 0, 0);
2340 IEM_MC_LOCAL(RTUINT128U, uSrc); /** @todo optimize this one day... */
2341 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
2342
2343 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
2344 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
2345 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
2346 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
2347
2348 IEM_MC_FETCH_XREG_U128(uSrc, IEM_GET_MODRM_REG(pVCpu, bRm));
2349 IEM_MC_STORE_MEM_U128(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, uSrc);
2350
2351 IEM_MC_ADVANCE_RIP_AND_FINISH();
2352 IEM_MC_END();
2353 }
2354}
2355
2356
2357/**
2358 * @opcode 0x11
2359 * @oppfx 0x66
2360 * @opcpuid sse2
2361 * @opgroup og_sse2_pcksclr_datamove
2362 * @opxcpttype 4UA
2363 * @optest op1=1 op2=2 -> op1=2
2364 * @optest op1=0 op2=-42 -> op1=-42
2365 */
2366FNIEMOP_DEF(iemOp_movupd_Wpd_Vpd)
2367{
2368 IEMOP_MNEMONIC2(MR, MOVUPD, movupd, Wpd_WO, Vpd, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
2369 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
2370 if (IEM_IS_MODRM_REG_MODE(bRm))
2371 {
2372 /*
2373 * XMM128, XMM128.
2374 */
2375 IEM_MC_BEGIN(0, 0, 0, 0);
2376 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
2377 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
2378 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
2379 IEM_MC_COPY_XREG_U128(IEM_GET_MODRM_RM(pVCpu, bRm),
2380 IEM_GET_MODRM_REG(pVCpu, bRm));
2381 IEM_MC_ADVANCE_RIP_AND_FINISH();
2382 IEM_MC_END();
2383 }
2384 else
2385 {
2386 /*
2387 * [mem128], XMM128.
2388 */
2389 IEM_MC_BEGIN(0, 2, 0, 0);
2390 IEM_MC_LOCAL(RTUINT128U, uSrc); /** @todo optimize this one day... */
2391 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
2392
2393 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
2394 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
2395 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
2396 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
2397
2398 IEM_MC_FETCH_XREG_U128(uSrc, IEM_GET_MODRM_REG(pVCpu, bRm));
2399 IEM_MC_STORE_MEM_U128(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, uSrc);
2400
2401 IEM_MC_ADVANCE_RIP_AND_FINISH();
2402 IEM_MC_END();
2403 }
2404}
2405
2406
2407/**
2408 * @opcode 0x11
2409 * @oppfx 0xf3
2410 * @opcpuid sse
2411 * @opgroup og_sse_simdfp_datamove
2412 * @opxcpttype 5
2413 * @optest op1=1 op2=2 -> op1=2
2414 * @optest op1=0 op2=-22 -> op1=-22
2415 */
2416FNIEMOP_DEF(iemOp_movss_Wss_Vss)
2417{
2418 IEMOP_MNEMONIC2(MR, MOVSS, movss, Wss_WO, Vss, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
2419 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
2420 if (IEM_IS_MODRM_REG_MODE(bRm))
2421 {
2422 /*
2423 * XMM32, XMM32.
2424 */
2425 IEM_MC_BEGIN(0, 1, 0, 0);
2426 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
2427 IEM_MC_LOCAL(uint32_t, uSrc);
2428
2429 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
2430 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
2431 IEM_MC_FETCH_XREG_U32(uSrc, IEM_GET_MODRM_REG(pVCpu, bRm), 0 /*a_iDword*/);
2432 IEM_MC_STORE_XREG_U32(IEM_GET_MODRM_RM(pVCpu, bRm), 0 /*a_iDword*/, uSrc);
2433
2434 IEM_MC_ADVANCE_RIP_AND_FINISH();
2435 IEM_MC_END();
2436 }
2437 else
2438 {
2439 /*
2440 * [mem32], XMM32.
2441 */
2442 IEM_MC_BEGIN(0, 2, 0, 0);
2443 IEM_MC_LOCAL(uint32_t, uSrc);
2444 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
2445
2446 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
2447 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
2448 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
2449 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
2450
2451 IEM_MC_FETCH_XREG_U32(uSrc, IEM_GET_MODRM_REG(pVCpu, bRm), 0 /*a_iDword*/);
2452 IEM_MC_STORE_MEM_U32(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, uSrc);
2453
2454 IEM_MC_ADVANCE_RIP_AND_FINISH();
2455 IEM_MC_END();
2456 }
2457}
2458
2459
2460/**
2461 * @opcode 0x11
2462 * @oppfx 0xf2
2463 * @opcpuid sse2
2464 * @opgroup og_sse2_pcksclr_datamove
2465 * @opxcpttype 5
2466 * @optest op1=1 op2=2 -> op1=2
2467 * @optest op1=0 op2=-42 -> op1=-42
2468 */
2469FNIEMOP_DEF(iemOp_movsd_Wsd_Vsd)
2470{
2471 IEMOP_MNEMONIC2(MR, MOVSD, movsd, Wsd_WO, Vsd, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
2472 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
2473 if (IEM_IS_MODRM_REG_MODE(bRm))
2474 {
2475 /*
2476 * XMM64, XMM64.
2477 */
2478 IEM_MC_BEGIN(0, 1, 0, 0);
2479 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
2480 IEM_MC_LOCAL(uint64_t, uSrc);
2481
2482 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
2483 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
2484 IEM_MC_FETCH_XREG_U64(uSrc, IEM_GET_MODRM_REG(pVCpu, bRm), 0 /* a_iQword*/);
2485 IEM_MC_STORE_XREG_U64(IEM_GET_MODRM_RM(pVCpu, bRm), 0 /* a_iQword*/, uSrc);
2486
2487 IEM_MC_ADVANCE_RIP_AND_FINISH();
2488 IEM_MC_END();
2489 }
2490 else
2491 {
2492 /*
2493 * [mem64], XMM64.
2494 */
2495 IEM_MC_BEGIN(0, 2, 0, 0);
2496 IEM_MC_LOCAL(uint64_t, uSrc);
2497 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
2498
2499 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
2500 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
2501 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
2502 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
2503
2504 IEM_MC_FETCH_XREG_U64(uSrc, IEM_GET_MODRM_REG(pVCpu, bRm), 0 /* a_iQword*/);
2505 IEM_MC_STORE_MEM_U64(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, uSrc);
2506
2507 IEM_MC_ADVANCE_RIP_AND_FINISH();
2508 IEM_MC_END();
2509 }
2510}
2511
2512
2513FNIEMOP_DEF(iemOp_movlps_Vq_Mq__movhlps)
2514{
2515 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
2516 if (IEM_IS_MODRM_REG_MODE(bRm))
2517 {
2518 /**
2519 * @opcode 0x12
2520 * @opcodesub 11 mr/reg
2521 * @oppfx none
2522 * @opcpuid sse
2523 * @opgroup og_sse_simdfp_datamove
2524 * @opxcpttype 5
2525 * @optest op1=1 op2=2 -> op1=2
2526 * @optest op1=0 op2=-42 -> op1=-42
2527 */
2528 IEMOP_MNEMONIC2(RM_REG, MOVHLPS, movhlps, Vq_WO, UqHi, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
2529
2530 IEM_MC_BEGIN(0, 1, 0, 0);
2531 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
2532 IEM_MC_LOCAL(uint64_t, uSrc);
2533
2534 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
2535 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
2536 IEM_MC_FETCH_XREG_U64(uSrc, IEM_GET_MODRM_RM(pVCpu, bRm), 1 /* a_iQword*/);
2537 IEM_MC_STORE_XREG_U64(IEM_GET_MODRM_REG(pVCpu, bRm), 0 /* a_iQword*/, uSrc);
2538
2539 IEM_MC_ADVANCE_RIP_AND_FINISH();
2540 IEM_MC_END();
2541 }
2542 else
2543 {
2544 /**
2545 * @opdone
2546 * @opcode 0x12
2547 * @opcodesub !11 mr/reg
2548 * @oppfx none
2549 * @opcpuid sse
2550 * @opgroup og_sse_simdfp_datamove
2551 * @opxcpttype 5
2552 * @optest op1=1 op2=2 -> op1=2
2553 * @optest op1=0 op2=-42 -> op1=-42
2554 * @opfunction iemOp_movlps_Vq_Mq__vmovhlps
2555 */
2556 IEMOP_MNEMONIC2(RM_MEM, MOVLPS, movlps, Vq, Mq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
2557
2558 IEM_MC_BEGIN(0, 2, 0, 0);
2559 IEM_MC_LOCAL(uint64_t, uSrc);
2560 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
2561
2562 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
2563 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
2564 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
2565 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
2566
2567 IEM_MC_FETCH_MEM_U64(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
2568 IEM_MC_STORE_XREG_U64(IEM_GET_MODRM_REG(pVCpu, bRm), 0 /* a_iQword*/, uSrc);
2569
2570 IEM_MC_ADVANCE_RIP_AND_FINISH();
2571 IEM_MC_END();
2572 }
2573}
2574
2575
2576/**
2577 * @opcode 0x12
2578 * @opcodesub !11 mr/reg
2579 * @oppfx 0x66
2580 * @opcpuid sse2
2581 * @opgroup og_sse2_pcksclr_datamove
2582 * @opxcpttype 5
2583 * @optest op1=1 op2=2 -> op1=2
2584 * @optest op1=0 op2=-42 -> op1=-42
2585 */
2586FNIEMOP_DEF(iemOp_movlpd_Vq_Mq)
2587{
2588 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
2589 if (IEM_IS_MODRM_MEM_MODE(bRm))
2590 {
2591 IEMOP_MNEMONIC2(RM_MEM, MOVLPD, movlpd, Vq_WO, Mq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
2592
2593 IEM_MC_BEGIN(0, 2, 0, 0);
2594 IEM_MC_LOCAL(uint64_t, uSrc);
2595 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
2596
2597 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
2598 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
2599 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
2600 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
2601
2602 IEM_MC_FETCH_MEM_U64(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
2603 IEM_MC_STORE_XREG_U64(IEM_GET_MODRM_REG(pVCpu, bRm), 0 /* a_iQword*/, uSrc);
2604
2605 IEM_MC_ADVANCE_RIP_AND_FINISH();
2606 IEM_MC_END();
2607 }
2608
2609 /**
2610 * @opdone
2611 * @opmnemonic ud660f12m3
2612 * @opcode 0x12
2613 * @opcodesub 11 mr/reg
2614 * @oppfx 0x66
2615 * @opunused immediate
2616 * @opcpuid sse
2617 * @optest ->
2618 */
2619 else
2620 IEMOP_RAISE_INVALID_OPCODE_RET();
2621}
2622
2623
2624/**
2625 * @opcode 0x12
2626 * @oppfx 0xf3
2627 * @opcpuid sse3
2628 * @opgroup og_sse3_pcksclr_datamove
2629 * @opxcpttype 4
2630 * @optest op1=-1 op2=0xdddddddd00000002eeeeeeee00000001 ->
2631 * op1=0x00000002000000020000000100000001
2632 */
2633FNIEMOP_DEF(iemOp_movsldup_Vdq_Wdq)
2634{
2635 IEMOP_MNEMONIC2(RM, MOVSLDUP, movsldup, Vdq_WO, Wdq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
2636 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
2637 if (IEM_IS_MODRM_REG_MODE(bRm))
2638 {
2639 /*
2640 * XMM, XMM.
2641 */
2642 IEM_MC_BEGIN(0, 1, 0, 0);
2643 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse3);
2644 IEM_MC_LOCAL(RTUINT128U, uSrc);
2645
2646 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
2647 IEM_MC_PREPARE_SSE_USAGE();
2648
2649 IEM_MC_FETCH_XREG_U128(uSrc, IEM_GET_MODRM_RM(pVCpu, bRm));
2650 IEM_MC_STORE_XREG_U32_U128(IEM_GET_MODRM_REG(pVCpu, bRm), 0, uSrc, 0);
2651 IEM_MC_STORE_XREG_U32_U128(IEM_GET_MODRM_REG(pVCpu, bRm), 1, uSrc, 0);
2652 IEM_MC_STORE_XREG_U32_U128(IEM_GET_MODRM_REG(pVCpu, bRm), 2, uSrc, 2);
2653 IEM_MC_STORE_XREG_U32_U128(IEM_GET_MODRM_REG(pVCpu, bRm), 3, uSrc, 2);
2654
2655 IEM_MC_ADVANCE_RIP_AND_FINISH();
2656 IEM_MC_END();
2657 }
2658 else
2659 {
2660 /*
2661 * XMM, [mem128].
2662 */
2663 IEM_MC_BEGIN(0, 2, 0, 0);
2664 IEM_MC_LOCAL(RTUINT128U, uSrc);
2665 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
2666
2667 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
2668 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse3);
2669 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
2670 IEM_MC_PREPARE_SSE_USAGE();
2671
2672 IEM_MC_FETCH_MEM_U128_ALIGN_SSE(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
2673 IEM_MC_STORE_XREG_U32_U128(IEM_GET_MODRM_REG(pVCpu, bRm), 0, uSrc, 0);
2674 IEM_MC_STORE_XREG_U32_U128(IEM_GET_MODRM_REG(pVCpu, bRm), 1, uSrc, 0);
2675 IEM_MC_STORE_XREG_U32_U128(IEM_GET_MODRM_REG(pVCpu, bRm), 2, uSrc, 2);
2676 IEM_MC_STORE_XREG_U32_U128(IEM_GET_MODRM_REG(pVCpu, bRm), 3, uSrc, 2);
2677
2678 IEM_MC_ADVANCE_RIP_AND_FINISH();
2679 IEM_MC_END();
2680 }
2681}
2682
2683
2684/**
2685 * @opcode 0x12
2686 * @oppfx 0xf2
2687 * @opcpuid sse3
2688 * @opgroup og_sse3_pcksclr_datamove
2689 * @opxcpttype 5
2690 * @optest op1=-1 op2=0xddddddddeeeeeeee2222222211111111 ->
2691 * op1=0x22222222111111112222222211111111
2692 */
2693FNIEMOP_DEF(iemOp_movddup_Vdq_Wdq)
2694{
2695 IEMOP_MNEMONIC2(RM, MOVDDUP, movddup, Vdq_WO, Wdq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
2696 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
2697 if (IEM_IS_MODRM_REG_MODE(bRm))
2698 {
2699 /*
2700 * XMM128, XMM64.
2701 */
2702 IEM_MC_BEGIN(0, 1, 0, 0);
2703 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse3);
2704 IEM_MC_LOCAL(uint64_t, uSrc);
2705
2706 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
2707 IEM_MC_PREPARE_SSE_USAGE();
2708
2709 IEM_MC_FETCH_XREG_U64(uSrc, IEM_GET_MODRM_RM(pVCpu, bRm), 0 /* a_iQword*/);
2710 IEM_MC_STORE_XREG_U64(IEM_GET_MODRM_REG(pVCpu, bRm), 0 /* a_iQword*/, uSrc);
2711 IEM_MC_STORE_XREG_HI_U64(IEM_GET_MODRM_REG(pVCpu, bRm), uSrc);
2712
2713 IEM_MC_ADVANCE_RIP_AND_FINISH();
2714 IEM_MC_END();
2715 }
2716 else
2717 {
2718 /*
2719 * XMM128, [mem64].
2720 */
2721 IEM_MC_BEGIN(0, 2, 0, 0);
2722 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
2723 IEM_MC_LOCAL(uint64_t, uSrc);
2724
2725 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
2726 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse3);
2727 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
2728 IEM_MC_PREPARE_SSE_USAGE();
2729
2730 IEM_MC_FETCH_MEM_U64(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
2731 IEM_MC_STORE_XREG_U64(IEM_GET_MODRM_REG(pVCpu, bRm), 0 /* a_iQword*/, uSrc);
2732 IEM_MC_STORE_XREG_HI_U64(IEM_GET_MODRM_REG(pVCpu, bRm), uSrc);
2733
2734 IEM_MC_ADVANCE_RIP_AND_FINISH();
2735 IEM_MC_END();
2736 }
2737}
2738
2739
2740/**
2741 * @opcode 0x13
2742 * @opcodesub !11 mr/reg
2743 * @oppfx none
2744 * @opcpuid sse
2745 * @opgroup og_sse_simdfp_datamove
2746 * @opxcpttype 5
2747 * @optest op1=1 op2=2 -> op1=2
2748 * @optest op1=0 op2=-42 -> op1=-42
2749 */
2750FNIEMOP_DEF(iemOp_movlps_Mq_Vq)
2751{
2752 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
2753 if (IEM_IS_MODRM_MEM_MODE(bRm))
2754 {
2755 IEMOP_MNEMONIC2(MR_MEM, MOVLPS, movlps, Mq_WO, Vq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
2756
2757 IEM_MC_BEGIN(0, 2, 0, 0);
2758 IEM_MC_LOCAL(uint64_t, uSrc);
2759 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
2760
2761 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
2762 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
2763 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
2764 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
2765
2766 IEM_MC_FETCH_XREG_U64(uSrc, IEM_GET_MODRM_REG(pVCpu, bRm), 0 /* a_iQword*/);
2767 IEM_MC_STORE_MEM_U64(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, uSrc);
2768
2769 IEM_MC_ADVANCE_RIP_AND_FINISH();
2770 IEM_MC_END();
2771 }
2772
2773 /**
2774 * @opdone
2775 * @opmnemonic ud0f13m3
2776 * @opcode 0x13
2777 * @opcodesub 11 mr/reg
2778 * @oppfx none
2779 * @opunused immediate
2780 * @opcpuid sse
2781 * @optest ->
2782 */
2783 else
2784 IEMOP_RAISE_INVALID_OPCODE_RET();
2785}
2786
2787
2788/**
2789 * @opcode 0x13
2790 * @opcodesub !11 mr/reg
2791 * @oppfx 0x66
2792 * @opcpuid sse2
2793 * @opgroup og_sse2_pcksclr_datamove
2794 * @opxcpttype 5
2795 * @optest op1=1 op2=2 -> op1=2
2796 * @optest op1=0 op2=-42 -> op1=-42
2797 */
2798FNIEMOP_DEF(iemOp_movlpd_Mq_Vq)
2799{
2800 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
2801 if (IEM_IS_MODRM_MEM_MODE(bRm))
2802 {
2803 IEMOP_MNEMONIC2(MR_MEM, MOVLPD, movlpd, Mq_WO, Vq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
2804
2805 IEM_MC_BEGIN(0, 2, 0, 0);
2806 IEM_MC_LOCAL(uint64_t, uSrc);
2807 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
2808
2809 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
2810 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
2811 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
2812 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
2813
2814 IEM_MC_FETCH_XREG_U64(uSrc, IEM_GET_MODRM_REG(pVCpu, bRm), 0 /* a_iQword*/);
2815 IEM_MC_STORE_MEM_U64(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, uSrc);
2816
2817 IEM_MC_ADVANCE_RIP_AND_FINISH();
2818 IEM_MC_END();
2819 }
2820
2821 /**
2822 * @opdone
2823 * @opmnemonic ud660f13m3
2824 * @opcode 0x13
2825 * @opcodesub 11 mr/reg
2826 * @oppfx 0x66
2827 * @opunused immediate
2828 * @opcpuid sse
2829 * @optest ->
2830 */
2831 else
2832 IEMOP_RAISE_INVALID_OPCODE_RET();
2833}
2834
2835
2836/**
2837 * @opmnemonic udf30f13
2838 * @opcode 0x13
2839 * @oppfx 0xf3
2840 * @opunused intel-modrm
2841 * @opcpuid sse
2842 * @optest ->
2843 * @opdone
2844 */
2845
2846/**
2847 * @opmnemonic udf20f13
2848 * @opcode 0x13
2849 * @oppfx 0xf2
2850 * @opunused intel-modrm
2851 * @opcpuid sse
2852 * @optest ->
2853 * @opdone
2854 */
2855
2856/** Opcode 0x0f 0x14 - unpcklps Vx, Wx*/
2857FNIEMOP_DEF(iemOp_unpcklps_Vx_Wx)
2858{
2859 IEMOP_MNEMONIC2(RM, UNPCKLPS, unpcklps, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
2860 return FNIEMOP_CALL_1(iemOpCommonSse_LowLow_To_Full, iemAImpl_unpcklps_u128);
2861}
2862
2863
2864/** Opcode 0x66 0x0f 0x14 - unpcklpd Vx, Wx */
2865FNIEMOP_DEF(iemOp_unpcklpd_Vx_Wx)
2866{
2867 IEMOP_MNEMONIC2(RM, UNPCKLPD, unpcklpd, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
2868 return FNIEMOP_CALL_1(iemOpCommonSse2_LowLow_To_Full, iemAImpl_unpcklpd_u128);
2869}
2870
2871
2872/**
2873 * @opdone
2874 * @opmnemonic udf30f14
2875 * @opcode 0x14
2876 * @oppfx 0xf3
2877 * @opunused intel-modrm
2878 * @opcpuid sse
2879 * @optest ->
2880 * @opdone
2881 */
2882
2883/**
2884 * @opmnemonic udf20f14
2885 * @opcode 0x14
2886 * @oppfx 0xf2
2887 * @opunused intel-modrm
2888 * @opcpuid sse
2889 * @optest ->
2890 * @opdone
2891 */
2892
2893/** Opcode 0x0f 0x15 - unpckhps Vx, Wx */
2894FNIEMOP_DEF(iemOp_unpckhps_Vx_Wx)
2895{
2896 IEMOP_MNEMONIC2(RM, UNPCKHPS, unpckhps, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
2897 return FNIEMOP_CALL_1(iemOpCommonSse_HighHigh_To_Full, iemAImpl_unpckhps_u128);
2898}
2899
2900
2901/** Opcode 0x66 0x0f 0x15 - unpckhpd Vx, Wx */
2902FNIEMOP_DEF(iemOp_unpckhpd_Vx_Wx)
2903{
2904 IEMOP_MNEMONIC2(RM, UNPCKHPD, unpckhpd, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
2905 return FNIEMOP_CALL_1(iemOpCommonSse2_HighHigh_To_Full, iemAImpl_unpckhpd_u128);
2906}
2907
2908
2909/* Opcode 0xf3 0x0f 0x15 - invalid */
2910/* Opcode 0xf2 0x0f 0x15 - invalid */
2911
2912/**
2913 * @opdone
2914 * @opmnemonic udf30f15
2915 * @opcode 0x15
2916 * @oppfx 0xf3
2917 * @opunused intel-modrm
2918 * @opcpuid sse
2919 * @optest ->
2920 * @opdone
2921 */
2922
2923/**
2924 * @opmnemonic udf20f15
2925 * @opcode 0x15
2926 * @oppfx 0xf2
2927 * @opunused intel-modrm
2928 * @opcpuid sse
2929 * @optest ->
2930 * @opdone
2931 */
2932
2933FNIEMOP_DEF(iemOp_movhps_Vdq_Mq__movlhps_Vdq_Uq)
2934{
2935 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
2936 if (IEM_IS_MODRM_REG_MODE(bRm))
2937 {
2938 /**
2939 * @opcode 0x16
2940 * @opcodesub 11 mr/reg
2941 * @oppfx none
2942 * @opcpuid sse
2943 * @opgroup og_sse_simdfp_datamove
2944 * @opxcpttype 5
2945 * @optest op1=1 op2=2 -> op1=2
2946 * @optest op1=0 op2=-42 -> op1=-42
2947 */
2948 IEMOP_MNEMONIC2(RM_REG, MOVLHPS, movlhps, VqHi_WO, Uq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
2949
2950 IEM_MC_BEGIN(0, 1, 0, 0);
2951 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
2952 IEM_MC_LOCAL(uint64_t, uSrc);
2953
2954 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
2955 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
2956 IEM_MC_FETCH_XREG_U64(uSrc, IEM_GET_MODRM_RM(pVCpu, bRm), 0 /* a_iQword*/);
2957 IEM_MC_STORE_XREG_HI_U64(IEM_GET_MODRM_REG(pVCpu, bRm), uSrc);
2958
2959 IEM_MC_ADVANCE_RIP_AND_FINISH();
2960 IEM_MC_END();
2961 }
2962 else
2963 {
2964 /**
2965 * @opdone
2966 * @opcode 0x16
2967 * @opcodesub !11 mr/reg
2968 * @oppfx none
2969 * @opcpuid sse
2970 * @opgroup og_sse_simdfp_datamove
2971 * @opxcpttype 5
2972 * @optest op1=1 op2=2 -> op1=2
2973 * @optest op1=0 op2=-42 -> op1=-42
2974 * @opfunction iemOp_movhps_Vdq_Mq__movlhps_Vdq_Uq
2975 */
2976 IEMOP_MNEMONIC2(RM_MEM, MOVHPS, movhps, VqHi_WO, Mq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
2977
2978 IEM_MC_BEGIN(0, 2, 0, 0);
2979 IEM_MC_LOCAL(uint64_t, uSrc);
2980 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
2981
2982 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
2983 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
2984 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
2985 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
2986
2987 IEM_MC_FETCH_MEM_U64(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
2988 IEM_MC_STORE_XREG_HI_U64(IEM_GET_MODRM_REG(pVCpu, bRm), uSrc);
2989
2990 IEM_MC_ADVANCE_RIP_AND_FINISH();
2991 IEM_MC_END();
2992 }
2993}
2994
2995
2996/**
2997 * @opcode 0x16
2998 * @opcodesub !11 mr/reg
2999 * @oppfx 0x66
3000 * @opcpuid sse2
3001 * @opgroup og_sse2_pcksclr_datamove
3002 * @opxcpttype 5
3003 * @optest op1=1 op2=2 -> op1=2
3004 * @optest op1=0 op2=-42 -> op1=-42
3005 */
3006FNIEMOP_DEF(iemOp_movhpd_Vdq_Mq)
3007{
3008 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
3009 if (IEM_IS_MODRM_MEM_MODE(bRm))
3010 {
3011 IEMOP_MNEMONIC2(RM_MEM, MOVHPD, movhpd, VqHi_WO, Mq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
3012
3013 IEM_MC_BEGIN(0, 2, 0, 0);
3014 IEM_MC_LOCAL(uint64_t, uSrc);
3015 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
3016
3017 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
3018 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
3019 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
3020 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
3021
3022 IEM_MC_FETCH_MEM_U64(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
3023 IEM_MC_STORE_XREG_HI_U64(IEM_GET_MODRM_REG(pVCpu, bRm), uSrc);
3024
3025 IEM_MC_ADVANCE_RIP_AND_FINISH();
3026 IEM_MC_END();
3027 }
3028
3029 /**
3030 * @opdone
3031 * @opmnemonic ud660f16m3
3032 * @opcode 0x16
3033 * @opcodesub 11 mr/reg
3034 * @oppfx 0x66
3035 * @opunused immediate
3036 * @opcpuid sse
3037 * @optest ->
3038 */
3039 else
3040 IEMOP_RAISE_INVALID_OPCODE_RET();
3041}
3042
3043
3044/**
3045 * @opcode 0x16
3046 * @oppfx 0xf3
3047 * @opcpuid sse3
3048 * @opgroup og_sse3_pcksclr_datamove
3049 * @opxcpttype 4
3050 * @optest op1=-1 op2=0x00000002dddddddd00000001eeeeeeee ->
3051 * op1=0x00000002000000020000000100000001
3052 */
3053FNIEMOP_DEF(iemOp_movshdup_Vdq_Wdq)
3054{
3055 IEMOP_MNEMONIC2(RM, MOVSHDUP, movshdup, Vdq_WO, Wdq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
3056 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
3057 if (IEM_IS_MODRM_REG_MODE(bRm))
3058 {
3059 /*
3060 * XMM128, XMM128.
3061 */
3062 IEM_MC_BEGIN(0, 1, 0, 0);
3063 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse3);
3064 IEM_MC_LOCAL(RTUINT128U, uSrc);
3065
3066 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
3067 IEM_MC_PREPARE_SSE_USAGE();
3068
3069 IEM_MC_FETCH_XREG_U128(uSrc, IEM_GET_MODRM_RM(pVCpu, bRm));
3070 IEM_MC_STORE_XREG_U32_U128(IEM_GET_MODRM_REG(pVCpu, bRm), 0, uSrc, 1);
3071 IEM_MC_STORE_XREG_U32_U128(IEM_GET_MODRM_REG(pVCpu, bRm), 1, uSrc, 1);
3072 IEM_MC_STORE_XREG_U32_U128(IEM_GET_MODRM_REG(pVCpu, bRm), 2, uSrc, 3);
3073 IEM_MC_STORE_XREG_U32_U128(IEM_GET_MODRM_REG(pVCpu, bRm), 3, uSrc, 3);
3074
3075 IEM_MC_ADVANCE_RIP_AND_FINISH();
3076 IEM_MC_END();
3077 }
3078 else
3079 {
3080 /*
3081 * XMM128, [mem128].
3082 */
3083 IEM_MC_BEGIN(0, 2, 0, 0);
3084 IEM_MC_LOCAL(RTUINT128U, uSrc);
3085 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
3086
3087 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
3088 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse3);
3089 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
3090 IEM_MC_PREPARE_SSE_USAGE();
3091
3092 IEM_MC_FETCH_MEM_U128_ALIGN_SSE(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
3093 IEM_MC_STORE_XREG_U32_U128(IEM_GET_MODRM_REG(pVCpu, bRm), 0, uSrc, 1);
3094 IEM_MC_STORE_XREG_U32_U128(IEM_GET_MODRM_REG(pVCpu, bRm), 1, uSrc, 1);
3095 IEM_MC_STORE_XREG_U32_U128(IEM_GET_MODRM_REG(pVCpu, bRm), 2, uSrc, 3);
3096 IEM_MC_STORE_XREG_U32_U128(IEM_GET_MODRM_REG(pVCpu, bRm), 3, uSrc, 3);
3097
3098 IEM_MC_ADVANCE_RIP_AND_FINISH();
3099 IEM_MC_END();
3100 }
3101}
3102
3103/**
3104 * @opdone
3105 * @opmnemonic udf30f16
3106 * @opcode 0x16
3107 * @oppfx 0xf2
3108 * @opunused intel-modrm
3109 * @opcpuid sse
3110 * @optest ->
3111 * @opdone
3112 */
3113
3114
3115/**
3116 * @opcode 0x17
3117 * @opcodesub !11 mr/reg
3118 * @oppfx none
3119 * @opcpuid sse
3120 * @opgroup og_sse_simdfp_datamove
3121 * @opxcpttype 5
3122 * @optest op1=1 op2=2 -> op1=2
3123 * @optest op1=0 op2=-42 -> op1=-42
3124 */
3125FNIEMOP_DEF(iemOp_movhps_Mq_Vq)
3126{
3127 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
3128 if (IEM_IS_MODRM_MEM_MODE(bRm))
3129 {
3130 IEMOP_MNEMONIC2(MR_MEM, MOVHPS, movhps, Mq_WO, VqHi, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
3131
3132 IEM_MC_BEGIN(0, 2, 0, 0);
3133 IEM_MC_LOCAL(uint64_t, uSrc);
3134 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
3135
3136 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
3137 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
3138 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
3139 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
3140
3141 IEM_MC_FETCH_XREG_U64(uSrc, IEM_GET_MODRM_REG(pVCpu, bRm), 1 /* a_iQword*/);
3142 IEM_MC_STORE_MEM_U64(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, uSrc);
3143
3144 IEM_MC_ADVANCE_RIP_AND_FINISH();
3145 IEM_MC_END();
3146 }
3147
3148 /**
3149 * @opdone
3150 * @opmnemonic ud0f17m3
3151 * @opcode 0x17
3152 * @opcodesub 11 mr/reg
3153 * @oppfx none
3154 * @opunused immediate
3155 * @opcpuid sse
3156 * @optest ->
3157 */
3158 else
3159 IEMOP_RAISE_INVALID_OPCODE_RET();
3160}
3161
3162
3163/**
3164 * @opcode 0x17
3165 * @opcodesub !11 mr/reg
3166 * @oppfx 0x66
3167 * @opcpuid sse2
3168 * @opgroup og_sse2_pcksclr_datamove
3169 * @opxcpttype 5
3170 * @optest op1=1 op2=2 -> op1=2
3171 * @optest op1=0 op2=-42 -> op1=-42
3172 */
3173FNIEMOP_DEF(iemOp_movhpd_Mq_Vq)
3174{
3175 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
3176 if (IEM_IS_MODRM_MEM_MODE(bRm))
3177 {
3178 IEMOP_MNEMONIC2(MR_MEM, MOVHPD, movhpd, Mq_WO, VqHi, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
3179
3180 IEM_MC_BEGIN(0, 2, 0, 0);
3181 IEM_MC_LOCAL(uint64_t, uSrc);
3182 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
3183
3184 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
3185 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
3186 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
3187 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
3188
3189 IEM_MC_FETCH_XREG_U64(uSrc, IEM_GET_MODRM_REG(pVCpu, bRm), 1 /* a_iQword*/);
3190 IEM_MC_STORE_MEM_U64(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, uSrc);
3191
3192 IEM_MC_ADVANCE_RIP_AND_FINISH();
3193 IEM_MC_END();
3194 }
3195
3196 /**
3197 * @opdone
3198 * @opmnemonic ud660f17m3
3199 * @opcode 0x17
3200 * @opcodesub 11 mr/reg
3201 * @oppfx 0x66
3202 * @opunused immediate
3203 * @opcpuid sse
3204 * @optest ->
3205 */
3206 else
3207 IEMOP_RAISE_INVALID_OPCODE_RET();
3208}
3209
3210
3211/**
3212 * @opdone
3213 * @opmnemonic udf30f17
3214 * @opcode 0x17
3215 * @oppfx 0xf3
3216 * @opunused intel-modrm
3217 * @opcpuid sse
3218 * @optest ->
3219 * @opdone
3220 */
3221
3222/**
3223 * @opmnemonic udf20f17
3224 * @opcode 0x17
3225 * @oppfx 0xf2
3226 * @opunused intel-modrm
3227 * @opcpuid sse
3228 * @optest ->
3229 * @opdone
3230 */
3231
3232
3233/** Opcode 0x0f 0x18. */
3234FNIEMOP_DEF(iemOp_prefetch_Grp16)
3235{
3236 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
3237 if (IEM_IS_MODRM_MEM_MODE(bRm))
3238 {
3239 switch (IEM_GET_MODRM_REG_8(bRm))
3240 {
3241 case 4: /* Aliased to /0 for the time being according to AMD. */
3242 case 5: /* Aliased to /0 for the time being according to AMD. */
3243 case 6: /* Aliased to /0 for the time being according to AMD. */
3244 case 7: /* Aliased to /0 for the time being according to AMD. */
3245 case 0: IEMOP_MNEMONIC(prefetchNTA, "prefetchNTA m8"); break;
3246 case 1: IEMOP_MNEMONIC(prefetchT0, "prefetchT0 m8"); break;
3247 case 2: IEMOP_MNEMONIC(prefetchT1, "prefetchT1 m8"); break;
3248 case 3: IEMOP_MNEMONIC(prefetchT2, "prefetchT2 m8"); break;
3249 IEM_NOT_REACHED_DEFAULT_CASE_RET();
3250 }
3251
3252 IEM_MC_BEGIN(0, 1, 0, 0);
3253 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
3254 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
3255 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
3256 /* Currently a NOP. */
3257 NOREF(GCPtrEffSrc);
3258 IEM_MC_ADVANCE_RIP_AND_FINISH();
3259 IEM_MC_END();
3260 }
3261 else
3262 IEMOP_RAISE_INVALID_OPCODE_RET();
3263}
3264
3265
3266/** Opcode 0x0f 0x19..0x1f. */
3267FNIEMOP_DEF(iemOp_nop_Ev)
3268{
3269 IEMOP_MNEMONIC(nop_Ev, "nop Ev");
3270 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
3271 if (IEM_IS_MODRM_REG_MODE(bRm))
3272 {
3273 IEM_MC_BEGIN(0, 0, 0, 0);
3274 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
3275 IEM_MC_ADVANCE_RIP_AND_FINISH();
3276 IEM_MC_END();
3277 }
3278 else
3279 {
3280 IEM_MC_BEGIN(0, 1, 0, 0);
3281 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
3282 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
3283 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
3284 /* Currently a NOP. */
3285 NOREF(GCPtrEffSrc);
3286 IEM_MC_ADVANCE_RIP_AND_FINISH();
3287 IEM_MC_END();
3288 }
3289}
3290
3291
3292/** Opcode 0x0f 0x20. */
3293FNIEMOP_DEF(iemOp_mov_Rd_Cd)
3294{
3295 /* mod is ignored, as is operand size overrides. */
3296/** @todo testcase: check memory encoding. */
3297 IEMOP_MNEMONIC(mov_Rd_Cd, "mov Rd,Cd");
3298 IEMOP_HLP_MIN_386();
3299 if (IEM_IS_64BIT_CODE(pVCpu))
3300 pVCpu->iem.s.enmEffOpSize = pVCpu->iem.s.enmDefOpSize = IEMMODE_64BIT;
3301 else
3302 pVCpu->iem.s.enmEffOpSize = pVCpu->iem.s.enmDefOpSize = IEMMODE_32BIT;
3303
3304 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
3305 uint8_t iCrReg = IEM_GET_MODRM_REG(pVCpu, bRm);
3306 if (pVCpu->iem.s.fPrefixes & IEM_OP_PRF_LOCK)
3307 {
3308 /* The lock prefix can be used to encode CR8 accesses on some CPUs. */
3309 if (!IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fMovCr8In32Bit)
3310 IEMOP_RAISE_INVALID_OPCODE_RET(); /* #UD takes precedence over #GP(), see test. */
3311 iCrReg |= 8;
3312 }
3313 switch (iCrReg)
3314 {
3315 case 0: case 2: case 3: case 4: case 8:
3316 break;
3317 default:
3318 IEMOP_RAISE_INVALID_OPCODE_RET();
3319 }
3320 IEMOP_HLP_DONE_DECODING();
3321
3322 IEM_MC_DEFER_TO_CIMPL_2_RET(IEM_CIMPL_F_VMEXIT,
3323 RT_BIT_64(kIemNativeGstReg_GprFirst + IEM_GET_MODRM_RM(pVCpu, bRm)),
3324 iemCImpl_mov_Rd_Cd, IEM_GET_MODRM_RM(pVCpu, bRm), iCrReg);
3325}
3326
3327
3328/** Opcode 0x0f 0x21. */
3329FNIEMOP_DEF(iemOp_mov_Rd_Dd)
3330{
3331/** @todo testcase: check memory encoding. */
3332 IEMOP_MNEMONIC(mov_Rd_Dd, "mov Rd,Dd");
3333 IEMOP_HLP_MIN_386();
3334 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
3335 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
3336 if (pVCpu->iem.s.fPrefixes & IEM_OP_PRF_REX_R)
3337 IEMOP_RAISE_INVALID_OPCODE_RET();
3338 IEM_MC_DEFER_TO_CIMPL_2_RET(IEM_CIMPL_F_VMEXIT,
3339 RT_BIT_64(kIemNativeGstReg_GprFirst + IEM_GET_MODRM_RM(pVCpu, bRm)),
3340 iemCImpl_mov_Rd_Dd, IEM_GET_MODRM_RM(pVCpu, bRm), IEM_GET_MODRM_REG_8(bRm));
3341}
3342
3343
3344/** Opcode 0x0f 0x22. */
3345FNIEMOP_DEF(iemOp_mov_Cd_Rd)
3346{
3347 /* mod is ignored, as is operand size overrides. */
3348 IEMOP_MNEMONIC(mov_Cd_Rd, "mov Cd,Rd");
3349 IEMOP_HLP_MIN_386();
3350 if (IEM_IS_64BIT_CODE(pVCpu))
3351 pVCpu->iem.s.enmEffOpSize = pVCpu->iem.s.enmDefOpSize = IEMMODE_64BIT;
3352 else
3353 pVCpu->iem.s.enmEffOpSize = pVCpu->iem.s.enmDefOpSize = IEMMODE_32BIT;
3354
3355 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
3356 uint8_t iCrReg = IEM_GET_MODRM_REG(pVCpu, bRm);
3357 if (pVCpu->iem.s.fPrefixes & IEM_OP_PRF_LOCK)
3358 {
3359 /* The lock prefix can be used to encode CR8 accesses on some CPUs. */
3360 if (!IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fMovCr8In32Bit)
3361 IEMOP_RAISE_INVALID_OPCODE_RET(); /* #UD takes precedence over #GP(), see test. */
3362 iCrReg |= 8;
3363 }
3364 switch (iCrReg)
3365 {
3366 case 0: case 2: case 3: case 4: case 8:
3367 break;
3368 default:
3369 IEMOP_RAISE_INVALID_OPCODE_RET();
3370 }
3371 IEMOP_HLP_DONE_DECODING();
3372
3373 if (iCrReg & (2 | 8))
3374 IEM_MC_DEFER_TO_CIMPL_2_RET(IEM_CIMPL_F_VMEXIT, 0,
3375 iemCImpl_mov_Cd_Rd, iCrReg, IEM_GET_MODRM_RM(pVCpu, bRm));
3376 else
3377 IEM_MC_DEFER_TO_CIMPL_2_RET(IEM_CIMPL_F_MODE | IEM_CIMPL_F_VMEXIT, 0,
3378 iemCImpl_mov_Cd_Rd, iCrReg, IEM_GET_MODRM_RM(pVCpu, bRm));
3379}
3380
3381
3382/** Opcode 0x0f 0x23. */
3383FNIEMOP_DEF(iemOp_mov_Dd_Rd)
3384{
3385 IEMOP_MNEMONIC(mov_Dd_Rd, "mov Dd,Rd");
3386 IEMOP_HLP_MIN_386();
3387 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
3388 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
3389 if (pVCpu->iem.s.fPrefixes & IEM_OP_PRF_REX_R)
3390 IEMOP_RAISE_INVALID_OPCODE_RET();
3391 IEM_MC_DEFER_TO_CIMPL_2_RET(IEM_CIMPL_F_MODE | IEM_CIMPL_F_VMEXIT, 0,
3392 iemCImpl_mov_Dd_Rd, IEM_GET_MODRM_REG_8(bRm), IEM_GET_MODRM_RM(pVCpu, bRm));
3393}
3394
3395
3396/** Opcode 0x0f 0x24. */
3397FNIEMOP_DEF(iemOp_mov_Rd_Td)
3398{
3399 IEMOP_MNEMONIC(mov_Rd_Td, "mov Rd,Td");
3400 IEMOP_HLP_MIN_386();
3401 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
3402 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
3403 if (RT_LIKELY(IEM_GET_TARGET_CPU(pVCpu) >= IEMTARGETCPU_PENTIUM))
3404 IEMOP_RAISE_INVALID_OPCODE_RET();
3405 IEM_MC_DEFER_TO_CIMPL_2_RET(0, RT_BIT_64(kIemNativeGstReg_GprFirst + IEM_GET_MODRM_RM(pVCpu, bRm)),
3406 iemCImpl_mov_Rd_Td, IEM_GET_MODRM_RM(pVCpu, bRm), IEM_GET_MODRM_REG_8(bRm));
3407}
3408
3409
3410/** Opcode 0x0f 0x26. */
3411FNIEMOP_DEF(iemOp_mov_Td_Rd)
3412{
3413 IEMOP_MNEMONIC(mov_Td_Rd, "mov Td,Rd");
3414 IEMOP_HLP_MIN_386();
3415 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
3416 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
3417 if (RT_LIKELY(IEM_GET_TARGET_CPU(pVCpu) >= IEMTARGETCPU_PENTIUM))
3418 IEMOP_RAISE_INVALID_OPCODE_RET();
3419 IEM_MC_DEFER_TO_CIMPL_2_RET(0, 0, iemCImpl_mov_Td_Rd, IEM_GET_MODRM_REG_8(bRm), IEM_GET_MODRM_RM(pVCpu, bRm));
3420}
3421
3422
3423/**
3424 * @opcode 0x28
3425 * @oppfx none
3426 * @opcpuid sse
3427 * @opgroup og_sse_simdfp_datamove
3428 * @opxcpttype 1
3429 * @optest op1=1 op2=2 -> op1=2
3430 * @optest op1=0 op2=-42 -> op1=-42
3431 */
3432FNIEMOP_DEF(iemOp_movaps_Vps_Wps)
3433{
3434 IEMOP_MNEMONIC2(RM, MOVAPS, movaps, Vps_WO, Wps, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
3435 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
3436 if (IEM_IS_MODRM_REG_MODE(bRm))
3437 {
3438 /*
3439 * Register, register.
3440 */
3441 IEM_MC_BEGIN(0, 0, 0, 0);
3442 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
3443 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
3444 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
3445 IEM_MC_COPY_XREG_U128(IEM_GET_MODRM_REG(pVCpu, bRm),
3446 IEM_GET_MODRM_RM(pVCpu, bRm));
3447 IEM_MC_ADVANCE_RIP_AND_FINISH();
3448 IEM_MC_END();
3449 }
3450 else
3451 {
3452 /*
3453 * Register, memory.
3454 */
3455 IEM_MC_BEGIN(0, 2, 0, 0);
3456 IEM_MC_LOCAL(RTUINT128U, uSrc); /** @todo optimize this one day... */
3457 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
3458
3459 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
3460 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
3461 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
3462 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
3463
3464 IEM_MC_FETCH_MEM_U128_ALIGN_SSE(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
3465 IEM_MC_STORE_XREG_U128(IEM_GET_MODRM_REG(pVCpu, bRm), uSrc);
3466
3467 IEM_MC_ADVANCE_RIP_AND_FINISH();
3468 IEM_MC_END();
3469 }
3470}
3471
3472/**
3473 * @opcode 0x28
3474 * @oppfx 66
3475 * @opcpuid sse2
3476 * @opgroup og_sse2_pcksclr_datamove
3477 * @opxcpttype 1
3478 * @optest op1=1 op2=2 -> op1=2
3479 * @optest op1=0 op2=-42 -> op1=-42
3480 */
3481FNIEMOP_DEF(iemOp_movapd_Vpd_Wpd)
3482{
3483 IEMOP_MNEMONIC2(RM, MOVAPD, movapd, Vpd_WO, Wpd, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
3484 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
3485 if (IEM_IS_MODRM_REG_MODE(bRm))
3486 {
3487 /*
3488 * Register, register.
3489 */
3490 IEM_MC_BEGIN(0, 0, 0, 0);
3491 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
3492 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
3493 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
3494 IEM_MC_COPY_XREG_U128(IEM_GET_MODRM_REG(pVCpu, bRm),
3495 IEM_GET_MODRM_RM(pVCpu, bRm));
3496 IEM_MC_ADVANCE_RIP_AND_FINISH();
3497 IEM_MC_END();
3498 }
3499 else
3500 {
3501 /*
3502 * Register, memory.
3503 */
3504 IEM_MC_BEGIN(0, 2, 0, 0);
3505 IEM_MC_LOCAL(RTUINT128U, uSrc); /** @todo optimize this one day... */
3506 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
3507
3508 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
3509 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
3510 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
3511 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
3512
3513 IEM_MC_FETCH_MEM_U128_ALIGN_SSE(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
3514 IEM_MC_STORE_XREG_U128(IEM_GET_MODRM_REG(pVCpu, bRm), uSrc);
3515
3516 IEM_MC_ADVANCE_RIP_AND_FINISH();
3517 IEM_MC_END();
3518 }
3519}
3520
3521/* Opcode 0xf3 0x0f 0x28 - invalid */
3522/* Opcode 0xf2 0x0f 0x28 - invalid */
3523
3524/**
3525 * @opcode 0x29
3526 * @oppfx none
3527 * @opcpuid sse
3528 * @opgroup og_sse_simdfp_datamove
3529 * @opxcpttype 1
3530 * @optest op1=1 op2=2 -> op1=2
3531 * @optest op1=0 op2=-42 -> op1=-42
3532 */
3533FNIEMOP_DEF(iemOp_movaps_Wps_Vps)
3534{
3535 IEMOP_MNEMONIC2(MR, MOVAPS, movaps, Wps_WO, Vps, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
3536 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
3537 if (IEM_IS_MODRM_REG_MODE(bRm))
3538 {
3539 /*
3540 * Register, register.
3541 */
3542 IEM_MC_BEGIN(0, 0, 0, 0);
3543 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
3544 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
3545 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
3546 IEM_MC_COPY_XREG_U128(IEM_GET_MODRM_RM(pVCpu, bRm),
3547 IEM_GET_MODRM_REG(pVCpu, bRm));
3548 IEM_MC_ADVANCE_RIP_AND_FINISH();
3549 IEM_MC_END();
3550 }
3551 else
3552 {
3553 /*
3554 * Memory, register.
3555 */
3556 IEM_MC_BEGIN(0, 2, 0, 0);
3557 IEM_MC_LOCAL(RTUINT128U, uSrc); /** @todo optimize this one day... */
3558 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
3559
3560 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
3561 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
3562 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
3563 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
3564
3565 IEM_MC_FETCH_XREG_U128(uSrc, IEM_GET_MODRM_REG(pVCpu, bRm));
3566 IEM_MC_STORE_MEM_U128_ALIGN_SSE(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, uSrc);
3567
3568 IEM_MC_ADVANCE_RIP_AND_FINISH();
3569 IEM_MC_END();
3570 }
3571}
3572
3573/**
3574 * @opcode 0x29
3575 * @oppfx 66
3576 * @opcpuid sse2
3577 * @opgroup og_sse2_pcksclr_datamove
3578 * @opxcpttype 1
3579 * @optest op1=1 op2=2 -> op1=2
3580 * @optest op1=0 op2=-42 -> op1=-42
3581 */
3582FNIEMOP_DEF(iemOp_movapd_Wpd_Vpd)
3583{
3584 IEMOP_MNEMONIC2(MR, MOVAPD, movapd, Wpd_WO, Vpd, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
3585 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
3586 if (IEM_IS_MODRM_REG_MODE(bRm))
3587 {
3588 /*
3589 * Register, register.
3590 */
3591 IEM_MC_BEGIN(0, 0, 0, 0);
3592 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
3593 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
3594 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
3595 IEM_MC_COPY_XREG_U128(IEM_GET_MODRM_RM(pVCpu, bRm),
3596 IEM_GET_MODRM_REG(pVCpu, bRm));
3597 IEM_MC_ADVANCE_RIP_AND_FINISH();
3598 IEM_MC_END();
3599 }
3600 else
3601 {
3602 /*
3603 * Memory, register.
3604 */
3605 IEM_MC_BEGIN(0, 2, 0, 0);
3606 IEM_MC_LOCAL(RTUINT128U, uSrc); /** @todo optimize this one day... */
3607 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
3608
3609 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
3610 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
3611 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
3612 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
3613
3614 IEM_MC_FETCH_XREG_U128(uSrc, IEM_GET_MODRM_REG(pVCpu, bRm));
3615 IEM_MC_STORE_MEM_U128_ALIGN_SSE(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, uSrc);
3616
3617 IEM_MC_ADVANCE_RIP_AND_FINISH();
3618 IEM_MC_END();
3619 }
3620}
3621
3622/* Opcode 0xf3 0x0f 0x29 - invalid */
3623/* Opcode 0xf2 0x0f 0x29 - invalid */
3624
3625
3626/** Opcode 0x0f 0x2a - cvtpi2ps Vps, Qpi */
3627FNIEMOP_DEF(iemOp_cvtpi2ps_Vps_Qpi)
3628{
3629 IEMOP_MNEMONIC2(RM, CVTPI2PS, cvtpi2ps, Vps, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0); /// @todo
3630 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
3631 if (IEM_IS_MODRM_REG_MODE(bRm))
3632 {
3633 /*
3634 * XMM, MMX
3635 */
3636 IEM_MC_BEGIN(3, 1, 0, 0);
3637 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
3638 IEM_MC_ARG(uint32_t *, pfMxcsr, 0);
3639 IEM_MC_LOCAL(X86XMMREG, Dst);
3640 IEM_MC_ARG_LOCAL_REF(PX86XMMREG, pDst, Dst, 1);
3641 IEM_MC_ARG(uint64_t, u64Src, 2);
3642 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
3643 IEM_MC_MAYBE_RAISE_FPU_XCPT();
3644 IEM_MC_PREPARE_FPU_USAGE();
3645 IEM_MC_FPU_TO_MMX_MODE();
3646
3647 IEM_MC_REF_MXCSR(pfMxcsr);
3648 IEM_MC_FETCH_XREG_XMM(Dst, IEM_GET_MODRM_REG(pVCpu, bRm)); /* Need it because the high quadword remains unchanged. */
3649 IEM_MC_FETCH_MREG_U64(u64Src, IEM_GET_MODRM_RM_8(bRm));
3650
3651 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_cvtpi2ps_u128, pfMxcsr, pDst, u64Src);
3652 IEM_MC_IF_MXCSR_XCPT_PENDING() {
3653 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
3654 } IEM_MC_ELSE() {
3655 IEM_MC_STORE_XREG_XMM(IEM_GET_MODRM_REG(pVCpu, bRm), Dst);
3656 } IEM_MC_ENDIF();
3657
3658 IEM_MC_ADVANCE_RIP_AND_FINISH();
3659 IEM_MC_END();
3660 }
3661 else
3662 {
3663 /*
3664 * XMM, [mem64]
3665 */
3666 IEM_MC_BEGIN(3, 2, 0, 0);
3667 IEM_MC_ARG(uint32_t *, pfMxcsr, 0);
3668 IEM_MC_LOCAL(X86XMMREG, Dst);
3669 IEM_MC_ARG_LOCAL_REF(PX86XMMREG, pDst, Dst, 1);
3670 IEM_MC_ARG(uint64_t, u64Src, 2);
3671 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
3672
3673 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
3674 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
3675 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
3676 IEM_MC_MAYBE_RAISE_FPU_XCPT();
3677 IEM_MC_FETCH_MEM_U64(u64Src, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
3678
3679 IEM_MC_PREPARE_FPU_USAGE();
3680 IEM_MC_FPU_TO_MMX_MODE();
3681 IEM_MC_REF_MXCSR(pfMxcsr);
3682
3683 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_cvtpi2ps_u128, pfMxcsr, pDst, u64Src);
3684 IEM_MC_IF_MXCSR_XCPT_PENDING() {
3685 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
3686 } IEM_MC_ELSE() {
3687 IEM_MC_STORE_XREG_XMM(IEM_GET_MODRM_REG(pVCpu, bRm), Dst);
3688 } IEM_MC_ENDIF();
3689
3690 IEM_MC_ADVANCE_RIP_AND_FINISH();
3691 IEM_MC_END();
3692 }
3693}
3694
3695
3696/** Opcode 0x66 0x0f 0x2a - cvtpi2pd Vpd, Qpi */
3697FNIEMOP_DEF(iemOp_cvtpi2pd_Vpd_Qpi)
3698{
3699 IEMOP_MNEMONIC2(RM, CVTPI2PD, cvtpi2pd, Vps, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0); /// @todo
3700 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
3701 if (IEM_IS_MODRM_REG_MODE(bRm))
3702 {
3703 /*
3704 * XMM, MMX
3705 */
3706 IEM_MC_BEGIN(3, 1, 0, 0);
3707 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
3708 IEM_MC_ARG(uint32_t *, pfMxcsr, 0);
3709 IEM_MC_LOCAL(X86XMMREG, Dst);
3710 IEM_MC_ARG_LOCAL_REF(PX86XMMREG, pDst, Dst, 1);
3711 IEM_MC_ARG(uint64_t, u64Src, 2);
3712 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
3713 IEM_MC_MAYBE_RAISE_FPU_XCPT();
3714 IEM_MC_PREPARE_FPU_USAGE();
3715 IEM_MC_FPU_TO_MMX_MODE();
3716
3717 IEM_MC_REF_MXCSR(pfMxcsr);
3718 IEM_MC_FETCH_MREG_U64(u64Src, IEM_GET_MODRM_RM_8(bRm));
3719
3720 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_cvtpi2pd_u128, pfMxcsr, pDst, u64Src);
3721 IEM_MC_IF_MXCSR_XCPT_PENDING() {
3722 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
3723 } IEM_MC_ELSE() {
3724 IEM_MC_STORE_XREG_XMM(IEM_GET_MODRM_REG(pVCpu, bRm), Dst);
3725 } IEM_MC_ENDIF();
3726
3727 IEM_MC_ADVANCE_RIP_AND_FINISH();
3728 IEM_MC_END();
3729 }
3730 else
3731 {
3732 /*
3733 * XMM, [mem64]
3734 */
3735 IEM_MC_BEGIN(3, 3, 0, 0);
3736 IEM_MC_ARG(uint32_t *, pfMxcsr, 0);
3737 IEM_MC_LOCAL(X86XMMREG, Dst);
3738 IEM_MC_ARG_LOCAL_REF(PX86XMMREG, pDst, Dst, 1);
3739 IEM_MC_ARG(uint64_t, u64Src, 2);
3740 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
3741
3742 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
3743 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
3744 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
3745 IEM_MC_MAYBE_RAISE_FPU_XCPT();
3746 IEM_MC_FETCH_MEM_U64(u64Src, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
3747
3748 /* Doesn't cause a transition to MMX mode. */
3749 IEM_MC_PREPARE_SSE_USAGE();
3750 IEM_MC_REF_MXCSR(pfMxcsr);
3751
3752 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_cvtpi2pd_u128, pfMxcsr, pDst, u64Src);
3753 IEM_MC_IF_MXCSR_XCPT_PENDING() {
3754 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
3755 } IEM_MC_ELSE() {
3756 IEM_MC_STORE_XREG_XMM(IEM_GET_MODRM_REG(pVCpu, bRm), Dst);
3757 } IEM_MC_ENDIF();
3758
3759 IEM_MC_ADVANCE_RIP_AND_FINISH();
3760 IEM_MC_END();
3761 }
3762}
3763
3764
3765/** Opcode 0xf3 0x0f 0x2a - cvtsi2ss Vss, Ey */
3766FNIEMOP_DEF(iemOp_cvtsi2ss_Vss_Ey)
3767{
3768 IEMOP_MNEMONIC2(RM, CVTSI2SS, cvtsi2ss, Vss, Ey, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
3769
3770 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
3771 if (pVCpu->iem.s.fPrefixes & IEM_OP_PRF_SIZE_REX_W)
3772 {
3773 if (IEM_IS_MODRM_REG_MODE(bRm))
3774 {
3775 /* XMM, greg64 */
3776 IEM_MC_BEGIN(3, 2, IEM_MC_F_64BIT, 0);
3777 IEM_MC_LOCAL(uint32_t, fMxcsr);
3778 IEM_MC_LOCAL(RTFLOAT32U, r32Dst);
3779 IEM_MC_ARG_LOCAL_REF(uint32_t *, pfMxcsr, fMxcsr, 0);
3780 IEM_MC_ARG_LOCAL_REF(PRTFLOAT32U, pr32Dst, r32Dst, 1);
3781 IEM_MC_ARG(const int64_t *, pi64Src, 2);
3782
3783 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
3784 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
3785 IEM_MC_PREPARE_SSE_USAGE(); /** @todo: This is superfluous because IEM_MC_CALL_SSE_AIMPL_3() is calling this but the tstIEMCheckMc testcase depends on it. */
3786
3787 IEM_MC_REF_GREG_I64_CONST(pi64Src, IEM_GET_MODRM_RM(pVCpu, bRm));
3788 IEM_MC_CALL_SSE_AIMPL_3(iemAImpl_cvtsi2ss_r32_i64, pfMxcsr, pr32Dst, pi64Src);
3789 IEM_MC_SSE_UPDATE_MXCSR(fMxcsr);
3790 IEM_MC_IF_MXCSR_XCPT_PENDING() {
3791 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
3792 } IEM_MC_ELSE() {
3793 IEM_MC_STORE_XREG_R32(IEM_GET_MODRM_REG(pVCpu, bRm), r32Dst);
3794 } IEM_MC_ENDIF();
3795
3796 IEM_MC_ADVANCE_RIP_AND_FINISH();
3797 IEM_MC_END();
3798 }
3799 else
3800 {
3801 /* XMM, [mem64] */
3802 IEM_MC_BEGIN(3, 4, IEM_MC_F_64BIT, 0);
3803 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
3804 IEM_MC_LOCAL(uint32_t, fMxcsr);
3805 IEM_MC_LOCAL(RTFLOAT32U, r32Dst);
3806 IEM_MC_LOCAL(int64_t, i64Src);
3807 IEM_MC_ARG_LOCAL_REF(uint32_t *, pfMxcsr, fMxcsr, 0);
3808 IEM_MC_ARG_LOCAL_REF(PRTFLOAT32U, pr32Dst, r32Dst, 1);
3809 IEM_MC_ARG_LOCAL_REF(const int64_t *, pi64Src, i64Src, 2);
3810
3811 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
3812 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
3813 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
3814 IEM_MC_PREPARE_SSE_USAGE(); /** @todo: This is superfluous because IEM_MC_CALL_SSE_AIMPL_3() is calling this but the tstIEMCheckMc testcase depends on it. */
3815
3816 IEM_MC_FETCH_MEM_I64(i64Src, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
3817 IEM_MC_CALL_SSE_AIMPL_3(iemAImpl_cvtsi2ss_r32_i64, pfMxcsr, pr32Dst, pi64Src);
3818 IEM_MC_SSE_UPDATE_MXCSR(fMxcsr);
3819 IEM_MC_IF_MXCSR_XCPT_PENDING() {
3820 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
3821 } IEM_MC_ELSE() {
3822 IEM_MC_STORE_XREG_R32(IEM_GET_MODRM_REG(pVCpu, bRm), r32Dst);
3823 } IEM_MC_ENDIF();
3824
3825 IEM_MC_ADVANCE_RIP_AND_FINISH();
3826 IEM_MC_END();
3827 }
3828 }
3829 else
3830 {
3831 if (IEM_IS_MODRM_REG_MODE(bRm))
3832 {
3833 /* greg, XMM */
3834 IEM_MC_BEGIN(3, 2, 0, 0);
3835 IEM_MC_LOCAL(uint32_t, fMxcsr);
3836 IEM_MC_LOCAL(RTFLOAT32U, r32Dst);
3837 IEM_MC_ARG_LOCAL_REF(uint32_t *, pfMxcsr, fMxcsr, 0);
3838 IEM_MC_ARG_LOCAL_REF(PRTFLOAT32U, pr32Dst, r32Dst, 1);
3839 IEM_MC_ARG(const int32_t *, pi32Src, 2);
3840
3841 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
3842 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
3843 IEM_MC_PREPARE_SSE_USAGE(); /** @todo: This is superfluous because IEM_MC_CALL_SSE_AIMPL_3() is calling this but the tstIEMCheckMc testcase depends on it. */
3844
3845 IEM_MC_REF_GREG_I32_CONST(pi32Src, IEM_GET_MODRM_RM(pVCpu, bRm));
3846 IEM_MC_CALL_SSE_AIMPL_3(iemAImpl_cvtsi2ss_r32_i32, pfMxcsr, pr32Dst, pi32Src);
3847 IEM_MC_SSE_UPDATE_MXCSR(fMxcsr);
3848 IEM_MC_IF_MXCSR_XCPT_PENDING() {
3849 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
3850 } IEM_MC_ELSE() {
3851 IEM_MC_STORE_XREG_R32(IEM_GET_MODRM_REG(pVCpu, bRm), r32Dst);
3852 } IEM_MC_ENDIF();
3853
3854 IEM_MC_ADVANCE_RIP_AND_FINISH();
3855 IEM_MC_END();
3856 }
3857 else
3858 {
3859 /* greg, [mem32] */
3860 IEM_MC_BEGIN(3, 4, 0, 0);
3861 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
3862 IEM_MC_LOCAL(uint32_t, fMxcsr);
3863 IEM_MC_LOCAL(RTFLOAT32U, r32Dst);
3864 IEM_MC_LOCAL(int32_t, i32Src);
3865 IEM_MC_ARG_LOCAL_REF(uint32_t *, pfMxcsr, fMxcsr, 0);
3866 IEM_MC_ARG_LOCAL_REF(PRTFLOAT32U, pr32Dst, r32Dst, 1);
3867 IEM_MC_ARG_LOCAL_REF(const int32_t *, pi32Src, i32Src, 2);
3868
3869 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
3870 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
3871 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
3872 IEM_MC_PREPARE_SSE_USAGE(); /** @todo This is superfluous because IEM_MC_CALL_SSE_AIMPL_3() is calling this but the tstIEMCheckMc testcase depends on it. */
3873
3874 IEM_MC_FETCH_MEM_I32(i32Src, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
3875 IEM_MC_CALL_SSE_AIMPL_3(iemAImpl_cvtsi2ss_r32_i32, pfMxcsr, pr32Dst, pi32Src);
3876 IEM_MC_SSE_UPDATE_MXCSR(fMxcsr);
3877 IEM_MC_IF_MXCSR_XCPT_PENDING() {
3878 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
3879 } IEM_MC_ELSE() {
3880 IEM_MC_STORE_XREG_R32(IEM_GET_MODRM_REG(pVCpu, bRm), r32Dst);
3881 } IEM_MC_ENDIF();
3882
3883 IEM_MC_ADVANCE_RIP_AND_FINISH();
3884 IEM_MC_END();
3885 }
3886 }
3887}
3888
3889
3890/** Opcode 0xf2 0x0f 0x2a - cvtsi2sd Vsd, Ey */
3891FNIEMOP_DEF(iemOp_cvtsi2sd_Vsd_Ey)
3892{
3893 IEMOP_MNEMONIC2(RM, CVTSI2SD, cvtsi2sd, Vsd, Ey, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
3894
3895 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
3896 if (pVCpu->iem.s.fPrefixes & IEM_OP_PRF_SIZE_REX_W)
3897 {
3898 if (IEM_IS_MODRM_REG_MODE(bRm))
3899 {
3900 /* XMM, greg64 */
3901 IEM_MC_BEGIN(3, 2, IEM_MC_F_64BIT, 0);
3902 IEM_MC_LOCAL(uint32_t, fMxcsr);
3903 IEM_MC_LOCAL(RTFLOAT64U, r64Dst);
3904 IEM_MC_ARG_LOCAL_REF(uint32_t *, pfMxcsr, fMxcsr, 0);
3905 IEM_MC_ARG_LOCAL_REF(PRTFLOAT64U, pr64Dst, r64Dst, 1);
3906 IEM_MC_ARG(const int64_t *, pi64Src, 2);
3907
3908 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
3909 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
3910 IEM_MC_PREPARE_SSE_USAGE(); /** @todo This is superfluous because IEM_MC_CALL_SSE_AIMPL_3() is calling this but the tstIEMCheckMc testcase depends on it. */
3911
3912 IEM_MC_REF_GREG_I64_CONST(pi64Src, IEM_GET_MODRM_RM(pVCpu, bRm));
3913 IEM_MC_CALL_SSE_AIMPL_3(iemAImpl_cvtsi2sd_r64_i64, pfMxcsr, pr64Dst, pi64Src);
3914 IEM_MC_SSE_UPDATE_MXCSR(fMxcsr);
3915 IEM_MC_IF_MXCSR_XCPT_PENDING() {
3916 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
3917 } IEM_MC_ELSE() {
3918 IEM_MC_STORE_XREG_R64(IEM_GET_MODRM_REG(pVCpu, bRm), r64Dst);
3919 } IEM_MC_ENDIF();
3920
3921 IEM_MC_ADVANCE_RIP_AND_FINISH();
3922 IEM_MC_END();
3923 }
3924 else
3925 {
3926 /* XMM, [mem64] */
3927 IEM_MC_BEGIN(3, 4, IEM_MC_F_64BIT, 0);
3928 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
3929 IEM_MC_LOCAL(uint32_t, fMxcsr);
3930 IEM_MC_LOCAL(RTFLOAT64U, r64Dst);
3931 IEM_MC_LOCAL(int64_t, i64Src);
3932 IEM_MC_ARG_LOCAL_REF(uint32_t *, pfMxcsr, fMxcsr, 0);
3933 IEM_MC_ARG_LOCAL_REF(PRTFLOAT64U, pr64Dst, r64Dst, 1);
3934 IEM_MC_ARG_LOCAL_REF(const int64_t *, pi64Src, i64Src, 2);
3935
3936 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
3937 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
3938 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
3939 IEM_MC_PREPARE_SSE_USAGE(); /** @todo This is superfluous because IEM_MC_CALL_SSE_AIMPL_3() is calling this but the tstIEMCheckMc testcase depends on it. */
3940
3941 IEM_MC_FETCH_MEM_I64(i64Src, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
3942 IEM_MC_CALL_SSE_AIMPL_3(iemAImpl_cvtsi2sd_r64_i64, pfMxcsr, pr64Dst, pi64Src);
3943 IEM_MC_SSE_UPDATE_MXCSR(fMxcsr);
3944 IEM_MC_IF_MXCSR_XCPT_PENDING() {
3945 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
3946 } IEM_MC_ELSE() {
3947 IEM_MC_STORE_XREG_R64(IEM_GET_MODRM_REG(pVCpu, bRm), r64Dst);
3948 } IEM_MC_ENDIF();
3949
3950 IEM_MC_ADVANCE_RIP_AND_FINISH();
3951 IEM_MC_END();
3952 }
3953 }
3954 else
3955 {
3956 if (IEM_IS_MODRM_REG_MODE(bRm))
3957 {
3958 /* XMM, greg32 */
3959 IEM_MC_BEGIN(3, 2, 0, 0);
3960 IEM_MC_LOCAL(uint32_t, fMxcsr);
3961 IEM_MC_LOCAL(RTFLOAT64U, r64Dst);
3962 IEM_MC_ARG_LOCAL_REF(uint32_t *, pfMxcsr, fMxcsr, 0);
3963 IEM_MC_ARG_LOCAL_REF(PRTFLOAT64U, pr64Dst, r64Dst, 1);
3964 IEM_MC_ARG(const int32_t *, pi32Src, 2);
3965
3966 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
3967 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
3968 IEM_MC_PREPARE_SSE_USAGE(); /** @todo: This is superfluous because IEM_MC_CALL_SSE_AIMPL_3() is calling this but the tstIEMCheckMc testcase depends on it. */
3969
3970 IEM_MC_REF_GREG_I32_CONST(pi32Src, IEM_GET_MODRM_RM(pVCpu, bRm));
3971 IEM_MC_CALL_SSE_AIMPL_3(iemAImpl_cvtsi2sd_r64_i32, pfMxcsr, pr64Dst, pi32Src);
3972 IEM_MC_SSE_UPDATE_MXCSR(fMxcsr);
3973 IEM_MC_IF_MXCSR_XCPT_PENDING() {
3974 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
3975 } IEM_MC_ELSE() {
3976 IEM_MC_STORE_XREG_R64(IEM_GET_MODRM_REG(pVCpu, bRm), r64Dst);
3977 } IEM_MC_ENDIF();
3978
3979 IEM_MC_ADVANCE_RIP_AND_FINISH();
3980 IEM_MC_END();
3981 }
3982 else
3983 {
3984 /* XMM, [mem32] */
3985 IEM_MC_BEGIN(3, 4, 0, 0);
3986 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
3987 IEM_MC_LOCAL(uint32_t, fMxcsr);
3988 IEM_MC_LOCAL(RTFLOAT64U, r64Dst);
3989 IEM_MC_LOCAL(int32_t, i32Src);
3990 IEM_MC_ARG_LOCAL_REF(uint32_t *, pfMxcsr, fMxcsr, 0);
3991 IEM_MC_ARG_LOCAL_REF(PRTFLOAT64U, pr64Dst, r64Dst, 1);
3992 IEM_MC_ARG_LOCAL_REF(const int32_t *, pi32Src, i32Src, 2);
3993
3994 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
3995 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
3996 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
3997 IEM_MC_PREPARE_SSE_USAGE(); /** @todo: This is superfluous because IEM_MC_CALL_SSE_AIMPL_3() is calling this but the tstIEMCheckMc testcase depends on it. */
3998
3999 IEM_MC_FETCH_MEM_I32(i32Src, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
4000 IEM_MC_CALL_SSE_AIMPL_3(iemAImpl_cvtsi2sd_r64_i32, pfMxcsr, pr64Dst, pi32Src);
4001 IEM_MC_SSE_UPDATE_MXCSR(fMxcsr);
4002 IEM_MC_IF_MXCSR_XCPT_PENDING() {
4003 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
4004 } IEM_MC_ELSE() {
4005 IEM_MC_STORE_XREG_R64(IEM_GET_MODRM_REG(pVCpu, bRm), r64Dst);
4006 } IEM_MC_ENDIF();
4007
4008 IEM_MC_ADVANCE_RIP_AND_FINISH();
4009 IEM_MC_END();
4010 }
4011 }
4012}
4013
4014
4015/**
4016 * @opcode 0x2b
4017 * @opcodesub !11 mr/reg
4018 * @oppfx none
4019 * @opcpuid sse
4020 * @opgroup og_sse1_cachect
4021 * @opxcpttype 1
4022 * @optest op1=1 op2=2 -> op1=2
4023 * @optest op1=0 op2=-42 -> op1=-42
4024 */
4025FNIEMOP_DEF(iemOp_movntps_Mps_Vps)
4026{
4027 IEMOP_MNEMONIC2(MR_MEM, MOVNTPS, movntps, Mps_WO, Vps, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
4028 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
4029 if (IEM_IS_MODRM_MEM_MODE(bRm))
4030 {
4031 /*
4032 * memory, register.
4033 */
4034 IEM_MC_BEGIN(0, 2, 0, 0);
4035 IEM_MC_LOCAL(RTUINT128U, uSrc); /** @todo optimize this one day... */
4036 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
4037
4038 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
4039 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
4040 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
4041 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
4042
4043 IEM_MC_FETCH_XREG_U128(uSrc, IEM_GET_MODRM_REG(pVCpu, bRm));
4044 IEM_MC_STORE_MEM_U128_ALIGN_SSE(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, uSrc);
4045
4046 IEM_MC_ADVANCE_RIP_AND_FINISH();
4047 IEM_MC_END();
4048 }
4049 /* The register, register encoding is invalid. */
4050 else
4051 IEMOP_RAISE_INVALID_OPCODE_RET();
4052}
4053
4054/**
4055 * @opcode 0x2b
4056 * @opcodesub !11 mr/reg
4057 * @oppfx 0x66
4058 * @opcpuid sse2
4059 * @opgroup og_sse2_cachect
4060 * @opxcpttype 1
4061 * @optest op1=1 op2=2 -> op1=2
4062 * @optest op1=0 op2=-42 -> op1=-42
4063 */
4064FNIEMOP_DEF(iemOp_movntpd_Mpd_Vpd)
4065{
4066 IEMOP_MNEMONIC2(MR_MEM, MOVNTPD, movntpd, Mpd_WO, Vpd, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
4067 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
4068 if (IEM_IS_MODRM_MEM_MODE(bRm))
4069 {
4070 /*
4071 * memory, register.
4072 */
4073 IEM_MC_BEGIN(0, 2, 0, 0);
4074 IEM_MC_LOCAL(RTUINT128U, uSrc); /** @todo optimize this one day... */
4075 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
4076
4077 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
4078 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
4079 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
4080 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
4081
4082 IEM_MC_FETCH_XREG_U128(uSrc, IEM_GET_MODRM_REG(pVCpu, bRm));
4083 IEM_MC_STORE_MEM_U128_ALIGN_SSE(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, uSrc);
4084
4085 IEM_MC_ADVANCE_RIP_AND_FINISH();
4086 IEM_MC_END();
4087 }
4088 /* The register, register encoding is invalid. */
4089 else
4090 IEMOP_RAISE_INVALID_OPCODE_RET();
4091}
4092/* Opcode 0xf3 0x0f 0x2b - invalid */
4093/* Opcode 0xf2 0x0f 0x2b - invalid */
4094
4095
4096/** Opcode 0x0f 0x2c - cvttps2pi Ppi, Wps */
4097FNIEMOP_DEF(iemOp_cvttps2pi_Ppi_Wps)
4098{
4099 IEMOP_MNEMONIC2(RM, CVTTPS2PI, cvttps2pi, Pq, Wps, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0); /// @todo
4100 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
4101 if (IEM_IS_MODRM_REG_MODE(bRm))
4102 {
4103 /*
4104 * Register, register.
4105 */
4106 IEM_MC_BEGIN(3, 1, 0, 0);
4107 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
4108 IEM_MC_ARG(uint32_t *, pfMxcsr, 0);
4109 IEM_MC_LOCAL(uint64_t, u64Dst);
4110 IEM_MC_ARG_LOCAL_REF(uint64_t *, pu64Dst, u64Dst, 1);
4111 IEM_MC_ARG(uint64_t, u64Src, 2);
4112 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
4113 IEM_MC_PREPARE_FPU_USAGE();
4114 IEM_MC_FPU_TO_MMX_MODE();
4115
4116 IEM_MC_REF_MXCSR(pfMxcsr);
4117 IEM_MC_FETCH_XREG_U64(u64Src, IEM_GET_MODRM_RM(pVCpu, bRm), 0 /* a_iQword*/);
4118
4119 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_cvttps2pi_u128, pfMxcsr, pu64Dst, u64Src);
4120 IEM_MC_IF_MXCSR_XCPT_PENDING() {
4121 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
4122 } IEM_MC_ELSE() {
4123 IEM_MC_STORE_MREG_U64(IEM_GET_MODRM_REG_8(bRm), u64Dst);
4124 } IEM_MC_ENDIF();
4125
4126 IEM_MC_ADVANCE_RIP_AND_FINISH();
4127 IEM_MC_END();
4128 }
4129 else
4130 {
4131 /*
4132 * Register, memory.
4133 */
4134 IEM_MC_BEGIN(3, 2, 0, 0);
4135 IEM_MC_ARG(uint32_t *, pfMxcsr, 0);
4136 IEM_MC_LOCAL(uint64_t, u64Dst);
4137 IEM_MC_ARG_LOCAL_REF(uint64_t *, pu64Dst, u64Dst, 1);
4138 IEM_MC_ARG(uint64_t, u64Src, 2);
4139 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
4140
4141 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
4142 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
4143 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
4144 IEM_MC_FETCH_MEM_U64(u64Src, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
4145
4146 IEM_MC_PREPARE_FPU_USAGE();
4147 IEM_MC_FPU_TO_MMX_MODE();
4148 IEM_MC_REF_MXCSR(pfMxcsr);
4149
4150 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_cvttps2pi_u128, pfMxcsr, pu64Dst, u64Src);
4151 IEM_MC_IF_MXCSR_XCPT_PENDING() {
4152 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
4153 } IEM_MC_ELSE() {
4154 IEM_MC_STORE_MREG_U64(IEM_GET_MODRM_REG_8(bRm), u64Dst);
4155 } IEM_MC_ENDIF();
4156
4157 IEM_MC_ADVANCE_RIP_AND_FINISH();
4158 IEM_MC_END();
4159 }
4160}
4161
4162
4163/** Opcode 0x66 0x0f 0x2c - cvttpd2pi Ppi, Wpd */
4164FNIEMOP_DEF(iemOp_cvttpd2pi_Ppi_Wpd)
4165{
4166 IEMOP_MNEMONIC2(RM, CVTTPD2PI, cvttpd2pi, Pq, Wpd, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0); /// @todo
4167 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
4168 if (IEM_IS_MODRM_REG_MODE(bRm))
4169 {
4170 /*
4171 * Register, register.
4172 */
4173 IEM_MC_BEGIN(3, 1, 0, 0);
4174 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
4175 IEM_MC_ARG(uint32_t *, pfMxcsr, 0);
4176 IEM_MC_LOCAL(uint64_t, u64Dst);
4177 IEM_MC_ARG_LOCAL_REF(uint64_t *, pu64Dst, u64Dst, 1);
4178 IEM_MC_ARG(PCX86XMMREG, pSrc, 2);
4179 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
4180 IEM_MC_PREPARE_FPU_USAGE();
4181 IEM_MC_FPU_TO_MMX_MODE();
4182
4183 IEM_MC_REF_MXCSR(pfMxcsr);
4184 IEM_MC_REF_XREG_XMM_CONST(pSrc, IEM_GET_MODRM_RM(pVCpu, bRm));
4185
4186 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_cvttpd2pi_u128, pfMxcsr, pu64Dst, pSrc);
4187 IEM_MC_IF_MXCSR_XCPT_PENDING() {
4188 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
4189 } IEM_MC_ELSE() {
4190 IEM_MC_STORE_MREG_U64(IEM_GET_MODRM_REG_8(bRm), u64Dst);
4191 } IEM_MC_ENDIF();
4192
4193 IEM_MC_ADVANCE_RIP_AND_FINISH();
4194 IEM_MC_END();
4195 }
4196 else
4197 {
4198 /*
4199 * Register, memory.
4200 */
4201 IEM_MC_BEGIN(3, 3, 0, 0);
4202 IEM_MC_ARG(uint32_t *, pfMxcsr, 0);
4203 IEM_MC_LOCAL(uint64_t, u64Dst);
4204 IEM_MC_ARG_LOCAL_REF(uint64_t *, pu64Dst, u64Dst, 1);
4205 IEM_MC_LOCAL(X86XMMREG, uSrc);
4206 IEM_MC_ARG_LOCAL_REF(PCX86XMMREG, pSrc, uSrc, 2);
4207 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
4208
4209 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
4210 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
4211 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
4212 IEM_MC_FETCH_MEM_XMM_ALIGN_SSE(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
4213
4214 IEM_MC_PREPARE_FPU_USAGE();
4215 IEM_MC_FPU_TO_MMX_MODE();
4216
4217 IEM_MC_REF_MXCSR(pfMxcsr);
4218
4219 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_cvttpd2pi_u128, pfMxcsr, pu64Dst, pSrc);
4220 IEM_MC_IF_MXCSR_XCPT_PENDING() {
4221 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
4222 } IEM_MC_ELSE() {
4223 IEM_MC_STORE_MREG_U64(IEM_GET_MODRM_REG_8(bRm), u64Dst);
4224 } IEM_MC_ENDIF();
4225
4226 IEM_MC_ADVANCE_RIP_AND_FINISH();
4227 IEM_MC_END();
4228 }
4229}
4230
4231
4232/** Opcode 0xf3 0x0f 0x2c - cvttss2si Gy, Wss */
4233FNIEMOP_DEF(iemOp_cvttss2si_Gy_Wss)
4234{
4235 IEMOP_MNEMONIC2(RM, CVTTSS2SI, cvttss2si, Gy, Wsd, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
4236
4237 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
4238 if (pVCpu->iem.s.fPrefixes & IEM_OP_PRF_SIZE_REX_W)
4239 {
4240 if (IEM_IS_MODRM_REG_MODE(bRm))
4241 {
4242 /* greg64, XMM */
4243 IEM_MC_BEGIN(3, 2, IEM_MC_F_64BIT, 0);
4244 IEM_MC_LOCAL(uint32_t, fMxcsr);
4245 IEM_MC_LOCAL(int64_t, i64Dst);
4246 IEM_MC_ARG_LOCAL_REF(uint32_t *, pfMxcsr, fMxcsr, 0);
4247 IEM_MC_ARG_LOCAL_REF(int64_t *, pi64Dst, i64Dst, 1);
4248 IEM_MC_ARG(const uint32_t *, pu32Src, 2);
4249
4250 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
4251 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
4252 IEM_MC_PREPARE_SSE_USAGE(); /** @todo: This is superfluous because IEM_MC_CALL_SSE_AIMPL_3() is calling this but the tstIEMCheckMc testcase depends on it. */
4253
4254 IEM_MC_REF_XREG_U32_CONST(pu32Src, IEM_GET_MODRM_RM(pVCpu, bRm));
4255 IEM_MC_CALL_SSE_AIMPL_3(iemAImpl_cvttss2si_i64_r32, pfMxcsr, pi64Dst, pu32Src);
4256 IEM_MC_SSE_UPDATE_MXCSR(fMxcsr);
4257 IEM_MC_IF_MXCSR_XCPT_PENDING() {
4258 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
4259 } IEM_MC_ELSE() {
4260 IEM_MC_STORE_GREG_I64(IEM_GET_MODRM_REG(pVCpu, bRm), i64Dst);
4261 } IEM_MC_ENDIF();
4262
4263 IEM_MC_ADVANCE_RIP_AND_FINISH();
4264 IEM_MC_END();
4265 }
4266 else
4267 {
4268 /* greg64, [mem64] */
4269 IEM_MC_BEGIN(3, 4, IEM_MC_F_64BIT, 0);
4270 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
4271 IEM_MC_LOCAL(uint32_t, fMxcsr);
4272 IEM_MC_LOCAL(int64_t, i64Dst);
4273 IEM_MC_LOCAL(uint32_t, u32Src);
4274 IEM_MC_ARG_LOCAL_REF(uint32_t *, pfMxcsr, fMxcsr, 0);
4275 IEM_MC_ARG_LOCAL_REF(int64_t *, pi64Dst, i64Dst, 1);
4276 IEM_MC_ARG_LOCAL_REF(const uint32_t *, pu32Src, u32Src, 2);
4277
4278 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
4279 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
4280 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
4281 IEM_MC_PREPARE_SSE_USAGE(); /** @todo: This is superfluous because IEM_MC_CALL_SSE_AIMPL_3() is calling this but the tstIEMCheckMc testcase depends on it. */
4282
4283 IEM_MC_FETCH_MEM_U32(u32Src, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
4284 IEM_MC_CALL_SSE_AIMPL_3(iemAImpl_cvttss2si_i64_r32, pfMxcsr, pi64Dst, pu32Src);
4285 IEM_MC_SSE_UPDATE_MXCSR(fMxcsr);
4286 IEM_MC_IF_MXCSR_XCPT_PENDING() {
4287 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
4288 } IEM_MC_ELSE() {
4289 IEM_MC_STORE_GREG_I64(IEM_GET_MODRM_REG(pVCpu, bRm), i64Dst);
4290 } IEM_MC_ENDIF();
4291
4292 IEM_MC_ADVANCE_RIP_AND_FINISH();
4293 IEM_MC_END();
4294 }
4295 }
4296 else
4297 {
4298 if (IEM_IS_MODRM_REG_MODE(bRm))
4299 {
4300 /* greg, XMM */
4301 IEM_MC_BEGIN(3, 2, 0, 0);
4302 IEM_MC_LOCAL(uint32_t, fMxcsr);
4303 IEM_MC_LOCAL(int32_t, i32Dst);
4304 IEM_MC_ARG_LOCAL_REF(uint32_t *, pfMxcsr, fMxcsr, 0);
4305 IEM_MC_ARG_LOCAL_REF(int32_t *, pi32Dst, i32Dst, 1);
4306 IEM_MC_ARG(const uint32_t *, pu32Src, 2);
4307
4308 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
4309 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
4310 IEM_MC_PREPARE_SSE_USAGE(); /** @todo: This is superfluous because IEM_MC_CALL_SSE_AIMPL_3() is calling this but the tstIEMCheckMc testcase depends on it. */
4311
4312 IEM_MC_REF_XREG_U32_CONST(pu32Src, IEM_GET_MODRM_RM(pVCpu, bRm));
4313 IEM_MC_CALL_SSE_AIMPL_3(iemAImpl_cvttss2si_i32_r32, pfMxcsr, pi32Dst, pu32Src);
4314 IEM_MC_SSE_UPDATE_MXCSR(fMxcsr);
4315 IEM_MC_IF_MXCSR_XCPT_PENDING() {
4316 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
4317 } IEM_MC_ELSE() {
4318 IEM_MC_STORE_GREG_U32(IEM_GET_MODRM_REG(pVCpu, bRm), i32Dst);
4319 } IEM_MC_ENDIF();
4320
4321 IEM_MC_ADVANCE_RIP_AND_FINISH();
4322 IEM_MC_END();
4323 }
4324 else
4325 {
4326 /* greg, [mem] */
4327 IEM_MC_BEGIN(3, 4, 0, 0);
4328 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
4329 IEM_MC_LOCAL(uint32_t, fMxcsr);
4330 IEM_MC_LOCAL(int32_t, i32Dst);
4331 IEM_MC_LOCAL(uint32_t, u32Src);
4332 IEM_MC_ARG_LOCAL_REF(uint32_t *, pfMxcsr, fMxcsr, 0);
4333 IEM_MC_ARG_LOCAL_REF(int32_t *, pi32Dst, i32Dst, 1);
4334 IEM_MC_ARG_LOCAL_REF(const uint32_t *, pu32Src, u32Src, 2);
4335
4336 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
4337 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
4338 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
4339 IEM_MC_PREPARE_SSE_USAGE(); /** @todo: This is superfluous because IEM_MC_CALL_SSE_AIMPL_3() is calling this but the tstIEMCheckMc testcase depends on it. */
4340
4341 IEM_MC_FETCH_MEM_U32(u32Src, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
4342 IEM_MC_CALL_SSE_AIMPL_3(iemAImpl_cvttss2si_i32_r32, pfMxcsr, pi32Dst, pu32Src);
4343 IEM_MC_SSE_UPDATE_MXCSR(fMxcsr);
4344 IEM_MC_IF_MXCSR_XCPT_PENDING() {
4345 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
4346 } IEM_MC_ELSE() {
4347 IEM_MC_STORE_GREG_U32(IEM_GET_MODRM_REG(pVCpu, bRm), i32Dst);
4348 } IEM_MC_ENDIF();
4349
4350 IEM_MC_ADVANCE_RIP_AND_FINISH();
4351 IEM_MC_END();
4352 }
4353 }
4354}
4355
4356
4357/** Opcode 0xf2 0x0f 0x2c - cvttsd2si Gy, Wsd */
4358FNIEMOP_DEF(iemOp_cvttsd2si_Gy_Wsd)
4359{
4360 IEMOP_MNEMONIC2(RM, CVTTSD2SI, cvttsd2si, Gy, Wsd, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
4361
4362 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
4363 if (pVCpu->iem.s.fPrefixes & IEM_OP_PRF_SIZE_REX_W)
4364 {
4365 if (IEM_IS_MODRM_REG_MODE(bRm))
4366 {
4367 /* greg64, XMM */
4368 IEM_MC_BEGIN(3, 2, IEM_MC_F_64BIT, 0);
4369 IEM_MC_LOCAL(uint32_t, fMxcsr);
4370 IEM_MC_LOCAL(int64_t, i64Dst);
4371 IEM_MC_ARG_LOCAL_REF(uint32_t *, pfMxcsr, fMxcsr, 0);
4372 IEM_MC_ARG_LOCAL_REF(int64_t *, pi64Dst, i64Dst, 1);
4373 IEM_MC_ARG(const uint64_t *, pu64Src, 2);
4374
4375 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
4376 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
4377 IEM_MC_PREPARE_SSE_USAGE(); /** @todo: This is superfluous because IEM_MC_CALL_SSE_AIMPL_3() is calling this but the tstIEMCheckMc testcase depends on it. */
4378
4379 IEM_MC_REF_XREG_U64_CONST(pu64Src, IEM_GET_MODRM_RM(pVCpu, bRm));
4380 IEM_MC_CALL_SSE_AIMPL_3(iemAImpl_cvttsd2si_i64_r64, pfMxcsr, pi64Dst, pu64Src);
4381 IEM_MC_SSE_UPDATE_MXCSR(fMxcsr);
4382 IEM_MC_IF_MXCSR_XCPT_PENDING() {
4383 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
4384 } IEM_MC_ELSE() {
4385 IEM_MC_STORE_GREG_I64(IEM_GET_MODRM_REG(pVCpu, bRm), i64Dst);
4386 } IEM_MC_ENDIF();
4387
4388 IEM_MC_ADVANCE_RIP_AND_FINISH();
4389 IEM_MC_END();
4390 }
4391 else
4392 {
4393 /* greg64, [mem64] */
4394 IEM_MC_BEGIN(3, 4, IEM_MC_F_64BIT, 0);
4395 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
4396 IEM_MC_LOCAL(uint32_t, fMxcsr);
4397 IEM_MC_LOCAL(int64_t, i64Dst);
4398 IEM_MC_LOCAL(uint64_t, u64Src);
4399 IEM_MC_ARG_LOCAL_REF(uint32_t *, pfMxcsr, fMxcsr, 0);
4400 IEM_MC_ARG_LOCAL_REF(int64_t *, pi64Dst, i64Dst, 1);
4401 IEM_MC_ARG_LOCAL_REF(const uint64_t *, pu64Src, u64Src, 2);
4402
4403 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
4404 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
4405 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
4406 IEM_MC_PREPARE_SSE_USAGE(); /** @todo: This is superfluous because IEM_MC_CALL_SSE_AIMPL_3() is calling this but the tstIEMCheckMc testcase depends on it. */
4407
4408 IEM_MC_FETCH_MEM_U64(u64Src, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
4409 IEM_MC_CALL_SSE_AIMPL_3(iemAImpl_cvttsd2si_i64_r64, pfMxcsr, pi64Dst, pu64Src);
4410 IEM_MC_SSE_UPDATE_MXCSR(fMxcsr);
4411 IEM_MC_IF_MXCSR_XCPT_PENDING() {
4412 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
4413 } IEM_MC_ELSE() {
4414 IEM_MC_STORE_GREG_I64(IEM_GET_MODRM_REG(pVCpu, bRm), i64Dst);
4415 } IEM_MC_ENDIF();
4416
4417 IEM_MC_ADVANCE_RIP_AND_FINISH();
4418 IEM_MC_END();
4419 }
4420 }
4421 else
4422 {
4423 if (IEM_IS_MODRM_REG_MODE(bRm))
4424 {
4425 /* greg, XMM */
4426 IEM_MC_BEGIN(3, 2, 0, 0);
4427 IEM_MC_LOCAL(uint32_t, fMxcsr);
4428 IEM_MC_LOCAL(int32_t, i32Dst);
4429 IEM_MC_ARG_LOCAL_REF(uint32_t *, pfMxcsr, fMxcsr, 0);
4430 IEM_MC_ARG_LOCAL_REF(int32_t *, pi32Dst, i32Dst, 1);
4431 IEM_MC_ARG(const uint64_t *, pu64Src, 2);
4432
4433 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
4434 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
4435 IEM_MC_PREPARE_SSE_USAGE(); /** @todo: This is superfluous because IEM_MC_CALL_SSE_AIMPL_3() is calling this but the tstIEMCheckMc testcase depends on it. */
4436
4437 IEM_MC_REF_XREG_U64_CONST(pu64Src, IEM_GET_MODRM_RM(pVCpu, bRm));
4438 IEM_MC_CALL_SSE_AIMPL_3(iemAImpl_cvttsd2si_i32_r64, pfMxcsr, pi32Dst, pu64Src);
4439 IEM_MC_SSE_UPDATE_MXCSR(fMxcsr);
4440 IEM_MC_IF_MXCSR_XCPT_PENDING() {
4441 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
4442 } IEM_MC_ELSE() {
4443 IEM_MC_STORE_GREG_U32(IEM_GET_MODRM_REG(pVCpu, bRm), i32Dst);
4444 } IEM_MC_ENDIF();
4445
4446 IEM_MC_ADVANCE_RIP_AND_FINISH();
4447 IEM_MC_END();
4448 }
4449 else
4450 {
4451 /* greg32, [mem32] */
4452 IEM_MC_BEGIN(3, 4, 0, 0);
4453 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
4454 IEM_MC_LOCAL(uint32_t, fMxcsr);
4455 IEM_MC_LOCAL(int32_t, i32Dst);
4456 IEM_MC_LOCAL(uint64_t, u64Src);
4457 IEM_MC_ARG_LOCAL_REF(uint32_t *, pfMxcsr, fMxcsr, 0);
4458 IEM_MC_ARG_LOCAL_REF(int32_t *, pi32Dst, i32Dst, 1);
4459 IEM_MC_ARG_LOCAL_REF(const uint64_t *, pu64Src, u64Src, 2);
4460
4461 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
4462 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
4463 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
4464 IEM_MC_PREPARE_SSE_USAGE(); /** @todo: This is superfluous because IEM_MC_CALL_SSE_AIMPL_3() is calling this but the tstIEMCheckMc testcase depends on it. */
4465
4466 IEM_MC_FETCH_MEM_U64(u64Src, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
4467 IEM_MC_CALL_SSE_AIMPL_3(iemAImpl_cvttsd2si_i32_r64, pfMxcsr, pi32Dst, pu64Src);
4468 IEM_MC_SSE_UPDATE_MXCSR(fMxcsr);
4469 IEM_MC_IF_MXCSR_XCPT_PENDING() {
4470 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
4471 } IEM_MC_ELSE() {
4472 IEM_MC_STORE_GREG_U32(IEM_GET_MODRM_REG(pVCpu, bRm), i32Dst);
4473 } IEM_MC_ENDIF();
4474
4475 IEM_MC_ADVANCE_RIP_AND_FINISH();
4476 IEM_MC_END();
4477 }
4478 }
4479}
4480
4481
4482/** Opcode 0x0f 0x2d - cvtps2pi Ppi, Wps */
4483FNIEMOP_DEF(iemOp_cvtps2pi_Ppi_Wps)
4484{
4485 IEMOP_MNEMONIC2(RM, CVTPS2PI, cvtps2pi, Pq, Wps, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0); /// @todo
4486 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
4487 if (IEM_IS_MODRM_REG_MODE(bRm))
4488 {
4489 /*
4490 * Register, register.
4491 */
4492 IEM_MC_BEGIN(3, 1, 0, 0);
4493 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
4494 IEM_MC_ARG(uint32_t *, pfMxcsr, 0);
4495 IEM_MC_LOCAL(uint64_t, u64Dst);
4496 IEM_MC_ARG_LOCAL_REF(uint64_t *, pu64Dst, u64Dst, 1);
4497 IEM_MC_ARG(uint64_t, u64Src, 2);
4498
4499 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
4500 IEM_MC_PREPARE_FPU_USAGE();
4501 IEM_MC_FPU_TO_MMX_MODE();
4502
4503 IEM_MC_REF_MXCSR(pfMxcsr);
4504 IEM_MC_FETCH_XREG_U64(u64Src, IEM_GET_MODRM_RM(pVCpu, bRm), 0 /* a_iQword*/);
4505
4506 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_cvtps2pi_u128, pfMxcsr, pu64Dst, u64Src);
4507 IEM_MC_IF_MXCSR_XCPT_PENDING() {
4508 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
4509 } IEM_MC_ELSE() {
4510 IEM_MC_STORE_MREG_U64(IEM_GET_MODRM_REG_8(bRm), u64Dst);
4511 } IEM_MC_ENDIF();
4512
4513 IEM_MC_ADVANCE_RIP_AND_FINISH();
4514 IEM_MC_END();
4515 }
4516 else
4517 {
4518 /*
4519 * Register, memory.
4520 */
4521 IEM_MC_BEGIN(3, 2, 0, 0);
4522 IEM_MC_ARG(uint32_t *, pfMxcsr, 0);
4523 IEM_MC_LOCAL(uint64_t, u64Dst);
4524 IEM_MC_ARG_LOCAL_REF(uint64_t *, pu64Dst, u64Dst, 1);
4525 IEM_MC_ARG(uint64_t, u64Src, 2);
4526 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
4527
4528 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
4529 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
4530 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
4531 IEM_MC_FETCH_MEM_U64(u64Src, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
4532
4533 IEM_MC_PREPARE_FPU_USAGE();
4534 IEM_MC_FPU_TO_MMX_MODE();
4535 IEM_MC_REF_MXCSR(pfMxcsr);
4536
4537 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_cvtps2pi_u128, pfMxcsr, pu64Dst, u64Src);
4538 IEM_MC_IF_MXCSR_XCPT_PENDING() {
4539 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
4540 } IEM_MC_ELSE() {
4541 IEM_MC_STORE_MREG_U64(IEM_GET_MODRM_REG_8(bRm), u64Dst);
4542 } IEM_MC_ENDIF();
4543
4544 IEM_MC_ADVANCE_RIP_AND_FINISH();
4545 IEM_MC_END();
4546 }
4547}
4548
4549
4550/** Opcode 0x66 0x0f 0x2d - cvtpd2pi Qpi, Wpd */
4551FNIEMOP_DEF(iemOp_cvtpd2pi_Qpi_Wpd)
4552{
4553 IEMOP_MNEMONIC2(RM, CVTPD2PI, cvtpd2pi, Pq, Wpd, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0); /// @todo
4554 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
4555 if (IEM_IS_MODRM_REG_MODE(bRm))
4556 {
4557 /*
4558 * Register, register.
4559 */
4560 IEM_MC_BEGIN(3, 1, 0, 0);
4561 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
4562 IEM_MC_ARG(uint32_t *, pfMxcsr, 0);
4563 IEM_MC_LOCAL(uint64_t, u64Dst);
4564 IEM_MC_ARG_LOCAL_REF(uint64_t *, pu64Dst, u64Dst, 1);
4565 IEM_MC_ARG(PCX86XMMREG, pSrc, 2);
4566
4567 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
4568 IEM_MC_PREPARE_FPU_USAGE();
4569 IEM_MC_FPU_TO_MMX_MODE();
4570
4571 IEM_MC_REF_MXCSR(pfMxcsr);
4572 IEM_MC_REF_XREG_XMM_CONST(pSrc, IEM_GET_MODRM_RM(pVCpu, bRm));
4573
4574 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_cvtpd2pi_u128, pfMxcsr, pu64Dst, pSrc);
4575 IEM_MC_IF_MXCSR_XCPT_PENDING() {
4576 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
4577 } IEM_MC_ELSE() {
4578 IEM_MC_STORE_MREG_U64(IEM_GET_MODRM_REG_8(bRm), u64Dst);
4579 } IEM_MC_ENDIF();
4580
4581 IEM_MC_ADVANCE_RIP_AND_FINISH();
4582 IEM_MC_END();
4583 }
4584 else
4585 {
4586 /*
4587 * Register, memory.
4588 */
4589 IEM_MC_BEGIN(3, 3, 0, 0);
4590 IEM_MC_ARG(uint32_t *, pfMxcsr, 0);
4591 IEM_MC_LOCAL(uint64_t, u64Dst);
4592 IEM_MC_ARG_LOCAL_REF(uint64_t *, pu64Dst, u64Dst, 1);
4593 IEM_MC_LOCAL(X86XMMREG, uSrc);
4594 IEM_MC_ARG_LOCAL_REF(PCX86XMMREG, pSrc, uSrc, 2);
4595 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
4596
4597 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
4598 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
4599 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
4600 IEM_MC_FETCH_MEM_XMM_ALIGN_SSE(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
4601
4602 IEM_MC_PREPARE_FPU_USAGE();
4603 IEM_MC_FPU_TO_MMX_MODE();
4604
4605 IEM_MC_REF_MXCSR(pfMxcsr);
4606
4607 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_cvtpd2pi_u128, pfMxcsr, pu64Dst, pSrc);
4608 IEM_MC_IF_MXCSR_XCPT_PENDING() {
4609 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
4610 } IEM_MC_ELSE() {
4611 IEM_MC_STORE_MREG_U64(IEM_GET_MODRM_REG_8(bRm), u64Dst);
4612 } IEM_MC_ENDIF();
4613
4614 IEM_MC_ADVANCE_RIP_AND_FINISH();
4615 IEM_MC_END();
4616 }
4617}
4618
4619
4620/** Opcode 0xf3 0x0f 0x2d - cvtss2si Gy, Wss */
4621FNIEMOP_DEF(iemOp_cvtss2si_Gy_Wss)
4622{
4623 IEMOP_MNEMONIC2(RM, CVTSS2SI, cvtss2si, Gy, Wsd, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
4624
4625 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
4626 if (pVCpu->iem.s.fPrefixes & IEM_OP_PRF_SIZE_REX_W)
4627 {
4628 if (IEM_IS_MODRM_REG_MODE(bRm))
4629 {
4630 /* greg64, XMM */
4631 IEM_MC_BEGIN(3, 2, IEM_MC_F_64BIT, 0);
4632 IEM_MC_LOCAL(uint32_t, fMxcsr);
4633 IEM_MC_LOCAL(int64_t, i64Dst);
4634 IEM_MC_ARG_LOCAL_REF(uint32_t *, pfMxcsr, fMxcsr, 0);
4635 IEM_MC_ARG_LOCAL_REF(int64_t *, pi64Dst, i64Dst, 1);
4636 IEM_MC_ARG(const uint32_t *, pu32Src, 2);
4637
4638 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
4639 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
4640 IEM_MC_PREPARE_SSE_USAGE(); /** @todo: This is superfluous because IEM_MC_CALL_SSE_AIMPL_3() is calling this but the tstIEMCheckMc testcase depends on it. */
4641
4642 IEM_MC_REF_XREG_U32_CONST(pu32Src, IEM_GET_MODRM_RM(pVCpu, bRm));
4643 IEM_MC_CALL_SSE_AIMPL_3(iemAImpl_cvtss2si_i64_r32, pfMxcsr, pi64Dst, pu32Src);
4644 IEM_MC_SSE_UPDATE_MXCSR(fMxcsr);
4645 IEM_MC_IF_MXCSR_XCPT_PENDING() {
4646 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
4647 } IEM_MC_ELSE() {
4648 IEM_MC_STORE_GREG_I64(IEM_GET_MODRM_REG(pVCpu, bRm), i64Dst);
4649 } IEM_MC_ENDIF();
4650
4651 IEM_MC_ADVANCE_RIP_AND_FINISH();
4652 IEM_MC_END();
4653 }
4654 else
4655 {
4656 /* greg64, [mem64] */
4657 IEM_MC_BEGIN(3, 4, IEM_MC_F_64BIT, 0);
4658 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
4659 IEM_MC_LOCAL(uint32_t, fMxcsr);
4660 IEM_MC_LOCAL(int64_t, i64Dst);
4661 IEM_MC_LOCAL(uint32_t, u32Src);
4662 IEM_MC_ARG_LOCAL_REF(uint32_t *, pfMxcsr, fMxcsr, 0);
4663 IEM_MC_ARG_LOCAL_REF(int64_t *, pi64Dst, i64Dst, 1);
4664 IEM_MC_ARG_LOCAL_REF(const uint32_t *, pu32Src, u32Src, 2);
4665
4666 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
4667 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
4668 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
4669 IEM_MC_PREPARE_SSE_USAGE(); /** @todo: This is superfluous because IEM_MC_CALL_SSE_AIMPL_3() is calling this but the tstIEMCheckMc testcase depends on it. */
4670
4671 IEM_MC_FETCH_MEM_U32(u32Src, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
4672 IEM_MC_CALL_SSE_AIMPL_3(iemAImpl_cvtss2si_i64_r32, pfMxcsr, pi64Dst, pu32Src);
4673 IEM_MC_SSE_UPDATE_MXCSR(fMxcsr);
4674 IEM_MC_IF_MXCSR_XCPT_PENDING() {
4675 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
4676 } IEM_MC_ELSE() {
4677 IEM_MC_STORE_GREG_I64(IEM_GET_MODRM_REG(pVCpu, bRm), i64Dst);
4678 } IEM_MC_ENDIF();
4679
4680 IEM_MC_ADVANCE_RIP_AND_FINISH();
4681 IEM_MC_END();
4682 }
4683 }
4684 else
4685 {
4686 if (IEM_IS_MODRM_REG_MODE(bRm))
4687 {
4688 /* greg, XMM */
4689 IEM_MC_BEGIN(3, 2, 0, 0);
4690 IEM_MC_LOCAL(uint32_t, fMxcsr);
4691 IEM_MC_LOCAL(int32_t, i32Dst);
4692 IEM_MC_ARG_LOCAL_REF(uint32_t *, pfMxcsr, fMxcsr, 0);
4693 IEM_MC_ARG_LOCAL_REF(int32_t *, pi32Dst, i32Dst, 1);
4694 IEM_MC_ARG(const uint32_t *, pu32Src, 2);
4695
4696 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
4697 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
4698 IEM_MC_PREPARE_SSE_USAGE(); /** @todo: This is superfluous because IEM_MC_CALL_SSE_AIMPL_3() is calling this but the tstIEMCheckMc testcase depends on it. */
4699
4700 IEM_MC_REF_XREG_U32_CONST(pu32Src, IEM_GET_MODRM_RM(pVCpu, bRm));
4701 IEM_MC_CALL_SSE_AIMPL_3(iemAImpl_cvtss2si_i32_r32, pfMxcsr, pi32Dst, pu32Src);
4702 IEM_MC_SSE_UPDATE_MXCSR(fMxcsr);
4703 IEM_MC_IF_MXCSR_XCPT_PENDING() {
4704 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
4705 } IEM_MC_ELSE() {
4706 IEM_MC_STORE_GREG_U32(IEM_GET_MODRM_REG(pVCpu, bRm), i32Dst);
4707 } IEM_MC_ENDIF();
4708
4709 IEM_MC_ADVANCE_RIP_AND_FINISH();
4710 IEM_MC_END();
4711 }
4712 else
4713 {
4714 /* greg, [mem] */
4715 IEM_MC_BEGIN(3, 4, 0, 0);
4716 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
4717 IEM_MC_LOCAL(uint32_t, fMxcsr);
4718 IEM_MC_LOCAL(int32_t, i32Dst);
4719 IEM_MC_LOCAL(uint32_t, u32Src);
4720 IEM_MC_ARG_LOCAL_REF(uint32_t *, pfMxcsr, fMxcsr, 0);
4721 IEM_MC_ARG_LOCAL_REF(int32_t *, pi32Dst, i32Dst, 1);
4722 IEM_MC_ARG_LOCAL_REF(const uint32_t *, pu32Src, u32Src, 2);
4723
4724 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
4725 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
4726 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
4727 IEM_MC_PREPARE_SSE_USAGE(); /** @todo: This is superfluous because IEM_MC_CALL_SSE_AIMPL_3() is calling this but the tstIEMCheckMc testcase depends on it. */
4728
4729 IEM_MC_FETCH_MEM_U32(u32Src, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
4730 IEM_MC_CALL_SSE_AIMPL_3(iemAImpl_cvtss2si_i32_r32, pfMxcsr, pi32Dst, pu32Src);
4731 IEM_MC_SSE_UPDATE_MXCSR(fMxcsr);
4732 IEM_MC_IF_MXCSR_XCPT_PENDING() {
4733 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
4734 } IEM_MC_ELSE() {
4735 IEM_MC_STORE_GREG_U32(IEM_GET_MODRM_REG(pVCpu, bRm), i32Dst);
4736 } IEM_MC_ENDIF();
4737
4738 IEM_MC_ADVANCE_RIP_AND_FINISH();
4739 IEM_MC_END();
4740 }
4741 }
4742}
4743
4744
4745/** Opcode 0xf2 0x0f 0x2d - cvtsd2si Gy, Wsd */
4746FNIEMOP_DEF(iemOp_cvtsd2si_Gy_Wsd)
4747{
4748 IEMOP_MNEMONIC2(RM, CVTSD2SI, cvtsd2si, Gy, Wsd, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
4749
4750 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
4751 if (pVCpu->iem.s.fPrefixes & IEM_OP_PRF_SIZE_REX_W)
4752 {
4753 if (IEM_IS_MODRM_REG_MODE(bRm))
4754 {
4755 /* greg64, XMM */
4756 IEM_MC_BEGIN(3, 2, IEM_MC_F_64BIT, 0);
4757 IEM_MC_LOCAL(uint32_t, fMxcsr);
4758 IEM_MC_LOCAL(int64_t, i64Dst);
4759 IEM_MC_ARG_LOCAL_REF(uint32_t *, pfMxcsr, fMxcsr, 0);
4760 IEM_MC_ARG_LOCAL_REF(int64_t *, pi64Dst, i64Dst, 1);
4761 IEM_MC_ARG(const uint64_t *, pu64Src, 2);
4762
4763 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
4764 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
4765 IEM_MC_PREPARE_SSE_USAGE(); /** @todo: This is superfluous because IEM_MC_CALL_SSE_AIMPL_3() is calling this but the tstIEMCheckMc testcase depends on it. */
4766
4767 IEM_MC_REF_XREG_U64_CONST(pu64Src, IEM_GET_MODRM_RM(pVCpu, bRm));
4768 IEM_MC_CALL_SSE_AIMPL_3(iemAImpl_cvtsd2si_i64_r64, pfMxcsr, pi64Dst, pu64Src);
4769 IEM_MC_SSE_UPDATE_MXCSR(fMxcsr);
4770 IEM_MC_IF_MXCSR_XCPT_PENDING() {
4771 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
4772 } IEM_MC_ELSE() {
4773 IEM_MC_STORE_GREG_I64(IEM_GET_MODRM_REG(pVCpu, bRm), i64Dst);
4774 } IEM_MC_ENDIF();
4775
4776 IEM_MC_ADVANCE_RIP_AND_FINISH();
4777 IEM_MC_END();
4778 }
4779 else
4780 {
4781 /* greg64, [mem64] */
4782 IEM_MC_BEGIN(3, 4, IEM_MC_F_64BIT, 0);
4783 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
4784 IEM_MC_LOCAL(uint32_t, fMxcsr);
4785 IEM_MC_LOCAL(int64_t, i64Dst);
4786 IEM_MC_LOCAL(uint64_t, u64Src);
4787 IEM_MC_ARG_LOCAL_REF(uint32_t *, pfMxcsr, fMxcsr, 0);
4788 IEM_MC_ARG_LOCAL_REF(int64_t *, pi64Dst, i64Dst, 1);
4789 IEM_MC_ARG_LOCAL_REF(const uint64_t *, pu64Src, u64Src, 2);
4790
4791 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
4792 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
4793 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
4794 IEM_MC_PREPARE_SSE_USAGE(); /** @todo: This is superfluous because IEM_MC_CALL_SSE_AIMPL_3() is calling this but the tstIEMCheckMc testcase depends on it. */
4795
4796 IEM_MC_FETCH_MEM_U64(u64Src, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
4797 IEM_MC_CALL_SSE_AIMPL_3(iemAImpl_cvtsd2si_i64_r64, pfMxcsr, pi64Dst, pu64Src);
4798 IEM_MC_SSE_UPDATE_MXCSR(fMxcsr);
4799 IEM_MC_IF_MXCSR_XCPT_PENDING() {
4800 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
4801 } IEM_MC_ELSE() {
4802 IEM_MC_STORE_GREG_I64(IEM_GET_MODRM_REG(pVCpu, bRm), i64Dst);
4803 } IEM_MC_ENDIF();
4804
4805 IEM_MC_ADVANCE_RIP_AND_FINISH();
4806 IEM_MC_END();
4807 }
4808 }
4809 else
4810 {
4811 if (IEM_IS_MODRM_REG_MODE(bRm))
4812 {
4813 /* greg32, XMM */
4814 IEM_MC_BEGIN(3, 2, 0, 0);
4815 IEM_MC_LOCAL(uint32_t, fMxcsr);
4816 IEM_MC_LOCAL(int32_t, i32Dst);
4817 IEM_MC_ARG_LOCAL_REF(uint32_t *, pfMxcsr, fMxcsr, 0);
4818 IEM_MC_ARG_LOCAL_REF(int32_t *, pi32Dst, i32Dst, 1);
4819 IEM_MC_ARG(const uint64_t *, pu64Src, 2);
4820
4821 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
4822 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
4823 IEM_MC_PREPARE_SSE_USAGE(); /** @todo: This is superfluous because IEM_MC_CALL_SSE_AIMPL_3() is calling this but the tstIEMCheckMc testcase depends on it. */
4824
4825 IEM_MC_REF_XREG_U64_CONST(pu64Src, IEM_GET_MODRM_RM(pVCpu, bRm));
4826 IEM_MC_CALL_SSE_AIMPL_3(iemAImpl_cvtsd2si_i32_r64, pfMxcsr, pi32Dst, pu64Src);
4827 IEM_MC_SSE_UPDATE_MXCSR(fMxcsr);
4828 IEM_MC_IF_MXCSR_XCPT_PENDING() {
4829 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
4830 } IEM_MC_ELSE() {
4831 IEM_MC_STORE_GREG_U32(IEM_GET_MODRM_REG(pVCpu, bRm), i32Dst);
4832 } IEM_MC_ENDIF();
4833
4834 IEM_MC_ADVANCE_RIP_AND_FINISH();
4835 IEM_MC_END();
4836 }
4837 else
4838 {
4839 /* greg32, [mem64] */
4840 IEM_MC_BEGIN(3, 4, 0, 0);
4841 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
4842 IEM_MC_LOCAL(uint32_t, fMxcsr);
4843 IEM_MC_LOCAL(int32_t, i32Dst);
4844 IEM_MC_LOCAL(uint64_t, u64Src);
4845 IEM_MC_ARG_LOCAL_REF(uint32_t *, pfMxcsr, fMxcsr, 0);
4846 IEM_MC_ARG_LOCAL_REF(int32_t *, pi32Dst, i32Dst, 1);
4847 IEM_MC_ARG_LOCAL_REF(const uint64_t *, pu64Src, u64Src, 2);
4848
4849 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
4850 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
4851 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
4852 IEM_MC_PREPARE_SSE_USAGE(); /** @todo: This is superfluous because IEM_MC_CALL_SSE_AIMPL_3() is calling this but the tstIEMCheckMc testcase depends on it. */
4853
4854 IEM_MC_FETCH_MEM_U64(u64Src, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
4855 IEM_MC_CALL_SSE_AIMPL_3(iemAImpl_cvtsd2si_i32_r64, pfMxcsr, pi32Dst, pu64Src);
4856 IEM_MC_SSE_UPDATE_MXCSR(fMxcsr);
4857 IEM_MC_IF_MXCSR_XCPT_PENDING() {
4858 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
4859 } IEM_MC_ELSE() {
4860 IEM_MC_STORE_GREG_U32(IEM_GET_MODRM_REG(pVCpu, bRm), i32Dst);
4861 } IEM_MC_ENDIF();
4862
4863 IEM_MC_ADVANCE_RIP_AND_FINISH();
4864 IEM_MC_END();
4865 }
4866 }
4867}
4868
4869
4870/** Opcode 0x0f 0x2e - ucomiss Vss, Wss */
4871FNIEMOP_DEF(iemOp_ucomiss_Vss_Wss)
4872{
4873 IEMOP_MNEMONIC2(RM, UCOMISS, ucomiss, Vss, Wss, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
4874 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
4875 if (IEM_IS_MODRM_REG_MODE(bRm))
4876 {
4877 /*
4878 * Register, register.
4879 */
4880 IEM_MC_BEGIN(4, 1, 0, 0);
4881 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
4882 IEM_MC_LOCAL(uint32_t, fEFlags);
4883 IEM_MC_ARG(uint32_t *, pfMxcsr, 0);
4884 IEM_MC_ARG_LOCAL_REF(uint32_t *, pEFlags, fEFlags, 1);
4885 IEM_MC_ARG(PCX86XMMREG, puSrc1, 2);
4886 IEM_MC_ARG(PCX86XMMREG, puSrc2, 3);
4887 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
4888 IEM_MC_PREPARE_SSE_USAGE();
4889 IEM_MC_FETCH_EFLAGS(fEFlags);
4890 IEM_MC_REF_MXCSR(pfMxcsr);
4891 IEM_MC_REF_XREG_XMM_CONST(puSrc1, IEM_GET_MODRM_REG(pVCpu, bRm));
4892 IEM_MC_REF_XREG_XMM_CONST(puSrc2, IEM_GET_MODRM_RM(pVCpu, bRm));
4893 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_ucomiss_u128, pfMxcsr, pEFlags, puSrc1, puSrc2);
4894 IEM_MC_IF_MXCSR_XCPT_PENDING() {
4895 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
4896 } IEM_MC_ELSE() {
4897 IEM_MC_COMMIT_EFLAGS(fEFlags);
4898 } IEM_MC_ENDIF();
4899
4900 IEM_MC_ADVANCE_RIP_AND_FINISH();
4901 IEM_MC_END();
4902 }
4903 else
4904 {
4905 /*
4906 * Register, memory.
4907 */
4908 IEM_MC_BEGIN(4, 3, 0, 0);
4909 IEM_MC_LOCAL(uint32_t, fEFlags);
4910 IEM_MC_ARG(uint32_t *, pfMxcsr, 0);
4911 IEM_MC_ARG_LOCAL_REF(uint32_t *, pEFlags, fEFlags, 1);
4912 IEM_MC_ARG(PCX86XMMREG, puSrc1, 2);
4913 IEM_MC_LOCAL(X86XMMREG, uSrc2);
4914 IEM_MC_ARG_LOCAL_REF(PCX86XMMREG, puSrc2, uSrc2, 3);
4915 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
4916
4917 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
4918 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
4919 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
4920 IEM_MC_FETCH_MEM_XMM_U32(uSrc2, 0 /*a_DWord*/, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
4921
4922 IEM_MC_PREPARE_SSE_USAGE();
4923 IEM_MC_FETCH_EFLAGS(fEFlags);
4924 IEM_MC_REF_MXCSR(pfMxcsr);
4925 IEM_MC_REF_XREG_XMM_CONST(puSrc1, IEM_GET_MODRM_REG(pVCpu, bRm));
4926 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_ucomiss_u128, pfMxcsr, pEFlags, puSrc1, puSrc2);
4927 IEM_MC_IF_MXCSR_XCPT_PENDING() {
4928 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
4929 } IEM_MC_ELSE() {
4930 IEM_MC_COMMIT_EFLAGS(fEFlags);
4931 } IEM_MC_ENDIF();
4932
4933 IEM_MC_ADVANCE_RIP_AND_FINISH();
4934 IEM_MC_END();
4935 }
4936}
4937
4938
4939/** Opcode 0x66 0x0f 0x2e - ucomisd Vsd, Wsd */
4940FNIEMOP_DEF(iemOp_ucomisd_Vsd_Wsd)
4941{
4942 IEMOP_MNEMONIC2(RM, UCOMISD, ucomisd, Vsd, Wsd, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
4943 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
4944 if (IEM_IS_MODRM_REG_MODE(bRm))
4945 {
4946 /*
4947 * Register, register.
4948 */
4949 IEM_MC_BEGIN(4, 1, 0, 0);
4950 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
4951 IEM_MC_LOCAL(uint32_t, fEFlags);
4952 IEM_MC_ARG(uint32_t *, pfMxcsr, 0);
4953 IEM_MC_ARG_LOCAL_REF(uint32_t *, pEFlags, fEFlags, 1);
4954 IEM_MC_ARG(PCX86XMMREG, puSrc1, 2);
4955 IEM_MC_ARG(PCX86XMMREG, puSrc2, 3);
4956 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
4957 IEM_MC_PREPARE_SSE_USAGE();
4958 IEM_MC_FETCH_EFLAGS(fEFlags);
4959 IEM_MC_REF_MXCSR(pfMxcsr);
4960 IEM_MC_REF_XREG_XMM_CONST(puSrc1, IEM_GET_MODRM_REG(pVCpu, bRm));
4961 IEM_MC_REF_XREG_XMM_CONST(puSrc2, IEM_GET_MODRM_RM(pVCpu, bRm));
4962 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_ucomisd_u128, pfMxcsr, pEFlags, puSrc1, puSrc2);
4963 IEM_MC_IF_MXCSR_XCPT_PENDING() {
4964 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
4965 } IEM_MC_ELSE() {
4966 IEM_MC_COMMIT_EFLAGS(fEFlags);
4967 } IEM_MC_ENDIF();
4968
4969 IEM_MC_ADVANCE_RIP_AND_FINISH();
4970 IEM_MC_END();
4971 }
4972 else
4973 {
4974 /*
4975 * Register, memory.
4976 */
4977 IEM_MC_BEGIN(4, 3, 0, 0);
4978 IEM_MC_LOCAL(uint32_t, fEFlags);
4979 IEM_MC_ARG(uint32_t *, pfMxcsr, 0);
4980 IEM_MC_ARG_LOCAL_REF(uint32_t *, pEFlags, fEFlags, 1);
4981 IEM_MC_ARG(PCX86XMMREG, puSrc1, 2);
4982 IEM_MC_LOCAL(X86XMMREG, uSrc2);
4983 IEM_MC_ARG_LOCAL_REF(PCX86XMMREG, puSrc2, uSrc2, 3);
4984 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
4985
4986 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
4987 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
4988 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
4989 IEM_MC_FETCH_MEM_XMM_U64(uSrc2, 0 /*a_QWord*/, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
4990
4991 IEM_MC_PREPARE_SSE_USAGE();
4992 IEM_MC_FETCH_EFLAGS(fEFlags);
4993 IEM_MC_REF_MXCSR(pfMxcsr);
4994 IEM_MC_REF_XREG_XMM_CONST(puSrc1, IEM_GET_MODRM_REG(pVCpu, bRm));
4995 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_ucomisd_u128, pfMxcsr, pEFlags, puSrc1, puSrc2);
4996 IEM_MC_IF_MXCSR_XCPT_PENDING() {
4997 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
4998 } IEM_MC_ELSE() {
4999 IEM_MC_COMMIT_EFLAGS(fEFlags);
5000 } IEM_MC_ENDIF();
5001
5002 IEM_MC_ADVANCE_RIP_AND_FINISH();
5003 IEM_MC_END();
5004 }
5005}
5006
5007
5008/* Opcode 0xf3 0x0f 0x2e - invalid */
5009/* Opcode 0xf2 0x0f 0x2e - invalid */
5010
5011
5012/** Opcode 0x0f 0x2f - comiss Vss, Wss */
5013FNIEMOP_DEF(iemOp_comiss_Vss_Wss)
5014{
5015 IEMOP_MNEMONIC2(RM, COMISS, comiss, Vss, Wss, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
5016 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
5017 if (IEM_IS_MODRM_REG_MODE(bRm))
5018 {
5019 /*
5020 * Register, register.
5021 */
5022 IEM_MC_BEGIN(4, 1, 0, 0);
5023 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
5024 IEM_MC_LOCAL(uint32_t, fEFlags);
5025 IEM_MC_ARG(uint32_t *, pfMxcsr, 0);
5026 IEM_MC_ARG_LOCAL_REF(uint32_t *, pEFlags, fEFlags, 1);
5027 IEM_MC_ARG(PCX86XMMREG, puSrc1, 2);
5028 IEM_MC_ARG(PCX86XMMREG, puSrc2, 3);
5029 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
5030 IEM_MC_PREPARE_SSE_USAGE();
5031 IEM_MC_FETCH_EFLAGS(fEFlags);
5032 IEM_MC_REF_MXCSR(pfMxcsr);
5033 IEM_MC_REF_XREG_XMM_CONST(puSrc1, IEM_GET_MODRM_REG(pVCpu, bRm));
5034 IEM_MC_REF_XREG_XMM_CONST(puSrc2, IEM_GET_MODRM_RM(pVCpu, bRm));
5035 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_comiss_u128, pfMxcsr, pEFlags, puSrc1, puSrc2);
5036 IEM_MC_IF_MXCSR_XCPT_PENDING() {
5037 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
5038 } IEM_MC_ELSE() {
5039 IEM_MC_COMMIT_EFLAGS(fEFlags);
5040 } IEM_MC_ENDIF();
5041
5042 IEM_MC_ADVANCE_RIP_AND_FINISH();
5043 IEM_MC_END();
5044 }
5045 else
5046 {
5047 /*
5048 * Register, memory.
5049 */
5050 IEM_MC_BEGIN(4, 3, 0, 0);
5051 IEM_MC_LOCAL(uint32_t, fEFlags);
5052 IEM_MC_ARG(uint32_t *, pfMxcsr, 0);
5053 IEM_MC_ARG_LOCAL_REF(uint32_t *, pEFlags, fEFlags, 1);
5054 IEM_MC_ARG(PCX86XMMREG, puSrc1, 2);
5055 IEM_MC_LOCAL(X86XMMREG, uSrc2);
5056 IEM_MC_ARG_LOCAL_REF(PCX86XMMREG, puSrc2, uSrc2, 3);
5057 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
5058
5059 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
5060 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
5061 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
5062 IEM_MC_FETCH_MEM_XMM_U32(uSrc2, 0 /*a_DWord*/, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
5063
5064 IEM_MC_PREPARE_SSE_USAGE();
5065 IEM_MC_FETCH_EFLAGS(fEFlags);
5066 IEM_MC_REF_MXCSR(pfMxcsr);
5067 IEM_MC_REF_XREG_XMM_CONST(puSrc1, IEM_GET_MODRM_REG(pVCpu, bRm));
5068 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_comiss_u128, pfMxcsr, pEFlags, puSrc1, puSrc2);
5069 IEM_MC_IF_MXCSR_XCPT_PENDING() {
5070 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
5071 } IEM_MC_ELSE() {
5072 IEM_MC_COMMIT_EFLAGS(fEFlags);
5073 } IEM_MC_ENDIF();
5074
5075 IEM_MC_ADVANCE_RIP_AND_FINISH();
5076 IEM_MC_END();
5077 }
5078}
5079
5080
5081/** Opcode 0x66 0x0f 0x2f - comisd Vsd, Wsd */
5082FNIEMOP_DEF(iemOp_comisd_Vsd_Wsd)
5083{
5084 IEMOP_MNEMONIC2(RM, COMISD, comisd, Vsd, Wsd, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
5085 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
5086 if (IEM_IS_MODRM_REG_MODE(bRm))
5087 {
5088 /*
5089 * Register, register.
5090 */
5091 IEM_MC_BEGIN(4, 1, 0, 0);
5092 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
5093 IEM_MC_LOCAL(uint32_t, fEFlags);
5094 IEM_MC_ARG(uint32_t *, pfMxcsr, 0);
5095 IEM_MC_ARG_LOCAL_REF(uint32_t *, pEFlags, fEFlags, 1);
5096 IEM_MC_ARG(PCX86XMMREG, puSrc1, 2);
5097 IEM_MC_ARG(PCX86XMMREG, puSrc2, 3);
5098 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
5099 IEM_MC_PREPARE_SSE_USAGE();
5100 IEM_MC_FETCH_EFLAGS(fEFlags);
5101 IEM_MC_REF_MXCSR(pfMxcsr);
5102 IEM_MC_REF_XREG_XMM_CONST(puSrc1, IEM_GET_MODRM_REG(pVCpu, bRm));
5103 IEM_MC_REF_XREG_XMM_CONST(puSrc2, IEM_GET_MODRM_RM(pVCpu, bRm));
5104 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_comisd_u128, pfMxcsr, pEFlags, puSrc1, puSrc2);
5105 IEM_MC_IF_MXCSR_XCPT_PENDING() {
5106 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
5107 } IEM_MC_ELSE() {
5108 IEM_MC_COMMIT_EFLAGS(fEFlags);
5109 } IEM_MC_ENDIF();
5110
5111 IEM_MC_ADVANCE_RIP_AND_FINISH();
5112 IEM_MC_END();
5113 }
5114 else
5115 {
5116 /*
5117 * Register, memory.
5118 */
5119 IEM_MC_BEGIN(4, 3, 0, 0);
5120 IEM_MC_LOCAL(uint32_t, fEFlags);
5121 IEM_MC_ARG(uint32_t *, pfMxcsr, 0);
5122 IEM_MC_ARG_LOCAL_REF(uint32_t *, pEFlags, fEFlags, 1);
5123 IEM_MC_ARG(PCX86XMMREG, puSrc1, 2);
5124 IEM_MC_LOCAL(X86XMMREG, uSrc2);
5125 IEM_MC_ARG_LOCAL_REF(PCX86XMMREG, puSrc2, uSrc2, 3);
5126 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
5127
5128 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
5129 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
5130 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
5131 IEM_MC_FETCH_MEM_XMM_U64(uSrc2, 0 /*a_QWord*/, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
5132
5133 IEM_MC_PREPARE_SSE_USAGE();
5134 IEM_MC_FETCH_EFLAGS(fEFlags);
5135 IEM_MC_REF_MXCSR(pfMxcsr);
5136 IEM_MC_REF_XREG_XMM_CONST(puSrc1, IEM_GET_MODRM_REG(pVCpu, bRm));
5137 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_comisd_u128, pfMxcsr, pEFlags, puSrc1, puSrc2);
5138 IEM_MC_IF_MXCSR_XCPT_PENDING() {
5139 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
5140 } IEM_MC_ELSE() {
5141 IEM_MC_COMMIT_EFLAGS(fEFlags);
5142 } IEM_MC_ENDIF();
5143
5144 IEM_MC_ADVANCE_RIP_AND_FINISH();
5145 IEM_MC_END();
5146 }
5147}
5148
5149
5150/* Opcode 0xf3 0x0f 0x2f - invalid */
5151/* Opcode 0xf2 0x0f 0x2f - invalid */
5152
5153/** Opcode 0x0f 0x30. */
5154FNIEMOP_DEF(iemOp_wrmsr)
5155{
5156 IEMOP_MNEMONIC(wrmsr, "wrmsr");
5157 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5158 IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_VMEXIT, 0, iemCImpl_wrmsr);
5159}
5160
5161
5162/** Opcode 0x0f 0x31. */
5163FNIEMOP_DEF(iemOp_rdtsc)
5164{
5165 IEMOP_MNEMONIC(rdtsc, "rdtsc");
5166 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5167 IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_VMEXIT,
5168 RT_BIT_64(kIemNativeGstReg_GprFirst + X86_GREG_xAX)
5169 | RT_BIT_64(kIemNativeGstReg_GprFirst + X86_GREG_xDX),
5170 iemCImpl_rdtsc);
5171}
5172
5173
5174/** Opcode 0x0f 0x33. */
5175FNIEMOP_DEF(iemOp_rdmsr)
5176{
5177 IEMOP_MNEMONIC(rdmsr, "rdmsr");
5178 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5179 IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_VMEXIT,
5180 RT_BIT_64(kIemNativeGstReg_GprFirst + X86_GREG_xAX)
5181 | RT_BIT_64(kIemNativeGstReg_GprFirst + X86_GREG_xDX),
5182 iemCImpl_rdmsr);
5183}
5184
5185
5186/** Opcode 0x0f 0x34. */
5187FNIEMOP_DEF(iemOp_rdpmc)
5188{
5189 IEMOP_MNEMONIC(rdpmc, "rdpmc");
5190 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5191 IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_VMEXIT,
5192 RT_BIT_64(kIemNativeGstReg_GprFirst + X86_GREG_xAX)
5193 | RT_BIT_64(kIemNativeGstReg_GprFirst + X86_GREG_xDX),
5194 iemCImpl_rdpmc);
5195}
5196
5197
5198/** Opcode 0x0f 0x34. */
5199FNIEMOP_DEF(iemOp_sysenter)
5200{
5201 IEMOP_MNEMONIC0(FIXED, SYSENTER, sysenter, DISOPTYPE_CONTROLFLOW | DISOPTYPE_UNCOND_CONTROLFLOW, 0);
5202 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5203 IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_BRANCH_INDIRECT | IEM_CIMPL_F_BRANCH_FAR | IEM_CIMPL_F_BRANCH_STACK_FAR
5204 | IEM_CIMPL_F_MODE | IEM_CIMPL_F_RFLAGS | IEM_CIMPL_F_VMEXIT | IEM_CIMPL_F_END_TB, 0,
5205 iemCImpl_sysenter);
5206}
5207
5208/** Opcode 0x0f 0x35. */
5209FNIEMOP_DEF(iemOp_sysexit)
5210{
5211 IEMOP_MNEMONIC0(FIXED, SYSEXIT, sysexit, DISOPTYPE_CONTROLFLOW | DISOPTYPE_UNCOND_CONTROLFLOW, 0);
5212 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5213 IEM_MC_DEFER_TO_CIMPL_1_RET(IEM_CIMPL_F_BRANCH_INDIRECT | IEM_CIMPL_F_BRANCH_FAR | IEM_CIMPL_F_BRANCH_STACK_FAR
5214 | IEM_CIMPL_F_MODE | IEM_CIMPL_F_RFLAGS | IEM_CIMPL_F_VMEXIT | IEM_CIMPL_F_END_TB, 0,
5215 iemCImpl_sysexit, pVCpu->iem.s.enmEffOpSize);
5216}
5217
5218/** Opcode 0x0f 0x37. */
5219FNIEMOP_STUB(iemOp_getsec);
5220
5221
5222/** Opcode 0x0f 0x38. */
5223FNIEMOP_DEF(iemOp_3byte_Esc_0f_38)
5224{
5225#ifdef IEM_WITH_THREE_0F_38
5226 uint8_t b; IEM_OPCODE_GET_NEXT_U8(&b);
5227 return FNIEMOP_CALL(g_apfnThreeByte0f38[(uintptr_t)b * 4 + pVCpu->iem.s.idxPrefix]);
5228#else
5229 IEMOP_BITCH_ABOUT_STUB();
5230 return VERR_IEM_INSTR_NOT_IMPLEMENTED;
5231#endif
5232}
5233
5234
5235/** Opcode 0x0f 0x3a. */
5236FNIEMOP_DEF(iemOp_3byte_Esc_0f_3a)
5237{
5238#ifdef IEM_WITH_THREE_0F_3A
5239 uint8_t b; IEM_OPCODE_GET_NEXT_U8(&b);
5240 return FNIEMOP_CALL(g_apfnThreeByte0f3a[(uintptr_t)b * 4 + pVCpu->iem.s.idxPrefix]);
5241#else
5242 IEMOP_BITCH_ABOUT_STUB();
5243 return VERR_IEM_INSTR_NOT_IMPLEMENTED;
5244#endif
5245}
5246
5247
5248/**
5249 * Implements a conditional move.
5250 *
5251 * Wish there was an obvious way to do this where we could share and reduce
5252 * code bloat.
5253 *
5254 * @param a_Cnd The conditional "microcode" operation.
5255 */
5256#define CMOV_X(a_Cnd) \
5257 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm); \
5258 if (IEM_IS_MODRM_REG_MODE(bRm)) \
5259 { \
5260 switch (pVCpu->iem.s.enmEffOpSize) \
5261 { \
5262 case IEMMODE_16BIT: \
5263 IEM_MC_BEGIN(0, 1, 0, 0); \
5264 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); \
5265 IEM_MC_LOCAL(uint16_t, u16Tmp); \
5266 a_Cnd { \
5267 IEM_MC_FETCH_GREG_U16(u16Tmp, IEM_GET_MODRM_RM(pVCpu, bRm)); \
5268 IEM_MC_STORE_GREG_U16(IEM_GET_MODRM_REG(pVCpu, bRm), u16Tmp); \
5269 } IEM_MC_ENDIF(); \
5270 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
5271 IEM_MC_END(); \
5272 break; \
5273 \
5274 case IEMMODE_32BIT: \
5275 IEM_MC_BEGIN(0, 1, IEM_MC_F_MIN_386, 0); \
5276 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); \
5277 IEM_MC_LOCAL(uint32_t, u32Tmp); \
5278 a_Cnd { \
5279 IEM_MC_FETCH_GREG_U32(u32Tmp, IEM_GET_MODRM_RM(pVCpu, bRm)); \
5280 IEM_MC_STORE_GREG_U32(IEM_GET_MODRM_REG(pVCpu, bRm), u32Tmp); \
5281 } IEM_MC_ELSE() { \
5282 IEM_MC_CLEAR_HIGH_GREG_U64(IEM_GET_MODRM_REG(pVCpu, bRm)); \
5283 } IEM_MC_ENDIF(); \
5284 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
5285 IEM_MC_END(); \
5286 break; \
5287 \
5288 case IEMMODE_64BIT: \
5289 IEM_MC_BEGIN(0, 1, IEM_MC_F_64BIT, 0); \
5290 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); \
5291 IEM_MC_LOCAL(uint64_t, u64Tmp); \
5292 a_Cnd { \
5293 IEM_MC_FETCH_GREG_U64(u64Tmp, IEM_GET_MODRM_RM(pVCpu, bRm)); \
5294 IEM_MC_STORE_GREG_U64(IEM_GET_MODRM_REG(pVCpu, bRm), u64Tmp); \
5295 } IEM_MC_ENDIF(); \
5296 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
5297 IEM_MC_END(); \
5298 break; \
5299 \
5300 IEM_NOT_REACHED_DEFAULT_CASE_RET(); \
5301 } \
5302 } \
5303 else \
5304 { \
5305 switch (pVCpu->iem.s.enmEffOpSize) \
5306 { \
5307 case IEMMODE_16BIT: \
5308 IEM_MC_BEGIN(0, 2, 0, 0); \
5309 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc); \
5310 IEM_MC_LOCAL(uint16_t, u16Tmp); \
5311 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0); \
5312 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); \
5313 IEM_MC_FETCH_MEM_U16(u16Tmp, pVCpu->iem.s.iEffSeg, GCPtrEffSrc); \
5314 a_Cnd { \
5315 IEM_MC_STORE_GREG_U16(IEM_GET_MODRM_REG(pVCpu, bRm), u16Tmp); \
5316 } IEM_MC_ENDIF(); \
5317 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
5318 IEM_MC_END(); \
5319 break; \
5320 \
5321 case IEMMODE_32BIT: \
5322 IEM_MC_BEGIN(0, 2, IEM_MC_F_MIN_386, 0); \
5323 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc); \
5324 IEM_MC_LOCAL(uint32_t, u32Tmp); \
5325 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0); \
5326 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); \
5327 IEM_MC_FETCH_MEM_U32(u32Tmp, pVCpu->iem.s.iEffSeg, GCPtrEffSrc); \
5328 a_Cnd { \
5329 IEM_MC_STORE_GREG_U32(IEM_GET_MODRM_REG(pVCpu, bRm), u32Tmp); \
5330 } IEM_MC_ELSE() { \
5331 IEM_MC_CLEAR_HIGH_GREG_U64(IEM_GET_MODRM_REG(pVCpu, bRm)); \
5332 } IEM_MC_ENDIF(); \
5333 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
5334 IEM_MC_END(); \
5335 break; \
5336 \
5337 case IEMMODE_64BIT: \
5338 IEM_MC_BEGIN(0, 2, IEM_MC_F_64BIT, 0); \
5339 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc); \
5340 IEM_MC_LOCAL(uint64_t, u64Tmp); \
5341 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0); \
5342 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); \
5343 IEM_MC_FETCH_MEM_U64(u64Tmp, pVCpu->iem.s.iEffSeg, GCPtrEffSrc); \
5344 a_Cnd { \
5345 IEM_MC_STORE_GREG_U64(IEM_GET_MODRM_REG(pVCpu, bRm), u64Tmp); \
5346 } IEM_MC_ENDIF(); \
5347 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
5348 IEM_MC_END(); \
5349 break; \
5350 \
5351 IEM_NOT_REACHED_DEFAULT_CASE_RET(); \
5352 } \
5353 } do {} while (0)
5354
5355
5356
5357/** Opcode 0x0f 0x40. */
5358FNIEMOP_DEF(iemOp_cmovo_Gv_Ev)
5359{
5360 IEMOP_MNEMONIC(cmovo_Gv_Ev, "cmovo Gv,Ev");
5361 CMOV_X(IEM_MC_IF_EFL_BIT_SET(X86_EFL_OF));
5362}
5363
5364
5365/** Opcode 0x0f 0x41. */
5366FNIEMOP_DEF(iemOp_cmovno_Gv_Ev)
5367{
5368 IEMOP_MNEMONIC(cmovno_Gv_Ev, "cmovno Gv,Ev");
5369 CMOV_X(IEM_MC_IF_EFL_BIT_NOT_SET(X86_EFL_OF));
5370}
5371
5372
5373/** Opcode 0x0f 0x42. */
5374FNIEMOP_DEF(iemOp_cmovc_Gv_Ev)
5375{
5376 IEMOP_MNEMONIC(cmovc_Gv_Ev, "cmovc Gv,Ev");
5377 CMOV_X(IEM_MC_IF_EFL_BIT_SET(X86_EFL_CF));
5378}
5379
5380
5381/** Opcode 0x0f 0x43. */
5382FNIEMOP_DEF(iemOp_cmovnc_Gv_Ev)
5383{
5384 IEMOP_MNEMONIC(cmovnc_Gv_Ev, "cmovnc Gv,Ev");
5385 CMOV_X(IEM_MC_IF_EFL_BIT_NOT_SET(X86_EFL_CF));
5386}
5387
5388
5389/** Opcode 0x0f 0x44. */
5390FNIEMOP_DEF(iemOp_cmove_Gv_Ev)
5391{
5392 IEMOP_MNEMONIC(cmove_Gv_Ev, "cmove Gv,Ev");
5393 CMOV_X(IEM_MC_IF_EFL_BIT_SET(X86_EFL_ZF));
5394}
5395
5396
5397/** Opcode 0x0f 0x45. */
5398FNIEMOP_DEF(iemOp_cmovne_Gv_Ev)
5399{
5400 IEMOP_MNEMONIC(cmovne_Gv_Ev, "cmovne Gv,Ev");
5401 CMOV_X(IEM_MC_IF_EFL_BIT_NOT_SET(X86_EFL_ZF));
5402}
5403
5404
5405/** Opcode 0x0f 0x46. */
5406FNIEMOP_DEF(iemOp_cmovbe_Gv_Ev)
5407{
5408 IEMOP_MNEMONIC(cmovbe_Gv_Ev, "cmovbe Gv,Ev");
5409 CMOV_X(IEM_MC_IF_EFL_ANY_BITS_SET(X86_EFL_CF | X86_EFL_ZF));
5410}
5411
5412
5413/** Opcode 0x0f 0x47. */
5414FNIEMOP_DEF(iemOp_cmovnbe_Gv_Ev)
5415{
5416 IEMOP_MNEMONIC(cmovnbe_Gv_Ev, "cmovnbe Gv,Ev");
5417 CMOV_X(IEM_MC_IF_EFL_NO_BITS_SET(X86_EFL_CF | X86_EFL_ZF));
5418}
5419
5420
5421/** Opcode 0x0f 0x48. */
5422FNIEMOP_DEF(iemOp_cmovs_Gv_Ev)
5423{
5424 IEMOP_MNEMONIC(cmovs_Gv_Ev, "cmovs Gv,Ev");
5425 CMOV_X(IEM_MC_IF_EFL_BIT_SET(X86_EFL_SF));
5426}
5427
5428
5429/** Opcode 0x0f 0x49. */
5430FNIEMOP_DEF(iemOp_cmovns_Gv_Ev)
5431{
5432 IEMOP_MNEMONIC(cmovns_Gv_Ev, "cmovns Gv,Ev");
5433 CMOV_X(IEM_MC_IF_EFL_BIT_NOT_SET(X86_EFL_SF));
5434}
5435
5436
5437/** Opcode 0x0f 0x4a. */
5438FNIEMOP_DEF(iemOp_cmovp_Gv_Ev)
5439{
5440 IEMOP_MNEMONIC(cmovp_Gv_Ev, "cmovp Gv,Ev");
5441 CMOV_X(IEM_MC_IF_EFL_BIT_SET(X86_EFL_PF));
5442}
5443
5444
5445/** Opcode 0x0f 0x4b. */
5446FNIEMOP_DEF(iemOp_cmovnp_Gv_Ev)
5447{
5448 IEMOP_MNEMONIC(cmovnp_Gv_Ev, "cmovnp Gv,Ev");
5449 CMOV_X(IEM_MC_IF_EFL_BIT_NOT_SET(X86_EFL_PF));
5450}
5451
5452
5453/** Opcode 0x0f 0x4c. */
5454FNIEMOP_DEF(iemOp_cmovl_Gv_Ev)
5455{
5456 IEMOP_MNEMONIC(cmovl_Gv_Ev, "cmovl Gv,Ev");
5457 CMOV_X(IEM_MC_IF_EFL_BITS_NE(X86_EFL_SF, X86_EFL_OF));
5458}
5459
5460
5461/** Opcode 0x0f 0x4d. */
5462FNIEMOP_DEF(iemOp_cmovnl_Gv_Ev)
5463{
5464 IEMOP_MNEMONIC(cmovnl_Gv_Ev, "cmovnl Gv,Ev");
5465 CMOV_X(IEM_MC_IF_EFL_BITS_EQ(X86_EFL_SF, X86_EFL_OF));
5466}
5467
5468
5469/** Opcode 0x0f 0x4e. */
5470FNIEMOP_DEF(iemOp_cmovle_Gv_Ev)
5471{
5472 IEMOP_MNEMONIC(cmovle_Gv_Ev, "cmovle Gv,Ev");
5473 CMOV_X(IEM_MC_IF_EFL_BIT_SET_OR_BITS_NE(X86_EFL_ZF, X86_EFL_SF, X86_EFL_OF));
5474}
5475
5476
5477/** Opcode 0x0f 0x4f. */
5478FNIEMOP_DEF(iemOp_cmovnle_Gv_Ev)
5479{
5480 IEMOP_MNEMONIC(cmovnle_Gv_Ev, "cmovnle Gv,Ev");
5481 CMOV_X(IEM_MC_IF_EFL_BIT_NOT_SET_AND_BITS_EQ(X86_EFL_ZF, X86_EFL_SF, X86_EFL_OF));
5482}
5483
5484#undef CMOV_X
5485
5486/** Opcode 0x0f 0x50 - movmskps Gy, Ups */
5487FNIEMOP_DEF(iemOp_movmskps_Gy_Ups)
5488{
5489 IEMOP_MNEMONIC2(RM_REG, MOVMSKPS, movmskps, Gy, Ux, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0); /** @todo */
5490 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
5491 if (IEM_IS_MODRM_REG_MODE(bRm))
5492 {
5493 /*
5494 * Register, register.
5495 */
5496 IEM_MC_BEGIN(2, 1, 0, 0);
5497 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
5498 IEM_MC_LOCAL(uint8_t, u8Dst);
5499 IEM_MC_ARG_LOCAL_REF(uint8_t *, pu8Dst, u8Dst, 0);
5500 IEM_MC_ARG(PCRTUINT128U, puSrc, 1);
5501 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
5502 IEM_MC_PREPARE_SSE_USAGE();
5503 IEM_MC_REF_XREG_U128_CONST(puSrc, IEM_GET_MODRM_RM(pVCpu, bRm));
5504 IEM_MC_CALL_VOID_AIMPL_2(iemAImpl_movmskps_u128, pu8Dst, puSrc);
5505 IEM_MC_STORE_GREG_U32(IEM_GET_MODRM_REG(pVCpu, bRm), u8Dst);
5506 IEM_MC_ADVANCE_RIP_AND_FINISH();
5507 IEM_MC_END();
5508 }
5509 /* No memory operand. */
5510 else
5511 IEMOP_RAISE_INVALID_OPCODE_RET();
5512}
5513
5514
5515/** Opcode 0x66 0x0f 0x50 - movmskpd Gy, Upd */
5516FNIEMOP_DEF(iemOp_movmskpd_Gy_Upd)
5517{
5518 IEMOP_MNEMONIC2(RM_REG, MOVMSKPD, movmskpd, Gy, Ux, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0); /** @todo */
5519 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
5520 if (IEM_IS_MODRM_REG_MODE(bRm))
5521 {
5522 /*
5523 * Register, register.
5524 */
5525 IEM_MC_BEGIN(2, 1, 0, 0);
5526 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
5527 IEM_MC_LOCAL(uint8_t, u8Dst);
5528 IEM_MC_ARG_LOCAL_REF(uint8_t *, pu8Dst, u8Dst, 0);
5529 IEM_MC_ARG(PCRTUINT128U, puSrc, 1);
5530 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
5531 IEM_MC_PREPARE_SSE_USAGE();
5532 IEM_MC_REF_XREG_U128_CONST(puSrc, IEM_GET_MODRM_RM(pVCpu, bRm));
5533 IEM_MC_CALL_VOID_AIMPL_2(iemAImpl_movmskpd_u128, pu8Dst, puSrc);
5534 IEM_MC_STORE_GREG_U32(IEM_GET_MODRM_REG_8(bRm), u8Dst);
5535 IEM_MC_ADVANCE_RIP_AND_FINISH();
5536 IEM_MC_END();
5537 }
5538 /* No memory operand. */
5539 else
5540 IEMOP_RAISE_INVALID_OPCODE_RET();
5541
5542}
5543
5544
5545/* Opcode 0xf3 0x0f 0x50 - invalid */
5546/* Opcode 0xf2 0x0f 0x50 - invalid */
5547
5548
5549/** Opcode 0x0f 0x51 - sqrtps Vps, Wps */
5550FNIEMOP_DEF(iemOp_sqrtps_Vps_Wps)
5551{
5552 IEMOP_MNEMONIC2(RM, SQRTPS, sqrtps, Vps, Wps, DISOPTYPE_HARMLESS, 0);
5553 return FNIEMOP_CALL_1(iemOpCommonSseFp_FullFull_To_Full, iemAImpl_sqrtps_u128);
5554}
5555
5556
5557/** Opcode 0x66 0x0f 0x51 - sqrtpd Vpd, Wpd */
5558FNIEMOP_DEF(iemOp_sqrtpd_Vpd_Wpd)
5559{
5560 IEMOP_MNEMONIC2(RM, SQRTPD, sqrtpd, Vpd, Wpd, DISOPTYPE_HARMLESS, 0);
5561 return FNIEMOP_CALL_1(iemOpCommonSse2Fp_FullFull_To_Full, iemAImpl_sqrtpd_u128);
5562}
5563
5564
5565/** Opcode 0xf3 0x0f 0x51 - sqrtss Vss, Wss */
5566FNIEMOP_DEF(iemOp_sqrtss_Vss_Wss)
5567{
5568 IEMOP_MNEMONIC2(RM, SQRTSS, sqrtss, Vss, Wss, DISOPTYPE_HARMLESS, 0);
5569 return FNIEMOP_CALL_1(iemOpCommonSseFp_FullR32_To_Full, iemAImpl_sqrtss_u128_r32);
5570}
5571
5572
5573/** Opcode 0xf2 0x0f 0x51 - sqrtsd Vsd, Wsd */
5574FNIEMOP_DEF(iemOp_sqrtsd_Vsd_Wsd)
5575{
5576 IEMOP_MNEMONIC2(RM, SQRTSD, sqrtsd, Vsd, Wsd, DISOPTYPE_HARMLESS, 0);
5577 return FNIEMOP_CALL_1(iemOpCommonSse2Fp_FullR64_To_Full, iemAImpl_sqrtsd_u128_r64);
5578}
5579
5580
5581/** Opcode 0x0f 0x52 - rsqrtps Vps, Wps */
5582FNIEMOP_DEF(iemOp_rsqrtps_Vps_Wps)
5583{
5584 IEMOP_MNEMONIC2(RM, RSQRTPS, rsqrtps, Vps, Wps, DISOPTYPE_HARMLESS, 0);
5585 return FNIEMOP_CALL_1(iemOpCommonSseFp_FullFull_To_Full, iemAImpl_rsqrtps_u128);
5586}
5587
5588
5589/* Opcode 0x66 0x0f 0x52 - invalid */
5590
5591
5592/** Opcode 0xf3 0x0f 0x52 - rsqrtss Vss, Wss */
5593FNIEMOP_DEF(iemOp_rsqrtss_Vss_Wss)
5594{
5595 IEMOP_MNEMONIC2(RM, RSQRTSS, rsqrtss, Vss, Wss, DISOPTYPE_HARMLESS, 0);
5596 return FNIEMOP_CALL_1(iemOpCommonSseFp_FullR32_To_Full, iemAImpl_rsqrtss_u128_r32);
5597}
5598
5599
5600/* Opcode 0xf2 0x0f 0x52 - invalid */
5601
5602/** Opcode 0x0f 0x53 - rcpps Vps, Wps */
5603FNIEMOP_STUB(iemOp_rcpps_Vps_Wps);
5604/* Opcode 0x66 0x0f 0x53 - invalid */
5605/** Opcode 0xf3 0x0f 0x53 - rcpss Vss, Wss */
5606FNIEMOP_STUB(iemOp_rcpss_Vss_Wss);
5607/* Opcode 0xf2 0x0f 0x53 - invalid */
5608
5609
5610/** Opcode 0x0f 0x54 - andps Vps, Wps */
5611FNIEMOP_DEF(iemOp_andps_Vps_Wps)
5612{
5613 IEMOP_MNEMONIC2(RM, ANDPS, andps, Vps, Wps, DISOPTYPE_HARMLESS, 0);
5614 return FNIEMOP_CALL_1(iemOpCommonSse_FullFull_To_Full, iemAImpl_pand_u128);
5615}
5616
5617
5618/** Opcode 0x66 0x0f 0x54 - andpd Vpd, Wpd */
5619FNIEMOP_DEF(iemOp_andpd_Vpd_Wpd)
5620{
5621 IEMOP_MNEMONIC2(RM, ANDPD, andpd, Vpd, Wpd, DISOPTYPE_HARMLESS, 0);
5622 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_pand_u128);
5623}
5624
5625
5626/* Opcode 0xf3 0x0f 0x54 - invalid */
5627/* Opcode 0xf2 0x0f 0x54 - invalid */
5628
5629
5630/** Opcode 0x0f 0x55 - andnps Vps, Wps */
5631FNIEMOP_DEF(iemOp_andnps_Vps_Wps)
5632{
5633 IEMOP_MNEMONIC2(RM, ANDNPS, andnps, Vps, Wps, DISOPTYPE_HARMLESS, 0);
5634 return FNIEMOP_CALL_1(iemOpCommonSse_FullFull_To_Full, iemAImpl_pandn_u128);
5635}
5636
5637
5638/** Opcode 0x66 0x0f 0x55 - andnpd Vpd, Wpd */
5639FNIEMOP_DEF(iemOp_andnpd_Vpd_Wpd)
5640{
5641 IEMOP_MNEMONIC2(RM, ANDNPD, andnpd, Vpd, Wpd, DISOPTYPE_HARMLESS, 0);
5642 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_pandn_u128);
5643}
5644
5645
5646/* Opcode 0xf3 0x0f 0x55 - invalid */
5647/* Opcode 0xf2 0x0f 0x55 - invalid */
5648
5649
5650/** Opcode 0x0f 0x56 - orps Vps, Wps */
5651FNIEMOP_DEF(iemOp_orps_Vps_Wps)
5652{
5653 IEMOP_MNEMONIC2(RM, ORPS, orps, Vps, Wps, DISOPTYPE_HARMLESS, 0);
5654 return FNIEMOP_CALL_1(iemOpCommonSse_FullFull_To_Full, iemAImpl_por_u128);
5655}
5656
5657
5658/** Opcode 0x66 0x0f 0x56 - orpd Vpd, Wpd */
5659FNIEMOP_DEF(iemOp_orpd_Vpd_Wpd)
5660{
5661 IEMOP_MNEMONIC2(RM, ORPD, orpd, Vpd, Wpd, DISOPTYPE_HARMLESS, 0);
5662 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_por_u128);
5663}
5664
5665
5666/* Opcode 0xf3 0x0f 0x56 - invalid */
5667/* Opcode 0xf2 0x0f 0x56 - invalid */
5668
5669
5670/** Opcode 0x0f 0x57 - xorps Vps, Wps */
5671FNIEMOP_DEF(iemOp_xorps_Vps_Wps)
5672{
5673 IEMOP_MNEMONIC2(RM, XORPS, xorps, Vps, Wps, DISOPTYPE_HARMLESS, 0);
5674 return FNIEMOP_CALL_1(iemOpCommonSse_FullFull_To_Full, iemAImpl_pxor_u128);
5675}
5676
5677
5678/** Opcode 0x66 0x0f 0x57 - xorpd Vpd, Wpd */
5679FNIEMOP_DEF(iemOp_xorpd_Vpd_Wpd)
5680{
5681 IEMOP_MNEMONIC2(RM, XORPD, xorpd, Vpd, Wpd, DISOPTYPE_HARMLESS, 0);
5682 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_pxor_u128);
5683}
5684
5685
5686/* Opcode 0xf3 0x0f 0x57 - invalid */
5687/* Opcode 0xf2 0x0f 0x57 - invalid */
5688
5689/** Opcode 0x0f 0x58 - addps Vps, Wps */
5690FNIEMOP_DEF(iemOp_addps_Vps_Wps)
5691{
5692 IEMOP_MNEMONIC2(RM, ADDPS, addps, Vps, Wps, DISOPTYPE_HARMLESS, 0);
5693 return FNIEMOP_CALL_1(iemOpCommonSseFp_FullFull_To_Full, iemAImpl_addps_u128);
5694}
5695
5696
5697/** Opcode 0x66 0x0f 0x58 - addpd Vpd, Wpd */
5698FNIEMOP_DEF(iemOp_addpd_Vpd_Wpd)
5699{
5700 IEMOP_MNEMONIC2(RM, ADDPD, addpd, Vpd, Wpd, DISOPTYPE_HARMLESS, 0);
5701 return FNIEMOP_CALL_1(iemOpCommonSse2Fp_FullFull_To_Full, iemAImpl_addpd_u128);
5702}
5703
5704
5705/** Opcode 0xf3 0x0f 0x58 - addss Vss, Wss */
5706FNIEMOP_DEF(iemOp_addss_Vss_Wss)
5707{
5708 IEMOP_MNEMONIC2(RM, ADDSS, addss, Vss, Wss, DISOPTYPE_HARMLESS, 0);
5709 return FNIEMOP_CALL_1(iemOpCommonSseFp_FullR32_To_Full, iemAImpl_addss_u128_r32);
5710}
5711
5712
5713/** Opcode 0xf2 0x0f 0x58 - addsd Vsd, Wsd */
5714FNIEMOP_DEF(iemOp_addsd_Vsd_Wsd)
5715{
5716 IEMOP_MNEMONIC2(RM, ADDSD, addsd, Vsd, Wsd, DISOPTYPE_HARMLESS, 0);
5717 return FNIEMOP_CALL_1(iemOpCommonSse2Fp_FullR64_To_Full, iemAImpl_addsd_u128_r64);
5718}
5719
5720
5721/** Opcode 0x0f 0x59 - mulps Vps, Wps */
5722FNIEMOP_DEF(iemOp_mulps_Vps_Wps)
5723{
5724 IEMOP_MNEMONIC2(RM, MULPS, mulps, Vps, Wps, DISOPTYPE_HARMLESS, 0);
5725 return FNIEMOP_CALL_1(iemOpCommonSseFp_FullFull_To_Full, iemAImpl_mulps_u128);
5726}
5727
5728
5729/** Opcode 0x66 0x0f 0x59 - mulpd Vpd, Wpd */
5730FNIEMOP_DEF(iemOp_mulpd_Vpd_Wpd)
5731{
5732 IEMOP_MNEMONIC2(RM, MULPD, mulpd, Vpd, Wpd, DISOPTYPE_HARMLESS, 0);
5733 return FNIEMOP_CALL_1(iemOpCommonSse2Fp_FullFull_To_Full, iemAImpl_mulpd_u128);
5734}
5735
5736
5737/** Opcode 0xf3 0x0f 0x59 - mulss Vss, Wss */
5738FNIEMOP_DEF(iemOp_mulss_Vss_Wss)
5739{
5740 IEMOP_MNEMONIC2(RM, MULSS, mulss, Vss, Wss, DISOPTYPE_HARMLESS, 0);
5741 return FNIEMOP_CALL_1(iemOpCommonSseFp_FullR32_To_Full, iemAImpl_mulss_u128_r32);
5742}
5743
5744
5745/** Opcode 0xf2 0x0f 0x59 - mulsd Vsd, Wsd */
5746FNIEMOP_DEF(iemOp_mulsd_Vsd_Wsd)
5747{
5748 IEMOP_MNEMONIC2(RM, MULSD, mulsd, Vsd, Wsd, DISOPTYPE_HARMLESS, 0);
5749 return FNIEMOP_CALL_1(iemOpCommonSse2Fp_FullR64_To_Full, iemAImpl_mulsd_u128_r64);
5750}
5751
5752
5753/** Opcode 0x0f 0x5a - cvtps2pd Vpd, Wps */
5754FNIEMOP_DEF(iemOp_cvtps2pd_Vpd_Wps)
5755{
5756 IEMOP_MNEMONIC2(RM, CVTPS2PD, cvtps2pd, Vpd, Wps, DISOPTYPE_HARMLESS, 0);
5757 return FNIEMOP_CALL_1(iemOpCommonSse2Fp_FullFull_To_Full, iemAImpl_cvtps2pd_u128);
5758}
5759
5760
5761/** Opcode 0x66 0x0f 0x5a - cvtpd2ps Vps, Wpd */
5762FNIEMOP_DEF(iemOp_cvtpd2ps_Vps_Wpd)
5763{
5764 IEMOP_MNEMONIC2(RM, CVTPD2PS, cvtpd2ps, Vps, Wpd, DISOPTYPE_HARMLESS, 0);
5765 return FNIEMOP_CALL_1(iemOpCommonSse2Fp_FullFull_To_Full, iemAImpl_cvtpd2ps_u128);
5766}
5767
5768
5769/** Opcode 0xf3 0x0f 0x5a - cvtss2sd Vsd, Wss */
5770FNIEMOP_DEF(iemOp_cvtss2sd_Vsd_Wss)
5771{
5772 IEMOP_MNEMONIC2(RM, CVTSS2SD, cvtss2sd, Vsd, Wss, DISOPTYPE_HARMLESS, 0);
5773 return FNIEMOP_CALL_1(iemOpCommonSseFp_FullR32_To_Full, iemAImpl_cvtss2sd_u128_r32);
5774}
5775
5776
5777/** Opcode 0xf2 0x0f 0x5a - cvtsd2ss Vss, Wsd */
5778FNIEMOP_DEF(iemOp_cvtsd2ss_Vss_Wsd)
5779{
5780 IEMOP_MNEMONIC2(RM, CVTSD2SS, cvtsd2ss, Vss, Wsd, DISOPTYPE_HARMLESS, 0);
5781 return FNIEMOP_CALL_1(iemOpCommonSse2Fp_FullR64_To_Full, iemAImpl_cvtsd2ss_u128_r64);
5782}
5783
5784
5785/** Opcode 0x0f 0x5b - cvtdq2ps Vps, Wdq */
5786FNIEMOP_DEF(iemOp_cvtdq2ps_Vps_Wdq)
5787{
5788 IEMOP_MNEMONIC2(RM, CVTDQ2PS, cvtdq2ps, Vps, Wdq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
5789 return FNIEMOP_CALL_1(iemOpCommonSse2Fp_FullFull_To_Full, iemAImpl_cvtdq2ps_u128);
5790}
5791
5792
5793/** Opcode 0x66 0x0f 0x5b - cvtps2dq Vdq, Wps */
5794FNIEMOP_DEF(iemOp_cvtps2dq_Vdq_Wps)
5795{
5796 IEMOP_MNEMONIC2(RM, CVTPS2DQ, cvtps2dq, Vdq, Wps, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
5797 return FNIEMOP_CALL_1(iemOpCommonSse2Fp_FullFull_To_Full, iemAImpl_cvtps2dq_u128);
5798}
5799
5800
5801/** Opcode 0xf3 0x0f 0x5b - cvttps2dq Vdq, Wps */
5802FNIEMOP_DEF(iemOp_cvttps2dq_Vdq_Wps)
5803{
5804 IEMOP_MNEMONIC2(RM, CVTTPS2DQ, cvttps2dq, Vdq, Wps, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
5805 return FNIEMOP_CALL_1(iemOpCommonSse2Fp_FullFull_To_Full, iemAImpl_cvttps2dq_u128);
5806}
5807
5808
5809/* Opcode 0xf2 0x0f 0x5b - invalid */
5810
5811
5812/** Opcode 0x0f 0x5c - subps Vps, Wps */
5813FNIEMOP_DEF(iemOp_subps_Vps_Wps)
5814{
5815 IEMOP_MNEMONIC2(RM, SUBPS, subps, Vps, Wps, DISOPTYPE_HARMLESS, 0);
5816 return FNIEMOP_CALL_1(iemOpCommonSseFp_FullFull_To_Full, iemAImpl_subps_u128);
5817}
5818
5819
5820/** Opcode 0x66 0x0f 0x5c - subpd Vpd, Wpd */
5821FNIEMOP_DEF(iemOp_subpd_Vpd_Wpd)
5822{
5823 IEMOP_MNEMONIC2(RM, SUBPD, subpd, Vpd, Wpd, DISOPTYPE_HARMLESS, 0);
5824 return FNIEMOP_CALL_1(iemOpCommonSse2Fp_FullFull_To_Full, iemAImpl_subpd_u128);
5825}
5826
5827
5828/** Opcode 0xf3 0x0f 0x5c - subss Vss, Wss */
5829FNIEMOP_DEF(iemOp_subss_Vss_Wss)
5830{
5831 IEMOP_MNEMONIC2(RM, SUBSS, subss, Vss, Wss, DISOPTYPE_HARMLESS, 0);
5832 return FNIEMOP_CALL_1(iemOpCommonSseFp_FullR32_To_Full, iemAImpl_subss_u128_r32);
5833}
5834
5835
5836/** Opcode 0xf2 0x0f 0x5c - subsd Vsd, Wsd */
5837FNIEMOP_DEF(iemOp_subsd_Vsd_Wsd)
5838{
5839 IEMOP_MNEMONIC2(RM, SUBSD, subsd, Vsd, Wsd, DISOPTYPE_HARMLESS, 0);
5840 return FNIEMOP_CALL_1(iemOpCommonSse2Fp_FullR64_To_Full, iemAImpl_subsd_u128_r64);
5841}
5842
5843
5844/** Opcode 0x0f 0x5d - minps Vps, Wps */
5845FNIEMOP_DEF(iemOp_minps_Vps_Wps)
5846{
5847 IEMOP_MNEMONIC2(RM, MINPS, minps, Vps, Wps, DISOPTYPE_HARMLESS, 0);
5848 return FNIEMOP_CALL_1(iemOpCommonSseFp_FullFull_To_Full, iemAImpl_minps_u128);
5849}
5850
5851
5852/** Opcode 0x66 0x0f 0x5d - minpd Vpd, Wpd */
5853FNIEMOP_DEF(iemOp_minpd_Vpd_Wpd)
5854{
5855 IEMOP_MNEMONIC2(RM, MINPD, minpd, Vpd, Wpd, DISOPTYPE_HARMLESS, 0);
5856 return FNIEMOP_CALL_1(iemOpCommonSse2Fp_FullFull_To_Full, iemAImpl_minpd_u128);
5857}
5858
5859
5860/** Opcode 0xf3 0x0f 0x5d - minss Vss, Wss */
5861FNIEMOP_DEF(iemOp_minss_Vss_Wss)
5862{
5863 IEMOP_MNEMONIC2(RM, MINSS, minss, Vss, Wss, DISOPTYPE_HARMLESS, 0);
5864 return FNIEMOP_CALL_1(iemOpCommonSseFp_FullR32_To_Full, iemAImpl_minss_u128_r32);
5865}
5866
5867
5868/** Opcode 0xf2 0x0f 0x5d - minsd Vsd, Wsd */
5869FNIEMOP_DEF(iemOp_minsd_Vsd_Wsd)
5870{
5871 IEMOP_MNEMONIC2(RM, MINSD, minsd, Vsd, Wsd, DISOPTYPE_HARMLESS, 0);
5872 return FNIEMOP_CALL_1(iemOpCommonSse2Fp_FullR64_To_Full, iemAImpl_minsd_u128_r64);
5873}
5874
5875
5876/** Opcode 0x0f 0x5e - divps Vps, Wps */
5877FNIEMOP_DEF(iemOp_divps_Vps_Wps)
5878{
5879 IEMOP_MNEMONIC2(RM, DIVPS, divps, Vps, Wps, DISOPTYPE_HARMLESS, 0);
5880 return FNIEMOP_CALL_1(iemOpCommonSseFp_FullFull_To_Full, iemAImpl_divps_u128);
5881}
5882
5883
5884/** Opcode 0x66 0x0f 0x5e - divpd Vpd, Wpd */
5885FNIEMOP_DEF(iemOp_divpd_Vpd_Wpd)
5886{
5887 IEMOP_MNEMONIC2(RM, DIVPD, divpd, Vpd, Wpd, DISOPTYPE_HARMLESS, 0);
5888 return FNIEMOP_CALL_1(iemOpCommonSse2Fp_FullFull_To_Full, iemAImpl_divpd_u128);
5889}
5890
5891
5892/** Opcode 0xf3 0x0f 0x5e - divss Vss, Wss */
5893FNIEMOP_DEF(iemOp_divss_Vss_Wss)
5894{
5895 IEMOP_MNEMONIC2(RM, DIVSS, divss, Vss, Wss, DISOPTYPE_HARMLESS, 0);
5896 return FNIEMOP_CALL_1(iemOpCommonSseFp_FullR32_To_Full, iemAImpl_divss_u128_r32);
5897}
5898
5899
5900/** Opcode 0xf2 0x0f 0x5e - divsd Vsd, Wsd */
5901FNIEMOP_DEF(iemOp_divsd_Vsd_Wsd)
5902{
5903 IEMOP_MNEMONIC2(RM, DIVSD, divsd, Vsd, Wsd, DISOPTYPE_HARMLESS, 0);
5904 return FNIEMOP_CALL_1(iemOpCommonSse2Fp_FullR64_To_Full, iemAImpl_divsd_u128_r64);
5905}
5906
5907
5908/** Opcode 0x0f 0x5f - maxps Vps, Wps */
5909FNIEMOP_DEF(iemOp_maxps_Vps_Wps)
5910{
5911 IEMOP_MNEMONIC2(RM, MAXPS, maxps, Vps, Wps, DISOPTYPE_HARMLESS, 0);
5912 return FNIEMOP_CALL_1(iemOpCommonSseFp_FullFull_To_Full, iemAImpl_maxps_u128);
5913}
5914
5915
5916/** Opcode 0x66 0x0f 0x5f - maxpd Vpd, Wpd */
5917FNIEMOP_DEF(iemOp_maxpd_Vpd_Wpd)
5918{
5919 IEMOP_MNEMONIC2(RM, MAXPD, maxpd, Vpd, Wpd, DISOPTYPE_HARMLESS, 0);
5920 return FNIEMOP_CALL_1(iemOpCommonSse2Fp_FullFull_To_Full, iemAImpl_maxpd_u128);
5921}
5922
5923
5924/** Opcode 0xf3 0x0f 0x5f - maxss Vss, Wss */
5925FNIEMOP_DEF(iemOp_maxss_Vss_Wss)
5926{
5927 IEMOP_MNEMONIC2(RM, MAXSS, maxss, Vss, Wss, DISOPTYPE_HARMLESS, 0);
5928 return FNIEMOP_CALL_1(iemOpCommonSseFp_FullR32_To_Full, iemAImpl_maxss_u128_r32);
5929}
5930
5931
5932/** Opcode 0xf2 0x0f 0x5f - maxsd Vsd, Wsd */
5933FNIEMOP_DEF(iemOp_maxsd_Vsd_Wsd)
5934{
5935 IEMOP_MNEMONIC2(RM, MAXSD, maxsd, Vsd, Wsd, DISOPTYPE_HARMLESS, 0);
5936 return FNIEMOP_CALL_1(iemOpCommonSse2Fp_FullR64_To_Full, iemAImpl_maxsd_u128_r64);
5937}
5938
5939
5940/** Opcode 0x0f 0x60 - punpcklbw Pq, Qd */
5941FNIEMOP_DEF(iemOp_punpcklbw_Pq_Qd)
5942{
5943 IEMOP_MNEMONIC2(RM, PUNPCKLBW, punpcklbw, Pq, Qd, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, 0);
5944 return FNIEMOP_CALL_1(iemOpCommonMmx_LowLow_To_Full, iemAImpl_punpcklbw_u64);
5945}
5946
5947
5948/** Opcode 0x66 0x0f 0x60 - punpcklbw Vx, W */
5949FNIEMOP_DEF(iemOp_punpcklbw_Vx_Wx)
5950{
5951 IEMOP_MNEMONIC2(RM, PUNPCKLBW, punpcklbw, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
5952 return FNIEMOP_CALL_1(iemOpCommonSse2_LowLow_To_Full, iemAImpl_punpcklbw_u128);
5953}
5954
5955
5956/* Opcode 0xf3 0x0f 0x60 - invalid */
5957
5958
5959/** Opcode 0x0f 0x61 - punpcklwd Pq, Qd */
5960FNIEMOP_DEF(iemOp_punpcklwd_Pq_Qd)
5961{
5962 /** @todo AMD mark the MMX version as 3DNow!. Intel says MMX CPUID req. */
5963 IEMOP_MNEMONIC2(RM, PUNPCKLWD, punpcklwd, Pq, Qd, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, 0);
5964 return FNIEMOP_CALL_1(iemOpCommonMmx_LowLow_To_Full, iemAImpl_punpcklwd_u64);
5965}
5966
5967
5968/** Opcode 0x66 0x0f 0x61 - punpcklwd Vx, Wx */
5969FNIEMOP_DEF(iemOp_punpcklwd_Vx_Wx)
5970{
5971 IEMOP_MNEMONIC2(RM, PUNPCKLWD, punpcklwd, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
5972 return FNIEMOP_CALL_1(iemOpCommonSse2_LowLow_To_Full, iemAImpl_punpcklwd_u128);
5973}
5974
5975
5976/* Opcode 0xf3 0x0f 0x61 - invalid */
5977
5978
5979/** Opcode 0x0f 0x62 - punpckldq Pq, Qd */
5980FNIEMOP_DEF(iemOp_punpckldq_Pq_Qd)
5981{
5982 IEMOP_MNEMONIC2(RM, PUNPCKLDQ, punpckldq, Pq, Qd, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, 0);
5983 return FNIEMOP_CALL_1(iemOpCommonMmx_LowLow_To_Full, iemAImpl_punpckldq_u64);
5984}
5985
5986
5987/** Opcode 0x66 0x0f 0x62 - punpckldq Vx, Wx */
5988FNIEMOP_DEF(iemOp_punpckldq_Vx_Wx)
5989{
5990 IEMOP_MNEMONIC2(RM, PUNPCKLDQ, punpckldq, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
5991 return FNIEMOP_CALL_1(iemOpCommonSse2_LowLow_To_Full, iemAImpl_punpckldq_u128);
5992}
5993
5994
5995/* Opcode 0xf3 0x0f 0x62 - invalid */
5996
5997
5998
5999/** Opcode 0x0f 0x63 - packsswb Pq, Qq */
6000FNIEMOP_DEF(iemOp_packsswb_Pq_Qq)
6001{
6002 IEMOP_MNEMONIC2(RM, PACKSSWB, packsswb, Pq, Qd, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, 0);
6003 return FNIEMOP_CALL_1(iemOpCommonMmxOpt_FullFull_To_Full, iemAImpl_packsswb_u64);
6004}
6005
6006
6007/** Opcode 0x66 0x0f 0x63 - packsswb Vx, Wx */
6008FNIEMOP_DEF(iemOp_packsswb_Vx_Wx)
6009{
6010 IEMOP_MNEMONIC2(RM, PACKSSWB, packsswb, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
6011 return FNIEMOP_CALL_1(iemOpCommonSse2Opt_FullFull_To_Full, iemAImpl_packsswb_u128);
6012}
6013
6014
6015/* Opcode 0xf3 0x0f 0x63 - invalid */
6016
6017
6018/** Opcode 0x0f 0x64 - pcmpgtb Pq, Qq */
6019FNIEMOP_DEF(iemOp_pcmpgtb_Pq_Qq)
6020{
6021 IEMOP_MNEMONIC2(RM, PCMPGTB, pcmpgtb, Pq, Qq, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
6022 return FNIEMOP_CALL_1(iemOpCommonMmx_FullFull_To_Full, iemAImpl_pcmpgtb_u64);
6023}
6024
6025
6026/** Opcode 0x66 0x0f 0x64 - pcmpgtb Vx, Wx */
6027FNIEMOP_DEF(iemOp_pcmpgtb_Vx_Wx)
6028{
6029 IEMOP_MNEMONIC2(RM, PCMPGTB, pcmpgtb, Vx, Wx, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
6030 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_pcmpgtb_u128);
6031}
6032
6033
6034/* Opcode 0xf3 0x0f 0x64 - invalid */
6035
6036
6037/** Opcode 0x0f 0x65 - pcmpgtw Pq, Qq */
6038FNIEMOP_DEF(iemOp_pcmpgtw_Pq_Qq)
6039{
6040 IEMOP_MNEMONIC2(RM, PCMPGTW, pcmpgtw, Pq, Qq, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
6041 return FNIEMOP_CALL_1(iemOpCommonMmx_FullFull_To_Full, iemAImpl_pcmpgtw_u64);
6042}
6043
6044
6045/** Opcode 0x66 0x0f 0x65 - pcmpgtw Vx, Wx */
6046FNIEMOP_DEF(iemOp_pcmpgtw_Vx_Wx)
6047{
6048 IEMOP_MNEMONIC2(RM, PCMPGTW, pcmpgtw, Vx, Wx, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
6049 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_pcmpgtw_u128);
6050}
6051
6052
6053/* Opcode 0xf3 0x0f 0x65 - invalid */
6054
6055
6056/** Opcode 0x0f 0x66 - pcmpgtd Pq, Qq */
6057FNIEMOP_DEF(iemOp_pcmpgtd_Pq_Qq)
6058{
6059 IEMOP_MNEMONIC2(RM, PCMPGTD, pcmpgtd, Pq, Qq, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
6060 return FNIEMOP_CALL_1(iemOpCommonMmx_FullFull_To_Full, iemAImpl_pcmpgtd_u64);
6061}
6062
6063
6064/** Opcode 0x66 0x0f 0x66 - pcmpgtd Vx, Wx */
6065FNIEMOP_DEF(iemOp_pcmpgtd_Vx_Wx)
6066{
6067 IEMOP_MNEMONIC2(RM, PCMPGTD, pcmpgtd, Vx, Wx, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
6068 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_pcmpgtd_u128);
6069}
6070
6071
6072/* Opcode 0xf3 0x0f 0x66 - invalid */
6073
6074
6075/** Opcode 0x0f 0x67 - packuswb Pq, Qq */
6076FNIEMOP_DEF(iemOp_packuswb_Pq_Qq)
6077{
6078 IEMOP_MNEMONIC2(RM, PACKUSWB, packuswb, Pq, Qd, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, 0);
6079 return FNIEMOP_CALL_1(iemOpCommonMmxOpt_FullFull_To_Full, iemAImpl_packuswb_u64);
6080}
6081
6082
6083/** Opcode 0x66 0x0f 0x67 - packuswb Vx, Wx */
6084FNIEMOP_DEF(iemOp_packuswb_Vx_Wx)
6085{
6086 IEMOP_MNEMONIC2(RM, PACKUSWB, packuswb, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
6087 return FNIEMOP_CALL_1(iemOpCommonSse2Opt_FullFull_To_Full, iemAImpl_packuswb_u128);
6088}
6089
6090
6091/* Opcode 0xf3 0x0f 0x67 - invalid */
6092
6093
6094/** Opcode 0x0f 0x68 - punpckhbw Pq, Qq
6095 * @note Intel and AMD both uses Qd for the second parameter, however they
6096 * both list it as a mmX/mem64 operand and intel describes it as being
6097 * loaded as a qword, so it should be Qq, shouldn't it? */
6098FNIEMOP_DEF(iemOp_punpckhbw_Pq_Qq)
6099{
6100 IEMOP_MNEMONIC2(RM, PUNPCKHBW, punpckhbw, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, 0);
6101 return FNIEMOP_CALL_1(iemOpCommonMmx_HighHigh_To_Full, iemAImpl_punpckhbw_u64);
6102}
6103
6104
6105/** Opcode 0x66 0x0f 0x68 - punpckhbw Vx, Wx */
6106FNIEMOP_DEF(iemOp_punpckhbw_Vx_Wx)
6107{
6108 IEMOP_MNEMONIC2(RM, PUNPCKHBW, punpckhbw, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
6109 return FNIEMOP_CALL_1(iemOpCommonSse2_HighHigh_To_Full, iemAImpl_punpckhbw_u128);
6110}
6111
6112
6113/* Opcode 0xf3 0x0f 0x68 - invalid */
6114
6115
6116/** Opcode 0x0f 0x69 - punpckhwd Pq, Qq
6117 * @note Intel and AMD both uses Qd for the second parameter, however they
6118 * both list it as a mmX/mem64 operand and intel describes it as being
6119 * loaded as a qword, so it should be Qq, shouldn't it? */
6120FNIEMOP_DEF(iemOp_punpckhwd_Pq_Qq)
6121{
6122 IEMOP_MNEMONIC2(RM, PUNPCKHWD, punpckhwd, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, 0);
6123 return FNIEMOP_CALL_1(iemOpCommonMmx_HighHigh_To_Full, iemAImpl_punpckhwd_u64);
6124}
6125
6126
6127/** Opcode 0x66 0x0f 0x69 - punpckhwd Vx, Hx, Wx */
6128FNIEMOP_DEF(iemOp_punpckhwd_Vx_Wx)
6129{
6130 IEMOP_MNEMONIC2(RM, PUNPCKHWD, punpckhwd, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
6131 return FNIEMOP_CALL_1(iemOpCommonSse2_HighHigh_To_Full, iemAImpl_punpckhwd_u128);
6132
6133}
6134
6135
6136/* Opcode 0xf3 0x0f 0x69 - invalid */
6137
6138
6139/** Opcode 0x0f 0x6a - punpckhdq Pq, Qq
6140 * @note Intel and AMD both uses Qd for the second parameter, however they
6141 * both list it as a mmX/mem64 operand and intel describes it as being
6142 * loaded as a qword, so it should be Qq, shouldn't it? */
6143FNIEMOP_DEF(iemOp_punpckhdq_Pq_Qq)
6144{
6145 IEMOP_MNEMONIC2(RM, PUNPCKHDQ, punpckhdq, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, 0);
6146 return FNIEMOP_CALL_1(iemOpCommonMmx_HighHigh_To_Full, iemAImpl_punpckhdq_u64);
6147}
6148
6149
6150/** Opcode 0x66 0x0f 0x6a - punpckhdq Vx, Wx */
6151FNIEMOP_DEF(iemOp_punpckhdq_Vx_Wx)
6152{
6153 IEMOP_MNEMONIC2(RM, PUNPCKHDQ, punpckhdq, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
6154 return FNIEMOP_CALL_1(iemOpCommonSse2_HighHigh_To_Full, iemAImpl_punpckhdq_u128);
6155}
6156
6157
6158/* Opcode 0xf3 0x0f 0x6a - invalid */
6159
6160
6161/** Opcode 0x0f 0x6b - packssdw Pq, Qd */
6162FNIEMOP_DEF(iemOp_packssdw_Pq_Qd)
6163{
6164 IEMOP_MNEMONIC2(RM, PACKSSDW, packssdw, Pq, Qd, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, 0);
6165 return FNIEMOP_CALL_1(iemOpCommonMmxOpt_FullFull_To_Full, iemAImpl_packssdw_u64);
6166}
6167
6168
6169/** Opcode 0x66 0x0f 0x6b - packssdw Vx, Wx */
6170FNIEMOP_DEF(iemOp_packssdw_Vx_Wx)
6171{
6172 IEMOP_MNEMONIC2(RM, PACKSSDW, packssdw, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
6173 return FNIEMOP_CALL_1(iemOpCommonSse2Opt_FullFull_To_Full, iemAImpl_packssdw_u128);
6174}
6175
6176
6177/* Opcode 0xf3 0x0f 0x6b - invalid */
6178
6179
6180/* Opcode 0x0f 0x6c - invalid */
6181
6182
6183/** Opcode 0x66 0x0f 0x6c - punpcklqdq Vx, Wx */
6184FNIEMOP_DEF(iemOp_punpcklqdq_Vx_Wx)
6185{
6186 IEMOP_MNEMONIC2(RM, PUNPCKLQDQ, punpcklqdq, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
6187 return FNIEMOP_CALL_1(iemOpCommonSse2_LowLow_To_Full, iemAImpl_punpcklqdq_u128);
6188}
6189
6190
6191/* Opcode 0xf3 0x0f 0x6c - invalid */
6192/* Opcode 0xf2 0x0f 0x6c - invalid */
6193
6194
6195/* Opcode 0x0f 0x6d - invalid */
6196
6197
6198/** Opcode 0x66 0x0f 0x6d - punpckhqdq Vx, Wx */
6199FNIEMOP_DEF(iemOp_punpckhqdq_Vx_Wx)
6200{
6201 IEMOP_MNEMONIC2(RM, PUNPCKHQDQ, punpckhqdq, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
6202 return FNIEMOP_CALL_1(iemOpCommonSse2_HighHigh_To_Full, iemAImpl_punpckhqdq_u128);
6203}
6204
6205
6206/* Opcode 0xf3 0x0f 0x6d - invalid */
6207
6208
6209FNIEMOP_DEF(iemOp_movd_q_Pd_Ey)
6210{
6211 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
6212 if (pVCpu->iem.s.fPrefixes & IEM_OP_PRF_SIZE_REX_W)
6213 {
6214 /**
6215 * @opcode 0x6e
6216 * @opcodesub rex.w=1
6217 * @oppfx none
6218 * @opcpuid mmx
6219 * @opgroup og_mmx_datamove
6220 * @opxcpttype 5
6221 * @optest 64-bit / op1=1 op2=2 -> op1=2 ftw=0xff
6222 * @optest 64-bit / op1=0 op2=-42 -> op1=-42 ftw=0xff
6223 */
6224 IEMOP_MNEMONIC2(RM, MOVQ, movq, Pq_WO, Eq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, IEMOPHINT_IGNORES_OZ_PFX);
6225 if (IEM_IS_MODRM_REG_MODE(bRm))
6226 {
6227 /* MMX, greg64 */
6228 IEM_MC_BEGIN(0, 1, IEM_MC_F_64BIT, 0);
6229 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fMmx);
6230 IEM_MC_LOCAL(uint64_t, u64Tmp);
6231
6232 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
6233 IEM_MC_ACTUALIZE_FPU_STATE_FOR_CHANGE();
6234 IEM_MC_FPU_TO_MMX_MODE();
6235
6236 IEM_MC_FETCH_GREG_U64(u64Tmp, IEM_GET_MODRM_RM(pVCpu, bRm));
6237 IEM_MC_STORE_MREG_U64(IEM_GET_MODRM_REG_8(bRm), u64Tmp);
6238
6239 IEM_MC_ADVANCE_RIP_AND_FINISH();
6240 IEM_MC_END();
6241 }
6242 else
6243 {
6244 /* MMX, [mem64] */
6245 IEM_MC_BEGIN(0, 2, IEM_MC_F_64BIT, 0);
6246 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
6247 IEM_MC_LOCAL(uint64_t, u64Tmp);
6248
6249 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
6250 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fMmx);
6251 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
6252 IEM_MC_ACTUALIZE_FPU_STATE_FOR_CHANGE();
6253 IEM_MC_FPU_TO_MMX_MODE();
6254
6255 IEM_MC_FETCH_MEM_U64(u64Tmp, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
6256 IEM_MC_STORE_MREG_U64(IEM_GET_MODRM_REG_8(bRm), u64Tmp);
6257
6258 IEM_MC_ADVANCE_RIP_AND_FINISH();
6259 IEM_MC_END();
6260 }
6261 }
6262 else
6263 {
6264 /**
6265 * @opdone
6266 * @opcode 0x6e
6267 * @opcodesub rex.w=0
6268 * @oppfx none
6269 * @opcpuid mmx
6270 * @opgroup og_mmx_datamove
6271 * @opxcpttype 5
6272 * @opfunction iemOp_movd_q_Pd_Ey
6273 * @optest op1=1 op2=2 -> op1=2 ftw=0xff
6274 * @optest op1=0 op2=-42 -> op1=-42 ftw=0xff
6275 */
6276 IEMOP_MNEMONIC2(RM, MOVD, movd, PdZx_WO, Ed, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, IEMOPHINT_IGNORES_OZ_PFX);
6277 if (IEM_IS_MODRM_REG_MODE(bRm))
6278 {
6279 /* MMX, greg32 */
6280 IEM_MC_BEGIN(0, 1, 0, 0);
6281 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fMmx);
6282 IEM_MC_LOCAL(uint32_t, u32Tmp);
6283
6284 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
6285 IEM_MC_ACTUALIZE_FPU_STATE_FOR_CHANGE();
6286 IEM_MC_FPU_TO_MMX_MODE();
6287
6288 IEM_MC_FETCH_GREG_U32(u32Tmp, IEM_GET_MODRM_RM(pVCpu, bRm));
6289 IEM_MC_STORE_MREG_U32_ZX_U64(IEM_GET_MODRM_REG_8(bRm), u32Tmp);
6290
6291 IEM_MC_ADVANCE_RIP_AND_FINISH();
6292 IEM_MC_END();
6293 }
6294 else
6295 {
6296 /* MMX, [mem32] */
6297 IEM_MC_BEGIN(0, 2, 0, 0);
6298 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
6299 IEM_MC_LOCAL(uint32_t, u32Tmp);
6300
6301 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
6302 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fMmx);
6303 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
6304 IEM_MC_ACTUALIZE_FPU_STATE_FOR_CHANGE();
6305 IEM_MC_FPU_TO_MMX_MODE();
6306
6307 IEM_MC_FETCH_MEM_U32(u32Tmp, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
6308 IEM_MC_STORE_MREG_U32_ZX_U64(IEM_GET_MODRM_REG_8(bRm), u32Tmp);
6309
6310 IEM_MC_ADVANCE_RIP_AND_FINISH();
6311 IEM_MC_END();
6312 }
6313 }
6314}
6315
6316FNIEMOP_DEF(iemOp_movd_q_Vy_Ey)
6317{
6318 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
6319 if (pVCpu->iem.s.fPrefixes & IEM_OP_PRF_SIZE_REX_W)
6320 {
6321 /**
6322 * @opcode 0x6e
6323 * @opcodesub rex.w=1
6324 * @oppfx 0x66
6325 * @opcpuid sse2
6326 * @opgroup og_sse2_simdint_datamove
6327 * @opxcpttype 5
6328 * @optest 64-bit / op1=1 op2=2 -> op1=2
6329 * @optest 64-bit / op1=0 op2=-42 -> op1=-42
6330 */
6331 IEMOP_MNEMONIC2(RM, MOVQ, movq, VqZx_WO, Eq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OZ_PFX);
6332 if (IEM_IS_MODRM_REG_MODE(bRm))
6333 {
6334 /* XMM, greg64 */
6335 IEM_MC_BEGIN(0, 1, IEM_MC_F_64BIT, 0);
6336 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
6337 IEM_MC_LOCAL(uint64_t, u64Tmp);
6338
6339 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
6340 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
6341
6342 IEM_MC_FETCH_GREG_U64(u64Tmp, IEM_GET_MODRM_RM(pVCpu, bRm));
6343 IEM_MC_STORE_XREG_U64_ZX_U128(IEM_GET_MODRM_REG(pVCpu, bRm), u64Tmp);
6344
6345 IEM_MC_ADVANCE_RIP_AND_FINISH();
6346 IEM_MC_END();
6347 }
6348 else
6349 {
6350 /* XMM, [mem64] */
6351 IEM_MC_BEGIN(0, 2, IEM_MC_F_64BIT, 0);
6352 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
6353 IEM_MC_LOCAL(uint64_t, u64Tmp);
6354
6355 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
6356 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
6357 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
6358 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
6359
6360 IEM_MC_FETCH_MEM_U64(u64Tmp, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
6361 IEM_MC_STORE_XREG_U64_ZX_U128(IEM_GET_MODRM_REG(pVCpu, bRm), u64Tmp);
6362
6363 IEM_MC_ADVANCE_RIP_AND_FINISH();
6364 IEM_MC_END();
6365 }
6366 }
6367 else
6368 {
6369 /**
6370 * @opdone
6371 * @opcode 0x6e
6372 * @opcodesub rex.w=0
6373 * @oppfx 0x66
6374 * @opcpuid sse2
6375 * @opgroup og_sse2_simdint_datamove
6376 * @opxcpttype 5
6377 * @opfunction iemOp_movd_q_Vy_Ey
6378 * @optest op1=1 op2=2 -> op1=2
6379 * @optest op1=0 op2=-42 -> op1=-42
6380 */
6381 IEMOP_MNEMONIC2(RM, MOVD, movd, VdZx_WO, Ed, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OZ_PFX);
6382 if (IEM_IS_MODRM_REG_MODE(bRm))
6383 {
6384 /* XMM, greg32 */
6385 IEM_MC_BEGIN(0, 1, 0, 0);
6386 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
6387 IEM_MC_LOCAL(uint32_t, u32Tmp);
6388
6389 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
6390 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
6391
6392 IEM_MC_FETCH_GREG_U32(u32Tmp, IEM_GET_MODRM_RM(pVCpu, bRm));
6393 IEM_MC_STORE_XREG_U32_ZX_U128(IEM_GET_MODRM_REG(pVCpu, bRm), u32Tmp);
6394
6395 IEM_MC_ADVANCE_RIP_AND_FINISH();
6396 IEM_MC_END();
6397 }
6398 else
6399 {
6400 /* XMM, [mem32] */
6401 IEM_MC_BEGIN(0, 2, 0, 0);
6402 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
6403 IEM_MC_LOCAL(uint32_t, u32Tmp);
6404
6405 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
6406 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
6407 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
6408 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
6409
6410 IEM_MC_FETCH_MEM_U32(u32Tmp, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
6411 IEM_MC_STORE_XREG_U32_ZX_U128(IEM_GET_MODRM_REG(pVCpu, bRm), u32Tmp);
6412
6413 IEM_MC_ADVANCE_RIP_AND_FINISH();
6414 IEM_MC_END();
6415 }
6416 }
6417}
6418
6419/* Opcode 0xf3 0x0f 0x6e - invalid */
6420
6421
6422/**
6423 * @opcode 0x6f
6424 * @oppfx none
6425 * @opcpuid mmx
6426 * @opgroup og_mmx_datamove
6427 * @opxcpttype 5
6428 * @optest op1=1 op2=2 -> op1=2 ftw=0xff
6429 * @optest op1=0 op2=-42 -> op1=-42 ftw=0xff
6430 */
6431FNIEMOP_DEF(iemOp_movq_Pq_Qq)
6432{
6433 IEMOP_MNEMONIC2(RM, MOVD, movd, Pq_WO, Qq, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
6434 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
6435 if (IEM_IS_MODRM_REG_MODE(bRm))
6436 {
6437 /*
6438 * Register, register.
6439 */
6440 IEM_MC_BEGIN(0, 1, 0, 0);
6441 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fMmx);
6442 IEM_MC_LOCAL(uint64_t, u64Tmp);
6443
6444 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
6445 IEM_MC_ACTUALIZE_FPU_STATE_FOR_CHANGE();
6446 IEM_MC_FPU_TO_MMX_MODE();
6447
6448 IEM_MC_FETCH_MREG_U64(u64Tmp, IEM_GET_MODRM_RM_8(bRm));
6449 IEM_MC_STORE_MREG_U64(IEM_GET_MODRM_REG_8(bRm), u64Tmp);
6450
6451 IEM_MC_ADVANCE_RIP_AND_FINISH();
6452 IEM_MC_END();
6453 }
6454 else
6455 {
6456 /*
6457 * Register, memory.
6458 */
6459 IEM_MC_BEGIN(0, 2, 0, 0);
6460 IEM_MC_LOCAL(uint64_t, u64Tmp);
6461 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
6462
6463 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
6464 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fMmx);
6465 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
6466 IEM_MC_ACTUALIZE_FPU_STATE_FOR_CHANGE();
6467 IEM_MC_FPU_TO_MMX_MODE();
6468
6469 IEM_MC_FETCH_MEM_U64(u64Tmp, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
6470 IEM_MC_STORE_MREG_U64(IEM_GET_MODRM_REG_8(bRm), u64Tmp);
6471
6472 IEM_MC_ADVANCE_RIP_AND_FINISH();
6473 IEM_MC_END();
6474 }
6475}
6476
6477/**
6478 * @opcode 0x6f
6479 * @oppfx 0x66
6480 * @opcpuid sse2
6481 * @opgroup og_sse2_simdint_datamove
6482 * @opxcpttype 1
6483 * @optest op1=1 op2=2 -> op1=2
6484 * @optest op1=0 op2=-42 -> op1=-42
6485 */
6486FNIEMOP_DEF(iemOp_movdqa_Vdq_Wdq)
6487{
6488 IEMOP_MNEMONIC2(RM, MOVDQA, movdqa, Vdq_WO, Wdq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
6489 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
6490 if (IEM_IS_MODRM_REG_MODE(bRm))
6491 {
6492 /*
6493 * Register, register.
6494 */
6495 IEM_MC_BEGIN(0, 0, 0, 0);
6496 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
6497
6498 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
6499 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
6500
6501 IEM_MC_COPY_XREG_U128(IEM_GET_MODRM_REG(pVCpu, bRm),
6502 IEM_GET_MODRM_RM(pVCpu, bRm));
6503 IEM_MC_ADVANCE_RIP_AND_FINISH();
6504 IEM_MC_END();
6505 }
6506 else
6507 {
6508 /*
6509 * Register, memory.
6510 */
6511 IEM_MC_BEGIN(0, 2, 0, 0);
6512 IEM_MC_LOCAL(RTUINT128U, u128Tmp);
6513 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
6514
6515 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
6516 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
6517 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
6518 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
6519
6520 IEM_MC_FETCH_MEM_U128_ALIGN_SSE(u128Tmp, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
6521 IEM_MC_STORE_XREG_U128(IEM_GET_MODRM_REG(pVCpu, bRm), u128Tmp);
6522
6523 IEM_MC_ADVANCE_RIP_AND_FINISH();
6524 IEM_MC_END();
6525 }
6526}
6527
6528/**
6529 * @opcode 0x6f
6530 * @oppfx 0xf3
6531 * @opcpuid sse2
6532 * @opgroup og_sse2_simdint_datamove
6533 * @opxcpttype 4UA
6534 * @optest op1=1 op2=2 -> op1=2
6535 * @optest op1=0 op2=-42 -> op1=-42
6536 */
6537FNIEMOP_DEF(iemOp_movdqu_Vdq_Wdq)
6538{
6539 IEMOP_MNEMONIC2(RM, MOVDQU, movdqu, Vdq_WO, Wdq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
6540 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
6541 if (IEM_IS_MODRM_REG_MODE(bRm))
6542 {
6543 /*
6544 * Register, register.
6545 */
6546 IEM_MC_BEGIN(0, 0, 0, 0);
6547 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
6548 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
6549 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
6550 IEM_MC_COPY_XREG_U128(IEM_GET_MODRM_REG(pVCpu, bRm),
6551 IEM_GET_MODRM_RM(pVCpu, bRm));
6552 IEM_MC_ADVANCE_RIP_AND_FINISH();
6553 IEM_MC_END();
6554 }
6555 else
6556 {
6557 /*
6558 * Register, memory.
6559 */
6560 IEM_MC_BEGIN(0, 2, 0, 0);
6561 IEM_MC_LOCAL(RTUINT128U, u128Tmp);
6562 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
6563
6564 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
6565 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
6566 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
6567 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
6568 IEM_MC_FETCH_MEM_U128(u128Tmp, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
6569 IEM_MC_STORE_XREG_U128(IEM_GET_MODRM_REG(pVCpu, bRm), u128Tmp);
6570
6571 IEM_MC_ADVANCE_RIP_AND_FINISH();
6572 IEM_MC_END();
6573 }
6574}
6575
6576
6577/** Opcode 0x0f 0x70 - pshufw Pq, Qq, Ib */
6578FNIEMOP_DEF(iemOp_pshufw_Pq_Qq_Ib)
6579{
6580 IEMOP_MNEMONIC3(RMI, PSHUFW, pshufw, Pq, Qq, Ib, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, 0);
6581 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
6582 if (IEM_IS_MODRM_REG_MODE(bRm))
6583 {
6584 /*
6585 * Register, register.
6586 */
6587 IEM_MC_BEGIN(3, 0, 0, 0);
6588 uint8_t bImm; IEM_OPCODE_GET_NEXT_U8(&bImm);
6589 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX_2_OR(fSse, fAmdMmxExts);
6590 IEM_MC_ARG(uint64_t *, pDst, 0);
6591 IEM_MC_ARG(uint64_t const *, pSrc, 1);
6592 IEM_MC_ARG_CONST(uint8_t, bImmArg, /*=*/ bImm, 2);
6593 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
6594 IEM_MC_PREPARE_FPU_USAGE();
6595 IEM_MC_FPU_TO_MMX_MODE();
6596
6597 IEM_MC_REF_MREG_U64(pDst, IEM_GET_MODRM_REG_8(bRm));
6598 IEM_MC_REF_MREG_U64_CONST(pSrc, IEM_GET_MODRM_RM_8(bRm));
6599 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_pshufw_u64, pDst, pSrc, bImmArg);
6600 IEM_MC_MODIFIED_MREG_BY_REF(pDst);
6601
6602 IEM_MC_ADVANCE_RIP_AND_FINISH();
6603 IEM_MC_END();
6604 }
6605 else
6606 {
6607 /*
6608 * Register, memory.
6609 */
6610 IEM_MC_BEGIN(3, 2, 0, 0);
6611 IEM_MC_ARG(uint64_t *, pDst, 0);
6612 IEM_MC_LOCAL(uint64_t, uSrc);
6613 IEM_MC_ARG_LOCAL_REF(uint64_t const *, pSrc, uSrc, 1);
6614 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
6615
6616 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 1);
6617 uint8_t bImm; IEM_OPCODE_GET_NEXT_U8(&bImm);
6618 IEM_MC_ARG_CONST(uint8_t, bImmArg, /*=*/ bImm, 2);
6619 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX_2_OR(fSse, fAmdMmxExts);
6620 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
6621 IEM_MC_FETCH_MEM_U64(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
6622
6623 IEM_MC_PREPARE_FPU_USAGE();
6624 IEM_MC_FPU_TO_MMX_MODE();
6625
6626 IEM_MC_REF_MREG_U64(pDst, IEM_GET_MODRM_REG_8(bRm));
6627 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_pshufw_u64, pDst, pSrc, bImmArg);
6628 IEM_MC_MODIFIED_MREG_BY_REF(pDst);
6629
6630 IEM_MC_ADVANCE_RIP_AND_FINISH();
6631 IEM_MC_END();
6632 }
6633}
6634
6635
6636/**
6637 * Common worker for SSE2 instructions on the forms:
6638 * pshufd xmm1, xmm2/mem128, imm8
6639 * pshufhw xmm1, xmm2/mem128, imm8
6640 * pshuflw xmm1, xmm2/mem128, imm8
6641 *
6642 * Proper alignment of the 128-bit operand is enforced.
6643 * Exceptions type 4. SSE2 cpuid checks.
6644 */
6645FNIEMOP_DEF_1(iemOpCommonSse2_pshufXX_Vx_Wx_Ib, PFNIEMAIMPLMEDIAPSHUFU128, pfnWorker)
6646{
6647 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
6648 if (IEM_IS_MODRM_REG_MODE(bRm))
6649 {
6650 /*
6651 * Register, register.
6652 */
6653 IEM_MC_BEGIN(3, 0, 0, 0);
6654 uint8_t bImm; IEM_OPCODE_GET_NEXT_U8(&bImm);
6655 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
6656 IEM_MC_ARG(PRTUINT128U, puDst, 0);
6657 IEM_MC_ARG(PCRTUINT128U, puSrc, 1);
6658 IEM_MC_ARG_CONST(uint8_t, bImmArg, /*=*/ bImm, 2);
6659 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
6660 IEM_MC_PREPARE_SSE_USAGE();
6661 IEM_MC_REF_XREG_U128(puDst, IEM_GET_MODRM_REG(pVCpu, bRm));
6662 IEM_MC_REF_XREG_U128_CONST(puSrc, IEM_GET_MODRM_RM(pVCpu, bRm));
6663 IEM_MC_CALL_VOID_AIMPL_3(pfnWorker, puDst, puSrc, bImmArg);
6664 IEM_MC_ADVANCE_RIP_AND_FINISH();
6665 IEM_MC_END();
6666 }
6667 else
6668 {
6669 /*
6670 * Register, memory.
6671 */
6672 IEM_MC_BEGIN(3, 2, 0, 0);
6673 IEM_MC_ARG(PRTUINT128U, puDst, 0);
6674 IEM_MC_LOCAL(RTUINT128U, uSrc);
6675 IEM_MC_ARG_LOCAL_REF(PCRTUINT128U, puSrc, uSrc, 1);
6676 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
6677
6678 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 1);
6679 uint8_t bImm; IEM_OPCODE_GET_NEXT_U8(&bImm);
6680 IEM_MC_ARG_CONST(uint8_t, bImmArg, /*=*/ bImm, 2);
6681 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
6682 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
6683
6684 IEM_MC_FETCH_MEM_U128_ALIGN_SSE(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
6685 IEM_MC_PREPARE_SSE_USAGE();
6686 IEM_MC_REF_XREG_U128(puDst, IEM_GET_MODRM_REG(pVCpu, bRm));
6687 IEM_MC_CALL_VOID_AIMPL_3(pfnWorker, puDst, puSrc, bImmArg);
6688
6689 IEM_MC_ADVANCE_RIP_AND_FINISH();
6690 IEM_MC_END();
6691 }
6692}
6693
6694
6695/** Opcode 0x66 0x0f 0x70 - pshufd Vx, Wx, Ib */
6696FNIEMOP_DEF(iemOp_pshufd_Vx_Wx_Ib)
6697{
6698 IEMOP_MNEMONIC3(RMI, PSHUFD, pshufd, Vx, Wx, Ib, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
6699 return FNIEMOP_CALL_1(iemOpCommonSse2_pshufXX_Vx_Wx_Ib, iemAImpl_pshufd_u128);
6700}
6701
6702
6703/** Opcode 0xf3 0x0f 0x70 - pshufhw Vx, Wx, Ib */
6704FNIEMOP_DEF(iemOp_pshufhw_Vx_Wx_Ib)
6705{
6706 IEMOP_MNEMONIC3(RMI, PSHUFHW, pshufhw, Vx, Wx, Ib, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
6707 return FNIEMOP_CALL_1(iemOpCommonSse2_pshufXX_Vx_Wx_Ib, iemAImpl_pshufhw_u128);
6708}
6709
6710
6711/** Opcode 0xf2 0x0f 0x70 - pshuflw Vx, Wx, Ib */
6712FNIEMOP_DEF(iemOp_pshuflw_Vx_Wx_Ib)
6713{
6714 IEMOP_MNEMONIC3(RMI, PSHUFLW, pshuflw, Vx, Wx, Ib, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
6715 return FNIEMOP_CALL_1(iemOpCommonSse2_pshufXX_Vx_Wx_Ib, iemAImpl_pshuflw_u128);
6716}
6717
6718
6719/**
6720 * Common worker for MMX instructions of the form:
6721 * psrlw mm, imm8
6722 * psraw mm, imm8
6723 * psllw mm, imm8
6724 * psrld mm, imm8
6725 * psrad mm, imm8
6726 * pslld mm, imm8
6727 * psrlq mm, imm8
6728 * psllq mm, imm8
6729 *
6730 */
6731FNIEMOP_DEF_2(iemOpCommonMmx_Shift_Imm, uint8_t, bRm, PFNIEMAIMPLMEDIAPSHIFTU64, pfnU64)
6732{
6733 if (IEM_IS_MODRM_REG_MODE(bRm))
6734 {
6735 /*
6736 * Register, immediate.
6737 */
6738 IEM_MC_BEGIN(2, 0, 0, 0);
6739 uint8_t bImm; IEM_OPCODE_GET_NEXT_U8(&bImm);
6740 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fMmx);
6741 IEM_MC_ARG(uint64_t *, pDst, 0);
6742 IEM_MC_ARG_CONST(uint8_t, bShiftArg, /*=*/ bImm, 1);
6743 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
6744 IEM_MC_PREPARE_FPU_USAGE();
6745 IEM_MC_FPU_TO_MMX_MODE();
6746
6747 IEM_MC_REF_MREG_U64(pDst, IEM_GET_MODRM_RM_8(bRm));
6748 IEM_MC_CALL_VOID_AIMPL_2(pfnU64, pDst, bShiftArg);
6749 IEM_MC_MODIFIED_MREG_BY_REF(pDst);
6750
6751 IEM_MC_ADVANCE_RIP_AND_FINISH();
6752 IEM_MC_END();
6753 }
6754 else
6755 {
6756 /*
6757 * Register, memory not supported.
6758 */
6759 /// @todo Caller already enforced register mode?!
6760 AssertFailedReturn(VINF_SUCCESS);
6761 }
6762}
6763
6764
6765/**
6766 * Common worker for SSE2 instructions of the form:
6767 * psrlw xmm, imm8
6768 * psraw xmm, imm8
6769 * psllw xmm, imm8
6770 * psrld xmm, imm8
6771 * psrad xmm, imm8
6772 * pslld xmm, imm8
6773 * psrlq xmm, imm8
6774 * psllq xmm, imm8
6775 *
6776 */
6777FNIEMOP_DEF_2(iemOpCommonSse2_Shift_Imm, uint8_t, bRm, PFNIEMAIMPLMEDIAPSHIFTU128, pfnU128)
6778{
6779 if (IEM_IS_MODRM_REG_MODE(bRm))
6780 {
6781 /*
6782 * Register, immediate.
6783 */
6784 IEM_MC_BEGIN(2, 0, 0, 0);
6785 uint8_t bImm; IEM_OPCODE_GET_NEXT_U8(&bImm);
6786 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
6787 IEM_MC_ARG(PRTUINT128U, pDst, 0);
6788 IEM_MC_ARG_CONST(uint8_t, bShiftArg, /*=*/ bImm, 1);
6789 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
6790 IEM_MC_PREPARE_SSE_USAGE();
6791 IEM_MC_REF_XREG_U128(pDst, IEM_GET_MODRM_RM(pVCpu, bRm));
6792 IEM_MC_CALL_VOID_AIMPL_2(pfnU128, pDst, bShiftArg);
6793 IEM_MC_ADVANCE_RIP_AND_FINISH();
6794 IEM_MC_END();
6795 }
6796 else
6797 {
6798 /*
6799 * Register, memory.
6800 */
6801 /// @todo Caller already enforced register mode?!
6802 AssertFailedReturn(VINF_SUCCESS);
6803 }
6804}
6805
6806
6807/** Opcode 0x0f 0x71 11/2 - psrlw Nq, Ib */
6808FNIEMOPRM_DEF(iemOp_Grp12_psrlw_Nq_Ib)
6809{
6810// IEMOP_MNEMONIC2(RI, PSRLW, psrlw, Nq, Ib, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, 0);
6811 return FNIEMOP_CALL_2(iemOpCommonMmx_Shift_Imm, bRm, iemAImpl_psrlw_imm_u64);
6812}
6813
6814
6815/** Opcode 0x66 0x0f 0x71 11/2. */
6816FNIEMOPRM_DEF(iemOp_Grp12_psrlw_Ux_Ib)
6817{
6818// IEMOP_MNEMONIC2(RI, PSRLW, psrlw, Ux, Ib, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
6819 return FNIEMOP_CALL_2(iemOpCommonSse2_Shift_Imm, bRm, iemAImpl_psrlw_imm_u128);
6820}
6821
6822
6823/** Opcode 0x0f 0x71 11/4. */
6824FNIEMOPRM_DEF(iemOp_Grp12_psraw_Nq_Ib)
6825{
6826// IEMOP_MNEMONIC2(RI, PSRAW, psraw, Nq, Ib, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, 0);
6827 return FNIEMOP_CALL_2(iemOpCommonMmx_Shift_Imm, bRm, iemAImpl_psraw_imm_u64);
6828}
6829
6830
6831/** Opcode 0x66 0x0f 0x71 11/4. */
6832FNIEMOPRM_DEF(iemOp_Grp12_psraw_Ux_Ib)
6833{
6834// IEMOP_MNEMONIC2(RI, PSRAW, psraw, Ux, Ib, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
6835 return FNIEMOP_CALL_2(iemOpCommonSse2_Shift_Imm, bRm, iemAImpl_psraw_imm_u128);
6836}
6837
6838
6839/** Opcode 0x0f 0x71 11/6. */
6840FNIEMOPRM_DEF(iemOp_Grp12_psllw_Nq_Ib)
6841{
6842// IEMOP_MNEMONIC2(RI, PSLLW, psllw, Nq, Ib, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, 0);
6843 return FNIEMOP_CALL_2(iemOpCommonMmx_Shift_Imm, bRm, iemAImpl_psllw_imm_u64);
6844}
6845
6846
6847/** Opcode 0x66 0x0f 0x71 11/6. */
6848FNIEMOPRM_DEF(iemOp_Grp12_psllw_Ux_Ib)
6849{
6850// IEMOP_MNEMONIC2(RI, PSLLW, psllw, Ux, Ib, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
6851 return FNIEMOP_CALL_2(iemOpCommonSse2_Shift_Imm, bRm, iemAImpl_psllw_imm_u128);
6852}
6853
6854
6855/**
6856 * Group 12 jump table for register variant.
6857 */
6858IEM_STATIC const PFNIEMOPRM g_apfnGroup12RegReg[] =
6859{
6860 /* /0 */ IEMOP_X4(iemOp_InvalidWithRMNeedImm8),
6861 /* /1 */ IEMOP_X4(iemOp_InvalidWithRMNeedImm8),
6862 /* /2 */ iemOp_Grp12_psrlw_Nq_Ib, iemOp_Grp12_psrlw_Ux_Ib, iemOp_InvalidWithRMNeedImm8, iemOp_InvalidWithRMNeedImm8,
6863 /* /3 */ IEMOP_X4(iemOp_InvalidWithRMNeedImm8),
6864 /* /4 */ iemOp_Grp12_psraw_Nq_Ib, iemOp_Grp12_psraw_Ux_Ib, iemOp_InvalidWithRMNeedImm8, iemOp_InvalidWithRMNeedImm8,
6865 /* /5 */ IEMOP_X4(iemOp_InvalidWithRMNeedImm8),
6866 /* /6 */ iemOp_Grp12_psllw_Nq_Ib, iemOp_Grp12_psllw_Ux_Ib, iemOp_InvalidWithRMNeedImm8, iemOp_InvalidWithRMNeedImm8,
6867 /* /7 */ IEMOP_X4(iemOp_InvalidWithRMNeedImm8)
6868};
6869AssertCompile(RT_ELEMENTS(g_apfnGroup12RegReg) == 8*4);
6870
6871
6872/** Opcode 0x0f 0x71. */
6873FNIEMOP_DEF(iemOp_Grp12)
6874{
6875 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
6876 if (IEM_IS_MODRM_REG_MODE(bRm))
6877 /* register, register */
6878 return FNIEMOP_CALL_1(g_apfnGroup12RegReg[ IEM_GET_MODRM_REG_8(bRm) * 4
6879 + pVCpu->iem.s.idxPrefix], bRm);
6880 return FNIEMOP_CALL_1(iemOp_InvalidWithRMNeedImm8, bRm);
6881}
6882
6883
6884/** Opcode 0x0f 0x72 11/2. */
6885FNIEMOPRM_DEF(iemOp_Grp13_psrld_Nq_Ib)
6886{
6887// IEMOP_MNEMONIC2(RI, PSRLD, psrld, Nq, Ib, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, 0);
6888 return FNIEMOP_CALL_2(iemOpCommonMmx_Shift_Imm, bRm, iemAImpl_psrld_imm_u64);
6889}
6890
6891
6892/** Opcode 0x66 0x0f 0x72 11/2. */
6893FNIEMOPRM_DEF(iemOp_Grp13_psrld_Ux_Ib)
6894{
6895// IEMOP_MNEMONIC2(RI, PSRLD, psrld, Ux, Ib, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
6896 return FNIEMOP_CALL_2(iemOpCommonSse2_Shift_Imm, bRm, iemAImpl_psrld_imm_u128);
6897}
6898
6899
6900/** Opcode 0x0f 0x72 11/4. */
6901FNIEMOPRM_DEF(iemOp_Grp13_psrad_Nq_Ib)
6902{
6903// IEMOP_MNEMONIC2(RI, PSRAD, psrad, Nq, Ib, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, 0);
6904 return FNIEMOP_CALL_2(iemOpCommonMmx_Shift_Imm, bRm, iemAImpl_psrad_imm_u64);
6905}
6906
6907
6908/** Opcode 0x66 0x0f 0x72 11/4. */
6909FNIEMOPRM_DEF(iemOp_Grp13_psrad_Ux_Ib)
6910{
6911// IEMOP_MNEMONIC2(RI, PSRAD, psrad, Ux, Ib, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
6912 return FNIEMOP_CALL_2(iemOpCommonSse2_Shift_Imm, bRm, iemAImpl_psrad_imm_u128);
6913}
6914
6915
6916/** Opcode 0x0f 0x72 11/6. */
6917FNIEMOPRM_DEF(iemOp_Grp13_pslld_Nq_Ib)
6918{
6919// IEMOP_MNEMONIC2(RI, PSLLD, pslld, Nq, Ib, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, 0);
6920 return FNIEMOP_CALL_2(iemOpCommonMmx_Shift_Imm, bRm, iemAImpl_pslld_imm_u64);
6921}
6922
6923/** Opcode 0x66 0x0f 0x72 11/6. */
6924FNIEMOPRM_DEF(iemOp_Grp13_pslld_Ux_Ib)
6925{
6926// IEMOP_MNEMONIC2(RI, PSLLD, pslld, Ux, Ib, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
6927 return FNIEMOP_CALL_2(iemOpCommonSse2_Shift_Imm, bRm, iemAImpl_pslld_imm_u128);
6928}
6929
6930
6931/**
6932 * Group 13 jump table for register variant.
6933 */
6934IEM_STATIC const PFNIEMOPRM g_apfnGroup13RegReg[] =
6935{
6936 /* /0 */ IEMOP_X4(iemOp_InvalidWithRMNeedImm8),
6937 /* /1 */ IEMOP_X4(iemOp_InvalidWithRMNeedImm8),
6938 /* /2 */ iemOp_Grp13_psrld_Nq_Ib, iemOp_Grp13_psrld_Ux_Ib, iemOp_InvalidWithRMNeedImm8, iemOp_InvalidWithRMNeedImm8,
6939 /* /3 */ IEMOP_X4(iemOp_InvalidWithRMNeedImm8),
6940 /* /4 */ iemOp_Grp13_psrad_Nq_Ib, iemOp_Grp13_psrad_Ux_Ib, iemOp_InvalidWithRMNeedImm8, iemOp_InvalidWithRMNeedImm8,
6941 /* /5 */ IEMOP_X4(iemOp_InvalidWithRMNeedImm8),
6942 /* /6 */ iemOp_Grp13_pslld_Nq_Ib, iemOp_Grp13_pslld_Ux_Ib, iemOp_InvalidWithRMNeedImm8, iemOp_InvalidWithRMNeedImm8,
6943 /* /7 */ IEMOP_X4(iemOp_InvalidWithRMNeedImm8)
6944};
6945AssertCompile(RT_ELEMENTS(g_apfnGroup13RegReg) == 8*4);
6946
6947/** Opcode 0x0f 0x72. */
6948FNIEMOP_DEF(iemOp_Grp13)
6949{
6950 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
6951 if (IEM_IS_MODRM_REG_MODE(bRm))
6952 /* register, register */
6953 return FNIEMOP_CALL_1(g_apfnGroup13RegReg[ IEM_GET_MODRM_REG_8(bRm) * 4
6954 + pVCpu->iem.s.idxPrefix], bRm);
6955 return FNIEMOP_CALL_1(iemOp_InvalidWithRMNeedImm8, bRm);
6956}
6957
6958
6959/** Opcode 0x0f 0x73 11/2. */
6960FNIEMOPRM_DEF(iemOp_Grp14_psrlq_Nq_Ib)
6961{
6962// IEMOP_MNEMONIC2(RI, PSRLQ, psrlq, Nq, Ib, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, 0);
6963 return FNIEMOP_CALL_2(iemOpCommonMmx_Shift_Imm, bRm, iemAImpl_psrlq_imm_u64);
6964}
6965
6966
6967/** Opcode 0x66 0x0f 0x73 11/2. */
6968FNIEMOPRM_DEF(iemOp_Grp14_psrlq_Ux_Ib)
6969{
6970// IEMOP_MNEMONIC2(RI, PSRLQ, psrlq, Ux, Ib, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
6971 return FNIEMOP_CALL_2(iemOpCommonSse2_Shift_Imm, bRm, iemAImpl_psrlq_imm_u128);
6972}
6973
6974
6975/** Opcode 0x66 0x0f 0x73 11/3. */
6976FNIEMOPRM_DEF(iemOp_Grp14_psrldq_Ux_Ib)
6977{
6978// IEMOP_MNEMONIC2(RI, PSRLDQ, psrldq, Ux, Ib, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
6979 return FNIEMOP_CALL_2(iemOpCommonSse2_Shift_Imm, bRm, iemAImpl_psrldq_imm_u128);
6980}
6981
6982
6983/** Opcode 0x0f 0x73 11/6. */
6984FNIEMOPRM_DEF(iemOp_Grp14_psllq_Nq_Ib)
6985{
6986// IEMOP_MNEMONIC2(RI, PSLLQ, psllq, Nq, Ib, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, 0);
6987 return FNIEMOP_CALL_2(iemOpCommonMmx_Shift_Imm, bRm, iemAImpl_psllq_imm_u64);
6988}
6989
6990
6991/** Opcode 0x66 0x0f 0x73 11/6. */
6992FNIEMOPRM_DEF(iemOp_Grp14_psllq_Ux_Ib)
6993{
6994// IEMOP_MNEMONIC2(RI, PSLLQ, psllq, Ux, Ib, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
6995 return FNIEMOP_CALL_2(iemOpCommonSse2_Shift_Imm, bRm, iemAImpl_psllq_imm_u128);
6996}
6997
6998
6999/** Opcode 0x66 0x0f 0x73 11/7. */
7000FNIEMOPRM_DEF(iemOp_Grp14_pslldq_Ux_Ib)
7001{
7002// IEMOP_MNEMONIC2(RI, PSLLDQ, pslldq, Ux, Ib, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
7003 return FNIEMOP_CALL_2(iemOpCommonSse2_Shift_Imm, bRm, iemAImpl_pslldq_imm_u128);
7004}
7005
7006/**
7007 * Group 14 jump table for register variant.
7008 */
7009IEM_STATIC const PFNIEMOPRM g_apfnGroup14RegReg[] =
7010{
7011 /* /0 */ IEMOP_X4(iemOp_InvalidWithRMNeedImm8),
7012 /* /1 */ IEMOP_X4(iemOp_InvalidWithRMNeedImm8),
7013 /* /2 */ iemOp_Grp14_psrlq_Nq_Ib, iemOp_Grp14_psrlq_Ux_Ib, iemOp_InvalidWithRMNeedImm8, iemOp_InvalidWithRMNeedImm8,
7014 /* /3 */ iemOp_InvalidWithRMNeedImm8, iemOp_Grp14_psrldq_Ux_Ib, iemOp_InvalidWithRMNeedImm8, iemOp_InvalidWithRMNeedImm8,
7015 /* /4 */ IEMOP_X4(iemOp_InvalidWithRMNeedImm8),
7016 /* /5 */ IEMOP_X4(iemOp_InvalidWithRMNeedImm8),
7017 /* /6 */ iemOp_Grp14_psllq_Nq_Ib, iemOp_Grp14_psllq_Ux_Ib, iemOp_InvalidWithRMNeedImm8, iemOp_InvalidWithRMNeedImm8,
7018 /* /7 */ iemOp_InvalidWithRMNeedImm8, iemOp_Grp14_pslldq_Ux_Ib, iemOp_InvalidWithRMNeedImm8, iemOp_InvalidWithRMNeedImm8,
7019};
7020AssertCompile(RT_ELEMENTS(g_apfnGroup14RegReg) == 8*4);
7021
7022
7023/** Opcode 0x0f 0x73. */
7024FNIEMOP_DEF(iemOp_Grp14)
7025{
7026 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
7027 if (IEM_IS_MODRM_REG_MODE(bRm))
7028 /* register, register */
7029 return FNIEMOP_CALL_1(g_apfnGroup14RegReg[ IEM_GET_MODRM_REG_8(bRm) * 4
7030 + pVCpu->iem.s.idxPrefix], bRm);
7031 return FNIEMOP_CALL_1(iemOp_InvalidWithRMNeedImm8, bRm);
7032}
7033
7034
7035/** Opcode 0x0f 0x74 - pcmpeqb Pq, Qq */
7036FNIEMOP_DEF(iemOp_pcmpeqb_Pq_Qq)
7037{
7038 IEMOP_MNEMONIC2(RM, PCMPEQB, pcmpeqb, Pq, Qq, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
7039 return FNIEMOP_CALL_1(iemOpCommonMmx_FullFull_To_Full, iemAImpl_pcmpeqb_u64);
7040}
7041
7042
7043/** Opcode 0x66 0x0f 0x74 - pcmpeqb Vx, Wx */
7044FNIEMOP_DEF(iemOp_pcmpeqb_Vx_Wx)
7045{
7046 IEMOP_MNEMONIC2(RM, PCMPEQB, pcmpeqb, Vx, Wx, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
7047 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_pcmpeqb_u128);
7048}
7049
7050
7051/* Opcode 0xf3 0x0f 0x74 - invalid */
7052/* Opcode 0xf2 0x0f 0x74 - invalid */
7053
7054
7055/** Opcode 0x0f 0x75 - pcmpeqw Pq, Qq */
7056FNIEMOP_DEF(iemOp_pcmpeqw_Pq_Qq)
7057{
7058 IEMOP_MNEMONIC2(RM, PCMPEQW, pcmpeqw, Pq, Qq, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
7059 return FNIEMOP_CALL_1(iemOpCommonMmx_FullFull_To_Full, iemAImpl_pcmpeqw_u64);
7060}
7061
7062
7063/** Opcode 0x66 0x0f 0x75 - pcmpeqw Vx, Wx */
7064FNIEMOP_DEF(iemOp_pcmpeqw_Vx_Wx)
7065{
7066 IEMOP_MNEMONIC2(RM, PCMPEQW, pcmpeqw, Vx, Wx, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
7067 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_pcmpeqw_u128);
7068}
7069
7070
7071/* Opcode 0xf3 0x0f 0x75 - invalid */
7072/* Opcode 0xf2 0x0f 0x75 - invalid */
7073
7074
7075/** Opcode 0x0f 0x76 - pcmpeqd Pq, Qq */
7076FNIEMOP_DEF(iemOp_pcmpeqd_Pq_Qq)
7077{
7078 IEMOP_MNEMONIC2(RM, PCMPEQD, pcmpeqd, Pq, Qq, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
7079 return FNIEMOP_CALL_1(iemOpCommonMmx_FullFull_To_Full, iemAImpl_pcmpeqd_u64);
7080}
7081
7082
7083/** Opcode 0x66 0x0f 0x76 - pcmpeqd Vx, Wx */
7084FNIEMOP_DEF(iemOp_pcmpeqd_Vx_Wx)
7085{
7086 IEMOP_MNEMONIC2(RM, PCMPEQD, pcmpeqd, Vx, Wx, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
7087 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_pcmpeqd_u128);
7088}
7089
7090
7091/* Opcode 0xf3 0x0f 0x76 - invalid */
7092/* Opcode 0xf2 0x0f 0x76 - invalid */
7093
7094
7095/** Opcode 0x0f 0x77 - emms (vex has vzeroall and vzeroupper here) */
7096FNIEMOP_DEF(iemOp_emms)
7097{
7098 IEMOP_MNEMONIC(emms, "emms");
7099 IEM_MC_BEGIN(0, 0, 0, 0);
7100 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7101 IEM_MC_MAYBE_RAISE_DEVICE_NOT_AVAILABLE();
7102 IEM_MC_MAYBE_RAISE_FPU_XCPT();
7103 IEM_MC_ACTUALIZE_FPU_STATE_FOR_CHANGE();
7104 IEM_MC_FPU_FROM_MMX_MODE();
7105 IEM_MC_ADVANCE_RIP_AND_FINISH();
7106 IEM_MC_END();
7107}
7108
7109/* Opcode 0x66 0x0f 0x77 - invalid */
7110/* Opcode 0xf3 0x0f 0x77 - invalid */
7111/* Opcode 0xf2 0x0f 0x77 - invalid */
7112
7113/** Opcode 0x0f 0x78 - VMREAD Ey, Gy */
7114#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
7115FNIEMOP_DEF(iemOp_vmread_Ey_Gy)
7116{
7117 IEMOP_MNEMONIC(vmread, "vmread Ey,Gy");
7118 IEMOP_HLP_IN_VMX_OPERATION("vmread", kVmxVDiag_Vmread);
7119 IEMOP_HLP_VMX_INSTR("vmread", kVmxVDiag_Vmread);
7120 IEMMODE const enmEffOpSize = IEM_IS_64BIT_CODE(pVCpu) ? IEMMODE_64BIT : IEMMODE_32BIT;
7121
7122 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
7123 if (IEM_IS_MODRM_REG_MODE(bRm))
7124 {
7125 /*
7126 * Register, register.
7127 */
7128 if (enmEffOpSize == IEMMODE_64BIT)
7129 {
7130 IEM_MC_BEGIN(2, 0, IEM_MC_F_64BIT, 0);
7131 IEMOP_HLP_DONE_DECODING_NO_SIZE_OP_REPZ_OR_REPNZ_PREFIXES();
7132 IEM_MC_ARG(uint64_t *, pu64Dst, 0);
7133 IEM_MC_ARG(uint64_t, u64Enc, 1);
7134 IEM_MC_FETCH_GREG_U64(u64Enc, IEM_GET_MODRM_REG(pVCpu, bRm));
7135 IEM_MC_REF_GREG_U64(pu64Dst, IEM_GET_MODRM_RM(pVCpu, bRm));
7136 IEM_MC_CALL_CIMPL_2(IEM_CIMPL_F_VMEXIT | IEM_CIMPL_F_STATUS_FLAGS,
7137 RT_BIT_64(kIemNativeGstReg_GprFirst + IEM_GET_MODRM_RM(pVCpu, bRm)),
7138 iemCImpl_vmread_reg64, pu64Dst, u64Enc);
7139 IEM_MC_END();
7140 }
7141 else
7142 {
7143 IEM_MC_BEGIN(2, 0, 0, 0);
7144 IEMOP_HLP_DONE_DECODING_NO_SIZE_OP_REPZ_OR_REPNZ_PREFIXES();
7145 IEM_MC_ARG(uint64_t *, pu64Dst, 0);
7146 IEM_MC_ARG(uint32_t, u32Enc, 1);
7147 IEM_MC_FETCH_GREG_U32(u32Enc, IEM_GET_MODRM_REG(pVCpu, bRm));
7148 IEM_MC_REF_GREG_U64(pu64Dst, IEM_GET_MODRM_RM(pVCpu, bRm));
7149 IEM_MC_CALL_CIMPL_2(IEM_CIMPL_F_VMEXIT | IEM_CIMPL_F_STATUS_FLAGS,
7150 RT_BIT_64(kIemNativeGstReg_GprFirst + IEM_GET_MODRM_RM(pVCpu, bRm)),
7151 iemCImpl_vmread_reg32, pu64Dst, u32Enc);
7152 IEM_MC_END();
7153 }
7154 }
7155 else
7156 {
7157 /*
7158 * Memory, register.
7159 */
7160 if (enmEffOpSize == IEMMODE_64BIT)
7161 {
7162 IEM_MC_BEGIN(3, 0, IEM_MC_F_64BIT, 0);
7163 IEM_MC_ARG(RTGCPTR, GCPtrVal, 1);
7164 IEM_MC_CALC_RM_EFF_ADDR(GCPtrVal, bRm, 0);
7165 IEMOP_HLP_DONE_DECODING_NO_SIZE_OP_REPZ_OR_REPNZ_PREFIXES();
7166 IEM_MC_ARG_CONST(uint8_t, iEffSeg, /*=*/ pVCpu->iem.s.iEffSeg, 0);
7167 IEM_MC_ARG(uint64_t, u64Enc, 2);
7168 IEM_MC_FETCH_GREG_U64(u64Enc, IEM_GET_MODRM_REG(pVCpu, bRm));
7169 IEM_MC_CALL_CIMPL_3(IEM_CIMPL_F_VMEXIT | IEM_CIMPL_F_STATUS_FLAGS, 0,
7170 iemCImpl_vmread_mem_reg64, iEffSeg, GCPtrVal, u64Enc);
7171 IEM_MC_END();
7172 }
7173 else
7174 {
7175 IEM_MC_BEGIN(3, 0, 0, 0);
7176 IEM_MC_ARG(RTGCPTR, GCPtrVal, 1);
7177 IEM_MC_CALC_RM_EFF_ADDR(GCPtrVal, bRm, 0);
7178 IEMOP_HLP_DONE_DECODING_NO_SIZE_OP_REPZ_OR_REPNZ_PREFIXES();
7179 IEM_MC_ARG_CONST(uint8_t, iEffSeg, /*=*/ pVCpu->iem.s.iEffSeg, 0);
7180 IEM_MC_ARG(uint32_t, u32Enc, 2);
7181 IEM_MC_FETCH_GREG_U32(u32Enc, IEM_GET_MODRM_REG(pVCpu, bRm));
7182 IEM_MC_CALL_CIMPL_3(IEM_CIMPL_F_VMEXIT | IEM_CIMPL_F_STATUS_FLAGS, 0,
7183 iemCImpl_vmread_mem_reg32, iEffSeg, GCPtrVal, u32Enc);
7184 IEM_MC_END();
7185 }
7186 }
7187}
7188#else
7189FNIEMOP_STUB(iemOp_vmread_Ey_Gy);
7190#endif
7191
7192/* Opcode 0x66 0x0f 0x78 - AMD Group 17 */
7193FNIEMOP_STUB(iemOp_AmdGrp17);
7194/* Opcode 0xf3 0x0f 0x78 - invalid */
7195/* Opcode 0xf2 0x0f 0x78 - invalid */
7196
7197/** Opcode 0x0f 0x79 - VMWRITE Gy, Ey */
7198#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
7199FNIEMOP_DEF(iemOp_vmwrite_Gy_Ey)
7200{
7201 IEMOP_MNEMONIC(vmwrite, "vmwrite Gy,Ey");
7202 IEMOP_HLP_IN_VMX_OPERATION("vmwrite", kVmxVDiag_Vmwrite);
7203 IEMOP_HLP_VMX_INSTR("vmwrite", kVmxVDiag_Vmwrite);
7204 IEMMODE const enmEffOpSize = IEM_IS_64BIT_CODE(pVCpu) ? IEMMODE_64BIT : IEMMODE_32BIT;
7205
7206 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
7207 if (IEM_IS_MODRM_REG_MODE(bRm))
7208 {
7209 /*
7210 * Register, register.
7211 */
7212 if (enmEffOpSize == IEMMODE_64BIT)
7213 {
7214 IEM_MC_BEGIN(2, 0, IEM_MC_F_64BIT, 0);
7215 IEMOP_HLP_DONE_DECODING_NO_SIZE_OP_REPZ_OR_REPNZ_PREFIXES();
7216 IEM_MC_ARG(uint64_t, u64Val, 0);
7217 IEM_MC_ARG(uint64_t, u64Enc, 1);
7218 IEM_MC_FETCH_GREG_U64(u64Val, IEM_GET_MODRM_RM(pVCpu, bRm));
7219 IEM_MC_FETCH_GREG_U64(u64Enc, IEM_GET_MODRM_REG(pVCpu, bRm));
7220 IEM_MC_CALL_CIMPL_2(IEM_CIMPL_F_VMEXIT | IEM_CIMPL_F_STATUS_FLAGS, 0, iemCImpl_vmwrite_reg, u64Val, u64Enc);
7221 IEM_MC_END();
7222 }
7223 else
7224 {
7225 IEM_MC_BEGIN(2, 0, 0, 0);
7226 IEMOP_HLP_DONE_DECODING_NO_SIZE_OP_REPZ_OR_REPNZ_PREFIXES();
7227 IEM_MC_ARG(uint32_t, u32Val, 0);
7228 IEM_MC_ARG(uint32_t, u32Enc, 1);
7229 IEM_MC_FETCH_GREG_U32(u32Val, IEM_GET_MODRM_RM(pVCpu, bRm));
7230 IEM_MC_FETCH_GREG_U32(u32Enc, IEM_GET_MODRM_REG(pVCpu, bRm));
7231 IEM_MC_CALL_CIMPL_2(IEM_CIMPL_F_VMEXIT | IEM_CIMPL_F_STATUS_FLAGS, 0, iemCImpl_vmwrite_reg, u32Val, u32Enc);
7232 IEM_MC_END();
7233 }
7234 }
7235 else
7236 {
7237 /*
7238 * Register, memory.
7239 */
7240 if (enmEffOpSize == IEMMODE_64BIT)
7241 {
7242 IEM_MC_BEGIN(3, 0, IEM_MC_F_64BIT, 0);
7243 IEM_MC_ARG(RTGCPTR, GCPtrVal, 1);
7244 IEM_MC_CALC_RM_EFF_ADDR(GCPtrVal, bRm, 0);
7245 IEMOP_HLP_DONE_DECODING_NO_SIZE_OP_REPZ_OR_REPNZ_PREFIXES();
7246 IEM_MC_ARG_CONST(uint8_t, iEffSeg, /*=*/ pVCpu->iem.s.iEffSeg, 0);
7247 IEM_MC_ARG(uint64_t, u64Enc, 2);
7248 IEM_MC_FETCH_GREG_U64(u64Enc, IEM_GET_MODRM_REG(pVCpu, bRm));
7249 IEM_MC_CALL_CIMPL_3(IEM_CIMPL_F_VMEXIT | IEM_CIMPL_F_STATUS_FLAGS, 0,
7250 iemCImpl_vmwrite_mem, iEffSeg, GCPtrVal, u64Enc);
7251 IEM_MC_END();
7252 }
7253 else
7254 {
7255 IEM_MC_BEGIN(3, 0, 0, 0);
7256 IEM_MC_ARG(RTGCPTR, GCPtrVal, 1);
7257 IEM_MC_CALC_RM_EFF_ADDR(GCPtrVal, bRm, 0);
7258 IEMOP_HLP_DONE_DECODING_NO_SIZE_OP_REPZ_OR_REPNZ_PREFIXES();
7259 IEM_MC_ARG(uint32_t, u32Enc, 2);
7260 IEM_MC_ARG_CONST(uint8_t, iEffSeg, /*=*/ pVCpu->iem.s.iEffSeg, 0);
7261 IEM_MC_FETCH_GREG_U32(u32Enc, IEM_GET_MODRM_REG(pVCpu, bRm));
7262 IEM_MC_CALL_CIMPL_3(IEM_CIMPL_F_VMEXIT | IEM_CIMPL_F_STATUS_FLAGS, 0,
7263 iemCImpl_vmwrite_mem, iEffSeg, GCPtrVal, u32Enc);
7264 IEM_MC_END();
7265 }
7266 }
7267}
7268#else
7269FNIEMOP_STUB(iemOp_vmwrite_Gy_Ey);
7270#endif
7271/* Opcode 0x66 0x0f 0x79 - invalid */
7272/* Opcode 0xf3 0x0f 0x79 - invalid */
7273/* Opcode 0xf2 0x0f 0x79 - invalid */
7274
7275/* Opcode 0x0f 0x7a - invalid */
7276/* Opcode 0x66 0x0f 0x7a - invalid */
7277/* Opcode 0xf3 0x0f 0x7a - invalid */
7278/* Opcode 0xf2 0x0f 0x7a - invalid */
7279
7280/* Opcode 0x0f 0x7b - invalid */
7281/* Opcode 0x66 0x0f 0x7b - invalid */
7282/* Opcode 0xf3 0x0f 0x7b - invalid */
7283/* Opcode 0xf2 0x0f 0x7b - invalid */
7284
7285/* Opcode 0x0f 0x7c - invalid */
7286
7287
7288/** Opcode 0x66 0x0f 0x7c - haddpd Vpd, Wpd */
7289FNIEMOP_DEF(iemOp_haddpd_Vpd_Wpd)
7290{
7291 IEMOP_MNEMONIC2(RM, HADDPD, haddpd, Vpd, Wpd, DISOPTYPE_HARMLESS, 0);
7292 return FNIEMOP_CALL_1(iemOpCommonSse3Fp_FullFull_To_Full, iemAImpl_haddpd_u128);
7293}
7294
7295
7296/* Opcode 0xf3 0x0f 0x7c - invalid */
7297
7298
7299/** Opcode 0xf2 0x0f 0x7c - haddps Vps, Wps */
7300FNIEMOP_DEF(iemOp_haddps_Vps_Wps)
7301{
7302 IEMOP_MNEMONIC2(RM, HADDPS, haddps, Vps, Wps, DISOPTYPE_HARMLESS, 0);
7303 return FNIEMOP_CALL_1(iemOpCommonSse3Fp_FullFull_To_Full, iemAImpl_haddps_u128);
7304}
7305
7306
7307/* Opcode 0x0f 0x7d - invalid */
7308
7309
7310/** Opcode 0x66 0x0f 0x7d - hsubpd Vpd, Wpd */
7311FNIEMOP_DEF(iemOp_hsubpd_Vpd_Wpd)
7312{
7313 IEMOP_MNEMONIC2(RM, HSUBPD, hsubpd, Vpd, Wpd, DISOPTYPE_HARMLESS, 0);
7314 return FNIEMOP_CALL_1(iemOpCommonSse3Fp_FullFull_To_Full, iemAImpl_hsubpd_u128);
7315}
7316
7317
7318/* Opcode 0xf3 0x0f 0x7d - invalid */
7319
7320
7321/** Opcode 0xf2 0x0f 0x7d - hsubps Vps, Wps */
7322FNIEMOP_DEF(iemOp_hsubps_Vps_Wps)
7323{
7324 IEMOP_MNEMONIC2(RM, HSUBPS, hsubps, Vps, Wps, DISOPTYPE_HARMLESS, 0);
7325 return FNIEMOP_CALL_1(iemOpCommonSse3Fp_FullFull_To_Full, iemAImpl_hsubps_u128);
7326}
7327
7328
7329/** Opcode 0x0f 0x7e - movd_q Ey, Pd */
7330FNIEMOP_DEF(iemOp_movd_q_Ey_Pd)
7331{
7332 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
7333 if (pVCpu->iem.s.fPrefixes & IEM_OP_PRF_SIZE_REX_W)
7334 {
7335 /**
7336 * @opcode 0x7e
7337 * @opcodesub rex.w=1
7338 * @oppfx none
7339 * @opcpuid mmx
7340 * @opgroup og_mmx_datamove
7341 * @opxcpttype 5
7342 * @optest 64-bit / op1=1 op2=2 -> op1=2 ftw=0xff
7343 * @optest 64-bit / op1=0 op2=-42 -> op1=-42 ftw=0xff
7344 */
7345 IEMOP_MNEMONIC2(MR, MOVQ, movq, Eq_WO, Pq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, IEMOPHINT_IGNORES_OZ_PFX);
7346 if (IEM_IS_MODRM_REG_MODE(bRm))
7347 {
7348 /* greg64, MMX */
7349 IEM_MC_BEGIN(0, 1, IEM_MC_F_64BIT, 0);
7350 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fMmx);
7351 IEM_MC_LOCAL(uint64_t, u64Tmp);
7352
7353 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
7354 IEM_MC_ACTUALIZE_FPU_STATE_FOR_CHANGE();
7355 IEM_MC_FPU_TO_MMX_MODE();
7356
7357 IEM_MC_FETCH_MREG_U64(u64Tmp, IEM_GET_MODRM_REG_8(bRm));
7358 IEM_MC_STORE_GREG_U64(IEM_GET_MODRM_RM(pVCpu, bRm), u64Tmp);
7359
7360 IEM_MC_ADVANCE_RIP_AND_FINISH();
7361 IEM_MC_END();
7362 }
7363 else
7364 {
7365 /* [mem64], MMX */
7366 IEM_MC_BEGIN(0, 2, IEM_MC_F_64BIT, 0);
7367 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
7368 IEM_MC_LOCAL(uint64_t, u64Tmp);
7369
7370 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
7371 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fMmx);
7372 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
7373 IEM_MC_ACTUALIZE_FPU_STATE_FOR_CHANGE();
7374 IEM_MC_FPU_TO_MMX_MODE();
7375
7376 IEM_MC_FETCH_MREG_U64(u64Tmp, IEM_GET_MODRM_REG_8(bRm));
7377 IEM_MC_STORE_MEM_U64(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, u64Tmp);
7378
7379 IEM_MC_ADVANCE_RIP_AND_FINISH();
7380 IEM_MC_END();
7381 }
7382 }
7383 else
7384 {
7385 /**
7386 * @opdone
7387 * @opcode 0x7e
7388 * @opcodesub rex.w=0
7389 * @oppfx none
7390 * @opcpuid mmx
7391 * @opgroup og_mmx_datamove
7392 * @opxcpttype 5
7393 * @opfunction iemOp_movd_q_Pd_Ey
7394 * @optest op1=1 op2=2 -> op1=2 ftw=0xff
7395 * @optest op1=0 op2=-42 -> op1=-42 ftw=0xff
7396 */
7397 IEMOP_MNEMONIC2(MR, MOVD, movd, Ed_WO, Pd, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, IEMOPHINT_IGNORES_OZ_PFX);
7398 if (IEM_IS_MODRM_REG_MODE(bRm))
7399 {
7400 /* greg32, MMX */
7401 IEM_MC_BEGIN(0, 1, 0, 0);
7402 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fMmx);
7403 IEM_MC_LOCAL(uint32_t, u32Tmp);
7404
7405 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
7406 IEM_MC_ACTUALIZE_FPU_STATE_FOR_CHANGE();
7407 IEM_MC_FPU_TO_MMX_MODE();
7408
7409 IEM_MC_FETCH_MREG_U32(u32Tmp, IEM_GET_MODRM_REG_8(bRm));
7410 IEM_MC_STORE_GREG_U32(IEM_GET_MODRM_RM(pVCpu, bRm), u32Tmp);
7411
7412 IEM_MC_ADVANCE_RIP_AND_FINISH();
7413 IEM_MC_END();
7414 }
7415 else
7416 {
7417 /* [mem32], MMX */
7418 IEM_MC_BEGIN(0, 2, 0, 0);
7419 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
7420 IEM_MC_LOCAL(uint32_t, u32Tmp);
7421
7422 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
7423 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fMmx);
7424 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
7425 IEM_MC_ACTUALIZE_FPU_STATE_FOR_CHANGE();
7426 IEM_MC_FPU_TO_MMX_MODE();
7427
7428 IEM_MC_FETCH_MREG_U32(u32Tmp, IEM_GET_MODRM_REG_8(bRm));
7429 IEM_MC_STORE_MEM_U32(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, u32Tmp);
7430
7431 IEM_MC_ADVANCE_RIP_AND_FINISH();
7432 IEM_MC_END();
7433 }
7434 }
7435}
7436
7437
7438FNIEMOP_DEF(iemOp_movd_q_Ey_Vy)
7439{
7440 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
7441 if (pVCpu->iem.s.fPrefixes & IEM_OP_PRF_SIZE_REX_W)
7442 {
7443 /**
7444 * @opcode 0x7e
7445 * @opcodesub rex.w=1
7446 * @oppfx 0x66
7447 * @opcpuid sse2
7448 * @opgroup og_sse2_simdint_datamove
7449 * @opxcpttype 5
7450 * @optest 64-bit / op1=1 op2=2 -> op1=2
7451 * @optest 64-bit / op1=0 op2=-42 -> op1=-42
7452 */
7453 IEMOP_MNEMONIC2(MR, MOVQ, movq, Eq_WO, Vq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OZ_PFX);
7454 if (IEM_IS_MODRM_REG_MODE(bRm))
7455 {
7456 /* greg64, XMM */
7457 IEM_MC_BEGIN(0, 1, IEM_MC_F_64BIT, 0);
7458 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
7459 IEM_MC_LOCAL(uint64_t, u64Tmp);
7460
7461 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
7462 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
7463
7464 IEM_MC_FETCH_XREG_U64(u64Tmp, IEM_GET_MODRM_REG(pVCpu, bRm), 0 /* a_iQword*/);
7465 IEM_MC_STORE_GREG_U64(IEM_GET_MODRM_RM(pVCpu, bRm), u64Tmp);
7466
7467 IEM_MC_ADVANCE_RIP_AND_FINISH();
7468 IEM_MC_END();
7469 }
7470 else
7471 {
7472 /* [mem64], XMM */
7473 IEM_MC_BEGIN(0, 2, IEM_MC_F_64BIT, 0);
7474 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
7475 IEM_MC_LOCAL(uint64_t, u64Tmp);
7476
7477 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
7478 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
7479 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
7480 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
7481
7482 IEM_MC_FETCH_XREG_U64(u64Tmp, IEM_GET_MODRM_REG(pVCpu, bRm), 0 /* a_iQword*/);
7483 IEM_MC_STORE_MEM_U64(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, u64Tmp);
7484
7485 IEM_MC_ADVANCE_RIP_AND_FINISH();
7486 IEM_MC_END();
7487 }
7488 }
7489 else
7490 {
7491 /**
7492 * @opdone
7493 * @opcode 0x7e
7494 * @opcodesub rex.w=0
7495 * @oppfx 0x66
7496 * @opcpuid sse2
7497 * @opgroup og_sse2_simdint_datamove
7498 * @opxcpttype 5
7499 * @opfunction iemOp_movd_q_Vy_Ey
7500 * @optest op1=1 op2=2 -> op1=2
7501 * @optest op1=0 op2=-42 -> op1=-42
7502 */
7503 IEMOP_MNEMONIC2(MR, MOVD, movd, Ed_WO, Vd, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OZ_PFX);
7504 if (IEM_IS_MODRM_REG_MODE(bRm))
7505 {
7506 /* greg32, XMM */
7507 IEM_MC_BEGIN(0, 1, 0, 0);
7508 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
7509 IEM_MC_LOCAL(uint32_t, u32Tmp);
7510
7511 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
7512 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
7513
7514 IEM_MC_FETCH_XREG_U32(u32Tmp, IEM_GET_MODRM_REG(pVCpu, bRm), 0 /*a_iDword*/);
7515 IEM_MC_STORE_GREG_U32(IEM_GET_MODRM_RM(pVCpu, bRm), u32Tmp);
7516
7517 IEM_MC_ADVANCE_RIP_AND_FINISH();
7518 IEM_MC_END();
7519 }
7520 else
7521 {
7522 /* [mem32], XMM */
7523 IEM_MC_BEGIN(0, 2, 0, 0);
7524 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
7525 IEM_MC_LOCAL(uint32_t, u32Tmp);
7526
7527 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
7528 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
7529 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
7530 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
7531
7532 IEM_MC_FETCH_XREG_U32(u32Tmp, IEM_GET_MODRM_REG(pVCpu, bRm), 0 /*a_iDword*/);
7533 IEM_MC_STORE_MEM_U32(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, u32Tmp);
7534
7535 IEM_MC_ADVANCE_RIP_AND_FINISH();
7536 IEM_MC_END();
7537 }
7538 }
7539}
7540
7541/**
7542 * @opcode 0x7e
7543 * @oppfx 0xf3
7544 * @opcpuid sse2
7545 * @opgroup og_sse2_pcksclr_datamove
7546 * @opxcpttype none
7547 * @optest op1=1 op2=2 -> op1=2
7548 * @optest op1=0 op2=-42 -> op1=-42
7549 */
7550FNIEMOP_DEF(iemOp_movq_Vq_Wq)
7551{
7552 IEMOP_MNEMONIC2(RM, MOVQ, movq, VqZx_WO, Wq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
7553 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
7554 if (IEM_IS_MODRM_REG_MODE(bRm))
7555 {
7556 /*
7557 * XMM128, XMM64.
7558 */
7559 IEM_MC_BEGIN(0, 2, 0, 0);
7560 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
7561 IEM_MC_LOCAL(uint64_t, uSrc);
7562
7563 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
7564 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
7565
7566 IEM_MC_FETCH_XREG_U64(uSrc, IEM_GET_MODRM_RM(pVCpu, bRm), 0 /* a_iQword*/);
7567 IEM_MC_STORE_XREG_U64_ZX_U128(IEM_GET_MODRM_REG(pVCpu, bRm), uSrc);
7568
7569 IEM_MC_ADVANCE_RIP_AND_FINISH();
7570 IEM_MC_END();
7571 }
7572 else
7573 {
7574 /*
7575 * XMM128, [mem64].
7576 */
7577 IEM_MC_BEGIN(0, 2, 0, 0);
7578 IEM_MC_LOCAL(uint64_t, uSrc);
7579 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
7580
7581 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
7582 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
7583 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
7584 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
7585
7586 IEM_MC_FETCH_MEM_U64(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
7587 IEM_MC_STORE_XREG_U64_ZX_U128(IEM_GET_MODRM_REG(pVCpu, bRm), uSrc);
7588
7589 IEM_MC_ADVANCE_RIP_AND_FINISH();
7590 IEM_MC_END();
7591 }
7592}
7593
7594/* Opcode 0xf2 0x0f 0x7e - invalid */
7595
7596
7597/** Opcode 0x0f 0x7f - movq Qq, Pq */
7598FNIEMOP_DEF(iemOp_movq_Qq_Pq)
7599{
7600 IEMOP_MNEMONIC2(MR, MOVQ, movq, Qq_WO, Pq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, IEMOPHINT_IGNORES_OZ_PFX | IEMOPHINT_IGNORES_REXW);
7601 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
7602 if (IEM_IS_MODRM_REG_MODE(bRm))
7603 {
7604 /*
7605 * MMX, MMX.
7606 */
7607 /** @todo testcase: REX.B / REX.R and MMX register indexing. Ignored? */
7608 /** @todo testcase: REX.B / REX.R and segment register indexing. Ignored? */
7609 IEM_MC_BEGIN(0, 1, 0, 0);
7610 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fMmx);
7611 IEM_MC_LOCAL(uint64_t, u64Tmp);
7612 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
7613 IEM_MC_ACTUALIZE_FPU_STATE_FOR_CHANGE();
7614 IEM_MC_FPU_TO_MMX_MODE();
7615
7616 IEM_MC_FETCH_MREG_U64(u64Tmp, IEM_GET_MODRM_REG_8(bRm));
7617 IEM_MC_STORE_MREG_U64(IEM_GET_MODRM_RM_8(bRm), u64Tmp);
7618
7619 IEM_MC_ADVANCE_RIP_AND_FINISH();
7620 IEM_MC_END();
7621 }
7622 else
7623 {
7624 /*
7625 * [mem64], MMX.
7626 */
7627 IEM_MC_BEGIN(0, 2, 0, 0);
7628 IEM_MC_LOCAL(uint64_t, u64Tmp);
7629 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
7630
7631 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
7632 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fMmx);
7633 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
7634 IEM_MC_ACTUALIZE_FPU_STATE_FOR_CHANGE();
7635 IEM_MC_FPU_TO_MMX_MODE();
7636
7637 IEM_MC_FETCH_MREG_U64(u64Tmp, IEM_GET_MODRM_REG_8(bRm));
7638 IEM_MC_STORE_MEM_U64(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, u64Tmp);
7639
7640 IEM_MC_ADVANCE_RIP_AND_FINISH();
7641 IEM_MC_END();
7642 }
7643}
7644
7645/** Opcode 0x66 0x0f 0x7f - movdqa Wx,Vx */
7646FNIEMOP_DEF(iemOp_movdqa_Wx_Vx)
7647{
7648 IEMOP_MNEMONIC2(MR, MOVDQA, movdqa, Wx_WO, Vx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
7649 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
7650 if (IEM_IS_MODRM_REG_MODE(bRm))
7651 {
7652 /*
7653 * XMM, XMM.
7654 */
7655 IEM_MC_BEGIN(0, 0, 0, 0);
7656 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
7657 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
7658 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
7659 IEM_MC_COPY_XREG_U128(IEM_GET_MODRM_RM(pVCpu, bRm),
7660 IEM_GET_MODRM_REG(pVCpu, bRm));
7661 IEM_MC_ADVANCE_RIP_AND_FINISH();
7662 IEM_MC_END();
7663 }
7664 else
7665 {
7666 /*
7667 * [mem128], XMM.
7668 */
7669 IEM_MC_BEGIN(0, 2, 0, 0);
7670 IEM_MC_LOCAL(RTUINT128U, u128Tmp);
7671 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
7672
7673 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
7674 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
7675 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
7676 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
7677
7678 IEM_MC_FETCH_XREG_U128(u128Tmp, IEM_GET_MODRM_REG(pVCpu, bRm));
7679 IEM_MC_STORE_MEM_U128_ALIGN_SSE(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, u128Tmp);
7680
7681 IEM_MC_ADVANCE_RIP_AND_FINISH();
7682 IEM_MC_END();
7683 }
7684}
7685
7686/** Opcode 0xf3 0x0f 0x7f - movdqu Wx,Vx */
7687FNIEMOP_DEF(iemOp_movdqu_Wx_Vx)
7688{
7689 IEMOP_MNEMONIC2(MR, MOVDQU, movdqu, Wx_WO, Vx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
7690 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
7691 if (IEM_IS_MODRM_REG_MODE(bRm))
7692 {
7693 /*
7694 * XMM, XMM.
7695 */
7696 IEM_MC_BEGIN(0, 0, 0, 0);
7697 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
7698 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
7699 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
7700 IEM_MC_COPY_XREG_U128(IEM_GET_MODRM_RM(pVCpu, bRm),
7701 IEM_GET_MODRM_REG(pVCpu, bRm));
7702 IEM_MC_ADVANCE_RIP_AND_FINISH();
7703 IEM_MC_END();
7704 }
7705 else
7706 {
7707 /*
7708 * [mem128], XMM.
7709 */
7710 IEM_MC_BEGIN(0, 2, 0, 0);
7711 IEM_MC_LOCAL(RTUINT128U, u128Tmp);
7712 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
7713
7714 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
7715 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
7716 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
7717 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
7718
7719 IEM_MC_FETCH_XREG_U128(u128Tmp, IEM_GET_MODRM_REG(pVCpu, bRm));
7720 IEM_MC_STORE_MEM_U128(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, u128Tmp);
7721
7722 IEM_MC_ADVANCE_RIP_AND_FINISH();
7723 IEM_MC_END();
7724 }
7725}
7726
7727/* Opcode 0xf2 0x0f 0x7f - invalid */
7728
7729
7730
7731/** Opcode 0x0f 0x80. */
7732FNIEMOP_DEF(iemOp_jo_Jv)
7733{
7734 IEMOP_MNEMONIC(jo_Jv, "jo Jv");
7735 IEMOP_HLP_MIN_386();
7736 IEMOP_HLP_DEFAULT_64BIT_OP_SIZE_AND_INTEL_IGNORES_OP_SIZE_PREFIX();
7737 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_16BIT)
7738 {
7739 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
7740 int16_t i16Imm; IEM_OPCODE_GET_NEXT_S16(&i16Imm);
7741 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7742 IEM_MC_IF_EFL_BIT_SET(X86_EFL_OF) {
7743 IEM_MC_REL_JMP_S16_AND_FINISH(i16Imm);
7744 } IEM_MC_ELSE() {
7745 IEM_MC_ADVANCE_RIP_AND_FINISH();
7746 } IEM_MC_ENDIF();
7747 IEM_MC_END();
7748 }
7749 else
7750 {
7751 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
7752 int32_t i32Imm; IEM_OPCODE_GET_NEXT_S32(&i32Imm);
7753 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7754 IEM_MC_IF_EFL_BIT_SET(X86_EFL_OF) {
7755 IEM_MC_REL_JMP_S32_AND_FINISH(i32Imm);
7756 } IEM_MC_ELSE() {
7757 IEM_MC_ADVANCE_RIP_AND_FINISH();
7758 } IEM_MC_ENDIF();
7759 IEM_MC_END();
7760 }
7761}
7762
7763
7764/** Opcode 0x0f 0x81. */
7765FNIEMOP_DEF(iemOp_jno_Jv)
7766{
7767 IEMOP_MNEMONIC(jno_Jv, "jno Jv");
7768 IEMOP_HLP_MIN_386();
7769 IEMOP_HLP_DEFAULT_64BIT_OP_SIZE_AND_INTEL_IGNORES_OP_SIZE_PREFIX();
7770 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_16BIT)
7771 {
7772 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
7773 int16_t i16Imm; IEM_OPCODE_GET_NEXT_S16(&i16Imm);
7774 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7775 IEM_MC_IF_EFL_BIT_SET(X86_EFL_OF) {
7776 IEM_MC_ADVANCE_RIP_AND_FINISH();
7777 } IEM_MC_ELSE() {
7778 IEM_MC_REL_JMP_S16_AND_FINISH(i16Imm);
7779 } IEM_MC_ENDIF();
7780 IEM_MC_END();
7781 }
7782 else
7783 {
7784 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
7785 int32_t i32Imm; IEM_OPCODE_GET_NEXT_S32(&i32Imm);
7786 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7787 IEM_MC_IF_EFL_BIT_SET(X86_EFL_OF) {
7788 IEM_MC_ADVANCE_RIP_AND_FINISH();
7789 } IEM_MC_ELSE() {
7790 IEM_MC_REL_JMP_S32_AND_FINISH(i32Imm);
7791 } IEM_MC_ENDIF();
7792 IEM_MC_END();
7793 }
7794}
7795
7796
7797/** Opcode 0x0f 0x82. */
7798FNIEMOP_DEF(iemOp_jc_Jv)
7799{
7800 IEMOP_MNEMONIC(jc_Jv, "jc/jb/jnae Jv");
7801 IEMOP_HLP_MIN_386();
7802 IEMOP_HLP_DEFAULT_64BIT_OP_SIZE_AND_INTEL_IGNORES_OP_SIZE_PREFIX();
7803 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_16BIT)
7804 {
7805 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
7806 int16_t i16Imm; IEM_OPCODE_GET_NEXT_S16(&i16Imm);
7807 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7808 IEM_MC_IF_EFL_BIT_SET(X86_EFL_CF) {
7809 IEM_MC_REL_JMP_S16_AND_FINISH(i16Imm);
7810 } IEM_MC_ELSE() {
7811 IEM_MC_ADVANCE_RIP_AND_FINISH();
7812 } IEM_MC_ENDIF();
7813 IEM_MC_END();
7814 }
7815 else
7816 {
7817 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
7818 int32_t i32Imm; IEM_OPCODE_GET_NEXT_S32(&i32Imm);
7819 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7820 IEM_MC_IF_EFL_BIT_SET(X86_EFL_CF) {
7821 IEM_MC_REL_JMP_S32_AND_FINISH(i32Imm);
7822 } IEM_MC_ELSE() {
7823 IEM_MC_ADVANCE_RIP_AND_FINISH();
7824 } IEM_MC_ENDIF();
7825 IEM_MC_END();
7826 }
7827}
7828
7829
7830/** Opcode 0x0f 0x83. */
7831FNIEMOP_DEF(iemOp_jnc_Jv)
7832{
7833 IEMOP_MNEMONIC(jnc_Jv, "jnc/jnb/jae Jv");
7834 IEMOP_HLP_MIN_386();
7835 IEMOP_HLP_DEFAULT_64BIT_OP_SIZE_AND_INTEL_IGNORES_OP_SIZE_PREFIX();
7836 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_16BIT)
7837 {
7838 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
7839 int16_t i16Imm; IEM_OPCODE_GET_NEXT_S16(&i16Imm);
7840 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7841 IEM_MC_IF_EFL_BIT_SET(X86_EFL_CF) {
7842 IEM_MC_ADVANCE_RIP_AND_FINISH();
7843 } IEM_MC_ELSE() {
7844 IEM_MC_REL_JMP_S16_AND_FINISH(i16Imm);
7845 } IEM_MC_ENDIF();
7846 IEM_MC_END();
7847 }
7848 else
7849 {
7850 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
7851 int32_t i32Imm; IEM_OPCODE_GET_NEXT_S32(&i32Imm);
7852 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7853 IEM_MC_IF_EFL_BIT_SET(X86_EFL_CF) {
7854 IEM_MC_ADVANCE_RIP_AND_FINISH();
7855 } IEM_MC_ELSE() {
7856 IEM_MC_REL_JMP_S32_AND_FINISH(i32Imm);
7857 } IEM_MC_ENDIF();
7858 IEM_MC_END();
7859 }
7860}
7861
7862
7863/** Opcode 0x0f 0x84. */
7864FNIEMOP_DEF(iemOp_je_Jv)
7865{
7866 IEMOP_MNEMONIC(je_Jv, "je/jz Jv");
7867 IEMOP_HLP_MIN_386();
7868 IEMOP_HLP_DEFAULT_64BIT_OP_SIZE_AND_INTEL_IGNORES_OP_SIZE_PREFIX();
7869 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_16BIT)
7870 {
7871 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
7872 int16_t i16Imm; IEM_OPCODE_GET_NEXT_S16(&i16Imm);
7873 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7874 IEM_MC_IF_EFL_BIT_SET(X86_EFL_ZF) {
7875 IEM_MC_REL_JMP_S16_AND_FINISH(i16Imm);
7876 } IEM_MC_ELSE() {
7877 IEM_MC_ADVANCE_RIP_AND_FINISH();
7878 } IEM_MC_ENDIF();
7879 IEM_MC_END();
7880 }
7881 else
7882 {
7883 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
7884 int32_t i32Imm; IEM_OPCODE_GET_NEXT_S32(&i32Imm);
7885 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7886 IEM_MC_IF_EFL_BIT_SET(X86_EFL_ZF) {
7887 IEM_MC_REL_JMP_S32_AND_FINISH(i32Imm);
7888 } IEM_MC_ELSE() {
7889 IEM_MC_ADVANCE_RIP_AND_FINISH();
7890 } IEM_MC_ENDIF();
7891 IEM_MC_END();
7892 }
7893}
7894
7895
7896/** Opcode 0x0f 0x85. */
7897FNIEMOP_DEF(iemOp_jne_Jv)
7898{
7899 IEMOP_MNEMONIC(jne_Jv, "jne/jnz Jv");
7900 IEMOP_HLP_MIN_386();
7901 IEMOP_HLP_DEFAULT_64BIT_OP_SIZE_AND_INTEL_IGNORES_OP_SIZE_PREFIX();
7902 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_16BIT)
7903 {
7904 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
7905 int16_t i16Imm; IEM_OPCODE_GET_NEXT_S16(&i16Imm);
7906 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7907 IEM_MC_IF_EFL_BIT_SET(X86_EFL_ZF) {
7908 IEM_MC_ADVANCE_RIP_AND_FINISH();
7909 } IEM_MC_ELSE() {
7910 IEM_MC_REL_JMP_S16_AND_FINISH(i16Imm);
7911 } IEM_MC_ENDIF();
7912 IEM_MC_END();
7913 }
7914 else
7915 {
7916 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
7917 int32_t i32Imm; IEM_OPCODE_GET_NEXT_S32(&i32Imm);
7918 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7919 IEM_MC_IF_EFL_BIT_SET(X86_EFL_ZF) {
7920 IEM_MC_ADVANCE_RIP_AND_FINISH();
7921 } IEM_MC_ELSE() {
7922 IEM_MC_REL_JMP_S32_AND_FINISH(i32Imm);
7923 } IEM_MC_ENDIF();
7924 IEM_MC_END();
7925 }
7926}
7927
7928
7929/** Opcode 0x0f 0x86. */
7930FNIEMOP_DEF(iemOp_jbe_Jv)
7931{
7932 IEMOP_MNEMONIC(jbe_Jv, "jbe/jna Jv");
7933 IEMOP_HLP_MIN_386();
7934 IEMOP_HLP_DEFAULT_64BIT_OP_SIZE_AND_INTEL_IGNORES_OP_SIZE_PREFIX();
7935 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_16BIT)
7936 {
7937 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
7938 int16_t i16Imm; IEM_OPCODE_GET_NEXT_S16(&i16Imm);
7939 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7940 IEM_MC_IF_EFL_ANY_BITS_SET(X86_EFL_CF | X86_EFL_ZF) {
7941 IEM_MC_REL_JMP_S16_AND_FINISH(i16Imm);
7942 } IEM_MC_ELSE() {
7943 IEM_MC_ADVANCE_RIP_AND_FINISH();
7944 } IEM_MC_ENDIF();
7945 IEM_MC_END();
7946 }
7947 else
7948 {
7949 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
7950 int32_t i32Imm; IEM_OPCODE_GET_NEXT_S32(&i32Imm);
7951 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7952 IEM_MC_IF_EFL_ANY_BITS_SET(X86_EFL_CF | X86_EFL_ZF) {
7953 IEM_MC_REL_JMP_S32_AND_FINISH(i32Imm);
7954 } IEM_MC_ELSE() {
7955 IEM_MC_ADVANCE_RIP_AND_FINISH();
7956 } IEM_MC_ENDIF();
7957 IEM_MC_END();
7958 }
7959}
7960
7961
7962/** Opcode 0x0f 0x87. */
7963FNIEMOP_DEF(iemOp_jnbe_Jv)
7964{
7965 IEMOP_MNEMONIC(ja_Jv, "jnbe/ja Jv");
7966 IEMOP_HLP_MIN_386();
7967 IEMOP_HLP_DEFAULT_64BIT_OP_SIZE_AND_INTEL_IGNORES_OP_SIZE_PREFIX();
7968 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_16BIT)
7969 {
7970 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
7971 int16_t i16Imm; IEM_OPCODE_GET_NEXT_S16(&i16Imm);
7972 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7973 IEM_MC_IF_EFL_ANY_BITS_SET(X86_EFL_CF | X86_EFL_ZF) {
7974 IEM_MC_ADVANCE_RIP_AND_FINISH();
7975 } IEM_MC_ELSE() {
7976 IEM_MC_REL_JMP_S16_AND_FINISH(i16Imm);
7977 } IEM_MC_ENDIF();
7978 IEM_MC_END();
7979 }
7980 else
7981 {
7982 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
7983 int32_t i32Imm; IEM_OPCODE_GET_NEXT_S32(&i32Imm);
7984 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7985 IEM_MC_IF_EFL_ANY_BITS_SET(X86_EFL_CF | X86_EFL_ZF) {
7986 IEM_MC_ADVANCE_RIP_AND_FINISH();
7987 } IEM_MC_ELSE() {
7988 IEM_MC_REL_JMP_S32_AND_FINISH(i32Imm);
7989 } IEM_MC_ENDIF();
7990 IEM_MC_END();
7991 }
7992}
7993
7994
7995/** Opcode 0x0f 0x88. */
7996FNIEMOP_DEF(iemOp_js_Jv)
7997{
7998 IEMOP_MNEMONIC(js_Jv, "js Jv");
7999 IEMOP_HLP_MIN_386();
8000 IEMOP_HLP_DEFAULT_64BIT_OP_SIZE_AND_INTEL_IGNORES_OP_SIZE_PREFIX();
8001 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_16BIT)
8002 {
8003 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
8004 int16_t i16Imm; IEM_OPCODE_GET_NEXT_S16(&i16Imm);
8005 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8006 IEM_MC_IF_EFL_BIT_SET(X86_EFL_SF) {
8007 IEM_MC_REL_JMP_S16_AND_FINISH(i16Imm);
8008 } IEM_MC_ELSE() {
8009 IEM_MC_ADVANCE_RIP_AND_FINISH();
8010 } IEM_MC_ENDIF();
8011 IEM_MC_END();
8012 }
8013 else
8014 {
8015 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
8016 int32_t i32Imm; IEM_OPCODE_GET_NEXT_S32(&i32Imm);
8017 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8018 IEM_MC_IF_EFL_BIT_SET(X86_EFL_SF) {
8019 IEM_MC_REL_JMP_S32_AND_FINISH(i32Imm);
8020 } IEM_MC_ELSE() {
8021 IEM_MC_ADVANCE_RIP_AND_FINISH();
8022 } IEM_MC_ENDIF();
8023 IEM_MC_END();
8024 }
8025}
8026
8027
8028/** Opcode 0x0f 0x89. */
8029FNIEMOP_DEF(iemOp_jns_Jv)
8030{
8031 IEMOP_MNEMONIC(jns_Jv, "jns Jv");
8032 IEMOP_HLP_MIN_386();
8033 IEMOP_HLP_DEFAULT_64BIT_OP_SIZE_AND_INTEL_IGNORES_OP_SIZE_PREFIX();
8034 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_16BIT)
8035 {
8036 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
8037 int16_t i16Imm; IEM_OPCODE_GET_NEXT_S16(&i16Imm);
8038 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8039 IEM_MC_IF_EFL_BIT_SET(X86_EFL_SF) {
8040 IEM_MC_ADVANCE_RIP_AND_FINISH();
8041 } IEM_MC_ELSE() {
8042 IEM_MC_REL_JMP_S16_AND_FINISH(i16Imm);
8043 } IEM_MC_ENDIF();
8044 IEM_MC_END();
8045 }
8046 else
8047 {
8048 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
8049 int32_t i32Imm; IEM_OPCODE_GET_NEXT_S32(&i32Imm);
8050 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8051 IEM_MC_IF_EFL_BIT_SET(X86_EFL_SF) {
8052 IEM_MC_ADVANCE_RIP_AND_FINISH();
8053 } IEM_MC_ELSE() {
8054 IEM_MC_REL_JMP_S32_AND_FINISH(i32Imm);
8055 } IEM_MC_ENDIF();
8056 IEM_MC_END();
8057 }
8058}
8059
8060
8061/** Opcode 0x0f 0x8a. */
8062FNIEMOP_DEF(iemOp_jp_Jv)
8063{
8064 IEMOP_MNEMONIC(jp_Jv, "jp Jv");
8065 IEMOP_HLP_MIN_386();
8066 IEMOP_HLP_DEFAULT_64BIT_OP_SIZE_AND_INTEL_IGNORES_OP_SIZE_PREFIX();
8067 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_16BIT)
8068 {
8069 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
8070 int16_t i16Imm; IEM_OPCODE_GET_NEXT_S16(&i16Imm);
8071 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8072 IEM_MC_IF_EFL_BIT_SET(X86_EFL_PF) {
8073 IEM_MC_REL_JMP_S16_AND_FINISH(i16Imm);
8074 } IEM_MC_ELSE() {
8075 IEM_MC_ADVANCE_RIP_AND_FINISH();
8076 } IEM_MC_ENDIF();
8077 IEM_MC_END();
8078 }
8079 else
8080 {
8081 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
8082 int32_t i32Imm; IEM_OPCODE_GET_NEXT_S32(&i32Imm);
8083 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8084 IEM_MC_IF_EFL_BIT_SET(X86_EFL_PF) {
8085 IEM_MC_REL_JMP_S32_AND_FINISH(i32Imm);
8086 } IEM_MC_ELSE() {
8087 IEM_MC_ADVANCE_RIP_AND_FINISH();
8088 } IEM_MC_ENDIF();
8089 IEM_MC_END();
8090 }
8091}
8092
8093
8094/** Opcode 0x0f 0x8b. */
8095FNIEMOP_DEF(iemOp_jnp_Jv)
8096{
8097 IEMOP_MNEMONIC(jnp_Jv, "jnp Jv");
8098 IEMOP_HLP_MIN_386();
8099 IEMOP_HLP_DEFAULT_64BIT_OP_SIZE_AND_INTEL_IGNORES_OP_SIZE_PREFIX();
8100 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_16BIT)
8101 {
8102 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
8103 int16_t i16Imm; IEM_OPCODE_GET_NEXT_S16(&i16Imm);
8104 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8105 IEM_MC_IF_EFL_BIT_SET(X86_EFL_PF) {
8106 IEM_MC_ADVANCE_RIP_AND_FINISH();
8107 } IEM_MC_ELSE() {
8108 IEM_MC_REL_JMP_S16_AND_FINISH(i16Imm);
8109 } IEM_MC_ENDIF();
8110 IEM_MC_END();
8111 }
8112 else
8113 {
8114 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
8115 int32_t i32Imm; IEM_OPCODE_GET_NEXT_S32(&i32Imm);
8116 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8117 IEM_MC_IF_EFL_BIT_SET(X86_EFL_PF) {
8118 IEM_MC_ADVANCE_RIP_AND_FINISH();
8119 } IEM_MC_ELSE() {
8120 IEM_MC_REL_JMP_S32_AND_FINISH(i32Imm);
8121 } IEM_MC_ENDIF();
8122 IEM_MC_END();
8123 }
8124}
8125
8126
8127/** Opcode 0x0f 0x8c. */
8128FNIEMOP_DEF(iemOp_jl_Jv)
8129{
8130 IEMOP_MNEMONIC(jl_Jv, "jl/jnge Jv");
8131 IEMOP_HLP_MIN_386();
8132 IEMOP_HLP_DEFAULT_64BIT_OP_SIZE_AND_INTEL_IGNORES_OP_SIZE_PREFIX();
8133 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_16BIT)
8134 {
8135 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
8136 int16_t i16Imm; IEM_OPCODE_GET_NEXT_S16(&i16Imm);
8137 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8138 IEM_MC_IF_EFL_BITS_NE(X86_EFL_SF, X86_EFL_OF) {
8139 IEM_MC_REL_JMP_S16_AND_FINISH(i16Imm);
8140 } IEM_MC_ELSE() {
8141 IEM_MC_ADVANCE_RIP_AND_FINISH();
8142 } IEM_MC_ENDIF();
8143 IEM_MC_END();
8144 }
8145 else
8146 {
8147 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
8148 int32_t i32Imm; IEM_OPCODE_GET_NEXT_S32(&i32Imm);
8149 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8150 IEM_MC_IF_EFL_BITS_NE(X86_EFL_SF, X86_EFL_OF) {
8151 IEM_MC_REL_JMP_S32_AND_FINISH(i32Imm);
8152 } IEM_MC_ELSE() {
8153 IEM_MC_ADVANCE_RIP_AND_FINISH();
8154 } IEM_MC_ENDIF();
8155 IEM_MC_END();
8156 }
8157}
8158
8159
8160/** Opcode 0x0f 0x8d. */
8161FNIEMOP_DEF(iemOp_jnl_Jv)
8162{
8163 IEMOP_MNEMONIC(jge_Jv, "jnl/jge Jv");
8164 IEMOP_HLP_MIN_386();
8165 IEMOP_HLP_DEFAULT_64BIT_OP_SIZE_AND_INTEL_IGNORES_OP_SIZE_PREFIX();
8166 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_16BIT)
8167 {
8168 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
8169 int16_t i16Imm; IEM_OPCODE_GET_NEXT_S16(&i16Imm);
8170 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8171 IEM_MC_IF_EFL_BITS_NE(X86_EFL_SF, X86_EFL_OF) {
8172 IEM_MC_ADVANCE_RIP_AND_FINISH();
8173 } IEM_MC_ELSE() {
8174 IEM_MC_REL_JMP_S16_AND_FINISH(i16Imm);
8175 } IEM_MC_ENDIF();
8176 IEM_MC_END();
8177 }
8178 else
8179 {
8180 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
8181 int32_t i32Imm; IEM_OPCODE_GET_NEXT_S32(&i32Imm);
8182 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8183 IEM_MC_IF_EFL_BITS_NE(X86_EFL_SF, X86_EFL_OF) {
8184 IEM_MC_ADVANCE_RIP_AND_FINISH();
8185 } IEM_MC_ELSE() {
8186 IEM_MC_REL_JMP_S32_AND_FINISH(i32Imm);
8187 } IEM_MC_ENDIF();
8188 IEM_MC_END();
8189 }
8190}
8191
8192
8193/** Opcode 0x0f 0x8e. */
8194FNIEMOP_DEF(iemOp_jle_Jv)
8195{
8196 IEMOP_MNEMONIC(jle_Jv, "jle/jng Jv");
8197 IEMOP_HLP_MIN_386();
8198 IEMOP_HLP_DEFAULT_64BIT_OP_SIZE_AND_INTEL_IGNORES_OP_SIZE_PREFIX();
8199 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_16BIT)
8200 {
8201 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
8202 int16_t i16Imm; IEM_OPCODE_GET_NEXT_S16(&i16Imm);
8203 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8204 IEM_MC_IF_EFL_BIT_SET_OR_BITS_NE(X86_EFL_ZF, X86_EFL_SF, X86_EFL_OF) {
8205 IEM_MC_REL_JMP_S16_AND_FINISH(i16Imm);
8206 } IEM_MC_ELSE() {
8207 IEM_MC_ADVANCE_RIP_AND_FINISH();
8208 } IEM_MC_ENDIF();
8209 IEM_MC_END();
8210 }
8211 else
8212 {
8213 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
8214 int32_t i32Imm; IEM_OPCODE_GET_NEXT_S32(&i32Imm);
8215 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8216 IEM_MC_IF_EFL_BIT_SET_OR_BITS_NE(X86_EFL_ZF, X86_EFL_SF, X86_EFL_OF) {
8217 IEM_MC_REL_JMP_S32_AND_FINISH(i32Imm);
8218 } IEM_MC_ELSE() {
8219 IEM_MC_ADVANCE_RIP_AND_FINISH();
8220 } IEM_MC_ENDIF();
8221 IEM_MC_END();
8222 }
8223}
8224
8225
8226/** Opcode 0x0f 0x8f. */
8227FNIEMOP_DEF(iemOp_jnle_Jv)
8228{
8229 IEMOP_MNEMONIC(jg_Jv, "jnle/jg Jv");
8230 IEMOP_HLP_MIN_386();
8231 IEMOP_HLP_DEFAULT_64BIT_OP_SIZE_AND_INTEL_IGNORES_OP_SIZE_PREFIX();
8232 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_16BIT)
8233 {
8234 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
8235 int16_t i16Imm; IEM_OPCODE_GET_NEXT_S16(&i16Imm);
8236 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8237 IEM_MC_IF_EFL_BIT_SET_OR_BITS_NE(X86_EFL_ZF, X86_EFL_SF, X86_EFL_OF) {
8238 IEM_MC_ADVANCE_RIP_AND_FINISH();
8239 } IEM_MC_ELSE() {
8240 IEM_MC_REL_JMP_S16_AND_FINISH(i16Imm);
8241 } IEM_MC_ENDIF();
8242 IEM_MC_END();
8243 }
8244 else
8245 {
8246 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
8247 int32_t i32Imm; IEM_OPCODE_GET_NEXT_S32(&i32Imm);
8248 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8249 IEM_MC_IF_EFL_BIT_SET_OR_BITS_NE(X86_EFL_ZF, X86_EFL_SF, X86_EFL_OF) {
8250 IEM_MC_ADVANCE_RIP_AND_FINISH();
8251 } IEM_MC_ELSE() {
8252 IEM_MC_REL_JMP_S32_AND_FINISH(i32Imm);
8253 } IEM_MC_ENDIF();
8254 IEM_MC_END();
8255 }
8256}
8257
8258
8259/** Opcode 0x0f 0x90. */
8260FNIEMOP_DEF(iemOp_seto_Eb)
8261{
8262 IEMOP_MNEMONIC(seto_Eb, "seto Eb");
8263 IEMOP_HLP_MIN_386();
8264 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
8265
8266 /** @todo Encoding test: Check if the 'reg' field is ignored or decoded in
8267 * any way. AMD says it's "unused", whatever that means. We're
8268 * ignoring for now. */
8269 if (IEM_IS_MODRM_REG_MODE(bRm))
8270 {
8271 /* register target */
8272 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
8273 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8274 IEM_MC_IF_EFL_BIT_SET(X86_EFL_OF) {
8275 IEM_MC_STORE_GREG_U8_CONST(IEM_GET_MODRM_RM(pVCpu, bRm), 1);
8276 } IEM_MC_ELSE() {
8277 IEM_MC_STORE_GREG_U8_CONST(IEM_GET_MODRM_RM(pVCpu, bRm), 0);
8278 } IEM_MC_ENDIF();
8279 IEM_MC_ADVANCE_RIP_AND_FINISH();
8280 IEM_MC_END();
8281 }
8282 else
8283 {
8284 /* memory target */
8285 IEM_MC_BEGIN(0, 1, IEM_MC_F_MIN_386, 0);
8286 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
8287 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
8288 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8289 IEM_MC_IF_EFL_BIT_SET(X86_EFL_OF) {
8290 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 1);
8291 } IEM_MC_ELSE() {
8292 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
8293 } IEM_MC_ENDIF();
8294 IEM_MC_ADVANCE_RIP_AND_FINISH();
8295 IEM_MC_END();
8296 }
8297}
8298
8299
8300/** Opcode 0x0f 0x91. */
8301FNIEMOP_DEF(iemOp_setno_Eb)
8302{
8303 IEMOP_MNEMONIC(setno_Eb, "setno Eb");
8304 IEMOP_HLP_MIN_386();
8305 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
8306
8307 /** @todo Encoding test: Check if the 'reg' field is ignored or decoded in
8308 * any way. AMD says it's "unused", whatever that means. We're
8309 * ignoring for now. */
8310 if (IEM_IS_MODRM_REG_MODE(bRm))
8311 {
8312 /* register target */
8313 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
8314 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8315 IEM_MC_IF_EFL_BIT_SET(X86_EFL_OF) {
8316 IEM_MC_STORE_GREG_U8_CONST(IEM_GET_MODRM_RM(pVCpu, bRm), 0);
8317 } IEM_MC_ELSE() {
8318 IEM_MC_STORE_GREG_U8_CONST(IEM_GET_MODRM_RM(pVCpu, bRm), 1);
8319 } IEM_MC_ENDIF();
8320 IEM_MC_ADVANCE_RIP_AND_FINISH();
8321 IEM_MC_END();
8322 }
8323 else
8324 {
8325 /* memory target */
8326 IEM_MC_BEGIN(0, 1, IEM_MC_F_MIN_386, 0);
8327 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
8328 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
8329 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8330 IEM_MC_IF_EFL_BIT_SET(X86_EFL_OF) {
8331 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
8332 } IEM_MC_ELSE() {
8333 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 1);
8334 } IEM_MC_ENDIF();
8335 IEM_MC_ADVANCE_RIP_AND_FINISH();
8336 IEM_MC_END();
8337 }
8338}
8339
8340
8341/** Opcode 0x0f 0x92. */
8342FNIEMOP_DEF(iemOp_setc_Eb)
8343{
8344 IEMOP_MNEMONIC(setc_Eb, "setc Eb");
8345 IEMOP_HLP_MIN_386();
8346 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
8347
8348 /** @todo Encoding test: Check if the 'reg' field is ignored or decoded in
8349 * any way. AMD says it's "unused", whatever that means. We're
8350 * ignoring for now. */
8351 if (IEM_IS_MODRM_REG_MODE(bRm))
8352 {
8353 /* register target */
8354 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
8355 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8356 IEM_MC_IF_EFL_BIT_SET(X86_EFL_CF) {
8357 IEM_MC_STORE_GREG_U8_CONST(IEM_GET_MODRM_RM(pVCpu, bRm), 1);
8358 } IEM_MC_ELSE() {
8359 IEM_MC_STORE_GREG_U8_CONST(IEM_GET_MODRM_RM(pVCpu, bRm), 0);
8360 } IEM_MC_ENDIF();
8361 IEM_MC_ADVANCE_RIP_AND_FINISH();
8362 IEM_MC_END();
8363 }
8364 else
8365 {
8366 /* memory target */
8367 IEM_MC_BEGIN(0, 1, IEM_MC_F_MIN_386, 0);
8368 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
8369 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
8370 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8371 IEM_MC_IF_EFL_BIT_SET(X86_EFL_CF) {
8372 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 1);
8373 } IEM_MC_ELSE() {
8374 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
8375 } IEM_MC_ENDIF();
8376 IEM_MC_ADVANCE_RIP_AND_FINISH();
8377 IEM_MC_END();
8378 }
8379}
8380
8381
8382/** Opcode 0x0f 0x93. */
8383FNIEMOP_DEF(iemOp_setnc_Eb)
8384{
8385 IEMOP_MNEMONIC(setnc_Eb, "setnc Eb");
8386 IEMOP_HLP_MIN_386();
8387 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
8388
8389 /** @todo Encoding test: Check if the 'reg' field is ignored or decoded in
8390 * any way. AMD says it's "unused", whatever that means. We're
8391 * ignoring for now. */
8392 if (IEM_IS_MODRM_REG_MODE(bRm))
8393 {
8394 /* register target */
8395 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
8396 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8397 IEM_MC_IF_EFL_BIT_SET(X86_EFL_CF) {
8398 IEM_MC_STORE_GREG_U8_CONST(IEM_GET_MODRM_RM(pVCpu, bRm), 0);
8399 } IEM_MC_ELSE() {
8400 IEM_MC_STORE_GREG_U8_CONST(IEM_GET_MODRM_RM(pVCpu, bRm), 1);
8401 } IEM_MC_ENDIF();
8402 IEM_MC_ADVANCE_RIP_AND_FINISH();
8403 IEM_MC_END();
8404 }
8405 else
8406 {
8407 /* memory target */
8408 IEM_MC_BEGIN(0, 1, IEM_MC_F_MIN_386, 0);
8409 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
8410 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
8411 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8412 IEM_MC_IF_EFL_BIT_SET(X86_EFL_CF) {
8413 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
8414 } IEM_MC_ELSE() {
8415 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 1);
8416 } IEM_MC_ENDIF();
8417 IEM_MC_ADVANCE_RIP_AND_FINISH();
8418 IEM_MC_END();
8419 }
8420}
8421
8422
8423/** Opcode 0x0f 0x94. */
8424FNIEMOP_DEF(iemOp_sete_Eb)
8425{
8426 IEMOP_MNEMONIC(sete_Eb, "sete Eb");
8427 IEMOP_HLP_MIN_386();
8428 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
8429
8430 /** @todo Encoding test: Check if the 'reg' field is ignored or decoded in
8431 * any way. AMD says it's "unused", whatever that means. We're
8432 * ignoring for now. */
8433 if (IEM_IS_MODRM_REG_MODE(bRm))
8434 {
8435 /* register target */
8436 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
8437 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8438 IEM_MC_IF_EFL_BIT_SET(X86_EFL_ZF) {
8439 IEM_MC_STORE_GREG_U8_CONST(IEM_GET_MODRM_RM(pVCpu, bRm), 1);
8440 } IEM_MC_ELSE() {
8441 IEM_MC_STORE_GREG_U8_CONST(IEM_GET_MODRM_RM(pVCpu, bRm), 0);
8442 } IEM_MC_ENDIF();
8443 IEM_MC_ADVANCE_RIP_AND_FINISH();
8444 IEM_MC_END();
8445 }
8446 else
8447 {
8448 /* memory target */
8449 IEM_MC_BEGIN(0, 1, IEM_MC_F_MIN_386, 0);
8450 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
8451 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
8452 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8453 IEM_MC_IF_EFL_BIT_SET(X86_EFL_ZF) {
8454 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 1);
8455 } IEM_MC_ELSE() {
8456 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
8457 } IEM_MC_ENDIF();
8458 IEM_MC_ADVANCE_RIP_AND_FINISH();
8459 IEM_MC_END();
8460 }
8461}
8462
8463
8464/** Opcode 0x0f 0x95. */
8465FNIEMOP_DEF(iemOp_setne_Eb)
8466{
8467 IEMOP_MNEMONIC(setne_Eb, "setne Eb");
8468 IEMOP_HLP_MIN_386();
8469 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
8470
8471 /** @todo Encoding test: Check if the 'reg' field is ignored or decoded in
8472 * any way. AMD says it's "unused", whatever that means. We're
8473 * ignoring for now. */
8474 if (IEM_IS_MODRM_REG_MODE(bRm))
8475 {
8476 /* register target */
8477 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
8478 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8479 IEM_MC_IF_EFL_BIT_SET(X86_EFL_ZF) {
8480 IEM_MC_STORE_GREG_U8_CONST(IEM_GET_MODRM_RM(pVCpu, bRm), 0);
8481 } IEM_MC_ELSE() {
8482 IEM_MC_STORE_GREG_U8_CONST(IEM_GET_MODRM_RM(pVCpu, bRm), 1);
8483 } IEM_MC_ENDIF();
8484 IEM_MC_ADVANCE_RIP_AND_FINISH();
8485 IEM_MC_END();
8486 }
8487 else
8488 {
8489 /* memory target */
8490 IEM_MC_BEGIN(0, 1, IEM_MC_F_MIN_386, 0);
8491 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
8492 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
8493 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8494 IEM_MC_IF_EFL_BIT_SET(X86_EFL_ZF) {
8495 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
8496 } IEM_MC_ELSE() {
8497 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 1);
8498 } IEM_MC_ENDIF();
8499 IEM_MC_ADVANCE_RIP_AND_FINISH();
8500 IEM_MC_END();
8501 }
8502}
8503
8504
8505/** Opcode 0x0f 0x96. */
8506FNIEMOP_DEF(iemOp_setbe_Eb)
8507{
8508 IEMOP_MNEMONIC(setbe_Eb, "setbe Eb");
8509 IEMOP_HLP_MIN_386();
8510 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
8511
8512 /** @todo Encoding test: Check if the 'reg' field is ignored or decoded in
8513 * any way. AMD says it's "unused", whatever that means. We're
8514 * ignoring for now. */
8515 if (IEM_IS_MODRM_REG_MODE(bRm))
8516 {
8517 /* register target */
8518 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
8519 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8520 IEM_MC_IF_EFL_ANY_BITS_SET(X86_EFL_CF | X86_EFL_ZF) {
8521 IEM_MC_STORE_GREG_U8_CONST(IEM_GET_MODRM_RM(pVCpu, bRm), 1);
8522 } IEM_MC_ELSE() {
8523 IEM_MC_STORE_GREG_U8_CONST(IEM_GET_MODRM_RM(pVCpu, bRm), 0);
8524 } IEM_MC_ENDIF();
8525 IEM_MC_ADVANCE_RIP_AND_FINISH();
8526 IEM_MC_END();
8527 }
8528 else
8529 {
8530 /* memory target */
8531 IEM_MC_BEGIN(0, 1, IEM_MC_F_MIN_386, 0);
8532 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
8533 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
8534 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8535 IEM_MC_IF_EFL_ANY_BITS_SET(X86_EFL_CF | X86_EFL_ZF) {
8536 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 1);
8537 } IEM_MC_ELSE() {
8538 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
8539 } IEM_MC_ENDIF();
8540 IEM_MC_ADVANCE_RIP_AND_FINISH();
8541 IEM_MC_END();
8542 }
8543}
8544
8545
8546/** Opcode 0x0f 0x97. */
8547FNIEMOP_DEF(iemOp_setnbe_Eb)
8548{
8549 IEMOP_MNEMONIC(setnbe_Eb, "setnbe Eb");
8550 IEMOP_HLP_MIN_386();
8551 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
8552
8553 /** @todo Encoding test: Check if the 'reg' field is ignored or decoded in
8554 * any way. AMD says it's "unused", whatever that means. We're
8555 * ignoring for now. */
8556 if (IEM_IS_MODRM_REG_MODE(bRm))
8557 {
8558 /* register target */
8559 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
8560 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8561 IEM_MC_IF_EFL_ANY_BITS_SET(X86_EFL_CF | X86_EFL_ZF) {
8562 IEM_MC_STORE_GREG_U8_CONST(IEM_GET_MODRM_RM(pVCpu, bRm), 0);
8563 } IEM_MC_ELSE() {
8564 IEM_MC_STORE_GREG_U8_CONST(IEM_GET_MODRM_RM(pVCpu, bRm), 1);
8565 } IEM_MC_ENDIF();
8566 IEM_MC_ADVANCE_RIP_AND_FINISH();
8567 IEM_MC_END();
8568 }
8569 else
8570 {
8571 /* memory target */
8572 IEM_MC_BEGIN(0, 1, IEM_MC_F_MIN_386, 0);
8573 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
8574 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
8575 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8576 IEM_MC_IF_EFL_ANY_BITS_SET(X86_EFL_CF | X86_EFL_ZF) {
8577 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
8578 } IEM_MC_ELSE() {
8579 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 1);
8580 } IEM_MC_ENDIF();
8581 IEM_MC_ADVANCE_RIP_AND_FINISH();
8582 IEM_MC_END();
8583 }
8584}
8585
8586
8587/** Opcode 0x0f 0x98. */
8588FNIEMOP_DEF(iemOp_sets_Eb)
8589{
8590 IEMOP_MNEMONIC(sets_Eb, "sets Eb");
8591 IEMOP_HLP_MIN_386();
8592 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
8593
8594 /** @todo Encoding test: Check if the 'reg' field is ignored or decoded in
8595 * any way. AMD says it's "unused", whatever that means. We're
8596 * ignoring for now. */
8597 if (IEM_IS_MODRM_REG_MODE(bRm))
8598 {
8599 /* register target */
8600 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
8601 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8602 IEM_MC_IF_EFL_BIT_SET(X86_EFL_SF) {
8603 IEM_MC_STORE_GREG_U8_CONST(IEM_GET_MODRM_RM(pVCpu, bRm), 1);
8604 } IEM_MC_ELSE() {
8605 IEM_MC_STORE_GREG_U8_CONST(IEM_GET_MODRM_RM(pVCpu, bRm), 0);
8606 } IEM_MC_ENDIF();
8607 IEM_MC_ADVANCE_RIP_AND_FINISH();
8608 IEM_MC_END();
8609 }
8610 else
8611 {
8612 /* memory target */
8613 IEM_MC_BEGIN(0, 1, IEM_MC_F_MIN_386, 0);
8614 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
8615 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
8616 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8617 IEM_MC_IF_EFL_BIT_SET(X86_EFL_SF) {
8618 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 1);
8619 } IEM_MC_ELSE() {
8620 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
8621 } IEM_MC_ENDIF();
8622 IEM_MC_ADVANCE_RIP_AND_FINISH();
8623 IEM_MC_END();
8624 }
8625}
8626
8627
8628/** Opcode 0x0f 0x99. */
8629FNIEMOP_DEF(iemOp_setns_Eb)
8630{
8631 IEMOP_MNEMONIC(setns_Eb, "setns Eb");
8632 IEMOP_HLP_MIN_386();
8633 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
8634
8635 /** @todo Encoding test: Check if the 'reg' field is ignored or decoded in
8636 * any way. AMD says it's "unused", whatever that means. We're
8637 * ignoring for now. */
8638 if (IEM_IS_MODRM_REG_MODE(bRm))
8639 {
8640 /* register target */
8641 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
8642 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8643 IEM_MC_IF_EFL_BIT_SET(X86_EFL_SF) {
8644 IEM_MC_STORE_GREG_U8_CONST(IEM_GET_MODRM_RM(pVCpu, bRm), 0);
8645 } IEM_MC_ELSE() {
8646 IEM_MC_STORE_GREG_U8_CONST(IEM_GET_MODRM_RM(pVCpu, bRm), 1);
8647 } IEM_MC_ENDIF();
8648 IEM_MC_ADVANCE_RIP_AND_FINISH();
8649 IEM_MC_END();
8650 }
8651 else
8652 {
8653 /* memory target */
8654 IEM_MC_BEGIN(0, 1, IEM_MC_F_MIN_386, 0);
8655 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
8656 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
8657 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8658 IEM_MC_IF_EFL_BIT_SET(X86_EFL_SF) {
8659 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
8660 } IEM_MC_ELSE() {
8661 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 1);
8662 } IEM_MC_ENDIF();
8663 IEM_MC_ADVANCE_RIP_AND_FINISH();
8664 IEM_MC_END();
8665 }
8666}
8667
8668
8669/** Opcode 0x0f 0x9a. */
8670FNIEMOP_DEF(iemOp_setp_Eb)
8671{
8672 IEMOP_MNEMONIC(setp_Eb, "setp Eb");
8673 IEMOP_HLP_MIN_386();
8674 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
8675
8676 /** @todo Encoding test: Check if the 'reg' field is ignored or decoded in
8677 * any way. AMD says it's "unused", whatever that means. We're
8678 * ignoring for now. */
8679 if (IEM_IS_MODRM_REG_MODE(bRm))
8680 {
8681 /* register target */
8682 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
8683 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8684 IEM_MC_IF_EFL_BIT_SET(X86_EFL_PF) {
8685 IEM_MC_STORE_GREG_U8_CONST(IEM_GET_MODRM_RM(pVCpu, bRm), 1);
8686 } IEM_MC_ELSE() {
8687 IEM_MC_STORE_GREG_U8_CONST(IEM_GET_MODRM_RM(pVCpu, bRm), 0);
8688 } IEM_MC_ENDIF();
8689 IEM_MC_ADVANCE_RIP_AND_FINISH();
8690 IEM_MC_END();
8691 }
8692 else
8693 {
8694 /* memory target */
8695 IEM_MC_BEGIN(0, 1, IEM_MC_F_MIN_386, 0);
8696 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
8697 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
8698 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8699 IEM_MC_IF_EFL_BIT_SET(X86_EFL_PF) {
8700 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 1);
8701 } IEM_MC_ELSE() {
8702 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
8703 } IEM_MC_ENDIF();
8704 IEM_MC_ADVANCE_RIP_AND_FINISH();
8705 IEM_MC_END();
8706 }
8707}
8708
8709
8710/** Opcode 0x0f 0x9b. */
8711FNIEMOP_DEF(iemOp_setnp_Eb)
8712{
8713 IEMOP_MNEMONIC(setnp_Eb, "setnp Eb");
8714 IEMOP_HLP_MIN_386();
8715 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
8716
8717 /** @todo Encoding test: Check if the 'reg' field is ignored or decoded in
8718 * any way. AMD says it's "unused", whatever that means. We're
8719 * ignoring for now. */
8720 if (IEM_IS_MODRM_REG_MODE(bRm))
8721 {
8722 /* register target */
8723 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
8724 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8725 IEM_MC_IF_EFL_BIT_SET(X86_EFL_PF) {
8726 IEM_MC_STORE_GREG_U8_CONST(IEM_GET_MODRM_RM(pVCpu, bRm), 0);
8727 } IEM_MC_ELSE() {
8728 IEM_MC_STORE_GREG_U8_CONST(IEM_GET_MODRM_RM(pVCpu, bRm), 1);
8729 } IEM_MC_ENDIF();
8730 IEM_MC_ADVANCE_RIP_AND_FINISH();
8731 IEM_MC_END();
8732 }
8733 else
8734 {
8735 /* memory target */
8736 IEM_MC_BEGIN(0, 1, IEM_MC_F_MIN_386, 0);
8737 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
8738 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
8739 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8740 IEM_MC_IF_EFL_BIT_SET(X86_EFL_PF) {
8741 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
8742 } IEM_MC_ELSE() {
8743 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 1);
8744 } IEM_MC_ENDIF();
8745 IEM_MC_ADVANCE_RIP_AND_FINISH();
8746 IEM_MC_END();
8747 }
8748}
8749
8750
8751/** Opcode 0x0f 0x9c. */
8752FNIEMOP_DEF(iemOp_setl_Eb)
8753{
8754 IEMOP_MNEMONIC(setl_Eb, "setl Eb");
8755 IEMOP_HLP_MIN_386();
8756 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
8757
8758 /** @todo Encoding test: Check if the 'reg' field is ignored or decoded in
8759 * any way. AMD says it's "unused", whatever that means. We're
8760 * ignoring for now. */
8761 if (IEM_IS_MODRM_REG_MODE(bRm))
8762 {
8763 /* register target */
8764 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
8765 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8766 IEM_MC_IF_EFL_BITS_NE(X86_EFL_SF, X86_EFL_OF) {
8767 IEM_MC_STORE_GREG_U8_CONST(IEM_GET_MODRM_RM(pVCpu, bRm), 1);
8768 } IEM_MC_ELSE() {
8769 IEM_MC_STORE_GREG_U8_CONST(IEM_GET_MODRM_RM(pVCpu, bRm), 0);
8770 } IEM_MC_ENDIF();
8771 IEM_MC_ADVANCE_RIP_AND_FINISH();
8772 IEM_MC_END();
8773 }
8774 else
8775 {
8776 /* memory target */
8777 IEM_MC_BEGIN(0, 1, IEM_MC_F_MIN_386, 0);
8778 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
8779 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
8780 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8781 IEM_MC_IF_EFL_BITS_NE(X86_EFL_SF, X86_EFL_OF) {
8782 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 1);
8783 } IEM_MC_ELSE() {
8784 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
8785 } IEM_MC_ENDIF();
8786 IEM_MC_ADVANCE_RIP_AND_FINISH();
8787 IEM_MC_END();
8788 }
8789}
8790
8791
8792/** Opcode 0x0f 0x9d. */
8793FNIEMOP_DEF(iemOp_setnl_Eb)
8794{
8795 IEMOP_MNEMONIC(setnl_Eb, "setnl Eb");
8796 IEMOP_HLP_MIN_386();
8797 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
8798
8799 /** @todo Encoding test: Check if the 'reg' field is ignored or decoded in
8800 * any way. AMD says it's "unused", whatever that means. We're
8801 * ignoring for now. */
8802 if (IEM_IS_MODRM_REG_MODE(bRm))
8803 {
8804 /* register target */
8805 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
8806 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8807 IEM_MC_IF_EFL_BITS_NE(X86_EFL_SF, X86_EFL_OF) {
8808 IEM_MC_STORE_GREG_U8_CONST(IEM_GET_MODRM_RM(pVCpu, bRm), 0);
8809 } IEM_MC_ELSE() {
8810 IEM_MC_STORE_GREG_U8_CONST(IEM_GET_MODRM_RM(pVCpu, bRm), 1);
8811 } IEM_MC_ENDIF();
8812 IEM_MC_ADVANCE_RIP_AND_FINISH();
8813 IEM_MC_END();
8814 }
8815 else
8816 {
8817 /* memory target */
8818 IEM_MC_BEGIN(0, 1, IEM_MC_F_MIN_386, 0);
8819 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
8820 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
8821 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8822 IEM_MC_IF_EFL_BITS_NE(X86_EFL_SF, X86_EFL_OF) {
8823 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
8824 } IEM_MC_ELSE() {
8825 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 1);
8826 } IEM_MC_ENDIF();
8827 IEM_MC_ADVANCE_RIP_AND_FINISH();
8828 IEM_MC_END();
8829 }
8830}
8831
8832
8833/** Opcode 0x0f 0x9e. */
8834FNIEMOP_DEF(iemOp_setle_Eb)
8835{
8836 IEMOP_MNEMONIC(setle_Eb, "setle Eb");
8837 IEMOP_HLP_MIN_386();
8838 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
8839
8840 /** @todo Encoding test: Check if the 'reg' field is ignored or decoded in
8841 * any way. AMD says it's "unused", whatever that means. We're
8842 * ignoring for now. */
8843 if (IEM_IS_MODRM_REG_MODE(bRm))
8844 {
8845 /* register target */
8846 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
8847 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8848 IEM_MC_IF_EFL_BIT_SET_OR_BITS_NE(X86_EFL_ZF, X86_EFL_SF, X86_EFL_OF) {
8849 IEM_MC_STORE_GREG_U8_CONST(IEM_GET_MODRM_RM(pVCpu, bRm), 1);
8850 } IEM_MC_ELSE() {
8851 IEM_MC_STORE_GREG_U8_CONST(IEM_GET_MODRM_RM(pVCpu, bRm), 0);
8852 } IEM_MC_ENDIF();
8853 IEM_MC_ADVANCE_RIP_AND_FINISH();
8854 IEM_MC_END();
8855 }
8856 else
8857 {
8858 /* memory target */
8859 IEM_MC_BEGIN(0, 1, IEM_MC_F_MIN_386, 0);
8860 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
8861 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
8862 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8863 IEM_MC_IF_EFL_BIT_SET_OR_BITS_NE(X86_EFL_ZF, X86_EFL_SF, X86_EFL_OF) {
8864 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 1);
8865 } IEM_MC_ELSE() {
8866 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
8867 } IEM_MC_ENDIF();
8868 IEM_MC_ADVANCE_RIP_AND_FINISH();
8869 IEM_MC_END();
8870 }
8871}
8872
8873
8874/** Opcode 0x0f 0x9f. */
8875FNIEMOP_DEF(iemOp_setnle_Eb)
8876{
8877 IEMOP_MNEMONIC(setnle_Eb, "setnle Eb");
8878 IEMOP_HLP_MIN_386();
8879 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
8880
8881 /** @todo Encoding test: Check if the 'reg' field is ignored or decoded in
8882 * any way. AMD says it's "unused", whatever that means. We're
8883 * ignoring for now. */
8884 if (IEM_IS_MODRM_REG_MODE(bRm))
8885 {
8886 /* register target */
8887 IEM_MC_BEGIN(0, 0, IEM_MC_F_MIN_386, 0);
8888 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8889 IEM_MC_IF_EFL_BIT_SET_OR_BITS_NE(X86_EFL_ZF, X86_EFL_SF, X86_EFL_OF) {
8890 IEM_MC_STORE_GREG_U8_CONST(IEM_GET_MODRM_RM(pVCpu, bRm), 0);
8891 } IEM_MC_ELSE() {
8892 IEM_MC_STORE_GREG_U8_CONST(IEM_GET_MODRM_RM(pVCpu, bRm), 1);
8893 } IEM_MC_ENDIF();
8894 IEM_MC_ADVANCE_RIP_AND_FINISH();
8895 IEM_MC_END();
8896 }
8897 else
8898 {
8899 /* memory target */
8900 IEM_MC_BEGIN(0, 1, IEM_MC_F_MIN_386, 0);
8901 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
8902 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
8903 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8904 IEM_MC_IF_EFL_BIT_SET_OR_BITS_NE(X86_EFL_ZF, X86_EFL_SF, X86_EFL_OF) {
8905 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
8906 } IEM_MC_ELSE() {
8907 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 1);
8908 } IEM_MC_ENDIF();
8909 IEM_MC_ADVANCE_RIP_AND_FINISH();
8910 IEM_MC_END();
8911 }
8912}
8913
8914
8915/** Opcode 0x0f 0xa0. */
8916FNIEMOP_DEF(iemOp_push_fs)
8917{
8918 IEMOP_MNEMONIC(push_fs, "push fs");
8919 IEMOP_HLP_MIN_386();
8920 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8921 return FNIEMOP_CALL_1(iemOpCommonPushSReg, X86_SREG_FS);
8922}
8923
8924
8925/** Opcode 0x0f 0xa1. */
8926FNIEMOP_DEF(iemOp_pop_fs)
8927{
8928 IEMOP_MNEMONIC(pop_fs, "pop fs");
8929 IEMOP_HLP_MIN_386();
8930 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8931 IEM_MC_DEFER_TO_CIMPL_2_RET(0,
8932 RT_BIT_64(kIemNativeGstReg_GprFirst + X86_GREG_xSP)
8933 | RT_BIT_64(kIemNativeGstReg_SegSelFirst + X86_SREG_FS)
8934 | RT_BIT_64(kIemNativeGstReg_SegBaseFirst + X86_SREG_FS)
8935 | RT_BIT_64(kIemNativeGstReg_SegLimitFirst + X86_SREG_FS)
8936 | RT_BIT_64(kIemNativeGstReg_SegAttribFirst + X86_SREG_FS),
8937 iemCImpl_pop_Sreg, X86_SREG_FS, pVCpu->iem.s.enmEffOpSize);
8938}
8939
8940
8941/** Opcode 0x0f 0xa2. */
8942FNIEMOP_DEF(iemOp_cpuid)
8943{
8944 IEMOP_MNEMONIC(cpuid, "cpuid");
8945 IEMOP_HLP_MIN_486(); /* not all 486es. */
8946 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8947 IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_VMEXIT,
8948 RT_BIT_64(kIemNativeGstReg_GprFirst + X86_GREG_xAX)
8949 | RT_BIT_64(kIemNativeGstReg_GprFirst + X86_GREG_xCX)
8950 | RT_BIT_64(kIemNativeGstReg_GprFirst + X86_GREG_xDX)
8951 | RT_BIT_64(kIemNativeGstReg_GprFirst + X86_GREG_xBX),
8952 iemCImpl_cpuid);
8953}
8954
8955
8956/**
8957 * Body for iemOp_bt_Ev_Gv, iemOp_btc_Ev_Gv, iemOp_btr_Ev_Gv and
8958 * iemOp_bts_Ev_Gv.
8959 */
8960
8961#define IEMOP_BODY_BIT_Ev_Gv_RW(a_fnNormalU16, a_fnNormalU32, a_fnNormalU64) \
8962 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm); \
8963 IEMOP_VERIFICATION_UNDEFINED_EFLAGS(X86_EFL_OF | X86_EFL_SF | X86_EFL_ZF | X86_EFL_AF | X86_EFL_PF); \
8964 \
8965 if (IEM_IS_MODRM_REG_MODE(bRm)) \
8966 { \
8967 /* register destination. */ \
8968 switch (pVCpu->iem.s.enmEffOpSize) \
8969 { \
8970 case IEMMODE_16BIT: \
8971 IEM_MC_BEGIN(3, 0, IEM_MC_F_MIN_386, 0); \
8972 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); \
8973 IEM_MC_ARG(uint16_t *, pu16Dst, 0); \
8974 IEM_MC_ARG(uint16_t, u16Src, 1); \
8975 IEM_MC_ARG(uint32_t *, pEFlags, 2); \
8976 \
8977 IEM_MC_FETCH_GREG_U16(u16Src, IEM_GET_MODRM_REG(pVCpu, bRm)); \
8978 IEM_MC_AND_LOCAL_U16(u16Src, 0xf); \
8979 IEM_MC_REF_GREG_U16(pu16Dst, IEM_GET_MODRM_RM(pVCpu, bRm)); \
8980 IEM_MC_REF_EFLAGS(pEFlags); \
8981 IEM_MC_CALL_VOID_AIMPL_3(a_fnNormalU16, pu16Dst, u16Src, pEFlags); \
8982 \
8983 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
8984 IEM_MC_END(); \
8985 break; \
8986 \
8987 case IEMMODE_32BIT: \
8988 IEM_MC_BEGIN(3, 0, IEM_MC_F_MIN_386, 0); \
8989 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); \
8990 IEM_MC_ARG(uint32_t *, pu32Dst, 0); \
8991 IEM_MC_ARG(uint32_t, u32Src, 1); \
8992 IEM_MC_ARG(uint32_t *, pEFlags, 2); \
8993 \
8994 IEM_MC_FETCH_GREG_U32(u32Src, IEM_GET_MODRM_REG(pVCpu, bRm)); \
8995 IEM_MC_AND_LOCAL_U32(u32Src, 0x1f); \
8996 IEM_MC_REF_GREG_U32(pu32Dst, IEM_GET_MODRM_RM(pVCpu, bRm)); \
8997 IEM_MC_REF_EFLAGS(pEFlags); \
8998 IEM_MC_CALL_VOID_AIMPL_3(a_fnNormalU32, pu32Dst, u32Src, pEFlags); \
8999 \
9000 IEM_MC_CLEAR_HIGH_GREG_U64(IEM_GET_MODRM_RM(pVCpu, bRm)); \
9001 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
9002 IEM_MC_END(); \
9003 break; \
9004 \
9005 case IEMMODE_64BIT: \
9006 IEM_MC_BEGIN(3, 0, IEM_MC_F_64BIT, 0); \
9007 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); \
9008 IEM_MC_ARG(uint64_t *, pu64Dst, 0); \
9009 IEM_MC_ARG(uint64_t, u64Src, 1); \
9010 IEM_MC_ARG(uint32_t *, pEFlags, 2); \
9011 \
9012 IEM_MC_FETCH_GREG_U64(u64Src, IEM_GET_MODRM_REG(pVCpu, bRm)); \
9013 IEM_MC_AND_LOCAL_U64(u64Src, 0x3f); \
9014 IEM_MC_REF_GREG_U64(pu64Dst, IEM_GET_MODRM_RM(pVCpu, bRm)); \
9015 IEM_MC_REF_EFLAGS(pEFlags); \
9016 IEM_MC_CALL_VOID_AIMPL_3(a_fnNormalU64, pu64Dst, u64Src, pEFlags); \
9017 \
9018 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
9019 IEM_MC_END(); \
9020 break; \
9021 \
9022 IEM_NOT_REACHED_DEFAULT_CASE_RET(); \
9023 } \
9024 } \
9025 else \
9026 { \
9027 /* memory destination. */ \
9028 /** @todo test negative bit offsets! */ \
9029 if (!(pVCpu->iem.s.fPrefixes & IEM_OP_PRF_LOCK) || (pVCpu->iem.s.fExec & IEM_F_X86_DISREGARD_LOCK)) \
9030 { \
9031 switch (pVCpu->iem.s.enmEffOpSize) \
9032 { \
9033 case IEMMODE_16BIT: \
9034 IEM_MC_BEGIN(3, 4, IEM_MC_F_MIN_386, 0); \
9035 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst); \
9036 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0); \
9037 IEMOP_HLP_DONE_DECODING(); \
9038 \
9039 IEM_MC_ARG(uint16_t, u16Src, 1); \
9040 IEM_MC_FETCH_GREG_U16(u16Src, IEM_GET_MODRM_REG(pVCpu, bRm)); \
9041 IEM_MC_LOCAL_ASSIGN(int16_t, i16AddrAdj, /*=*/ u16Src); \
9042 IEM_MC_AND_ARG_U16(u16Src, 0x0f); \
9043 IEM_MC_SAR_LOCAL_S16(i16AddrAdj, 4); \
9044 IEM_MC_SHL_LOCAL_S16(i16AddrAdj, 1); \
9045 IEM_MC_ADD_LOCAL_S16_TO_EFF_ADDR(GCPtrEffDst, i16AddrAdj); \
9046 \
9047 IEM_MC_LOCAL(uint8_t, bUnmapInfo); \
9048 IEM_MC_ARG(uint16_t *, pu16Dst, 0); \
9049 IEM_MC_MEM_MAP_U16_RW(pu16Dst, bUnmapInfo, pVCpu->iem.s.iEffSeg, GCPtrEffDst); \
9050 \
9051 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 2); \
9052 IEM_MC_FETCH_EFLAGS(EFlags); \
9053 IEM_MC_CALL_VOID_AIMPL_3(a_fnNormalU16, pu16Dst, u16Src, pEFlags); \
9054 \
9055 IEM_MC_MEM_COMMIT_AND_UNMAP_RW(bUnmapInfo); \
9056 IEM_MC_COMMIT_EFLAGS(EFlags); \
9057 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
9058 IEM_MC_END(); \
9059 break; \
9060 \
9061 case IEMMODE_32BIT: \
9062 IEM_MC_BEGIN(3, 4, IEM_MC_F_MIN_386, 0); \
9063 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst); \
9064 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0); \
9065 IEMOP_HLP_DONE_DECODING(); \
9066 \
9067 IEM_MC_ARG(uint32_t, u32Src, 1); \
9068 IEM_MC_FETCH_GREG_U32(u32Src, IEM_GET_MODRM_REG(pVCpu, bRm)); \
9069 IEM_MC_LOCAL_ASSIGN(int32_t, i32AddrAdj, /*=*/ u32Src); \
9070 IEM_MC_AND_ARG_U32(u32Src, 0x1f); \
9071 IEM_MC_SAR_LOCAL_S32(i32AddrAdj, 5); \
9072 IEM_MC_SHL_LOCAL_S32(i32AddrAdj, 2); \
9073 IEM_MC_ADD_LOCAL_S32_TO_EFF_ADDR(GCPtrEffDst, i32AddrAdj); \
9074 \
9075 IEM_MC_LOCAL(uint8_t, bUnmapInfo); \
9076 IEM_MC_ARG(uint32_t *, pu32Dst, 0); \
9077 IEM_MC_MEM_MAP_U32_RW(pu32Dst, bUnmapInfo, pVCpu->iem.s.iEffSeg, GCPtrEffDst); \
9078 \
9079 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 2); \
9080 IEM_MC_FETCH_EFLAGS(EFlags); \
9081 IEM_MC_CALL_VOID_AIMPL_3(a_fnNormalU32, pu32Dst, u32Src, pEFlags); \
9082 \
9083 IEM_MC_MEM_COMMIT_AND_UNMAP_RW(bUnmapInfo); \
9084 IEM_MC_COMMIT_EFLAGS(EFlags); \
9085 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
9086 IEM_MC_END(); \
9087 break; \
9088 \
9089 case IEMMODE_64BIT: \
9090 IEM_MC_BEGIN(3, 5, IEM_MC_F_64BIT, 0); \
9091 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst); \
9092 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0); \
9093 IEMOP_HLP_DONE_DECODING(); \
9094 \
9095 IEM_MC_ARG(uint64_t, u64Src, 1); \
9096 IEM_MC_FETCH_GREG_U64(u64Src, IEM_GET_MODRM_REG(pVCpu, bRm)); \
9097 IEM_MC_LOCAL_ASSIGN(int64_t, i64AddrAdj, /*=*/ u64Src); \
9098 IEM_MC_AND_ARG_U64(u64Src, 0x3f); \
9099 IEM_MC_SAR_LOCAL_S64(i64AddrAdj, 6); \
9100 IEM_MC_SHL_LOCAL_S64(i64AddrAdj, 3); \
9101 IEM_MC_ADD_LOCAL_S64_TO_EFF_ADDR(GCPtrEffDst, i64AddrAdj); \
9102 \
9103 IEM_MC_LOCAL(uint8_t, bUnmapInfo); \
9104 IEM_MC_ARG(uint64_t *, pu64Dst, 0); \
9105 IEM_MC_MEM_MAP_U64_RW(pu64Dst, bUnmapInfo, pVCpu->iem.s.iEffSeg, GCPtrEffDst); \
9106 \
9107 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 2); \
9108 IEM_MC_FETCH_EFLAGS(EFlags); \
9109 IEM_MC_CALL_VOID_AIMPL_3(a_fnNormalU64, pu64Dst, u64Src, pEFlags); \
9110 \
9111 IEM_MC_MEM_COMMIT_AND_UNMAP_RW(bUnmapInfo); \
9112 IEM_MC_COMMIT_EFLAGS(EFlags); \
9113 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
9114 IEM_MC_END(); \
9115 break; \
9116 \
9117 IEM_NOT_REACHED_DEFAULT_CASE_RET(); \
9118 } \
9119 } \
9120 else \
9121 { \
9122 (void)0
9123/* Separate macro to work around parsing issue in IEMAllInstPython.py */
9124#define IEMOP_BODY_BIT_Ev_Gv_LOCKED(a_fnLockedU16, a_fnLockedU32, a_fnLockedU64) \
9125 switch (pVCpu->iem.s.enmEffOpSize) \
9126 { \
9127 case IEMMODE_16BIT: \
9128 IEM_MC_BEGIN(3, 4, IEM_MC_F_MIN_386, 0); \
9129 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst); \
9130 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0); \
9131 IEMOP_HLP_DONE_DECODING(); \
9132 \
9133 IEM_MC_ARG(uint16_t, u16Src, 1); \
9134 IEM_MC_FETCH_GREG_U16(u16Src, IEM_GET_MODRM_REG(pVCpu, bRm)); \
9135 IEM_MC_LOCAL_ASSIGN(int16_t, i16AddrAdj, /*=*/ u16Src); \
9136 IEM_MC_AND_ARG_U16(u16Src, 0x0f); \
9137 IEM_MC_SAR_LOCAL_S16(i16AddrAdj, 4); \
9138 IEM_MC_SHL_LOCAL_S16(i16AddrAdj, 1); \
9139 IEM_MC_ADD_LOCAL_S16_TO_EFF_ADDR(GCPtrEffDst, i16AddrAdj); \
9140 \
9141 IEM_MC_LOCAL(uint8_t, bUnmapInfo); \
9142 IEM_MC_ARG(uint16_t *, pu16Dst, 0); \
9143 IEM_MC_MEM_MAP_U16_RW(pu16Dst, bUnmapInfo, pVCpu->iem.s.iEffSeg, GCPtrEffDst); \
9144 \
9145 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 2); \
9146 IEM_MC_FETCH_EFLAGS(EFlags); \
9147 IEM_MC_CALL_VOID_AIMPL_3(a_fnLockedU16, pu16Dst, u16Src, pEFlags); \
9148 \
9149 IEM_MC_MEM_COMMIT_AND_UNMAP_RW(bUnmapInfo); \
9150 IEM_MC_COMMIT_EFLAGS(EFlags); \
9151 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
9152 IEM_MC_END(); \
9153 break; \
9154 \
9155 case IEMMODE_32BIT: \
9156 IEM_MC_BEGIN(3, 4, IEM_MC_F_MIN_386, 0); \
9157 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst); \
9158 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0); \
9159 IEMOP_HLP_DONE_DECODING(); \
9160 \
9161 IEM_MC_ARG(uint32_t, u32Src, 1); \
9162 IEM_MC_FETCH_GREG_U32(u32Src, IEM_GET_MODRM_REG(pVCpu, bRm)); \
9163 IEM_MC_LOCAL_ASSIGN(int32_t, i32AddrAdj, /*=*/ u32Src); \
9164 IEM_MC_AND_ARG_U32(u32Src, 0x1f); \
9165 IEM_MC_SAR_LOCAL_S32(i32AddrAdj, 5); \
9166 IEM_MC_SHL_LOCAL_S32(i32AddrAdj, 2); \
9167 IEM_MC_ADD_LOCAL_S32_TO_EFF_ADDR(GCPtrEffDst, i32AddrAdj); \
9168 \
9169 IEM_MC_LOCAL(uint8_t, bUnmapInfo); \
9170 IEM_MC_ARG(uint32_t *, pu32Dst, 0); \
9171 IEM_MC_MEM_MAP_U32_RW(pu32Dst, bUnmapInfo, pVCpu->iem.s.iEffSeg, GCPtrEffDst); \
9172 \
9173 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 2); \
9174 IEM_MC_FETCH_EFLAGS(EFlags); \
9175 IEM_MC_CALL_VOID_AIMPL_3(a_fnLockedU32, pu32Dst, u32Src, pEFlags); \
9176 \
9177 IEM_MC_MEM_COMMIT_AND_UNMAP_RW(bUnmapInfo); \
9178 IEM_MC_COMMIT_EFLAGS(EFlags); \
9179 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
9180 IEM_MC_END(); \
9181 break; \
9182 \
9183 case IEMMODE_64BIT: \
9184 IEM_MC_BEGIN(3, 4, IEM_MC_F_64BIT, 0); \
9185 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst); \
9186 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0); \
9187 IEMOP_HLP_DONE_DECODING(); \
9188 \
9189 IEM_MC_ARG(uint64_t, u64Src, 1); \
9190 IEM_MC_FETCH_GREG_U64(u64Src, IEM_GET_MODRM_REG(pVCpu, bRm)); \
9191 IEM_MC_LOCAL_ASSIGN(int64_t, i64AddrAdj, /*=*/ u64Src); \
9192 IEM_MC_AND_ARG_U64(u64Src, 0x3f); \
9193 IEM_MC_SAR_LOCAL_S64(i64AddrAdj, 6); \
9194 IEM_MC_SHL_LOCAL_S64(i64AddrAdj, 3); \
9195 IEM_MC_ADD_LOCAL_S64_TO_EFF_ADDR(GCPtrEffDst, i64AddrAdj); \
9196 \
9197 IEM_MC_LOCAL(uint8_t, bUnmapInfo); \
9198 IEM_MC_ARG(uint64_t *, pu64Dst, 0); \
9199 IEM_MC_MEM_MAP_U64_RW(pu64Dst, bUnmapInfo, pVCpu->iem.s.iEffSeg, GCPtrEffDst); \
9200 \
9201 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 2); \
9202 IEM_MC_FETCH_EFLAGS(EFlags); \
9203 IEM_MC_CALL_VOID_AIMPL_3(a_fnLockedU64, pu64Dst, u64Src, pEFlags); \
9204 \
9205 IEM_MC_MEM_COMMIT_AND_UNMAP_RW(bUnmapInfo); \
9206 IEM_MC_COMMIT_EFLAGS(EFlags); \
9207 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
9208 IEM_MC_END(); \
9209 break; \
9210 \
9211 IEM_NOT_REACHED_DEFAULT_CASE_RET(); \
9212 } \
9213 } \
9214 } \
9215 (void)0
9216
9217/* Read-only version (bt). */
9218#define IEMOP_BODY_BIT_Ev_Gv_RO(a_fnNormalU16, a_fnNormalU32, a_fnNormalU64) \
9219 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm); \
9220 IEMOP_VERIFICATION_UNDEFINED_EFLAGS(X86_EFL_OF | X86_EFL_SF | X86_EFL_ZF | X86_EFL_AF | X86_EFL_PF); \
9221 \
9222 if (IEM_IS_MODRM_REG_MODE(bRm)) \
9223 { \
9224 /* register destination. */ \
9225 switch (pVCpu->iem.s.enmEffOpSize) \
9226 { \
9227 case IEMMODE_16BIT: \
9228 IEM_MC_BEGIN(3, 0, IEM_MC_F_MIN_386, 0); \
9229 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); \
9230 IEM_MC_ARG(uint16_t const *, pu16Dst, 0); \
9231 IEM_MC_ARG(uint16_t, u16Src, 1); \
9232 IEM_MC_ARG(uint32_t *, pEFlags, 2); \
9233 \
9234 IEM_MC_FETCH_GREG_U16(u16Src, IEM_GET_MODRM_REG(pVCpu, bRm)); \
9235 IEM_MC_AND_LOCAL_U16(u16Src, 0xf); \
9236 IEM_MC_REF_GREG_U16_CONST(pu16Dst, IEM_GET_MODRM_RM(pVCpu, bRm)); \
9237 IEM_MC_REF_EFLAGS(pEFlags); \
9238 IEM_MC_CALL_VOID_AIMPL_3(a_fnNormalU16, pu16Dst, u16Src, pEFlags); \
9239 \
9240 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
9241 IEM_MC_END(); \
9242 break; \
9243 \
9244 case IEMMODE_32BIT: \
9245 IEM_MC_BEGIN(3, 0, IEM_MC_F_MIN_386, 0); \
9246 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); \
9247 IEM_MC_ARG(uint32_t const *, pu32Dst, 0); \
9248 IEM_MC_ARG(uint32_t, u32Src, 1); \
9249 IEM_MC_ARG(uint32_t *, pEFlags, 2); \
9250 \
9251 IEM_MC_FETCH_GREG_U32(u32Src, IEM_GET_MODRM_REG(pVCpu, bRm)); \
9252 IEM_MC_AND_LOCAL_U32(u32Src, 0x1f); \
9253 IEM_MC_REF_GREG_U32_CONST(pu32Dst, IEM_GET_MODRM_RM(pVCpu, bRm)); \
9254 IEM_MC_REF_EFLAGS(pEFlags); \
9255 IEM_MC_CALL_VOID_AIMPL_3(a_fnNormalU32, pu32Dst, u32Src, pEFlags); \
9256 \
9257 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
9258 IEM_MC_END(); \
9259 break; \
9260 \
9261 case IEMMODE_64BIT: \
9262 IEM_MC_BEGIN(3, 0, IEM_MC_F_64BIT, 0); \
9263 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); \
9264 IEM_MC_ARG(uint64_t const *, pu64Dst, 0); \
9265 IEM_MC_ARG(uint64_t, u64Src, 1); \
9266 IEM_MC_ARG(uint32_t *, pEFlags, 2); \
9267 \
9268 IEM_MC_FETCH_GREG_U64(u64Src, IEM_GET_MODRM_REG(pVCpu, bRm)); \
9269 IEM_MC_AND_LOCAL_U64(u64Src, 0x3f); \
9270 IEM_MC_REF_GREG_U64_CONST(pu64Dst, IEM_GET_MODRM_RM(pVCpu, bRm)); \
9271 IEM_MC_REF_EFLAGS(pEFlags); \
9272 IEM_MC_CALL_VOID_AIMPL_3(a_fnNormalU64, pu64Dst, u64Src, pEFlags); \
9273 \
9274 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
9275 IEM_MC_END(); \
9276 break; \
9277 \
9278 IEM_NOT_REACHED_DEFAULT_CASE_RET(); \
9279 } \
9280 } \
9281 else \
9282 { \
9283 /* memory destination. */ \
9284 /** @todo test negative bit offsets! */ \
9285 if (!(pVCpu->iem.s.fPrefixes & IEM_OP_PRF_LOCK) || (pVCpu->iem.s.fExec & IEM_F_X86_DISREGARD_LOCK)) \
9286 { \
9287 switch (pVCpu->iem.s.enmEffOpSize) \
9288 { \
9289 case IEMMODE_16BIT: \
9290 IEM_MC_BEGIN(3, 4, IEM_MC_F_MIN_386, 0); \
9291 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst); \
9292 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0); \
9293 IEMOP_HLP_DONE_DECODING(); \
9294 \
9295 IEM_MC_ARG(uint16_t, u16Src, 1); \
9296 IEM_MC_FETCH_GREG_U16(u16Src, IEM_GET_MODRM_REG(pVCpu, bRm)); \
9297 IEM_MC_LOCAL_ASSIGN(int16_t, i16AddrAdj, /*=*/ u16Src); \
9298 IEM_MC_AND_ARG_U16(u16Src, 0x0f); \
9299 IEM_MC_SAR_LOCAL_S16(i16AddrAdj, 4); \
9300 IEM_MC_SHL_LOCAL_S16(i16AddrAdj, 1); \
9301 IEM_MC_ADD_LOCAL_S16_TO_EFF_ADDR(GCPtrEffDst, i16AddrAdj); \
9302 \
9303 IEM_MC_LOCAL(uint8_t, bUnmapInfo); \
9304 IEM_MC_ARG(uint16_t const *, pu16Dst, 0); \
9305 IEM_MC_MEM_MAP_U16_RO(pu16Dst, bUnmapInfo, pVCpu->iem.s.iEffSeg, GCPtrEffDst); \
9306 \
9307 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 2); \
9308 IEM_MC_FETCH_EFLAGS(EFlags); \
9309 IEM_MC_CALL_VOID_AIMPL_3(a_fnNormalU16, pu16Dst, u16Src, pEFlags); \
9310 \
9311 IEM_MC_MEM_COMMIT_AND_UNMAP_RO(bUnmapInfo); \
9312 IEM_MC_COMMIT_EFLAGS(EFlags); \
9313 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
9314 IEM_MC_END(); \
9315 break; \
9316 \
9317 case IEMMODE_32BIT: \
9318 IEM_MC_BEGIN(3, 4, IEM_MC_F_MIN_386, 0); \
9319 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst); \
9320 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0); \
9321 IEMOP_HLP_DONE_DECODING(); \
9322 \
9323 IEM_MC_ARG(uint32_t, u32Src, 1); \
9324 IEM_MC_FETCH_GREG_U32(u32Src, IEM_GET_MODRM_REG(pVCpu, bRm)); \
9325 IEM_MC_LOCAL_ASSIGN(int32_t, i32AddrAdj, /*=*/ u32Src); \
9326 IEM_MC_AND_ARG_U32(u32Src, 0x1f); \
9327 IEM_MC_SAR_LOCAL_S32(i32AddrAdj, 5); \
9328 IEM_MC_SHL_LOCAL_S32(i32AddrAdj, 2); \
9329 IEM_MC_ADD_LOCAL_S32_TO_EFF_ADDR(GCPtrEffDst, i32AddrAdj); \
9330 \
9331 IEM_MC_ARG(uint32_t const *, pu32Dst, 0); \
9332 IEM_MC_LOCAL(uint8_t, bUnmapInfo); \
9333 IEM_MC_MEM_MAP_U32_RO(pu32Dst, bUnmapInfo, pVCpu->iem.s.iEffSeg, GCPtrEffDst); \
9334 \
9335 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 2); \
9336 IEM_MC_FETCH_EFLAGS(EFlags); \
9337 IEM_MC_CALL_VOID_AIMPL_3(a_fnNormalU32, pu32Dst, u32Src, pEFlags); \
9338 \
9339 IEM_MC_MEM_COMMIT_AND_UNMAP_RO(bUnmapInfo); \
9340 IEM_MC_COMMIT_EFLAGS(EFlags); \
9341 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
9342 IEM_MC_END(); \
9343 break; \
9344 \
9345 case IEMMODE_64BIT: \
9346 IEM_MC_BEGIN(3, 4, IEM_MC_F_64BIT, 0); \
9347 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst); \
9348 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0); \
9349 IEMOP_HLP_DONE_DECODING(); \
9350 \
9351 IEM_MC_ARG(uint64_t, u64Src, 1); \
9352 IEM_MC_FETCH_GREG_U64(u64Src, IEM_GET_MODRM_REG(pVCpu, bRm)); \
9353 IEM_MC_LOCAL_ASSIGN(int64_t, i64AddrAdj, /*=*/ u64Src); \
9354 IEM_MC_AND_ARG_U64(u64Src, 0x3f); \
9355 IEM_MC_SAR_LOCAL_S64(i64AddrAdj, 6); \
9356 IEM_MC_SHL_LOCAL_S64(i64AddrAdj, 3); \
9357 IEM_MC_ADD_LOCAL_S64_TO_EFF_ADDR(GCPtrEffDst, i64AddrAdj); \
9358 \
9359 IEM_MC_LOCAL(uint8_t, bUnmapInfo); \
9360 IEM_MC_ARG(uint64_t const *, pu64Dst, 0); \
9361 IEM_MC_MEM_MAP_U64_RO(pu64Dst, bUnmapInfo, pVCpu->iem.s.iEffSeg, GCPtrEffDst); \
9362 \
9363 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 2); \
9364 IEM_MC_FETCH_EFLAGS(EFlags); \
9365 IEM_MC_CALL_VOID_AIMPL_3(a_fnNormalU64, pu64Dst, u64Src, pEFlags); \
9366 \
9367 IEM_MC_MEM_COMMIT_AND_UNMAP_RO(bUnmapInfo); \
9368 IEM_MC_COMMIT_EFLAGS(EFlags); \
9369 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
9370 IEM_MC_END(); \
9371 break; \
9372 \
9373 IEM_NOT_REACHED_DEFAULT_CASE_RET(); \
9374 } \
9375 } \
9376 else \
9377 { \
9378 IEMOP_HLP_DONE_DECODING(); \
9379 IEMOP_RAISE_INVALID_LOCK_PREFIX_RET(); \
9380 } \
9381 } \
9382 (void)0
9383
9384
9385/** Opcode 0x0f 0xa3. */
9386FNIEMOP_DEF(iemOp_bt_Ev_Gv)
9387{
9388 IEMOP_MNEMONIC(bt_Ev_Gv, "bt Ev,Gv");
9389 IEMOP_HLP_MIN_386();
9390 IEMOP_BODY_BIT_Ev_Gv_RO(iemAImpl_bt_u16, iemAImpl_bt_u32, iemAImpl_bt_u64);
9391}
9392
9393
9394/**
9395 * Common worker for iemOp_shrd_Ev_Gv_Ib and iemOp_shld_Ev_Gv_Ib.
9396 */
9397FNIEMOP_DEF_1(iemOpCommonShldShrd_Ib, PCIEMOPSHIFTDBLSIZES, pImpl)
9398{
9399 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
9400 IEMOP_VERIFICATION_UNDEFINED_EFLAGS(X86_EFL_AF | X86_EFL_OF);
9401
9402 if (IEM_IS_MODRM_REG_MODE(bRm))
9403 {
9404 uint8_t cShift; IEM_OPCODE_GET_NEXT_U8(&cShift);
9405
9406 switch (pVCpu->iem.s.enmEffOpSize)
9407 {
9408 case IEMMODE_16BIT:
9409 IEM_MC_BEGIN(4, 0, IEM_MC_F_MIN_386, 0);
9410 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
9411 IEM_MC_ARG(uint16_t *, pu16Dst, 0);
9412 IEM_MC_ARG(uint16_t, u16Src, 1);
9413 IEM_MC_ARG_CONST(uint8_t, cShiftArg, /*=*/cShift, 2);
9414 IEM_MC_ARG(uint32_t *, pEFlags, 3);
9415
9416 IEM_MC_FETCH_GREG_U16(u16Src, IEM_GET_MODRM_REG(pVCpu, bRm));
9417 IEM_MC_REF_GREG_U16(pu16Dst, IEM_GET_MODRM_RM(pVCpu, bRm));
9418 IEM_MC_REF_EFLAGS(pEFlags);
9419 IEM_MC_CALL_VOID_AIMPL_4(pImpl->pfnNormalU16, pu16Dst, u16Src, cShiftArg, pEFlags);
9420
9421 IEM_MC_ADVANCE_RIP_AND_FINISH();
9422 IEM_MC_END();
9423 break;
9424
9425 case IEMMODE_32BIT:
9426 IEM_MC_BEGIN(4, 0, IEM_MC_F_MIN_386, 0);
9427 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
9428 IEM_MC_ARG(uint32_t *, pu32Dst, 0);
9429 IEM_MC_ARG(uint32_t, u32Src, 1);
9430 IEM_MC_ARG_CONST(uint8_t, cShiftArg, /*=*/cShift, 2);
9431 IEM_MC_ARG(uint32_t *, pEFlags, 3);
9432
9433 IEM_MC_FETCH_GREG_U32(u32Src, IEM_GET_MODRM_REG(pVCpu, bRm));
9434 IEM_MC_REF_GREG_U32(pu32Dst, IEM_GET_MODRM_RM(pVCpu, bRm));
9435 IEM_MC_REF_EFLAGS(pEFlags);
9436 IEM_MC_CALL_VOID_AIMPL_4(pImpl->pfnNormalU32, pu32Dst, u32Src, cShiftArg, pEFlags);
9437
9438 IEM_MC_CLEAR_HIGH_GREG_U64(IEM_GET_MODRM_RM(pVCpu, bRm));
9439 IEM_MC_ADVANCE_RIP_AND_FINISH();
9440 IEM_MC_END();
9441 break;
9442
9443 case IEMMODE_64BIT:
9444 IEM_MC_BEGIN(4, 0, IEM_MC_F_64BIT, 0);
9445 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
9446 IEM_MC_ARG(uint64_t *, pu64Dst, 0);
9447 IEM_MC_ARG(uint64_t, u64Src, 1);
9448 IEM_MC_ARG_CONST(uint8_t, cShiftArg, /*=*/cShift, 2);
9449 IEM_MC_ARG(uint32_t *, pEFlags, 3);
9450
9451 IEM_MC_FETCH_GREG_U64(u64Src, IEM_GET_MODRM_REG(pVCpu, bRm));
9452 IEM_MC_REF_GREG_U64(pu64Dst, IEM_GET_MODRM_RM(pVCpu, bRm));
9453 IEM_MC_REF_EFLAGS(pEFlags);
9454 IEM_MC_CALL_VOID_AIMPL_4(pImpl->pfnNormalU64, pu64Dst, u64Src, cShiftArg, pEFlags);
9455
9456 IEM_MC_ADVANCE_RIP_AND_FINISH();
9457 IEM_MC_END();
9458 break;
9459
9460 IEM_NOT_REACHED_DEFAULT_CASE_RET();
9461 }
9462 }
9463 else
9464 {
9465 switch (pVCpu->iem.s.enmEffOpSize)
9466 {
9467 case IEMMODE_16BIT:
9468 IEM_MC_BEGIN(4, 3, IEM_MC_F_MIN_386, 0);
9469 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
9470 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 1);
9471
9472 uint8_t cShift; IEM_OPCODE_GET_NEXT_U8(&cShift);
9473 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
9474
9475 IEM_MC_LOCAL(uint8_t, bUnmapInfo);
9476 IEM_MC_ARG(uint16_t *, pu16Dst, 0);
9477 IEM_MC_MEM_MAP_U16_RW(pu16Dst, bUnmapInfo, pVCpu->iem.s.iEffSeg, GCPtrEffDst);
9478
9479 IEM_MC_ARG(uint16_t, u16Src, 1);
9480 IEM_MC_FETCH_GREG_U16(u16Src, IEM_GET_MODRM_REG(pVCpu, bRm));
9481 IEM_MC_ARG_CONST(uint8_t, cShiftArg,/*=*/ cShift, 2);
9482 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 3);
9483 IEM_MC_FETCH_EFLAGS(EFlags);
9484 IEM_MC_CALL_VOID_AIMPL_4(pImpl->pfnNormalU16, pu16Dst, u16Src, cShiftArg, pEFlags);
9485
9486 IEM_MC_MEM_COMMIT_AND_UNMAP_RW(bUnmapInfo);
9487 IEM_MC_COMMIT_EFLAGS(EFlags);
9488 IEM_MC_ADVANCE_RIP_AND_FINISH();
9489 IEM_MC_END();
9490 break;
9491
9492 case IEMMODE_32BIT:
9493 IEM_MC_BEGIN(4, 3, IEM_MC_F_MIN_386, 0);
9494 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
9495 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 1);
9496
9497 uint8_t cShift; IEM_OPCODE_GET_NEXT_U8(&cShift);
9498 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
9499
9500 IEM_MC_LOCAL(uint8_t, bUnmapInfo);
9501 IEM_MC_ARG(uint32_t *, pu32Dst, 0);
9502 IEM_MC_MEM_MAP_U32_RW(pu32Dst, bUnmapInfo, pVCpu->iem.s.iEffSeg, GCPtrEffDst);
9503
9504 IEM_MC_ARG(uint32_t, u32Src, 1);
9505 IEM_MC_FETCH_GREG_U32(u32Src, IEM_GET_MODRM_REG(pVCpu, bRm));
9506 IEM_MC_ARG_CONST(uint8_t, cShiftArg,/*=*/ cShift, 2);
9507 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 3);
9508 IEM_MC_FETCH_EFLAGS(EFlags);
9509 IEM_MC_CALL_VOID_AIMPL_4(pImpl->pfnNormalU32, pu32Dst, u32Src, cShiftArg, pEFlags);
9510
9511 IEM_MC_MEM_COMMIT_AND_UNMAP_RW(bUnmapInfo);
9512 IEM_MC_COMMIT_EFLAGS(EFlags);
9513 IEM_MC_ADVANCE_RIP_AND_FINISH();
9514 IEM_MC_END();
9515 break;
9516
9517 case IEMMODE_64BIT:
9518 IEM_MC_BEGIN(4, 3, IEM_MC_F_64BIT, 0);
9519 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
9520 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 1);
9521
9522 uint8_t cShift; IEM_OPCODE_GET_NEXT_U8(&cShift);
9523 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
9524
9525 IEM_MC_LOCAL(uint8_t, bUnmapInfo);
9526 IEM_MC_ARG(uint64_t *, pu64Dst, 0);
9527 IEM_MC_MEM_MAP_U64_RW(pu64Dst, bUnmapInfo, pVCpu->iem.s.iEffSeg, GCPtrEffDst);
9528
9529 IEM_MC_ARG(uint64_t, u64Src, 1);
9530 IEM_MC_FETCH_GREG_U64(u64Src, IEM_GET_MODRM_REG(pVCpu, bRm));
9531 IEM_MC_ARG_CONST(uint8_t, cShiftArg,/*=*/ cShift, 2);
9532 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 3);
9533 IEM_MC_FETCH_EFLAGS(EFlags);
9534
9535 IEM_MC_CALL_VOID_AIMPL_4(pImpl->pfnNormalU64, pu64Dst, u64Src, cShiftArg, pEFlags);
9536
9537 IEM_MC_MEM_COMMIT_AND_UNMAP_RW(bUnmapInfo);
9538 IEM_MC_COMMIT_EFLAGS(EFlags);
9539 IEM_MC_ADVANCE_RIP_AND_FINISH();
9540 IEM_MC_END();
9541 break;
9542
9543 IEM_NOT_REACHED_DEFAULT_CASE_RET();
9544 }
9545 }
9546}
9547
9548
9549/**
9550 * Common worker for iemOp_shrd_Ev_Gv_CL and iemOp_shld_Ev_Gv_CL.
9551 */
9552FNIEMOP_DEF_1(iemOpCommonShldShrd_CL, PCIEMOPSHIFTDBLSIZES, pImpl)
9553{
9554 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
9555 IEMOP_VERIFICATION_UNDEFINED_EFLAGS(X86_EFL_AF | X86_EFL_OF);
9556
9557 if (IEM_IS_MODRM_REG_MODE(bRm))
9558 {
9559 switch (pVCpu->iem.s.enmEffOpSize)
9560 {
9561 case IEMMODE_16BIT:
9562 IEM_MC_BEGIN(4, 0, IEM_MC_F_MIN_386, 0);
9563 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
9564 IEM_MC_ARG(uint16_t *, pu16Dst, 0);
9565 IEM_MC_ARG(uint16_t, u16Src, 1);
9566 IEM_MC_ARG(uint8_t, cShiftArg, 2);
9567 IEM_MC_ARG(uint32_t *, pEFlags, 3);
9568
9569 IEM_MC_FETCH_GREG_U16(u16Src, IEM_GET_MODRM_REG(pVCpu, bRm));
9570 IEM_MC_FETCH_GREG_U8(cShiftArg, X86_GREG_xCX);
9571 IEM_MC_REF_GREG_U16(pu16Dst, IEM_GET_MODRM_RM(pVCpu, bRm));
9572 IEM_MC_REF_EFLAGS(pEFlags);
9573 IEM_MC_CALL_VOID_AIMPL_4(pImpl->pfnNormalU16, pu16Dst, u16Src, cShiftArg, pEFlags);
9574
9575 IEM_MC_ADVANCE_RIP_AND_FINISH();
9576 IEM_MC_END();
9577 break;
9578
9579 case IEMMODE_32BIT:
9580 IEM_MC_BEGIN(4, 0, IEM_MC_F_MIN_386, 0);
9581 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
9582 IEM_MC_ARG(uint32_t *, pu32Dst, 0);
9583 IEM_MC_ARG(uint32_t, u32Src, 1);
9584 IEM_MC_ARG(uint8_t, cShiftArg, 2);
9585 IEM_MC_ARG(uint32_t *, pEFlags, 3);
9586
9587 IEM_MC_FETCH_GREG_U32(u32Src, IEM_GET_MODRM_REG(pVCpu, bRm));
9588 IEM_MC_FETCH_GREG_U8(cShiftArg, X86_GREG_xCX);
9589 IEM_MC_REF_GREG_U32(pu32Dst, IEM_GET_MODRM_RM(pVCpu, bRm));
9590 IEM_MC_REF_EFLAGS(pEFlags);
9591 IEM_MC_CALL_VOID_AIMPL_4(pImpl->pfnNormalU32, pu32Dst, u32Src, cShiftArg, pEFlags);
9592
9593 IEM_MC_CLEAR_HIGH_GREG_U64(IEM_GET_MODRM_RM(pVCpu, bRm));
9594 IEM_MC_ADVANCE_RIP_AND_FINISH();
9595 IEM_MC_END();
9596 break;
9597
9598 case IEMMODE_64BIT:
9599 IEM_MC_BEGIN(4, 0, IEM_MC_F_64BIT, 0);
9600 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
9601 IEM_MC_ARG(uint64_t *, pu64Dst, 0);
9602 IEM_MC_ARG(uint64_t, u64Src, 1);
9603 IEM_MC_ARG(uint8_t, cShiftArg, 2);
9604 IEM_MC_ARG(uint32_t *, pEFlags, 3);
9605
9606 IEM_MC_FETCH_GREG_U64(u64Src, IEM_GET_MODRM_REG(pVCpu, bRm));
9607 IEM_MC_FETCH_GREG_U8(cShiftArg, X86_GREG_xCX);
9608 IEM_MC_REF_GREG_U64(pu64Dst, IEM_GET_MODRM_RM(pVCpu, bRm));
9609 IEM_MC_REF_EFLAGS(pEFlags);
9610 IEM_MC_CALL_VOID_AIMPL_4(pImpl->pfnNormalU64, pu64Dst, u64Src, cShiftArg, pEFlags);
9611
9612 IEM_MC_ADVANCE_RIP_AND_FINISH();
9613 IEM_MC_END();
9614 break;
9615
9616 IEM_NOT_REACHED_DEFAULT_CASE_RET();
9617 }
9618 }
9619 else
9620 {
9621 switch (pVCpu->iem.s.enmEffOpSize)
9622 {
9623 case IEMMODE_16BIT:
9624 IEM_MC_BEGIN(4, 3, IEM_MC_F_MIN_386, 0);
9625 IEM_MC_ARG(uint16_t *, pu16Dst, 0);
9626 IEM_MC_ARG(uint16_t, u16Src, 1);
9627 IEM_MC_ARG(uint8_t, cShiftArg, 2);
9628 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 3);
9629 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
9630 IEM_MC_LOCAL(uint8_t, bUnmapInfo);
9631
9632 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
9633 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
9634 IEM_MC_FETCH_GREG_U16(u16Src, IEM_GET_MODRM_REG(pVCpu, bRm));
9635 IEM_MC_FETCH_GREG_U8(cShiftArg, X86_GREG_xCX);
9636 IEM_MC_FETCH_EFLAGS(EFlags);
9637 IEM_MC_MEM_MAP_U16_RW(pu16Dst, bUnmapInfo, pVCpu->iem.s.iEffSeg, GCPtrEffDst);
9638 IEM_MC_CALL_VOID_AIMPL_4(pImpl->pfnNormalU16, pu16Dst, u16Src, cShiftArg, pEFlags);
9639
9640 IEM_MC_MEM_COMMIT_AND_UNMAP_RW(bUnmapInfo);
9641 IEM_MC_COMMIT_EFLAGS(EFlags);
9642 IEM_MC_ADVANCE_RIP_AND_FINISH();
9643 IEM_MC_END();
9644 break;
9645
9646 case IEMMODE_32BIT:
9647 IEM_MC_BEGIN(4, 3, IEM_MC_F_MIN_386, 0);
9648 IEM_MC_ARG(uint32_t *, pu32Dst, 0);
9649 IEM_MC_ARG(uint32_t, u32Src, 1);
9650 IEM_MC_ARG(uint8_t, cShiftArg, 2);
9651 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 3);
9652 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
9653 IEM_MC_LOCAL(uint8_t, bUnmapInfo);
9654
9655 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
9656 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
9657 IEM_MC_FETCH_GREG_U32(u32Src, IEM_GET_MODRM_REG(pVCpu, bRm));
9658 IEM_MC_FETCH_GREG_U8(cShiftArg, X86_GREG_xCX);
9659 IEM_MC_FETCH_EFLAGS(EFlags);
9660 IEM_MC_MEM_MAP_U32_RW(pu32Dst, bUnmapInfo, pVCpu->iem.s.iEffSeg, GCPtrEffDst);
9661 IEM_MC_CALL_VOID_AIMPL_4(pImpl->pfnNormalU32, pu32Dst, u32Src, cShiftArg, pEFlags);
9662
9663 IEM_MC_MEM_COMMIT_AND_UNMAP_RW(bUnmapInfo);
9664 IEM_MC_COMMIT_EFLAGS(EFlags);
9665 IEM_MC_ADVANCE_RIP_AND_FINISH();
9666 IEM_MC_END();
9667 break;
9668
9669 case IEMMODE_64BIT:
9670 IEM_MC_BEGIN(4, 3, IEM_MC_F_64BIT, 0);
9671 IEM_MC_ARG(uint64_t *, pu64Dst, 0);
9672 IEM_MC_ARG(uint64_t, u64Src, 1);
9673 IEM_MC_ARG(uint8_t, cShiftArg, 2);
9674 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 3);
9675 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
9676 IEM_MC_LOCAL(uint8_t, bUnmapInfo);
9677
9678 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
9679 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
9680 IEM_MC_FETCH_GREG_U64(u64Src, IEM_GET_MODRM_REG(pVCpu, bRm));
9681 IEM_MC_FETCH_GREG_U8(cShiftArg, X86_GREG_xCX);
9682 IEM_MC_FETCH_EFLAGS(EFlags);
9683 IEM_MC_MEM_MAP_U64_RW(pu64Dst, bUnmapInfo, pVCpu->iem.s.iEffSeg, GCPtrEffDst);
9684 IEM_MC_CALL_VOID_AIMPL_4(pImpl->pfnNormalU64, pu64Dst, u64Src, cShiftArg, pEFlags);
9685
9686 IEM_MC_MEM_COMMIT_AND_UNMAP_RW(bUnmapInfo);
9687 IEM_MC_COMMIT_EFLAGS(EFlags);
9688 IEM_MC_ADVANCE_RIP_AND_FINISH();
9689 IEM_MC_END();
9690 break;
9691
9692 IEM_NOT_REACHED_DEFAULT_CASE_RET();
9693 }
9694 }
9695}
9696
9697
9698
9699/** Opcode 0x0f 0xa4. */
9700FNIEMOP_DEF(iemOp_shld_Ev_Gv_Ib)
9701{
9702 IEMOP_MNEMONIC(shld_Ev_Gv_Ib, "shld Ev,Gv,Ib");
9703 IEMOP_HLP_MIN_386();
9704 return FNIEMOP_CALL_1(iemOpCommonShldShrd_Ib, IEMTARGETCPU_EFL_BEHAVIOR_SELECT(g_iemAImpl_shld_eflags));
9705}
9706
9707
9708/** Opcode 0x0f 0xa5. */
9709FNIEMOP_DEF(iemOp_shld_Ev_Gv_CL)
9710{
9711 IEMOP_MNEMONIC(shld_Ev_Gv_CL, "shld Ev,Gv,CL");
9712 IEMOP_HLP_MIN_386();
9713 return FNIEMOP_CALL_1(iemOpCommonShldShrd_CL, IEMTARGETCPU_EFL_BEHAVIOR_SELECT(g_iemAImpl_shld_eflags));
9714}
9715
9716
9717/** Opcode 0x0f 0xa8. */
9718FNIEMOP_DEF(iemOp_push_gs)
9719{
9720 IEMOP_MNEMONIC(push_gs, "push gs");
9721 IEMOP_HLP_MIN_386();
9722 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
9723 return FNIEMOP_CALL_1(iemOpCommonPushSReg, X86_SREG_GS);
9724}
9725
9726
9727/** Opcode 0x0f 0xa9. */
9728FNIEMOP_DEF(iemOp_pop_gs)
9729{
9730 IEMOP_MNEMONIC(pop_gs, "pop gs");
9731 IEMOP_HLP_MIN_386();
9732 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
9733 IEM_MC_DEFER_TO_CIMPL_2_RET(0,
9734 RT_BIT_64(kIemNativeGstReg_GprFirst + X86_GREG_xSP)
9735 | RT_BIT_64(kIemNativeGstReg_SegSelFirst + X86_SREG_GS)
9736 | RT_BIT_64(kIemNativeGstReg_SegBaseFirst + X86_SREG_GS)
9737 | RT_BIT_64(kIemNativeGstReg_SegLimitFirst + X86_SREG_GS)
9738 | RT_BIT_64(kIemNativeGstReg_SegAttribFirst + X86_SREG_GS),
9739 iemCImpl_pop_Sreg, X86_SREG_GS, pVCpu->iem.s.enmEffOpSize);
9740}
9741
9742
9743/** Opcode 0x0f 0xaa. */
9744FNIEMOP_DEF(iemOp_rsm)
9745{
9746 IEMOP_MNEMONIC0(FIXED, RSM, rsm, DISOPTYPE_HARMLESS, 0);
9747 IEMOP_HLP_MIN_386(); /* 386SL and later. */
9748 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
9749 IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_BRANCH_INDIRECT | IEM_CIMPL_F_BRANCH_FAR | IEM_CIMPL_F_BRANCH_STACK_FAR
9750 | IEM_CIMPL_F_MODE | IEM_CIMPL_F_RFLAGS | IEM_CIMPL_F_VMEXIT | IEM_CIMPL_F_END_TB, 0,
9751 iemCImpl_rsm);
9752}
9753
9754
9755
9756/** Opcode 0x0f 0xab. */
9757FNIEMOP_DEF(iemOp_bts_Ev_Gv)
9758{
9759 IEMOP_MNEMONIC(bts_Ev_Gv, "bts Ev,Gv");
9760 IEMOP_HLP_MIN_386();
9761 IEMOP_BODY_BIT_Ev_Gv_RW( iemAImpl_bts_u16, iemAImpl_bts_u32, iemAImpl_bts_u64);
9762 IEMOP_BODY_BIT_Ev_Gv_LOCKED(iemAImpl_bts_u16_locked, iemAImpl_bts_u32_locked, iemAImpl_bts_u64_locked);
9763}
9764
9765
9766/** Opcode 0x0f 0xac. */
9767FNIEMOP_DEF(iemOp_shrd_Ev_Gv_Ib)
9768{
9769 IEMOP_MNEMONIC(shrd_Ev_Gv_Ib, "shrd Ev,Gv,Ib");
9770 IEMOP_HLP_MIN_386();
9771 return FNIEMOP_CALL_1(iemOpCommonShldShrd_Ib, IEMTARGETCPU_EFL_BEHAVIOR_SELECT(g_iemAImpl_shrd_eflags));
9772}
9773
9774
9775/** Opcode 0x0f 0xad. */
9776FNIEMOP_DEF(iemOp_shrd_Ev_Gv_CL)
9777{
9778 IEMOP_MNEMONIC(shrd_Ev_Gv_CL, "shrd Ev,Gv,CL");
9779 IEMOP_HLP_MIN_386();
9780 return FNIEMOP_CALL_1(iemOpCommonShldShrd_CL, IEMTARGETCPU_EFL_BEHAVIOR_SELECT(g_iemAImpl_shrd_eflags));
9781}
9782
9783
9784/** Opcode 0x0f 0xae mem/0. */
9785FNIEMOP_DEF_1(iemOp_Grp15_fxsave, uint8_t, bRm)
9786{
9787 IEMOP_MNEMONIC(fxsave, "fxsave m512");
9788 if (!IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fFxSaveRstor)
9789 IEMOP_RAISE_INVALID_OPCODE_RET();
9790
9791 IEM_MC_BEGIN(3, 1, IEM_MC_F_MIN_PENTIUM_II, 0);
9792 IEM_MC_ARG(RTGCPTR, GCPtrEff, 1);
9793 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEff, bRm, 0);
9794 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
9795 IEM_MC_ACTUALIZE_FPU_STATE_FOR_READ();
9796 IEM_MC_ARG_CONST(uint8_t, iEffSeg, /*=*/ pVCpu->iem.s.iEffSeg, 0);
9797 IEM_MC_ARG_CONST(IEMMODE, enmEffOpSize, /*=*/pVCpu->iem.s.enmEffOpSize, 2);
9798 IEM_MC_CALL_CIMPL_3(IEM_CIMPL_F_FPU, 0, iemCImpl_fxsave, iEffSeg, GCPtrEff, enmEffOpSize);
9799 IEM_MC_END();
9800}
9801
9802
9803/** Opcode 0x0f 0xae mem/1. */
9804FNIEMOP_DEF_1(iemOp_Grp15_fxrstor, uint8_t, bRm)
9805{
9806 IEMOP_MNEMONIC(fxrstor, "fxrstor m512");
9807 if (!IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fFxSaveRstor)
9808 IEMOP_RAISE_INVALID_OPCODE_RET();
9809
9810 IEM_MC_BEGIN(3, 1, IEM_MC_F_MIN_PENTIUM_II, 0);
9811 IEM_MC_ARG(RTGCPTR, GCPtrEff, 1);
9812 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEff, bRm, 0);
9813 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
9814 IEM_MC_ACTUALIZE_FPU_STATE_FOR_CHANGE();
9815 IEM_MC_ARG_CONST(uint8_t, iEffSeg, /*=*/ pVCpu->iem.s.iEffSeg, 0);
9816 IEM_MC_ARG_CONST(IEMMODE, enmEffOpSize, /*=*/pVCpu->iem.s.enmEffOpSize, 2);
9817 IEM_MC_CALL_CIMPL_3(IEM_CIMPL_F_FPU, 0, iemCImpl_fxrstor, iEffSeg, GCPtrEff, enmEffOpSize);
9818 IEM_MC_END();
9819}
9820
9821
9822/**
9823 * @opmaps grp15
9824 * @opcode !11/2
9825 * @oppfx none
9826 * @opcpuid sse
9827 * @opgroup og_sse_mxcsrsm
9828 * @opxcpttype 5
9829 * @optest op1=0 -> mxcsr=0
9830 * @optest op1=0x2083 -> mxcsr=0x2083
9831 * @optest op1=0xfffffffe -> value.xcpt=0xd
9832 * @optest op1=0x2083 cr0|=ts -> value.xcpt=0x7
9833 * @optest op1=0x2083 cr0|=em -> value.xcpt=0x6
9834 * @optest op1=0x2083 cr0|=mp -> mxcsr=0x2083
9835 * @optest op1=0x2083 cr4&~=osfxsr -> value.xcpt=0x6
9836 * @optest op1=0x2083 cr0|=ts,em -> value.xcpt=0x6
9837 * @optest op1=0x2083 cr0|=em cr4&~=osfxsr -> value.xcpt=0x6
9838 * @optest op1=0x2083 cr0|=ts,em cr4&~=osfxsr -> value.xcpt=0x6
9839 * @optest op1=0x2083 cr0|=ts,em,mp cr4&~=osfxsr -> value.xcpt=0x6
9840 */
9841FNIEMOP_DEF_1(iemOp_Grp15_ldmxcsr, uint8_t, bRm)
9842{
9843 IEMOP_MNEMONIC1(M_MEM, LDMXCSR, ldmxcsr, Md_RO, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
9844 if (!IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fSse)
9845 IEMOP_RAISE_INVALID_OPCODE_RET();
9846
9847 IEM_MC_BEGIN(2, 0, IEM_MC_F_MIN_PENTIUM_II, 0);
9848 IEM_MC_ARG(RTGCPTR, GCPtrEff, 1);
9849 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEff, bRm, 0);
9850 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
9851 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
9852 IEM_MC_ARG_CONST(uint8_t, iEffSeg, /*=*/ pVCpu->iem.s.iEffSeg, 0);
9853 IEM_MC_CALL_CIMPL_2(IEM_CIMPL_F_FPU, 0, iemCImpl_ldmxcsr, iEffSeg, GCPtrEff);
9854 IEM_MC_END();
9855}
9856
9857
9858/**
9859 * @opmaps grp15
9860 * @opcode !11/3
9861 * @oppfx none
9862 * @opcpuid sse
9863 * @opgroup og_sse_mxcsrsm
9864 * @opxcpttype 5
9865 * @optest mxcsr=0 -> op1=0
9866 * @optest mxcsr=0x2083 -> op1=0x2083
9867 * @optest mxcsr=0x2084 cr0|=ts -> value.xcpt=0x7
9868 * @optest mxcsr=0x2085 cr0|=em -> value.xcpt=0x6
9869 * @optest mxcsr=0x2086 cr0|=mp -> op1=0x2086
9870 * @optest mxcsr=0x2087 cr4&~=osfxsr -> value.xcpt=0x6
9871 * @optest mxcsr=0x2088 cr0|=ts,em -> value.xcpt=0x6
9872 * @optest mxcsr=0x2089 cr0|=em cr4&~=osfxsr -> value.xcpt=0x6
9873 * @optest mxcsr=0x208a cr0|=ts,em cr4&~=osfxsr -> value.xcpt=0x6
9874 * @optest mxcsr=0x208b cr0|=ts,em,mp cr4&~=osfxsr -> value.xcpt=0x6
9875 */
9876FNIEMOP_DEF_1(iemOp_Grp15_stmxcsr, uint8_t, bRm)
9877{
9878 IEMOP_MNEMONIC1(M_MEM, STMXCSR, stmxcsr, Md_WO, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
9879 if (!IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fSse)
9880 IEMOP_RAISE_INVALID_OPCODE_RET();
9881
9882 IEM_MC_BEGIN(2, 0, IEM_MC_F_MIN_PENTIUM_II, 0);
9883 IEM_MC_ARG(RTGCPTR, GCPtrEff, 1);
9884 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEff, bRm, 0);
9885 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
9886 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
9887 IEM_MC_ARG_CONST(uint8_t, iEffSeg, /*=*/ pVCpu->iem.s.iEffSeg, 0);
9888 IEM_MC_CALL_CIMPL_2(IEM_CIMPL_F_FPU, 0, iemCImpl_stmxcsr, iEffSeg, GCPtrEff);
9889 IEM_MC_END();
9890}
9891
9892
9893/**
9894 * @opmaps grp15
9895 * @opcode !11/4
9896 * @oppfx none
9897 * @opcpuid xsave
9898 * @opgroup og_system
9899 * @opxcpttype none
9900 */
9901FNIEMOP_DEF_1(iemOp_Grp15_xsave, uint8_t, bRm)
9902{
9903 IEMOP_MNEMONIC1(M_MEM, XSAVE, xsave, M_RW, DISOPTYPE_HARMLESS, 0);
9904 if (!IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fXSaveRstor)
9905 IEMOP_RAISE_INVALID_OPCODE_RET();
9906
9907 IEM_MC_BEGIN(3, 0, IEM_MC_F_MIN_CORE, 0);
9908 IEM_MC_ARG(RTGCPTR, GCPtrEff, 1);
9909 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEff, bRm, 0);
9910 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
9911 IEM_MC_ACTUALIZE_FPU_STATE_FOR_READ();
9912 IEM_MC_ARG_CONST(uint8_t, iEffSeg, /*=*/ pVCpu->iem.s.iEffSeg, 0);
9913 IEM_MC_ARG_CONST(IEMMODE, enmEffOpSize, /*=*/ pVCpu->iem.s.enmEffOpSize, 2);
9914 IEM_MC_CALL_CIMPL_3(IEM_CIMPL_F_FPU, 0, iemCImpl_xsave, iEffSeg, GCPtrEff, enmEffOpSize);
9915 IEM_MC_END();
9916}
9917
9918
9919/**
9920 * @opmaps grp15
9921 * @opcode !11/5
9922 * @oppfx none
9923 * @opcpuid xsave
9924 * @opgroup og_system
9925 * @opxcpttype none
9926 */
9927FNIEMOP_DEF_1(iemOp_Grp15_xrstor, uint8_t, bRm)
9928{
9929 IEMOP_MNEMONIC1(M_MEM, XRSTOR, xrstor, M_RO, DISOPTYPE_HARMLESS, 0);
9930 if (!IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fXSaveRstor)
9931 IEMOP_RAISE_INVALID_OPCODE_RET();
9932
9933 IEM_MC_BEGIN(3, 0, IEM_MC_F_MIN_CORE, 0);
9934 IEM_MC_ARG(RTGCPTR, GCPtrEff, 1);
9935 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEff, bRm, 0);
9936 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
9937 IEM_MC_ACTUALIZE_FPU_STATE_FOR_READ();
9938 IEM_MC_ARG_CONST(uint8_t, iEffSeg, /*=*/ pVCpu->iem.s.iEffSeg, 0);
9939 IEM_MC_ARG_CONST(IEMMODE, enmEffOpSize, /*=*/ pVCpu->iem.s.enmEffOpSize, 2);
9940 IEM_MC_CALL_CIMPL_3(IEM_CIMPL_F_FPU, 0, iemCImpl_xrstor, iEffSeg, GCPtrEff, enmEffOpSize);
9941 IEM_MC_END();
9942}
9943
9944/** Opcode 0x0f 0xae mem/6. */
9945FNIEMOP_STUB_1(iemOp_Grp15_xsaveopt, uint8_t, bRm);
9946
9947/**
9948 * @opmaps grp15
9949 * @opcode !11/7
9950 * @oppfx none
9951 * @opcpuid clfsh
9952 * @opgroup og_cachectl
9953 * @optest op1=1 ->
9954 */
9955FNIEMOP_DEF_1(iemOp_Grp15_clflush, uint8_t, bRm)
9956{
9957 IEMOP_MNEMONIC1(M_MEM, CLFLUSH, clflush, Mb_RO, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
9958 if (!IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fClFlush)
9959 return FNIEMOP_CALL_1(iemOp_InvalidWithRMAllNeeded, bRm);
9960
9961 IEM_MC_BEGIN(2, 0, IEM_MC_F_NOT_286_OR_OLDER, 0);
9962 IEM_MC_ARG(RTGCPTR, GCPtrEff, 1);
9963 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEff, bRm, 0);
9964 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
9965 IEM_MC_ARG_CONST(uint8_t, iEffSeg, /*=*/ pVCpu->iem.s.iEffSeg, 0);
9966 IEM_MC_CALL_CIMPL_2(IEM_CIMPL_F_VMEXIT, 0, iemCImpl_clflush_clflushopt, iEffSeg, GCPtrEff);
9967 IEM_MC_END();
9968}
9969
9970/**
9971 * @opmaps grp15
9972 * @opcode !11/7
9973 * @oppfx 0x66
9974 * @opcpuid clflushopt
9975 * @opgroup og_cachectl
9976 * @optest op1=1 ->
9977 */
9978FNIEMOP_DEF_1(iemOp_Grp15_clflushopt, uint8_t, bRm)
9979{
9980 IEMOP_MNEMONIC1(M_MEM, CLFLUSHOPT, clflushopt, Mb_RO, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
9981 if (!IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fClFlushOpt)
9982 return FNIEMOP_CALL_1(iemOp_InvalidWithRMAllNeeded, bRm);
9983
9984 IEM_MC_BEGIN(2, 0, IEM_MC_F_NOT_286_OR_OLDER, 0);
9985 IEM_MC_ARG(RTGCPTR, GCPtrEff, 1);
9986 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEff, bRm, 0);
9987 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
9988 IEM_MC_ARG_CONST(uint8_t, iEffSeg, /*=*/ pVCpu->iem.s.iEffSeg, 0);
9989 IEM_MC_CALL_CIMPL_2(IEM_CIMPL_F_VMEXIT, 0, iemCImpl_clflush_clflushopt, iEffSeg, GCPtrEff);
9990 IEM_MC_END();
9991}
9992
9993
9994/** Opcode 0x0f 0xae 11b/5. */
9995FNIEMOP_DEF_1(iemOp_Grp15_lfence, uint8_t, bRm)
9996{
9997 RT_NOREF_PV(bRm);
9998 IEMOP_MNEMONIC(lfence, "lfence");
9999 IEM_MC_BEGIN(0, 0, IEM_MC_F_NOT_286_OR_OLDER, 0);
10000 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
10001#ifdef RT_ARCH_ARM64
10002 IEM_MC_CALL_VOID_AIMPL_0(iemAImpl_lfence);
10003#else
10004 if (IEM_GET_HOST_CPU_FEATURES(pVCpu)->fSse2)
10005 IEM_MC_CALL_VOID_AIMPL_0(iemAImpl_lfence);
10006 else
10007 IEM_MC_CALL_VOID_AIMPL_0(iemAImpl_alt_mem_fence);
10008#endif
10009 IEM_MC_ADVANCE_RIP_AND_FINISH();
10010 IEM_MC_END();
10011}
10012
10013
10014/** Opcode 0x0f 0xae 11b/6. */
10015FNIEMOP_DEF_1(iemOp_Grp15_mfence, uint8_t, bRm)
10016{
10017 RT_NOREF_PV(bRm);
10018 IEMOP_MNEMONIC(mfence, "mfence");
10019 IEM_MC_BEGIN(0, 0, IEM_MC_F_NOT_286_OR_OLDER, 0);
10020 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
10021#ifdef RT_ARCH_ARM64
10022 IEM_MC_CALL_VOID_AIMPL_0(iemAImpl_mfence);
10023#else
10024 if (IEM_GET_HOST_CPU_FEATURES(pVCpu)->fSse2)
10025 IEM_MC_CALL_VOID_AIMPL_0(iemAImpl_mfence);
10026 else
10027 IEM_MC_CALL_VOID_AIMPL_0(iemAImpl_alt_mem_fence);
10028#endif
10029 IEM_MC_ADVANCE_RIP_AND_FINISH();
10030 IEM_MC_END();
10031}
10032
10033
10034/** Opcode 0x0f 0xae 11b/7. */
10035FNIEMOP_DEF_1(iemOp_Grp15_sfence, uint8_t, bRm)
10036{
10037 RT_NOREF_PV(bRm);
10038 IEMOP_MNEMONIC(sfence, "sfence");
10039 IEM_MC_BEGIN(0, 0, IEM_MC_F_NOT_286_OR_OLDER, 0);
10040 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
10041#ifdef RT_ARCH_ARM64
10042 IEM_MC_CALL_VOID_AIMPL_0(iemAImpl_sfence);
10043#else
10044 if (IEM_GET_HOST_CPU_FEATURES(pVCpu)->fSse2)
10045 IEM_MC_CALL_VOID_AIMPL_0(iemAImpl_sfence);
10046 else
10047 IEM_MC_CALL_VOID_AIMPL_0(iemAImpl_alt_mem_fence);
10048#endif
10049 IEM_MC_ADVANCE_RIP_AND_FINISH();
10050 IEM_MC_END();
10051}
10052
10053
10054/** Opcode 0xf3 0x0f 0xae 11b/0. */
10055FNIEMOP_DEF_1(iemOp_Grp15_rdfsbase, uint8_t, bRm)
10056{
10057 IEMOP_MNEMONIC(rdfsbase, "rdfsbase Ry");
10058 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_64BIT)
10059 {
10060 IEM_MC_BEGIN(0, 1, IEM_MC_F_64BIT, 0);
10061 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fFsGsBase);
10062 IEM_MC_MAYBE_RAISE_FSGSBASE_XCPT();
10063 IEM_MC_LOCAL(uint64_t, u64Dst);
10064 IEM_MC_FETCH_SREG_BASE_U64(u64Dst, X86_SREG_FS);
10065 IEM_MC_STORE_GREG_U64(IEM_GET_MODRM_RM(pVCpu, bRm), u64Dst);
10066 IEM_MC_ADVANCE_RIP_AND_FINISH();
10067 IEM_MC_END();
10068 }
10069 else
10070 {
10071 IEM_MC_BEGIN(0, 1, IEM_MC_F_NOT_286_OR_OLDER, 0);
10072 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fFsGsBase);
10073 IEM_MC_MAYBE_RAISE_FSGSBASE_XCPT();
10074 IEM_MC_LOCAL(uint32_t, u32Dst);
10075 IEM_MC_FETCH_SREG_BASE_U32(u32Dst, X86_SREG_FS);
10076 IEM_MC_STORE_GREG_U32(IEM_GET_MODRM_RM(pVCpu, bRm), u32Dst);
10077 IEM_MC_ADVANCE_RIP_AND_FINISH();
10078 IEM_MC_END();
10079 }
10080}
10081
10082
10083/** Opcode 0xf3 0x0f 0xae 11b/1. */
10084FNIEMOP_DEF_1(iemOp_Grp15_rdgsbase, uint8_t, bRm)
10085{
10086 IEMOP_MNEMONIC(rdgsbase, "rdgsbase Ry");
10087 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_64BIT)
10088 {
10089 IEM_MC_BEGIN(0, 1, IEM_MC_F_64BIT, 0);
10090 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fFsGsBase);
10091 IEM_MC_MAYBE_RAISE_FSGSBASE_XCPT();
10092 IEM_MC_LOCAL(uint64_t, u64Dst);
10093 IEM_MC_FETCH_SREG_BASE_U64(u64Dst, X86_SREG_GS);
10094 IEM_MC_STORE_GREG_U64(IEM_GET_MODRM_RM(pVCpu, bRm), u64Dst);
10095 IEM_MC_ADVANCE_RIP_AND_FINISH();
10096 IEM_MC_END();
10097 }
10098 else
10099 {
10100 IEM_MC_BEGIN(0, 1, IEM_MC_F_NOT_286_OR_OLDER, 0);
10101 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fFsGsBase);
10102 IEM_MC_MAYBE_RAISE_FSGSBASE_XCPT();
10103 IEM_MC_LOCAL(uint32_t, u32Dst);
10104 IEM_MC_FETCH_SREG_BASE_U32(u32Dst, X86_SREG_GS);
10105 IEM_MC_STORE_GREG_U32(IEM_GET_MODRM_RM(pVCpu, bRm), u32Dst);
10106 IEM_MC_ADVANCE_RIP_AND_FINISH();
10107 IEM_MC_END();
10108 }
10109}
10110
10111
10112/** Opcode 0xf3 0x0f 0xae 11b/2. */
10113FNIEMOP_DEF_1(iemOp_Grp15_wrfsbase, uint8_t, bRm)
10114{
10115 IEMOP_MNEMONIC(wrfsbase, "wrfsbase Ry");
10116 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_64BIT)
10117 {
10118 IEM_MC_BEGIN(0, 1, IEM_MC_F_64BIT, 0);
10119 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fFsGsBase);
10120 IEM_MC_MAYBE_RAISE_FSGSBASE_XCPT();
10121 IEM_MC_LOCAL(uint64_t, u64Dst);
10122 IEM_MC_FETCH_GREG_U64(u64Dst, IEM_GET_MODRM_RM(pVCpu, bRm));
10123 IEM_MC_MAYBE_RAISE_NON_CANONICAL_ADDR_GP0(u64Dst);
10124 IEM_MC_STORE_SREG_BASE_U64(X86_SREG_FS, u64Dst);
10125 IEM_MC_ADVANCE_RIP_AND_FINISH();
10126 IEM_MC_END();
10127 }
10128 else
10129 {
10130 IEM_MC_BEGIN(0, 1, IEM_MC_F_NOT_286_OR_OLDER, 0);
10131 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fFsGsBase);
10132 IEM_MC_MAYBE_RAISE_FSGSBASE_XCPT();
10133 IEM_MC_LOCAL(uint32_t, u32Dst);
10134 IEM_MC_FETCH_GREG_U32(u32Dst, IEM_GET_MODRM_RM(pVCpu, bRm));
10135 IEM_MC_STORE_SREG_BASE_U64(X86_SREG_FS, u32Dst);
10136 IEM_MC_ADVANCE_RIP_AND_FINISH();
10137 IEM_MC_END();
10138 }
10139}
10140
10141
10142/** Opcode 0xf3 0x0f 0xae 11b/3. */
10143FNIEMOP_DEF_1(iemOp_Grp15_wrgsbase, uint8_t, bRm)
10144{
10145 IEMOP_MNEMONIC(wrgsbase, "wrgsbase Ry");
10146 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_64BIT)
10147 {
10148 IEM_MC_BEGIN(0, 1, IEM_MC_F_64BIT, 0);
10149 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fFsGsBase);
10150 IEM_MC_MAYBE_RAISE_FSGSBASE_XCPT();
10151 IEM_MC_LOCAL(uint64_t, u64Dst);
10152 IEM_MC_FETCH_GREG_U64(u64Dst, IEM_GET_MODRM_RM(pVCpu, bRm));
10153 IEM_MC_MAYBE_RAISE_NON_CANONICAL_ADDR_GP0(u64Dst);
10154 IEM_MC_STORE_SREG_BASE_U64(X86_SREG_GS, u64Dst);
10155 IEM_MC_ADVANCE_RIP_AND_FINISH();
10156 IEM_MC_END();
10157 }
10158 else
10159 {
10160 IEM_MC_BEGIN(0, 1, IEM_MC_F_NOT_286_OR_OLDER, 0);
10161 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fFsGsBase);
10162 IEM_MC_MAYBE_RAISE_FSGSBASE_XCPT();
10163 IEM_MC_LOCAL(uint32_t, u32Dst);
10164 IEM_MC_FETCH_GREG_U32(u32Dst, IEM_GET_MODRM_RM(pVCpu, bRm));
10165 IEM_MC_STORE_SREG_BASE_U64(X86_SREG_GS, u32Dst);
10166 IEM_MC_ADVANCE_RIP_AND_FINISH();
10167 IEM_MC_END();
10168 }
10169}
10170
10171
10172/**
10173 * Group 15 jump table for register variant.
10174 */
10175IEM_STATIC const PFNIEMOPRM g_apfnGroup15RegReg[] =
10176{ /* pfx: none, 066h, 0f3h, 0f2h */
10177 /* /0 */ iemOp_InvalidWithRM, iemOp_InvalidWithRM, iemOp_Grp15_rdfsbase, iemOp_InvalidWithRM,
10178 /* /1 */ iemOp_InvalidWithRM, iemOp_InvalidWithRM, iemOp_Grp15_rdgsbase, iemOp_InvalidWithRM,
10179 /* /2 */ iemOp_InvalidWithRM, iemOp_InvalidWithRM, iemOp_Grp15_wrfsbase, iemOp_InvalidWithRM,
10180 /* /3 */ iemOp_InvalidWithRM, iemOp_InvalidWithRM, iemOp_Grp15_wrgsbase, iemOp_InvalidWithRM,
10181 /* /4 */ IEMOP_X4(iemOp_InvalidWithRM),
10182 /* /5 */ iemOp_Grp15_lfence, iemOp_InvalidWithRM, iemOp_InvalidWithRM, iemOp_InvalidWithRM,
10183 /* /6 */ iemOp_Grp15_mfence, iemOp_InvalidWithRM, iemOp_InvalidWithRM, iemOp_InvalidWithRM,
10184 /* /7 */ iemOp_Grp15_sfence, iemOp_InvalidWithRM, iemOp_InvalidWithRM, iemOp_InvalidWithRM,
10185};
10186AssertCompile(RT_ELEMENTS(g_apfnGroup15RegReg) == 8*4);
10187
10188
10189/**
10190 * Group 15 jump table for memory variant.
10191 */
10192IEM_STATIC const PFNIEMOPRM g_apfnGroup15MemReg[] =
10193{ /* pfx: none, 066h, 0f3h, 0f2h */
10194 /* /0 */ iemOp_Grp15_fxsave, iemOp_InvalidWithRM, iemOp_InvalidWithRM, iemOp_InvalidWithRM,
10195 /* /1 */ iemOp_Grp15_fxrstor, iemOp_InvalidWithRM, iemOp_InvalidWithRM, iemOp_InvalidWithRM,
10196 /* /2 */ iemOp_Grp15_ldmxcsr, iemOp_InvalidWithRM, iemOp_InvalidWithRM, iemOp_InvalidWithRM,
10197 /* /3 */ iemOp_Grp15_stmxcsr, iemOp_InvalidWithRM, iemOp_InvalidWithRM, iemOp_InvalidWithRM,
10198 /* /4 */ iemOp_Grp15_xsave, iemOp_InvalidWithRM, iemOp_InvalidWithRM, iemOp_InvalidWithRM,
10199 /* /5 */ iemOp_Grp15_xrstor, iemOp_InvalidWithRM, iemOp_InvalidWithRM, iemOp_InvalidWithRM,
10200 /* /6 */ iemOp_Grp15_xsaveopt, iemOp_InvalidWithRM, iemOp_InvalidWithRM, iemOp_InvalidWithRM,
10201 /* /7 */ iemOp_Grp15_clflush, iemOp_Grp15_clflushopt, iemOp_InvalidWithRM, iemOp_InvalidWithRM,
10202};
10203AssertCompile(RT_ELEMENTS(g_apfnGroup15MemReg) == 8*4);
10204
10205
10206/** Opcode 0x0f 0xae. */
10207FNIEMOP_DEF(iemOp_Grp15)
10208{
10209 IEMOP_HLP_MIN_586(); /* Not entirely accurate nor needed, but useful for debugging 286 code. */
10210 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
10211 if (IEM_IS_MODRM_REG_MODE(bRm))
10212 /* register, register */
10213 return FNIEMOP_CALL_1(g_apfnGroup15RegReg[ IEM_GET_MODRM_REG_8(bRm) * 4
10214 + pVCpu->iem.s.idxPrefix], bRm);
10215 /* memory, register */
10216 return FNIEMOP_CALL_1(g_apfnGroup15MemReg[ IEM_GET_MODRM_REG_8(bRm) * 4
10217 + pVCpu->iem.s.idxPrefix], bRm);
10218}
10219
10220
10221/** Opcode 0x0f 0xaf. */
10222FNIEMOP_DEF(iemOp_imul_Gv_Ev)
10223{
10224 IEMOP_MNEMONIC(imul_Gv_Ev, "imul Gv,Ev");
10225 IEMOP_HLP_MIN_386();
10226 IEMOP_VERIFICATION_UNDEFINED_EFLAGS(X86_EFL_SF | X86_EFL_ZF | X86_EFL_AF | X86_EFL_PF);
10227 const IEMOPBINSIZES * const pImpl = IEMTARGETCPU_EFL_BEHAVIOR_SELECT(g_iemAImpl_imul_two_eflags);
10228 IEMOP_BODY_BINARY_rv_rm(pImpl->pfnNormalU16, pImpl->pfnNormalU32, pImpl->pfnNormalU64, 1, IEM_MC_F_MIN_386);
10229}
10230
10231
10232/** Opcode 0x0f 0xb0. */
10233FNIEMOP_DEF(iemOp_cmpxchg_Eb_Gb)
10234{
10235 IEMOP_MNEMONIC(cmpxchg_Eb_Gb, "cmpxchg Eb,Gb");
10236 IEMOP_HLP_MIN_486();
10237 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
10238
10239 if (IEM_IS_MODRM_REG_MODE(bRm))
10240 {
10241 IEM_MC_BEGIN(4, 0, IEM_MC_F_MIN_486, 0);
10242 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
10243 IEM_MC_ARG(uint8_t *, pu8Dst, 0);
10244 IEM_MC_ARG(uint8_t *, pu8Al, 1);
10245 IEM_MC_ARG(uint8_t, u8Src, 2);
10246 IEM_MC_ARG(uint32_t *, pEFlags, 3);
10247
10248 IEM_MC_FETCH_GREG_U8(u8Src, IEM_GET_MODRM_REG(pVCpu, bRm));
10249 IEM_MC_REF_GREG_U8(pu8Dst, IEM_GET_MODRM_RM(pVCpu, bRm));
10250 IEM_MC_REF_GREG_U8(pu8Al, X86_GREG_xAX);
10251 IEM_MC_REF_EFLAGS(pEFlags);
10252 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpxchg_u8, pu8Dst, pu8Al, u8Src, pEFlags);
10253
10254 IEM_MC_ADVANCE_RIP_AND_FINISH();
10255 IEM_MC_END();
10256 }
10257 else
10258 {
10259#define IEMOP_BODY_CMPXCHG_BYTE(a_fnWorker) \
10260 IEM_MC_BEGIN(4, 4, IEM_MC_F_MIN_486, 0); \
10261 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst); \
10262 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0); \
10263 IEMOP_HLP_DONE_DECODING(); \
10264 \
10265 IEM_MC_LOCAL(uint8_t, bUnmapInfo); \
10266 IEM_MC_ARG(uint8_t *, pu8Dst, 0); \
10267 IEM_MC_MEM_MAP_U8_RW(pu8Dst, bUnmapInfo, pVCpu->iem.s.iEffSeg, GCPtrEffDst); \
10268 \
10269 IEM_MC_ARG(uint8_t, u8Src, 2); \
10270 IEM_MC_FETCH_GREG_U8(u8Src, IEM_GET_MODRM_REG(pVCpu, bRm)); \
10271 \
10272 IEM_MC_LOCAL(uint8_t, u8Al); \
10273 IEM_MC_FETCH_GREG_U8(u8Al, X86_GREG_xAX); \
10274 IEM_MC_ARG_LOCAL_REF(uint8_t *, pu8Al, u8Al, 1); \
10275 \
10276 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 3); \
10277 IEM_MC_FETCH_EFLAGS(EFlags); \
10278 IEM_MC_CALL_VOID_AIMPL_4(a_fnWorker, pu8Dst, pu8Al, u8Src, pEFlags); \
10279 \
10280 IEM_MC_MEM_COMMIT_AND_UNMAP_RW(bUnmapInfo); \
10281 IEM_MC_COMMIT_EFLAGS(EFlags); \
10282 IEM_MC_STORE_GREG_U8(X86_GREG_xAX, u8Al); \
10283 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
10284 IEM_MC_END()
10285
10286 if (!(pVCpu->iem.s.fPrefixes & IEM_OP_PRF_LOCK) || (pVCpu->iem.s.fExec & IEM_F_X86_DISREGARD_LOCK))
10287 {
10288 IEMOP_BODY_CMPXCHG_BYTE(iemAImpl_cmpxchg_u8);
10289 }
10290 else
10291 {
10292 IEMOP_BODY_CMPXCHG_BYTE(iemAImpl_cmpxchg_u8_locked);
10293 }
10294 }
10295}
10296
10297/** Opcode 0x0f 0xb1. */
10298FNIEMOP_DEF(iemOp_cmpxchg_Ev_Gv)
10299{
10300 IEMOP_MNEMONIC(cmpxchg_Ev_Gv, "cmpxchg Ev,Gv");
10301 IEMOP_HLP_MIN_486();
10302 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
10303
10304 if (IEM_IS_MODRM_REG_MODE(bRm))
10305 {
10306 switch (pVCpu->iem.s.enmEffOpSize)
10307 {
10308 case IEMMODE_16BIT:
10309 IEM_MC_BEGIN(4, 0, IEM_MC_F_MIN_486, 0);
10310 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
10311 IEM_MC_ARG(uint16_t *, pu16Dst, 0);
10312 IEM_MC_ARG(uint16_t *, pu16Ax, 1);
10313 IEM_MC_ARG(uint16_t, u16Src, 2);
10314 IEM_MC_ARG(uint32_t *, pEFlags, 3);
10315
10316 IEM_MC_FETCH_GREG_U16(u16Src, IEM_GET_MODRM_REG(pVCpu, bRm));
10317 IEM_MC_REF_GREG_U16(pu16Dst, IEM_GET_MODRM_RM(pVCpu, bRm));
10318 IEM_MC_REF_GREG_U16(pu16Ax, X86_GREG_xAX);
10319 IEM_MC_REF_EFLAGS(pEFlags);
10320 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpxchg_u16, pu16Dst, pu16Ax, u16Src, pEFlags);
10321
10322 IEM_MC_ADVANCE_RIP_AND_FINISH();
10323 IEM_MC_END();
10324 break;
10325
10326 case IEMMODE_32BIT:
10327 IEM_MC_BEGIN(4, 0, IEM_MC_F_MIN_486, 0);
10328 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
10329 IEM_MC_ARG(uint32_t *, pu32Dst, 0);
10330 IEM_MC_ARG(uint32_t *, pu32Eax, 1);
10331 IEM_MC_ARG(uint32_t, u32Src, 2);
10332 IEM_MC_ARG(uint32_t *, pEFlags, 3);
10333
10334 IEM_MC_FETCH_GREG_U32(u32Src, IEM_GET_MODRM_REG(pVCpu, bRm));
10335 IEM_MC_REF_GREG_U32(pu32Dst, IEM_GET_MODRM_RM(pVCpu, bRm));
10336 IEM_MC_REF_GREG_U32(pu32Eax, X86_GREG_xAX);
10337 IEM_MC_REF_EFLAGS(pEFlags);
10338 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpxchg_u32, pu32Dst, pu32Eax, u32Src, pEFlags);
10339
10340 IEM_MC_IF_EFL_BIT_SET(X86_EFL_ZF) {
10341 IEM_MC_CLEAR_HIGH_GREG_U64(IEM_GET_MODRM_RM(pVCpu, bRm));
10342 } IEM_MC_ELSE() {
10343 IEM_MC_CLEAR_HIGH_GREG_U64(X86_GREG_xAX);
10344 } IEM_MC_ENDIF();
10345
10346 IEM_MC_ADVANCE_RIP_AND_FINISH();
10347 IEM_MC_END();
10348 break;
10349
10350 case IEMMODE_64BIT:
10351 IEM_MC_BEGIN(4, 0, IEM_MC_F_64BIT, 0);
10352 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
10353 IEM_MC_ARG(uint64_t *, pu64Dst, 0);
10354 IEM_MC_ARG(uint64_t *, pu64Rax, 1);
10355 IEM_MC_ARG(uint64_t, u64Src, 2);
10356 IEM_MC_ARG(uint32_t *, pEFlags, 3);
10357
10358 IEM_MC_FETCH_GREG_U64(u64Src, IEM_GET_MODRM_REG(pVCpu, bRm));
10359 IEM_MC_REF_GREG_U64(pu64Dst, IEM_GET_MODRM_RM(pVCpu, bRm));
10360 IEM_MC_REF_GREG_U64(pu64Rax, X86_GREG_xAX);
10361 IEM_MC_REF_EFLAGS(pEFlags);
10362 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpxchg_u64, pu64Dst, pu64Rax, u64Src, pEFlags);
10363
10364 IEM_MC_ADVANCE_RIP_AND_FINISH();
10365 IEM_MC_END();
10366 break;
10367
10368 IEM_NOT_REACHED_DEFAULT_CASE_RET();
10369 }
10370 }
10371 else
10372 {
10373#define IEMOP_BODY_CMPXCHG_EV_GV(a_fnWorker16, a_fnWorker32, a_fnWorker64) \
10374 do { \
10375 switch (pVCpu->iem.s.enmEffOpSize) \
10376 { \
10377 case IEMMODE_16BIT: \
10378 IEM_MC_BEGIN(4, 4, IEM_MC_F_MIN_486, 0); \
10379 \
10380 IEM_MC_LOCAL(uint8_t, bUnmapInfo); \
10381 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst); \
10382 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0); \
10383 IEMOP_HLP_DONE_DECODING(); \
10384 \
10385 IEM_MC_ARG(uint16_t *, pu16Dst, 0); \
10386 IEM_MC_MEM_MAP_U16_RW(pu16Dst, bUnmapInfo, pVCpu->iem.s.iEffSeg, GCPtrEffDst); \
10387 \
10388 IEM_MC_ARG(uint16_t, u16Src, 2); \
10389 IEM_MC_FETCH_GREG_U16(u16Src, IEM_GET_MODRM_REG(pVCpu, bRm)); \
10390 \
10391 IEM_MC_LOCAL(uint16_t, u16Ax); \
10392 IEM_MC_FETCH_GREG_U16(u16Ax, X86_GREG_xAX); \
10393 IEM_MC_ARG_LOCAL_REF(uint16_t *, pu16Ax, u16Ax, 1); \
10394 \
10395 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 3); \
10396 IEM_MC_FETCH_EFLAGS(EFlags); \
10397 IEM_MC_CALL_VOID_AIMPL_4(a_fnWorker16, pu16Dst, pu16Ax, u16Src, pEFlags); \
10398 \
10399 IEM_MC_MEM_COMMIT_AND_UNMAP_RW(bUnmapInfo); \
10400 IEM_MC_COMMIT_EFLAGS(EFlags); \
10401 IEM_MC_STORE_GREG_U16(X86_GREG_xAX, u16Ax); \
10402 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
10403 IEM_MC_END(); \
10404 break; \
10405 \
10406 case IEMMODE_32BIT: \
10407 IEM_MC_BEGIN(4, 4, IEM_MC_F_MIN_486, 0); \
10408 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst); \
10409 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0); \
10410 IEMOP_HLP_DONE_DECODING(); \
10411 \
10412 IEM_MC_LOCAL(uint8_t, bUnmapInfo); \
10413 IEM_MC_ARG(uint32_t *, pu32Dst, 0); \
10414 IEM_MC_MEM_MAP_U32_RW(pu32Dst, bUnmapInfo, pVCpu->iem.s.iEffSeg, GCPtrEffDst); \
10415 \
10416 IEM_MC_ARG(uint32_t, u32Src, 2); \
10417 IEM_MC_FETCH_GREG_U32(u32Src, IEM_GET_MODRM_REG(pVCpu, bRm)); \
10418 \
10419 IEM_MC_LOCAL(uint32_t, u32Eax); \
10420 IEM_MC_FETCH_GREG_U32(u32Eax, X86_GREG_xAX); \
10421 IEM_MC_ARG_LOCAL_REF(uint32_t *, pu32Eax, u32Eax, 1); \
10422 \
10423 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 3); \
10424 IEM_MC_FETCH_EFLAGS(EFlags); \
10425 IEM_MC_CALL_VOID_AIMPL_4(a_fnWorker32, pu32Dst, pu32Eax, u32Src, pEFlags); \
10426 \
10427 IEM_MC_MEM_COMMIT_AND_UNMAP_RW(bUnmapInfo); \
10428 IEM_MC_COMMIT_EFLAGS(EFlags); \
10429 \
10430 IEM_MC_IF_EFL_BIT_NOT_SET(X86_EFL_ZF) { \
10431 IEM_MC_STORE_GREG_U32(X86_GREG_xAX, u32Eax); \
10432 } IEM_MC_ENDIF(); \
10433 \
10434 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
10435 IEM_MC_END(); \
10436 break; \
10437 \
10438 case IEMMODE_64BIT: \
10439 IEM_MC_BEGIN(4, 4, IEM_MC_F_64BIT, 0); \
10440 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst); \
10441 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0); \
10442 IEMOP_HLP_DONE_DECODING(); \
10443 \
10444 IEM_MC_LOCAL(uint8_t, bUnmapInfo); \
10445 IEM_MC_ARG(uint64_t *, pu64Dst, 0); \
10446 IEM_MC_MEM_MAP_U64_RW(pu64Dst, bUnmapInfo, pVCpu->iem.s.iEffSeg, GCPtrEffDst); \
10447 \
10448 IEM_MC_ARG(uint64_t, u64Src, 2); \
10449 IEM_MC_FETCH_GREG_U64(u64Src, IEM_GET_MODRM_REG(pVCpu, bRm)); \
10450 \
10451 IEM_MC_LOCAL(uint64_t, u64Rax); \
10452 IEM_MC_FETCH_GREG_U64(u64Rax, X86_GREG_xAX); \
10453 IEM_MC_ARG_LOCAL_REF(uint64_t *, pu64Rax, u64Rax, 1); \
10454 \
10455 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 3); \
10456 IEM_MC_FETCH_EFLAGS(EFlags); \
10457 \
10458 IEM_MC_CALL_VOID_AIMPL_4(a_fnWorker64, pu64Dst, pu64Rax, u64Src, pEFlags); \
10459 \
10460 IEM_MC_MEM_COMMIT_AND_UNMAP_RW(bUnmapInfo); \
10461 IEM_MC_COMMIT_EFLAGS(EFlags); \
10462 IEM_MC_STORE_GREG_U64(X86_GREG_xAX, u64Rax); \
10463 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
10464 IEM_MC_END(); \
10465 break; \
10466 \
10467 IEM_NOT_REACHED_DEFAULT_CASE_RET(); \
10468 } \
10469 } while (0)
10470
10471 if (!(pVCpu->iem.s.fPrefixes & IEM_OP_PRF_LOCK) || (pVCpu->iem.s.fExec & IEM_F_X86_DISREGARD_LOCK))
10472 {
10473 IEMOP_BODY_CMPXCHG_EV_GV(iemAImpl_cmpxchg_u16, iemAImpl_cmpxchg_u32, iemAImpl_cmpxchg_u64);
10474 }
10475 else
10476 {
10477 IEMOP_BODY_CMPXCHG_EV_GV(iemAImpl_cmpxchg_u16_locked, iemAImpl_cmpxchg_u32_locked, iemAImpl_cmpxchg_u64_locked);
10478 }
10479 }
10480}
10481
10482
10483/** Opcode 0x0f 0xb2. */
10484FNIEMOP_DEF(iemOp_lss_Gv_Mp)
10485{
10486 IEMOP_MNEMONIC(lss_Gv_Mp, "lss Gv,Mp");
10487 IEMOP_HLP_MIN_386();
10488 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
10489 if (IEM_IS_MODRM_REG_MODE(bRm))
10490 IEMOP_RAISE_INVALID_OPCODE_RET();
10491 return FNIEMOP_CALL_2(iemOpCommonLoadSRegAndGreg, X86_SREG_SS, bRm);
10492}
10493
10494
10495/** Opcode 0x0f 0xb3. */
10496FNIEMOP_DEF(iemOp_btr_Ev_Gv)
10497{
10498 IEMOP_MNEMONIC(btr_Ev_Gv, "btr Ev,Gv");
10499 IEMOP_HLP_MIN_386();
10500 IEMOP_BODY_BIT_Ev_Gv_RW( iemAImpl_btr_u16, iemAImpl_btr_u32, iemAImpl_btr_u64);
10501 IEMOP_BODY_BIT_Ev_Gv_LOCKED(iemAImpl_btr_u16_locked, iemAImpl_btr_u32_locked, iemAImpl_btr_u64_locked);
10502}
10503
10504
10505/** Opcode 0x0f 0xb4. */
10506FNIEMOP_DEF(iemOp_lfs_Gv_Mp)
10507{
10508 IEMOP_MNEMONIC(lfs_Gv_Mp, "lfs Gv,Mp");
10509 IEMOP_HLP_MIN_386();
10510 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
10511 if (IEM_IS_MODRM_REG_MODE(bRm))
10512 IEMOP_RAISE_INVALID_OPCODE_RET();
10513 return FNIEMOP_CALL_2(iemOpCommonLoadSRegAndGreg, X86_SREG_FS, bRm);
10514}
10515
10516
10517/** Opcode 0x0f 0xb5. */
10518FNIEMOP_DEF(iemOp_lgs_Gv_Mp)
10519{
10520 IEMOP_MNEMONIC(lgs_Gv_Mp, "lgs Gv,Mp");
10521 IEMOP_HLP_MIN_386();
10522 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
10523 if (IEM_IS_MODRM_REG_MODE(bRm))
10524 IEMOP_RAISE_INVALID_OPCODE_RET();
10525 return FNIEMOP_CALL_2(iemOpCommonLoadSRegAndGreg, X86_SREG_GS, bRm);
10526}
10527
10528
10529/** Opcode 0x0f 0xb6. */
10530FNIEMOP_DEF(iemOp_movzx_Gv_Eb)
10531{
10532 IEMOP_MNEMONIC(movzx_Gv_Eb, "movzx Gv,Eb");
10533 IEMOP_HLP_MIN_386();
10534
10535 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
10536
10537 /*
10538 * If rm is denoting a register, no more instruction bytes.
10539 */
10540 if (IEM_IS_MODRM_REG_MODE(bRm))
10541 {
10542 switch (pVCpu->iem.s.enmEffOpSize)
10543 {
10544 case IEMMODE_16BIT:
10545 IEM_MC_BEGIN(0, 1, IEM_MC_F_MIN_386, 0);
10546 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
10547 IEM_MC_LOCAL(uint16_t, u16Value);
10548 IEM_MC_FETCH_GREG_U8_ZX_U16(u16Value, IEM_GET_MODRM_RM(pVCpu, bRm));
10549 IEM_MC_STORE_GREG_U16(IEM_GET_MODRM_REG(pVCpu, bRm), u16Value);
10550 IEM_MC_ADVANCE_RIP_AND_FINISH();
10551 IEM_MC_END();
10552 break;
10553
10554 case IEMMODE_32BIT:
10555 IEM_MC_BEGIN(0, 1, IEM_MC_F_MIN_386, 0);
10556 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
10557 IEM_MC_LOCAL(uint32_t, u32Value);
10558 IEM_MC_FETCH_GREG_U8_ZX_U32(u32Value, IEM_GET_MODRM_RM(pVCpu, bRm));
10559 IEM_MC_STORE_GREG_U32(IEM_GET_MODRM_REG(pVCpu, bRm), u32Value);
10560 IEM_MC_ADVANCE_RIP_AND_FINISH();
10561 IEM_MC_END();
10562 break;
10563
10564 case IEMMODE_64BIT:
10565 IEM_MC_BEGIN(0, 1, IEM_MC_F_64BIT, 0);
10566 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
10567 IEM_MC_LOCAL(uint64_t, u64Value);
10568 IEM_MC_FETCH_GREG_U8_ZX_U64(u64Value, IEM_GET_MODRM_RM(pVCpu, bRm));
10569 IEM_MC_STORE_GREG_U64(IEM_GET_MODRM_REG(pVCpu, bRm), u64Value);
10570 IEM_MC_ADVANCE_RIP_AND_FINISH();
10571 IEM_MC_END();
10572 break;
10573
10574 IEM_NOT_REACHED_DEFAULT_CASE_RET();
10575 }
10576 }
10577 else
10578 {
10579 /*
10580 * We're loading a register from memory.
10581 */
10582 switch (pVCpu->iem.s.enmEffOpSize)
10583 {
10584 case IEMMODE_16BIT:
10585 IEM_MC_BEGIN(0, 2, IEM_MC_F_MIN_386, 0);
10586 IEM_MC_LOCAL(uint16_t, u16Value);
10587 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
10588 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
10589 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
10590 IEM_MC_FETCH_MEM_U8_ZX_U16(u16Value, pVCpu->iem.s.iEffSeg, GCPtrEffDst);
10591 IEM_MC_STORE_GREG_U16(IEM_GET_MODRM_REG(pVCpu, bRm), u16Value);
10592 IEM_MC_ADVANCE_RIP_AND_FINISH();
10593 IEM_MC_END();
10594 break;
10595
10596 case IEMMODE_32BIT:
10597 IEM_MC_BEGIN(0, 2, IEM_MC_F_MIN_386, 0);
10598 IEM_MC_LOCAL(uint32_t, u32Value);
10599 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
10600 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
10601 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
10602 IEM_MC_FETCH_MEM_U8_ZX_U32(u32Value, pVCpu->iem.s.iEffSeg, GCPtrEffDst);
10603 IEM_MC_STORE_GREG_U32(IEM_GET_MODRM_REG(pVCpu, bRm), u32Value);
10604 IEM_MC_ADVANCE_RIP_AND_FINISH();
10605 IEM_MC_END();
10606 break;
10607
10608 case IEMMODE_64BIT:
10609 IEM_MC_BEGIN(0, 2, IEM_MC_F_64BIT, 0);
10610 IEM_MC_LOCAL(uint64_t, u64Value);
10611 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
10612 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
10613 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
10614 IEM_MC_FETCH_MEM_U8_ZX_U64(u64Value, pVCpu->iem.s.iEffSeg, GCPtrEffDst);
10615 IEM_MC_STORE_GREG_U64(IEM_GET_MODRM_REG(pVCpu, bRm), u64Value);
10616 IEM_MC_ADVANCE_RIP_AND_FINISH();
10617 IEM_MC_END();
10618 break;
10619
10620 IEM_NOT_REACHED_DEFAULT_CASE_RET();
10621 }
10622 }
10623}
10624
10625
10626/** Opcode 0x0f 0xb7. */
10627FNIEMOP_DEF(iemOp_movzx_Gv_Ew)
10628{
10629 IEMOP_MNEMONIC(movzx_Gv_Ew, "movzx Gv,Ew");
10630 IEMOP_HLP_MIN_386();
10631
10632 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
10633
10634 /** @todo Not entirely sure how the operand size prefix is handled here,
10635 * assuming that it will be ignored. Would be nice to have a few
10636 * test for this. */
10637
10638 /** @todo There should be no difference in the behaviour whether REX.W is
10639 * present or not... */
10640
10641 /*
10642 * If rm is denoting a register, no more instruction bytes.
10643 */
10644 if (IEM_IS_MODRM_REG_MODE(bRm))
10645 {
10646 if (pVCpu->iem.s.enmEffOpSize != IEMMODE_64BIT)
10647 {
10648 IEM_MC_BEGIN(0, 1, IEM_MC_F_MIN_386, 0);
10649 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
10650 IEM_MC_LOCAL(uint32_t, u32Value);
10651 IEM_MC_FETCH_GREG_U16_ZX_U32(u32Value, IEM_GET_MODRM_RM(pVCpu, bRm));
10652 IEM_MC_STORE_GREG_U32(IEM_GET_MODRM_REG(pVCpu, bRm), u32Value);
10653 IEM_MC_ADVANCE_RIP_AND_FINISH();
10654 IEM_MC_END();
10655 }
10656 else
10657 {
10658 IEM_MC_BEGIN(0, 1, IEM_MC_F_64BIT, 0);
10659 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
10660 IEM_MC_LOCAL(uint64_t, u64Value);
10661 IEM_MC_FETCH_GREG_U16_ZX_U64(u64Value, IEM_GET_MODRM_RM(pVCpu, bRm));
10662 IEM_MC_STORE_GREG_U64(IEM_GET_MODRM_REG(pVCpu, bRm), u64Value);
10663 IEM_MC_ADVANCE_RIP_AND_FINISH();
10664 IEM_MC_END();
10665 }
10666 }
10667 else
10668 {
10669 /*
10670 * We're loading a register from memory.
10671 */
10672 if (pVCpu->iem.s.enmEffOpSize != IEMMODE_64BIT)
10673 {
10674 IEM_MC_BEGIN(0, 2, IEM_MC_F_MIN_386, 0);
10675 IEM_MC_LOCAL(uint32_t, u32Value);
10676 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
10677 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
10678 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
10679 IEM_MC_FETCH_MEM_U16_ZX_U32(u32Value, pVCpu->iem.s.iEffSeg, GCPtrEffDst);
10680 IEM_MC_STORE_GREG_U32(IEM_GET_MODRM_REG(pVCpu, bRm), u32Value);
10681 IEM_MC_ADVANCE_RIP_AND_FINISH();
10682 IEM_MC_END();
10683 }
10684 else
10685 {
10686 IEM_MC_BEGIN(0, 2, IEM_MC_F_64BIT, 0);
10687 IEM_MC_LOCAL(uint64_t, u64Value);
10688 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
10689 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
10690 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
10691 IEM_MC_FETCH_MEM_U16_ZX_U64(u64Value, pVCpu->iem.s.iEffSeg, GCPtrEffDst);
10692 IEM_MC_STORE_GREG_U64(IEM_GET_MODRM_REG(pVCpu, bRm), u64Value);
10693 IEM_MC_ADVANCE_RIP_AND_FINISH();
10694 IEM_MC_END();
10695 }
10696 }
10697}
10698
10699
10700/** Opcode 0x0f 0xb8 - JMPE (reserved for emulator on IPF) */
10701FNIEMOP_UD_STUB(iemOp_jmpe);
10702
10703
10704/** Opcode 0xf3 0x0f 0xb8 - POPCNT Gv, Ev */
10705FNIEMOP_DEF(iemOp_popcnt_Gv_Ev)
10706{
10707 IEMOP_MNEMONIC2(RM, POPCNT, popcnt, Gv, Ev, DISOPTYPE_HARMLESS, 0);
10708 if (!IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fPopCnt)
10709 return iemOp_InvalidNeedRM(pVCpu);
10710#ifndef TST_IEM_CHECK_MC
10711# if (defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)) && !defined(IEM_WITHOUT_ASSEMBLY)
10712 static const IEMOPBINSIZES s_Native =
10713 { NULL, NULL, iemAImpl_popcnt_u16, NULL, iemAImpl_popcnt_u32, NULL, iemAImpl_popcnt_u64, NULL };
10714# endif
10715 static const IEMOPBINSIZES s_Fallback =
10716 { NULL, NULL, iemAImpl_popcnt_u16_fallback, NULL, iemAImpl_popcnt_u32_fallback, NULL, iemAImpl_popcnt_u64_fallback, NULL };
10717#endif
10718 const IEMOPBINSIZES * const pImpl = IEM_SELECT_HOST_OR_FALLBACK(fPopCnt, &s_Native, &s_Fallback);
10719 IEMOP_BODY_BINARY_rv_rm(pImpl->pfnNormalU16, pImpl->pfnNormalU32, pImpl->pfnNormalU64, 1, IEM_MC_F_NOT_286_OR_OLDER);
10720}
10721
10722
10723/**
10724 * @opcode 0xb9
10725 * @opinvalid intel-modrm
10726 * @optest ->
10727 */
10728FNIEMOP_DEF(iemOp_Grp10)
10729{
10730 /*
10731 * AMD does not decode beyond the 0xb9 whereas intel does the modr/m bit
10732 * too. See bs3-cpu-decoder-1.c32. So, we can forward to iemOp_InvalidNeedRM.
10733 */
10734 Log(("iemOp_Grp10 aka UD1 -> #UD\n"));
10735 IEMOP_MNEMONIC2EX(ud1, "ud1", RM, UD1, ud1, Gb, Eb, DISOPTYPE_INVALID, IEMOPHINT_IGNORES_OP_SIZES); /* just picked Gb,Eb here. */
10736 return FNIEMOP_CALL(iemOp_InvalidNeedRM);
10737}
10738
10739
10740/**
10741 * Body for group 8 bit instruction.
10742 */
10743#define IEMOP_BODY_BIT_Ev_Ib_RW(a_fnNormalU16, a_fnNormalU32, a_fnNormalU64) \
10744 IEMOP_VERIFICATION_UNDEFINED_EFLAGS(X86_EFL_OF | X86_EFL_SF | X86_EFL_ZF | X86_EFL_AF | X86_EFL_PF); \
10745 \
10746 if (IEM_IS_MODRM_REG_MODE(bRm)) \
10747 { \
10748 /* register destination. */ \
10749 uint8_t bImm; IEM_OPCODE_GET_NEXT_U8(&bImm); \
10750 \
10751 switch (pVCpu->iem.s.enmEffOpSize) \
10752 { \
10753 case IEMMODE_16BIT: \
10754 IEM_MC_BEGIN(3, 0, IEM_MC_F_MIN_386, 0); \
10755 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); \
10756 IEM_MC_ARG(uint16_t *, pu16Dst, 0); \
10757 IEM_MC_ARG_CONST(uint16_t, u16Src, /*=*/ bImm & 0x0f, 1); \
10758 IEM_MC_ARG(uint32_t *, pEFlags, 2); \
10759 \
10760 IEM_MC_REF_GREG_U16(pu16Dst, IEM_GET_MODRM_RM(pVCpu, bRm)); \
10761 IEM_MC_REF_EFLAGS(pEFlags); \
10762 IEM_MC_CALL_VOID_AIMPL_3(a_fnNormalU16, pu16Dst, u16Src, pEFlags); \
10763 \
10764 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
10765 IEM_MC_END(); \
10766 break; \
10767 \
10768 case IEMMODE_32BIT: \
10769 IEM_MC_BEGIN(3, 0, IEM_MC_F_MIN_386, 0); \
10770 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); \
10771 IEM_MC_ARG(uint32_t *, pu32Dst, 0); \
10772 IEM_MC_ARG_CONST(uint32_t, u32Src, /*=*/ bImm & 0x1f, 1); \
10773 IEM_MC_ARG(uint32_t *, pEFlags, 2); \
10774 \
10775 IEM_MC_REF_GREG_U32(pu32Dst, IEM_GET_MODRM_RM(pVCpu, bRm)); \
10776 IEM_MC_REF_EFLAGS(pEFlags); \
10777 IEM_MC_CALL_VOID_AIMPL_3(a_fnNormalU32, pu32Dst, u32Src, pEFlags); \
10778 \
10779 IEM_MC_CLEAR_HIGH_GREG_U64(IEM_GET_MODRM_RM(pVCpu, bRm)); \
10780 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
10781 IEM_MC_END(); \
10782 break; \
10783 \
10784 case IEMMODE_64BIT: \
10785 IEM_MC_BEGIN(3, 0, IEM_MC_F_64BIT, 0); \
10786 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); \
10787 IEM_MC_ARG(uint64_t *, pu64Dst, 0); \
10788 IEM_MC_ARG_CONST(uint64_t, u64Src, /*=*/ bImm & 0x3f, 1); \
10789 IEM_MC_ARG(uint32_t *, pEFlags, 2); \
10790 \
10791 IEM_MC_REF_GREG_U64(pu64Dst, IEM_GET_MODRM_RM(pVCpu, bRm)); \
10792 IEM_MC_REF_EFLAGS(pEFlags); \
10793 IEM_MC_CALL_VOID_AIMPL_3(a_fnNormalU64, pu64Dst, u64Src, pEFlags); \
10794 \
10795 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
10796 IEM_MC_END(); \
10797 break; \
10798 \
10799 IEM_NOT_REACHED_DEFAULT_CASE_RET(); \
10800 } \
10801 } \
10802 else \
10803 { \
10804 /* memory destination. */ \
10805 /** @todo test negative bit offsets! */ \
10806 if (!(pVCpu->iem.s.fPrefixes & IEM_OP_PRF_LOCK) || (pVCpu->iem.s.fExec & IEM_F_X86_DISREGARD_LOCK)) \
10807 { \
10808 switch (pVCpu->iem.s.enmEffOpSize) \
10809 { \
10810 case IEMMODE_16BIT: \
10811 IEM_MC_BEGIN(3, 3, IEM_MC_F_MIN_386, 0); \
10812 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst); \
10813 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 1); \
10814 \
10815 uint8_t bImm; IEM_OPCODE_GET_NEXT_U8(&bImm); \
10816 IEMOP_HLP_DONE_DECODING(); \
10817 \
10818 IEM_MC_LOCAL(uint8_t, bUnmapInfo); \
10819 IEM_MC_ARG(uint16_t *, pu16Dst, 0); \
10820 IEM_MC_MEM_MAP_U16_RW(pu16Dst, bUnmapInfo, pVCpu->iem.s.iEffSeg, GCPtrEffDst); \
10821 \
10822 IEM_MC_ARG_CONST(uint16_t, u16Src, /*=*/ bImm & 0x0f, 1); \
10823 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 2); \
10824 IEM_MC_FETCH_EFLAGS(EFlags); \
10825 IEM_MC_CALL_VOID_AIMPL_3(a_fnNormalU16, pu16Dst, u16Src, pEFlags); \
10826 \
10827 IEM_MC_MEM_COMMIT_AND_UNMAP_RW(bUnmapInfo); \
10828 IEM_MC_COMMIT_EFLAGS(EFlags); \
10829 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
10830 IEM_MC_END(); \
10831 break; \
10832 \
10833 case IEMMODE_32BIT: \
10834 IEM_MC_BEGIN(3, 3, IEM_MC_F_MIN_386, 0); \
10835 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst); \
10836 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 1); \
10837 \
10838 uint8_t bImm; IEM_OPCODE_GET_NEXT_U8(&bImm); \
10839 IEMOP_HLP_DONE_DECODING(); \
10840 \
10841 IEM_MC_LOCAL(uint8_t, bUnmapInfo); \
10842 IEM_MC_ARG(uint32_t *, pu32Dst, 0); \
10843 IEM_MC_MEM_MAP_U32_RW(pu32Dst, bUnmapInfo, pVCpu->iem.s.iEffSeg, GCPtrEffDst); \
10844 \
10845 IEM_MC_ARG_CONST(uint32_t, u32Src, /*=*/ bImm & 0x1f, 1); \
10846 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 2); \
10847 IEM_MC_FETCH_EFLAGS(EFlags); \
10848 IEM_MC_CALL_VOID_AIMPL_3(a_fnNormalU32, pu32Dst, u32Src, pEFlags); \
10849 \
10850 IEM_MC_MEM_COMMIT_AND_UNMAP_RW(bUnmapInfo); \
10851 IEM_MC_COMMIT_EFLAGS(EFlags); \
10852 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
10853 IEM_MC_END(); \
10854 break; \
10855 \
10856 case IEMMODE_64BIT: \
10857 IEM_MC_BEGIN(3, 3, IEM_MC_F_64BIT, 0); \
10858 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst); \
10859 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 1); \
10860 \
10861 uint8_t bImm; IEM_OPCODE_GET_NEXT_U8(&bImm); \
10862 IEMOP_HLP_DONE_DECODING(); \
10863 \
10864 IEM_MC_LOCAL(uint8_t, bUnmapInfo); \
10865 IEM_MC_ARG(uint64_t *, pu64Dst, 0); \
10866 IEM_MC_MEM_MAP_U64_RW(pu64Dst, bUnmapInfo, pVCpu->iem.s.iEffSeg, GCPtrEffDst); \
10867 \
10868 IEM_MC_ARG_CONST(uint64_t, u64Src, /*=*/ bImm & 0x3f, 1); \
10869 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 2); \
10870 IEM_MC_FETCH_EFLAGS(EFlags); \
10871 IEM_MC_CALL_VOID_AIMPL_3(a_fnNormalU64, pu64Dst, u64Src, pEFlags); \
10872 \
10873 IEM_MC_MEM_COMMIT_AND_UNMAP_RW(bUnmapInfo); \
10874 IEM_MC_COMMIT_EFLAGS(EFlags); \
10875 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
10876 IEM_MC_END(); \
10877 break; \
10878 \
10879 IEM_NOT_REACHED_DEFAULT_CASE_RET(); \
10880 } \
10881 } \
10882 else \
10883 { \
10884 (void)0
10885/* Separate macro to work around parsing issue in IEMAllInstPython.py */
10886#define IEMOP_BODY_BIT_Ev_Ib_LOCKED(a_fnLockedU16, a_fnLockedU32, a_fnLockedU64) \
10887 switch (pVCpu->iem.s.enmEffOpSize) \
10888 { \
10889 case IEMMODE_16BIT: \
10890 IEM_MC_BEGIN(3, 3, IEM_MC_F_MIN_386, 0); \
10891 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst); \
10892 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 1); \
10893 \
10894 uint8_t bImm; IEM_OPCODE_GET_NEXT_U8(&bImm); \
10895 IEMOP_HLP_DONE_DECODING(); \
10896 \
10897 IEM_MC_ARG(uint16_t *, pu16Dst, 0); \
10898 IEM_MC_LOCAL(uint8_t, bUnmapInfo); \
10899 IEM_MC_MEM_MAP_U16_RW(pu16Dst, bUnmapInfo, pVCpu->iem.s.iEffSeg, GCPtrEffDst); \
10900 \
10901 IEM_MC_ARG_CONST(uint16_t, u16Src, /*=*/ bImm & 0x0f, 1); \
10902 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 2); \
10903 IEM_MC_FETCH_EFLAGS(EFlags); \
10904 IEM_MC_CALL_VOID_AIMPL_3(a_fnLockedU16, pu16Dst, u16Src, pEFlags); \
10905 \
10906 IEM_MC_MEM_COMMIT_AND_UNMAP_RW(bUnmapInfo); \
10907 IEM_MC_COMMIT_EFLAGS(EFlags); \
10908 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
10909 IEM_MC_END(); \
10910 break; \
10911 \
10912 case IEMMODE_32BIT: \
10913 IEM_MC_BEGIN(3, 3, IEM_MC_F_MIN_386, 0); \
10914 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst); \
10915 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 1); \
10916 \
10917 uint8_t bImm; IEM_OPCODE_GET_NEXT_U8(&bImm); \
10918 IEMOP_HLP_DONE_DECODING(); \
10919 \
10920 IEM_MC_LOCAL(uint8_t, bUnmapInfo); \
10921 IEM_MC_ARG(uint32_t *, pu32Dst, 0); \
10922 IEM_MC_MEM_MAP_U32_RW(pu32Dst, bUnmapInfo, pVCpu->iem.s.iEffSeg, GCPtrEffDst); \
10923 \
10924 IEM_MC_ARG_CONST(uint32_t, u32Src, /*=*/ bImm & 0x1f, 1); \
10925 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 2); \
10926 IEM_MC_FETCH_EFLAGS(EFlags); \
10927 IEM_MC_CALL_VOID_AIMPL_3(a_fnLockedU32, pu32Dst, u32Src, pEFlags); \
10928 \
10929 IEM_MC_MEM_COMMIT_AND_UNMAP_RW(bUnmapInfo); \
10930 IEM_MC_COMMIT_EFLAGS(EFlags); \
10931 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
10932 IEM_MC_END(); \
10933 break; \
10934 \
10935 case IEMMODE_64BIT: \
10936 IEM_MC_BEGIN(3, 3, IEM_MC_F_64BIT, 0); \
10937 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst); \
10938 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 1); \
10939 \
10940 uint8_t bImm; IEM_OPCODE_GET_NEXT_U8(&bImm); \
10941 IEMOP_HLP_DONE_DECODING(); \
10942 \
10943 IEM_MC_LOCAL(uint8_t, bUnmapInfo); \
10944 IEM_MC_ARG(uint64_t *, pu64Dst, 0); \
10945 IEM_MC_MEM_MAP_U64_RW(pu64Dst, bUnmapInfo, pVCpu->iem.s.iEffSeg, GCPtrEffDst); \
10946 \
10947 IEM_MC_ARG_CONST(uint64_t, u64Src, /*=*/ bImm & 0x3f, 1); \
10948 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 2); \
10949 IEM_MC_FETCH_EFLAGS(EFlags); \
10950 IEM_MC_CALL_VOID_AIMPL_3(a_fnLockedU64, pu64Dst, u64Src, pEFlags); \
10951 \
10952 IEM_MC_MEM_COMMIT_AND_UNMAP_RW(bUnmapInfo); \
10953 IEM_MC_COMMIT_EFLAGS(EFlags); \
10954 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
10955 IEM_MC_END(); \
10956 break; \
10957 \
10958 IEM_NOT_REACHED_DEFAULT_CASE_RET(); \
10959 } \
10960 } \
10961 } \
10962 (void)0
10963
10964/* Read-only version (bt) */
10965#define IEMOP_BODY_BIT_Ev_Ib_RO(a_fnNormalU16, a_fnNormalU32, a_fnNormalU64) \
10966 IEMOP_VERIFICATION_UNDEFINED_EFLAGS(X86_EFL_OF | X86_EFL_SF | X86_EFL_ZF | X86_EFL_AF | X86_EFL_PF); \
10967 \
10968 if (IEM_IS_MODRM_REG_MODE(bRm)) \
10969 { \
10970 /* register destination. */ \
10971 uint8_t bImm; IEM_OPCODE_GET_NEXT_U8(&bImm); \
10972 \
10973 switch (pVCpu->iem.s.enmEffOpSize) \
10974 { \
10975 case IEMMODE_16BIT: \
10976 IEM_MC_BEGIN(3, 0, IEM_MC_F_MIN_386, 0); \
10977 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); \
10978 IEM_MC_ARG(uint16_t const *, pu16Dst, 0); \
10979 IEM_MC_ARG_CONST(uint16_t, u16Src, /*=*/ bImm & 0x0f, 1); \
10980 IEM_MC_ARG(uint32_t *, pEFlags, 2); \
10981 \
10982 IEM_MC_REF_GREG_U16_CONST(pu16Dst, IEM_GET_MODRM_RM(pVCpu, bRm)); \
10983 IEM_MC_REF_EFLAGS(pEFlags); \
10984 IEM_MC_CALL_VOID_AIMPL_3(a_fnNormalU16, pu16Dst, u16Src, pEFlags); \
10985 \
10986 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
10987 IEM_MC_END(); \
10988 break; \
10989 \
10990 case IEMMODE_32BIT: \
10991 IEM_MC_BEGIN(3, 0, IEM_MC_F_MIN_386, 0); \
10992 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); \
10993 IEM_MC_ARG(uint32_t const *, pu32Dst, 0); \
10994 IEM_MC_ARG_CONST(uint32_t, u32Src, /*=*/ bImm & 0x1f, 1); \
10995 IEM_MC_ARG(uint32_t *, pEFlags, 2); \
10996 \
10997 IEM_MC_REF_GREG_U32_CONST(pu32Dst, IEM_GET_MODRM_RM(pVCpu, bRm)); \
10998 IEM_MC_REF_EFLAGS(pEFlags); \
10999 IEM_MC_CALL_VOID_AIMPL_3(a_fnNormalU32, pu32Dst, u32Src, pEFlags); \
11000 \
11001 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
11002 IEM_MC_END(); \
11003 break; \
11004 \
11005 case IEMMODE_64BIT: \
11006 IEM_MC_BEGIN(3, 0, IEM_MC_F_64BIT, 0); \
11007 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); \
11008 IEM_MC_ARG(uint64_t const *, pu64Dst, 0); \
11009 IEM_MC_ARG_CONST(uint64_t, u64Src, /*=*/ bImm & 0x3f, 1); \
11010 IEM_MC_ARG(uint32_t *, pEFlags, 2); \
11011 \
11012 IEM_MC_REF_GREG_U64_CONST(pu64Dst, IEM_GET_MODRM_RM(pVCpu, bRm)); \
11013 IEM_MC_REF_EFLAGS(pEFlags); \
11014 IEM_MC_CALL_VOID_AIMPL_3(a_fnNormalU64, pu64Dst, u64Src, pEFlags); \
11015 \
11016 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
11017 IEM_MC_END(); \
11018 break; \
11019 \
11020 IEM_NOT_REACHED_DEFAULT_CASE_RET(); \
11021 } \
11022 } \
11023 else \
11024 { \
11025 /* memory destination. */ \
11026 /** @todo test negative bit offsets! */ \
11027 if (!(pVCpu->iem.s.fPrefixes & IEM_OP_PRF_LOCK) || (pVCpu->iem.s.fExec & IEM_F_X86_DISREGARD_LOCK)) \
11028 { \
11029 switch (pVCpu->iem.s.enmEffOpSize) \
11030 { \
11031 case IEMMODE_16BIT: \
11032 IEM_MC_BEGIN(3, 3, IEM_MC_F_MIN_386, 0); \
11033 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst); \
11034 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 1); \
11035 \
11036 uint8_t bImm; IEM_OPCODE_GET_NEXT_U8(&bImm); \
11037 IEMOP_HLP_DONE_DECODING(); \
11038 \
11039 IEM_MC_LOCAL(uint8_t, bUnmapInfo); \
11040 IEM_MC_ARG(uint16_t const *, pu16Dst, 0); \
11041 IEM_MC_MEM_MAP_U16_RO(pu16Dst, bUnmapInfo, pVCpu->iem.s.iEffSeg, GCPtrEffDst); \
11042 \
11043 IEM_MC_ARG_CONST(uint16_t, u16Src, /*=*/ bImm & 0x0f, 1); \
11044 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 2); \
11045 IEM_MC_FETCH_EFLAGS(EFlags); \
11046 IEM_MC_CALL_VOID_AIMPL_3(a_fnNormalU16, pu16Dst, u16Src, pEFlags); \
11047 \
11048 IEM_MC_MEM_COMMIT_AND_UNMAP_RO(bUnmapInfo); \
11049 IEM_MC_COMMIT_EFLAGS(EFlags); \
11050 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
11051 IEM_MC_END(); \
11052 break; \
11053 \
11054 case IEMMODE_32BIT: \
11055 IEM_MC_BEGIN(3, 3, IEM_MC_F_MIN_386, 0); \
11056 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst); \
11057 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 1); \
11058 \
11059 uint8_t bImm; IEM_OPCODE_GET_NEXT_U8(&bImm); \
11060 IEMOP_HLP_DONE_DECODING(); \
11061 \
11062 IEM_MC_LOCAL(uint8_t, bUnmapInfo); \
11063 IEM_MC_ARG(uint32_t const *, pu32Dst, 0); \
11064 IEM_MC_MEM_MAP_U32_RO(pu32Dst, bUnmapInfo, pVCpu->iem.s.iEffSeg, GCPtrEffDst); \
11065 \
11066 IEM_MC_ARG_CONST(uint32_t, u32Src, /*=*/ bImm & 0x1f, 1); \
11067 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 2); \
11068 IEM_MC_FETCH_EFLAGS(EFlags); \
11069 IEM_MC_CALL_VOID_AIMPL_3(a_fnNormalU32, pu32Dst, u32Src, pEFlags); \
11070 \
11071 IEM_MC_MEM_COMMIT_AND_UNMAP_RO(bUnmapInfo); \
11072 IEM_MC_COMMIT_EFLAGS(EFlags); \
11073 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
11074 IEM_MC_END(); \
11075 break; \
11076 \
11077 case IEMMODE_64BIT: \
11078 IEM_MC_BEGIN(3, 3, IEM_MC_F_64BIT, 0); \
11079 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst); \
11080 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 1); \
11081 \
11082 uint8_t bImm; IEM_OPCODE_GET_NEXT_U8(&bImm); \
11083 IEMOP_HLP_DONE_DECODING(); \
11084 \
11085 IEM_MC_LOCAL(uint8_t, bUnmapInfo); \
11086 IEM_MC_ARG(uint64_t const *, pu64Dst, 0); \
11087 IEM_MC_MEM_MAP_U64_RO(pu64Dst, bUnmapInfo, pVCpu->iem.s.iEffSeg, GCPtrEffDst); \
11088 \
11089 IEM_MC_ARG_CONST(uint64_t, u64Src, /*=*/ bImm & 0x3f, 1); \
11090 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 2); \
11091 IEM_MC_FETCH_EFLAGS(EFlags); \
11092 IEM_MC_CALL_VOID_AIMPL_3(a_fnNormalU64, pu64Dst, u64Src, pEFlags); \
11093 \
11094 IEM_MC_MEM_COMMIT_AND_UNMAP_RO(bUnmapInfo); \
11095 IEM_MC_COMMIT_EFLAGS(EFlags); \
11096 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
11097 IEM_MC_END(); \
11098 break; \
11099 \
11100 IEM_NOT_REACHED_DEFAULT_CASE_RET(); \
11101 } \
11102 } \
11103 else \
11104 { \
11105 IEMOP_HLP_DONE_DECODING(); \
11106 IEMOP_RAISE_INVALID_LOCK_PREFIX_RET(); \
11107 } \
11108 } \
11109 (void)0
11110
11111
11112/** Opcode 0x0f 0xba /4. */
11113FNIEMOPRM_DEF(iemOp_Grp8_bt_Ev_Ib)
11114{
11115 IEMOP_MNEMONIC(bt_Ev_Ib, "bt Ev,Ib");
11116 IEMOP_BODY_BIT_Ev_Ib_RO(iemAImpl_bt_u16, iemAImpl_bt_u32, iemAImpl_bt_u64);
11117}
11118
11119
11120/** Opcode 0x0f 0xba /5. */
11121FNIEMOPRM_DEF(iemOp_Grp8_bts_Ev_Ib)
11122{
11123 IEMOP_MNEMONIC(bts_Ev_Ib, "bts Ev,Ib");
11124 IEMOP_BODY_BIT_Ev_Ib_RW( iemAImpl_bts_u16, iemAImpl_bts_u32, iemAImpl_bts_u64);
11125 IEMOP_BODY_BIT_Ev_Ib_LOCKED(iemAImpl_bts_u16_locked, iemAImpl_bts_u32_locked, iemAImpl_bts_u64_locked);
11126}
11127
11128
11129/** Opcode 0x0f 0xba /6. */
11130FNIEMOPRM_DEF(iemOp_Grp8_btr_Ev_Ib)
11131{
11132 IEMOP_MNEMONIC(btr_Ev_Ib, "btr Ev,Ib");
11133 IEMOP_BODY_BIT_Ev_Ib_RW( iemAImpl_btr_u16, iemAImpl_btr_u32, iemAImpl_btr_u64);
11134 IEMOP_BODY_BIT_Ev_Ib_LOCKED(iemAImpl_btr_u16_locked, iemAImpl_btr_u32_locked, iemAImpl_btr_u64_locked);
11135}
11136
11137
11138/** Opcode 0x0f 0xba /7. */
11139FNIEMOPRM_DEF(iemOp_Grp8_btc_Ev_Ib)
11140{
11141 IEMOP_MNEMONIC(btc_Ev_Ib, "btc Ev,Ib");
11142 IEMOP_BODY_BIT_Ev_Ib_RW( iemAImpl_btc_u16, iemAImpl_btc_u32, iemAImpl_btc_u64);
11143 IEMOP_BODY_BIT_Ev_Ib_LOCKED(iemAImpl_btc_u16_locked, iemAImpl_btc_u32_locked, iemAImpl_btc_u64_locked);
11144}
11145
11146
11147/** Opcode 0x0f 0xba. */
11148FNIEMOP_DEF(iemOp_Grp8)
11149{
11150 IEMOP_HLP_MIN_386();
11151 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
11152 switch (IEM_GET_MODRM_REG_8(bRm))
11153 {
11154 case 4: return FNIEMOP_CALL_1(iemOp_Grp8_bt_Ev_Ib, bRm);
11155 case 5: return FNIEMOP_CALL_1(iemOp_Grp8_bts_Ev_Ib, bRm);
11156 case 6: return FNIEMOP_CALL_1(iemOp_Grp8_btr_Ev_Ib, bRm);
11157 case 7: return FNIEMOP_CALL_1(iemOp_Grp8_btc_Ev_Ib, bRm);
11158
11159 case 0: case 1: case 2: case 3:
11160 /* Both AMD and Intel want full modr/m decoding and imm8. */
11161 return FNIEMOP_CALL_1(iemOp_InvalidWithRMAllNeedImm8, bRm);
11162
11163 IEM_NOT_REACHED_DEFAULT_CASE_RET();
11164 }
11165}
11166
11167
11168/** Opcode 0x0f 0xbb. */
11169FNIEMOP_DEF(iemOp_btc_Ev_Gv)
11170{
11171 IEMOP_MNEMONIC(btc_Ev_Gv, "btc Ev,Gv");
11172 IEMOP_HLP_MIN_386();
11173 IEMOP_BODY_BIT_Ev_Gv_RW( iemAImpl_btc_u16, iemAImpl_btc_u32, iemAImpl_btc_u64);
11174 IEMOP_BODY_BIT_Ev_Gv_LOCKED(iemAImpl_btc_u16_locked, iemAImpl_btc_u32_locked, iemAImpl_btc_u64_locked);
11175}
11176
11177
11178/**
11179 * Common worker for BSF and BSR instructions.
11180 *
11181 * These cannot use iemOpHlpBinaryOperator_rv_rm because they don't always write
11182 * the destination register, which means that for 32-bit operations the high
11183 * bits must be left alone.
11184 *
11185 * @param pImpl Pointer to the instruction implementation (assembly).
11186 */
11187FNIEMOP_DEF_1(iemOpHlpBitScanOperator_rv_rm, PCIEMOPBINSIZES, pImpl)
11188{
11189 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
11190
11191 /*
11192 * If rm is denoting a register, no more instruction bytes.
11193 */
11194 if (IEM_IS_MODRM_REG_MODE(bRm))
11195 {
11196 switch (pVCpu->iem.s.enmEffOpSize)
11197 {
11198 case IEMMODE_16BIT:
11199 IEM_MC_BEGIN(3, 0, IEM_MC_F_MIN_386, 0);
11200 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
11201 IEM_MC_ARG(uint16_t *, pu16Dst, 0);
11202 IEM_MC_ARG(uint16_t, u16Src, 1);
11203 IEM_MC_ARG(uint32_t *, pEFlags, 2);
11204
11205 IEM_MC_FETCH_GREG_U16(u16Src, IEM_GET_MODRM_RM(pVCpu, bRm));
11206 IEM_MC_REF_GREG_U16(pu16Dst, IEM_GET_MODRM_REG(pVCpu, bRm));
11207 IEM_MC_REF_EFLAGS(pEFlags);
11208 IEM_MC_CALL_VOID_AIMPL_3(pImpl->pfnNormalU16, pu16Dst, u16Src, pEFlags);
11209
11210 IEM_MC_ADVANCE_RIP_AND_FINISH();
11211 IEM_MC_END();
11212 break;
11213
11214 case IEMMODE_32BIT:
11215 IEM_MC_BEGIN(3, 0, IEM_MC_F_MIN_386, 0);
11216 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
11217 IEM_MC_ARG(uint32_t *, pu32Dst, 0);
11218 IEM_MC_ARG(uint32_t, u32Src, 1);
11219 IEM_MC_ARG(uint32_t *, pEFlags, 2);
11220
11221 IEM_MC_FETCH_GREG_U32(u32Src, IEM_GET_MODRM_RM(pVCpu, bRm));
11222 IEM_MC_REF_GREG_U32(pu32Dst, IEM_GET_MODRM_REG(pVCpu, bRm));
11223 IEM_MC_REF_EFLAGS(pEFlags);
11224 IEM_MC_CALL_VOID_AIMPL_3(pImpl->pfnNormalU32, pu32Dst, u32Src, pEFlags);
11225 IEM_MC_IF_EFL_BIT_NOT_SET(X86_EFL_ZF) {
11226 IEM_MC_CLEAR_HIGH_GREG_U64(IEM_GET_MODRM_REG(pVCpu, bRm));
11227 } IEM_MC_ENDIF();
11228 IEM_MC_ADVANCE_RIP_AND_FINISH();
11229 IEM_MC_END();
11230 break;
11231
11232 case IEMMODE_64BIT:
11233 IEM_MC_BEGIN(3, 0, IEM_MC_F_64BIT, 0);
11234 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
11235 IEM_MC_ARG(uint64_t *, pu64Dst, 0);
11236 IEM_MC_ARG(uint64_t, u64Src, 1);
11237 IEM_MC_ARG(uint32_t *, pEFlags, 2);
11238
11239 IEM_MC_FETCH_GREG_U64(u64Src, IEM_GET_MODRM_RM(pVCpu, bRm));
11240 IEM_MC_REF_GREG_U64(pu64Dst, IEM_GET_MODRM_REG(pVCpu, bRm));
11241 IEM_MC_REF_EFLAGS(pEFlags);
11242 IEM_MC_CALL_VOID_AIMPL_3(pImpl->pfnNormalU64, pu64Dst, u64Src, pEFlags);
11243
11244 IEM_MC_ADVANCE_RIP_AND_FINISH();
11245 IEM_MC_END();
11246 break;
11247
11248 IEM_NOT_REACHED_DEFAULT_CASE_RET();
11249 }
11250 }
11251 else
11252 {
11253 /*
11254 * We're accessing memory.
11255 */
11256 switch (pVCpu->iem.s.enmEffOpSize)
11257 {
11258 case IEMMODE_16BIT:
11259 IEM_MC_BEGIN(3, 1, IEM_MC_F_MIN_386, 0);
11260 IEM_MC_ARG(uint16_t *, pu16Dst, 0);
11261 IEM_MC_ARG(uint16_t, u16Src, 1);
11262 IEM_MC_ARG(uint32_t *, pEFlags, 2);
11263 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
11264
11265 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
11266 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
11267 IEM_MC_FETCH_MEM_U16(u16Src, pVCpu->iem.s.iEffSeg, GCPtrEffDst);
11268 IEM_MC_REF_GREG_U16(pu16Dst, IEM_GET_MODRM_REG(pVCpu, bRm));
11269 IEM_MC_REF_EFLAGS(pEFlags);
11270 IEM_MC_CALL_VOID_AIMPL_3(pImpl->pfnNormalU16, pu16Dst, u16Src, pEFlags);
11271
11272 IEM_MC_ADVANCE_RIP_AND_FINISH();
11273 IEM_MC_END();
11274 break;
11275
11276 case IEMMODE_32BIT:
11277 IEM_MC_BEGIN(3, 1, IEM_MC_F_MIN_386, 0);
11278 IEM_MC_ARG(uint32_t *, pu32Dst, 0);
11279 IEM_MC_ARG(uint32_t, u32Src, 1);
11280 IEM_MC_ARG(uint32_t *, pEFlags, 2);
11281 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
11282
11283 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
11284 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
11285 IEM_MC_FETCH_MEM_U32(u32Src, pVCpu->iem.s.iEffSeg, GCPtrEffDst);
11286 IEM_MC_REF_GREG_U32(pu32Dst, IEM_GET_MODRM_REG(pVCpu, bRm));
11287 IEM_MC_REF_EFLAGS(pEFlags);
11288 IEM_MC_CALL_VOID_AIMPL_3(pImpl->pfnNormalU32, pu32Dst, u32Src, pEFlags);
11289
11290 IEM_MC_IF_EFL_BIT_NOT_SET(X86_EFL_ZF) {
11291 IEM_MC_CLEAR_HIGH_GREG_U64(IEM_GET_MODRM_REG(pVCpu, bRm));
11292 } IEM_MC_ENDIF();
11293 IEM_MC_ADVANCE_RIP_AND_FINISH();
11294 IEM_MC_END();
11295 break;
11296
11297 case IEMMODE_64BIT:
11298 IEM_MC_BEGIN(3, 1, IEM_MC_F_64BIT, 0);
11299 IEM_MC_ARG(uint64_t *, pu64Dst, 0);
11300 IEM_MC_ARG(uint64_t, u64Src, 1);
11301 IEM_MC_ARG(uint32_t *, pEFlags, 2);
11302 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
11303
11304 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
11305 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
11306 IEM_MC_FETCH_MEM_U64(u64Src, pVCpu->iem.s.iEffSeg, GCPtrEffDst);
11307 IEM_MC_REF_GREG_U64(pu64Dst, IEM_GET_MODRM_REG(pVCpu, bRm));
11308 IEM_MC_REF_EFLAGS(pEFlags);
11309 IEM_MC_CALL_VOID_AIMPL_3(pImpl->pfnNormalU64, pu64Dst, u64Src, pEFlags);
11310
11311 IEM_MC_ADVANCE_RIP_AND_FINISH();
11312 IEM_MC_END();
11313 break;
11314
11315 IEM_NOT_REACHED_DEFAULT_CASE_RET();
11316 }
11317 }
11318}
11319
11320
11321/** Opcode 0x0f 0xbc. */
11322FNIEMOP_DEF(iemOp_bsf_Gv_Ev)
11323{
11324 IEMOP_MNEMONIC(bsf_Gv_Ev, "bsf Gv,Ev");
11325 IEMOP_HLP_MIN_386();
11326 IEMOP_VERIFICATION_UNDEFINED_EFLAGS(X86_EFL_OF | X86_EFL_SF | X86_EFL_AF | X86_EFL_PF | X86_EFL_CF);
11327 return FNIEMOP_CALL_1(iemOpHlpBitScanOperator_rv_rm, IEMTARGETCPU_EFL_BEHAVIOR_SELECT(g_iemAImpl_bsf_eflags));
11328}
11329
11330
11331/** Opcode 0xf3 0x0f 0xbc - TZCNT Gv, Ev */
11332FNIEMOP_DEF(iemOp_tzcnt_Gv_Ev)
11333{
11334 if (!IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fBmi1)
11335 return FNIEMOP_CALL(iemOp_bsf_Gv_Ev);
11336 IEMOP_MNEMONIC2(RM, TZCNT, tzcnt, Gv, Ev, DISOPTYPE_HARMLESS, 0);
11337
11338#ifndef TST_IEM_CHECK_MC
11339 static const IEMOPBINSIZES s_iemAImpl_tzcnt =
11340 { NULL, NULL, iemAImpl_tzcnt_u16, NULL, iemAImpl_tzcnt_u32, NULL, iemAImpl_tzcnt_u64, NULL };
11341 static const IEMOPBINSIZES s_iemAImpl_tzcnt_amd =
11342 { NULL, NULL, iemAImpl_tzcnt_u16_amd, NULL, iemAImpl_tzcnt_u32_amd, NULL, iemAImpl_tzcnt_u64_amd, NULL };
11343 static const IEMOPBINSIZES s_iemAImpl_tzcnt_intel =
11344 { NULL, NULL, iemAImpl_tzcnt_u16_intel, NULL, iemAImpl_tzcnt_u32_intel, NULL, iemAImpl_tzcnt_u64_intel, NULL };
11345 static const IEMOPBINSIZES * const s_iemAImpl_tzcnt_eflags[2][4] =
11346 {
11347 { &s_iemAImpl_tzcnt_intel, &s_iemAImpl_tzcnt_intel, &s_iemAImpl_tzcnt_amd, &s_iemAImpl_tzcnt_intel },
11348 { &s_iemAImpl_tzcnt, &s_iemAImpl_tzcnt_intel, &s_iemAImpl_tzcnt_amd, &s_iemAImpl_tzcnt }
11349 };
11350#endif
11351 IEMOP_VERIFICATION_UNDEFINED_EFLAGS(X86_EFL_OF | X86_EFL_SF | X86_EFL_AF | X86_EFL_PF);
11352 const IEMOPBINSIZES * const pImpl = IEMTARGETCPU_EFL_BEHAVIOR_SELECT_EX(s_iemAImpl_tzcnt_eflags,
11353 IEM_GET_HOST_CPU_FEATURES(pVCpu)->fBmi1);
11354 IEMOP_BODY_BINARY_rv_rm(pImpl->pfnNormalU16, pImpl->pfnNormalU32, pImpl->pfnNormalU64, 1, IEM_MC_F_NOT_286_OR_OLDER);
11355}
11356
11357
11358/** Opcode 0x0f 0xbd. */
11359FNIEMOP_DEF(iemOp_bsr_Gv_Ev)
11360{
11361 IEMOP_MNEMONIC(bsr_Gv_Ev, "bsr Gv,Ev");
11362 IEMOP_HLP_MIN_386();
11363 IEMOP_VERIFICATION_UNDEFINED_EFLAGS(X86_EFL_OF | X86_EFL_SF | X86_EFL_AF | X86_EFL_PF | X86_EFL_CF);
11364 return FNIEMOP_CALL_1(iemOpHlpBitScanOperator_rv_rm, IEMTARGETCPU_EFL_BEHAVIOR_SELECT(g_iemAImpl_bsr_eflags));
11365}
11366
11367
11368/** Opcode 0xf3 0x0f 0xbd - LZCNT Gv, Ev */
11369FNIEMOP_DEF(iemOp_lzcnt_Gv_Ev)
11370{
11371 if (!IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fBmi1)
11372 return FNIEMOP_CALL(iemOp_bsr_Gv_Ev);
11373 IEMOP_MNEMONIC2(RM, LZCNT, lzcnt, Gv, Ev, DISOPTYPE_HARMLESS, 0);
11374
11375#ifndef TST_IEM_CHECK_MC
11376 static const IEMOPBINSIZES s_iemAImpl_lzcnt =
11377 { NULL, NULL, iemAImpl_lzcnt_u16, NULL, iemAImpl_lzcnt_u32, NULL, iemAImpl_lzcnt_u64, NULL };
11378 static const IEMOPBINSIZES s_iemAImpl_lzcnt_amd =
11379 { NULL, NULL, iemAImpl_lzcnt_u16_amd, NULL, iemAImpl_lzcnt_u32_amd, NULL, iemAImpl_lzcnt_u64_amd, NULL };
11380 static const IEMOPBINSIZES s_iemAImpl_lzcnt_intel =
11381 { NULL, NULL, iemAImpl_lzcnt_u16_intel, NULL, iemAImpl_lzcnt_u32_intel, NULL, iemAImpl_lzcnt_u64_intel, NULL };
11382 static const IEMOPBINSIZES * const s_iemAImpl_lzcnt_eflags[2][4] =
11383 {
11384 { &s_iemAImpl_lzcnt_intel, &s_iemAImpl_lzcnt_intel, &s_iemAImpl_lzcnt_amd, &s_iemAImpl_lzcnt_intel },
11385 { &s_iemAImpl_lzcnt, &s_iemAImpl_lzcnt_intel, &s_iemAImpl_lzcnt_amd, &s_iemAImpl_lzcnt }
11386 };
11387#endif
11388 IEMOP_VERIFICATION_UNDEFINED_EFLAGS(X86_EFL_OF | X86_EFL_SF | X86_EFL_AF | X86_EFL_PF);
11389 const IEMOPBINSIZES * const pImpl = IEMTARGETCPU_EFL_BEHAVIOR_SELECT_EX(s_iemAImpl_lzcnt_eflags,
11390 IEM_GET_HOST_CPU_FEATURES(pVCpu)->fBmi1);
11391 IEMOP_BODY_BINARY_rv_rm(pImpl->pfnNormalU16, pImpl->pfnNormalU32, pImpl->pfnNormalU64, 1, IEM_MC_F_NOT_286_OR_OLDER);
11392}
11393
11394
11395
11396/** Opcode 0x0f 0xbe. */
11397FNIEMOP_DEF(iemOp_movsx_Gv_Eb)
11398{
11399 IEMOP_MNEMONIC(movsx_Gv_Eb, "movsx Gv,Eb");
11400 IEMOP_HLP_MIN_386();
11401
11402 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
11403
11404 /*
11405 * If rm is denoting a register, no more instruction bytes.
11406 */
11407 if (IEM_IS_MODRM_REG_MODE(bRm))
11408 {
11409 switch (pVCpu->iem.s.enmEffOpSize)
11410 {
11411 case IEMMODE_16BIT:
11412 IEM_MC_BEGIN(0, 1, IEM_MC_F_MIN_386, 0);
11413 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
11414 IEM_MC_LOCAL(uint16_t, u16Value);
11415 IEM_MC_FETCH_GREG_U8_SX_U16(u16Value, IEM_GET_MODRM_RM(pVCpu, bRm));
11416 IEM_MC_STORE_GREG_U16(IEM_GET_MODRM_REG(pVCpu, bRm), u16Value);
11417 IEM_MC_ADVANCE_RIP_AND_FINISH();
11418 IEM_MC_END();
11419 break;
11420
11421 case IEMMODE_32BIT:
11422 IEM_MC_BEGIN(0, 1, IEM_MC_F_MIN_386, 0);
11423 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
11424 IEM_MC_LOCAL(uint32_t, u32Value);
11425 IEM_MC_FETCH_GREG_U8_SX_U32(u32Value, IEM_GET_MODRM_RM(pVCpu, bRm));
11426 IEM_MC_STORE_GREG_U32(IEM_GET_MODRM_REG(pVCpu, bRm), u32Value);
11427 IEM_MC_ADVANCE_RIP_AND_FINISH();
11428 IEM_MC_END();
11429 break;
11430
11431 case IEMMODE_64BIT:
11432 IEM_MC_BEGIN(0, 1, IEM_MC_F_64BIT, 0);
11433 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
11434 IEM_MC_LOCAL(uint64_t, u64Value);
11435 IEM_MC_FETCH_GREG_U8_SX_U64(u64Value, IEM_GET_MODRM_RM(pVCpu, bRm));
11436 IEM_MC_STORE_GREG_U64(IEM_GET_MODRM_REG(pVCpu, bRm), u64Value);
11437 IEM_MC_ADVANCE_RIP_AND_FINISH();
11438 IEM_MC_END();
11439 break;
11440
11441 IEM_NOT_REACHED_DEFAULT_CASE_RET();
11442 }
11443 }
11444 else
11445 {
11446 /*
11447 * We're loading a register from memory.
11448 */
11449 switch (pVCpu->iem.s.enmEffOpSize)
11450 {
11451 case IEMMODE_16BIT:
11452 IEM_MC_BEGIN(0, 2, IEM_MC_F_MIN_386, 0);
11453 IEM_MC_LOCAL(uint16_t, u16Value);
11454 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
11455 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
11456 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
11457 IEM_MC_FETCH_MEM_U8_SX_U16(u16Value, pVCpu->iem.s.iEffSeg, GCPtrEffDst);
11458 IEM_MC_STORE_GREG_U16(IEM_GET_MODRM_REG(pVCpu, bRm), u16Value);
11459 IEM_MC_ADVANCE_RIP_AND_FINISH();
11460 IEM_MC_END();
11461 break;
11462
11463 case IEMMODE_32BIT:
11464 IEM_MC_BEGIN(0, 2, IEM_MC_F_MIN_386, 0);
11465 IEM_MC_LOCAL(uint32_t, u32Value);
11466 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
11467 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
11468 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
11469 IEM_MC_FETCH_MEM_U8_SX_U32(u32Value, pVCpu->iem.s.iEffSeg, GCPtrEffDst);
11470 IEM_MC_STORE_GREG_U32(IEM_GET_MODRM_REG(pVCpu, bRm), u32Value);
11471 IEM_MC_ADVANCE_RIP_AND_FINISH();
11472 IEM_MC_END();
11473 break;
11474
11475 case IEMMODE_64BIT:
11476 IEM_MC_BEGIN(0, 2, IEM_MC_F_64BIT, 0);
11477 IEM_MC_LOCAL(uint64_t, u64Value);
11478 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
11479 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
11480 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
11481 IEM_MC_FETCH_MEM_U8_SX_U64(u64Value, pVCpu->iem.s.iEffSeg, GCPtrEffDst);
11482 IEM_MC_STORE_GREG_U64(IEM_GET_MODRM_REG(pVCpu, bRm), u64Value);
11483 IEM_MC_ADVANCE_RIP_AND_FINISH();
11484 IEM_MC_END();
11485 break;
11486
11487 IEM_NOT_REACHED_DEFAULT_CASE_RET();
11488 }
11489 }
11490}
11491
11492
11493/** Opcode 0x0f 0xbf. */
11494FNIEMOP_DEF(iemOp_movsx_Gv_Ew)
11495{
11496 IEMOP_MNEMONIC(movsx_Gv_Ew, "movsx Gv,Ew");
11497 IEMOP_HLP_MIN_386();
11498
11499 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
11500
11501 /** @todo Not entirely sure how the operand size prefix is handled here,
11502 * assuming that it will be ignored. Would be nice to have a few
11503 * test for this. */
11504 /*
11505 * If rm is denoting a register, no more instruction bytes.
11506 */
11507 if (IEM_IS_MODRM_REG_MODE(bRm))
11508 {
11509 if (pVCpu->iem.s.enmEffOpSize != IEMMODE_64BIT)
11510 {
11511 IEM_MC_BEGIN(0, 1, IEM_MC_F_MIN_386, 0);
11512 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
11513 IEM_MC_LOCAL(uint32_t, u32Value);
11514 IEM_MC_FETCH_GREG_U16_SX_U32(u32Value, IEM_GET_MODRM_RM(pVCpu, bRm));
11515 IEM_MC_STORE_GREG_U32(IEM_GET_MODRM_REG(pVCpu, bRm), u32Value);
11516 IEM_MC_ADVANCE_RIP_AND_FINISH();
11517 IEM_MC_END();
11518 }
11519 else
11520 {
11521 IEM_MC_BEGIN(0, 1, IEM_MC_F_64BIT, 0);
11522 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
11523 IEM_MC_LOCAL(uint64_t, u64Value);
11524 IEM_MC_FETCH_GREG_U16_SX_U64(u64Value, IEM_GET_MODRM_RM(pVCpu, bRm));
11525 IEM_MC_STORE_GREG_U64(IEM_GET_MODRM_REG(pVCpu, bRm), u64Value);
11526 IEM_MC_ADVANCE_RIP_AND_FINISH();
11527 IEM_MC_END();
11528 }
11529 }
11530 else
11531 {
11532 /*
11533 * We're loading a register from memory.
11534 */
11535 if (pVCpu->iem.s.enmEffOpSize != IEMMODE_64BIT)
11536 {
11537 IEM_MC_BEGIN(0, 2, IEM_MC_F_MIN_386, 0);
11538 IEM_MC_LOCAL(uint32_t, u32Value);
11539 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
11540 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
11541 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
11542 IEM_MC_FETCH_MEM_U16_SX_U32(u32Value, pVCpu->iem.s.iEffSeg, GCPtrEffDst);
11543 IEM_MC_STORE_GREG_U32(IEM_GET_MODRM_REG(pVCpu, bRm), u32Value);
11544 IEM_MC_ADVANCE_RIP_AND_FINISH();
11545 IEM_MC_END();
11546 }
11547 else
11548 {
11549 IEM_MC_BEGIN(0, 2, IEM_MC_F_64BIT, 0);
11550 IEM_MC_LOCAL(uint64_t, u64Value);
11551 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
11552 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
11553 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
11554 IEM_MC_FETCH_MEM_U16_SX_U64(u64Value, pVCpu->iem.s.iEffSeg, GCPtrEffDst);
11555 IEM_MC_STORE_GREG_U64(IEM_GET_MODRM_REG(pVCpu, bRm), u64Value);
11556 IEM_MC_ADVANCE_RIP_AND_FINISH();
11557 IEM_MC_END();
11558 }
11559 }
11560}
11561
11562
11563/** Opcode 0x0f 0xc0. */
11564FNIEMOP_DEF(iemOp_xadd_Eb_Gb)
11565{
11566 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
11567 IEMOP_HLP_MIN_486();
11568 IEMOP_MNEMONIC(xadd_Eb_Gb, "xadd Eb,Gb");
11569
11570 /*
11571 * If rm is denoting a register, no more instruction bytes.
11572 */
11573 if (IEM_IS_MODRM_REG_MODE(bRm))
11574 {
11575 IEM_MC_BEGIN(3, 0, IEM_MC_F_MIN_486, 0);
11576 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
11577 IEM_MC_ARG(uint8_t *, pu8Dst, 0);
11578 IEM_MC_ARG(uint8_t *, pu8Reg, 1);
11579 IEM_MC_ARG(uint32_t *, pEFlags, 2);
11580
11581 IEM_MC_REF_GREG_U8(pu8Dst, IEM_GET_MODRM_RM(pVCpu, bRm));
11582 IEM_MC_REF_GREG_U8(pu8Reg, IEM_GET_MODRM_REG(pVCpu, bRm));
11583 IEM_MC_REF_EFLAGS(pEFlags);
11584 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_xadd_u8, pu8Dst, pu8Reg, pEFlags);
11585
11586 IEM_MC_ADVANCE_RIP_AND_FINISH();
11587 IEM_MC_END();
11588 }
11589 else
11590 {
11591 /*
11592 * We're accessing memory.
11593 */
11594#define IEMOP_BODY_XADD_BYTE(a_fnWorker) \
11595 IEM_MC_BEGIN(3, 4, IEM_MC_F_MIN_486, 0); \
11596 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst); \
11597 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0); \
11598 IEMOP_HLP_DONE_DECODING(); \
11599 \
11600 IEM_MC_LOCAL(uint8_t, bUnmapInfo); \
11601 IEM_MC_ARG(uint8_t *, pu8Dst, 0); \
11602 IEM_MC_MEM_MAP_U8_RW(pu8Dst, bUnmapInfo, pVCpu->iem.s.iEffSeg, GCPtrEffDst); \
11603 \
11604 IEM_MC_LOCAL(uint8_t, u8RegCopy); \
11605 IEM_MC_FETCH_GREG_U8(u8RegCopy, IEM_GET_MODRM_REG(pVCpu, bRm)); \
11606 IEM_MC_ARG_LOCAL_REF(uint8_t *, pu8Reg, u8RegCopy, 1); \
11607 \
11608 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 2); \
11609 IEM_MC_FETCH_EFLAGS(EFlags); \
11610 IEM_MC_CALL_VOID_AIMPL_3(a_fnWorker, pu8Dst, pu8Reg, pEFlags); \
11611 \
11612 IEM_MC_MEM_COMMIT_AND_UNMAP_RW(bUnmapInfo); \
11613 IEM_MC_COMMIT_EFLAGS(EFlags); \
11614 IEM_MC_STORE_GREG_U8(IEM_GET_MODRM_REG(pVCpu, bRm), u8RegCopy); \
11615 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
11616 IEM_MC_END()
11617 if (!(pVCpu->iem.s.fPrefixes & IEM_OP_PRF_LOCK) || (pVCpu->iem.s.fExec & IEM_F_X86_DISREGARD_LOCK))
11618 {
11619 IEMOP_BODY_XADD_BYTE(iemAImpl_xadd_u8);
11620 }
11621 else
11622 {
11623 IEMOP_BODY_XADD_BYTE(iemAImpl_xadd_u8_locked);
11624 }
11625 }
11626}
11627
11628
11629/** Opcode 0x0f 0xc1. */
11630FNIEMOP_DEF(iemOp_xadd_Ev_Gv)
11631{
11632 IEMOP_MNEMONIC(xadd_Ev_Gv, "xadd Ev,Gv");
11633 IEMOP_HLP_MIN_486();
11634 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
11635
11636 /*
11637 * If rm is denoting a register, no more instruction bytes.
11638 */
11639 if (IEM_IS_MODRM_REG_MODE(bRm))
11640 {
11641 switch (pVCpu->iem.s.enmEffOpSize)
11642 {
11643 case IEMMODE_16BIT:
11644 IEM_MC_BEGIN(3, 0, IEM_MC_F_MIN_486, 0);
11645 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
11646 IEM_MC_ARG(uint16_t *, pu16Dst, 0);
11647 IEM_MC_ARG(uint16_t *, pu16Reg, 1);
11648 IEM_MC_ARG(uint32_t *, pEFlags, 2);
11649
11650 IEM_MC_REF_GREG_U16(pu16Dst, IEM_GET_MODRM_RM(pVCpu, bRm));
11651 IEM_MC_REF_GREG_U16(pu16Reg, IEM_GET_MODRM_REG(pVCpu, bRm));
11652 IEM_MC_REF_EFLAGS(pEFlags);
11653 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_xadd_u16, pu16Dst, pu16Reg, pEFlags);
11654
11655 IEM_MC_ADVANCE_RIP_AND_FINISH();
11656 IEM_MC_END();
11657 break;
11658
11659 case IEMMODE_32BIT:
11660 IEM_MC_BEGIN(3, 0, IEM_MC_F_MIN_486, 0);
11661 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
11662 IEM_MC_ARG(uint32_t *, pu32Dst, 0);
11663 IEM_MC_ARG(uint32_t *, pu32Reg, 1);
11664 IEM_MC_ARG(uint32_t *, pEFlags, 2);
11665
11666 IEM_MC_REF_GREG_U32(pu32Dst, IEM_GET_MODRM_RM(pVCpu, bRm));
11667 IEM_MC_REF_GREG_U32(pu32Reg, IEM_GET_MODRM_REG(pVCpu, bRm));
11668 IEM_MC_REF_EFLAGS(pEFlags);
11669 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_xadd_u32, pu32Dst, pu32Reg, pEFlags);
11670
11671 IEM_MC_CLEAR_HIGH_GREG_U64(IEM_GET_MODRM_RM(pVCpu, bRm));
11672 IEM_MC_CLEAR_HIGH_GREG_U64(IEM_GET_MODRM_REG(pVCpu, bRm));
11673 IEM_MC_ADVANCE_RIP_AND_FINISH();
11674 IEM_MC_END();
11675 break;
11676
11677 case IEMMODE_64BIT:
11678 IEM_MC_BEGIN(3, 0, IEM_MC_F_64BIT, 0);
11679 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
11680 IEM_MC_ARG(uint64_t *, pu64Dst, 0);
11681 IEM_MC_ARG(uint64_t *, pu64Reg, 1);
11682 IEM_MC_ARG(uint32_t *, pEFlags, 2);
11683
11684 IEM_MC_REF_GREG_U64(pu64Dst, IEM_GET_MODRM_RM(pVCpu, bRm));
11685 IEM_MC_REF_GREG_U64(pu64Reg, IEM_GET_MODRM_REG(pVCpu, bRm));
11686 IEM_MC_REF_EFLAGS(pEFlags);
11687 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_xadd_u64, pu64Dst, pu64Reg, pEFlags);
11688
11689 IEM_MC_ADVANCE_RIP_AND_FINISH();
11690 IEM_MC_END();
11691 break;
11692
11693 IEM_NOT_REACHED_DEFAULT_CASE_RET();
11694 }
11695 }
11696 else
11697 {
11698 /*
11699 * We're accessing memory.
11700 */
11701#define IEMOP_BODY_XADD_EV_GV(a_fnWorker16, a_fnWorker32, a_fnWorker64) \
11702 do { \
11703 switch (pVCpu->iem.s.enmEffOpSize) \
11704 { \
11705 case IEMMODE_16BIT: \
11706 IEM_MC_BEGIN(3, 4, IEM_MC_F_MIN_486, 0); \
11707 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst); \
11708 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0); \
11709 IEMOP_HLP_DONE_DECODING(); \
11710 \
11711 IEM_MC_LOCAL(uint8_t, bUnmapInfo); \
11712 IEM_MC_ARG(uint16_t *, pu16Dst, 0); \
11713 IEM_MC_MEM_MAP_U16_RW(pu16Dst, bUnmapInfo, pVCpu->iem.s.iEffSeg, GCPtrEffDst); \
11714 \
11715 IEM_MC_LOCAL(uint16_t, u16RegCopy); \
11716 IEM_MC_FETCH_GREG_U16(u16RegCopy, IEM_GET_MODRM_REG(pVCpu, bRm)); \
11717 IEM_MC_ARG_LOCAL_REF(uint16_t *, pu16Reg, u16RegCopy, 1); \
11718 \
11719 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 2); \
11720 IEM_MC_FETCH_EFLAGS(EFlags); \
11721 IEM_MC_CALL_VOID_AIMPL_3(a_fnWorker16, pu16Dst, pu16Reg, pEFlags); \
11722 \
11723 IEM_MC_MEM_COMMIT_AND_UNMAP_RW(bUnmapInfo); \
11724 IEM_MC_COMMIT_EFLAGS(EFlags); \
11725 IEM_MC_STORE_GREG_U16(IEM_GET_MODRM_REG(pVCpu, bRm), u16RegCopy); \
11726 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
11727 IEM_MC_END(); \
11728 break; \
11729 \
11730 case IEMMODE_32BIT: \
11731 IEM_MC_BEGIN(3, 4, IEM_MC_F_MIN_486, 0); \
11732 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst); \
11733 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0); \
11734 IEMOP_HLP_DONE_DECODING(); \
11735 \
11736 IEM_MC_LOCAL(uint8_t, bUnmapInfo); \
11737 IEM_MC_ARG(uint32_t *, pu32Dst, 0); \
11738 IEM_MC_MEM_MAP_U32_RW(pu32Dst, bUnmapInfo, pVCpu->iem.s.iEffSeg, GCPtrEffDst); \
11739 \
11740 IEM_MC_LOCAL(uint32_t, u32RegCopy); \
11741 IEM_MC_FETCH_GREG_U32(u32RegCopy, IEM_GET_MODRM_REG(pVCpu, bRm)); \
11742 IEM_MC_ARG_LOCAL_REF(uint32_t *, pu32Reg, u32RegCopy, 1); \
11743 \
11744 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 2); \
11745 IEM_MC_FETCH_EFLAGS(EFlags); \
11746 IEM_MC_CALL_VOID_AIMPL_3(a_fnWorker32, pu32Dst, pu32Reg, pEFlags); \
11747 \
11748 IEM_MC_MEM_COMMIT_AND_UNMAP_RW(bUnmapInfo); \
11749 IEM_MC_COMMIT_EFLAGS(EFlags); \
11750 IEM_MC_STORE_GREG_U32(IEM_GET_MODRM_REG(pVCpu, bRm), u32RegCopy); \
11751 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
11752 IEM_MC_END(); \
11753 break; \
11754 \
11755 case IEMMODE_64BIT: \
11756 IEM_MC_BEGIN(3, 4, IEM_MC_F_64BIT, 0); \
11757 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst); \
11758 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0); \
11759 IEMOP_HLP_DONE_DECODING(); \
11760 \
11761 IEM_MC_LOCAL(uint8_t, bUnmapInfo); \
11762 IEM_MC_ARG(uint64_t *, pu64Dst, 0); \
11763 IEM_MC_MEM_MAP_U64_RW(pu64Dst, bUnmapInfo, pVCpu->iem.s.iEffSeg, GCPtrEffDst); \
11764 \
11765 IEM_MC_LOCAL(uint64_t, u64RegCopy); \
11766 IEM_MC_FETCH_GREG_U64(u64RegCopy, IEM_GET_MODRM_REG(pVCpu, bRm)); \
11767 IEM_MC_ARG_LOCAL_REF(uint64_t *, pu64Reg, u64RegCopy, 1); \
11768 \
11769 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 2); \
11770 IEM_MC_FETCH_EFLAGS(EFlags); \
11771 IEM_MC_CALL_VOID_AIMPL_3(a_fnWorker64, pu64Dst, pu64Reg, pEFlags); \
11772 \
11773 IEM_MC_MEM_COMMIT_AND_UNMAP_RW(bUnmapInfo); \
11774 IEM_MC_COMMIT_EFLAGS(EFlags); \
11775 IEM_MC_STORE_GREG_U64(IEM_GET_MODRM_REG(pVCpu, bRm), u64RegCopy); \
11776 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
11777 IEM_MC_END(); \
11778 break; \
11779 \
11780 IEM_NOT_REACHED_DEFAULT_CASE_RET(); \
11781 } \
11782 } while (0)
11783
11784 if (!(pVCpu->iem.s.fPrefixes & IEM_OP_PRF_LOCK) || (pVCpu->iem.s.fExec & IEM_F_X86_DISREGARD_LOCK))
11785 {
11786 IEMOP_BODY_XADD_EV_GV(iemAImpl_xadd_u16, iemAImpl_xadd_u32, iemAImpl_xadd_u64);
11787 }
11788 else
11789 {
11790 IEMOP_BODY_XADD_EV_GV(iemAImpl_xadd_u16_locked, iemAImpl_xadd_u32_locked, iemAImpl_xadd_u64_locked);
11791 }
11792 }
11793}
11794
11795
11796/** Opcode 0x0f 0xc2 - cmpps Vps,Wps,Ib */
11797FNIEMOP_DEF(iemOp_cmpps_Vps_Wps_Ib)
11798{
11799 IEMOP_MNEMONIC3(RMI, CMPPS, cmpps, Vps, Wps, Ib, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
11800
11801 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
11802 if (IEM_IS_MODRM_REG_MODE(bRm))
11803 {
11804 /*
11805 * XMM, XMM.
11806 */
11807 IEM_MC_BEGIN(4, 2, IEM_MC_F_NOT_286_OR_OLDER, 0);
11808 uint8_t bImm; IEM_OPCODE_GET_NEXT_U8(&bImm);
11809 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
11810 IEM_MC_LOCAL(IEMMEDIAF2XMMSRC, Src);
11811 IEM_MC_LOCAL(X86XMMREG, Dst);
11812 IEM_MC_ARG(uint32_t *, pfMxcsr, 0);
11813 IEM_MC_ARG_LOCAL_REF(PX86XMMREG, pDst, Dst, 1);
11814 IEM_MC_ARG_LOCAL_REF(PCIEMMEDIAF2XMMSRC, pSrc, Src, 2);
11815 IEM_MC_ARG_CONST(uint8_t, bImmArg, /*=*/ bImm, 3);
11816 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
11817 IEM_MC_PREPARE_SSE_USAGE();
11818 IEM_MC_REF_MXCSR(pfMxcsr);
11819 IEM_MC_FETCH_XREG_PAIR_XMM(Src, IEM_GET_MODRM_REG(pVCpu, bRm), IEM_GET_MODRM_RM(pVCpu, bRm));
11820 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpps_u128, pfMxcsr, pDst, pSrc, bImmArg);
11821 IEM_MC_IF_MXCSR_XCPT_PENDING() {
11822 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
11823 } IEM_MC_ELSE() {
11824 IEM_MC_STORE_XREG_XMM(IEM_GET_MODRM_REG(pVCpu, bRm), Dst);
11825 } IEM_MC_ENDIF();
11826
11827 IEM_MC_ADVANCE_RIP_AND_FINISH();
11828 IEM_MC_END();
11829 }
11830 else
11831 {
11832 /*
11833 * XMM, [mem128].
11834 */
11835 IEM_MC_BEGIN(4, 3, IEM_MC_F_NOT_286_OR_OLDER, 0);
11836 IEM_MC_LOCAL(IEMMEDIAF2XMMSRC, Src);
11837 IEM_MC_LOCAL(X86XMMREG, Dst);
11838 IEM_MC_ARG(uint32_t *, pfMxcsr, 0);
11839 IEM_MC_ARG_LOCAL_REF(PX86XMMREG, pDst, Dst, 1);
11840 IEM_MC_ARG_LOCAL_REF(PCIEMMEDIAF2XMMSRC, pSrc, Src, 2);
11841 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
11842
11843 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 1);
11844 uint8_t bImm; IEM_OPCODE_GET_NEXT_U8(&bImm);
11845 IEM_MC_ARG_CONST(uint8_t, bImmArg, /*=*/ bImm, 3);
11846 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
11847 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
11848 IEM_MC_PREPARE_SSE_USAGE();
11849
11850 IEM_MC_FETCH_MEM_XMM_ALIGN_SSE_AND_XREG_XMM(Src, IEM_GET_MODRM_REG(pVCpu, bRm), pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
11851 IEM_MC_REF_MXCSR(pfMxcsr);
11852 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpps_u128, pfMxcsr, pDst, pSrc, bImmArg);
11853 IEM_MC_IF_MXCSR_XCPT_PENDING() {
11854 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
11855 } IEM_MC_ELSE() {
11856 IEM_MC_STORE_XREG_XMM(IEM_GET_MODRM_REG(pVCpu, bRm), Dst);
11857 } IEM_MC_ENDIF();
11858
11859 IEM_MC_ADVANCE_RIP_AND_FINISH();
11860 IEM_MC_END();
11861 }
11862}
11863
11864
11865/** Opcode 0x66 0x0f 0xc2 - cmppd Vpd,Wpd,Ib */
11866FNIEMOP_DEF(iemOp_cmppd_Vpd_Wpd_Ib)
11867{
11868 IEMOP_MNEMONIC3(RMI, CMPPD, cmppd, Vpd, Wpd, Ib, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
11869
11870 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
11871 if (IEM_IS_MODRM_REG_MODE(bRm))
11872 {
11873 /*
11874 * XMM, XMM.
11875 */
11876 IEM_MC_BEGIN(4, 2, IEM_MC_F_NOT_286_OR_OLDER, 0);
11877 uint8_t bImm; IEM_OPCODE_GET_NEXT_U8(&bImm);
11878 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
11879 IEM_MC_LOCAL(IEMMEDIAF2XMMSRC, Src);
11880 IEM_MC_LOCAL(X86XMMREG, Dst);
11881 IEM_MC_ARG(uint32_t *, pfMxcsr, 0);
11882 IEM_MC_ARG_LOCAL_REF(PX86XMMREG, pDst, Dst, 1);
11883 IEM_MC_ARG_LOCAL_REF(PCIEMMEDIAF2XMMSRC, pSrc, Src, 2);
11884 IEM_MC_ARG_CONST(uint8_t, bImmArg, /*=*/ bImm, 3);
11885 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
11886 IEM_MC_PREPARE_SSE_USAGE();
11887 IEM_MC_REF_MXCSR(pfMxcsr);
11888 IEM_MC_FETCH_XREG_PAIR_XMM(Src, IEM_GET_MODRM_REG(pVCpu, bRm), IEM_GET_MODRM_RM(pVCpu, bRm));
11889 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmppd_u128, pfMxcsr, pDst, pSrc, bImmArg);
11890 IEM_MC_IF_MXCSR_XCPT_PENDING() {
11891 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
11892 } IEM_MC_ELSE() {
11893 IEM_MC_STORE_XREG_XMM(IEM_GET_MODRM_REG(pVCpu, bRm), Dst);
11894 } IEM_MC_ENDIF();
11895
11896 IEM_MC_ADVANCE_RIP_AND_FINISH();
11897 IEM_MC_END();
11898 }
11899 else
11900 {
11901 /*
11902 * XMM, [mem128].
11903 */
11904 IEM_MC_BEGIN(4, 3, IEM_MC_F_NOT_286_OR_OLDER, 0);
11905 IEM_MC_LOCAL(IEMMEDIAF2XMMSRC, Src);
11906 IEM_MC_LOCAL(X86XMMREG, Dst);
11907 IEM_MC_ARG(uint32_t *, pfMxcsr, 0);
11908 IEM_MC_ARG_LOCAL_REF(PX86XMMREG, pDst, Dst, 1);
11909 IEM_MC_ARG_LOCAL_REF(PCIEMMEDIAF2XMMSRC, pSrc, Src, 2);
11910 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
11911
11912 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 1);
11913 uint8_t bImm; IEM_OPCODE_GET_NEXT_U8(&bImm);
11914 IEM_MC_ARG_CONST(uint8_t, bImmArg, /*=*/ bImm, 3);
11915 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
11916 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
11917 IEM_MC_PREPARE_SSE_USAGE();
11918
11919 IEM_MC_REF_MXCSR(pfMxcsr);
11920 IEM_MC_FETCH_MEM_XMM_ALIGN_SSE_AND_XREG_XMM(Src, IEM_GET_MODRM_REG(pVCpu, bRm), pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
11921 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmppd_u128, pfMxcsr, pDst, pSrc, bImmArg);
11922 IEM_MC_IF_MXCSR_XCPT_PENDING() {
11923 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
11924 } IEM_MC_ELSE() {
11925 IEM_MC_STORE_XREG_XMM(IEM_GET_MODRM_REG(pVCpu, bRm), Dst);
11926 } IEM_MC_ENDIF();
11927
11928 IEM_MC_ADVANCE_RIP_AND_FINISH();
11929 IEM_MC_END();
11930 }
11931}
11932
11933
11934/** Opcode 0xf3 0x0f 0xc2 - cmpss Vss,Wss,Ib */
11935FNIEMOP_DEF(iemOp_cmpss_Vss_Wss_Ib)
11936{
11937 IEMOP_MNEMONIC3(RMI, CMPSS, cmpss, Vss, Wss, Ib, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
11938
11939 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
11940 if (IEM_IS_MODRM_REG_MODE(bRm))
11941 {
11942 /*
11943 * XMM32, XMM32.
11944 */
11945 IEM_MC_BEGIN(4, 2, IEM_MC_F_NOT_286_OR_OLDER, 0);
11946 uint8_t bImm; IEM_OPCODE_GET_NEXT_U8(&bImm);
11947 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
11948 IEM_MC_LOCAL(IEMMEDIAF2XMMSRC, Src);
11949 IEM_MC_LOCAL(X86XMMREG, Dst);
11950 IEM_MC_ARG(uint32_t *, pfMxcsr, 0);
11951 IEM_MC_ARG_LOCAL_REF(PX86XMMREG, pDst, Dst, 1);
11952 IEM_MC_ARG_LOCAL_REF(PCIEMMEDIAF2XMMSRC, pSrc, Src, 2);
11953 IEM_MC_ARG_CONST(uint8_t, bImmArg, /*=*/ bImm, 3);
11954 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
11955 IEM_MC_PREPARE_SSE_USAGE();
11956 IEM_MC_REF_MXCSR(pfMxcsr);
11957 IEM_MC_FETCH_XREG_PAIR_XMM(Src, IEM_GET_MODRM_REG(pVCpu, bRm), IEM_GET_MODRM_RM(pVCpu, bRm));
11958 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpss_u128, pfMxcsr, pDst, pSrc, bImmArg);
11959 IEM_MC_IF_MXCSR_XCPT_PENDING() {
11960 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
11961 } IEM_MC_ELSE() {
11962 IEM_MC_STORE_XREG_XMM_U32(IEM_GET_MODRM_REG(pVCpu, bRm), 0 /*a_iDword*/, Dst);
11963 } IEM_MC_ENDIF();
11964
11965 IEM_MC_ADVANCE_RIP_AND_FINISH();
11966 IEM_MC_END();
11967 }
11968 else
11969 {
11970 /*
11971 * XMM32, [mem32].
11972 */
11973 IEM_MC_BEGIN(4, 3, IEM_MC_F_NOT_286_OR_OLDER, 0);
11974 IEM_MC_LOCAL(IEMMEDIAF2XMMSRC, Src);
11975 IEM_MC_LOCAL(X86XMMREG, Dst);
11976 IEM_MC_ARG(uint32_t *, pfMxcsr, 0);
11977 IEM_MC_ARG_LOCAL_REF(PX86XMMREG, pDst, Dst, 1);
11978 IEM_MC_ARG_LOCAL_REF(PCIEMMEDIAF2XMMSRC, pSrc, Src, 2);
11979 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
11980
11981 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 1);
11982 uint8_t bImm; IEM_OPCODE_GET_NEXT_U8(&bImm);
11983 IEM_MC_ARG_CONST(uint8_t, bImmArg, /*=*/ bImm, 3);
11984 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
11985 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
11986 IEM_MC_PREPARE_SSE_USAGE();
11987
11988 IEM_MC_FETCH_MEM_XMM_U32_AND_XREG_XMM(Src, IEM_GET_MODRM_REG(pVCpu, bRm),
11989 0 /*a_iDword*/, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
11990 IEM_MC_REF_MXCSR(pfMxcsr);
11991 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpss_u128, pfMxcsr, pDst, pSrc, bImmArg);
11992 IEM_MC_IF_MXCSR_XCPT_PENDING() {
11993 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
11994 } IEM_MC_ELSE() {
11995 IEM_MC_STORE_XREG_XMM_U32(IEM_GET_MODRM_REG(pVCpu, bRm), 0 /*a_iDword*/, Dst);
11996 } IEM_MC_ENDIF();
11997
11998 IEM_MC_ADVANCE_RIP_AND_FINISH();
11999 IEM_MC_END();
12000 }
12001}
12002
12003
12004/** Opcode 0xf2 0x0f 0xc2 - cmpsd Vsd,Wsd,Ib */
12005FNIEMOP_DEF(iemOp_cmpsd_Vsd_Wsd_Ib)
12006{
12007 IEMOP_MNEMONIC3(RMI, CMPSD, cmpsd, Vsd, Wsd, Ib, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
12008
12009 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
12010 if (IEM_IS_MODRM_REG_MODE(bRm))
12011 {
12012 /*
12013 * XMM64, XMM64.
12014 */
12015 IEM_MC_BEGIN(4, 2, IEM_MC_F_NOT_286_OR_OLDER, 0);
12016 uint8_t bImm; IEM_OPCODE_GET_NEXT_U8(&bImm);
12017 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
12018 IEM_MC_LOCAL(IEMMEDIAF2XMMSRC, Src);
12019 IEM_MC_LOCAL(X86XMMREG, Dst);
12020 IEM_MC_ARG(uint32_t *, pfMxcsr, 0);
12021 IEM_MC_ARG_LOCAL_REF(PX86XMMREG, pDst, Dst, 1);
12022 IEM_MC_ARG_LOCAL_REF(PCIEMMEDIAF2XMMSRC, pSrc, Src, 2);
12023 IEM_MC_ARG_CONST(uint8_t, bImmArg, /*=*/ bImm, 3);
12024 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
12025 IEM_MC_PREPARE_SSE_USAGE();
12026 IEM_MC_REF_MXCSR(pfMxcsr);
12027 IEM_MC_FETCH_XREG_PAIR_XMM(Src, IEM_GET_MODRM_REG(pVCpu, bRm), IEM_GET_MODRM_RM(pVCpu, bRm));
12028 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpsd_u128, pfMxcsr, pDst, pSrc, bImmArg);
12029 IEM_MC_IF_MXCSR_XCPT_PENDING() {
12030 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
12031 } IEM_MC_ELSE() {
12032 IEM_MC_STORE_XREG_XMM_U64(IEM_GET_MODRM_REG(pVCpu, bRm), 0 /*a_iQword*/, Dst);
12033 } IEM_MC_ENDIF();
12034
12035 IEM_MC_ADVANCE_RIP_AND_FINISH();
12036 IEM_MC_END();
12037 }
12038 else
12039 {
12040 /*
12041 * XMM64, [mem64].
12042 */
12043 IEM_MC_BEGIN(4, 3, IEM_MC_F_NOT_286_OR_OLDER, 0);
12044 IEM_MC_LOCAL(IEMMEDIAF2XMMSRC, Src);
12045 IEM_MC_LOCAL(X86XMMREG, Dst);
12046 IEM_MC_ARG(uint32_t *, pfMxcsr, 0);
12047 IEM_MC_ARG_LOCAL_REF(PX86XMMREG, pDst, Dst, 1);
12048 IEM_MC_ARG_LOCAL_REF(PCIEMMEDIAF2XMMSRC, pSrc, Src, 2);
12049 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
12050
12051 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 1);
12052 uint8_t bImm; IEM_OPCODE_GET_NEXT_U8(&bImm);
12053 IEM_MC_ARG_CONST(uint8_t, bImmArg, /*=*/ bImm, 3);
12054 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
12055 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
12056 IEM_MC_PREPARE_SSE_USAGE();
12057
12058 IEM_MC_REF_MXCSR(pfMxcsr);
12059 IEM_MC_FETCH_MEM_XMM_U64_AND_XREG_XMM(Src, IEM_GET_MODRM_REG(pVCpu, bRm),
12060 0 /*a_iQword */, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
12061 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpsd_u128, pfMxcsr, pDst, pSrc, bImmArg);
12062 IEM_MC_IF_MXCSR_XCPT_PENDING() {
12063 IEM_MC_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
12064 } IEM_MC_ELSE() {
12065 IEM_MC_STORE_XREG_XMM_U64(IEM_GET_MODRM_REG(pVCpu, bRm), 0 /*a_iQword*/, Dst);
12066 } IEM_MC_ENDIF();
12067
12068 IEM_MC_ADVANCE_RIP_AND_FINISH();
12069 IEM_MC_END();
12070 }
12071}
12072
12073
12074/** Opcode 0x0f 0xc3. */
12075FNIEMOP_DEF(iemOp_movnti_My_Gy)
12076{
12077 IEMOP_MNEMONIC(movnti_My_Gy, "movnti My,Gy");
12078
12079 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
12080
12081 /* Only the register -> memory form makes sense, assuming #UD for the other form. */
12082 if (IEM_IS_MODRM_MEM_MODE(bRm))
12083 {
12084 switch (pVCpu->iem.s.enmEffOpSize)
12085 {
12086 case IEMMODE_32BIT:
12087 IEM_MC_BEGIN(0, 2, IEM_MC_F_MIN_386, 0);
12088 IEM_MC_LOCAL(uint32_t, u32Value);
12089 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
12090
12091 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
12092 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
12093
12094 IEM_MC_FETCH_GREG_U32(u32Value, IEM_GET_MODRM_REG(pVCpu, bRm));
12095 IEM_MC_STORE_MEM_U32(pVCpu->iem.s.iEffSeg, GCPtrEffDst, u32Value);
12096 IEM_MC_ADVANCE_RIP_AND_FINISH();
12097 IEM_MC_END();
12098 break;
12099
12100 case IEMMODE_64BIT:
12101 IEM_MC_BEGIN(0, 2, IEM_MC_F_64BIT, 0);
12102 IEM_MC_LOCAL(uint64_t, u64Value);
12103 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
12104
12105 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
12106 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
12107
12108 IEM_MC_FETCH_GREG_U64(u64Value, IEM_GET_MODRM_REG(pVCpu, bRm));
12109 IEM_MC_STORE_MEM_U64(pVCpu->iem.s.iEffSeg, GCPtrEffDst, u64Value);
12110 IEM_MC_ADVANCE_RIP_AND_FINISH();
12111 IEM_MC_END();
12112 break;
12113
12114 case IEMMODE_16BIT:
12115 /** @todo check this form. */
12116 IEMOP_RAISE_INVALID_OPCODE_RET();
12117
12118 IEM_NOT_REACHED_DEFAULT_CASE_RET();
12119 }
12120 }
12121 else
12122 IEMOP_RAISE_INVALID_OPCODE_RET();
12123}
12124
12125
12126/* Opcode 0x66 0x0f 0xc3 - invalid */
12127/* Opcode 0xf3 0x0f 0xc3 - invalid */
12128/* Opcode 0xf2 0x0f 0xc3 - invalid */
12129
12130
12131/** Opcode 0x0f 0xc4 - pinsrw Pq, Ry/Mw,Ib */
12132FNIEMOP_DEF(iemOp_pinsrw_Pq_RyMw_Ib)
12133{
12134 IEMOP_MNEMONIC3(RMI, PINSRW, pinsrw, Pq, Ey, Ib, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, 0);
12135 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
12136 if (IEM_IS_MODRM_REG_MODE(bRm))
12137 {
12138 /*
12139 * Register, register.
12140 */
12141 IEM_MC_BEGIN(3, 0, IEM_MC_F_NOT_286_OR_OLDER, 0);
12142 uint8_t bImm; IEM_OPCODE_GET_NEXT_U8(&bImm);
12143 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX_2_OR(fSse, fAmdMmxExts);
12144 IEM_MC_ARG(uint64_t *, pu64Dst, 0);
12145 IEM_MC_ARG(uint16_t, u16Src, 1);
12146 IEM_MC_ARG_CONST(uint8_t, bImmArg, /*=*/ bImm, 2);
12147 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
12148 IEM_MC_PREPARE_FPU_USAGE();
12149 IEM_MC_FPU_TO_MMX_MODE();
12150 IEM_MC_REF_MREG_U64(pu64Dst, IEM_GET_MODRM_REG_8(bRm));
12151 IEM_MC_FETCH_GREG_U16(u16Src, IEM_GET_MODRM_RM(pVCpu, bRm));
12152 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_pinsrw_u64, pu64Dst, u16Src, bImmArg);
12153 IEM_MC_MODIFIED_MREG_BY_REF(pu64Dst);
12154 IEM_MC_ADVANCE_RIP_AND_FINISH();
12155 IEM_MC_END();
12156 }
12157 else
12158 {
12159 /*
12160 * Register, memory.
12161 */
12162 IEM_MC_BEGIN(3, 1, IEM_MC_F_NOT_286_OR_OLDER, 0);
12163 IEM_MC_ARG(uint64_t *, pu64Dst, 0);
12164 IEM_MC_ARG(uint16_t, u16Src, 1);
12165 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
12166
12167 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 1);
12168 uint8_t bImm; IEM_OPCODE_GET_NEXT_U8(&bImm);
12169 IEM_MC_ARG_CONST(uint8_t, bImmArg, /*=*/ bImm, 2);
12170 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX_2_OR(fSse, fAmdMmxExts);
12171 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
12172 IEM_MC_PREPARE_FPU_USAGE();
12173 IEM_MC_FPU_TO_MMX_MODE();
12174
12175 IEM_MC_FETCH_MEM_U16(u16Src, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
12176 IEM_MC_REF_MREG_U64(pu64Dst, IEM_GET_MODRM_REG_8(bRm));
12177 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_pinsrw_u64, pu64Dst, u16Src, bImmArg);
12178 IEM_MC_MODIFIED_MREG_BY_REF(pu64Dst);
12179 IEM_MC_ADVANCE_RIP_AND_FINISH();
12180 IEM_MC_END();
12181 }
12182}
12183
12184
12185/** Opcode 0x66 0x0f 0xc4 - pinsrw Vdq, Ry/Mw,Ib */
12186FNIEMOP_DEF(iemOp_pinsrw_Vdq_RyMw_Ib)
12187{
12188 IEMOP_MNEMONIC3(RMI, PINSRW, pinsrw, Vq, Ey, Ib, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
12189 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
12190 if (IEM_IS_MODRM_REG_MODE(bRm))
12191 {
12192 /*
12193 * Register, register.
12194 */
12195 IEM_MC_BEGIN(3, 0, IEM_MC_F_NOT_286_OR_OLDER, 0);
12196 uint8_t bImm; IEM_OPCODE_GET_NEXT_U8(&bImm);
12197 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
12198 IEM_MC_ARG(PRTUINT128U, puDst, 0);
12199 IEM_MC_ARG(uint16_t, u16Src, 1);
12200 IEM_MC_ARG_CONST(uint8_t, bImmArg, /*=*/ bImm, 2);
12201 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
12202 IEM_MC_PREPARE_SSE_USAGE();
12203 IEM_MC_FETCH_GREG_U16(u16Src, IEM_GET_MODRM_RM(pVCpu, bRm));
12204 IEM_MC_REF_XREG_U128(puDst, IEM_GET_MODRM_REG(pVCpu, bRm));
12205 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_pinsrw_u128, puDst, u16Src, bImmArg);
12206 IEM_MC_ADVANCE_RIP_AND_FINISH();
12207 IEM_MC_END();
12208 }
12209 else
12210 {
12211 /*
12212 * Register, memory.
12213 */
12214 IEM_MC_BEGIN(3, 2, IEM_MC_F_NOT_286_OR_OLDER, 0);
12215 IEM_MC_ARG(PRTUINT128U, puDst, 0);
12216 IEM_MC_ARG(uint16_t, u16Src, 1);
12217 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
12218
12219 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 1);
12220 uint8_t bImm; IEM_OPCODE_GET_NEXT_U8(&bImm);
12221 IEM_MC_ARG_CONST(uint8_t, bImmArg, /*=*/ bImm, 2);
12222 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
12223 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
12224 IEM_MC_PREPARE_SSE_USAGE();
12225
12226 IEM_MC_FETCH_MEM_U16(u16Src, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
12227 IEM_MC_REF_XREG_U128(puDst, IEM_GET_MODRM_REG(pVCpu, bRm));
12228 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_pinsrw_u128, puDst, u16Src, bImmArg);
12229 IEM_MC_ADVANCE_RIP_AND_FINISH();
12230 IEM_MC_END();
12231 }
12232}
12233
12234
12235/* Opcode 0xf3 0x0f 0xc4 - invalid */
12236/* Opcode 0xf2 0x0f 0xc4 - invalid */
12237
12238
12239/** Opcode 0x0f 0xc5 - pextrw Gd, Nq, Ib */
12240FNIEMOP_DEF(iemOp_pextrw_Gd_Nq_Ib)
12241{
12242 /*IEMOP_MNEMONIC3(RMI_REG, PEXTRW, pextrw, Gd, Nq, Ib, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, 0);*/ /** @todo */
12243 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
12244 if (IEM_IS_MODRM_REG_MODE(bRm))
12245 {
12246 /*
12247 * Greg32, MMX, imm8.
12248 */
12249 IEM_MC_BEGIN(3, 1, IEM_MC_F_NOT_286_OR_OLDER, 0);
12250 uint8_t bImm; IEM_OPCODE_GET_NEXT_U8(&bImm);
12251 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX_2_OR(fSse, fAmdMmxExts);
12252 IEM_MC_LOCAL(uint16_t, u16Dst);
12253 IEM_MC_ARG_LOCAL_REF(uint16_t *, pu16Dst, u16Dst, 0);
12254 IEM_MC_ARG(uint64_t, u64Src, 1);
12255 IEM_MC_ARG_CONST(uint8_t, bImmArg, /*=*/ bImm, 2);
12256 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
12257 IEM_MC_PREPARE_FPU_USAGE();
12258 IEM_MC_FPU_TO_MMX_MODE();
12259 IEM_MC_FETCH_MREG_U64(u64Src, IEM_GET_MODRM_RM_8(bRm));
12260 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_pextrw_u64, pu16Dst, u64Src, bImmArg);
12261 IEM_MC_STORE_GREG_U32(IEM_GET_MODRM_REG(pVCpu, bRm), u16Dst);
12262 IEM_MC_ADVANCE_RIP_AND_FINISH();
12263 IEM_MC_END();
12264 }
12265 /* No memory operand. */
12266 else
12267 IEMOP_RAISE_INVALID_OPCODE_RET();
12268}
12269
12270
12271/** Opcode 0x66 0x0f 0xc5 - pextrw Gd, Udq, Ib */
12272FNIEMOP_DEF(iemOp_pextrw_Gd_Udq_Ib)
12273{
12274 IEMOP_MNEMONIC3(RMI_REG, PEXTRW, pextrw, Gd, Ux, Ib, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
12275 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
12276 if (IEM_IS_MODRM_REG_MODE(bRm))
12277 {
12278 /*
12279 * Greg32, XMM, imm8.
12280 */
12281 IEM_MC_BEGIN(3, 1, IEM_MC_F_NOT_286_OR_OLDER, 0);
12282 uint8_t bImm; IEM_OPCODE_GET_NEXT_U8(&bImm);
12283 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
12284 IEM_MC_LOCAL(uint16_t, u16Dst);
12285 IEM_MC_ARG_LOCAL_REF(uint16_t *, pu16Dst, u16Dst, 0);
12286 IEM_MC_ARG(PCRTUINT128U, puSrc, 1);
12287 IEM_MC_ARG_CONST(uint8_t, bImmArg, /*=*/ bImm, 2);
12288 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
12289 IEM_MC_PREPARE_SSE_USAGE();
12290 IEM_MC_REF_XREG_U128_CONST(puSrc, IEM_GET_MODRM_RM(pVCpu, bRm));
12291 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_pextrw_u128, pu16Dst, puSrc, bImmArg);
12292 IEM_MC_STORE_GREG_U32(IEM_GET_MODRM_REG(pVCpu, bRm), u16Dst);
12293 IEM_MC_ADVANCE_RIP_AND_FINISH();
12294 IEM_MC_END();
12295 }
12296 /* No memory operand. */
12297 else
12298 IEMOP_RAISE_INVALID_OPCODE_RET();
12299}
12300
12301
12302/* Opcode 0xf3 0x0f 0xc5 - invalid */
12303/* Opcode 0xf2 0x0f 0xc5 - invalid */
12304
12305
12306/** Opcode 0x0f 0xc6 - shufps Vps, Wps, Ib */
12307FNIEMOP_DEF(iemOp_shufps_Vps_Wps_Ib)
12308{
12309 IEMOP_MNEMONIC3(RMI, SHUFPS, shufps, Vps, Wps, Ib, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
12310 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
12311 if (IEM_IS_MODRM_REG_MODE(bRm))
12312 {
12313 /*
12314 * XMM, XMM, imm8.
12315 */
12316 IEM_MC_BEGIN(3, 0, IEM_MC_F_NOT_286_OR_OLDER, 0);
12317 uint8_t bImm; IEM_OPCODE_GET_NEXT_U8(&bImm);
12318 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
12319 IEM_MC_ARG(PRTUINT128U, pDst, 0);
12320 IEM_MC_ARG(PCRTUINT128U, pSrc, 1);
12321 IEM_MC_ARG_CONST(uint8_t, bImmArg, /*=*/ bImm, 2);
12322 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
12323 IEM_MC_PREPARE_SSE_USAGE();
12324 IEM_MC_REF_XREG_U128(pDst, IEM_GET_MODRM_REG(pVCpu, bRm));
12325 IEM_MC_REF_XREG_U128_CONST(pSrc, IEM_GET_MODRM_RM(pVCpu, bRm));
12326 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_shufps_u128, pDst, pSrc, bImmArg);
12327 IEM_MC_ADVANCE_RIP_AND_FINISH();
12328 IEM_MC_END();
12329 }
12330 else
12331 {
12332 /*
12333 * XMM, [mem128], imm8.
12334 */
12335 IEM_MC_BEGIN(3, 2, IEM_MC_F_NOT_286_OR_OLDER, 0);
12336 IEM_MC_ARG(PRTUINT128U, pDst, 0);
12337 IEM_MC_LOCAL(RTUINT128U, uSrc);
12338 IEM_MC_ARG_LOCAL_REF(PCRTUINT128U, pSrc, uSrc, 1);
12339 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
12340
12341 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 1);
12342 uint8_t bImm; IEM_OPCODE_GET_NEXT_U8(&bImm);
12343 IEM_MC_ARG_CONST(uint8_t, bImmArg, /*=*/ bImm, 2);
12344 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse);
12345 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
12346 IEM_MC_FETCH_MEM_U128_ALIGN_SSE(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
12347
12348 IEM_MC_PREPARE_SSE_USAGE();
12349 IEM_MC_REF_XREG_U128(pDst, IEM_GET_MODRM_REG(pVCpu, bRm));
12350 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_shufps_u128, pDst, pSrc, bImmArg);
12351
12352 IEM_MC_ADVANCE_RIP_AND_FINISH();
12353 IEM_MC_END();
12354 }
12355}
12356
12357
12358/** Opcode 0x66 0x0f 0xc6 - shufpd Vpd, Wpd, Ib */
12359FNIEMOP_DEF(iemOp_shufpd_Vpd_Wpd_Ib)
12360{
12361 IEMOP_MNEMONIC3(RMI, SHUFPD, shufpd, Vpd, Wpd, Ib, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
12362 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
12363 if (IEM_IS_MODRM_REG_MODE(bRm))
12364 {
12365 /*
12366 * XMM, XMM, imm8.
12367 */
12368 IEM_MC_BEGIN(3, 0, IEM_MC_F_NOT_286_OR_OLDER, 0);
12369 uint8_t bImm; IEM_OPCODE_GET_NEXT_U8(&bImm);
12370 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
12371 IEM_MC_ARG(PRTUINT128U, pDst, 0);
12372 IEM_MC_ARG(PCRTUINT128U, pSrc, 1);
12373 IEM_MC_ARG_CONST(uint8_t, bImmArg, /*=*/ bImm, 2);
12374 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
12375 IEM_MC_PREPARE_SSE_USAGE();
12376 IEM_MC_REF_XREG_U128(pDst, IEM_GET_MODRM_REG(pVCpu, bRm));
12377 IEM_MC_REF_XREG_U128_CONST(pSrc, IEM_GET_MODRM_RM(pVCpu, bRm));
12378 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_shufpd_u128, pDst, pSrc, bImmArg);
12379 IEM_MC_ADVANCE_RIP_AND_FINISH();
12380 IEM_MC_END();
12381 }
12382 else
12383 {
12384 /*
12385 * XMM, [mem128], imm8.
12386 */
12387 IEM_MC_BEGIN(3, 2, IEM_MC_F_NOT_286_OR_OLDER, 0);
12388 IEM_MC_ARG(PRTUINT128U, pDst, 0);
12389 IEM_MC_LOCAL(RTUINT128U, uSrc);
12390 IEM_MC_ARG_LOCAL_REF(PCRTUINT128U, pSrc, uSrc, 1);
12391 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
12392
12393 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 1);
12394 uint8_t bImm; IEM_OPCODE_GET_NEXT_U8(&bImm);
12395 IEM_MC_ARG_CONST(uint8_t, bImmArg, /*=*/ bImm, 2);
12396 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
12397 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
12398 IEM_MC_FETCH_MEM_U128_ALIGN_SSE(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
12399
12400 IEM_MC_PREPARE_SSE_USAGE();
12401 IEM_MC_REF_XREG_U128(pDst, IEM_GET_MODRM_REG(pVCpu, bRm));
12402 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_shufpd_u128, pDst, pSrc, bImmArg);
12403
12404 IEM_MC_ADVANCE_RIP_AND_FINISH();
12405 IEM_MC_END();
12406 }
12407}
12408
12409
12410/* Opcode 0xf3 0x0f 0xc6 - invalid */
12411/* Opcode 0xf2 0x0f 0xc6 - invalid */
12412
12413
12414/** Opcode 0x0f 0xc7 !11/1. */
12415FNIEMOP_DEF_1(iemOp_Grp9_cmpxchg8b_Mq, uint8_t, bRm)
12416{
12417 IEMOP_MNEMONIC(cmpxchg8b, "cmpxchg8b Mq");
12418#define IEMOP_BODY_CMPXCHG8B(a_fnWorker) \
12419 IEM_MC_BEGIN(4, 5, IEM_MC_F_NOT_286_OR_OLDER, 0); \
12420 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst); \
12421 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0); \
12422 IEMOP_HLP_DONE_DECODING_EX(fCmpXchg8b); \
12423 \
12424 IEM_MC_LOCAL(uint8_t, bUnmapInfo); \
12425 IEM_MC_ARG(uint64_t *, pu64MemDst, 0); \
12426 IEM_MC_MEM_MAP_U64_RW(pu64MemDst, bUnmapInfo, pVCpu->iem.s.iEffSeg, GCPtrEffDst); \
12427 \
12428 IEM_MC_LOCAL(RTUINT64U, u64EaxEdx); \
12429 IEM_MC_FETCH_GREG_PAIR_U32(u64EaxEdx, X86_GREG_xAX, X86_GREG_xDX); \
12430 IEM_MC_ARG_LOCAL_REF(PRTUINT64U, pu64EaxEdx, u64EaxEdx, 1); \
12431 \
12432 IEM_MC_LOCAL(RTUINT64U, u64EbxEcx); \
12433 IEM_MC_FETCH_GREG_PAIR_U32(u64EbxEcx, X86_GREG_xBX, X86_GREG_xCX); \
12434 IEM_MC_ARG_LOCAL_REF(PRTUINT64U, pu64EbxEcx, u64EbxEcx, 2); \
12435 \
12436 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 3); \
12437 IEM_MC_FETCH_EFLAGS(EFlags); \
12438 IEM_MC_CALL_VOID_AIMPL_4(a_fnWorker, pu64MemDst, pu64EaxEdx, pu64EbxEcx, pEFlags); \
12439 \
12440 IEM_MC_MEM_COMMIT_AND_UNMAP_RW(bUnmapInfo); \
12441 IEM_MC_COMMIT_EFLAGS(EFlags); \
12442 IEM_MC_IF_EFL_BIT_NOT_SET(X86_EFL_ZF) { \
12443 IEM_MC_STORE_GREG_PAIR_U32(X86_GREG_xAX, X86_GREG_xDX, u64EaxEdx); \
12444 } IEM_MC_ENDIF(); \
12445 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
12446 \
12447 IEM_MC_END()
12448 if (!(pVCpu->iem.s.fPrefixes & IEM_OP_PRF_LOCK) || (pVCpu->iem.s.fExec & IEM_F_X86_DISREGARD_LOCK))
12449 {
12450 IEMOP_BODY_CMPXCHG8B(iemAImpl_cmpxchg8b);
12451 }
12452 else
12453 {
12454 IEMOP_BODY_CMPXCHG8B(iemAImpl_cmpxchg8b_locked);
12455 }
12456}
12457
12458
12459/** Opcode REX.W 0x0f 0xc7 !11/1. */
12460FNIEMOP_DEF_1(iemOp_Grp9_cmpxchg16b_Mdq, uint8_t, bRm)
12461{
12462 IEMOP_MNEMONIC(cmpxchg16b, "cmpxchg16b Mdq");
12463 if (IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fCmpXchg16b)
12464 {
12465 /*
12466 * This is hairy, very hairy macro fun. We're walking a fine line
12467 * here to make the code parsable by IEMAllInstPython.py and fit into
12468 * the patterns IEMAllThrdPython.py requires for the code morphing.
12469 */
12470#define BODY_CMPXCHG16B_HEAD(bUnmapInfoStmt) \
12471 IEM_MC_BEGIN(5, 4, IEM_MC_F_64BIT, 0); \
12472 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst); \
12473 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0); \
12474 IEMOP_HLP_DONE_DECODING(); \
12475 \
12476 IEM_MC_RAISE_GP0_IF_EFF_ADDR_UNALIGNED(GCPtrEffDst, 16); \
12477 bUnmapInfoStmt; \
12478 IEM_MC_ARG(PRTUINT128U, pu128MemDst, 0); \
12479 IEM_MC_MEM_MAP_U128_RW(pu128MemDst, bUnmapInfo, pVCpu->iem.s.iEffSeg, GCPtrEffDst); \
12480 \
12481 IEM_MC_LOCAL(RTUINT128U, u128RaxRdx); \
12482 IEM_MC_FETCH_GREG_PAIR_U64(u128RaxRdx, X86_GREG_xAX, X86_GREG_xDX); \
12483 IEM_MC_ARG_LOCAL_REF(PRTUINT128U, pu128RaxRdx, u128RaxRdx, 1); \
12484 \
12485 IEM_MC_LOCAL(RTUINT128U, u128RbxRcx); \
12486 IEM_MC_FETCH_GREG_PAIR_U64(u128RbxRcx, X86_GREG_xBX, X86_GREG_xCX); \
12487 IEM_MC_ARG_LOCAL_REF(PRTUINT128U, pu128RbxRcx, u128RbxRcx, 2); \
12488 \
12489 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 3); \
12490 IEM_MC_FETCH_EFLAGS(EFlags)
12491
12492#define BODY_CMPXCHG16B_TAIL \
12493 IEM_MC_MEM_COMMIT_AND_UNMAP_RW(bUnmapInfo); \
12494 IEM_MC_COMMIT_EFLAGS(EFlags); \
12495 IEM_MC_IF_EFL_BIT_NOT_SET(X86_EFL_ZF) { \
12496 IEM_MC_STORE_GREG_PAIR_U64(X86_GREG_xAX, X86_GREG_xDX, u128RaxRdx); \
12497 } IEM_MC_ENDIF(); \
12498 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
12499 IEM_MC_END()
12500
12501#ifdef RT_ARCH_AMD64
12502 if (IEM_GET_HOST_CPU_FEATURES(pVCpu)->fCmpXchg16b)
12503 {
12504 if (!(pVCpu->iem.s.fPrefixes & IEM_OP_PRF_LOCK) || (pVCpu->iem.s.fExec & IEM_F_X86_DISREGARD_LOCK))
12505 {
12506 BODY_CMPXCHG16B_HEAD(IEM_MC_LOCAL(uint8_t, bUnmapInfo));
12507 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpxchg16b, pu128MemDst, pu128RaxRdx, pu128RbxRcx, pEFlags);
12508 BODY_CMPXCHG16B_TAIL;
12509 }
12510 else
12511 {
12512 BODY_CMPXCHG16B_HEAD(IEM_MC_LOCAL(uint8_t, bUnmapInfo));
12513 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpxchg16b_locked, pu128MemDst, pu128RaxRdx, pu128RbxRcx, pEFlags);
12514 BODY_CMPXCHG16B_TAIL;
12515 }
12516 }
12517 else
12518 { /* (see comments in #else case below) */
12519 if (pVCpu->CTX_SUFF(pVM)->cCpus == 1)
12520 {
12521 BODY_CMPXCHG16B_HEAD(IEM_MC_LOCAL(uint8_t, bUnmapInfo));
12522 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpxchg16b_fallback, pu128MemDst, pu128RaxRdx, pu128RbxRcx, pEFlags);
12523 BODY_CMPXCHG16B_TAIL;
12524 }
12525 else
12526 {
12527 BODY_CMPXCHG16B_HEAD(IEM_MC_ARG(uint8_t, bUnmapInfo, 4));
12528 IEM_MC_CALL_CIMPL_5(IEM_CIMPL_F_STATUS_FLAGS,
12529 RT_BIT_64(kIemNativeGstReg_GprFirst + X86_GREG_xAX)
12530 | RT_BIT_64(kIemNativeGstReg_GprFirst + X86_GREG_xDX),
12531 iemCImpl_cmpxchg16b_fallback_rendezvous, pu128MemDst, pu128RaxRdx, pu128RbxRcx,
12532 pEFlags, bUnmapInfo);
12533 IEM_MC_END();
12534 }
12535 }
12536
12537#elif defined(RT_ARCH_ARM64)
12538 /** @todo may require fallback for unaligned accesses... */
12539 if (!(pVCpu->iem.s.fPrefixes & IEM_OP_PRF_LOCK) || (pVCpu->iem.s.fExec & IEM_F_X86_DISREGARD_LOCK))
12540 {
12541 BODY_CMPXCHG16B_HEAD(IEM_MC_LOCAL(uint8_t, bUnmapInfo));
12542 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpxchg16b, pu128MemDst, pu128RaxRdx, pu128RbxRcx, pEFlags);
12543 BODY_CMPXCHG16B_TAIL;
12544 }
12545 else
12546 {
12547 BODY_CMPXCHG16B_HEAD(IEM_MC_LOCAL(uint8_t, bUnmapInfo));
12548 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpxchg16b_locked, pu128MemDst, pu128RaxRdx, pu128RbxRcx, pEFlags);
12549 BODY_CMPXCHG16B_TAIL;
12550 }
12551
12552#else
12553 /* Note! The fallback for 32-bit systems and systems without CX16 is multiple
12554 accesses and not all all atomic, which works fine on in UNI CPU guest
12555 configuration (ignoring DMA). If guest SMP is active we have no choice
12556 but to use a rendezvous callback here. Sigh. */
12557 if (pVCpu->CTX_SUFF(pVM)->cCpus == 1)
12558 {
12559 BODY_CMPXCHG16B_HEAD(IEM_MC_LOCAL(uint8_t, bUnmapInfo));
12560 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpxchg16b_fallback, pu128MemDst, pu128RaxRdx, pu128RbxRcx, pEFlags);
12561 BODY_CMPXCHG16B_TAIL;
12562 }
12563 else
12564 {
12565 BODY_CMPXCHG16B_HEAD(IEM_MC_ARG(uint8_t, bUnmapInfo, 4));
12566 IEM_MC_CALL_CIMPL_4(IEM_CIMPL_F_STATUS_FLAGS,
12567 RT_BIT_64(kIemNativeGstReg_GprFirst + X86_GREG_xAX)
12568 | RT_BIT_64(kIemNativeGstReg_GprFirst + X86_GREG_xDX),
12569 iemCImpl_cmpxchg16b_fallback_rendezvous,
12570 pu128MemDst, pu128RaxRdx, pu128RbxRcx, pEFlags);
12571 IEM_MC_END();
12572 /* Does not get here, tail code is duplicated in iemCImpl_cmpxchg16b_fallback_rendezvous. */
12573 }
12574#endif
12575
12576#undef BODY_CMPXCHG16B
12577 }
12578 Log(("cmpxchg16b -> #UD\n"));
12579 IEMOP_RAISE_INVALID_OPCODE_RET();
12580}
12581
12582FNIEMOP_DEF_1(iemOp_Grp9_cmpxchg8bOr16b, uint8_t, bRm)
12583{
12584 if (pVCpu->iem.s.fPrefixes & IEM_OP_PRF_SIZE_REX_W)
12585 return FNIEMOP_CALL_1(iemOp_Grp9_cmpxchg16b_Mdq, bRm);
12586 return FNIEMOP_CALL_1(iemOp_Grp9_cmpxchg8b_Mq, bRm);
12587}
12588
12589
12590/** Opcode 0x0f 0xc7 11/6. */
12591FNIEMOP_DEF_1(iemOp_Grp9_rdrand_Rv, uint8_t, bRm)
12592{
12593 if (!IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fRdRand)
12594 IEMOP_RAISE_INVALID_OPCODE_RET();
12595
12596 if (IEM_IS_MODRM_REG_MODE(bRm))
12597 {
12598 IEM_MC_BEGIN(2, 0, IEM_MC_F_NOT_286_OR_OLDER, 0);
12599 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
12600 IEM_MC_ARG_CONST(uint8_t, iReg, /*=*/ IEM_GET_MODRM_RM(pVCpu, bRm), 0);
12601 IEM_MC_ARG_CONST(IEMMODE, enmEffOpSize,/*=*/ pVCpu->iem.s.enmEffOpSize, 1);
12602 IEM_MC_CALL_CIMPL_2(IEM_CIMPL_F_RFLAGS | IEM_CIMPL_F_VMEXIT,
12603 RT_BIT_64(kIemNativeGstReg_GprFirst + IEM_GET_MODRM_RM(pVCpu, bRm)),
12604 iemCImpl_rdrand, iReg, enmEffOpSize);
12605 IEM_MC_END();
12606 }
12607 /* Register only. */
12608 else
12609 IEMOP_RAISE_INVALID_OPCODE_RET();
12610}
12611
12612/** Opcode 0x0f 0xc7 !11/6. */
12613#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
12614FNIEMOP_DEF_1(iemOp_Grp9_vmptrld_Mq, uint8_t, bRm)
12615{
12616 IEMOP_MNEMONIC(vmptrld, "vmptrld");
12617 IEMOP_HLP_IN_VMX_OPERATION("vmptrld", kVmxVDiag_Vmptrld);
12618 IEMOP_HLP_VMX_INSTR("vmptrld", kVmxVDiag_Vmptrld);
12619 IEM_MC_BEGIN(2, 0, IEM_MC_F_NOT_286_OR_OLDER, 0);
12620 IEM_MC_ARG(RTGCPTR, GCPtrEffSrc, 1);
12621 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
12622 IEMOP_HLP_DONE_DECODING_NO_SIZE_OP_REPZ_OR_REPNZ_PREFIXES();
12623 IEM_MC_ARG_CONST(uint8_t, iEffSeg, /*=*/ pVCpu->iem.s.iEffSeg, 0);
12624 IEM_MC_CALL_CIMPL_2(IEM_CIMPL_F_VMEXIT | IEM_CIMPL_F_STATUS_FLAGS, 0, iemCImpl_vmptrld, iEffSeg, GCPtrEffSrc);
12625 IEM_MC_END();
12626}
12627#else
12628FNIEMOP_UD_STUB_1(iemOp_Grp9_vmptrld_Mq, uint8_t, bRm);
12629#endif
12630
12631/** Opcode 0x66 0x0f 0xc7 !11/6. */
12632#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
12633FNIEMOP_DEF_1(iemOp_Grp9_vmclear_Mq, uint8_t, bRm)
12634{
12635 IEMOP_MNEMONIC(vmclear, "vmclear");
12636 IEMOP_HLP_IN_VMX_OPERATION("vmclear", kVmxVDiag_Vmclear);
12637 IEMOP_HLP_VMX_INSTR("vmclear", kVmxVDiag_Vmclear);
12638 IEM_MC_BEGIN(2, 0, IEM_MC_F_NOT_286_OR_OLDER, 0);
12639 IEM_MC_ARG(RTGCPTR, GCPtrEffDst, 1);
12640 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
12641 IEMOP_HLP_DONE_DECODING();
12642 IEM_MC_ARG_CONST(uint8_t, iEffSeg, /*=*/ pVCpu->iem.s.iEffSeg, 0);
12643 IEM_MC_CALL_CIMPL_2(IEM_CIMPL_F_VMEXIT | IEM_CIMPL_F_STATUS_FLAGS, 0, iemCImpl_vmclear, iEffSeg, GCPtrEffDst);
12644 IEM_MC_END();
12645}
12646#else
12647FNIEMOP_UD_STUB_1(iemOp_Grp9_vmclear_Mq, uint8_t, bRm);
12648#endif
12649
12650/** Opcode 0xf3 0x0f 0xc7 !11/6. */
12651#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
12652FNIEMOP_DEF_1(iemOp_Grp9_vmxon_Mq, uint8_t, bRm)
12653{
12654 IEMOP_MNEMONIC(vmxon, "vmxon");
12655 IEMOP_HLP_VMX_INSTR("vmxon", kVmxVDiag_Vmxon);
12656 IEM_MC_BEGIN(2, 0, IEM_MC_F_NOT_286_OR_OLDER, 0);
12657 IEM_MC_ARG(RTGCPTR, GCPtrEffSrc, 1);
12658 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
12659 IEMOP_HLP_DONE_DECODING();
12660 IEM_MC_ARG_CONST(uint8_t, iEffSeg, /*=*/ pVCpu->iem.s.iEffSeg, 0);
12661 IEM_MC_CALL_CIMPL_2(IEM_CIMPL_F_VMEXIT | IEM_CIMPL_F_STATUS_FLAGS, 0, iemCImpl_vmxon, iEffSeg, GCPtrEffSrc);
12662 IEM_MC_END();
12663}
12664#else
12665FNIEMOP_UD_STUB_1(iemOp_Grp9_vmxon_Mq, uint8_t, bRm);
12666#endif
12667
12668/** Opcode [0xf3] 0x0f 0xc7 !11/7. */
12669#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
12670FNIEMOP_DEF_1(iemOp_Grp9_vmptrst_Mq, uint8_t, bRm)
12671{
12672 IEMOP_MNEMONIC(vmptrst, "vmptrst");
12673 IEMOP_HLP_IN_VMX_OPERATION("vmptrst", kVmxVDiag_Vmptrst);
12674 IEMOP_HLP_VMX_INSTR("vmptrst", kVmxVDiag_Vmptrst);
12675 IEM_MC_BEGIN(2, 0, IEM_MC_F_NOT_286_OR_OLDER, 0);
12676 IEM_MC_ARG(RTGCPTR, GCPtrEffDst, 1);
12677 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
12678 IEMOP_HLP_DONE_DECODING_NO_SIZE_OP_REPZ_OR_REPNZ_PREFIXES();
12679 IEM_MC_ARG_CONST(uint8_t, iEffSeg, /*=*/ pVCpu->iem.s.iEffSeg, 0);
12680 IEM_MC_CALL_CIMPL_2(IEM_CIMPL_F_VMEXIT | IEM_CIMPL_F_STATUS_FLAGS, 0, iemCImpl_vmptrst, iEffSeg, GCPtrEffDst);
12681 IEM_MC_END();
12682}
12683#else
12684FNIEMOP_UD_STUB_1(iemOp_Grp9_vmptrst_Mq, uint8_t, bRm);
12685#endif
12686
12687/** Opcode 0x0f 0xc7 11/7. */
12688FNIEMOP_DEF_1(iemOp_Grp9_rdseed_Rv, uint8_t, bRm)
12689{
12690 if (!IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fRdSeed)
12691 IEMOP_RAISE_INVALID_OPCODE_RET();
12692
12693 if (IEM_IS_MODRM_REG_MODE(bRm))
12694 {
12695 /* register destination. */
12696 IEM_MC_BEGIN(2, 0, IEM_MC_F_NOT_286_OR_OLDER, 0);
12697 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
12698 IEM_MC_ARG_CONST(uint8_t, iReg, /*=*/ IEM_GET_MODRM_RM(pVCpu, bRm), 0);
12699 IEM_MC_ARG_CONST(IEMMODE, enmEffOpSize,/*=*/ pVCpu->iem.s.enmEffOpSize, 1);
12700 IEM_MC_CALL_CIMPL_2(IEM_CIMPL_F_RFLAGS | IEM_CIMPL_F_VMEXIT,
12701 RT_BIT_64(kIemNativeGstReg_GprFirst + IEM_GET_MODRM_RM(pVCpu, bRm)),
12702 iemCImpl_rdseed, iReg, enmEffOpSize);
12703 IEM_MC_END();
12704 }
12705 /* Register only. */
12706 else
12707 IEMOP_RAISE_INVALID_OPCODE_RET();
12708}
12709
12710/**
12711 * Group 9 jump table for register variant.
12712 */
12713IEM_STATIC const PFNIEMOPRM g_apfnGroup9RegReg[] =
12714{ /* pfx: none, 066h, 0f3h, 0f2h */
12715 /* /0 */ IEMOP_X4(iemOp_InvalidWithRM),
12716 /* /1 */ IEMOP_X4(iemOp_InvalidWithRM),
12717 /* /2 */ IEMOP_X4(iemOp_InvalidWithRM),
12718 /* /3 */ IEMOP_X4(iemOp_InvalidWithRM),
12719 /* /4 */ IEMOP_X4(iemOp_InvalidWithRM),
12720 /* /5 */ IEMOP_X4(iemOp_InvalidWithRM),
12721 /* /6 */ iemOp_Grp9_rdrand_Rv, iemOp_Grp9_rdrand_Rv, iemOp_InvalidWithRM, iemOp_InvalidWithRM,
12722 /* /7 */ iemOp_Grp9_rdseed_Rv, iemOp_Grp9_rdseed_Rv, iemOp_InvalidWithRM, iemOp_InvalidWithRM,
12723};
12724AssertCompile(RT_ELEMENTS(g_apfnGroup9RegReg) == 8*4);
12725
12726
12727/**
12728 * Group 9 jump table for memory variant.
12729 */
12730IEM_STATIC const PFNIEMOPRM g_apfnGroup9MemReg[] =
12731{ /* pfx: none, 066h, 0f3h, 0f2h */
12732 /* /0 */ IEMOP_X4(iemOp_InvalidWithRM),
12733 /* /1 */ iemOp_Grp9_cmpxchg8bOr16b, iemOp_Grp9_cmpxchg8bOr16b, iemOp_Grp9_cmpxchg8bOr16b, iemOp_Grp9_cmpxchg8bOr16b, /* see bs3-cpu-decoding-1 */
12734 /* /2 */ IEMOP_X4(iemOp_InvalidWithRM),
12735 /* /3 */ IEMOP_X4(iemOp_InvalidWithRM),
12736 /* /4 */ IEMOP_X4(iemOp_InvalidWithRM),
12737 /* /5 */ IEMOP_X4(iemOp_InvalidWithRM),
12738 /* /6 */ iemOp_Grp9_vmptrld_Mq, iemOp_Grp9_vmclear_Mq, iemOp_Grp9_vmxon_Mq, iemOp_InvalidWithRM,
12739 /* /7 */ iemOp_Grp9_vmptrst_Mq, iemOp_InvalidWithRM, iemOp_InvalidWithRM, iemOp_InvalidWithRM,
12740};
12741AssertCompile(RT_ELEMENTS(g_apfnGroup9MemReg) == 8*4);
12742
12743
12744/** Opcode 0x0f 0xc7. */
12745FNIEMOP_DEF(iemOp_Grp9)
12746{
12747 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
12748 if (IEM_IS_MODRM_REG_MODE(bRm))
12749 /* register, register */
12750 return FNIEMOP_CALL_1(g_apfnGroup9RegReg[ IEM_GET_MODRM_REG_8(bRm) * 4
12751 + pVCpu->iem.s.idxPrefix], bRm);
12752 /* memory, register */
12753 return FNIEMOP_CALL_1(g_apfnGroup9MemReg[ IEM_GET_MODRM_REG_8(bRm) * 4
12754 + pVCpu->iem.s.idxPrefix], bRm);
12755}
12756
12757
12758/**
12759 * Common 'bswap register' helper.
12760 */
12761FNIEMOP_DEF_1(iemOpCommonBswapGReg, uint8_t, iReg)
12762{
12763 switch (pVCpu->iem.s.enmEffOpSize)
12764 {
12765 case IEMMODE_16BIT:
12766 IEM_MC_BEGIN(1, 0, IEM_MC_F_MIN_486, 0);
12767 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
12768 IEM_MC_ARG(uint32_t *, pu32Dst, 0);
12769 IEM_MC_REF_GREG_U32(pu32Dst, iReg); /* Don't clear the high dword! */
12770 IEM_MC_CALL_VOID_AIMPL_1(iemAImpl_bswap_u16, pu32Dst);
12771 IEM_MC_ADVANCE_RIP_AND_FINISH();
12772 IEM_MC_END();
12773 break;
12774
12775 case IEMMODE_32BIT:
12776 IEM_MC_BEGIN(1, 0, IEM_MC_F_MIN_486, 0);
12777 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
12778 IEM_MC_ARG(uint32_t *, pu32Dst, 0);
12779 IEM_MC_REF_GREG_U32(pu32Dst, iReg);
12780 IEM_MC_CALL_VOID_AIMPL_1(iemAImpl_bswap_u32, pu32Dst);
12781 IEM_MC_CLEAR_HIGH_GREG_U64(iReg);
12782 IEM_MC_ADVANCE_RIP_AND_FINISH();
12783 IEM_MC_END();
12784 break;
12785
12786 case IEMMODE_64BIT:
12787 IEM_MC_BEGIN(1, 0, IEM_MC_F_64BIT, 0);
12788 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
12789 IEM_MC_ARG(uint64_t *, pu64Dst, 0);
12790 IEM_MC_REF_GREG_U64(pu64Dst, iReg);
12791 IEM_MC_CALL_VOID_AIMPL_1(iemAImpl_bswap_u64, pu64Dst);
12792 IEM_MC_ADVANCE_RIP_AND_FINISH();
12793 IEM_MC_END();
12794 break;
12795
12796 IEM_NOT_REACHED_DEFAULT_CASE_RET();
12797 }
12798}
12799
12800
12801/** Opcode 0x0f 0xc8. */
12802FNIEMOP_DEF(iemOp_bswap_rAX_r8)
12803{
12804 IEMOP_MNEMONIC(bswap_rAX_r8, "bswap rAX/r8");
12805 /* Note! Intel manuals states that R8-R15 can be accessed by using a REX.X
12806 prefix. REX.B is the correct prefix it appears. For a parallel
12807 case, see iemOp_mov_AL_Ib and iemOp_mov_eAX_Iv. */
12808 IEMOP_HLP_MIN_486();
12809 return FNIEMOP_CALL_1(iemOpCommonBswapGReg, X86_GREG_xAX | pVCpu->iem.s.uRexB);
12810}
12811
12812
12813/** Opcode 0x0f 0xc9. */
12814FNIEMOP_DEF(iemOp_bswap_rCX_r9)
12815{
12816 IEMOP_MNEMONIC(bswap_rCX_r9, "bswap rCX/r9");
12817 IEMOP_HLP_MIN_486();
12818 return FNIEMOP_CALL_1(iemOpCommonBswapGReg, X86_GREG_xCX | pVCpu->iem.s.uRexB);
12819}
12820
12821
12822/** Opcode 0x0f 0xca. */
12823FNIEMOP_DEF(iemOp_bswap_rDX_r10)
12824{
12825 IEMOP_MNEMONIC(bswap_rDX_r9, "bswap rDX/r10");
12826 IEMOP_HLP_MIN_486();
12827 return FNIEMOP_CALL_1(iemOpCommonBswapGReg, X86_GREG_xDX | pVCpu->iem.s.uRexB);
12828}
12829
12830
12831/** Opcode 0x0f 0xcb. */
12832FNIEMOP_DEF(iemOp_bswap_rBX_r11)
12833{
12834 IEMOP_MNEMONIC(bswap_rBX_r9, "bswap rBX/r11");
12835 IEMOP_HLP_MIN_486();
12836 return FNIEMOP_CALL_1(iemOpCommonBswapGReg, X86_GREG_xBX | pVCpu->iem.s.uRexB);
12837}
12838
12839
12840/** Opcode 0x0f 0xcc. */
12841FNIEMOP_DEF(iemOp_bswap_rSP_r12)
12842{
12843 IEMOP_MNEMONIC(bswap_rSP_r12, "bswap rSP/r12");
12844 IEMOP_HLP_MIN_486();
12845 return FNIEMOP_CALL_1(iemOpCommonBswapGReg, X86_GREG_xSP | pVCpu->iem.s.uRexB);
12846}
12847
12848
12849/** Opcode 0x0f 0xcd. */
12850FNIEMOP_DEF(iemOp_bswap_rBP_r13)
12851{
12852 IEMOP_MNEMONIC(bswap_rBP_r13, "bswap rBP/r13");
12853 IEMOP_HLP_MIN_486();
12854 return FNIEMOP_CALL_1(iemOpCommonBswapGReg, X86_GREG_xBP | pVCpu->iem.s.uRexB);
12855}
12856
12857
12858/** Opcode 0x0f 0xce. */
12859FNIEMOP_DEF(iemOp_bswap_rSI_r14)
12860{
12861 IEMOP_MNEMONIC(bswap_rSI_r14, "bswap rSI/r14");
12862 IEMOP_HLP_MIN_486();
12863 return FNIEMOP_CALL_1(iemOpCommonBswapGReg, X86_GREG_xSI | pVCpu->iem.s.uRexB);
12864}
12865
12866
12867/** Opcode 0x0f 0xcf. */
12868FNIEMOP_DEF(iemOp_bswap_rDI_r15)
12869{
12870 IEMOP_MNEMONIC(bswap_rDI_r15, "bswap rDI/r15");
12871 IEMOP_HLP_MIN_486();
12872 return FNIEMOP_CALL_1(iemOpCommonBswapGReg, X86_GREG_xDI | pVCpu->iem.s.uRexB);
12873}
12874
12875
12876/* Opcode 0x0f 0xd0 - invalid */
12877
12878
12879/** Opcode 0x66 0x0f 0xd0 - addsubpd Vpd, Wpd */
12880FNIEMOP_DEF(iemOp_addsubpd_Vpd_Wpd)
12881{
12882 IEMOP_MNEMONIC2(RM, ADDSUBPD, addsubpd, Vpd, Wpd, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
12883 return FNIEMOP_CALL_1(iemOpCommonSse3Fp_FullFull_To_Full, iemAImpl_addsubpd_u128);
12884}
12885
12886
12887/* Opcode 0xf3 0x0f 0xd0 - invalid */
12888
12889
12890/** Opcode 0xf2 0x0f 0xd0 - addsubps Vps, Wps */
12891FNIEMOP_DEF(iemOp_addsubps_Vps_Wps)
12892{
12893 IEMOP_MNEMONIC2(RM, ADDSUBPS, addsubps, Vps, Wps, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
12894 return FNIEMOP_CALL_1(iemOpCommonSse3Fp_FullFull_To_Full, iemAImpl_addsubps_u128);
12895}
12896
12897
12898
12899/** Opcode 0x0f 0xd1 - psrlw Pq, Qq */
12900FNIEMOP_DEF(iemOp_psrlw_Pq_Qq)
12901{
12902 IEMOP_MNEMONIC2(RM, PSRLW, psrlw, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, 0);
12903 return FNIEMOP_CALL_1(iemOpCommonMmxOpt_FullFull_To_Full, iemAImpl_psrlw_u64);
12904}
12905
12906/** Opcode 0x66 0x0f 0xd1 - psrlw Vx, Wx */
12907FNIEMOP_DEF(iemOp_psrlw_Vx_Wx)
12908{
12909 IEMOP_MNEMONIC2(RM, PSRLW, psrlw, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
12910 return FNIEMOP_CALL_1(iemOpCommonSse2Opt_FullFull_To_Full, iemAImpl_psrlw_u128);
12911}
12912
12913/* Opcode 0xf3 0x0f 0xd1 - invalid */
12914/* Opcode 0xf2 0x0f 0xd1 - invalid */
12915
12916/** Opcode 0x0f 0xd2 - psrld Pq, Qq */
12917FNIEMOP_DEF(iemOp_psrld_Pq_Qq)
12918{
12919 IEMOP_MNEMONIC2(RM, PSRLD, psrld, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, 0);
12920 return FNIEMOP_CALL_1(iemOpCommonMmxOpt_FullFull_To_Full, iemAImpl_psrld_u64);
12921}
12922
12923
12924/** Opcode 0x66 0x0f 0xd2 - psrld Vx, Wx */
12925FNIEMOP_DEF(iemOp_psrld_Vx_Wx)
12926{
12927 IEMOP_MNEMONIC2(RM, PSRLD, psrld, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
12928 return FNIEMOP_CALL_1(iemOpCommonSse2Opt_FullFull_To_Full, iemAImpl_psrld_u128);
12929}
12930
12931
12932/* Opcode 0xf3 0x0f 0xd2 - invalid */
12933/* Opcode 0xf2 0x0f 0xd2 - invalid */
12934
12935/** Opcode 0x0f 0xd3 - psrlq Pq, Qq */
12936FNIEMOP_DEF(iemOp_psrlq_Pq_Qq)
12937{
12938 IEMOP_MNEMONIC2(RM, PSRLQ, psrlq, Pq, Qq, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
12939 return FNIEMOP_CALL_1(iemOpCommonMmxOpt_FullFull_To_Full, iemAImpl_psrlq_u64);
12940}
12941
12942
12943/** Opcode 0x66 0x0f 0xd3 - psrlq Vx, Wx */
12944FNIEMOP_DEF(iemOp_psrlq_Vx_Wx)
12945{
12946 IEMOP_MNEMONIC2(RM, PSRLQ, psrlq, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
12947 return FNIEMOP_CALL_1(iemOpCommonSse2Opt_FullFull_To_Full, iemAImpl_psrlq_u128);
12948}
12949
12950
12951/* Opcode 0xf3 0x0f 0xd3 - invalid */
12952/* Opcode 0xf2 0x0f 0xd3 - invalid */
12953
12954
12955/** Opcode 0x0f 0xd4 - paddq Pq, Qq */
12956FNIEMOP_DEF(iemOp_paddq_Pq_Qq)
12957{
12958 IEMOP_MNEMONIC2(RM, PADDQ, paddq, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, IEMOPHINT_IGNORES_OP_SIZES);
12959 return FNIEMOP_CALL_1(iemOpCommonMmx_FullFull_To_Full_Sse2, iemAImpl_paddq_u64);
12960}
12961
12962
12963/** Opcode 0x66 0x0f 0xd4 - paddq Vx, Wx */
12964FNIEMOP_DEF(iemOp_paddq_Vx_Wx)
12965{
12966 IEMOP_MNEMONIC2(RM, PADDQ, paddq, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
12967 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_paddq_u128);
12968}
12969
12970
12971/* Opcode 0xf3 0x0f 0xd4 - invalid */
12972/* Opcode 0xf2 0x0f 0xd4 - invalid */
12973
12974/** Opcode 0x0f 0xd5 - pmullw Pq, Qq */
12975FNIEMOP_DEF(iemOp_pmullw_Pq_Qq)
12976{
12977 IEMOP_MNEMONIC2(RM, PMULLW, pmullw, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, IEMOPHINT_IGNORES_OP_SIZES);
12978 return FNIEMOP_CALL_1(iemOpCommonMmx_FullFull_To_Full, iemAImpl_pmullw_u64);
12979}
12980
12981/** Opcode 0x66 0x0f 0xd5 - pmullw Vx, Wx */
12982FNIEMOP_DEF(iemOp_pmullw_Vx_Wx)
12983{
12984 IEMOP_MNEMONIC2(RM, PMULLW, pmullw, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
12985 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_pmullw_u128);
12986}
12987
12988
12989/* Opcode 0xf3 0x0f 0xd5 - invalid */
12990/* Opcode 0xf2 0x0f 0xd5 - invalid */
12991
12992/* Opcode 0x0f 0xd6 - invalid */
12993
12994/**
12995 * @opcode 0xd6
12996 * @oppfx 0x66
12997 * @opcpuid sse2
12998 * @opgroup og_sse2_pcksclr_datamove
12999 * @opxcpttype none
13000 * @optest op1=-1 op2=2 -> op1=2
13001 * @optest op1=0 op2=-42 -> op1=-42
13002 */
13003FNIEMOP_DEF(iemOp_movq_Wq_Vq)
13004{
13005 IEMOP_MNEMONIC2(MR, MOVQ, movq, WqZxReg_WO, Vq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
13006 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
13007 if (IEM_IS_MODRM_REG_MODE(bRm))
13008 {
13009 /*
13010 * Register, register.
13011 */
13012 IEM_MC_BEGIN(0, 2, IEM_MC_F_NOT_286_OR_OLDER, 0);
13013 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
13014 IEM_MC_LOCAL(uint64_t, uSrc);
13015
13016 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
13017 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
13018
13019 IEM_MC_FETCH_XREG_U64(uSrc, IEM_GET_MODRM_REG(pVCpu, bRm), 0 /* a_iQword*/);
13020 IEM_MC_STORE_XREG_U64_ZX_U128(IEM_GET_MODRM_RM(pVCpu, bRm), uSrc);
13021
13022 IEM_MC_ADVANCE_RIP_AND_FINISH();
13023 IEM_MC_END();
13024 }
13025 else
13026 {
13027 /*
13028 * Memory, register.
13029 */
13030 IEM_MC_BEGIN(0, 2, IEM_MC_F_NOT_286_OR_OLDER, 0);
13031 IEM_MC_LOCAL(uint64_t, uSrc);
13032 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
13033
13034 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
13035 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
13036 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
13037 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
13038
13039 IEM_MC_FETCH_XREG_U64(uSrc, IEM_GET_MODRM_REG(pVCpu, bRm), 0 /* a_iQword*/);
13040 IEM_MC_STORE_MEM_U64(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, uSrc);
13041
13042 IEM_MC_ADVANCE_RIP_AND_FINISH();
13043 IEM_MC_END();
13044 }
13045}
13046
13047
13048/**
13049 * @opcode 0xd6
13050 * @opcodesub 11 mr/reg
13051 * @oppfx f3
13052 * @opcpuid sse2
13053 * @opgroup og_sse2_simdint_datamove
13054 * @optest op1=1 op2=2 -> op1=2 ftw=0xff
13055 * @optest op1=0 op2=-42 -> op1=-42 ftw=0xff
13056 */
13057FNIEMOP_DEF(iemOp_movq2dq_Vdq_Nq)
13058{
13059 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
13060 if (IEM_IS_MODRM_REG_MODE(bRm))
13061 {
13062 /*
13063 * Register, register.
13064 */
13065 IEMOP_MNEMONIC2(RM_REG, MOVQ2DQ, movq2dq, VqZx_WO, Nq, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
13066 IEM_MC_BEGIN(0, 1, IEM_MC_F_NOT_286_OR_OLDER, 0);
13067 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
13068 IEM_MC_LOCAL(uint64_t, uSrc);
13069
13070 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
13071 IEM_MC_ACTUALIZE_FPU_STATE_FOR_CHANGE();
13072 IEM_MC_FPU_TO_MMX_MODE();
13073
13074 IEM_MC_FETCH_MREG_U64(uSrc, IEM_GET_MODRM_RM_8(bRm));
13075 IEM_MC_STORE_XREG_U64_ZX_U128(IEM_GET_MODRM_REG(pVCpu, bRm), uSrc);
13076
13077 IEM_MC_ADVANCE_RIP_AND_FINISH();
13078 IEM_MC_END();
13079 }
13080
13081 /**
13082 * @opdone
13083 * @opmnemonic udf30fd6mem
13084 * @opcode 0xd6
13085 * @opcodesub !11 mr/reg
13086 * @oppfx f3
13087 * @opunused intel-modrm
13088 * @opcpuid sse
13089 * @optest ->
13090 */
13091 else
13092 return FNIEMOP_CALL_1(iemOp_InvalidWithRMNeedDecode, bRm);
13093}
13094
13095
13096/**
13097 * @opcode 0xd6
13098 * @opcodesub 11 mr/reg
13099 * @oppfx f2
13100 * @opcpuid sse2
13101 * @opgroup og_sse2_simdint_datamove
13102 * @optest op1=1 op2=2 -> op1=2 ftw=0xff
13103 * @optest op1=0 op2=-42 -> op1=-42 ftw=0xff
13104 * @optest op1=0 op2=0x1123456789abcdef -> op1=0x1123456789abcdef ftw=0xff
13105 * @optest op1=0 op2=0xfedcba9876543210 -> op1=0xfedcba9876543210 ftw=0xff
13106 * @optest op1=-42 op2=0xfedcba9876543210
13107 * -> op1=0xfedcba9876543210 ftw=0xff
13108 */
13109FNIEMOP_DEF(iemOp_movdq2q_Pq_Uq)
13110{
13111 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
13112 if (IEM_IS_MODRM_REG_MODE(bRm))
13113 {
13114 /*
13115 * Register, register.
13116 */
13117 IEMOP_MNEMONIC2(RM_REG, MOVDQ2Q, movdq2q, Pq_WO, Uq, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
13118 IEM_MC_BEGIN(0, 1, IEM_MC_F_NOT_286_OR_OLDER, 0);
13119 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
13120 IEM_MC_LOCAL(uint64_t, uSrc);
13121
13122 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
13123 IEM_MC_ACTUALIZE_FPU_STATE_FOR_CHANGE();
13124 IEM_MC_FPU_TO_MMX_MODE();
13125
13126 IEM_MC_FETCH_XREG_U64(uSrc, IEM_GET_MODRM_RM(pVCpu, bRm), 0 /* a_iQword*/);
13127 IEM_MC_STORE_MREG_U64(IEM_GET_MODRM_REG_8(bRm), uSrc);
13128
13129 IEM_MC_ADVANCE_RIP_AND_FINISH();
13130 IEM_MC_END();
13131 }
13132
13133 /**
13134 * @opdone
13135 * @opmnemonic udf20fd6mem
13136 * @opcode 0xd6
13137 * @opcodesub !11 mr/reg
13138 * @oppfx f2
13139 * @opunused intel-modrm
13140 * @opcpuid sse
13141 * @optest ->
13142 */
13143 else
13144 return FNIEMOP_CALL_1(iemOp_InvalidWithRMNeedDecode, bRm);
13145}
13146
13147
13148/** Opcode 0x0f 0xd7 - pmovmskb Gd, Nq */
13149FNIEMOP_DEF(iemOp_pmovmskb_Gd_Nq)
13150{
13151 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
13152 /* Docs says register only. */
13153 if (IEM_IS_MODRM_REG_MODE(bRm)) /** @todo test that this is registers only. */
13154 {
13155 /* Note! Taking the lazy approch here wrt the high 32-bits of the GREG. */
13156 IEMOP_MNEMONIC2(RM_REG, PMOVMSKB, pmovmskb, Gd, Nq, DISOPTYPE_X86_MMX | DISOPTYPE_HARMLESS, 0);
13157 IEM_MC_BEGIN(2, 0, IEM_MC_F_NOT_286_OR_OLDER, 0);
13158 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX_2_OR(fSse, fAmdMmxExts);
13159 IEM_MC_ARG(uint64_t *, puDst, 0);
13160 IEM_MC_ARG(uint64_t const *, puSrc, 1);
13161 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
13162 IEM_MC_PREPARE_FPU_USAGE();
13163 IEM_MC_FPU_TO_MMX_MODE();
13164
13165 IEM_MC_REF_GREG_U64(puDst, IEM_GET_MODRM_REG(pVCpu, bRm));
13166 IEM_MC_REF_MREG_U64_CONST(puSrc, IEM_GET_MODRM_RM_8(bRm));
13167 IEM_MC_CALL_VOID_AIMPL_2(iemAImpl_pmovmskb_u64, puDst, puSrc);
13168
13169 IEM_MC_ADVANCE_RIP_AND_FINISH();
13170 IEM_MC_END();
13171 }
13172 else
13173 IEMOP_RAISE_INVALID_OPCODE_RET();
13174}
13175
13176
13177/** Opcode 0x66 0x0f 0xd7 - */
13178FNIEMOP_DEF(iemOp_pmovmskb_Gd_Ux)
13179{
13180 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
13181 /* Docs says register only. */
13182 if (IEM_IS_MODRM_REG_MODE(bRm)) /** @todo test that this is registers only. */
13183 {
13184 /* Note! Taking the lazy approch here wrt the high 32-bits of the GREG. */
13185 IEMOP_MNEMONIC2(RM_REG, PMOVMSKB, pmovmskb, Gd, Ux, DISOPTYPE_X86_SSE | DISOPTYPE_HARMLESS, 0);
13186 IEM_MC_BEGIN(2, 0, IEM_MC_F_NOT_286_OR_OLDER, 0);
13187 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
13188 IEM_MC_ARG(uint64_t *, puDst, 0);
13189 IEM_MC_ARG(PCRTUINT128U, puSrc, 1);
13190 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
13191 IEM_MC_PREPARE_SSE_USAGE();
13192 IEM_MC_REF_GREG_U64(puDst, IEM_GET_MODRM_REG(pVCpu, bRm));
13193 IEM_MC_REF_XREG_U128_CONST(puSrc, IEM_GET_MODRM_RM(pVCpu, bRm));
13194 IEM_MC_CALL_VOID_AIMPL_2(iemAImpl_pmovmskb_u128, puDst, puSrc);
13195 IEM_MC_ADVANCE_RIP_AND_FINISH();
13196 IEM_MC_END();
13197 }
13198 else
13199 IEMOP_RAISE_INVALID_OPCODE_RET();
13200}
13201
13202
13203/* Opcode 0xf3 0x0f 0xd7 - invalid */
13204/* Opcode 0xf2 0x0f 0xd7 - invalid */
13205
13206
13207/** Opcode 0x0f 0xd8 - psubusb Pq, Qq */
13208FNIEMOP_DEF(iemOp_psubusb_Pq_Qq)
13209{
13210 IEMOP_MNEMONIC2(RM, PSUBUSB, psubusb, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, IEMOPHINT_IGNORES_OP_SIZES);
13211 return FNIEMOP_CALL_1(iemOpCommonMmx_FullFull_To_Full, iemAImpl_psubusb_u64);
13212}
13213
13214
13215/** Opcode 0x66 0x0f 0xd8 - psubusb Vx, Wx */
13216FNIEMOP_DEF(iemOp_psubusb_Vx_Wx)
13217{
13218 IEMOP_MNEMONIC2(RM, PSUBUSB, psubusb, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
13219 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_psubusb_u128);
13220}
13221
13222
13223/* Opcode 0xf3 0x0f 0xd8 - invalid */
13224/* Opcode 0xf2 0x0f 0xd8 - invalid */
13225
13226/** Opcode 0x0f 0xd9 - psubusw Pq, Qq */
13227FNIEMOP_DEF(iemOp_psubusw_Pq_Qq)
13228{
13229 IEMOP_MNEMONIC2(RM, PSUBUSW, psubusw, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, IEMOPHINT_IGNORES_OP_SIZES);
13230 return FNIEMOP_CALL_1(iemOpCommonMmx_FullFull_To_Full, iemAImpl_psubusw_u64);
13231}
13232
13233
13234/** Opcode 0x66 0x0f 0xd9 - psubusw Vx, Wx */
13235FNIEMOP_DEF(iemOp_psubusw_Vx_Wx)
13236{
13237 IEMOP_MNEMONIC2(RM, PSUBUSW, psubusw, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
13238 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_psubusw_u128);
13239}
13240
13241
13242/* Opcode 0xf3 0x0f 0xd9 - invalid */
13243/* Opcode 0xf2 0x0f 0xd9 - invalid */
13244
13245/** Opcode 0x0f 0xda - pminub Pq, Qq */
13246FNIEMOP_DEF(iemOp_pminub_Pq_Qq)
13247{
13248 IEMOP_MNEMONIC2(RM, PMINUB, pminub, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, IEMOPHINT_IGNORES_OP_SIZES);
13249 return FNIEMOP_CALL_1(iemOpCommonMmxSse_FullFull_To_Full, iemAImpl_pminub_u64);
13250}
13251
13252
13253/** Opcode 0x66 0x0f 0xda - pminub Vx, Wx */
13254FNIEMOP_DEF(iemOp_pminub_Vx_Wx)
13255{
13256 IEMOP_MNEMONIC2(RM, PMINUB, pminub, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
13257 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_pminub_u128);
13258}
13259
13260/* Opcode 0xf3 0x0f 0xda - invalid */
13261/* Opcode 0xf2 0x0f 0xda - invalid */
13262
13263/** Opcode 0x0f 0xdb - pand Pq, Qq */
13264FNIEMOP_DEF(iemOp_pand_Pq_Qq)
13265{
13266 IEMOP_MNEMONIC2(RM, PAND, pand, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, IEMOPHINT_IGNORES_OP_SIZES);
13267 return FNIEMOP_CALL_1(iemOpCommonMmx_FullFull_To_Full, iemAImpl_pand_u64);
13268}
13269
13270
13271/** Opcode 0x66 0x0f 0xdb - pand Vx, Wx */
13272FNIEMOP_DEF(iemOp_pand_Vx_Wx)
13273{
13274 IEMOP_MNEMONIC2(RM, PAND, pand, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
13275 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_pand_u128);
13276}
13277
13278
13279/* Opcode 0xf3 0x0f 0xdb - invalid */
13280/* Opcode 0xf2 0x0f 0xdb - invalid */
13281
13282/** Opcode 0x0f 0xdc - paddusb Pq, Qq */
13283FNIEMOP_DEF(iemOp_paddusb_Pq_Qq)
13284{
13285 IEMOP_MNEMONIC2(RM, PADDUSB, paddusb, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, IEMOPHINT_IGNORES_OP_SIZES);
13286 return FNIEMOP_CALL_1(iemOpCommonMmx_FullFull_To_Full, iemAImpl_paddusb_u64);
13287}
13288
13289
13290/** Opcode 0x66 0x0f 0xdc - paddusb Vx, Wx */
13291FNIEMOP_DEF(iemOp_paddusb_Vx_Wx)
13292{
13293 IEMOP_MNEMONIC2(RM, PADDUSB, paddusb, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
13294 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_paddusb_u128);
13295}
13296
13297
13298/* Opcode 0xf3 0x0f 0xdc - invalid */
13299/* Opcode 0xf2 0x0f 0xdc - invalid */
13300
13301/** Opcode 0x0f 0xdd - paddusw Pq, Qq */
13302FNIEMOP_DEF(iemOp_paddusw_Pq_Qq)
13303{
13304 IEMOP_MNEMONIC2(RM, PADDUSW, paddusw, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, IEMOPHINT_IGNORES_OP_SIZES);
13305 return FNIEMOP_CALL_1(iemOpCommonMmx_FullFull_To_Full, iemAImpl_paddusw_u64);
13306}
13307
13308
13309/** Opcode 0x66 0x0f 0xdd - paddusw Vx, Wx */
13310FNIEMOP_DEF(iemOp_paddusw_Vx_Wx)
13311{
13312 IEMOP_MNEMONIC2(RM, PADDUSW, paddusw, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
13313 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_paddusw_u128);
13314}
13315
13316
13317/* Opcode 0xf3 0x0f 0xdd - invalid */
13318/* Opcode 0xf2 0x0f 0xdd - invalid */
13319
13320/** Opcode 0x0f 0xde - pmaxub Pq, Qq */
13321FNIEMOP_DEF(iemOp_pmaxub_Pq_Qq)
13322{
13323 IEMOP_MNEMONIC2(RM, PMAXUB, pmaxub, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, IEMOPHINT_IGNORES_OP_SIZES);
13324 return FNIEMOP_CALL_1(iemOpCommonMmxSse_FullFull_To_Full, iemAImpl_pmaxub_u64);
13325}
13326
13327
13328/** Opcode 0x66 0x0f 0xde - pmaxub Vx, W */
13329FNIEMOP_DEF(iemOp_pmaxub_Vx_Wx)
13330{
13331 IEMOP_MNEMONIC2(RM, PMAXUB, pmaxub, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
13332 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_pmaxub_u128);
13333}
13334
13335/* Opcode 0xf3 0x0f 0xde - invalid */
13336/* Opcode 0xf2 0x0f 0xde - invalid */
13337
13338
13339/** Opcode 0x0f 0xdf - pandn Pq, Qq */
13340FNIEMOP_DEF(iemOp_pandn_Pq_Qq)
13341{
13342 IEMOP_MNEMONIC2(RM, PANDN, pandn, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, IEMOPHINT_IGNORES_OP_SIZES);
13343 return FNIEMOP_CALL_1(iemOpCommonMmx_FullFull_To_Full, iemAImpl_pandn_u64);
13344}
13345
13346
13347/** Opcode 0x66 0x0f 0xdf - pandn Vx, Wx */
13348FNIEMOP_DEF(iemOp_pandn_Vx_Wx)
13349{
13350 IEMOP_MNEMONIC2(RM, PANDN, pandn, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
13351 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_pandn_u128);
13352}
13353
13354
13355/* Opcode 0xf3 0x0f 0xdf - invalid */
13356/* Opcode 0xf2 0x0f 0xdf - invalid */
13357
13358/** Opcode 0x0f 0xe0 - pavgb Pq, Qq */
13359FNIEMOP_DEF(iemOp_pavgb_Pq_Qq)
13360{
13361 IEMOP_MNEMONIC2(RM, PAVGB, pavgb, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, IEMOPHINT_IGNORES_OP_SIZES);
13362 return FNIEMOP_CALL_1(iemOpCommonMmxSseOpt_FullFull_To_Full, iemAImpl_pavgb_u64);
13363}
13364
13365
13366/** Opcode 0x66 0x0f 0xe0 - pavgb Vx, Wx */
13367FNIEMOP_DEF(iemOp_pavgb_Vx_Wx)
13368{
13369 IEMOP_MNEMONIC2(RM, PAVGB, pavgb, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
13370 return FNIEMOP_CALL_1(iemOpCommonSse2Opt_FullFull_To_Full, iemAImpl_pavgb_u128);
13371}
13372
13373
13374/* Opcode 0xf3 0x0f 0xe0 - invalid */
13375/* Opcode 0xf2 0x0f 0xe0 - invalid */
13376
13377/** Opcode 0x0f 0xe1 - psraw Pq, Qq */
13378FNIEMOP_DEF(iemOp_psraw_Pq_Qq)
13379{
13380 IEMOP_MNEMONIC2(RM, PSRAW, psraw, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, IEMOPHINT_IGNORES_OP_SIZES);
13381 return FNIEMOP_CALL_1(iemOpCommonMmxOpt_FullFull_To_Full, iemAImpl_psraw_u64);
13382}
13383
13384
13385/** Opcode 0x66 0x0f 0xe1 - psraw Vx, Wx */
13386FNIEMOP_DEF(iemOp_psraw_Vx_Wx)
13387{
13388 IEMOP_MNEMONIC2(RM, PSRAW, psraw, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
13389 return FNIEMOP_CALL_1(iemOpCommonSse2Opt_FullFull_To_Full, iemAImpl_psraw_u128);
13390}
13391
13392
13393/* Opcode 0xf3 0x0f 0xe1 - invalid */
13394/* Opcode 0xf2 0x0f 0xe1 - invalid */
13395
13396/** Opcode 0x0f 0xe2 - psrad Pq, Qq */
13397FNIEMOP_DEF(iemOp_psrad_Pq_Qq)
13398{
13399 IEMOP_MNEMONIC2(RM, PSRAD, psrad, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, IEMOPHINT_IGNORES_OP_SIZES);
13400 return FNIEMOP_CALL_1(iemOpCommonMmxOpt_FullFull_To_Full, iemAImpl_psrad_u64);
13401}
13402
13403
13404/** Opcode 0x66 0x0f 0xe2 - psrad Vx, Wx */
13405FNIEMOP_DEF(iemOp_psrad_Vx_Wx)
13406{
13407 IEMOP_MNEMONIC2(RM, PSRAD, psrad, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
13408 return FNIEMOP_CALL_1(iemOpCommonSse2Opt_FullFull_To_Full, iemAImpl_psrad_u128);
13409}
13410
13411
13412/* Opcode 0xf3 0x0f 0xe2 - invalid */
13413/* Opcode 0xf2 0x0f 0xe2 - invalid */
13414
13415/** Opcode 0x0f 0xe3 - pavgw Pq, Qq */
13416FNIEMOP_DEF(iemOp_pavgw_Pq_Qq)
13417{
13418 IEMOP_MNEMONIC2(RM, PAVGW, pavgw, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, IEMOPHINT_IGNORES_OP_SIZES);
13419 return FNIEMOP_CALL_1(iemOpCommonMmxSseOpt_FullFull_To_Full, iemAImpl_pavgw_u64);
13420}
13421
13422
13423/** Opcode 0x66 0x0f 0xe3 - pavgw Vx, Wx */
13424FNIEMOP_DEF(iemOp_pavgw_Vx_Wx)
13425{
13426 IEMOP_MNEMONIC2(RM, PAVGW, pavgw, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
13427 return FNIEMOP_CALL_1(iemOpCommonSse2Opt_FullFull_To_Full, iemAImpl_pavgw_u128);
13428}
13429
13430
13431/* Opcode 0xf3 0x0f 0xe3 - invalid */
13432/* Opcode 0xf2 0x0f 0xe3 - invalid */
13433
13434/** Opcode 0x0f 0xe4 - pmulhuw Pq, Qq */
13435FNIEMOP_DEF(iemOp_pmulhuw_Pq_Qq)
13436{
13437 IEMOP_MNEMONIC2(RM, PMULHUW, pmulhuw, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, IEMOPHINT_IGNORES_OP_SIZES);
13438 return FNIEMOP_CALL_1(iemOpCommonMmxSseOpt_FullFull_To_Full, iemAImpl_pmulhuw_u64);
13439}
13440
13441
13442/** Opcode 0x66 0x0f 0xe4 - pmulhuw Vx, Wx */
13443FNIEMOP_DEF(iemOp_pmulhuw_Vx_Wx)
13444{
13445 IEMOP_MNEMONIC2(RM, PMULHUW, pmulhuw, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
13446 return FNIEMOP_CALL_1(iemOpCommonSse2Opt_FullFull_To_Full, iemAImpl_pmulhuw_u128);
13447}
13448
13449
13450/* Opcode 0xf3 0x0f 0xe4 - invalid */
13451/* Opcode 0xf2 0x0f 0xe4 - invalid */
13452
13453/** Opcode 0x0f 0xe5 - pmulhw Pq, Qq */
13454FNIEMOP_DEF(iemOp_pmulhw_Pq_Qq)
13455{
13456 IEMOP_MNEMONIC2(RM, PMULHW, pmulhw, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, IEMOPHINT_IGNORES_OP_SIZES);
13457 return FNIEMOP_CALL_1(iemOpCommonMmx_FullFull_To_Full, iemAImpl_pmulhw_u64);
13458}
13459
13460
13461/** Opcode 0x66 0x0f 0xe5 - pmulhw Vx, Wx */
13462FNIEMOP_DEF(iemOp_pmulhw_Vx_Wx)
13463{
13464 IEMOP_MNEMONIC2(RM, PMULHW, pmulhw, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
13465 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_pmulhw_u128);
13466}
13467
13468
13469/* Opcode 0xf3 0x0f 0xe5 - invalid */
13470/* Opcode 0xf2 0x0f 0xe5 - invalid */
13471/* Opcode 0x0f 0xe6 - invalid */
13472
13473
13474/** Opcode 0x66 0x0f 0xe6 - cvttpd2dq Vx, Wpd */
13475FNIEMOP_DEF(iemOp_cvttpd2dq_Vx_Wpd)
13476{
13477 IEMOP_MNEMONIC2(RM, CVTTPD2DQ, cvttpd2dq, Vx, Wpd, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
13478 return FNIEMOP_CALL_1(iemOpCommonSse2Fp_FullFull_To_Full, iemAImpl_cvttpd2dq_u128);
13479}
13480
13481
13482/** Opcode 0xf3 0x0f 0xe6 - cvtdq2pd Vx, Wpd */
13483FNIEMOP_DEF(iemOp_cvtdq2pd_Vx_Wpd)
13484{
13485 IEMOP_MNEMONIC2(RM, CVTDQ2PD, cvtdq2pd, Vx, Wpd, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
13486 return FNIEMOP_CALL_1(iemOpCommonSse2Fp_FullFull_To_Full, iemAImpl_cvtdq2pd_u128);
13487}
13488
13489
13490/** Opcode 0xf2 0x0f 0xe6 - cvtpd2dq Vx, Wpd */
13491FNIEMOP_DEF(iemOp_cvtpd2dq_Vx_Wpd)
13492{
13493 IEMOP_MNEMONIC2(RM, CVTPD2DQ, cvtpd2dq, Vx, Wpd, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
13494 return FNIEMOP_CALL_1(iemOpCommonSse2Fp_FullFull_To_Full, iemAImpl_cvtpd2dq_u128);
13495}
13496
13497
13498/**
13499 * @opcode 0xe7
13500 * @opcodesub !11 mr/reg
13501 * @oppfx none
13502 * @opcpuid sse
13503 * @opgroup og_sse1_cachect
13504 * @opxcpttype none
13505 * @optest op1=-1 op2=2 -> op1=2 ftw=0xff
13506 * @optest op1=0 op2=-42 -> op1=-42 ftw=0xff
13507 */
13508FNIEMOP_DEF(iemOp_movntq_Mq_Pq)
13509{
13510 IEMOP_MNEMONIC2(MR_MEM, MOVNTQ, movntq, Mq_WO, Pq, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
13511 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
13512 if (IEM_IS_MODRM_MEM_MODE(bRm))
13513 {
13514 /* Register, memory. */
13515 IEM_MC_BEGIN(0, 2, IEM_MC_F_NOT_286_OR_OLDER, 0);
13516 IEM_MC_LOCAL(uint64_t, uSrc);
13517 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
13518
13519 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
13520 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fMmx);
13521 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
13522 IEM_MC_ACTUALIZE_FPU_STATE_FOR_CHANGE();
13523 IEM_MC_FPU_TO_MMX_MODE();
13524
13525 IEM_MC_FETCH_MREG_U64(uSrc, IEM_GET_MODRM_REG_8(bRm));
13526 IEM_MC_STORE_MEM_U64(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, uSrc);
13527
13528 IEM_MC_ADVANCE_RIP_AND_FINISH();
13529 IEM_MC_END();
13530 }
13531 /**
13532 * @opdone
13533 * @opmnemonic ud0fe7reg
13534 * @opcode 0xe7
13535 * @opcodesub 11 mr/reg
13536 * @oppfx none
13537 * @opunused immediate
13538 * @opcpuid sse
13539 * @optest ->
13540 */
13541 else
13542 IEMOP_RAISE_INVALID_OPCODE_RET();
13543}
13544
13545/**
13546 * @opcode 0xe7
13547 * @opcodesub !11 mr/reg
13548 * @oppfx 0x66
13549 * @opcpuid sse2
13550 * @opgroup og_sse2_cachect
13551 * @opxcpttype 1
13552 * @optest op1=-1 op2=2 -> op1=2
13553 * @optest op1=0 op2=-42 -> op1=-42
13554 */
13555FNIEMOP_DEF(iemOp_movntdq_Mdq_Vdq)
13556{
13557 IEMOP_MNEMONIC2(MR_MEM, MOVNTDQ, movntdq, Mdq_WO, Vdq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
13558 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
13559 if (IEM_IS_MODRM_MEM_MODE(bRm))
13560 {
13561 /* Register, memory. */
13562 IEM_MC_BEGIN(0, 2, IEM_MC_F_NOT_286_OR_OLDER, 0);
13563 IEM_MC_LOCAL(RTUINT128U, uSrc);
13564 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
13565
13566 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
13567 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
13568 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
13569 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
13570
13571 IEM_MC_FETCH_XREG_U128(uSrc, IEM_GET_MODRM_REG(pVCpu, bRm));
13572 IEM_MC_STORE_MEM_U128_ALIGN_SSE(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, uSrc);
13573
13574 IEM_MC_ADVANCE_RIP_AND_FINISH();
13575 IEM_MC_END();
13576 }
13577
13578 /**
13579 * @opdone
13580 * @opmnemonic ud660fe7reg
13581 * @opcode 0xe7
13582 * @opcodesub 11 mr/reg
13583 * @oppfx 0x66
13584 * @opunused immediate
13585 * @opcpuid sse
13586 * @optest ->
13587 */
13588 else
13589 IEMOP_RAISE_INVALID_OPCODE_RET();
13590}
13591
13592/* Opcode 0xf3 0x0f 0xe7 - invalid */
13593/* Opcode 0xf2 0x0f 0xe7 - invalid */
13594
13595
13596/** Opcode 0x0f 0xe8 - psubsb Pq, Qq */
13597FNIEMOP_DEF(iemOp_psubsb_Pq_Qq)
13598{
13599 IEMOP_MNEMONIC2(RM, PSUBSB, psubsb, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, IEMOPHINT_IGNORES_OP_SIZES);
13600 return FNIEMOP_CALL_1(iemOpCommonMmx_FullFull_To_Full, iemAImpl_psubsb_u64);
13601}
13602
13603
13604/** Opcode 0x66 0x0f 0xe8 - psubsb Vx, Wx */
13605FNIEMOP_DEF(iemOp_psubsb_Vx_Wx)
13606{
13607 IEMOP_MNEMONIC2(RM, PSUBSB, psubsb, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
13608 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_psubsb_u128);
13609}
13610
13611
13612/* Opcode 0xf3 0x0f 0xe8 - invalid */
13613/* Opcode 0xf2 0x0f 0xe8 - invalid */
13614
13615/** Opcode 0x0f 0xe9 - psubsw Pq, Qq */
13616FNIEMOP_DEF(iemOp_psubsw_Pq_Qq)
13617{
13618 IEMOP_MNEMONIC2(RM, PSUBSW, psubsw, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, IEMOPHINT_IGNORES_OP_SIZES);
13619 return FNIEMOP_CALL_1(iemOpCommonMmx_FullFull_To_Full, iemAImpl_psubsw_u64);
13620}
13621
13622
13623/** Opcode 0x66 0x0f 0xe9 - psubsw Vx, Wx */
13624FNIEMOP_DEF(iemOp_psubsw_Vx_Wx)
13625{
13626 IEMOP_MNEMONIC2(RM, PSUBSW, psubsw, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
13627 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_psubsw_u128);
13628}
13629
13630
13631/* Opcode 0xf3 0x0f 0xe9 - invalid */
13632/* Opcode 0xf2 0x0f 0xe9 - invalid */
13633
13634
13635/** Opcode 0x0f 0xea - pminsw Pq, Qq */
13636FNIEMOP_DEF(iemOp_pminsw_Pq_Qq)
13637{
13638 IEMOP_MNEMONIC2(RM, PMINSW, pminsw, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, IEMOPHINT_IGNORES_OP_SIZES);
13639 return FNIEMOP_CALL_1(iemOpCommonMmxSse_FullFull_To_Full, iemAImpl_pminsw_u64);
13640}
13641
13642
13643/** Opcode 0x66 0x0f 0xea - pminsw Vx, Wx */
13644FNIEMOP_DEF(iemOp_pminsw_Vx_Wx)
13645{
13646 IEMOP_MNEMONIC2(RM, PMINSW, pminsw, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
13647 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_pminsw_u128);
13648}
13649
13650
13651/* Opcode 0xf3 0x0f 0xea - invalid */
13652/* Opcode 0xf2 0x0f 0xea - invalid */
13653
13654
13655/** Opcode 0x0f 0xeb - por Pq, Qq */
13656FNIEMOP_DEF(iemOp_por_Pq_Qq)
13657{
13658 IEMOP_MNEMONIC2(RM, POR, por, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, IEMOPHINT_IGNORES_OP_SIZES);
13659 return FNIEMOP_CALL_1(iemOpCommonMmx_FullFull_To_Full, iemAImpl_por_u64);
13660}
13661
13662
13663/** Opcode 0x66 0x0f 0xeb - por Vx, Wx */
13664FNIEMOP_DEF(iemOp_por_Vx_Wx)
13665{
13666 IEMOP_MNEMONIC2(RM, POR, por, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
13667 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_por_u128);
13668}
13669
13670
13671/* Opcode 0xf3 0x0f 0xeb - invalid */
13672/* Opcode 0xf2 0x0f 0xeb - invalid */
13673
13674/** Opcode 0x0f 0xec - paddsb Pq, Qq */
13675FNIEMOP_DEF(iemOp_paddsb_Pq_Qq)
13676{
13677 IEMOP_MNEMONIC2(RM, PADDSB, paddsb, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, IEMOPHINT_IGNORES_OP_SIZES);
13678 return FNIEMOP_CALL_1(iemOpCommonMmx_FullFull_To_Full, iemAImpl_paddsb_u64);
13679}
13680
13681
13682/** Opcode 0x66 0x0f 0xec - paddsb Vx, Wx */
13683FNIEMOP_DEF(iemOp_paddsb_Vx_Wx)
13684{
13685 IEMOP_MNEMONIC2(RM, PADDSB, paddsb, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
13686 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_paddsb_u128);
13687}
13688
13689
13690/* Opcode 0xf3 0x0f 0xec - invalid */
13691/* Opcode 0xf2 0x0f 0xec - invalid */
13692
13693/** Opcode 0x0f 0xed - paddsw Pq, Qq */
13694FNIEMOP_DEF(iemOp_paddsw_Pq_Qq)
13695{
13696 IEMOP_MNEMONIC2(RM, PADDSW, paddsw, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, IEMOPHINT_IGNORES_OP_SIZES);
13697 return FNIEMOP_CALL_1(iemOpCommonMmx_FullFull_To_Full, iemAImpl_paddsw_u64);
13698}
13699
13700
13701/** Opcode 0x66 0x0f 0xed - paddsw Vx, Wx */
13702FNIEMOP_DEF(iemOp_paddsw_Vx_Wx)
13703{
13704 IEMOP_MNEMONIC2(RM, PADDSW, paddsw, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
13705 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_paddsw_u128);
13706}
13707
13708
13709/* Opcode 0xf3 0x0f 0xed - invalid */
13710/* Opcode 0xf2 0x0f 0xed - invalid */
13711
13712
13713/** Opcode 0x0f 0xee - pmaxsw Pq, Qq */
13714FNIEMOP_DEF(iemOp_pmaxsw_Pq_Qq)
13715{
13716 IEMOP_MNEMONIC2(RM, PMAXSW, pmaxsw, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, IEMOPHINT_IGNORES_OP_SIZES);
13717 return FNIEMOP_CALL_1(iemOpCommonMmxSse_FullFull_To_Full, iemAImpl_pmaxsw_u64);
13718}
13719
13720
13721/** Opcode 0x66 0x0f 0xee - pmaxsw Vx, Wx */
13722FNIEMOP_DEF(iemOp_pmaxsw_Vx_Wx)
13723{
13724 IEMOP_MNEMONIC2(RM, PMAXSW, pmaxsw, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
13725 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_pmaxsw_u128);
13726}
13727
13728
13729/* Opcode 0xf3 0x0f 0xee - invalid */
13730/* Opcode 0xf2 0x0f 0xee - invalid */
13731
13732
13733/** Opcode 0x0f 0xef - pxor Pq, Qq */
13734FNIEMOP_DEF(iemOp_pxor_Pq_Qq)
13735{
13736 IEMOP_MNEMONIC2(RM, PXOR, pxor, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, IEMOPHINT_IGNORES_OP_SIZES);
13737 return FNIEMOP_CALL_1(iemOpCommonMmx_FullFull_To_Full, iemAImpl_pxor_u64);
13738}
13739
13740
13741/** Opcode 0x66 0x0f 0xef - pxor Vx, Wx */
13742FNIEMOP_DEF(iemOp_pxor_Vx_Wx)
13743{
13744 IEMOP_MNEMONIC2(RM, PXOR, pxor, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
13745 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_pxor_u128);
13746}
13747
13748
13749/* Opcode 0xf3 0x0f 0xef - invalid */
13750/* Opcode 0xf2 0x0f 0xef - invalid */
13751
13752/* Opcode 0x0f 0xf0 - invalid */
13753/* Opcode 0x66 0x0f 0xf0 - invalid */
13754
13755
13756/** Opcode 0xf2 0x0f 0xf0 - lddqu Vx, Mx */
13757FNIEMOP_DEF(iemOp_lddqu_Vx_Mx)
13758{
13759 IEMOP_MNEMONIC2(RM_MEM, LDDQU, lddqu, Vdq_WO, Mx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
13760 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
13761 if (IEM_IS_MODRM_REG_MODE(bRm))
13762 {
13763 /*
13764 * Register, register - (not implemented, assuming it raises \#UD).
13765 */
13766 IEMOP_RAISE_INVALID_OPCODE_RET();
13767 }
13768 else
13769 {
13770 /*
13771 * Register, memory.
13772 */
13773 IEM_MC_BEGIN(0, 2, IEM_MC_F_NOT_286_OR_OLDER, 0);
13774 IEM_MC_LOCAL(RTUINT128U, u128Tmp);
13775 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
13776
13777 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
13778 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse3);
13779 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
13780 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
13781 IEM_MC_FETCH_MEM_U128(u128Tmp, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
13782 IEM_MC_STORE_XREG_U128(IEM_GET_MODRM_REG(pVCpu, bRm), u128Tmp);
13783
13784 IEM_MC_ADVANCE_RIP_AND_FINISH();
13785 IEM_MC_END();
13786 }
13787}
13788
13789
13790/** Opcode 0x0f 0xf1 - psllw Pq, Qq */
13791FNIEMOP_DEF(iemOp_psllw_Pq_Qq)
13792{
13793 IEMOP_MNEMONIC2(RM, PSLLW, psllw, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, 0);
13794 return FNIEMOP_CALL_1(iemOpCommonMmxOpt_FullFull_To_Full, iemAImpl_psllw_u64);
13795}
13796
13797
13798/** Opcode 0x66 0x0f 0xf1 - psllw Vx, Wx */
13799FNIEMOP_DEF(iemOp_psllw_Vx_Wx)
13800{
13801 IEMOP_MNEMONIC2(RM, PSLLW, psllw, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
13802 return FNIEMOP_CALL_1(iemOpCommonSse2Opt_FullFull_To_Full, iemAImpl_psllw_u128);
13803}
13804
13805
13806/* Opcode 0xf2 0x0f 0xf1 - invalid */
13807
13808/** Opcode 0x0f 0xf2 - pslld Pq, Qq */
13809FNIEMOP_DEF(iemOp_pslld_Pq_Qq)
13810{
13811 IEMOP_MNEMONIC2(RM, PSLLD, pslld, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, 0);
13812 return FNIEMOP_CALL_1(iemOpCommonMmxOpt_FullFull_To_Full, iemAImpl_pslld_u64);
13813}
13814
13815
13816/** Opcode 0x66 0x0f 0xf2 - pslld Vx, Wx */
13817FNIEMOP_DEF(iemOp_pslld_Vx_Wx)
13818{
13819 IEMOP_MNEMONIC2(RM, PSLLD, pslld, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
13820 return FNIEMOP_CALL_1(iemOpCommonSse2Opt_FullFull_To_Full, iemAImpl_pslld_u128);
13821}
13822
13823
13824/* Opcode 0xf2 0x0f 0xf2 - invalid */
13825
13826/** Opcode 0x0f 0xf3 - psllq Pq, Qq */
13827FNIEMOP_DEF(iemOp_psllq_Pq_Qq)
13828{
13829 IEMOP_MNEMONIC2(RM, PSLLQ, psllq, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, 0);
13830 return FNIEMOP_CALL_1(iemOpCommonMmxOpt_FullFull_To_Full, iemAImpl_psllq_u64);
13831}
13832
13833
13834/** Opcode 0x66 0x0f 0xf3 - psllq Vx, Wx */
13835FNIEMOP_DEF(iemOp_psllq_Vx_Wx)
13836{
13837 IEMOP_MNEMONIC2(RM, PSLLQ, psllq, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
13838 return FNIEMOP_CALL_1(iemOpCommonSse2Opt_FullFull_To_Full, iemAImpl_psllq_u128);
13839}
13840
13841/* Opcode 0xf2 0x0f 0xf3 - invalid */
13842
13843/** Opcode 0x0f 0xf4 - pmuludq Pq, Qq */
13844FNIEMOP_DEF(iemOp_pmuludq_Pq_Qq)
13845{
13846 IEMOP_MNEMONIC2(RM, PMULUDQ, pmuludq, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
13847 return FNIEMOP_CALL_1(iemOpCommonMmx_FullFull_To_Full, iemAImpl_pmuludq_u64);
13848}
13849
13850
13851/** Opcode 0x66 0x0f 0xf4 - pmuludq Vx, W */
13852FNIEMOP_DEF(iemOp_pmuludq_Vx_Wx)
13853{
13854 IEMOP_MNEMONIC2(RM, PMULUDQ, pmuludq, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
13855 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_pmuludq_u128);
13856}
13857
13858
13859/* Opcode 0xf2 0x0f 0xf4 - invalid */
13860
13861/** Opcode 0x0f 0xf5 - pmaddwd Pq, Qq */
13862FNIEMOP_DEF(iemOp_pmaddwd_Pq_Qq)
13863{
13864 IEMOP_MNEMONIC2(RM, PMADDWD, pmaddwd, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, 0);
13865 return FNIEMOP_CALL_1(iemOpCommonMmx_FullFull_To_Full, iemAImpl_pmaddwd_u64);
13866}
13867
13868
13869/** Opcode 0x66 0x0f 0xf5 - pmaddwd Vx, Wx */
13870FNIEMOP_DEF(iemOp_pmaddwd_Vx_Wx)
13871{
13872 IEMOP_MNEMONIC2(RM, PMADDWD, pmaddwd, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
13873 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_pmaddwd_u128);
13874}
13875
13876/* Opcode 0xf2 0x0f 0xf5 - invalid */
13877
13878/** Opcode 0x0f 0xf6 - psadbw Pq, Qq */
13879FNIEMOP_DEF(iemOp_psadbw_Pq_Qq)
13880{
13881 IEMOP_MNEMONIC2(RM, PSADBW, psadbw, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, IEMOPHINT_IGNORES_OP_SIZES);
13882 return FNIEMOP_CALL_1(iemOpCommonMmxSseOpt_FullFull_To_Full, iemAImpl_psadbw_u64);
13883}
13884
13885
13886/** Opcode 0x66 0x0f 0xf6 - psadbw Vx, Wx */
13887FNIEMOP_DEF(iemOp_psadbw_Vx_Wx)
13888{
13889 IEMOP_MNEMONIC2(RM, PSADBW, psadbw, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
13890 return FNIEMOP_CALL_1(iemOpCommonSse2Opt_FullFull_To_Full, iemAImpl_psadbw_u128);
13891}
13892
13893
13894/* Opcode 0xf2 0x0f 0xf6 - invalid */
13895
13896/** Opcode 0x0f 0xf7 - maskmovq Pq, Nq */
13897FNIEMOP_STUB(iemOp_maskmovq_Pq_Nq);
13898/** Opcode 0x66 0x0f 0xf7 - maskmovdqu Vdq, Udq */
13899FNIEMOP_STUB(iemOp_maskmovdqu_Vdq_Udq);
13900/* Opcode 0xf2 0x0f 0xf7 - invalid */
13901
13902
13903/** Opcode 0x0f 0xf8 - psubb Pq, Qq */
13904FNIEMOP_DEF(iemOp_psubb_Pq_Qq)
13905{
13906 IEMOP_MNEMONIC2(RM, PSUBB, psubb, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, IEMOPHINT_IGNORES_OP_SIZES);
13907 return FNIEMOP_CALL_1(iemOpCommonMmx_FullFull_To_Full, iemAImpl_psubb_u64);
13908}
13909
13910
13911/** Opcode 0x66 0x0f 0xf8 - psubb Vx, Wx */
13912FNIEMOP_DEF(iemOp_psubb_Vx_Wx)
13913{
13914 IEMOP_MNEMONIC2(RM, PSUBB, psubb, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
13915 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_psubb_u128);
13916}
13917
13918
13919/* Opcode 0xf2 0x0f 0xf8 - invalid */
13920
13921
13922/** Opcode 0x0f 0xf9 - psubw Pq, Qq */
13923FNIEMOP_DEF(iemOp_psubw_Pq_Qq)
13924{
13925 IEMOP_MNEMONIC2(RM, PSUBW, psubw, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, IEMOPHINT_IGNORES_OP_SIZES);
13926 return FNIEMOP_CALL_1(iemOpCommonMmx_FullFull_To_Full, iemAImpl_psubw_u64);
13927}
13928
13929
13930/** Opcode 0x66 0x0f 0xf9 - psubw Vx, Wx */
13931FNIEMOP_DEF(iemOp_psubw_Vx_Wx)
13932{
13933 IEMOP_MNEMONIC2(RM, PSUBW, psubw, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
13934 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_psubw_u128);
13935}
13936
13937
13938/* Opcode 0xf2 0x0f 0xf9 - invalid */
13939
13940
13941/** Opcode 0x0f 0xfa - psubd Pq, Qq */
13942FNIEMOP_DEF(iemOp_psubd_Pq_Qq)
13943{
13944 IEMOP_MNEMONIC2(RM, PSUBD, psubd, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, IEMOPHINT_IGNORES_OP_SIZES);
13945 return FNIEMOP_CALL_1(iemOpCommonMmx_FullFull_To_Full, iemAImpl_psubd_u64);
13946}
13947
13948
13949/** Opcode 0x66 0x0f 0xfa - psubd Vx, Wx */
13950FNIEMOP_DEF(iemOp_psubd_Vx_Wx)
13951{
13952 IEMOP_MNEMONIC2(RM, PSUBD, psubd, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
13953 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_psubd_u128);
13954}
13955
13956
13957/* Opcode 0xf2 0x0f 0xfa - invalid */
13958
13959
13960/** Opcode 0x0f 0xfb - psubq Pq, Qq */
13961FNIEMOP_DEF(iemOp_psubq_Pq_Qq)
13962{
13963 IEMOP_MNEMONIC2(RM, PSUBQ, psubq, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, IEMOPHINT_IGNORES_OP_SIZES);
13964 return FNIEMOP_CALL_1(iemOpCommonMmx_FullFull_To_Full_Sse2, iemAImpl_psubq_u64);
13965}
13966
13967
13968/** Opcode 0x66 0x0f 0xfb - psubq Vx, Wx */
13969FNIEMOP_DEF(iemOp_psubq_Vx_Wx)
13970{
13971 IEMOP_MNEMONIC2(RM, PSUBQ, psubq, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
13972 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_psubq_u128);
13973}
13974
13975
13976/* Opcode 0xf2 0x0f 0xfb - invalid */
13977
13978
13979/** Opcode 0x0f 0xfc - paddb Pq, Qq */
13980FNIEMOP_DEF(iemOp_paddb_Pq_Qq)
13981{
13982 IEMOP_MNEMONIC2(RM, PADDB, paddb, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, IEMOPHINT_IGNORES_OP_SIZES);
13983 return FNIEMOP_CALL_1(iemOpCommonMmx_FullFull_To_Full, iemAImpl_paddb_u64);
13984}
13985
13986
13987/** Opcode 0x66 0x0f 0xfc - paddb Vx, Wx */
13988FNIEMOP_DEF(iemOp_paddb_Vx_Wx)
13989{
13990 IEMOP_MNEMONIC2(RM, PADDB, paddb, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
13991 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_paddb_u128);
13992}
13993
13994
13995/* Opcode 0xf2 0x0f 0xfc - invalid */
13996
13997
13998/** Opcode 0x0f 0xfd - paddw Pq, Qq */
13999FNIEMOP_DEF(iemOp_paddw_Pq_Qq)
14000{
14001 IEMOP_MNEMONIC2(RM, PADDW, paddw, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, IEMOPHINT_IGNORES_OP_SIZES);
14002 return FNIEMOP_CALL_1(iemOpCommonMmx_FullFull_To_Full, iemAImpl_paddw_u64);
14003}
14004
14005
14006/** Opcode 0x66 0x0f 0xfd - paddw Vx, Wx */
14007FNIEMOP_DEF(iemOp_paddw_Vx_Wx)
14008{
14009 IEMOP_MNEMONIC2(RM, PADDW, paddw, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
14010 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_paddw_u128);
14011}
14012
14013
14014/* Opcode 0xf2 0x0f 0xfd - invalid */
14015
14016
14017/** Opcode 0x0f 0xfe - paddd Pq, Qq */
14018FNIEMOP_DEF(iemOp_paddd_Pq_Qq)
14019{
14020 IEMOP_MNEMONIC2(RM, PADDD, paddd, Pq, Qq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_MMX, IEMOPHINT_IGNORES_OP_SIZES);
14021 return FNIEMOP_CALL_1(iemOpCommonMmx_FullFull_To_Full, iemAImpl_paddd_u64);
14022}
14023
14024
14025/** Opcode 0x66 0x0f 0xfe - paddd Vx, W */
14026FNIEMOP_DEF(iemOp_paddd_Vx_Wx)
14027{
14028 IEMOP_MNEMONIC2(RM, PADDD, paddd, Vx, Wx, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, IEMOPHINT_IGNORES_OP_SIZES);
14029 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, iemAImpl_paddd_u128);
14030}
14031
14032
14033/* Opcode 0xf2 0x0f 0xfe - invalid */
14034
14035
14036/** Opcode **** 0x0f 0xff - UD0 */
14037FNIEMOP_DEF(iemOp_ud0)
14038{
14039 IEMOP_MNEMONIC(ud0, "ud0");
14040 if (pVCpu->iem.s.enmCpuVendor == CPUMCPUVENDOR_INTEL)
14041 {
14042 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm); RT_NOREF(bRm);
14043 if (IEM_IS_MODRM_MEM_MODE(bRm))
14044 IEM_OPCODE_SKIP_RM_EFF_ADDR_BYTES(bRm);
14045 }
14046 IEMOP_HLP_DONE_DECODING();
14047 IEMOP_RAISE_INVALID_OPCODE_RET();
14048}
14049
14050
14051
14052/**
14053 * Two byte opcode map, first byte 0x0f.
14054 *
14055 * @remarks The g_apfnVexMap1 table is currently a subset of this one, so please
14056 * check if it needs updating as well when making changes.
14057 */
14058const PFNIEMOP g_apfnTwoByteMap[] =
14059{
14060 /* no prefix, 066h prefix f3h prefix, f2h prefix */
14061 /* 0x00 */ IEMOP_X4(iemOp_Grp6),
14062 /* 0x01 */ IEMOP_X4(iemOp_Grp7),
14063 /* 0x02 */ IEMOP_X4(iemOp_lar_Gv_Ew),
14064 /* 0x03 */ IEMOP_X4(iemOp_lsl_Gv_Ew),
14065 /* 0x04 */ IEMOP_X4(iemOp_Invalid),
14066 /* 0x05 */ IEMOP_X4(iemOp_syscall),
14067 /* 0x06 */ IEMOP_X4(iemOp_clts),
14068 /* 0x07 */ IEMOP_X4(iemOp_sysret),
14069 /* 0x08 */ IEMOP_X4(iemOp_invd),
14070 /* 0x09 */ IEMOP_X4(iemOp_wbinvd),
14071 /* 0x0a */ IEMOP_X4(iemOp_Invalid),
14072 /* 0x0b */ IEMOP_X4(iemOp_ud2),
14073 /* 0x0c */ IEMOP_X4(iemOp_Invalid),
14074 /* 0x0d */ IEMOP_X4(iemOp_nop_Ev_GrpP),
14075 /* 0x0e */ IEMOP_X4(iemOp_femms),
14076 /* 0x0f */ IEMOP_X4(iemOp_3Dnow),
14077
14078 /* 0x10 */ iemOp_movups_Vps_Wps, iemOp_movupd_Vpd_Wpd, iemOp_movss_Vss_Wss, iemOp_movsd_Vsd_Wsd,
14079 /* 0x11 */ iemOp_movups_Wps_Vps, iemOp_movupd_Wpd_Vpd, iemOp_movss_Wss_Vss, iemOp_movsd_Wsd_Vsd,
14080 /* 0x12 */ iemOp_movlps_Vq_Mq__movhlps, iemOp_movlpd_Vq_Mq, iemOp_movsldup_Vdq_Wdq, iemOp_movddup_Vdq_Wdq,
14081 /* 0x13 */ iemOp_movlps_Mq_Vq, iemOp_movlpd_Mq_Vq, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14082 /* 0x14 */ iemOp_unpcklps_Vx_Wx, iemOp_unpcklpd_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14083 /* 0x15 */ iemOp_unpckhps_Vx_Wx, iemOp_unpckhpd_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14084 /* 0x16 */ iemOp_movhps_Vdq_Mq__movlhps_Vdq_Uq, iemOp_movhpd_Vdq_Mq, iemOp_movshdup_Vdq_Wdq, iemOp_InvalidNeedRM,
14085 /* 0x17 */ iemOp_movhps_Mq_Vq, iemOp_movhpd_Mq_Vq, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14086 /* 0x18 */ IEMOP_X4(iemOp_prefetch_Grp16),
14087 /* 0x19 */ IEMOP_X4(iemOp_nop_Ev),
14088 /* 0x1a */ IEMOP_X4(iemOp_nop_Ev),
14089 /* 0x1b */ IEMOP_X4(iemOp_nop_Ev),
14090 /* 0x1c */ IEMOP_X4(iemOp_nop_Ev),
14091 /* 0x1d */ IEMOP_X4(iemOp_nop_Ev),
14092 /* 0x1e */ IEMOP_X4(iemOp_nop_Ev),
14093 /* 0x1f */ IEMOP_X4(iemOp_nop_Ev),
14094
14095 /* 0x20 */ iemOp_mov_Rd_Cd, iemOp_mov_Rd_Cd, iemOp_mov_Rd_Cd, iemOp_mov_Rd_Cd,
14096 /* 0x21 */ iemOp_mov_Rd_Dd, iemOp_mov_Rd_Dd, iemOp_mov_Rd_Dd, iemOp_mov_Rd_Dd,
14097 /* 0x22 */ iemOp_mov_Cd_Rd, iemOp_mov_Cd_Rd, iemOp_mov_Cd_Rd, iemOp_mov_Cd_Rd,
14098 /* 0x23 */ iemOp_mov_Dd_Rd, iemOp_mov_Dd_Rd, iemOp_mov_Dd_Rd, iemOp_mov_Dd_Rd,
14099 /* 0x24 */ iemOp_mov_Rd_Td, iemOp_mov_Rd_Td, iemOp_mov_Rd_Td, iemOp_mov_Rd_Td,
14100 /* 0x25 */ iemOp_Invalid, iemOp_Invalid, iemOp_Invalid, iemOp_Invalid,
14101 /* 0x26 */ iemOp_mov_Td_Rd, iemOp_mov_Td_Rd, iemOp_mov_Td_Rd, iemOp_mov_Td_Rd,
14102 /* 0x27 */ iemOp_Invalid, iemOp_Invalid, iemOp_Invalid, iemOp_Invalid,
14103 /* 0x28 */ iemOp_movaps_Vps_Wps, iemOp_movapd_Vpd_Wpd, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14104 /* 0x29 */ iemOp_movaps_Wps_Vps, iemOp_movapd_Wpd_Vpd, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14105 /* 0x2a */ iemOp_cvtpi2ps_Vps_Qpi, iemOp_cvtpi2pd_Vpd_Qpi, iemOp_cvtsi2ss_Vss_Ey, iemOp_cvtsi2sd_Vsd_Ey,
14106 /* 0x2b */ iemOp_movntps_Mps_Vps, iemOp_movntpd_Mpd_Vpd, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14107 /* 0x2c */ iemOp_cvttps2pi_Ppi_Wps, iemOp_cvttpd2pi_Ppi_Wpd, iemOp_cvttss2si_Gy_Wss, iemOp_cvttsd2si_Gy_Wsd,
14108 /* 0x2d */ iemOp_cvtps2pi_Ppi_Wps, iemOp_cvtpd2pi_Qpi_Wpd, iemOp_cvtss2si_Gy_Wss, iemOp_cvtsd2si_Gy_Wsd,
14109 /* 0x2e */ iemOp_ucomiss_Vss_Wss, iemOp_ucomisd_Vsd_Wsd, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14110 /* 0x2f */ iemOp_comiss_Vss_Wss, iemOp_comisd_Vsd_Wsd, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14111
14112 /* 0x30 */ IEMOP_X4(iemOp_wrmsr),
14113 /* 0x31 */ IEMOP_X4(iemOp_rdtsc),
14114 /* 0x32 */ IEMOP_X4(iemOp_rdmsr),
14115 /* 0x33 */ IEMOP_X4(iemOp_rdpmc),
14116 /* 0x34 */ IEMOP_X4(iemOp_sysenter),
14117 /* 0x35 */ IEMOP_X4(iemOp_sysexit),
14118 /* 0x36 */ IEMOP_X4(iemOp_Invalid),
14119 /* 0x37 */ IEMOP_X4(iemOp_getsec),
14120 /* 0x38 */ IEMOP_X4(iemOp_3byte_Esc_0f_38),
14121 /* 0x39 */ IEMOP_X4(iemOp_InvalidNeed3ByteEscRM),
14122 /* 0x3a */ IEMOP_X4(iemOp_3byte_Esc_0f_3a),
14123 /* 0x3b */ IEMOP_X4(iemOp_InvalidNeed3ByteEscRMImm8),
14124 /* 0x3c */ IEMOP_X4(iemOp_InvalidNeed3ByteEscRM),
14125 /* 0x3d */ IEMOP_X4(iemOp_InvalidNeed3ByteEscRM),
14126 /* 0x3e */ IEMOP_X4(iemOp_InvalidNeed3ByteEscRMImm8),
14127 /* 0x3f */ IEMOP_X4(iemOp_InvalidNeed3ByteEscRMImm8),
14128
14129 /* 0x40 */ IEMOP_X4(iemOp_cmovo_Gv_Ev),
14130 /* 0x41 */ IEMOP_X4(iemOp_cmovno_Gv_Ev),
14131 /* 0x42 */ IEMOP_X4(iemOp_cmovc_Gv_Ev),
14132 /* 0x43 */ IEMOP_X4(iemOp_cmovnc_Gv_Ev),
14133 /* 0x44 */ IEMOP_X4(iemOp_cmove_Gv_Ev),
14134 /* 0x45 */ IEMOP_X4(iemOp_cmovne_Gv_Ev),
14135 /* 0x46 */ IEMOP_X4(iemOp_cmovbe_Gv_Ev),
14136 /* 0x47 */ IEMOP_X4(iemOp_cmovnbe_Gv_Ev),
14137 /* 0x48 */ IEMOP_X4(iemOp_cmovs_Gv_Ev),
14138 /* 0x49 */ IEMOP_X4(iemOp_cmovns_Gv_Ev),
14139 /* 0x4a */ IEMOP_X4(iemOp_cmovp_Gv_Ev),
14140 /* 0x4b */ IEMOP_X4(iemOp_cmovnp_Gv_Ev),
14141 /* 0x4c */ IEMOP_X4(iemOp_cmovl_Gv_Ev),
14142 /* 0x4d */ IEMOP_X4(iemOp_cmovnl_Gv_Ev),
14143 /* 0x4e */ IEMOP_X4(iemOp_cmovle_Gv_Ev),
14144 /* 0x4f */ IEMOP_X4(iemOp_cmovnle_Gv_Ev),
14145
14146 /* 0x50 */ iemOp_movmskps_Gy_Ups, iemOp_movmskpd_Gy_Upd, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14147 /* 0x51 */ iemOp_sqrtps_Vps_Wps, iemOp_sqrtpd_Vpd_Wpd, iemOp_sqrtss_Vss_Wss, iemOp_sqrtsd_Vsd_Wsd,
14148 /* 0x52 */ iemOp_rsqrtps_Vps_Wps, iemOp_InvalidNeedRM, iemOp_rsqrtss_Vss_Wss, iemOp_InvalidNeedRM,
14149 /* 0x53 */ iemOp_rcpps_Vps_Wps, iemOp_InvalidNeedRM, iemOp_rcpss_Vss_Wss, iemOp_InvalidNeedRM,
14150 /* 0x54 */ iemOp_andps_Vps_Wps, iemOp_andpd_Vpd_Wpd, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14151 /* 0x55 */ iemOp_andnps_Vps_Wps, iemOp_andnpd_Vpd_Wpd, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14152 /* 0x56 */ iemOp_orps_Vps_Wps, iemOp_orpd_Vpd_Wpd, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14153 /* 0x57 */ iemOp_xorps_Vps_Wps, iemOp_xorpd_Vpd_Wpd, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14154 /* 0x58 */ iemOp_addps_Vps_Wps, iemOp_addpd_Vpd_Wpd, iemOp_addss_Vss_Wss, iemOp_addsd_Vsd_Wsd,
14155 /* 0x59 */ iemOp_mulps_Vps_Wps, iemOp_mulpd_Vpd_Wpd, iemOp_mulss_Vss_Wss, iemOp_mulsd_Vsd_Wsd,
14156 /* 0x5a */ iemOp_cvtps2pd_Vpd_Wps, iemOp_cvtpd2ps_Vps_Wpd, iemOp_cvtss2sd_Vsd_Wss, iemOp_cvtsd2ss_Vss_Wsd,
14157 /* 0x5b */ iemOp_cvtdq2ps_Vps_Wdq, iemOp_cvtps2dq_Vdq_Wps, iemOp_cvttps2dq_Vdq_Wps, iemOp_InvalidNeedRM,
14158 /* 0x5c */ iemOp_subps_Vps_Wps, iemOp_subpd_Vpd_Wpd, iemOp_subss_Vss_Wss, iemOp_subsd_Vsd_Wsd,
14159 /* 0x5d */ iemOp_minps_Vps_Wps, iemOp_minpd_Vpd_Wpd, iemOp_minss_Vss_Wss, iemOp_minsd_Vsd_Wsd,
14160 /* 0x5e */ iemOp_divps_Vps_Wps, iemOp_divpd_Vpd_Wpd, iemOp_divss_Vss_Wss, iemOp_divsd_Vsd_Wsd,
14161 /* 0x5f */ iemOp_maxps_Vps_Wps, iemOp_maxpd_Vpd_Wpd, iemOp_maxss_Vss_Wss, iemOp_maxsd_Vsd_Wsd,
14162
14163 /* 0x60 */ iemOp_punpcklbw_Pq_Qd, iemOp_punpcklbw_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14164 /* 0x61 */ iemOp_punpcklwd_Pq_Qd, iemOp_punpcklwd_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14165 /* 0x62 */ iemOp_punpckldq_Pq_Qd, iemOp_punpckldq_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14166 /* 0x63 */ iemOp_packsswb_Pq_Qq, iemOp_packsswb_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14167 /* 0x64 */ iemOp_pcmpgtb_Pq_Qq, iemOp_pcmpgtb_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14168 /* 0x65 */ iemOp_pcmpgtw_Pq_Qq, iemOp_pcmpgtw_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14169 /* 0x66 */ iemOp_pcmpgtd_Pq_Qq, iemOp_pcmpgtd_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14170 /* 0x67 */ iemOp_packuswb_Pq_Qq, iemOp_packuswb_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14171 /* 0x68 */ iemOp_punpckhbw_Pq_Qq, iemOp_punpckhbw_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14172 /* 0x69 */ iemOp_punpckhwd_Pq_Qq, iemOp_punpckhwd_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14173 /* 0x6a */ iemOp_punpckhdq_Pq_Qq, iemOp_punpckhdq_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14174 /* 0x6b */ iemOp_packssdw_Pq_Qd, iemOp_packssdw_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14175 /* 0x6c */ iemOp_InvalidNeedRM, iemOp_punpcklqdq_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14176 /* 0x6d */ iemOp_InvalidNeedRM, iemOp_punpckhqdq_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14177 /* 0x6e */ iemOp_movd_q_Pd_Ey, iemOp_movd_q_Vy_Ey, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14178 /* 0x6f */ iemOp_movq_Pq_Qq, iemOp_movdqa_Vdq_Wdq, iemOp_movdqu_Vdq_Wdq, iemOp_InvalidNeedRM,
14179
14180 /* 0x70 */ iemOp_pshufw_Pq_Qq_Ib, iemOp_pshufd_Vx_Wx_Ib, iemOp_pshufhw_Vx_Wx_Ib, iemOp_pshuflw_Vx_Wx_Ib,
14181 /* 0x71 */ IEMOP_X4(iemOp_Grp12),
14182 /* 0x72 */ IEMOP_X4(iemOp_Grp13),
14183 /* 0x73 */ IEMOP_X4(iemOp_Grp14),
14184 /* 0x74 */ iemOp_pcmpeqb_Pq_Qq, iemOp_pcmpeqb_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14185 /* 0x75 */ iemOp_pcmpeqw_Pq_Qq, iemOp_pcmpeqw_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14186 /* 0x76 */ iemOp_pcmpeqd_Pq_Qq, iemOp_pcmpeqd_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14187 /* 0x77 */ iemOp_emms, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14188
14189 /* 0x78 */ iemOp_vmread_Ey_Gy, iemOp_AmdGrp17, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14190 /* 0x79 */ iemOp_vmwrite_Gy_Ey, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14191 /* 0x7a */ iemOp_InvalidNeedRM, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14192 /* 0x7b */ iemOp_InvalidNeedRM, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14193 /* 0x7c */ iemOp_InvalidNeedRM, iemOp_haddpd_Vpd_Wpd, iemOp_InvalidNeedRM, iemOp_haddps_Vps_Wps,
14194 /* 0x7d */ iemOp_InvalidNeedRM, iemOp_hsubpd_Vpd_Wpd, iemOp_InvalidNeedRM, iemOp_hsubps_Vps_Wps,
14195 /* 0x7e */ iemOp_movd_q_Ey_Pd, iemOp_movd_q_Ey_Vy, iemOp_movq_Vq_Wq, iemOp_InvalidNeedRM,
14196 /* 0x7f */ iemOp_movq_Qq_Pq, iemOp_movdqa_Wx_Vx, iemOp_movdqu_Wx_Vx, iemOp_InvalidNeedRM,
14197
14198 /* 0x80 */ IEMOP_X4(iemOp_jo_Jv),
14199 /* 0x81 */ IEMOP_X4(iemOp_jno_Jv),
14200 /* 0x82 */ IEMOP_X4(iemOp_jc_Jv),
14201 /* 0x83 */ IEMOP_X4(iemOp_jnc_Jv),
14202 /* 0x84 */ IEMOP_X4(iemOp_je_Jv),
14203 /* 0x85 */ IEMOP_X4(iemOp_jne_Jv),
14204 /* 0x86 */ IEMOP_X4(iemOp_jbe_Jv),
14205 /* 0x87 */ IEMOP_X4(iemOp_jnbe_Jv),
14206 /* 0x88 */ IEMOP_X4(iemOp_js_Jv),
14207 /* 0x89 */ IEMOP_X4(iemOp_jns_Jv),
14208 /* 0x8a */ IEMOP_X4(iemOp_jp_Jv),
14209 /* 0x8b */ IEMOP_X4(iemOp_jnp_Jv),
14210 /* 0x8c */ IEMOP_X4(iemOp_jl_Jv),
14211 /* 0x8d */ IEMOP_X4(iemOp_jnl_Jv),
14212 /* 0x8e */ IEMOP_X4(iemOp_jle_Jv),
14213 /* 0x8f */ IEMOP_X4(iemOp_jnle_Jv),
14214
14215 /* 0x90 */ IEMOP_X4(iemOp_seto_Eb),
14216 /* 0x91 */ IEMOP_X4(iemOp_setno_Eb),
14217 /* 0x92 */ IEMOP_X4(iemOp_setc_Eb),
14218 /* 0x93 */ IEMOP_X4(iemOp_setnc_Eb),
14219 /* 0x94 */ IEMOP_X4(iemOp_sete_Eb),
14220 /* 0x95 */ IEMOP_X4(iemOp_setne_Eb),
14221 /* 0x96 */ IEMOP_X4(iemOp_setbe_Eb),
14222 /* 0x97 */ IEMOP_X4(iemOp_setnbe_Eb),
14223 /* 0x98 */ IEMOP_X4(iemOp_sets_Eb),
14224 /* 0x99 */ IEMOP_X4(iemOp_setns_Eb),
14225 /* 0x9a */ IEMOP_X4(iemOp_setp_Eb),
14226 /* 0x9b */ IEMOP_X4(iemOp_setnp_Eb),
14227 /* 0x9c */ IEMOP_X4(iemOp_setl_Eb),
14228 /* 0x9d */ IEMOP_X4(iemOp_setnl_Eb),
14229 /* 0x9e */ IEMOP_X4(iemOp_setle_Eb),
14230 /* 0x9f */ IEMOP_X4(iemOp_setnle_Eb),
14231
14232 /* 0xa0 */ IEMOP_X4(iemOp_push_fs),
14233 /* 0xa1 */ IEMOP_X4(iemOp_pop_fs),
14234 /* 0xa2 */ IEMOP_X4(iemOp_cpuid),
14235 /* 0xa3 */ IEMOP_X4(iemOp_bt_Ev_Gv),
14236 /* 0xa4 */ IEMOP_X4(iemOp_shld_Ev_Gv_Ib),
14237 /* 0xa5 */ IEMOP_X4(iemOp_shld_Ev_Gv_CL),
14238 /* 0xa6 */ IEMOP_X4(iemOp_InvalidNeedRM),
14239 /* 0xa7 */ IEMOP_X4(iemOp_InvalidNeedRM),
14240 /* 0xa8 */ IEMOP_X4(iemOp_push_gs),
14241 /* 0xa9 */ IEMOP_X4(iemOp_pop_gs),
14242 /* 0xaa */ IEMOP_X4(iemOp_rsm),
14243 /* 0xab */ IEMOP_X4(iemOp_bts_Ev_Gv),
14244 /* 0xac */ IEMOP_X4(iemOp_shrd_Ev_Gv_Ib),
14245 /* 0xad */ IEMOP_X4(iemOp_shrd_Ev_Gv_CL),
14246 /* 0xae */ IEMOP_X4(iemOp_Grp15),
14247 /* 0xaf */ IEMOP_X4(iemOp_imul_Gv_Ev),
14248
14249 /* 0xb0 */ IEMOP_X4(iemOp_cmpxchg_Eb_Gb),
14250 /* 0xb1 */ IEMOP_X4(iemOp_cmpxchg_Ev_Gv),
14251 /* 0xb2 */ IEMOP_X4(iemOp_lss_Gv_Mp),
14252 /* 0xb3 */ IEMOP_X4(iemOp_btr_Ev_Gv),
14253 /* 0xb4 */ IEMOP_X4(iemOp_lfs_Gv_Mp),
14254 /* 0xb5 */ IEMOP_X4(iemOp_lgs_Gv_Mp),
14255 /* 0xb6 */ IEMOP_X4(iemOp_movzx_Gv_Eb),
14256 /* 0xb7 */ IEMOP_X4(iemOp_movzx_Gv_Ew),
14257 /* 0xb8 */ iemOp_jmpe, iemOp_InvalidNeedRM, iemOp_popcnt_Gv_Ev, iemOp_InvalidNeedRM,
14258 /* 0xb9 */ IEMOP_X4(iemOp_Grp10),
14259 /* 0xba */ IEMOP_X4(iemOp_Grp8),
14260 /* 0xbb */ IEMOP_X4(iemOp_btc_Ev_Gv), // 0xf3?
14261 /* 0xbc */ iemOp_bsf_Gv_Ev, iemOp_bsf_Gv_Ev, iemOp_tzcnt_Gv_Ev, iemOp_bsf_Gv_Ev,
14262 /* 0xbd */ iemOp_bsr_Gv_Ev, iemOp_bsr_Gv_Ev, iemOp_lzcnt_Gv_Ev, iemOp_bsr_Gv_Ev,
14263 /* 0xbe */ IEMOP_X4(iemOp_movsx_Gv_Eb),
14264 /* 0xbf */ IEMOP_X4(iemOp_movsx_Gv_Ew),
14265
14266 /* 0xc0 */ IEMOP_X4(iemOp_xadd_Eb_Gb),
14267 /* 0xc1 */ IEMOP_X4(iemOp_xadd_Ev_Gv),
14268 /* 0xc2 */ iemOp_cmpps_Vps_Wps_Ib, iemOp_cmppd_Vpd_Wpd_Ib, iemOp_cmpss_Vss_Wss_Ib, iemOp_cmpsd_Vsd_Wsd_Ib,
14269 /* 0xc3 */ iemOp_movnti_My_Gy, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14270 /* 0xc4 */ iemOp_pinsrw_Pq_RyMw_Ib, iemOp_pinsrw_Vdq_RyMw_Ib, iemOp_InvalidNeedRMImm8, iemOp_InvalidNeedRMImm8,
14271 /* 0xc5 */ iemOp_pextrw_Gd_Nq_Ib, iemOp_pextrw_Gd_Udq_Ib, iemOp_InvalidNeedRMImm8, iemOp_InvalidNeedRMImm8,
14272 /* 0xc6 */ iemOp_shufps_Vps_Wps_Ib, iemOp_shufpd_Vpd_Wpd_Ib, iemOp_InvalidNeedRMImm8, iemOp_InvalidNeedRMImm8,
14273 /* 0xc7 */ IEMOP_X4(iemOp_Grp9),
14274 /* 0xc8 */ IEMOP_X4(iemOp_bswap_rAX_r8),
14275 /* 0xc9 */ IEMOP_X4(iemOp_bswap_rCX_r9),
14276 /* 0xca */ IEMOP_X4(iemOp_bswap_rDX_r10),
14277 /* 0xcb */ IEMOP_X4(iemOp_bswap_rBX_r11),
14278 /* 0xcc */ IEMOP_X4(iemOp_bswap_rSP_r12),
14279 /* 0xcd */ IEMOP_X4(iemOp_bswap_rBP_r13),
14280 /* 0xce */ IEMOP_X4(iemOp_bswap_rSI_r14),
14281 /* 0xcf */ IEMOP_X4(iemOp_bswap_rDI_r15),
14282
14283 /* 0xd0 */ iemOp_InvalidNeedRM, iemOp_addsubpd_Vpd_Wpd, iemOp_InvalidNeedRM, iemOp_addsubps_Vps_Wps,
14284 /* 0xd1 */ iemOp_psrlw_Pq_Qq, iemOp_psrlw_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14285 /* 0xd2 */ iemOp_psrld_Pq_Qq, iemOp_psrld_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14286 /* 0xd3 */ iemOp_psrlq_Pq_Qq, iemOp_psrlq_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14287 /* 0xd4 */ iemOp_paddq_Pq_Qq, iemOp_paddq_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14288 /* 0xd5 */ iemOp_pmullw_Pq_Qq, iemOp_pmullw_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14289 /* 0xd6 */ iemOp_InvalidNeedRM, iemOp_movq_Wq_Vq, iemOp_movq2dq_Vdq_Nq, iemOp_movdq2q_Pq_Uq,
14290 /* 0xd7 */ iemOp_pmovmskb_Gd_Nq, iemOp_pmovmskb_Gd_Ux, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14291 /* 0xd8 */ iemOp_psubusb_Pq_Qq, iemOp_psubusb_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14292 /* 0xd9 */ iemOp_psubusw_Pq_Qq, iemOp_psubusw_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14293 /* 0xda */ iemOp_pminub_Pq_Qq, iemOp_pminub_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14294 /* 0xdb */ iemOp_pand_Pq_Qq, iemOp_pand_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14295 /* 0xdc */ iemOp_paddusb_Pq_Qq, iemOp_paddusb_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14296 /* 0xdd */ iemOp_paddusw_Pq_Qq, iemOp_paddusw_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14297 /* 0xde */ iemOp_pmaxub_Pq_Qq, iemOp_pmaxub_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14298 /* 0xdf */ iemOp_pandn_Pq_Qq, iemOp_pandn_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14299
14300 /* 0xe0 */ iemOp_pavgb_Pq_Qq, iemOp_pavgb_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14301 /* 0xe1 */ iemOp_psraw_Pq_Qq, iemOp_psraw_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14302 /* 0xe2 */ iemOp_psrad_Pq_Qq, iemOp_psrad_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14303 /* 0xe3 */ iemOp_pavgw_Pq_Qq, iemOp_pavgw_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14304 /* 0xe4 */ iemOp_pmulhuw_Pq_Qq, iemOp_pmulhuw_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14305 /* 0xe5 */ iemOp_pmulhw_Pq_Qq, iemOp_pmulhw_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14306 /* 0xe6 */ iemOp_InvalidNeedRM, iemOp_cvttpd2dq_Vx_Wpd, iemOp_cvtdq2pd_Vx_Wpd, iemOp_cvtpd2dq_Vx_Wpd,
14307 /* 0xe7 */ iemOp_movntq_Mq_Pq, iemOp_movntdq_Mdq_Vdq, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14308 /* 0xe8 */ iemOp_psubsb_Pq_Qq, iemOp_psubsb_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14309 /* 0xe9 */ iemOp_psubsw_Pq_Qq, iemOp_psubsw_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14310 /* 0xea */ iemOp_pminsw_Pq_Qq, iemOp_pminsw_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14311 /* 0xeb */ iemOp_por_Pq_Qq, iemOp_por_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14312 /* 0xec */ iemOp_paddsb_Pq_Qq, iemOp_paddsb_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14313 /* 0xed */ iemOp_paddsw_Pq_Qq, iemOp_paddsw_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14314 /* 0xee */ iemOp_pmaxsw_Pq_Qq, iemOp_pmaxsw_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14315 /* 0xef */ iemOp_pxor_Pq_Qq, iemOp_pxor_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14316
14317 /* 0xf0 */ iemOp_InvalidNeedRM, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM, iemOp_lddqu_Vx_Mx,
14318 /* 0xf1 */ iemOp_psllw_Pq_Qq, iemOp_psllw_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14319 /* 0xf2 */ iemOp_pslld_Pq_Qq, iemOp_pslld_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14320 /* 0xf3 */ iemOp_psllq_Pq_Qq, iemOp_psllq_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14321 /* 0xf4 */ iemOp_pmuludq_Pq_Qq, iemOp_pmuludq_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14322 /* 0xf5 */ iemOp_pmaddwd_Pq_Qq, iemOp_pmaddwd_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14323 /* 0xf6 */ iemOp_psadbw_Pq_Qq, iemOp_psadbw_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14324 /* 0xf7 */ iemOp_maskmovq_Pq_Nq, iemOp_maskmovdqu_Vdq_Udq, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14325 /* 0xf8 */ iemOp_psubb_Pq_Qq, iemOp_psubb_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14326 /* 0xf9 */ iemOp_psubw_Pq_Qq, iemOp_psubw_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14327 /* 0xfa */ iemOp_psubd_Pq_Qq, iemOp_psubd_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14328 /* 0xfb */ iemOp_psubq_Pq_Qq, iemOp_psubq_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14329 /* 0xfc */ iemOp_paddb_Pq_Qq, iemOp_paddb_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14330 /* 0xfd */ iemOp_paddw_Pq_Qq, iemOp_paddw_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14331 /* 0xfe */ iemOp_paddd_Pq_Qq, iemOp_paddd_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
14332 /* 0xff */ IEMOP_X4(iemOp_ud0),
14333};
14334AssertCompile(RT_ELEMENTS(g_apfnTwoByteMap) == 1024);
14335
14336/** @} */
14337
Note: See TracBrowser for help on using the repository browser.

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