]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
mips: allow Valgrind to be compiled for soft-float
authorPetar Jovanovic <mips32r2@gmail.com>
Wed, 12 Oct 2016 15:13:27 +0000 (15:13 +0000)
committerPetar Jovanovic <mips32r2@gmail.com>
Wed, 12 Oct 2016 15:13:27 +0000 (15:13 +0000)
Force "hardfloat" mode for inline assembly that uses FPU instructions,
but pop original mode at the end of the assembly. Unhandled FPU
instructions will be handled by the signal handler (env_unsup_insn).

Skip MIPS specific tests for FPU if the code gets compiled for soft-
float.

This should allow Valgrind to be compiled as a soft-float binary, but
that executable should be used for soft-float systems only.

Related VEX change - r3261.
Related issue - BZ#351282.

Patch by Aleksandar Rikalo.

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

19 files changed:
coregrind/m_machine.c
none/tests/mips32/FPUarithmetic.c
none/tests/mips32/FPUarithmetic.vgtest
none/tests/mips32/MoveIns.c
none/tests/mips32/MoveIns.vgtest
none/tests/mips32/change_fp_mode.c
none/tests/mips32/change_fp_mode.vgtest
none/tests/mips32/fpu_branches.c
none/tests/mips32/fpu_branches.vgtest
none/tests/mips32/round.c
none/tests/mips32/round.vgtest
none/tests/mips32/round_fpu64.c
none/tests/mips32/round_fpu64.vgtest
none/tests/mips32/test_fcsr.c
none/tests/mips32/test_fcsr.vgtest
none/tests/mips32/vfp.c
none/tests/mips32/vfp.vgtest
none/tests/mips64/change_fp_mode.c
none/tests/mips64/change_fp_mode.vgtest

index 8215c8024dcbb2b547c6af5d017144e80e59dea0..4fdfe93e08dd9091c404bdc7074f3cb60a090a10 100644 (file)
@@ -1738,10 +1738,6 @@ Bool VG_(machine_get_hwcaps)( void )
         }
      }
 
-     VG_(convert_sigaction_fromK_to_toK)(&saved_sigill_act, &tmp_sigill_act);
-     VG_(sigaction)(VKI_SIGILL, &tmp_sigill_act, NULL);
-     VG_(sigprocmask)(VKI_SIG_SETMASK, &saved_set, NULL);
-
 #    if defined(VGP_mips32_linux)
      Int fpmode = VG_(prctl)(VKI_PR_GET_FP_MODE);
 #    else
@@ -1752,25 +1748,33 @@ Bool VG_(machine_get_hwcaps)( void )
         /* prctl(PR_GET_FP_MODE) is not supported by Kernel,
            we are using alternative way to determine FP mode */
         ULong result = 0;
-        __asm__ volatile (
-           ".set push\n\t"
-           ".set noreorder\n\t"
-           ".set oddspreg\n\t"
-           "lui $t0, 0x3FF0\n\t"
-           "ldc1 $f0, %0\n\t"
-           "mtc1 $t0, $f1\n\t"
-           "sdc1 $f0, %0\n\t"
-           ".set pop\n\t"
-           : "+m"(result)
-           :
-           : "t0", "$f0", "$f1", "memory");
-
-        fpmode = (result != 0x3FF0000000000000ull);
+
+        if (!VG_MINIMAL_SETJMP(env_unsup_insn)) {
+           __asm__ volatile (
+              ".set push\n\t"
+              ".set noreorder\n\t"
+              ".set oddspreg\n\t"
+              ".set hardfloat\n\t"
+              "lui $t0, 0x3FF0\n\t"
+              "ldc1 $f0, %0\n\t"
+              "mtc1 $t0, $f1\n\t"
+              "sdc1 $f0, %0\n\t"
+              ".set pop\n\t"
+              : "+m"(result)
+              :
+              : "t0", "$f0", "$f1", "memory");
+
+           fpmode = (result != 0x3FF0000000000000ull);
+        }
      }
 
      if (fpmode != 0)
         vai.hwcaps |= VEX_MIPS_HOST_FR;
 
+     VG_(convert_sigaction_fromK_to_toK)(&saved_sigill_act, &tmp_sigill_act);
+     VG_(sigaction)(VKI_SIGILL, &tmp_sigill_act, NULL);
+     VG_(sigprocmask)(VKI_SIG_SETMASK, &saved_set, NULL);
+
      VG_(debugLog)(1, "machine", "hwcaps = 0x%x\n", vai.hwcaps);
      VG_(machine_get_cache_info)(&vai);
 
index 72806fa5f2f1c2683cc593952a9098a167af7d20..7b12c755bff7e35735c341342267b73714693728 100644 (file)
@@ -1,3 +1,5 @@
+#if defined(__mips_hard_float)
+
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -235,4 +237,8 @@ int main()
 
    return 0;
 }
-
+#else
+int main() {
+   return 0;
+}
+#endif
index c33c448108a88b8a375998e6e9ebc24dff5ab06c..1d2cace1ce76a668ede7ca2ebe06b33d554d4b1c 100644 (file)
@@ -1,2 +1,3 @@
 prog: FPUarithmetic
+prereq: ../../../tests/mips_features fpu
 vgopts: -q
index 30c28e57058d78cc63cbd6e5f8da798603d4fe78..ce2cb1332fe9b1d3f5a97fb75db893d7ec3dd72c 100644 (file)
@@ -1,3 +1,5 @@
+#if defined(__mips_hard_float)
+
 #include <stdint.h>
 #include <stdio.h>
 
@@ -661,3 +663,8 @@ int main()
 
    return 0;
 }
+#else
+int main() {
+   return 0;
+}
+#endif
index 662bf4f774d820568cc4ef3afd1737fca321b337..572529088bc029234602d6ef8ab89188033d4e47 100644 (file)
@@ -1,2 +1,3 @@
 prog: MoveIns
+prereq: ../../../tests/mips_features fpu
 vgopts: -q
index 73350b150b5824bee8a1d37dc791d2bfcd7a377a..87b10e995828acb2abeaece7f8433fdf36661a9c 100644 (file)
@@ -1,3 +1,5 @@
+#if defined(__mips_hard_float)
+
 #include <elf.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -76,3 +78,8 @@ int main() {
 
    return 0;
 }
+#else
+int main() {
+   return 0;
+}
+#endif
index 68fa456d9e4b6ca611fa813a485c52af83330368..df9ed62905959c6827601bfdec2d79094a672125 100644 (file)
@@ -1,2 +1,3 @@
 prog: change_fp_mode
+prereq: ../../../tests/mips_features fpu
 vgopts: -q
index f81321d37d9c58ae39d3d953c7b9a46aa60442b3..dbf9aa08923cb1afb6d909ffaa2a56e62df9f3e0 100644 (file)
@@ -1,3 +1,5 @@
+#if defined(__mips_hard_float)
+
 #include <stdio.h>
 
 #define MAX_ARR 24
@@ -314,4 +316,8 @@ int main()
    }
    return 0;
 }
-
+#else
+int main() {
+   return 0;
+}
+#endif
index 206651219753ab2d53325f2182340822854754a9..1854b59cf5caf330c3fffd12d1caaaca8e66cacd 100644 (file)
@@ -1,2 +1,3 @@
 prog: fpu_branches
+prereq: ../../../tests/mips_features fpu
 vgopts: -q
index 710c15adea495ff232e66fbcf281c8c37813c91d..feba1685561e98e99f58926c66d31e4088c2cc19 100644 (file)
@@ -1,3 +1,5 @@
+#if defined(__mips_hard_float)
+
 #include <stdio.h>
 
 typedef enum {
@@ -289,4 +291,9 @@ int main()
    }
    return 0;
 }
+#else
+int main() {
+   return 0;
+}
+#endif
 
index d5eb00e8f048f1a5f646198064dbd786d730e848..a0374b4bf87e1ab2714b1eb72c0dfffe51fa45a1 100644 (file)
@@ -1,2 +1,3 @@
 prog: round
+prereq: ../../../tests/mips_features fpu
 vgopts: -q
index 837e4b23a10793b0a7ad2e9a1ec95b4b6e821c1d..a4715f2a03124cb262adacc6ed7b025304286612 100644 (file)
@@ -1,3 +1,5 @@
+#if defined(__mips_hard_float)
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <signal.h>
@@ -202,3 +204,8 @@ int main()
 #endif
    return 0;
 }
+#else
+int main() {
+   return 0;
+}
+#endif
index 95d11b07379a54e94b8f61a8107e59cc1989f939..92f44af18f57abd735cb65e15dcebbabdf4f6fb9 100644 (file)
@@ -1,2 +1,3 @@
 prog: round_fpu64
+prereq: ../../../tests/mips_features fpu
 vgopts: -q
index 737c87ba378cf0506be6423205e64b8bb7720583..6bb03a0a42faa38d91951c48947a64ebdb8fa251 100644 (file)
@@ -1,3 +1,5 @@
+#if defined(__mips_hard_float)
+
 #include <stdio.h>
 
 int main ()
@@ -23,3 +25,8 @@ int main ()
    printf("FCSR::1: 0x%x, 2: 0x%x\n", out[0], out[1]);
    return 0;
 }
+#else
+int main() {
+   return 0;
+}
+#endif
index c864d253f01cb148f74f4accb24390790a205655..69dba5b377947c89dc7705260cb15598963c7862 100644 (file)
@@ -1,2 +1,3 @@
 prog: test_fcsr
+prereq: ../../../tests/mips_features fpu
 vgopts: -q
index 3e12e99ef43eb752d0ff6d29fa7fb046955fcc24..68acfb6dd29b97e4eb765eee61bc467a0751701f 100644 (file)
@@ -1,3 +1,5 @@
+#if defined(__mips_hard_float)
+
 #include <stdint.h>
 #include <stdio.h>
 
@@ -405,4 +407,8 @@ int main()
 
    return 0;
 }
-
+#else
+int main() {
+   return 0;
+}
+#endif
index fd3e759bd9c18e21af02a4c7d81be7ce0d336745..043eeb41c0b3ea8430c39f7ca4413b1a70efbb7d 100644 (file)
@@ -1,2 +1,3 @@
 prog: vfp
+prereq: ../../../tests/mips_features fpu
 vgopts: -q
index fb29365fb89b715c5c5e13e70bb7cb4724464d9c..a1f7c0471161b07d4a75b0cd13ecc0a0ad6c3520 100644 (file)
@@ -1,3 +1,5 @@
+#if defined(__mips_hard_float)
+
 #include <elf.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -257,3 +259,8 @@ int main() {
 
    return 0;
 }
+#else
+int main() {
+   return 0;
+}
+#endif
index 68fa456d9e4b6ca611fa813a485c52af83330368..df9ed62905959c6827601bfdec2d79094a672125 100644 (file)
@@ -1,2 +1,3 @@
 prog: change_fp_mode
+prereq: ../../../tests/mips_features fpu
 vgopts: -q