if (({ __builtin_flags_t __r;
asm ("cmpxchgl %3, %0"
: "=m" (mem), "=C" (__r)
: "0" (mem), "r" (oldval));
__r; }))
should be practical: where __builtin_flags_t is a magic type that maps
to CCmode, and the "C" constraint allows only (reg:CC 17). (We might
need __builtin_cc_t, _ccz_t, _ccno_t, etc.)
If this is easier it is even more welcome since it's a more general
solution. The interface needs some thoughts, though. The
__builtin_flags_t type would represent the whole set of conditional
flags. While on x86 something like __builtin_cflag_p (__r) to test for
the carray flag might be sufficient, how would you do this on IA-64 with
its scores of conditional registers? Invent a special notation for each
architecture? This might indeed be a possibility.This seems both easier to
implement, and cleaner notation to boot. Bonus points for permitting
if (asm ("cmpxchgl %3, %0"
: "=m" (mem), "=C"
: "0" (mem), "r" (oldval)))
Well, the problem described above remains. Yes, one could define the
return value of an asm() statement (now asm() expression) to be the
conditional flags, but how to access the values?