VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMAll/IEMAllInstCommonBodyMacros.h@ 103548

Last change on this file since 103548 was 103548, checked in by vboxsync, 9 months ago

VMM/IEM: Special case the 'xor reg32,samereg32' operation as it it fairly command and allows for easy EFLAGS optimizations (hardcoded). bugref:10376

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.1 KB
Line 
1/* $Id: IEMAllInstCommonBodyMacros.h 103548 2024-02-23 15:32:19Z vboxsync $ */
2/** @file
3 * IEM - Instruction Decoding and Emulation, Common Body Macros.
4 *
5 * This is placed in its own file without anything else in it, so that it can
6 * be digested by SimplerParser in IEMAllInstPython.py prior processing
7 * any of the other IEMAllInstruction*.cpp.h files. For instance
8 * IEMAllInstCommon.cpp.h wouldn't do as it defines several invalid
9 * instructions and such that could confuse the parser result.
10 */
11
12/*
13 * Copyright (C) 2011-2023 Oracle and/or its affiliates.
14 *
15 * This file is part of VirtualBox base platform packages, as
16 * available from https://www.virtualbox.org.
17 *
18 * This program is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU General Public License
20 * as published by the Free Software Foundation, in version 3 of the
21 * License.
22 *
23 * This program is distributed in the hope that it will be useful, but
24 * WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26 * General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, see <https://www.gnu.org/licenses>.
30 *
31 * SPDX-License-Identifier: GPL-3.0-only
32 */
33
34
35/**
36 * Body for word/dword/qword instructions like ADD, AND, OR, ++ with a register
37 * as the destination.
38 *
39 * @note Used both in OneByte and TwoByte0f.
40 */
41#define IEMOP_BODY_BINARY_rv_rm(a_bRm, a_fnNormalU16, a_fnNormalU32, a_fnNormalU64, a_fModifiesDstReg, a_f16BitMcFlag) \
42 /* \
43 * If rm is denoting a register, no more instruction bytes. \
44 */ \
45 if (IEM_IS_MODRM_REG_MODE(a_bRm)) \
46 { \
47 switch (pVCpu->iem.s.enmEffOpSize) \
48 { \
49 case IEMMODE_16BIT: \
50 IEM_MC_BEGIN(3, 0, a_f16BitMcFlag, 0); \
51 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); \
52 IEM_MC_ARG(uint16_t *, pu16Dst, 0); \
53 IEM_MC_ARG(uint16_t, u16Src, 1); \
54 IEM_MC_ARG(uint32_t *, pEFlags, 2); \
55 \
56 IEM_MC_FETCH_GREG_U16(u16Src, IEM_GET_MODRM_RM(pVCpu, a_bRm)); \
57 IEM_MC_REF_GREG_U16(pu16Dst, IEM_GET_MODRM_REG(pVCpu, a_bRm)); \
58 IEM_MC_REF_EFLAGS(pEFlags); \
59 IEM_MC_CALL_VOID_AIMPL_3(a_fnNormalU16, pu16Dst, u16Src, pEFlags); \
60 \
61 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
62 IEM_MC_END(); \
63 break; \
64 \
65 case IEMMODE_32BIT: \
66 IEM_MC_BEGIN(3, 0, IEM_MC_F_MIN_386, 0); \
67 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); \
68 IEM_MC_ARG(uint32_t *, pu32Dst, 0); \
69 IEM_MC_ARG(uint32_t, u32Src, 1); \
70 IEM_MC_ARG(uint32_t *, pEFlags, 2); \
71 \
72 IEM_MC_FETCH_GREG_U32(u32Src, IEM_GET_MODRM_RM(pVCpu, a_bRm)); \
73 IEM_MC_REF_GREG_U32(pu32Dst, IEM_GET_MODRM_REG(pVCpu, a_bRm)); \
74 IEM_MC_REF_EFLAGS(pEFlags); \
75 IEM_MC_CALL_VOID_AIMPL_3(a_fnNormalU32, pu32Dst, u32Src, pEFlags); \
76 \
77 if (a_fModifiesDstReg) \
78 IEM_MC_CLEAR_HIGH_GREG_U64(IEM_GET_MODRM_REG(pVCpu, a_bRm)); \
79 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
80 IEM_MC_END(); \
81 break; \
82 \
83 case IEMMODE_64BIT: \
84 IEM_MC_BEGIN(3, 0, IEM_MC_F_64BIT, 0); \
85 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); \
86 IEM_MC_ARG(uint64_t *, pu64Dst, 0); \
87 IEM_MC_ARG(uint64_t, u64Src, 1); \
88 IEM_MC_ARG(uint32_t *, pEFlags, 2); \
89 \
90 IEM_MC_FETCH_GREG_U64(u64Src, IEM_GET_MODRM_RM(pVCpu, a_bRm)); \
91 IEM_MC_REF_GREG_U64(pu64Dst, IEM_GET_MODRM_REG(pVCpu, a_bRm)); \
92 IEM_MC_REF_EFLAGS(pEFlags); \
93 IEM_MC_CALL_VOID_AIMPL_3(a_fnNormalU64, pu64Dst, u64Src, pEFlags); \
94 \
95 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
96 IEM_MC_END(); \
97 break; \
98 \
99 IEM_NOT_REACHED_DEFAULT_CASE_RET(); \
100 } \
101 } \
102 else \
103 { \
104 /* \
105 * We're accessing memory. \
106 */ \
107 switch (pVCpu->iem.s.enmEffOpSize) \
108 { \
109 case IEMMODE_16BIT: \
110 IEM_MC_BEGIN(3, 1, a_f16BitMcFlag, 0); \
111 IEM_MC_ARG(uint16_t *, pu16Dst, 0); \
112 IEM_MC_ARG(uint16_t, u16Src, 1); \
113 IEM_MC_ARG(uint32_t *, pEFlags, 2); \
114 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst); \
115 \
116 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, a_bRm, 0); \
117 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); \
118 IEM_MC_FETCH_MEM_U16(u16Src, pVCpu->iem.s.iEffSeg, GCPtrEffDst); \
119 IEM_MC_REF_GREG_U16(pu16Dst, IEM_GET_MODRM_REG(pVCpu, a_bRm)); \
120 IEM_MC_REF_EFLAGS(pEFlags); \
121 IEM_MC_CALL_VOID_AIMPL_3(a_fnNormalU16, pu16Dst, u16Src, pEFlags); \
122 \
123 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
124 IEM_MC_END(); \
125 break; \
126 \
127 case IEMMODE_32BIT: \
128 IEM_MC_BEGIN(3, 1, IEM_MC_F_MIN_386, 0); \
129 IEM_MC_ARG(uint32_t *, pu32Dst, 0); \
130 IEM_MC_ARG(uint32_t, u32Src, 1); \
131 IEM_MC_ARG(uint32_t *, pEFlags, 2); \
132 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst); \
133 \
134 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, a_bRm, 0); \
135 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); \
136 IEM_MC_FETCH_MEM_U32(u32Src, pVCpu->iem.s.iEffSeg, GCPtrEffDst); \
137 IEM_MC_REF_GREG_U32(pu32Dst, IEM_GET_MODRM_REG(pVCpu, a_bRm)); \
138 IEM_MC_REF_EFLAGS(pEFlags); \
139 IEM_MC_CALL_VOID_AIMPL_3(a_fnNormalU32, pu32Dst, u32Src, pEFlags); \
140 \
141 if (a_fModifiesDstReg) \
142 IEM_MC_CLEAR_HIGH_GREG_U64(IEM_GET_MODRM_REG(pVCpu, a_bRm)); \
143 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
144 IEM_MC_END(); \
145 break; \
146 \
147 case IEMMODE_64BIT: \
148 IEM_MC_BEGIN(3, 1, IEM_MC_F_64BIT, 0); \
149 IEM_MC_ARG(uint64_t *, pu64Dst, 0); \
150 IEM_MC_ARG(uint64_t, u64Src, 1); \
151 IEM_MC_ARG(uint32_t *, pEFlags, 2); \
152 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst); \
153 \
154 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, a_bRm, 0); \
155 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); \
156 IEM_MC_FETCH_MEM_U64(u64Src, pVCpu->iem.s.iEffSeg, GCPtrEffDst); \
157 IEM_MC_REF_GREG_U64(pu64Dst, IEM_GET_MODRM_REG(pVCpu, a_bRm)); \
158 IEM_MC_REF_EFLAGS(pEFlags); \
159 IEM_MC_CALL_VOID_AIMPL_3(a_fnNormalU64, pu64Dst, u64Src, pEFlags); \
160 \
161 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
162 IEM_MC_END(); \
163 break; \
164 \
165 IEM_NOT_REACHED_DEFAULT_CASE_RET(); \
166 } \
167 } \
168 (void)0
169
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