Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 8 additions & 15 deletions llvm/lib/TargetParser/Host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//

#include "llvm/TargetParser/Host.h"
#include "llvm/ADT/Bitfields.h"
#include "llvm/ADT/STLFunctionalExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
Expand Down Expand Up @@ -434,22 +435,14 @@ StringRef sys::detail::getHostCPUNameForARM(StringRef ProcCpuinfoContent) {
StringRef sys::detail::getHostCPUNameForARM(uint64_t PrimaryCpuInfo,
ArrayRef<uint64_t> UniqueCpuInfos) {
// On Windows, the registry provides cached copied of the MIDR_EL1 register.
union MIDR_EL1 {
uint64_t Raw;
struct _Components {
uint64_t Revision : 4;
uint64_t Partnum : 12;
uint64_t Architecture : 4;
uint64_t Variant : 4;
uint64_t Implementer : 8;
uint64_t Reserved : 32;
} Components;
};
using PartNum = Bitfield::Element<uint16_t, 4, 12>;
using Implementer = Bitfield::Element<uint16_t, 24, 8>;
using Variant = Bitfield::Element<uint16_t, 20, 4>;

SmallVector<std::string> PartsHolder;
PartsHolder.reserve(UniqueCpuInfos.size());
for (auto Info : UniqueCpuInfos)
PartsHolder.push_back("0x" + utohexstr(MIDR_EL1{Info}.Components.Partnum,
PartsHolder.push_back("0x" + utohexstr(Bitfield::get<PartNum>(Info),
/*LowerCase*/ true,
/*Width*/ 3));

Expand All @@ -459,14 +452,14 @@ StringRef sys::detail::getHostCPUNameForARM(uint64_t PrimaryCpuInfo,
Parts.push_back(Part);

return getHostCPUNameForARMFromComponents(
"0x" + utohexstr(MIDR_EL1{PrimaryCpuInfo}.Components.Implementer,
"0x" + utohexstr(Bitfield::get<Implementer>(PrimaryCpuInfo),
/*LowerCase*/ true,
/*Width*/ 2),
/*Hardware*/ "",
"0x" + utohexstr(MIDR_EL1{PrimaryCpuInfo}.Components.Partnum,
"0x" + utohexstr(Bitfield::get<PartNum>(PrimaryCpuInfo),
/*LowerCase*/ true,
/*Width*/ 3),
Parts, [=]() { return MIDR_EL1{PrimaryCpuInfo}.Components.Variant; });
Parts, [=]() { return Bitfield::get<Variant>(PrimaryCpuInfo); });
}

namespace {
Expand Down