[Top][All Lists]
[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: |
Richard Henderson |
Subject: |
Re: [Qemu-devel] [PATCH v12 09/14] target-mips: Add ASE DSP bit/manipulation instructions |
Date: |
Wed, 31 Oct 2012 16:26:43 +1100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121016 Thunderbird/16.0.1 |
On 2012-10-31 01:44, Peter Maydell wrote:
> On 30 October 2012 15:34, Jia Liu <address@hidden> wrote:
>> On Mon, Oct 29, 2012 at 9:40 PM, Jovanovic, Petar <address@hidden> wrote:
>>>> imm = (int16_t)(imm << 6) >> 6;
>>>
>>> result of a bitwise shift of a signed type and a negative vlaue is
>>> implementation-defined, so you can not rely on that.
>>>
>>
>> I think it will take a 10bits signed value sign extend into 16bits
>> signed value, and I've tested it with negative values, it working
>> well.
>
> You cannot rely on the behaviour of a specific compiler implementation
> as evidence that a piece of code is correct. C has a standard which
> defines what is and is not valid.
Indeed. The only portable way is
val = ((val & (sign | (sign - 1))) ^ sign) - sign
with all unsigned types, and "sign" set to the sign bit.
>
> Having said that, right shift of negative signed integers is one of
> those bits of implementation defined behaviour which we allow ourselves
> to rely on in QEMU because all the platforms we care about behave
> that way. (That integers are 2s complement representation is another.)
Also very true. I don't like seeing the code in question though.
We've several implementations of sign-extend-to-N-bits functions
throughout qemu; we ought to unify them.
r~
- Re: [Qemu-devel] [PATCH v12 09/14] target-mips: Add ASE DSP bit/manipulation instructions, Jovanovic, Petar, 2012/10/27
- Re: [Qemu-devel] [PATCH v12 09/14] target-mips: Add ASE DSP bit/manipulation instructions, Jia Liu, 2012/10/29
- Re: [Qemu-devel] [PATCH v12 09/14] target-mips: Add ASE DSP bit/manipulation instructions, Jovanovic, Petar, 2012/10/29
- Re: [Qemu-devel] [PATCH v12 09/14] target-mips: Add ASE DSP bit/manipulation instructions, Jia Liu, 2012/10/30
- Re: [Qemu-devel] [PATCH v12 09/14] target-mips: Add ASE DSP bit/manipulation instructions, Peter Maydell, 2012/10/30
- Re: [Qemu-devel] [PATCH v12 09/14] target-mips: Add ASE DSP bit/manipulation instructions,
Richard Henderson <=
- Re: [Qemu-devel] [PATCH v12 09/14] target-mips: Add ASE DSP bit/manipulation instructions, Jia Liu, 2012/10/31
- Re: [Qemu-devel] [PATCH v12 09/14] target-mips: Add ASE DSP bit/manipulation instructions, Aurelien Jarno, 2012/10/31
- Re: [Qemu-devel] [PATCH v12 09/14] target-mips: Add ASE DSP bit/manipulation instructions, Jia Liu, 2012/10/31
Re: [Qemu-devel] [PATCH v12 09/14] target-mips: Add ASE DSP bit/manipulation instructions, Peter Maydell, 2012/10/30