Skip to content

Commit

Permalink
Treat iree-llvmcpu-target-cpu as an error outside of x86, and conti…
Browse files Browse the repository at this point in the history
…nue past errors (iree-org#15477)

See the discussion thread below
https://discord.com/channels/689900678990135345/1171569395697467403/1171572035336548453
.

Implementing `iree-llvmcpu-target-cpu` on arm64 is hopeless because Arm
CPU names are under-defined. For instance, LLVM thinks that Cortex-A710
implies SVE, but most current Cortex-A710 based devices do not support
SVE.
  • Loading branch information
bjacob authored Nov 8, 2023
1 parent 65fe91f commit d509096
Showing 1 changed file with 3 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/TargetParser/AArch64TargetParser.h"
#include "llvm/TargetParser/Host.h"
#include "llvm/TargetParser/SubtargetFeature.h"
#include "llvm/TargetParser/Triple.h"
Expand Down Expand Up @@ -81,24 +80,6 @@ bool resolveCPUAndCPUFeatures(llvm::StringRef inCpu,
targetCpuFeatures.AddFeature(feature);
}
outCpuFeatures = targetCpuFeatures.getString();
} else if (triple.isAArch64()) {
std::vector<std::string> UpdatedFeaturesVec;
std::optional<llvm::AArch64::CpuInfo> cpuInfo =
llvm::AArch64::parseCpu(outCpu);
if (!cpuInfo) {
llvm::errs() << "error: Failed to resolve AArch64 CPU features for the "
"specified CPU.\n";
return false;
}
auto cpuExts = cpuInfo->getImpliedExtensions();
std::vector<StringRef> cpuExtFeatures;
llvm::AArch64::getExtensionFeatures(cpuExts, cpuExtFeatures);
for (auto feature : cpuExtFeatures) {
if (!outCpuFeatures.empty()) {
outCpuFeatures.append(",");
}
outCpuFeatures.append(feature);
}
} else {
llvm::errs()
<< "error: Resolution of target CPU to target CPU features is not "
Expand Down Expand Up @@ -158,7 +139,9 @@ std::optional<LLVMTarget> LLVMTarget::create(std::string_view triple,
}
if (!resolveCPUAndCPUFeatures(cpu, cpuFeatures, llvm::Triple(triple),
target.cpu, target.cpuFeatures)) {
return {};
// Something bad happened, and our target might not be what the user expects
// but we need to continue to avoid breaking existing users. Hopefully
// resolveCPUAndCPUFeatures logged a helpful error already.
}
return target;
}
Expand Down

0 comments on commit d509096

Please sign in to comment.