On Mar 9, 2011, at 3:35 PM, Georg-Johann Lay wrote:

> Paulo J. Matos schrieb:
>> Hi,
>> I am having some trouble really understanding the working of cc_status.
>> In order to understand it better I was looking at the code for avr under gcc 
>> 4.3.
>> My assumption is that set_zn, set_* means that an instructions _changes_ 
>> these flags. So an instruction that set_zn means that Z and N are modified 
>> but we are not sure to which values. I assume clobber means that an 
>> instruction changes some flags but we don't know which.
> 
> set_* tells you which condition code flags have been set in a usable way, 
> e.g. to be used in a subsequent branch instruction. For example, if * 
> contains 'z' you can use the Z-Flag to test if the value just set is equal to 
> zero or not. Look at "andqi3" insn which sets Z and N, but "andhi3" just sets 
> N or clobbers CC. Z just reflects the andi-action of the high byte of the 
> result, so you cannot use Z-flag to test wether or not the result is zero or 
> not. However, for alternatives 0 and 2, you can use N to test the result 
> (interpreted as signed) for <0 resp. >= 0.
> 'clobber' means the instruction leaves CC in a mess. 'none' means CC is 
> unchanged.

By the way: "in a mess" doesn't necessarily mean "in an unpredicable way".  It 
can also mean "in a way that is too hard to describe, or not worth describing". 
 For example, the strlen pattern quoted by Paulo would leave the condition 
codes set from the zero byte (i.e., Z=1).  That could be stated, but it isn't 
interesting, so "clobber" simply tells GCC that nothing useful is in the CC at 
this time.

That's true for the use of the term "clobber" generally, not just for condition 
codes.

        paul

Reply via email to