diff options
author | Keith Walker <kwalker@arm.com> | 2017-11-30 11:38:56 +0000 |
---|---|---|
committer | Keith Walker <kwalker@arm.com> | 2017-11-30 11:38:56 +0000 |
commit | aac00512b56fcddcb73c6cd1767bf280d111f897 (patch) | |
tree | 70ffc7139b9a8dd9c0892d2a543204ca8ff335b8 /lib/Driver/ToolChains/Arch | |
parent | f64fbddb87285b85fcc88b0455e0e731ff14032f (diff) | |
download | clang-aac00512b56fcddcb73c6cd1767bf280d111f897.tar.gz |
[ARM] disable FPU features when using soft floating point.
To be compatible with GCC if soft floating point is in effect any FPU
specified is effectively ignored, eg,
-mfloat-abi=soft -fpu=neon
If any floating point features which require FPU hardware are enabled
they must be disable.
There was some support for doing this for NEON, but it did not handle
VFP, nor did it prevent the backend from emitting the build attribute
Tag_FP_arch describing the generated code as using the floating point
hardware if a FPU was specified (even though soft float does not use
the FPU).
Disabling the hardware floating point features for targets which are
compiling for soft float has meant that some tests which were incorrectly
checking for hardware support also needed to be updated. In such cases,
where appropriate the tests have been updated to check compiling for
soft float and a non-soft float variant (usually softfp). This was
usually because the target specified in the test defaulted to soft float.
Differential Revision: https://reviews.llvm.org/D40256
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@319420 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/ToolChains/Arch')
-rw-r--r-- | lib/Driver/ToolChains/Arch/ARM.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/Driver/ToolChains/Arch/ARM.cpp b/lib/Driver/ToolChains/Arch/ARM.cpp index 44c8871d0e..5be8698aff 100644 --- a/lib/Driver/ToolChains/Arch/ARM.cpp +++ b/lib/Driver/ToolChains/Arch/ARM.cpp @@ -391,12 +391,22 @@ void arm::getARMTargetFeatures(const ToolChain &TC, } else if (HDivArg) getARMHWDivFeatures(D, HDivArg, Args, HDivArg->getValue(), Features); - // Setting -msoft-float effectively disables NEON because of the GCC - // implementation, although the same isn't true of VFP or VFP3. + // Setting -msoft-float/-mfloat-abi=soft effectively disables the FPU (GCC + // ignores the -mfpu options in this case). + // Note that the ABI can also be set implicitly by the target selected. if (ABI == arm::FloatABI::Soft) { - Features.push_back("-neon"); - // Also need to explicitly disable features which imply NEON. - Features.push_back("-crypto"); + llvm::ARM::getFPUFeatures(llvm::ARM::FK_NONE, Features); + + // Disable hardware FP features which have been enabled. + // FIXME: Disabling vfp2 and neon should be enough as all the other + // features are dependant on these 2 features in LLVM. However + // there is currently no easy way to test this in clang, so for + // now just be explicit and disable all known dependent features + // as well. + for (std::string Feature : {"vfp2", "vfp3", "vfp4", "fp-armv8", "fullfp16", + "neon", "crypto", "dotprod"}) + if (std::find(std::begin(Features), std::end(Features), "+" + Feature) != std::end(Features)) + Features.push_back("-" + Feature); } // En/disable crc code generation. |