diff options
author | Eric Christopher <echristo@gmail.com> | 2015-11-11 23:05:08 +0000 |
---|---|---|
committer | Eric Christopher <echristo@gmail.com> | 2015-11-11 23:05:08 +0000 |
commit | 2b90a64e319be87760ca2b4323362b1b0e403182 (patch) | |
tree | c96388aa8f24b4bb46e9d39f0255a15a30f74709 /clang/lib/CodeGen/CGCall.cpp | |
parent | cc9030b60a4b84e3057836eaef2e2fc39b2712c8 (diff) | |
download | bcm5719-llvm-2b90a64e319be87760ca2b4323362b1b0e403182.tar.gz bcm5719-llvm-2b90a64e319be87760ca2b4323362b1b0e403182.zip |
Extract out a function onto CodeGenModule for getting the map of
features for a particular function, then use it to clean up some
code.
llvm-svn: 252819
Diffstat (limited to 'clang/lib/CodeGen/CGCall.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGCall.cpp | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 99a093223d1..430184d4398 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -1506,24 +1506,7 @@ 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>(); - TargetAttr::ParsedTargetAttr ParsedAttr = TD->parse(); - - // Make a copy of the features as passed on the command line into the - // beginning of the additional features from the function to override. - ParsedAttr.first.insert( - ParsedAttr.first.begin(), - getTarget().getTargetOpts().FeaturesAsWritten.begin(), - getTarget().getTargetOpts().FeaturesAsWritten.end()); - - if (ParsedAttr.second != "") - TargetCPU = ParsedAttr.second; - - // 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 - // from the attribute. - getTarget().initFeatureMap(FeatureMap, Diags, TargetCPU, ParsedAttr.first); + getFunctionFeatureMap(FeatureMap, FD); // Produce the canonical string for this set of features. std::vector<std::string> Features; @@ -1533,6 +1516,13 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI, Features.push_back((it->second ? "+" : "-") + it->first().str()); // Now add the target-cpu and target-features to the function. + // While we populated the feature map above, we still need to + // get and parse the target attribute so we can get the cpu for + // the function. + const auto *TD = FD->getAttr<TargetAttr>(); + TargetAttr::ParsedTargetAttr ParsedAttr = TD->parse(); + if (ParsedAttr.second != "") + TargetCPU = ParsedAttr.second; if (TargetCPU != "") FuncAttrs.addAttribute("target-cpu", TargetCPU); if (!Features.empty()) { |