From: Julian Seward Date: Tue, 18 Mar 2014 23:02:59 +0000 (+0000) Subject: Make Helgrind test cases build on arm64-linux. X-Git-Tag: svn/VALGRIND_3_10_0~558 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fd0e5403b4b894cb762dc2fd3f86a44ba553a514;p=thirdparty%2Fvalgrind.git Make Helgrind test cases build on arm64-linux. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13878 --- diff --git a/helgrind/tests/annotate_hbefore.c b/helgrind/tests/annotate_hbefore.c index 61974bb5b2..3368c5646c 100644 --- a/helgrind/tests/annotate_hbefore.c +++ b/helgrind/tests/annotate_hbefore.c @@ -167,6 +167,39 @@ UWord do_acasW ( UWord* addr, UWord expected, UWord nyu ) return success; } +#elif defined(VGA_arm64) + +// arm64 +/* return 1 if success, 0 if failure */ +UWord do_acasW ( UWord* addr, UWord expected, UWord nyu ) +{ + UWord old, success; + UWord block[2] = { (UWord)addr, nyu }; + + /* Fetch the old value, and set the reservation */ + __asm__ __volatile__ ( + "ldxr %0, [%1]" "\n" + : /*out*/ "=r"(old) + : /*in*/ "r"(addr) + ); + + /* If the old value isn't as expected, we've had it */ + if (old != expected) return 0; + + /* otherwise try to stuff the new value in */ + __asm__ __volatile__( + "ldr x4, [%1, #0]" "\n\t" + "ldr x5, [%1, #8]" "\n\t" + "stxr w6, x5, [x4, #0]" "\n\t" + "eor %0, x6, #1" "\n\t" + : /*out*/ "=r"(success) + : /*in*/ "r"(&block[0]) + : /*trash*/ "x4","x5","x6","memory" + ); + assert(success == 0 || success == 1); + return success; +} + #elif defined(VGA_s390x) // s390x diff --git a/helgrind/tests/tc07_hbl1.c b/helgrind/tests/tc07_hbl1.c index 92c74e018f..be62337db5 100644 --- a/helgrind/tests/tc07_hbl1.c +++ b/helgrind/tests/tc07_hbl1.c @@ -13,6 +13,7 @@ #undef PLAT_ppc32_linux #undef PLAT_ppc64_linux #undef PLAT_arm_linux +#undef PLAT_arm64_linux #undef PLAT_s390x_linux #undef PLAT_mips32_linux @@ -28,8 +29,10 @@ # define PLAT_ppc32_linux 1 #elif defined(__linux__) && defined(__powerpc__) && defined(__powerpc64__) # define PLAT_ppc64_linux 1 -#elif defined(__linux__) && defined(__arm__) +#elif defined(__linux__) && defined(__arm__) && !defined(__aarch64__) # define PLAT_arm_linux 1 +#elif defined(__linux__) && defined(__aarch64__) && !defined(__arm__) +# define PLAT_arm64_linux 1 #elif defined(__linux__) && defined(__s390x__) # define PLAT_s390x_linux 1 #elif defined(__linux__) && defined(__mips__) @@ -64,6 +67,18 @@ : /*out*/ : /*in*/ "r"(&(_lval)) \ : /*trash*/ "r8", "r9", "cc", "memory" \ ); +#elif defined(PLAT_arm64_linux) +# define INC(_lval,_lqual) \ + __asm__ __volatile__( \ + "1:\n" \ + " ldxr w8, [%0, #0]\n" \ + " add w8, w8, #1\n" \ + " stxr w9, w8, [%0, #0]\n" \ + " cmp w9, #0\n" \ + " bne 1b\n" \ + : /*out*/ : /*in*/ "r"(&(_lval)) \ + : /*trash*/ "x8", "x9", "cc", "memory" \ + ); #elif defined(PLAT_s390x_linux) # define INC(_lval,_lqual) \ __asm__ __volatile__( \ diff --git a/helgrind/tests/tc08_hbl2.c b/helgrind/tests/tc08_hbl2.c index 54a1f683d7..2b720a8f6f 100644 --- a/helgrind/tests/tc08_hbl2.c +++ b/helgrind/tests/tc08_hbl2.c @@ -29,6 +29,7 @@ #undef PLAT_ppc32_linux #undef PLAT_ppc64_linux #undef PLAT_arm_linux +#undef PLAT_arm64_linux #undef PLAT_s390x_linux #undef PLAT_mips32_linux #undef PLAT_mips64_linux @@ -45,8 +46,10 @@ # define PLAT_ppc32_linux 1 #elif defined(__linux__) && defined(__powerpc__) && defined(__powerpc64__) # define PLAT_ppc64_linux 1 -#elif defined(__linux__) && defined(__arm__) +#elif defined(__linux__) && defined(__arm__) && !defined(__aarch64__) # define PLAT_arm_linux 1 +#elif defined(__linux__) && defined(__aarch64__) && !defined(__arm__) +# define PLAT_arm64_linux 1 #elif defined(__linux__) && defined(__s390x__) # define PLAT_s390x_linux 1 #elif defined(__linux__) && defined(__mips__) @@ -86,6 +89,18 @@ : /*out*/ : /*in*/ "r"(&(_lval)) \ : /*trash*/ "r8", "r9", "cc", "memory" \ ); +#elif defined(PLAT_arm64_linux) +# define INC(_lval,_lqual) \ + __asm__ __volatile__( \ + "1:\n" \ + " ldxr w8, [%0, #0]\n" \ + " add w8, w8, #1\n" \ + " stxr w9, w8, [%0, #0]\n" \ + " cmp w9, #0\n" \ + " bne 1b\n" \ + : /*out*/ : /*in*/ "r"(&(_lval)) \ + : /*trash*/ "x8", "x9", "cc", "memory" \ + ); #elif defined(PLAT_s390x_linux) # define INC(_lval,_lqual) \ __asm__ __volatile__( \ diff --git a/helgrind/tests/tc11_XCHG.c b/helgrind/tests/tc11_XCHG.c index fadc774fba..23edf9e085 100644 --- a/helgrind/tests/tc11_XCHG.c +++ b/helgrind/tests/tc11_XCHG.c @@ -31,8 +31,10 @@ # define PLAT_ppc32_linux 1 #elif defined(__linux__) && defined(__powerpc__) && defined(__powerpc64__) # define PLAT_ppc64_linux 1 -#elif defined(__linux__) && defined(__arm__) +#elif defined(__linux__) && defined(__arm__) && !defined(__aarch64__) # define PLAT_arm_linux 1 +#elif defined(__linux__) && defined(__aarch64__) && !defined(__arm__) +# define PLAT_arm64_linux 1 #elif defined(__linux__) && defined(__s390x__) # define PLAT_s390x_linux 1 #elif defined(__linux__) && defined(__mips__) @@ -91,7 +93,7 @@ XCHG_M_R(_addr,_lval) #elif defined(PLAT_ppc32_linux) || defined(PLAT_ppc64_linux) \ - || defined(PLAT_arm_linux) + || defined(PLAT_arm_linux) || defined(PLAT_arm64_linux) # if defined(HAVE_BUILTIN_ATOMIC) # define XCHG_M_R(_addr,_lval) \ do { \