public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew MacLeod <amacleod@redhat.com>
To: Richard Henderson <rth@redhat.com>
Cc: Aldy Hernandez <aldyh@redhat.com>,
	Jakub Jelinek <jakub@redhat.com>,
	       "Joseph S. Myers" <joseph@codesourcery.com>,
	       gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: __sync_swap* with acq/rel/full memory barrier semantics
Date: Mon, 20 Jun 2011 16:39:00 -0000	[thread overview]
Message-ID: <4DFF73C1.6080609@redhat.com> (raw)
In-Reply-To: <4DFCFCE2.1090307@redhat.com>

> On 06/17/2011 02:12 PM, Andrew MacLeod wrote:
>> --- machmode.h	(working copy)
>> *************** extern enum machine_mode ptr_mode;
>> *** 275,278 ****
>> --- 275,291 ----
>>    /* Target-dependent machine mode initialization - in insn-modes.c.  */
>>    extern void init_adjust_machine_modes (void);
>>
>> + /* Memory model types for the __sync_mem* builtins.
>> +    This must match the order in libstdc++-v3/include/bits/atomic_base.h.  */
>> + enum memmodel
>> + {
>> +   MEMMODEL_RELAXED = 0,
>> +   MEMMODEL_CONSUME = 1,
>> +   MEMMODEL_ACQUIRE = 2,
>> +   MEMMODEL_RELEASE = 3,
>> +   MEMMODEL_ACQ_REL = 4,
>> +   MEMMODEL_SEQ_CST = 5,
>> +   MEMMODEL_LAST = 6
>> + };
> This isn't a very machine mode sort of define.
> I think coretypes.h is a better choice.

cool that seems to work fine.  As long as its somewhere common.

>> + static rtx
>> + expand_builtin_mem_exchange (enum machine_mode mode, tree exp, rtx target)
> Some names include "sync" and some don't?

Well, I was going to blame Aldy :-)  but then I went to look at this, 
and thats the same way *all* the other __sync instructions seem to be.

ie:

builtins.c:expand_builtin_lock_test_and_set (enum machine_mode mode, 
tree exp,
builtins.c:    case BUILT_IN_LOCK_TEST_AND_SET_1:
builtins.c:    case BUILT_IN_LOCK_TEST_AND_SET_2:
builtins.c:    case BUILT_IN_LOCK_TEST_AND_SET_4:

whereas everything else is 'sync_lock_test_and_set'..

So i guess it falls to prior art... I assume Aldy just cut-and-pasted 
for his new routine and just changed the names in the same format.


>> + 
> The xchg instruction is a full barrier; no need for anything extra here.
> Indeed, you needn't define UNSPECV_MEM_XCHG either.  This could be as
> simple as
>
>
Ah, even better.  For some reason I thought I saw somewhere that it 
wasn't a full barrier.  Might have just been the documentation for 
lock_test_and_set.

Andrew

  reply	other threads:[~2011-06-20 16:22 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-24  8:27 Aldy Hernandez
2011-05-24  9:25 ` Joseph S. Myers
2011-05-30 22:53   ` Andrew MacLeod
2011-05-31 13:12     ` Jakub Jelinek
2011-05-31 15:23       ` Andrew MacLeod
2011-06-02 19:13     ` Aldy Hernandez
2011-06-02 19:25       ` Jakub Jelinek
2011-06-02 19:53         ` Aldy Hernandez
2011-06-03 14:27           ` Richard Henderson
2011-06-17 22:21             ` Andrew MacLeod
2011-06-18 19:49               ` Richard Henderson
2011-06-20 16:39                 ` Andrew MacLeod [this message]
2011-06-20 22:50                   ` Richard Henderson
2011-06-20 23:02                     ` Andrew MacLeod
2011-06-20 23:29                       ` Richard Henderson
2011-06-21 18:56                         ` __sync_swap* [ rename sync builtins ] Andrew MacLeod
2011-06-21 19:03                           ` Richard Henderson
2011-06-21 23:03                             ` Graham Stott
2011-06-21 23:26                               ` Andrew MacLeod
2011-06-22  0:59                                 ` Andrew MacLeod
2011-06-24  0:35                                 ` Ian Lance Taylor
2011-06-24  0:38                                   ` Andrew MacLeod
2011-06-21 23:03                         ` [cxx-mem-model] sync_mem_exchange implementation with memory model parameters Andrew MacLeod
2011-06-22 20:36                           ` Richard Henderson
2011-07-08 17:00                   ` __sync_swap* with acq/rel/full memory barrier semantics Aldy Hernandez
2011-06-18 23:49               ` Richard Henderson

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=4DFF73C1.6080609@redhat.com \
    --to=amacleod@redhat.com \
    --cc=aldyh@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=rth@redhat.com \
    /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).