}
Features[Name] = Enabled;
-
- SmallVector<StringRef, 8> ImpliedFeatures;
- llvm::X86::getImpliedFeatures(Name, Enabled, ImpliedFeatures);
- for (const auto &F : ImpliedFeatures)
- Features[F] = Enabled;
+ llvm::X86::updateImpliedFeatures(Name, Enabled, Features);
}
/// handleTargetFeatures - Perform initialization based on the user
#define LLVM_SUPPORT_X86TARGETPARSERCOMMON_H
#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringMap.h"
namespace llvm {
class StringRef;
/// Fill in the features that \p CPU supports into \p Features.
void getFeaturesForCPU(StringRef CPU, SmallVectorImpl<StringRef> &Features);
-/// Fill \p Features with the features that are implied to be enabled/disabled
+/// Set or clear entries in \p Features that are implied to be enabled/disabled
/// by the provided \p Feature.
-void getImpliedFeatures(StringRef Feature, bool Enabled,
- SmallVectorImpl<StringRef> &Features);
+void updateImpliedFeatures(StringRef Feature, bool Enabled,
+ StringMap<bool> &Features);
} // namespace X86
} // namespace llvm
#include "llvm/Support/X86TargetParser.def"
};
-// Convert the set bits in FeatureBitset to a list of strings.
-static void getFeatureBitsAsStrings(const FeatureBitset &Bits,
- SmallVectorImpl<StringRef> &Features) {
- for (unsigned i = 0; i != CPU_FEATURE_MAX; ++i)
- if (Bits[i] && !FeatureInfos[i].Name.empty())
- Features.push_back(FeatureInfos[i].Name);
-}
-
void llvm::X86::getFeaturesForCPU(StringRef CPU,
SmallVectorImpl<StringRef> &EnabledFeatures) {
auto I = llvm::find_if(Processors,
Bits &= ~Feature64BIT;
// Add the string version of all set bits.
- getFeatureBitsAsStrings(Bits, EnabledFeatures);
+ for (unsigned i = 0; i != CPU_FEATURE_MAX; ++i)
+ if (Bits[i] && !FeatureInfos[i].Name.empty())
+ EnabledFeatures.push_back(FeatureInfos[i].Name);
}
// For each feature that is (transitively) implied by this feature, set it.
} while (Prev != Bits);
}
-void llvm::X86::getImpliedFeatures(
+void llvm::X86::updateImpliedFeatures(
StringRef Feature, bool Enabled,
- SmallVectorImpl<StringRef> &ImpliedFeatures) {
+ StringMap<bool> &Features) {
auto I = llvm::find_if(
FeatureInfos, [&](const FeatureInfo &FI) { return FI.Name == Feature; });
if (I == std::end(FeatureInfos)) {
getImpliedDisabledFeatures(ImpliedBits,
std::distance(std::begin(FeatureInfos), I));
- // Convert all the found bits into strings.
- getFeatureBitsAsStrings(ImpliedBits, ImpliedFeatures);
+ // Update the map entry for all implied features.
+ for (unsigned i = 0; i != CPU_FEATURE_MAX; ++i)
+ if (ImpliedBits[i] && !FeatureInfos[i].Name.empty())
+ Features[FeatureInfos[i].Name] = Enabled;
}