linux-mips
[Top] [All Lists]

Re: question about memory constraint in atomic_add

To: Indigodfw <indigodfw@yahoo.com>
Subject: Re: question about memory constraint in atomic_add
From: Ralf Baechle <ralf@linux-mips.org>
Date: Wed, 18 Feb 2004 14:45:01 +0100
Cc: linux-mips@linux-mips.org
In-reply-to: <20040214151152.80368.qmail@web9502.mail.yahoo.com>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <20040214151152.80368.qmail@web9502.mail.yahoo.com>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mutt/1.4.1i
On Sat, Feb 14, 2004 at 07:11:52AM -0800, Indigodfw wrote:

> 2. Result of (C expression) should go into %xyz
> register 
> So v->counter goes into %1, IOW ll from an int!
> 
> Does not make sense to me.
> Why does it work, What am I missing?

> I mean in general what is the expression for a m
> constraint ptr (because I want ptr to be in regiser)
> or *ptr (because I wanna tell compiler that *ptr is
> what gets changed) 

"m" gives you *something* suitable to address a memory object; that isn't
necessarily a memory address.  On MIPS it can't even be just an address
in a register because "m" constraints are used with loads and stores and
those only accept the offset(reg) addressing mode.  If you want an address
use something like "r" (&v->counter), then lw reg,(%xxx).

  Ralf

<Prev in Thread] Current Thread [Next in Thread>