linux-mips
[Top] [All Lists]

branch delay slot

To: linux-mips@linux-mips.org
Subject: branch delay slot
From: "Winson Yung" <winson.yung@gmail.com>
Date: Fri, 21 Sep 2007 09:01:15 -0700
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; bh=lVGPG37d6VSKBJtY3o44Gerpo3T07Sa5Ho+NWfEpH1Y=; b=SWBoDlDnfLw+7r5undPgiEjQEOd3j3KDLkPd6e36rrRq++EZW2UeSh7ZRpADHB3ygWFAXIJI4t6fG6QWbrphgdCxvagQpy++NydjNi/1uvCl6x7mFJOERh8fw2FyLOZwBlYVvv+4KwJpZKE0ihhVA2YMfqZiu2aoW9WTrAn67Vk=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=Ve4LdoSkHTZyd96eCZSyWFEUBX8MykumRhFQxbGTGGT8zy3nFDT7pRgUjR27Hrz1xIrIPrlnsfVI9lFSz7tu9mgg8pmUflQuH7aL8zX2aIEUZJXCPdKf1qtfmoznxfrXeFRAvLrgMM+qtYMIykktSfhZg8pJBBNz7QD7zsmcMnI=
Original-recipient: rfc822;linux-mips@linux-mips.org
Sender: linux-mips-bounce@linux-mips.org
Hi there, in the following mips 32bit atomic cmp_xchg api, I was
wondering why there is no nop after the two branch instructions. Does
this introduce a bug, or is it a "feature" in the code to use the
delay slot for an instructino to execut something whether or not they
take the branch.

#define __arch_compare_and_exchange_xxx_32_int(mem, newval, oldval, rel, acq) \
     __asm__ __volatile__ (                                                   \
     ".set      push\n\t"                                                     \
     MIPS_PUSH_MIPS2                                                          \
     rel        "\n"                                                          \
     "1:\t"                                                                   \
     "ll        %0,%4\n\t"                                                    \
     "move      %1,$0\n\t"                                                    \
     "bne       %0,%2,2f\n\t"                                                 \
     "move      %1,%3\n\t"                                                    \
     "sc        %1,%4\n\t"                                                    \
     "beqz      %1,1b\n"                                                      \
     acq        "\n\t"                                                        \
     ".set      pop\n"                                                        \
     "2:\n\t"                                                                 \
              : "=&r" (__prev), "=&r" (__cmp)                                 \
              : "r" (oldval), "r" (newval), "m" (*mem)                        \
              : "memory")

<Prev in Thread] Current Thread [Next in Thread>