[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH v3 22/46] target/i386: introduce operands for de
From: |
Jan Bobek |
Subject: |
[Qemu-devel] [RFC PATCH v3 22/46] target/i386: introduce operands for decoding modrm fields |
Date: |
Wed, 14 Aug 2019 22:09:04 -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 operands.
Signed-off-by: Jan Bobek <address@hidden>
---
target/i386/translate.c | 62 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 62 insertions(+)
diff --git a/target/i386/translate.c b/target/i386/translate.c
index 25c25a30fb..e4515e81df 100644
--- a/target/i386/translate.c
+++ b/target/i386/translate.c
@@ -4760,6 +4760,68 @@ INSNOP_FINALIZE(modrm)
{
}
+/*
+ * modrm_mod
+ *
+ * Operand whose value is the MOD field of the ModR/M byte.
+ */
+typedef int insnop_arg_t(modrm_mod);
+typedef struct {} insnop_ctxt_t(modrm_mod);
+
+INSNOP_INIT(modrm_mod)
+{
+ return 0;
+}
+INSNOP_PREPARE(modrm_mod)
+{
+ return (modrm >> 6) & 3;
+}
+INSNOP_FINALIZE(modrm_mod)
+{
+}
+
+/*
+ * modrm_reg
+ *
+ * Operand whose value is the REG field of the ModR/M byte, extended
+ * with the REX.R bit if REX prefix is present.
+ */
+typedef int insnop_arg_t(modrm_reg);
+typedef struct {} insnop_ctxt_t(modrm_reg);
+
+INSNOP_INIT(modrm_reg)
+{
+ return 0;
+}
+INSNOP_PREPARE(modrm_reg)
+{
+ return ((modrm >> 3) & 7) | REX_R(s);
+}
+INSNOP_FINALIZE(modrm_reg)
+{
+}
+
+/*
+ * modrm_rm
+ *
+ * Operand whose value is the RM field of the ModR/M byte, extended
+ * with the REX.B bit if REX prefix is present.
+ */
+typedef int insnop_arg_t(modrm_rm);
+typedef struct {} insnop_ctxt_t(modrm_rm);
+
+INSNOP_INIT(modrm_rm)
+{
+ return 0;
+}
+INSNOP_PREPARE(modrm_rm)
+{
+ return (modrm & 7) | REX_B(s);
+}
+INSNOP_FINALIZE(modrm_rm)
+{
+}
+
static void gen_sse_ng(CPUX86State *env, DisasContext *s, int b)
{
enum {
--
2.20.1
- [Qemu-devel] [RFC PATCH v3 06/46] target/i386: Simplify gen_exception arguments, (continued)
- [Qemu-devel] [RFC PATCH v3 06/46] target/i386: Simplify gen_exception arguments, Jan Bobek, 2019/08/14
- [Qemu-devel] [RFC PATCH v3 07/46] target/i386: use pc_start from DisasContext, Jan Bobek, 2019/08/14
- [Qemu-devel] [RFC PATCH v3 12/46] target/i386: introduce gen_sse_ng, Jan Bobek, 2019/08/14
- [Qemu-devel] [RFC PATCH v3 13/46] target/i386: disable unused function warning temporarily, Jan Bobek, 2019/08/14
- [Qemu-devel] [RFC PATCH v3 17/46] target/i386: introduce generic operand alias, Jan Bobek, 2019/08/14
- [Qemu-devel] [RFC PATCH v3 16/46] target/i386: introduce instruction operand infrastructure, Jan Bobek, 2019/08/14
- [Qemu-devel] [RFC PATCH v3 21/46] target/i386: introduce modrm operand, Jan Bobek, 2019/08/14
- [Qemu-devel] [RFC PATCH v3 18/46] target/i386: introduce generic either-or operand, Jan Bobek, 2019/08/14
- [Qemu-devel] [RFC PATCH v3 19/46] target/i386: introduce generic load-store operand, Jan Bobek, 2019/08/14
- [Qemu-devel] [RFC PATCH v3 20/46] target/i386: introduce tcg_temp operands, Jan Bobek, 2019/08/14
- [Qemu-devel] [RFC PATCH v3 22/46] target/i386: introduce operands for decoding modrm fields,
Jan Bobek <=
- [Qemu-devel] [RFC PATCH v3 23/46] target/i386: introduce operand for direct-only r/m field, Jan Bobek, 2019/08/14
- [Qemu-devel] [RFC PATCH v3 25/46] target/i386: introduce Ib (immediate) operand, Jan Bobek, 2019/08/14
- [Qemu-devel] [RFC PATCH v3 29/46] target/i386: introduce H*, V*, U*, W* (SSE/AVX) operands, Jan Bobek, 2019/08/14
- [Qemu-devel] [RFC PATCH v3 28/46] target/i386: introduce P*, N*, Q* (MMX) operands, Jan Bobek, 2019/08/14
- [Qemu-devel] [RFC PATCH v3 27/46] target/i386: introduce G*, R*, E* (general register) operands, Jan Bobek, 2019/08/14
- [Qemu-devel] [RFC PATCH v3 30/46] target/i386: introduce code generators, Jan Bobek, 2019/08/14
- [Qemu-devel] [RFC PATCH v3 33/46] target/i386: introduce sse-opcode.inc.h, Jan Bobek, 2019/08/14
- [Qemu-devel] [RFC PATCH v3 32/46] target/i386: introduce gvec-based code generator macros, Jan Bobek, 2019/08/14
- [Qemu-devel] [RFC PATCH v3 34/46] target/i386: introduce instruction translator macros, Jan Bobek, 2019/08/14
- [Qemu-devel] [RFC PATCH v3 24/46] target/i386: introduce operand vex_v, Jan Bobek, 2019/08/14