/// the \args CPU; this should include all legal feature strings on
/// the target.
virtual void getDefaultFeatures(const std::string &CPU,
- llvm::StringMap<bool> &Features) {
+ llvm::StringMap<bool> &Features) const {
+ }
+
+ /// setFeatureEnabled - Enable or disable a specific target feature,
+ /// the feature name must be valid.
+ ///
+ /// \return - False on error (invalid feature name).
+ virtual bool setFeatureEnabled(llvm::StringMap<bool> &Features,
+ const std::string &Name,
+ bool Enabled) const {
+ return false;
}
/// HandleTargetOptions - Perform initialization based on the user
OPTION("-mno-soft-float", mno_soft_float, Flag, m_Group, INVALID, "", 0, 0, 0)
OPTION("-mno-sse2", mno_sse2, Flag, m_x86_Features_Group, INVALID, "", 0, 0, 0)
OPTION("-mno-sse3", mno_sse3, Flag, m_x86_Features_Group, INVALID, "", 0, 0, 0)
-OPTION("-mno-sse41", mno_sse41, Flag, m_x86_Features_Group, INVALID, "", 0, 0, 0)
-OPTION("-mno-sse42", mno_sse42, Flag, m_x86_Features_Group, INVALID, "", 0, 0, 0)
OPTION("-mno-sse4a", mno_sse4a, Flag, m_x86_Features_Group, INVALID, "", 0, 0, 0)
+OPTION("-mno-sse4", mno_sse4, Flag, m_x86_Features_Group, INVALID, "", 0, 0, 0)
OPTION("-mno-sse", mno_sse, Flag, m_x86_Features_Group, INVALID, "", 0, 0, 0)
OPTION("-mno-ssse3", mno_ssse3, Flag, m_x86_Features_Group, INVALID, "", 0, 0, 0)
OPTION("-mno-warn-nonportable-cfstrings", mno_warn_nonportable_cfstrings, Flag, m_Group, INVALID, "", 0, 0, 0)
OPTION("-msoft-float", msoft_float, Flag, m_Group, INVALID, "", 0, 0, 0)
OPTION("-msse2", msse2, Flag, m_x86_Features_Group, INVALID, "", 0, 0, 0)
OPTION("-msse3", msse3, Flag, m_x86_Features_Group, INVALID, "", 0, 0, 0)
-OPTION("-msse41", msse41, Flag, m_x86_Features_Group, INVALID, "", 0, 0, 0)
-OPTION("-msse42", msse42, Flag, m_x86_Features_Group, INVALID, "", 0, 0, 0)
OPTION("-msse4a", msse4a, Flag, m_x86_Features_Group, INVALID, "", 0, 0, 0)
+OPTION("-msse4", msse4, Flag, m_x86_Features_Group, INVALID, "", 0, 0, 0)
OPTION("-msse", msse, Flag, m_x86_Features_Group, INVALID, "", 0, 0, 0)
OPTION("-mssse3", mssse3, Flag, m_x86_Features_Group, INVALID, "", 0, 0, 0)
OPTION("-mtune=", mtune_EQ, Joined, m_Group, INVALID, "", 0, 0, 0)
}
virtual void getTargetDefines(const LangOptions &Opts,
std::vector<char> &Defines) const;
-
+ virtual bool setFeatureEnabled(llvm::StringMap<bool> &Features,
+ const std::string &Name,
+ bool Enabled) const;
virtual void getDefaultFeatures(const std::string &CPU,
- llvm::StringMap<bool> &Features);
+ llvm::StringMap<bool> &Features) const;
virtual void HandleTargetFeatures(const llvm::StringMap<bool> &Features);
};
void X86TargetInfo::getDefaultFeatures(const std::string &CPU,
- llvm::StringMap<bool> &Features) {
+ llvm::StringMap<bool> &Features) const {
// FIXME: This should not be here.
Features["3dnow"] = false;
Features["3dnowa"] = false;
Features["sse2"] = Features["sse"] = Features["mmx"] = true;
}
+bool X86TargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features,
+ const std::string &Name,
+ bool Enabled) const {
+ // FIXME: This *really* should not be here.
+ if (!Features.count(Name) && Name != "sse4")
+ return false;
+
+ if (Enabled) {
+ if (Name == "mmx")
+ Features["mmx"] = true;
+ else if (Name == "sse")
+ Features["mmx"] = Features["sse"] = true;
+ else if (Name == "sse2")
+ Features["mmx"] = Features["sse"] = Features["sse2"] = true;
+ else if (Name == "sse3")
+ Features["mmx"] = Features["sse"] = Features["sse2"] =
+ Features["sse3"] = true;
+ else if (Name == "ssse3")
+ Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] =
+ Features["ssse3"] = true;
+ else if (Name == "sse4")
+ Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] =
+ Features["ssse3"] = Features["sse41"] = Features["sse42"] = true;
+ else if (Name == "3dnow")
+ Features["3dnowa"] = true;
+ else if (Name == "3dnowa")
+ Features["3dnow"] = Features["3dnowa"] = true;
+ } else {
+ if (Name == "mmx")
+ Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] =
+ Features["ssse3"] = Features["sse41"] = Features["sse42"] = false;
+ else if (Name == "sse")
+ Features["sse"] = Features["sse2"] = Features["sse3"] =
+ Features["ssse3"] = Features["sse41"] = Features["sse42"] = false;
+ else if (Name == "sse2")
+ Features["sse2"] = Features["sse3"] = Features["ssse3"] =
+ Features["sse41"] = Features["sse42"] = false;
+ else if (Name == "sse3")
+ Features["sse3"] = Features["ssse3"] = Features["sse41"] =
+ Features["sse42"] = false;
+ else if (Name == "ssse3")
+ Features["ssse3"] = Features["sse41"] = Features["sse42"] = false;
+ else if (Name == "sse4")
+ Features["sse41"] = Features["sse42"] = false;
+ else if (Name == "3dnow")
+ Features["3dnow"] = Features["3dnowa"] = false;
+ else if (Name == "3dnowa")
+ Features["3dnowa"] = false;
+ }
+
+ return true;
+}
+
/// HandleTargetOptions - Perform initialization based on the user
/// configured set of features.
void X86TargetInfo::HandleTargetFeatures(const llvm::StringMap<bool>&Features) {
Define(Defs, "__amd64");
Define(Defs, "__x86_64");
Define(Defs, "__x86_64__");
- Define(Defs, "__SSE3__");
} else {
DefineStd(Defs, "i386", Opts);
}
--- /dev/null
+// FIXME: Use -triple, not -ccc-host-triple.
+
+// RUN: clang -ccc-host-triple i386-unknown-unknown -march=core2 -msse4 -x c -E -dM -o %t %s &&
+// RUN: grep '#define __SSE2_MATH__ 1' %t &&
+// RUN: grep '#define __SSE2__ 1' %t &&
+// RUN: grep '#define __SSE3__ 1' %t &&
+// RUN: grep '#define __SSE4_1__ 1' %t &&
+// RUN: grep '#define __SSE4_2__ 1' %t &&
+// RUN: grep '#define __SSE_MATH__ 1' %t &&
+// RUN: grep '#define __SSE__ 1' %t &&
+// RUN: grep '#define __SSSE3__ 1' %t &&
+
+// RUN: clang -ccc-host-triple i386-unknown-unknown -march=core2 -msse4 -mno-sse2 -x c -E -dM -o %t %s &&
+// RUN: grep '#define __SSE2_MATH__ 1' %t | count 0 &&
+// RUN: grep '#define __SSE2__ 1' %t | count 0 &&
+// RUN: grep '#define __SSE3__ 1' %t | count 0 &&
+// RUN: grep '#define __SSE4_1__ 1' %t | count 0 &&
+// RUN: grep '#define __SSE4_2__ 1' %t | count 0 &&
+// RUN: grep '#define __SSE_MATH__ 1' %t &&
+// RUN: grep '#define __SSE__ 1' %t &&
+// RUN: grep '#define __SSSE3__ 1' %t | count 0 &&
+
+// RUN: true
+
+
Name);
exit(1);
}
-
- llvm::StringMap<bool>::iterator it = Features.find(Name + 1);
- if (it == Features.end()) {
- fprintf(stderr, "error: clang-cc: invalid target feature string: %s\n",
- Name);
+ if (!Target->setFeatureEnabled(Features, Name + 1, (Name[0] == '+'))) {
+ fprintf(stderr, "error: clang-cc: invalid target feature name: %s\n",
+ Name + 1);
exit(1);
}
-
- // FIXME: Actually, we need to apply all the features implied by
- // this feature.
- it->second = (Name[0] == '+');
}
}