From 48669bd8a2fb19076915918f9eddca6bb4302031 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Sun, 30 Aug 2015 09:01:38 +0000 Subject: [PATCH] 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 --- lib/Support/TargetParser.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/Support/TargetParser.cpp b/lib/Support/TargetParser.cpp index 3280035dca9..4f5d9acba51 100644 --- a/lib/Support/TargetParser.cpp +++ b/lib/Support/TargetParser.cpp @@ -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(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,