On Mon, 2002-06-17 at 15:36, Thiemo Seufer wrote:
> Ralf Baechle wrote:
> > > Looks to me like we're missing some proper asm clobber markers:
> > No, as per convention $1 is never used by the compiler per convention,
> > so clobbering not necessary. I recently removed all "$1" clobbers to
> > make the code a bit easier to read.
> How can this work? A grep shows many instances of $1 usage,
> I don't think all of this code is interrupt safe.
The "$x" clobber markers exist so that the *compiler* won't expect
values in those registers to be preserved across the asm call. It has
nothing to do with safety across interrupts. In other words, it's there
to prevent something like this:
foo = 2; // Compiler sticks foo a register, say, $2
" lw $2, baz\n"
" sw $2, (%0)\n"
::"r" (sna)); // Assembly code uses $2 as a temp reg
(*bar) = foo; // Compiler erroneously does (*bar) = baz;
In terms of interrupt safety, there is no issue with $1; any interrupt
would save the register before mucking with it, and restore it before
returning. The only registers for which this is not true are k0 and k1.
As others have rightly pointed out, the compiler isn't allowed to muck
with $1 anyways, as it is defined to be a temporary register for the
assembler. So the clobber notation isn't necessary.