VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMAll/IEMAllInstructionsCommonBodyMacros.h@ 100061

Last change on this file since 100061 was 98916, checked in by vboxsync, 21 months ago

VMM/IEM: More work on processing MC blocks, mainly related to reworking common functions for binary operations into body macros. bugref:10369

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.8 KB
Line 
1/* $Id: IEMAllInstructionsCommonBodyMacros.h 98916 2023-03-12 01:27:21Z 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 IEMAllInstructionsPython.py prior processing
7 * any of the other IEMAllInstruction*.cpp.h files. For instance
8 * IEMAllInstructionsCommon.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_fnNormalU16, a_fnNormalU32, a_fnNormalU64, a_fModifiesDstReg) \
42 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm); \
43 \
44 /* \
45 * If rm is denoting a register, no more instruction bytes. \
46 */ \
47 if (IEM_IS_MODRM_REG_MODE(bRm)) \
48 { \
49 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); \
50 switch (pVCpu->iem.s.enmEffOpSize) \
51 { \
52 case IEMMODE_16BIT: \
53 IEM_MC_BEGIN(3, 0); \
54 IEM_MC_ARG(uint16_t *, pu16Dst, 0); \
55 IEM_MC_ARG(uint16_t, u16Src, 1); \
56 IEM_MC_ARG(uint32_t *, pEFlags, 2); \
57 \
58 IEM_MC_FETCH_GREG_U16(u16Src, IEM_GET_MODRM_RM(pVCpu, bRm)); \
59 IEM_MC_REF_GREG_U16(pu16Dst, IEM_GET_MODRM_REG(pVCpu, bRm)); \
60 IEM_MC_REF_EFLAGS(pEFlags); \
61 IEM_MC_CALL_VOID_AIMPL_3(a_fnNormalU16, pu16Dst, u16Src, pEFlags); \
62 \
63 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
64 IEM_MC_END(); \
65 break; \
66 \
67 case IEMMODE_32BIT: \
68 IEM_MC_BEGIN(3, 0); \
69 IEM_MC_ARG(uint32_t *, pu32Dst, 0); \
70 IEM_MC_ARG(uint32_t, u32Src, 1); \
71 IEM_MC_ARG(uint32_t *, pEFlags, 2); \
72 \
73 IEM_MC_FETCH_GREG_U32(u32Src, IEM_GET_MODRM_RM(pVCpu, bRm)); \
74 IEM_MC_REF_GREG_U32(pu32Dst, IEM_GET_MODRM_REG(pVCpu, bRm)); \
75 IEM_MC_REF_EFLAGS(pEFlags); \
76 IEM_MC_CALL_VOID_AIMPL_3(a_fnNormalU32, pu32Dst, u32Src, pEFlags); \
77 \
78 if (a_fModifiesDstReg) \
79 IEM_MC_CLEAR_HIGH_GREG_U64_BY_REF(pu32Dst); \
80 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
81 IEM_MC_END(); \
82 break; \
83 \
84 case IEMMODE_64BIT: \
85 IEM_MC_BEGIN(3, 0); \
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, bRm)); \
91 IEM_MC_REF_GREG_U64(pu64Dst, IEM_GET_MODRM_REG(pVCpu, 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); \
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, 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, 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); \
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, 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, 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_BY_REF(pu32Dst); \
143 IEM_MC_ADVANCE_RIP_AND_FINISH(); \
144 IEM_MC_END(); \
145 break; \
146 \
147 case IEMMODE_64BIT: \
148 IEM_MC_BEGIN(3, 1); \
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, 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, 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