public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Russell King <rmk+lkml@arm.linux.org.uk>
To: David Howells <dhowells@redhat.com>
Cc: torvalds@osdl.org, akpm@osdl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] get rid of "+m" constraint in i386 rwsems
Date: Thu, 6 May 2004 13:18:46 +0100	[thread overview]
Message-ID: <20040506131846.A29621@flint.arm.linux.org.uk> (raw)
In-Reply-To: <4955.1083844733@redhat.com>; from dhowells@redhat.com on Thu, May 06, 2004 at 12:58:53PM +0100

On Thu, May 06, 2004 at 12:58:53PM +0100, David Howells wrote:
> Here's a patch to remove the usage of a "+m" constraint in the i386 optimised
> rwsem implementation.

Doesn't the assembly assume that %0 is the same as %4, though because
they're memory operands, the chances of them not being so is pretty
slim?  From the gcc manual, it appears that this may not always be
the case:

|    The ordinary output operands must be write-only; GCC will assume that
| the values in these operands before the instruction are dead and need
| not be generated.  Extended asm supports input-output or read-write
| operands.  Use the constraint character `+' to indicate such an operand
| and list it with the output operands.
| 
|    When the constraints for the read-write operand (or the operand in
| which only some of the bits are to be changed) allows a register, you
| may, as an alternative, logically split its function into two separate
| operands, one input operand and one write-only output operand.  The
| connection between them is expressed by constraints which say they need
| to be in the same location when the instruction executes.  You can use
| the same C expression for both operands, or different expressions.  For
| example, here we write the (fictitious) `combine' instruction with
| `bar' as its read-only source operand and `foo' as its read-write
| destination:
| 
|      asm ("combine %2,%0" : "=r" (foo) : "0" (foo), "g" (bar));
| 
| The constraint `"0"' for operand 1 says that it must occupy the same
| location as operand 0.  A number in constraint is allowed only in an
| input operand and it must refer to an output operand.
| 
|    Only a number in the constraint can guarantee that one operand will
| be in the same place as another.  The mere fact that `foo' is the value
| of both operands is not enough to guarantee that they will be in the
| same place in the generated assembler code.  The following would not
| work reliably:
| 
|      asm ("combine %2,%0" : "=r" (foo) : "r" (foo), "g" (bar));

Can you explain the need for the change?

-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 PCMCIA      - http://pcmcia.arm.linux.org.uk/
                 2.6 Serial core

  reply	other threads:[~2004-05-06 12:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-06 11:58 [PATCH] get rid of "+m" constraint in i386 rwsems David Howells
2004-05-06 12:18 ` Russell King [this message]
2004-05-06 12:58   ` David Howells
2004-05-06 13:24     ` Russell King
2004-05-06 19:23       ` Horst von Brand
2004-05-06 14:42 ` Linus Torvalds
2004-05-06 23:45   ` Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040506131846.A29621@flint.arm.linux.org.uk \
    --to=rmk+lkml@arm.linux.org.uk \
    --cc=akpm@osdl.org \
    --cc=dhowells@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox