qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] target-i386: guest variable shift by 0 provokes shift b


From: Richard Henderson
Subject: Re: [Qemu-devel] target-i386: guest variable shift by 0 provokes shift by -1
Date: Tue, 18 Mar 2014 07:39:12 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0

On 03/18/2014 07:25 AM, Peter Maydell wrote:
> Why do you think this? tcg/README says out of
> range shifts are undefined behaviour. That means we
> mustn't execute them, and this code doesn't attempt
> to branch around or otherwise avoid the shift by -1.

Bah.  Stuff and nonsense.  None of our backends are so stupid as to start WWIII
with an out of range input.

For most backends, the shift count gets (partially) masked as it is inserted
into the immediate field.  Then either the cpu considers a large shift as
producing zero (arm), or fully masks the input (everyone else).

Though indeed, Sparc considers an out of range shift immediate as an illegal
instruction, so we have an extra step in the backend for exactly this case:

    do_shift32:
        /* Limit immediate shift count lest we create an illegal insn.  */
        tcg_out_arithc(s, args[0], args[1], args[2] & 31, const_args[2], c);
        break;

> The docs say undefined behaviour, not undefined
> result value... (Is there a C standard term for
> the latter?)

The README is hardly standard-ese.  Don't read it like it's been written that 
way.

The term from C you're looking for is unspecified behaviour.



r~



reply via email to

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