summaryrefslogtreecommitdiffstats
path: root/clang/lib/Basic/Targets.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-03-03 19:56:18 +0000
committerChris Lattner <sabre@nondot.org>2009-03-03 19:56:18 +0000
commit5c3529634a9a7ca34ea154b99782a7132328728f (patch)
treefa9e05b9c0413a9e7a9e034024026ae1b43116ca /clang/lib/Basic/Targets.cpp
parent3a72265d41956504009112a2219b5cd8da079430 (diff)
downloadbcm5719-llvm-5c3529634a9a7ca34ea154b99782a7132328728f.tar.gz
bcm5719-llvm-5c3529634a9a7ca34ea154b99782a7132328728f.zip
implement support for propagating *features* down to the code generator
and defining target-specific macros based on them (like __SSE3__ and friends). After extensive discussion with Daniel, this work will need driver support, which will translate things like -msse3 into a -mattr feature. Until this work is done, the code in clang.cpp is disabled and the X86TargetInfo ctor still defaults to SSE2. With these two things changed, this code will work. PR3634 llvm-svn: 65966
Diffstat (limited to 'clang/lib/Basic/Targets.cpp')
-rw-r--r--clang/lib/Basic/Targets.cpp49
1 files changed, 41 insertions, 8 deletions
diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index bb9c861a170..04ab3afdb14 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -420,7 +420,10 @@ class X86TargetInfo : public TargetInfo {
} SSELevel;
public:
X86TargetInfo(const std::string& triple)
- : TargetInfo(triple), SSELevel(SSE2) {
+ : TargetInfo(triple),
+ // FIXME: hard coding to SSE2 for now. This should change to NoMMXSSE so
+ // that the driver controls this.
+ SSELevel(SSE2) {
LongDoubleFormat = &llvm::APFloat::x87DoubleExtended;
}
virtual void getTargetBuiltins(const Builtin::Info *&Records,
@@ -449,19 +452,49 @@ public:
}
virtual void getTargetDefines(std::vector<char> &Defines) const;
- virtual int HandleTargetOptions(std::string *StrArray, unsigned NumStrs,
- std::string &ErrorReason);
+ virtual int HandleTargetFeatures(std::string *StrArray, unsigned NumStrs,
+ std::string &ErrorReason);
};
/// HandleTargetOptions - Handle target-specific options like -msse2 and
/// friends. An array of arguments is passed in: if they are all valid, this
/// should handle them and return -1. If there is an error, the index of the
/// invalid argument should be returned along with an optional error string.
-int X86TargetInfo::HandleTargetOptions(std::string *StrArray, unsigned NumStrs,
- std::string &ErrorReason) {
- if (NumStrs == 0)
- return -1;
- return 0;
+int X86TargetInfo::HandleTargetFeatures(std::string *StrArray, unsigned NumStrs,
+ std::string &ErrorReason) {
+ for (unsigned i = 0; i != NumStrs; ++i) {
+ const std::string &Feature = StrArray[i];
+ if (Feature.size() < 2) return i;
+ // Ignore explicitly disabled features.
+ if (Feature[0] == '-') continue;
+
+ // Feature strings are of the form "+feature".
+ if (Feature[0] != '+') return i;
+
+ // The set of supported subtarget features is defined in
+ // lib/Target/X86/X86.td. Here we recognize and map onto our internal
+ // state.
+ if (Feature == "+mmx")
+ SSELevel = std::max(SSELevel, MMX);
+ else if (Feature == "+sse")
+ SSELevel = std::max(SSELevel, SSE1);
+ else if (Feature == "+sse2")
+ SSELevel = std::max(SSELevel, SSE2);
+ else if (Feature == "+sse3")
+ SSELevel = std::max(SSELevel, SSE3);
+ else if (Feature == "+ssse3")
+ SSELevel = std::max(SSELevel, SSSE3);
+ else if (Feature == "+sse41")
+ SSELevel = std::max(SSELevel, SSE41);
+ else if (Feature == "+sse42")
+ SSELevel = std::max(SSELevel, SSE42);
+ else if (Feature == "+64bit" || Feature == "+slow-bt-mem")
+ // Ignore these features.
+ continue;
+ else
+ return i;
+ }
+ return -1;
}
/// X86TargetInfo::getTargetDefines - Return a set of the X86-specific #defines
OpenPOWER on IntegriCloud