Commit 8128c6e7 authored by yangguo@chromium.org's avatar yangguo@chromium.org

Cleanup hardfp ABI detection. This work was triggered by issue 2140.

BUG=none
TEST=none

Review URL: https://chromiumcodereview.appspot.com/10713009

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11951 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 32e01d22
...@@ -161,48 +161,43 @@ bool OS::ArmCpuHasFeature(CpuFeature feature) { ...@@ -161,48 +161,43 @@ bool OS::ArmCpuHasFeature(CpuFeature feature) {
} }
// Simple helper function to detect whether the C code is compiled with bool OS::ArmUsingHardFloat() {
// option -mfloat-abi=hard. The register d0 is loaded with 1.0 and the register // GCC versions 4.6 and above define __ARM_PCS or __ARM_PCS_VFP to specify
// pair r0, r1 is loaded with 0.0. If -mfloat-abi=hard is pased to GCC then // the Floating Point ABI used (PCS stands for Procedure Call Standard).
// calling this will return 1.0 and otherwise 0.0. // We use these as well as a couple of other defines to statically determine
static void ArmUsingHardFloatHelper() { // what FP ABI used.
asm("mov r0, #0":::"r0"); // GCC versions 4.4 and below don't support hard-fp.
#if defined(__VFP_FP__) && !defined(__SOFTFP__) // GCC versions 4.5 may support hard-fp without defining __ARM_PCS or
// Load 0x3ff00000 into r1 using instructions available in both ARM // __ARM_PCS_VFP.
// and Thumb mode.
asm("mov r1, #3":::"r1"); #define GCC_VERSION (__GNUC__ * 10000 \
asm("mov r2, #255":::"r2"); + __GNUC_MINOR__ * 100 \
asm("lsl r1, r1, #8":::"r1"); + __GNUC_PATCHLEVEL__)
asm("orr r1, r1, r2":::"r1"); #if GCC_VERSION >= 40600
asm("lsl r1, r1, #20":::"r1"); #if defined(__ARM_PCS_VFP)
// For vmov d0, r0, r1 use ARM mode. return true;
#ifdef __thumb__
asm volatile(
"@ Enter ARM Mode \n\t"
" adr r3, 1f \n\t"
" bx r3 \n\t"
" .ALIGN 4 \n\t"
" .ARM \n"
"1: vmov d0, r0, r1 \n\t"
"@ Enter THUMB Mode\n\t"
" adr r3, 2f+1 \n\t"
" bx r3 \n\t"
" .THUMB \n"
"2: \n\t":::"r3");
#else #else
asm("vmov d0, r0, r1"); return false;
#endif // __thumb__ #endif
#endif // defined(__VFP_FP__) && !defined(__SOFTFP__)
asm("mov r1, #0":::"r1");
}
#elif GCC_VERSION < 40500
return false;
bool OS::ArmUsingHardFloat() { #else
// Cast helper function from returning void to returning double. #if defined(__ARM_PCS_VFP)
typedef double (*F)(); return true;
F f = FUNCTION_CAST<F>(FUNCTION_ADDR(ArmUsingHardFloatHelper)); #elif defined(__ARM_PCS) || defined(__SOFTFP) || !defined(__VFP_FP__)
return f() == 1.0; return false;
#else
#error "Your version of GCC does not report the FP ABI compiled for." \
"Please report it on this issue" \
"http://code.google.com/p/v8/issues/detail?id=2140"
#endif
#endif
#undef GCC_VERSION
} }
#endif // def __arm__ #endif // def __arm__
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment