r316338 - Pull X86 "CPUKind" checking into .cpp file. [NFC]

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 23 09:20:15 PDT 2017


Author: erichkeane
Date: Mon Oct 23 09:20:15 2017
New Revision: 316338

URL: http://llvm.org/viewvc/llvm-project?rev=316338&view=rev
Log:
Pull X86 "CPUKind" checking into .cpp file. [NFC]

Preparing to do a refactor of CPU/feature checking, this
patch pulls the one CPU implementation from the .h file
to the .cpp file.

Modified:
    cfe/trunk/lib/Basic/Targets/X86.cpp
    cfe/trunk/lib/Basic/Targets/X86.h

Modified: cfe/trunk/lib/Basic/Targets/X86.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.cpp?rev=316338&r1=316337&r2=316338&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets/X86.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/X86.cpp Mon Oct 23 09:20:15 2017
@@ -1522,6 +1522,78 @@ std::string X86TargetInfo::convertConstr
   }
 }
 
+bool X86TargetInfo::checkCPUKind(CPUKind Kind) const {
+  // Perform any per-CPU checks necessary to determine if this CPU is
+  // acceptable.
+  // FIXME: This results in terrible diagnostics. Clang just says the CPU is
+  // invalid without explaining *why*.
+  switch (Kind) {
+  case CK_Generic:
+    // No processor selected!
+    return false;
+
+  case CK_i386:
+  case CK_i486:
+  case CK_WinChipC6:
+  case CK_WinChip2:
+  case CK_C3:
+  case CK_i586:
+  case CK_Pentium:
+  case CK_PentiumMMX:
+  case CK_i686:
+  case CK_PentiumPro:
+  case CK_Pentium2:
+  case CK_Pentium3:
+  case CK_PentiumM:
+  case CK_Yonah:
+  case CK_C3_2:
+  case CK_Pentium4:
+  case CK_Lakemont:
+  case CK_Prescott:
+  case CK_K6:
+  case CK_K6_2:
+  case CK_K6_3:
+  case CK_Athlon:
+  case CK_AthlonXP:
+  case CK_Geode:
+    // Only accept certain architectures when compiling in 32-bit mode.
+    if (getTriple().getArch() != llvm::Triple::x86)
+      return false;
+
+    LLVM_FALLTHROUGH;
+  case CK_Nocona:
+  case CK_Core2:
+  case CK_Penryn:
+  case CK_Bonnell:
+  case CK_Silvermont:
+  case CK_Goldmont:
+  case CK_Nehalem:
+  case CK_Westmere:
+  case CK_SandyBridge:
+  case CK_IvyBridge:
+  case CK_Haswell:
+  case CK_Broadwell:
+  case CK_SkylakeClient:
+  case CK_SkylakeServer:
+  case CK_Cannonlake:
+  case CK_KNL:
+  case CK_KNM:
+  case CK_K8:
+  case CK_K8SSE3:
+  case CK_AMDFAM10:
+  case CK_BTVER1:
+  case CK_BTVER2:
+  case CK_BDVER1:
+  case CK_BDVER2:
+  case CK_BDVER3:
+  case CK_BDVER4:
+  case CK_ZNVER1:
+  case CK_x86_64:
+    return true;
+  }
+  llvm_unreachable("Unhandled CPU kind");
+}
+
 X86TargetInfo::CPUKind X86TargetInfo::getCPUKind(StringRef CPU) const {
   return llvm::StringSwitch<CPUKind>(CPU)
       .Case("i386", CK_i386)

Modified: cfe/trunk/lib/Basic/Targets/X86.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.h?rev=316338&r1=316337&r2=316338&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets/X86.h (original)
+++ cfe/trunk/lib/Basic/Targets/X86.h Mon Oct 23 09:20:15 2017
@@ -270,77 +270,7 @@ class LLVM_LIBRARY_VISIBILITY X86TargetI
     //@}
   } CPU = CK_Generic;
 
-  bool checkCPUKind(CPUKind Kind) const {
-    // Perform any per-CPU checks necessary to determine if this CPU is
-    // acceptable.
-    // FIXME: This results in terrible diagnostics. Clang just says the CPU is
-    // invalid without explaining *why*.
-    switch (Kind) {
-    case CK_Generic:
-      // No processor selected!
-      return false;
-
-    case CK_i386:
-    case CK_i486:
-    case CK_WinChipC6:
-    case CK_WinChip2:
-    case CK_C3:
-    case CK_i586:
-    case CK_Pentium:
-    case CK_PentiumMMX:
-    case CK_i686:
-    case CK_PentiumPro:
-    case CK_Pentium2:
-    case CK_Pentium3:
-    case CK_PentiumM:
-    case CK_Yonah:
-    case CK_C3_2:
-    case CK_Pentium4:
-    case CK_Lakemont:
-    case CK_Prescott:
-    case CK_K6:
-    case CK_K6_2:
-    case CK_K6_3:
-    case CK_Athlon:
-    case CK_AthlonXP:
-    case CK_Geode:
-      // Only accept certain architectures when compiling in 32-bit mode.
-      if (getTriple().getArch() != llvm::Triple::x86)
-        return false;
-
-      LLVM_FALLTHROUGH;
-    case CK_Nocona:
-    case CK_Core2:
-    case CK_Penryn:
-    case CK_Bonnell:
-    case CK_Silvermont:
-    case CK_Goldmont:
-    case CK_Nehalem:
-    case CK_Westmere:
-    case CK_SandyBridge:
-    case CK_IvyBridge:
-    case CK_Haswell:
-    case CK_Broadwell:
-    case CK_SkylakeClient:
-    case CK_SkylakeServer:
-    case CK_Cannonlake:
-    case CK_KNL:
-    case CK_KNM:
-    case CK_K8:
-    case CK_K8SSE3:
-    case CK_AMDFAM10:
-    case CK_BTVER1:
-    case CK_BTVER2:
-    case CK_BDVER1:
-    case CK_BDVER2:
-    case CK_BDVER3:
-    case CK_BDVER4:
-    case CK_ZNVER1:
-    case CK_x86_64:
-      return true;
-    }
-    llvm_unreachable("Unhandled CPU kind");
-  }
+  bool checkCPUKind(CPUKind Kind) const;
 
   CPUKind getCPUKind(StringRef CPU) const;
 




More information about the cfe-commits mailing list