From: Petar Jovanovic Date: Wed, 12 Oct 2016 15:13:27 +0000 (+0000) Subject: mips: allow Valgrind to be compiled for soft-float X-Git-Tag: svn/VALGRIND_3_13_0~342 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ed74dc8a27e2d5f65380bd94c3ddc488c55673c0;p=thirdparty%2Fvalgrind.git mips: allow Valgrind to be compiled for soft-float 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 --- diff --git a/coregrind/m_machine.c b/coregrind/m_machine.c index 8215c8024d..4fdfe93e08 100644 --- a/coregrind/m_machine.c +++ b/coregrind/m_machine.c @@ -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); diff --git a/none/tests/mips32/FPUarithmetic.c b/none/tests/mips32/FPUarithmetic.c index 72806fa5f2..7b12c755bf 100644 --- a/none/tests/mips32/FPUarithmetic.c +++ b/none/tests/mips32/FPUarithmetic.c @@ -1,3 +1,5 @@ +#if defined(__mips_hard_float) + #include #include @@ -235,4 +237,8 @@ int main() return 0; } - +#else +int main() { + return 0; +} +#endif diff --git a/none/tests/mips32/FPUarithmetic.vgtest b/none/tests/mips32/FPUarithmetic.vgtest index c33c448108..1d2cace1ce 100644 --- a/none/tests/mips32/FPUarithmetic.vgtest +++ b/none/tests/mips32/FPUarithmetic.vgtest @@ -1,2 +1,3 @@ prog: FPUarithmetic +prereq: ../../../tests/mips_features fpu vgopts: -q diff --git a/none/tests/mips32/MoveIns.c b/none/tests/mips32/MoveIns.c index 30c28e5705..ce2cb1332f 100644 --- a/none/tests/mips32/MoveIns.c +++ b/none/tests/mips32/MoveIns.c @@ -1,3 +1,5 @@ +#if defined(__mips_hard_float) + #include #include @@ -661,3 +663,8 @@ int main() return 0; } +#else +int main() { + return 0; +} +#endif diff --git a/none/tests/mips32/MoveIns.vgtest b/none/tests/mips32/MoveIns.vgtest index 662bf4f774..572529088b 100644 --- a/none/tests/mips32/MoveIns.vgtest +++ b/none/tests/mips32/MoveIns.vgtest @@ -1,2 +1,3 @@ prog: MoveIns +prereq: ../../../tests/mips_features fpu vgopts: -q diff --git a/none/tests/mips32/change_fp_mode.c b/none/tests/mips32/change_fp_mode.c index 73350b150b..87b10e9958 100644 --- a/none/tests/mips32/change_fp_mode.c +++ b/none/tests/mips32/change_fp_mode.c @@ -1,3 +1,5 @@ +#if defined(__mips_hard_float) + #include #include #include @@ -76,3 +78,8 @@ int main() { return 0; } +#else +int main() { + return 0; +} +#endif diff --git a/none/tests/mips32/change_fp_mode.vgtest b/none/tests/mips32/change_fp_mode.vgtest index 68fa456d9e..df9ed62905 100644 --- a/none/tests/mips32/change_fp_mode.vgtest +++ b/none/tests/mips32/change_fp_mode.vgtest @@ -1,2 +1,3 @@ prog: change_fp_mode +prereq: ../../../tests/mips_features fpu vgopts: -q diff --git a/none/tests/mips32/fpu_branches.c b/none/tests/mips32/fpu_branches.c index f81321d37d..dbf9aa0892 100644 --- a/none/tests/mips32/fpu_branches.c +++ b/none/tests/mips32/fpu_branches.c @@ -1,3 +1,5 @@ +#if defined(__mips_hard_float) + #include #define MAX_ARR 24 @@ -314,4 +316,8 @@ int main() } return 0; } - +#else +int main() { + return 0; +} +#endif diff --git a/none/tests/mips32/fpu_branches.vgtest b/none/tests/mips32/fpu_branches.vgtest index 2066512197..1854b59cf5 100644 --- a/none/tests/mips32/fpu_branches.vgtest +++ b/none/tests/mips32/fpu_branches.vgtest @@ -1,2 +1,3 @@ prog: fpu_branches +prereq: ../../../tests/mips_features fpu vgopts: -q diff --git a/none/tests/mips32/round.c b/none/tests/mips32/round.c index 710c15adea..feba168556 100644 --- a/none/tests/mips32/round.c +++ b/none/tests/mips32/round.c @@ -1,3 +1,5 @@ +#if defined(__mips_hard_float) + #include typedef enum { @@ -289,4 +291,9 @@ int main() } return 0; } +#else +int main() { + return 0; +} +#endif diff --git a/none/tests/mips32/round.vgtest b/none/tests/mips32/round.vgtest index d5eb00e8f0..a0374b4bf8 100644 --- a/none/tests/mips32/round.vgtest +++ b/none/tests/mips32/round.vgtest @@ -1,2 +1,3 @@ prog: round +prereq: ../../../tests/mips_features fpu vgopts: -q diff --git a/none/tests/mips32/round_fpu64.c b/none/tests/mips32/round_fpu64.c index 837e4b23a1..a4715f2a03 100644 --- a/none/tests/mips32/round_fpu64.c +++ b/none/tests/mips32/round_fpu64.c @@ -1,3 +1,5 @@ +#if defined(__mips_hard_float) + #include #include #include @@ -202,3 +204,8 @@ int main() #endif return 0; } +#else +int main() { + return 0; +} +#endif diff --git a/none/tests/mips32/round_fpu64.vgtest b/none/tests/mips32/round_fpu64.vgtest index 95d11b0737..92f44af18f 100644 --- a/none/tests/mips32/round_fpu64.vgtest +++ b/none/tests/mips32/round_fpu64.vgtest @@ -1,2 +1,3 @@ prog: round_fpu64 +prereq: ../../../tests/mips_features fpu vgopts: -q diff --git a/none/tests/mips32/test_fcsr.c b/none/tests/mips32/test_fcsr.c index 737c87ba37..6bb03a0a42 100644 --- a/none/tests/mips32/test_fcsr.c +++ b/none/tests/mips32/test_fcsr.c @@ -1,3 +1,5 @@ +#if defined(__mips_hard_float) + #include 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 diff --git a/none/tests/mips32/test_fcsr.vgtest b/none/tests/mips32/test_fcsr.vgtest index c864d253f0..69dba5b377 100644 --- a/none/tests/mips32/test_fcsr.vgtest +++ b/none/tests/mips32/test_fcsr.vgtest @@ -1,2 +1,3 @@ prog: test_fcsr +prereq: ../../../tests/mips_features fpu vgopts: -q diff --git a/none/tests/mips32/vfp.c b/none/tests/mips32/vfp.c index 3e12e99ef4..68acfb6dd2 100644 --- a/none/tests/mips32/vfp.c +++ b/none/tests/mips32/vfp.c @@ -1,3 +1,5 @@ +#if defined(__mips_hard_float) + #include #include @@ -405,4 +407,8 @@ int main() return 0; } - +#else +int main() { + return 0; +} +#endif diff --git a/none/tests/mips32/vfp.vgtest b/none/tests/mips32/vfp.vgtest index fd3e759bd9..043eeb41c0 100644 --- a/none/tests/mips32/vfp.vgtest +++ b/none/tests/mips32/vfp.vgtest @@ -1,2 +1,3 @@ prog: vfp +prereq: ../../../tests/mips_features fpu vgopts: -q diff --git a/none/tests/mips64/change_fp_mode.c b/none/tests/mips64/change_fp_mode.c index fb29365fb8..a1f7c04711 100644 --- a/none/tests/mips64/change_fp_mode.c +++ b/none/tests/mips64/change_fp_mode.c @@ -1,3 +1,5 @@ +#if defined(__mips_hard_float) + #include #include #include @@ -257,3 +259,8 @@ int main() { return 0; } +#else +int main() { + return 0; +} +#endif diff --git a/none/tests/mips64/change_fp_mode.vgtest b/none/tests/mips64/change_fp_mode.vgtest index 68fa456d9e..df9ed62905 100644 --- a/none/tests/mips64/change_fp_mode.vgtest +++ b/none/tests/mips64/change_fp_mode.vgtest @@ -1,2 +1,3 @@ prog: change_fp_mode +prereq: ../../../tests/mips_features fpu vgopts: -q