[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH v3 23/46] target/i386: introduce operand for dir
From: |
Jan Bobek |
Subject: |
[Qemu-devel] [RFC PATCH v3 23/46] target/i386: introduce operand for direct-only r/m field |
Date: |
Wed, 14 Aug 2019 22:09:05 -0400 |
Many operands can only decode successfully if the ModR/M byte has the
direct form (i.e. MOD=3). Capture this common aspect by introducing a
special direct-only r/m field operand.
Signed-off-by: Jan Bobek <address@hidden>
---
target/i386/translate.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/target/i386/translate.c b/target/i386/translate.c
index e4515e81df..c918065b96 100644
--- a/target/i386/translate.c
+++ b/target/i386/translate.c
@@ -4822,6 +4822,43 @@ INSNOP_FINALIZE(modrm_rm)
{
}
+/*
+ * modrm_rm_direct
+ *
+ * Equivalent of modrm_rm, but only decodes successfully if
+ * the ModR/M byte has the direct form (i.e. MOD=3).
+ */
+typedef insnop_arg_t(modrm_rm) insnop_arg_t(modrm_rm_direct);
+typedef struct {
+ insnop_ctxt_t(modrm_rm) rm;
+} insnop_ctxt_t(modrm_rm_direct);
+
+INSNOP_INIT(modrm_rm_direct)
+{
+ int ret;
+ insnop_ctxt_t(modrm_mod) modctxt;
+
+ ret = insnop_init(modrm_mod)(&modctxt, env, s, modrm, 0);
+ if (!ret) {
+ const int mod = insnop_prepare(modrm_mod)(&modctxt, env, s, modrm, 0);
+ if (mod == 3) {
+ ret = insnop_init(modrm_rm)(&ctxt->rm, env, s, modrm, is_write);
+ } else {
+ ret = 1;
+ }
+ insnop_finalize(modrm_mod)(&modctxt, env, s, modrm, 0, mod);
+ }
+ return ret;
+}
+INSNOP_PREPARE(modrm_rm_direct)
+{
+ return insnop_prepare(modrm_rm)(&ctxt->rm, env, s, modrm, is_write);
+}
+INSNOP_FINALIZE(modrm_rm_direct)
+{
+ insnop_finalize(modrm_rm)(&ctxt->rm, env, s, modrm, is_write, arg);
+}
+
static void gen_sse_ng(CPUX86State *env, DisasContext *s, int b)
{
enum {
--
2.20.1
- [Qemu-devel] [RFC PATCH v3 07/46] target/i386: use pc_start from DisasContext, (continued)
- [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, 2019/08/14
- [Qemu-devel] [RFC PATCH v3 23/46] target/i386: introduce operand for direct-only r/m field,
Jan Bobek <=
- [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
- [Qemu-devel] [RFC PATCH v3 26/46] target/i386: introduce M* (memptr) operands, Jan Bobek, 2019/08/14