[llvm] r246377 - Remove a linear walk to find the default FPU for a given CPU by directly

Chandler Carruth via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 30 02:01:38 PDT 2015


Author: chandlerc
Date: Sun Aug 30 04:01:38 2015
New Revision: 246377

URL: http://llvm.org/viewvc/llvm-project?rev=246377&view=rev
Log:
Remove a linear walk to find the default FPU for a given CPU by directly
expanding the .def file within a StringSwitch.

Modified:
    llvm/trunk/lib/Support/TargetParser.cpp

Modified: llvm/trunk/lib/Support/TargetParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/TargetParser.cpp?rev=246377&r1=246376&r2=246377&view=diff
==============================================================================
--- llvm/trunk/lib/Support/TargetParser.cpp (original)
+++ llvm/trunk/lib/Support/TargetParser.cpp Sun Aug 30 04:01:38 2015
@@ -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(un
 }
 
 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,




More information about the llvm-commits mailing list