mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-01 01:30:36 +00:00
Define getHostCPUFeatures for ARM Linux platform
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170085 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c567b1cd0d
commit
fde71f4f25
@ -517,6 +517,64 @@ std::string sys::getHostCPUName() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__linux__) && defined(__arm__)
|
||||||
|
bool sys::getHostCPUFeatures(StringMap<bool> &Features) {
|
||||||
|
std::string Err;
|
||||||
|
DataStreamer *DS = getDataFileStreamer("/proc/cpuinfo", &Err);
|
||||||
|
if (!DS) {
|
||||||
|
DEBUG(dbgs() << "Unable to open /proc/cpuinfo: " << Err << "\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read 1024 bytes from /proc/cpuinfo, which should contain the Features line
|
||||||
|
// in all cases.
|
||||||
|
char buffer[1024];
|
||||||
|
size_t CPUInfoSize = DS->GetBytes((unsigned char*) buffer, sizeof(buffer));
|
||||||
|
delete DS;
|
||||||
|
|
||||||
|
StringRef Str(buffer, CPUInfoSize);
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#else
|
||||||
bool sys::getHostCPUFeatures(StringMap<bool> &Features){
|
bool sys::getHostCPUFeatures(StringMap<bool> &Features){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user