]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
mips: atomic_add_8bit and atomic_add_16bit for MIPS64-BE
authorPetar Jovanovic <mips32r2@gmail.com>
Tue, 14 May 2013 13:33:27 +0000 (13:33 +0000)
committerPetar Jovanovic <mips32r2@gmail.com>
Tue, 14 May 2013 13:33:27 +0000 (13:33 +0000)
It fixes memcheck/tests/atomic_incs on MIPS64-BE.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13399

memcheck/tests/atomic_incs.c

index ae1368cbc1e57ea4f906e0392dc9c2e2ed253a1b..c3d1a58f3965aff37e032d10febd65585916cb89 100644 (file)
@@ -180,6 +180,23 @@ __attribute__((noinline)) void atomic_add_8bit ( char* p, int n )
          : /*trash*/ "memory", "t0", "t1", "t2", "t3", "s0"
       );
    } while (block[2] != 1);
+#elif defined (_MIPSEB)
+   unsigned long block[3]
+      = { (unsigned long)p, (unsigned long)n << 56, 0x0 };
+   do {
+      __asm__ __volatile__(
+         "move  $t0, %0"          "\n\t"
+         "ld    $t1, 0($t0)"      "\n\t"  // p
+         "ld    $t2, 8($t0)"      "\n\t"  // n
+         "lld   $t3, 0($t1)"      "\n\t"
+         "daddu $t3, $t3, $t2"    "\n\t"
+         "scd   $t3, 0($t1)"      "\n\t"
+         "sd    $t3, 16($t0)"     "\n\t"
+         : /*out*/
+         : /*in*/ "r"(&block[0])
+         : /*trash*/ "memory", "t0", "t1", "t2", "t3"
+      );
+   } while (block[2] != 1);
 #endif
 #else
 # error "Unsupported arch"
@@ -344,6 +361,23 @@ __attribute__((noinline)) void atomic_add_16bit ( short* p, int n )
          : /*trash*/ "memory", "t0", "t1", "t2", "t3", "s0"
       );
    } while (block[2] != 1);
+#elif defined (_MIPSEB)
+   unsigned long block[3]
+      = { (unsigned long)p, (unsigned long)n << 48, 0x0 };
+   do {
+      __asm__ __volatile__(
+         "move  $t0, %0"          "\n\t"
+         "ld    $t1, 0($t0)"      "\n\t"  // p
+         "ld    $t2, 8($t0)"      "\n\t"  // n
+         "lld   $t3, 0($t1)"      "\n\t"
+         "daddu $t3, $t3, $t2"    "\n\t"
+         "scd   $t3, 0($t1)"      "\n\t"
+         "sd    $t3, 16($t0)"     "\n\t"
+         : /*out*/
+         : /*in*/ "r"(&block[0])
+         : /*trash*/ "memory", "t0", "t1", "t2", "t3"
+      );
+   } while (block[2] != 1);
 #endif
 #else
 # error "Unsupported arch"