From 0070c0bfbe11fd114092a61015d1512bfa40f0fb Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Mon, 30 Jan 2012 06:38:25 +0000 Subject: 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 . llvm-svn: 149227 --- clang/lib/Basic/Module.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'clang/lib/Basic/Module.cpp') diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp index 3052532650e..c5838fb65f2 100644 --- a/clang/lib/Basic/Module.cpp +++ b/clang/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(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 -- cgit v1.2.3