diff options
| author | Tobias Grosser <grosser@fim.uni-passau.de> | 2013-06-11 21:45:01 +0000 |
|---|---|---|
| committer | Tobias Grosser <grosser@fim.uni-passau.de> | 2013-06-11 21:45:01 +0000 |
| commit | bd9e549e218c1d47d3c7e44f668eae26418774bc (patch) | |
| tree | 08b8f334a2ce14c9571a36d8a48635c6c6cb1a24 | |
| parent | dd76f067f79320fbd7e0fa49762036fa93b724c4 (diff) | |
| download | bcm5719-llvm-bd9e549e218c1d47d3c7e44f668eae26418774bc.tar.gz bcm5719-llvm-bd9e549e218c1d47d3c7e44f668eae26418774bc.zip | |
Make host ARM CPU feature detection independent of the vendor
For ARM on linux we use /proc/cpuinfo to detect the host CPU's features.
Linux derives these values without ever looking at the vendor of the
specific CPU implementation. Hence, it adds little value, if we parse
the output of /proc/cpuinfo only for certain vendors.
This patch enables us to derive the correct feature flags e.g. for Qualcomm
CPUs.
llvm-svn: 183790
| -rw-r--r-- | llvm/lib/Support/Host.cpp | 50 |
1 files changed, 20 insertions, 30 deletions
diff --git a/llvm/lib/Support/Host.cpp b/llvm/lib/Support/Host.cpp index a7c7a958005..20942a56bbc 100644 --- a/llvm/lib/Support/Host.cpp +++ b/llvm/lib/Support/Host.cpp @@ -570,41 +570,31 @@ bool sys::getHostCPUFeatures(StringMap<bool> &Features) { SmallVector<StringRef, 32> Lines; Str.split(Lines, "\n"); - // Look for the CPU implementer line. - StringRef Implementer; - for (unsigned I = 0, E = Lines.size(); I != E; ++I) - if (Lines[I].startswith("CPU implementer")) - Implementer = Lines[I].substr(15).ltrim("\t :"); - - if (Implementer == "0x41") { // ARM Ltd. - SmallVector<StringRef, 32> CPUFeatures; + SmallVector<StringRef, 32> CPUFeatures; - // Look for the CPU features. - for (unsigned I = 0, E = Lines.size(); I != E; ++I) - if (Lines[I].startswith("Features")) { - Lines[I].split(CPUFeatures, " "); - break; - } - - for (unsigned I = 0, E = CPUFeatures.size(); I != E; ++I) { - StringRef LLVMFeatureStr = StringSwitch<StringRef>(CPUFeatures[I]) - .Case("half", "fp16") - .Case("neon", "neon") - .Case("vfpv3", "vfp3") - .Case("vfpv3d16", "d16") - .Case("vfpv4", "vfp4") - .Case("idiva", "hwdiv-arm") - .Case("idivt", "hwdiv") - .Default(""); - - if (LLVMFeatureStr != "") - Features.GetOrCreateValue(LLVMFeatureStr).setValue(true); + // Look for the CPU features. + for (unsigned I = 0, E = Lines.size(); I != E; ++I) + if (Lines[I].startswith("Features")) { + Lines[I].split(CPUFeatures, " "); + break; } - return true; + for (unsigned I = 0, E = CPUFeatures.size(); I != E; ++I) { + StringRef LLVMFeatureStr = StringSwitch<StringRef>(CPUFeatures[I]) + .Case("half", "fp16") + .Case("neon", "neon") + .Case("vfpv3", "vfp3") + .Case("vfpv3d16", "d16") + .Case("vfpv4", "vfp4") + .Case("idiva", "hwdiv-arm") + .Case("idivt", "hwdiv") + .Default(""); + + if (LLVMFeatureStr != "") + Features.GetOrCreateValue(LLVMFeatureStr).setValue(true); } - return false; + return true; } #else bool sys::getHostCPUFeatures(StringMap<bool> &Features){ |

