qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v12 09/14] target-mips: Add ASE DSP bit/manipula


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH v12 09/14] target-mips: Add ASE DSP bit/manipulation instructions
Date: Tue, 30 Oct 2012 15:51:54 +0100

On 29 October 2012 13:36, Jia Liu <address@hidden> wrote:
>         case OPC_REPL_PH:
>             check_dsp(ctx);
>             {
>                 imm = (ctx->opcode >> 16) & 0x03FF;
>                 imm = (int16_t)(imm << 6) >> 6;
>                 tcg_gen_movi_tl(cpu_gpr[ret], \
>                                 (target_long)(int32_t)((int32_t)imm << 16 | \
>                                 (uint32_t)(uint16_t)imm));
>             }
>             break;

This code is using rather more casts than it needs to.
Also, if you kept the scope of 'imm' to the local blocks
where it is used then it would be easy to see at a glance
what type it is (in this case int16_t) and thus which
of these casts are needed. (It would also mean you could
use the sensible type for the job -- for instance
in the OPC_REPL_QB case a 32 bit type would let you
avoid a lot of the casts your current code has.)

-- PMM



reply via email to

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