This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Another question re asm constraints
- From: Ian Lance Taylor <iant at google dot com>
- To: dw <limegreensocks at yahoo dot com>
- Cc: "gcc-help at gcc dot gnu dot org" <gcc-help at gcc dot gnu dot org>
- Date: Mon, 25 Mar 2013 14:56:07 -0700
- Subject: Re: Another question re asm constraints
- References: <5150C6CF dot 3060400 at yahoo dot com>
On Mon, Mar 25, 2013 at 2:51 PM, dw <limegreensocks@yahoo.com> wrote:
> Does specifying the + operator on outputs remove the need for listing the
> variable as an input? For example:
>
> __CRT_INLINE SHORT AddTest(SHORT *Addend)
> {
> SHORT ret = 1;
> __asm__ __volatile__("lock\n\txaddw %0,%1 "
> : "+r" (ret), "+m" (*Addend)
> : "0" (ret)
> : "cc");
> return ret + 1;
> }
>
> Is the "0" constraint accomplishing anything useful here
No.
> And more importantly, is the "+m" enough to ensure that any existing values
> for Addend have been written to memory?
Yes, at least from the compiler's perspective (there may be pending
writes from another processor that the compiler knows nothing about).
Ian