Remove a linear walk to find the default FPU for a given CPU by directly

expanding the .def file within a StringSwitch.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@246377 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chandler Carruth 2015-08-30 09:01:38 +00:00
parent 16c92083ab
commit 2ff230d5c9

View File

@ -110,13 +110,12 @@ struct {
const char *NameCStr;
size_t NameLength;
ARM::ArchKind ArchID;
ARM::FPUKind DefaultFPU;
bool Default; // is $Name the default CPU for $ArchID ?
StringRef getName() const { return StringRef(NameCStr, NameLength); }
} CPUNames[] = {
#define ARM_CPU_NAME(NAME, ID, DEFAULT_FPU, IS_DEFAULT) \
{ NAME, sizeof(NAME) - 1, ID, DEFAULT_FPU, IS_DEFAULT },
{ NAME, sizeof(NAME) - 1, ID, IS_DEFAULT },
#include "llvm/Support/ARMTargetParser.def"
};
@ -151,11 +150,11 @@ unsigned llvm::ARM::getFPURestriction(unsigned FPUKind) {
}
unsigned llvm::ARM::getDefaultFPU(StringRef CPU) {
for (const auto C : CPUNames) {
if (CPU == C.getName())
return C.DefaultFPU;
}
return ARM::FK_INVALID;
return StringSwitch<unsigned>(CPU)
#define ARM_CPU_NAME(NAME, ID, DEFAULT_FPU, IS_DEFAULT) \
.Case(NAME, DEFAULT_FPU)
#include "llvm/Support/ARMTargetParser.def"
.Default(ARM::FK_INVALID);
}
bool llvm::ARM::getHWDivFeatures(unsigned HWDivKind,