[cfe-commits] r91753 - in /cfe/trunk: include/clang/Basic/TargetInfo.h lib/Basic/Targets.cpp
Daniel Dunbar
daniel at zuster.org
Fri Dec 18 19:30:58 PST 2009
Author: ddunbar
Date: Fri Dec 18 21:30:57 2009
New Revision: 91753
URL: http://llvm.org/viewvc/llvm-project?rev=91753&view=rev
Log:
Targets: Allow CreateTargetInfo to mutate the target features.
- In particular, it can claim features for itself instead of always passing them on to LLVM.
- This allows using the target features as a generic mechanism for passing target specific options to the TargetInfo instance, which may need them for initializing preprocessor defines, etc.
Modified:
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/Basic/Targets.cpp
Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=91753&r1=91752&r2=91753&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Fri Dec 18 21:30:57 2009
@@ -61,8 +61,11 @@
public:
/// CreateTargetInfo - Construct a target for the given options.
- static TargetInfo* CreateTargetInfo(Diagnostic &Diags,
- const TargetOptions &Opts);
+ ///
+ /// \param Opts - The options to use to initialize the target. The target may
+ /// modify the options to canonicalize the target feature information to match
+ /// what the backend expects.
+ static TargetInfo* CreateTargetInfo(Diagnostic &Diags, TargetOptions &Opts);
virtual ~TargetInfo();
@@ -389,7 +392,10 @@
/// HandleTargetOptions - Perform initialization based on the user configured
/// set of features (e.g., +sse4). The list is guaranteed to have at most one
/// entry per feature.
- virtual void HandleTargetFeatures(const std::vector<std::string> &Features) {
+ ///
+ /// The target may modify the features list, to change which options are
+ /// passed onwards to the backend.
+ virtual void HandleTargetFeatures(std::vector<std::string> &Features) {
}
// getRegParmMax - Returns maximal number of args passed in registers.
Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=91753&r1=91752&r2=91753&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri Dec 18 21:30:57 2009
@@ -688,7 +688,7 @@
bool Enabled) const;
virtual void getDefaultFeatures(const std::string &CPU,
llvm::StringMap<bool> &Features) const;
- virtual void HandleTargetFeatures(const std::vector<std::string> &Features);
+ virtual void HandleTargetFeatures(std::vector<std::string> &Features);
};
void X86TargetInfo::getDefaultFeatures(const std::string &CPU,
@@ -805,8 +805,7 @@
/// HandleTargetOptions - Perform initialization based on the user
/// configured set of features.
-void
-X86TargetInfo::HandleTargetFeatures(const std::vector<std::string> &Features) {
+void X86TargetInfo::HandleTargetFeatures(std::vector<std::string> &Features) {
// Remember the maximum enabled sselevel.
for (unsigned i = 0, e = Features.size(); i !=e; ++i) {
// Ignore disabled features.
@@ -2112,7 +2111,7 @@
/// CreateTargetInfo - Return the target info object for the specified target
/// triple.
TargetInfo *TargetInfo::CreateTargetInfo(Diagnostic &Diags,
- const TargetOptions &Opts) {
+ TargetOptions &Opts) {
llvm::Triple Triple(Opts.Triple);
// Construct the target
@@ -2156,11 +2155,11 @@
//
// FIXME: If we are completely confident that we have the right set, we only
// need to pass the minuses.
- std::vector<std::string> StrFeatures;
+ Opts.Features.clear();
for (llvm::StringMap<bool>::const_iterator it = Features.begin(),
ie = Features.end(); it != ie; ++it)
- StrFeatures.push_back(std::string(it->second ? "+" : "-") + it->first());
- Target->HandleTargetFeatures(StrFeatures);
+ Opts.Features.push_back(std::string(it->second ? "+" : "-") + it->first());
+ Target->HandleTargetFeatures(Opts.Features);
return Target.take();
}
More information about the cfe-commits
mailing list