From 2ff230d5c9658b0f1e6f789344e4d2cffc03b51e 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@246377 91177308-0d34-0410-b5e6-96231b3b80d8 --- 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,