[SystemZ] Automatically detect zEC12 and z196 hosts
[oota-llvm.git] / lib / Target / SystemZ / SystemZSubtarget.cpp
index b6a63923cf5c863bf65ce686a8843a292c2df89c..474192099f22fc6120e2d8d3b9ef36d9643a8b10 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "SystemZSubtarget.h"
 #include "llvm/IR/GlobalValue.h"
+#include "llvm/Support/Host.h"
 #include "MCTargetDesc/SystemZMCTargetDesc.h"
 
 #define GET_SUBTARGETINFO_TARGET_DESC
@@ -25,7 +26,11 @@ SystemZSubtarget::SystemZSubtarget(const std::string &TT,
     TargetTriple(TT) {
   std::string CPUName = CPU;
   if (CPUName.empty())
-    CPUName = "z10";
+    CPUName = "generic";
+#if defined(__linux__) && defined(__s390x__)
+  if (CPUName == "generic")
+    CPUName = sys::getHostCPUName();
+#endif
 
   // Parse features string.
   ParseSubtargetFeatures(CPUName, FS);