Enable a suitable ISA for the assembler around ll/sc so that code

builds even for processors that don't support the instructions.
Plus minor formatting fixes.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
This commit is contained in:
Maciej W. Rozycki 2005-06-14 17:35:03 +00:00 committed by Ralf Baechle
parent fded2e508a
commit aac8aa7717
4 changed files with 118 additions and 32 deletions

View File

@ -42,24 +42,28 @@ static inline int __sem_update_count(struct semaphore *sem, int incr)
if (cpu_has_llsc && R10000_LLSC_WAR) { if (cpu_has_llsc && R10000_LLSC_WAR) {
__asm__ __volatile__( __asm__ __volatile__(
"1: ll %0, %2 \n" " .set mips2 \n"
"1: ll %0, %2 # __sem_update_count \n"
" sra %1, %0, 31 \n" " sra %1, %0, 31 \n"
" not %1 \n" " not %1 \n"
" and %1, %0, %1 \n" " and %1, %0, %1 \n"
" add %1, %1, %3 \n" " addu %1, %1, %3 \n"
" sc %1, %2 \n" " sc %1, %2 \n"
" beqzl %1, 1b \n" " beqzl %1, 1b \n"
" .set mips0 \n"
: "=&r" (old_count), "=&r" (tmp), "=m" (sem->count) : "=&r" (old_count), "=&r" (tmp), "=m" (sem->count)
: "r" (incr), "m" (sem->count)); : "r" (incr), "m" (sem->count));
} else if (cpu_has_llsc) { } else if (cpu_has_llsc) {
__asm__ __volatile__( __asm__ __volatile__(
"1: ll %0, %2 \n" " .set mips2 \n"
"1: ll %0, %2 # __sem_update_count \n"
" sra %1, %0, 31 \n" " sra %1, %0, 31 \n"
" not %1 \n" " not %1 \n"
" and %1, %0, %1 \n" " and %1, %0, %1 \n"
" add %1, %1, %3 \n" " addu %1, %1, %3 \n"
" sc %1, %2 \n" " sc %1, %2 \n"
" beqz %1, 1b \n" " beqz %1, 1b \n"
" .set mips0 \n"
: "=&r" (old_count), "=&r" (tmp), "=m" (sem->count) : "=&r" (old_count), "=&r" (tmp), "=m" (sem->count)
: "r" (incr), "m" (sem->count)); : "r" (incr), "m" (sem->count));
} else { } else {

View File

@ -62,20 +62,24 @@ static __inline__ void atomic_add(int i, atomic_t * v)
unsigned long temp; unsigned long temp;
__asm__ __volatile__( __asm__ __volatile__(
" .set mips2 \n"
"1: ll %0, %1 # atomic_add \n" "1: ll %0, %1 # atomic_add \n"
" addu %0, %2 \n" " addu %0, %2 \n"
" sc %0, %1 \n" " sc %0, %1 \n"
" beqzl %0, 1b \n" " beqzl %0, 1b \n"
" .set mips0 \n"
: "=&r" (temp), "=m" (v->counter) : "=&r" (temp), "=m" (v->counter)
: "Ir" (i), "m" (v->counter)); : "Ir" (i), "m" (v->counter));
} else if (cpu_has_llsc) { } else if (cpu_has_llsc) {
unsigned long temp; unsigned long temp;
__asm__ __volatile__( __asm__ __volatile__(
" .set mips2 \n"
"1: ll %0, %1 # atomic_add \n" "1: ll %0, %1 # atomic_add \n"
" addu %0, %2 \n" " addu %0, %2 \n"
" sc %0, %1 \n" " sc %0, %1 \n"
" beqz %0, 1b \n" " beqz %0, 1b \n"
" .set mips0 \n"
: "=&r" (temp), "=m" (v->counter) : "=&r" (temp), "=m" (v->counter)
: "Ir" (i), "m" (v->counter)); : "Ir" (i), "m" (v->counter));
} else { } else {
@ -100,20 +104,24 @@ static __inline__ void atomic_sub(int i, atomic_t * v)
unsigned long temp; unsigned long temp;
__asm__ __volatile__( __asm__ __volatile__(
" .set mips2 \n"
"1: ll %0, %1 # atomic_sub \n" "1: ll %0, %1 # atomic_sub \n"
" subu %0, %2 \n" " subu %0, %2 \n"
" sc %0, %1 \n" " sc %0, %1 \n"
" beqzl %0, 1b \n" " beqzl %0, 1b \n"
" .set mips0 \n"
: "=&r" (temp), "=m" (v->counter) : "=&r" (temp), "=m" (v->counter)
: "Ir" (i), "m" (v->counter)); : "Ir" (i), "m" (v->counter));
} else if (cpu_has_llsc) { } else if (cpu_has_llsc) {
unsigned long temp; unsigned long temp;
__asm__ __volatile__( __asm__ __volatile__(
" .set mips2 \n"
"1: ll %0, %1 # atomic_sub \n" "1: ll %0, %1 # atomic_sub \n"
" subu %0, %2 \n" " subu %0, %2 \n"
" sc %0, %1 \n" " sc %0, %1 \n"
" beqz %0, 1b \n" " beqz %0, 1b \n"
" .set mips0 \n"
: "=&r" (temp), "=m" (v->counter) : "=&r" (temp), "=m" (v->counter)
: "Ir" (i), "m" (v->counter)); : "Ir" (i), "m" (v->counter));
} else { } else {
@ -136,12 +144,14 @@ static __inline__ int atomic_add_return(int i, atomic_t * v)
unsigned long temp; unsigned long temp;
__asm__ __volatile__( __asm__ __volatile__(
" .set mips2 \n"
"1: ll %1, %2 # atomic_add_return \n" "1: ll %1, %2 # atomic_add_return \n"
" addu %0, %1, %3 \n" " addu %0, %1, %3 \n"
" sc %0, %2 \n" " sc %0, %2 \n"
" beqzl %0, 1b \n" " beqzl %0, 1b \n"
" addu %0, %1, %3 \n" " addu %0, %1, %3 \n"
" sync \n" " sync \n"
" .set mips0 \n"
: "=&r" (result), "=&r" (temp), "=m" (v->counter) : "=&r" (result), "=&r" (temp), "=m" (v->counter)
: "Ir" (i), "m" (v->counter) : "Ir" (i), "m" (v->counter)
: "memory"); : "memory");
@ -149,12 +159,14 @@ static __inline__ int atomic_add_return(int i, atomic_t * v)
unsigned long temp; unsigned long temp;
__asm__ __volatile__( __asm__ __volatile__(
" .set mips2 \n"
"1: ll %1, %2 # atomic_add_return \n" "1: ll %1, %2 # atomic_add_return \n"
" addu %0, %1, %3 \n" " addu %0, %1, %3 \n"
" sc %0, %2 \n" " sc %0, %2 \n"
" beqz %0, 1b \n" " beqz %0, 1b \n"
" addu %0, %1, %3 \n" " addu %0, %1, %3 \n"
" sync \n" " sync \n"
" .set mips0 \n"
: "=&r" (result), "=&r" (temp), "=m" (v->counter) : "=&r" (result), "=&r" (temp), "=m" (v->counter)
: "Ir" (i), "m" (v->counter) : "Ir" (i), "m" (v->counter)
: "memory"); : "memory");
@ -179,12 +191,14 @@ static __inline__ int atomic_sub_return(int i, atomic_t * v)
unsigned long temp; unsigned long temp;
__asm__ __volatile__( __asm__ __volatile__(
" .set mips2 \n"
"1: ll %1, %2 # atomic_sub_return \n" "1: ll %1, %2 # atomic_sub_return \n"
" subu %0, %1, %3 \n" " subu %0, %1, %3 \n"
" sc %0, %2 \n" " sc %0, %2 \n"
" beqzl %0, 1b \n" " beqzl %0, 1b \n"
" subu %0, %1, %3 \n" " subu %0, %1, %3 \n"
" sync \n" " sync \n"
" .set mips0 \n"
: "=&r" (result), "=&r" (temp), "=m" (v->counter) : "=&r" (result), "=&r" (temp), "=m" (v->counter)
: "Ir" (i), "m" (v->counter) : "Ir" (i), "m" (v->counter)
: "memory"); : "memory");
@ -192,12 +206,14 @@ static __inline__ int atomic_sub_return(int i, atomic_t * v)
unsigned long temp; unsigned long temp;
__asm__ __volatile__( __asm__ __volatile__(
" .set mips2 \n"
"1: ll %1, %2 # atomic_sub_return \n" "1: ll %1, %2 # atomic_sub_return \n"
" subu %0, %1, %3 \n" " subu %0, %1, %3 \n"
" sc %0, %2 \n" " sc %0, %2 \n"
" beqz %0, 1b \n" " beqz %0, 1b \n"
" subu %0, %1, %3 \n" " subu %0, %1, %3 \n"
" sync \n" " sync \n"
" .set mips0 \n"
: "=&r" (result), "=&r" (temp), "=m" (v->counter) : "=&r" (result), "=&r" (temp), "=m" (v->counter)
: "Ir" (i), "m" (v->counter) : "Ir" (i), "m" (v->counter)
: "memory"); : "memory");
@ -229,6 +245,7 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
unsigned long temp; unsigned long temp;
__asm__ __volatile__( __asm__ __volatile__(
" .set mips2 \n"
"1: ll %1, %2 # atomic_sub_if_positive\n" "1: ll %1, %2 # atomic_sub_if_positive\n"
" subu %0, %1, %3 \n" " subu %0, %1, %3 \n"
" bltz %0, 1f \n" " bltz %0, 1f \n"
@ -236,6 +253,7 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
" beqzl %0, 1b \n" " beqzl %0, 1b \n"
" sync \n" " sync \n"
"1: \n" "1: \n"
" .set mips0 \n"
: "=&r" (result), "=&r" (temp), "=m" (v->counter) : "=&r" (result), "=&r" (temp), "=m" (v->counter)
: "Ir" (i), "m" (v->counter) : "Ir" (i), "m" (v->counter)
: "memory"); : "memory");
@ -243,6 +261,7 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
unsigned long temp; unsigned long temp;
__asm__ __volatile__( __asm__ __volatile__(
" .set mips2 \n"
"1: ll %1, %2 # atomic_sub_if_positive\n" "1: ll %1, %2 # atomic_sub_if_positive\n"
" subu %0, %1, %3 \n" " subu %0, %1, %3 \n"
" bltz %0, 1f \n" " bltz %0, 1f \n"
@ -250,6 +269,7 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
" beqz %0, 1b \n" " beqz %0, 1b \n"
" sync \n" " sync \n"
"1: \n" "1: \n"
" .set mips0 \n"
: "=&r" (result), "=&r" (temp), "=m" (v->counter) : "=&r" (result), "=&r" (temp), "=m" (v->counter)
: "Ir" (i), "m" (v->counter) : "Ir" (i), "m" (v->counter)
: "memory"); : "memory");
@ -367,20 +387,24 @@ static __inline__ void atomic64_add(long i, atomic64_t * v)
unsigned long temp; unsigned long temp;
__asm__ __volatile__( __asm__ __volatile__(
" .set mips3 \n"
"1: lld %0, %1 # atomic64_add \n" "1: lld %0, %1 # atomic64_add \n"
" addu %0, %2 \n" " addu %0, %2 \n"
" scd %0, %1 \n" " scd %0, %1 \n"
" beqzl %0, 1b \n" " beqzl %0, 1b \n"
" .set mips0 \n"
: "=&r" (temp), "=m" (v->counter) : "=&r" (temp), "=m" (v->counter)
: "Ir" (i), "m" (v->counter)); : "Ir" (i), "m" (v->counter));
} else if (cpu_has_llsc) { } else if (cpu_has_llsc) {
unsigned long temp; unsigned long temp;
__asm__ __volatile__( __asm__ __volatile__(
" .set mips3 \n"
"1: lld %0, %1 # atomic64_add \n" "1: lld %0, %1 # atomic64_add \n"
" addu %0, %2 \n" " addu %0, %2 \n"
" scd %0, %1 \n" " scd %0, %1 \n"
" beqz %0, 1b \n" " beqz %0, 1b \n"
" .set mips0 \n"
: "=&r" (temp), "=m" (v->counter) : "=&r" (temp), "=m" (v->counter)
: "Ir" (i), "m" (v->counter)); : "Ir" (i), "m" (v->counter));
} else { } else {
@ -405,20 +429,24 @@ static __inline__ void atomic64_sub(long i, atomic64_t * v)
unsigned long temp; unsigned long temp;
__asm__ __volatile__( __asm__ __volatile__(
" .set mips3 \n"
"1: lld %0, %1 # atomic64_sub \n" "1: lld %0, %1 # atomic64_sub \n"
" subu %0, %2 \n" " subu %0, %2 \n"
" scd %0, %1 \n" " scd %0, %1 \n"
" beqzl %0, 1b \n" " beqzl %0, 1b \n"
" .set mips0 \n"
: "=&r" (temp), "=m" (v->counter) : "=&r" (temp), "=m" (v->counter)
: "Ir" (i), "m" (v->counter)); : "Ir" (i), "m" (v->counter));
} else if (cpu_has_llsc) { } else if (cpu_has_llsc) {
unsigned long temp; unsigned long temp;
__asm__ __volatile__( __asm__ __volatile__(
" .set mips3 \n"
"1: lld %0, %1 # atomic64_sub \n" "1: lld %0, %1 # atomic64_sub \n"
" subu %0, %2 \n" " subu %0, %2 \n"
" scd %0, %1 \n" " scd %0, %1 \n"
" beqz %0, 1b \n" " beqz %0, 1b \n"
" .set mips0 \n"
: "=&r" (temp), "=m" (v->counter) : "=&r" (temp), "=m" (v->counter)
: "Ir" (i), "m" (v->counter)); : "Ir" (i), "m" (v->counter));
} else { } else {
@ -441,12 +469,14 @@ static __inline__ long atomic64_add_return(long i, atomic64_t * v)
unsigned long temp; unsigned long temp;
__asm__ __volatile__( __asm__ __volatile__(
" .set mips3 \n"
"1: lld %1, %2 # atomic64_add_return \n" "1: lld %1, %2 # atomic64_add_return \n"
" addu %0, %1, %3 \n" " addu %0, %1, %3 \n"
" scd %0, %2 \n" " scd %0, %2 \n"
" beqzl %0, 1b \n" " beqzl %0, 1b \n"
" addu %0, %1, %3 \n" " addu %0, %1, %3 \n"
" sync \n" " sync \n"
" .set mips0 \n"
: "=&r" (result), "=&r" (temp), "=m" (v->counter) : "=&r" (result), "=&r" (temp), "=m" (v->counter)
: "Ir" (i), "m" (v->counter) : "Ir" (i), "m" (v->counter)
: "memory"); : "memory");
@ -454,12 +484,14 @@ static __inline__ long atomic64_add_return(long i, atomic64_t * v)
unsigned long temp; unsigned long temp;
__asm__ __volatile__( __asm__ __volatile__(
" .set mips3 \n"
"1: lld %1, %2 # atomic64_add_return \n" "1: lld %1, %2 # atomic64_add_return \n"
" addu %0, %1, %3 \n" " addu %0, %1, %3 \n"
" scd %0, %2 \n" " scd %0, %2 \n"
" beqz %0, 1b \n" " beqz %0, 1b \n"
" addu %0, %1, %3 \n" " addu %0, %1, %3 \n"
" sync \n" " sync \n"
" .set mips0 \n"
: "=&r" (result), "=&r" (temp), "=m" (v->counter) : "=&r" (result), "=&r" (temp), "=m" (v->counter)
: "Ir" (i), "m" (v->counter) : "Ir" (i), "m" (v->counter)
: "memory"); : "memory");
@ -484,12 +516,14 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
unsigned long temp; unsigned long temp;
__asm__ __volatile__( __asm__ __volatile__(
" .set mips3 \n"
"1: lld %1, %2 # atomic64_sub_return \n" "1: lld %1, %2 # atomic64_sub_return \n"
" subu %0, %1, %3 \n" " subu %0, %1, %3 \n"
" scd %0, %2 \n" " scd %0, %2 \n"
" beqzl %0, 1b \n" " beqzl %0, 1b \n"
" subu %0, %1, %3 \n" " subu %0, %1, %3 \n"
" sync \n" " sync \n"
" .set mips0 \n"
: "=&r" (result), "=&r" (temp), "=m" (v->counter) : "=&r" (result), "=&r" (temp), "=m" (v->counter)
: "Ir" (i), "m" (v->counter) : "Ir" (i), "m" (v->counter)
: "memory"); : "memory");
@ -497,12 +531,14 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
unsigned long temp; unsigned long temp;
__asm__ __volatile__( __asm__ __volatile__(
" .set mips3 \n"
"1: lld %1, %2 # atomic64_sub_return \n" "1: lld %1, %2 # atomic64_sub_return \n"
" subu %0, %1, %3 \n" " subu %0, %1, %3 \n"
" scd %0, %2 \n" " scd %0, %2 \n"
" beqz %0, 1b \n" " beqz %0, 1b \n"
" subu %0, %1, %3 \n" " subu %0, %1, %3 \n"
" sync \n" " sync \n"
" .set mips0 \n"
: "=&r" (result), "=&r" (temp), "=m" (v->counter) : "=&r" (result), "=&r" (temp), "=m" (v->counter)
: "Ir" (i), "m" (v->counter) : "Ir" (i), "m" (v->counter)
: "memory"); : "memory");
@ -534,6 +570,7 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
unsigned long temp; unsigned long temp;
__asm__ __volatile__( __asm__ __volatile__(
" .set mips3 \n"
"1: lld %1, %2 # atomic64_sub_if_positive\n" "1: lld %1, %2 # atomic64_sub_if_positive\n"
" dsubu %0, %1, %3 \n" " dsubu %0, %1, %3 \n"
" bltz %0, 1f \n" " bltz %0, 1f \n"
@ -541,6 +578,7 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
" beqzl %0, 1b \n" " beqzl %0, 1b \n"
" sync \n" " sync \n"
"1: \n" "1: \n"
" .set mips0 \n"
: "=&r" (result), "=&r" (temp), "=m" (v->counter) : "=&r" (result), "=&r" (temp), "=m" (v->counter)
: "Ir" (i), "m" (v->counter) : "Ir" (i), "m" (v->counter)
: "memory"); : "memory");
@ -548,6 +586,7 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
unsigned long temp; unsigned long temp;
__asm__ __volatile__( __asm__ __volatile__(
" .set mips3 \n"
"1: lld %1, %2 # atomic64_sub_if_positive\n" "1: lld %1, %2 # atomic64_sub_if_positive\n"
" dsubu %0, %1, %3 \n" " dsubu %0, %1, %3 \n"
" bltz %0, 1f \n" " bltz %0, 1f \n"
@ -555,6 +594,7 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
" beqz %0, 1b \n" " beqz %0, 1b \n"
" sync \n" " sync \n"
"1: \n" "1: \n"
" .set mips0 \n"
: "=&r" (result), "=&r" (temp), "=m" (v->counter) : "=&r" (result), "=&r" (temp), "=m" (v->counter)
: "Ir" (i), "m" (v->counter) : "Ir" (i), "m" (v->counter)
: "memory"); : "memory");

View File

@ -20,12 +20,14 @@
#define SZLONG_MASK 31UL #define SZLONG_MASK 31UL
#define __LL "ll " #define __LL "ll "
#define __SC "sc " #define __SC "sc "
#define __SET_MIPS ".set mips2 "
#define cpu_to_lelongp(x) cpu_to_le32p((__u32 *) (x)) #define cpu_to_lelongp(x) cpu_to_le32p((__u32 *) (x))
#elif (_MIPS_SZLONG == 64) #elif (_MIPS_SZLONG == 64)
#define SZLONG_LOG 6 #define SZLONG_LOG 6
#define SZLONG_MASK 63UL #define SZLONG_MASK 63UL
#define __LL "lld " #define __LL "lld "
#define __SC "scd " #define __SC "scd "
#define __SET_MIPS ".set mips3 "
#define cpu_to_lelongp(x) cpu_to_le64p((__u64 *) (x)) #define cpu_to_lelongp(x) cpu_to_le64p((__u64 *) (x))
#endif #endif
@ -72,18 +74,22 @@ static inline void set_bit(unsigned long nr, volatile unsigned long *addr)
if (cpu_has_llsc && R10000_LLSC_WAR) { if (cpu_has_llsc && R10000_LLSC_WAR) {
__asm__ __volatile__( __asm__ __volatile__(
" " __SET_MIPS " \n"
"1: " __LL "%0, %1 # set_bit \n" "1: " __LL "%0, %1 # set_bit \n"
" or %0, %2 \n" " or %0, %2 \n"
" "__SC "%0, %1 \n" " " __SC "%0, %1 \n"
" beqzl %0, 1b \n" " beqzl %0, 1b \n"
" .set mips0 \n"
: "=&r" (temp), "=m" (*m) : "=&r" (temp), "=m" (*m)
: "ir" (1UL << (nr & SZLONG_MASK)), "m" (*m)); : "ir" (1UL << (nr & SZLONG_MASK)), "m" (*m));
} else if (cpu_has_llsc) { } else if (cpu_has_llsc) {
__asm__ __volatile__( __asm__ __volatile__(
" " __SET_MIPS " \n"
"1: " __LL "%0, %1 # set_bit \n" "1: " __LL "%0, %1 # set_bit \n"
" or %0, %2 \n" " or %0, %2 \n"
" "__SC "%0, %1 \n" " " __SC "%0, %1 \n"
" beqz %0, 1b \n" " beqz %0, 1b \n"
" .set mips0 \n"
: "=&r" (temp), "=m" (*m) : "=&r" (temp), "=m" (*m)
: "ir" (1UL << (nr & SZLONG_MASK)), "m" (*m)); : "ir" (1UL << (nr & SZLONG_MASK)), "m" (*m));
} else { } else {
@ -132,18 +138,22 @@ static inline void clear_bit(unsigned long nr, volatile unsigned long *addr)
if (cpu_has_llsc && R10000_LLSC_WAR) { if (cpu_has_llsc && R10000_LLSC_WAR) {
__asm__ __volatile__( __asm__ __volatile__(
" " __SET_MIPS " \n"
"1: " __LL "%0, %1 # clear_bit \n" "1: " __LL "%0, %1 # clear_bit \n"
" and %0, %2 \n" " and %0, %2 \n"
" " __SC "%0, %1 \n" " " __SC "%0, %1 \n"
" beqzl %0, 1b \n" " beqzl %0, 1b \n"
" .set mips0 \n"
: "=&r" (temp), "=m" (*m) : "=&r" (temp), "=m" (*m)
: "ir" (~(1UL << (nr & SZLONG_MASK))), "m" (*m)); : "ir" (~(1UL << (nr & SZLONG_MASK))), "m" (*m));
} else if (cpu_has_llsc) { } else if (cpu_has_llsc) {
__asm__ __volatile__( __asm__ __volatile__(
" " __SET_MIPS " \n"
"1: " __LL "%0, %1 # clear_bit \n" "1: " __LL "%0, %1 # clear_bit \n"
" and %0, %2 \n" " and %0, %2 \n"
" " __SC "%0, %1 \n" " " __SC "%0, %1 \n"
" beqz %0, 1b \n" " beqz %0, 1b \n"
" .set mips0 \n"
: "=&r" (temp), "=m" (*m) : "=&r" (temp), "=m" (*m)
: "ir" (~(1UL << (nr & SZLONG_MASK))), "m" (*m)); : "ir" (~(1UL << (nr & SZLONG_MASK))), "m" (*m));
} else { } else {
@ -191,10 +201,12 @@ static inline void change_bit(unsigned long nr, volatile unsigned long *addr)
unsigned long temp; unsigned long temp;
__asm__ __volatile__( __asm__ __volatile__(
" " __SET_MIPS " \n"
"1: " __LL "%0, %1 # change_bit \n" "1: " __LL "%0, %1 # change_bit \n"
" xor %0, %2 \n" " xor %0, %2 \n"
" "__SC "%0, %1 \n" " " __SC "%0, %1 \n"
" beqzl %0, 1b \n" " beqzl %0, 1b \n"
" .set mips0 \n"
: "=&r" (temp), "=m" (*m) : "=&r" (temp), "=m" (*m)
: "ir" (1UL << (nr & SZLONG_MASK)), "m" (*m)); : "ir" (1UL << (nr & SZLONG_MASK)), "m" (*m));
} else if (cpu_has_llsc) { } else if (cpu_has_llsc) {
@ -202,10 +214,12 @@ static inline void change_bit(unsigned long nr, volatile unsigned long *addr)
unsigned long temp; unsigned long temp;
__asm__ __volatile__( __asm__ __volatile__(
" " __SET_MIPS " \n"
"1: " __LL "%0, %1 # change_bit \n" "1: " __LL "%0, %1 # change_bit \n"
" xor %0, %2 \n" " xor %0, %2 \n"
" "__SC "%0, %1 \n" " " __SC "%0, %1 \n"
" beqz %0, 1b \n" " beqz %0, 1b \n"
" .set mips0 \n"
: "=&r" (temp), "=m" (*m) : "=&r" (temp), "=m" (*m)
: "ir" (1UL << (nr & SZLONG_MASK)), "m" (*m)); : "ir" (1UL << (nr & SZLONG_MASK)), "m" (*m));
} else { } else {
@ -253,14 +267,16 @@ static inline int test_and_set_bit(unsigned long nr,
unsigned long temp, res; unsigned long temp, res;
__asm__ __volatile__( __asm__ __volatile__(
" " __SET_MIPS " \n"
"1: " __LL "%0, %1 # test_and_set_bit \n" "1: " __LL "%0, %1 # test_and_set_bit \n"
" or %2, %0, %3 \n" " or %2, %0, %3 \n"
" " __SC "%2, %1 \n" " " __SC "%2, %1 \n"
" beqzl %2, 1b \n" " beqzl %2, 1b \n"
" and %2, %0, %3 \n" " and %2, %0, %3 \n"
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
"sync \n" " sync \n"
#endif #endif
" .set mips0 \n"
: "=&r" (temp), "=m" (*m), "=&r" (res) : "=&r" (temp), "=m" (*m), "=&r" (res)
: "r" (1UL << (nr & SZLONG_MASK)), "m" (*m) : "r" (1UL << (nr & SZLONG_MASK)), "m" (*m)
: "memory"); : "memory");
@ -271,16 +287,18 @@ static inline int test_and_set_bit(unsigned long nr,
unsigned long temp, res; unsigned long temp, res;
__asm__ __volatile__( __asm__ __volatile__(
" .set noreorder # test_and_set_bit \n" " .set push \n"
"1: " __LL "%0, %1 \n" " .set noreorder \n"
" " __SET_MIPS " \n"
"1: " __LL "%0, %1 # test_and_set_bit \n"
" or %2, %0, %3 \n" " or %2, %0, %3 \n"
" " __SC "%2, %1 \n" " " __SC "%2, %1 \n"
" beqz %2, 1b \n" " beqz %2, 1b \n"
" and %2, %0, %3 \n" " and %2, %0, %3 \n"
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
"sync \n" " sync \n"
#endif #endif
".set\treorder" " .set pop \n"
: "=&r" (temp), "=m" (*m), "=&r" (res) : "=&r" (temp), "=m" (*m), "=&r" (res)
: "r" (1UL << (nr & SZLONG_MASK)), "m" (*m) : "r" (1UL << (nr & SZLONG_MASK)), "m" (*m)
: "memory"); : "memory");
@ -343,15 +361,17 @@ static inline int test_and_clear_bit(unsigned long nr,
unsigned long temp, res; unsigned long temp, res;
__asm__ __volatile__( __asm__ __volatile__(
" " __SET_MIPS " \n"
"1: " __LL "%0, %1 # test_and_clear_bit \n" "1: " __LL "%0, %1 # test_and_clear_bit \n"
" or %2, %0, %3 \n" " or %2, %0, %3 \n"
" xor %2, %3 \n" " xor %2, %3 \n"
__SC "%2, %1 \n" " " __SC "%2, %1 \n"
" beqzl %2, 1b \n" " beqzl %2, 1b \n"
" and %2, %0, %3 \n" " and %2, %0, %3 \n"
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
" sync \n" " sync \n"
#endif #endif
" .set mips0 \n"
: "=&r" (temp), "=m" (*m), "=&r" (res) : "=&r" (temp), "=m" (*m), "=&r" (res)
: "r" (1UL << (nr & SZLONG_MASK)), "m" (*m) : "r" (1UL << (nr & SZLONG_MASK)), "m" (*m)
: "memory"); : "memory");
@ -362,17 +382,19 @@ static inline int test_and_clear_bit(unsigned long nr,
unsigned long temp, res; unsigned long temp, res;
__asm__ __volatile__( __asm__ __volatile__(
" .set noreorder # test_and_clear_bit \n" " .set push \n"
"1: " __LL "%0, %1 \n" " .set noreorder \n"
" " __SET_MIPS " \n"
"1: " __LL "%0, %1 # test_and_clear_bit \n"
" or %2, %0, %3 \n" " or %2, %0, %3 \n"
" xor %2, %3 \n" " xor %2, %3 \n"
__SC "%2, %1 \n" " " __SC "%2, %1 \n"
" beqz %2, 1b \n" " beqz %2, 1b \n"
" and %2, %0, %3 \n" " and %2, %0, %3 \n"
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
" sync \n" " sync \n"
#endif #endif
" .set reorder \n" " .set pop \n"
: "=&r" (temp), "=m" (*m), "=&r" (res) : "=&r" (temp), "=m" (*m), "=&r" (res)
: "r" (1UL << (nr & SZLONG_MASK)), "m" (*m) : "r" (1UL << (nr & SZLONG_MASK)), "m" (*m)
: "memory"); : "memory");
@ -435,14 +457,16 @@ static inline int test_and_change_bit(unsigned long nr,
unsigned long temp, res; unsigned long temp, res;
__asm__ __volatile__( __asm__ __volatile__(
"1: " __LL " %0, %1 # test_and_change_bit \n" " " __SET_MIPS " \n"
"1: " __LL "%0, %1 # test_and_change_bit \n"
" xor %2, %0, %3 \n" " xor %2, %0, %3 \n"
" "__SC "%2, %1 \n" " " __SC "%2, %1 \n"
" beqzl %2, 1b \n" " beqzl %2, 1b \n"
" and %2, %0, %3 \n" " and %2, %0, %3 \n"
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
" sync \n" " sync \n"
#endif #endif
" .set mips0 \n"
: "=&r" (temp), "=m" (*m), "=&r" (res) : "=&r" (temp), "=m" (*m), "=&r" (res)
: "r" (1UL << (nr & SZLONG_MASK)), "m" (*m) : "r" (1UL << (nr & SZLONG_MASK)), "m" (*m)
: "memory"); : "memory");
@ -453,16 +477,18 @@ static inline int test_and_change_bit(unsigned long nr,
unsigned long temp, res; unsigned long temp, res;
__asm__ __volatile__( __asm__ __volatile__(
" .set noreorder # test_and_change_bit \n" " .set push \n"
"1: " __LL " %0, %1 \n" " .set noreorder \n"
" " __SET_MIPS " \n"
"1: " __LL "%0, %1 # test_and_change_bit \n"
" xor %2, %0, %3 \n" " xor %2, %0, %3 \n"
" "__SC "\t%2, %1 \n" " " __SC "\t%2, %1 \n"
" beqz %2, 1b \n" " beqz %2, 1b \n"
" and %2, %0, %3 \n" " and %2, %0, %3 \n"
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
" sync \n" " sync \n"
#endif #endif
" .set reorder \n" " .set pop \n"
: "=&r" (temp), "=m" (*m), "=&r" (res) : "=&r" (temp), "=m" (*m), "=&r" (res)
: "r" (1UL << (nr & SZLONG_MASK)), "m" (*m) : "r" (1UL << (nr & SZLONG_MASK)), "m" (*m)
: "memory"); : "memory");

View File

@ -176,6 +176,7 @@ static inline unsigned long __xchg_u32(volatile int * m, unsigned int val)
unsigned long dummy; unsigned long dummy;
__asm__ __volatile__( __asm__ __volatile__(
" .set mips2 \n"
"1: ll %0, %3 # xchg_u32 \n" "1: ll %0, %3 # xchg_u32 \n"
" move %2, %z4 \n" " move %2, %z4 \n"
" sc %2, %1 \n" " sc %2, %1 \n"
@ -184,6 +185,7 @@ static inline unsigned long __xchg_u32(volatile int * m, unsigned int val)
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
" sync \n" " sync \n"
#endif #endif
" .set mips0 \n"
: "=&r" (retval), "=m" (*m), "=&r" (dummy) : "=&r" (retval), "=m" (*m), "=&r" (dummy)
: "R" (*m), "Jr" (val) : "R" (*m), "Jr" (val)
: "memory"); : "memory");
@ -191,6 +193,7 @@ static inline unsigned long __xchg_u32(volatile int * m, unsigned int val)
unsigned long dummy; unsigned long dummy;
__asm__ __volatile__( __asm__ __volatile__(
" .set mips2 \n"
"1: ll %0, %3 # xchg_u32 \n" "1: ll %0, %3 # xchg_u32 \n"
" move %2, %z4 \n" " move %2, %z4 \n"
" sc %2, %1 \n" " sc %2, %1 \n"
@ -198,6 +201,7 @@ static inline unsigned long __xchg_u32(volatile int * m, unsigned int val)
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
" sync \n" " sync \n"
#endif #endif
" .set mips0 \n"
: "=&r" (retval), "=m" (*m), "=&r" (dummy) : "=&r" (retval), "=m" (*m), "=&r" (dummy)
: "R" (*m), "Jr" (val) : "R" (*m), "Jr" (val)
: "memory"); : "memory");
@ -222,6 +226,7 @@ static inline __u64 __xchg_u64(volatile __u64 * m, __u64 val)
unsigned long dummy; unsigned long dummy;
__asm__ __volatile__( __asm__ __volatile__(
" .set mips3 \n"
"1: lld %0, %3 # xchg_u64 \n" "1: lld %0, %3 # xchg_u64 \n"
" move %2, %z4 \n" " move %2, %z4 \n"
" scd %2, %1 \n" " scd %2, %1 \n"
@ -230,6 +235,7 @@ static inline __u64 __xchg_u64(volatile __u64 * m, __u64 val)
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
" sync \n" " sync \n"
#endif #endif
" .set mips0 \n"
: "=&r" (retval), "=m" (*m), "=&r" (dummy) : "=&r" (retval), "=m" (*m), "=&r" (dummy)
: "R" (*m), "Jr" (val) : "R" (*m), "Jr" (val)
: "memory"); : "memory");
@ -237,6 +243,7 @@ static inline __u64 __xchg_u64(volatile __u64 * m, __u64 val)
unsigned long dummy; unsigned long dummy;
__asm__ __volatile__( __asm__ __volatile__(
" .set mips3 \n"
"1: lld %0, %3 # xchg_u64 \n" "1: lld %0, %3 # xchg_u64 \n"
" move %2, %z4 \n" " move %2, %z4 \n"
" scd %2, %1 \n" " scd %2, %1 \n"
@ -244,6 +251,7 @@ static inline __u64 __xchg_u64(volatile __u64 * m, __u64 val)
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
" sync \n" " sync \n"
#endif #endif
" .set mips0 \n"
: "=&r" (retval), "=m" (*m), "=&r" (dummy) : "=&r" (retval), "=m" (*m), "=&r" (dummy)
: "R" (*m), "Jr" (val) : "R" (*m), "Jr" (val)
: "memory"); : "memory");
@ -291,7 +299,9 @@ static inline unsigned long __cmpxchg_u32(volatile int * m, unsigned long old,
if (cpu_has_llsc && R10000_LLSC_WAR) { if (cpu_has_llsc && R10000_LLSC_WAR) {
__asm__ __volatile__( __asm__ __volatile__(
" .set push \n"
" .set noat \n" " .set noat \n"
" .set mips2 \n"
"1: ll %0, %2 # __cmpxchg_u32 \n" "1: ll %0, %2 # __cmpxchg_u32 \n"
" bne %0, %z3, 2f \n" " bne %0, %z3, 2f \n"
" move $1, %z4 \n" " move $1, %z4 \n"
@ -302,13 +312,15 @@ static inline unsigned long __cmpxchg_u32(volatile int * m, unsigned long old,
" sync \n" " sync \n"
#endif #endif
"2: \n" "2: \n"
" .set at \n" " .set pop \n"
: "=&r" (retval), "=m" (*m) : "=&r" (retval), "=m" (*m)
: "R" (*m), "Jr" (old), "Jr" (new) : "R" (*m), "Jr" (old), "Jr" (new)
: "memory"); : "memory");
} else if (cpu_has_llsc) { } else if (cpu_has_llsc) {
__asm__ __volatile__( __asm__ __volatile__(
" .set push \n"
" .set noat \n" " .set noat \n"
" .set mips2 \n"
"1: ll %0, %2 # __cmpxchg_u32 \n" "1: ll %0, %2 # __cmpxchg_u32 \n"
" bne %0, %z3, 2f \n" " bne %0, %z3, 2f \n"
" move $1, %z4 \n" " move $1, %z4 \n"
@ -318,7 +330,7 @@ static inline unsigned long __cmpxchg_u32(volatile int * m, unsigned long old,
" sync \n" " sync \n"
#endif #endif
"2: \n" "2: \n"
" .set at \n" " .set pop \n"
: "=&r" (retval), "=m" (*m) : "=&r" (retval), "=m" (*m)
: "R" (*m), "Jr" (old), "Jr" (new) : "R" (*m), "Jr" (old), "Jr" (new)
: "memory"); : "memory");
@ -343,7 +355,9 @@ static inline unsigned long __cmpxchg_u64(volatile int * m, unsigned long old,
if (cpu_has_llsc) { if (cpu_has_llsc) {
__asm__ __volatile__( __asm__ __volatile__(
" .set push \n"
" .set noat \n" " .set noat \n"
" .set mips3 \n"
"1: lld %0, %2 # __cmpxchg_u64 \n" "1: lld %0, %2 # __cmpxchg_u64 \n"
" bne %0, %z3, 2f \n" " bne %0, %z3, 2f \n"
" move $1, %z4 \n" " move $1, %z4 \n"
@ -354,13 +368,15 @@ static inline unsigned long __cmpxchg_u64(volatile int * m, unsigned long old,
" sync \n" " sync \n"
#endif #endif
"2: \n" "2: \n"
" .set at \n" " .set pop \n"
: "=&r" (retval), "=m" (*m) : "=&r" (retval), "=m" (*m)
: "R" (*m), "Jr" (old), "Jr" (new) : "R" (*m), "Jr" (old), "Jr" (new)
: "memory"); : "memory");
} else if (cpu_has_llsc) { } else if (cpu_has_llsc) {
__asm__ __volatile__( __asm__ __volatile__(
" .set push \n"
" .set noat \n" " .set noat \n"
" .set mips2 \n"
"1: lld %0, %2 # __cmpxchg_u64 \n" "1: lld %0, %2 # __cmpxchg_u64 \n"
" bne %0, %z3, 2f \n" " bne %0, %z3, 2f \n"
" move $1, %z4 \n" " move $1, %z4 \n"
@ -370,7 +386,7 @@ static inline unsigned long __cmpxchg_u64(volatile int * m, unsigned long old,
" sync \n" " sync \n"
#endif #endif
"2: \n" "2: \n"
" .set at \n" " .set pop \n"
: "=&r" (retval), "=m" (*m) : "=&r" (retval), "=m" (*m)
: "R" (*m), "Jr" (old), "Jr" (new) : "R" (*m), "Jr" (old), "Jr" (new)
: "memory"); : "memory");