diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-08-20 18:57:55 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-08-20 18:57:55 +0000 |
| commit | db0fcfbfaeb2e401c06ca55a431755f11af76720 (patch) | |
| tree | d3e8950d691e4923c09083deb069c73c5d76ac73 /clang/lib/Basic/Targets.cpp | |
| parent | 9427939f65fd757da5b460ca923f1b56ae38a3a0 (diff) | |
| download | bcm5719-llvm-db0fcfbfaeb2e401c06ca55a431755f11af76720.tar.gz bcm5719-llvm-db0fcfbfaeb2e401c06ca55a431755f11af76720.zip | |
Centralize the logic for handling -m* options and fix pr16943.
This moves the logic for handling -mfoo -mno-foo from the driver to -cc1. It
also changes -cc1 to apply the options in order, fixing pr16943.
The handling of -mno-mmx -msse is now an explicit special case.
llvm-svn: 188817
Diffstat (limited to 'clang/lib/Basic/Targets.cpp')
| -rw-r--r-- | clang/lib/Basic/Targets.cpp | 44 |
1 files changed, 20 insertions, 24 deletions
diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index 788579de7a1..9d6406be257 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -2089,7 +2089,8 @@ void X86TargetInfo::setSSELevel(llvm::StringMap<bool> &Features, case SSE2: Features["sse2"] = true; case SSE1: - setMMXLevel(Features, MMX, Enabled); + if (!Features.count("mmx")) + setMMXLevel(Features, MMX, Enabled); Features["sse"] = true; case NoSSE: break; @@ -5468,34 +5469,29 @@ TargetInfo *TargetInfo::CreateTargetInfo(DiagnosticsEngine &Diags, llvm::StringMap<bool> Features; Target->getDefaultFeatures(Features); - // Apply the user specified deltas. - // First the enables. - for (std::vector<std::string>::const_iterator - it = Opts->FeaturesAsWritten.begin(), - ie = Opts->FeaturesAsWritten.end(); - it != ie; ++it) { - const char *Name = it->c_str(); - - if (Name[0] != '+') - continue; - - // Apply the feature via the target. - Target->setFeatureEnabled(Features, Name + 1, true); + // Fist the last of each option; + llvm::StringMap<unsigned> LastOpt; + for (unsigned I = 0, N = Opts->FeaturesAsWritten.size(); + I < N; ++I) { + const char *Name = Opts->FeaturesAsWritten[I].c_str() + 1; + LastOpt[Name] = I; } - // Then the disables. - for (std::vector<std::string>::const_iterator - it = Opts->FeaturesAsWritten.begin(), - ie = Opts->FeaturesAsWritten.end(); - it != ie; ++it) { - const char *Name = it->c_str(); - - if (Name[0] == '+') + // Apply the user specified deltas. + for (unsigned I = 0, N = Opts->FeaturesAsWritten.size(); + I < N; ++I) { + const char *Name = Opts->FeaturesAsWritten[I].c_str(); + + // If this option was overridden, ignore it. + llvm::StringMap<unsigned>::iterator LastI = LastOpt.find(Name + 1); + assert(LastI != LastOpt.end()); + unsigned Last = LastI->second; + if (Last != I) continue; // Apply the feature via the target. - assert(Name[0] == '-'); - Target->setFeatureEnabled(Features, Name + 1, false); + bool Enabled = Name[0] == '+'; + Target->setFeatureEnabled(Features, Name + 1, Enabled); } // Add the features to the compile options. |

