[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
- [Qemu-devel] [PATCH v14 07/33] target-tilegx: Fix LDNA_ADD_IMM8_OPCODE_X1, (continued)
- [Qemu-devel] [PATCH v14 07/33] target-tilegx: Fix LDNA_ADD_IMM8_OPCODE_X1, Richard Henderson, 2015/08/24
- [Qemu-devel] [PATCH v14 05/33] target-tilegx: Modify opcode_tilegx.h to fit QEMU usage, Richard Henderson, 2015/08/24
- [Qemu-devel] [PATCH v14 04/33] target-tilegx: Add opcode basic implementation from Tilera Corporation, Richard Henderson, 2015/08/24
- [Qemu-devel] [PATCH v14 08/33] target-tilegx: Add special register information from Tilera Corporation, Richard Henderson, 2015/08/24
- [Qemu-devel] [PATCH v14 09/33] target-tilegx: Add cpu basic features for linux-user, Richard Henderson, 2015/08/24
- [Qemu-devel] [PATCH v14 10/33] target-tilegx: Add several helpers for instructions translation, Richard Henderson, 2015/08/24
- Re: [Qemu-devel] [PATCH v14 10/33] target-tilegx: Add several helpers for instructions translation,
Peter Maydell <=
- [Qemu-devel] [PATCH v14 12/33] target-tilegx: Generate SEGV properly, Richard Henderson, 2015/08/24
- [Qemu-devel] [PATCH v14 14/33] target-tilegx: Handle simple logical operations, Richard Henderson, 2015/08/24
- [Qemu-devel] [PATCH v14 15/33] target-tilegx: Handle arithmetic instructions, Richard Henderson, 2015/08/24
- [Qemu-devel] [PATCH v14 11/33] target-tilegx: Framework for decoding bundles, Richard Henderson, 2015/08/24