From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24126 invoked by alias); 20 Jun 2011 16:22:56 -0000 Received: (qmail 24116 invoked by uid 22791); 20 Jun 2011 16:22:54 -0000 X-SWARE-Spam-Status: No, hits=-6.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 20 Jun 2011 16:22:36 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p5KGMRgr002691 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 20 Jun 2011 12:22:27 -0400 Received: from [10.11.10.67] (vpn-10-67.rdu.redhat.com [10.11.10.67]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p5KGMPBo004508; Mon, 20 Jun 2011 12:22:25 -0400 Message-ID: <4DFF73C1.6080609@redhat.com> Date: Mon, 20 Jun 2011 16:39:00 -0000 From: Andrew MacLeod User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc13 Thunderbird/3.1.7 MIME-Version: 1.0 To: Richard Henderson CC: Aldy Hernandez , Jakub Jelinek , "Joseph S. Myers" , gcc-patches Subject: Re: __sync_swap* with acq/rel/full memory barrier semantics References: <4DDAE516.4010307@redhat.com> <4DE3F8ED.6020109@redhat.com> <4DE7E0A6.9070400@redhat.com> <20110602192514.GA17079@tyan-ft48-01.lab.bos.redhat.com> <4DE7EA11.30306@redhat.com> <4DE8EF17.5020400@redhat.com> <4DFBC33E.60408@redhat.com> <4DFCFCE2.1090307@redhat.com> In-Reply-To: <4DFCFCE2.1090307@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-06/txt/msg01503.txt.bz2 > 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