ck_pr: Prettify the arm bits.

gcc is smart enough to use an even register for 64bits operations, and provide
a way to access the first and the second words, so use that instead of
hardcoding registers.
ck_pring
Olivier Houchard 10 years ago
parent 0422a23f62
commit 0f7827f479

@ -170,33 +170,32 @@ CK_PR_STORE_S(char, char, "strb")
CK_CC_INLINE static void CK_CC_INLINE static void
ck_pr_store_64(const uint64_t *target, uint64_t value) ck_pr_store_64(const uint64_t *target, uint64_t value)
{ {
register uint64_t tmp asm("r0") = value;
__asm __volatile("strd %0, [%1]" __asm __volatile("strd %0, [%1]"
: :
: "r" (tmp), "r" (target) : "r" (value), "r" (target)
: "memory", "cc"); : "memory", "cc");
} }
CK_CC_INLINE static bool CK_CC_INLINE static bool
ck_pr_cas_64_value(uint64_t *target, uint64_t compare, uint64_t set, uint64_t *value) ck_pr_cas_64_value(uint64_t *target, uint64_t compare, uint64_t set, uint64_t *value)
{ {
register uint64_t __compare asm("r0") = compare; uint64_t previous;
register uint64_t __set asm("r2") = set; int tmp;
__asm__ __volatile__("1:" __asm__ __volatile__("1:"
"ldrexd r4, [%3];" "ldrexd %0, [%4];"
"cmp r4, r0;" "cmp %Q0, %Q2;"
"ittt eq;" "ittt eq;"
"cmpeq r5, r1;" "cmpeq %R0, %R2;"
"strexdeq r6, r2, [%3];" "strexdeq %1, %3, [%4];"
"cmpeq r6, #1;" "cmpeq %1, #1;"
"beq 1b;" "beq 1b;"
"strd r4, [%0];" :"=&r" (previous), "=&r" (tmp)
: "+r" (value) : "r" (compare), "r" (set) ,
: "r" (__compare), "r" (__set) ,
"r"(target) "r"(target)
: "memory", "cc", "r4", "r5", "r6"); : "memory", "cc", "r4", "r5", "r6");
*value = previous;
return (*value == compare); return (*value == compare);
} }
@ -215,22 +214,21 @@ ck_pr_cas_ptr_2_value(void *target, void *compare, void *set, void *value)
CK_CC_INLINE static bool CK_CC_INLINE static bool
ck_pr_cas_64(uint64_t *target, uint64_t compare, uint64_t set) ck_pr_cas_64(uint64_t *target, uint64_t compare, uint64_t set)
{ {
register uint64_t __compare asm("r0") = compare;
register uint64_t __set asm("r2") = set;
int ret; int ret;
uint64_t tmp;
__asm__ __volatile__("1:" __asm__ __volatile__("1:"
"mov %0, #0;" "mov %0, #0;"
"ldrexd r4, [%3];" "ldrexd %1, [%4];"
"cmp r4, r0;" "cmp %Q1, %Q2;"
"itttt eq;" "itttt eq;"
"cmpeq r5, r1;" "cmpeq %R1, %R2;"
"strexdeq r6, r2, [%3];" "strexdeq %1, %3, [%4];"
"moveq %0, #1;" "moveq %0, #1;"
"cmpeq r6, #1;" "cmpeq %1, #1;"
"beq 1b;" "beq 1b;"
: "=&r" (ret) : "=&r" (ret), "=&r" (tmp)
: "r" (__compare), "r" (__set) , : "r" (compare), "r" (set) ,
"r"(target) "r"(target)
: "memory", "cc", "r4", "r5", "r6"); : "memory", "cc", "r4", "r5", "r6");

Loading…
Cancel
Save