All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Richard Henderson <rth@twiddle.net>
Cc: qemu-devel@nongnu.org, agraf@suse.de
Subject: Re: [Qemu-devel] [PATCH 09/12] tcg-s390: Use risbgz for andi
Date: Wed, 27 Mar 2013 20:03:35 +0100	[thread overview]
Message-ID: <51534287.8090309@redhat.com> (raw)
In-Reply-To: <1364410353-24728-10-git-send-email-rth@twiddle.net>

Il 27/03/2013 19:52, Richard Henderson ha scritto:
> This is immediately usable by the tlb lookup code.
> 
> Signed-off-by: Richard Henderson <rth@twiddle.net>
> ---
>  tcg/s390/tcg-target.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++-----
>  1 file changed, 53 insertions(+), 5 deletions(-)
> 
> diff --git a/tcg/s390/tcg-target.c b/tcg/s390/tcg-target.c
> index 203cbb5..2bab245 100644
> --- a/tcg/s390/tcg-target.c
> +++ b/tcg/s390/tcg-target.c
> @@ -827,6 +827,15 @@ static void tcg_out_ld_abs(TCGContext *s, TCGType type, TCGReg dest, void *abs)
>      tcg_out_ld(s, type, dest, dest, addr & 0xffff);
>  }
>  
> +static inline void tcg_out_risbg(TCGContext *s, TCGReg dest, TCGReg src,
> +                                 int msb, int lsb, int ofs, int z)
> +{
> +    /* Format RIE-f */
> +    tcg_out16(s, (RIE_RISBG & 0xff00) | (dest << 4) | src);
> +    tcg_out16(s, (msb << 8) | (z << 7) | lsb);
> +    tcg_out16(s, (ofs << 8) | (RIE_RISBG & 0xff));
> +}
> +
>  static void tgen_ext8s(TCGContext *s, TCGType type, TCGReg dest, TCGReg src)
>  {
>      if (facilities & FACILITY_EXT_IMM) {
> @@ -940,6 +949,36 @@ static inline void tgen64_addi(TCGContext *s, TCGReg dest, int64_t val)
>  
>  }
>  
> +/* Accept bit patterns like these:
> +    0....01....1
> +    1....10....0
> +    1..10..01..1
> +    0..01..10..0
> +   Copied from gcc sources.  */
> +static inline bool risbg_mask(uint64_t c)
> +{
> +    uint64_t lsb;
> +    /* We don't change the number of transitions by inverting,
> +       so make sure we start with the LSB zero.  */
> +    if (c & 1) {
> +        c = ~c;
> +    }
> +    /* Reject all zeros or all ones.  */
> +    if (c == 0) {
> +        return false;
> +    }
> +    /* Find the first transition.  */
> +    lsb = c & -c;
> +    /* Invert to look for a second transition.  */
> +    c = ~c;
> +    /* Erase the first transition.  */
> +    c &= -lsb;
> +    /* Find the second transition, if any.  */
> +    lsb = c & -c;
> +    /* Match if all the bits are 1's, or if c is zero.  */
> +    return c == -lsb;
> +}
> +
>  static void tgen_andi(TCGContext *s, TCGType type, TCGReg dest, uint64_t val)
>  {
>      static const S390Opcode ni_insns[4] = {
> @@ -986,6 +1025,19 @@ static void tgen_andi(TCGContext *s, TCGType type, TCGReg dest, uint64_t val)
>              }
>          }
>      }
> +    if ((facilities & FACILITY_GEN_INST_EXT) && risbg_mask(val)) {
> +        int msb, lsb;
> +        if ((val & 0x8000000000000001ull) == 0x8000000000000001ull) {
> +            /* Achieve wraparound by swapping msb and lsb.  */
> +            msb = 63 - ctz64(~val);
> +            lsb = clz64(~val) + 1;
> +        } else {
> +            msb = clz64(val);
> +            lsb = 63 - ctz64(val);
> +        }
> +        tcg_out_risbg(s, dest, dest, msb, lsb, 0, 1);
> +        return;
> +    }
>  
>      /* Fall back to loading the constant.  */
>      tcg_out_movi(s, type, TCG_TMP0, val);
> @@ -1142,11 +1194,7 @@ static void tgen_deposit(TCGContext *s, TCGReg dest, TCGReg src,
>  {
>      int lsb = (63 - ofs);
>      int msb = lsb - (len - 1);
> -
> -    /* Format RIE-f */
> -    tcg_out16(s, (RIE_RISBG & 0xff00) | (dest << 4) | src);
> -    tcg_out16(s, (msb << 8) | lsb);
> -    tcg_out16(s, (ofs << 8) | (RIE_RISBG & 0xff));
> +    tcg_out_risbg(s, dest, src, msb, lsb, ofs, 0);
>  }
>  
>  static void tgen_gotoi(TCGContext *s, int cc, tcg_target_long dest)
> 

I wonder if PPC can use this too.

Paolo

  reply	other threads:[~2013-03-27 19:03 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-27 18:52 [Qemu-devel] [PATCH 00/12] tcg-s390 updates Richard Henderson
2013-03-27 18:52 ` [Qemu-devel] [PATCH 01/12] tcg-s390: Fix movi Richard Henderson
2013-03-27 18:52 ` [Qemu-devel] [PATCH 02/12] tcg-s390: Properly allocate a stack frame Richard Henderson
2013-03-27 18:52 ` [Qemu-devel] [PATCH 03/12] tcg-s390: Remove useless preprocessor conditions Richard Henderson
2013-03-28  0:14   ` Aurelien Jarno
2013-03-28  0:54     ` Richard Henderson
2013-03-27 18:52 ` [Qemu-devel] [PATCH 04/12] tcg-s390: Implement add2/sub2 opcodes Richard Henderson
2013-03-27 18:52 ` [Qemu-devel] [PATCH 05/12] tcg-s390: Implement mulu2_i64 opcode Richard Henderson
2013-03-27 18:52 ` [Qemu-devel] [PATCH 06/12] tcg-s390: Implement movcond opcodes Richard Henderson
2013-03-27 18:52 ` [Qemu-devel] [PATCH 07/12] tcg-s390: Implement deposit opcodes Richard Henderson
2013-03-27 18:52 ` [Qemu-devel] [PATCH 08/12] tcg-s390: Remove constraint letters for and Richard Henderson
2013-03-28 15:03   ` Aurelien Jarno
2013-03-28 15:08     ` Richard Henderson
2013-03-27 18:52 ` [Qemu-devel] [PATCH 09/12] tcg-s390: Use risbgz for andi Richard Henderson
2013-03-27 19:03   ` Paolo Bonzini [this message]
2013-03-27 19:27     ` Richard Henderson
2013-03-27 18:52 ` [Qemu-devel] [PATCH 10/12] tcg-s390: Cleanup argument shuffling fixme in softmmu code Richard Henderson
2013-03-27 18:52 ` [Qemu-devel] [PATCH 11/12] tcg-s390: Use load-address for addition Richard Henderson
2013-03-27 18:52 ` [Qemu-devel] [PATCH 12/12] tcg-s390: Use all 20 bits of the offset in tcg_out_mem 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=51534287.8090309@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=agraf@suse.de \
    --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.