[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH v2 16/39] target/i386: introduce instruction ope
From: |
Jan Bobek |
Subject: |
[Qemu-devel] [RFC PATCH v2 16/39] target/i386: introduce instruction operand infrastructure |
Date: |
Sat, 10 Aug 2019 00:12:32 -0400 |
insnop_t and the init, prepare and finalize functions form the basis
of instruction operand decoding. Introduce macros for defining a
generic instruction operand; use cases for operand decoding will be
introduced later with instruction translators.
Signed-off-by: Jan Bobek <address@hidden>
---
target/i386/translate.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/target/i386/translate.c b/target/i386/translate.c
index 508d584584..109e4922eb 100644
--- a/target/i386/translate.c
+++ b/target/i386/translate.c
@@ -4545,6 +4545,47 @@ static int ck_cpuid(CPUX86State *env, DisasContext *s,
int ck_cpuid_feat)
}
}
+/*
+ * Core instruction operand infrastructure
+ */
+#define insnop_t(opT) insnop_ ## opT ## _t
+#define insnop_init(opT) insnop_ ## opT ## _init
+#define insnop_prepare(opT) insnop_ ## opT ## _prepare
+#define insnop_finalize(opT) insnop_ ## opT ## _finalize
+
+#define TYPEDEF_INSNOP_T(opT, type) \
+ typedef type insnop_t(opT);
+#define INSNOP_INIT(opT, init_stmt) \
+ static int insnop_init(opT)(CPUX86State *env, DisasContext *s, \
+ int modrm, insnop_t(opT) *op) \
+ { \
+ init_stmt; \
+ }
+#define INSNOP_PREPARE(opT, prepare_stmt) \
+ static void insnop_prepare(opT)(CPUX86State *env, DisasContext *s, \
+ int modrm, insnop_t(opT) *op) \
+ { \
+ prepare_stmt; \
+ }
+#define INSNOP_FINALIZE(opT, finalize_stmt) \
+ static void insnop_finalize(opT)(CPUX86State *env, DisasContext *s, \
+ int modrm, insnop_t(opT) *op) \
+ { \
+ finalize_stmt; \
+ }
+#define INSNOP(opT, type, init_stmt, prepare_stmt, finalize_stmt) \
+ TYPEDEF_INSNOP_T(opT, type) \
+ INSNOP_INIT(opT, init_stmt) \
+ INSNOP_PREPARE(opT, prepare_stmt) \
+ INSNOP_FINALIZE(opT, finalize_stmt)
+
+#define INSNOP_INIT_FAIL return 1
+#define INSNOP_INIT_OK(x) return ((*(op) = (x)), 0)
+#define INSNOP_PREPARE_NOOP /* no-op */
+#define INSNOP_PREPARE_INVALID g_assert_not_reached()
+#define INSNOP_FINALIZE_NOOP /* no-op */
+#define INSNOP_FINALIZE_INVALID g_assert_not_reached()
+
static void gen_sse_ng(CPUX86State *env, DisasContext *s, int b)
{
enum {
--
2.20.1
- Re: [Qemu-devel] [RFC PATCH v2 07/39] target/i386: use pc_start from DisasContext, (continued)
- [Qemu-devel] [RFC PATCH v2 11/39] target/i386: introduce gen_(ld, st)d_env_A0, Jan Bobek, 2019/08/10
- [Qemu-devel] [RFC PATCH v2 13/39] target/i386: disable unused function warning temporarily, Jan Bobek, 2019/08/10
- [Qemu-devel] [RFC PATCH v2 14/39] target/i386: introduce mnemonic aliases for several gvec operations, Jan Bobek, 2019/08/10
- [Qemu-devel] [RFC PATCH v2 12/39] target/i386: introduce gen_sse_ng, Jan Bobek, 2019/08/10
- [Qemu-devel] [RFC PATCH v2 15/39] target/i386: introduce function ck_cpuid, Jan Bobek, 2019/08/10
- [Qemu-devel] [RFC PATCH v2 16/39] target/i386: introduce instruction operand infrastructure,
Jan Bobek <=
- [Qemu-devel] [RFC PATCH v2 17/39] target/i386: introduce helpers for decoding modrm fields, Jan Bobek, 2019/08/10
- [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