Skip to content

Commit ec15717

Browse files
committed
Get feature flags from proper source
Thanks Renato!
1 parent fbcd09d commit ec15717

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

mlir/lib/Target/LLVMIR/Transforms/TargetToTargetFeatures.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ namespace LLVM {
2424
using namespace mlir;
2525

2626
struct 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

Comments
 (0)