forked from OSchip/llvm-project
[X86] Merge X86TargetInfo::setFeatureEnabled and X86TargetInfo::setFeatureEnabledImpl. NFC
setFeatureEnabled is a virtual function. setFeatureEnabledImpl was its implementation. This split was to avoid virtual calls when we need to call setFeatureEnabled in initFeatureMap. With C++11 we can use 'final' on setFeatureEnabled to enable the compiler to perform de-virtualization for the initFeatureMap calls.
This commit is contained in:
parent
560292fa99
commit
3cbfe988bc
|
@ -108,14 +108,14 @@ bool X86TargetInfo::initFeatureMap(
|
|||
// FIXME: This *really* should not be here.
|
||||
// X86_64 always has SSE2.
|
||||
if (getTriple().getArch() == llvm::Triple::x86_64)
|
||||
setFeatureEnabledImpl(Features, "sse2", true);
|
||||
setFeatureEnabled(Features, "sse2", true);
|
||||
|
||||
using namespace llvm::X86;
|
||||
|
||||
SmallVector<StringRef, 16> CPUFeatures;
|
||||
getFeaturesForCPU(CPU, CPUFeatures);
|
||||
for (auto &F : CPUFeatures)
|
||||
setFeatureEnabledImpl(Features, F, true);
|
||||
setFeatureEnabled(Features, F, true);
|
||||
|
||||
if (!TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec))
|
||||
return false;
|
||||
|
@ -145,8 +145,8 @@ bool X86TargetInfo::initFeatureMap(
|
|||
return true;
|
||||
}
|
||||
|
||||
void X86TargetInfo::setFeatureEnabledImpl(llvm::StringMap<bool> &Features,
|
||||
StringRef Name, bool Enabled) {
|
||||
void X86TargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features,
|
||||
StringRef Name, bool Enabled) const {
|
||||
if (Name == "sse4") {
|
||||
// We can get here via the __target__ attribute since that's not controlled
|
||||
// via the -msse4/-mno-sse4 command line alias. Handle this the same way
|
||||
|
|
|
@ -263,14 +263,7 @@ public:
|
|||
MacroBuilder &Builder) const override;
|
||||
|
||||
void setFeatureEnabled(llvm::StringMap<bool> &Features, StringRef Name,
|
||||
bool Enabled) const override {
|
||||
setFeatureEnabledImpl(Features, Name, Enabled);
|
||||
}
|
||||
|
||||
// This exists purely to cut down on the number of virtual calls in
|
||||
// initFeatureMap which calls this repeatedly.
|
||||
static void setFeatureEnabledImpl(llvm::StringMap<bool> &Features,
|
||||
StringRef Name, bool Enabled);
|
||||
bool Enabled) const final;
|
||||
|
||||
bool
|
||||
initFeatureMap(llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags,
|
||||
|
@ -279,7 +272,7 @@ public:
|
|||
|
||||
bool isValidFeatureName(StringRef Name) const override;
|
||||
|
||||
bool hasFeature(StringRef Feature) const override;
|
||||
bool hasFeature(StringRef Feature) const final;
|
||||
|
||||
bool handleTargetFeatures(std::vector<std::string> &Features,
|
||||
DiagnosticsEngine &Diags) override;
|
||||
|
|
Loading…
Reference in New Issue