This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Trouble with inline void function using asm
- To: "Jeff Hammond" <jshammond at my-deja dot com>
- Subject: Re: Trouble with inline void function using asm
- From: Alexandre Oliva <aoliva at redhat dot com>
- Date: 24 Jan 2001 00:09:10 -0200
- Cc: gcc at gcc dot gnu dot org
- Organization: GCC Team, Red Hat
- References: <200101240143.RAA18274@mail24.bigmailbox.com>
On Jan 23, 2001, "Jeff Hammond" <jshammond@my-deja.com> wrote:
> asm("SALT r%0,r%1,0 ; write_altmem"
> : "r"(data) : "r"(addr) );
> I get the error message:
> memaccess.c:11: output operand constraint lacks `='
> I didn't think that I would need a '=' since there are no output
> variables.
Then why is `data' in the output operands section (i.e., between the
first and the second `:')?
Maybe you mean:
> asm("SALT r%0,r%1,0 ; write_altmem"
> : : "r"(data), "r"(addr) );
> When I put an '=' in the first argument there are no compiler errors
> but the compiler decides that this function doesn't do anything and
> optimizes it out.
It probably optimizes it out because then the output operand is
unused.
Maybe you should instead indicate that the memory area pointed to by
addr is modified (in which case you'd use a `=m' constraint)? Or
maybe you should make the asm statement volatile, so that GCC doesn't
optimize it away.
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist *Please* write to mailing lists, not to me