Skip to content

Commit 4f683b1

Browse files
authored
[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 8666ffd commit 4f683b1

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
@@ -833,19 +833,6 @@ static bool operator<(StringRef LHS, const ImpliedExtsEntry &RHS) {
833833
#include "llvm/TargetParser/RISCVTargetParserDef.inc"
834834

835835
void RISCVISAInfo::updateImplication() {
836-
bool HasE = Exts.count("e") != 0;
837-
bool HasI = Exts.count("i") != 0;
838-
839-
// If not in e extension and i extension does not exist, i extension is
840-
// implied
841-
if (!HasE && !HasI) {
842-
auto Version = findDefaultVersion("i");
843-
Exts["i"] = *Version;
844-
}
845-
846-
if (HasE && HasI)
847-
Exts.erase("i");
848-
849836
assert(llvm::is_sorted(ImpliedExts) && "Table not sorted by Name");
850837

851838
// This loop may execute over 1 iteration since implication can be layered
@@ -887,6 +874,21 @@ void RISCVISAInfo::updateImplication() {
887874
auto Version = findDefaultVersion("zcf");
888875
Exts["zcf"] = *Version;
889876
}
877+
878+
// Handle I/E after implications have been resolved, in case either
879+
// of them was implied by another extension.
880+
bool HasE = Exts.count("e") != 0;
881+
bool HasI = Exts.count("i") != 0;
882+
883+
// If not in e extension and i extension does not exist, i extension is
884+
// implied
885+
if (!HasE && !HasI) {
886+
auto Version = findDefaultVersion("i");
887+
Exts["i"] = *Version;
888+
}
889+
890+
if (HasE && HasI)
891+
Exts.erase("i");
890892
}
891893

892894
static constexpr StringLiteral CombineIntoExts[] = {

0 commit comments

Comments
 (0)