On Sat, Apr 20, 2002 at 02:42:46AM -0700, Brian Pane wrote: > This patch removes what I think is extraneous code in > the atomic compare-and-swap function for sparcs. Since > it's assembly, I'd like to get a second opinion before > I commit it.
Yes, this change looks correct. +1. The Sparc V9 Architecture Manual says (pg. 152): The CASA instruction compares the low-order 32 bits of register r[rs2] with a word in memory pointed to by the word address in r[rs1]. If the values are equal, the low-order 32 bits of register r[rd] are swapped with the contents of the memory word pointed to by the address in r[rs1] and the high-order 32 bits of register r[rd] are set to zero. If the values are not equal, the memory location remains unchanges, but the zero-extended contents of the memory word pointed to by r[rs1] replace the low-order 32 bits of r[rd] and the high-order 32 bits of register r[rd] are set to zero. (Try reading that ten times fast...cas is a synthetic instruction for casa) Basically, I parse the above as this: if mem(r[rs1]) == r[rs2] then swap mem(r[rs1]) and r[rd] else r[rd] = mem(r[rs1]) endif high-order(r[rd]) = 0 So, r[rd] should always have the "old" value. In our screwy assembler semantics (why do we use %o1 as r[rd]?), that's %o1. Hope this helps. -- justin
