Skip to content

Commit 04ac4c8

Browse files
committed
[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.
1 parent 5254e71 commit 04ac4c8

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

llvm/lib/TargetParser/RISCVISAInfo.cpp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -802,19 +802,6 @@ static bool operator<(StringRef LHS, const ImpliedExtsEntry &RHS) {
802802
#include "llvm/TargetParser/RISCVTargetParserDef.inc"
803803

804804
void RISCVISAInfo::updateImplication() {
805-
bool HasE = Exts.count("e") != 0;
806-
bool HasI = Exts.count("i") != 0;
807-
808-
// If not in e extension and i extension does not exist, i extension is
809-
// implied
810-
if (!HasE && !HasI) {
811-
auto Version = findDefaultVersion("i");
812-
Exts["i"] = *Version;
813-
}
814-
815-
if (HasE && HasI)
816-
Exts.erase("i");
817-
818805
assert(llvm::is_sorted(ImpliedExts) && "Table not sorted by Name");
819806

820807
// This loop may execute over 1 iteration since implication can be layered
@@ -844,6 +831,21 @@ void RISCVISAInfo::updateImplication() {
844831
auto Version = findDefaultVersion("zcf");
845832
Exts["zcf"] = *Version;
846833
}
834+
835+
// Handle I/E after implications have been resolved, in case either
836+
// of them was implied by another extension.
837+
bool HasE = Exts.count("e") != 0;
838+
bool HasI = Exts.count("i") != 0;
839+
840+
// If not in e extension and i extension does not exist, i extension is
841+
// implied
842+
if (!HasE && !HasI) {
843+
auto Version = findDefaultVersion("i");
844+
Exts["i"] = *Version;
845+
}
846+
847+
if (HasE && HasI)
848+
Exts.erase("i");
847849
}
848850

849851
static constexpr StringLiteral CombineIntoExts[] = {

0 commit comments

Comments
 (0)