1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00

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

expanding the .def file within a StringSwitch.

llvm-svn: 246377
This commit is contained in:
Chandler Carruth 2015-08-30 09:01:38 +00:00
parent e59e834a2a
commit 48669bd8a2

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,