summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGCall.cpp
diff options
context:
space:
mode:
authorEric Christopher <echristo@gmail.com>2015-09-01 22:03:58 +0000
committerEric Christopher <echristo@gmail.com>2015-09-01 22:03:58 +0000
commit21213a704094c5bb13f45301b49757c0d13d4599 (patch)
treeee82826e72ba0b7fcf3032b5152a467a7697af76 /clang/lib/CodeGen/CGCall.cpp
parentb57804a134dfecfd9117c61ec07ce937791cb8ce (diff)
downloadbcm5719-llvm-21213a704094c5bb13f45301b49757c0d13d4599.tar.gz
bcm5719-llvm-21213a704094c5bb13f45301b49757c0d13d4599.zip
Migrate the target attribute parsing code into an extension off of
the main attribute and cache the results so we don't have to parse a single attribute more than once. llvm-svn: 246596
Diffstat (limited to 'clang/lib/CodeGen/CGCall.cpp')
-rw-r--r--clang/lib/CodeGen/CGCall.cpp37
1 files changed, 8 insertions, 29 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 270d9941ec8..ed7bf60c024 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -1499,40 +1499,19 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI,
const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(TargetDecl);
if (FD && FD->hasAttr<TargetAttr>()) {
llvm::StringMap<bool> FeatureMap;
- const auto *TD = FD->getAttr<TargetAttr>();
+ auto *TD = FD->getAttr<TargetAttr>();
// Make a copy of the features as passed on the command line.
std::vector<std::string> FnFeatures =
getTarget().getTargetOpts().FeaturesAsWritten;
- // Grab the target attribute string.
- StringRef FeaturesStr = TD->getFeatures();
- SmallVector<StringRef, 1> AttrFeatures;
- FeaturesStr.split(AttrFeatures, ",");
-
- // Grab the various features and prepend a "+" to turn on the feature to
- // the backend and add them to our existing set of features.
- for (auto &Feature : AttrFeatures) {
- // Go ahead and trim whitespace rather than either erroring or
- // accepting it weirdly.
- Feature = Feature.trim();
-
- // While we're here iterating check for a different target cpu.
- if (Feature.startswith("arch="))
- TargetCPU = Feature.split("=").second.trim();
- else if (Feature.startswith("tune="))
- // We don't support cpu tuning this way currently.
- ;
- else if (Feature.startswith("fpmath="))
- // TODO: Support the fpmath option this way. It will require checking
- // overall feature validity for the function with the rest of the
- // attributes on the function.
- ;
- else if (Feature.startswith("no-"))
- FnFeatures.push_back("-" + Feature.split("-").second.str());
- else
- FnFeatures.push_back("+" + Feature.str());
- }
+ std::vector<std::string> &AttrFeatures = TD->getFeatures();
+ std::copy(AttrFeatures.begin(), AttrFeatures.end(),
+ std::back_inserter(FnFeatures));
+
+ if (TD->getCPU() != "")
+ TargetCPU = TD->getCPU();
+
// Now populate the feature map, first with the TargetCPU which is either
// the default or a new one from the target attribute string. Then we'll
// use the passed in features (FeaturesAsWritten) along with the new ones
OpenPOWER on IntegriCloud