[llvm] [RISCV] Add getFeaturesForCPU function support (PR #83269)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 28 08:57:30 PST 2024
================
@@ -95,5 +96,31 @@ void fillValidTuneCPUArchList(SmallVectorImpl<StringRef> &Values, bool IsRV64) {
#include "llvm/TargetParser/RISCVTargetParserDef.inc"
}
+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 */ true);
+ for (const auto &F : FeatStrings) {
+ if (F[0] == '-')
----------------
topperc wrote:
Why pass AddAllExtensions=true if you're going to skip the '-' ones?
https://github.com/llvm/llvm-project/pull/83269
More information about the llvm-commits
mailing list