All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>,
	qemu-ppc@nongnu.org, david@gibson.dropbear.id.au
Cc: qemu-devel@nongnu.org, benh@kernel.crashing.org
Subject: Re: [Qemu-devel] [PATCH 5/6] target-ppc: add lxvb16x and lxvh8x
Date: Mon, 8 Aug 2016 10:57:13 +0530	[thread overview]
Message-ID: <e02dcc37-3b6b-c421-dfa7-89a5abb8d8f0@twiddle.net> (raw)
In-Reply-To: <1470591415-3268-6-git-send-email-nikunj@linux.vnet.ibm.com>

On 08/07/2016 11:06 PM, Nikunj A Dadhania wrote:
> +#define LXV(name, access, swap, type, elems)                     \
> +uint64_t helper_##name(CPUPPCState *env,                         \
> +                       target_ulong addr)                        \
> +{                                                                \
> +    type r[elems] = {0};                                         \
> +    int i, index, bound, step;                                   \
> +    if (msr_le) {                                                \
> +        index = elems - 1;                                       \
> +        bound = -1;                                              \
> +        step = -1;                                               \
> +    } else  {                                                    \
> +        index = 0;                                               \
> +        bound = elems;                                           \
> +        step = 1;                                                \
> +    }                                                            \
> +                                                                 \
> +    for (i = index; i != bound; i += step) {                     \
> +        if (needs_byteswap(env)) {                               \
> +            r[i] = swap(access(env, addr, GETPC()));             \
> +        } else {                                                 \
> +            r[i] =  access(env, addr, GETPC());                  \
> +        }                                                        \
> +        addr = addr_add(env, addr, sizeof(type));                \
> +    }                                                            \
> +    return  *((uint64_t *)r);                                    \
> +}

This looks more complicated than necessary.

(1) In big-endian mode, surely this simplifies to two 64-bit big-endian loads.

(2) In little-endian mode, the overhead of accessing memory surely dominates, 
and therefore we should perform two 64-bit loads and manipulate the data after.

AFAICS, this is easiest done by requesting two 64-bit *big-endian* loads, and 
then swapping bytes.  E.g.

uint64_t helper_bswap16x4(uint64_t x)
{
     uint64_t m = 0x00ff00ff00ff00ffull;
     return ((x & m) << 8) | ((x >> 8) & m);
}

uint64_t helper_bswap32x2(uint64_t x)
{
     return deposit64(bswap32(x >> 32), 32, 32, bswap32(x));
}


     tcg_gen_qemu_ld_i64(dest, addr, MO_BEQ, s->mem_index);
     if (ctx->le_mode) {
         gen_helper_bswap16x4(dest, dest);
     }


r~

  reply	other threads:[~2016-08-08  5:27 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-07 17:36 [Qemu-devel] [PATCH 0/6] POWER9 TCG enablements - part4 Nikunj A Dadhania
2016-08-07 17:36 ` [Qemu-devel] [PATCH 1/6] target-ppc: add xxspltib instruction Nikunj A Dadhania
2016-08-08  4:43   ` Richard Henderson
2016-08-08  6:19     ` Nikunj A Dadhania
2016-08-07 17:36 ` [Qemu-devel] [PATCH 2/6] target-ppc: Implement darn instruction Nikunj A Dadhania
2016-08-07 21:33   ` Benjamin Herrenschmidt
2016-08-08  1:52     ` Nikunj A Dadhania
2016-08-08  3:22       ` Benjamin Herrenschmidt
2016-08-08  3:32         ` Nikunj A Dadhania
2016-08-09  3:28     ` David Gibson
2016-08-09  4:54       ` Nikunj A Dadhania
2016-08-09  9:17         ` [Qemu-devel] [Qemu-ppc] " Nikunj A Dadhania
2016-08-12  6:29           ` David Gibson
2016-08-12  6:43             ` Nikunj A Dadhania
2016-08-12  6:56               ` David Gibson
2016-08-12  7:13                 ` Nikunj A Dadhania
2016-08-12  7:29               ` Thomas Huth
2016-08-12  7:39                 ` Nikunj A Dadhania
2016-08-12  7:55                   ` Thomas Huth
2016-08-12  8:41                     ` Nikunj A Dadhania
2016-08-12  9:29                       ` Thomas Huth
2016-08-12  9:51                         ` Nikunj A Dadhania
2016-08-12 13:26                           ` Richard Henderson
2016-08-12 13:39                             ` Nikunj A Dadhania
2016-08-15 10:28                         ` David Gibson
2016-08-08  5:01   ` [Qemu-devel] " Richard Henderson
2016-08-08  6:20     ` Nikunj A Dadhania
2016-08-07 17:36 ` [Qemu-devel] [PATCH 3/6] target-ppc: add lxsi[bw]zx instruction Nikunj A Dadhania
2016-08-08  5:08   ` Richard Henderson
2016-08-08  6:21     ` Nikunj A Dadhania
2016-08-07 17:36 ` [Qemu-devel] [PATCH 4/6] target-ppc: add stxsi[bh]x instruction Nikunj A Dadhania
2016-08-08  5:08   ` Richard Henderson
2016-08-07 17:36 ` [Qemu-devel] [PATCH 5/6] target-ppc: add lxvb16x and lxvh8x Nikunj A Dadhania
2016-08-08  5:27   ` Richard Henderson [this message]
2016-08-08  6:35     ` Richard Henderson
2016-08-10  9:21       ` Nikunj A Dadhania
2016-08-10 10:12         ` Richard Henderson
2016-08-10 10:33           ` Nikunj A Dadhania
2016-08-10 15:21           ` Nikunj A Dadhania
2016-08-07 17:36 ` [Qemu-devel] [PATCH 6/6] target-ppc: add stxvb16x and stxvh8x Nikunj A Dadhania
2016-08-08  5:27   ` Richard Henderson
2016-08-09  3:30 ` [Qemu-devel] [PATCH 0/6] POWER9 TCG enablements - part4 David Gibson

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=e02dcc37-3b6b-c421-dfa7-89a5abb8d8f0@twiddle.net \
    --to=rth@twiddle.net \
    --cc=benh@kernel.crashing.org \
    --cc=david@gibson.dropbear.id.au \
    --cc=nikunj@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@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 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.