aboutsummaryrefslogtreecommitdiff
path: root/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
commit6328cc316d7032517399da9230a197cd29f2664d (patch)
treed2abea490e57bd931855bfe07d11a30f9e88cf65 /lib/Basic/Targets.cpp
parent7ba138abd329e591a8f6d5001f60dd7082f71b3b (diff)
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65966 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Basic/Targets.cpp')
-rw-r--r--lib/Basic/Targets.cpp49
1 files changed, 41 insertions, 8 deletions
diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp
index bb9c861a17..04ab3afdb1 100644
--- a/lib/Basic/Targets.cpp
+++ b/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