summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorEric Christopher <echristo@gmail.com>2015-11-11 23:05:08 +0000
committerEric Christopher <echristo@gmail.com>2015-11-11 23:05:08 +0000
commit2b90a64e319be87760ca2b4323362b1b0e403182 (patch)
treec96388aa8f24b4bb46e9d39f0255a15a30f74709 /clang/lib/CodeGen/CodeGenModule.cpp
parentcc9030b60a4b84e3057836eaef2e2fc39b2712c8 (diff)
downloadbcm5719-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/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index d36a85df54c..5f4de74014f 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -3875,3 +3875,32 @@ llvm::MDTuple *CodeGenModule::CreateVTableBitSetEntry(
llvm::ConstantInt::get(Int64Ty, Offset.getQuantity()))};
return llvm::MDTuple::get(getLLVMContext(), BitsetOps);
}
+
+// Fills in the supplied string map with the set of target features for the
+// passed in function.
+void CodeGenModule::getFunctionFeatureMap(llvm::StringMap<bool> &FeatureMap,
+ const FunctionDecl *FD) {
+ StringRef TargetCPU = Target.getTargetOpts().CPU;
+ if (const auto *TD = FD->getAttr<TargetAttr>()) {
+ // If we have a TargetAttr build up the feature map based on that.
+ 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(),
+ Target.getTargetOpts().FeaturesAsWritten.begin(),
+ Target.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.
+ Target.initFeatureMap(FeatureMap, getDiags(), TargetCPU, ParsedAttr.first);
+ } else {
+ Target.initFeatureMap(FeatureMap, getDiags(), TargetCPU,
+ Target.getTargetOpts().Features);
+ }
+}
OpenPOWER on IntegriCloud