The C11 standard permits sizeof(_Atomic char) to be different from sizeof(char). Are there any targets where this freedom is taken? Is there currently a TargetInfo member or chunk of a DataLayoutString that indicates the size of the various atomics?
I did some source searches, and didn't find anything. I've made some initial attempts at adding such support, but I've hit some non-trivial front-end crashes, so I figured I'd ask around before digging any deeper.
[Note previous discussion that occurred on the (otherwise unrelated)
http://reviews.llvm.org/D17950.]
The C11 standard permits sizeof(_Atomic char) to be different from
sizeof(char). Are there any targets where this freedom is taken?
No, it doesn't do that for primitive integer types, only for
non-power-of-two sized types. (ASTContext.cpp:1822)
Is there currently a TargetInfo member or chunk of a DataLayoutString that
indicates the size of the various atomics?
Nope.
I did some source searches, and didn't find anything. I've made some
initial attempts at adding such support, but I've hit some non-trivial
front-end crashes, so I figured I'd ask around before digging any deeper
As I said before, I don't think that this is really a good idea. Unless (as
you brought up) there's an architecture which actually uses
byte-granularity memory protection AND has a single-byte load/store BUT is
missing a single-byte version of the ll/sc or cmpxchg instructions (having
only a 4byte version, say), thus making it truly impossible to implement a
lock-free atomic char. (Such an architecture would seem pretty broken to
me. It should really be fixed)
In other cases, where it is possible to implement atomic char, by using a
word-sized cmpxchg on the containing aligned word, I think it's probably
best to just do that. Despite the approximately 15 extra instructions
needed to do the masking/shifting of the values.