[cfe-dev] Targets where sizeof(_Atomic X) != sizeof(X) ?
James Y Knight via cfe-dev
cfe-dev at lists.llvm.org
Mon Apr 4 09:29:56 PDT 2016
[Note previous discussion that occurred on the (otherwise unrelated)
http://reviews.llvm.org/D17950.]
On Mon, Apr 4, 2016 at 9:58 AM, Craig, Ben via cfe-dev <
cfe-dev at lists.llvm.org> wrote:
> 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160404/ac6b4fa6/attachment.html>
More information about the cfe-dev
mailing list