qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jan Bobek <jan.bobek@gmail.com>
To: qemu-devel@nongnu.org
Cc: "Alex Bennée" <alex.bennee@linaro.org>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Jan Bobek" <jan.bobek@gmail.com>
Subject: [Qemu-devel] [RFC PATCH v1 06/22] target/i386: introduce gen_gvec_ld_modrm_* helpers
Date: Wed, 31 Jul 2019 13:56:46 -0400	[thread overview]
Message-ID: <20190731175702.4916-7-jan.bobek@gmail.com> (raw)
In-Reply-To: <20190731175702.4916-1-jan.bobek@gmail.com>

gen_gvec_ld_modrm_* helpers tie together a gen_ld_modrm_* helper and a
particular gvec operation, effectively handling a single instruction.

Signed-off-by: Jan Bobek <jan.bobek@gmail.com>
---
 target/i386/translate.c | 77 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 77 insertions(+)

diff --git a/target/i386/translate.c b/target/i386/translate.c
index 7548677e1f..d576b3345c 100644
--- a/target/i386/translate.c
+++ b/target/i386/translate.c
@@ -3087,6 +3087,83 @@ static inline void gen_ld_modrm_VxHxWx(CPUX86State *env, DisasContext *s, int mo
     *aofs = offsetof(CPUX86State, xmm_regs[s->vex_v]);
 }
 
+typedef void (*gen_ld_modrm_2_fp_t)(CPUX86State *env, DisasContext *s, int modrm,
+                                    uint32_t *dofs, uint32_t *aofs);
+typedef void (*gen_ld_modrm_3_fp_t)(CPUX86State *env, DisasContext *s, int modrm,
+                                    uint32_t *dofs, uint32_t *aofs, uint32_t *bofs);
+typedef void (*gen_gvec_2_fp_t)(unsigned vece, uint32_t dofs, uint32_t aofs,
+                                uint32_t bofs, uint32_t oprsz, uint32_t maxsz);
+
+static inline void gen_gvec_ld_modrm_2(CPUX86State *env, DisasContext *s,
+                                       int modrm, unsigned vece,
+                                       uint32_t oprsz, uint32_t maxsz,
+                                       gen_ld_modrm_2_fp_t gen_ld_modrm_2_fp,
+                                       gen_gvec_2_fp_t gen_gvec_2_fp,
+                                       int opctl)
+{
+    uint32_t ofss[2];
+
+    const int opd = ((opctl >> 6) & 7) - 1;
+    const int opa = ((opctl >> 3) & 7) - 1;
+    const int opb = ((opctl >> 0) & 7) - 1;
+
+    assert(0 <= opd && opd < 2);
+    assert(0 <= opa && opa < 2);
+    assert(0 <= opb && opb < 2);
+
+    (*gen_ld_modrm_2_fp)(env, s, modrm, &ofss[0], &ofss[1]);
+    (*gen_gvec_2_fp)(vece, ofss[opd], ofss[opa], ofss[opb], oprsz, maxsz);
+}
+
+static inline void gen_gvec_ld_modrm_3(CPUX86State *env, DisasContext *s,
+                                       int modrm, unsigned vece,
+                                       uint32_t oprsz, uint32_t maxsz,
+                                       gen_ld_modrm_3_fp_t gen_ld_modrm_3_fp,
+                                       gen_gvec_2_fp_t gen_gvec_2_fp,
+                                       int opctl)
+{
+    uint32_t ofss[3];
+
+    const int opd = ((opctl >> 6) & 7) - 1;
+    const int opa = ((opctl >> 3) & 7) - 1;
+    const int opb = ((opctl >> 0) & 7) - 1;
+
+    assert(0 <= opd && opd < 3);
+    assert(0 <= opa && opa < 3);
+    assert(0 <= opb && opb < 3);
+
+    (*gen_ld_modrm_3_fp)(env, s, modrm, &ofss[0], &ofss[1], &ofss[2]);
+    (*gen_gvec_2_fp)(vece, ofss[opd], ofss[opa], ofss[opb], oprsz, maxsz);
+}
+
+#define gen_gvec_ld_modrm_mm(env, s, modrm, vece,                       \
+                             gen_gvec_2_fp, opctl)                      \
+    gen_gvec_ld_modrm_2((env), (s), (modrm), (vece),                    \
+                        sizeof(MMXReg), sizeof(MMXReg),                 \
+                        gen_ld_modrm_PqQq,                              \
+                        gen_gvec_2_fp, (opctl))
+
+#define gen_gvec_ld_modrm_xmm(env, s, modrm, vece,                      \
+                              gen_gvec_2_fp, opctl)                     \
+    gen_gvec_ld_modrm_2((env), (s), (modrm), (vece),                    \
+                        sizeof(XMMReg), sizeof(XMMReg),                 \
+                        gen_ld_modrm_VxWx,                              \
+                        gen_gvec_2_fp, (opctl))
+
+#define gen_gvec_ld_modrm_vxmm(env, s, modrm, vece,                     \
+                               gen_gvec_2_fp, opctl)                    \
+    gen_gvec_ld_modrm_3((env), (s), (modrm), (vece),                    \
+                        sizeof(XMMReg), sizeof(ZMMReg),                 \
+                        gen_ld_modrm_VxHxWx,                            \
+                        gen_gvec_2_fp, (opctl))
+
+#define gen_gvec_ld_modrm_vymm(env, s, modrm, vece,                     \
+                               gen_gvec_2_fp, opctl)                    \
+    gen_gvec_ld_modrm_3((env), (s), (modrm), (vece),                    \
+                        sizeof(YMMReg), sizeof(ZMMReg),                 \
+                        gen_ld_modrm_VxHxWx,                            \
+                        gen_gvec_2_fp, (opctl))
+
 static void gen_sse(CPUX86State *env, DisasContext *s, int b)
 {
     int b1, op1_offset, op2_offset, is_xmm, val;
-- 
2.20.1



  parent reply	other threads:[~2019-07-31 18:00 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-31 17:56 [Qemu-devel] [RFC PATCH v1 00/22] reimplement (some) x86 vector instructions using tcg-gvec Jan Bobek
2019-07-31 17:56 ` [Qemu-devel] [RFC PATCH v1 01/22] target/i386: Push rex_r into DisasContext Jan Bobek
2019-07-31 17:56 ` [Qemu-devel] [RFC PATCH v1 02/22] target/i386: Push rex_w " Jan Bobek
2019-07-31 17:56 ` [Qemu-devel] [RFC PATCH v1 03/22] target/i386: Use prefix, aflag and dflag from DisasContext Jan Bobek
2019-07-31 19:41   ` Aleksandar Markovic
2019-07-31 20:04     ` Aleksandar Markovic
2019-08-02 13:20       ` Jan Bobek
2019-07-31 17:56 ` [Qemu-devel] [RFC PATCH v1 04/22] target/i386: Simplify gen_exception arguments Jan Bobek
2019-07-31 17:56 ` [Qemu-devel] [RFC PATCH v1 05/22] target/i386: introduce gen_ld_modrm_* helpers Jan Bobek
2019-07-31 19:08   ` Richard Henderson
2019-08-02 13:26     ` Jan Bobek
2019-07-31 17:56 ` Jan Bobek [this message]
2019-07-31 22:47   ` [Qemu-devel] [RFC PATCH v1 06/22] target/i386: introduce gen_gvec_ld_modrm_* helpers Richard Henderson
2019-08-02 13:34     ` Jan Bobek
2019-07-31 17:56 ` [Qemu-devel] [RFC PATCH v1 07/22] target/i386: add vector register file alignment constraints Jan Bobek
2019-07-31 19:14   ` Richard Henderson
2019-07-31 17:56 ` [Qemu-devel] [RFC PATCH v1 08/22] target/i386: reimplement (V)PAND, (V)ANDPS, (V)ANDPD Jan Bobek
2019-07-31 19:35   ` Richard Henderson
2019-07-31 20:27     ` Aleksandar Markovic
2019-07-31 21:21       ` Richard Henderson
2019-08-02 13:53     ` Jan Bobek
2019-07-31 17:56 ` [Qemu-devel] [RFC PATCH v1 09/22] target/i386: reimplement (V)POR, (V)ORPS, (V)ORPD Jan Bobek
2019-07-31 17:56 ` [Qemu-devel] [RFC PATCH v1 10/22] target/i386: reimplement (V)PXOR, (V)XORPS, (V)XORPD Jan Bobek
2019-07-31 17:56 ` [Qemu-devel] [RFC PATCH v1 11/22] target/i386: reimplement (V)PANDN, (V)ANDNPS, (V)ANDNPD Jan Bobek
2019-07-31 17:56 ` [Qemu-devel] [RFC PATCH v1 12/22] target/i386: reimplement (V)PADD(B, W, D, Q) Jan Bobek
2019-07-31 17:56 ` [Qemu-devel] [RFC PATCH v1 13/22] target/i386: reimplement (V)PSUB(B, " Jan Bobek
2019-07-31 17:56 ` [Qemu-devel] [RFC PATCH v1 14/22] target/i386: reimplement (V)PADDS(B, W) Jan Bobek
2019-07-31 17:56 ` [Qemu-devel] [RFC PATCH v1 15/22] target/i386: reimplement (V)PADDUS(B, W) Jan Bobek
2019-07-31 17:56 ` [Qemu-devel] [RFC PATCH v1 16/22] target/i386: reimplement (V)PSUBS(B, W) Jan Bobek
2019-07-31 17:56 ` [Qemu-devel] [RFC PATCH v1 17/22] target/i386: reimplement (V)PSUBUS(B, W) Jan Bobek
2019-07-31 17:56 ` [Qemu-devel] [RFC PATCH v1 18/22] target/i386: reimplement (V)PMINSW Jan Bobek
2019-07-31 17:56 ` [Qemu-devel] [RFC PATCH v1 19/22] target/i386: reimplement (V)PMINUB Jan Bobek
2019-07-31 17:57 ` [Qemu-devel] [RFC PATCH v1 20/22] target/i386: reimplement (V)PMAXSW Jan Bobek
2019-07-31 17:57 ` [Qemu-devel] [RFC PATCH v1 21/22] target/i386: reimplement (V)PMAXUB Jan Bobek
2019-07-31 17:57 ` [Qemu-devel] [RFC PATCH v1 22/22] target/i386: reimplement (V)P(EQ, CMP)(B, W, D) Jan Bobek
2019-07-31 19:50   ` Richard Henderson
2019-07-31 20:09     ` Aleksandar Markovic
2019-07-31 21:31       ` Richard Henderson
2019-08-02 14:07         ` Jan Bobek
2019-08-02 14:18         ` Aleksandar Markovic
2019-07-31 18:20 ` [Qemu-devel] [RFC PATCH v1 00/22] reimplement (some) x86 vector instructions using tcg-gvec no-reply
2019-07-31 19:21 ` no-reply
2019-07-31 19:21 ` no-reply
2019-08-01 15:46 ` no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190731175702.4916-7-jan.bobek@gmail.com \
    --to=jan.bobek@gmail.com \
    --cc=alex.bennee@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).