From cc0ddc707d5a7b1dd11141881df0bf4210f8aeee Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Fri, 8 Jul 2011 21:14:14 +0000 Subject: [PATCH] For non-x86 host, used generic as CPU name. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134741 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp | 7 ++++++- lib/Target/X86/X86Subtarget.cpp | 15 ++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp b/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp index bcde60a0532..204485d94fa 100644 --- a/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp +++ b/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp @@ -140,8 +140,13 @@ MCSubtargetInfo *X86_MC::createX86MCSubtargetInfo(StringRef TT, StringRef CPU, } std::string CPUName = CPU; - if (CPUName.empty()) + if (CPUName.empty()) { +#if defined (__x86_64__) || defined(__i386__) CPUName = sys::getHostCPUName(); +#else + CPUName = "generic"; +#endif + } if (ArchFS.empty() && CPUName.empty() && hasX86_64()) // Auto-detect if host is 64-bit capable, it's the default if true. diff --git a/lib/Target/X86/X86Subtarget.cpp b/lib/Target/X86/X86Subtarget.cpp index b567c456b8f..fea4782c57e 100644 --- a/lib/Target/X86/X86Subtarget.cpp +++ b/lib/Target/X86/X86Subtarget.cpp @@ -258,12 +258,17 @@ X86Subtarget::X86Subtarget(const std::string &TT, const std::string &CPU, ArchFS = FS; } - std::string CPUName = CPU; - if (CPUName.empty()) - CPUName = sys::getHostCPUName(); - // Determine default and user specified characteristics - if (!CPUName.empty() || !ArchFS.empty()) { + if (!ArchFS.empty()) { + std::string CPUName = CPU; + if (CPUName.empty()) { +#if defined (__x86_64__) || defined(__i386__) + CPUName = sys::getHostCPUName(); +#else + CPUName = "generic"; +#endif + } + // If feature string is not empty, parse features string. ParseSubtargetFeatures(CPUName, ArchFS); // All X86-64 CPUs also have SSE2, however user might request no SSE via