]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
mips: update tests to compile for nanoMIPS
authorPetar Jovanovic <mips32r2@gmail.com>
Tue, 31 Dec 2019 15:56:23 +0000 (15:56 +0000)
committerPetar Jovanovic <mips32r2@gmail.com>
Tue, 31 Dec 2019 15:56:23 +0000 (15:56 +0000)
Update the tests so they can be compiled for nanoMIPS.

Patch by Dimitrije Nikolic and Aleksandra Karadzic.

helgrind/tests/tc07_hbl1.c
helgrind/tests/tc08_hbl2.c
helgrind/tests/tc11_XCHG.c
memcheck/tests/atomic_incs.c
memcheck/tests/leak.h
memcheck/tests/unit_libcbase.c
none/tests/libvex_test.c
perf/bigcode.c

index 1744dc130494089c89ad0f4bef152c7b5d508629..3972b512eef5070caba7fa7224054f9b38215f00 100644 (file)
@@ -39,6 +39,8 @@
 #  define PLAT_s390x_linux 1
 #elif defined(__linux__) && defined(__mips__)
 #  define PLAT_mips32_linux 1
+#elif defined(__linux__) && defined(__nanomips__)
+#  define PLAT_nanomips_linux 1
 #elif defined(__sun__) && defined(__i386__)
 #  define PLAT_x86_solaris 1
 #elif defined(__sun__) && defined(__x86_64__)
       : /*out*/ : /*in*/ "r"(&(_lval))              \
       : /*trash*/ "$8", "$9", "$10", "cc", "memory" \
    )
+#elif defined(PLAT_nanomips_linux)
+#  define INC(_lval,_lqual)                         \
+     __asm__ __volatile__ (                         \
+      "1:\n"                                        \
+      "        move $t0, %0\n"                      \
+      "        ll $t1, 0($t0)\n"                    \
+      "        addiu $t1, $t1, 1\n"                 \
+      "        sc $t1, 0($t0)\n"                    \
+      "        beqc $t1, $zero, 1b\n"               \
+      : /*out*/ : /*in*/ "r"(&(_lval))              \
+      : /*trash*/ "$t0", "$t1", "memory"            \
+   )
 #else
 #  error "Fix Me for this platform"
 #endif
index f660d82dd98fc9fb597164d8b5b20ee0fd8dd78c..e84ecec4a1f0e36bc33b7a334d05fa9e0afa0cd1 100644 (file)
@@ -60,6 +60,8 @@
 #else
 #  define PLAT_mips32_linux 1
 #endif
+#elif defined(__linux__) && defined(__nanomips__)
+#  define PLAT_nanomips_linux 1
 #elif defined(__sun__) && defined(__i386__)
 #  define PLAT_x86_solaris 1
 #elif defined(__sun__) && defined(__x86_64__)
       : /*out*/ : /*in*/ "r"(&(_lval))              \
       : /*trash*/ "t0", "t1", "memory"              \
         )
+#elif defined(PLAT_nanomips_linux)
+#  define INC(_lval,_lqual)                         \
+     __asm__ __volatile__ (                         \
+      "1:\n"                                        \
+      "        move $t0, %0\n"                      \
+      "        ll $t1, 0($t0)\n"                    \
+      "        addiu $t1, $t1, 1\n"                 \
+      "        sc $t1, 0($t0)\n"                    \
+      "        beqc $t1, $zero, 1b\n"               \
+      : /*out*/ : /*in*/ "r"(&(_lval))              \
+      : /*trash*/ "$t0", "$t1", "memory"            \
+   )
 #else
 #  error "Fix Me for this platform"
 #endif
index 48fc1b1a9e396ced1c9312548f404eb1e1b7c7b0..15167e87e8e44e4cdcf7c8d4e653c821c1874f78 100644 (file)
@@ -41,6 +41,8 @@
 #  define PLAT_s390x_linux 1
 #elif defined(__linux__) && defined(__mips__)
 #  define PLAT_mips32_linux 1
+#elif defined(__linux__) && defined(__nanomips__)
+#  define PLAT_nanomips_linux 1
 #elif defined(__sun__) && defined(__i386__)
 #  define PLAT_x86_solaris 1
 #elif defined(__sun__) && defined(__x86_64__)
         : "$12", "$13", "$14", "memory", "cc"                \
      )
 
+#  define XCHG_M_R_with_redundant_LOCK(_addr,_lval) \
+      XCHG_M_R(_addr,_lval)
+#elif defined(PLAT_nanomips_linux)
+#  define XCHG_M_R(_addr,_lval)                              \
+     __asm__ __volatile__(                                   \
+        "move $t0, %2\n"                                     \
+        "move $t1, %1\n"                                     \
+        "ll $t2, 0($t1)\n"                                   \
+        "sc $t0, 0($t1)\n"                                   \
+        "move %0, $t2\n"                                     \
+        : /*out*/ "=r"(_lval)                                \
+        : /*in*/  "r"(&_addr), "r"(_lval)                    \
+        : "$t0", "$t1", "$t1", "memory"                      \
+     )
+
 #  define XCHG_M_R_with_redundant_LOCK(_addr,_lval) \
       XCHG_M_R(_addr,_lval)
 
index b6816d78a77faeaaa31b7eead3baa98853608b0d..f931750f474221de692b9eb1017bff20f43ee359 100644 (file)
@@ -146,7 +146,7 @@ __attribute__((noinline)) void atomic_add_8bit ( char* p, int n )
       : "+m" (*p), "+m" (dummy)
       : "d" (n)
       : "cc", "memory", "0", "1");
-#elif defined(VGA_mips32)
+#elif defined(VGA_mips32) || defined (VGA_nanomips)
    /* We rely on the fact that p is 4-aligned. Otherwise 'll' may throw an
       exception that can cause this function to fail. */
 #if defined (_MIPSEL)
@@ -362,7 +362,7 @@ __attribute__((noinline)) void atomic_add_16bit ( short* p, int n )
       : "+m" (*p), "+m" (dummy)
       : "d" (n)
       : "cc", "memory", "0", "1");
-#elif defined(VGA_mips32)
+#elif defined(VGA_mips32) || defined (VGA_nanomips)
    /* We rely on the fact that p is 4-aligned. Otherwise 'll' may throw an
       exception that can cause this function to fail. */
 #if defined (_MIPSEL)
@@ -571,7 +571,7 @@ __attribute__((noinline)) void atomic_add_32bit ( int* p, int n )
       : "+m" (*p)
       : "d" (n)
       : "cc", "memory", "0", "1");
-#elif defined(VGA_mips32)
+#elif defined(VGA_mips32) || defined (VGA_nanomips)
    unsigned int block[3]
       = { (unsigned int)p, (unsigned int)n, 0x0 };
    do {
@@ -612,7 +612,8 @@ __attribute__((noinline)) void atomic_add_32bit ( int* p, int n )
 
 __attribute__((noinline)) void atomic_add_64bit ( long long int* p, int n ) 
 {
-#if defined(VGA_x86) || defined(VGA_ppc32) || defined(VGA_mips32)
+#if defined(VGA_x86) || defined(VGA_ppc32) || defined(VGA_mips32) \
+ || defined (VGA_nanomips)
    /* do nothing; is not supported */
 #elif defined(VGA_amd64)
    // this is a bit subtle.  It relies on the fact that, on a 64-bit platform,
index a1f93e8aaa3b8b9170f857d5f57f1ee2ea3d5951..9056cf09717a6eb5b73b662c7df5253f32ccecf8 100644 (file)
    __asm__ __volatile__( "li 11, 0" : : :/*trash*/"r11" ); \
    __asm__ __volatile__( "li 12, 0" : : :/*trash*/"r12" ); \
   } while (0)
+#elif defined(__nanomips__)
+#define CLEAR_CALLER_SAVED_REGS                                             \
+   do {                                                                     \
+      __asm__ __volatile__ (".set push       \n\t"                          \
+                            ".set noat       \n\t"                          \
+                            "move $at, $zero \n\t"                          \
+                            "move $t4, $zero \n\t"                          \
+                            "move $t5, $zero \n\t"                          \
+                            "move $a0, $zero \n\t"                          \
+                            "move $a1, $zero \n\t"                          \
+                            "move $a2, $zero \n\t"                          \
+                            "move $a3, $zero \n\t"                          \
+                            "move $a4, $zero \n\t"                          \
+                            "move $a5, $zero \n\t"                          \
+                            "move $a6, $zero \n\t"                          \
+                            "move $a7, $zero \n\t"                          \
+                            "move $t0, $zero \n\t"                          \
+                            "move $t1, $zero \n\t"                          \
+                            "move $t2, $zero \n\t"                          \
+                            "move $t3, $zero \n\t"                          \
+                            "move $t8, $zero \n\t"                          \
+                            "move $t9, $zero \n\t"                          \
+                            ".set pop        \n\t"                          \
+                            : : : "$at", "$t4", "$t5", "$a0", "$a1", "$a2", \
+                                  "$a3", "$a4", "$a5", "$a6", "$a7", "$t0", \
+                                  "$t1", "$t2", "$t3", "$t8", "$t9");       \
+   } while (0)
 #elif (__mips == 32)
 #define CLEAR_CALLER_SAVED_REGS                                              \
    do {                                                                      \
index 2944cea7253e7d92b4927811d08ffc5006e3bb1c..0ce65be264519042ba982df06f089dc65ade1874 100644 (file)
@@ -15,7 +15,8 @@
 unsigned long VKI_PAGE_SIZE  = 1UL << 12;
 #elif defined(VGP_arm64_linux)
 unsigned long VKI_PAGE_SIZE  = 1UL << 16;
-#elif defined(VGP_mips32_linux) || defined(VGP_mips64_linux)
+#elif defined(VGP_mips32_linux) || defined(VGP_mips64_linux) \
+    || defined (VGP_nanomips_linux)
 #include <unistd.h>
 unsigned long VKI_PAGE_SIZE;
 #endif
index bb1738a0b1567b0dc581e822b8475714560c481a..5b57a4c2e220ec1c4e545dcf31239457065a8a5a 100644 (file)
@@ -74,6 +74,8 @@ __attribute__((noinline)) static void get_guest_arch(VexArch    *ga)
    *ga = VexArchMIPS32;
 #elif defined(VGA_mips64)
    *ga = VexArchMIPS64;
+#elif defined(VGA_nanomips)
+   *ga = VexArchNANOMIPS;
 #else
    missing arch;
 #endif
@@ -94,6 +96,7 @@ static VexEndness arch_endness (VexArch va) {
    case VexArchS390X:  return VexEndnessBE;
    case VexArchMIPS32:
    case VexArchMIPS64:
+   case VexArchNANOMIPS:
       /* mips32/64 supports BE or LE, but at compile time.
          If mips64 is compiled on a non mips system, the VEX lib
          is missing bit and pieces of code related to endianness.
@@ -105,7 +108,7 @@ static VexEndness arch_endness (VexArch va) {
          VexArch ga;
          get_guest_arch( &ga);
 
-         if (ga == VexArchMIPS64 || ga == VexArchMIPS32)
+         if (ga == VexArchMIPS64 || ga == VexArchMIPS32 || ga == VexArchNANOMIPS)
             return running_endness();
          else
             return VexEndnessBE;
@@ -135,6 +138,7 @@ static UInt arch_hwcaps (VexArch va) {
    case VexArchMIPS32: return VEX_PRID_COMP_MIPS;
    case VexArchMIPS64: return VEX_PRID_COMP_MIPS | VEX_MIPS_HOST_FR;
 #endif
+   case VexArchNANOMIPS: return 0;
    default: failure_exit();
    }
 }
@@ -151,6 +155,7 @@ static Bool mode64 (VexArch va) {
    case VexArchS390X:  return True;
    case VexArchMIPS32: return False;
    case VexArchMIPS64: return True;
+   case VexArchNANOMIPS: return False;
    default: failure_exit();
    }
 }
@@ -270,7 +275,7 @@ int main(int argc, char **argv)
    // explicitly via command line arguments.
    if (multiarch) {
       VexArch va;
-      for (va = VexArchX86; va <= VexArchMIPS64; va++) {
+      for (va = VexArchX86; va <= VexArchNANOMIPS; va++) {
          vta.arch_host = va;
          vta.archinfo_host.endness = arch_endness (vta.arch_host);
          vta.archinfo_host.hwcaps = arch_hwcaps (vta.arch_host);
index 02e069d9f6587139b966981f8f6a272a3217dea3..e2adf0ec462d606dc0a1530e282935663c856a61 100644 (file)
@@ -85,6 +85,8 @@ int main(int argc, char* argv[])
 
 #if defined(__mips__)
    syscall(__NR_cacheflush, a, FN_SIZE * n_fns, ICACHE);
+#elif defined(__nanomips__)
+   __builtin___clear_cache(a, (char*)a + FN_SIZE * n_fns);
 #endif
 
    for (h = 0; h < n_reps; h += 1) {