[PATCH] D158814: [X86] Merge FeatureInfos_WithPLUS and FeatureInfos. NFC
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 27 22:40:13 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5487b67caf91: [X86] Merge FeatureInfos_WithPLUS and FeatureInfos. NFC (authored by craig.topper).
Changed prior to commit:
https://reviews.llvm.org/D158814?vs=553353&id=553840#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D158814/new/
https://reviews.llvm.org/D158814
Files:
llvm/include/llvm/TargetParser/X86TargetParser.h
llvm/lib/TargetParser/X86TargetParser.cpp
Index: llvm/lib/TargetParser/X86TargetParser.cpp
===================================================================
--- llvm/lib/TargetParser/X86TargetParser.cpp
+++ llvm/lib/TargetParser/X86TargetParser.cpp
@@ -32,8 +32,15 @@
};
struct FeatureInfo {
- StringLiteral Name;
+ StringLiteral NameWithPlus;
FeatureBitset ImpliedFeatures;
+
+ StringRef getName(bool WithPlus = false) const {
+ assert(NameWithPlus[0] == '+' && "Expected string to start with '+'");
+ if (WithPlus)
+ return NameWithPlus;
+ return NameWithPlus.drop_front();
+ }
};
} // end anonymous namespace
@@ -603,18 +610,13 @@
constexpr FeatureBitset ImpliedFeaturesAVXVNNI = FeatureAVX2;
constexpr FeatureInfo FeatureInfos[X86::CPU_FEATURE_MAX] = {
-#define X86_FEATURE(ENUM, STR) {{STR}, ImpliedFeatures##ENUM},
-#include "llvm/TargetParser/X86TargetParser.def"
-};
-
-constexpr FeatureInfo FeatureInfos_WithPLUS[X86::CPU_FEATURE_MAX] = {
#define X86_FEATURE(ENUM, STR) {{"+" STR}, ImpliedFeatures##ENUM},
#include "llvm/TargetParser/X86TargetParser.def"
};
void llvm::X86::getFeaturesForCPU(StringRef CPU,
SmallVectorImpl<StringRef> &EnabledFeatures,
- bool IfNeedPlus) {
+ bool NeedPlus) {
auto I = llvm::find_if(Processors,
[&](const ProcInfo &P) { return P.Name == CPU; });
assert(I != std::end(Processors) && "Processor not found!");
@@ -627,11 +629,8 @@
// Add the string version of all set bits.
for (unsigned i = 0; i != CPU_FEATURE_MAX; ++i)
- if (Bits[i] && !FeatureInfos[i].Name.empty() &&
- !FeatureInfos_WithPLUS[i].Name.empty()){
- EnabledFeatures.push_back(IfNeedPlus ? FeatureInfos_WithPLUS[i].Name
- : FeatureInfos[i].Name);
- }
+ if (Bits[i] && !FeatureInfos[i].getName(NeedPlus).empty())
+ EnabledFeatures.push_back(FeatureInfos[i].getName(NeedPlus));
}
// For each feature that is (transitively) implied by this feature, set it.
@@ -668,8 +667,9 @@
void llvm::X86::updateImpliedFeatures(
StringRef Feature, bool Enabled,
StringMap<bool> &Features) {
- auto I = llvm::find_if(
- FeatureInfos, [&](const FeatureInfo &FI) { return FI.Name == Feature; });
+ auto I = llvm::find_if(FeatureInfos, [&](const FeatureInfo &FI) {
+ return FI.getName() == Feature;
+ });
if (I == std::end(FeatureInfos)) {
// FIXME: This shouldn't happen, but may not have all features in the table
// yet.
@@ -685,8 +685,8 @@
// 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;
+ if (ImpliedBits[i] && !FeatureInfos[i].getName().empty())
+ Features[FeatureInfos[i].getName()] = Enabled;
}
char llvm::X86::getCPUDispatchMangling(StringRef CPU) {
Index: llvm/include/llvm/TargetParser/X86TargetParser.h
===================================================================
--- llvm/include/llvm/TargetParser/X86TargetParser.h
+++ llvm/include/llvm/TargetParser/X86TargetParser.h
@@ -164,9 +164,9 @@
ProcessorFeatures getKeyFeature(CPUKind Kind);
/// Fill in the features that \p CPU supports into \p Features.
-/// "+" will be append in front of each feature if IfNeedPlus is true.
+/// "+" will be append in front of each feature if NeedPlus is true.
void getFeaturesForCPU(StringRef CPU, SmallVectorImpl<StringRef> &Features,
- bool IfNeedPlus = false);
+ bool NeedPlus = false);
/// Set or clear entries in \p Features that are implied to be enabled/disabled
/// by the provided \p Feature.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158814.553840.patch
Type: text/x-patch
Size: 3765 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230828/40202099/attachment.bin>
More information about the llvm-commits
mailing list