[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH v2 17/39] target/i386: introduce helpers for dec
From: |
Jan Bobek |
Subject: |
[Qemu-devel] [RFC PATCH v2 17/39] target/i386: introduce helpers for decoding modrm fields |
Date: |
Sat, 10 Aug 2019 00:12:33 -0400 |
The old code uses bitshifts and bitwise-and all over the place for
decoding ModR/M fields. Avoid doing that by introducing proper
decoding macros.
Signed-off-by: Jan Bobek <address@hidden>
---
target/i386/translate.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/target/i386/translate.c b/target/i386/translate.c
index 109e4922eb..4a2dae6238 100644
--- a/target/i386/translate.c
+++ b/target/i386/translate.c
@@ -4500,6 +4500,21 @@ static void gen_sse(CPUX86State *env, DisasContext *s,
int b)
#define tcg_gen_gvec_cmpgt(vece, dofs, aofs, bofs, oprsz, maxsz) \
tcg_gen_gvec_cmp(TCG_COND_GT, vece, dofs, aofs, bofs, oprsz, maxsz)
+#define decode_modrm_mod(env, s, modrm) \
+ (((modrm) >> 6) & 3)
+
+#define decode_modrm_reg_norexr(env, s, modrm) \
+ (((modrm) >> 3) & 7)
+#define decode_modrm_reg_rexr(env, s, modrm) \
+ (decode_modrm_reg_norexr(env, s, modrm) \
+ | REX_R(s))
+
+#define decode_modrm_rm_norexb(env, s, modrm) \
+ ((modrm) & 7)
+#define decode_modrm_rm_rexb(env, s, modrm) \
+ (decode_modrm_rm_norexb(env, s, modrm) \
+ | REX_B(s))
+
enum {
CK_CPUID_MMX = 1,
CK_CPUID_3DNOW,
--
2.20.1
- [Qemu-devel] [RFC PATCH v2 14/39] target/i386: introduce mnemonic aliases for several gvec operations, (continued)
- [Qemu-devel] [RFC PATCH v2 17/39] target/i386: introduce helpers for decoding modrm fields,
Jan Bobek <=
- [Qemu-devel] [RFC PATCH v2 18/39] target/i386: introduce modifier for direct-only operand decoding, Jan Bobek, 2019/08/10
- [Qemu-devel] [RFC PATCH v2 20/39] target/i386: introduce generic load-store operand, Jan Bobek, 2019/08/10
- [Qemu-devel] [RFC PATCH v2 22/39] target/i386: introduce code generators, Jan Bobek, 2019/08/10
- [Qemu-devel] [RFC PATCH v2 19/39] target/i386: introduce generic operand alias, Jan Bobek, 2019/08/10
- [Qemu-devel] [RFC PATCH v2 21/39] target/i386: introduce insn.h, Jan Bobek, 2019/08/10
- [Qemu-devel] [RFC PATCH v2 24/39] target/i386: introduce Ib (immediate) operand, Jan Bobek, 2019/08/10
- [Qemu-devel] [RFC PATCH v2 25/39] target/i386: introduce M* (memptr) operands, Jan Bobek, 2019/08/10
- [Qemu-devel] [RFC PATCH v2 23/39] target/i386: introduce instruction translator macros, Jan Bobek, 2019/08/10