From owner-freebsd-alpha@FreeBSD.ORG Thu Aug 7 12:12:36 2003 Return-Path: Delivered-To: freebsd-alpha@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B961E37B40C; Thu, 7 Aug 2003 12:12:36 -0700 (PDT) Received: from ns1.xcllnt.net (209-128-86-226.BAYAREA.NET [209.128.86.226]) by mx1.FreeBSD.org (Postfix) with ESMTP id 861AF43FA3; Thu, 7 Aug 2003 12:12:34 -0700 (PDT) (envelope-from marcel@xcllnt.net) Received: from athlon.pn.xcllnt.net (athlon.pn.xcllnt.net [192.168.4.3]) by ns1.xcllnt.net (8.12.9/8.12.9) with ESMTP id h77JCYwO046656; Thu, 7 Aug 2003 12:12:34 -0700 (PDT) (envelope-from marcel@piii.pn.xcllnt.net) Received: from athlon.pn.xcllnt.net (localhost [127.0.0.1]) by athlon.pn.xcllnt.net (8.12.9/8.12.9) with ESMTP id h77JCYWe000748; Thu, 7 Aug 2003 12:12:34 -0700 (PDT) (envelope-from marcel@athlon.pn.xcllnt.net) Received: (from marcel@localhost) by athlon.pn.xcllnt.net (8.12.9/8.12.9/Submit) id h77JCX26000747; Thu, 7 Aug 2003 12:12:33 -0700 (PDT) (envelope-from marcel) Date: Thu, 7 Aug 2003 12:12:33 -0700 From: Marcel Moolenaar To: deischen@freebsd.org Message-ID: <20030807191233.GB559@athlon.pn.xcllnt.net> References: <20030807185507.GA559@athlon.pn.xcllnt.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.4i cc: "Portante, Peter" cc: alpha@freebsd.org Subject: Re: Atomic swap X-BeenThere: freebsd-alpha@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Porting FreeBSD to the Alpha List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Aug 2003 19:12:37 -0000 On Thu, Aug 07, 2003 at 03:05:28PM -0400, Daniel Eischen wrote: > > The following has been written down without testing (I > > dropped the cosmetic \t and instead indented by hand to > > make the source code readable, not what is given to the > > assembler (per se): > > > > static __inline void > > atomic_swap_long(volatile long *dst, long val, long *res) > > { > > __asm ( "1: ldq_l t0,%0\n" > > " mov %1,t1\n" > > If I swap the first 2 instructions: > > __asm ( "1: mov %1,t1\n" > ldq_l t0,%0\n" > > that eliminates 1 instruction from between the locked > instructions. Is there anything wrong with doing that? No. > > So it's OK to hardcode registers (t0, t1) in inline assembly? > Not generally. On some platforms the compiler needs temporary registers to move the C types into registers. You need to stay away from the registers the compiler uses. I don't think this is the case here, but you might want to check (ie cc -S and see if the compiler uses t0 and t1). Since arguments are passed in registers, the compiler can directly use 0(a0), a1 and 0(a2) without needing anything else. -- Marcel Moolenaar USPA: A-39004 marcel@xcllnt.net