qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 3/4] target-tricore: Add instructions of RRPW opcode format
Date: Wed, 21 Jan 2015 10:57:06 -0800	[thread overview]
Message-ID: <54BFF682.2080603@twiddle.net> (raw)
In-Reply-To: <1421863489-7716-4-git-send-email-kbastian@mail.uni-paderborn.de>

On 01/21/2015 10:04 AM, Bastian Koppelmann wrote:
> Signed-off-by: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
> ---
>  target-tricore/translate.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 63 insertions(+)
> 
> diff --git a/target-tricore/translate.c b/target-tricore/translate.c
> index 4af31c2..73d8d7d 100644
> --- a/target-tricore/translate.c
> +++ b/target-tricore/translate.c
> @@ -5084,6 +5084,53 @@ static void decode_rr2_mul(CPUTriCoreState *env, DisasContext *ctx)
>      }
>  }
>  
> +/* RRPW format */
> +static void decode_rrpw_extract_insert(CPUTriCoreState *env, DisasContext *ctx)
> +{
> +    uint32_t op2;
> +    int r1, r2, r3;
> +    int32_t pos, width;
> +
> +    op2 = MASK_OP_RRPW_OP2(ctx->opcode);
> +    r1 = MASK_OP_RRPW_S1(ctx->opcode);
> +    r2 = MASK_OP_RRPW_S2(ctx->opcode);
> +    r3 = MASK_OP_RRPW_D(ctx->opcode);
> +    pos = MASK_OP_RRPW_POS(ctx->opcode);
> +    width = MASK_OP_RRPW_WIDTH(ctx->opcode);
> +
> +    switch (op2) {
> +    case OPC2_32_RRPW_EXTR:
> +        if (pos + width <= 31) {
> +            tcg_gen_shri_tl(cpu_gpr_d[r3], cpu_gpr_d[r1], pos);
> +            tcg_gen_andi_tl(cpu_gpr_d[r3], cpu_gpr_d[r3], ~0u >> (32 - width));
> +            /* sign extend it */
> +            tcg_gen_shli_tl(cpu_gpr_d[r3], cpu_gpr_d[r3], (32 - width));
> +            tcg_gen_sari_tl(cpu_gpr_d[r3], cpu_gpr_d[r3], (32 - width));

You can do this with just the last two shifts:

  shl tmp, r3, 32 - pos - width
  sar r3, tmp, 32 - width

Given that this appears to be the canonical way to sign-extend,
you may well want to special case pos == 0, width == {8,16} to
emit the tcg extension opcodes.


> +        temp = tcg_temp_new();
> +        tcg_gen_shli_tl(cpu_gpr_d[r3], cpu_gpr_d[r2], const16);
> +        tcg_gen_shri_tl(temp, cpu_gpr_d[r1], 32 - const16);
> +        tcg_gen_or_tl(cpu_gpr_d[r3], cpu_gpr_d[r3], temp);
> +        tcg_temp_free(temp);
> +        break;

It should be worth special casing r1 == r2 as rotate left.


r~

  reply	other threads:[~2015-01-21 18:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-21 18:04 [Qemu-devel] [PATCH 0/4] TriCore add instructions of RR1, RR2, RRPW and RRR opcode format Bastian Koppelmann
2015-01-21 18:04 ` [Qemu-devel] [PATCH 1/4] target-tricore: target-tricore: Add instructions of RR1 opcode format, that have 0x93 as first opcode Bastian Koppelmann
2015-01-21 18:14   ` Richard Henderson
2015-01-21 18:04 ` [Qemu-devel] [PATCH 2/4] target-tricore: Add instructions of RR2 opcode format Bastian Koppelmann
2015-01-21 18:16   ` Richard Henderson
2015-01-22 14:58     ` Bastian Koppelmann
2015-01-21 18:04 ` [Qemu-devel] [PATCH 3/4] target-tricore: Add instructions of RRPW " Bastian Koppelmann
2015-01-21 18:57   ` Richard Henderson [this message]
2015-01-21 18:04 ` [Qemu-devel] [PATCH 4/4] target-tricore: Add instructions of RRR " Bastian Koppelmann
2015-01-21 19:45   ` Richard Henderson

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=54BFF682.2080603@twiddle.net \
    --to=rth@twiddle.net \
    --cc=kbastian@mail.uni-paderborn.de \
    --cc=qemu-devel@nongnu.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).