Changeset View
Changeset View
Standalone View
Standalone View
lib/Driver/ToolChains/Arch/ARM.cpp
Show First 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | |||||
if (!FeatureName.empty()) | if (!FeatureName.empty()) | ||||
Features.push_back(FeatureName); | Features.push_back(FeatureName); | ||||
else | else | ||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
static void DecodeARMFeaturesFromCPU(const Driver &D, StringRef CPU, | |||||
rengolin: Why are you returning bool if you're not using the result? | |||||
std::vector<StringRef> &Features) { | |||||
if (CPU != "generic") { | |||||
Not Done ReplyInline ActionsNit: just for readability I would prefer an early exit: if (CPU == "generic") return false; SjoerdMeijer: Nit: just for readability I would prefer an early exit:
if (CPU == "generic")
return false; | |||||
llvm::ARM::ArchKind ArchKind = llvm::ARM::parseCPUArch(CPU); | |||||
unsigned Extension = llvm::ARM::getDefaultExtensions(CPU, ArchKind); | |||||
llvm::ARM::getExtensionFeatures(Extension, Features); | |||||
} | |||||
} | |||||
// Check if -march is valid by checking if it can be canonicalised and parsed. | // Check if -march is valid by checking if it can be canonicalised and parsed. | ||||
// getARMArch is used here instead of just checking the -march value in order | // getARMArch is used here instead of just checking the -march value in order | ||||
// to handle -march=native correctly. | // to handle -march=native correctly. | ||||
static void checkARMArchName(const Driver &D, const Arg *A, const ArgList &Args, | static void checkARMArchName(const Driver &D, const Arg *A, const ArgList &Args, | ||||
Not Done ReplyInline ActionsNit: you're not checking the return value (so you could simplify this function, but I don't have a strong opinion on this). SjoerdMeijer: Nit: you're not checking the return value (so you could simplify this function, but I don't… | |||||
llvm::StringRef ArchName, | llvm::StringRef ArchName, | ||||
std::vector<StringRef> &Features, | std::vector<StringRef> &Features, | ||||
const llvm::Triple &Triple) { | const llvm::Triple &Triple) { | ||||
std::pair<StringRef, StringRef> Split = ArchName.split("+"); | std::pair<StringRef, StringRef> Split = ArchName.split("+"); | ||||
std::string MArch = arm::getARMArch(ArchName, Triple); | std::string MArch = arm::getARMArch(ArchName, Triple); | ||||
if (llvm::ARM::parseArch(MArch) == llvm::ARM::ArchKind::INVALID || | if (llvm::ARM::parseArch(MArch) == llvm::ARM::ArchKind::INVALID || | ||||
(Split.second.size() && !DecodeARMFeatures(D, Split.second, Features))) | (Split.second.size() && !DecodeARMFeatures(D, Split.second, Features))) | ||||
▲ Show 20 Lines • Show All 180 Lines • ▼ Show 20 Lines | |||||
// Add CPU features for generic CPUs | // Add CPU features for generic CPUs | ||||
if (CPUName == "native") { | if (CPUName == "native") { | ||||
llvm::StringMap<bool> HostFeatures; | llvm::StringMap<bool> HostFeatures; | ||||
if (llvm::sys::getHostCPUFeatures(HostFeatures)) | if (llvm::sys::getHostCPUFeatures(HostFeatures)) | ||||
for (auto &F : HostFeatures) | for (auto &F : HostFeatures) | ||||
Features.push_back( | Features.push_back( | ||||
Args.MakeArgString((F.second ? "+" : "-") + F.first())); | Args.MakeArgString((F.second ? "+" : "-") + F.first())); | ||||
} else if (!CPUName.empty()) { | |||||
Not Done ReplyInline ActionsIsn't this conditional redundant with what the function does? rengolin: Isn't this conditional redundant with what the function does? | |||||
Not Done ReplyInline ActionsCPUName != "generic" is also checked in function DecodeARMFeaturesFromCPU. SjoerdMeijer: CPUName != "generic" is also checked in function DecodeARMFeaturesFromCPU. | |||||
DecodeARMFeaturesFromCPU(D, CPUName, Features); | |||||
} | } | ||||
// Honor -mfpu=. ClangAs gives preference to -Wa,-mfpu=. | // Honor -mfpu=. ClangAs gives preference to -Wa,-mfpu=. | ||||
const Arg *FPUArg = Args.getLastArg(options::OPT_mfpu_EQ); | const Arg *FPUArg = Args.getLastArg(options::OPT_mfpu_EQ); | ||||
if (WaFPU) { | if (WaFPU) { | ||||
if (FPUArg) | if (FPUArg) | ||||
D.Diag(clang::diag::warn_drv_unused_argument) | D.Diag(clang::diag::warn_drv_unused_argument) | ||||
<< FPUArg->getAsString(Args); | << FPUArg->getAsString(Args); | ||||
▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines |
Why are you returning bool if you're not using the result?