@@ -24,7 +24,8 @@ namespace LLVM {
2424using namespace mlir ;
2525
2626struct TargetToTargetFeaturesPass
27- : public LLVM::impl::LLVMTargetToTargetFeaturesBase<TargetToTargetFeaturesPass> {
27+ : public LLVM::impl::LLVMTargetToTargetFeaturesBase<
28+ TargetToTargetFeaturesPass> {
2829 using LLVM::impl::LLVMTargetToTargetFeaturesBase<
2930 TargetToTargetFeaturesPass>::LLVMTargetToTargetFeaturesBase;
3031
@@ -53,10 +54,19 @@ struct TargetToTargetFeaturesPass
5354 llvm::MCSubtargetInfo const *subTargetInfo =
5455 (*targetMachine)->getMCSubtargetInfo ();
5556
56- StringRef fullTargetFeaturesStr = subTargetInfo->getFeatureString ();
57+ const std::vector<llvm::SubtargetFeatureKV> enabledFeatures =
58+ subTargetInfo->getEnabledProcessorFeatures ();
59+
60+ auto plussedFeatures = llvm::to_vector (
61+ llvm::map_range (enabledFeatures, [](llvm::SubtargetFeatureKV feature) {
62+ return std::string (" +" ) + feature.Key ;
63+ }));
64+
65+ auto plussedFeaturesRefs = llvm::to_vector (llvm::map_range (
66+ plussedFeatures, [](auto &it) { return StringRef (it.c_str ()); }));
5767
5868 auto fullTargetFeaturesAttr =
59- LLVM::TargetFeaturesAttr::get (&getContext (), fullTargetFeaturesStr );
69+ LLVM::TargetFeaturesAttr::get (&getContext (), plussedFeaturesRefs );
6070
6171 auto updatedTargetAttr =
6272 LLVM::TargetAttr::get (&getContext (), targetAttr.getTriple (),
0 commit comments