[llvm] [RISCV] Add getFeaturesForCPU function support (PR #83269)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 28 19:18:24 PST 2024
================
@@ -95,5 +96,28 @@ void fillValidTuneCPUArchList(SmallVectorImpl<StringRef> &Values, bool IsRV64) {
#include "llvm/TargetParser/RISCVTargetParserDef.inc"
}
+// This function is currently used by IREE, so it's not dead code.
+void getFeaturesForCPU(StringRef CPU,
+ SmallVectorImpl<std::string> &EnabledFeatures,
+ bool NeedPlus) {
+ StringRef MarchFromCPU = llvm::RISCV::getMArchFromMcpu(CPU);
+ if (MarchFromCPU == "")
+ return;
+
+ EnabledFeatures.clear();
+ auto RII = RISCVISAInfo::parseArchString(
+ MarchFromCPU, /* EnableExperimentalExtension */ true);
+
+ if (llvm::errorToBool(RII.takeError()))
+ return;
+
+ std::vector<std::string> FeatStrings =
+ (*RII)->toFeatures(/* AddAllExtensions */ false);
+ for (const auto &F : FeatStrings)
+ if (NeedPlus)
+ EnabledFeatures.push_back(F);
+ else
+ EnabledFeatures.push_back(F.substr(1, F.size() - 1));
----------------
topperc wrote:
I think we can use `F.substr(1)`?
https://github.com/llvm/llvm-project/pull/83269
More information about the llvm-commits
mailing list