[RISCV] When resolving extension implications, handle the default I/E case after implications are resolved. (#154353)

This is needed to handle the scenario of an extension that implies
FeatureStdExtE, as is the case for the
downstream FeatureVendorXCheriot used for Cheriot support.
This commit is contained in:
Owen Anderson 2025-08-20 09:59:23 +08:00 committed by GitHub
parent 8666ffdd15
commit 4f683b10b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -833,19 +833,6 @@ static bool operator<(StringRef LHS, const ImpliedExtsEntry &RHS) {
#include "llvm/TargetParser/RISCVTargetParserDef.inc"
void RISCVISAInfo::updateImplication() {
bool HasE = Exts.count("e") != 0;
bool HasI = Exts.count("i") != 0;
// If not in e extension and i extension does not exist, i extension is
// implied
if (!HasE && !HasI) {
auto Version = findDefaultVersion("i");
Exts["i"] = *Version;
}
if (HasE && HasI)
Exts.erase("i");
assert(llvm::is_sorted(ImpliedExts) && "Table not sorted by Name");
// This loop may execute over 1 iteration since implication can be layered
@ -887,6 +874,21 @@ void RISCVISAInfo::updateImplication() {
auto Version = findDefaultVersion("zcf");
Exts["zcf"] = *Version;
}
// Handle I/E after implications have been resolved, in case either
// of them was implied by another extension.
bool HasE = Exts.count("e") != 0;
bool HasI = Exts.count("i") != 0;
// If not in e extension and i extension does not exist, i extension is
// implied
if (!HasE && !HasI) {
auto Version = findDefaultVersion("i");
Exts["i"] = *Version;
}
if (HasE && HasI)
Exts.erase("i");
}
static constexpr StringLiteral CombineIntoExts[] = {