diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-12-19 03:30:57 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-12-19 03:30:57 +0000 |
commit | 7b245eda5e1f8979a4afb0abbcd063ccde7a0acd (patch) | |
tree | 777cf23fa57789ef4a24bd36fff7e77502234352 /clang/lib | |
parent | 0a66daf900a7a4c21885ffac7bc3c8a8287750cf (diff) | |
download | bcm5719-llvm-7b245eda5e1f8979a4afb0abbcd063ccde7a0acd.tar.gz bcm5719-llvm-7b245eda5e1f8979a4afb0abbcd063ccde7a0acd.zip |
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.
llvm-svn: 91753
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Basic/Targets.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index 059d4d3023a..7cc9f73b6cd 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -688,7 +688,7 @@ public: 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 @@ bool X86TargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features, /// 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 @@ static TargetInfo *AllocateTarget(const std::string &T) { /// 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 @@ TargetInfo *TargetInfo::CreateTargetInfo(Diagnostic &Diags, // // 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(); } |