summaryrefslogtreecommitdiffstats
path: root/clang/lib/Basic/Targets.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2011-11-27 20:00:43 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2011-11-27 20:00:43 +0000
commita6416a7c73733b0c2615ffe14708fa4eab02f75d (patch)
tree0c2333c3731ce7b840cf63a4ba9bf2baf861a5fe /clang/lib/Basic/Targets.cpp
parent080dd7ce302ecfa78476fa2a6a2ac890e8d7dc54 (diff)
downloadbcm5719-llvm-a6416a7c73733b0c2615ffe14708fa4eab02f75d.tar.gz
bcm5719-llvm-a6416a7c73733b0c2615ffe14708fa4eab02f75d.zip
Make our handling of MMX x SSE closer to what gcc does:
* Enabling sse enables mmx. * Disabling (-mno-mmx) mmx, doesn't disable sse (we got this right already). * The order in not important. -msse -mno-mmx is the same as -mno-mmx -msse. llvm-svn: 145194
Diffstat (limited to 'clang/lib/Basic/Targets.cpp')
-rw-r--r--clang/lib/Basic/Targets.cpp45
1 files changed, 34 insertions, 11 deletions
diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index 1dcdf93ba70..3726fb8e0dc 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -1587,23 +1587,26 @@ bool X86TargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features,
(Name != "sse4" && Name != "sse4.2" && Name != "sse4.1"))
return false;
+ // FIXME: this should probably use a switch with fall through.
+
if (Enabled) {
if (Name == "mmx")
Features["mmx"] = true;
else if (Name == "sse")
- Features["sse"] = true;
+ Features["mmx"] = Features["sse"] = true;
else if (Name == "sse2")
- Features["sse"] = Features["sse2"] = true;
+ Features["mmx"] = Features["sse"] = Features["sse2"] = true;
else if (Name == "sse3")
- Features["sse"] = Features["sse2"] = Features["sse3"] = true;
+ Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] =
+ true;
else if (Name == "ssse3")
- Features["sse"] = Features["sse2"] = Features["sse3"] =
+ Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] =
Features["ssse3"] = true;
else if (Name == "sse4" || Name == "sse4.2")
- Features["sse"] = Features["sse2"] = Features["sse3"] =
+ Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] =
Features["ssse3"] = Features["sse41"] = Features["sse42"] = true;
else if (Name == "sse4.1")
- Features["sse"] = Features["sse2"] = Features["sse3"] =
+ Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] =
Features["ssse3"] = Features["sse41"] = true;
else if (Name == "3dnow")
Features["mmx"] = Features["3dnow"] = true;
@@ -1612,10 +1615,11 @@ bool X86TargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features,
else if (Name == "aes")
Features["aes"] = true;
else if (Name == "avx")
- Features["avx"] = Features["sse"] = Features["sse2"] = Features["sse3"] =
- Features["ssse3"] = Features["sse41"] = Features["sse42"] = true;
+ Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] =
+ Features["ssse3"] = Features["sse41"] = Features["sse42"] =
+ Features["avx"] = true;
else if (Name == "sse4a")
- Features["sse4a"] = true;
+ Features["mmx"] = Features["sse4a"] = true;
} else {
if (Name == "mmx")
Features["mmx"] = Features["3dnow"] = Features["3dnowa"] = false;
@@ -3671,13 +3675,32 @@ TargetInfo *TargetInfo::CreateTargetInfo(DiagnosticsEngine &Diags,
Target->getDefaultFeatures(Features);
// Apply the user specified deltas.
+ // First the enables.
for (std::vector<std::string>::const_iterator it = Opts.Features.begin(),
ie = Opts.Features.end(); it != ie; ++it) {
const char *Name = it->c_str();
+ if (Name[0] != '+')
+ continue;
+
+ // Apply the feature via the target.
+ if (!Target->setFeatureEnabled(Features, Name + 1, true)) {
+ Diags.Report(diag::err_target_invalid_feature) << Name;
+ return 0;
+ }
+ }
+
+ // Then the disables.
+ for (std::vector<std::string>::const_iterator it = Opts.Features.begin(),
+ ie = Opts.Features.end(); it != ie; ++it) {
+ const char *Name = it->c_str();
+
+ if (Name[0] == '+')
+ continue;
+
// Apply the feature via the target.
- if ((Name[0] != '-' && Name[0] != '+') ||
- !Target->setFeatureEnabled(Features, Name + 1, (Name[0] == '+'))) {
+ if (Name[0] != '-' ||
+ !Target->setFeatureEnabled(Features, Name + 1, false)) {
Diags.Report(diag::err_target_invalid_feature) << Name;
return 0;
}
OpenPOWER on IntegriCloud