qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 2/4] tcg/aarch64: implement byte swap operations


From: Claudio Fontana
Subject: Re: [Qemu-devel] [PATCH 2/4] tcg/aarch64: implement byte swap operations
Date: Mon, 3 Jun 2013 11:44:39 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20130509 Thunderbird/17.0.6

On 31.05.2013 21:11, Richard Henderson wrote:
> On 05/31/2013 11:01 AM, Jani Kokkonen wrote:
>> +static inline void tcg_out_rev(TCGContext *s, int ext, TCGReg rd, TCGReg rm)
>> +{
>> +    /* using REV 0x5ac00800 */
>> +    unsigned int base = ext ? 0xdac00c00 : 0x5ac00800;
>> +    tcg_out32(s, base | rm << 5 | rd);
>> +}
>> +
>> +static inline void tcg_out_rev16(TCGContext *s, int ext, TCGReg rd, TCGReg 
>> rm)
>> +{
>> +    /* using REV16 0x5ac00400 */
>> +    unsigned int base = ext ? 0xdac00400 : 0x5ac00400;
>> +    tcg_out32(s, base | rm << 5 | rd);
>> +}
>> +
>> +static inline void tcg_out_rev32(TCGContext *s, TCGReg rd, TCGReg rm)
>> +{
>> +    /* using REV32 0xdac00800 */
>> +    unsigned int base = 0xdac00800;
>> +    tcg_out32(s, base | rm << 5 | rd);
>> +}
> 
> You don't actually need rev32.
> 
>> * bswap32_i32/i64 t0, t1
>>
>> 32 bit byte swap on a 32/64 bit value. With a 64 bit value, it assumes that
>> the four high order bytes are set to zero.
> 
> The fact that the high order bytes are known to be zero means that you
> can always use tcg_out_rev with ext=0.
> 
>     case INDEX_op_bswap64_i64:
>         ext = 1;
>         /* FALLTHRU */
>     case INDEX_op_bswap32_i64:
>     case INDEX_op_bswap32_i32:
>         tcg_out_rev(s, ext, args[0], args[1]);
>         break;
>     case INDEX_op_bswap16_i64:
>     case INDEX_op_bswap16_i32:
>         tcg_out_rev16(s, 0, args[0], args[1]);
>         break;
> 
> 
> r~
> 

ACK.




reply via email to

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