Commit cf3b3baa authored by Max Filippov's avatar Max Filippov

xtensa: use "m" constraint instead of "a" in cmpxchg.h assembly

Use "m" constraint instead of "r" for the address, as "m" allows
compiler to access adjacent locations using base + offset, while "r"
requires updating the base register every time.
Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
parent 812e708a
...@@ -43,9 +43,9 @@ __cmpxchg_u32(volatile int *p, int old, int new) ...@@ -43,9 +43,9 @@ __cmpxchg_u32(volatile int *p, int old, int new)
#elif XCHAL_HAVE_S32C1I #elif XCHAL_HAVE_S32C1I
__asm__ __volatile__( __asm__ __volatile__(
" wsr %[cmp], scompare1\n" " wsr %[cmp], scompare1\n"
" s32c1i %[new], %[addr], 0\n" " s32c1i %[new], %[mem]\n"
: [new] "+a" (new) : [new] "+a" (new), [mem] "+m" (*p)
: [addr] "a" (p), [cmp] "a" (old) : [cmp] "a" (old)
: "memory" : "memory"
); );
...@@ -53,14 +53,14 @@ __cmpxchg_u32(volatile int *p, int old, int new) ...@@ -53,14 +53,14 @@ __cmpxchg_u32(volatile int *p, int old, int new)
#else #else
__asm__ __volatile__( __asm__ __volatile__(
" rsil a15, "__stringify(TOPLEVEL)"\n" " rsil a15, "__stringify(TOPLEVEL)"\n"
" l32i %[old], %[addr], 0\n" " l32i %[old], %[mem]\n"
" bne %[old], %[cmp], 1f\n" " bne %[old], %[cmp], 1f\n"
" s32i %[new], %[addr], 0\n" " s32i %[new], %[mem]\n"
"1:\n" "1:\n"
" wsr a15, ps\n" " wsr a15, ps\n"
" rsync\n" " rsync\n"
: [old] "=&a" (old) : [old] "=&a" (old), [mem] "+m" (*p)
: [addr] "a" (p), [cmp] "a" (old), [new] "r" (new) : [cmp] "a" (old), [new] "r" (new)
: "a15", "memory"); : "a15", "memory");
return old; return old;
#endif #endif
...@@ -143,13 +143,14 @@ static inline unsigned long xchg_u32(volatile int * m, unsigned long val) ...@@ -143,13 +143,14 @@ static inline unsigned long xchg_u32(volatile int * m, unsigned long val)
#elif XCHAL_HAVE_S32C1I #elif XCHAL_HAVE_S32C1I
unsigned long tmp, result; unsigned long tmp, result;
__asm__ __volatile__( __asm__ __volatile__(
"1: l32i %[tmp], %[addr], 0\n" "1: l32i %[tmp], %[mem]\n"
" mov %[result], %[val]\n" " mov %[result], %[val]\n"
" wsr %[tmp], scompare1\n" " wsr %[tmp], scompare1\n"
" s32c1i %[result], %[addr], 0\n" " s32c1i %[result], %[mem]\n"
" bne %[result], %[tmp], 1b\n" " bne %[result], %[tmp], 1b\n"
: [result] "=&a" (result), [tmp] "=&a" (tmp) : [result] "=&a" (result), [tmp] "=&a" (tmp),
: [addr] "a" (m), [val] "a" (val) [mem] "+m" (*m)
: [val] "a" (val)
: "memory" : "memory"
); );
return result; return result;
...@@ -157,12 +158,12 @@ static inline unsigned long xchg_u32(volatile int * m, unsigned long val) ...@@ -157,12 +158,12 @@ static inline unsigned long xchg_u32(volatile int * m, unsigned long val)
unsigned long tmp; unsigned long tmp;
__asm__ __volatile__( __asm__ __volatile__(
" rsil a15, "__stringify(TOPLEVEL)"\n" " rsil a15, "__stringify(TOPLEVEL)"\n"
" l32i %[tmp], %[addr], 0\n" " l32i %[tmp], %[mem]\n"
" s32i %[val], %[addr], 0\n" " s32i %[val], %[mem]\n"
" wsr a15, ps\n" " wsr a15, ps\n"
" rsync\n" " rsync\n"
: [tmp] "=&a" (tmp) : [tmp] "=&a" (tmp), [mem] "+m" (*m)
: [addr] "a" (m), [val] "a" (val) : [val] "a" (val)
: "a15", "memory"); : "a15", "memory");
return tmp; return tmp;
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment