Skip to content

Commit c942cb2

Browse files
committed
[AArch64] Add getHostCPUFeatures to query for enabled features in cpuinfo
1 parent d43ec97 commit c942cb2

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

clang/lib/Driver/ToolChains/Arch/AArch64.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,4 +445,21 @@ void aarch64::getAArch64TargetFeatures(const Driver &D,
445445

446446
if (Args.getLastArg(options::OPT_mno_bti_at_return_twice))
447447
Features.push_back("+no-bti-at-return-twice");
448+
449+
// Parse AArch64 CPU Features
450+
const Arg *CPUArg = Args.getLastArg(options::OPT_mcpu_EQ);
451+
StringRef CPUName;
452+
453+
if (CPUArg) {
454+
CPUName = CPUArg->getValue();
455+
if (CPUName == "native") {
456+
llvm::StringMap<bool> HostFeatures;
457+
if (llvm::sys::getHostCPUFeatures(HostFeatures)) {
458+
for (auto &F : HostFeatures) {
459+
Features.push_back(
460+
Args.MakeArgString((F.second ? "+" : "-") + F.first()));
461+
}
462+
}
463+
}
464+
}
448465
}

0 commit comments

Comments
 (0)