From: Aurelien Jarno <aurelien@aurel32.net>
To: Richard Henderson <rth@twiddle.net>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 3/5] tcg/i386: Add tcg_out_vex_modrm
Date: Sun, 16 Feb 2014 19:12:13 +0100 [thread overview]
Message-ID: <20140216181213.GA18671@hall.aurel32.net> (raw)
In-Reply-To: <1391179418-13422-4-git-send-email-rth@twiddle.net>
On Fri, Jan 31, 2014 at 08:43:36AM -0600, Richard Henderson wrote:
> Prepare for emitting BMI insns which require VEX encoding.
>
> Signed-off-by: Richard Henderson <rth@twiddle.net>
> ---
> tcg/i386/tcg-target.c | 41 ++++++++++++++++++++++++++++++++++++++---
> 1 file changed, 38 insertions(+), 3 deletions(-)
>
> diff --git a/tcg/i386/tcg-target.c b/tcg/i386/tcg-target.c
> index 7008b0e..00dbc3b 100644
> --- a/tcg/i386/tcg-target.c
> +++ b/tcg/i386/tcg-target.c
> @@ -402,9 +402,9 @@ static void tcg_out_opc(TCGContext *s, int opc, int r, int rm, int x)
>
> rex = 0;
> rex |= (opc & P_REXW) ? 0x8 : 0x0; /* REX.W */
> - rex |= (r & 8) >> 1; /* REX.R */
> - rex |= (x & 8) >> 2; /* REX.X */
> - rex |= (rm & 8) >> 3; /* REX.B */
> + rex |= (r & 8) >> 1; /* REX.R */
> + rex |= (x & 8) >> 2; /* REX.X */
> + rex |= (rm & 8) >> 3; /* REX.B */
>
> /* P_REXB_{R,RM} indicates that the given register is the low byte.
> For %[abcd]l we need no REX prefix, but for %{si,di,bp,sp}l we do,
> @@ -453,6 +453,41 @@ static void tcg_out_modrm(TCGContext *s, int opc, int r, int rm)
> tcg_out8(s, 0xc0 | (LOWREGMASK(r) << 3) | LOWREGMASK(rm));
> }
>
> +static void tcg_out_vex_modrm(TCGContext *s, int opc, int r, int v, int rm)
> +{
> + int tmp;
> +
> + if ((opc & (P_REXW | P_EXT | P_EXT38)) || (rm & 8)) {
> + /* Three byte VEX prefix. */
> + tcg_out8(s, 0xc4);
> +
> + /* VEX.m-mmmm */
> + if (opc & P_EXT38) {
> + tmp = 2;
> + } else if (opc & P_EXT) {
> + tmp = 1;
> + } else {
> + tcg_abort();
> + }
> + tmp |= 0x40; /* VEX.X */
> + tmp |= (r & 8 ? 0 : 0x80); /* VEX.R */
> + tmp |= (rm & 8 ? 0 : 0x20); /* VEX.B */
> + tcg_out8(s, tmp);
> +
> + tmp = (opc & P_REXW ? 0x80 : 0); /* VEX.W */
> + } else {
> + /* Two byte VEX prefix. */
> + tcg_out8(s, 0xc5);
> +
> + tmp = (r & 8 ? 0 : 0x80); /* VEX.R */
> + }
> + tmp |= (opc & P_DATA16 ? 1 : 0); /* VEX.pp */
> + tmp |= (~v & 15) << 3; /* VEX.vvvv */
> + tcg_out8(s, tmp);
> + tcg_out8(s, opc);
> + tcg_out8(s, 0xc0 | (LOWREGMASK(r) << 3) | LOWREGMASK(rm));
> +}
> +
> /* Output an opcode with a full "rm + (index<<shift) + offset" address mode.
> We handle either RM and INDEX missing with a negative value. In 64-bit
> mode for absolute addresses, ~RM is the size of the immediate operand
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
--
Aurelien Jarno GPG: 1024D/F1BCDB73
aurelien@aurel32.net http://www.aurel32.net
next prev parent reply other threads:[~2014-02-16 18:12 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-31 14:43 [Qemu-devel] [PATCH 0/5] tcg/i386 support for bmi Richard Henderson
2014-01-31 14:43 ` [Qemu-devel] [PATCH 1/5] disas/i386: Disassemble ANDN/SHLX/SHRX/SHAX Richard Henderson
2014-02-16 18:12 ` Aurelien Jarno
2014-01-31 14:43 ` [Qemu-devel] [PATCH 2/5] tcg/i386: Move TCG_CT_CONST_* to tcg-target.c Richard Henderson
2014-02-16 18:12 ` Aurelien Jarno
2014-01-31 14:43 ` [Qemu-devel] [PATCH 3/5] tcg/i386: Add tcg_out_vex_modrm Richard Henderson
2014-02-16 18:12 ` Aurelien Jarno [this message]
2014-01-31 14:43 ` [Qemu-devel] [PATCH 4/5] tcg/i386: Use ANDN instruction Richard Henderson
2014-02-16 18:12 ` Aurelien Jarno
2014-02-17 16:18 ` Richard Henderson
2014-02-20 16:25 ` Peter Maydell
2014-02-20 16:42 ` Peter Maydell
2014-02-20 16:43 ` Richard Henderson
2014-02-20 17:38 ` Peter Maydell
2014-01-31 14:43 ` [Qemu-devel] [PATCH 5/5] tcg/i386: Use SHLX/SHRX/SARX instructions Richard Henderson
2014-02-16 14:21 ` Paolo Bonzini
2014-02-16 17:57 ` Richard Henderson
2014-02-17 16:01 ` Richard Henderson
2014-02-16 18:12 ` Aurelien Jarno
2014-02-14 21:44 ` [Qemu-devel] [PATCH 0/5] tcg/i386 support for bmi Richard Henderson
2014-02-16 14:22 ` Paolo Bonzini
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=20140216181213.GA18671@hall.aurel32.net \
--to=aurelien@aurel32.net \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.