diff options
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Support/RISCVISAInfo.cpp')
| -rw-r--r-- | contrib/llvm-project/llvm/lib/Support/RISCVISAInfo.cpp | 41 |
1 files changed, 14 insertions, 27 deletions
diff --git a/contrib/llvm-project/llvm/lib/Support/RISCVISAInfo.cpp b/contrib/llvm-project/llvm/lib/Support/RISCVISAInfo.cpp index a9b7e209915a..70f531e40b90 100644 --- a/contrib/llvm-project/llvm/lib/Support/RISCVISAInfo.cpp +++ b/contrib/llvm-project/llvm/lib/Support/RISCVISAInfo.cpp @@ -466,35 +466,38 @@ bool RISCVISAInfo::compareExtension(const std::string &LHS, return LHS < RHS; } -void RISCVISAInfo::toFeatures( - std::vector<StringRef> &Features, - llvm::function_ref<StringRef(const Twine &)> StrAlloc, - bool AddAllExtensions) const { - for (auto const &Ext : Exts) { - StringRef ExtName = Ext.first; - +std::vector<std::string> RISCVISAInfo::toFeatures(bool AddAllExtensions, + bool IgnoreUnknown) const { + std::vector<std::string> Features; + for (const auto &[ExtName, _] : Exts) { + // i is a base instruction set, not an extension (see + // https://github.com/riscv/riscv-isa-manual/blob/main/src/naming.adoc#base-integer-isa) + // and is not recognized in clang -cc1 if (ExtName == "i") continue; + if (IgnoreUnknown && !isSupportedExtension(ExtName)) + continue; if (isExperimentalExtension(ExtName)) { - Features.push_back(StrAlloc("+experimental-" + ExtName)); + Features.push_back((llvm::Twine("+experimental-") + ExtName).str()); } else { - Features.push_back(StrAlloc("+" + ExtName)); + Features.push_back((llvm::Twine("+") + ExtName).str()); } } if (AddAllExtensions) { for (const RISCVSupportedExtension &Ext : SupportedExtensions) { if (Exts.count(Ext.Name)) continue; - Features.push_back(StrAlloc(Twine("-") + Ext.Name)); + Features.push_back((llvm::Twine("-") + Ext.Name).str()); } for (const RISCVSupportedExtension &Ext : SupportedExperimentalExtensions) { if (Exts.count(Ext.Name)) continue; - Features.push_back(StrAlloc(Twine("-experimental-") + Ext.Name)); + Features.push_back((llvm::Twine("-experimental-") + Ext.Name).str()); } } + return Features; } // Extensions may have a version number, and may be separated by @@ -1269,22 +1272,6 @@ std::string RISCVISAInfo::toString() const { return Arch.str(); } -std::vector<std::string> RISCVISAInfo::toFeatureVector() const { - std::vector<std::string> FeatureVector; - for (auto const &Ext : Exts) { - std::string ExtName = Ext.first; - if (ExtName == "i") // i is not recognized in clang -cc1 - continue; - if (!isSupportedExtension(ExtName)) - continue; - std::string Feature = isExperimentalExtension(ExtName) - ? "+experimental-" + ExtName - : "+" + ExtName; - FeatureVector.push_back(Feature); - } - return FeatureVector; -} - llvm::Expected<std::unique_ptr<RISCVISAInfo>> RISCVISAInfo::postProcessAndChecking(std::unique_ptr<RISCVISAInfo> &&ISAInfo) { ISAInfo->updateImplication(); |
