21#include "llvm/Config/llvm-config.h"
44#include <mach/host_info.h>
46#include <mach/mach_host.h>
47#include <mach/machine.h>
49#include <sys/sysctl.h>
52#include <sys/systemcfg.h>
54#if defined(__sun__) && defined(__svr4__)
57#if defined(__GNUC__) || defined(__clang__)
58#if (defined(__i386__) || defined(__x86_64__)) && !defined(_MSC_VER)
63#define DEBUG_TYPE "host-detection"
73[[maybe_unused]]
static std::unique_ptr<llvm::MemoryBuffer>
75 const char *CPUInfoFile =
"/proc/cpuinfo";
76 if (
const char *CpuinfoIntercept = std::getenv(
"LLVM_CPUINFO"))
77 CPUInfoFile = CpuinfoIntercept;
81 if (std::error_code EC = Text.getError()) {
82 llvm::errs() <<
"Can't read " << CPUInfoFile <<
": " << EC.message()
86 return std::move(*Text);
93 const char *
generic =
"generic";
107 while (CIP < CPUInfoEnd && CPUStart ==
nullptr) {
108 if (CIP < CPUInfoEnd && *CIP ==
'\n')
111 if (CIP < CPUInfoEnd && *CIP ==
'c') {
113 if (CIP < CPUInfoEnd && *CIP ==
'p') {
115 if (CIP < CPUInfoEnd && *CIP ==
'u') {
117 while (CIP < CPUInfoEnd && (*CIP ==
' ' || *CIP ==
'\t'))
120 if (CIP < CPUInfoEnd && *CIP ==
':') {
122 while (CIP < CPUInfoEnd && (*CIP ==
' ' || *CIP ==
'\t'))
125 if (CIP < CPUInfoEnd) {
127 while (CIP < CPUInfoEnd && (*CIP !=
' ' && *CIP !=
'\t' &&
128 *CIP !=
',' && *CIP !=
'\n'))
130 CPULen = CIP - CPUStart;
137 if (CPUStart ==
nullptr)
138 while (CIP < CPUInfoEnd && *CIP !=
'\n')
142 if (CPUStart ==
nullptr)
146 .
Case(
"604e",
"604e")
148 .
Case(
"7400",
"7400")
149 .
Case(
"7410",
"7400")
150 .
Case(
"7447",
"7400")
151 .
Case(
"7455",
"7450")
153 .
Case(
"POWER4",
"970")
154 .
Case(
"PPC970FX",
"970")
155 .
Case(
"PPC970MP",
"970")
157 .
Case(
"POWER5",
"g5")
159 .
Case(
"POWER6",
"pwr6")
160 .
Case(
"POWER7",
"pwr7")
161 .
Case(
"POWER8",
"pwr8")
162 .
Case(
"POWER8E",
"pwr8")
163 .
Case(
"POWER8NVL",
"pwr8")
164 .
Case(
"POWER9",
"pwr9")
165 .
Case(
"POWER10",
"pwr10")
166 .
Case(
"POWER11",
"pwr11")
179 if (Parts.
size() == 2)
180 return (Parts[0] == Big && Parts[1] == Little) ||
181 (Parts[1] == Big && Parts[0] == Little);
185 if (Implementer ==
"0x41") {
192 if (MatchBigLittle(Parts,
"0xd85",
"0xd87"))
193 return "cortex-x925";
201 .
Case(
"0x926",
"arm926ej-s")
202 .
Case(
"0xb02",
"mpcore")
203 .
Case(
"0xb36",
"arm1136j-s")
204 .
Case(
"0xb56",
"arm1156t2-s")
205 .
Case(
"0xb76",
"arm1176jz-s")
206 .
Case(
"0xc05",
"cortex-a5")
207 .
Case(
"0xc07",
"cortex-a7")
208 .
Case(
"0xc08",
"cortex-a8")
209 .
Case(
"0xc09",
"cortex-a9")
210 .
Case(
"0xc0f",
"cortex-a15")
211 .
Case(
"0xc0e",
"cortex-a17")
212 .
Case(
"0xc20",
"cortex-m0")
213 .
Case(
"0xc23",
"cortex-m3")
214 .
Case(
"0xc24",
"cortex-m4")
215 .
Case(
"0xc27",
"cortex-m7")
216 .
Case(
"0xd20",
"cortex-m23")
217 .
Case(
"0xd21",
"cortex-m33")
218 .
Case(
"0xd24",
"cortex-m52")
219 .
Case(
"0xd22",
"cortex-m55")
220 .
Case(
"0xd23",
"cortex-m85")
221 .
Case(
"0xc18",
"cortex-r8")
222 .
Case(
"0xd13",
"cortex-r52")
223 .
Case(
"0xd16",
"cortex-r52plus")
224 .
Case(
"0xd15",
"cortex-r82")
225 .
Case(
"0xd14",
"cortex-r82ae")
226 .
Case(
"0xd02",
"cortex-a34")
227 .
Case(
"0xd04",
"cortex-a35")
228 .
Case(
"0xd8f",
"cortex-a320")
229 .
Case(
"0xd03",
"cortex-a53")
230 .
Case(
"0xd05",
"cortex-a55")
231 .
Case(
"0xd46",
"cortex-a510")
232 .
Case(
"0xd80",
"cortex-a520")
233 .
Case(
"0xd88",
"cortex-a520ae")
234 .
Case(
"0xd07",
"cortex-a57")
235 .
Case(
"0xd06",
"cortex-a65")
236 .
Case(
"0xd43",
"cortex-a65ae")
237 .
Case(
"0xd08",
"cortex-a72")
238 .
Case(
"0xd09",
"cortex-a73")
239 .
Case(
"0xd0a",
"cortex-a75")
240 .
Case(
"0xd0b",
"cortex-a76")
241 .
Case(
"0xd0e",
"cortex-a76ae")
242 .
Case(
"0xd0d",
"cortex-a77")
243 .
Case(
"0xd41",
"cortex-a78")
244 .
Case(
"0xd42",
"cortex-a78ae")
245 .
Case(
"0xd4b",
"cortex-a78c")
246 .
Case(
"0xd47",
"cortex-a710")
247 .
Case(
"0xd4d",
"cortex-a715")
248 .
Case(
"0xd81",
"cortex-a720")
249 .
Case(
"0xd89",
"cortex-a720ae")
250 .
Case(
"0xd87",
"cortex-a725")
251 .
Case(
"0xd44",
"cortex-x1")
252 .
Case(
"0xd4c",
"cortex-x1c")
253 .
Case(
"0xd48",
"cortex-x2")
254 .
Case(
"0xd4e",
"cortex-x3")
255 .
Case(
"0xd82",
"cortex-x4")
256 .
Case(
"0xd85",
"cortex-x925")
257 .
Case(
"0xd4a",
"neoverse-e1")
258 .
Case(
"0xd0c",
"neoverse-n1")
259 .
Case(
"0xd49",
"neoverse-n2")
260 .
Case(
"0xd8e",
"neoverse-n3")
261 .
Case(
"0xd40",
"neoverse-v1")
262 .
Case(
"0xd4f",
"neoverse-v2")
263 .
Case(
"0xd84",
"neoverse-v3")
264 .
Case(
"0xd83",
"neoverse-v3ae")
268 if (Implementer ==
"0x42" || Implementer ==
"0x43") {
270 .
Case(
"0x516",
"thunderx2t99")
271 .
Case(
"0x0516",
"thunderx2t99")
272 .
Case(
"0xaf",
"thunderx2t99")
273 .
Case(
"0x0af",
"thunderx2t99")
274 .
Case(
"0xa1",
"thunderxt88")
275 .
Case(
"0x0a1",
"thunderxt88")
279 if (Implementer ==
"0x46") {
281 .
Case(
"0x001",
"a64fx")
282 .
Case(
"0x003",
"fujitsu-monaka")
286 if (Implementer ==
"0x4e") {
288 .
Case(
"0x004",
"carmel")
289 .
Case(
"0x10",
"olympus")
290 .
Case(
"0x010",
"olympus")
294 if (Implementer ==
"0x48")
299 .
Case(
"0xd01",
"tsv110")
302 if (Implementer ==
"0x51")
307 .
Case(
"0x06f",
"krait")
308 .
Case(
"0x201",
"kryo")
309 .
Case(
"0x205",
"kryo")
310 .
Case(
"0x211",
"kryo")
311 .
Case(
"0x800",
"cortex-a73")
312 .
Case(
"0x801",
"cortex-a73")
313 .
Case(
"0x802",
"cortex-a75")
314 .
Case(
"0x803",
"cortex-a75")
315 .
Case(
"0x804",
"cortex-a76")
316 .
Case(
"0x805",
"cortex-a76")
317 .
Case(
"0xc00",
"falkor")
318 .
Case(
"0xc01",
"saphira")
319 .
Case(
"0x001",
"oryon-1")
321 if (Implementer ==
"0x53") {
327 unsigned Variant = GetVariant();
334 unsigned Exynos = (Variant << 12) | PartAsInt;
346 if (Implementer ==
"0x61") {
348 .
Case(
"0x020",
"apple-m1")
349 .
Case(
"0x021",
"apple-m1")
350 .
Case(
"0x022",
"apple-m1")
351 .
Case(
"0x023",
"apple-m1")
352 .
Case(
"0x024",
"apple-m1")
353 .
Case(
"0x025",
"apple-m1")
354 .
Case(
"0x028",
"apple-m1")
355 .
Case(
"0x029",
"apple-m1")
356 .
Case(
"0x030",
"apple-m2")
357 .
Case(
"0x031",
"apple-m2")
358 .
Case(
"0x032",
"apple-m2")
359 .
Case(
"0x033",
"apple-m2")
360 .
Case(
"0x034",
"apple-m2")
361 .
Case(
"0x035",
"apple-m2")
362 .
Case(
"0x038",
"apple-m2")
363 .
Case(
"0x039",
"apple-m2")
364 .
Case(
"0x049",
"apple-m3")
365 .
Case(
"0x048",
"apple-m3")
369 if (Implementer ==
"0x63") {
371 .
Case(
"0x132",
"star-mc1")
372 .
Case(
"0xd25",
"star-mc3")
376 if (Implementer ==
"0x6d") {
379 .
Case(
"0xd49",
"neoverse-n2")
383 if (Implementer ==
"0xc0") {
385 .
Case(
"0xac3",
"ampere1")
386 .
Case(
"0xac4",
"ampere1a")
387 .
Case(
"0xac5",
"ampere1b")
401 ProcCpuinfoContent.
split(Lines,
'\n');
409 if (Line.consume_front(
"CPU implementer"))
410 Implementer = Line.
ltrim(
"\t :");
411 else if (Line.consume_front(
"Hardware"))
412 Hardware = Line.
ltrim(
"\t :");
413 else if (Line.consume_front(
"CPU part"))
424 auto GetVariant = [&]() {
425 unsigned Variant = 0;
427 if (
I.consume_front(
"CPU variant"))
428 I.ltrim(
"\t :").getAsInteger(0, Variant);
445 for (
auto Info : UniqueCpuInfos)
452 for (
const auto &Part : PartsHolder)
467StringRef getCPUNameFromS390Model(
unsigned int Id,
bool HaveVectorSupport) {
487 return HaveVectorSupport?
"z13" :
"zEC12";
490 return HaveVectorSupport?
"z14" :
"zEC12";
493 return HaveVectorSupport?
"z15" :
"zEC12";
496 return HaveVectorSupport?
"z16" :
"zEC12";
500 return HaveVectorSupport?
"z17" :
"zEC12";
511 ProcCpuinfoContent.
split(Lines,
'\n');
515 for (
unsigned I = 0, E = Lines.size();
I != E; ++
I)
517 size_t Pos = Lines[
I].find(
':');
519 Lines[
I].drop_front(Pos + 1).split(CPUFeatures,
' ');
527 bool HaveVectorSupport =
false;
528 for (
unsigned I = 0, E = CPUFeatures.size();
I != E; ++
I) {
529 if (CPUFeatures[
I] ==
"vx")
530 HaveVectorSupport =
true;
534 for (
unsigned I = 0, E = Lines.size();
I != E; ++
I) {
536 size_t Pos = Lines[
I].find(
"machine = ");
538 Pos +=
sizeof(
"machine = ") - 1;
540 if (!Lines[
I].drop_front(Pos).getAsInteger(10, Id))
541 return getCPUNameFromS390Model(Id, HaveVectorSupport);
553 ProcCpuinfoContent.
split(Lines,
'\n');
557 for (
unsigned I = 0, E = Lines.size();
I != E; ++
I) {
559 UArch = Lines[
I].substr(5).ltrim(
"\t :");
565 .
Case(
"eswin,eic770x",
"sifive-p550")
566 .
Case(
"sifive,u74-mc",
"sifive-u74")
567 .
Case(
"sifive,bullet0",
"sifive-u74")
572#if !defined(__linux__) || !defined(__x86_64__)
575 uint8_t v3_insns[40] __attribute__ ((aligned (8))) =
577 { 0xb7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
579 0xb7, 0x2, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0,
581 0xae, 0x20, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0,
583 0xb7, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0,
585 0x95, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 };
587 uint8_t v2_insns[40] __attribute__ ((aligned (8))) =
589 { 0xb7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
591 0xb7, 0x2, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0,
593 0xad, 0x20, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0,
595 0xb7, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0,
597 0x95, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 };
599 struct bpf_prog_load_attr {
615 int fd = syscall(321 , 5 , &attr,
623 memset(&attr, 0,
sizeof(attr));
628 fd = syscall(321 , 5 , &attr,
sizeof(attr));
637#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || \
638 defined(_M_X64)) && \
643static bool getX86CpuIDAndInfo(
unsigned value,
unsigned *rEAX,
unsigned *rEBX,
644 unsigned *rECX,
unsigned *rEDX) {
645#if (defined(__i386__) || defined(__x86_64__)) && !defined(_MSC_VER)
646 return !__get_cpuid(value, rEAX, rEBX, rECX, rEDX);
647#elif defined(_MSC_VER)
650 __cpuid(registers, value);
651 *rEAX = registers[0];
652 *rEBX = registers[1];
653 *rECX = registers[2];
654 *rEDX = registers[3];
666VendorSignatures getVendorSignature(
unsigned *MaxLeaf) {
667 unsigned EAX = 0, EBX = 0, ECX = 0, EDX = 0;
668 if (MaxLeaf ==
nullptr)
673 if (getX86CpuIDAndInfo(0, MaxLeaf, &EBX, &ECX, &EDX) || *MaxLeaf < 1)
674 return VendorSignatures::UNKNOWN;
677 if (EBX == 0x756e6547 && EDX == 0x49656e69 && ECX == 0x6c65746e)
678 return VendorSignatures::GENUINE_INTEL;
681 if (EBX == 0x68747541 && EDX == 0x69746e65 && ECX == 0x444d4163)
682 return VendorSignatures::AUTHENTIC_AMD;
684 return VendorSignatures::UNKNOWN;
697static bool getX86CpuIDAndInfoEx(
unsigned value,
unsigned subleaf,
698 unsigned *rEAX,
unsigned *rEBX,
unsigned *rECX,
704#if (defined(__i386__) || defined(__x86_64__)) && !defined(_MSC_VER)
705 return !__get_cpuid_count(value, subleaf, rEAX, rEBX, rECX, rEDX);
706#elif defined(_MSC_VER)
708 __cpuidex(registers, value, subleaf);
709 *rEAX = registers[0];
710 *rEBX = registers[1];
711 *rECX = registers[2];
712 *rEDX = registers[3];
720static bool getX86XCR0(
unsigned *rEAX,
unsigned *rEDX) {
724#if defined(__GNUC__) || defined(__clang__)
728 __asm__(
".byte 0x0f, 0x01, 0xd0" :
"=a"(*rEAX),
"=d"(*rEDX) :
"c"(0));
730#elif defined(_MSC_FULL_VER) && defined(_XCR_XFEATURE_ENABLED_MASK)
731 unsigned long long Result = _xgetbv(_XCR_XFEATURE_ENABLED_MASK);
740static void detectX86FamilyModel(
unsigned EAX,
unsigned *Family,
742 *Family = (
EAX >> 8) & 0xf;
743 *Model = (
EAX >> 4) & 0xf;
744 if (*Family == 6 || *Family == 0xf) {
747 *Family += (
EAX >> 20) & 0xff;
749 *Model += ((
EAX >> 16) & 0xf) << 4;
753#define testFeature(F) (Features[F / 32] & (1 << (F % 32))) != 0
755static StringRef getIntelProcessorTypeAndSubtype(
unsigned Family,
757 const unsigned *Features,
770 if (testFeature(X86::FEATURE_MMX)) {
786 *
Type = X86::INTEL_CORE2;
795 *
Type = X86::INTEL_CORE2;
804 *
Type = X86::INTEL_COREI7;
805 *Subtype = X86::INTEL_COREI7_NEHALEM;
812 *
Type = X86::INTEL_COREI7;
813 *Subtype = X86::INTEL_COREI7_WESTMERE;
819 *
Type = X86::INTEL_COREI7;
820 *Subtype = X86::INTEL_COREI7_SANDYBRIDGE;
825 *
Type = X86::INTEL_COREI7;
826 *Subtype = X86::INTEL_COREI7_IVYBRIDGE;
835 *
Type = X86::INTEL_COREI7;
836 *Subtype = X86::INTEL_COREI7_HASWELL;
845 *
Type = X86::INTEL_COREI7;
846 *Subtype = X86::INTEL_COREI7_BROADWELL;
857 *
Type = X86::INTEL_COREI7;
858 *Subtype = X86::INTEL_COREI7_SKYLAKE;
864 *
Type = X86::INTEL_COREI7;
865 *Subtype = X86::INTEL_COREI7_ROCKETLAKE;
870 *
Type = X86::INTEL_COREI7;
871 if (testFeature(X86::FEATURE_AVX512BF16)) {
873 *Subtype = X86::INTEL_COREI7_COOPERLAKE;
874 }
else if (testFeature(X86::FEATURE_AVX512VNNI)) {
876 *Subtype = X86::INTEL_COREI7_CASCADELAKE;
878 CPU =
"skylake-avx512";
879 *Subtype = X86::INTEL_COREI7_SKYLAKE_AVX512;
886 *
Type = X86::INTEL_COREI7;
887 *Subtype = X86::INTEL_COREI7_CANNONLAKE;
893 CPU =
"icelake-client";
894 *
Type = X86::INTEL_COREI7;
895 *Subtype = X86::INTEL_COREI7_ICELAKE_CLIENT;
902 *
Type = X86::INTEL_COREI7;
903 *Subtype = X86::INTEL_COREI7_TIGERLAKE;
910 *
Type = X86::INTEL_COREI7;
911 *Subtype = X86::INTEL_COREI7_ALDERLAKE;
917 *
Type = X86::INTEL_COREI7;
918 *Subtype = X86::INTEL_COREI7_ALDERLAKE;
926 *
Type = X86::INTEL_COREI7;
927 *Subtype = X86::INTEL_COREI7_ALDERLAKE;
934 *
Type = X86::INTEL_COREI7;
935 *Subtype = X86::INTEL_COREI7_ALDERLAKE;
943 *
Type = X86::INTEL_COREI7;
944 *Subtype = X86::INTEL_COREI7_ARROWLAKE;
950 *
Type = X86::INTEL_COREI7;
951 *Subtype = X86::INTEL_COREI7_ARROWLAKE_S;
957 *
Type = X86::INTEL_COREI7;
958 *Subtype = X86::INTEL_COREI7_ARROWLAKE_S;
964 *
Type = X86::INTEL_COREI7;
965 *Subtype = X86::INTEL_COREI7_PANTHERLAKE;
971 *
Type = X86::INTEL_COREI7;
972 *Subtype = X86::INTEL_COREI7_PANTHERLAKE;
977 CPU =
"graniterapids";
978 *
Type = X86::INTEL_COREI7;
979 *Subtype = X86::INTEL_COREI7_GRANITERAPIDS;
984 CPU =
"graniterapids-d";
985 *
Type = X86::INTEL_COREI7;
986 *Subtype = X86::INTEL_COREI7_GRANITERAPIDS_D;
992 CPU =
"icelake-server";
993 *
Type = X86::INTEL_COREI7;
994 *Subtype = X86::INTEL_COREI7_ICELAKE_SERVER;
999 CPU =
"emeraldrapids";
1000 *
Type = X86::INTEL_COREI7;
1001 *Subtype = X86::INTEL_COREI7_SAPPHIRERAPIDS;
1006 CPU =
"sapphirerapids";
1007 *
Type = X86::INTEL_COREI7;
1008 *Subtype = X86::INTEL_COREI7_SAPPHIRERAPIDS;
1017 *
Type = X86::INTEL_BONNELL;
1028 *
Type = X86::INTEL_SILVERMONT;
1034 *
Type = X86::INTEL_GOLDMONT;
1037 CPU =
"goldmont-plus";
1038 *
Type = X86::INTEL_GOLDMONT_PLUS;
1045 *
Type = X86::INTEL_TREMONT;
1050 CPU =
"sierraforest";
1051 *
Type = X86::INTEL_SIERRAFOREST;
1057 *
Type = X86::INTEL_GRANDRIDGE;
1062 CPU =
"clearwaterforest";
1063 *
Type = X86::INTEL_CLEARWATERFOREST;
1069 *
Type = X86::INTEL_KNL;
1073 *
Type = X86::INTEL_KNM;
1080 if (testFeature(X86::FEATURE_AVX512VP2INTERSECT)) {
1082 }
else if (testFeature(X86::FEATURE_AVX512VBMI2)) {
1083 CPU =
"icelake-client";
1084 }
else if (testFeature(X86::FEATURE_AVX512VBMI)) {
1086 }
else if (testFeature(X86::FEATURE_AVX512BF16)) {
1088 }
else if (testFeature(X86::FEATURE_AVX512VNNI)) {
1089 CPU =
"cascadelake";
1090 }
else if (testFeature(X86::FEATURE_AVX512VL)) {
1091 CPU =
"skylake-avx512";
1092 }
else if (testFeature(X86::FEATURE_CLFLUSHOPT)) {
1093 if (testFeature(X86::FEATURE_SHA))
1097 }
else if (testFeature(X86::FEATURE_ADX)) {
1099 }
else if (testFeature(X86::FEATURE_AVX2)) {
1101 }
else if (testFeature(X86::FEATURE_AVX)) {
1102 CPU =
"sandybridge";
1103 }
else if (testFeature(X86::FEATURE_SSE4_2)) {
1104 if (testFeature(X86::FEATURE_MOVBE))
1108 }
else if (testFeature(X86::FEATURE_SSE4_1)) {
1110 }
else if (testFeature(X86::FEATURE_SSSE3)) {
1111 if (testFeature(X86::FEATURE_MOVBE))
1115 }
else if (testFeature(X86::FEATURE_64BIT)) {
1117 }
else if (testFeature(X86::FEATURE_SSE3)) {
1119 }
else if (testFeature(X86::FEATURE_SSE2)) {
1121 }
else if (testFeature(X86::FEATURE_SSE)) {
1123 }
else if (testFeature(X86::FEATURE_MMX)) {
1132 if (testFeature(X86::FEATURE_64BIT)) {
1136 if (testFeature(X86::FEATURE_SSE3)) {
1147 CPU =
"diamondrapids";
1148 *
Type = X86::INTEL_COREI7;
1149 *Subtype = X86::INTEL_COREI7_DIAMONDRAPIDS;
1162 *
Type = X86::INTEL_COREI7;
1163 *Subtype = X86::INTEL_COREI7_NOVALAKE;
1177static const char *getAMDProcessorTypeAndSubtype(
unsigned Family,
1179 const unsigned *Features,
1181 unsigned *Subtype) {
1182 const char *CPU =
nullptr;
1208 if (testFeature(X86::FEATURE_SSE)) {
1215 if (testFeature(X86::FEATURE_SSE3)) {
1224 *
Type = X86::AMDFAM10H;
1227 *Subtype = X86::AMDFAM10H_BARCELONA;
1230 *Subtype = X86::AMDFAM10H_SHANGHAI;
1233 *Subtype = X86::AMDFAM10H_ISTANBUL;
1239 *
Type = X86::AMD_BTVER1;
1243 *
Type = X86::AMDFAM15H;
1244 if (Model >= 0x60 && Model <= 0x7f) {
1246 *Subtype = X86::AMDFAM15H_BDVER4;
1249 if (Model >= 0x30 && Model <= 0x3f) {
1251 *Subtype = X86::AMDFAM15H_BDVER3;
1254 if ((Model >= 0x10 && Model <= 0x1f) || Model == 0x02) {
1256 *Subtype = X86::AMDFAM15H_BDVER2;
1259 if (Model <= 0x0f) {
1260 *Subtype = X86::AMDFAM15H_BDVER1;
1266 *
Type = X86::AMD_BTVER2;
1270 *
Type = X86::AMDFAM17H;
1271 if ((Model >= 0x30 && Model <= 0x3f) || (Model == 0x47) ||
1272 (Model >= 0x60 && Model <= 0x67) || (Model >= 0x68 && Model <= 0x6f) ||
1273 (Model >= 0x70 && Model <= 0x7f) || (Model >= 0x84 && Model <= 0x87) ||
1274 (Model >= 0x90 && Model <= 0x97) || (Model >= 0x98 && Model <= 0x9f) ||
1275 (Model >= 0xa0 && Model <= 0xaf)) {
1286 *Subtype = X86::AMDFAM17H_ZNVER2;
1289 if ((Model >= 0x10 && Model <= 0x1f) || (Model >= 0x20 && Model <= 0x2f)) {
1293 *Subtype = X86::AMDFAM17H_ZNVER1;
1299 *
Type = X86::AMDFAM19H;
1300 if (Model <= 0x0f || (Model >= 0x20 && Model <= 0x2f) ||
1301 (Model >= 0x30 && Model <= 0x3f) || (Model >= 0x40 && Model <= 0x4f) ||
1302 (Model >= 0x50 && Model <= 0x5f)) {
1308 *Subtype = X86::AMDFAM19H_ZNVER3;
1311 if ((Model >= 0x10 && Model <= 0x1f) || (Model >= 0x60 && Model <= 0x6f) ||
1312 (Model >= 0x70 && Model <= 0x77) || (Model >= 0x78 && Model <= 0x7f) ||
1313 (Model >= 0xa0 && Model <= 0xaf)) {
1320 *Subtype = X86::AMDFAM19H_ZNVER4;
1326 *
Type = X86::AMDFAM1AH;
1327 if (Model <= 0x4f || (Model >= 0x60 && Model <= 0x77) ||
1328 (Model >= 0xd0 && Model <= 0xd7)) {
1339 *Subtype = X86::AMDFAM1AH_ZNVER5;
1353static void getAvailableFeatures(
unsigned ECX,
unsigned EDX,
unsigned MaxLeaf,
1354 unsigned *Features) {
1357 auto setFeature = [&](
unsigned F) {
1358 Features[
F / 32] |= 1U << (
F % 32);
1361 if ((EDX >> 15) & 1)
1362 setFeature(X86::FEATURE_CMOV);
1363 if ((EDX >> 23) & 1)
1364 setFeature(X86::FEATURE_MMX);
1365 if ((EDX >> 25) & 1)
1366 setFeature(X86::FEATURE_SSE);
1367 if ((EDX >> 26) & 1)
1368 setFeature(X86::FEATURE_SSE2);
1371 setFeature(X86::FEATURE_SSE3);
1373 setFeature(X86::FEATURE_PCLMUL);
1375 setFeature(X86::FEATURE_SSSE3);
1376 if ((ECX >> 12) & 1)
1377 setFeature(X86::FEATURE_FMA);
1378 if ((ECX >> 19) & 1)
1379 setFeature(X86::FEATURE_SSE4_1);
1380 if ((ECX >> 20) & 1) {
1381 setFeature(X86::FEATURE_SSE4_2);
1382 setFeature(X86::FEATURE_CRC32);
1384 if ((ECX >> 23) & 1)
1385 setFeature(X86::FEATURE_POPCNT);
1386 if ((ECX >> 25) & 1)
1387 setFeature(X86::FEATURE_AES);
1389 if ((ECX >> 22) & 1)
1390 setFeature(X86::FEATURE_MOVBE);
1395 const unsigned AVXBits = (1 << 27) | (1 << 28);
1396 bool HasAVX = ((
ECX & AVXBits) == AVXBits) && !getX86XCR0(&EAX, &EDX) &&
1397 ((
EAX & 0x6) == 0x6);
1398#if defined(__APPLE__)
1402 bool HasAVX512Save =
true;
1405 bool HasAVX512Save = HasAVX && ((
EAX & 0xe0) == 0xe0);
1409 setFeature(X86::FEATURE_AVX);
1412 MaxLeaf >= 0x7 && !getX86CpuIDAndInfoEx(0x7, 0x0, &EAX, &EBX, &ECX, &EDX);
1414 if (HasLeaf7 && ((EBX >> 3) & 1))
1415 setFeature(X86::FEATURE_BMI);
1416 if (HasLeaf7 && ((EBX >> 5) & 1) && HasAVX)
1417 setFeature(X86::FEATURE_AVX2);
1418 if (HasLeaf7 && ((EBX >> 8) & 1))
1419 setFeature(X86::FEATURE_BMI2);
1420 if (HasLeaf7 && ((EBX >> 16) & 1) && HasAVX512Save) {
1421 setFeature(X86::FEATURE_AVX512F);
1423 if (HasLeaf7 && ((EBX >> 17) & 1) && HasAVX512Save)
1424 setFeature(X86::FEATURE_AVX512DQ);
1425 if (HasLeaf7 && ((EBX >> 19) & 1))
1426 setFeature(X86::FEATURE_ADX);
1427 if (HasLeaf7 && ((EBX >> 21) & 1) && HasAVX512Save)
1428 setFeature(X86::FEATURE_AVX512IFMA);
1429 if (HasLeaf7 && ((EBX >> 23) & 1))
1430 setFeature(X86::FEATURE_CLFLUSHOPT);
1431 if (HasLeaf7 && ((EBX >> 28) & 1) && HasAVX512Save)
1432 setFeature(X86::FEATURE_AVX512CD);
1433 if (HasLeaf7 && ((EBX >> 29) & 1))
1434 setFeature(X86::FEATURE_SHA);
1435 if (HasLeaf7 && ((EBX >> 30) & 1) && HasAVX512Save)
1436 setFeature(X86::FEATURE_AVX512BW);
1437 if (HasLeaf7 && ((EBX >> 31) & 1) && HasAVX512Save)
1438 setFeature(X86::FEATURE_AVX512VL);
1440 if (HasLeaf7 && ((ECX >> 1) & 1) && HasAVX512Save)
1441 setFeature(X86::FEATURE_AVX512VBMI);
1442 if (HasLeaf7 && ((ECX >> 6) & 1) && HasAVX512Save)
1443 setFeature(X86::FEATURE_AVX512VBMI2);
1444 if (HasLeaf7 && ((ECX >> 8) & 1))
1445 setFeature(X86::FEATURE_GFNI);
1446 if (HasLeaf7 && ((ECX >> 10) & 1) && HasAVX)
1447 setFeature(X86::FEATURE_VPCLMULQDQ);
1448 if (HasLeaf7 && ((ECX >> 11) & 1) && HasAVX512Save)
1449 setFeature(X86::FEATURE_AVX512VNNI);
1450 if (HasLeaf7 && ((ECX >> 12) & 1) && HasAVX512Save)
1451 setFeature(X86::FEATURE_AVX512BITALG);
1452 if (HasLeaf7 && ((ECX >> 14) & 1) && HasAVX512Save)
1453 setFeature(X86::FEATURE_AVX512VPOPCNTDQ);
1455 if (HasLeaf7 && ((EDX >> 2) & 1) && HasAVX512Save)
1456 setFeature(X86::FEATURE_AVX5124VNNIW);
1457 if (HasLeaf7 && ((EDX >> 3) & 1) && HasAVX512Save)
1458 setFeature(X86::FEATURE_AVX5124FMAPS);
1459 if (HasLeaf7 && ((EDX >> 8) & 1) && HasAVX512Save)
1460 setFeature(X86::FEATURE_AVX512VP2INTERSECT);
1464 bool HasLeaf7Subleaf1 =
1465 HasLeaf7 &&
EAX >= 1 &&
1466 !getX86CpuIDAndInfoEx(0x7, 0x1, &EAX, &EBX, &ECX, &EDX);
1467 if (HasLeaf7Subleaf1 && ((EAX >> 5) & 1) && HasAVX512Save)
1468 setFeature(X86::FEATURE_AVX512BF16);
1470 unsigned MaxExtLevel;
1471 getX86CpuIDAndInfo(0x80000000, &MaxExtLevel, &EBX, &ECX, &EDX);
1473 bool HasExtLeaf1 = MaxExtLevel >= 0x80000001 &&
1474 !getX86CpuIDAndInfo(0x80000001, &EAX, &EBX, &ECX, &EDX);
1475 if (HasExtLeaf1 && ((ECX >> 6) & 1))
1476 setFeature(X86::FEATURE_SSE4_A);
1477 if (HasExtLeaf1 && ((ECX >> 11) & 1))
1478 setFeature(X86::FEATURE_XOP);
1479 if (HasExtLeaf1 && ((ECX >> 16) & 1))
1480 setFeature(X86::FEATURE_FMA4);
1482 if (HasExtLeaf1 && ((EDX >> 29) & 1))
1483 setFeature(X86::FEATURE_64BIT);
1487 unsigned MaxLeaf = 0;
1493 getX86CpuIDAndInfo(0x1, &EAX, &EBX, &ECX, &EDX);
1495 unsigned Family = 0, Model = 0;
1497 detectX86FamilyModel(EAX, &Family, &Model);
1498 getAvailableFeatures(ECX, EDX, MaxLeaf, Features);
1503 unsigned Subtype = 0;
1508 CPU = getIntelProcessorTypeAndSubtype(Family, Model, Features, &
Type,
1511 CPU = getAMDProcessorTypeAndSubtype(Family, Model, Features, &
Type,
1521#elif defined(_M_ARM64) || defined(_M_ARM64EC)
1524 constexpr char CentralProcessorKeyName[] =
1525 "HARDWARE\\DESCRIPTION\\System\\CentralProcessor";
1528 constexpr size_t SubKeyNameMaxSize = ARRAYSIZE(CentralProcessorKeyName) + 10;
1532 char PrimaryPartKeyName[SubKeyNameMaxSize];
1533 DWORD PrimaryPartKeyNameSize = 0;
1534 HKEY CentralProcessorKey;
1535 if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, CentralProcessorKeyName, 0, KEY_READ,
1536 &CentralProcessorKey) == ERROR_SUCCESS) {
1537 for (
unsigned Index = 0; Index < UINT32_MAX; ++Index) {
1538 char SubKeyName[SubKeyNameMaxSize];
1539 DWORD SubKeySize = SubKeyNameMaxSize;
1541 if ((RegEnumKeyExA(CentralProcessorKey, Index, SubKeyName, &SubKeySize,
1542 nullptr,
nullptr,
nullptr,
1543 nullptr) == ERROR_SUCCESS) &&
1544 (RegOpenKeyExA(CentralProcessorKey, SubKeyName, 0, KEY_READ,
1545 &SubKey) == ERROR_SUCCESS)) {
1550 DWORD RegValueSize =
sizeof(RegValue);
1551 if ((RegQueryValueExA(SubKey,
"CP 4000",
nullptr, &ActualType,
1553 &RegValueSize) == ERROR_SUCCESS) &&
1554 (ActualType == REG_QWORD) && RegValueSize ==
sizeof(RegValue)) {
1559 if (PrimaryPartKeyNameSize < SubKeySize ||
1560 (PrimaryPartKeyNameSize == SubKeySize &&
1561 ::memcmp(SubKeyName, PrimaryPartKeyName, SubKeySize) > 0)) {
1562 PrimaryCpuInfo = RegValue;
1563 ::memcpy(PrimaryPartKeyName, SubKeyName, SubKeySize + 1);
1564 PrimaryPartKeyNameSize = SubKeySize;
1570 RegCloseKey(SubKey);
1576 RegCloseKey(CentralProcessorKey);
1579 if (Values.
empty()) {
1590#elif defined(__APPLE__) && defined(__powerpc__)
1592 host_basic_info_data_t hostInfo;
1593 mach_msg_type_number_t infoCount;
1595 infoCount = HOST_BASIC_INFO_COUNT;
1596 mach_port_t hostPort = mach_host_self();
1597 host_info(hostPort, HOST_BASIC_INFO, (host_info_t)&hostInfo,
1599 mach_port_deallocate(mach_task_self(), hostPort);
1601 if (hostInfo.cpu_type != CPU_TYPE_POWERPC)
1604 switch (hostInfo.cpu_subtype) {
1634#elif defined(__linux__) && defined(__powerpc__)
1640#elif defined(__linux__) && (defined(__arm__) || defined(__aarch64__))
1646#elif defined(__linux__) && defined(__s390x__)
1652#elif defined(__MVS__)
1657 int *StartToCVTOffset =
reinterpret_cast<int *
>(0x10);
1660 int ReadValue = *StartToCVTOffset;
1662 ReadValue = (ReadValue & 0x7FFFFFFF);
1663 char *CVT =
reinterpret_cast<char *
>(ReadValue);
1672 bool HaveVectorSupport = CVT[244] & 0x80;
1673 return getCPUNameFromS390Model(Id, HaveVectorSupport);
1675#elif defined(__APPLE__) && (defined(__arm__) || defined(__aarch64__))
1680#define CPUFAMILY_UNKNOWN 0
1681#define CPUFAMILY_ARM_9 0xe73283ae
1682#define CPUFAMILY_ARM_11 0x8ff620d8
1683#define CPUFAMILY_ARM_XSCALE 0x53b005f5
1684#define CPUFAMILY_ARM_12 0xbd1b0ae9
1685#define CPUFAMILY_ARM_13 0x0cc90e64
1686#define CPUFAMILY_ARM_14 0x96077ef1
1687#define CPUFAMILY_ARM_15 0xa8511bca
1688#define CPUFAMILY_ARM_SWIFT 0x1e2d6381
1689#define CPUFAMILY_ARM_CYCLONE 0x37a09642
1690#define CPUFAMILY_ARM_TYPHOON 0x2c91a47e
1691#define CPUFAMILY_ARM_TWISTER 0x92fb37c8
1692#define CPUFAMILY_ARM_HURRICANE 0x67ceee93
1693#define CPUFAMILY_ARM_MONSOON_MISTRAL 0xe81e7ef6
1694#define CPUFAMILY_ARM_VORTEX_TEMPEST 0x07d34b9f
1695#define CPUFAMILY_ARM_LIGHTNING_THUNDER 0x462504d2
1696#define CPUFAMILY_ARM_FIRESTORM_ICESTORM 0x1b588bb3
1697#define CPUFAMILY_ARM_BLIZZARD_AVALANCHE 0xda33d83d
1698#define CPUFAMILY_ARM_EVEREST_SAWTOOTH 0x8765edea
1699#define CPUFAMILY_ARM_IBIZA 0xfa33415e
1700#define CPUFAMILY_ARM_PALMA 0x72015832
1701#define CPUFAMILY_ARM_COLL 0x2876f5b5
1702#define CPUFAMILY_ARM_LOBOS 0x5f4dea93
1703#define CPUFAMILY_ARM_DONAN 0x6f5129ac
1704#define CPUFAMILY_ARM_BRAVA 0x17d5b93a
1705#define CPUFAMILY_ARM_TAHITI 0x75d4acb9
1706#define CPUFAMILY_ARM_TUPAI 0x204526d0
1710 size_t Length =
sizeof(Family);
1711 sysctlbyname(
"hw.cpufamily", &Family, &
Length, NULL, 0);
1723 case CPUFAMILY_UNKNOWN:
1725 case CPUFAMILY_ARM_9:
1727 case CPUFAMILY_ARM_11:
1728 return "arm1136jf-s";
1729 case CPUFAMILY_ARM_XSCALE:
1731 case CPUFAMILY_ARM_12:
1733 case CPUFAMILY_ARM_13:
1735 case CPUFAMILY_ARM_14:
1737 case CPUFAMILY_ARM_15:
1739 case CPUFAMILY_ARM_SWIFT:
1741 case CPUFAMILY_ARM_CYCLONE:
1743 case CPUFAMILY_ARM_TYPHOON:
1745 case CPUFAMILY_ARM_TWISTER:
1747 case CPUFAMILY_ARM_HURRICANE:
1749 case CPUFAMILY_ARM_MONSOON_MISTRAL:
1751 case CPUFAMILY_ARM_VORTEX_TEMPEST:
1753 case CPUFAMILY_ARM_LIGHTNING_THUNDER:
1755 case CPUFAMILY_ARM_FIRESTORM_ICESTORM:
1757 case CPUFAMILY_ARM_BLIZZARD_AVALANCHE:
1759 case CPUFAMILY_ARM_EVEREST_SAWTOOTH:
1760 case CPUFAMILY_ARM_IBIZA:
1761 case CPUFAMILY_ARM_PALMA:
1762 case CPUFAMILY_ARM_LOBOS:
1764 case CPUFAMILY_ARM_COLL:
1766 case CPUFAMILY_ARM_DONAN:
1767 case CPUFAMILY_ARM_BRAVA:
1768 case CPUFAMILY_ARM_TAHITI:
1769 case CPUFAMILY_ARM_TUPAI:
1778 switch (_system_configuration.implementation) {
1780 if (_system_configuration.version == PV_4_3)
1784 if (_system_configuration.version == PV_5)
1788 if (_system_configuration.version == PV_6_Compat)
1814#elif defined(__loongarch__)
1818 __asm__(
"cpucfg %[prid], $zero\n\t" : [prid]
"=r"(processor_id));
1820 switch (processor_id & 0xf000) {
1831#elif defined(__riscv)
1832#if defined(__linux__)
1834struct RISCVHwProbe {
1841#if defined(__linux__)
1843 RISCVHwProbe Query[]{{0, 0},
1846 int Ret = syscall(258, Query,
1847 std::size(Query), 0,
1864#if __riscv_xlen == 64
1865 return "generic-rv64";
1866#elif __riscv_xlen == 32
1867 return "generic-rv32";
1869#error "Unhandled value of __riscv_xlen"
1872#elif defined(__sparc__)
1873#if defined(__linux__)
1876 ProcCpuinfoContent.
split(Lines,
'\n');
1880 for (
unsigned I = 0,
E =
Lines.size();
I !=
E; ++
I) {
1882 Cpu =
Lines[
I].substr(5).ltrim(
"\t :");
1914#if defined(__linux__)
1918#elif defined(__sun__) && defined(__svr4__)
1922 kstat_named_t *brand = NULL;
1926 ksp = kstat_lookup(kc,
const_cast<char *
>(
"cpu_info"), -1, NULL);
1927 if (ksp != NULL && kstat_read(kc, ksp, NULL) != -1 &&
1928 ksp->ks_type == KSTAT_TYPE_NAMED)
1930 (kstat_named_t *)kstat_data_lookup(ksp,
const_cast<char *
>(
"brand"));
1931 if (brand != NULL && brand->data_type == KSTAT_DATA_STRING)
1932 buf = KSTAT_NAMED_STR_PTR(brand);
1937 .
Case(
"TMS390S10",
"supersparc")
1938 .
Case(
"TMS390Z50",
"supersparc")
1941 .
Case(
"MB86904",
"supersparc")
1942 .
Case(
"MB86907",
"supersparc")
1943 .
Case(
"RT623",
"hypersparc")
1944 .
Case(
"RT625",
"hypersparc")
1945 .
Case(
"RT626",
"hypersparc")
1946 .
Case(
"UltraSPARC-I",
"ultrasparc")
1947 .
Case(
"UltraSPARC-II",
"ultrasparc")
1948 .
Case(
"UltraSPARC-IIe",
"ultrasparc")
1949 .
Case(
"UltraSPARC-IIi",
"ultrasparc")
1950 .
Case(
"SPARC64-III",
"ultrasparc")
1951 .
Case(
"SPARC64-IV",
"ultrasparc")
1952 .
Case(
"UltraSPARC-III",
"ultrasparc3")
1953 .
Case(
"UltraSPARC-III+",
"ultrasparc3")
1954 .
Case(
"UltraSPARC-IIIi",
"ultrasparc3")
1955 .
Case(
"UltraSPARC-IIIi+",
"ultrasparc3")
1956 .
Case(
"UltraSPARC-IV",
"ultrasparc3")
1957 .
Case(
"UltraSPARC-IV+",
"ultrasparc3")
1958 .
Case(
"SPARC64-V",
"ultrasparc3")
1959 .
Case(
"SPARC64-VI",
"ultrasparc3")
1960 .
Case(
"SPARC64-VII",
"ultrasparc3")
1961 .
Case(
"UltraSPARC-T1",
"niagara")
1962 .
Case(
"UltraSPARC-T2",
"niagara2")
1963 .
Case(
"UltraSPARC-T2",
"niagara2")
1964 .
Case(
"UltraSPARC-T2+",
"niagara2")
1965 .
Case(
"SPARC-T3",
"niagara3")
1966 .
Case(
"SPARC-T4",
"niagara4")
1967 .
Case(
"SPARC-T5",
"niagara4")
1969 .
Case(
"SPARC-M7",
"niagara4" )
1970 .
Case(
"SPARC-S7",
"niagara4" )
1971 .
Case(
"SPARC-M8",
"niagara4" )
1994#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || \
1995 defined(_M_X64)) && \
1996 !defined(_M_ARM64EC)
2002 if (getX86CpuIDAndInfo(0, &MaxLevel, &EBX, &ECX, &EDX) || MaxLevel < 1)
2005 getX86CpuIDAndInfo(1, &EAX, &EBX, &ECX, &EDX);
2007 Features[
"cx8"] = (
EDX >> 8) & 1;
2008 Features[
"cmov"] = (
EDX >> 15) & 1;
2009 Features[
"mmx"] = (
EDX >> 23) & 1;
2010 Features[
"fxsr"] = (
EDX >> 24) & 1;
2011 Features[
"sse"] = (
EDX >> 25) & 1;
2012 Features[
"sse2"] = (
EDX >> 26) & 1;
2014 Features[
"sse3"] = (
ECX >> 0) & 1;
2015 Features[
"pclmul"] = (
ECX >> 1) & 1;
2016 Features[
"ssse3"] = (
ECX >> 9) & 1;
2017 Features[
"cx16"] = (
ECX >> 13) & 1;
2018 Features[
"sse4.1"] = (
ECX >> 19) & 1;
2019 Features[
"sse4.2"] = (
ECX >> 20) & 1;
2020 Features[
"crc32"] = Features[
"sse4.2"];
2021 Features[
"movbe"] = (
ECX >> 22) & 1;
2022 Features[
"popcnt"] = (
ECX >> 23) & 1;
2023 Features[
"aes"] = (
ECX >> 25) & 1;
2024 Features[
"rdrnd"] = (
ECX >> 30) & 1;
2029 bool HasXSave = ((
ECX >> 27) & 1) && !getX86XCR0(&EAX, &EDX);
2030 bool HasAVXSave = HasXSave && ((
ECX >> 28) & 1) && ((EAX & 0x6) == 0x6);
2031#if defined(__APPLE__)
2035 bool HasAVX512Save =
true;
2038 bool HasAVX512Save = HasAVXSave && ((
EAX & 0xe0) == 0xe0);
2041 const unsigned AMXBits = (1 << 17) | (1 << 18);
2042 bool HasAMXSave = HasXSave && ((
EAX & AMXBits) == AMXBits);
2044 Features[
"avx"] = HasAVXSave;
2045 Features[
"fma"] = ((
ECX >> 12) & 1) && HasAVXSave;
2047 Features[
"xsave"] = ((
ECX >> 26) & 1) && HasAVXSave;
2048 Features[
"f16c"] = ((
ECX >> 29) & 1) && HasAVXSave;
2050 unsigned MaxExtLevel;
2051 getX86CpuIDAndInfo(0x80000000, &MaxExtLevel, &EBX, &ECX, &EDX);
2053 bool HasExtLeaf1 = MaxExtLevel >= 0x80000001 &&
2054 !getX86CpuIDAndInfo(0x80000001, &EAX, &EBX, &ECX, &EDX);
2055 Features[
"sahf"] = HasExtLeaf1 && ((
ECX >> 0) & 1);
2056 Features[
"lzcnt"] = HasExtLeaf1 && ((
ECX >> 5) & 1);
2057 Features[
"sse4a"] = HasExtLeaf1 && ((
ECX >> 6) & 1);
2058 Features[
"prfchw"] = HasExtLeaf1 && ((
ECX >> 8) & 1);
2059 Features[
"xop"] = HasExtLeaf1 && ((
ECX >> 11) & 1) && HasAVXSave;
2060 Features[
"lwp"] = HasExtLeaf1 && ((
ECX >> 15) & 1);
2061 Features[
"fma4"] = HasExtLeaf1 && ((
ECX >> 16) & 1) && HasAVXSave;
2062 Features[
"tbm"] = HasExtLeaf1 && ((
ECX >> 21) & 1);
2063 Features[
"mwaitx"] = HasExtLeaf1 && ((
ECX >> 29) & 1);
2065 Features[
"64bit"] = HasExtLeaf1 && ((
EDX >> 29) & 1);
2069 bool HasExtLeaf8 = MaxExtLevel >= 0x80000008 &&
2070 !getX86CpuIDAndInfo(0x80000008, &EAX, &EBX, &ECX, &EDX);
2071 Features[
"clzero"] = HasExtLeaf8 && ((
EBX >> 0) & 1);
2072 Features[
"rdpru"] = HasExtLeaf8 && ((
EBX >> 4) & 1);
2073 Features[
"wbnoinvd"] = HasExtLeaf8 && ((
EBX >> 9) & 1);
2075 bool HasExtLeaf21 = MaxExtLevel >= 0x80000021 &&
2076 !getX86CpuIDAndInfo(0x80000021, &EAX, &EBX, &ECX, &EDX);
2078 Features[
"prefetchi"] = HasExtLeaf21 && ((
EAX >> 20) & 1);
2081 MaxLevel >= 7 && !getX86CpuIDAndInfoEx(0x7, 0x0, &EAX, &EBX, &ECX, &EDX);
2083 Features[
"fsgsbase"] = HasLeaf7 && ((
EBX >> 0) & 1);
2084 Features[
"sgx"] = HasLeaf7 && ((
EBX >> 2) & 1);
2085 Features[
"bmi"] = HasLeaf7 && ((
EBX >> 3) & 1);
2087 Features[
"avx2"] = HasLeaf7 && ((
EBX >> 5) & 1) && HasAVXSave;
2088 Features[
"bmi2"] = HasLeaf7 && ((
EBX >> 8) & 1);
2089 Features[
"invpcid"] = HasLeaf7 && ((
EBX >> 10) & 1);
2090 Features[
"rtm"] = HasLeaf7 && ((
EBX >> 11) & 1);
2092 Features[
"avx512f"] = HasLeaf7 && ((
EBX >> 16) & 1) && HasAVX512Save;
2093 Features[
"avx512dq"] = HasLeaf7 && ((
EBX >> 17) & 1) && HasAVX512Save;
2094 Features[
"rdseed"] = HasLeaf7 && ((
EBX >> 18) & 1);
2095 Features[
"adx"] = HasLeaf7 && ((
EBX >> 19) & 1);
2096 Features[
"avx512ifma"] = HasLeaf7 && ((
EBX >> 21) & 1) && HasAVX512Save;
2097 Features[
"clflushopt"] = HasLeaf7 && ((
EBX >> 23) & 1);
2098 Features[
"clwb"] = HasLeaf7 && ((
EBX >> 24) & 1);
2099 Features[
"avx512cd"] = HasLeaf7 && ((
EBX >> 28) & 1) && HasAVX512Save;
2100 Features[
"sha"] = HasLeaf7 && ((
EBX >> 29) & 1);
2101 Features[
"avx512bw"] = HasLeaf7 && ((
EBX >> 30) & 1) && HasAVX512Save;
2102 Features[
"avx512vl"] = HasLeaf7 && ((
EBX >> 31) & 1) && HasAVX512Save;
2104 Features[
"avx512vbmi"] = HasLeaf7 && ((
ECX >> 1) & 1) && HasAVX512Save;
2105 Features[
"pku"] = HasLeaf7 && ((
ECX >> 4) & 1);
2106 Features[
"waitpkg"] = HasLeaf7 && ((
ECX >> 5) & 1);
2107 Features[
"avx512vbmi2"] = HasLeaf7 && ((
ECX >> 6) & 1) && HasAVX512Save;
2108 Features[
"shstk"] = HasLeaf7 && ((
ECX >> 7) & 1);
2109 Features[
"gfni"] = HasLeaf7 && ((
ECX >> 8) & 1);
2110 Features[
"vaes"] = HasLeaf7 && ((
ECX >> 9) & 1) && HasAVXSave;
2111 Features[
"vpclmulqdq"] = HasLeaf7 && ((
ECX >> 10) & 1) && HasAVXSave;
2112 Features[
"avx512vnni"] = HasLeaf7 && ((
ECX >> 11) & 1) && HasAVX512Save;
2113 Features[
"avx512bitalg"] = HasLeaf7 && ((
ECX >> 12) & 1) && HasAVX512Save;
2114 Features[
"avx512vpopcntdq"] = HasLeaf7 && ((
ECX >> 14) & 1) && HasAVX512Save;
2115 Features[
"rdpid"] = HasLeaf7 && ((
ECX >> 22) & 1);
2116 Features[
"kl"] = HasLeaf7 && ((
ECX >> 23) & 1);
2117 Features[
"cldemote"] = HasLeaf7 && ((
ECX >> 25) & 1);
2118 Features[
"movdiri"] = HasLeaf7 && ((
ECX >> 27) & 1);
2119 Features[
"movdir64b"] = HasLeaf7 && ((
ECX >> 28) & 1);
2120 Features[
"enqcmd"] = HasLeaf7 && ((
ECX >> 29) & 1);
2122 Features[
"uintr"] = HasLeaf7 && ((
EDX >> 5) & 1);
2123 Features[
"avx512vp2intersect"] =
2124 HasLeaf7 && ((
EDX >> 8) & 1) && HasAVX512Save;
2125 Features[
"serialize"] = HasLeaf7 && ((
EDX >> 14) & 1);
2126 Features[
"tsxldtrk"] = HasLeaf7 && ((
EDX >> 16) & 1);
2137 Features[
"pconfig"] = HasLeaf7 && ((
EDX >> 18) & 1);
2138 Features[
"amx-bf16"] = HasLeaf7 && ((
EDX >> 22) & 1) && HasAMXSave;
2139 Features[
"avx512fp16"] = HasLeaf7 && ((
EDX >> 23) & 1) && HasAVX512Save;
2140 Features[
"amx-tile"] = HasLeaf7 && ((
EDX >> 24) & 1) && HasAMXSave;
2141 Features[
"amx-int8"] = HasLeaf7 && ((
EDX >> 25) & 1) && HasAMXSave;
2144 bool HasLeaf7Subleaf1 =
2145 HasLeaf7 &&
EAX >= 1 &&
2146 !getX86CpuIDAndInfoEx(0x7, 0x1, &EAX, &EBX, &ECX, &EDX);
2147 Features[
"sha512"] = HasLeaf7Subleaf1 && ((
EAX >> 0) & 1);
2148 Features[
"sm3"] = HasLeaf7Subleaf1 && ((
EAX >> 1) & 1);
2149 Features[
"sm4"] = HasLeaf7Subleaf1 && ((
EAX >> 2) & 1);
2150 Features[
"raoint"] = HasLeaf7Subleaf1 && ((
EAX >> 3) & 1);
2151 Features[
"avxvnni"] = HasLeaf7Subleaf1 && ((
EAX >> 4) & 1) && HasAVXSave;
2152 Features[
"avx512bf16"] = HasLeaf7Subleaf1 && ((
EAX >> 5) & 1) && HasAVX512Save;
2153 Features[
"amx-fp16"] = HasLeaf7Subleaf1 && ((
EAX >> 21) & 1) && HasAMXSave;
2154 Features[
"cmpccxadd"] = HasLeaf7Subleaf1 && ((
EAX >> 7) & 1);
2155 Features[
"hreset"] = HasLeaf7Subleaf1 && ((
EAX >> 22) & 1);
2156 Features[
"avxifma"] = HasLeaf7Subleaf1 && ((
EAX >> 23) & 1) && HasAVXSave;
2157 Features[
"movrs"] = HasLeaf7Subleaf1 && ((
EAX >> 31) & 1);
2158 Features[
"avxvnniint8"] = HasLeaf7Subleaf1 && ((
EDX >> 4) & 1) && HasAVXSave;
2159 Features[
"avxneconvert"] = HasLeaf7Subleaf1 && ((
EDX >> 5) & 1) && HasAVXSave;
2160 Features[
"amx-complex"] = HasLeaf7Subleaf1 && ((
EDX >> 8) & 1) && HasAMXSave;
2161 Features[
"avxvnniint16"] = HasLeaf7Subleaf1 && ((
EDX >> 10) & 1) && HasAVXSave;
2162 Features[
"prefetchi"] |= HasLeaf7Subleaf1 && ((
EDX >> 14) & 1);
2163 Features[
"usermsr"] = HasLeaf7Subleaf1 && ((
EDX >> 15) & 1);
2164 bool HasAVX10 = HasLeaf7Subleaf1 && ((
EDX >> 19) & 1);
2165 bool HasAPXF = HasLeaf7Subleaf1 && ((
EDX >> 21) & 1);
2166 Features[
"egpr"] = HasAPXF;
2167 Features[
"push2pop2"] = HasAPXF;
2168 Features[
"ppx"] = HasAPXF;
2169 Features[
"ndd"] = HasAPXF;
2170 Features[
"ccmp"] = HasAPXF;
2171 Features[
"nf"] = HasAPXF;
2172 Features[
"cf"] = HasAPXF;
2173 Features[
"zu"] = HasAPXF;
2175 bool HasLeafD = MaxLevel >= 0xd &&
2176 !getX86CpuIDAndInfoEx(0xd, 0x1, &EAX, &EBX, &ECX, &EDX);
2179 Features[
"xsaveopt"] = HasLeafD && ((
EAX >> 0) & 1) && HasAVXSave;
2180 Features[
"xsavec"] = HasLeafD && ((
EAX >> 1) & 1) && HasAVXSave;
2181 Features[
"xsaves"] = HasLeafD && ((
EAX >> 3) & 1) && HasAVXSave;
2183 bool HasLeaf14 = MaxLevel >= 0x14 &&
2184 !getX86CpuIDAndInfoEx(0x14, 0x0, &EAX, &EBX, &ECX, &EDX);
2186 Features[
"ptwrite"] = HasLeaf14 && ((
EBX >> 4) & 1);
2189 MaxLevel >= 0x19 && !getX86CpuIDAndInfo(0x19, &EAX, &EBX, &ECX, &EDX);
2190 Features[
"widekl"] = HasLeaf7 && HasLeaf19 && ((
EBX >> 2) & 1);
2192 bool HasLeaf1E = MaxLevel >= 0x1e &&
2193 !getX86CpuIDAndInfoEx(0x1e, 0x1, &EAX, &EBX, &ECX, &EDX);
2194 Features[
"amx-fp8"] = HasLeaf1E && ((
EAX >> 4) & 1) && HasAMXSave;
2195 Features[
"amx-transpose"] = HasLeaf1E && ((
EAX >> 5) & 1) && HasAMXSave;
2196 Features[
"amx-tf32"] = HasLeaf1E && ((
EAX >> 6) & 1) && HasAMXSave;
2197 Features[
"amx-avx512"] = HasLeaf1E && ((
EAX >> 7) & 1) && HasAMXSave;
2198 Features[
"amx-movrs"] = HasLeaf1E && ((
EAX >> 8) & 1) && HasAMXSave;
2201 MaxLevel >= 0x24 && !getX86CpuIDAndInfo(0x24, &EAX, &EBX, &ECX, &EDX);
2203 int AVX10Ver = HasLeaf24 && (
EBX & 0xff);
2204 Features[
"avx10.1"] = HasAVX10 && AVX10Ver >= 1;
2205 Features[
"avx10.2"] = HasAVX10 && AVX10Ver >= 2;
2209#elif defined(__linux__) && (defined(__arm__) || defined(__aarch64__))
2217 P->getBuffer().split(Lines,
'\n');
2222 for (
unsigned I = 0,
E =
Lines.size();
I !=
E; ++
I)
2224 Lines[
I].split(CPUFeatures,
' ');
2228#if defined(__aarch64__)
2231 enum { CAP_AES = 0x1, CAP_PMULL = 0x2, CAP_SHA1 = 0x4, CAP_SHA2 = 0x8 };
2235 for (
unsigned I = 0,
E = CPUFeatures.size();
I !=
E; ++
I) {
2237#if defined(__aarch64__)
2238 .
Case(
"asimd",
"neon")
2239 .
Case(
"fp",
"fp-armv8")
2240 .
Case(
"crc32",
"crc")
2241 .
Case(
"atomics",
"lse")
2242 .
Case(
"sha3",
"sha3")
2245 .
Case(
"sve2",
"sve2")
2246 .
Case(
"sveaes",
"sve-aes")
2247 .
Case(
"svesha3",
"sve-sha3")
2248 .
Case(
"svesm4",
"sve-sm4")
2250 .
Case(
"half",
"fp16")
2251 .
Case(
"neon",
"neon")
2252 .
Case(
"vfpv3",
"vfp3")
2253 .
Case(
"vfpv3d16",
"vfp3d16")
2254 .
Case(
"vfpv4",
"vfp4")
2255 .
Case(
"idiva",
"hwdiv-arm")
2256 .
Case(
"idivt",
"hwdiv")
2260#if defined(__aarch64__)
2263 if (CPUFeatures[
I] ==
"aes")
2265 else if (CPUFeatures[
I] ==
"pmull")
2266 crypto |= CAP_PMULL;
2267 else if (CPUFeatures[
I] ==
"sha1")
2269 else if (CPUFeatures[
I] ==
"sha2")
2273 if (LLVMFeatureStr !=
"")
2274 Features[LLVMFeatureStr] =
true;
2277#if defined(__aarch64__)
2281 uint32_t Aes = CAP_AES | CAP_PMULL;
2282 uint32_t Sha2 = CAP_SHA1 | CAP_SHA2;
2283 Features[
"aes"] = (crypto & Aes) == Aes;
2284 Features[
"sha2"] = (crypto & Sha2) == Sha2;
2289#elif defined(_WIN32) && (defined(__aarch64__) || defined(_M_ARM64) || \
2290 defined(__arm64ec__) || defined(_M_ARM64EC))
2296 IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE);
2298 IsProcessorFeaturePresent(PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE);
2302 IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE);
2303 Features[
"aes"] = TradCrypto;
2304 Features[
"sha2"] = TradCrypto;
2308#elif defined(__linux__) && defined(__loongarch__)
2309#include <sys/auxv.h>
2311 unsigned long hwcap = getauxval(AT_HWCAP);
2312 bool HasFPU = hwcap & (1UL << 3);
2313 uint32_t cpucfg2 = 0x2, cpucfg3 = 0x3;
2314 __asm__(
"cpucfg %[cpucfg2], %[cpucfg2]\n\t" : [cpucfg2]
"+r"(cpucfg2));
2315 __asm__(
"cpucfg %[cpucfg3], %[cpucfg3]\n\t" : [cpucfg3]
"+r"(cpucfg3));
2319 Features[
"f"] = HasFPU && (cpucfg2 & (1U << 1));
2320 Features[
"d"] = HasFPU && (cpucfg2 & (1U << 2));
2322 Features[
"lsx"] = hwcap & (1UL << 4);
2323 Features[
"lasx"] = hwcap & (1UL << 5);
2324 Features[
"lvz"] = hwcap & (1UL << 9);
2326 Features[
"frecipe"] = cpucfg2 & (1U << 25);
2327 Features[
"div32"] = cpucfg2 & (1U << 26);
2328 Features[
"lam-bh"] = cpucfg2 & (1U << 27);
2329 Features[
"lamcas"] = cpucfg2 & (1U << 28);
2330 Features[
"scq"] = cpucfg2 & (1U << 30);
2332 Features[
"ld-seq-sa"] = cpucfg3 & (1U << 23);
2338#elif defined(__linux__) && defined(__riscv)
2340 RISCVHwProbe Query[]{{3, 0},
2343 int Ret = syscall(258, Query,
2344 std::size(Query), 0,
2350 uint64_t BaseMask = Query[0].Value;
2353 Features[
"i"] =
true;
2354 Features[
"m"] =
true;
2355 Features[
"a"] =
true;
2359 Features[
"f"] = ExtMask & (1 << 0);
2360 Features[
"d"] = ExtMask & (1 << 0);
2361 Features[
"c"] = ExtMask & (1 << 1);
2362 Features[
"v"] = ExtMask & (1 << 2);
2363 Features[
"zba"] = ExtMask & (1 << 3);
2364 Features[
"zbb"] = ExtMask & (1 << 4);
2365 Features[
"zbs"] = ExtMask & (1 << 5);
2366 Features[
"zicboz"] = ExtMask & (1 << 6);
2367 Features[
"zbc"] = ExtMask & (1 << 7);
2368 Features[
"zbkb"] = ExtMask & (1 << 8);
2369 Features[
"zbkc"] = ExtMask & (1 << 9);
2370 Features[
"zbkx"] = ExtMask & (1 << 10);
2371 Features[
"zknd"] = ExtMask & (1 << 11);
2372 Features[
"zkne"] = ExtMask & (1 << 12);
2373 Features[
"zknh"] = ExtMask & (1 << 13);
2374 Features[
"zksed"] = ExtMask & (1 << 14);
2375 Features[
"zksh"] = ExtMask & (1 << 15);
2376 Features[
"zkt"] = ExtMask & (1 << 16);
2377 Features[
"zvbb"] = ExtMask & (1 << 17);
2378 Features[
"zvbc"] = ExtMask & (1 << 18);
2379 Features[
"zvkb"] = ExtMask & (1 << 19);
2380 Features[
"zvkg"] = ExtMask & (1 << 20);
2381 Features[
"zvkned"] = ExtMask & (1 << 21);
2382 Features[
"zvknha"] = ExtMask & (1 << 22);
2383 Features[
"zvknhb"] = ExtMask & (1 << 23);
2384 Features[
"zvksed"] = ExtMask & (1 << 24);
2385 Features[
"zvksh"] = ExtMask & (1 << 25);
2386 Features[
"zvkt"] = ExtMask & (1 << 26);
2387 Features[
"zfh"] = ExtMask & (1 << 27);
2388 Features[
"zfhmin"] = ExtMask & (1 << 28);
2389 Features[
"zihintntl"] = ExtMask & (1 << 29);
2390 Features[
"zvfh"] = ExtMask & (1 << 30);
2391 Features[
"zvfhmin"] = ExtMask & (1ULL << 31);
2392 Features[
"zfa"] = ExtMask & (1ULL << 32);
2393 Features[
"ztso"] = ExtMask & (1ULL << 33);
2394 Features[
"zacas"] = ExtMask & (1ULL << 34);
2395 Features[
"zicond"] = ExtMask & (1ULL << 35);
2396 Features[
"zihintpause"] =
2397 ExtMask & (1ULL << 36);
2398 Features[
"zve32x"] = ExtMask & (1ULL << 37);
2399 Features[
"zve32f"] = ExtMask & (1ULL << 38);
2400 Features[
"zve64x"] = ExtMask & (1ULL << 39);
2401 Features[
"zve64f"] = ExtMask & (1ULL << 40);
2402 Features[
"zve64d"] = ExtMask & (1ULL << 41);
2403 Features[
"zimop"] = ExtMask & (1ULL << 42);
2404 Features[
"zca"] = ExtMask & (1ULL << 43);
2405 Features[
"zcb"] = ExtMask & (1ULL << 44);
2406 Features[
"zcd"] = ExtMask & (1ULL << 45);
2407 Features[
"zcf"] = ExtMask & (1ULL << 46);
2408 Features[
"zcmop"] = ExtMask & (1ULL << 47);
2409 Features[
"zawrs"] = ExtMask & (1ULL << 48);
2415 if (Query[2].
Key != -1 &&
2416 Query[2].
Value == 3)
2417 Features[
"unaligned-scalar-mem"] =
true;
2430 T.setArchName(
"arm");
2431#elif defined(__arm64e__)
2433 T.setArchName(
"arm64e");
2434#elif defined(__aarch64__)
2436 T.setArchName(
"arm64");
2437#elif defined(__x86_64h__)
2439 T.setArchName(
"x86_64h");
2440#elif defined(__x86_64__)
2442 T.setArchName(
"x86_64");
2443#elif defined(__i386__)
2445 T.setArchName(
"i386");
2446#elif defined(__powerpc__)
2448 T.setArchName(
"powerpc");
2450# error "Unimplemented host arch fixup"
2457 std::string TargetTripleString = updateTripleOSVersion(LLVM_HOST_TRIPLE);
2463 PT = withHostArch(PT);
2475#if LLVM_VERSION_PRINTER_SHOW_HOST_TARGET_INFO
2477 if (CPU ==
"generic")
2480 <<
" Host CPU: " << CPU <<
'\n';
This file defines the StringMap class.
This file implements methods to test, set and extract typed bits from packed unsigned integers.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
StringRef getHostCPUNameForARMFromComponents(StringRef Implementer, StringRef Hardware, StringRef Part, ArrayRef< StringRef > Parts, function_ref< unsigned()> GetVariant)
static std::unique_ptr< llvm::MemoryBuffer > getProcCpuinfoContent()
Merge contiguous icmps into a memcmp
This file defines the SmallVector class.
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
Represents either an error or a value T.
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFileAsStream(const Twine &Filename)
Read all of the specified file into a MemoryBuffer as a stream (i.e.
reference emplace_back(ArgTypes &&... Args)
void reserve(size_type N)
iterator erase(const_iterator CI)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
StringRef - Represent a constant reference to a string, i.e.
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
bool getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
const char * const_iterator
StringRef ltrim(char Char) const
Return string with consecutive Char characters starting from the the left removed.
bool ends_with(StringRef Suffix) const
Check if this string ends with the given Suffix.
static constexpr size_t npos
A switch()-like statement whose cases are string literals.
StringSwitch & Case(StringLiteral S, T Value)
StringSwitch & StartsWith(StringLiteral S, T Value)
Triple - Helper class for working with autoconf configuration names.
LLVM_ABI llvm::Triple get32BitArchVariant() const
Form a triple with a 32-bit variant of the current architecture.
LLVM_ABI llvm::Triple get64BitArchVariant() const
Form a triple with a 64-bit variant of the current architecture.
static LLVM_ABI std::string normalize(StringRef Str, CanonicalForm Form=CanonicalForm::ANY)
Turn an arbitrary machine specification into the canonical triple form (or something sensible that th...
const std::string & str() const
LLVM_ABI bool isArch64Bit() const
Test whether the architecture is 64-bit.
LLVM_ABI bool isArch32Bit() const
Test whether the architecture is 32-bit.
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
An efficient, type-erasing, non-owning reference to a callable.
This class implements an extremely fast bulk output stream that can only output to a stream.
@ CPU_SUBTYPE_POWERPC_970
@ CPU_SUBTYPE_POWERPC_604e
@ CPU_SUBTYPE_POWERPC_603e
@ CPU_SUBTYPE_POWERPC_7400
@ CPU_SUBTYPE_POWERPC_604
@ CPU_SUBTYPE_POWERPC_750
@ CPU_SUBTYPE_POWERPC_601
@ CPU_SUBTYPE_POWERPC_620
@ CPU_SUBTYPE_POWERPC_603ev
@ CPU_SUBTYPE_POWERPC_603
@ CPU_SUBTYPE_POWERPC_7450
@ CPU_SUBTYPE_POWERPC_602
LLVM_ABI StringRef getCPUNameFromCPUModel(const CPUModel &Model)
Helper functions to extract CPU details from CPUID on x86.
LLVM_ABI VendorSignatures getVendorSignature(unsigned *MaxLeaf=nullptr)
Returns the host CPU's vendor.
LLVM_ABI StringRef getHostCPUNameForSPARC(StringRef ProcCpuinfoContent)
LLVM_ABI StringRef getHostCPUNameForS390x(StringRef ProcCpuinfoContent)
LLVM_ABI StringRef getHostCPUNameForPowerPC(StringRef ProcCpuinfoContent)
Helper functions to extract HostCPUName from /proc/cpuinfo on linux.
LLVM_ABI StringRef getHostCPUNameForBPF()
LLVM_ABI StringRef getHostCPUNameForARM(StringRef ProcCpuinfoContent)
LLVM_ABI StringRef getHostCPUNameForRISCV(StringRef ProcCpuinfoContent)
LLVM_ABI StringMap< bool, MallocAllocator > getHostCPUFeatures()
getHostCPUFeatures - Get the LLVM names for the host CPU features.
LLVM_ABI StringRef getHostCPUName()
getHostCPUName - Get the LLVM name for the host CPU.
LLVM_ABI void printDefaultTargetAndDetectedCPU(raw_ostream &OS)
This is a function compatible with cl::AddExtraVersionPrinter, which adds info about the current targ...
LLVM_ABI std::string getDefaultTargetTriple()
getDefaultTargetTriple() - Return the default target triple the compiler has been configured to produ...
LLVM_ABI std::string getProcessTriple()
getProcessTriple() - Return an appropriate target triple for generating code to be loaded into the cu...
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Value
std::string utohexstr(uint64_t X, bool LowerCase=false, unsigned Width=0)
int64_t decodePackedBCD(const uint8_t *Ptr, size_t ByteLen, bool IsSigned=true)
auto unique(Range &&R, Predicate P)
void sort(IteratorTy Start, IteratorTy End)
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Describes an element of a Bitfield.
static Bitfield::Type get(StorageType Packed)
Unpacks the field from the Packed value.