Skip to content

Commit 08969ca

Browse files
committed
[RISCV] Remove RISCVISAInfo::addExtension. NFC
We can edit the map directly at the caller. Many of the callers already directly call contains or erase on the map. So there's no good reason to have a wrapper for adding to the map.
1 parent bd32151 commit 08969ca

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

llvm/include/llvm/TargetParser/RISCVISAInfo.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ class RISCVISAInfo {
8787

8888
RISCVISAUtils::OrderedExtensionMap Exts;
8989

90-
bool addExtension(StringRef ExtName, RISCVISAUtils::ExtensionVersion Version);
91-
9290
Error checkDependency();
9391

9492
void updateImplication();

llvm/lib/TargetParser/RISCVISAInfo.cpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,6 @@ findDefaultVersion(StringRef ExtName) {
171171
return std::nullopt;
172172
}
173173

174-
bool RISCVISAInfo::addExtension(StringRef ExtName,
175-
RISCVISAUtils::ExtensionVersion Version) {
176-
return Exts.emplace(ExtName, Version).second;
177-
}
178-
179174
static StringRef getExtensionTypeDesc(StringRef Ext) {
180175
if (Ext.starts_with('s'))
181176
return "standard supervisor-level extension";
@@ -431,7 +426,7 @@ RISCVISAInfo::parseFeatures(unsigned XLen,
431426
continue;
432427

433428
if (Add)
434-
ISAInfo->addExtension(ExtName, ExtensionInfoIterator->Version);
429+
ISAInfo->Exts[ExtName.str()] = ExtensionInfoIterator->Version;
435430
else
436431
ISAInfo->Exts.erase(ExtName.str());
437432
}
@@ -513,7 +508,11 @@ RISCVISAInfo::parseNormalizedArchString(StringRef Arch) {
513508
"'" + Twine(ExtName[0]) +
514509
"' must be followed by a letter");
515510

516-
if (!ISAInfo->addExtension(ExtName, {MajorVersion, MinorVersion}))
511+
if (!ISAInfo->Exts
512+
.emplace(
513+
ExtName.str(),
514+
RISCVISAUtils::ExtensionVersion{MajorVersion, MinorVersion})
515+
.second)
517516
return createStringError(errc::invalid_argument,
518517
"duplicate extension '" + ExtName + "'");
519518
}
@@ -722,11 +721,10 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
722721
// Check all Extensions are supported.
723722
for (auto &SeenExtAndVers : SeenExtMap) {
724723
const std::string &ExtName = SeenExtAndVers.first;
725-
RISCVISAUtils::ExtensionVersion ExtVers = SeenExtAndVers.second;
726724

727725
if (!RISCVISAInfo::isSupportedExtension(ExtName))
728726
return getStringErrorForInvalidExt(ExtName);
729-
ISAInfo->addExtension(ExtName, ExtVers);
727+
ISAInfo->Exts[ExtName] = SeenExtAndVers.second;
730728
}
731729

732730
return RISCVISAInfo::postProcessAndChecking(std::move(ISAInfo));
@@ -830,7 +828,7 @@ void RISCVISAInfo::updateImplication() {
830828
// implied
831829
if (!HasE && !HasI) {
832830
auto Version = findDefaultVersion("i");
833-
addExtension("i", *Version);
831+
Exts["i"] = *Version;
834832
}
835833

836834
if (HasE && HasI)
@@ -854,7 +852,7 @@ void RISCVISAInfo::updateImplication() {
854852
if (Exts.count(ImpliedExt))
855853
return;
856854
auto Version = findDefaultVersion(ImpliedExt);
857-
addExtension(ImpliedExt, *Version);
855+
Exts[ImpliedExt] = *Version;
858856
WorkList.push_back(ImpliedExt);
859857
});
860858
}
@@ -863,7 +861,7 @@ void RISCVISAInfo::updateImplication() {
863861
if (XLen == 32 && Exts.count("zce") && Exts.count("f") &&
864862
!Exts.count("zcf")) {
865863
auto Version = findDefaultVersion("zcf");
866-
addExtension("zcf", *Version);
864+
Exts["zcf"] = *Version;
867865
}
868866
}
869867

@@ -890,7 +888,7 @@ void RISCVISAInfo::updateCombination() {
890888
});
891889
if (HasAllRequiredFeatures) {
892890
auto Version = findDefaultVersion(CombineExt);
893-
addExtension(CombineExt, *Version);
891+
Exts[CombineExt.str()] = *Version;
894892
MadeChange = true;
895893
}
896894
}

0 commit comments

Comments
 (0)