VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMAll/IEMAllAImplC.cpp@ 93881

Last change on this file since 93881 was 93881, checked in by vboxsync, 3 years ago

VMM/IEM: doxygen fix. bugref:9898

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 110.7 KB
Line 
1/* $Id: IEMAllAImplC.cpp 93881 2022-02-22 09:09:52Z vboxsync $ */
2/** @file
3 * IEM - Instruction Implementation in Assembly, portable C variant.
4 */
5
6/*
7 * Copyright (C) 2011-2022 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18
19/*********************************************************************************************************************************
20* Header Files *
21*********************************************************************************************************************************/
22#include "IEMInternal.h"
23#include <VBox/vmm/vmcc.h>
24#include <iprt/errcore.h>
25#include <iprt/x86.h>
26#include <iprt/uint128.h>
27
28
29/*********************************************************************************************************************************
30* Defined Constants And Macros *
31*********************************************************************************************************************************/
32/** @def IEM_WITHOUT_ASSEMBLY
33 * Enables all the code in this file.
34 */
35#if !defined(IEM_WITHOUT_ASSEMBLY)
36# if defined(RT_ARCH_ARM32) || defined(RT_ARCH_ARM64) || defined(DOXYGEN_RUNNING)
37# define IEM_WITHOUT_ASSEMBLY
38# endif
39#endif
40/* IEM_WITH_ASSEMBLY trumps IEM_WITHOUT_ASSEMBLY for tstIEMAImplAsm purposes. */
41#ifdef IEM_WITH_ASSEMBLY
42# undef IEM_WITHOUT_ASSEMBLY
43#endif
44
45/**
46 * Calculates the signed flag value given a result and it's bit width.
47 *
48 * The signed flag (SF) is a duplication of the most significant bit in the
49 * result.
50 *
51 * @returns X86_EFL_SF or 0.
52 * @param a_uResult Unsigned result value.
53 * @param a_cBitsWidth The width of the result (8, 16, 32, 64).
54 */
55#define X86_EFL_CALC_SF(a_uResult, a_cBitsWidth) \
56 ( (uint32_t)((a_uResult) >> ((a_cBitsWidth) - X86_EFL_SF_BIT - 1)) & X86_EFL_SF )
57
58/**
59 * Calculates the zero flag value given a result.
60 *
61 * The zero flag (ZF) indicates whether the result is zero or not.
62 *
63 * @returns X86_EFL_ZF or 0.
64 * @param a_uResult Unsigned result value.
65 */
66#define X86_EFL_CALC_ZF(a_uResult) \
67 ( (uint32_t)((a_uResult) == 0) << X86_EFL_ZF_BIT )
68
69/**
70 * Extracts the OF flag from a OF calculation result.
71 *
72 * These are typically used by concating with a bitcount. The problem is that
73 * 8-bit values needs shifting in the other direction than the others.
74 */
75#define X86_EFL_GET_OF_8(a_uValue) (((uint32_t)(a_uValue) << (X86_EFL_OF_BIT - 8 + 1)) & X86_EFL_OF)
76#define X86_EFL_GET_OF_16(a_uValue) ((uint32_t)((a_uValue) >> (16 - X86_EFL_OF_BIT - 1)) & X86_EFL_OF)
77#define X86_EFL_GET_OF_32(a_uValue) ((uint32_t)((a_uValue) >> (32 - X86_EFL_OF_BIT - 1)) & X86_EFL_OF)
78#define X86_EFL_GET_OF_64(a_uValue) ((uint32_t)((a_uValue) >> (64 - X86_EFL_OF_BIT - 1)) & X86_EFL_OF)
79
80/**
81 * Updates the status bits (CF, PF, AF, ZF, SF, and OF) after arithmetic op.
82 *
83 * @returns Status bits.
84 * @param a_pfEFlags Pointer to the 32-bit EFLAGS value to update.
85 * @param a_uResult Unsigned result value.
86 * @param a_uSrc The source value (for AF calc).
87 * @param a_uDst The original destination value (for AF calc).
88 * @param a_cBitsWidth The width of the result (8, 16, 32, 64).
89 * @param a_CfExpr Bool expression for the carry flag (CF).
90 * @param a_uSrcOf The a_uSrc value to use for overflow calculation.
91 */
92#define IEM_EFL_UPDATE_STATUS_BITS_FOR_ARITHMETIC(a_pfEFlags, a_uResult, a_uDst, a_uSrc, a_cBitsWidth, a_CfExpr, a_uSrcOf) \
93 do { \
94 uint32_t fEflTmp = *(a_pfEFlags); \
95 fEflTmp &= ~X86_EFL_STATUS_BITS; \
96 fEflTmp |= (a_CfExpr) << X86_EFL_CF_BIT; \
97 fEflTmp |= g_afParity[(a_uResult) & 0xff]; \
98 fEflTmp |= ((uint32_t)(a_uResult) ^ (uint32_t)(a_uSrc) ^ (uint32_t)(a_uDst)) & X86_EFL_AF; \
99 fEflTmp |= X86_EFL_CALC_ZF(a_uResult); \
100 fEflTmp |= X86_EFL_CALC_SF(a_uResult, a_cBitsWidth); \
101 \
102 /* Overflow during ADDition happens when both inputs have the same signed \
103 bit value and the result has a different sign bit value. \
104 \
105 Since subtraction can be rewritten as addition: 2 - 1 == 2 + -1, it \
106 follows that for SUBtraction the signed bit value must differ between \
107 the two inputs and the result's signed bit diff from the first input. \
108 Note! Must xor with sign bit to convert, not do (0 - a_uSrc). \
109 \
110 See also: http://teaching.idallen.com/dat2343/10f/notes/040_overflow.txt */ \
111 fEflTmp |= X86_EFL_GET_OF_ ## a_cBitsWidth( ( ((uint ## a_cBitsWidth ## _t)~((a_uDst) ^ (a_uSrcOf))) \
112 & RT_BIT_64(a_cBitsWidth - 1)) \
113 & ((a_uResult) ^ (a_uDst)) ); \
114 *(a_pfEFlags) = fEflTmp; \
115 } while (0)
116
117/**
118 * Updates the status bits (CF, PF, AF, ZF, SF, and OF) after a logical op.
119 *
120 * CF and OF are defined to be 0 by logical operations. AF on the other hand is
121 * undefined. We do not set AF, as that seems to make the most sense (which
122 * probably makes it the most wrong in real life).
123 *
124 * @returns Status bits.
125 * @param a_pfEFlags Pointer to the 32-bit EFLAGS value to update.
126 * @param a_uResult Unsigned result value.
127 * @param a_cBitsWidth The width of the result (8, 16, 32, 64).
128 * @param a_fExtra Additional bits to set.
129 */
130#define IEM_EFL_UPDATE_STATUS_BITS_FOR_LOGIC(a_pfEFlags, a_uResult, a_cBitsWidth, a_fExtra) \
131 do { \
132 uint32_t fEflTmp = *(a_pfEFlags); \
133 fEflTmp &= ~X86_EFL_STATUS_BITS; \
134 fEflTmp |= g_afParity[(a_uResult) & 0xff]; \
135 fEflTmp |= X86_EFL_CALC_ZF(a_uResult); \
136 fEflTmp |= X86_EFL_CALC_SF(a_uResult, a_cBitsWidth); \
137 fEflTmp |= (a_fExtra); \
138 *(a_pfEFlags) = fEflTmp; \
139 } while (0)
140
141
142/*********************************************************************************************************************************
143* Global Variables *
144*********************************************************************************************************************************/
145#if !defined(RT_ARCH_AMD64) || defined(IEM_WITHOUT_ASSEMBLY)
146/**
147 * Parity calculation table.
148 *
149 * The generator code:
150 * @code
151 * #include <stdio.h>
152 *
153 * int main()
154 * {
155 * unsigned b;
156 * for (b = 0; b < 256; b++)
157 * {
158 * int cOnes = ( b & 1)
159 * + ((b >> 1) & 1)
160 * + ((b >> 2) & 1)
161 * + ((b >> 3) & 1)
162 * + ((b >> 4) & 1)
163 * + ((b >> 5) & 1)
164 * + ((b >> 6) & 1)
165 * + ((b >> 7) & 1);
166 * printf(" /" "* %#04x = %u%u%u%u%u%u%u%ub *" "/ %s,\n",
167 * b,
168 * (b >> 7) & 1,
169 * (b >> 6) & 1,
170 * (b >> 5) & 1,
171 * (b >> 4) & 1,
172 * (b >> 3) & 1,
173 * (b >> 2) & 1,
174 * (b >> 1) & 1,
175 * b & 1,
176 * cOnes & 1 ? "0" : "X86_EFL_PF");
177 * }
178 * return 0;
179 * }
180 * @endcode
181 */
182static uint8_t const g_afParity[256] =
183{
184 /* 0000 = 00000000b */ X86_EFL_PF,
185 /* 0x01 = 00000001b */ 0,
186 /* 0x02 = 00000010b */ 0,
187 /* 0x03 = 00000011b */ X86_EFL_PF,
188 /* 0x04 = 00000100b */ 0,
189 /* 0x05 = 00000101b */ X86_EFL_PF,
190 /* 0x06 = 00000110b */ X86_EFL_PF,
191 /* 0x07 = 00000111b */ 0,
192 /* 0x08 = 00001000b */ 0,
193 /* 0x09 = 00001001b */ X86_EFL_PF,
194 /* 0x0a = 00001010b */ X86_EFL_PF,
195 /* 0x0b = 00001011b */ 0,
196 /* 0x0c = 00001100b */ X86_EFL_PF,
197 /* 0x0d = 00001101b */ 0,
198 /* 0x0e = 00001110b */ 0,
199 /* 0x0f = 00001111b */ X86_EFL_PF,
200 /* 0x10 = 00010000b */ 0,
201 /* 0x11 = 00010001b */ X86_EFL_PF,
202 /* 0x12 = 00010010b */ X86_EFL_PF,
203 /* 0x13 = 00010011b */ 0,
204 /* 0x14 = 00010100b */ X86_EFL_PF,
205 /* 0x15 = 00010101b */ 0,
206 /* 0x16 = 00010110b */ 0,
207 /* 0x17 = 00010111b */ X86_EFL_PF,
208 /* 0x18 = 00011000b */ X86_EFL_PF,
209 /* 0x19 = 00011001b */ 0,
210 /* 0x1a = 00011010b */ 0,
211 /* 0x1b = 00011011b */ X86_EFL_PF,
212 /* 0x1c = 00011100b */ 0,
213 /* 0x1d = 00011101b */ X86_EFL_PF,
214 /* 0x1e = 00011110b */ X86_EFL_PF,
215 /* 0x1f = 00011111b */ 0,
216 /* 0x20 = 00100000b */ 0,
217 /* 0x21 = 00100001b */ X86_EFL_PF,
218 /* 0x22 = 00100010b */ X86_EFL_PF,
219 /* 0x23 = 00100011b */ 0,
220 /* 0x24 = 00100100b */ X86_EFL_PF,
221 /* 0x25 = 00100101b */ 0,
222 /* 0x26 = 00100110b */ 0,
223 /* 0x27 = 00100111b */ X86_EFL_PF,
224 /* 0x28 = 00101000b */ X86_EFL_PF,
225 /* 0x29 = 00101001b */ 0,
226 /* 0x2a = 00101010b */ 0,
227 /* 0x2b = 00101011b */ X86_EFL_PF,
228 /* 0x2c = 00101100b */ 0,
229 /* 0x2d = 00101101b */ X86_EFL_PF,
230 /* 0x2e = 00101110b */ X86_EFL_PF,
231 /* 0x2f = 00101111b */ 0,
232 /* 0x30 = 00110000b */ X86_EFL_PF,
233 /* 0x31 = 00110001b */ 0,
234 /* 0x32 = 00110010b */ 0,
235 /* 0x33 = 00110011b */ X86_EFL_PF,
236 /* 0x34 = 00110100b */ 0,
237 /* 0x35 = 00110101b */ X86_EFL_PF,
238 /* 0x36 = 00110110b */ X86_EFL_PF,
239 /* 0x37 = 00110111b */ 0,
240 /* 0x38 = 00111000b */ 0,
241 /* 0x39 = 00111001b */ X86_EFL_PF,
242 /* 0x3a = 00111010b */ X86_EFL_PF,
243 /* 0x3b = 00111011b */ 0,
244 /* 0x3c = 00111100b */ X86_EFL_PF,
245 /* 0x3d = 00111101b */ 0,
246 /* 0x3e = 00111110b */ 0,
247 /* 0x3f = 00111111b */ X86_EFL_PF,
248 /* 0x40 = 01000000b */ 0,
249 /* 0x41 = 01000001b */ X86_EFL_PF,
250 /* 0x42 = 01000010b */ X86_EFL_PF,
251 /* 0x43 = 01000011b */ 0,
252 /* 0x44 = 01000100b */ X86_EFL_PF,
253 /* 0x45 = 01000101b */ 0,
254 /* 0x46 = 01000110b */ 0,
255 /* 0x47 = 01000111b */ X86_EFL_PF,
256 /* 0x48 = 01001000b */ X86_EFL_PF,
257 /* 0x49 = 01001001b */ 0,
258 /* 0x4a = 01001010b */ 0,
259 /* 0x4b = 01001011b */ X86_EFL_PF,
260 /* 0x4c = 01001100b */ 0,
261 /* 0x4d = 01001101b */ X86_EFL_PF,
262 /* 0x4e = 01001110b */ X86_EFL_PF,
263 /* 0x4f = 01001111b */ 0,
264 /* 0x50 = 01010000b */ X86_EFL_PF,
265 /* 0x51 = 01010001b */ 0,
266 /* 0x52 = 01010010b */ 0,
267 /* 0x53 = 01010011b */ X86_EFL_PF,
268 /* 0x54 = 01010100b */ 0,
269 /* 0x55 = 01010101b */ X86_EFL_PF,
270 /* 0x56 = 01010110b */ X86_EFL_PF,
271 /* 0x57 = 01010111b */ 0,
272 /* 0x58 = 01011000b */ 0,
273 /* 0x59 = 01011001b */ X86_EFL_PF,
274 /* 0x5a = 01011010b */ X86_EFL_PF,
275 /* 0x5b = 01011011b */ 0,
276 /* 0x5c = 01011100b */ X86_EFL_PF,
277 /* 0x5d = 01011101b */ 0,
278 /* 0x5e = 01011110b */ 0,
279 /* 0x5f = 01011111b */ X86_EFL_PF,
280 /* 0x60 = 01100000b */ X86_EFL_PF,
281 /* 0x61 = 01100001b */ 0,
282 /* 0x62 = 01100010b */ 0,
283 /* 0x63 = 01100011b */ X86_EFL_PF,
284 /* 0x64 = 01100100b */ 0,
285 /* 0x65 = 01100101b */ X86_EFL_PF,
286 /* 0x66 = 01100110b */ X86_EFL_PF,
287 /* 0x67 = 01100111b */ 0,
288 /* 0x68 = 01101000b */ 0,
289 /* 0x69 = 01101001b */ X86_EFL_PF,
290 /* 0x6a = 01101010b */ X86_EFL_PF,
291 /* 0x6b = 01101011b */ 0,
292 /* 0x6c = 01101100b */ X86_EFL_PF,
293 /* 0x6d = 01101101b */ 0,
294 /* 0x6e = 01101110b */ 0,
295 /* 0x6f = 01101111b */ X86_EFL_PF,
296 /* 0x70 = 01110000b */ 0,
297 /* 0x71 = 01110001b */ X86_EFL_PF,
298 /* 0x72 = 01110010b */ X86_EFL_PF,
299 /* 0x73 = 01110011b */ 0,
300 /* 0x74 = 01110100b */ X86_EFL_PF,
301 /* 0x75 = 01110101b */ 0,
302 /* 0x76 = 01110110b */ 0,
303 /* 0x77 = 01110111b */ X86_EFL_PF,
304 /* 0x78 = 01111000b */ X86_EFL_PF,
305 /* 0x79 = 01111001b */ 0,
306 /* 0x7a = 01111010b */ 0,
307 /* 0x7b = 01111011b */ X86_EFL_PF,
308 /* 0x7c = 01111100b */ 0,
309 /* 0x7d = 01111101b */ X86_EFL_PF,
310 /* 0x7e = 01111110b */ X86_EFL_PF,
311 /* 0x7f = 01111111b */ 0,
312 /* 0x80 = 10000000b */ 0,
313 /* 0x81 = 10000001b */ X86_EFL_PF,
314 /* 0x82 = 10000010b */ X86_EFL_PF,
315 /* 0x83 = 10000011b */ 0,
316 /* 0x84 = 10000100b */ X86_EFL_PF,
317 /* 0x85 = 10000101b */ 0,
318 /* 0x86 = 10000110b */ 0,
319 /* 0x87 = 10000111b */ X86_EFL_PF,
320 /* 0x88 = 10001000b */ X86_EFL_PF,
321 /* 0x89 = 10001001b */ 0,
322 /* 0x8a = 10001010b */ 0,
323 /* 0x8b = 10001011b */ X86_EFL_PF,
324 /* 0x8c = 10001100b */ 0,
325 /* 0x8d = 10001101b */ X86_EFL_PF,
326 /* 0x8e = 10001110b */ X86_EFL_PF,
327 /* 0x8f = 10001111b */ 0,
328 /* 0x90 = 10010000b */ X86_EFL_PF,
329 /* 0x91 = 10010001b */ 0,
330 /* 0x92 = 10010010b */ 0,
331 /* 0x93 = 10010011b */ X86_EFL_PF,
332 /* 0x94 = 10010100b */ 0,
333 /* 0x95 = 10010101b */ X86_EFL_PF,
334 /* 0x96 = 10010110b */ X86_EFL_PF,
335 /* 0x97 = 10010111b */ 0,
336 /* 0x98 = 10011000b */ 0,
337 /* 0x99 = 10011001b */ X86_EFL_PF,
338 /* 0x9a = 10011010b */ X86_EFL_PF,
339 /* 0x9b = 10011011b */ 0,
340 /* 0x9c = 10011100b */ X86_EFL_PF,
341 /* 0x9d = 10011101b */ 0,
342 /* 0x9e = 10011110b */ 0,
343 /* 0x9f = 10011111b */ X86_EFL_PF,
344 /* 0xa0 = 10100000b */ X86_EFL_PF,
345 /* 0xa1 = 10100001b */ 0,
346 /* 0xa2 = 10100010b */ 0,
347 /* 0xa3 = 10100011b */ X86_EFL_PF,
348 /* 0xa4 = 10100100b */ 0,
349 /* 0xa5 = 10100101b */ X86_EFL_PF,
350 /* 0xa6 = 10100110b */ X86_EFL_PF,
351 /* 0xa7 = 10100111b */ 0,
352 /* 0xa8 = 10101000b */ 0,
353 /* 0xa9 = 10101001b */ X86_EFL_PF,
354 /* 0xaa = 10101010b */ X86_EFL_PF,
355 /* 0xab = 10101011b */ 0,
356 /* 0xac = 10101100b */ X86_EFL_PF,
357 /* 0xad = 10101101b */ 0,
358 /* 0xae = 10101110b */ 0,
359 /* 0xaf = 10101111b */ X86_EFL_PF,
360 /* 0xb0 = 10110000b */ 0,
361 /* 0xb1 = 10110001b */ X86_EFL_PF,
362 /* 0xb2 = 10110010b */ X86_EFL_PF,
363 /* 0xb3 = 10110011b */ 0,
364 /* 0xb4 = 10110100b */ X86_EFL_PF,
365 /* 0xb5 = 10110101b */ 0,
366 /* 0xb6 = 10110110b */ 0,
367 /* 0xb7 = 10110111b */ X86_EFL_PF,
368 /* 0xb8 = 10111000b */ X86_EFL_PF,
369 /* 0xb9 = 10111001b */ 0,
370 /* 0xba = 10111010b */ 0,
371 /* 0xbb = 10111011b */ X86_EFL_PF,
372 /* 0xbc = 10111100b */ 0,
373 /* 0xbd = 10111101b */ X86_EFL_PF,
374 /* 0xbe = 10111110b */ X86_EFL_PF,
375 /* 0xbf = 10111111b */ 0,
376 /* 0xc0 = 11000000b */ X86_EFL_PF,
377 /* 0xc1 = 11000001b */ 0,
378 /* 0xc2 = 11000010b */ 0,
379 /* 0xc3 = 11000011b */ X86_EFL_PF,
380 /* 0xc4 = 11000100b */ 0,
381 /* 0xc5 = 11000101b */ X86_EFL_PF,
382 /* 0xc6 = 11000110b */ X86_EFL_PF,
383 /* 0xc7 = 11000111b */ 0,
384 /* 0xc8 = 11001000b */ 0,
385 /* 0xc9 = 11001001b */ X86_EFL_PF,
386 /* 0xca = 11001010b */ X86_EFL_PF,
387 /* 0xcb = 11001011b */ 0,
388 /* 0xcc = 11001100b */ X86_EFL_PF,
389 /* 0xcd = 11001101b */ 0,
390 /* 0xce = 11001110b */ 0,
391 /* 0xcf = 11001111b */ X86_EFL_PF,
392 /* 0xd0 = 11010000b */ 0,
393 /* 0xd1 = 11010001b */ X86_EFL_PF,
394 /* 0xd2 = 11010010b */ X86_EFL_PF,
395 /* 0xd3 = 11010011b */ 0,
396 /* 0xd4 = 11010100b */ X86_EFL_PF,
397 /* 0xd5 = 11010101b */ 0,
398 /* 0xd6 = 11010110b */ 0,
399 /* 0xd7 = 11010111b */ X86_EFL_PF,
400 /* 0xd8 = 11011000b */ X86_EFL_PF,
401 /* 0xd9 = 11011001b */ 0,
402 /* 0xda = 11011010b */ 0,
403 /* 0xdb = 11011011b */ X86_EFL_PF,
404 /* 0xdc = 11011100b */ 0,
405 /* 0xdd = 11011101b */ X86_EFL_PF,
406 /* 0xde = 11011110b */ X86_EFL_PF,
407 /* 0xdf = 11011111b */ 0,
408 /* 0xe0 = 11100000b */ 0,
409 /* 0xe1 = 11100001b */ X86_EFL_PF,
410 /* 0xe2 = 11100010b */ X86_EFL_PF,
411 /* 0xe3 = 11100011b */ 0,
412 /* 0xe4 = 11100100b */ X86_EFL_PF,
413 /* 0xe5 = 11100101b */ 0,
414 /* 0xe6 = 11100110b */ 0,
415 /* 0xe7 = 11100111b */ X86_EFL_PF,
416 /* 0xe8 = 11101000b */ X86_EFL_PF,
417 /* 0xe9 = 11101001b */ 0,
418 /* 0xea = 11101010b */ 0,
419 /* 0xeb = 11101011b */ X86_EFL_PF,
420 /* 0xec = 11101100b */ 0,
421 /* 0xed = 11101101b */ X86_EFL_PF,
422 /* 0xee = 11101110b */ X86_EFL_PF,
423 /* 0xef = 11101111b */ 0,
424 /* 0xf0 = 11110000b */ X86_EFL_PF,
425 /* 0xf1 = 11110001b */ 0,
426 /* 0xf2 = 11110010b */ 0,
427 /* 0xf3 = 11110011b */ X86_EFL_PF,
428 /* 0xf4 = 11110100b */ 0,
429 /* 0xf5 = 11110101b */ X86_EFL_PF,
430 /* 0xf6 = 11110110b */ X86_EFL_PF,
431 /* 0xf7 = 11110111b */ 0,
432 /* 0xf8 = 11111000b */ 0,
433 /* 0xf9 = 11111001b */ X86_EFL_PF,
434 /* 0xfa = 11111010b */ X86_EFL_PF,
435 /* 0xfb = 11111011b */ 0,
436 /* 0xfc = 11111100b */ X86_EFL_PF,
437 /* 0xfd = 11111101b */ 0,
438 /* 0xfe = 11111110b */ 0,
439 /* 0xff = 11111111b */ X86_EFL_PF,
440};
441#endif /* !RT_ARCH_AMD64 || IEM_WITHOUT_ASSEMBLY */
442
443
444
445/*
446 * There are a few 64-bit on 32-bit things we'd rather do in C. Actually, doing
447 * it all in C is probably safer atm., optimize what's necessary later, maybe.
448 */
449#if !defined(RT_ARCH_AMD64) || defined(IEM_WITHOUT_ASSEMBLY)
450
451
452/*********************************************************************************************************************************
453* Binary Operations *
454*********************************************************************************************************************************/
455
456/*
457 * ADD
458 */
459
460IEM_DECL_IMPL_DEF(void, iemAImpl_add_u64,(uint64_t *puDst, uint64_t uSrc, uint32_t *pfEFlags))
461{
462 uint64_t uDst = *puDst;
463 uint64_t uResult = uDst + uSrc;
464 *puDst = uResult;
465 IEM_EFL_UPDATE_STATUS_BITS_FOR_ARITHMETIC(pfEFlags, uResult, uDst, uSrc, 64, uResult < uDst, uSrc);
466}
467
468# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
469
470IEM_DECL_IMPL_DEF(void, iemAImpl_add_u32,(uint32_t *puDst, uint32_t uSrc, uint32_t *pfEFlags))
471{
472 uint32_t uDst = *puDst;
473 uint32_t uResult = uDst + uSrc;
474 *puDst = uResult;
475 IEM_EFL_UPDATE_STATUS_BITS_FOR_ARITHMETIC(pfEFlags, uResult, uDst, uSrc, 32, uResult < uDst, uSrc);
476}
477
478
479IEM_DECL_IMPL_DEF(void, iemAImpl_add_u16,(uint16_t *puDst, uint16_t uSrc, uint32_t *pfEFlags))
480{
481 uint16_t uDst = *puDst;
482 uint16_t uResult = uDst + uSrc;
483 *puDst = uResult;
484 IEM_EFL_UPDATE_STATUS_BITS_FOR_ARITHMETIC(pfEFlags, uResult, uDst, uSrc, 16, uResult < uDst, uSrc);
485}
486
487
488IEM_DECL_IMPL_DEF(void, iemAImpl_add_u8,(uint8_t *puDst, uint8_t uSrc, uint32_t *pfEFlags))
489{
490 uint8_t uDst = *puDst;
491 uint8_t uResult = uDst + uSrc;
492 *puDst = uResult;
493 IEM_EFL_UPDATE_STATUS_BITS_FOR_ARITHMETIC(pfEFlags, uResult, uDst, uSrc, 8, uResult < uDst, uSrc);
494}
495
496# endif /* !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY) */
497
498/*
499 * ADC
500 */
501
502IEM_DECL_IMPL_DEF(void, iemAImpl_adc_u64,(uint64_t *puDst, uint64_t uSrc, uint32_t *pfEFlags))
503{
504 if (!(*pfEFlags & X86_EFL_CF))
505 iemAImpl_add_u64(puDst, uSrc, pfEFlags);
506 else
507 {
508 uint64_t uDst = *puDst;
509 uint64_t uResult = uDst + uSrc + 1;
510 *puDst = uResult;
511 IEM_EFL_UPDATE_STATUS_BITS_FOR_ARITHMETIC(pfEFlags, uResult, uDst, uSrc, 64, uResult <= uDst, uSrc);
512 }
513}
514
515# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
516
517IEM_DECL_IMPL_DEF(void, iemAImpl_adc_u32,(uint32_t *puDst, uint32_t uSrc, uint32_t *pfEFlags))
518{
519 if (!(*pfEFlags & X86_EFL_CF))
520 iemAImpl_add_u32(puDst, uSrc, pfEFlags);
521 else
522 {
523 uint32_t uDst = *puDst;
524 uint32_t uResult = uDst + uSrc + 1;
525 *puDst = uResult;
526 IEM_EFL_UPDATE_STATUS_BITS_FOR_ARITHMETIC(pfEFlags, uResult, uDst, uSrc, 32, uResult <= uDst, uSrc);
527 }
528}
529
530
531IEM_DECL_IMPL_DEF(void, iemAImpl_adc_u16,(uint16_t *puDst, uint16_t uSrc, uint32_t *pfEFlags))
532{
533 if (!(*pfEFlags & X86_EFL_CF))
534 iemAImpl_add_u16(puDst, uSrc, pfEFlags);
535 else
536 {
537 uint16_t uDst = *puDst;
538 uint16_t uResult = uDst + uSrc + 1;
539 *puDst = uResult;
540 IEM_EFL_UPDATE_STATUS_BITS_FOR_ARITHMETIC(pfEFlags, uResult, uDst, uSrc, 16, uResult <= uDst, uSrc);
541 }
542}
543
544
545IEM_DECL_IMPL_DEF(void, iemAImpl_adc_u8,(uint8_t *puDst, uint8_t uSrc, uint32_t *pfEFlags))
546{
547 if (!(*pfEFlags & X86_EFL_CF))
548 iemAImpl_add_u8(puDst, uSrc, pfEFlags);
549 else
550 {
551 uint8_t uDst = *puDst;
552 uint8_t uResult = uDst + uSrc + 1;
553 *puDst = uResult;
554 IEM_EFL_UPDATE_STATUS_BITS_FOR_ARITHMETIC(pfEFlags, uResult, uDst, uSrc, 8, uResult <= uDst, uSrc);
555 }
556}
557
558# endif /* !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY) */
559
560/*
561 * SUB
562 */
563
564IEM_DECL_IMPL_DEF(void, iemAImpl_sub_u64,(uint64_t *puDst, uint64_t uSrc, uint32_t *pfEFlags))
565{
566 uint64_t uDst = *puDst;
567 uint64_t uResult = uDst - uSrc;
568 *puDst = uResult;
569 IEM_EFL_UPDATE_STATUS_BITS_FOR_ARITHMETIC(pfEFlags, uResult, uDst, uSrc, 64, uDst < uSrc, uSrc ^ RT_BIT_64(63));
570}
571
572# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
573
574IEM_DECL_IMPL_DEF(void, iemAImpl_sub_u32,(uint32_t *puDst, uint32_t uSrc, uint32_t *pfEFlags))
575{
576 uint32_t uDst = *puDst;
577 uint32_t uResult = uDst - uSrc;
578 *puDst = uResult;
579 IEM_EFL_UPDATE_STATUS_BITS_FOR_ARITHMETIC(pfEFlags, uResult, uDst, uSrc, 32, uDst < uSrc, uSrc ^ RT_BIT_32(31));
580}
581
582
583IEM_DECL_IMPL_DEF(void, iemAImpl_sub_u16,(uint16_t *puDst, uint16_t uSrc, uint32_t *pfEFlags))
584{
585 uint16_t uDst = *puDst;
586 uint16_t uResult = uDst - uSrc;
587 *puDst = uResult;
588 IEM_EFL_UPDATE_STATUS_BITS_FOR_ARITHMETIC(pfEFlags, uResult, uDst, uSrc, 16, uDst < uSrc, uSrc ^ (uint16_t)0x8000);
589}
590
591
592IEM_DECL_IMPL_DEF(void, iemAImpl_sub_u8,(uint8_t *puDst, uint8_t uSrc, uint32_t *pfEFlags))
593{
594 uint8_t uDst = *puDst;
595 uint8_t uResult = uDst - uSrc;
596 *puDst = uResult;
597 IEM_EFL_UPDATE_STATUS_BITS_FOR_ARITHMETIC(pfEFlags, uResult, uDst, uSrc, 8, uDst < uSrc, uSrc ^ (uint8_t)0x80);
598}
599
600# endif /* !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY) */
601
602/*
603 * SBB
604 */
605
606IEM_DECL_IMPL_DEF(void, iemAImpl_sbb_u64,(uint64_t *puDst, uint64_t uSrc, uint32_t *pfEFlags))
607{
608 if (!(*pfEFlags & X86_EFL_CF))
609 iemAImpl_sub_u64(puDst, uSrc, pfEFlags);
610 else
611 {
612 uint64_t uDst = *puDst;
613 uint64_t uResult = uDst - uSrc - 1;
614 *puDst = uResult;
615 IEM_EFL_UPDATE_STATUS_BITS_FOR_ARITHMETIC(pfEFlags, uResult, uDst, uSrc, 64, uDst <= uSrc, uSrc ^ RT_BIT_64(63));
616 }
617}
618
619# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
620
621IEM_DECL_IMPL_DEF(void, iemAImpl_sbb_u32,(uint32_t *puDst, uint32_t uSrc, uint32_t *pfEFlags))
622{
623 if (!(*pfEFlags & X86_EFL_CF))
624 iemAImpl_sub_u32(puDst, uSrc, pfEFlags);
625 else
626 {
627 uint32_t uDst = *puDst;
628 uint32_t uResult = uDst - uSrc - 1;
629 *puDst = uResult;
630 IEM_EFL_UPDATE_STATUS_BITS_FOR_ARITHMETIC(pfEFlags, uResult, uDst, uSrc, 32, uDst <= uSrc, uSrc ^ RT_BIT_32(31));
631 }
632}
633
634
635IEM_DECL_IMPL_DEF(void, iemAImpl_sbb_u16,(uint16_t *puDst, uint16_t uSrc, uint32_t *pfEFlags))
636{
637 if (!(*pfEFlags & X86_EFL_CF))
638 iemAImpl_sub_u16(puDst, uSrc, pfEFlags);
639 else
640 {
641 uint16_t uDst = *puDst;
642 uint16_t uResult = uDst - uSrc - 1;
643 *puDst = uResult;
644 IEM_EFL_UPDATE_STATUS_BITS_FOR_ARITHMETIC(pfEFlags, uResult, uDst, uSrc, 16, uDst <= uSrc, uSrc ^ (uint16_t)0x8000);
645 }
646}
647
648
649IEM_DECL_IMPL_DEF(void, iemAImpl_sbb_u8,(uint8_t *puDst, uint8_t uSrc, uint32_t *pfEFlags))
650{
651 if (!(*pfEFlags & X86_EFL_CF))
652 iemAImpl_sub_u8(puDst, uSrc, pfEFlags);
653 else
654 {
655 uint8_t uDst = *puDst;
656 uint8_t uResult = uDst - uSrc - 1;
657 *puDst = uResult;
658 IEM_EFL_UPDATE_STATUS_BITS_FOR_ARITHMETIC(pfEFlags, uResult, uDst, uSrc, 8, uDst <= uSrc, uSrc ^ (uint8_t)0x80);
659 }
660}
661
662# endif /* !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY) */
663
664
665/*
666 * OR
667 */
668
669IEM_DECL_IMPL_DEF(void, iemAImpl_or_u64,(uint64_t *puDst, uint64_t uSrc, uint32_t *pfEFlags))
670{
671 uint64_t uResult = *puDst | uSrc;
672 *puDst = uResult;
673 IEM_EFL_UPDATE_STATUS_BITS_FOR_LOGIC(pfEFlags, uResult, 64, 0);
674}
675
676# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
677
678IEM_DECL_IMPL_DEF(void, iemAImpl_or_u32,(uint32_t *puDst, uint32_t uSrc, uint32_t *pfEFlags))
679{
680 uint32_t uResult = *puDst | uSrc;
681 *puDst = uResult;
682 IEM_EFL_UPDATE_STATUS_BITS_FOR_LOGIC(pfEFlags, uResult, 32, 0);
683}
684
685
686IEM_DECL_IMPL_DEF(void, iemAImpl_or_u16,(uint16_t *puDst, uint16_t uSrc, uint32_t *pfEFlags))
687{
688 uint16_t uResult = *puDst | uSrc;
689 *puDst = uResult;
690 IEM_EFL_UPDATE_STATUS_BITS_FOR_LOGIC(pfEFlags, uResult, 16, 0);
691}
692
693
694IEM_DECL_IMPL_DEF(void, iemAImpl_or_u8,(uint8_t *puDst, uint8_t uSrc, uint32_t *pfEFlags))
695{
696 uint8_t uResult = *puDst | uSrc;
697 *puDst = uResult;
698 IEM_EFL_UPDATE_STATUS_BITS_FOR_LOGIC(pfEFlags, uResult, 8, 0);
699}
700
701# endif /* !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY) */
702
703/*
704 * XOR
705 */
706
707IEM_DECL_IMPL_DEF(void, iemAImpl_xor_u64,(uint64_t *puDst, uint64_t uSrc, uint32_t *pfEFlags))
708{
709 uint64_t uResult = *puDst ^ uSrc;
710 *puDst = uResult;
711 IEM_EFL_UPDATE_STATUS_BITS_FOR_LOGIC(pfEFlags, uResult, 64, 0);
712}
713
714# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
715
716IEM_DECL_IMPL_DEF(void, iemAImpl_xor_u32,(uint32_t *puDst, uint32_t uSrc, uint32_t *pfEFlags))
717{
718 uint32_t uResult = *puDst ^ uSrc;
719 *puDst = uResult;
720 IEM_EFL_UPDATE_STATUS_BITS_FOR_LOGIC(pfEFlags, uResult, 32, 0);
721}
722
723
724IEM_DECL_IMPL_DEF(void, iemAImpl_xor_u16,(uint16_t *puDst, uint16_t uSrc, uint32_t *pfEFlags))
725{
726 uint16_t uResult = *puDst ^ uSrc;
727 *puDst = uResult;
728 IEM_EFL_UPDATE_STATUS_BITS_FOR_LOGIC(pfEFlags, uResult, 16, 0);
729}
730
731
732IEM_DECL_IMPL_DEF(void, iemAImpl_xor_u8,(uint8_t *puDst, uint8_t uSrc, uint32_t *pfEFlags))
733{
734 uint8_t uResult = *puDst ^ uSrc;
735 *puDst = uResult;
736 IEM_EFL_UPDATE_STATUS_BITS_FOR_LOGIC(pfEFlags, uResult, 8, 0);
737}
738
739# endif /* !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY) */
740
741/*
742 * AND
743 */
744
745IEM_DECL_IMPL_DEF(void, iemAImpl_and_u64,(uint64_t *puDst, uint64_t uSrc, uint32_t *pfEFlags))
746{
747 uint64_t uResult = *puDst & uSrc;
748 *puDst = uResult;
749 IEM_EFL_UPDATE_STATUS_BITS_FOR_LOGIC(pfEFlags, uResult, 64, 0);
750}
751
752# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
753
754IEM_DECL_IMPL_DEF(void, iemAImpl_and_u32,(uint32_t *puDst, uint32_t uSrc, uint32_t *pfEFlags))
755{
756 uint32_t uResult = *puDst & uSrc;
757 *puDst = uResult;
758 IEM_EFL_UPDATE_STATUS_BITS_FOR_LOGIC(pfEFlags, uResult, 32, 0);
759}
760
761
762IEM_DECL_IMPL_DEF(void, iemAImpl_and_u16,(uint16_t *puDst, uint16_t uSrc, uint32_t *pfEFlags))
763{
764 uint16_t uResult = *puDst & uSrc;
765 *puDst = uResult;
766 IEM_EFL_UPDATE_STATUS_BITS_FOR_LOGIC(pfEFlags, uResult, 16, 0);
767}
768
769
770IEM_DECL_IMPL_DEF(void, iemAImpl_and_u8,(uint8_t *puDst, uint8_t uSrc, uint32_t *pfEFlags))
771{
772 uint8_t uResult = *puDst & uSrc;
773 *puDst = uResult;
774 IEM_EFL_UPDATE_STATUS_BITS_FOR_LOGIC(pfEFlags, uResult, 8, 0);
775}
776
777# endif /* !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY) */
778
779/*
780 * CMP
781 */
782
783IEM_DECL_IMPL_DEF(void, iemAImpl_cmp_u64,(uint64_t *puDst, uint64_t uSrc, uint32_t *pfEFlags))
784{
785 uint64_t uDstTmp = *puDst;
786 iemAImpl_sub_u64(&uDstTmp, uSrc, pfEFlags);
787}
788
789# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
790
791IEM_DECL_IMPL_DEF(void, iemAImpl_cmp_u32,(uint32_t *puDst, uint32_t uSrc, uint32_t *pfEFlags))
792{
793 uint32_t uDstTmp = *puDst;
794 iemAImpl_sub_u32(&uDstTmp, uSrc, pfEFlags);
795}
796
797
798IEM_DECL_IMPL_DEF(void, iemAImpl_cmp_u16,(uint16_t *puDst, uint16_t uSrc, uint32_t *pfEFlags))
799{
800 uint16_t uDstTmp = *puDst;
801 iemAImpl_sub_u16(&uDstTmp, uSrc, pfEFlags);
802}
803
804
805IEM_DECL_IMPL_DEF(void, iemAImpl_cmp_u8,(uint8_t *puDst, uint8_t uSrc, uint32_t *pfEFlags))
806{
807 uint8_t uDstTmp = *puDst;
808 iemAImpl_sub_u8(&uDstTmp, uSrc, pfEFlags);
809}
810
811# endif /* !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY) */
812
813/*
814 * TEST
815 */
816
817IEM_DECL_IMPL_DEF(void, iemAImpl_test_u64,(uint64_t *puDst, uint64_t uSrc, uint32_t *pfEFlags))
818{
819 uint64_t uResult = *puDst & uSrc;
820 IEM_EFL_UPDATE_STATUS_BITS_FOR_LOGIC(pfEFlags, uResult, 64, 0);
821}
822
823# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
824
825IEM_DECL_IMPL_DEF(void, iemAImpl_test_u32,(uint32_t *puDst, uint32_t uSrc, uint32_t *pfEFlags))
826{
827 uint32_t uResult = *puDst & uSrc;
828 IEM_EFL_UPDATE_STATUS_BITS_FOR_LOGIC(pfEFlags, uResult, 32, 0);
829}
830
831
832IEM_DECL_IMPL_DEF(void, iemAImpl_test_u16,(uint16_t *puDst, uint16_t uSrc, uint32_t *pfEFlags))
833{
834 uint16_t uResult = *puDst & uSrc;
835 IEM_EFL_UPDATE_STATUS_BITS_FOR_LOGIC(pfEFlags, uResult, 16, 0);
836}
837
838
839IEM_DECL_IMPL_DEF(void, iemAImpl_test_u8,(uint8_t *puDst, uint8_t uSrc, uint32_t *pfEFlags))
840{
841 uint8_t uResult = *puDst & uSrc;
842 IEM_EFL_UPDATE_STATUS_BITS_FOR_LOGIC(pfEFlags, uResult, 8, 0);
843}
844
845# endif /* !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY) */
846
847
848/*
849 * LOCK prefixed variants of the above
850 */
851
852/** 64-bit locked binary operand operation. */
853# define DO_LOCKED_BIN_OP(a_Mnemonic, a_cBitsWidth) \
854 do { \
855 uint ## a_cBitsWidth ## _t uOld = ASMAtomicUoReadU ## a_cBitsWidth(puDst); \
856 uint ## a_cBitsWidth ## _t uTmp; \
857 uint32_t fEflTmp; \
858 do \
859 { \
860 uTmp = uOld; \
861 fEflTmp = *pfEFlags; \
862 iemAImpl_ ## a_Mnemonic ## _u ## a_cBitsWidth(&uTmp, uSrc, &fEflTmp); \
863 } while (!ASMAtomicCmpXchgExU ## a_cBitsWidth(puDst, uTmp, uOld, &uOld)); \
864 *pfEFlags = fEflTmp; \
865 } while (0)
866
867
868#define EMIT_LOCKED_BIN_OP(a_Mnemonic, a_cBitsWidth) \
869 IEM_DECL_IMPL_DEF(void, iemAImpl_ ## a_Mnemonic ## _u ## a_cBitsWidth ## _locked,(uint ## a_cBitsWidth ## _t *puDst, \
870 uint ## a_cBitsWidth ## _t uSrc, \
871 uint32_t *pfEFlags)) \
872 { \
873 DO_LOCKED_BIN_OP(a_Mnemonic, a_cBitsWidth); \
874 }
875
876EMIT_LOCKED_BIN_OP(add, 64)
877EMIT_LOCKED_BIN_OP(adc, 64)
878EMIT_LOCKED_BIN_OP(sub, 64)
879EMIT_LOCKED_BIN_OP(sbb, 64)
880EMIT_LOCKED_BIN_OP(or, 64)
881EMIT_LOCKED_BIN_OP(xor, 64)
882EMIT_LOCKED_BIN_OP(and, 64)
883# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
884EMIT_LOCKED_BIN_OP(add, 32)
885EMIT_LOCKED_BIN_OP(adc, 32)
886EMIT_LOCKED_BIN_OP(sub, 32)
887EMIT_LOCKED_BIN_OP(sbb, 32)
888EMIT_LOCKED_BIN_OP(or, 32)
889EMIT_LOCKED_BIN_OP(xor, 32)
890EMIT_LOCKED_BIN_OP(and, 32)
891
892EMIT_LOCKED_BIN_OP(add, 16)
893EMIT_LOCKED_BIN_OP(adc, 16)
894EMIT_LOCKED_BIN_OP(sub, 16)
895EMIT_LOCKED_BIN_OP(sbb, 16)
896EMIT_LOCKED_BIN_OP(or, 16)
897EMIT_LOCKED_BIN_OP(xor, 16)
898EMIT_LOCKED_BIN_OP(and, 16)
899
900EMIT_LOCKED_BIN_OP(add, 8)
901EMIT_LOCKED_BIN_OP(adc, 8)
902EMIT_LOCKED_BIN_OP(sub, 8)
903EMIT_LOCKED_BIN_OP(sbb, 8)
904EMIT_LOCKED_BIN_OP(or, 8)
905EMIT_LOCKED_BIN_OP(xor, 8)
906EMIT_LOCKED_BIN_OP(and, 8)
907# endif /* !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY) */
908
909
910/*
911 * Bit operations (same signature as above).
912 */
913
914/*
915 * BT
916 */
917
918IEM_DECL_IMPL_DEF(void, iemAImpl_bt_u64,(uint64_t *puDst, uint64_t uSrc, uint32_t *pfEFlags))
919{
920 /* Note! "undefined" flags: OF, SF, ZF, AF, PF. However, it seems they're
921 not modified by either AMD (3990x) or Intel (i9-9980HK). */
922 Assert(uSrc < 64);
923 uint64_t uDst = *puDst;
924 if (uDst & RT_BIT_64(uSrc))
925 *pfEFlags |= X86_EFL_CF;
926 else
927 *pfEFlags &= ~X86_EFL_CF;
928}
929
930# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
931
932IEM_DECL_IMPL_DEF(void, iemAImpl_bt_u32,(uint32_t *puDst, uint32_t uSrc, uint32_t *pfEFlags))
933{
934 /* Note! "undefined" flags: OF, SF, ZF, AF, PF. However, it seems they're
935 not modified by either AMD (3990x) or Intel (i9-9980HK). */
936 Assert(uSrc < 32);
937 uint32_t uDst = *puDst;
938 if (uDst & RT_BIT_32(uSrc))
939 *pfEFlags |= X86_EFL_CF;
940 else
941 *pfEFlags &= ~X86_EFL_CF;
942}
943
944IEM_DECL_IMPL_DEF(void, iemAImpl_bt_u16,(uint16_t *puDst, uint16_t uSrc, uint32_t *pfEFlags))
945{
946 /* Note! "undefined" flags: OF, SF, ZF, AF, PF. However, it seems they're
947 not modified by either AMD (3990x) or Intel (i9-9980HK). */
948 Assert(uSrc < 16);
949 uint16_t uDst = *puDst;
950 if (uDst & RT_BIT_32(uSrc))
951 *pfEFlags |= X86_EFL_CF;
952 else
953 *pfEFlags &= ~X86_EFL_CF;
954}
955
956# endif /* !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY) */
957
958/*
959 * BTC
960 */
961
962IEM_DECL_IMPL_DEF(void, iemAImpl_btc_u64,(uint64_t *puDst, uint64_t uSrc, uint32_t *pfEFlags))
963{
964 /* Note! "undefined" flags: OF, SF, ZF, AF, PF. However, it seems they're
965 not modified by either AMD (3990x) or Intel (i9-9980HK). */
966 Assert(uSrc < 64);
967 uint64_t fMask = RT_BIT_64(uSrc);
968 uint64_t uDst = *puDst;
969 if (uDst & fMask)
970 {
971 uDst &= ~fMask;
972 *puDst = uDst;
973 *pfEFlags |= X86_EFL_CF;
974 }
975 else
976 {
977 uDst |= fMask;
978 *puDst = uDst;
979 *pfEFlags &= ~X86_EFL_CF;
980 }
981}
982
983# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
984
985IEM_DECL_IMPL_DEF(void, iemAImpl_btc_u32,(uint32_t *puDst, uint32_t uSrc, uint32_t *pfEFlags))
986{
987 /* Note! "undefined" flags: OF, SF, ZF, AF, PF. However, it seems they're
988 not modified by either AMD (3990x) or Intel (i9-9980HK). */
989 Assert(uSrc < 32);
990 uint32_t fMask = RT_BIT_32(uSrc);
991 uint32_t uDst = *puDst;
992 if (uDst & fMask)
993 {
994 uDst &= ~fMask;
995 *puDst = uDst;
996 *pfEFlags |= X86_EFL_CF;
997 }
998 else
999 {
1000 uDst |= fMask;
1001 *puDst = uDst;
1002 *pfEFlags &= ~X86_EFL_CF;
1003 }
1004}
1005
1006
1007IEM_DECL_IMPL_DEF(void, iemAImpl_btc_u16,(uint16_t *puDst, uint16_t uSrc, uint32_t *pfEFlags))
1008{
1009 /* Note! "undefined" flags: OF, SF, ZF, AF, PF. However, it seems they're
1010 not modified by either AMD (3990x) or Intel (i9-9980HK). */
1011 Assert(uSrc < 16);
1012 uint16_t fMask = RT_BIT_32(uSrc);
1013 uint16_t uDst = *puDst;
1014 if (uDst & fMask)
1015 {
1016 uDst &= ~fMask;
1017 *puDst = uDst;
1018 *pfEFlags |= X86_EFL_CF;
1019 }
1020 else
1021 {
1022 uDst |= fMask;
1023 *puDst = uDst;
1024 *pfEFlags &= ~X86_EFL_CF;
1025 }
1026}
1027
1028# endif /* !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY) */
1029
1030/*
1031 * BTR
1032 */
1033
1034IEM_DECL_IMPL_DEF(void, iemAImpl_btr_u64,(uint64_t *puDst, uint64_t uSrc, uint32_t *pfEFlags))
1035{
1036 /* Note! "undefined" flags: OF, SF, ZF, AF, PF. We set them as after an
1037 logical operation (AND/OR/whatever). */
1038 Assert(uSrc < 64);
1039 uint64_t fMask = RT_BIT_64(uSrc);
1040 uint64_t uDst = *puDst;
1041 if (uDst & fMask)
1042 {
1043 uDst &= ~fMask;
1044 *puDst = uDst;
1045 *pfEFlags |= X86_EFL_CF;
1046 }
1047 else
1048 *pfEFlags &= ~X86_EFL_CF;
1049}
1050
1051# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
1052
1053IEM_DECL_IMPL_DEF(void, iemAImpl_btr_u32,(uint32_t *puDst, uint32_t uSrc, uint32_t *pfEFlags))
1054{
1055 /* Note! "undefined" flags: OF, SF, ZF, AF, PF. We set them as after an
1056 logical operation (AND/OR/whatever). */
1057 Assert(uSrc < 32);
1058 uint32_t fMask = RT_BIT_32(uSrc);
1059 uint32_t uDst = *puDst;
1060 if (uDst & fMask)
1061 {
1062 uDst &= ~fMask;
1063 *puDst = uDst;
1064 *pfEFlags |= X86_EFL_CF;
1065 }
1066 else
1067 *pfEFlags &= ~X86_EFL_CF;
1068}
1069
1070
1071IEM_DECL_IMPL_DEF(void, iemAImpl_btr_u16,(uint16_t *puDst, uint16_t uSrc, uint32_t *pfEFlags))
1072{
1073 /* Note! "undefined" flags: OF, SF, ZF, AF, PF. We set them as after an
1074 logical operation (AND/OR/whatever). */
1075 Assert(uSrc < 16);
1076 uint16_t fMask = RT_BIT_32(uSrc);
1077 uint16_t uDst = *puDst;
1078 if (uDst & fMask)
1079 {
1080 uDst &= ~fMask;
1081 *puDst = uDst;
1082 *pfEFlags |= X86_EFL_CF;
1083 }
1084 else
1085 *pfEFlags &= ~X86_EFL_CF;
1086}
1087
1088# endif /* !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY) */
1089
1090/*
1091 * BTS
1092 */
1093
1094IEM_DECL_IMPL_DEF(void, iemAImpl_bts_u64,(uint64_t *puDst, uint64_t uSrc, uint32_t *pfEFlags))
1095{
1096 /* Note! "undefined" flags: OF, SF, ZF, AF, PF. We set them as after an
1097 logical operation (AND/OR/whatever). */
1098 Assert(uSrc < 64);
1099 uint64_t fMask = RT_BIT_64(uSrc);
1100 uint64_t uDst = *puDst;
1101 if (uDst & fMask)
1102 *pfEFlags |= X86_EFL_CF;
1103 else
1104 {
1105 uDst |= fMask;
1106 *puDst = uDst;
1107 *pfEFlags &= ~X86_EFL_CF;
1108 }
1109}
1110
1111# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
1112
1113IEM_DECL_IMPL_DEF(void, iemAImpl_bts_u32,(uint32_t *puDst, uint32_t uSrc, uint32_t *pfEFlags))
1114{
1115 /* Note! "undefined" flags: OF, SF, ZF, AF, PF. We set them as after an
1116 logical operation (AND/OR/whatever). */
1117 Assert(uSrc < 32);
1118 uint32_t fMask = RT_BIT_32(uSrc);
1119 uint32_t uDst = *puDst;
1120 if (uDst & fMask)
1121 *pfEFlags |= X86_EFL_CF;
1122 else
1123 {
1124 uDst |= fMask;
1125 *puDst = uDst;
1126 *pfEFlags &= ~X86_EFL_CF;
1127 }
1128}
1129
1130
1131IEM_DECL_IMPL_DEF(void, iemAImpl_bts_u16,(uint16_t *puDst, uint16_t uSrc, uint32_t *pfEFlags))
1132{
1133 /* Note! "undefined" flags: OF, SF, ZF, AF, PF. We set them as after an
1134 logical operation (AND/OR/whatever). */
1135 Assert(uSrc < 16);
1136 uint16_t fMask = RT_BIT_32(uSrc);
1137 uint32_t uDst = *puDst;
1138 if (uDst & fMask)
1139 *pfEFlags |= X86_EFL_CF;
1140 else
1141 {
1142 uDst |= fMask;
1143 *puDst = uDst;
1144 *pfEFlags &= ~X86_EFL_CF;
1145 }
1146}
1147
1148# endif /* !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY) */
1149
1150
1151EMIT_LOCKED_BIN_OP(btc, 64)
1152EMIT_LOCKED_BIN_OP(btr, 64)
1153EMIT_LOCKED_BIN_OP(bts, 64)
1154# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
1155EMIT_LOCKED_BIN_OP(btc, 32)
1156EMIT_LOCKED_BIN_OP(btr, 32)
1157EMIT_LOCKED_BIN_OP(bts, 32)
1158
1159EMIT_LOCKED_BIN_OP(btc, 16)
1160EMIT_LOCKED_BIN_OP(btr, 16)
1161EMIT_LOCKED_BIN_OP(bts, 16)
1162# endif /* !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY) */
1163
1164
1165/*
1166 * BSF - first (least significant) bit set
1167 */
1168
1169IEM_DECL_IMPL_DEF(void, iemAImpl_bsf_u64,(uint64_t *puDst, uint64_t uSrc, uint32_t *pfEFlags))
1170{
1171 /* Note! "undefined" flags: OF, SF, AF, PF, CF. */
1172 /* Intel & AMD differs here. This is is the AMD behaviour. */
1173 unsigned iBit = ASMBitFirstSetU64(uSrc);
1174 if (iBit)
1175 {
1176 *puDst = iBit - 1;
1177 *pfEFlags &= ~X86_EFL_ZF;
1178 }
1179 else
1180 *pfEFlags |= X86_EFL_ZF;
1181}
1182
1183# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
1184
1185IEM_DECL_IMPL_DEF(void, iemAImpl_bsf_u32,(uint32_t *puDst, uint32_t uSrc, uint32_t *pfEFlags))
1186{
1187 /* Note! "undefined" flags: OF, SF, AF, PF, CF. */
1188 /* Intel & AMD differs here. This is is the AMD behaviour. */
1189 unsigned iBit = ASMBitFirstSetU32(uSrc);
1190 if (iBit)
1191 {
1192 *puDst = iBit - 1;
1193 *pfEFlags &= ~X86_EFL_ZF;
1194 }
1195 else
1196 *pfEFlags |= X86_EFL_ZF;
1197}
1198
1199
1200IEM_DECL_IMPL_DEF(void, iemAImpl_bsf_u16,(uint16_t *puDst, uint16_t uSrc, uint32_t *pfEFlags))
1201{
1202 /* Note! "undefined" flags: OF, SF, AF, PF, CF. */
1203 /* Intel & AMD differs here. This is is the AMD behaviour. */
1204 unsigned iBit = ASMBitFirstSetU16(uSrc);
1205 if (iBit)
1206 {
1207 *puDst = iBit - 1;
1208 *pfEFlags &= ~X86_EFL_ZF;
1209 }
1210 else
1211 *pfEFlags |= X86_EFL_ZF;
1212}
1213
1214# endif /* !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY) */
1215
1216/*
1217 * BSR - last (most significant) bit set
1218 */
1219
1220IEM_DECL_IMPL_DEF(void, iemAImpl_bsr_u64,(uint64_t *puDst, uint64_t uSrc, uint32_t *pfEFlags))
1221{
1222 /* Note! "undefined" flags: OF, SF, AF, PF, CF. */
1223 /* Intel & AMD differs here. This is is the AMD behaviour. */
1224 unsigned iBit = ASMBitLastSetU64(uSrc);
1225 if (uSrc)
1226 {
1227 *puDst = iBit - 1;
1228 *pfEFlags &= ~X86_EFL_ZF;
1229 }
1230 else
1231 *pfEFlags |= X86_EFL_ZF;
1232}
1233
1234# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
1235
1236IEM_DECL_IMPL_DEF(void, iemAImpl_bsr_u32,(uint32_t *puDst, uint32_t uSrc, uint32_t *pfEFlags))
1237{
1238 /* Note! "undefined" flags: OF, SF, AF, PF, CF. */
1239 /* Intel & AMD differs here. This is is the AMD behaviour. */
1240 unsigned iBit = ASMBitLastSetU32(uSrc);
1241 if (uSrc)
1242 {
1243 *puDst = iBit - 1;
1244 *pfEFlags &= ~X86_EFL_ZF;
1245 }
1246 else
1247 *pfEFlags |= X86_EFL_ZF;
1248}
1249
1250
1251IEM_DECL_IMPL_DEF(void, iemAImpl_bsr_u16,(uint16_t *puDst, uint16_t uSrc, uint32_t *pfEFlags))
1252{
1253 /* Note! "undefined" flags: OF, SF, AF, PF, CF. */
1254 /* Intel & AMD differs here. This is is the AMD behaviour. */
1255 unsigned iBit = ASMBitLastSetU16(uSrc);
1256 if (uSrc)
1257 {
1258 *puDst = iBit - 1;
1259 *pfEFlags &= ~X86_EFL_ZF;
1260 }
1261 else
1262 *pfEFlags |= X86_EFL_ZF;
1263}
1264
1265# endif /* !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY) */
1266
1267
1268/*
1269 * XCHG
1270 */
1271
1272IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u64_locked,(uint64_t *puMem, uint64_t *puReg))
1273{
1274#if ARCH_BITS >= 64
1275 *puReg = ASMAtomicXchgU64(puMem, *puReg);
1276#else
1277 uint64_t uOldMem = *puMem;
1278 while (!ASMAtomicCmpXchgExU64(puMem, *puReg, uOldMem, &uOldMem))
1279 ASMNopPause();
1280 *puReg = uOldMem;
1281#endif
1282}
1283
1284# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
1285
1286IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u32_locked,(uint32_t *puMem, uint32_t *puReg))
1287{
1288 *puReg = ASMAtomicXchgU32(puMem, *puReg);
1289}
1290
1291
1292IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u16_locked,(uint16_t *puMem, uint16_t *puReg))
1293{
1294 *puReg = ASMAtomicXchgU16(puMem, *puReg);
1295}
1296
1297
1298IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u8_locked,(uint8_t *puMem, uint8_t *puReg))
1299{
1300 *puReg = ASMAtomicXchgU8(puMem, *puReg);
1301}
1302
1303# endif /* !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY) */
1304
1305
1306/* Unlocked variants for fDisregardLock mode: */
1307
1308IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u64_unlocked,(uint64_t *puMem, uint64_t *puReg))
1309{
1310 uint64_t const uOld = *puMem;
1311 *puMem = *puReg;
1312 *puReg = uOld;
1313}
1314
1315# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
1316
1317IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u32_unlocked,(uint32_t *puMem, uint32_t *puReg))
1318{
1319 uint32_t const uOld = *puMem;
1320 *puMem = *puReg;
1321 *puReg = uOld;
1322}
1323
1324
1325IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u16_unlocked,(uint16_t *puMem, uint16_t *puReg))
1326{
1327 uint16_t const uOld = *puMem;
1328 *puMem = *puReg;
1329 *puReg = uOld;
1330}
1331
1332
1333IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u8_unlocked,(uint8_t *puMem, uint8_t *puReg))
1334{
1335 uint8_t const uOld = *puMem;
1336 *puMem = *puReg;
1337 *puReg = uOld;
1338}
1339
1340# endif /* !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY) */
1341
1342
1343/*
1344 * XADD and LOCK XADD.
1345 */
1346#define EMIT_XADD(a_cBitsWidth, a_Type) \
1347IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u ## a_cBitsWidth,(a_Type *puDst, a_Type *puReg, uint32_t *pfEFlags)) \
1348{ \
1349 a_Type uDst = *puDst; \
1350 a_Type uResult = uDst; \
1351 iemAImpl_add_u ## a_cBitsWidth(&uResult, *puReg, pfEFlags); \
1352 *puDst = uResult; \
1353 *puReg = uDst; \
1354} \
1355\
1356IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u ## a_cBitsWidth ## _locked,(a_Type *puDst, a_Type *puReg, uint32_t *pfEFlags)) \
1357{ \
1358 a_Type uOld = ASMAtomicUoReadU ## a_cBitsWidth(puDst); \
1359 a_Type uResult; \
1360 uint32_t fEflTmp; \
1361 do \
1362 { \
1363 uResult = uOld; \
1364 fEflTmp = *pfEFlags; \
1365 iemAImpl_add_u ## a_cBitsWidth(&uResult, *puReg, &fEflTmp); \
1366 } while (!ASMAtomicCmpXchgExU ## a_cBitsWidth(puDst, uResult, uOld, &uOld)); \
1367 *puReg = uOld; \
1368 *pfEFlags = fEflTmp; \
1369}
1370EMIT_XADD(64, uint64_t)
1371# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
1372EMIT_XADD(32, uint32_t)
1373EMIT_XADD(16, uint16_t)
1374EMIT_XADD(8, uint8_t)
1375# endif /* !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY) */
1376
1377#endif
1378
1379/*
1380 * CMPXCHG, CMPXCHG8B, CMPXCHG16B
1381 *
1382 * Note! We don't have non-locking/atomic cmpxchg primitives, so all cmpxchg
1383 * instructions are emulated as locked.
1384 */
1385#if defined(IEM_WITHOUT_ASSEMBLY)
1386
1387IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u8_locked, (uint8_t *pu8Dst, uint8_t *puAl, uint8_t uSrcReg, uint32_t *pEFlags))
1388{
1389 uint8_t uOld = *puAl;
1390 if (ASMAtomicCmpXchgExU8(pu8Dst, uSrcReg, uOld, puAl))
1391 Assert(*puAl == uOld);
1392 iemAImpl_cmp_u8(&uOld, *puAl, pEFlags);
1393}
1394
1395
1396IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u16_locked,(uint16_t *pu16Dst, uint16_t *puAx, uint16_t uSrcReg, uint32_t *pEFlags))
1397{
1398 uint16_t uOld = *puAx;
1399 if (ASMAtomicCmpXchgExU16(pu16Dst, uSrcReg, uOld, puAx))
1400 Assert(*puAx == uOld);
1401 iemAImpl_cmp_u16(&uOld, *puAx, pEFlags);
1402}
1403
1404
1405IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u32_locked,(uint32_t *pu32Dst, uint32_t *puEax, uint32_t uSrcReg, uint32_t *pEFlags))
1406{
1407 uint32_t uOld = *puEax;
1408 if (ASMAtomicCmpXchgExU32(pu32Dst, uSrcReg, uOld, puEax))
1409 Assert(*puEax == uOld);
1410 iemAImpl_cmp_u32(&uOld, *puEax, pEFlags);
1411}
1412
1413
1414# if ARCH_BITS == 32
1415IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u64_locked,(uint64_t *pu64Dst, uint64_t *puRax, uint64_t *puSrcReg, uint32_t *pEFlags))
1416# else
1417IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u64_locked,(uint64_t *pu64Dst, uint64_t *puRax, uint64_t uSrcReg, uint32_t *pEFlags))
1418# endif
1419{
1420# if ARCH_BITS == 32
1421 uint64_t const uSrcReg = *puSrcReg;
1422# endif
1423 uint64_t uOld = *puRax;
1424 if (ASMAtomicCmpXchgExU64(pu64Dst, uSrcReg, uOld, puRax))
1425 Assert(*puRax == uOld);
1426 iemAImpl_cmp_u64(&uOld, *puRax, pEFlags);
1427}
1428
1429
1430IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg8b_locked,(uint64_t *pu64Dst, PRTUINT64U pu64EaxEdx, PRTUINT64U pu64EbxEcx,
1431 uint32_t *pEFlags))
1432{
1433 uint64_t const uNew = pu64EbxEcx->u;
1434 uint64_t const uOld = pu64EaxEdx->u;
1435 if (ASMAtomicCmpXchgExU64(pu64Dst, uNew, uOld, &pu64EaxEdx->u))
1436 {
1437 Assert(pu64EaxEdx->u == uOld);
1438 *pEFlags |= X86_EFL_ZF;
1439 }
1440 else
1441 *pEFlags &= ~X86_EFL_ZF;
1442}
1443
1444
1445# if defined(RT_ARCH_AMD64) || defined(RT_ARCH_ARM64)
1446IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg16b_locked,(PRTUINT128U pu128Dst, PRTUINT128U pu128RaxRdx, PRTUINT128U pu128RbxRcx,
1447 uint32_t *pEFlags))
1448{
1449# ifdef VBOX_STRICT
1450 RTUINT128U const uOld = *pu128RaxRdx;
1451# endif
1452# if defined(RT_ARCH_AMD64)
1453 if (ASMAtomicCmpXchgU128v2(&pu128Dst->u, pu128RbxRcx->s.Hi, pu128RbxRcx->s.Lo, pu128RaxRdx->s.Hi, pu128RaxRdx->s.Lo,
1454 &pu128RaxRdx->u))
1455# else
1456 if (ASMAtomicCmpXchgU128(&pu128Dst->u, pu128RbxRcx->u, pu128RaxRdx->u, &pu128RaxRdx->u))
1457# endif
1458 {
1459 Assert(pu128RaxRdx->s.Lo == uOld.s.Lo && pu128RaxRdx->s.Hi == uOld.s.Hi);
1460 *pEFlags |= X86_EFL_ZF;
1461 }
1462 else
1463 *pEFlags &= ~X86_EFL_ZF;
1464}
1465# endif
1466
1467#endif /* defined(IEM_WITHOUT_ASSEMBLY) */
1468
1469# if !defined(RT_ARCH_ARM64) /** @todo may need this for unaligned accesses... */
1470IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg16b_fallback,(PRTUINT128U pu128Dst, PRTUINT128U pu128RaxRdx,
1471 PRTUINT128U pu128RbxRcx, uint32_t *pEFlags))
1472{
1473 RTUINT128U u128Tmp = *pu128Dst;
1474 if ( u128Tmp.s.Lo == pu128RaxRdx->s.Lo
1475 && u128Tmp.s.Hi == pu128RaxRdx->s.Hi)
1476 {
1477 *pu128Dst = *pu128RbxRcx;
1478 *pEFlags |= X86_EFL_ZF;
1479 }
1480 else
1481 {
1482 *pu128RaxRdx = u128Tmp;
1483 *pEFlags &= ~X86_EFL_ZF;
1484 }
1485}
1486#endif /* !RT_ARCH_ARM64 */
1487
1488#if defined(IEM_WITHOUT_ASSEMBLY)
1489
1490/* Unlocked versions mapped to the locked ones: */
1491
1492IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u8, (uint8_t *pu8Dst, uint8_t *puAl, uint8_t uSrcReg, uint32_t *pEFlags))
1493{
1494 iemAImpl_cmpxchg_u8_locked(pu8Dst, puAl, uSrcReg, pEFlags);
1495}
1496
1497
1498IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u16, (uint16_t *pu16Dst, uint16_t *puAx, uint16_t uSrcReg, uint32_t *pEFlags))
1499{
1500 iemAImpl_cmpxchg_u16_locked(pu16Dst, puAx, uSrcReg, pEFlags);
1501}
1502
1503
1504IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u32, (uint32_t *pu32Dst, uint32_t *puEax, uint32_t uSrcReg, uint32_t *pEFlags))
1505{
1506 iemAImpl_cmpxchg_u32_locked(pu32Dst, puEax, uSrcReg, pEFlags);
1507}
1508
1509
1510# if ARCH_BITS == 32
1511IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u64, (uint64_t *pu64Dst, uint64_t *puRax, uint64_t *puSrcReg, uint32_t *pEFlags))
1512{
1513 iemAImpl_cmpxchg_u64_locked(pu64Dst, puRax, puSrcReg, pEFlags);
1514}
1515# else
1516IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u64, (uint64_t *pu64Dst, uint64_t *puRax, uint64_t uSrcReg, uint32_t *pEFlags))
1517{
1518 iemAImpl_cmpxchg_u64_locked(pu64Dst, puRax, uSrcReg, pEFlags);
1519}
1520# endif
1521
1522
1523IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg8b,(uint64_t *pu64Dst, PRTUINT64U pu64EaxEdx, PRTUINT64U pu64EbxEcx, uint32_t *pEFlags))
1524{
1525 iemAImpl_cmpxchg8b_locked(pu64Dst, pu64EaxEdx, pu64EbxEcx, pEFlags);
1526}
1527
1528
1529IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg16b,(PRTUINT128U pu128Dst, PRTUINT128U pu128RaxRdx, PRTUINT128U pu128RbxRcx,
1530 uint32_t *pEFlags))
1531{
1532 iemAImpl_cmpxchg16b_locked(pu128Dst, pu128RaxRdx, pu128RbxRcx, pEFlags);
1533}
1534
1535#endif /* defined(IEM_WITHOUT_ASSEMBLY) */
1536
1537#if !defined(RT_ARCH_AMD64) || defined(IEM_WITHOUT_ASSEMBLY)
1538
1539/*
1540 * MUL, IMUL, DIV and IDIV helpers.
1541 *
1542 * - The U64 versions must use 128-bit intermediates, so we need to abstract the
1543 * division step so we can select between using C operators and
1544 * RTUInt128DivRem/RTUInt128MulU64ByU64.
1545 *
1546 * - The U8 versions work returns output in AL + AH instead of xDX + xAX, with the
1547 * IDIV/DIV taking all the input in AX too. This means we have to abstract some
1548 * input loads and the result storing.
1549 */
1550
1551DECLINLINE(void) RTUInt128DivRemByU64(PRTUINT128U pQuotient, PRTUINT128U pRemainder, PCRTUINT128U pDividend, uint64_t u64Divisor)
1552{
1553# ifdef __GNUC__ /* GCC maybe really annoying in function. */
1554 pQuotient->s.Lo = 0;
1555 pQuotient->s.Hi = 0;
1556# endif
1557 RTUINT128U Divisor;
1558 Divisor.s.Lo = u64Divisor;
1559 Divisor.s.Hi = 0;
1560 RTUInt128DivRem(pQuotient, pRemainder, pDividend, &Divisor);
1561}
1562
1563# define DIV_LOAD(a_Dividend) \
1564 a_Dividend.s.Lo = *puA, a_Dividend.s.Hi = *puD
1565# define DIV_LOAD_U8(a_Dividend) \
1566 a_Dividend.u = *puAX
1567
1568# define DIV_STORE(a_Quotient, a_uReminder) *puA = (a_Quotient), *puD = (a_uReminder)
1569# define DIV_STORE_U8(a_Quotient, a_uReminder) *puAX = (a_Quotient) | ((uint16_t)(a_uReminder) << 8)
1570
1571# define MUL_LOAD_F1() *puA
1572# define MUL_LOAD_F1_U8() ((uint8_t)*puAX)
1573
1574# define MUL_STORE(a_Result) *puA = (a_Result).s.Lo, *puD = (a_Result).s.Hi
1575# define MUL_STORE_U8(a_Result) *puAX = a_Result.u
1576
1577# define MULDIV_NEG(a_Value, a_cBitsWidth2x) \
1578 (a_Value).u = UINT ## a_cBitsWidth2x ## _C(0) - (a_Value).u
1579# define MULDIV_NEG_U128(a_Value, a_cBitsWidth2x) \
1580 RTUInt128AssignNeg(&(a_Value))
1581
1582# define MULDIV_MUL(a_Result, a_Factor1, a_Factor2, a_cBitsWidth2x) \
1583 (a_Result).u = (uint ## a_cBitsWidth2x ## _t)(a_Factor1) * (a_Factor2)
1584# define MULDIV_MUL_U128(a_Result, a_Factor1, a_Factor2, a_cBitsWidth2x) \
1585 RTUInt128MulU64ByU64(&(a_Result), a_Factor1, a_Factor2);
1586
1587# define MULDIV_MODDIV(a_Quotient, a_Remainder, a_Dividend, a_uDivisor) \
1588 a_Quotient.u = (a_Dividend).u / (a_uDivisor), \
1589 a_Remainder.u = (a_Dividend).u % (a_uDivisor)
1590# define MULDIV_MODDIV_U128(a_Quotient, a_Remainder, a_Dividend, a_uDivisor) \
1591 RTUInt128DivRemByU64(&a_Quotient, &a_Remainder, &a_Dividend, a_uDivisor)
1592
1593
1594/*
1595 * MUL
1596 */
1597# define EMIT_MUL(a_cBitsWidth, a_cBitsWidth2x, a_Args, a_fnLoadF1, a_fnStore, a_fnMul) \
1598IEM_DECL_IMPL_DEF(int, iemAImpl_mul_u ## a_cBitsWidth, a_Args) \
1599{ \
1600 RTUINT ## a_cBitsWidth2x ## U Result; \
1601 a_fnMul(Result, a_fnLoadF1(), uFactor, a_cBitsWidth2x); \
1602 a_fnStore(Result); \
1603 \
1604 /* MUL EFLAGS according to Skylake (similar to IMUL). */ \
1605 *pfEFlags &= ~(X86_EFL_SF | X86_EFL_CF | X86_EFL_OF | X86_EFL_AF | X86_EFL_ZF | X86_EFL_PF); \
1606 if (Result.s.Lo & RT_BIT_64(a_cBitsWidth - 1)) \
1607 *pfEFlags |= X86_EFL_SF; \
1608 *pfEFlags |= g_afParity[Result.s.Lo & 0xff]; /* (Skylake behaviour) */ \
1609 if (Result.s.Hi != 0) \
1610 *pfEFlags |= X86_EFL_CF | X86_EFL_OF; \
1611 return 0; \
1612}
1613EMIT_MUL(64, 128, (uint64_t *puA, uint64_t *puD, uint64_t uFactor, uint32_t *pfEFlags), MUL_LOAD_F1, MUL_STORE, MULDIV_MUL_U128)
1614# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
1615EMIT_MUL(32, 64, (uint32_t *puA, uint32_t *puD, uint32_t uFactor, uint32_t *pfEFlags), MUL_LOAD_F1, MUL_STORE, MULDIV_MUL)
1616EMIT_MUL(16, 32, (uint16_t *puA, uint16_t *puD, uint16_t uFactor, uint32_t *pfEFlags), MUL_LOAD_F1, MUL_STORE, MULDIV_MUL)
1617EMIT_MUL(8, 16, (uint16_t *puAX, uint8_t uFactor, uint32_t *pfEFlags), MUL_LOAD_F1_U8, MUL_STORE_U8, MULDIV_MUL)
1618# endif /* !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY) */
1619
1620
1621/*
1622 * IMUL
1623 */
1624# define EMIT_IMUL(a_cBitsWidth, a_cBitsWidth2x, a_Args, a_fnLoadF1, a_fnStore, a_fnNeg, a_fnMul) \
1625IEM_DECL_IMPL_DEF(int, iemAImpl_imul_u ## a_cBitsWidth,a_Args) \
1626{ \
1627 RTUINT ## a_cBitsWidth2x ## U Result; \
1628 /* The SF, ZF, AF and PF flags are "undefined". AMD (3990x) leaves these \
1629 flags as is. Whereas Intel skylake always clear AF and ZF and calculates \
1630 SF and PF as per the lower half of the result. */ \
1631 uint32_t fEfl = *pfEFlags & ~(X86_EFL_CF | X86_EFL_OF); \
1632 \
1633 uint ## a_cBitsWidth ## _t const uFactor1 = a_fnLoadF1(); \
1634 if (!(uFactor1 & RT_BIT_64(a_cBitsWidth - 1))) \
1635 { \
1636 if (!(uFactor2 & RT_BIT_64(a_cBitsWidth - 1))) \
1637 { \
1638 a_fnMul(Result, uFactor1, uFactor2, a_cBitsWidth2x); \
1639 if (Result.s.Hi != 0 || Result.s.Lo >= RT_BIT_64(a_cBitsWidth - 1)) \
1640 fEfl |= X86_EFL_CF | X86_EFL_OF; \
1641 } \
1642 else \
1643 { \
1644 a_fnMul(Result, uFactor1, UINT ## a_cBitsWidth ## _C(0) - uFactor2, a_cBitsWidth2x); \
1645 if (Result.s.Hi != 0 || Result.s.Lo > RT_BIT_64(a_cBitsWidth - 1)) \
1646 fEfl |= X86_EFL_CF | X86_EFL_OF; \
1647 a_fnNeg(Result, a_cBitsWidth2x); \
1648 } \
1649 } \
1650 else \
1651 { \
1652 if (!(uFactor2 & RT_BIT_64(a_cBitsWidth - 1))) \
1653 { \
1654 a_fnMul(Result, UINT ## a_cBitsWidth ## _C(0) - uFactor1, uFactor2, a_cBitsWidth2x); \
1655 if (Result.s.Hi != 0 || Result.s.Lo > RT_BIT_64(a_cBitsWidth - 1)) \
1656 fEfl |= X86_EFL_CF | X86_EFL_OF; \
1657 a_fnNeg(Result, a_cBitsWidth2x); \
1658 } \
1659 else \
1660 { \
1661 /*a_fnMul(Result, UINT ## a_cBitsWidth ## _C(0) - uFactor1, UINT ## a_cBitsWidth ## _C(0) - uFactor2, a_cBitsWidth2x);*/ \
1662 a_fnMul(Result, uFactor1, uFactor2, a_cBitsWidth2x); \
1663 if (Result.s.Hi != 0 || Result.s.Lo >= RT_BIT_64(a_cBitsWidth - 1)) \
1664 fEfl |= X86_EFL_CF | X86_EFL_OF; \
1665 } \
1666 } \
1667 a_fnStore(Result); \
1668 if (false) \
1669 { /* Intel (skylake) flags "undefined" behaviour: */ \
1670 fEfl &= ~(X86_EFL_AF | X86_EFL_ZF | X86_EFL_SF | X86_EFL_PF); \
1671 if (Result.s.Lo & RT_BIT_64(a_cBitsWidth - 1)) \
1672 fEfl |= X86_EFL_SF; \
1673 fEfl |= g_afParity[Result.s.Lo & 0xff]; \
1674 } \
1675 *pfEFlags = fEfl; \
1676 return 0; \
1677}
1678/** @todo Testcase: IMUL 2 and 3 operands. */
1679EMIT_IMUL(64, 128, (uint64_t *puA, uint64_t *puD, uint64_t uFactor2, uint32_t *pfEFlags), MUL_LOAD_F1, MUL_STORE, MULDIV_NEG_U128, MULDIV_MUL_U128)
1680# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
1681EMIT_IMUL(32, 64, (uint32_t *puA, uint32_t *puD, uint32_t uFactor2, uint32_t *pfEFlags), MUL_LOAD_F1, MUL_STORE, MULDIV_NEG, MULDIV_MUL)
1682EMIT_IMUL(16, 32, (uint16_t *puA, uint16_t *puD, uint16_t uFactor2, uint32_t *pfEFlags), MUL_LOAD_F1, MUL_STORE, MULDIV_NEG, MULDIV_MUL)
1683EMIT_IMUL(8, 16, (uint16_t *puAX, uint8_t uFactor2, uint32_t *pfEFlags), MUL_LOAD_F1_U8, MUL_STORE_U8, MULDIV_NEG, MULDIV_MUL)
1684# endif /* !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY) */
1685
1686
1687IEM_DECL_IMPL_DEF(void, iemAImpl_imul_two_u64,(uint64_t *puDst, uint64_t uSrc, uint32_t *pfEFlags))
1688{
1689 uint64_t uIgn;
1690 iemAImpl_imul_u64(puDst, &uIgn, uSrc, pfEFlags);
1691}
1692
1693# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
1694
1695IEM_DECL_IMPL_DEF(void, iemAImpl_imul_two_u32,(uint32_t *puDst, uint32_t uSrc, uint32_t *pfEFlags))
1696{
1697 uint32_t uIgn;
1698 iemAImpl_imul_u32(puDst, &uIgn, uSrc, pfEFlags);
1699}
1700
1701
1702IEM_DECL_IMPL_DEF(void, iemAImpl_imul_two_u16,(uint16_t *puDst, uint16_t uSrc, uint32_t *pfEFlags))
1703{
1704 uint16_t uIgn;
1705 iemAImpl_imul_u16(puDst, &uIgn, uSrc, pfEFlags);
1706}
1707
1708#endif
1709
1710/*
1711 * DIV
1712 */
1713# define EMIT_DIV(a_cBitsWidth, a_cBitsWidth2x, a_Args, a_fnLoad, a_fnStore, a_fnDivRem) \
1714IEM_DECL_IMPL_DEF(int, iemAImpl_div_u ## a_cBitsWidth,a_Args) \
1715{ \
1716 /* Note! Skylake leaves all flags alone. */ \
1717 RT_NOREF_PV(pfEFlags); \
1718 \
1719 RTUINT ## a_cBitsWidth2x ## U Dividend; \
1720 a_fnLoad(Dividend); \
1721 if ( uDivisor != 0 \
1722 && Dividend.s.Hi < uDivisor) \
1723 { \
1724 RTUINT ## a_cBitsWidth2x ## U Remainder, Quotient; \
1725 a_fnDivRem(Remainder, Quotient, Dividend, uDivisor); \
1726 a_fnStore(Quotient.s.Lo, Remainder.s.Lo); \
1727 /** @todo research the undefined DIV flags. */ \
1728 return 0; \
1729 } \
1730 /* #DE */ \
1731 return -1; \
1732}
1733EMIT_DIV(64,128,(uint64_t *puA, uint64_t *puD, uint64_t uDivisor, uint32_t *pfEFlags), DIV_LOAD, DIV_STORE, MULDIV_MODDIV_U128)
1734# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
1735EMIT_DIV(32,64, (uint32_t *puA, uint32_t *puD, uint32_t uDivisor, uint32_t *pfEFlags), DIV_LOAD, DIV_STORE, MULDIV_MODDIV)
1736EMIT_DIV(16,32, (uint16_t *puA, uint16_t *puD, uint16_t uDivisor, uint32_t *pfEFlags), DIV_LOAD, DIV_STORE, MULDIV_MODDIV)
1737EMIT_DIV(8,16, (uint16_t *puAX, uint8_t uDivisor, uint32_t *pfEFlags), DIV_LOAD_U8, DIV_STORE_U8, MULDIV_MODDIV)
1738# endif /* !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY) */
1739
1740
1741/*
1742 * IDIV
1743 */
1744# define EMIT_IDIV(a_cBitsWidth, a_cBitsWidth2x, a_Args, a_fnLoad, a_fnStore, a_fnNeg, a_fnDivRem) \
1745IEM_DECL_IMPL_DEF(int, iemAImpl_idiv_u ## a_cBitsWidth,a_Args) \
1746{ \
1747 /* Note! Skylake leaves all flags alone. */ \
1748 RT_NOREF_PV(pfEFlags); \
1749 \
1750 /** @todo overflow checks */ \
1751 if (uDivisor != 0) \
1752 { \
1753 /* \
1754 * Convert to unsigned division. \
1755 */ \
1756 RTUINT ## a_cBitsWidth2x ## U Dividend; \
1757 a_fnLoad(Dividend); \
1758 if ((int ## a_cBitsWidth ## _t)Dividend.s.Hi < 0) \
1759 a_fnNeg(Dividend, a_cBitsWidth2x); \
1760 \
1761 uint ## a_cBitsWidth ## _t uDivisorPositive; \
1762 if ((int ## a_cBitsWidth ## _t)uDivisor >= 0) \
1763 uDivisorPositive = uDivisor; \
1764 else \
1765 uDivisorPositive = UINT ## a_cBitsWidth ## _C(0) - uDivisor; \
1766 \
1767 RTUINT ## a_cBitsWidth2x ## U Remainder, Quotient; \
1768 a_fnDivRem(Remainder, Quotient, Dividend, uDivisorPositive); \
1769 \
1770 /* \
1771 * Setup the result, checking for overflows. \
1772 */ \
1773 if ((int ## a_cBitsWidth ## _t)uDivisor >= 0) \
1774 { \
1775 if ((int ## a_cBitsWidth ## _t)Dividend.s.Hi >= 0) \
1776 { \
1777 /* Positive divisor, positive dividend => result positive. */ \
1778 if (Quotient.s.Hi == 0 && Quotient.s.Lo <= (uint ## a_cBitsWidth ## _t)INT ## a_cBitsWidth ## _MAX) \
1779 { \
1780 a_fnStore(Quotient.s.Lo, Remainder.s.Lo); \
1781 return 0; \
1782 } \
1783 } \
1784 else \
1785 { \
1786 /* Positive divisor, positive dividend => result negative. */ \
1787 if (Quotient.s.Hi == 0 && Quotient.s.Lo <= RT_BIT_64(a_cBitsWidth - 1)) \
1788 { \
1789 a_fnStore(UINT ## a_cBitsWidth ## _C(0) - Quotient.s.Lo, UINT ## a_cBitsWidth ## _C(0) - Remainder.s.Lo); \
1790 return 0; \
1791 } \
1792 } \
1793 } \
1794 else \
1795 { \
1796 if ((int ## a_cBitsWidth ## _t)Dividend.s.Hi >= 0) \
1797 { \
1798 /* Negative divisor, positive dividend => negative quotient, positive remainder. */ \
1799 if (Quotient.s.Hi == 0 && Quotient.s.Lo <= RT_BIT_64(a_cBitsWidth - 1)) \
1800 { \
1801 a_fnStore(UINT ## a_cBitsWidth ## _C(0) - Quotient.s.Lo, Remainder.s.Lo); \
1802 return 0; \
1803 } \
1804 } \
1805 else \
1806 { \
1807 /* Negative divisor, negative dividend => positive quotient, negative remainder. */ \
1808 if (Quotient.s.Hi == 0 && Quotient.s.Lo <= (uint ## a_cBitsWidth ## _t)INT ## a_cBitsWidth ## _MAX) \
1809 { \
1810 a_fnStore(Quotient.s.Lo, UINT ## a_cBitsWidth ## _C(0) - Remainder.s.Lo); \
1811 return 0; \
1812 } \
1813 } \
1814 } \
1815 } \
1816 /* #DE */ \
1817 return -1; \
1818}
1819EMIT_IDIV(64,128,(uint64_t *puA, uint64_t *puD, uint64_t uDivisor, uint32_t *pfEFlags), DIV_LOAD, DIV_STORE, MULDIV_NEG_U128, MULDIV_MODDIV_U128)
1820# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
1821EMIT_IDIV(32,64,(uint32_t *puA, uint32_t *puD, uint32_t uDivisor, uint32_t *pfEFlags), DIV_LOAD, DIV_STORE, MULDIV_NEG, MULDIV_MODDIV)
1822EMIT_IDIV(16,32,(uint16_t *puA, uint16_t *puD, uint16_t uDivisor, uint32_t *pfEFlags), DIV_LOAD, DIV_STORE, MULDIV_NEG, MULDIV_MODDIV)
1823EMIT_IDIV(8,16,(uint16_t *puAX, uint8_t uDivisor, uint32_t *pfEFlags), DIV_LOAD_U8, DIV_STORE_U8, MULDIV_NEG, MULDIV_MODDIV)
1824# endif /* !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY) */
1825
1826
1827/*********************************************************************************************************************************
1828* Unary operations. *
1829*********************************************************************************************************************************/
1830
1831/**
1832 * Updates the status bits (CF, PF, AF, ZF, SF, and OF) for an INC or DEC instruction.
1833 *
1834 * CF is NOT modified for hysterical raisins (allegedly for carrying and
1835 * borrowing in arithmetic loops on intel 8008).
1836 *
1837 * @returns Status bits.
1838 * @param a_pfEFlags Pointer to the 32-bit EFLAGS value to update.
1839 * @param a_uResult Unsigned result value.
1840 * @param a_uDst The original destination value (for AF calc).
1841 * @param a_cBitsWidth The width of the result (8, 16, 32, 64).
1842 * @param a_OfMethod 0 for INC-style, 1 for DEC-style.
1843 */
1844#define IEM_EFL_UPDATE_STATUS_BITS_FOR_INC_DEC(a_pfEFlags, a_uResult, a_uDst, a_cBitsWidth, a_OfMethod) \
1845 do { \
1846 uint32_t fEflTmp = *(a_pfEFlags); \
1847 fEflTmp &= ~X86_EFL_STATUS_BITS & ~X86_EFL_CF; \
1848 fEflTmp |= g_afParity[(a_uResult) & 0xff]; \
1849 fEflTmp |= ((uint32_t)(a_uResult) ^ (uint32_t)(a_uDst)) & X86_EFL_AF; \
1850 fEflTmp |= X86_EFL_CALC_ZF(a_uResult); \
1851 fEflTmp |= X86_EFL_CALC_SF(a_uResult, a_cBitsWidth); \
1852 fEflTmp |= X86_EFL_GET_OF_ ## a_cBitsWidth(a_OfMethod == 0 ? (((a_uDst) ^ RT_BIT_64(63)) & (a_uResult)) \
1853 : ((a_uDst) & ((a_uResult) ^ RT_BIT_64(63))) ); \
1854 *(a_pfEFlags) = fEflTmp; \
1855 } while (0)
1856
1857/*
1858 * INC
1859 */
1860
1861IEM_DECL_IMPL_DEF(void, iemAImpl_inc_u64,(uint64_t *puDst, uint32_t *pfEFlags))
1862{
1863 uint64_t uDst = *puDst;
1864 uint64_t uResult = uDst + 1;
1865 *puDst = uResult;
1866 IEM_EFL_UPDATE_STATUS_BITS_FOR_INC_DEC(pfEFlags, uResult, uDst, 64, 0 /*INC*/);
1867}
1868
1869# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
1870
1871IEM_DECL_IMPL_DEF(void, iemAImpl_inc_u32,(uint32_t *puDst, uint32_t *pfEFlags))
1872{
1873 uint32_t uDst = *puDst;
1874 uint32_t uResult = uDst + 1;
1875 *puDst = uResult;
1876 IEM_EFL_UPDATE_STATUS_BITS_FOR_INC_DEC(pfEFlags, uResult, uDst, 32, 0 /*INC*/);
1877}
1878
1879
1880IEM_DECL_IMPL_DEF(void, iemAImpl_inc_u16,(uint16_t *puDst, uint32_t *pfEFlags))
1881{
1882 uint16_t uDst = *puDst;
1883 uint16_t uResult = uDst + 1;
1884 *puDst = uResult;
1885 IEM_EFL_UPDATE_STATUS_BITS_FOR_INC_DEC(pfEFlags, uResult, uDst, 16, 0 /*INC*/);
1886}
1887
1888IEM_DECL_IMPL_DEF(void, iemAImpl_inc_u8,(uint8_t *puDst, uint32_t *pfEFlags))
1889{
1890 uint8_t uDst = *puDst;
1891 uint8_t uResult = uDst + 1;
1892 *puDst = uResult;
1893 IEM_EFL_UPDATE_STATUS_BITS_FOR_INC_DEC(pfEFlags, uResult, uDst, 8, 0 /*INC*/);
1894}
1895
1896# endif /* !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY) */
1897
1898
1899/*
1900 * DEC
1901 */
1902
1903IEM_DECL_IMPL_DEF(void, iemAImpl_dec_u64,(uint64_t *puDst, uint32_t *pfEFlags))
1904{
1905 uint64_t uDst = *puDst;
1906 uint64_t uResult = uDst - 1;
1907 *puDst = uResult;
1908 IEM_EFL_UPDATE_STATUS_BITS_FOR_INC_DEC(pfEFlags, uResult, uDst, 64, 1 /*INC*/);
1909}
1910
1911# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
1912
1913IEM_DECL_IMPL_DEF(void, iemAImpl_dec_u32,(uint32_t *puDst, uint32_t *pfEFlags))
1914{
1915 uint32_t uDst = *puDst;
1916 uint32_t uResult = uDst - 1;
1917 *puDst = uResult;
1918 IEM_EFL_UPDATE_STATUS_BITS_FOR_INC_DEC(pfEFlags, uResult, uDst, 32, 1 /*INC*/);
1919}
1920
1921
1922IEM_DECL_IMPL_DEF(void, iemAImpl_dec_u16,(uint16_t *puDst, uint32_t *pfEFlags))
1923{
1924 uint16_t uDst = *puDst;
1925 uint16_t uResult = uDst - 1;
1926 *puDst = uResult;
1927 IEM_EFL_UPDATE_STATUS_BITS_FOR_INC_DEC(pfEFlags, uResult, uDst, 16, 1 /*INC*/);
1928}
1929
1930
1931IEM_DECL_IMPL_DEF(void, iemAImpl_dec_u8,(uint8_t *puDst, uint32_t *pfEFlags))
1932{
1933 uint8_t uDst = *puDst;
1934 uint8_t uResult = uDst - 1;
1935 *puDst = uResult;
1936 IEM_EFL_UPDATE_STATUS_BITS_FOR_INC_DEC(pfEFlags, uResult, uDst, 8, 1 /*INC*/);
1937}
1938
1939# endif /* !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY) */
1940
1941
1942/*
1943 * NOT
1944 */
1945
1946IEM_DECL_IMPL_DEF(void, iemAImpl_not_u64,(uint64_t *puDst, uint32_t *pfEFlags))
1947{
1948 uint64_t uDst = *puDst;
1949 uint64_t uResult = ~uDst;
1950 *puDst = uResult;
1951 /* EFLAGS are not modified. */
1952 RT_NOREF_PV(pfEFlags);
1953}
1954
1955# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
1956
1957IEM_DECL_IMPL_DEF(void, iemAImpl_not_u32,(uint32_t *puDst, uint32_t *pfEFlags))
1958{
1959 uint32_t uDst = *puDst;
1960 uint32_t uResult = ~uDst;
1961 *puDst = uResult;
1962 /* EFLAGS are not modified. */
1963 RT_NOREF_PV(pfEFlags);
1964}
1965
1966IEM_DECL_IMPL_DEF(void, iemAImpl_not_u16,(uint16_t *puDst, uint32_t *pfEFlags))
1967{
1968 uint16_t uDst = *puDst;
1969 uint16_t uResult = ~uDst;
1970 *puDst = uResult;
1971 /* EFLAGS are not modified. */
1972 RT_NOREF_PV(pfEFlags);
1973}
1974
1975IEM_DECL_IMPL_DEF(void, iemAImpl_not_u8,(uint8_t *puDst, uint32_t *pfEFlags))
1976{
1977 uint8_t uDst = *puDst;
1978 uint8_t uResult = ~uDst;
1979 *puDst = uResult;
1980 /* EFLAGS are not modified. */
1981 RT_NOREF_PV(pfEFlags);
1982}
1983
1984# endif /* !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY) */
1985
1986
1987/*
1988 * NEG
1989 */
1990
1991/**
1992 * Updates the status bits (CF, PF, AF, ZF, SF, and OF) for an NEG instruction.
1993 *
1994 * @returns Status bits.
1995 * @param a_pfEFlags Pointer to the 32-bit EFLAGS value to update.
1996 * @param a_uResult Unsigned result value.
1997 * @param a_uDst The original destination value (for AF calc).
1998 * @param a_cBitsWidth The width of the result (8, 16, 32, 64).
1999 */
2000#define IEM_EFL_UPDATE_STATUS_BITS_FOR_NEG(a_pfEFlags, a_uResult, a_uDst, a_cBitsWidth) \
2001 do { \
2002 uint32_t fEflTmp = *(a_pfEFlags); \
2003 fEflTmp &= ~X86_EFL_STATUS_BITS & ~X86_EFL_CF; \
2004 fEflTmp |= ((a_uDst) != 0) << X86_EFL_CF_BIT; \
2005 fEflTmp |= g_afParity[(a_uResult) & 0xff]; \
2006 fEflTmp |= ((uint32_t)(a_uResult) ^ (uint32_t)(a_uDst)) & X86_EFL_AF; \
2007 fEflTmp |= X86_EFL_CALC_ZF(a_uResult); \
2008 fEflTmp |= X86_EFL_CALC_SF(a_uResult, a_cBitsWidth); \
2009 fEflTmp |= X86_EFL_GET_OF_ ## a_cBitsWidth((a_uDst) & (a_uResult)); \
2010 *(a_pfEFlags) = fEflTmp; \
2011 } while (0)
2012
2013IEM_DECL_IMPL_DEF(void, iemAImpl_neg_u64,(uint64_t *puDst, uint32_t *pfEFlags))
2014{
2015 uint64_t uDst = *puDst;
2016 uint64_t uResult = (uint64_t)0 - uDst;
2017 *puDst = uResult;
2018 IEM_EFL_UPDATE_STATUS_BITS_FOR_NEG(pfEFlags, uResult, uDst, 64);
2019}
2020
2021# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
2022
2023IEM_DECL_IMPL_DEF(void, iemAImpl_neg_u32,(uint32_t *puDst, uint32_t *pfEFlags))
2024{
2025 uint32_t uDst = *puDst;
2026 uint32_t uResult = (uint32_t)0 - uDst;
2027 *puDst = uResult;
2028 IEM_EFL_UPDATE_STATUS_BITS_FOR_NEG(pfEFlags, uResult, uDst, 32);
2029}
2030
2031
2032IEM_DECL_IMPL_DEF(void, iemAImpl_neg_u16,(uint16_t *puDst, uint32_t *pfEFlags))
2033{
2034 uint16_t uDst = *puDst;
2035 uint16_t uResult = (uint16_t)0 - uDst;
2036 *puDst = uResult;
2037 IEM_EFL_UPDATE_STATUS_BITS_FOR_NEG(pfEFlags, uResult, uDst, 16);
2038}
2039
2040
2041IEM_DECL_IMPL_DEF(void, iemAImpl_neg_u8,(uint8_t *puDst, uint32_t *pfEFlags))
2042{
2043 uint8_t uDst = *puDst;
2044 uint8_t uResult = (uint8_t)0 - uDst;
2045 *puDst = uResult;
2046 IEM_EFL_UPDATE_STATUS_BITS_FOR_NEG(pfEFlags, uResult, uDst, 8);
2047}
2048
2049# endif /* !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY) */
2050
2051/*
2052 * Locked variants.
2053 */
2054
2055/** Emit a function for doing a locked unary operand operation. */
2056# define EMIT_LOCKED_UNARY_OP(a_Mnemonic, a_cBitsWidth) \
2057 IEM_DECL_IMPL_DEF(void, iemAImpl_ ## a_Mnemonic ## _u ## a_cBitsWidth ## _locked,(uint ## a_cBitsWidth ## _t *puDst, \
2058 uint32_t *pfEFlags)) \
2059 { \
2060 uint ## a_cBitsWidth ## _t uOld = ASMAtomicUoReadU ## a_cBitsWidth(puDst); \
2061 uint ## a_cBitsWidth ## _t uTmp; \
2062 uint32_t fEflTmp; \
2063 do \
2064 { \
2065 uTmp = uOld; \
2066 fEflTmp = *pfEFlags; \
2067 iemAImpl_ ## a_Mnemonic ## _u ## a_cBitsWidth(&uTmp, &fEflTmp); \
2068 } while (!ASMAtomicCmpXchgExU ## a_cBitsWidth(puDst, uTmp, uOld, &uOld)); \
2069 *pfEFlags = fEflTmp; \
2070 }
2071
2072EMIT_LOCKED_UNARY_OP(inc, 64)
2073EMIT_LOCKED_UNARY_OP(dec, 64)
2074EMIT_LOCKED_UNARY_OP(not, 64)
2075EMIT_LOCKED_UNARY_OP(neg, 64)
2076# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
2077EMIT_LOCKED_UNARY_OP(inc, 32)
2078EMIT_LOCKED_UNARY_OP(dec, 32)
2079EMIT_LOCKED_UNARY_OP(not, 32)
2080EMIT_LOCKED_UNARY_OP(neg, 32)
2081
2082EMIT_LOCKED_UNARY_OP(inc, 16)
2083EMIT_LOCKED_UNARY_OP(dec, 16)
2084EMIT_LOCKED_UNARY_OP(not, 16)
2085EMIT_LOCKED_UNARY_OP(neg, 16)
2086
2087EMIT_LOCKED_UNARY_OP(inc, 8)
2088EMIT_LOCKED_UNARY_OP(dec, 8)
2089EMIT_LOCKED_UNARY_OP(not, 8)
2090EMIT_LOCKED_UNARY_OP(neg, 8)
2091# endif
2092
2093
2094/*********************************************************************************************************************************
2095* Shifting and Rotating *
2096*********************************************************************************************************************************/
2097
2098/*
2099 * ROL
2100 */
2101
2102/**
2103 * Updates the status bits (OF and CF) for an ROL instruction.
2104 *
2105 * @returns Status bits.
2106 * @param a_pfEFlags Pointer to the 32-bit EFLAGS value to update.
2107 * @param a_uResult Unsigned result value.
2108 * @param a_cBitsWidth The width of the result (8, 16, 32, 64).
2109 */
2110#define IEM_EFL_UPDATE_STATUS_BITS_FOR_ROL(a_pfEFlags, a_uResult, a_cBitsWidth) do { \
2111 /* Calc EFLAGS. The OF bit is undefined if cShift > 1, we implement \
2112 it the same way as for 1 bit shifts. */ \
2113 AssertCompile(X86_EFL_CF_BIT == 0); \
2114 uint32_t fEflTmp = *(a_pfEFlags); \
2115 fEflTmp &= ~(X86_EFL_CF | X86_EFL_OF); \
2116 uint32_t const fCarry = ((a_uResult) & X86_EFL_CF); \
2117 fEflTmp |= fCarry; \
2118 fEflTmp |= (((a_uResult) >> (a_cBitsWidth - 1)) ^ fCarry) << X86_EFL_OF_BIT; \
2119 *(a_pfEFlags) = fEflTmp; \
2120 } while (0)
2121
2122IEM_DECL_IMPL_DEF(void, iemAImpl_rol_u64,(uint64_t *puDst, uint8_t cShift, uint32_t *pfEFlags))
2123{
2124 cShift &= 63;
2125 if (cShift)
2126 {
2127 uint64_t uResult = ASMRotateLeftU64(*puDst, cShift);
2128 *puDst = uResult;
2129 IEM_EFL_UPDATE_STATUS_BITS_FOR_ROL(pfEFlags, uResult, 64);
2130 }
2131}
2132
2133# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
2134
2135IEM_DECL_IMPL_DEF(void, iemAImpl_rol_u32,(uint32_t *puDst, uint8_t cShift, uint32_t *pfEFlags))
2136{
2137 cShift &= 31;
2138 if (cShift)
2139 {
2140 uint32_t uResult = ASMRotateLeftU32(*puDst, cShift);
2141 *puDst = uResult;
2142 IEM_EFL_UPDATE_STATUS_BITS_FOR_ROL(pfEFlags, uResult, 32);
2143 }
2144}
2145
2146
2147IEM_DECL_IMPL_DEF(void, iemAImpl_rol_u16,(uint16_t *puDst, uint8_t cShift, uint32_t *pfEFlags))
2148{
2149 cShift &= 15;
2150 if (cShift)
2151 {
2152 uint16_t uDst = *puDst;
2153 uint16_t uResult = (uDst << cShift) | (uDst >> (16 - cShift));
2154 *puDst = uResult;
2155 IEM_EFL_UPDATE_STATUS_BITS_FOR_ROL(pfEFlags, uResult, 16);
2156 }
2157}
2158
2159
2160IEM_DECL_IMPL_DEF(void, iemAImpl_rol_u8,(uint8_t *puDst, uint8_t cShift, uint32_t *pfEFlags))
2161{
2162 cShift &= 7;
2163 if (cShift)
2164 {
2165 uint8_t uDst = *puDst;
2166 uint8_t uResult = (uDst << cShift) | (uDst >> (8 - cShift));
2167 *puDst = uResult;
2168 IEM_EFL_UPDATE_STATUS_BITS_FOR_ROL(pfEFlags, uResult, 8);
2169 }
2170}
2171
2172# endif /* !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY) */
2173
2174
2175/*
2176 * ROR
2177 */
2178
2179/**
2180 * Updates the status bits (OF and CF) for an ROL instruction.
2181 *
2182 * @returns Status bits.
2183 * @param a_pfEFlags Pointer to the 32-bit EFLAGS value to update.
2184 * @param a_uResult Unsigned result value.
2185 * @param a_cBitsWidth The width of the result (8, 16, 32, 64).
2186 */
2187#define IEM_EFL_UPDATE_STATUS_BITS_FOR_ROR(a_pfEFlags, a_uResult, a_cBitsWidth) do { \
2188 /* Calc EFLAGS. The OF bit is undefined if cShift > 1, we implement \
2189 it the same way as for 1 bit shifts. */ \
2190 AssertCompile(X86_EFL_CF_BIT == 0); \
2191 uint32_t fEflTmp = *(a_pfEFlags); \
2192 fEflTmp &= ~(X86_EFL_CF | X86_EFL_OF); \
2193 uint32_t const fCarry = ((a_uResult) >> ((a_cBitsWidth) - 1)) & X86_EFL_CF; \
2194 fEflTmp |= fCarry; \
2195 fEflTmp |= (((a_uResult) >> ((a_cBitsWidth) - 2)) ^ fCarry) << X86_EFL_OF_BIT; \
2196 *(a_pfEFlags) = fEflTmp; \
2197 } while (0)
2198
2199IEM_DECL_IMPL_DEF(void, iemAImpl_ror_u64,(uint64_t *puDst, uint8_t cShift, uint32_t *pfEFlags))
2200{
2201 cShift &= 63;
2202 if (cShift)
2203 {
2204 uint64_t const uResult = ASMRotateRightU64(*puDst, cShift);
2205 *puDst = uResult;
2206 IEM_EFL_UPDATE_STATUS_BITS_FOR_ROR(pfEFlags, uResult, 64);
2207 }
2208}
2209
2210# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
2211
2212IEM_DECL_IMPL_DEF(void, iemAImpl_ror_u32,(uint32_t *puDst, uint8_t cShift, uint32_t *pfEFlags))
2213{
2214 cShift &= 31;
2215 if (cShift)
2216 {
2217 uint64_t const uResult = ASMRotateRightU32(*puDst, cShift);
2218 *puDst = uResult;
2219 IEM_EFL_UPDATE_STATUS_BITS_FOR_ROR(pfEFlags, uResult, 32);
2220 }
2221}
2222
2223
2224IEM_DECL_IMPL_DEF(void, iemAImpl_ror_u16,(uint16_t *puDst, uint8_t cShift, uint32_t *pfEFlags))
2225{
2226 cShift &= 15;
2227 if (cShift)
2228 {
2229 uint16_t uDst = *puDst;
2230 uint16_t uResult;
2231 uResult = uDst >> cShift;
2232 uResult |= uDst << (16 - cShift);
2233 *puDst = uResult;
2234 IEM_EFL_UPDATE_STATUS_BITS_FOR_ROR(pfEFlags, uResult, 16);
2235 }
2236}
2237
2238
2239IEM_DECL_IMPL_DEF(void, iemAImpl_ror_u8,(uint8_t *puDst, uint8_t cShift, uint32_t *pfEFlags))
2240{
2241 cShift &= 7;
2242 if (cShift)
2243 {
2244 uint8_t uDst = *puDst;
2245 uint8_t uResult;
2246 uResult = uDst >> cShift;
2247 uResult |= uDst << (8 - cShift);
2248 *puDst = uResult;
2249 IEM_EFL_UPDATE_STATUS_BITS_FOR_ROR(pfEFlags, uResult, 8);
2250 }
2251}
2252
2253# endif /* !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY) */
2254
2255
2256/*
2257 * RCL
2258 */
2259#define EMIT_RCL(a_cBitsWidth) \
2260IEM_DECL_IMPL_DEF(void, iemAImpl_rcl_u ## a_cBitsWidth,(uint ## a_cBitsWidth ## _t *puDst, uint8_t cShift, uint32_t *pfEFlags)) \
2261{ \
2262 cShift &= a_cBitsWidth - 1; \
2263 if (cShift) \
2264 { \
2265 uint ## a_cBitsWidth ## _t const uDst = *puDst; \
2266 uint ## a_cBitsWidth ## _t uResult = uDst << cShift; \
2267 if (cShift > 1) \
2268 uResult |= uDst >> (a_cBitsWidth + 1 - cShift); \
2269 \
2270 uint32_t fEfl = *pfEFlags; \
2271 AssertCompile(X86_EFL_CF_BIT == 0); \
2272 uResult |= (uint ## a_cBitsWidth ## _t)(fEfl & X86_EFL_CF) << (cShift - 1); \
2273 \
2274 *puDst = uResult; \
2275 \
2276 /* Calc EFLAGS. The OF bit is undefined if cShift > 1, we implement \
2277 it the same way as for 1 bit shifts. */ \
2278 fEfl &= ~(X86_EFL_CF | X86_EFL_OF); \
2279 uint32_t const fCarry = (uDst >> (a_cBitsWidth - cShift)) & X86_EFL_CF; \
2280 fEfl |= fCarry; \
2281 fEfl |= ((uResult >> (a_cBitsWidth - 1)) ^ fCarry) << X86_EFL_OF_BIT; \
2282 *pfEFlags = fEfl; \
2283 } \
2284}
2285EMIT_RCL(64)
2286# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
2287EMIT_RCL(32)
2288EMIT_RCL(16)
2289EMIT_RCL(8)
2290# endif
2291
2292
2293/*
2294 * RCR
2295 */
2296#define EMIT_RCR(a_cBitsWidth) \
2297IEM_DECL_IMPL_DEF(void, iemAImpl_rcr_u ## a_cBitsWidth,(uint ## a_cBitsWidth ##_t *puDst, uint8_t cShift, uint32_t *pfEFlags)) \
2298{ \
2299 cShift &= a_cBitsWidth - 1; \
2300 if (cShift) \
2301 { \
2302 uint ## a_cBitsWidth ## _t const uDst = *puDst; \
2303 uint ## a_cBitsWidth ## _t uResult = uDst >> cShift; \
2304 if (cShift > 1) \
2305 uResult |= uDst << (a_cBitsWidth + 1 - cShift); \
2306 \
2307 AssertCompile(X86_EFL_CF_BIT == 0); \
2308 uint32_t fEfl = *pfEFlags; \
2309 uResult |= (uint ## a_cBitsWidth ## _t)(fEfl & X86_EFL_CF) << (a_cBitsWidth - cShift); \
2310 *puDst = uResult; \
2311 \
2312 /* Calc EFLAGS. The OF bit is undefined if cShift > 1, we implement \
2313 it the same way as for 1 bit shifts. */ \
2314 fEfl &= ~(X86_EFL_CF | X86_EFL_OF); \
2315 uint32_t const fCarry = (uDst >> (cShift - 1)) & X86_EFL_CF; \
2316 fEfl |= fCarry; \
2317 fEfl |= ((uResult >> (a_cBitsWidth - 1)) ^ fCarry) << X86_EFL_OF_BIT; \
2318 *pfEFlags = fEfl; \
2319 } \
2320}
2321EMIT_RCR(64)
2322# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
2323EMIT_RCR(32)
2324EMIT_RCR(16)
2325EMIT_RCR(8)
2326# endif
2327
2328
2329/*
2330 * SHL
2331 */
2332#define EMIT_SHL(a_cBitsWidth) \
2333IEM_DECL_IMPL_DEF(void, iemAImpl_shl_u ## a_cBitsWidth,(uint ## a_cBitsWidth ## _t *puDst, uint8_t cShift, uint32_t *pfEFlags)) \
2334{ \
2335 cShift &= a_cBitsWidth - 1; \
2336 if (cShift) \
2337 { \
2338 uint ## a_cBitsWidth ##_t const uDst = *puDst; \
2339 uint ## a_cBitsWidth ##_t uResult = uDst << cShift; \
2340 *puDst = uResult; \
2341 \
2342 /* Calc EFLAGS. The OF bit is undefined if cShift > 1, we implement \
2343 it the same way as for 1 bit shifts. The AF bit is undefined, we \
2344 always set it to zero atm. */ \
2345 AssertCompile(X86_EFL_CF_BIT == 0); \
2346 uint32_t fEfl = *pfEFlags & ~X86_EFL_STATUS_BITS; \
2347 uint32_t fCarry = (uDst >> (a_cBitsWidth - cShift)) & X86_EFL_CF; \
2348 fEfl |= fCarry; \
2349 fEfl |= ((uResult >> (a_cBitsWidth - 1)) ^ fCarry) << X86_EFL_OF_BIT; \
2350 fEfl |= X86_EFL_CALC_SF(uResult, a_cBitsWidth); \
2351 fEfl |= X86_EFL_CALC_ZF(uResult); \
2352 fEfl |= g_afParity[uResult & 0xff]; \
2353 *pfEFlags = fEfl; \
2354 } \
2355}
2356EMIT_SHL(64)
2357# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
2358EMIT_SHL(32)
2359EMIT_SHL(16)
2360EMIT_SHL(8)
2361# endif
2362
2363
2364/*
2365 * SHR
2366 */
2367#define EMIT_SHR(a_cBitsWidth) \
2368IEM_DECL_IMPL_DEF(void, iemAImpl_shr_u ## a_cBitsWidth,(uint ## a_cBitsWidth ## _t *puDst, uint8_t cShift, uint32_t *pfEFlags)) \
2369{ \
2370 cShift &= a_cBitsWidth - 1; \
2371 if (cShift) \
2372 { \
2373 uint ## a_cBitsWidth ## _t const uDst = *puDst; \
2374 uint ## a_cBitsWidth ## _t uResult = uDst >> cShift; \
2375 *puDst = uResult; \
2376 \
2377 /* Calc EFLAGS. The OF bit is undefined if cShift > 1, we implement \
2378 it the same way as for 1 bit shifts. The AF bit is undefined, we \
2379 always set it to zero atm. */ \
2380 AssertCompile(X86_EFL_CF_BIT == 0); \
2381 uint32_t fEfl = *pfEFlags & ~X86_EFL_STATUS_BITS; \
2382 fEfl |= (uDst >> (cShift - 1)) & X86_EFL_CF; \
2383 fEfl |= (uDst >> (a_cBitsWidth - 1)) << X86_EFL_OF_BIT; \
2384 fEfl |= X86_EFL_CALC_SF(uResult, a_cBitsWidth); \
2385 fEfl |= X86_EFL_CALC_ZF(uResult); \
2386 fEfl |= g_afParity[uResult & 0xff]; \
2387 *pfEFlags = fEfl; \
2388 } \
2389}
2390EMIT_SHR(64)
2391# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
2392EMIT_SHR(32)
2393EMIT_SHR(16)
2394EMIT_SHR(8)
2395# endif
2396
2397
2398/*
2399 * SAR
2400 */
2401#define EMIT_SAR(a_cBitsWidth) \
2402IEM_DECL_IMPL_DEF(void, iemAImpl_sar_u ## a_cBitsWidth,(uint ## a_cBitsWidth ## _t *puDst, uint8_t cShift, uint32_t *pfEFlags)) \
2403{ \
2404 cShift &= a_cBitsWidth - 1; \
2405 if (cShift) \
2406 { \
2407 uint ## a_cBitsWidth ## _t const uDst = *puDst; \
2408 uint ## a_cBitsWidth ## _t uResult = (int ## a_cBitsWidth ## _t)uDst >> cShift; \
2409 *puDst = uResult; \
2410 \
2411 /* Calc EFLAGS. The OF bit is undefined if cShift > 1, we implement \
2412 it the same way as for 1 bit shifts (0). The AF bit is undefined, \
2413 we always set it to zero atm. */ \
2414 AssertCompile(X86_EFL_CF_BIT == 0); \
2415 uint32_t fEfl = *pfEFlags & ~X86_EFL_STATUS_BITS; \
2416 fEfl |= (uDst >> (cShift - 1)) & X86_EFL_CF; \
2417 fEfl |= X86_EFL_CALC_SF(uResult, a_cBitsWidth); \
2418 fEfl |= X86_EFL_CALC_ZF(uResult); \
2419 fEfl |= g_afParity[uResult & 0xff]; \
2420 *pfEFlags = fEfl; \
2421 } \
2422}
2423EMIT_SAR(64)
2424# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
2425EMIT_SAR(32)
2426EMIT_SAR(16)
2427EMIT_SAR(8)
2428# endif
2429
2430
2431/*
2432 * SHLD
2433 */
2434#define EMIT_SHLD(a_cBitsWidth) \
2435IEM_DECL_IMPL_DEF(void, iemAImpl_shld_u ## a_cBitsWidth,(uint ## a_cBitsWidth ## _t *puDst, \
2436 uint ## a_cBitsWidth ## _t uSrc, uint8_t cShift, uint32_t *pfEFlags)) \
2437{ \
2438 cShift &= a_cBitsWidth - 1; \
2439 if (cShift) \
2440 { \
2441 uint ## a_cBitsWidth ## _t const uDst = *puDst; \
2442 uint ## a_cBitsWidth ## _t uResult = uDst << cShift; \
2443 uResult |= uSrc >> (a_cBitsWidth - cShift); \
2444 *puDst = uResult; \
2445 \
2446 /* Calc EFLAGS. The OF bit is undefined if cShift > 1, we implement \
2447 it the same way as for 1 bit shifts. The AF bit is undefined, \
2448 we always set it to zero atm. */ \
2449 AssertCompile(X86_EFL_CF_BIT == 0); \
2450 uint32_t fEfl = *pfEFlags & ~X86_EFL_STATUS_BITS; \
2451 fEfl |= (uDst >> (a_cBitsWidth - cShift)) & X86_EFL_CF; \
2452 fEfl |= (uint32_t)((uDst >> (a_cBitsWidth - 1)) ^ (uint32_t)(uResult >> (a_cBitsWidth - 1))) << X86_EFL_OF_BIT; \
2453 fEfl |= X86_EFL_CALC_SF(uResult, a_cBitsWidth); \
2454 fEfl |= X86_EFL_CALC_ZF(uResult); \
2455 fEfl |= g_afParity[uResult & 0xff]; \
2456 *pfEFlags = fEfl; \
2457 } \
2458}
2459EMIT_SHLD(64)
2460# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
2461EMIT_SHLD(32)
2462EMIT_SHLD(16)
2463EMIT_SHLD(8)
2464# endif
2465
2466
2467/*
2468 * SHRD
2469 */
2470#define EMIT_SHRD(a_cBitsWidth) \
2471IEM_DECL_IMPL_DEF(void, iemAImpl_shrd_u ## a_cBitsWidth,(uint ## a_cBitsWidth ## _t *puDst, \
2472 uint ## a_cBitsWidth ## _t uSrc, uint8_t cShift, uint32_t *pfEFlags)) \
2473{ \
2474 cShift &= a_cBitsWidth - 1; \
2475 if (cShift) \
2476 { \
2477 uint ## a_cBitsWidth ## _t const uDst = *puDst; \
2478 uint ## a_cBitsWidth ## _t uResult = uDst >> cShift; \
2479 uResult |= uSrc << (a_cBitsWidth - cShift); \
2480 *puDst = uResult; \
2481 \
2482 /* Calc EFLAGS. The OF bit is undefined if cShift > 1, we implement \
2483 it the same way as for 1 bit shifts. The AF bit is undefined, \
2484 we always set it to zero atm. */ \
2485 AssertCompile(X86_EFL_CF_BIT == 0); \
2486 uint32_t fEfl = *pfEFlags & ~X86_EFL_STATUS_BITS; \
2487 fEfl |= (uDst >> (cShift - 1)) & X86_EFL_CF; \
2488 fEfl |= (uint32_t)((uDst >> (a_cBitsWidth - 1)) ^ (uint32_t)(uResult >> (a_cBitsWidth - 1))) << X86_EFL_OF_BIT; \
2489 fEfl |= X86_EFL_CALC_SF(uResult, a_cBitsWidth); \
2490 fEfl |= X86_EFL_CALC_ZF(uResult); \
2491 fEfl |= g_afParity[uResult & 0xff]; \
2492 *pfEFlags = fEfl; \
2493 } \
2494}
2495EMIT_SHRD(64)
2496# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
2497EMIT_SHRD(32)
2498EMIT_SHRD(16)
2499EMIT_SHRD(8)
2500# endif
2501
2502
2503# if !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY)
2504/*
2505 * BSWAP
2506 */
2507
2508IEM_DECL_IMPL_DEF(void, iemAImpl_bswap_u64,(uint64_t *puDst))
2509{
2510 *puDst = ASMByteSwapU64(*puDst);
2511}
2512
2513
2514IEM_DECL_IMPL_DEF(void, iemAImpl_bswap_u32,(uint32_t *puDst))
2515{
2516 *puDst = ASMByteSwapU32(*puDst);
2517}
2518
2519
2520/* Note! undocument, so 32-bit arg */
2521IEM_DECL_IMPL_DEF(void, iemAImpl_bswap_u16,(uint32_t *puDst))
2522{
2523 *puDst = ASMByteSwapU16((uint16_t)*puDst) | (*puDst & UINT32_C(0xffff0000));
2524}
2525
2526# endif /* !defined(RT_ARCH_X86) || defined(IEM_WITHOUT_ASSEMBLY) */
2527
2528
2529
2530# if defined(IEM_WITHOUT_ASSEMBLY)
2531
2532/*
2533 * LFENCE, SFENCE & MFENCE.
2534 */
2535
2536IEM_DECL_IMPL_DEF(void, iemAImpl_lfence,(void))
2537{
2538 ASMReadFence();
2539}
2540
2541
2542IEM_DECL_IMPL_DEF(void, iemAImpl_sfence,(void))
2543{
2544 ASMWriteFence();
2545}
2546
2547
2548IEM_DECL_IMPL_DEF(void, iemAImpl_mfence,(void))
2549{
2550 ASMMemoryFence();
2551}
2552
2553
2554# ifndef RT_ARCH_ARM64
2555IEM_DECL_IMPL_DEF(void, iemAImpl_alt_mem_fence,(void))
2556{
2557 ASMMemoryFence();
2558}
2559# endif
2560
2561# endif
2562
2563#endif /* !RT_ARCH_AMD64 || IEM_WITHOUT_ASSEMBLY */
2564
2565
2566IEM_DECL_IMPL_DEF(void, iemAImpl_arpl,(uint16_t *pu16Dst, uint16_t u16Src, uint32_t *pfEFlags))
2567{
2568 if ((*pu16Dst & X86_SEL_RPL) < (u16Src & X86_SEL_RPL))
2569 {
2570 *pu16Dst &= X86_SEL_MASK_OFF_RPL;
2571 *pu16Dst |= u16Src & X86_SEL_RPL;
2572
2573 *pfEFlags |= X86_EFL_ZF;
2574 }
2575 else
2576 *pfEFlags &= ~X86_EFL_ZF;
2577}
2578
2579
2580/*********************************************************************************************************************************
2581* x87 FPU *
2582*********************************************************************************************************************************/
2583#if defined(IEM_WITHOUT_ASSEMBLY)
2584
2585IEM_DECL_IMPL_DEF(void, iemAImpl_f2xm1_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, PCRTFLOAT80U pr80Val))
2586{
2587 RT_NOREF(pFpuState, pFpuRes, pr80Val);
2588 AssertReleaseFailed();
2589}
2590
2591
2592IEM_DECL_IMPL_DEF(void, iemAImpl_fabs_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, PCRTFLOAT80U pr80Val))
2593{
2594 RT_NOREF(pFpuState, pFpuRes, pr80Val);
2595 AssertReleaseFailed();
2596}
2597
2598
2599IEM_DECL_IMPL_DEF(void, iemAImpl_fadd_r80_by_r32,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
2600 PCRTFLOAT80U pr80Val1, PCRTFLOAT32U pr32Val2))
2601{
2602 RT_NOREF(pFpuState, pFpuRes, pr80Val1, pr32Val2);
2603 AssertReleaseFailed();
2604}
2605
2606
2607IEM_DECL_IMPL_DEF(void, iemAImpl_fadd_r80_by_r64,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
2608 PCRTFLOAT80U pr80Val1, PCRTFLOAT64U pr64Val2))
2609{
2610 RT_NOREF(pFpuState, pFpuRes, pr80Val1, pr64Val2);
2611 AssertReleaseFailed();
2612}
2613
2614
2615IEM_DECL_IMPL_DEF(void, iemAImpl_fadd_r80_by_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
2616 PCRTFLOAT80U pr80Val1, PCRTFLOAT80U pr80Val2))
2617{
2618 RT_NOREF(pFpuState, pFpuRes, pr80Val1, pr80Val2);
2619 AssertReleaseFailed();
2620}
2621
2622
2623IEM_DECL_IMPL_DEF(void, iemAImpl_fchs_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, PCRTFLOAT80U pr80Val))
2624{
2625 RT_NOREF(pFpuState, pFpuRes, pr80Val);
2626 AssertReleaseFailed();
2627}
2628
2629
2630IEM_DECL_IMPL_DEF(void, iemAImpl_fcom_r80_by_r32,(PCX86FXSTATE pFpuState, uint16_t *pFSW,
2631 PCRTFLOAT80U pr80Val1, PCRTFLOAT32U pr32Val2))
2632{
2633 RT_NOREF(pFpuState, pFSW, pr80Val1, pr32Val2);
2634 AssertReleaseFailed();
2635}
2636
2637
2638IEM_DECL_IMPL_DEF(void, iemAImpl_fcom_r80_by_r64,(PCX86FXSTATE pFpuState, uint16_t *pFSW,
2639 PCRTFLOAT80U pr80Val1, PCRTFLOAT64U pr64Val2))
2640{
2641 RT_NOREF(pFpuState, pFSW, pr80Val1, pr64Val2);
2642 AssertReleaseFailed();
2643}
2644
2645
2646IEM_DECL_IMPL_DEF(void, iemAImpl_fcom_r80_by_r80,(PCX86FXSTATE pFpuState, uint16_t *pFSW,
2647 PCRTFLOAT80U pr80Val1, PCRTFLOAT80U pr80Val2))
2648{
2649 RT_NOREF(pFpuState, pFSW, pr80Val1, pr80Val2);
2650 AssertReleaseFailed();
2651}
2652
2653
2654IEM_DECL_IMPL_DEF(uint32_t, iemAImpl_fcomi_r80_by_r80,(PCX86FXSTATE pFpuState, uint16_t *pFSW,
2655 PCRTFLOAT80U pr80Val1, PCRTFLOAT80U pr80Val2))
2656{
2657 RT_NOREF(pFpuState, pFSW, pr80Val1, pr80Val2);
2658 AssertReleaseFailed();
2659 return 0;
2660}
2661
2662
2663IEM_DECL_IMPL_DEF(void, iemAImpl_fcos_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, PCRTFLOAT80U pr80Val))
2664{
2665 RT_NOREF(pFpuState, pFpuRes, pr80Val);
2666 AssertReleaseFailed();
2667}
2668
2669
2670IEM_DECL_IMPL_DEF(void, iemAImpl_fdiv_r80_by_r32,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
2671 PCRTFLOAT80U pr80Val1, PCRTFLOAT32U pr32Val2))
2672{
2673 RT_NOREF(pFpuState, pFpuRes, pr80Val1, pr32Val2);
2674 AssertReleaseFailed();
2675}
2676
2677
2678IEM_DECL_IMPL_DEF(void, iemAImpl_fdiv_r80_by_r64,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
2679 PCRTFLOAT80U pr80Val1, PCRTFLOAT64U pr64Val2))
2680{
2681 RT_NOREF(pFpuState, pFpuRes, pr80Val1, pr64Val2);
2682 AssertReleaseFailed();
2683}
2684
2685
2686IEM_DECL_IMPL_DEF(void, iemAImpl_fdiv_r80_by_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
2687 PCRTFLOAT80U pr80Val1, PCRTFLOAT80U pr80Val2))
2688{
2689 RT_NOREF(pFpuState, pFpuRes, pr80Val1, pr80Val2);
2690 AssertReleaseFailed();
2691}
2692
2693
2694IEM_DECL_IMPL_DEF(void, iemAImpl_fdivr_r80_by_r32,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
2695 PCRTFLOAT80U pr80Val1, PCRTFLOAT32U pr32Val2))
2696{
2697 RT_NOREF(pFpuState, pFpuRes, pr80Val1, pr32Val2);
2698 AssertReleaseFailed();
2699}
2700
2701
2702IEM_DECL_IMPL_DEF(void, iemAImpl_fdivr_r80_by_r64,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
2703 PCRTFLOAT80U pr80Val1, PCRTFLOAT64U pr64Val2))
2704{
2705 RT_NOREF(pFpuState, pFpuRes, pr80Val1, pr64Val2);
2706 AssertReleaseFailed();
2707}
2708
2709
2710IEM_DECL_IMPL_DEF(void, iemAImpl_fdivr_r80_by_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
2711 PCRTFLOAT80U pr80Val1, PCRTFLOAT80U pr80Val2))
2712{
2713 RT_NOREF(pFpuState, pFpuRes, pr80Val1, pr80Val2);
2714 AssertReleaseFailed();
2715}
2716
2717
2718IEM_DECL_IMPL_DEF(void, iemAImpl_fiadd_r80_by_i16,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
2719 PCRTFLOAT80U pr80Val1, int16_t const *pi16Val2))
2720{
2721 RT_NOREF(pFpuState, pFpuRes, pr80Val1, pi16Val2);
2722 AssertReleaseFailed();
2723}
2724
2725
2726IEM_DECL_IMPL_DEF(void, iemAImpl_fiadd_r80_by_i32,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
2727 PCRTFLOAT80U pr80Val1, int32_t const *pi32Val2))
2728{
2729 RT_NOREF(pFpuState, pFpuRes, pr80Val1, pi32Val2);
2730 AssertReleaseFailed();
2731}
2732
2733
2734IEM_DECL_IMPL_DEF(void, iemAImpl_ficom_r80_by_i16,(PCX86FXSTATE pFpuState, uint16_t *pu16Fsw,
2735 PCRTFLOAT80U pr80Val1, int16_t const *pi16Val2))
2736{
2737 RT_NOREF(pFpuState, pu16Fsw, pr80Val1, pi16Val2);
2738 AssertReleaseFailed();
2739}
2740
2741
2742IEM_DECL_IMPL_DEF(void, iemAImpl_ficom_r80_by_i32,(PCX86FXSTATE pFpuState, uint16_t *pu16Fsw,
2743 PCRTFLOAT80U pr80Val1, int32_t const *pi32Val2))
2744{
2745 RT_NOREF(pFpuState, pu16Fsw, pr80Val1, pi32Val2);
2746 AssertReleaseFailed();
2747}
2748
2749
2750IEM_DECL_IMPL_DEF(void, iemAImpl_fidiv_r80_by_i16,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
2751 PCRTFLOAT80U pr80Val1, int16_t const *pi16Val2))
2752{
2753 RT_NOREF(pFpuState, pFpuRes, pr80Val1, pi16Val2);
2754 AssertReleaseFailed();
2755}
2756
2757
2758IEM_DECL_IMPL_DEF(void, iemAImpl_fidiv_r80_by_i32,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
2759 PCRTFLOAT80U pr80Val1, int32_t const *pi32Val2))
2760{
2761 RT_NOREF(pFpuState, pFpuRes, pr80Val1, pi32Val2);
2762 AssertReleaseFailed();
2763}
2764
2765
2766IEM_DECL_IMPL_DEF(void, iemAImpl_fidivr_r80_by_i16,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
2767 PCRTFLOAT80U pr80Val1, int16_t const *pi16Val2))
2768{
2769 RT_NOREF(pFpuState, pFpuRes, pr80Val1, pi16Val2);
2770 AssertReleaseFailed();
2771}
2772
2773
2774IEM_DECL_IMPL_DEF(void, iemAImpl_fidivr_r80_by_i32,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
2775 PCRTFLOAT80U pr80Val1, int32_t const *pi32Val2))
2776{
2777 RT_NOREF(pFpuState, pFpuRes, pr80Val1, pi32Val2);
2778 AssertReleaseFailed();
2779}
2780
2781
2782IEM_DECL_IMPL_DEF(void, iemAImpl_fild_i16_to_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, int16_t const *pi16Val))
2783{
2784 RT_NOREF(pFpuState, pFpuRes, pi16Val);
2785 AssertReleaseFailed();
2786}
2787
2788
2789IEM_DECL_IMPL_DEF(void, iemAImpl_fild_i32_to_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, int32_t const *pi32Val))
2790{
2791 RT_NOREF(pFpuState, pFpuRes, pi32Val);
2792 AssertReleaseFailed();
2793}
2794
2795
2796IEM_DECL_IMPL_DEF(void, iemAImpl_fild_i64_to_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, int64_t const *pi64Val))
2797{
2798 RT_NOREF(pFpuState, pFpuRes, pi64Val);
2799 AssertReleaseFailed();
2800}
2801
2802
2803IEM_DECL_IMPL_DEF(void, iemAImpl_fimul_r80_by_i16,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
2804 PCRTFLOAT80U pr80Val1, int16_t const *pi16Val2))
2805{
2806 RT_NOREF(pFpuState, pFpuRes, pr80Val1, pi16Val2);
2807 AssertReleaseFailed();
2808}
2809
2810
2811IEM_DECL_IMPL_DEF(void, iemAImpl_fimul_r80_by_i32,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
2812 PCRTFLOAT80U pr80Val1, int32_t const *pi32Val2))
2813{
2814 RT_NOREF(pFpuState, pFpuRes, pr80Val1, pi32Val2);
2815 AssertReleaseFailed();
2816}
2817
2818
2819IEM_DECL_IMPL_DEF(void, iemAImpl_fist_r80_to_i16,(PCX86FXSTATE pFpuState, uint16_t *pu16FSW,
2820 int16_t *pi16Val, PCRTFLOAT80U pr80Val))
2821{
2822 RT_NOREF(pFpuState, pu16FSW, pi16Val, pr80Val);
2823 AssertReleaseFailed();
2824}
2825
2826
2827IEM_DECL_IMPL_DEF(void, iemAImpl_fist_r80_to_i32,(PCX86FXSTATE pFpuState, uint16_t *pu16FSW,
2828 int32_t *pi32Val, PCRTFLOAT80U pr80Val))
2829{
2830 RT_NOREF(pFpuState, pu16FSW, pi32Val, pr80Val);
2831 AssertReleaseFailed();
2832}
2833
2834
2835IEM_DECL_IMPL_DEF(void, iemAImpl_fist_r80_to_i64,(PCX86FXSTATE pFpuState, uint16_t *pu16FSW,
2836 int64_t *pi64Val, PCRTFLOAT80U pr80Val))
2837{
2838 RT_NOREF(pFpuState, pu16FSW, pi64Val, pr80Val);
2839 AssertReleaseFailed();
2840}
2841
2842
2843IEM_DECL_IMPL_DEF(void, iemAImpl_fistt_r80_to_i16,(PCX86FXSTATE pFpuState, uint16_t *pu16FSW,
2844 int16_t *pi16Val, PCRTFLOAT80U pr80Val))
2845{
2846 RT_NOREF(pFpuState, pu16FSW, pi16Val, pr80Val);
2847 AssertReleaseFailed();
2848}
2849
2850
2851IEM_DECL_IMPL_DEF(void, iemAImpl_fistt_r80_to_i32,(PCX86FXSTATE pFpuState, uint16_t *pu16FSW,
2852 int32_t *pi32Val, PCRTFLOAT80U pr80Val))
2853{
2854 RT_NOREF(pFpuState, pu16FSW, pi32Val, pr80Val);
2855 AssertReleaseFailed();
2856}
2857
2858
2859IEM_DECL_IMPL_DEF(void, iemAImpl_fistt_r80_to_i64,(PCX86FXSTATE pFpuState, uint16_t *pu16FSW,
2860 int64_t *pi64Val, PCRTFLOAT80U pr80Val))
2861{
2862 RT_NOREF(pFpuState, pu16FSW, pi64Val, pr80Val);
2863 AssertReleaseFailed();
2864}
2865
2866
2867IEM_DECL_IMPL_DEF(void, iemAImpl_fisub_r80_by_i16,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
2868 PCRTFLOAT80U pr80Val1, int16_t const *pi16Val2))
2869{
2870 RT_NOREF(pFpuState, pFpuRes, pr80Val1, pi16Val2);
2871 AssertReleaseFailed();
2872}
2873
2874
2875IEM_DECL_IMPL_DEF(void, iemAImpl_fisub_r80_by_i32,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
2876 PCRTFLOAT80U pr80Val1, int32_t const *pi32Val2))
2877{
2878 RT_NOREF(pFpuState, pFpuRes, pr80Val1, pi32Val2);
2879 AssertReleaseFailed();
2880}
2881
2882
2883IEM_DECL_IMPL_DEF(void, iemAImpl_fisubr_r80_by_i16,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
2884 PCRTFLOAT80U pr80Val1, int16_t const *pi16Val2))
2885{
2886 RT_NOREF(pFpuState, pFpuRes, pr80Val1, pi16Val2);
2887 AssertReleaseFailed();
2888}
2889
2890
2891IEM_DECL_IMPL_DEF(void, iemAImpl_fisubr_r80_by_i32,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
2892 PCRTFLOAT80U pr80Val1, int32_t const *pi32Val2))
2893{
2894 RT_NOREF(pFpuState, pFpuRes, pr80Val1, pi32Val2);
2895 AssertReleaseFailed();
2896}
2897
2898
2899IEM_DECL_IMPL_DEF(void, iemAImpl_fld_r32_to_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, PCRTFLOAT32U pr32Val))
2900{
2901 RT_NOREF(pFpuState, pFpuRes, pr32Val);
2902 AssertReleaseFailed();
2903}
2904
2905
2906IEM_DECL_IMPL_DEF(void, iemAImpl_fld_r64_to_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, PCRTFLOAT64U pr64Val))
2907{
2908 RT_NOREF(pFpuState, pFpuRes, pr64Val);
2909 AssertReleaseFailed();
2910}
2911
2912IEM_DECL_IMPL_DEF(void, iemAImpl_fld_r80_from_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, PCRTFLOAT80U pr80Val))
2913{
2914 RT_NOREF(pFpuState, pFpuRes, pr80Val);
2915 AssertReleaseFailed();
2916}
2917
2918
2919IEM_DECL_IMPL_DEF(void, iemAImpl_fld1,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes))
2920{
2921 RT_NOREF(pFpuState, pFpuRes);
2922 AssertReleaseFailed();
2923}
2924
2925
2926IEM_DECL_IMPL_DEF(void, iemAImpl_fldl2e,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes))
2927{
2928 RT_NOREF(pFpuState, pFpuRes);
2929 AssertReleaseFailed();
2930}
2931
2932
2933IEM_DECL_IMPL_DEF(void, iemAImpl_fldl2t,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes))
2934{
2935 RT_NOREF(pFpuState, pFpuRes);
2936 AssertReleaseFailed();
2937}
2938
2939
2940IEM_DECL_IMPL_DEF(void, iemAImpl_fldlg2,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes))
2941{
2942 RT_NOREF(pFpuState, pFpuRes);
2943 AssertReleaseFailed();
2944}
2945
2946
2947IEM_DECL_IMPL_DEF(void, iemAImpl_fldln2,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes))
2948{
2949 RT_NOREF(pFpuState, pFpuRes);
2950 AssertReleaseFailed();
2951}
2952
2953
2954IEM_DECL_IMPL_DEF(void, iemAImpl_fldpi,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes))
2955{
2956 RT_NOREF(pFpuState, pFpuRes);
2957 AssertReleaseFailed();
2958}
2959
2960
2961IEM_DECL_IMPL_DEF(void, iemAImpl_fldz,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes))
2962{
2963 RT_NOREF(pFpuState, pFpuRes);
2964 AssertReleaseFailed();
2965}
2966
2967
2968IEM_DECL_IMPL_DEF(void, iemAImpl_fmul_r80_by_r32,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
2969 PCRTFLOAT80U pr80Val1, PCRTFLOAT32U pr32Val2))
2970{
2971 RT_NOREF(pFpuState, pFpuRes, pr80Val1, pr32Val2);
2972 AssertReleaseFailed();
2973}
2974
2975
2976IEM_DECL_IMPL_DEF(void, iemAImpl_fmul_r80_by_r64,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
2977 PCRTFLOAT80U pr80Val1, PCRTFLOAT64U pr64Val2))
2978{
2979 RT_NOREF(pFpuState, pFpuRes, pr80Val1, pr64Val2);
2980 AssertReleaseFailed();
2981}
2982
2983
2984IEM_DECL_IMPL_DEF(void, iemAImpl_fmul_r80_by_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
2985 PCRTFLOAT80U pr80Val1, PCRTFLOAT80U pr80Val2))
2986{
2987 RT_NOREF(pFpuState, pFpuRes, pr80Val1, pr80Val2);
2988 AssertReleaseFailed();
2989}
2990
2991
2992IEM_DECL_IMPL_DEF(void, iemAImpl_fpatan_r80_by_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
2993 PCRTFLOAT80U pr80Val1, PCRTFLOAT80U pr80Val2))
2994{
2995 RT_NOREF(pFpuState, pFpuRes, pr80Val1, pr80Val2);
2996 AssertReleaseFailed();
2997}
2998
2999
3000IEM_DECL_IMPL_DEF(void, iemAImpl_fprem_r80_by_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
3001 PCRTFLOAT80U pr80Val1, PCRTFLOAT80U pr80Val2))
3002{
3003 RT_NOREF(pFpuState, pFpuRes, pr80Val1, pr80Val2);
3004 AssertReleaseFailed();
3005}
3006
3007
3008IEM_DECL_IMPL_DEF(void, iemAImpl_fprem1_r80_by_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
3009 PCRTFLOAT80U pr80Val1, PCRTFLOAT80U pr80Val2))
3010{
3011 RT_NOREF(pFpuState, pFpuRes, pr80Val1, pr80Val2);
3012 AssertReleaseFailed();
3013}
3014
3015
3016IEM_DECL_IMPL_DEF(void, iemAImpl_fptan_r80_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULTTWO pFpuResTwo, PCRTFLOAT80U pr80Val))
3017{
3018 RT_NOREF(pFpuState, pFpuResTwo, pr80Val);
3019 AssertReleaseFailed();
3020}
3021
3022
3023IEM_DECL_IMPL_DEF(void, iemAImpl_frndint_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, PCRTFLOAT80U pr80Val))
3024{
3025 RT_NOREF(pFpuState, pFpuRes, pr80Val);
3026 AssertReleaseFailed();
3027}
3028
3029
3030IEM_DECL_IMPL_DEF(void, iemAImpl_fscale_r80_by_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
3031 PCRTFLOAT80U pr80Val1, PCRTFLOAT80U pr80Val2))
3032{
3033 RT_NOREF(pFpuState, pFpuRes, pr80Val1, pr80Val2);
3034 AssertReleaseFailed();
3035}
3036
3037
3038IEM_DECL_IMPL_DEF(void, iemAImpl_fsin_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, PCRTFLOAT80U pr80Val))
3039{
3040 RT_NOREF(pFpuState, pFpuRes, pr80Val);
3041 AssertReleaseFailed();
3042}
3043
3044
3045IEM_DECL_IMPL_DEF(void, iemAImpl_fsincos_r80_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULTTWO pFpuResTwo, PCRTFLOAT80U pr80Val))
3046{
3047 RT_NOREF(pFpuState, pFpuResTwo, pr80Val);
3048 AssertReleaseFailed();
3049}
3050
3051
3052IEM_DECL_IMPL_DEF(void, iemAImpl_fsqrt_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, PCRTFLOAT80U pr80Val))
3053{
3054 RT_NOREF(pFpuState, pFpuRes, pr80Val);
3055 AssertReleaseFailed();
3056}
3057
3058
3059IEM_DECL_IMPL_DEF(void, iemAImpl_fst_r80_to_r32,(PCX86FXSTATE pFpuState, uint16_t *pu16FSW,
3060 PRTFLOAT32U pr32Dst, PCRTFLOAT80U pr80Src))
3061{
3062 RT_NOREF(pFpuState, pu16FSW, pr32Dst, pr80Src);
3063 AssertReleaseFailed();
3064}
3065
3066
3067IEM_DECL_IMPL_DEF(void, iemAImpl_fst_r80_to_r64,(PCX86FXSTATE pFpuState, uint16_t *pu16FSW,
3068 PRTFLOAT64U pr64Dst, PCRTFLOAT80U pr80Src))
3069{
3070 RT_NOREF(pFpuState, pu16FSW, pr64Dst, pr80Src);
3071 AssertReleaseFailed();
3072}
3073
3074
3075IEM_DECL_IMPL_DEF(void, iemAImpl_fst_r80_to_r80,(PCX86FXSTATE pFpuState, uint16_t *pu16FSW,
3076 PRTFLOAT80U pr80Dst, PCRTFLOAT80U pr80Src))
3077{
3078 RT_NOREF(pFpuState, pu16FSW, pr80Dst, pr80Src);
3079 AssertReleaseFailed();
3080}
3081
3082
3083IEM_DECL_IMPL_DEF(void, iemAImpl_fsub_r80_by_r32,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
3084 PCRTFLOAT80U pr80Val1, PCRTFLOAT32U pr32Val2))
3085{
3086 RT_NOREF(pFpuState, pFpuRes, pr80Val1, pr32Val2);
3087 AssertReleaseFailed();
3088}
3089
3090
3091IEM_DECL_IMPL_DEF(void, iemAImpl_fsub_r80_by_r64,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
3092 PCRTFLOAT80U pr80Val1, PCRTFLOAT64U pr64Val2))
3093{
3094 RT_NOREF(pFpuState, pFpuRes, pr80Val1, pr64Val2);
3095 AssertReleaseFailed();
3096}
3097
3098
3099IEM_DECL_IMPL_DEF(void, iemAImpl_fsub_r80_by_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
3100 PCRTFLOAT80U pr80Val1, PCRTFLOAT80U pr80Val2))
3101{
3102 RT_NOREF(pFpuState, pFpuRes, pr80Val1, pr80Val2);
3103 AssertReleaseFailed();
3104}
3105
3106
3107IEM_DECL_IMPL_DEF(void, iemAImpl_fsubr_r80_by_r32,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
3108 PCRTFLOAT80U pr80Val1, PCRTFLOAT32U pr32Val2))
3109{
3110 RT_NOREF(pFpuState, pFpuRes, pr80Val1, pr32Val2);
3111 AssertReleaseFailed();
3112}
3113
3114
3115IEM_DECL_IMPL_DEF(void, iemAImpl_fsubr_r80_by_r64,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
3116 PCRTFLOAT80U pr80Val1, PCRTFLOAT64U pr64Val2))
3117{
3118 RT_NOREF(pFpuState, pFpuRes, pr80Val1, pr64Val2);
3119 AssertReleaseFailed();
3120}
3121
3122
3123IEM_DECL_IMPL_DEF(void, iemAImpl_fsubr_r80_by_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
3124 PCRTFLOAT80U pr80Val1, PCRTFLOAT80U pr80Val2))
3125{
3126 RT_NOREF(pFpuState, pFpuRes, pr80Val1, pr80Val2);
3127 AssertReleaseFailed();
3128}
3129
3130
3131IEM_DECL_IMPL_DEF(void, iemAImpl_ftst_r80,(PCX86FXSTATE pFpuState, uint16_t *pu16Fsw, PCRTFLOAT80U pr80Val))
3132{
3133 RT_NOREF(pFpuState, pu16Fsw, pr80Val);
3134 AssertReleaseFailed();
3135}
3136
3137
3138IEM_DECL_IMPL_DEF(void, iemAImpl_fucom_r80_by_r80,(PCX86FXSTATE pFpuState, uint16_t *pFSW,
3139 PCRTFLOAT80U pr80Val1, PCRTFLOAT80U pr80Val2))
3140{
3141 RT_NOREF(pFpuState, pFSW, pr80Val1, pr80Val2);
3142 AssertReleaseFailed();
3143}
3144
3145
3146IEM_DECL_IMPL_DEF(uint32_t, iemAImpl_fucomi_r80_by_r80,(PCX86FXSTATE pFpuState, uint16_t *pu16Fsw,
3147 PCRTFLOAT80U pr80Val1, PCRTFLOAT80U pr80Val2))
3148{
3149 RT_NOREF(pFpuState, pu16Fsw, pr80Val1, pr80Val2);
3150 AssertReleaseFailed();
3151 return 0;
3152}
3153
3154
3155IEM_DECL_IMPL_DEF(void, iemAImpl_fxam_r80,(PCX86FXSTATE pFpuState, uint16_t *pu16Fsw, PCRTFLOAT80U pr80Val))
3156{
3157 RT_NOREF(pFpuState, pu16Fsw, pr80Val);
3158 AssertReleaseFailed();
3159}
3160
3161
3162IEM_DECL_IMPL_DEF(void, iemAImpl_fxtract_r80_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULTTWO pFpuResTwo, PCRTFLOAT80U pr80Val))
3163{
3164 RT_NOREF(pFpuState, pFpuResTwo, pr80Val);
3165 AssertReleaseFailed();
3166}
3167
3168
3169IEM_DECL_IMPL_DEF(void, iemAImpl_fyl2x_r80_by_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
3170 PCRTFLOAT80U pr80Val1, PCRTFLOAT80U pr80Val2))
3171{
3172 RT_NOREF(pFpuState, pFpuRes, pr80Val1, pr80Val2);
3173 AssertReleaseFailed();
3174}
3175
3176
3177IEM_DECL_IMPL_DEF(void, iemAImpl_fyl2xp1_r80_by_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
3178 PCRTFLOAT80U pr80Val1, PCRTFLOAT80U pr80Val2))
3179{
3180 RT_NOREF(pFpuState, pFpuRes, pr80Val1, pr80Val2);
3181 AssertReleaseFailed();
3182}
3183
3184#endif /* IEM_WITHOUT_ASSEMBLY */
3185
3186
3187/*********************************************************************************************************************************
3188* MMX, SSE & AVX *
3189*********************************************************************************************************************************/
3190
3191IEM_DECL_IMPL_DEF(void, iemAImpl_movsldup,(PCX86FXSTATE pFpuState, PRTUINT128U puDst, PCRTUINT128U puSrc))
3192{
3193 RT_NOREF(pFpuState);
3194 puDst->au32[0] = puSrc->au32[0];
3195 puDst->au32[1] = puSrc->au32[0];
3196 puDst->au32[2] = puSrc->au32[2];
3197 puDst->au32[3] = puSrc->au32[2];
3198}
3199
3200#ifdef IEM_WITH_VEX
3201
3202IEM_DECL_IMPL_DEF(void, iemAImpl_vmovsldup_256_rr,(PX86XSAVEAREA pXState, uint8_t iYRegDst, uint8_t iYRegSrc))
3203{
3204 pXState->x87.aXMM[iYRegDst].au32[0] = pXState->x87.aXMM[iYRegSrc].au32[0];
3205 pXState->x87.aXMM[iYRegDst].au32[1] = pXState->x87.aXMM[iYRegSrc].au32[0];
3206 pXState->x87.aXMM[iYRegDst].au32[2] = pXState->x87.aXMM[iYRegSrc].au32[2];
3207 pXState->x87.aXMM[iYRegDst].au32[3] = pXState->x87.aXMM[iYRegSrc].au32[2];
3208 pXState->u.YmmHi.aYmmHi[iYRegDst].au32[0] = pXState->u.YmmHi.aYmmHi[iYRegSrc].au32[0];
3209 pXState->u.YmmHi.aYmmHi[iYRegDst].au32[1] = pXState->u.YmmHi.aYmmHi[iYRegSrc].au32[0];
3210 pXState->u.YmmHi.aYmmHi[iYRegDst].au32[2] = pXState->u.YmmHi.aYmmHi[iYRegSrc].au32[2];
3211 pXState->u.YmmHi.aYmmHi[iYRegDst].au32[3] = pXState->u.YmmHi.aYmmHi[iYRegSrc].au32[2];
3212}
3213
3214
3215IEM_DECL_IMPL_DEF(void, iemAImpl_vmovsldup_256_rm,(PX86XSAVEAREA pXState, uint8_t iYRegDst, PCRTUINT256U pSrc))
3216{
3217 pXState->x87.aXMM[iYRegDst].au32[0] = pSrc->au32[0];
3218 pXState->x87.aXMM[iYRegDst].au32[1] = pSrc->au32[0];
3219 pXState->x87.aXMM[iYRegDst].au32[2] = pSrc->au32[2];
3220 pXState->x87.aXMM[iYRegDst].au32[3] = pSrc->au32[2];
3221 pXState->u.YmmHi.aYmmHi[iYRegDst].au32[0] = pSrc->au32[4];
3222 pXState->u.YmmHi.aYmmHi[iYRegDst].au32[1] = pSrc->au32[4];
3223 pXState->u.YmmHi.aYmmHi[iYRegDst].au32[2] = pSrc->au32[6];
3224 pXState->u.YmmHi.aYmmHi[iYRegDst].au32[3] = pSrc->au32[6];
3225}
3226
3227#endif /* IEM_WITH_VEX */
3228
3229
3230IEM_DECL_IMPL_DEF(void, iemAImpl_movshdup,(PCX86FXSTATE pFpuState, PRTUINT128U puDst, PCRTUINT128U puSrc))
3231{
3232 RT_NOREF(pFpuState);
3233 puDst->au32[0] = puSrc->au32[1];
3234 puDst->au32[1] = puSrc->au32[1];
3235 puDst->au32[2] = puSrc->au32[3];
3236 puDst->au32[3] = puSrc->au32[3];
3237}
3238
3239
3240IEM_DECL_IMPL_DEF(void, iemAImpl_movddup,(PCX86FXSTATE pFpuState, PRTUINT128U puDst, uint64_t uSrc))
3241{
3242 RT_NOREF(pFpuState);
3243 puDst->au64[0] = uSrc;
3244 puDst->au64[1] = uSrc;
3245}
3246
3247#ifdef IEM_WITH_VEX
3248
3249IEM_DECL_IMPL_DEF(void, iemAImpl_vmovddup_256_rr,(PX86XSAVEAREA pXState, uint8_t iYRegDst, uint8_t iYRegSrc))
3250{
3251 pXState->x87.aXMM[iYRegDst].au64[0] = pXState->x87.aXMM[iYRegSrc].au64[0];
3252 pXState->x87.aXMM[iYRegDst].au64[1] = pXState->x87.aXMM[iYRegSrc].au64[0];
3253 pXState->u.YmmHi.aYmmHi[iYRegDst].au64[0] = pXState->u.YmmHi.aYmmHi[iYRegSrc].au64[0];
3254 pXState->u.YmmHi.aYmmHi[iYRegDst].au64[1] = pXState->u.YmmHi.aYmmHi[iYRegSrc].au64[0];
3255}
3256
3257IEM_DECL_IMPL_DEF(void, iemAImpl_vmovddup_256_rm,(PX86XSAVEAREA pXState, uint8_t iYRegDst, PCRTUINT256U pSrc))
3258{
3259 pXState->x87.aXMM[iYRegDst].au64[0] = pSrc->au64[0];
3260 pXState->x87.aXMM[iYRegDst].au64[1] = pSrc->au64[0];
3261 pXState->u.YmmHi.aYmmHi[iYRegDst].au64[0] = pSrc->au64[2];
3262 pXState->u.YmmHi.aYmmHi[iYRegDst].au64[1] = pSrc->au64[2];
3263}
3264
3265#endif /* IEM_WITH_VEX */
3266
3267#ifdef IEM_WITHOUT_ASSEMBLY
3268
3269IEM_DECL_IMPL_DEF(void, iemAImpl_pcmpeqb_u64,(PCX86FXSTATE pFpuState, uint64_t *pu64Dst, uint64_t const *pu64Src))
3270{
3271 RT_NOREF(pFpuState, pu64Dst, pu64Src);
3272 AssertReleaseFailed();
3273}
3274
3275
3276IEM_DECL_IMPL_DEF(void, iemAImpl_pcmpeqb_u128,(PCX86FXSTATE pFpuState, PRTUINT128U pu128Dst, PCRTUINT128U pu128Src))
3277{
3278 RT_NOREF(pFpuState, pu128Dst, pu128Src);
3279 AssertReleaseFailed();
3280}
3281
3282
3283IEM_DECL_IMPL_DEF(void, iemAImpl_pcmpeqw_u64,(PCX86FXSTATE pFpuState, uint64_t *pu64Dst, uint64_t const *pu64Src))
3284{
3285 RT_NOREF(pFpuState, pu64Dst, pu64Src);
3286 AssertReleaseFailed();
3287}
3288
3289
3290IEM_DECL_IMPL_DEF(void, iemAImpl_pcmpeqw_u128,(PCX86FXSTATE pFpuState, PRTUINT128U pu128Dst, PCRTUINT128U pu128Src))
3291{
3292 RT_NOREF(pFpuState, pu128Dst, pu128Src);
3293 AssertReleaseFailed();
3294}
3295
3296
3297IEM_DECL_IMPL_DEF(void, iemAImpl_pcmpeqd_u64,(PCX86FXSTATE pFpuState, uint64_t *pu64Dst, uint64_t const *pu64Src))
3298{
3299 RT_NOREF(pFpuState, pu64Dst, pu64Src);
3300 AssertReleaseFailed();
3301}
3302
3303
3304IEM_DECL_IMPL_DEF(void, iemAImpl_pcmpeqd_u128,(PCX86FXSTATE pFpuState, PRTUINT128U pu128Dst, PCRTUINT128U pu128Src))
3305{
3306 RT_NOREF(pFpuState, pu128Dst, pu128Src);
3307 AssertReleaseFailed();
3308}
3309
3310
3311IEM_DECL_IMPL_DEF(void, iemAImpl_pxor_u64,(PCX86FXSTATE pFpuState, uint64_t *pu64Dst, uint64_t const *pu64Src))
3312{
3313 RT_NOREF(pFpuState, pu64Dst, pu64Src);
3314 AssertReleaseFailed();
3315}
3316
3317
3318IEM_DECL_IMPL_DEF(void, iemAImpl_pxor_u128,(PCX86FXSTATE pFpuState, PRTUINT128U pu128Dst, PCRTUINT128U pu128Src))
3319{
3320 RT_NOREF(pFpuState, pu128Dst, pu128Src);
3321 AssertReleaseFailed();
3322}
3323
3324
3325IEM_DECL_IMPL_DEF(void, iemAImpl_pmovmskb_u64,(PCX86FXSTATE pFpuState, uint64_t *pu64Dst, uint64_t const *pu64Src))
3326{
3327 RT_NOREF(pFpuState, pu64Dst, pu64Src);
3328 AssertReleaseFailed();
3329
3330}
3331
3332
3333IEM_DECL_IMPL_DEF(void, iemAImpl_pmovmskb_u128,(PCX86FXSTATE pFpuState, uint64_t *pu64Dst, PCRTUINT128U pu128Src))
3334{
3335 RT_NOREF(pFpuState, pu64Dst, pu128Src);
3336 AssertReleaseFailed();
3337}
3338
3339
3340IEM_DECL_IMPL_DEF(void, iemAImpl_pshufw,(PCX86FXSTATE pFpuState, uint64_t *pu64Dst, uint64_t const *pu64Src, uint8_t bEvil))
3341{
3342 RT_NOREF(pFpuState, pu64Dst, pu64Src, bEvil);
3343 AssertReleaseFailed();
3344}
3345
3346
3347IEM_DECL_IMPL_DEF(void, iemAImpl_pshufhw,(PCX86FXSTATE pFpuState, PRTUINT128U pu128Dst, PCRTUINT128U pu128Src, uint8_t bEvil))
3348{
3349 RT_NOREF(pFpuState, pu128Dst, pu128Src, bEvil);
3350 AssertReleaseFailed();
3351}
3352
3353
3354IEM_DECL_IMPL_DEF(void, iemAImpl_pshuflw,(PCX86FXSTATE pFpuState, PRTUINT128U pu128Dst, PCRTUINT128U pu128Src, uint8_t bEvil))
3355{
3356 RT_NOREF(pFpuState, pu128Dst, pu128Src, bEvil);
3357 AssertReleaseFailed();
3358}
3359
3360
3361IEM_DECL_IMPL_DEF(void, iemAImpl_pshufd,(PCX86FXSTATE pFpuState, PRTUINT128U pu128Dst, PCRTUINT128U pu128Src, uint8_t bEvil))
3362{
3363 RT_NOREF(pFpuState, pu128Dst, pu128Src, bEvil);
3364 AssertReleaseFailed();
3365}
3366
3367/* PUNPCKHxxx */
3368
3369IEM_DECL_IMPL_DEF(void, iemAImpl_punpckhbw_u64,(PCX86FXSTATE pFpuState, uint64_t *pu64Dst, uint64_t const *pu64Src))
3370{
3371 RT_NOREF(pFpuState, pu64Dst, pu64Src);
3372 AssertReleaseFailed();
3373}
3374
3375
3376IEM_DECL_IMPL_DEF(void, iemAImpl_punpckhbw_u128,(PCX86FXSTATE pFpuState, PRTUINT128U pu128Dst, PCRTUINT128U pu128Src))
3377{
3378 RT_NOREF(pFpuState, pu128Dst, pu128Src);
3379 AssertReleaseFailed();
3380}
3381
3382
3383IEM_DECL_IMPL_DEF(void, iemAImpl_punpckhwd_u64,(PCX86FXSTATE pFpuState, uint64_t *pu64Dst, uint64_t const *pu64Src))
3384{
3385 RT_NOREF(pFpuState, pu64Dst, pu64Src);
3386 AssertReleaseFailed();
3387}
3388
3389
3390IEM_DECL_IMPL_DEF(void, iemAImpl_punpckhwd_u128,(PCX86FXSTATE pFpuState, PRTUINT128U pu128Dst, PCRTUINT128U pu128Src))
3391{
3392 RT_NOREF(pFpuState, pu128Dst, pu128Src);
3393 AssertReleaseFailed();
3394}
3395
3396
3397IEM_DECL_IMPL_DEF(void, iemAImpl_punpckhdq_u64,(PCX86FXSTATE pFpuState, uint64_t *pu64Dst, uint64_t const *pu64Src))
3398{
3399 RT_NOREF(pFpuState, pu64Dst, pu64Src);
3400 AssertReleaseFailed();
3401}
3402
3403
3404IEM_DECL_IMPL_DEF(void, iemAImpl_punpckhdq_u128,(PCX86FXSTATE pFpuState, PRTUINT128U pu128Dst, PCRTUINT128U pu128Src))
3405{
3406 RT_NOREF(pFpuState, pu128Dst, pu128Src);
3407 AssertReleaseFailed();
3408}
3409
3410
3411IEM_DECL_IMPL_DEF(void, iemAImpl_punpckhqdq_u128,(PCX86FXSTATE pFpuState, PRTUINT128U pu128Dst, PCRTUINT128U pu128Src))
3412{
3413 RT_NOREF(pFpuState, pu128Dst, pu128Src);
3414 AssertReleaseFailed();
3415}
3416
3417/* PUNPCKLxxx */
3418
3419IEM_DECL_IMPL_DEF(void, iemAImpl_punpcklbw_u64,(PCX86FXSTATE pFpuState, uint64_t *pu64Dst, uint32_t const *pu32Src))
3420{
3421 RT_NOREF(pFpuState, pu64Dst, pu32Src);
3422 AssertReleaseFailed();
3423}
3424
3425
3426IEM_DECL_IMPL_DEF(void, iemAImpl_punpcklbw_u128,(PCX86FXSTATE pFpuState, PRTUINT128U pu128Dst, uint64_t const *pu64Src))
3427{
3428 RT_NOREF(pFpuState, pu128Dst, pu64Src);
3429 AssertReleaseFailed();
3430}
3431
3432
3433IEM_DECL_IMPL_DEF(void, iemAImpl_punpcklwd_u64,(PCX86FXSTATE pFpuState, uint64_t *pu64Dst, uint32_t const *pu32Src))
3434{
3435 RT_NOREF(pFpuState, pu64Dst, pu32Src);
3436 AssertReleaseFailed();
3437}
3438
3439
3440IEM_DECL_IMPL_DEF(void, iemAImpl_punpcklwd_u128,(PCX86FXSTATE pFpuState, PRTUINT128U pu128Dst, uint64_t const *pu64Src))
3441{
3442 RT_NOREF(pFpuState, pu128Dst, pu64Src);
3443 AssertReleaseFailed();
3444}
3445
3446
3447IEM_DECL_IMPL_DEF(void, iemAImpl_punpckldq_u64,(PCX86FXSTATE pFpuState, uint64_t *pu64Dst, uint32_t const *pu32Src))
3448{
3449 RT_NOREF(pFpuState, pu64Dst, pu32Src);
3450 AssertReleaseFailed();
3451}
3452
3453
3454IEM_DECL_IMPL_DEF(void, iemAImpl_punpckldq_u128,(PCX86FXSTATE pFpuState, PRTUINT128U pu128Dst, uint64_t const *pu64Src))
3455{
3456 RT_NOREF(pFpuState, pu128Dst, pu64Src);
3457 AssertReleaseFailed();
3458}
3459
3460
3461IEM_DECL_IMPL_DEF(void, iemAImpl_punpcklqdq_u128,(PCX86FXSTATE pFpuState, PRTUINT128U pu128Dst, uint64_t const *pu64Src))
3462{
3463 RT_NOREF(pFpuState, pu128Dst, pu64Src);
3464 AssertReleaseFailed();
3465}
3466
3467#endif /* IEM_WITHOUT_ASSEMBLY */
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