diff options
author | Sjoerd Meijer <sjoerd.meijer@arm.com> | 2016-10-19 07:25:06 +0000 |
---|---|---|
committer | Sjoerd Meijer <sjoerd.meijer@arm.com> | 2016-10-19 07:25:06 +0000 |
commit | a3187792634ee4a321a5456109fecb374980be4a (patch) | |
tree | 22c039ced12e23ee392d9b7187e44531a4403e4d /llvm/lib/Target/ARM | |
parent | da9dc6ad84d865431d712f5af9d23e40382ab072 (diff) | |
download | bcm5719-llvm-a3187792634ee4a321a5456109fecb374980be4a.tar.gz bcm5719-llvm-a3187792634ee4a321a5456109fecb374980be4a.zip |
Checking FP function attribute values and adding more build attribute tests.
This renames the function for checking FP function attribute values and also
adds more build attribute tests (which are in separate files because build
attributes are set per file).
Differential Revision: https://reviews.llvm.org/D25625
llvm-svn: 284571
Diffstat (limited to 'llvm/lib/Target/ARM')
-rw-r--r-- | llvm/lib/Target/ARM/ARMAsmPrinter.cpp | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/llvm/lib/Target/ARM/ARMAsmPrinter.cpp b/llvm/lib/Target/ARM/ARMAsmPrinter.cpp index ad8a6ed0b6d..eec42f27a03 100644 --- a/llvm/lib/Target/ARM/ARMAsmPrinter.cpp +++ b/llvm/lib/Target/ARM/ARMAsmPrinter.cpp @@ -633,17 +633,17 @@ static ARMBuildAttrs::CPUArch getArchForCPU(StringRef CPU, return ARMBuildAttrs::v4; } -// Returns true if all functions have the same function attribute value -static bool haveAllFunctionsAttribute(const Module &M, StringRef Attr, - StringRef Value) { - for (auto &F : M) - if (F.getFnAttribute(Attr).getValueAsString() != Value) - return false; - - return true; +// Returns true if all functions have the same function attribute value. +// It also returns true when there are no functions, or when +// the particular function attribute is not set to a value. +static bool checkFunctionsAttributeConsistency(const Module &M, StringRef Attr, + StringRef Value) { + return !any_of(M, [&](const Function &F) { + return F.hasFnAttribute(Attr) && + F.getFnAttribute(Attr).getValueAsString() != Value; + }); } - void ARMAsmPrinter::emitAttributes() { MCTargetStreamer &TS = *OutStreamer->getTargetStreamer(); ARMTargetStreamer &ATS = static_cast<ARMTargetStreamer &>(TS); @@ -781,13 +781,15 @@ void ARMAsmPrinter::emitAttributes() { } // Set FP Denormals. - if (haveAllFunctionsAttribute(*MMI->getModule(), "denormal-fp-math", - "preserve-sign") || + if (checkFunctionsAttributeConsistency(*MMI->getModule(), + "denormal-fp-math", + "preserve-sign") || TM.Options.FPDenormalMode == FPDenormal::PreserveSign) ATS.emitAttribute(ARMBuildAttrs::ABI_FP_denormal, ARMBuildAttrs::PreserveFPSign); - else if (haveAllFunctionsAttribute(*MMI->getModule(), "denormal-fp-math", - "positive-zero") || + else if (checkFunctionsAttributeConsistency(*MMI->getModule(), + "denormal-fp-math", + "positive-zero") || TM.Options.FPDenormalMode == FPDenormal::PositiveZero) ATS.emitAttribute(ARMBuildAttrs::ABI_FP_denormal, ARMBuildAttrs::PositiveZero); @@ -821,7 +823,8 @@ void ARMAsmPrinter::emitAttributes() { } // Set FP exceptions and rounding - if (haveAllFunctionsAttribute(*MMI->getModule(), "no-trapping-math", "true") || + if (checkFunctionsAttributeConsistency(*MMI->getModule(), + "no-trapping-math", "true") || TM.Options.NoTrappingFPMath) ATS.emitAttribute(ARMBuildAttrs::ABI_FP_exceptions, ARMBuildAttrs::Not_Allowed); |