public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew MacLeod <amacleod@redhat.com>
To: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [PATCH 0/5] Atomic type qualifier
Date: Tue, 30 Jul 2013 16:56:00 -0000	[thread overview]
Message-ID: <51F7EE86.20805@redhat.com> (raw)
In-Reply-To: <51F2AEB1.60408@redhat.com>

On 07/26/2013 01:15 PM, Andrew MacLeod wrote:
> This patch adds an atomic type qualifier to GCC.   It can be accessed 
> via __attribute__((atomic)) or in C11 mode via the _Atomic keyword.
>
> What it does:
>  *  All the __atomic builtins now expect an atomic qualified value for 
> the atomic variable.  Non-atomic values can still be passed in, but 
> they are not guaranteed to work if the original type is not compatible 
> with the atomic type  No fears.  At the moment, every target's atomic 
> types line up with the unsigned type of the same size, so like magic, 
> its all good for existing code.
>  *  There is a new target hook "atomic_align_for_mode" which a target 
> can use to override the default alignment when the atomic variation 
> requires something different.   There may be other attributes 
> eventually, but for now alignment is the only thing supported.  I 
> considered size, but the effort to do that is what drove me to the 
> re-architecture project :-P  At least the mechanism is now in place 
> for overrides when atomic requirements aren't just the default it use 
> to be.    (I introduced atomicQI_type_node, atomicHI_type_node,  
> atomicSI_type_node, atomicDI_type_node, atomicTI_type_node, ).  I 
> tested this by aligning all shorts to 32 byte boundaries and 
> bootstrapping/running all the tests.
>  * I went through the front ends trying to treat  atomic qualifier 
> mostly like a volatile, since thats is the basic behaviour one 
> expects.  In the backend, it sets the TREE_IS_VOLATILE bit so 
> behaviour ought to be the same as before, plus they are/will be always 
> used in __atomic_built-in functions.
>  * I changed the libstdc++ atomic implementation so that all the 
> atomic classes use __attribute__((atomic)) on their data members, 
> ensuring that if anyone overrides the atomic type, it should work fine 
> with C++ atomics.   It also served as a good test that I had the type 
> set up properly... getting TYPE_CANONICAL() correct throughout the C++ 
> compiler was, well..., lets just say painful.
> * I changed 2 of the atomic test sets, one uses 
> __attribute__((atomic)) to ensure the attribute compiles ok, and the 
> other uses _Atomic and --std=c11 to ensure that compiles OK.
>
> What it doesn't do:
>   * It doesn't implement the C11 expression expansion into atomic 
> built-ins.  ie, you can't write:
> _Atomic int x;
>  x = 0;
>       and have the result be an atomic operation calling 
> __atomic_store (&x, 0).   That will be in a  follow on patch. So none 
> of the expression expansion from C11 is included yet. This just 
> enables that.
>  * It doesn't do a full set of checks when _Atomic is used in invalid 
> ways.  I don't know the standard nor the front end well enough.. Im 
> hoping someone else will pitch in with that eventually, assuming 
> someone cares enough :-)  There are a couple of errors issued, but 
> that is it.
>
> This bootstraps on x86_64, and passes all the testsuites with no new 
> regressions.  I didnt split it up any more than this because most of 
> it is inter-related... plus this is already split out from a much 
> larger set of changes :-) I did try to at least organize the ordering, 
> all the long boring stuff is at the end :-)
>
> Both front end and back end stuff in here.  I think I caught it all, 
> but have a look. There is time to find any remaining issues I may have 
> missed.
>
> Andrew
>
I split the original patch into some smaller hunks, and cleaned up a few 
bit and pieces here and there... following:


  parent reply	other threads:[~2013-07-30 16:49 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-26 17:18 [PATCH] Add atomic " Andrew MacLeod
2013-07-26 19:24 ` Andi Kleen
2013-07-26 19:34   ` Andrew MacLeod
2013-07-26 21:14     ` Andi Kleen
2013-07-26 22:29       ` Andrew MacLeod
2013-07-26 20:42 ` Hans-Peter Nilsson
2013-07-26 23:58 ` Joseph S. Myers
2013-07-27  1:15   ` Andrew MacLeod
2013-08-01 21:54   ` Andrew MacLeod
2013-07-28 21:15 ` Joseph S. Myers
2013-07-29 15:47   ` Andrew MacLeod
2013-07-29 16:12     ` Joseph S. Myers
2013-07-29 16:30       ` Andrew MacLeod
2013-07-29 16:48         ` Joseph S. Myers
2013-07-29 18:20           ` Andrew MacLeod
2013-07-29 23:24       ` Andrew MacLeod
2013-07-30 12:03         ` Joseph S. Myers
2013-07-30 12:38           ` Andrew MacLeod
2013-07-30 13:25             ` Joseph S. Myers
2013-07-30 13:58               ` Andrew MacLeod
2013-07-31 12:19                 ` Andrew MacLeod
2013-07-29 16:24     ` Andrew MacLeod
2013-07-30 16:56 ` Andrew MacLeod [this message]
2013-07-30 17:13   ` [PATCH 2/5] Atomic type qualifier - Add atomic type to tree node Andrew MacLeod
2013-07-30 17:14   ` [PATCH 1/5] Atomic type qualifier - Add type alignment override hook Andrew MacLeod
2013-07-30 17:14   ` [PATCH 3/5] Atomic type qualifier - front end changes Andrew MacLeod
2013-08-09  0:06     ` Joseph S. Myers
2013-07-30 17:14   ` [PATCH 4/5] Atomic type qualifier - Change built-in function types Andrew MacLeod
2013-07-30 17:32   ` [PATCH 5/5] Atomic type qualifier - Use atomic objects Andrew MacLeod
2013-08-02 19:22   ` [PATCH] - C11 expressions and stdatomic.h - Just for current state Andrew MacLeod
2013-08-07 23:06     ` Joseph S. Myers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51F7EE86.20805@redhat.com \
    --to=amacleod@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).