diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-01-30 06:38:25 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-01-30 06:38:25 +0000 |
commit | e727d21d3fd5f6f68d9e7a260bbf84dc2fc8ae3a (patch) | |
tree | bc05640ca1b614f850dc49bdf962c8511959cc06 /lib/Basic/Module.cpp | |
parent | 89f42834092621ab6ebac24e09b17b61ac000b6b (diff) |
Introduce TargetInfo::hasFeature() to query various feature names in
each of the targets. Use this for module requirements, so that we can
pin the availability of certain modules to certain target features,
e.g., provide a module for xmmintrin.h only when SSE support is
available.
Use these feature names to provide a nearly-complete module map for
Clang's built-in headers. Only mm_alloc.h and unwind.h are missing,
and those two are fairly specialized at the moment. Finishes
<rdar://problem/10710060>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149227 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Basic/Module.cpp')
-rw-r--r-- | lib/Basic/Module.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/Basic/Module.cpp b/lib/Basic/Module.cpp index 3052532650..c5838fb65f 100644 --- a/lib/Basic/Module.cpp +++ b/lib/Basic/Module.cpp @@ -14,6 +14,7 @@ #include "clang/Basic/Module.h" #include "clang/Basic/FileManager.h" #include "clang/Basic/LangOptions.h" +#include "clang/Basic/TargetInfo.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" #include "llvm/ADT/SmallVector.h" @@ -50,12 +51,15 @@ Module::~Module() { static bool hasFeature(StringRef Feature, const LangOptions &LangOpts, const TargetInfo &Target) { return llvm::StringSwitch<bool>(Feature) + .Case("altivec", LangOpts.AltiVec) .Case("blocks", LangOpts.Blocks) .Case("cplusplus", LangOpts.CPlusPlus) .Case("cplusplus11", LangOpts.CPlusPlus0x) .Case("objc", LangOpts.ObjC1) .Case("objc_arc", LangOpts.ObjCAutoRefCount) - .Default(false); + .Case("opencl", LangOpts.OpenCL) + .Case("tls", Target.isTLSSupported()) + .Default(Target.hasFeature(Feature)); } bool |