qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v14 10/33] target-tilegx: Add several helpers fo


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH v14 10/33] target-tilegx: Add several helpers for instructions translation
Date: Sat, 29 Aug 2015 15:37:03 +0100

On 24 August 2015 at 17:17, Richard Henderson <address@hidden> wrote:
> From: Chen Gang <address@hidden>
>
> The related instructions are exception, cntlz, cnttz, shufflebytes.
>
> Signed-off-by: Chen Gang <address@hidden>
> Message-Id: <address@hidden>
> [rth: Remove incorrect implementation of add_saturate.]
> Signed-off-by: Richard Henderson <address@hidden>
> ---

> +/*
> + * Functional Description
> + *     uint64_t a = rf[SrcA];
> + *     uint64_t b = rf[SrcB];
> + *     uint64_t d = rf[Dest];
> + *     uint64_t output = 0;
> + *     unsigned int counter;
> + *     for (counter = 0; counter < (WORD_SIZE / BYTE_SIZE); counter++)
> + *     {
> + *         int sel = getByte (b, counter) & 0xf;
> + *         uint8_t byte = (sel < 8) ? getByte (d, sel) : getByte (a, (sel - 
> 8));
> + *         output = setByte (output, counter, byte);
> + *     }
> + *     rf[Dest] = output;
> + */
> +uint64_t helper_shufflebytes(uint64_t dest, uint64_t srca, uint64_t srcb)
> +{
> +    uint64_t vdst = 0;
> +    int count;
> +
> +    for (count = 0; count < 64; count += 8) {
> +        uint64_t sel = srcb >> count;
> +        uint64_t src = (sel & 8) ? srca : dest;
> +        vdst |= ((src >> ((sel & 7) * 8)) & 0xff) << count;

I would have used extract64(src, (sel & 7) * 8, 8)
as being slightly easier to read in comparison with the quoted
pseudocode, but it's not a big deal, so

Reviewed-by: Peter Maydell <address@hidden>

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]