]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
mips: fix helgrind/tests/annotate_hbefore for nanoMIPS
authorAleksandar Rikalo <aleksandar.rikalo@rt-rk.com>
Fri, 17 Apr 2020 18:38:11 +0000 (18:38 +0000)
committerPetar Jovanovic <mips32r2@gmail.com>
Fri, 17 Apr 2020 18:38:11 +0000 (18:38 +0000)
Implement do_acasW() function for nanoMIPS.

helgrind/tests/annotate_hbefore.c

index e53423b425a16340630d7a3a2694d15bdf46630d..259d3b64c895800390375d16b10206014a8affb9 100644 (file)
@@ -252,6 +252,35 @@ UWord do_acasW ( UWord* addr, UWord expected, UWord nyu )
    return success;
 }
 
+#elif defined(VGA_nanomips)
+
+/* return 1 if success, 0 if failure */
+UWord do_acasW ( UWord* addr, UWord expected, UWord nyu )
+{
+  UWord success;
+  UWord block[3] = { (UWord)addr, nyu, expected};
+
+   __asm__ __volatile__(
+      "lw     $t0, 0(%1)"        "\n\t"
+      "lw     $t2, 8(%1)"        "\n\t"
+      "lw     $t3, 4(%1)"        "\n\t"
+      "ll     $t1, 0($t0)"       "\n\t"
+      "bnec   $t1, $t2, 1f"      "\n\t"
+      "sc     $t3, 0($t0)"       "\n\t"
+      "move   %0, $t3"           "\n\t"
+      "bc 2f"                    "\n\t"
+      "1:"                       "\n\t"
+      "move   %0, $zero"         "\n\t"
+      "2:"                       "\n\t"
+      : /*out*/ "=r"(success)
+      : /*in*/ "r"(&block[0])
+      : /*trash*/ "t0", "t1", "t2", "t3", "memory"
+   );
+
+   assert(success == 0 || success == 1);
+   return success;
+}
+
 #elif defined(VGA_mips64) && !defined(VGABI_N32)
 
 // mips64