Re: [PATCH] get rid of "+m" constraint in i386 rwsems

From: Russell King
Date: Thu May 06 2004 - 07:21:23 EST


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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/